agent-contracts 0.5.1 → 0.6.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 CHANGED
@@ -1,6 +1,9 @@
1
1
 
2
2
  # agent-contracts
3
3
 
4
+ [![npm version](https://img.shields.io/npm/v/agent-contracts.svg)](https://www.npmjs.com/package/agent-contracts)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
4
7
  **Design multi-agent systems as contracts.**
5
8
 
6
9
  `agent-contracts` is a toolkit for declaratively defining multi-agent development workflows in **YAML DSL**, with **static validation, semantic linting, and prompt rendering**.
@@ -116,7 +119,7 @@ version: 1
116
119
  system:
117
120
  id: my-project
118
121
  name: My Agent Workflow
119
- default_phase_order: [design, implement]
122
+ default_workflow_order: [design, implement]
120
123
 
121
124
  agents:
122
125
  architect:
@@ -133,7 +136,7 @@ tasks:
133
136
  description: "Delegate feature implementation"
134
137
  target_agent: implementer
135
138
  allowed_from_agents: [architect]
136
- phase: implement
139
+ workflow: implement
137
140
  input_artifacts: [spec-md]
138
141
  invocation_handoff: task-delegation
139
142
  result_handoff: implementation-result
@@ -184,7 +187,7 @@ A **Task** defines a delegatable unit of work:
184
187
 
185
188
  * target agent
186
189
  * allowed callers
187
- * phase
190
+ * workflow
188
191
  * input artifacts
189
192
  * invocation/result handoffs
190
193
  * task-specific execution expectations
@@ -242,6 +245,7 @@ Design regressions become testable.
242
245
  * **Artifact ownership and lifecycle modeling**
243
246
  * **Config-driven prompt rendering**
244
247
  * **Inheritance with merge operators via `extends`**
248
+ * **Flexible file splitting** via `$ref` (replacement) and `$refs` (import + deep-merge)
245
249
  * **JSON Schema for editor support and external tooling**
246
250
  * **CI-friendly workflow checks**
247
251
 
@@ -258,7 +262,7 @@ extends: "./base/"
258
262
  system:
259
263
  id: my-project
260
264
  name: My Agent Workflow
261
- default_phase_order:
265
+ default_workflow_order:
262
266
  - analyze
263
267
  - specify
264
268
  - plan
@@ -289,7 +293,7 @@ tasks: { ... }
289
293
  artifacts: { ... }
290
294
  ````
291
295
 
292
- ### Multi-file format
296
+ ### Multi-file format (section-level `$ref`)
293
297
 
294
298
  ````yaml
295
299
  version: 1
@@ -297,7 +301,7 @@ extends: "./base/"
297
301
  system:
298
302
  id: my-project
299
303
  name: My Agent Workflow
300
- default_phase_order: [analyze, specify, plan, implement, audit, release, reflect]
304
+ default_workflow_order: [analyze, specify, plan, implement, audit, release, reflect]
301
305
 
302
306
  agents: { $ref: "./agents.yaml" }
303
307
  tasks: { $ref: "./tasks.yaml" }
@@ -309,6 +313,91 @@ workflow: { $ref: "./workflow.yaml" }
309
313
  policies: { $ref: "./policies.yaml" }
310
314
  ````
311
315
 
316
+ ### Per-entry `$ref`
317
+
318
+ `$ref` can be used at any object position. This allows splitting individual entries into separate files:
319
+
320
+ ````yaml
321
+ agents:
322
+ architect: { $ref: "./agents/architect.yaml" }
323
+ implementer: { $ref: "./agents/implementer.yaml" }
324
+ test-writer: { $ref: "./agents/test-writer.yaml" }
325
+ ````
326
+
327
+ Each referenced file contains the agent definition directly (without the key):
328
+
329
+ ````yaml
330
+ # agents/architect.yaml
331
+ role_name: "Architect"
332
+ purpose: "Drive phases and delegate work"
333
+ can_invoke_agents: [implementer]
334
+ ````
335
+
336
+ ### Directory `$ref`
337
+
338
+ When `$ref` points to a directory, all `*.yaml` / `*.yml` files in the directory are loaded and merged:
339
+
340
+ ````yaml
341
+ agents: { $ref: "./agents/" }
342
+ ````
343
+
344
+ Each file in the directory contains one or more keyed entries:
345
+
346
+ ````yaml
347
+ # agents/architect.yaml
348
+ architect:
349
+ role_name: "Architect"
350
+ purpose: "Drive phases and delegate work"
351
+ ````
352
+
353
+ Files are loaded in alphabetical order. Conflicting leaf values across files result in an error.
354
+
355
+ ### `$refs` (import and merge)
356
+
357
+ `$refs` imports multiple files and **deep-merges** them into the containing map.
358
+ Unlike `$ref` (which replaces an object entirely), `$refs` allows mixing inline definitions with external files.
359
+
360
+ ````yaml
361
+ agents:
362
+ inline-agent:
363
+ role_name: "Inline Agent"
364
+ purpose: "Defined right here"
365
+ $refs:
366
+ - "./agents/architect.yaml"
367
+ - "./agents/implementer.yaml"
368
+ - "./more-agents/" # directories are also supported
369
+ ````
370
+
371
+ Each referenced file uses the same keyed format:
372
+
373
+ ````yaml
374
+ # agents/architect.yaml
375
+ architect:
376
+ role_name: "Architect"
377
+ purpose: "Drive phases and delegate work"
378
+ ````
379
+
380
+ `$refs` can also be used at the root level to compose a DSL from multiple aspect-oriented files:
381
+
382
+ ````yaml
383
+ version: 1
384
+ system:
385
+ id: my-project
386
+ name: My Agent Workflow
387
+ default_workflow_order: [analyze, implement]
388
+ $refs:
389
+ - "./agents-core.yaml" # agents + artifacts definitions
390
+ - "./agents-constraints.yaml" # constraints for the same agents
391
+ - "./tasks.yaml"
392
+ ````
393
+
394
+ Overlapping map keys are deep-merged recursively. Conflicting leaf values (scalar or array) result in an error.
395
+
396
+ | Directive | Type | Behavior |
397
+ | --------- | ------ | -------------------------------------------------------- |
398
+ | `$ref` | string | Replace the object at that position with file contents |
399
+ | `$refs` | array | Import files and deep-merge into the containing map |
400
+
312
401
  ---
313
402
 
314
403
  ## Example: Agent definition
@@ -357,7 +446,7 @@ tasks:
357
446
  target_agent: implementer
358
447
  allowed_from_agents:
359
448
  - main-architect
360
- phase: implement
449
+ workflow: implement
361
450
  input_artifacts:
362
451
  - spec-md
363
452
  - plan-md
@@ -368,15 +457,21 @@ tasks:
368
457
  execution_steps:
369
458
  - id: read-specs
370
459
  action: "Read spec-md and design-docs"
460
+ description: "Read all relevant specification and design documents"
371
461
  - id: implement
372
462
  action: "Implement changes in codebase"
373
463
  - id: run-db-lint
374
464
  action: "Run db-lint"
465
+ description: "Run database schema linter to check migrations"
375
466
  uses_tool: db-lint
467
+ x-timeout: 120
376
468
  completion_criteria:
377
469
  - "canonical artifacts updated"
378
470
  ````
379
471
 
472
+ `x-` prefixed custom properties work at any nesting level — including inside
473
+ `execution_steps`, `rules`, `workflow.steps`, and other nested objects.
474
+
380
475
  ---
381
476
 
382
477
  ## Example: Artifact definition
@@ -516,7 +611,9 @@ Checks:
516
611
  * types
517
612
  * enums
518
613
  * handoff payload shape
519
- * invalid custom properties without `x-` prefix
614
+ * invalid custom properties without `x-` prefix (checked at all nesting levels)
615
+
616
+ Custom properties with `x-` prefix are allowed on any object in the DSL — top-level entities (agents, tasks, artifacts, …), nested objects (rules, execution steps, workflow steps, …), and the root DSL itself.
520
617
 
521
618
  ### Reference integrity
522
619