mirror of
https://github.com/hansjone/netxops.git
synced 2026-10-09 02:40:45 +08:00
Fix knowledge-base browse feedback and accept MANIFEST.json paths.
Browse no longer fails silently, falls back to Host directoryPicker RPC, and resolve treats a MANIFEST.json file path as its parent package root. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
de7c6a0c4b
commit
f64f1279e7
9 changed files with 246 additions and 49 deletions
21
lib/index.js
21
lib/index.js
|
|
@ -844,7 +844,7 @@ function registerKbContextSkill(ctx, snapshot) {
|
|||
|
||||
// src/netx/kb-manifest.ts
|
||||
import { existsSync as existsSync2, readdirSync, readFileSync, statSync } from "node:fs";
|
||||
import { dirname as dirname2, join as join3, resolve } from "node:path";
|
||||
import { basename, dirname as dirname2, join as join3, resolve } from "node:path";
|
||||
var EMPTY_CONTENT = {
|
||||
regions: false,
|
||||
theory: false,
|
||||
|
|
@ -1000,11 +1000,26 @@ function resolveKbRoot(kbRoot, maxDepth = 3) {
|
|||
const trimmed = kbRoot.trim();
|
||||
if (!trimmed)
|
||||
return unconfiguredKbSnapshot();
|
||||
const located = findManifest(trimmed, maxDepth);
|
||||
let root = resolve(trimmed);
|
||||
try {
|
||||
const st = statSync(root);
|
||||
if (st.isFile()) {
|
||||
if (basename(root).toLowerCase() === "manifest.json") {
|
||||
root = dirname2(root);
|
||||
} else {
|
||||
return errorSnapshot(`kbRoot is not a directory: ${root}`);
|
||||
}
|
||||
} else if (!st.isDirectory()) {
|
||||
return errorSnapshot(`kbRoot is not a directory: ${root}`);
|
||||
}
|
||||
} catch {
|
||||
return errorSnapshot(`kbRoot not found: ${root}`);
|
||||
}
|
||||
const located = findManifest(root, maxDepth);
|
||||
if (located.error)
|
||||
return errorSnapshot(located.error);
|
||||
if (located.paths.length === 0) {
|
||||
return errorSnapshot(`no MANIFEST.json under ${resolve(trimmed)} (maxDepth=${maxDepth})`);
|
||||
return errorSnapshot(`no MANIFEST.json under ${root} (maxDepth=${maxDepth})`);
|
||||
}
|
||||
if (located.paths.length > 1) {
|
||||
return errorSnapshot(`ambiguous MANIFEST.json (${located.paths.length} hits); pick a unique package root`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue