@nanonets/graft 0.8.2 → 0.9.1

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.
Files changed (129) hide show
  1. package/README.md +106 -32
  2. package/dist/ai/llm/openai.d.ts +11 -0
  3. package/dist/ai/llm/openai.d.ts.map +1 -1
  4. package/dist/ai/llm/openai.js +33 -1
  5. package/dist/ai/llm/openai.js.map +1 -1
  6. package/dist/ask/ask.d.ts.map +1 -1
  7. package/dist/ask/ask.js +32 -22
  8. package/dist/ask/ask.js.map +1 -1
  9. package/dist/ask/fuse.d.ts +4 -0
  10. package/dist/ask/fuse.d.ts.map +1 -1
  11. package/dist/ask/fuse.js +2 -1
  12. package/dist/ask/fuse.js.map +1 -1
  13. package/dist/ask/index-file.d.ts +1 -0
  14. package/dist/ask/index-file.d.ts.map +1 -1
  15. package/dist/ask/index-file.js +1 -1
  16. package/dist/ask/index-file.js.map +1 -1
  17. package/dist/claude/format.js +1 -1
  18. package/dist/claude/format.js.map +1 -1
  19. package/dist/claude/skill-template.d.ts.map +1 -1
  20. package/dist/claude/skill-template.js +11 -5
  21. package/dist/claude/skill-template.js.map +1 -1
  22. package/dist/cli-meta.d.ts +6 -1
  23. package/dist/cli-meta.d.ts.map +1 -1
  24. package/dist/cli-meta.js +8 -2
  25. package/dist/cli-meta.js.map +1 -1
  26. package/dist/cli-picker.d.ts.map +1 -1
  27. package/dist/cli-picker.js +3 -1
  28. package/dist/cli-picker.js.map +1 -1
  29. package/dist/cli.js +30 -2
  30. package/dist/cli.js.map +1 -1
  31. package/dist/context/build.d.ts.map +1 -1
  32. package/dist/context/build.js +13 -4
  33. package/dist/context/build.js.map +1 -1
  34. package/dist/context/check.d.ts.map +1 -1
  35. package/dist/context/check.js +14 -5
  36. package/dist/context/check.js.map +1 -1
  37. package/dist/context/node-file.d.ts.map +1 -1
  38. package/dist/context/node-file.js +4 -18
  39. package/dist/context/node-file.js.map +1 -1
  40. package/dist/context/savings.d.ts +12 -3
  41. package/dist/context/savings.d.ts.map +1 -1
  42. package/dist/context/savings.js +15 -3
  43. package/dist/context/savings.js.map +1 -1
  44. package/dist/graph/build.d.ts +3 -0
  45. package/dist/graph/build.d.ts.map +1 -1
  46. package/dist/graph/build.js +41 -12
  47. package/dist/graph/build.js.map +1 -1
  48. package/dist/graph/cards.d.ts.map +1 -1
  49. package/dist/graph/cards.js +3 -2
  50. package/dist/graph/cards.js.map +1 -1
  51. package/dist/graph/check.d.ts.map +1 -1
  52. package/dist/graph/check.js +7 -4
  53. package/dist/graph/check.js.map +1 -1
  54. package/dist/graph/extract-cache.d.ts +1 -0
  55. package/dist/graph/extract-cache.d.ts.map +1 -1
  56. package/dist/graph/extract-cache.js +1 -1
  57. package/dist/graph/extract-cache.js.map +1 -1
  58. package/dist/graph/extract.d.ts +17 -0
  59. package/dist/graph/extract.d.ts.map +1 -1
  60. package/dist/graph/extract.js +188 -17
  61. package/dist/graph/extract.js.map +1 -1
  62. package/dist/graph/fingerprint.d.ts +1 -0
  63. package/dist/graph/fingerprint.d.ts.map +1 -1
  64. package/dist/graph/fingerprint.js +15 -6
  65. package/dist/graph/fingerprint.js.map +1 -1
  66. package/dist/graph/map.d.ts.map +1 -1
  67. package/dist/graph/map.js +8 -6
  68. package/dist/graph/map.js.map +1 -1
  69. package/dist/graph/refresh.d.ts.map +1 -1
  70. package/dist/graph/refresh.js +61 -13
  71. package/dist/graph/refresh.js.map +1 -1
  72. package/dist/graph/resolve.d.ts.map +1 -1
  73. package/dist/graph/resolve.js +36 -43
  74. package/dist/graph/resolve.js.map +1 -1
  75. package/dist/graph/scopes.d.ts +14 -2
  76. package/dist/graph/scopes.d.ts.map +1 -1
  77. package/dist/graph/scopes.js +51 -81
  78. package/dist/graph/scopes.js.map +1 -1
  79. package/dist/graph/seed.d.ts +38 -0
  80. package/dist/graph/seed.d.ts.map +1 -0
  81. package/dist/graph/seed.js +226 -0
  82. package/dist/graph/seed.js.map +1 -0
  83. package/dist/graph/source-files.d.ts +13 -5
  84. package/dist/graph/source-files.d.ts.map +1 -1
  85. package/dist/graph/source-files.js +16 -7
  86. package/dist/graph/source-files.js.map +1 -1
  87. package/dist/graph/traverse-cli.d.ts +8 -2
  88. package/dist/graph/traverse-cli.d.ts.map +1 -1
  89. package/dist/graph/traverse-cli.js +28 -8
  90. package/dist/graph/traverse-cli.js.map +1 -1
  91. package/dist/graph/traverse.d.ts +3 -1
  92. package/dist/graph/traverse.d.ts.map +1 -1
  93. package/dist/graph/traverse.js +22 -3
  94. package/dist/graph/traverse.js.map +1 -1
  95. package/dist/graph/types.d.ts +1 -0
  96. package/dist/graph/types.d.ts.map +1 -1
  97. package/dist/graph/workspace-cli.d.ts +5 -0
  98. package/dist/graph/workspace-cli.d.ts.map +1 -1
  99. package/dist/graph/workspace-cli.js +7 -0
  100. package/dist/graph/workspace-cli.js.map +1 -1
  101. package/dist/graph/workspace.js +3 -3
  102. package/dist/graph/workspace.js.map +1 -1
  103. package/dist/ingest/fs.d.ts +30 -2
  104. package/dist/ingest/fs.d.ts.map +1 -1
  105. package/dist/ingest/fs.js +84 -8
  106. package/dist/ingest/fs.js.map +1 -1
  107. package/dist/mcp/tools.js +5 -5
  108. package/dist/mcp/tools.js.map +1 -1
  109. package/dist/search/grep-cli.d.ts.map +1 -1
  110. package/dist/search/grep-cli.js +12 -10
  111. package/dist/search/grep-cli.js.map +1 -1
  112. package/dist/search/grep.d.ts +2 -1
  113. package/dist/search/grep.d.ts.map +1 -1
  114. package/dist/search/grep.js +16 -3
  115. package/dist/search/grep.js.map +1 -1
  116. package/dist/util/paths.d.ts +29 -0
  117. package/dist/util/paths.d.ts.map +1 -0
  118. package/dist/util/paths.js +71 -0
  119. package/dist/util/paths.js.map +1 -0
  120. package/dist/util/source.d.ts +4 -0
  121. package/dist/util/source.d.ts.map +1 -0
  122. package/dist/util/source.js +12 -0
  123. package/dist/util/source.js.map +1 -0
  124. package/dist/util/state.d.ts +25 -0
  125. package/dist/util/state.d.ts.map +1 -1
  126. package/dist/util/state.js +41 -0
  127. package/dist/util/state.js.map +1 -1
  128. package/package.json +2 -2
  129. package/scripts/run-tests.mjs +43 -0
