@nanonets/graft 0.5.1 → 0.6.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 +9 -7
- package/dist/ask/ask.d.ts +3 -0
- package/dist/ask/ask.d.ts.map +1 -1
- package/dist/ask/ask.js +7 -17
- package/dist/ask/ask.js.map +1 -1
- package/dist/claude/init.d.ts +3 -0
- package/dist/claude/init.d.ts.map +1 -1
- package/dist/claude/init.js +6 -1
- package/dist/claude/init.js.map +1 -1
- package/dist/claude/skill-template.d.ts.map +1 -1
- package/dist/claude/skill-template.js +16 -9
- package/dist/claude/skill-template.js.map +1 -1
- package/dist/cli.d.ts +3 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +25 -30
- package/dist/cli.js.map +1 -1
- package/dist/context/savings.d.ts +34 -0
- package/dist/context/savings.d.ts.map +1 -0
- package/dist/context/savings.js +49 -0
- package/dist/context/savings.js.map +1 -0
- package/dist/graph/map.d.ts +4 -0
- package/dist/graph/map.d.ts.map +1 -1
- package/dist/graph/map.js +4 -1
- package/dist/graph/map.js.map +1 -1
- package/dist/graph/scopes.d.ts +15 -0
- package/dist/graph/scopes.d.ts.map +1 -1
- package/dist/graph/scopes.js +23 -0
- package/dist/graph/scopes.js.map +1 -1
- package/dist/graph/traverse-cli.d.ts +28 -18
- package/dist/graph/traverse-cli.d.ts.map +1 -1
- package/dist/graph/traverse-cli.js +68 -43
- package/dist/graph/traverse-cli.js.map +1 -1
- package/dist/graph/traverse.d.ts +35 -14
- package/dist/graph/traverse.d.ts.map +1 -1
- package/dist/graph/traverse.js +46 -20
- package/dist/graph/traverse.js.map +1 -1
- package/dist/graph/workspace.d.ts +136 -0
- package/dist/graph/workspace.d.ts.map +1 -0
- package/dist/graph/workspace.js +339 -0
- package/dist/graph/workspace.js.map +1 -0
- package/dist/hosts/instructions.d.ts.map +1 -1
- package/dist/hosts/instructions.js +4 -3
- package/dist/hosts/instructions.js.map +1 -1
- package/dist/hosts/mcp-config.d.ts +5 -0
- package/dist/hosts/mcp-config.d.ts.map +1 -1
- package/dist/hosts/mcp-config.js +2 -2
- package/dist/hosts/mcp-config.js.map +1 -1
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +33 -65
- package/dist/mcp/tools.js.map +1 -1
- package/dist/search/grep-cli.d.ts.map +1 -1
- package/dist/search/grep-cli.js +4 -0
- package/dist/search/grep-cli.js.map +1 -1
- package/dist/search/grep.d.ts +4 -0
- package/dist/search/grep.d.ts.map +1 -1
- package/dist/search/grep.js +2 -0
- package/dist/search/grep.js.map +1 -1
- package/package.json +1 -1
package/dist/graph/traverse.js
CHANGED
|
@@ -82,32 +82,38 @@ export function impactOf(graph, symbol, maxDepth = 2) {
|
|
|
82
82
|
return impactOfMany(graph, [symbol], maxDepth);
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
|
-
* BFS over
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
85
|
+
* BFS over walk-relation edges from *multiple* seed nodes at once, in the given
|
|
86
|
+
* `direction` (`in` = incoming, the default — "who breaks if this changes";
|
|
87
|
+
* `out` = outgoing — "what this reaches"). The multi-seed generalization of
|
|
88
|
+
* {@link impactOf} (`impactOf(g, n, d)` is exactly `impactOfMany(g, [n], d)`).
|
|
89
|
+
* Used when one logical unit spans several graph node ids — e.g. a file plus
|
|
90
|
+
* every symbol defined in it, since a `calls`/`references`/etc. edge from
|
|
91
|
+
* another file always targets the SYMBOL id, never the FILE id, so walking the
|
|
92
|
+
* file node alone misses dependents that call into it rather than merely
|
|
93
|
+
* importing it.
|
|
92
94
|
*
|
|
93
95
|
* Every seed is pre-marked visited (so a seed can never appear as its own
|
|
94
96
|
* hit, and an edge between two seeds is never reported), then the walk
|
|
95
97
|
* proceeds exactly like `impactOf`'s: each reached node deduped by id and
|
|
96
98
|
* reported once, at the depth it was first reached from *any* seed.
|
|
97
99
|
*/
|
|
98
|
-
export function impactOfMany(graph, seeds, maxDepth = 2) {
|
|
100
|
+
export function impactOfMany(graph, seeds, maxDepth = 2, direction = "in") {
|
|
99
101
|
const byId = new Map(graph.nodes.map((n) => [n.id, n]));
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
+
// Adjacency keyed for the walk direction, restricted to walk relations:
|
|
103
|
+
// 'in' → key = edge.target, neighbour = edge.source (who points AT key)
|
|
104
|
+
// 'out' → key = edge.source, neighbour = edge.target (what key points TO)
|
|
105
|
+
const adj = new Map();
|
|
102
106
|
for (const e of graph.edges) {
|
|
103
107
|
if (!WALK_RELATIONS.has(e.relation))
|
|
104
108
|
continue;
|
|
105
|
-
const
|
|
106
|
-
const
|
|
109
|
+
const key = direction === "in" ? e.target : e.source;
|
|
110
|
+
const other = direction === "in" ? e.source : e.target;
|
|
111
|
+
const entry = { other, relation: e.relation };
|
|
112
|
+
const arr = adj.get(key);
|
|
107
113
|
if (arr)
|
|
108
114
|
arr.push(entry);
|
|
109
115
|
else
|
|
110
|
-
|
|
116
|
+
adj.set(key, [entry]);
|
|
111
117
|
}
|
|
112
118
|
const visited = new Set(seeds.map((s) => s.id));
|
|
113
119
|
const hits = [];
|
|
@@ -115,12 +121,12 @@ export function impactOfMany(graph, seeds, maxDepth = 2) {
|
|
|
115
121
|
for (let depth = 1; depth <= maxDepth && frontier.length > 0; depth++) {
|
|
116
122
|
const next = [];
|
|
117
123
|
for (const current of frontier) {
|
|
118
|
-
for (const {
|
|
119
|
-
if (visited.has(
|
|
124
|
+
for (const { other, relation } of adj.get(current) ?? []) {
|
|
125
|
+
if (visited.has(other))
|
|
120
126
|
continue;
|
|
121
|
-
visited.add(
|
|
122
|
-
hits.push({ node: byId.get(
|
|
123
|
-
next.push(
|
|
127
|
+
visited.add(other);
|
|
128
|
+
hits.push({ node: byId.get(other) ?? null, id: other, relation, depth });
|
|
129
|
+
next.push(other);
|
|
124
130
|
}
|
|
125
131
|
}
|
|
126
132
|
frontier = next;
|
|
@@ -141,7 +147,27 @@ function symbolsInFile(graph, fileNode) {
|
|
|
141
147
|
* see this module's header and `impactOfMany`'s doc for why. Symbol-kind
|
|
142
148
|
* queries keep using plain `impactOf`; this is only for file-kind matches.
|
|
143
149
|
*/
|
|
144
|
-
export function impactOfFile(graph, fileNode, maxDepth = 2) {
|
|
145
|
-
return impactOfMany(graph, [fileNode, ...symbolsInFile(graph, fileNode)], maxDepth);
|
|
150
|
+
export function impactOfFile(graph, fileNode, maxDepth = 2, direction = "in") {
|
|
151
|
+
return impactOfMany(graph, [fileNode, ...symbolsInFile(graph, fileNode)], maxDepth, direction);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The single entry point behind `graft callers` and the MCP `graft_callers`
|
|
155
|
+
* tool, covering all of what were once three commands:
|
|
156
|
+
* - `direction:in, depth:1` → callers (who calls/references this)
|
|
157
|
+
* - `direction:out, depth:1` → callees (what this calls/references)
|
|
158
|
+
* - `direction:in, depth>1` → blast radius (transitive dependents)
|
|
159
|
+
* - `direction:out, depth>1` → transitive dependencies
|
|
160
|
+
*
|
|
161
|
+
* Depth 1 uses the plain single-hop scan ({@link callersOf}/{@link calleesOf})
|
|
162
|
+
* so `graft callers <symbol>` output is unchanged. Depth >1 runs the BFS, and
|
|
163
|
+
* for a `kind: 'file'` seed aggregates over the symbols the file defines (see
|
|
164
|
+
* {@link impactOfMany}) so file-level dependents aren't silently dropped.
|
|
165
|
+
*/
|
|
166
|
+
export function edgeWalk(graph, node, direction, depth) {
|
|
167
|
+
if (depth <= 1)
|
|
168
|
+
return direction === "in" ? callersOf(graph, node) : calleesOf(graph, node);
|
|
169
|
+
if (node.kind === "file")
|
|
170
|
+
return impactOfFile(graph, node, depth, direction);
|
|
171
|
+
return impactOfMany(graph, [node], depth, direction);
|
|
146
172
|
}
|
|
147
173
|
//# sourceMappingURL=traverse.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverse.js","sourceRoot":"","sources":["../../src/graph/traverse.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"traverse.js","sourceRoot":"","sources":["../../src/graph/traverse.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAkBhD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc,EAAE,KAAa,EAAE,OAA6B,EAAE;IAC1F,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IACvC,MAAM,iBAAiB,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAEtE,IAAI,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAErD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAChD,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAC1E,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,WAAW,CAAC,CAAC;QACjG,CAAC;IACH,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,iBAAiB,EAAE,CAAC;QAC9C,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAC1B,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,IAAI,KAAK,MAAM;YACjB,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,UAAU;gBACl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,QAAQ,GAAG,CAAC,EAAE,YAAuB,IAAI;IACtG,OAAO,YAAY,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,GAAG,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AACjG,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc,EAAE,IAAY,EAAE,SAAoB,EAAE,KAAa;IACxF,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC5F,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;IAC7E,OAAO,YAAY,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { type AskIndex } from "../ask/index-file.js";
|
|
2
|
+
import { type GraphBuildResult } from "./build.js";
|
|
3
|
+
import { type GraphCheckResult } from "./check.js";
|
|
4
|
+
import { type RepoMap } from "./map.js";
|
|
5
|
+
import type { GraphV1 } from "./types.js";
|
|
6
|
+
/** The parent-side manifest — the ONLY thing a workspace parent's graft/ holds. */
|
|
7
|
+
export interface WorkspaceV1 {
|
|
8
|
+
version: 1;
|
|
9
|
+
/** Immediate child git repos, as dir names, sorted. */
|
|
10
|
+
children: string[];
|
|
11
|
+
}
|
|
12
|
+
export declare const WORKSPACE_FILE = "workspace.json";
|
|
13
|
+
/** `<contextDir>/workspace.json` — sibling of where `.graph/` would live. */
|
|
14
|
+
export declare function workspacePath(outDir: string): string;
|
|
15
|
+
/** Read the workspace manifest for the repo/parent at `root` (respecting the
|
|
16
|
+
* `--dir` override like every other reader). Null when absent or malformed —
|
|
17
|
+
* a non-workspace root costs one `existsSync`. */
|
|
18
|
+
export declare function readWorkspace(root: string, contextDirOverride?: string): WorkspaceV1 | null;
|
|
19
|
+
/** Write the manifest (children sorted; deterministic bytes, like writeGraph). */
|
|
20
|
+
export declare function writeWorkspace(outDir: string, ws: WorkspaceV1): string;
|
|
21
|
+
/** Build-time workspace detection: `root` has NO `.git` of its own and >=2
|
|
22
|
+
* immediate git children (a `.git` FILE — worktree/submodule — counts).
|
|
23
|
+
* Returns the sorted child names, or null when `root` is a normal repo/dir. */
|
|
24
|
+
export declare function isWorkspaceRoot(root: string): string[] | null;
|
|
25
|
+
export interface WorkspaceGraphs {
|
|
26
|
+
/** All children listed in the manifest. */
|
|
27
|
+
children: string[];
|
|
28
|
+
/** Children with a built graph, in manifest order. Each child's graph and
|
|
29
|
+
* sidecar come from ITS OWN `graft/` via the shared caches. */
|
|
30
|
+
built: {
|
|
31
|
+
child: string;
|
|
32
|
+
contextDir: string;
|
|
33
|
+
graph: GraphV1;
|
|
34
|
+
askIndex: AskIndex | null;
|
|
35
|
+
}[];
|
|
36
|
+
/** Children without a built graph — surfaced, never silently skipped. */
|
|
37
|
+
unbuilt: string[];
|
|
38
|
+
/** The surfacing line, set whenever `unbuilt` is non-empty. */
|
|
39
|
+
note?: string;
|
|
40
|
+
}
|
|
41
|
+
/** Load every child's graph via `loadGraphCached` (the only graph loader).
|
|
42
|
+
* Null when `root` is not a workspace (no manifest). */
|
|
43
|
+
export declare function loadWorkspaceGraphs(root: string, contextDirOverride?: string): WorkspaceGraphs | null;
|
|
44
|
+
/** Merge the built children into one virtual graph whose scopes are each
|
|
45
|
+
* child's scopes prefixed `<child>/` (child root scope → `<child>`). With >=2
|
|
46
|
+
* built children this is always multi-scope, so `ask` takes its per-scope
|
|
47
|
+
* RRF path and labels every hit with its repo. Null when nothing is built. */
|
|
48
|
+
export declare function mergeWorkspaceGraphs(built: WorkspaceGraphs["built"]): GraphV1 | null;
|
|
49
|
+
/** Merge the children's build-time ask sidecars to match the merged graph:
|
|
50
|
+
* doc ids prefixed, and each doc's path bag gains the child dir's tokens —
|
|
51
|
+
* exactly what live tokenization of the prefixed path would produce, so the
|
|
52
|
+
* sidecar stays a provably exact cache. `df`/`docCount`/`avgBodyLen` are
|
|
53
|
+
* recomputed over the merged docs. Null (→ live-tokenization fallback, same
|
|
54
|
+
* degradation as any stale sidecar) unless EVERY built child has a sidecar
|
|
55
|
+
* that exactly covers its graph. */
|
|
56
|
+
export declare function mergeWorkspaceAskIndexes(built: WorkspaceGraphs["built"]): AskIndex | null;
|
|
57
|
+
/** One-call federation for graph-consuming commands (grep, callers/callees,
|
|
58
|
+
* impact, MCP): null when `root` is not a workspace; otherwise the merged
|
|
59
|
+
* graph (null when no child is built) plus the unbuilt-children note. */
|
|
60
|
+
export declare function loadFederatedGraph(root: string, contextDirOverride?: string): {
|
|
61
|
+
graph: GraphV1 | null;
|
|
62
|
+
note?: string;
|
|
63
|
+
} | null;
|
|
64
|
+
/** Federation inputs for `ask`: the merged graph + merged sidecar + each built
|
|
65
|
+
* child's context dir (for its concept nodes). `ask` feeds the merged graph to
|
|
66
|
+
* its existing multi-scope pipeline, so `rankScopesAndFuse` does the fair
|
|
67
|
+
* cross-repo fusion with `<child>/`-prefixed scope labels. */
|
|
68
|
+
export declare function federateAsk(root: string, contextDirOverride?: string): {
|
|
69
|
+
graph: GraphV1 | null;
|
|
70
|
+
askIndex: AskIndex | null;
|
|
71
|
+
built: {
|
|
72
|
+
child: string;
|
|
73
|
+
contextDir: string;
|
|
74
|
+
}[];
|
|
75
|
+
note?: string;
|
|
76
|
+
} | null;
|
|
77
|
+
/** EXACT migration wording (asserted by tests) for a parent whose old combined
|
|
78
|
+
* graph is being replaced by the workspace manifest. */
|
|
79
|
+
export declare function migrationNote(children: string[]): string;
|
|
80
|
+
export interface WorkspaceBuildResult {
|
|
81
|
+
children: {
|
|
82
|
+
child: string;
|
|
83
|
+
result: GraphBuildResult;
|
|
84
|
+
}[];
|
|
85
|
+
workspacePath: string;
|
|
86
|
+
/** True when a pre-existing combined graph at the parent was replaced. */
|
|
87
|
+
migrated: boolean;
|
|
88
|
+
/** The exact {@link migrationNote} wording, set only when `migrated`. */
|
|
89
|
+
migrationNote?: string;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* `graft build` at a workspace parent: build each child's graph into the child
|
|
93
|
+
* (plain `buildGraph(childDir)` — nothing parent-side touches it, which is what
|
|
94
|
+
* makes the result byte-identical to a standalone build), then write the
|
|
95
|
+
* parent manifest. A pre-existing mega-graph (`graft/.graph/wiring.json` at
|
|
96
|
+
* the parent) is replaced: its `.graph/` and `.cache/` are deleted AFTER the
|
|
97
|
+
* children built successfully, so a failed child build never destroys the old
|
|
98
|
+
* (still-working) graph.
|
|
99
|
+
*/
|
|
100
|
+
export declare function buildWorkspace(root: string, opts?: {
|
|
101
|
+
contextDir?: string;
|
|
102
|
+
}): Promise<WorkspaceBuildResult>;
|
|
103
|
+
/** Human report for a workspace build — the migration note (when migrating)
|
|
104
|
+
* first, then one ✓ line per child, then where the manifest went. */
|
|
105
|
+
export declare function formatWorkspaceBuild(r: WorkspaceBuildResult): string;
|
|
106
|
+
export interface WorkspaceCheck {
|
|
107
|
+
children: {
|
|
108
|
+
child: string;
|
|
109
|
+
missing: boolean;
|
|
110
|
+
ok: boolean;
|
|
111
|
+
summary: string;
|
|
112
|
+
result: GraphCheckResult;
|
|
113
|
+
}[];
|
|
114
|
+
/** True when any child that HAS a graph is stale — unbuilt alone never fails. */
|
|
115
|
+
failed: boolean;
|
|
116
|
+
}
|
|
117
|
+
/** Per-child drift check ({@link checkGraph} in each child repo). */
|
|
118
|
+
export declare function checkWorkspace(root: string, contextDirOverride?: string): WorkspaceCheck;
|
|
119
|
+
export declare function formatWorkspaceCheck(c: WorkspaceCheck): string;
|
|
120
|
+
export interface WorkspaceMap {
|
|
121
|
+
children: {
|
|
122
|
+
child: string;
|
|
123
|
+
map: RepoMap;
|
|
124
|
+
}[];
|
|
125
|
+
note?: string;
|
|
126
|
+
}
|
|
127
|
+
/** Per-child repo maps, the directory budget split evenly across the built
|
|
128
|
+
* children. Null when `root` is not a workspace. */
|
|
129
|
+
export declare function buildWorkspaceMap(root: string, opts?: {
|
|
130
|
+
maxDirs?: number;
|
|
131
|
+
contextDir?: string;
|
|
132
|
+
}): WorkspaceMap | null;
|
|
133
|
+
/** One section per child (its own `formatRepoMap` report under a `<child>/`
|
|
134
|
+
* heading), plus the unbuilt-children note when present. */
|
|
135
|
+
export declare function formatWorkspaceMap(m: WorkspaceMap): string;
|
|
136
|
+
//# sourceMappingURL=workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/graph/workspace.ts"],"names":[],"mappings":"AAgCA,OAAO,EAAoB,KAAK,QAAQ,EAAoB,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAc,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAc,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE/D,OAAO,EAA+B,KAAK,OAAO,EAAE,MAAM,UAAU,CAAC;AAGrE,OAAO,KAAK,EAAU,OAAO,EAAmB,MAAM,YAAY,CAAC;AAEnE,mFAAmF;AACnF,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,CAAC,CAAC;IACX,uDAAuD;IACvD,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAE/C,6EAA6E;AAC7E,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;kDAEkD;AAClD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAkB3F;AAED,kFAAkF;AAClF,wBAA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AAG,MAAM,CAU9D;AAID,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;oDACoD;AACpD,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GACnD,YAAY,GAAG,IAAI,CAQrB;AAED;4DAC4D;AAC5D,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,YAAY,GAAG,MAAM,CAO1D"}
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace federation — a parent directory with >=2 immediate git children
|
|
3
|
+
* and no own `.git` is a WORKSPACE, not a repo. Building there builds each
|
|
4
|
+
* child's graph INTO THE CHILD (`<child>/graft/`, committable in that repo,
|
|
5
|
+
* byte-identical to a standalone build — the parent never influences a child
|
|
6
|
+
* build) and leaves the parent holding ONLY `graft/workspace.json`: a manifest
|
|
7
|
+
* of child dir names, no nodes or edges.
|
|
8
|
+
*
|
|
9
|
+
* Queries at the parent federate across the children's graphs:
|
|
10
|
+
* - `ask` merges the child graphs into one virtual corpus whose ranking
|
|
11
|
+
* scopes are `<child>/<scope>` (child root scope → `<child>`), so the
|
|
12
|
+
* existing per-scope RRF pipeline (`rankScopesAndFuse`) does the fair
|
|
13
|
+
* cross-repo fusion — a big repo can't drown a small one, and every hit
|
|
14
|
+
* is labeled with the repo it came from.
|
|
15
|
+
* - `grep` / `callers` / `callees` / `impact` run over the same merged
|
|
16
|
+
* graph: node ids and paths are prefixed `<child>/`, edges never cross
|
|
17
|
+
* children, so in-degree/coupling stays each child's own.
|
|
18
|
+
* - `map` and `check` run per child (see {@link buildWorkspaceMap} /
|
|
19
|
+
* {@link checkWorkspace}).
|
|
20
|
+
*
|
|
21
|
+
* Migration: a parent that HAS an old combined ("mega") graph gets it replaced
|
|
22
|
+
* by the workspace manifest on the next `graft build` there — loudly, via
|
|
23
|
+
* {@link migrationNote} — and never any other way: a stale mega-graph parent
|
|
24
|
+
* keeps answering `check`/queries as before until the user rebuilds.
|
|
25
|
+
*
|
|
26
|
+
* Unbuilt children are surfaced, never silently skipped: every loader here
|
|
27
|
+
* carries a "N of M workspace repos have graphs; run graft build to cover X"
|
|
28
|
+
* note that each command attaches to its output.
|
|
29
|
+
*/
|
|
30
|
+
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
31
|
+
import { join, resolve } from "node:path";
|
|
32
|
+
import { contextDirFor, CACHE_DIR } from "../context/node-file.js";
|
|
33
|
+
import { counts, tokenize } from "../ask/index-file.js";
|
|
34
|
+
import { buildGraph } from "./build.js";
|
|
35
|
+
import { checkGraph } from "./check.js";
|
|
36
|
+
import { loadGraphCached, loadAskIndexCached } from "./load.js";
|
|
37
|
+
import { buildRepoMap, formatRepoMap } from "./map.js";
|
|
38
|
+
import { discoverWorkspaceChildren, scopesOfGraph } from "./scopes.js";
|
|
39
|
+
import { GRAPH_DIR, wiringPath } from "./write.js";
|
|
40
|
+
export const WORKSPACE_FILE = "workspace.json";
|
|
41
|
+
/** `<contextDir>/workspace.json` — sibling of where `.graph/` would live. */
|
|
42
|
+
export function workspacePath(outDir) {
|
|
43
|
+
return join(outDir, WORKSPACE_FILE);
|
|
44
|
+
}
|
|
45
|
+
/** Read the workspace manifest for the repo/parent at `root` (respecting the
|
|
46
|
+
* `--dir` override like every other reader). Null when absent or malformed —
|
|
47
|
+
* a non-workspace root costs one `existsSync`. */
|
|
48
|
+
export function readWorkspace(root, contextDirOverride) {
|
|
49
|
+
const path = workspacePath(contextDirFor(resolve(root), contextDirOverride));
|
|
50
|
+
if (!existsSync(path))
|
|
51
|
+
return null;
|
|
52
|
+
try {
|
|
53
|
+
const raw = JSON.parse(readFileSync(path, "utf8"));
|
|
54
|
+
if (!raw ||
|
|
55
|
+
typeof raw !== "object" ||
|
|
56
|
+
raw.version !== 1 ||
|
|
57
|
+
!Array.isArray(raw.children) ||
|
|
58
|
+
!raw.children.every((c) => typeof c === "string" && c.length > 0)) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
return { version: 1, children: raw.children };
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** Write the manifest (children sorted; deterministic bytes, like writeGraph). */
|
|
68
|
+
export function writeWorkspace(outDir, ws) {
|
|
69
|
+
const path = workspacePath(outDir);
|
|
70
|
+
mkdirSync(outDir, { recursive: true });
|
|
71
|
+
const sorted = { version: 1, children: [...ws.children].sort() };
|
|
72
|
+
writeFileSync(path, JSON.stringify(sorted, null, 2) + "\n");
|
|
73
|
+
return path;
|
|
74
|
+
}
|
|
75
|
+
/** Build-time workspace detection: `root` has NO `.git` of its own and >=2
|
|
76
|
+
* immediate git children (a `.git` FILE — worktree/submodule — counts).
|
|
77
|
+
* Returns the sorted child names, or null when `root` is a normal repo/dir. */
|
|
78
|
+
export function isWorkspaceRoot(root) {
|
|
79
|
+
const absRoot = resolve(root);
|
|
80
|
+
if (existsSync(join(absRoot, ".git")))
|
|
81
|
+
return null;
|
|
82
|
+
const children = discoverWorkspaceChildren(absRoot).sort();
|
|
83
|
+
return children.length >= 2 ? children : null;
|
|
84
|
+
}
|
|
85
|
+
/** Load every child's graph via `loadGraphCached` (the only graph loader).
|
|
86
|
+
* Null when `root` is not a workspace (no manifest). */
|
|
87
|
+
export function loadWorkspaceGraphs(root, contextDirOverride) {
|
|
88
|
+
const ws = readWorkspace(root, contextDirOverride);
|
|
89
|
+
if (!ws)
|
|
90
|
+
return null;
|
|
91
|
+
const absRoot = resolve(root);
|
|
92
|
+
const built = [];
|
|
93
|
+
const unbuilt = [];
|
|
94
|
+
for (const child of ws.children) {
|
|
95
|
+
// children always use their own default graft/ — that's what makes each
|
|
96
|
+
// child's graph committable in (and byte-identical to) the child repo.
|
|
97
|
+
const contextDir = contextDirFor(join(absRoot, child));
|
|
98
|
+
const graph = loadGraphCached(contextDir);
|
|
99
|
+
if (graph)
|
|
100
|
+
built.push({ child, contextDir, graph, askIndex: loadAskIndexCached(contextDir) });
|
|
101
|
+
else
|
|
102
|
+
unbuilt.push(child);
|
|
103
|
+
}
|
|
104
|
+
const note = unbuilt.length
|
|
105
|
+
? `${built.length} of ${ws.children.length} workspace repos have graphs; run graft build to cover ${unbuilt.join(", ")}`
|
|
106
|
+
: undefined;
|
|
107
|
+
return { children: ws.children, built, unbuilt, note };
|
|
108
|
+
}
|
|
109
|
+
// ── Merging: one virtual graph, everything prefixed `<child>/` ───────────────
|
|
110
|
+
/** Prefix a child's nodes/edges with `<child>/` so ids and paths are unique
|
|
111
|
+
* and workspace-relative (pointers open from the parent cwd). Edge endpoints
|
|
112
|
+
* that aren't node ids (unresolved import module strings) stay untouched. */
|
|
113
|
+
function prefixChild(child, g) {
|
|
114
|
+
const ids = new Set(g.nodes.map((n) => n.id));
|
|
115
|
+
const pre = (id) => (ids.has(id) ? `${child}/${id}` : id);
|
|
116
|
+
return {
|
|
117
|
+
nodes: g.nodes.map((n) => ({ ...n, id: `${child}/${n.id}`, path: `${child}/${n.path}` })),
|
|
118
|
+
edges: g.edges.map((e) => ({ ...e, source: pre(e.source), target: pre(e.target) })),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/** Merge the built children into one virtual graph whose scopes are each
|
|
122
|
+
* child's scopes prefixed `<child>/` (child root scope → `<child>`). With >=2
|
|
123
|
+
* built children this is always multi-scope, so `ask` takes its per-scope
|
|
124
|
+
* RRF path and labels every hit with its repo. Null when nothing is built. */
|
|
125
|
+
export function mergeWorkspaceGraphs(built) {
|
|
126
|
+
if (built.length === 0)
|
|
127
|
+
return null;
|
|
128
|
+
const nodes = [];
|
|
129
|
+
const edges = [];
|
|
130
|
+
const langs = new Set();
|
|
131
|
+
const scopes = [];
|
|
132
|
+
for (const { child, graph } of built) {
|
|
133
|
+
const p = prefixChild(child, graph);
|
|
134
|
+
nodes.push(...p.nodes);
|
|
135
|
+
edges.push(...p.edges);
|
|
136
|
+
for (const l of graph.meta.languages)
|
|
137
|
+
langs.add(l);
|
|
138
|
+
for (const s of scopesOfGraph(graph)) {
|
|
139
|
+
const prefix = s.prefix ? `${child}/${s.prefix}` : child;
|
|
140
|
+
scopes.push({ prefix, label: prefix, markers: s.markers });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// rule-7 ordering (prefix-length desc, then lexicographic) — scopeOf depends on it.
|
|
144
|
+
scopes.sort((a, b) => b.prefix.length - a.prefix.length || a.prefix.localeCompare(b.prefix));
|
|
145
|
+
return {
|
|
146
|
+
meta: {
|
|
147
|
+
version: 1,
|
|
148
|
+
nodeCount: nodes.length,
|
|
149
|
+
edgeCount: edges.length,
|
|
150
|
+
languages: [...langs].sort(),
|
|
151
|
+
scopes,
|
|
152
|
+
},
|
|
153
|
+
nodes,
|
|
154
|
+
edges,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function addBag(into, pairs) {
|
|
158
|
+
for (const [t, c] of pairs)
|
|
159
|
+
into.set(t, (into.get(t) ?? 0) + c);
|
|
160
|
+
}
|
|
161
|
+
/** Merge the children's build-time ask sidecars to match the merged graph:
|
|
162
|
+
* doc ids prefixed, and each doc's path bag gains the child dir's tokens —
|
|
163
|
+
* exactly what live tokenization of the prefixed path would produce, so the
|
|
164
|
+
* sidecar stays a provably exact cache. `df`/`docCount`/`avgBodyLen` are
|
|
165
|
+
* recomputed over the merged docs. Null (→ live-tokenization fallback, same
|
|
166
|
+
* degradation as any stale sidecar) unless EVERY built child has a sidecar
|
|
167
|
+
* that exactly covers its graph. */
|
|
168
|
+
export function mergeWorkspaceAskIndexes(built) {
|
|
169
|
+
if (built.length === 0)
|
|
170
|
+
return null;
|
|
171
|
+
for (const { graph, askIndex } of built) {
|
|
172
|
+
if (!askIndex || askIndex.docs.length !== graph.nodes.length)
|
|
173
|
+
return null;
|
|
174
|
+
const byId = new Set(askIndex.docs.map((d) => d.id));
|
|
175
|
+
if (!graph.nodes.every((n) => byId.has(n.id)))
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
const docs = [];
|
|
179
|
+
const df = new Map();
|
|
180
|
+
let bodyLenSum = 0;
|
|
181
|
+
for (const { child, askIndex } of built) {
|
|
182
|
+
const childTokens = [...counts(tokenize(child)).entries()];
|
|
183
|
+
for (const d of askIndex.docs) {
|
|
184
|
+
const path = new Map();
|
|
185
|
+
addBag(path, childTokens);
|
|
186
|
+
addBag(path, d.path);
|
|
187
|
+
const doc = { id: `${child}/${d.id}`, name: d.name, path: [...path.entries()], body: d.body };
|
|
188
|
+
docs.push(doc);
|
|
189
|
+
const bag = new Set([...doc.name, ...doc.path, ...doc.body].map(([t]) => t));
|
|
190
|
+
for (const t of bag)
|
|
191
|
+
df.set(t, (df.get(t) ?? 0) + 1);
|
|
192
|
+
for (const [, c] of d.body)
|
|
193
|
+
bodyLenSum += c;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
version: 1,
|
|
198
|
+
avgBodyLen: docs.length ? bodyLenSum / docs.length : 0,
|
|
199
|
+
df: [...df.entries()],
|
|
200
|
+
docCount: docs.length,
|
|
201
|
+
docs,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
/** One-call federation for graph-consuming commands (grep, callers/callees,
|
|
205
|
+
* impact, MCP): null when `root` is not a workspace; otherwise the merged
|
|
206
|
+
* graph (null when no child is built) plus the unbuilt-children note. */
|
|
207
|
+
export function loadFederatedGraph(root, contextDirOverride) {
|
|
208
|
+
const wg = loadWorkspaceGraphs(root, contextDirOverride);
|
|
209
|
+
if (!wg)
|
|
210
|
+
return null;
|
|
211
|
+
return { graph: mergeWorkspaceGraphs(wg.built), note: wg.note };
|
|
212
|
+
}
|
|
213
|
+
/** Federation inputs for `ask`: the merged graph + merged sidecar + each built
|
|
214
|
+
* child's context dir (for its concept nodes). `ask` feeds the merged graph to
|
|
215
|
+
* its existing multi-scope pipeline, so `rankScopesAndFuse` does the fair
|
|
216
|
+
* cross-repo fusion with `<child>/`-prefixed scope labels. */
|
|
217
|
+
export function federateAsk(root, contextDirOverride) {
|
|
218
|
+
const wg = loadWorkspaceGraphs(root, contextDirOverride);
|
|
219
|
+
if (!wg)
|
|
220
|
+
return null;
|
|
221
|
+
return {
|
|
222
|
+
graph: mergeWorkspaceGraphs(wg.built),
|
|
223
|
+
askIndex: mergeWorkspaceAskIndexes(wg.built),
|
|
224
|
+
built: wg.built.map(({ child, contextDir }) => ({ child, contextDir })),
|
|
225
|
+
note: wg.note,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
// ── Build + migration ────────────────────────────────────────────────────────
|
|
229
|
+
/** EXACT migration wording (asserted by tests) for a parent whose old combined
|
|
230
|
+
* graph is being replaced by the workspace manifest. */
|
|
231
|
+
export function migrationNote(children) {
|
|
232
|
+
return (`⚠ this folder contains ${children.length} separate git repos — splitting: each repo now gets ` +
|
|
233
|
+
`its own committable graft/ (${children.map((c) => `${c}/graft/`).join(", ")}); the combined ` +
|
|
234
|
+
`graph here is replaced by a workspace index. Queries from here now search all repos, fairly.`);
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* `graft build` at a workspace parent: build each child's graph into the child
|
|
238
|
+
* (plain `buildGraph(childDir)` — nothing parent-side touches it, which is what
|
|
239
|
+
* makes the result byte-identical to a standalone build), then write the
|
|
240
|
+
* parent manifest. A pre-existing mega-graph (`graft/.graph/wiring.json` at
|
|
241
|
+
* the parent) is replaced: its `.graph/` and `.cache/` are deleted AFTER the
|
|
242
|
+
* children built successfully, so a failed child build never destroys the old
|
|
243
|
+
* (still-working) graph.
|
|
244
|
+
*/
|
|
245
|
+
export async function buildWorkspace(root, opts = {}) {
|
|
246
|
+
const absRoot = resolve(root);
|
|
247
|
+
const children = discoverWorkspaceChildren(absRoot).sort();
|
|
248
|
+
const outDir = contextDirFor(absRoot, opts.contextDir);
|
|
249
|
+
const hadMegaGraph = existsSync(wiringPath(outDir));
|
|
250
|
+
const results = [];
|
|
251
|
+
for (const child of children) {
|
|
252
|
+
results.push({ child, result: await buildGraph(join(absRoot, child)) });
|
|
253
|
+
}
|
|
254
|
+
if (hadMegaGraph) {
|
|
255
|
+
rmSync(join(outDir, GRAPH_DIR), { recursive: true, force: true });
|
|
256
|
+
rmSync(join(outDir, CACHE_DIR), { recursive: true, force: true });
|
|
257
|
+
}
|
|
258
|
+
const path = writeWorkspace(outDir, { version: 1, children });
|
|
259
|
+
return {
|
|
260
|
+
children: results,
|
|
261
|
+
workspacePath: path,
|
|
262
|
+
migrated: hadMegaGraph,
|
|
263
|
+
migrationNote: hadMegaGraph ? migrationNote(children) : undefined,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
/** Human report for a workspace build — the migration note (when migrating)
|
|
267
|
+
* first, then one ✓ line per child, then where the manifest went. */
|
|
268
|
+
export function formatWorkspaceBuild(r) {
|
|
269
|
+
const lines = [];
|
|
270
|
+
if (r.migrationNote)
|
|
271
|
+
lines.push(r.migrationNote);
|
|
272
|
+
for (const { child, result } of r.children) {
|
|
273
|
+
lines.push(`✓ ${child}/: ${result.nodes} nodes, ${result.edges} edges, ${result.cards} cards [${result.languages.join(", ")}]`);
|
|
274
|
+
for (const e of result.errors)
|
|
275
|
+
lines.push(`✗ ${child}/: ${e}`);
|
|
276
|
+
}
|
|
277
|
+
lines.push(` → ${r.workspacePath}`);
|
|
278
|
+
lines.push(` queries here now federate across: ${r.children.map((c) => `${c.child}/`).join(", ")}`);
|
|
279
|
+
return lines.join("\n");
|
|
280
|
+
}
|
|
281
|
+
/** Per-child drift check ({@link checkGraph} in each child repo). */
|
|
282
|
+
export function checkWorkspace(root, contextDirOverride) {
|
|
283
|
+
const ws = readWorkspace(root, contextDirOverride);
|
|
284
|
+
const children = ws?.children ?? [];
|
|
285
|
+
const absRoot = resolve(root);
|
|
286
|
+
const rows = children.map((child) => {
|
|
287
|
+
const result = checkGraph(join(absRoot, child));
|
|
288
|
+
if (result.missing) {
|
|
289
|
+
return { child, missing: true, ok: false, summary: "no graph — run `graft build` to cover it", result };
|
|
290
|
+
}
|
|
291
|
+
if (result.ok)
|
|
292
|
+
return { child, missing: false, ok: true, summary: "OK — wiring graph in sync", result };
|
|
293
|
+
const parts = [];
|
|
294
|
+
if (result.changed.length)
|
|
295
|
+
parts.push(`${result.changed.length} changed`);
|
|
296
|
+
if (result.added.length)
|
|
297
|
+
parts.push(`${result.added.length} added`);
|
|
298
|
+
if (result.removed.length)
|
|
299
|
+
parts.push(`${result.removed.length} removed`);
|
|
300
|
+
if (result.stale.length)
|
|
301
|
+
parts.push(`${result.stale.length} stale summaries`);
|
|
302
|
+
return { child, missing: false, ok: false, summary: `STALE — ${parts.join(", ")} (run \`graft build\` in ${child}/)`, result };
|
|
303
|
+
});
|
|
304
|
+
return { children: rows, failed: rows.some((r) => !r.missing && !r.ok) };
|
|
305
|
+
}
|
|
306
|
+
export function formatWorkspaceCheck(c) {
|
|
307
|
+
const lines = [`workspace check — ${c.children.length} repos`, ""];
|
|
308
|
+
for (const row of c.children)
|
|
309
|
+
lines.push(`${row.child}/: ${row.summary}`);
|
|
310
|
+
lines.push("");
|
|
311
|
+
lines.push(c.failed
|
|
312
|
+
? "workspace check: STALE — rebuild the repos above and commit their graft/."
|
|
313
|
+
: "workspace check: OK");
|
|
314
|
+
return lines.join("\n");
|
|
315
|
+
}
|
|
316
|
+
/** Per-child repo maps, the directory budget split evenly across the built
|
|
317
|
+
* children. Null when `root` is not a workspace. */
|
|
318
|
+
export function buildWorkspaceMap(root, opts = {}) {
|
|
319
|
+
const wg = loadWorkspaceGraphs(root, opts.contextDir);
|
|
320
|
+
if (!wg)
|
|
321
|
+
return null;
|
|
322
|
+
const per = Math.max(1, Math.floor((opts.maxDirs ?? 16) / Math.max(1, wg.built.length)));
|
|
323
|
+
return {
|
|
324
|
+
children: wg.built.map(({ child, graph }) => ({ child, map: buildRepoMap(graph, { maxDirs: per }) })),
|
|
325
|
+
note: wg.note,
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
/** One section per child (its own `formatRepoMap` report under a `<child>/`
|
|
329
|
+
* heading), plus the unbuilt-children note when present. */
|
|
330
|
+
export function formatWorkspaceMap(m) {
|
|
331
|
+
const lines = [`workspace map — ${m.children.length} repo${m.children.length === 1 ? "" : "s"}`];
|
|
332
|
+
for (const { child, map } of m.children) {
|
|
333
|
+
lines.push("", `── ${child}/ ──`, formatRepoMap(map).trimEnd());
|
|
334
|
+
}
|
|
335
|
+
if (m.note)
|
|
336
|
+
lines.push("", m.note);
|
|
337
|
+
return lines.join("\n") + "\n";
|
|
338
|
+
}
|
|
339
|
+
//# sourceMappingURL=workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/graph/workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAmC,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAE,UAAU,EAAyB,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAyB,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAgB,MAAM,UAAU,CAAC;AACrE,OAAO,EAAE,yBAAy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"file":"instructions.d.ts","sourceRoot":"","sources":["../../src/hosts/instructions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wBAAgB,eAAe,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../src/hosts/instructions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wBAAgB,eAAe,IAAI,MAAM,CAqCxC;AAED,wBAAgB,UAAU,IAAI,MAAM,CAOnC;AAED,wBAAgB,YAAY,IAAI,MAAM,CAMrC;AAED,wBAAgB,YAAY,IAAI,MAAM,CAGrC"}
|