wiki-graph 0.7.1 → 0.8.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.
- package/dist/cli.js +668 -633
- package/dist/cli.js.map +1 -1
- package/dist/data/help/commands/library-predicate.jinja +13 -0
- package/dist/data/help/commands/library.jinja +9 -2
- package/dist/data/help/commands/predicate.jinja +11 -9
- package/dist/data/help/commands/uri.jinja +13 -0
- package/dist/data/help/topics/library.jinja +3 -1
- package/dist/data/help/topics/readiness.jinja +3 -3
- package/dist/data/help/topics/recipe.jinja +1 -1
- package/dist/data/help/topics/uri.jinja +6 -1
- package/dist/gc-worker.js +102 -85
- package/dist/gc-worker.js.map +1 -1
- package/dist/index.cjs +685 -186
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +602 -99
- package/dist/index.js.map +1 -1
- package/dist/queue-worker.js +657 -622
- package/dist/queue-worker.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -45,6 +45,7 @@ async function withWikiGraphCLIRuntimeContext(context, operation) {
|
|
|
45
45
|
cwd: context.cwd,
|
|
46
46
|
env: context.env,
|
|
47
47
|
envPolicy: context.envPolicy,
|
|
48
|
+
providers: {},
|
|
48
49
|
...context.stateDir === void 0 ? {} : { stateDir: context.stateDir }
|
|
49
50
|
},
|
|
50
51
|
operation
|
|
@@ -559,6 +560,29 @@ var init_version = __esm({
|
|
|
559
560
|
}
|
|
560
561
|
});
|
|
561
562
|
|
|
563
|
+
// src/support/archive-target.ts
|
|
564
|
+
function parseCLIArchiveTarget(locator) {
|
|
565
|
+
if (locator.startsWith("wikg://lib/")) {
|
|
566
|
+
return { kind: "library", uri: locator };
|
|
567
|
+
}
|
|
568
|
+
if (!locator.includes("://")) {
|
|
569
|
+
return { kind: "standalone", path: locator };
|
|
570
|
+
}
|
|
571
|
+
const parsed = (0, import_wiki_graph_sdk4.parseLocatedWikiGraphUri)(locator);
|
|
572
|
+
return {
|
|
573
|
+
kind: "standalone",
|
|
574
|
+
path: parsed.archivePath ?? locator,
|
|
575
|
+
...parsed.objectUri === void 0 ? {} : { objectUri: parsed.objectUri }
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
var import_wiki_graph_sdk4;
|
|
579
|
+
var init_archive_target = __esm({
|
|
580
|
+
"src/support/archive-target.ts"() {
|
|
581
|
+
"use strict";
|
|
582
|
+
import_wiki_graph_sdk4 = require("wiki-graph-sdk");
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
|
|
562
586
|
// src/support/index.ts
|
|
563
587
|
var init_support = __esm({
|
|
564
588
|
"src/support/index.ts"() {
|
|
@@ -572,6 +596,7 @@ var init_support = __esm({
|
|
|
572
596
|
init_uri();
|
|
573
597
|
init_version();
|
|
574
598
|
init_command();
|
|
599
|
+
init_archive_target();
|
|
575
600
|
}
|
|
576
601
|
});
|
|
577
602
|
|
|
@@ -587,20 +612,20 @@ var init_local_config = __esm({
|
|
|
587
612
|
// src/runtime/config.ts
|
|
588
613
|
async function loadCLIConfig(options) {
|
|
589
614
|
try {
|
|
590
|
-
return await (0,
|
|
615
|
+
return await (0, import_wiki_graph_sdk15.loadWikiGraphRuntimeConfig)(options);
|
|
591
616
|
} catch (error) {
|
|
592
617
|
throw withConfigHelp(error);
|
|
593
618
|
}
|
|
594
619
|
}
|
|
595
620
|
function resolveWikispineConfig(value, envPolicy = getCLIEnvPolicy()) {
|
|
596
621
|
try {
|
|
597
|
-
return (0,
|
|
622
|
+
return (0, import_wiki_graph_sdk15.resolveWikispineConfig)(value, envPolicy);
|
|
598
623
|
} catch (error) {
|
|
599
624
|
throw withConfigHelp(error);
|
|
600
625
|
}
|
|
601
626
|
}
|
|
602
627
|
function resolveHostedProviderEndpoint(scope, envPolicy = getCLIEnvPolicy()) {
|
|
603
|
-
return (0,
|
|
628
|
+
return (0, import_wiki_graph_sdk15.resolveHostedProviderEndpoint)(scope, envPolicy);
|
|
604
629
|
}
|
|
605
630
|
function withConfigHelp(error) {
|
|
606
631
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -608,11 +633,11 @@ function withConfigHelp(error) {
|
|
|
608
633
|
cause: error
|
|
609
634
|
});
|
|
610
635
|
}
|
|
611
|
-
var
|
|
636
|
+
var import_wiki_graph_sdk15;
|
|
612
637
|
var init_config = __esm({
|
|
613
638
|
"src/runtime/config.ts"() {
|
|
614
639
|
"use strict";
|
|
615
|
-
|
|
640
|
+
import_wiki_graph_sdk15 = require("wiki-graph-sdk");
|
|
616
641
|
init_support();
|
|
617
642
|
init_context();
|
|
618
643
|
}
|
|
@@ -621,7 +646,7 @@ var init_config = __esm({
|
|
|
621
646
|
// src/runtime/llm.ts
|
|
622
647
|
function buildLLMOptions(config) {
|
|
623
648
|
try {
|
|
624
|
-
return (0,
|
|
649
|
+
return (0, import_wiki_graph_sdk16.buildWikiGraphLLMOptions)(config);
|
|
625
650
|
} catch (error) {
|
|
626
651
|
const message = error instanceof Error ? error.message : String(error);
|
|
627
652
|
throw new Error(withHelpRoute(message, CLI_HELP_ROUTES.config), {
|
|
@@ -629,11 +654,11 @@ function buildLLMOptions(config) {
|
|
|
629
654
|
});
|
|
630
655
|
}
|
|
631
656
|
}
|
|
632
|
-
var
|
|
657
|
+
var import_wiki_graph_sdk16;
|
|
633
658
|
var init_llm = __esm({
|
|
634
659
|
"src/runtime/llm.ts"() {
|
|
635
660
|
"use strict";
|
|
636
|
-
|
|
661
|
+
import_wiki_graph_sdk16 = require("wiki-graph-sdk");
|
|
637
662
|
init_support();
|
|
638
663
|
}
|
|
639
664
|
});
|
|
@@ -1024,7 +1049,7 @@ var init_progress_output = __esm({
|
|
|
1024
1049
|
// src/runtime/stage.ts
|
|
1025
1050
|
async function loadRequiredStageConfig(options) {
|
|
1026
1051
|
try {
|
|
1027
|
-
return await (0,
|
|
1052
|
+
return await (0, import_wiki_graph_sdk18.loadRequiredStageConfig)(options);
|
|
1028
1053
|
} catch (error) {
|
|
1029
1054
|
const message = error instanceof Error ? error.message : String(error);
|
|
1030
1055
|
throw new Error(withHelpRoute(message, CLI_HELP_ROUTES.config), {
|
|
@@ -1032,12 +1057,12 @@ async function loadRequiredStageConfig(options) {
|
|
|
1032
1057
|
});
|
|
1033
1058
|
}
|
|
1034
1059
|
}
|
|
1035
|
-
var
|
|
1060
|
+
var import_wiki_graph_sdk17, import_wiki_graph_sdk18;
|
|
1036
1061
|
var init_stage = __esm({
|
|
1037
1062
|
"src/runtime/stage.ts"() {
|
|
1038
1063
|
"use strict";
|
|
1039
|
-
import_wiki_graph_sdk16 = require("wiki-graph-sdk");
|
|
1040
1064
|
import_wiki_graph_sdk17 = require("wiki-graph-sdk");
|
|
1065
|
+
import_wiki_graph_sdk18 = require("wiki-graph-sdk");
|
|
1041
1066
|
init_support();
|
|
1042
1067
|
}
|
|
1043
1068
|
});
|
|
@@ -1054,18 +1079,18 @@ var init_wikispine = __esm({
|
|
|
1054
1079
|
// src/runtime/index.ts
|
|
1055
1080
|
var runtime_exports = {};
|
|
1056
1081
|
__export(runtime_exports, {
|
|
1057
|
-
DEFAULT_EXTRACTION_PROMPT: () =>
|
|
1058
|
-
DEFAULT_KNOWLEDGE_GRAPH_RECALL_PROMPT: () =>
|
|
1082
|
+
DEFAULT_EXTRACTION_PROMPT: () => import_wiki_graph_sdk17.DEFAULT_EXTRACTION_PROMPT,
|
|
1083
|
+
DEFAULT_KNOWLEDGE_GRAPH_RECALL_PROMPT: () => import_wiki_graph_sdk17.DEFAULT_KNOWLEDGE_GRAPH_RECALL_PROMPT,
|
|
1059
1084
|
ProgressOutputWriter: () => ProgressOutputWriter,
|
|
1060
1085
|
buildLLMOptions: () => buildLLMOptions,
|
|
1061
1086
|
createCLIProgressRenderer: () => createCLIProgressRenderer,
|
|
1062
|
-
createStageLLM: () =>
|
|
1087
|
+
createStageLLM: () => import_wiki_graph_sdk17.createStageLLM,
|
|
1063
1088
|
formatStatusText: () => formatStatusText,
|
|
1064
1089
|
loadCLIConfig: () => loadCLIConfig,
|
|
1065
1090
|
loadRequiredStageConfig: () => loadRequiredStageConfig,
|
|
1066
|
-
resolveExtractionPrompt: () =>
|
|
1091
|
+
resolveExtractionPrompt: () => import_wiki_graph_sdk17.resolveExtractionPrompt,
|
|
1067
1092
|
resolveHostedProviderEndpoint: () => resolveHostedProviderEndpoint,
|
|
1068
|
-
resolveKnowledgeGraphRecallPrompt: () =>
|
|
1093
|
+
resolveKnowledgeGraphRecallPrompt: () => import_wiki_graph_sdk17.resolveKnowledgeGraphRecallPrompt,
|
|
1069
1094
|
resolveWikispineConfig: () => resolveWikispineConfig,
|
|
1070
1095
|
toCLIGenerationPerformanceHints: () => toCLIGenerationPerformanceHints
|
|
1071
1096
|
});
|
|
@@ -1284,7 +1309,7 @@ async function createArchive(args) {
|
|
|
1284
1309
|
args.json === true ? formatCLIJSON({ uri: result.locatedUri }) : "<archive>\n"
|
|
1285
1310
|
);
|
|
1286
1311
|
} catch (error) {
|
|
1287
|
-
if (!(error instanceof
|
|
1312
|
+
if (!(error instanceof import_wiki_graph_sdk19.WikiGraphArchiveExistsError)) throw error;
|
|
1288
1313
|
throw new Error(formatArchiveAlreadyExistsMessage(error.path), {
|
|
1289
1314
|
cause: error
|
|
1290
1315
|
});
|
|
@@ -1299,11 +1324,11 @@ function formatArchiveAlreadyExistsMessage(archivePath) {
|
|
|
1299
1324
|
`Use \`${formatCliCommand([uri, "inspect"])}\` to view it, or rerun with \`--replace\` to overwrite it.`
|
|
1300
1325
|
].join("\n");
|
|
1301
1326
|
}
|
|
1302
|
-
var
|
|
1327
|
+
var import_wiki_graph_sdk19;
|
|
1303
1328
|
var init_create = __esm({
|
|
1304
1329
|
"src/commands/archive-command/create.ts"() {
|
|
1305
1330
|
"use strict";
|
|
1306
|
-
|
|
1331
|
+
import_wiki_graph_sdk19 = require("wiki-graph-sdk");
|
|
1307
1332
|
init_context();
|
|
1308
1333
|
init_runtime();
|
|
1309
1334
|
init_support();
|
|
@@ -1312,16 +1337,306 @@ var init_create = __esm({
|
|
|
1312
1337
|
|
|
1313
1338
|
// src/commands/archive-command/inspect.ts
|
|
1314
1339
|
async function writeArchiveInspectReport(args) {
|
|
1315
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
1340
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
1341
|
+
parseCLIArchiveTarget(args.archivePath)
|
|
1342
|
+
);
|
|
1316
1343
|
const report = toCLIInspectReport(
|
|
1317
|
-
await
|
|
1318
|
-
|
|
1319
|
-
|
|
1344
|
+
await createInspectReport(
|
|
1345
|
+
await archive.inspect({
|
|
1346
|
+
...args.chapterId === void 0 ? {} : { chapterId: args.chapterId }
|
|
1347
|
+
})
|
|
1348
|
+
)
|
|
1320
1349
|
);
|
|
1321
1350
|
await writeTextToStdout(
|
|
1322
1351
|
args.json === true ? formatCLIJSON(report) : formatArchiveInspectText(report)
|
|
1323
1352
|
);
|
|
1324
1353
|
}
|
|
1354
|
+
async function createInspectReport(inspection) {
|
|
1355
|
+
const config = await (0, import_wiki_graph_sdk20.loadWikiGraphRuntimeConfig)();
|
|
1356
|
+
const chapters = inspection.chapters;
|
|
1357
|
+
const contentChapters = chapters.filter(
|
|
1358
|
+
({ chapter }) => chapter.stage !== "planned"
|
|
1359
|
+
);
|
|
1360
|
+
const readingGraphCovered = contentChapters.filter(
|
|
1361
|
+
({ capabilities }) => capabilities.readingGraph.completed
|
|
1362
|
+
);
|
|
1363
|
+
const knowledgeGraphCovered = contentChapters.filter(
|
|
1364
|
+
({ capabilities }) => capabilities.knowledgeGraph.completed
|
|
1365
|
+
);
|
|
1366
|
+
const summaryCovered = contentChapters.filter(
|
|
1367
|
+
({ capabilities }) => capabilities.readingSummary.completed
|
|
1368
|
+
);
|
|
1369
|
+
const ftsArtifactCovered = contentChapters.filter(
|
|
1370
|
+
({ indexes }) => indexes.fts.current
|
|
1371
|
+
);
|
|
1372
|
+
const sourceEmbeddingArtifactCovered = contentChapters.filter(
|
|
1373
|
+
({ indexes }) => indexes.sourceEmbedding.current
|
|
1374
|
+
);
|
|
1375
|
+
const summaryEmbeddingArtifactCovered = contentChapters.filter(
|
|
1376
|
+
({ indexes }) => indexes.summaryEmbedding.current
|
|
1377
|
+
);
|
|
1378
|
+
const queryBlockedChapters = contentChapters.filter(
|
|
1379
|
+
(chapter) => !ftsArtifactCovered.includes(chapter) && !sourceEmbeddingArtifactCovered.includes(chapter)
|
|
1380
|
+
);
|
|
1381
|
+
const queryReady = queryBlockedChapters.length === 0;
|
|
1382
|
+
const concurrent = {
|
|
1383
|
+
job: config.concurrent?.job ?? import_wiki_graph_sdk20.DEFAULT_GENERATION_JOB_CONCURRENCY,
|
|
1384
|
+
request: config.concurrent?.request ?? import_wiki_graph_sdk20.DEFAULT_GENERATION_REQUEST_CONCURRENCY
|
|
1385
|
+
};
|
|
1386
|
+
const improvements = createInspectImprovements({
|
|
1387
|
+
concurrent,
|
|
1388
|
+
contentChapters,
|
|
1389
|
+
indexCacheCurrent: inspection.localIndexCache.current,
|
|
1390
|
+
knowledgeGraphCovered,
|
|
1391
|
+
planningModel: (0, import_wiki_graph_sdk20.formatGenerationPlanningModel)(config.llm),
|
|
1392
|
+
queryBlockedChapters,
|
|
1393
|
+
readingGraphCovered,
|
|
1394
|
+
summaryCovered
|
|
1395
|
+
});
|
|
1396
|
+
const performanceHints = (0, import_wiki_graph_sdk20.createGenerationPerformanceHints)({
|
|
1397
|
+
chapters: Math.max(
|
|
1398
|
+
0,
|
|
1399
|
+
...improvements.map((improvement) => improvement.missingChapters ?? 0)
|
|
1400
|
+
),
|
|
1401
|
+
concurrent,
|
|
1402
|
+
hasJobWork: improvements.some(
|
|
1403
|
+
(improvement) => improvement.planning !== void 0
|
|
1404
|
+
),
|
|
1405
|
+
hasRequestWork: improvements.some(
|
|
1406
|
+
(improvement) => improvement.planning !== void 0
|
|
1407
|
+
)
|
|
1408
|
+
});
|
|
1409
|
+
const sourceWords = sumWords(contentChapters);
|
|
1410
|
+
const indexCacheCurrent = inspection.localIndexCache.current;
|
|
1411
|
+
return {
|
|
1412
|
+
archiveUri: inspection.archiveUri,
|
|
1413
|
+
content: {
|
|
1414
|
+
chapters: {
|
|
1415
|
+
content: contentChapters.length,
|
|
1416
|
+
planned: chapters.length - contentChapters.length,
|
|
1417
|
+
total: chapters.length
|
|
1418
|
+
},
|
|
1419
|
+
sourceWords,
|
|
1420
|
+
summaryWords: chapters.reduce(
|
|
1421
|
+
(total, chapter) => total + chapter.summaryWords,
|
|
1422
|
+
0
|
|
1423
|
+
)
|
|
1424
|
+
},
|
|
1425
|
+
coverage: {
|
|
1426
|
+
ftsIndexArtifact: createInspectCoverage(
|
|
1427
|
+
ftsArtifactCovered,
|
|
1428
|
+
contentChapters
|
|
1429
|
+
),
|
|
1430
|
+
knowledgeGraph: createInspectCoverage(
|
|
1431
|
+
knowledgeGraphCovered,
|
|
1432
|
+
contentChapters
|
|
1433
|
+
),
|
|
1434
|
+
readingGraph: createInspectCoverage(readingGraphCovered, contentChapters),
|
|
1435
|
+
sourceEmbeddingIndexArtifact: createInspectCoverage(
|
|
1436
|
+
sourceEmbeddingArtifactCovered,
|
|
1437
|
+
contentChapters
|
|
1438
|
+
),
|
|
1439
|
+
summary: createInspectCoverage(summaryCovered, contentChapters),
|
|
1440
|
+
summaryEmbeddingIndexArtifact: createInspectCoverage(
|
|
1441
|
+
summaryEmbeddingArtifactCovered,
|
|
1442
|
+
contentChapters
|
|
1443
|
+
)
|
|
1444
|
+
},
|
|
1445
|
+
improvements,
|
|
1446
|
+
localIndexCache: {
|
|
1447
|
+
current: indexCacheCurrent,
|
|
1448
|
+
...!queryReady ? {
|
|
1449
|
+
blockedBy: "missing-search-artifacts",
|
|
1450
|
+
impact: "The cache cannot be built until every content chapter has a current FTS or source embedding artifact."
|
|
1451
|
+
} : indexCacheCurrent ? {} : {
|
|
1452
|
+
impact: "The next archive query may need to sync index cache first.",
|
|
1453
|
+
resource: "local CPU/disk time only; no provider calls."
|
|
1454
|
+
},
|
|
1455
|
+
status: !queryReady ? "blocked" : indexCacheCurrent ? "current" : "missing-or-outdated",
|
|
1456
|
+
syncAvailable: queryReady && !indexCacheCurrent
|
|
1457
|
+
},
|
|
1458
|
+
performanceHints,
|
|
1459
|
+
query: { ready: queryReady },
|
|
1460
|
+
retrievalGuidance: formatRetrievalGuidance({
|
|
1461
|
+
contentChapters,
|
|
1462
|
+
indexCacheCurrent,
|
|
1463
|
+
knowledgeGraphCovered,
|
|
1464
|
+
queryReady,
|
|
1465
|
+
readingGraphCovered,
|
|
1466
|
+
sourceWords
|
|
1467
|
+
}),
|
|
1468
|
+
scope: inspection.scope,
|
|
1469
|
+
searchArtifacts: {
|
|
1470
|
+
blockedChapters: queryBlockedChapters.map(
|
|
1471
|
+
(item) => createInspectChapterReference(inspection.archiveUri, item)
|
|
1472
|
+
),
|
|
1473
|
+
...!queryReady ? { resource: "local CPU/disk time only; no provider calls." } : {},
|
|
1474
|
+
ready: queryReady,
|
|
1475
|
+
status: queryReady ? "ready" : "incomplete"
|
|
1476
|
+
},
|
|
1477
|
+
summaryCoverageNote: "Summary coverage means a current summary artifact exists for the chapter; it does not guarantee that every source topic is represented in the summary text.",
|
|
1478
|
+
uri: inspection.uri
|
|
1479
|
+
};
|
|
1480
|
+
}
|
|
1481
|
+
function createInspectChapterReference(archiveUri, inspection) {
|
|
1482
|
+
return {
|
|
1483
|
+
chapterId: inspection.chapter.chapterId,
|
|
1484
|
+
locatedUri: `${archiveUri.replace(/\/+$/u, "")}/${inspection.chapter.uri.replace(/^wikg:\/\//u, "")}`,
|
|
1485
|
+
title: inspection.chapter.title,
|
|
1486
|
+
uri: inspection.chapter.uri
|
|
1487
|
+
};
|
|
1488
|
+
}
|
|
1489
|
+
function createInspectCoverage(covered, total) {
|
|
1490
|
+
const coveredWords = sumWords(covered);
|
|
1491
|
+
const totalWords = sumWords(total);
|
|
1492
|
+
return {
|
|
1493
|
+
coveredChapters: covered.length,
|
|
1494
|
+
coveredWords,
|
|
1495
|
+
percent: formatPercent(coveredWords, totalWords),
|
|
1496
|
+
totalChapters: total.length,
|
|
1497
|
+
totalWords
|
|
1498
|
+
};
|
|
1499
|
+
}
|
|
1500
|
+
function createInspectImprovements(input) {
|
|
1501
|
+
if (input.contentChapters.length === 0) {
|
|
1502
|
+
return [
|
|
1503
|
+
{
|
|
1504
|
+
kind: "add-source",
|
|
1505
|
+
recommendation: "No source content is available yet; add or import source text before graph or summary generation.",
|
|
1506
|
+
title: "Add source content"
|
|
1507
|
+
}
|
|
1508
|
+
];
|
|
1509
|
+
}
|
|
1510
|
+
const improvements = [];
|
|
1511
|
+
if (input.queryBlockedChapters.length > 0) {
|
|
1512
|
+
improvements.push({
|
|
1513
|
+
kind: "build",
|
|
1514
|
+
missingChapters: input.queryBlockedChapters.length,
|
|
1515
|
+
missingWords: sumWords(input.queryBlockedChapters),
|
|
1516
|
+
recommendation: "Build local FTS artifacts to make this scope queryable. This does not call a provider.",
|
|
1517
|
+
task: "index-fts",
|
|
1518
|
+
title: "Enable query with local FTS"
|
|
1519
|
+
});
|
|
1520
|
+
} else if (!input.indexCacheCurrent) {
|
|
1521
|
+
improvements.push({
|
|
1522
|
+
kind: "sync-index",
|
|
1523
|
+
recommendation: "Sync the index cache from chapter index artifacts so query starts without a lazy cache rebuild.",
|
|
1524
|
+
title: "Sync index cache"
|
|
1525
|
+
});
|
|
1526
|
+
}
|
|
1527
|
+
improvements.push(
|
|
1528
|
+
...createGraphImprovement({
|
|
1529
|
+
concurrent: input.concurrent,
|
|
1530
|
+
covered: input.readingGraphCovered,
|
|
1531
|
+
planningModel: input.planningModel,
|
|
1532
|
+
task: "reading-graph",
|
|
1533
|
+
title: "Complete Reading Graph coverage",
|
|
1534
|
+
total: input.contentChapters
|
|
1535
|
+
}),
|
|
1536
|
+
...createGraphImprovement({
|
|
1537
|
+
concurrent: input.concurrent,
|
|
1538
|
+
covered: input.knowledgeGraphCovered,
|
|
1539
|
+
planningModel: input.planningModel,
|
|
1540
|
+
task: "knowledge-graph",
|
|
1541
|
+
title: "Complete Knowledge Graph coverage",
|
|
1542
|
+
total: input.contentChapters
|
|
1543
|
+
}),
|
|
1544
|
+
...createGraphImprovement({
|
|
1545
|
+
concurrent: input.concurrent,
|
|
1546
|
+
covered: input.summaryCovered,
|
|
1547
|
+
planningModel: input.planningModel,
|
|
1548
|
+
task: "reading-summary",
|
|
1549
|
+
title: "Complete Summary coverage",
|
|
1550
|
+
total: input.contentChapters
|
|
1551
|
+
})
|
|
1552
|
+
);
|
|
1553
|
+
return improvements;
|
|
1554
|
+
}
|
|
1555
|
+
function createGraphImprovement(input) {
|
|
1556
|
+
const coveredIds = new Set(
|
|
1557
|
+
input.covered.map(({ chapter }) => chapter.chapterId)
|
|
1558
|
+
);
|
|
1559
|
+
const missing = input.total.filter(
|
|
1560
|
+
({ chapter }) => !coveredIds.has(chapter.chapterId)
|
|
1561
|
+
);
|
|
1562
|
+
if (missing.length === 0) return [];
|
|
1563
|
+
const missingWords = sumWords(missing);
|
|
1564
|
+
return [
|
|
1565
|
+
{
|
|
1566
|
+
kind: "build",
|
|
1567
|
+
missingChapters: missing.length,
|
|
1568
|
+
missingWords,
|
|
1569
|
+
planning: (0, import_wiki_graph_sdk20.planGenerationTask)(
|
|
1570
|
+
input.task,
|
|
1571
|
+
missingWords,
|
|
1572
|
+
missing.length,
|
|
1573
|
+
input.concurrent,
|
|
1574
|
+
input.planningModel
|
|
1575
|
+
),
|
|
1576
|
+
recommendation: formatImprovementRecommendation(
|
|
1577
|
+
input.covered,
|
|
1578
|
+
input.total,
|
|
1579
|
+
missingWords
|
|
1580
|
+
),
|
|
1581
|
+
task: input.task,
|
|
1582
|
+
title: input.title
|
|
1583
|
+
}
|
|
1584
|
+
];
|
|
1585
|
+
}
|
|
1586
|
+
function formatImprovementRecommendation(covered, total, missingWords) {
|
|
1587
|
+
const totalWords = sumWords(total);
|
|
1588
|
+
const coveredWords = sumWords(covered);
|
|
1589
|
+
if (totalWords === 0) return "No source content is available.";
|
|
1590
|
+
if (total.length === 1 || coveredWords / totalWords >= 0.9 || missingWords <= 1e3) {
|
|
1591
|
+
return "Queue the full scope to finish the remaining gap.";
|
|
1592
|
+
}
|
|
1593
|
+
return "Queue selected chapters first if only part of the scope matters.";
|
|
1594
|
+
}
|
|
1595
|
+
function formatRetrievalGuidance(input) {
|
|
1596
|
+
if (input.sourceWords === 0 || input.contentChapters.length === 0) {
|
|
1597
|
+
return [
|
|
1598
|
+
"Source content: empty.",
|
|
1599
|
+
"Add source text before using query coverage or graph-based retrieval."
|
|
1600
|
+
];
|
|
1601
|
+
}
|
|
1602
|
+
return [
|
|
1603
|
+
input.queryReady ? `Query: available; local index cache is ${input.indexCacheCurrent ? "current" : "missing or outdated and can be synced from artifacts"}.` : "Query: unavailable until every content chapter has a current FTS or source embedding artifact.",
|
|
1604
|
+
formatObjectSearchGuidance(
|
|
1605
|
+
"Reading Graph object retrieval",
|
|
1606
|
+
input.readingGraphCovered,
|
|
1607
|
+
input.contentChapters
|
|
1608
|
+
),
|
|
1609
|
+
formatObjectSearchGuidance(
|
|
1610
|
+
"Entity/triple retrieval",
|
|
1611
|
+
input.knowledgeGraphCovered,
|
|
1612
|
+
input.contentChapters
|
|
1613
|
+
)
|
|
1614
|
+
];
|
|
1615
|
+
}
|
|
1616
|
+
function formatObjectSearchGuidance(label, covered, total) {
|
|
1617
|
+
const coveredWords = sumWords(covered);
|
|
1618
|
+
const totalWords = sumWords(total);
|
|
1619
|
+
const ratio = totalWords === 0 ? 0 : coveredWords / totalWords;
|
|
1620
|
+
const coverage = formatPercent(coveredWords, totalWords);
|
|
1621
|
+
if (ratio >= 1) {
|
|
1622
|
+
return `${label}: covers all source content; it can represent the full scope for object retrieval.`;
|
|
1623
|
+
}
|
|
1624
|
+
if (ratio >= 0.9) {
|
|
1625
|
+
return `${label}: covers ${coverage}; use it as the main path, but source --query is needed for uncovered content.`;
|
|
1626
|
+
}
|
|
1627
|
+
if (ratio >= 0.5) {
|
|
1628
|
+
return `${label}: covers ${coverage}; use it as leads, not as a full-scope substitute for source --query.`;
|
|
1629
|
+
}
|
|
1630
|
+
return `${label}: covers ${coverage}; build missing graph coverage before relying on object retrieval.`;
|
|
1631
|
+
}
|
|
1632
|
+
function sumWords(chapters) {
|
|
1633
|
+
return chapters.reduce((total, { chapter }) => total + chapter.words, 0);
|
|
1634
|
+
}
|
|
1635
|
+
function formatPercent(numerator, denominator) {
|
|
1636
|
+
if (denominator === 0) return "n/a";
|
|
1637
|
+
const percent = numerator / denominator * 100;
|
|
1638
|
+
return `${Number.isInteger(percent) ? percent.toFixed(0) : percent.toFixed(1)}%`;
|
|
1639
|
+
}
|
|
1325
1640
|
function toCLIInspectReport(report) {
|
|
1326
1641
|
const { archiveUri, summaryCoverageNote, ...base } = report;
|
|
1327
1642
|
return {
|
|
@@ -1477,12 +1792,15 @@ function formatInspectPerformanceHints(hints) {
|
|
|
1477
1792
|
])
|
|
1478
1793
|
];
|
|
1479
1794
|
}
|
|
1795
|
+
var import_wiki_graph_sdk20;
|
|
1480
1796
|
var init_inspect = __esm({
|
|
1481
1797
|
"src/commands/archive-command/inspect.ts"() {
|
|
1482
1798
|
"use strict";
|
|
1799
|
+
import_wiki_graph_sdk20 = require("wiki-graph-sdk");
|
|
1483
1800
|
init_runtime();
|
|
1484
1801
|
init_context();
|
|
1485
1802
|
init_support();
|
|
1803
|
+
init_archive_target();
|
|
1486
1804
|
}
|
|
1487
1805
|
});
|
|
1488
1806
|
|
|
@@ -1568,11 +1886,11 @@ function formatEvidencePreviewContinuation(evidence, hiddenEvidenceCount) {
|
|
|
1568
1886
|
}
|
|
1569
1887
|
return hiddenEvidenceCount > 0 ? ["", `${hiddenEvidenceCount} evidence more...`] : [];
|
|
1570
1888
|
}
|
|
1571
|
-
var
|
|
1889
|
+
var import_wiki_graph_sdk21;
|
|
1572
1890
|
var init_evidence = __esm({
|
|
1573
1891
|
"src/commands/archive-output/text/evidence.ts"() {
|
|
1574
1892
|
"use strict";
|
|
1575
|
-
|
|
1893
|
+
import_wiki_graph_sdk21 = require("wiki-graph-sdk");
|
|
1576
1894
|
init_command();
|
|
1577
1895
|
init_lines();
|
|
1578
1896
|
init_source();
|
|
@@ -1636,7 +1954,7 @@ function toWikiGraphUri(id) {
|
|
|
1636
1954
|
case "fragment":
|
|
1637
1955
|
return `wikg://chapter/${first ?? ""}/source/${second ?? "0"}`;
|
|
1638
1956
|
case "meta":
|
|
1639
|
-
return "wikg://";
|
|
1957
|
+
return "wikg://meta";
|
|
1640
1958
|
case "node":
|
|
1641
1959
|
return `wikg://chunk/${first ?? ""}`;
|
|
1642
1960
|
case "summary":
|
|
@@ -1930,6 +2248,14 @@ function createObjectResultPage(objects, nextCursor, limit, warnings = []) {
|
|
|
1930
2248
|
async function createFindObject(hit, context) {
|
|
1931
2249
|
const uri = toWikiGraphUri(hit.id);
|
|
1932
2250
|
const librarySource = createLibrarySourceObject(hit);
|
|
2251
|
+
if (hit.type === "archive-title") {
|
|
2252
|
+
return {
|
|
2253
|
+
...librarySource,
|
|
2254
|
+
title: hit.title,
|
|
2255
|
+
type: "archive-title",
|
|
2256
|
+
uri
|
|
2257
|
+
};
|
|
2258
|
+
}
|
|
1933
2259
|
if (hit.type === "chapter") {
|
|
1934
2260
|
return {
|
|
1935
2261
|
...librarySource,
|
|
@@ -2077,6 +2403,13 @@ async function createPageObject(page, context) {
|
|
|
2077
2403
|
uri: toWikiGraphUri(page.id)
|
|
2078
2404
|
};
|
|
2079
2405
|
}
|
|
2406
|
+
case "archive-title":
|
|
2407
|
+
return {
|
|
2408
|
+
...librarySource,
|
|
2409
|
+
title: page.title,
|
|
2410
|
+
type: "archive-title",
|
|
2411
|
+
uri: toWikiGraphUri(page.id)
|
|
2412
|
+
};
|
|
2080
2413
|
case "chapter-title":
|
|
2081
2414
|
return {
|
|
2082
2415
|
...librarySource,
|
|
@@ -2266,6 +2599,7 @@ async function formatPackAnchor(anchor, context) {
|
|
|
2266
2599
|
switch (anchor.type) {
|
|
2267
2600
|
case "artifact":
|
|
2268
2601
|
return formatPlainObject(await createPageObject(anchor, context));
|
|
2602
|
+
case "archive-title":
|
|
2269
2603
|
case "chapter-title":
|
|
2270
2604
|
case "chapter":
|
|
2271
2605
|
return formatPlainObject(await createPageObject(anchor, context));
|
|
@@ -2800,6 +3134,7 @@ async function writePage(page, context, format) {
|
|
|
2800
3134
|
`
|
|
2801
3135
|
);
|
|
2802
3136
|
return;
|
|
3137
|
+
case "archive-title":
|
|
2803
3138
|
case "chapter-title":
|
|
2804
3139
|
await writeTextToStdout(
|
|
2805
3140
|
`${formatPlainObject(await createPageObject(page, context))}
|
|
@@ -3021,27 +3356,16 @@ var init_types2 = __esm({
|
|
|
3021
3356
|
});
|
|
3022
3357
|
|
|
3023
3358
|
// src/commands/archive-command/run/uri.ts
|
|
3024
|
-
|
|
3025
|
-
return await (0, import_wiki_graph_sdk20.resolveWikiGraphArchiveLocation)(uriOrPath);
|
|
3026
|
-
}
|
|
3027
|
-
async function resolveArchiveCommandRuntimeArguments(args) {
|
|
3359
|
+
function resolveArchiveCommandRuntimeArguments(args) {
|
|
3028
3360
|
if (args.action === "create" || args.action === "export") {
|
|
3029
|
-
|
|
3030
|
-
return { ...args, archivePath: location2.archivePath };
|
|
3361
|
+
return { ...args, archivePath: getArchivePath(args.archivePath) };
|
|
3031
3362
|
}
|
|
3032
|
-
|
|
3033
|
-
if (!args.archivePath.startsWith("wikg://lib/")) {
|
|
3034
|
-
return args;
|
|
3035
|
-
}
|
|
3036
|
-
const location = await resolveArchiveRuntimeLocation(args.archivePath);
|
|
3037
|
-
return {
|
|
3038
|
-
...args,
|
|
3039
|
-
archivePath: location.locatedUri,
|
|
3040
|
-
...args.objectId === args.archivePath ? { objectId: location.locatedUri } : {}
|
|
3041
|
-
};
|
|
3363
|
+
return args;
|
|
3042
3364
|
}
|
|
3043
3365
|
function getArchivePath(uri) {
|
|
3044
|
-
if (
|
|
3366
|
+
if (!uri.includes("://")) return uri;
|
|
3367
|
+
const libraryTarget = (0, import_wiki_graph_sdk22.parseWikiGraphLibraryUri)(uri);
|
|
3368
|
+
if (libraryTarget?.kind === "scope" || libraryTarget?.kind === "archive-collection") {
|
|
3045
3369
|
return uri;
|
|
3046
3370
|
}
|
|
3047
3371
|
const archivePath = parseLocatedWikiGraphUri(uri).archivePath;
|
|
@@ -3051,14 +3375,15 @@ function getArchivePath(uri) {
|
|
|
3051
3375
|
return archivePath;
|
|
3052
3376
|
}
|
|
3053
3377
|
function getArchiveIndexScope(uri) {
|
|
3054
|
-
|
|
3378
|
+
const libraryTarget = (0, import_wiki_graph_sdk22.parseWikiGraphLibraryUri)(uri);
|
|
3379
|
+
if (libraryTarget?.kind === "scope" || libraryTarget?.kind === "archive-collection") {
|
|
3055
3380
|
return { kind: "library-index", libraryId: -1 };
|
|
3056
3381
|
}
|
|
3057
3382
|
const archivePath = getArchivePath(uri);
|
|
3058
3383
|
return { archiveKey: archivePath, archivePath, kind: "archive-index" };
|
|
3059
3384
|
}
|
|
3060
3385
|
function getObjectUri(uri) {
|
|
3061
|
-
const libraryTarget = (0,
|
|
3386
|
+
const libraryTarget = (0, import_wiki_graph_sdk22.parseWikiGraphLibraryUri)(uri);
|
|
3062
3387
|
if (libraryTarget?.kind === "scope" && libraryTarget.objectUri !== void 0) {
|
|
3063
3388
|
return libraryTarget.objectUri;
|
|
3064
3389
|
}
|
|
@@ -3072,11 +3397,11 @@ function parseChapterScope(uri) {
|
|
|
3072
3397
|
const match = /^wikg:\/\/chapter\/([1-9][0-9]*)(?:\/|$)/u.exec(uri);
|
|
3073
3398
|
return match?.[1] === void 0 ? void 0 : Number(match[1]);
|
|
3074
3399
|
}
|
|
3075
|
-
var
|
|
3400
|
+
var import_wiki_graph_sdk22;
|
|
3076
3401
|
var init_uri3 = __esm({
|
|
3077
3402
|
"src/commands/archive-command/run/uri.ts"() {
|
|
3078
3403
|
"use strict";
|
|
3079
|
-
|
|
3404
|
+
import_wiki_graph_sdk22 = require("wiki-graph-sdk");
|
|
3080
3405
|
init_support();
|
|
3081
3406
|
}
|
|
3082
3407
|
});
|
|
@@ -3098,6 +3423,7 @@ function createFindOptions(args) {
|
|
|
3098
3423
|
...createOptionalEvidenceLimit(args),
|
|
3099
3424
|
...args.limit === void 0 ? {} : { limit: args.limit },
|
|
3100
3425
|
...args.reverse === true ? { order: "doc-desc" } : {},
|
|
3426
|
+
...args.queryMode === void 0 ? {} : { queryMode: args.queryMode },
|
|
3101
3427
|
...args.skipUnindexed === true ? { skipUnindexed: true } : {},
|
|
3102
3428
|
...createOptionalSourceContext(args),
|
|
3103
3429
|
...args.triplePattern === void 0 ? {} : { triplePattern: args.triplePattern },
|
|
@@ -3119,6 +3445,7 @@ function createArchiveOutputContext(args, options = {}) {
|
|
|
3119
3445
|
...args.reverse === true ? { order: "doc-desc" } : {},
|
|
3120
3446
|
...args.action !== "evidence" && args.action !== "related" && args.action !== "search" ? {} : args.query === void 0 ? {} : { query: args.query },
|
|
3121
3447
|
...args.role === void 0 ? {} : { role: args.role },
|
|
3448
|
+
...args.queryMode === void 0 ? {} : { queryMode: args.queryMode },
|
|
3122
3449
|
...args.skipUnindexed === true ? { skipUnindexed: true } : {},
|
|
3123
3450
|
...options.continuationKind === "collection" ? createScopeOptions(args) : {},
|
|
3124
3451
|
...args.triplePattern === void 0 ? {} : { triplePattern: args.triplePattern },
|
|
@@ -3192,7 +3519,7 @@ function createScopeOptions(args) {
|
|
|
3192
3519
|
if (args.chapters !== void 0) {
|
|
3193
3520
|
return { chapters: args.chapters };
|
|
3194
3521
|
}
|
|
3195
|
-
const objectUri = (0,
|
|
3522
|
+
const objectUri = (0, import_wiki_graph_sdk23.parseLocatedWikiGraphUri)(args.archivePath).objectUri;
|
|
3196
3523
|
if (objectUri === void 0) {
|
|
3197
3524
|
return {};
|
|
3198
3525
|
}
|
|
@@ -3235,11 +3562,11 @@ function toArchiveCollectionType(kind) {
|
|
|
3235
3562
|
return "triple";
|
|
3236
3563
|
}
|
|
3237
3564
|
}
|
|
3238
|
-
var
|
|
3565
|
+
var import_wiki_graph_sdk23;
|
|
3239
3566
|
var init_options = __esm({
|
|
3240
3567
|
"src/commands/archive-command/run/options.ts"() {
|
|
3241
3568
|
"use strict";
|
|
3242
|
-
|
|
3569
|
+
import_wiki_graph_sdk23 = require("wiki-graph-sdk");
|
|
3243
3570
|
init_types2();
|
|
3244
3571
|
init_uri3();
|
|
3245
3572
|
}
|
|
@@ -3249,7 +3576,7 @@ var init_options = __esm({
|
|
|
3249
3576
|
async function runNextArchivePage(args) {
|
|
3250
3577
|
const cursorId = args.cursor ?? args.archivePath;
|
|
3251
3578
|
const page = await getWikiGraphSDK().continuations.next({
|
|
3252
|
-
...args.cursor === void 0 ? {} : { archive: args.archivePath },
|
|
3579
|
+
...args.cursor === void 0 ? {} : { archive: parseCLIArchiveTarget(args.archivePath) },
|
|
3253
3580
|
cursor: cursorId,
|
|
3254
3581
|
...args.format === void 0 ? {} : { format: args.format },
|
|
3255
3582
|
...args.limit === void 0 ? {} : { limit: args.limit }
|
|
@@ -3311,6 +3638,7 @@ function createCursorOutputContext(cursor, format, limit) {
|
|
|
3311
3638
|
targetUri: cursor.targetUri
|
|
3312
3639
|
} : {},
|
|
3313
3640
|
...cursor.kind === "related" && cursor.role !== void 0 ? { role: cursor.role } : {},
|
|
3641
|
+
...(cursor.kind === "search" || cursor.kind === "evidence" || cursor.kind === "related") && cursor.queryMode !== void 0 ? { queryMode: cursor.queryMode } : {},
|
|
3314
3642
|
...cursor.kind === "source-locators" ? { targetUri: cursor.targetUri } : {},
|
|
3315
3643
|
..."evidenceLimit" in cursor && cursor.evidenceLimit !== void 0 ? { evidenceLimit: cursor.evidenceLimit } : {},
|
|
3316
3644
|
..."sourceContext" in cursor && cursor.sourceContext !== void 0 ? { sourceContext: cursor.sourceContext } : {}
|
|
@@ -3319,6 +3647,7 @@ function createCursorOutputContext(cursor, format, limit) {
|
|
|
3319
3647
|
var init_next = __esm({
|
|
3320
3648
|
"src/commands/archive-command/run/next.ts"() {
|
|
3321
3649
|
"use strict";
|
|
3650
|
+
init_archive_target();
|
|
3322
3651
|
init_context();
|
|
3323
3652
|
init_archive_output();
|
|
3324
3653
|
init_options();
|
|
@@ -3330,17 +3659,17 @@ async function writeArchiveRoot(args) {
|
|
|
3330
3659
|
const archivePath = getArchivePath(args.objectId);
|
|
3331
3660
|
if (args.format === "json") {
|
|
3332
3661
|
await writeTextToStdout(
|
|
3333
|
-
formatCLIJSON({ uri: (0,
|
|
3662
|
+
formatCLIJSON({ uri: (0, import_wiki_graph_sdk24.formatLocatedWikiGraphUri)(archivePath) })
|
|
3334
3663
|
);
|
|
3335
3664
|
return;
|
|
3336
3665
|
}
|
|
3337
3666
|
await writeTextToStdout("<archive>\n");
|
|
3338
3667
|
}
|
|
3339
|
-
var
|
|
3668
|
+
var import_wiki_graph_sdk24;
|
|
3340
3669
|
var init_root = __esm({
|
|
3341
3670
|
"src/commands/archive-command/run/root.ts"() {
|
|
3342
3671
|
"use strict";
|
|
3343
|
-
|
|
3672
|
+
import_wiki_graph_sdk24 = require("wiki-graph-sdk");
|
|
3344
3673
|
init_support();
|
|
3345
3674
|
init_uri3();
|
|
3346
3675
|
}
|
|
@@ -3364,12 +3693,12 @@ __export(archive_command_exports, {
|
|
|
3364
3693
|
runArchiveCommand: () => runArchiveCommand
|
|
3365
3694
|
});
|
|
3366
3695
|
async function runArchiveCommand(args) {
|
|
3367
|
-
const libraryTarget = (0,
|
|
3368
|
-
if (libraryTarget?.kind === "scope" && libraryTarget.objectUri !== "wikg://index" && (libraryTarget.objectUri !== void 0 || args.action === "related" || args.action === "evidence" || args.action === "pack" || args.action === "search" || args.action === "list")) {
|
|
3696
|
+
const libraryTarget = (0, import_wiki_graph_sdk25.parseWikiGraphLibraryUri)(args.archivePath);
|
|
3697
|
+
if (libraryTarget?.kind === "scope" && libraryTarget.objectUri !== "wikg://index" && (libraryTarget.objectUri !== void 0 || args.action === "related" || args.action === "evidence" || args.action === "pack" || args.action === "search" || args.action === "list") || libraryTarget?.kind === "archive-collection" && args.action === "search") {
|
|
3369
3698
|
await runLibraryIndexArchiveCommand(args, libraryTarget);
|
|
3370
3699
|
return;
|
|
3371
3700
|
}
|
|
3372
|
-
args =
|
|
3701
|
+
args = resolveArchiveCommandRuntimeArguments(args);
|
|
3373
3702
|
switch (args.action) {
|
|
3374
3703
|
case "create":
|
|
3375
3704
|
await createArchive(args);
|
|
@@ -3414,7 +3743,9 @@ async function runArchiveCommand(args) {
|
|
|
3414
3743
|
return;
|
|
3415
3744
|
case "pack":
|
|
3416
3745
|
await writePack(
|
|
3417
|
-
await (await getWikiGraphSDK().archives.open(
|
|
3746
|
+
await (await getWikiGraphSDK().archives.open(
|
|
3747
|
+
parseCLIArchiveTarget(args.archivePath)
|
|
3748
|
+
)).pack(getObjectUri(args.objectId), args.budget ?? 5e3),
|
|
3418
3749
|
createArchiveOutputContext(args),
|
|
3419
3750
|
args.format ?? "text"
|
|
3420
3751
|
);
|
|
@@ -3422,9 +3753,11 @@ async function runArchiveCommand(args) {
|
|
|
3422
3753
|
}
|
|
3423
3754
|
}
|
|
3424
3755
|
async function runArchiveList(args) {
|
|
3425
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
3756
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
3757
|
+
parseCLIArchiveTarget(args.archivePath)
|
|
3758
|
+
);
|
|
3426
3759
|
const objectUri = getObjectUri(args.archivePath);
|
|
3427
|
-
if ((0,
|
|
3760
|
+
if ((0, import_wiki_graph_sdk25.isSourceLocatorScopeUri)(objectUri)) {
|
|
3428
3761
|
const context2 = createArchiveOutputContext(args, {
|
|
3429
3762
|
continuationKind: "source-locators",
|
|
3430
3763
|
targetUri: objectUri
|
|
@@ -3491,7 +3824,9 @@ async function runArchiveList(args) {
|
|
|
3491
3824
|
);
|
|
3492
3825
|
}
|
|
3493
3826
|
async function runArchiveSearch(args) {
|
|
3494
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
3827
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
3828
|
+
parseCLIArchiveTarget(args.archivePath)
|
|
3829
|
+
);
|
|
3495
3830
|
const scope = await archive.resolveScope({
|
|
3496
3831
|
...args.depth === void 0 ? {} : { depth: args.depth }
|
|
3497
3832
|
});
|
|
@@ -3525,7 +3860,9 @@ async function runArchiveGet(args) {
|
|
|
3525
3860
|
const objectUri = getObjectUri(args.objectId);
|
|
3526
3861
|
const evidenceLimit = getSingleObjectEvidenceLimit(args, objectUri);
|
|
3527
3862
|
const context = evidenceLimit === void 0 ? createArchiveOutputContext(args) : createArchiveOutputContext({ ...args, evidenceLimit });
|
|
3528
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
3863
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
3864
|
+
parseCLIArchiveTarget(args.archivePath)
|
|
3865
|
+
);
|
|
3529
3866
|
await writePage(
|
|
3530
3867
|
await archive.page(objectUri, {
|
|
3531
3868
|
...args.backlinks === void 0 ? {} : { backlinks: args.backlinks },
|
|
@@ -3539,7 +3876,9 @@ async function runArchiveGet(args) {
|
|
|
3539
3876
|
}
|
|
3540
3877
|
async function runArchiveRelated(args) {
|
|
3541
3878
|
const objectUri = getObjectUri(args.objectId);
|
|
3542
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
3879
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
3880
|
+
parseCLIArchiveTarget(args.archivePath)
|
|
3881
|
+
);
|
|
3543
3882
|
const scope = await archive.resolveScope();
|
|
3544
3883
|
const context = createArchiveOutputContext(
|
|
3545
3884
|
scope === void 0 ? args : { ...args, chapters: scope.chapterIds },
|
|
@@ -3554,6 +3893,7 @@ async function runArchiveRelated(args) {
|
|
|
3554
3893
|
...args.limit === void 0 ? {} : { limit: args.limit },
|
|
3555
3894
|
...args.reverse === true ? { order: "doc-desc" } : {},
|
|
3556
3895
|
...args.query === void 0 ? {} : { query: args.query },
|
|
3896
|
+
...args.queryMode === void 0 ? {} : { queryMode: args.queryMode },
|
|
3557
3897
|
...args.role === void 0 ? {} : { role: args.role },
|
|
3558
3898
|
...args.skipUnindexed === true ? { skipUnindexed: true } : {},
|
|
3559
3899
|
...createOptionalSourceContext(args)
|
|
@@ -3571,7 +3911,9 @@ async function runArchiveRelated(args) {
|
|
|
3571
3911
|
}
|
|
3572
3912
|
async function runArchiveEvidence(args) {
|
|
3573
3913
|
const objectUri = getObjectUri(args.objectId);
|
|
3574
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
3914
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
3915
|
+
parseCLIArchiveTarget(args.archivePath)
|
|
3916
|
+
);
|
|
3575
3917
|
const scope = await archive.resolveScope();
|
|
3576
3918
|
const context = createArchiveOutputContext(
|
|
3577
3919
|
scope === void 0 ? args : { ...args, chapters: scope.chapterIds },
|
|
@@ -3585,6 +3927,7 @@ async function runArchiveEvidence(args) {
|
|
|
3585
3927
|
...args.limit === void 0 ? {} : { limit: args.limit },
|
|
3586
3928
|
...args.reverse === true ? { order: "doc-desc" } : {},
|
|
3587
3929
|
...args.query === void 0 ? {} : { query: args.query },
|
|
3930
|
+
...args.queryMode === void 0 ? {} : { queryMode: args.queryMode },
|
|
3588
3931
|
...args.skipUnindexed === true ? { skipUnindexed: true } : {},
|
|
3589
3932
|
...createOptionalSourceContext(args)
|
|
3590
3933
|
});
|
|
@@ -3630,10 +3973,11 @@ function isArchiveQueryNotReadyError(error) {
|
|
|
3630
3973
|
async function runLibraryIndexArchiveCommand(args, target) {
|
|
3631
3974
|
const libraries = getWikiGraphSDK().libraries;
|
|
3632
3975
|
const library = await libraries.get(
|
|
3633
|
-
(0,
|
|
3976
|
+
(0, import_wiki_graph_sdk25.formatWikiGraphLibraryUri)(target.publicId)
|
|
3634
3977
|
);
|
|
3635
|
-
const
|
|
3636
|
-
const
|
|
3978
|
+
const isArchiveMemberCollection = target.kind === "archive-collection";
|
|
3979
|
+
const isLibraryRootCollection = !isArchiveMemberCollection && target.objectUri === void 0 && args.objectId === void 0;
|
|
3980
|
+
const objectUri = isLibraryRootCollection ? void 0 : isArchiveMemberCollection ? void 0 : getObjectUri(args.objectId ?? args.archivePath);
|
|
3637
3981
|
const context = {
|
|
3638
3982
|
...createArchiveOutputContext(args),
|
|
3639
3983
|
archiveKey: args.archivePath,
|
|
@@ -3642,25 +3986,25 @@ async function runLibraryIndexArchiveCommand(args, target) {
|
|
|
3642
3986
|
kind: "library-index",
|
|
3643
3987
|
libraryId: library.snapshot.id
|
|
3644
3988
|
},
|
|
3645
|
-
libraryQuery: "objects"
|
|
3989
|
+
libraryQuery: isArchiveMemberCollection ? "archive-members" : "objects"
|
|
3646
3990
|
};
|
|
3647
3991
|
switch (args.action) {
|
|
3648
3992
|
case "search": {
|
|
3649
3993
|
const findOptions = createSearchFindOptions(args);
|
|
3650
3994
|
if (objectUri === void 0) {
|
|
3995
|
+
const search = async (cursor) => await (isArchiveMemberCollection ? libraries.searchArchiveMembers(target, args.query, {
|
|
3996
|
+
...findOptions,
|
|
3997
|
+
...cursor === void 0 ? {} : { cursor }
|
|
3998
|
+
}) : libraries.search(target, args.query, {
|
|
3999
|
+
...findOptions,
|
|
4000
|
+
...cursor === void 0 ? {} : { cursor }
|
|
4001
|
+
}));
|
|
3651
4002
|
if (args.all === true) {
|
|
3652
|
-
await writeAllFindHits(
|
|
3653
|
-
async (cursor) => await libraries.search(target, args.query, {
|
|
3654
|
-
...findOptions,
|
|
3655
|
-
...cursor === void 0 ? {} : { cursor }
|
|
3656
|
-
}),
|
|
3657
|
-
context,
|
|
3658
|
-
args.format ?? "text"
|
|
3659
|
-
);
|
|
4003
|
+
await writeAllFindHits(search, context, args.format ?? "text");
|
|
3660
4004
|
return;
|
|
3661
4005
|
}
|
|
3662
4006
|
await writeFindHits(
|
|
3663
|
-
await
|
|
4007
|
+
await search(args.cursor),
|
|
3664
4008
|
context,
|
|
3665
4009
|
args.format ?? "text"
|
|
3666
4010
|
);
|
|
@@ -3801,6 +4145,7 @@ async function runLibraryIndexArchiveCommand(args, target) {
|
|
|
3801
4145
|
...args.limit === void 0 ? {} : { limit: args.limit },
|
|
3802
4146
|
...args.reverse === true ? { order: "doc-desc" } : {},
|
|
3803
4147
|
...args.query === void 0 ? {} : { query: args.query },
|
|
4148
|
+
...args.queryMode === void 0 ? {} : { queryMode: args.queryMode },
|
|
3804
4149
|
...args.role === void 0 ? {} : { role: args.role },
|
|
3805
4150
|
...args.skipUnindexed === true ? { skipUnindexed: true } : {},
|
|
3806
4151
|
...createOptionalSourceContext(args)
|
|
@@ -3835,6 +4180,7 @@ async function runLibraryIndexArchiveCommand(args, target) {
|
|
|
3835
4180
|
...args.limit === void 0 ? {} : { limit: args.limit },
|
|
3836
4181
|
...args.reverse === true ? { order: "doc-desc" } : {},
|
|
3837
4182
|
...args.query === void 0 ? {} : { query: args.query },
|
|
4183
|
+
...args.queryMode === void 0 ? {} : { queryMode: args.queryMode },
|
|
3838
4184
|
...args.skipUnindexed === true ? { skipUnindexed: true } : {},
|
|
3839
4185
|
...createOptionalSourceContext(args)
|
|
3840
4186
|
}),
|
|
@@ -3850,6 +4196,7 @@ async function runLibraryIndexArchiveCommand(args, target) {
|
|
|
3850
4196
|
...args.limit === void 0 ? {} : { limit: args.limit },
|
|
3851
4197
|
...args.reverse === true ? { order: "doc-desc" } : {},
|
|
3852
4198
|
...args.query === void 0 ? {} : { query: args.query },
|
|
4199
|
+
...args.queryMode === void 0 ? {} : { queryMode: args.queryMode },
|
|
3853
4200
|
...args.skipUnindexed === true ? { skipUnindexed: true } : {},
|
|
3854
4201
|
...createOptionalSourceContext(args)
|
|
3855
4202
|
}),
|
|
@@ -3887,11 +4234,11 @@ function requireLibraryObjectUri(action, objectUri) {
|
|
|
3887
4234
|
}
|
|
3888
4235
|
return objectUri;
|
|
3889
4236
|
}
|
|
3890
|
-
var
|
|
4237
|
+
var import_wiki_graph_sdk25;
|
|
3891
4238
|
var init_archive_command = __esm({
|
|
3892
4239
|
"src/commands/archive-command/index.ts"() {
|
|
3893
4240
|
"use strict";
|
|
3894
|
-
|
|
4241
|
+
import_wiki_graph_sdk25 = require("wiki-graph-sdk");
|
|
3895
4242
|
init_context();
|
|
3896
4243
|
init_support();
|
|
3897
4244
|
init_convert();
|
|
@@ -3899,6 +4246,38 @@ var init_archive_command = __esm({
|
|
|
3899
4246
|
init_inspect();
|
|
3900
4247
|
init_archive_output();
|
|
3901
4248
|
init_run();
|
|
4249
|
+
init_archive_target();
|
|
4250
|
+
}
|
|
4251
|
+
});
|
|
4252
|
+
|
|
4253
|
+
// src/commands/archive-title.ts
|
|
4254
|
+
var archive_title_exports = {};
|
|
4255
|
+
__export(archive_title_exports, {
|
|
4256
|
+
runArchiveTitleCommand: () => runArchiveTitleCommand
|
|
4257
|
+
});
|
|
4258
|
+
async function runArchiveTitleCommand(args) {
|
|
4259
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
4260
|
+
parseCLIArchiveTarget(args.archivePath)
|
|
4261
|
+
);
|
|
4262
|
+
if (args.action === "clear") {
|
|
4263
|
+
await archive.setArchiveTitle(null);
|
|
4264
|
+
await writeTextToStdout("Cleared archive title.\n");
|
|
4265
|
+
return;
|
|
4266
|
+
}
|
|
4267
|
+
const title = args.title;
|
|
4268
|
+
if (title === void 0) {
|
|
4269
|
+
throw new Error("Missing archive title.");
|
|
4270
|
+
}
|
|
4271
|
+
const stored = await archive.setArchiveTitle(title);
|
|
4272
|
+
await writeTextToStdout(`${stored}
|
|
4273
|
+
`);
|
|
4274
|
+
}
|
|
4275
|
+
var init_archive_title = __esm({
|
|
4276
|
+
"src/commands/archive-title.ts"() {
|
|
4277
|
+
"use strict";
|
|
4278
|
+
init_context();
|
|
4279
|
+
init_archive_target();
|
|
4280
|
+
init_support();
|
|
3902
4281
|
}
|
|
3903
4282
|
});
|
|
3904
4283
|
|
|
@@ -4225,15 +4604,6 @@ var init_estimate = __esm({
|
|
|
4225
4604
|
}
|
|
4226
4605
|
});
|
|
4227
4606
|
|
|
4228
|
-
// src/runtime/node-platform.ts
|
|
4229
|
-
var node_platform_exports = {};
|
|
4230
|
-
var init_node_platform = __esm({
|
|
4231
|
-
"src/runtime/node-platform.ts"() {
|
|
4232
|
-
"use strict";
|
|
4233
|
-
__reExport(node_platform_exports, require("wiki-graph-sdk/node-platform"));
|
|
4234
|
-
}
|
|
4235
|
-
});
|
|
4236
|
-
|
|
4237
4607
|
// src/commands/queue/output.ts
|
|
4238
4608
|
async function writeJobList(jobs, options) {
|
|
4239
4609
|
const chapters = await resolveJobChapters(jobs);
|
|
@@ -4467,7 +4837,7 @@ function createJobChapterReference(job, chapter) {
|
|
|
4467
4837
|
}
|
|
4468
4838
|
function createJobChapterReferenceFromPath(archivePath, chapter) {
|
|
4469
4839
|
return {
|
|
4470
|
-
locatedUri: (0,
|
|
4840
|
+
locatedUri: (0, import_wiki_graph_sdk26.formatLocatedChapterUri)(archivePath, chapter.path),
|
|
4471
4841
|
title: chapter.title,
|
|
4472
4842
|
uri: chapter.uri
|
|
4473
4843
|
};
|
|
@@ -4480,26 +4850,23 @@ async function resolveJobChapter(job) {
|
|
|
4480
4850
|
}
|
|
4481
4851
|
function getJobResourcePath(job, resourceKey, legacyKey) {
|
|
4482
4852
|
const record = job;
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
const managedPath = getManagedJobResourcePath(resource);
|
|
4486
|
-
if (managedPath !== void 0) return managedPath;
|
|
4487
|
-
return (0, node_platform_exports.getNodeResourcePath)(resource);
|
|
4853
|
+
if (resourceKey === "archive") {
|
|
4854
|
+
return job.archive.kind === "library" ? job.archive.uri : job.archive.path;
|
|
4488
4855
|
}
|
|
4489
4856
|
const legacyPath = record[legacyKey];
|
|
4490
|
-
if (typeof legacyPath === "string")
|
|
4857
|
+
if (typeof legacyPath === "string") {
|
|
4858
|
+
return resolveManagedJobResourcePath(legacyPath) ?? legacyPath;
|
|
4859
|
+
}
|
|
4491
4860
|
return void 0;
|
|
4492
4861
|
}
|
|
4493
|
-
function
|
|
4494
|
-
if (
|
|
4495
|
-
|
|
4496
|
-
}
|
|
4497
|
-
const relativePath = resource.identity.slice("managed:library:".length);
|
|
4862
|
+
function resolveManagedJobResourcePath(identity) {
|
|
4863
|
+
if (!identity.startsWith("managed:library:")) return void 0;
|
|
4864
|
+
const relativePath = identity.slice("managed:library:".length);
|
|
4498
4865
|
const segments = relativePath.split("/");
|
|
4499
4866
|
if (relativePath === "" || segments.some(
|
|
4500
4867
|
(segment) => segment === "" || segment === "." || segment === ".." || segment.includes("\\")
|
|
4501
4868
|
)) {
|
|
4502
|
-
throw new TypeError(`Invalid managed job resource: ${
|
|
4869
|
+
throw new TypeError(`Invalid managed job resource: ${identity}`);
|
|
4503
4870
|
}
|
|
4504
4871
|
const environmentHome = getCLIEnvValue("HOME")?.trim();
|
|
4505
4872
|
const stateDirectory = getCLIStateDir() ?? (0, import_path7.join)(
|
|
@@ -4513,14 +4880,13 @@ function requireJobResourcePath(job, resourceKey, legacyKey) {
|
|
|
4513
4880
|
if (path !== void 0) return path;
|
|
4514
4881
|
throw new TypeError(`Build job is missing ${resourceKey}`);
|
|
4515
4882
|
}
|
|
4516
|
-
var
|
|
4883
|
+
var import_wiki_graph_sdk26, import_os3, import_path7;
|
|
4517
4884
|
var init_output = __esm({
|
|
4518
4885
|
"src/commands/queue/output.ts"() {
|
|
4519
4886
|
"use strict";
|
|
4520
|
-
|
|
4887
|
+
import_wiki_graph_sdk26 = require("wiki-graph-sdk");
|
|
4521
4888
|
init_support();
|
|
4522
4889
|
init_estimate();
|
|
4523
|
-
init_node_platform();
|
|
4524
4890
|
init_context();
|
|
4525
4891
|
import_os3 = require("os");
|
|
4526
4892
|
import_path7 = require("path");
|
|
@@ -4553,6 +4919,7 @@ var init_add = __esm({
|
|
|
4553
4919
|
init_internal_child();
|
|
4554
4920
|
init_estimate();
|
|
4555
4921
|
init_output();
|
|
4922
|
+
init_archive_target();
|
|
4556
4923
|
}
|
|
4557
4924
|
});
|
|
4558
4925
|
|
|
@@ -4563,7 +4930,7 @@ __export(chapter_exports, {
|
|
|
4563
4930
|
});
|
|
4564
4931
|
async function runArchiveChapterCommand(args) {
|
|
4565
4932
|
const sdk = getWikiGraphSDK();
|
|
4566
|
-
const archive = await sdk.archives.open(args.path);
|
|
4933
|
+
const archive = await sdk.archives.open(parseCLIArchiveTarget(args.path));
|
|
4567
4934
|
switch (args.action) {
|
|
4568
4935
|
case "add": {
|
|
4569
4936
|
const details = await archive.addChapter({
|
|
@@ -4593,7 +4960,7 @@ async function runArchiveChapterCommand(args) {
|
|
|
4593
4960
|
requireChapterPath2(args.chapterPath)
|
|
4594
4961
|
);
|
|
4595
4962
|
const job = await sdk.jobs.create({
|
|
4596
|
-
archive: archive.
|
|
4963
|
+
archive: archive.target,
|
|
4597
4964
|
chapterId: chapter.chapterId,
|
|
4598
4965
|
target: requireIndexArtifactTarget(args.indexArtifactTarget)
|
|
4599
4966
|
});
|
|
@@ -4653,7 +5020,7 @@ async function runArchiveChapterCommand(args) {
|
|
|
4653
5020
|
return;
|
|
4654
5021
|
case "set-source": {
|
|
4655
5022
|
const sourceText = await readRequiredSourceText(args);
|
|
4656
|
-
const parsed = args.inputFormat === "jsonl" ? (0,
|
|
5023
|
+
const parsed = args.inputFormat === "jsonl" ? (0, import_wiki_graph_sdk27.parseSourceTextJsonl)(sourceText) : void 0;
|
|
4657
5024
|
await writeChapterDetails(
|
|
4658
5025
|
await archive.setChapterSource(
|
|
4659
5026
|
requireChapterPath2(args.chapterPath),
|
|
@@ -4686,7 +5053,7 @@ async function runArchiveChapterCommand(args) {
|
|
|
4686
5053
|
if (args.treeAction === "apply") {
|
|
4687
5054
|
await writeChapterTreeApplyResult(
|
|
4688
5055
|
await archive.applyChapterTree(
|
|
4689
|
-
(0,
|
|
5056
|
+
(0, import_wiki_graph_sdk27.parseChapterTreeInput)(JSON.parse(await readContentText(args))),
|
|
4690
5057
|
{ dryRun: args.dryRun ?? false }
|
|
4691
5058
|
),
|
|
4692
5059
|
args.dryRun ?? false
|
|
@@ -4812,10 +5179,10 @@ function formatChapterCommandUri(archiveLocator, chapterPath) {
|
|
|
4812
5179
|
if (archiveLocator.startsWith("wikg://")) {
|
|
4813
5180
|
const parsed = parseLocatedWikiGraphUri(archiveLocator);
|
|
4814
5181
|
if (parsed.archivePath !== void 0) {
|
|
4815
|
-
return (0,
|
|
5182
|
+
return (0, import_wiki_graph_sdk27.formatLocatedChapterUri)(parsed.archivePath, chapterPath);
|
|
4816
5183
|
}
|
|
4817
5184
|
}
|
|
4818
|
-
return (0,
|
|
5185
|
+
return (0, import_wiki_graph_sdk27.formatLocatedChapterUri)(archiveLocator, chapterPath);
|
|
4819
5186
|
}
|
|
4820
5187
|
async function writeChapterList(entries, json) {
|
|
4821
5188
|
if (json) {
|
|
@@ -4902,14 +5269,15 @@ function formatStage(stage) {
|
|
|
4902
5269
|
return "reading-summary";
|
|
4903
5270
|
}
|
|
4904
5271
|
}
|
|
4905
|
-
var import_promises2,
|
|
5272
|
+
var import_promises2, import_wiki_graph_sdk27;
|
|
4906
5273
|
var init_chapter = __esm({
|
|
4907
5274
|
"src/commands/archive-command/chapter.ts"() {
|
|
4908
5275
|
"use strict";
|
|
4909
5276
|
import_promises2 = require("fs/promises");
|
|
4910
|
-
|
|
5277
|
+
import_wiki_graph_sdk27 = require("wiki-graph-sdk");
|
|
4911
5278
|
init_context();
|
|
4912
5279
|
init_support();
|
|
5280
|
+
init_archive_target();
|
|
4913
5281
|
init_support();
|
|
4914
5282
|
init_add();
|
|
4915
5283
|
init_output();
|
|
@@ -4935,11 +5303,15 @@ async function runArchiveIndexCommand(args) {
|
|
|
4935
5303
|
}
|
|
4936
5304
|
}
|
|
4937
5305
|
async function readIndexCache(args) {
|
|
4938
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
5306
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
5307
|
+
parseCLIArchiveTarget(args.archivePath)
|
|
5308
|
+
);
|
|
4939
5309
|
await writeIndexOutput(args, await archive.getSearchIndexStatus());
|
|
4940
5310
|
}
|
|
4941
5311
|
async function syncIndexCache(args) {
|
|
4942
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
5312
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
5313
|
+
parseCLIArchiveTarget(args.archivePath)
|
|
5314
|
+
);
|
|
4943
5315
|
const writer = new ProgressOutputWriter({
|
|
4944
5316
|
jsonl: args.jsonl ?? false,
|
|
4945
5317
|
throttleMs: INDEX_PROGRESS_OUTPUT_INTERVAL_MS
|
|
@@ -4988,7 +5360,9 @@ async function syncIndexCache(args) {
|
|
|
4988
5360
|
});
|
|
4989
5361
|
}
|
|
4990
5362
|
async function cleanIndexCache(args) {
|
|
4991
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
5363
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
5364
|
+
parseCLIArchiveTarget(args.archivePath)
|
|
5365
|
+
);
|
|
4992
5366
|
await writeIndexOutput(args, await archive.cleanSearchIndex());
|
|
4993
5367
|
}
|
|
4994
5368
|
function formatIndexCounter(input) {
|
|
@@ -5057,6 +5431,7 @@ var init_search_index = __esm({
|
|
|
5057
5431
|
"src/commands/archive-command/search-index.ts"() {
|
|
5058
5432
|
"use strict";
|
|
5059
5433
|
init_support();
|
|
5434
|
+
init_archive_target();
|
|
5060
5435
|
init_support();
|
|
5061
5436
|
init_runtime();
|
|
5062
5437
|
init_context();
|
|
@@ -5075,13 +5450,17 @@ async function runArchiveMetaCommand(args) {
|
|
|
5075
5450
|
await updateArchiveMeta(args.inputPath, args.metaPatch);
|
|
5076
5451
|
return;
|
|
5077
5452
|
}
|
|
5078
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
5453
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
5454
|
+
parseCLIArchiveTarget(args.inputPath)
|
|
5455
|
+
);
|
|
5079
5456
|
await writeArchiveMeta(await archive.readBookMeta(), {
|
|
5080
5457
|
json: args.json ?? false
|
|
5081
5458
|
});
|
|
5082
5459
|
}
|
|
5083
5460
|
async function runArchiveCoverCommand(args) {
|
|
5084
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
5461
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
5462
|
+
parseCLIArchiveTarget(args.inputPath)
|
|
5463
|
+
);
|
|
5085
5464
|
if (process.stdout.isTTY === true) {
|
|
5086
5465
|
throw new Error(
|
|
5087
5466
|
"Refusing to write binary cover data to an interactive terminal. Redirect stdout or pipe it."
|
|
@@ -5094,7 +5473,9 @@ async function runArchiveCoverCommand(args) {
|
|
|
5094
5473
|
await writeBinaryToStdout(cover.data);
|
|
5095
5474
|
}
|
|
5096
5475
|
async function updateArchiveMeta(path, patch) {
|
|
5097
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
5476
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
5477
|
+
parseCLIArchiveTarget(path)
|
|
5478
|
+
);
|
|
5098
5479
|
const meta = await archive.readBookMeta();
|
|
5099
5480
|
if (meta === void 0) {
|
|
5100
5481
|
throw new Error("Archive metadata is missing.");
|
|
@@ -5157,6 +5538,7 @@ var init_maintenance = __esm({
|
|
|
5157
5538
|
"src/commands/archive-command/maintenance.ts"() {
|
|
5158
5539
|
"use strict";
|
|
5159
5540
|
init_support();
|
|
5541
|
+
init_archive_target();
|
|
5160
5542
|
init_support();
|
|
5161
5543
|
init_context();
|
|
5162
5544
|
}
|
|
@@ -5687,7 +6069,7 @@ async function runLibraryCommand(args) {
|
|
|
5687
6069
|
}
|
|
5688
6070
|
if (args.target.kind === "archive-collection") {
|
|
5689
6071
|
await writeLibraryArchives(
|
|
5690
|
-
await (await libraries.get((0,
|
|
6072
|
+
await (await libraries.get((0, import_wiki_graph_sdk28.formatWikiGraphLibraryUri)(args.target.publicId))).archives(),
|
|
5691
6073
|
args.json ?? false
|
|
5692
6074
|
);
|
|
5693
6075
|
return;
|
|
@@ -5719,7 +6101,7 @@ async function runLibraryCommand(args) {
|
|
|
5719
6101
|
}
|
|
5720
6102
|
case "archive-tree": {
|
|
5721
6103
|
await writeLibraryArchiveTree(
|
|
5722
|
-
await (await libraries.get((0,
|
|
6104
|
+
await (await libraries.get((0, import_wiki_graph_sdk28.formatWikiGraphLibraryUri)(args.target.publicId))).archives(),
|
|
5723
6105
|
{
|
|
5724
6106
|
...args.depth === void 0 ? {} : { depth: args.depth },
|
|
5725
6107
|
json: args.json ?? false,
|
|
@@ -5793,10 +6175,24 @@ async function runLibraryCommand(args) {
|
|
|
5793
6175
|
);
|
|
5794
6176
|
return;
|
|
5795
6177
|
}
|
|
6178
|
+
case "replace": {
|
|
6179
|
+
if (args.inputPath === void 0) {
|
|
6180
|
+
throw new Error("Missing --input <path> for library archive replace.");
|
|
6181
|
+
}
|
|
6182
|
+
await writeLibraryArchive(
|
|
6183
|
+
await libraries.replaceArchive({
|
|
6184
|
+
inputPath: args.inputPath,
|
|
6185
|
+
target: args.target
|
|
6186
|
+
}),
|
|
6187
|
+
args.json ?? false,
|
|
6188
|
+
"Replaced library archive"
|
|
6189
|
+
);
|
|
6190
|
+
return;
|
|
6191
|
+
}
|
|
5796
6192
|
case "get": {
|
|
5797
6193
|
if (args.target.kind === "path") {
|
|
5798
6194
|
await writeLibraryPath(
|
|
5799
|
-
(await libraries.get((0,
|
|
6195
|
+
(await libraries.get((0, import_wiki_graph_sdk28.formatWikiGraphLibraryUri)(args.target.publicId))).snapshot,
|
|
5800
6196
|
args.json ?? false
|
|
5801
6197
|
);
|
|
5802
6198
|
return;
|
|
@@ -5824,7 +6220,7 @@ async function runLibraryCommand(args) {
|
|
|
5824
6220
|
}
|
|
5825
6221
|
if (args.target.kind === "archive-collection") {
|
|
5826
6222
|
await writeLibraryArchives(
|
|
5827
|
-
await (await libraries.get((0,
|
|
6223
|
+
await (await libraries.get((0, import_wiki_graph_sdk28.formatWikiGraphLibraryUri)(args.target.publicId))).archives(),
|
|
5828
6224
|
args.json ?? false
|
|
5829
6225
|
);
|
|
5830
6226
|
return;
|
|
@@ -5890,9 +6286,8 @@ async function writeLibrary(library, json) {
|
|
|
5890
6286
|
formatCLIJSON({
|
|
5891
6287
|
uri: library.uri,
|
|
5892
6288
|
id: library.publicId,
|
|
5893
|
-
folderPath:
|
|
6289
|
+
folderPath: library.folderPath,
|
|
5894
6290
|
isDefault: library.isDefault,
|
|
5895
|
-
stagingPath: (0, node_platform_exports.getNodeResourcePath)(library.staging),
|
|
5896
6291
|
createdAt: library.createdAt,
|
|
5897
6292
|
updatedAt: library.updatedAt
|
|
5898
6293
|
})
|
|
@@ -5909,7 +6304,7 @@ async function writeLibraries(libraries, json) {
|
|
|
5909
6304
|
items: libraries.map((library) => ({
|
|
5910
6305
|
uri: library.uri,
|
|
5911
6306
|
id: library.publicId,
|
|
5912
|
-
path:
|
|
6307
|
+
path: library.folderPath,
|
|
5913
6308
|
isDefault: library.isDefault
|
|
5914
6309
|
}))
|
|
5915
6310
|
})
|
|
@@ -5921,7 +6316,7 @@ async function writeLibraries(libraries, json) {
|
|
|
5921
6316
|
(library) => [
|
|
5922
6317
|
library.uri,
|
|
5923
6318
|
library.publicId,
|
|
5924
|
-
|
|
6319
|
+
library.folderPath,
|
|
5925
6320
|
library.isDefault ? "default" : ""
|
|
5926
6321
|
].join(" ")
|
|
5927
6322
|
).join("\n") + (libraries.length === 0 ? "" : "\n")
|
|
@@ -5932,12 +6327,12 @@ async function writeLibraryPath(library, json) {
|
|
|
5932
6327
|
await writeTextToStdout(
|
|
5933
6328
|
formatCLIJSON({
|
|
5934
6329
|
uri: `${library.uri}/path`,
|
|
5935
|
-
path:
|
|
6330
|
+
path: library.folderPath
|
|
5936
6331
|
})
|
|
5937
6332
|
);
|
|
5938
6333
|
return;
|
|
5939
6334
|
}
|
|
5940
|
-
await writeTextToStdout(`${
|
|
6335
|
+
await writeTextToStdout(`${library.folderPath}
|
|
5941
6336
|
`);
|
|
5942
6337
|
}
|
|
5943
6338
|
async function writeLibraryArchivePath(archive, json) {
|
|
@@ -6004,8 +6399,8 @@ async function writeLibraryArchives(archives, json) {
|
|
|
6004
6399
|
}
|
|
6005
6400
|
async function writeLibraryScopeCollection(target, json) {
|
|
6006
6401
|
const manager = getWikiGraphSDK().libraries;
|
|
6007
|
-
const library = await manager.get((0,
|
|
6008
|
-
const baseUri = (0,
|
|
6402
|
+
const library = await manager.get((0, import_wiki_graph_sdk28.formatWikiGraphLibraryUri)(target.publicId));
|
|
6403
|
+
const baseUri = (0, import_wiki_graph_sdk28.formatWikiGraphLibraryUri)(target.publicId);
|
|
6009
6404
|
const context = {
|
|
6010
6405
|
archiveKey: baseUri,
|
|
6011
6406
|
archivePath: baseUri,
|
|
@@ -6276,18 +6671,17 @@ function formatMetadataTextValue(value) {
|
|
|
6276
6671
|
return String(value);
|
|
6277
6672
|
}
|
|
6278
6673
|
function formatArchiveHostPath(archive) {
|
|
6279
|
-
return archive.
|
|
6674
|
+
return archive.relativePath;
|
|
6280
6675
|
}
|
|
6281
|
-
var import_promises4,
|
|
6676
|
+
var import_promises4, import_wiki_graph_sdk28, INDEX_PROGRESS_OUTPUT_INTERVAL_MS2;
|
|
6282
6677
|
var init_library = __esm({
|
|
6283
6678
|
"src/commands/library.ts"() {
|
|
6284
6679
|
"use strict";
|
|
6285
6680
|
import_promises4 = require("fs/promises");
|
|
6286
|
-
|
|
6681
|
+
import_wiki_graph_sdk28 = require("wiki-graph-sdk");
|
|
6287
6682
|
init_context();
|
|
6288
6683
|
init_support();
|
|
6289
6684
|
init_run();
|
|
6290
|
-
init_node_platform();
|
|
6291
6685
|
init_archive_output();
|
|
6292
6686
|
init_runtime();
|
|
6293
6687
|
INDEX_PROGRESS_OUTPUT_INTERVAL_MS2 = 6e3;
|
|
@@ -6300,7 +6694,9 @@ __export(object_metadata_exports, {
|
|
|
6300
6694
|
runObjectMetadataCommand: () => runObjectMetadataCommand
|
|
6301
6695
|
});
|
|
6302
6696
|
async function runObjectMetadataCommand(args) {
|
|
6303
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
6697
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
6698
|
+
parseCLIArchiveTarget(args.archivePath)
|
|
6699
|
+
);
|
|
6304
6700
|
switch (args.action) {
|
|
6305
6701
|
case "get": {
|
|
6306
6702
|
await writeMetadataMap2(
|
|
@@ -6431,6 +6827,7 @@ var init_object_metadata = __esm({
|
|
|
6431
6827
|
import_promises5 = require("fs/promises");
|
|
6432
6828
|
init_context();
|
|
6433
6829
|
init_support();
|
|
6830
|
+
init_archive_target();
|
|
6434
6831
|
init_support();
|
|
6435
6832
|
}
|
|
6436
6833
|
});
|
|
@@ -6564,11 +6961,11 @@ function formatProgressTokenMetrics(tokens) {
|
|
|
6564
6961
|
];
|
|
6565
6962
|
return metrics.length === 0 ? void 0 : { metrics, name: "tokens" };
|
|
6566
6963
|
}
|
|
6567
|
-
var
|
|
6964
|
+
var import_wiki_graph_sdk29, PROGRESS_OUTPUT_INTERVAL_MS;
|
|
6568
6965
|
var init_watch = __esm({
|
|
6569
6966
|
"src/commands/queue/watch.ts"() {
|
|
6570
6967
|
"use strict";
|
|
6571
|
-
|
|
6968
|
+
import_wiki_graph_sdk29 = require("wiki-graph-sdk");
|
|
6572
6969
|
init_runtime();
|
|
6573
6970
|
init_context();
|
|
6574
6971
|
PROGRESS_OUTPUT_INTERVAL_MS = 6e3;
|
|
@@ -6582,7 +6979,7 @@ async function runQueueWorker() {
|
|
|
6582
6979
|
process.once("SIGINT", stop);
|
|
6583
6980
|
process.once("SIGTERM", stop);
|
|
6584
6981
|
try {
|
|
6585
|
-
await (0,
|
|
6982
|
+
await (0, import_wiki_graph_sdk30.runWikiGraphQueueWorker)({ signal: controller.signal });
|
|
6586
6983
|
} catch (error) {
|
|
6587
6984
|
const message = error instanceof Error ? error.message : String(error);
|
|
6588
6985
|
throw new Error(withHelpRoute(message, CLI_HELP_ROUTES.config), {
|
|
@@ -6593,11 +6990,11 @@ async function runQueueWorker() {
|
|
|
6593
6990
|
process.removeListener("SIGTERM", stop);
|
|
6594
6991
|
}
|
|
6595
6992
|
}
|
|
6596
|
-
var
|
|
6993
|
+
var import_wiki_graph_sdk30;
|
|
6597
6994
|
var init_worker = __esm({
|
|
6598
6995
|
"src/commands/queue/worker.ts"() {
|
|
6599
6996
|
"use strict";
|
|
6600
|
-
|
|
6997
|
+
import_wiki_graph_sdk30 = require("wiki-graph-sdk");
|
|
6601
6998
|
init_support();
|
|
6602
6999
|
}
|
|
6603
7000
|
});
|
|
@@ -6661,7 +7058,7 @@ async function runQueueCommand(args) {
|
|
|
6661
7058
|
(await getWikiGraphSDK().jobs.list({
|
|
6662
7059
|
...args.activeOnly === void 0 ? {} : { activeOnly: args.activeOnly },
|
|
6663
7060
|
...args.all === void 0 ? {} : { all: args.all },
|
|
6664
|
-
...args.archivePath === void 0 ? {} : { archive:
|
|
7061
|
+
...args.archivePath === void 0 ? {} : { archive: parseCLIArchiveTarget(args.archivePath) }
|
|
6665
7062
|
})).map((job) => job.snapshot),
|
|
6666
7063
|
{ json: args.json ?? false }
|
|
6667
7064
|
);
|
|
@@ -6713,7 +7110,7 @@ async function getQueueJob(args) {
|
|
|
6713
7110
|
}
|
|
6714
7111
|
function createEnqueueOptions(args) {
|
|
6715
7112
|
return {
|
|
6716
|
-
archive: args.archivePath,
|
|
7113
|
+
archive: parseCLIArchiveTarget(args.archivePath),
|
|
6717
7114
|
...args.boost === void 0 ? {} : { boost: args.boost },
|
|
6718
7115
|
...args.chapterId === void 0 ? {} : { chapterId: args.chapterId },
|
|
6719
7116
|
...args.chapterIds === void 0 ? {} : { chapterIds: args.chapterIds },
|
|
@@ -6730,11 +7127,11 @@ var init_queue = __esm({
|
|
|
6730
7127
|
init_config();
|
|
6731
7128
|
init_context();
|
|
6732
7129
|
init_support();
|
|
7130
|
+
init_archive_target();
|
|
6733
7131
|
init_add();
|
|
6734
7132
|
init_estimate();
|
|
6735
7133
|
init_output();
|
|
6736
7134
|
init_watch();
|
|
6737
|
-
init_node_platform();
|
|
6738
7135
|
init_worker();
|
|
6739
7136
|
}
|
|
6740
7137
|
});
|
|
@@ -6750,10 +7147,10 @@ module.exports = __toCommonJS(src_exports);
|
|
|
6750
7147
|
|
|
6751
7148
|
// src/app/runner.ts
|
|
6752
7149
|
var import_stream2 = require("stream");
|
|
6753
|
-
var
|
|
7150
|
+
var import_wiki_graph_sdk32 = require("wiki-graph-sdk");
|
|
6754
7151
|
|
|
6755
7152
|
// src/args/help.ts
|
|
6756
|
-
var
|
|
7153
|
+
var import_wiki_graph_sdk6 = require("wiki-graph-sdk");
|
|
6757
7154
|
var import_fs3 = require("fs");
|
|
6758
7155
|
var import_path5 = require("path");
|
|
6759
7156
|
init_command();
|
|
@@ -6763,7 +7160,7 @@ init_support();
|
|
|
6763
7160
|
init_support();
|
|
6764
7161
|
|
|
6765
7162
|
// src/args/uri/chapter/target.ts
|
|
6766
|
-
var
|
|
7163
|
+
var import_wiki_graph_sdk5 = require("wiki-graph-sdk");
|
|
6767
7164
|
|
|
6768
7165
|
// src/args/uri/triple-pattern.ts
|
|
6769
7166
|
function parseTriplePatternObjectUri(objectUri) {
|
|
@@ -6910,7 +7307,7 @@ function parseChapterPathAndSuffix(value) {
|
|
|
6910
7307
|
);
|
|
6911
7308
|
const pathParts = suffixStart === -1 ? parts : parts.slice(0, suffixStart);
|
|
6912
7309
|
const suffixParts = suffixStart === -1 ? [] : parts.slice(suffixStart);
|
|
6913
|
-
const chapterPath = (0,
|
|
7310
|
+
const chapterPath = (0, import_wiki_graph_sdk5.parseChapterPath)(pathParts.join("/"), "chapter URI");
|
|
6914
7311
|
return {
|
|
6915
7312
|
chapterPath,
|
|
6916
7313
|
...suffixParts.length === 0 ? {} : { suffix: suffixParts.join("/") }
|
|
@@ -6978,6 +7375,7 @@ var URI_HELP_TARGETS = [
|
|
|
6978
7375
|
name: "archive-scope",
|
|
6979
7376
|
predicates: ["create", "export", "inspect"]
|
|
6980
7377
|
},
|
|
7378
|
+
{ name: "archive-title-object", predicates: ["clear", "set"] },
|
|
6981
7379
|
{ name: "artifact-object", predicates: [] },
|
|
6982
7380
|
{
|
|
6983
7381
|
name: "chapter-collection-scope",
|
|
@@ -7176,7 +7574,7 @@ function formatHelpCommandUri(uri) {
|
|
|
7176
7574
|
return formatShellArgument(uri);
|
|
7177
7575
|
}
|
|
7178
7576
|
function formatLibraryHelpUri(fallbackUri, target) {
|
|
7179
|
-
const scopeUri = (0,
|
|
7577
|
+
const scopeUri = (0, import_wiki_graph_sdk6.formatWikiGraphLibraryUri)(target.publicId);
|
|
7180
7578
|
switch (target.kind) {
|
|
7181
7579
|
case "archive":
|
|
7182
7580
|
if (target.archivePublicId === void 0) {
|
|
@@ -7249,7 +7647,7 @@ function requireUriHelpTarget(name) {
|
|
|
7249
7647
|
function getLibraryHelpContext(uri) {
|
|
7250
7648
|
const target = (() => {
|
|
7251
7649
|
try {
|
|
7252
|
-
return (0,
|
|
7650
|
+
return (0, import_wiki_graph_sdk6.parseWikiGraphLibraryUri)(uri);
|
|
7253
7651
|
} catch {
|
|
7254
7652
|
return void 0;
|
|
7255
7653
|
}
|
|
@@ -7276,7 +7674,7 @@ function getUriHelpContext(uri) {
|
|
|
7276
7674
|
}
|
|
7277
7675
|
function getHelpObjectUri(uri) {
|
|
7278
7676
|
try {
|
|
7279
|
-
const libraryTarget = (0,
|
|
7677
|
+
const libraryTarget = (0, import_wiki_graph_sdk6.parseWikiGraphLibraryUri)(uri);
|
|
7280
7678
|
if (libraryTarget?.objectUri !== void 0) {
|
|
7281
7679
|
return libraryTarget.objectUri;
|
|
7282
7680
|
}
|
|
@@ -7300,7 +7698,7 @@ function renderHelpTemplate(templateName, extraContext = {}) {
|
|
|
7300
7698
|
});
|
|
7301
7699
|
}
|
|
7302
7700
|
function getHelpTemplateEnvironment() {
|
|
7303
|
-
helpTemplateEnvironment ??= (0,
|
|
7701
|
+
helpTemplateEnvironment ??= (0, import_wiki_graph_sdk6.createNodeTemplateEnvironment)(
|
|
7304
7702
|
resolveCLIDataDirectory(),
|
|
7305
7703
|
{
|
|
7306
7704
|
autoescape: false
|
|
@@ -7333,7 +7731,7 @@ function resolveCLIDataDirectory() {
|
|
|
7333
7731
|
|
|
7334
7732
|
// src/args/archive.ts
|
|
7335
7733
|
init_support();
|
|
7336
|
-
var
|
|
7734
|
+
var import_wiki_graph_sdk10 = require("wiki-graph-sdk");
|
|
7337
7735
|
|
|
7338
7736
|
// src/args/helper/actions.ts
|
|
7339
7737
|
init_support();
|
|
@@ -7347,13 +7745,13 @@ function isArchiveMaintenanceCommand(value) {
|
|
|
7347
7745
|
}
|
|
7348
7746
|
|
|
7349
7747
|
// src/args/helper/chapter/ids.ts
|
|
7350
|
-
var
|
|
7748
|
+
var import_wiki_graph_sdk8 = require("wiki-graph-sdk");
|
|
7351
7749
|
init_support();
|
|
7352
7750
|
|
|
7353
7751
|
// src/args/helper/uri.ts
|
|
7354
7752
|
init_support();
|
|
7355
7753
|
init_local_config();
|
|
7356
|
-
var
|
|
7754
|
+
var import_wiki_graph_sdk7 = require("wiki-graph-sdk");
|
|
7357
7755
|
function validateArchiveCommandUriInput(action, value) {
|
|
7358
7756
|
if (action === "create" || action === "export" || action === "inspect" || action === "next") {
|
|
7359
7757
|
return;
|
|
@@ -7523,7 +7921,7 @@ function formatMissingArchiveInputMessage(action) {
|
|
|
7523
7921
|
}
|
|
7524
7922
|
}
|
|
7525
7923
|
function isWikiGraphUri(value) {
|
|
7526
|
-
return value?.startsWith(
|
|
7924
|
+
return value?.startsWith(import_wiki_graph_sdk7.WIKI_GRAPH_URI_PREFIX) === true;
|
|
7527
7925
|
}
|
|
7528
7926
|
function stripObjectUriPrefix(objectUri) {
|
|
7529
7927
|
const prefix = getWikiGraphUriPrefix(objectUri);
|
|
@@ -7586,8 +7984,8 @@ function parseWikiGraphJobTargetUri(uri) {
|
|
|
7586
7984
|
return jobId;
|
|
7587
7985
|
}
|
|
7588
7986
|
function getWikiGraphUriPrefix(uri) {
|
|
7589
|
-
if (uri.startsWith(
|
|
7590
|
-
return
|
|
7987
|
+
if (uri.startsWith(import_wiki_graph_sdk7.WIKI_GRAPH_URI_PREFIX)) {
|
|
7988
|
+
return import_wiki_graph_sdk7.WIKI_GRAPH_URI_PREFIX;
|
|
7591
7989
|
}
|
|
7592
7990
|
return void 0;
|
|
7593
7991
|
}
|
|
@@ -7613,7 +8011,7 @@ function parseWikiGraphPath(value) {
|
|
|
7613
8011
|
return void 0;
|
|
7614
8012
|
}
|
|
7615
8013
|
try {
|
|
7616
|
-
const parsed = (0,
|
|
8014
|
+
const parsed = (0, import_wiki_graph_sdk7.parseWikiGraphUriSyntax)(value);
|
|
7617
8015
|
return parsed.protocol === "wikg" ? parsed.path : void 0;
|
|
7618
8016
|
} catch {
|
|
7619
8017
|
return void 0;
|
|
@@ -7634,7 +8032,7 @@ function parseChapterPathRef(value, flag, archivePath, helpRoute) {
|
|
|
7634
8032
|
const normalized = value.trim();
|
|
7635
8033
|
try {
|
|
7636
8034
|
if (!isWikiGraphUri(normalized)) {
|
|
7637
|
-
return (0,
|
|
8035
|
+
return (0, import_wiki_graph_sdk8.parseChapterPath)(normalized, flag);
|
|
7638
8036
|
}
|
|
7639
8037
|
const parsed = parseLocatedWikiGraphUri(normalized);
|
|
7640
8038
|
if (parsed.archivePath !== void 0 && parsed.archivePath !== archivePath) {
|
|
@@ -7642,7 +8040,7 @@ function parseChapterPathRef(value, flag, archivePath, helpRoute) {
|
|
|
7642
8040
|
`Invalid ${flag}: ${value}. Chapter URI belongs to a different archive.`
|
|
7643
8041
|
);
|
|
7644
8042
|
}
|
|
7645
|
-
const path = (0,
|
|
8043
|
+
const path = (0, import_wiki_graph_sdk8.parseChapterUriPath)(parsed.objectUri ?? normalized);
|
|
7646
8044
|
if (path === void 0) {
|
|
7647
8045
|
throw new Error(
|
|
7648
8046
|
`Invalid ${flag}: ${value}. Expected a chapter path or URI.`
|
|
@@ -8272,7 +8670,7 @@ function parseBuildJobTarget(value) {
|
|
|
8272
8670
|
|
|
8273
8671
|
// src/args/helper/flags.ts
|
|
8274
8672
|
init_support();
|
|
8275
|
-
var
|
|
8673
|
+
var import_wiki_graph_sdk9 = require("wiki-graph-sdk");
|
|
8276
8674
|
function rejectArchiveChapterFlag(name, value, helpRoute) {
|
|
8277
8675
|
if (value !== void 0) {
|
|
8278
8676
|
throw new Error(
|
|
@@ -8312,7 +8710,7 @@ function rejectNonCreateReplaceFlag(positionals, values) {
|
|
|
8312
8710
|
return;
|
|
8313
8711
|
}
|
|
8314
8712
|
const [command, action] = positionals;
|
|
8315
|
-
if (command?.startsWith(
|
|
8713
|
+
if (command?.startsWith(import_wiki_graph_sdk9.WIKI_GRAPH_URI_PREFIX) === true && action === "create") {
|
|
8316
8714
|
return;
|
|
8317
8715
|
}
|
|
8318
8716
|
throw new Error(
|
|
@@ -8773,6 +9171,7 @@ function parseArchiveArguments(action, positionals, values, helpRoute = `wg ${ac
|
|
|
8773
9171
|
);
|
|
8774
9172
|
}
|
|
8775
9173
|
rejectNonQuerySkipUnindexedFlag(action, values, helpRoute);
|
|
9174
|
+
const queryMode = parseQueryModeFlag(values, helpRoute);
|
|
8776
9175
|
switch (action) {
|
|
8777
9176
|
case "create": {
|
|
8778
9177
|
rejectArchiveExtraPositionals(action, positionals, 1, helpRoute);
|
|
@@ -8950,6 +9349,7 @@ function parseArchiveArguments(action, positionals, values, helpRoute = `wg ${ac
|
|
|
8950
9349
|
)
|
|
8951
9350
|
},
|
|
8952
9351
|
query,
|
|
9352
|
+
...queryMode,
|
|
8953
9353
|
...values["skip-unindexed"] === true ? { skipUnindexed: true } : {},
|
|
8954
9354
|
...options.defaultKinds === void 0 ? {} : { kinds: options.defaultKinds },
|
|
8955
9355
|
...options.triplePattern === void 0 ? {} : { triplePattern: options.triplePattern }
|
|
@@ -9070,6 +9470,7 @@ function parseArchiveArguments(action, positionals, values, helpRoute = `wg ${ac
|
|
|
9070
9470
|
},
|
|
9071
9471
|
objectId: archivePath,
|
|
9072
9472
|
...values.query === void 0 ? {} : { query: values.query },
|
|
9473
|
+
...queryMode,
|
|
9073
9474
|
...values.reverse === true ? { reverse: true } : {},
|
|
9074
9475
|
...values["skip-unindexed"] === true ? { skipUnindexed: true } : {},
|
|
9075
9476
|
...relatedTarget === "entity" ? parseRelatedRoleFlag(values.role, helpRoute) : {}
|
|
@@ -9114,6 +9515,7 @@ function parseArchiveArguments(action, positionals, values, helpRoute = `wg ${ac
|
|
|
9114
9515
|
},
|
|
9115
9516
|
objectId: archivePath,
|
|
9116
9517
|
...values.query === void 0 ? {} : { query: values.query },
|
|
9518
|
+
...queryMode,
|
|
9117
9519
|
...values.reverse === true ? { reverse: true } : {},
|
|
9118
9520
|
...values["skip-unindexed"] === true ? { skipUnindexed: true } : {}
|
|
9119
9521
|
},
|
|
@@ -9212,17 +9614,35 @@ function rejectNonQuerySkipUnindexedFlag(action, values, helpRoute) {
|
|
|
9212
9614
|
helpRoute
|
|
9213
9615
|
);
|
|
9214
9616
|
}
|
|
9617
|
+
function parseQueryModeFlag(values, helpRoute) {
|
|
9618
|
+
const value = values["query-mode"];
|
|
9619
|
+
if (value === void 0) return {};
|
|
9620
|
+
if (values.query === void 0) {
|
|
9621
|
+
throw new Error(
|
|
9622
|
+
withHelpRoute("`--query-mode` requires `--query`.", helpRoute)
|
|
9623
|
+
);
|
|
9624
|
+
}
|
|
9625
|
+
if (value !== "hybrid" && value !== "fts" && value !== "embedding") {
|
|
9626
|
+
throw new Error(
|
|
9627
|
+
withHelpRoute(
|
|
9628
|
+
"--query-mode must be one of: hybrid, fts, embedding.",
|
|
9629
|
+
helpRoute
|
|
9630
|
+
)
|
|
9631
|
+
);
|
|
9632
|
+
}
|
|
9633
|
+
return { queryMode: value };
|
|
9634
|
+
}
|
|
9215
9635
|
|
|
9216
9636
|
// src/args/parse.ts
|
|
9217
9637
|
var import_util = require("util");
|
|
9218
|
-
var
|
|
9638
|
+
var import_wiki_graph_sdk14 = require("wiki-graph-sdk");
|
|
9219
9639
|
init_support();
|
|
9220
9640
|
|
|
9221
9641
|
// src/args/queue.ts
|
|
9222
9642
|
init_support();
|
|
9223
9643
|
|
|
9224
9644
|
// src/args/uri/chapter/routing.ts
|
|
9225
|
-
var
|
|
9645
|
+
var import_wiki_graph_sdk11 = require("wiki-graph-sdk");
|
|
9226
9646
|
init_support();
|
|
9227
9647
|
function parseArchiveChapterUriArguments(uri, archivePath, target, action, tail, values) {
|
|
9228
9648
|
const helpRoute = formatWikiGraphHelpCommand(uri, action);
|
|
@@ -9502,7 +9922,7 @@ function parseSingleChapterUriArguments(archivePath, chapterPath, action, tail,
|
|
|
9502
9922
|
case "list":
|
|
9503
9923
|
return parseArchiveArguments(
|
|
9504
9924
|
action,
|
|
9505
|
-
[(0,
|
|
9925
|
+
[(0, import_wiki_graph_sdk11.formatLocatedChapterUri)(archivePath, chapterPath), ...tail],
|
|
9506
9926
|
values,
|
|
9507
9927
|
helpRoute
|
|
9508
9928
|
);
|
|
@@ -9598,7 +10018,7 @@ function parseChapterResourceUriArguments(uri, archivePath, chapterPath, resourc
|
|
|
9598
10018
|
return parseArchiveArguments(
|
|
9599
10019
|
action,
|
|
9600
10020
|
[
|
|
9601
|
-
resource === "source" || resource === "summary" ? formatChapterScopedArchiveUri(archivePath, chapterPath) : (0,
|
|
10021
|
+
resource === "source" || resource === "summary" ? formatChapterScopedArchiveUri(archivePath, chapterPath) : (0, import_wiki_graph_sdk11.formatLocatedChapterUri)(archivePath, chapterPath),
|
|
9602
10022
|
...tail
|
|
9603
10023
|
],
|
|
9604
10024
|
values,
|
|
@@ -9631,7 +10051,7 @@ function parseChapterResourceUriArguments(uri, archivePath, chapterPath, resourc
|
|
|
9631
10051
|
);
|
|
9632
10052
|
}
|
|
9633
10053
|
if (action === "get") {
|
|
9634
|
-
const objectUri = uri.includes("#") && (resource === "source" || resource === "summary") ? uri : isLibraryArchiveLocator(archivePath) ? uri : resource === "source" ? (0,
|
|
10054
|
+
const objectUri = uri.includes("#") && (resource === "source" || resource === "summary") ? uri : isLibraryArchiveLocator(archivePath) ? uri : resource === "source" ? (0, import_wiki_graph_sdk11.formatLocatedChapterSourceCollectionUri)(archivePath, chapterPath) : (0, import_wiki_graph_sdk11.formatLocatedChapterResourceUri)(
|
|
9635
10055
|
archivePath,
|
|
9636
10056
|
chapterPath,
|
|
9637
10057
|
resource
|
|
@@ -9657,7 +10077,7 @@ function parseChapterResourceUriArguments(uri, archivePath, chapterPath, resourc
|
|
|
9657
10077
|
);
|
|
9658
10078
|
}
|
|
9659
10079
|
function formatChapterScopedArchiveUri(archivePath, chapterPath) {
|
|
9660
|
-
return isLibraryArchiveLocator(archivePath) ? `${archivePath}/chapter/${chapterPath}` : (0,
|
|
10080
|
+
return isLibraryArchiveLocator(archivePath) ? `${archivePath}/chapter/${chapterPath}` : (0, import_wiki_graph_sdk11.formatLocatedChapterUri)(archivePath, chapterPath);
|
|
9661
10081
|
}
|
|
9662
10082
|
function isLibraryArchiveLocator(archivePath) {
|
|
9663
10083
|
return archivePath.startsWith("wikg://lib/arc/") || /^wikg:\/\/lib\/[^/]+\/arc\//u.test(archivePath);
|
|
@@ -9709,7 +10129,7 @@ function parseArchiveChapterLikeArguments(action, archivePath, tail, values, hel
|
|
|
9709
10129
|
}
|
|
9710
10130
|
|
|
9711
10131
|
// src/args/uri/entry.ts
|
|
9712
|
-
var
|
|
10132
|
+
var import_wiki_graph_sdk12 = require("wiki-graph-sdk");
|
|
9713
10133
|
init_support();
|
|
9714
10134
|
|
|
9715
10135
|
// src/args/uri/archive-objects.ts
|
|
@@ -10099,6 +10519,9 @@ function classifyArchiveUriHelpTarget(uri) {
|
|
|
10099
10519
|
if (path === "index") {
|
|
10100
10520
|
return "index-object";
|
|
10101
10521
|
}
|
|
10522
|
+
if (path === "title") {
|
|
10523
|
+
return "archive-title-object";
|
|
10524
|
+
}
|
|
10102
10525
|
if (/^artifact\/[0-9a-f]{12,64}(?:#.+)?$/iu.test(path)) {
|
|
10103
10526
|
return "artifact-object";
|
|
10104
10527
|
}
|
|
@@ -10265,6 +10688,48 @@ function parseArchiveUriTargetArguments(uri, action, tail, values) {
|
|
|
10265
10688
|
if (objectUri === "wikg://index") {
|
|
10266
10689
|
return parseArchiveIndexUriArguments(archivePath, action, tail, values);
|
|
10267
10690
|
}
|
|
10691
|
+
if (objectUri === "wikg://title") {
|
|
10692
|
+
if (action === "get") {
|
|
10693
|
+
return parseArchiveArguments("get", [uri, ...tail], values, helpRoute);
|
|
10694
|
+
}
|
|
10695
|
+
if (action !== "set" && action !== "clear") {
|
|
10696
|
+
throw new Error(
|
|
10697
|
+
withHelpRoute(
|
|
10698
|
+
`The archive title resource does not support \`${action}\`. Read it directly, or use set or clear.`,
|
|
10699
|
+
"wg <archive-uri>/title --help"
|
|
10700
|
+
)
|
|
10701
|
+
);
|
|
10702
|
+
}
|
|
10703
|
+
const expected = action === "set" ? 1 : 0;
|
|
10704
|
+
if (tail.length !== expected) {
|
|
10705
|
+
throw new Error(
|
|
10706
|
+
withHelpRoute(
|
|
10707
|
+
action === "set" ? "Archive title set requires exactly one title value." : "Archive title clear does not accept a value.",
|
|
10708
|
+
helpRoute
|
|
10709
|
+
)
|
|
10710
|
+
);
|
|
10711
|
+
}
|
|
10712
|
+
const unsupported = Object.entries(values).find(
|
|
10713
|
+
([key, value]) => key !== "help" && value !== void 0 && value !== false
|
|
10714
|
+
);
|
|
10715
|
+
if (unsupported !== void 0) {
|
|
10716
|
+
throw new Error(
|
|
10717
|
+
withHelpRoute(
|
|
10718
|
+
`Archive title ${action} does not support --${unsupported[0]}.`,
|
|
10719
|
+
helpRoute
|
|
10720
|
+
)
|
|
10721
|
+
);
|
|
10722
|
+
}
|
|
10723
|
+
return {
|
|
10724
|
+
args: {
|
|
10725
|
+
action,
|
|
10726
|
+
archivePath,
|
|
10727
|
+
...tail[0] === void 0 ? {} : { title: tail[0] }
|
|
10728
|
+
},
|
|
10729
|
+
help: false,
|
|
10730
|
+
kind: "archive-title"
|
|
10731
|
+
};
|
|
10732
|
+
}
|
|
10268
10733
|
const chapterTarget = parseChapterTarget(objectUri);
|
|
10269
10734
|
if (chapterTarget !== void 0) {
|
|
10270
10735
|
return parseArchiveChapterUriArguments(
|
|
@@ -10305,7 +10770,7 @@ function parseArchiveUriTargetArguments(uri, action, tail, values) {
|
|
|
10305
10770
|
return parseArchiveArguments(action, [uri, ...tail], values, helpRoute);
|
|
10306
10771
|
}
|
|
10307
10772
|
function parseLibraryArchiveObjectTarget(uri) {
|
|
10308
|
-
const target = (0,
|
|
10773
|
+
const target = (0, import_wiki_graph_sdk12.parseWikiGraphLibraryUri)(uri);
|
|
10309
10774
|
if (target?.kind === "archive" && target.objectUri !== void 0) {
|
|
10310
10775
|
return target;
|
|
10311
10776
|
}
|
|
@@ -11158,9 +11623,9 @@ function parseTransformArguments(positionals, values) {
|
|
|
11158
11623
|
}
|
|
11159
11624
|
|
|
11160
11625
|
// src/args/uri/library.ts
|
|
11161
|
-
var
|
|
11626
|
+
var import_wiki_graph_sdk13 = require("wiki-graph-sdk");
|
|
11162
11627
|
init_support();
|
|
11163
|
-
var LIBRARY_ARCHIVE_ACTIONS = /* @__PURE__ */ new Set(["get", "remove"]);
|
|
11628
|
+
var LIBRARY_ARCHIVE_ACTIONS = /* @__PURE__ */ new Set(["get", "remove", "replace"]);
|
|
11164
11629
|
var LIBRARY_ARCHIVE_COLLECTION_ACTIONS = /* @__PURE__ */ new Set(["add", "get", "scan"]);
|
|
11165
11630
|
var LIBRARY_ARCHIVE_PATH_ACTIONS = /* @__PURE__ */ new Set(["get", "set"]);
|
|
11166
11631
|
var LIBRARY_ARCHIVE_TREE_ACTIONS = /* @__PURE__ */ new Set(["archive-tree"]);
|
|
@@ -11189,11 +11654,11 @@ function parseLibraryUriFirstArguments(positionals, values) {
|
|
|
11189
11654
|
if (uri === void 0) {
|
|
11190
11655
|
throw new Error("Internal error: missing library URI.");
|
|
11191
11656
|
}
|
|
11192
|
-
const target = (0,
|
|
11657
|
+
const target = (0, import_wiki_graph_sdk13.parseWikiGraphLibraryUri)(uri);
|
|
11193
11658
|
if (target === void 0) {
|
|
11194
11659
|
throw new Error(`Expected a Wiki Graph library URI: ${uri}`);
|
|
11195
11660
|
}
|
|
11196
|
-
const action = explicitAction ?? (target.kind === "scope" && (target.objectUri !== void 0 && target.objectUri !== "wikg://index" || values.query !== void 0 || values.limit !== void 0 || values.cursor !== void 0) ? resolveImplicitLibraryQueryAction(target.objectUri, values.query) : target.kind === "scope" || target.kind === "archive-collection" || target.kind === "metadata" || target.kind === "path" || target.kind === "archive" || target.kind === "archive-path" || target.objectUri === "wikg://index" ? "get" : target.kind === "archive-tree" ? "archive-tree" : "list");
|
|
11661
|
+
const action = explicitAction ?? ((target.kind === "scope" || target.kind === "archive-collection") && (target.kind === "scope" && target.objectUri !== void 0 && target.objectUri !== "wikg://index" || values.query !== void 0 || target.kind === "scope" && values.limit !== void 0 || target.kind === "scope" && values.cursor !== void 0) ? resolveImplicitLibraryQueryAction(target.objectUri, values.query) : target.kind === "scope" || target.kind === "archive-collection" || target.kind === "metadata" || target.kind === "path" || target.kind === "archive" || target.kind === "archive-path" || target.objectUri === "wikg://index" ? "get" : target.kind === "archive-tree" ? "archive-tree" : "list");
|
|
11197
11662
|
if (action === "inspect" && target.kind !== "archive") {
|
|
11198
11663
|
throw new Error(
|
|
11199
11664
|
withHelpRoute(
|
|
@@ -11246,6 +11711,15 @@ function parseLibraryUriFirstArguments(positionals, values) {
|
|
|
11246
11711
|
values
|
|
11247
11712
|
);
|
|
11248
11713
|
}
|
|
11714
|
+
if (target.kind === "archive-collection" && (action === "search" || values.query !== void 0)) {
|
|
11715
|
+
return parseLibraryQueryArguments(
|
|
11716
|
+
uri,
|
|
11717
|
+
target,
|
|
11718
|
+
action,
|
|
11719
|
+
explicitAction === void 0 ? [] : positionals.slice(2),
|
|
11720
|
+
values
|
|
11721
|
+
);
|
|
11722
|
+
}
|
|
11249
11723
|
if (target.kind === "archive-collection") {
|
|
11250
11724
|
return parseLibraryArchiveCollectionArguments(
|
|
11251
11725
|
uri,
|
|
@@ -11867,10 +12341,22 @@ function parseLibraryArchiveArguments(uri, target, action, tail, values) {
|
|
|
11867
12341
|
allowConfirm: action === "remove"
|
|
11868
12342
|
});
|
|
11869
12343
|
rejectArchiveFlag(action, "--path", values.path, helpRoute);
|
|
11870
|
-
rejectArchiveFlag(action, "--input", values.input, helpRoute);
|
|
11871
12344
|
rejectArchiveFlag(action, "--json-input", values["json-input"], helpRoute);
|
|
11872
12345
|
rejectArchiveBooleanFlag(action, "--jsonl", values.jsonl, helpRoute);
|
|
11873
12346
|
rejectExtraPositionals(action, tail, 0, helpRoute);
|
|
12347
|
+
if (action === "replace") {
|
|
12348
|
+
if (values.input === void 0) {
|
|
12349
|
+
throw new Error(withHelpRoute("Missing --input <path>.", helpRoute));
|
|
12350
|
+
}
|
|
12351
|
+
rejectArchiveFlag(action, "--to", values.to, helpRoute);
|
|
12352
|
+
rejectArchiveBooleanFlag(action, "--confirm", values.confirm, helpRoute);
|
|
12353
|
+
return {
|
|
12354
|
+
args: { action, inputPath: values.input, json: values.json, target },
|
|
12355
|
+
help: false,
|
|
12356
|
+
kind: "library"
|
|
12357
|
+
};
|
|
12358
|
+
}
|
|
12359
|
+
rejectArchiveFlag(action, "--input", values.input, helpRoute);
|
|
11874
12360
|
if (action === "get") {
|
|
11875
12361
|
rejectArchiveFlag(action, "--to", values.to, helpRoute);
|
|
11876
12362
|
rejectArchiveBooleanFlag(action, "--confirm", values.confirm, helpRoute);
|
|
@@ -11967,6 +12453,7 @@ function parseLibraryScopeArguments(uri, target, action, tail, values) {
|
|
|
11967
12453
|
case "add":
|
|
11968
12454
|
case "create":
|
|
11969
12455
|
case "rebind":
|
|
12456
|
+
case "replace":
|
|
11970
12457
|
case "scan":
|
|
11971
12458
|
throw new Error(
|
|
11972
12459
|
"Internal error: unsupported action routed to library scope."
|
|
@@ -12034,6 +12521,7 @@ function parseLibraryMetadataArguments(uri, target, action, tail, values) {
|
|
|
12034
12521
|
case "create":
|
|
12035
12522
|
case "list":
|
|
12036
12523
|
case "remove":
|
|
12524
|
+
case "replace":
|
|
12037
12525
|
case "add":
|
|
12038
12526
|
case "rebind":
|
|
12039
12527
|
case "clean-index":
|
|
@@ -12078,7 +12566,7 @@ function rejectExtraPositionals(action, positionals, expected, helpRoute) {
|
|
|
12078
12566
|
}
|
|
12079
12567
|
}
|
|
12080
12568
|
function isLibraryAction(action) {
|
|
12081
|
-
return action === "add" || action === "archive-tree" || action === "clear" || action === "clean-index" || action === "create" || action === "delete" || action === "get" || action === "get-index" || action === "list" || action === "put" || action === "rebind" || action === "remove" || action === "scan" || action === "set" || action === "sync-index";
|
|
12569
|
+
return action === "add" || action === "archive-tree" || action === "clear" || action === "clean-index" || action === "create" || action === "delete" || action === "get" || action === "get-index" || action === "list" || action === "put" || action === "rebind" || action === "replace" || action === "remove" || action === "scan" || action === "set" || action === "sync-index";
|
|
12082
12570
|
}
|
|
12083
12571
|
function validateTargetAction(uri, label, actions, action) {
|
|
12084
12572
|
if (!actions.has(action)) {
|
|
@@ -12313,6 +12801,9 @@ function parseCLIArguments(argv = process.argv.slice(2)) {
|
|
|
12313
12801
|
query: {
|
|
12314
12802
|
type: "string"
|
|
12315
12803
|
},
|
|
12804
|
+
"query-mode": {
|
|
12805
|
+
type: "string"
|
|
12806
|
+
},
|
|
12316
12807
|
replace: {
|
|
12317
12808
|
type: "boolean"
|
|
12318
12809
|
},
|
|
@@ -12454,7 +12945,7 @@ function parseCLIArguments(argv = process.argv.slice(2)) {
|
|
|
12454
12945
|
);
|
|
12455
12946
|
return parseLocalConfigUriFirstArguments(positionals, values);
|
|
12456
12947
|
}
|
|
12457
|
-
if ((0,
|
|
12948
|
+
if ((0, import_wiki_graph_sdk14.isWikiGraphLibraryUri)(positionals[0])) {
|
|
12458
12949
|
return parseLibraryUriFirstArguments(positionals, values);
|
|
12459
12950
|
}
|
|
12460
12951
|
if (isWikiGraphUri(positionals[0])) {
|
|
@@ -12484,7 +12975,7 @@ function rejectNonWikiGraphSkipUnindexedFlag(positionals, values) {
|
|
|
12484
12975
|
return;
|
|
12485
12976
|
}
|
|
12486
12977
|
const command = positionals[0];
|
|
12487
|
-
if (command !== void 0 && (isWikiGraphUri(command) || (0,
|
|
12978
|
+
if (command !== void 0 && (isWikiGraphUri(command) || (0, import_wiki_graph_sdk14.isWikiGraphLibraryUri)(command))) {
|
|
12488
12979
|
return;
|
|
12489
12980
|
}
|
|
12490
12981
|
throw new Error(
|
|
@@ -12500,6 +12991,10 @@ async function runArchiveCommand2(args) {
|
|
|
12500
12991
|
const command = await Promise.resolve().then(() => (init_archive_command(), archive_command_exports));
|
|
12501
12992
|
return command.runArchiveCommand(args);
|
|
12502
12993
|
}
|
|
12994
|
+
async function runArchiveTitleCommand2(args) {
|
|
12995
|
+
const command = await Promise.resolve().then(() => (init_archive_title(), archive_title_exports));
|
|
12996
|
+
return command.runArchiveTitleCommand(args);
|
|
12997
|
+
}
|
|
12503
12998
|
async function runArchiveChapterCommand2(args) {
|
|
12504
12999
|
const command = await Promise.resolve().then(() => (init_chapter(), chapter_exports));
|
|
12505
13000
|
return command.runArchiveChapterCommand(args);
|
|
@@ -12553,7 +13048,7 @@ async function runQueueCommand2(args) {
|
|
|
12553
13048
|
init_support();
|
|
12554
13049
|
init_support();
|
|
12555
13050
|
init_home_target();
|
|
12556
|
-
var
|
|
13051
|
+
var import_wiki_graph_sdk31 = require("wiki-graph-sdk");
|
|
12557
13052
|
init_context();
|
|
12558
13053
|
async function dispatchWikiGraphCLI(input) {
|
|
12559
13054
|
try {
|
|
@@ -12599,6 +13094,9 @@ async function dispatchWikiGraphCLI(input) {
|
|
|
12599
13094
|
case "archive":
|
|
12600
13095
|
await runArchiveCommand2(parsed.args);
|
|
12601
13096
|
return { exitCode: 0 };
|
|
13097
|
+
case "archive-title":
|
|
13098
|
+
await runArchiveTitleCommand2(parsed.args);
|
|
13099
|
+
return { exitCode: 0 };
|
|
12602
13100
|
case "archive-index":
|
|
12603
13101
|
await runArchiveIndexCommand2(parsed.args);
|
|
12604
13102
|
return { exitCode: 0 };
|
|
@@ -12640,10 +13138,10 @@ function shouldPrintDefaultHelp(argv, stdinIsTTY) {
|
|
|
12640
13138
|
return argv.length === 0 && stdinIsTTY === true;
|
|
12641
13139
|
}
|
|
12642
13140
|
function formatCLIError(error, argv) {
|
|
12643
|
-
if (error instanceof
|
|
13141
|
+
if (error instanceof import_wiki_graph_sdk31.LLMPaymentRequiredError) {
|
|
12644
13142
|
return "LLM payment required. Check your provider billing status or account balance.";
|
|
12645
13143
|
}
|
|
12646
|
-
const message = formatTerminalRemediation(error, (0,
|
|
13144
|
+
const message = formatTerminalRemediation(error, (0, import_wiki_graph_sdk31.formatError)(error));
|
|
12647
13145
|
const relativeResolution = hasErrorCode(error, "ENOENT") ? getRelativeArchiveUriResolution(argv[0] ?? "") : void 0;
|
|
12648
13146
|
if (relativeResolution === void 0) {
|
|
12649
13147
|
return message;
|
|
@@ -12656,7 +13154,7 @@ Resolved archive path:
|
|
|
12656
13154
|
See: wg help uri`;
|
|
12657
13155
|
}
|
|
12658
13156
|
function formatTerminalRemediation(error, message) {
|
|
12659
|
-
if (error instanceof
|
|
13157
|
+
if (error instanceof import_wiki_graph_sdk31.WikiGraphError) {
|
|
12660
13158
|
const chapterId = error.details.chapterId;
|
|
12661
13159
|
switch (error.code) {
|
|
12662
13160
|
case "chapter_has_children":
|
|
@@ -12700,7 +13198,7 @@ function createCLIErrorObject(error, argv) {
|
|
|
12700
13198
|
return {
|
|
12701
13199
|
error: {
|
|
12702
13200
|
message: formatCLIError(error, argv),
|
|
12703
|
-
type: error instanceof
|
|
13201
|
+
type: error instanceof import_wiki_graph_sdk31.LLMPaymentRequiredError ? "llm_payment_required" : "error"
|
|
12704
13202
|
}
|
|
12705
13203
|
};
|
|
12706
13204
|
}
|
|
@@ -12758,7 +13256,7 @@ async function runWikiGraphCLIWithEntryPolicy(input = {}, envPolicy) {
|
|
|
12758
13256
|
envPolicy: entryContext.envPolicy,
|
|
12759
13257
|
exitCode: 0,
|
|
12760
13258
|
queueAutostart: true,
|
|
12761
|
-
sdk: (0,
|
|
13259
|
+
sdk: (0, import_wiki_graph_sdk32.createWikiGraphSDK)({
|
|
12762
13260
|
cwd: input.cwd ?? process.cwd(),
|
|
12763
13261
|
env: entryContext.env,
|
|
12764
13262
|
envPolicy: entryContext.envPolicy,
|
|
@@ -12869,8 +13367,9 @@ var CaptureWritable = class extends import_stream2.Writable {
|
|
|
12869
13367
|
}
|
|
12870
13368
|
};
|
|
12871
13369
|
|
|
12872
|
-
// src/
|
|
12873
|
-
|
|
13370
|
+
// src/runtime/node-platform.ts
|
|
13371
|
+
var node_platform_exports = {};
|
|
13372
|
+
__reExport(node_platform_exports, require("wiki-graph-sdk/node-platform"));
|
|
12874
13373
|
// Annotate the CommonJS export names for ESM import in node:
|
|
12875
13374
|
0 && (module.exports = {
|
|
12876
13375
|
createWikiGraphCLI,
|