agent-contracts 0.0.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +384 -300
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +60986 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +726 -2
- package/dist/index.js +60775 -1
- package/dist/index.js.map +1 -1
- package/package.json +33 -7
- package/dist/index.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,48 +1,259 @@
|
|
|
1
|
+
|
|
1
2
|
# agent-contracts
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
**Design multi-agent systems as contracts.**
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
`agent-contracts` is a toolkit for declaratively defining multi-agent development workflows in **YAML DSL**, with **static validation, semantic linting, and prompt rendering**.
|
|
7
|
+
|
|
8
|
+
It is designed for teams that need more than “agents that happen to work”.
|
|
9
|
+
It helps you define, validate, and evolve:
|
|
10
|
+
|
|
11
|
+
- who each agent is
|
|
12
|
+
- what tasks can be delegated
|
|
13
|
+
- which artifacts exist and who owns them
|
|
14
|
+
- what validations are required
|
|
15
|
+
- how handoffs are structured
|
|
16
|
+
- how prompts are rendered from the design itself
|
|
17
|
+
|
|
18
|
+
Instead of letting workflow rules live only in prompts and code, `agent-contracts` makes the system **explicit, reviewable, and CI-checkable**.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Why agent-contracts?
|
|
23
|
+
|
|
24
|
+
Most agent frameworks focus on **runtime execution**.
|
|
25
|
+
|
|
26
|
+
`agent-contracts` focuses on **design-time guarantees**.
|
|
27
|
+
|
|
28
|
+
As multi-agent systems grow, teams usually run into the same problems:
|
|
29
|
+
|
|
30
|
+
- agent responsibilities become ambiguous
|
|
31
|
+
- handoff rules drift across prompts
|
|
32
|
+
- artifact ownership is unclear
|
|
33
|
+
- validation logic is inconsistent
|
|
34
|
+
- prompts diverge from the intended workflow
|
|
35
|
+
- shared team conventions stop being enforceable
|
|
36
|
+
|
|
37
|
+
`agent-contracts` addresses this by treating your agent workflow as a **contract**, not just a set of prompts.
|
|
38
|
+
|
|
39
|
+
You can think of it as:
|
|
40
|
+
|
|
41
|
+
- **OpenAPI for multi-agent workflows**
|
|
42
|
+
- **a contract layer above runtime orchestration**
|
|
43
|
+
- **a source of truth for agent roles, handoffs, and artifact flows**
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Who this is for
|
|
6
48
|
|
|
7
|
-
-
|
|
8
|
-
- **Track artifact ownership, editors, consumers, and validation requirements**
|
|
9
|
-
- **Detect design flaws statically** via Schema Validation + Semantic Lint
|
|
10
|
-
- **Define and validate handoff payloads** with structured schemas
|
|
11
|
-
- **Generate static agent prompts (md)** from Handlebars templates via Prompt Renderer
|
|
12
|
-
- **Separate common and project-specific definitions** using the `extends` inheritance mechanism
|
|
49
|
+
`agent-contracts` is a strong fit for teams that build or operate:
|
|
13
50
|
|
|
14
|
-
|
|
51
|
+
- multi-agent coding workflows
|
|
52
|
+
- spec → implement → audit → release style pipelines
|
|
53
|
+
- internal agent platforms
|
|
54
|
+
- review-heavy or gate-heavy delivery processes
|
|
55
|
+
- agent systems where artifact ownership matters
|
|
56
|
+
- reusable team definitions shared across projects
|
|
15
57
|
|
|
16
|
-
|
|
58
|
+
Typical users include:
|
|
17
59
|
|
|
18
|
-
|
|
60
|
+
- platform teams standardizing agent workflows
|
|
61
|
+
- engineering teams building internal coding/review agents
|
|
62
|
+
- products that require explicit validation and handoff policies
|
|
63
|
+
- teams that want CI enforcement for agent design consistency
|
|
19
64
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Who this is not for
|
|
68
|
+
|
|
69
|
+
`agent-contracts` is probably **not** the right starting point if you want:
|
|
70
|
+
|
|
71
|
+
- a single-agent chatbot
|
|
72
|
+
- a quick prompt prototype
|
|
73
|
+
- an all-in-one hosted agent runtime
|
|
74
|
+
- built-in scheduling, memory, tracing, or hosting
|
|
75
|
+
- a purely code-first orchestration style with no declarative spec
|
|
76
|
+
- maximum flexibility with minimal process constraints
|
|
77
|
+
|
|
78
|
+
In short:
|
|
79
|
+
|
|
80
|
+
- if you want to **run agents quickly**, start with a runtime framework
|
|
81
|
+
- if you want to **design multi-agent systems that stay coherent over time**, use `agent-contracts`
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## What makes it different?
|
|
25
86
|
|
|
26
|
-
|
|
87
|
+
`agent-contracts` does not try to replace every agent framework.
|
|
27
88
|
|
|
28
|
-
|
|
29
|
-
base definition (shared team definition)
|
|
30
|
-
↓ project definition references base via extends
|
|
31
|
-
↓ id-based deep merge + merge operators apply diffs
|
|
32
|
-
→ resolved YAML (final result)
|
|
33
|
-
```
|
|
89
|
+
It occupies a different layer.
|
|
34
90
|
|
|
35
|
-
|
|
91
|
+
### Positioning
|
|
92
|
+
|
|
93
|
+
| Product / approach | Primary focus | Best fit | How `agent-contracts` differs |
|
|
94
|
+
|---|---|---|---|
|
|
95
|
+
| **OpenAI Agents SDK** | runtime execution with instructions, tools, and handoffs | apps built around agent runtime behavior | `agent-contracts` focuses on design contracts, static guarantees, and artifact relationships |
|
|
96
|
+
| **CrewAI** | agent/task workflow orchestration | teams that want runtime task execution in YAML | `agent-contracts` goes deeper on validation, ownership, inheritance, and renderable design specs |
|
|
97
|
+
| **AutoGen** | code-first multi-agent programming | research or custom orchestration flows | `agent-contracts` is more declarative, reviewable, and CI-oriented |
|
|
98
|
+
| **Google ADK style patterns** | choosing runtime interaction patterns | production systems built around runtime composition | `agent-contracts` is framework-agnostic and centered on workflow design as a contract |
|
|
99
|
+
|
|
100
|
+
The key distinction is simple:
|
|
101
|
+
|
|
102
|
+
> Other frameworks mainly answer: **How do I run these agents?**
|
|
103
|
+
> `agent-contracts` answers: **What is the allowed structure of this agent system, and how do we keep it correct as it evolves?**
|
|
104
|
+
|
|
105
|
+
This positioning is consistent with common industry patterns: some frameworks center the agent runtime, others separate agent definition and task invocation, but `agent-contracts` is strongest as a **design-time contract layer** across those execution models.
|
|
36
106
|
|
|
37
107
|
---
|
|
38
108
|
|
|
39
|
-
##
|
|
109
|
+
## Quick Start
|
|
40
110
|
|
|
41
|
-
|
|
111
|
+
Define your system in a single YAML file:
|
|
42
112
|
|
|
43
113
|
```yaml
|
|
114
|
+
# agent-contracts.yaml
|
|
44
115
|
version: 1
|
|
45
|
-
|
|
116
|
+
system:
|
|
117
|
+
id: my-project
|
|
118
|
+
name: My Agent Workflow
|
|
119
|
+
default_phase_order: [design, implement]
|
|
120
|
+
|
|
121
|
+
agents:
|
|
122
|
+
architect:
|
|
123
|
+
role_name: "Architect"
|
|
124
|
+
purpose: "Drive phases and delegate work"
|
|
125
|
+
can_invoke_agents: [implementer]
|
|
126
|
+
|
|
127
|
+
implementer:
|
|
128
|
+
role_name: "Implementer"
|
|
129
|
+
purpose: "Implement features based on specs"
|
|
130
|
+
|
|
131
|
+
tasks:
|
|
132
|
+
implement-feature:
|
|
133
|
+
description: "Delegate feature implementation"
|
|
134
|
+
target_agent: implementer
|
|
135
|
+
allowed_from_agents: [architect]
|
|
136
|
+
phase: implement
|
|
137
|
+
input_artifacts: [spec-md]
|
|
138
|
+
invocation_handoff: task-delegation
|
|
139
|
+
result_handoff: implementation-result
|
|
140
|
+
|
|
141
|
+
artifacts:
|
|
142
|
+
spec-md:
|
|
143
|
+
type: document
|
|
144
|
+
owner: architect
|
|
145
|
+
producers: [architect]
|
|
146
|
+
editors: [architect]
|
|
147
|
+
consumers: [implementer]
|
|
148
|
+
states: [draft, reviewed, approved]
|
|
149
|
+
````
|
|
150
|
+
|
|
151
|
+
Validate and render:
|
|
152
|
+
|
|
153
|
+
````bash
|
|
154
|
+
agent-contracts validate
|
|
155
|
+
agent-contracts render -c agent-contracts.config.yaml
|
|
156
|
+
````
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
A working example is available in [`sample/`](./sample), including:
|
|
160
|
+
|
|
161
|
+
* [`sample/agent-contracts.yaml`](./sample/agent-contracts.yaml)
|
|
162
|
+
* [`sample/agent-contracts.config.yaml`](./sample/agent-contracts.config.yaml)
|
|
163
|
+
* [`sample/templates`](./sample/templates)
|
|
164
|
+
* [`sample/output`](./sample/output)
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## Core concepts
|
|
169
|
+
|
|
170
|
+
### Agent
|
|
171
|
+
|
|
172
|
+
An **Agent** defines who an execution entity is:
|
|
173
|
+
|
|
174
|
+
* role name
|
|
175
|
+
* purpose
|
|
176
|
+
* capabilities
|
|
177
|
+
* permissions
|
|
178
|
+
* constraints
|
|
179
|
+
* behavioral rules
|
|
180
|
+
|
|
181
|
+
### Task
|
|
182
|
+
|
|
183
|
+
A **Task** defines a delegatable unit of work:
|
|
184
|
+
|
|
185
|
+
* target agent
|
|
186
|
+
* allowed callers
|
|
187
|
+
* phase
|
|
188
|
+
* input artifacts
|
|
189
|
+
* invocation/result handoffs
|
|
190
|
+
* task-specific execution expectations
|
|
191
|
+
|
|
192
|
+
### Artifact
|
|
193
|
+
|
|
194
|
+
An **Artifact** defines the objects that move through the workflow:
|
|
195
|
+
|
|
196
|
+
* owner
|
|
197
|
+
* producers
|
|
198
|
+
* editors
|
|
199
|
+
* consumers
|
|
200
|
+
* states
|
|
201
|
+
* required validations
|
|
202
|
+
* visibility
|
|
203
|
+
|
|
204
|
+
### Handoff
|
|
205
|
+
|
|
206
|
+
A **Handoff** is a runtime delegation instance.
|
|
207
|
+
The YAML defines the allowed handoff types and constraints; concrete handoffs are created at runtime.
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## Why teams adopt it
|
|
212
|
+
|
|
213
|
+
### 1. Explicit workflow design
|
|
214
|
+
|
|
215
|
+
Your architecture stops living only in prompts, code, and tribal knowledge.
|
|
216
|
+
|
|
217
|
+
### 2. Static guarantees before runtime
|
|
218
|
+
|
|
219
|
+
You can catch broken references, invalid ownership, missing validations, and workflow inconsistencies before execution.
|
|
220
|
+
|
|
221
|
+
### 3. Prompt generation from source of truth
|
|
222
|
+
|
|
223
|
+
Rendered prompts come from the same DSL that defines roles, tasks, artifacts, and policies.
|
|
224
|
+
|
|
225
|
+
### 4. Reuse across teams and projects
|
|
226
|
+
|
|
227
|
+
Shared base definitions can be extended safely with `extends`.
|
|
228
|
+
|
|
229
|
+
### 5. Better CI discipline
|
|
230
|
+
|
|
231
|
+
Design regressions become testable.
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Features
|
|
236
|
+
|
|
237
|
+
* **Declarative YAML DSL** for multi-agent development workflows
|
|
238
|
+
* **Static schema validation**
|
|
239
|
+
* **Reference integrity checks**
|
|
240
|
+
* **Semantic linting**
|
|
241
|
+
* **Structured handoff definitions**
|
|
242
|
+
* **Artifact ownership and lifecycle modeling**
|
|
243
|
+
* **Config-driven prompt rendering**
|
|
244
|
+
* **Inheritance with merge operators via `extends`**
|
|
245
|
+
* **JSON Schema for editor support and external tooling**
|
|
246
|
+
* **CI-friendly workflow checks**
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## DSL structure
|
|
251
|
+
|
|
252
|
+
Entities are defined as **maps keyed by ID**.
|
|
253
|
+
|
|
254
|
+
````yaml
|
|
255
|
+
version: 1
|
|
256
|
+
extends: "./base/"
|
|
46
257
|
|
|
47
258
|
system:
|
|
48
259
|
id: my-project
|
|
@@ -56,35 +267,33 @@ system:
|
|
|
56
267
|
- release
|
|
57
268
|
- reflect
|
|
58
269
|
|
|
59
|
-
agents:
|
|
60
|
-
tasks:
|
|
61
|
-
artifacts:
|
|
62
|
-
tools:
|
|
63
|
-
validations:
|
|
64
|
-
handoff_types:
|
|
65
|
-
workflow:
|
|
66
|
-
policies:
|
|
67
|
-
|
|
270
|
+
agents: {}
|
|
271
|
+
tasks: {}
|
|
272
|
+
artifacts: {}
|
|
273
|
+
tools: {}
|
|
274
|
+
validations: {}
|
|
275
|
+
handoff_types: {}
|
|
276
|
+
workflow: {}
|
|
277
|
+
policies: {}
|
|
278
|
+
````
|
|
68
279
|
|
|
69
|
-
|
|
280
|
+
This makes definitions easy to merge, extend, and reference by stable identifiers.
|
|
70
281
|
|
|
71
|
-
|
|
282
|
+
### Single-file format
|
|
72
283
|
|
|
73
|
-
|
|
74
|
-
# agentdef.yaml
|
|
284
|
+
````yaml
|
|
75
285
|
version: 1
|
|
76
286
|
system: { ... }
|
|
77
|
-
agents:
|
|
78
|
-
tasks:
|
|
79
|
-
artifacts:
|
|
80
|
-
|
|
287
|
+
agents: { ... }
|
|
288
|
+
tasks: { ... }
|
|
289
|
+
artifacts: { ... }
|
|
290
|
+
````
|
|
81
291
|
|
|
82
|
-
|
|
292
|
+
### Multi-file format
|
|
83
293
|
|
|
84
|
-
|
|
85
|
-
# agentdef.yaml
|
|
294
|
+
````yaml
|
|
86
295
|
version: 1
|
|
87
|
-
extends: "
|
|
296
|
+
extends: "./base/"
|
|
88
297
|
system:
|
|
89
298
|
id: my-project
|
|
90
299
|
name: My Agent Workflow
|
|
@@ -98,19 +307,19 @@ validations: { $ref: "./validations.yaml" }
|
|
|
98
307
|
handoff_types: { $ref: "./handoff-types.yaml" }
|
|
99
308
|
workflow: { $ref: "./workflow.yaml" }
|
|
100
309
|
policies: { $ref: "./policies.yaml" }
|
|
101
|
-
|
|
310
|
+
````
|
|
102
311
|
|
|
103
312
|
---
|
|
104
313
|
|
|
105
|
-
##
|
|
314
|
+
## Example: Agent definition
|
|
106
315
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
```yaml
|
|
316
|
+
````yaml
|
|
110
317
|
agents:
|
|
111
|
-
|
|
318
|
+
main-architect:
|
|
112
319
|
role_name: "Architect"
|
|
113
320
|
purpose: "Drive phases, delegate, make gate decisions, integrate audits"
|
|
321
|
+
dispatch_only: true
|
|
322
|
+
mode: read-only
|
|
114
323
|
can_read_artifacts:
|
|
115
324
|
- spec-md
|
|
116
325
|
- codebase
|
|
@@ -127,32 +336,23 @@ agents:
|
|
|
127
336
|
can_return_handoffs:
|
|
128
337
|
- evidence-gate-verdict
|
|
129
338
|
|
|
130
|
-
# General behavioral spec (common across all tasks)
|
|
131
339
|
responsibilities:
|
|
132
340
|
- "Manage phase progression and gate decisions"
|
|
133
341
|
constraints:
|
|
134
342
|
- "Never write code directly"
|
|
135
|
-
rules:
|
|
136
|
-
- id: R-ARCH-001
|
|
137
|
-
description: "Evidence Gates must use structured evaluation criteria"
|
|
138
|
-
severity: mandatory
|
|
139
343
|
|
|
140
|
-
# Extension properties (freely added with x- prefix)
|
|
141
344
|
x-identity: |
|
|
142
345
|
You act as the Architect. You NEVER implement or test directly.
|
|
143
346
|
Instead you delegate to specialist sub-agents.
|
|
144
|
-
|
|
145
|
-
- agent: implementer
|
|
146
|
-
condition: "Backend code, infrastructure, database migrations"
|
|
147
|
-
- agent: test-writer
|
|
148
|
-
condition: "Test code creation and coverage improvement"
|
|
149
|
-
```
|
|
347
|
+
````
|
|
150
348
|
|
|
151
|
-
|
|
349
|
+
---
|
|
152
350
|
|
|
153
|
-
|
|
351
|
+
## Example: Task definition
|
|
352
|
+
|
|
353
|
+
````yaml
|
|
154
354
|
tasks:
|
|
155
|
-
|
|
355
|
+
implement-feature:
|
|
156
356
|
description: "Delegate feature implementation"
|
|
157
357
|
target_agent: implementer
|
|
158
358
|
allowed_from_agents:
|
|
@@ -163,8 +363,6 @@ tasks:
|
|
|
163
363
|
- plan-md
|
|
164
364
|
invocation_handoff: task-delegation
|
|
165
365
|
result_handoff: dependency-evidence
|
|
166
|
-
|
|
167
|
-
# Task-specific behavioral spec
|
|
168
366
|
responsibilities:
|
|
169
367
|
- "Implement all requirements from spec-md"
|
|
170
368
|
execution_steps:
|
|
@@ -177,13 +375,15 @@ tasks:
|
|
|
177
375
|
uses_tool: db-lint
|
|
178
376
|
completion_criteria:
|
|
179
377
|
- "canonical artifacts updated"
|
|
180
|
-
|
|
378
|
+
````
|
|
181
379
|
|
|
182
|
-
|
|
380
|
+
---
|
|
183
381
|
|
|
184
|
-
|
|
382
|
+
## Example: Artifact definition
|
|
383
|
+
|
|
384
|
+
````yaml
|
|
185
385
|
artifacts:
|
|
186
|
-
|
|
386
|
+
spec-md:
|
|
187
387
|
type: document
|
|
188
388
|
description: "Specification document"
|
|
189
389
|
owner: main-architect
|
|
@@ -193,30 +393,29 @@ artifacts:
|
|
|
193
393
|
states: [draft, reviewed, approved]
|
|
194
394
|
required_validations: [spec-semantic-review]
|
|
195
395
|
visibility: internal
|
|
196
|
-
|
|
396
|
+
````
|
|
197
397
|
|
|
198
|
-
|
|
398
|
+
---
|
|
199
399
|
|
|
200
|
-
|
|
400
|
+
## Inheritance and merge operators
|
|
201
401
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
402
|
+
`agent-contracts` supports shared base definitions with project-level overrides through `extends`.
|
|
403
|
+
|
|
404
|
+
````yaml
|
|
405
|
+
extends: "./base/"
|
|
205
406
|
|
|
206
407
|
agents:
|
|
207
|
-
|
|
208
|
-
- id: implementer
|
|
408
|
+
implementer:
|
|
209
409
|
constraints:
|
|
210
410
|
$append:
|
|
211
|
-
- "
|
|
411
|
+
- "Use only approved external libraries"
|
|
212
412
|
|
|
213
|
-
|
|
214
|
-
- id: designer
|
|
413
|
+
designer:
|
|
215
414
|
role_name: "Designer"
|
|
216
415
|
purpose: "UI design"
|
|
217
416
|
|
|
218
417
|
tasks:
|
|
219
|
-
|
|
418
|
+
implement-feature:
|
|
220
419
|
execution_steps:
|
|
221
420
|
$insert_after:
|
|
222
421
|
target: run-db-lint
|
|
@@ -224,46 +423,18 @@ tasks:
|
|
|
224
423
|
- id: run-contract-pipeline
|
|
225
424
|
action: "Run contract pipeline"
|
|
226
425
|
uses_tool: api-pipeline
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
Merge operators:
|
|
426
|
+
````
|
|
230
427
|
|
|
231
|
-
|
|
232
|
-
|---|---|
|
|
233
|
-
| `$append` | Append to end of array |
|
|
234
|
-
| `$prepend` | Prepend to beginning of array |
|
|
235
|
-
| `$insert_after` | Insert after element with specified id |
|
|
236
|
-
| `$replace` | Replace entire array/value |
|
|
237
|
-
| `$remove` | Remove element by id |
|
|
238
|
-
| (direct value) | Override scalar field |
|
|
428
|
+
Supported merge operators:
|
|
239
429
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
# Scalar (multiline text)
|
|
250
|
-
x-identity: |
|
|
251
|
-
You act as the Architect.
|
|
252
|
-
|
|
253
|
-
# Array
|
|
254
|
-
x-role-selection-guide:
|
|
255
|
-
- agent: implementer
|
|
256
|
-
condition: "Backend code, infrastructure"
|
|
257
|
-
|
|
258
|
-
# Object
|
|
259
|
-
x-cursor-config:
|
|
260
|
-
subagent_type: null
|
|
261
|
-
globs: ["**/*"]
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
- `x-` properties pass through the schema validator (no type errors)
|
|
265
|
-
- Same merge rules and operators as standard properties apply during `extends` inheritance
|
|
266
|
-
- Included in the Prompt Renderer template context
|
|
430
|
+
| Operator | Behavior |
|
|
431
|
+
| --------------- | ------------------------------------------ |
|
|
432
|
+
| `$append` | Append entries to end of map/array |
|
|
433
|
+
| `$prepend` | Prepend entries to beginning of map/array |
|
|
434
|
+
| `$insert_after` | Insert after element with specified key/id |
|
|
435
|
+
| `$replace` | Replace entire value |
|
|
436
|
+
| `$remove` | Remove entries by key/id |
|
|
437
|
+
| direct value | Override scalar field |
|
|
267
438
|
|
|
268
439
|
---
|
|
269
440
|
|
|
@@ -271,222 +442,135 @@ agents:
|
|
|
271
442
|
|
|
272
443
|
### Installation
|
|
273
444
|
|
|
274
|
-
|
|
275
|
-
npm install -g agent-contracts
|
|
276
|
-
npm install -D agent-contracts
|
|
277
|
-
npx agent-contracts
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
### Commands
|
|
281
|
-
|
|
282
|
-
| Command | Description |
|
|
283
|
-
|---|---|
|
|
284
|
-
| `agent-contracts resolve [dir]` | Resolve `extends` inheritance and output resolved YAML |
|
|
285
|
-
| `agent-contracts validate [dir]` | Schema validation + reference integrity check. Exit 1 on errors |
|
|
286
|
-
| `agent-contracts lint [dir]` | Run semantic lint. Display diagnostics and control exit code by severity |
|
|
287
|
-
| `agent-contracts render [dir]` | Generate prompt md from resolved YAML + Handlebars templates |
|
|
288
|
-
| `agent-contracts render [dir] --check` | Drift check. Detect diffs without writing files; exit 1 if diffs found |
|
|
289
|
-
|
|
290
|
-
### Render Command Options
|
|
291
|
-
|
|
292
|
-
| Option | Description |
|
|
293
|
-
|---|---|
|
|
294
|
-
| `--template-dir <path>` | Handlebars template directory (required) |
|
|
295
|
-
| `--output-dir <path>` | Output directory (required) |
|
|
296
|
-
| `agent-contracts check [dir]` | Run resolve → validate → lint → render --check in sequence (for CI) |
|
|
297
|
-
|
|
298
|
-
### Common Options
|
|
299
|
-
|
|
300
|
-
| Option | Description |
|
|
301
|
-
|---|---|
|
|
302
|
-
| `--format json\|text` | Specify output format |
|
|
303
|
-
| `--quiet` | Show errors only |
|
|
304
|
-
| `--strict` | Treat warnings as exit 1 |
|
|
305
|
-
|
|
306
|
-
### Usage Examples
|
|
307
|
-
|
|
308
|
-
```bash
|
|
309
|
-
# Output resolved YAML to stdout
|
|
310
|
-
agent-contracts resolve ./my-project
|
|
311
|
-
|
|
312
|
-
# Output resolved YAML to file
|
|
313
|
-
agent-contracts resolve ./my-project -o resolved.yaml
|
|
314
|
-
|
|
315
|
-
# Schema validation
|
|
316
|
-
agent-contracts validate ./my-project
|
|
317
|
-
|
|
318
|
-
# Semantic lint (JSON output)
|
|
319
|
-
agent-contracts lint ./my-project --format json
|
|
445
|
+
````bash
|
|
446
|
+
npm install -g agent-contracts
|
|
447
|
+
npm install -D agent-contracts
|
|
448
|
+
npx agent-contracts
|
|
449
|
+
````
|
|
320
450
|
|
|
321
|
-
|
|
322
|
-
agent-contracts render ./my-project --template-dir ./templates --output-dir ./rendered
|
|
451
|
+
### Main commands
|
|
323
452
|
|
|
324
|
-
|
|
325
|
-
|
|
453
|
+
| Command | Description |
|
|
454
|
+
| --------------------------------- | ------------------------------------------------------ |
|
|
455
|
+
| `agent-contracts resolve [path]` | Resolve `extends` inheritance and output resolved YAML |
|
|
456
|
+
| `agent-contracts validate [path]` | Validate schema and references |
|
|
457
|
+
| `agent-contracts lint [path]` | Run semantic lint |
|
|
458
|
+
| `agent-contracts render` | Render outputs from config |
|
|
459
|
+
| `agent-contracts check` | Run resolve → validate → lint → render --check |
|
|
326
460
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
```
|
|
461
|
+
The `[path]` argument defaults to `agent-contracts.yaml` in the current directory.
|
|
462
|
+
If `-c` / `--config` is specified, the DSL path from the config file is used.
|
|
330
463
|
|
|
331
|
-
###
|
|
464
|
+
### Common usage
|
|
332
465
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
agent-contracts
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
agent-contracts
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
agent-contracts resolve ./project/ -o ./resolved.yaml
|
|
342
|
-
```
|
|
466
|
+
````bash
|
|
467
|
+
agent-contracts resolve
|
|
468
|
+
agent-contracts validate
|
|
469
|
+
agent-contracts lint --strict
|
|
470
|
+
agent-contracts render -c agent-contracts.config.yaml
|
|
471
|
+
agent-contracts render -c agent-contracts.config.yaml --check
|
|
472
|
+
agent-contracts check -c agent-contracts.config.yaml --strict
|
|
473
|
+
````
|
|
343
474
|
|
|
344
475
|
---
|
|
345
476
|
|
|
346
|
-
##
|
|
347
|
-
|
|
348
|
-
```text
|
|
349
|
-
1. Define DSL in YAML
|
|
350
|
-
├── agentdef.yaml (entry point; references base via extends)
|
|
351
|
-
└── agents.yaml, tasks.yaml, ... (for multi-file format)
|
|
477
|
+
## Config-driven rendering
|
|
352
478
|
|
|
353
|
-
|
|
354
|
-
Resolve extends inheritance → id-based deep merge → generate resolved YAML
|
|
479
|
+
Rendering is configured via `agent-contracts.config.yaml`.
|
|
355
480
|
|
|
356
|
-
|
|
357
|
-
|
|
481
|
+
````yaml
|
|
482
|
+
dsl: ./agent-contracts.yaml
|
|
358
483
|
|
|
359
|
-
|
|
360
|
-
|
|
484
|
+
renders:
|
|
485
|
+
- template: ./templates/agent-prompt.md.hbs
|
|
486
|
+
context: agent
|
|
487
|
+
output: ./output/{agent.id}.md
|
|
361
488
|
|
|
362
|
-
|
|
363
|
-
|
|
489
|
+
- template: ./templates/overview.md.hbs
|
|
490
|
+
context: system
|
|
491
|
+
output: ./output/overview.md
|
|
492
|
+
````
|
|
364
493
|
|
|
365
|
-
|
|
366
|
-
Run steps 2–5 in sequence to ensure design consistency and up-to-date rendered output
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
---
|
|
494
|
+
This lets you generate static outputs for:
|
|
370
495
|
|
|
371
|
-
|
|
496
|
+
* agent prompts
|
|
497
|
+
* task specs
|
|
498
|
+
* overviews
|
|
499
|
+
* artifact docs
|
|
500
|
+
* validation docs
|
|
501
|
+
* workflow docs
|
|
372
502
|
|
|
373
|
-
|
|
503
|
+
all from the same resolved DSL.
|
|
374
504
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
| Context | Contents |
|
|
378
|
-
|---|---|
|
|
379
|
-
| **global context** | Entire resolved YAML (system, agents, tasks, artifacts, etc. + extension properties) |
|
|
380
|
-
| **per-agent context** | Each agent + related tasks + related handoff_types + related artifacts/tools |
|
|
505
|
+
---
|
|
381
506
|
|
|
382
|
-
|
|
507
|
+
## Validation model
|
|
383
508
|
|
|
384
|
-
|
|
385
|
-
# {{agent.role_name}}
|
|
509
|
+
`agent-contracts` validates your system in multiple layers.
|
|
386
510
|
|
|
387
|
-
|
|
511
|
+
### Schema validation
|
|
388
512
|
|
|
389
|
-
|
|
513
|
+
Checks:
|
|
390
514
|
|
|
391
|
-
|
|
515
|
+
* required fields
|
|
516
|
+
* types
|
|
517
|
+
* enums
|
|
518
|
+
* handoff payload shape
|
|
519
|
+
* invalid custom properties without `x-` prefix
|
|
392
520
|
|
|
393
|
-
|
|
394
|
-
- {{this}}
|
|
395
|
-
{{/each}}
|
|
521
|
+
### Reference integrity
|
|
396
522
|
|
|
397
|
-
|
|
398
|
-
## Identity
|
|
523
|
+
Checks:
|
|
399
524
|
|
|
400
|
-
|
|
401
|
-
|
|
525
|
+
* cross-entity references
|
|
526
|
+
* owner / producer / editor / consumer validity
|
|
527
|
+
* handoff and payload consistency
|
|
528
|
+
* permission alignment between agents and artifacts
|
|
402
529
|
|
|
403
|
-
|
|
404
|
-
## Role Selection Guide
|
|
530
|
+
### Semantic lint
|
|
405
531
|
|
|
406
|
-
|
|
407
|
-
- **{{this.agent}}**: {{this.condition}}
|
|
408
|
-
{{/each}}
|
|
409
|
-
{{/if}}
|
|
410
|
-
```
|
|
532
|
+
Checks:
|
|
411
533
|
|
|
412
|
-
|
|
534
|
+
* bidirectional consistency
|
|
535
|
+
* validation coverage
|
|
536
|
+
* workflow graph completeness
|
|
537
|
+
* merge integrity
|
|
538
|
+
* read-only write violations
|
|
539
|
+
* prerequisite readability
|
|
540
|
+
* naming/style issues through Spectral rules
|
|
413
541
|
|
|
414
542
|
---
|
|
415
543
|
|
|
416
|
-
##
|
|
417
|
-
|
|
418
|
-
agent-contracts separates validation into 3 layers.
|
|
419
|
-
|
|
420
|
-
### A. Schema Validation (Zod + Spectral)
|
|
544
|
+
## Best used with runtime frameworks
|
|
421
545
|
|
|
422
|
-
-
|
|
423
|
-
- Detection of custom properties without `x-` prefix
|
|
424
|
-
- Handoff payload shape validation
|
|
425
|
-
- Naming conventions
|
|
546
|
+
`agent-contracts` works well alongside runtime frameworks and internal agent infrastructure.
|
|
426
547
|
|
|
427
|
-
|
|
548
|
+
A practical model is:
|
|
428
549
|
|
|
429
|
-
|
|
430
|
-
|
|
550
|
+
1. define the workflow in YAML
|
|
551
|
+
2. validate and lint it in CI
|
|
552
|
+
3. render prompts and derived docs
|
|
553
|
+
4. execute the workflow in your runtime of choice
|
|
431
554
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
- **Bidirectional consistency** between `can_execute_tools` and `tools.invokable_by`
|
|
435
|
-
- Bidirectional consistency between `allowed_from_agents` and `can_invoke_agents`
|
|
436
|
-
- Validation coverage analysis (e.g., whether code artifacts have mechanical validation)
|
|
437
|
-
- Workflow graph completeness (existence of release / audit roots)
|
|
438
|
-
- Design rule validation on post-merge resolved definitions
|
|
439
|
-
|
|
440
|
-
---
|
|
441
|
-
|
|
442
|
-
## Programmatic API
|
|
443
|
-
|
|
444
|
-
In addition to the CLI, a programmatic API is available for use from TypeScript.
|
|
445
|
-
|
|
446
|
-
```typescript
|
|
447
|
-
import { resolve, validate, lint, render } from "agent-contracts";
|
|
448
|
-
|
|
449
|
-
const resolved = await resolve("./my-project");
|
|
450
|
-
const validationResult = await validate(resolved);
|
|
451
|
-
const lintResult = await lint(resolved);
|
|
452
|
-
await render(resolved, { templateDir: "./templates", outputDir: "./rendered" });
|
|
453
|
-
```
|
|
555
|
+
That separation keeps runtime concerns and architecture concerns from being mixed together.
|
|
454
556
|
|
|
455
557
|
---
|
|
456
558
|
|
|
457
|
-
## Tech
|
|
559
|
+
## Tech stack
|
|
458
560
|
|
|
459
|
-
| Category
|
|
460
|
-
|
|
461
|
-
| Language
|
|
462
|
-
| Schema
|
|
463
|
-
| YAML parsing | yaml
|
|
464
|
-
| Lint
|
|
465
|
-
| Templates
|
|
466
|
-
| CLI
|
|
467
|
-
| Testing
|
|
468
|
-
| Build
|
|
561
|
+
| Category | Choice |
|
|
562
|
+
| ------------ | ---------------------------------- |
|
|
563
|
+
| Language | TypeScript (ESM, strict mode) |
|
|
564
|
+
| Schema | Zod |
|
|
565
|
+
| YAML parsing | yaml |
|
|
566
|
+
| Lint | TypeScript custom rules + Spectral |
|
|
567
|
+
| Templates | Handlebars |
|
|
568
|
+
| CLI | commander |
|
|
569
|
+
| Testing | Vitest |
|
|
570
|
+
| Build | tsup |
|
|
469
571
|
|
|
470
572
|
---
|
|
471
573
|
|
|
472
|
-
## Project Structure
|
|
473
|
-
|
|
474
|
-
```text
|
|
475
|
-
agent-contracts/
|
|
476
|
-
src/
|
|
477
|
-
schema/ # Zod schema definitions
|
|
478
|
-
loader/ # YAML loading and integration
|
|
479
|
-
resolver/ # extends resolution + id-based deep merge
|
|
480
|
-
validator/ # Schema Validation + reference integrity
|
|
481
|
-
linter/ # Semantic Lint (TypeScript custom rules)
|
|
482
|
-
renderer/ # Prompt Renderer (Handlebars)
|
|
483
|
-
cli/ # CLI entry point + commands
|
|
484
|
-
spectral/ # Spectral rulesets
|
|
485
|
-
schemas/ # JSON Schema derived from Zod
|
|
486
|
-
test/
|
|
487
|
-
fixtures/ # Test YAML samples
|
|
488
|
-
```
|
|
489
|
-
|
|
490
574
|
## License
|
|
491
575
|
|
|
492
576
|
MIT
|