"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/extension.ts var extension_exports = {}; __export(extension_exports, { activate: () => activate, deactivate: () => deactivate }); module.exports = __toCommonJS(extension_exports); var vscode2 = __toESM(require("vscode")); // src/copyContext.ts var vscode = __toESM(require("vscode")); function formatFileContent(filePath) { return `[${filePath}]`; } function formatFileSelection(filePath, startLine, startCol, endLine, endCol) { const header = `${filePath} L${startLine}C${startCol}-L${endLine}C${endCol}`; return `[${header}]`; } function formatMultiFile(entries) { return entries.map((e) => formatFileContent(e.filePath)).join(""); } async function copySelection() { const editor = vscode.window.activeTextEditor; if (!editor) return; const selection = editor.selection; if (selection.isEmpty) return; const document = editor.document; const filePath = vscode.workspace.asRelativePath(document.uri); const startLine = selection.start.line + 1; const startCol = selection.start.character + 1; const endLine = selection.end.line + 1; const endCol = selection.end.character + 1; const result = formatFileSelection(filePath, startLine, startCol, endLine, endCol); await vscode.env.clipboard.writeText(result); showStatus(`$(clippy) Copied ${filePath}:${startLine}-${endLine}`); } async function copyActiveFile() { const editor = vscode.window.activeTextEditor; if (!editor) return; const document = editor.document; const filePath = vscode.workspace.asRelativePath(document.uri); const result = formatFileContent(filePath); await vscode.env.clipboard.writeText(result); showStatus(`$(clippy) Copied file: ${filePath}`); } async function copySingleItem(itemUri) { const itemPath = vscode.workspace.asRelativePath(itemUri); const result = `[${itemPath}]`; await vscode.env.clipboard.writeText(result); showStatus(`$(clippy) Copied: ${itemPath}`); } async function copyMultiFiles(selectedUris) { if (!selectedUris || selectedUris.length === 0) return; await copyFilesFromUris(selectedUris); } async function collectFilesRecursively(dirUri) { const result = []; const entries = await vscode.workspace.fs.readDirectory(dirUri); for (const [name, type] of entries) { const childUri = vscode.Uri.joinPath(dirUri, name); if (type === vscode.FileType.Directory) { const children = await collectFilesRecursively(childUri); result.push(...children); } else if (type === vscode.FileType.File) { result.push(childUri); } } return result; } async function copyFilesFromUris(uris) { const entries = []; for (const uri of uris) { let fileUris = [uri]; try { const stat = await vscode.workspace.fs.stat(uri); if (stat.type === vscode.FileType.Directory) { fileUris = await collectFilesRecursively(uri); } } catch { } for (const fu of fileUris) { entries.push({ filePath: vscode.workspace.asRelativePath(fu) }); } } if (entries.length === 0) return; const result = formatMultiFile(entries); await vscode.env.clipboard.writeText(result); showStatus(`$(clippy) Copied ${entries.length} file(s)`); } function showStatus(message) { vscode.window.setStatusBarMessage(message, 3e3); } // src/extension.ts function activate(context) { console.log("[copy-ai-ctx] activating..."); context.subscriptions.push( vscode2.commands.registerCommand("copy-ai-ctx.copySelection", () => { copySelection(); }) ); context.subscriptions.push( vscode2.commands.registerCommand("copy-ai-ctx.copyFile", () => { copyActiveFile(); }) ); context.subscriptions.push( vscode2.commands.registerCommand("copy-ai-ctx.copySelectedFiles", (args) => { if (!args) { const editor = vscode2.window.activeTextEditor; if (!editor) return; copySingleItem(editor.document.uri); return; } copySingleItem(args); }) ); context.subscriptions.push( vscode2.commands.registerCommand("copy-ai-ctx.copyMultiFiles", (...args) => { if (args.length < 2) { const editor = vscode2.window.activeTextEditor; if (!editor) return; copyMultiFiles([editor.document.uri]); return; } const resources = Array.isArray(args[1]) ? args[1] : args.slice(1); if (resources.length === 0) return; copyMultiFiles(resources); }) ); console.log("[copy-ai-ctx] activated"); } function deactivate() { } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { activate, deactivate }); //# sourceMappingURL=extension.js.map