agent-contracts 0.18.0 → 0.19.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 CHANGED
@@ -343,6 +343,7 @@ Design regressions become testable.
343
343
  * **`extensions` declarations** with scope, schema validation, and strict enforcement for custom `x-*` fields
344
344
  * **`resolve --expand-defaults`** to materialize all Zod schema defaults in output
345
345
  * **DSL completeness scoring** with 7 dimensions, text/JSON output, and `--threshold` CI gate
346
+ * **LLM-based semantic audit** — design coherence, prompt fidelity, and completeness checks via Claude, OpenAI, Gemini, or Cursor adapters
346
347
  * **JSON Schema for editor support and external tooling**
347
348
  * **CI-friendly workflow checks**
348
349
 
@@ -1030,6 +1031,7 @@ npx agent-contracts
1030
1031
  | `agent-contracts score [path]` | Calculate DSL completeness score |
1031
1032
  | `agent-contracts generate guardrails` | Generate guardrail artifacts from bindings |
1032
1033
  | `agent-contracts generate interface` | Generate team interface YAML from DSL |
1034
+ | `agent-contracts audit <type>` | Run LLM-based semantic audit (render/dsl/prompt/all) |
1033
1035
  | `agent-contracts check` | Run resolve → validate → lint → render --check |
1034
1036
 
1035
1037
  The `[path]` argument defaults to `agent-contracts.yaml` in the current directory.
@@ -1055,6 +1057,26 @@ All commands also accept `--team <id>` to limit execution to a single team when
1055
1057
  | `-c, --config <path>` | Path to `agent-contracts.config.yaml` |
1056
1058
  | `--team <id>` | Limit to one team (multi-team config only) |
1057
1059
 
1060
+ #### `audit` options
1061
+
1062
+ | Option | Description |
1063
+ |--------|-------------|
1064
+ | `--format <text\|json\|markdown>` | Output format (default: `text`) |
1065
+ | `--scope <filter>` | Limit audit scope (e.g. `agents:architect,implementer`) |
1066
+ | `--dry-run` | Output the audit prompt without calling the LLM |
1067
+ | `--adapter <name>` | SDK adapter: `claude`, `openai`, `gemini`, `cursor` (overrides config) |
1068
+ | `--model <name>` | LLM model override (overrides config) |
1069
+ | `-c, --config <path>` | Path to `agent-contracts.config.yaml` |
1070
+ | `--team <id>` | Limit to one team (multi-team config only) |
1071
+
1072
+ The `audit` command requires `agent-contracts-runtime` (optional peer dependency) to be installed. Configure the default adapter and model in `agent-contracts.config.yaml`:
1073
+
1074
+ ```yaml
1075
+ audit:
1076
+ adapter: openai
1077
+ model: gpt-4.1
1078
+ ```
1079
+
1058
1080
  The score command evaluates 7 dimensions:
1059
1081
 
1060
1082
  | Dimension | What it measures | Weight |
@@ -1083,6 +1105,10 @@ agent-contracts check -c agent-contracts.config.yaml --strict
1083
1105
  agent-contracts generate interface -c agent-contracts.config.yaml
1084
1106
  agent-contracts generate interface -c agent-contracts.config.yaml --dry-run
1085
1107
  agent-contracts generate interface -c agent-contracts.config.yaml --format json
1108
+ agent-contracts audit dsl -c agent-contracts.config.yaml
1109
+ agent-contracts audit render -c agent-contracts.config.yaml --format json
1110
+ agent-contracts audit all -c agent-contracts.config.yaml --adapter claude
1111
+ agent-contracts audit dsl -c agent-contracts.config.yaml --dry-run
1086
1112
  ````
1087
1113
 
1088
1114
  ---
@@ -1632,6 +1658,61 @@ Use `--threshold` in CI to enforce a minimum quality bar:
1632
1658
  agent-contracts score -c config.yaml --threshold 70
1633
1659
  ````
1634
1660
 
