agents-reverse-engineer 0.3.6 → 0.4.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.
Files changed (156) hide show
  1. package/dist/ai/backends/claude.d.ts +92 -0
  2. package/dist/ai/backends/claude.d.ts.map +1 -0
  3. package/dist/ai/backends/claude.js +213 -0
  4. package/dist/ai/backends/claude.js.map +1 -0
  5. package/dist/ai/backends/gemini.d.ts +53 -0
  6. package/dist/ai/backends/gemini.d.ts.map +1 -0
  7. package/dist/ai/backends/gemini.js +66 -0
  8. package/dist/ai/backends/gemini.js.map +1 -0
  9. package/dist/ai/backends/opencode.d.ts +53 -0
  10. package/dist/ai/backends/opencode.d.ts.map +1 -0
  11. package/dist/ai/backends/opencode.js +66 -0
  12. package/dist/ai/backends/opencode.js.map +1 -0
  13. package/dist/ai/index.d.ts +39 -0
  14. package/dist/ai/index.d.ts.map +1 -0
  15. package/dist/ai/index.js +54 -0
  16. package/dist/ai/index.js.map +1 -0
  17. package/dist/ai/pricing.d.ts +84 -0
  18. package/dist/ai/pricing.d.ts.map +1 -0
  19. package/dist/ai/pricing.js +149 -0
  20. package/dist/ai/pricing.js.map +1 -0
  21. package/dist/ai/pricing.test.d.ts +2 -0
  22. package/dist/ai/pricing.test.d.ts.map +1 -0
  23. package/dist/ai/pricing.test.js +164 -0
  24. package/dist/ai/pricing.test.js.map +1 -0
  25. package/dist/ai/registry.d.ts +128 -0
  26. package/dist/ai/registry.d.ts.map +1 -0
  27. package/dist/ai/registry.js +192 -0
  28. package/dist/ai/registry.js.map +1 -0
  29. package/dist/ai/retry.d.ts +77 -0
  30. package/dist/ai/retry.d.ts.map +1 -0
  31. package/dist/ai/retry.js +100 -0
  32. package/dist/ai/retry.js.map +1 -0
  33. package/dist/ai/service.d.ts +124 -0
  34. package/dist/ai/service.d.ts.map +1 -0
  35. package/dist/ai/service.js +239 -0
  36. package/dist/ai/service.js.map +1 -0
  37. package/dist/ai/subprocess.d.ts +45 -0
  38. package/dist/ai/subprocess.d.ts.map +1 -0
  39. package/dist/ai/subprocess.js +90 -0
  40. package/dist/ai/subprocess.js.map +1 -0
  41. package/dist/ai/telemetry/cleanup.d.ts +30 -0
  42. package/dist/ai/telemetry/cleanup.d.ts.map +1 -0
  43. package/dist/ai/telemetry/cleanup.js +56 -0
  44. package/dist/ai/telemetry/cleanup.js.map +1 -0
  45. package/dist/ai/telemetry/logger.d.ts +76 -0
  46. package/dist/ai/telemetry/logger.d.ts.map +1 -0
  47. package/dist/ai/telemetry/logger.js +130 -0
  48. package/dist/ai/telemetry/logger.js.map +1 -0
  49. package/dist/ai/telemetry/run-log.d.ts +29 -0
  50. package/dist/ai/telemetry/run-log.d.ts.map +1 -0
  51. package/dist/ai/telemetry/run-log.js +43 -0
  52. package/dist/ai/telemetry/run-log.js.map +1 -0
  53. package/dist/ai/types.d.ts +235 -0
  54. package/dist/ai/types.d.ts.map +1 -0
  55. package/dist/ai/types.js +34 -0
  56. package/dist/ai/types.js.map +1 -0
  57. package/dist/cli/discover.d.ts.map +1 -1
  58. package/dist/cli/discover.js +0 -2
  59. package/dist/cli/discover.js.map +1 -1
  60. package/dist/cli/generate.d.ts +22 -14
  61. package/dist/cli/generate.d.ts.map +1 -1
  62. package/dist/cli/generate.js +91 -50
  63. package/dist/cli/generate.js.map +1 -1
  64. package/dist/cli/index.js +12 -3
  65. package/dist/cli/index.js.map +1 -1
  66. package/dist/cli/update.d.ts +13 -4
  67. package/dist/cli/update.d.ts.map +1 -1
  68. package/dist/cli/update.js +93 -131
  69. package/dist/cli/update.js.map +1 -1
  70. package/dist/config/defaults.d.ts +2 -2
  71. package/dist/config/defaults.d.ts.map +1 -1
  72. package/dist/config/defaults.js +2 -0
  73. package/dist/config/defaults.js.map +1 -1
  74. package/dist/config/schema.d.ts +175 -1
  75. package/dist/config/schema.d.ts.map +1 -1
  76. package/dist/config/schema.js +36 -1
  77. package/dist/config/schema.js.map +1 -1
  78. package/dist/generation/executor.d.ts.map +1 -1
  79. package/dist/generation/executor.js +2 -5
  80. package/dist/generation/executor.js.map +1 -1
  81. package/dist/generation/prompts/builder.d.ts +10 -0
  82. package/dist/generation/prompts/builder.d.ts.map +1 -1
  83. package/dist/generation/prompts/builder.js +77 -1
  84. package/dist/generation/prompts/builder.js.map +1 -1
  85. package/dist/generation/prompts/index.d.ts +1 -1
  86. package/dist/generation/prompts/index.d.ts.map +1 -1
  87. package/dist/generation/prompts/index.js +1 -1
  88. package/dist/generation/prompts/index.js.map +1 -1
  89. package/dist/generation/prompts/templates.d.ts +5 -0
  90. package/dist/generation/prompts/templates.d.ts.map +1 -1
  91. package/dist/generation/prompts/templates.js +94 -7
  92. package/dist/generation/prompts/templates.js.map +1 -1
  93. package/dist/generation/prompts/types.d.ts +2 -2
  94. package/dist/generation/prompts/types.js +1 -1
  95. package/dist/generation/writers/agents-md.d.ts +3 -59
  96. package/dist/generation/writers/agents-md.d.ts.map +1 -1
  97. package/dist/generation/writers/agents-md.js +11 -249
  98. package/dist/generation/writers/agents-md.js.map +1 -1
  99. package/dist/generation/writers/index.d.ts +1 -1
  100. package/dist/generation/writers/index.d.ts.map +1 -1
  101. package/dist/generation/writers/index.js +1 -1
  102. package/dist/generation/writers/index.js.map +1 -1
  103. package/dist/orchestration/index.d.ts +27 -0
  104. package/dist/orchestration/index.d.ts.map +1 -0
  105. package/dist/orchestration/index.js +34 -0
  106. package/dist/orchestration/index.js.map +1 -0
  107. package/dist/orchestration/pool.d.ts +62 -0
  108. package/dist/orchestration/pool.d.ts.map +1 -0
  109. package/dist/orchestration/pool.js +75 -0
  110. package/dist/orchestration/pool.js.map +1 -0
  111. package/dist/orchestration/progress.d.ts +124 -0
  112. package/dist/orchestration/progress.d.ts.map +1 -0
  113. package/dist/orchestration/progress.js +214 -0
  114. package/dist/orchestration/progress.js.map +1 -0
  115. package/dist/orchestration/runner.d.ts +76 -0
  116. package/dist/orchestration/runner.d.ts.map +1 -0
  117. package/dist/orchestration/runner.js +494 -0
  118. package/dist/orchestration/runner.js.map +1 -0
  119. package/dist/orchestration/types.d.ts +123 -0
  120. package/dist/orchestration/types.d.ts.map +1 -0
  121. package/dist/orchestration/types.js +11 -0
  122. package/dist/orchestration/types.js.map +1 -0
  123. package/dist/quality/density/validator.d.ts +38 -0
  124. package/dist/quality/density/validator.d.ts.map +1 -0
  125. package/dist/quality/density/validator.js +61 -0
  126. package/dist/quality/density/validator.js.map +1 -0
  127. package/dist/quality/inconsistency/code-vs-code.d.ts +26 -0
  128. package/dist/quality/inconsistency/code-vs-code.d.ts.map +1 -0
  129. package/dist/quality/inconsistency/code-vs-code.js +51 -0
  130. package/dist/quality/inconsistency/code-vs-code.js.map +1 -0
  131. package/dist/quality/inconsistency/code-vs-doc.d.ts +35 -0
  132. package/dist/quality/inconsistency/code-vs-doc.d.ts.map +1 -0
  133. package/dist/quality/inconsistency/code-vs-doc.js +59 -0
  134. package/dist/quality/inconsistency/code-vs-doc.js.map +1 -0
  135. package/dist/quality/inconsistency/code-vs-doc.test.d.ts +2 -0
  136. package/dist/quality/inconsistency/code-vs-doc.test.d.ts.map +1 -0
  137. package/dist/quality/inconsistency/code-vs-doc.test.js +196 -0
  138. package/dist/quality/inconsistency/code-vs-doc.test.js.map +1 -0
  139. package/dist/quality/inconsistency/reporter.d.ts +49 -0
  140. package/dist/quality/inconsistency/reporter.d.ts.map +1 -0
  141. package/dist/quality/inconsistency/reporter.js +99 -0
  142. package/dist/quality/inconsistency/reporter.js.map +1 -0
  143. package/dist/quality/index.d.ts +15 -0
  144. package/dist/quality/index.d.ts.map +1 -0
  145. package/dist/quality/index.js +25 -0
  146. package/dist/quality/index.js.map +1 -0
  147. package/dist/quality/types.d.ts +63 -0
  148. package/dist/quality/types.d.ts.map +1 -0
  149. package/dist/quality/types.js +5 -0
  150. package/dist/quality/types.js.map +1 -0
  151. package/dist/update/orchestrator.d.ts.map +1 -1
  152. package/dist/update/orchestrator.js +2 -1
  153. package/dist/update/orchestrator.js.map +1 -1
  154. package/dist/update/orphan-cleaner.js +1 -1
  155. package/dist/update/orphan-cleaner.js.map +1 -1
  156. package/package.json +1 -1
