exponential-cli 1.21.0 → 1.24.0
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/README.md +47 -7
- package/dist/index.js +552 -111
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1394,20 +1394,115 @@ Pipeline Stages (${stages.length})`));
|
|
|
1394
1394
|
function outputPageJson(page) {
|
|
1395
1395
|
console.log(JSON.stringify(page, null, 2));
|
|
1396
1396
|
}
|
|
1397
|
+
function formatBytes(bytes) {
|
|
1398
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
1399
|
+
return `${(bytes / 1024).toFixed(bytes < 10 * 1024 ? 1 : 0)} KB`;
|
|
1400
|
+
}
|
|
1401
|
+
function formatDay(value) {
|
|
1402
|
+
return new Date(value).toISOString().slice(0, 10);
|
|
1403
|
+
}
|
|
1397
1404
|
function outputPagePretty(page) {
|
|
1398
1405
|
console.log(chalk3.gray("\u2500".repeat(50)));
|
|
1399
1406
|
console.log(`
|
|
1400
1407
|
${chalk3.bold(page.title)}`);
|
|
1401
|
-
console.log(chalk3.gray(` ID: ${page.id}`));
|
|
1408
|
+
console.log(chalk3.gray(` ID: ${page.id} v${page.docVersion}`));
|
|
1402
1409
|
if (page.project) {
|
|
1403
1410
|
console.log(` ${chalk3.gray("Project:")} ${page.project.name}`);
|
|
1404
1411
|
}
|
|
1412
|
+
if (page.asOf || page.source) {
|
|
1413
|
+
const parts = [];
|
|
1414
|
+
if (page.asOf) parts.push(`As of ${formatDay(page.asOf)}`);
|
|
1415
|
+
if (page.source) parts.push(`Source: ${page.source}`);
|
|
1416
|
+
console.log(` ${chalk3.gray(parts.join(" \xB7 "))}`);
|
|
1417
|
+
}
|
|
1418
|
+
if (typeof page.bodyBytes === "number") {
|
|
1419
|
+
const scope = page.section ? ` (showing section "${page.section.text}")` : "";
|
|
1420
|
+
console.log(chalk3.gray(` Body: ${formatBytes(page.bodyBytes)}${scope}`));
|
|
1421
|
+
}
|
|
1422
|
+
if (page.outline) {
|
|
1423
|
+
console.log();
|
|
1424
|
+
if (page.outline.length === 0) console.log(chalk3.gray(" (no headings)"));
|
|
1425
|
+
for (const h of page.outline) {
|
|
1426
|
+
console.log(
|
|
1427
|
+
` ${" ".repeat(h.level - 1)}${chalk3.gray("#".repeat(h.level))} ${h.text} ${chalk3.gray(`L${h.line + 1}`)}`
|
|
1428
|
+
);
|
|
1429
|
+
}
|
|
1430
|
+
console.log();
|
|
1431
|
+
return;
|
|
1432
|
+
}
|
|
1405
1433
|
if (page.body) {
|
|
1406
1434
|
console.log(`
|
|
1407
1435
|
${page.body}
|
|
1408
1436
|
`);
|
|
1409
1437
|
}
|
|
1410
1438
|
}
|
|
1439
|
+
function outputPageSearchPretty(result) {
|
|
1440
|
+
if (result.results.length === 0) {
|
|
1441
|
+
console.log(chalk3.gray(`No pages about "${result.query}".`));
|
|
1442
|
+
return;
|
|
1443
|
+
}
|
|
1444
|
+
console.log(chalk3.bold(`
|
|
1445
|
+
Pages about "${result.query}" (${result.results.length})`));
|
|
1446
|
+
console.log(chalk3.gray("\u2500".repeat(50)));
|
|
1447
|
+
for (const r of result.results) {
|
|
1448
|
+
const score = r.similarity === null ? chalk3.gray("text match") : chalk3.gray(`${Math.round(r.similarity * 100)}%`);
|
|
1449
|
+
console.log(` ${chalk3.bold(r.title)} ${score}`);
|
|
1450
|
+
console.log(chalk3.gray(` ID: ${r.id} ${r.url}`));
|
|
1451
|
+
if (r.snippet) console.log(` ${r.snippet}`);
|
|
1452
|
+
}
|
|
1453
|
+
console.log();
|
|
1454
|
+
}
|
|
1455
|
+
function outputPageHistoryPretty(history) {
|
|
1456
|
+
if (history.revisions.length === 0) {
|
|
1457
|
+
console.log(chalk3.gray("No revisions yet."));
|
|
1458
|
+
return;
|
|
1459
|
+
}
|
|
1460
|
+
const n = history.revisions.length;
|
|
1461
|
+
console.log(chalk3.bold(`
|
|
1462
|
+
History (${n} revision${n === 1 ? "" : "s"})`));
|
|
1463
|
+
console.log(chalk3.gray("\u2500".repeat(50)));
|
|
1464
|
+
for (const r of history.revisions) {
|
|
1465
|
+
const when = new Date(r.updatedAt).toISOString().replace("T", " ").slice(0, 16);
|
|
1466
|
+
const who = r.kind === "baseline" ? "before history" : r.authorHidden ? "a member" : r.author?.name ?? "automated";
|
|
1467
|
+
console.log(
|
|
1468
|
+
` ${chalk3.gray(when)} ${chalk3.bold(who)} ${chalk3.cyan(r.kind)} v${r.docVersion} ${chalk3.gray(formatBytes(r.bodyBytes))}`
|
|
1469
|
+
);
|
|
1470
|
+
console.log(chalk3.gray(` ${r.id} "${r.title}"`));
|
|
1471
|
+
if (r.note) console.log(` ${r.note}`);
|
|
1472
|
+
else if (r.kind === "markdown" || r.kind === "restore") console.log(chalk3.gray(" (no reason given)"));
|
|
1473
|
+
}
|
|
1474
|
+
if (history.nextCursor) {
|
|
1475
|
+
console.log(chalk3.gray(`
|
|
1476
|
+
More: --cursor ${history.nextCursor}`));
|
|
1477
|
+
}
|
|
1478
|
+
console.log();
|
|
1479
|
+
}
|
|
1480
|
+
function outputPageDiffPretty(diff) {
|
|
1481
|
+
const side = (s) => s.revisionId ? `${s.revisionId} (v${s.docVersion})` : s.createdAt ? "current" : "(empty)";
|
|
1482
|
+
console.log(chalk3.gray(`${side(diff.from)} \u2192 ${side(diff.to)}`));
|
|
1483
|
+
if (diff.titleChanged) {
|
|
1484
|
+
console.log(chalk3.red(`- title: ${diff.from.title}`));
|
|
1485
|
+
console.log(chalk3.green(`+ title: ${diff.to.title}`));
|
|
1486
|
+
}
|
|
1487
|
+
if (diff.provenanceChanged) {
|
|
1488
|
+
const prov = (s) => `as of ${s.asOf ? formatDay(s.asOf) : "\u2014"} \xB7 source ${s.source ?? "\u2014"}`;
|
|
1489
|
+
console.log(chalk3.red(`- ${prov(diff.from)}`));
|
|
1490
|
+
console.log(chalk3.green(`+ ${prov(diff.to)}`));
|
|
1491
|
+
}
|
|
1492
|
+
if (!diff.unified) {
|
|
1493
|
+
console.log(chalk3.gray("No changes to the body."));
|
|
1494
|
+
return;
|
|
1495
|
+
}
|
|
1496
|
+
console.log(chalk3.gray(`+${diff.stats.added} \u2212${diff.stats.removed}
|
|
1497
|
+
`));
|
|
1498
|
+
for (const line of diff.unified.split("\n")) {
|
|
1499
|
+
if (line.startsWith("+++") || line.startsWith("---") || line.startsWith("@@")) {
|
|
1500
|
+
console.log(chalk3.gray(line));
|
|
1501
|
+
} else if (line.startsWith("+")) console.log(chalk3.green(line));
|
|
1502
|
+
else if (line.startsWith("-")) console.log(chalk3.red(line));
|
|
1503
|
+
else console.log(line);
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1411
1506
|
function outputPagesJson(pages) {
|
|
1412
1507
|
console.log(JSON.stringify({ pages, total: pages.length }, null, 2));
|
|
1413
1508
|
}
|
|
@@ -1658,8 +1753,8 @@ function transformDecisionListRow(d) {
|
|
|
1658
1753
|
supersededBy: d.supersededBy ?? null
|
|
1659
1754
|
};
|
|
1660
1755
|
}
|
|
1661
|
-
function outputDecisionJson(decision) {
|
|
1662
|
-
console.log(JSON.stringify(transformDecision(decision), null, 2));
|
|
1756
|
+
function outputDecisionJson(decision, extra = {}) {
|
|
1757
|
+
console.log(JSON.stringify({ ...transformDecision(decision), ...extra }, null, 2));
|
|
1663
1758
|
}
|
|
1664
1759
|
function outputDecisionPretty(decision) {
|
|
1665
1760
|
const color = getDecisionStatusColor(decision.status);
|
|
@@ -2514,6 +2609,9 @@ function hostnameOf(url) {
|
|
|
2514
2609
|
return null;
|
|
2515
2610
|
}
|
|
2516
2611
|
}
|
|
2612
|
+
function formatResourceTags(tags) {
|
|
2613
|
+
return `Tags: ${tags.join(", ")}`;
|
|
2614
|
+
}
|
|
2517
2615
|
function transformResource(r) {
|
|
2518
2616
|
return {
|
|
2519
2617
|
id: r.id,
|
|
@@ -2537,6 +2635,7 @@ function outputResourcePretty(resource) {
|
|
|
2537
2635
|
console.log(` ${badge} ${chalk3.bold(resource.title)}`);
|
|
2538
2636
|
if (resource.url) console.log(chalk3.gray(` ${resource.url}`));
|
|
2539
2637
|
if (resource.description) console.log(` ${resource.description}`);
|
|
2638
|
+
if (resource.tags?.length) console.log(chalk3.cyan(` ${formatResourceTags(resource.tags)}`));
|
|
2540
2639
|
console.log(chalk3.gray(` ID: ${resource.id}`));
|
|
2541
2640
|
}
|
|
2542
2641
|
function outputResourcesJson(resources, filters = {}) {
|
|
@@ -2558,6 +2657,7 @@ ${heading} (${resources.length} total)`));
|
|
|
2558
2657
|
const host = hostnameOf(r.url);
|
|
2559
2658
|
console.log(` ${chalk3.bold(r.title)}${host ? chalk3.gray(` ${host}`) : ""} ${chalk3.gray(when.toLocaleDateString())}`);
|
|
2560
2659
|
if (r.description) console.log(chalk3.gray(` ${r.description}`));
|
|
2660
|
+
if (r.tags?.length) console.log(chalk3.cyan(` ${formatResourceTags(r.tags)}`));
|
|
2561
2661
|
console.log(chalk3.gray(` ID: ${r.id}`));
|
|
2562
2662
|
}
|
|
2563
2663
|
console.log();
|
|
@@ -3232,6 +3332,27 @@ function parseNullableInt(v) {
|
|
|
3232
3332
|
if (Number.isNaN(n)) throw new Error(`Expected a number, got "${v}".`);
|
|
3233
3333
|
return n;
|
|
3234
3334
|
}
|
|
3335
|
+
var DECISION_LABEL = /^D-(\d+)$/i;
|
|
3336
|
+
function pickDecisionRef(positional, flag) {
|
|
3337
|
+
if (positional && flag && positional !== flag) {
|
|
3338
|
+
throw new Error(`Got two decisions ("${positional}" and --id "${flag}"). Pass one.`);
|
|
3339
|
+
}
|
|
3340
|
+
const ref = positional ?? flag;
|
|
3341
|
+
if (!ref) throw new Error("Pass the decision: a D-number like D-0006, or its id.");
|
|
3342
|
+
return ref;
|
|
3343
|
+
}
|
|
3344
|
+
async function resolveDecisionRef(client, workspaceId, ref) {
|
|
3345
|
+
const match = DECISION_LABEL.exec(ref.trim());
|
|
3346
|
+
if (!match) return ref;
|
|
3347
|
+
const number = Number.parseInt(match[1], 10);
|
|
3348
|
+
const [row] = await client.decisions.list({ workspaceId, number, limit: 1 });
|
|
3349
|
+
if (!row) {
|
|
3350
|
+
throw new Error(
|
|
3351
|
+
`${ref} is not in this workspace's decision log. Drafts are not listed until someone confirms them, so pass a draft's id instead (the "id" field from "decisions create --json").`
|
|
3352
|
+
);
|
|
3353
|
+
}
|
|
3354
|
+
return row.id;
|
|
3355
|
+
}
|
|
3235
3356
|
var BATCH_ITEM_KEYS = /* @__PURE__ */ new Set([
|
|
3236
3357
|
"statement",
|
|
3237
3358
|
"body",
|
|
@@ -3309,6 +3430,55 @@ function batchDeciders(value, index) {
|
|
|
3309
3430
|
);
|
|
3310
3431
|
});
|
|
3311
3432
|
}
|
|
3433
|
+
function notLinkedMessage(decision, featureId, error) {
|
|
3434
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
3435
|
+
return `Logged ${decision.label} (${decision.id}) but could not link it to feature ${featureId}: ${reason}. Link it with: exponential decisions link ${decision.id} --feature ${featureId}`;
|
|
3436
|
+
}
|
|
3437
|
+
function addConfirmCommand(parent) {
|
|
3438
|
+
parent.command("confirm [id]").description(
|
|
3439
|
+
"Publish a draft decision into the log, as the signed-in person. Takes a D-number (D-0006) or an id. --status ACCEPTED also accepts it. Agents cannot confirm: this needs a person's login."
|
|
3440
|
+
).option("--id <id>", "Decision id (alternative to the positional <id>)").option("--status <status>", "Then set this status: OPEN, PROPOSED, ACCEPTED or DEPRECATED").option("--workspace <slug|id>", "Workspace (defaults to your default workspace)").action(
|
|
3441
|
+
async (idArg, options, cmd) => {
|
|
3442
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
3443
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
3444
|
+
try {
|
|
3445
|
+
const ref = pickDecisionRef(idArg, options.id);
|
|
3446
|
+
const status = options.status ? parseStatus(options.status) : void 0;
|
|
3447
|
+
if (status === "SUPERSEDED") {
|
|
3448
|
+
throw new Error(
|
|
3449
|
+
'SUPERSEDED needs the decision that replaced this one. Confirm first, then run "decisions status <id> --status SUPERSEDED --superseded-by <id>".'
|
|
3450
|
+
);
|
|
3451
|
+
}
|
|
3452
|
+
const client = getClient();
|
|
3453
|
+
const workspaceId = await resolveWorkspaceId(client, options.workspace);
|
|
3454
|
+
const decisionId = await resolveDecisionRef(client, workspaceId, ref);
|
|
3455
|
+
let decision = await client.decisions.confirmDraft(workspaceId, decisionId);
|
|
3456
|
+
if (status && decision.status !== status) {
|
|
3457
|
+
try {
|
|
3458
|
+
decision = await client.decisions.setStatus({
|
|
3459
|
+
workspaceId,
|
|
3460
|
+
decisionId: decision.id,
|
|
3461
|
+
status
|
|
3462
|
+
});
|
|
3463
|
+
} catch (error) {
|
|
3464
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
3465
|
+
throw new Error(
|
|
3466
|
+
`Confirmed ${decision.label}, but it is still ${decision.status}: setting ${status} failed (${reason}). Retry with: exponential decisions status ${decision.id} --status ${status}`
|
|
3467
|
+
);
|
|
3468
|
+
}
|
|
3469
|
+
}
|
|
3470
|
+
if (useJson) outputDecisionJson(decision);
|
|
3471
|
+
else {
|
|
3472
|
+
console.log(`
|
|
3473
|
+
\u2713 Confirmed${status ? ` as ${decision.status}` : ""}`);
|
|
3474
|
+
outputDecisionPretty(decision);
|
|
3475
|
+
}
|
|
3476
|
+
} catch (error) {
|
|
3477
|
+
handleError(error, useJson);
|
|
3478
|
+
}
|
|
3479
|
+
}
|
|
3480
|
+
);
|
|
3481
|
+
}
|
|
3312
3482
|
function createDecisionsCommand() {
|
|
3313
3483
|
const decisions = new Command4("decisions").description(
|
|
3314
3484
|
[
|
|
@@ -3317,7 +3487,8 @@ function createDecisionsCommand() {
|
|
|
3317
3487
|
OPEN_QUESTION_NOTE,
|
|
3318
3488
|
"",
|
|
3319
3489
|
"Statuses: OPEN (an open question) \xB7 PROPOSED \xB7 ACCEPTED \xB7 SUPERSEDED \xB7 DEPRECATED.",
|
|
3320
|
-
'SUPERSEDED and DEPRECATED are reached with "decisions status", never at creation.'
|
|
3490
|
+
'SUPERSEDED and DEPRECATED are reached with "decisions status", never at creation.',
|
|
3491
|
+
"Commands that take a decision accept its D-number (D-0006) or its id."
|
|
3321
3492
|
].join("\n")
|
|
3322
3493
|
);
|
|
3323
3494
|
decisions.command("list").description(
|
|
@@ -3387,13 +3558,16 @@ function createDecisionsCommand() {
|
|
|
3387
3558
|
}
|
|
3388
3559
|
}
|
|
3389
3560
|
);
|
|
3390
|
-
decisions.command("get <id>").description(
|
|
3561
|
+
decisions.command("get <id>").description(
|
|
3562
|
+
"Show one decision in full: body, evidence, deciders, chain and links. Takes a D-number (D-0006) or an id."
|
|
3563
|
+
).option("--workspace <slug|id>", "Workspace (defaults to your default workspace)").action(async (id, options, cmd) => {
|
|
3391
3564
|
const globalOpts = cmd.optsWithGlobals();
|
|
3392
3565
|
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
3393
3566
|
try {
|
|
3394
3567
|
const client = getClient();
|
|
3395
3568
|
const workspaceId = await resolveWorkspaceId(client, options.workspace);
|
|
3396
|
-
const
|
|
3569
|
+
const decisionId = await resolveDecisionRef(client, workspaceId, id);
|
|
3570
|
+
const decision = await client.decisions.get(workspaceId, decisionId);
|
|
3397
3571
|
if (useJson) outputDecisionJson(decision);
|
|
3398
3572
|
else outputDecisionPretty(decision);
|
|
3399
3573
|
} catch (error) {
|
|
@@ -3407,7 +3581,10 @@ function createDecisionsCommand() {
|
|
|
3407
3581
|
"Bodies are Markdown: use --body-file <path> (or - for stdin) rather than a shell argument.",
|
|
3408
3582
|
"Bulk: --from-file <path|-> takes a JSON array of decisions; the other flags become its defaults."
|
|
3409
3583
|
].join(" ")
|
|
3410
|
-
).option("-s, --statement <text>", "The decision, or the open question (max 500 chars)").option("-b, --body <markdown>", "Markdown detail: context, alternatives, consequences").option("--body-file <path>", 'Read the body from a file ("-" = stdin)').option("--status <status>", "OPEN (open question), PROPOSED (default) or ACCEPTED").option("--source <source>", "MEETING, MANUAL or AGENT").option("--meeting <id>", "Meeting (transcriptionSessionId) this came out of \u2014 needs edit access to it").option("--workspace <slug|id>", "Workspace (defaults to your default workspace)").option("--product <slug|id>", "Link to a product").option("--project <id>", "Link to a project CUID").option("--goal <id>", "Link to a goal (integer id)").option("--key-result <id>", "Link to a key result CUID").option("--occurrence <id>", "Link to a ceremony occurrence CUID").option(
|
|
3584
|
+
).option("-s, --statement <text>", "The decision, or the open question (max 500 chars)").option("-b, --body <markdown>", "Markdown detail: context, alternatives, consequences").option("--body-file <path>", 'Read the body from a file ("-" = stdin)').option("--status <status>", "OPEN (open question), PROPOSED (default) or ACCEPTED").option("--source <source>", "MEETING, MANUAL or AGENT").option("--meeting <id>", "Meeting (transcriptionSessionId) this came out of \u2014 needs edit access to it").option("--workspace <slug|id>", "Workspace (defaults to your default workspace)").option("--product <slug|id>", "Link to a product").option("--project <id>", "Link to a project CUID").option("--goal <id>", "Link to a goal (integer id)").option("--key-result <id>", "Link to a key result CUID").option("--occurrence <id>", "Link to a ceremony occurrence CUID").option(
|
|
3585
|
+
"--feature <id>",
|
|
3586
|
+
'Also link it as "implemented by" this feature CUID, so it shows on the feature page'
|
|
3587
|
+
).option("--decided-at <iso>", "When it was decided (e.g. 2026-09-10T14:00)").option("--owner <userId>", "Owner user ID").option(
|
|
3411
3588
|
'--decider <"Name <email>">',
|
|
3412
3589
|
"Someone who made the decision (repeatable); external people need no account",
|
|
3413
3590
|
(value, previous) => [...previous, parseDecider(value)],
|
|
@@ -3493,6 +3670,20 @@ function createDecisionsCommand() {
|
|
|
3493
3670
|
);
|
|
3494
3671
|
}
|
|
3495
3672
|
const decision2 = await client.decisions.create(input);
|
|
3673
|
+
if (options.feature) {
|
|
3674
|
+
try {
|
|
3675
|
+
await client.decisions.linkFeature(workspaceId, decision2.id, options.feature);
|
|
3676
|
+
} catch (error) {
|
|
3677
|
+
results.push({
|
|
3678
|
+
index,
|
|
3679
|
+
success: false,
|
|
3680
|
+
decision: decision2,
|
|
3681
|
+
statement,
|
|
3682
|
+
error: notLinkedMessage(decision2, options.feature, error)
|
|
3683
|
+
});
|
|
3684
|
+
continue;
|
|
3685
|
+
}
|
|
3686
|
+
}
|
|
3496
3687
|
results.push({ index, success: true, decision: decision2, statement });
|
|
3497
3688
|
} catch (error) {
|
|
3498
3689
|
results.push({
|
|
@@ -3521,26 +3712,40 @@ function createDecisionsCommand() {
|
|
|
3521
3712
|
deciders: options.decider.length > 0 ? options.decider : void 0,
|
|
3522
3713
|
evidence: evidenceRaw === void 0 ? void 0 : parseEvidence(evidenceRaw)
|
|
3523
3714
|
});
|
|
3524
|
-
|
|
3715
|
+
let featureLink;
|
|
3716
|
+
if (options.feature) {
|
|
3717
|
+
try {
|
|
3718
|
+
featureLink = await client.decisions.linkFeature(
|
|
3719
|
+
workspaceId,
|
|
3720
|
+
decision.id,
|
|
3721
|
+
options.feature
|
|
3722
|
+
);
|
|
3723
|
+
} catch (error) {
|
|
3724
|
+
throw new Error(notLinkedMessage(decision, options.feature, error));
|
|
3725
|
+
}
|
|
3726
|
+
}
|
|
3727
|
+
if (useJson) outputDecisionJson(decision, featureLink ? { featureLink } : {});
|
|
3525
3728
|
else {
|
|
3526
3729
|
console.log(
|
|
3527
3730
|
`
|
|
3528
3731
|
\u2713 ${decision.status === "OPEN" ? "Open question" : "Decision"} logged`
|
|
3529
3732
|
);
|
|
3530
3733
|
outputDecisionPretty(decision);
|
|
3734
|
+
if (featureLink) console.log(chalk4.gray(` Linked to feature ${options.feature}`));
|
|
3531
3735
|
}
|
|
3532
3736
|
} catch (error) {
|
|
3533
3737
|
handleError(error, useJson);
|
|
3534
3738
|
}
|
|
3535
3739
|
}
|
|
3536
3740
|
);
|
|
3537
|
-
decisions.command("update").description(
|
|
3538
|
-
`Update a decision's content and scope; only the fields you pass are written. Status changes go through "decisions status".`
|
|
3539
|
-
).
|
|
3540
|
-
async (options, cmd) => {
|
|
3741
|
+
decisions.command("update [id]").description(
|
|
3742
|
+
`Update a decision's content and scope; only the fields you pass are written. Takes a D-number (D-0006) or an id. Status changes go through "decisions status".`
|
|
3743
|
+
).option("--id <id>", "Decision id (alternative to the positional <id>)").option("--workspace <slug|id>", "Workspace (defaults to your default workspace)").option("-s, --statement <text>", "New statement").option("-b, --body <markdown>", 'New Markdown body (or "null" to clear)').option("--body-file <path>", 'Read the new body from a file ("-" = stdin)').option("--decided-at <iso>", 'When it was decided (or "null" to clear)').option("--owner <userId>", 'Owner user ID (or "null" to clear)').option("--product <slug|id>", 'Product (or "null" to detach)').option("--project <id>", 'Project CUID (or "null" to detach)').option("--goal <id>", 'Goal integer id (or "null" to detach)').option("--key-result <id>", 'Key result CUID (or "null" to detach)').option("--adr <id>", 'ADR document CUID (or "null" to detach)').action(
|
|
3744
|
+
async (idArg, options, cmd) => {
|
|
3541
3745
|
const globalOpts = cmd.optsWithGlobals();
|
|
3542
3746
|
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
3543
3747
|
try {
|
|
3748
|
+
const ref = pickDecisionRef(idArg, options.id);
|
|
3544
3749
|
const body = options.body === "null" ? null : readText(options.body, options.bodyFile);
|
|
3545
3750
|
const patch = {
|
|
3546
3751
|
statement: options.statement,
|
|
@@ -3562,7 +3767,7 @@ function createDecisionsCommand() {
|
|
|
3562
3767
|
const productId = options.product === void 0 ? void 0 : options.product === "null" ? null : await resolveProductId(client, workspaceId, options.product);
|
|
3563
3768
|
const decision = await client.decisions.update({
|
|
3564
3769
|
workspaceId,
|
|
3565
|
-
decisionId:
|
|
3770
|
+
decisionId: await resolveDecisionRef(client, workspaceId, ref),
|
|
3566
3771
|
...patch,
|
|
3567
3772
|
productId
|
|
3568
3773
|
});
|
|
@@ -3576,16 +3781,20 @@ function createDecisionsCommand() {
|
|
|
3576
3781
|
}
|
|
3577
3782
|
}
|
|
3578
3783
|
);
|
|
3579
|
-
decisions.command("status").description(
|
|
3580
|
-
|
|
3581
|
-
).
|
|
3784
|
+
decisions.command("status [id]").alias("set-status").description(
|
|
3785
|
+
'Move a confirmed decision through its lifecycle \u2014 including answering an open question by moving it from OPEN to ACCEPTED. Takes a D-number (D-0006) or an id. A draft has to be confirmed first: "decisions confirm <id> --status ACCEPTED" does both.'
|
|
3786
|
+
).option("--id <id>", "Decision id (alternative to the positional <id>)").requiredOption(
|
|
3582
3787
|
"--status <status>",
|
|
3583
3788
|
"OPEN, PROPOSED, ACCEPTED, SUPERSEDED or DEPRECATED"
|
|
3584
|
-
).option(
|
|
3585
|
-
|
|
3789
|
+
).option(
|
|
3790
|
+
"--superseded-by <id>",
|
|
3791
|
+
"The decision that replaced this one, as a D-number or id (with --status SUPERSEDED)"
|
|
3792
|
+
).option("--workspace <slug|id>", "Workspace (defaults to your default workspace)").action(
|
|
3793
|
+
async (idArg, options, cmd) => {
|
|
3586
3794
|
const globalOpts = cmd.optsWithGlobals();
|
|
3587
3795
|
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
3588
3796
|
try {
|
|
3797
|
+
const ref = pickDecisionRef(idArg, options.id);
|
|
3589
3798
|
const status = parseStatus(options.status);
|
|
3590
3799
|
if (status === "SUPERSEDED" && !options.supersededBy) {
|
|
3591
3800
|
throw new Error(
|
|
@@ -3596,9 +3805,9 @@ function createDecisionsCommand() {
|
|
|
3596
3805
|
const workspaceId = await resolveWorkspaceId(client, options.workspace);
|
|
3597
3806
|
const decision = await client.decisions.setStatus({
|
|
3598
3807
|
workspaceId,
|
|
3599
|
-
decisionId:
|
|
3808
|
+
decisionId: await resolveDecisionRef(client, workspaceId, ref),
|
|
3600
3809
|
status,
|
|
3601
|
-
supersededById: options.supersededBy
|
|
3810
|
+
supersededById: options.supersededBy ? await resolveDecisionRef(client, workspaceId, options.supersededBy) : void 0
|
|
3602
3811
|
});
|
|
3603
3812
|
if (useJson) outputDecisionJson(decision);
|
|
3604
3813
|
else {
|
|
@@ -3611,11 +3820,14 @@ function createDecisionsCommand() {
|
|
|
3611
3820
|
}
|
|
3612
3821
|
}
|
|
3613
3822
|
);
|
|
3614
|
-
decisions.command("link
|
|
3615
|
-
|
|
3823
|
+
decisions.command("link [id]").description(
|
|
3824
|
+
"Record what implements a decision: a ticket or a feature. Takes a D-number (D-0006) or an id. Idempotent."
|
|
3825
|
+
).option("--id <id>", "Decision id (alternative to the positional <id>)").option("--ticket <id>", "Ticket CUID").option("--feature <id>", "Feature CUID").option("--workspace <slug|id>", "Workspace (defaults to your default workspace)").action(
|
|
3826
|
+
async (idArg, options, cmd) => {
|
|
3616
3827
|
const globalOpts = cmd.optsWithGlobals();
|
|
3617
3828
|
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
3618
3829
|
try {
|
|
3830
|
+
const ref = pickDecisionRef(idArg, options.id);
|
|
3619
3831
|
if (!options.ticket && !options.feature) {
|
|
3620
3832
|
throw new Error("Pass --ticket <id> or --feature <id>.");
|
|
3621
3833
|
}
|
|
@@ -3624,7 +3836,8 @@ function createDecisionsCommand() {
|
|
|
3624
3836
|
}
|
|
3625
3837
|
const client = getClient();
|
|
3626
3838
|
const workspaceId = await resolveWorkspaceId(client, options.workspace);
|
|
3627
|
-
const
|
|
3839
|
+
const decisionId = await resolveDecisionRef(client, workspaceId, ref);
|
|
3840
|
+
const link = options.ticket ? await client.decisions.linkTicket(workspaceId, decisionId, options.ticket) : await client.decisions.linkFeature(workspaceId, decisionId, options.feature);
|
|
3628
3841
|
if (useJson) console.log(JSON.stringify(link, null, 2));
|
|
3629
3842
|
else {
|
|
3630
3843
|
console.log(`\u2713 Linked ${chalk4.gray(`(link id ${link.id})`)}`);
|
|
@@ -3688,52 +3901,52 @@ function createDecisionsCommand() {
|
|
|
3688
3901
|
handleError(error, useJson);
|
|
3689
3902
|
}
|
|
3690
3903
|
});
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
try {
|
|
3695
|
-
const client = getClient();
|
|
3696
|
-
const workspaceId = await resolveWorkspaceId(client, options.workspace);
|
|
3697
|
-
const decision = await client.decisions.confirmDraft(workspaceId, options.id);
|
|
3698
|
-
if (useJson) outputDecisionJson(decision);
|
|
3699
|
-
else {
|
|
3700
|
-
console.log("\n\u2713 Draft confirmed");
|
|
3701
|
-
outputDecisionPretty(decision);
|
|
3702
|
-
}
|
|
3703
|
-
} catch (error) {
|
|
3704
|
-
handleError(error, useJson);
|
|
3705
|
-
}
|
|
3706
|
-
});
|
|
3707
|
-
drafts.command("reject").description(
|
|
3904
|
+
addConfirmCommand(decisions);
|
|
3905
|
+
addConfirmCommand(drafts);
|
|
3906
|
+
drafts.command("reject [id]").description(
|
|
3708
3907
|
'Reject a draft. A confirmed decision is never rejected \u2014 deprecate or supersede it with "decisions status".'
|
|
3709
|
-
).
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3908
|
+
).option("--id <id>", "Decision id (alternative to the positional <id>)").option("--workspace <slug|id>", "Workspace (defaults to your default workspace)").action(
|
|
3909
|
+
async (idArg, options, cmd) => {
|
|
3910
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
3911
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
3912
|
+
try {
|
|
3913
|
+
const client = getClient();
|
|
3914
|
+
const workspaceId = await resolveWorkspaceId(client, options.workspace);
|
|
3915
|
+
const decisionId = await resolveDecisionRef(
|
|
3916
|
+
client,
|
|
3917
|
+
workspaceId,
|
|
3918
|
+
pickDecisionRef(idArg, options.id)
|
|
3919
|
+
);
|
|
3920
|
+
const result = await client.decisions.rejectDraft(workspaceId, decisionId);
|
|
3921
|
+
if (useJson) console.log(JSON.stringify(result, null, 2));
|
|
3922
|
+
else console.log("\u2713 Draft rejected");
|
|
3923
|
+
} catch (error) {
|
|
3924
|
+
handleError(error, useJson);
|
|
3925
|
+
}
|
|
3720
3926
|
}
|
|
3721
|
-
|
|
3722
|
-
drafts.command("delete").description(
|
|
3927
|
+
);
|
|
3928
|
+
drafts.command("delete [id]").description(
|
|
3723
3929
|
"Permanently delete a draft or rejected decision. Confirmed decisions are never deleted."
|
|
3724
|
-
).
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3930
|
+
).option("--id <id>", "Decision id (alternative to the positional <id>)").option("--workspace <slug|id>", "Workspace (defaults to your default workspace)").action(
|
|
3931
|
+
async (idArg, options, cmd) => {
|
|
3932
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
3933
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
3934
|
+
try {
|
|
3935
|
+
const client = getClient();
|
|
3936
|
+
const workspaceId = await resolveWorkspaceId(client, options.workspace);
|
|
3937
|
+
const decisionId = await resolveDecisionRef(
|
|
3938
|
+
client,
|
|
3939
|
+
workspaceId,
|
|
3940
|
+
pickDecisionRef(idArg, options.id)
|
|
3941
|
+
);
|
|
3942
|
+
const result = await client.decisions.deleteDraft(workspaceId, decisionId);
|
|
3943
|
+
if (useJson) console.log(JSON.stringify({ deleted: true, ...result }, null, 2));
|
|
3944
|
+
else console.log("\u2713 Draft deleted");
|
|
3945
|
+
} catch (error) {
|
|
3946
|
+
handleError(error, useJson);
|
|
3947
|
+
}
|
|
3735
3948
|
}
|
|
3736
|
-
|
|
3949
|
+
);
|
|
3737
3950
|
decisions.addCommand(drafts);
|
|
3738
3951
|
return decisions;
|
|
3739
3952
|
}
|
|
@@ -5536,6 +5749,7 @@ function createOrganizationsCommand() {
|
|
|
5536
5749
|
|
|
5537
5750
|
// src/commands/pages.ts
|
|
5538
5751
|
import { Command as Command17 } from "commander";
|
|
5752
|
+
import chalk8 from "chalk";
|
|
5539
5753
|
|
|
5540
5754
|
// src/commands/pageComments.ts
|
|
5541
5755
|
import { Command as Command16 } from "commander";
|
|
@@ -5634,11 +5848,22 @@ function createPageCommentsCommand() {
|
|
|
5634
5848
|
}
|
|
5635
5849
|
|
|
5636
5850
|
// src/commands/pages.ts
|
|
5851
|
+
function parseLimit(value) {
|
|
5852
|
+
if (value === void 0) return void 0;
|
|
5853
|
+
const n = Number(value);
|
|
5854
|
+
if (!Number.isInteger(n) || n < 1) {
|
|
5855
|
+
throw new Error(`--limit must be a positive integer, got "${value}"`);
|
|
5856
|
+
}
|
|
5857
|
+
return n;
|
|
5858
|
+
}
|
|
5637
5859
|
function createPagesCommand() {
|
|
5638
5860
|
const pages = new Command17("pages").description(
|
|
5639
|
-
|
|
5861
|
+
`Manage Knowledge pages (PRDs, research, technical specs). Reads are Markdown-only by default; every write is recorded in the page's history. Link one to a feature with "features link-page".`
|
|
5640
5862
|
);
|
|
5641
|
-
pages.command("list").description("List pages in a workspace").option("--workspace <slug|id>", "Workspace (defaults to the configured default)").option(
|
|
5863
|
+
pages.command("list").description("List pages in a workspace (metadata only, no bodies)").option("--workspace <slug|id>", "Workspace (defaults to the configured default)").option(
|
|
5864
|
+
"--search <text>",
|
|
5865
|
+
'Case-insensitive title match. To find pages by content or meaning use "pages search".'
|
|
5866
|
+
).action(
|
|
5642
5867
|
async (options, cmd) => {
|
|
5643
5868
|
const globalOpts = cmd.optsWithGlobals();
|
|
5644
5869
|
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
@@ -5656,19 +5881,51 @@ function createPagesCommand() {
|
|
|
5656
5881
|
}
|
|
5657
5882
|
}
|
|
5658
5883
|
);
|
|
5659
|
-
pages.command("
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
const
|
|
5664
|
-
const
|
|
5665
|
-
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
5884
|
+
pages.command("search <query>").description(
|
|
5885
|
+
"Find pages by meaning: semantic hits from the Knowledge index first (with the matching passage), then pages whose title or body contain the text"
|
|
5886
|
+
).option("--workspace <slug|id>", "Workspace (defaults to the configured default)").option("--project <id>", "Only pages filed under this project").option("-l, --limit <n>", "Max pages (1-25, default 10)").action(
|
|
5887
|
+
async (query, options, cmd) => {
|
|
5888
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
5889
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
5890
|
+
try {
|
|
5891
|
+
const client = getClient();
|
|
5892
|
+
const workspaceId = await resolveWorkspaceId(client, options.workspace);
|
|
5893
|
+
const result = await client.pages.search({
|
|
5894
|
+
workspaceId,
|
|
5895
|
+
query,
|
|
5896
|
+
projectId: options.project,
|
|
5897
|
+
limit: parseLimit(options.limit)
|
|
5898
|
+
});
|
|
5899
|
+
if (useJson) console.log(JSON.stringify(result, null, 2));
|
|
5900
|
+
else outputPageSearchPretty(result);
|
|
5901
|
+
} catch (error) {
|
|
5902
|
+
handleError(error, useJson);
|
|
5903
|
+
}
|
|
5669
5904
|
}
|
|
5670
|
-
|
|
5671
|
-
pages.command("
|
|
5905
|
+
);
|
|
5906
|
+
pages.command("get <id>").description(
|
|
5907
|
+
"Get a page by CUID. Markdown body only by default (the editor doc is never sent). --outline shows its headings; --section reads one part."
|
|
5908
|
+
).option("--outline", "Headings only (level, text, line) and the body size, no body").option(
|
|
5909
|
+
"--section <heading>",
|
|
5910
|
+
`Only this heading's section (case-insensitive; a "## " prefix is allowed)`
|
|
5911
|
+
).option("--full", "Include the editor's ProseMirror document as well (large)").action(
|
|
5912
|
+
async (id, options, cmd) => {
|
|
5913
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
5914
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
5915
|
+
try {
|
|
5916
|
+
const client = getClient();
|
|
5917
|
+
const page = await client.pages.get(id, {
|
|
5918
|
+
format: options.outline ? "outline" : options.full ? "full" : "markdown",
|
|
5919
|
+
section: options.section
|
|
5920
|
+
});
|
|
5921
|
+
if (useJson) outputPageJson(page);
|
|
5922
|
+
else outputPagePretty(page);
|
|
5923
|
+
} catch (error) {
|
|
5924
|
+
handleError(error, useJson);
|
|
5925
|
+
}
|
|
5926
|
+
}
|
|
5927
|
+
);
|
|
5928
|
+
pages.command("create").description("Create a page. Body: -b text, --body-file <path>, or --body-file - for stdin.").option("--workspace <slug|id>", "Workspace (defaults to the configured default)").requiredOption("-t, --title <title>", "Page title").option("-b, --body <markdown>", "Markdown body").option("--body-file <path>", 'Read the Markdown body from a file ("-" = stdin)').option("--project <id>", "File the page under a project").option("--source <text>", "Where the facts come from: a URL, a document, a person").option("--as-of <date>", "The date the facts were true (YYYY-MM-DD)").option("-n, --note <text>", "Why: recorded on the page's first revision").action(
|
|
5672
5929
|
async (options, cmd) => {
|
|
5673
5930
|
const globalOpts = cmd.optsWithGlobals();
|
|
5674
5931
|
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
@@ -5677,8 +5934,12 @@ function createPagesCommand() {
|
|
|
5677
5934
|
const workspaceId = await resolveWorkspaceId(client, options.workspace);
|
|
5678
5935
|
const page = await client.pages.create({
|
|
5679
5936
|
workspaceId,
|
|
5937
|
+
projectId: options.project,
|
|
5680
5938
|
title: options.title,
|
|
5681
|
-
body: readText(options.body, options.bodyFile)
|
|
5939
|
+
body: readText(options.body, options.bodyFile),
|
|
5940
|
+
source: options.source,
|
|
5941
|
+
asOf: parseDate(options.asOf),
|
|
5942
|
+
note: options.note
|
|
5682
5943
|
});
|
|
5683
5944
|
if (useJson) outputPageJson(page);
|
|
5684
5945
|
else {
|
|
@@ -5691,8 +5952,8 @@ function createPagesCommand() {
|
|
|
5691
5952
|
}
|
|
5692
5953
|
);
|
|
5693
5954
|
pages.command("update").description(
|
|
5694
|
-
"Update a page. Sending a body is a Markdown-source write: the Markdown becomes canonical."
|
|
5695
|
-
).requiredOption("--id <id>", "Page CUID").option("-t, --title <title>", "New title").option("-b, --body <markdown>", "New Markdown body (replaces the whole body)").option("--body-file <path>", 'Read the new Markdown body from a file ("-" = stdin)').action(
|
|
5955
|
+
"Update a page. Sending a body is a Markdown-source write: the Markdown becomes canonical. Pass --base-version so a newer edit by someone else is a CONFLICT, not an overwrite."
|
|
5956
|
+
).requiredOption("--id <id>", "Page CUID").option("-t, --title <title>", "New title").option("-b, --body <markdown>", "New Markdown body (replaces the whole body)").option("--body-file <path>", 'Read the new Markdown body from a file ("-" = stdin)').option("--base-version <n>", "The docVersion you read before editing (compare-and-set)").option("-n, --note <text>", "Why this change: shown in the page's history").option("--source <text>", "Where the facts come from (an empty string clears it)").option("--as-of <date>", "The date the facts were true (YYYY-MM-DD)").option("--clear-as-of", "Remove the as-of date").action(
|
|
5696
5957
|
async (options, cmd) => {
|
|
5697
5958
|
const globalOpts = cmd.optsWithGlobals();
|
|
5698
5959
|
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
@@ -5701,7 +5962,11 @@ function createPagesCommand() {
|
|
|
5701
5962
|
const page = await client.pages.update({
|
|
5702
5963
|
id: options.id,
|
|
5703
5964
|
title: options.title,
|
|
5704
|
-
body: readText(options.body, options.bodyFile)
|
|
5965
|
+
body: readText(options.body, options.bodyFile),
|
|
5966
|
+
baseVersion: options.baseVersion === void 0 ? void 0 : Number(options.baseVersion),
|
|
5967
|
+
note: options.note,
|
|
5968
|
+
source: options.source,
|
|
5969
|
+
asOf: options.clearAsOf ? null : parseDate(options.asOf)
|
|
5705
5970
|
});
|
|
5706
5971
|
if (useJson) outputPageJson(page);
|
|
5707
5972
|
else {
|
|
@@ -5713,6 +5978,107 @@ function createPagesCommand() {
|
|
|
5713
5978
|
}
|
|
5714
5979
|
}
|
|
5715
5980
|
);
|
|
5981
|
+
pages.command("history <id>").description(
|
|
5982
|
+
"The page's revisions, newest first: who, when, why and the body size. Never the bodies."
|
|
5983
|
+
).option("-l, --limit <n>", "Max revisions (1-200, default 50)").option("--cursor <revisionId>", "Continue from a previous page of history").action(
|
|
5984
|
+
async (id, options, cmd) => {
|
|
5985
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
5986
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
5987
|
+
try {
|
|
5988
|
+
const client = getClient();
|
|
5989
|
+
const history = await client.pages.history(id, {
|
|
5990
|
+
limit: parseLimit(options.limit),
|
|
5991
|
+
cursor: options.cursor
|
|
5992
|
+
});
|
|
5993
|
+
if (useJson) console.log(JSON.stringify(history, null, 2));
|
|
5994
|
+
else outputPageHistoryPretty(history);
|
|
5995
|
+
} catch (error) {
|
|
5996
|
+
handleError(error, useJson);
|
|
5997
|
+
}
|
|
5998
|
+
}
|
|
5999
|
+
);
|
|
6000
|
+
pages.command("revision <id> <revisionId>").description("One revision with its Markdown body").action(
|
|
6001
|
+
async (id, revisionId, _options, cmd) => {
|
|
6002
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
6003
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
6004
|
+
try {
|
|
6005
|
+
const client = getClient();
|
|
6006
|
+
const revision = await client.pages.revision(id, revisionId);
|
|
6007
|
+
if (useJson) console.log(JSON.stringify(revision, null, 2));
|
|
6008
|
+
else {
|
|
6009
|
+
console.log(chalk8.gray("\u2500".repeat(50)));
|
|
6010
|
+
console.log(
|
|
6011
|
+
`
|
|
6012
|
+
${chalk8.bold(revision.title)} ${chalk8.gray(`v${revision.docVersion} \xB7 ${revision.kind}`)}`
|
|
6013
|
+
);
|
|
6014
|
+
console.log(chalk8.gray(` Revision: ${revision.id}`));
|
|
6015
|
+
if (revision.note) console.log(` ${chalk8.gray("Note:")} ${revision.note}`);
|
|
6016
|
+
if (revision.body) console.log(`
|
|
6017
|
+
${revision.body}
|
|
6018
|
+
`);
|
|
6019
|
+
}
|
|
6020
|
+
} catch (error) {
|
|
6021
|
+
handleError(error, useJson);
|
|
6022
|
+
}
|
|
6023
|
+
}
|
|
6024
|
+
);
|
|
6025
|
+
pages.command("diff <id>").description(
|
|
6026
|
+
"What a revision changed, as a unified diff of the Markdown. Defaults to the latest revision against the one before it."
|
|
6027
|
+
).option("--revision <revisionId>", "The revision to inspect (default: the latest)").option(
|
|
6028
|
+
"--against <previous|current|revisionId>",
|
|
6029
|
+
"What to compare with: the revision before it (default), the page as it is now, or another revision"
|
|
6030
|
+
).action(
|
|
6031
|
+
async (id, options, cmd) => {
|
|
6032
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
6033
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
6034
|
+
try {
|
|
6035
|
+
const client = getClient();
|
|
6036
|
+
let revisionId = options.revision;
|
|
6037
|
+
if (!revisionId) {
|
|
6038
|
+
const latest = await client.pages.history(id, { limit: 1 });
|
|
6039
|
+
revisionId = latest.revisions[0]?.id;
|
|
6040
|
+
if (!revisionId) throw new Error("This page has no revisions yet.");
|
|
6041
|
+
}
|
|
6042
|
+
const diff = await client.pages.diff(id, revisionId, { against: options.against });
|
|
6043
|
+
if (useJson) console.log(JSON.stringify(diff, null, 2));
|
|
6044
|
+
else outputPageDiffPretty(diff);
|
|
6045
|
+
} catch (error) {
|
|
6046
|
+
handleError(error, useJson);
|
|
6047
|
+
}
|
|
6048
|
+
}
|
|
6049
|
+
);
|
|
6050
|
+
pages.command("restore <id>").description(
|
|
6051
|
+
"Put a revision's title and body back as the page's current content. A forward write: the history keeps what was replaced."
|
|
6052
|
+
).requiredOption("--revision <revisionId>", 'The revision to restore (see "pages history")').option("-n, --note <text>", "Why: recorded on the restore revision").option(
|
|
6053
|
+
"--base-version <n>",
|
|
6054
|
+
`The page version you looked at (newest revision's v-number in "pages history"); a newer save makes this a CONFLICT. Defaults to the newest revision now.`
|
|
6055
|
+
).action(
|
|
6056
|
+
async (id, options, cmd) => {
|
|
6057
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
6058
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
6059
|
+
try {
|
|
6060
|
+
const client = getClient();
|
|
6061
|
+
let baseVersion = options.baseVersion === void 0 ? void 0 : Number(options.baseVersion);
|
|
6062
|
+
if (baseVersion === void 0) {
|
|
6063
|
+
const latest = await client.pages.history(id, { limit: 1 });
|
|
6064
|
+
baseVersion = latest.revisions[0]?.docVersion;
|
|
6065
|
+
}
|
|
6066
|
+
const result = await client.pages.restore(id, options.revision, {
|
|
6067
|
+
note: options.note,
|
|
6068
|
+
baseVersion
|
|
6069
|
+
});
|
|
6070
|
+
if (useJson) console.log(JSON.stringify(result, null, 2));
|
|
6071
|
+
else {
|
|
6072
|
+
console.log(
|
|
6073
|
+
`
|
|
6074
|
+
\u2713 Page restored (now v${result.docVersion}, revision ${result.revisionId})`
|
|
6075
|
+
);
|
|
6076
|
+
}
|
|
6077
|
+
} catch (error) {
|
|
6078
|
+
handleError(error, useJson);
|
|
6079
|
+
}
|
|
6080
|
+
}
|
|
6081
|
+
);
|
|
5716
6082
|
pages.addCommand(createPageCommentsCommand());
|
|
5717
6083
|
return pages;
|
|
5718
6084
|
}
|
|
@@ -6016,11 +6382,16 @@ function validateStatus(value) {
|
|
|
6016
6382
|
}
|
|
6017
6383
|
return v;
|
|
6018
6384
|
}
|
|
6385
|
+
function collectTags(value, previous) {
|
|
6386
|
+
const next = value.split(",").map((t) => t.trim()).filter(Boolean);
|
|
6387
|
+
return [.../* @__PURE__ */ new Set([...previous, ...next])];
|
|
6388
|
+
}
|
|
6389
|
+
var TAG_OPTION = "--tag <tag>";
|
|
6019
6390
|
function createResourcesCommand() {
|
|
6020
6391
|
const resources = new Command20("resources").description(
|
|
6021
6392
|
"Saved links and reference material. `list` defaults to the Reading list (unread); `create --url` saves a link to read later."
|
|
6022
6393
|
);
|
|
6023
|
-
resources.command("list").description("List resources. Defaults to the Reading list (unread); --status read for what you finished, all for everything.").option("--workspace <slug|id>", "Workspace (defaults to the configured default)").option("--status <status>", `One of: ${STATUS_FILTERS.join(", ")} (default: unread)`).option("--search <text>", "Filter by title/description").option("--limit <n>", "Max rows (default 50)", "50").action(
|
|
6394
|
+
resources.command("list").description("List resources. Defaults to the Reading list (unread); --status read for what you finished, all for everything.").option("--workspace <slug|id>", "Workspace (defaults to the configured default)").option("--status <status>", `One of: ${STATUS_FILTERS.join(", ")} (default: unread)`).option("--search <text>", "Filter by title/description").option(TAG_OPTION, "Only resources with this tag (repeatable or comma-separated; matches any)", collectTags, []).option("--limit <n>", "Max rows (default 50)", "50").action(
|
|
6024
6395
|
async (options, cmd) => {
|
|
6025
6396
|
const globalOpts = cmd.optsWithGlobals();
|
|
6026
6397
|
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
@@ -6032,16 +6403,22 @@ function createResourcesCommand() {
|
|
|
6032
6403
|
workspaceId,
|
|
6033
6404
|
readStatus: status === "all" ? void 0 : status,
|
|
6034
6405
|
search: options.search,
|
|
6406
|
+
tags: options.tag.length > 0 ? options.tag : void 0,
|
|
6035
6407
|
limit: Number.parseInt(options.limit, 10) || 50
|
|
6036
6408
|
});
|
|
6037
|
-
if (useJson) outputResourcesJson(rows, { status });
|
|
6409
|
+
if (useJson) outputResourcesJson(rows, { status, ...options.tag.length > 0 && { tags: options.tag } });
|
|
6038
6410
|
else outputResourcesPretty(rows, status);
|
|
6039
6411
|
} catch (error) {
|
|
6040
6412
|
handleError(error, useJson);
|
|
6041
6413
|
}
|
|
6042
6414
|
}
|
|
6043
6415
|
);
|
|
6044
|
-
resources.command("create").description("Save a link to the Reading list (to read later). Stored by title and URL; not fetched or indexed.").requiredOption("--url <url>", "The http(s) link to save").option("-t, --title <title>", "Title (defaults to the hostname)").option("--note <text>", "One-line note (why, or who recommended it)").option(
|
|
6416
|
+
resources.command("create").description("Save a link to the Reading list (to read later). Stored by title and URL; not fetched or indexed.").requiredOption("--url <url>", "The http(s) link to save").option("-t, --title <title>", "Title (defaults to the hostname)").option("--note <text>", "One-line note (why, or who recommended it)").option(
|
|
6417
|
+
TAG_OPTION,
|
|
6418
|
+
"Label it, e.g. where it came from (repeatable or comma-separated; added to any tags a re-saved link has)",
|
|
6419
|
+
collectTags,
|
|
6420
|
+
[]
|
|
6421
|
+
).option("--workspace <slug|id>", "Workspace (defaults to the configured default)").option("--read", "Save as already read (reference material, not a queue item)").action(
|
|
6045
6422
|
async (options, cmd) => {
|
|
6046
6423
|
const globalOpts = cmd.optsWithGlobals();
|
|
6047
6424
|
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
@@ -6052,6 +6429,7 @@ function createResourcesCommand() {
|
|
|
6052
6429
|
url: options.url,
|
|
6053
6430
|
title: options.title,
|
|
6054
6431
|
note: options.note,
|
|
6432
|
+
tags: options.tag.length > 0 ? options.tag : void 0,
|
|
6055
6433
|
workspaceId,
|
|
6056
6434
|
readStatus: options.read ? "read" : "to_read"
|
|
6057
6435
|
});
|
|
@@ -6065,6 +6443,28 @@ function createResourcesCommand() {
|
|
|
6065
6443
|
}
|
|
6066
6444
|
}
|
|
6067
6445
|
);
|
|
6446
|
+
resources.command("tag <id>").description("Add or remove a resource's tags").option("--add <tag>", "Tag to add (repeatable or comma-separated)", collectTags, []).option("--remove <tag>", "Tag to remove (repeatable or comma-separated)", collectTags, []).action(async (id, options, cmd) => {
|
|
6447
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
6448
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
6449
|
+
try {
|
|
6450
|
+
if (options.add.length === 0 && options.remove.length === 0) {
|
|
6451
|
+
throw new Error("Pass --add <tag> and/or --remove <tag>");
|
|
6452
|
+
}
|
|
6453
|
+
const client = getClient();
|
|
6454
|
+
const current = await client.resources.get(id);
|
|
6455
|
+
const kept = (current.tags ?? []).filter((t) => !options.remove.includes(t));
|
|
6456
|
+
const tags = [.../* @__PURE__ */ new Set([...kept, ...options.add])];
|
|
6457
|
+
const resource = await client.resources.update(id, { tags });
|
|
6458
|
+
if (useJson) outputResourceJson(resource);
|
|
6459
|
+
else {
|
|
6460
|
+
console.log(`
|
|
6461
|
+
\u2713 Tags updated`);
|
|
6462
|
+
outputResourcePretty(resource);
|
|
6463
|
+
}
|
|
6464
|
+
} catch (error) {
|
|
6465
|
+
handleError(error, useJson);
|
|
6466
|
+
}
|
|
6467
|
+
});
|
|
6068
6468
|
const setStatus = (name, readStatus, description) => resources.command(`${name} <id>`).description(description).action(async (id, _options, cmd) => {
|
|
6069
6469
|
const globalOpts = cmd.optsWithGlobals();
|
|
6070
6470
|
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
@@ -6659,7 +7059,18 @@ ${plan.contents}
|
|
|
6659
7059
|
|
|
6660
7060
|
// src/commands/search.ts
|
|
6661
7061
|
import { Command as Command22 } from "commander";
|
|
6662
|
-
import
|
|
7062
|
+
import chalk9 from "chalk";
|
|
7063
|
+
var KNOWLEDGE_TYPES = ["transcription", "resource", "document", "page"];
|
|
7064
|
+
function parseTypes(value) {
|
|
7065
|
+
if (!value) return void 0;
|
|
7066
|
+
const types = value.split(",").map((t) => t.trim()).filter(Boolean);
|
|
7067
|
+
for (const t of types) {
|
|
7068
|
+
if (!KNOWLEDGE_TYPES.includes(t)) {
|
|
7069
|
+
throw new Error(`Unknown source type "${t}". Use: ${KNOWLEDGE_TYPES.join(", ")}`);
|
|
7070
|
+
}
|
|
7071
|
+
}
|
|
7072
|
+
return types;
|
|
7073
|
+
}
|
|
6663
7074
|
var TYPE_LABELS = {
|
|
6664
7075
|
workspace: "Workspaces",
|
|
6665
7076
|
project: "Projects",
|
|
@@ -6678,8 +7089,8 @@ var TYPE_LABELS = {
|
|
|
6678
7089
|
};
|
|
6679
7090
|
function createSearchCommand() {
|
|
6680
7091
|
const search = new Command22("search").description(
|
|
6681
|
-
"Global search across projects, actions, goals, workspaces and more \u2014 same coverage as the app's Cmd+K palette"
|
|
6682
|
-
).argument("<query>", "Text to search for").option("-w, --workspace <slug>", "Restrict results to one workspace (slug or ID)").option("-l, --limit <n>", "Max results per entity type (1-25, default 10)").action(async (query, options, cmd) => {
|
|
7092
|
+
"Global search across projects, actions, goals, workspaces and more \u2014 same coverage as the app's Cmd+K palette. Matches titles; add --semantic to search meetings, resources, documents and pages by meaning."
|
|
7093
|
+
).argument("<query>", "Text to search for").option("-w, --workspace <slug>", "Restrict results to one workspace (slug or ID; required with --semantic)").option("-l, --limit <n>", "Max results per entity type (1-25, default 10; 1-20 with --semantic)").option("--semantic", "Search the Knowledge index by meaning instead of matching titles").option("--types <list>", "With --semantic: comma-separated source kinds (transcription,resource,document,page)").action(async (query, options, cmd) => {
|
|
6683
7094
|
const globalOpts = cmd.optsWithGlobals();
|
|
6684
7095
|
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
6685
7096
|
try {
|
|
@@ -6691,23 +7102,53 @@ function createSearchCommand() {
|
|
|
6691
7102
|
(w) => w.slug === options.workspace || w.id === options.workspace
|
|
6692
7103
|
);
|
|
6693
7104
|
if (!match) {
|
|
6694
|
-
console.error(
|
|
6695
|
-
console.log(
|
|
7105
|
+
console.error(chalk9.red(`Workspace "${options.workspace}" not found.`));
|
|
7106
|
+
console.log(chalk9.gray("Available workspaces:"));
|
|
6696
7107
|
workspaces.forEach((w) => {
|
|
6697
|
-
console.log(
|
|
7108
|
+
console.log(chalk9.gray(` - ${w.slug} (${w.name})`));
|
|
6698
7109
|
});
|
|
6699
7110
|
process.exit(1);
|
|
6700
7111
|
}
|
|
6701
7112
|
workspaceId = match.id;
|
|
6702
7113
|
}
|
|
6703
7114
|
const limit = options.limit ? Number(options.limit) : void 0;
|
|
7115
|
+
if (options.semantic) {
|
|
7116
|
+
if (!workspaceId) {
|
|
7117
|
+
throw new Error("--semantic searches one workspace at a time: pass --workspace <slug>.");
|
|
7118
|
+
}
|
|
7119
|
+
const knowledge = await client.search.knowledge({
|
|
7120
|
+
query,
|
|
7121
|
+
workspaceId,
|
|
7122
|
+
limit,
|
|
7123
|
+
sourceTypes: parseTypes(options.types)
|
|
7124
|
+
});
|
|
7125
|
+
if (useJson) {
|
|
7126
|
+
console.log(JSON.stringify(knowledge, null, 2));
|
|
7127
|
+
return;
|
|
7128
|
+
}
|
|
7129
|
+
if (knowledge.results.length === 0) {
|
|
7130
|
+
console.log(chalk9.gray(`Nothing about "${knowledge.query}" in the Knowledge index.`));
|
|
7131
|
+
return;
|
|
7132
|
+
}
|
|
7133
|
+
console.log(chalk9.bold(`
|
|
7134
|
+
About "${knowledge.query}"`));
|
|
7135
|
+
for (const row of knowledge.results) {
|
|
7136
|
+
console.log(
|
|
7137
|
+
` ${chalk9.white(row.title)} ${chalk9.gray(`\xB7 ${row.sourceType} \xB7 ${Math.round(row.similarity * 100)}%`)}`
|
|
7138
|
+
);
|
|
7139
|
+
console.log(chalk9.gray(` ${row.sourceId} ${row.url}`));
|
|
7140
|
+
if (row.snippet) console.log(` ${row.snippet}`);
|
|
7141
|
+
}
|
|
7142
|
+
console.log();
|
|
7143
|
+
return;
|
|
7144
|
+
}
|
|
6704
7145
|
const result = await client.search.global({ query, workspaceId, limit });
|
|
6705
7146
|
if (useJson) {
|
|
6706
7147
|
console.log(JSON.stringify(result, null, 2));
|
|
6707
7148
|
return;
|
|
6708
7149
|
}
|
|
6709
7150
|
if (result.results.length === 0) {
|
|
6710
|
-
console.log(
|
|
7151
|
+
console.log(chalk9.gray(`No matches for "${result.query}".`));
|
|
6711
7152
|
return;
|
|
6712
7153
|
}
|
|
6713
7154
|
const byType = /* @__PURE__ */ new Map();
|
|
@@ -6717,14 +7158,14 @@ function createSearchCommand() {
|
|
|
6717
7158
|
byType.set(r.type, bucket);
|
|
6718
7159
|
}
|
|
6719
7160
|
for (const [type, rows] of byType) {
|
|
6720
|
-
console.log(
|
|
7161
|
+
console.log(chalk9.bold(`
|
|
6721
7162
|
${TYPE_LABELS[type] ?? type}`));
|
|
6722
7163
|
for (const row of rows) {
|
|
6723
|
-
const parts = [
|
|
6724
|
-
if (row.subtitle) parts.push(
|
|
6725
|
-
if (row.workspace) parts.push(
|
|
6726
|
-
console.log(` ${parts.join(
|
|
6727
|
-
console.log(
|
|
7164
|
+
const parts = [chalk9.white(row.title)];
|
|
7165
|
+
if (row.subtitle) parts.push(chalk9.gray(row.subtitle));
|
|
7166
|
+
if (row.workspace) parts.push(chalk9.cyan(`@${row.workspace.slug}`));
|
|
7167
|
+
console.log(` ${parts.join(chalk9.gray(" \xB7 "))}`);
|
|
7168
|
+
console.log(chalk9.gray(` ${row.id}${row.url ? ` ${row.url}` : ""}`));
|
|
6728
7169
|
}
|
|
6729
7170
|
}
|
|
6730
7171
|
console.log();
|
|
@@ -7501,7 +7942,7 @@ function parseMessagesFile(raw) {
|
|
|
7501
7942
|
|
|
7502
7943
|
// src/commands/workspaces.ts
|
|
7503
7944
|
import { Command as Command25 } from "commander";
|
|
7504
|
-
import
|
|
7945
|
+
import chalk10 from "chalk";
|
|
7505
7946
|
function createWorkspacesCommand() {
|
|
7506
7947
|
const workspaces = new Command25("workspaces").description("Manage workspaces");
|
|
7507
7948
|
workspaces.command("list").description("List all workspaces").action(async (_options, cmd) => {
|
|
@@ -7516,7 +7957,7 @@ function createWorkspacesCommand() {
|
|
|
7516
7957
|
const config = getConfig();
|
|
7517
7958
|
outputWorkspacesPretty(workspaces2);
|
|
7518
7959
|
if (config.defaultWorkspaceSlug) {
|
|
7519
|
-
console.log(
|
|
7960
|
+
console.log(chalk10.gray(`Default workspace: ${config.defaultWorkspaceSlug}`));
|
|
7520
7961
|
}
|
|
7521
7962
|
}
|
|
7522
7963
|
} catch (error) {
|
|
@@ -7529,10 +7970,10 @@ function createWorkspacesCommand() {
|
|
|
7529
7970
|
const workspaces2 = await client.workspaces.list();
|
|
7530
7971
|
const workspace = workspaces2.find((w) => w.slug === slug);
|
|
7531
7972
|
if (!workspace) {
|
|
7532
|
-
console.error(
|
|
7533
|
-
console.log(
|
|
7973
|
+
console.error(chalk10.red(`Workspace with slug "${slug}" not found.`));
|
|
7974
|
+
console.log(chalk10.gray("Available workspaces:"));
|
|
7534
7975
|
workspaces2.forEach((w) => {
|
|
7535
|
-
console.log(
|
|
7976
|
+
console.log(chalk10.gray(` - ${w.slug} (${w.name})`));
|
|
7536
7977
|
});
|
|
7537
7978
|
process.exit(1);
|
|
7538
7979
|
}
|
|
@@ -7540,7 +7981,7 @@ function createWorkspacesCommand() {
|
|
|
7540
7981
|
defaultWorkspaceId: workspace.id,
|
|
7541
7982
|
defaultWorkspaceSlug: workspace.slug
|
|
7542
7983
|
});
|
|
7543
|
-
console.log(
|
|
7984
|
+
console.log(chalk10.green(`Default workspace set to: ${workspace.name} (${workspace.slug})`));
|
|
7544
7985
|
} catch (error) {
|
|
7545
7986
|
handleError(error);
|
|
7546
7987
|
}
|
|
@@ -7568,20 +8009,20 @@ function createWorkspacesCommand() {
|
|
|
7568
8009
|
return;
|
|
7569
8010
|
}
|
|
7570
8011
|
if (members.length === 0) {
|
|
7571
|
-
console.log(
|
|
8012
|
+
console.log(chalk10.gray("No members found."));
|
|
7572
8013
|
return;
|
|
7573
8014
|
}
|
|
7574
|
-
console.log(
|
|
8015
|
+
console.log(chalk10.bold(`
|
|
7575
8016
|
Members (${members.length})
|
|
7576
8017
|
`));
|
|
7577
8018
|
for (const m of members) {
|
|
7578
8019
|
const label = m.name ?? m.email ?? m.id;
|
|
7579
|
-
const via = m.source === "team" ?
|
|
8020
|
+
const via = m.source === "team" ? chalk10.gray(
|
|
7580
8021
|
` via team${m.teams.length ? `: ${m.teams.map((t) => t.name).join(", ")}` : ""}` + (m.teamRole ? ` [team ${m.teamRole}]` : "")
|
|
7581
8022
|
) : "";
|
|
7582
|
-
console.log(`${
|
|
7583
|
-
if (m.email) console.log(
|
|
7584
|
-
console.log(
|
|
8023
|
+
console.log(`${chalk10.bold(label)} ${chalk10.gray(`(${m.role})`)}${via}`);
|
|
8024
|
+
if (m.email) console.log(chalk10.gray(` ${m.email}`));
|
|
8025
|
+
console.log(chalk10.gray(` mention: ${m.mentionSyntax}`));
|
|
7585
8026
|
console.log();
|
|
7586
8027
|
}
|
|
7587
8028
|
} catch (error) {
|