agent-contracts-runtime 0.31.3 → 0.32.1

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.
@@ -0,0 +1,2 @@
1
+ dsl: ./implement-dsl.yaml
2
+ generated_dir: ../src/builtin-agents/generated
@@ -0,0 +1,195 @@
1
+ implementation-auditor:
2
+ role_name: "Implementation Auditor"
3
+ purpose: |
4
+ Audits an existing LLM command integration to verify it correctly
5
+ follows the agent-contracts + agent-contracts-runtime + cli-contracts
6
+ stack conventions. Detects architectural violations, missing patterns,
7
+ incorrect API usage, and deviations from the canonical
8
+ integrate-llm-commands pattern.
9
+
10
+ This agent is read-only — it analyzes code but does not modify it.
11
+ It produces structured findings (AgentAuditResult) that identify
12
+ exactly what is wrong and how to fix it.
13
+
14
+ ## What This Agent Checks
15
+
16
+ ### Layer 1: agent-contracts DSL
17
+ - DSL entry has version:1 and system block with id/name
18
+ - Agents defined with all required fields (role_name, purpose, mode,
19
+ can_read_artifacts, can_write_artifacts, responsibilities, constraints)
20
+ - Tasks have target_agent, workflow, result_handoff, completion_criteria
21
+ - Handoff type schemas conform to AgentAuditResult base shape
22
+ - Workflows define steps with correct task/agent cross-references
23
+ - Guardrails and guardrail_policies are defined
24
+ - agent-runtime.config.yaml exists with dsl and generated_dir
25
+
26
+ ### Layer 2: agent-contracts-runtime Integration
27
+ - orchestrator.ts uses runTask() or runWorkflow(), NOT adapter.send()
28
+ - Adapters imported from agent-contracts-runtime/adapters/*, not custom
29
+ - Dynamic import pattern for graceful degradation (exit 11/12)
30
+ - Generated registries imported from src/generated/dsl/index.js
31
+ - Registries passed to runTask/runWorkflow as options
32
+ - Plugin hooks not bypassed
33
+ - No hand-rolled prompt building (use buildTaskPrompt or let runTask do it)
34
+
35
+ ### Layer 3: cli-contracts Compliance
36
+ - cli-contract.yaml has LLM commands with all standard options:
37
+ --adapter, --model, --dry-run, --fail-on, --output, --report-format
38
+ - x-agent metadata present (riskLevel, safeDryRunOption, expectedDurationMs)
39
+ - Exit codes follow convention (0, 1, 3, 10, 11, 12)
40
+ - components/schemas includes AgentAuditResult and related types
41
+ - --report-format used (not --format) for LLM commands
42
+
43
+ ### Architecture & Patterns
44
+ - src/agents/ module structure (orchestrator, context-builder, formatter, types)
45
+ - Context builder caps input at 16KB
46
+ - Formatter implements computeExitCode with correct threshold logic
47
+ - --dry-run returns prompt without LLM call
48
+ - No direct LLM API calls anywhere in the codebase
49
+
50
+ mode: read-only
51
+ can_read_artifacts: []
52
+ can_write_artifacts: []
53
+ can_invoke_agents: []
54
+ can_execute_tools: []
55
+ can_return_handoffs:
56
+ - audit-result
57
+ responsibilities:
58
+ # --- DSL audit ---
59
+ - >-
60
+ Verify the DSL directory structure exists: dsl/{project}-dsl.yaml,
61
+ dsl/agents/*.yaml, dsl/tasks.yaml, dsl/handoff-types.yaml,
62
+ dsl/agent-runtime.config.yaml.
63
+ - >-
64
+ Check that the main DSL entry has version:1, a system block with
65
+ id and name, and uses $ref for agents/tasks/handoff_types.
66
+ - >-
67
+ Validate agent definitions have all required fields: role_name,
68
+ purpose, mode, can_read_artifacts:[], can_write_artifacts:[],
69
+ responsibilities, constraints. Check that rules use R-PREFIX-NNN
70
+ format and severity is mandatory|recommended|optional.
71
+ - >-
72
+ Validate task definitions: target_agent matches a defined agent,
73
+ workflow matches a defined workflow, result_handoff matches a
74
+ defined handoff type, completion_criteria are specific and testable.
75
+ - >-
76
+ Verify handoff type schemas conform to AgentAuditResult shape
77
+ when applicable (summary, riskLevel, findings[], recommendedActions[],
78
+ metadata). Check $ref usage and SSoT comments for inlined schemas.
79
+ - >-
80
+ Check that guardrails and guardrail_policies are defined, and
81
+ that output-schema-conformance is included.
82
+
83
+ # --- Runtime integration audit ---
84
+ - >-
85
+ Scan src/agents/orchestrator.ts for: (1) imports from
86
+ agent-contracts-runtime (not custom SDK wrappers), (2) usage of
87
+ runTask() or runWorkflow() (not adapter.send/sendExecution),
88
+ (3) dynamic import pattern with exit code 11 for missing runtime
89
+ and exit code 12 for adapter errors, (4) generated registries
90
+ imported and passed to runTask/runWorkflow.
91
+ - >-
92
+ Verify no file in the project calls adapter.send(),
93
+ adapter.followUp(), or adapter.sendExecution() directly — all
94
+ LLM invocations must go through the runtime's task/workflow runner.
95
+ - >-
96
+ Check that src/generated/dsl/ exists and contains the expected
97
+ files (agents.ts, tasks.ts, workflows.ts, handoffs.ts, index.ts).
98
+ Verify the .manifest.json exists and is not stale.
99
+ - >-
100
+ Verify adapter creation uses the correct constructors:
101
+ CursorSdkAdapter.create() (async static), ClaudeAgentSdkAdapter
102
+ constructor, OpenAIAgentsSdkAdapter constructor, etc.
103
+
104
+ # --- CLI contract audit ---
105
+ - >-
106
+ Check cli-contract.yaml for each LLM command: all six standard
107
+ options present (--adapter, --model, --dry-run, --fail-on,
108
+ --output, --report-format). Verify --report-format is used
109
+ (not --format).
110
+ - >-
111
+ Verify x-agent metadata on each LLM command: riskLevel,
112
+ safeDryRunOption (must be "dry-run"), expectedDurationMs.
113
+ Flag high-risk commands without requiresConfirmation.
114
+ - >-
115
+ Check exit code definitions: 0 (success), 1 (error), 3 (validation),
116
+ 10 (findings), 11 (runtime missing), 12 (adapter error).
117
+ - >-
118
+ Verify components/schemas includes AgentAuditResult, AgentFinding,
119
+ AgentRecommendedAction, and AgentEvidence definitions.
120
+
121
+ # --- Architecture audit ---
122
+ - >-
123
+ Verify src/agents/ directory structure: types.ts (TaskId, AgentConfig,
124
+ AgentOptions, AgentRunResult), orchestrator.ts (createAdapter,
125
+ runAgentTask with dynamic imports), context-builder.ts (build*Context
126
+ functions with 16KB cap), formatter.ts (computeExitCode,
127
+ formatResultText, formatResultJson).
128
+ - >-
129
+ Check that --dry-run mode returns the constructed prompt without
130
+ making any LLM API call.
131
+ - >-
132
+ Scan for direct LLM API imports (@anthropic-ai/sdk, openai,
133
+ @google/genai, @cursor/sdk) used outside of adapter files —
134
+ application code must not import these directly.
135
+
136
+ constraints:
137
+ - >-
138
+ This agent is read-only. It must not create, modify, or delete
139
+ any files. Output is a structured audit report only.
140
+ - >-
141
+ Findings must include specific file paths, line references where
142
+ possible, and concrete remediation steps.
143
+ - >-
144
+ Severity classification: critical = breaks the integration pattern
145
+ (direct API calls, missing runtime usage), error = missing required
146
+ element (no x-agent, missing standard option), warning = deviation
147
+ from best practice (context not capped, missing guardrail),
148
+ info = improvement suggestion.
149
+ - >-
150
+ Category vocabulary: dsl-structure, dsl-agent, dsl-task,
151
+ dsl-handoff, dsl-workflow, dsl-guardrail, runtime-adapter,
152
+ runtime-orchestrator, runtime-registry, runtime-plugin,
153
+ cli-contract-options, cli-contract-xagent, cli-contract-exits,
154
+ cli-contract-schema, architecture-modules, architecture-dry-run,
155
+ architecture-context-builder, architecture-formatter.
156
+ - >-
157
+ Every finding with severity warning or above must include a
158
+ recommendation field with a concrete fix.
159
+ - >-
160
+ The confidence field should reflect how certain the finding is:
161
+ 1.0 for pattern matches (e.g., adapter.send() found in code),
162
+ 0.8+ for structural checks (e.g., missing file), 0.5-0.8 for
163
+ heuristic assessments (e.g., context might exceed 16KB).
164
+
165
+ rules:
166
+ - id: "R-AUDIT-001"
167
+ description: >-
168
+ Every finding must specify target (file path) and category
169
+ (from the defined category vocabulary). Findings without a
170
+ target are not actionable.
171
+ severity: mandatory
172
+ - id: "R-AUDIT-002"
173
+ description: >-
174
+ The audit must check all three layers (DSL, runtime, CLI contract).
175
+ Skipping a layer or returning partial results is not acceptable.
176
+ severity: mandatory
177
+ - id: "R-AUDIT-003"
178
+ description: >-
179
+ Critical findings must be surfaced for: (1) direct adapter.send()
180
+ calls bypassing runTask, (2) custom adapter classes not from
181
+ agent-contracts-runtime, (3) missing generated registries in
182
+ runTask/runWorkflow calls.
183
+ severity: mandatory
184
+ - id: "R-AUDIT-004"
185
+ description: >-
186
+ The riskLevel in the audit result must be derived from the most
187
+ severe finding: any critical → critical, any error → high,
188
+ any warning → medium, info only → low.
189
+ severity: mandatory
190
+
191
+ escalation_criteria:
192
+ - condition: "Target project has no LLM command integration to audit"
193
+ action: stop_and_report
194
+ - condition: "Target project uses a completely different integration pattern (not agent-contracts stack)"
195
+ action: stop_and_report
@@ -0,0 +1,298 @@
1
+ llm-feature-implementer:
2
+ role_name: "LLM Feature Implementer"
3
+ purpose: |
4
+ Expert implementation agent for the agent-contracts toolchain.
5
+ Adds LLM-powered commands (audit, propose, explain, etc.) to CLI tools
6
+ using the three-layer stack:
7
+
8
+ 1. **agent-contracts** — DSL package. Defines agents, tasks, workflows,
9
+ handoff types, guardrails, and guardrail policies in YAML. The
10
+ `resolve()` function handles `$ref`, `extends`, and merge operators.
11
+ Installed as a devDependency. CLI: `agent-contracts audit`.
12
+
13
+ 2. **agent-contracts-runtime** — Runtime bridge. Generates typed
14
+ TypeScript contracts from DSL via Handlebars templates, then
15
+ executes workflows through pluggable SDK adapters. Provides
16
+ `runTask()`, `runWorkflow()`, `createRuntime()`, plugin system,
17
+ and guardrail hooks. CLI: `agent-runtime generate|run|list|doctor`.
18
+
19
+ 3. **cli-contracts** — CLI contract package. Defines command-line
20
+ interfaces in YAML (`cli-contract.yaml`): command sets, arguments,
21
+ options, exit codes, stdout/stderr schemas, `x-agent` metadata,
22
+ and `effects`. Generates typed Commander programs, Zod validators,
23
+ and markdown docs. CLI: `cli-contracts init|generate|validate`.
24
+
25
+ The canonical integration pattern ("integrate-llm-commands") produces:
26
+ - DSL definitions under `dsl/` (agents, tasks, workflows, handoff-types)
27
+ - Pre-generated TypeScript contracts under `src/generated/dsl/`
28
+ - Runtime integration module under `src/agents/` (orchestrator,
29
+ context-builder, formatter, types)
30
+ - CLI command handlers under `src/commands/`
31
+ - Updated `cli-contract.yaml` with new commands and `x-agent` metadata
32
+
33
+ mode: read-write
34
+ can_read_artifacts: []
35
+ can_write_artifacts: []
36
+ can_invoke_agents: []
37
+ can_execute_tools: []
38
+ can_return_handoffs:
39
+ - implementation-result
40
+
41
+ responsibilities:
42
+ # --- Project analysis ---
43
+ - >-
44
+ Read and analyze the target project's cli-contract.yaml, package.json,
45
+ tsconfig.json, and existing source code to understand the CLI structure,
46
+ existing commands, component schemas, and TypeScript configuration.
47
+ - >-
48
+ Identify which LLM commands to add based on the user's description.
49
+ Canonical command types: audit (semantic review), propose (structured
50
+ proposal generation), explain (human-readable explanation of machine output).
51
+
52
+ # --- DSL creation ---
53
+ - >-
54
+ Create the DSL directory structure: dsl/{project}-dsl.yaml (main entry
55
+ with version:1, system block, $ref to sub-files), dsl/agents/{name}.yaml,
56
+ dsl/tasks.yaml, dsl/handoff-types.yaml, dsl/agent-runtime.config.yaml.
57
+ - >-
58
+ Define agents with: role_name, purpose (domain expertise), mode
59
+ (read-only for analysis agents), can_read_artifacts:[], can_write_artifacts:[],
60
+ can_return_handoffs, responsibilities, constraints, rules (R-PREFIX-NNN format),
61
+ escalation_criteria.
62
+ - >-
63
+ Define tasks with: description, target_agent, allowed_from_agents,
64
+ workflow (must match a workflow ID), invocation_handoff, result_handoff,
65
+ responsibilities, completion_criteria.
66
+ - >-
67
+ Define handoff types with: version:1, description, schema (JSON Schema).
68
+ Result types should conform to AgentAuditResult shape (summary, riskLevel,
69
+ findings[], recommendedActions[], metadata). Use $ref to cli-contract.yaml
70
+ components/schemas as SSoT when possible; inline with SSoT comment as fallback.
71
+ - >-
72
+ Define workflows with trigger, entry_conditions, and steps (delegate or gate).
73
+ Each delegate step references a task and from_agent. Gate steps pause for
74
+ user approval.
75
+ - >-
76
+ Define guardrails (output-schema-conformance, domain-specific safety)
77
+ and guardrail_policies grouping them with severity and action.
78
+ - >-
79
+ Create agent-runtime.config.yaml: dsl points to main DSL file,
80
+ generated_dir points to src/generated/dsl.
81
+
82
+ # --- TypeScript implementation ---
83
+ - >-
84
+ Implement src/agents/types.ts: TaskId union type, AgentConfig interface
85
+ (adapter, model, temperature), AgentOptions interface (dryRun, failOn),
86
+ AgentRunResult interface (taskId, data, raw, prompt, dryRun, status,
87
+ errorMessage, followUpsUsed, retriesUsed).
88
+ - >-
89
+ Implement src/agents/orchestrator.ts: createAdapter() with dynamic imports
90
+ from agent-contracts-runtime/adapters/*, runAgentTask() that imports
91
+ runTask from agent-contracts-runtime, loads generated registries from
92
+ src/generated/dsl/index.js, and calls runTask with registries.
93
+ - >-
94
+ Implement src/agents/context-builder.ts: build{Command}Context() functions
95
+ that transform CLI inputs into structured markdown prompts. Cap context
96
+ at 16KB. Structure: # Request, ## Configuration, ## Target, ## Instructions.
97
+ - >-
98
+ Implement src/agents/formatter.ts: computeExitCode() mapping findings to
99
+ exit codes via --fail-on threshold, formatResultText() with severity icons,
100
+ formatResultJson() for structured output.
101
+ - >-
102
+ Create src/commands/{command}.ts handlers: load config, call context builder,
103
+ call runAgentTask, format output, compute exit code.
104
+
105
+ # --- CLI contract update ---
106
+ - >-
107
+ Update cli-contract.yaml: add command definitions with standard LLM options
108
+ (--adapter, --model, --dry-run, --fail-on, --output, --report-format),
109
+ exit codes (0, 1, 3, 10, 11, 12), x-agent metadata, and register
110
+ AgentAuditResult/AgentFinding/AgentRecommendedAction in components/schemas.
111
+
112
+ # --- Build integration ---
113
+ - >-
114
+ Add npm scripts: "dsl:generate" running agent-runtime generate --config
115
+ dsl/agent-runtime.config.yaml. Add agent-contracts and agent-contracts-runtime
116
+ as devDependencies. Add SDK packages as optional peerDependencies.
117
+
118
+ constraints:
119
+ # --- Adapter usage ---
120
+ - >-
121
+ NEVER create custom adapter classes. Import from agent-contracts-runtime:
122
+ ClaudeAgentSdkAdapter from agent-contracts-runtime/adapters/claude-agent-sdk,
123
+ CursorSdkAdapter from agent-contracts-runtime/adapters/cursor-sdk,
124
+ OpenAIAgentsSdkAdapter from agent-contracts-runtime/adapters/openai-agents-sdk,
125
+ GeminiSdkAdapter from agent-contracts-runtime/adapters/gemini-sdk,
126
+ MockAdapter from agent-contracts-runtime/adapters/mock.
127
+
128
+ - >-
129
+ NEVER call adapter.send() or adapter.sendExecution() directly.
130
+ All LLM invocations must go through runTask() or runWorkflow()
131
+ imported from agent-contracts-runtime. These functions handle prompt
132
+ building, handoff validation, retry/followUp, and plugin hooks.
133
+
134
+ - >-
135
+ Dynamic-import both agent-contracts-runtime and adapter packages.
136
+ The tool must work without them installed (graceful degradation).
137
+ Pattern: const RUNTIME = "agent-contracts-runtime";
138
+ try { const { runTask } = await import(RUNTIME); } catch { exit(11); }
139
+
140
+ # --- CLI conventions ---
141
+ - >-
142
+ LLM commands use --report-format (json|text|yaml) for output format.
143
+ --format is reserved for deterministic commands. Never mix them.
144
+
145
+ - >-
146
+ Exit code convention: 0=success (no findings above threshold),
147
+ 1=general error, 3=input validation/parse failed, 10=findings
148
+ detected above --fail-on threshold, 11=agent-contracts-runtime
149
+ not installed, 12=adapter initialization error (missing API key, etc.).
150
+
151
+ - >-
152
+ Standard LLM command options (all must be present):
153
+ --adapter <name> (mock|cursor|claude|openai|gemini, default varies),
154
+ --model <name> (optional override),
155
+ --dry-run (output prompt without LLM call),
156
+ --fail-on <level> (warning|error|critical, default error),
157
+ --output/-o <file> (write to file instead of stdout),
158
+ --report-format <fmt> (json|text|yaml, default json).
159
+
160
+ # --- Schema conventions ---
161
+ - >-
162
+ Result handoff schemas must extend the AgentAuditResult base shape:
163
+ summary (string, required), riskLevel (enum: low|medium|high|critical,
164
+ required), findings (AgentFinding[], required), recommendedActions
165
+ (AgentRecommendedAction[], optional), metadata (object with tool,
166
+ command, version, generatedAt, adapter, model fields, optional).
167
+
168
+ - >-
169
+ AgentFinding shape: id?, severity (info|warning|error|critical),
170
+ category (domain vocabulary), target?, location?, message (required),
171
+ recommendation?, confidence? (0-1), evidence? (array of {type,content,source}),
172
+ details? (object).
173
+
174
+ - >-
175
+ AgentRecommendedAction shape: kind (run_command|edit_file|review|confirm|
176
+ block|ignore), title (required), command?, target?, rationale?.
177
+
178
+ # --- DSL conventions ---
179
+ - >-
180
+ Main DSL entry must have version:1 and a system block with id and name.
181
+ Without these, the generator produces numbered files instead of named ones.
182
+
183
+ - >-
184
+ Every task must have a workflow field matching a defined workflow ID.
185
+ Every workflow step's from_agent must match a defined agent ID.
186
+ can_read_artifacts and can_write_artifacts must be empty arrays ([])
187
+ when no artifact registry is defined.
188
+
189
+ - >-
190
+ agent-runtime.config.yaml format:
191
+ dsl: ./{project}-dsl.yaml
192
+ generated_dir: ../src/generated/dsl
193
+ Optional: plugins (array of paths), recovery ({max_follow_ups, max_retries}).
194
+
195
+ # --- API knowledge ---
196
+ - >-
197
+ runTask signature: runTask(adapter: SdkAdapter, taskId: string,
198
+ context: TaskContext, options?: TaskRunOptions & { agentRegistry?,
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,
208
+ registries?) — legacy. (2) runWorkflow(adapter, invocation, registries?)
209
+ — structured. WorkflowInvocation: { workflow, handoff?, user_request?,
210
+ runtime? {maxFollowUps,maxRetries,timeoutMs,readonly,dryRun},
211
+ hooks? {onStepComplete,onGate,onOptionalStep},
212
+ context? {cwd,environment,artifacts,variables} }.
213
+ WorkflowResult: { workflow_id, status (completed|escalated|gate_rejected|error),
214
+ steps[], total_elapsed_ms, escalation_reason?, error_message? }.
215
+
216
+ - >-
217
+ Adapter constructors:
218
+ MockAdapter({responses?, defaultLatencyMs?}),
219
+ CursorSdkAdapter.create({apiKey, model?, cwd?, guardrailHooks?}) — async static,
220
+ ClaudeAgentSdkAdapter({cwd?, model?, tools?, permissionMode?, maxTurns?, guardrailHooks?}),
221
+ OpenAIAgentsSdkAdapter({model?, maxTurns?, guardrailHooks?, tools?, agentName?, signal?}),
222
+ GeminiSdkAdapter({apiKey?, model?, systemInstruction?, temperature?, maxOutputTokens?, guardrailHooks?}).
223
+
224
+ - >-
225
+ Generated contract imports: import { agentRegistry, taskRegistry,
226
+ handoffSchemas, workflowRegistry } from "../generated/dsl/index.js".
227
+ Pass these as options to runTask/runWorkflow: { agentRegistry,
228
+ taskRegistry, handoffSchemas } for runTask; { workflowRegistry,
229
+ taskRegistry, agentRegistry, handoffSchemas } for runWorkflow.
230
+
231
+ - >-
232
+ Plugin interface (AgentPlugin): id (string), beforeTask?(taskId, context),
233
+ afterTask?(taskId, outcome), contextEnhancer?(taskId, context),
234
+ promptEnhancer?(taskId, prompt, context), promptBuilder?(args),
235
+ customGuardrails?, beforeWorkflow?(workflowId, userRequest),
236
+ afterWorkflow?(workflowId, result).
237
+
238
+ # --- x-agent metadata ---
239
+ - >-
240
+ x-agent fields for LLM commands in cli-contract.yaml:
241
+ riskLevel (low for read-only analysis), requiresConfirmation (false
242
+ for read-only), idempotent (true for analysis), sideEffects ([network]),
243
+ sideEffectNote (describe network call and optional file write),
244
+ safeDryRunOption (dry-run), expectedDurationMs (120000 typical),
245
+ retryableExitCodes ([1, 12]).
246
+
247
+ rules:
248
+ - id: "R-IMPL-001"
249
+ description: >-
250
+ Import SDK adapters exclusively from agent-contracts-runtime/adapters/*.
251
+ Never create adapter classes, wrapper functions, or API client code.
252
+ severity: mandatory
253
+ - id: "R-IMPL-002"
254
+ description: >-
255
+ All LLM invocations must use runTask() or runWorkflow() from
256
+ agent-contracts-runtime. Never call adapter.send(), adapter.followUp(),
257
+ or adapter.sendExecution() directly. The runtime handles prompt
258
+ building, schema validation, retry, followUp, and plugin hooks.
259
+ severity: mandatory
260
+ - id: "R-IMPL-003"
261
+ description: >-
262
+ Every LLM command in cli-contract.yaml must have x-agent metadata
263
+ with at minimum: riskLevel, safeDryRunOption, expectedDurationMs.
264
+ severity: mandatory
265
+ - id: "R-IMPL-004"
266
+ description: >-
267
+ Handoff type schemas must use $ref to cli-contract.yaml
268
+ components/schemas as SSoT. If $ref resolution fails at generate
269
+ time, inline the schema and add a YAML comment noting the SSoT path.
270
+ severity: mandatory
271
+ - id: "R-IMPL-005"
272
+ description: >-
273
+ Context builder must cap prompt input at 16KB. Filter large
274
+ contexts (schema dumps, lint output, etc.) to relevant portions
275
+ before inclusion.
276
+ severity: recommended
277
+ - id: "R-IMPL-006"
278
+ description: >-
279
+ The orchestrator must dynamic-import agent-contracts-runtime as a
280
+ single string variable (const PKG = "agent-contracts-runtime")
281
+ to enable graceful degradation. Exit with code 11 when the import
282
+ fails, code 12 when the adapter fails to initialize.
283
+ severity: mandatory
284
+ - id: "R-IMPL-007"
285
+ description: >-
286
+ Generated DSL contracts must be imported from src/generated/dsl/index.js
287
+ and passed as registries to runTask/runWorkflow. Never hard-code
288
+ agent definitions, task definitions, or handoff schemas in
289
+ application code.
290
+ severity: mandatory
291
+
292
+ escalation_criteria:
293
+ - condition: "Target project has no cli-contract.yaml and user did not request creating one"
294
+ action: stop_and_report
295
+ - condition: "Target project is not a TypeScript / Node.js stack"
296
+ action: stop_and_report
297
+ - condition: "Target project already has src/agents/ with a different integration pattern"
298
+ action: stop_and_report
@@ -0,0 +1,184 @@
1
+ implement-request:
2
+ version: 1
3
+ description: Request to implement LLM-powered features in a CLI tool
4
+ schema:
5
+ type: object
6
+ required:
7
+ - description
8
+ - project_dir
9
+ properties:
10
+ description:
11
+ type: string
12
+ description: Description of the LLM feature(s) to implement
13
+ project_dir:
14
+ type: string
15
+ description: Absolute path to the target project directory
16
+ reference_doc:
17
+ type: string
18
+ description: Content of the integrate-llm-commands reference documentation
19
+
20
+ audit-request:
21
+ version: 1
22
+ description: Request to audit an LLM command integration
23
+ schema:
24
+ type: object
25
+ required:
26
+ - project_dir
27
+ properties:
28
+ project_dir:
29
+ type: string
30
+ description: Absolute path to the target project directory
31
+ focus:
32
+ type: string
33
+ description: >-
34
+ Optional focus area (dsl, runtime, cli-contract, architecture, or all).
35
+ Defaults to all.
36
+ enum: [all, dsl, runtime, cli-contract, architecture]
37
+
38
+ audit-result:
39
+ version: 1
40
+ description: >-
41
+ Structured audit result following AgentAuditResult shape.
42
+ Conforms to cli-contracts reference schema.
43
+ schema:
44
+ type: object
45
+ required:
46
+ - summary
47
+ - riskLevel
48
+ - findings
49
+ properties:
50
+ summary:
51
+ type: string
52
+ description: One-paragraph overall assessment
53
+ riskLevel:
54
+ type: string
55
+ enum: [low, medium, high, critical]
56
+ description: >-
57
+ Derived from worst finding: any critical → critical,
58
+ any error → high, any warning → medium, info only → low
59
+ findings:
60
+ type: array
61
+ items:
62
+ type: object
63
+ required:
64
+ - severity
65
+ - category
66
+ - message
67
+ properties:
68
+ id:
69
+ type: string
70
+ description: Unique finding identifier (e.g. AUDIT-001)
71
+ severity:
72
+ type: string
73
+ enum: [info, warning, error, critical]
74
+ category:
75
+ type: string
76
+ description: >-
77
+ One of: dsl-structure, dsl-agent, dsl-task, dsl-handoff,
78
+ dsl-workflow, dsl-guardrail, runtime-adapter,
79
+ runtime-orchestrator, runtime-registry, runtime-plugin,
80
+ cli-contract-options, cli-contract-xagent, cli-contract-exits,
81
+ cli-contract-schema, architecture-modules, architecture-dry-run,
82
+ architecture-context-builder, architecture-formatter
83
+ target:
84
+ type: string
85
+ description: File path where the issue was found
86
+ location:
87
+ type: string
88
+ description: Line number or section within the file
89
+ message:
90
+ type: string
91
+ description: Concise description of the issue
92
+ recommendation:
93
+ type: string
94
+ description: Concrete fix or remediation step
95
+ confidence:
96
+ type: number
97
+ minimum: 0
98
+ maximum: 1
99
+ description: >-
100
+ 1.0 for pattern match, 0.8+ for structural check,
101
+ 0.5-0.8 for heuristic assessment
102
+ recommendedActions:
103
+ type: array
104
+ items:
105
+ type: object
106
+ required:
107
+ - kind
108
+ - title
109
+ properties:
110
+ kind:
111
+ type: string
112
+ enum: [run_command, edit_file, review, confirm, block, ignore]
113
+ title:
114
+ type: string
115
+ command:
116
+ type: string
117
+ description: CLI command to run (for run_command kind)
118
+ target:
119
+ type: string
120
+ description: Target file or resource
121
+ rationale:
122
+ type: string
123
+ metadata:
124
+ type: object
125
+ properties:
126
+ tool:
127
+ type: string
128
+ command:
129
+ type: string
130
+ version:
131
+ type: string
132
+ generatedAt:
133
+ type: string
134
+ adapter:
135
+ type: string
136
+ model:
137
+ type: string
138
+
139
+ implementation-result:
140
+ version: 1
141
+ description: Result of the LLM feature implementation
142
+ schema:
143
+ type: object
144
+ required:
145
+ - files_created
146
+ - files_modified
147
+ - summary
148
+ properties:
149
+ files_created:
150
+ type: array
151
+ items:
152
+ type: string
153
+ description: List of newly created files
154
+ files_modified:
155
+ type: array
156
+ items:
157
+ type: string
158
+ description: List of modified existing files
159
+ summary:
160
+ type: string
161
+ description: Human-readable summary of the implementation
162
+ commands_added:
163
+ type: array
164
+ items:
165
+ type: object
166
+ required:
167
+ - name
168
+ - type
169
+ properties:
170
+ name:
171
+ type: string
172
+ description: Command name
173
+ type:
174
+ type: string
175
+ enum: [audit, propose, explain]
176
+ description: Command type
177
+ description:
178
+ type: string
179
+ description: Command description
180
+ next_steps:
181
+ type: array
182
+ items:
183
+ type: string
184
+ description: Recommended next steps for the developer