@@ -1,5 +1,16 @@
1
1
  import * as path from 'node:path';
2
- import { getTemplate } from './templates.js';
2
+ import { readdir, readFile } from 'node:fs/promises';
3
+ import pc from 'picocolors';
4
+ import { getTemplate, DIRECTORY_SYSTEM_PROMPT } from './templates.js';
5
+ import { readSumFile, getSumPath } from '../writers/sum.js';
6
+ const DEBUG = process.env.DEBUG_PROMPTS === '1' || process.env.DEBUG === '1';
7
+ function logTemplate(action, filePath, fileType, extra) {
8
+ if (!DEBUG)
9
+ return;
10
+ const rel = path.relative(process.cwd(), filePath);
11
+ const msg = `${pc.dim('[prompt]')} ${pc.cyan(action)} ${pc.bold(fileType)} ${pc.dim('→')} ${rel}`;
12
+ console.error(extra ? `${msg} ${pc.dim(extra)}` : msg);
13
+ }
3
14
  /**
4
15
  * Detect language from file extension for syntax highlighting.
5
16
  */
@@ -56,6 +67,7 @@ export function buildPrompt(context) {
56
67
  const template = getTemplate(context.fileType);
57
68
  const lang = detectLanguage(context.filePath);
58
69
  const framework = detectFramework(context.content);
70
+ logTemplate('buildPrompt', context.filePath, context.fileType, `lang=${lang} framework=${framework}`);
59
71
  let userPrompt = template.userPrompt
60
72
  .replace(/\{\{FILE_PATH\}\}/g, context.filePath)
61
73
  .replace(/\{\{CONTENT\}\}/g, context.content)
@@ -79,6 +91,7 @@ export function buildPrompt(context) {
79
91
  export function buildChunkPrompt(context) {
80
92
  const template = getTemplate(context.fileType);
81
93
  const lang = detectLanguage(context.filePath);
94
+ logTemplate('buildChunkPrompt', context.filePath, context.fileType, `chunk=${context.chunkIndex + 1}/${context.totalChunks} lines=${context.lineRange.start}-${context.lineRange.end}`);
82
95
  const system = `${template.systemPrompt}
83
96
 
84
97
  This is chunk ${context.chunkIndex + 1} of ${context.totalChunks} from a large file.
@@ -106,6 +119,7 @@ Keep it concise - this will be combined with other chunks.`;
106
119
  */
107
120
  export function buildSynthesisPrompt(context) {
108
121
  const template = getTemplate(context.fileType);
122
+ logTemplate('buildSynthesisPrompt', context.filePath, context.fileType, `chunks=${context.chunkSummaries.length}`);
109
123
  const system = `${template.systemPrompt}
110
124
 
111
125
  You are synthesizing chunk summaries into a final, cohesive summary.`;
@@ -133,4 +147,66 @@ Focus on:
133
147
  ${template.focusAreas.map((area) => `- ${area}`).join('\n')}`;
134
148
  return { system, user };
135
149
  }
150
+ /**
151
+ * Build a prompt for generating a directory-level AGENTS.md.
152
+ *
153
+ * Reads all .sum files in the directory, child AGENTS.md files,
154
+ * and AGENTS.local.md to provide full context to the LLM.
155
+ */
156
+ export async function buildDirectoryPrompt(dirPath, projectRoot) {
157
+ const relativePath = path.relative(projectRoot, dirPath) || '.';
158
+ const dirName = path.basename(dirPath) || 'root';
159
+ // Collect .sum file summaries
160
+ const entries = await readdir(dirPath, { withFileTypes: true });
161
+ const fileSummaries = [];
162
+ const subdirSections = [];
163
+ for (const entry of entries) {
164
+ const entryPath = path.join(dirPath, entry.name);
165
+ if (entry.isFile() && !entry.name.endsWith('.sum') && !entry.name.startsWith('.')) {
166
+ const sumPath = getSumPath(entryPath);
167
+ const sumContent = await readSumFile(sumPath);
168
+ if (sumContent) {
169
+ fileSummaries.push(`### ${entry.name}\n**Type:** ${sumContent.fileType}\n**Purpose:** ${sumContent.metadata.purpose}\n\n${sumContent.summary}`);
170
+ }
171
+ }
172
+ if (entry.isDirectory()) {
173
+ // Read child AGENTS.md if it exists (post-order means it's already generated)
174
+ const childAgentsPath = path.join(entryPath, 'AGENTS.md');
175
+ try {
176
+ const childContent = await readFile(childAgentsPath, 'utf-8');
177
+ subdirSections.push(`### ${entry.name}/\n${childContent}`);
178
+ }
179
+ catch {
180
+ subdirSections.push(`### ${entry.name}/\n(no AGENTS.md yet)`);
181
+ }
182
+ }
183
+ }
184
+ // Check for user-defined AGENTS.local.md
185
+ let localSection = '';
186
+ try {
187
+ const localContent = await readFile(path.join(dirPath, 'AGENTS.local.md'), 'utf-8');
188
+ localSection = `\n## User Notes (AGENTS.local.md)\n\n${localContent}\n\nNote: Reference [AGENTS.local.md](./AGENTS.local.md) for additional documentation.`;
189
+ }
190
+ catch {
191
+ // No local file
192
+ }
193
+ logTemplate('buildDirectoryPrompt', dirPath, 'directory', `files=${fileSummaries.length} subdirs=${subdirSections.length}`);
194
+ const userSections = [
195
+ `Generate AGENTS.md for directory: "${relativePath}" (${dirName})`,
196
+ '',
197
+ `## File Summaries (${fileSummaries.length} files)`,
198
+ '',
199
+ ...fileSummaries,
200
+ ];
201
+ if (subdirSections.length > 0) {
202
+ userSections.push('', '## Subdirectories', '', ...subdirSections);
203
+ }
204
+ if (localSection) {
205
+ userSections.push(localSection);
206
+ }
207
+ return {
208
+ system: DIRECTORY_SYSTEM_PROMPT,
209
+ user: userSections.join('\n'),
210
+ };
211
+ }
136
212
  //# sourceMappingURL=builder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"builder.js","sourceRoot":"","sources":["../../../src/generation/prompts/builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;IACjD,MAAM,OAAO,GAA2B;QACtC,KAAK,EAAE,YAAY;QACnB,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,YAAY;QACnB,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,MAAM;QACb,OAAO,EAAE,MAAM;QACf,KAAK,EAAE,QAAQ;QACf,QAAQ,EAAE,OAAO;QACjB,KAAK,EAAE,QAAQ;QACf,MAAM,EAAE,KAAK;QACb,MAAM,EAAE,KAAK;QACb,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AC,IAAI,CAAC,OAAO,KAAK,CAAC,IAAI,uBAAuB,CAAC,CAAC;YAChE,CAAC;QACH,CAAC;IACH,CAAC;IAED,yCAAyC;IACzC,IAAI,YAAY,GAAG,EAAE,CAAC;IACtB,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,iBAAiB,CAAC,EAAE,OAAO,CAAC,CAAC;QACpF,YAAY,GAAG,wCAAwC,YAAY,wFAAwF,CAAC;IAC9J,CAAC;IAAC,MAAM,CAAC;QACP,gBAAgB;IAClB,CAAC;IAED,WAAW,CAAC,sBAAsB,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,aAAa,CAAC,MAAM,YAAY,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC;IAE5H,MAAM,YAAY,GAAa;QAC7B,sCAAsC,YAAY,MAAM,OAAO,GAAG;QAClE,EAAE;QACF,sBAAsB,aAAa,CAAC,MAAM,SAAS;QACnD,EAAE;QACF,GAAG,aAAa;KACjB,CAAC;IAEF,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,YAAY,CAAC,IAAI,CAAC,EAAE,EAAE,mBAAmB,EAAE,EAAE,EAAE,GAAG,cAAc,CAAC,CAAC;IACpE,CAAC;IAED,IAAI,YAAY,EAAE,CAAC;QACjB,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAClC,CAAC;IAED,OAAO;QACL,MAAM,EAAE,uBAAuB;QAC/B,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;KAC9B,CAAC;AACJ,CAAC"}
