exponential-cli 1.22.0 → 1.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1394,20 +1394,115 @@ Pipeline Stages (${stages.length})`));
1394
1394
  function outputPageJson(page) {
1395
1395
  console.log(JSON.stringify(page, null, 2));
1396
1396
  }
1397
+ function formatBytes(bytes) {
1398
+ if (bytes < 1024) return `${bytes} B`;
1399
+ return `${(bytes / 1024).toFixed(bytes < 10 * 1024 ? 1 : 0)} KB`;
1400
+ }
1401
+ function formatDay(value) {
1402
+ return new Date(value).toISOString().slice(0, 10);
1403
+ }
1397
1404
  function outputPagePretty(page) {
1398
1405
  console.log(chalk3.gray("\u2500".repeat(50)));
1399
1406
  console.log(`
1400
1407
  ${chalk3.bold(page.title)}`);
1401
- console.log(chalk3.gray(` ID: ${page.id}`));
1408
+ console.log(chalk3.gray(` ID: ${page.id} v${page.docVersion}`));
1402
1409
  if (page.project) {
1403
1410
  console.log(` ${chalk3.gray("Project:")} ${page.project.name}`);
1404
1411
  }
1412
+ if (page.asOf || page.source) {
1413
+ const parts = [];
1414
+ if (page.asOf) parts.push(`As of ${formatDay(page.asOf)}`);
1415
+ if (page.source) parts.push(`Source: ${page.source}`);
1416
+ console.log(` ${chalk3.gray(parts.join(" \xB7 "))}`);
1417
+ }
1418
+ if (typeof page.bodyBytes === "number") {
1419
+ const scope = page.section ? ` (showing section "${page.section.text}")` : "";
1420
+ console.log(chalk3.gray(` Body: ${formatBytes(page.bodyBytes)}${scope}`));
1421
+ }
1422
+ if (page.outline) {
1423
+ console.log();
1424
+ if (page.outline.length === 0) console.log(chalk3.gray(" (no headings)"));
1425
+ for (const h of page.outline) {
1426
+ console.log(
1427
+ ` ${" ".repeat(h.level - 1)}${chalk3.gray("#".repeat(h.level))} ${h.text} ${chalk3.gray(`L${h.line + 1}`)}`
1428
+ );
1429
+ }
1430
+ console.log();
1431
+ return;
1432
+ }
1405
1433
  if (page.body) {
1406
1434
  console.log(`
1407
1435
  ${page.body}