1661
+ ### LLM-based semantic audit
1662
+
1663
+ Static tools (`validate`, `lint`, `score`) catch structural and naming issues, but cannot evaluate **design quality** — whether agent responsibilities are well-scoped, whether workflow gates are placed correctly, or whether generated prompts faithfully represent DSL intent. The `audit` command bridges this gap by using LLMs as semantic reviewers.
1664
+
1665
+ Requires `agent-contracts-runtime` (optional peer dependency) and an API key for at least one supported adapter.
1666
+
1667
+ #### Audit types
1668
+
1669
+ | Type | What it checks |
1670
+ |------|----------------|
1671
+ | `render` | 19-dimension cross-check of DSL definitions vs generated prompts — detects template gaps, data gaps, and DSL gaps |
1672
+ | `dsl` | Design coherence — role overlap, scope breadth, gate placement, guardrail enforcement paths, handoff schema completeness |
1673
+ | `prompt` | Prompt fidelity — missing responsibilities, hallucinated permissions, ambiguous instructions, unsafe directives |
1674
+ | `all` | Run all three |
1675
+
1676
+ Results are structured: each finding has a severity (`critical` / `warning` / `info`), a gap type classification, and prioritized recommendations (P0/P1/P2) with concrete fix proposals.
1677
+
1678
+ #### Configuration
1679
+
1680
+ ````yaml
1681
+ # agent-contracts.config.yaml
1682
+ audit:
1683
+ adapter: openai # claude | openai | gemini | cursor
1684
+ model: gpt-4.1 # model override (adapter-specific)
1685
+ ````
1686
+
1687
+ | Adapter | Environment Variable |
1688
+ |---------|---------------------|
1689
+ | `claude` | `ANTHROPIC_API_KEY` |
1690
+ | `openai` | `OPENAI_API_KEY` |
1691
+ | `gemini` | `GEMINI_API_KEY` |
1692
+ | `cursor` | `CURSOR_API_KEY` |
1693
+
1694
+ #### Usage
1695
+
1696
+ ````bash
1697
+ agent-contracts audit dsl -c config.yaml
1698
+ agent-contracts audit all -c config.yaml --adapter claude
1699
+ agent-contracts audit render -c config.yaml --format json
1700
+ agent-contracts audit dsl -c config.yaml --dry-run
1701
+ ````
1702
+
1703
+ Use `--dry-run` to inspect the prompt sent to the LLM without making an API call. Running multiple adapters provides cross-validation — findings reported by 3+ adapters are high-confidence issues.
1704
+
1705
+ | Exit Code | Meaning |
1706
+ |-----------|---------|
1707
+ | 0 | No critical findings |
1708
+ | 1 | Critical findings detected |
1709
+ | 2 | Invalid input or configuration |
1710
+ | 3 | LLM adapter error (API failure, runtime not installed) |
1711
+
1712
+ #### A self-hosted example of agent-contracts + runtime
1713
+
1714
+ The audit feature is itself built on the agent-contracts ecosystem. The auditor agent, audit tasks, handoff schemas, and workflow are all defined as DSL in `dsl_base/`, and executed via `agent-contracts-runtime` adapters at runtime. This makes the audit command a concrete, working example of how to combine the two packages: define agent behavior declaratively in YAML, auto-generate typed registries, and execute tasks against real LLM adapters with structured output validation.
1715
+
1635
1716
  ---
1636
1717
 
1637
1718
  ## Best used with runtime frameworks
package/cli-contract.yaml CHANGED
@@ -3,7 +3,7 @@ cliContracts: 0.1.0
3
3
 
4
4
  info:
5
5
  title: agent-contracts CLI
6
- version: 0.18.0
6
+ version: 0.19.1
7
7
  description: >-
8
8
  Declarative YAML DSL toolkit for defining, validating, and rendering
9
9
  multi-agent development workflows. Provides static validation,
@@ -505,6 +505,126 @@ commandSets:
505
505
  idempotent: true
506
506
  sideEffects: []
507
507
 