@@ -1,5 +1,5 @@
1
1
  export type { PromptTemplate, PromptContext, ChunkContext, SynthesisContext, } from './types.js';
2
2
  export { SUMMARY_GUIDELINES } from './types.js';
3
3
  export { TEMPLATES, getTemplate } from './templates.js';
4
- export { buildPrompt, buildChunkPrompt, buildSynthesisPrompt, detectLanguage, detectFramework, } from './builder.js';
4
+ export { buildPrompt, buildChunkPrompt, buildSynthesisPrompt, buildDirectoryPrompt, detectLanguage, detectFramework, } from './builder.js';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generation/prompts/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,aAAa,EACb,YAAY,EACZ,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,eAAe,GAChB,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generation/prompts/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,aAAa,EACb,YAAY,EACZ,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,eAAe,GAChB,MAAM,cAAc,CAAC"}
@@ -1,4 +1,4 @@
1
1
  export { SUMMARY_GUIDELINES } from './types.js';
2
2
  export { TEMPLATES, getTemplate } from './templates.js';
3
- export { buildPrompt, buildChunkPrompt, buildSynthesisPrompt, detectLanguage, detectFramework, } from './builder.js';
3
+ export { buildPrompt, buildChunkPrompt, buildSynthesisPrompt, buildDirectoryPrompt, detectLanguage, detectFramework, } from './builder.js';
4
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/generation/prompts/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,eAAe,GAChB,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/generation/prompts/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,eAAe,GAChB,MAAM,cAAc,CAAC"}
@@ -8,4 +8,9 @@ export declare const TEMPLATES: Record<FileType, PromptTemplate>;
8
8
  * Get the prompt template for a file type.