1408
1436
  `);
1409
1437
  }
1410
1438
  }
1439
+ function outputPageSearchPretty(result) {
1440
+ if (result.results.length === 0) {
1441
+ console.log(chalk3.gray(`No pages about "${result.query}".`));
1442
+ return;
1443
+ }
1444
+ console.log(chalk3.bold(`
1445
+ Pages about "${result.query}" (${result.results.length})`));
1446
+ console.log(chalk3.gray("\u2500".repeat(50)));
1447
+ for (const r of result.results) {
1448
+ const score = r.similarity === null ? chalk3.gray("text match") : chalk3.gray(`${Math.round(r.similarity * 100)}%`);
1449
+ console.log(` ${chalk3.bold(r.title)} ${score}`);
1450
+ console.log(chalk3.gray(` ID: ${r.id} ${r.url}`));
1451
+ if (r.snippet) console.log(` ${r.snippet}`);
1452
+ }
1453
+ console.log();
1454
+ }
1455
+ function outputPageHistoryPretty(history) {
1456
+ if (history.revisions.length === 0) {
1457
+ console.log(chalk3.gray("No revisions yet."));
1458
+ return;
1459
+ }
1460
+ const n = history.revisions.length;
1461
+ console.log(chalk3.bold(`
1462
+ History (${n} revision${n === 1 ? "" : "s"})`));
1463
+ console.log(chalk3.gray("\u2500".repeat(50)));
1464
+ for (const r of history.revisions) {
1465
+ const when = new Date(r.updatedAt).toISOString().replace("T", " ").slice(0, 16);
1466
+ const who = r.kind === "baseline" ? "before history" : r.authorHidden ? "a member" : r.author?.name ?? "automated";
1467
+ console.log(
1468
+ ` ${chalk3.gray(when)} ${chalk3.bold(who)} ${chalk3.cyan(r.kind)} v${r.docVersion} ${chalk3.gray(formatBytes(r.bodyBytes))}`
1469
+ );
1470
+ console.log(chalk3.gray(` ${r.id} "${r.title}"`));
1471
+ if (r.note) console.log(` ${r.note}`);
1472
+ else if (r.kind === "markdown" || r.kind === "restore") console.log(chalk3.gray(" (no reason given)"));
1473
+ }
1474
+ if (history.nextCursor) {
1475
+ console.log(chalk3.gray(`
1476
+ More: --cursor ${history.nextCursor}`));
1477
+ }
1478
+ console.log();
1479
+ }
1480
+ function outputPageDiffPretty(diff) {
1481
+ const side = (s) => s.revisionId ? `${s.revisionId} (v${s.docVersion})` : s.createdAt ? "current" : "(empty)";
1482
+ console.log(chalk3.gray(`${side(diff.from)} \u2192 ${side(diff.to)}`));
1483
+ if (diff.titleChanged) {
1484
+ console.log(chalk3.red(`- title: ${diff.from.title}`));
1485
+ console.log(chalk3.green(`+ title: ${diff.to.title}`));
1486
+ }
1487
+ if (diff.provenanceChanged) {
1488
+ const prov = (s) => `as of ${s.asOf ? formatDay(s.asOf) : "\u2014"} \xB7 source ${s.source ?? "\u2014"}`;
1489
+ console.log(chalk3.red(`- ${prov(diff.from)}`));
1490
+ console.log(chalk3.green(`+ ${prov(diff.to)}`));
1491
+ }
1492
+ if (!diff.unified) {
1493
+ console.log(chalk3.gray("No changes to the body."));
1494
+ return;
1495
+ }
1496
+ console.log(chalk3.gray(`+${diff.stats.added} \u2212${diff.stats.removed}
1497
+ `));
1498
+ for (const line of diff.unified.split("\n")) {
1499
+ if (line.startsWith("+++") || line.startsWith("---") || line.startsWith("@@")) {
1500
+ console.log(chalk3.gray(line));
1501
+ } else if (line.startsWith("+")) console.log(chalk3.green(line));
1502
+ else if (line.startsWith("-")) console.log(chalk3.red(line));
1503
+ else console.log(line);
1504
+ }
1505
+ }
1411
1506
  function outputPagesJson(pages) {
1412
1507
  console.log(JSON.stringify({ pages, total: pages.length }, null, 2));
1413
1508
  }
@@ -2514,6 +2609,9 @@ function hostnameOf(url) {
2514
2609
  return null;
2515
2610
  }
2516
2611
  }
2612
+ function formatResourceTags(tags) {
2613
+ return `Tags: ${tags.join(", ")}`;
2614
+ }
2517
2615
  function transformResource(r) {
2518
2616
  return {
2519
2617
  id: r.id,
@@ -2537,6 +2635,7 @@ function outputResourcePretty(resource) {
2537
2635
  console.log(` ${badge} ${chalk3.bold(resource.title)}`);
2538
2636
  if (resource.url) console.log(chalk3.gray(` ${resource.url}`));
2539
2637
  if (resource.description) console.log(` ${resource.description}`);
2638
+ if (resource.tags?.length) console.log(chalk3.cyan(` ${formatResourceTags(resource.tags)}`));
2540
2639
  console.log(chalk3.gray(` ID: ${resource.id}`));
2541
2640
  }
2542
2641
  function outputResourcesJson(resources, filters = {}) {
@@ -2558,6 +2657,7 @@ ${heading} (${resources.length} total)`));
2558
2657
  const host = hostnameOf(r.url);
2559
2658
  console.log(` ${chalk3.bold(r.title)}${host ? chalk3.gray(` ${host}`) : ""} ${chalk3.gray(when.toLocaleDateString())}`);
2560
2659
  if (r.description) console.log(chalk3.gray(` ${r.description}`));
2660
+ if (r.tags?.length) console.log(chalk3.cyan(` ${formatResourceTags(r.tags)}`));
2561
2661
  console.log(chalk3.gray(` ID: ${r.id}`));
2562
2662
  }
2563
2663
  console.log();
