contractspec 1.52.0 → 1.53.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/AGENT_MODES.md CHANGED
@@ -5,6 +5,7 @@ The contracts-cli supports multiple AI agent modes for code generation and valid
5
5
  ## Available Agent Modes
6
6
 
7
7
  ### 1. Simple Mode (Default)
8
+
8
9
  - **Mode**: `simple`
9
10
  - **Description**: Direct LLM API calls for code generation
10
11
  - **Best For**: Quick prototyping, basic implementations
@@ -13,11 +14,13 @@ The contracts-cli supports multiple AI agent modes for code generation and valid
13
14
  - **Quality**: Good baseline quality
14
15
 
15
16
  **Example:**
17
+
16
18
  ```bash
17
19
  contractspec build spec.contracts.ts --agent-mode simple
18
20
  ```
19
21
 
20
22
  ### 2. Cursor Agent Mode
23
+
21
24
  - **Mode**: `cursor`
22
25
  - **Description**: Leverages Windsurf/Cursor's agentic capabilities
23
26
  - **Best For**: Complex implementations, iterative development
@@ -26,6 +29,7 @@ contractspec build spec.contracts.ts --agent-mode simple
26
29
  - **Quality**: High quality with context awareness
27
30
 
28
31
  **Example:**
32
+
29
33
  ```bash
30
34
  contractspec build spec.contracts.ts --agent-mode cursor
31
35
  ```
@@ -33,6 +37,7 @@ contractspec build spec.contracts.ts --agent-mode cursor
33
37
  **Note**: This mode requires Windsurf/Cursor CLI access. If not available, falls back to simple mode.
34
38
 
35
39
  ### 3. Claude Code Mode
40
+
36
41
  - **Mode**: `claude-code`
37
42
  - **Description**: Uses Anthropic's Claude with extended thinking for code generation
38
43
  - **Best For**: Production-quality code, complex logic, thorough validation
@@ -41,18 +46,21 @@ contractspec build spec.contracts.ts --agent-mode cursor
41
46
  - **Quality**: Very high quality, excellent for validation
42
47
 
43
48
  **Features:**
49
+
44
50
  - Extended context understanding
45
51
  - Detailed code review capabilities
46
52
  - Comprehensive validation reports
47
53
  - Best for critical implementations
48
54
 
49
55
  **Example:**
56
+
50
57
  ```bash
51
58
  export ANTHROPIC_API_KEY=your_key
52
59
  contractspec build spec.contracts.ts --agent-mode claude-code
53
60
  ```
54
61
 
55
62
  ### 4. OpenAI Codex Mode
63
+
56
64
  - **Mode**: `openai-codex`
57
65
  - **Description**: Uses OpenAI's GPT-4o and o1 models for code generation
58
66
  - **Best For**: Complex algorithms, optimization tasks
@@ -61,16 +69,33 @@ contractspec build spec.contracts.ts --agent-mode claude-code
61
69
  - **Quality**: High quality, excellent for algorithmic problems
62
70
 
63
71
  **Features:**
72
+
64
73
  - Automatically selects o1 for complex tasks
65
74
  - Uses GPT-4o for standard generation
66
75
  - Strong at optimization and algorithms
67
76
 
68
77
  **Example:**
78
+
69
79
  ```bash
70
80
  export OPENAI_API_KEY=your_key
71
81
  contractspec build spec.contracts.ts --agent-mode openai-codex
72
82
  ```
73
83
 
84
+ ### 5. OpenCode SDK Mode
85
+
86
+ - **Mode**: `opencode` (alias for `opencode-sdk`)
87
+ - **Description**: Uses the OpenCode SDK for self-hosted AI backends
88
+ - **Best For**: Teams running open, self-hosted agent infrastructure
89
+ - **Requirements**: `@opencode-ai/sdk` and a running OpenCode server
90
+ - **Speed**: Moderate
91
+ - **Quality**: High quality with self-hosted control
92
+
93
+ **Example:**
94
+
95
+ ```bash
96
+ contractspec build spec.contracts.ts --agent-mode opencode
97
+ ```
98
+
74
99
  ## Configuring Agent Modes
75
100
 
76
101
  ### Via Configuration File
@@ -101,22 +126,23 @@ contractspec build spec.ts --agent-mode claude-code --provider claude
101
126
 
102
127
  ## Agent Mode Comparison
