@mmerterden/multi-agent-pipeline 23.3.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 (224) hide show
  1. package/CHANGELOG.md +44 -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 +5 -5
  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 +223 -155
  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/graph/SKILL.md +57 -24
  21. package/pipeline/commands/multi-agent/pair/SKILL.md +92 -0
  22. package/pipeline/commands/multi-agent/prune-prompts/SKILL.md +1 -1
  23. package/pipeline/commands/multi-agent/search/SKILL.md +7 -1
  24. package/pipeline/commands/multi-agent/status/SKILL.md +4 -0
  25. package/pipeline/commands/multi-agent/sync/SKILL.md +3 -3
  26. package/pipeline/contract/CHANGELOG.md +49 -0
  27. package/pipeline/contract/build.mjs +13 -1
  28. package/pipeline/contract/fixtures/error-invalid-request.json +1 -1
  29. package/pipeline/contract/fixtures/error-unauthorized.json +1 -1
  30. package/pipeline/contract/fixtures/runs-awaiting-question.json +4 -1
  31. package/pipeline/contract/fixtures/runs-empty.json +1 -1
  32. package/pipeline/contract/fixtures/runs-failed.json +4 -1
  33. package/pipeline/contract/fixtures/runs-old-schema.json +3 -0
  34. package/pipeline/contract/fixtures/runs-pr-opened-redacted.json +4 -1
  35. package/pipeline/contract/fixtures/runs-pr-opened.json +4 -1
  36. package/pipeline/contract/fixtures/runs-running.json +4 -1
  37. package/pipeline/contract/manifest.json +28 -15
  38. package/pipeline/contract/types/index.d.ts +55 -3
  39. package/pipeline/lib/detach-self.mjs +95 -0
  40. package/pipeline/lib/public-mcp-servers.mjs +33 -0
  41. package/pipeline/lib/rotated-log.mjs +93 -0
  42. package/pipeline/lib/tls-trust.mjs +29 -0
  43. package/pipeline/lib/usage-lifecycle.mjs +9 -11
  44. package/pipeline/lib/usage-names.generated.mjs +614 -0
  45. package/pipeline/lib/usage-run-key.mjs +235 -0
  46. package/pipeline/lib/usage-vocab.mjs +210 -0
  47. package/pipeline/multi-agent-refs/analysis/intake.md +2 -2
  48. package/pipeline/multi-agent-refs/analysis/render.md +1 -1
  49. package/pipeline/multi-agent-refs/channels/generator.md +4 -5
  50. package/pipeline/multi-agent-refs/cross-cli-contract.md +3 -3
  51. package/pipeline/multi-agent-refs/design-check/scope-and-ledger.md +1 -1
  52. package/pipeline/multi-agent-refs/features/code-graph.md +146 -11
  53. package/pipeline/multi-agent-refs/features/code-intelligence.md +16 -14
  54. package/pipeline/multi-agent-refs/features/dev-critic.md +7 -7
  55. package/pipeline/multi-agent-refs/features/model-fallback.md +6 -4
  56. package/pipeline/multi-agent-refs/features/remote-control.md +252 -0
  57. package/pipeline/multi-agent-refs/features/review-delta.md +1 -1
  58. package/pipeline/multi-agent-refs/features/review-file-set.md +3 -3
  59. package/pipeline/multi-agent-refs/features/review-multi-repo.md +1 -1
  60. package/pipeline/multi-agent-refs/features/session-brief.md +42 -0
  61. package/pipeline/multi-agent-refs/features/skill-conformance.md +3 -3
  62. package/pipeline/multi-agent-refs/features/usage-reporting.md +252 -24
  63. package/pipeline/multi-agent-refs/help/en.md +3 -2
  64. package/pipeline/multi-agent-refs/help/tr.md +3 -2
  65. package/pipeline/multi-agent-refs/knowledge.md +1 -1
  66. package/pipeline/multi-agent-refs/orchestrator/dispatcher.md +1 -1
  67. package/pipeline/multi-agent-refs/phases/operations.md +2 -2
  68. package/pipeline/multi-agent-refs/phases/phase-0-init.md +13 -12
  69. package/pipeline/multi-agent-refs/phases/phase-1-plan.md +4 -4
  70. package/pipeline/multi-agent-refs/phases/phase-3-review.md +2 -0
  71. package/pipeline/multi-agent-refs/phases/phase-5-report.md +1 -1
  72. package/pipeline/multi-agent-refs/platform-parity.md +2 -2
  73. package/pipeline/multi-agent-refs/wiki-capture.md +3 -17
  74. package/pipeline/office/index.html +1207 -233
  75. package/pipeline/office/toolkit.json +1 -1
  76. package/pipeline/rules/outside-the-pipeline.md +1 -1
  77. package/pipeline/schemas/activity.schema.json +23 -0
  78. package/pipeline/schemas/agent-state.schema.json +6 -1
  79. package/pipeline/schemas/code-graph-calls.schema.json +254 -0
  80. package/pipeline/schemas/code-graph-docs.schema.json +223 -0
  81. package/pipeline/schemas/code-graph-infra.schema.json +227 -0
  82. package/pipeline/schemas/code-graph.schema.json +2 -2
  83. package/pipeline/schemas/examples/design-check-config.json +27 -0
  84. package/pipeline/schemas/learning-curve.schema.json +67 -0
  85. package/pipeline/schemas/office-jobs.json +69 -2
  86. package/pipeline/schemas/office-jobs.schema.json +8 -1
  87. package/pipeline/schemas/phases.json +5 -0
  88. package/pipeline/schemas/phases.schema.json +8 -0
  89. package/pipeline/schemas/prefs.schema.json +46 -12
  90. package/pipeline/schemas/runs-index.schema.json +17 -0
  91. package/pipeline/schemas/toolkit-path-params.json +84 -8
  92. package/pipeline/scripts/README.md +1 -0
  93. package/pipeline/scripts/_code-graph.mjs +184 -103
  94. package/pipeline/scripts/_contract-core.mjs +1 -1
  95. package/pipeline/scripts/_contract-routes-office.mjs +21 -0
  96. package/pipeline/scripts/_diff-impact.mjs +21 -2
  97. package/pipeline/scripts/_graph-sidecars.mjs +372 -0
  98. package/pipeline/scripts/_http-post.mjs +103 -115
  99. package/pipeline/scripts/_safe-read.mjs +57 -0
  100. package/pipeline/scripts/_skill-practices.mjs +26 -0
  101. package/pipeline/scripts/_strip-code.mjs +380 -0
  102. package/pipeline/scripts/activity-snapshot.mjs +13 -1
  103. package/pipeline/scripts/aggregate-metrics.mjs +3 -5
  104. package/pipeline/scripts/call-graph/index.mjs +78 -0
  105. package/pipeline/scripts/call-graph/lang/cpp.mjs +308 -0
  106. package/pipeline/scripts/call-graph/lang/csharp.mjs +130 -0
  107. package/pipeline/scripts/call-graph/lang/go.mjs +303 -0
  108. package/pipeline/scripts/call-graph/lang/java.mjs +370 -0
  109. package/pipeline/scripts/call-graph/lang/kotlin.mjs +397 -0
  110. package/pipeline/scripts/call-graph/lang/python.mjs +399 -0
  111. package/pipeline/scripts/call-graph/lang/rust.mjs +345 -0
  112. package/pipeline/scripts/call-graph/lang/shared.mjs +230 -0
  113. package/pipeline/scripts/call-graph/lang/swift.mjs +432 -0
  114. package/pipeline/scripts/call-graph/lang/typescript.mjs +692 -0
  115. package/pipeline/scripts/call-graph/lex.mjs +396 -0
  116. package/pipeline/scripts/call-graph/platform.mjs +86 -0
  117. package/pipeline/scripts/call-graph/profiles.mjs +89 -0
  118. package/pipeline/scripts/call-graph/resolve.mjs +1125 -0
  119. package/pipeline/scripts/call-graph/scan.mjs +267 -0
  120. package/pipeline/scripts/code-graph-rules/android.json +7 -2
  121. package/pipeline/scripts/code-graph-rules/cpp.json +99 -0
  122. package/pipeline/scripts/code-graph-rules/csharp.json +102 -0
  123. package/pipeline/scripts/code-graph-rules/go.json +2 -1
  124. package/pipeline/scripts/code-graph-rules/ios.json +3 -1
  125. package/pipeline/scripts/code-graph-rules/java.json +76 -0
  126. package/pipeline/scripts/code-graph-rules/node.json +7 -2
  127. package/pipeline/scripts/code-graph-rules/python.json +6 -2
  128. package/pipeline/scripts/code-graph-rules/rust.json +105 -0
  129. package/pipeline/scripts/contract-server.mjs +1 -0
  130. package/pipeline/scripts/feedback-send.mjs +26 -26
  131. package/pipeline/scripts/gate-ledger.mjs +2 -1
  132. package/pipeline/scripts/gen-usage-names.mjs +124 -0
  133. package/pipeline/scripts/graph-affected.mjs +109 -20
  134. package/pipeline/scripts/graph-build.mjs +95 -15
  135. package/pipeline/scripts/graph-export.mjs +272 -0
  136. package/pipeline/scripts/graph-hint.mjs +15 -2
  137. package/pipeline/scripts/graph-query.mjs +305 -26
  138. package/pipeline/scripts/graph-report.mjs +187 -1
  139. package/pipeline/scripts/health-report.mjs +3 -4
  140. package/pipeline/scripts/infra/docs.mjs +317 -0
  141. package/pipeline/scripts/infra/extract.mjs +998 -0
  142. package/pipeline/scripts/infra/graph.mjs +245 -0
  143. package/pipeline/scripts/infra/yaml-lite.mjs +311 -0
  144. package/pipeline/scripts/job-launch.mjs +67 -2
  145. package/pipeline/scripts/learning-curve.mjs +288 -178
  146. package/pipeline/scripts/log-metric.sh +10 -1
  147. package/pipeline/scripts/note-agent-event.mjs +3 -4
  148. package/pipeline/scripts/note-command-use.mjs +333 -0
  149. package/pipeline/scripts/note-command-use.sh +126 -0
  150. package/pipeline/scripts/note-mcp-call.sh +89 -0
  151. package/pipeline/scripts/note-mcp-failure.mjs +272 -1
  152. package/pipeline/scripts/note-session.sh +62 -3
  153. package/pipeline/scripts/note-skill-use.mjs +58 -2
  154. package/pipeline/scripts/office-build.mjs +115 -1
  155. package/pipeline/scripts/office-memory.mjs +14 -5
  156. package/pipeline/scripts/pair.mjs +333 -0
  157. package/pipeline/scripts/pre-push-check.sh +1 -1
  158. package/pipeline/scripts/remote/cbor.mjs +128 -0
  159. package/pipeline/scripts/remote/contract.mjs +98 -0
  160. package/pipeline/scripts/remote/handler.mjs +317 -0
  161. package/pipeline/scripts/remote/handles.mjs +57 -0
  162. package/pipeline/scripts/remote/lifecycle.mjs +186 -0
  163. package/pipeline/scripts/remote/listener.mjs +204 -0
  164. package/pipeline/scripts/remote/lockout.mjs +103 -0
  165. package/pipeline/scripts/remote/nonces.mjs +61 -0
  166. package/pipeline/scripts/remote/pairing.mjs +519 -0
  167. package/pipeline/scripts/remote/qr-encode.mjs +459 -0
  168. package/pipeline/scripts/remote/store.mjs +188 -0
  169. package/pipeline/scripts/remote/transport.mjs +211 -0
  170. package/pipeline/scripts/remote/verbs.json +70 -0
  171. package/pipeline/scripts/remote/verbs.mjs +217 -0
  172. package/pipeline/scripts/remote/webauthn.mjs +169 -0
  173. package/pipeline/scripts/remote/wire.mjs +364 -0
  174. package/pipeline/scripts/remote-listener.mjs +83 -0
  175. package/pipeline/scripts/route-learn.mjs +4 -4
  176. package/pipeline/scripts/run-kill.mjs +1 -1
  177. package/pipeline/scripts/run-write.mjs +13 -2
  178. package/pipeline/scripts/runs-index.mjs +30 -3
  179. package/pipeline/scripts/search-logs.sh +9 -0
  180. package/pipeline/scripts/session-brief.mjs +458 -0
  181. package/pipeline/scripts/session-brief.sh +130 -0
  182. package/pipeline/scripts/test-gap-rules/cpp.json +25 -0
  183. package/pipeline/scripts/test-gap-rules/csharp.json +20 -0
  184. package/pipeline/scripts/test-gap-rules/java.json +20 -0
  185. package/pipeline/scripts/test-gap-rules/rust.json +14 -0
  186. package/pipeline/scripts/token-budget-report.mjs +3 -2
  187. package/pipeline/scripts/uninstall.mjs +29 -0
  188. package/pipeline/scripts/usage-access.mjs +16 -31
  189. package/pipeline/scripts/usage-health.mjs +31 -62
  190. package/pipeline/scripts/usage-register-beacon.mjs +11 -22
  191. package/pipeline/scripts/usage-register.mjs +39 -29
  192. package/pipeline/scripts/usage-report.mjs +579 -178
  193. package/pipeline/scripts/validate-code-graph.mjs +361 -111
  194. package/pipeline/scripts/write-state.mjs +39 -0
  195. package/pipeline/skills/.skill-manifest.json +21 -17
  196. package/pipeline/skills/.skills-index.json +13 -2
  197. package/pipeline/skills/shared/README.md +5 -4
  198. package/pipeline/skills/shared/core/multi-agent-design-check/SKILL.md +1 -1
  199. package/pipeline/skills/shared/core/multi-agent-diff-explain/SKILL.md +3 -3
  200. package/pipeline/skills/shared/core/multi-agent-graph/SKILL.md +55 -21
  201. package/pipeline/skills/shared/core/multi-agent-pair/SKILL.md +41 -0
  202. package/pipeline/skills/shared/core/multi-agent-prune-prompts/SKILL.md +1 -1
  203. package/pipeline/skills/shared/core/multi-agent-sync/SKILL.md +3 -3
  204. package/pipeline/skills/shared/external/app-store-optimization/SKILL.md +2 -3
  205. package/pipeline/skills/shared/external/app-store-optimization/references/keyword-research-methodology.md +2 -2
  206. package/pipeline/skills/shared/external/app-store-optimization/references/product-page-variants.md +2 -2
  207. package/pipeline/skills/shared/external/app-store-review/SKILL.md +11 -4
  208. package/pipeline/skills/shared/external/build-settings-audit/SKILL.md +1 -1
  209. package/pipeline/skills/shared/external/build-time-benchmark/SKILL.md +5 -5
  210. package/pipeline/skills/shared/external/build-time-fixes/SKILL.md +5 -5
  211. package/pipeline/skills/shared/external/build-time-optimizer/SKILL.md +6 -6
  212. package/pipeline/skills/shared/external/free-llm-apis/references/providers.md +1 -0
  213. package/pipeline/skills/shared/external/ios-coding-standard/references/STANDARD.md +2 -2
  214. package/pipeline/skills/shared/external/ios-haptics/references/core-haptics.md +1 -1
  215. package/pipeline/skills/shared/external/localization-reuse-map/references/publish-and-snapshot.md +1 -1
  216. package/pipeline/skills/shared/external/package-build-audit/SKILL.md +3 -3
  217. package/pipeline/skills/shared/external/reverse-engineer-own-app/SKILL.md +2 -3
  218. package/pipeline/skills/shared/external/swift-compile-hotspots/SKILL.md +2 -2
  219. package/pipeline/skills/shared/external/weatherkit/SKILL.md +5 -6
  220. package/pipeline/skills/skills-index.md +3 -2
  221. package/docs/FIGMA_PIPELINE.md +0 -137
  222. package/pipeline/lib/identifier-scan.mjs +0 -156
  223. package/pipeline/scripts/publish-staged.mjs +0 -324
  224. package/pipeline/skills/shared/external/ios-coding-standard/scripts/check_structure.py +0 -765
