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.
Files changed (37) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/README.md +40 -15
  3. package/dist/cli.js +293 -13
  4. package/dist/commands/capability.js +13 -8
  5. package/dist/commands/db.js +185 -1
  6. package/dist/commands/format.js +1 -1
  7. package/dist/commands/spec.js +101 -0
  8. package/dist/commands/work.js +569 -20
  9. package/dist/core/project_db_migrations.js +24 -0
  10. package/dist/core/project_db_queue.js +186 -0
  11. package/dist/core/project_db_snapshot.js +28 -3
  12. package/dist/graph/agent_file_types.js +95 -7
  13. package/dist/graph/capabilities_indexer.js +89 -2
  14. package/dist/graph/frontmatter.js +6 -0
  15. package/dist/graph/node.js +8 -2
  16. package/dist/init/AGENT_START.md +15 -9
  17. package/dist/init/CLI_COMMAND_MATRIX.md +33 -5
  18. package/dist/init/README.md +36 -11
  19. package/dist/init/init-manifest.json +64 -9
  20. package/dist/init/skills/default/verify-close-and-checkpoint/SKILL.md +8 -7
  21. package/dist/init/templates/default/receipt.md +12 -1
  22. package/dist/init/templates/default/spec.md +8 -6
  23. package/dist/init/templates/default/work.md +5 -1
  24. package/dist/init/templates/default/work_order.md +11 -0
  25. package/dist/init/templates/skills/base.SKILL.md +66 -0
  26. package/dist/init/templates/specs/agent.SPEC.md +80 -0
  27. package/dist/init/templates/specs/api.SPEC.md +33 -0
  28. package/dist/init/templates/specs/base.SPEC.md +120 -0
  29. package/dist/init/templates/specs/capability.SPEC.md +45 -0
  30. package/dist/init/templates/specs/integration.SPEC.md +25 -0
  31. package/dist/init/templates/specs/model.SPEC.md +21 -0
  32. package/dist/init/templates/specs/project.SPEC.md +39 -0
  33. package/dist/init/templates/specs/runtime-agent.SPEC.md +49 -0
  34. package/dist/init/templates/specs/runtime-image.SPEC.md +21 -0
  35. package/dist/init/templates/specs/tool.SPEC.md +25 -0
  36. package/dist/util/argparse.js +8 -0
  37. package/package.json +5 -2
