@warmhub/cli 0.136.0 → 0.138.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 +124 -35
  2. package/package.json +1 -1
package/dist/wh.js CHANGED
@@ -26272,6 +26272,9 @@ var RESERVED_THING_ROOT_PREFIX = `${RESERVED_THING_ROOT}/`;
26272
26272
  function isReservedThingRoot(name) {
26273
26273
  return name === RESERVED_THING_ROOT || name.startsWith(RESERVED_THING_ROOT_PREFIX);
26274
26274
  }
26275
+ function isReservedShapeName(name) {
26276
+ return name === RESERVED_THING_ROOT;
26277
+ }
26275
26278
  function reservedThingRootMessage(name) {
26276
26279
  return `Name "${name}" is under the reserved root "${RESERVED_THING_ROOT_PREFIX}"; only Shapes live there, as ${RESERVED_THING_ROOT_PREFIX}shapes/<Name>`;
26277
26280
  }
@@ -26354,8 +26357,9 @@ function reservedRootRefusal(name, operationIndex) {
26354
26357
  };
26355
26358
  }
26356
26359
  function reservedRootGuard(op, operationIndex) {
26357
- if (op.kind === "shape")
26358
- return [];
26360
+ if (op.operation === "add" && op.kind === "shape") {
26361
+ return op.name && isReservedShapeName(op.name) ? [reservedRootRefusal(op.name, operationIndex)] : [];
26362
+ }
26359
26363
  if (op.operation === "add" && op.name) {
26360
26364
  const stored = op.kind === "collection" ? op.name : splitLocalPath2(op.name)?.bareName;
26361
26365
  if (stored !== undefined && isReservedThingRoot(stored)) {
@@ -26363,8 +26367,8 @@ function reservedRootGuard(op, operationIndex) {
26363
26367
  }
26364
26368
  return [];
26365
26369
  }
26366
- const isShapeRename = op.name !== undefined && splitLocalPath2(op.name) === null;
26367
- if (op.operation === "rename" && !isShapeRename && op.newName !== undefined && isReservedThingRoot(op.newName)) {
26370
+ const isShapeRename = op.kind === "shape" || op.name !== undefined && splitLocalPath2(op.name) === null;
26371
+ if (op.operation === "rename" && op.newName !== undefined && (isShapeRename ? isReservedShapeName(op.newName) : isReservedThingRoot(op.newName))) {
26368
26372
  return [reservedRootRefusal(op.newName, operationIndex)];
26369
26373
  }
26370
26374
  return [];
@@ -44522,7 +44526,7 @@ class PartialStreamSubmissionError extends Error {
44522
44526
  }
44523
44527
 
44524
44528
  class AllStreamOperationsFailedError extends Error {
44525
- code = "STREAM_ALL_OPERATIONS_FAILED";
44529
+ code;
44526
44530
  receipts;
44527
44531
  result;
44528
44532
  operations;
@@ -44532,6 +44536,7 @@ class AllStreamOperationsFailedError extends Error {
44532
44536
  const primaryFailure = result.operations.find((operation) => operation.status === "error")?.errors[0];
44533
44537
  super(primaryFailure ? `All ${result.operationCount} stream operations failed: ${primaryFailure.message}` : `All ${result.operationCount} stream operations failed.`);
44534
44538
  this.name = "WarmHubError";
44539
+ this.code = primaryFailure && result.operations.every((operation) => operation.status === "error" && operation.errors.length > 0 && operation.errors.every((error51) => error51.code === primaryFailure.code)) ? primaryFailure.code : "STREAM_ALL_OPERATIONS_FAILED";
44535
44540
  this.cause = primaryFailure;
44536
44541
  this.result = result;
44537
44542
  this.receipts = result.receipts;
@@ -44589,6 +44594,7 @@ var DEFINITE_CLIENT_REJECT_CODES = new Set([
44589
44594
  "NOT_FOUND",
44590
44595
  "KIND_MISMATCH",
44591
44596
  "CONFLICT",
44597
+ "NAME_TAKEN",
44592
44598
  "ALREADY_RETRACTED",
44593
44599
  "ARCHIVED",
44594
44600
  "RATE_LIMITED",
@@ -44988,7 +44994,13 @@ var currentErrorDetailsSchema = exports_external.discriminatedUnion("reason", [
44988
44994
  exports_external.object({
44989
44995
  reason: exports_external.literal("dependency_failed"),
44990
44996
  producerOpIndexes: exports_external.array(exports_external.number().int().nonnegative()).min(1)
44991
- }).strict()
44997
+ }).strict(),
44998
+ exports_external.object({
44999
+ reason: exports_external.literal("name_taken"),
45000
+ name: exports_external.string().min(1),
45001
+ takenBy: exports_external.object({ shape: exports_external.string().min(1), durableId: exports_external.string().min(1) }).loose().optional(),
45002
+ suggestedName: exports_external.string().min(1).optional()
45003
+ }).loose()
44992
45004
  ]);
44993
45005
  var currentBaseShape = {
44994
45006
  ...positionShape,
@@ -45478,7 +45490,7 @@ function createStreamingSubmissionHandle(input, deps) {
45478
45490
  // ../../packages/sdk-ts/package.json
45479
45491
  var package_default = {
45480
45492
  name: "@warmhub/sdk-ts",
45481
- version: "0.134.0",
45493
+ version: "0.136.0",
45482
45494
  private: false,
45483
45495
  type: "module",
45484
45496
  description: "The TypeScript SDK for WarmHub — create repos, commit and query data, and compound knowledge with your AI agents.",
@@ -46942,7 +46954,8 @@ class WarmHubClient {
46942
46954
  orgName,
46943
46955
  repoName,
46944
46956
  shapeName,
46945
- includeRetracted: opts?.includeRetracted
46957
+ includeRetracted: opts?.includeRetracted,
46958
+ includeComposition: opts?.includeComposition
46946
46959
  });
46947
46960
  } catch (error51) {
46948
46961
  throw toWarmHubError(error51);
@@ -48397,6 +48410,8 @@ function classifyConflict(message, code) {
48397
48410
  return "lease-held";
48398
48411
  case "INCREMENTAL_READ_UNAVAILABLE":
48399
48412
  return "incremental-read-unavailable";
48413
+ case "NAME_TAKEN":
48414
+ return "name-taken";
48400
48415
  case undefined:
48401
48416
  default:
48402
48417
  break;
@@ -48433,6 +48448,10 @@ function conflictHint(message, code) {
48433
48448
  return "This thing is leased by another holder. Back off until the lease expires (see leaseExpiresAt / retryAfter), then retry.";
48434
48449
  case "incremental-read-unavailable":
48435
48450
  return INCREMENTAL_READ_UNAVAILABLE_GUIDANCE;
48451
+ case "name-taken": {
48452
+ const suggested = /for example "([^"]+)"/.exec(message)?.[1];
48453
+ 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
+ }
48436
48455
  case "other":
48437
48456
  default:
48438
48457
  return "Resolve the conflicting existing state and try again.";
@@ -48456,6 +48475,7 @@ var TOP_LEVEL_USER_INPUT_CODES = new Set([
48456
48475
  ]);
48457
48476
  var CONFLICT_SHAPED_CODES = new Set([
48458
48477
  "CONFLICT",
48478
+ "NAME_TAKEN",
48459
48479
  "ALREADY_EXISTS",
48460
48480
  "BUILTIN_SHAPE_CONFLICT",
48461
48481
  "ARCHIVED",
@@ -48668,6 +48688,11 @@ function generateSuggestions(code, message, context, errorCode) {
48668
48688
  action: "Wait for the repo delete to finish or cancel it before retrying"
48669
48689
  });
48670
48690
  break;
48691
+ case "name-taken":
48692
+ suggestions.push({
48693
+ action: "Choose a name no other Thing in the repository holds (use details.suggestedName when the error carries one)"
48694
+ });
48695
+ break;
48671
48696
  case "lease-held":
48672
48697
  suggestions.push({
48673
48698
  action: "Another holder leased this thing. Back off until the lease expires (leaseExpiresAt / retryAfter), then retry"
@@ -52561,7 +52586,7 @@ function emitPartialPageHint(ctx, count, _nextCursor, _limit) {
52561
52586
  }
52562
52587
 
52563
52588
  // ../../packages/warmhub-cli/src/domains/commit-output-contract-id.ts
52564
- var COMMIT_SUBMIT_OUTPUT_SCHEMA_ID = "wh.commit.submit.result/v0.4";
52589
+ var COMMIT_SUBMIT_OUTPUT_SCHEMA_ID = "wh.commit.submit.result/v0.5";
52565
52590
  function identifyCommitSubmitOutput(value) {
52566
52591
  if ("schema" in value) {
52567
52592
  if (value.schema === COMMIT_SUBMIT_OUTPUT_SCHEMA_ID) {
@@ -57622,7 +57647,7 @@ var createFlags3 = {
57622
57647
  };
57623
57648
 
57624
57649
  // ../../packages/warmhub-cli/src/domains/commit-stream-output-contract-id.ts
57625
- var COMMIT_SUBMIT_STREAM_ROW_SCHEMA_ID = "wh.commit.submit.stream.row/v0.3";
57650
+ var COMMIT_SUBMIT_STREAM_ROW_SCHEMA_ID = "wh.commit.submit.stream.row/v0.4";
57626
57651
  function identify(row) {
57627
57652
  if ("schema" in row) {
57628
57653
  throw new Error("Streaming submission row already defines a schema field");
@@ -57638,12 +57663,68 @@ function identifyCommitSubmitStreamRow(row) {
57638
57663
 
57639
57664
  // ../../packages/warmhub-cli/src/domains/commit-submit-template.ts
57640
57665
  import { writeFile } from "node:fs/promises";
57666
+
57667
+ // ../../packages/warmhub-cli/src/domains/shape/composition.ts
57668
+ function capturedShapeMembers(shape) {
57669
+ const data = shape.version?.data;
57670
+ if (Array.isArray(data?.composes) && data.composes.length > 0 && !shape.composition) {
57671
+ throw new CliError(4 /* Backend */, "BACKEND", "The server did not return this Shape’s captured composition. Update the server before scaffolding or displaying inherited fields.");
57672
+ }
57673
+ return shape.composition ?? [];
57674
+ }
57675
+ function effectiveShapeFields(shape) {
57676
+ const data = shape.version?.data;
57677
+ const own = isPlainObject(data?.fields) ? data.fields : {};
57678
+ const fields = structuredClone(own);
57679
+ for (const member of capturedShapeMembers(shape)) {
57680
+ mergeFields(fields, member.fields);
57681
+ }
57682
+ return fields;
57683
+ }
57684
+ function mergeFields(target, source) {
57685
+ for (const [name, spec] of Object.entries(source)) {
57686
+ const bare = name.endsWith("?") ? name.slice(0, -1) : name;
57687
+ if (name.endsWith("?") && Object.hasOwn(target, bare)) {
57688
+ const required2 = target[bare];
57689
+ if (isPlainObject(required2) && !isTypeSpecObject(required2) && isPlainObject(spec) && !isTypeSpecObject(spec)) {
57690
+ mergeFields(required2, spec);
57691
+ }
57692
+ continue;
57693
+ }
57694
+ const optionalName = `${name}?`;
57695
+ if (!name.endsWith("?") && Object.hasOwn(target, optionalName)) {
57696
+ const optional2 = target[optionalName];
57697
+ delete target[optionalName];
57698
+ Object.defineProperty(target, name, {
57699
+ configurable: true,
57700
+ enumerable: true,
57701
+ writable: true,
57702
+ value: isPlainObject(optional2) && !isTypeSpecObject(optional2) && isPlainObject(spec) && !isTypeSpecObject(spec) ? optional2 : spec
57703
+ });
57704
+ }
57705
+ const current = Object.hasOwn(target, name) ? target[name] : undefined;
57706
+ if (isPlainObject(current) && !isTypeSpecObject(current) && isPlainObject(spec) && !isTypeSpecObject(spec)) {
57707
+ mergeFields(current, spec);
57708
+ } else if (current === undefined) {
57709
+ Object.defineProperty(target, name, {
57710
+ configurable: true,
57711
+ enumerable: true,
57712
+ writable: true,
57713
+ value: spec
57714
+ });
57715
+ }
57716
+ }
57717
+ }
57718
+
57719
+ // ../../packages/warmhub-cli/src/domains/commit-submit-template.ts
57641
57720
  var WRITE_TEMPLATE_KINDS = ["thing", "assertion"];
57642
- function composesLocalAssertion(shapeData, org, repo) {
57721
+ function composesLocalAssertion(shapeData, org, repo, captured = []) {
57643
57722
  const composes = shapeData?.composes;
57644
- if (!Array.isArray(composes))
57645
- return false;
57646
- return composes.some((entry) => {
57723
+ const candidates = [
57724
+ ...Array.isArray(composes) ? composes : [],
57725
+ ...captured.map((entry) => entry.wref)
57726
+ ];
57727
+ return candidates.some((entry) => {
57647
57728
  if (typeof entry !== "string")
57648
57729
  return false;
57649
57730
  const unversioned = entry.replace(/@(HEAD|v\d+)$/i, "");
@@ -57652,7 +57733,9 @@ function composesLocalAssertion(shapeData, org, repo) {
57652
57733
  }
57653
57734
  async function readTemplateShape(ctx, org, repo, shapeName) {
57654
57735
  try {
57655
- const shape = await ctx.client.shape.get(org, repo, shapeName);
57736
+ const shape = await ctx.client.shape.get(org, repo, shapeName, {
57737
+ includeComposition: true
57738
+ });
57656
57739
  if ((shapeName === "Set" || shapeName === "List") && shape.componentRef !== "warmhub/system") {
57657
57740
  return;
57658
57741
  }
@@ -57699,21 +57782,15 @@ function zeroValueForField(fieldSpec) {
57699
57782
  }
57700
57783
  }
57701
57784
  if (isPlainObject(fieldSpec)) {
57702
- const result = {};
57703
- for (const [key, value] of Object.entries(fieldSpec)) {
57704
- result[key] = zeroValueForField(value);
57705
- }
57706
- return result;
57785
+ return buildTemplateData(fieldSpec);
57707
57786
  }
57708
57787
  return null;
57709
57788
  }
57710
57789
  function buildTemplateData(fields) {
57711
- const data = {};
57712
- for (const [fieldName, fieldSpec] of Object.entries(fields)) {
57713
- const key = fieldName.endsWith("?") ? fieldName.slice(0, -1) : fieldName;
57714
- data[key] = zeroValueForField(fieldSpec);
57715
- }
57716
- return data;
57790
+ return Object.fromEntries(Object.entries(fields).map(([fieldName, fieldSpec]) => [
57791
+ fieldName.endsWith("?") ? fieldName.slice(0, -1) : fieldName,
57792
+ zeroValueForField(fieldSpec)
57793
+ ]));
57717
57794
  }
57718
57795
  var templateFlags = {
57719
57796
  operation: flag.string({
@@ -57794,12 +57871,12 @@ var handleTemplate = async (ctx, { flags, args }) => {
57794
57871
  }
57795
57872
  const shapeVersion = shape.version;
57796
57873
  const shapeData = shapeVersion?.data;
57797
- const fields = shapeData?.fields ?? {};
57874
+ const fields = effectiveShapeFields(shape);
57798
57875
  let aboutPlaceholder;
57799
57876
  if (templateKind === "assertion") {
57800
57877
  aboutPlaceholder = flags.about ? parseCollectionAboutFlag(flags.about) : "Shape/FILL_IN";
57801
57878
  }
57802
- const composesAssertion = composesLocalAssertion(shapeData, org, repo);
57879
+ const composesAssertion = composesLocalAssertion(shapeData, org, repo, shape.composition);
57803
57880
  const emittedKind = templateKind === "assertion" && composesAssertion ? "thing" : templateKind;
57804
57881
  const data = buildTemplateData(fields);
57805
57882
  const emittedData = aboutPlaceholder && emittedKind === "thing" ? { ...data, about: aboutPlaceholder } : data;
@@ -66241,7 +66318,8 @@ var handleView7 = async (ctx, { flags, args }) => {
66241
66318
  const { org, repo: repo2 } = parseOrgRepo(getRepoRef(ctx), ctx.config);
66242
66319
  const c = ctx.colors;
66243
66320
  const result = await ctx.client.shape.get(org, repo2, shapeName, {
66244
- includeRetracted: flags["include-retracted"]
66321
+ includeRetracted: flags["include-retracted"],
66322
+ includeComposition: ctx.format === "pretty"
66245
66323
  });
66246
66324
  writeOutput(ctx, result, () => {
66247
66325
  const shapeVersion = result.version;
@@ -66258,15 +66336,26 @@ var handleView7 = async (ctx, { flags, args }) => {
66258
66336
  ctx.out(` ${c.dim}owner:${c.reset} ${c.yellow}${componentRef}${c.reset}`);
66259
66337
  }
66260
66338
  const fields = shapeData?.fields;
66261
- if (fields) {
66262
- ctx.out(` ${c.dim}fields:${c.reset}`);
66263
- for (const [fieldName, fieldType] of Object.entries(fields)) {
66339
+ const composes = shapeData?.composes;
66340
+ if (Array.isArray(composes) && composes.length > 0) {
66341
+ ctx.out(` ${c.dim}composes:${c.reset} ${composes.map((name) => escapeTerminalTextForDisplay(String(name))).join(", ")}`);
66342
+ }
66343
+ const printFields = (entries) => {
66344
+ for (const [fieldName, fieldType] of Object.entries(entries)) {
66264
66345
  const typeStr = displayFieldType(fieldType);
66265
66346
  const fieldDesc = fieldDescriptionFromSpec(fieldType);
66266
66347
  const descSuffix = fieldDesc ? ` ${c.dim}${escapeTerminalTextForDisplay(fieldDesc)}${c.reset}` : "";
66267
66348
  const safeFieldName = escapeFieldNameForDisplay(fieldName);
66268
66349
  ctx.out(` ${c.cyan}${safeFieldName}${c.reset}: ${c.dim}${typeStr}${c.reset}${descSuffix}`);
66269
66350
  }
66351
+ };
66352
+ if (fields && Object.keys(fields).length > 0) {
66353
+ ctx.out(` ${c.dim}fields:${c.reset}`);
66354
+ printFields(fields);
66355
+ }
66356
+ for (const member of capturedShapeMembers(result)) {
66357
+ ctx.out(` ${c.dim}inherited from ${escapeTerminalTextForDisplay(member.wref)}:${c.reset}`);
66358
+ printFields(member.fields);
66270
66359
  }
66271
66360
  ctx.out("");
66272
66361
  ctx.out(` ${c.dim}Scaffold a write ops file for this shape:${c.reset} ${c.cyan}wh shape template ${result.name ?? shapeName}${c.reset}`);
@@ -70052,7 +70141,7 @@ function resolveLogLevel(flagLevel, env) {
70052
70141
  // package.json
70053
70142
  var package_default3 = {
70054
70143
  name: "@warmhub/cli",
70055
- version: "0.136.0",
70144
+ version: "0.138.0",
70056
70145
  private: false,
70057
70146
  type: "module",
70058
70147
  description: "The wh CLI for WarmHub — create repos, commit and query data, and compound knowledge with your AI agents.",
@@ -70677,5 +70766,5 @@ process.exitCode = interceptedExitCode === undefined ? await runPreparedCli(laun
70677
70766
  version: package_default3.version
70678
70767
  }) : interceptedExitCode;
70679
70768
 
70680
- //# debugId=17E23D79103C8D1164756E2164756E21
70681
- //# warmhub-cli-build-info {"cliVersion":"0.136.0","sdkVersion":"0.134.0"}
70769
+ //# debugId=34AED26DA6FD886964756E2164756E21
70770
+ //# warmhub-cli-build-info {"cliVersion":"0.138.0","sdkVersion":"0.136.0"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warmhub/cli",
3
- "version": "0.136.0",
3
+ "version": "0.138.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.",