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.
- package/README.md +77 -96
- package/cli-contract.yaml +411 -22
- package/dist/{chunk-IAIG5VCJ.js → chunk-W5YWUFAH.js} +7 -3
- package/dist/chunk-W5YWUFAH.js.map +1 -0
- package/dist/cli/index.js +1011 -12
- package/dist/cli/index.js.map +1 -1
- package/dist/generator/index.js +1 -1
- package/docs/cli-reference.md +1370 -216
- package/dsl/agent-runtime.config.yaml +2 -0
- package/dsl/agents/implementation-auditor.yaml +195 -0
- package/dsl/agents/llm-feature-implementer.yaml +298 -0
- package/dsl/handoff-types.yaml +184 -0
- package/dsl/implement-dsl.yaml +119 -0
- package/dsl/tasks.yaml +635 -0
- package/package.json +5 -3
- package/templates/implement-reference-templates.md +823 -0
- package/templates/implement-reference.md +240 -0
- package/templates/workflows.ts.hbs +2 -2
- package/dist/chunk-IAIG5VCJ.js.map +0 -1
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: integrate-llm-commands
|
|
3
|
+
description: >-
|
|
4
|
+
Integrate LLM-powered commands into an existing CLI tool using
|
|
5
|
+
agent-contracts DSL, agent-contracts-runtime SDK adapters, and
|
|
6
|
+
cli-contracts x-agent metadata. Produces agent definitions, typed
|
|
7
|
+
handoff schemas, context builders, orchestrator, formatter, and
|
|
8
|
+
CLI command handlers. Use when adding LLM audit, proposal, or
|
|
9
|
+
explanation commands to a CLI, LLM機能組み込み, エージェント統合,
|
|
10
|
+
Agent-Native Toolchain 化.
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Integrate LLM Commands into a CLI Tool
|
|
14
|
+
|
|
15
|
+
Add LLM-powered commands (audit, propose, explain, etc.) to an existing
|
|
16
|
+
CLI tool using the agent-contracts / agent-contracts-runtime / cli-contracts
|
|
17
|
+
stack.
|
|
18
|
+
|
|
19
|
+
## Prerequisites
|
|
20
|
+
|
|
21
|
+
The target project must already have:
|
|
22
|
+
|
|
23
|
+
- A working CLI (Commander, yargs, or similar)
|
|
24
|
+
- `cli-contract.yaml` (or plan to create one via cli-contracts)
|
|
25
|
+
- Node.js / TypeScript codebase
|
|
26
|
+
|
|
27
|
+
## Workflow
|
|
28
|
+
|
|
29
|
+
### Phase 1: Design LLM commands
|
|
30
|
+
|
|
31
|
+
Identify which LLM commands to add. The canonical pattern has three types:
|
|
32
|
+
|
|
33
|
+
| Type | Purpose | Example |
|
|
34
|
+
|------|---------|---------|
|
|
35
|
+
| **audit** | Semantic review of project artifacts | `audit` — safety review of migrations |
|
|
36
|
+
| **propose** | Generate structured proposals | `propose-expand-contract` — decompose unsafe DDL |
|
|
37
|
+
| **explain** | Human-readable explanation of machine output | `explain` — translate lint/check JSON to prose |
|
|
38
|
+
|
|
39
|
+
For each command, decide:
|
|
40
|
+
- What domain-specific context to provide (files, lint results, schema, config)
|
|
41
|
+
- What structured output schema to return
|
|
42
|
+
- Whether it reads stdin, file arguments, or both
|
|
43
|
+
|
|
44
|
+
### Phase 2: Install dependencies
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm install --save-dev agent-contracts
|
|
48
|
+
npm install --save-dev agent-contracts-runtime zod
|
|
49
|
+
npm install --save-dev @openai/agents @cursor/sdk # adapter SDKs
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Phase 3: Create DSL definitions
|
|
53
|
+
|
|
54
|
+
Create `dsl/` directory with these files. See [reference.md](reference.md)
|
|
55
|
+
for complete templates.
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
dsl/
|
|
59
|
+
├── {project}-dsl.yaml # Main entry: system, agents, tasks, workflows, guardrails
|
|
60
|
+
├── agent-runtime.config.yaml # Points to DSL + generated output dir
|
|
61
|
+
├── agents/{agent-name}.yaml # Agent definition
|
|
62
|
+
├── tasks.yaml # Task definitions
|
|
63
|
+
└── handoff-types.yaml # Request/result schemas
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Key rules:
|
|
67
|
+
- Use `version: 1` and `system:` block in the main DSL
|
|
68
|
+
- **Handoff schemas**: prefer `$ref` to `cli-contract.yaml#/components/schemas/AgentAuditResult` as SSoT. If agent-contracts cannot resolve the `$ref` at generate time, inline the schema with a comment noting the SSoT location. Domain-specific result types (e.g., `ExpandContractProposal`) extend the base `AgentAuditResult` shape with additional fields
|
|
69
|
+
- Keep `can_read_artifacts: []` and `can_write_artifacts: []` to pass validation
|
|
70
|
+
- One agent can serve multiple tasks/workflows if the domain is the same
|
|
71
|
+
- Add guardrails: `output-schema-conformance`, `no-{dangerous-action}`, `confidence-threshold`
|
|
72
|
+
|
|
73
|
+
### Phase 4: Generate TypeScript from DSL
|
|
74
|
+
|
|
75
|
+
Add script to `package.json`:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"scripts": {
|
|
80
|
+
"dsl:generate": "agent-runtime generate --config dsl/agent-runtime.config.yaml"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
npm run dsl:generate
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
This produces `src/generated/dsl/` with typed registries and Zod schemas.
|
|
90
|
+
|
|
91
|
+
### Phase 5: Implement `src/agents/` module
|
|
92
|
+
|
|
93
|
+
Create these files:
|
|
94
|
+
|
|
95
|
+
| File | Responsibility |
|
|
96
|
+
|------|----------------|
|
|
97
|
+
| `types.ts` | `TaskId` union, `AgentConfig`, `AgentOptions`, `AgentRunResult` |
|
|
98
|
+
| `orchestrator.ts` | `createAdapter()`, `runAgentTask()` — dynamic imports of runtime + adapters |
|
|
99
|
+
| `context-builder.ts` | `build{Command}Context()` — transforms CLI input into LLM prompt |
|
|
100
|
+
| `formatter.ts` | `formatResultText()`, `formatResultJson()`, `computeExitCode()` |
|
|
101
|
+
| `index.ts` | Re-exports |
|
|
102
|
+
|
|
103
|
+
Critical implementation details:
|
|
104
|
+
|
|
105
|
+
**orchestrator.ts**:
|
|
106
|
+
- Dynamic-import `agent-contracts-runtime` so the tool works without it installed (graceful degradation)
|
|
107
|
+
- Dynamic-import adapter packages (`/adapters/cursor-sdk`, `/adapters/openai-agents-sdk`, etc.)
|
|
108
|
+
- Import generated DSL registries and pass to `runTask()`
|
|
109
|
+
- Support `--dry-run` by returning the prompt without calling the LLM
|
|
110
|
+
- Use exit codes: 0 = success, 1 = error, 10 = findings, 11 = runtime missing, 12 = adapter error
|
|
111
|
+
|
|
112
|
+
**context-builder.ts**:
|
|
113
|
+
- Build markdown-structured prompts: `# Request Title`, `## Configuration`, `## Target`, `## Instructions`
|
|
114
|
+
- Include project-specific context (lint results, config, related artifacts)
|
|
115
|
+
- Filter large context to relevant portions (e.g., only referenced tables from schema dump)
|
|
116
|
+
- Cap context size (e.g., 16KB) to avoid truncation with smaller models
|
|
117
|
+
|
|
118
|
+
**formatter.ts**:
|
|
119
|
+
- Map severity to icons/prefixes
|
|
120
|
+
- Format findings as structured text with location + recommendation
|
|
121
|
+
- JSON mode outputs raw structured data
|
|
122
|
+
- Exit code based on `--fail-on` threshold vs finding severity
|
|
123
|
+
|
|
124
|
+
### Phase 6: Add CLI command handlers
|
|
125
|
+
|
|
126
|
+
For each LLM command, create `src/commands/{command}.ts`:
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
export async function command{Name}(config, target, opts) {
|
|
130
|
+
const context = await build{Name}Context(target, config);
|
|
131
|
+
const result = await runAgentTask(context, "{task-id}", agentConfig, agentOpts);
|
|
132
|
+
// format + output + exit code
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Register in CLI with the **cli-contracts standard LLM command options**:
|
|
137
|
+
- `--adapter <name>` — LLM adapter (cursor, openai, gemini, claude, mock)
|
|
138
|
+
- `--model <name>` — Model name to pass to the adapter
|
|
139
|
+
- `--dry-run` — Output the prompt context without making an LLM call
|
|
140
|
+
- `--fail-on <level>` — Minimum severity that causes a non-zero exit (warning, error, critical)
|
|
141
|
+
- `--output <file>` / `-o` — Write result to a file instead of stdout
|
|
142
|
+
- `--report-format <fmt>` — Output format for the report (json, text, yaml). Note: LLM commands use `--report-format`, NOT `--format`. `--format` is reserved for core deterministic commands
|
|
143
|
+
|
|
144
|
+
### Phase 7: Update cli-contract.yaml
|
|
145
|
+
|
|
146
|
+
Add `x-agent` metadata to each command:
|
|
147
|
+
|
|
148
|
+
```yaml
|
|
149
|
+
x-agent:
|
|
150
|
+
riskLevel: low|medium|high
|
|
151
|
+
requiresConfirmation: true|false
|
|
152
|
+
idempotent: true|false
|
|
153
|
+
sideEffects: [network]
|
|
154
|
+
sideEffectNote: >-
|
|
155
|
+
Network calls to LLM provider when adapter is not mock.
|
|
156
|
+
Filesystem write only when --output is specified.
|
|
157
|
+
safeDryRunOption: dry-run
|
|
158
|
+
expectedDurationMs: 120000
|
|
159
|
+
retryableExitCodes: [1, 12]
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
For destructive (non-LLM) commands, also add:
|
|
163
|
+
- `reversible: true|false`
|
|
164
|
+
- `rollbackGuidance: "..."` (if not reversible)
|
|
165
|
+
|
|
166
|
+
### Phase 8: Update README
|
|
167
|
+
|
|
168
|
+
Follow this structure — concise mention high up, detailed section after mechanical features:
|
|
169
|
+
|
|
170
|
+
**1. Design Philosophy** — Add an "Agent-native" bullet:
|
|
171
|
+
|
|
172
|
+
> **Agent-native**: Domain-specific semantic reasoning is encapsulated
|
|
173
|
+
> inside the toolchain itself. Higher-level agents do not need to know
|
|
174
|
+
> every {domain-specific rule} — they invoke {tool} and consume
|
|
175
|
+
> structured findings.
|
|
176
|
+
|
|
177
|
+
**2. Commands** — Split into "Deterministic Commands" and "LLM-Powered Commands" subsections. Add safety note under LLM commands:
|
|
178
|
+
|
|
179
|
+
> LLM-powered commands are read-only by default. `audit` and `explain`
|
|
180
|
+
> do not modify files or state. `propose-*` produces a proposal;
|
|
181
|
+
> generated output should be reviewed before use. LLM commands do not
|
|
182
|
+
> replace deterministic gates — they are an additional semantic review
|
|
183
|
+
> layer.
|
|
184
|
+
|
|
185
|
+
**3. CI Integration** — Add commented-out optional audit step in workflow YAML.
|
|
186
|
+
|
|
187
|
+
**4. Agent-Native Toolchain** (after Comparison / mechanical features) — Include these subsections:
|
|
188
|
+
|
|
189
|
+
- **Intro**: "{Tool} is designed for development workflows where AI agents are first-class participants. It encapsulates domain-specific semantic reasoning inside the toolchain itself, returning structured results that humans, CI systems, and AI agents consume in the same way."
|
|
190
|
+
- **Deterministic checks first**
|
|
191
|
+
- **Semantic audit inside the toolchain** — list each LLM command and what domain reasoning it performs
|
|
192
|
+
- **Structured findings** — "Results conform to typed schemas such as `{ProjectResult}`. Audit-style results are compatible with the common `AgentAuditResult` / `AgentFinding` shape so that higher-level workflow agents can aggregate findings across toolchains."
|
|
193
|
+
- **Tool-owned domain knowledge**
|
|
194
|
+
- **Agent-readable interface** — reference cli-contract.yaml
|
|
195
|
+
- **LLM Adapter Configuration** — table with "runtime default" (not pinned model names), `--model` for pinning
|
|
196
|
+
|
|
197
|
+
**5. Technology Stack** — Add agent-contracts-runtime, agent-contracts, cli-contracts rows.
|
|
198
|
+
|
|
199
|
+
### Phase 9: Validate
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
npm run build
|
|
203
|
+
npm test
|
|
204
|
+
npx {tool} {llm-command} --dry-run # verify prompt construction
|
|
205
|
+
npx {tool} {llm-command} --adapter mock # verify with mock adapter
|
|
206
|
+
npx {tool} {llm-command} --adapter openai # real LLM test
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Run `agent-contracts audit --config {project}-audit.config.yaml` to validate DSL completeness.
|
|
210
|
+
|
|
211
|
+
## Adapter Reference
|
|
212
|
+
|
|
213
|
+
| Adapter | Import path | Required env var | Constructor |
|
|
214
|
+
|---------|-------------|------------------|-------------|
|
|
215
|
+
| mock | `/adapters/mock` | — | `new MockAdapter()` |
|
|
216
|
+
| cursor | `/adapters/cursor-sdk` | `CURSOR_API_KEY` | `CursorSdkAdapter.create({apiKey, model})` |
|
|
217
|
+
| openai | `/adapters/openai-agents-sdk` | `OPENAI_API_KEY` | `new OpenAIAgentsSdkAdapter({model, maxTurns})` |
|
|
218
|
+
| gemini | `/adapters/gemini-sdk` | `GEMINI_API_KEY` | `new GeminiSdkAdapter({apiKey, model, temperature})` |
|
|
219
|
+
| claude | `/adapters/claude-agent-sdk` | `ANTHROPIC_API_KEY` | `new ClaudeAgentSdkAdapter({model, tools, permissionMode})` |
|
|
220
|
+
|
|
221
|
+
## Exit Code Convention
|
|
222
|
+
|
|
223
|
+
| Code | Meaning |
|
|
224
|
+
|------|---------|
|
|
225
|
+
| 0 | Success (no findings above threshold) |
|
|
226
|
+
| 1 | General error |
|
|
227
|
+
| 3 | Input validation / parse failed |
|
|
228
|
+
| 10 | Findings detected above `--fail-on` threshold |
|
|
229
|
+
| 11 | `agent-contracts-runtime` not installed |
|
|
230
|
+
| 12 | Adapter initialization error (missing API key, etc.) |
|
|
231
|
+
|
|
232
|
+
## Common Pitfalls
|
|
233
|
+
|
|
234
|
+
- **$ref resolution in handoff-types.yaml**: agent-contracts may not resolve `$ref` to external files like `cli-contract.yaml` at generate time. Prefer `$ref` (as cli-contracts does), but fall back to inlining with a comment noting the SSoT location
|
|
235
|
+
- **`--format` vs `--report-format`**: LLM commands use `--report-format` (json/text/yaml). `--format` is for core deterministic commands only. Do not mix them
|
|
236
|
+
- **Large context → truncation**: Filter context to relevant portions; cap at 16KB
|
|
237
|
+
- **Missing `version: 1` + `system:` block**: DSL generator produces numbered files instead of named ones
|
|
238
|
+
- **`can_read_artifacts` referencing non-existent IDs**: Keep empty `[]` if no artifact registry is defined
|
|
239
|
+
- **Missing workflows for tasks**: Every task needs a `workflow:` field; define all workflows in the main DSL
|
|
240
|
+
- **Handoff schema drift**: Domain-specific result types must extend the base `AgentAuditResult` shape (summary, riskLevel, findings, recommendedActions, metadata). Add domain fields alongside, not replacing base fields
|
|
@@ -41,7 +41,7 @@ export const {{varName}}: WorkflowContract = {
|
|
|
41
41
|
description: {{{json description}}},
|
|
42
42
|
optional: {{optional}},
|
|
43
43
|
max_retries: {{max_retries}},
|
|
44
|
-
{{#if
|
|
44
|
+
{{#if (hasDependsOn this)}}
|
|
45
45
|
depends_on: {{{json depends_on}}},
|
|
46
46
|
{{/if}}
|
|
47
47
|
},
|
|
@@ -51,7 +51,7 @@ export const {{varName}}: WorkflowContract = {
|
|
|
51
51
|
type: "gate",
|
|
52
52
|
gate_kind: "{{gate_kind}}",
|
|
53
53
|
description: {{{json description}}},
|
|
54
|
-
{{#if
|
|
54
|
+
{{#if (hasDependsOn this)}}
|
|
55
55
|
depends_on: {{{json depends_on}}},
|
|
56
56
|
{{/if}}
|
|
57
57
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/generator/index.ts","../src/generator/config.ts","../src/generator/template-engine.ts","../src/generator/context.ts"],"sourcesContent":["/**\n * Generator — orchestrates DSL-to-TypeScript code generation\n */\n\nimport { readFile, writeFile, mkdir, rm, stat } from \"node:fs/promises\";\nimport { resolve, join, relative } from \"node:path\";\nimport { createHash } from \"node:crypto\";\nimport YAML from \"yaml\";\nimport { loadConfig, type ResolvedConfig } from \"./config.js\";\nimport { renderTemplate } from \"./template-engine.js\";\nimport { buildContractContext, buildGuardrailContext } from \"./context.js\";\n\nexport interface GenerateOptions {\n clean?: boolean;\n check?: boolean;\n templates?: string;\n configPath?: string;\n}\n\nexport interface GenerateResult {\n files_generated: string[];\n dsl_hash: string;\n generation_input_hash: string;\n cleaned: boolean;\n check_mode: boolean;\n has_differences: boolean;\n}\n\nconst DO_NOT_EDIT_HEADER = `/**\n * AUTO-GENERATED by agent-contracts-runtime. DO NOT EDIT.\n *\n * Regenerate via: npx agent-runtime generate\n */\n\n`;\n\nasync function loadYaml(filePath: string): Promise<unknown> {\n const raw = await readFile(filePath, \"utf8\");\n return YAML.parse(raw);\n}\n\nfunction computeHash(data: string): string {\n return createHash(\"sha256\").update(data).digest(\"hex\");\n}\n\nfunction sortDeep(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(sortDeep);\n if (value !== null && typeof value === \"object\") {\n return Object.fromEntries(\n Object.entries(value as Record<string, unknown>)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => [k, sortDeep(v)]),\n );\n }\n return value;\n}\n\nfunction canonicalStringify(obj: unknown): string {\n return JSON.stringify(sortDeep(obj));\n}\n\n/**\n * Load DSL via agent-contracts resolve() which handles extends, merge\n * operators ($replace/$append), and $ref resolution including\n * file.yaml#/json-pointer fragments.\n */\nasync function loadDsl(dslPath: string): Promise<Record<string, unknown>> {\n const { resolve: resolveDsl } = await import(\"agent-contracts\");\n const result = await resolveDsl(dslPath);\n return result.data;\n}\n\nconst CONTRACT_TEMPLATES = [\n { template: \"agents.ts.hbs\", output: \"agents.ts\" },\n { template: \"tasks.ts.hbs\", output: \"tasks.ts\" },\n { template: \"workflows.ts.hbs\", output: \"workflows.ts\" },\n { template: \"handoffs.ts.hbs\", output: \"handoffs.ts\" },\n { template: \"contracts-index.ts.hbs\", output: \"index.ts\" },\n];\n\nconst GUARDRAIL_TEMPLATES = [\n { template: \"guardrails.ts.hbs\", output: \"hooks/guardrails.ts\" },\n { template: \"hooks-index.ts.hbs\", output: \"hooks/index.ts\" },\n];\n\nexport async function generate(options: GenerateOptions = {}): Promise<GenerateResult> {\n const configPath = options.configPath ?? \"./agent-runtime.config.yaml\";\n const config = await loadConfig(configPath);\n\n const templatesDir = options.templates ?? config.templatesDir;\n const checkMode = options.check ?? false;\n const cleaned = options.clean ?? false;\n\n if (cleaned && !checkMode) {\n try {\n await rm(config.generatedDir, { recursive: true, force: true });\n } catch {\n // directory may not exist\n }\n }\n\n const dsl = await loadDsl(config.dslPath);\n const dslCanonical = canonicalStringify(dsl);\n const dslHash = computeHash(dslCanonical);\n\n const contractCtx = buildContractContext(dsl);\n\n const files_generated: string[] = [];\n const generatedContents: Map<string, string> = new Map();\n\n // Phase 1: Contract files\n for (const { template, output } of CONTRACT_TEMPLATES) {\n const rendered = DO_NOT_EDIT_HEADER + await renderTemplate(template, contractCtx as unknown as Record<string, unknown>, templatesDir);\n const outPath = join(config.generatedDir, output);\n files_generated.push(relative(config.configDir, outPath));\n generatedContents.set(outPath, rendered);\n }\n\n // Phase 2: Guardrail hooks (only if bindings are configured)\n if (config.bindingPaths.length > 0) {\n for (const bindingPath of config.bindingPaths) {\n const binding = await loadYaml(bindingPath);\n const guardrailCtx = buildGuardrailContext(\n dsl,\n binding,\n config.active_guardrail_policy,\n );\n\n if (guardrailCtx.hasGuardrails) {\n for (const { template, output } of GUARDRAIL_TEMPLATES) {\n const rendered = DO_NOT_EDIT_HEADER + await renderTemplate(\n template,\n guardrailCtx as unknown as Record<string, unknown>,\n templatesDir,\n );\n const outPath = join(config.generatedDir, output);\n files_generated.push(relative(config.configDir, outPath));\n generatedContents.set(outPath, rendered);\n }\n }\n }\n }\n\n // Compute generation input hash (DSL + binding + generator version)\n const generationInputParts = [dslCanonical];\n for (const bp of config.bindingPaths) {\n try {\n generationInputParts.push(await readFile(bp, \"utf8\"));\n } catch {\n // binding may not exist\n }\n }\n const generation_input_hash = computeHash(generationInputParts.join(\"\\n---\\n\"));\n\n // Check mode — compare without writing\n let has_differences = false;\n if (checkMode) {\n for (const [outPath, content] of generatedContents) {\n try {\n const existing = await readFile(outPath, \"utf8\");\n if (existing !== content) {\n has_differences = true;\n break;\n }\n } catch {\n has_differences = true;\n break;\n }\n }\n } else {\n // Write files\n for (const [outPath, content] of generatedContents) {\n const dir = resolve(outPath, \"..\");\n await mkdir(dir, { recursive: true });\n await writeFile(outPath, content, \"utf8\");\n }\n\n // Write manifest\n const manifest = {\n generated_at: new Date().toISOString(),\n dsl_hash: dslHash,\n generation_input_hash,\n files: files_generated,\n };\n const manifestPath = join(config.generatedDir, \".manifest.json\");\n await mkdir(resolve(manifestPath, \"..\"), { recursive: true });\n await writeFile(manifestPath, JSON.stringify(manifest, null, 2) + \"\\n\", \"utf8\");\n }\n\n return {\n files_generated,\n dsl_hash: dslHash,\n generation_input_hash,\n cleaned,\n check_mode: checkMode,\n has_differences,\n };\n}\n\nexport async function checkFreshness(configPath?: string): Promise<boolean> {\n const config = await loadConfig(configPath ?? \"./agent-runtime.config.yaml\");\n const manifestPath = join(config.generatedDir, \".manifest.json\");\n\n try {\n const raw = await readFile(manifestPath, \"utf8\");\n const manifest = JSON.parse(raw) as { dsl_hash: string };\n\n const dsl = await loadDsl(config.dslPath);\n const dslCanonical = canonicalStringify(dsl);\n const currentHash = computeHash(dslCanonical);\n\n return manifest.dsl_hash === currentHash;\n } catch {\n return false;\n }\n}\n\nexport { loadConfig, type ResolvedConfig } from \"./config.js\";\nexport { buildContractContext, buildGuardrailContext } from \"./context.js\";\n","/**\n * Generator configuration — loads and validates agent-runtime.config.yaml\n */\n\nimport { readFile } from \"node:fs/promises\";\nimport { resolve, dirname } from \"node:path\";\nimport { z } from \"zod\";\nimport YAML from \"yaml\";\n\nconst RecoverySchema = z.object({\n max_follow_ups: z.number().int().min(0).default(2),\n max_retries: z.number().int().min(0).default(0),\n}).default(() => ({ max_follow_ups: 2, max_retries: 0 }));\n\nexport const RuntimeConfigSchema = z.object({\n dsl: z.string().default(\"./agent-contracts.yaml\"),\n generated_dir: z.string().default(\"./agent/generated\"),\n bindings: z.array(z.string()).default([]),\n active_guardrail_policy: z.string().optional(),\n templates_dir: z.string().optional(),\n plugins: z.array(z.string()).default([]),\n recovery: RecoverySchema,\n});\n\nexport type RuntimeConfig = z.infer<typeof RuntimeConfigSchema>;\n\nexport interface ResolvedConfig extends RuntimeConfig {\n configDir: string;\n dslPath: string;\n generatedDir: string;\n bindingPaths: string[];\n templatesDir: string | undefined;\n pluginPaths: string[];\n}\n\nexport async function loadConfig(configPath: string): Promise<ResolvedConfig> {\n const absPath = resolve(configPath);\n const raw = await readFile(absPath, \"utf8\");\n const parsed = YAML.parse(raw);\n const config = RuntimeConfigSchema.parse(parsed);\n const configDir = dirname(absPath);\n\n return {\n ...config,\n configDir,\n dslPath: resolve(configDir, config.dsl),\n generatedDir: resolve(configDir, config.generated_dir),\n bindingPaths: config.bindings.map((b) => resolve(configDir, b)),\n templatesDir: config.templates_dir\n ? resolve(configDir, config.templates_dir)\n : undefined,\n pluginPaths: config.plugins,\n };\n}\n","/**\n * Handlebars template engine with custom helpers for TypeScript code generation\n */\n\nimport { readFile } from \"node:fs/promises\";\nimport { resolve, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport Handlebars from \"handlebars\";\n\nimport { existsSync } from \"node:fs\";\n\nconst __dirname = fileURLToPath(new URL(\".\", import.meta.url));\n\nfunction findPackageRoot(): string {\n let dir = __dirname;\n for (let i = 0; i < 5; i++) {\n if (existsSync(join(dir, \"package.json\"))) return dir;\n dir = resolve(dir, \"..\");\n }\n return resolve(__dirname, \"..\");\n}\n\nconst BUILTIN_TEMPLATES_DIR = join(findPackageRoot(), \"templates\");\n\nfunction toCamelCase(str: string): string {\n return str.replace(/-([a-z])/g, (_, c: string) => c.toUpperCase());\n}\n\nfunction toPascalCase(str: string): string {\n const camel = toCamelCase(str);\n return camel.charAt(0).toUpperCase() + camel.slice(1);\n}\n\nconst hbs = Handlebars.create();\n\nhbs.registerHelper(\"camelCase\", (str: string) => toCamelCase(str));\nhbs.registerHelper(\"PascalCase\", (str: string) => toPascalCase(str));\n\nhbs.registerHelper(\"eq\", (a: unknown, b: unknown) => a === b);\nhbs.registerHelper(\"notEmpty\", (arr: unknown) =>\n Array.isArray(arr) ? arr.length > 0 : !!arr,\n);\n\nhbs.registerHelper(\"json\", (value: unknown) =>\n new Handlebars.SafeString(JSON.stringify(value, null, 2)),\n);\n\nhbs.registerHelper(\"jsonInline\", (value: unknown) =>\n new Handlebars.SafeString(JSON.stringify(value)),\n);\n\nhbs.registerHelper(\"indent\", (text: string, spaces: number) => {\n if (typeof text !== \"string\") return text;\n const pad = \" \".repeat(spaces);\n return text\n .split(\"\\n\")\n .map((line, i) => (i === 0 ? line : pad + line))\n .join(\"\\n\");\n});\n\nhbs.registerHelper(\"zodType\", function zodType(schema: Record<string, unknown>): string {\n if (!schema || typeof schema !== \"object\") return \"z.unknown()\";\n\n if (schema.enum) {\n const vals = (schema.enum as string[]).map((v) => `\"${v}\"`).join(\", \");\n return `z.enum([${vals}])`;\n }\n\n if (schema.const !== undefined) {\n return `z.literal(${JSON.stringify(schema.const)})`;\n }\n\n const type = schema.type as string | undefined;\n\n if (type === \"string\") return \"z.string()\";\n if (type === \"number\" || type === \"integer\") return \"z.number()\";\n if (type === \"boolean\") return \"z.boolean()\";\n\n if (type === \"array\") {\n const items = schema.items as Record<string, unknown> | undefined;\n const inner = items ? zodType(items) : \"z.unknown()\";\n return `z.array(${inner})`;\n }\n\n if (type === \"object\") {\n const props = schema.properties as Record<string, Record<string, unknown>> | undefined;\n if (!props) return \"z.record(z.string(), z.unknown())\";\n\n const required = (schema.required as string[]) ?? [];\n const fields = Object.entries(props)\n .map(([key, val]) => {\n const base = zodType(val);\n const opt = required.includes(key) ? \"\" : \".optional()\";\n const safeKey = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key) ? key : `\"${key}\"`;\n return ` ${safeKey}: ${base}${opt},`;\n })\n .join(\"\\n\");\n return `z.object({\\n${fields}\\n})`;\n }\n\n if (schema.allOf) {\n const parts = (schema.allOf as Record<string, unknown>[]).map(zodType);\n if (parts.length === 1) return parts[0];\n return parts.reduce((acc, part) => `${acc}.extend(${part}.shape)`);\n }\n\n return \"z.unknown()\";\n});\n\nhbs.registerHelper(\"regexEscape\", (str: string) => {\n if (typeof str !== \"string\") return str;\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n});\n\nhbs.registerHelper(\"stringArray\", (arr: unknown) => {\n if (!Array.isArray(arr)) return \"[]\";\n return \"[\" + arr.map((s) => `\"${s}\"`).join(\", \") + \"]\";\n});\n\n/**\n * Load a template by name, with custom dir override fallback to built-in.\n */\nasync function loadTemplate(\n name: string,\n customDir?: string,\n): Promise<string> {\n if (customDir) {\n try {\n return await readFile(join(customDir, name), \"utf8\");\n } catch {\n // fallback to built-in\n }\n }\n return readFile(join(BUILTIN_TEMPLATES_DIR, name), \"utf8\");\n}\n\nexport async function renderTemplate(\n name: string,\n context: Record<string, unknown>,\n customDir?: string,\n): Promise<string> {\n const source = await loadTemplate(name, customDir);\n const compiled = hbs.compile(source, { noEscape: true });\n return compiled(context);\n}\n\nexport { hbs, toCamelCase, toPascalCase };\n","/**\n * Build template contexts from resolved DSL data\n */\n\nimport { toCamelCase, toPascalCase } from \"./template-engine.js\";\n\nexport interface AgentEntry {\n id: string;\n varName: string;\n role_name: string;\n purpose: string;\n mode: string;\n dispatch_only: boolean;\n can_read_artifacts: string[];\n can_write_artifacts: string[];\n can_execute_tools: string[];\n can_invoke_agents: string[];\n can_return_handoffs: string[];\n responsibilities: string[];\n constraints: string[];\n rules: Array<{ id: string; description: string; severity: string }>;\n escalation_criteria: Array<{ condition: string; action: string }>;\n}\n\nexport interface TaskEntry {\n id: string;\n varName: string;\n description: string;\n target_agent: string;\n allowed_from_agents: string[];\n workflow: string;\n invocation_handoff: string;\n result_handoff: string;\n input_artifacts: string[];\n responsibilities: string[];\n completion_criteria: string[];\n optional: boolean;\n}\n\nexport interface WorkflowStepEntry {\n type: string;\n task?: string;\n from_agent?: string;\n description?: string;\n optional?: boolean;\n max_retries?: number;\n max_follow_ups?: number;\n depends_on?: string[];\n gate_kind?: string;\n retry?: { condition: string; fix_task: string; revalidate_task?: string };\n}\n\nexport interface WorkflowEntry {\n id: string;\n varName: string;\n description: string;\n trigger: string;\n entry_conditions: string[];\n steps: WorkflowStepEntry[];\n}\n\nexport interface HandoffEntry {\n id: string;\n varName: string;\n pascalName: string;\n schemaName: string;\n description: string;\n schema: Record<string, unknown>;\n}\n\nexport interface ContractContext {\n agentEntries: AgentEntry[];\n taskEntries: TaskEntry[];\n workflowEntries: WorkflowEntry[];\n handoffEntries: HandoffEntry[];\n}\n\n/**\n * Determine if a task is optional by checking if any workflow step referencing it is optional.\n */\nfunction isTaskOptional(\n taskId: string,\n workflows: Record<string, { steps: Array<{ type: string; task?: string; optional?: boolean }> }>,\n): boolean {\n for (const wf of Object.values(workflows)) {\n for (const step of wf.steps) {\n if (step.type === \"delegate\" && step.task === taskId && step.optional) {\n return true;\n }\n }\n }\n return false;\n}\n\n/**\n * Compute max_retries from workflow step or fallback to 0.\n */\nfunction getMaxRetries(\n taskId: string,\n workflows: Record<string, { steps: Array<Record<string, unknown>> }>,\n): number {\n for (const wf of Object.values(workflows)) {\n for (const step of wf.steps) {\n if (step.type === \"delegate\" && step.task === taskId) {\n const retry = step.retry as { condition: string } | undefined;\n return retry ? 1 : 0;\n }\n }\n }\n return 0;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function buildContractContext(dsl: any): ContractContext {\n const agents = (dsl.agents ?? {}) as Record<string, Record<string, unknown>>;\n const tasks = (dsl.tasks ?? {}) as Record<string, Record<string, unknown>>;\n const workflows = (dsl.workflow ?? {}) as Record<string, Record<string, unknown>>;\n const handoffTypes = (dsl.handoff_types ?? {}) as Record<string, Record<string, unknown>>;\n\n const agentEntries: AgentEntry[] = Object.entries(agents).map(([id, agent]) => ({\n id,\n varName: toCamelCase(id),\n role_name: (agent.role_name as string) ?? id,\n purpose: (agent.purpose as string) ?? \"\",\n mode: (agent.mode as string) ?? \"read-write\",\n dispatch_only: (agent.dispatch_only as boolean) ?? false,\n can_read_artifacts: (agent.can_read_artifacts as string[]) ?? [],\n can_write_artifacts: (agent.can_write_artifacts as string[]) ?? [],\n can_execute_tools: (agent.can_execute_tools as string[]) ?? [],\n can_invoke_agents: (agent.can_invoke_agents as string[]) ?? [],\n can_return_handoffs: (agent.can_return_handoffs as string[]) ?? [],\n responsibilities: (agent.responsibilities as string[]) ?? [],\n constraints: (agent.constraints as string[]) ?? [],\n rules: (agent.rules as AgentEntry[\"rules\"]) ?? [],\n escalation_criteria: (agent.escalation_criteria as AgentEntry[\"escalation_criteria\"]) ?? [],\n }));\n\n const taskEntries: TaskEntry[] = Object.entries(tasks).map(([id, task]) => ({\n id,\n varName: toCamelCase(id),\n description: (task.description as string) ?? \"\",\n target_agent: (task.target_agent as string) ?? \"\",\n allowed_from_agents: (task.allowed_from_agents as string[]) ?? [],\n workflow: (task.workflow as string) ?? \"\",\n invocation_handoff: (task.invocation_handoff as string) ?? \"\",\n result_handoff: (task.result_handoff as string) ?? \"\",\n input_artifacts: (task.input_artifacts as string[]) ?? [],\n responsibilities: (task.responsibilities as string[]) ?? [],\n completion_criteria: (task.completion_criteria as string[]) ?? [],\n optional: isTaskOptional(id, workflows as Record<string, { steps: Array<{ type: string; task?: string; optional?: boolean }> }>),\n }));\n\n const workflowEntries: WorkflowEntry[] = Object.entries(workflows).map(\n ([id, wf]) => {\n const steps = ((wf.steps as Array<Record<string, unknown>>) ?? []).map((step) => {\n const entry: WorkflowStepEntry = { type: step.type as string };\n if (step.type === \"delegate\") {\n entry.task = step.task as string;\n entry.from_agent = step.from_agent as string;\n entry.description = (step.description as string | undefined) ?? \"\";\n const wfStep = step as Record<string, unknown>;\n entry.optional = isTaskOptional(\n step.task as string,\n workflows as Record<string, { steps: Array<{ type: string; task?: string; optional?: boolean }> }>,\n );\n entry.max_retries = (wfStep.max_retries as number | undefined) ?? (wfStep.retry ? 1 : 0);\n entry.max_follow_ups = wfStep.max_follow_ups as number | undefined;\n if (wfStep.depends_on) {\n entry.depends_on = wfStep.depends_on as string[];\n }\n if (wfStep.retry) {\n const r = wfStep.retry as Record<string, unknown>;\n entry.retry = {\n condition: r.condition as string,\n fix_task: r.fix_task as string,\n revalidate_task: r.revalidate_task as string | undefined,\n };\n }\n } else if (step.type === \"gate\") {\n entry.gate_kind = step.gate_kind as string;\n entry.description = (step.description as string | undefined) ?? \"\";\n if (step.depends_on) {\n entry.depends_on = step.depends_on as string[];\n }\n }\n return entry;\n });\n\n return {\n id,\n varName: toCamelCase(id),\n description: (wf.description as string) ?? \"\",\n trigger: (wf.trigger as string) ?? \"\",\n entry_conditions: (wf.entry_conditions as string[]) ?? [],\n steps,\n };\n },\n );\n\n const handoffEntries: HandoffEntry[] = Object.entries(handoffTypes).map(\n ([id, ht]) => ({\n id,\n varName: toCamelCase(id),\n pascalName: toPascalCase(id),\n schemaName: toPascalCase(id) + \"Schema\",\n description: (ht.description as string) ?? \"\",\n schema: (ht.schema as Record<string, unknown>) ?? {},\n }),\n );\n\n return { agentEntries, taskEntries, workflowEntries, handoffEntries };\n}\n\nexport interface GuardrailCheckEntry {\n guardrail_id: string;\n description: string;\n severity: string;\n action: string;\n matcher_type: string;\n pattern: string;\n message: string;\n file_glob?: string;\n exclude_glob?: string;\n}\n\nexport interface GuardrailContext {\n commandChecks: GuardrailCheckEntry[];\n fileChecks: GuardrailCheckEntry[];\n contentChecks: GuardrailCheckEntry[];\n allChecks: GuardrailCheckEntry[];\n hasGuardrails: boolean;\n}\n\n/**\n * Build guardrail context from DSL guardrails, binding guardrail_impl, and active policy.\n * Mirrors the agent-contracts resolveChecks pattern.\n */\nexport function buildGuardrailContext(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n dsl: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n binding: any,\n policyName?: string,\n): GuardrailContext {\n const empty: GuardrailContext = {\n commandChecks: [],\n fileChecks: [],\n contentChecks: [],\n allChecks: [],\n hasGuardrails: false,\n };\n\n if (!binding?.guardrail_impl) return empty;\n\n const guardrails = dsl.guardrails ?? {};\n const policies = dsl.guardrail_policies ?? {};\n const policy = policyName ? policies[policyName] : undefined;\n\n const allChecks: GuardrailCheckEntry[] = [];\n\n for (const [guardrailId, impl] of Object.entries(\n binding.guardrail_impl as Record<string, { checks: Array<Record<string, unknown>> }>,\n )) {\n const guardrail = guardrails[guardrailId] as Record<string, unknown> | undefined;\n const description = (guardrail?.description as string) ?? guardrailId;\n\n const policyRule = policy?.rules?.find(\n (r: Record<string, unknown>) => r.guardrail === guardrailId,\n );\n const severity = (policyRule?.severity as string) ?? \"warning\";\n const action = (policyRule?.action as string) ?? \"warn\";\n\n for (const check of impl.checks) {\n const matcher = check.matcher as Record<string, unknown> | undefined;\n if (!matcher) continue;\n\n allChecks.push({\n guardrail_id: guardrailId,\n description,\n severity,\n action,\n matcher_type: matcher.type as string,\n pattern: matcher.pattern as string,\n message: (check.message as string) ?? description,\n file_glob: matcher.file_glob as string | undefined,\n exclude_glob: matcher.exclude_glob as string | undefined,\n });\n }\n }\n\n return {\n commandChecks: allChecks.filter((c) => c.matcher_type === \"command_regex\"),\n fileChecks: allChecks.filter((c) => c.matcher_type === \"file_glob\"),\n contentChecks: allChecks.filter((c) => c.matcher_type === \"content_regex\"),\n allChecks,\n hasGuardrails: allChecks.length > 0,\n };\n}\n"],"mappings":";AAIA,SAAS,YAAAA,WAAU,WAAW,OAAO,UAAgB;AACrD,SAAS,WAAAC,UAAS,QAAAC,OAAM,gBAAgB;AACxC,SAAS,kBAAkB;AAC3B,OAAOC,WAAU;;;ACHjB,SAAS,gBAAgB;AACzB,SAAS,SAAS,eAAe;AACjC,SAAS,SAAS;AAClB,OAAO,UAAU;AAEjB,IAAM,iBAAiB,EAAE,OAAO;AAAA,EAC9B,gBAAgB,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,QAAQ,CAAC;AAAA,EACjD,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,QAAQ,CAAC;AAChD,CAAC,EAAE,QAAQ,OAAO,EAAE,gBAAgB,GAAG,aAAa,EAAE,EAAE;AAEjD,IAAM,sBAAsB,EAAE,OAAO;AAAA,EAC1C,KAAK,EAAE,OAAO,EAAE,QAAQ,wBAAwB;AAAA,EAChD,eAAe,EAAE,OAAO,EAAE,QAAQ,mBAAmB;AAAA,EACrD,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;AAAA,EACxC,yBAAyB,EAA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