103
128
 
104
- | Feature | Simple | Cursor | Claude Code | OpenAI Codex |
105
- |---------|--------|--------|-------------|--------------|
106
- | Speed | ⚡⚡⚡ | ⚡⚡ | ⚡⚡ | ⚡⚡⚡ |
107
- | Quality | ⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
108
- | Validation | Basic | Good | Excellent | Good |
109
- | Setup | Easy | Moderate | Easy | Easy |
110
- | Cost | Low | N/A | Moderate | Low-Moderate |
129
+ | Feature | Simple | Cursor | Claude Code | OpenAI Codex | OpenCode |
130
+ | ---------- | ------ | -------- | ----------- | ------------ | -------------- |
131
+ | Speed | ⚡⚡⚡ | ⚡⚡ | ⚡⚡ | ⚡⚡⚡ | ⚡⚡ |
132
+ | Quality | ⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
133
+ | Validation | Basic | Good | Excellent | Good | Good |
134
+ | Setup | Easy | Moderate | Easy | Easy | Moderate |
135
+ | Cost | Low | N/A | Moderate | Low-Moderate | Infrastructure |
111
136
 
112
137
  ## Fallback Behavior
113
138
 
114
139
  The CLI automatically falls back to simpler modes if the primary mode fails:
115
140
 
116
- 1. **cursor** → **claude-code** → **openai-codex** → **simple**
117
- 2. **claude-code** → **openai-codex** → **simple**
118
- 3. **openai-codex** → **simple**
119
- 4. **simple** → Basic templates (no AI)
141
+ 1. **opencode** → **claude-code** → **openai-codex** → **simple**
142
+ 2. **cursor** → **claude-code** → **openai-codex** → **simple**
143
+ 3. **claude-code** → **openai-codex** → **simple**
144
+ 4. **openai-codex** → **simple**
145
+ 5. **simple** → Basic templates (no AI)
120
146
 
121
147
  ## Usage Examples
122
148
 
@@ -129,6 +155,9 @@ contractspec build user.contracts.ts --agent-mode claude-code
129
155
  # Use OpenAI for algorithmic code
130
156
  contractspec build optimizer.contracts.ts --agent-mode openai-codex
131
157
 
158
+ # Use OpenCode for self-hosted backends
159
+ contractspec build spec.contracts.ts --agent-mode opencode
160
+
132
161
  # Disable AI entirely
133
162
  contractspec build simple.contracts.ts --no-agent