@@ -0,0 +1,267 @@
1
+ /**
2
+ * @file scan.mjs - turn a function body into call chains.
3
+ *
4
+ * A chain is one expression of the shape `root.member.method(args).next(...)`,
5
+ * recorded as a list of steps the resolver can evaluate once every file's types
6
+ * are known. Nothing here looks at another file: the scanner reads tokens and a
7
+ * language profile, and writes plain arrays so a file's facts can be cached and
8
+ * reused while the rest of the repository changes.
9
+ *
10
+ * Step encoding (first element is the tag):
11
+ * ["s"] self / this
12
+ * ["u"] super / base
13
+ * ["i", name] identifier (local, field, type or module)
14
+ * ["c", name, n, labels, tc] bare call; n arguments, argument labels, trailing closure
15
+ * ["n", Type, n, labels] constructor through a `new`-style keyword
16
+ * ["k", Type] cast: the expression is known to be Type
17
+ * ["f", name] member access
18
+ * ["m", name, n, labels, tc] method call
19
+ * ["x"] something with no usable type (index, call of a value)
20
+ *
21
+ * Events per function, in source order:
22
+ * ["d", name, type|null] local declaration; type null clears a known type
23
+ * ["c", line, bind|null, steps]
24
+ *
25
+ * @module pipeline/scripts/call-graph/scan
26
+ */
27
+
28
+ import { isIdent, skipAngles, countArgs, readType, tick } from "./lex.mjs";
29
+
30
+ const MAX_CHAIN_STEPS = 64;
31
+ export const STRING_MARK = "\u0001";
32
+ export const MAX_EVENTS_PER_FN = 4000;
33
+
34
+ /**
35
+ * Parse the call chain that starts at token i.
36
+ *
37
+ * @param {object} tk
38
+ * @param {number} i - first token of the chain
39
+ * @param {number} end - exclusive upper bound
40
+ * @param {object} p - language profile
41
+ * @returns {{steps: Array, next: number}}
42
+ */
43
+ export function parseChain(tk, i, end, p) {
44
+ const t = tk.t;
45
+ const steps = [];
46
+ let j = i;
47
+ const callAt = (k) => {
48
+ let o = k;
49
+ if (t[o] === "<" && p.genericCalls) o = skipAngles(tk, o, end);
50
+ if (t[o] === "::" && t[o + 1] === "<" && p.genericCalls) o = skipAngles(tk, o + 1, end);
51
+ return t[o] === "(" && tk.m[o] > o ? o : -1;
52
+ };
53
+ const afterCall = (open) => {
54
+ const { n, labels } = countArgs(tk, open, p.labelOps);
55
+ let k = tk.m[open] + 1;
56
+ let tc = 0;
57
+ if (p.trailingClosure && t[k] === "{" && tk.line[k] === tk.line[k - 1]) {
58
+ tc = 1;
59
+ k = tk.m[k] + 1;
60
+ }
61
+ return { n, labels, tc, k };
62
+ };
63
+
64
+ if (p.newKeyword && t[j] === p.newKeyword) {
65
+ const ty = readType(tk, j + 1, { limit: end });
66
+ const open = ty.next < end && t[ty.next] === "(" ? ty.next : -1;
67
+ if (ty.name && open > 0) {
68
+ const a = countArgs(tk, open, p.labelOps);
69
+ steps.push(["n", ty.name, a.n, a.labels]);
70
+ j = tk.m[open] + 1;
71
+ } else {
72
+ steps.push(["x"]);
73
+ return { steps, next: Math.max(ty.next, j + 1) };
74
+ }
75
+ } else if (isIdent(t[j])) {
76
+ const name = t[j];
77
+ if (p.selfWords.has(name)) {
78
+ steps.push(["s"]);
79
+ j++;
80
+ } else if (p.superWords.has(name)) {
81
+ steps.push(["u"]);
82
+ j++;
83
+ if (p.superCall && t[j] === "(" && tk.m[j] > j) j = tk.m[j] + 1;
84
+ } else {
85
+ const open = callAt(j + 1);
86
+ if (open > 0) {
87
+ const a = afterCall(open);
88
+ steps.push(["c", name, a.n, a.labels, a.tc]);
89
+ j = a.k;
90
+ } else {
91
+ steps.push(["i", name]);
92
+ j++;
93
+ }
94
+ }
95
+ } else if (t[j] === STRING_MARK && p.stringType) {
96
+ steps.push(["k", p.stringType]);
97
+ j++;
98
+ } else if (t[j] === "(" && tk.m[j] > j) {
99
+ const cast = castType(tk, j, p);
100
+ steps.push(cast ? ["k", cast] : ["x"]);
101
+ j = tk.m[j] + 1;
102
+ } else {
103
+ return { steps, next: j + 1 };
104
+ }
105
+
106
+ while (j < end && steps.length < MAX_CHAIN_STEPS) {
107
+ const s = t[j];
108
+ if (p.memberOps.has(s) && isIdent(t[j + 1])) {
109
+ const name = t[j + 1];
110
+ const open = callAt(j + 2);
111
+ if (open > 0) {
112
+ const a = afterCall(open);
113
+ steps.push(["m", name, a.n, a.labels, a.tc]);
114
+ j = a.k;
115
+ } else {
116
+ steps.push(["f", name]);
117
+ j += 2;
118
+ }
119
+ } else if (s === "[" && tk.m[j] > j) {
120
+ steps.push(["x"]);
121
+ j = tk.m[j] + 1;
122
+ } else if (s === "(" && tk.m[j] > j && steps.length) {
123
+ steps.push(["x"]);
124
+ j = tk.m[j] + 1;
125
+ } else if (s === "!" && p.memberOps.has(t[j + 1])) {
126
+ j++;
127
+ } else break;
128
+ }
129
+ if (p.castWords && j < end && p.castWords.has(t[j]) && steps.length) {
130
+ let q = j + 1;
131
+ if (t[q] === "?" || t[q] === "!") q++;
132
+ const ty = readType(tk, q, { limit: end, union: p.union });
133
+ if (ty.name && ty.name !== "const") {
134
+ steps.push(["k", ty.name, "m"]);
135
+ j = ty.next;
136
+ }
137
+ }
138
+ return { steps, next: j };
139
+ }
140
+
141
+ /** `(expr as Type)` / `(expr as? Type)` / `(Type) expr`-free: the cast target, or null. */
142
+ function castType(tk, open, p) {
143
+ if (p.castFn) return p.castFn(tk, open);
144
+ if (!p.castWords) return null;
145
+ const close = tk.m[open];
146
+ for (let k = open + 1; k < close; k++) {
147
+ if (tk.m[k] > k) {
148
+ k = tk.m[k];
149
+ continue;
150
+ }
151
+ if (p.castWords.has(tk.t[k])) {
152
+ let q = k + 1;
153
+ if (tk.t[q] === "?" || tk.t[q] === "!") q++;
154
+ return readType(tk, q, { limit: close, union: p.union }).name;
155
+ }
156
+ }
157
+ return null;
158
+ }
159
+
160
+ const TAG_PREV = new Set([
161
+ "(",
162
+ "{",
163
+ "}",
164
+ ">",
165
+ "return",
166
+ "=>",
167
+ "?",
168
+ ":",
169
+ "&&",
170
+ "||",
171
+ "??",
172
+ ",",
173
+ "=",
174
+ "[",
175
+ ]);
176
+
177
+ /** `<Name ...>` or `<Name />` where an expression starts: a component used as a tag, not a comparison or a generic. */
178
+ function isComponentTag(tk, i) {
179
+ const t = tk.t;
180
+ const name = t[i + 1];
181
+ if (!isIdent(name) || !/^[A-Z]/.test(name) || t[i + 2] === ".") return false;
182
+ const prev = i > 0 ? t[i - 1] : "{";
183
+ if (!TAG_PREV.has(prev) && tk.first[i] !== 1) return false;
184
+ const after = t[i + 2];
185
+ if (after === ">") return t[i + 3] !== "(";
186
+ return after === "/" || isIdent(after);
187
+ }
188
+
189
+ /**
190
+ * Scan tokens [from, to) as one function body.
191
+ *
192
+ * @param {object} tk
193
+ * @param {number} from
194
+ * @param {number} to
195
+ * @param {object} p - language profile
196
+ * @returns {Array} events
197
+ */
198
+ export function scanBody(tk, from, to, p) {
199
+ const t = tk.t;
200
+ const events = [];
201
+ const binds = new Map();
202
+ const special = (s) => p.selfWords.has(s) || p.superWords.has(s) || s === p.newKeyword;
203
+ let i = from;
204
+ while (i < to && events.length < MAX_EVENTS_PER_FN) {
205
+ tick(tk);
206
+ const s = t[i];
207
+ const prev = i > from ? t[i - 1] : "{";
208
+
209
+ if (p.lambdaParams) {
210
+ const lp = p.lambdaParams(tk, i, to);
211
+ if (lp) for (const [name, type] of lp.params) events.push(["d", name, type]);
212
+ }
213
+ if (s === STRING_MARK && p.stringType && p.memberOps.has(t[i + 1]) && !p.memberOps.has(prev)) {
214
+ const { steps } = parseChain(tk, i, to, p);
215
+ if (steps.some((st) => st[0] === "c" || st[0] === "m"))
216
+ events.push(["c", tk.line[i], null, steps]);
217
+ i++;
218
+ continue;
219
+ }
220
+ if (s === "<" && p.jsx && isComponentTag(tk, i)) {
221
+ events.push(["c", tk.line[i], null, [["c", t[i + 1], 1, [], 0]]]);
222
+ i++;
223
+ continue;
224
+ }
225
+ if (!isIdent(s)) {
226
+ i++;
227
+ continue;
228
+ }
229
+
230
+ const stmtStart = tk.first[i] === 1 || ";{}".includes(prev) || prev === "(";
231
+ if (p.localDecl && (stmtStart || p.condWords?.has(prev))) {
232
+ const d = p.localDecl(tk, i, to);
233
+ if (d) {
234
+ if (!d.bound) {
235
+ events.push(["d", d.name, d.type || null]);
236
+ for (const extra of d.also || []) events.push(["d", extra, null]);
237
+ }
238
+ if (d.init != null && !d.type) binds.set(d.init, d.name);
239
+ if (d.scan) events.push(...scanBody(tk, d.scan[0], d.scan[1], p));
240
+ i = d.init != null ? d.init : d.next;
241
+ continue;
242
+ }
243
+ }
244
+ if (p.keywords.has(s) && !special(s) && !(p.contextual?.has(s) && t[i + 1] === "(")) {
245
+ i++;
246
+ continue;
247
+ }
248
+ const label =
249
+ p.labelOps.includes(t[i + 1]) &&
250
+ (prev === "(" || prev === "," || (prev === "{" && p.labelOps[0] === ":"));
251
+ if (p.memberOps.has(prev) || p.declWords.has(prev) || label) {
252
+ i++;
253
+ continue;
254
+ }
255
+ const { steps, next } = parseChain(tk, i, to, p);
256
+ if (p.id === "typescript" && steps.length === 1 && steps[0][0] === "c" && t[next] === "{") {
257
+ i++;
258
+ continue;
259
+ }
260
+ const bind = binds.get(i) || null;
261
+ if (bind) binds.delete(i);
262
+ const hasCall = steps.some((st) => st[0] === "c" || st[0] === "m" || st[0] === "n");
263
+ if (hasCall || bind) events.push(["c", tk.line[i], bind, steps]);
264
+ i++;
265
+ }
266
+ return events;
267
+ }
@@ -5,7 +5,9 @@
5
5
  "comments": {
6
6
  "line": ["//"],
7
7
  "block": [["/*", "*/"]],
8
- "string": ["\"\"\"", "\""]
8
+ "string": ["\"\"\"", "\""],
9
+ "dialect": "kotlin",
10
+ "nested": true
9
11
  },
