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.
Files changed (227) hide show
  1. package/.env.example +78 -0
  2. package/README.md +282 -0
  3. package/dist/src/active-inference/actions.d.ts +75 -0
  4. package/dist/src/active-inference/actions.js +250 -0
  5. package/dist/src/active-inference/autonomous-loop.d.ts +103 -0
  6. package/dist/src/active-inference/autonomous-loop.js +289 -0
  7. package/dist/src/active-inference/core.d.ts +85 -0
  8. package/dist/src/active-inference/core.js +555 -0
  9. package/dist/src/active-inference/demo-autonomous-loop.d.ts +8 -0
  10. package/dist/src/active-inference/demo-autonomous-loop.js +338 -0
  11. package/dist/src/active-inference/demo-value-integration.d.ts +8 -0
  12. package/dist/src/active-inference/demo-value-integration.js +174 -0
  13. package/dist/src/active-inference/index.d.ts +32 -0
  14. package/dist/src/active-inference/index.js +88 -0
  15. package/dist/src/active-inference/integration.d.ts +114 -0
  16. package/dist/src/active-inference/integration.js +698 -0
  17. package/dist/src/active-inference/memory-integration.d.ts +51 -0
  18. package/dist/src/active-inference/memory-integration.js +232 -0
  19. package/dist/src/active-inference/observations.d.ts +67 -0
  20. package/dist/src/active-inference/observations.js +147 -0
  21. package/dist/src/active-inference/test-active-inference.d.ts +8 -0
  22. package/dist/src/active-inference/test-active-inference.js +320 -0
  23. package/dist/src/active-inference/test-value-integration.d.ts +6 -0
  24. package/dist/src/active-inference/test-value-integration.js +168 -0
  25. package/dist/src/active-inference/types.d.ts +150 -0
  26. package/dist/src/active-inference/types.js +59 -0
  27. package/dist/src/active-inference/value-integration.d.ts +164 -0
  28. package/dist/src/active-inference/value-integration.js +459 -0
  29. package/dist/src/agents/base-agent.d.ts +53 -0
  30. package/dist/src/agents/base-agent.js +178 -0
  31. package/dist/src/agents/builder.d.ts +67 -0
  32. package/dist/src/agents/builder.js +537 -0
  33. package/dist/src/agents/critic.d.ts +35 -0
  34. package/dist/src/agents/critic.js +322 -0
  35. package/dist/src/agents/ethicist.d.ts +54 -0
  36. package/dist/src/agents/ethicist.js +393 -0
  37. package/dist/src/agents/explorer.d.ts +26 -0
  38. package/dist/src/agents/explorer.js +216 -0
  39. package/dist/src/agents/feeling.d.ts +41 -0
  40. package/dist/src/agents/feeling.js +320 -0
  41. package/dist/src/agents/index.d.ts +111 -0
  42. package/dist/src/agents/index.js +222 -0
  43. package/dist/src/agents/memory.d.ts +69 -0
  44. package/dist/src/agents/memory.js +404 -0
  45. package/dist/src/agents/message-bus.d.ts +88 -0
  46. package/dist/src/agents/message-bus.js +267 -0
  47. package/dist/src/agents/narrator.d.ts +90 -0
  48. package/dist/src/agents/narrator.js +473 -0
  49. package/dist/src/agents/planner.d.ts +38 -0
  50. package/dist/src/agents/planner.js +341 -0
  51. package/dist/src/agents/predictor.d.ts +73 -0
  52. package/dist/src/agents/predictor.js +506 -0
  53. package/dist/src/agents/sensor.d.ts +88 -0
  54. package/dist/src/agents/sensor.js +377 -0
  55. package/dist/src/agents/test-agents.d.ts +6 -0
  56. package/dist/src/agents/test-agents.js +73 -0
  57. package/dist/src/agents/types.d.ts +194 -0
  58. package/dist/src/agents/types.js +7 -0
  59. package/dist/src/brain/index.d.ts +185 -0
  60. package/dist/src/brain/index.js +843 -0
  61. package/dist/src/brain/trace.d.ts +91 -0
  62. package/dist/src/brain/trace.js +327 -0
  63. package/dist/src/brain/types.d.ts +165 -0
  64. package/dist/src/brain/types.js +51 -0
  65. package/dist/src/cli/chat.d.ts +237 -0
  66. package/dist/src/cli/chat.js +1959 -0
  67. package/dist/src/cli/dispatcher.d.ts +182 -0
  68. package/dist/src/cli/dispatcher.js +718 -0
  69. package/dist/src/cli/human-loop.d.ts +170 -0
  70. package/dist/src/cli/human-loop.js +543 -0
  71. package/dist/src/cli/index.d.ts +12 -0
  72. package/dist/src/cli/index.js +28 -0
  73. package/dist/src/cli/interactive.d.ts +141 -0
  74. package/dist/src/cli/interactive.js +757 -0
  75. package/dist/src/cli/ui.d.ts +205 -0
  76. package/dist/src/cli/ui.js +632 -0
  77. package/dist/src/consciousness/attention-schema.d.ts +154 -0
  78. package/dist/src/consciousness/attention-schema.js +432 -0
  79. package/dist/src/consciousness/global-workspace.d.ts +149 -0
  80. package/dist/src/consciousness/global-workspace.js +422 -0
  81. package/dist/src/consciousness/index.d.ts +186 -0
  82. package/dist/src/consciousness/index.js +476 -0
  83. package/dist/src/consciousness/phi-calculator.d.ts +119 -0
  84. package/dist/src/consciousness/phi-calculator.js +445 -0
  85. package/dist/src/consciousness/phi-decisions.d.ts +169 -0
  86. package/dist/src/consciousness/phi-decisions.js +383 -0
  87. package/dist/src/consciousness/phi-monitor.d.ts +153 -0
  88. package/dist/src/consciousness/phi-monitor.js +465 -0
  89. package/dist/src/consciousness/types.d.ts +260 -0
  90. package/dist/src/consciousness/types.js +44 -0
  91. package/dist/src/daemon/dream-mode.d.ts +115 -0
  92. package/dist/src/daemon/dream-mode.js +470 -0
  93. package/dist/src/daemon/index.d.ts +162 -0
  94. package/dist/src/daemon/index.js +542 -0
  95. package/dist/src/daemon/maintenance.d.ts +139 -0
  96. package/dist/src/daemon/maintenance.js +549 -0
  97. package/dist/src/daemon/process.d.ts +82 -0
  98. package/dist/src/daemon/process.js +442 -0
  99. package/dist/src/daemon/scheduler.d.ts +90 -0
  100. package/dist/src/daemon/scheduler.js +494 -0
  101. package/dist/src/daemon/types.d.ts +213 -0
  102. package/dist/src/daemon/types.js +50 -0
  103. package/dist/src/epistemic/index.d.ts +74 -0
  104. package/dist/src/epistemic/index.js +225 -0
  105. package/dist/src/grounding/epistemic-stack.d.ts +100 -0
  106. package/dist/src/grounding/epistemic-stack.js +408 -0
  107. package/dist/src/grounding/feedback.d.ts +98 -0
  108. package/dist/src/grounding/feedback.js +276 -0
  109. package/dist/src/grounding/index.d.ts +123 -0
  110. package/dist/src/grounding/index.js +224 -0
  111. package/dist/src/grounding/verifier.d.ts +149 -0
  112. package/dist/src/grounding/verifier.js +484 -0
  113. package/dist/src/healing/detector.d.ts +110 -0
  114. package/dist/src/healing/detector.js +436 -0
  115. package/dist/src/healing/fixer.d.ts +138 -0
  116. package/dist/src/healing/fixer.js +572 -0
  117. package/dist/src/healing/index.d.ts +23 -0
  118. package/dist/src/healing/index.js +43 -0
  119. package/dist/src/hooks/index.d.ts +135 -0
  120. package/dist/src/hooks/index.js +317 -0
  121. package/dist/src/index.d.ts +23 -0
  122. package/dist/src/index.js +1266 -0
  123. package/dist/src/kernel/index.d.ts +155 -0
  124. package/dist/src/kernel/index.js +795 -0
  125. package/dist/src/kernel/invariants.d.ts +153 -0
  126. package/dist/src/kernel/invariants.js +355 -0
  127. package/dist/src/kernel/test-kernel.d.ts +6 -0
  128. package/dist/src/kernel/test-kernel.js +108 -0
  129. package/dist/src/kernel/test-real-mcp.d.ts +10 -0
  130. package/dist/src/kernel/test-real-mcp.js +295 -0
  131. package/dist/src/llm/index.d.ts +146 -0
  132. package/dist/src/llm/index.js +428 -0
  133. package/dist/src/llm/router.d.ts +136 -0
  134. package/dist/src/llm/router.js +510 -0
  135. package/dist/src/mcp/index.d.ts +85 -0
  136. package/dist/src/mcp/index.js +657 -0
  137. package/dist/src/mcp/resilient.d.ts +139 -0
  138. package/dist/src/mcp/resilient.js +417 -0
  139. package/dist/src/memory/cache.d.ts +118 -0
  140. package/dist/src/memory/cache.js +356 -0
  141. package/dist/src/memory/cognitive-workspace.d.ts +231 -0
  142. package/dist/src/memory/cognitive-workspace.js +521 -0
  143. package/dist/src/memory/consolidation.d.ts +99 -0
  144. package/dist/src/memory/consolidation.js +443 -0
  145. package/dist/src/memory/episodic.d.ts +114 -0
  146. package/dist/src/memory/episodic.js +394 -0
  147. package/dist/src/memory/forgetting.d.ts +134 -0
  148. package/dist/src/memory/forgetting.js +324 -0
  149. package/dist/src/memory/index.d.ts +211 -0
  150. package/dist/src/memory/index.js +367 -0
  151. package/dist/src/memory/indexer.d.ts +123 -0
  152. package/dist/src/memory/indexer.js +479 -0
  153. package/dist/src/memory/procedural.d.ts +136 -0
  154. package/dist/src/memory/procedural.js +479 -0
  155. package/dist/src/memory/semantic.d.ts +132 -0
  156. package/dist/src/memory/semantic.js +497 -0
  157. package/dist/src/memory/types.d.ts +193 -0
  158. package/dist/src/memory/types.js +15 -0
  159. package/dist/src/orchestrator.d.ts +65 -0
  160. package/dist/src/orchestrator.js +317 -0
  161. package/dist/src/persistence/index.d.ts +257 -0
  162. package/dist/src/persistence/index.js +763 -0
  163. package/dist/src/pipeline/executor.d.ts +51 -0
  164. package/dist/src/pipeline/executor.js +695 -0
  165. package/dist/src/pipeline/index.d.ts +7 -0
  166. package/dist/src/pipeline/index.js +11 -0
  167. package/dist/src/self-production.d.ts +67 -0
  168. package/dist/src/self-production.js +205 -0
  169. package/dist/src/subagents/executor.d.ts +58 -0
  170. package/dist/src/subagents/executor.js +283 -0
  171. package/dist/src/subagents/index.d.ts +37 -0
  172. package/dist/src/subagents/index.js +53 -0
  173. package/dist/src/subagents/registry.d.ts +23 -0
  174. package/dist/src/subagents/registry.js +167 -0
  175. package/dist/src/subagents/types.d.ts +79 -0
  176. package/dist/src/subagents/types.js +14 -0
  177. package/dist/src/tools/bash.d.ts +139 -0
  178. package/dist/src/tools/bash.js +583 -0
  179. package/dist/src/tools/edit.d.ts +125 -0
  180. package/dist/src/tools/edit.js +424 -0
  181. package/dist/src/tools/git.d.ts +179 -0
  182. package/dist/src/tools/git.js +504 -0
  183. package/dist/src/tools/index.d.ts +21 -0
  184. package/dist/src/tools/index.js +163 -0
  185. package/dist/src/types.d.ts +145 -0
  186. package/dist/src/types.js +7 -0
  187. package/dist/src/world-model/decoder.d.ts +163 -0
  188. package/dist/src/world-model/decoder.js +517 -0
  189. package/dist/src/world-model/digital-twin.d.ts +219 -0
  190. package/dist/src/world-model/digital-twin.js +695 -0
  191. package/dist/src/world-model/encoder.d.ts +141 -0
  192. package/dist/src/world-model/encoder.js +564 -0
  193. package/dist/src/world-model/index.d.ts +221 -0
  194. package/dist/src/world-model/index.js +772 -0
  195. package/dist/src/world-model/predictor.d.ts +161 -0
  196. package/dist/src/world-model/predictor.js +681 -0
  197. package/dist/src/world-model/test-value-jepa.d.ts +8 -0
  198. package/dist/src/world-model/test-value-jepa.js +430 -0
  199. package/dist/src/world-model/types.d.ts +341 -0
  200. package/dist/src/world-model/types.js +69 -0
  201. package/dist/src/world-model/value-jepa.d.ts +247 -0
  202. package/dist/src/world-model/value-jepa.js +622 -0
  203. package/dist/test/brain.test.d.ts +11 -0
  204. package/dist/test/brain.test.js +358 -0
  205. package/dist/test/cli/dispatcher.test.d.ts +4 -0
  206. package/dist/test/cli/dispatcher.test.js +332 -0
  207. package/dist/test/cli/human-loop.test.d.ts +4 -0
  208. package/dist/test/cli/human-loop.test.js +270 -0
  209. package/dist/test/grounding/feedback.test.d.ts +4 -0
  210. package/dist/test/grounding/feedback.test.js +462 -0
  211. package/dist/test/grounding/verifier.test.d.ts +4 -0
  212. package/dist/test/grounding/verifier.test.js +442 -0
  213. package/dist/test/grounding.test.d.ts +6 -0
  214. package/dist/test/grounding.test.js +246 -0
  215. package/dist/test/healing/detector.test.d.ts +4 -0
  216. package/dist/test/healing/detector.test.js +266 -0
  217. package/dist/test/healing/fixer.test.d.ts +4 -0
  218. package/dist/test/healing/fixer.test.js +369 -0
  219. package/dist/test/integration.test.d.ts +5 -0
  220. package/dist/test/integration.test.js +290 -0
  221. package/dist/test/tools/bash.test.d.ts +4 -0
  222. package/dist/test/tools/bash.test.js +348 -0
  223. package/dist/test/tools/edit.test.d.ts +4 -0
  224. package/dist/test/tools/edit.test.js +350 -0
  225. package/dist/test/tools/git.test.d.ts +4 -0
  226. package/dist/test/tools/git.test.js +350 -0
  227. package/package.json +60 -0
