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.js
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
|
|
@@ -556,6 +557,30 @@ var init_version = __esm({
|
|
|
556
557
|
}
|
|
557
558
|
});
|
|
558
559
|
|
|
560
|
+
// src/support/archive-target.ts
|
|
561
|
+
import {
|
|
562
|
+
parseLocatedWikiGraphUri as parseLocatedWikiGraphUri2
|
|
563
|
+
} from "wiki-graph-sdk";
|
|
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 = parseLocatedWikiGraphUri2(locator);
|
|
572
|
+
return {
|
|
573
|
+
kind: "standalone",
|
|
574
|
+
path: parsed.archivePath ?? locator,
|
|
575
|
+
...parsed.objectUri === void 0 ? {} : { objectUri: parsed.objectUri }
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
var init_archive_target = __esm({
|
|
579
|
+
"src/support/archive-target.ts"() {
|
|
580
|
+
"use strict";
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
|
|
559
584
|
// src/support/index.ts
|
|
560
585
|
var init_support = __esm({
|
|
561
586
|
"src/support/index.ts"() {
|
|
@@ -569,6 +594,7 @@ var init_support = __esm({
|
|
|
569
594
|
init_uri();
|
|
570
595
|
init_version();
|
|
571
596
|
init_command();
|
|
597
|
+
init_archive_target();
|
|
572
598
|
}
|
|
573
599
|
});
|
|
574
600
|
|
|
@@ -1321,17 +1347,315 @@ var init_create = __esm({
|
|
|
1321
1347
|
});
|
|
1322
1348
|
|
|
1323
1349
|
// src/commands/archive-command/inspect.ts
|
|
1350
|
+
import {
|
|
1351
|
+
createGenerationPerformanceHints,
|
|
1352
|
+
DEFAULT_GENERATION_JOB_CONCURRENCY,
|
|
1353
|
+
DEFAULT_GENERATION_REQUEST_CONCURRENCY,
|
|
1354
|
+
formatGenerationPlanningModel,
|
|
1355
|
+
loadWikiGraphRuntimeConfig as loadWikiGraphRuntimeConfig2,
|
|
1356
|
+
planGenerationTask
|
|
1357
|
+
} from "wiki-graph-sdk";
|
|
1324
1358
|
async function writeArchiveInspectReport(args) {
|
|
1325
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
1359
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
1360
|
+
parseCLIArchiveTarget(args.archivePath)
|
|
1361
|
+
);
|
|
1326
1362
|
const report = toCLIInspectReport(
|
|
1327
|
-
await
|
|
1328
|
-
|
|
1329
|
-
|
|
1363
|
+
await createInspectReport(
|
|
1364
|
+
await archive.inspect({
|
|
1365
|
+
...args.chapterId === void 0 ? {} : { chapterId: args.chapterId }
|
|
1366
|
+
})
|
|
1367
|
+
)
|
|
1330
1368
|
);
|
|
1331
1369
|
await writeTextToStdout(
|
|
1332
1370
|
args.json === true ? formatCLIJSON(report) : formatArchiveInspectText(report)
|
|
1333
1371
|
);
|
|
1334
1372
|
}
|
|
1373
|
+
async function createInspectReport(inspection) {
|
|
1374
|
+
const config = await loadWikiGraphRuntimeConfig2();
|
|
1375
|
+
const chapters = inspection.chapters;
|
|
1376
|
+
const contentChapters = chapters.filter(
|
|
1377
|
+
({ chapter }) => chapter.stage !== "planned"
|
|
1378
|
+
);
|
|
1379
|
+
const readingGraphCovered = contentChapters.filter(
|
|
1380
|
+
({ capabilities }) => capabilities.readingGraph.completed
|
|
1381
|
+
);
|
|
1382
|
+
const knowledgeGraphCovered = contentChapters.filter(
|
|
1383
|
+
({ capabilities }) => capabilities.knowledgeGraph.completed
|
|
1384
|
+
);
|
|
1385
|
+
const summaryCovered = contentChapters.filter(
|
|
1386
|
+
({ capabilities }) => capabilities.readingSummary.completed
|
|
1387
|
+
);
|
|
1388
|
+
const ftsArtifactCovered = contentChapters.filter(
|
|
1389
|
+
({ indexes }) => indexes.fts.current
|
|
1390
|
+
);
|
|
1391
|
+
const sourceEmbeddingArtifactCovered = contentChapters.filter(
|
|
1392
|
+
({ indexes }) => indexes.sourceEmbedding.current
|
|
1393
|
+
);
|
|
1394
|
+
const summaryEmbeddingArtifactCovered = contentChapters.filter(
|
|
1395
|
+
({ indexes }) => indexes.summaryEmbedding.current
|
|
1396
|
+
);
|
|
1397
|
+
const queryBlockedChapters = contentChapters.filter(
|
|
1398
|
+
(chapter) => !ftsArtifactCovered.includes(chapter) && !sourceEmbeddingArtifactCovered.includes(chapter)
|
|
1399
|
+
);
|
|
1400
|
+
const queryReady = queryBlockedChapters.length === 0;
|
|
1401
|
+
const concurrent = {
|
|
1402
|
+
job: config.concurrent?.job ?? DEFAULT_GENERATION_JOB_CONCURRENCY,
|
|
1403
|
+
request: config.concurrent?.request ?? DEFAULT_GENERATION_REQUEST_CONCURRENCY
|
|
1404
|
+
};
|
|
1405
|
+
const improvements = createInspectImprovements({
|
|
1406
|
+
concurrent,
|
|
1407
|
+
contentChapters,
|
|
1408
|
+
indexCacheCurrent: inspection.localIndexCache.current,
|
|
1409
|
+
knowledgeGraphCovered,
|
|
1410
|
+
planningModel: formatGenerationPlanningModel(config.llm),
|
|
1411
|
+
queryBlockedChapters,
|
|
1412
|
+
readingGraphCovered,
|
|
1413
|
+
summaryCovered
|
|
1414
|
+
});
|
|
1415
|
+
const performanceHints = createGenerationPerformanceHints({
|
|
1416
|
+
chapters: Math.max(
|
|
1417
|
+
0,
|
|
1418
|
+
...improvements.map((improvement) => improvement.missingChapters ?? 0)
|
|
1419
|
+
),
|
|
1420
|
+
concurrent,
|
|
1421
|
+
hasJobWork: improvements.some(
|
|
1422
|
+
(improvement) => improvement.planning !== void 0
|
|
1423
|
+
),
|
|
1424
|
+
hasRequestWork: improvements.some(
|
|
1425
|
+
(improvement) => improvement.planning !== void 0
|
|
1426
|
+
)
|
|
1427
|
+
});
|
|
1428
|
+
const sourceWords = sumWords(contentChapters);
|
|
1429
|
+
const indexCacheCurrent = inspection.localIndexCache.current;
|
|
1430
|
+
return {
|
|
1431
|
+
archiveUri: inspection.archiveUri,
|
|
1432
|
+
content: {
|
|
1433
|
+
chapters: {
|
|
1434
|
+
content: contentChapters.length,
|
|
1435
|
+
planned: chapters.length - contentChapters.length,
|
|
1436
|
+
total: chapters.length
|
|
1437
|
+
},
|
|
1438
|
+
sourceWords,
|
|
1439
|
+
summaryWords: chapters.reduce(
|
|
1440
|
+
(total, chapter) => total + chapter.summaryWords,
|
|
1441
|
+
0
|
|
1442
|
+
)
|
|
1443
|
+
},
|
|
1444
|
+
coverage: {
|
|
1445
|
+
ftsIndexArtifact: createInspectCoverage(
|
|
1446
|
+
ftsArtifactCovered,
|
|
1447
|
+
contentChapters
|
|
1448
|
+
),
|
|
1449
|
+
knowledgeGraph: createInspectCoverage(
|
|
1450
|
+
knowledgeGraphCovered,
|
|
1451
|
+
contentChapters
|
|
1452
|
+
),
|
|
1453
|
+
readingGraph: createInspectCoverage(readingGraphCovered, contentChapters),
|
|
1454
|
+
sourceEmbeddingIndexArtifact: createInspectCoverage(
|
|
1455
|
+
sourceEmbeddingArtifactCovered,
|
|
1456
|
+
contentChapters
|
|
1457
|
+
),
|
|
1458
|
+
summary: createInspectCoverage(summaryCovered, contentChapters),
|
|
1459
|
+
summaryEmbeddingIndexArtifact: createInspectCoverage(
|
|
1460
|
+
summaryEmbeddingArtifactCovered,
|
|
1461
|
+
contentChapters
|
|
1462
|
+
)
|
|
1463
|
+
},
|
|
1464
|
+
improvements,
|
|
1465
|
+
localIndexCache: {
|
|
1466
|
+
current: indexCacheCurrent,
|
|
1467
|
+
...!queryReady ? {
|
|
1468
|
+
blockedBy: "missing-search-artifacts",
|
|
1469
|
+
impact: "The cache cannot be built until every content chapter has a current FTS or source embedding artifact."
|
|
1470
|
+
} : indexCacheCurrent ? {} : {
|
|
1471
|
+
impact: "The next archive query may need to sync index cache first.",
|
|
1472
|
+
resource: "local CPU/disk time only; no provider calls."
|
|
1473
|
+
},
|
|
1474
|
+
status: !queryReady ? "blocked" : indexCacheCurrent ? "current" : "missing-or-outdated",
|
|
1475
|
+
syncAvailable: queryReady && !indexCacheCurrent
|
|
1476
|
+
},
|
|
1477
|
+
performanceHints,
|
|
1478
|
+
query: { ready: queryReady },
|
|
1479
|
+
retrievalGuidance: formatRetrievalGuidance({
|
|
1480
|
+
contentChapters,
|
|
1481
|
+
indexCacheCurrent,
|
|
1482
|
+
knowledgeGraphCovered,
|
|
1483
|
+
queryReady,
|
|
1484
|
+
readingGraphCovered,
|
|
1485
|
+
sourceWords
|
|
1486
|
+
}),
|
|
1487
|
+
scope: inspection.scope,
|
|
1488
|
+
searchArtifacts: {
|
|
1489
|
+
blockedChapters: queryBlockedChapters.map(
|
|
1490
|
+
(item) => createInspectChapterReference(inspection.archiveUri, item)
|
|
1491
|
+
),
|
|
1492
|
+
...!queryReady ? { resource: "local CPU/disk time only; no provider calls." } : {},
|
|
1493
|
+
ready: queryReady,
|
|
1494
|
+
status: queryReady ? "ready" : "incomplete"
|
|
1495
|
+
},
|
|
1496
|
+
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.",
|
|
1497
|
+
uri: inspection.uri
|
|
1498
|
+
};
|
|
1499
|
+
}
|
|
1500
|
+
function createInspectChapterReference(archiveUri, inspection) {
|
|
1501
|
+
return {
|
|
1502
|
+
chapterId: inspection.chapter.chapterId,
|
|
1503
|
+
locatedUri: `${archiveUri.replace(/\/+$/u, "")}/${inspection.chapter.uri.replace(/^wikg:\/\//u, "")}`,
|
|
1504
|
+
title: inspection.chapter.title,
|
|
1505
|
+
uri: inspection.chapter.uri
|
|
1506
|
+
};
|
|
1507
|
+
}
|
|
1508
|
+
function createInspectCoverage(covered, total) {
|
|
1509
|
+
const coveredWords = sumWords(covered);
|
|
1510
|
+
const totalWords = sumWords(total);
|
|
1511
|
+
return {
|
|
1512
|
+
coveredChapters: covered.length,
|
|
1513
|
+
coveredWords,
|
|
1514
|
+
percent: formatPercent(coveredWords, totalWords),
|
|
1515
|
+
totalChapters: total.length,
|
|
1516
|
+
totalWords
|
|
1517
|
+
};
|
|
1518
|
+
}
|
|
1519
|
+
function createInspectImprovements(input) {
|
|
1520
|
+
if (input.contentChapters.length === 0) {
|
|
1521
|
+
return [
|
|
1522
|
+
{
|
|
1523
|
+
kind: "add-source",
|
|
1524
|
+
recommendation: "No source content is available yet; add or import source text before graph or summary generation.",
|
|
1525
|
+
title: "Add source content"
|
|
1526
|
+
}
|
|
1527
|
+
];
|
|
1528
|
+
}
|
|
1529
|
+
const improvements = [];
|
|
1530
|
+
if (input.queryBlockedChapters.length > 0) {
|
|
1531
|
+
improvements.push({
|
|
1532
|
+
kind: "build",
|
|
1533
|
+
missingChapters: input.queryBlockedChapters.length,
|
|
1534
|
+
missingWords: sumWords(input.queryBlockedChapters),
|
|
1535
|
+
recommendation: "Build local FTS artifacts to make this scope queryable. This does not call a provider.",
|
|
1536
|
+
task: "index-fts",
|
|
1537
|
+
title: "Enable query with local FTS"
|
|
1538
|
+
});
|
|
1539
|
+
} else if (!input.indexCacheCurrent) {
|
|
1540
|
+
improvements.push({
|
|
1541
|
+
kind: "sync-index",
|
|
1542
|
+
recommendation: "Sync the index cache from chapter index artifacts so query starts without a lazy cache rebuild.",
|
|
1543
|
+
title: "Sync index cache"
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1546
|
+
improvements.push(
|
|
1547
|
+
...createGraphImprovement({
|
|
1548
|
+
concurrent: input.concurrent,
|
|
1549
|
+
covered: input.readingGraphCovered,
|
|
1550
|
+
planningModel: input.planningModel,
|
|
1551
|
+
task: "reading-graph",
|
|
1552
|
+
title: "Complete Reading Graph coverage",
|
|
1553
|
+
total: input.contentChapters
|
|
1554
|
+
}),
|
|
1555
|
+
...createGraphImprovement({
|
|
1556
|
+
concurrent: input.concurrent,
|
|
1557
|
+
covered: input.knowledgeGraphCovered,
|
|
1558
|
+
planningModel: input.planningModel,
|
|
1559
|
+
task: "knowledge-graph",
|
|
1560
|
+
title: "Complete Knowledge Graph coverage",
|
|
1561
|
+
total: input.contentChapters
|
|
1562
|
+
}),
|
|
1563
|
+
...createGraphImprovement({
|
|
1564
|
+
concurrent: input.concurrent,
|
|
1565
|
+
covered: input.summaryCovered,
|
|
1566
|
+
planningModel: input.planningModel,
|
|
1567
|
+
task: "reading-summary",
|
|
1568
|
+
title: "Complete Summary coverage",
|
|
1569
|
+
total: input.contentChapters
|
|
1570
|
+
})
|
|
1571
|
+
);
|
|
1572
|
+
return improvements;
|
|
1573
|
+
}
|
|
1574
|
+
function createGraphImprovement(input) {
|
|
1575
|
+
const coveredIds = new Set(
|
|
1576
|
+
input.covered.map(({ chapter }) => chapter.chapterId)
|
|
1577
|
+
);
|
|
1578
|
+
const missing = input.total.filter(
|
|
1579
|
+
({ chapter }) => !coveredIds.has(chapter.chapterId)
|
|
1580
|
+
);
|
|
1581
|
+
if (missing.length === 0) return [];
|
|
1582
|
+
const missingWords = sumWords(missing);
|
|
1583
|
+
return [
|
|
1584
|
+
{
|
|
1585
|
+
kind: "build",
|
|
1586
|
+
missingChapters: missing.length,
|
|
1587
|
+
missingWords,
|
|
1588
|
+
planning: planGenerationTask(
|
|
1589
|
+
input.task,
|
|
1590
|
+
missingWords,
|
|
1591
|
+
missing.length,
|
|
1592
|
+
input.concurrent,
|
|
1593
|
+
input.planningModel
|
|
1594
|
+
),
|
|
1595
|
+
recommendation: formatImprovementRecommendation(
|
|
1596
|
+
input.covered,
|
|
1597
|
+
input.total,
|
|
1598
|
+
missingWords
|
|
1599
|
+
),
|
|
1600
|
+
task: input.task,
|
|
1601
|
+
title: input.title
|
|
1602
|
+
}
|
|
1603
|
+
];
|
|
1604
|
+
}
|
|
1605
|
+
function formatImprovementRecommendation(covered, total, missingWords) {
|
|
1606
|
+
const totalWords = sumWords(total);
|
|
1607
|
+
const coveredWords = sumWords(covered);
|
|
1608
|
+
if (totalWords === 0) return "No source content is available.";
|
|
1609
|
+
if (total.length === 1 || coveredWords / totalWords >= 0.9 || missingWords <= 1e3) {
|
|
1610
|
+
return "Queue the full scope to finish the remaining gap.";
|
|
1611
|
+
}
|
|
1612
|
+
return "Queue selected chapters first if only part of the scope matters.";
|
|
1613
|
+
}
|
|
1614
|
+
function formatRetrievalGuidance(input) {
|
|
1615
|
+
if (input.sourceWords === 0 || input.contentChapters.length === 0) {
|
|
1616
|
+
return [
|
|
1617
|
+
"Source content: empty.",
|
|
1618
|
+
"Add source text before using query coverage or graph-based retrieval."
|
|
1619
|
+
];
|
|
1620
|
+
}
|
|
1621
|
+
return [
|
|
1622
|
+
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.",
|
|
1623
|
+
formatObjectSearchGuidance(
|
|
1624
|
+
"Reading Graph object retrieval",
|
|
1625
|
+
input.readingGraphCovered,
|
|
1626
|
+
input.contentChapters
|
|
1627
|
+
),
|
|
1628
|
+
formatObjectSearchGuidance(
|
|
1629
|
+
"Entity/triple retrieval",
|
|
1630
|
+
input.knowledgeGraphCovered,
|
|
1631
|
+
input.contentChapters
|
|
1632
|
+
)
|
|
1633
|
+
];
|
|
1634
|
+
}
|
|
1635
|
+
function formatObjectSearchGuidance(label, covered, total) {
|
|
1636
|
+
const coveredWords = sumWords(covered);
|
|
1637
|
+
const totalWords = sumWords(total);
|
|
1638
|
+
const ratio = totalWords === 0 ? 0 : coveredWords / totalWords;
|
|
1639
|
+
const coverage = formatPercent(coveredWords, totalWords);
|
|
1640
|
+
if (ratio >= 1) {
|
|
1641
|
+
return `${label}: covers all source content; it can represent the full scope for object retrieval.`;
|
|
1642
|
+
}
|
|
1643
|
+
if (ratio >= 0.9) {
|
|
1644
|
+
return `${label}: covers ${coverage}; use it as the main path, but source --query is needed for uncovered content.`;
|
|
1645
|
+
}
|
|
1646
|
+
if (ratio >= 0.5) {
|
|
1647
|
+
return `${label}: covers ${coverage}; use it as leads, not as a full-scope substitute for source --query.`;
|
|
1648
|
+
}
|
|
1649
|
+
return `${label}: covers ${coverage}; build missing graph coverage before relying on object retrieval.`;
|
|
1650
|
+
}
|
|
1651
|
+
function sumWords(chapters) {
|
|
1652
|
+
return chapters.reduce((total, { chapter }) => total + chapter.words, 0);
|
|
1653
|
+
}
|
|
1654
|
+
function formatPercent(numerator, denominator) {
|
|
1655
|
+
if (denominator === 0) return "n/a";
|
|
1656
|
+
const percent = numerator / denominator * 100;
|
|
1657
|
+
return `${Number.isInteger(percent) ? percent.toFixed(0) : percent.toFixed(1)}%`;
|
|
1658
|
+
}
|
|
1335
1659
|
function toCLIInspectReport(report) {
|
|
1336
1660
|
const { archiveUri, summaryCoverageNote, ...base } = report;
|
|
1337
1661
|
return {
|
|
@@ -1493,6 +1817,7 @@ var init_inspect = __esm({
|
|
|
1493
1817
|
init_runtime();
|
|
1494
1818
|
init_context();
|
|
1495
1819
|
init_support();
|
|
1820
|
+
init_archive_target();
|
|
1496
1821
|
}
|
|
1497
1822
|
});
|
|
1498
1823
|
|
|
@@ -1645,7 +1970,7 @@ function toWikiGraphUri(id) {
|
|
|
1645
1970
|
case "fragment":
|
|
1646
1971
|
return `wikg://chapter/${first ?? ""}/source/${second ?? "0"}`;
|
|
1647
1972
|
case "meta":
|
|
1648
|
-
return "wikg://";
|
|
1973
|
+
return "wikg://meta";
|
|
1649
1974
|
case "node":
|
|
1650
1975
|
return `wikg://chunk/${first ?? ""}`;
|
|
1651
1976
|
case "summary":
|
|
@@ -1939,6 +2264,14 @@ function createObjectResultPage(objects, nextCursor, limit, warnings = []) {
|
|
|
1939
2264
|
async function createFindObject(hit, context) {
|
|
1940
2265
|
const uri = toWikiGraphUri(hit.id);
|
|
1941
2266
|
const librarySource = createLibrarySourceObject(hit);
|
|
2267
|
+
if (hit.type === "archive-title") {
|
|
2268
|
+
return {
|
|
2269
|
+
...librarySource,
|
|
2270
|
+
title: hit.title,
|
|
2271
|
+
type: "archive-title",
|
|
2272
|
+
uri
|
|
2273
|
+
};
|
|
2274
|
+
}
|
|
1942
2275
|
if (hit.type === "chapter") {
|
|
1943
2276
|
return {
|
|
1944
2277
|
...librarySource,
|
|
@@ -2086,6 +2419,13 @@ async function createPageObject(page, context) {
|
|
|
2086
2419
|
uri: toWikiGraphUri(page.id)
|
|
2087
2420
|
};
|
|
2088
2421
|
}
|
|
2422
|
+
case "archive-title":
|
|
2423
|
+
return {
|
|
2424
|
+
...librarySource,
|
|
2425
|
+
title: page.title,
|
|
2426
|
+
type: "archive-title",
|
|
2427
|
+
uri: toWikiGraphUri(page.id)
|
|
2428
|
+
};
|
|
2089
2429
|
case "chapter-title":
|
|
2090
2430
|
return {
|
|
2091
2431
|
...librarySource,
|
|
@@ -2275,6 +2615,7 @@ async function formatPackAnchor(anchor, context) {
|
|
|
2275
2615
|
switch (anchor.type) {
|
|
2276
2616
|
case "artifact":
|
|
2277
2617
|
return formatPlainObject(await createPageObject(anchor, context));
|
|
2618
|
+
case "archive-title":
|
|
2278
2619
|
case "chapter-title":
|
|
2279
2620
|
case "chapter":
|
|
2280
2621
|
return formatPlainObject(await createPageObject(anchor, context));
|
|
@@ -2809,6 +3150,7 @@ async function writePage(page, context, format) {
|
|
|
2809
3150
|
`
|
|
2810
3151
|
);
|
|
2811
3152
|
return;
|
|
3153
|
+
case "archive-title":
|
|
2812
3154
|
case "chapter-title":
|
|
2813
3155
|
await writeTextToStdout(
|
|
2814
3156
|
`${formatPlainObject(await createPageObject(page, context))}
|
|
@@ -3030,31 +3372,17 @@ var init_types2 = __esm({
|
|
|
3030
3372
|
});
|
|
3031
3373
|
|
|
3032
3374
|
// src/commands/archive-command/run/uri.ts
|
|
3033
|
-
import {
|
|
3034
|
-
|
|
3035
|
-
resolveWikiGraphArchiveLocation
|
|
3036
|
-
} from "wiki-graph-sdk";
|
|
3037
|
-
async function resolveArchiveRuntimeLocation(uriOrPath) {
|
|
3038
|
-
return await resolveWikiGraphArchiveLocation(uriOrPath);
|
|
3039
|
-
}
|
|
3040
|
-
async function resolveArchiveCommandRuntimeArguments(args) {
|
|
3375
|
+
import { parseWikiGraphLibraryUri as parseWikiGraphLibraryUri4 } from "wiki-graph-sdk";
|
|
3376
|
+
function resolveArchiveCommandRuntimeArguments(args) {
|
|
3041
3377
|
if (args.action === "create" || args.action === "export") {
|
|
3042
|
-
|
|
3043
|
-
return { ...args, archivePath: location2.archivePath };
|
|
3378
|
+
return { ...args, archivePath: getArchivePath(args.archivePath) };
|
|
3044
3379
|
}
|
|
3045
|
-
|
|
3046
|
-
if (!args.archivePath.startsWith("wikg://lib/")) {
|
|
3047
|
-
return args;
|
|
3048
|
-
}
|
|
3049
|
-
const location = await resolveArchiveRuntimeLocation(args.archivePath);
|
|
3050
|
-
return {
|
|
3051
|
-
...args,
|
|
3052
|
-
archivePath: location.locatedUri,
|
|
3053
|
-
...args.objectId === args.archivePath ? { objectId: location.locatedUri } : {}
|
|
3054
|
-
};
|
|
3380
|
+
return args;
|
|
3055
3381
|
}
|
|
3056
3382
|
function getArchivePath(uri) {
|
|
3057
|
-
if (
|
|
3383
|
+
if (!uri.includes("://")) return uri;
|
|
3384
|
+
const libraryTarget = parseWikiGraphLibraryUri4(uri);
|
|
3385
|
+
if (libraryTarget?.kind === "scope" || libraryTarget?.kind === "archive-collection") {
|
|
3058
3386
|
return uri;
|
|
3059
3387
|
}
|
|
3060
3388
|
const archivePath = parseLocatedWikiGraphUri(uri).archivePath;
|
|
@@ -3064,7 +3392,8 @@ function getArchivePath(uri) {
|
|
|
3064
3392
|
return archivePath;
|
|
3065
3393
|
}
|
|
3066
3394
|
function getArchiveIndexScope(uri) {
|
|
3067
|
-
|
|
3395
|
+
const libraryTarget = parseWikiGraphLibraryUri4(uri);
|
|
3396
|
+
if (libraryTarget?.kind === "scope" || libraryTarget?.kind === "archive-collection") {
|
|
3068
3397
|
return { kind: "library-index", libraryId: -1 };
|
|
3069
3398
|
}
|
|
3070
3399
|
const archivePath = getArchivePath(uri);
|
|
@@ -3094,7 +3423,7 @@ var init_uri3 = __esm({
|
|
|
3094
3423
|
|
|
3095
3424
|
// src/commands/archive-command/run/options.ts
|
|
3096
3425
|
import {
|
|
3097
|
-
parseLocatedWikiGraphUri as
|
|
3426
|
+
parseLocatedWikiGraphUri as parseLocatedWikiGraphUri3
|
|
3098
3427
|
} from "wiki-graph-sdk";
|
|
3099
3428
|
function createFindOptions(args) {
|
|
3100
3429
|
const types = args.kinds?.map((kind) => {
|
|
@@ -3112,6 +3441,7 @@ function createFindOptions(args) {
|
|
|
3112
3441
|
...createOptionalEvidenceLimit(args),
|
|
3113
3442
|
...args.limit === void 0 ? {} : { limit: args.limit },
|
|
3114
3443
|
...args.reverse === true ? { order: "doc-desc" } : {},
|
|
3444
|
+
...args.queryMode === void 0 ? {} : { queryMode: args.queryMode },
|
|
3115
3445
|
...args.skipUnindexed === true ? { skipUnindexed: true } : {},
|
|
3116
3446
|
...createOptionalSourceContext(args),
|
|
3117
3447
|
...args.triplePattern === void 0 ? {} : { triplePattern: args.triplePattern },
|
|
@@ -3133,6 +3463,7 @@ function createArchiveOutputContext(args, options = {}) {
|
|
|
3133
3463
|
...args.reverse === true ? { order: "doc-desc" } : {},
|
|
3134
3464
|
...args.action !== "evidence" && args.action !== "related" && args.action !== "search" ? {} : args.query === void 0 ? {} : { query: args.query },
|
|
3135
3465
|
...args.role === void 0 ? {} : { role: args.role },
|
|
3466
|
+
...args.queryMode === void 0 ? {} : { queryMode: args.queryMode },
|
|
3136
3467
|
...args.skipUnindexed === true ? { skipUnindexed: true } : {},
|
|
3137
3468
|
...options.continuationKind === "collection" ? createScopeOptions(args) : {},
|
|
3138
3469
|
...args.triplePattern === void 0 ? {} : { triplePattern: args.triplePattern },
|
|
@@ -3206,7 +3537,7 @@ function createScopeOptions(args) {
|
|
|
3206
3537
|
if (args.chapters !== void 0) {
|
|
3207
3538
|
return { chapters: args.chapters };
|
|
3208
3539
|
}
|
|
3209
|
-
const objectUri =
|
|
3540
|
+
const objectUri = parseLocatedWikiGraphUri3(args.archivePath).objectUri;
|
|
3210
3541
|
if (objectUri === void 0) {
|
|
3211
3542
|
return {};
|
|
3212
3543
|
}
|
|
@@ -3261,7 +3592,7 @@ var init_options = __esm({
|
|
|
3261
3592
|
async function runNextArchivePage(args) {
|
|
3262
3593
|
const cursorId = args.cursor ?? args.archivePath;
|
|
3263
3594
|
const page = await getWikiGraphSDK().continuations.next({
|
|
3264
|
-
...args.cursor === void 0 ? {} : { archive: args.archivePath },
|
|
3595
|
+
...args.cursor === void 0 ? {} : { archive: parseCLIArchiveTarget(args.archivePath) },
|
|
3265
3596
|
cursor: cursorId,
|
|
3266
3597
|
...args.format === void 0 ? {} : { format: args.format },
|
|
3267
3598
|
...args.limit === void 0 ? {} : { limit: args.limit }
|
|
@@ -3323,6 +3654,7 @@ function createCursorOutputContext(cursor, format, limit) {
|
|
|
3323
3654
|
targetUri: cursor.targetUri
|
|
3324
3655
|
} : {},
|
|
3325
3656
|
...cursor.kind === "related" && cursor.role !== void 0 ? { role: cursor.role } : {},
|
|
3657
|
+
...(cursor.kind === "search" || cursor.kind === "evidence" || cursor.kind === "related") && cursor.queryMode !== void 0 ? { queryMode: cursor.queryMode } : {},
|
|
3326
3658
|
...cursor.kind === "source-locators" ? { targetUri: cursor.targetUri } : {},
|
|
3327
3659
|
..."evidenceLimit" in cursor && cursor.evidenceLimit !== void 0 ? { evidenceLimit: cursor.evidenceLimit } : {},
|
|
3328
3660
|
..."sourceContext" in cursor && cursor.sourceContext !== void 0 ? { sourceContext: cursor.sourceContext } : {}
|
|
@@ -3331,6 +3663,7 @@ function createCursorOutputContext(cursor, format, limit) {
|
|
|
3331
3663
|
var init_next = __esm({
|
|
3332
3664
|
"src/commands/archive-command/run/next.ts"() {
|
|
3333
3665
|
"use strict";
|
|
3666
|
+
init_archive_target();
|
|
3334
3667
|
init_context();
|
|
3335
3668
|
init_archive_output();
|
|
3336
3669
|
init_options();
|
|
@@ -3381,11 +3714,11 @@ import {
|
|
|
3381
3714
|
} from "wiki-graph-sdk";
|
|
3382
3715
|
async function runArchiveCommand(args) {
|
|
3383
3716
|
const libraryTarget = parseWikiGraphLibraryUri5(args.archivePath);
|
|
3384
|
-
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")) {
|
|
3717
|
+
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") {
|
|
3385
3718
|
await runLibraryIndexArchiveCommand(args, libraryTarget);
|
|
3386
3719
|
return;
|
|
3387
3720
|
}
|
|
3388
|
-
args =
|
|
3721
|
+
args = resolveArchiveCommandRuntimeArguments(args);
|
|
3389
3722
|
switch (args.action) {
|
|
3390
3723
|
case "create":
|
|
3391
3724
|
await createArchive(args);
|
|
@@ -3430,7 +3763,9 @@ async function runArchiveCommand(args) {
|
|
|
3430
3763
|
return;
|
|
3431
3764
|
case "pack":
|
|
3432
3765
|
await writePack(
|
|
3433
|
-
await (await getWikiGraphSDK().archives.open(
|
|
3766
|
+
await (await getWikiGraphSDK().archives.open(
|
|
3767
|
+
parseCLIArchiveTarget(args.archivePath)
|
|
3768
|
+
)).pack(getObjectUri(args.objectId), args.budget ?? 5e3),
|
|
3434
3769
|
createArchiveOutputContext(args),
|
|
3435
3770
|
args.format ?? "text"
|
|
3436
3771
|
);
|
|
@@ -3438,7 +3773,9 @@ async function runArchiveCommand(args) {
|
|
|
3438
3773
|
}
|
|
3439
3774
|
}
|
|
3440
3775
|
async function runArchiveList(args) {
|
|
3441
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
3776
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
3777
|
+
parseCLIArchiveTarget(args.archivePath)
|
|
3778
|
+
);
|
|
3442
3779
|
const objectUri = getObjectUri(args.archivePath);
|
|
3443
3780
|
if (isSourceLocatorScopeUri(objectUri)) {
|
|
3444
3781
|
const context2 = createArchiveOutputContext(args, {
|
|
@@ -3507,7 +3844,9 @@ async function runArchiveList(args) {
|
|
|
3507
3844
|
);
|
|
3508
3845
|
}
|
|
3509
3846
|
async function runArchiveSearch(args) {
|
|
3510
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
3847
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
3848
|
+
parseCLIArchiveTarget(args.archivePath)
|
|
3849
|
+
);
|
|
3511
3850
|
const scope = await archive.resolveScope({
|
|
3512
3851
|
...args.depth === void 0 ? {} : { depth: args.depth }
|
|
3513
3852
|
});
|
|
@@ -3541,7 +3880,9 @@ async function runArchiveGet(args) {
|
|
|
3541
3880
|
const objectUri = getObjectUri(args.objectId);
|
|
3542
3881
|
const evidenceLimit = getSingleObjectEvidenceLimit(args, objectUri);
|
|
3543
3882
|
const context = evidenceLimit === void 0 ? createArchiveOutputContext(args) : createArchiveOutputContext({ ...args, evidenceLimit });
|
|
3544
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
3883
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
3884
|
+
parseCLIArchiveTarget(args.archivePath)
|
|
3885
|
+
);
|
|
3545
3886
|
await writePage(
|
|
3546
3887
|
await archive.page(objectUri, {
|
|
3547
3888
|
...args.backlinks === void 0 ? {} : { backlinks: args.backlinks },
|
|
@@ -3555,7 +3896,9 @@ async function runArchiveGet(args) {
|
|
|
3555
3896
|
}
|
|
3556
3897
|
async function runArchiveRelated(args) {
|
|
3557
3898
|
const objectUri = getObjectUri(args.objectId);
|
|
3558
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
3899
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
3900
|
+
parseCLIArchiveTarget(args.archivePath)
|
|
3901
|
+
);
|
|
3559
3902
|
const scope = await archive.resolveScope();
|
|
3560
3903
|
const context = createArchiveOutputContext(
|
|
3561
3904
|
scope === void 0 ? args : { ...args, chapters: scope.chapterIds },
|
|
@@ -3570,6 +3913,7 @@ async function runArchiveRelated(args) {
|
|
|
3570
3913
|
...args.limit === void 0 ? {} : { limit: args.limit },
|
|
3571
3914
|
...args.reverse === true ? { order: "doc-desc" } : {},
|
|
3572
3915
|
...args.query === void 0 ? {} : { query: args.query },
|
|
3916
|
+
...args.queryMode === void 0 ? {} : { queryMode: args.queryMode },
|
|
3573
3917
|
...args.role === void 0 ? {} : { role: args.role },
|
|
3574
3918
|
...args.skipUnindexed === true ? { skipUnindexed: true } : {},
|
|
3575
3919
|
...createOptionalSourceContext(args)
|
|
@@ -3587,7 +3931,9 @@ async function runArchiveRelated(args) {
|
|
|
3587
3931
|
}
|
|
3588
3932
|
async function runArchiveEvidence(args) {
|
|
3589
3933
|
const objectUri = getObjectUri(args.objectId);
|
|
3590
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
3934
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
3935
|
+
parseCLIArchiveTarget(args.archivePath)
|
|
3936
|
+
);
|
|
3591
3937
|
const scope = await archive.resolveScope();
|
|
3592
3938
|
const context = createArchiveOutputContext(
|
|
3593
3939
|
scope === void 0 ? args : { ...args, chapters: scope.chapterIds },
|
|
@@ -3601,6 +3947,7 @@ async function runArchiveEvidence(args) {
|
|
|
3601
3947
|
...args.limit === void 0 ? {} : { limit: args.limit },
|
|
3602
3948
|
...args.reverse === true ? { order: "doc-desc" } : {},
|
|
3603
3949
|
...args.query === void 0 ? {} : { query: args.query },
|
|
3950
|
+
...args.queryMode === void 0 ? {} : { queryMode: args.queryMode },
|
|
3604
3951
|
...args.skipUnindexed === true ? { skipUnindexed: true } : {},
|
|
3605
3952
|
...createOptionalSourceContext(args)
|
|
3606
3953
|
});
|
|
@@ -3648,8 +3995,9 @@ async function runLibraryIndexArchiveCommand(args, target) {
|
|
|
3648
3995
|
const library = await libraries.get(
|
|
3649
3996
|
formatWikiGraphLibraryUri2(target.publicId)
|
|
3650
3997
|
);
|
|
3651
|
-
const
|
|
3652
|
-
const
|
|
3998
|
+
const isArchiveMemberCollection = target.kind === "archive-collection";
|
|
3999
|
+
const isLibraryRootCollection = !isArchiveMemberCollection && target.objectUri === void 0 && args.objectId === void 0;
|
|
4000
|
+
const objectUri = isLibraryRootCollection ? void 0 : isArchiveMemberCollection ? void 0 : getObjectUri(args.objectId ?? args.archivePath);
|
|
3653
4001
|
const context = {
|
|
3654
4002
|
...createArchiveOutputContext(args),
|
|
3655
4003
|
archiveKey: args.archivePath,
|
|
@@ -3658,25 +4006,25 @@ async function runLibraryIndexArchiveCommand(args, target) {
|
|
|
3658
4006
|
kind: "library-index",
|
|
3659
4007
|
libraryId: library.snapshot.id
|
|
3660
4008
|
},
|
|
3661
|
-
libraryQuery: "objects"
|
|
4009
|
+
libraryQuery: isArchiveMemberCollection ? "archive-members" : "objects"
|
|
3662
4010
|
};
|
|
3663
4011
|
switch (args.action) {
|
|
3664
4012
|
case "search": {
|
|
3665
4013
|
const findOptions = createSearchFindOptions(args);
|
|
3666
4014
|
if (objectUri === void 0) {
|
|
4015
|
+
const search = async (cursor) => await (isArchiveMemberCollection ? libraries.searchArchiveMembers(target, args.query, {
|
|
4016
|
+
...findOptions,
|
|
4017
|
+
...cursor === void 0 ? {} : { cursor }
|
|
4018
|
+
}) : libraries.search(target, args.query, {
|
|
4019
|
+
...findOptions,
|
|
4020
|
+
...cursor === void 0 ? {} : { cursor }
|
|
4021
|
+
}));
|
|
3667
4022
|
if (args.all === true) {
|
|
3668
|
-
await writeAllFindHits(
|
|
3669
|
-
async (cursor) => await libraries.search(target, args.query, {
|
|
3670
|
-
...findOptions,
|
|
3671
|
-
...cursor === void 0 ? {} : { cursor }
|
|
3672
|
-
}),
|
|
3673
|
-
context,
|
|
3674
|
-
args.format ?? "text"
|
|
3675
|
-
);
|
|
4023
|
+
await writeAllFindHits(search, context, args.format ?? "text");
|
|
3676
4024
|
return;
|
|
3677
4025
|
}
|
|
3678
4026
|
await writeFindHits(
|
|
3679
|
-
await
|
|
4027
|
+
await search(args.cursor),
|
|
3680
4028
|
context,
|
|
3681
4029
|
args.format ?? "text"
|
|
3682
4030
|
);
|
|
@@ -3817,6 +4165,7 @@ async function runLibraryIndexArchiveCommand(args, target) {
|
|
|
3817
4165
|
...args.limit === void 0 ? {} : { limit: args.limit },
|
|
3818
4166
|
...args.reverse === true ? { order: "doc-desc" } : {},
|
|
3819
4167
|
...args.query === void 0 ? {} : { query: args.query },
|
|
4168
|
+
...args.queryMode === void 0 ? {} : { queryMode: args.queryMode },
|
|
3820
4169
|
...args.role === void 0 ? {} : { role: args.role },
|
|
3821
4170
|
...args.skipUnindexed === true ? { skipUnindexed: true } : {},
|
|
3822
4171
|
...createOptionalSourceContext(args)
|
|
@@ -3851,6 +4200,7 @@ async function runLibraryIndexArchiveCommand(args, target) {
|
|
|
3851
4200
|
...args.limit === void 0 ? {} : { limit: args.limit },
|
|
3852
4201
|
...args.reverse === true ? { order: "doc-desc" } : {},
|
|
3853
4202
|
...args.query === void 0 ? {} : { query: args.query },
|
|
4203
|
+
...args.queryMode === void 0 ? {} : { queryMode: args.queryMode },
|
|
3854
4204
|
...args.skipUnindexed === true ? { skipUnindexed: true } : {},
|
|
3855
4205
|
...createOptionalSourceContext(args)
|
|
3856
4206
|
}),
|
|
@@ -3866,6 +4216,7 @@ async function runLibraryIndexArchiveCommand(args, target) {
|
|
|
3866
4216
|
...args.limit === void 0 ? {} : { limit: args.limit },
|
|
3867
4217
|
...args.reverse === true ? { order: "doc-desc" } : {},
|
|
3868
4218
|
...args.query === void 0 ? {} : { query: args.query },
|
|
4219
|
+
...args.queryMode === void 0 ? {} : { queryMode: args.queryMode },
|
|
3869
4220
|
...args.skipUnindexed === true ? { skipUnindexed: true } : {},
|
|
3870
4221
|
...createOptionalSourceContext(args)
|
|
3871
4222
|
}),
|
|
@@ -3913,6 +4264,38 @@ var init_archive_command = __esm({
|
|
|
3913
4264
|
init_inspect();
|
|
3914
4265
|
init_archive_output();
|
|
3915
4266
|
init_run();
|
|
4267
|
+
init_archive_target();
|
|
4268
|
+
}
|
|
4269
|
+
});
|
|
4270
|
+
|
|
4271
|
+
// src/commands/archive-title.ts
|
|
4272
|
+
var archive_title_exports = {};
|
|
4273
|
+
__export(archive_title_exports, {
|
|
4274
|
+
runArchiveTitleCommand: () => runArchiveTitleCommand
|
|
4275
|
+
});
|
|
4276
|
+
async function runArchiveTitleCommand(args) {
|
|
4277
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
4278
|
+
parseCLIArchiveTarget(args.archivePath)
|
|
4279
|
+
);
|
|
4280
|
+
if (args.action === "clear") {
|
|
4281
|
+
await archive.setArchiveTitle(null);
|
|
4282
|
+
await writeTextToStdout("Cleared archive title.\n");
|
|
4283
|
+
return;
|
|
4284
|
+
}
|
|
4285
|
+
const title = args.title;
|
|
4286
|
+
if (title === void 0) {
|
|
4287
|
+
throw new Error("Missing archive title.");
|
|
4288
|
+
}
|
|
4289
|
+
const stored = await archive.setArchiveTitle(title);
|
|
4290
|
+
await writeTextToStdout(`${stored}
|
|
4291
|
+
`);
|
|
4292
|
+
}
|
|
4293
|
+
var init_archive_title = __esm({
|
|
4294
|
+
"src/commands/archive-title.ts"() {
|
|
4295
|
+
"use strict";
|
|
4296
|
+
init_context();
|
|
4297
|
+
init_archive_target();
|
|
4298
|
+
init_support();
|
|
3916
4299
|
}
|
|
3917
4300
|
});
|
|
3918
4301
|
|
|
@@ -4239,16 +4622,6 @@ var init_estimate = __esm({
|
|
|
4239
4622
|
}
|
|
4240
4623
|
});
|
|
4241
4624
|
|
|
4242
|
-
// src/runtime/node-platform.ts
|
|
4243
|
-
var node_platform_exports = {};
|
|
4244
|
-
import * as node_platform_star from "wiki-graph-sdk/node-platform";
|
|
4245
|
-
var init_node_platform = __esm({
|
|
4246
|
-
"src/runtime/node-platform.ts"() {
|
|
4247
|
-
"use strict";
|
|
4248
|
-
__reExport(node_platform_exports, node_platform_star);
|
|
4249
|
-
}
|
|
4250
|
-
});
|
|
4251
|
-
|
|
4252
4625
|
// src/commands/queue/output.ts
|
|
4253
4626
|
import {
|
|
4254
4627
|
formatLocatedChapterUri as formatLocatedChapterUri2
|
|
@@ -4500,26 +4873,23 @@ async function resolveJobChapter(job) {
|
|
|
4500
4873
|
}
|
|
4501
4874
|
function getJobResourcePath(job, resourceKey, legacyKey) {
|
|
4502
4875
|
const record = job;
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
const managedPath = getManagedJobResourcePath(resource);
|
|
4506
|
-
if (managedPath !== void 0) return managedPath;
|
|
4507
|
-
return (0, node_platform_exports.getNodeResourcePath)(resource);
|
|
4876
|
+
if (resourceKey === "archive") {
|
|
4877
|
+
return job.archive.kind === "library" ? job.archive.uri : job.archive.path;
|
|
4508
4878
|
}
|
|
4509
4879
|
const legacyPath = record[legacyKey];
|
|
4510
|
-
if (typeof legacyPath === "string")
|
|
4880
|
+
if (typeof legacyPath === "string") {
|
|
4881
|
+
return resolveManagedJobResourcePath(legacyPath) ?? legacyPath;
|
|
4882
|
+
}
|
|
4511
4883
|
return void 0;
|
|
4512
4884
|
}
|
|
4513
|
-
function
|
|
4514
|
-
if (
|
|
4515
|
-
|
|
4516
|
-
}
|
|
4517
|
-
const relativePath = resource.identity.slice("managed:library:".length);
|
|
4885
|
+
function resolveManagedJobResourcePath(identity) {
|
|
4886
|
+
if (!identity.startsWith("managed:library:")) return void 0;
|
|
4887
|
+
const relativePath = identity.slice("managed:library:".length);
|
|
4518
4888
|
const segments = relativePath.split("/");
|
|
4519
4889
|
if (relativePath === "" || segments.some(
|
|
4520
4890
|
(segment) => segment === "" || segment === "." || segment === ".." || segment.includes("\\")
|
|
4521
4891
|
)) {
|
|
4522
|
-
throw new TypeError(`Invalid managed job resource: ${
|
|
4892
|
+
throw new TypeError(`Invalid managed job resource: ${identity}`);
|
|
4523
4893
|
}
|
|
4524
4894
|
const environmentHome = getCLIEnvValue("HOME")?.trim();
|
|
4525
4895
|
const stateDirectory = getCLIStateDir() ?? join5(
|
|
@@ -4538,7 +4908,6 @@ var init_output = __esm({
|
|
|
4538
4908
|
"use strict";
|
|
4539
4909
|
init_support();
|
|
4540
4910
|
init_estimate();
|
|
4541
|
-
init_node_platform();
|
|
4542
4911
|
init_context();
|
|
4543
4912
|
}
|
|
4544
4913
|
});
|
|
@@ -4569,6 +4938,7 @@ var init_add = __esm({
|
|
|
4569
4938
|
init_internal_child();
|
|
4570
4939
|
init_estimate();
|
|
4571
4940
|
init_output();
|
|
4941
|
+
init_archive_target();
|
|
4572
4942
|
}
|
|
4573
4943
|
});
|
|
4574
4944
|
|
|
@@ -4585,7 +4955,7 @@ import {
|
|
|
4585
4955
|
} from "wiki-graph-sdk";
|
|
4586
4956
|
async function runArchiveChapterCommand(args) {
|
|
4587
4957
|
const sdk = getWikiGraphSDK();
|
|
4588
|
-
const archive = await sdk.archives.open(args.path);
|
|
4958
|
+
const archive = await sdk.archives.open(parseCLIArchiveTarget(args.path));
|
|
4589
4959
|
switch (args.action) {
|
|
4590
4960
|
case "add": {
|
|
4591
4961
|
const details = await archive.addChapter({
|
|
@@ -4615,7 +4985,7 @@ async function runArchiveChapterCommand(args) {
|
|
|
4615
4985
|
requireChapterPath2(args.chapterPath)
|
|
4616
4986
|
);
|
|
4617
4987
|
const job = await sdk.jobs.create({
|
|
4618
|
-
archive: archive.
|
|
4988
|
+
archive: archive.target,
|
|
4619
4989
|
chapterId: chapter.chapterId,
|
|
4620
4990
|
target: requireIndexArtifactTarget(args.indexArtifactTarget)
|
|
4621
4991
|
});
|
|
@@ -4929,6 +5299,7 @@ var init_chapter = __esm({
|
|
|
4929
5299
|
"use strict";
|
|
4930
5300
|
init_context();
|
|
4931
5301
|
init_support();
|
|
5302
|
+
init_archive_target();
|
|
4932
5303
|
init_support();
|
|
4933
5304
|
init_add();
|
|
4934
5305
|
init_output();
|
|
@@ -4954,11 +5325,15 @@ async function runArchiveIndexCommand(args) {
|
|
|
4954
5325
|
}
|
|
4955
5326
|
}
|
|
4956
5327
|
async function readIndexCache(args) {
|
|
4957
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
5328
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
5329
|
+
parseCLIArchiveTarget(args.archivePath)
|
|
5330
|
+
);
|
|
4958
5331
|
await writeIndexOutput(args, await archive.getSearchIndexStatus());
|
|
4959
5332
|
}
|
|
4960
5333
|
async function syncIndexCache(args) {
|
|
4961
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
5334
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
5335
|
+
parseCLIArchiveTarget(args.archivePath)
|
|
5336
|
+
);
|
|
4962
5337
|
const writer = new ProgressOutputWriter({
|
|
4963
5338
|
jsonl: args.jsonl ?? false,
|
|
4964
5339
|
throttleMs: INDEX_PROGRESS_OUTPUT_INTERVAL_MS
|
|
@@ -5007,7 +5382,9 @@ async function syncIndexCache(args) {
|
|
|
5007
5382
|
});
|
|
5008
5383
|
}
|
|
5009
5384
|
async function cleanIndexCache(args) {
|
|
5010
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
5385
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
5386
|
+
parseCLIArchiveTarget(args.archivePath)
|
|
5387
|
+
);
|
|
5011
5388
|
await writeIndexOutput(args, await archive.cleanSearchIndex());
|
|
5012
5389
|
}
|
|
5013
5390
|
function formatIndexCounter(input) {
|
|
@@ -5076,6 +5453,7 @@ var init_search_index = __esm({
|
|
|
5076
5453
|
"src/commands/archive-command/search-index.ts"() {
|
|
5077
5454
|
"use strict";
|
|
5078
5455
|
init_support();
|
|
5456
|
+
init_archive_target();
|
|
5079
5457
|
init_support();
|
|
5080
5458
|
init_runtime();
|
|
5081
5459
|
init_context();
|
|
@@ -5094,13 +5472,17 @@ async function runArchiveMetaCommand(args) {
|
|
|
5094
5472
|
await updateArchiveMeta(args.inputPath, args.metaPatch);
|
|
5095
5473
|
return;
|
|
5096
5474
|
}
|
|
5097
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
5475
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
5476
|
+
parseCLIArchiveTarget(args.inputPath)
|
|
5477
|
+
);
|
|
5098
5478
|
await writeArchiveMeta(await archive.readBookMeta(), {
|
|
5099
5479
|
json: args.json ?? false
|
|
5100
5480
|
});
|
|
5101
5481
|
}
|
|
5102
5482
|
async function runArchiveCoverCommand(args) {
|
|
5103
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
5483
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
5484
|
+
parseCLIArchiveTarget(args.inputPath)
|
|
5485
|
+
);
|
|
5104
5486
|
if (process.stdout.isTTY === true) {
|
|
5105
5487
|
throw new Error(
|
|
5106
5488
|
"Refusing to write binary cover data to an interactive terminal. Redirect stdout or pipe it."
|
|
@@ -5113,7 +5495,9 @@ async function runArchiveCoverCommand(args) {
|
|
|
5113
5495
|
await writeBinaryToStdout(cover.data);
|
|
5114
5496
|
}
|
|
5115
5497
|
async function updateArchiveMeta(path, patch) {
|
|
5116
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
5498
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
5499
|
+
parseCLIArchiveTarget(path)
|
|
5500
|
+
);
|
|
5117
5501
|
const meta = await archive.readBookMeta();
|
|
5118
5502
|
if (meta === void 0) {
|
|
5119
5503
|
throw new Error("Archive metadata is missing.");
|
|
@@ -5176,6 +5560,7 @@ var init_maintenance = __esm({
|
|
|
5176
5560
|
"src/commands/archive-command/maintenance.ts"() {
|
|
5177
5561
|
"use strict";
|
|
5178
5562
|
init_support();
|
|
5563
|
+
init_archive_target();
|
|
5179
5564
|
init_support();
|
|
5180
5565
|
init_context();
|
|
5181
5566
|
}
|
|
@@ -5814,6 +6199,20 @@ async function runLibraryCommand(args) {
|
|
|
5814
6199
|
);
|
|
5815
6200
|
return;
|
|
5816
6201
|
}
|
|
6202
|
+
case "replace": {
|
|
6203
|
+
if (args.inputPath === void 0) {
|
|
6204
|
+
throw new Error("Missing --input <path> for library archive replace.");
|
|
6205
|
+
}
|
|
6206
|
+
await writeLibraryArchive(
|
|
6207
|
+
await libraries.replaceArchive({
|
|
6208
|
+
inputPath: args.inputPath,
|
|
6209
|
+
target: args.target
|
|
6210
|
+
}),
|
|
6211
|
+
args.json ?? false,
|
|
6212
|
+
"Replaced library archive"
|
|
6213
|
+
);
|
|
6214
|
+
return;
|
|
6215
|
+
}
|
|
5817
6216
|
case "get": {
|
|
5818
6217
|
if (args.target.kind === "path") {
|
|
5819
6218
|
await writeLibraryPath(
|
|
@@ -5911,9 +6310,8 @@ async function writeLibrary(library, json) {
|
|
|
5911
6310
|
formatCLIJSON({
|
|
5912
6311
|
uri: library.uri,
|
|
5913
6312
|
id: library.publicId,
|
|
5914
|
-
folderPath:
|
|
6313
|
+
folderPath: library.folderPath,
|
|
5915
6314
|
isDefault: library.isDefault,
|
|
5916
|
-
stagingPath: (0, node_platform_exports.getNodeResourcePath)(library.staging),
|
|
5917
6315
|
createdAt: library.createdAt,
|
|
5918
6316
|
updatedAt: library.updatedAt
|
|
5919
6317
|
})
|
|
@@ -5930,7 +6328,7 @@ async function writeLibraries(libraries, json) {
|
|
|
5930
6328
|
items: libraries.map((library) => ({
|
|
5931
6329
|
uri: library.uri,
|
|
5932
6330
|
id: library.publicId,
|
|
5933
|
-
path:
|
|
6331
|
+
path: library.folderPath,
|
|
5934
6332
|
isDefault: library.isDefault
|
|
5935
6333
|
}))
|
|
5936
6334
|
})
|
|
@@ -5942,7 +6340,7 @@ async function writeLibraries(libraries, json) {
|
|
|
5942
6340
|
(library) => [
|
|
5943
6341
|
library.uri,
|
|
5944
6342
|
library.publicId,
|
|
5945
|
-
|
|
6343
|
+
library.folderPath,
|
|
5946
6344
|
library.isDefault ? "default" : ""
|
|
5947
6345
|
].join(" ")
|
|
5948
6346
|
).join("\n") + (libraries.length === 0 ? "" : "\n")
|
|
@@ -5953,12 +6351,12 @@ async function writeLibraryPath(library, json) {
|
|
|
5953
6351
|
await writeTextToStdout(
|
|
5954
6352
|
formatCLIJSON({
|
|
5955
6353
|
uri: `${library.uri}/path`,
|
|
5956
|
-
path:
|
|
6354
|
+
path: library.folderPath
|
|
5957
6355
|
})
|
|
5958
6356
|
);
|
|
5959
6357
|
return;
|
|
5960
6358
|
}
|
|
5961
|
-
await writeTextToStdout(`${
|
|
6359
|
+
await writeTextToStdout(`${library.folderPath}
|
|
5962
6360
|
`);
|
|
5963
6361
|
}
|
|
5964
6362
|
async function writeLibraryArchivePath(archive, json) {
|
|
@@ -6297,7 +6695,7 @@ function formatMetadataTextValue(value) {
|
|
|
6297
6695
|
return String(value);
|
|
6298
6696
|
}
|
|
6299
6697
|
function formatArchiveHostPath(archive) {
|
|
6300
|
-
return archive.
|
|
6698
|
+
return archive.relativePath;
|
|
6301
6699
|
}
|
|
6302
6700
|
var INDEX_PROGRESS_OUTPUT_INTERVAL_MS2;
|
|
6303
6701
|
var init_library = __esm({
|
|
@@ -6306,7 +6704,6 @@ var init_library = __esm({
|
|
|
6306
6704
|
init_context();
|
|
6307
6705
|
init_support();
|
|
6308
6706
|
init_run();
|
|
6309
|
-
init_node_platform();
|
|
6310
6707
|
init_archive_output();
|
|
6311
6708
|
init_runtime();
|
|
6312
6709
|
INDEX_PROGRESS_OUTPUT_INTERVAL_MS2 = 6e3;
|
|
@@ -6320,7 +6717,9 @@ __export(object_metadata_exports, {
|
|
|
6320
6717
|
});
|
|
6321
6718
|
import { readFile as readFile3 } from "fs/promises";
|
|
6322
6719
|
async function runObjectMetadataCommand(args) {
|
|
6323
|
-
const archive = await getWikiGraphSDK().archives.open(
|
|
6720
|
+
const archive = await getWikiGraphSDK().archives.open(
|
|
6721
|
+
parseCLIArchiveTarget(args.archivePath)
|
|
6722
|
+
);
|
|
6324
6723
|
switch (args.action) {
|
|
6325
6724
|
case "get": {
|
|
6326
6725
|
await writeMetadataMap2(
|
|
@@ -6449,6 +6848,7 @@ var init_object_metadata = __esm({
|
|
|
6449
6848
|
"use strict";
|
|
6450
6849
|
init_context();
|
|
6451
6850
|
init_support();
|
|
6851
|
+
init_archive_target();
|
|
6452
6852
|
init_support();
|
|
6453
6853
|
}
|
|
6454
6854
|
});
|
|
@@ -6681,7 +7081,7 @@ async function runQueueCommand(args) {
|
|
|
6681
7081
|
(await getWikiGraphSDK().jobs.list({
|
|
6682
7082
|
...args.activeOnly === void 0 ? {} : { activeOnly: args.activeOnly },
|
|
6683
7083
|
...args.all === void 0 ? {} : { all: args.all },
|
|
6684
|
-
...args.archivePath === void 0 ? {} : { archive:
|
|
7084
|
+
...args.archivePath === void 0 ? {} : { archive: parseCLIArchiveTarget(args.archivePath) }
|
|
6685
7085
|
})).map((job) => job.snapshot),
|
|
6686
7086
|
{ json: args.json ?? false }
|
|
6687
7087
|
);
|
|
@@ -6733,7 +7133,7 @@ async function getQueueJob(args) {
|
|
|
6733
7133
|
}
|
|
6734
7134
|
function createEnqueueOptions(args) {
|
|
6735
7135
|
return {
|
|
6736
|
-
archive: args.archivePath,
|
|
7136
|
+
archive: parseCLIArchiveTarget(args.archivePath),
|
|
6737
7137
|
...args.boost === void 0 ? {} : { boost: args.boost },
|
|
6738
7138
|
...args.chapterId === void 0 ? {} : { chapterId: args.chapterId },
|
|
6739
7139
|
...args.chapterIds === void 0 ? {} : { chapterIds: args.chapterIds },
|
|
@@ -6750,11 +7150,11 @@ var init_queue = __esm({
|
|
|
6750
7150
|
init_config();
|
|
6751
7151
|
init_context();
|
|
6752
7152
|
init_support();
|
|
7153
|
+
init_archive_target();
|
|
6753
7154
|
init_add();
|
|
6754
7155
|
init_estimate();
|
|
6755
7156
|
init_output();
|
|
6756
7157
|
init_watch();
|
|
6757
|
-
init_node_platform();
|
|
6758
7158
|
init_worker();
|
|
6759
7159
|
}
|
|
6760
7160
|
});
|
|
@@ -6995,6 +7395,7 @@ var URI_HELP_TARGETS = [
|
|
|
6995
7395
|
name: "archive-scope",
|
|
6996
7396
|
predicates: ["create", "export", "inspect"]
|
|
6997
7397
|
},
|
|
7398
|
+
{ name: "archive-title-object", predicates: ["clear", "set"] },
|
|
6998
7399
|
{ name: "artifact-object", predicates: [] },
|
|
6999
7400
|
{
|
|
7000
7401
|
name: "chapter-collection-scope",
|
|
@@ -8790,6 +9191,7 @@ function parseArchiveArguments(action, positionals, values, helpRoute = `wg ${ac
|
|
|
8790
9191
|
);
|
|
8791
9192
|
}
|
|
8792
9193
|
rejectNonQuerySkipUnindexedFlag(action, values, helpRoute);
|
|
9194
|
+
const queryMode = parseQueryModeFlag(values, helpRoute);
|
|
8793
9195
|
switch (action) {
|
|
8794
9196
|
case "create": {
|
|
8795
9197
|
rejectArchiveExtraPositionals(action, positionals, 1, helpRoute);
|
|
@@ -8967,6 +9369,7 @@ function parseArchiveArguments(action, positionals, values, helpRoute = `wg ${ac
|
|
|
8967
9369
|
)
|
|
8968
9370
|
},
|
|
8969
9371
|
query,
|
|
9372
|
+
...queryMode,
|
|
8970
9373
|
...values["skip-unindexed"] === true ? { skipUnindexed: true } : {},
|
|
8971
9374
|
...options.defaultKinds === void 0 ? {} : { kinds: options.defaultKinds },
|
|
8972
9375
|
...options.triplePattern === void 0 ? {} : { triplePattern: options.triplePattern }
|
|
@@ -9087,6 +9490,7 @@ function parseArchiveArguments(action, positionals, values, helpRoute = `wg ${ac
|
|
|
9087
9490
|
},
|
|
9088
9491
|
objectId: archivePath,
|
|
9089
9492
|
...values.query === void 0 ? {} : { query: values.query },
|
|
9493
|
+
...queryMode,
|
|
9090
9494
|
...values.reverse === true ? { reverse: true } : {},
|
|
9091
9495
|
...values["skip-unindexed"] === true ? { skipUnindexed: true } : {},
|
|
9092
9496
|
...relatedTarget === "entity" ? parseRelatedRoleFlag(values.role, helpRoute) : {}
|
|
@@ -9131,6 +9535,7 @@ function parseArchiveArguments(action, positionals, values, helpRoute = `wg ${ac
|
|
|
9131
9535
|
},
|
|
9132
9536
|
objectId: archivePath,
|
|
9133
9537
|
...values.query === void 0 ? {} : { query: values.query },
|
|
9538
|
+
...queryMode,
|
|
9134
9539
|
...values.reverse === true ? { reverse: true } : {},
|
|
9135
9540
|
...values["skip-unindexed"] === true ? { skipUnindexed: true } : {}
|
|
9136
9541
|
},
|
|
@@ -9229,6 +9634,24 @@ function rejectNonQuerySkipUnindexedFlag(action, values, helpRoute) {
|
|
|
9229
9634
|
helpRoute
|
|
9230
9635
|
);
|
|
9231
9636
|
}
|
|
9637
|
+
function parseQueryModeFlag(values, helpRoute) {
|
|
9638
|
+
const value = values["query-mode"];
|
|
9639
|
+
if (value === void 0) return {};
|
|
9640
|
+
if (values.query === void 0) {
|
|
9641
|
+
throw new Error(
|
|
9642
|
+
withHelpRoute("`--query-mode` requires `--query`.", helpRoute)
|
|
9643
|
+
);
|
|
9644
|
+
}
|
|
9645
|
+
if (value !== "hybrid" && value !== "fts" && value !== "embedding") {
|
|
9646
|
+
throw new Error(
|
|
9647
|
+
withHelpRoute(
|
|
9648
|
+
"--query-mode must be one of: hybrid, fts, embedding.",
|
|
9649
|
+
helpRoute
|
|
9650
|
+
)
|
|
9651
|
+
);
|
|
9652
|
+
}
|
|
9653
|
+
return { queryMode: value };
|
|
9654
|
+
}
|
|
9232
9655
|
|
|
9233
9656
|
// src/args/parse.ts
|
|
9234
9657
|
import { parseArgs } from "util";
|
|
@@ -10122,6 +10545,9 @@ function classifyArchiveUriHelpTarget(uri) {
|
|
|
10122
10545
|
if (path === "index") {
|
|
10123
10546
|
return "index-object";
|
|
10124
10547
|
}
|
|
10548
|
+
if (path === "title") {
|
|
10549
|
+
return "archive-title-object";
|
|
10550
|
+
}
|
|
10125
10551
|
if (/^artifact\/[0-9a-f]{12,64}(?:#.+)?$/iu.test(path)) {
|
|
10126
10552
|
return "artifact-object";
|
|
10127
10553
|
}
|
|
@@ -10288,6 +10714,48 @@ function parseArchiveUriTargetArguments(uri, action, tail, values) {
|
|
|
10288
10714
|
if (objectUri === "wikg://index") {
|
|
10289
10715
|
return parseArchiveIndexUriArguments(archivePath, action, tail, values);
|
|
10290
10716
|
}
|
|
10717
|
+
if (objectUri === "wikg://title") {
|
|
10718
|
+
if (action === "get") {
|
|
10719
|
+
return parseArchiveArguments("get", [uri, ...tail], values, helpRoute);
|
|
10720
|
+
}
|
|
10721
|
+
if (action !== "set" && action !== "clear") {
|
|
10722
|
+
throw new Error(
|
|
10723
|
+
withHelpRoute(
|
|
10724
|
+
`The archive title resource does not support \`${action}\`. Read it directly, or use set or clear.`,
|
|
10725
|
+
"wg <archive-uri>/title --help"
|
|
10726
|
+
)
|
|
10727
|
+
);
|
|
10728
|
+
}
|
|
10729
|
+
const expected = action === "set" ? 1 : 0;
|
|
10730
|
+
if (tail.length !== expected) {
|
|
10731
|
+
throw new Error(
|
|
10732
|
+
withHelpRoute(
|
|
10733
|
+
action === "set" ? "Archive title set requires exactly one title value." : "Archive title clear does not accept a value.",
|
|
10734
|
+
helpRoute
|
|
10735
|
+
)
|
|
10736
|
+
);
|
|
10737
|
+
}
|
|
10738
|
+
const unsupported = Object.entries(values).find(
|
|
10739
|
+
([key, value]) => key !== "help" && value !== void 0 && value !== false
|
|
10740
|
+
);
|
|
10741
|
+
if (unsupported !== void 0) {
|
|
10742
|
+
throw new Error(
|
|
10743
|
+
withHelpRoute(
|
|
10744
|
+
`Archive title ${action} does not support --${unsupported[0]}.`,
|
|
10745
|
+
helpRoute
|
|
10746
|
+
)
|
|
10747
|
+
);
|
|
10748
|
+
}
|
|
10749
|
+
return {
|
|
10750
|
+
args: {
|
|
10751
|
+
action,
|
|
10752
|
+
archivePath,
|
|
10753
|
+
...tail[0] === void 0 ? {} : { title: tail[0] }
|
|
10754
|
+
},
|
|
10755
|
+
help: false,
|
|
10756
|
+
kind: "archive-title"
|
|
10757
|
+
};
|
|
10758
|
+
}
|
|
10291
10759
|
const chapterTarget = parseChapterTarget(objectUri);
|
|
10292
10760
|
if (chapterTarget !== void 0) {
|
|
10293
10761
|
return parseArchiveChapterUriArguments(
|
|
@@ -11185,7 +11653,7 @@ init_support();
|
|
|
11185
11653
|
import {
|
|
11186
11654
|
parseWikiGraphLibraryUri as parseWikiGraphLibraryUri3
|
|
11187
11655
|
} from "wiki-graph-sdk";
|
|
11188
|
-
var LIBRARY_ARCHIVE_ACTIONS = /* @__PURE__ */ new Set(["get", "remove"]);
|
|
11656
|
+
var LIBRARY_ARCHIVE_ACTIONS = /* @__PURE__ */ new Set(["get", "remove", "replace"]);
|
|
11189
11657
|
var LIBRARY_ARCHIVE_COLLECTION_ACTIONS = /* @__PURE__ */ new Set(["add", "get", "scan"]);
|
|
11190
11658
|
var LIBRARY_ARCHIVE_PATH_ACTIONS = /* @__PURE__ */ new Set(["get", "set"]);
|
|
11191
11659
|
var LIBRARY_ARCHIVE_TREE_ACTIONS = /* @__PURE__ */ new Set(["archive-tree"]);
|
|
@@ -11218,7 +11686,7 @@ function parseLibraryUriFirstArguments(positionals, values) {
|
|
|
11218
11686
|
if (target === void 0) {
|
|
11219
11687
|
throw new Error(`Expected a Wiki Graph library URI: ${uri}`);
|
|
11220
11688
|
}
|
|
11221
|
-
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");
|
|
11689
|
+
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");
|
|
11222
11690
|
if (action === "inspect" && target.kind !== "archive") {
|
|
11223
11691
|
throw new Error(
|
|
11224
11692
|
withHelpRoute(
|
|
@@ -11271,6 +11739,15 @@ function parseLibraryUriFirstArguments(positionals, values) {
|
|
|
11271
11739
|
values
|
|
11272
11740
|
);
|
|
11273
11741
|
}
|
|
11742
|
+
if (target.kind === "archive-collection" && (action === "search" || values.query !== void 0)) {
|
|
11743
|
+
return parseLibraryQueryArguments(
|
|
11744
|
+
uri,
|
|
11745
|
+
target,
|
|
11746
|
+
action,
|
|
11747
|
+
explicitAction === void 0 ? [] : positionals.slice(2),
|
|
11748
|
+
values
|
|
11749
|
+
);
|
|
11750
|
+
}
|
|
11274
11751
|
if (target.kind === "archive-collection") {
|
|
11275
11752
|
return parseLibraryArchiveCollectionArguments(
|
|
11276
11753
|
uri,
|
|
@@ -11892,10 +12369,22 @@ function parseLibraryArchiveArguments(uri, target, action, tail, values) {
|
|
|
11892
12369
|
allowConfirm: action === "remove"
|
|
11893
12370
|
});
|
|
11894
12371
|
rejectArchiveFlag(action, "--path", values.path, helpRoute);
|
|
11895
|
-
rejectArchiveFlag(action, "--input", values.input, helpRoute);
|
|
11896
12372
|
rejectArchiveFlag(action, "--json-input", values["json-input"], helpRoute);
|
|
11897
12373
|
rejectArchiveBooleanFlag(action, "--jsonl", values.jsonl, helpRoute);
|
|
11898
12374
|
rejectExtraPositionals(action, tail, 0, helpRoute);
|
|
12375
|
+
if (action === "replace") {
|
|
12376
|
+
if (values.input === void 0) {
|
|
12377
|
+
throw new Error(withHelpRoute("Missing --input <path>.", helpRoute));
|
|
12378
|
+
}
|
|
12379
|
+
rejectArchiveFlag(action, "--to", values.to, helpRoute);
|
|
12380
|
+
rejectArchiveBooleanFlag(action, "--confirm", values.confirm, helpRoute);
|
|
12381
|
+
return {
|
|
12382
|
+
args: { action, inputPath: values.input, json: values.json, target },
|
|
12383
|
+
help: false,
|
|
12384
|
+
kind: "library"
|
|
12385
|
+
};
|
|
12386
|
+
}
|
|
12387
|
+
rejectArchiveFlag(action, "--input", values.input, helpRoute);
|
|
11899
12388
|
if (action === "get") {
|
|
11900
12389
|
rejectArchiveFlag(action, "--to", values.to, helpRoute);
|
|
11901
12390
|
rejectArchiveBooleanFlag(action, "--confirm", values.confirm, helpRoute);
|
|
@@ -11992,6 +12481,7 @@ function parseLibraryScopeArguments(uri, target, action, tail, values) {
|
|
|
11992
12481
|
case "add":
|
|
11993
12482
|
case "create":
|
|
11994
12483
|
case "rebind":
|
|
12484
|
+
case "replace":
|
|
11995
12485
|
case "scan":
|
|
11996
12486
|
throw new Error(
|
|
11997
12487
|
"Internal error: unsupported action routed to library scope."
|
|
@@ -12059,6 +12549,7 @@ function parseLibraryMetadataArguments(uri, target, action, tail, values) {
|
|
|
12059
12549
|
case "create":
|
|
12060
12550
|
case "list":
|
|
12061
12551
|
case "remove":
|
|
12552
|
+
case "replace":
|
|
12062
12553
|
case "add":
|
|
12063
12554
|
case "rebind":
|
|
12064
12555
|
case "clean-index":
|
|
@@ -12103,7 +12594,7 @@ function rejectExtraPositionals(action, positionals, expected, helpRoute) {
|
|
|
12103
12594
|
}
|
|
12104
12595
|
}
|
|
12105
12596
|
function isLibraryAction(action) {
|
|
12106
|
-
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";
|
|
12597
|
+
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";
|
|
12107
12598
|
}
|
|
12108
12599
|
function validateTargetAction(uri, label, actions, action) {
|
|
12109
12600
|
if (!actions.has(action)) {
|
|
@@ -12338,6 +12829,9 @@ function parseCLIArguments(argv = process.argv.slice(2)) {
|
|
|
12338
12829
|
query: {
|
|
12339
12830
|
type: "string"
|
|
12340
12831
|
},
|
|
12832
|
+
"query-mode": {
|
|
12833
|
+
type: "string"
|
|
12834
|
+
},
|
|
12341
12835
|
replace: {
|
|
12342
12836
|
type: "boolean"
|
|
12343
12837
|
},
|
|
@@ -12525,6 +13019,10 @@ async function runArchiveCommand2(args) {
|
|
|
12525
13019
|
const command = await Promise.resolve().then(() => (init_archive_command(), archive_command_exports));
|
|
12526
13020
|
return command.runArchiveCommand(args);
|
|
12527
13021
|
}
|
|
13022
|
+
async function runArchiveTitleCommand2(args) {
|
|
13023
|
+
const command = await Promise.resolve().then(() => (init_archive_title(), archive_title_exports));
|
|
13024
|
+
return command.runArchiveTitleCommand(args);
|
|
13025
|
+
}
|
|
12528
13026
|
async function runArchiveChapterCommand2(args) {
|
|
12529
13027
|
const command = await Promise.resolve().then(() => (init_chapter(), chapter_exports));
|
|
12530
13028
|
return command.runArchiveChapterCommand(args);
|
|
@@ -12628,6 +13126,9 @@ async function dispatchWikiGraphCLI(input) {
|
|
|
12628
13126
|
case "archive":
|
|
12629
13127
|
await runArchiveCommand2(parsed.args);
|
|
12630
13128
|
return { exitCode: 0 };
|
|
13129
|
+
case "archive-title":
|
|
13130
|
+
await runArchiveTitleCommand2(parsed.args);
|
|
13131
|
+
return { exitCode: 0 };
|
|
12631
13132
|
case "archive-index":
|
|
12632
13133
|
await runArchiveIndexCommand2(parsed.args);
|
|
12633
13134
|
return { exitCode: 0 };
|
|
@@ -12898,8 +13399,10 @@ var CaptureWritable = class extends Writable2 {
|
|
|
12898
13399
|
}
|
|
12899
13400
|
};
|
|
12900
13401
|
|
|
12901
|
-
// src/
|
|
12902
|
-
|
|
13402
|
+
// src/runtime/node-platform.ts
|
|
13403
|
+
var node_platform_exports = {};
|
|
13404
|
+
__reExport(node_platform_exports, node_platform_star);
|
|
13405
|
+
import * as node_platform_star from "wiki-graph-sdk/node-platform";
|
|
12903
13406
|
export {
|
|
12904
13407
|
createWikiGraphCLI,
|
|
12905
13408
|
runWikiGraphCLI,
|