@mmerterden/multi-agent-pipeline 23.2.0 → 23.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 (230) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +25 -6
  3. package/README.tr.md +26 -7
  4. package/docs/adr/0008-installer-modularization-and-secret-leak-defense.md +1 -1
  5. package/docs/adr/0010-own-code-graph.md +299 -8
  6. package/docs/architecture.md +3 -3
  7. package/docs/ecosystem.md +10 -10
  8. package/docs/engineering.md +4 -4
  9. package/docs/facts.json +8 -8
  10. package/docs/features.md +6 -6
  11. package/docs/performance.md +17 -17
  12. package/install/_dev-only-files.mjs +9 -0
  13. package/install/claude.mjs +28 -2
  14. package/install/templates/claude-hooks.json +32 -1
  15. package/manifest.json +229 -161
  16. package/package.json +11 -3
  17. package/pipeline/commands/multi-agent/SKILL.md +1 -1
  18. package/pipeline/commands/multi-agent/design-check/SKILL.md +2 -2
  19. package/pipeline/commands/multi-agent/diff-explain/SKILL.md +3 -3
  20. package/pipeline/commands/multi-agent/fable-status/SKILL.md +1 -1
  21. package/pipeline/commands/multi-agent/graph/SKILL.md +57 -24
  22. package/pipeline/commands/multi-agent/pair/SKILL.md +92 -0
  23. package/pipeline/commands/multi-agent/prune-prompts/SKILL.md +1 -1
  24. package/pipeline/commands/multi-agent/search/SKILL.md +7 -1
  25. package/pipeline/commands/multi-agent/status/SKILL.md +4 -0
  26. package/pipeline/commands/multi-agent/sync/SKILL.md +3 -3
  27. package/pipeline/contract/CHANGELOG.md +49 -0
  28. package/pipeline/contract/build.mjs +13 -1
  29. package/pipeline/contract/fixtures/error-invalid-request.json +1 -1
  30. package/pipeline/contract/fixtures/error-unauthorized.json +1 -1
  31. package/pipeline/contract/fixtures/runs-awaiting-question.json +4 -1
  32. package/pipeline/contract/fixtures/runs-empty.json +1 -1
  33. package/pipeline/contract/fixtures/runs-failed.json +4 -1
  34. package/pipeline/contract/fixtures/runs-old-schema.json +3 -0
  35. package/pipeline/contract/fixtures/runs-pr-opened-redacted.json +4 -1
  36. package/pipeline/contract/fixtures/runs-pr-opened.json +4 -1
  37. package/pipeline/contract/fixtures/runs-running.json +4 -1
  38. package/pipeline/contract/manifest.json +28 -15
  39. package/pipeline/contract/types/index.d.ts +55 -3
  40. package/pipeline/lib/detach-self.mjs +95 -0
  41. package/pipeline/lib/model-rung.sh +1 -1
  42. package/pipeline/lib/public-mcp-servers.mjs +33 -0
  43. package/pipeline/lib/rotated-log.mjs +93 -0
  44. package/pipeline/lib/tls-trust.mjs +29 -0
  45. package/pipeline/lib/usage-lifecycle.mjs +9 -11
  46. package/pipeline/lib/usage-names.generated.mjs +614 -0
  47. package/pipeline/lib/usage-run-key.mjs +235 -0
  48. package/pipeline/lib/usage-vocab.mjs +210 -0
  49. package/pipeline/multi-agent-refs/analysis/intake.md +2 -2
  50. package/pipeline/multi-agent-refs/analysis/render.md +1 -1
  51. package/pipeline/multi-agent-refs/channels/generator.md +4 -5
  52. package/pipeline/multi-agent-refs/cross-cli-contract.md +4 -4
  53. package/pipeline/multi-agent-refs/design-check/scope-and-ledger.md +1 -1
  54. package/pipeline/multi-agent-refs/features/code-graph.md +146 -11
  55. package/pipeline/multi-agent-refs/features/code-intelligence.md +16 -14
  56. package/pipeline/multi-agent-refs/features/dev-critic.md +7 -7
  57. package/pipeline/multi-agent-refs/features/model-fallback.md +9 -7
  58. package/pipeline/multi-agent-refs/features/remote-control.md +252 -0
  59. package/pipeline/multi-agent-refs/features/review-delta.md +1 -1
  60. package/pipeline/multi-agent-refs/features/review-file-set.md +3 -3
  61. package/pipeline/multi-agent-refs/features/review-multi-repo.md +1 -1
  62. package/pipeline/multi-agent-refs/features/session-brief.md +42 -0
  63. package/pipeline/multi-agent-refs/features/skill-conformance.md +3 -3
  64. package/pipeline/multi-agent-refs/features/usage-reporting.md +252 -24
  65. package/pipeline/multi-agent-refs/help/en.md +3 -2
  66. package/pipeline/multi-agent-refs/help/tr.md +3 -2
  67. package/pipeline/multi-agent-refs/knowledge.md +1 -1
  68. package/pipeline/multi-agent-refs/orchestrator/copilot-pipeline.md +1 -1
  69. package/pipeline/multi-agent-refs/orchestrator/dispatcher.md +1 -1
  70. package/pipeline/multi-agent-refs/phases/operations.md +2 -2
  71. package/pipeline/multi-agent-refs/phases/phase-0-init.md +13 -12
  72. package/pipeline/multi-agent-refs/phases/phase-1-plan.md +4 -4
  73. package/pipeline/multi-agent-refs/phases/phase-3-review.md +5 -3
  74. package/pipeline/multi-agent-refs/phases/phase-5-report.md +1 -1
  75. package/pipeline/multi-agent-refs/platform-parity.md +2 -2
  76. package/pipeline/multi-agent-refs/review/panel.md +1 -1
  77. package/pipeline/multi-agent-refs/wiki-capture.md +3 -17
  78. package/pipeline/office/index.html +1207 -233
  79. package/pipeline/office/toolkit.json +1 -1
  80. package/pipeline/rules/outside-the-pipeline.md +1 -1
  81. package/pipeline/schemas/activity.schema.json +23 -0
  82. package/pipeline/schemas/agent-state.schema.json +6 -1
  83. package/pipeline/schemas/code-graph-calls.schema.json +254 -0
  84. package/pipeline/schemas/code-graph-docs.schema.json +223 -0
  85. package/pipeline/schemas/code-graph-infra.schema.json +227 -0
  86. package/pipeline/schemas/code-graph.schema.json +2 -2
  87. package/pipeline/schemas/examples/design-check-config.json +27 -0
  88. package/pipeline/schemas/learning-curve.schema.json +67 -0
  89. package/pipeline/schemas/office-jobs.json +69 -2
  90. package/pipeline/schemas/office-jobs.schema.json +8 -1
  91. package/pipeline/schemas/phases.json +5 -0
  92. package/pipeline/schemas/phases.schema.json +8 -0
  93. package/pipeline/schemas/prefs.schema.json +46 -12
  94. package/pipeline/schemas/runs-index.schema.json +17 -0
  95. package/pipeline/schemas/toolkit-path-params.json +84 -8
  96. package/pipeline/scripts/README.md +1 -0
  97. package/pipeline/scripts/_code-graph.mjs +184 -103
  98. package/pipeline/scripts/_contract-core.mjs +1 -1
  99. package/pipeline/scripts/_contract-routes-office.mjs +21 -0
  100. package/pipeline/scripts/_diff-impact.mjs +21 -2
  101. package/pipeline/scripts/_graph-sidecars.mjs +372 -0
  102. package/pipeline/scripts/_http-post.mjs +103 -115
  103. package/pipeline/scripts/_safe-read.mjs +57 -0
  104. package/pipeline/scripts/_skill-practices.mjs +26 -0
  105. package/pipeline/scripts/_strip-code.mjs +380 -0
  106. package/pipeline/scripts/activity-snapshot.mjs +13 -1
  107. package/pipeline/scripts/aggregate-metrics.mjs +3 -5
  108. package/pipeline/scripts/call-graph/index.mjs +78 -0
  109. package/pipeline/scripts/call-graph/lang/cpp.mjs +308 -0
  110. package/pipeline/scripts/call-graph/lang/csharp.mjs +130 -0
  111. package/pipeline/scripts/call-graph/lang/go.mjs +303 -0
  112. package/pipeline/scripts/call-graph/lang/java.mjs +370 -0
  113. package/pipeline/scripts/call-graph/lang/kotlin.mjs +397 -0
  114. package/pipeline/scripts/call-graph/lang/python.mjs +399 -0
  115. package/pipeline/scripts/call-graph/lang/rust.mjs +345 -0
  116. package/pipeline/scripts/call-graph/lang/shared.mjs +230 -0
  117. package/pipeline/scripts/call-graph/lang/swift.mjs +432 -0
  118. package/pipeline/scripts/call-graph/lang/typescript.mjs +692 -0
  119. package/pipeline/scripts/call-graph/lex.mjs +396 -0
  120. package/pipeline/scripts/call-graph/platform.mjs +86 -0
  121. package/pipeline/scripts/call-graph/profiles.mjs +89 -0
  122. package/pipeline/scripts/call-graph/resolve.mjs +1125 -0
  123. package/pipeline/scripts/call-graph/scan.mjs +267 -0
  124. package/pipeline/scripts/code-graph-rules/android.json +7 -2
  125. package/pipeline/scripts/code-graph-rules/cpp.json +99 -0
  126. package/pipeline/scripts/code-graph-rules/csharp.json +102 -0
  127. package/pipeline/scripts/code-graph-rules/go.json +2 -1
  128. package/pipeline/scripts/code-graph-rules/ios.json +3 -1
  129. package/pipeline/scripts/code-graph-rules/java.json +76 -0
  130. package/pipeline/scripts/code-graph-rules/node.json +7 -2
  131. package/pipeline/scripts/code-graph-rules/python.json +6 -2
  132. package/pipeline/scripts/code-graph-rules/rust.json +105 -0
  133. package/pipeline/scripts/contract-server.mjs +1 -0
  134. package/pipeline/scripts/cost-table.json +6 -5
  135. package/pipeline/scripts/feedback-send.mjs +26 -26
  136. package/pipeline/scripts/gate-ledger.mjs +2 -1
  137. package/pipeline/scripts/gen-usage-names.mjs +124 -0
  138. package/pipeline/scripts/graph-affected.mjs +109 -20
  139. package/pipeline/scripts/graph-build.mjs +95 -15
  140. package/pipeline/scripts/graph-export.mjs +272 -0
  141. package/pipeline/scripts/graph-hint.mjs +15 -2
  142. package/pipeline/scripts/graph-query.mjs +305 -26
  143. package/pipeline/scripts/graph-report.mjs +187 -1
  144. package/pipeline/scripts/health-report.mjs +3 -4
  145. package/pipeline/scripts/infra/docs.mjs +317 -0
  146. package/pipeline/scripts/infra/extract.mjs +998 -0
  147. package/pipeline/scripts/infra/graph.mjs +245 -0
  148. package/pipeline/scripts/infra/yaml-lite.mjs +311 -0
  149. package/pipeline/scripts/job-launch.mjs +67 -2
  150. package/pipeline/scripts/learning-curve.mjs +288 -178
  151. package/pipeline/scripts/log-metric.sh +10 -1
  152. package/pipeline/scripts/note-agent-event.mjs +3 -4
  153. package/pipeline/scripts/note-command-use.mjs +333 -0
  154. package/pipeline/scripts/note-command-use.sh +126 -0
  155. package/pipeline/scripts/note-mcp-call.sh +89 -0
  156. package/pipeline/scripts/note-mcp-failure.mjs +272 -1
  157. package/pipeline/scripts/note-session.sh +62 -3
  158. package/pipeline/scripts/note-skill-use.mjs +58 -2
  159. package/pipeline/scripts/office-build.mjs +115 -1
  160. package/pipeline/scripts/office-memory.mjs +14 -5
  161. package/pipeline/scripts/pair.mjs +333 -0
  162. package/pipeline/scripts/pre-push-check.sh +1 -1
  163. package/pipeline/scripts/remote/cbor.mjs +128 -0
  164. package/pipeline/scripts/remote/contract.mjs +98 -0
  165. package/pipeline/scripts/remote/handler.mjs +317 -0
  166. package/pipeline/scripts/remote/handles.mjs +57 -0
  167. package/pipeline/scripts/remote/lifecycle.mjs +186 -0
  168. package/pipeline/scripts/remote/listener.mjs +204 -0
  169. package/pipeline/scripts/remote/lockout.mjs +103 -0
  170. package/pipeline/scripts/remote/nonces.mjs +61 -0
  171. package/pipeline/scripts/remote/pairing.mjs +519 -0
  172. package/pipeline/scripts/remote/qr-encode.mjs +459 -0
  173. package/pipeline/scripts/remote/store.mjs +188 -0
  174. package/pipeline/scripts/remote/transport.mjs +211 -0
  175. package/pipeline/scripts/remote/verbs.json +70 -0
  176. package/pipeline/scripts/remote/verbs.mjs +217 -0
  177. package/pipeline/scripts/remote/webauthn.mjs +169 -0
  178. package/pipeline/scripts/remote/wire.mjs +364 -0
  179. package/pipeline/scripts/remote-listener.mjs +83 -0
  180. package/pipeline/scripts/route-learn.mjs +4 -4
  181. package/pipeline/scripts/run-kill.mjs +1 -1
  182. package/pipeline/scripts/run-write.mjs +13 -2
  183. package/pipeline/scripts/runs-index.mjs +30 -3
  184. package/pipeline/scripts/search-logs.sh +9 -0
  185. package/pipeline/scripts/session-brief.mjs +458 -0
  186. package/pipeline/scripts/session-brief.sh +130 -0
  187. package/pipeline/scripts/test-gap-rules/cpp.json +25 -0
  188. package/pipeline/scripts/test-gap-rules/csharp.json +20 -0
  189. package/pipeline/scripts/test-gap-rules/java.json +20 -0
  190. package/pipeline/scripts/test-gap-rules/rust.json +14 -0
  191. package/pipeline/scripts/token-budget-report.mjs +3 -2
  192. package/pipeline/scripts/uninstall.mjs +29 -0
  193. package/pipeline/scripts/usage-access.mjs +16 -31
  194. package/pipeline/scripts/usage-health.mjs +31 -62
  195. package/pipeline/scripts/usage-register-beacon.mjs +11 -22
  196. package/pipeline/scripts/usage-register.mjs +39 -29
  197. package/pipeline/scripts/usage-report.mjs +579 -178
  198. package/pipeline/scripts/validate-code-graph.mjs +361 -111
  199. package/pipeline/scripts/write-state.mjs +39 -0
  200. package/pipeline/skills/.skill-manifest.json +22 -18
  201. package/pipeline/skills/.skills-index.json +13 -2
  202. package/pipeline/skills/shared/README.md +5 -4
  203. package/pipeline/skills/shared/core/multi-agent-design-check/SKILL.md +1 -1
  204. package/pipeline/skills/shared/core/multi-agent-diff-explain/SKILL.md +3 -3
  205. package/pipeline/skills/shared/core/multi-agent-fable-status/SKILL.md +1 -1
  206. package/pipeline/skills/shared/core/multi-agent-graph/SKILL.md +55 -21
  207. package/pipeline/skills/shared/core/multi-agent-pair/SKILL.md +41 -0
  208. package/pipeline/skills/shared/core/multi-agent-prune-prompts/SKILL.md +1 -1
  209. package/pipeline/skills/shared/core/multi-agent-sync/SKILL.md +3 -3
  210. package/pipeline/skills/shared/external/app-store-optimization/SKILL.md +2 -3
  211. package/pipeline/skills/shared/external/app-store-optimization/references/keyword-research-methodology.md +2 -2
  212. package/pipeline/skills/shared/external/app-store-optimization/references/product-page-variants.md +2 -2
  213. package/pipeline/skills/shared/external/app-store-review/SKILL.md +11 -4
  214. package/pipeline/skills/shared/external/build-settings-audit/SKILL.md +1 -1
  215. package/pipeline/skills/shared/external/build-time-benchmark/SKILL.md +5 -5
  216. package/pipeline/skills/shared/external/build-time-fixes/SKILL.md +5 -5
  217. package/pipeline/skills/shared/external/build-time-optimizer/SKILL.md +6 -6
  218. package/pipeline/skills/shared/external/free-llm-apis/references/providers.md +1 -0
  219. package/pipeline/skills/shared/external/ios-coding-standard/references/STANDARD.md +2 -2
  220. package/pipeline/skills/shared/external/ios-haptics/references/core-haptics.md +1 -1
  221. package/pipeline/skills/shared/external/localization-reuse-map/references/publish-and-snapshot.md +1 -1
  222. package/pipeline/skills/shared/external/package-build-audit/SKILL.md +3 -3
  223. package/pipeline/skills/shared/external/reverse-engineer-own-app/SKILL.md +2 -3
  224. package/pipeline/skills/shared/external/swift-compile-hotspots/SKILL.md +2 -2
  225. package/pipeline/skills/shared/external/weatherkit/SKILL.md +5 -6
  226. package/pipeline/skills/skills-index.md +3 -2
  227. package/docs/FIGMA_PIPELINE.md +0 -137
  228. package/pipeline/lib/identifier-scan.mjs +0 -156
  229. package/pipeline/scripts/publish-staged.mjs +0 -324
  230. package/pipeline/skills/shared/external/ios-coding-standard/scripts/check_structure.py +0 -765
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$comment": "Generated by pipeline/scripts/gen-toolkit-path-params.mjs from multi-agent-mcp tool-manifest.json; do not edit. Per toolkit tool: the parameters it writes to and the filesystem paths it reads, both confined by scripts/unattended_policy.py.",
3
- "toolkitVersion": "4.2.0",
3
+ "toolkitVersion": "4.3.0",
4
4
  "tools": {
5
5
  "agent_query_output": {
6
6
  "writes": [],
@@ -162,6 +162,18 @@
162
162
  "writes": [],
163
163
  "reads": []
164
164
  },
165
+ "binary_analyse": {
166
+ "writes": [],
167
+ "reads": [
168
+ "path"
169
+ ]
170
+ },
171
+ "binary_android": {
172
+ "writes": [],
173
+ "reads": [
174
+ "path"
175
+ ]
176
+ },
165
177
  "binary_compare_versions": {
166
178
  "writes": [],
167
179
  "reads": [
@@ -176,6 +188,24 @@
176
188
  "observed"
177
189
  ]
178
190
  },
191
+ "binary_evm": {
192
+ "writes": [],
193
+ "reads": [
194
+ "path"
195
+ ]
196
+ },
197
+ "binary_firmware": {
198
+ "writes": [],
199
+ "reads": [
200
+ "path"
201
+ ]
202
+ },
203
+ "binary_formats": {
204
+ "writes": [],
205
+ "reads": [
206
+ "path"
207
+ ]
208
+ },
179
209
  "binary_inspect": {
180
210
  "writes": [],
181
211
  "reads": [
@@ -188,6 +218,18 @@
188
218
  "path"
189
219
  ]
190
220
  },
221
+ "binary_pcap": {
222
+ "writes": [],
223
+ "reads": [
224
+ "path"
225
+ ]
226
+ },
227
+ "binary_sqlite": {
228
+ "writes": [],
229
+ "reads": [
230
+ "path"
231
+ ]
232
+ },
191
233
  "binary_strings_endpoints": {
192
234
  "writes": [],
193
235
  "reads": [
@@ -250,7 +292,9 @@
250
292
  },
251
293
  "context_get": {
252
294
  "writes": [],
253
- "reads": []
295
+ "reads": [
296
+ "path"
297
+ ]
254
298
  },
255
299
  "context_index": {
256
300
  "writes": [],
@@ -606,7 +650,8 @@
606
650
  "out_dir"
607
651
  ],
608
652
  "reads": [
609
- "path"
653
+ "path",
654
+ "against"
610
655
  ]
611
656
  },
612
657
  "media_music_beats": {
@@ -624,14 +669,20 @@
624
669
  ]
625
670
  },