9
9
  */
10
10
  export declare function getTemplate(fileType: FileType): PromptTemplate;
11
+ /**
12
+ * System prompt for directory-level AGENTS.md generation.
13
+ * Used by buildDirectoryPrompt() in builder.ts.
14
+ */
15
+ export declare const DIRECTORY_SYSTEM_PROMPT = "You are generating an AGENTS.md file \u2014 a directory-level overview for AI coding assistants.\n\nCRITICAL: Output ONLY the raw markdown content. No code fences, no preamble, no explanations, no conversational text. Your entire response IS the AGENTS.md file content.\n\nOUTPUT FORMAT:\n- First line MUST be exactly: <!-- Generated by agents-reverse-engineer -->\n- Use a # heading with the directory name\n- Write a one-paragraph purpose statement for the directory\n- Group files by purpose/category under ## Contents with ### subheadings\n- For each file: markdown link [filename](./filename) and a one-line description\n- If subdirectories exist, list them under ## Subdirectories with links and brief summaries\n- End with ## How Files Relate \u2014 2-3 sentences synthesizing how the files collaborate\n\nDENSITY RULES (MANDATORY):\n- Every sentence must reference at least one specific identifier (function name, class name, type name, or constant)\n- Never use filler phrases: \"this directory\", \"this module\", \"provides\", \"responsible for\", \"is used to\"\n- Use technical shorthand: \"exports X, Y, Z\" not \"this module exports a function called X...\"\n- Maximum 500 words. Every word must earn its place.\n\nCOMMON PATTERNS (MANDATORY):\n- Identify recurring patterns shared by files in the directory (e.g., all files export a factory, all use a shared base class, all follow request/response pairs)\n- Name patterns explicitly (e.g., \"Strategy pattern\", \"Barrel re-export\", \"Builder pattern\")\n- If all files follow the same structure, state it once concisely\n\nLIBRARY & DEPENDENCY STATISTICS (MANDATORY):\n- Aggregate library usage across all files in the directory\n- List each external library with total usage count (e.g., \"zod (used in 4/7 files)\")\n- For Node built-ins, note which specific APIs are used\n- Group: external packages first, then node built-ins\n\nDISCOVERABLE CONTENT:\n- When files share patterns, stack choices, or structural conventions worth documenting in detail, suggest supplementary files\n- Use relative links: [PATTERNS.md](./PATTERNS.md), [STACK.md](./STACK.md), [STRUCTURE.md](./STRUCTURE.md)\n- Possible supplementary files:\n - PATTERNS.md \u2014 recurring design/architectural patterns\n - STACK.md \u2014 libraries and tools with rationale\n - STRUCTURE.md \u2014 directory layout conventions and naming rules\n - Any other relevant *.md (e.g., CONVENTIONS.md, API.md, TESTING.md)\n- Keep AGENTS.md as the entry point; don't duplicate supplementary content";
11
16
  //# sourceMappingURL=templates.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../src/generation/prompts/templates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AA8OjD;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,QAAQ,EAAE,cAAc,CAYtD,CAAC;AAEF;;GAEG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,CAE9D"}
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../src/generation/prompts/templates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AA0RjD;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,QAAQ,EAAE,cAAc,CAYtD,CAAC;AAEF;;GAEG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,CAE9D;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,w+EAsCuC,CAAC"}
@@ -1,12 +1,56 @@
1
1
  const BASE_SYSTEM_PROMPT = `You are analyzing source code to generate documentation for AI coding assistants.
2
2
 
3
- Guidelines:
4
- - Be concise but comprehensive (300-500 words)
5
- - Focus on what the code DOES and HOW to use it
6
- - Include key function signatures as code snippets
7
- - Note dependencies and their purposes
8
- - Mention only critical TODOs (security, breaking issues)
9
- - Reference tightly coupled files (used together)`;
3
+ OUTPUT FORMAT:
4
+ - Lead with a single-line purpose statement (what this file IS, not what it does)
5
+ - List all public exports with their type signatures
6
+ - For each export: one sentence explaining its role
7
+ - End with dependencies and coupled files
8
+
9
+ DENSITY RULES (MANDATORY):
10
+ - Every sentence must reference at least one specific identifier (function name, class name, type name, or constant)
11
+ - Never use filler phrases: "this file", "this module", "provides", "responsible for", "is used to", "basically", "essentially", "provides functionality for"
12
+ - Use the pattern: "[ExportName] does X" not "The ExportName function is responsible for doing X"
13
+ - Use technical shorthand: "exports X, Y, Z" not "this module exports a function called X..."
14
+ - Compress descriptions: "parses YAML frontmatter from .sum files" not "responsible for the parsing of YAML-style frontmatter..."
15
+ - Maximum 300 words. Every word must earn its place.
16
+
17
+ ANCHOR TERM PRESERVATION (MANDATORY):
18
+ - All exported function/class/type/const names MUST appear in the summary exactly as written in source
19
+ - Key parameter types and return types MUST be mentioned
20
+ - Preserve exact casing of identifiers (e.g., buildAgentsMd, not "build agents md")
21
+ - Missing any exported identifier is a failure
22
+
23
+ COMMON PATTERNS (MANDATORY):
24
+ - Identify recurring patterns shared by files at the same directory level (e.g., all files export a factory, all use a shared base class, all follow request/response pairs)
25
+ - Name the pattern explicitly (e.g., "Strategy pattern", "Barrel re-export", "Builder pattern", "Middleware chain")
26
+ - If sibling files follow the same structure, state it once concisely: "All files in this directory follow the [pattern] pattern"
27
+
28
+ LIBRARY & DEPENDENCY STATISTICS (MANDATORY):
29
+ - List each imported library/package with a usage count across the file (e.g., "zod (3 usages: schema, parse, infer)")
30
+ - For Node built-ins, note which specific APIs are used (e.g., "node:path (join, resolve, extname)")
31
+ - Group: external packages first, then node built-ins, then local imports
32
+
33
+ DISCOVERABLE CONTENT:
34
+ - When a directory contains files that share patterns, stack choices, or structural conventions, recommend splitting documentation into supplementary files rather than cramming everything into AGENTS.md
35
+ - Use relative links to point to supplementary docs: [PATTERNS.md](./PATTERNS.md), [STACK.md](./STACK.md), [STRUCTURE.md](./STRUCTURE.md)
36
+ - Suggest supplementary files when appropriate:
37
+ - PATTERNS.md — recurring design/architectural patterns across sibling files
38
+ - STACK.md — libraries, frameworks, and tools used with version constraints and rationale
39
+ - STRUCTURE.md — directory layout conventions, naming rules, file organization
40
+ - Any other relevant *.md (e.g., CONVENTIONS.md, API.md, TESTING.md)
41
+ - Keep AGENTS.md as the entry point that links out to these files; don't duplicate their content
42
+
43
+ WHAT TO INCLUDE:
44
+ - All exported function/class/type/const names
45
+ - Parameter types and return types for public functions
46
+ - Key dependencies and what they're used for
47
+ - Coupled sibling files
48
+ - Only critical TODOs (security, breaking issues)
49
+
50
+ WHAT TO EXCLUDE:
51
+ - Internal implementation details
52
+ - Generic descriptions without identifiers
53
+ - Filler phrases and transitions`;
10
54
  const COMPONENT_TEMPLATE = {
11
55
  fileType: 'component',
12
56
  systemPrompt: BASE_SYSTEM_PROMPT,
@@ -244,4 +288,47 @@ export const TEMPLATES = {
244
288
  export function getTemplate(fileType) {
245
289
  return TEMPLATES[fileType];
246
290
  }
291
+ /**
292
+ * System prompt for directory-level AGENTS.md generation.
293
+ * Used by buildDirectoryPrompt() in builder.ts.
294
+ */
295
+ export const DIRECTORY_SYSTEM_PROMPT = `You are generating an AGENTS.md file — a directory-level overview for AI coding assistants.
296
+
297
+ CRITICAL: Output ONLY the raw markdown content. No code fences, no preamble, no explanations, no conversational text. Your entire response IS the AGENTS.md file content.
298
+
299
+ OUTPUT FORMAT:
300
+ - First line MUST be exactly: <!-- Generated by agents-reverse-engineer -->
301
+ - Use a # heading with the directory name
302
+ - Write a one-paragraph purpose statement for the directory
303
+ - Group files by purpose/category under ## Contents with ### subheadings
304
+ - For each file: markdown link [filename](./filename) and a one-line description
305
+ - If subdirectories exist, list them under ## Subdirectories with links and brief summaries
306
+ - End with ## How Files Relate — 2-3 sentences synthesizing how the files collaborate
307
+
308
+ DENSITY RULES (MANDATORY):
309
+ - Every sentence must reference at least one specific identifier (function name, class name, type name, or constant)
310
+ - Never use filler phrases: "this directory", "this module", "provides", "responsible for", "is used to"
311
+ - Use technical shorthand: "exports X, Y, Z" not "this module exports a function called X..."
312
+ - Maximum 500 words. Every word must earn its place.
313
+
314
+ COMMON PATTERNS (MANDATORY):
315
+ - Identify recurring patterns shared by files in the directory (e.g., all files export a factory, all use a shared base class, all follow request/response pairs)
316
+ - Name patterns explicitly (e.g., "Strategy pattern", "Barrel re-export", "Builder pattern")
317
+ - If all files follow the same structure, state it once concisely
318
+
319
+ LIBRARY & DEPENDENCY STATISTICS (MANDATORY):
320
+ - Aggregate library usage across all files in the directory
321
+ - List each external library with total usage count (e.g., "zod (used in 4/7 files)")
322
+ - For Node built-ins, note which specific APIs are used
323
+ - Group: external packages first, then node built-ins
324
+
325
+ DISCOVERABLE CONTENT:
326
+ - When files share patterns, stack choices, or structural conventions worth documenting in detail, suggest supplementary files
327
+ - Use relative links: [PATTERNS.md](./PATTERNS.md), [STACK.md](./STACK.md), [STRUCTURE.md](./STRUCTURE.md)
328
+ - Possible supplementary files:
329
+ - PATTERNS.md — recurring design/architectural patterns
330
+ - STACK.md — libraries and tools with rationale
331
+ - STRUCTURE.md — directory layout conventions and naming rules
332
+ - Any other relevant *.md (e.g., CONVENTIONS.md, API.md, TESTING.md)
333
+ - Keep AGENTS.md as the entry point; don't duplicate supplementary content`;
247
334
  //# sourceMappingURL=templates.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/generation/prompts/templates.ts"],"names":[],"mappings":"AAGA,MAAM,kBAAkB,GAAG;;;;;;;;kDAQuB,CAAC;AAEnD,MAAM,kBAAkB,GAAmB;IACzC,QAAQ,EAAE,WAAW;IACrB,YAAY,EAAE,kBAAkB;IAChC,UAAU,EAAE;;;;;;;;;;;;;;;2DAe6C;IACzD,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,CAAC;CACpE,CAAC;AAEF,MAAM,gBAAgB,GAAmB;IACvC,QAAQ,EAAE,SAAS;IACnB,YAAY,EAAE,kBAAkB;IAChC,UAAU,EAAE;;;;;;;;;;;;;;6DAc+C;IAC3D,UAAU,EAAE,CAAC,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,cAAc,CAAC;CACjF,CAAC;AAEF,MAAM,aAAa,GAAmB;IACpC,QAAQ,EAAE,MAAM;IAChB,YAAY,EAAE,kBAAkB;IAChC,UAAU,EAAE;;;;;;;;;;;;;8CAagC;IAC5C,UAAU,EAAE,CAAC,qBAAqB,EAAE,oBAAoB,EAAE,YAAY,CAAC;CACxE,CAAC;AAEF,MAAM,aAAa,GAAmB;IACpC,QAAQ,EAAE,MAAM;IAChB,YAAY,EAAE,kBAAkB;IAChC,UAAU,EAAE;;;;;;;;;;;;;oDAasC;IAClD,UAAU,EAAE,CAAC,uBAAuB,EAAE,oBAAoB,EAAE,UAAU,CAAC;CACxE,CAAC;AAEF,MAAM,aAAa,GAAmB;IACpC,QAAQ,EAAE,MAAM;IAChB,YAAY,EAAE,kBAAkB;IAChC,UAAU,EAAE;;;;;;;;;;;;;0DAa4C;IACxD,UAAU,EAA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E,CAAC;AAEF,MAAM,eAAe,GAAmB;IACtC,QAAQ,EAAE,QAAQ;IAClB,YAAY,EAAE,kBAAkB;IAChC,UAAU,EAAE;;;;;;;;;;;;;;qCAcuB;IACnC,UAAU,EAAE,CAAC,kBAAkB,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,CAAC;CACrE,CAAC;AAEF,MAAM,gBAAgB,GAAmB;IACvC,QAAQ,EAAE,SAAS;IACnB,YAAY,EAAE,kBAAkB;IAChC,UAAU,EAAE;;;;;;;;;;;;;sCAawB;IACpC,UAAU,EAAE,CAAC,SAAS,EAAE,cAAc,EAAE,UAAU,CAAC;CACpD,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAqC;IACzD,SAAS,EAAE,kBAAkB;IAC7B,OAAO,EAAE,gBAAgB;IACzB,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,aAAa;IACnB,MAAM,EAAE,eAAe;IACvB,GAAG,EAAE,YAAY;IACjB,KAAK,EAAE,cAAc;IACrB,IAAI,EAAE,aAAa;IACnB,MAAM,EAAE,eAAe;IACvB,OAAO,EAAE,gBAAgB;CAC1B,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,QAAkB;IAC5C,OAAO,SAAS,CAAC,QAAQ,CAAC,CAAC;AAC7B,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2EAsCoC,CAAC"}
