autodocs-engine 0.5.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 (240) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +185 -0
  3. package/dist/analysis-builder.d.ts +13 -0
  4. package/dist/analysis-builder.js +268 -0
  5. package/dist/analysis-builder.js.map +1 -0
  6. package/dist/anti-pattern-detector.d.ts +9 -0
  7. package/dist/anti-pattern-detector.js +58 -0
  8. package/dist/anti-pattern-detector.js.map +1 -0
  9. package/dist/architecture-detector.d.ts +7 -0
  10. package/dist/architecture-detector.js +212 -0
  11. package/dist/architecture-detector.js.map +1 -0
  12. package/dist/ast-parser.d.ts +5 -0
  13. package/dist/ast-parser.js +635 -0
  14. package/dist/ast-parser.js.map +1 -0
  15. package/dist/benchmark/code-generator.d.ts +20 -0
  16. package/dist/benchmark/code-generator.js +206 -0
  17. package/dist/benchmark/code-generator.js.map +1 -0
  18. package/dist/benchmark/pr-miner.d.ts +61 -0
  19. package/dist/benchmark/pr-miner.js +304 -0
  20. package/dist/benchmark/pr-miner.js.map +1 -0
  21. package/dist/benchmark/pr-runner.d.ts +58 -0
  22. package/dist/benchmark/pr-runner.js +346 -0
  23. package/dist/benchmark/pr-runner.js.map +1 -0
  24. package/dist/benchmark/pr-scorer.d.ts +48 -0
  25. package/dist/benchmark/pr-scorer.js +222 -0
  26. package/dist/benchmark/pr-scorer.js.map +1 -0
  27. package/dist/benchmark/pr-task-gen.d.ts +16 -0
  28. package/dist/benchmark/pr-task-gen.js +129 -0
  29. package/dist/benchmark/pr-task-gen.js.map +1 -0
  30. package/dist/benchmark/report.d.ts +9 -0
  31. package/dist/benchmark/report.js +131 -0
  32. package/dist/benchmark/report.js.map +1 -0
  33. package/dist/benchmark/runner.d.ts +6 -0
  34. package/dist/benchmark/runner.js +183 -0
  35. package/dist/benchmark/runner.js.map +1 -0
  36. package/dist/benchmark/scorer.d.ts +6 -0
  37. package/dist/benchmark/scorer.js +549 -0
  38. package/dist/benchmark/scorer.js.map +1 -0
  39. package/dist/benchmark/shuffler.d.ts +5 -0
  40. package/dist/benchmark/shuffler.js +70 -0
  41. package/dist/benchmark/shuffler.js.map +1 -0
  42. package/dist/benchmark/statistics.d.ts +36 -0
  43. package/dist/benchmark/statistics.js +159 -0
  44. package/dist/benchmark/statistics.js.map +1 -0
  45. package/dist/benchmark/task-generator.d.ts +20 -0
  46. package/dist/benchmark/task-generator.js +388 -0
  47. package/dist/benchmark/task-generator.js.map +1 -0
  48. package/dist/benchmark/types.d.ts +111 -0
  49. package/dist/benchmark/types.js +3 -0
  50. package/dist/benchmark/types.js.map +1 -0
  51. package/dist/bin/autodocs-engine.d.ts +2 -0
  52. package/dist/bin/autodocs-engine.js +296 -0
  53. package/dist/bin/autodocs-engine.js.map +1 -0
  54. package/dist/bin/benchmark.d.ts +14 -0
  55. package/dist/bin/benchmark.js +172 -0
  56. package/dist/bin/benchmark.js.map +1 -0
  57. package/dist/bin/check.d.ts +13 -0
  58. package/dist/bin/check.js +79 -0
  59. package/dist/bin/check.js.map +1 -0
  60. package/dist/bin/init.d.ts +11 -0
  61. package/dist/bin/init.js +268 -0
  62. package/dist/bin/init.js.map +1 -0
  63. package/dist/bin/serve.d.ts +4 -0
  64. package/dist/bin/serve.js +29 -0
  65. package/dist/bin/serve.js.map +1 -0
  66. package/dist/budget-validator.d.ts +22 -0
  67. package/dist/budget-validator.js +119 -0
  68. package/dist/budget-validator.js.map +1 -0
  69. package/dist/command-extractor.d.ts +10 -0
  70. package/dist/command-extractor.js +276 -0
  71. package/dist/command-extractor.js.map +1 -0
  72. package/dist/config-analyzer.d.ts +5 -0
  73. package/dist/config-analyzer.js +364 -0
  74. package/dist/config-analyzer.js.map +1 -0
  75. package/dist/config.d.ts +33 -0
  76. package/dist/config.js +172 -0
  77. package/dist/config.js.map +1 -0
  78. package/dist/contribution-patterns.d.ts +6 -0
  79. package/dist/contribution-patterns.js +263 -0
  80. package/dist/contribution-patterns.js.map +1 -0
  81. package/dist/convention-extractor.d.ts +17 -0
  82. package/dist/convention-extractor.js +90 -0
  83. package/dist/convention-extractor.js.map +1 -0
  84. package/dist/cross-package.d.ts +5 -0
  85. package/dist/cross-package.js +71 -0
  86. package/dist/cross-package.js.map +1 -0
  87. package/dist/dependency-analyzer.d.ts +5 -0
  88. package/dist/dependency-analyzer.js +233 -0
  89. package/dist/dependency-analyzer.js.map +1 -0
  90. package/dist/detectors/build-tool.d.ts +2 -0
  91. package/dist/detectors/build-tool.js +67 -0
  92. package/dist/detectors/build-tool.js.map +1 -0
  93. package/dist/detectors/component-patterns.d.ts +2 -0
  94. package/dist/detectors/component-patterns.js +49 -0
  95. package/dist/detectors/component-patterns.js.map +1 -0
  96. package/dist/detectors/data-fetching.d.ts +2 -0
  97. package/dist/detectors/data-fetching.js +127 -0
  98. package/dist/detectors/data-fetching.js.map +1 -0
  99. package/dist/detectors/database.d.ts +2 -0
  100. package/dist/detectors/database.js +54 -0
  101. package/dist/detectors/database.js.map +1 -0
  102. package/dist/detectors/error-handling.d.ts +2 -0
  103. package/dist/detectors/error-handling.js +47 -0
  104. package/dist/detectors/error-handling.js.map +1 -0
  105. package/dist/detectors/export-patterns.d.ts +2 -0
  106. package/dist/detectors/export-patterns.js +64 -0
  107. package/dist/detectors/export-patterns.js.map +1 -0
  108. package/dist/detectors/file-naming.d.ts +2 -0
  109. package/dist/detectors/file-naming.js +74 -0
  110. package/dist/detectors/file-naming.js.map +1 -0
  111. package/dist/detectors/graphql-patterns.d.ts +2 -0
  112. package/dist/detectors/graphql-patterns.js +47 -0
  113. package/dist/detectors/graphql-patterns.js.map +1 -0
  114. package/dist/detectors/hook-patterns.d.ts +2 -0
  115. package/dist/detectors/hook-patterns.js +105 -0
  116. package/dist/detectors/hook-patterns.js.map +1 -0
  117. package/dist/detectors/import-patterns.d.ts +2 -0
  118. package/dist/detectors/import-patterns.js +88 -0
  119. package/dist/detectors/import-patterns.js.map +1 -0
  120. package/dist/detectors/telemetry-patterns.d.ts +2 -0
  121. package/dist/detectors/telemetry-patterns.js +42 -0
  122. package/dist/detectors/telemetry-patterns.js.map +1 -0
  123. package/dist/detectors/test-framework-ecosystem.d.ts +2 -0
  124. package/dist/detectors/test-framework-ecosystem.js +95 -0
  125. package/dist/detectors/test-framework-ecosystem.js.map +1 -0
  126. package/dist/detectors/test-patterns.d.ts +2 -0
  127. package/dist/detectors/test-patterns.js +60 -0
  128. package/dist/detectors/test-patterns.js.map +1 -0
  129. package/dist/detectors/web-framework.d.ts +2 -0
  130. package/dist/detectors/web-framework.js +51 -0
  131. package/dist/detectors/web-framework.js.map +1 -0
  132. package/dist/deterministic-formatter.d.ts +54 -0
  133. package/dist/deterministic-formatter.js +922 -0
  134. package/dist/deterministic-formatter.js.map +1 -0
  135. package/dist/diff-analyzer.d.ts +7 -0
  136. package/dist/diff-analyzer.js +126 -0
  137. package/dist/diff-analyzer.js.map +1 -0
  138. package/dist/example-extractor.d.ts +6 -0
  139. package/dist/example-extractor.js +115 -0
  140. package/dist/example-extractor.js.map +1 -0
  141. package/dist/existing-docs.d.ts +36 -0
  142. package/dist/existing-docs.js +257 -0
  143. package/dist/existing-docs.js.map +1 -0
  144. package/dist/file-discovery.d.ts +6 -0
  145. package/dist/file-discovery.js +154 -0
  146. package/dist/file-discovery.js.map +1 -0
  147. package/dist/git-history.d.ts +41 -0
  148. package/dist/git-history.js +401 -0
  149. package/dist/git-history.js.map +1 -0
  150. package/dist/impact-classifier.d.ts +22 -0
  151. package/dist/impact-classifier.js +87 -0
  152. package/dist/impact-classifier.js.map +1 -0
  153. package/dist/impact-radius.d.ts +23 -0
  154. package/dist/impact-radius.js +130 -0
  155. package/dist/impact-radius.js.map +1 -0
  156. package/dist/import-chain.d.ts +12 -0
  157. package/dist/import-chain.js +93 -0
  158. package/dist/import-chain.js.map +1 -0
  159. package/dist/index.d.ts +40 -0
  160. package/dist/index.js +72 -0
  161. package/dist/index.js.map +1 -0
  162. package/dist/inferability.d.ts +16 -0
  163. package/dist/inferability.js +142 -0
  164. package/dist/inferability.js.map +1 -0
  165. package/dist/llm/adapter.d.ts +33 -0
  166. package/dist/llm/adapter.js +202 -0
  167. package/dist/llm/adapter.js.map +1 -0
  168. package/dist/llm/client.d.ts +5 -0
  169. package/dist/llm/client.js +68 -0
  170. package/dist/llm/client.js.map +1 -0
  171. package/dist/llm/hierarchical.d.ts +23 -0
  172. package/dist/llm/hierarchical.js +126 -0
  173. package/dist/llm/hierarchical.js.map +1 -0
  174. package/dist/llm/serializer.d.ts +19 -0
  175. package/dist/llm/serializer.js +363 -0
  176. package/dist/llm/serializer.js.map +1 -0
  177. package/dist/llm/template-selector.d.ts +7 -0
  178. package/dist/llm/template-selector.js +21 -0
  179. package/dist/llm/template-selector.js.map +1 -0
  180. package/dist/llm-adapter.d.ts +2 -0
  181. package/dist/llm-adapter.js +5 -0
  182. package/dist/llm-adapter.js.map +1 -0
  183. package/dist/mcp/cache.d.ts +30 -0
  184. package/dist/mcp/cache.js +112 -0
  185. package/dist/mcp/cache.js.map +1 -0
  186. package/dist/mcp/errors.d.ts +21 -0
  187. package/dist/mcp/errors.js +27 -0
  188. package/dist/mcp/errors.js.map +1 -0
  189. package/dist/mcp/queries.d.ts +27 -0
  190. package/dist/mcp/queries.js +121 -0
  191. package/dist/mcp/queries.js.map +1 -0
  192. package/dist/mcp/server.d.ts +14 -0
  193. package/dist/mcp/server.js +131 -0
  194. package/dist/mcp/server.js.map +1 -0
  195. package/dist/mcp/tools.d.ts +39 -0
  196. package/dist/mcp/tools.js +249 -0
  197. package/dist/mcp/tools.js.map +1 -0
  198. package/dist/mermaid-generator.d.ts +6 -0
  199. package/dist/mermaid-generator.js +59 -0
  200. package/dist/mermaid-generator.js.map +1 -0
  201. package/dist/meta-tool-detector.d.ts +23 -0
  202. package/dist/meta-tool-detector.js +177 -0
  203. package/dist/meta-tool-detector.js.map +1 -0
  204. package/dist/output-validator.d.ts +6 -0
  205. package/dist/output-validator.js +471 -0
  206. package/dist/output-validator.js.map +1 -0
  207. package/dist/pattern-fingerprinter.d.ts +7 -0
  208. package/dist/pattern-fingerprinter.js +241 -0
  209. package/dist/pattern-fingerprinter.js.map +1 -0
  210. package/dist/pipeline.d.ts +5 -0
  211. package/dist/pipeline.js +374 -0
  212. package/dist/pipeline.js.map +1 -0
  213. package/dist/plugin-loader.d.ts +19 -0
  214. package/dist/plugin-loader.js +124 -0
  215. package/dist/plugin-loader.js.map +1 -0
  216. package/dist/role-inferrer.d.ts +5 -0
  217. package/dist/role-inferrer.js +159 -0
  218. package/dist/role-inferrer.js.map +1 -0
  219. package/dist/symbol-graph.d.ts +11 -0
  220. package/dist/symbol-graph.js +613 -0
  221. package/dist/symbol-graph.js.map +1 -0
  222. package/dist/templates/agents-md.d.ts +20 -0
  223. package/dist/templates/agents-md.js +346 -0
  224. package/dist/templates/agents-md.js.map +1 -0
  225. package/dist/templates/claude-md.d.ts +4 -0
  226. package/dist/templates/claude-md.js +23 -0
  227. package/dist/templates/claude-md.js.map +1 -0
  228. package/dist/templates/cursorrules.d.ts +4 -0
  229. package/dist/templates/cursorrules.js +18 -0
  230. package/dist/templates/cursorrules.js.map +1 -0
  231. package/dist/tier-classifier.d.ts +7 -0
  232. package/dist/tier-classifier.js +32 -0
  233. package/dist/tier-classifier.js.map +1 -0
  234. package/dist/types.d.ts +428 -0
  235. package/dist/types.js +42 -0
  236. package/dist/types.js.map +1 -0
  237. package/dist/workflow-rules.d.ts +18 -0
  238. package/dist/workflow-rules.js +131 -0
  239. package/dist/workflow-rules.js.map +1 -0
  240. package/package.json +62 -0