626
671
  "media_thumbnail_check": {
627
- "writes": [],
672
+ "writes": [
673
+ "cover.output"
674
+ ],
628
675
  "reads": [
629
676
  "path"
630
677
  ]
631
678
  },
632
679
  "media_transcript": {
633
- "writes": [],
634
- "reads": []
680
+ "writes": [
681
+ "out_dir"
682
+ ],
683
+ "reads": [
684
+ "path"
685
+ ]
635
686
  },
636
687
  "media_video_check": {
637
688
  "writes": [],
@@ -660,7 +711,21 @@
660
711
  "footage_dir",
661
712
  "voice_dir",
662
713
  "sfx[].file",
663
- "music"
714
+ "music",
715
+ "brand",
716
+ "brand.logo",
717
+ "brand.intro",
718
+ "brand.outro",
719
+ "scenes[].image",
720
+ "variants[].music",
721
+ "variants[].footage_dir",
722
+ "variants[].voice_dir",
723
+ "variants[].brand",
724
+ "variants[].brand.logo",
725
+ "variants[].brand.intro",
726
+ "variants[].brand.outro",
727
+ "variants[].scenes[].image",
728
+ "variants[].sfx[].file"
664
729
  ]
665
730
  },
666
731
  "pass_build": {
@@ -940,6 +1005,14 @@
940
1005
  "bibliography"
941
1006
  ]
