mdkg 0.1.10 → 0.3.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/CHANGELOG.md +69 -0
- package/README.md +40 -15
- package/dist/cli.js +293 -13
- package/dist/commands/capability.js +13 -8
- package/dist/commands/db.js +185 -1
- package/dist/commands/format.js +1 -1
- package/dist/commands/spec.js +101 -0
- package/dist/commands/work.js +569 -20
- package/dist/core/project_db_migrations.js +24 -0
- package/dist/core/project_db_queue.js +186 -0
- package/dist/core/project_db_snapshot.js +28 -3
- package/dist/graph/agent_file_types.js +95 -7
- package/dist/graph/capabilities_indexer.js +89 -2
- package/dist/graph/frontmatter.js +6 -0
- package/dist/graph/node.js +8 -2
- package/dist/init/AGENT_START.md +15 -9
- package/dist/init/CLI_COMMAND_MATRIX.md +33 -5
- package/dist/init/README.md +36 -11
- package/dist/init/init-manifest.json +64 -9
- package/dist/init/skills/default/verify-close-and-checkpoint/SKILL.md +8 -7
- package/dist/init/templates/default/receipt.md +12 -1
- package/dist/init/templates/default/spec.md +8 -6
- package/dist/init/templates/default/work.md +5 -1
- package/dist/init/templates/default/work_order.md +11 -0
- package/dist/init/templates/skills/base.SKILL.md +66 -0
- package/dist/init/templates/specs/agent.SPEC.md +80 -0
- package/dist/init/templates/specs/api.SPEC.md +33 -0
- package/dist/init/templates/specs/base.SPEC.md +120 -0
- package/dist/init/templates/specs/capability.SPEC.md +45 -0
- package/dist/init/templates/specs/integration.SPEC.md +25 -0
- package/dist/init/templates/specs/model.SPEC.md +21 -0
- package/dist/init/templates/specs/project.SPEC.md +39 -0
- package/dist/init/templates/specs/runtime-agent.SPEC.md +49 -0
- package/dist/init/templates/specs/runtime-image.SPEC.md +21 -0
- package/dist/init/templates/specs/tool.SPEC.md +25 -0
- package/dist/util/argparse.js +8 -0
- package/package.json +5 -2
package/dist/cli.js
CHANGED
|
@@ -20,6 +20,7 @@ const format_1 = require("./commands/format");
|
|
|
20
20
|
const doctor_1 = require("./commands/doctor");
|
|
21
21
|
const db_1 = require("./commands/db");
|
|
22
22
|
const capability_1 = require("./commands/capability");
|
|
23
|
+
const spec_1 = require("./commands/spec");
|
|
23
24
|
const archive_1 = require("./commands/archive");
|
|
24
25
|
const bundle_1 = require("./commands/bundle");
|
|
25
26
|
const subgraph_1 = require("./commands/subgraph");
|
|
@@ -63,6 +64,7 @@ function printUsage(log) {
|
|
|
63
64
|
log(" pack Generate a context pack");
|
|
64
65
|
log(" skill Create, list, show, search, and validate skills");
|
|
65
66
|
log(" capability List, search, show, and resolve cached capability surfaces");
|
|
67
|
+
log(" spec List, show, and validate optional SPEC.md capability records");
|
|
66
68
|
log(" archive Add, list, show, verify, and compress archive sidecars");
|
|
67
69
|
log(" bundle Create, list, show, and verify full graph snapshot bundles");
|
|
68
70
|
log(" subgraph Register, sync, materialize, and verify read-only child graph snapshots");
|
|
@@ -194,18 +196,41 @@ function printDbHelp(log, subcommand) {
|
|
|
194
196
|
return;
|
|
195
197
|
case "snapshot":
|
|
196
198
|
log("Usage:");
|
|
197
|
-
log(" mdkg db snapshot seal [--json]");
|
|
199
|
+
log(" mdkg db snapshot seal [--queue-policy drain|paused] [--json]");
|
|
198
200
|
log(" mdkg db snapshot verify [--json]");
|
|
199
201
|
log(" mdkg db snapshot status [--json]");
|
|
200
202
|
log(" mdkg db snapshot dump [--snapshot <path>] [--output <path>] [--json]");
|
|
201
203
|
log(" mdkg db snapshot diff <left-snapshot> <right-snapshot> [--json]");
|
|
202
204
|
log("\nBoundaries:");
|
|
203
205
|
log(" - snapshot seal writes a clean opt-in sealed project DB checkpoint");
|
|
206
|
+
log(" - default queue policy is drain: no ready or leased queue messages");
|
|
207
|
+
log(" - paused queue policy allows ready messages only in paused queues and never leased messages");
|
|
204
208
|
log(" - snapshot verify/status read `.mdkg/db/state/project.sqlite` and its manifest");
|
|
205
209
|
log(" - snapshot dump/diff are deterministic review aids, not source of truth");
|
|
206
210
|
log(" - active runtime/WAL files remain ignored by default");
|
|
207
211
|
printGlobalOptions(log);
|
|
208
212
|
return;
|
|
213
|
+
case "queue":
|
|
214
|
+
log("Usage:");
|
|
215
|
+
log(" mdkg db queue create <queue> [--paused] [--reason <text>] [--json]");
|
|
216
|
+
log(" mdkg db queue pause <queue> [--reason <text>] [--json]");
|
|
217
|
+
log(" mdkg db queue resume <queue> [--json]");
|
|
218
|
+
log(" mdkg db queue enqueue <queue> <message-id> --payload-json <json>|--payload-file <path> [--dedupe-key <key>] [--available-at-ms <ms>] [--max-attempts <n>] [--json]");
|
|
219
|
+
log(" mdkg db queue claim <queue> --lease-owner <owner> --lease-ms <ms> [--json]");
|
|
220
|
+
log(" mdkg db queue ack <queue> <message-id> --lease-owner <owner> [--json]");
|
|
221
|
+
log(" mdkg db queue fail <queue> <message-id> --lease-owner <owner> --error <text> [--retry-after-ms <ms>] [--json]");
|
|
222
|
+
log(" mdkg db queue dead-letter <queue> <message-id> --lease-owner <owner> --error <text> [--json]");
|
|
223
|
+
log(" mdkg db queue release-expired [queue] [--json]");
|
|
224
|
+
log(" mdkg db queue stats [queue] [--json]");
|
|
225
|
+
log(" mdkg db queue list <queue> [--status ready|leased|acked|dead_letter|all] [--limit <n>] [--json]");
|
|
226
|
+
log(" mdkg db queue show <queue> <message-id> [--json]");
|
|
227
|
+
log("\nSemantics:");
|
|
228
|
+
log(" - queues are durable local delivery state, not canonical event history");
|
|
229
|
+
log(" - paused queues reject enqueue and claim");
|
|
230
|
+
log(" - ack, fail, dead-letter, and release-expired are allowed while paused so leased work can settle");
|
|
231
|
+
log(" - no raw SQL or hosted queue dependency is exposed");
|
|
232
|
+
printGlobalOptions(log);
|
|
233
|
+
return;
|
|
209
234
|
default:
|
|
210
235
|
log("Usage:");
|
|
211
236
|
log(" mdkg db index rebuild [--tolerant] [--json]");
|
|
@@ -215,7 +240,13 @@ function printDbHelp(log, subcommand) {
|
|
|
215
240
|
log(" mdkg db migrate [--json]");
|
|
216
241
|
log(" mdkg db verify [--json]");
|
|
217
242
|
log(" mdkg db stats [--json]");
|
|
218
|
-
log(" mdkg db
|
|
243
|
+
log(" mdkg db queue create <queue> [--paused] [--reason <text>] [--json]");
|
|
244
|
+
log(" mdkg db queue enqueue <queue> <message-id> --payload-json <json>|--payload-file <path> [--json]");
|
|
245
|
+
log(" mdkg db queue claim <queue> --lease-owner <owner> --lease-ms <ms> [--json]");
|
|
246
|
+
log(" mdkg db queue ack|fail|dead-letter <queue> <message-id> --lease-owner <owner> [--json]");
|
|
247
|
+
log(" mdkg db queue pause|resume <queue> [--json]");
|
|
248
|
+
log(" mdkg db queue stats|list|show ... [--json]");
|
|
249
|
+
log(" mdkg db snapshot seal [--queue-policy drain|paused] [--json]");
|
|
219
250
|
log(" mdkg db snapshot verify [--json]");
|
|
220
251
|
log(" mdkg db snapshot status [--json]");
|
|
221
252
|
log(" mdkg db snapshot dump [--snapshot <path>] [--output <path>] [--json]");
|
|
@@ -227,14 +258,15 @@ function printDbHelp(log, subcommand) {
|
|
|
227
258
|
log(" - `mdkg db init` does not create an active runtime SQLite database");
|
|
228
259
|
log(" - `mdkg db migrate` creates/updates the active runtime SQLite database");
|
|
229
260
|
log(" - `mdkg db migrate` applies mdkg-owned foundation plus internal queue, event, receipt, reducer, and lease migrations");
|
|
230
|
-
log(" - queue
|
|
261
|
+
log(" - `mdkg db queue ...` exposes local durable queue delivery operations");
|
|
262
|
+
log(" - paused queues reject enqueue/claim and can be sealed with explicit paused snapshot policy");
|
|
231
263
|
log(" - event rows are durable local history; receipts, reducers, and writer leases remain internal helper surfaces");
|
|
232
264
|
log(" - no public `mdkg db event`, `mdkg db reducer`, or `mdkg db lease` CLI is exposed");
|
|
233
265
|
log(" - `mdkg db verify` checks config, layout, SQLite integrity, migrations, and transient files");
|
|
234
266
|
log(" - `mdkg db stats` reports table counts, migration state, DB size, and receipt counts");
|
|
235
267
|
log(" - `mdkg db snapshot ...` manages opt-in sealed checkpoints and review dumps");
|
|
236
268
|
log(" - active `.mdkg/db/runtime` and transient DB files are ignored by default");
|
|
237
|
-
log(" - no raw SQL, hosted queue/event store, profile, public
|
|
269
|
+
log(" - no raw SQL, hosted queue/event store, profile, public event/reducer/lease command, or publish behavior is exposed here");
|
|
238
270
|
printGlobalOptions(log);
|
|
239
271
|
}
|
|
240
272
|
}
|
|
@@ -405,6 +437,41 @@ function printCapabilityHelp(log, subcommand) {
|
|
|
405
437
|
printGlobalOptions(log);
|
|
406
438
|
}
|
|
407
439
|
}
|
|
440
|
+
function printSpecHelp(log, subcommand) {
|
|
441
|
+
switch ((subcommand ?? "").toLowerCase()) {
|
|
442
|
+
case "list":
|
|
443
|
+
log("Usage:");
|
|
444
|
+
log(" mdkg spec list [--json]");
|
|
445
|
+
log("\nNotes:");
|
|
446
|
+
log(" SPEC.md is optional and declares reusable capability surfaces.");
|
|
447
|
+
printGlobalOptions(log);
|
|
448
|
+
return;
|
|
449
|
+
case "show":
|
|
450
|
+
log("Usage:");
|
|
451
|
+
log(" mdkg spec show <id-or-qid-or-alias> [--json]");
|
|
452
|
+
log("\nNotes:");
|
|
453
|
+
log(" Shows one optional SPEC.md capability record from the capability index.");
|
|
454
|
+
printGlobalOptions(log);
|
|
455
|
+
return;
|
|
456
|
+
case "validate":
|
|
457
|
+
log("Usage:");
|
|
458
|
+
log(" mdkg spec validate [<id-or-qid-or-alias>] [--json]");
|
|
459
|
+
log("\nNotes:");
|
|
460
|
+
log(" With no reference, validates the graph and all optional SPEC.md capability records.");
|
|
461
|
+
log(" With a reference, also ensures that specific SPEC.md capability exists.");
|
|
462
|
+
printGlobalOptions(log);
|
|
463
|
+
return;
|
|
464
|
+
default:
|
|
465
|
+
log("Usage:");
|
|
466
|
+
log(" mdkg spec list [--json]");
|
|
467
|
+
log(" mdkg spec show <id-or-qid-or-alias> [--json]");
|
|
468
|
+
log(" mdkg spec validate [<id-or-qid-or-alias>] [--json]");
|
|
469
|
+
log("\nNotes:");
|
|
470
|
+
log(" SPEC.md is optional and reusable-capability oriented.");
|
|
471
|
+
log(" Use `mdkg capability ...` for broader skill, SPEC.md, WORK.md, core-doc, and design-doc discovery.");
|
|
472
|
+
printGlobalOptions(log);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
408
475
|
function printArchiveHelp(log, subcommand) {
|
|
409
476
|
switch ((subcommand ?? "").toLowerCase()) {
|
|
410
477
|
case "add":
|
|
@@ -550,15 +617,31 @@ function printWorkHelp(log, subcommand) {
|
|
|
550
617
|
log("Usage:");
|
|
551
618
|
log(' mdkg work contract new "<title>" --id <work.id> --agent-id <agent.id> --kind <kind> --inputs <...> --outputs <...> [--required-capabilities <...>] [--pricing-model <...>] [--json]');
|
|
552
619
|
break;
|
|
620
|
+
case "trigger":
|
|
621
|
+
log("Usage:");
|
|
622
|
+
log(' mdkg work trigger <work-or-capability-ref> [--id <order.id>] [--title "<title>"] [--requester <ref>] [--enqueue <queue>] [--json]');
|
|
623
|
+
log("\nExample:");
|
|
624
|
+
log(" mdkg work trigger work.example --id order.example-1 --requester user://example --json");
|
|
625
|
+
log("\nNotes:");
|
|
626
|
+
log(" Accepted targets: direct WORK.md ref, or SPEC.md ref with exactly one resolvable work contract.");
|
|
627
|
+
log(" Creates a deterministic WORK_ORDER.md semantic mirror and does not execute work.");
|
|
628
|
+
log(" Queue enqueue requires a valid project DB plus an explicitly created active queue and never executes work.");
|
|
629
|
+
break;
|
|
553
630
|
case "order":
|
|
554
631
|
log("Usage:");
|
|
555
|
-
log(' mdkg work order new "<title>" --id <order.id> --work-id <work.id> --requester <ref> [--request-ref <ref>] [--input-refs <...>] [--requested-outputs <...>] [--json]');
|
|
556
|
-
log(" mdkg work order
|
|
632
|
+
log(' mdkg work order new "<title>" --id <order.id> --work-id <work.id> --requester <ref> [--request-ref <ref>] [--trigger-ref <ref>] [--payload-hash <sha256:...>] [--input-refs <...>] [--queue-refs <...>] [--requested-outputs <...>] [--json]');
|
|
633
|
+
log(" mdkg work order status <id-or-qid> [--json]");
|
|
634
|
+
log(" mdkg work order update <id-or-qid> [--status <status>] [--add-input-refs <...>] [--add-queue-refs <...>] [--add-artifacts <...>] [--json]");
|
|
635
|
+
log("\nNotes:");
|
|
636
|
+
log(" work order status is read-only and reports deterministic JSON order state plus linked receipts.");
|
|
557
637
|
break;
|
|
558
638
|
case "receipt":
|
|
559
639
|
log("Usage:");
|
|
560
|
-
log(' mdkg work receipt new "<title>" --id <receipt.id> --work-order-id <order.id> --outcome success|partial|failure [--receipt-status recorded|verified|rejected|superseded] [--json]');
|
|
561
|
-
log(" mdkg work receipt
|
|
640
|
+
log(' mdkg work receipt new "<title>" --id <receipt.id> --work-order-id <order.id> --outcome success|partial|failure [--receipt-status recorded|verified|rejected|superseded] [--redaction-policy refs_and_hashes_only|redacted_summary|external_private] [--evidence-hashes <sha256:...>] [--json]');
|
|
641
|
+
log(" mdkg work receipt verify <id-or-qid> [--json]");
|
|
642
|
+
log(" mdkg work receipt update <id-or-qid> [--receipt-status <status>] [--add-artifacts <...>] [--add-proof-refs <...>] [--add-attestation-refs <...>] [--add-evidence-hashes <sha256:...>] [--json]");
|
|
643
|
+
log("\nNotes:");
|
|
644
|
+
log(" work receipt verify is read-only and reports deterministic JSON linkage, evidence, hash, outcome, and redaction checks.");
|
|
562
645
|
break;
|
|
563
646
|
case "artifact":
|
|
564
647
|
log("Usage:");
|
|
@@ -567,8 +650,9 @@ function printWorkHelp(log, subcommand) {
|
|
|
567
650
|
default:
|
|
568
651
|
log("Usage:");
|
|
569
652
|
log(" mdkg work contract new ...");
|
|
570
|
-
log(" mdkg work
|
|
571
|
-
log(" mdkg work
|
|
653
|
+
log(" mdkg work trigger <work-or-capability-ref> ...");
|
|
654
|
+
log(" mdkg work order new|status|update ...");
|
|
655
|
+
log(" mdkg work receipt new|verify|update ...");
|
|
572
656
|
log(" mdkg work artifact add ...");
|
|
573
657
|
log("\nNotes:");
|
|
574
658
|
log(" - work commands mutate semantic mirror files only");
|
|
@@ -807,6 +891,9 @@ function printCommandHelp(log, command, subcommand) {
|
|
|
807
891
|
case "capability":
|
|
808
892
|
printCapabilityHelp(log, subcommand);
|
|
809
893
|
return;
|
|
894
|
+
case "spec":
|
|
895
|
+
printSpecHelp(log, subcommand);
|
|
896
|
+
return;
|
|
810
897
|
case "archive":
|
|
811
898
|
printArchiveHelp(log, subcommand);
|
|
812
899
|
return;
|
|
@@ -922,6 +1009,16 @@ function parseNumberFlag(flag, value) {
|
|
|
922
1009
|
}
|
|
923
1010
|
return parsed;
|
|
924
1011
|
}
|
|
1012
|
+
function parseQueuePolicyFlag(value) {
|
|
1013
|
+
const raw = requireFlagValue("--queue-policy", value);
|
|
1014
|
+
if (raw === undefined) {
|
|
1015
|
+
return undefined;
|
|
1016
|
+
}
|
|
1017
|
+
if (raw === "drain" || raw === "paused") {
|
|
1018
|
+
return raw;
|
|
1019
|
+
}
|
|
1020
|
+
throw new errors_1.UsageError("--queue-policy must be drain or paused");
|
|
1021
|
+
}
|
|
925
1022
|
function parseEdgesFlag(value) {
|
|
926
1023
|
if (value === undefined) {
|
|
927
1024
|
return undefined;
|
|
@@ -1109,6 +1206,107 @@ function runDbSubcommand(parsed, root) {
|
|
|
1109
1206
|
(0, db_1.runDbStatsCommand)({ root, json: parseBooleanFlag("--json", parsed.flags["--json"]) });
|
|
1110
1207
|
return 0;
|
|
1111
1208
|
}
|
|
1209
|
+
case "queue": {
|
|
1210
|
+
const action = (parsed.positionals[2] ?? "").toLowerCase();
|
|
1211
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
1212
|
+
const queueName = parsed.positionals[3];
|
|
1213
|
+
const messageId = parsed.positionals[4];
|
|
1214
|
+
const common = {
|
|
1215
|
+
root,
|
|
1216
|
+
json,
|
|
1217
|
+
queueName,
|
|
1218
|
+
messageId,
|
|
1219
|
+
leaseOwner: requireFlagValue("--lease-owner", parsed.flags["--lease-owner"]),
|
|
1220
|
+
leaseMs: parseNumberFlag("--lease-ms", parsed.flags["--lease-ms"]),
|
|
1221
|
+
payloadJson: requireFlagValue("--payload-json", parsed.flags["--payload-json"]),
|
|
1222
|
+
payloadFile: requireFlagValue("--payload-file", parsed.flags["--payload-file"]),
|
|
1223
|
+
dedupeKey: requireFlagValue("--dedupe-key", parsed.flags["--dedupe-key"]),
|
|
1224
|
+
availableAtMs: parseNumberFlag("--available-at-ms", parsed.flags["--available-at-ms"]),
|
|
1225
|
+
maxAttempts: parseNumberFlag("--max-attempts", parsed.flags["--max-attempts"]),
|
|
1226
|
+
retryAfterMs: parseNumberFlag("--retry-after-ms", parsed.flags["--retry-after-ms"]),
|
|
1227
|
+
error: requireFlagValue("--error", parsed.flags["--error"]),
|
|
1228
|
+
paused: parseBooleanFlag("--paused", parsed.flags["--paused"]),
|
|
1229
|
+
reason: requireFlagValue("--reason", parsed.flags["--reason"]),
|
|
1230
|
+
status: requireFlagValue("--status", parsed.flags["--status"]),
|
|
1231
|
+
limit: parseNumberFlag("--limit", parsed.flags["--limit"]),
|
|
1232
|
+
};
|
|
1233
|
+
switch (action) {
|
|
1234
|
+
case "create":
|
|
1235
|
+
if (!queueName || parsed.positionals.length > 4) {
|
|
1236
|
+
throw new errors_1.UsageError("mdkg db queue create requires <queue>");
|
|
1237
|
+
}
|
|
1238
|
+
(0, db_1.runDbQueueCreateCommand)(common);
|
|
1239
|
+
return 0;
|
|
1240
|
+
case "pause":
|
|
1241
|
+
if (!queueName || parsed.positionals.length > 4) {
|
|
1242
|
+
throw new errors_1.UsageError("mdkg db queue pause requires <queue>");
|
|
1243
|
+
}
|
|
1244
|
+
(0, db_1.runDbQueuePauseCommand)(common);
|
|
1245
|
+
return 0;
|
|
1246
|
+
case "resume":
|
|
1247
|
+
if (!queueName || parsed.positionals.length > 4) {
|
|
1248
|
+
throw new errors_1.UsageError("mdkg db queue resume requires <queue>");
|
|
1249
|
+
}
|
|
1250
|
+
(0, db_1.runDbQueueResumeCommand)(common);
|
|
1251
|
+
return 0;
|
|
1252
|
+
case "enqueue":
|
|
1253
|
+
if (!queueName || !messageId || parsed.positionals.length > 5) {
|
|
1254
|
+
throw new errors_1.UsageError("mdkg db queue enqueue requires <queue> <message-id>");
|
|
1255
|
+
}
|
|
1256
|
+
(0, db_1.runDbQueueEnqueueCommand)(common);
|
|
1257
|
+
return 0;
|
|
1258
|
+
case "claim":
|
|
1259
|
+
if (!queueName || parsed.positionals.length > 4) {
|
|
1260
|
+
throw new errors_1.UsageError("mdkg db queue claim requires <queue>");
|
|
1261
|
+
}
|
|
1262
|
+
(0, db_1.runDbQueueClaimCommand)(common);
|
|
1263
|
+
return 0;
|
|
1264
|
+
case "ack":
|
|
1265
|
+
if (!queueName || !messageId || parsed.positionals.length > 5) {
|
|
1266
|
+
throw new errors_1.UsageError("mdkg db queue ack requires <queue> <message-id>");
|
|
1267
|
+
}
|
|
1268
|
+
(0, db_1.runDbQueueAckCommand)(common);
|
|
1269
|
+
return 0;
|
|
1270
|
+
case "fail":
|
|
1271
|
+
if (!queueName || !messageId || parsed.positionals.length > 5) {
|
|
1272
|
+
throw new errors_1.UsageError("mdkg db queue fail requires <queue> <message-id>");
|
|
1273
|
+
}
|
|
1274
|
+
(0, db_1.runDbQueueFailCommand)(common);
|
|
1275
|
+
return 0;
|
|
1276
|
+
case "dead-letter":
|
|
1277
|
+
if (!queueName || !messageId || parsed.positionals.length > 5) {
|
|
1278
|
+
throw new errors_1.UsageError("mdkg db queue dead-letter requires <queue> <message-id>");
|
|
1279
|
+
}
|
|
1280
|
+
(0, db_1.runDbQueueDeadLetterCommand)(common);
|
|
1281
|
+
return 0;
|
|
1282
|
+
case "release-expired":
|
|
1283
|
+
if (parsed.positionals.length > 4) {
|
|
1284
|
+
throw new errors_1.UsageError("mdkg db queue release-expired accepts at most one queue");
|
|
1285
|
+
}
|
|
1286
|
+
(0, db_1.runDbQueueReleaseExpiredCommand)(common);
|
|
1287
|
+
return 0;
|
|
1288
|
+
case "stats":
|
|
1289
|
+
if (parsed.positionals.length > 4) {
|
|
1290
|
+
throw new errors_1.UsageError("mdkg db queue stats accepts at most one queue");
|
|
1291
|
+
}
|
|
1292
|
+
(0, db_1.runDbQueueStatsCommand)(common);
|
|
1293
|
+
return 0;
|
|
1294
|
+
case "list":
|
|
1295
|
+
if (!queueName || parsed.positionals.length > 4) {
|
|
1296
|
+
throw new errors_1.UsageError("mdkg db queue list requires <queue>");
|
|
1297
|
+
}
|
|
1298
|
+
(0, db_1.runDbQueueListCommand)(common);
|
|
1299
|
+
return 0;
|
|
1300
|
+
case "show":
|
|
1301
|
+
if (!queueName || !messageId || parsed.positionals.length > 5) {
|
|
1302
|
+
throw new errors_1.UsageError("mdkg db queue show requires <queue> <message-id>");
|
|
1303
|
+
}
|
|
1304
|
+
(0, db_1.runDbQueueShowCommand)(common);
|
|
1305
|
+
return 0;
|
|
1306
|
+
default:
|
|
1307
|
+
throw new errors_1.UsageError("mdkg db queue requires create/pause/resume/enqueue/claim/ack/fail/dead-letter/release-expired/stats/list/show");
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1112
1310
|
case "snapshot": {
|
|
1113
1311
|
const action = (parsed.positionals[2] ?? "").toLowerCase();
|
|
1114
1312
|
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
@@ -1117,7 +1315,7 @@ function runDbSubcommand(parsed, root) {
|
|
|
1117
1315
|
if (parsed.positionals.length > 3) {
|
|
1118
1316
|
throw new errors_1.UsageError("mdkg db snapshot seal does not accept positional arguments");
|
|
1119
1317
|
}
|
|
1120
|
-
(0, db_1.runDbSnapshotSealCommand)({ root, json });
|
|
1318
|
+
(0, db_1.runDbSnapshotSealCommand)({ root, json, queuePolicy: parseQueuePolicyFlag(parsed.flags["--queue-policy"]) });
|
|
1121
1319
|
return 0;
|
|
1122
1320
|
case "verify":
|
|
1123
1321
|
if (parsed.positionals.length > 3) {
|
|
@@ -1154,7 +1352,7 @@ function runDbSubcommand(parsed, root) {
|
|
|
1154
1352
|
}
|
|
1155
1353
|
}
|
|
1156
1354
|
default:
|
|
1157
|
-
throw new errors_1.UsageError("mdkg db requires index/init/migrate/verify/stats/snapshot");
|
|
1355
|
+
throw new errors_1.UsageError("mdkg db requires index/init/migrate/verify/stats/queue/snapshot");
|
|
1158
1356
|
}
|
|
1159
1357
|
}
|
|
1160
1358
|
function runCapabilitySubcommand(parsed, root) {
|
|
@@ -1212,6 +1410,45 @@ function runCapabilitySubcommand(parsed, root) {
|
|
|
1212
1410
|
throw new errors_1.UsageError("capability requires list/search/show/resolve");
|
|
1213
1411
|
}
|
|
1214
1412
|
}
|
|
1413
|
+
function runSpecSubcommand(parsed, root) {
|
|
1414
|
+
const subcommand = (parsed.positionals[1] ?? "").toLowerCase();
|
|
1415
|
+
switch (subcommand) {
|
|
1416
|
+
case "list": {
|
|
1417
|
+
if (parsed.positionals.length > 2) {
|
|
1418
|
+
throw new errors_1.UsageError("spec list does not accept positional arguments");
|
|
1419
|
+
}
|
|
1420
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
1421
|
+
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
1422
|
+
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
1423
|
+
(0, spec_1.runSpecListCommand)({ root, json, noCache, noReindex });
|
|
1424
|
+
return 0;
|
|
1425
|
+
}
|
|
1426
|
+
case "show": {
|
|
1427
|
+
const id = parsed.positionals[2];
|
|
1428
|
+
if (!id || parsed.positionals.length > 3) {
|
|
1429
|
+
throw new errors_1.UsageError("spec show requires <id-or-qid-or-alias>");
|
|
1430
|
+
}
|
|
1431
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
1432
|
+
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
1433
|
+
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
1434
|
+
(0, spec_1.runSpecShowCommand)({ root, id, json, noCache, noReindex });
|
|
1435
|
+
return 0;
|
|
1436
|
+
}
|
|
1437
|
+
case "validate": {
|
|
1438
|
+
const id = parsed.positionals[2];
|
|
1439
|
+
if (parsed.positionals.length > 3) {
|
|
1440
|
+
throw new errors_1.UsageError("spec validate accepts at most one SPEC reference");
|
|
1441
|
+
}
|
|
1442
|
+
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
1443
|
+
const noCache = parseBooleanFlag("--no-cache", parsed.flags["--no-cache"]);
|
|
1444
|
+
const noReindex = parseBooleanFlag("--no-reindex", parsed.flags["--no-reindex"]);
|
|
1445
|
+
(0, spec_1.runSpecValidateCommand)({ root, id, json, noCache, noReindex });
|
|
1446
|
+
return 0;
|
|
1447
|
+
}
|
|
1448
|
+
default:
|
|
1449
|
+
throw new errors_1.UsageError("spec requires list/show/validate");
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1215
1452
|
function runArchiveSubcommand(parsed, root) {
|
|
1216
1453
|
const subcommand = (parsed.positionals[1] ?? "").toLowerCase();
|
|
1217
1454
|
switch (subcommand) {
|
|
@@ -1446,6 +1683,18 @@ function runWorkSubcommand(parsed, root) {
|
|
|
1446
1683
|
const action = (parsed.positionals[2] ?? "").toLowerCase();
|
|
1447
1684
|
const ws = requireFlagValue("--ws", parsed.flags["--ws"]);
|
|
1448
1685
|
const json = parseBooleanFlag("--json", parsed.flags["--json"]);
|
|
1686
|
+
if (domain === "trigger") {
|
|
1687
|
+
const targetRef = parsed.positionals[2];
|
|
1688
|
+
if (!targetRef || parsed.positionals.length > 3) {
|
|
1689
|
+
throw new errors_1.UsageError("work trigger requires <work-or-capability-ref>");
|
|
1690
|
+
}
|
|
1691
|
+
const id = requireFlagValue("--id", parsed.flags["--id"]);
|
|
1692
|
+
const title = requireFlagValue("--title", parsed.flags["--title"]);
|
|
1693
|
+
const requester = requireFlagValue("--requester", parsed.flags["--requester"]);
|
|
1694
|
+
const enqueue = requireFlagValue("--enqueue", parsed.flags["--enqueue"]);
|
|
1695
|
+
(0, work_1.runWorkTriggerCommand)({ root, ws, targetRef, id, title, requester, enqueue, json });
|
|
1696
|
+
return 0;
|
|
1697
|
+
}
|
|
1449
1698
|
if (domain === "contract" && action === "new") {
|
|
1450
1699
|
const title = parsed.positionals.slice(3).join(" ");
|
|
1451
1700
|
const id = requireFlagValue("--id", parsed.flags["--id"]);
|
|
@@ -1482,7 +1731,10 @@ function runWorkSubcommand(parsed, root) {
|
|
|
1482
1731
|
throw new errors_1.UsageError("work order new requires title, --id, --work-id, and --requester");
|
|
1483
1732
|
}
|
|
1484
1733
|
const requestRef = requireFlagValue("--request-ref", parsed.flags["--request-ref"]);
|
|
1734
|
+
const triggerRef = requireFlagValue("--trigger-ref", parsed.flags["--trigger-ref"]);
|
|
1735
|
+
const payloadHash = requireFlagValue("--payload-hash", parsed.flags["--payload-hash"]);
|
|
1485
1736
|
const inputRefs = requireFlagValue("--input-refs", parsed.flags["--input-refs"]);
|
|
1737
|
+
const queueRefs = requireFlagValue("--queue-refs", parsed.flags["--queue-refs"]);
|
|
1486
1738
|
const requestedOutputs = requireFlagValue("--requested-outputs", parsed.flags["--requested-outputs"]);
|
|
1487
1739
|
const constraintRefs = requireFlagValue("--constraint-refs", parsed.flags["--constraint-refs"]);
|
|
1488
1740
|
(0, work_1.runWorkOrderNewCommand)({
|
|
@@ -1493,7 +1745,10 @@ function runWorkSubcommand(parsed, root) {
|
|
|
1493
1745
|
workId,
|
|
1494
1746
|
requester,
|
|
1495
1747
|
requestRef,
|
|
1748
|
+
triggerRef,
|
|
1749
|
+
payloadHash,
|
|
1496
1750
|
inputRefs,
|
|
1751
|
+
queueRefs,
|
|
1497
1752
|
requestedOutputs,
|
|
1498
1753
|
constraintRefs,
|
|
1499
1754
|
json,
|
|
@@ -1507,8 +1762,17 @@ function runWorkSubcommand(parsed, root) {
|
|
|
1507
1762
|
}
|
|
1508
1763
|
const status = requireFlagValue("--status", parsed.flags["--status"]);
|
|
1509
1764
|
const addInputRefs = requireFlagValue("--add-input-refs", parsed.flags["--add-input-refs"]);
|
|
1765
|
+
const addQueueRefs = requireFlagValue("--add-queue-refs", parsed.flags["--add-queue-refs"]);
|
|
1510
1766
|
const addArtifacts = requireFlagValue("--add-artifacts", parsed.flags["--add-artifacts"]);
|
|
1511
|
-
(0, work_1.runWorkOrderUpdateCommand)({ root, ws, id, status, addInputRefs, addArtifacts, json });
|
|
1767
|
+
(0, work_1.runWorkOrderUpdateCommand)({ root, ws, id, status, addInputRefs, addQueueRefs, addArtifacts, json });
|
|
1768
|
+
return 0;
|
|
1769
|
+
}
|
|
1770
|
+
if (domain === "order" && action === "status") {
|
|
1771
|
+
const id = parsed.positionals[3];
|
|
1772
|
+
if (!id || parsed.positionals.length > 4) {
|
|
1773
|
+
throw new errors_1.UsageError("work order status requires <id-or-qid>");
|
|
1774
|
+
}
|
|
1775
|
+
(0, work_1.runWorkOrderStatusCommand)({ root, ws, id, json });
|
|
1512
1776
|
return 0;
|
|
1513
1777
|
}
|
|
1514
1778
|
if (domain === "receipt" && action === "new") {
|
|
@@ -1521,9 +1785,11 @@ function runWorkSubcommand(parsed, root) {
|
|
|
1521
1785
|
}
|
|
1522
1786
|
const receiptStatus = requireFlagValue("--receipt-status", parsed.flags["--receipt-status"]);
|
|
1523
1787
|
const costRef = requireFlagValue("--cost-ref", parsed.flags["--cost-ref"]);
|
|
1788
|
+
const redactionPolicy = requireFlagValue("--redaction-policy", parsed.flags["--redaction-policy"]);
|
|
1524
1789
|
const artifacts = requireFlagValue("--artifacts", parsed.flags["--artifacts"]);
|
|
1525
1790
|
const proofRefs = requireFlagValue("--proof-refs", parsed.flags["--proof-refs"]);
|
|
1526
1791
|
const attestationRefs = requireFlagValue("--attestation-refs", parsed.flags["--attestation-refs"]);
|
|
1792
|
+
const evidenceHashes = requireFlagValue("--evidence-hashes", parsed.flags["--evidence-hashes"]);
|
|
1527
1793
|
const inputHashes = requireFlagValue("--input-hashes", parsed.flags["--input-hashes"]);
|
|
1528
1794
|
const outputHashes = requireFlagValue("--output-hashes", parsed.flags["--output-hashes"]);
|
|
1529
1795
|
(0, work_1.runWorkReceiptNewCommand)({
|
|
@@ -1535,9 +1801,11 @@ function runWorkSubcommand(parsed, root) {
|
|
|
1535
1801
|
outcome,
|
|
1536
1802
|
receiptStatus,
|
|
1537
1803
|
costRef,
|
|
1804
|
+
redactionPolicy,
|
|
1538
1805
|
artifacts,
|
|
1539
1806
|
proofRefs,
|
|
1540
1807
|
attestationRefs,
|
|
1808
|
+
evidenceHashes,
|
|
1541
1809
|
inputHashes,
|
|
1542
1810
|
outputHashes,
|
|
1543
1811
|
json,
|
|
@@ -1553,6 +1821,7 @@ function runWorkSubcommand(parsed, root) {
|
|
|
1553
1821
|
const addArtifacts = requireFlagValue("--add-artifacts", parsed.flags["--add-artifacts"]);
|
|
1554
1822
|
const addProofRefs = requireFlagValue("--add-proof-refs", parsed.flags["--add-proof-refs"]);
|
|
1555
1823
|
const addAttestationRefs = requireFlagValue("--add-attestation-refs", parsed.flags["--add-attestation-refs"]);
|
|
1824
|
+
const addEvidenceHashes = requireFlagValue("--add-evidence-hashes", parsed.flags["--add-evidence-hashes"]);
|
|
1556
1825
|
(0, work_1.runWorkReceiptUpdateCommand)({
|
|
1557
1826
|
root,
|
|
1558
1827
|
ws,
|
|
@@ -1561,10 +1830,19 @@ function runWorkSubcommand(parsed, root) {
|
|
|
1561
1830
|
addArtifacts,
|
|
1562
1831
|
addProofRefs,
|
|
1563
1832
|
addAttestationRefs,
|
|
1833
|
+
addEvidenceHashes,
|
|
1564
1834
|
json,
|
|
1565
1835
|
});
|
|
1566
1836
|
return 0;
|
|
1567
1837
|
}
|
|
1838
|
+
if (domain === "receipt" && action === "verify") {
|
|
1839
|
+
const id = parsed.positionals[3];
|
|
1840
|
+
if (!id || parsed.positionals.length > 4) {
|
|
1841
|
+
throw new errors_1.UsageError("work receipt verify requires <id-or-qid>");
|
|
1842
|
+
}
|
|
1843
|
+
(0, work_1.runWorkReceiptVerifyCommand)({ root, ws, id, json });
|
|
1844
|
+
return 0;
|
|
1845
|
+
}
|
|
1568
1846
|
if (domain === "artifact" && action === "add") {
|
|
1569
1847
|
const targetId = parsed.positionals[3];
|
|
1570
1848
|
const file = parsed.positionals[4];
|
|
@@ -2034,6 +2312,8 @@ function runCommand(parsed, root, runtime) {
|
|
|
2034
2312
|
return runSkillSubcommand(parsed, root);
|
|
2035
2313
|
case "capability":
|
|
2036
2314
|
return runCapabilitySubcommand(parsed, root);
|
|
2315
|
+
case "spec":
|
|
2316
|
+
return runSpecSubcommand(parsed, root);
|
|
2037
2317
|
case "archive":
|
|
2038
2318
|
return runArchiveSubcommand(parsed, root);
|
|
2039
2319
|
case "bundle":
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadCapabilityRecords = loadCapabilityRecords;
|
|
4
|
+
exports.filterCapabilityRecords = filterCapabilityRecords;
|
|
5
|
+
exports.resolveCapabilityRecord = resolveCapabilityRecord;
|
|
3
6
|
exports.runCapabilityListCommand = runCapabilityListCommand;
|
|
4
7
|
exports.runCapabilitySearchCommand = runCapabilitySearchCommand;
|
|
5
8
|
exports.runCapabilityShowCommand = runCapabilityShowCommand;
|
|
@@ -29,7 +32,7 @@ function normalizeVisibility(value) {
|
|
|
29
32
|
}
|
|
30
33
|
throw new errors_1.UsageError(`--visibility must be one of ${capabilities_indexer_1.CAPABILITY_VISIBILITIES.join(", ")}`);
|
|
31
34
|
}
|
|
32
|
-
function
|
|
35
|
+
function loadCapabilityRecords(options) {
|
|
33
36
|
const config = (0, config_1.loadConfig)(options.root);
|
|
34
37
|
const { index, stale, rebuilt } = (0, capabilities_index_cache_1.loadCapabilitiesIndex)({
|
|
35
38
|
root: options.root,
|
|
@@ -46,7 +49,7 @@ function loadRecords(options) {
|
|
|
46
49
|
}
|
|
47
50
|
return [...index.records, ...subgraph.records];
|
|
48
51
|
}
|
|
49
|
-
function
|
|
52
|
+
function filterCapabilityRecords(records, options) {
|
|
50
53
|
const kind = normalizeKind(options.kind);
|
|
51
54
|
const visibility = normalizeVisibility(options.visibility);
|
|
52
55
|
return records.filter((record) => {
|
|
@@ -78,6 +81,7 @@ function capabilitySearchText(record) {
|
|
|
78
81
|
...record.headings.map((heading) => heading.text),
|
|
79
82
|
JSON.stringify(record.spec ?? {}),
|
|
80
83
|
JSON.stringify(record.work ?? {}),
|
|
84
|
+
JSON.stringify(record.linkage ?? {}),
|
|
81
85
|
JSON.stringify(record.skill ?? {}),
|
|
82
86
|
]
|
|
83
87
|
.filter((value) => typeof value === "string" && value.length > 0)
|
|
@@ -117,6 +121,7 @@ function requirementMatch(record, required) {
|
|
|
117
121
|
...record.tags,
|
|
118
122
|
JSON.stringify(record.spec ?? {}),
|
|
119
123
|
JSON.stringify(record.work ?? {}),
|
|
124
|
+
JSON.stringify(record.linkage ?? {}),
|
|
120
125
|
JSON.stringify(record.skill ?? {}),
|
|
121
126
|
]
|
|
122
127
|
.join(" ")
|
|
@@ -199,7 +204,7 @@ function printCapabilityList(records, json, query) {
|
|
|
199
204
|
console.log(`${record.qid} | ${record.kind} | ${record.visibility} | ${label} | ${record.title}`);
|
|
200
205
|
}
|
|
201
206
|
}
|
|
202
|
-
function
|
|
207
|
+
function resolveCapabilityRecord(records, id) {
|
|
203
208
|
const normalized = id.toLowerCase();
|
|
204
209
|
const exact = records.find((record) => record.qid === id || record.id === id);
|
|
205
210
|
if (exact) {
|
|
@@ -233,19 +238,19 @@ function printCapability(record, json) {
|
|
|
233
238
|
console.log(`path: ${record.path}`);
|
|
234
239
|
}
|
|
235
240
|
function runCapabilityListCommand(options) {
|
|
236
|
-
const records =
|
|
241
|
+
const records = filterCapabilityRecords(loadCapabilityRecords(options), options);
|
|
237
242
|
printCapabilityList(records, options.json);
|
|
238
243
|
}
|
|
239
244
|
function runCapabilitySearchCommand(options) {
|
|
240
|
-
const records =
|
|
245
|
+
const records = filterCapabilityRecords(loadCapabilityRecords(options), options).filter((record) => matchesQuery(record, options.query));
|
|
241
246
|
printCapabilityList(records, options.json, options.query);
|
|
242
247
|
}
|
|
243
248
|
function runCapabilityShowCommand(options) {
|
|
244
|
-
const records =
|
|
245
|
-
printCapability(
|
|
249
|
+
const records = loadCapabilityRecords(options);
|
|
250
|
+
printCapability(resolveCapabilityRecord(records, options.id), options.json);
|
|
246
251
|
}
|
|
247
252
|
function runCapabilityResolveCommand(options) {
|
|
248
|
-
const records =
|
|
253
|
+
const records = filterCapabilityRecords(loadCapabilityRecords(options), options);
|
|
249
254
|
const items = resolveCapabilities(records, options).map((record, rank) => ({
|
|
250
255
|
rank: rank + 1,
|
|
251
256
|
score: resolveScore(record, options),
|