10
12
  "definitionPatterns": [
11
13
  {
@@ -56,7 +58,10 @@
56
58
  }
57
59
  ],
58
60
  "referenceKinds": ["class", "interface", "object", "enum", "record", "typealias", "composable"],
59
- "supertypes": { "syntax": "colon", "kinds": ["class", "interface", "object", "enum"] },
61
+ "supertypes": {
62
+ "syntax": "colon",
63
+ "kinds": ["class", "interface", "object", "enum"]
64
+ },
60
65
  "referenceKindsNote": "fun is deliberately absent, for the reason Swift's rules record for func: a bare lowercase name matched across files is almost never a call to that exact declaration, and on a large app the generic ones (invoke, build, create, get) take the top god-node slots purely because each happened to be declared once. A capitalised fun is the exception and gets its own kind, composable: Kotlin names ordinary functions in lowerCamelCase, so a capitalised fun is in practice a Compose UI function (or a factory named after the type it builds), and it is called by that exact name the way a type is.",
61
66
  "ignoredIdentifiers": [
62
67
  "this",
@@ -0,0 +1,99 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "stack": "cpp",
4
+ "description": "C and C++ code-graph rules. Classes, structs, unions and enums are the symbols; functions and methods come from the call analysis, which blanks preprocessor lines first. A forward declaration (`class Foo;`) defines nothing.",
5
+ "comments": {
6
+ "line": ["//"],
7
+ "block": [["/*", "*/"]],
8
+ "string": ["\""],
9
+ "dialect": "cpp"
10
+ },
11
+ "importSpecifiersAreStrings": true,
12
+ "definitionPatterns": [
13
+ {
14
+ "id": "enum",
15
+ "kind": "enum",
16
+ "regex": "\\benum\\s+(?:class\\s+|struct\\s+)?([A-Za-z_][A-Za-z0-9_]*)\\s*(?::[^;{]*)?\\{"
17
+ },
18
+ {
19
+ "id": "class",
20
+ "kind": "class",
21
+ "regex": "\\bclass\\s+([A-Za-z_][A-Za-z0-9_]*)\\s*(?:final\\s*)?(?::[^;{]*)?\\{"
22
+ },
23
+ {
24
+ "id": "struct",
25
+ "kind": "struct",
26
+ "regex": "\\bstruct\\s+([A-Za-z_][A-Za-z0-9_]*)\\s*(?:final\\s*)?(?::[^;{]*)?\\{"
27
+ },
28
+ {
29
+ "id": "union",
30
+ "kind": "union",
31
+ "regex": "\\bunion\\s+([A-Za-z_][A-Za-z0-9_]*)\\s*\\{"
32
+ }
33
+ ],
34
+ "importPatterns": [
35
+ {
36
+ "id": "include",
37
+ "regex": "^\\s*#\\s*include\\s*[<\"](?:[A-Za-z0-9_.+-]+/)*([A-Za-z0-9_+-]+)(?:\\.[A-Za-z]+)?[>\"]"
38
+ }
39
+ ],
40
+ "referenceKinds": ["class", "struct", "union", "enum"],
41
+ "supertypes": {
42
+ "syntax": "colon",
43
+ "kinds": ["class", "struct"]
44
+ },
45
+ "ignoredIdentifiers": [
46
+ "this",
47
+ "class",
48
+ "struct",
49
+ "union",
50
+ "enum",
51
+ "namespace",
52
+ "using",
53
+ "typedef",
54
+ "template",
55
+ "typename",
56
+ "public",
57
+ "private",
58
+ "protected",
59
+ "virtual",
60
+ "static",
61
+ "inline",
62
+ "const",
63
+ "constexpr",
64
+ "override",
65
+ "final",
66
+ "void",
67
+ "int",
68
+ "char",
69
+ "bool",
70
+ "float",
71
+ "double",
72
+ "long",
73
+ "short",
74
+ "unsigned",
75
+ "signed",
76
+ "auto",
77
+ "new",
78
+ "delete",
79
+ "return",
80
+ "if",
81
+ "else",
82
+ "for",
83
+ "while",
84
+ "switch",
85
+ "case",
86
+ "default",
87
+ "try",
88
+ "catch",
89
+ "throw",
90
+ "nullptr",
91
+ "NULL",
92
+ "true",
93
+ "false",
94
+ "std",
95
+ "string",
96
+ "vector",
97
+ "map"
98
+ ]
99
+ }
@@ -0,0 +1,102 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "stack": "csharp",
4
+ "description": "C# code-graph rules. Types are the symbols; methods, constructors and properties come from the call analysis. A partial type spread over several files is one type to the call analysis.",
5
+ "comments": {
6
+ "line": ["//"],
7
+ "block": [["/*", "*/"]],
8
+ "string": ["\"\"\"", "\"", "'"],
9
+ "dialect": "csharp"
10
+ },
11
+ "definitionPatterns": [
12
+ {
13
+ "id": "enum",
14
+ "kind": "enum",
15
+ "regex": "\\benum\\s+([A-Z][A-Za-z0-9_]*)"
16
+ },
17
+ {
18
+ "id": "record",
19
+ "kind": "record",
20
+ "regex": "\\brecord\\s+(?:class\\s+|struct\\s+)?([A-Z][A-Za-z0-9_]*)"
21
+ },
22
+ {
23
+ "id": "interface",
24
+ "kind": "interface",
25
+ "regex": "\\binterface\\s+([A-Z][A-Za-z0-9_]*)"
26
+ },
27
+ {
28
+ "id": "struct",
29
+ "kind": "struct",
30
+ "regex": "\\bstruct\\s+([A-Z][A-Za-z0-9_]*)"
31
+ },
32
+ {
33
+ "id": "class",
34
+ "kind": "class",
35
+ "regex": "\\bclass\\s+([A-Z][A-Za-z0-9_]*)"
36
+ }
37
+ ],
38
+ "importPatterns": [
39
+ {
40
+ "id": "using",
41
+ "regex": "^\\s*(?:global\\s+)?using\\s+(?:static\\s+)?(?:[A-Za-z_][A-Za-z0-9_]*\\.)*([A-Za-z_][A-Za-z0-9_]*)\\s*;"
42
+ }
43
+ ],
44
+ "referenceKinds": ["class", "interface", "struct", "enum", "record"],
45
+ "supertypes": {
46
+ "syntax": "colon",
47
+ "kinds": ["class", "interface", "struct", "record"]
48
+ },
49
+ "ignoredIdentifiers": [
50
+ "this",
51
+ "base",
52
+ "class",
53
+ "interface",
54
+ "struct",
55
+ "enum",
56
+ "record",
57
+ "namespace",
58
+ "using",
59
+ "public",
60
+ "private",
61
+ "protected",
62
+ "internal",
63
+ "static",
64
+ "readonly",
65
+ "abstract",
66
+ "virtual",
67
+ "override",
68
+ "sealed",
69
+ "partial",
70
+ "async",
71
+ "await",
72
+ "void",
73
+ "new",
74
+ "return",
75
+ "if",
76
+ "else",
77
+ "for",
78
+ "foreach",
79
+ "while",
80
+ "switch",
81
+ "case",
82
+ "default",
83
+ "try",
84
+ "catch",
85
+ "finally",
86
+ "throw",
87
+ "null",
88
+ "true",
89
+ "false",
90
+ "var",
91
+ "string",
92
+ "object",
93
+ "int",
94
+ "bool",
95
+ "Task",
96
+ "List",
97
+ "Dictionary",
98
+ "IEnumerable",
99
+ "Action",
100
+ "Func"
101
+ ]
102
+ }
@@ -5,7 +5,8 @@
5
5
  "comments": {
6
6
  "line": ["//"],
7
7
  "block": [["/*", "*/"]],
8
- "string": ["`", "\"", "'"]
8
+ "string": ["`", "\"", "'"],
9
+ "dialect": "go"
9
10
  },