@@ -0,0 +1,142 @@
1
+ // src/inferability.ts — Compute how "inferable" a repo's patterns are from source code alone
2
+ // High score = AI can figure it out from sibling files (AGENTS.md pattern sections redundant)
3
+ // Low score = AI needs AGENTS.md guidance (non-obvious patterns, unique conventions)
4
+ // ─── Standard Directory Names ────────────────────────────────────────────────
5
+ const OBVIOUS_DIR_NAMES = new Set([
6
+ "src", "lib", "dist", "build", "out", "coverage",
7
+ "components", "component", "utils", "util", "utilities", "helpers", "helper",
8
+ "types", "typings", "interfaces", "models", "model",
9
+ "hooks", "hook",
10
+ "styles", "css", "assets", "images", "icons", "fonts",
11
+ "public", "static",
12
+ "pages", "page", "views", "view", "screens",
13
+ "app", "apps",
14
+ "api", "apis", "routes", "route", "controllers", "controller",
15
+ "config", "configs", "configuration", "settings",
16
+ "constants", "const",
17
+ "test", "tests", "__tests__", "spec", "specs",
18
+ "middleware", "middlewares",
19
+ "services", "service",
20
+ "store", "stores", "state",
21
+ "context", "contexts", "providers",
22
+ "actions", "reducers", "selectors",
23
+ "layouts", "layout",
24
+ "features", "modules",
25
+ "common", "shared", "core",
26
+ "server", "client",
27
+ "bin", "cli", "cmd",
28
+ ]);
29
+ // ─── Public API ──────────────────────────────────────────────────────────────
30
+ /**
31
+ * Compute how inferable a package's patterns are from source code alone.
32
+ * Used to decide which AGENTS.md sections to include.
33
+ */
34
+ export function computeInferabilityScore(pkg) {
35
+ const directoryObviousness = computeDirectoryObviousness(pkg);
36
+ const namingConsistency = computeNamingConsistency(pkg);
37
+ const patternUniqueness = computePatternUniqueness(pkg);
38
+ const registrationComplexity = computeRegistrationComplexity(pkg);
39
+ // Weighted average: directory and patterns matter most
40
+ const score = Math.round(directoryObviousness * 0.30 +
41
+ namingConsistency * 0.25 +
42
+ patternUniqueness * 0.25 +
43
+ registrationComplexity * 0.20);
44
+ // Thresholds
45
+ let recommendation;
46
+ if (score <= 35) {
47
+ recommendation = "full"; // Repo has non-obvious patterns → include all sections
48
+ }
49
+ else if (score <= 65) {
50
+ recommendation = "minimal"; // Mixed → include architecture + commands, skip verbose patterns
51
+ }
52
+ else {
53
+ recommendation = "skip"; // Standard patterns → omit pattern sections
54
+ }
55
+ // Floor rule: if most directories are non-obvious, never "skip" — the repo
56
+ // has structure worth documenting even if patterns are standard.
57
+ // Calibrated against 20-repo benchmark: vitest (directoryObviousness=25, delta=+13.2%)
58
+ // was incorrectly recommended "skip" without this rule.
59
+ if (directoryObviousness < 40 && recommendation === "skip") {
60
+ recommendation = "minimal";
61
+ }
62
+ return {
63
+ score,
64
+ factors: { directoryObviousness, namingConsistency, patternUniqueness, registrationComplexity },
65
+ recommendation,
66
+ };
67
+ }
68
+ // ─── Factor Computation ──────────────────────────────────────────────────────
69
+ /**
70
+ * What fraction of directories have standard/obvious names?
71
+ * High = all dirs are standard (src/, lib/, utils/) → AI can infer
72
+ * Low = has unique dirs (integration-tests/, adapters/, protocols/) → needs guidance
73
+ */
74
+ function computeDirectoryObviousness(pkg) {
75
+ const dirs = pkg.architecture.directories;
76
+ if (dirs.length === 0)
77
+ return 100;
78
+ let obvious = 0;
79
+ for (const dir of dirs) {
80
+ const name = dir.path.replace(/\/$/, "").split("/").pop()?.toLowerCase() ?? "";
81
+ if (OBVIOUS_DIR_NAMES.has(name))
82
+ obvious++;
83
+ }
84
+ return Math.round((obvious / dirs.length) * 100);
85
+ }
86
+ /**
87
+ * How consistent is the file naming pattern?
88
+ * High = one dominant pattern (>90% kebab-case) → AI infers from siblings
89
+ * Low = mixed patterns or non-standard naming → needs explicit guidance
90
+ */
91
+ function computeNamingConsistency(pkg) {
92
+ const namingConvention = pkg.conventions.find(c => c.category === "file-naming");
93
+ if (!namingConvention)
94
+ return 80; // No naming convention detected → assume standard
95
+ return Math.min(100, namingConvention.confidence.percentage);
96
+ }
97
+ /**
98
+ * Inverse of pattern uniqueness — how many deep pattern signals exist?
99
+ * High = no deep signals (AI can infer everything from siblings)
100
+ * Low = has commonImports, exportSuffix, registrationFile → needs AGENTS.md
101
+ */
102
+ function computePatternUniqueness(pkg) {
103
+ const patterns = pkg.contributionPatterns ?? [];
104
+ if (patterns.length === 0)
105
+ return 90; // No patterns detected → standard structure
106
+ let deepSignals = 0;
107
+ let totalPossible = 0;
108
+ for (const p of patterns) {
109
+ totalPossible += 3; // 3 possible deep signals per pattern
110
+ if (p.commonImports && p.commonImports.length > 0)
111
+ deepSignals++;
112
+ if (p.exportSuffix)
113
+ deepSignals++;
114
+ if (p.registrationFile)
115
+ deepSignals++;
116
+ }
117
+ if (totalPossible === 0)
118
+ return 90;
119
+ // More deep signals = lower inferability (patterns are non-obvious)
120
+ const uniqueRatio = deepSignals / totalPossible;
121
+ return Math.round((1 - uniqueRatio) * 100);
122
+ }
123
+ /**
124
+ * Inverse of registration complexity.
125
+ * High = no registration files → standard structure
126
+ * Low = multiple registration files → complex wiring the AI would miss
127
+ */
128
+ function computeRegistrationComplexity(pkg) {
129
+ const patterns = pkg.contributionPatterns ?? [];
130
+ const registrationFiles = patterns
131
+ .filter(p => p.registrationFile)
132
+ .map(p => p.registrationFile);
133
+ const uniqueRegistrations = new Set(registrationFiles).size;
134
+ if (uniqueRegistrations === 0)
135
+ return 100;
136
+ if (uniqueRegistrations === 1)
137
+ return 60;
138
+ if (uniqueRegistrations === 2)
139
+ return 30;
140
+ return 10; // 3+ registration files = complex wiring
141
+ }
142
+ //# sourceMappingURL=inferability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inferability.js","sourceRoot":"","sources":["../src/inferability.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,8FAA8F;AAC9F,qFAAqF;AAiBrF,gFAAgF;AAEhF,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC;IAChC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU;IAChD,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ;IAC5E,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO;IACnD,OAAO,EAAE,MAAM;IACf,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO;IACrD,QAAQ,EAAE,QAAQ;IAClB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS;IAC3C,KAAK,EAAE,MAAM;IACb,KAAK,EAA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CAAC,CAAC;IAEjC,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC;IAE5D,IAAI,mBAAmB,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IAC1C,IAAI,mBAAmB,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACzC,IAAI,mBAAmB,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACzC,OAAO,EAAE,CAAC,CAAC,yCAAyC;AACtD,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { StructuredAnalysis, ResolvedConfig, PackageAnalysis } from "../types.js";
2
+ /**
3
+ * Format a StructuredAnalysis into a single context file via LLM.
4
+ * For "json" format, returns JSON.stringify directly (no LLM call).
5
+ */
6
+ export declare function formatWithLLM(analysis: StructuredAnalysis, config: Pick<ResolvedConfig, "output" | "llm">): Promise<string>;
7
+ /**
8
+ * Validate LLM output against analysis. If errors found, retry once with corrections.
9
+ * Maximum 1 retry (2x cost per file cap).
10
+ */
11
+ export declare function validateAndCorrect(output: string, analysis: StructuredAnalysis | PackageAnalysis, format: "root" | "package-detail", systemPrompt: string, llmConfig: ResolvedConfig["llm"]): Promise<string>;
12
+ /**
13
+ * Format a StructuredAnalysis using deterministic code for 13 sections
14
+ * and micro-LLM calls for architecture + domain terminology.
15
+ * This is the default mode for agents.md output.
16
+ */
17
+ export declare function formatDeterministic(analysis: StructuredAnalysis, config: Pick<ResolvedConfig, "output" | "llm">, rootDir?: string): Promise<string>;
18
+ /**
19
+ * Generate ONLY the architecture section via a constrained micro-LLM call.
20
+ * Input is limited to directory names, export names, and call graph edges.
21
+ * The LLM cannot hallucinate technologies because it doesn't see them.
22
+ */
23
+ export declare function synthesizeArchitecture(pkg: PackageAnalysis, llmConfig: ResolvedConfig["llm"]): Promise<string>;
24
+ /**
25
+ * Generate domain terminology from README context.
26
+ * Input is ONLY the README first paragraph — can't hallucinate technology stack.
27
+ */
28
+ export declare function synthesizeDomainTerms(readmeContext: string | undefined, llmConfig: ResolvedConfig["llm"]): Promise<string>;
29
+ /**
30
+ * Extract contributing workflow rules from CONTRIBUTING.md context.
31
+ * Input is the first 1000 chars of CONTRIBUTING.md content.
32
+ */
33
+ export declare function synthesizeContributingRules(contributingContext: string | undefined, llmConfig: ResolvedConfig["llm"]): Promise<string>;
@@ -0,0 +1,202 @@
1
+ // src/llm/adapter.ts — Orchestration: serialize -> call LLM -> validate -> output
2
+ // Split from llm-adapter.ts (W5-B1)
3
+ import { LLMError } from "../types.js";
4
+ import { validateOutput } from "../output-validator.js";
5
+ import { callLLMWithRetry } from "./client.js";
6
+ import { serializeToMarkdown } from "./serializer.js";
7
+ import { getTemplate } from "./template-selector.js";
8
+ import { generateDeterministicAgentsMd, assembleFinalOutput, formatArchitectureFallback, } from "../deterministic-formatter.js";
9
+ import { extractReadmeContext, extractContributingContext } from "../existing-docs.js";
10
+ // Note: formatHierarchical and HierarchicalOutput are re-exported from the
11
+ // barrel (src/llm-adapter.ts) via hierarchical.ts, not through this module,
12
+ // to avoid circular dependencies.
13
+ function mapReplacer(_key, value) {
14
+ if (value instanceof Map)
15
+ return Object.fromEntries(value);
16
+ if (value instanceof Set)
17
+ return [...value];
18
+ return value;
19
+ }
20
+ /**
21
+ * Format a StructuredAnalysis into a single context file via LLM.
22
+ * For "json" format, returns JSON.stringify directly (no LLM call).
23
+ */
24
+ export async function formatWithLLM(analysis, config) {
25
+ if (config.output.format === "json") {
26
+ return JSON.stringify(analysis, mapReplacer, 2);
27
+ }
28
+ const serialized = serializeToMarkdown(analysis);
29
+ const isMultiPackage = analysis.packages.length > 1;
30
+ const template = getTemplate(config.output.format, isMultiPackage);
31
+ const systemPrompt = template.systemPrompt;
32
+ const userPrompt = `<instructions>
33
+ ${template.formatInstructions}
34
+ </instructions>
35
+
36
+ <analysis>
37
+ ${serialized}
38
+ </analysis>
39
+
40
+ Generate the AGENTS.md now. Use ONLY data from the <analysis> section. Do NOT add technologies, frameworks, runtimes, or version numbers that are not explicitly present in <analysis>.`;
41
+ const apiKey = config.llm.apiKey;
42
+ if (!apiKey) {
43
+ throw new LLMError("No API key provided. Set ANTHROPIC_API_KEY or use --format json.");
44
+ }
45
+ // W2-1: Generate, validate, optionally retry once with corrections
46
+ const output = await callLLMWithRetry(systemPrompt, userPrompt, config.llm);
47
+ return validateAndCorrect(output, analysis, "root", template.systemPrompt, config.llm);
48
+ }
49
+ // ---- W2-1: Validation + Correction ----
50
+ /**
51
+ * Validate LLM output against analysis. If errors found, retry once with corrections.
52
+ * Maximum 1 retry (2x cost per file cap).
53
+ */
54
+ export async function validateAndCorrect(output, analysis, format, systemPrompt, llmConfig) {
55
+ const validation = validateOutput(output, analysis, format);
56
+ if (validation.isValid || !validation.correctionPrompt) {
57
+ return output;
58
+ }
59
+ // One targeted retry
60
+ try {
61
+ const corrected = await callLLMWithRetry(systemPrompt, validation.correctionPrompt, llmConfig);
62
+ return corrected;
63
+ }
64
+ catch {
65
+ // If retry fails, return original output
66
+ return output;
67
+ }
68
+ }
69
+ // ---- Deterministic Formatting (70% code, 30% micro-LLM) ----
70
+ /**
71
+ * Format a StructuredAnalysis using deterministic code for 13 sections
72
+ * and micro-LLM calls for architecture + domain terminology.
73
+ * This is the default mode for agents.md output.
74
+ */
75
+ export async function formatDeterministic(analysis, config, rootDir) {
76
+ if (config.output.format === "json") {
77
+ return JSON.stringify(analysis, mapReplacer, 2);
78
+ }
79
+ // Step 1: Deterministic sections (no LLM)
80
+ const deterministic = generateDeterministicAgentsMd(analysis);
81
+ // Step 2: Extract context from docs for LLM synthesis
82
+ const pkgDir = analysis.packages[0]?.relativePath ?? ".";
83
+ const readmeContext = extractReadmeContext(pkgDir, rootDir);
84
+ const contributingContext = extractContributingContext(pkgDir, rootDir);
85
+ // Step 3: Micro-LLM calls for synthesis (small, constrained)
86
+ let architectureSection;
87
+ let domainSection;
88
+ let contributingSection;
89
+ if (config.llm.apiKey) {
90
+ // Parallel micro-LLM calls
91
+ const [archResult, domainResult, contributingResult] = await Promise.all([
92
+ synthesizeArchitecture(analysis.packages[0], config.llm),
93
+ synthesizeDomainTerms(readmeContext, config.llm),
94
+ synthesizeContributingRules(contributingContext, config.llm),
95
+ ]);
96
+ architectureSection = archResult;
97
+ domainSection = domainResult;
98
+ contributingSection = contributingResult;
99
+ }
100
+ else {
101
+ // No API key: use deterministic fallback
102
+ architectureSection = formatArchitectureFallback(analysis.packages[0]);
103
+ domainSection = "";
104
+ contributingSection = "";
105
+ }
106
+ // Step 4: Assemble final output
107
+ return assembleFinalOutput(deterministic, architectureSection, domainSection, contributingSection);
108
+ }
109
+ /**
110
+ * Generate ONLY the architecture section via a constrained micro-LLM call.
111
+ * Input is limited to directory names, export names, and call graph edges.
112
+ * The LLM cannot hallucinate technologies because it doesn't see them.
113
+ */
114
+ export async function synthesizeArchitecture(pkg, llmConfig) {
115
+ // Build constrained input — ONLY architecture data
116
+ const input = [];
117
+ input.push(`Package: ${pkg.name}`);
118
+ input.push(`Type: ${pkg.architecture.packageType}`);
119
+ input.push(`Entry: ${pkg.architecture.entryPoint}`);
120
+ input.push("");
121
+ input.push("Directories and their exports:");
122
+ for (const dir of pkg.architecture.directories) {
123
+ if (dir.exports?.length) {
124
+ input.push(` ${dir.purpose}: ${dir.exports.join(", ")}`);
125
+ }
126
+ else {
127
+ input.push(` ${dir.purpose}: ${dir.fileCount} files`);
128
+ }
129
+ }
130
+ if (pkg.callGraph?.length) {
131
+ input.push("");
132
+ input.push("Key call relationships:");
133
+ for (const edge of pkg.callGraph.slice(0, 10)) {
134
+ input.push(` ${edge.from} \u2192 ${edge.to}`);
135
+ }
136
+ }
137
+ const systemPrompt = `You are writing 4-6 bullet points describing a TypeScript package's architecture.
138
+ Use ONLY the directory names, export names, and call relationships provided below.
139
+ Describe CAPABILITIES (what the code does), not file locations.
140
+ Do NOT mention any technology, framework, or library by name — only describe what the exports DO.
141
+ Output ONLY the bullet points, no headers or explanations.`;
142
+ const userPrompt = input.join("\n");
143
+ if (!llmConfig.apiKey)
144
+ return formatArchitectureFallback(pkg);
145
+ try {
146
+ const result = await callLLMWithRetry(systemPrompt, userPrompt, {
147
+ ...llmConfig,
148
+ maxOutputTokens: 500,
149
+ });
150
+ return `## Architecture\n\n${result.trim()}`;
151
+ }
152
+ catch {
153
+ return formatArchitectureFallback(pkg);
154
+ }
155
+ }
156
+ /**
157
+ * Generate domain terminology from README context.
158
+ * Input is ONLY the README first paragraph — can't hallucinate technology stack.
159
+ */
160
+ export async function synthesizeDomainTerms(readmeContext, llmConfig) {
161
+ if (!readmeContext || readmeContext.length < 50 || !llmConfig.apiKey)
162
+ return "";
163
+ const systemPrompt = `Extract 3-5 domain-specific terms from the project description below.
164
+ For each term, provide a one-line definition.
165
+ These are terms that an AI coding tool wouldn't know from reading source code alone.
166
+ Output as a markdown list. If no domain-specific terms are found, output nothing.`;
167
+ try {
168
+ const result = await callLLMWithRetry(systemPrompt, readmeContext, {
169
+ ...llmConfig,
170
+ maxOutputTokens: 300,
171
+ });
172
+ const trimmed = result.trim();
173
+ return trimmed ? `## Domain Terminology\n\n${trimmed}` : "";
174
+ }
175
+ catch {
176
+ return "";
177
+ }
178
+ }
179
+ /**
180
+ * Extract contributing workflow rules from CONTRIBUTING.md context.
181
+ * Input is the first 1000 chars of CONTRIBUTING.md content.
182
+ */
183
+ export async function synthesizeContributingRules(contributingContext, llmConfig) {
184
+ if (!contributingContext || contributingContext.length < 50 || !llmConfig.apiKey)
185
+ return "";
186
+ const systemPrompt = `Extract 4-6 concrete contribution workflow rules from this CONTRIBUTING guide.
187
+ Focus on: PR process, branch naming, commit conventions, setup requirements, testing expectations.
188
+ Format as a markdown bullet list. Only include rules that are specific to this project.
189
+ If the content is just a redirect or generic "contributions welcome" with no process details, output nothing.`;
190
+ try {
191
+ const result = await callLLMWithRetry(systemPrompt, contributingContext, {
192
+ ...llmConfig,
193
+ maxOutputTokens: 400,
194
+ });
195
+ const trimmed = result.trim();
196
+ return trimmed ? `## Contributing Guidelines\n\n${trimmed}` : "";
197
+ }
198
+ catch {
199
+ return "";
200
+ }
201
+ }
202
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/llm/adapter.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,oCAAoC;AAGpC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EACL,6BAA6B,EAC7B,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAEvF,2EAA2E;AAC3E,4EAA4E;AAC5E,kCAAkC;AAElC,SAAS,WAAW,CAAC,IAAY,EAAE,KAAc;IAC/C,IAAI,KAAK,YAAY,GAAG;QAAE,OAAO,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAC3D,IAAI,KAAK,YAAY,GAAG;QAAE,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;IAC5C,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,QAA4B,EAC5B,MAA8C;IAE9C,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,UAAU,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACjD,MAAM,cAAc,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,C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CAAC,CAAC,EAAE,CAAC;IAC9D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,mBAAuC,EACvC,SAAgC;IAEhC,IAAI,CAAC,mBAAmB,IAAI,mBAAmB,CAAC,MAAM,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IAE5F,MAAM,YAAY,GAAG;;;8GAGuF,CAAC;IAE7G,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,YAAY,EAAE,mBAAmB,EAAE;YACvE,GAAG,SAAS;YACZ,eAAe,EAAE,GAAG;SACrB,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;QAC9B,OAAO,OAAO,CAAC,CAAC,CAAC,iCAAiC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACnE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { ResolvedConfig } from "../types.js";
2
+ /**
3
+ * Call LLM API with automatic retry (1 retry after 2s delay).
4
+ */
5
+ export declare function callLLMWithRetry(systemPrompt: string, userPrompt: string, llmConfig: ResolvedConfig["llm"]): Promise<string>;
@@ -0,0 +1,68 @@
1
+ // src/llm/client.ts — HTTP client for LLM API calls
2
+ // Split from llm-adapter.ts (W5-B1)
3
+ import { LLMError } from "../types.js";
4
+ /**
5
+ * Call LLM API with automatic retry (1 retry after 2s delay).
6
+ */
7
+ export async function callLLMWithRetry(systemPrompt, userPrompt, llmConfig) {
8
+ try {
9
+ return await callLLM(systemPrompt, userPrompt, llmConfig);
10
+ }
11
+ catch (err) {
12
+ await new Promise((resolve) => setTimeout(resolve, 2000));
13
+ try {
14
+ return await callLLM(systemPrompt, userPrompt, llmConfig);
15
+ }
16
+ catch (retryErr) {
17
+ throw new LLMError(`LLM API failed after retry: ${retryErr instanceof Error ? retryErr.message : String(retryErr)}`);
18
+ }
19
+ }
20
+ }
21
+ async function callLLM(systemPrompt, userPrompt, llmConfig) {
22
+ const baseUrl = llmConfig.baseUrl ?? "https://api.anthropic.com";
23
+ const url = `${baseUrl}/v1/messages`;
24
+ // E-33: AbortController timeout
25
+ const controller = new AbortController();
26
+ const timer = setTimeout(() => controller.abort(), 120_000);
27
+ try {
28
+ const response = await fetch(url, {
29
+ method: "POST",
30
+ signal: controller.signal,
31
+ headers: {
32
+ "Content-Type": "application/json",
33
+ "x-api-key": llmConfig.apiKey,
34
+ "anthropic-version": "2023-06-01",
35
+ },
36
+ body: JSON.stringify({
37
+ model: llmConfig.model,
38
+ max_tokens: llmConfig.maxOutputTokens,
39
+ system: systemPrompt,
40
+ messages: [{ role: "user", content: userPrompt }],
41
+ temperature: 0,
42
+ }),
43
+ });
44
+ clearTimeout(timer);
45
+ if (!response.ok) {
46
+ const body = await response.text().catch(() => "");
47
+ // Truncate error body to avoid leaking sensitive data in logs
48
+ const safeBody = body.slice(0, 200);
49
+ throw new LLMError(`LLM API returned ${response.status}: ${safeBody}`, response.status);
50
+ }
51
+ const data = await response.json();
52
+ const text = data?.content?.[0]?.text;
53
+ if (!text) {
54
+ throw new LLMError("LLM response missing content text");
55
+ }
56
+ return text;
57
+ }
58
+ catch (err) {
59
+ clearTimeout(timer);
60
+ if (err instanceof LLMError)
61
+ throw err;
62
+ if (err instanceof Error && err.name === "AbortError") {
63
+ throw new LLMError("LLM API request timed out after 120s");
64
+ }
65
+ throw err;
66
+ }
67
+ }
68
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/llm/client.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,oCAAoC;AAGpC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAMvC;;GAE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AC7D,CAAC;QACD,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { StructuredAnalysis, ResolvedConfig } from "../types.js";
2
+ export interface HierarchicalOutput {
3
+ root: string;
4
+ packages: {
5
+ filename: string;
6
+ content: string;
7
+ }[];
8
+ }
9
+ /**
10
+ * Format a StructuredAnalysis into hierarchical output: root AGENTS.md + per-package detail files.
11
+ * Only applicable when format is "agents.md" and there are multiple packages.
12
+ */
13
+ export declare function formatHierarchical(analysis: StructuredAnalysis, config: Pick<ResolvedConfig, "output" | "llm">): Promise<HierarchicalOutput>;
14
+ /**
15
+ * Format hierarchical output using deterministic code for sections + micro-LLM for synthesis.
16
+ * Generates root AGENTS.md + per-package detail files without full LLM calls.
17
+ */
18
+ export declare function formatHierarchicalDeterministic(analysis: StructuredAnalysis, config: Pick<ResolvedConfig, "output" | "llm">): Promise<HierarchicalOutput>;
19
+ /**
20
+ * Convert a package name to a safe filename.
21
+ * @scope/my-package-name -> my-package-name.md
22
+ */
23
+ export declare function toPackageFilename(name: string): string;
@@ -0,0 +1,126 @@
1
+ // src/llm/hierarchical.ts — Multi-file hierarchical output
2
+ // Split from llm-adapter.ts (W5-B1)
3
+ import { LLMError } from "../types.js";
4
+ import { agentsMdMultiRootTemplate, agentsMdPackageDetailTemplate, } from "../templates/agents-md.js";
5
+ import { callLLMWithRetry } from "./client.js";
6
+ import { serializeToMarkdown, serializePackageToMarkdown } from "./serializer.js";
7
+ import { validateAndCorrect, synthesizeArchitecture, synthesizeDomainTerms, synthesizeContributingRules } from "./adapter.js";
8
+ import { generateDeterministicAgentsMd, generatePackageDeterministicAgentsMd, assembleFinalOutput, formatArchitectureFallback, } from "../deterministic-formatter.js";
9
+ import { extractReadmeContext, extractContributingContext } from "../existing-docs.js";
10
+ /**
11
+ * Format a StructuredAnalysis into hierarchical output: root AGENTS.md + per-package detail files.
12
+ * Only applicable when format is "agents.md" and there are multiple packages.
13
+ */
14
+ export async function formatHierarchical(analysis, config) {
15
+ const apiKey = config.llm.apiKey;
16
+ if (!apiKey) {
17
+ throw new LLMError("No API key provided. Set ANTHROPIC_API_KEY or use --format json.");
18
+ }
19
+ // Generate root AGENTS.md with lean multi-package template
20
+ const rootSerialized = serializeToMarkdown(analysis);
21
+ const rootTemplate = agentsMdMultiRootTemplate;
22
+ // Build package detail filename list for root template to reference
23
+ const packageFilenames = analysis.packages.map((pkg) => ({
24
+ name: pkg.name,
25
+ filename: toPackageFilename(pkg.name),
26
+ }));
27
+ const filenameHint = `\n\nPackage detail files will be at:\n${packageFilenames.map((p) => `- packages/${p.filename}`).join("\n")}`;
28
+ const rootPrompt = `<instructions>
29
+ ${rootTemplate.formatInstructions}${filenameHint}
30
+ </instructions>
31
+
32
+ <analysis>
33
+ ${rootSerialized}
34
+ </analysis>
35
+
36
+ Generate the AGENTS.md now. Use ONLY data from the <analysis> section. Do NOT add technologies, frameworks, runtimes, or version numbers that are not explicitly present in <analysis>.`;
37
+ const rawRoot = await callLLMWithRetry(rootTemplate.systemPrompt, rootPrompt, config.llm);
38
+ // W2-1: Validate root output
39
+ const rootContent = await validateAndCorrect(rawRoot, analysis, "root", rootTemplate.systemPrompt, config.llm);
40
+ // Generate per-package detail files (can be parallelized)
41
+ const packagePromises = analysis.packages.map(async (pkg) => {
42
+ const pkgSerialized = serializePackageToMarkdown(pkg);
43
+ const pkgTemplate = agentsMdPackageDetailTemplate;
44
+ const pkgPrompt = `<instructions>
45
+ ${pkgTemplate.formatInstructions}
46
+ </instructions>
47
+
48
+ <analysis>
49
+ ${pkgSerialized}
50
+ </analysis>
51
+
52
+ Generate the package detail file now. Use ONLY data from the <analysis> section. Do NOT add technologies, frameworks, runtimes, or version numbers that are not explicitly present in <analysis>.`;
53
+ const rawContent = await callLLMWithRetry(pkgTemplate.systemPrompt, pkgPrompt, config.llm);
54
+ // W2-1: Validate per-package output
55
+ const content = await validateAndCorrect(rawContent, pkg, "package-detail", pkgTemplate.systemPrompt, config.llm);
56
+ return {
57
+ filename: toPackageFilename(pkg.name),
58
+ content,
59
+ };
60
+ });
61
+ const packages = await Promise.all(packagePromises);
62
+ return { root: rootContent, packages };
63
+ }
64
+ /**
65
+ * Format hierarchical output using deterministic code for sections + micro-LLM for synthesis.
66
+ * Generates root AGENTS.md + per-package detail files without full LLM calls.
67
+ */
68
+ export async function formatHierarchicalDeterministic(analysis, config) {
69
+ // Root AGENTS.md — deterministic sections
70
+ const rootDeterministic = generateDeterministicAgentsMd(analysis);
71
+ // Doc context for LLM synthesis
72
+ const pkgDir = analysis.packages[0]?.relativePath ?? ".";
73
+ const readmeContext = extractReadmeContext(pkgDir, analysis.meta.rootDir);
74
+ const contributingContext = extractContributingContext(pkgDir, analysis.meta.rootDir);
75
+ // Micro-LLM calls for root architecture + domain + contributing (if API key available)
76
+ let rootArchitecture;
77
+ let rootDomain;
78
+ let rootContributing;
79
+ if (config.llm.apiKey) {
80
+ const [archResult, domainResult, contributingResult] = await Promise.all([
81
+ synthesizeArchitecture(analysis.packages[0], config.llm),
82
+ synthesizeDomainTerms(readmeContext, config.llm),
83
+ synthesizeContributingRules(contributingContext, config.llm),
84
+ ]);
85
+ rootArchitecture = archResult;
86
+ rootDomain = domainResult;
87
+ rootContributing = contributingResult;
88
+ }
89
+ else {
90
+ rootArchitecture = formatArchitectureFallback(analysis.packages[0]);
91
+ rootDomain = "";
92
+ rootContributing = "";
93
+ }
94
+ const rootContent = assembleFinalOutput(rootDeterministic, rootArchitecture, rootDomain, rootContributing);
95
+ // Per-package detail files — deterministic + micro-LLM architecture per package
96
+ const packagePromises = analysis.packages.map(async (pkg) => {
97
+ const pkgDeterministic = generatePackageDeterministicAgentsMd(pkg);
98
+ let pkgArchitecture;
99
+ if (config.llm.apiKey) {
100
+ pkgArchitecture = await synthesizeArchitecture(pkg, config.llm);
101
+ }
102
+ else {
103
+ pkgArchitecture = formatArchitectureFallback(pkg);
104
+ }
105
+ const content = assembleFinalOutput(pkgDeterministic, pkgArchitecture, "");
106
+ return {
107
+ filename: toPackageFilename(pkg.name),
108
+ content,
109
+ };
110
+ });
111
+ const packages = await Promise.all(packagePromises);
112
+ return { root: rootContent, packages };
113
+ }
114
+ /**
115
+ * Convert a package name to a safe filename.
116
+ * @scope/my-package-name -> my-package-name.md
117
+ */
118
+ export function toPackageFilename(name) {
119
+ return name
120
+ .replace(/^@[^/]+\//, "") // Strip scope
121
+ .replace(/[^a-z0-9-]/gi, "-") // Replace unsafe chars
122
+ .replace(/-+/g, "-") // Collapse multiple dashes
123
+ .replace(/^-|-$/g, "") // Trim dashes
124
+ + ".md";
125
+ }
126
+ //# sourceMappingURL=hierarchical.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hierarchical.js","sourceRoot":"","sources":["../../src/llm/hierarchical.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oCAAoC;AAGpC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EACL,yBAAyB,EACzB,6BAA6B,GAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAC9H,OAAO,EACL,6BAA6B,EAC7B,oCAAoC,EACpC,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAOvF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,QAA4B,EAC5B,MAA8C;IAE9C,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;IACjC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,QAAQ,CA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