@nella-labs/core 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 +82 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +85 -0
- package/dist/index.js.map +1 -0
- package/dist/run.d.ts +63 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +259 -0
- package/dist/run.js.map +1 -0
- package/dist/safety/index.d.ts +5 -0
- package/dist/safety/index.d.ts.map +1 -0
- package/dist/safety/index.js +21 -0
- package/dist/safety/index.js.map +1 -0
- package/dist/safety/refusal-detector.d.ts +60 -0
- package/dist/safety/refusal-detector.d.ts.map +1 -0
- package/dist/safety/refusal-detector.js +250 -0
- package/dist/safety/refusal-detector.js.map +1 -0
- package/dist/types/agent.d.ts +39 -0
- package/dist/types/agent.d.ts.map +1 -0
- package/dist/types/agent.js +8 -0
- package/dist/types/agent.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +23 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/result.d.ts +166 -0
- package/dist/types/result.d.ts.map +1 -0
- package/dist/types/result.js +8 -0
- package/dist/types/result.js.map +1 -0
- package/dist/types/task.d.ts +105 -0
- package/dist/types/task.d.ts.map +1 -0
- package/dist/types/task.js +8 -0
- package/dist/types/task.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +22 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +56 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +127 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/workspace.d.ts +45 -0
- package/dist/utils/workspace.d.ts.map +1 -0
- package/dist/utils/workspace.js +199 -0
- package/dist/utils/workspace.js.map +1 -0
- package/dist/validators/command-runner.d.ts +33 -0
- package/dist/validators/command-runner.d.ts.map +1 -0
- package/dist/validators/command-runner.js +135 -0
- package/dist/validators/command-runner.js.map +1 -0
- package/dist/validators/constraint-checker.d.ts +37 -0
- package/dist/validators/constraint-checker.d.ts.map +1 -0
- package/dist/validators/constraint-checker.js +127 -0
- package/dist/validators/constraint-checker.js.map +1 -0
- package/dist/validators/index.d.ts +7 -0
- package/dist/validators/index.d.ts.map +1 -0
- package/dist/validators/index.js +23 -0
- package/dist/validators/index.js.map +1 -0
- package/dist/validators/scope-checker.d.ts +15 -0
- package/dist/validators/scope-checker.d.ts.map +1 -0
- package/dist/validators/scope-checker.js +64 -0
- package/dist/validators/scope-checker.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Utils - Re-exports
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
__exportStar(require("./logger"), exports);
|
|
21
|
+
__exportStar(require("./workspace"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;AAEH,2CAAyB;AACzB,8CAA4B"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger
|
|
3
|
+
*
|
|
4
|
+
* Structured JSONL logging for run records.
|
|
5
|
+
*/
|
|
6
|
+
import { LogEntry, LogEntryType } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* Structured logger that writes JSONL to a file
|
|
9
|
+
*/
|
|
10
|
+
export declare class RunLogger {
|
|
11
|
+
private logPath;
|
|
12
|
+
private entries;
|
|
13
|
+
constructor(runDir: string);
|
|
14
|
+
/**
|
|
15
|
+
* Log an entry
|
|
16
|
+
*/
|
|
17
|
+
log(type: LogEntryType, data: Record<string, unknown>): void;
|
|
18
|
+
/**
|
|
19
|
+
* Log a plan declaration
|
|
20
|
+
*/
|
|
21
|
+
logPlan(files: string[], summary: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Log a refusal decision
|
|
24
|
+
*/
|
|
25
|
+
logRefusal(reason: string, patterns: string[]): void;
|
|
26
|
+
/**
|
|
27
|
+
* Log a constraint check result
|
|
28
|
+
*/
|
|
29
|
+
logConstraintCheck(id: string, passed: boolean, details?: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* Log a validation result
|
|
32
|
+
*/
|
|
33
|
+
logValidation(type: "test" | "lint" | "compile", passed: boolean, exitCode: number): void;
|
|
34
|
+
/**
|
|
35
|
+
* Log scope check result
|
|
36
|
+
*/
|
|
37
|
+
logScopeCheck(extraFiles: string[], missingFiles: string[], ratio: number): void;
|
|
38
|
+
/**
|
|
39
|
+
* Log final metrics
|
|
40
|
+
*/
|
|
41
|
+
logMetrics(metrics: object): void;
|
|
42
|
+
/**
|
|
43
|
+
* Log an error
|
|
44
|
+
*/
|
|
45
|
+
logError(error: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* Get all entries
|
|
48
|
+
*/
|
|
49
|
+
getEntries(): LogEntry[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Generate a unique run ID
|
|
53
|
+
* Format: YYYY-MM-DD_HHMMSS_XXXX (date_time_random4)
|
|
54
|
+
*/
|
|
55
|
+
export declare function generateRunId(): string;
|
|
56
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAElD;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAkB;gBAErB,MAAM,EAAE,MAAM;IAI1B;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAa5D;;OAEG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAI/C;;OAEG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI;IAIpD;;OAEG;IACH,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAIvE;;OAEG;IACH,aAAa,CACX,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EACjC,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,MAAM,GACf,IAAI;IAIP;;OAEG;IACH,aAAa,CACX,UAAU,EAAE,MAAM,EAAE,EACpB,YAAY,EAAE,MAAM,EAAE,EACtB,KAAK,EAAE,MAAM,GACZ,IAAI;IAIP;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIjC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI7B;;OAEG;IACH,UAAU,IAAI,QAAQ,EAAE;CAGzB;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAMtC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Logger
|
|
4
|
+
*
|
|
5
|
+
* Structured JSONL logging for run records.
|
|
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
|
+
exports.RunLogger = void 0;
|
|
42
|
+
exports.generateRunId = generateRunId;
|
|
43
|
+
const fs = __importStar(require("fs"));
|
|
44
|
+
const path = __importStar(require("path"));
|
|
45
|
+
/**
|
|
46
|
+
* Structured logger that writes JSONL to a file
|
|
47
|
+
*/
|
|
48
|
+
class RunLogger {
|
|
49
|
+
constructor(runDir) {
|
|
50
|
+
this.entries = [];
|
|
51
|
+
this.logPath = path.join(runDir, "logs.jsonl");
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Log an entry
|
|
55
|
+
*/
|
|
56
|
+
log(type, data) {
|
|
57
|
+
const entry = {
|
|
58
|
+
ts: new Date().toISOString(),
|
|
59
|
+
type,
|
|
60
|
+
data,
|
|
61
|
+
};
|
|
62
|
+
this.entries.push(entry);
|
|
63
|
+
// Append to file immediately (streaming)
|
|
64
|
+
fs.appendFileSync(this.logPath, JSON.stringify(entry) + "\n");
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Log a plan declaration
|
|
68
|
+
*/
|
|
69
|
+
logPlan(files, summary) {
|
|
70
|
+
this.log("plan", { files, summary });
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Log a refusal decision
|
|
74
|
+
*/
|
|
75
|
+
logRefusal(reason, patterns) {
|
|
76
|
+
this.log("refusal", { reason, patterns });
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Log a constraint check result
|
|
80
|
+
*/
|
|
81
|
+
logConstraintCheck(id, passed, details) {
|
|
82
|
+
this.log("constraint_check", { id, passed, details });
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Log a validation result
|
|
86
|
+
*/
|
|
87
|
+
logValidation(type, passed, exitCode) {
|
|
88
|
+
this.log("validation", { type, passed, exitCode });
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Log scope check result
|
|
92
|
+
*/
|
|
93
|
+
logScopeCheck(extraFiles, missingFiles, ratio) {
|
|
94
|
+
this.log("scope_check", { extraFiles, missingFiles, scopeCreepRatio: ratio });
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Log final metrics
|
|
98
|
+
*/
|
|
99
|
+
logMetrics(metrics) {
|
|
100
|
+
this.log("metrics", { ...metrics });
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Log an error
|
|
104
|
+
*/
|
|
105
|
+
logError(error) {
|
|
106
|
+
this.log("error", { error });
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Get all entries
|
|
110
|
+
*/
|
|
111
|
+
getEntries() {
|
|
112
|
+
return [...this.entries];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.RunLogger = RunLogger;
|
|
116
|
+
/**
|
|
117
|
+
* Generate a unique run ID
|
|
118
|
+
* Format: YYYY-MM-DD_HHMMSS_XXXX (date_time_random4)
|
|
119
|
+
*/
|
|
120
|
+
function generateRunId() {
|
|
121
|
+
const now = new Date();
|
|
122
|
+
const date = now.toISOString().split("T")[0];
|
|
123
|
+
const time = now.toTimeString().split(" ")[0].replace(/:/g, "");
|
|
124
|
+
const random = Math.random().toString(36).substring(2, 6);
|
|
125
|
+
return `${date}_${time}_${random}`;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sour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3
|
+
*
|
|
4
|
+
* Handles workspace isolation - copying to temp, applying changes, generating diffs.
|
|
5
|
+
*/
|
|
6
|
+
import { FileChange, Artifacts } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* Create a temporary copy of a workspace
|
|
9
|
+
*
|
|
10
|
+
* @param sourcePath - Original workspace path
|
|
11
|
+
* @returns Path to the temporary copy
|
|
12
|
+
*/
|
|
13
|
+
export declare function createTempWorkspace(sourcePath: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Apply file changes to a workspace
|
|
16
|
+
*
|
|
17
|
+
* @param workspacePath - Path to workspace
|
|
18
|
+
* @param changes - File changes to apply
|
|
19
|
+
* @returns List of modified file paths
|
|
20
|
+
*/
|
|
21
|
+
export declare function applyChanges(workspacePath: string, changes: FileChange[]): string[];
|
|
22
|
+
/**
|
|
23
|
+
* Initialize git in workspace and get diff of changes
|
|
24
|
+
*
|
|
25
|
+
* @param workspacePath - Path to workspace
|
|
26
|
+
* @returns Git diff string
|
|
27
|
+
*/
|
|
28
|
+
export declare function getDiff(workspacePath: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Get list of modified files from git
|
|
31
|
+
*/
|
|
32
|
+
export declare function getModifiedFiles(workspacePath: string): string[];
|
|
33
|
+
/**
|
|
34
|
+
* Create the .nella directory structure for artifacts
|
|
35
|
+
*/
|
|
36
|
+
export declare function createNellaDir(workspacePath: string, runId: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Write artifacts to the run directory
|
|
39
|
+
*/
|
|
40
|
+
export declare function writeArtifacts(runDir: string, diff: string, metrics: object): Artifacts;
|
|
41
|
+
/**
|
|
42
|
+
* Clean up a temporary workspace
|
|
43
|
+
*/
|
|
44
|
+
export declare function cleanupTempWorkspace(tempPath: string): void;
|
|
45
|
+
//# sourceMappingURL=workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/utils/workspace.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEjD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAO9D;AA4BD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,UAAU,EAAE,GACpB,MAAM,EAAE,CA4BV;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAqBrD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,CAehE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAI3E;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,SAAS,CAcX;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAM3D"}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Workspace Manager
|
|
4
|
+
*
|
|
5
|
+
* Handles workspace isolation - copying to temp, applying changes, generating diffs.
|
|
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
|
+
exports.createTempWorkspace = createTempWorkspace;
|
|
42
|
+
exports.applyChanges = applyChanges;
|
|
43
|
+
exports.getDiff = getDiff;
|
|
44
|
+
exports.getModifiedFiles = getModifiedFiles;
|
|
45
|
+
exports.createNellaDir = createNellaDir;
|
|
46
|
+
exports.writeArtifacts = writeArtifacts;
|
|
47
|
+
exports.cleanupTempWorkspace = cleanupTempWorkspace;
|
|
48
|
+
const fs = __importStar(require("fs"));
|
|
49
|
+
const path = __importStar(require("path"));
|
|
50
|
+
const os = __importStar(require("os"));
|
|
51
|
+
const child_process_1 = require("child_process");
|
|
52
|
+
/**
|
|
53
|
+
* Create a temporary copy of a workspace
|
|
54
|
+
*
|
|
55
|
+
* @param sourcePath - Original workspace path
|
|
56
|
+
* @returns Path to the temporary copy
|
|
57
|
+
*/
|
|
58
|
+
function createTempWorkspace(sourcePath) {
|
|
59
|
+
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "nella-"));
|
|
60
|
+
// Copy the workspace (excluding node_modules for speed)
|
|
61
|
+
copyDirRecursive(sourcePath, tempDir, ["node_modules", ".git", ".nella"]);
|
|
62
|
+
return tempDir;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Recursively copy a directory
|
|
66
|
+
*/
|
|
67
|
+
function copyDirRecursive(src, dest, exclude = []) {
|
|
68
|
+
if (!fs.existsSync(dest)) {
|
|
69
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
70
|
+
}
|
|
71
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
72
|
+
for (const entry of entries) {
|
|
73
|
+
if (exclude.includes(entry.name)) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const srcPath = path.join(src, entry.name);
|
|
77
|
+
const destPath = path.join(dest, entry.name);
|
|
78
|
+
if (entry.isDirectory()) {
|
|
79
|
+
copyDirRecursive(srcPath, destPath, exclude);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
fs.copyFileSync(srcPath, destPath);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Apply file changes to a workspace
|
|
88
|
+
*
|
|
89
|
+
* @param workspacePath - Path to workspace
|
|
90
|
+
* @param changes - File changes to apply
|
|
91
|
+
* @returns List of modified file paths
|
|
92
|
+
*/
|
|
93
|
+
function applyChanges(workspacePath, changes) {
|
|
94
|
+
const modifiedFiles = [];
|
|
95
|
+
for (const change of changes) {
|
|
96
|
+
const filePath = path.join(workspacePath, change.path);
|
|
97
|
+
const dirPath = path.dirname(filePath);
|
|
98
|
+
switch (change.operation) {
|
|
99
|
+
case "create":
|
|
100
|
+
case "modify":
|
|
101
|
+
// Ensure directory exists
|
|
102
|
+
if (!fs.existsSync(dirPath)) {
|
|
103
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
104
|
+
}
|
|
105
|
+
fs.writeFileSync(filePath, change.content);
|
|
106
|
+
modifiedFiles.push(change.path);
|
|
107
|
+
break;
|
|
108
|
+
case "delete":
|
|
109
|
+
if (fs.existsSync(filePath)) {
|
|
110
|
+
fs.unlinkSync(filePath);
|
|
111
|
+
modifiedFiles.push(change.path);
|
|
112
|
+
}
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return modifiedFiles;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Initialize git in workspace and get diff of changes
|
|
120
|
+
*
|
|
121
|
+
* @param workspacePath - Path to workspace
|
|
122
|
+
* @returns Git diff string
|
|
123
|
+
*/
|
|
124
|
+
function getDiff(workspacePath) {
|
|
125
|
+
try {
|
|
126
|
+
// Initialize git if not already
|
|
127
|
+
const gitDir = path.join(workspacePath, ".git");
|
|
128
|
+
if (!fs.existsSync(gitDir)) {
|
|
129
|
+
(0, child_process_1.execSync)("git init", { cwd: workspacePath, stdio: "pipe" });
|
|
130
|
+
(0, child_process_1.execSync)("git add -A", { cwd: workspacePath, stdio: "pipe" });
|
|
131
|
+
(0, child_process_1.execSync)('git commit -m "initial"', { cwd: workspacePath, stdio: "pipe" });
|
|
132
|
+
}
|
|
133
|
+
// Get diff of uncommitted changes
|
|
134
|
+
const diff = (0, child_process_1.execSync)("git diff HEAD", {
|
|
135
|
+
cwd: workspacePath,
|
|
136
|
+
encoding: "utf-8",
|
|
137
|
+
stdio: "pipe",
|
|
138
|
+
});
|
|
139
|
+
return diff;
|
|
140
|
+
}
|
|
141
|
+
catch (e) {
|
|
142
|
+
return "";
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Get list of modified files from git
|
|
147
|
+
*/
|
|
148
|
+
function getModifiedFiles(workspacePath) {
|
|
149
|
+
try {
|
|
150
|
+
const output = (0, child_process_1.execSync)("git status --porcelain", {
|
|
151
|
+
cwd: workspacePath,
|
|
152
|
+
encoding: "utf-8",
|
|
153
|
+
stdio: "pipe",
|
|
154
|
+
});
|
|
155
|
+
return output
|
|
156
|
+
.split("\n")
|
|
157
|
+
.filter((line) => line.trim())
|
|
158
|
+
.map((line) => line.substring(3).trim());
|
|
159
|
+
}
|
|
160
|
+
catch (e) {
|
|
161
|
+
return [];
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Create the .nella directory structure for artifacts
|
|
166
|
+
*/
|
|
167
|
+
function createNellaDir(workspacePath, runId) {
|
|
168
|
+
const nellaDir = path.join(workspacePath, ".nella", "runs", runId);
|
|
169
|
+
fs.mkdirSync(nellaDir, { recursive: true });
|
|
170
|
+
return nellaDir;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Write artifacts to the run directory
|
|
174
|
+
*/
|
|
175
|
+
function writeArtifacts(runDir, diff, metrics) {
|
|
176
|
+
const diffPath = path.join(runDir, "diff.patch");
|
|
177
|
+
const metricsPath = path.join(runDir, "metrics.json");
|
|
178
|
+
const logsPath = path.join(runDir, "logs.jsonl");
|
|
179
|
+
fs.writeFileSync(diffPath, diff);
|
|
180
|
+
fs.writeFileSync(metricsPath, JSON.stringify(metrics, null, 2));
|
|
181
|
+
return {
|
|
182
|
+
diffPath,
|
|
183
|
+
logsPath,
|
|
184
|
+
metricsPath,
|
|
185
|
+
runDir,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Clean up a temporary workspace
|
|
190
|
+
*/
|
|
191
|
+
function cleanupTempWorkspace(tempPath) {
|
|
192
|
+
try {
|
|
193
|
+
fs.rmSync(tempPath, { recursive: true, force: true });
|
|
194
|
+
}
|
|
195
|
+
catch (e) {
|
|
196
|
+
// Ignore cleanup errors
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=workspace.js.map
|
|
@@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C;IACxD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,wBAAwB;IAC1B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command Runner
|
|
3
|
+
*
|
|
4
|
+
* Executes validation commands (test, lint, compile) and captures results.
|
|
5
|
+
*/
|
|
6
|
+
import { ValidationConfig, ValidationResult, CommandResult } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* Run a single command and capture output
|
|
9
|
+
*
|
|
10
|
+
* @param command - Shell command to execute
|
|
11
|
+
* @param workDir - Working directory
|
|
12
|
+
* @param timeoutMs - Timeout in milliseconds
|
|
13
|
+
* @returns Command result with exit code and output
|
|
14
|
+
*/
|
|
15
|
+
export declare function runCommand(command: string, workDir: string, timeoutMs?: number): CommandResult;
|
|
16
|
+
/**
|
|
17
|
+
* Run all validation commands
|
|
18
|
+
*
|
|
19
|
+
* @param config - Validation commands to run
|
|
20
|
+
* @param workDir - Working directory
|
|
21
|
+
* @param timeoutMs - Timeout per command
|
|
22
|
+
* @returns Validation results with pass/fail status
|
|
23
|
+
*/
|
|
24
|
+
export declare function runValidation(config: ValidationConfig, workDir: string, timeoutMs?: number): ValidationResult;
|
|
25
|
+
/**
|
|
26
|
+
* Get combined error output from validation results
|
|
27
|
+
*/
|
|
28
|
+
export declare function getValidationErrors(result: ValidationResult): string;
|
|
29
|
+
/**
|
|
30
|
+
* Calculate validation integrity (ratio of passed checks)
|
|
31
|
+
*/
|
|
32
|
+
export declare function calculateValidationIntegrity(result: ValidationResult): number;
|
|
33
|
+
//# sourceMappingURL=command-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-runner.d.ts","sourceRoot":"","sources":["../../src/validators/command-runner.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAO7E;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,SAAS,GAAE,MAA2B,GACrC,aAAa,CA4Cf;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,MAAM,EACf,SAAS,GAAE,MAA2B,GACrC,gBAAgB,CAgClB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAgBpE;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAoB7E"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Command Runner
|
|
4
|
+
*
|
|
5
|
+
* Executes validation commands (test, lint, compile) and captures results.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.runCommand = runCommand;
|
|
9
|
+
exports.runValidation = runValidation;
|
|
10
|
+
exports.getValidationErrors = getValidationErrors;
|
|
11
|
+
exports.calculateValidationIntegrity = calculateValidationIntegrity;
|
|
12
|
+
const child_process_1 = require("child_process");
|
|
13
|
+
/**
|
|
14
|
+
* Default timeout for commands (2 minutes)
|
|
15
|
+
*/
|
|
16
|
+
const DEFAULT_TIMEOUT_MS = 120000;
|
|
17
|
+
/**
|
|
18
|
+
* Run a single command and capture output
|
|
19
|
+
*
|
|
20
|
+
* @param command - Shell command to execute
|
|
21
|
+
* @param workDir - Working directory
|
|
22
|
+
* @param timeoutMs - Timeout in milliseconds
|
|
23
|
+
* @returns Command result with exit code and output
|
|
24
|
+
*/
|
|
25
|
+
function runCommand(command, workDir, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
26
|
+
const startTime = Date.now();
|
|
27
|
+
const options = {
|
|
28
|
+
cwd: workDir,
|
|
29
|
+
encoding: "utf-8",
|
|
30
|
+
timeout: timeoutMs,
|
|
31
|
+
stdio: "pipe",
|
|
32
|
+
shell: true,
|
|
33
|
+
env: { ...process.env, CI: "true", FORCE_COLOR: "0" },
|
|
34
|
+
};
|
|
35
|
+
try {
|
|
36
|
+
const output = (0, child_process_1.execSync)(command, options);
|
|
37
|
+
const durationMs = Date.now() - startTime;
|
|
38
|
+
return {
|
|
39
|
+
command,
|
|
40
|
+
success: true,
|
|
41
|
+
output: output.toString(),
|
|
42
|
+
exitCode: 0,
|
|
43
|
+
durationMs,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
const durationMs = Date.now() - startTime;
|
|
48
|
+
const execError = error;
|
|
49
|
+
const stdout = execError.stdout ?? "";
|
|
50
|
+
const stderr = execError.stderr ?? "";
|
|
51
|
+
const message = execError.message ?? "";
|
|
52
|
+
return {
|
|
53
|
+
command,
|
|
54
|
+
success: false,
|
|
55
|
+
output: `${stdout}\n${stderr}\n${message}`.trim(),
|
|
56
|
+
exitCode: execError.status ?? 1,
|
|
57
|
+
durationMs,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Run all validation commands
|
|
63
|
+
*
|
|
64
|
+
* @param config - Validation commands to run
|
|
65
|
+
* @param workDir - Working directory
|
|
66
|
+
* @param timeoutMs - Timeout per command
|
|
67
|
+
* @returns Validation results with pass/fail status
|
|
68
|
+
*/
|
|
69
|
+
function runValidation(config, workDir, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
70
|
+
let testResult = null;
|
|
71
|
+
let lintResult = null;
|
|
72
|
+
let compileResult = null;
|
|
73
|
+
// Run test command
|
|
74
|
+
if (config.test) {
|
|
75
|
+
testResult = runCommand(config.test, workDir, timeoutMs);
|
|
76
|
+
}
|
|
77
|
+
// Run lint command
|
|
78
|
+
if (config.lint) {
|
|
79
|
+
lintResult = runCommand(config.lint, workDir, timeoutMs);
|
|
80
|
+
}
|
|
81
|
+
// Run compile/typecheck command
|
|
82
|
+
if (config.compile) {
|
|
83
|
+
compileResult = runCommand(config.compile, workDir, timeoutMs);
|
|
84
|
+
}
|
|
85
|
+
// Check if all configured validations passed
|
|
86
|
+
const allPassed = (testResult === null || testResult.success) &&
|
|
87
|
+
(lintResult === null || lintResult.success) &&
|
|
88
|
+
(compileResult === null || compileResult.success);
|
|
89
|
+
return {
|
|
90
|
+
test: testResult,
|
|
91
|
+
lint: lintResult,
|
|
92
|
+
compile: compileResult,
|
|
93
|
+
allPassed,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Get combined error output from validation results
|
|
98
|
+
*/
|
|
99
|
+
function getValidationErrors(result) {
|
|
100
|
+
const errors = [];
|
|
101
|
+
if (result.test && !result.test.success) {
|
|
102
|
+
errors.push(`Test failed:\n${result.test.output}`);
|
|
103
|
+
}
|
|
104
|
+
if (result.lint && !result.lint.success) {
|
|
105
|
+
errors.push(`Lint failed:\n${result.lint.output}`);
|
|
106
|
+
}
|
|
107
|
+
if (result.compile && !result.compile.success) {
|
|
108
|
+
errors.push(`Compile failed:\n${result.compile.output}`);
|
|
109
|
+
}
|
|
110
|
+
return errors.join("\n\n");
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Calculate validation integrity (ratio of passed checks)
|
|
114
|
+
*/
|
|
115
|
+
function calculateValidationIntegrity(result) {
|
|
116
|
+
let passed = 0;
|
|
117
|
+
let total = 0;
|
|
118
|
+
if (result.test !== null) {
|
|
119
|
+
total++;
|
|
120
|
+
if (result.test.success)
|
|
121
|
+
passed++;
|
|
122
|
+
}
|
|
123
|
+
if (result.lint !== null) {
|
|
124
|
+
total++;
|
|
125
|
+
if (result.lint.success)
|
|
126
|
+
passed++;
|
|
127
|
+
}
|
|
128
|
+
if (result.compile !== null) {
|
|
129
|
+
total++;
|
|
130
|
+
if (result.compile.success)
|
|
131
|
+
passed++;
|
|
132
|
+
}
|
|
133
|
+
return total > 0 ? passed / total : 1;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=command-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-runner.js","sourceRoot":"","sources":["../../src/validators/command-runner.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAkBH,gCAgDC;AAUD,sCAoCC;AAKD,kDAgBC;AAKD,oEAoBC;AA5JD,iDAA4E;AAG5E;;GAEG;AACH,MAAM,kBAAkB,GAAG,MAAO,CAAC;AAEnC;;;;;;;GAOG;AACH,SAAgB,UAAU,CACxB,OAAe,EACf,OAAe,EACf,YAAoB,kBAAkB;IAEtC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,MAAM,OAAO,GAAsC;QACjD,GAAG,EAAE,OAAO;QACZ,QAAQ,EAAE,OAAO;QACjB,OAAO,EAAE,SAAS;QAClB,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,IAAyB;QAChC,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE;KACtD,CAAC;IAEF,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAA,wBAAQ,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC1C,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;QAE1C,OAAO;YACL,OAAO;YACP,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE;YACzB,QAAQ,EAAE,CAAC;YACX,UAAU;SACX,CAAC;IACJ,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;QAC1C,MAAM,SAAS,GAAG,KAKjB,CAAC;QAEF,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,IAAI,EAAE,CAAC;QACtC,MAAM,MAAM,GAAG,SAAS,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