@mmerterden/multi-agent-pipeline 23.3.0 → 23.5.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 +73 -0
- package/README.md +27 -8
- package/README.tr.md +28 -9
- package/SECURITY.md +16 -0
- 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/_platform-filter.mjs +2 -55
- package/install/claude.mjs +28 -2
- package/install/codex.mjs +1 -3
- package/install/copilot.mjs +4 -8
- package/install/templates/claude-hooks.json +32 -1
- package/manifest.json +236 -167
- package/package.json +11 -3
- package/pipeline/commands/multi-agent/SKILL.md +1 -1
- package/pipeline/commands/multi-agent/design-check/SKILL.md +3 -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 +63 -0
- package/pipeline/contract/README.md +1 -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 +41 -15
- package/pipeline/contract/types/index.d.ts +81 -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/stack-detect.sh +1 -1
- package/pipeline/lib/tls-trust.mjs +29 -0
- package/pipeline/lib/usage-lifecycle.mjs +9 -11
- package/pipeline/lib/usage-names.generated.mjs +613 -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/init-inventory.md +11 -1
- 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 +253 -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 +255 -27
- 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 +2 -2
- 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 +1309 -236
- 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/mcp-health.schema.json +96 -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 +78 -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 +33 -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/build-stack-plugins.mjs +1 -47
- 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 +3 -0
- package/pipeline/scripts/design-check-config.mjs +205 -0
- package/pipeline/scripts/feedback-send.mjs +26 -26
- package/pipeline/scripts/gate-ledger.mjs +2 -1
- package/pipeline/scripts/gen-facts.mjs +1 -2
- 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/mcp-health.mjs +309 -0
- 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 +330 -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 +191 -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/skill-usage.mjs +16 -5
- 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/_renamed-skills.mjs +0 -164
- package/pipeline/scripts/publish-staged.mjs +0 -324
- package/pipeline/skills/renamed.json +0 -30
- package/pipeline/skills/shared/external/ios-coding-standard/scripts/check_structure.py +0 -765
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file swift.mjs - Swift profile for the call-edge scanner.
|
|
3
|
+
*
|
|
4
|
+
* Reads declarations (types, extensions, protocols, functions, initialisers,
|
|
5
|
+
* stored and computed properties) with a statement walker over bracket-matched
|
|
6
|
+
* tokens. It does not type-check: an expression whose type depends on
|
|
7
|
+
* inference beyond `let x = Foo(...)`, an annotation or a return type stays
|
|
8
|
+
* unknown, and result builders, property wrappers and operator overloads are
|
|
9
|
+
* not modelled.
|
|
10
|
+
*
|
|
11
|
+
* @module pipeline/scripts/call-graph/lang/swift
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { isIdent, readType, skipAngles, splitTop, tick, MAX_HEADER_TOKENS } from "../lex.mjs";
|
|
15
|
+
|
|
16
|
+
const TYPE_KW = new Set(["class", "struct", "enum", "protocol", "actor", "extension"]);
|
|
17
|
+
const IMPORT_KINDS = new Set([
|
|
18
|
+
"struct",
|
|
19
|
+
"class",
|
|
20
|
+
"enum",
|
|
21
|
+
"protocol",
|
|
22
|
+
"func",
|
|
23
|
+
"var",
|
|
24
|
+
"let",
|
|
25
|
+
"typealias",
|
|
26
|
+
]);
|
|
27
|
+
const MODS = new Set(
|
|
28
|
+
`public private fileprivate internal open final static override mutating nonmutating lazy weak
|
|
29
|
+
unowned convenience required indirect prefix postfix infix nonisolated isolated dynamic optional
|
|
30
|
+
distributed borrowing consuming package`.split(/\s+/),
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const KEYWORDS = new Set(
|
|
34
|
+
`if else guard while for in switch case default return throw throws rethrows try await catch do
|
|
35
|
+
repeat break continue defer where is as func class struct enum protocol extension init deinit
|
|
36
|
+
typealias import let var nil true false subscript associatedtype operator async some any inout
|
|
37
|
+
static public private fileprivate internal open final override actor`.split(/\s+/),
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
function readParams(tk, open) {
|
|
41
|
+
const params = [];
|
|
42
|
+
let min = 0;
|
|
43
|
+
let max = 0;
|
|
44
|
+
for (const [a, b] of splitTop(tk, open)) {
|
|
45
|
+
let k = a;
|
|
46
|
+
while (tk.t[k] === "@") {
|
|
47
|
+
k += 2;
|
|
48
|
+
if (tk.t[k] === "(") k = tk.m[k] + 1;
|
|
49
|
+
}
|
|
50
|
+
const first = tk.t[k];
|
|
51
|
+
if (!isIdent(first)) continue;
|
|
52
|
+
let label = first;
|
|
53
|
+
let name = first;
|
|
54
|
+
if (isIdent(tk.t[k + 1]) && tk.t[k + 1] !== "in") {
|
|
55
|
+
name = tk.t[k + 1];
|
|
56
|
+
k += 2;
|
|
57
|
+
} else k += 1;
|
|
58
|
+
if (label === "_") label = null;
|
|
59
|
+
let type = null;
|
|
60
|
+
let variadic = false;
|
|
61
|
+
let hasDefault = false;
|
|
62
|
+
if (tk.t[k] === ":") {
|
|
63
|
+
const r = readType(tk, k + 1, { skip: new Set(["inout", "some", "any"]), limit: b });
|
|
64
|
+
type = r.name;
|
|
65
|
+
let q = r.next;
|
|
66
|
+
if (tk.t[q] === "..." || (tk.t[q] === "." && tk.t[q + 1] === "." && tk.t[q + 2] === ".")) {
|
|
67
|
+
variadic = true;
|
|
68
|
+
q += tk.t[q] === "..." ? 1 : 3;
|
|
69
|
+
}
|
|
70
|
+
for (let z = q; z < b; z++) if (tk.t[z] === "=") hasDefault = true;
|
|
71
|
+
}
|
|
72
|
+
params.push([label, name, variadic && type ? `[${type}]` : type]);
|
|
73
|
+
if (variadic) max = Infinity;
|
|
74
|
+
else if (max !== Infinity) max++;
|
|
75
|
+
if (!hasDefault && !variadic) min++;
|
|
76
|
+
}
|
|
77
|
+
return { params, min, max };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function headerSupers(tk, i, limit) {
|
|
81
|
+
const sup = [];
|
|
82
|
+
let j = i;
|
|
83
|
+
if (tk.t[j] !== ":") return { sup, next: j };
|
|
84
|
+
j++;
|
|
85
|
+
while (j < limit && tk.t[j] !== "{" && tk.t[j] !== "where") {
|
|
86
|
+
const r = readType(tk, j, { limit });
|
|
87
|
+
if (r.name) sup.push(r.name);
|
|
88
|
+
j = Math.max(r.next, j + 1);
|
|
89
|
+
while (j < limit && tk.t[j] !== "," && tk.t[j] !== "{" && tk.t[j] !== "where") {
|
|
90
|
+
j = tk.m[j] > j ? tk.m[j] + 1 : j + 1;
|
|
91
|
+
}
|
|
92
|
+
if (tk.t[j] === ",") j++;
|
|
93
|
+
}
|
|
94
|
+
return { sup, next: j };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function genericNames(tk, i) {
|
|
98
|
+
if (tk.t[i] !== "<") return { gen: [], next: i };
|
|
99
|
+
const after = skipAngles(tk, i);
|
|
100
|
+
const gen = [];
|
|
101
|
+
for (let j = i + 1; j < after - 1; j++) {
|
|
102
|
+
if (isIdent(tk.t[j]) && (tk.t[j - 1] === "<" || tk.t[j - 1] === ",")) gen.push(tk.t[j]);
|
|
103
|
+
}
|
|
104
|
+
return { gen, next: after };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function parse(tk) {
|
|
108
|
+
const t = tk.t;
|
|
109
|
+
const types = [];
|
|
110
|
+
const fns = [];
|
|
111
|
+
const fieldsOf = new Map();
|
|
112
|
+
const mods = [];
|
|
113
|
+
|
|
114
|
+
const walk = (from, to, owner, ownerKind) => {
|
|
115
|
+
let i = from;
|
|
116
|
+
let isStatic = false;
|
|
117
|
+
while (i < to) {
|
|
118
|
+
tick(tk);
|
|
119
|
+
const s = t[i];
|
|
120
|
+
if (s === "@") {
|
|
121
|
+
i += 2;
|
|
122
|
+
while (t[i] === "." && isIdent(t[i + 1])) i += 2;
|
|
123
|
+
if (t[i] === "(" && tk.m[i] > i) i = tk.m[i] + 1;
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (s === "#") {
|
|
127
|
+
i++;
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (s === "import" && !owner && tk.first[i] === 1) {
|
|
131
|
+
let k = i + 1;
|
|
132
|
+
if (IMPORT_KINDS.has(t[k]) && isIdent(t[k + 1])) k++;
|
|
133
|
+
if (isIdent(t[k]) && !mods.includes(t[k])) mods.push(t[k]);
|
|
134
|
+
i = k + 1;
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (MODS.has(s) && !(s === "class" && false)) {
|
|
138
|
+
if (s === "static") isStatic = true;
|
|
139
|
+
i++;
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if (s === "class" && ["func", "var", "let", "subscript"].includes(t[i + 1])) {
|
|
143
|
+
isStatic = true;
|
|
144
|
+
i++;
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (TYPE_KW.has(s) && isIdent(t[i + 1])) {
|
|
148
|
+
i = typeDecl(i, to, owner);
|
|
149
|
+
isStatic = false;
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
if (s === "func" && isIdent(t[i + 1])) {
|
|
153
|
+
i = funcDecl(i, to, owner, ownerKind, isStatic);
|
|
154
|
+
isStatic = false;
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
if (
|
|
158
|
+
s === "init" &&
|
|
159
|
+
owner &&
|
|
160
|
+
(t[i + 1] === "(" || ((t[i + 1] === "?" || t[i + 1] === "!") && t[i + 2] === "("))
|
|
161
|
+
) {
|
|
162
|
+
i = funcDecl(i - 1, to, owner, ownerKind, false, true);
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
if ((s === "var" || s === "let") && owner && isIdent(t[i + 1])) {
|
|
166
|
+
i = propDecl(i, to, owner, isStatic);
|
|
167
|
+
isStatic = false;
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
if (s === "{" && tk.m[i] > i) {
|
|
171
|
+
i = tk.m[i] + 1;
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
isStatic = false;
|
|
175
|
+
i++;
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const typeDecl = (i, to, outer) => {
|
|
180
|
+
const kw = t[i];
|
|
181
|
+
let j = i + 1;
|
|
182
|
+
let name = t[j];
|
|
183
|
+
j++;
|
|
184
|
+
while (t[j] === "." && isIdent(t[j + 1])) {
|
|
185
|
+
name = t[j + 1];
|
|
186
|
+
j += 2;
|
|
187
|
+
}
|
|
188
|
+
const g = genericNames(tk, j);
|
|
189
|
+
j = g.next;
|
|
190
|
+
const hs = headerSupers(tk, j, Math.min(to, j + MAX_HEADER_TOKENS));
|
|
191
|
+
j = hs.next;
|
|
192
|
+
const lim = Math.min(to, j + MAX_HEADER_TOKENS);
|
|
193
|
+
while (j < lim && t[j] !== "{") j++;
|
|
194
|
+
if (t[j] !== "{" || tk.m[j] < 0) return i + 2;
|
|
195
|
+
const rec = {
|
|
196
|
+
n: name,
|
|
197
|
+
k: kw === "extension" ? "ext" : kw,
|
|
198
|
+
line: tk.line[i],
|
|
199
|
+
end: tk.line[tk.m[j]],
|
|
200
|
+
sup: hs.sup,
|
|
201
|
+
...(outer && kw !== "extension" ? { outer } : {}),
|
|
202
|
+
...(g.gen.length ? { gen: g.gen } : {}),
|
|
203
|
+
f: {},
|
|
204
|
+
};
|
|
205
|
+
types.push(rec);
|
|
206
|
+
fieldsOf.set(name + "@" + tk.line[i], rec);
|
|
207
|
+
walk(j + 1, tk.m[j], name, kw);
|
|
208
|
+
return tk.m[j] + 1;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const funcDecl = (i, to, owner, ownerKind, isStatic, isInit = false) => {
|
|
212
|
+
let j = i + 1;
|
|
213
|
+
const name = isInit ? "init" : t[j];
|
|
214
|
+
j++;
|
|
215
|
+
if (isInit && (t[j] === "?" || t[j] === "!")) j++;
|
|
216
|
+
const g = genericNames(tk, j);
|
|
217
|
+
j = g.next;
|
|
218
|
+
if (t[j] !== "(" || tk.m[j] < 0) return i + 2;
|
|
219
|
+
const sig = readParams(tk, j);
|
|
220
|
+
j = tk.m[j] + 1;
|
|
221
|
+
while (j < to && ["async", "throws", "rethrows"].includes(t[j])) j++;
|
|
222
|
+
let ret = null;
|
|
223
|
+
if (t[j] === "->") {
|
|
224
|
+
const r = readType(tk, j + 1, { skip: new Set(["some", "any"]), limit: to });
|
|
225
|
+
ret = r.name;
|
|
226
|
+
j = r.next;
|
|
227
|
+
}
|
|
228
|
+
let body = null;
|
|
229
|
+
let k = j;
|
|
230
|
+
const lim = Math.min(to, j + MAX_HEADER_TOKENS);
|
|
231
|
+
while (k < lim && t[k] !== "{" && !(tk.first[k] && ownerKind === "protocol")) k++;
|
|
232
|
+
if (t[k] === "{" && tk.m[k] > k) body = [k + 1, tk.m[k]];
|
|
233
|
+
const endTok = body ? tk.m[k] : Math.max(i, j - 1);
|
|
234
|
+
fns.push({
|
|
235
|
+
n: name,
|
|
236
|
+
o: owner,
|
|
237
|
+
a: [sig.min, sig.max],
|
|
238
|
+
p: sig.params,
|
|
239
|
+
r: ret,
|
|
240
|
+
l: tk.line[isInit ? i + 1 : i],
|
|
241
|
+
e: tk.line[endTok],
|
|
242
|
+
...(isStatic ? { s: 1 } : {}),
|
|
243
|
+
...(ownerKind === "protocol" || !body ? { ab: 1 } : {}),
|
|
244
|
+
...(g.gen.length ? { g: g.gen } : {}),
|
|
245
|
+
body,
|
|
246
|
+
});
|
|
247
|
+
return body ? tk.m[k] + 1 : Math.max(j, i + 2);
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const propDecl = (i, to, owner, isStatic) => {
|
|
251
|
+
const name = t[i + 1];
|
|
252
|
+
let j = i + 2;
|
|
253
|
+
let type = null;
|
|
254
|
+
if (t[j] === ":") {
|
|
255
|
+
const r = readType(tk, j + 1, { skip: new Set(["some", "any"]), limit: to });
|
|
256
|
+
type = r.name;
|
|
257
|
+
j = r.next;
|
|
258
|
+
}
|
|
259
|
+
let body = null;
|
|
260
|
+
if (t[j] === "=") {
|
|
261
|
+
const c = t[j + 1];
|
|
262
|
+
if (!type && isIdent(c) && /^[A-Z]/.test(c)) {
|
|
263
|
+
let q = j + 1;
|
|
264
|
+
let last = c;
|
|
265
|
+
while (t[q + 1] === "." && isIdent(t[q + 2]) && /^[A-Z]/.test(t[q + 2])) {
|
|
266
|
+
last = t[q + 2];
|
|
267
|
+
q += 2;
|
|
268
|
+
}
|
|
269
|
+
if (t[q + 1] === "(" || t[q + 1] === "<") type = last;
|
|
270
|
+
}
|
|
271
|
+
if (c === "{" && tk.m[j + 1] > j + 1) body = [j + 2, tk.m[j + 1]];
|
|
272
|
+
} else if (t[j] === "{" && tk.m[j] > j) {
|
|
273
|
+
body = [j + 1, tk.m[j]];
|
|
274
|
+
}
|
|
275
|
+
const rec = [...types].reverse().find((x) => x.n === owner);
|
|
276
|
+
if (rec && type) rec.f[name] = type;
|
|
277
|
+
if (body) {
|
|
278
|
+
fns.push({
|
|
279
|
+
n: name,
|
|
280
|
+
o: owner,
|
|
281
|
+
a: [0, 0],
|
|
282
|
+
p: [],
|
|
283
|
+
r: type,
|
|
284
|
+
l: tk.line[i],
|
|
285
|
+
e: tk.line[body[1]],
|
|
286
|
+
...(isStatic ? { s: 1 } : {}),
|
|
287
|
+
acc: 1,
|
|
288
|
+
body,
|
|
289
|
+
});
|
|
290
|
+
return body[1] + 1;
|
|
291
|
+
}
|
|
292
|
+
return j;
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
walk(0, tk.n, null, null);
|
|
296
|
+
return { types, fns, binds: [], mods };
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function localDecl(tk, i, end) {
|
|
300
|
+
const t = tk.t;
|
|
301
|
+
const s = t[i];
|
|
302
|
+
if (s === "func" && isIdent(t[i + 1]))
|
|
303
|
+
return { name: t[i + 1], type: null, init: null, next: i + 2 };
|
|
304
|
+
if (s === "let" || s === "var") {
|
|
305
|
+
let j = i + 1;
|
|
306
|
+
if (t[j] === "(") {
|
|
307
|
+
const names = [];
|
|
308
|
+
for (let k = j + 1; k < tk.m[j]; k++) if (isIdent(t[k]) && t[k] !== "_") names.push(t[k]);
|
|
309
|
+
const after = tk.m[j] + 1;
|
|
310
|
+
return {
|
|
311
|
+
name: names[0] || "_",
|
|
312
|
+
also: names.slice(1),
|
|
313
|
+
type: null,
|
|
314
|
+
init: t[after] === "=" ? after + 1 : null,
|
|
315
|
+
next: after,
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
if (!isIdent(t[j]) || t[j] === "self") return null;
|
|
319
|
+
const name = t[j];
|
|
320
|
+
j++;
|
|
321
|
+
let type = null;
|
|
322
|
+
if (t[j] === ":") {
|
|
323
|
+
const r = readType(tk, j + 1, { skip: new Set(["some", "any"]), limit: end });
|
|
324
|
+
type = r.name;
|
|
325
|
+
j = r.next;
|
|
326
|
+
}
|
|
327
|
+
if (t[j] === "=") return { name, type, init: j + 1, next: j + 1 };
|
|
328
|
+
if (t[j] === "{" && type) return { name, type, init: null, next: j };
|
|
329
|
+
if (type) return { name, type, init: null, next: j };
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
if (s === "for") {
|
|
333
|
+
let j = i + 1;
|
|
334
|
+
if (t[j] === "case") j++;
|
|
335
|
+
if (t[j] === "let" || t[j] === "var") j++;
|
|
336
|
+
const names = [];
|
|
337
|
+
while (j < end && t[j] !== "in" && t[j] !== "{") {
|
|
338
|
+
if (isIdent(t[j]) && t[j] !== "_") names.push(t[j]);
|
|
339
|
+
j++;
|
|
340
|
+
}
|
|
341
|
+
if (t[j] !== "in" || !names.length) return null;
|
|
342
|
+
return { name: names[0], also: names.slice(1), type: null, init: null, next: i + 1 };
|
|
343
|
+
}
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function lambdaParams(tk, i, end) {
|
|
348
|
+
const t = tk.t;
|
|
349
|
+
if (t[i] !== "{") return null;
|
|
350
|
+
let j = i + 1;
|
|
351
|
+
if (t[j] === "[" && tk.m[j] > j) j = tk.m[j] + 1;
|
|
352
|
+
const params = [];
|
|
353
|
+
if (t[j] === "(") {
|
|
354
|
+
const close = tk.m[j];
|
|
355
|
+
if (close < 0) return null;
|
|
356
|
+
for (const [a, b] of splitTop(tk, j)) {
|
|
357
|
+
if (!isIdent(t[a])) continue;
|
|
358
|
+
const type = t[a + 1] === ":" ? readType(tk, a + 2, { limit: b }).name : null;
|
|
359
|
+
params.push([t[a], type]);
|
|
360
|
+
}
|
|
361
|
+
j = close + 1;
|
|
362
|
+
} else {
|
|
363
|
+
while (j < end && isIdent(t[j]) && t[j] !== "in") {
|
|
364
|
+
params.push([t[j], null]);
|
|
365
|
+
j++;
|
|
366
|
+
if (t[j] === ",") j++;
|
|
367
|
+
else break;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
if (t[j] === "->") j = readType(tk, j + 1).next;
|
|
371
|
+
while (t[j] === "async" || t[j] === "throws") j++;
|
|
372
|
+
return t[j] === "in" && params.length ? { params } : null;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Which build target a file belongs to, as far as the directory layout says:
|
|
377
|
+
* `.../Sources/<Target>/...` and `.../Tests/<Target>/...` for a package, the
|
|
378
|
+
* first directory otherwise (an Xcode project keeps one group per target).
|
|
379
|
+
*/
|
|
380
|
+
export function targetOf(path) {
|
|
381
|
+
const parts = path.split("/");
|
|
382
|
+
for (let i = 0; i < parts.length - 2; i++) {
|
|
383
|
+
if (parts[i] === "Sources" || parts[i] === "Tests") {
|
|
384
|
+
return {
|
|
385
|
+
root: parts.slice(0, i + 2).join("/"),
|
|
386
|
+
name: parts[i + 1],
|
|
387
|
+
test: parts[i] === "Tests" || /Tests?$/.test(parts[i + 1]),
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
const name = parts.length > 1 ? parts[0] : "";
|
|
392
|
+
return { root: name, name, test: /(UI)?Tests?$/.test(name) };
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export default {
|
|
396
|
+
id: "swift",
|
|
397
|
+
targetOf,
|
|
398
|
+
stringType: "String",
|
|
399
|
+
exts: [".swift"],
|
|
400
|
+
implicitSelf: true,
|
|
401
|
+
initName: "init",
|
|
402
|
+
selfWords: new Set(["self", "Self"]),
|
|
403
|
+
superWords: new Set(["super"]),
|
|
404
|
+
newKeyword: null,
|
|
405
|
+
memberOps: new Set([".", "?.", "!."]),
|
|
406
|
+
labelOps: [":"],
|
|
407
|
+
trailingClosure: true,
|
|
408
|
+
genericCalls: true,
|
|
409
|
+
castWords: new Set(["as"]),
|
|
410
|
+
keywords: KEYWORDS,
|
|
411
|
+
declWords: new Set([
|
|
412
|
+
"func",
|
|
413
|
+
"class",
|
|
414
|
+
"struct",
|
|
415
|
+
"enum",
|
|
416
|
+
"protocol",
|
|
417
|
+
"extension",
|
|
418
|
+
"typealias",
|
|
419
|
+
"actor",
|
|
420
|
+
"case",
|
|
421
|
+
"import",
|
|
422
|
+
"let",
|
|
423
|
+
"var",
|
|
424
|
+
"init",
|
|
425
|
+
"subscript",
|
|
426
|
+
]),
|
|
427
|
+
condWords: new Set(["if", "guard", "while", ",", "case"]),
|
|
428
|
+
perNameImports: false,
|
|
429
|
+
parse,
|
|
430
|
+
localDecl,
|
|
431
|
+
lambdaParams,
|
|
432
|
+
};
|