134
163
  ```
@@ -142,6 +171,9 @@ contractspec validate user.contracts.ts --check-implementation --agent-mode clau
142
171
  # Interactive validation
143
172
  contractspec validate user.contracts.ts -i --agent-mode claude-code
144
173
 
174
+ # Validate with OpenCode
175
+ contractspec validate user.contracts.ts --check-implementation --agent-mode opencode
176
+
145
177
  # Specify implementation path
146
178
  contractspec validate user.contracts.ts \
147
179
  --check-implementation \
@@ -152,19 +184,27 @@ contractspec validate user.contracts.ts \
152
184
  ## Best Practices
153
185
 
154
186
  ### For Development
187
+
155
188
  - Use **simple** mode for rapid iteration
156
189
  - Use **cursor** mode if working in Windsurf/Cursor
157
190
 
158
191
  ### For Production
192
+
159
193
  - Use **claude-code** for critical implementations
160
194
  - Always validate with `--check-implementation`
161
195
  - Review AI-generated code before committing
162
196
 
163
197
  ### For Complex Logic
198
+
164
199
  - Use **openai-codex** for algorithmic problems
165
200
  - Use **claude-code** for comprehensive validation
166
201
 
202
+ ### For Self-Hosted Backends
203
+
204
+ - Use **opencode** when running an OpenCode server
205
+
167
206
  ### For CI/CD
207
+
168
208
  - Use **simple** mode for speed
169
209
  - Configure via environment variables
170
210
  - Set up validation in pre-commit hooks
@@ -174,6 +214,7 @@ contractspec validate user.contracts.ts \
174
214
  ### Agent Mode Not Working
175
215
 
176
216
  Check:
217
+
177
218
  1. API keys are set correctly
178
219
  2. Network connectivity to AI providers
179
220
  3. Provider quotas and rate limits
@@ -181,6 +222,7 @@ Check:
181
222
  ### Fallback to Simple Mode
182
223
 
183
224
  This happens when:
225
+
184
226
  - API key is missing
185
227
  - Provider is unavailable
186
228
  - Agent cannot handle the task
@@ -190,6 +232,7 @@ The CLI will show warnings explaining why.
190
232
  ### Poor Quality Output
191
233
 
192
234
  Try:
235
+
193
236
  1. Using a more powerful agent mode
194
237
  2. Adding more context to your spec
195
238
  3. Reviewing and refining the spec structure
@@ -201,7 +244,7 @@ Try:
201
244
  CONTRACTSPEC_AI_PROVIDER=claude|openai|ollama|custom
202
245
 
203
246
  # Agent mode
204
- CONTRACTSPEC_AGENT_MODE=simple|cursor|claude-code|openai-codex
247
+ CONTRACTSPEC_AGENT_MODE=simple|cursor|claude-code|openai-codex|opencode
205
248
 
206
249
  # Model selection
207
250
  CONTRACTSPEC_AI_MODEL=claude-3-7-sonnet-20250219
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # contractspec
2
2
 
3
+ ## 1.53.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f4180d4: fix: performance improvement
8
+
9
+ ### Patch Changes
10
+
11
+ - cd7f418: Move ContractSpec automation into reusable actions and ship typed report generators.
12
+ - 1484fa6: Add reusable ContractSpec workflows with shared reporting and document the new automation guidance.
13
+ - 5b371b1: Expose OpenCode agent mode in the CLI and workspace validation with updated docs and examples.
14
+ - Updated dependencies [5b371b1]
15
+ - Updated dependencies [f4180d4]
16
+ - @contractspec/app.cli-contractspec@1.53.0
17
+
3
18
  ## 1.52.0
4
19
 
5
20
  ### Minor Changes
package/README.md CHANGED
@@ -4,10 +4,8 @@
4
4
  [![npm downloads](https://img.shields.io/npm/dt/contractspec)](https://www.npmjs.com/package/contractspec)
5
5
  [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/lssm-tech/contractspec)
6
6
 
7
-
8
7
  Website: https://contractspec.io/
9
8
 
10
-
11
9
  **Stabilize your AI-generated code** — Define contracts once, generate consistent code across API, DB, UI, and events. Safe regeneration. No lock-in.
12
10
 
13
11
  CLI tool for creating, building, and validating contract specifications.
@@ -41,6 +39,7 @@ contractspec validate src/contracts/mySpec.ts
41
39
  List all contract specifications in the project with filtering options.
42
40
 
43
41
  **Options:**
42
+
44
43
  - `--pattern <pattern>` - File pattern to search (glob)
45
44
  - `--deep` - Load spec modules to extract richer metadata (executes spec modules)
46
45
  - `--type <type>` - Filter by spec type (operation, event, presentation, etc.)
@@ -70,6 +69,7 @@ contractspec list --json
70
69
  Watch contract specifications and auto-regenerate on changes.
71
70
 
72
71
  **Options:**
72
+
73
73
  - `--pattern <pattern>` - File pattern to watch (default: `**/*.contracts.ts`)
74
74
  - `--build` - Auto-run build command on changes
75
75
  - `--validate` - Auto-run validate command on changes
@@ -95,6 +95,7 @@ contractspec watch --pattern 'src/**/*.ts' --debounce 1000
95
95
  Sync contracts by building all discovered specs.
96
96
 
97
97
  **Options:**
98
+
98
99
  - `--pattern <pattern>` - File pattern to search (glob)
99
100
  - `--buckets <buckets>` - Optional output buckets (comma-separated). Builds repeat into `./generated/<bucket>/`
100
101
  - `--surfaces <surfaces>` - (deprecated) Alias for `--buckets`
@@ -119,6 +120,7 @@ contractspec sync --dry-run
119
120
  Clean generated files and build artifacts.
120
121
 
121
122
  **Options:**
123
+
122
124
  - `--dry-run` - Show what would be deleted without deleting
123
125
  - `--generated-only` - Only clean generated directories (generated/, dist/, .turbo/, outputDir artifacts)
124
126
  - `--older-than <days>` - Only clean files older than specified days
@@ -146,6 +148,7 @@ contractspec clean --git-clean
146
148
  Analyze contract dependencies and relationships.
147
149
 
148
150
  **Options:**