@@ -5649,6 +5749,7 @@ function createOrganizationsCommand() {
5649
5749
 
5650
5750
  // src/commands/pages.ts
5651
5751
  import { Command as Command17 } from "commander";
5752
+ import chalk8 from "chalk";
5652
5753
 
5653
5754
  // src/commands/pageComments.ts
5654
5755
  import { Command as Command16 } from "commander";
@@ -5747,11 +5848,22 @@ function createPageCommentsCommand() {
5747
5848
  }
5748
5849
 
5749
5850
  // src/commands/pages.ts
5851
+ function parseLimit(value) {
5852
+ if (value === void 0) return void 0;
5853
+ const n = Number(value);
5854
+ if (!Number.isInteger(n) || n < 1) {
5855
+ throw new Error(`--limit must be a positive integer, got "${value}"`);
5856
+ }
5857
+ return n;
5858
+ }
5750
5859
  function createPagesCommand() {
5751
5860
  const pages = new Command17("pages").description(
5752
- 'Manage Knowledge pages (PRDs, research, technical specs). Link one to a feature with "features link-page".'
5861
+ `Manage Knowledge pages (PRDs, research, technical specs). Reads are Markdown-only by default; every write is recorded in the page's history. Link one to a feature with "features link-page".`
5753
5862
  );
5754
- pages.command("list").description("List pages in a workspace").option("--workspace <slug|id>", "Workspace (defaults to the configured default)").option("--search <text>", "Filter by title/content").action(
5863
+ pages.command("list").description("List pages in a workspace (metadata only, no bodies)").option("--workspace <slug|id>", "Workspace (defaults to the configured default)").option(
5864
+ "--search <text>",
5865
+ 'Case-insensitive title match. To find pages by content or meaning use "pages search".'
5866
+ ).action(
5755
5867
  async (options, cmd) => {
5756
5868
  const globalOpts = cmd.optsWithGlobals();
5757
5869
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
@@ -5769,19 +5881,51 @@ function createPagesCommand() {
5769
5881
  }
5770
5882
  }
5771
5883
  );
5772
- pages.command("get <id>").description("Get a page by CUID (body is Markdown)").action(async (id, _options, cmd) => {
5773
- const globalOpts = cmd.optsWithGlobals();
5774
- const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
5775
- try {
5776
- const client = getClient();
5777
- const page = await client.pages.get(id);
5778
- if (useJson) outputPageJson(page);
5779
- else outputPagePretty(page);
5780
- } catch (error) {
5781
- handleError(error, useJson);
5884
+ pages.command("search <query>").description(
5885
+ "Find pages by meaning: semantic hits from the Knowledge index first (with the matching passage), then pages whose title or body contain the text"
5886
+ ).option("--workspace <slug|id>", "Workspace (defaults to the configured default)").option("--project <id>", "Only pages filed under this project").option("-l, --limit <n>", "Max pages (1-25, default 10)").action(
5887
+ async (query, options, cmd) => {
5888
+ const globalOpts = cmd.optsWithGlobals();
5889
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
5890
+ try {
5891
+ const client = getClient();
5892
+ const workspaceId = await resolveWorkspaceId(client, options.workspace);
5893
+ const result = await client.pages.search({
5894
+ workspaceId,
5895
+ query,
5896
+ projectId: options.project,
5897
+ limit: parseLimit(options.limit)
5898
+ });
5899
+ if (useJson) console.log(JSON.stringify(result, null, 2));
5900
+ else outputPageSearchPretty(result);
5901
+ } catch (error) {
5902
+ handleError(error, useJson);
5903
+ }
5782
5904
  }
5783
- });
5784
- 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)').action(
5905
+ );
5906
+ pages.command("get <id>").description(
5907
+ "Get a page by CUID. Markdown body only by default (the editor doc is never sent). --outline shows its headings; --section reads one part."
5908
+ ).option("--outline", "Headings only (level, text, line) and the body size, no body").option(
5909
+ "--section <heading>",
5910
+ `Only this heading's section (case-insensitive; a "## " prefix is allowed)`
5911
+ ).option("--full", "Include the editor's ProseMirror document as well (large)").action(
5912
+ async (id, options, cmd) => {
5913
+ const globalOpts = cmd.optsWithGlobals();
5914
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
5915
+ try {
5916
+ const client = getClient();
5917
+ const page = await client.pages.get(id, {
5918
+ format: options.outline ? "outline" : options.full ? "full" : "markdown",
5919
+ section: options.section
5920
+ });
5921
+ if (useJson) outputPageJson(page);
5922
+ else outputPagePretty(page);
5923
+ } catch (error) {
5924
+ handleError(error, useJson);
5925
+ }
5926
+ }
5927
+ );
5928
+ pages.command("create").description("Create a page. Body: -b text, --body-file <path>, or --body-file - for stdin.").option("--workspace <slug|id>", "Workspace (defaults to the configured default)").requiredOption("-t, --title <title>", "Page title").option("-b, --body <markdown>", "Markdown body").option("--body-file <path>", 'Read the Markdown body from a file ("-" = stdin)').option("--project <id>", "File the page under a project").option("--source <text>", "Where the facts come from: a URL, a document, a person").option("--as-of <date>", "The date the facts were true (YYYY-MM-DD)").option("-n, --note <text>", "Why: recorded on the page's first revision").action(
5785
5929
  async (options, cmd) => {
5786
5930
  const globalOpts = cmd.optsWithGlobals();
5787
5931
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
@@ -5790,8 +5934,12 @@ function createPagesCommand() {
5790
5934
  const workspaceId = await resolveWorkspaceId(client, options.workspace);
5791
5935
  const page = await client.pages.create({
5792
5936
  workspaceId,
5937
+ projectId: options.project,
5793
5938
  title: options.title,
5794
- body: readText(options.body, options.bodyFile)
5939
+ body: readText(options.body, options.bodyFile),
5940
+ source: options.source,
5941
+ asOf: parseDate(options.asOf),
5942
+ note: options.note
5795
5943
  });
5796
5944
  if (useJson) outputPageJson(page);
5797
5945
  else {
@@ -5804,8 +5952,8 @@ function createPagesCommand() {
5804
5952
  }
5805
5953
  );
5806
5954
  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(
5955
+ "Update a page. Sending a body is a Markdown-source write: the Markdown becomes canonical. Pass --base-version so a newer edit by someone else is a CONFLICT, not an overwrite."
5956
+ ).requiredOption("--id <id>", "Page CUID").option("-t, --title <title>", "New title").option("-b, --body <markdown>", "New Markdown body (replaces the whole body)").option("--body-file <path>", 'Read the new Markdown body from a file ("-" = stdin)').option("--base-version <n>", "The docVersion you read before editing (compare-and-set)").option("-n, --note <text>", "Why this change: shown in the page's history").option("--source <text>", "Where the facts come from (an empty string clears it)").option("--as-of <date>", "The date the facts were true (YYYY-MM-DD)").option("--clear-as-of", "Remove the as-of date").action(
5809
5957
  async (options, cmd) => {
5810
5958
  const globalOpts = cmd.optsWithGlobals();
5811
5959
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
@@ -5814,7 +5962,11 @@ function createPagesCommand() {
5814
5962
  const page = await client.pages.update({
5815
5963
  id: options.id,
5816
5964
  title: options.title,
5817
- body: readText(options.body, options.bodyFile)
5965
+ body: readText(options.body, options.bodyFile),
5966
+ baseVersion: options.baseVersion === void 0 ? void 0 : Number(options.baseVersion),
5967
+ note: options.note,
5968
+ source: options.source,
5969
+ asOf: options.clearAsOf ? null : parseDate(options.asOf)
5818
5970
  });
5819
5971
  if (useJson) outputPageJson(page);
5820
5972
  else {
@@ -5826,6 +5978,107 @@ function createPagesCommand() {
5826
5978
  }
5827
5979
  }
5828
5980
  );
5981
+ pages.command("history <id>").description(
5982
+ "The page's revisions, newest first: who, when, why and the body size. Never the bodies."
5983
+ ).option("-l, --limit <n>", "Max revisions (1-200, default 50)").option("--cursor <revisionId>", "Continue from a previous page of history").action(
5984
+ async (id, options, cmd) => {
5985
+ const globalOpts = cmd.optsWithGlobals();
5986
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
5987
+ try {
5988
+ const client = getClient();
5989
+ const history = await client.pages.history(id, {
5990
+ limit: parseLimit(options.limit),
5991
+ cursor: options.cursor
5992
+ });
5993
+ if (useJson) console.log(JSON.stringify(history, null, 2));
5994
+ else outputPageHistoryPretty(history);
5995
+ } catch (error) {
5996
+ handleError(error, useJson);
5997
+ }
5998
+ }
5999
+ );
6000
+ pages.command("revision <id> <revisionId>").description("One revision with its Markdown body").action(
6001
+ async (id, revisionId, _options, cmd) => {
6002
+ const globalOpts = cmd.optsWithGlobals();
6003
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
6004
+ try {
6005
+ const client = getClient();
6006
+ const revision = await client.pages.revision(id, revisionId);
6007
+ if (useJson) console.log(JSON.stringify(revision, null, 2));
6008
+ else {
6009
+ console.log(chalk8.gray("\u2500".repeat(50)));
6010
+ console.log(
6011
+ `
6012
+ ${chalk8.bold(revision.title)} ${chalk8.gray(`v${revision.docVersion} \xB7 ${revision.kind}`)}`
6013
+ );
6014
+ console.log(chalk8.gray(` Revision: ${revision.id}`));
6015
+ if (revision.note) console.log(` ${chalk8.gray("Note:")} ${revision.note}`);
6016
+ if (revision.body) console.log(`
6017
+ ${revision.body}
6018
+ `);
6019
+ }
6020
+ } catch (error) {
6021
+ handleError(error, useJson);
6022
+ }
6023
+ }
6024
+ );
6025
+ pages.command("diff <id>").description(
6026
+ "What a revision changed, as a unified diff of the Markdown. Defaults to the latest revision against the one before it."
6027
+ ).option("--revision <revisionId>", "The revision to inspect (default: the latest)").option(
6028
+ "--against <previous|current|revisionId>",
6029
+ "What to compare with: the revision before it (default), the page as it is now, or another revision"
6030
+ ).action(
6031
+ async (id, options, cmd) => {
6032
+ const globalOpts = cmd.optsWithGlobals();
6033
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
6034
+ try {
6035
+ const client = getClient();
6036
+ let revisionId = options.revision;
6037
+ if (!revisionId) {
6038
+ const latest = await client.pages.history(id, { limit: 1 });
6039
+ revisionId = latest.revisions[0]?.id;
6040
+ if (!revisionId) throw new Error("This page has no revisions yet.");
6041
+ }
6042
+ const diff = await client.pages.diff(id, revisionId, { against: options.against });
6043
+ if (useJson) console.log(JSON.stringify(diff, null, 2));
6044
+ else outputPageDiffPretty(diff);
6045
+ } catch (error) {
6046
+ handleError(error, useJson);
6047
+ }
6048
+ }
6049
+ );
6050
+ pages.command("restore <id>").description(
6051
+ "Put a revision's title and body back as the page's current content. A forward write: the history keeps what was replaced."
6052
+ ).requiredOption("--revision <revisionId>", 'The revision to restore (see "pages history")').option("-n, --note <text>", "Why: recorded on the restore revision").option(
6053
+ "--base-version <n>",
6054
+ `The page version you looked at (newest revision's v-number in "pages history"); a newer save makes this a CONFLICT. Defaults to the newest revision now.`
6055
+ ).action(
6056
+ async (id, options, cmd) => {
6057
+ const globalOpts = cmd.optsWithGlobals();
6058
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
6059
+ try {
6060
+ const client = getClient();
6061
+ let baseVersion = options.baseVersion === void 0 ? void 0 : Number(options.baseVersion);
6062
+ if (baseVersion === void 0) {
6063
+ const latest = await client.pages.history(id, { limit: 1 });
6064
+ baseVersion = latest.revisions[0]?.docVersion;
6065
+ }
6066
+ const result = await client.pages.restore(id, options.revision, {
6067
+ note: options.note,
6068
+ baseVersion
6069
+ });
6070
+ if (useJson) console.log(JSON.stringify(result, null, 2));
6071
+ else {
6072
+ console.log(
6073
+ `
6074
+ \u2713 Page restored (now v${result.docVersion}, revision ${result.revisionId})`
6075
+ );
6076
+ }
6077
+ } catch (error) {
6078
+ handleError(error, useJson);
6079
+ }
6080
+ }
6081
+ );
5829
6082
  pages.addCommand(createPageCommentsCommand());
5830
6083
  return pages;
5831
6084
  }
@@ -6129,11 +6382,16 @@ function validateStatus(value) {
6129
6382
  }
6130
6383
  return v;
6131
6384
  }
6385
+ function collectTags(value, previous) {
6386
+ const next = value.split(",").map((t) => t.trim()).filter(Boolean);
6387
+ return [.../* @__PURE__ */ new Set([...previous, ...next])];
6388
+ }
6389
+ var TAG_OPTION = "--tag <tag>";
6132
6390
  function createResourcesCommand() {
6133
6391
  const resources = new Command20("resources").description(
6134
6392
  "Saved links and reference material. `list` defaults to the Reading list (unread); `create --url` saves a link to read later."
6135
6393
  );
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(
6394
+ resources.command("list").description("List resources. Defaults to the Reading list (unread); --status read for what you finished, all for everything.").option("--workspace <slug|id>", "Workspace (defaults to the configured default)").option("--status <status>", `One of: ${STATUS_FILTERS.join(", ")} (default: unread)`).option("--search <text>", "Filter by title/description").option(TAG_OPTION, "Only resources with this tag (repeatable or comma-separated; matches any)", collectTags, []).option("--limit <n>", "Max rows (default 50)", "50").action(
6137
6395
  async (options, cmd) => {
6138
6396
  const globalOpts = cmd.optsWithGlobals();
6139
6397
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
@@ -6145,16 +6403,22 @@ function createResourcesCommand() {
6145
6403
  workspaceId,
6146
6404
  readStatus: status === "all" ? void 0 : status,
6147
6405
  search: options.search,
6406
+ tags: options.tag.length > 0 ? options.tag : void 0,
6148
6407
  limit: Number.parseInt(options.limit, 10) || 50
6149
6408
  });
6150
- if (useJson) outputResourcesJson(rows, { status });
6409
+ if (useJson) outputResourcesJson(rows, { status, ...options.tag.length > 0 && { tags: options.tag } });
6151
6410
  else outputResourcesPretty(rows, status);
6152
6411
  } catch (error) {
6153
6412
  handleError(error, useJson);
6154
6413
  }
6155
6414
  }
6156
6415
  );
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("--workspace <slug|id>", "Workspace (defaults to the configured default)").option("--read", "Save as already read (reference material, not a queue item)").action(
6416
+ resources.command("create").description("Save a link to the Reading list (to read later). Stored by title and URL; not fetched or indexed.").requiredOption("--url <url>", "The http(s) link to save").option("-t, --title <title>", "Title (defaults to the hostname)").option("--note <text>", "One-line note (why, or who recommended it)").option(
6417
+ TAG_OPTION,
6418
+ "Label it, e.g. where it came from (repeatable or comma-separated; added to any tags a re-saved link has)",
6419
+ collectTags,
6420
+ []
6421
+ ).option("--workspace <slug|id>", "Workspace (defaults to the configured default)").option("--read", "Save as already read (reference material, not a queue item)").action(
6158
6422
  async (options, cmd) => {
6159
6423
  const globalOpts = cmd.optsWithGlobals();
6160
6424
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
@@ -6165,6 +6429,7 @@ function createResourcesCommand() {
6165
6429
  url: options.url,
6166
6430
  title: options.title,
6167
6431
  note: options.note,
6432
+ tags: options.tag.length > 0 ? options.tag : void 0,
6168
6433
  workspaceId,
6169
6434
  readStatus: options.read ? "read" : "to_read"
6170
6435
  });
@@ -6178,6 +6443,28 @@ function createResourcesCommand() {
6178
6443
  }
6179
6444
  }
6180
6445
  );
6446
+ resources.command("tag <id>").description("Add or remove a resource's tags").option("--add <tag>", "Tag to add (repeatable or comma-separated)", collectTags, []).option("--remove <tag>", "Tag to remove (repeatable or comma-separated)", collectTags, []).action(async (id, options, cmd) => {
6447
+ const globalOpts = cmd.optsWithGlobals();
6448
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
6449
+ try {
6450
+ if (options.add.length === 0 && options.remove.length === 0) {
6451
+ throw new Error("Pass --add <tag> and/or --remove <tag>");
6452
+ }
6453
+ const client = getClient();
6454
+ const current = await client.resources.get(id);
6455
+ const kept = (current.tags ?? []).filter((t) => !options.remove.includes(t));
6456
+ const tags = [.../* @__PURE__ */ new Set([...kept, ...options.add])];
6457
+ const resource = await client.resources.update(id, { tags });
6458
+ if (useJson) outputResourceJson(resource);
6459
+ else {
6460
+ console.log(`
6461
+ \u2713 Tags updated`);
6462
+ outputResourcePretty(resource);
6463
+ }
6464
+ } catch (error) {
6465
+ handleError(error, useJson);
6466
+ }
6467
+ });
6181
6468
  const setStatus = (name, readStatus, description) => resources.command(`${name} <id>`).description(description).action(async (id, _options, cmd) => {
6182
6469
  const globalOpts = cmd.optsWithGlobals();
6183
6470
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
@@ -6772,7 +7059,18 @@ ${plan.contents}
6772
7059
 
6773
7060
  // src/commands/search.ts
6774
7061
  import { Command as Command22 } from "commander";
6775
- import chalk8 from "chalk";
7062
+ import chalk9 from "chalk";
7063
+ var KNOWLEDGE_TYPES = ["transcription", "resource", "document", "page"];
7064
+ function parseTypes(value) {
7065
+ if (!value) return void 0;
7066
+ const types = value.split(",").map((t) => t.trim()).filter(Boolean);
7067
+ for (const t of types) {
7068
+ if (!KNOWLEDGE_TYPES.includes(t)) {
7069
+ throw new Error(`Unknown source type "${t}". Use: ${KNOWLEDGE_TYPES.join(", ")}`);
7070
+ }
7071
+ }
7072
+ return types;
7073
+ }
6776
7074
  var TYPE_LABELS = {
6777
7075
  workspace: "Workspaces",
6778
7076
  project: "Projects",
@@ -6791,8 +7089,8 @@ var TYPE_LABELS = {
6791
7089
  };
6792
7090
  function createSearchCommand() {
6793
7091
  const search = new Command22("search").description(
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) => {
7092
+ "Global search across projects, actions, goals, workspaces and more \u2014 same coverage as the app's Cmd+K palette. Matches titles; add --semantic to search meetings, resources, documents and pages by meaning."
7093
+ ).argument("<query>", "Text to search for").option("-w, --workspace <slug>", "Restrict results to one workspace (slug or ID; required with --semantic)").option("-l, --limit <n>", "Max results per entity type (1-25, default 10; 1-20 with --semantic)").option("--semantic", "Search the Knowledge index by meaning instead of matching titles").option("--types <list>", "With --semantic: comma-separated source kinds (transcription,resource,document,page)").action(async (query, options, cmd) => {
6796
7094
  const globalOpts = cmd.optsWithGlobals();
6797
7095
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
6798
7096
  try {
@@ -6804,23 +7102,53 @@ function createSearchCommand() {
6804
7102
  (w) => w.slug === options.workspace || w.id === options.workspace
6805
7103
  );
6806
7104
  if (!match) {
6807
- console.error(chalk8.red(`Workspace "${options.workspace}" not found.`));
6808
- console.log(chalk8.gray("Available workspaces:"));
7105
+ console.error(chalk9.red(`Workspace "${options.workspace}" not found.`));
7106
+ console.log(chalk9.gray("Available workspaces:"));
6809
7107
  workspaces.forEach((w) => {
6810
- console.log(chalk8.gray(` - ${w.slug} (${w.name})`));
7108
+ console.log(chalk9.gray(` - ${w.slug} (${w.name})`));
6811
7109
  });
6812
7110
  process.exit(1);
6813
7111
  }
6814
7112
  workspaceId = match.id;
6815
7113
  }
6816
7114
  const limit = options.limit ? Number(options.limit) : void 0;
7115
+ if (options.semantic) {
7116
+ if (!workspaceId) {
7117
+ throw new Error("--semantic searches one workspace at a time: pass --workspace <slug>.");
7118
+ }
7119
+ const knowledge = await client.search.knowledge({
7120
+ query,
7121
+ workspaceId,
7122
+ limit,
7123
+ sourceTypes: parseTypes(options.types)
7124
+ });
7125
+ if (useJson) {
7126
+ console.log(JSON.stringify(knowledge, null, 2));
7127
+ return;
7128
+ }
7129
+ if (knowledge.results.length === 0) {
7130
+ console.log(chalk9.gray(`Nothing about "${knowledge.query}" in the Knowledge index.`));
7131
+ return;
7132
+ }
7133
+ console.log(chalk9.bold(`
7134
+ About "${knowledge.query}"`));
7135
+ for (const row of knowledge.results) {
7136
+ console.log(
7137
+ ` ${chalk9.white(row.title)} ${chalk9.gray(`\xB7 ${row.sourceType} \xB7 ${Math.round(row.similarity * 100)}%`)}`
7138
+ );
7139
+ console.log(chalk9.gray(` ${row.sourceId} ${row.url}`));
7140
+ if (row.snippet) console.log(` ${row.snippet}`);
7141
+ }
7142
+ console.log();
7143
+ return;
7144
+ }
6817
7145
  const result = await client.search.global({ query, workspaceId, limit });
6818
7146
  if (useJson) {
6819
7147
  console.log(JSON.stringify(result, null, 2));
6820
7148
  return;
6821
7149
  }
6822
7150
  if (result.results.length === 0) {
6823
- console.log(chalk8.gray(`No matches for "${result.query}".`));
7151
+ console.log(chalk9.gray(`No matches for "${result.query}".`));
6824
7152
  return;
6825
7153
  }
6826
7154
  const byType = /* @__PURE__ */ new Map();
@@ -6830,14 +7158,14 @@ function createSearchCommand() {
6830
7158
  byType.set(r.type, bucket);
6831
7159
  }
6832
7160
  for (const [type, rows] of byType) {
6833
- console.log(chalk8.bold(`
7161
+ console.log(chalk9.bold(`
6834
7162
  ${TYPE_LABELS[type] ?? type}`));
6835
7163
  for (const row of rows) {
6836
- const parts = [chalk8.white(row.title)];
6837
- if (row.subtitle) parts.push(chalk8.gray(row.subtitle));
6838
- if (row.workspace) parts.push(chalk8.cyan(`@${row.workspace.slug}`));
6839
- console.log(` ${parts.join(chalk8.gray(" \xB7 "))}`);
6840
- console.log(chalk8.gray(` ${row.id}${row.url ? ` ${row.url}` : ""}`));
7164
+ const parts = [chalk9.white(row.title)];
7165
+ if (row.subtitle) parts.push(chalk9.gray(row.subtitle));
7166
+ if (row.workspace) parts.push(chalk9.cyan(`@${row.workspace.slug}`));
7167
+ console.log(` ${parts.join(chalk9.gray(" \xB7 "))}`);
7168
+ console.log(chalk9.gray(` ${row.id}${row.url ? ` ${row.url}` : ""}`));
6841
7169
  }
6842
7170
  }
6843
7171
  console.log();
@@ -7614,7 +7942,7 @@ function parseMessagesFile(raw) {
7614
7942
 
7615
7943
  // src/commands/workspaces.ts
7616
7944
  import { Command as Command25 } from "commander";
7617
- import chalk9 from "chalk";
7945
+ import chalk10 from "chalk";
7618
7946
  function createWorkspacesCommand() {
7619
7947
  const workspaces = new Command25("workspaces").description("Manage workspaces");
7620
7948
  workspaces.command("list").description("List all workspaces").action(async (_options, cmd) => {
@@ -7629,7 +7957,7 @@ function createWorkspacesCommand() {
7629
7957
  const config = getConfig();
7630
7958
  outputWorkspacesPretty(workspaces2);
7631
7959
  if (config.defaultWorkspaceSlug) {
7632
- console.log(chalk9.gray(`Default workspace: ${config.defaultWorkspaceSlug}`));
7960
+ console.log(chalk10.gray(`Default workspace: ${config.defaultWorkspaceSlug}`));
7633
7961
  }
7634
7962
  }
7635
7963
  } catch (error) {
@@ -7642,10 +7970,10 @@ function createWorkspacesCommand() {
7642
7970
  const workspaces2 = await client.workspaces.list();
7643
7971
  const workspace = workspaces2.find((w) => w.slug === slug);
7644
7972
  if (!workspace) {
7645
- console.error(chalk9.red(`Workspace with slug "${slug}" not found.`));
7646
- console.log(chalk9.gray("Available workspaces:"));
7973
+ console.error(chalk10.red(`Workspace with slug "${slug}" not found.`));
7974
+ console.log(chalk10.gray("Available workspaces:"));
7647
7975
  workspaces2.forEach((w) => {
7648
- console.log(chalk9.gray(` - ${w.slug} (${w.name})`));
7976
+ console.log(chalk10.gray(` - ${w.slug} (${w.name})`));
7649
7977
  });
7650
7978
  process.exit(1);
7651
7979
  }
@@ -7653,7 +7981,7 @@ function createWorkspacesCommand() {
7653
7981
  defaultWorkspaceId: workspace.id,
7654
7982
  defaultWorkspaceSlug: workspace.slug
7655
7983
  });
7656
- console.log(chalk9.green(`Default workspace set to: ${workspace.name} (${workspace.slug})`));
7984
+ console.log(chalk10.green(`Default workspace set to: ${workspace.name} (${workspace.slug})`));
7657
7985
  } catch (error) {
7658
7986
  handleError(error);
7659
7987
  }
@@ -7681,20 +8009,20 @@ function createWorkspacesCommand() {
7681
8009
  return;
7682
8010
  }
7683
8011
  if (members.length === 0) {
7684
- console.log(chalk9.gray("No members found."));
8012
+ console.log(chalk10.gray("No members found."));
7685
8013
  return;
7686
8014
  }
7687
- console.log(chalk9.bold(`
8015
+ console.log(chalk10.bold(`
7688
8016
  Members (${members.length})
7689
8017
  `));
7690
8018
  for (const m of members) {
7691
8019
  const label = m.name ?? m.email ?? m.id;
7692
- const via = m.source === "team" ? chalk9.gray(
8020
+ const via = m.source === "team" ? chalk10.gray(
7693
8021
  ` via team${m.teams.length ? `: ${m.teams.map((t) => t.name).join(", ")}` : ""}` + (m.teamRole ? ` [team ${m.teamRole}]` : "")
7694
8022
  ) : "";
7695
- console.log(`${chalk9.bold(label)} ${chalk9.gray(`(${m.role})`)}${via}`);
7696
- if (m.email) console.log(chalk9.gray(` ${m.email}`));
7697
- console.log(chalk9.gray(` mention: ${m.mentionSyntax}`));
8023
+ console.log(`${chalk10.bold(label)} ${chalk10.gray(`(${m.role})`)}${via}`);
8024
+ if (m.email) console.log(chalk10.gray(` ${m.email}`));
8025
+ console.log(chalk10.gray(` mention: ${m.mentionSyntax}`));
7698
8026
  console.log();
7699
8027
  }
7700
8028
  } catch (error) {