agent-contracts-runtime 0.32.1 → 0.32.2
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/cli-contract.yaml +4 -13
- package/dist/{chunk-NLVQ3OOT.js → chunk-MINIXDVQ.js} +9 -2
- package/dist/chunk-MINIXDVQ.js.map +1 -0
- package/dist/cli/index.js +134 -26
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/docs/cli-reference.md +3 -7
- package/dsl/agents/implementation-auditor.yaml +99 -18
- package/dsl/agents/llm-feature-implementer.yaml +26 -30
- package/dsl/handoff-types.yaml +7 -4
- package/dsl/implement-dsl.yaml +1 -1
- package/dsl/tasks.yaml +164 -22
- package/package.json +2 -1
- package/templates/implement-reference.md +5 -25
- package/dist/chunk-NLVQ3OOT.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -51,6 +51,8 @@ interface WorkflowRunOptions {
|
|
|
51
51
|
maxFollowUps?: number;
|
|
52
52
|
/** Override max full retry attempts per step. Default: from DSL step.max_retries */
|
|
53
53
|
maxRetries?: number;
|
|
54
|
+
/** Variables propagated to every TaskContext in the workflow (from WorkflowInvocation.context). */
|
|
55
|
+
variables?: Record<string, unknown>;
|
|
54
56
|
onGate?: (gateKind: string, description: string, stepResults: StepResult[]) => Promise<boolean>;
|
|
55
57
|
onStepComplete?: (event: StepCompleteEvent) => void;
|
|
56
58
|
onOptionalStep?: (step: DelegateStep, context: TaskContext) => Promise<boolean>;
|
package/dist/index.js
CHANGED
package/docs/cli-reference.md
CHANGED
|
@@ -533,11 +533,7 @@ user-request arguments are read from the file instead of CLI args.
|
|
|
533
533
|
|
|
534
534
|
- **stderr:** format=`text`
|
|
535
535
|
|
|
536
|
-
**Exit
|
|
537
|
-
|
|
538
|
-
- **stderr:** format=`text`
|
|
539
|
-
|
|
540
|
-
**Exit 3:** Generated files outdated. Run `agent-runtime generate` first.
|
|
536
|
+
**Exit 3:** Input validation failed (invalid arguments, unknown workflow/adapter, or generated files outdated).
|
|
541
537
|
|
|
542
538
|
- **stderr:** format=`text`
|
|
543
539
|
|
|
@@ -556,6 +552,7 @@ x-agent:
|
|
|
556
552
|
- sdk_call
|
|
557
553
|
- filesystem_write
|
|
558
554
|
safeDryRunOption: dry-run
|
|
555
|
+
expectedDurationMs: 300000
|
|
559
556
|
recommendedBeforeUse:
|
|
560
557
|
- Run `agent-runtime generate --check` to ensure contracts are up to date.
|
|
561
558
|
- Run `agent-runtime doctor` to verify SDK configuration.
|
|
@@ -783,7 +780,7 @@ Requires an agentic adapter that supports tool use (file read/write).
|
|
|
783
780
|
**Usage:**
|
|
784
781
|
|
|
785
782
|
```
|
|
786
|
-
agent-runtime implement <description> [--adapter] [--project-dir] [--dry-run] [--model] [--
|
|
783
|
+
agent-runtime implement <description> [--adapter] [--project-dir] [--dry-run] [--model] [--output] [--report-format]
|
|
787
784
|
```
|
|
788
785
|
|
|
789
786
|
#### Arguments
|
|
@@ -800,7 +797,6 @@ agent-runtime implement <description> [--adapter] [--project-dir] [--dry-run] [-
|
|
|
800
797
|
| `--project-dir` | -p | No | `"."` | Path to the target project directory. |
|
|
801
798
|
| `--dry-run` | -n | No | `false` | Output the prompt context without calling the LLM. |
|
|
802
799
|
| `--model` | | No | | Model name override for the selected adapter. |
|
|
803
|
-
| `--fail-on` | | No | `"error"` | Minimum finding severity that causes a non-zero exit. |
|
|
804
800
|
| `--output` | -o | No | | Write the result to a file instead of stdout. |
|
|
805
801
|
| `--report-format` | | No | `"text"` | Output format for the result. |
|
|
806
802
|
|
|
@@ -24,13 +24,15 @@ implementation-auditor:
|
|
|
24
24
|
- agent-runtime.config.yaml exists with dsl and generated_dir
|
|
25
25
|
|
|
26
26
|
### Layer 2: agent-contracts-runtime Integration
|
|
27
|
-
- orchestrator.ts uses
|
|
27
|
+
- orchestrator.ts uses runWorkflow(), NOT runTask() or adapter.send()
|
|
28
|
+
- runTask() is a low-level internal API — consumer projects must
|
|
29
|
+
use runWorkflow() which handles workflow DAG, plugin hooks, gates
|
|
28
30
|
- Adapters imported from agent-contracts-runtime/adapters/*, not custom
|
|
29
31
|
- Dynamic import pattern for graceful degradation (exit 11/12)
|
|
30
32
|
- Generated registries imported from src/generated/dsl/index.js
|
|
31
|
-
- Registries passed to
|
|
33
|
+
- Registries (including workflowRegistry) passed to runWorkflow
|
|
32
34
|
- Plugin hooks not bypassed
|
|
33
|
-
- No hand-rolled prompt building (use buildTaskPrompt or let
|
|
35
|
+
- No hand-rolled prompt building (use buildTaskPrompt or let runWorkflow do it)
|
|
34
36
|
|
|
35
37
|
### Layer 3: cli-contracts Compliance
|
|
36
38
|
- cli-contract.yaml has LLM commands with all standard options:
|
|
@@ -47,6 +49,19 @@ implementation-auditor:
|
|
|
47
49
|
- --dry-run returns prompt without LLM call
|
|
48
50
|
- No direct LLM API calls anywhere in the codebase
|
|
49
51
|
|
|
52
|
+
### Semantic Design Coherence
|
|
53
|
+
- Context-builder must contain only domain DATA (file contents,
|
|
54
|
+
config, scan results) — never agent INSTRUCTIONS (evaluation
|
|
55
|
+
criteria, rules, anti-patterns, output format specifications).
|
|
56
|
+
These belong in the DSL agent definition and are injected by
|
|
57
|
+
buildTaskPrompt / runWorkflow. Hardcoding instructions in
|
|
58
|
+
context-builder defeats the purpose of using DSL.
|
|
59
|
+
- Agent mode must match purpose: read-only agents must not have
|
|
60
|
+
write-oriented purposes, read-write agents must propagate cwd
|
|
61
|
+
to their adapter so file tools operate in the project directory.
|
|
62
|
+
- CLI must use cli-contracts' generated CommandHandlers interface
|
|
63
|
+
and createProgram() — not manually wired Commander commands.
|
|
64
|
+
|
|
50
65
|
mode: read-only
|
|
51
66
|
can_read_artifacts: []
|
|
52
67
|
can_write_artifacts: []
|
|
@@ -84,14 +99,16 @@ implementation-auditor:
|
|
|
84
99
|
- >-
|
|
85
100
|
Scan src/agents/orchestrator.ts for: (1) imports from
|
|
86
101
|
agent-contracts-runtime (not custom SDK wrappers), (2) usage of
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
102
|
+
runWorkflow() — NOT runTask() which is a low-level internal API
|
|
103
|
+
that bypasses workflow orchestration, plugin hooks, and gate
|
|
104
|
+
steps, (3) dynamic import pattern with exit code 11 for missing
|
|
105
|
+
runtime and exit code 12 for adapter errors, (4) generated
|
|
106
|
+
registries (including workflowRegistry) imported and passed to
|
|
107
|
+
runWorkflow.
|
|
91
108
|
- >-
|
|
92
109
|
Verify no file in the project calls adapter.send(),
|
|
93
|
-
adapter.followUp(),
|
|
94
|
-
LLM invocations must go through
|
|
110
|
+
adapter.followUp(), adapter.sendExecution(), or runTask()
|
|
111
|
+
directly — all LLM invocations must go through runWorkflow().
|
|
95
112
|
- >-
|
|
96
113
|
Check that src/generated/dsl/ exists and contains the expected
|
|
97
114
|
files (agents.ts, tasks.ts, workflows.ts, handoffs.ts, index.ts).
|
|
@@ -133,6 +150,36 @@ implementation-auditor:
|
|
|
133
150
|
@google/genai, @cursor/sdk) used outside of adapter files —
|
|
134
151
|
application code must not import these directly.
|
|
135
152
|
|
|
153
|
+
# --- Semantic design coherence ---
|
|
154
|
+
- >-
|
|
155
|
+
Audit context-builder for SSoT violations: scan for hardcoded
|
|
156
|
+
agent instructions (sections titled "## Instructions",
|
|
157
|
+
"## Required Patterns", "## Output Format", evaluation criteria,
|
|
158
|
+
checklists, anti-pattern definitions, API references, or output
|
|
159
|
+
schema descriptions). These belong in the DSL agent definition
|
|
160
|
+
and are injected by buildTaskPrompt. Context-builder should
|
|
161
|
+
contain only domain-specific data (file contents, configuration,
|
|
162
|
+
scan results, project metadata).
|
|
163
|
+
- >-
|
|
164
|
+
Check agent mode-purpose coherence: for each agent in the DSL,
|
|
165
|
+
verify that mode: read-only agents do not have purposes or
|
|
166
|
+
responsibilities describing file writing/editing/creation, and
|
|
167
|
+
that mode: read-write agents propagate cwd through AgentConfig
|
|
168
|
+
to the adapter so file tools operate in the correct directory.
|
|
169
|
+
- >-
|
|
170
|
+
Verify cwd propagation: command handlers must set cwd in
|
|
171
|
+
AgentConfig (e.g. process.cwd() or resolve(projectDir)),
|
|
172
|
+
createAdapter must pass cwd to adapter constructors/factories,
|
|
173
|
+
and AgentConfig type must include a cwd field.
|
|
174
|
+
- >-
|
|
175
|
+
Verify cli-contracts handler wiring: if the project uses
|
|
176
|
+
cli-contracts (has src/generated/program.ts or
|
|
177
|
+
src/generated/cli/program.ts exporting CommandHandlers and
|
|
178
|
+
createProgram), the CLI entry point must use
|
|
179
|
+
createProgram(handlers, version) with a handlers object
|
|
180
|
+
implementing the CommandHandlers interface — not manually
|
|
181
|
+
created Commander commands.
|
|
182
|
+
|
|
136
183
|
constraints:
|
|
137
184
|
- >-
|
|
138
185
|
This agent is read-only. It must not create, modify, or delete
|
|
@@ -149,10 +196,13 @@ implementation-auditor:
|
|
|
149
196
|
- >-
|
|
150
197
|
Category vocabulary: dsl-structure, dsl-agent, dsl-task,
|
|
151
198
|
dsl-handoff, dsl-workflow, dsl-guardrail, runtime-adapter,
|
|
152
|
-
runtime-orchestrator, runtime-registry, runtime-
|
|
153
|
-
|
|
154
|
-
cli-contract-
|
|
155
|
-
architecture-
|
|
199
|
+
runtime-orchestrator, runtime-registry, runtime-handler,
|
|
200
|
+
runtime-plugin, cli-contract-options, cli-contract-xagent,
|
|
201
|
+
cli-contract-exits, cli-contract-schema,
|
|
202
|
+
architecture-modules, architecture-dry-run,
|
|
203
|
+
architecture-context-builder, architecture-agent-coherence,
|
|
204
|
+
architecture-adapter-cwd, architecture-handler,
|
|
205
|
+
architecture-formatter.
|
|
156
206
|
- >-
|
|
157
207
|
Every finding with severity warning or above must include a
|
|
158
208
|
recommendation field with a concrete fix.
|
|
@@ -171,15 +221,18 @@ implementation-auditor:
|
|
|
171
221
|
severity: mandatory
|
|
172
222
|
- id: "R-AUDIT-002"
|
|
173
223
|
description: >-
|
|
174
|
-
The audit must check all
|
|
175
|
-
Skipping a layer or returning partial results is
|
|
224
|
+
The audit must check all four layers (DSL, runtime, CLI contract,
|
|
225
|
+
architecture). Skipping a layer or returning partial results is
|
|
226
|
+
not acceptable.
|
|
176
227
|
severity: mandatory
|
|
177
228
|
- id: "R-AUDIT-003"
|
|
178
229
|
description: >-
|
|
179
230
|
Critical findings must be surfaced for: (1) direct adapter.send()
|
|
180
|
-
calls bypassing
|
|
181
|
-
|
|
182
|
-
|
|
231
|
+
calls bypassing runWorkflow, (2) runTask() used instead of
|
|
232
|
+
runWorkflow() — runTask is a low-level internal API that
|
|
233
|
+
bypasses workflow orchestration, (3) custom adapter classes
|
|
234
|
+
not from agent-contracts-runtime, (4) missing generated
|
|
235
|
+
registries in runWorkflow calls.
|
|
183
236
|
severity: mandatory
|
|
184
237
|
- id: "R-AUDIT-004"
|
|
185
238
|
description: >-
|
|
@@ -187,6 +240,34 @@ implementation-auditor:
|
|
|
187
240
|
severe finding: any critical → critical, any error → high,
|
|
188
241
|
any warning → medium, info only → low.
|
|
189
242
|
severity: mandatory
|
|
243
|
+
- id: "R-AUDIT-005"
|
|
244
|
+
description: >-
|
|
245
|
+
Context-builder must be audited for SSoT violations. Any
|
|
246
|
+
hardcoded agent instructions (evaluation criteria, rules,
|
|
247
|
+
anti-patterns, output format specs) in context-builder is a
|
|
248
|
+
critical finding — these belong in the DSL agent definition
|
|
249
|
+
and are injected by buildTaskPrompt / runWorkflow. Context-builder
|
|
250
|
+
may only contain domain-specific data (file contents,
|
|
251
|
+
configuration, scan results, project metadata).
|
|
252
|
+
severity: mandatory
|
|
253
|
+
- id: "R-AUDIT-007"
|
|
254
|
+
description: >-
|
|
255
|
+
runTask() usage in consumer projects is a CRITICAL finding.
|
|
256
|
+
Consumer projects integrating with cli-contracts must use
|
|
257
|
+
runWorkflow() exclusively. runTask() is a low-level internal
|
|
258
|
+
API that bypasses workflow DAG orchestration, workflow-level
|
|
259
|
+
plugin hooks (beforeWorkflow/afterWorkflow), gate steps, and
|
|
260
|
+
step dependencies. Any occurrence of runTask import or call
|
|
261
|
+
in orchestrator, command handler, or CLI entry point code
|
|
262
|
+
must be reported as severity: critical.
|
|
263
|
+
severity: mandatory
|
|
264
|
+
- id: "R-AUDIT-006"
|
|
265
|
+
description: >-
|
|
266
|
+
Agent mode-purpose coherence must be verified. A read-only
|
|
267
|
+
agent whose purpose describes file writing is a critical
|
|
268
|
+
finding because the adapter's tool set (Read/Glob/Grep only)
|
|
269
|
+
makes the stated purpose impossible to fulfil.
|
|
270
|
+
severity: mandatory
|
|
190
271
|
|
|
191
272
|
escalation_criteria:
|
|
192
273
|
- condition: "Target project has no LLM command integration to audit"
|
|
@@ -87,9 +87,11 @@ llm-feature-implementer:
|
|
|
87
87
|
errorMessage, followUpsUsed, retriesUsed).
|
|
88
88
|
- >-
|
|
89
89
|
Implement src/agents/orchestrator.ts: createAdapter() with dynamic imports
|
|
90
|
-
from agent-contracts-runtime/adapters/*,
|
|
91
|
-
|
|
92
|
-
src/generated/dsl/index.js, and calls
|
|
90
|
+
from agent-contracts-runtime/adapters/*, runAgentWorkflow() that imports
|
|
91
|
+
runWorkflow from agent-contracts-runtime, loads generated registries
|
|
92
|
+
(including workflowRegistry) from src/generated/dsl/index.js, and calls
|
|
93
|
+
runWorkflow with registries. NEVER use runTask — it is a low-level
|
|
94
|
+
internal API that bypasses workflow orchestration.
|
|
93
95
|
- >-
|
|
94
96
|
Implement src/agents/context-builder.ts: build{Command}Context() functions
|
|
95
97
|
that transform CLI inputs into structured markdown prompts. Cap context
|
|
@@ -100,7 +102,7 @@ llm-feature-implementer:
|
|
|
100
102
|
formatResultJson() for structured output.
|
|
101
103
|
- >-
|
|
102
104
|
Create src/commands/{command}.ts handlers: load config, call context builder,
|
|
103
|
-
call
|
|
105
|
+
call runAgentWorkflow, format output, compute exit code.
|
|
104
106
|
|
|
105
107
|
# --- CLI contract update ---
|
|
106
108
|
- >-
|
|
@@ -127,15 +129,16 @@ llm-feature-implementer:
|
|
|
127
129
|
|
|
128
130
|
- >-
|
|
129
131
|
NEVER call adapter.send() or adapter.sendExecution() directly.
|
|
130
|
-
All LLM invocations must go through
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
All LLM invocations must go through runWorkflow() imported from
|
|
133
|
+
agent-contracts-runtime. NEVER use runTask() — it is a low-level
|
|
134
|
+
internal API. runWorkflow() handles prompt building, handoff
|
|
135
|
+
validation, retry/followUp, workflow DAG, and plugin hooks.
|
|
133
136
|
|
|
134
137
|
- >-
|
|
135
138
|
Dynamic-import both agent-contracts-runtime and adapter packages.
|
|
136
139
|
The tool must work without them installed (graceful degradation).
|
|
137
140
|
Pattern: const RUNTIME = "agent-contracts-runtime";
|
|
138
|
-
try { const {
|
|
141
|
+
try { const { runWorkflow } = await import(RUNTIME); } catch { exit(11); }
|
|
139
142
|
|
|
140
143
|
# --- CLI conventions ---
|
|
141
144
|
- >-
|
|
@@ -194,24 +197,16 @@ llm-feature-implementer:
|
|
|
194
197
|
|
|
195
198
|
# --- API knowledge ---
|
|
196
199
|
- >-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
taskRegistry?, handoffSchemas?, retry? }): Promise<TaskRunResult>.
|
|
200
|
-
TaskContext: { user_request, prior_context?, relevant_paths?,
|
|
201
|
-
acceptance_criteria?, handoff_input?, variables? }.
|
|
202
|
-
TaskRunResult: { outcome: TaskOutcome, follow_ups_used, retries_used }.
|
|
203
|
-
TaskOutcome: success {data,raw} | validation_error {errors,raw} |
|
|
204
|
-
escalation {reason,raw} | error {message}.
|
|
205
|
-
|
|
206
|
-
- >-
|
|
207
|
-
runWorkflow overloads: (1) runWorkflow(adapter, workflowId, options,
|
|
200
|
+
runWorkflow (the ONLY API consumer projects should use):
|
|
201
|
+
Overloads: (1) runWorkflow(adapter, workflowId, options,
|
|
208
202
|
registries?) — legacy. (2) runWorkflow(adapter, invocation, registries?)
|
|
209
|
-
— structured. WorkflowInvocation: { workflow, handoff?,
|
|
210
|
-
runtime? {maxFollowUps,maxRetries,timeoutMs,readonly,
|
|
211
|
-
hooks? {onStepComplete,onGate,onOptionalStep},
|
|
203
|
+
— structured (preferred). WorkflowInvocation: { workflow, handoff?,
|
|
204
|
+
user_request?, runtime? {maxFollowUps,maxRetries,timeoutMs,readonly,
|
|
205
|
+
dryRun}, hooks? {onStepComplete,onGate,onOptionalStep},
|
|
212
206
|
context? {cwd,environment,artifacts,variables} }.
|
|
213
207
|
WorkflowResult: { workflow_id, status (completed|escalated|gate_rejected|error),
|
|
214
208
|
steps[], total_elapsed_ms, escalation_reason?, error_message? }.
|
|
209
|
+
NEVER use runTask() — it is a low-level internal API.
|
|
215
210
|
|
|
216
211
|
- >-
|
|
217
212
|
Adapter constructors:
|
|
@@ -224,9 +219,8 @@ llm-feature-implementer:
|
|
|
224
219
|
- >-
|
|
225
220
|
Generated contract imports: import { agentRegistry, taskRegistry,
|
|
226
221
|
handoffSchemas, workflowRegistry } from "../generated/dsl/index.js".
|
|
227
|
-
Pass these as
|
|
228
|
-
taskRegistry, handoffSchemas }
|
|
229
|
-
taskRegistry, agentRegistry, handoffSchemas } for runWorkflow.
|
|
222
|
+
Pass these as registries to runWorkflow: { workflowRegistry,
|
|
223
|
+
taskRegistry, agentRegistry, handoffSchemas }.
|
|
230
224
|
|
|
231
225
|
- >-
|
|
232
226
|
Plugin interface (AgentPlugin): id (string), beforeTask?(taskId, context),
|
|
@@ -252,10 +246,12 @@ llm-feature-implementer:
|
|
|
252
246
|
severity: mandatory
|
|
253
247
|
- id: "R-IMPL-002"
|
|
254
248
|
description: >-
|
|
255
|
-
All LLM invocations must use
|
|
256
|
-
agent-contracts-runtime.
|
|
257
|
-
|
|
258
|
-
|
|
249
|
+
All LLM invocations must use runWorkflow() from
|
|
250
|
+
agent-contracts-runtime. NEVER use runTask() — it is a low-level
|
|
251
|
+
internal API that bypasses workflow orchestration. Never call
|
|
252
|
+
adapter.send(), adapter.followUp(), or adapter.sendExecution()
|
|
253
|
+
directly. The runtime handles prompt building, schema validation,
|
|
254
|
+
retry, followUp, workflow DAG, and plugin hooks.
|
|
259
255
|
severity: mandatory
|
|
260
256
|
- id: "R-IMPL-003"
|
|
261
257
|
description: >-
|
|
@@ -284,7 +280,7 @@ llm-feature-implementer:
|
|
|
284
280
|
- id: "R-IMPL-007"
|
|
285
281
|
description: >-
|
|
286
282
|
Generated DSL contracts must be imported from src/generated/dsl/index.js
|
|
287
|
-
and passed as registries to
|
|
283
|
+
and passed as registries to runWorkflow. Never hard-code
|
|
288
284
|
agent definitions, task definitions, or handoff schemas in
|
|
289
285
|
application code.
|
|
290
286
|
severity: mandatory
|
package/dsl/handoff-types.yaml
CHANGED
|
@@ -76,10 +76,13 @@ audit-result:
|
|
|
76
76
|
description: >-
|
|
77
77
|
One of: dsl-structure, dsl-agent, dsl-task, dsl-handoff,
|
|
78
78
|
dsl-workflow, dsl-guardrail, runtime-adapter,
|
|
79
|
-
runtime-orchestrator, runtime-registry, runtime-
|
|
80
|
-
|
|
81
|
-
cli-contract-
|
|
82
|
-
architecture-
|
|
79
|
+
runtime-orchestrator, runtime-registry, runtime-handler,
|
|
80
|
+
runtime-plugin, cli-contract-options, cli-contract-xagent,
|
|
81
|
+
cli-contract-exits, cli-contract-schema,
|
|
82
|
+
architecture-modules, architecture-dry-run,
|
|
83
|
+
architecture-context-builder, architecture-agent-coherence,
|
|
84
|
+
architecture-adapter-cwd, architecture-handler,
|
|
85
|
+
architecture-formatter
|
|
83
86
|
target:
|
|
84
87
|
type: string
|
|
85
88
|
description: File path where the issue was found
|
package/dsl/implement-dsl.yaml
CHANGED
|
@@ -35,7 +35,7 @@ guardrails:
|
|
|
35
35
|
description: >-
|
|
36
36
|
The implementer agent must not generate code that calls LLM APIs
|
|
37
37
|
directly. All LLM invocations must go through agent-contracts-runtime
|
|
38
|
-
|
|
38
|
+
runWorkflow().
|
|
39
39
|
scope:
|
|
40
40
|
agents:
|
|
41
41
|
- llm-feature-implementer
|