@@ -0,0 +1,462 @@
1
+ "use strict";
2
+ /**
3
+ * Tests for Genesis Grounding Feedback Loop
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 feedback_js_1 = require("../../src/grounding/feedback.js");
47
+ const verifier_js_1 = require("../../src/grounding/verifier.js");
48
+ const fixer_js_1 = require("../../src/healing/fixer.js");
49
+ // Test directory
50
+ const TEST_DIR = '/tmp/genesis-feedback-test-' + Date.now();
51
+ (0, node_test_1.describe)('FeedbackLoop', () => {
52
+ (0, node_test_1.before)(() => {
53
+ fs.mkdirSync(TEST_DIR, { recursive: true });
54
+ (0, feedback_js_1.resetFeedbackLoop)();
55
+ (0, verifier_js_1.resetVerifier)();
56
+ (0, fixer_js_1.resetAutoFixer)();
57
+ });
58
+ (0, node_test_1.after)(() => {
59
+ fs.rmSync(TEST_DIR, { recursive: true, force: true });
60
+ (0, feedback_js_1.resetFeedbackLoop)();
61
+ (0, verifier_js_1.resetVerifier)();
62
+ (0, fixer_js_1.resetAutoFixer)();
63
+ });
64
+ (0, node_test_1.beforeEach)(() => {
65
+ // Clean test directory
66
+ const files = fs.readdirSync(TEST_DIR);
67
+ for (const file of files) {
68
+ fs.rmSync(path.join(TEST_DIR, file), { force: true, recursive: true });
69
+ }
70
+ (0, feedback_js_1.resetFeedbackLoop)();
71
+ });
72
+ // ==========================================================================
73
+ // Basic Loop Tests
74
+ // ==========================================================================
75
+ (0, node_test_1.describe)('Basic Loop', () => {
76
+ (0, node_test_1.it)('should pass on first iteration if code is valid', async () => {
77
+ fs.writeFileSync(path.join(TEST_DIR, 'package.json'), JSON.stringify({
78
+ name: 'test',
79
+ scripts: { build: 'echo "ok"', test: 'echo "ok"' },
80
+ }));
81
+ const loop = new feedback_js_1.FeedbackLoop({
82
+ maxIterations: 3,
83
+ verificationContext: {
84
+ workingDirectory: TEST_DIR,
85
+ buildCommand: 'echo "ok"',
86
+ testCommand: 'echo "ok"',
87
+ typeCheckCommand: 'echo "ok"',
88
+ },
89
+ enableAutoFix: false,
90
+ });
91
+ const result = await loop.run();
92
+ node_assert_1.default.ok(result.success);
93
+ node_assert_1.default.strictEqual(result.iterations, 1);
94
+ node_assert_1.default.ok(result.history[0].success);
95
+ });
96
+ (0, node_test_1.it)('should track iteration count', async () => {
97
+ fs.writeFileSync(path.join(TEST_DIR, 'package.json'), JSON.stringify({
98
+ name: 'test',
99
+ scripts: { build: 'exit 1' },
100
+ }));
101
+ const loop = new feedback_js_1.FeedbackLoop({
102
+ maxIterations: 3,
103
+ verificationContext: {
104
+ workingDirectory: TEST_DIR,
105
+ buildCommand: 'exit 1',
106
+ testCommand: 'echo "ok"',
107
+ typeCheckCommand: 'echo "ok"',
108
+ },
109
+ enableAutoFix: false,
110
+ });
111
+ const result = await loop.run();
112
+ node_assert_1.default.strictEqual(result.success, false);
113
+ node_assert_1.default.strictEqual(result.iterations, 3);
114
+ });
115
+ (0, node_test_1.it)('should stop on first success when configured', async () => {
116
+ let callCount = 0;
117
+ fs.writeFileSync(path.join(TEST_DIR, 'package.json'), JSON.stringify({
118
+ name: 'test',
119
+ scripts: { build: 'echo "ok"', test: 'echo "ok"' },
120
+ }));
121
+ const loop = new feedback_js_1.FeedbackLoop({
122
+ maxIterations: 5,
123
+ stopOnSuccess: true,
124
+ verificationContext: {
125
+ workingDirectory: TEST_DIR,
126
+ buildCommand: 'echo "ok"',
127
+ testCommand: 'echo "ok"',
128
+ typeCheckCommand: 'echo "ok"',
129
+ },
130
+ enableAutoFix: false,
131
+ });
132
+ const result = await loop.run();
133
+ node_assert_1.default.ok(result.success);
134
+ node_assert_1.default.strictEqual(result.iterations, 1);
135
+ });
136
+ });
137
+ // ==========================================================================
138
+ // Configuration Tests
139
+ // ==========================================================================
140
+ (0, node_test_1.describe)('Configuration', () => {
141
+ (0, node_test_1.it)('should use default configuration', () => {
142
+ const loop = new feedback_js_1.FeedbackLoop();
143
+ const config = loop.getConfig();
144
+ node_assert_1.default.strictEqual(config.maxIterations, 3);
145
+ node_assert_1.default.strictEqual(config.stopOnSuccess, true);
146
+ node_assert_1.default.strictEqual(config.enableAutoFix, true);
147
+ });
148
+ (0, node_test_1.it)('should accept custom configuration', () => {
149
+ const loop = new feedback_js_1.FeedbackLoop({
150
+ maxIterations: 5,
151
+ stopOnSuccess: false,
152
+ enableAutoFix: false,
153
+ verbose: true,
154
+ });
155
+ const config = loop.getConfig();
156
+ node_assert_1.default.strictEqual(config.maxIterations, 5);
157
+ node_assert_1.default.strictEqual(config.stopOnSuccess, false);
158
+ node_assert_1.default.strictEqual(config.enableAutoFix, false);
159
+ node_assert_1.default.strictEqual(config.verbose, true);
160
+ });
161
+ (0, node_test_1.it)('should update configuration', () => {
162
+ const loop = (0, feedback_js_1.getFeedbackLoop)();
163
+ loop.updateConfig({
164
+ maxIterations: 10,
165
+ verificationContext: {
166
+ workingDirectory: TEST_DIR,
167
+ },
168
+ });
169
+ const config = loop.getConfig();
170
+ node_assert_1.default.strictEqual(config.maxIterations, 10);
171
+ });
172
+ });
173
+ // ==========================================================================
174
+ // Verification Only
175
+ // ==========================================================================
176
+ (0, node_test_1.describe)('Verification Only', () => {
177
+ (0, node_test_1.it)('should run verification without feedback loop', async () => {
178
+ fs.writeFileSync(path.join(TEST_DIR, 'package.json'), JSON.stringify({
179
+ name: 'test',
180
+ scripts: { build: 'echo "ok"', test: 'echo "ok"' },
181
+ }));
182
+ const loop = new feedback_js_1.FeedbackLoop({
183
+ verificationContext: {
184
+ workingDirectory: TEST_DIR,
185
+ buildCommand: 'echo "ok"',
186
+ testCommand: 'echo "ok"',
187
+ typeCheckCommand: 'echo "ok"',
188
+ },
189
+ });
190
+ const result = await loop.verifyOnly();
191
+ node_assert_1.default.ok(result.compiles);
192
+ node_assert_1.default.ok(result.typesValid);
193
+ node_assert_1.default.ok(result.testsPass);
194
+ });
195
+ });
196
+ // ==========================================================================
197
+ // History Tracking
198
+ // ==========================================================================
199
+ (0, node_test_1.describe)('History Tracking', () => {
200
+ (0, node_test_1.it)('should record all iterations', async () => {
201
+ fs.writeFileSync(path.join(TEST_DIR, 'package.json'), JSON.stringify({
202
+ name: 'test',
203
+ scripts: { build: 'exit 1' },
204
+ }));
205
+ const loop = new feedback_js_1.FeedbackLoop({
206
+ maxIterations: 3,
207
+ verificationContext: {
208
+ workingDirectory: TEST_DIR,
209
+ buildCommand: 'exit 1',
210
+ testCommand: 'echo "ok"',
211
+ typeCheckCommand: 'echo "ok"',
212
+ },
213
+ enableAutoFix: false,
214
+ });
215
+ const result = await loop.run();
216
+ node_assert_1.default.strictEqual(result.history.length, 3);
217
+ for (let i = 0; i < result.history.length; i++) {
218
+ node_assert_1.default.strictEqual(result.history[i].iteration, i + 1);
219
+ node_assert_1.default.ok(result.history[i].duration >= 0);
220
+ node_assert_1.default.ok(result.history[i].verification);
221
+ }
222
+ });
223
+ (0, node_test_1.it)('should include fix results when auto-fix is enabled', async () => {
224
+ fs.writeFileSync(path.join(TEST_DIR, 'package.json'), JSON.stringify({
225
+ name: 'test',
226
+ scripts: { build: 'exit 1' },
227
+ }));
228
+ const loop = new feedback_js_1.FeedbackLoop({
229
+ maxIterations: 2,
230
+ verificationContext: {
231
+ workingDirectory: TEST_DIR,
232
+ buildCommand: 'exit 1',
233
+ testCommand: 'echo "ok"',
234
+ typeCheckCommand: 'echo "ok"',
235
+ },
236
+ enableAutoFix: true,
237
+ });
238
+ const result = await loop.run();
239
+ // At least one iteration should have attempted a fix
240
+ node_assert_1.default.ok(result.history.some(h => h.fix !== undefined));
241
+ });
242
+ });
243
+ // ==========================================================================
244
+ // Convenience Functions
245
+ // ==========================================================================
246
+ (0, node_test_1.describe)('Convenience Functions', () => {
247
+ (0, node_test_1.it)('runFeedbackLoop should work', async () => {
248
+ fs.writeFileSync(path.join(TEST_DIR, 'package.json'), JSON.stringify({
249
+ name: 'test',
250
+ scripts: { build: 'echo "ok"', test: 'echo "ok"' },
251
+ }));
252
+ // Use FeedbackLoop directly since runFeedbackLoop doesn't accept verificationContext
253
+ const loop = new feedback_js_1.FeedbackLoop({
254
+ maxIterations: 1,
255
+ enableAutoFix: false,
256
+ verificationContext: {
257
+ workingDirectory: TEST_DIR,
258
+ buildCommand: 'echo "ok"',
259
+ testCommand: 'echo "ok"',
260
+ typeCheckCommand: 'echo "ok"',
261
+ },
262
+ });
263
+ const result = await loop.run();
264
+ node_assert_1.default.ok(result.success);
265
+ });
266
+ (0, node_test_1.it)('verifyAndFix should work', async () => {
267
+ fs.writeFileSync(path.join(TEST_DIR, 'package.json'), JSON.stringify({
268
+ name: 'test',
269
+ scripts: { build: 'echo "ok"', test: 'echo "ok"' },
270
+ }));
271
+ // Reset and configure
272
+ (0, feedback_js_1.resetFeedbackLoop)();
273
+ const loop = (0, feedback_js_1.getFeedbackLoop)({
274
+ verificationContext: {
275
+ workingDirectory: TEST_DIR,
276
+ buildCommand: 'echo "ok"',
277
+ testCommand: 'echo "ok"',
278
+ typeCheckCommand: 'echo "ok"',
279
+ },
280
+ });
281
+ const result = await (0, feedback_js_1.verifyAndFix)(TEST_DIR, 1);
282
+ node_assert_1.default.ok(typeof result.success === 'boolean');
283
+ });
284
+ (0, node_test_1.it)('isProjectValid should return boolean', async () => {
285
+ fs.writeFileSync(path.join(TEST_DIR, 'package.json'), JSON.stringify({
286
+ name: 'test',
287
+ scripts: { build: 'echo "ok"', test: 'echo "ok"' },
288
+ }));
289
+ (0, feedback_js_1.resetFeedbackLoop)();
290
+ const valid = await (0, feedback_js_1.isProjectValid)(TEST_DIR);
291
+ node_assert_1.default.strictEqual(typeof valid, 'boolean');
292
+ });
293
+ });
294
+ // ==========================================================================
295
+ // Formatting
296
+ // ==========================================================================
297
+ (0, node_test_1.describe)('Formatting', () => {
298
+ (0, node_test_1.it)('should format success result', () => {
299
+ const result = {
300
+ success: true,
301
+ iterations: 1,
302
+ history: [{
303
+ iteration: 1,
304
+ verification: {
305
+ success: true,
306
+ compiles: true,
307
+ typesValid: true,
308
+ testsPass: true,
309
+ testsPassed: 10,
310
+ testsFailed: 0,
311
+ testsTotal: 10,
312
+ lintPass: true,
313
+ semanticMatch: 0.95,
314
+ issues: [],
315
+ duration: 1000,
316
+ outputs: {},
317
+ },
318
+ duration: 1000,
319
+ success: true,
320
+ }],
321
+ finalResult: {
322
+ success: true,
323
+ compiles: true,
324
+ typesValid: true,
325
+ testsPass: true,
326
+ testsPassed: 10,
327
+ testsFailed: 0,
328
+ testsTotal: 10,
329
+ lintPass: true,
330
+ semanticMatch: 0.95,
331
+ issues: [],
332
+ duration: 1000,
333
+ outputs: {},
334
+ },
335
+ totalDuration: 1000,
336
+ summary: 'Verification passed on first attempt (1000ms)',
337
+ };
338
+ const formatted = (0, feedback_js_1.formatFeedbackResult)(result);
339
+ node_assert_1.default.ok(formatted.includes('SUCCESS'));
340
+ node_assert_1.default.ok(formatted.includes('first attempt'));
341
+ });
342
+ (0, node_test_1.it)('should format failure result with history', () => {
343
+ const result = {
344
+ success: false,
345
+ iterations: 3,
346
+ history: [
347
+ {
348
+ iteration: 1,
349
+ verification: {
350
+ success: false,
351
+ compiles: false,
352
+ typesValid: true,
353
+ testsPass: true,
354
+ testsPassed: 0,
355
+ testsFailed: 0,
356
+ testsTotal: 0,
357
+ lintPass: true,
358
+ semanticMatch: 0.5,
359
+ issues: [{ type: 'compile', severity: 'error', message: 'Build failed' }],
360
+ duration: 500,
361
+ outputs: {},
362
+ },
363
+ fix: { success: false, iterations: 1, candidates: [], evaluations: [] },
364
+ duration: 600,
365
+ success: false,
366
+ },
367
+ {
368
+ iteration: 2,
369
+ verification: {
370
+ success: false,
371
+ compiles: false,
372
+ typesValid: true,
373
+ testsPass: true,
374
+ testsPassed: 0,
375
+ testsFailed: 0,
376
+ testsTotal: 0,
377
+ lintPass: true,
378
+ semanticMatch: 0.5,
379
+ issues: [{ type: 'compile', severity: 'error', message: 'Build failed' }],
380
+ duration: 500,
381
+ outputs: {},
382
+ },
383
+ duration: 500,
384
+ success: false,
385
+ },
386
+ {
387
+ iteration: 3,
388
+ verification: {
389
+ success: false,
390
+ compiles: false,
391
+ typesValid: true,
392
+ testsPass: true,
393
+ testsPassed: 0,
394
+ testsFailed: 0,
395
+ testsTotal: 0,
396
+ lintPass: true,
397
+ semanticMatch: 0.5,
398
+ issues: [{ type: 'compile', severity: 'error', message: 'Build failed' }],
399
+ duration: 500,
400
+ outputs: {},
401
+ },
402
+ duration: 500,
403
+ success: false,
404
+ },
405
+ ],
406
+ finalResult: {
407
+ success: false,
408
+ compiles: false,
409
+ typesValid: true,
410
+ testsPass: true,
411
+ testsPassed: 0,
412
+ testsFailed: 0,
413
+ testsTotal: 0,
414
+ lintPass: true,
415
+ semanticMatch: 0.5,
416
+ issues: [{ type: 'compile', severity: 'error', message: 'Build failed' }],
417
+ duration: 500,
418
+ outputs: {},
419
+ },
420
+ totalDuration: 1600,
421
+ summary: 'Verification failed after 3 iterations. 1 issues remaining, 0 fixes attempted (1600ms)',
422
+ };
423
+ const formatted = (0, feedback_js_1.formatFeedbackResult)(result);
424
+ node_assert_1.default.ok(formatted.includes('FAILED'));
425
+ node_assert_1.default.ok(formatted.includes('3 iterations'));
426
+ node_assert_1.default.ok(formatted.includes('Iteration History'));
427
+ node_assert_1.default.ok(formatted.includes('Remaining Issues'));
428
+ });
429
+ });
430
+ // ==========================================================================
431
+ // Edge Cases
432
+ // ==========================================================================
433
+ (0, node_test_1.describe)('Edge Cases', () => {
434
+ (0, node_test_1.it)('should handle zero max iterations', async () => {
435
+ const loop = new feedback_js_1.FeedbackLoop({
436
+ maxIterations: 0,
437
+ verificationContext: {
438
+ workingDirectory: TEST_DIR,
439
+ },
440
+ enableAutoFix: false,
441
+ });
442
+ const result = await loop.run();
443
+ node_assert_1.default.strictEqual(result.iterations, 0);
444
+ node_assert_1.default.ok(result.finalResult); // Should still have a final result
445
+ });
446
+ (0, node_test_1.it)('should handle empty working directory', async () => {
447
+ const loop = new feedback_js_1.FeedbackLoop({
448
+ maxIterations: 1,
449
+ verificationContext: {
450
+ workingDirectory: TEST_DIR,
451
+ buildCommand: 'echo "ok"',
452
+ testCommand: 'echo "ok"',
453
+ typeCheckCommand: 'echo "ok"',
454
+ },
455
+ enableAutoFix: false,
456
+ });
457
+ const result = await loop.run();
458
+ // Should complete without crashing
459
+ node_assert_1.default.ok(result.finalResult);
460
+ });
461
+ });
462
+ });
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Tests for Genesis Grounding Verifier
3
+ */
4
+ export {};