@mrciphersmith/keryx 0.4.50 → 0.4.52
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/dist/cli.js +1024 -969
- package/dist/core.js +279 -230
- package/dist/keryx-general-worker-entry.js +1 -1
- package/package.json +1 -1
- package/src/gdgraph/build.ts +37 -4
- package/src/gdgraph/staleness.ts +24 -3
|
@@ -14824,7 +14824,7 @@ var init_metaproject_projection = __esm(() => {
|
|
|
14824
14824
|
// src/openspec/catalog.ts
|
|
14825
14825
|
var MAX_DISCOVERY_ENTRIES = 1e4, RESERVED_COLLECTION_ENTRIES, MAX_FILE_BYTES, MAX_TOTAL_BYTES;
|
|
14826
14826
|
var init_catalog4 = __esm(() => {
|
|
14827
|
-
|
|
14827
|
+
init_descriptor_read();
|
|
14828
14828
|
RESERVED_COLLECTION_ENTRIES = Math.floor(MAX_DISCOVERY_ENTRIES / 3) - 1;
|
|
14829
14829
|
MAX_FILE_BYTES = 1024 * 1024;
|
|
14830
14830
|
MAX_TOTAL_BYTES = 64 * MAX_FILE_BYTES;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrciphersmith/keryx",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.52",
|
|
4
4
|
"description": "Version-controlled project context for AI coding agents: code graph, architecture wiki, project memory, relevant tests, quality signals, and task flows.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
package/src/gdgraph/build.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mkdir, readdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
2
|
+
import { existsSync, lstatSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { gdgraphArtifactsDir, gdgraphStorageDir } from "./data-dir";
|
|
5
5
|
import type { GraphData, GraphEdge, GraphNode, ImportKind, TranspilerImportKind } from "./types";
|
|
@@ -67,6 +67,7 @@ type BuildResult = {
|
|
|
67
67
|
type SourceCollection = {
|
|
68
68
|
files: string[];
|
|
69
69
|
skippedDirectories: string[];
|
|
70
|
+
checkoutBoundaries: Map<string, boolean>;
|
|
70
71
|
};
|
|
71
72
|
|
|
72
73
|
type PathMapping = {
|
|
@@ -136,7 +137,7 @@ export async function buildGraph(projectRoot: string, options: { dataDir?: strin
|
|
|
136
137
|
|
|
137
138
|
for (const { specifier, kind: importKind } of records) {
|
|
138
139
|
const resolved = resolveImport(projectRoot, file, specifier, fileSet, resolver);
|
|
139
|
-
const asset = resolved ? null : resolveAssetImport(projectRoot, file, specifier, resolver);
|
|
140
|
+
const asset = resolved ? null : resolveAssetImport(projectRoot, file, specifier, resolver, collection.checkoutBoundaries);
|
|
140
141
|
const shouldTrackUnresolved =
|
|
141
142
|
specifier.startsWith(".") || resolver.matchesAlias(specifier) || isLanguageAware;
|
|
142
143
|
if (!resolved && !asset && !shouldTrackUnresolved) {
|
|
@@ -201,10 +202,20 @@ export async function buildGraph(projectRoot: string, options: { dataDir?: strin
|
|
|
201
202
|
async function collectSourceFiles(projectRoot: string): Promise<SourceCollection> {
|
|
202
203
|
const result: string[] = [];
|
|
203
204
|
const skippedDirectories: string[] = [];
|
|
205
|
+
const checkoutBoundaries = new Map<string, boolean>();
|
|
204
206
|
|
|
205
207
|
async function walk(relativeDir: string): Promise<void> {
|
|
206
208
|
const absoluteDir = path.join(projectRoot, relativeDir);
|
|
207
209
|
const entries = await readdir(absoluteDir, { withFileTypes: true });
|
|
210
|
+
// A linked worktree or submodule has a .git file. An independent
|
|
211
|
+
// checkout usually has a .git directory. The selected root owns its marker.
|
|
212
|
+
const nestedCheckout = relativeDir !== "."
|
|
213
|
+
&& entries.some((entry) => entry.name === ".git" && (entry.isFile() || entry.isDirectory()));
|
|
214
|
+
checkoutBoundaries.set(relativeDir, nestedCheckout);
|
|
215
|
+
if (nestedCheckout) {
|
|
216
|
+
skippedDirectories.push(relativeDir);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
208
219
|
|
|
209
220
|
for (const entry of entries) {
|
|
210
221
|
if (entry.isDirectory()) {
|
|
@@ -231,7 +242,7 @@ async function collectSourceFiles(projectRoot: string): Promise<SourceCollection
|
|
|
231
242
|
}
|
|
232
243
|
|
|
233
244
|
await walk(".");
|
|
234
|
-
return { files: result.sort(), skippedDirectories: skippedDirectories.sort() };
|
|
245
|
+
return { files: result.sort(), skippedDirectories: skippedDirectories.sort(), checkoutBoundaries };
|
|
235
246
|
}
|
|
236
247
|
|
|
237
248
|
type ImportRecord = { specifier: string; kind: ImportKind };
|
|
@@ -416,16 +427,38 @@ function resolveAssetImport(
|
|
|
416
427
|
fromFile: string,
|
|
417
428
|
specifier: string,
|
|
418
429
|
resolver: ImportResolver,
|
|
430
|
+
checkoutBoundaries: Map<string, boolean>,
|
|
419
431
|
): string | null {
|
|
420
432
|
for (const candidate of importCandidateBases(projectRoot, fromFile, specifier, resolver)) {
|
|
421
433
|
const extension = path.posix.extname(candidate);
|
|
422
|
-
if (ASSET_EXTENSIONS.includes(extension) && existsSync(path.join(projectRoot, candidate))
|
|
434
|
+
if (ASSET_EXTENSIONS.includes(extension) && existsSync(path.join(projectRoot, candidate))
|
|
435
|
+
&& !inNestedCheckout(projectRoot, candidate, checkoutBoundaries)) {
|
|
423
436
|
return candidate;
|
|
424
437
|
}
|
|
425
438
|
}
|
|
426
439
|
return null;
|
|
427
440
|
}
|
|
428
441
|
|
|
442
|
+
function inNestedCheckout(projectRoot: string, candidate: string, boundaries: Map<string, boolean>): boolean {
|
|
443
|
+
let parent = path.posix.dirname(candidate);
|
|
444
|
+
while (parent !== "." && parent !== ".." && !parent.startsWith("../") && parent !== "/") {
|
|
445
|
+
let isCheckout = boundaries.get(parent);
|
|
446
|
+
if (isCheckout === undefined) {
|
|
447
|
+
// An asset may live in a directory ignored by the source-file walk.
|
|
448
|
+
try {
|
|
449
|
+
const marker = lstatSync(path.join(projectRoot, parent, ".git"), { throwIfNoEntry: false });
|
|
450
|
+
isCheckout = marker?.isFile() === true || marker?.isDirectory() === true;
|
|
451
|
+
boundaries.set(parent, isCheckout);
|
|
452
|
+
} catch {
|
|
453
|
+
return true;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
if (isCheckout) return true;
|
|
457
|
+
parent = path.posix.dirname(parent);
|
|
458
|
+
}
|
|
459
|
+
return false;
|
|
460
|
+
}
|
|
461
|
+
|
|
429
462
|
function importCandidateBases(
|
|
430
463
|
projectRoot: string,
|
|
431
464
|
fromFile: string,
|
package/src/gdgraph/staleness.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
-
import { stat } from "node:fs/promises";
|
|
2
|
+
import { lstat, readFile, stat } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { revisionOperand } from "../lib/git-revision";
|
|
5
5
|
import { gitCmd, readProvenance } from "../sync/provenance";
|
|
@@ -206,6 +206,26 @@ function categorizeStatusEntries(
|
|
|
206
206
|
return { added, deleted, renamed, modified };
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
+
/** Keep a contaminated legacy snapshot stale until it has been rebuilt. */
|
|
210
|
+
async function graphAdditions(cwd: string, rootPrefix: string, added: string[]): Promise<string[]> {
|
|
211
|
+
let nodes: string | undefined;
|
|
212
|
+
const relevant: string[] = [];
|
|
213
|
+
for (const candidate of added) {
|
|
214
|
+
if (candidate.endsWith("/") && candidate.startsWith(rootPrefix)) {
|
|
215
|
+
const relative = candidate.slice(rootPrefix.length);
|
|
216
|
+
const marker = await lstat(path.join(cwd, relative, ".git")).catch(() => undefined);
|
|
217
|
+
if (marker?.isFile() || marker?.isDirectory()) {
|
|
218
|
+
nodes ??= await readFile(nodesJsonlPath(cwd), "utf8").catch(() => undefined);
|
|
219
|
+
// JSON-escape the prefix the same way as the graph emitter.
|
|
220
|
+
const prefix = `"path":${JSON.stringify(relative).slice(0, -1)}`;
|
|
221
|
+
if (nodes !== undefined && !nodes.includes(prefix)) continue;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
relevant.push(candidate);
|
|
225
|
+
}
|
|
226
|
+
return relevant;
|
|
227
|
+
}
|
|
228
|
+
|
|
209
229
|
const REASON_FILE_DISPLAY_LIMIT = 5;
|
|
210
230
|
|
|
211
231
|
function nameFiles(message: string, files: string[]): string {
|
|
@@ -369,8 +389,9 @@ export async function checkGraphStaleness(
|
|
|
369
389
|
// can itself contain "\n"), so entries are split on "\0", not "\n".
|
|
370
390
|
const entries = porcelain.split("\0").filter((entry) => entry.length > 0);
|
|
371
391
|
const { added, deleted, renamed, modified } = categorizeStatusEntries(entries, rootPrefix);
|
|
372
|
-
|
|
373
|
-
|
|
392
|
+
const relevantAdditions = await graphAdditions(cwd, rootPrefix, added);
|
|
393
|
+
if (relevantAdditions.length > 0) {
|
|
394
|
+
reasons.push(nameFiles("an untracked or newly added file exists in the working tree", relevantAdditions));
|
|
374
395
|
}
|
|
375
396
|
if (deleted.length > 0) {
|
|
376
397
|
reasons.push(nameFiles("a tracked file was deleted in the working tree", deleted));
|