@velarscript/cli 0.21.0 → 0.22.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/README.md +10 -0
- package/dist/application-entry.d.ts +43 -0
- package/dist/application-entry.d.ts.map +1 -1
- package/dist/application-entry.js +60 -0
- package/dist/application-entry.js.map +1 -1
- package/dist/cli.js +113 -3
- package/dist/cli.js.map +1 -1
- package/dist/language-server.d.ts.map +1 -1
- package/dist/language-server.js +72 -22
- package/dist/language-server.js.map +1 -1
- package/dist/logic-graph-output.d.ts +30 -0
- package/dist/logic-graph-output.d.ts.map +1 -0
- package/dist/logic-graph-output.js +129 -0
- package/dist/logic-graph-output.js.map +1 -0
- package/dist/mechanical-fixer.d.ts +8 -9
- package/dist/mechanical-fixer.d.ts.map +1 -1
- package/dist/mechanical-fixer.js +74 -10
- package/dist/mechanical-fixer.js.map +1 -1
- package/dist/ownership-graph.d.ts +27 -0
- package/dist/ownership-graph.d.ts.map +1 -1
- package/dist/ownership-graph.js +176 -6
- package/dist/ownership-graph.js.map +1 -1
- package/dist/project-check.d.ts +34 -0
- package/dist/project-check.d.ts.map +1 -1
- package/dist/project-check.js +57 -20
- package/dist/project-check.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +8 -8
- package/skill/ai-skill-server.md +1 -1
- package/skill/ai-skill.md +9 -4
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { relative } from "node:path";
|
|
2
|
+
const overviewKinds = new Set([
|
|
3
|
+
"module",
|
|
4
|
+
"component",
|
|
5
|
+
"state",
|
|
6
|
+
"computed",
|
|
7
|
+
"action",
|
|
8
|
+
"function",
|
|
9
|
+
"class",
|
|
10
|
+
"type",
|
|
11
|
+
"enum",
|
|
12
|
+
"capability",
|
|
13
|
+
"readonlyProjection",
|
|
14
|
+
]);
|
|
15
|
+
function portablePath(root, path) {
|
|
16
|
+
if (path === undefined)
|
|
17
|
+
return undefined;
|
|
18
|
+
const value = relative(root, path).replaceAll("\\", "/");
|
|
19
|
+
return value && !value.startsWith("../") ? value : path.replaceAll("\\", "/");
|
|
20
|
+
}
|
|
21
|
+
function focusNodes(nodes, root, query) {
|
|
22
|
+
const normalized = query.trim().toLocaleLowerCase("en-US");
|
|
23
|
+
const exact = nodes.filter((node) => node.id.toLocaleLowerCase("en-US") === normalized
|
|
24
|
+
|| node.name.toLocaleLowerCase("en-US") === normalized
|
|
25
|
+
|| portablePath(root, node.path)?.toLocaleLowerCase("en-US") === normalized);
|
|
26
|
+
if (exact.length > 0)
|
|
27
|
+
return exact;
|
|
28
|
+
return nodes.filter((node) => node.name.toLocaleLowerCase("en-US").includes(normalized)
|
|
29
|
+
|| node.id.toLocaleLowerCase("en-US").includes(normalized)
|
|
30
|
+
|| portablePath(root, node.path)?.toLocaleLowerCase("en-US").includes(normalized));
|
|
31
|
+
}
|
|
32
|
+
export function createProjectLogicGraph(graph, root, options) {
|
|
33
|
+
const selected = new Set();
|
|
34
|
+
let selectionLimitReached = false;
|
|
35
|
+
if (options.focus) {
|
|
36
|
+
const starts = focusNodes(graph.nodes, root, options.focus);
|
|
37
|
+
if (starts.length === 0)
|
|
38
|
+
throw new Error(`No ownership graph node matches '${options.focus}'`);
|
|
39
|
+
const adjacent = new Map();
|
|
40
|
+
for (const edge of graph.edges) {
|
|
41
|
+
const from = adjacent.get(edge.from) ?? [];
|
|
42
|
+
from.push(edge.to);
|
|
43
|
+
adjacent.set(edge.from, from);
|
|
44
|
+
const to = adjacent.get(edge.to) ?? [];
|
|
45
|
+
to.push(edge.from);
|
|
46
|
+
adjacent.set(edge.to, to);
|
|
47
|
+
}
|
|
48
|
+
const pending = starts.map((node) => ({ id: node.id, depth: 0 }));
|
|
49
|
+
for (let cursor = 0; cursor < pending.length; cursor += 1) {
|
|
50
|
+
const current = pending[cursor];
|
|
51
|
+
if (selected.has(current.id))
|
|
52
|
+
continue;
|
|
53
|
+
if (selected.size >= options.maximumNodes) {
|
|
54
|
+
selectionLimitReached = true;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
selected.add(current.id);
|
|
58
|
+
if (current.depth >= options.depth)
|
|
59
|
+
continue;
|
|
60
|
+
for (const id of adjacent.get(current.id) ?? []) {
|
|
61
|
+
if (!selected.has(id))
|
|
62
|
+
pending.push({ id, depth: current.depth + 1 });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
for (const node of graph.nodes) {
|
|
68
|
+
if (!overviewKinds.has(node.kind))
|
|
69
|
+
continue;
|
|
70
|
+
if (selected.size >= options.maximumNodes) {
|
|
71
|
+
selectionLimitReached = true;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
selected.add(node.id);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const nodes = graph.nodes
|
|
78
|
+
.filter((node) => selected.has(node.id))
|
|
79
|
+
.map((node) => {
|
|
80
|
+
const { path, ...rest } = node;
|
|
81
|
+
return path ? { ...rest, path: portablePath(root, path) } : rest;
|
|
82
|
+
});
|
|
83
|
+
const eligibleEdges = graph.edges.filter((edge) => selected.has(edge.from) && selected.has(edge.to));
|
|
84
|
+
if (eligibleEdges.length > options.maximumEdges)
|
|
85
|
+
selectionLimitReached = true;
|
|
86
|
+
const edges = eligibleEdges.slice(0, options.maximumEdges)
|
|
87
|
+
.map((edge) => {
|
|
88
|
+
const { path, ...rest } = edge;
|
|
89
|
+
return path ? { ...rest, path: portablePath(root, path) } : rest;
|
|
90
|
+
});
|
|
91
|
+
return {
|
|
92
|
+
protocolVersion: 1,
|
|
93
|
+
revision: graph.revision,
|
|
94
|
+
root,
|
|
95
|
+
focus: options.focus ?? null,
|
|
96
|
+
depth: options.focus ? options.depth : 0,
|
|
97
|
+
diagnostics: options.diagnostics,
|
|
98
|
+
nodes,
|
|
99
|
+
edges,
|
|
100
|
+
coverage: graph.coverage,
|
|
101
|
+
sourceLimitReached: graph.limitReached,
|
|
102
|
+
selectionLimitReached,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function oneLine(value) {
|
|
106
|
+
return value.replaceAll(/\s+/gu, " ").trim();
|
|
107
|
+
}
|
|
108
|
+
export function renderProjectLogicGraph(view) {
|
|
109
|
+
const aliases = new Map(view.nodes.map((node, index) => [node.id, `n${index + 1}`]));
|
|
110
|
+
const lines = [
|
|
111
|
+
`velar-logic-graph v${view.protocolVersion} revision=${view.revision}`,
|
|
112
|
+
`scope=${view.focus ? `focus:${JSON.stringify(view.focus)} depth:${view.depth}` : "project-overview"} nodes=${view.nodes.length} edges=${view.edges.length} diagnostics=${view.diagnostics}`,
|
|
113
|
+
`coverage=${view.coverage.modulesIncluded}/${view.coverage.modulesTotal} complete=${view.coverage.complete} sourceLimit=${view.sourceLimitReached} selectionLimit=${view.selectionLimitReached}`,
|
|
114
|
+
"nodes:",
|
|
115
|
+
];
|
|
116
|
+
for (const node of view.nodes) {
|
|
117
|
+
const location = node.path ? ` ${node.path}${node.selectionSpan ? `@${node.selectionSpan.start}:${node.selectionSpan.end}` : ""}` : "";
|
|
118
|
+
const flags = [node.exported ? "exported" : "", node.mutable ? "mutable" : ""].filter(Boolean).join(",");
|
|
119
|
+
const type = node.type ? ` type=${JSON.stringify(oneLine(node.type))}` : "";
|
|
120
|
+
const documentation = node.documentation ? ` doc=${JSON.stringify(oneLine(node.documentation))}` : "";
|
|
121
|
+
lines.push(`${aliases.get(node.id)} ${node.kind} ${JSON.stringify(node.name)}${location}${flags ? ` [${flags}]` : ""}${type}${documentation}`);
|
|
122
|
+
}
|
|
123
|
+
lines.push("edges:");
|
|
124
|
+
for (const edge of view.edges) {
|
|
125
|
+
lines.push(`${aliases.get(edge.from)} -${edge.kind}-> ${aliases.get(edge.to)}`);
|
|
126
|
+
}
|
|
127
|
+
return `${lines.join("\n")}\n`;
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=logic-graph-output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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,CAAC,IAAI,CAAC,GAAG,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,GAAG,aAAa,EAAE,CAAC,CAAC;IACjJ,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QAC9B,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAClF,CAAC;IACD,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACjC,CAAC"}
|
|
@@ -19,14 +19,13 @@ export interface MechanicalFixReport {
|
|
|
19
19
|
* stage run and report its own mechanical guidance in turn. It stops when a
|
|
20
20
|
* pass changes nothing, which is exactly what makes a second `velar fix` a
|
|
21
21
|
* no-op.
|
|
22
|
+
*
|
|
23
|
+
* The scope is not a parameter: `input` is the same argument `velar check`
|
|
24
|
+
* takes, and the roots and the project-layer rules are both derived from it
|
|
25
|
+
* through the functions `check` derives them from. A fixer handed a
|
|
26
|
+
* pre-computed scope is a fixer that can be handed a different one, and the
|
|
27
|
+
* defect this shape exists to prevent is precisely the two commands reading
|
|
28
|
+
* one tree two ways.
|
|
22
29
|
*/
|
|
23
|
-
export declare function applyProjectMechanicalFixes(config: VelarProjectConfig, displayPath: (path: string) => string, maximumPasses?: number
|
|
24
|
-
/**
|
|
25
|
-
* D51 (audit 12): extra roots the module graph does not reach — `*.test.vel`
|
|
26
|
-
* modules nobody imports, and every other source nothing imports either. Both
|
|
27
|
-
* are source the author owns, so `fix` rewrites them on the same terms as
|
|
28
|
-
* every other module, and on the same terms `velar check` reads them: a
|
|
29
|
-
* diagnostic `check` refuses over must be one `fix` can reach.
|
|
30
|
-
*/
|
|
31
|
-
additionalEntries?: readonly string[]): Promise<MechanicalFixReport>;
|
|
30
|
+
export declare function applyProjectMechanicalFixes(config: VelarProjectConfig, input: string | null, displayPath: (path: string) => string, maximumPasses?: number): Promise<MechanicalFixReport>;
|
|
32
31
|
//# sourceMappingURL=mechanical-fixer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mechanical-fixer.d.ts","sourceRoot":"","sources":["../src/mechanical-fixer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"mechanical-fixer.d.ts","sourceRoot":"","sources":["../src/mechanical-fixer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAMtD,MAAM,WAAW,mBAAmB;IAClC,gFAAgF;IAChF,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,QAAQ,CAAC,oBAAoB,EAAE,SAAS,MAAM,EAAE,CAAC;IACjD;;;;;OAKG;IACH,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,MAAM,GAAG,IAAI,EACpB,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EACrC,aAAa,SAAI,GAChB,OAAO,CAAC,mBAAmB,CAAC,CA4I9B"}
|
package/dist/mechanical-fixer.js
CHANGED
|
@@ -5,6 +5,7 @@ import { basename, dirname, isAbsolute, join, relative } from "node:path";
|
|
|
5
5
|
import { applyMechanicalFixes, formatDiagnostic } from "@velarscript/compiler";
|
|
6
6
|
import { hostErrorMessage } from "./host-error.js";
|
|
7
7
|
import { compileProject } from "./project.js";
|
|
8
|
+
import { additionalProjectRoots, projectLayerFindings } from "./project-check.js";
|
|
8
9
|
import { readVelarSourceFile } from "./source-limits.js";
|
|
9
10
|
/**
|
|
10
11
|
* D38 §48: the `velar fix` engine. It applies every rewrite the compile itself
|
|
@@ -12,19 +13,23 @@ import { readVelarSourceFile } from "./source-limits.js";
|
|
|
12
13
|
* stage run and report its own mechanical guidance in turn. It stops when a
|
|
13
14
|
* pass changes nothing, which is exactly what makes a second `velar fix` a
|
|
14
15
|
* no-op.
|
|
16
|
+
*
|
|
17
|
+
* The scope is not a parameter: `input` is the same argument `velar check`
|
|
18
|
+
* takes, and the roots and the project-layer rules are both derived from it
|
|
19
|
+
* through the functions `check` derives them from. A fixer handed a
|
|
20
|
+
* pre-computed scope is a fixer that can be handed a different one, and the
|
|
21
|
+
* defect this shape exists to prevent is precisely the two commands reading
|
|
22
|
+
* one tree two ways.
|
|
15
23
|
*/
|
|
16
|
-
export async function applyProjectMechanicalFixes(config, displayPath, maximumPasses = 8
|
|
17
|
-
/**
|
|
18
|
-
* D51 (audit 12): extra roots the module graph does not reach — `*.test.vel`
|
|
19
|
-
* modules nobody imports, and every other source nothing imports either. Both
|
|
20
|
-
* are source the author owns, so `fix` rewrites them on the same terms as
|
|
21
|
-
* every other module, and on the same terms `velar check` reads them: a
|
|
22
|
-
* diagnostic `check` refuses over must be one `fix` can reach.
|
|
23
|
-
*/
|
|
24
|
-
additionalEntries = []) {
|
|
24
|
+
export async function applyProjectMechanicalFixes(config, input, displayPath, maximumPasses = 8) {
|
|
25
25
|
const changes = [];
|
|
26
26
|
const changedFiles = new Set();
|
|
27
|
-
|
|
27
|
+
// D51 (audit 12): extra roots the module graph does not reach — `*.test.vel`
|
|
28
|
+
// modules nobody imports, and every other source nothing imports either. Both
|
|
29
|
+
// are source the author owns, so `fix` rewrites them on the same terms as
|
|
30
|
+
// every other module, and on the same terms `velar check` reads them: a
|
|
31
|
+
// diagnostic `check` refuses over must be one `fix` can reach.
|
|
32
|
+
const entries = [config.entryPath, ...await additionalProjectRoots(config, input)];
|
|
28
33
|
const compile = async () => {
|
|
29
34
|
const results = [];
|
|
30
35
|
// A root an earlier root already walked needs no compile of its own: the
|
|
@@ -60,6 +65,7 @@ additionalEntries = []) {
|
|
|
60
65
|
passes += 1;
|
|
61
66
|
const writes = [];
|
|
62
67
|
const visited = new Set();
|
|
68
|
+
const targets = new Set();
|
|
63
69
|
for (const module of projects.flatMap((result) => result.modules)) {
|
|
64
70
|
if (visited.has(module.inputPath))
|
|
65
71
|
continue;
|
|
@@ -75,12 +81,48 @@ additionalEntries = []) {
|
|
|
75
81
|
const result = applyMechanicalFixes(source.text, module.result.diagnostics);
|
|
76
82
|
if (result.applied.length === 0)
|
|
77
83
|
continue;
|
|
84
|
+
// One file is written once per pass, whatever it is called. Two roots
|
|
85
|
+
// reach one file whenever the author gave it two names — a link inside
|
|
86
|
+
// `src/` pointing at a shared module, a module hard-linked under a second
|
|
87
|
+
// name — and each name is a module of its own to the compiler. The second
|
|
88
|
+
// write would be computed from the same snapshot as the first, so it
|
|
89
|
+
// would either race it or fail its own re-read, and it would report the
|
|
90
|
+
// same rewrite twice.
|
|
91
|
+
const identity = await writeIdentity(module.inputPath);
|
|
92
|
+
if (targets.has(identity))
|
|
93
|
+
continue;
|
|
94
|
+
targets.add(identity);
|
|
78
95
|
const lines = result.applied.map((fix) => {
|
|
79
96
|
const location = source.location(fix.offset);
|
|
80
97
|
return `${displayPath(module.inputPath)}:${location.line}:${location.column} fixed ${fix.code}: ${fix.title}`;
|
|
81
98
|
});
|
|
82
99
|
writes.push({ path: module.inputPath, lines, write: replaceSourceFile(module.inputPath, source.text, result.text) });
|
|
83
100
|
}
|
|
101
|
+
// The project layer's own rewrites, from the same rules `velar check`
|
|
102
|
+
// refuses on. They are withheld from a pass that already rewrote something:
|
|
103
|
+
// both kinds are computed from one snapshot, and two whole-file writes
|
|
104
|
+
// against one snapshot cannot both be what the file should hold. The loop
|
|
105
|
+
// recompiles and applies it on the next pass — the same deferral
|
|
106
|
+
// `applyMechanicalFixes` uses for two edits that overlap.
|
|
107
|
+
if (writes.length === 0) {
|
|
108
|
+
// `entries[0]` is the project entry and no earlier root can have covered
|
|
109
|
+
// it, so the first result is the entry's own project — the one the
|
|
110
|
+
// project-layer rules are about.
|
|
111
|
+
for (const finding of projectLayerFindings(config, input, projects[0])) {
|
|
112
|
+
const fix = finding.fix;
|
|
113
|
+
if (!fix)
|
|
114
|
+
continue;
|
|
115
|
+
const module = projects[0].modules.find((item) => item.inputPath === fix.path);
|
|
116
|
+
if (!module || !await ownedByProject(config, module))
|
|
117
|
+
continue;
|
|
118
|
+
const location = module.result.source.location(fix.offset);
|
|
119
|
+
writes.push({
|
|
120
|
+
path: fix.path,
|
|
121
|
+
lines: [`${displayPath(fix.path)}:${location.line}:${location.column} fixed ${fix.code}: ${fix.title}`],
|
|
122
|
+
write: replaceSourceFile(fix.path, fix.expected, fix.text),
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
84
126
|
pending = writes.length > 0;
|
|
85
127
|
if (!pending)
|
|
86
128
|
break;
|
|
@@ -122,6 +164,14 @@ additionalEntries = []) {
|
|
|
122
164
|
remaining.push(...module.result.diagnostics.map((item) => formatDiagnostic(module.result.source, item)));
|
|
123
165
|
}
|
|
124
166
|
}
|
|
167
|
+
// What the project layer still refuses over the tree as it now stands on
|
|
168
|
+
// disk. A finding that carried no rewrite is reported here rather than
|
|
169
|
+
// silently dropped, and a rewrite the passes above could not land is reported
|
|
170
|
+
// here too, because this is read from the files rather than from the run:
|
|
171
|
+
// `velar fix` may never claim a tree is clean that `velar check` will refuse.
|
|
172
|
+
if (projects !== null && projects.length > 0) {
|
|
173
|
+
remaining.push(...projectLayerFindings(config, input, projects[0]).map((finding) => finding.message));
|
|
174
|
+
}
|
|
125
175
|
return { changes, changedFiles: [...changedFiles].sort(), remainingDiagnostics: remaining, writeFailures, passes };
|
|
126
176
|
}
|
|
127
177
|
/**
|
|
@@ -169,6 +219,20 @@ function containedByProject(root, path) {
|
|
|
169
219
|
const segments = pathSegments(within);
|
|
170
220
|
return !segments.includes("..") && !segments.includes("node_modules");
|
|
171
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* The file a path names, as the filesystem itself identifies it. A path the
|
|
224
|
+
* fixer cannot stat is answered with the path, which makes it its own identity
|
|
225
|
+
* and leaves the failure to the write, where it is reported.
|
|
226
|
+
*/
|
|
227
|
+
async function writeIdentity(path) {
|
|
228
|
+
try {
|
|
229
|
+
const metadata = await stat(path);
|
|
230
|
+
return `${metadata.dev}:${metadata.ino}`;
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
return path;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
172
236
|
/** A path that does not exist is its own real path; the write reports the rest. */
|
|
173
237
|
async function resolvedPath(path) {
|
|
174
238
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mechanical-fixer.js","sourceRoot":"","sources":["../src/mechanical-fixer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,cAAc,EAA0C,MAAM,cAAc,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,MAA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AAG,CAAC,EAAE,CAAC;QACvB,6EAA6E;QAC7E,0EAA0E;QAC1E,sEAAsE;QACtE,4EAA4E;QAC5E,MAAM,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QACtC,OAAO;IACT,CAAC;IACD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,QAAQ,CAAC,MAAM,CAAC,cAAc,UAAU,EAAE,EAAE,CAAC,CAAC;IAC1F,MAAM,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,KAAK,EAAE,CAAC,CAAC;IACpF,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAClC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACrC,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -6,6 +6,8 @@ export interface OwnershipGraphNode {
|
|
|
6
6
|
readonly id: string;
|
|
7
7
|
readonly kind: OwnershipNodeKind;
|
|
8
8
|
readonly name: string;
|
|
9
|
+
/** Compiler-owned declaration documentation, used by presentation clients as a human label. */
|
|
10
|
+
readonly documentation?: string;
|
|
9
11
|
readonly path?: string;
|
|
10
12
|
readonly span?: Span;
|
|
11
13
|
readonly selectionSpan?: Span;
|
|
@@ -35,12 +37,37 @@ export interface OwnershipGraphResult {
|
|
|
35
37
|
readonly coverage: OwnershipGraphCoverage;
|
|
36
38
|
readonly limitReached: boolean;
|
|
37
39
|
readonly durationMs: number;
|
|
40
|
+
readonly activity: {
|
|
41
|
+
readonly strategy: "full" | "affected-modules";
|
|
42
|
+
readonly modulesVisited: number;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* One revision-to-revision ownership update. IDs remain compiler-owned and
|
|
47
|
+
* stable, so an editor or AI host can patch its current view without replacing
|
|
48
|
+
* the whole graph after every keystroke.
|
|
49
|
+
*/
|
|
50
|
+
export interface OwnershipGraphDelta {
|
|
51
|
+
readonly baseRevision: string;
|
|
52
|
+
readonly revision: string;
|
|
53
|
+
readonly nodes: readonly OwnershipGraphNode[];
|
|
54
|
+
readonly edges: readonly OwnershipGraphEdge[];
|
|
55
|
+
readonly removedNodeIds: readonly string[];
|
|
56
|
+
readonly removedEdgeIds: readonly string[];
|
|
38
57
|
}
|
|
39
58
|
export interface OwnershipGraphOptions {
|
|
40
59
|
readonly maximumNodes?: number;
|
|
41
60
|
readonly maximumEdges?: number;
|
|
42
61
|
readonly cancelled?: () => boolean;
|
|
43
62
|
}
|
|
63
|
+
/** Produces a transport patch from two complete graphs without interpreting source text. */
|
|
64
|
+
export declare function ownershipGraphDelta(previous: OwnershipGraphResult, current: OwnershipGraphResult): OwnershipGraphDelta;
|
|
44
65
|
export declare function ownershipGraphRevision(project: ProjectResult): string;
|
|
45
66
|
export declare function buildOwnershipGraph(project: ProjectResult, options?: OwnershipGraphOptions): Promise<OwnershipGraphResult>;
|
|
67
|
+
/**
|
|
68
|
+
* Reuses graph fragments whose compiler module result was reused by the
|
|
69
|
+
* incremental project session. A bounded/truncated base cannot be patched
|
|
70
|
+
* safely, so that uncommon case deliberately falls back to a full build.
|
|
71
|
+
*/
|
|
72
|
+
export declare function updateOwnershipGraph(previousGraph: OwnershipGraphResult, previousProject: ProjectResult, project: ProjectResult, options?: OwnershipGraphOptions): Promise<OwnershipGraphResult>;
|
|
46
73
|
//# sourceMappingURL=ownership-graph.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ownership-graph.d.ts","sourceRoot":"","sources":["../src/ownership-graph.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAqC,IAAI,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAwC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