@continum/cli 0.1.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/README.md +481 -0
- package/SETUP.md +517 -0
- package/dist/api/client.d.ts +17 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +70 -0
- package/dist/api/client.js.map +1 -0
- package/dist/commands/init.d.ts +4 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +104 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/login.d.ts +2 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +217 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/patterns.d.ts +3 -0
- package/dist/commands/patterns.d.ts.map +1 -0
- package/dist/commands/patterns.js +67 -0
- package/dist/commands/patterns.js.map +1 -0
- package/dist/commands/scan.d.ts +11 -0
- package/dist/commands/scan.d.ts.map +1 -0
- package/dist/commands/scan.js +219 -0
- package/dist/commands/scan.js.map +1 -0
- package/dist/commands/status.d.ts +2 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +61 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/uninstall.d.ts +2 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +87 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/config/default-config.d.ts +3 -0
- package/dist/config/default-config.d.ts.map +1 -0
- package/dist/config/default-config.js +25 -0
- package/dist/config/default-config.js.map +1 -0
- package/dist/config/loader.d.ts +11 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +96 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/git/git-utils.d.ts +8 -0
- package/dist/git/git-utils.d.ts.map +1 -0
- package/dist/git/git-utils.js +130 -0
- package/dist/git/git-utils.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +63 -0
- package/dist/index.js.map +1 -0
- package/dist/scanner/local-scan.d.ts +15 -0
- package/dist/scanner/local-scan.d.ts.map +1 -0
- package/dist/scanner/local-scan.js +227 -0
- package/dist/scanner/local-scan.js.map +1 -0
- package/dist/scanner/pattern-updater.d.ts +12 -0
- package/dist/scanner/pattern-updater.d.ts.map +1 -0
- package/dist/scanner/pattern-updater.js +110 -0
- package/dist/scanner/pattern-updater.js.map +1 -0
- package/dist/scanner/patterns.d.ts +5 -0
- package/dist/scanner/patterns.d.ts.map +1 -0
- package/dist/scanner/patterns.js +145 -0
- package/dist/scanner/patterns.js.map +1 -0
- package/dist/types.d.ts +59 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +40 -0
- package/src/api/client.ts +77 -0
- package/src/commands/init.ts +113 -0
- package/src/commands/login.ts +205 -0
- package/src/commands/patterns.ts +68 -0
- package/src/commands/scan.ts +257 -0
- package/src/commands/status.ts +57 -0
- package/src/commands/uninstall.ts +55 -0
- package/src/config/default-config.ts +23 -0
- package/src/config/loader.ts +67 -0
- package/src/git/git-utils.ts +95 -0
- package/src/index.ts +72 -0
- package/src/scanner/local-scan.ts +222 -0
- package/src/scanner/pattern-updater.ts +94 -0
- package/src/scanner/patterns.ts +156 -0
- package/src/types.ts +64 -0
- package/tsconfig.json +19 -0
package/SETUP.md
ADDED
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
# Continum CLI - Development Setup Guide
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This guide covers setting up the Continum CLI for development, testing, and deployment.
|
|
6
|
+
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
- Node.js >= 16.0.0
|
|
10
|
+
- PostgreSQL database
|
|
11
|
+
- Git
|
|
12
|
+
- npm or yarn
|
|
13
|
+
|
|
14
|
+
## Development Setup
|
|
15
|
+
|
|
16
|
+
### Step 1: Clone and Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Clone the repository
|
|
20
|
+
git clone <your-repo-url>
|
|
21
|
+
cd continum
|
|
22
|
+
|
|
23
|
+
# Install all dependencies
|
|
24
|
+
npm install
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Step 2: Database Setup
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Navigate to API directory
|
|
31
|
+
cd apps/api
|
|
32
|
+
|
|
33
|
+
# Copy environment file
|
|
34
|
+
cp .env.example .env
|
|
35
|
+
|
|
36
|
+
# Edit .env and set your database URL
|
|
37
|
+
# DATABASE_URL="postgresql://user:password@localhost:5432/continum"
|
|
38
|
+
|
|
39
|
+
# Run database migrations
|
|
40
|
+
npm run db:migrate
|
|
41
|
+
|
|
42
|
+
# Generate Prisma client
|
|
43
|
+
npm run db:generate
|
|
44
|
+
|
|
45
|
+
# Verify with Prisma Studio (optional)
|
|
46
|
+
npm run db:studio
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Step 3: Build the CLI
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# From repository root
|
|
53
|
+
cd ../..
|
|
54
|
+
npm run build:cli
|
|
55
|
+
|
|
56
|
+
# Link CLI globally for local testing
|
|
57
|
+
cd packages/cli
|
|
58
|
+
npm link
|
|
59
|
+
cd ../..
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Step 4: Start Development Servers
|
|
63
|
+
|
|
64
|
+
Open 3 terminal windows:
|
|
65
|
+
|
|
66
|
+
**Terminal 1 - API Server:**
|
|
67
|
+
```bash
|
|
68
|
+
cd apps/api
|
|
69
|
+
npm run dev
|
|
70
|
+
# API runs on http://localhost:3000
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Terminal 2 - Console:**
|
|
74
|
+
```bash
|
|
75
|
+
cd apps/console
|
|
76
|
+
npm run dev
|
|
77
|
+
# Console runs on http://localhost:3001
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Terminal 3 - CLI Testing:**
|
|
81
|
+
```bash
|
|
82
|
+
# Verify CLI is available
|
|
83
|
+
continum --version
|
|
84
|
+
# Should show: 0.1.0
|
|
85
|
+
|
|
86
|
+
continum --help
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Step 5: Create Test User
|
|
90
|
+
|
|
91
|
+
1. Open browser to http://localhost:3001
|
|
92
|
+
2. Sign up for a new account
|
|
93
|
+
3. Complete onboarding
|
|
94
|
+
4. You're ready to test!
|
|
95
|
+
|
|
96
|
+
## Testing the CLI
|
|
97
|
+
|
|
98
|
+
### Test Login Flow
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
continum login
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Expected behavior:**
|
|
105
|
+
1. Browser opens to http://localhost:3001/cli/auth
|
|
106
|
+
2. You sign in with your test account
|
|
107
|
+
3. Browser shows "Authentication Successful"
|
|
108
|
+
4. CLI shows success message
|
|
109
|
+
5. Credentials saved to `~/.continum/credentials.json`
|
|
110
|
+
|
|
111
|
+
### Test in a Repository
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Create test directory
|
|
115
|
+
mkdir ~/test-continum
|
|
116
|
+
cd ~/test-continum
|
|
117
|
+
|
|
118
|
+
# Initialize git
|
|
119
|
+
git init
|
|
120
|
+
|
|
121
|
+
# Initialize Continum
|
|
122
|
+
continum init
|
|
123
|
+
# Enter sandbox name: test
|
|
124
|
+
|
|
125
|
+
# Verify setup
|
|
126
|
+
continum status
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Test Known Pattern Detection
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Create file with AWS key
|
|
133
|
+
echo 'const key = "AKIAIOSFODNN7EXAMPLE";' > test.ts
|
|
134
|
+
|
|
135
|
+
# Stage file
|
|
136
|
+
git add test.ts
|
|
137
|
+
|
|
138
|
+
# Try to commit (should be blocked)
|
|
139
|
+
git commit -m "test commit"
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Expected output:**
|
|
143
|
+
```
|
|
144
|
+
Continum — scanning 1 file...
|
|
145
|
+
|
|
146
|
+
❌ BLOCKED
|
|
147
|
+
|
|
148
|
+
test.ts (line 1)
|
|
149
|
+
──────────────────────────────────────────────────────
|
|
150
|
+
Type: AWS_ACCESS_KEY
|
|
151
|
+
Found: AKIA••••••••7EXAMPLE
|
|
152
|
+
Severity: CRITICAL
|
|
153
|
+
|
|
154
|
+
Fix these before committing.
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
✅ Success! The CLI blocked the commit.
|
|
158
|
+
|
|
159
|
+
### Test Unknown Pattern Detection
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# Create file with unknown pattern
|
|
163
|
+
echo 'const acmeKey = "acme_prod_x7k9m2p8q4w6";' > config.ts
|
|
164
|
+
|
|
165
|
+
# Stage file
|
|
166
|
+
git add config.ts
|
|
167
|
+
|
|
168
|
+
# Try to commit
|
|
169
|
+
git commit -m "add acme config"
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Expected output:**
|
|
173
|
+
```
|
|
174
|
+
⚠️ POSSIBLE CREDENTIAL DETECTED
|
|
175
|
+
|
|
176
|
+
config.ts (line 1)
|
|
177
|
+
──────────────────────────────────────────────────────
|
|
178
|
+
Type: UNKNOWN_PATTERN (HIGH confidence)
|
|
179
|
+
Found: acme_prod_x7k9••••••••
|
|
180
|
+
Pattern: acme_prod_[a-z0-9]{16}
|
|
181
|
+
|
|
182
|
+
Options:
|
|
183
|
+
[b] Block this commit
|
|
184
|
+
[a] Approve pattern and block
|
|
185
|
+
[i] Ignore this pattern
|
|
186
|
+
[c] Continue anyway
|
|
187
|
+
|
|
188
|
+
Choice:
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Type `a` to approve, then enter description and severity.
|
|
192
|
+
|
|
193
|
+
### Test Clean Commit
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
# Create clean file
|
|
197
|
+
echo 'const name = "John Doe";' > user.ts
|
|
198
|
+
|
|
199
|
+
# Stage and commit
|
|
200
|
+
git add user.ts
|
|
201
|
+
git commit -m "add user"
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Expected output:**
|
|
205
|
+
```
|
|
206
|
+
Continum — scanning 1 file...
|
|
207
|
+
✓ Clean
|
|
208
|
+
|
|
209
|
+
[main abc1234] add user
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
✅ Success! Clean commits go through.
|
|
213
|
+
|
|
214
|
+
## Database Schema
|
|
215
|
+
|
|
216
|
+
The CLI requires the `approved_patterns` table:
|
|
217
|
+
|
|
218
|
+
```sql
|
|
219
|
+
CREATE TABLE "approved_patterns" (
|
|
220
|
+
"id" TEXT PRIMARY KEY,
|
|
221
|
+
"customerId" TEXT NOT NULL,
|
|
222
|
+
"pattern" TEXT NOT NULL,
|
|
223
|
+
"patternType" TEXT NOT NULL,
|
|
224
|
+
"description" TEXT NOT NULL,
|
|
225
|
+
"severity" TEXT NOT NULL,
|
|
226
|
+
"isGlobal" BOOLEAN DEFAULT false,
|
|
227
|
+
"isActive" BOOLEAN DEFAULT true,
|
|
228
|
+
"createdBy" TEXT DEFAULT 'cli',
|
|
229
|
+
"createdAt" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
230
|
+
"totalDetections" INTEGER DEFAULT 0,
|
|
231
|
+
"lastDetectedAt" TIMESTAMP,
|
|
232
|
+
|
|
233
|
+
FOREIGN KEY ("customerId") REFERENCES "customers"("id")
|
|
234
|
+
);
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
This is created automatically by the migration in `apps/api/prisma/migrations/20260324_add_patterns/`.
|
|
238
|
+
|
|
239
|
+
## API Endpoints
|
|
240
|
+
|
|
241
|
+
The CLI communicates with these endpoints:
|
|
242
|
+
|
|
243
|
+
### POST /patterns/approve
|
|
244
|
+
|
|
245
|
+
Approve a new pattern detected by the CLI.
|
|
246
|
+
|
|
247
|
+
**Request:**
|
|
248
|
+
```json
|
|
249
|
+
{
|
|
250
|
+
"pattern": "acme_prod_[a-z0-9]{16}",
|
|
251
|
+
"patternType": "CUSTOM",
|
|
252
|
+
"description": "ACME Production API Key",
|
|
253
|
+
"severity": "HIGH",
|
|
254
|
+
"exampleValue": "acme_prod_x7k9••••••••",
|
|
255
|
+
"confidence": "HIGH",
|
|
256
|
+
"context": {
|
|
257
|
+
"file": "src/config.ts",
|
|
258
|
+
"line": 14,
|
|
259
|
+
"variableName": "apiKey"
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
**Response:**
|
|
265
|
+
```json
|
|
266
|
+
{
|
|
267
|
+
"success": true,
|
|
268
|
+
"patternId": "clx..."
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### GET /patterns/library
|
|
273
|
+
|
|
274
|
+
Get all patterns for the customer (custom + global).
|
|
275
|
+
|
|
276
|
+
**Response:**
|
|
277
|
+
```json
|
|
278
|
+
[
|
|
279
|
+
{
|
|
280
|
+
"pattern": "AKIA[0-9A-Z]{16}",
|
|
281
|
+
"patternType": "AWS_ACCESS_KEY",
|
|
282
|
+
"description": "AWS Access Key ID",
|
|
283
|
+
"severity": "CRITICAL"
|
|
284
|
+
}
|
|
285
|
+
]
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### GET /patterns/status
|
|
289
|
+
|
|
290
|
+
Test API connection and get customer info.
|
|
291
|
+
|
|
292
|
+
**Response:**
|
|
293
|
+
```json
|
|
294
|
+
{
|
|
295
|
+
"success": true,
|
|
296
|
+
"customer": "Acme Corp"
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### POST /patterns/audit
|
|
301
|
+
|
|
302
|
+
Background audit of git diff (fire-and-forget).
|
|
303
|
+
|
|
304
|
+
**Request:**
|
|
305
|
+
```json
|
|
306
|
+
{
|
|
307
|
+
"diff": "diff --git a/src/config.ts...",
|
|
308
|
+
"sandbox": "employee_confidential"
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
## File Structure
|
|
313
|
+
|
|
314
|
+
```
|
|
315
|
+
packages/cli/
|
|
316
|
+
├── src/
|
|
317
|
+
│ ├── commands/
|
|
318
|
+
│ │ ├── login.ts # Browser-based authentication
|
|
319
|
+
│ │ ├── init.ts # Project initialization
|
|
320
|
+
│ │ ├── scan.ts # File scanning
|
|
321
|
+
│ │ ├── patterns.ts # Pattern management
|
|
322
|
+
│ │ ├── status.ts # Status check
|
|
323
|
+
│ │ └── uninstall.ts # Uninstall hook
|
|
324
|
+
│ ├── scanner/
|
|
325
|
+
│ │ ├── patterns.ts # Built-in patterns
|
|
326
|
+
│ │ ├── local-scan.ts # Local scanner logic
|
|
327
|
+
│ │ └── pattern-updater.ts # Pattern sync
|
|
328
|
+
│ ├── api/
|
|
329
|
+
│ │ └── client.ts # API client
|
|
330
|
+
│ ├── config/
|
|
331
|
+
│ │ ├── default-config.ts # Default configuration
|
|
332
|
+
│ │ └── loader.ts # Config management
|
|
333
|
+
│ ├── git/
|
|
334
|
+
│ │ └── git-utils.ts # Git operations
|
|
335
|
+
│ ├── types.ts # TypeScript types
|
|
336
|
+
│ └── index.ts # CLI entry point
|
|
337
|
+
├── package.json
|
|
338
|
+
├── tsconfig.json
|
|
339
|
+
├── README.md
|
|
340
|
+
└── SETUP.md (this file)
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
## Environment Variables
|
|
344
|
+
|
|
345
|
+
### Development
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
# CLI
|
|
349
|
+
CONTINUM_API_URL=http://localhost:3000
|
|
350
|
+
CONTINUM_CONSOLE_URL=http://localhost:3001
|
|
351
|
+
|
|
352
|
+
# Console
|
|
353
|
+
NEXT_PUBLIC_API_URL=http://localhost:3000
|
|
354
|
+
|
|
355
|
+
# API
|
|
356
|
+
DATABASE_URL=postgresql://user:password@localhost:5432/continum
|
|
357
|
+
INTERNAL_API_KEY=your-internal-key
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### Production
|
|
361
|
+
|
|
362
|
+
```bash
|
|
363
|
+
# CLI (defaults)
|
|
364
|
+
CONTINUM_API_URL=https://api.continum.dev
|
|
365
|
+
CONTINUM_CONSOLE_URL=https://console.continum.dev
|
|
366
|
+
|
|
367
|
+
# Console
|
|
368
|
+
NEXT_PUBLIC_API_URL=https://api.continum.dev
|
|
369
|
+
|
|
370
|
+
# API
|
|
371
|
+
DATABASE_URL=postgresql://...
|
|
372
|
+
INTERNAL_API_KEY=...
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
## Publishing
|
|
376
|
+
|
|
377
|
+
### To npm
|
|
378
|
+
|
|
379
|
+
```bash
|
|
380
|
+
cd packages/cli
|
|
381
|
+
|
|
382
|
+
# Update version
|
|
383
|
+
npm version patch # or minor, major
|
|
384
|
+
|
|
385
|
+
# Build
|
|
386
|
+
npm run build
|
|
387
|
+
|
|
388
|
+
# Publish
|
|
389
|
+
npm publish
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
### Users Install
|
|
393
|
+
|
|
394
|
+
```bash
|
|
395
|
+
npm install -g @continum/cli
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
## Troubleshooting
|
|
399
|
+
|
|
400
|
+
### "Command not found: continum"
|
|
401
|
+
|
|
402
|
+
```bash
|
|
403
|
+
cd packages/cli
|
|
404
|
+
npm link
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### "Failed to connect to Continum API"
|
|
408
|
+
|
|
409
|
+
Check:
|
|
410
|
+
- API is running: `curl http://localhost:3000/health`
|
|
411
|
+
- API URL is correct in credentials
|
|
412
|
+
- Network connection works
|
|
413
|
+
|
|
414
|
+
### "Not in a git repository"
|
|
415
|
+
|
|
416
|
+
```bash
|
|
417
|
+
git init
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
### Database migration fails
|
|
421
|
+
|
|
422
|
+
```bash
|
|
423
|
+
# Check DATABASE_URL in apps/api/.env
|
|
424
|
+
cat apps/api/.env
|
|
425
|
+
|
|
426
|
+
# Ensure PostgreSQL is running
|
|
427
|
+
psql -U postgres -c "SELECT version();"
|
|
428
|
+
|
|
429
|
+
# Run migration again
|
|
430
|
+
cd apps/api
|
|
431
|
+
npm run db:migrate
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### Port 8765 already in use
|
|
435
|
+
|
|
436
|
+
```bash
|
|
437
|
+
# Kill process on port 8765
|
|
438
|
+
lsof -ti:8765 | xargs kill -9
|
|
439
|
+
|
|
440
|
+
# Or on Windows
|
|
441
|
+
netstat -ano | findstr :8765
|
|
442
|
+
taskkill /PID <PID> /F
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
## Testing Checklist
|
|
446
|
+
|
|
447
|
+
- [ ] CLI builds successfully
|
|
448
|
+
- [ ] Database migration runs
|
|
449
|
+
- [ ] API starts on port 3000
|
|
450
|
+
- [ ] Console starts on port 3001
|
|
451
|
+
- [ ] `continum login` opens browser
|
|
452
|
+
- [ ] Browser auth page loads
|
|
453
|
+
- [ ] Authentication completes
|
|
454
|
+
- [ ] Credentials saved to `~/.continum/credentials.json`
|
|
455
|
+
- [ ] `continum init` without login shows error
|
|
456
|
+
- [ ] `continum login` then `continum init` works
|
|
457
|
+
- [ ] Config file created
|
|
458
|
+
- [ ] Pre-commit hook installed
|
|
459
|
+
- [ ] Known patterns blocked
|
|
460
|
+
- [ ] Unknown patterns prompt for approval
|
|
461
|
+
- [ ] Approved patterns saved
|
|
462
|
+
- [ ] Patterns sync across team
|
|
463
|
+
- [ ] Clean commits go through
|
|
464
|
+
- [ ] `continum status` shows correct info
|
|
465
|
+
|
|
466
|
+
## Architecture
|
|
467
|
+
|
|
468
|
+
### Login Flow
|
|
469
|
+
|
|
470
|
+
```
|
|
471
|
+
Developer → CLI → Browser → Console → API → CLI → Credentials Saved
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
1. Developer runs `continum login`
|
|
475
|
+
2. CLI starts local server on port 8765
|
|
476
|
+
3. CLI opens browser to console.continum.dev/cli/auth
|
|
477
|
+
4. User authenticates in browser
|
|
478
|
+
5. Console fetches API key from API
|
|
479
|
+
6. Console redirects to localhost:8765 with credentials
|
|
480
|
+
7. CLI receives credentials and saves them
|
|
481
|
+
|
|
482
|
+
### Scan Flow
|
|
483
|
+
|
|
484
|
+
```
|
|
485
|
+
Git Commit → Pre-commit Hook → CLI Scan → Block/Allow
|
|
486
|
+
↓
|
|
487
|
+
API (background audit)
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
1. Developer commits
|
|
491
|
+
2. Pre-commit hook runs `continum scan --staged`
|
|
492
|
+
3. CLI scans files with known patterns
|
|
493
|
+
4. If violations found → Block commit
|
|
494
|
+
5. If clean → Allow commit + send diff to API (background)
|
|
495
|
+
|
|
496
|
+
### Pattern Learning Flow
|
|
497
|
+
|
|
498
|
+
```
|
|
499
|
+
Unknown Pattern → Prompt Developer → Approve → Save to API → Sync to Team
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
1. CLI detects unknown pattern
|
|
503
|
+
2. Prompts developer for approval
|
|
504
|
+
3. Developer approves with description
|
|
505
|
+
4. CLI sends to API
|
|
506
|
+
5. API saves to database
|
|
507
|
+
6. Other team members get pattern on next scan
|
|
508
|
+
|
|
509
|
+
## Support
|
|
510
|
+
|
|
511
|
+
- Documentation: See README.md
|
|
512
|
+
- Issues: GitHub Issues
|
|
513
|
+
- Discord: https://discord.gg/continum
|
|
514
|
+
|
|
515
|
+
## License
|
|
516
|
+
|
|
517
|
+
MIT
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Pattern, ApprovePatternDto } from '../types';
|
|
2
|
+
export declare class ContinumApiClient {
|
|
3
|
+
private apiUrl;
|
|
4
|
+
private apiKey;
|
|
5
|
+
constructor(apiUrl: string, apiKey: string);
|
|
6
|
+
approvePattern(dto: ApprovePatternDto): Promise<{
|
|
7
|
+
success: boolean;
|
|
8
|
+
patternId: string;
|
|
9
|
+
}>;
|
|
10
|
+
getPatternLibrary(): Promise<Pattern[]>;
|
|
11
|
+
sendSandboxAudit(diff: string, sandbox: string): Promise<void>;
|
|
12
|
+
testConnection(): Promise<{
|
|
13
|
+
success: boolean;
|
|
14
|
+
customer: string;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAEtD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAKpC,cAAc,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAkBxF,iBAAiB,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAiBvC,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAc9D,cAAc,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAexE"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ContinumApiClient = void 0;
|
|
7
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
8
|
+
class ContinumApiClient {
|
|
9
|
+
constructor(apiUrl, apiKey) {
|
|
10
|
+
this.apiUrl = apiUrl.replace(/\/$/, ''); // Remove trailing slash
|
|
11
|
+
this.apiKey = apiKey;
|
|
12
|
+
}
|
|
13
|
+
async approvePattern(dto) {
|
|
14
|
+
const response = await (0, node_fetch_1.default)(`${this.apiUrl}/patterns/approve`, {
|
|
15
|
+
method: 'POST',
|
|
16
|
+
headers: {
|
|
17
|
+
'x-continum-key': this.apiKey,
|
|
18
|
+
'Content-Type': 'application/json'
|
|
19
|
+
},
|
|
20
|
+
body: JSON.stringify(dto)
|
|
21
|
+
});
|
|
22
|
+
if (!response.ok) {
|
|
23
|
+
const error = await response.text();
|
|
24
|
+
throw new Error(`Failed to approve pattern: ${error}`);
|
|
25
|
+
}
|
|
26
|
+
return response.json();
|
|
27
|
+
}
|
|
28
|
+
async getPatternLibrary() {
|
|
29
|
+
const response = await (0, node_fetch_1.default)(`${this.apiUrl}/patterns/library`, {
|
|
30
|
+
method: 'GET',
|
|
31
|
+
headers: {
|
|
32
|
+
'x-continum-key': this.apiKey,
|
|
33
|
+
'Content-Type': 'application/json'
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
if (!response.ok) {
|
|
37
|
+
const error = await response.text();
|
|
38
|
+
throw new Error(`Failed to fetch patterns: ${error}`);
|
|
39
|
+
}
|
|
40
|
+
return response.json();
|
|
41
|
+
}
|
|
42
|
+
async sendSandboxAudit(diff, sandbox) {
|
|
43
|
+
// Fire and forget - don't wait for response
|
|
44
|
+
(0, node_fetch_1.default)(`${this.apiUrl}/patterns/audit`, {
|
|
45
|
+
method: 'POST',
|
|
46
|
+
headers: {
|
|
47
|
+
'x-continum-key': this.apiKey,
|
|
48
|
+
'Content-Type': 'application/json'
|
|
49
|
+
},
|
|
50
|
+
body: JSON.stringify({ diff, sandbox })
|
|
51
|
+
}).catch(() => {
|
|
52
|
+
// Silent fail - this is background audit
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
async testConnection() {
|
|
56
|
+
const response = await (0, node_fetch_1.default)(`${this.apiUrl}/patterns/status`, {
|
|
57
|
+
method: 'GET',
|
|
58
|
+
headers: {
|
|
59
|
+
'x-continum-key': this.apiKey,
|
|
60
|
+
'Content-Type': 'application/json'
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
if (!response.ok) {
|
|
64
|
+
throw new Error('Failed to connect to Continum API');
|
|
65
|
+
}
|
|
66
|
+
return response.json();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.ContinumApiClient = ContinumApiClient;
|
|
70
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA+B;AAG/B,MAAa,iBAAiB;IAI5B,YAAY,MAAc,EAAE,MAAc;QACxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,wBAAwB;QACjE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,GAAsB;QACzC,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAK,EAAC,GAAG,IAAI,CAAC,MAAM,mBAAmB,EAAE;YAC9D,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,gBAAgB,EAAE,IAAI,CAAC,MAAM;gBAC7B,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;SAC1B,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CAAC,8BAA8B,KAAK,EAAE,CAAC,CAAC;QACzD,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,EAAsD,CAAC;IAC7E,CAAC;IAED,KAAK,CAAC,iBAAiB;QACrB,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAK,EAAC,GAAG,IAAI,CAAC,MAAM,mBAAmB,EAAE;YAC9D,MAAM,EAAE,KAAK;YACb,OAAO,EAAE;gBACP,gBAAgB,EAAE,IAAI,CAAC,MAAM;gBAC7B,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CAAC,6BAA6B,KAAK,EAAE,CAAC,CAAC;QACxD,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,EAAwB,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,IAAY,EAAE,OAAe;QAClD,4CAA4C;QAC5C,IAAA,oBAAK,EAAC,GAAG,IAAI,CAAC,MAAM,iBAAiB,EAAE;YACrC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,gBAAgB,EAAE,IAAI,CAAC,MAAM;gBAC7B,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;SACxC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;YACZ,yCAAyC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAK,EAAC,GAAG,IAAI,CAAC,MAAM,kBAAkB,EAAE;YAC7D,MAAM,EAAE,KAAK;YACb,OAAO,EAAE;gBACP,gBAAgB,EAAE,IAAI,CAAC,MAAM;gBAC7B,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACvD,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,EAAqD,CAAC;IAC5E,CAAC;CACF;AAzED,8CAyEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAOA,wBAAsB,WAAW,CAAC,OAAO,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAyG9E"}
|