@neurcode-ai/cli 0.1.7 → 0.2.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/dist/api-client.d.ts +76 -0
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +122 -1
- package/dist/api-client.js.map +1 -1
- package/dist/commands/allow.d.ts +7 -0
- package/dist/commands/allow.d.ts.map +1 -0
- package/dist/commands/allow.js +128 -0
- package/dist/commands/allow.js.map +1 -0
- package/dist/commands/map.d.ts +10 -0
- package/dist/commands/map.d.ts.map +1 -0
- package/dist/commands/map.js +108 -0
- package/dist/commands/map.js.map +1 -0
- package/dist/commands/plan.d.ts.map +1 -1
- package/dist/commands/plan.js +127 -2
- package/dist/commands/plan.js.map +1 -1
- package/dist/commands/verify.d.ts +1 -0
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +151 -2
- package/dist/commands/verify.js.map +1 -1
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -1
- package/dist/services/mapper/ProjectScanner.d.ts +52 -0
- package/dist/services/mapper/ProjectScanner.d.ts.map +1 -0
- package/dist/services/mapper/ProjectScanner.js +274 -0
- package/dist/services/mapper/ProjectScanner.js.map +1 -0
- package/package.json +6 -3
- package/README.md +0 -125
- package/dist/commands/check.integration.test.d.ts +0 -7
- package/dist/commands/check.integration.test.d.ts.map +0 -1
- package/dist/commands/check.integration.test.js +0 -157
- package/dist/commands/check.integration.test.js.map +0 -1
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProjectScanner = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
const glob_1 = require("glob");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
class ProjectScanner {
|
|
8
|
+
project;
|
|
9
|
+
rootDir;
|
|
10
|
+
ignorePatterns;
|
|
11
|
+
constructor(rootDir = process.cwd()) {
|
|
12
|
+
this.rootDir = (0, path_1.resolve)(rootDir);
|
|
13
|
+
this.project = new ts_morph_1.Project({
|
|
14
|
+
tsConfigFilePath: undefined, // We'll add files manually
|
|
15
|
+
skipAddingFilesFromTsConfig: true,
|
|
16
|
+
skipFileDependencyResolution: true,
|
|
17
|
+
});
|
|
18
|
+
this.ignorePatterns = [
|
|
19
|
+
'**/node_modules/**',
|
|
20
|
+
'**/dist/**',
|
|
21
|
+
'**/.git/**',
|
|
22
|
+
'**/build/**',
|
|
23
|
+
'**/.next/**',
|
|
24
|
+
'**/.turbo/**',
|
|
25
|
+
'**/.cache/**',
|
|
26
|
+
'**/*.map',
|
|
27
|
+
'**/*.log',
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Scan the project and extract exports and imports
|
|
32
|
+
*/
|
|
33
|
+
async scan() {
|
|
34
|
+
// Find all TypeScript/JavaScript files
|
|
35
|
+
const files = await this.findSourceFiles();
|
|
36
|
+
// Add files to ts-morph project
|
|
37
|
+
const sourceFiles = [];
|
|
38
|
+
for (const filePath of files) {
|
|
39
|
+
try {
|
|
40
|
+
const sourceFile = this.project.addSourceFileAtPath(filePath);
|
|
41
|
+
sourceFiles.push(sourceFile);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
// Skip files that can't be parsed
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Extract metadata from each file
|
|
49
|
+
const fileMetadata = {};
|
|
50
|
+
const globalExports = [];
|
|
51
|
+
for (const sourceFile of sourceFiles) {
|
|
52
|
+
const filePath = (0, path_1.relative)(this.rootDir, sourceFile.getFilePath());
|
|
53
|
+
try {
|
|
54
|
+
const exports = this.extractExports(sourceFile, filePath);
|
|
55
|
+
const imports = this.extractImports(sourceFile);
|
|
56
|
+
fileMetadata[filePath] = {
|
|
57
|
+
filePath,
|
|
58
|
+
exports,
|
|
59
|
+
imports,
|
|
60
|
+
};
|
|
61
|
+
// Add to global exports list
|
|
62
|
+
globalExports.push(...exports);
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
// If extraction fails for a file, continue with others
|
|
66
|
+
fileMetadata[filePath] = {
|
|
67
|
+
filePath,
|
|
68
|
+
exports: [],
|
|
69
|
+
imports: [],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
files: fileMetadata,
|
|
75
|
+
globalExports,
|
|
76
|
+
scannedAt: new Date().toISOString(),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Find all TypeScript/JavaScript source files
|
|
81
|
+
*/
|
|
82
|
+
async findSourceFiles() {
|
|
83
|
+
const patterns = [
|
|
84
|
+
'**/*.ts',
|
|
85
|
+
'**/*.tsx',
|
|
86
|
+
'**/*.js',
|
|
87
|
+
'**/*.jsx',
|
|
88
|
+
];
|
|
89
|
+
const allFiles = [];
|
|
90
|
+
for (const pattern of patterns) {
|
|
91
|
+
try {
|
|
92
|
+
const files = await (0, glob_1.glob)(pattern, {
|
|
93
|
+
cwd: this.rootDir,
|
|
94
|
+
ignore: this.ignorePatterns,
|
|
95
|
+
absolute: true,
|
|
96
|
+
});
|
|
97
|
+
allFiles.push(...files);
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
// Continue with other patterns if one fails
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// Remove duplicates and sort
|
|
105
|
+
return Array.from(new Set(allFiles)).sort();
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Extract all exports from a source file
|
|
109
|
+
*/
|
|
110
|
+
extractExports(sourceFile, filePath) {
|
|
111
|
+
const exports = [];
|
|
112
|
+
// Get all export declarations
|
|
113
|
+
const exportDeclarations = sourceFile.getExportedDeclarations();
|
|
114
|
+
for (const [name, declarations] of exportDeclarations) {
|
|
115
|
+
for (const declaration of declarations) {
|
|
116
|
+
const exportItem = this.createExportItem(declaration, name, filePath);
|
|
117
|
+
if (exportItem) {
|
|
118
|
+
exports.push(exportItem);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// Check for default exports
|
|
123
|
+
const defaultExport = sourceFile.getDefaultExportSymbol();
|
|
124
|
+
if (defaultExport) {
|
|
125
|
+
const declaration = defaultExport.getValueDeclaration();
|
|
126
|
+
if (declaration) {
|
|
127
|
+
const exportItem = this.createExportItem(declaration, 'default', filePath);
|
|
128
|
+
if (exportItem) {
|
|
129
|
+
exports.push(exportItem);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// Check for export * from statements
|
|
134
|
+
const exportStarDeclarations = sourceFile.getExportDeclarations();
|
|
135
|
+
for (const exportDecl of exportStarDeclarations) {
|
|
136
|
+
if (exportDecl.isNamespaceExport()) {
|
|
137
|
+
const moduleSpecifier = exportDecl.getModuleSpecifierValue();
|
|
138
|
+
if (moduleSpecifier) {
|
|
139
|
+
exports.push({
|
|
140
|
+
name: '*',
|
|
141
|
+
filePath,
|
|
142
|
+
type: 'namespace',
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return exports;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Create an ExportItem from a declaration node
|
|
151
|
+
*/
|
|
152
|
+
createExportItem(declaration, name, filePath) {
|
|
153
|
+
const kind = declaration.getKind();
|
|
154
|
+
let type = 'unknown';
|
|
155
|
+
let signature;
|
|
156
|
+
if (kind === ts_morph_1.SyntaxKind.FunctionDeclaration || kind === ts_morph_1.SyntaxKind.FunctionExpression) {
|
|
157
|
+
type = 'function';
|
|
158
|
+
signature = this.getFunctionSignature(declaration);
|
|
159
|
+
}
|
|
160
|
+
else if (kind === ts_morph_1.SyntaxKind.ClassDeclaration) {
|
|
161
|
+
type = 'class';
|
|
162
|
+
signature = declaration.getText().split('\n')[0] || undefined;
|
|
163
|
+
}
|
|
164
|
+
else if (kind === ts_morph_1.SyntaxKind.InterfaceDeclaration) {
|
|
165
|
+
type = 'interface';
|
|
166
|
+
signature = declaration.getText().split('\n')[0] || undefined;
|
|
167
|
+
}
|
|
168
|
+
else if (kind === ts_morph_1.SyntaxKind.TypeAliasDeclaration) {
|
|
169
|
+
type = 'type';
|
|
170
|
+
signature = declaration.getText().split('\n')[0] || undefined;
|
|
171
|
+
}
|
|
172
|
+
else if (kind === ts_morph_1.SyntaxKind.EnumDeclaration) {
|
|
173
|
+
type = 'enum';
|
|
174
|
+
signature = declaration.getText().split('\n')[0] || undefined;
|
|
175
|
+
}
|
|
176
|
+
else if (kind === ts_morph_1.SyntaxKind.ModuleDeclaration) {
|
|
177
|
+
type = 'namespace';
|
|
178
|
+
signature = declaration.getText().split('\n')[0] || undefined;
|
|
179
|
+
}
|
|
180
|
+
else if (kind === ts_morph_1.SyntaxKind.VariableDeclaration) {
|
|
181
|
+
const varDecl = declaration.asKind(ts_morph_1.SyntaxKind.VariableDeclaration);
|
|
182
|
+
if (varDecl) {
|
|
183
|
+
const initializer = varDecl.getInitializer();
|
|
184
|
+
if (initializer?.getKind() === ts_morph_1.SyntaxKind.ArrowFunction ||
|
|
185
|
+
initializer?.getKind() === ts_morph_1.SyntaxKind.FunctionExpression) {
|
|
186
|
+
type = 'function';
|
|
187
|
+
signature = this.getFunctionSignature(initializer);
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
type = 'const';
|
|
191
|
+
signature = varDecl.getText();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
type = 'variable';
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
else if (kind === ts_morph_1.SyntaxKind.Identifier && name === 'default') {
|
|
199
|
+
type = 'default';
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
name,
|
|
203
|
+
filePath,
|
|
204
|
+
signature,
|
|
205
|
+
type,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Get function signature as a string
|
|
210
|
+
*/
|
|
211
|
+
getFunctionSignature(node) {
|
|
212
|
+
try {
|
|
213
|
+
const text = node.getText();
|
|
214
|
+
// Extract function signature (name and parameters)
|
|
215
|
+
const match = text.match(/(?:async\s+)?(?:function\s+)?(\w+)?\s*\([^)]*\)/);
|
|
216
|
+
if (match) {
|
|
217
|
+
return match[0];
|
|
218
|
+
}
|
|
219
|
+
// For arrow functions
|
|
220
|
+
const arrowMatch = text.match(/(?:async\s+)?\([^)]*\)\s*=>/);
|
|
221
|
+
if (arrowMatch) {
|
|
222
|
+
return arrowMatch[0];
|
|
223
|
+
}
|
|
224
|
+
return text.split('\n')[0] || '';
|
|
225
|
+
}
|
|
226
|
+
catch {
|
|
227
|
+
return '';
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Extract all imports from a source file
|
|
232
|
+
*/
|
|
233
|
+
extractImports(sourceFile) {
|
|
234
|
+
const imports = [];
|
|
235
|
+
const importDeclarations = sourceFile.getImportDeclarations();
|
|
236
|
+
for (const importDecl of importDeclarations) {
|
|
237
|
+
const moduleSpecifier = importDecl.getModuleSpecifierValue();
|
|
238
|
+
if (!moduleSpecifier)
|
|
239
|
+
continue;
|
|
240
|
+
const isTypeOnly = importDecl.isTypeOnly();
|
|
241
|
+
const namedImports = [];
|
|
242
|
+
const defaultImport = importDecl.getDefaultImport();
|
|
243
|
+
// Get named imports
|
|
244
|
+
const namedImportsNode = importDecl.getNamedImports();
|
|
245
|
+
if (namedImportsNode) {
|
|
246
|
+
for (const specifier of namedImportsNode) {
|
|
247
|
+
const importName = specifier.getName();
|
|
248
|
+
namedImports.push(importName);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
// Get namespace import
|
|
252
|
+
const namespaceImport = importDecl.getNamespaceImport();
|
|
253
|
+
if (namespaceImport) {
|
|
254
|
+
namedImports.push(`* as ${namespaceImport.getText()}`);
|
|
255
|
+
}
|
|
256
|
+
// Combine default and named imports
|
|
257
|
+
const allImports = [];
|
|
258
|
+
if (defaultImport) {
|
|
259
|
+
allImports.push('default');
|
|
260
|
+
}
|
|
261
|
+
allImports.push(...namedImports);
|
|
262
|
+
if (allImports.length > 0 || moduleSpecifier) {
|
|
263
|
+
imports.push({
|
|
264
|
+
from: moduleSpecifier,
|
|
265
|
+
imports: allImports,
|
|
266
|
+
isTypeOnly,
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return imports;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
exports.ProjectScanner = ProjectScanner;
|
|
274
|
+
//# sourceMappingURL=ProjectScanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectScanner.js","sourceRoot":"","sources":["../../../src/services/mapper/ProjectScanner.ts"],"names":[],"mappings":";;;AAAA,uCAAuG;AACvG,+BAA4B;AAC5B,+BAA+C;AA4B/C,MAAa,cAAc;IACjB,OAAO,CAAU;IACjB,OAAO,CAAS;IAChB,cAAc,CAAW;IAEjC,YAAY,UAAkB,OAAO,CAAC,GAAG,EAAE;QACzC,IAAI,CAAC,OAAO,GAAG,IAAA,cAAO,EAAC,OAAO,CAAC,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,IAAI,kBAAO,CAAC;YACzB,gBAAgB,EAAE,SAAS,EAAE,2BAA2B;YACxD,2BAA2B,EAAE,IAAI;YACjC,4BAA4B,EAAE,IAAI;SACnC,CAAC,CAAC;QACH,IAAI,CAAC,cAAc,GAAG;YACpB,oBAAoB;YACpB,YAAY;YACZ,YAAY;YACZ,aAAa;YACb,aAAa;YACb,cAAc;YACd,cAAc;YACd,UAAU;YACV,UAAU;SACX,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,uCAAuC;QACvC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC;QAE3C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,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA1RD,wCA0RC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neurcode-ai/cli",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Neurcode CLI - AI code governance and diff analysis",
|
|
5
5
|
"bin": {
|
|
6
6
|
"neurcode": "./dist/index.js"
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"README.md"
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
|
-
"build": "tsc",
|
|
15
|
+
"build": "tsc && chmod +x dist/index.js",
|
|
16
16
|
"dev": "tsc --watch",
|
|
17
17
|
"start": "node dist/index.js",
|
|
18
18
|
"prepublishOnly": "./scripts/publish-prep.sh",
|
|
@@ -41,13 +41,16 @@
|
|
|
41
41
|
"@neurcode-ai/diff-parser": "^0.1.0",
|
|
42
42
|
"@neurcode-ai/policy-engine": "^0.1.0",
|
|
43
43
|
"chalk": "^4.1.2",
|
|
44
|
-
"commander": "^11.1.0"
|
|
44
|
+
"commander": "^11.1.0",
|
|
45
|
+
"glob": "^10.3.10",
|
|
46
|
+
"ts-morph": "^24.0.0"
|
|
45
47
|
},
|
|
46
48
|
"publishConfig": {
|
|
47
49
|
"access": "public"
|
|
48
50
|
},
|
|
49
51
|
"devDependencies": {
|
|
50
52
|
"@types/node": "^20.10.0",
|
|
53
|
+
"@types/glob": "^8.1.0",
|
|
51
54
|
"typescript": "^5.3.0"
|
|
52
55
|
}
|
|
53
56
|
}
|
package/README.md
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
# Neurcode CLI
|
|
2
|
-
|
|
3
|
-
AI-powered code governance and diff analysis tool.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
### Option 1: Link locally (for development)
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
# From the monorepo root
|
|
11
|
-
pnpm install
|
|
12
|
-
pnpm --filter @neurcode/cli build
|
|
13
|
-
|
|
14
|
-
# Link globally
|
|
15
|
-
cd packages/cli
|
|
16
|
-
pnpm link --global
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### Option 2: Use via pnpm (from monorepo)
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
# From monorepo root
|
|
23
|
-
pnpm cli check --help
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Configuration
|
|
27
|
-
|
|
28
|
-
Create a `neurcode.config.json` file in your project root or home directory:
|
|
29
|
-
|
|
30
|
-
```json
|
|
31
|
-
{
|
|
32
|
-
"apiUrl": "https://api.neurcode.com",
|
|
33
|
-
"apiKey": "nk_live_YOUR_API_KEY_HERE",
|
|
34
|
-
"projectId": "optional-project-id"
|
|
35
|
-
}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
Or set environment variables:
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
export NEURCODE_API_URL="https://api.neurcode.com"
|
|
42
|
-
export NEURCODE_API_KEY="nk_live_YOUR_API_KEY_HERE"
|
|
43
|
-
export NEURCODE_PROJECT_ID="optional-project-id"
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Usage
|
|
47
|
-
|
|
48
|
-
### Basic Check (Local Rules)
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
# Check staged changes
|
|
52
|
-
neurcode check --staged
|
|
53
|
-
|
|
54
|
-
# Check changes against HEAD
|
|
55
|
-
neurcode check --head
|
|
56
|
-
|
|
57
|
-
# Check against specific base
|
|
58
|
-
neurcode check --base main
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
### Online Check (Rule-Based Analysis)
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
# Send diff to API for rule-based analysis
|
|
65
|
-
neurcode check --staged --online
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### AI-Powered Analysis (with Session Tracking)
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
# AI analysis with automatic session creation
|
|
72
|
-
neurcode check --staged --online --ai --intent "Fix login bug"
|
|
73
|
-
|
|
74
|
-
# Use existing session
|
|
75
|
-
neurcode check --staged --online --ai --intent "Add feature" --session-id "session_123"
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## Getting Your API Key
|
|
79
|
-
|
|
80
|
-
1. Go to https://neurcode.com/dashboard/api-keys
|
|
81
|
-
2. Create a new API key
|
|
82
|
-
3. Copy the key (starts with `nk_live_`)
|
|
83
|
-
4. Add it to your config file or environment variables
|
|
84
|
-
|
|
85
|
-
## Viewing Sessions
|
|
86
|
-
|
|
87
|
-
After running AI analysis, you'll get a session ID. View it in the dashboard:
|
|
88
|
-
|
|
89
|
-
```
|
|
90
|
-
https://neurcode.com/dashboard/sessions/{sessionId}
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
## Exit Codes (for CI/CD)
|
|
94
|
-
|
|
95
|
-
The CLI uses exit codes to indicate analysis results:
|
|
96
|
-
|
|
97
|
-
- **0**: `ALLOW` - Code is clean, no issues found
|
|
98
|
-
- **1**: `WARN` - Issues found but not blocking (moderate redundancy or warnings)
|
|
99
|
-
- **2**: `BLOCK` - Critical issues found (high redundancy, intent mismatch, or security violations)
|
|
100
|
-
|
|
101
|
-
### CI/CD Integration
|
|
102
|
-
|
|
103
|
-
```bash
|
|
104
|
-
# In your CI/CD pipeline
|
|
105
|
-
neurcode check --staged --ai --intent "Add feature"
|
|
106
|
-
|
|
107
|
-
# Exit code 0 = success, continue
|
|
108
|
-
# Exit code 1 = warnings, you may want to continue or fail
|
|
109
|
-
# Exit code 2 = blocked, should fail the build
|
|
110
|
-
|
|
111
|
-
# Example GitHub Actions
|
|
112
|
-
- name: Check code with Neurcode
|
|
113
|
-
run: neurcode check --staged --ai --intent "${{ github.event.head_commit.message }}"
|
|
114
|
-
continue-on-error: false # Fail on exit code 1 or 2
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### Custom Exit Code Behavior
|
|
118
|
-
|
|
119
|
-
If you want to customize exit code behavior, you can wrap the command:
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
# Only fail on BLOCK (exit code 2)
|
|
123
|
-
neurcode check --staged --ai --intent "Add feature" || [ $? -eq 1 ]
|
|
124
|
-
```
|
|
125
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"check.integration.test.d.ts","sourceRoot":"","sources":["../../src/commands/check.integration.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Integration Tests for CLI → API Flow
|
|
4
|
-
*
|
|
5
|
-
* Tests the complete flow: CLI → API → Database → Response
|
|
6
|
-
*/
|
|
7
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
-
if (k2 === undefined) k2 = k;
|
|
9
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
-
}
|
|
13
|
-
Object.defineProperty(o, k2, desc);
|
|
14
|
-
}) : (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
o[k2] = m[k];
|
|
17
|
-
}));
|
|
18
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
-
}) : function(o, v) {
|
|
21
|
-
o["default"] = v;
|
|
22
|
-
});
|
|
23
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
-
var ownKeys = function(o) {
|
|
25
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
-
var ar = [];
|
|
27
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
-
return ar;
|
|
29
|
-
};
|
|
30
|
-
return ownKeys(o);
|
|
31
|
-
};
|
|
32
|
-
return function (mod) {
|
|
33
|
-
if (mod && mod.__esModule) return mod;
|
|
34
|
-
var result = {};
|
|
35
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
-
__setModuleDefault(result, mod);
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
})();
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
const vitest_1 = require("vitest");
|
|
42
|
-
const child_process_1 = require("child_process");
|
|
43
|
-
const path_1 = require("path");
|
|
44
|
-
const index_1 = require("../../../services/api/src/index");
|
|
45
|
-
const db_1 = require("../../../services/api/src/db");
|
|
46
|
-
const api_keys_1 = require("../../../services/api/src/lib/api-keys");
|
|
47
|
-
(0, vitest_1.describe)('CLI → API Integration Tests', () => {
|
|
48
|
-
let server;
|
|
49
|
-
let apiKey;
|
|
50
|
-
let apiUrl;
|
|
51
|
-
let organizationId;
|
|
52
|
-
let cliPath;
|
|
53
|
-
(0, vitest_1.beforeAll)(async () => {
|
|
54
|
-
// Initialize database
|
|
55
|
-
await (0, db_1.initDatabase)(process.env.DATABASE_URL || 'postgresql://neurcode:neurcode@localhost:5432/neurcode');
|
|
56
|
-
// Build server
|
|
57
|
-
server = await (0, index_1.buildServer)();
|
|
58
|
-
await server.ready();
|
|
59
|
-
// Get server URL
|
|
60
|
-
const address = server.server.address();
|
|
61
|
-
if (typeof address === 'string') {
|
|
62
|
-
apiUrl = address;
|
|
63
|
-
}
|
|
64
|
-
else if (address) {
|
|
65
|
-
apiUrl = `http://localhost:${address.port}`;
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
apiUrl = 'http://localhost:3000';
|
|
69
|
-
}
|
|
70
|
-
// Create test organization and API key
|
|
71
|
-
const orgResult = await (0, db_1.query)(`
|
|
72
|
-
INSERT INTO organizations (id, name, slug)
|
|
73
|
-
VALUES (gen_random_uuid(), 'Test Org', 'test-org-cli')
|
|
74
|
-
ON CONFLICT (slug) DO UPDATE SET name = EXCLUDED.name
|
|
75
|
-
RETURNING id
|
|
76
|
-
`);
|
|
77
|
-
organizationId = orgResult.rows[0].id;
|
|
78
|
-
const keyData = await (0, api_keys_1.createApiKey)(organizationId, null, 'CLI Test Key');
|
|
79
|
-
apiKey = keyData.key;
|
|
80
|
-
// Build CLI
|
|
81
|
-
const cliDir = (0, path_1.join)(__dirname, '..', '..');
|
|
82
|
-
(0, child_process_1.execSync)('pnpm build', { cwd: cliDir, stdio: 'inherit' });
|
|
83
|
-
cliPath = (0, path_1.join)(cliDir, 'dist', 'index.js');
|
|
84
|
-
}, 30000);
|
|
85
|
-
(0, vitest_1.afterAll)(async () => {
|
|
86
|
-
await server.close();
|
|
87
|
-
await (0, db_1.closeDatabase)();
|
|
88
|
-
});
|
|
89
|
-
(0, vitest_1.describe)('CLI online mode', () => {
|
|
90
|
-
(0, vitest_1.it)('should send diff to API and get response', async () => {
|
|
91
|
-
// Create a test git repo with a diff
|
|
92
|
-
const testDir = '/tmp/neurcode-cli-test';
|
|
93
|
-
try {
|
|
94
|
-
(0, child_process_1.execSync)('rm -rf ' + testDir, { stdio: 'ignore' });
|
|
95
|
-
(0, child_process_1.execSync)('mkdir -p ' + testDir, { stdio: 'ignore' });
|
|
96
|
-
(0, child_process_1.execSync)('git init', { cwd: testDir, stdio: 'ignore' });
|
|
97
|
-
(0, child_process_1.execSync)('git config user.email "test@test.com"', { cwd: testDir, stdio: 'ignore' });
|
|
98
|
-
(0, child_process_1.execSync)('git config user.name "Test User"', { cwd: testDir, stdio: 'ignore' });
|
|
99
|
-
// Create a test file
|
|
100
|
-
const fs = await Promise.resolve().then(() => __importStar(require('fs')));
|
|
101
|
-
fs.writeFileSync((0, path_1.join)(testDir, 'test.js'), 'console.log("test");\n');
|
|
102
|
-
(0, child_process_1.execSync)('git add test.js', { cwd: testDir, stdio: 'ignore' });
|
|
103
|
-
(0, child_process_1.execSync)('git commit -m "Initial commit"', { cwd: testDir, stdio: 'ignore' });
|
|
104
|
-
// Make a change
|
|
105
|
-
fs.writeFileSync((0, path_1.join)(testDir, 'test.js'), 'console.log("test");\nconst x = 1;\n');
|
|
106
|
-
(0, child_process_1.execSync)('git add test.js', { cwd: testDir, stdio: 'ignore' });
|
|
107
|
-
// Run CLI with online mode
|
|
108
|
-
const result = (0, child_process_1.execSync)(`node ${cliPath} check --online --staged`, {
|
|
109
|
-
cwd: testDir,
|
|
110
|
-
env: {
|
|
111
|
-
...process.env,
|
|
112
|
-
NEURCODE_API_URL: apiUrl,
|
|
113
|
-
NEURCODE_API_KEY: apiKey,
|
|
114
|
-
},
|
|
115
|
-
encoding: 'utf-8',
|
|
116
|
-
});
|
|
117
|
-
// Should not throw and should contain analysis results
|
|
118
|
-
(0, vitest_1.expect)(result).toBeDefined();
|
|
119
|
-
(0, vitest_1.expect)(result.length).toBeGreaterThan(0);
|
|
120
|
-
}
|
|
121
|
-
finally {
|
|
122
|
-
(0, child_process_1.execSync)('rm -rf ' + testDir, { stdio: 'ignore' });
|
|
123
|
-
}
|
|
124
|
-
}, 60000);
|
|
125
|
-
(0, vitest_1.it)('should handle API errors gracefully', async () => {
|
|
126
|
-
const testDir = '/tmp/neurcode-cli-test-error';
|
|
127
|
-
try {
|
|
128
|
-
(0, child_process_1.execSync)('rm -rf ' + testDir, { stdio: 'ignore' });
|
|
129
|
-
(0, child_process_1.execSync)('mkdir -p ' + testDir, { stdio: 'ignore' });
|
|
130
|
-
(0, child_process_1.execSync)('git init', { cwd: testDir, stdio: 'ignore' });
|
|
131
|
-
(0, child_process_1.execSync)('git config user.email "test@test.com"', { cwd: testDir, stdio: 'ignore' });
|
|
132
|
-
(0, child_process_1.execSync)('git config user.name "Test User"', { cwd: testDir, stdio: 'ignore' });
|
|
133
|
-
// Use invalid API key
|
|
134
|
-
try {
|
|
135
|
-
(0, child_process_1.execSync)(`node ${cliPath} check --online --staged`, {
|
|
136
|
-
cwd: testDir,
|
|
137
|
-
env: {
|
|
138
|
-
...process.env,
|
|
139
|
-
NEURCODE_API_URL: apiUrl,
|
|
140
|
-
NEURCODE_API_KEY: 'invalid_key',
|
|
141
|
-
},
|
|
142
|
-
encoding: 'utf-8',
|
|
143
|
-
stdio: 'pipe',
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
// Should fail with error message
|
|
148
|
-
(0, vitest_1.expect)(error.message).toBeDefined();
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
finally {
|
|
152
|
-
(0, child_process_1.execSync)('rm -rf ' + testDir, { stdio: 'ignore' });
|
|
153
|
-
}
|
|
154
|
-
}, 30000);
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
//# sourceMappingURL=check.integration.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"check.integration.test.js","sourceRoot":"","sources":["../../src/commands/check.integration.test.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,mCAAmE;AACnE,iDAAyC;AACzC,+BAA4B;AAC5B,2DAA8D;AAE9D,qDAAkF;AAClF,qEAAsE;AAEtE,IAAA,iBAAQ,EAAC,6BAA6B,EAAE,GAAG,EAAE;IAC3C,IAAI,MAAuB,CAAC;IAC5B,IAAI,MAAc,CAAC;IACnB,IAAI,MAAc,CAAC;IACnB,IAAI,cAAsB,CAAC;IAC3B,IAAI,OAAe,CAAC;IAEpB,IAAA,kBAAS,EAAC,KAAK,IAAI,EAAE;QACnB,sBAAsB;QACtB,MAAM,IAAA,iBAAY,EAAC,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,wDAAwD,CAAC,CAAC;QAEzG,eAAe;QACf,MAAM,GAAG,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