@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,308 @@
1
+ /**
2
+ * @file cpp.mjs - C and C++ profile for the call-edge scanner.
3
+ *
4
+ * Preprocessor lines are blanked before scanning, so macro-defined code is
5
+ * invisible and conditional compilation contributes every branch. A declaration
6
+ * in a header and its definition in a source file are both functions of the
7
+ * graph; a call resolves to the definition. Namespaces, classes, structs, enums,
8
+ * out-of-class member definitions (`Type Class::name(...) {`), constructors,
9
+ * and `#include "x.h"` bindings are read. Not modelled: templates beyond the
10
+ * parameter list, overload resolution by type, ADL, function pointers, and
11
+ * macros that expand to declarations or calls.
12
+ *
13
+ * @module pipeline/scripts/call-graph/lang/cpp
14
+ */
15
+
16
+ import { isIdent, readType, skipAngles, tick, MAX_HEADER_TOKENS } from "../lex.mjs";
17
+ import { genericNames, typeList, paramsTypeFirst } from "./shared.mjs";
18
+
19
+ const SPECS = new Set(
20
+ `static inline virtual extern constexpr consteval constinit explicit friend typedef mutable register
21
+ thread_local volatile const unsigned signed long short`.split(/\s+/),
22
+ );
23
+ const KEYWORDS = new Set(
24
+ `if else for while do switch case default return throw try catch break continue goto new delete
25
+ class struct union enum namespace using typedef template typename public private protected
26
+ virtual static inline const volatile sizeof alignof typeid operator this nullptr true false auto
27
+ void int long short char float double bool unsigned signed co_await co_return co_yield`.split(
28
+ /\s+/,
29
+ ),
30
+ );
31
+ const TYPE_KW = new Set(["class", "struct", "union", "enum"]);
32
+
33
+ function prepare(text) {
34
+ const lines = text.split("\n");
35
+ let continued = false;
36
+ for (let i = 0; i < lines.length; i++) {
37
+ const trimmed = lines[i].trimStart();
38
+ if (continued || trimmed.startsWith("#")) {
39
+ continued = lines[i].trimEnd().endsWith("\\");
40
+ const branch = !continued && trimmed.match(/^#\s*(if|ifdef|ifndef|else|elif|endif)\b/);
41
+ lines[i] = branch ? `#${branch[1]}`.padEnd(lines[i].length) : " ".repeat(lines[i].length);
42
+ }
43
+ }
44
+ return lines.join("\n").replace(/'(?:\\.[^']*|[^'\\\n])'/g, (m) => "0".padEnd(m.length, " "));
45
+ }
46
+
47
+ function parse(tk) {
48
+ const t = tk.t;
49
+ const types = [];
50
+ const fns = [];
51
+
52
+ const walk = (from, to, owner, ownerKind) => {
53
+ let i = from;
54
+ while (i < to) {
55
+ tick(tk);
56
+ const s = t[i];
57
+ if (s === "namespace") {
58
+ let j = i + 1;
59
+ while (isIdent(t[j]) || t[j] === "::") j++;
60
+ if (t[j] === "{" && tk.m[j] > j) {
61
+ walk(j + 1, tk.m[j], owner, ownerKind);
62
+ i = tk.m[j] + 1;
63
+ continue;
64
+ }
65
+ i = j;
66
+ continue;
67
+ }
68
+ if (s === "extern" && t[i + 2] === "{" && tk.m[i + 2] > i + 2) {
69
+ walk(i + 3, tk.m[i + 2], owner, ownerKind);
70
+ i = tk.m[i + 2] + 1;
71
+ continue;
72
+ }
73
+ if ((s === "public" || s === "private" || s === "protected") && t[i + 1] === ":") {
74
+ i += 2;
75
+ continue;
76
+ }
77
+ if (s === "template" && t[i + 1] === "<") {
78
+ const g = genericNames(tk, i + 1);
79
+ pendingGen = g.gen;
80
+ const after = skipAngles(tk, i + 1);
81
+ i = after > i + 1 ? after : i + 1;
82
+ continue;
83
+ }
84
+ if (TYPE_KW.has(s)) {
85
+ const next = typeDecl(i, to, owner);
86
+ if (next > i) {
87
+ i = next;
88
+ continue;
89
+ }
90
+ }
91
+ if (s === "using" || s === "typedef") {
92
+ while (i < to && t[i] !== ";") i = tk.m[i] > i ? tk.m[i] + 1 : i + 1;
93
+ i++;
94
+ continue;
95
+ }
96
+ const next = statement(i, to, owner, ownerKind);
97
+ i = Math.max(next, i + 1);
98
+ }
99
+ };
100
+ let pendingGen = [];
101
+
102
+ const typeDecl = (i, to, outer) => {
103
+ let j = i + 1;
104
+ if (t[j] === "class" || t[j] === "struct") j++;
105
+ while (t[j] === "[" && tk.m[j] > j) j = tk.m[j] + 1;
106
+ if (!isIdent(t[j])) return i;
107
+ const name = t[j];
108
+ j++;
109
+ if (t[j] === "final") j++;
110
+ const sup = [];
111
+ if (t[j] === ":") {
112
+ let k = j + 1;
113
+ const lim = Math.min(to, k + MAX_HEADER_TOKENS);
114
+ while (k < lim && t[k] !== "{") k = tk.m[k] > k ? tk.m[k] + 1 : k + 1;
115
+ if (t[i] !== "enum")
116
+ sup.push(...typeList(tk, j + 1, k, new Set(["public", "private", "protected", "virtual"])));
117
+ j = k;
118
+ }
119
+ if (t[j] !== "{" || tk.m[j] < 0) return i;
120
+ types.push({
121
+ n: name,
122
+ k: t[i] === "enum" ? "enum" : t[i],
123
+ line: tk.line[i],
124
+ end: tk.line[tk.m[j]],
125
+ sup,
126
+ ...(outer ? { outer } : {}),
127
+ ...(pendingGen.length ? { gen: pendingGen } : {}),
128
+ f: {},
129
+ });
130
+ pendingGen = [];
131
+ if (t[i] !== "enum") walk(j + 1, tk.m[j], name, t[i]);
132
+ let after = tk.m[j] + 1;
133
+ while (after < to && t[after] !== ";" && !isIdent(t[after])) after++;
134
+ return t[after] === ";" ? after + 1 : tk.m[j] + 1;
135
+ };
136
+
137
+ const statement = (i, to, owner, ownerKind) => {
138
+ let k = i;
139
+ let paren = -1;
140
+ while (k < to && t[k] !== ";" && t[k] !== "{" && t[k] !== "}") {
141
+ if (t[k] === "(" && paren < 0 && k > i && (isIdent(t[k - 1]) || t[k - 1] === ">")) {
142
+ const before = t[k - 1];
143
+ if (!KEYWORDS.has(before) || before === "operator") {
144
+ paren = k;
145
+ break;
146
+ }
147
+ }
148
+ if (t[k] === "=") break;
149
+ k = tk.m[k] > k ? tk.m[k] + 1 : k + 1;
150
+ }
151
+ if (paren > 0) return funcAt(i, paren, to, owner, ownerKind);
152
+ let e = k;
153
+ while (e < to && t[e] !== ";") e = tk.m[e] > e ? tk.m[e] + 1 : e + 1;
154
+ if (owner && ownerKind !== "enum") field(i, k);
155
+ return e + 1;
156
+ };
157
+
158
+ const field = (i, end) => {
159
+ let j = i;
160
+ while (SPECS.has(t[j])) j++;
161
+ const r = readType(tk, j, { skip: SPECS, limit: end });
162
+ if (!r.name) return;
163
+ let k = r.next;
164
+ while (t[k] === "*" || t[k] === "&") k++;
165
+ if (isIdent(t[k])) {
166
+ const rec = types[types.length - 1];
167
+ if (rec) rec.f[t[k]] = r.name;
168
+ }
169
+ };
170
+
171
+ const funcAt = (i, paren, to, owner, ownerKind) => {
172
+ let nameTok = paren - 1;
173
+ const name = t[nameTok];
174
+ let cls = owner;
175
+ if (name === ">") return skipStatement(paren, to);
176
+ if (name === "operator" || t[nameTok - 1] === "operator") return skipStatement(paren, to);
177
+ if (t[nameTok - 1] === "~") nameTok--;
178
+ while (t[nameTok - 1] === "::" && isIdent(t[nameTok - 2])) {
179
+ cls = t[nameTok - 2];
180
+ nameTok -= 2;
181
+ }
182
+ let retStart = i;
183
+ while (SPECS.has(t[retStart]) || t[retStart] === "[")
184
+ retStart = t[retStart] === "[" ? tk.m[retStart] + 1 : retStart + 1;
185
+ const ret =
186
+ nameTok > retStart ? readType(tk, retStart, { skip: SPECS, limit: nameTok }).name : null;
187
+ const isCtor = name === cls || t[nameTok] === "~";
188
+ const sig = paramsTypeFirst(tk, paren, { skip: SPECS });
189
+ let j = tk.m[paren] + 1;
190
+ let trailing = null;
191
+ const lim = Math.min(to, j + MAX_HEADER_TOKENS);
192
+ while (j < lim && t[j] !== "{" && t[j] !== ";") {
193
+ if (t[j] === "->") trailing = readType(tk, j + 1, { limit: to }).name;
194
+ j = tk.m[j] > j ? tk.m[j] + 1 : j + 1;
195
+ }
196
+ const body = t[j] === "{" && tk.m[j] > j ? [j + 1, tk.m[j]] : null;
197
+ const pure = !body && t[j - 1] === "0" && t[j - 2] === "=";
198
+ fns.push({
199
+ n: isCtor ? "constructor" : name,
200
+ o: cls || null,
201
+ a: [sig.min, sig.max],
202
+ p: sig.params.filter((q) => q[0]),
203
+ r: isCtor ? cls : trailing || (ret === "auto" ? null : ret),
204
+ l: tk.line[i],
205
+ e: tk.line[body ? body[1] : i],
206
+ ...(t.slice(i, nameTok).includes("static") ? { s: 1 } : {}),
207
+ ...(!body || pure ? { ab: 1 } : {}),
208
+ ...(pendingGen.length ? { g: pendingGen } : {}),
209
+ body,
210
+ });
211
+ pendingGen = [];
212
+ void ownerKind;
213
+ return body ? body[1] + 1 : j + 1;
214
+ };
215
+
216
+ const skipStatement = (from, to) => {
217
+ let j = from;
218
+ while (j < to && t[j] !== ";" && t[j] !== "{") j = tk.m[j] > j ? tk.m[j] + 1 : j + 1;
219
+ return t[j] === "{" && tk.m[j] > j ? tk.m[j] + 1 : j + 1;
220
+ };
221
+
222
+ walk(0, tk.n, null, null);
223
+ return { types, fns, binds: [] };
224
+ }
225
+
226
+ function localDecl(tk, i, end) {
227
+ const t = tk.t;
228
+ const s = t[i];
229
+ if (
230
+ KEYWORDS.has(s) &&
231
+ ![
232
+ "auto",
233
+ "int",
234
+ "long",
235
+ "short",
236
+ "char",
237
+ "float",
238
+ "double",
239
+ "bool",
240
+ "unsigned",
241
+ "signed",
242
+ "const",
243
+ ].includes(s)
244
+ )
245
+ return null;
246
+ let j = i;
247
+ while (SPECS.has(t[j])) j++;
248
+ const r = readType(tk, j, { skip: SPECS, limit: end });
249
+ if (!r.name && r.next === j) return null;
250
+ let k = r.next;
251
+ while (t[k] === "*" || t[k] === "&" || t[k] === "&&" || t[k] === "const") k++;
252
+ if (!isIdent(t[k]) || KEYWORDS.has(t[k])) return null;
253
+ const name = t[k];
254
+ const nx = t[k + 1];
255
+ const type = r.name === "auto" ? null : r.name;
256
+ if (nx === "=") return { name, type, init: k + 2, next: k + 2 };
257
+ if (nx === ";" || nx === "," || nx === ":" || nx === "[")
258
+ return { name, type, init: null, next: k + 1 };
259
+ if ((nx === "(" || nx === "{") && tk.m[k + 1] > k + 1 && r.name && r.name !== "auto")
260
+ return { name, type, init: null, next: k + 1 };
261
+ return null;
262
+ }
263
+
264
+ function binds(text) {
265
+ const out = [];
266
+ for (const m of text.matchAll(/^[ \t]*#[ \t]{0,4}include[ \t]{0,4}"([^"\n]{1,300})"/gm)) {
267
+ const base = m[1]
268
+ .split("/")
269
+ .pop()
270
+ .replace(/\.[^.]+$/, "");
271
+ out.push({ l: `#${base}`, m: m[1], x: null });
272
+ }
273
+ return out;
274
+ }
275
+
276
+ export default {
277
+ id: "cpp",
278
+ exts: [".c", ".h", ".cc", ".cpp", ".cxx", ".hpp", ".hh", ".hxx", ".inl"],
279
+ implicitSelf: true,
280
+ initName: "constructor",
281
+ selfWords: new Set(["this"]),
282
+ superWords: new Set(),
283
+ newKeyword: "new",
284
+ memberOps: new Set([".", "->", "::"]),
285
+ labelOps: [],
286
+ genericCalls: true,
287
+ keywords: KEYWORDS,
288
+ declWords: new Set([
289
+ "class",
290
+ "struct",
291
+ "union",
292
+ "enum",
293
+ "namespace",
294
+ "using",
295
+ "typedef",
296
+ "new",
297
+ "delete",
298
+ "sizeof",
299
+ "typename",
300
+ ]),
301
+ condWords: new Set(["for", "catch", "(", "if", "while", "switch"]),
302
+ bareCallConstructs: true,
303
+ keepStrings: true,
304
+ prepare,
305
+ parse,
306
+ localDecl,
307
+ binds,
308
+ };
@@ -0,0 +1,130 @@
1
+ /**
2
+ * @file csharp.mjs - C# profile for the call-edge scanner.
3
+ *
4
+ * Shares the member grammar with Java and adds what C# declares differently:
5
+ * namespaces (block and file-scoped), properties with accessor bodies, expression
6
+ * bodied members, extension methods (a static method whose first parameter is
7
+ * `this T` becomes a method of `T`), attributes, and `partial` types spread over
8
+ * several files, which are merged into one type. Not modelled: LINQ query
9
+ * syntax, dynamic, implicit usings, and which overload a conversion selects.
10
+ *
11
+ * @module pipeline/scripts/call-graph/lang/csharp
12
+ */
13
+
14
+ import { isIdent, readType } from "../lex.mjs";
15
+ import { makeParse } from "./java.mjs";
16
+
17
+ const MODS = new Set(
18
+ `public private protected internal static readonly virtual override abstract sealed partial async
19
+ extern unsafe new const volatile implicit explicit required file`.split(/\s+/),
20
+ );
21
+ const TYPE_KW = new Set(["class", "interface", "struct", "enum", "record"]);
22
+ const KEYWORDS = new Set(
23
+ `if else for foreach while do switch case default return throw try catch finally new break continue
24
+ class interface struct enum record namespace using static public private protected internal
25
+ readonly virtual override abstract sealed partial async await extern unsafe const volatile
26
+ void int long short byte char bool double float decimal string object true false null typeof
27
+ nameof is as in out ref lock checked unchecked yield goto var base this`.split(/\s+/),
28
+ );
29
+ const PRIMITIVE = new Set([
30
+ "int",
31
+ "long",
32
+ "short",
33
+ "byte",
34
+ "char",
35
+ "bool",
36
+ "double",
37
+ "float",
38
+ "decimal",
39
+ "string",
40
+ "object",
41
+ ]);
42
+
43
+ function skipAttributes(tk, i) {
44
+ let j = i;
45
+ while (tk.t[j] === "[" && tk.m[j] > j) j = tk.m[j] + 1;
46
+ return j;
47
+ }
48
+
49
+ function localDecl(tk, i, end) {
50
+ const t = tk.t;
51
+ const s = t[i];
52
+ if (s === "using" && t[i + 1] === "var") return localDecl(tk, i + 1, end);
53
+ if (KEYWORDS.has(s) && s !== "var" && !PRIMITIVE.has(s)) return null;
54
+ const r = readType(tk, i, { limit: end });
55
+ if (!r.name && r.next === i) return null;
56
+ const k = r.next;
57
+ if (!isIdent(t[k]) || (KEYWORDS.has(t[k]) && t[k] !== "value")) return null;
58
+ const name = t[k];
59
+ const nx = t[k + 1];
60
+ const type = r.name === "var" ? null : r.name;
61
+ if (nx === "=") return { name, type, init: k + 2, next: k + 2 };
62
+ if (nx === ";" || nx === "," || nx === "in") return { name, type, init: null, next: k + 1 };
63
+ return null;
64
+ }
65
+
66
+ function lambdaParams(tk, i) {
67
+ const t = tk.t;
68
+ if (t[i] === "(" && tk.m[i] > i && t[tk.m[i] + 1] === "=>") {
69
+ const params = [];
70
+ for (let k = i + 1; k < tk.m[i]; k++) {
71
+ if (isIdent(t[k]) && (t[k + 1] === "," || k + 1 === tk.m[i])) params.push([t[k], null]);
72
+ }
73
+ return params.length ? { params } : null;
74
+ }
75
+ if (isIdent(t[i]) && t[i + 1] === "=>" && t[i - 1] !== ".") return { params: [[t[i], null]] };
76
+ return null;
77
+ }
78
+
79
+ function castType(tk, open) {
80
+ if (tk.t[open + 1] === "(" && tk.m[open + 1] > open + 1) {
81
+ return readType(tk, open + 2, { limit: tk.m[open + 1] }).name;
82
+ }
83
+ return null;
84
+ }
85
+
86
+ export default {
87
+ id: "csharp",
88
+ stringType: "string",
89
+ exts: [".cs"],
90
+ implicitSelf: true,
91
+ initName: "constructor",
92
+ selfWords: new Set(["this"]),
93
+ superWords: new Set(["base"]),
94
+ newKeyword: "new",
95
+ memberOps: new Set([".", "?.", "!."]),
96
+ labelOps: [":"],
97
+ castWords: new Set(["as"]),
98
+ castFn: castType,
99
+ keywords: KEYWORDS,
100
+ declWords: new Set([
101
+ "class",
102
+ "interface",
103
+ "struct",
104
+ "enum",
105
+ "record",
106
+ "new",
107
+ "namespace",
108
+ "using",
109
+ "typeof",
110
+ "nameof",
111
+ ]),
112
+ condWords: new Set(["foreach", "for", "using", "catch", "(", "if", "while"]),
113
+ union: false,
114
+ parse: makeParse({
115
+ mods: MODS,
116
+ typeKw: TYPE_KW,
117
+ namespaces: true,
118
+ propertyBraces: true,
119
+ extensionThis: true,
120
+ skipAttributes,
121
+ paramMods: new Set(["this", "ref", "out", "in", "params", "scoped", "readonly"]),
122
+ partialOf: (tk, from, i) => {
123
+ for (let k = i - 1; k >= Math.max(from, i - 8); k--) if (tk.t[k] === "partial") return true;
124
+ return false;
125
+ },
126
+ }),
127
+ localDecl,
128
+ lambdaParams,
129
+ binds: () => [],
130
+ };