@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,397 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file kotlin.mjs - Kotlin profile for the call-edge scanner.
|
|
3
|
+
*
|
|
4
|
+
* Reads classes, interfaces, objects (and companions as static members of the
|
|
5
|
+
* enclosing type), extension functions, primary-constructor properties and
|
|
6
|
+
* expression-bodied functions. Not modelled: scope functions that rebind
|
|
7
|
+
* `this` (`apply`, `with`, `run`), delegated properties, type inference beyond
|
|
8
|
+
* a constructor call or an annotation, and overload resolution by argument
|
|
9
|
+
* type.
|
|
10
|
+
*
|
|
11
|
+
* @module pipeline/scripts/call-graph/lang/kotlin
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { isIdent, readType, skipAngles, tick, MAX_HEADER_TOKENS } from "../lex.mjs";
|
|
15
|
+
import { genericNames, skipAnnotations, typeList, exprEnd, paramsColon } from "./shared.mjs";
|
|
16
|
+
|
|
17
|
+
const MODS = new Set(
|
|
18
|
+
`public private protected internal open final abstract override sealed data inner value inline
|
|
19
|
+
suspend operator infix lateinit const tailrec external annotation actual expect vararg crossinline
|
|
20
|
+
noinline reified enum`.split(/\s+/),
|
|
21
|
+
);
|
|
22
|
+
const TYPE_KW = new Set(["class", "interface", "object"]);
|
|
23
|
+
const KEYWORDS = new Set(
|
|
24
|
+
`if else when for while do try catch finally return throw break continue in is as object class
|
|
25
|
+
interface fun val var typealias package import true false null constructor init by where get set
|
|
26
|
+
out`.split(/\s+/),
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
function parse(tk) {
|
|
30
|
+
const t = tk.t;
|
|
31
|
+
const types = [];
|
|
32
|
+
const fns = [];
|
|
33
|
+
const gl = {};
|
|
34
|
+
|
|
35
|
+
const walk = (from, to, owner, ownerKind, isCompanion) => {
|
|
36
|
+
let i = from;
|
|
37
|
+
while (i < to) {
|
|
38
|
+
tick(tk);
|
|
39
|
+
i = skipAnnotations(tk, i);
|
|
40
|
+
const s = t[i];
|
|
41
|
+
if (s === undefined || i >= to) break;
|
|
42
|
+
if (s === "@") {
|
|
43
|
+
i++;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (
|
|
47
|
+
MODS.has(s) &&
|
|
48
|
+
!(s === "enum" && t[i + 1] !== "class") &&
|
|
49
|
+
!(s === "annotation" && t[i + 1] !== "class")
|
|
50
|
+
) {
|
|
51
|
+
i++;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (s === "fun" && t[i + 1] === "interface") {
|
|
55
|
+
i++;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (s === "companion" && t[i + 1] === "object") {
|
|
59
|
+
i = companion(i, to, owner);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (TYPE_KW.has(s) && isIdent(t[i + 1])) {
|
|
63
|
+
i = typeDecl(i, to, owner);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (s === "fun") {
|
|
67
|
+
i = funDecl(i, to, owner, ownerKind, isCompanion);
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (s === "constructor" && t[i + 1] === "(" && owner) {
|
|
71
|
+
i = ctorDecl(i, to, owner);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (s === "init" && t[i + 1] === "{" && owner && tk.m[i + 1] > i) {
|
|
75
|
+
fns.push({
|
|
76
|
+
n: "<init>",
|
|
77
|
+
o: owner,
|
|
78
|
+
a: [0, 0],
|
|
79
|
+
p: [],
|
|
80
|
+
r: null,
|
|
81
|
+
l: tk.line[i],
|
|
82
|
+
e: tk.line[tk.m[i + 1]],
|
|
83
|
+
body: [i + 2, tk.m[i + 1]],
|
|
84
|
+
});
|
|
85
|
+
i = tk.m[i + 1] + 1;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if ((s === "val" || s === "var") && (owner || tk.dep[i] === 0)) {
|
|
89
|
+
i = propDecl(i, to, owner, isCompanion);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (s === "{" && tk.m[i] > i) {
|
|
93
|
+
i = tk.m[i] + 1;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
i++;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const companion = (i, to, owner) => {
|
|
101
|
+
let j = i + 2;
|
|
102
|
+
if (isIdent(t[j]) && t[j] !== "{") j++;
|
|
103
|
+
if (t[j] === ":") {
|
|
104
|
+
const lim = Math.min(to, j + MAX_HEADER_TOKENS);
|
|
105
|
+
while (j < lim && t[j] !== "{") j++;
|
|
106
|
+
}
|
|
107
|
+
if (t[j] !== "{" || tk.m[j] < 0) return i + 2;
|
|
108
|
+
walk(j + 1, tk.m[j], owner, "class", true);
|
|
109
|
+
return tk.m[j] + 1;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const typeDecl = (i, to, outer) => {
|
|
113
|
+
const kw = t[i];
|
|
114
|
+
let j = i + 1;
|
|
115
|
+
const name = t[j];
|
|
116
|
+
j++;
|
|
117
|
+
const g = genericNames(tk, j);
|
|
118
|
+
j = g.next;
|
|
119
|
+
const fields = {};
|
|
120
|
+
let ctorParams = null;
|
|
121
|
+
while (t[j] === "private" || t[j] === "internal" || t[j] === "public" || t[j] === "protected")
|
|
122
|
+
j++;
|
|
123
|
+
if (t[j] === "constructor") j++;
|
|
124
|
+
if (t[j] === "(" && tk.m[j] > j) {
|
|
125
|
+
ctorParams = j;
|
|
126
|
+
const sig = paramsColon(tk, j, { mods: MODS });
|
|
127
|
+
for (let k = j + 1; k < tk.m[j]; k++) {
|
|
128
|
+
if ((t[k] === "val" || t[k] === "var") && isIdent(t[k + 1]) && t[k + 2] === ":") {
|
|
129
|
+
const r = readType(tk, k + 3, { limit: tk.m[j] });
|
|
130
|
+
if (r.name) fields[t[k + 1]] = r.name;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
fns.push({
|
|
134
|
+
n: "constructor",
|
|
135
|
+
o: name,
|
|
136
|
+
a: [sig.min, sig.max],
|
|
137
|
+
p: sig.params,
|
|
138
|
+
r: name,
|
|
139
|
+
l: tk.line[i],
|
|
140
|
+
e: tk.line[tk.m[j]],
|
|
141
|
+
});
|
|
142
|
+
j = tk.m[j] + 1;
|
|
143
|
+
}
|
|
144
|
+
let sup = [];
|
|
145
|
+
if (t[j] === ":") {
|
|
146
|
+
let k = j + 1;
|
|
147
|
+
while (
|
|
148
|
+
k < to &&
|
|
149
|
+
t[k] !== "{" &&
|
|
150
|
+
t[k] !== "where" &&
|
|
151
|
+
!(tk.first[k] && k > j + 1 && tk.dep[k] === tk.dep[i])
|
|
152
|
+
)
|
|
153
|
+
k++;
|
|
154
|
+
sup = typeList(tk, j + 1, k);
|
|
155
|
+
j = k;
|
|
156
|
+
}
|
|
157
|
+
if (t[j] === "where") {
|
|
158
|
+
const lim = Math.min(to, j + MAX_HEADER_TOKENS);
|
|
159
|
+
while (j < lim && t[j] !== "{") j++;
|
|
160
|
+
}
|
|
161
|
+
const hasBody =
|
|
162
|
+
t[j] === "{" &&
|
|
163
|
+
tk.m[j] > j &&
|
|
164
|
+
!(tk.first[j] && j > i && tk.line[j] > tk.line[i] + 1 && false);
|
|
165
|
+
const rec = {
|
|
166
|
+
n: name,
|
|
167
|
+
k: kw === "class" ? "class" : kw,
|
|
168
|
+
line: tk.line[i],
|
|
169
|
+
end: hasBody ? tk.line[tk.m[j]] : tk.line[Math.max(i, j - 1)],
|
|
170
|
+
sup,
|
|
171
|
+
...(outer ? { outer } : {}),
|
|
172
|
+
...(g.gen.length ? { gen: g.gen } : {}),
|
|
173
|
+
f: fields,
|
|
174
|
+
};
|
|
175
|
+
types.push(rec);
|
|
176
|
+
if (ctorParams === null && !hasBody) return j;
|
|
177
|
+
if (hasBody) {
|
|
178
|
+
walk(j + 1, tk.m[j], name, kw, false);
|
|
179
|
+
return tk.m[j] + 1;
|
|
180
|
+
}
|
|
181
|
+
return j;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const ctorDecl = (i, to, owner) => {
|
|
185
|
+
const sig = paramsColon(tk, i + 1);
|
|
186
|
+
let j = tk.m[i + 1] + 1;
|
|
187
|
+
if (t[j] === ":") {
|
|
188
|
+
const lim = Math.min(to, j + MAX_HEADER_TOKENS);
|
|
189
|
+
while (j < lim && t[j] !== "{") j++;
|
|
190
|
+
}
|
|
191
|
+
const body = t[j] === "{" && tk.m[j] > j ? [j + 1, tk.m[j]] : null;
|
|
192
|
+
fns.push({
|
|
193
|
+
n: "constructor",
|
|
194
|
+
o: owner,
|
|
195
|
+
a: [sig.min, sig.max],
|
|
196
|
+
p: sig.params,
|
|
197
|
+
r: owner,
|
|
198
|
+
l: tk.line[i],
|
|
199
|
+
e: tk.line[body ? body[1] : i],
|
|
200
|
+
body,
|
|
201
|
+
});
|
|
202
|
+
return body ? body[1] + 1 : j;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const funDecl = (i, to, owner, ownerKind, isCompanion) => {
|
|
206
|
+
let j = i + 1;
|
|
207
|
+
const g = genericNames(tk, j);
|
|
208
|
+
j = g.next;
|
|
209
|
+
let recv = null;
|
|
210
|
+
let name = null;
|
|
211
|
+
let open = j;
|
|
212
|
+
while (open < to && t[open] !== "(" && t[open] !== "{" && t[open] !== "=") {
|
|
213
|
+
open = t[open] === "<" ? Math.max(skipAngles(tk, open, to), open + 1) : open + 1;
|
|
214
|
+
}
|
|
215
|
+
if (t[open] === "(" && isIdent(t[open - 1])) {
|
|
216
|
+
name = t[open - 1];
|
|
217
|
+
if (t[open - 2] === "." && open - 2 > j) {
|
|
218
|
+
recv = readType(tk, j, { limit: open - 2 }).name;
|
|
219
|
+
}
|
|
220
|
+
j = open;
|
|
221
|
+
}
|
|
222
|
+
if (!name || t[j] !== "(" || tk.m[j] < 0) return i + 1;
|
|
223
|
+
const sig = paramsColon(tk, j, { mods: MODS });
|
|
224
|
+
j = tk.m[j] + 1;
|
|
225
|
+
let ret = null;
|
|
226
|
+
if (t[j] === ":") {
|
|
227
|
+
const r = readType(tk, j + 1, { limit: to });
|
|
228
|
+
ret = r.name;
|
|
229
|
+
j = r.next;
|
|
230
|
+
}
|
|
231
|
+
while (j < to && t[j] === "where") while (j < to && t[j] !== "{" && t[j] !== "=") j++;
|
|
232
|
+
let body = null;
|
|
233
|
+
let next = j;
|
|
234
|
+
if (t[j] === "{" && tk.m[j] > j) {
|
|
235
|
+
body = [j + 1, tk.m[j]];
|
|
236
|
+
next = tk.m[j] + 1;
|
|
237
|
+
} else if (t[j] === "=") {
|
|
238
|
+
const end = exprEnd(tk, j + 1, to);
|
|
239
|
+
body = [j + 1, end];
|
|
240
|
+
next = end;
|
|
241
|
+
}
|
|
242
|
+
fns.push({
|
|
243
|
+
n: name,
|
|
244
|
+
o: recv || owner,
|
|
245
|
+
a: [sig.min, sig.max],
|
|
246
|
+
p: sig.params,
|
|
247
|
+
r: ret,
|
|
248
|
+
l: tk.line[i],
|
|
249
|
+
e: tk.line[Math.max(i, next - 1)],
|
|
250
|
+
...(isCompanion || ownerKind === "object" ? { s: 1 } : {}),
|
|
251
|
+
...(ownerKind === "interface" && !body ? { ab: 1 } : {}),
|
|
252
|
+
...(g.gen.length ? { g: g.gen } : {}),
|
|
253
|
+
body,
|
|
254
|
+
});
|
|
255
|
+
return Math.max(next, i + 1);
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
const propDecl = (i, to, owner) => {
|
|
259
|
+
let j = i + 1;
|
|
260
|
+
if (t[j] === "<") j = genericNames(tk, j).next;
|
|
261
|
+
if (!isIdent(t[j])) return i + 1;
|
|
262
|
+
let recv = null;
|
|
263
|
+
if (t[j + 1] === "." && isIdent(t[j + 2])) {
|
|
264
|
+
recv = t[j];
|
|
265
|
+
j += 2;
|
|
266
|
+
}
|
|
267
|
+
const name = t[j];
|
|
268
|
+
j++;
|
|
269
|
+
let type = null;
|
|
270
|
+
if (t[j] === ":") {
|
|
271
|
+
const r = readType(tk, j + 1, { limit: to });
|
|
272
|
+
type = r.name;
|
|
273
|
+
j = r.next;
|
|
274
|
+
}
|
|
275
|
+
if (t[j] === "=" && !type && isIdent(t[j + 1]) && /^[A-Z]/.test(t[j + 1]) && t[j + 2] === "(")
|
|
276
|
+
type = t[j + 1];
|
|
277
|
+
const target = recv || owner;
|
|
278
|
+
if (target && type) {
|
|
279
|
+
const rec = [...types].reverse().find((x) => x.n === target);
|
|
280
|
+
if (rec) rec.f[name] = type;
|
|
281
|
+
else if (recv)
|
|
282
|
+
types.push({
|
|
283
|
+
n: recv,
|
|
284
|
+
k: "ext",
|
|
285
|
+
line: tk.line[i],
|
|
286
|
+
end: tk.line[i],
|
|
287
|
+
sup: [],
|
|
288
|
+
f: { [name]: type },
|
|
289
|
+
});
|
|
290
|
+
} else if (!owner && type) gl[name] = type;
|
|
291
|
+
return j;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
walk(0, tk.n, null, null, false);
|
|
295
|
+
return { types, fns, binds: [], gl };
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function localDecl(tk, i, end) {
|
|
299
|
+
const t = tk.t;
|
|
300
|
+
const s = t[i];
|
|
301
|
+
if (s === "fun" && isIdent(t[i + 1]) && t[i + 1] !== "interface")
|
|
302
|
+
return { name: t[i + 1], type: null, init: null, next: i + 2 };
|
|
303
|
+
if (s === "val" || s === "var") {
|
|
304
|
+
let j = i + 1;
|
|
305
|
+
if (t[j] === "(") {
|
|
306
|
+
const names = [];
|
|
307
|
+
for (let k = j + 1; k < tk.m[j]; k++) if (isIdent(t[k]) && t[k] !== "_") names.push(t[k]);
|
|
308
|
+
const after = tk.m[j] + 1;
|
|
309
|
+
return {
|
|
310
|
+
name: names[0] || "_",
|
|
311
|
+
also: names.slice(1),
|
|
312
|
+
type: null,
|
|
313
|
+
init: t[after] === "=" ? after + 1 : null,
|
|
314
|
+
next: after,
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
if (!isIdent(t[j])) return null;
|
|
318
|
+
const name = t[j];
|
|
319
|
+
j++;
|
|
320
|
+
let type = null;
|
|
321
|
+
if (t[j] === ":") {
|
|
322
|
+
const r = readType(tk, j + 1, { limit: end });
|
|
323
|
+
type = r.name;
|
|
324
|
+
j = r.next;
|
|
325
|
+
}
|
|
326
|
+
if (t[j] === "=" || t[j] === "by")
|
|
327
|
+
return { name, type, init: t[j] === "=" ? j + 1 : null, next: j + 1 };
|
|
328
|
+
return type ? { name, type, init: null, next: j } : null;
|
|
329
|
+
}
|
|
330
|
+
if (s === "for" && t[i + 1] === "(") {
|
|
331
|
+
const names = [];
|
|
332
|
+
for (let k = i + 2; k < tk.m[i + 1] && t[k] !== "in"; k++)
|
|
333
|
+
if (isIdent(t[k]) && t[k] !== "_") names.push(t[k]);
|
|
334
|
+
return names.length
|
|
335
|
+
? { name: names[0], also: names.slice(1), type: null, init: null, next: i + 2 }
|
|
336
|
+
: null;
|
|
337
|
+
}
|
|
338
|
+
if (s === "catch" && t[i + 1] === "(" && isIdent(t[i + 2]) && t[i + 3] === ":") {
|
|
339
|
+
const r = readType(tk, i + 4, { limit: tk.m[i + 1] });
|
|
340
|
+
return { name: t[i + 2], type: r.name, init: null, next: i + 2 };
|
|
341
|
+
}
|
|
342
|
+
return null;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function lambdaParams(tk, i, end) {
|
|
346
|
+
const t = tk.t;
|
|
347
|
+
if (t[i] !== "{") return null;
|
|
348
|
+
let j = i + 1;
|
|
349
|
+
const params = [];
|
|
350
|
+
while (j < end && isIdent(t[j])) {
|
|
351
|
+
let type = null;
|
|
352
|
+
const name = t[j];
|
|
353
|
+
j++;
|
|
354
|
+
if (t[j] === ":") {
|
|
355
|
+
const r = readType(tk, j + 1, { limit: end });
|
|
356
|
+
type = r.name;
|
|
357
|
+
j = r.next;
|
|
358
|
+
}
|
|
359
|
+
params.push([name, type]);
|
|
360
|
+
if (t[j] === ",") j++;
|
|
361
|
+
else break;
|
|
362
|
+
}
|
|
363
|
+
return t[j] === "->" && params.length ? { params } : null;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
export default {
|
|
367
|
+
id: "kotlin",
|
|
368
|
+
stringType: "String",
|
|
369
|
+
exts: [".kt", ".kts"],
|
|
370
|
+
implicitSelf: true,
|
|
371
|
+
initName: "constructor",
|
|
372
|
+
selfWords: new Set(["this"]),
|
|
373
|
+
superWords: new Set(["super"]),
|
|
374
|
+
newKeyword: null,
|
|
375
|
+
memberOps: new Set([".", "?.", "!."]),
|
|
376
|
+
labelOps: ["="],
|
|
377
|
+
trailingClosure: true,
|
|
378
|
+
genericCalls: true,
|
|
379
|
+
castWords: new Set(["as"]),
|
|
380
|
+
keywords: KEYWORDS,
|
|
381
|
+
declWords: new Set([
|
|
382
|
+
"fun",
|
|
383
|
+
"class",
|
|
384
|
+
"interface",
|
|
385
|
+
"object",
|
|
386
|
+
"val",
|
|
387
|
+
"var",
|
|
388
|
+
"typealias",
|
|
389
|
+
"package",
|
|
390
|
+
"import",
|
|
391
|
+
]),
|
|
392
|
+
condWords: new Set(["if", "while", "when"]),
|
|
393
|
+
union: false,
|
|
394
|
+
parse,
|
|
395
|
+
localDecl,
|
|
396
|
+
lambdaParams,
|
|
397
|
+
};
|