genesis-ai-cli 7.4.5
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/.env.example +78 -0
- package/README.md +282 -0
- package/dist/src/active-inference/actions.d.ts +75 -0
- package/dist/src/active-inference/actions.js +250 -0
- package/dist/src/active-inference/autonomous-loop.d.ts +103 -0
- package/dist/src/active-inference/autonomous-loop.js +289 -0
- package/dist/src/active-inference/core.d.ts +85 -0
- package/dist/src/active-inference/core.js +555 -0
- package/dist/src/active-inference/demo-autonomous-loop.d.ts +8 -0
- package/dist/src/active-inference/demo-autonomous-loop.js +338 -0
- package/dist/src/active-inference/demo-value-integration.d.ts +8 -0
- package/dist/src/active-inference/demo-value-integration.js +174 -0
- package/dist/src/active-inference/index.d.ts +32 -0
- package/dist/src/active-inference/index.js +88 -0
- package/dist/src/active-inference/integration.d.ts +114 -0
- package/dist/src/active-inference/integration.js +698 -0
- package/dist/src/active-inference/memory-integration.d.ts +51 -0
- package/dist/src/active-inference/memory-integration.js +232 -0
- package/dist/src/active-inference/observations.d.ts +67 -0
- package/dist/src/active-inference/observations.js +147 -0
- package/dist/src/active-inference/test-active-inference.d.ts +8 -0
- package/dist/src/active-inference/test-active-inference.js +320 -0
- package/dist/src/active-inference/test-value-integration.d.ts +6 -0
- package/dist/src/active-inference/test-value-integration.js +168 -0
- package/dist/src/active-inference/types.d.ts +150 -0
- package/dist/src/active-inference/types.js +59 -0
- package/dist/src/active-inference/value-integration.d.ts +164 -0
- package/dist/src/active-inference/value-integration.js +459 -0
- package/dist/src/agents/base-agent.d.ts +53 -0
- package/dist/src/agents/base-agent.js +178 -0
- package/dist/src/agents/builder.d.ts +67 -0
- package/dist/src/agents/builder.js +537 -0
- package/dist/src/agents/critic.d.ts +35 -0
- package/dist/src/agents/critic.js +322 -0
- package/dist/src/agents/ethicist.d.ts +54 -0
- package/dist/src/agents/ethicist.js +393 -0
- package/dist/src/agents/explorer.d.ts +26 -0
- package/dist/src/agents/explorer.js +216 -0
- package/dist/src/agents/feeling.d.ts +41 -0
- package/dist/src/agents/feeling.js +320 -0
- package/dist/src/agents/index.d.ts +111 -0
- package/dist/src/agents/index.js +222 -0
- package/dist/src/agents/memory.d.ts +69 -0
- package/dist/src/agents/memory.js +404 -0
- package/dist/src/agents/message-bus.d.ts +88 -0
- package/dist/src/agents/message-bus.js +267 -0
- package/dist/src/agents/narrator.d.ts +90 -0
- package/dist/src/agents/narrator.js +473 -0
- package/dist/src/agents/planner.d.ts +38 -0
- package/dist/src/agents/planner.js +341 -0
- package/dist/src/agents/predictor.d.ts +73 -0
- package/dist/src/agents/predictor.js +506 -0
- package/dist/src/agents/sensor.d.ts +88 -0
- package/dist/src/agents/sensor.js +377 -0
- package/dist/src/agents/test-agents.d.ts +6 -0
- package/dist/src/agents/test-agents.js +73 -0
- package/dist/src/agents/types.d.ts +194 -0
- package/dist/src/agents/types.js +7 -0
- package/dist/src/brain/index.d.ts +185 -0
- package/dist/src/brain/index.js +843 -0
- package/dist/src/brain/trace.d.ts +91 -0
- package/dist/src/brain/trace.js +327 -0
- package/dist/src/brain/types.d.ts +165 -0
- package/dist/src/brain/types.js +51 -0
- package/dist/src/cli/chat.d.ts +237 -0
- package/dist/src/cli/chat.js +1959 -0
- package/dist/src/cli/dispatcher.d.ts +182 -0
- package/dist/src/cli/dispatcher.js +718 -0
- package/dist/src/cli/human-loop.d.ts +170 -0
- package/dist/src/cli/human-loop.js +543 -0
- package/dist/src/cli/index.d.ts +12 -0
- package/dist/src/cli/index.js +28 -0
- package/dist/src/cli/interactive.d.ts +141 -0
- package/dist/src/cli/interactive.js +757 -0
- package/dist/src/cli/ui.d.ts +205 -0
- package/dist/src/cli/ui.js +632 -0
- package/dist/src/consciousness/attention-schema.d.ts +154 -0
- package/dist/src/consciousness/attention-schema.js +432 -0
- package/dist/src/consciousness/global-workspace.d.ts +149 -0
- package/dist/src/consciousness/global-workspace.js +422 -0
- package/dist/src/consciousness/index.d.ts +186 -0
- package/dist/src/consciousness/index.js +476 -0
- package/dist/src/consciousness/phi-calculator.d.ts +119 -0
- package/dist/src/consciousness/phi-calculator.js +445 -0
- package/dist/src/consciousness/phi-decisions.d.ts +169 -0
- package/dist/src/consciousness/phi-decisions.js +383 -0
- package/dist/src/consciousness/phi-monitor.d.ts +153 -0
- package/dist/src/consciousness/phi-monitor.js +465 -0
- package/dist/src/consciousness/types.d.ts +260 -0
- package/dist/src/consciousness/types.js +44 -0
- package/dist/src/daemon/dream-mode.d.ts +115 -0
- package/dist/src/daemon/dream-mode.js +470 -0
- package/dist/src/daemon/index.d.ts +162 -0
- package/dist/src/daemon/index.js +542 -0
- package/dist/src/daemon/maintenance.d.ts +139 -0
- package/dist/src/daemon/maintenance.js +549 -0
- package/dist/src/daemon/process.d.ts +82 -0
- package/dist/src/daemon/process.js +442 -0
- package/dist/src/daemon/scheduler.d.ts +90 -0
- package/dist/src/daemon/scheduler.js +494 -0
- package/dist/src/daemon/types.d.ts +213 -0
- package/dist/src/daemon/types.js +50 -0
- package/dist/src/epistemic/index.d.ts +74 -0
- package/dist/src/epistemic/index.js +225 -0
- package/dist/src/grounding/epistemic-stack.d.ts +100 -0
- package/dist/src/grounding/epistemic-stack.js +408 -0
- package/dist/src/grounding/feedback.d.ts +98 -0
- package/dist/src/grounding/feedback.js +276 -0
- package/dist/src/grounding/index.d.ts +123 -0
- package/dist/src/grounding/index.js +224 -0
- package/dist/src/grounding/verifier.d.ts +149 -0
- package/dist/src/grounding/verifier.js +484 -0
- package/dist/src/healing/detector.d.ts +110 -0
- package/dist/src/healing/detector.js +436 -0
- package/dist/src/healing/fixer.d.ts +138 -0
- package/dist/src/healing/fixer.js +572 -0
- package/dist/src/healing/index.d.ts +23 -0
- package/dist/src/healing/index.js +43 -0
- package/dist/src/hooks/index.d.ts +135 -0
- package/dist/src/hooks/index.js +317 -0
- package/dist/src/index.d.ts +23 -0
- package/dist/src/index.js +1266 -0
- package/dist/src/kernel/index.d.ts +155 -0
- package/dist/src/kernel/index.js +795 -0
- package/dist/src/kernel/invariants.d.ts +153 -0
- package/dist/src/kernel/invariants.js +355 -0
- package/dist/src/kernel/test-kernel.d.ts +6 -0
- package/dist/src/kernel/test-kernel.js +108 -0
- package/dist/src/kernel/test-real-mcp.d.ts +10 -0
- package/dist/src/kernel/test-real-mcp.js +295 -0
- package/dist/src/llm/index.d.ts +146 -0
- package/dist/src/llm/index.js +428 -0
- package/dist/src/llm/router.d.ts +136 -0
- package/dist/src/llm/router.js +510 -0
- package/dist/src/mcp/index.d.ts +85 -0
- package/dist/src/mcp/index.js +657 -0
- package/dist/src/mcp/resilient.d.ts +139 -0
- package/dist/src/mcp/resilient.js +417 -0
- package/dist/src/memory/cache.d.ts +118 -0
- package/dist/src/memory/cache.js +356 -0
- package/dist/src/memory/cognitive-workspace.d.ts +231 -0
- package/dist/src/memory/cognitive-workspace.js +521 -0
- package/dist/src/memory/consolidation.d.ts +99 -0
- package/dist/src/memory/consolidation.js +443 -0
- package/dist/src/memory/episodic.d.ts +114 -0
- package/dist/src/memory/episodic.js +394 -0
- package/dist/src/memory/forgetting.d.ts +134 -0
- package/dist/src/memory/forgetting.js +324 -0
- package/dist/src/memory/index.d.ts +211 -0
- package/dist/src/memory/index.js +367 -0
- package/dist/src/memory/indexer.d.ts +123 -0
- package/dist/src/memory/indexer.js +479 -0
- package/dist/src/memory/procedural.d.ts +136 -0
- package/dist/src/memory/procedural.js +479 -0
- package/dist/src/memory/semantic.d.ts +132 -0
- package/dist/src/memory/semantic.js +497 -0
- package/dist/src/memory/types.d.ts +193 -0
- package/dist/src/memory/types.js +15 -0
- package/dist/src/orchestrator.d.ts +65 -0
- package/dist/src/orchestrator.js +317 -0
- package/dist/src/persistence/index.d.ts +257 -0
- package/dist/src/persistence/index.js +763 -0
- package/dist/src/pipeline/executor.d.ts +51 -0
- package/dist/src/pipeline/executor.js +695 -0
- package/dist/src/pipeline/index.d.ts +7 -0
- package/dist/src/pipeline/index.js +11 -0
- package/dist/src/self-production.d.ts +67 -0
- package/dist/src/self-production.js +205 -0
- package/dist/src/subagents/executor.d.ts +58 -0
- package/dist/src/subagents/executor.js +283 -0
- package/dist/src/subagents/index.d.ts +37 -0
- package/dist/src/subagents/index.js +53 -0
- package/dist/src/subagents/registry.d.ts +23 -0
- package/dist/src/subagents/registry.js +167 -0
- package/dist/src/subagents/types.d.ts +79 -0
- package/dist/src/subagents/types.js +14 -0
- package/dist/src/tools/bash.d.ts +139 -0
- package/dist/src/tools/bash.js +583 -0
- package/dist/src/tools/edit.d.ts +125 -0
- package/dist/src/tools/edit.js +424 -0
- package/dist/src/tools/git.d.ts +179 -0
- package/dist/src/tools/git.js +504 -0
- package/dist/src/tools/index.d.ts +21 -0
- package/dist/src/tools/index.js +163 -0
- package/dist/src/types.d.ts +145 -0
- package/dist/src/types.js +7 -0
- package/dist/src/world-model/decoder.d.ts +163 -0
- package/dist/src/world-model/decoder.js +517 -0
- package/dist/src/world-model/digital-twin.d.ts +219 -0
- package/dist/src/world-model/digital-twin.js +695 -0
- package/dist/src/world-model/encoder.d.ts +141 -0
- package/dist/src/world-model/encoder.js +564 -0
- package/dist/src/world-model/index.d.ts +221 -0
- package/dist/src/world-model/index.js +772 -0
- package/dist/src/world-model/predictor.d.ts +161 -0
- package/dist/src/world-model/predictor.js +681 -0
- package/dist/src/world-model/test-value-jepa.d.ts +8 -0
- package/dist/src/world-model/test-value-jepa.js +430 -0
- package/dist/src/world-model/types.d.ts +341 -0
- package/dist/src/world-model/types.js +69 -0
- package/dist/src/world-model/value-jepa.d.ts +247 -0
- package/dist/src/world-model/value-jepa.js +622 -0
- package/dist/test/brain.test.d.ts +11 -0
- package/dist/test/brain.test.js +358 -0
- package/dist/test/cli/dispatcher.test.d.ts +4 -0
- package/dist/test/cli/dispatcher.test.js +332 -0
- package/dist/test/cli/human-loop.test.d.ts +4 -0
- package/dist/test/cli/human-loop.test.js +270 -0
- package/dist/test/grounding/feedback.test.d.ts +4 -0
- package/dist/test/grounding/feedback.test.js +462 -0
- package/dist/test/grounding/verifier.test.d.ts +4 -0
- package/dist/test/grounding/verifier.test.js +442 -0
- package/dist/test/grounding.test.d.ts +6 -0
- package/dist/test/grounding.test.js +246 -0
- package/dist/test/healing/detector.test.d.ts +4 -0
- package/dist/test/healing/detector.test.js +266 -0
- package/dist/test/healing/fixer.test.d.ts +4 -0
- package/dist/test/healing/fixer.test.js +369 -0
- package/dist/test/integration.test.d.ts +5 -0
- package/dist/test/integration.test.js +290 -0
- package/dist/test/tools/bash.test.d.ts +4 -0
- package/dist/test/tools/bash.test.js +348 -0
- package/dist/test/tools/edit.test.d.ts +4 -0
- package/dist/test/tools/edit.test.js +350 -0
- package/dist/test/tools/git.test.d.ts +4 -0
- package/dist/test/tools/git.test.js +350 -0
- package/package.json +60 -0
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Tests for Genesis Grounding Verifier
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
const node_test_1 = require("node:test");
|
|
43
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
44
|
+
const fs = __importStar(require("fs"));
|
|
45
|
+
const path = __importStar(require("path"));
|
|
46
|
+
const verifier_js_1 = require("../../src/grounding/verifier.js");
|
|
47
|
+
// Test directory
|
|
48
|
+
const TEST_DIR = '/tmp/genesis-verifier-test-' + Date.now();
|
|
49
|
+
(0, node_test_1.describe)('Verifier', () => {
|
|
50
|
+
(0, node_test_1.before)(() => {
|
|
51
|
+
fs.mkdirSync(TEST_DIR, { recursive: true });
|
|
52
|
+
(0, verifier_js_1.resetVerifier)();
|
|
53
|
+
});
|
|
54
|
+
(0, node_test_1.after)(() => {
|
|
55
|
+
fs.rmSync(TEST_DIR, { recursive: true, force: true });
|
|
56
|
+
(0, verifier_js_1.resetVerifier)();
|
|
57
|
+
});
|
|
58
|
+
(0, node_test_1.beforeEach)(() => {
|
|
59
|
+
// Clean test directory
|
|
60
|
+
const files = fs.readdirSync(TEST_DIR);
|
|
61
|
+
for (const file of files) {
|
|
62
|
+
fs.rmSync(path.join(TEST_DIR, file), { force: true, recursive: true });
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
// ==========================================================================
|
|
66
|
+
// Basic Verification Tests
|
|
67
|
+
// ==========================================================================
|
|
68
|
+
(0, node_test_1.describe)('Basic Verification', () => {
|
|
69
|
+
(0, node_test_1.it)('should verify valid TypeScript code', async () => {
|
|
70
|
+
// Create a simple valid TS file
|
|
71
|
+
fs.writeFileSync(path.join(TEST_DIR, 'valid.ts'), `
|
|
72
|
+
export function add(a: number, b: number): number {
|
|
73
|
+
return a + b;
|
|
74
|
+
}
|
|
75
|
+
`);
|
|
76
|
+
// Create minimal package.json
|
|
77
|
+
fs.writeFileSync(path.join(TEST_DIR, 'package.json'), JSON.stringify({
|
|
78
|
+
name: 'test',
|
|
79
|
+
type: 'module',
|
|
80
|
+
scripts: {
|
|
81
|
+
build: 'echo "build ok"',
|
|
82
|
+
test: 'echo "test ok"',
|
|
83
|
+
},
|
|
84
|
+
}));
|
|
85
|
+
// Create tsconfig.json
|
|
86
|
+
fs.writeFileSync(path.join(TEST_DIR, 'tsconfig.json'), JSON.stringify({
|
|
87
|
+
compilerOptions: {
|
|
88
|
+
target: 'ES2022',
|
|
89
|
+
module: 'NodeNext',
|
|
90
|
+
strict: true,
|
|
91
|
+
noEmit: true,
|
|
92
|
+
},
|
|
93
|
+
include: ['*.ts'],
|
|
94
|
+
}));
|
|
95
|
+
const result = await (0, verifier_js_1.verifyCode)({
|
|
96
|
+
workingDirectory: TEST_DIR,
|
|
97
|
+
buildCommand: 'echo "build ok"',
|
|
98
|
+
testCommand: 'echo "test ok"',
|
|
99
|
+
timeout: 30000,
|
|
100
|
+
});
|
|
101
|
+
node_assert_1.default.ok(result.compiles);
|
|
102
|
+
node_assert_1.default.ok(result.typesValid);
|
|
103
|
+
});
|
|
104
|
+
(0, node_test_1.it)('should detect type errors', async () => {
|
|
105
|
+
// Create TS file with type error
|
|
106
|
+
fs.writeFileSync(path.join(TEST_DIR, 'invalid.ts'), `
|
|
107
|
+
const x: number = "not a number";
|
|
108
|
+
`);
|
|
109
|
+
fs.writeFileSync(path.join(TEST_DIR, 'tsconfig.json'), JSON.stringify({
|
|
110
|
+
compilerOptions: {
|
|
111
|
+
target: 'ES2022',
|
|
112
|
+
module: 'NodeNext',
|
|
113
|
+
strict: true,
|
|
114
|
+
noEmit: true,
|
|
115
|
+
},
|
|
116
|
+
include: ['*.ts'],
|
|
117
|
+
}));
|
|
118
|
+
const result = await (0, verifier_js_1.verifyCode)({
|
|
119
|
+
workingDirectory: TEST_DIR,
|
|
120
|
+
buildCommand: 'echo "skip"',
|
|
121
|
+
testCommand: 'echo "skip"',
|
|
122
|
+
timeout: 30000,
|
|
123
|
+
});
|
|
124
|
+
node_assert_1.default.strictEqual(result.typesValid, false);
|
|
125
|
+
node_assert_1.default.ok(result.issues.some(i => i.type === 'type'));
|
|
126
|
+
});
|
|
127
|
+
(0, node_test_1.it)('should detect build failures', async () => {
|
|
128
|
+
fs.writeFileSync(path.join(TEST_DIR, 'package.json'), JSON.stringify({
|
|
129
|
+
name: 'test',
|
|
130
|
+
scripts: { build: 'exit 1' },
|
|
131
|
+
}));
|
|
132
|
+
const verifier = new verifier_js_1.Verifier({ skipTypeCheck: true });
|
|
133
|
+
const result = await verifier.verify({
|
|
134
|
+
workingDirectory: TEST_DIR,
|
|
135
|
+
buildCommand: 'exit 1',
|
|
136
|
+
testCommand: 'echo "ok"',
|
|
137
|
+
timeout: 10000,
|
|
138
|
+
});
|
|
139
|
+
node_assert_1.default.strictEqual(result.compiles, false);
|
|
140
|
+
node_assert_1.default.ok(result.issues.some(i => i.type === 'compile'));
|
|
141
|
+
});
|
|
142
|
+
(0, node_test_1.it)('should detect test failures', async () => {
|
|
143
|
+
fs.writeFileSync(path.join(TEST_DIR, 'package.json'), JSON.stringify({
|
|
144
|
+
name: 'test',
|
|
145
|
+
scripts: {
|
|
146
|
+
build: 'echo "ok"',
|
|
147
|
+
test: 'exit 1',
|
|
148
|
+
},
|
|
149
|
+
}));
|
|
150
|
+
const verifier = new verifier_js_1.Verifier({ skipTypeCheck: true });
|
|
151
|
+
const result = await verifier.verify({
|
|
152
|
+
workingDirectory: TEST_DIR,
|
|
153
|
+
buildCommand: 'echo "ok"',
|
|
154
|
+
testCommand: 'echo "FAIL test.ts" && exit 1',
|
|
155
|
+
timeout: 10000,
|
|
156
|
+
});
|
|
157
|
+
node_assert_1.default.strictEqual(result.testsPass, false);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
// ==========================================================================
|
|
161
|
+
// Test Output Parsing
|
|
162
|
+
// ==========================================================================
|
|
163
|
+
(0, node_test_1.describe)('Test Output Parsing', () => {
|
|
164
|
+
(0, node_test_1.it)('should parse Node test runner output', async () => {
|
|
165
|
+
const output = `
|
|
166
|
+
✔ test 1 (1ms)
|
|
167
|
+
✔ test 2 (2ms)
|
|
168
|
+
✖ test 3 (3ms)
|
|
169
|
+
ℹ tests 3
|
|
170
|
+
ℹ pass 2
|
|
171
|
+
ℹ fail 1
|
|
172
|
+
`;
|
|
173
|
+
fs.writeFileSync(path.join(TEST_DIR, 'package.json'), JSON.stringify({
|
|
174
|
+
name: 'test',
|
|
175
|
+
scripts: { build: 'echo "ok"', test: `echo "${output}"` },
|
|
176
|
+
}));
|
|
177
|
+
const verifier = new verifier_js_1.Verifier({ skipTypeCheck: true, skipBuild: true });
|
|
178
|
+
const result = await verifier.verify({
|
|
179
|
+
workingDirectory: TEST_DIR,
|
|
180
|
+
testCommand: `printf "${output}"`,
|
|
181
|
+
timeout: 10000,
|
|
182
|
+
});
|
|
183
|
+
node_assert_1.default.strictEqual(result.testsTotal, 3);
|
|
184
|
+
node_assert_1.default.strictEqual(result.testsPassed, 2);
|
|
185
|
+
node_assert_1.default.strictEqual(result.testsFailed, 1);
|
|
186
|
+
});
|
|
187
|
+
(0, node_test_1.it)('should count checkmarks and crosses', async () => {
|
|
188
|
+
const verifier = new verifier_js_1.Verifier({ skipTypeCheck: true, skipBuild: true });
|
|
189
|
+
const result = await verifier.verify({
|
|
190
|
+
workingDirectory: TEST_DIR,
|
|
191
|
+
testCommand: 'echo "✔ pass1\n✔ pass2\n✖ fail1"',
|
|
192
|
+
timeout: 10000,
|
|
193
|
+
});
|
|
194
|
+
// Should count at least some passes and fails
|
|
195
|
+
node_assert_1.default.ok(result.testsPassed >= 2);
|
|
196
|
+
node_assert_1.default.ok(result.testsFailed >= 1);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
// ==========================================================================
|
|
200
|
+
// Configuration Tests
|
|
201
|
+
// ==========================================================================
|
|
202
|
+
(0, node_test_1.describe)('Configuration', () => {
|
|
203
|
+
(0, node_test_1.it)('should use default configuration', () => {
|
|
204
|
+
const verifier = new verifier_js_1.Verifier();
|
|
205
|
+
const config = verifier.getConfig();
|
|
206
|
+
node_assert_1.default.strictEqual(config.buildCommand, 'npm run build');
|
|
207
|
+
node_assert_1.default.strictEqual(config.testCommand, 'npm test');
|
|
208
|
+
node_assert_1.default.strictEqual(config.timeout, 120000);
|
|
209
|
+
});
|
|
210
|
+
(0, node_test_1.it)('should accept custom configuration', () => {
|
|
211
|
+
const verifier = new verifier_js_1.Verifier({
|
|
212
|
+
buildCommand: 'make build',
|
|
213
|
+
testCommand: 'make test',
|
|
214
|
+
timeout: 60000,
|
|
215
|
+
});
|
|
216
|
+
const config = verifier.getConfig();
|
|
217
|
+
node_assert_1.default.strictEqual(config.buildCommand, 'make build');
|
|
218
|
+
node_assert_1.default.strictEqual(config.testCommand, 'make test');
|
|
219
|
+
node_assert_1.default.strictEqual(config.timeout, 60000);
|
|
220
|
+
});
|
|
221
|
+
(0, node_test_1.it)('should update configuration', () => {
|
|
222
|
+
const verifier = (0, verifier_js_1.getVerifier)();
|
|
223
|
+
verifier.updateConfig({ skipLint: false, lintCommand: 'eslint .' });
|
|
224
|
+
const config = verifier.getConfig();
|
|
225
|
+
node_assert_1.default.strictEqual(config.skipLint, false);
|
|
226
|
+
node_assert_1.default.strictEqual(config.lintCommand, 'eslint .');
|
|
227
|
+
});
|
|
228
|
+
(0, node_test_1.it)('should skip steps when configured', async () => {
|
|
229
|
+
const verifier = new verifier_js_1.Verifier({
|
|
230
|
+
skipBuild: true,
|
|
231
|
+
skipTypeCheck: true,
|
|
232
|
+
skipTest: true,
|
|
233
|
+
});
|
|
234
|
+
const result = await verifier.verify({
|
|
235
|
+
workingDirectory: TEST_DIR,
|
|
236
|
+
});
|
|
237
|
+
// Should succeed since all steps are skipped
|
|
238
|
+
node_assert_1.default.ok(result.success);
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
// ==========================================================================
|
|
242
|
+
// Single File Verification
|
|
243
|
+
// ==========================================================================
|
|
244
|
+
(0, node_test_1.describe)('Single File Verification', () => {
|
|
245
|
+
(0, node_test_1.it)('should verify valid file', async () => {
|
|
246
|
+
const filePath = path.join(TEST_DIR, 'single.ts');
|
|
247
|
+
fs.writeFileSync(filePath, 'const x: number = 42;');
|
|
248
|
+
fs.writeFileSync(path.join(TEST_DIR, 'tsconfig.json'), JSON.stringify({
|
|
249
|
+
compilerOptions: { target: 'ES2022', module: 'NodeNext', strict: true, noEmit: true },
|
|
250
|
+
include: ['*.ts'],
|
|
251
|
+
}));
|
|
252
|
+
const verifier = (0, verifier_js_1.getVerifier)();
|
|
253
|
+
const result = await verifier.verifyFile(filePath, TEST_DIR);
|
|
254
|
+
node_assert_1.default.ok(result.valid);
|
|
255
|
+
node_assert_1.default.strictEqual(result.errors.length, 0);
|
|
256
|
+
});
|
|
257
|
+
(0, node_test_1.it)('should detect invalid file', async () => {
|
|
258
|
+
const filePath = path.join(TEST_DIR, 'invalid.ts');
|
|
259
|
+
fs.writeFileSync(filePath, 'const x: number = "string";');
|
|
260
|
+
fs.writeFileSync(path.join(TEST_DIR, 'tsconfig.json'), JSON.stringify({
|
|
261
|
+
compilerOptions: { target: 'ES2022', module: 'NodeNext', strict: true, noEmit: true },
|
|
262
|
+
include: ['*.ts'],
|
|
263
|
+
}));
|
|
264
|
+
const verifier = (0, verifier_js_1.getVerifier)();
|
|
265
|
+
const result = await verifier.verifyFile(filePath, TEST_DIR);
|
|
266
|
+
node_assert_1.default.strictEqual(result.valid, false);
|
|
267
|
+
node_assert_1.default.ok(result.errors.length > 0);
|
|
268
|
+
});
|
|
269
|
+
(0, node_test_1.it)('should handle missing file', async () => {
|
|
270
|
+
const verifier = (0, verifier_js_1.getVerifier)();
|
|
271
|
+
const result = await verifier.verifyFile('/nonexistent/file.ts', TEST_DIR);
|
|
272
|
+
node_assert_1.default.strictEqual(result.valid, false);
|
|
273
|
+
node_assert_1.default.ok(result.errors.some(e => e.message.includes('not found')));
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
// ==========================================================================
|
|
277
|
+
// Semantic Match
|
|
278
|
+
// ==========================================================================
|
|
279
|
+
(0, node_test_1.describe)('Semantic Match', () => {
|
|
280
|
+
(0, node_test_1.it)('should calculate high semantic match for clean code', async () => {
|
|
281
|
+
fs.writeFileSync(path.join(TEST_DIR, 'package.json'), JSON.stringify({
|
|
282
|
+
name: 'test',
|
|
283
|
+
scripts: { build: 'echo "ok"', test: 'echo "ok"' },
|
|
284
|
+
}));
|
|
285
|
+
const verifier = new verifier_js_1.Verifier({ skipTypeCheck: true });
|
|
286
|
+
const result = await verifier.verify({
|
|
287
|
+
workingDirectory: TEST_DIR,
|
|
288
|
+
buildCommand: 'echo "ok"',
|
|
289
|
+
testCommand: 'echo "ok"',
|
|
290
|
+
modifiedFiles: [],
|
|
291
|
+
timeout: 10000,
|
|
292
|
+
});
|
|
293
|
+
node_assert_1.default.ok(result.semanticMatch >= 0.9);
|
|
294
|
+
});
|
|
295
|
+
(0, node_test_1.it)('should reduce semantic match for issues', async () => {
|
|
296
|
+
fs.writeFileSync(path.join(TEST_DIR, 'bad.ts'), 'const x: number = "bad";');
|
|
297
|
+
fs.writeFileSync(path.join(TEST_DIR, 'tsconfig.json'), JSON.stringify({
|
|
298
|
+
compilerOptions: { target: 'ES2022', module: 'NodeNext', strict: true, noEmit: true },
|
|
299
|
+
include: ['*.ts'],
|
|
300
|
+
}));
|
|
301
|
+
const result = await (0, verifier_js_1.verifyCode)({
|
|
302
|
+
workingDirectory: TEST_DIR,
|
|
303
|
+
buildCommand: 'echo "ok"',
|
|
304
|
+
testCommand: 'echo "ok"',
|
|
305
|
+
timeout: 30000,
|
|
306
|
+
});
|
|
307
|
+
node_assert_1.default.ok(result.semanticMatch < 1.0);
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
// ==========================================================================
|
|
311
|
+
// Formatting
|
|
312
|
+
// ==========================================================================
|
|
313
|
+
(0, node_test_1.describe)('Formatting', () => {
|
|
314
|
+
(0, node_test_1.it)('should format success result', () => {
|
|
315
|
+
const result = {
|
|
316
|
+
success: true,
|
|
317
|
+
compiles: true,
|
|
318
|
+
typesValid: true,
|
|
319
|
+
testsPass: true,
|
|
320
|
+
testsPassed: 10,
|
|
321
|
+
testsFailed: 0,
|
|
322
|
+
testsTotal: 10,
|
|
323
|
+
lintPass: true,
|
|
324
|
+
semanticMatch: 0.95,
|
|
325
|
+
issues: [],
|
|
326
|
+
duration: 1234,
|
|
327
|
+
outputs: {},
|
|
328
|
+
};
|
|
329
|
+
const formatted = (0, verifier_js_1.formatVerificationResult)(result);
|
|
330
|
+
node_assert_1.default.ok(formatted.includes('PASSED'));
|
|
331
|
+
node_assert_1.default.ok(formatted.includes('✓'));
|
|
332
|
+
node_assert_1.default.ok(formatted.includes('10/10'));
|
|
333
|
+
});
|
|
334
|
+
(0, node_test_1.it)('should format failure result with issues', () => {
|
|
335
|
+
const result = {
|
|
336
|
+
success: false,
|
|
337
|
+
compiles: false,
|
|
338
|
+
typesValid: false,
|
|
339
|
+
testsPass: false,
|
|
340
|
+
testsPassed: 3,
|
|
341
|
+
testsFailed: 2,
|
|
342
|
+
testsTotal: 5,
|
|
343
|
+
lintPass: true,
|
|
344
|
+
semanticMatch: 0.5,
|
|
345
|
+
issues: [
|
|
346
|
+
{ type: 'type', severity: 'error', message: 'Type mismatch', file: 'test.ts', line: 10 },
|
|
347
|
+
{ type: 'test', severity: 'error', message: 'Test failed' },
|
|
348
|
+
],
|
|
349
|
+
duration: 2000,
|
|
350
|
+
outputs: {},
|
|
351
|
+
};
|
|
352
|
+
const formatted = (0, verifier_js_1.formatVerificationResult)(result);
|
|
353
|
+
node_assert_1.default.ok(formatted.includes('FAILED'));
|
|
354
|
+
node_assert_1.default.ok(formatted.includes('✗'));
|
|
355
|
+
node_assert_1.default.ok(formatted.includes('Type mismatch'));
|
|
356
|
+
node_assert_1.default.ok(formatted.includes('Test failed'));
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
// ==========================================================================
|
|
360
|
+
// Convenience Functions
|
|
361
|
+
// ==========================================================================
|
|
362
|
+
(0, node_test_1.describe)('Convenience Functions', () => {
|
|
363
|
+
(0, node_test_1.it)('isCodeValid should return boolean', async () => {
|
|
364
|
+
fs.writeFileSync(path.join(TEST_DIR, 'package.json'), JSON.stringify({
|
|
365
|
+
name: 'test',
|
|
366
|
+
scripts: { build: 'echo "ok"', test: 'echo "ok"' },
|
|
367
|
+
}));
|
|
368
|
+
// Skip type check for this simple test
|
|
369
|
+
(0, verifier_js_1.resetVerifier)();
|
|
370
|
+
const verifier = (0, verifier_js_1.getVerifier)({ skipTypeCheck: true });
|
|
371
|
+
const valid = await (0, verifier_js_1.isCodeValid)(TEST_DIR);
|
|
372
|
+
node_assert_1.default.strictEqual(typeof valid, 'boolean');
|
|
373
|
+
});
|
|
374
|
+
(0, node_test_1.it)('quickVerify should skip heavy operations', async () => {
|
|
375
|
+
fs.writeFileSync(path.join(TEST_DIR, 'package.json'), JSON.stringify({
|
|
376
|
+
name: 'test',
|
|
377
|
+
scripts: { build: 'sleep 10', test: 'sleep 10' },
|
|
378
|
+
}));
|
|
379
|
+
const startTime = Date.now();
|
|
380
|
+
const result = await (0, verifier_js_1.quickVerify)({
|
|
381
|
+
workingDirectory: TEST_DIR,
|
|
382
|
+
timeout: 5000,
|
|
383
|
+
});
|
|
384
|
+
const duration = Date.now() - startTime;
|
|
385
|
+
// Should be fast because we skip build and test
|
|
386
|
+
node_assert_1.default.ok(duration < 10000);
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
// ==========================================================================
|
|
390
|
+
// Edge Cases
|
|
391
|
+
// ==========================================================================
|
|
392
|
+
(0, node_test_1.describe)('Edge Cases', () => {
|
|
393
|
+
(0, node_test_1.it)('should handle empty directory', async () => {
|
|
394
|
+
const verifier = new verifier_js_1.Verifier({ skipTypeCheck: true });
|
|
395
|
+
const result = await verifier.verify({
|
|
396
|
+
workingDirectory: TEST_DIR,
|
|
397
|
+
buildCommand: 'echo "ok"',
|
|
398
|
+
testCommand: 'echo "ok"',
|
|
399
|
+
timeout: 10000,
|
|
400
|
+
});
|
|
401
|
+
// Should succeed with skipped type check
|
|
402
|
+
node_assert_1.default.ok(result.success);
|
|
403
|
+
});
|
|
404
|
+
(0, node_test_1.it)('should handle command timeout', async () => {
|
|
405
|
+
const verifier = new verifier_js_1.Verifier({ skipTypeCheck: true });
|
|
406
|
+
try {
|
|
407
|
+
await verifier.verify({
|
|
408
|
+
workingDirectory: TEST_DIR,
|
|
409
|
+
buildCommand: 'sleep 30',
|
|
410
|
+
timeout: 100, // Very short timeout
|
|
411
|
+
});
|
|
412
|
+
// Should have thrown or failed
|
|
413
|
+
}
|
|
414
|
+
catch {
|
|
415
|
+
// Expected to fail
|
|
416
|
+
node_assert_1.default.ok(true);
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
(0, node_test_1.it)('should handle concurrent verifications', async () => {
|
|
420
|
+
fs.writeFileSync(path.join(TEST_DIR, 'package.json'), JSON.stringify({
|
|
421
|
+
name: 'test',
|
|
422
|
+
scripts: { build: 'echo "ok"', test: 'echo "ok"' },
|
|
423
|
+
}));
|
|
424
|
+
const verifier = new verifier_js_1.Verifier({ skipTypeCheck: true });
|
|
425
|
+
const results = await Promise.all([
|
|
426
|
+
verifier.verify({
|
|
427
|
+
workingDirectory: TEST_DIR,
|
|
428
|
+
buildCommand: 'echo "1"',
|
|
429
|
+
testCommand: 'echo "1"',
|
|
430
|
+
timeout: 10000,
|
|
431
|
+
}),
|
|
432
|
+
verifier.verify({
|
|
433
|
+
workingDirectory: TEST_DIR,
|
|
434
|
+
buildCommand: 'echo "2"',
|
|
435
|
+
testCommand: 'echo "2"',
|
|
436
|
+
timeout: 10000,
|
|
437
|
+
}),
|
|
438
|
+
]);
|
|
439
|
+
node_assert_1.default.strictEqual(results.length, 2);
|
|
440
|
+
});
|
|
441
|
+
});
|
|
442
|
+
});
|