@warmhub/cli 0.138.0 → 0.139.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.
Files changed (2) hide show
  1. package/dist/wh.js +186 -75
  2. package/package.json +1 -1
package/dist/wh.js CHANGED
@@ -18164,7 +18164,8 @@ var COMMIT_OPERATIONS = [
18164
18164
  "revise",
18165
18165
  "retract",
18166
18166
  "reaffirm",
18167
- "rename"
18167
+ "rename",
18168
+ "remove"
18168
18169
  ];
18169
18170
  var COMMIT_OPERATION_KINDS = [
18170
18171
  "shape",
@@ -43665,7 +43666,11 @@ function normalizeCommitValidationOperations(operations, skipExisting) {
43665
43666
  return operations.map((operation, index) => {
43666
43667
  let normalized;
43667
43668
  try {
43668
- normalized = toBackendStreamOperation(operation);
43669
+ normalized = operation.operation === "remove" ? {
43670
+ operation: "remove",
43671
+ name: operation.name,
43672
+ expectedVersion: operation.expectedVersion
43673
+ } : toBackendStreamOperation(operation);
43669
43674
  } catch (error51) {
43670
43675
  const message = error51 instanceof Error ? error51.message : String(error51);
43671
43676
  throw new CommitValidationInputError(`Invalid operation at index ${index}: ${message}`);
@@ -44595,6 +44600,7 @@ var DEFINITE_CLIENT_REJECT_CODES = new Set([
44595
44600
  "KIND_MISMATCH",
44596
44601
  "CONFLICT",
44597
44602
  "NAME_TAKEN",
44603
+ "TARGET_REMOVED",
44598
44604
  "ALREADY_RETRACTED",
44599
44605
  "ARCHIVED",
44600
44606
  "RATE_LIMITED",
@@ -45000,6 +45006,11 @@ var currentErrorDetailsSchema = exports_external.discriminatedUnion("reason", [
45000
45006
  name: exports_external.string().min(1),
45001
45007
  takenBy: exports_external.object({ shape: exports_external.string().min(1), durableId: exports_external.string().min(1) }).loose().optional(),
45002
45008
  suggestedName: exports_external.string().min(1).optional()
45009
+ }).loose(),
45010
+ exports_external.object({
45011
+ reason: exports_external.literal("target_removed"),
45012
+ targetDurableId: exports_external.string().min(1),
45013
+ fieldPath: exports_external.string().optional()
45003
45014
  }).loose()
45004
45015
  ]);
45005
45016
  var currentBaseShape = {
@@ -45490,7 +45501,7 @@ function createStreamingSubmissionHandle(input, deps) {
45490
45501
  // ../../packages/sdk-ts/package.json
45491
45502
  var package_default = {
45492
45503
  name: "@warmhub/sdk-ts",
45493
- version: "0.136.0",
45504
+ version: "0.137.0",
45494
45505
  private: false,
45495
45506
  type: "module",
45496
45507
  description: "The TypeScript SDK for WarmHub — create repos, commit and query data, and compound knowledge with your AI agents.",
@@ -45990,7 +46001,11 @@ function toWarmHubError(error51) {
45990
46001
  if (error51 instanceof Error) {
45991
46002
  const warmhubLike = error51;
45992
46003
  if (error51.name === "WarmHubError" && typeof warmhubLike.code === "string") {
45993
- return new WarmHubError(warmhubLike.code, sanitizeErrorMessage(error51.message), typeof warmhubLike.status === "number" ? warmhubLike.status : undefined, typeof warmhubLike.hint === "string" ? warmhubLike.hint : undefined, typeof warmhubLike.retryAfter === "number" ? warmhubLike.retryAfter : undefined, typeof warmhubLike.errorCode === "string" ? warmhubLike.errorCode : typeof warmhubLike.backendCode === "string" ? warmhubLike.backendCode : undefined, warmhubLike.details);
46004
+ const mapped = new WarmHubError(warmhubLike.code, sanitizeErrorMessage(error51.message), typeof warmhubLike.status === "number" ? warmhubLike.status : undefined, typeof warmhubLike.hint === "string" ? warmhubLike.hint : undefined, typeof warmhubLike.retryAfter === "number" ? warmhubLike.retryAfter : undefined, typeof warmhubLike.errorCode === "string" ? warmhubLike.errorCode : typeof warmhubLike.backendCode === "string" ? warmhubLike.backendCode : undefined, warmhubLike.details);
46005
+ if (isAllFailedStreamError(error51)) {
46006
+ Object.defineProperty(mapped, ALL_OPERATIONS_FAILED, { value: true });
46007
+ }
46008
+ return mapped;
45994
46009
  }
45995
46010
  if (error51.name === "AbortError") {
45996
46011
  return new WarmHubError("CANCELLED", error51.message);
@@ -46002,6 +46017,15 @@ function toWarmHubError(error51) {
46002
46017
  }
46003
46018
  return new WarmHubError("BACKEND", "Unknown SDK error");
46004
46019
  }
46020
+ var ALL_OPERATIONS_FAILED = Symbol.for("@warmhub/sdk-ts:allStreamOperationsFailed");
46021
+ function isAllFailedStreamError(error51) {
46022
+ if (error51 instanceof AllStreamOperationsFailedError)
46023
+ return true;
46024
+ if (!(error51 instanceof Error))
46025
+ return false;
46026
+ const shape = error51;
46027
+ return shape[ALL_OPERATIONS_FAILED] === true || shape.name === "WarmHubError" && Array.isArray(shape.receipts) && Array.isArray(shape.operations);
46028
+ }
46005
46029
  function isWarmHubError(error51) {
46006
46030
  return error51 instanceof WarmHubError;
46007
46031
  }
@@ -47674,6 +47698,19 @@ class WarmHubClient {
47674
47698
  throw toWarmHubError(error51);
47675
47699
  }
47676
47700
  },
47701
+ remove: async (orgName, repoName, wref, opts) => {
47702
+ try {
47703
+ return await this.trpc.thing.remove.mutate({
47704
+ orgName,
47705
+ repoName,
47706
+ wref,
47707
+ expectedVersion: opts.expectedVersion,
47708
+ eventRequestId: opts.eventRequestId
47709
+ });
47710
+ } catch (error51) {
47711
+ throw toWarmHubError(error51);
47712
+ }
47713
+ },
47677
47714
  resolve: async (orgName, repoName, wref) => {
47678
47715
  try {
47679
47716
  return await this.trpc.thing.resolve.query({
@@ -48412,6 +48449,8 @@ function classifyConflict(message, code) {
48412
48449
  return "incremental-read-unavailable";
48413
48450
  case "NAME_TAKEN":
48414
48451
  return "name-taken";
48452
+ case "TARGET_REMOVED":
48453
+ return "target-removed";
48415
48454
  case undefined:
48416
48455
  default:
48417
48456
  break;
@@ -48452,6 +48491,8 @@ function conflictHint(message, code) {
48452
48491
  const suggested = /for example "([^"]+)"/.exec(message)?.[1];
48453
48492
  return suggested ? `Another Thing in this repository holds this name. Use "${suggested}" or another free name; retrying the same name cannot succeed.` : "Another Thing in this repository holds this name. Choose another name; retrying the same name cannot succeed.";
48454
48493
  }
48494
+ case "target-removed":
48495
+ return "The referenced Thing was removed and cannot be referenced again. Point the reference at another Thing or drop it; retrying cannot succeed.";
48455
48496
  case "other":
48456
48497
  default:
48457
48498
  return "Resolve the conflicting existing state and try again.";
@@ -48476,6 +48517,7 @@ var TOP_LEVEL_USER_INPUT_CODES = new Set([
48476
48517
  var CONFLICT_SHAPED_CODES = new Set([
48477
48518
  "CONFLICT",
48478
48519
  "NAME_TAKEN",
48520
+ "TARGET_REMOVED",
48479
48521
  "ALREADY_EXISTS",
48480
48522
  "BUILTIN_SHAPE_CONFLICT",
48481
48523
  "ARCHIVED",
@@ -48693,6 +48735,11 @@ function generateSuggestions(code, message, context, errorCode) {
48693
48735
  action: "Choose a name no other Thing in the repository holds (use details.suggestedName when the error carries one)"
48694
48736
  });
48695
48737
  break;
48738
+ case "target-removed":
48739
+ suggestions.push({
48740
+ action: "The referenced Thing was removed (details.targetDurableId names it). Reference another Thing or drop the reference"
48741
+ });
48742
+ break;
48696
48743
  case "lease-held":
48697
48744
  suggestions.push({
48698
48745
  action: "Another holder leased this thing. Back off until the lease expires (leaseExpiresAt / retryAfter), then retry"
@@ -52586,7 +52633,7 @@ function emitPartialPageHint(ctx, count, _nextCursor, _limit) {
52586
52633
  }
52587
52634
 
52588
52635
  // ../../packages/warmhub-cli/src/domains/commit-output-contract-id.ts
52589
- var COMMIT_SUBMIT_OUTPUT_SCHEMA_ID = "wh.commit.submit.result/v0.5";
52636
+ var COMMIT_SUBMIT_OUTPUT_SCHEMA_ID = "wh.commit.submit.result/v0.6";
52590
52637
  function identifyCommitSubmitOutput(value) {
52591
52638
  if ("schema" in value) {
52592
52639
  if (value.schema === COMMIT_SUBMIT_OUTPUT_SCHEMA_ID) {
@@ -54441,6 +54488,119 @@ var handleReleaseLease = async (ctx, { flags, args }) => {
54441
54488
  });
54442
54489
  };
54443
54490
 
54491
+ // ../../packages/warmhub-cli/src/domains/commit-validation-render.ts
54492
+ function renderCommitValidation(ctx, result) {
54493
+ if (ctx.format === "json") {
54494
+ ctx.out(JSON.stringify(result));
54495
+ } else if (ctx.format === "jsonl") {
54496
+ for (const operation of result.operations) {
54497
+ ctx.out(JSON.stringify({ type: "operation", ...operation }));
54498
+ }
54499
+ const { operations: _operations, ...summary } = result;
54500
+ ctx.out(JSON.stringify({ type: "summary", ...summary }));
54501
+ } else {
54502
+ renderPrettyValidation(ctx, result);
54503
+ }
54504
+ const error51 = containedDiagnosticError(validationDiagnostics(result));
54505
+ if (error51)
54506
+ ctx.requestedExitCode = error51.code;
54507
+ }
54508
+ function renderPrettyValidation(ctx, result) {
54509
+ const c = ctx.colors;
54510
+ const baseline = result.baseline.kind === "repo_seq" ? `repo sequence ${result.baseline.repoSeq}` : "withheld";
54511
+ ctx.out(`${c.dim}validation baseline${c.reset} ${baseline}`);
54512
+ for (const caveat of result.caveats) {
54513
+ ctx.out(` ${ctx.chars.warn} ${c.dim}${caveat.code}${c.reset} ${caveat.message}`);
54514
+ }
54515
+ for (const operation of result.operations) {
54516
+ const marker = markerFor(operation.status, ctx);
54517
+ ctx.out(`${marker} [${operation.opIndex}] ${operation.operation} ${displayName(c, operation.name)} ${operation.status}`);
54518
+ renderDiagnostics(ctx, operation.status === "error" ? operation.errors : undefined);
54519
+ for (const effect of operation.effects ?? []) {
54520
+ renderEffect(ctx, effect);
54521
+ }
54522
+ }
54523
+ ctx.out(`${c.bold}${result.canCommit ? "can commit" : "cannot commit"}${c.reset} — ${result.counts.wouldApply} would apply, ${result.counts.noop} noop, ${result.counts.error} error`);
54524
+ }
54525
+ function renderEffect(ctx, effect) {
54526
+ ctx.out(` ${markerFor(effect.status, ctx)} effect ${effect.effectIndex}: ${effect.operation} ${displayName(ctx.colors, effect.name)} ${effect.status}`);
54527
+ renderDiagnostics(ctx, "errors" in effect ? effect.errors : undefined, 6);
54528
+ }
54529
+ function renderDiagnostics(ctx, diagnostics, indent = 4) {
54530
+ for (const diagnostic of diagnostics ?? []) {
54531
+ ctx.out(`${" ".repeat(indent)}${diagnostic.code}: ${diagnostic.message}`);
54532
+ }
54533
+ }
54534
+ function markerFor(status, ctx) {
54535
+ if (status === "error" || status === "discarded")
54536
+ return ctx.chars.cross;
54537
+ if (status === "noop")
54538
+ return ctx.chars.warn;
54539
+ return ctx.chars.check;
54540
+ }
54541
+ function validationDiagnostics(result) {
54542
+ const diagnostics = [];
54543
+ for (const operation of result.operations) {
54544
+ if (operation.status === "error")
54545
+ diagnostics.push(...operation.errors);
54546
+ for (const effect of operation.effects ?? []) {
54547
+ if ("errors" in effect)
54548
+ diagnostics.push(...effect.errors);
54549
+ }
54550
+ }
54551
+ return diagnostics;
54552
+ }
54553
+
54554
+ // ../../packages/warmhub-cli/src/domains/thing/remove.ts
54555
+ var USAGE = "Usage: wh thing remove <wref|durableId> [--expected-version <n>] [--yes]";
54556
+ var EXAMPLE = "wh thing remove Location/cave --yes";
54557
+ var removeFlags = {
54558
+ "expected-version": flag.number({
54559
+ description: "only remove if the Thing is still at this version (default: the version read before removing)"
54560
+ }),
54561
+ yes: flag.boolean({ short: "y", description: "Skip confirmation prompt" }),
54562
+ "event-request-id": operationEventRequestIdFlag
54563
+ };
54564
+ var handleThingRemove = async (ctx, { flags, args }) => {
54565
+ const target = args[0];
54566
+ if (!target)
54567
+ usageError(USAGE, EXAMPLE);
54568
+ const { org, repo } = parseOrgRepo(getRepoRef(ctx), ctx.config);
54569
+ const c = ctx.colors;
54570
+ let expectedVersion = parsePositiveIntFlag(flags["expected-version"], "--expected-version", "wh thing remove Location/cave --expected-version 3");
54571
+ let label = target;
54572
+ if (expectedVersion === undefined || !flags.yes && !ctx.dryRun) {
54573
+ const thing = await ctx.client.thing.get(org, repo, target, undefined, {
54574
+ includeRetracted: true
54575
+ });
54576
+ expectedVersion ??= thing.version;
54577
+ label = `${thing.wref} (${thing.metadata?.durableId ?? target})`;
54578
+ }
54579
+ if (ctx.dryRun) {
54580
+ const validation = await ctx.client.commit.validate(org, repo, [
54581
+ { operation: "remove", name: target, expectedVersion }
54582
+ ]);
54583
+ renderCommitValidation(ctx, validation);
54584
+ return;
54585
+ }
54586
+ if (!flags.yes) {
54587
+ const confirmed = await ctx.confirm?.(`Permanently remove ${label} at v${expectedVersion}? This deletes the Thing and all its versions.`);
54588
+ if (!confirmed) {
54589
+ ctx.status("Cancelled");
54590
+ return;
54591
+ }
54592
+ }
54593
+ const eventRequestId = flags["event-request-id"] ?? createOperationEventRequestId();
54594
+ ctx.status(`Operation event request: ${eventRequestId}`);
54595
+ const receipt = await ctx.client.thing.remove(org, repo, target, {
54596
+ eventRequestId,
54597
+ expectedVersion
54598
+ });
54599
+ writeOutput(ctx, receipt, () => {
54600
+ ctx.out(`${c.green}Removed${c.reset} ${displayName(c, label)}`);
54601
+ });
54602
+ };
54603
+
54444
54604
  // ../../packages/warmhub-cli/src/domains/thing/rename.ts
54445
54605
  var renameFlags = {
54446
54606
  "event-request-id": operationEventRequestIdFlag
@@ -55117,6 +55277,19 @@ var THING_DOMAIN = defineDomain({
55117
55277
  ],
55118
55278
  handler: handleThingRetract
55119
55279
  },
55280
+ remove: {
55281
+ prime: false,
55282
+ summary: "Permanently delete a thing and all its versions (needs things:delete)",
55283
+ args: "<wref|durableId>",
55284
+ flags: removeFlags,
55285
+ dryRunBehavior: "execute",
55286
+ examples: [
55287
+ "wh thing remove Location/cave --dry-run",
55288
+ "wh thing remove Location/cave --yes",
55289
+ "wh thing remove 040T1QCTF2Y79... --expected-version 3 --yes"
55290
+ ],
55291
+ handler: handleThingRemove
55292
+ },
55120
55293
  query: {
55121
55294
  prime: true,
55122
55295
  summary: "Query things by filters",
@@ -57647,7 +57820,7 @@ var createFlags3 = {
57647
57820
  };
57648
57821
 
57649
57822
  // ../../packages/warmhub-cli/src/domains/commit-stream-output-contract-id.ts
57650
- var COMMIT_SUBMIT_STREAM_ROW_SCHEMA_ID = "wh.commit.submit.stream.row/v0.4";
57823
+ var COMMIT_SUBMIT_STREAM_ROW_SCHEMA_ID = "wh.commit.submit.stream.row/v0.5";
57651
57824
  function identify(row) {
57652
57825
  if ("schema" in row) {
57653
57826
  throw new Error("Streaming submission row already defines a schema field");
@@ -58017,7 +58190,8 @@ function rejectLegacyLifecycleOperations(operations) {
58017
58190
  if (!legacy)
58018
58191
  return;
58019
58192
  const target = legacy.name ? ` ${legacy.name}` : "";
58020
- throw new CliError(2 /* UserInput */, "USER_INPUT", `Commit operation "${legacy.operation}" is not supported.`, undefined, `Use {"operation":"retract","name":"${legacy.name ?? "<wref>"}"} or \`wh commit submit --retract${target}\`.`);
58193
+ const retract = `Use {"operation":"retract","name":"${legacy.name ?? "<wref>"}"} or \`wh commit submit --retract${target}\``;
58194
+ throw new CliError(2 /* UserInput */, "USER_INPUT", `Commit operation "${legacy.operation}" is not supported.`, undefined, legacy.operation === "remove" ? `To delete the Thing permanently, use \`wh thing remove${target || " <wref>"}\`. To withdraw it, ${retract.charAt(0).toLowerCase()}${retract.slice(1)}.` : `${retract}.`);
58021
58195
  }
58022
58196
  function synthesizeCommitMessage(operations) {
58023
58197
  if (operations.length === 0)
@@ -58720,69 +58894,6 @@ function createBoundedCommitValidateInput(org, repo, operations, options) {
58720
58894
  return input;
58721
58895
  }
58722
58896
 
58723
- // ../../packages/warmhub-cli/src/domains/commit-validation-render.ts
58724
- function renderCommitValidation(ctx, result) {
58725
- if (ctx.format === "json") {
58726
- ctx.out(JSON.stringify(result));
58727
- } else if (ctx.format === "jsonl") {
58728
- for (const operation of result.operations) {
58729
- ctx.out(JSON.stringify({ type: "operation", ...operation }));
58730
- }
58731
- const { operations: _operations, ...summary } = result;
58732
- ctx.out(JSON.stringify({ type: "summary", ...summary }));
58733
- } else {
58734
- renderPrettyValidation(ctx, result);
58735
- }
58736
- const error51 = containedDiagnosticError(validationDiagnostics(result));
58737
- if (error51)
58738
- ctx.requestedExitCode = error51.code;
58739
- }
58740
- function renderPrettyValidation(ctx, result) {
58741
- const c = ctx.colors;
58742
- const baseline = result.baseline.kind === "repo_seq" ? `repo sequence ${result.baseline.repoSeq}` : "withheld";
58743
- ctx.out(`${c.dim}validation baseline${c.reset} ${baseline}`);
58744
- for (const caveat of result.caveats) {
58745
- ctx.out(` ${ctx.chars.warn} ${c.dim}${caveat.code}${c.reset} ${caveat.message}`);
58746
- }
58747
- for (const operation of result.operations) {
58748
- const marker = markerFor(operation.status, ctx);
58749
- ctx.out(`${marker} [${operation.opIndex}] ${operation.operation} ${displayName(c, operation.name)} ${operation.status}`);
58750
- renderDiagnostics(ctx, operation.status === "error" ? operation.errors : undefined);
58751
- for (const effect of operation.effects ?? []) {
58752
- renderEffect(ctx, effect);
58753
- }
58754
- }
58755
- ctx.out(`${c.bold}${result.canCommit ? "can commit" : "cannot commit"}${c.reset} — ${result.counts.wouldApply} would apply, ${result.counts.noop} noop, ${result.counts.error} error`);
58756
- }
58757
- function renderEffect(ctx, effect) {
58758
- ctx.out(` ${markerFor(effect.status, ctx)} effect ${effect.effectIndex}: ${effect.operation} ${displayName(ctx.colors, effect.name)} ${effect.status}`);
58759
- renderDiagnostics(ctx, "errors" in effect ? effect.errors : undefined, 6);
58760
- }
58761
- function renderDiagnostics(ctx, diagnostics, indent = 4) {
58762
- for (const diagnostic of diagnostics ?? []) {
58763
- ctx.out(`${" ".repeat(indent)}${diagnostic.code}: ${diagnostic.message}`);
58764
- }
58765
- }
58766
- function markerFor(status, ctx) {
58767
- if (status === "error" || status === "discarded")
58768
- return ctx.chars.cross;
58769
- if (status === "noop")
58770
- return ctx.chars.warn;
58771
- return ctx.chars.check;
58772
- }
58773
- function validationDiagnostics(result) {
58774
- const diagnostics = [];
58775
- for (const operation of result.operations) {
58776
- if (operation.status === "error")
58777
- diagnostics.push(...operation.errors);
58778
- for (const effect of operation.effects ?? []) {
58779
- if ("errors" in effect)
58780
- diagnostics.push(...effect.errors);
58781
- }
58782
- }
58783
- return diagnostics;
58784
- }
58785
-
58786
58897
  // ../../packages/warmhub-cli/src/domains/commit-validation-execute.ts
58787
58898
  async function executeCommitValidation(ctx, args) {
58788
58899
  const options = {
@@ -59749,7 +59860,7 @@ function bindComponentMethodArgs(invocation, method) {
59749
59860
  }
59750
59861
 
59751
59862
  // ../../packages/warmhub-cli/src/component-exec.ts
59752
- var USAGE = "wh component exec <component> <method> [args] --repo org/repo";
59863
+ var USAGE2 = "wh component exec <component> <method> [args] --repo org/repo";
59753
59864
  function methodHelpHint(componentName, methodName, installRepo) {
59754
59865
  return `wh component exec ${componentName} ${methodName} --help --repo ${installRepo}`;
59755
59866
  }
@@ -59803,7 +59914,7 @@ var handleComponentExec = async (ctx, _domain) => {
59803
59914
  const helpRequested = invocation.help;
59804
59915
  const dryRun = invocation.flags["dry-run"] === true;
59805
59916
  if (!invocation.component)
59806
- usageError("Component name is required", USAGE);
59917
+ usageError("Component name is required", USAGE2);
59807
59918
  const componentName = invocation.component;
59808
59919
  const methodName = invocation.method;
59809
59920
  const { org, repo } = parseOrgRepo(getRepoRef(ctx), ctx.config);
@@ -70141,7 +70252,7 @@ function resolveLogLevel(flagLevel, env) {
70141
70252
  // package.json
70142
70253
  var package_default3 = {
70143
70254
  name: "@warmhub/cli",
70144
- version: "0.138.0",
70255
+ version: "0.139.0",
70145
70256
  private: false,
70146
70257
  type: "module",
70147
70258
  description: "The wh CLI for WarmHub — create repos, commit and query data, and compound knowledge with your AI agents.",
@@ -70766,5 +70877,5 @@ process.exitCode = interceptedExitCode === undefined ? await runPreparedCli(laun
70766
70877
  version: package_default3.version
70767
70878
  }) : interceptedExitCode;
70768
70879
 
70769
- //# debugId=34AED26DA6FD886964756E2164756E21
70770
- //# warmhub-cli-build-info {"cliVersion":"0.138.0","sdkVersion":"0.136.0"}
70880
+ //# debugId=07DF6F73C022E9A064756E2164756E21
70881
+ //# warmhub-cli-build-info {"cliVersion":"0.139.0","sdkVersion":"0.137.0"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warmhub/cli",
3
- "version": "0.138.0",
3
+ "version": "0.139.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "The wh CLI for WarmHub — create repos, commit and query data, and compound knowledge with your AI agents.",