10
11
  "importSpecifiersAreStrings": true,
11
12
  "definitionPatterns": [
@@ -5,7 +5,9 @@
5
5
  "comments": {
6
6
  "line": ["//"],
7
7
  "block": [["/*", "*/"]],
8
- "string": ["\"\"\"", "\""]
8
+ "string": ["\"\"\"", "\""],
9
+ "dialect": "swift",
10
+ "nested": true
9
11
  },
10
12
  "definitionPatterns": [
11
13
  {
@@ -0,0 +1,76 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "stack": "java",
4
+ "description": "Java code-graph rules for a plain JVM project (Maven or Gradle layout). A Java file inside an Android project is covered by the android stack, which reads .java and .kt together. Types are the symbols; methods and constructors come from the call analysis.",
5
+ "comments": {
6
+ "line": ["//"],
7
+ "block": [["/*", "*/"]],
8
+ "string": ["\"\"\"", "\"", "'"]
9
+ },
10
+ "definitionPatterns": [
11
+ { "id": "enum", "kind": "enum", "regex": "\\benum\\s+([A-Z][A-Za-z0-9_]*)" },
12
+ { "id": "record", "kind": "record", "regex": "\\brecord\\s+([A-Z][A-Za-z0-9_]*)\\s*[(<]" },
13
+ {
14
+ "id": "interface",
15
+ "kind": "interface",
16
+ "regex": "(?<!@)\\binterface\\s+([A-Z][A-Za-z0-9_]*)"
17
+ },
18
+ { "id": "class", "kind": "class", "regex": "\\bclass\\s+([A-Z][A-Za-z0-9_]*)" }
19
+ ],
20
+ "importPatterns": [
21
+ {
22
+ "id": "import",
23
+ "regex": "^\\s*import\\s+(?:static\\s+)?(?:[A-Za-z_][A-Za-z0-9_]*\\.)*([A-Za-z_][A-Za-z0-9_]*)\\s*;"
24
+ }
25
+ ],
26
+ "referenceKinds": ["class", "interface", "enum", "record"],
27
+ "supertypes": { "syntax": "extends", "kinds": ["class", "interface", "enum", "record"] },
28
+ "ignoredIdentifiers": [
29
+ "this",
30
+ "super",
31
+ "class",
32
+ "interface",
33
+ "enum",
34
+ "record",
35
+ "extends",
36
+ "implements",
37
+ "import",
38
+ "package",
39
+ "public",
40
+ "private",
41
+ "protected",
42
+ "static",
43
+ "final",
44
+ "abstract",
45
+ "void",
46
+ "new",
47
+ "return",
48
+ "if",
49
+ "else",
50
+ "for",
51
+ "while",
52
+ "switch",
53
+ "case",
54
+ "default",
55
+ "try",
56
+ "catch",
57
+ "finally",
58
+ "throw",
59
+ "throws",
60
+ "null",
61
+ "true",
62
+ "false",
63
+ "String",
64
+ "Object",
65
+ "Integer",
66
+ "Long",
67
+ "Double",
68
+ "Boolean",
69
+ "List",
70
+ "Map",
71
+ "Set",
72
+ "Optional",
73
+ "Override",
74
+ "Test"
75
+ ]
76
+ }
@@ -5,7 +5,9 @@
5
5
  "comments": {
6
6
  "line": ["//"],
7
7
  "block": [["/*", "*/"]],
8
- "string": ["`", "\"", "'"]
8
+ "string": ["`", "\"", "'"],
9
+ "regex": true,
10
+ "dialect": "js"
9
11
  },
10
12
  "definitionPatterns": [
11
13
  {
@@ -46,7 +48,10 @@
46
48
  }
47
49
  ],
48
50
  "referenceKinds": ["class", "interface", "type", "enum", "const"],
49
- "supertypes": { "syntax": "extends", "kinds": ["class", "interface"] },
51
+ "supertypes": {
52
+ "syntax": "extends",
53
+ "kinds": ["class", "interface"]
54
+ },
50
55
  "referenceKindsNote": "function is deliberately absent, for the reason Swift's rules record for func: a bare name matched across files is almost never a call to that exact declaration, and the generic ones (run, main, get, parse, handler) would take the top god-node slots purely because each happened to be declared once. Functions still reach the graph through their defines edge, so they stay findable by name. const is present but narrowed to an uppercase-initial declaration at column 0, which is what a component, a singleton or an exported table looks like; a lowercase const is a local and is not a declaration anyone references across files. Measured on this repo (126 sources): including function put `ok` at degree 52, `f` at 38, `tokens` at 15 and `arg` at 12 - local helper names that happen to be declared exactly once, so the ambiguity rule does not catch them either. Excluding it leaves a thin symbol layer, and that is the honest shape of this stack: a JavaScript module's exported unit is usually a function, so the useful graph here is the import graph between files. `graph-affected \"<file>.mjs\"` answers who imports a module, which is the question this stack actually gets asked.",
51
56
  "ignoredIdentifiers": [
52
57
  "this",
@@ -5,7 +5,8 @@
5
5
  "comments": {
6
6
  "line": ["#"],
7
7
  "block": [],
8
- "string": ["\"\"\"", "'''", "\"", "'"]
8
+ "string": ["\"\"\"", "'''", "\"", "'"],
9
+ "dialect": "python"
9
10
  },
10
11
  "definitionPatterns": [
11
12
  {
@@ -30,7 +31,10 @@
30
31
  }
31
32
  ],
32
33
  "referenceKinds": ["class"],
33
- "supertypes": { "syntax": "parens", "kinds": ["class"] },
34
+ "supertypes": {
35
+ "syntax": "parens",
36
+ "kinds": ["class"]
37
+ },
34
38
  "referenceKindsNote": "def is deliberately absent, for the reason Swift's rules record for func and the node rules record with measurements: a bare lowercase name matched across files is almost never a call to that exact declaration, and Python's convention of short module-level helpers (main, run, load, parse, setup) makes it worse than most. Functions still reach the graph through their defines edge, so they stay findable by name.",
35
39
  "ignoredIdentifiers": [
36
40
  "self",