942
1007
  },
1008
+ "thesis_convert": {
1009
+ "writes": [
1010
+ "out"
1011
+ ],
1012
+ "reads": [
1013
+ "paths"
1014
+ ]
1015
+ },
943
1016
  "thesis_overlap": {
944
1017
  "writes": [],
945
1018
  "reads": [
@@ -954,7 +1027,9 @@
954
1027
  ]
955
1028
  },
956
1029
  "thesis_reference_verify": {
957
- "writes": [],
1030
+ "writes": [
1031
+ "out_dir"
1032
+ ],
958
1033
  "reads": [
959
1034
  "bibliography"
960
1035
  ]
@@ -1183,6 +1258,7 @@
1183
1258
  },
1184
1259
  "web_session_open": {
1185
1260
  "writes": [
1261
+ "record_video.out_dir",
1186
1262
  "profile_dir"
1187
1263
  ],
1188
1264
  "reads": []
@@ -94,6 +94,7 @@ Shell scripts invoked during pipeline execution.
94
94
  - `eval-mine-corpus.mjs` - manual maintainer CLI: mines `~/.claude/memory/multi-agent/<repo-slug>/triage-corpus.jsonl` from real runs into new triage eval fixtures (dev-only, excluded from the npm package; not part of `npm test`)
95
95
  - `gen-skills-index.mjs` - regenerates `pipeline/skills/shared/README.md` skill catalog
96
96
  - `gen-facts.mjs` - derives `docs/facts.json`, the counts the docs and the website state; `gen-fact-marks.mjs` renders them into the docs
97
+ - `gen-office-command-matrix.mjs` - writes `pipeline/office/command-matrix.json`, how the office handles each command (start, window, or terminal-only with its reason); `--check` runs in `npm test`
97
98
  - `migrate-prefs.mjs` - preference migration driver
98
99
  - `migrate-state.mjs` - generic migration runner (reads `schemas/migrations/`)
99
100
  - `token-budget-report.mjs` - per-phase token usage report
@@ -5,11 +5,12 @@
5
5
  * instead of hand-writing architecture.md from a single task's window. The
6
6
  * design: extraction with zero LLM cost, one graph file, an incremental
7
7
  * manifest gate, hub nodes, and token-budgeted traversal as the query surface.
8
- * The extraction itself is
8
+ * Definitions and imports are
9
9
  * regex over comment-stripped source rather than tree-sitter - a tree-sitter
10
- * binding would be an npm runtime dependency, which ADR-0004 forbids. That
11
- * trade is deliberate: definitions and imports survive it, call graphs and type
12
- * resolution do not, and neither consumer needs those.
10
+ * binding would be an npm runtime dependency, which ADR-0004 forbids. Calls are
11
+ * resolved by the hand-written readers in call-graph/, which are heuristic and
12
+ * say so on every edge (`via`, `confidence`); infrastructure, configuration,
13
+ * documentation and rationale come from infra/.
13
14
  *
14
15
  * Definition and import patterns come from the rule files. References do NOT:
15
16
  * a per-language reference regex is both brittle and redundant once every
@@ -17,10 +18,13 @@
17
18
  * with the global symbol index instead. That is language-agnostic and cannot
18
19
  * drift from the definition patterns, because it is derived from them.
19
20
  *
20
- * Two passes, one read per file:
21
+ * Passes, one read per file:
21
22
  * 1. strip comments and strings, extract definitions + imports, keep the
22
- * file's identifier set (a Set of strings, not the source text)
23
+ * file's identifier set (a Set of strings, not the source text) and the
24
+ * file's call facts
23
25
  * 2. intersect each identifier set with the symbol index to emit references
26
+ * 3. resolve the call facts across files into calls edges
27
+ * 4. add infrastructure, configuration, documentation and rationale nodes
24
28
  *
25
29
  * Zero runtime dependencies (ADR-0004).
26
30
  *
@@ -33,9 +37,19 @@ import { join, dirname, relative, sep } from "node:path";
33
37
  import { fileURLToPath } from "node:url";
34
38
  import { isExcludedBy } from "./_path-match.mjs";
35
39
  import { supertypesAt } from "./_supertypes.mjs";
40
+ import { analyzeFile, addCallEdges } from "./call-graph/index.mjs";
41
+ import { codeReads, mayReadConfig } from "./infra/extract.mjs";
42
+ import { addInfra } from "./infra/graph.mjs";
43
+ import { addDocs, rationaleComments } from "./infra/docs.mjs";
44
+ import { attachSidecars, makeSidecar } from "./_graph-sidecars.mjs";
45
+ import { stripCode } from "./_strip-code.mjs";
46
+
47
+ export { stripCode };
36
48
 
37
49
  const __dirname = dirname(fileURLToPath(import.meta.url));
38
50
 
51
+ const MAX_SKIPPED_LISTED = 200;
52
+
39
53
  export const GRAPH_SCHEMA_VERSION = "1.2.0";
40
54
 
41
55
  /**
@@ -118,79 +132,6 @@ export function loadRules(requested, baseDir = __dirname) {
118
132
  };
119
133
  }
120
134
 
121
- /**
122
- * Remove comments and string literals so they cannot produce phantom edges.
123
- *
124
- * Character-scanned rather than regex-replaced: a regex pass cannot tell a `//`
125
- * inside a string from a real comment, and that difference is exactly what
126
- * makes reference edges noisy. Replaces removed spans with spaces so byte
127
- * offsets, and therefore line numbers, are preserved.
128
- *
129
- * @param {string} text - source text
130
- * @param {object} comments - rules.comments
131
- * @returns {string} same length, comments and string bodies blanked
132
- */
133
- export function stripCode(text, comments = {}) {
134
- const line = comments.line || [];
135
- const block = comments.block || [];
136
- const quotes = comments.string || [];
137
- const out = text.split("");
138
-
139
- let i = 0;
140
- const blank = (from, to) => {
141
- for (let k = from; k < to && k < out.length; k++) {
142
- if (out[k] !== "\n") out[k] = " ";
143
- }
144
- };
145
-
146
- while (i < text.length) {
147
- const rest = text.slice(i, i + 8);
148
-
149
- const lineTok = line.find((t) => rest.startsWith(t));
150
- if (lineTok) {
151
- let end = text.indexOf("\n", i);
152
- if (end === -1) end = text.length;
153
- blank(i, end);
154
- i = end;
155
- continue;
156
- }
157
-
158
- const blockTok = block.find(([open]) => rest.startsWith(open));
159
- if (blockTok) {
160
- const [open, close] = blockTok;
161
- let end = text.indexOf(close, i + open.length);
162
- end = end === -1 ? text.length : end + close.length;
163
- blank(i, end);
164
- i = end;
165
- continue;
166
- }
167
-
168
- const quoteTok = quotes.find((q) => rest.startsWith(q));
169
- if (quoteTok) {
170
- let j = i + quoteTok.length;
171
- while (j < text.length) {
172
- if (text[j] === "\\") {
173
- j += 2;
174
- continue;
175
- }
176
- if (text.startsWith(quoteTok, j)) {
177
- j += quoteTok.length;
178
- break;
179
- }
180
- if (text[j] === "\n" && quoteTok.length === 1) break;
181
- j++;
182
- }
183
- blank(i, j);
184
- i = j;
185
- continue;
186
- }
187
-
188
- i++;
189
- }
190
-
191
- return out.join("");
192
- }
193
-
194
135
  /**
195
136
  * First populated capture group of a match.
196
137
  *
@@ -223,6 +164,8 @@ function blankImportLines(stripped) {
223
164
  return stripped.replace(IMPORT_LINE_RE, (line) => " ".repeat(line.length));
224
165
  }
225
166
 
167
+ const NO_READS = { env: [], config: [] };
168
+
226
169
  const IDENTIFIER_RE = /[A-Za-z_][A-Za-z0-9_]*/g;
227
170
 
228
171
  /**
@@ -388,9 +331,11 @@ export function assignSpans(definitions, lines) {
388
331
  *
389
332
  * @param {string} text - raw source
390
333
  * @param {object} rules - merged rules from loadRules
391
- * @returns {{definitions: Array, imports: string[], tokens: Set<string>}}
334
+ * @param {string} [path] - repo-relative path; when given, call facts are scanned too
335
+ * @param {{skipCalls?: string}} [options] - skipCalls names why call facts are not scanned for this file
336
+ * @returns {{definitions: Array, imports: string[], tokens: Set<string>, calls: object|null}}
392
337
  */
393
- export function extractFile(text, rules) {
338
+ export function extractFile(text, rules, path, { skipCalls = null } = {}) {
394
339
  const stripped = stripCode(text, rules.comments);
395
340
 
396
341
  // Swift and the JVM name a module with a bare identifier, so the fully
@@ -452,33 +397,64 @@ export function extractFile(text, rules) {
452
397
 
453
398
  assignSpans(definitions, body.split("\n"));
454
399
  for (const d of definitions) delete d.indent;
455
- return { definitions, imports, tokens: identifiers(body), conformances };
400
+ const why = rationaleComments(text);
401
+ const reads = mayReadConfig(text)
402
+ ? codeReads(stripCode(text, { line: rules.comments.line, block: rules.comments.block }))
403
+ : NO_READS;
404
+ const { facts, skipped } = skipCalls
405
+ ? { facts: null, skipped: path ? skipCalls : null }
406
+ : path
407
+ ? analyzeFile(
408
+ text,
409
+ (o) =>
410
+ o.keepStrings
411
+ ? stripCode(text, { line: rules.comments.line, block: rules.comments.block })
412
+ : stripCode(text, rules.comments, o),
413
+ path,
414
+ )
415
+ : { facts: null };
416
+ return {
417
+ definitions,
418
+ imports,
419
+ tokens: identifiers(body),
420
+ conformances,
421
+ calls: facts,
422
+ ...(reads.env.length || reads.config.length ? { reads } : {}),
423
+ ...(why.length ? { rationale: why } : {}),
424
+ ...(skipped ? { skipped } : {}),
425
+ };
456
426
  }
457
427
 
458
428
  /**
459
- * Every source file under root, honouring .gitignore and excludePathGlobs.
460
- *
461
- * Uses `git ls-files` when root is a work tree, so .gitignore and
462
- * .git/info/exclude are respected without reimplementing them; falls back to a
463
- * directory walk otherwise.
429
+ * Every file under root that the work tree tracks or would add, honouring
430
+ * .gitignore and .git/info/exclude without reimplementing them; a directory
431
+ * walk stands in when root is not a work tree.
464
432
  *
465
433
  * @param {string} root - absolute repo root
466
- * @param {object} rules - merged rules
467
- * @returns {string[]} repo-relative paths, sorted
434
+ * @returns {string[]} repo-relative paths
468
435
  */
469
- export function listSourceFiles(root, rules) {
470
- let candidates;
436
+ export function listCandidateFiles(root) {
471
437
  try {
472
438
  const out = execFileSync("git", ["-C", root, "ls-files", "-z", "-co", "--exclude-standard"], {
473
439
  encoding: "utf8",
474
440
  maxBuffer: 64 * 1024 * 1024,
475
441
  stdio: ["ignore", "pipe", "ignore"],
476
442
  });
477
- candidates = out.split("\0").filter(Boolean);
443
+ return out.split("\0").filter(Boolean);
478
444
  } catch {
479
- candidates = walkDir(root, root);
445
+ return walkDir(root, root);
480
446
  }
447
+ }
481
448
 
449
+ /**
450
+ * Every source file of the stack, honouring excludePathGlobs.
451
+ *
452
+ * @param {string} root - absolute repo root
453
+ * @param {object} rules - merged rules
454
+ * @param {string[]} [candidates] - listCandidateFiles(root), when the caller already has it
455
+ * @returns {string[]} repo-relative paths, sorted
456
+ */
457
+ export function listSourceFiles(root, rules, candidates = listCandidateFiles(root)) {
482
458
  const isSource = (p) => {
483
459
  if (!rules.sourceExtensions.some((ext) => p.endsWith(ext))) return false;
484
460
  if (isExcludedBy(p, rules.excludePathGlobs)) return false;
@@ -539,9 +515,17 @@ export const symbolNodeId = (path, name) => `sym:${path}#${name}`;
539
515
  * @param {object} [params.manifest] - relPath -> {size, mtimeMs}
540
516
  * @param {string|null} [params.baseCommit]
541
517
  * @param {string} [params.generatedAt] - ISO timestamp, injected by the caller
542
- * @returns {object} graph conforming to code-graph.schema.json
518
+ * @param {Map<string, object>} [params.infra] - collectInfra result; omitted for none
519
+ * @param {Set<string>} [params.known] - every path that exists, to resolve file references
520
+ * @param {Map<string, object>} [params.docs] - collectDocs result; omitted for none
521
+ * @param {boolean} [params.calls] - build the calls sidecar; default true
522
+ * @param {object} [params.caps] - per-sidecar {maxNodes, maxEdges} overrides
523
+ * @param {number} [params.resolveBudgetMs] - time the call resolution may take; files left over are listed
524
+ * @param {() => number} [params.resolveClock] - clock for that budget, injectable for tests
525
+ * @returns {{graph: object, sidecars: object}} the main graph (schema 1.2.0) and the
526
+ * sidecars that were asked for
543
527
  */
544
- export function buildGraph({
528
+ export function buildGraphSet({
545
529
  root,
546
530
  stack,
547
531
  extracted,
@@ -549,6 +533,13 @@ export function buildGraph({
549
533
  manifest = {},
550
534
  baseCommit = null,
551
535
  generatedAt,
536
+ infra = null,
537
+ known = null,
538
+ docs = null,
539
+ calls = true,
540
+ caps = {},
541
+ resolveBudgetMs,
542
+ resolveClock,
552
543
  }) {
553
544
  const nodes = new Map();
554
545
  const edges = [];
@@ -673,25 +664,115 @@ export function buildGraph({
673
664
  }
674
665
 
675
666
  for (const edge of edges) {
676
- if (nodes.has(edge.from)) nodes.get(edge.from).degree++;
677
- if (nodes.has(edge.to)) nodes.get(edge.to).degree++;
667
+ nodes.get(edge.from).degree++;
668
+ nodes.get(edge.to).degree++;
678
669
  }
679
670
 
680
- return {
671
+ const graph = {
681
672
  schemaVersion: GRAPH_SCHEMA_VERSION,
682
673
  stack,
683
674
  root,
684
675
  baseCommit,
685
676
  generatedAt,
686
- stats: {
687
- files: extracted.size,
688
- nodes: nodes.size,
689
- edges: edges.length,
690
- },
677
+ stats: { files: extracted.size, nodes: nodes.size, edges: edges.length },
691
678
  nodes: [...nodes.values()],
692
679
  edges,
693
680
  manifest,
694
681
  };
682
+ const sidecars = {};
683
+ const layer = (build) => {
684
+ const view = new Map(nodes);
685
+ const extra = [];
686
+ const annotations = {};
687
+ const info = build(view, extra, annotations) || {};
688
+ const fresh = [...view.values()].filter((n) => !nodes.has(n.id));
689
+ return { nodes: fresh, edges: extra, annotations, ...info };
690
+ };
691
+
692
+ if (calls) {
693
+ const body = layer((view, extra, annotations) => {
694
+ const st = addCallEdges({
695
+ extracted,
696
+ nodes: view,
697
+ edges: extra,
698
+ annotations,
699
+ isTest: (p) => isTestPath(p, rules),
700
+ budgetMs: resolveBudgetMs,
701
+ now: resolveClock,
702
+ });
703
+ const skipped = [
704
+ ...[...extracted]
705
+ .filter(([, d]) => d.skipped)
706
+ .map(([path, d]) => ({ path, reason: d.skipped })),
707
+ ...st.unresolved.map((path) => ({ path, reason: "resolve-time-budget" })),
708
+ ];
709
+ return {
710
+ stats: { calls: st.calls, callFilesSkipped: skipped.length },
711
+ coverage: { callAnalysisSkipped: skipped.slice(0, MAX_SKIPPED_LISTED) },
712
+ };
713
+ });
714
+ sidecars.calls = makeSidecar("calls", graph, body, caps.calls);
715
+ }
716
+
717
+ if (infra) {
718
+ const readers = [...extracted].filter(([, d]) => d.reads);
719
+ const body = layer((view, extra) => {
720
+ const st = addInfra({
721
+ nodes: view,
722
+ edges: extra,
723
+ files: infra,
724
+ reads: new Map(readers.map(([path, d]) => [path, d.reads])),
725
+ known: known || new Set(extracted.keys()),
726
+ });
727
+ return {
728
+ stats: { infra: st.infra, env: st.env, config: st.config },
729
+ ...(infra.skipped?.length ? { coverage: { skipped: infra.skipped } } : {}),
730
+ };
731
+ });
732
+ body.manifest = inputManifest(root, [...infra.keys(), ...readers.map(([p]) => p)]);
733
+ sidecars.infra = makeSidecar("infra", graph, body, caps.infra);
734
+ }
735
+
736
+ if (docs) {
737
+ const whys = [...extracted].filter(([, d]) => d.rationale);
738
+ const body = layer((view, extra) => {
739
+ const st = addDocs({
740
+ nodes: view,
741
+ edges: extra,
742
+ docs,
743
+ rationale: new Map(whys.map(([path, d]) => [path, d.rationale])),
744
+ });
745
+ return {
746
+ stats: { docs: st.docs, rationale: st.rationale },
747
+ ...(docs.skipped?.length ? { coverage: { skipped: docs.skipped } } : {}),
748
+ };
749
+ });
750
+ body.manifest = inputManifest(root, [...docs.keys(), ...whys.map(([p]) => p)]);
751
+ sidecars.docs = makeSidecar("docs", graph, body, caps.docs);
752
+ }
753
+
754
+ return { graph, sidecars };
755
+ }
756
+
757
+ function inputManifest(root, paths) {
758
+ const out = {};
759
+ for (const p of paths) {
760
+ try {
761
+ out[p] = manifestEntry(join(root, p));
762
+ } catch {
763
+ // vanished between read and stat: it is simply not an input of this build
764
+ }
765
+ }
766
+ return out;
767
+ }
768
+
769
+ /**
770
+ * The same build as buildGraphSet with every layer joined to the main graph in
771
+ * memory, the view a reader gets from loadGraph.
772
+ */
773
+ export function buildGraph(params) {
774
+ const { graph, sidecars } = buildGraphSet(params);
775
+ return attachSidecars(graph, "in-memory.json", { parsed: sidecars });
695
776
  }
696
777
 
697
778
  /**
@@ -21,7 +21,7 @@ import { launchRepoAllowed, launchRepos } from "./launch-request.mjs";
21
21
  import { selectRuns } from "./runs-index.mjs";
22
22
 
23
23
  /** The contract as a whole; pipeline/contract/manifest.json carries the same. */
24
- export const CONTRACT_VERSION = "2.0.0";
24
+ export const CONTRACT_VERSION = "2.2.0";
25
25
  /** Confirm tokens held at once; the oldest is dropped past this. */
26
26
  export const MAX_CONFIRMS = 256;
27
27
  /** How long a kill or gc confirm token stays valid. */
@@ -8,6 +8,7 @@
8
8
 
9
9
  import { activitySnapshot, agentChat, createActivityCache } from "./activity-snapshot.mjs";
10
10
  import { officeCredentials } from "./office-credentials.mjs";
11
+ import { CONTRACT_VERSION as LEARNING_VERSION, cachedLearningCurve } from "./learning-curve.mjs";
11
12
  import { officeLedger } from "./office-ledger.mjs";
12
13
  import { officeMemory } from "./office-memory.mjs";
13
14
  import { officeServerRoom } from "./office-server-room.mjs";
@@ -80,6 +81,26 @@ export const officeRoutes = {
80
81
  query: [],
81
82
  handle: () => officeLedger(),
82
83
  },
84
+ learning: {
85
+ method: "GET",
86
+ path: "/v1/learning-curve",
87
+ remote: "read",
88
+ query: [],
89
+ handle: shared(
90
+ () => "learning-curve",
91
+ () => {
92
+ const curve = cachedLearningCurve();
93
+ if (!curve.ok)
94
+ return {
95
+ contractVersion: LEARNING_VERSION,
96
+ ok: false,
97
+ code: curve.code,
98
+ buckets: [],
99
+ };
100
+ return { contractVersion: LEARNING_VERSION, ...curve };
101
+ },
102
+ ),
103
+ },
83
104
  system: {
84
105
  method: "GET",
85
106
  path: "/v1/system",
@@ -24,6 +24,7 @@ import { execFileSync } from "node:child_process";
24
24
  import { existsSync, statSync } from "node:fs";
25
25
  import { join } from "node:path";
26
26
  import { diffHeaderPath } from "./git-path.mjs";
27
+ import { listSourceFiles, loadRules } from "./_code-graph.mjs";
27
28
 
28
29
  const HUNK_RE = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;
29
30
 
@@ -266,7 +267,8 @@ function gitOut(root, args) {
266
267
  *
267
268
  * @param {object} graph
268
269
  * @param {{root?: string}} [opts] - defaults to the root recorded in the graph
269
- * @returns {{stale: boolean, commitMoved: boolean|null, baseCommit: string|null, head: string|null, changedFiles: string[], removedFiles: string[]}}
270
+ * @returns {{stale: boolean, commitMoved: boolean|null, baseCommit: string|null, head: string|null, changedFiles: string[], removedFiles: string[], addedFiles: string[]}}
271
+ * addedFiles are source files of the graph's stack that exist now and were not in the build
270
272
  */
271
273
  export function graphFreshness(graph, { root = graph.root } = {}) {
272
274
  const manifest = graph.manifest || {};
@@ -284,16 +286,33 @@ export function graphFreshness(graph, { root = graph.root } = {}) {
284
286
  const head = root ? gitOut(root, ["rev-parse", "HEAD"]) : null;
285
287
  const baseCommit = graph.baseCommit || null;
286
288
  const commitMoved = head && baseCommit ? head !== baseCommit : null;
289
+ const addedFiles = [];
290
+ if (root && Object.keys(manifest).length > 0) {
291
+ try {
292
+ for (const p of listSourceFiles(root, loadRules(graph.stack))) {
293
+ if (!(p in manifest) && addedFiles.length < MAX_ADDED_LISTED) addedFiles.push(p);
294
+ }
295
+ } catch {
296
+ // A stack with no rules on this install, or a root that is gone: nothing to add.
297
+ }
298
+ }
287
299
  return {
288
- stale: Boolean(commitMoved) || changedFiles.length > 0 || removedFiles.length > 0,
300
+ stale:
301
+ Boolean(commitMoved) ||
302
+ changedFiles.length > 0 ||
303
+ removedFiles.length > 0 ||
304
+ addedFiles.length > 0,
289
305
  commitMoved,
290
306
  baseCommit,
291
307
  head,
292
308
  changedFiles: changedFiles.sort(),
293
309
  removedFiles: removedFiles.sort(),
310
+ addedFiles: addedFiles.sort(),
294
311
  };
295
312
  }
296
313
 
314
+ const MAX_ADDED_LISTED = 200;
315
+
297
316
  /**
298
317
  * Which side of a diff the graph's line numbers describe. For a commit range
299
318
  * (`range`, `<base>..<head>`) the graph's build commit decides: built at the