@@ -21,37 +21,26 @@
21
21
  * 7. `label` = `prefix` (both "" for root); ordering is prefix-length desc,
22
22
  * then lexicographic.
23
23
  */
24
- import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
24
+ import { existsSync, readdirSync, readFileSync } from "node:fs";
25
25
  import { join, resolve } from "node:path";
26
- import { SKIP_DIRS } from "../ingest/fs.js";
26
+ import { shouldSkipDir, walkDir } from "../ingest/fs.js";
27
+ import { relPosix } from "../util/paths.js";
28
+ import { readIncludeDirs } from "../util/state.js";
27
29
  /** Project-marker files, checked in this order (also the order `markers` is built in). */
28
30
  const MARKERS = ["package.json", "go.mod", "pyproject.toml", "setup.py", "Cargo.toml"];
29
31
  const CANONICAL_ROOT = [{ prefix: "", label: "", markers: [] }];
30
- /** Recursively collect every directory under `root` (posix rel path, "" = root itself),
31
- * reusing `walkDir`'s skip rules (dot-dirs, `SKIP_DIRS`) so build-output and dependency
32
- * trees are never scanned for markers. */
33
- function collectDirs(root) {
34
- const out = [""];
35
- const walk = (absDir, relDir) => {
36
- let entries;
37
- try {
38
- entries = readdirSync(absDir, { withFileTypes: true });
39
- }
40
- catch {
41
- return;
42
- }
43
- for (const entry of entries) {
44
- if (!entry.isDirectory())
45
- continue;
46
- if (entry.name.startsWith(".") || SKIP_DIRS.has(entry.name))
47
- continue;
48
- const rel = relDir === "" ? entry.name : `${relDir}/${entry.name}`;
49
- out.push(rel);
50
- walk(join(absDir, entry.name), rel);
51
- }
52
- };
53
- walk(root, "");
54
- return out;
32
+ /** Collect directories represented by the canonical visible file set. Building
33
+ * this from `walkDir` keeps scope discovery aligned with extraction: an ignored
34
+ * generated tree cannot become a marker or workspace scope. */
35
+ function collectDirs(root, repoFiles) {
36
+ const out = new Set([""]);
37
+ for (const abs of repoFiles) {
38
+ const parts = relPosix(root, abs).split("/");
39
+ parts.pop();
40
+ for (let i = 1; i <= parts.length; i++)
41
+ out.add(parts.slice(0, i).join("/"));
42
+ }
43
+ return [...out];
55
44
  }
56
45
  /** Minimal `packages:` list parser for `pnpm-workspace.yaml` — no YAML dependency,
57
46
  * handles the `packages:\n - 'glob'\n - "glob"` form pnpm actually generates. */
@@ -104,10 +93,9 @@ function readWorkspaceGlobs(root) {
104
93
  }
105
94
  return null;
106
95
  }