151
+
149
152
  - `--pattern <pattern>` - File pattern to search (glob)
150
153
  - `--entry <name>` - Focus on a specific contract name
151
154
  - `--format <format>` - text|json|dot (default: text)
@@ -175,9 +178,11 @@ contractspec deps --format dot > deps.dot
175
178
  Compare contract specifications and show differences.
176
179
 
177
180
  **Arguments:**
181
+
178
182
  - `<spec1> <spec2>` - Two spec files to compare
179
183
 
180
184
  **Options:**
185
+
181
186
  - `--breaking` - Only show breaking changes
182
187
  - `--semantic` - Show semantic differences (not just text)
183
188
  - `--json` - Output as JSON for scripting
@@ -204,6 +209,7 @@ contractspec diff spec1.ts spec2.ts --semantic
204
209
  Interactive wizard to create contract specifications.
205
210
 
206
211
  **Options:**
212
+
207
213
  - `--type <type>` - Spec type: operation, event, presentation, form, feature
208
214
  - `--ai` - Use AI to generate spec from description
209
215
  - `--provider <provider>` - AI provider: claude, openai, ollama, custom
@@ -227,10 +233,11 @@ contractspec create --ai --provider ollama --model codellama
227
233
  Generate implementation code from contract specs using AI agents with automatic fallbacks.
228
234
 
229
235
  **Options:**
236
+
230
237
  - `--output-dir <dir>` - Output directory (default: ./generated)
231
238
  - `--provider <provider>` - AI provider: claude, openai, ollama, custom
232
239
  - `--model <model>` - AI model to use
233
- - `--agent-mode <mode>` - Agent mode: simple, cursor, claude-code, openai-codex
240
+ - `--agent-mode <mode>` - Agent mode: simple, cursor, claude-code, openai-codex, opencode
234
241
  - `--no-tests` - Skip test generation
235
242
  - `--no-agent` - Disable AI (use basic templates)
236
243
 
@@ -257,9 +264,10 @@ contractspec build src/contracts/simple.contracts.ts --no-agent
257
264
  Validate contract specifications and optionally verify implementations against specs using AI.
258
265
 
259
266
  **Options:**
267
+
260
268
  - `--check-implementation` - Validate implementation against spec using AI
261
269
  - `--implementation-path <path>` - Path to implementation (auto-detected if not specified)
262
- - `--agent-mode <mode>` - Agent mode for validation: simple, claude-code, openai-codex
270
+ - `--agent-mode <mode>` - Agent mode for validation: simple, claude-code, openai-codex, opencode
263
271
  - `--check-handlers` - Verify handler implementations exist
264
272
  - `--check-tests` - Verify test coverage
265
273
  - `-i, --interactive` - Interactive mode - prompt for what to validate
@@ -290,6 +298,7 @@ contractspec validate src/contracts/signup.contracts.ts \
290
298
  Run all validation checks for CI/CD pipelines with machine-readable output formats.
291
299
 
292
300
  **Options:**
301
+
293
302
  - `--pattern <glob>` - Glob pattern for spec discovery
294
303
  - `--format <format>` - Output format: text, json, sarif (default: text)
295
304
  - `--output <file>` - Write results to file
@@ -301,6 +310,7 @@ Run all validation checks for CI/CD pipelines with machine-readable output forma
301
310
  - `--verbose` - Verbose output
302
311
 
303
312
  **Available Checks:**
313
+
304
314
  - `structure` - Spec structure validation (meta, io, policy)
305
315
  - `integrity` - Contract integrity (orphaned specs, broken refs)
306
316
  - `deps` - Dependency analysis (circular deps, missing refs)
@@ -309,6 +319,7 @@ Run all validation checks for CI/CD pipelines with machine-readable output forma
309
319
  - `tests` - Test file existence
310
320
 
311
321
  **Exit Codes:**
322
+
312
323
  - `0` - All checks passed
313
324
  - `1` - Errors found
314
325
  - `2` - Warnings found (with `--fail-on-warnings`)
@@ -366,6 +377,7 @@ The CLI supports multiple AI agent modes for different use cases:
366
377
  - **cursor** - Leverages Windsurf/Cursor agentic capabilities (requires Cursor environment)
367
378
  - **claude-code** - Uses Claude with extended thinking, best for production code and validation
368
379
  - **openai-codex** - Uses GPT-4o/o1 models, excellent for algorithms and optimization
