@lssm/app.cli-contractspec 0.0.0-canary-20251221165922 → 0.0.0-canary-20251221185840
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/CHANGELOG.md +9 -9
- package/package.json +11 -11
- package/AGENT_MODES.md +0 -247
- package/QUICK_REFERENCE.md +0 -209
- package/QUICK_START.md +0 -174
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.0.0-canary-
|
|
3
|
+
## 0.0.0-canary-20251221185840
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
### Patch Changes
|
|
10
10
|
|
|
11
11
|
- Updated dependencies [66a5dfd]
|
|
12
|
-
- @lssm/bundle.contractspec-workspace@0.0.0-canary-
|
|
13
|
-
- @lssm/lib.ai-providers@0.0.0-canary-
|
|
14
|
-
- @lssm/lib.contracts@0.0.0-canary-
|
|
15
|
-
- @lssm/lib.contracts-transformers@0.0.0-canary-
|
|
16
|
-
- @lssm/lib.schema@0.0.0-canary-
|
|
17
|
-
- @lssm/lib.testing@0.0.0-canary-
|
|
18
|
-
- @lssm/module.ai-chat@0.0.0-canary-
|
|
19
|
-
- @lssm/module.contractspec-examples@0.0.0-canary-
|
|
12
|
+
- @lssm/bundle.contractspec-workspace@0.0.0-canary-20251221185840
|
|
13
|
+
- @lssm/lib.ai-providers@0.0.0-canary-20251221185840
|
|
14
|
+
- @lssm/lib.contracts@0.0.0-canary-20251221185840
|
|
15
|
+
- @lssm/lib.contracts-transformers@0.0.0-canary-20251221185840
|
|
16
|
+
- @lssm/lib.schema@0.0.0-canary-20251221185840
|
|
17
|
+
- @lssm/lib.testing@0.0.0-canary-20251221185840
|
|
18
|
+
- @lssm/module.ai-chat@0.0.0-canary-20251221185840
|
|
19
|
+
- @lssm/module.contractspec-examples@0.0.0-canary-20251221185840
|
|
20
20
|
|
|
21
21
|
## 0.12.0
|
|
22
22
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lssm/app.cli-contractspec",
|
|
3
|
-
"version": "0.0.0-canary-
|
|
3
|
+
"version": "0.0.0-canary-20251221185840",
|
|
4
4
|
"description": "CLI tool for creating, building, and validating contract specifications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
"@ai-sdk/mistral": "beta",
|
|
35
35
|
"@ai-sdk/openai": "beta",
|
|
36
36
|
"ollama-ai-provider": "^1.2.0",
|
|
37
|
-
"@lssm/bundle.contractspec-workspace": "0.0.0-canary-
|
|
38
|
-
"@lssm/lib.ai-providers": "0.0.0-canary-
|
|
39
|
-
"@lssm/lib.contracts": "0.0.0-canary-
|
|
40
|
-
"@lssm/lib.contracts-transformers": "0.0.0-canary-
|
|
41
|
-
"@lssm/lib.testing": "0.0.0-canary-
|
|
42
|
-
"@lssm/lib.schema": "0.0.0-canary-
|
|
43
|
-
"@lssm/module.ai-chat": "0.0.0-canary-
|
|
44
|
-
"@lssm/module.contractspec-examples": "0.0.0-canary-
|
|
37
|
+
"@lssm/bundle.contractspec-workspace": "0.0.0-canary-20251221185840",
|
|
38
|
+
"@lssm/lib.ai-providers": "0.0.0-canary-20251221185840",
|
|
39
|
+
"@lssm/lib.contracts": "0.0.0-canary-20251221185840",
|
|
40
|
+
"@lssm/lib.contracts-transformers": "0.0.0-canary-20251221185840",
|
|
41
|
+
"@lssm/lib.testing": "0.0.0-canary-20251221185840",
|
|
42
|
+
"@lssm/lib.schema": "0.0.0-canary-20251221185840",
|
|
43
|
+
"@lssm/module.ai-chat": "0.0.0-canary-20251221185840",
|
|
44
|
+
"@lssm/module.contractspec-examples": "0.0.0-canary-20251221185840",
|
|
45
45
|
"glob": "^13.0.0",
|
|
46
46
|
"commander": "^14.0.2",
|
|
47
47
|
"@inquirer/prompts": "^8.1.0",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"zod": "^4.1.13"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@lssm/tool.tsdown": "0.0.0-canary-
|
|
55
|
-
"@lssm/tool.typescript": "0.0.0-canary-
|
|
54
|
+
"@lssm/tool.tsdown": "0.0.0-canary-20251221185840",
|
|
55
|
+
"@lssm/tool.typescript": "0.0.0-canary-20251221185840",
|
|
56
56
|
"@types/node": "^22.10.2",
|
|
57
57
|
"rimraf": "^6.1.2",
|
|
58
58
|
"eslint": "^9.39.2"
|
package/AGENT_MODES.md
DELETED
|
@@ -1,247 +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
|
-
- **Mode**: `simple`
|
|
9
|
-
- **Description**: Direct LLM API calls for code generation
|
|
10
|
-
- **Best For**: Quick prototyping, basic implementations
|
|
11
|
-
- **Requirements**: API key for your chosen provider (Claude, OpenAI, Ollama)
|
|
12
|
-
- **Speed**: Fast
|
|
13
|
-
- **Quality**: Good baseline quality
|
|
14
|
-
|
|
15
|
-
**Example:**
|
|
16
|
-
```bash
|
|
17
|
-
contractspec build spec.contracts.ts --agent-mode simple
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
### 2. Cursor Agent Mode
|
|
21
|
-
- **Mode**: `cursor`
|
|
22
|
-
- **Description**: Leverages Windsurf/Cursor's agentic capabilities
|
|
23
|
-
- **Best For**: Complex implementations, iterative development
|
|
24
|
-
- **Requirements**: Running in Windsurf/Cursor environment
|
|
25
|
-
- **Speed**: Moderate
|
|
26
|
-
- **Quality**: High quality with context awareness
|
|
27
|
-
|
|
28
|
-
**Example:**
|
|
29
|
-
```bash
|
|
30
|
-
contractspec build spec.contracts.ts --agent-mode cursor
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
**Note**: This mode requires Windsurf/Cursor CLI access. If not available, falls back to simple mode.
|
|
34
|
-
|
|
35
|
-
### 3. Claude Code Mode
|
|
36
|
-
- **Mode**: `claude-code`
|
|
37
|
-
- **Description**: Uses Anthropic's Claude with extended thinking for code generation
|
|
38
|
-
- **Best For**: Production-quality code, complex logic, thorough validation
|
|
39
|
-
- **Requirements**: `ANTHROPIC_API_KEY` environment variable
|
|
40
|
-
- **Speed**: Moderate to slow
|
|
41
|
-
- **Quality**: Very high quality, excellent for validation
|
|
42
|
-
|
|
43
|
-
**Features:**
|
|
44
|
-
- Extended context understanding
|
|
45
|
-
- Detailed code review capabilities
|
|
46
|
-
- Comprehensive validation reports
|
|
47
|
-
- Best for critical implementations
|
|
48
|
-
|
|
49
|
-
**Example:**
|
|
50
|
-
```bash
|
|
51
|
-
export ANTHROPIC_API_KEY=your_key
|
|
52
|
-
contractspec build spec.contracts.ts --agent-mode claude-code
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### 4. OpenAI Codex Mode
|
|
56
|
-
- **Mode**: `openai-codex`
|
|
57
|
-
- **Description**: Uses OpenAI's GPT-4o and o1 models for code generation
|
|
58
|
-
- **Best For**: Complex algorithms, optimization tasks
|
|
59
|
-
- **Requirements**: `OPENAI_API_KEY` environment variable
|
|
60
|
-
- **Speed**: Fast (GPT-4o) to slow (o1 reasoning)
|
|
61
|
-
- **Quality**: High quality, excellent for algorithmic problems
|
|
62
|
-
|
|
63
|
-
**Features:**
|
|
64
|
-
- Automatically selects o1 for complex tasks
|
|
65
|
-
- Uses GPT-4o for standard generation
|
|
66
|
-
- Strong at optimization and algorithms
|
|
67
|
-
|
|
68
|
-
**Example:**
|
|
69
|
-
```bash
|
|
70
|
-
export OPENAI_API_KEY=your_key
|
|
71
|
-
contractspec build spec.contracts.ts --agent-mode openai-codex
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## Configuring Agent Modes
|
|
75
|
-
|
|
76
|
-
### Via Configuration File
|
|
77
|
-
|
|
78
|
-
Add to `.contractsrc.json`:
|
|
79
|
-
|
|
80
|
-
```json
|
|
81
|
-
{
|
|
82
|
-
"aiProvider": "claude",
|
|
83
|
-
"agentMode": "claude-code",
|
|
84
|
-
"aiModel": "claude-3-7-sonnet-20250219"
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### Via Environment Variables
|
|
89
|
-
|
|
90
|
-
```bash
|
|
91
|
-
export CONTRACTSPEC_AGENT_MODE=claude-code
|
|
92
|
-
export CONTRACTSPEC_AI_PROVIDER=claude
|
|
93
|
-
export ANTHROPIC_API_KEY=your_key
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### Via CLI Options
|
|
97
|
-
|
|
98
|
-
```bash
|
|
99
|
-
contractspec build spec.ts --agent-mode claude-code --provider claude
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
## Agent Mode Comparison
|
|
103
|
-
|
|
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 |
|
|
111
|
-
|
|
112
|
-
## Fallback Behavior
|
|
113
|
-
|
|
114
|
-
The CLI automatically falls back to simpler modes if the primary mode fails:
|
|
115
|
-
|
|
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)
|
|
120
|
-
|
|
121
|
-
## Usage Examples
|
|
122
|
-
|
|
123
|
-
### Build with Agent Mode
|
|
124
|
-
|
|
125
|
-
```bash
|
|
126
|
-
# Use Claude Code for high-quality generation
|
|
127
|
-
contractspec build user.contracts.ts --agent-mode claude-code
|
|
128
|
-
|
|
129
|
-
# Use OpenAI for algorithmic code
|
|
130
|
-
contractspec build optimizer.contracts.ts --agent-mode openai-codex
|
|
131
|
-
|
|
132
|
-
# Disable AI entirely
|
|
133
|
-
contractspec build simple.contracts.ts --no-agent
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### Validate with Agent Mode
|
|
137
|
-
|
|
138
|
-
```bash
|
|
139
|
-
# Validate implementation with AI
|
|
140
|
-
contractspec validate user.contracts.ts --check-implementation --agent-mode claude-code
|
|
141
|
-
|
|
142
|
-
# Interactive validation
|
|
143
|
-
contractspec validate user.contracts.ts -i --agent-mode claude-code
|
|
144
|
-
|
|
145
|
-
# Specify implementation path
|
|
146
|
-
contractspec validate user.contracts.ts \
|
|
147
|
-
--check-implementation \
|
|
148
|
-
--implementation-path ./handlers/user.handler.ts \
|
|
149
|
-
--agent-mode claude-code
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
## Best Practices
|
|
153
|
-
|
|
154
|
-
### For Development
|
|
155
|
-
- Use **simple** mode for rapid iteration
|
|
156
|
-
- Use **cursor** mode if working in Windsurf/Cursor
|
|
157
|
-
|
|
158
|
-
### For Production
|
|
159
|
-
- Use **claude-code** for critical implementations
|
|
160
|
-
- Always validate with `--check-implementation`
|
|
161
|
-
- Review AI-generated code before committing
|
|
162
|
-
|
|
163
|
-
### For Complex Logic
|
|
164
|
-
- Use **openai-codex** for algorithmic problems
|
|
165
|
-
- Use **claude-code** for comprehensive validation
|
|
166
|
-
|
|
167
|
-
### For CI/CD
|
|
168
|
-
- Use **simple** mode for speed
|
|
169
|
-
- Configure via environment variables
|
|
170
|
-
- Set up validation in pre-commit hooks
|
|
171
|
-
|
|
172
|
-
## Troubleshooting
|
|
173
|
-
|
|
174
|
-
### Agent Mode Not Working
|
|
175
|
-
|
|
176
|
-
Check:
|
|
177
|
-
1. API keys are set correctly
|
|
178
|
-
2. Network connectivity to AI providers
|
|
179
|
-
3. Provider quotas and rate limits
|
|
180
|
-
|
|
181
|
-
### Fallback to Simple Mode
|
|
182
|
-
|
|
183
|
-
This happens when:
|
|
184
|
-
- API key is missing
|
|
185
|
-
- Provider is unavailable
|
|
186
|
-
- Agent cannot handle the task
|
|
187
|
-
|
|
188
|
-
The CLI will show warnings explaining why.
|
|
189
|
-
|
|
190
|
-
### Poor Quality Output
|
|
191
|
-
|
|
192
|
-
Try:
|
|
193
|
-
1. Using a more powerful agent mode
|
|
194
|
-
2. Adding more context to your spec
|
|
195
|
-
3. Reviewing and refining the spec structure
|
|
196
|
-
|
|
197
|
-
## Environment Variables Reference
|
|
198
|
-
|
|
199
|
-
```bash
|
|
200
|
-
# Provider selection
|
|
201
|
-
CONTRACTSPEC_AI_PROVIDER=claude|openai|ollama|custom
|
|
202
|
-
|
|
203
|
-
# Agent mode
|
|
204
|
-
CONTRACTSPEC_AGENT_MODE=simple|cursor|claude-code|openai-codex
|
|
205
|
-
|
|
206
|
-
# Model selection
|
|
207
|
-
CONTRACTSPEC_AI_MODEL=claude-3-7-sonnet-20250219
|
|
208
|
-
|
|
209
|
-
# API Keys
|
|
210
|
-
ANTHROPIC_API_KEY=your_anthropic_key
|
|
211
|
-
OPENAI_API_KEY=your_openai_key
|
|
212
|
-
|
|
213
|
-
# Custom endpoints
|
|
214
|
-
CONTRACTSPEC_LLM_ENDPOINT=https://your-custom-endpoint
|
|
215
|
-
CONTRACTSPEC_LLM_API_KEY=your_custom_key
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
## Advanced Configuration
|
|
219
|
-
|
|
220
|
-
### Custom Agent Priorities
|
|
221
|
-
|
|
222
|
-
You can configure fallback priorities in `.contractsrc.json`:
|
|
223
|
-
|
|
224
|
-
```json
|
|
225
|
-
{
|
|
226
|
-
"agentMode": "claude-code",
|
|
227
|
-
"aiProvider": "claude",
|
|
228
|
-
"aiModel": "claude-3-7-sonnet-20250219",
|
|
229
|
-
"outputDir": "./src",
|
|
230
|
-
"defaultOwners": ["@team"],
|
|
231
|
-
"defaultTags": ["auto-generated"]
|
|
232
|
-
}
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
### Multi-Model Strategy
|
|
236
|
-
|
|
237
|
-
Use different models for different tasks:
|
|
238
|
-
|
|
239
|
-
```bash
|
|
240
|
-
# Use Claude for generation
|
|
241
|
-
contractspec build spec.ts --agent-mode claude-code
|
|
242
|
-
|
|
243
|
-
# Use OpenAI for validation
|
|
244
|
-
contractspec validate spec.ts \
|
|
245
|
-
--check-implementation \
|
|
246
|
-
--agent-mode openai-codex
|
|
247
|
-
```
|
package/QUICK_REFERENCE.md
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
# Quick Reference Guide
|
|
2
|
-
|
|
3
|
-
## New Commands Overview
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
# Discovery & Management
|
|
7
|
-
contractspec list # List all contracts
|
|
8
|
-
contractspec list --type operation # Filter contracts
|
|
9
|
-
contractspec list --pattern 'src/**/*.ts' # Custom discovery pattern
|
|
10
|
-
contractspec list --deep # Load spec modules (richer metadata)
|
|
11
|
-
contractspec deps # Analyze dependencies
|
|
12
|
-
contractspec deps --circular # Find circular deps
|
|
13
|
-
contractspec deps --format dot > deps.dot # GraphViz dot output
|
|
14
|
-
|
|
15
|
-
# Development Workflow
|
|
16
|
-
contractspec watch --build # Auto-build on changes
|
|
17
|
-
contractspec watch --validate # Auto-validate on changes
|
|
18
|
-
contractspec watch --on-start both # Run on startup too
|
|
19
|
-
contractspec watch --continue-on-error # Keep watching even on failures
|
|
20
|
-
|
|
21
|
-
# Maintenance & Comparison
|
|
22
|
-
contractspec clean # Clean generated files
|
|
23
|
-
contractspec clean --dry-run # Preview cleanup
|
|
24
|
-
contractspec diff spec1.ts spec2.ts # Compare specs
|
|
25
|
-
contractspec diff spec.ts spec.ts --baseline main # Compare with git baseline
|
|
26
|
-
contractspec sync # Build all discovered specs
|
|
27
|
-
contractspec sync --buckets api,ui # Repeat builds into ./generated/<bucket>/
|
|
28
|
-
|
|
29
|
-
# Validation & Testing
|
|
30
|
-
contractspec validate '**/*.ts' # Validate all specs
|
|
31
|
-
contractspec validate spec.ts --check-implementation
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## Agent Modes at a Glance
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
# Simple (default) - Fast, basic quality
|
|
38
|
-
contractspec build spec.ts
|
|
39
|
-
|
|
40
|
-
# Claude Code - Best quality, production-ready
|
|
41
|
-
contractspec build spec.ts --agent-mode claude-code
|
|
42
|
-
|
|
43
|
-
# OpenAI Codex - Best for algorithms
|
|
44
|
-
contractspec build spec.ts --agent-mode openai-codex
|
|
45
|
-
|
|
46
|
-
# Cursor - IDE-integrated (Windsurf/Cursor)
|
|
47
|
-
contractspec build spec.ts --agent-mode cursor
|
|
48
|
-
|
|
49
|
-
# No AI - Templates only
|
|
50
|
-
contractspec build spec.ts --no-agent
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
## Build Examples
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
# Basic build
|
|
57
|
-
contractspec build user.contracts.ts
|
|
58
|
-
# (Falls back to templates automatically if the requested agent is unavailable)
|
|
59
|
-
|
|
60
|
-
# Production build with tests
|
|
61
|
-
contractspec build user.contracts.ts --agent-mode claude-code
|
|
62
|
-
|
|
63
|
-
# Fast build without tests
|
|
64
|
-
contractspec build user.contracts.ts --no-tests
|
|
65
|
-
|
|
66
|
-
# Custom output directory
|
|
67
|
-
contractspec build user.contracts.ts -o ./src/handlers
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
## Validation Examples
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
# Validate spec only
|
|
74
|
-
contractspec validate user.contracts.ts
|
|
75
|
-
|
|
76
|
-
# Validate implementation with AI
|
|
77
|
-
contractspec validate user.contracts.ts --check-implementation
|
|
78
|
-
|
|
79
|
-
# Interactive validation
|
|
80
|
-
contractspec validate user.contracts.ts -i
|
|
81
|
-
|
|
82
|
-
# Default prompt (no flags): choose spec-only vs spec+implementation
|
|
83
|
-
contractspec validate user.contracts.ts
|
|
84
|
-
|
|
85
|
-
# Validate with specific implementation
|
|
86
|
-
contractspec validate user.contracts.ts \
|
|
87
|
-
--check-implementation \
|
|
88
|
-
--implementation-path ./handlers/user.handler.ts \
|
|
89
|
-
--agent-mode claude-code
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
## Configuration
|
|
93
|
-
|
|
94
|
-
### Minimal .contractsrc.json
|
|
95
|
-
```json
|
|
96
|
-
{
|
|
97
|
-
"aiProvider": "claude",
|
|
98
|
-
"agentMode": "claude-code",
|
|
99
|
-
"outputDir": "./src"
|
|
100
|
-
}
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### Environment Variables
|
|
104
|
-
```bash
|
|
105
|
-
# Required for Claude
|
|
106
|
-
export ANTHROPIC_API_KEY=sk-ant-...
|
|
107
|
-
|
|
108
|
-
# Required for OpenAI
|
|
109
|
-
export OPENAI_API_KEY=sk-...
|
|
110
|
-
|
|
111
|
-
# Agent mode (optional)
|
|
112
|
-
export CONTRACTSPEC_AGENT_MODE=claude-code
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
## Common Workflows
|
|
116
|
-
|
|
117
|
-
### Development Flow
|
|
118
|
-
```bash
|
|
119
|
-
# 1. Create spec
|
|
120
|
-
contractspec create --type operation --ai
|
|
121
|
-
|
|
122
|
-
# 2. Generate implementation
|
|
123
|
-
contractspec build spec.contracts.ts --agent-mode claude-code
|
|
124
|
-
|
|
125
|
-
# 3. Validate
|
|
126
|
-
contractspec validate spec.contracts.ts --check-implementation
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### CI/CD Flow
|
|
130
|
-
```bash
|
|
131
|
-
# Fast validation in CI
|
|
132
|
-
contractspec validate '**/*.contracts.ts' --agent-mode simple
|
|
133
|
-
|
|
134
|
-
# Validate implementations (skip prompt)
|
|
135
|
-
contractspec validate '**/*.contracts.ts' --check-implementation
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### Multi-Provider Strategy
|
|
139
|
-
```bash
|
|
140
|
-
# Draft with local model (free)
|
|
141
|
-
contractspec create --ai --provider ollama
|
|
142
|
-
|
|
143
|
-
# Build with Claude (quality)
|
|
144
|
-
contractspec build spec.ts --agent-mode claude-code
|
|
145
|
-
|
|
146
|
-
# Validate with OpenAI (cost-effective)
|
|
147
|
-
contractspec validate spec.ts --check-implementation --agent-mode openai-codex
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
## Troubleshooting
|
|
151
|
-
|
|
152
|
-
### AI Not Working
|
|
153
|
-
```bash
|
|
154
|
-
# Check API key
|
|
155
|
-
echo $ANTHROPIC_API_KEY
|
|
156
|
-
|
|
157
|
-
# Use simple mode as fallback
|
|
158
|
-
contractspec build spec.ts --agent-mode simple
|
|
159
|
-
|
|
160
|
-
# Disable AI completely
|
|
161
|
-
contractspec build spec.ts --no-agent
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
### Wrong Implementation Path
|
|
165
|
-
```bash
|
|
166
|
-
# Specify path explicitly
|
|
167
|
-
contractspec validate spec.contracts.ts \
|
|
168
|
-
--check-implementation \
|
|
169
|
-
--implementation-path ./custom/path/handler.ts
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
### Slow Generation
|
|
173
|
-
```bash
|
|
174
|
-
# Use faster agent mode
|
|
175
|
-
contractspec build spec.ts --agent-mode simple
|
|
176
|
-
|
|
177
|
-
# Skip tests
|
|
178
|
-
contractspec build spec.ts --no-tests
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
## Best Practices
|
|
182
|
-
|
|
183
|
-
✅ **DO:**
|
|
184
|
-
- Use `claude-code` for production implementations
|
|
185
|
-
- Validate with `--check-implementation` before committing
|
|
186
|
-
- Set agent mode in `.contractsrc.json` for consistency
|
|
187
|
-
- Use environment variables for API keys
|
|
188
|
-
|
|
189
|
-
❌ **DON'T:**
|
|
190
|
-
- Commit AI-generated code without review
|
|
191
|
-
- Use expensive agents in CI/CD unnecessarily
|
|
192
|
-
- Store API keys in `.contractsrc.json`
|
|
193
|
-
- Skip validation for critical code
|
|
194
|
-
|
|
195
|
-
## Performance Tips
|
|
196
|
-
|
|
197
|
-
| Task | Recommended Agent | Speed | Quality |
|
|
198
|
-
|------|------------------|-------|---------|
|
|
199
|
-
| Prototyping | simple | ⚡⚡⚡ | ⭐⭐⭐ |
|
|
200
|
-
| Production | claude-code | ⚡⚡ | ⭐⭐⭐⭐⭐ |
|
|
201
|
-
| Algorithms | openai-codex | ⚡⚡⚡ | ⭐⭐⭐⭐ |
|
|
202
|
-
| CI/CD | simple | ⚡⚡⚡ | ⭐⭐⭐ |
|
|
203
|
-
| Validation | claude-code | ⚡⚡ | ⭐⭐⭐⭐⭐ |
|
|
204
|
-
|
|
205
|
-
## More Information
|
|
206
|
-
|
|
207
|
-
- Full documentation: [README.md](./README.md)
|
|
208
|
-
- Agent modes guide: [AGENT_MODES.md](./AGENT_MODES.md)
|
|
209
|
-
- Quick start: [QUICK_START.md](./QUICK_START.md)
|
package/QUICK_START.md
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
# Quick Start Guide
|
|
2
|
-
|
|
3
|
-
Get started with contracts-cli in 5 minutes.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
cd packages/lssm/tools/contracts-cli
|
|
9
|
-
pnpm install
|
|
10
|
-
pnpm build
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## First Spec
|
|
14
|
-
|
|
15
|
-
### 1. Create a spec interactively
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
pnpm exec contractspec create
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Follow the prompts:
|
|
22
|
-
- Choose "Operation (Command/Query)"
|
|
23
|
-
- Select "Command"
|
|
24
|
-
- Name: `user.signup`
|
|
25
|
-
- Fill in description, goal, context
|
|
26
|
-
- Set auth to `anonymous`
|
|
27
|
-
- Add owners: `@team`
|
|
28
|
-
|
|
29
|
-
This creates: `src/interactions/commands/user-signup.contracts.ts`
|
|
30
|
-
|
|
31
|
-
### 2. Or use AI assistance
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
export ANTHROPIC_API_KEY=your-key-here
|
|
35
|
-
pnpm exec contractspec create --ai
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
Describe what you want:
|
|
39
|
-
> "Create a command for user signup that takes an email and sends a magic link"
|
|
40
|
-
|
|
41
|
-
Review and accept the AI-generated spec!
|
|
42
|
-
|
|
43
|
-
### 3. Generate handler
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
pnpm exec contractspec build src/interactions/commands/user-signup.contracts.ts
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
This generates:
|
|
50
|
-
- `src/handlers/user-signup.handler.ts` - Implementation stub
|
|
51
|
-
- `src/handlers/user-signup.handler.test.ts` - Tests
|
|
52
|
-
|
|
53
|
-
### 4. Validate
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
pnpm exec contractspec validate src/interactions/commands/user-signup.contracts.ts
|
|
57
|
-
# You'll be prompted to validate the spec only or the implementation as well.
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## Using Local Models (Free!)
|
|
61
|
-
|
|
62
|
-
### Install Ollama
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
# macOS
|
|
66
|
-
brew install ollama
|
|
67
|
-
|
|
68
|
-
# Start Ollama
|
|
69
|
-
ollama serve
|
|
70
|
-
|
|
71
|
-
# Pull a model
|
|
72
|
-
ollama pull codellama
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### Generate with Ollama
|
|
76
|
-
|
|
77
|
-
```bash
|
|
78
|
-
pnpm exec contractspec create --ai --provider ollama --model codellama
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
No API keys needed! Everything runs locally.
|
|
82
|
-
|
|
83
|
-
## Configuration
|
|
84
|
-
|
|
85
|
-
Create `.contractsrc.json` in your project root:
|
|
86
|
-
|
|
87
|
-
```json
|
|
88
|
-
{
|
|
89
|
-
"aiProvider": "claude",
|
|
90
|
-
"outputDir": "./src",
|
|
91
|
-
"defaultOwners": ["@my-team"],
|
|
92
|
-
"conventions": {
|
|
93
|
-
"operations": "interactions/commands|queries",
|
|
94
|
-
"events": "events"
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
Now commands use these defaults:
|
|
100
|
-
|
|
101
|
-
```bash
|
|
102
|
-
# Uses Claude from config
|
|
103
|
-
pnpm exec contractspec create --ai
|
|
104
|
-
|
|
105
|
-
# Override with Ollama
|
|
106
|
-
pnpm exec contractspec create --ai --provider ollama
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
## Next Steps
|
|
110
|
-
|
|
111
|
-
1. **Complete the TODO items** in generated files
|
|
112
|
-
2. **Implement handler logic** with real business rules
|
|
113
|
-
3. **Run tests**: `pnpm test`
|
|
114
|
-
4. **Validate**: `pnpm exec contractspec validate src/**/*.contracts.ts`
|
|
115
|
-
5. **Register in registry** and mount REST/GraphQL adapters
|
|
116
|
-
|
|
117
|
-
## Common Workflows
|
|
118
|
-
|
|
119
|
-
### Create Event
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
pnpm exec contractspec create --type event
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### Build Presentation Component
|
|
126
|
-
|
|
127
|
-
```bash
|
|
128
|
-
pnpm exec contractspec create --type presentation
|
|
129
|
-
pnpm exec contractspec build src/presentations/user-profile.presentation.ts
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### Multi-Spec Workflow
|
|
133
|
-
|
|
134
|
-
```bash
|
|
135
|
-
# Create operation spec
|
|
136
|
-
pnpm exec contractspec create --type operation --ai
|
|
137
|
-
|
|
138
|
-
# Create related event spec
|
|
139
|
-
pnpm exec contractspec create --type event --ai
|
|
140
|
-
|
|
141
|
-
# Generate all implementations
|
|
142
|
-
pnpm exec contractspec build src/contracts/**/*.ts
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
## Tips
|
|
146
|
-
|
|
147
|
-
- Use `--ai` for faster spec creation
|
|
148
|
-
- Use Ollama for free local generation
|
|
149
|
-
- Use Claude/GPT-4 for production-quality code
|
|
150
|
-
- Always validate before committing
|
|
151
|
-
- Keep specs close to implementations
|
|
152
|
-
|
|
153
|
-
## Troubleshooting
|
|
154
|
-
|
|
155
|
-
**No AI provider?**
|
|
156
|
-
```bash
|
|
157
|
-
# Use interactive wizard instead
|
|
158
|
-
pnpm exec contractspec create
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
**Can't find contractspec?**
|
|
162
|
-
```bash
|
|
163
|
-
# Use pnpm exec
|
|
164
|
-
pnpm exec contractspec --help
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
**Import errors?**
|
|
168
|
-
```bash
|
|
169
|
-
# Install dependencies
|
|
170
|
-
pnpm add @lssm/lib.contracts @lssm/lib.schema
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
Happy contract authoring! 🎉
|
|
174
|
-
|