agent-contracts 0.12.3 → 0.13.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 +71 -20
- package/dist/cli.js +770 -44
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +89 -5
- package/dist/index.js +756 -41
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -332,7 +332,7 @@ Design regressions become testable.
|
|
|
332
332
|
* **Guardrail generation** from DSL + policy + bindings via `generate guardrails`
|
|
333
333
|
* **Flexible file splitting** via `$ref` (replacement), `$refs` (import + deep-merge), and JSON Pointer `$ref` (in-document)
|
|
334
334
|
* **YAML safety linting** for reserved word collision detection across YAML 1.1/1.2
|
|
335
|
-
* **`
|
|
335
|
+
* **`extensions` declarations** with scope, schema validation, and strict enforcement for custom `x-*` fields
|
|
336
336
|
* **`resolve --expand-defaults`** to materialize all Zod schema defaults in output
|
|
337
337
|
* **DSL completeness scoring** with 7 dimensions, text/JSON output, and `--threshold` CI gate
|
|
338
338
|
* **JSON Schema for editor support and external tooling**
|
|
@@ -373,15 +373,20 @@ guardrail_policies: {}
|
|
|
373
373
|
components:
|
|
374
374
|
schemas: {}
|
|
375
375
|
|
|
376
|
-
|
|
377
|
-
x-extensions:
|
|
376
|
+
extensions:
|
|
378
377
|
x-flags:
|
|
379
378
|
type: array
|
|
380
379
|
items: string
|
|
381
380
|
description: "CLI flags for tool commands"
|
|
382
|
-
x-
|
|
381
|
+
x-path-hint:
|
|
383
382
|
type: string
|
|
384
|
-
description: "
|
|
383
|
+
description: "Filesystem path hint"
|
|
384
|
+
scope: [artifact]
|
|
385
|
+
schema:
|
|
386
|
+
type: string
|
|
387
|
+
minLength: 1
|
|
388
|
+
required: true
|
|
389
|
+
extensions_strict: false
|
|
385
390
|
````
|
|
386
391
|
|
|
387
392
|
This makes definitions easy to merge, extend, and reference by stable identifiers.
|
|
@@ -612,22 +617,53 @@ tasks:
|
|
|
612
617
|
`x-` prefixed custom properties work at any nesting level — including inside
|
|
613
618
|
`execution_steps`, `rules`, `workflow.steps`, and other nested objects.
|
|
614
619
|
|
|
615
|
-
###
|
|
620
|
+
### Extension declarations
|
|
616
621
|
|
|
617
|
-
Projects can
|
|
622
|
+
Projects can declare their custom `x-*` extension fields in the DSL using `extensions`. This makes extensions discoverable, self-documenting, and — optionally — machine-validated:
|
|
618
623
|
|
|
619
624
|
````yaml
|
|
620
|
-
|
|
625
|
+
extensions:
|
|
621
626
|
x-flags:
|
|
622
627
|
type: array
|
|
623
628
|
items: string
|
|
624
629
|
description: "CLI flags for tool commands"
|
|
625
|
-
x-
|
|
630
|
+
x-path-hint:
|
|
626
631
|
type: string
|
|
627
|
-
description: "
|
|
632
|
+
description: "Filesystem path hint"
|
|
633
|
+
scope: [artifact]
|
|
634
|
+
schema:
|
|
635
|
+
type: string
|
|
636
|
+
minLength: 1
|
|
637
|
+
required: true
|
|
638
|
+
|
|
639
|
+
extensions_strict: true # undeclared x-* properties become errors
|
|
628
640
|
````
|
|
629
641
|
|
|
630
|
-
Each key must start with `x-` (validated at schema level). The
|
|
642
|
+
Each key must start with `x-` (validated at schema level). The declaration supports:
|
|
643
|
+
|
|
644
|
+
| Field | Type | Default | Description |
|
|
645
|
+
|-------|------|---------|-------------|
|
|
646
|
+
| `type` | `string` | *(required)* | Informational type descriptor |
|
|
647
|
+
| `items` | `string` | — | Item type (for array-typed extensions) |
|
|
648
|
+
| `description` | `string` | — | Human-readable description |
|
|
649
|
+
| `scope` | `string[]` | all node types | Restricts which DSL node types this extension may appear on |
|
|
650
|
+
| `schema` | `object` | — | JSON Schema to validate the extension value |
|
|
651
|
+
| `required` | `boolean` | `false` | Whether the extension must be present on every in-scope entity |
|
|
652
|
+
|
|
653
|
+
**Scope values**: `root`, `system`, `agent`, `task`, `execution_step`, `artifact`, `tool`, `tool_command`, `validation`, `handoff_type`, `workflow`, `workflow_step`, `policy`, `guardrail`, `guardrail_policy`, `rule`, `escalation_criterion`, `prerequisite`
|
|
654
|
+
|
|
655
|
+
**`extensions_strict`**: When `true`, any `x-*` property not declared in `extensions` is an error. When `false` (default), undeclared extensions produce a warning.
|
|
656
|
+
|
|
657
|
+
**Diagnostics**:
|
|
658
|
+
|
|
659
|
+
| Code | Severity | Trigger |
|
|
660
|
+
|------|----------|---------|
|
|
661
|
+
| `extension-scope-mismatch` | error | Extension used on a node type outside its declared `scope` |
|
|
662
|
+
| `extension-schema-violation` | error | Extension value fails the declared JSON Schema |
|
|
663
|
+
| `extension-required-missing` | error | Required extension missing on an in-scope entity |
|
|
664
|
+
| `undeclared-extension` | warning/error | Extension not declared in `extensions` (error when `extensions_strict: true`) |
|
|
665
|
+
|
|
666
|
+
> **Backward compatibility:** `x-extensions` and `x-extensions-strict` are still accepted as deprecated aliases. They produce a `deprecated-property` warning and are normalized to `extensions` / `extensions_strict` during validation.
|
|
631
667
|
|
|
632
668
|
---
|
|
633
669
|
|
|
@@ -999,10 +1035,10 @@ Each `context` type provides a different rendering scope:
|
|
|
999
1035
|
| Context | Scope | Output | Key variables |
|
|
1000
1036
|
|---------|-------|--------|---------------|
|
|
1001
1037
|
| `system` | Single file | `output` as-is | `system`, `dsl`, `guardrailEnforcement`\*, `bindings`\* |
|
|
1002
|
-
| `agent` | Per agent | `{agent.id}` in output path | `agent`, `receivableTasks`, `delegatableTasks`, `relatedArtifacts`, `relatedTools`, `relatedHandoffTypes`, `mergedBehavior`, `dsl` |
|
|
1003
|
-
| `task` | Per task | `{task.id}` in output path | `task`, `targetAgent`, `dsl` |
|
|
1004
|
-
| `artifact` | Per artifact | `{artifact.id}` in output path | `artifact`, `relatedTools`, `relatedValidations`, `producerAgents`, `consumerAgents`, `editorAgents`, `createdInWorkflows`, `dsl` |
|
|
1005
|
-
| `tool` | Per tool | `{tool.id}` in output path | `tool`, `invokableAgents`, `inputArtifactDetails`, `outputArtifactDetails`, `dsl` |
|
|
1038
|
+
| `agent` | Per agent | `{agent.id}` in output path | `agent`, `receivableTasks`, `delegatableTasks`, `relatedArtifacts`, `relatedTools`, `relatedHandoffTypes`, `mergedBehavior`, `relatedGuardrails`, `relatedValidations`, `dsl` |
|
|
1039
|
+
| `task` | Per task | `{task.id}` in output path | `task`, `targetAgent`, `relatedGuardrails`, `relatedValidations`, `dsl` |
|
|
1040
|
+
| `artifact` | Per artifact | `{artifact.id}` in output path | `artifact`, `relatedTools`, `relatedValidations`, `relatedGuardrails`, `producerAgents`, `consumerAgents`, `editorAgents`, `createdInWorkflows`, `dsl` |
|
|
1041
|
+
| `tool` | Per tool | `{tool.id}` in output path | `tool`, `invokableAgents`, `inputArtifactDetails`, `outputArtifactDetails`, `relatedGuardrails`, `relatedValidations`, `dsl` |
|
|
1006
1042
|
| `validation` | Per validation | `{validation.id}` in output path | `validation`, `dsl` |
|
|
1007
1043
|
| `handoff_type` | Per handoff type | `{handoff_type.id}` in output path | `handoff_type`, `relatedTasks`, `dsl` |
|
|
1008
1044
|
| `workflow` | Per workflow phase | `{workflow.id}` in output path | `workflow`, `relatedAgents`, `relatedTasks`, `relatedTools`, `relatedArtifacts`, `relatedValidations`, `dsl` |
|
|
@@ -1027,6 +1063,23 @@ Each `context` type provides a different rendering scope:
|
|
|
1027
1063
|
* `producerAgents` / `consumerAgents` / `editorAgents` — resolved agent records
|
|
1028
1064
|
* `createdInWorkflows` — workflow phases where this artifact is written
|
|
1029
1065
|
|
|
1066
|
+
**`agent` context** provides merged behavioral specs and cross-references:
|
|
1067
|
+
|
|
1068
|
+
* `relatedGuardrails` — guardrails bound via `agent.guardrails[]` or guardrail `scope.agents[]`, merged and deduplicated
|
|
1069
|
+
* `relatedValidations` — validations from `agent.can_perform_validations`, resolved into full entries (kind, target_artifact, executor_type, blocking)
|
|
1070
|
+
|
|
1071
|
+
**`task` context** provides execution details:
|
|
1072
|
+
|
|
1073
|
+
* `relatedGuardrails` — guardrails bound via `task.guardrails[]` or guardrail `scope.tasks[]`
|
|
1074
|
+
* `relatedValidations` — validations from `task.validations[]`, resolved into full entries
|
|
1075
|
+
|
|
1076
|
+
**`tool` context** provides invocation and artifact details:
|
|
1077
|
+
|
|
1078
|
+
* `relatedGuardrails` — guardrails bound via `tool.guardrails[]` or guardrail `scope.tools[]`
|
|
1079
|
+
* `relatedValidations` — validations where `executor_type` is `"tool"` and `executor` matches this tool ID
|
|
1080
|
+
* `invokableAgents` — agents listed in `invokable_by`
|
|
1081
|
+
* `inputArtifactDetails` / `outputArtifactDetails` — resolved artifact records
|
|
1082
|
+
|
|
1030
1083
|
**`system` context** includes binding-aware guardrail enforcement data when `bindings` and `active_guardrail_policy` are configured:
|
|
1031
1084
|
|
|
1032
1085
|
* `guardrailEnforcement` — array of enforcement entries, each with `guardrail_id`, `description`, `severity`, `action`, scoped entities (`scoped_agents`, `scoped_tasks`, `scoped_workflows`, `scoped_tools`, `scoped_artifacts`), `allow_override`, `override_requires`, `trigger` (from binding matcher type), and `escalation`
|
|
@@ -1039,11 +1092,6 @@ These fields are only populated when the config specifies `bindings` and `active
|
|
|
1039
1092
|
* `guardrailCoverageMatrix` — generates a Guardrail Coverage Matrix table (guardrail × severity × action × scoped entities × trigger × override × escalation)
|
|
1040
1093
|
* `taskGuardrailMatrix` — generates a Task × Guardrail cross-reference table showing which action applies to each task
|
|
1041
1094
|
|
|
1042
|
-
**`tool` context** resolves agent and artifact references:
|
|
1043
|
-
|
|
1044
|
-
* `invokableAgents` — agents listed in `invokable_by`
|
|
1045
|
-
* `inputArtifactDetails` / `outputArtifactDetails` — resolved artifact records
|
|
1046
|
-
|
|
1047
1095
|
### Handlebars helpers
|
|
1048
1096
|
|
|
1049
1097
|
Templates can use these built-in helpers:
|
|
@@ -1251,6 +1299,8 @@ Checks:
|
|
|
1251
1299
|
* handoff schema shape (meta-validated as valid JSON Schema via ajv)
|
|
1252
1300
|
* `allOf` composition in handoff schemas
|
|
1253
1301
|
* invalid custom properties without `x-` prefix (checked at all nesting levels)
|
|
1302
|
+
* `extensions` declaration validation — scope, schema, required, and undeclared checks
|
|
1303
|
+
* `extensions_strict` enforcement — reject undeclared `x-*` properties when enabled
|
|
1254
1304
|
|
|
1255
1305
|
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.
|
|
1256
1306
|
|
|
@@ -1306,6 +1356,7 @@ Checks:
|
|
|
1306
1356
|
* artifact ownership — `produces_artifact`/`reads_artifact` in execution steps vs. artifact producers/editors/consumers
|
|
1307
1357
|
* tool commands — `commands[].reads`/`commands[].writes` reference valid artifacts and align with `output_artifacts`
|
|
1308
1358
|
* semantic validation phase coverage — warns when `semantic` or `fidelity` validations only appear in late workflow phases (e.g., audit) but not earlier phases (e.g., specify, plan)
|
|
1359
|
+
* validation executor context wiring — warns when a validation's executor (agent or tool) exists in the DSL but the validation is not surfaced in the executor's prompt context
|
|
1309
1360
|
* YAML safety — warns when YAML 1.1 reserved words (`on`, `yes`, `no`, `true`, `false`, etc.) are used in positions where they may be misinterpreted by non-1.2 parsers
|
|
1310
1361
|
* naming/style issues through Spectral rules
|
|
1311
1362
|
|