@ted-galago/wave-cli 0.1.15 → 0.1.17

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.cjs CHANGED
@@ -181,6 +181,22 @@ function graphqlOperationName(command) {
181
181
  function toCamelCase(value) {
182
182
  return value.replace(/_([a-z])/g, (_, char) => char.toUpperCase());
183
183
  }
184
+ function capitalizeFirst(value) {
185
+ return value.length === 0 ? value : value[0].toUpperCase() + value.slice(1);
186
+ }
187
+ var MUTATION_PARAMS_INPUT_TYPE_OVERRIDES = {
188
+ createOpenAiRealtimeClientSecret: "OpenAiRealtimeClientSecretInput",
189
+ createOpenAiRealtimeSession: "OpenAiRealtimeSessionInput",
190
+ createOpenAiTranscription: "OpenAiTranscriptionInput",
191
+ finalizeOpenAiTranscription: "OpenAiFinalizeTranscriptionInput"
192
+ };
193
+ function inferMutationParamsInputType(input) {
194
+ if (input.operationType !== "mutation") {
195
+ return null;
196
+ }
197
+ const graphqlField = toCamelCase(input.field);
198
+ return MUTATION_PARAMS_INPUT_TYPE_OVERRIDES[graphqlField] ?? `${capitalizeFirst(graphqlField)}ParamsInput`;
199
+ }
184
200
  function inferStatusFromGraphqlErrors(errors) {
185
201
  if (!Array.isArray(errors) || errors.length === 0) {
186
202
  return 400;
@@ -413,7 +429,7 @@ function buildFeedbackFindRequestBody(command, identity) {
413
429
  page: 1,
414
430
  per: 1
415
431
  },
416
- selectionSet: "{ data { id type attributes } count currentPage totalPages }"
432
+ selectionSet: "{ data { id type attributes { id name slug year quarter organizationId memberIds } } count currentPage totalPages }"
417
433
  });
418
434
  }
419
435
  async function requestGraphqlHttp(params) {
@@ -484,7 +500,13 @@ function graphqlTypeForValue(value) {
484
500
  }
485
501
  return "JSON";
486
502
  }