107
- /** Resolve one workspace glob to matched dir paths (posix, rel to `root`). Supports
108
- * only `dir/*` (immediate subdirs) and `dir/**` (any nested depth) forms, implemented
109
- * with plain `readdir` — no glob dependency, per spec. Unsupported forms resolve empty. */
110
- function resolveGlob(root, pattern) {
96
+ /** Resolve one workspace glob against visible directories only. Supports
97
+ * `dir/*` (immediate subdirs), `dir/**` (any nested depth), and literal dirs. */
98
+ function resolveGlob(dirs, pattern) {
111
99
  const norm = pattern.replace(/\\/g, "/").replace(/\/$/, "");
112
100
  let base;
113
101
  let recursive;
@@ -128,57 +116,26 @@ function resolveGlob(root, pattern) {
128
116
  recursive = false;
129
117
  }
130
118
  else if (!norm.includes("*")) {
131
- // Literal entry (no glob chars), e.g. `packages: ['apps/*', 'docs']` — a plain
132
- // workspace-list entry that names a real directory counts as a workspace match
133
- // in its own right, same as a resolved glob would. Without this, a literal
134
- // entry silently resolves to nothing while Rule 2 still strips its
135
- // `package.json` marker (it's a JS-family dir that never matched the glob
136
- // set), de-scoping a real workspace package.
137
- try {
138
- return existsSync(join(root, norm)) && statSync(join(root, norm)).isDirectory()
139
- ? [norm]
140
- : [];
141
- }
142
- catch {
143
- return [];
144
- }
119
+ return dirs.includes(norm) ? [norm] : [];
145
120
  }
146
121
  else {
147
122
  return []; // unsupported glob form
148
123
  }
149
- const results = [];
150
- const listDirs = (absDir, relDir) => {
151
- let entries;
152
- try {
153
- entries = readdirSync(absDir, { withFileTypes: true });
154
- }
155
- catch {
156
- return [];
157
- }
158
- return entries
159
- .filter((e) => e.isDirectory() && !e.name.startsWith(".") && !SKIP_DIRS.has(e.name))
160
- .map((e) => (relDir === "" ? e.name : `${relDir}/${e.name}`));
161
- };
162
- const baseAbs = base === "" ? root : join(root, base);
163
- if (!recursive) {
164
- results.push(...listDirs(baseAbs, base));
165
- }
166
- else {
167
- const stack = [base];
168
- while (stack.length) {
169
- const relDir = stack.pop();
170
- const absDir = relDir === "" ? root : join(root, relDir);
171
- const children = listDirs(absDir, relDir);
172
- results.push(...children);
173
- stack.push(...children);
174
- }
175
- }
176
- return results;
124
+ return dirs.filter((dir) => {
125
+ if (dir === "")
126
+ return false;
127
+ if (recursive)
128
+ return base === "" || dir.startsWith(`${base}/`);
129
+ const slash = dir.lastIndexOf("/");
130
+ const parent = slash === -1 ? "" : dir.slice(0, slash);
131
+ return parent === base;
132
+ });
177
133
  }
178
- /** Walk the tree (reusing `walkDir`'s skip rules) and find project-marker dirs. */
179
- export function discoverScopes(root) {
134
+ /** Walk the tree (reusing `walkDir`'s skip rules, including the repo's persisted
135
+ * `--include-dir` override) and find project-marker dirs. */
136
+ export function discoverScopes(root, repoFiles = walkDir(root, readIncludeDirs(resolve(root)))) {
180
137
  const absRoot = resolve(root);
181
- const dirs = collectDirs(absRoot);
138
+ const dirs = collectDirs(absRoot, repoFiles);
182
139
  const markerMap = new Map();
183
140
  for (const dir of dirs) {
184
141
  const found = MARKERS.filter((m) => existsSync(join(absRoot, dir, m)));
@@ -189,7 +146,7 @@ export function discoverScopes(root) {
189
146
  const workspaceMatches = new Set();
190
147
  if (workspaceGlobs) {
191
148
  for (const glob of workspaceGlobs) {
192
- for (const dir of resolveGlob(absRoot, glob))
149
+ for (const dir of resolveGlob(dirs, glob))
193
150
  workspaceMatches.add(dir);
194
151
  }
195
152
  }
@@ -342,10 +299,26 @@ export function scopesHereClause(scopes) {
342
299
  export function pathUnderPrefix(path, prefix) {
343
300
  return prefix === "" || path === prefix || path.startsWith(`${prefix}/`);
344
301
  }
302
+ /**
303
+ * Validate a normalized `--in` prefix against the graph before a query runs. A
304
+ * prefix matching no indexed node is a caller mistake (typo, wrong sub-project,
305
+ * or a mid-path fragment where a prefix is required) rather than a legitimate
306
+ * zero-hit query, so every `--in`-taking command fails loudly and identically
307
+ * instead of printing empty output the caller has to interpret.
308
+ *
309
+ * Pass the prefix through `normalizePathPrefix` first — an un-normalized
310
+ * `src\gpu` or `src/` will not match anything here.
311
+ */
312
+ export function assertPrefixIndexed(graph, prefix) {
313
+ if (!prefix || graph.nodes.some((n) => pathUnderPrefix(n.path, prefix)))
314
+ return;
315
+ throw new Error(`nothing indexed under "${prefix}/"${scopesHereClause(scopesOfGraph(graph))} (or any path prefix)`);
316
+ }
345
317
  /** Immediate subdirs of `root` that are themselves git repos (have `.git`).
346
318
  * Used by workspace federation (Task 5). */
347
319
  export function discoverWorkspaceChildren(root) {
348
320
  const absRoot = resolve(root);
321
+ const includes = readIncludeDirs(absRoot);
349
322
  let entries;
350
323
  try {
351
324
  entries = readdirSync(absRoot, { withFileTypes: true });
@@ -354,10 +327,7 @@ export function discoverWorkspaceChildren(root) {
354
327
  return [];
355
328
  }
356
329
  return entries
357
- .filter((e) => e.isDirectory() &&
358
- !e.name.startsWith(".") &&
359
- !SKIP_DIRS.has(e.name) &&
360
- existsSync(join(absRoot, e.name, ".git")))
330
+ .filter((e) => e.isDirectory() && !shouldSkipDir(e.name, includes) && existsSync(join(absRoot, e.name, ".git")))
361
331
  .map((e) => e.name);
362
332
  }
363
333
  /** Every consumer's entry point to a graph's scopes: absent `meta.scopes` (old
@@ -1 +1 @@
1
- {"version":3,"file":"scopes.js","sourceRoot":"","sources":["../../src/graph/scopes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAe,MAAM,SAAS,CAAC;AACvF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CA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AAC,eAAe,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAAE,OAAO;IAChF,MAAM,IAAI,KAAK,CACb,0BAA0B,MAAM,KAAK,gBAAgB,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,uBAAuB,CACnG,CAAC;AACJ,CAAC;AAED;4CAC4C;AAC5C,MAAM,UAAU,yBAAyB,CAAC,IAAY;IACpD,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,MAAM,QAAQ,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IAC1C,IAAI,OAAiB,CAAC;IACtB,IAAI,CAAC;QACH,OAAO,GAAG,WAAW,CAAC,OAAO,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,OAAO;SACX,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;SAC/G,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC;AAED;;2EAE2E;AAC3E,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,IAAI,cAAc,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,38 @@
1
+ /** Env kill switch, mirroring `GRAFT_NO_REFRESH` in ./refresh.ts. */
2
+ export declare function seedDisabled(): boolean;
3
+ /**
4
+ * The main checkout of the repo `root` is a linked worktree of, or null when `root`
5
+ * isn't one (which is the common case, and not an error).
6
+ *
7
+ * Filesystem-only on purpose: no `git` subprocess on a path that runs before every
8
+ * query. The shapes it has to tell apart:
9
+ *
10
+ * - `<root>/.git` is a **directory** → this *is* the main checkout. Nothing to seed.
11
+ * - `gitdir: <main>/.git/worktrees/<name>` → a linked worktree. `commondir` inside
12
+ * that dir points back at the shared `.git` (`../..`), whose parent is the main
13
+ * checkout.
14
+ * - `gitdir: <super>/.git/modules/<name>` → a **submodule**. Identical file shape,
15
+ * completely different thing: a submodule is its own repo and its parent's `graft/`
16
+ * describes different code entirely. The `worktrees` path segment is what rejects it.
17
+ * - A bare repo or `--separate-git-dir` layout, where the resolved common dir isn't
18
+ * named `.git` and there may be no working tree at all → null.
19
+ */
20
+ export declare function mainWorktreeRoot(root: string): string | null;
21
+ export interface SeedResult {
22
+ seeded: boolean;
23
+ /** The main checkout the graph came from, when one was used. */
24
+ from?: string;
25
+ }
26
+ /**
27
+ * Copy the parent checkout's graph into `root`'s own `graft/`, if all of this holds:
28
+ * `root` is a linked worktree, it has no graph yet, the parent has one, and no `--dir`
29
+ * override is in play (a custom output dir can't be mapped to a sibling checkout —
30
+ * the same conservatism `ensureGitignored` applies).
31
+ *
32
+ * Best-effort by contract: the caller's fallback is the behaviour that existed before
33
+ * this function did, so every failure returns `{ seeded: false }` rather than raising.
34
+ */
35
+ export declare function seedGraph(root: string, opts?: {
36
+ contextDir?: string;
37
+ }): SeedResult;
38
+ //# sourceMappingURL=seed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../../src/graph/seed.ts"],"names":[],"mappings":"AAwDA,qEAAqE;AACrE,wBAAgB,YAAY,IAAI,OAAO,CAGtC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA4B5D;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,gEAAgE;IAChE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAwFD;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,UAAU,CAiBtF"}
@@ -0,0 +1,226 @@
1
+ /**
2
+ * `seedGraph` — give a linked git worktree the graph its parent checkout already has.
3
+ *
4
+ * `graft/` is a local cache, so it is gitignored, so `git worktree add` never checks
5
+ * it out: a worktree starts with `src/` and `.claude/` and no graph at all. Every
6
+ * MCP tool then answers "no graph found — run graft build first" for the whole
7
+ * session, and the passive surface (`INDEX.md`, the cards) is missing too. The agent
8
+ * that was supposed to be cheapest in a fresh worktree is instead blind in one.
9
+ *
10
+ * What travels is the graph and the sidecars a query reads — never the markdown; see
11
+ * `seedable` for why the cards are the parent's branch and not this one's.
12
+ *
13
+ * The parent checkout has not gone anywhere, though — a worktree's `.git` is a *file*
14
+ * naming it, and the harness that creates these worktrees already reaches back the
15
+ * same way (Claude Code symlinks `node_modules` to the parent's). So: copy the
16
+ * parent's `graft/` in, then let the ordinary refresh gate repair the difference.
17
+ *
18
+ * Copy, not symlink. `node_modules` is the same for every branch; a graph is a set of
19
+ * `file:line` spans for one specific tree, so a shared one would have the worktree
20
+ * rewriting the parent's graph with its own branch's line numbers. What makes the
21
+ * copy worth doing rather than just rebuilding cold:
22
+ *
23
+ * - **The Tier-2 meaning layer survives.** Summaries and cruxes cost real money;
24
+ * `buildGraph` folds a prior `wiring.json` in by `body_hash`, so an unchanged
25
+ * function keeps the summary someone already paid for. A cold build throws them all
26
+ * away and the worktree silently drops to structural-only answers.
27
+ * - **The repair is small.** `probeDrift` confirms a suspect file by content hash, so
28
+ * a fresh checkout's brand-new mtimes cost one hashing pass and nothing more; the
29
+ * drift that survives is exactly the diff between the two checkouts' commits.
30
+ * - **$0 and offline**, like everything else on the query path.
31
+ *
32
+ * Never writes to the parent, never throws, and no-ops unless there is genuinely a
33
+ * built parent checkout on disk — so a fresh clone, CI, or a cloud session whose repo
34
+ * was *cloned* rather than worktree'd behaves exactly as it did before: "run graft
35
+ * build first".
36
+ */
37
+ import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, } from "node:fs";
38
+ import { basename, dirname, isAbsolute, join, resolve } from "node:path";
39
+ import { ASK_INDEX_FILE } from "../ask/index-file.js";
40
+ import { CACHE_DIR, contextDirFor } from "../context/node-file.js";
41
+ import { EXTRACT_CACHE_PREFIX } from "./extract-cache.js";
42
+ import { FINGERPRINT_PREFIX } from "./fingerprint.js";
43
+ import { GRAPH_DIR, wiringPath } from "./write.js";
44
+ /** The one line a linked worktree's `.git` file carries. */
45
+ const GITDIR_KEY = "gitdir:";
46
+ /** Env kill switch, mirroring `GRAFT_NO_REFRESH` in ./refresh.ts. */
47
+ export function seedDisabled() {
48
+ const v = process.env.GRAFT_NO_SEED;
49
+ return v !== undefined && v !== "" && v !== "0" && v !== "false";
50
+ }
51
+ /**
52
+ * The main checkout of the repo `root` is a linked worktree of, or null when `root`
53
+ * isn't one (which is the common case, and not an error).
54
+ *
55
+ * Filesystem-only on purpose: no `git` subprocess on a path that runs before every
56
+ * query. The shapes it has to tell apart:
57
+ *
58
+ * - `<root>/.git` is a **directory** → this *is* the main checkout. Nothing to seed.
59
+ * - `gitdir: <main>/.git/worktrees/<name>` → a linked worktree. `commondir` inside
60
+ * that dir points back at the shared `.git` (`../..`), whose parent is the main
61
+ * checkout.
62
+ * - `gitdir: <super>/.git/modules/<name>` → a **submodule**. Identical file shape,
63
+ * completely different thing: a submodule is its own repo and its parent's `graft/`
64
+ * describes different code entirely. The `worktrees` path segment is what rejects it.
65
+ * - A bare repo or `--separate-git-dir` layout, where the resolved common dir isn't
66
+ * named `.git` and there may be no working tree at all → null.
67
+ */
68
+ export function mainWorktreeRoot(root) {
69
+ try {
70
+ const dot = join(root, ".git");
71
+ if (statSync(dot).isDirectory())
72
+ return null;
73
+ // Read the pointer without a regex. `/^gitdir:[ \t]*(.+?)[ \t]*$/m` is the
74
+ // polynomial-ReDoS shape CodeQL flagged on `ensureSearchable` (`js/polynomial-redos`,
75
+ // fixed in 44a191e): `.` also matches space and tab, so the lazy group and the
76
+ // trailing `[ \t]*` overlap and a line of blanks costs O(n²). Same conclusion as
77
+ // that fix — the ambiguity buys nothing, and split/startsWith/trim is linear and
78
+ // plainer. `trim` also absorbs the `\r` of a CRLF checkout.
79
+ const line = readFileSync(dot, "utf8").split("\n").find((l) => l.startsWith(GITDIR_KEY));
80
+ if (line === undefined)
81
+ return null;
82
+ const target = line.slice(GITDIR_KEY.length).trim();
83
+ if (!target)
84
+ return null;
85
+ const gitdir = isAbsolute(target) ? target : resolve(root, target);
86
+ if (basename(dirname(gitdir)) !== "worktrees")
87
+ return null;
88
+ const rel = readFileSync(join(gitdir, "commondir"), "utf8").trim();
89
+ if (!rel)
90
+ return null;
91
+ const common = isAbsolute(rel) ? rel : resolve(gitdir, rel);
92
+ if (basename(common) !== ".git" || !statSync(common).isDirectory())
93
+ return null;
94
+ const main = dirname(common);
95
+ if (resolve(main) === resolve(root))
96
+ return null;
97
+ return main;
98
+ }
99
+ catch {
100
+ // No `.git` at all, an unreadable one, a `commondir` that doesn't exist: all of
101
+ // them mean "can't seed from here", which is the same answer as "not a worktree".
102
+ return null;
103
+ }
104
+ }
105
+ const NOT_SEEDED = { seeded: false };
106
+ /**
107
+ * An allowlist, not a skip list: is this repo-relative path (posix) one of the few
108
+ * files a seed may bring across?
109
+ *
110
+ * The gate that calls this promises "writes only what a query reads — the graph, the
111
+ * `ask` sidecar, the freshness record" (see the header of ./refresh.ts). A copy that
112
+ * wrote anything else would turn a read into a write of the repo, so the copy honours
113
+ * the same list. The extraction memo is on it because the refresh immediately after
114
+ * rewrites that file anyway, and replaying it is what keeps the repair cheap.
115
+ *
116
+ * **Deliberately absent: the cards and `INDEX.md`.** They would land as this
117
+ * checkout's documentation while describing the *parent's* branch, and nothing on the
118
+ * query path rewrites them (`writeCards`/`writeIndex` sit behind `!graphOnly`), so they
119
+ * would stay wrong indefinitely. An explicit `graft build` regenerates them from this
120
+ * checkout's own graph — and prunes the ones that no longer apply — which is both
121
+ * correct and nearly free once the graph is here.
122
+ *
123
+ * Also absent, because it belongs to the checkout that produced it: `.cache/session/`
124
+ * (another session's transcripts), `.sync.lock` (another process's lock), and
125
+ * `stats.json` (this checkout earns its own savings and dirty flag).
126
+ */
127
+ function seedable(rel) {
128
+ // The dirs themselves, or cpSync would never look inside them.
129
+ if (rel === "" || rel === GRAPH_DIR || rel === CACHE_DIR)
130
+ return true;
131
+ if (!rel.startsWith(`${CACHE_DIR}/`))
132
+ return false; // incl. the graph: `installGraph` places it
133
+ const name = rel.slice(CACHE_DIR.length + 1);
134
+ return (name === ASK_INDEX_FILE ||
135
+ name.startsWith(`${EXTRACT_CACHE_PREFIX}.`) ||
136
+ name.startsWith(`${FINGERPRINT_PREFIX}.`));
137
+ }
138
+ /**
139
+ * Copy `srcDir` into `outDir`, keeping only what {@link seedable} allows.
140
+ *
141
+ * Walked by hand rather than through `cpSync`'s `filter`, which did not hold on
142
+ * Windows: the graph arrived — it is placed directly, by {@link installGraph} — while
143
+ * every allowlisted sidecar next to it was dropped. A seeded worktree therefore had no
144
+ * fingerprint, `probeDrift` read that as "never built", and the query right behind the
145
+ * seed rebuilt the whole repo instead of the diff against the parent: precisely the
146
+ * cost seeding exists to avoid, and silent, because a full rebuild still answers
147
+ * correctly. It only surfaced as a `(? files changed)` note on the CI leg.
148
+ *
149
+ * Composing `rel` from the segments this walk joined itself is what fixes it — the
150
+ * allowlist no longer depends on the form `cpSync` chooses to hand its callback, and
151
+ * `rel` is posix by construction rather than by conversion. Also narrower than the old
152
+ * copy in one way worth keeping: only real files and directories travel, never a
153
+ * symlink, and nothing in the allowlist is one.
154
+ */
155
+ function copyTree(srcDir, outDir) {
156
+ const walk = (rel) => {
157
+ const from = rel ? join(srcDir, rel) : srcDir;
158
+ mkdirSync(rel ? join(outDir, rel) : outDir, { recursive: true });
159
+ for (const entry of readdirSync(from, { withFileTypes: true })) {
160
+ const childRel = rel ? `${rel}/${entry.name}` : entry.name;
161
+ if (!seedable(childRel))
162
+ continue;
163
+ if (entry.isDirectory())
164
+ walk(childRel);
165
+ else if (entry.isFile())
166
+ copyFileSync(join(from, entry.name), join(outDir, childRel));
167
+ }
168
+ };
169
+ walk("");
170
+ }
171
+ /**
172
+ * Put `wiring.json` in place last, via a temp file and a rename.
173
+ *
174
+ * Its presence is the flag every caller reads to mean "this repo has a graph"
175
+ * (`refresh.ts`, `workspace.ts`, every MCP tool). So it must appear only once the
176
+ * rest of the copy has landed and must never appear half-written: a seed killed
177
+ * midway then leaves no graph, and the next call simply seeds again.
178
+ */
179
+ function installGraph(srcGraph, destGraph) {
180
+ mkdirSync(dirname(destGraph), { recursive: true });
181
+ const tmp = `${destGraph}.seed.${process.pid}`;
182
+ try {
183
+ copyFileSync(srcGraph, tmp);
184
+ renameSync(tmp, destGraph);
185
+ }
186
+ catch (err) {
187
+ try {
188
+ rmSync(tmp, { force: true });
189
+ }
190
+ catch { /* nothing to clean up */ }
191
+ throw err;
192
+ }
193
+ }
194
+ /**
195
+ * Copy the parent checkout's graph into `root`'s own `graft/`, if all of this holds:
196
+ * `root` is a linked worktree, it has no graph yet, the parent has one, and no `--dir`
197
+ * override is in play (a custom output dir can't be mapped to a sibling checkout —
198
+ * the same conservatism `ensureGitignored` applies).
199
+ *
200
+ * Best-effort by contract: the caller's fallback is the behaviour that existed before
201
+ * this function did, so every failure returns `{ seeded: false }` rather than raising.
202
+ */
203
+ export function seedGraph(root, opts = {}) {
204
+ if (opts.contextDir || seedDisabled())
205
+ return NOT_SEEDED;
206
+ try {
207
+ const dir = resolve(root);
208
+ const outDir = contextDirFor(dir);
209
+ if (existsSync(wiringPath(outDir)))
210
+ return NOT_SEEDED; // already has its own
211
+ const main = mainWorktreeRoot(dir);
212
+ if (!main)
213
+ return NOT_SEEDED;
214
+ const srcDir = contextDirFor(main);
215
+ const srcGraph = wiringPath(srcDir);
216
+ if (!existsSync(srcGraph))
217
+ return NOT_SEEDED; // parent never built either
218
+ copyTree(srcDir, outDir);
219
+ installGraph(srcGraph, wiringPath(outDir));
220
+ return { seeded: true, from: main };
221
+ }
222
+ catch {
223
+ return NOT_SEEDED;
224
+ }
225
+ }
226
+ //# sourceMappingURL=seed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed.js","sourceRoot":"","sources":["../../src/graph/seed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,EACL,YAAY,EACZ,UAAU,EACV,SAAS,EACT,YAAY,EACZ,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,GACT,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEnD,4DAA4D;AAC5D,MAAM,UAAU,GAAG,SAAS,CAAC;AAE7B,qEAAqE;AACrE,MAAM,UAAU,YAAY;IAC1B,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IACpC,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,OAAO,CAAC;AACnE,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,EAA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;;;GAQG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,OAAgC,EAAE;IACxE,IAAI,IAAI,CAAC,UAAU,IAAI,YAAY,EAAE;QAAE,OAAO,UAAU,CAAC;IACzD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1B,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAAE,OAAO,UAAU,CAAC,CAAC,sBAAsB;QAC7E,MAAM,IAAI,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI;YAAE,OAAO,UAAU,CAAC;QAC7B,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;QACnC,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;YAAE,OAAO,UAAU,CAAC,CAAC,4BAA4B;QAC1E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACzB,YAAY,CAAC,QAAQ,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;QAC3C,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,UAAU,CAAC;IACpB,CAAC;AACH,CAAC"}
@@ -1,10 +1,18 @@
1
- /** The source files a graph build parses: supported languages, minus the output dir. */
2
- export declare function listSourceFiles(root: string, outDir: string): string[];
1
+ /**
2
+ * The source files a graph build parses: supported languages, minus the
3
+ * output dir. When no pre-enumerated `repoFiles` is passed, the walk reads
4
+ * `root`'s persisted `--include-dir` override (if any) directly from state —
5
+ * so every caller that enumerates through here (the fingerprint probe, the
6
+ * hooks/refresh path, none of which ever see a CLI flag) behaves identically
7
+ * to the `graft build --include-dir` invocation that set it.
8
+ */
9
+ export declare function listSourceFiles(root: string, outDir: string, repoFiles?: string[]): string[];
3
10
  export interface SourceStat {
4
11
  /** Absolute path. */
5
12
  abs: string;
6
- /** `relative(root, abs)` — exactly the form `buildGraph` uses for node ids and
7
- * `checkGraph` diffs against, so cache keys and ids can never disagree. */
13
+ /** Repo-relative, posix (`relPosix`) — exactly the form `buildGraph` uses for
14
+ * node ids and `checkGraph` diffs against, so cache keys and ids can never
15
+ * disagree. Posix on every platform: see `../util/paths.ts`. */
8
16
  rel: string;
9
17
  size: number;
10
18
  mtimeMs: number;
@@ -14,5 +22,5 @@ export interface SourceStat {
14
22
  * both the freshness probe and the extraction cache. Files that vanish between
15
23
  * the walk and the stat are dropped (same fail-soft posture as `walkDir`).
16
24
  */
17
- export declare function listSourceStats(root: string, outDir: string): SourceStat[];
25
+ export declare function listSourceStats(root: string, outDir: string, repoFiles?: string[]): SourceStat[];
18
26
  //# sourceMappingURL=source-files.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"source-files.d.ts","sourceRoot":"","sources":["../../src/graph/source-files.ts"],"names":[],"mappings":"AAaA,wFAAwF;AACxF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAEtE;AAED,MAAM,WAAW,UAAU;IACzB,qBAAqB;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ;+EAC2E;IAC3E,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,EAAE,CAY1E"}
1
+ {"version":3,"file":"source-files.d.ts","sourceRoot":"","sources":["../../src/graph/source-files.ts"],"names":[],"mappings":"AAeA;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,MAAM,EAAkD,GAClE,MAAM,EAAE,CAEV;AAED,MAAM,WAAW,UAAU;IACzB,qBAAqB;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ;;oEAEgE;IAChE,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,CAYhG"}
@@ -7,21 +7,30 @@
7
7
  * {@link listSourceFiles} so its existing importers are unaffected.
8
8
  */
9
9
  import { statSync } from "node:fs";
10
- import { relative } from "node:path";
10
+ import { resolve } from "node:path";
11
11
  import { walkDir } from "../ingest/fs.js";
12
+ import { relPosix } from "../util/paths.js";
13
+ import { readIncludeDirs } from "../util/state.js";
12
14
  import { languageOf } from "./extract.js";
13
- /** The source files a graph build parses: supported languages, minus the output dir. */
14
- export function listSourceFiles(root, outDir) {
15
- return walkDir(root).filter((f) => !f.startsWith(outDir) && languageOf(f) !== null);
15
+ /**
16
+ * The source files a graph build parses: supported languages, minus the
17
+ * output dir. When no pre-enumerated `repoFiles` is passed, the walk reads
18
+ * `root`'s persisted `--include-dir` override (if any) directly from state —
19
+ * so every caller that enumerates through here (the fingerprint probe, the
20
+ * hooks/refresh path, none of which ever see a CLI flag) behaves identically
21
+ * to the `graft build --include-dir` invocation that set it.
22
+ */
23
+ export function listSourceFiles(root, outDir, repoFiles = walkDir(root, readIncludeDirs(resolve(root)))) {
24
+ return repoFiles.filter((f) => !f.startsWith(outDir) && languageOf(f) !== null);
16
25
  }
17
26
  /**
18
27
  * {@link listSourceFiles} plus each file's `(size, mtimeMs)` — the currency of
19
28
  * both the freshness probe and the extraction cache. Files that vanish between
20
29
  * the walk and the stat are dropped (same fail-soft posture as `walkDir`).
21
30
  */
22
- export function listSourceStats(root, outDir) {
31
+ export function listSourceStats(root, outDir, repoFiles) {
23
32
  const out = [];
24
- for (const abs of listSourceFiles(root, outDir)) {
33
+ for (const abs of listSourceFiles(root, outDir, repoFiles)) {
25
34
  let s;
26
35
  try {
27
36
  s = statSync(abs);
@@ -29,7 +38,7 @@ export function listSourceStats(root, outDir) {
29
38
  catch {
30
39
  continue;
31
40
  }
32
- out.push({ abs, rel: relative(root, abs), size: s.size, mtimeMs: s.mtimeMs });
41
+ out.push({ abs, rel: relPosix(root, abs), size: s.size, mtimeMs: s.mtimeMs });
33
42
  }
34
43
  return out;
35
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"source-files.js","sourceRoot":"","sources":["../../src/graph/source-files.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,wFAAwF;AACxF,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,MAAc;IAC1D,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;AACtF,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,MAAc;IAC1D,MAAM,GAAG,GAAiB,EAAE,CAAC;IAC7B,KAAK,MAAM,GAAG,IAAI,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC;QAChD,IAAI,CAAoC,CAAC;QACzC,IAAI,CAAC;YACH,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QACpB,CAAC;QAAC,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AC;YACH,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QACpB,CAAC;QAAC,MAAM,CAAC;YACP,SAAS;QACX,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IAChF,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -26,8 +26,14 @@ export declare function callersSavings(graph: GraphV1, results: {
26
26
  symbol: NodeV1;
27
27
  hits: EdgeHit[];
28
28
  }[]): Savings | undefined;
29
- /** Loud, actionable empty-result note — never a bare empty list. */
30
- export declare function looseNoteFor(direction: Direction, name: string): string;
29
+ /** Loud, actionable empty-result note — never a bare empty list. `candidateCount`
30
+ * is how many nodes {@link resolveSymbol} matched for this query (both call
31
+ * sites already hold it as `matches.length`) — when it's >1, the query name is
32
+ * itself ambiguous (several definitions share it), which is exactly the case
33
+ * `resolve.ts` drops a cross-file call/reference for rather than guessing which
34
+ * one it means. Without saying so, a zero-hit result here reads as "nothing
35
+ * calls this" when it may really be "something does, but the edge was dropped". */
36
+ export declare function looseNoteFor(direction: Direction, name: string, candidateCount: number): string;
31
37
  /**
32
38
  * Resolve `query` in the graph at `dir` (respecting `--dir`/`--in`), walk edges
33
39
  * per `--direction`/`--depth`, and print either the human report or `--json`.
@@ -1 +1 @@
1
- {"version":3,"file":"traverse-cli.d.ts","sourceRoot":"","sources":["../../src/graph/traverse-cli.ts"],"names":[],"mappings":"AAeA,OAAO,EAA6B,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhF,OAAO,EAA2B,KAAK,SAAS,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AACtF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,WAAW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