@@ -35,8 +35,8 @@ export interface PromptContext {
35
35
  export declare const SUMMARY_GUIDELINES: {
36
36
  /** Target word count range */
37
37
  readonly targetLength: {
38
- readonly min: 300;
39
- readonly max: 500;
38
+ readonly min: 200;
39
+ readonly max: 300;
40
40
  };
41
41
  /** What to include */
42
42
  readonly include: readonly ["Purpose and responsibility", "Public interface (exports, key functions)", "Key patterns and notable algorithms", "Dependencies with usage context", "Key function signatures as code snippets", "Tightly coupled sibling files"];
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const SUMMARY_GUIDELINES = {
5
5
  /** Target word count range */
6
- targetLength: { min: 300, max: 500 },
6
+ targetLength: { min: 200, max: 300 },
7
7
  /** What to include */
8
8
  include: [
9
9
  'Purpose and responsibility',
@@ -1,69 +1,13 @@
1
1
  /**
2
- * Reference to a file in a directory.
3
- */
4
- export interface FileRef {
5
- /** File name */
6
- name: string;
7
- /** Brief description from .sum file */
8
- description: string;
9
- /** Whether this is a critical/frequently modified file */
10
- critical?: boolean;
11
- }
12
- /**
13
- * Group of files by purpose.
14
- */
15
- export interface FileGroup {
16
- /** Purpose/category of this group */
17
- purpose: string;
18
- /** Files in this group */
19
- files: FileRef[];
20
- }
21
- /**
22
- * Summary of a subdirectory.
23
- */
24
- export interface SubdirSummary {
25
- /** Directory name */
26
- name: string;
27
- /** Brief summary (from child AGENTS.md or inferred) */
28
- summary: string;
29
- }
30
- /**
31
- * Complete directory documentation structure.
32
- */
33
- export interface DirectoryDoc {
34
- /** Directory path (relative to project root) */
35
- path: string;
36
- /** Directory description */
37
- description: string;
38
- /** Files grouped by purpose */
39
- files: FileGroup[];
40
- /** Subdirectories with summaries */
41
- subdirectories: SubdirSummary[];
42
- /** Related directories (from imports, config) */
43
- relatedDirectories: string[];
44
- /** Patterns/conventions in this directory */
45
- patterns: string[];
46
- }
47
- /**
48
- * Build AGENTS.md content from directory documentation.
49
- *
50
- * @param doc - Directory documentation
51
- * @param hasLocalFile - Whether AGENTS.local.md exists (user-defined content)
52
- */
53
- export declare function buildAgentsMd(doc: DirectoryDoc, hasLocalFile?: boolean): string;
54
- /**
55
- * Build directory documentation from .sum files.
56
- */
57
- export declare function buildDirectoryDoc(dirPath: string, projectRoot: string): Promise<DirectoryDoc>;
58
- /**
59
- * Write AGENTS.md for a directory.
2
+ * Write AGENTS.md for a directory with LLM-generated content.
60
3
  *
61
4
  * If a user-defined AGENTS.md exists (not generated by us), it will be
62
5
  * preserved as AGENTS.local.md and referenced in the generated file.
63
6
  *
64
7
  * @param dirPath - Directory to write AGENTS.md for
65
8
  * @param projectRoot - Project root for relative paths
9
+ * @param content - LLM-generated AGENTS.md content
66
10
  * @returns Path to written AGENTS.md
67
11
  */
68
- export declare function writeAgentsMd(dirPath: string, projectRoot: string): Promise<string>;
12
+ export declare function writeAgentsMd(dirPath: string, _projectRoot: string, content: string): Promise<string>;
69
13
  //# sourceMappingURL=agents-md.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agents-md.d.ts","sourceRoot":"","sources":["../../../src/generation/writers/agents-md.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,0BAA0B;IAC1B,KAAK,EAAE,OAAO,EAAE,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,+BAA+B;IAC/B,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,oCAAoC;IACpC,cAAc,EAAE,aAAa,EAAE,CAAC;IAChC,iDAAiD;IACjD,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,YAAY,EAAE,YAAY,GAAE,OAAe,GAAG,MAAM,CA+DtF;AA+GD;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,YAAY,CAAC,CAyEvB;AA0BD;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CA0BjB"}
1
+ {"version":3,"file":"agents-md.d.ts","sourceRoot":"","sources":["../../../src/generation/writers/agents-md.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;GAUG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,CA0BjB"}