exponential-cli 1.22.0 → 1.25.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 +67 -0
- package/dist/index.js +1013 -130
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/program.ts
|
|
4
|
-
import { Command as
|
|
4
|
+
import { Command as Command28 } from "commander";
|
|
5
5
|
|
|
6
6
|
// src/commands/auth.ts
|
|
7
7
|
import { Command } from "commander";
|
|
@@ -93,12 +93,14 @@ function handleError(error, json = false) {
|
|
|
93
93
|
message = "Access denied";
|
|
94
94
|
break;
|
|
95
95
|
}
|
|
96
|
+
const property = error.data?.property;
|
|
96
97
|
if (json) {
|
|
97
98
|
console.log(JSON.stringify({
|
|
98
99
|
error: {
|
|
99
100
|
code,
|
|
100
101
|
message,
|
|
101
|
-
suggestion
|
|
102
|
+
suggestion,
|
|
103
|
+
...property ? { property } : {}
|
|
102
104
|
}
|
|
103
105
|
}, null, 2));
|
|
104
106
|
} else {
|
|
@@ -1394,20 +1396,115 @@ Pipeline Stages (${stages.length})`));
|
|
|
1394
1396
|
function outputPageJson(page) {
|
|
1395
1397
|
console.log(JSON.stringify(page, null, 2));
|
|
1396
1398
|
}
|
|
1399
|
+
function formatBytes(bytes) {
|
|
1400
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
1401
|
+
return `${(bytes / 1024).toFixed(bytes < 10 * 1024 ? 1 : 0)} KB`;
|
|
1402
|
+
}
|
|
1403
|
+
function formatDay(value) {
|
|
1404
|
+
return new Date(value).toISOString().slice(0, 10);
|
|
1405
|
+
}
|
|
1397
1406
|
function outputPagePretty(page) {
|
|
1398
1407
|
console.log(chalk3.gray("\u2500".repeat(50)));
|
|
1399
1408
|
console.log(`
|
|
1400
1409
|
${chalk3.bold(page.title)}`);
|
|
1401
|
-
console.log(chalk3.gray(` ID: ${page.id}`));
|
|
1410
|
+
console.log(chalk3.gray(` ID: ${page.id} v${page.docVersion}`));
|
|
1402
1411
|
if (page.project) {
|
|
1403
1412
|
console.log(` ${chalk3.gray("Project:")} ${page.project.name}`);
|
|
1404
1413
|
}
|
|
1414
|
+
if (page.asOf || page.source) {
|
|
1415
|
+
const parts = [];
|
|
1416
|
+
if (page.asOf) parts.push(`As of ${formatDay(page.asOf)}`);
|
|
1417
|
+
if (page.source) parts.push(`Source: ${page.source}`);
|
|
1418
|
+
console.log(` ${chalk3.gray(parts.join(" \xB7 "))}`);
|
|
1419
|
+
}
|
|
1420
|
+
if (typeof page.bodyBytes === "number") {
|
|
1421
|
+
const scope = page.section ? ` (showing section "${page.section.text}")` : "";
|
|
1422
|
+
console.log(chalk3.gray(` Body: ${formatBytes(page.bodyBytes)}${scope}`));
|
|
1423
|
+
}
|
|
1424
|
+
if (page.outline) {
|
|
1425
|
+
console.log();
|
|
1426
|
+
if (page.outline.length === 0) console.log(chalk3.gray(" (no headings)"));
|
|
1427
|
+
for (const h of page.outline) {
|
|
1428
|
+
console.log(
|
|
1429
|
+
` ${" ".repeat(h.level - 1)}${chalk3.gray("#".repeat(h.level))} ${h.text} ${chalk3.gray(`L${h.line + 1}`)}`
|
|
1430
|
+
);
|
|
1431
|
+
}
|
|
1432
|
+
console.log();
|
|
1433
|
+
return;
|
|
1434
|
+
}
|
|
1405
1435
|
if (page.body) {
|
|
1406
1436
|
console.log(`
|
|
1407
1437
|
${page.body}
|
|
1408
1438
|
`);
|
|
1409
1439
|
}
|
|
1410
1440
|
}
|
|
1441
|
+
function outputPageSearchPretty(result) {
|
|
1442
|
+
if (result.results.length === 0) {
|
|
1443
|
+
console.log(chalk3.gray(`No pages about "${result.query}".`));
|
|
1444
|
+
return;
|
|
1445
|
+
}
|
|
1446
|
+
console.log(chalk3.bold(`
|
|
1447
|
+
Pages about "${result.query}" (${result.results.length})`));
|
|
1448
|
+
console.log(chalk3.gray("\u2500".repeat(50)));
|
|
1449
|
+
for (const r of result.results) {
|
|
1450
|
+
const score = r.similarity === null ? chalk3.gray("text match") : chalk3.gray(`${Math.round(r.similarity * 100)}%`);
|
|
1451
|
+
console.log(` ${chalk3.bold(r.title)} ${score}`);
|
|
1452
|
+
console.log(chalk3.gray(` ID: ${r.id} ${r.url}`));
|
|
1453
|
+
if (r.snippet) console.log(` ${r.snippet}`);
|
|
1454
|
+
}
|
|
1455
|
+
console.log();
|
|
1456
|
+
}
|
|
1457
|
+
function outputPageHistoryPretty(history) {
|
|
1458
|
+
if (history.revisions.length === 0) {
|
|
1459
|
+
console.log(chalk3.gray("No revisions yet."));
|
|
1460
|
+
return;
|
|
1461
|
+
}
|
|
1462
|
+
const n = history.revisions.length;
|
|
1463
|
+
console.log(chalk3.bold(`
|
|
1464
|
+
History (${n} revision${n === 1 ? "" : "s"})`));
|
|
1465
|
+
console.log(chalk3.gray("\u2500".repeat(50)));
|
|
1466
|
+
for (const r of history.revisions) {
|
|
1467
|
+
const when = new Date(r.updatedAt).toISOString().replace("T", " ").slice(0, 16);
|
|
1468
|
+
const who = r.kind === "baseline" ? "before history" : r.authorHidden ? "a member" : r.author?.name ?? "automated";
|
|
1469
|
+
console.log(
|
|
1470
|
+
` ${chalk3.gray(when)} ${chalk3.bold(who)} ${chalk3.cyan(r.kind)} v${r.docVersion} ${chalk3.gray(formatBytes(r.bodyBytes))}`
|
|
1471
|
+
);
|
|
1472
|
+
console.log(chalk3.gray(` ${r.id} "${r.title}"`));
|
|
1473
|
+
if (r.note) console.log(` ${r.note}`);
|
|
1474
|
+
else if (r.kind === "markdown" || r.kind === "restore") console.log(chalk3.gray(" (no reason given)"));
|
|
1475
|
+
}
|
|
1476
|
+
if (history.nextCursor) {
|
|
1477
|
+
console.log(chalk3.gray(`
|
|
1478
|
+
More: --cursor ${history.nextCursor}`));
|
|
1479
|
+
}
|
|
1480
|
+
console.log();
|
|
1481
|
+
}
|
|
1482
|
+
function outputPageDiffPretty(diff) {
|
|
1483
|
+
const side = (s) => s.revisionId ? `${s.revisionId} (v${s.docVersion})` : s.createdAt ? "current" : "(empty)";
|
|
1484
|
+
console.log(chalk3.gray(`${side(diff.from)} \u2192 ${side(diff.to)}`));
|
|
1485
|
+
if (diff.titleChanged) {
|
|
1486
|
+
console.log(chalk3.red(`- title: ${diff.from.title}`));
|
|
1487
|
+
console.log(chalk3.green(`+ title: ${diff.to.title}`));
|
|
1488
|
+
}
|
|
1489
|
+
if (diff.provenanceChanged) {
|
|
1490
|
+
const prov = (s) => `as of ${s.asOf ? formatDay(s.asOf) : "\u2014"} \xB7 source ${s.source ?? "\u2014"}`;
|
|
1491
|
+
console.log(chalk3.red(`- ${prov(diff.from)}`));
|
|
1492
|
+
console.log(chalk3.green(`+ ${prov(diff.to)}`));
|
|
1493
|
+
}
|
|
1494
|
+
if (!diff.unified) {
|
|
1495
|
+
console.log(chalk3.gray("No changes to the body."));
|
|
1496
|
+
return;
|
|
1497
|
+
}
|
|
1498
|
+
console.log(chalk3.gray(`+${diff.stats.added} \u2212${diff.stats.removed}
|
|
1499
|
+
`));
|
|
1500
|
+
for (const line of diff.unified.split("\n")) {
|
|
1501
|
+
if (line.startsWith("+++") || line.startsWith("---") || line.startsWith("@@")) {
|
|
1502
|
+
console.log(chalk3.gray(line));
|
|
1503
|
+
} else if (line.startsWith("+")) console.log(chalk3.green(line));
|
|
1504
|
+
else if (line.startsWith("-")) console.log(chalk3.red(line));
|
|
1505
|
+
else console.log(line);
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1411
1508
|
function outputPagesJson(pages) {
|
|
1412
1509
|
console.log(JSON.stringify({ pages, total: pages.length }, null, 2));
|
|
1413
1510
|
}
|
|
@@ -2514,6 +2611,9 @@ function hostnameOf(url) {
|
|
|
2514
2611
|
return null;
|
|
2515
2612
|
}
|
|
2516
2613
|
}
|
|
2614
|
+
function formatResourceTags(tags) {
|
|
2615
|
+
return `Tags: ${tags.join(", ")}`;
|
|
2616
|
+
}
|
|
2517
2617
|
function transformResource(r) {
|
|
2518
2618
|
return {
|
|
2519
2619
|
id: r.id,
|
|
@@ -2537,6 +2637,7 @@ function outputResourcePretty(resource) {
|
|
|
2537
2637
|
console.log(` ${badge} ${chalk3.bold(resource.title)}`);
|
|
2538
2638
|
if (resource.url) console.log(chalk3.gray(` ${resource.url}`));
|
|
2539
2639
|
if (resource.description) console.log(` ${resource.description}`);
|
|
2640
|
+
if (resource.tags?.length) console.log(chalk3.cyan(` ${formatResourceTags(resource.tags)}`));
|
|
2540
2641
|
console.log(chalk3.gray(` ID: ${resource.id}`));
|
|
2541
2642
|
}
|
|
2542
2643
|
function outputResourcesJson(resources, filters = {}) {
|
|
@@ -2558,10 +2659,134 @@ ${heading} (${resources.length} total)`));
|
|
|
2558
2659
|
const host = hostnameOf(r.url);
|
|
2559
2660
|
console.log(` ${chalk3.bold(r.title)}${host ? chalk3.gray(` ${host}`) : ""} ${chalk3.gray(when.toLocaleDateString())}`);
|
|
2560
2661
|
if (r.description) console.log(chalk3.gray(` ${r.description}`));
|
|
2662
|
+
if (r.tags?.length) console.log(chalk3.cyan(` ${formatResourceTags(r.tags)}`));
|
|
2561
2663
|
console.log(chalk3.gray(` ID: ${r.id}`));
|
|
2562
2664
|
}
|
|
2563
2665
|
console.log();
|
|
2564
2666
|
}
|
|
2667
|
+
function outputDatabaseJson(database) {
|
|
2668
|
+
console.log(JSON.stringify(database, null, 2));
|
|
2669
|
+
}
|
|
2670
|
+
function describeProperty(p) {
|
|
2671
|
+
const options = p.options?.length ? ` [${p.options.map((o) => o.name).join(", ")}]` : "";
|
|
2672
|
+
return ` ${p.name} ${chalk3.gray(`${p.type} ${p.id}`)}${chalk3.gray(options)}`;
|
|
2673
|
+
}
|
|
2674
|
+
function outputDatabasePretty(database) {
|
|
2675
|
+
console.log(chalk3.gray("\u2500".repeat(50)));
|
|
2676
|
+
console.log(`
|
|
2677
|
+
${chalk3.bold(database.name)}`);
|
|
2678
|
+
console.log(chalk3.gray(` ID: ${database.id}`));
|
|
2679
|
+
console.log(` ${chalk3.gray("Page:")} ${database.page.title} ${chalk3.gray(database.page.id)}`);
|
|
2680
|
+
const facts = [];
|
|
2681
|
+
if (typeof database.rowCount === "number") facts.push(`${database.rowCount} row${database.rowCount === 1 ? "" : "s"}`);
|
|
2682
|
+
if (database.detachedAt) facts.push(`detached ${formatDate(new Date(database.detachedAt))} \u2014 block is out of the page`);
|
|
2683
|
+
if (facts.length) console.log(chalk3.gray(` ${facts.join(" \xB7 ")}`));
|
|
2684
|
+
console.log(`
|
|
2685
|
+
${chalk3.gray("Properties")}`);
|
|
2686
|
+
for (const p of database.properties) console.log(describeProperty(p));
|
|
2687
|
+
const view = database.view;
|
|
2688
|
+
const viewParts = [];
|
|
2689
|
+
if (view.sort) viewParts.push(`sort ${view.sort.propertyId} ${view.sort.direction}`);
|
|
2690
|
+
if (view.filters.length) viewParts.push(`${view.filters.length} filter${view.filters.length === 1 ? "" : "s"}`);
|
|
2691
|
+
if (view.hiddenPropertyIds.length) viewParts.push(`${view.hiddenPropertyIds.length} hidden`);
|
|
2692
|
+
if (viewParts.length) console.log(chalk3.gray(`
|
|
2693
|
+
View: ${viewParts.join(" \xB7 ")}`));
|
|
2694
|
+
console.log();
|
|
2695
|
+
}
|
|
2696
|
+
function outputDatabasesPretty(databases) {
|
|
2697
|
+
if (databases.length === 0) {
|
|
2698
|
+
console.log(chalk3.gray("No databases on this page."));
|
|
2699
|
+
return;
|
|
2700
|
+
}
|
|
2701
|
+
console.log(chalk3.bold(`
|
|
2702
|
+
Databases (${databases.length})`));
|
|
2703
|
+
console.log(chalk3.gray("\u2500".repeat(50)));
|
|
2704
|
+
for (const d of databases) {
|
|
2705
|
+
const state = d.detachedAt ? chalk3.yellow(" detached") : "";
|
|
2706
|
+
const rows = typeof d.rowCount === "number" ? chalk3.gray(` ${d.rowCount} rows`) : "";
|
|
2707
|
+
console.log(` ${d.name} ${chalk3.gray(d.id)}${rows}${state}`);
|
|
2708
|
+
}
|
|
2709
|
+
console.log();
|
|
2710
|
+
}
|
|
2711
|
+
function formatCell(def, value) {
|
|
2712
|
+
if (value === null || value === void 0 || value === "") return chalk3.gray("\u2014");
|
|
2713
|
+
if (Array.isArray(value)) {
|
|
2714
|
+
if (value.length === 0) return chalk3.gray("\u2014");
|
|
2715
|
+
return value.map((v) => formatCell(def, v)).join(", ");
|
|
2716
|
+
}
|
|
2717
|
+
if (def?.options) {
|
|
2718
|
+
return def.options.find((o) => o.id === value)?.name ?? String(value);
|
|
2719
|
+
}
|
|
2720
|
+
if (typeof value === "boolean") return value ? "Yes" : "No";
|
|
2721
|
+
return String(value);
|
|
2722
|
+
}
|
|
2723
|
+
function outputRowJson(row) {
|
|
2724
|
+
console.log(JSON.stringify(row, null, 2));
|
|
2725
|
+
}
|
|
2726
|
+
function outputRowPretty(row, database) {
|
|
2727
|
+
console.log(`
|
|
2728
|
+
${chalk3.bold(row.title || "Untitled")} ${chalk3.gray(row.id)}`);
|
|
2729
|
+
const defs = database?.properties.filter((p) => p.type !== "title") ?? [];
|
|
2730
|
+
if (defs.length) {
|
|
2731
|
+
for (const def of defs) {
|
|
2732
|
+
console.log(` ${chalk3.gray(`${def.name}:`)} ${formatCell(def, row.values[def.id])}`);
|
|
2733
|
+
}
|
|
2734
|
+
} else {
|
|
2735
|
+
for (const [key, value] of Object.entries(row.values)) {
|
|
2736
|
+
console.log(` ${chalk3.gray(`${key}:`)} ${formatCell(void 0, value)}`);
|
|
2737
|
+
}
|
|
2738
|
+
}
|
|
2739
|
+
console.log(chalk3.gray(` Read the page: exponential pages get ${row.id}`));
|
|
2740
|
+
console.log();
|
|
2741
|
+
}
|
|
2742
|
+
function outputRowsPretty(page, database) {
|
|
2743
|
+
if (page.rows.length === 0) {
|
|
2744
|
+
console.log(chalk3.gray(`No rows in ${database.name}.`));
|
|
2745
|
+
return;
|
|
2746
|
+
}
|
|
2747
|
+
const byId = new Map(database.properties.map((p) => [p.id, p]));
|
|
2748
|
+
const columns = page.columns.map((id) => byId.get(id)).filter((p) => !!p && p.type !== "title");
|
|
2749
|
+
console.log(chalk3.bold(`
|
|
2750
|
+
${database.name} (${page.rows.length} row${page.rows.length === 1 ? "" : "s"}${page.nextCursor ? ", more" : ""})`));
|
|
2751
|
+
console.log(chalk3.gray("\u2500".repeat(50)));
|
|
2752
|
+
for (const row of page.rows) {
|
|
2753
|
+
const cells = columns.map((c) => `${chalk3.gray(`${c.name}:`)} ${formatCell(c, row.values[c.id])}`);
|
|
2754
|
+
console.log(` ${chalk3.bold(row.title || "Untitled")} ${chalk3.gray(row.id)}`);
|
|
2755
|
+
if (cells.length) console.log(` ${cells.join(" ")}`);
|
|
2756
|
+
}
|
|
2757
|
+
if (page.nextCursor) console.log(chalk3.gray(`
|
|
2758
|
+
More: --cursor ${page.nextCursor}`));
|
|
2759
|
+
console.log();
|
|
2760
|
+
}
|
|
2761
|
+
function outputCsvSkipped(skipped) {
|
|
2762
|
+
if (skipped.length === 0) return;
|
|
2763
|
+
console.log(chalk3.yellow(`
|
|
2764
|
+
${skipped.length} row${skipped.length === 1 ? "" : "s"} not imported:`));
|
|
2765
|
+
for (const row of skipped) {
|
|
2766
|
+
const why = row.errors.map((e) => `${e.propertyName} ${e.reason}`).join("; ");
|
|
2767
|
+
console.log(` row ${row.index + 1}: ${why}`);
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
function outputCsvPreviewPretty(preview) {
|
|
2771
|
+
console.log(chalk3.bold(`
|
|
2772
|
+
CSV preview: ${preview.importable} of ${preview.total} row${preview.total === 1 ? "" : "s"} would be created`));
|
|
2773
|
+
console.log(chalk3.gray("\u2500".repeat(50)));
|
|
2774
|
+
for (const column of preview.columns) {
|
|
2775
|
+
const to = column.target.kind === "skip" ? chalk3.gray("skipped") : column.target.kind === "new" ? `${chalk3.green("new")} ${column.propertyName} (${column.type})` : `${column.propertyName} (${column.type})`;
|
|
2776
|
+
console.log(` ${chalk3.gray(`${column.header} \u2192`)} ${to}`);
|
|
2777
|
+
}
|
|
2778
|
+
const newOptions = Object.entries(preview.newOptions ?? {});
|
|
2779
|
+
if (newOptions.length) {
|
|
2780
|
+
console.log(chalk3.green("\n Options the import will add:"));
|
|
2781
|
+
for (const [columnId, names] of newOptions) {
|
|
2782
|
+
const column = preview.columns.find((c) => (c.target.kind === "property" ? c.target.propertyId : `new:${c.propertyName ?? ""}`) === columnId);
|
|
2783
|
+
console.log(` ${column?.propertyName ?? columnId}: ${names.join(", ")}`);
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2786
|
+
const skipped = preview.rows.filter((r) => r.errors.length > 0).map((r) => ({ index: r.index, errors: r.errors }));
|
|
2787
|
+
outputCsvSkipped(skipped);
|
|
2788
|
+
console.log(chalk3.gray("\n Nothing was created. Run again without --dry-run to import."));
|
|
2789
|
+
}
|
|
2565
2790
|
|
|
2566
2791
|
// src/commands/actions.ts
|
|
2567
2792
|
var VALID_PRIORITIES = [
|
|
@@ -3102,7 +3327,7 @@ function createContactsCommand() {
|
|
|
3102
3327
|
return contacts;
|
|
3103
3328
|
}
|
|
3104
3329
|
|
|
3105
|
-
// src/commands/
|
|
3330
|
+
// src/commands/databases.ts
|
|
3106
3331
|
import { Command as Command4 } from "commander";
|
|
3107
3332
|
import chalk4 from "chalk";
|
|
3108
3333
|
|
|
@@ -3132,7 +3357,436 @@ function parseDate(value) {
|
|
|
3132
3357
|
return date;
|
|
3133
3358
|
}
|
|
3134
3359
|
|
|
3360
|
+
// src/commands/databases.ts
|
|
3361
|
+
var ADDABLE_TYPES = [
|
|
3362
|
+
"text",
|
|
3363
|
+
"number",
|
|
3364
|
+
"select",
|
|
3365
|
+
"multiSelect",
|
|
3366
|
+
"date",
|
|
3367
|
+
"checkbox",
|
|
3368
|
+
"url",
|
|
3369
|
+
"person",
|
|
3370
|
+
"createdTime",
|
|
3371
|
+
"lastEditedTime",
|
|
3372
|
+
"createdBy"
|
|
3373
|
+
];
|
|
3374
|
+
function collect(value, previous) {
|
|
3375
|
+
return [...previous, value];
|
|
3376
|
+
}
|
|
3377
|
+
function parseLimit(value) {
|
|
3378
|
+
if (value === void 0) return void 0;
|
|
3379
|
+
const n = Number(value);
|
|
3380
|
+
if (!Number.isInteger(n) || n < 1) {
|
|
3381
|
+
throw new Error(`--limit must be a positive integer, got "${value}"`);
|
|
3382
|
+
}
|
|
3383
|
+
return n;
|
|
3384
|
+
}
|
|
3385
|
+
function parseSet(pairs, cleared = []) {
|
|
3386
|
+
const values = {};
|
|
3387
|
+
for (const pair of pairs) {
|
|
3388
|
+
const at = pair.indexOf("=");
|
|
3389
|
+
if (at <= 0) {
|
|
3390
|
+
throw new Error(`--set expects Property=value, got "${pair}"`);
|
|
3391
|
+
}
|
|
3392
|
+
const key = pair.slice(0, at).trim();
|
|
3393
|
+
const raw = pair.slice(at + 1);
|
|
3394
|
+
values[key] = raw === "" ? null : raw;
|
|
3395
|
+
}
|
|
3396
|
+
for (const key of cleared) values[key.trim()] = null;
|
|
3397
|
+
return values;
|
|
3398
|
+
}
|
|
3399
|
+
function parseCsvMapping(database, flags) {
|
|
3400
|
+
const mapping = {};
|
|
3401
|
+
const split = (pair, flag) => {
|
|
3402
|
+
const at = pair.indexOf("=");
|
|
3403
|
+
if (at <= 0) throw new Error(`${flag} expects Column=value, got "${pair}"`);
|
|
3404
|
+
return [pair.slice(0, at).trim(), pair.slice(at + 1).trim()];
|
|
3405
|
+
};
|
|
3406
|
+
for (const pair of flags.map) {
|
|
3407
|
+
const [column, property] = split(pair, "--map");
|
|
3408
|
+
mapping[column] = { kind: "property", propertyId: resolveProperty(database, property).id };
|
|
3409
|
+
}
|
|
3410
|
+
for (const pair of flags.new) {
|
|
3411
|
+
const [column, spec] = split(pair, "--new");
|
|
3412
|
+
const colon = spec.indexOf(":");
|
|
3413
|
+
const name = colon > 0 ? spec.slice(0, colon).trim() : column;
|
|
3414
|
+
const type = colon > 0 ? spec.slice(colon + 1).trim() : spec;
|
|
3415
|
+
mapping[column] = { kind: "new", name, type: parsePropertyType(type) };
|
|
3416
|
+
}
|
|
3417
|
+
for (const column of flags.skip) mapping[column.trim()] = { kind: "skip" };
|
|
3418
|
+
return mapping;
|
|
3419
|
+
}
|
|
3420
|
+
function parsePropertyType(value) {
|
|
3421
|
+
if (ADDABLE_TYPES.includes(value)) return value;
|
|
3422
|
+
throw new Error(`--type must be one of: ${ADDABLE_TYPES.join(", ")} (got "${value}")`);
|
|
3423
|
+
}
|
|
3424
|
+
function parseOptions(value) {
|
|
3425
|
+
if (value === void 0) return void 0;
|
|
3426
|
+
return value.split(",").map((part) => part.trim()).filter(Boolean).map((part) => {
|
|
3427
|
+
const at = part.lastIndexOf(":");
|
|
3428
|
+
if (at > 0) {
|
|
3429
|
+
return { name: part.slice(0, at).trim(), color: part.slice(at + 1).trim() };
|
|
3430
|
+
}
|
|
3431
|
+
return { name: part };
|
|
3432
|
+
});
|
|
3433
|
+
}
|
|
3434
|
+
function parseFilter(expression) {
|
|
3435
|
+
const match = /^\s*(.+?)\s*(!=|>=|<=|=|~|>|<| in )\s*(.*)$/.exec(expression);
|
|
3436
|
+
if (!match) throw new Error(`--filter expects Property=value (or !=, ~, >, <, in), got "${expression}"`);
|
|
3437
|
+
const [, property, operator, value] = match;
|
|
3438
|
+
switch (operator.trim()) {
|
|
3439
|
+
case "=":
|
|
3440
|
+
return value === "" ? { property, op: "isEmpty" } : { property, op: "eq", value };
|
|
3441
|
+
case "!=":
|
|
3442
|
+
return value === "" ? { property, op: "isNotEmpty" } : { property, op: "neq", value };
|
|
3443
|
+
case "~":
|
|
3444
|
+
return { property, op: "contains", value };
|
|
3445
|
+
case ">":
|
|
3446
|
+
return { property, op: "gt", value };
|
|
3447
|
+
case "<":
|
|
3448
|
+
return { property, op: "lt", value };
|
|
3449
|
+
case ">=":
|
|
3450
|
+
case "<=":
|
|
3451
|
+
throw new Error(`--filter does not support "${operator.trim()}" (only > and <), got "${expression}"`);
|
|
3452
|
+
case "in":
|
|
3453
|
+
return { property, op: "anyOf", value: value.split(",").map((s) => s.trim()).filter(Boolean) };
|
|
3454
|
+
default:
|
|
3455
|
+
throw new Error(`Unknown filter operator "${operator}"`);
|
|
3456
|
+
}
|
|
3457
|
+
}
|
|
3458
|
+
function parseSort(value) {
|
|
3459
|
+
if (value === void 0) return void 0;
|
|
3460
|
+
const at = value.lastIndexOf(":");
|
|
3461
|
+
const property = at > 0 ? value.slice(0, at).trim() : value.trim();
|
|
3462
|
+
const direction = at > 0 ? value.slice(at + 1).trim().toLowerCase() : "asc";
|
|
3463
|
+
if (direction !== "asc" && direction !== "desc") {
|
|
3464
|
+
throw new Error(`--sort expects Property or Property:asc|desc, got "${value}"`);
|
|
3465
|
+
}
|
|
3466
|
+
return { property, direction };
|
|
3467
|
+
}
|
|
3468
|
+
function resolveProperty(database, key) {
|
|
3469
|
+
const byId = database.properties.find((p) => p.id === key);
|
|
3470
|
+
if (byId) return byId;
|
|
3471
|
+
const wanted = key.trim().toLowerCase();
|
|
3472
|
+
const byName = database.properties.filter((p) => p.name.trim().toLowerCase() === wanted);
|
|
3473
|
+
if (byName.length === 1) return byName[0];
|
|
3474
|
+
throw new Error(
|
|
3475
|
+
`No property "${key}" on ${database.name}. Properties: ${database.properties.map((p) => p.name).join(", ")}`
|
|
3476
|
+
);
|
|
3477
|
+
}
|
|
3478
|
+
function buildListView(database, filters, sort) {
|
|
3479
|
+
if (filters.length === 0 && sort === void 0) return void 0;
|
|
3480
|
+
const parsedSort = parseSort(sort);
|
|
3481
|
+
return {
|
|
3482
|
+
...database.view,
|
|
3483
|
+
sort: parsedSort ? { propertyId: resolveProperty(database, parsedSort.property).id, direction: parsedSort.direction } : database.view.sort,
|
|
3484
|
+
filters: filters.length === 0 ? database.view.filters : filters.map((expression) => {
|
|
3485
|
+
const { property, op, value } = parseFilter(expression);
|
|
3486
|
+
return { propertyId: resolveProperty(database, property).id, op, ...value !== void 0 ? { value } : {} };
|
|
3487
|
+
})
|
|
3488
|
+
};
|
|
3489
|
+
}
|
|
3490
|
+
function createDatabasesCommand() {
|
|
3491
|
+
const databases = new Command4("databases").description(
|
|
3492
|
+
'Databases: typed tables inside pages. A database is a block in a page body, owned by that page; each row is a page of its own (read it with "pages get <rowId>"). Writes are typed per property \u2014 a bad value is refused naming the property. Not a work tracker: use tickets, actions and projects for work.'
|
|
3493
|
+
);
|
|
3494
|
+
databases.command("create").description(
|
|
3495
|
+
"Create a database on a page (with a title property) and place its block at the end of the page body. --no-place leaves the body alone and prints the marker to put in yourself."
|
|
3496
|
+
).requiredOption("--page <id>", "The page that will hold the database (you need edit access)").requiredOption("--name <name>", "Database name, e.g. Metrics").option("--no-place", "Do not append the marker to the page body").option("-n, --note <text>", "Why: recorded on the page revision that places the block").action(
|
|
3497
|
+
async (options, cmd) => {
|
|
3498
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
3499
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
3500
|
+
try {
|
|
3501
|
+
const client = getClient();
|
|
3502
|
+
const database = await client.databases.create({ pageId: options.page, name: options.name });
|
|
3503
|
+
let placed = false;
|
|
3504
|
+
if (options.place && database.marker) {
|
|
3505
|
+
const page = await client.pages.get(options.page);
|
|
3506
|
+
const body = page.body?.trimEnd();
|
|
3507
|
+
await client.pages.update({
|
|
3508
|
+
id: options.page,
|
|
3509
|
+
body: body ? `${body}
|
|
3510
|
+
|
|
3511
|
+
${database.marker}` : database.marker,
|
|
3512
|
+
baseVersion: page.docVersion,
|
|
3513
|
+
note: options.note ?? `Add the ${database.name} database`
|
|
3514
|
+
});
|
|
3515
|
+
placed = true;
|
|
3516
|
+
}
|
|
3517
|
+
if (useJson) outputDatabaseJson({ ...database, placed });
|
|
3518
|
+
else {
|
|
3519
|
+
console.log(`
|
|
3520
|
+
\u2713 Database created${placed ? ` and placed in "${database.page.title}"` : ""}`);
|
|
3521
|
+
outputDatabasePretty(database);
|
|
3522
|
+
if (!placed && database.marker) {
|
|
3523
|
+
console.log(chalk4.gray(` Put this line in the page body to show it: ${database.marker}
|
|
3524
|
+
`));
|
|
3525
|
+
}
|
|
3526
|
+
}
|
|
3527
|
+
} catch (error) {
|
|
3528
|
+
handleError(error, useJson);
|
|
3529
|
+
}
|
|
3530
|
+
}
|
|
3531
|
+
);
|
|
3532
|
+
databases.command("get <id>").description("One database: its properties, saved view, row count and holding page").action(async (id, _options, cmd) => {
|
|
3533
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
3534
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
3535
|
+
try {
|
|
3536
|
+
const database = await getClient().databases.get(id);
|
|
3537
|
+
if (useJson) outputDatabaseJson(database);
|
|
3538
|
+
else outputDatabasePretty(database);
|
|
3539
|
+
} catch (error) {
|
|
3540
|
+
handleError(error, useJson);
|
|
3541
|
+
}
|
|
3542
|
+
});
|
|
3543
|
+
databases.command("list").description("The databases a page holds, detached ones included (a detached database's block is out of the body; its rows wait 30 days for the purge)").requiredOption("--page <id>", "Page CUID").action(async (options, cmd) => {
|
|
3544
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
3545
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
3546
|
+
try {
|
|
3547
|
+
const list = await getClient().databases.list(options.page);
|
|
3548
|
+
if (useJson) console.log(JSON.stringify(list, null, 2));
|
|
3549
|
+
else outputDatabasesPretty(list);
|
|
3550
|
+
} catch (error) {
|
|
3551
|
+
handleError(error, useJson);
|
|
3552
|
+
}
|
|
3553
|
+
});
|
|
3554
|
+
databases.command("update").description("Rename a database, or replace its saved view whole (JSON: { sort?, filters, hiddenPropertyIds, propertyOrder })").requiredOption("--id <id>", "Database CUID").option("--name <name>", "New name").option("--view <json>", "The whole view as JSON").option("--view-file <path>", 'Read the view JSON from a file ("-" = stdin)').action(
|
|
3555
|
+
async (options, cmd) => {
|
|
3556
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
3557
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
3558
|
+
try {
|
|
3559
|
+
const viewText = readText(options.view, options.viewFile);
|
|
3560
|
+
const view = viewText === void 0 ? void 0 : JSON.parse(viewText);
|
|
3561
|
+
const database = await getClient().databases.update({ id: options.id, name: options.name, view });
|
|
3562
|
+
if (useJson) outputDatabaseJson(database);
|
|
3563
|
+
else {
|
|
3564
|
+
console.log("\n\u2713 Database updated");
|
|
3565
|
+
outputDatabasePretty(database);
|
|
3566
|
+
}
|
|
3567
|
+
} catch (error) {
|
|
3568
|
+
handleError(error, useJson);
|
|
3569
|
+
}
|
|
3570
|
+
}
|
|
3571
|
+
);
|
|
3572
|
+
databases.command("delete <id>").description("Delete a database and every row with it. Removing the block from the page only detaches; this is the delete.").requiredOption("--yes", "Confirm: the rows are pages and they go too").action(async (id, _options, cmd) => {
|
|
3573
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
3574
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
3575
|
+
try {
|
|
3576
|
+
const result = await getClient().databases.delete(id);
|
|
3577
|
+
if (useJson) console.log(JSON.stringify(result, null, 2));
|
|
3578
|
+
else console.log(`
|
|
3579
|
+
\u2713 Database ${result.id} deleted with ${result.rowCount} row${result.rowCount === 1 ? "" : "s"}
|
|
3580
|
+
`);
|
|
3581
|
+
} catch (error) {
|
|
3582
|
+
handleError(error, useJson);
|
|
3583
|
+
}
|
|
3584
|
+
});
|
|
3585
|
+
databases.addCommand(createPropertiesCommand());
|
|
3586
|
+
databases.addCommand(createRowsCommand());
|
|
3587
|
+
return databases;
|
|
3588
|
+
}
|
|
3589
|
+
function createPropertiesCommand() {
|
|
3590
|
+
const properties = new Command4("properties").description(
|
|
3591
|
+
"The schema: add, rename, retype, re-option, remove or reorder properties. Ids are stable \u2014 renaming never rewrites a row. A property is named by id or by name."
|
|
3592
|
+
);
|
|
3593
|
+
properties.command("add <databaseId>").description(`Add a property. Types: ${ADDABLE_TYPES.join(", ")} (title exists from creation; relation arrives with V3).`).requiredOption("--name <name>", "Property name").requiredOption("--type <type>", "Property type").option("--options <list>", 'select/multiSelect options, comma-separated; "Name:color" picks a palette colour').option("--description <text>", "What the property means").action(
|
|
3594
|
+
async (databaseId, options, cmd) => {
|
|
3595
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
3596
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
3597
|
+
try {
|
|
3598
|
+
const result = await getClient().databases.addProperty({
|
|
3599
|
+
id: databaseId,
|
|
3600
|
+
name: options.name,
|
|
3601
|
+
type: parsePropertyType(options.type),
|
|
3602
|
+
description: options.description,
|
|
3603
|
+
options: parseOptions(options.options)
|
|
3604
|
+
});
|
|
3605
|
+
if (useJson) console.log(JSON.stringify(result, null, 2));
|
|
3606
|
+
else {
|
|
3607
|
+
console.log(`
|
|
3608
|
+
\u2713 Property "${result.property.name}" (${result.property.type}) added \u2014 id ${result.property.id}`);
|
|
3609
|
+
outputDatabasePretty(result.database);
|
|
3610
|
+
}
|
|
3611
|
+
} catch (error) {
|
|
3612
|
+
handleError(error, useJson);
|
|
3613
|
+
}
|
|
3614
|
+
}
|
|
3615
|
+
);
|
|
3616
|
+
properties.command("update <databaseId> <property>").description('Rename, retype, re-option or describe a property. --options replaces the whole list; "id=Name" keeps an existing option under a new name.').option("--name <name>", "New name").option("--type <type>", "New type (not for the title property)").option("--options <list>", 'The full option list, comma-separated; prefix "optionId=" to keep an existing option').option("--description <text>", "New description").option("--clear-description", "Remove the description").action(
|
|
3617
|
+
async (databaseId, property, options, cmd) => {
|
|
3618
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
3619
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
3620
|
+
try {
|
|
3621
|
+
const parsedOptions = parseOptions(options.options)?.map((option) => {
|
|
3622
|
+
const at = option.name.indexOf("=");
|
|
3623
|
+
return at > 0 ? { ...option, id: option.name.slice(0, at).trim(), name: option.name.slice(at + 1).trim() } : option;
|
|
3624
|
+
});
|
|
3625
|
+
const result = await getClient().databases.updateProperty({
|
|
3626
|
+
id: databaseId,
|
|
3627
|
+
propertyId: property,
|
|
3628
|
+
name: options.name,
|
|
3629
|
+
type: options.type === void 0 ? void 0 : parsePropertyType(options.type),
|
|
3630
|
+
description: options.clearDescription ? null : options.description,
|
|
3631
|
+
options: parsedOptions
|
|
3632
|
+
});
|
|
3633
|
+
if (useJson) console.log(JSON.stringify(result, null, 2));
|
|
3634
|
+
else {
|
|
3635
|
+
console.log(`
|
|
3636
|
+
\u2713 Property "${result.property.name}" updated`);
|
|
3637
|
+
outputDatabasePretty(result.database);
|
|
3638
|
+
}
|
|
3639
|
+
} catch (error) {
|
|
3640
|
+
handleError(error, useJson);
|
|
3641
|
+
}
|
|
3642
|
+
}
|
|
3643
|
+
);
|
|
3644
|
+
properties.command("remove <databaseId> <property>").description("Remove a property from the schema and the view. Row values under it stay until each row is next written. The title property cannot be removed.").action(async (databaseId, property, _options, cmd) => {
|
|
3645
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
3646
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
3647
|
+
try {
|
|
3648
|
+
const database = await getClient().databases.removeProperty(databaseId, property);
|
|
3649
|
+
if (useJson) outputDatabaseJson(database);
|
|
3650
|
+
else {
|
|
3651
|
+
console.log("\n\u2713 Property removed");
|
|
3652
|
+
outputDatabasePretty(database);
|
|
3653
|
+
}
|
|
3654
|
+
} catch (error) {
|
|
3655
|
+
handleError(error, useJson);
|
|
3656
|
+
}
|
|
3657
|
+
});
|
|
3658
|
+
properties.command("reorder <databaseId> <propertyIds...>").description("Set the column order. List every property id exactly once (space- or comma-separated).").action(async (databaseId, propertyIds, _options, cmd) => {
|
|
3659
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
3660
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
3661
|
+
try {
|
|
3662
|
+
const ids = propertyIds.flatMap((part) => part.split(",")).map((s) => s.trim()).filter(Boolean);
|
|
3663
|
+
const database = await getClient().databases.reorderProperties(databaseId, ids);
|
|
3664
|
+
if (useJson) outputDatabaseJson(database);
|
|
3665
|
+
else {
|
|
3666
|
+
console.log("\n\u2713 Properties reordered");
|
|
3667
|
+
outputDatabasePretty(database);
|
|
3668
|
+
}
|
|
3669
|
+
} catch (error) {
|
|
3670
|
+
handleError(error, useJson);
|
|
3671
|
+
}
|
|
3672
|
+
});
|
|
3673
|
+
return properties;
|
|
3674
|
+
}
|
|
3675
|
+
function createRowsCommand() {
|
|
3676
|
+
const rows = new Command4("rows").description(
|
|
3677
|
+
`Rows: each is a page of the database. Write values with repeatable --set Property=value; read a row's body and history with "pages get <rowId>" / "pages history <rowId>".`
|
|
3678
|
+
);
|
|
3679
|
+
rows.command("list <databaseId>").description(
|
|
3680
|
+
'Rows through the saved view, or with your own --filter/--sort: "Status=Tracked", "Score>5", "Owner!=", "Name~latency", "Status in Tracked,Instrumenting".'
|
|
3681
|
+
).option("--filter <expr>", "Filter (repeatable); replaces the saved filters", collect, []).option("--sort <prop[:asc|desc]>", "Sort; replaces the saved sort").option("-l, --limit <n>", "Rows per page (1-200, default 50)").option("--cursor <cursor>", "Continue from a previous page (nextCursor)").action(
|
|
3682
|
+
async (databaseId, options, cmd) => {
|
|
3683
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
3684
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
3685
|
+
try {
|
|
3686
|
+
const client = getClient();
|
|
3687
|
+
const database = await client.databases.get(databaseId);
|
|
3688
|
+
const page = await client.databases.listRows(databaseId, {
|
|
3689
|
+
view: buildListView(database, options.filter, options.sort),
|
|
3690
|
+
limit: parseLimit(options.limit),
|
|
3691
|
+
cursor: options.cursor
|
|
3692
|
+
});
|
|
3693
|
+
if (useJson) console.log(JSON.stringify(page, null, 2));
|
|
3694
|
+
else outputRowsPretty(page, database);
|
|
3695
|
+
} catch (error) {
|
|
3696
|
+
handleError(error, useJson);
|
|
3697
|
+
}
|
|
3698
|
+
}
|
|
3699
|
+
);
|
|
3700
|
+
rows.command("add <databaseId>").description(
|
|
3701
|
+
'Add a row. --set Name="Alert latency" --set Status=Tracked (repeatable; property by name or id; a select by option name, lists comma-separated, dates ISO, checkboxes yes/no).'
|
|
3702
|
+
).option("--set <Property=value>", "A cell value (repeatable)", collect, []).option("-n, --note <text>", "Why: recorded on the row page's first revision").action(async (databaseId, options, cmd) => {
|
|
3703
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
3704
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
3705
|
+
try {
|
|
3706
|
+
const client = getClient();
|
|
3707
|
+
const row = await client.databases.createRow(databaseId, parseSet(options.set), { note: options.note });
|
|
3708
|
+
if (useJson) outputRowJson(row);
|
|
3709
|
+
else {
|
|
3710
|
+
console.log("\n\u2713 Row added");
|
|
3711
|
+
outputRowPretty(row, await client.databases.get(databaseId));
|
|
3712
|
+
}
|
|
3713
|
+
} catch (error) {
|
|
3714
|
+
handleError(error, useJson);
|
|
3715
|
+
}
|
|
3716
|
+
});
|
|
3717
|
+
rows.command("import <databaseId>").description(
|
|
3718
|
+
'Import a CSV: --csv file (or - for stdin). Columns map to properties by header name; --map "Col=Property", --new "Col=type" (or "Col=Name:type") and --skip Col override. --dry-run shows the typed preview and creates nothing. Rows with a cell that does not fit are reported and left out.'
|
|
3719
|
+
).requiredOption("--csv <file>", "The CSV file, or - for stdin").option("--map <Col=Property>", "Send a column to an existing property (repeatable)", collect, []).option("--new <Col=type>", "Create a property for a column (repeatable)", collect, []).option("--skip <Col>", "Leave a column out (repeatable)", collect, []).option("--dry-run", "Preview only: type every row, create nothing").option("-n, --note <text>", "Why: recorded on each new row's first revision").action(
|
|
3720
|
+
async (databaseId, options, cmd) => {
|
|
3721
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
3722
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
3723
|
+
try {
|
|
3724
|
+
const csv = readText(void 0, options.csv);
|
|
3725
|
+
if (!csv?.trim()) throw new Error("The CSV is empty");
|
|
3726
|
+
const client = getClient();
|
|
3727
|
+
const database = await client.databases.get(databaseId);
|
|
3728
|
+
const overrides = parseCsvMapping(database, options);
|
|
3729
|
+
const suggested = await client.databases.previewCsv(databaseId, csv);
|
|
3730
|
+
const mapping = { ...suggested.mapping, ...overrides };
|
|
3731
|
+
const preview = Object.keys(overrides).length > 0 ? await client.databases.previewCsv(databaseId, csv, mapping) : suggested;
|
|
3732
|
+
if (options.dryRun) {
|
|
3733
|
+
if (useJson) console.log(JSON.stringify(preview, null, 2));
|
|
3734
|
+
else outputCsvPreviewPretty(preview);
|
|
3735
|
+
return;
|
|
3736
|
+
}
|
|
3737
|
+
const result = await client.databases.commitCsv(databaseId, csv, mapping, { note: options.note });
|
|
3738
|
+
if (useJson) console.log(JSON.stringify(result, null, 2));
|
|
3739
|
+
else {
|
|
3740
|
+
console.log(`
|
|
3741
|
+
\u2713 Imported ${result.created.length} of ${result.total} row${result.total === 1 ? "" : "s"}`);
|
|
3742
|
+
for (const p of result.properties) console.log(` + property ${p.name} (${p.type})`);
|
|
3743
|
+
outputCsvSkipped(result.skipped);
|
|
3744
|
+
}
|
|
3745
|
+
} catch (error) {
|
|
3746
|
+
handleError(error, useJson);
|
|
3747
|
+
}
|
|
3748
|
+
}
|
|
3749
|
+
);
|
|
3750
|
+
rows.command("update <rowId>").description("Write some of a row's cells: --set Property=value (repeatable), --clear Property to empty one. Other cells are kept. Recorded in the row page's history.").option("--set <Property=value>", "A cell value (repeatable)", collect, []).option("--clear <Property>", "Empty a cell (repeatable)", collect, []).option("-n, --note <text>", "Why: shown in the row page's history").action(
|
|
3751
|
+
async (rowId, options, cmd) => {
|
|
3752
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
3753
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
3754
|
+
try {
|
|
3755
|
+
const values = parseSet(options.set, options.clear);
|
|
3756
|
+
if (Object.keys(values).length === 0) {
|
|
3757
|
+
throw new Error("Nothing to write: pass at least one --set Property=value or --clear Property");
|
|
3758
|
+
}
|
|
3759
|
+
const client = getClient();
|
|
3760
|
+
const row = await client.databases.updateRow(rowId, values, { note: options.note });
|
|
3761
|
+
if (useJson) outputRowJson(row);
|
|
3762
|
+
else {
|
|
3763
|
+
console.log("\n\u2713 Row updated");
|
|
3764
|
+
outputRowPretty(row, row.databaseId ? await client.databases.get(row.databaseId) : void 0);
|
|
3765
|
+
}
|
|
3766
|
+
} catch (error) {
|
|
3767
|
+
handleError(error, useJson);
|
|
3768
|
+
}
|
|
3769
|
+
}
|
|
3770
|
+
);
|
|
3771
|
+
rows.command("delete <rowId>").description("Delete a row (the page and its search chunks)").requiredOption("--yes", "Confirm").action(async (rowId, _options, cmd) => {
|
|
3772
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
3773
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
3774
|
+
try {
|
|
3775
|
+
const result = await getClient().databases.deleteRow(rowId);
|
|
3776
|
+
if (useJson) console.log(JSON.stringify(result, null, 2));
|
|
3777
|
+
else console.log(`
|
|
3778
|
+
\u2713 Row ${result.id} deleted
|
|
3779
|
+
`);
|
|
3780
|
+
} catch (error) {
|
|
3781
|
+
handleError(error, useJson);
|
|
3782
|
+
}
|
|
3783
|
+
});
|
|
3784
|
+
return rows;
|
|
3785
|
+
}
|
|
3786
|
+
|
|
3135
3787
|
// src/commands/decisions.ts
|
|
3788
|
+
import { Command as Command5 } from "commander";
|
|
3789
|
+
import chalk5 from "chalk";
|
|
3136
3790
|
var STATUSES = [
|
|
3137
3791
|
"OPEN",
|
|
3138
3792
|
"PROPOSED",
|
|
@@ -3380,7 +4034,7 @@ function addConfirmCommand(parent) {
|
|
|
3380
4034
|
);
|
|
3381
4035
|
}
|
|
3382
4036
|
function createDecisionsCommand() {
|
|
3383
|
-
const decisions = new
|
|
4037
|
+
const decisions = new Command5("decisions").description(
|
|
3384
4038
|
[
|
|
3385
4039
|
"Log and manage decisions and open questions (the workspace Decision Log).",
|
|
3386
4040
|
"",
|
|
@@ -3431,7 +4085,7 @@ function createDecisionsCommand() {
|
|
|
3431
4085
|
outputDecisionsPretty(rows2);
|
|
3432
4086
|
if (!result.canLogDecision) {
|
|
3433
4087
|
console.log(
|
|
3434
|
-
|
|
4088
|
+
chalk5.yellow(
|
|
3435
4089
|
"You cannot log decisions on this meeting (no edit access, or it has no workspace)."
|
|
3436
4090
|
)
|
|
3437
4091
|
);
|
|
@@ -3631,7 +4285,7 @@ function createDecisionsCommand() {
|
|
|
3631
4285
|
\u2713 ${decision.status === "OPEN" ? "Open question" : "Decision"} logged`
|
|
3632
4286
|
);
|
|
3633
4287
|
outputDecisionPretty(decision);
|
|
3634
|
-
if (featureLink) console.log(
|
|
4288
|
+
if (featureLink) console.log(chalk5.gray(` Linked to feature ${options.feature}`));
|
|
3635
4289
|
}
|
|
3636
4290
|
} catch (error) {
|
|
3637
4291
|
handleError(error, useJson);
|
|
@@ -3740,9 +4394,9 @@ function createDecisionsCommand() {
|
|
|
3740
4394
|
const link = options.ticket ? await client.decisions.linkTicket(workspaceId, decisionId, options.ticket) : await client.decisions.linkFeature(workspaceId, decisionId, options.feature);
|
|
3741
4395
|
if (useJson) console.log(JSON.stringify(link, null, 2));
|
|
3742
4396
|
else {
|
|
3743
|
-
console.log(`\u2713 Linked ${
|
|
4397
|
+
console.log(`\u2713 Linked ${chalk5.gray(`(link id ${link.id})`)}`);
|
|
3744
4398
|
console.log(
|
|
3745
|
-
|
|
4399
|
+
chalk5.gray(" Remove it with: exponential decisions unlink --link " + link.id)
|
|
3746
4400
|
);
|
|
3747
4401
|
}
|
|
3748
4402
|
} catch (error) {
|
|
@@ -3765,7 +4419,7 @@ function createDecisionsCommand() {
|
|
|
3765
4419
|
handleError(error, useJson);
|
|
3766
4420
|
}
|
|
3767
4421
|
});
|
|
3768
|
-
const drafts = new
|
|
4422
|
+
const drafts = new Command5("draft").description(
|
|
3769
4423
|
"Review decisions an agent proposed but nobody has confirmed yet (visible only on their source meeting)"
|
|
3770
4424
|
);
|
|
3771
4425
|
drafts.command("extract").description(
|
|
@@ -3780,22 +4434,22 @@ function createDecisionsCommand() {
|
|
|
3780
4434
|
else {
|
|
3781
4435
|
if (result.alreadyPublished) {
|
|
3782
4436
|
console.log(
|
|
3783
|
-
|
|
4437
|
+
chalk5.gray("This meeting already has confirmed decisions \u2014 nothing was extracted.")
|
|
3784
4438
|
);
|
|
3785
4439
|
} else if (result.alreadyDrafted) {
|
|
3786
|
-
console.log(
|
|
4440
|
+
console.log(chalk5.gray("Returning the drafts this meeting already had."));
|
|
3787
4441
|
}
|
|
3788
4442
|
console.log(
|
|
3789
4443
|
`\u2713 ${result.draftCount} draft${result.draftCount === 1 ? "" : "s"} awaiting review (${result.draftsCreated} new)`
|
|
3790
4444
|
);
|
|
3791
4445
|
if (result.discardedWithoutEvidence > 0) {
|
|
3792
4446
|
console.log(
|
|
3793
|
-
|
|
4447
|
+
chalk5.gray(
|
|
3794
4448
|
` ${result.discardedWithoutEvidence} candidate(s) dropped \u2014 no transcript turn supported them.`
|
|
3795
4449
|
)
|
|
3796
4450
|
);
|
|
3797
4451
|
}
|
|
3798
|
-
for (const message of result.errors) console.log(
|
|
4452
|
+
for (const message of result.errors) console.log(chalk5.yellow(` ${message}`));
|
|
3799
4453
|
}
|
|
3800
4454
|
} catch (error) {
|
|
3801
4455
|
handleError(error, useJson);
|
|
@@ -3852,9 +4506,9 @@ function createDecisionsCommand() {
|
|
|
3852
4506
|
}
|
|
3853
4507
|
|
|
3854
4508
|
// src/commands/deals.ts
|
|
3855
|
-
import { Command as
|
|
4509
|
+
import { Command as Command6 } from "commander";
|
|
3856
4510
|
function createDealsCommand() {
|
|
3857
|
-
const deals = new
|
|
4511
|
+
const deals = new Command6("deals").description("Manage pipeline deals");
|
|
3858
4512
|
deals.command("pipeline").description("Get pipeline overview with stages").requiredOption("--workspace <id>", "Workspace ID").action(async (options, cmd) => {
|
|
3859
4513
|
const globalOpts = cmd.optsWithGlobals();
|
|
3860
4514
|
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
@@ -4039,7 +4693,7 @@ function createDealsCommand() {
|
|
|
4039
4693
|
}
|
|
4040
4694
|
|
|
4041
4695
|
// src/commands/epics.ts
|
|
4042
|
-
import { Command as
|
|
4696
|
+
import { Command as Command7 } from "commander";
|
|
4043
4697
|
var EPIC_STATUSES = ["OPEN", "IN_PROGRESS", "DONE", "CANCELLED"];
|
|
4044
4698
|
var EPIC_PRIORITIES = ["HIGH", "MEDIUM", "LOW", "NONE"];
|
|
4045
4699
|
function validateEpicStatus(value) {
|
|
@@ -4067,7 +4721,7 @@ function parseDate2(value) {
|
|
|
4067
4721
|
return d;
|
|
4068
4722
|
}
|
|
4069
4723
|
function createEpicsCommand() {
|
|
4070
|
-
const epics = new
|
|
4724
|
+
const epics = new Command7("epics").description(
|
|
4071
4725
|
"Manage epics. Epics are workspace-scoped and group actions and tickets across products."
|
|
4072
4726
|
);
|
|
4073
4727
|
epics.command("list").description("List epics in a workspace").option("--workspace <slug|id>", "Workspace slug or CUID").option("--status <status>", `Filter by status: ${EPIC_STATUSES.join(", ")}`).action(
|
|
@@ -4184,10 +4838,10 @@ function createEpicsCommand() {
|
|
|
4184
4838
|
}
|
|
4185
4839
|
|
|
4186
4840
|
// src/commands/features.ts
|
|
4187
|
-
import { Command as
|
|
4841
|
+
import { Command as Command13 } from "commander";
|
|
4188
4842
|
|
|
4189
4843
|
// src/commands/stories.ts
|
|
4190
|
-
import { Command as
|
|
4844
|
+
import { Command as Command8 } from "commander";
|
|
4191
4845
|
async function readStdin() {
|
|
4192
4846
|
const chunks = [];
|
|
4193
4847
|
for await (const chunk of process.stdin) {
|
|
@@ -4196,7 +4850,7 @@ async function readStdin() {
|
|
|
4196
4850
|
return Buffer.concat(chunks).toString("utf-8");
|
|
4197
4851
|
}
|
|
4198
4852
|
function createStoriesCommand() {
|
|
4199
|
-
const stories = new
|
|
4853
|
+
const stories = new Command8("stories").description(
|
|
4200
4854
|
"Manage a feature's native, structured user stories (As a / I want / So that)."
|
|
4201
4855
|
);
|
|
4202
4856
|
stories.command("add").description(
|
|
@@ -4330,7 +4984,7 @@ function createStoriesCommand() {
|
|
|
4330
4984
|
}
|
|
4331
4985
|
|
|
4332
4986
|
// src/commands/scopes.ts
|
|
4333
|
-
import { Command as
|
|
4987
|
+
import { Command as Command9 } from "commander";
|
|
4334
4988
|
var SCOPE_STATUSES = [
|
|
4335
4989
|
"PLANNED",
|
|
4336
4990
|
"IN_PROGRESS",
|
|
@@ -4347,7 +5001,7 @@ function validateScopeStatus(value) {
|
|
|
4347
5001
|
return value;
|
|
4348
5002
|
}
|
|
4349
5003
|
function createScopesCommand() {
|
|
4350
|
-
const scopes = new
|
|
5004
|
+
const scopes = new Command9("scopes").description(
|
|
4351
5005
|
`Manage a feature's scopes: shippable increments ("V1", "V2"), each with its own lifecycle.`
|
|
4352
5006
|
);
|
|
4353
5007
|
scopes.command("list").description("List a feature's scopes").requiredOption("--feature <id>", "Feature CUID").action(
|
|
@@ -4426,7 +5080,7 @@ function createScopesCommand() {
|
|
|
4426
5080
|
}
|
|
4427
5081
|
|
|
4428
5082
|
// src/commands/requirements.ts
|
|
4429
|
-
import { Command as
|
|
5083
|
+
import { Command as Command10 } from "commander";
|
|
4430
5084
|
var REQUIREMENT_KINDS = [
|
|
4431
5085
|
"FUNCTIONAL",
|
|
4432
5086
|
"NON_FUNCTIONAL",
|
|
@@ -4449,7 +5103,7 @@ async function readStdin2() {
|
|
|
4449
5103
|
return Buffer.concat(chunks).toString("utf-8");
|
|
4450
5104
|
}
|
|
4451
5105
|
function createRequirementsCommand() {
|
|
4452
|
-
const requirements = new
|
|
5106
|
+
const requirements = new Command10("requirements").description(
|
|
4453
5107
|
`Manage a feature's requirements: atomic, testable EARS-style "shall" statements, checkable met/unmet.`
|
|
4454
5108
|
);
|
|
4455
5109
|
requirements.command("add").description(
|
|
@@ -4580,25 +5234,25 @@ function createRequirementsCommand() {
|
|
|
4580
5234
|
}
|
|
4581
5235
|
|
|
4582
5236
|
// src/commands/areas.ts
|
|
4583
|
-
import { Command as
|
|
4584
|
-
import
|
|
5237
|
+
import { Command as Command11 } from "commander";
|
|
5238
|
+
import chalk6 from "chalk";
|
|
4585
5239
|
function outputAreasPretty(areas) {
|
|
4586
5240
|
if (areas.length === 0) {
|
|
4587
|
-
console.log(
|
|
5241
|
+
console.log(chalk6.gray("No areas found."));
|
|
4588
5242
|
return;
|
|
4589
5243
|
}
|
|
4590
|
-
console.log(
|
|
5244
|
+
console.log(chalk6.bold(`
|
|
4591
5245
|
Areas (${areas.length} total)`));
|
|
4592
|
-
console.log(
|
|
5246
|
+
console.log(chalk6.gray("\u2500".repeat(50)));
|
|
4593
5247
|
for (const a of areas) {
|
|
4594
|
-
const count = a._count?.features != null ?
|
|
4595
|
-
console.log(` ${
|
|
4596
|
-
console.log(
|
|
5248
|
+
const count = a._count?.features != null ? chalk6.gray(` (${a._count.features} features)`) : "";
|
|
5249
|
+
console.log(` ${chalk6.bold(a.name)}${count}`);
|
|
5250
|
+
console.log(chalk6.gray(` ID: ${a.id}`));
|
|
4597
5251
|
}
|
|
4598
5252
|
console.log();
|
|
4599
5253
|
}
|
|
4600
5254
|
function createAreasCommand() {
|
|
4601
|
-
const areas = new
|
|
5255
|
+
const areas = new Command11("areas").description(
|
|
4602
5256
|
"Manage a product's areas: the buckets features are filed under (a feature has exactly one or none)."
|
|
4603
5257
|
);
|
|
4604
5258
|
areas.command("list").description("List a product's areas").requiredOption("--product <slug|id>", "Product slug or CUID").option("--workspace <slug|id>", "Workspace (required when --product is a slug)").action(
|
|
@@ -4642,7 +5296,7 @@ function createAreasCommand() {
|
|
|
4642
5296
|
}
|
|
4643
5297
|
|
|
4644
5298
|
// src/commands/featureComments.ts
|
|
4645
|
-
import { Command as
|
|
5299
|
+
import { Command as Command12 } from "commander";
|
|
4646
5300
|
|
|
4647
5301
|
// src/utils/mentions.ts
|
|
4648
5302
|
function candidateLabels(member) {
|
|
@@ -4715,7 +5369,7 @@ function collectMention(value, previous) {
|
|
|
4715
5369
|
|
|
4716
5370
|
// src/commands/featureComments.ts
|
|
4717
5371
|
function createFeatureCommentsCommand() {
|
|
4718
|
-
const comment = new
|
|
5372
|
+
const comment = new Command12("comment").description(
|
|
4719
5373
|
"Read and post comments on a feature. Mention teammates with --mention."
|
|
4720
5374
|
);
|
|
4721
5375
|
comment.command("list").description("List comments on a feature").requiredOption("--feature <id>", "Feature ID").action(async (options, cmd) => {
|
|
@@ -4916,7 +5570,7 @@ function validateFeatureStatus(value) {
|
|
|
4916
5570
|
return value;
|
|
4917
5571
|
}
|
|
4918
5572
|
function createFeaturesCommand() {
|
|
4919
|
-
const features = new
|
|
5573
|
+
const features = new Command13("features").description(
|
|
4920
5574
|
"Manage features. A feature lives under a product and groups user stories, scopes, and tickets."
|
|
4921
5575
|
);
|
|
4922
5576
|
features.command("list").description("List features in a product").requiredOption("--product <slug|id>", "Product slug or CUID").option("--workspace <slug|id>", "Workspace (required when --product is a slug)").option("--status <status>", `Filter by status: ${FEATURE_STATUSES.join(", ")}`).action(
|
|
@@ -5173,8 +5827,8 @@ Aborted: ${reason}. Feature "${feature.name}" was NOT deleted.`);
|
|
|
5173
5827
|
}
|
|
5174
5828
|
|
|
5175
5829
|
// src/commands/labels.ts
|
|
5176
|
-
import { Command as
|
|
5177
|
-
import
|
|
5830
|
+
import { Command as Command14 } from "commander";
|
|
5831
|
+
import chalk7 from "chalk";
|
|
5178
5832
|
var TRIAGE_LABELS = [
|
|
5179
5833
|
{ slug: "needs-triage", name: "needs-triage", color: "avatar-orange" },
|
|
5180
5834
|
{ slug: "needs-info", name: "needs-info", color: "avatar-yellow" },
|
|
@@ -5188,22 +5842,22 @@ function looksLikeCuid(value) {
|
|
|
5188
5842
|
}
|
|
5189
5843
|
function outputTagsPretty(tags) {
|
|
5190
5844
|
if (tags.length === 0) {
|
|
5191
|
-
console.log(
|
|
5845
|
+
console.log(chalk7.dim("No labels found."));
|
|
5192
5846
|
return;
|
|
5193
5847
|
}
|
|
5194
5848
|
console.log();
|
|
5195
5849
|
for (const tag of tags) {
|
|
5196
|
-
const scope = tag.workspaceId === null ?
|
|
5197
|
-
const category = tag.category === null ?
|
|
5850
|
+
const scope = tag.workspaceId === null ? chalk7.cyan("global") : chalk7.magenta("workspace");
|
|
5851
|
+
const category = tag.category === null ? chalk7.dim("(label)") : chalk7.dim(`(${tag.category})`);
|
|
5198
5852
|
console.log(
|
|
5199
|
-
` ${
|
|
5853
|
+
` ${chalk7.bold(tag.slug)} ${tag.name} ${chalk7.gray(tag.color)} ${scope} ${category}`
|
|
5200
5854
|
);
|
|
5201
5855
|
}
|
|
5202
5856
|
console.log();
|
|
5203
5857
|
}
|
|
5204
5858
|
function outputTagPretty(tag, prefix) {
|
|
5205
5859
|
if (prefix) console.log(prefix);
|
|
5206
|
-
console.log(` ${
|
|
5860
|
+
console.log(` ${chalk7.bold(tag.slug)} ${tag.name} ${chalk7.gray(tag.color)}`);
|
|
5207
5861
|
}
|
|
5208
5862
|
async function resolveLabelIds(client, workspaceId, values) {
|
|
5209
5863
|
if (values.length === 0) return [];
|
|
@@ -5227,7 +5881,7 @@ async function resolveLabelIds(client, workspaceId, values) {
|
|
|
5227
5881
|
return [...byId, ...resolvedFromSlugs];
|
|
5228
5882
|
}
|
|
5229
5883
|
function createLabelsCommand() {
|
|
5230
|
-
const labels = new
|
|
5884
|
+
const labels = new Command14("labels").description(
|
|
5231
5885
|
"Manage labels (orthogonal tags applied to actions, tickets, features, and epics)."
|
|
5232
5886
|
);
|
|
5233
5887
|
labels.command("list").description("List labels visible in a workspace").option("--workspace <slug|id>", "Workspace slug or CUID").option(
|
|
@@ -5275,7 +5929,7 @@ function createLabelsCommand() {
|
|
|
5275
5929
|
if (useJson) {
|
|
5276
5930
|
console.log(JSON.stringify(tag, null, 2));
|
|
5277
5931
|
} else {
|
|
5278
|
-
outputTagPretty(tag,
|
|
5932
|
+
outputTagPretty(tag, chalk7.green("\n\u2713 Label created"));
|
|
5279
5933
|
}
|
|
5280
5934
|
} catch (error) {
|
|
5281
5935
|
handleError(error, useJson);
|
|
@@ -5313,10 +5967,10 @@ function createLabelsCommand() {
|
|
|
5313
5967
|
console.log(JSON.stringify(results, null, 2));
|
|
5314
5968
|
} else {
|
|
5315
5969
|
console.log();
|
|
5316
|
-
console.log(
|
|
5970
|
+
console.log(chalk7.bold("Triage labels:"));
|
|
5317
5971
|
for (const r of results) {
|
|
5318
|
-
const tag =
|
|
5319
|
-
const status = r.status === "created" ?
|
|
5972
|
+
const tag = chalk7.bold(r.slug);
|
|
5973
|
+
const status = r.status === "created" ? chalk7.green("created") : chalk7.dim("existed");
|
|
5320
5974
|
console.log(` ${tag} ${status}`);
|
|
5321
5975
|
}
|
|
5322
5976
|
console.log();
|
|
@@ -5330,10 +5984,10 @@ function createLabelsCommand() {
|
|
|
5330
5984
|
}
|
|
5331
5985
|
|
|
5332
5986
|
// src/commands/meetings.ts
|
|
5333
|
-
import { Command as
|
|
5334
|
-
import
|
|
5987
|
+
import { Command as Command15 } from "commander";
|
|
5988
|
+
import chalk8 from "chalk";
|
|
5335
5989
|
function createMeetingsCommand() {
|
|
5336
|
-
const meetings = new
|
|
5990
|
+
const meetings = new Command15("meetings").description(
|
|
5337
5991
|
"Manage meetings and their notes (recorded, imported, or manually created)"
|
|
5338
5992
|
);
|
|
5339
5993
|
meetings.command("list").description(
|
|
@@ -5494,7 +6148,7 @@ function createMeetingsCommand() {
|
|
|
5494
6148
|
console.log(`\u2713 Deleted ${count} of ${ids.length} meeting${ids.length === 1 ? "" : "s"}`);
|
|
5495
6149
|
if (skipped > 0) {
|
|
5496
6150
|
console.log(
|
|
5497
|
-
|
|
6151
|
+
chalk8.yellow(
|
|
5498
6152
|
`${skipped} id(s) were skipped \u2014 not found, or not owned by you.`
|
|
5499
6153
|
)
|
|
5500
6154
|
);
|
|
@@ -5505,7 +6159,7 @@ function createMeetingsCommand() {
|
|
|
5505
6159
|
}
|
|
5506
6160
|
}
|
|
5507
6161
|
);
|
|
5508
|
-
const notes = new
|
|
6162
|
+
const notes = new Command15("notes").description(
|
|
5509
6163
|
"Read and write a meeting's notes"
|
|
5510
6164
|
);
|
|
5511
6165
|
notes.command("get <id>").description(
|
|
@@ -5521,7 +6175,7 @@ function createMeetingsCommand() {
|
|
|
5521
6175
|
process.stdout.write(body.endsWith("\n") ? body : `${body}
|
|
5522
6176
|
`);
|
|
5523
6177
|
} else if (process.stdout.isTTY) {
|
|
5524
|
-
console.log(
|
|
6178
|
+
console.log(chalk8.gray("No notes yet."));
|
|
5525
6179
|
}
|
|
5526
6180
|
} catch (error) {
|
|
5527
6181
|
handleError(error, shouldUseJson(globalOpts.json, globalOpts.pretty));
|
|
@@ -5570,7 +6224,7 @@ function createMeetingsCommand() {
|
|
|
5570
6224
|
}
|
|
5571
6225
|
|
|
5572
6226
|
// src/commands/organizations.ts
|
|
5573
|
-
import { Command as
|
|
6227
|
+
import { Command as Command16 } from "commander";
|
|
5574
6228
|
var VALID_SIZES = [
|
|
5575
6229
|
"1-10",
|
|
5576
6230
|
"11-50",
|
|
@@ -5580,7 +6234,7 @@ var VALID_SIZES = [
|
|
|
5580
6234
|
"1000+"
|
|
5581
6235
|
];
|
|
5582
6236
|
function createOrganizationsCommand() {
|
|
5583
|
-
const organizations = new
|
|
6237
|
+
const organizations = new Command16("organizations").alias("orgs").description("Manage CRM organizations");
|
|
5584
6238
|
organizations.command("list").description("List organizations").requiredOption("--workspace <id>", "Workspace ID").option("--search <query>", "Search by name or description").option("--industry <industry>", "Filter by industry").option("--limit <n>", "Max results to return", parseInt).option("--cursor <cursor>", "Pagination cursor").action(async (options, cmd) => {
|
|
5585
6239
|
const globalOpts = cmd.optsWithGlobals();
|
|
5586
6240
|
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
@@ -5648,12 +6302,13 @@ function createOrganizationsCommand() {
|
|
|
5648
6302
|
}
|
|
5649
6303
|
|
|
5650
6304
|
// src/commands/pages.ts
|
|
5651
|
-
import { Command as
|
|
6305
|
+
import { Command as Command18 } from "commander";
|
|
6306
|
+
import chalk9 from "chalk";
|
|
5652
6307
|
|
|
5653
6308
|
// src/commands/pageComments.ts
|
|
5654
|
-
import { Command as
|
|
6309
|
+
import { Command as Command17 } from "commander";
|
|
5655
6310
|
function createPageCommentsCommand() {
|
|
5656
|
-
const comment = new
|
|
6311
|
+
const comment = new Command17("comment").description(
|
|
5657
6312
|
"Read and post comments on a page. Mention teammates with --mention."
|
|
5658
6313
|
);
|
|
5659
6314
|
comment.command("list").description("List comments on a page").requiredOption("--page <id>", "Page ID").action(async (options, cmd) => {
|
|
@@ -5747,11 +6402,22 @@ function createPageCommentsCommand() {
|
|
|
5747
6402
|
}
|
|
5748
6403
|
|
|
5749
6404
|
// src/commands/pages.ts
|
|
6405
|
+
function parseLimit2(value) {
|
|
6406
|
+
if (value === void 0) return void 0;
|
|
6407
|
+
const n = Number(value);
|
|
6408
|
+
if (!Number.isInteger(n) || n < 1) {
|
|
6409
|
+
throw new Error(`--limit must be a positive integer, got "${value}"`);
|
|
6410
|
+
}
|
|
6411
|
+
return n;
|
|
6412
|
+
}
|
|
5750
6413
|
function createPagesCommand() {
|
|
5751
|
-
const pages = new
|
|
5752
|
-
|
|
6414
|
+
const pages = new Command18("pages").description(
|
|
6415
|
+
`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".`
|
|
5753
6416
|
);
|
|
5754
|
-
pages.command("list").description("List pages in a workspace").option("--workspace <slug|id>", "Workspace (defaults to the configured default)").option(
|
|
6417
|
+
pages.command("list").description("List pages in a workspace (metadata only, no bodies)").option("--workspace <slug|id>", "Workspace (defaults to the configured default)").option(
|
|
6418
|
+
"--search <text>",
|
|
6419
|
+
'Case-insensitive title match. To find pages by content or meaning use "pages search".'
|
|
6420
|
+
).action(
|
|
5755
6421
|
async (options, cmd) => {
|
|
5756
6422
|
const globalOpts = cmd.optsWithGlobals();
|
|
5757
6423
|
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
@@ -5769,19 +6435,51 @@ function createPagesCommand() {
|
|
|
5769
6435
|
}
|
|
5770
6436
|
}
|
|
5771
6437
|
);
|
|
5772
|
-
pages.command("
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
const
|
|
5777
|
-
const
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
6438
|
+
pages.command("search <query>").description(
|
|
6439
|
+
"Find pages by meaning: semantic hits from the Knowledge index first (with the matching passage), then pages whose title or body contain the text"
|
|
6440
|
+
).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(
|
|
6441
|
+
async (query, options, cmd) => {
|
|
6442
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
6443
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
6444
|
+
try {
|
|
6445
|
+
const client = getClient();
|
|
6446
|
+
const workspaceId = await resolveWorkspaceId(client, options.workspace);
|
|
6447
|
+
const result = await client.pages.search({
|
|
6448
|
+
workspaceId,
|
|
6449
|
+
query,
|
|
6450
|
+
projectId: options.project,
|
|
6451
|
+
limit: parseLimit2(options.limit)
|
|
6452
|
+
});
|
|
6453
|
+
if (useJson) console.log(JSON.stringify(result, null, 2));
|
|
6454
|
+
else outputPageSearchPretty(result);
|
|
6455
|
+
} catch (error) {
|
|
6456
|
+
handleError(error, useJson);
|
|
6457
|
+
}
|
|
5782
6458
|
}
|
|
5783
|
-
|
|
5784
|
-
pages.command("
|
|
6459
|
+
);
|
|
6460
|
+
pages.command("get <id>").description(
|
|
6461
|
+
"Get a page by CUID. Markdown body only by default (the editor doc is never sent). --outline shows its headings; --section reads one part."
|
|
6462
|
+
).option("--outline", "Headings only (level, text, line) and the body size, no body").option(
|
|
6463
|
+
"--section <heading>",
|
|
6464
|
+
`Only this heading's section (case-insensitive; a "## " prefix is allowed)`
|
|
6465
|
+
).option("--full", "Include the editor's ProseMirror document as well (large)").action(
|
|
6466
|
+
async (id, options, cmd) => {
|
|
6467
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
6468
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
6469
|
+
try {
|
|
6470
|
+
const client = getClient();
|
|
6471
|
+
const page = await client.pages.get(id, {
|
|
6472
|
+
format: options.outline ? "outline" : options.full ? "full" : "markdown",
|
|
6473
|
+
section: options.section
|
|
6474
|
+
});
|
|
6475
|
+
if (useJson) outputPageJson(page);
|
|
6476
|
+
else outputPagePretty(page);
|
|
6477
|
+
} catch (error) {
|
|
6478
|
+
handleError(error, useJson);
|
|
6479
|
+
}
|
|
6480
|
+
}
|
|
6481
|
+
);
|
|
6482
|
+
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(
|
|
5785
6483
|
async (options, cmd) => {
|
|
5786
6484
|
const globalOpts = cmd.optsWithGlobals();
|
|
5787
6485
|
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
@@ -5790,8 +6488,12 @@ function createPagesCommand() {
|
|
|
5790
6488
|
const workspaceId = await resolveWorkspaceId(client, options.workspace);
|
|
5791
6489
|
const page = await client.pages.create({
|
|
5792
6490
|
workspaceId,
|
|
6491
|
+
projectId: options.project,
|
|
5793
6492
|
title: options.title,
|
|
5794
|
-
body: readText(options.body, options.bodyFile)
|
|
6493
|
+
body: readText(options.body, options.bodyFile),
|
|
6494
|
+
source: options.source,
|
|
6495
|
+
asOf: parseDate(options.asOf),
|
|
6496
|
+
note: options.note
|
|
5795
6497
|
});
|
|
5796
6498
|
if (useJson) outputPageJson(page);
|
|
5797
6499
|
else {
|
|
@@ -5804,8 +6506,8 @@ function createPagesCommand() {
|
|
|
5804
6506
|
}
|
|
5805
6507
|
);
|
|
5806
6508
|
pages.command("update").description(
|
|
5807
|
-
"Update a page. Sending a body is a Markdown-source write: the Markdown becomes canonical."
|
|
5808
|
-
).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(
|
|
6509
|
+
"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."
|
|
6510
|
+
).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(
|
|
5809
6511
|
async (options, cmd) => {
|
|
5810
6512
|
const globalOpts = cmd.optsWithGlobals();
|
|
5811
6513
|
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
@@ -5814,7 +6516,11 @@ function createPagesCommand() {
|
|
|
5814
6516
|
const page = await client.pages.update({
|
|
5815
6517
|
id: options.id,
|
|
5816
6518
|
title: options.title,
|
|
5817
|
-
body: readText(options.body, options.bodyFile)
|
|
6519
|
+
body: readText(options.body, options.bodyFile),
|
|
6520
|
+
baseVersion: options.baseVersion === void 0 ? void 0 : Number(options.baseVersion),
|
|
6521
|
+
note: options.note,
|
|
6522
|
+
source: options.source,
|
|
6523
|
+
asOf: options.clearAsOf ? null : parseDate(options.asOf)
|
|
5818
6524
|
});
|
|
5819
6525
|
if (useJson) outputPageJson(page);
|
|
5820
6526
|
else {
|
|
@@ -5826,14 +6532,115 @@ function createPagesCommand() {
|
|
|
5826
6532
|
}
|
|
5827
6533
|
}
|
|
5828
6534
|
);
|
|
6535
|
+
pages.command("history <id>").description(
|
|
6536
|
+
"The page's revisions, newest first: who, when, why and the body size. Never the bodies."
|
|
6537
|
+
).option("-l, --limit <n>", "Max revisions (1-200, default 50)").option("--cursor <revisionId>", "Continue from a previous page of history").action(
|
|
6538
|
+
async (id, options, cmd) => {
|
|
6539
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
6540
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
6541
|
+
try {
|
|
6542
|
+
const client = getClient();
|
|
6543
|
+
const history = await client.pages.history(id, {
|
|
6544
|
+
limit: parseLimit2(options.limit),
|
|
6545
|
+
cursor: options.cursor
|
|
6546
|
+
});
|
|
6547
|
+
if (useJson) console.log(JSON.stringify(history, null, 2));
|
|
6548
|
+
else outputPageHistoryPretty(history);
|
|
6549
|
+
} catch (error) {
|
|
6550
|
+
handleError(error, useJson);
|
|
6551
|
+
}
|
|
6552
|
+
}
|
|
6553
|
+
);
|
|
6554
|
+
pages.command("revision <id> <revisionId>").description("One revision with its Markdown body").action(
|
|
6555
|
+
async (id, revisionId, _options, cmd) => {
|
|
6556
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
6557
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
6558
|
+
try {
|
|
6559
|
+
const client = getClient();
|
|
6560
|
+
const revision = await client.pages.revision(id, revisionId);
|
|
6561
|
+
if (useJson) console.log(JSON.stringify(revision, null, 2));
|
|
6562
|
+
else {
|
|
6563
|
+
console.log(chalk9.gray("\u2500".repeat(50)));
|
|
6564
|
+
console.log(
|
|
6565
|
+
`
|
|
6566
|
+
${chalk9.bold(revision.title)} ${chalk9.gray(`v${revision.docVersion} \xB7 ${revision.kind}`)}`
|
|
6567
|
+
);
|
|
6568
|
+
console.log(chalk9.gray(` Revision: ${revision.id}`));
|
|
6569
|
+
if (revision.note) console.log(` ${chalk9.gray("Note:")} ${revision.note}`);
|
|
6570
|
+
if (revision.body) console.log(`
|
|
6571
|
+
${revision.body}
|
|
6572
|
+
`);
|
|
6573
|
+
}
|
|
6574
|
+
} catch (error) {
|
|
6575
|
+
handleError(error, useJson);
|
|
6576
|
+
}
|
|
6577
|
+
}
|
|
6578
|
+
);
|
|
6579
|
+
pages.command("diff <id>").description(
|
|
6580
|
+
"What a revision changed, as a unified diff of the Markdown. Defaults to the latest revision against the one before it."
|
|
6581
|
+
).option("--revision <revisionId>", "The revision to inspect (default: the latest)").option(
|
|
6582
|
+
"--against <previous|current|revisionId>",
|
|
6583
|
+
"What to compare with: the revision before it (default), the page as it is now, or another revision"
|
|
6584
|
+
).action(
|
|
6585
|
+
async (id, options, cmd) => {
|
|
6586
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
6587
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
6588
|
+
try {
|
|
6589
|
+
const client = getClient();
|
|
6590
|
+
let revisionId = options.revision;
|
|
6591
|
+
if (!revisionId) {
|
|
6592
|
+
const latest = await client.pages.history(id, { limit: 1 });
|
|
6593
|
+
revisionId = latest.revisions[0]?.id;
|
|
6594
|
+
if (!revisionId) throw new Error("This page has no revisions yet.");
|
|
6595
|
+
}
|
|
6596
|
+
const diff = await client.pages.diff(id, revisionId, { against: options.against });
|
|
6597
|
+
if (useJson) console.log(JSON.stringify(diff, null, 2));
|
|
6598
|
+
else outputPageDiffPretty(diff);
|
|
6599
|
+
} catch (error) {
|
|
6600
|
+
handleError(error, useJson);
|
|
6601
|
+
}
|
|
6602
|
+
}
|
|
6603
|
+
);
|
|
6604
|
+
pages.command("restore <id>").description(
|
|
6605
|
+
"Put a revision's title and body back as the page's current content. A forward write: the history keeps what was replaced."
|
|
6606
|
+
).requiredOption("--revision <revisionId>", 'The revision to restore (see "pages history")').option("-n, --note <text>", "Why: recorded on the restore revision").option(
|
|
6607
|
+
"--base-version <n>",
|
|
6608
|
+
`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.`
|
|
6609
|
+
).action(
|
|
6610
|
+
async (id, options, cmd) => {
|
|
6611
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
6612
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
6613
|
+
try {
|
|
6614
|
+
const client = getClient();
|
|
6615
|
+
let baseVersion = options.baseVersion === void 0 ? void 0 : Number(options.baseVersion);
|
|
6616
|
+
if (baseVersion === void 0) {
|
|
6617
|
+
const latest = await client.pages.history(id, { limit: 1 });
|
|
6618
|
+
baseVersion = latest.revisions[0]?.docVersion;
|
|
6619
|
+
}
|
|
6620
|
+
const result = await client.pages.restore(id, options.revision, {
|
|
6621
|
+
note: options.note,
|
|
6622
|
+
baseVersion
|
|
6623
|
+
});
|
|
6624
|
+
if (useJson) console.log(JSON.stringify(result, null, 2));
|
|
6625
|
+
else {
|
|
6626
|
+
console.log(
|
|
6627
|
+
`
|
|
6628
|
+
\u2713 Page restored (now v${result.docVersion}, revision ${result.revisionId})`
|
|
6629
|
+
);
|
|
6630
|
+
}
|
|
6631
|
+
} catch (error) {
|
|
6632
|
+
handleError(error, useJson);
|
|
6633
|
+
}
|
|
6634
|
+
}
|
|
6635
|
+
);
|
|
5829
6636
|
pages.addCommand(createPageCommentsCommand());
|
|
5830
6637
|
return pages;
|
|
5831
6638
|
}
|
|
5832
6639
|
|
|
5833
6640
|
// src/commands/products.ts
|
|
5834
|
-
import { Command as
|
|
6641
|
+
import { Command as Command19 } from "commander";
|
|
5835
6642
|
function createProductsCommand() {
|
|
5836
|
-
const products = new
|
|
6643
|
+
const products = new Command19("products").description(
|
|
5837
6644
|
"Manage products. A workspace contains products; a product holds features and tickets."
|
|
5838
6645
|
);
|
|
5839
6646
|
products.command("list").description("List products in a workspace").option("--workspace <slug|id>", "Workspace slug or CUID (defaults to configured workspace)").action(async (options, cmd) => {
|
|
@@ -5974,7 +6781,7 @@ Re-run with --force to delete it anyway.`
|
|
|
5974
6781
|
}
|
|
5975
6782
|
|
|
5976
6783
|
// src/commands/projects.ts
|
|
5977
|
-
import { Command as
|
|
6784
|
+
import { Command as Command20 } from "commander";
|
|
5978
6785
|
var PROJECT_STATUSES = [
|
|
5979
6786
|
"ACTIVE",
|
|
5980
6787
|
"ON_HOLD",
|
|
@@ -6001,7 +6808,7 @@ function validateProjectPriority(value) {
|
|
|
6001
6808
|
return value;
|
|
6002
6809
|
}
|
|
6003
6810
|
function createProjectsCommand() {
|
|
6004
|
-
const projects = new
|
|
6811
|
+
const projects = new Command20("projects").description("Manage projects");
|
|
6005
6812
|
projects.command("list").description("List all projects").option("--workspace <slug|id>", "Workspace slug or CUID").option("--include-actions", "Include actions in output").action(async (options, cmd) => {
|
|
6006
6813
|
const globalOpts = cmd.optsWithGlobals();
|
|
6007
6814
|
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
@@ -6120,7 +6927,7 @@ Re-run with --force to delete it anyway.`
|
|
|
6120
6927
|
}
|
|
6121
6928
|
|
|
6122
6929
|
// src/commands/resources.ts
|
|
6123
|
-
import { Command as
|
|
6930
|
+
import { Command as Command21 } from "commander";
|
|
6124
6931
|
var STATUS_FILTERS = ["unread", "to_read", "reading", "read", "all"];
|
|
6125
6932
|
function validateStatus(value) {
|
|
6126
6933
|
const v = value ?? "unread";
|
|
@@ -6129,11 +6936,16 @@ function validateStatus(value) {
|
|
|
6129
6936
|
}
|
|
6130
6937
|
return v;
|
|
6131
6938
|
}
|
|
6939
|
+
function collectTags(value, previous) {
|
|
6940
|
+
const next = value.split(",").map((t) => t.trim()).filter(Boolean);
|
|
6941
|
+
return [.../* @__PURE__ */ new Set([...previous, ...next])];
|
|
6942
|
+
}
|
|
6943
|
+
var TAG_OPTION = "--tag <tag>";
|
|
6132
6944
|
function createResourcesCommand() {
|
|
6133
|
-
const resources = new
|
|
6945
|
+
const resources = new Command21("resources").description(
|
|
6134
6946
|
"Saved links and reference material. `list` defaults to the Reading list (unread); `create --url` saves a link to read later."
|
|
6135
6947
|
);
|
|
6136
|
-
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(
|
|
6948
|
+
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(
|
|
6137
6949
|
async (options, cmd) => {
|
|
6138
6950
|
const globalOpts = cmd.optsWithGlobals();
|
|
6139
6951
|
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
@@ -6145,16 +6957,22 @@ function createResourcesCommand() {
|
|
|
6145
6957
|
workspaceId,
|
|
6146
6958
|
readStatus: status === "all" ? void 0 : status,
|
|
6147
6959
|
search: options.search,
|
|
6960
|
+
tags: options.tag.length > 0 ? options.tag : void 0,
|
|
6148
6961
|
limit: Number.parseInt(options.limit, 10) || 50
|
|
6149
6962
|
});
|
|
6150
|
-
if (useJson) outputResourcesJson(rows, { status });
|
|
6963
|
+
if (useJson) outputResourcesJson(rows, { status, ...options.tag.length > 0 && { tags: options.tag } });
|
|
6151
6964
|
else outputResourcesPretty(rows, status);
|
|
6152
6965
|
} catch (error) {
|
|
6153
6966
|
handleError(error, useJson);
|
|
6154
6967
|
}
|
|
6155
6968
|
}
|
|
6156
6969
|
);
|
|
6157
|
-
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(
|
|
6970
|
+
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(
|
|
6971
|
+
TAG_OPTION,
|
|
6972
|
+
"Label it, e.g. where it came from (repeatable or comma-separated; added to any tags a re-saved link has)",
|
|
6973
|
+
collectTags,
|
|
6974
|
+
[]
|
|
6975
|
+
).option("--workspace <slug|id>", "Workspace (defaults to the configured default)").option("--read", "Save as already read (reference material, not a queue item)").action(
|
|
6158
6976
|
async (options, cmd) => {
|
|
6159
6977
|
const globalOpts = cmd.optsWithGlobals();
|
|
6160
6978
|
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
@@ -6165,6 +6983,7 @@ function createResourcesCommand() {
|
|
|
6165
6983
|
url: options.url,
|
|
6166
6984
|
title: options.title,
|
|
6167
6985
|
note: options.note,
|
|
6986
|
+
tags: options.tag.length > 0 ? options.tag : void 0,
|
|
6168
6987
|
workspaceId,
|
|
6169
6988
|
readStatus: options.read ? "read" : "to_read"
|
|
6170
6989
|
});
|
|
@@ -6178,6 +6997,28 @@ function createResourcesCommand() {
|
|
|
6178
6997
|
}
|
|
6179
6998
|
}
|
|
6180
6999
|
);
|
|
7000
|
+
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) => {
|
|
7001
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
7002
|
+
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
7003
|
+
try {
|
|
7004
|
+
if (options.add.length === 0 && options.remove.length === 0) {
|
|
7005
|
+
throw new Error("Pass --add <tag> and/or --remove <tag>");
|
|
7006
|
+
}
|
|
7007
|
+
const client = getClient();
|
|
7008
|
+
const current = await client.resources.get(id);
|
|
7009
|
+
const kept = (current.tags ?? []).filter((t) => !options.remove.includes(t));
|
|
7010
|
+
const tags = [.../* @__PURE__ */ new Set([...kept, ...options.add])];
|
|
7011
|
+
const resource = await client.resources.update(id, { tags });
|
|
7012
|
+
if (useJson) outputResourceJson(resource);
|
|
7013
|
+
else {
|
|
7014
|
+
console.log(`
|
|
7015
|
+
\u2713 Tags updated`);
|
|
7016
|
+
outputResourcePretty(resource);
|
|
7017
|
+
}
|
|
7018
|
+
} catch (error) {
|
|
7019
|
+
handleError(error, useJson);
|
|
7020
|
+
}
|
|
7021
|
+
});
|
|
6181
7022
|
const setStatus = (name, readStatus, description) => resources.command(`${name} <id>`).description(description).action(async (id, _options, cmd) => {
|
|
6182
7023
|
const globalOpts = cmd.optsWithGlobals();
|
|
6183
7024
|
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
@@ -6208,7 +7049,7 @@ function createResourcesCommand() {
|
|
|
6208
7049
|
}
|
|
6209
7050
|
|
|
6210
7051
|
// src/commands/runner.ts
|
|
6211
|
-
import { Command as
|
|
7052
|
+
import { Command as Command22 } from "commander";
|
|
6212
7053
|
import { hostname, homedir as homedir2, tmpdir as tmpdir2 } from "os";
|
|
6213
7054
|
import { execFileSync } from "child_process";
|
|
6214
7055
|
import { mkdirSync as mkdirSync3 } from "fs";
|
|
@@ -6660,7 +7501,7 @@ function removeServiceFile(plan) {
|
|
|
6660
7501
|
|
|
6661
7502
|
// src/commands/runner.ts
|
|
6662
7503
|
function createRunnerCommand() {
|
|
6663
|
-
const cmd = new
|
|
7504
|
+
const cmd = new Command22("runner").description(
|
|
6664
7505
|
"Run your Assistant locally: claim its queued runs and work them with Claude Code on this machine"
|
|
6665
7506
|
);
|
|
6666
7507
|
cmd.command("start").description("Poll for queued runs and work them until stopped (Ctrl-C)").option("--runner-id <id>", "Name of this runner, recorded on each run", hostname()).option("--cwd <dir>", "Working directory for the spawned CLI (overrides runner config; never from the server)").option("--interval <seconds>", "Seconds between polls when nothing is queued", "15").option("--once", "Claim at most one run, work it, and exit").option("--no-mcp", "Spawn without the Exponential MCP run tools (progress still streams; the session cannot ask the owner)").action(async (opts) => {
|
|
@@ -6771,8 +7612,19 @@ ${plan.contents}
|
|
|
6771
7612
|
}
|
|
6772
7613
|
|
|
6773
7614
|
// src/commands/search.ts
|
|
6774
|
-
import { Command as
|
|
6775
|
-
import
|
|
7615
|
+
import { Command as Command23 } from "commander";
|
|
7616
|
+
import chalk10 from "chalk";
|
|
7617
|
+
var KNOWLEDGE_TYPES = ["transcription", "resource", "document", "page"];
|
|
7618
|
+
function parseTypes(value) {
|
|
7619
|
+
if (!value) return void 0;
|
|
7620
|
+
const types = value.split(",").map((t) => t.trim()).filter(Boolean);
|
|
7621
|
+
for (const t of types) {
|
|
7622
|
+
if (!KNOWLEDGE_TYPES.includes(t)) {
|
|
7623
|
+
throw new Error(`Unknown source type "${t}". Use: ${KNOWLEDGE_TYPES.join(", ")}`);
|
|
7624
|
+
}
|
|
7625
|
+
}
|
|
7626
|
+
return types;
|
|
7627
|
+
}
|
|
6776
7628
|
var TYPE_LABELS = {
|
|
6777
7629
|
workspace: "Workspaces",
|
|
6778
7630
|
project: "Projects",
|
|
@@ -6790,9 +7642,9 @@ var TYPE_LABELS = {
|
|
|
6790
7642
|
product: "Products"
|
|
6791
7643
|
};
|
|
6792
7644
|
function createSearchCommand() {
|
|
6793
|
-
const search = new
|
|
6794
|
-
"Global search across projects, actions, goals, workspaces and more \u2014 same coverage as the app's Cmd+K palette"
|
|
6795
|
-
).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) => {
|
|
7645
|
+
const search = new Command23("search").description(
|
|
7646
|
+
"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."
|
|
7647
|
+
).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) => {
|
|
6796
7648
|
const globalOpts = cmd.optsWithGlobals();
|
|
6797
7649
|
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
6798
7650
|
try {
|
|
@@ -6804,23 +7656,53 @@ function createSearchCommand() {
|
|
|
6804
7656
|
(w) => w.slug === options.workspace || w.id === options.workspace
|
|
6805
7657
|
);
|
|
6806
7658
|
if (!match) {
|
|
6807
|
-
console.error(
|
|
6808
|
-
console.log(
|
|
7659
|
+
console.error(chalk10.red(`Workspace "${options.workspace}" not found.`));
|
|
7660
|
+
console.log(chalk10.gray("Available workspaces:"));
|
|
6809
7661
|
workspaces.forEach((w) => {
|
|
6810
|
-
console.log(
|
|
7662
|
+
console.log(chalk10.gray(` - ${w.slug} (${w.name})`));
|
|
6811
7663
|
});
|
|
6812
7664
|
process.exit(1);
|
|
6813
7665
|
}
|
|
6814
7666
|
workspaceId = match.id;
|
|
6815
7667
|
}
|
|
6816
7668
|
const limit = options.limit ? Number(options.limit) : void 0;
|
|
7669
|
+
if (options.semantic) {
|
|
7670
|
+
if (!workspaceId) {
|
|
7671
|
+
throw new Error("--semantic searches one workspace at a time: pass --workspace <slug>.");
|
|
7672
|
+
}
|
|
7673
|
+
const knowledge = await client.search.knowledge({
|
|
7674
|
+
query,
|
|
7675
|
+
workspaceId,
|
|
7676
|
+
limit,
|
|
7677
|
+
sourceTypes: parseTypes(options.types)
|
|
7678
|
+
});
|
|
7679
|
+
if (useJson) {
|
|
7680
|
+
console.log(JSON.stringify(knowledge, null, 2));
|
|
7681
|
+
return;
|
|
7682
|
+
}
|
|
7683
|
+
if (knowledge.results.length === 0) {
|
|
7684
|
+
console.log(chalk10.gray(`Nothing about "${knowledge.query}" in the Knowledge index.`));
|
|
7685
|
+
return;
|
|
7686
|
+
}
|
|
7687
|
+
console.log(chalk10.bold(`
|
|
7688
|
+
About "${knowledge.query}"`));
|
|
7689
|
+
for (const row of knowledge.results) {
|
|
7690
|
+
console.log(
|
|
7691
|
+
` ${chalk10.white(row.title)} ${chalk10.gray(`\xB7 ${row.sourceType} \xB7 ${Math.round(row.similarity * 100)}%`)}`
|
|
7692
|
+
);
|
|
7693
|
+
console.log(chalk10.gray(` ${row.sourceId} ${row.url}`));
|
|
7694
|
+
if (row.snippet) console.log(` ${row.snippet}`);
|
|
7695
|
+
}
|
|
7696
|
+
console.log();
|
|
7697
|
+
return;
|
|
7698
|
+
}
|
|
6817
7699
|
const result = await client.search.global({ query, workspaceId, limit });
|
|
6818
7700
|
if (useJson) {
|
|
6819
7701
|
console.log(JSON.stringify(result, null, 2));
|
|
6820
7702
|
return;
|
|
6821
7703
|
}
|
|
6822
7704
|
if (result.results.length === 0) {
|
|
6823
|
-
console.log(
|
|
7705
|
+
console.log(chalk10.gray(`No matches for "${result.query}".`));
|
|
6824
7706
|
return;
|
|
6825
7707
|
}
|
|
6826
7708
|
const byType = /* @__PURE__ */ new Map();
|
|
@@ -6830,14 +7712,14 @@ function createSearchCommand() {
|
|
|
6830
7712
|
byType.set(r.type, bucket);
|
|
6831
7713
|
}
|
|
6832
7714
|
for (const [type, rows] of byType) {
|
|
6833
|
-
console.log(
|
|
7715
|
+
console.log(chalk10.bold(`
|
|
6834
7716
|
${TYPE_LABELS[type] ?? type}`));
|
|
6835
7717
|
for (const row of rows) {
|
|
6836
|
-
const parts = [
|
|
6837
|
-
if (row.subtitle) parts.push(
|
|
6838
|
-
if (row.workspace) parts.push(
|
|
6839
|
-
console.log(` ${parts.join(
|
|
6840
|
-
console.log(
|
|
7718
|
+
const parts = [chalk10.white(row.title)];
|
|
7719
|
+
if (row.subtitle) parts.push(chalk10.gray(row.subtitle));
|
|
7720
|
+
if (row.workspace) parts.push(chalk10.cyan(`@${row.workspace.slug}`));
|
|
7721
|
+
console.log(` ${parts.join(chalk10.gray(" \xB7 "))}`);
|
|
7722
|
+
console.log(chalk10.gray(` ${row.id}${row.url ? ` ${row.url}` : ""}`));
|
|
6841
7723
|
}
|
|
6842
7724
|
}
|
|
6843
7725
|
console.log();
|
|
@@ -6849,7 +7731,7 @@ ${TYPE_LABELS[type] ?? type}`));
|
|
|
6849
7731
|
}
|
|
6850
7732
|
|
|
6851
7733
|
// src/commands/tickets.ts
|
|
6852
|
-
import { Command as
|
|
7734
|
+
import { Command as Command24 } from "commander";
|
|
6853
7735
|
function collectRepeatable(value, previous) {
|
|
6854
7736
|
return [...previous, value];
|
|
6855
7737
|
}
|
|
@@ -6892,7 +7774,7 @@ function validateTicketType(value) {
|
|
|
6892
7774
|
return value;
|
|
6893
7775
|
}
|
|
6894
7776
|
function createTicketsCommand() {
|
|
6895
|
-
const tickets = new
|
|
7777
|
+
const tickets = new Command24("tickets").description(
|
|
6896
7778
|
"Manage product backlog tickets. Tickets live under a product, link to features/epics, depend on each other, and can be implemented via actions."
|
|
6897
7779
|
);
|
|
6898
7780
|
tickets.command("list").description(
|
|
@@ -7261,7 +8143,7 @@ function createTicketsCommand() {
|
|
|
7261
8143
|
handleError(error, useJson);
|
|
7262
8144
|
}
|
|
7263
8145
|
});
|
|
7264
|
-
const comment = new
|
|
8146
|
+
const comment = new Command24("comment").description("Manage comments on a ticket");
|
|
7265
8147
|
comment.command("list").description("List comments on a ticket").requiredOption("--id <id>", "Ticket CUID").action(async (options, cmd) => {
|
|
7266
8148
|
const globalOpts = cmd.optsWithGlobals();
|
|
7267
8149
|
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
@@ -7353,7 +8235,7 @@ function createTicketsCommand() {
|
|
|
7353
8235
|
}
|
|
7354
8236
|
|
|
7355
8237
|
// src/commands/time.ts
|
|
7356
|
-
import { Command as
|
|
8238
|
+
import { Command as Command25 } from "commander";
|
|
7357
8239
|
import { segmentConversation } from "exponential-sdk";
|
|
7358
8240
|
var SOURCES2 = ["manual", "claude-desktop", "agent-run"];
|
|
7359
8241
|
var STATUSES2 = ["PROPOSED", "CONFIRMED"];
|
|
@@ -7443,7 +8325,7 @@ function batchItemToInput(item, index, defaults) {
|
|
|
7443
8325
|
};
|
|
7444
8326
|
}
|
|
7445
8327
|
function createTimeCommand() {
|
|
7446
|
-
const time = new
|
|
8328
|
+
const time = new Command25("time").description(
|
|
7447
8329
|
`Time entries \u2014 log the day's work and list it. ${OWNERSHIP_NOTE}`
|
|
7448
8330
|
);
|
|
7449
8331
|
time.command("log").description(
|
|
@@ -7613,10 +8495,10 @@ function parseMessagesFile(raw) {
|
|
|
7613
8495
|
}
|
|
7614
8496
|
|
|
7615
8497
|
// src/commands/workspaces.ts
|
|
7616
|
-
import { Command as
|
|
7617
|
-
import
|
|
8498
|
+
import { Command as Command26 } from "commander";
|
|
8499
|
+
import chalk11 from "chalk";
|
|
7618
8500
|
function createWorkspacesCommand() {
|
|
7619
|
-
const workspaces = new
|
|
8501
|
+
const workspaces = new Command26("workspaces").description("Manage workspaces");
|
|
7620
8502
|
workspaces.command("list").description("List all workspaces").action(async (_options, cmd) => {
|
|
7621
8503
|
const globalOpts = cmd.optsWithGlobals();
|
|
7622
8504
|
const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
|
|
@@ -7629,7 +8511,7 @@ function createWorkspacesCommand() {
|
|
|
7629
8511
|
const config = getConfig();
|
|
7630
8512
|
outputWorkspacesPretty(workspaces2);
|
|
7631
8513
|
if (config.defaultWorkspaceSlug) {
|
|
7632
|
-
console.log(
|
|
8514
|
+
console.log(chalk11.gray(`Default workspace: ${config.defaultWorkspaceSlug}`));
|
|
7633
8515
|
}
|
|
7634
8516
|
}
|
|
7635
8517
|
} catch (error) {
|
|
@@ -7642,10 +8524,10 @@ function createWorkspacesCommand() {
|
|
|
7642
8524
|
const workspaces2 = await client.workspaces.list();
|
|
7643
8525
|
const workspace = workspaces2.find((w) => w.slug === slug);
|
|
7644
8526
|
if (!workspace) {
|
|
7645
|
-
console.error(
|
|
7646
|
-
console.log(
|
|
8527
|
+
console.error(chalk11.red(`Workspace with slug "${slug}" not found.`));
|
|
8528
|
+
console.log(chalk11.gray("Available workspaces:"));
|
|
7647
8529
|
workspaces2.forEach((w) => {
|
|
7648
|
-
console.log(
|
|
8530
|
+
console.log(chalk11.gray(` - ${w.slug} (${w.name})`));
|
|
7649
8531
|
});
|
|
7650
8532
|
process.exit(1);
|
|
7651
8533
|
}
|
|
@@ -7653,7 +8535,7 @@ function createWorkspacesCommand() {
|
|
|
7653
8535
|
defaultWorkspaceId: workspace.id,
|
|
7654
8536
|
defaultWorkspaceSlug: workspace.slug
|
|
7655
8537
|
});
|
|
7656
|
-
console.log(
|
|
8538
|
+
console.log(chalk11.green(`Default workspace set to: ${workspace.name} (${workspace.slug})`));
|
|
7657
8539
|
} catch (error) {
|
|
7658
8540
|
handleError(error);
|
|
7659
8541
|
}
|
|
@@ -7681,20 +8563,20 @@ function createWorkspacesCommand() {
|
|
|
7681
8563
|
return;
|
|
7682
8564
|
}
|
|
7683
8565
|
if (members.length === 0) {
|
|
7684
|
-
console.log(
|
|
8566
|
+
console.log(chalk11.gray("No members found."));
|
|
7685
8567
|
return;
|
|
7686
8568
|
}
|
|
7687
|
-
console.log(
|
|
8569
|
+
console.log(chalk11.bold(`
|
|
7688
8570
|
Members (${members.length})
|
|
7689
8571
|
`));
|
|
7690
8572
|
for (const m of members) {
|
|
7691
8573
|
const label = m.name ?? m.email ?? m.id;
|
|
7692
|
-
const via = m.source === "team" ?
|
|
8574
|
+
const via = m.source === "team" ? chalk11.gray(
|
|
7693
8575
|
` via team${m.teams.length ? `: ${m.teams.map((t) => t.name).join(", ")}` : ""}` + (m.teamRole ? ` [team ${m.teamRole}]` : "")
|
|
7694
8576
|
) : "";
|
|
7695
|
-
console.log(`${
|
|
7696
|
-
if (m.email) console.log(
|
|
7697
|
-
console.log(
|
|
8577
|
+
console.log(`${chalk11.bold(label)} ${chalk11.gray(`(${m.role})`)}${via}`);
|
|
8578
|
+
if (m.email) console.log(chalk11.gray(` ${m.email}`));
|
|
8579
|
+
console.log(chalk11.gray(` mention: ${m.mentionSyntax}`));
|
|
7698
8580
|
console.log();
|
|
7699
8581
|
}
|
|
7700
8582
|
} catch (error) {
|
|
@@ -7706,7 +8588,7 @@ Members (${members.length})
|
|
|
7706
8588
|
}
|
|
7707
8589
|
|
|
7708
8590
|
// src/commands/goals.ts
|
|
7709
|
-
import { Command as
|
|
8591
|
+
import { Command as Command27 } from "commander";
|
|
7710
8592
|
var GOAL_STATUSES = [
|
|
7711
8593
|
"planned",
|
|
7712
8594
|
"active",
|
|
@@ -7818,7 +8700,7 @@ function validateKeyResultUnit(value) {
|
|
|
7818
8700
|
return value;
|
|
7819
8701
|
}
|
|
7820
8702
|
function createKeyResultsCommand() {
|
|
7821
|
-
const kr = new
|
|
8703
|
+
const kr = new Command27("kr").description(
|
|
7822
8704
|
"Key results on an objective. Ids are CUIDs; --goal takes the objective's integer id."
|
|
7823
8705
|
);
|
|
7824
8706
|
kr.command("list").description("List key results").option("--goal <id>", "Objective ID (a number)").option("-w, --workspace <slug|id>", "Workspace (workspace-wide: every member's KRs)").option("--period <period>", "Period, e.g. Q3-2026").option("--status <status>", `Filter by status: ${KEY_RESULT_STATUSES.join(", ")}`).option("--mine", "Narrow a workspace list to key results you own").action(
|
|
@@ -8021,7 +8903,7 @@ function createKeyResultsCommand() {
|
|
|
8021
8903
|
return kr;
|
|
8022
8904
|
}
|
|
8023
8905
|
function createGoalCommentsCommand() {
|
|
8024
|
-
const comment = new
|
|
8906
|
+
const comment = new Command27("comment").description(
|
|
8025
8907
|
"Read and post comments on a goal. Mention teammates with --mention."
|
|
8026
8908
|
);
|
|
8027
8909
|
comment.command("list").description("List comments on a goal").requiredOption("--goal <id>", "Goal ID (a number)").action(async (options, cmd) => {
|
|
@@ -8116,7 +8998,7 @@ function createGoalCommentsCommand() {
|
|
|
8116
8998
|
return comment;
|
|
8117
8999
|
}
|
|
8118
9000
|
function createGoalsCommand() {
|
|
8119
|
-
const goals = new
|
|
9001
|
+
const goals = new Command27("goals").description(
|
|
8120
9002
|
"Manage goals (objectives) and their key results. Objectives have integer ids; key results are CUIDs."
|
|
8121
9003
|
);
|
|
8122
9004
|
goals.command("list").description(
|
|
@@ -8403,7 +9285,7 @@ Re-run with --with-key-results to go ahead, or move them with \`goals kr update
|
|
|
8403
9285
|
return goals;
|
|
8404
9286
|
}
|
|
8405
9287
|
function createOkrsCommand() {
|
|
8406
|
-
const okrs = new
|
|
9288
|
+
const okrs = new Command27("okrs").description(
|
|
8407
9289
|
"OKRs \u2014 objectives with their key results nested. Manage the parts with `goals` and `goals kr`."
|
|
8408
9290
|
);
|
|
8409
9291
|
okrs.command("list").description(
|
|
@@ -8492,7 +9374,7 @@ function isBareVersionRequest(args) {
|
|
|
8492
9374
|
return args.includes("--version") && args.every((arg) => arg.startsWith("-"));
|
|
8493
9375
|
}
|
|
8494
9376
|
function buildProgram() {
|
|
8495
|
-
const program = new
|
|
9377
|
+
const program = new Command28();
|
|
8496
9378
|
program.name("exponential").description(
|
|
8497
9379
|
[
|
|
8498
9380
|
"CLI to interact with Exponential productivity app.",
|
|
@@ -8505,6 +9387,7 @@ function buildProgram() {
|
|
|
8505
9387
|
program.addCommand(createAuthCommand());
|
|
8506
9388
|
program.addCommand(createActionsCommand());
|
|
8507
9389
|
program.addCommand(createContactsCommand());
|
|
9390
|
+
program.addCommand(createDatabasesCommand());
|
|
8508
9391
|
program.addCommand(createDecisionsCommand());
|
|
8509
9392
|
program.addCommand(createDealsCommand());
|
|
8510
9393
|
program.addCommand(createEpicsCommand());
|