508
+ # ── audit ───────────────────────────────────────────
509
+ audit:
510
+ summary: Run LLM-based semantic audit on DSL definitions and generated outputs.
511
+ description: >-
512
+ Performs LLM-based semantic analysis on DSL definitions and/or
513
+ generated outputs. Three audit types are available: "render"
514
+ checks whether generated files faithfully reflect the resolved
515
+ DSL, "dsl" reviews DSL design for semantic coherence, and
516
+ "prompt" verifies that generated prompts accurately express
517
+ DSL intent. Uses agent-contracts-runtime (optional peer
518
+ dependency) for LLM execution with handoff schema validation
519
+ and follow-up recovery.
520
+ usage:
521
+ - agent-contracts audit render -c agent-contracts.config.yaml
522
+ - agent-contracts audit dsl -c agent-contracts.config.yaml
523
+ - agent-contracts audit prompt -c agent-contracts.config.yaml
524
+ - agent-contracts audit all -c agent-contracts.config.yaml
525
+ - agent-contracts audit dsl --dry-run -c agent-contracts.config.yaml
526
+ - agent-contracts audit render --format json -c agent-contracts.config.yaml
527
+ - agent-contracts audit dsl --scope agents:architect,implementer -c config.yaml
528
+
529
+ arguments:
530
+ - name: type
531
+ index: 0
532
+ required: false
533
+ description: >-
534
+ Audit type to run: render (semantic diff of generated
535
+ outputs vs DSL), dsl (design coherence review), prompt
536
+ (generated prompt fidelity check), or all (run all three).
537
+ schema:
538
+ type: string
539
+ enum: [render, dsl, prompt, all]
540
+ default: all
541
+
542
+ options:
543
+ - name: config
544
+ aliases: [c]
545
+ description: Path to agent-contracts.config.yaml.
546
+ valueName: path
547
+ schema:
548
+ type: string
549
+ file:
550
+ mode: read
551
+ exists: false
552
+ mediaType: application/yaml
553
+ encoding: utf-8
554
+
555
+ - name: team
556
+ description: Limit to one team (multi-team config only).
557
+ valueName: id
558
+ schema:
559
+ type: string
560
+
561
+ - name: format
562
+ description: Output format.
563
+ valueName: format
564
+ schema:
565
+ type: string
566
+ enum: [text, json, markdown]
567
+ default: text
568
+
569
+ - name: scope
570
+ description: >-
571
+ Limit audit scope to specified entities
572
+ (e.g. agents:architect,implementer).
573
+ valueName: entities
574
+ schema:
575
+ type: string
576
+
577
+ - name: dry-run
578
+ description: Output the audit prompt without calling LLM.
579
+ schema:
580
+ type: boolean
581
+ default: false
582
+
583
+ - name: adapter
584
+ description: >-
585
+ SDK adapter to use for LLM calls
586
+ (overrides config audit.adapter).
587
+ valueName: name
588
+ schema:
589
+ type: string
590
+
591
+ - name: model
592
+ description: LLM model override (overrides config audit.model).
593
+ valueName: name
594
+ schema:
595
+ type: string
596
+
597
+ exits:
598
+ '0':
599
+ description: No critical findings detected.
600
+ stdout:
601
+ format: text
602
+
603
+ '1':
604
+ description: Critical findings detected.
605
+ stdout:
606
+ format: text
607
+
608
+ '2':
609
+ description: Invalid input or configuration error.
610
+ stderr:
611
+ format: text
612
+
613
+ '3':
614
+ description: LLM adapter error (API failure, runtime not installed).
615
+ stderr:
616
+ format: text
617
+
618
+ x-agent:
619
+ riskLevel: low
620
+ requiresConfirmation: false
621
+ idempotent: true
622
+ sideEffects: []
623
+ recommendedBeforeUse:
624
+ - Ensure agent-contracts.config.yaml exists with render targets.
625
+ - Run validate first to confirm DSL is valid.
626
+ - Install agent-contracts-runtime if not using --dry-run.
627
+
508
628
  # ── generate ──────────────────────────────────────
509
629
  generate:
510
630
  summary: Generate guardrail or interface artifacts from DSL.