contractspec 3.7.17 → 4.0.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/contractsrc.schema.json +1371 -0
- package/package.json +7 -2
- package/AGENTS.md +0 -26
- package/AGENT_MODES.md +0 -290
- package/CHANGELOG.md +0 -906
- package/QUICK_REFERENCE.md +0 -209
- package/QUICK_START.md +0 -174
package/package.json
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "contractspec",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
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": "
|
|
9
|
+
"@contractspec/app.cli-contractspec": "6.0.0"
|
|
10
10
|
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin",
|
|
13
|
+
"contractsrc.schema.json",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
11
16
|
"scripts": {
|
|
12
17
|
"publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
|
|
13
18
|
"publish:pkg:canary": "bun publish:pkg --tag canary"
|
package/AGENTS.md
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# AI Agent Guide -- `contractspec`
|
|
2
|
-
|
|
3
|
-
Scope: `packages/apps-registry/contractspec/*`
|
|
4
|
-
|
|
5
|
-
npm-published CLI entry point for ContractSpec. Thin wrapper that delegates to `@contractspec/app.cli-contractspec` via `bin/contractspec.mjs`.
|
|
6
|
-
|
|
7
|
-
## Quick Context
|
|
8
|
-
|
|
9
|
-
- **Layer**: apps-registry
|
|
10
|
-
- **Consumers**: end-users installing `npx contractspec` or `bun x contractspec`
|
|
11
|
-
|
|
12
|
-
## Public Exports
|
|
13
|
-
|
|
14
|
-
| Subpath | Purpose |
|
|
15
|
-
| --- | --- |
|
|
16
|
-
| `bin/contractspec.mjs` | CLI binary entry point |
|
|
17
|
-
|
|
18
|
-
## Guardrails
|
|
19
|
-
|
|
20
|
-
- This package is a shim; all logic lives in `@contractspec/app.cli-contractspec`
|
|
21
|
-
- Do not add dependencies beyond the CLI app workspace reference
|
|
22
|
-
- Changes to `bin/contractspec.mjs` affect every user -- test locally before publishing
|
|
23
|
-
|
|
24
|
-
## Local Commands
|
|
25
|
-
|
|
26
|
-
- Publish: `bun run publish:pkg`
|
package/AGENT_MODES.md
DELETED
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
# AI Agent Modes
|
|
2
|
-
|
|
3
|
-
The contracts-cli supports multiple AI agent modes for code generation and validation. Each mode offers different capabilities and trade-offs.
|
|
4
|
-
|
|
5
|
-
## Available Agent Modes
|
|
6
|
-
|
|
7
|
-
### 1. Simple Mode (Default)
|
|
8
|
-
|
|
9
|
-
- **Mode**: `simple`
|
|
10
|
-
- **Description**: Direct LLM API calls for code generation
|
|
11
|
-
- **Best For**: Quick prototyping, basic implementations
|
|
12
|
-
- **Requirements**: API key for your chosen provider (Claude, OpenAI, Ollama)
|
|
13
|
-
- **Speed**: Fast
|
|
14
|
-
- **Quality**: Good baseline quality
|
|
15
|
-
|
|
16
|
-
**Example:**
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
contractspec build spec.contracts.ts --agent-mode simple
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
### 2. Cursor Agent Mode
|
|
23
|
-
|
|
24
|
-
- **Mode**: `cursor`
|
|
25
|
-
- **Description**: Leverages Windsurf/Cursor's agentic capabilities
|
|
26
|
-
- **Best For**: Complex implementations, iterative development
|
|
27
|
-
- **Requirements**: Running in Windsurf/Cursor environment
|
|
28
|
-
- **Speed**: Moderate
|
|
29
|
-
- **Quality**: High quality with context awareness
|
|
30
|
-
|
|
31
|
-
**Example:**
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
contractspec build spec.contracts.ts --agent-mode cursor
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
**Note**: This mode requires Windsurf/Cursor CLI access. If not available, falls back to simple mode.
|
|
38
|
-
|
|
39
|
-
### 3. Claude Code Mode
|
|
40
|
-
|
|
41
|
-
- **Mode**: `claude-code`
|
|
42
|
-
- **Description**: Uses Anthropic's Claude with extended thinking for code generation
|
|
43
|
-
- **Best For**: Production-quality code, complex logic, thorough validation
|
|
44
|
-
- **Requirements**: `ANTHROPIC_API_KEY` environment variable
|
|
45
|
-
- **Speed**: Moderate to slow
|
|
46
|
-
- **Quality**: Very high quality, excellent for validation
|
|
47
|
-
|
|
48
|
-
**Features:**
|
|
49
|
-
|
|
50
|
-
- Extended context understanding
|
|
51
|
-
- Detailed code review capabilities
|
|
52
|
-
- Comprehensive validation reports
|
|
53
|
-
- Best for critical implementations
|
|
54
|
-
|
|
55
|
-
**Example:**
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
export ANTHROPIC_API_KEY=your_key
|
|
59
|
-
contractspec build spec.contracts.ts --agent-mode claude-code
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
### 4. OpenAI Codex Mode
|
|
63
|
-
|
|
64
|
-
- **Mode**: `openai-codex`
|
|
65
|
-
- **Description**: Uses OpenAI's GPT-4o and o1 models for code generation
|
|
66
|
-
- **Best For**: Complex algorithms, optimization tasks
|
|
67
|
-
- **Requirements**: `OPENAI_API_KEY` environment variable
|
|
68
|
-
- **Speed**: Fast (GPT-4o) to slow (o1 reasoning)
|
|
69
|
-
- **Quality**: High quality, excellent for algorithmic problems
|
|
70
|
-
|
|
71
|
-
**Features:**
|
|
72
|
-
|
|
73
|
-
- Automatically selects o1 for complex tasks
|
|
74
|
-
- Uses GPT-4o for standard generation
|
|
75
|
-
- Strong at optimization and algorithms
|
|
76
|
-
|
|
77
|
-
**Example:**
|
|
78
|
-
|
|
79
|
-
```bash
|
|
80
|
-
export OPENAI_API_KEY=your_key
|
|
81
|
-
contractspec build spec.contracts.ts --agent-mode openai-codex
|
|
82
|
-
```
|
|
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
|
-
|
|
99
|
-
## Configuring Agent Modes
|
|
100
|
-
|
|
101
|
-
### Via Configuration File
|
|
102
|
-
|
|
103
|
-
Add to `.contractsrc.json`:
|
|
104
|
-
|
|
105
|
-
```json
|
|
106
|
-
{
|
|
107
|
-
"aiProvider": "claude",
|
|
108
|
-
"agentMode": "claude-code",
|
|
109
|
-
"aiModel": "claude-3-7-sonnet-20250219"
|
|
110
|
-
}
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### Via Environment Variables
|
|
114
|
-
|
|
115
|
-
```bash
|
|
116
|
-
export CONTRACTSPEC_AGENT_MODE=claude-code
|
|
117
|
-
export CONTRACTSPEC_AI_PROVIDER=claude
|
|
118
|
-
export ANTHROPIC_API_KEY=your_key
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
### Via CLI Options
|
|
122
|
-
|
|
123
|
-
```bash
|
|
124
|
-
contractspec build spec.ts --agent-mode claude-code --provider claude
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
## Agent Mode Comparison
|
|
128
|
-
|
|
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 |
|
|
136
|
-
|
|
137
|
-
## Fallback Behavior
|
|
138
|
-
|
|
139
|
-
The CLI automatically falls back to simpler modes if the primary mode fails:
|
|
140
|
-
|
|
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)
|
|
146
|
-
|
|
147
|
-
## Usage Examples
|
|
148
|
-
|
|
149
|
-
### Build with Agent Mode
|
|
150
|
-
|
|
151
|
-
```bash
|
|
152
|
-
# Use Claude Code for high-quality generation
|
|
153
|
-
contractspec build user.contracts.ts --agent-mode claude-code
|
|
154
|
-
|
|
155
|
-
# Use OpenAI for algorithmic code
|
|
156
|
-
contractspec build optimizer.contracts.ts --agent-mode openai-codex
|
|
157
|
-
|
|
158
|
-
# Use OpenCode for self-hosted backends
|
|
159
|
-
contractspec build spec.contracts.ts --agent-mode opencode
|
|
160
|
-
|
|
161
|
-
# Disable AI entirely
|
|
162
|
-
contractspec build simple.contracts.ts --no-agent
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
### Validate with Agent Mode
|
|
166
|
-
|
|
167
|
-
```bash
|
|
168
|
-
# Validate implementation with AI
|
|
169
|
-
contractspec validate user.contracts.ts --check-implementation --agent-mode claude-code
|
|
170
|
-
|
|
171
|
-
# Interactive validation
|
|
172
|
-
contractspec validate user.contracts.ts -i --agent-mode claude-code
|
|
173
|
-
|
|
174
|
-
# Validate with OpenCode
|
|
175
|
-
contractspec validate user.contracts.ts --check-implementation --agent-mode opencode
|
|
176
|
-
|
|
177
|
-
# Specify implementation path
|
|
178
|
-
contractspec validate user.contracts.ts \
|
|
179
|
-
--check-implementation \
|
|
180
|
-
--implementation-path ./handlers/user.handler.ts \
|
|
181
|
-
--agent-mode claude-code
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
## Best Practices
|
|
185
|
-
|
|
186
|
-
### For Development
|
|
187
|
-
|
|
188
|
-
- Use **simple** mode for rapid iteration
|
|
189
|
-
- Use **cursor** mode if working in Windsurf/Cursor
|
|
190
|
-
|
|
191
|
-
### For Production
|
|
192
|
-
|
|
193
|
-
- Use **claude-code** for critical implementations
|
|
194
|
-
- Always validate with `--check-implementation`
|
|
195
|
-
- Review AI-generated code before committing
|
|
196
|
-
|
|
197
|
-
### For Complex Logic
|
|
198
|
-
|
|
199
|
-
- Use **openai-codex** for algorithmic problems
|
|
200
|
-
- Use **claude-code** for comprehensive validation
|
|
201
|
-
|
|
202
|
-
### For Self-Hosted Backends
|
|
203
|
-
|
|
204
|
-
- Use **opencode** when running an OpenCode server
|
|
205
|
-
|
|
206
|
-
### For CI/CD
|
|
207
|
-
|
|
208
|
-
- Use **simple** mode for speed
|
|
209
|
-
- Configure via environment variables
|
|
210
|
-
- Set up validation in pre-commit hooks
|
|
211
|
-
|
|
212
|
-
## Troubleshooting
|
|
213
|
-
|
|
214
|
-
### Agent Mode Not Working
|
|
215
|
-
|
|
216
|
-
Check:
|
|
217
|
-
|
|
218
|
-
1. API keys are set correctly
|
|
219
|
-
2. Network connectivity to AI providers
|
|
220
|
-
3. Provider quotas and rate limits
|
|
221
|
-
|
|
222
|
-
### Fallback to Simple Mode
|
|
223
|
-
|
|
224
|
-
This happens when:
|
|
225
|
-
|
|
226
|
-
- API key is missing
|
|
227
|
-
- Provider is unavailable
|
|
228
|
-
- Agent cannot handle the task
|
|
229
|
-
|
|
230
|
-
The CLI will show warnings explaining why.
|
|
231
|
-
|
|
232
|
-
### Poor Quality Output
|
|
233
|
-
|
|
234
|
-
Try:
|
|
235
|
-
|
|
236
|
-
1. Using a more powerful agent mode
|
|
237
|
-
2. Adding more context to your spec
|
|
238
|
-
3. Reviewing and refining the spec structure
|
|
239
|
-
|
|
240
|
-
## Environment Variables Reference
|
|
241
|
-
|
|
242
|
-
```bash
|
|
243
|
-
# Provider selection
|
|
244
|
-
CONTRACTSPEC_AI_PROVIDER=claude|openai|ollama|custom
|
|
245
|
-
|
|
246
|
-
# Agent mode
|
|
247
|
-
CONTRACTSPEC_AGENT_MODE=simple|cursor|claude-code|openai-codex|opencode
|
|
248
|
-
|
|
249
|
-
# Model selection
|
|
250
|
-
CONTRACTSPEC_AI_MODEL=claude-3-7-sonnet-20250219
|
|
251
|
-
|
|
252
|
-
# API Keys
|
|
253
|
-
ANTHROPIC_API_KEY=your_anthropic_key
|
|
254
|
-
OPENAI_API_KEY=your_openai_key
|
|
255
|
-
|
|
256
|
-
# Custom endpoints
|
|
257
|
-
CONTRACTSPEC_LLM_ENDPOINT=https://your-custom-endpoint
|
|
258
|
-
CONTRACTSPEC_LLM_API_KEY=your_custom_key
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
## Advanced Configuration
|
|
262
|
-
|
|
263
|
-
### Custom Agent Priorities
|
|
264
|
-
|
|
265
|
-
You can configure fallback priorities in `.contractsrc.json`:
|
|
266
|
-
|
|
267
|
-
```json
|
|
268
|
-
{
|
|
269
|
-
"agentMode": "claude-code",
|
|
270
|
-
"aiProvider": "claude",
|
|
271
|
-
"aiModel": "claude-3-7-sonnet-20250219",
|
|
272
|
-
"outputDir": "./src",
|
|
273
|
-
"defaultOwners": ["@team"],
|
|
274
|
-
"defaultTags": ["auto-generated"]
|
|
275
|
-
}
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
### Multi-Model Strategy
|
|
279
|
-
|
|
280
|
-
Use different models for different tasks:
|
|
281
|
-
|
|
282
|
-
```bash
|
|
283
|
-
# Use Claude for generation
|
|
284
|
-
contractspec build spec.ts --agent-mode claude-code
|
|
285
|
-
|
|
286
|
-
# Use OpenAI for validation
|
|
287
|
-
contractspec validate spec.ts \
|
|
288
|
-
--check-implementation \
|
|
289
|
-
--agent-mode openai-codex
|
|
290
|
-
```
|