@@ -0,0 +1,80 @@
1
+ ---
2
+ extends: base.SPEC.md
3
+ template_kind: agent
4
+ spec_kind: agent
5
+ ---
6
+
7
+ # Agent Role
8
+
9
+ Define the durable agent role and trigger conditions.
10
+
11
+ Suggested generic roles:
12
+
13
+ - orchestrator agent.
14
+ - worker agent.
15
+ - reviewer agent.
16
+ - summarizer agent.
17
+ - graph/project agent.
18
+
19
+ # Trigger Conditions
20
+
21
+ - Human request.
22
+ - Graph work item.
23
+ - Queue event.
24
+ - Scheduled check.
25
+ - API or runtime event.
26
+
27
+ # Allowed Resources
28
+
29
+ - Resources the agent may read or write.
30
+
31
+ # Allowed Capabilities
32
+
33
+ - Capability ids and optional generic capability URIs.
34
+
35
+ # Forbidden Actions
36
+
37
+ - Actions this agent must never perform.
38
+
39
+ # Input Context
40
+
41
+ - Required room, goal, task, pack, or queue context.
42
+
43
+ # Output Contract
44
+
45
+ - Required report, patch, receipt, or handoff.
46
+
47
+ # Receipt / Evidence Contract
48
+
49
+ - Attempt, validation, and final evidence requirements.
50
+
51
+ # Queue / Event Semantics
52
+
53
+ - Accepted trigger events.
54
+ - AgentRun claim rules.
55
+ - AttemptReceipt requirements.
56
+ - ValidationReceipt requirements.
57
+ - FinalReceipt requirements.
58
+
59
+ # Single-Writer Policy
60
+
61
+ - The graph, repo, path, branch, queue, or work item key that serializes writes.
62
+
63
+ # Escalation Behavior
64
+
65
+ - When to stop, ask, or return a blocker.
66
+
67
+ # Failure Modes
68
+
69
+ - Ambiguous scope.
70
+ - Conflicting writers.
71
+ - Invalid or stale context.
72
+ - Validation failure.
73
+ - Missing final receipt.
74
+
75
+ # Projection Targets
76
+
77
+ - Tool-specific agent manifest.
78
+ - Future runtime agent manifest.
79
+ - Future workflow/runtime capability object.
80
+ - Future workflow/runtime agent definition.
@@ -0,0 +1,33 @@
1
+ ---
2
+ extends: base.SPEC.md
3
+ template_kind: api
4
+ spec_kind: api
5
+ ---
6
+
7
+ # Service Name
8
+
9
+ API or service identity.
10
+
11
+ # Methods
12
+
13
+ - Method name, request, response, and streaming behavior.
14
+
15
+ # Idempotency
16
+
17
+ - Idempotency keys and replay behavior.
18
+
19
+ # Auth
20
+
21
+ - Required principal, policy, and capability context.
22
+
23
+ # Errors
24
+
25
+ - Error taxonomy and fail-closed behavior.
26
+
27
+ # Versioning
28
+
29
+ - Package/version and compatibility policy.
30
+
31
+ # Conformance Tests
32
+
33
+ - Fixture and integration proof requirements.
@@ -0,0 +1,120 @@
1
+ ---
2
+ id: {{spec_id}}
3
+ type: spec
4
+ title: {{title}}
5
+ version: 0.1.0
6
+ spec_kind: capability
7
+ role: {{role}}
8
+ runtime_mode: {{runtime_mode}}
9
+ work_contracts: []
10
+ requested_capabilities: []
11
+ skill_refs: []
12
+ tool_refs: []
13
+ model_refs: []
14
+ wasm_component_refs: []
15
+ runtime_image_refs: []
16
+ subagent_refs: []
17
+ resource_profile: builder
18
+ update_policy: manual
19
+ tags: [spec]
20
+ owners: []
21
+ links: []
22
+ artifacts: []
23
+ relates: []
24
+ refs: []
25
+ aliases: []
26
+ created: {{created}}
27
+ updated: {{updated}}
28
+ ---
29
+
30
+ # Identity
31
+
32
+ Name, stable id, owner, status, and source mdkg nodes.
33
+
34
+ # Purpose
35
+
36
+ What durable capability or contract this SPEC defines.
37
+
38
+ # Authority Boundary
39
+
40
+ Who or what is allowed to make decisions, mutate state, delegate work, or accept
41
+ evidence under this SPEC.
42
+
43
+ # Resource Boundary
44
+
45
+ Included behavior, resources, paths, graph nodes, queues, services, and
46
+ explicit non-authorities.
47
+
48
+ # Optional Resource URIs
49
+
50
+ - Optional generic draft URI: `resource://...`
51
+ - Optional mdkg draft URI: `mdkg://resource/...`
52
+
53
+ # Capabilities
54
+
55
+ - Capability id:
56
+ - Optional generic draft URI: `capability://...`
57
+ - Optional mdkg draft URI: `mdkg://capability/...`
58
+
59
+ # Queue / Event Semantics
60
+
61
+ - Trigger events accepted:
62
+ - Queue ownership:
63
+ - Retry, ack, fail, and dead-letter expectations:
64
+ - Ordering or idempotency rules:
65
+
66
+ # Single-Writer Policy
67
+
68
+ - Writer key:
69
+ - Allowed write surfaces:
70
+ - Forbidden write surfaces:
71
+ - Conflict handling:
72
+
73
+ # Inputs
74
+
75
+ - Required input contract.
76
+
77
+ # Outputs
78
+
79
+ - Required output or receipt contract.
80
+
81
+ # Receipts / Evidence
82
+
83
+ - Attempt evidence:
84
+ - Validation evidence:
85
+ - Final receipt or closeout evidence:
86
+ - Aggregate checkpoint policy:
87
+
88
+ # Dependencies
89
+
90
+ - Other specs, skills, tools, models, services, or runtime images.
91
+
92
+ # Security / Privacy
93
+
94
+ - Authority, secret, data, and mutation boundaries.
95
+ - No raw secrets, credentials, local auth state, or production controls.
96
+
97
+ # Validation Checks
98
+
99
+ - Commands or review checks.
100
+
101
+ # Closeout Evidence
102
+
103
+ - Evidence required to accept this SPEC or implementation.
104
+
105
+ # Projection Targets
106
+
107
+ - Runtime manifest, package metadata, API contract, tool manifest, or protocol
108
+ projection.
109
+
110
+ # Versioning
111
+
112
+ - Compatibility rules.
113
+
114
+ # Change Policy
115
+
116
+ - Who can change this SPEC and what validation is required.
117
+
118
+ # Open Questions
119
+
120
+ - Decision needed before implementation.
@@ -0,0 +1,45 @@
1
+ ---
2
+ extends: base.SPEC.md
3
+ template_kind: capability
4
+ spec_kind: capability
5
+ ---
6
+
7
+ # Capability Name
8
+
9
+ Stable mdkg capability id.
10
+
11
+ # Optional Capability URI
12
+
13
+ Optional generic URI: `capability://...`
14
+
15
+ Optional mdkg URI: `mdkg://capability/...`
16
+
17
+ # Resource Types
18
+
19
+ - Optional generic resource URI: `resource://...`
20
+ - Optional mdkg resource URI: `mdkg://resource/...`
21
+
22
+ # Allowed Principals
23
+
24
+ - Roles or agents allowed to use this capability.
25
+
26
+ # Required Policy Context
27
+
28
+ - Preconditions, policy refs, scopes, or approval state required before use.
29
+
30
+ # Delegation Rules
31
+
32
+ - Whether and how the capability can be delegated.
33
+
34
+ # Revocation Rules
35
+
36
+ - Conditions that revoke or disable the capability.
37
+
38
+ # Audit Events
39
+
40
+ - Receipts, summaries, or metrics created by use.
41
+
42
+ # Validation Checks
43
+
44
+ - Checks that prove capability use remains inside its authority and resource
45
+ boundaries.
@@ -0,0 +1,25 @@
1
+ ---
2
+ extends: base.SPEC.md
3
+ template_kind: integration
4
+ spec_kind: integration
5
+ ---
6
+
7
+ # Integration Boundary
8
+
9
+ Systems, repos, protocols, and ownership split.
10
+
11
+ # Data Flow
12
+
13
+ - Inputs, outputs, transformations, and receipts.
14
+
15
+ # Failure And Retry
16
+
17
+ - Retry, idempotency, dead-letter, and cleanup policy.
18
+
19
+ # Security
20
+
21
+ - Auth, secret refs, network, and data minimization.
22
+
23
+ # Conformance
24
+
25
+ - Contract tests and fixture expectations.
@@ -0,0 +1,21 @@
1
+ ---
2
+ extends: base.SPEC.md
3
+ template_kind: model
4
+ spec_kind: model
5
+ ---
6
+
7
+ # Model Identity
8
+
9
+ Provider, model id, version, and intended use.
10
+
11
+ # Capabilities
12
+
13
+ - Reasoning, coding, browsing, vision, tool-use, or structured-output needs.
14
+
15
+ # Policy Context
16
+
17
+ - Data classes, retention, privacy, and allowed prompts.
18
+
19
+ # Evaluation Checks
20
+
21
+ - Task families, quality gates, and regression criteria.
@@ -0,0 +1,39 @@
1
+ ---
2
+ extends: base.SPEC.md
3
+ template_kind: project
4
+ spec_kind: project_service
5
+ ---
6
+
7
+ # Project Role
8
+
9
+ Describe the repo/service responsibility and non-authorities.
10
+
11
+ # Canonical Repo
12
+
13
+ - Local path:
14
+ - Remote:
15
+ - Default branch:
16
+
17
+ # Owned Capabilities
18
+
19
+ - Capability ids and optional generic capability URIs.
20
+
21
+ # Project-Agent Boundary
22
+
23
+ - Graph writes owned by this project.
24
+ - Read-only surfaces exposed to parent or sibling orchestrators.
25
+ - Queue/event surfaces accepted from external orchestrators.
26
+
27
+ # Single-Writer Policy
28
+
29
+ - Project writer key.
30
+ - Branch or graph write policy.
31
+ - Accepted receipt before external refresh.
32
+
33
+ # Integration Boundaries
34
+
35
+ - Upstream/downstream repos and APIs.
36
+
37
+ # Validation Checks
38
+
39
+ - Build, test, mdkg, security, and release gates.
@@ -0,0 +1,49 @@
1
+ ---
2
+ extends: agent.SPEC.md
3
+ template_kind: runtime_agent
4
+ spec_kind: runtime_agent
5
+ ---
6
+
7
+ # Queue Ownership
8
+
9
+ - Orchestrator queue and per-agent queue responsibilities.
10
+
11
+ # Trigger Kinds
12
+
13
+ - User message, scheduled job, API event, mdkg queue event, runtime event, or
14
+ internal retry.
15
+
16
+ # Sandbox Requirements
17
+
18
+ - Lease refs, workspace bounds, cleanup, and metering requirements.
19
+
20
+ # SecretGrant Requirements
21
+
22
+ - Opaque refs and allowed consumers only.
23
+
24
+ # Single-Writer Keys
25
+
26
+ - Repo, graph, branch, or room keys that serialize writes.
27
+
28
+ # Receipt Lifecycle
29
+
30
+ - TriggerEvent contract.
31
+ - AgentRun contract.
32
+ - AttemptReceipt contract.
33
+ - ValidationReceipt contract.
34
+ - FinalReceipt contract.
35
+
36
+ # Cancellation And Retry
37
+
38
+ - Cancellation, retry, backoff, dead-letter, and finalization policy.
39
+
40
+ # Telemetry Policy
41
+
42
+ - Aggregate-safe stats and improvement proposals only unless a runtime spec says
43
+ otherwise.
44
+
45
+ # Projection Targets
46
+
47
+ - Local runtime agent manifest.
48
+ - Workflow/runtime protocol manifest.
49
+ - Downstream agent manifest owned outside mdkg canonical source.
@@ -0,0 +1,21 @@
1
+ ---
2
+ extends: base.SPEC.md
3
+ template_kind: runtime_image
4
+ spec_kind: runtime_image
5
+ ---
6
+
7
+ # Runtime Image
8
+
9
+ Image name, digest policy, base image, and supported commands.
10
+
11
+ # Resource Profile
12
+
13
+ - CPU, memory, storage, network, and sandbox assumptions.
14
+
15
+ # Secrets And Mounts
16
+
17
+ - Opaque refs only; no raw secret values.
18
+
19
+ # Conformance Checks
20
+
21
+ - Build, scan, smoke, and cleanup proof.
@@ -0,0 +1,25 @@
1
+ ---
2
+ extends: base.SPEC.md
3
+ template_kind: tool
4
+ spec_kind: tool
5
+ ---
6
+
7
+ # Tool Identity
8
+
9
+ Name, command/API surface, and owner.
10
+
11
+ # Allowed Operations
12
+
13
+ - Operations and parameters.
14
+
15
+ # Required Policy Context
16
+
17
+ - Auth, sandbox, path, network, and secret boundaries.
18
+
19
+ # Failure Modes
20
+
21
+ - Expected errors and retry behavior.
22
+
23
+ # Audit Events
24
+
25
+ - Events or receipts emitted by tool use.
@@ -61,20 +61,28 @@ const VALUE_FLAGS = new Set([
61
61
  "--work-id",
62
62
  "--requester",
63
63
  "--request-ref",
64
+ "--trigger-ref",
65
+ "--payload-hash",
64
66
  "--input-refs",
67
+ "--queue-refs",
65
68
  "--requested-outputs",
66
69
  "--constraint-refs",
70
+ "--add-queue-refs",
71
+ "--enqueue",
67
72
  "--receipt-status",
68
73
  "--work-order-id",
69
74
  "--outcome",
70
75
  "--cost-ref",
76
+ "--redaction-policy",
71
77
  "--proof-refs",
72
78
  "--attestation-refs",
79
+ "--evidence-hashes",
73
80
  "--input-hashes",
74
81
  "--output-hashes",
75
82
  "--add-input-refs",
76
83
  "--add-proof-refs",
77
84
  "--add-attestation-refs",
85
+ "--add-evidence-hashes",
78
86
  "--notes",
79
87
  "--agent",
80
88
  "--skill",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdkg",
3
- "version": "0.1.10",
3
+ "version": "0.3.0",
4
4
  "description": "Markdown Knowledge Graph",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -18,10 +18,13 @@
18
18
  "smoke:capabilities": "npm run build && node scripts/smoke-capabilities.js",
19
19
  "smoke:db": "npm run build && node scripts/smoke-db.js",
20
20
  "smoke:db-queue": "npm run build && node scripts/smoke-db-queue.js",
21
+ "smoke:db-queue-cli": "npm run build && node scripts/smoke-db-queue-cli.js",
21
22
  "smoke:db-events": "npm run build && node scripts/smoke-db-events.js",
22
23
  "smoke:db-materializer": "npm run build && node scripts/smoke-db-materializer.js",
23
24
  "smoke:db-snapshot": "npm run build && node scripts/smoke-db-snapshot.js",
24
25
  "smoke:archive-work": "npm run build && node scripts/smoke-archive-work.js",
26
+ "smoke:work-invocation": "npm run build && node scripts/smoke-work-invocation.js",
27
+ "smoke:cli-ux-polish": "npm run build && node scripts/smoke-cli-ux-polish.js",
25
28
  "smoke:bundle": "npm run build && node scripts/smoke-bundle.js",
26
29
  "smoke:bundle-import": "npm run smoke:subgraph",
27
30
  "smoke:visibility": "npm run build && node scripts/smoke-visibility.js",
@@ -31,7 +34,7 @@
31
34
  "cli:snapshot": "npm run build && node scripts/cli_help_snapshot.js",
32
35
  "cli:check": "npm run build && node scripts/cli_help_snapshot.js --check",
33
36
  "prepack": "npm run build && node scripts/assert-publish-ready.js",
34
- "prepublishOnly": "npm run test && npm run cli:check && node dist/cli.js validate && npm run smoke:consumer && npm run smoke:matrix && npm run smoke:upgrade && npm run smoke:init && npm run smoke:capabilities && npm run smoke:db && npm run smoke:db-queue && npm run smoke:db-events && npm run smoke:db-materializer && npm run smoke:db-snapshot && npm run smoke:archive-work && npm run smoke:bundle && npm run smoke:subgraph && npm run smoke:visibility && npm run smoke:sqlite && npm run smoke:parallel && npm run smoke:goal && node scripts/assert-publish-ready.js",
37
+ "prepublishOnly": "npm run test && npm run cli:check && node dist/cli.js validate && npm run smoke:consumer && npm run smoke:matrix && npm run smoke:upgrade && npm run smoke:init && npm run smoke:capabilities && npm run smoke:db && npm run smoke:db-queue && npm run smoke:db-queue-cli && npm run smoke:db-events && npm run smoke:db-materializer && npm run smoke:db-snapshot && npm run smoke:archive-work && npm run smoke:work-invocation && npm run smoke:cli-ux-polish && npm run smoke:bundle && npm run smoke:subgraph && npm run smoke:visibility && npm run smoke:sqlite && npm run smoke:parallel && npm run smoke:goal && node scripts/assert-publish-ready.js",
35
38
  "postinstall": "node scripts/postinstall.js",
36
39
  "smoke:subgraph": "npm run build && node scripts/smoke-subgraph.js"
37
40
  },