487
- function graphqlTypeForVariable(name, value) {
503
+ function graphqlTypeForVariable(input, name, value) {
504
+ if (name === "params") {
505
+ const paramsInputType = inferMutationParamsInputType(input);
506
+ if (paramsInputType) {
507
+ return paramsInputType;
508
+ }
509
+ }
488
510
  if (name === "id" || name.endsWith("Id")) {
489
511
  return "ID";
490
512
  }
@@ -528,7 +550,7 @@ function buildGraphqlBody(input) {
528
550
  const variableDecl = variableEntries.map(([name, value]) => {
529
551
  const overriddenType = graphqlVariableTypes[name];
530
552
  const hasOverriddenType = typeof overriddenType === "string" && overriddenType.trim().length > 0;
531
- const typeName = hasOverriddenType ? overriddenType.trim() : graphqlTypeForVariable(name, value);
553
+ const typeName = hasOverriddenType ? overriddenType.trim() : graphqlTypeForVariable(input, name, value);
532
554
  return `$${name}: ${hasOverriddenType ? typeName : withNonNull(typeName)}`;
533
555
  }).join(", ");
534
556
  const fieldArgs = variableEntries.map(([name]) => `${name}: $${name}`).join(", ");
@@ -823,8 +845,7 @@ var RESOURCE_QUERY_FIELDS = {
823
845
  "memberIds",
824
846
  "leadMemberId",
825
847
  "organizationId",
826
- "responsibilities",
827
- "keyMetric"
848
+ "responsibilities"
828
849
  ],
829
850
  member: [
830
851
  "slug",
@@ -1280,16 +1301,16 @@ function defaultQuerySelectionSet(field, isList) {
1280
1301
  const canonicalField = RESOURCE_FIELD_ALIASES[field] ?? field;
1281
1302
  const explicitFields = RESOURCE_QUERY_FIELDS[canonicalField];
1282
1303
  if (explicitFields) {
1304
+ const attributes = explicitFields.length > 0 ? `attributes { ${Array.from(/* @__PURE__ */ new Set(["id", ...explicitFields])).join(" ")} }` : "attributes";
1283
1305
  if (isList) {
1284
- return "{ data { id type attributes } count currentPage totalPages }";
1306
+ return `{ data { id type ${attributes} } count currentPage totalPages }`;
1285
1307
  }
1286
- const fields = Array.from(/* @__PURE__ */ new Set(["id", "type", ...explicitFields, "attributes"])).join(" ");
1287
- return `{ ${fields} }`;
1308
+ return `{ id type ${attributes} }`;
1288
1309
  }
1289
1310
  if (isList) {
1290
- return "{ data { id type attributes } count currentPage totalPages }";
1311
+ return "{ data { id type } count currentPage totalPages }";
1291
1312
  }
1292
- return "{ id type attributes }";
1313
+ return "{ id type }";
1293
1314
  }
1294
1315
  function isRecord(value) {
1295
1316
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
@@ -2594,7 +2615,10 @@ var idSchema3 = import_zod4.z.string().min(1);
2594
2615
  var projectCreateDataJsonHelp = buildDataJsonHelp("project", "create") ?? 'JSON object for project or {"project": {...}}';
2595
2616
  var projectUpdateDataJsonHelp = buildDataJsonHelp("project", "update") ?? 'JSON object for project or {"project": {...}}';
2596
2617
  var projectsIndexMinimalSelectionSet = "{ count currentPage totalPages data { id type attributes { name slug status priority } } }";
2597
- var projectShowFullSelectionSet = "{ id type name slug description status priority createdAt updatedAt startDate targetDate archivedAt memberId organizationId teamIds emoji { id name memberId } backgroundImage { backgroundType gradientStart gradientEnd gradientDegrees color imageUrl image { url lowUrl } } favorites { id memberId } resources { ...ResourceSummaryFull } displayPreference { id type attributes viewType favorite groupingField groupToggleState memberId focusMemberId focusTeamId displayableId displayableType preferenceType agendaItemId } filterPreferences { id type attributes filterType filter memberId focusMemberId focusTeamId filterableId filterableType preferenceType agendaItemId } healthUpdates { id type value memberId status createdAt updatedAt updatableType updatableId parentUpdateId emojis { id name memberId } resources { ...ResourceSummaryFull } replies { id type value memberId createdAt updatedAt commentType commentableId commentableType parentCommentId emojis { id name memberId } resources { ...ResourceSummaryFull } replies { id type } } } } fragment ResourceSummaryFull on ResourceSummary { id resourceType slug url skillId skill { id name slug emoji scope description } metadata { urlName imageUrl siteName providerName mediaType skillId skillName skillSlug skillScope skillEmoji skillDescription } attachment { id fileKey filename url } content { id name slug type firstChildSlug childCount } }";
2618
+ var displayPreferenceAttributesSelectionSet = "attributes { id viewType favorite groupingField groupToggleState memberId focusMemberId focusTeamId displayableId displayableType preferenceType agendaItemId }";
2619
+ var filterPreferenceAttributesSelectionSet = "attributes { id filterType filter memberId focusMemberId focusTeamId filterableId filterableType preferenceType agendaItemId }";
2620
+ var healthUpdateSummarySelectionSet = "id type value memberId status createdAt updatedAt updatableType updatableId parentUpdateId emojis { id name memberId } resources { ...ResourceSummaryFull }";
2621
+ var projectShowFullSelectionSet = `{ id type name slug description status priority createdAt updatedAt startDate targetDate archivedAt memberId organizationId teamIds emoji { id name memberId } backgroundImage { backgroundType gradientStart gradientEnd gradientDegrees color imageUrl image { url lowUrl } } favorites { id memberId } resources { ...ResourceSummaryFull } displayPreference { id type ${displayPreferenceAttributesSelectionSet} viewType favorite groupingField groupToggleState memberId focusMemberId focusTeamId displayableId displayableType preferenceType agendaItemId } filterPreferences { id type ${filterPreferenceAttributesSelectionSet} filterType filter memberId focusMemberId focusTeamId filterableId filterableType preferenceType agendaItemId } healthUpdates { ${healthUpdateSummarySelectionSet} replies { ${healthUpdateSummarySelectionSet} replies { id type } } } } fragment ResourceSummaryFull on ResourceSummary { id resourceType slug url skillId skill { id name slug emoji scope description } metadata { urlName imageUrl siteName providerName mediaType skillId skillName skillSlug skillScope skillEmoji skillDescription } attachment { id fileKey filename url } content { id name slug type firstChildSlug childCount } }`;
2598
2622
  function asRecord2(value) {
2599
2623
  return value && typeof value === "object" ? value : null;
2600
2624
  }
@@ -3999,7 +4023,7 @@ function registerSystemToolCommands(program) {
3999
4023
  page: 1,
4000
4024
  per: 200
4001
4025
  },
4002
- selectionSet: "{ data { id type slug summary description memberId status rank createdAt updatedAt headlineType teamIds meetingId labelIds attributes } count currentPage totalPages }",
4026
+ selectionSet: "{ data { id type slug summary description memberId status rank createdAt updatedAt headlineType teamIds meetingId labelIds attributes { id slug summary description memberId status rank createdAt updatedAt headlineType teamIds meetingId labelIds } } count currentPage totalPages }",
4003
4027
  transformData: (value) => {
4004
4028
  if (!value || typeof value !== "object") {
4005
4029
  return null;
@@ -4616,7 +4640,13 @@ function registerFoundationCommands(program) {
4616
4640
  var import_zod12 = require("zod");
4617
4641
  var idSchema11 = import_zod12.z.string().min(1);
4618
4642
  var jsonObjectSchema = import_zod12.z.record(import_zod12.z.string(), import_zod12.z.unknown());
4619
- var childListMinimalSelectionSet = "{ data { id type attributes } count currentPage totalPages }";
4643
+ function buildChildListSelectionSet(parentField, extraFields = []) {
4644
+ const fields = Array.from(
4645
+ /* @__PURE__ */ new Set(["id", "type", "name", "status", "priority", "rank", "dueDate", "memberId", parentField, ...extraFields])
4646
+ );
4647
+ const attributeFields = fields.filter((field) => field !== "type");
4648
+ return `{ data { ${fields.join(" ")} attributes { ${attributeFields.join(" ")} } } count currentPage totalPages }`;
4649
+ }
4620
4650
  function parseJsonObject2(raw) {
4621
4651
  try {
4622
4652
  const parsed = JSON.parse(raw);
@@ -4821,7 +4851,7 @@ function registerChildEntityCommands(program) {
4821
4851
  createOperationName: "SubtasksCreate",
4822
4852
  updateOperationName: "SubtasksUpdate",
4823
4853
  destroyOperationName: "SubtasksDestroy",
4824
- listSelectionSet: childListMinimalSelectionSet,
4854
+ listSelectionSet: buildChildListSelectionSet("taskId"),
4825
4855
  listParentTypedField: "taskId",
4826
4856
  normalizeCreateBody: normalizeSubtaskCreateBody
4827
4857
  });
@@ -4840,7 +4870,7 @@ function registerChildEntityCommands(program) {
4840
4870
  createOperationName: "MilestonesCreate",
4841
4871
  updateOperationName: "MilestonesUpdate",
4842
4872
  destroyOperationName: "MilestonesDestroy",
4843
- listSelectionSet: childListMinimalSelectionSet
4873
+ listSelectionSet: buildChildListSelectionSet("rockId")
4844
4874
  });
4845
4875
  registerChildCommands(program, {
4846
4876
  command: "subitems",
@@ -4857,7 +4887,7 @@ function registerChildEntityCommands(program) {
4857
4887
  createOperationName: "SubitemsCreate",
4858
4888
  updateOperationName: "SubitemsUpdate",
4859
4889
  destroyOperationName: "SubitemsDestroy",
4860
- listSelectionSet: childListMinimalSelectionSet,
4890
+ listSelectionSet: buildChildListSelectionSet("listItemId"),
4861
4891
  listParentTypedField: "listItemId"
4862
4892
  });
4863
4893
  registerChildCommands(program, {
@@ -4875,7 +4905,7 @@ function registerChildEntityCommands(program) {
4875
4905
  createOperationName: "SubtodosCreate",
4876
4906
  updateOperationName: "SubtodosUpdate",
4877
4907
  destroyOperationName: "SubtodosDestroy",
4878
- listSelectionSet: childListMinimalSelectionSet,
4908
+ listSelectionSet: buildChildListSelectionSet("todoId"),
4879
4909
  listParentTypedField: "todoId"
4880
4910
  });
4881
4911
  registerChildCommands(program, {
@@ -4893,7 +4923,7 @@ function registerChildEntityCommands(program) {
4893
4923
  createOperationName: "SubissuesCreate",
4894
4924
  updateOperationName: "SubissuesUpdate",
4895
4925
  destroyOperationName: "SubissuesDestroy",
4896
- listSelectionSet: childListMinimalSelectionSet,
4926
+ listSelectionSet: buildChildListSelectionSet("issueId"),
4897
4927
  listParentTypedField: "issueId"
4898
4928
  });
4899
4929
  registerChildCommands(program, {
@@ -4911,7 +4941,7 @@ function registerChildEntityCommands(program) {
4911
4941
  createOperationName: "TalkingPointsCreate",
4912
4942
  updateOperationName: "TalkingPointsUpdate",
4913
4943
  destroyOperationName: "TalkingPointsDestroy",
4914
- listSelectionSet: childListMinimalSelectionSet,
4944
+ listSelectionSet: buildChildListSelectionSet("meetingId", ["description", "creatorId", "slug"]),
4915
4945
  listParentTypedField: "meetingId"
4916
4946
  });
4917
4947
  }
@@ -4920,6 +4950,7 @@ function registerChildEntityCommands(program) {
4920
4950
  var import_zod13 = require("zod");
4921
4951
  var idSchema12 = import_zod13.z.string().min(1);
4922
4952
  var nonEmptyString = import_zod13.z.string().min(1);
4953
+ var contentAttributesSelection = "attributes { id type name slug content firstChildSlug rootParentSlug status contentType lastEdited organizationId memberId focusMemberId focusTeamId teamId creatorId createdAt updatedAt childCount assignmentType contentableId contentableSlug contentableType votesTotal labelIds rootContentId parentContentId }";
4923
4954
  function assertUpdateFields(params) {
4924
4955
  if (!params.name && !params.content && !params.status) {
4925
4956
  throw new CliError({
@@ -4967,7 +4998,7 @@ function registerContentCommands(program) {
4967
4998
  per: opts.per
4968
4999
  }),
4969
5000
  isList: true,
4970
- selectionSet: "{ count currentPage totalPages data { id type attributes } }"
5001
+ selectionSet: `{ count currentPage totalPages data { id type ${contentAttributesSelection} } }`
4971
5002
  });
4972
5003
  });
4973
5004
  content.command("show").requiredOption("--id <id>").action(async (opts, cmd) => {
@@ -4984,7 +5015,7 @@ function registerContentCommands(program) {
4984
5015
  id
4985
5016
  }),
4986
5017
  isShow: true,
4987
- selectionSet: "{ id type name slug firstChildSlug rootParentSlug status contentType lastEdited organizationId memberId focusMemberId focusTeamId teamId creatorId createdAt updatedAt childCount assignmentType contentableId contentableSlug contentableType votesTotal labelIds rootContentId parentContentId attributes }"
5018
+ selectionSet: `{ id type resources { id resourceType slug url } ${contentAttributesSelection} }`
4988
5019
  });
4989
5020
  });
4990
5021
  content.command("update").requiredOption("--id <id>").option("--name <name>").option("--body <body>").option("--status <status>").action(async (opts, cmd) => {
@@ -6088,7 +6119,7 @@ function registerMutationCapabilityCommands(program) {
6088
6119
  var import_promises = require("fs/promises");
6089
6120
  var import_zod16 = require("zod");
6090
6121
  var sourceSchema = import_zod16.z.enum(["canonical_osmd", "agent_overlay", "agent_wiki"]);
6091
- var accessSchema = import_zod16.z.enum(["read_only", "read_write", "append_only"]);
6122
+ var accessSchema = import_zod16.z.enum(["read_only", "read_write", "append_only"]).catch("read_write");
6092
6123
  var ownerSchema = import_zod16.z.enum(["system", "atlas"]);
6093
6124
  var suggestedActionSchema = import_zod16.z.enum([
6094
6125
  "read",
@@ -6098,7 +6129,7 @@ var suggestedActionSchema = import_zod16.z.enum([
6098
6129
  "append",
6099
6130
  "forbidden",
6100
6131
  "invalid_parent"
6101
- ]);
6132
+ ]).catch("update");
6102
6133
  var agentMarkdownErrorCodeSchema = import_zod16.z.enum([
6103
6134
  "canonical_osmd_read_only",
6104
6135
  "agent_parent_not_found",
@@ -6109,9 +6140,13 @@ var agentMarkdownErrorCodeSchema = import_zod16.z.enum([
6109
6140
  "unsupported_agent_file",
6110
6141
  "invalid_agent_wiki_path"
6111
6142
  ]);
6143
+ var agentMarkdownErrorCodeFieldSchema = agentMarkdownErrorCodeSchema.nullable().catch(null);
6112
6144
  var nonEmptyString3 = import_zod16.z.string().min(1);
6113
6145
  var nonNegativeInt3 = import_zod16.z.coerce.number().int().min(0);
6114
- var agentOverlayFileSchema = import_zod16.z.enum(["notes.md", "log.md"]);
6146
+ var supportedAgentOverlayFile = "notes.md";
6147
+ var supportedWikiIndexFile = "index.md";
6148
+ var supportedWikiLogFile = "log.md";
6149
+ var agentOverlayFileSchema = import_zod16.z.enum([supportedAgentOverlayFile]);
6115
6150
  var agentMarkdownFileSchema = import_zod16.z.object({
6116
6151
  path: import_zod16.z.string(),
6117
6152
  source: sourceSchema,
@@ -6124,7 +6159,7 @@ var agentMarkdownFileSchema = import_zod16.z.object({
6124
6159
  parentRef: import_zod16.z.string().nullable().optional(),
6125
6160
  agentChildrenAllowed: import_zod16.z.boolean(),
6126
6161
  suggestedAction: suggestedActionSchema,
6127
- errorCode: agentMarkdownErrorCodeSchema.nullable().optional(),
6162
+ errorCode: agentMarkdownErrorCodeFieldSchema.optional(),
6128
6163
  content: import_zod16.z.string().nullable().optional(),
6129
6164
  url: import_zod16.z.string().nullable().optional()
6130
6165
  }).transform((value) => ({
@@ -6198,6 +6233,21 @@ var AGENT_JSON_KEY_ALIASES = {
6198
6233
  suggested_action: "suggestedAction",
6199
6234
  error_code: "errorCode"
6200
6235
  };
6236
+ function isSupportedAgentMarkdownFile(file) {
6237
+ if (file.source !== "agent_overlay") {
6238
+ return true;
6239
+ }
6240
+ return file.path === `.agent/${supportedAgentOverlayFile}` || file.path.endsWith(`/.agent/${supportedAgentOverlayFile}`);
6241
+ }
6242
+ function filterSupportedAgentMarkdownData(data) {
6243
+ if (isRecord5(data) && Array.isArray(data.files)) {
6244
+ return {
6245
+ ...data,
6246
+ files: data.files.filter(isSupportedAgentMarkdownFile)
6247
+ };
6248
+ }
6249
+ return data;
6250
+ }
6201
6251
  var contentStdinPromise = null;
6202
6252
  function isRecord5(value) {
6203
6253
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
@@ -6370,7 +6420,7 @@ async function runAgentMarkdownMutation(params) {
6370
6420
  envelope: buildSuccessEnvelope({
6371
6421
  command: params.command,
6372
6422
  status: mutationPayload.status,
6373
- data: parsedData.data,
6423
+ data: filterSupportedAgentMarkdownData(parsedData.data),
6374
6424
  requestId: result.envelope.meta.requestId
6375
6425
  })
6376
6426
  });
@@ -6381,24 +6431,50 @@ function normalizeAgentFilePath(file) {
6381
6431
  const parsed = agentOverlayFileSchema.safeParse(fileName);
6382
6432
  if (!parsed.success) {
6383
6433
  throw new CliError({
6384
- message: ".agent supports only notes.md and log.md in this CLI slice.",
6434
+ message: ".agent supports only notes.md in this CLI slice.",
6385
6435
  kind: "invalid_args",
6386
6436
  status: 400,
6387
6437
  exitCode: EXIT_CODES.invalidArgs,
6388
- details: { supportedFiles: ["notes.md", "log.md"] }
6438
+ details: { supportedFiles: [supportedAgentOverlayFile] }
6389
6439
  });
6390
6440
  }
6391
6441
  return `.agent/${parsed.data}`;
6392
6442
  }
6393
- function normalizeWikiPath(path) {
6443
+ function supportedWikiFilesMessage(files) {
6444
+ return `Agent Wiki file commands support only ${files.join(" and ")} in this CLI slice.`;
6445
+ }
6446
+ function normalizeWikiPath(path, options = {}) {
6447
+ const supportedFiles = options.supportedFiles ?? [supportedWikiIndexFile, supportedWikiLogFile];
6394
6448
  const trimmed = nonEmptyString3.parse(path).trim().replace(/^\/+/, "");
6395
6449
  if (trimmed.localeCompare("Agent Wiki", void 0, { sensitivity: "accent" }) === 0) {
6396
- return "Agent Wiki";
6450
+ if (options.allowRoot) {
6451
+ return "Agent Wiki";
6452
+ }
6453
+ throw new CliError({
6454
+ message: supportedWikiFilesMessage(supportedFiles),
6455
+ kind: "invalid_args",
6456
+ status: 400,
6457
+ exitCode: EXIT_CODES.invalidArgs,
6458
+ details: { supportedFiles }
6459
+ });
6397
6460
  }
6398
- if (trimmed.toLowerCase().startsWith("agent wiki/")) {
6399
- return `Agent Wiki/${trimmed.slice("Agent Wiki/".length)}`;
6461
+ const fileName = trimmed.toLowerCase().startsWith("agent wiki/") ? trimmed.slice("Agent Wiki/".length) : trimmed;
6462
+ if (!supportedFiles.includes(fileName)) {
6463
+ throw new CliError({
6464
+ message: supportedWikiFilesMessage(supportedFiles),
6465
+ kind: "invalid_args",
6466
+ status: 400,
6467
+ exitCode: EXIT_CODES.invalidArgs,
6468
+ details: { supportedFiles }
6469
+ });
6400
6470
  }
6401
- return `Agent Wiki/${trimmed}`;
6471
+ return `Agent Wiki/${fileName}`;
6472
+ }
6473
+ function normalizeWikiIndexPath(path) {
6474
+ return normalizeWikiPath(path, { supportedFiles: [supportedWikiIndexFile] });
6475
+ }
6476
+ function normalizeWikiLogPath(path = supportedWikiLogFile) {
6477
+ return normalizeWikiPath(path, { supportedFiles: [supportedWikiLogFile] });
6402
6478
  }
6403
6479
  function parseOptionalParentRef(value) {
6404
6480
  return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
@@ -6508,6 +6584,14 @@ function writePreflightError(status, action) {
6508
6584
  status: 403
6509
6585
  };
6510
6586
  }
6587
+ if (status.access === "append_only" && action !== "append") {
6588
+ return {
6589
+ code: "append_only_violation",
6590
+ message: `Agent markdown file is append-only and cannot be overwritten: ${status.path}`,
6591
+ suggestedAction: status.suggestedAction,
6592
+ status: 403
6593
+ };
6594
+ }
6511
6595
  if (action === "create") {
6512
6596
  if (status.exists) {
6513
6597
  return {
@@ -6519,7 +6603,7 @@ function writePreflightError(status, action) {
6519
6603
  }
6520
6604
  if (!status.canCreate) {
6521
6605
  return {
6522
- code: status.access === "append_only" ? "append_only_violation" : "agent_path_forbidden",
6606
+ code: "agent_path_forbidden",
6523
6607
  message: `Create is not allowed for ${status.path}.`,
6524
6608
  suggestedAction: status.suggestedAction,
6525
6609
  status: 403
@@ -6537,7 +6621,7 @@ function writePreflightError(status, action) {
6537
6621
  }
6538
6622
  if (!status.canUpdate) {
6539
6623
  return {
6540
- code: status.access === "append_only" ? "append_only_violation" : "agent_path_forbidden",
6624
+ code: "agent_path_forbidden",
6541
6625
  message: `Update is not allowed for ${status.path}.`,
6542
6626
  suggestedAction: status.suggestedAction,
6543
6627
  status: 403
@@ -6553,7 +6637,7 @@ function writePreflightError(status, action) {
6553
6637
  status: 404
6554
6638
  };
6555
6639
  }
6556
- if (!status.canAppend) {
6640
+ if (status.access !== "append_only" || !status.canAppend) {
6557
6641
  return {
6558
6642
  code: "append_only_violation",
6559
6643
  message: `Append is not allowed for ${status.path}.`,
@@ -6606,21 +6690,26 @@ async function runWriteFlow(params) {
6606
6690
  field: "update_agent_markdown_file"
6607
6691
  },
6608
6692
  append: {
6609
- operationName: "AppendAgentMarkdownFile",
6610
- field: "append_agent_markdown_file"
6693
+ operationName: "RecordAgentMarkdownLog",
6694
+ field: "record_agent_markdown_log"
6611
6695
  }
6612
6696
  }[params.action];
6697
+ const variables = params.action === "append" ? {
6698
+ organization_id: params.organizationId,
6699
+ path: status.data.path,
6700
+ content: params.content
6701
+ } : {
6702
+ organization_id: params.organizationId,
6703
+ path: status.data.path,
6704
+ parent_ref: status.data.parentRef ?? params.parentRef,
6705
+ content: params.content
6706
+ };
6613
6707
  return runAgentMarkdownMutation({
6614
6708
  command: params.command,
6615
6709
  operationName: mutation.operationName,
6616
6710
  runtimeOptions: params.runtimeOptions,
6617
6711
  field: mutation.field,
6618
- variables: {
6619
- organization_id: params.organizationId,
6620
- path: status.data.path,
6621
- parent_ref: status.data.parentRef ?? params.parentRef,
6622
- content: params.content
6623
- }
6712
+ variables
6624
6713
  });
6625
6714
  }
6626
6715
  function addContentOptions(command) {
@@ -6714,8 +6803,8 @@ function registerOsmdCommands(program) {
6714
6803
  })
6715
6804
  });
6716
6805
  });
6717
- const agent = osmd.command("agent").description(".agent overlay files writable by agents; supports notes.md and log.md");
6718
- agent.command("status <parent-ref> <file>").action(async (parentRef, file, _opts, cmd) => {
6806
+ const agent = osmd.command("agent").description(".agent overlay memory attached to canonical OSMD parents; supports notes.md");
6807
+ agent.command("status <parent-ref> <file>").description("Show .agent notes.md metadata without creating files").action(async (parentRef, file, _opts, cmd) => {
6719
6808
  const { organizationId, runtimeOptions } = await resolveOsmdContext(cmd);
6720
6809
  const result = await requestAgentMarkdownStatus({
6721
6810
  command: "osmd.agent.status",
@@ -6733,7 +6822,7 @@ function registerOsmdCommands(program) {
6733
6822
  })
6734
6823
  });
6735
6824
  });
6736
- agent.command("init <parent-ref>").action(async (parentRef, _opts, cmd) => {
6825
+ agent.command("init <parent-ref>").description("Idempotently initialize supported .agent files for a canonical OSMD parent").action(async (parentRef, _opts, cmd) => {
6737
6826
  const { organizationId, runtimeOptions } = await resolveOsmdContext(cmd);
6738
6827
  return runAgentMarkdownMutation({
6739
6828
  command: "osmd.agent.init",
@@ -6747,7 +6836,7 @@ function registerOsmdCommands(program) {
6747
6836
  }
6748
6837
  });
6749
6838
  });
6750
- agent.command("read <parent-ref> <file>").action(async (parentRef, file, _opts, cmd) => {
6839
+ agent.command("read <parent-ref> <file>").description("Read .agent notes.md without creating files").action(async (parentRef, file, _opts, cmd) => {
6751
6840
  const { organizationId, runtimeOptions } = await resolveOsmdContext(cmd);
6752
6841
  const result = await requestAgentMarkdownFile({
6753
6842
  command: "osmd.agent.read",
@@ -6765,7 +6854,9 @@ function registerOsmdCommands(program) {
6765
6854
  })
6766
6855
  });
6767
6856
  });
6768
- addContentOptions(agent.command("create <parent-ref> <file>")).action(
6857
+ addContentOptions(
6858
+ agent.command("create <parent-ref> <file>").description("Create .agent notes.md after status/permission preflight")
6859
+ ).action(
6769
6860
  async (parentRef, file, opts, cmd) => {
6770
6861
  const globals = cmd.optsWithGlobals();
6771
6862
  const content = await resolveContentInput(opts, globals);
@@ -6781,7 +6872,9 @@ function registerOsmdCommands(program) {
6781
6872
  });
6782
6873
  }
6783
6874
  );
6784
- addContentOptions(agent.command("update <parent-ref> <file>")).action(
6875
+ addContentOptions(
6876
+ agent.command("update <parent-ref> <file>").description("Update .agent notes.md after status/permission preflight")
6877
+ ).action(
6785
6878
  async (parentRef, file, opts, cmd) => {
6786
6879
  const globals = cmd.optsWithGlobals();
6787
6880
  const content = await resolveContentInput(opts, globals);
@@ -6797,24 +6890,8 @@ function registerOsmdCommands(program) {
6797
6890
  });
6798
6891
  }
6799
6892
  );
6800
- addContentOptions(agent.command("append <parent-ref> <file>")).action(
6801
- async (parentRef, file, opts, cmd) => {
6802
- const globals = cmd.optsWithGlobals();
6803
- const content = await resolveContentInput(opts, globals);
6804
- const { organizationId, runtimeOptions } = await resolveOsmdContext(cmd);
6805
- return runWriteFlow({
6806
- command: "osmd.agent.append",
6807
- action: "append",
6808
- runtimeOptions,
6809
- organizationId,
6810
- path: normalizeAgentFilePath(file),
6811
- parentRef: nonEmptyString3.parse(parentRef).trim(),
6812
- content
6813
- });
6814
- }
6815
- );
6816
- const wiki = osmd.command("wiki").description("Agent Wiki files writable by agents; first slice should use index.md and log.md");
6817
- wiki.command("status <path>").action(async (path, _opts, cmd) => {
6893
+ const wiki = osmd.command("wiki").description("Agent Wiki files writable by agents; supports index.md and append-only log.md");
6894
+ wiki.command("status <path>").description("Show Agent Wiki index.md or log.md metadata without creating files").action(async (path, _opts, cmd) => {
6818
6895
  const { organizationId, runtimeOptions } = await resolveOsmdContext(cmd);
6819
6896
  const result = await requestAgentMarkdownStatus({
6820
6897
  command: "osmd.wiki.status",
@@ -6831,7 +6908,7 @@ function registerOsmdCommands(program) {
6831
6908
  })
6832
6909
  });
6833
6910
  });
6834
- wiki.command("read <path>").action(async (path, _opts, cmd) => {
6911
+ wiki.command("read <path>").description("Read Agent Wiki index.md or log.md without creating files").action(async (path, _opts, cmd) => {
6835
6912
  const { organizationId, runtimeOptions } = await resolveOsmdContext(cmd);
6836
6913
  const result = await requestAgentMarkdownFile({
6837
6914
  command: "osmd.wiki.read",
@@ -6848,13 +6925,13 @@ function registerOsmdCommands(program) {
6848
6925
  })
6849
6926
  });
6850
6927
  });
6851
- wiki.command("children [path]").action(async (path, _opts, cmd) => {
6928
+ wiki.command("children [path]").description("List Agent Wiki children through backend metadata").action(async (path, _opts, cmd) => {
6852
6929
  const { organizationId, runtimeOptions } = await resolveOsmdContext(cmd);
6853
6930
  const result = await requestAgentMarkdownChildren({
6854
6931
  command: "osmd.wiki.children",
6855
6932
  runtimeOptions,
6856
6933
  organizationId,
6857
- path: typeof path === "string" && path.trim() !== "" ? normalizeWikiPath(path) : "Agent Wiki",
6934
+ path: typeof path === "string" && path.trim() !== "" ? normalizeWikiPath(path, { allowRoot: true }) : "Agent Wiki",
6858
6935
  source: "agent_wiki"
6859
6936
  });
6860
6937
  return printEnvelopeAndExit({
@@ -6866,7 +6943,9 @@ function registerOsmdCommands(program) {
6866
6943
  })
6867
6944
  });
6868
6945
  });
6869
- addContentOptions(wiki.command("create <path>")).action(async (path, opts, cmd) => {
6946
+ addContentOptions(
6947
+ wiki.command("create <path>").description("Create Agent Wiki index.md after status/permission preflight")
6948
+ ).action(async (path, opts, cmd) => {
6870
6949
  const globals = cmd.optsWithGlobals();
6871
6950
  const content = await resolveContentInput(opts, globals);
6872
6951
  const { organizationId, runtimeOptions } = await resolveOsmdContext(cmd);
@@ -6875,11 +6954,13 @@ function registerOsmdCommands(program) {
6875
6954
  action: "create",
6876
6955
  runtimeOptions,
6877
6956
  organizationId,
6878
- path: normalizeWikiPath(path),
6957
+ path: normalizeWikiIndexPath(path),
6879
6958
  content
6880
6959
  });
6881
6960
  });
6882
- addContentOptions(wiki.command("update <path>")).action(async (path, opts, cmd) => {
6961
+ addContentOptions(
6962
+ wiki.command("update <path>").description("Update Agent Wiki index.md after status/permission preflight")
6963
+ ).action(async (path, opts, cmd) => {
6883
6964
  const globals = cmd.optsWithGlobals();
6884
6965
  const content = await resolveContentInput(opts, globals);
6885
6966
  const { organizationId, runtimeOptions } = await resolveOsmdContext(cmd);
@@ -6888,20 +6969,22 @@ function registerOsmdCommands(program) {
6888
6969
  action: "update",
6889
6970
  runtimeOptions,
6890
6971
  organizationId,
6891
- path: normalizeWikiPath(path),
6972
+ path: normalizeWikiIndexPath(path),
6892
6973
  content
6893
6974
  });
6894
6975
  });
6895
- addContentOptions(wiki.command("append <path>")).action(async (path, opts, cmd) => {
6976
+ addContentOptions(
6977
+ wiki.command("append-log [path]").description("Append to Agent Wiki log.md after status/permission preflight")
6978
+ ).action(async (path, opts, cmd) => {
6896
6979
  const globals = cmd.optsWithGlobals();
6897
6980
  const content = await resolveContentInput(opts, globals);
6898
6981
  const { organizationId, runtimeOptions } = await resolveOsmdContext(cmd);
6899
6982
  return runWriteFlow({
6900
- command: "osmd.wiki.append",
6983
+ command: "osmd.wiki.append-log",
6901
6984
  action: "append",
6902
6985
  runtimeOptions,
6903
6986
  organizationId,
6904
- path: normalizeWikiPath(path),
6987
+ path: normalizeWikiLogPath(typeof path === "string" && path.trim() !== "" ? path : void 0),
6905
6988
  content
6906
6989
  });
6907
6990
  });
@@ -6951,23 +7034,21 @@ function buildCli(options) {
6951
7034
 
6952
7035
  // src/index.ts
6953
7036
  function printCliFailure(params) {
6954
- printEnvelopeAndExit({
6955
- envelope: {
6956
- ok: false,
6957
- command: "cli",
6958
- status: params.status,
6959
- data: null,
6960
- error: {
6961
- code: params.code,
6962
- message: params.message,
6963
- details: params.details ?? {}
6964
- },
6965
- meta: {
6966
- requestId: "local_error"
6967
- }
7037
+ printEnvelope({
7038
+ ok: false,
7039
+ command: "cli",
7040
+ status: params.status,
7041
+ data: null,
7042
+ error: {
7043
+ code: params.code,
7044
+ message: params.message,
7045
+ details: params.details ?? {}
6968
7046
  },
6969
- exitCode: params.exitCode
7047
+ meta: {
7048
+ requestId: "local_error"
7049
+ }
6970
7050
  });
7051
+ process.exitCode = params.exitCode;
6971
7052
  }
6972
7053
  async function main() {
6973
7054
  const program = buildCli();