agent-contracts 0.0.2 → 0.5.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 +353 -313
- 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 +34 -8
- package/dist/index.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,12 +1,114 @@
|
|
|
1
|
+
|
|
1
2
|
# agent-contracts
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
**Design multi-agent systems as contracts.**
|
|
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
|
|
48
|
+
|
|
49
|
+
`agent-contracts` is a strong fit for teams that build or operate:
|
|
50
|
+
|
|
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
|
|
57
|
+
|
|
58
|
+
Typical users include:
|
|
59
|
+
|
|
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
|
|
64
|
+
|
|
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?
|
|
4
86
|
|
|
5
|
-
|
|
87
|
+
`agent-contracts` does not try to replace every agent framework.
|
|
88
|
+
|
|
89
|
+
It occupies a different layer.
|
|
90
|
+
|
|
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.
|
|
106
|
+
|
|
107
|
+
---
|
|
6
108
|
|
|
7
109
|
## Quick Start
|
|
8
110
|
|
|
9
|
-
Define your
|
|
111
|
+
Define your system in a single YAML file:
|
|
10
112
|
|
|
11
113
|
```yaml
|
|
12
114
|
# agent-contracts.yaml
|
|
@@ -14,79 +116,144 @@ version: 1
|
|
|
14
116
|
system:
|
|
15
117
|
id: my-project
|
|
16
118
|
name: My Agent Workflow
|
|
119
|
+
default_phase_order: [design, implement]
|
|
17
120
|
|
|
18
121
|
agents:
|
|
19
|
-
|
|
122
|
+
architect:
|
|
20
123
|
role_name: "Architect"
|
|
21
124
|
purpose: "Drive phases and delegate work"
|
|
22
125
|
can_invoke_agents: [implementer]
|
|
23
126
|
|
|
24
|
-
|
|
127
|
+
implementer:
|
|
25
128
|
role_name: "Implementer"
|
|
26
129
|
purpose: "Implement features based on specs"
|
|
27
130
|
|
|
28
131
|
tasks:
|
|
29
|
-
|
|
132
|
+
implement-feature:
|
|
133
|
+
description: "Delegate feature implementation"
|
|
30
134
|
target_agent: implementer
|
|
31
135
|
allowed_from_agents: [architect]
|
|
32
136
|
phase: implement
|
|
33
137
|
input_artifacts: [spec-md]
|
|
138
|
+
invocation_handoff: task-delegation
|
|
139
|
+
result_handoff: implementation-result
|
|
34
140
|
|
|
35
141
|
artifacts:
|
|
36
|
-
|
|
142
|
+
spec-md:
|
|
37
143
|
type: document
|
|
38
144
|
owner: architect
|
|
145
|
+
producers: [architect]
|
|
146
|
+
editors: [architect]
|
|
39
147
|
consumers: [implementer]
|
|
40
|
-
|
|
148
|
+
states: [draft, reviewed, approved]
|
|
149
|
+
````
|
|
41
150
|
|
|
42
|
-
|
|
151
|
+
Validate and render:
|
|
43
152
|
|
|
44
|
-
|
|
45
|
-
agent-contracts validate
|
|
46
|
-
agent-contracts render
|
|
47
|
-
|
|
153
|
+
````bash
|
|
154
|
+
agent-contracts validate
|
|
155
|
+
agent-contracts render -c agent-contracts.config.yaml
|
|
156
|
+
````
|
|
48
157
|
|
|
49
|
-
## Features
|
|
50
158
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
|
57
169
|
|
|
58
|
-
|
|
170
|
+
### Agent
|
|
59
171
|
|
|
60
|
-
|
|
172
|
+
An **Agent** defines who an execution entity is:
|
|
61
173
|
|
|
62
|
-
|
|
174
|
+
* role name
|
|
175
|
+
* purpose
|
|
176
|
+
* capabilities
|
|
177
|
+
* permissions
|
|
178
|
+
* constraints
|
|
179
|
+
* behavioral rules
|
|
63
180
|
|
|
64
|
-
|
|
65
|
-
|---|---|---|
|
|
66
|
-
| **Agent** | Capability declaration and general behavioral spec of the execution entity | `agents` |
|
|
67
|
-
| **Task** | A type of work that can be delegated to an agent, with task-specific behavioral spec | `tasks` |
|
|
68
|
-
| **Handoff** | A concrete delegation instance (runtime object, not predefined in YAML) | Generated at runtime |
|
|
181
|
+
### Task
|
|
69
182
|
|
|
70
|
-
|
|
183
|
+
A **Task** defines a delegatable unit of work:
|
|
71
184
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
185
|
+
* target agent
|
|
186
|
+
* allowed callers
|
|
187
|
+
* phase
|
|
188
|
+
* input artifacts
|
|
189
|
+
* invocation/result handoffs
|
|
190
|
+
* task-specific execution expectations
|
|
78
191
|
|
|
79
|
-
|
|
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.
|
|
80
208
|
|
|
81
209
|
---
|
|
82
210
|
|
|
83
|
-
##
|
|
211
|
+
## Why teams adopt it
|
|
84
212
|
|
|
85
|
-
###
|
|
213
|
+
### 1. Explicit workflow design
|
|
86
214
|
|
|
87
|
-
|
|
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
|
|
88
255
|
version: 1
|
|
89
|
-
extends: "
|
|
256
|
+
extends: "./base/"
|
|
90
257
|
|
|
91
258
|
system:
|
|
92
259
|
id: my-project
|
|
@@ -100,35 +267,33 @@ system:
|
|
|
100
267
|
- release
|
|
101
268
|
- reflect
|
|
102
269
|
|
|
103
|
-
agents:
|
|
104
|
-
tasks:
|
|
105
|
-
artifacts:
|
|
106
|
-
tools:
|
|
107
|
-
validations:
|
|
108
|
-
handoff_types:
|
|
109
|
-
workflow:
|
|
110
|
-
policies:
|
|
111
|
-
|
|
270
|
+
agents: {}
|
|
271
|
+
tasks: {}
|
|
272
|
+
artifacts: {}
|
|
273
|
+
tools: {}
|
|
274
|
+
validations: {}
|
|
275
|
+
handoff_types: {}
|
|
276
|
+
workflow: {}
|
|
277
|
+
policies: {}
|
|
278
|
+
````
|
|
112
279
|
|
|
113
|
-
|
|
280
|
+
This makes definitions easy to merge, extend, and reference by stable identifiers.
|
|
114
281
|
|
|
115
|
-
|
|
282
|
+
### Single-file format
|
|
116
283
|
|
|
117
|
-
|
|
118
|
-
# agent-contracts.yaml
|
|
284
|
+
````yaml
|
|
119
285
|
version: 1
|
|
120
286
|
system: { ... }
|
|
121
|
-
agents:
|
|
122
|
-
tasks:
|
|
123
|
-
artifacts:
|
|
124
|
-
|
|
287
|
+
agents: { ... }
|
|
288
|
+
tasks: { ... }
|
|
289
|
+
artifacts: { ... }
|
|
290
|
+
````
|
|
125
291
|
|
|
126
|
-
|
|
292
|
+
### Multi-file format
|
|
127
293
|
|
|
128
|
-
|
|
129
|
-
# agent-contracts.yaml
|
|
294
|
+
````yaml
|
|
130
295
|
version: 1
|
|
131
|
-
extends: "
|
|
296
|
+
extends: "./base/"
|
|
132
297
|
system:
|
|
133
298
|
id: my-project
|
|
134
299
|
name: My Agent Workflow
|
|
@@ -142,19 +307,19 @@ validations: { $ref: "./validations.yaml" }
|
|
|
142
307
|
handoff_types: { $ref: "./handoff-types.yaml" }
|
|
143
308
|
workflow: { $ref: "./workflow.yaml" }
|
|
144
309
|
policies: { $ref: "./policies.yaml" }
|
|
145
|
-
|
|
310
|
+
````
|
|
146
311
|
|
|
147
312
|
---
|
|
148
313
|
|
|
149
|
-
##
|
|
314
|
+
## Example: Agent definition
|
|
150
315
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
```yaml
|
|
316
|
+
````yaml
|
|
154
317
|
agents:
|
|
155
|
-
|
|
318
|
+
main-architect:
|
|
156
319
|
role_name: "Architect"
|
|
157
320
|
purpose: "Drive phases, delegate, make gate decisions, integrate audits"
|
|
321
|
+
dispatch_only: true
|
|
322
|
+
mode: read-only
|
|
158
323
|
can_read_artifacts:
|
|
159
324
|
- spec-md
|
|
160
325
|
- codebase
|
|
@@ -171,32 +336,23 @@ agents:
|
|
|
171
336
|
can_return_handoffs:
|
|
172
337
|
- evidence-gate-verdict
|
|
173
338
|
|
|
174
|
-
# General behavioral spec (common across all tasks)
|
|
175
339
|
responsibilities:
|
|
176
340
|
- "Manage phase progression and gate decisions"
|
|
177
341
|
constraints:
|
|
178
342
|
- "Never write code directly"
|
|
179
|
-
rules:
|
|
180
|
-
- id: R-ARCH-001
|
|
181
|
-
description: "Evidence Gates must use structured evaluation criteria"
|
|
182
|
-
severity: mandatory
|
|
183
343
|
|
|
184
|
-
# Extension properties (freely added with x- prefix)
|
|
185
344
|
x-identity: |
|
|
186
345
|
You act as the Architect. You NEVER implement or test directly.
|
|
187
346
|
Instead you delegate to specialist sub-agents.
|
|
188
|
-
|
|
189
|
-
- agent: implementer
|
|
190
|
-
condition: "Backend code, infrastructure, database migrations"
|
|
191
|
-
- agent: test-writer
|
|
192
|
-
condition: "Test code creation and coverage improvement"
|
|
193
|
-
```
|
|
347
|
+
````
|
|
194
348
|
|
|
195
|
-
|
|
349
|
+
---
|
|
196
350
|
|
|
197
|
-
|
|
351
|
+
## Example: Task definition
|
|
352
|
+
|
|
353
|
+
````yaml
|
|
198
354
|
tasks:
|
|
199
|
-
|
|
355
|
+
implement-feature:
|
|
200
356
|
description: "Delegate feature implementation"
|
|
201
357
|
target_agent: implementer
|
|
202
358
|
allowed_from_agents:
|
|
@@ -207,8 +363,6 @@ tasks:
|
|
|
207
363
|
- plan-md
|
|
208
364
|
invocation_handoff: task-delegation
|
|
209
365
|
result_handoff: dependency-evidence
|
|
210
|
-
|
|
211
|
-
# Task-specific behavioral spec
|
|
212
366
|
responsibilities:
|
|
213
367
|
- "Implement all requirements from spec-md"
|
|
214
368
|
execution_steps:
|
|
@@ -221,13 +375,15 @@ tasks:
|
|
|
221
375
|
uses_tool: db-lint
|
|
222
376
|
completion_criteria:
|
|
223
377
|
- "canonical artifacts updated"
|
|
224
|
-
|
|
378
|
+
````
|
|
225
379
|
|
|
226
|
-
|
|
380
|
+
---
|
|
227
381
|
|
|
228
|
-
|
|
382
|
+
## Example: Artifact definition
|
|
383
|
+
|
|
384
|
+
````yaml
|
|
229
385
|
artifacts:
|
|
230
|
-
|
|
386
|
+
spec-md:
|
|
231
387
|
type: document
|
|
232
388
|
description: "Specification document"
|
|
233
389
|
owner: main-architect
|
|
@@ -237,30 +393,29 @@ artifacts:
|
|
|
237
393
|
states: [draft, reviewed, approved]
|
|
238
394
|
required_validations: [spec-semantic-review]
|
|
239
395
|
visibility: internal
|
|
240
|
-
|
|
396
|
+
````
|
|
397
|
+
|
|
398
|
+
---
|
|
241
399
|
|
|
242
|
-
|
|
400
|
+
## Inheritance and merge operators
|
|
243
401
|
|
|
244
|
-
|
|
402
|
+
`agent-contracts` supports shared base definitions with project-level overrides through `extends`.
|
|
245
403
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
extends: "@agent-contracts/base-team"
|
|
404
|
+
````yaml
|
|
405
|
+
extends: "./base/"
|
|
249
406
|
|
|
250
407
|
agents:
|
|
251
|
-
|
|
252
|
-
- id: implementer
|
|
408
|
+
implementer:
|
|
253
409
|
constraints:
|
|
254
410
|
$append:
|
|
255
|
-
- "
|
|
411
|
+
- "Use only approved external libraries"
|
|
256
412
|
|
|
257
|
-
|
|
258
|
-
- id: designer
|
|
413
|
+
designer:
|
|
259
414
|
role_name: "Designer"
|
|
260
415
|
purpose: "UI design"
|
|
261
416
|
|
|
262
417
|
tasks:
|
|
263
|
-
|
|
418
|
+
implement-feature:
|
|
264
419
|
execution_steps:
|
|
265
420
|
$insert_after:
|
|
266
421
|
target: run-db-lint
|
|
@@ -268,46 +423,18 @@ tasks:
|
|
|
268
423
|
- id: run-contract-pipeline
|
|
269
424
|
action: "Run contract pipeline"
|
|
270
425
|
uses_tool: api-pipeline
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
Merge operators:
|
|
274
|
-
|
|
275
|
-
| Operator | Behavior |
|
|
276
|
-
|---|---|
|
|
277
|
-
| `$append` | Append to end of array |
|
|
278
|
-
| `$prepend` | Prepend to beginning of array |
|
|
279
|
-
| `$insert_after` | Insert after element with specified id |
|
|
280
|
-
| `$replace` | Replace entire array/value |
|
|
281
|
-
| `$remove` | Remove element by id |
|
|
282
|
-
| (direct value) | Override scalar field |
|
|
283
|
-
|
|
284
|
-
### Extension Properties (`x-` prefix)
|
|
285
|
-
|
|
286
|
-
Information that cannot be expressed with the standard schema can be written as properties with the `x-` prefix (following OpenAPI conventions).
|
|
287
|
-
|
|
288
|
-
```yaml
|
|
289
|
-
agents:
|
|
290
|
-
- id: main-architect
|
|
291
|
-
# ... standard properties ...
|
|
426
|
+
````
|
|
292
427
|
|
|
293
|
-
|
|
294
|
-
x-identity: |
|
|
295
|
-
You act as the Architect.
|
|
296
|
-
|
|
297
|
-
# Array
|
|
298
|
-
x-role-selection-guide:
|
|
299
|
-
- agent: implementer
|
|
300
|
-
condition: "Backend code, infrastructure"
|
|
428
|
+
Supported merge operators:
|
|
301
429
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
- 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 |
|
|
311
438
|
|
|
312
439
|
---
|
|
313
440
|
|
|
@@ -315,222 +442,135 @@ agents:
|
|
|
315
442
|
|
|
316
443
|
### Installation
|
|
317
444
|
|
|
318
|
-
|
|
319
|
-
npm install -g agent-contracts
|
|
320
|
-
npm install -D agent-contracts
|
|
321
|
-
npx agent-contracts
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
### Commands
|
|
325
|
-
|
|
326
|
-
| Command | Description |
|
|
327
|
-
|---|---|
|
|
328
|
-
| `agent-contracts resolve [dir]` | Resolve `extends` inheritance and output resolved YAML |
|
|
329
|
-
| `agent-contracts validate [dir]` | Schema validation + reference integrity check. Exit 1 on errors |
|
|
330
|
-
| `agent-contracts lint [dir]` | Run semantic lint. Display diagnostics and control exit code by severity |
|
|
331
|
-
| `agent-contracts render [dir]` | Generate prompt md from resolved YAML + Handlebars templates |
|
|
332
|
-
| `agent-contracts render [dir] --check` | Drift check. Detect diffs without writing files; exit 1 if diffs found |
|
|
333
|
-
| `agent-contracts check [dir]` | Run resolve → validate → lint → render --check in sequence (for CI) |
|
|
334
|
-
|
|
335
|
-
### Options for `render` / `check`
|
|
336
|
-
|
|
337
|
-
| Option | Description |
|
|
338
|
-
|---|---|
|
|
339
|
-
| `--template-dir <path>` | Handlebars template directory (required) |
|
|
340
|
-
| `--output-dir <path>` | Output directory (required) |
|
|
341
|
-
|
|
342
|
-
### Common Options
|
|
343
|
-
|
|
344
|
-
| Option | Description |
|
|
345
|
-
|---|---|
|
|
346
|
-
| `--format json\|text` | Specify output format |
|
|
347
|
-
| `--quiet` | Show errors only |
|
|
348
|
-
| `--strict` | Treat warnings as exit 1 |
|
|
349
|
-
|
|
350
|
-
### Usage Examples
|
|
351
|
-
|
|
352
|
-
```bash
|
|
353
|
-
# Output resolved YAML to stdout
|
|
354
|
-
agent-contracts resolve ./my-project
|
|
355
|
-
|
|
356
|
-
# Output resolved YAML to file
|
|
357
|
-
agent-contracts resolve ./my-project -o resolved.yaml
|
|
358
|
-
|
|
359
|
-
# Schema validation
|
|
360
|
-
agent-contracts validate ./my-project
|
|
361
|
-
|
|
362
|
-
# Semantic lint (JSON output)
|
|
363
|
-
agent-contracts lint ./my-project --format json
|
|
364
|
-
|
|
365
|
-
# Generate prompt md
|
|
366
|
-
agent-contracts render ./my-project --template-dir ./templates --output-dir ./rendered
|
|
367
|
-
|
|
368
|
-
# Drift check in CI
|
|
369
|
-
agent-contracts render ./my-project --template-dir ./templates --output-dir ./rendered --check
|
|
445
|
+
````bash
|
|
446
|
+
npm install -g agent-contracts
|
|
447
|
+
npm install -D agent-contracts
|
|
448
|
+
npx agent-contracts
|
|
449
|
+
````
|
|
370
450
|
|
|
371
|
-
|
|
372
|
-
agent-contracts check ./my-project --template-dir ./templates --output-dir ./rendered --strict
|
|
373
|
-
```
|
|
451
|
+
### Main commands
|
|
374
452
|
|
|
375
|
-
|
|
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 |
|
|
376
460
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
agent-contracts resolve ./base/ -o ./team/base-resolved.yaml
|
|
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.
|
|
380
463
|
|
|
381
|
-
|
|
382
|
-
agent-contracts resolve ./team/ -o ./project/team-resolved.yaml
|
|
464
|
+
### Common usage
|
|
383
465
|
|
|
384
|
-
|
|
385
|
-
agent-contracts resolve
|
|
386
|
-
|
|
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
|
+
````
|
|
387
474
|
|
|
388
475
|
---
|
|
389
476
|
|
|
390
|
-
##
|
|
477
|
+
## Config-driven rendering
|
|
391
478
|
|
|
392
|
-
|
|
393
|
-
1. Define DSL in YAML
|
|
394
|
-
├── agent-contracts.yaml (entry point; references base via extends)
|
|
395
|
-
└── agents.yaml, tasks.yaml, ... (for multi-file format)
|
|
479
|
+
Rendering is configured via `agent-contracts.config.yaml`.
|
|
396
480
|
|
|
397
|
-
|
|
398
|
-
|
|
481
|
+
````yaml
|
|
482
|
+
dsl: ./agent-contracts.yaml
|
|
399
483
|
|
|
400
|
-
|
|
401
|
-
|
|
484
|
+
renders:
|
|
485
|
+
- template: ./templates/agent-prompt.md.hbs
|
|
486
|
+
context: agent
|
|
487
|
+
output: ./output/{agent.id}.md
|
|
402
488
|
|
|
403
|
-
|
|
404
|
-
|
|
489
|
+
- template: ./templates/overview.md.hbs
|
|
490
|
+
context: system
|
|
491
|
+
output: ./output/overview.md
|
|
492
|
+
````
|
|
405
493
|
|
|
406
|
-
|
|
407
|
-
resolved YAML + Handlebars templates → generate agent prompts (md)
|
|
494
|
+
This lets you generate static outputs for:
|
|
408
495
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
496
|
+
* agent prompts
|
|
497
|
+
* task specs
|
|
498
|
+
* overviews
|
|
499
|
+
* artifact docs
|
|
500
|
+
* validation docs
|
|
501
|
+
* workflow docs
|
|
412
502
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
## Prompt Rendering
|
|
416
|
-
|
|
417
|
-
Generates one static Markdown file per agent from resolved YAML and Handlebars templates. Files are written to the directory specified by `render --output-dir`. The output serves as the system prompt or instruction document for each agent, containing its responsibilities, constraints, available tools, and delegatable tasks — all derived from the YAML definitions.
|
|
418
|
-
|
|
419
|
-
### Template Context
|
|
503
|
+
all from the same resolved DSL.
|
|
420
504
|
|
|
421
|
-
|
|
422
|
-
|---|---|
|
|
423
|
-
| **global context** | Entire resolved YAML (system, agents, tasks, artifacts, etc. + extension properties) |
|
|
424
|
-
| **per-agent context** | Each agent + related tasks + related handoff_types + related artifacts/tools |
|
|
505
|
+
---
|
|
425
506
|
|
|
426
|
-
|
|
507
|
+
## Validation model
|
|
427
508
|
|
|
428
|
-
|
|
429
|
-
# {{agent.role_name}}
|
|
509
|
+
`agent-contracts` validates your system in multiple layers.
|
|
430
510
|
|
|
431
|
-
|
|
511
|
+
### Schema validation
|
|
432
512
|
|
|
433
|
-
|
|
513
|
+
Checks:
|
|
434
514
|
|
|
435
|
-
|
|
515
|
+
* required fields
|
|
516
|
+
* types
|
|
517
|
+
* enums
|
|
518
|
+
* handoff payload shape
|
|
519
|
+
* invalid custom properties without `x-` prefix
|
|
436
520
|
|
|
437
|
-
|
|
438
|
-
- {{this}}
|
|
439
|
-
{{/each}}
|
|
521
|
+
### Reference integrity
|
|
440
522
|
|
|
441
|
-
|
|
442
|
-
## Identity
|
|
523
|
+
Checks:
|
|
443
524
|
|
|
444
|
-
|
|
445
|
-
|
|
525
|
+
* cross-entity references
|
|
526
|
+
* owner / producer / editor / consumer validity
|
|
527
|
+
* handoff and payload consistency
|
|
528
|
+
* permission alignment between agents and artifacts
|
|
446
529
|
|
|
447
|
-
|
|
448
|
-
## Role Selection Guide
|
|
530
|
+
### Semantic lint
|
|
449
531
|
|
|
450
|
-
|
|
451
|
-
- **{{this.agent}}**: {{this.condition}}
|
|
452
|
-
{{/each}}
|
|
453
|
-
{{/if}}
|
|
454
|
-
```
|
|
532
|
+
Checks:
|
|
455
533
|
|
|
456
|
-
|
|
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
|
|
457
541
|
|
|
458
542
|
---
|
|
459
543
|
|
|
460
|
-
##
|
|
461
|
-
|
|
462
|
-
agent-contracts separates validation into 3 layers.
|
|
463
|
-
|
|
464
|
-
### A. Schema Validation (Zod + Spectral)
|
|
465
|
-
|
|
466
|
-
- Type, required field, and enum validation
|
|
467
|
-
- Detection of custom properties without `x-` prefix
|
|
468
|
-
- Handoff payload shape validation
|
|
469
|
-
- Naming conventions
|
|
544
|
+
## Best used with runtime frameworks
|
|
470
545
|
|
|
471
|
-
|
|
546
|
+
`agent-contracts` works well alongside runtime frameworks and internal agent infrastructure.
|
|
472
547
|
|
|
473
|
-
|
|
474
|
-
- Existence check for owner, producers, editors, consumers references
|
|
548
|
+
A practical model is:
|
|
475
549
|
|
|
476
|
-
|
|
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
|
|
477
554
|
|
|
478
|
-
|
|
479
|
-
- Bidirectional consistency between `allowed_from_agents` and `can_invoke_agents`
|
|
480
|
-
- Validation coverage analysis (e.g., whether code artifacts have mechanical validation)
|
|
481
|
-
- Workflow graph completeness (existence of release / audit roots)
|
|
482
|
-
- Design rule validation on post-merge resolved definitions
|
|
555
|
+
That separation keeps runtime concerns and architecture concerns from being mixed together.
|
|
483
556
|
|
|
484
557
|
---
|
|
485
558
|
|
|
486
|
-
##
|
|
559
|
+
## Tech stack
|
|
487
560
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
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 |
|
|
498
571
|
|
|
499
572
|
---
|
|
500
573
|
|
|
501
|
-
## Tech Stack
|
|
502
|
-
|
|
503
|
-
| Category | Choice |
|
|
504
|
-
|---|---|
|
|
505
|
-
| Language | TypeScript 5.x (ESM, strict mode) |
|
|
506
|
-
| Schema | Zod |
|
|
507
|
-
| YAML parsing | yaml (npm) |
|
|
508
|
-
| Lint | Spectral (Stoplight) |
|
|
509
|
-
| Templates | Handlebars |
|
|
510
|
-
| CLI | commander |
|
|
511
|
-
| Testing | Vitest |
|
|
512
|
-
| Build | tsup |
|
|
513
|
-
|
|
514
|
-
---
|
|
515
|
-
|
|
516
|
-
## Project Structure
|
|
517
|
-
|
|
518
|
-
```text
|
|
519
|
-
agent-contracts/
|
|
520
|
-
src/
|
|
521
|
-
schema/ # Zod schema definitions
|
|
522
|
-
loader/ # YAML loading and integration
|
|
523
|
-
resolver/ # extends resolution + id-based deep merge
|
|
524
|
-
validator/ # Schema Validation + reference integrity
|
|
525
|
-
linter/ # Semantic Lint (TypeScript custom rules)
|
|
526
|
-
renderer/ # Prompt Renderer (Handlebars)
|
|
527
|
-
cli/ # CLI entry point + commands
|
|
528
|
-
spectral/ # Spectral rulesets
|
|
529
|
-
schemas/ # JSON Schema derived from Zod
|
|
530
|
-
test/
|
|
531
|
-
fixtures/ # Test YAML samples
|
|
532
|
-
```
|
|
533
|
-
|
|
534
574
|
## License
|
|
535
575
|
|
|
536
576
|
MIT
|