@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.
- package/CHANGELOG.md +44 -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 +5 -5
- 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 +223 -155
- 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/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/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 +3 -3
- 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 +6 -4
- 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/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 +2 -0
- 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/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/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 +21 -17
- 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-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,396 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file lex.mjs - tokeniser and bracket matcher for the call-edge scanner.
|
|
3
|
+
*
|
|
4
|
+
* Input is source text whose comments and string bodies are already blanked
|
|
5
|
+
* (see stripCode in _code-graph.mjs), so every token left is code. The scanner
|
|
6
|
+
* is deliberately not a grammar: it needs identifiers, punctuation, line
|
|
7
|
+
* numbers and a bracket map, and it must stay linear in the file size.
|
|
8
|
+
*
|
|
9
|
+
* Source files are untrusted input. A file over MAX_FILE_BYTES, one with a NUL
|
|
10
|
+
* byte, one that looks minified (a very long line) and one that yields more than
|
|
11
|
+
* MAX_TOKENS tokens is refused with a reason rather than analysed, and the
|
|
12
|
+
* bracket matcher bails out on an unbalanced file instead of guessing.
|
|
13
|
+
*
|
|
14
|
+
* Zero runtime dependencies (ADR-0004).
|
|
15
|
+
*
|
|
16
|
+
* @module pipeline/scripts/call-graph/lex
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export const MAX_FILE_BYTES = 1_500_000;
|
|
20
|
+
export const MAX_TOKENS = 400_000;
|
|
21
|
+
export const MAX_LINE_CHARS = 4_000;
|
|
22
|
+
export const MAX_NESTING = 400;
|
|
23
|
+
export const MAX_FILE_MS = 2500;
|
|
24
|
+
|
|
25
|
+
/** Longest run of tokens a declaration header (name, generics, supertypes) may span. */
|
|
26
|
+
export const MAX_HEADER_TOKENS = 600;
|
|
27
|
+
|
|
28
|
+
/** Thrown when a file's analysis outlasts its time budget. */
|
|
29
|
+
export class BudgetError extends Error {}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Count one unit of work against the file's time budget. Called from the loops
|
|
33
|
+
* of the scanner and the language readers, so a file built to make some loop
|
|
34
|
+
* slow is abandoned with a recorded reason instead of stalling the build.
|
|
35
|
+
*/
|
|
36
|
+
export function tick(tk) {
|
|
37
|
+
const budget = tk.budget;
|
|
38
|
+
if ((++budget.ticks & 255) === 0 && performance.now() > budget.until) throw new BudgetError();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const TWO_CHAR = new Set([
|
|
42
|
+
"?.",
|
|
43
|
+
"!.",
|
|
44
|
+
"::",
|
|
45
|
+
"->",
|
|
46
|
+
"=>",
|
|
47
|
+
"==",
|
|
48
|
+
"!=",
|
|
49
|
+
"<=",
|
|
50
|
+
">=",
|
|
51
|
+
"&&",
|
|
52
|
+
"||",
|
|
53
|
+
"..",
|
|
54
|
+
"++",
|
|
55
|
+
"--",
|
|
56
|
+
":=",
|
|
57
|
+
"+=",
|
|
58
|
+
"-=",
|
|
59
|
+
"*=",
|
|
60
|
+
"/=",
|
|
61
|
+
"%=",
|
|
62
|
+
"&=",
|
|
63
|
+
"|=",
|
|
64
|
+
"^=",
|
|
65
|
+
]);
|
|
66
|
+
|
|
67
|
+
/** Letters, underscore, dollar and anything outside ASCII; digits cannot start an identifier. */
|
|
68
|
+
const identStart = (c) =>
|
|
69
|
+
(c >= 97 && c <= 122) || (c >= 65 && c <= 90) || c === 95 || c === 36 || c > 127;
|
|
70
|
+
const identPart = (c) => identStart(c) || (c >= 48 && c <= 57);
|
|
71
|
+
|
|
72
|
+
const OPEN = new Map([
|
|
73
|
+
["(", ")"],
|
|
74
|
+
["[", "]"],
|
|
75
|
+
["{", "}"],
|
|
76
|
+
]);
|
|
77
|
+
const CLOSERS = new Set([")", "]", "}"]);
|
|
78
|
+
const DIRECTIVE_RE = /#[ \t]*([A-Za-z_]+)/y;
|
|
79
|
+
const BRANCH_WORDS = new Set(["if", "ifdef", "ifndef", "else", "elif", "elseif", "endif"]);
|
|
80
|
+
const SKIPPED_DIRECTIVES = new Set([
|
|
81
|
+
"region",
|
|
82
|
+
"endregion",
|
|
83
|
+
"pragma",
|
|
84
|
+
"define",
|
|
85
|
+
"undef",
|
|
86
|
+
"line",
|
|
87
|
+
"error",
|
|
88
|
+
"warning",
|
|
89
|
+
"include",
|
|
90
|
+
"include_next",
|
|
91
|
+
"import",
|
|
92
|
+
"nullable",
|
|
93
|
+
"sourceLocation",
|
|
94
|
+
]);
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Why a file must not be analysed, or null when it may be.
|
|
98
|
+
*
|
|
99
|
+
* @param {string} text - raw source
|
|
100
|
+
* @returns {string|null}
|
|
101
|
+
*/
|
|
102
|
+
export function refusal(text) {
|
|
103
|
+
if (text.length > MAX_FILE_BYTES) return "too-large";
|
|
104
|
+
if (text.includes("\0")) return "binary";
|
|
105
|
+
let lineStart = 0;
|
|
106
|
+
for (let i = 0; i <= text.length; i++) {
|
|
107
|
+
if (i === text.length || text.charCodeAt(i) === 10) {
|
|
108
|
+
if (i - lineStart > MAX_LINE_CHARS) return "minified";
|
|
109
|
+
lineStart = i + 1;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Tokenise stripped source.
|
|
117
|
+
*
|
|
118
|
+
* @param {string} text - comments and strings already blanked
|
|
119
|
+
* @param {number} [budgetMs] - time the analysis of this file may take
|
|
120
|
+
* @returns {{t: string[], line: Int32Array, first: Uint8Array, col: Uint16Array, m: Int32Array, n: number}|{skipped: string}}
|
|
121
|
+
* `{skipped}` names why the file is not analysed: more than MAX_TOKENS tokens, brackets nested
|
|
122
|
+
* past MAX_NESTING, or brackets that do not balance
|
|
123
|
+
*/
|
|
124
|
+
export function tokenize(text, budgetMs = MAX_FILE_MS) {
|
|
125
|
+
const t = [];
|
|
126
|
+
const directives = [];
|
|
127
|
+
const lines = [];
|
|
128
|
+
const first = [];
|
|
129
|
+
const cols = [];
|
|
130
|
+
const depths = [];
|
|
131
|
+
let depth = 0;
|
|
132
|
+
let line = 1;
|
|
133
|
+
let lineStart = 0;
|
|
134
|
+
let lastLine = 0;
|
|
135
|
+
let pos = 0;
|
|
136
|
+
const n = text.length;
|
|
137
|
+
while (pos < n) {
|
|
138
|
+
const c = text.charCodeAt(pos);
|
|
139
|
+
if (c === 10) {
|
|
140
|
+
line++;
|
|
141
|
+
pos++;
|
|
142
|
+
lineStart = pos;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (c === 32 || c === 9 || c === 13) {
|
|
146
|
+
pos++;
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
if (c === 35 && line !== lastLine) {
|
|
150
|
+
DIRECTIVE_RE.lastIndex = pos;
|
|
151
|
+
const d = DIRECTIVE_RE.exec(text);
|
|
152
|
+
if (d && (BRANCH_WORDS.has(d[1]) || SKIPPED_DIRECTIVES.has(d[1]))) {
|
|
153
|
+
if (BRANCH_WORDS.has(d[1])) directives.push([t.length, d[1]]);
|
|
154
|
+
const eol = text.indexOf("\n", pos);
|
|
155
|
+
pos = eol === -1 ? n : eol;
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
let end = pos + 1;
|
|
160
|
+
if (identStart(c)) {
|
|
161
|
+
while (end < n && identPart(text.charCodeAt(end))) end++;
|
|
162
|
+
} else if (c >= 48 && c <= 57) {
|
|
163
|
+
while (end < n) {
|
|
164
|
+
const d = text.charCodeAt(end);
|
|
165
|
+
if (!identPart(d) && d !== 46) break;
|
|
166
|
+
end++;
|
|
167
|
+
}
|
|
168
|
+
} else if (end < n) {
|
|
169
|
+
if (c === 46 && text.startsWith("...", pos)) end = pos + 3;
|
|
170
|
+
else if (TWO_CHAR.has(text.slice(pos, pos + 2))) end = pos + 2;
|
|
171
|
+
}
|
|
172
|
+
if (t.length >= MAX_TOKENS) return { skipped: "too-many-tokens" };
|
|
173
|
+
const tok = text.slice(pos, end);
|
|
174
|
+
t.push(tok);
|
|
175
|
+
lines.push(line);
|
|
176
|
+
first.push(line !== lastLine ? 1 : 0);
|
|
177
|
+
cols.push(Math.min(pos - lineStart, 65535));
|
|
178
|
+
if (c === 41 || c === 93 || c === 125) {
|
|
179
|
+
if (depth > 0) depth--;
|
|
180
|
+
}
|
|
181
|
+
depths.push(depth);
|
|
182
|
+
if (c === 40 || c === 91 || c === 123) depth++;
|
|
183
|
+
lastLine = line;
|
|
184
|
+
pos = end;
|
|
185
|
+
}
|
|
186
|
+
const match = new Int32Array(t.length).fill(-1);
|
|
187
|
+
const stack = [];
|
|
188
|
+
const branches = [];
|
|
189
|
+
let next = 0;
|
|
190
|
+
const applyDirectives = (upTo) => {
|
|
191
|
+
while (next < directives.length && directives[next][0] <= upTo) {
|
|
192
|
+
const [at, word] = directives[next++];
|
|
193
|
+
// Each branch of a conditional is analysed against the brackets open where
|
|
194
|
+
// the conditional began, so a brace in `#if` and another in `#else` do not
|
|
195
|
+
// both stay open.
|
|
196
|
+
if (word === "if" || word === "ifdef" || word === "ifndef")
|
|
197
|
+
branches.push(branches.length < MAX_NESTING ? stack.slice() : null);
|
|
198
|
+
else if (word === "endif") branches.pop();
|
|
199
|
+
else {
|
|
200
|
+
const saved = branches[branches.length - 1];
|
|
201
|
+
if (!saved) continue;
|
|
202
|
+
const kept = new Set(saved);
|
|
203
|
+
for (const open of stack) if (!kept.has(open)) match[open] = Math.min(at, t.length - 1);
|
|
204
|
+
stack.length = 0;
|
|
205
|
+
for (const open of saved) stack.push(open);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
for (let i = 0; i < t.length; i++) {
|
|
210
|
+
applyDirectives(i);
|
|
211
|
+
const tok = t[i];
|
|
212
|
+
if (OPEN.has(tok)) {
|
|
213
|
+
if (stack.length >= MAX_NESTING) return { skipped: "too-deeply-nested" };
|
|
214
|
+
stack.push(i);
|
|
215
|
+
} else if (CLOSERS.has(tok)) {
|
|
216
|
+
const open = stack.pop();
|
|
217
|
+
if (open === undefined || OPEN.get(t[open]) !== tok)
|
|
218
|
+
return { skipped: "unbalanced-brackets" };
|
|
219
|
+
match[open] = i;
|
|
220
|
+
match[i] = open;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
applyDirectives(t.length);
|
|
224
|
+
if (stack.length) return { skipped: "unbalanced-brackets" };
|
|
225
|
+
return {
|
|
226
|
+
budget: { until: performance.now() + budgetMs, ticks: 0 },
|
|
227
|
+
t,
|
|
228
|
+
line: Int32Array.from(lines),
|
|
229
|
+
first: Uint8Array.from(first),
|
|
230
|
+
col: Uint16Array.from(cols),
|
|
231
|
+
dep: Uint16Array.from(depths),
|
|
232
|
+
m: match,
|
|
233
|
+
n: t.length,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export const isIdent = (s) => s !== undefined && s.length > 0 && identStart(s.charCodeAt(0));
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Skip a balanced `<...>` generic argument list starting at index i, or return
|
|
241
|
+
* i unchanged when it does not look like one. A `<` followed by something that
|
|
242
|
+
* cannot sit in a type argument list (a literal, an operator) is a comparison.
|
|
243
|
+
*
|
|
244
|
+
* @returns {number} index just past the closing `>`, or i
|
|
245
|
+
*/
|
|
246
|
+
export function skipAngles(tk, i, limit = tk.n) {
|
|
247
|
+
if (tk.t[i] !== "<") return i;
|
|
248
|
+
let depth = 0;
|
|
249
|
+
const end = Math.min(limit, i + 200);
|
|
250
|
+
for (let j = i; j < end; j++) {
|
|
251
|
+
tick(tk);
|
|
252
|
+
const s = tk.t[j];
|
|
253
|
+
if (s === "<") depth++;
|
|
254
|
+
else if (s === ">") {
|
|
255
|
+
depth--;
|
|
256
|
+
if (depth === 0) return j + 1;
|
|
257
|
+
} else if (s === "(" || s === "[" || s === "{") {
|
|
258
|
+
if (tk.m[j] < 0) return i;
|
|
259
|
+
j = tk.m[j];
|
|
260
|
+
} else if (s === ";" || s === "=" || s === "&&" || s === "||" || /^\d/.test(s)) return i;
|
|
261
|
+
}
|
|
262
|
+
return i;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Read a type reference: `a.b.Foo<X>?`, `[Foo]`, `Foo[]`, `*Foo`, `&mut Foo`,
|
|
267
|
+
* `Foo | null`. Returns the simple name of the outermost type, or null for a
|
|
268
|
+
* function type, tuple or anything else that has no single name.
|
|
269
|
+
*
|
|
270
|
+
* @param {object} tk - tokenize() result
|
|
271
|
+
* @param {number} i - first token of the type
|
|
272
|
+
* @param {object} [opts]
|
|
273
|
+
* @param {Set<string>} [opts.skip] - leading words to ignore (`mut`, `const`, `dyn`...)
|
|
274
|
+
* @returns {{name: string|null, next: number, args: string[]}}
|
|
275
|
+
*/
|
|
276
|
+
export function readType(tk, i, opts = {}) {
|
|
277
|
+
tick(tk);
|
|
278
|
+
const skip = opts.skip || new Set();
|
|
279
|
+
const limit = opts.limit ?? tk.n;
|
|
280
|
+
let j = i;
|
|
281
|
+
while (j < limit && (skip.has(tk.t[j]) || tk.t[j] === "&" || tk.t[j] === "*")) j++;
|
|
282
|
+
if (tk.t[j] === "[") {
|
|
283
|
+
const close = tk.m[j];
|
|
284
|
+
const inner = close > j ? readType(tk, j + 1, { ...opts, limit: close }) : null;
|
|
285
|
+
return {
|
|
286
|
+
name: inner?.name ? `[${inner.name}]` : null,
|
|
287
|
+
next: close > 0 ? close + 1 : j + 1,
|
|
288
|
+
args: [],
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
if (tk.t[j] === "(") {
|
|
292
|
+
const close = tk.m[j];
|
|
293
|
+
return { name: null, next: close > 0 ? close + 1 : j + 1, args: [] };
|
|
294
|
+
}
|
|
295
|
+
if (!isIdent(tk.t[j])) return { name: null, next: j, args: [] };
|
|
296
|
+
let name = tk.t[j];
|
|
297
|
+
j++;
|
|
298
|
+
while (j + 1 < limit && (tk.t[j] === "." || tk.t[j] === "::") && isIdent(tk.t[j + 1])) {
|
|
299
|
+
name = tk.t[j + 1];
|
|
300
|
+
j += 2;
|
|
301
|
+
}
|
|
302
|
+
const args = [];
|
|
303
|
+
if (tk.t[j] === "<") {
|
|
304
|
+
const after = skipAngles(tk, j, limit);
|
|
305
|
+
if (after > j) {
|
|
306
|
+
let k = j + 1;
|
|
307
|
+
while (k < after - 1) {
|
|
308
|
+
const a = readType(tk, k, { ...opts, limit: after - 1 });
|
|
309
|
+
if (a.name) args.push(a.name);
|
|
310
|
+
k = Math.max(a.next, k + 1);
|
|
311
|
+
while (k < after - 1 && tk.t[k] !== ",") {
|
|
312
|
+
if (tk.m[k] > k) k = tk.m[k];
|
|
313
|
+
k++;
|
|
314
|
+
}
|
|
315
|
+
k++;
|
|
316
|
+
}
|
|
317
|
+
j = after;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
while (j < limit) {
|
|
321
|
+
const s = tk.t[j];
|
|
322
|
+
if (s === "?" || s === "!" || s === "*" || s === "&") j++;
|
|
323
|
+
else if (s === "[" && tk.m[j] === j + 1) {
|
|
324
|
+
name = `[${name}]`;
|
|
325
|
+
j += 2;
|
|
326
|
+
} else break;
|
|
327
|
+
}
|
|
328
|
+
if (opts.unwrap?.has(name) && args.length) name = args[0];
|
|
329
|
+
if ((tk.t[j] === "|" || tk.t[j] === "&") && opts.union) {
|
|
330
|
+
const rest = readType(tk, j + 1, opts);
|
|
331
|
+
const dropped = new Set(["null", "undefined", "None", "nil", "void"]);
|
|
332
|
+
if (dropped.has(rest.name)) return { name, next: rest.next, args };
|
|
333
|
+
if (dropped.has(name)) return { name: rest.name, next: rest.next, args: rest.args };
|
|
334
|
+
return { name: null, next: rest.next, args };
|
|
335
|
+
}
|
|
336
|
+
return { name, next: j, args };
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Number of top-level arguments between a `(` and its match, with the names of
|
|
341
|
+
* the labelled ones (`f(a: 1)`, `f(a = 1)`).
|
|
342
|
+
*
|
|
343
|
+
* @param {object} tk
|
|
344
|
+
* @param {number} open - index of the `(`
|
|
345
|
+
* @param {string[]} labelOps - tokens that follow a label (`:` in Swift, `=` in Python)
|
|
346
|
+
* @returns {{n: number, labels: string[]}}
|
|
347
|
+
*/
|
|
348
|
+
export function countArgs(tk, open, labelOps) {
|
|
349
|
+
const close = tk.m[open];
|
|
350
|
+
if (close < 0 || close === open + 1) return { n: 0, labels: [] };
|
|
351
|
+
let n = 1;
|
|
352
|
+
const labels = [];
|
|
353
|
+
let atStart = true;
|
|
354
|
+
for (let j = open + 1; j < close; j++) {
|
|
355
|
+
tick(tk);
|
|
356
|
+
const s = tk.t[j];
|
|
357
|
+
if (atStart && isIdent(s) && labelOps.includes(tk.t[j + 1])) labels.push(s);
|
|
358
|
+
atStart = false;
|
|
359
|
+
if (tk.m[j] > j) {
|
|
360
|
+
j = tk.m[j];
|
|
361
|
+
continue;
|
|
362
|
+
}
|
|
363
|
+
if (s === ",") {
|
|
364
|
+
if (j + 1 < close) n++;
|
|
365
|
+
atStart = true;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return { n, labels };
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Split the contents of a bracket pair at its top-level commas.
|
|
373
|
+
*
|
|
374
|
+
* @param {object} tk
|
|
375
|
+
* @param {number} open - index of the opening bracket
|
|
376
|
+
* @returns {Array<[number, number]>} half-open token ranges, empty segments dropped
|
|
377
|
+
*/
|
|
378
|
+
export function splitTop(tk, open) {
|
|
379
|
+
const close = tk.m[open];
|
|
380
|
+
const parts = [];
|
|
381
|
+
if (close < 0) return parts;
|
|
382
|
+
let start = open + 1;
|
|
383
|
+
for (let j = open + 1; j < close; j++) {
|
|
384
|
+
tick(tk);
|
|
385
|
+
if (tk.m[j] > j) j = tk.m[j];
|
|
386
|
+
else if (tk.t[j] === "<" && isIdent(tk.t[j - 1])) {
|
|
387
|
+
const after = skipAngles(tk, j, close);
|
|
388
|
+
if (after > j) j = after - 1;
|
|
389
|
+
} else if (tk.t[j] === ",") {
|
|
390
|
+
if (j > start) parts.push([start, j]);
|
|
391
|
+
start = j + 1;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
if (close > start) parts.push([start, close]);
|
|
395
|
+
return parts;
|
|
396
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file platform.mjs - names every language's standard library and platform
|
|
3
|
+
* frameworks already own.
|
|
4
|
+
*
|
|
5
|
+
* A bare `URL(...)`, `Timeline(...)`, `print(...)` or `Map(...)` is the
|
|
6
|
+
* platform's, not a repository type that happens to share the name. The
|
|
7
|
+
* resolver therefore binds such a name to a repository declaration only when
|
|
8
|
+
* that declaration is in lexical scope (the same file, a type enclosing the
|
|
9
|
+
* call, or the module an import names). The lists are short and cover the
|
|
10
|
+
* names a repository is most likely to collide with, not the whole library.
|
|
11
|
+
*
|
|
12
|
+
* @module pipeline/scripts/call-graph/platform
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const words = (s) => new Set(s.split(/\s+/).filter(Boolean));
|
|
16
|
+
|
|
17
|
+
export const PLATFORM_NAMES = {
|
|
18
|
+
swift: words(`
|
|
19
|
+
URL URLRequest URLSession URLComponents Data Date String Substring Character Array Dictionary Set Optional Result
|
|
20
|
+
Int Int8 Int16 Int32 Int64 UInt UInt8 UInt16 UInt32 UInt64 Double Float Bool Void Any AnyObject Never
|
|
21
|
+
UUID Calendar Locale TimeZone Decimal Measurement Notification NotificationCenter Bundle FileManager UserDefaults
|
|
22
|
+
JSONDecoder JSONEncoder PropertyListDecoder DispatchQueue DispatchGroup OperationQueue Timer Thread Process
|
|
23
|
+
NSObject NSError NSString NSNumber NSArray NSDictionary Error DecodingError Task TaskGroup Actor MainActor
|
|
24
|
+
CGFloat CGPoint CGSize CGRect CGColor CGImage UIColor UIImage UIView UIViewController UIFont NSColor NSImage
|
|
25
|
+
Text Image Button Color Font List Form Label Toggle Slider Picker Stepper TextField SecureField Section Group
|
|
26
|
+
NavigationStack NavigationView NavigationLink ScrollView LazyVStack LazyHStack VStack HStack ZStack Grid GridRow
|
|
27
|
+
Spacer Divider Rectangle Circle Capsule RoundedRectangle Path Shape View Scene App Binding State StateObject
|
|
28
|
+
ObservedObject EnvironmentObject Environment Animation Transaction Gesture Alert Sheet Menu TabView
|
|
29
|
+
Timeline TimelineEntry TimelineProvider WidgetConfiguration WidgetFamily WidgetCenter
|
|
30
|
+
Logger OSLog Progress Process Pipe Host HTTPURLResponse DateFormatter NumberFormatter ByteCountFormatter
|
|
31
|
+
ProcessInfo RunLoop Selector Mirror Unmanaged ObjectIdentifier IndexPath IndexSet Range ClosedRange Sequence
|
|
32
|
+
Collection Equatable Hashable Comparable Codable Encodable Decodable Identifiable
|
|
33
|
+
print debugPrint dump min max abs zip stride assert assertionFailure precondition preconditionFailure fatalError
|
|
34
|
+
swap type withUnsafePointer withUnsafeBytes withCheckedContinuation withThrowingTaskGroup withTaskGroup
|
|
35
|
+
isKnownUniquelyReferenced numericCast repeatElement sequence readLine
|
|
36
|
+
`),
|
|
37
|
+
kotlin: words(`
|
|
38
|
+
String Int Long Short Byte Double Float Boolean Char Unit Any Nothing Number Array List Map Set MutableList
|
|
39
|
+
MutableMap MutableSet Pair Triple Result Exception Throwable Error Regex Date Uri Intent Bundle Context View
|
|
40
|
+
Log Thread Runnable Sequence Iterator Lazy Comparable Collection
|
|
41
|
+
println print listOf mapOf setOf mutableListOf mutableMapOf mutableSetOf arrayOf emptyList emptyMap emptySet
|
|
42
|
+
require check error lazy run let apply also with repeat TODO assert requireNotNull checkNotNull to
|
|
43
|
+
`),
|
|
44
|
+
java: words(`
|
|
45
|
+
String Object Integer Long Short Byte Double Float Boolean Character Number Void Math System Thread Runnable
|
|
46
|
+
List Map Set ArrayList HashMap HashSet LinkedList TreeMap Optional Objects Arrays Collections Collection
|
|
47
|
+
Iterator Iterable StringBuilder StringBuffer Exception RuntimeException Error Throwable Class Date File Path
|
|
48
|
+
Paths Files URL URI UUID Random Scanner Stream Collectors Function Supplier Consumer Predicate Callable
|
|
49
|
+
Duration Instant LocalDate LocalDateTime BigDecimal BigInteger Pattern Matcher
|
|
50
|
+
`),
|
|
51
|
+
csharp: words(`
|
|
52
|
+
String Object Int32 Int64 Double Boolean Char Byte Decimal Guid DateTime DateTimeOffset TimeSpan Uri Math Console
|
|
53
|
+
List Dictionary HashSet Queue Stack Array Enumerable Task Exception Action Func Tuple Nullable Lazy Thread
|
|
54
|
+
StringBuilder Convert Environment File Path Directory Stream Regex Random
|
|
55
|
+
`),
|
|
56
|
+
typescript: words(`
|
|
57
|
+
Object Array Map Set WeakMap WeakSet Promise Error TypeError RangeError Date RegExp JSON Math Number String
|
|
58
|
+
Boolean Symbol BigInt URL URLSearchParams Buffer Uint8Array Float64Array ArrayBuffer Proxy Reflect Intl
|
|
59
|
+
Response Request Headers FormData AbortController Event EventTarget TextEncoder TextDecoder
|
|
60
|
+
fetch require setTimeout clearTimeout setInterval clearInterval setImmediate parseInt parseFloat isNaN isFinite
|
|
61
|
+
structuredClone queueMicrotask encodeURIComponent decodeURIComponent encodeURI decodeURI atob btoa alert
|
|
62
|
+
console process
|
|
63
|
+
`),
|
|
64
|
+
python: words(`
|
|
65
|
+
print len range int str float list dict set tuple frozenset bool bytes bytearray object type open isinstance
|
|
66
|
+
issubclass enumerate zip map filter sorted reversed sum min max abs any all iter next super getattr setattr
|
|
67
|
+
hasattr delattr repr format round id input hash callable vars dir divmod pow chr ord hex oct bin slice
|
|
68
|
+
property staticmethod classmethod Exception ValueError TypeError KeyError IndexError RuntimeError
|
|
69
|
+
OSError NotImplementedError StopIteration
|
|
70
|
+
`),
|
|
71
|
+
go: words(`
|
|
72
|
+
len cap make new append copy delete panic recover print println close min max clear complex real imag
|
|
73
|
+
string int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 float32 float64 bool byte rune error any
|
|
74
|
+
`),
|
|
75
|
+
rust: words(`
|
|
76
|
+
Vec String Option Result Box Rc Arc RefCell Cell Mutex RwLock HashMap HashSet BTreeMap BTreeSet VecDeque Cow
|
|
77
|
+
Some None Ok Err Default Clone Iterator Into From TryFrom AsRef Path PathBuf Duration Instant
|
|
78
|
+
drop panic assert
|
|
79
|
+
`),
|
|
80
|
+
cpp: words(`
|
|
81
|
+
string vector map unordered_map set unordered_set list deque array pair tuple optional variant shared_ptr
|
|
82
|
+
unique_ptr weak_ptr function thread mutex move forward make_unique make_shared make_pair swap sort find
|
|
83
|
+
printf fprintf sprintf snprintf scanf malloc calloc realloc free memcpy memset memmove strlen strcmp strcpy
|
|
84
|
+
exit abort assert sizeof static_cast dynamic_cast reinterpret_cast const_cast size_t
|
|
85
|
+
`),
|
|
86
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file profiles.mjs - which language profile reads which file.
|
|
3
|
+
*
|
|
4
|
+
* Chosen by file extension, not by the graph's stack: the Android stack holds
|
|
5
|
+
* Kotlin and Java side by side, and a Node tree can hold TypeScript, JavaScript
|
|
6
|
+
* and a Python script.
|
|
7
|
+
*
|
|
8
|
+
* @module pipeline/scripts/call-graph/profiles
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import swift from "./lang/swift.mjs";
|
|
12
|
+
import kotlin from "./lang/kotlin.mjs";
|
|
13
|
+
import typescript from "./lang/typescript.mjs";
|
|
14
|
+
import python from "./lang/python.mjs";
|
|
15
|
+
import go from "./lang/go.mjs";
|
|
16
|
+
import rust from "./lang/rust.mjs";
|
|
17
|
+
import java from "./lang/java.mjs";
|
|
18
|
+
import csharp from "./lang/csharp.mjs";
|
|
19
|
+
import cpp from "./lang/cpp.mjs";
|
|
20
|
+
import { PLATFORM_NAMES } from "./platform.mjs";
|
|
21
|
+
|
|
22
|
+
const ALL = [swift, kotlin, typescript, python, go, rust, java, csharp, cpp];
|
|
23
|
+
|
|
24
|
+
const BY_EXT = new Map();
|
|
25
|
+
for (const profile of ALL) {
|
|
26
|
+
for (const ext of profile.exts) BY_EXT.set(ext, profile);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const DEFAULTS = {
|
|
30
|
+
implicitSelf: false,
|
|
31
|
+
initName: "init",
|
|
32
|
+
selfWords: new Set(),
|
|
33
|
+
superWords: new Set(),
|
|
34
|
+
newKeyword: null,
|
|
35
|
+
memberOps: new Set(["."]),
|
|
36
|
+
labelOps: [],
|
|
37
|
+
trailingClosure: false,
|
|
38
|
+
genericCalls: false,
|
|
39
|
+
castWords: null,
|
|
40
|
+
keywords: new Set(),
|
|
41
|
+
declWords: new Set(),
|
|
42
|
+
condWords: null,
|
|
43
|
+
perNameImports: false,
|
|
44
|
+
packageScope: false,
|
|
45
|
+
localDecl: null,
|
|
46
|
+
lambdaParams: null,
|
|
47
|
+
moduleSuffixes: null,
|
|
48
|
+
union: false,
|
|
49
|
+
castFn: null,
|
|
50
|
+
prepare: null,
|
|
51
|
+
binds: null,
|
|
52
|
+
keepStrings: false,
|
|
53
|
+
superCall: false,
|
|
54
|
+
bareCallConstructs: false,
|
|
55
|
+
structuralInterfaces: false,
|
|
56
|
+
topLevel: false,
|
|
57
|
+
targetOf: null,
|
|
58
|
+
contextual: null,
|
|
59
|
+
jsx: false,
|
|
60
|
+
reexports: null,
|
|
61
|
+
platformNames: new Set(),
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const PACKAGE_SCOPE = new Set(["swift", "kotlin", "java", "csharp", "go"]);
|
|
65
|
+
const PER_NAME_IMPORTS = new Set(["typescript", "python", "rust"]);
|
|
66
|
+
|
|
67
|
+
for (const [ext, profile] of BY_EXT) {
|
|
68
|
+
BY_EXT.set(ext, {
|
|
69
|
+
...DEFAULTS,
|
|
70
|
+
...profile,
|
|
71
|
+
packageScope: PACKAGE_SCOPE.has(profile.id),
|
|
72
|
+
perNameImports: PER_NAME_IMPORTS.has(profile.id),
|
|
73
|
+
platformNames: PLATFORM_NAMES[profile.id] || DEFAULTS.platformNames,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @param {string} path
|
|
79
|
+
* @returns {object|null} the profile for this file's extension
|
|
80
|
+
*/
|
|
81
|
+
export function profileForPath(path) {
|
|
82
|
+
const dot = path.lastIndexOf(".");
|
|
83
|
+
return dot < 0 ? null : BY_EXT.get(path.slice(dot)) || null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** @returns {string[]} every extension a profile reads */
|
|
87
|
+
export function supportedExtensions() {
|
|
88
|
+
return [...BY_EXT.keys()];
|
|
89
|
+
}
|