s9n-devops-agent 2.0.10 → 2.0.11-dev.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/bin/cs-devops-agent +28 -0
- package/package.json +4 -3
- package/scripts/contract-automation/README.md +515 -0
- package/scripts/contract-automation/analyze-with-llm.js +497 -0
- package/scripts/contract-automation/check-compliance.js +567 -0
- package/scripts/contract-automation/generate-contracts.js +592 -0
- package/scripts/contract-automation/validate-commit.js +422 -0
- package/src/credentials-manager.js +108 -0
- package/src/session-coordinator.js +7 -3
- package/src/setup-cs-devops-agent.js +175 -3
package/bin/cs-devops-agent
CHANGED
|
@@ -9,6 +9,10 @@ import { fileURLToPath } from 'url';
|
|
|
9
9
|
import { dirname, join } from 'path';
|
|
10
10
|
import { spawn } from 'child_process';
|
|
11
11
|
import fs from 'fs';
|
|
12
|
+
import { credentialsManager } from '../src/credentials-manager.js';
|
|
13
|
+
|
|
14
|
+
// Inject credentials immediately
|
|
15
|
+
credentialsManager.injectEnv();
|
|
12
16
|
|
|
13
17
|
const __filename = fileURLToPath(import.meta.url);
|
|
14
18
|
const __dirname = dirname(__filename);
|
|
@@ -113,6 +117,28 @@ switch(command) {
|
|
|
113
117
|
}
|
|
114
118
|
break;
|
|
115
119
|
|
|
120
|
+
case 'creds':
|
|
121
|
+
const subCmd = args[1];
|
|
122
|
+
if (subCmd === 'set-groq-key') {
|
|
123
|
+
const key = args[2];
|
|
124
|
+
if (!key) {
|
|
125
|
+
console.error('Error: Please provide a key. Usage: cs-devops-agent creds set-groq-key <key>');
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
credentialsManager.setGroqApiKey(key);
|
|
129
|
+
console.log('✅ Groq API Key saved securely.');
|
|
130
|
+
} else if (subCmd === 'status') {
|
|
131
|
+
console.log('Credentials Status:');
|
|
132
|
+
console.log(`- Groq API Key: ${credentialsManager.hasGroqApiKey() ? '✅ Configured' : '❌ Missing'}`);
|
|
133
|
+
console.log(`- Storage: ${credentialsManager.hasGroqApiKey() ? 'local_deploy/credentials.json' : 'N/A'}`);
|
|
134
|
+
} else if (subCmd === 'clear') {
|
|
135
|
+
credentialsManager.clearAll();
|
|
136
|
+
console.log('✅ All credentials cleared.');
|
|
137
|
+
} else {
|
|
138
|
+
console.log('Usage: cs-devops-agent creds [set-groq-key <key> | status | clear]');
|
|
139
|
+
}
|
|
140
|
+
break;
|
|
141
|
+
|
|
116
142
|
case 'tutorial':
|
|
117
143
|
// Run interactive tutorial
|
|
118
144
|
runScript(join(rootDir, 'src', 'tutorial-mode.js'), args.slice(1));
|
|
@@ -153,6 +179,7 @@ Commands:
|
|
|
153
179
|
create Create a new session
|
|
154
180
|
close Close an active session
|
|
155
181
|
cleanup Clean up stale sessions
|
|
182
|
+
creds Manage API credentials
|
|
156
183
|
version Show version information
|
|
157
184
|
help Show this help message
|
|
158
185
|
|
|
@@ -163,6 +190,7 @@ Examples:
|
|
|
163
190
|
cs-devops-agent help-topics # Browse comprehensive help
|
|
164
191
|
cs-devops-agent list # List active sessions
|
|
165
192
|
cs-devops-agent create --task api # Create new session for API work
|
|
193
|
+
cs-devops-agent creds status # Check API credential status
|
|
166
194
|
|
|
167
195
|
Environment Variables:
|
|
168
196
|
AC_BRANCH_PREFIX Branch prefix for daily branches
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "s9n-devops-agent",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.11-dev.0",
|
|
4
4
|
"description": "CS_DevOpsAgent - Intelligent Git Automation System with multi-agent support and session management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/cs-devops-agent-worker.js",
|
|
7
7
|
"bin": {
|
|
8
|
-
"s9n-devops-agent": "
|
|
8
|
+
"s9n-devops-agent": "bin/cs-devops-agent"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"bin/",
|
|
@@ -50,7 +50,8 @@
|
|
|
50
50
|
"license": "MIT",
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"chokidar": "^3.5.3",
|
|
53
|
-
"execa": "^7.1.1"
|
|
53
|
+
"execa": "^7.1.1",
|
|
54
|
+
"groq-sdk": "^0.37.0"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
57
|
"jest": "^29.7.0"
|
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
# Contract Automation Scripts
|
|
2
|
+
|
|
3
|
+
**Created:** 2024-12-02
|
|
4
|
+
**Purpose:** Automate contract generation, validation, and compliance checking
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
This directory contains scripts that enable the **DevOps Agent** to automatically generate, validate, and maintain contract files. These scripts prevent duplicate work and conflicts when multiple coding agents work on the same codebase.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Scripts
|
|
15
|
+
|
|
16
|
+
### 1. `generate-contracts.js`
|
|
17
|
+
|
|
18
|
+
**Purpose:** Scan codebase and generate populated contract files using local file system analysis.
|
|
19
|
+
|
|
20
|
+
**Features:**
|
|
21
|
+
- Scans for features, API endpoints, database tables, SQL queries, third-party integrations, and environment variables
|
|
22
|
+
- Uses regex and file parsing (no LLM required)
|
|
23
|
+
- Fast and deterministic
|
|
24
|
+
- Generates JSON output with all discovered information
|
|
25
|
+
|
|
26
|
+
**Usage:**
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Generate all contracts
|
|
30
|
+
node scripts/contract-automation/generate-contracts.js
|
|
31
|
+
|
|
32
|
+
# Generate specific contract
|
|
33
|
+
node scripts/contract-automation/generate-contracts.js --contract=features
|
|
34
|
+
node scripts/contract-automation/generate-contracts.js --contract=api
|
|
35
|
+
|
|
36
|
+
# Verbose output
|
|
37
|
+
node scripts/contract-automation/generate-contracts.js --verbose
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Options:**
|
|
41
|
+
- `--contract=<name>` - Generate specific contract (features, api, database, sql, integrations, infra)
|
|
42
|
+
- `--validate-only` - Only validate, don't generate
|
|
43
|
+
- `--output=<path>` - Output directory (default: House_Rules_Contracts/)
|
|
44
|
+
- `--verbose` - Detailed logging
|
|
45
|
+
|
|
46
|
+
**Output:**
|
|
47
|
+
- `House_Rules_Contracts/contract-scan-results.json` - All discovered information
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
### 2. `analyze-with-llm.js`
|
|
52
|
+
|
|
53
|
+
**Purpose:** Use Groq LLM to perform intelligent analysis and generate human-readable documentation.
|
|
54
|
+
|
|
55
|
+
**Features:**
|
|
56
|
+
- Analyzes scan results from `generate-contracts.js`
|
|
57
|
+
- Generates descriptions, user stories, acceptance criteria
|
|
58
|
+
- Infers API request/response formats
|
|
59
|
+
- Provides security and performance recommendations
|
|
60
|
+
- Validates contract completeness
|
|
61
|
+
|
|
62
|
+
**Usage:**
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Analyze scan results
|
|
66
|
+
node scripts/contract-automation/analyze-with-llm.js --scan-results=House_Rules_Contracts/contract-scan-results.json
|
|
67
|
+
|
|
68
|
+
# Analyze specific file
|
|
69
|
+
node scripts/contract-automation/analyze-with-llm.js --analyze-file=src/features/auth/index.js
|
|
70
|
+
|
|
71
|
+
# Validate existing contracts
|
|
72
|
+
node scripts/contract-automation/analyze-with-llm.js --validate-contracts
|
|
73
|
+
|
|
74
|
+
# Use different model
|
|
75
|
+
node scripts/contract-automation/analyze-with-llm.js --model=mixtral-8x7b-32768 --scan-results=...
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**Options:**
|
|
79
|
+
- `--scan-results=<path>` - Use scan results from generate-contracts.js
|
|
80
|
+
- `--analyze-file=<path>` - Analyze specific file
|
|
81
|
+
- `--validate-contracts` - Validate existing contracts for completeness
|
|
82
|
+
- `--model=<name>` - Groq model to use (default: llama-3.1-70b-versatile)
|
|
83
|
+
- `--verbose` - Detailed logging
|
|
84
|
+
|
|
85
|
+
**Environment Variables:**
|
|
86
|
+
- `OPENAI_API_KEY` - Required (Groq API key via OpenAI-compatible endpoint)
|
|
87
|
+
|
|
88
|
+
**Output:**
|
|
89
|
+
- `House_Rules_Contracts/llm-analysis-results.json` - Enhanced documentation
|
|
90
|
+
|
|
91
|
+
**Available Models:**
|
|
92
|
+
- `llama-3.1-70b-versatile` (default) - Best for complex analysis
|
|
93
|
+
- `llama-3.1-8b-instant` - Faster, good for simple tasks
|
|
94
|
+
- `mixtral-8x7b-32768` - Alternative with large context window
|
|
95
|
+
- `gemini-2.5-flash` - Fast and efficient
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
### 3. `validate-commit.js`
|
|
100
|
+
|
|
101
|
+
**Purpose:** Validate commit messages and check if contract files were updated when claimed.
|
|
102
|
+
|
|
103
|
+
**Features:**
|
|
104
|
+
- Parses commit message for contract flags
|
|
105
|
+
- Checks if claimed contract files were actually modified
|
|
106
|
+
- Detects false positives (claimed T but not modified)
|
|
107
|
+
- Detects false negatives (modified but not claimed)
|
|
108
|
+
- Auto-fix mode generates corrected commit message
|
|
109
|
+
|
|
110
|
+
**Commit Format:**
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
feat(api): add user profile endpoint
|
|
114
|
+
|
|
115
|
+
Contracts: [SQL:T, API:T, DB:F, 3RD:F, FEAT:T, INFRA:F]
|
|
116
|
+
|
|
117
|
+
[WHY section explaining motivation...]
|
|
118
|
+
|
|
119
|
+
[WHAT section listing file changes...]
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Contract Flags:**
|
|
123
|
+
- `SQL:T/F` - SQL_CONTRACT.json modified
|
|
124
|
+
- `API:T/F` - API_CONTRACT.md modified
|
|
125
|
+
- `DB:T/F` - DATABASE_SCHEMA_CONTRACT.md modified
|
|
126
|
+
- `3RD:T/F` - THIRD_PARTY_INTEGRATIONS.md modified
|
|
127
|
+
- `FEAT:T/F` - FEATURES_CONTRACT.md modified
|
|
128
|
+
- `INFRA:T/F` - INFRA_CONTRACT.md modified
|
|
129
|
+
|
|
130
|
+
**Usage:**
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Validate commit message
|
|
134
|
+
node scripts/contract-automation/validate-commit.js
|
|
135
|
+
|
|
136
|
+
# Validate with staged files check
|
|
137
|
+
node scripts/contract-automation/validate-commit.js --check-staged
|
|
138
|
+
|
|
139
|
+
# Auto-fix incorrect flags
|
|
140
|
+
node scripts/contract-automation/validate-commit.js --check-staged --auto-fix
|
|
141
|
+
|
|
142
|
+
# Strict mode (warnings = errors)
|
|
143
|
+
node scripts/contract-automation/validate-commit.js --check-staged --strict
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**Options:**
|
|
147
|
+
- `--commit-msg=<path>` - Path to commit message file (default: .claude-commit-msg)
|
|
148
|
+
- `--check-staged` - Check staged files in git
|
|
149
|
+
- `--strict` - Fail on warnings
|
|
150
|
+
- `--auto-fix` - Suggest correct contract flags
|
|
151
|
+
|
|
152
|
+
**Output:**
|
|
153
|
+
- Validation report with errors/warnings
|
|
154
|
+
- Exit code 0 (pass) or 1 (fail)
|
|
155
|
+
- `.claude-commit-msg.corrected` (if --auto-fix used)
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
### 4. `check-compliance.js`
|
|
160
|
+
|
|
161
|
+
**Purpose:** Check if codebase is in sync with contract files.
|
|
162
|
+
|
|
163
|
+
**Features:**
|
|
164
|
+
- Detects items in code but missing from contracts
|
|
165
|
+
- Detects items in contracts but missing from code
|
|
166
|
+
- Comprehensive scanning of all contract types
|
|
167
|
+
- JSON and text report formats
|
|
168
|
+
- Strict mode for CI/CD integration
|
|
169
|
+
|
|
170
|
+
**Usage:**
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
# Check compliance
|
|
174
|
+
node scripts/contract-automation/check-compliance.js
|
|
175
|
+
|
|
176
|
+
# Generate JSON report
|
|
177
|
+
node scripts/contract-automation/check-compliance.js --report=json
|
|
178
|
+
|
|
179
|
+
# Strict mode (exit with error if issues found)
|
|
180
|
+
node scripts/contract-automation/check-compliance.js --strict
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
**Options:**
|
|
184
|
+
- `--fix` - Generate missing contract entries (future feature)
|
|
185
|
+
- `--report=<format>` - Output format (text|json|html)
|
|
186
|
+
- `--strict` - Exit with error if any discrepancies found
|
|
187
|
+
|
|
188
|
+
**Output:**
|
|
189
|
+
- Compliance report showing missing/extra items
|
|
190
|
+
- Exit code 0 (compliant) or 1 (non-compliant in strict mode)
|
|
191
|
+
|
|
192
|
+
**What It Checks:**
|
|
193
|
+
- ✅ Features in code vs FEATURES_CONTRACT.md
|
|
194
|
+
- ✅ API endpoints in code vs API_CONTRACT.md
|
|
195
|
+
- ✅ Database tables in migrations vs DATABASE_SCHEMA_CONTRACT.md
|
|
196
|
+
- ✅ Third-party services in package.json vs THIRD_PARTY_INTEGRATIONS.md
|
|
197
|
+
- ✅ Environment variables in code vs INFRA_CONTRACT.md
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Workflow
|
|
202
|
+
|
|
203
|
+
### Initial Contract Population
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
# Step 1: Scan codebase
|
|
207
|
+
node scripts/contract-automation/generate-contracts.js --verbose
|
|
208
|
+
|
|
209
|
+
# Step 2: Analyze with LLM for rich documentation
|
|
210
|
+
node scripts/contract-automation/analyze-with-llm.js \
|
|
211
|
+
--scan-results=House_Rules_Contracts/contract-scan-results.json
|
|
212
|
+
|
|
213
|
+
# Step 3: Review results
|
|
214
|
+
cat House_Rules_Contracts/llm-analysis-results.json
|
|
215
|
+
|
|
216
|
+
# Step 4: Manually populate contract files using the results
|
|
217
|
+
# (Future: automated population script)
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Pre-Commit Validation
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
# Before committing, validate commit message and contract updates
|
|
224
|
+
node scripts/contract-automation/validate-commit.js --check-staged --auto-fix
|
|
225
|
+
|
|
226
|
+
# If validation fails, review and fix
|
|
227
|
+
cat .claude-commit-msg.corrected
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Periodic Compliance Check
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
# Check if contracts are up-to-date
|
|
234
|
+
node scripts/contract-automation/check-compliance.js
|
|
235
|
+
|
|
236
|
+
# If issues found, update contracts or remove stale entries
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### CI/CD Integration
|
|
240
|
+
|
|
241
|
+
```yaml
|
|
242
|
+
# .github/workflows/contract-validation.yml
|
|
243
|
+
name: Contract Validation
|
|
244
|
+
|
|
245
|
+
on: [pull_request]
|
|
246
|
+
|
|
247
|
+
jobs:
|
|
248
|
+
validate:
|
|
249
|
+
runs-on: ubuntu-latest
|
|
250
|
+
steps:
|
|
251
|
+
- uses: actions/checkout@v2
|
|
252
|
+
- uses: actions/setup-node@v2
|
|
253
|
+
|
|
254
|
+
- name: Check Contract Compliance
|
|
255
|
+
run: node scripts/contract-automation/check-compliance.js --strict --report=json
|
|
256
|
+
|
|
257
|
+
- name: Validate Commit Message
|
|
258
|
+
run: |
|
|
259
|
+
git log -1 --pretty=%B > commit-msg.txt
|
|
260
|
+
node scripts/contract-automation/validate-commit.js --commit-msg=commit-msg.txt
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## Dependencies
|
|
266
|
+
|
|
267
|
+
### Node.js Packages
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
# Install dependencies
|
|
271
|
+
npm install openai
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Environment Variables
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
# For LLM analysis (analyze-with-llm.js)
|
|
278
|
+
export OPENAI_API_KEY="your-groq-api-key"
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## Architecture
|
|
284
|
+
|
|
285
|
+
### Local Scanning (generate-contracts.js)
|
|
286
|
+
|
|
287
|
+
**Approach:** File system operations + regex + AST parsing
|
|
288
|
+
|
|
289
|
+
**Pros:**
|
|
290
|
+
- ✅ Fast and deterministic
|
|
291
|
+
- ✅ No API costs
|
|
292
|
+
- ✅ Works offline
|
|
293
|
+
- ✅ Reliable for structured data
|
|
294
|
+
|
|
295
|
+
**Cons:**
|
|
296
|
+
- ❌ Cannot infer intent or relationships
|
|
297
|
+
- ❌ Limited to pattern matching
|
|
298
|
+
- ❌ No natural language descriptions
|
|
299
|
+
|
|
300
|
+
**Best For:**
|
|
301
|
+
- Initial discovery
|
|
302
|
+
- Structured data extraction
|
|
303
|
+
- Fast iteration
|
|
304
|
+
|
|
305
|
+
### LLM Analysis (analyze-with-llm.js)
|
|
306
|
+
|
|
307
|
+
**Approach:** Groq LLM via OpenAI-compatible API
|
|
308
|
+
|
|
309
|
+
**Pros:**
|
|
310
|
+
- ✅ Understands code intent
|
|
311
|
+
- ✅ Generates human-readable docs
|
|
312
|
+
- ✅ Infers relationships and dependencies
|
|
313
|
+
- ✅ Provides recommendations
|
|
314
|
+
|
|
315
|
+
**Cons:**
|
|
316
|
+
- ❌ Requires API key
|
|
317
|
+
- ❌ Slower than local scanning
|
|
318
|
+
- ❌ Non-deterministic output
|
|
319
|
+
- ❌ API costs (minimal with Groq)
|
|
320
|
+
|
|
321
|
+
**Best For:**
|
|
322
|
+
- Rich documentation
|
|
323
|
+
- Gap analysis
|
|
324
|
+
- Validation
|
|
325
|
+
- Recommendations
|
|
326
|
+
|
|
327
|
+
### Hybrid Approach (Recommended)
|
|
328
|
+
|
|
329
|
+
1. **Use local scanning** for initial discovery
|
|
330
|
+
2. **Use LLM analysis** for enhancement and validation
|
|
331
|
+
3. **Combine results** for comprehensive documentation
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
## Examples
|
|
336
|
+
|
|
337
|
+
### Example 1: Full Contract Generation
|
|
338
|
+
|
|
339
|
+
```bash
|
|
340
|
+
# Scan codebase
|
|
341
|
+
node scripts/contract-automation/generate-contracts.js --verbose
|
|
342
|
+
|
|
343
|
+
# Output: House_Rules_Contracts/contract-scan-results.json
|
|
344
|
+
# {
|
|
345
|
+
# "results": {
|
|
346
|
+
# "features": [
|
|
347
|
+
# { "id": "F-001", "name": "User Authentication", "path": "src/features/auth" }
|
|
348
|
+
# ],
|
|
349
|
+
# "api": [
|
|
350
|
+
# { "method": "POST", "path": "/api/v1/auth/login", "source": "src/api/auth.js" }
|
|
351
|
+
# ],
|
|
352
|
+
# ...
|
|
353
|
+
# }
|
|
354
|
+
# }
|
|
355
|
+
|
|
356
|
+
# Analyze with LLM
|
|
357
|
+
node scripts/contract-automation/analyze-with-llm.js \
|
|
358
|
+
--scan-results=House_Rules_Contracts/contract-scan-results.json
|
|
359
|
+
|
|
360
|
+
# Output: House_Rules_Contracts/llm-analysis-results.json
|
|
361
|
+
# {
|
|
362
|
+
# "results": {
|
|
363
|
+
# "features": [
|
|
364
|
+
# {
|
|
365
|
+
# "id": "F-001",
|
|
366
|
+
# "name": "User Authentication",
|
|
367
|
+
# "description": "Provides secure user authentication with JWT tokens...",
|
|
368
|
+
# "userStory": "As a user, I want to log in securely so that...",
|
|
369
|
+
# "acceptanceCriteria": [...]
|
|
370
|
+
# }
|
|
371
|
+
# ]
|
|
372
|
+
# }
|
|
373
|
+
# }
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### Example 2: Commit Validation
|
|
377
|
+
|
|
378
|
+
```bash
|
|
379
|
+
# Create commit message
|
|
380
|
+
cat > .claude-commit-msg << 'EOF'
|
|
381
|
+
feat(api): add user profile endpoint
|
|
382
|
+
|
|
383
|
+
Contracts: [SQL:T, API:T, DB:F, 3RD:F, FEAT:T, INFRA:F]
|
|
384
|
+
|
|
385
|
+
[WHY] Users need to view and update their profile information.
|
|
386
|
+
|
|
387
|
+
[WHAT]
|
|
388
|
+
- File(s): src/api/profile.js - Added GET /api/v1/profile endpoint
|
|
389
|
+
- File(s): House_Rules_Contracts/API_CONTRACT.md - Documented new endpoint
|
|
390
|
+
- File(s): House_Rules_Contracts/SQL_CONTRACT.json - Added get_user_profile query
|
|
391
|
+
EOF
|
|
392
|
+
|
|
393
|
+
# Validate
|
|
394
|
+
node scripts/contract-automation/validate-commit.js --check-staged
|
|
395
|
+
|
|
396
|
+
# Output:
|
|
397
|
+
# [SUCCESS] VALIDATION PASSED ✅
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
### Example 3: Compliance Check
|
|
401
|
+
|
|
402
|
+
```bash
|
|
403
|
+
# Check compliance
|
|
404
|
+
node scripts/contract-automation/check-compliance.js
|
|
405
|
+
|
|
406
|
+
# Output:
|
|
407
|
+
# ============================================================
|
|
408
|
+
# CONTRACT COMPLIANCE REPORT
|
|
409
|
+
# ============================================================
|
|
410
|
+
#
|
|
411
|
+
# FEATURES:
|
|
412
|
+
# Missing in contract (2):
|
|
413
|
+
# - payment-processing
|
|
414
|
+
# - notification-service
|
|
415
|
+
#
|
|
416
|
+
# API ENDPOINTS:
|
|
417
|
+
# Missing in contract (5):
|
|
418
|
+
# - POST /api/v1/payments/charge
|
|
419
|
+
# - GET /api/v1/notifications
|
|
420
|
+
# ...
|
|
421
|
+
#
|
|
422
|
+
# ============================================================
|
|
423
|
+
# COMPLIANCE CHECK FAILED ❌
|
|
424
|
+
# Found 7 items missing from contracts.
|
|
425
|
+
# Run with --fix to generate missing entries.
|
|
426
|
+
# ============================================================
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
---
|
|
430
|
+
|
|
431
|
+
## Future Enhancements
|
|
432
|
+
|
|
433
|
+
### Planned Features
|
|
434
|
+
|
|
435
|
+
1. **Auto-fix for compliance** - Automatically generate missing contract entries
|
|
436
|
+
2. **Contract diff tool** - Show changes between contract versions
|
|
437
|
+
3. **Visual reports** - HTML reports with charts and graphs
|
|
438
|
+
4. **Git hooks** - Pre-commit and pre-push hooks for validation
|
|
439
|
+
5. **IDE integration** - VSCode extension for real-time validation
|
|
440
|
+
6. **Contract versioning** - Track contract changes over time
|
|
441
|
+
7. **Dependency graph** - Visualize relationships between contracts
|
|
442
|
+
|
|
443
|
+
### Integration Ideas
|
|
444
|
+
|
|
445
|
+
1. **GitHub Actions** - Automated validation on PRs
|
|
446
|
+
2. **Pre-commit hooks** - Validate before allowing commits
|
|
447
|
+
3. **Slack notifications** - Alert team of compliance issues
|
|
448
|
+
4. **Dashboard** - Web UI for contract status
|
|
449
|
+
5. **API** - RESTful API for contract queries
|
|
450
|
+
|
|
451
|
+
---
|
|
452
|
+
|
|
453
|
+
## Troubleshooting
|
|
454
|
+
|
|
455
|
+
### Issue: "Contract directory not found"
|
|
456
|
+
|
|
457
|
+
**Solution:** Merge the contract system branch first or create the directory:
|
|
458
|
+
|
|
459
|
+
```bash
|
|
460
|
+
mkdir -p House_Rules_Contracts
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
### Issue: "OPENAI_API_KEY not set"
|
|
464
|
+
|
|
465
|
+
**Solution:** Set the environment variable:
|
|
466
|
+
|
|
467
|
+
```bash
|
|
468
|
+
export OPENAI_API_KEY="your-groq-api-key"
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
### Issue: "No files found"
|
|
472
|
+
|
|
473
|
+
**Solution:** Ensure you're running from the repository root:
|
|
474
|
+
|
|
475
|
+
```bash
|
|
476
|
+
cd /path/to/CS_DevOpsAgent
|
|
477
|
+
node scripts/contract-automation/generate-contracts.js
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
### Issue: "Permission denied"
|
|
481
|
+
|
|
482
|
+
**Solution:** Make scripts executable:
|
|
483
|
+
|
|
484
|
+
```bash
|
|
485
|
+
chmod +x scripts/contract-automation/*.js
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
---
|
|
489
|
+
|
|
490
|
+
## Best Practices
|
|
491
|
+
|
|
492
|
+
1. **Run generate-contracts.js first** - Get raw data before LLM analysis
|
|
493
|
+
2. **Use LLM analysis sparingly** - API costs add up, use for validation
|
|
494
|
+
3. **Validate commits before pushing** - Catch issues early
|
|
495
|
+
4. **Run compliance checks weekly** - Keep contracts up-to-date
|
|
496
|
+
5. **Review auto-generated content** - Don't blindly trust automation
|
|
497
|
+
6. **Version control contracts** - Track changes over time
|
|
498
|
+
7. **Document exceptions** - If something can't be automated, document why
|
|
499
|
+
|
|
500
|
+
---
|
|
501
|
+
|
|
502
|
+
## Contributing
|
|
503
|
+
|
|
504
|
+
When adding new scripts:
|
|
505
|
+
|
|
506
|
+
1. Follow the existing structure and naming conventions
|
|
507
|
+
2. Add comprehensive help text and usage examples
|
|
508
|
+
3. Support `--verbose` flag for debugging
|
|
509
|
+
4. Handle errors gracefully with clear messages
|
|
510
|
+
5. Update this README with new script documentation
|
|
511
|
+
|
|
512
|
+
---
|
|
513
|
+
|
|
514
|
+
**Status:** ✅ Ready for use
|
|
515
|
+
**Last Updated:** 2024-12-02
|