@davstack/peek 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,355 @@
1
+ // src/index.ts
2
+ import { execFile } from "child_process";
3
+ import { mkdir, readdir, readFile, writeFile } from "fs/promises";
4
+ import path from "path";
5
+ import { promisify } from "util";
6
+ var GENERATED_PEEK_FILE = ".folder-peek.generated.md";
7
+ var execFileAsync = promisify(execFile);
8
+ var PEEK_OUTPUT_PRESETS = {
9
+ human: {
10
+ deep: true,
11
+ indent: true,
12
+ filePaths: "full"
13
+ },
14
+ agent: {
15
+ deep: true,
16
+ indent: false,
17
+ filePaths: "concise"
18
+ }
19
+ };
20
+ var SKIP_DIRS = /* @__PURE__ */ new Set([
21
+ ".git",
22
+ ".next",
23
+ "coverage",
24
+ "dist",
25
+ "dist-ssr",
26
+ "node_modules"
27
+ ]);
28
+ var SKIP_FILES = /* @__PURE__ */ new Set([GENERATED_PEEK_FILE]);
29
+ async function scanFolderPeek(folder, options = {}) {
30
+ const root = path.resolve(folder);
31
+ const repoRoot = await findRepoRoot(root);
32
+ const outputConfig = resolveOutputConfig(options);
33
+ const summary = await collectFolderSummary(root, repoRoot, root, outputConfig.deep, outputConfig);
34
+ return `${renderFolderSummary(summary, outputConfig)}
35
+ `;
36
+ }
37
+ async function generateFolderPeek(folder, options = {}) {
38
+ const root = path.resolve(folder);
39
+ const content = await scanFolderPeek(root, options);
40
+ const outPath = path.join(root, GENERATED_PEEK_FILE);
41
+ await mkdir(root, { recursive: true });
42
+ await writeFile(outPath, content, "utf8");
43
+ return { path: outPath, content };
44
+ }
45
+ async function peekFolder(folder, options = {}) {
46
+ const root = path.resolve(folder);
47
+ const generatedPath = path.join(root, GENERATED_PEEK_FILE);
48
+ try {
49
+ if (!options.deep && !hasOutputOverrides(options)) return await readFile(generatedPath, "utf8");
50
+ } catch (error) {
51
+ if (error.code !== "ENOENT") throw error;
52
+ }
53
+ return (await generateFolderPeek(root, options)).content;
54
+ }
55
+ async function collectFolderSummary(root, repoRoot, dir, deep, outputConfig) {
56
+ const entries = await readdir(dir, { withFileTypes: true });
57
+ const files = [];
58
+ const folders = [];
59
+ const omittedFiles = [];
60
+ for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
61
+ const fullPath = path.join(dir, entry.name);
62
+ if (await isGitIgnored(root, fullPath)) continue;
63
+ if (entry.isDirectory()) {
64
+ if (!deep || shouldSkipDirectory(entry.name)) continue;
65
+ folders.push(await collectFolderSummary(root, repoRoot, fullPath, deep, outputConfig));
66
+ continue;
67
+ }
68
+ if (!entry.isFile() || shouldSkipFile(entry.name)) continue;
69
+ const summary = await summarizeFile(root, repoRoot, fullPath, outputConfig);
70
+ if (summary) {
71
+ files.push(summary);
72
+ } else {
73
+ omittedFiles.push(entry.name);
74
+ }
75
+ }
76
+ return {
77
+ path: formatFolderPath(root, repoRoot, dir),
78
+ files: files.sort((a, b) => a.path.localeCompare(b.path)),
79
+ folders: folders.sort((a, b) => a.path.localeCompare(b.path)),
80
+ omittedFiles: omittedFiles.sort((a, b) => a.localeCompare(b))
81
+ };
82
+ }
83
+ function formatFolderPath(root, repoRoot, dir) {
84
+ const base = isInsidePath(repoRoot, dir) ? repoRoot : root;
85
+ const relativePath = toPosix(path.relative(base, dir));
86
+ return relativePath || ".";
87
+ }
88
+ function renderFolderSummary(summary, outputConfig, depth = 0) {
89
+ const indent = outputConfig.indent ? " ".repeat(Math.max(0, depth - 1)) : "";
90
+ const childIndent = outputConfig.indent ? " ".repeat(depth) : "";
91
+ const lines = [`${indent}<folder path="${escapeAttribute(summary.path)}">`];
92
+ for (const file of summary.files) {
93
+ lines.push(`${childIndent}<file path="${escapeAttribute(file.path)}">`);
94
+ for (const item of file.items) {
95
+ const prefix = item.startsWith("[ln ") ? "" : "- ";
96
+ lines.push(`${childIndent}${prefix}${item}`);
97
+ }
98
+ lines.push(`${childIndent}</file>`);
99
+ }
100
+ for (const folder of summary.folders) {
101
+ lines.push(renderFolderSummary(folder, outputConfig, depth + 1));
102
+ }
103
+ if (summary.omittedFiles.length > 0) {
104
+ lines.push(`${childIndent}<omitted_files>`);
105
+ for (const omittedFile of summary.omittedFiles) {
106
+ lines.push(`${childIndent}- ${escapeText(omittedFile)}`);
107
+ }
108
+ lines.push(`${childIndent}</omitted_files>`);
109
+ }
110
+ lines.push(`${indent}</folder>`);
111
+ return lines.join("\n");
112
+ }
113
+ async function summarizeFile(root, repoRoot, fullPath, outputConfig) {
114
+ const extension = path.extname(fullPath);
115
+ const relativePath = formatFilePath(root, repoRoot, fullPath, outputConfig.filePaths);
116
+ if (extension === ".md" || extension === ".mdx") {
117
+ const text = await readFile(fullPath, "utf8");
118
+ return { path: relativePath, kind: "markdown", items: extractMarkdownHeadings(text) };
119
+ }
120
+ if (isTypeScriptLikeFile(extension, fullPath)) {
121
+ const text = await readFile(fullPath, "utf8");
122
+ return { path: relativePath, kind: "typescript", items: extractTypeScriptSymbols(text) };
123
+ }
124
+ if (extension === ".py") {
125
+ const text = await readFile(fullPath, "utf8");
126
+ return { path: relativePath, kind: "python", items: extractPythonSymbols(text) };
127
+ }
128
+ return null;
129
+ }
130
+ function isTypeScriptLikeFile(extension, fullPath) {
131
+ return [".ts", ".tsx", ".mts", ".cts", ".js", ".mjs"].includes(extension) && !fullPath.endsWith(".d.ts");
132
+ }
133
+ function extractMarkdownHeadings(text) {
134
+ return text.split(/\r?\n/).map((line) => /^(#{1,6})\s+(.+?)\s*$/.exec(line)).filter((match) => match !== null).map((match) => `h${match[1].length} ${match[2].replace(/\s+#+$/, "").trim()}`);
135
+ }
136
+ function extractTypeScriptSymbols(text) {
137
+ const items = [];
138
+ const source = stripBlockComments(text);
139
+ const patterns = [
140
+ [/^(?:export\s+)?(?:abstract\s+)?class\s+([A-Za-z_$][\w$]*)/gm, "class"],
141
+ [/^(?:export\s+)?interface\s+([A-Za-z_$][\w$]*)/gm, "interface"],
142
+ [/^(?:export\s+)?type\s+([A-Za-z_$][\w$]*)\s*=/gm, "type"],
143
+ [/^(?:export\s+)?(?:declare\s+)?(?:const|let|var)\s+([A-Za-z_$][\w$]*)/gm, "const"],
144
+ [
145
+ /^(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)\s*\(/gm,
146
+ "function"
147
+ ]
148
+ ];
149
+ for (const [pattern, label] of patterns) {
150
+ for (const match of source.matchAll(pattern)) {
151
+ const range = lineRangeForTypeScriptSymbol(source, match.index ?? 0);
152
+ items.push(`${formatLineRange(range)} ${label} ${match[1]}`);
153
+ }
154
+ }
155
+ items.push(...extractTypeScriptTestCalls(source));
156
+ return unique(items);
157
+ }
158
+ function extractTypeScriptTestCalls(text) {
159
+ const items = [];
160
+ const pattern = /^\s*(describe|test|it)\s*\(\s*(['"`])((?:\\.|(?!\2)[\s\S])*?)\2/gm;
161
+ for (const match of text.matchAll(pattern)) {
162
+ const callName = match[1];
163
+ const quote = match[2];
164
+ const title = match[3];
165
+ const range = lineRangeForCallExpression(text, match.index ?? 0);
166
+ items.push(`${formatLineRange(range)} ${callName}(${quote}${title}${quote})`);
167
+ }
168
+ return items;
169
+ }
170
+ function extractPythonSymbols(text) {
171
+ const items = [];
172
+ const lines = text.split(/\r?\n/);
173
+ for (const [index, line] of lines.entries()) {
174
+ const lineNumber = index + 1;
175
+ let match = /^class\s+([A-Za-z_]\w*)\s*[:(]/.exec(line);
176
+ if (match) {
177
+ items.push(`${formatLineRange(lineRangeForPythonBlock(lines, index))} class ${match[1]}`);
178
+ continue;
179
+ }
180
+ match = /^(?:async\s+)?def\s+([A-Za-z_]\w*)\s*\(/.exec(line);
181
+ if (match) {
182
+ items.push(`${formatLineRange(lineRangeForPythonBlock(lines, index))} function ${match[1]}`);
183
+ continue;
184
+ }
185
+ match = /^([A-Z][A-Z0-9_]*)\s*[:=]/.exec(line);
186
+ if (match) items.push(`${formatLineRange({ start: lineNumber, end: lineNumber })} const ${match[1]}`);
187
+ }
188
+ return unique(items);
189
+ }
190
+ function shouldSkipDirectory(name) {
191
+ return SKIP_DIRS.has(name);
192
+ }
193
+ function shouldSkipFile(name) {
194
+ return SKIP_FILES.has(name) || name.endsWith(".map");
195
+ }
196
+ function stripBlockComments(text) {
197
+ return text.replace(
198
+ /\/\*[\s\S]*?\*\//g,
199
+ (comment) => comment.replace(/[^\r\n]/g, " ")
200
+ );
201
+ }
202
+ function unique(items) {
203
+ return Array.from(new Set(items));
204
+ }
205
+ function lineNumberAt(text, index) {
206
+ let lineNumber = 1;
207
+ for (let offset = 0; offset < index; offset += 1) {
208
+ if (text.charCodeAt(offset) === 10) lineNumber += 1;
209
+ }
210
+ return lineNumber;
211
+ }
212
+ function lineRangeForTypeScriptSymbol(text, index) {
213
+ const start = lineNumberAt(text, index);
214
+ const lineEnd = text.indexOf("\n", index);
215
+ const declarationEnd = lineEnd === -1 ? text.length : lineEnd;
216
+ const openingBrace = text.indexOf("{", index);
217
+ if (openingBrace !== -1 && openingBrace < declarationEnd) {
218
+ const closingBrace = findMatchingBrace(text, openingBrace);
219
+ if (closingBrace !== -1) return { start, end: lineNumberAt(text, closingBrace) };
220
+ }
221
+ const semicolon = text.indexOf(";", index);
222
+ if (semicolon !== -1 && semicolon < declarationEnd) {
223
+ return { start, end: lineNumberAt(text, semicolon) };
224
+ }
225
+ return { start, end: start };
226
+ }
227
+ function findMatchingBrace(text, openingBrace) {
228
+ let depth = 0;
229
+ for (let index = openingBrace; index < text.length; index += 1) {
230
+ const char = text[index];
231
+ if (char === "{") depth += 1;
232
+ if (char === "}") {
233
+ depth -= 1;
234
+ if (depth === 0) return index;
235
+ }
236
+ }
237
+ return -1;
238
+ }
239
+ function lineRangeForCallExpression(text, index) {
240
+ const start = lineNumberAt(text, index);
241
+ const openingParen = text.indexOf("(", index);
242
+ if (openingParen === -1) return { start, end: start };
243
+ const closingParen = findMatchingParen(text, openingParen);
244
+ if (closingParen === -1) return { start, end: start };
245
+ return { start, end: lineNumberAt(text, closingParen) };
246
+ }
247
+ function findMatchingParen(text, openingParen) {
248
+ let depth = 0;
249
+ let quote = null;
250
+ for (let index = openingParen; index < text.length; index += 1) {
251
+ const char = text[index];
252
+ if (quote) {
253
+ if (char === "\\") {
254
+ index += 1;
255
+ continue;
256
+ }
257
+ if (char === quote) quote = null;
258
+ continue;
259
+ }
260
+ if (char === '"' || char === "'" || char === "`") {
261
+ quote = char;
262
+ continue;
263
+ }
264
+ if (char === "(") depth += 1;
265
+ if (char === ")") {
266
+ depth -= 1;
267
+ if (depth === 0) return index;
268
+ }
269
+ }
270
+ return -1;
271
+ }
272
+ function lineRangeForPythonBlock(lines, startIndex) {
273
+ const startIndent = indentationLength(lines[startIndex] ?? "");
274
+ let endIndex = startIndex;
275
+ for (let index = startIndex + 1; index < lines.length; index += 1) {
276
+ const line = lines[index] ?? "";
277
+ if (line.trim() === "") {
278
+ endIndex = index;
279
+ continue;
280
+ }
281
+ if (indentationLength(line) <= startIndent) break;
282
+ endIndex = index;
283
+ }
284
+ while (endIndex > startIndex && (lines[endIndex] ?? "").trim() === "") endIndex -= 1;
285
+ return { start: startIndex + 1, end: endIndex + 1 };
286
+ }
287
+ function indentationLength(line) {
288
+ return line.match(/^\s*/)?.[0].length ?? 0;
289
+ }
290
+ function formatLineRange(range) {
291
+ return range.start === range.end ? `[ln ${range.start}]` : `[ln ${range.start}-${range.end}]`;
292
+ }
293
+ function formatFilePath(root, repoRoot, fullPath, filePaths) {
294
+ if (filePaths === "concise") return `/${path.basename(fullPath)}`;
295
+ const base = isInsidePath(repoRoot, fullPath) ? repoRoot : root;
296
+ return toPosix(path.relative(base, fullPath));
297
+ }
298
+ function resolveOutputConfig(options) {
299
+ const presetName = options.preset ?? "human";
300
+ const preset = PEEK_OUTPUT_PRESETS[presetName];
301
+ if (!preset) throw new Error(`Unknown peek output preset: ${presetName}`);
302
+ return {
303
+ deep: options.deep ?? preset.deep,
304
+ indent: options.indent ?? preset.indent,
305
+ filePaths: normalizeFilePathMode(options.filePaths ?? options.file_paths ?? preset.filePaths)
306
+ };
307
+ }
308
+ function normalizeFilePathMode(value) {
309
+ if (value === "concise" || value === "full") return value;
310
+ throw new Error(`Unknown peek file path mode: ${String(value)}`);
311
+ }
312
+ function hasOutputOverrides(options) {
313
+ return options.preset !== void 0 || options.indent !== void 0 || options.filePaths !== void 0 || options.file_paths !== void 0;
314
+ }
315
+ function isInsidePath(parent, child) {
316
+ const relativePath = path.relative(parent, child);
317
+ return relativePath === "" || !relativePath.startsWith("..") && !path.isAbsolute(relativePath);
318
+ }
319
+ function toPosix(value) {
320
+ return value.split(path.sep).join("/");
321
+ }
322
+ function escapeAttribute(value) {
323
+ return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;");
324
+ }
325
+ function escapeText(value) {
326
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;");
327
+ }
328
+ async function isGitIgnored(root, fullPath) {
329
+ const relativePath = toPosix(path.relative(root, fullPath));
330
+ if (!relativePath || relativePath.startsWith("..")) return false;
331
+ try {
332
+ await execFileAsync("git", ["-C", root, "check-ignore", "--quiet", "--", relativePath]);
333
+ return true;
334
+ } catch (error) {
335
+ const code = error.code;
336
+ if (code === 1 || code === 128 || code === "ENOENT") return false;
337
+ return false;
338
+ }
339
+ }
340
+ async function findRepoRoot(root) {
341
+ try {
342
+ const { stdout } = await execFileAsync("git", ["-C", root, "rev-parse", "--show-toplevel"]);
343
+ return path.resolve(stdout.trim());
344
+ } catch {
345
+ return root;
346
+ }
347
+ }
348
+ export {
349
+ GENERATED_PEEK_FILE,
350
+ PEEK_OUTPUT_PRESETS,
351
+ generateFolderPeek,
352
+ peekFolder,
353
+ scanFolderPeek
354
+ };
355
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { execFile } from 'node:child_process';\nimport { mkdir, readdir, readFile, writeFile } from 'node:fs/promises';\nimport path from 'node:path';\nimport { promisify } from 'node:util';\n\nexport const GENERATED_PEEK_FILE = '.folder-peek.generated.md';\nconst execFileAsync = promisify(execFile);\n\nexport type ScanOptions = {\n deep?: boolean;\n preset?: PeekOutputPresetName;\n indent?: boolean;\n filePaths?: PeekFilePathMode;\n file_paths?: PeekFilePathMode;\n};\n\ntype FileSummary = {\n path: string;\n kind: 'markdown' | 'typescript' | 'python';\n items: string[];\n};\n\nexport type PeekFilePathMode = 'concise' | 'full';\nexport type PeekOutputPresetName = 'agent' | 'human';\n\nexport type PeekOutputConfig = {\n deep: boolean;\n indent: boolean;\n filePaths: PeekFilePathMode;\n};\n\nexport const PEEK_OUTPUT_PRESETS: Record<PeekOutputPresetName, PeekOutputConfig> = {\n human: {\n deep: true,\n indent: true,\n filePaths: 'full',\n },\n agent: {\n deep: true,\n indent: false,\n filePaths: 'concise',\n },\n};\n\ntype FolderSummary = {\n path: string;\n files: FileSummary[];\n folders: FolderSummary[];\n omittedFiles: string[];\n};\n\nconst SKIP_DIRS = new Set([\n '.git',\n '.next',\n 'coverage',\n 'dist',\n 'dist-ssr',\n 'node_modules',\n]);\n\nconst SKIP_FILES = new Set([GENERATED_PEEK_FILE]);\n\nexport async function scanFolderPeek(folder: string, options: ScanOptions = {}): Promise<string> {\n const root = path.resolve(folder);\n const repoRoot = await findRepoRoot(root);\n const outputConfig = resolveOutputConfig(options);\n const summary = await collectFolderSummary(root, repoRoot, root, outputConfig.deep, outputConfig);\n\n return `${renderFolderSummary(summary, outputConfig)}\\n`;\n}\n\nexport async function generateFolderPeek(\n folder: string,\n options: ScanOptions = {},\n): Promise<{ path: string; content: string }> {\n const root = path.resolve(folder);\n const content = await scanFolderPeek(root, options);\n const outPath = path.join(root, GENERATED_PEEK_FILE);\n await mkdir(root, { recursive: true });\n await writeFile(outPath, content, 'utf8');\n return { path: outPath, content };\n}\n\nexport async function peekFolder(folder: string, options: ScanOptions = {}): Promise<string> {\n const root = path.resolve(folder);\n const generatedPath = path.join(root, GENERATED_PEEK_FILE);\n try {\n if (!options.deep && !hasOutputOverrides(options)) return await readFile(generatedPath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;\n }\n return (await generateFolderPeek(root, options)).content;\n}\n\nasync function collectFolderSummary(\n root: string,\n repoRoot: string,\n dir: string,\n deep: boolean,\n outputConfig: PeekOutputConfig,\n): Promise<FolderSummary> {\n const entries = await readdir(dir, { withFileTypes: true });\n const files: FileSummary[] = [];\n const folders: FolderSummary[] = [];\n const omittedFiles: string[] = [];\n\n for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {\n const fullPath = path.join(dir, entry.name);\n if (await isGitIgnored(root, fullPath)) continue;\n\n if (entry.isDirectory()) {\n if (!deep || shouldSkipDirectory(entry.name)) continue;\n folders.push(await collectFolderSummary(root, repoRoot, fullPath, deep, outputConfig));\n continue;\n }\n if (!entry.isFile() || shouldSkipFile(entry.name)) continue;\n\n const summary = await summarizeFile(root, repoRoot, fullPath, outputConfig);\n if (summary) {\n files.push(summary);\n } else {\n omittedFiles.push(entry.name);\n }\n }\n\n return {\n path: formatFolderPath(root, repoRoot, dir),\n files: files.sort((a, b) => a.path.localeCompare(b.path)),\n folders: folders.sort((a, b) => a.path.localeCompare(b.path)),\n omittedFiles: omittedFiles.sort((a, b) => a.localeCompare(b)),\n };\n}\n\nfunction formatFolderPath(root: string, repoRoot: string, dir: string): string {\n const base = isInsidePath(repoRoot, dir) ? repoRoot : root;\n const relativePath = toPosix(path.relative(base, dir));\n return relativePath || '.';\n}\n\nfunction renderFolderSummary(\n summary: FolderSummary,\n outputConfig: PeekOutputConfig,\n depth = 0,\n): string {\n const indent = outputConfig.indent ? '\\t'.repeat(Math.max(0, depth - 1)) : '';\n const childIndent = outputConfig.indent ? '\\t'.repeat(depth) : '';\n const lines = [`${indent}<folder path=\"${escapeAttribute(summary.path)}\">`];\n\n for (const file of summary.files) {\n lines.push(`${childIndent}<file path=\"${escapeAttribute(file.path)}\">`);\n for (const item of file.items) {\n const prefix = item.startsWith('[ln ') ? '' : '- ';\n lines.push(`${childIndent}${prefix}${item}`);\n }\n lines.push(`${childIndent}</file>`);\n }\n\n for (const folder of summary.folders) {\n lines.push(renderFolderSummary(folder, outputConfig, depth + 1));\n }\n\n if (summary.omittedFiles.length > 0) {\n lines.push(`${childIndent}<omitted_files>`);\n for (const omittedFile of summary.omittedFiles) {\n lines.push(`${childIndent}- ${escapeText(omittedFile)}`);\n }\n lines.push(`${childIndent}</omitted_files>`);\n }\n\n lines.push(`${indent}</folder>`);\n return lines.join('\\n');\n}\n\nasync function summarizeFile(\n root: string,\n repoRoot: string,\n fullPath: string,\n outputConfig: PeekOutputConfig,\n): Promise<FileSummary | null> {\n const extension = path.extname(fullPath);\n const relativePath = formatFilePath(root, repoRoot, fullPath, outputConfig.filePaths);\n\n if (extension === '.md' || extension === '.mdx') {\n const text = await readFile(fullPath, 'utf8');\n return { path: relativePath, kind: 'markdown', items: extractMarkdownHeadings(text) };\n }\n if (isTypeScriptLikeFile(extension, fullPath)) {\n const text = await readFile(fullPath, 'utf8');\n return { path: relativePath, kind: 'typescript', items: extractTypeScriptSymbols(text) };\n }\n if (extension === '.py') {\n const text = await readFile(fullPath, 'utf8');\n return { path: relativePath, kind: 'python', items: extractPythonSymbols(text) };\n }\n return null;\n}\n\nfunction isTypeScriptLikeFile(extension: string, fullPath: string): boolean {\n return ['.ts', '.tsx', '.mts', '.cts', '.js', '.mjs'].includes(extension) && !fullPath.endsWith('.d.ts');\n}\n\nfunction extractMarkdownHeadings(text: string): string[] {\n return text\n .split(/\\r?\\n/)\n .map((line) => /^(#{1,6})\\s+(.+?)\\s*$/.exec(line))\n .filter((match): match is RegExpExecArray => match !== null)\n .map((match) => `h${match[1].length} ${match[2].replace(/\\s+#+$/, '').trim()}`);\n}\n\nfunction extractTypeScriptSymbols(text: string): string[] {\n const items: string[] = [];\n const source = stripBlockComments(text);\n const patterns: Array<[RegExp, string]> = [\n [/^(?:export\\s+)?(?:abstract\\s+)?class\\s+([A-Za-z_$][\\w$]*)/gm, 'class'],\n [/^(?:export\\s+)?interface\\s+([A-Za-z_$][\\w$]*)/gm, 'interface'],\n [/^(?:export\\s+)?type\\s+([A-Za-z_$][\\w$]*)\\s*=/gm, 'type'],\n [/^(?:export\\s+)?(?:declare\\s+)?(?:const|let|var)\\s+([A-Za-z_$][\\w$]*)/gm, 'const'],\n [\n /^(?:export\\s+)?(?:async\\s+)?function\\s+([A-Za-z_$][\\w$]*)\\s*\\(/gm,\n 'function',\n ],\n ];\n\n for (const [pattern, label] of patterns) {\n for (const match of source.matchAll(pattern)) {\n const range = lineRangeForTypeScriptSymbol(source, match.index ?? 0);\n items.push(`${formatLineRange(range)} ${label} ${match[1]}`);\n }\n }\n items.push(...extractTypeScriptTestCalls(source));\n return unique(items);\n}\n\nfunction extractTypeScriptTestCalls(text: string): string[] {\n const items: string[] = [];\n const pattern = /^\\s*(describe|test|it)\\s*\\(\\s*(['\"`])((?:\\\\.|(?!\\2)[\\s\\S])*?)\\2/gm;\n\n for (const match of text.matchAll(pattern)) {\n const callName = match[1];\n const quote = match[2];\n const title = match[3];\n const range = lineRangeForCallExpression(text, match.index ?? 0);\n items.push(`${formatLineRange(range)} ${callName}(${quote}${title}${quote})`);\n }\n\n return items;\n}\n\nfunction extractPythonSymbols(text: string): string[] {\n const items: string[] = [];\n const lines = text.split(/\\r?\\n/);\n for (const [index, line] of lines.entries()) {\n const lineNumber = index + 1;\n let match = /^class\\s+([A-Za-z_]\\w*)\\s*[:(]/.exec(line);\n if (match) {\n items.push(`${formatLineRange(lineRangeForPythonBlock(lines, index))} class ${match[1]}`);\n continue;\n }\n match = /^(?:async\\s+)?def\\s+([A-Za-z_]\\w*)\\s*\\(/.exec(line);\n if (match) {\n items.push(`${formatLineRange(lineRangeForPythonBlock(lines, index))} function ${match[1]}`);\n continue;\n }\n match = /^([A-Z][A-Z0-9_]*)\\s*[:=]/.exec(line);\n if (match) items.push(`${formatLineRange({ start: lineNumber, end: lineNumber })} const ${match[1]}`);\n }\n return unique(items);\n}\n\nfunction shouldSkipDirectory(name: string): boolean {\n return SKIP_DIRS.has(name);\n}\n\nfunction shouldSkipFile(name: string): boolean {\n return SKIP_FILES.has(name) || name.endsWith('.map');\n}\n\nfunction stripBlockComments(text: string): string {\n return text.replace(/\\/\\*[\\s\\S]*?\\*\\//g, (comment) =>\n comment.replace(/[^\\r\\n]/g, ' '),\n );\n}\n\nfunction unique(items: string[]): string[] {\n return Array.from(new Set(items));\n}\n\nfunction lineNumberAt(text: string, index: number): number {\n let lineNumber = 1;\n for (let offset = 0; offset < index; offset += 1) {\n if (text.charCodeAt(offset) === 10) lineNumber += 1;\n }\n return lineNumber;\n}\n\nfunction lineRangeForTypeScriptSymbol(text: string, index: number): { start: number; end: number } {\n const start = lineNumberAt(text, index);\n const lineEnd = text.indexOf('\\n', index);\n const declarationEnd = lineEnd === -1 ? text.length : lineEnd;\n const openingBrace = text.indexOf('{', index);\n\n if (openingBrace !== -1 && openingBrace < declarationEnd) {\n const closingBrace = findMatchingBrace(text, openingBrace);\n if (closingBrace !== -1) return { start, end: lineNumberAt(text, closingBrace) };\n }\n\n const semicolon = text.indexOf(';', index);\n if (semicolon !== -1 && semicolon < declarationEnd) {\n return { start, end: lineNumberAt(text, semicolon) };\n }\n\n return { start, end: start };\n}\n\nfunction findMatchingBrace(text: string, openingBrace: number): number {\n let depth = 0;\n for (let index = openingBrace; index < text.length; index += 1) {\n const char = text[index];\n if (char === '{') depth += 1;\n if (char === '}') {\n depth -= 1;\n if (depth === 0) return index;\n }\n }\n return -1;\n}\n\nfunction lineRangeForCallExpression(text: string, index: number): { start: number; end: number } {\n const start = lineNumberAt(text, index);\n const openingParen = text.indexOf('(', index);\n if (openingParen === -1) return { start, end: start };\n\n const closingParen = findMatchingParen(text, openingParen);\n if (closingParen === -1) return { start, end: start };\n return { start, end: lineNumberAt(text, closingParen) };\n}\n\nfunction findMatchingParen(text: string, openingParen: number): number {\n let depth = 0;\n let quote: string | null = null;\n\n for (let index = openingParen; index < text.length; index += 1) {\n const char = text[index];\n if (quote) {\n if (char === '\\\\') {\n index += 1;\n continue;\n }\n if (char === quote) quote = null;\n continue;\n }\n if (char === '\"' || char === \"'\" || char === '`') {\n quote = char;\n continue;\n }\n if (char === '(') depth += 1;\n if (char === ')') {\n depth -= 1;\n if (depth === 0) return index;\n }\n }\n return -1;\n}\n\nfunction lineRangeForPythonBlock(\n lines: string[],\n startIndex: number,\n): { start: number; end: number } {\n const startIndent = indentationLength(lines[startIndex] ?? '');\n let endIndex = startIndex;\n\n for (let index = startIndex + 1; index < lines.length; index += 1) {\n const line = lines[index] ?? '';\n if (line.trim() === '') {\n endIndex = index;\n continue;\n }\n if (indentationLength(line) <= startIndent) break;\n endIndex = index;\n }\n\n while (endIndex > startIndex && (lines[endIndex] ?? '').trim() === '') endIndex -= 1;\n return { start: startIndex + 1, end: endIndex + 1 };\n}\n\nfunction indentationLength(line: string): number {\n return line.match(/^\\s*/)?.[0].length ?? 0;\n}\n\nfunction formatLineRange(range: { start: number; end: number }): string {\n return range.start === range.end ? `[ln ${range.start}]` : `[ln ${range.start}-${range.end}]`;\n}\n\nfunction formatFilePath(\n root: string,\n repoRoot: string,\n fullPath: string,\n filePaths: PeekFilePathMode,\n): string {\n if (filePaths === 'concise') return `/${path.basename(fullPath)}`;\n const base = isInsidePath(repoRoot, fullPath) ? repoRoot : root;\n return toPosix(path.relative(base, fullPath));\n}\n\nfunction resolveOutputConfig(options: ScanOptions): PeekOutputConfig {\n const presetName = options.preset ?? 'human';\n const preset = PEEK_OUTPUT_PRESETS[presetName];\n if (!preset) throw new Error(`Unknown peek output preset: ${presetName}`);\n\n return {\n deep: options.deep ?? preset.deep,\n indent: options.indent ?? preset.indent,\n filePaths: normalizeFilePathMode(options.filePaths ?? options.file_paths ?? preset.filePaths),\n };\n}\n\nfunction normalizeFilePathMode(value: PeekFilePathMode): PeekFilePathMode {\n if (value === 'concise' || value === 'full') return value;\n throw new Error(`Unknown peek file path mode: ${String(value)}`);\n}\n\nfunction hasOutputOverrides(options: ScanOptions): boolean {\n return (\n options.preset !== undefined ||\n options.indent !== undefined ||\n options.filePaths !== undefined ||\n options.file_paths !== undefined\n );\n}\n\nfunction isInsidePath(parent: string, child: string): boolean {\n const relativePath = path.relative(parent, child);\n return relativePath === '' || (!relativePath.startsWith('..') && !path.isAbsolute(relativePath));\n}\n\nfunction toPosix(value: string): string {\n return value.split(path.sep).join('/');\n}\n\nfunction escapeAttribute(value: string): string {\n return value.replace(/&/g, '&amp;').replace(/\"/g, '&quot;');\n}\n\nfunction escapeText(value: string): string {\n return value.replace(/&/g, '&amp;').replace(/</g, '&lt;');\n}\n\nasync function isGitIgnored(root: string, fullPath: string): Promise<boolean> {\n const relativePath = toPosix(path.relative(root, fullPath));\n if (!relativePath || relativePath.startsWith('..')) return false;\n\n try {\n await execFileAsync('git', ['-C', root, 'check-ignore', '--quiet', '--', relativePath]);\n return true;\n } catch (error) {\n const code = (error as { code?: number | string }).code;\n if (code === 1 || code === 128 || code === 'ENOENT') return false;\n return false;\n }\n}\n\nasync function findRepoRoot(root: string): Promise<string> {\n try {\n const { stdout } = await execFileAsync('git', ['-C', root, 'rev-parse', '--show-toplevel']);\n return path.resolve(stdout.trim());\n } catch {\n return root;\n }\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,OAAO,SAAS,UAAU,iBAAiB;AACpD,OAAO,UAAU;AACjB,SAAS,iBAAiB;AAEnB,IAAM,sBAAsB;AACnC,IAAM,gBAAgB,UAAU,QAAQ;AAyBjC,IAAM,sBAAsE;AAAA,EACjF,OAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,WAAW;AAAA,EACb;AAAA,EACA,OAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,WAAW;AAAA,EACb;AACF;AASA,IAAM,YAAY,oBAAI,IAAI;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,aAAa,oBAAI,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AAgB,OAAuB;AAC9C,SAAO,MAAM,QAAQ,MAAM,OAAO,EAAE,QAAQ,MAAM,QAAQ;AAC5D;AAEA,SAAS,WAAW,OAAuB;AACzC,SAAO,MAAM,QAAQ,MAAM,OAAO,EAAE,QAAQ,MAAM,MAAM;AAC1D;AAEA,eAAe,aAAa,MAAc,UAAoC;AAC5E,QAAM,eAAe,QAAQ,KAAK,SAAS,MAAM,QAAQ,CAAC;AAC1D,MAAI,CAAC,gBAAgB,aAAa,WAAW,IAAI,EAAG,QAAO;AAE3D,MAAI;AACF,UAAM,cAAc,OAAO,CAAC,MAAM,MAAM,gBAAgB,WAAW,MAAM,YAAY,CAAC;AACtF,WAAO;AAAA,EACT,SAAS,OAAO;AACd,UAAM,OAAQ,MAAqC;AACnD,QAAI,SAAS,KAAK,SAAS,OAAO,SAAS,SAAU,QAAO;AAC5D,WAAO;AAAA,EACT;AACF;AAEA,eAAe,aAAa,MAA+B;AACzD,MAAI;AACF,UAAM,EAAE,OAAO,IAAI,MAAM,cAAc,OAAO,CAAC,MAAM,MAAM,aAAa,iBAAiB,CAAC;AAC1F,WAAO,KAAK,QAAQ,OAAO,KAAK,CAAC;AAAA,EACnC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@davstack/peek",
3
+ "version": "0.1.0",
4
+ "license": "MIT",
5
+ "type": "module",
6
+ "description": "Peek at concise, agent-friendly folder summaries.",
7
+ "bin": {
8
+ "peek": "./bin/davstack-peek.mjs"
9
+ },
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "./cli-spec": {
16
+ "types": "./dist/cli-spec.d.ts",
17
+ "default": "./dist/cli-spec.js"
18
+ }
19
+ },
20
+ "files": [
21
+ "bin/**",
22
+ "dist/**",
23
+ "README.md"
24
+ ],
25
+ "engines": {
26
+ "node": ">=20"
27
+ },
28
+ "dependencies": {
29
+ "@davstack/cli-utils": "1.3.1"
30
+ },
31
+ "devDependencies": {
32
+ "@types/node": "^25.9.1",
33
+ "tsup": "^8.0.0",
34
+ "typescript": "^5.0.0"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "scripts": {
40
+ "build": "tsup",
41
+ "test": "pnpm -w exec vitest run --project peek"
42
+ }
43
+ }