agent-contracts 0.16.0 → 0.16.2

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
@@ -1005,6 +1005,10 @@ VarsSubstitutionError: Undefined variable "repo_url" in value "Repository: ${var
1005
1005
 
1006
1006
  ## CLI
1007
1007
 
1008
+ For the full CLI reference with all commands, options, arguments, exit codes, and AI agent policies, see the [CLI Reference](docs/cli-reference.md).
1009
+
1010
+ The CLI contract specification is defined in [`cli-contract.yaml`](cli-contract.yaml) using [CLI Contracts](https://github.com/foo-ogawa/cli-contracts).
1011
+
1008
1012
  ### Installation
1009
1013
 
1010
1014
  ````bash
@@ -0,0 +1,610 @@
1
+ # yaml-language-server: $schema=./node_modules/cli-contracts/schemas/cli-contract.schema.json
2
+ cliContracts: 0.1.0
3
+
4
+ info:
5
+ title: agent-contracts CLI
6
+ version: 0.16.2
7
+ description: >-
8
+ Declarative YAML DSL toolkit for defining, validating, and rendering
9
+ multi-agent development workflows. Provides static validation,
10
+ semantic linting, prompt rendering, guardrail generation, and
11
+ completeness scoring for agent contract definitions.
12
+ license:
13
+ name: MIT
14
+ contact:
15
+ name: foo-ogawa
16
+ url: https://github.com/foo-ogawa/agent-contracts
17
+
18
+ commandSets:
19
+ agent-contracts:
20
+ summary: Agent contracts tooling — validate, lint, render DSL files.
21
+ executable: agent-contracts
22
+
23
+ globalOptions:
24
+ - name: version
25
+ aliases: [V]
26
+ description: Print version and exit.
27
+ schema:
28
+ type: boolean
29
+
30
+ - name: help
31
+ aliases: [h]
32
+ description: Show help and exit.
33
+ schema:
34
+ type: boolean
35
+
36
+ commands:
37
+ # ── resolve ───────────────────────────────────────
38
+ resolve:
39
+ summary: Resolve DSL (load + merge extends) and output YAML.
40
+ description: >-
41
+ Loads the agent-contracts DSL file, merges all extends
42
+ inheritance chains, substitutes variables from config, and
43
+ outputs the fully resolved result as YAML or JSON.
44
+ usage:
45
+ - agent-contracts resolve
46
+ - agent-contracts resolve path/to/agent-contracts.yaml
47
+ - agent-contracts resolve --format json
48
+ - agent-contracts resolve --expand-defaults
49
+ - agent-contracts resolve -c agent-contracts.config.yaml
50
+
51
+ arguments:
52
+ - name: dir
53
+ index: 0
54
+ required: false
55
+ description: Path to agent-contracts.yaml.
56
+ schema:
57
+ type: string
58
+ default: agent-contracts.yaml
59
+ file:
60
+ mode: read
61
+ exists: true
62
+ mediaType: application/yaml
63
+ encoding: utf-8
64
+
65
+ options:
66
+ - name: config
67
+ aliases: [c]
68
+ description: Path to agent-contracts.config.yaml.
69
+ valueName: path
70
+ schema:
71
+ type: string
72
+ file:
73
+ mode: read
74
+ exists: false
75
+ mediaType: application/yaml
76
+ encoding: utf-8
77
+
78
+ - name: team
79
+ description: Limit to one team (multi-team config only).
80
+ valueName: id
81
+ schema:
82
+ type: string
83
+
84
+ - name: format
85
+ description: Output format.
86
+ valueName: format
87
+ schema:
88
+ type: string
89
+ enum: [text, json]
90
+ default: text
91
+
92
+ - name: expand-defaults
93
+ description: >-
94
+ Expand all Zod default values in output. Fields like
95
+ required_validations, tags, and can_read_artifacts are
96
+ written explicitly instead of relying on schema defaults.
97
+ schema:
98
+ type: boolean
99
+ default: false
100
+
101
+ exits:
102
+ '0':
103
+ description: Resolved DSL output successfully.
104
+ stdout:
105
+ format: text
106
+
107
+ '1':
108
+ description: Resolution failed (file not found, parse error, or config error).
109
+ stderr:
110
+ format: text
111
+
112
+ x-agent:
113
+ riskLevel: low
114
+ requiresConfirmation: false
115
+ idempotent: true
116
+ sideEffects: []
117
+
118
+ # ── validate ──────────────────────────────────────
119
+ validate:
120
+ summary: Validate DSL against schema and check references.
121
+ description: >-
122
+ Validates the resolved DSL against the Zod schema, checks
123
+ inter-entity references (agent→task, task→artifact, etc.),
124
+ and validates handoff schemas. Reports diagnostics with
125
+ severity levels.
126
+ usage:
127
+ - agent-contracts validate
128
+ - agent-contracts validate path/to/agent-contracts.yaml
129
+ - agent-contracts validate --strict
130
+ - agent-contracts validate --format json
131
+ - agent-contracts validate --quiet
132
+
133
+ arguments:
134
+ - name: dir
135
+ index: 0
136
+ required: false
137
+ description: Path to agent-contracts.yaml.
138
+ schema:
139
+ type: string
140
+ default: agent-contracts.yaml
141
+ file:
142
+ mode: read
143
+ exists: true
144
+ mediaType: application/yaml
145
+ encoding: utf-8
146
+
147
+ options:
148
+ - name: config
149
+ aliases: [c]
150
+ description: Path to agent-contracts.config.yaml.
151
+ valueName: path
152
+ schema:
153
+ type: string
154
+ file:
155
+ mode: read
156
+ exists: false
157
+ mediaType: application/yaml
158
+ encoding: utf-8
159
+
160
+ - name: team
161
+ description: Limit to one team (multi-team config only).
162
+ valueName: id
163
+ schema:
164
+ type: string
165
+
166
+ - name: format
167
+ description: Diagnostic output format.
168
+ valueName: format
169
+ schema:
170
+ type: string
171
+ enum: [text, json]
172
+ default: text
173
+
174
+ - name: quiet
175
+ description: Suppress output on success.
176
+ schema:
177
+ type: boolean
178
+ default: false
179
+
180
+ - name: strict
181
+ description: Treat warnings as errors.
182
+ schema:
183
+ type: boolean
184
+ default: false
185
+
186
+ exits:
187
+ '0':
188
+ description: Validation passed. No errors found.
189
+ stdout:
190
+ format: text
191
+
192
+ '1':
193
+ description: Validation failed or unexpected error.
194
+ stderr:
195
+ format: text
196
+
197
+ x-agent:
198
+ riskLevel: low
199
+ requiresConfirmation: false
200
+ idempotent: true
201
+ sideEffects: []
202
+
203
+ # ── lint ──────────────────────────────────────────
204
+ lint:
205
+ summary: Run semantic lint rules on resolved DSL.
206
+ description: >-
207
+ Runs TypeScript-based semantic lint rules and Spectral rules
208
+ on the resolved DSL. Checks for best-practice violations,
209
+ naming conventions, and structural issues beyond schema
210
+ conformance.
211
+ usage:
212
+ - agent-contracts lint
213
+ - agent-contracts lint path/to/agent-contracts.yaml
214
+ - agent-contracts lint --strict
215
+ - agent-contracts lint --format json
216
+
217
+ arguments:
218
+ - name: dir
219
+ index: 0
220
+ required: false
221
+ description: Path to agent-contracts.yaml.
222
+ schema:
223
+ type: string
224
+ default: agent-contracts.yaml
225
+ file:
226
+ mode: read
227
+ exists: true
228
+ mediaType: application/yaml
229
+ encoding: utf-8
230
+
231
+ options:
232
+ - name: config
233
+ aliases: [c]
234
+ description: Path to agent-contracts.config.yaml.
235
+ valueName: path
236
+ schema:
237
+ type: string
238
+ file:
239
+ mode: read
240
+ exists: false
241
+ mediaType: application/yaml
242
+ encoding: utf-8
243
+
244
+ - name: team
245
+ description: Limit to one team (multi-team config only).
246
+ valueName: id
247
+ schema:
248
+ type: string
249
+
250
+ - name: format
251
+ description: Output format.
252
+ valueName: format
253
+ schema:
254
+ type: string
255
+ enum: [text, json]
256
+ default: text
257
+
258
+ - name: quiet
259
+ description: Suppress output on success.
260
+ schema:
261
+ type: boolean
262
+ default: false
263
+
264
+ - name: strict
265
+ description: Treat warnings as errors.
266
+ schema:
267
+ type: boolean
268
+ default: false
269
+
270
+ exits:
271
+ '0':
272
+ description: Lint passed. No errors or warnings.
273
+ stdout:
274
+ format: text
275
+
276
+ '1':
277
+ description: Lint failed or unexpected error.
278
+ stderr:
279
+ format: text
280
+
281
+ x-agent:
282
+ riskLevel: low
283
+ requiresConfirmation: false
284
+ idempotent: true
285
+ sideEffects: []
286
+
287
+ # ── render ────────────────────────────────────────
288
+ render:
289
+ summary: Render resolved DSL with Handlebars templates.
290
+ description: >-
291
+ Renders output files from the resolved DSL using Handlebars
292
+ templates configured in agent-contracts.config.yaml. Supports
293
+ drift detection via --check mode. Requires a config file.
294
+ usage:
295
+ - agent-contracts render -c agent-contracts.config.yaml
296
+ - agent-contracts render -c agent-contracts.config.yaml --check
297
+ - agent-contracts render --quiet
298
+
299
+ options:
300
+ - name: config
301
+ aliases: [c]
302
+ description: Path to agent-contracts.config.yaml.
303
+ valueName: path
304
+ schema:
305
+ type: string
306
+ file:
307
+ mode: read
308
+ exists: false
309
+ mediaType: application/yaml
310
+ encoding: utf-8
311
+
312
+ - name: team
313
+ description: Limit to one team (multi-team config only).
314
+ valueName: id
315
+ schema:
316
+ type: string
317
+
318
+ - name: check
319
+ description: Check for drift without writing files.
320
+ schema:
321
+ type: boolean
322
+ default: false
323
+
324
+ - name: quiet
325
+ description: Suppress output on success.
326
+ schema:
327
+ type: boolean
328
+ default: false
329
+
330
+ exits:
331
+ '0':
332
+ description: Render succeeded (or no drift detected in --check mode).
333
+ stdout:
334
+ format: text
335
+
336
+ '1':
337
+ description: >-
338
+ Render failed, config not found, schema validation failed,
339
+ or drift detected in --check mode.
340
+ stderr:
341
+ format: text
342
+
343
+ x-agent:
344
+ riskLevel: medium
345
+ requiresConfirmation: false
346
+ idempotent: true
347
+ sideEffects:
348
+ - file_write
349
+ recommendedBeforeUse:
350
+ - Ensure agent-contracts.config.yaml exists with render targets.
351
+ - Run validate first to confirm DSL is valid.
352
+
353
+ # ── check ─────────────────────────────────────────
354
+ check:
355
+ summary: Run full pipeline — resolve, validate, lint, render --check.
356
+ description: >-
357
+ Executes the complete verification pipeline in order: resolve
358
+ DSL, validate schema and references, run lint rules, and check
359
+ for render drift. Also verifies cross-team interface imports
360
+ and team-interface.yaml drift when applicable.
361
+ usage:
362
+ - agent-contracts check -c agent-contracts.config.yaml
363
+ - agent-contracts check -c agent-contracts.config.yaml --strict
364
+ - agent-contracts check --format json --quiet
365
+
366
+ options:
367
+ - name: config
368
+ aliases: [c]
369
+ description: Path to agent-contracts.config.yaml.
370
+ valueName: path
371
+ schema:
372
+ type: string
373
+ file:
374
+ mode: read
375
+ exists: false
376
+ mediaType: application/yaml
377
+ encoding: utf-8
378
+
379
+ - name: team
380
+ description: Limit to one team (multi-team config only).
381
+ valueName: id
382
+ schema:
383
+ type: string
384
+
385
+ - name: format
386
+ description: Diagnostic output format.
387
+ valueName: format
388
+ schema:
389
+ type: string
390
+ enum: [text, json]
391
+ default: text
392
+
393
+ - name: quiet
394
+ description: Suppress output on success.
395
+ schema:
396
+ type: boolean
397
+ default: false
398
+
399
+ - name: strict
400
+ description: Treat warnings as errors.
401
+ schema:
402
+ type: boolean
403
+ default: false
404
+
405
+ exits:
406
+ '0':
407
+ description: All checks passed.
408
+ stdout:
409
+ format: text
410
+
411
+ '1':
412
+ description: >-
413
+ One or more checks failed — validation errors, lint errors,
414
+ render drift, or missing interface files.
415
+ stderr:
416
+ format: text
417
+
418
+ x-agent:
419
+ riskLevel: low
420
+ requiresConfirmation: false
421
+ idempotent: true
422
+ sideEffects: []
423
+ recommendedBeforeUse:
424
+ - Ensure agent-contracts.config.yaml exists.
425
+
426
+ # ── score ─────────────────────────────────────────
427
+ score:
428
+ summary: Calculate DSL completeness score.
429
+ description: >-
430
+ Evaluates the resolved DSL across 7 dimensions including
431
+ artifact validation coverage, task validation coverage,
432
+ guardrail policy coverage, workflow validation integration,
433
+ schema completeness, cross-reference bidirectionality, and
434
+ guardrail scope resolution. Returns a score out of 100 with
435
+ optional CI gating via --threshold.
436
+ usage:
437
+ - agent-contracts score
438
+ - agent-contracts score --format json
439
+ - agent-contracts score --threshold 70
440
+ - agent-contracts score -c agent-contracts.config.yaml
441
+
442
+ arguments:
443
+ - name: dir
444
+ index: 0
445
+ required: false
446
+ description: Path to agent-contracts.yaml.
447
+ schema:
448
+ type: string
449
+ default: agent-contracts.yaml
450
+ file:
451
+ mode: read
452
+ exists: true
453
+ mediaType: application/yaml
454
+ encoding: utf-8
455
+
456
+ options:
457
+ - name: config
458
+ aliases: [c]
459
+ description: Path to agent-contracts.config.yaml.
460
+ valueName: path
461
+ schema:
462
+ type: string
463
+ file:
464
+ mode: read
465
+ exists: false
466
+ mediaType: application/yaml
467
+ encoding: utf-8
468
+
469
+ - name: team
470
+ description: Limit to one team (multi-team config only).
471
+ valueName: id
472
+ schema:
473
+ type: string
474
+
475
+ - name: format
476
+ description: Output format.
477
+ valueName: format
478
+ schema:
479
+ type: string
480
+ enum: [text, json]
481
+ default: text
482
+
483
+ - name: threshold
484
+ description: Minimum score; exit 1 if below (for CI gates).
485
+ valueName: number
486
+ schema:
487
+ type: integer
488
+
489
+ exits:
490
+ '0':
491
+ description: Score calculated (and above threshold if specified).
492
+ stdout:
493
+ format: text
494
+
495
+ '1':
496
+ description: >-
497
+ Score below threshold, schema validation failed,
498
+ or unexpected error.
499
+ stderr:
500
+ format: text
501
+
502
+ x-agent:
503
+ riskLevel: low
504
+ requiresConfirmation: false
505
+ idempotent: true
506
+ sideEffects: []
507
+
508
+ # ── generate ──────────────────────────────────────
509
+ generate:
510
+ summary: Generate guardrail or interface artifacts from DSL.
511
+ description: >-
512
+ Generates runtime artifacts from the DSL. When type is
513
+ "guardrails" (default), produces guardrail binding files from
514
+ DSL, policies, and software bindings. When type is "interface",
515
+ generates a team interface YAML/JSON file from the DSL's
516
+ team_interface section.
517
+ usage:
518
+ - agent-contracts generate -c agent-contracts.config.yaml
519
+ - agent-contracts generate guardrails -c agent-contracts.config.yaml
520
+ - agent-contracts generate guardrails --binding cursor-rules
521
+ - agent-contracts generate guardrails --dry-run
522
+ - agent-contracts generate interface -c agent-contracts.config.yaml
523
+ - agent-contracts generate interface --format json
524
+ - agent-contracts generate interface -o team-interface.yaml --dry-run
525
+
526
+ arguments:
527
+ - name: type
528
+ index: 0
529
+ required: false
530
+ description: Type of artifacts to generate.
531
+ schema:
532
+ type: string
533
+ enum: [guardrails, interface]
534
+ default: guardrails
535
+
536
+ options:
537
+ - name: config
538
+ aliases: [c]
539
+ description: Path to agent-contracts.config.yaml.
540
+ valueName: path
541
+ schema:
542
+ type: string
543
+ file:
544
+ mode: read
545
+ exists: false
546
+ mediaType: application/yaml
547
+ encoding: utf-8
548
+
549
+ - name: team
550
+ description: Limit to one team (multi-team config only).
551
+ valueName: id
552
+ schema:
553
+ type: string
554
+
555
+ - name: binding
556
+ description: Filter to specific software binding(s). Guardrails type only.
557
+ valueName: name
558
+ repeatable: true
559
+ schema:
560
+ type: string
561
+
562
+ - name: output
563
+ aliases: [o]
564
+ description: Output path for generated team interface. Interface type only.
565
+ valueName: path
566
+ schema:
567
+ type: string
568
+
569
+ - name: format
570
+ description: Output format for team interface (yaml or json). Interface type only.
571
+ valueName: format
572
+ schema:
573
+ type: string
574
+ enum: [yaml, json]
575
+ default: yaml
576
+
577
+ - name: dry-run
578
+ description: Print what would be generated without writing files.
579
+ schema:
580
+ type: boolean
581
+ default: false
582
+
583
+ - name: quiet
584
+ description: Suppress output on success.
585
+ schema:
586
+ type: boolean
587
+ default: false
588
+
589
+ exits:
590
+ '0':
591
+ description: Generation succeeded.
592
+ stdout:
593
+ format: text
594
+
595
+ '1':
596
+ description: >-
597
+ Generation failed — unknown type, schema validation failed,
598
+ config not found, or error-level diagnostics.
599
+ stderr:
600
+ format: text
601
+
602
+ x-agent:
603
+ riskLevel: medium
604
+ requiresConfirmation: false
605
+ idempotent: true
606
+ sideEffects:
607
+ - file_write
608
+ recommendedBeforeUse:
609
+ - Ensure agent-contracts.config.yaml exists with binding definitions.
610
+ - Run validate first to confirm DSL is valid.
package/dist/cli.js CHANGED
@@ -55209,7 +55209,9 @@ function buildPerAgentContext(dsl, agent) {
55209
55209
  const handoffKinds = /* @__PURE__ */ new Set([
55210
55210
  ...agent.can_return_handoffs,
55211
55211
  ...receivableTasks.map((t3) => t3.invocation_handoff),
55212
- ...receivableTasks.map((t3) => t3.result_handoff)
55212
+ ...receivableTasks.map((t3) => t3.result_handoff),
55213
+ ...delegatableTasks.map((t3) => t3.invocation_handoff),
55214
+ ...delegatableTasks.map((t3) => t3.result_handoff)
55213
55215
  ]);
55214
55216
  const relatedHandoffTypes = {};
55215
55217
  for (const [kind, ht] of Object.entries(dsl.handoff_types)) {