@nanonets/graft 0.5.1 → 0.7.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 +29 -7
- package/dist/ask/ask.d.ts +52 -1
- package/dist/ask/ask.d.ts.map +1 -1
- package/dist/ask/ask.js +274 -83
- package/dist/ask/ask.js.map +1 -1
- package/dist/ask/fuse.d.ts +59 -17
- package/dist/ask/fuse.d.ts.map +1 -1
- package/dist/ask/fuse.js +51 -25
- package/dist/ask/fuse.js.map +1 -1
- package/dist/ask/graphrank.d.ts +6 -0
- package/dist/ask/graphrank.d.ts.map +1 -1
- package/dist/ask/graphrank.js +5 -1
- package/dist/ask/graphrank.js.map +1 -1
- package/dist/claude/format.js +1 -1
- package/dist/claude/format.js.map +1 -1
- package/dist/claude/hooks.d.ts +16 -0
- package/dist/claude/hooks.d.ts.map +1 -1
- package/dist/claude/hooks.js +57 -2
- package/dist/claude/hooks.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 +20 -9
- package/dist/claude/skill-template.js.map +1 -1
- package/dist/cli.d.ts +3 -14
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +99 -70
- 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/engine.d.ts +1 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +7 -1
- package/dist/engine.js.map +1 -1
- package/dist/graph/build.d.ts.map +1 -1
- package/dist/graph/build.js +33 -0
- package/dist/graph/build.js.map +1 -1
- package/dist/graph/map.d.ts +38 -2
- package/dist/graph/map.d.ts.map +1 -1
- package/dist/graph/map.js +111 -24
- 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/types.d.ts +12 -0
- package/dist/graph/types.d.ts.map +1 -1
- package/dist/graph/workspace-cli.d.ts +37 -0
- package/dist/graph/workspace-cli.d.ts.map +1 -0
- package/dist/graph/workspace-cli.js +70 -0
- package/dist/graph/workspace-cli.js.map +1 -0
- package/dist/graph/workspace.d.ts +128 -0
- package/dist/graph/workspace.d.ts.map +1 -0
- package/dist/graph/workspace.js +395 -0
- package/dist/graph/workspace.js.map +1 -0
- package/dist/hosts/instructions.d.ts.map +1 -1
- package/dist/hosts/instructions.js +7 -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 +94 -66
- 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,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O,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"}
|
package/dist/graph/types.d.ts
CHANGED
|
@@ -45,12 +45,24 @@ export interface EdgeV1 {
|
|
|
45
45
|
relation: Relation;
|
|
46
46
|
confidence: Confidence;
|
|
47
47
|
}
|
|
48
|
+
/** A ranking scope: a sub-project discovered by project-marker files (`package.json`,
|
|
49
|
+
* `go.mod`, ...). `prefix` is a posix path relative to the graph root ("" = root scope);
|
|
50
|
+
* `label` is the same value without a trailing slash (also "" for root); `markers` lists
|
|
51
|
+
* which marker file(s) were found in that directory. See `src/graph/scopes.ts`. */
|
|
52
|
+
export interface ScopeV1 {
|
|
53
|
+
prefix: string;
|
|
54
|
+
label: string;
|
|
55
|
+
markers: string[];
|
|
56
|
+
}
|
|
48
57
|
export interface GraphV1 {
|
|
49
58
|
meta: {
|
|
50
59
|
version: 1;
|
|
51
60
|
nodeCount: number;
|
|
52
61
|
edgeCount: number;
|
|
53
62
|
languages: string[];
|
|
63
|
+
/** Ranking scopes: posix path prefixes relative to the graph root, "" = root scope.
|
|
64
|
+
* Absent (old graphs) ≡ [{ prefix: "", label: "" }]. Sorted by prefix length desc. */
|
|
65
|
+
scopes?: ScopeV1[];
|
|
54
66
|
};
|
|
55
67
|
nodes: NodeV1[];
|
|
56
68
|
edges: EdgeV1[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/graph/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,yFAAyF;AACzF,MAAM,MAAM,IAAI,GACZ,MAAM,GACN,OAAO,GACP,UAAU,GACV,QAAQ,GACR,WAAW,GACX,MAAM,GACN,MAAM,GACN,QAAQ,CAAC;AAEb,4CAA4C;AAC5C,MAAM,M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M,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE;QACJ,OAAO,EAAE,CAAC,CAAC;QACX,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,EAAE,CAAC;QACpB;8FACsF;QACtF,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;KACpB,CAAC;IACF,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { EngineConfig } from "../ai/providers.js";
|
|
2
|
+
import type { Direction } from "./traverse.js";
|
|
3
|
+
export interface WorkspaceBuildOptions {
|
|
4
|
+
deep: boolean;
|
|
5
|
+
extensions?: string[];
|
|
6
|
+
concurrency?: number;
|
|
7
|
+
/** Provider/model/key config for child builds — WITHOUT any contextDir
|
|
8
|
+
* override, so each child writes to its own `<child>/graft/`. */
|
|
9
|
+
childConfig: EngineConfig;
|
|
10
|
+
override?: string;
|
|
11
|
+
}
|
|
12
|
+
/** Build every git child into its own committable `graft/`, then replace the
|
|
13
|
+
* parent's `graft/` with `workspace.json`. Prints the one-time split warning
|
|
14
|
+
* first when migrating away from a mega-graph. */
|
|
15
|
+
export declare function runWorkspaceBuild(root: string, opts: WorkspaceBuildOptions): Promise<void>;
|
|
16
|
+
export declare function runWorkspaceAsk(root: string, override: string | undefined, query: string, opts: {
|
|
17
|
+
limit?: number;
|
|
18
|
+
source?: boolean;
|
|
19
|
+
full?: boolean;
|
|
20
|
+
in?: string;
|
|
21
|
+
json?: boolean;
|
|
22
|
+
}): void;
|
|
23
|
+
export declare function runWorkspaceGrep(root: string, override: string | undefined, pattern: string, opts: {
|
|
24
|
+
ignoreCase?: boolean;
|
|
25
|
+
fixed?: boolean;
|
|
26
|
+
json?: boolean;
|
|
27
|
+
}): void;
|
|
28
|
+
export declare function runWorkspaceMap(root: string, override: string | undefined, opts: {
|
|
29
|
+
maxDirs?: number;
|
|
30
|
+
}): void;
|
|
31
|
+
export declare function runWorkspaceCheck(root: string, override?: string): void;
|
|
32
|
+
export declare function runWorkspaceCallers(root: string, override: string | undefined, symbol: string, opts: {
|
|
33
|
+
direction?: Direction;
|
|
34
|
+
depth?: number;
|
|
35
|
+
in?: string;
|
|
36
|
+
}): void;
|
|
37
|
+
//# sourceMappingURL=workspace-cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-cli.d.ts","sourceRoot":"","sources":["../../src/graph/workspace-cli.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAa/C,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;qEACiE;IACjE,WAAW,EAAE,YAAY,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;kDAEkD;AAClD,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBhG;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GACtF,IAAI,CAIN;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9D,IAAI,CAYN;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,IAAI,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GACzB,IAAI,CAEN;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAIvE;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE;IAAE,SAAS,CAAC,EAAE,SAAS,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3D,IAAI,CAON"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI print/exit wrappers + per-child build orchestration for workspace
|
|
3
|
+
* federation. Kept out of both `cli.ts` (so routing there stays a one-liner
|
|
4
|
+
* per command) and `workspace.ts` (so the core stays free of process/exit and
|
|
5
|
+
* engine dependencies). The federated command bodies live in `workspace.ts`;
|
|
6
|
+
* this file only renders them and wires the child builds through the engine.
|
|
7
|
+
*/
|
|
8
|
+
import { Graft } from "../engine.js";
|
|
9
|
+
import { formatAsk } from "../ask/ask.js";
|
|
10
|
+
import { federateAsk, federateCallers, federateCheck, federateGrep, federateMap, formatGrepResult, migrationNote, splitWorkspace, zeroHitNote, } from "./workspace.js";
|
|
11
|
+
/** Build every git child into its own committable `graft/`, then replace the
|
|
12
|
+
* parent's `graft/` with `workspace.json`. Prints the one-time split warning
|
|
13
|
+
* first when migrating away from a mega-graph. */
|
|
14
|
+
export async function runWorkspaceBuild(root, opts) {
|
|
15
|
+
const buildChild = async (childDir, childName) => {
|
|
16
|
+
const engine = new Graft({ ...opts.childConfig, contextDir: undefined });
|
|
17
|
+
if (opts.deep)
|
|
18
|
+
await engine.init(childDir, { extensions: opts.extensions });
|
|
19
|
+
const g = await engine.graph(childDir, { llm: opts.deep, concurrency: opts.concurrency });
|
|
20
|
+
console.log(`✓ ${childName}/: ${g.nodes} nodes, ${g.edges} edges, ${g.cards} cards [${g.languages.join(", ")}]`);
|
|
21
|
+
for (const e of g.errors)
|
|
22
|
+
console.error(`✗ ${childName}/: ${e}`);
|
|
23
|
+
};
|
|
24
|
+
const { children } = await splitWorkspace(root, opts.override, buildChild, ({ children, migrated }) => {
|
|
25
|
+
if (migrated)
|
|
26
|
+
console.error(migrationNote(children));
|
|
27
|
+
console.error(`building ${children.length} workspace repos: ${children.join(", ")}`);
|
|
28
|
+
});
|
|
29
|
+
console.log(`✓ workspace: ${children.length} repos federated → graft/workspace.json`);
|
|
30
|
+
console.log(` commit each repo's graft/ and this folder's graft/workspace.json.`);
|
|
31
|
+
}
|
|
32
|
+
export function runWorkspaceAsk(root, override, query, opts) {
|
|
33
|
+
const r = federateAsk(root, override, query, { limit: opts.limit, source: opts.source, full: opts.full, in: opts.in });
|
|
34
|
+
if (opts.json)
|
|
35
|
+
console.log(JSON.stringify(r, null, 2));
|
|
36
|
+
else
|
|
37
|
+
process.stdout.write(formatAsk(r));
|
|
38
|
+
}
|
|
39
|
+
export function runWorkspaceGrep(root, override, pattern, opts) {
|
|
40
|
+
const { result, coverage } = federateGrep(root, override, pattern, { ignoreCase: opts.ignoreCase, fixed: opts.fixed });
|
|
41
|
+
if (opts.json) {
|
|
42
|
+
console.log(JSON.stringify(result, null, 2));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (result.totalHits === 0) {
|
|
46
|
+
console.error(coverage ? `${zeroHitNote(result)}\n${coverage}` : zeroHitNote(result));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
process.stdout.write(formatGrepResult(result));
|
|
50
|
+
if (coverage)
|
|
51
|
+
console.log(coverage);
|
|
52
|
+
}
|
|
53
|
+
export function runWorkspaceMap(root, override, opts) {
|
|
54
|
+
process.stdout.write(federateMap(root, override, { maxDirs: opts.maxDirs }));
|
|
55
|
+
}
|
|
56
|
+
export function runWorkspaceCheck(root, override) {
|
|
57
|
+
const { text, ok } = federateCheck(root, override);
|
|
58
|
+
process.stdout.write(text);
|
|
59
|
+
if (!ok)
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
export function runWorkspaceCallers(root, override, symbol, opts) {
|
|
63
|
+
const { text, found } = federateCallers(root, override, symbol, opts);
|
|
64
|
+
if (!found) {
|
|
65
|
+
console.error(`✗ ${text}`);
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
process.stdout.write(text + "\n");
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=workspace-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-cli.js","sourceRoot":"","sources":["../../src/graph/workspace-cli.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EACL,WAAW,EACX,eAAe,EACf,aAAa,EACb,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,WAAW,GACZ,MAAM,gBAAgB,CAAC;AAYxB;;kDAEkD;AAClD,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAAY,EAAE,IAA2B;IAC/E,MAAM,UAAU,GAAG,KAAK,EAAE,QAAgB,EAAE,SAAiB,EAAiB,EAAE;QAC9E,MAAM,MAA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AM,CAAC,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/C,IAAI,QAAQ;QAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,IAAY,EACZ,QAA4B,EAC5B,IAA0B;IAE1B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AAC/E,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,QAAiB;IAC/D,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,aAAa,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACnD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3B,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,IAAY,EACZ,QAA4B,EAC5B,MAAc,EACd,IAA4D;IAE5D,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IACtE,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;QAC3B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { type Direction } from "./traverse.js";
|
|
2
|
+
import type { GraphV1 } from "./types.js";
|
|
3
|
+
import { type AskResult } from "../ask/ask.js";
|
|
4
|
+
import { type GrepResult } from "../search/grep.js";
|
|
5
|
+
import { formatGrepResult, zeroHitNote } from "../search/grep-cli.js";
|
|
6
|
+
/** The parent index written to `<parent>/graft/workspace.json`. Nodes/edges
|
|
7
|
+
* never live at the parent — they live in each child's own `graft/`. */
|
|
8
|
+
export interface WorkspaceV1 {
|
|
9
|
+
version: 1;
|
|
10
|
+
/** Immediate child dir names that are git repos, sorted. */
|
|
11
|
+
children: string[];
|
|
12
|
+
}
|
|
13
|
+
/** Absolute path to the workspace index for a parent root (`<dir>/graft/workspace.json`). */
|
|
14
|
+
export declare function workspacePath(root: string, override?: string): string;
|
|
15
|
+
/** Read the workspace index, or null when the parent has none (not a workspace,
|
|
16
|
+
* or unparseable/foreign json — treated the same as absent). */
|
|
17
|
+
export declare function readWorkspace(root: string, override?: string): WorkspaceV1 | null;
|
|
18
|
+
/** Write the workspace index, sorting children for a stable, minimal git diff. */
|
|
19
|
+
export declare function writeWorkspace(root: string, ws: WorkspaceV1, override?: string): string;
|
|
20
|
+
/** A parent is a workspace BUILD target when it has no own `.git` and ≥2 git
|
|
21
|
+
* children — or it was already split (a `workspace.json` is present). The
|
|
22
|
+
* no-own-`.git` guard keeps a normal repo with git submodules from being
|
|
23
|
+
* mistaken for a workspace. */
|
|
24
|
+
export declare function isWorkspaceBuildRoot(root: string, override?: string): boolean;
|
|
25
|
+
/** True when the parent has a mega-graph from an older single-graph build
|
|
26
|
+
* (`graft/.graph/wiring.json`) — the thing a workspace build migrates away. */
|
|
27
|
+
export declare function hasMegaGraph(root: string, override?: string): boolean;
|
|
28
|
+
/** The EXACT split warning printed once, when a mega-graph parent is first
|
|
29
|
+
* built as a workspace. Templated on the child list so it names the real repos. */
|
|
30
|
+
export declare function migrationNote(children: string[]): string;
|
|
31
|
+
/** Remove the parent's entire `graft/` tree — the mega-graph, its `.cache`, and
|
|
32
|
+
* any stale cards — so after `writeWorkspace` the parent holds ONLY
|
|
33
|
+
* workspace.json. Child graphs live in sibling `<child>/graft/`, never under
|
|
34
|
+
* this dir, so they are untouched. */
|
|
35
|
+
export declare function clearParentGraft(root: string, override?: string): void;
|
|
36
|
+
export interface LoadedChild {
|
|
37
|
+
child: string;
|
|
38
|
+
graph: GraphV1;
|
|
39
|
+
}
|
|
40
|
+
export interface WorkspaceGraphs {
|
|
41
|
+
/** Children (from workspace.json when present, else discovered) that have a
|
|
42
|
+
* built graph, in sorted child order. */
|
|
43
|
+
loaded: LoadedChild[];
|
|
44
|
+
/** Listed children with no built graph yet — surfaced, never silently skipped. */
|
|
45
|
+
missing: string[];
|
|
46
|
+
}
|
|
47
|
+
/** Load each child's graph via `loadGraphCached`. Children come from
|
|
48
|
+
* workspace.json when present, otherwise from live git-child discovery (a
|
|
49
|
+
* not-yet-built workspace). A child without a built graph is counted into
|
|
50
|
+
* `missing`, not dropped. */
|
|
51
|
+
export declare function loadWorkspaceGraphs(root: string, override?: string): WorkspaceGraphs;
|
|
52
|
+
/** "2 of 3 workspace repos have graphs; run graft build to cover repoC" — the
|
|
53
|
+
* coverage line federated commands append when some listed child is unbuilt.
|
|
54
|
+
* Empty string when every child has a graph. */
|
|
55
|
+
export declare function coverageNote(g: WorkspaceGraphs): string;
|
|
56
|
+
export interface FederateAskOptions {
|
|
57
|
+
limit?: number;
|
|
58
|
+
source?: boolean;
|
|
59
|
+
full?: boolean;
|
|
60
|
+
graphRank?: boolean;
|
|
61
|
+
/** Narrow to one child (`repoA`) or a sub-scope within it (`repoA/backend`).
|
|
62
|
+
* A prefix matching NO child throws, listing the repos. */
|
|
63
|
+
in?: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Federated `ask` across a workspace: run each child's own per-scope ask
|
|
67
|
+
* pipeline, then fuse ALL the children's scope lists with the same
|
|
68
|
+
* `fuseScopes` used inside a single multi-scope repo. Each child contributes
|
|
69
|
+
* one fusion scope per intra-child scope, labeled `<child>/<scope>` (or just
|
|
70
|
+
* `<child>` for a child's root scope), so a big repo can't drown a small one —
|
|
71
|
+
* rank positions are comparable across repos where raw scores are not.
|
|
72
|
+
*
|
|
73
|
+
* Returns a normal `AskResult`; `formatAsk` renders it unchanged, labeling each
|
|
74
|
+
* hit `[<child>/…]` via the standard multi-scope path.
|
|
75
|
+
*/
|
|
76
|
+
export declare function federateAsk(root: string, override: string | undefined, query: string, opts?: FederateAskOptions): AskResult;
|
|
77
|
+
/** Merge every child's `GrepResult` into one, prefixing group paths with the
|
|
78
|
+
* child dir and re-sorting by coupling (inDegree desc, path asc) across repos.
|
|
79
|
+
* In-degree stays each child's own — it comes from that child's graph. */
|
|
80
|
+
export declare function federateGrep(root: string, override: string | undefined, pattern: string, opts?: {
|
|
81
|
+
ignoreCase?: boolean;
|
|
82
|
+
fixed?: boolean;
|
|
83
|
+
}): {
|
|
84
|
+
result: GrepResult;
|
|
85
|
+
coverage: string;
|
|
86
|
+
};
|
|
87
|
+
/** One `graft map` section per child (each child's own map, budget split evenly
|
|
88
|
+
* across the loaded children), joined under `<child>/` headers. */
|
|
89
|
+
export declare function federateMap(root: string, override: string | undefined, opts?: {
|
|
90
|
+
maxDirs?: number;
|
|
91
|
+
}): string;
|
|
92
|
+
/** Per-child drift status. `ok` is false when any BUILT child is stale — an
|
|
93
|
+
* unbuilt child is surfaced (coverage), never a failure. */
|
|
94
|
+
export declare function federateCheck(root: string, override?: string): {
|
|
95
|
+
text: string;
|
|
96
|
+
ok: boolean;
|
|
97
|
+
};
|
|
98
|
+
/** Resolve a symbol across every child, grouped per child. Reuses the shared
|
|
99
|
+
* traverse-cli formatters so each block reads exactly like `graft callers`. */
|
|
100
|
+
export declare function federateCallers(root: string, override: string | undefined, symbol: string, opts?: {
|
|
101
|
+
direction?: Direction;
|
|
102
|
+
depth?: number;
|
|
103
|
+
in?: string;
|
|
104
|
+
}): {
|
|
105
|
+
text: string;
|
|
106
|
+
found: boolean;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Split a parent into a workspace: build each git child (via the supplied
|
|
110
|
+
* `buildChild` callback, so this stays free of any engine/LLM dependency),
|
|
111
|
+
* then REPLACE the parent's `graft/` with just `workspace.json`. `onStart`
|
|
112
|
+
* fires once — before any child is built — carrying whether this build is a
|
|
113
|
+
* mega-graph migration, so the caller can print the one-time split warning
|
|
114
|
+
* first, exactly as the spec requires.
|
|
115
|
+
*
|
|
116
|
+
* The child build writes into `<child>/graft/` and is byte-identical to
|
|
117
|
+
* building that child standalone (`buildChild` is just `buildGraph(childDir)`),
|
|
118
|
+
* because nothing about the parent path enters the child's build.
|
|
119
|
+
*/
|
|
120
|
+
export declare function splitWorkspace(root: string, override: string | undefined, buildChild: (childDir: string, childName: string) => Promise<void>, onStart?: (info: {
|
|
121
|
+
children: string[];
|
|
122
|
+
migrated: boolean;
|
|
123
|
+
}) => void): Promise<{
|
|
124
|
+
children: string[];
|
|
125
|
+
migrated: boolean;
|
|
126
|
+
}>;
|
|
127
|
+
export { formatGrepResult, zeroHitNote };
|
|
128
|
+
//# 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,EAA2B,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAExE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,EAA6B,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGtE;wEACwE;AACxE,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,CAAC,CAAC;IACX,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAID,6FAA6F;AAC7F,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM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