@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.
- package/CHANGELOG.md +50 -0
- package/README.md +25 -6
- package/README.tr.md +26 -7
- package/docs/adr/0008-installer-modularization-and-secret-leak-defense.md +1 -1
- package/docs/adr/0010-own-code-graph.md +299 -8
- package/docs/architecture.md +3 -3
- package/docs/ecosystem.md +10 -10
- package/docs/engineering.md +4 -4
- package/docs/facts.json +8 -8
- package/docs/features.md +6 -6
- package/docs/performance.md +17 -17
- package/install/_dev-only-files.mjs +9 -0
- package/install/claude.mjs +28 -2
- package/install/templates/claude-hooks.json +32 -1
- package/manifest.json +229 -161
- package/package.json +11 -3
- package/pipeline/commands/multi-agent/SKILL.md +1 -1
- package/pipeline/commands/multi-agent/design-check/SKILL.md +2 -2
- package/pipeline/commands/multi-agent/diff-explain/SKILL.md +3 -3
- package/pipeline/commands/multi-agent/fable-status/SKILL.md +1 -1
- package/pipeline/commands/multi-agent/graph/SKILL.md +57 -24
- package/pipeline/commands/multi-agent/pair/SKILL.md +92 -0
- package/pipeline/commands/multi-agent/prune-prompts/SKILL.md +1 -1
- package/pipeline/commands/multi-agent/search/SKILL.md +7 -1
- package/pipeline/commands/multi-agent/status/SKILL.md +4 -0
- package/pipeline/commands/multi-agent/sync/SKILL.md +3 -3
- package/pipeline/contract/CHANGELOG.md +49 -0
- package/pipeline/contract/build.mjs +13 -1
- package/pipeline/contract/fixtures/error-invalid-request.json +1 -1
- package/pipeline/contract/fixtures/error-unauthorized.json +1 -1
- package/pipeline/contract/fixtures/runs-awaiting-question.json +4 -1
- package/pipeline/contract/fixtures/runs-empty.json +1 -1
- package/pipeline/contract/fixtures/runs-failed.json +4 -1
- package/pipeline/contract/fixtures/runs-old-schema.json +3 -0
- package/pipeline/contract/fixtures/runs-pr-opened-redacted.json +4 -1
- package/pipeline/contract/fixtures/runs-pr-opened.json +4 -1
- package/pipeline/contract/fixtures/runs-running.json +4 -1
- package/pipeline/contract/manifest.json +28 -15
- package/pipeline/contract/types/index.d.ts +55 -3
- package/pipeline/lib/detach-self.mjs +95 -0
- package/pipeline/lib/model-rung.sh +1 -1
- package/pipeline/lib/public-mcp-servers.mjs +33 -0
- package/pipeline/lib/rotated-log.mjs +93 -0
- package/pipeline/lib/tls-trust.mjs +29 -0
- package/pipeline/lib/usage-lifecycle.mjs +9 -11
- package/pipeline/lib/usage-names.generated.mjs +614 -0
- package/pipeline/lib/usage-run-key.mjs +235 -0
- package/pipeline/lib/usage-vocab.mjs +210 -0
- package/pipeline/multi-agent-refs/analysis/intake.md +2 -2
- package/pipeline/multi-agent-refs/analysis/render.md +1 -1
- package/pipeline/multi-agent-refs/channels/generator.md +4 -5
- package/pipeline/multi-agent-refs/cross-cli-contract.md +4 -4
- package/pipeline/multi-agent-refs/design-check/scope-and-ledger.md +1 -1
- package/pipeline/multi-agent-refs/features/code-graph.md +146 -11
- package/pipeline/multi-agent-refs/features/code-intelligence.md +16 -14
- package/pipeline/multi-agent-refs/features/dev-critic.md +7 -7
- package/pipeline/multi-agent-refs/features/model-fallback.md +9 -7
- package/pipeline/multi-agent-refs/features/remote-control.md +252 -0
- package/pipeline/multi-agent-refs/features/review-delta.md +1 -1
- package/pipeline/multi-agent-refs/features/review-file-set.md +3 -3
- package/pipeline/multi-agent-refs/features/review-multi-repo.md +1 -1
- package/pipeline/multi-agent-refs/features/session-brief.md +42 -0
- package/pipeline/multi-agent-refs/features/skill-conformance.md +3 -3
- package/pipeline/multi-agent-refs/features/usage-reporting.md +252 -24
- package/pipeline/multi-agent-refs/help/en.md +3 -2
- package/pipeline/multi-agent-refs/help/tr.md +3 -2
- package/pipeline/multi-agent-refs/knowledge.md +1 -1
- package/pipeline/multi-agent-refs/orchestrator/copilot-pipeline.md +1 -1
- package/pipeline/multi-agent-refs/orchestrator/dispatcher.md +1 -1
- package/pipeline/multi-agent-refs/phases/operations.md +2 -2
- package/pipeline/multi-agent-refs/phases/phase-0-init.md +13 -12
- package/pipeline/multi-agent-refs/phases/phase-1-plan.md +4 -4
- package/pipeline/multi-agent-refs/phases/phase-3-review.md +5 -3
- package/pipeline/multi-agent-refs/phases/phase-5-report.md +1 -1
- package/pipeline/multi-agent-refs/platform-parity.md +2 -2
- package/pipeline/multi-agent-refs/review/panel.md +1 -1
- package/pipeline/multi-agent-refs/wiki-capture.md +3 -17
- package/pipeline/office/index.html +1207 -233
- package/pipeline/office/toolkit.json +1 -1
- package/pipeline/rules/outside-the-pipeline.md +1 -1
- package/pipeline/schemas/activity.schema.json +23 -0
- package/pipeline/schemas/agent-state.schema.json +6 -1
- package/pipeline/schemas/code-graph-calls.schema.json +254 -0
- package/pipeline/schemas/code-graph-docs.schema.json +223 -0
- package/pipeline/schemas/code-graph-infra.schema.json +227 -0
- package/pipeline/schemas/code-graph.schema.json +2 -2
- package/pipeline/schemas/examples/design-check-config.json +27 -0
- package/pipeline/schemas/learning-curve.schema.json +67 -0
- package/pipeline/schemas/office-jobs.json +69 -2
- package/pipeline/schemas/office-jobs.schema.json +8 -1
- package/pipeline/schemas/phases.json +5 -0
- package/pipeline/schemas/phases.schema.json +8 -0
- package/pipeline/schemas/prefs.schema.json +46 -12
- package/pipeline/schemas/runs-index.schema.json +17 -0
- package/pipeline/schemas/toolkit-path-params.json +84 -8
- package/pipeline/scripts/README.md +1 -0
- package/pipeline/scripts/_code-graph.mjs +184 -103
- package/pipeline/scripts/_contract-core.mjs +1 -1
- package/pipeline/scripts/_contract-routes-office.mjs +21 -0
- package/pipeline/scripts/_diff-impact.mjs +21 -2
- package/pipeline/scripts/_graph-sidecars.mjs +372 -0
- package/pipeline/scripts/_http-post.mjs +103 -115
- package/pipeline/scripts/_safe-read.mjs +57 -0
- package/pipeline/scripts/_skill-practices.mjs +26 -0
- package/pipeline/scripts/_strip-code.mjs +380 -0
- package/pipeline/scripts/activity-snapshot.mjs +13 -1
- package/pipeline/scripts/aggregate-metrics.mjs +3 -5
- package/pipeline/scripts/call-graph/index.mjs +78 -0
- package/pipeline/scripts/call-graph/lang/cpp.mjs +308 -0
- package/pipeline/scripts/call-graph/lang/csharp.mjs +130 -0
- package/pipeline/scripts/call-graph/lang/go.mjs +303 -0
- package/pipeline/scripts/call-graph/lang/java.mjs +370 -0
- package/pipeline/scripts/call-graph/lang/kotlin.mjs +397 -0
- package/pipeline/scripts/call-graph/lang/python.mjs +399 -0
- package/pipeline/scripts/call-graph/lang/rust.mjs +345 -0
- package/pipeline/scripts/call-graph/lang/shared.mjs +230 -0
- package/pipeline/scripts/call-graph/lang/swift.mjs +432 -0
- package/pipeline/scripts/call-graph/lang/typescript.mjs +692 -0
- package/pipeline/scripts/call-graph/lex.mjs +396 -0
- package/pipeline/scripts/call-graph/platform.mjs +86 -0
- package/pipeline/scripts/call-graph/profiles.mjs +89 -0
- package/pipeline/scripts/call-graph/resolve.mjs +1125 -0
- package/pipeline/scripts/call-graph/scan.mjs +267 -0
- package/pipeline/scripts/code-graph-rules/android.json +7 -2
- package/pipeline/scripts/code-graph-rules/cpp.json +99 -0
- package/pipeline/scripts/code-graph-rules/csharp.json +102 -0
- package/pipeline/scripts/code-graph-rules/go.json +2 -1
- package/pipeline/scripts/code-graph-rules/ios.json +3 -1
- package/pipeline/scripts/code-graph-rules/java.json +76 -0
- package/pipeline/scripts/code-graph-rules/node.json +7 -2
- package/pipeline/scripts/code-graph-rules/python.json +6 -2
- package/pipeline/scripts/code-graph-rules/rust.json +105 -0
- package/pipeline/scripts/contract-server.mjs +1 -0
- package/pipeline/scripts/cost-table.json +6 -5
- package/pipeline/scripts/feedback-send.mjs +26 -26
- package/pipeline/scripts/gate-ledger.mjs +2 -1
- package/pipeline/scripts/gen-usage-names.mjs +124 -0
- package/pipeline/scripts/graph-affected.mjs +109 -20
- package/pipeline/scripts/graph-build.mjs +95 -15
- package/pipeline/scripts/graph-export.mjs +272 -0
- package/pipeline/scripts/graph-hint.mjs +15 -2
- package/pipeline/scripts/graph-query.mjs +305 -26
- package/pipeline/scripts/graph-report.mjs +187 -1
- package/pipeline/scripts/health-report.mjs +3 -4
- package/pipeline/scripts/infra/docs.mjs +317 -0
- package/pipeline/scripts/infra/extract.mjs +998 -0
- package/pipeline/scripts/infra/graph.mjs +245 -0
- package/pipeline/scripts/infra/yaml-lite.mjs +311 -0
- package/pipeline/scripts/job-launch.mjs +67 -2
- package/pipeline/scripts/learning-curve.mjs +288 -178
- package/pipeline/scripts/log-metric.sh +10 -1
- package/pipeline/scripts/note-agent-event.mjs +3 -4
- package/pipeline/scripts/note-command-use.mjs +333 -0
- package/pipeline/scripts/note-command-use.sh +126 -0
- package/pipeline/scripts/note-mcp-call.sh +89 -0
- package/pipeline/scripts/note-mcp-failure.mjs +272 -1
- package/pipeline/scripts/note-session.sh +62 -3
- package/pipeline/scripts/note-skill-use.mjs +58 -2
- package/pipeline/scripts/office-build.mjs +115 -1
- package/pipeline/scripts/office-memory.mjs +14 -5
- package/pipeline/scripts/pair.mjs +333 -0
- package/pipeline/scripts/pre-push-check.sh +1 -1
- package/pipeline/scripts/remote/cbor.mjs +128 -0
- package/pipeline/scripts/remote/contract.mjs +98 -0
- package/pipeline/scripts/remote/handler.mjs +317 -0
- package/pipeline/scripts/remote/handles.mjs +57 -0
- package/pipeline/scripts/remote/lifecycle.mjs +186 -0
- package/pipeline/scripts/remote/listener.mjs +204 -0
- package/pipeline/scripts/remote/lockout.mjs +103 -0
- package/pipeline/scripts/remote/nonces.mjs +61 -0
- package/pipeline/scripts/remote/pairing.mjs +519 -0
- package/pipeline/scripts/remote/qr-encode.mjs +459 -0
- package/pipeline/scripts/remote/store.mjs +188 -0
- package/pipeline/scripts/remote/transport.mjs +211 -0
- package/pipeline/scripts/remote/verbs.json +70 -0
- package/pipeline/scripts/remote/verbs.mjs +217 -0
- package/pipeline/scripts/remote/webauthn.mjs +169 -0
- package/pipeline/scripts/remote/wire.mjs +364 -0
- package/pipeline/scripts/remote-listener.mjs +83 -0
- package/pipeline/scripts/route-learn.mjs +4 -4
- package/pipeline/scripts/run-kill.mjs +1 -1
- package/pipeline/scripts/run-write.mjs +13 -2
- package/pipeline/scripts/runs-index.mjs +30 -3
- package/pipeline/scripts/search-logs.sh +9 -0
- package/pipeline/scripts/session-brief.mjs +458 -0
- package/pipeline/scripts/session-brief.sh +130 -0
- package/pipeline/scripts/test-gap-rules/cpp.json +25 -0
- package/pipeline/scripts/test-gap-rules/csharp.json +20 -0
- package/pipeline/scripts/test-gap-rules/java.json +20 -0
- package/pipeline/scripts/test-gap-rules/rust.json +14 -0
- package/pipeline/scripts/token-budget-report.mjs +3 -2
- package/pipeline/scripts/uninstall.mjs +29 -0
- package/pipeline/scripts/usage-access.mjs +16 -31
- package/pipeline/scripts/usage-health.mjs +31 -62
- package/pipeline/scripts/usage-register-beacon.mjs +11 -22
- package/pipeline/scripts/usage-register.mjs +39 -29
- package/pipeline/scripts/usage-report.mjs +579 -178
- package/pipeline/scripts/validate-code-graph.mjs +361 -111
- package/pipeline/scripts/write-state.mjs +39 -0
- package/pipeline/skills/.skill-manifest.json +22 -18
- package/pipeline/skills/.skills-index.json +13 -2
- package/pipeline/skills/shared/README.md +5 -4
- package/pipeline/skills/shared/core/multi-agent-design-check/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-diff-explain/SKILL.md +3 -3
- package/pipeline/skills/shared/core/multi-agent-fable-status/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-graph/SKILL.md +55 -21
- package/pipeline/skills/shared/core/multi-agent-pair/SKILL.md +41 -0
- package/pipeline/skills/shared/core/multi-agent-prune-prompts/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-sync/SKILL.md +3 -3
- package/pipeline/skills/shared/external/app-store-optimization/SKILL.md +2 -3
- package/pipeline/skills/shared/external/app-store-optimization/references/keyword-research-methodology.md +2 -2
- package/pipeline/skills/shared/external/app-store-optimization/references/product-page-variants.md +2 -2
- package/pipeline/skills/shared/external/app-store-review/SKILL.md +11 -4
- package/pipeline/skills/shared/external/build-settings-audit/SKILL.md +1 -1
- package/pipeline/skills/shared/external/build-time-benchmark/SKILL.md +5 -5
- package/pipeline/skills/shared/external/build-time-fixes/SKILL.md +5 -5
- package/pipeline/skills/shared/external/build-time-optimizer/SKILL.md +6 -6
- package/pipeline/skills/shared/external/free-llm-apis/references/providers.md +1 -0
- package/pipeline/skills/shared/external/ios-coding-standard/references/STANDARD.md +2 -2
- package/pipeline/skills/shared/external/ios-haptics/references/core-haptics.md +1 -1
- package/pipeline/skills/shared/external/localization-reuse-map/references/publish-and-snapshot.md +1 -1
- package/pipeline/skills/shared/external/package-build-audit/SKILL.md +3 -3
- package/pipeline/skills/shared/external/reverse-engineer-own-app/SKILL.md +2 -3
- package/pipeline/skills/shared/external/swift-compile-hotspots/SKILL.md +2 -2
- package/pipeline/skills/shared/external/weatherkit/SKILL.md +5 -6
- package/pipeline/skills/skills-index.md +3 -2
- package/docs/FIGMA_PIPELINE.md +0 -137
- package/pipeline/lib/identifier-scan.mjs +0 -156
- package/pipeline/scripts/publish-staged.mjs +0 -324
- package/pipeline/skills/shared/external/ios-coding-standard/scripts/check_structure.py +0 -765
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file rust.mjs - Rust profile for the call-edge scanner.
|
|
3
|
+
*
|
|
4
|
+
* Methods live in `impl` blocks and attach to the implemented type; `impl Trait
|
|
5
|
+
* for Type` records the trait as a supertype of `Type`, so a call through a trait
|
|
6
|
+
* reaches the implementers. Paths (`Type::new`, `module::f`) are member steps.
|
|
7
|
+
* Not modelled: macro-generated items, closures' parameter types, trait objects
|
|
8
|
+
* behind generics, and method resolution through `Deref`.
|
|
9
|
+
*
|
|
10
|
+
* @module pipeline/scripts/call-graph/lang/rust
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { isIdent, readType as readTypeRaw, splitTop, tick, MAX_HEADER_TOKENS } from "../lex.mjs";
|
|
14
|
+
import { genericNames, typeList } from "./shared.mjs";
|
|
15
|
+
|
|
16
|
+
const WRAP = new Set(["Box", "Rc", "Arc"]);
|
|
17
|
+
const readType = (tk, i, o = {}) => readTypeRaw(tk, i, { ...o, unwrap: WRAP });
|
|
18
|
+
|
|
19
|
+
const MODS = new Set(["pub", "async", "unsafe", "const", "extern", "default"]);
|
|
20
|
+
const KEYWORDS = new Set(
|
|
21
|
+
`if else match for while loop in return break continue let mut ref fn struct enum trait impl mod use
|
|
22
|
+
pub type where as dyn move static const true false unsafe async await crate`.split(/\s+/),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
function params(tk, open) {
|
|
26
|
+
const out = [];
|
|
27
|
+
let min = 0;
|
|
28
|
+
let max = 0;
|
|
29
|
+
let hasSelf = false;
|
|
30
|
+
for (const [a, b] of splitTop(tk, open)) {
|
|
31
|
+
let k = a;
|
|
32
|
+
while (
|
|
33
|
+
tk.t[k] === "&" ||
|
|
34
|
+
tk.t[k] === "mut" ||
|
|
35
|
+
tk.t[k] === "'" ||
|
|
36
|
+
(isIdent(tk.t[k]) && tk.t[k - 1] === "'")
|
|
37
|
+
)
|
|
38
|
+
k++;
|
|
39
|
+
if (tk.t[k] === "self") {
|
|
40
|
+
hasSelf = true;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (tk.t[k] === "mut") k++;
|
|
44
|
+
if (!isIdent(tk.t[k]) || tk.t[k + 1] !== ":") continue;
|
|
45
|
+
const r = readType(tk, k + 2, { limit: b, skip: new Set(["mut", "dyn", "impl"]) });
|
|
46
|
+
out.push([tk.t[k], tk.t[k], r.name]);
|
|
47
|
+
max++;
|
|
48
|
+
min++;
|
|
49
|
+
}
|
|
50
|
+
return { params: out, min, max, hasSelf };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function parse(tk) {
|
|
54
|
+
const t = tk.t;
|
|
55
|
+
const types = [];
|
|
56
|
+
const fns = [];
|
|
57
|
+
|
|
58
|
+
const walk = (from, to, owner) => {
|
|
59
|
+
let i = from;
|
|
60
|
+
while (i < to) {
|
|
61
|
+
tick(tk);
|
|
62
|
+
const s = t[i];
|
|
63
|
+
if (s === "#") {
|
|
64
|
+
i++;
|
|
65
|
+
if (t[i] === "!") i++;
|
|
66
|
+
if (t[i] === "[" && tk.m[i] > i) i = tk.m[i] + 1;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (s === "pub" && t[i + 1] === "(" && tk.m[i + 1] > i + 1) {
|
|
70
|
+
i = tk.m[i + 1] + 1;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (
|
|
74
|
+
MODS.has(s) &&
|
|
75
|
+
(t[i + 1] === "fn" ||
|
|
76
|
+
MODS.has(t[i + 1]) ||
|
|
77
|
+
["struct", "enum", "trait", "impl", "mod", "type", "use"].includes(t[i + 1]) ||
|
|
78
|
+
s === "pub")
|
|
79
|
+
) {
|
|
80
|
+
i++;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if ((s === "struct" || s === "enum" || s === "trait" || s === "union") && isIdent(t[i + 1])) {
|
|
84
|
+
i = typeDecl(i, to);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (s === "impl") {
|
|
88
|
+
i = implDecl(i, to);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (s === "mod" && isIdent(t[i + 1]) && t[i + 2] === "{" && tk.m[i + 2] > i + 2) {
|
|
92
|
+
walk(i + 3, tk.m[i + 2], null);
|
|
93
|
+
i = tk.m[i + 2] + 1;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (s === "fn" && isIdent(t[i + 1])) {
|
|
97
|
+
i = fnDecl(i, to, owner);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (s === "{" && tk.m[i] > i) {
|
|
101
|
+
i = tk.m[i] + 1;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
i++;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const typeDecl = (i, to) => {
|
|
109
|
+
const kw = t[i];
|
|
110
|
+
const name = t[i + 1];
|
|
111
|
+
let j = i + 2;
|
|
112
|
+
const g = genericNames(tk, j);
|
|
113
|
+
j = g.next;
|
|
114
|
+
const sup = [];
|
|
115
|
+
const lim = Math.min(to, j + MAX_HEADER_TOKENS);
|
|
116
|
+
if (t[j] === ":" && kw === "trait") {
|
|
117
|
+
let k = j + 1;
|
|
118
|
+
while (k < lim && t[k] !== "{" && t[k] !== "where") k++;
|
|
119
|
+
sup.push(...typeList(tk, j + 1, k, new Set(["?", "'static"])));
|
|
120
|
+
j = k;
|
|
121
|
+
}
|
|
122
|
+
while (j < lim && t[j] !== "{" && t[j] !== ";" && !(t[j] === "(" && kw === "struct")) j++;
|
|
123
|
+
const f = {};
|
|
124
|
+
let end = tk.line[i];
|
|
125
|
+
let body = null;
|
|
126
|
+
if (t[j] === "{" && tk.m[j] > j) {
|
|
127
|
+
body = j;
|
|
128
|
+
end = tk.line[tk.m[j]];
|
|
129
|
+
if (kw === "struct") {
|
|
130
|
+
for (const [a, b] of splitTop(tk, j)) {
|
|
131
|
+
let k = a;
|
|
132
|
+
while (t[k] === "#") k = tk.m[k + 1] > 0 ? tk.m[k + 1] + 1 : k + 2;
|
|
133
|
+
if (t[k] === "pub") k++;
|
|
134
|
+
if (t[k] === "(") k = tk.m[k] + 1;
|
|
135
|
+
if (isIdent(t[k]) && t[k + 1] === ":") {
|
|
136
|
+
const r = readType(tk, k + 2, { limit: b, skip: new Set(["mut", "dyn"]) });
|
|
137
|
+
if (r.name) f[t[k]] = r.name;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
} else if (t[j] === "(" && tk.m[j] > j) {
|
|
142
|
+
j = tk.m[j] + 1;
|
|
143
|
+
}
|
|
144
|
+
types.push({
|
|
145
|
+
n: name,
|
|
146
|
+
k: kw === "trait" ? "trait" : kw,
|
|
147
|
+
line: tk.line[i],
|
|
148
|
+
end,
|
|
149
|
+
sup,
|
|
150
|
+
...(g.gen.length ? { gen: g.gen } : {}),
|
|
151
|
+
f,
|
|
152
|
+
});
|
|
153
|
+
if (body !== null && kw === "trait") {
|
|
154
|
+
walk(body + 1, tk.m[body], name);
|
|
155
|
+
return tk.m[body] + 1;
|
|
156
|
+
}
|
|
157
|
+
return body !== null ? tk.m[body] + 1 : j + 1;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const implDecl = (i, to) => {
|
|
161
|
+
let j = i + 1;
|
|
162
|
+
const g = genericNames(tk, j);
|
|
163
|
+
j = g.next;
|
|
164
|
+
let k = j;
|
|
165
|
+
const lim = Math.min(to, j + MAX_HEADER_TOKENS);
|
|
166
|
+
while (k < lim && t[k] !== "{" && t[k] !== "where") k = tk.m[k] > k ? tk.m[k] + 1 : k + 1;
|
|
167
|
+
const first = readType(tk, j, { limit: k, skip: new Set(["!", "dyn"]) });
|
|
168
|
+
let target = first.name;
|
|
169
|
+
let trait = null;
|
|
170
|
+
if (t[first.next] === "for") {
|
|
171
|
+
trait = first.name;
|
|
172
|
+
target = readType(tk, first.next + 1, { limit: k, skip: new Set(["dyn"]) }).name;
|
|
173
|
+
}
|
|
174
|
+
while (k < lim && t[k] !== "{") k++;
|
|
175
|
+
if (!target || t[k] !== "{" || tk.m[k] < 0) return i + 1;
|
|
176
|
+
types.push({
|
|
177
|
+
n: target,
|
|
178
|
+
k: "ext",
|
|
179
|
+
line: tk.line[i],
|
|
180
|
+
end: tk.line[tk.m[k]],
|
|
181
|
+
sup: trait ? [trait] : [],
|
|
182
|
+
f: {},
|
|
183
|
+
...(g.gen.length ? { gen: g.gen } : {}),
|
|
184
|
+
});
|
|
185
|
+
walk(k + 1, tk.m[k], target);
|
|
186
|
+
return tk.m[k] + 1;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const fnDecl = (i, to, owner) => {
|
|
190
|
+
const name = t[i + 1];
|
|
191
|
+
let j = i + 2;
|
|
192
|
+
const g = genericNames(tk, j);
|
|
193
|
+
j = g.next;
|
|
194
|
+
if (t[j] !== "(" || tk.m[j] < 0) return i + 1;
|
|
195
|
+
const sig = params(tk, j);
|
|
196
|
+
j = tk.m[j] + 1;
|
|
197
|
+
let ret = null;
|
|
198
|
+
if (t[j] === "->") {
|
|
199
|
+
const r = readType(tk, j + 1, { limit: to, skip: new Set(["mut", "dyn", "impl"]) });
|
|
200
|
+
ret = r.name;
|
|
201
|
+
j = r.next;
|
|
202
|
+
}
|
|
203
|
+
const sigLim = Math.min(to, j + MAX_HEADER_TOKENS);
|
|
204
|
+
while (j < sigLim && t[j] !== "{" && t[j] !== ";") j = tk.m[j] > j ? tk.m[j] + 1 : j + 1;
|
|
205
|
+
const body = t[j] === "{" && tk.m[j] > j ? [j + 1, tk.m[j]] : null;
|
|
206
|
+
fns.push({
|
|
207
|
+
n: name,
|
|
208
|
+
o: owner,
|
|
209
|
+
a: [sig.min, sig.max],
|
|
210
|
+
p: sig.params,
|
|
211
|
+
r: ret === "Self" && owner ? owner : ret,
|
|
212
|
+
l: tk.line[i],
|
|
213
|
+
e: tk.line[body ? body[1] : i],
|
|
214
|
+
...(owner && !sig.hasSelf ? { s: 1 } : {}),
|
|
215
|
+
...(!body ? { ab: 1 } : {}),
|
|
216
|
+
...(g.gen.length ? { g: g.gen } : {}),
|
|
217
|
+
body,
|
|
218
|
+
});
|
|
219
|
+
return body ? body[1] + 1 : j + 1;
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
walk(0, tk.n, null);
|
|
223
|
+
return { types, fns, binds: [] };
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function localDecl(tk, i, end) {
|
|
227
|
+
const t = tk.t;
|
|
228
|
+
if (t[i] === "fn" && isIdent(t[i + 1]))
|
|
229
|
+
return { name: t[i + 1], type: null, init: null, next: i + 2 };
|
|
230
|
+
if (t[i] === "let") {
|
|
231
|
+
let j = i + 1;
|
|
232
|
+
if (t[j] === "mut") j++;
|
|
233
|
+
if (t[j] === "(") {
|
|
234
|
+
const names = [];
|
|
235
|
+
for (let k = j + 1; k < tk.m[j]; k++) if (isIdent(t[k]) && t[k] !== "mut") names.push(t[k]);
|
|
236
|
+
const after = tk.m[j] + 1;
|
|
237
|
+
return {
|
|
238
|
+
name: names[0] || "_",
|
|
239
|
+
also: names.slice(1),
|
|
240
|
+
type: null,
|
|
241
|
+
init: t[after] === "=" ? after + 1 : null,
|
|
242
|
+
next: after,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
if (!isIdent(t[j])) return null;
|
|
246
|
+
if (t[j + 1] === "(" || t[j + 1] === "::" || t[j + 1] === "{") return null;
|
|
247
|
+
const name = t[j];
|
|
248
|
+
j++;
|
|
249
|
+
let type = null;
|
|
250
|
+
if (t[j] === ":") {
|
|
251
|
+
const r = readType(tk, j + 1, { limit: end, skip: new Set(["mut", "dyn", "impl"]) });
|
|
252
|
+
type = r.name;
|
|
253
|
+
j = r.next;
|
|
254
|
+
}
|
|
255
|
+
if (t[j] === "=") return { name, type, init: j + 1, next: j + 1 };
|
|
256
|
+
return type ? { name, type, init: null, next: j } : null;
|
|
257
|
+
}
|
|
258
|
+
if (t[i] === "for" && isIdent(t[i + 1])) {
|
|
259
|
+
let k = i + 1;
|
|
260
|
+
while (k < end && t[k] !== "in") k++;
|
|
261
|
+
return { name: t[i + 1], type: null, init: null, next: i + 1 };
|
|
262
|
+
}
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function binds(text) {
|
|
267
|
+
const out = [];
|
|
268
|
+
for (const m of text.matchAll(
|
|
269
|
+
/^[ \t]*(?:pub(?:\([^)\n]{0,60}\))?[ \t]+)?use[ \t]+([^;]{1,3000});/gm,
|
|
270
|
+
)) {
|
|
271
|
+
const body = m[1].replace(/\s+/g, " ").trim();
|
|
272
|
+
const expand = (prefix, spec) => {
|
|
273
|
+
const brace = spec.indexOf("{");
|
|
274
|
+
if (brace < 0) {
|
|
275
|
+
const [path, alias] = spec.split(/\s+as\s+/);
|
|
276
|
+
const segs = path.trim().split("::");
|
|
277
|
+
const last = segs.pop();
|
|
278
|
+
const base = [prefix, ...segs].filter(Boolean).join("::");
|
|
279
|
+
if (last === "self") out.push({ l: alias || segs[segs.length - 1], m: base, x: null });
|
|
280
|
+
else
|
|
281
|
+
out.push({
|
|
282
|
+
l: alias || last,
|
|
283
|
+
m: base,
|
|
284
|
+
x: last,
|
|
285
|
+
alt: [base, last].filter(Boolean).join("::"),
|
|
286
|
+
});
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const head = spec.slice(0, brace).replace(/::$/, "");
|
|
290
|
+
const inner = spec.slice(brace + 1, spec.lastIndexOf("}"));
|
|
291
|
+
let depth = 0;
|
|
292
|
+
let cur = "";
|
|
293
|
+
const parts = [];
|
|
294
|
+
for (const ch of inner) {
|
|
295
|
+
if (ch === "{") depth++;
|
|
296
|
+
if (ch === "}") depth--;
|
|
297
|
+
if (ch === "," && depth === 0) {
|
|
298
|
+
parts.push(cur);
|
|
299
|
+
cur = "";
|
|
300
|
+
} else cur += ch;
|
|
301
|
+
}
|
|
302
|
+
if (cur.trim()) parts.push(cur);
|
|
303
|
+
for (const p of parts) expand([prefix, head].filter(Boolean).join("::"), p.trim());
|
|
304
|
+
};
|
|
305
|
+
expand("", body);
|
|
306
|
+
}
|
|
307
|
+
return out;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function moduleSuffixes(spec, fromPath) {
|
|
311
|
+
const segs = spec.split("::").filter((s) => s && s !== "crate" && s !== "self");
|
|
312
|
+
let dir = null;
|
|
313
|
+
const up = spec.split("::").filter((s) => s === "super").length;
|
|
314
|
+
if (up) {
|
|
315
|
+
const parts = fromPath.split("/").slice(0, -1);
|
|
316
|
+
for (let n = 0; n < up; n++) parts.pop();
|
|
317
|
+
dir = parts.join("/");
|
|
318
|
+
}
|
|
319
|
+
const rel = segs.filter((s) => s !== "super").join("/");
|
|
320
|
+
if (!rel) return [];
|
|
321
|
+
const stem = dir !== null ? `${dir}/${rel}` : rel;
|
|
322
|
+
return [`${stem}.rs`, `${stem}/mod.rs`];
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export default {
|
|
326
|
+
id: "rust",
|
|
327
|
+
stringType: "str",
|
|
328
|
+
exts: [".rs"],
|
|
329
|
+
implicitSelf: false,
|
|
330
|
+
initName: "new",
|
|
331
|
+
selfWords: new Set(["self", "Self"]),
|
|
332
|
+
superWords: new Set(),
|
|
333
|
+
newKeyword: null,
|
|
334
|
+
memberOps: new Set([".", "::", "?."]),
|
|
335
|
+
labelOps: [],
|
|
336
|
+
genericCalls: true,
|
|
337
|
+
keywords: KEYWORDS,
|
|
338
|
+
declWords: new Set(["fn", "struct", "enum", "trait", "impl", "mod", "use", "type", "let"]),
|
|
339
|
+
condWords: null,
|
|
340
|
+
prepare: (text) => text.replace(/'(?:\\.[^']*|[^'\\\n])'/g, (m) => "0".padEnd(m.length, " ")),
|
|
341
|
+
parse,
|
|
342
|
+
localDecl,
|
|
343
|
+
binds,
|
|
344
|
+
moduleSuffixes,
|
|
345
|
+
};
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file shared.mjs - declaration helpers the language profiles have in common.
|
|
3
|
+
*
|
|
4
|
+
* @module pipeline/scripts/call-graph/lang/shared
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { isIdent, readType, skipAngles, splitTop } from "../lex.mjs";
|
|
8
|
+
|
|
9
|
+
/** Names introduced by a `<T, U : Bound>` list at i, and the index after it. */
|
|
10
|
+
export function genericNames(tk, i) {
|
|
11
|
+
if (tk.t[i] !== "<") return { gen: [], next: i };
|
|
12
|
+
const after = skipAngles(tk, i);
|
|
13
|
+
if (after === i) return { gen: [], next: i };
|
|
14
|
+
const gen = [];
|
|
15
|
+
for (let j = i + 1; j < after - 1; j++) {
|
|
16
|
+
if (isIdent(tk.t[j]) && (tk.t[j - 1] === "<" || tk.t[j - 1] === ",")) gen.push(tk.t[j]);
|
|
17
|
+
else if (tk.t[j] === "(" || tk.t[j] === "[") j = Math.max(j, tk.m[j]);
|
|
18
|
+
}
|
|
19
|
+
return { gen, next: after };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Skip `@Name`, `@a.b.Name(args)` annotations starting at i. */
|
|
23
|
+
export function skipAnnotations(tk, i) {
|
|
24
|
+
let j = i;
|
|
25
|
+
while (tk.t[j] === "@" && isIdent(tk.t[j + 1])) {
|
|
26
|
+
j += 2;
|
|
27
|
+
while (tk.t[j] === "." && isIdent(tk.t[j + 1])) j += 2;
|
|
28
|
+
if (tk.t[j] === "(" && tk.m[j] > j) j = tk.m[j] + 1;
|
|
29
|
+
}
|
|
30
|
+
return j;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The names in a comma-separated list of types: `A, B<X>, c.D`.
|
|
35
|
+
*
|
|
36
|
+
* @param {object} tk
|
|
37
|
+
* @param {number} i - first token
|
|
38
|
+
* @param {number} limit - exclusive bound
|
|
39
|
+
* @param {Set<string>} [skip] - leading words to ignore (`public`, `virtual`)
|
|
40
|
+
*/
|
|
41
|
+
export function typeList(tk, i, limit, skip = new Set()) {
|
|
42
|
+
const names = [];
|
|
43
|
+
let j = i;
|
|
44
|
+
while (j < limit) {
|
|
45
|
+
while (j < limit && skip.has(tk.t[j])) j++;
|
|
46
|
+
const r = readType(tk, j, { limit });
|
|
47
|
+
if (r.name) names.push(r.name);
|
|
48
|
+
j = Math.max(r.next, j + 1);
|
|
49
|
+
while (j < limit && tk.t[j] !== ",") j = tk.m[j] > j ? tk.m[j] + 1 : j + 1;
|
|
50
|
+
if (tk.t[j] === ",") j++;
|
|
51
|
+
}
|
|
52
|
+
return names;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* End (exclusive) of an expression body that starts at i and runs to the end
|
|
57
|
+
* of the statement: a `;`, or a line break at bracket depth 0 that does not
|
|
58
|
+
* continue the expression.
|
|
59
|
+
*/
|
|
60
|
+
export function exprEnd(tk, i, limit) {
|
|
61
|
+
const base = tk.dep[i];
|
|
62
|
+
let j = i;
|
|
63
|
+
while (j < limit) {
|
|
64
|
+
if (tk.dep[j] === base && j > i) {
|
|
65
|
+
const s = tk.t[j];
|
|
66
|
+
if (s === ";") return j;
|
|
67
|
+
if ((s === "}" || s === ")" || s === "]") && tk.m[j] < i) return j;
|
|
68
|
+
if (tk.first[j] === 1) {
|
|
69
|
+
const prev = tk.t[j - 1];
|
|
70
|
+
const continues =
|
|
71
|
+
[
|
|
72
|
+
".",
|
|
73
|
+
"?.",
|
|
74
|
+
"!.",
|
|
75
|
+
"+",
|
|
76
|
+
"-",
|
|
77
|
+
"*",
|
|
78
|
+
"/",
|
|
79
|
+
"&&",
|
|
80
|
+
"||",
|
|
81
|
+
"?",
|
|
82
|
+
":",
|
|
83
|
+
"=",
|
|
84
|
+
",",
|
|
85
|
+
"(",
|
|
86
|
+
"[",
|
|
87
|
+
"{",
|
|
88
|
+
"->",
|
|
89
|
+
"=>",
|
|
90
|
+
].includes(prev) ||
|
|
91
|
+
[".", "?.", "&&", "||", "?", ":", "+", "-", "*", "/", "|>", "=>"].includes(s);
|
|
92
|
+
if (!continues) return j;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
j++;
|
|
96
|
+
}
|
|
97
|
+
return limit;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The names a destructuring pattern at `open` binds: `{ a, b: c, d = 1, ...e }`
|
|
102
|
+
* binds a, c, d and e. A default value is skipped, a key that is renamed is not
|
|
103
|
+
* a binding.
|
|
104
|
+
*/
|
|
105
|
+
export function patternNames(tk, open, close) {
|
|
106
|
+
const names = [];
|
|
107
|
+
for (let j = open + 1; j < close; j++) {
|
|
108
|
+
const t = tk.t[j];
|
|
109
|
+
if (t === "=") {
|
|
110
|
+
while (j < close && tk.t[j] !== ",") j = tk.m[j] > j ? tk.m[j] + 1 : j + 1;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (!isIdent(t) || tk.t[j + 1] === ":") continue;
|
|
114
|
+
const prev = tk.t[j - 1];
|
|
115
|
+
if (prev === "{" || prev === "[" || prev === "," || prev === ":" || prev === "...")
|
|
116
|
+
names.push(t);
|
|
117
|
+
}
|
|
118
|
+
return names;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** `name: Type` / `Type name` parameter lists, split into [label, name, type] with arity. */
|
|
122
|
+
export function paramsColon(tk, open, opts = {}) {
|
|
123
|
+
const params = [];
|
|
124
|
+
let min = 0;
|
|
125
|
+
let max = 0;
|
|
126
|
+
for (const [a, b] of splitTop(tk, open)) {
|
|
127
|
+
let k = a;
|
|
128
|
+
k = skipAnnotations(tk, k);
|
|
129
|
+
let variadic = false;
|
|
130
|
+
while (opts.mods?.has(tk.t[k])) {
|
|
131
|
+
if (tk.t[k] === "vararg") variadic = true;
|
|
132
|
+
k++;
|
|
133
|
+
}
|
|
134
|
+
if (tk.t[k] === "..." || tk.t[k] === "*" || tk.t[k] === "**") {
|
|
135
|
+
variadic = true;
|
|
136
|
+
k++;
|
|
137
|
+
}
|
|
138
|
+
if (tk.t[k] === "val" || tk.t[k] === "var") k++;
|
|
139
|
+
let name;
|
|
140
|
+
if (tk.t[k] === "{" || tk.t[k] === "[") {
|
|
141
|
+
const close = tk.m[k] > k ? tk.m[k] : b;
|
|
142
|
+
for (const bound of patternNames(tk, k, close)) params.push([bound, bound, null]);
|
|
143
|
+
name = "_";
|
|
144
|
+
k = close + 1;
|
|
145
|
+
} else {
|
|
146
|
+
if (!isIdent(tk.t[k])) continue;
|
|
147
|
+
name = tk.t[k];
|
|
148
|
+
k++;
|
|
149
|
+
}
|
|
150
|
+
if (tk.t[k] === "?") k++;
|
|
151
|
+
let type = null;
|
|
152
|
+
if (tk.t[k] === ":") {
|
|
153
|
+
const r = readType(tk, k + 1, { limit: b, union: opts.union, skip: opts.skip });
|
|
154
|
+
type = r.name;
|
|
155
|
+
k = r.next;
|
|
156
|
+
if (tk.t[k] === "...") {
|
|
157
|
+
variadic = true;
|
|
158
|
+
k++;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
let hasDefault = false;
|
|
162
|
+
for (let z = k; z < b; z++) if (tk.t[z] === "=") hasDefault = true;
|
|
163
|
+
params.push([name, name, type]);
|
|
164
|
+
if (variadic) max = Infinity;
|
|
165
|
+
else if (max !== Infinity) max++;
|
|
166
|
+
if (!hasDefault && !variadic && !(opts.optional && tk.t[k - 1] === "?")) min++;
|
|
167
|
+
}
|
|
168
|
+
return { params, min, max };
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** `Type name` parameter lists (Java, C#, C++), split with arity. */
|
|
172
|
+
export function paramsTypeFirst(tk, open, opts = {}) {
|
|
173
|
+
const params = [];
|
|
174
|
+
let min = 0;
|
|
175
|
+
let max = 0;
|
|
176
|
+
for (const [a, b] of splitTop(tk, open)) {
|
|
177
|
+
let k = skipAnnotations(tk, a);
|
|
178
|
+
let variadic = false;
|
|
179
|
+
while (opts.mods?.has(tk.t[k])) {
|
|
180
|
+
if (tk.t[k] === "params") variadic = true;
|
|
181
|
+
k++;
|
|
182
|
+
}
|
|
183
|
+
const r = readType(tk, k, { limit: b, skip: opts.skip });
|
|
184
|
+
let q = r.next;
|
|
185
|
+
if (tk.t[q] === "...") {
|
|
186
|
+
variadic = true;
|
|
187
|
+
q++;
|
|
188
|
+
}
|
|
189
|
+
while (tk.t[q] === "&" || tk.t[q] === "*" || tk.t[q] === "&&") q++;
|
|
190
|
+
const name = isIdent(tk.t[q]) && q < b ? tk.t[q] : null;
|
|
191
|
+
if (!r.name && !name) continue;
|
|
192
|
+
let hasDefault = false;
|
|
193
|
+
for (let z = q; z < b; z++) if (tk.t[z] === "=") hasDefault = true;
|
|
194
|
+
params.push([name, name || "_", r.name]);
|
|
195
|
+
if (variadic) max = Infinity;
|
|
196
|
+
else if (max !== Infinity) max++;
|
|
197
|
+
if (!hasDefault && !variadic) min++;
|
|
198
|
+
}
|
|
199
|
+
return { params, min, max };
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Token ranges of top-level statements: everything outside the given spans, cut
|
|
204
|
+
* at statement starts, without import and export-from lines.
|
|
205
|
+
*
|
|
206
|
+
* @param {Array<[number, number]>} spans - declarations already read
|
|
207
|
+
* @param {number} n - token count
|
|
208
|
+
* @param {object} tk
|
|
209
|
+
* @returns {Array<[number, number]>}
|
|
210
|
+
*/
|
|
211
|
+
export function complement(spans, n, tk) {
|
|
212
|
+
const out = [];
|
|
213
|
+
const sorted = [...spans].sort((a, b) => a[0] - b[0]);
|
|
214
|
+
let at = 0;
|
|
215
|
+
const push = (from, to) => {
|
|
216
|
+
if (to - from < 3) return;
|
|
217
|
+
if (
|
|
218
|
+
tk.t[from] === "import" ||
|
|
219
|
+
(tk.t[from] === "export" && tk.t.slice(from, to).includes("from"))
|
|
220
|
+
)
|
|
221
|
+
return;
|
|
222
|
+
out.push([from, to]);
|
|
223
|
+
};
|
|
224
|
+
for (const [a, b] of sorted) {
|
|
225
|
+
if (a > at) push(at, a);
|
|
226
|
+
at = Math.max(at, b);
|
|
227
|
+
}
|
|
228
|
+
if (at < n) push(at, n);
|
|
229
|
+
return out;
|
|
230
|
+
}
|