380
+ - **opencode** (alias for opencode-sdk) - Uses OpenCode SDK for self-hosted backends (requires `@opencode-ai/sdk`)
369
381
 
370
382
  See [AGENT_MODES.md](./AGENT_MODES.md) for detailed comparison and usage guide.
371
383
 
@@ -536,16 +548,19 @@ src/
536
548
  ### "Provider not available" error
537
549
 
538
550
  **Claude:**
551
+
539
552
  ```bash
540
553
  export ANTHROPIC_API_KEY=sk-ant-...
541
554
  ```
542
555
 
543
556
  **OpenAI:**
557
+
544
558
  ```bash
545
559
  export OPENAI_API_KEY=sk-...
546
560
  ```
547
561
 
548
562
  **Ollama:**
563
+
549
564
  ```bash
550
565
  # Install Ollama from https://ollama.ai
551
566
  ollama serve
@@ -555,11 +570,13 @@ ollama pull codellama
555
570
  ### Slow generation
556
571
 
557
572
  For faster local generation, use smaller models:
573
+
558
574
  ```bash
559
575
  contractspec create --ai --provider ollama --model codellama:7b
560
576
  ```
561
577
 
562
578
  For cloud, use faster models:
579
+
563
580
  ```bash
564
581
  contractspec build spec.ts --provider openai --model gpt-3.5-turbo
565
582
  ```
@@ -567,6 +584,7 @@ contractspec build spec.ts --provider openai --model gpt-3.5-turbo
567
584
  ### Import errors in generated code
568
585
 
569
586
  Make sure `@contractspec/lib.contracts` and `@contractspec/lib.schema` are installed:
587
+
570
588
  ```bash
571
589
  bun add @contractspec/lib.contracts @contractspec/lib.schema
572
590
  ```
@@ -585,23 +603,27 @@ Contributions welcome! Please:
585
603
  ### When to Use Each Mode
586
604
 
587
605
  **Simple Mode** - Default, good for:
606
+
588
607
  - Rapid prototyping
589
608
  - Basic implementations
590
609
  - Quick iterations
591
610
  - CI/CD pipelines (fast)
592
611
 
593
612
  **Cursor Mode** - Best for:
613
+
594
614
  - Working in Windsurf/Cursor IDE
595
615
  - Complex, iterative development
596
616
  - Context-aware code generation
597
617
 
598
618
  **Claude Code Mode** - Best for:
619
+
599
620
  - Production-quality implementations
600
621
  - Critical business logic
601
622
  - Comprehensive code validation
602
623
  - Detailed code reviews
603
624
 
604
625
  **OpenAI Codex Mode** - Best for:
626
+
605
627
  - Algorithmic problems
606
628
  - Performance optimization
607
629
  - Mathematical computations
@@ -612,7 +634,7 @@ For more details, see [AGENT_MODES.md](./AGENT_MODES.md).
612
634
  ## Roadmap
613
635
 
614
636
  - [x] AI-powered code generation
615
- - [x] Multiple agent modes (simple, cursor, claude-code, openai-codex)
637
+ - [x] Multiple agent modes (simple, cursor, claude-code, openai-codex, opencode)
616
638
  - [x] AI-powered implementation validation
617
639
  - [x] Contract listing and discovery (`contractspec list`)
618
640
  - [x] Watch mode for auto-regeneration (`contractspec watch`)
@@ -633,4 +655,3 @@ For more details, see [AGENT_MODES.md](./AGENT_MODES.md).
633
655
  ## License
634
656
 
635
657
  MIT
636
-
@@ -1,3 +1,3 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env bun
2
2
  // One bin, picks the right runtime via conditional exports.
3
- import "@contractspec/app.cli-contractspec/run";
3
+ import '@contractspec/app.cli-contractspec/run';
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "contractspec",
3
- "version": "1.52.0",
3
+ "version": "1.53.0",
4
4
  "description": "CLI tool for creating, building, and validating contract specifications",
5
5
  "bin": {
6
6
  "contractspec": "./bin/contractspec.mjs"
7
7
  },
8
8
  "dependencies": {
9
- "@contractspec/app.cli-contractspec": "1.52.0"
9
+ "@contractspec/app.cli-contractspec": "1.53.0"
10
10
  },
11
11
  "scripts": {
12
12
  "publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",