@ted-galago/wave-cli 0.1.13 → 0.1.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ted-galago/wave-cli",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "wave": "dist/index.js"
@@ -312,6 +312,27 @@ function summarizeStatus(result) {
312
312
  return `status=${status},err=${err}`;
313
313
  }
314
314
 
315
+ function firstArrayValue(input, paths) {
316
+ for (const path of paths) {
317
+ const value = readPath(input, path);
318
+ if (Array.isArray(value)) {
319
+ return value;
320
+ }
321
+ }
322
+ return [];
323
+ }
324
+
325
+ function recordExactCheck({ lines, label, result, ok, reason }) {
326
+ const status = result?.parsed?.status ?? "n/a";
327
+ const errCode = result?.parsed?.error?.code ?? "none";
328
+ lines.push(
329
+ `${ok ? "PASS" : "FAIL"} | status=${status} | err=${errCode} | reason=${
330
+ reason || (ok ? "ok" : "assertion_failed")
331
+ } | ${label} (${result?.args?.join(" ") ?? "n/a"})`
332
+ );
333
+ return ok ? 0 : 1;
334
+ }
335
+
315
336
  function resolveAnnualStrategicObjectiveId(result) {
316
337
  return firstDefinedValue(result?.parsed, [
317
338
  ["data", "annual_objective", "attributes", "strategicObjectiveId"],
@@ -962,6 +983,8 @@ if (issueId) {
962
983
 
963
984
  const postUpdateVerificationLines = [];
964
985
  let postUpdateVerificationFailures = 0;
986
+ const osmdVerificationLines = [];
987
+ let osmdVerificationFailures = 0;
965
988
 
966
989
  function hasSuccessfulCommand(commandPrefix) {
967
990
  return results.some((res) => {
@@ -1106,6 +1129,193 @@ verifyFieldWrite({
1106
1129
  candidatePaths: [["data", "responsibility", "attributes", "name"]]
1107
1130
  });
1108
1131
 
1132
+ function resolveOsmdAgentParentRef() {
1133
+ const queries = ["Wave Tools", "Ted Martinez", "Ted"];
1134
+ for (const query of queries) {
1135
+ const findRes = runWave(["find", query, "--limit", "10"], env);
1136
+ results.push(findRes);
1137
+ const candidates = firstArrayValue(findRes.parsed, [["data", "candidates"]]);
1138
+ for (const candidate of candidates) {
1139
+ const canonicalPath =
1140
+ candidate && typeof candidate === "object" && typeof candidate.canonicalPath === "string"
1141
+ ? candidate.canonicalPath
1142
+ : "";
1143
+ if (!canonicalPath) continue;
1144
+
1145
+ const statusRes = runWave(["osmd", "status", canonicalPath], env);
1146
+ results.push(statusRes);
1147
+ if (
1148
+ statusRes.parsed?.ok === true &&
1149
+ statusRes.parsed?.data?.source === "canonical_osmd" &&
1150
+ statusRes.parsed?.data?.exists === true &&
1151
+ statusRes.parsed?.data?.agentChildrenAllowed === true
1152
+ ) {
1153
+ return String(statusRes.parsed.data.path || canonicalPath);
1154
+ }
1155
+ }
1156
+ }
1157
+ return null;
1158
+ }
1159
+
1160
+ function runOsmdLiveVerification() {
1161
+ const treeDepthZero = runWave(["osmd", "tree", "--depth", "0"], env);
1162
+ results.push(treeDepthZero);
1163
+ osmdVerificationFailures += recordExactCheck({
1164
+ lines: osmdVerificationLines,
1165
+ label: "osmd.tree depth 0 returns metadata and normalized empty children",
1166
+ result: treeDepthZero,
1167
+ ok:
1168
+ treeDepthZero.parsed?.ok === true &&
1169
+ treeDepthZero.parsed?.data?.source === "canonical_osmd" &&
1170
+ Array.isArray(treeDepthZero.parsed?.data?.children) &&
1171
+ treeDepthZero.parsed.data.children.length === 0,
1172
+ reason: "depth_zero_contract"
1173
+ });
1174
+
1175
+ const wikiRootRead = runWave(["osmd", "wiki", "read", "Agent Wiki"], env);
1176
+ results.push(wikiRootRead);
1177
+ osmdVerificationFailures += recordExactCheck({
1178
+ lines: osmdVerificationLines,
1179
+ label: "osmd.wiki read root",
1180
+ result: wikiRootRead,
1181
+ ok:
1182
+ wikiRootRead.parsed?.ok === true &&
1183
+ wikiRootRead.parsed?.data?.path === "Agent Wiki" &&
1184
+ wikiRootRead.parsed?.data?.source === "agent_wiki",
1185
+ reason: "agent_wiki_root_read"
1186
+ });
1187
+
1188
+ const wikiChildren = runWave(["osmd", "wiki", "children"], env);
1189
+ results.push(wikiChildren);
1190
+ osmdVerificationFailures += recordExactCheck({
1191
+ lines: osmdVerificationLines,
1192
+ label: "osmd.wiki children returns an array",
1193
+ result: wikiChildren,
1194
+ ok: wikiChildren.parsed?.ok === true && Array.isArray(wikiChildren.parsed?.data),
1195
+ reason: "agent_wiki_children"
1196
+ });
1197
+
1198
+ const missingWikiPath = `missing-${verifyStamp}.md`;
1199
+ const missingWikiUpdate = runWave(
1200
+ ["osmd", "wiki", "update", missingWikiPath, "--content", "verify missing update"],
1201
+ env
1202
+ );
1203
+ results.push(missingWikiUpdate);
1204
+ osmdVerificationFailures += recordExactCheck({
1205
+ lines: osmdVerificationLines,
1206
+ label: "osmd.wiki update missing file returns 404 metadata",
1207
+ result: missingWikiUpdate,
1208
+ ok:
1209
+ missingWikiUpdate.code === 5 &&
1210
+ missingWikiUpdate.parsed?.ok === false &&
1211
+ missingWikiUpdate.parsed?.status === 404 &&
1212
+ missingWikiUpdate.parsed?.error?.code === "agent_file_not_found" &&
1213
+ missingWikiUpdate.parsed?.error?.suggestedAction === "create" &&
1214
+ missingWikiUpdate.parsed?.data?.exists === false &&
1215
+ missingWikiUpdate.parsed?.data?.canCreate === true,
1216
+ reason: "missing_file_404"
1217
+ });
1218
+
1219
+ const parentRef = resolveOsmdAgentParentRef();
1220
+ if (!parentRef) {
1221
+ osmdVerificationLines.push(
1222
+ "FAIL | status=n/a | err=osmd_parent_not_found | reason=no_agent_children_allowed_parent | osmd agent parent resolution"
1223
+ );
1224
+ osmdVerificationFailures += 1;
1225
+ return;
1226
+ }
1227
+
1228
+ const agentStatus = runWave(["osmd", "agent", "status", parentRef, "notes.md"], env);
1229
+ results.push(agentStatus);
1230
+ osmdVerificationFailures += recordExactCheck({
1231
+ lines: osmdVerificationLines,
1232
+ label: `osmd.agent status notes parent=${parentRef}`,
1233
+ result: agentStatus,
1234
+ ok:
1235
+ agentStatus.parsed?.ok === true &&
1236
+ agentStatus.parsed?.data?.source === "agent_overlay" &&
1237
+ agentStatus.parsed?.data?.parentRef === parentRef,
1238
+ reason: "agent_overlay_status"
1239
+ });
1240
+
1241
+ const agentInit = runWave(["osmd", "agent", "init", parentRef], env);
1242
+ results.push(agentInit);
1243
+ const initFiles = firstArrayValue(agentInit.parsed, [["data", "files"]]);
1244
+ osmdVerificationFailures += recordExactCheck({
1245
+ lines: osmdVerificationLines,
1246
+ label: `osmd.agent init parent=${parentRef}`,
1247
+ result: agentInit,
1248
+ ok:
1249
+ agentInit.parsed?.ok === true &&
1250
+ initFiles.some((file) => file?.path?.endsWith("/.agent/notes.md")) &&
1251
+ initFiles.some((file) => file?.path?.endsWith("/.agent/log.md")),
1252
+ reason: "agent_overlay_init"
1253
+ });
1254
+
1255
+ const notesContent = `CLI live verify notes ${verifyStamp}`;
1256
+ const agentUpdate = runWave(
1257
+ ["osmd", "agent", "update", parentRef, "notes.md", "--content", notesContent],
1258
+ env
1259
+ );
1260
+ results.push(agentUpdate);
1261
+ osmdVerificationFailures += recordExactCheck({
1262
+ lines: osmdVerificationLines,
1263
+ label: `osmd.agent update notes parent=${parentRef}`,
1264
+ result: agentUpdate,
1265
+ ok:
1266
+ agentUpdate.parsed?.ok === true &&
1267
+ agentUpdate.parsed?.data?.access === "read_write" &&
1268
+ agentUpdate.parsed?.data?.content === notesContent,
1269
+ reason: "agent_overlay_update"
1270
+ });
1271
+
1272
+ const logEntry = `CLI live verify log append ${verifyStamp}`;
1273
+ const agentAppend = runWave(
1274
+ ["osmd", "agent", "append", parentRef, "log.md", "--content", logEntry],
1275
+ env
1276
+ );
1277
+ results.push(agentAppend);
1278
+ osmdVerificationFailures += recordExactCheck({
1279
+ lines: osmdVerificationLines,
1280
+ label: `osmd.agent append log parent=${parentRef}`,
1281
+ result: agentAppend,
1282
+ ok:
1283
+ agentAppend.parsed?.ok === true &&
1284
+ agentAppend.parsed?.data?.access === "append_only" &&
1285
+ String(agentAppend.parsed?.data?.content ?? "").includes(logEntry),
1286
+ reason: "agent_overlay_append"
1287
+ });
1288
+
1289
+ const appendRefusal = runWave(
1290
+ [
1291
+ "osmd",
1292
+ "agent",
1293
+ "append",
1294
+ parentRef,
1295
+ "notes.md",
1296
+ "--content",
1297
+ "verify append refusal"
1298
+ ],
1299
+ env
1300
+ );
1301
+ results.push(appendRefusal);
1302
+ osmdVerificationFailures += recordExactCheck({
1303
+ lines: osmdVerificationLines,
1304
+ label: `osmd.agent append refuses read_write notes parent=${parentRef}`,
1305
+ result: appendRefusal,
1306
+ ok:
1307
+ appendRefusal.code === 4 &&
1308
+ appendRefusal.parsed?.ok === false &&
1309
+ appendRefusal.parsed?.status === 403 &&
1310
+ appendRefusal.parsed?.error?.code === "append_only_violation" &&
1311
+ appendRefusal.parsed?.error?.suggestedAction === "update" &&
1312
+ appendRefusal.parsed?.data?.canAppend === false,
1313
+ reason: "agent_overlay_append_refusal"
1314
+ });
1315
+ }
1316
+
1317
+ runOsmdLiveVerification();
1318
+
1109
1319
  const lines = [];
1110
1320
  let failures = 0;
1111
1321
  for (const res of results) {
@@ -1128,6 +1338,10 @@ if (postUpdateVerificationLines.length > 0) {
1128
1338
  lines.push(...postUpdateVerificationLines);
1129
1339
  }
1130
1340
  failures += postUpdateVerificationFailures;
1341
+ if (osmdVerificationLines.length > 0) {
1342
+ lines.push(...osmdVerificationLines);
1343
+ }
1344
+ failures += osmdVerificationFailures;
1131
1345
  failures += validationRemediationFailures;
1132
1346
 
1133
1347
  if (validationRemediationEntries.length > 0) {