@mcoda/codali 0.1.135-codali.42 → 0.1.135-codali.47
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/CHANGELOG.md +56 -0
- package/config/deterministic/node-worker.mjs +15 -2
- package/config/skills/code-implementation/SKILL.md +1 -1
- package/config/skills/planning/SKILL.md +1 -1
- package/config/skills/ui-ux-design/SKILL.md +1 -1
- package/config/skills/webapp-testing/SKILL.md +2 -11
- package/config/skills/webapp-testing/journey-driver.mjs +104 -3
- package/dist/eval/fixtures/ContractReviewProvider.d.ts +5 -0
- package/dist/eval/fixtures/ContractReviewProvider.d.ts.map +1 -1
- package/dist/eval/fixtures/ContractReviewProvider.js +63 -0
- package/dist/eval/fixtures/MixedMediaRecoveryJourney.js +2 -2
- package/dist/eval/fixtures/TerminalRecoveryJourney.js +2 -2
- package/dist/permissions/PermissionGate.js +1 -1
- package/dist/providers/ClaudeCliProvider.d.ts.map +1 -1
- package/dist/providers/ClaudeCliProvider.js +1 -0
- package/dist/providers/CodexCliProvider.d.ts.map +1 -1
- package/dist/providers/CodexCliProvider.js +1 -0
- package/dist/providers/ModelServiceError.d.ts +14 -0
- package/dist/providers/ModelServiceError.d.ts.map +1 -1
- package/dist/providers/ModelServiceError.js +15 -2
- package/dist/providers/OllamaRemoteProvider.d.ts.map +1 -1
- package/dist/providers/OllamaRemoteProvider.js +1 -0
- package/dist/providers/OpenAiCompatibleProvider.d.ts.map +1 -1
- package/dist/providers/OpenAiCompatibleProvider.js +4 -0
- package/dist/providers/ProviderTypes.d.ts +4 -0
- package/dist/providers/ProviderTypes.d.ts.map +1 -1
- package/dist/runtime/AnswerEdits.d.ts +39 -0
- package/dist/runtime/AnswerEdits.d.ts.map +1 -0
- package/dist/runtime/AnswerEdits.js +134 -0
- package/dist/runtime/AnswerVerification.d.ts.map +1 -1
- package/dist/runtime/AnswerVerification.js +4 -2
- package/dist/runtime/AuditGuards.d.ts +41 -0
- package/dist/runtime/AuditGuards.d.ts.map +1 -0
- package/dist/runtime/AuditGuards.js +81 -0
- package/dist/runtime/CompletionReport.d.ts +4 -2
- package/dist/runtime/CompletionReport.d.ts.map +1 -1
- package/dist/runtime/CompletionReport.js +8 -3
- package/dist/runtime/DeliveryDocs.d.ts +21 -0
- package/dist/runtime/DeliveryDocs.d.ts.map +1 -0
- package/dist/runtime/DeliveryDocs.js +148 -0
- package/dist/runtime/FigureCheck.d.ts +61 -2
- package/dist/runtime/FigureCheck.d.ts.map +1 -1
- package/dist/runtime/FigureCheck.js +210 -14
- package/dist/runtime/GatewayRequest.d.ts +13 -0
- package/dist/runtime/GatewayRequest.d.ts.map +1 -1
- package/dist/runtime/GatewayRequest.js +54 -1
- package/dist/runtime/InspectionConvergence.d.ts +4 -0
- package/dist/runtime/InspectionConvergence.d.ts.map +1 -1
- package/dist/runtime/InspectionConvergence.js +24 -1
- package/dist/runtime/NumericProvenance.d.ts +102 -0
- package/dist/runtime/NumericProvenance.d.ts.map +1 -0
- package/dist/runtime/NumericProvenance.js +411 -0
- package/dist/runtime/OutageWait.d.ts +13 -0
- package/dist/runtime/OutageWait.d.ts.map +1 -1
- package/dist/runtime/OutageWait.js +13 -0
- package/dist/runtime/ResearchEvidence.d.ts.map +1 -1
- package/dist/runtime/ResearchEvidence.js +79 -3
- package/dist/runtime/ReviewCoordinator.d.ts +22 -0
- package/dist/runtime/ReviewCoordinator.d.ts.map +1 -1
- package/dist/runtime/ReviewCoordinator.js +201 -24
- package/dist/runtime/SessionController.d.ts +31 -22
- package/dist/runtime/SessionController.d.ts.map +1 -1
- package/dist/runtime/SessionController.js +592 -176
- package/dist/runtime/StructuralEvidence.d.ts +10 -0
- package/dist/runtime/StructuralEvidence.d.ts.map +1 -1
- package/dist/runtime/StructuralEvidence.js +10 -0
- package/dist/runtime/TaskReview.d.ts +10 -0
- package/dist/runtime/TaskReview.d.ts.map +1 -1
- package/dist/runtime/TaskReview.js +14 -1
- package/dist/tools/ToolRegistry.d.ts.map +1 -1
- package/dist/tools/ToolRegistry.js +11 -2
- package/dist/tools/browser/BrowserWorker.js +142 -2
- package/dist/tools/calculation/CalculatorTool.d.ts +1 -1
- package/dist/tools/calculation/CalculatorTool.d.ts.map +1 -1
- package/dist/tools/calculation/CalculatorTool.js +209 -41
- package/dist/tools/deterministic/DeterministicTools.js +1 -1
- package/dist/tools/deterministic/node-worker.cjs +10 -10
- package/dist/tools/shell/AsyncProcess.d.ts +2 -0
- package/dist/tools/shell/AsyncProcess.d.ts.map +1 -1
- package/dist/tools/shell/AsyncProcess.js +32 -5
- package/dist/tools/shell/IsolatedExecutor.d.ts +29 -1
- package/dist/tools/shell/IsolatedExecutor.d.ts.map +1 -1
- package/dist/tools/shell/IsolatedExecutor.js +169 -7
- package/dist/tools/shell/ShellTool.js +1 -1
- package/dist/tools/verification/CodeRunTool.d.ts +19 -0
- package/dist/tools/verification/CodeRunTool.d.ts.map +1 -0
- package/dist/tools/verification/CodeRunTool.js +104 -0
- package/dist/tools/verification/JavaScriptVerificationTool.d.ts.map +1 -1
- package/dist/tools/verification/JavaScriptVerificationTool.js +21 -10
- package/dist/tools/verification/VitestTool.d.ts +27 -0
- package/dist/tools/verification/VitestTool.d.ts.map +1 -1
- package/dist/tools/verification/VitestTool.js +160 -16
- package/package.json +3 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { promises as fs } from "node:fs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
|
+
import { execFileSync } from "node:child_process";
|
|
4
5
|
import os from "node:os";
|
|
5
6
|
import path from "node:path";
|
|
6
7
|
import { createIsolatedExecutor } from "../shell/IsolatedExecutor.js";
|
|
@@ -99,26 +100,160 @@ class _Mark:
|
|
|
99
100
|
mark=_Mark()
|
|
100
101
|
def __getattr__(name): raise AttributeError('pytest.'+name+' is not available in this runner (stand-in provides raises, approx, fail and mark.parametrize); use the standard library')
|
|
101
102
|
`;
|
|
103
|
+
/** Which supplied files are tests. Explicitly listed files are run whatever
|
|
104
|
+
* convention they follow: node's default names (x.test.js, x-test.js, x_test.js,
|
|
105
|
+
* test-x.js, test.js, test/…), test_x.js, a file importing node:test or vitest;
|
|
106
|
+
* Python test_x.py or x_test.py. Cycle 7 lost five runs to test_x.js. */
|
|
107
|
+
export function isTestFile(file, runner) {
|
|
108
|
+
if (runner === "python")
|
|
109
|
+
return /(?:^|\/)(?:test_[^/]+|[^/]+_test)\.py$/.test(file.path);
|
|
110
|
+
const named = /(?:^|\/)(?:[^/]+[._-](?:test|spec)|test[_-][^/]+|test)\.[cm]?[jt]s$|(?:^|\/)tests?\/[^/].*\.[cm]?[jt]s$/.test(file.path);
|
|
111
|
+
// A name alone is not enough: test-fixtures.js or test/helpers.js with no
|
|
112
|
+
// test call would run as one passing file-level "test" (review of .43).
|
|
113
|
+
const declaresTests = /(?:^|[^\w.$])(?:test|it|describe|suite)(?:\.(?:only|skip|todo|each|concurrent|sequential))?\s*\(/m.test(file.content ?? "");
|
|
114
|
+
return declaresTests && (named || (runner === "node" ? /["']node:test["']/ : /["']vitest["']/).test(file.content ?? ""));
|
|
115
|
+
}
|
|
116
|
+
let stdlibModules;
|
|
117
|
+
/** The sandbox interpreter's standard-library module names, computed once.
|
|
118
|
+
* Undefined when Python is unavailable: then nothing is carried for Python. */
|
|
119
|
+
const pythonStdlib = () => {
|
|
120
|
+
if (stdlibModules === undefined) {
|
|
121
|
+
try {
|
|
122
|
+
const names = execFileSync("python3", ["-I", "-c", "import sys;print(' '.join(sorted(sys.stdlib_module_names)))"], { encoding: "utf8", timeout: 5000, stdio: ["ignore", "pipe", "ignore"] });
|
|
123
|
+
stdlibModules = new Set(names.split(/\s+/).filter(Boolean));
|
|
124
|
+
if (!stdlibModules.size)
|
|
125
|
+
stdlibModules = null;
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
stdlibModules = null;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return stdlibModules ?? undefined;
|
|
132
|
+
};
|
|
133
|
+
/** Files a test imports from its own directory tree, with the paths that
|
|
134
|
+
* would satisfy each import. Python names cannot be told from the standard
|
|
135
|
+
* library, so they are reported as candidates, never as definite misses. */
|
|
136
|
+
export function localImports(files, runner) {
|
|
137
|
+
const found = [];
|
|
138
|
+
for (const file of files) {
|
|
139
|
+
if (typeof file?.content !== "string" || typeof file.path !== "string")
|
|
140
|
+
continue;
|
|
141
|
+
if (runner === "python") {
|
|
142
|
+
const modules = [...file.content.matchAll(/^[ \t]*from[ \t]+([A-Za-z_][\w.]*)[ \t]+import\b/gm)].map(match => match[1])
|
|
143
|
+
.concat([...file.content.matchAll(/^[ \t]*import[ \t]+([A-Za-z_][\w.]*(?:[ \t]*,[ \t]*[A-Za-z_][\w.]*)*)/gm)].flatMap(match => match[1].split(",").map(item => item.trim())));
|
|
144
|
+
for (const module of new Set(modules)) {
|
|
145
|
+
const nested = module.replace(/\./g, "/"), top = module.split(".")[0];
|
|
146
|
+
found.push({ file: file.path, specifier: module, candidates: [...new Set([`${nested}.py`, `${nested}/__init__.py`, `${top}.py`, `${top}/__init__.py`])] });
|
|
147
|
+
}
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
const base = path.posix.dirname(file.path);
|
|
151
|
+
for (const match of file.content.matchAll(/(?:\bfrom\s*|\bimport\s*\(\s*|\bimport\s+|\brequire\s*\(\s*)["'](\.{1,2}\/[^"'\n]+)["']/g)) {
|
|
152
|
+
const resolved = path.posix.normalize(path.posix.join(base, match[1]));
|
|
153
|
+
if (resolved.startsWith(".."))
|
|
154
|
+
continue;
|
|
155
|
+
const extension = path.posix.extname(resolved);
|
|
156
|
+
const candidates = [".js", ".mjs", ".cjs", ".ts"].includes(extension)
|
|
157
|
+
? [resolved, ...(runner === "vitest" && extension !== ".ts" ? [resolved.slice(0, -extension.length) + ".ts"] : [])]
|
|
158
|
+
: extension ? [] : [".js", ".mjs", ".cjs", ...(runner === "vitest" ? [".ts"] : [])].flatMap(ext => [resolved + ext, `${resolved}/index${ext}`]);
|
|
159
|
+
if (candidates.length)
|
|
160
|
+
found.push({ file: file.path, specifier: match[1], candidates });
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return found;
|
|
164
|
+
}
|
|
165
|
+
/** The sandbox keeps nothing between calls. A test sent without the module it
|
|
166
|
+
* imports, when an earlier call in the same session sent that module, gets the
|
|
167
|
+
* session's latest version of it (cycle 7: 5 of 26 runs sent only the test).
|
|
168
|
+
* Only an import that names the file is filled; nothing else is inferred. */
|
|
169
|
+
export function completeTestFiles(args, earlier) {
|
|
170
|
+
const value = args;
|
|
171
|
+
if (!value || !Array.isArray(value.files) || !earlier.size)
|
|
172
|
+
return { args, carried: [] };
|
|
173
|
+
const runner = value.runner ?? "vitest";
|
|
174
|
+
if (!["vitest", "node", "python"].includes(runner))
|
|
175
|
+
return { args, carried: [] };
|
|
176
|
+
const files = [...value.files], carried = [];
|
|
177
|
+
// A Python import of a standard-library name (json, math, ...) must not
|
|
178
|
+
// pull in a same-named session file that would shadow the library.
|
|
179
|
+
const stdlib = runner === "python" ? pythonStdlib() : undefined;
|
|
180
|
+
if (runner === "python" && !stdlib)
|
|
181
|
+
return { args, carried: [] };
|
|
182
|
+
for (const item of localImports(value.files, runner)) {
|
|
183
|
+
if (stdlib?.has(item.specifier.split(".")[0]))
|
|
184
|
+
continue;
|
|
185
|
+
if (item.candidates.some(candidate => files.some(file => file?.path === candidate)))
|
|
186
|
+
continue;
|
|
187
|
+
const reuse = item.candidates.find(candidate => earlier.has(candidate));
|
|
188
|
+
if (!reuse || files.length >= 12)
|
|
189
|
+
continue;
|
|
190
|
+
files.push({ path: reuse, content: earlier.get(reuse) });
|
|
191
|
+
carried.push(reuse);
|
|
192
|
+
}
|
|
193
|
+
return carried.length ? { args: { ...value, files }, carried } : { args, carried };
|
|
194
|
+
}
|
|
195
|
+
const invalidRequest = (args, runner, payload) => {
|
|
196
|
+
const problems = [];
|
|
197
|
+
if (!["vitest", "node", "python"].includes(runner))
|
|
198
|
+
problems.push(`runner must be "vitest", "node" or "python", not ${JSON.stringify(runner)}`);
|
|
199
|
+
if (payload.length > 96000)
|
|
200
|
+
problems.push(`the request is ${payload.length} characters; the limit is 96000`);
|
|
201
|
+
const files = args.files;
|
|
202
|
+
if (!Array.isArray(files) || !files.length)
|
|
203
|
+
problems.push("files must list the implementation and its tests (1 to 12 {path, content} objects)");
|
|
204
|
+
else {
|
|
205
|
+
if (files.length > 12)
|
|
206
|
+
problems.push(`${files.length} files were sent; the limit is 12`);
|
|
207
|
+
for (const file of files) {
|
|
208
|
+
const name = JSON.stringify(typeof file?.path === "string" ? file.path : file?.path ?? null);
|
|
209
|
+
if (typeof file?.path !== "string" || !/^(?:[A-Za-z0-9_-]+\/)*[A-Za-z0-9_.-]+\.(?:[cm]?js|ts|py)$/.test(file.path))
|
|
210
|
+
problems.push(`${name} is not a relative path ending in .js, .mjs, .cjs, .ts or .py`);
|
|
211
|
+
else if (runner === "python" && !file.path.endsWith(".py"))
|
|
212
|
+
problems.push(`${name}: runner python takes only .py files`);
|
|
213
|
+
else if (runner !== "python" && file.path.endsWith(".py"))
|
|
214
|
+
problems.push(`${name}: .py files need runner "python"`);
|
|
215
|
+
else if (runner === "node" && file.path.endsWith(".ts"))
|
|
216
|
+
problems.push(`${name}: runner node cannot load TypeScript; use runner "vitest"`);
|
|
217
|
+
else if (file.path.split("/").some(segment => segment === "node_modules" || segment.startsWith(".")))
|
|
218
|
+
problems.push(`${name}: node_modules and dot-directories are not allowed`);
|
|
219
|
+
else if (/(?:^|\/)(?:vite|vitest)\.config\./.test(file.path))
|
|
220
|
+
problems.push(`${name}: runner configs are not accepted`);
|
|
221
|
+
if (typeof file?.content !== "string")
|
|
222
|
+
problems.push(`${name} has no string content`);
|
|
223
|
+
else if (file.content.length > 24000)
|
|
224
|
+
problems.push(`${name} is ${file.content.length} characters; the limit per file is 24000`);
|
|
225
|
+
}
|
|
226
|
+
if (new Set(files.map(file => file?.path)).size !== files.length)
|
|
227
|
+
problems.push("two files have the same path");
|
|
228
|
+
if (!problems.length && ["vitest", "node", "python"].includes(runner) && !files.some(file => isTestFile(file, runner))) {
|
|
229
|
+
problems.push(`none of ${files.map(file => file.path).join(", ")} is recognized as a test for runner ${runner}: ${runner === "python"
|
|
230
|
+
? "name the test file test_<name>.py or <name>_test.py"
|
|
231
|
+
: `name it <name>.test.js, test_<name>.js or test-<name>.js, or import ${runner === "node" ? "node:test" : "vitest"} in it, and declare cases with test(), it() or describe()`}`);
|
|
232
|
+
}
|
|
233
|
+
if (!problems.length && runner !== "python") {
|
|
234
|
+
const missing = localImports(files, runner).filter(item => !item.candidates.some(candidate => files.some(file => file.path === candidate)));
|
|
235
|
+
for (const item of missing.slice(0, 4))
|
|
236
|
+
problems.push(`${item.file} imports "${item.specifier}", which is not among the files; include ${item.candidates[0]} with the implementation`);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return problems.length ? `verify_tests did not run: ${problems.join("; ")}. Each call starts from an empty sandbox: send the implementation together with its tests.` : undefined;
|
|
240
|
+
};
|
|
102
241
|
export const createVitestTool = () => ({
|
|
103
242
|
name: "verify_tests", readOnly: true, capability: "verification",
|
|
104
|
-
description: "Run supplied tests offline: runner vitest (default) for JS/TS, node for node:test, python for unittest classes and pytest-style test_ functions or Test classes in test_*.py (pytest.raises/approx/parametrize only; no fixtures, async tests or plugins). Use the requested language/runner without translating tests. No workspace/config/credentials. Reports supplied-test results, not independent proof.",
|
|
105
|
-
inputSchema: { type: "object", properties: { runner: { type: "string", enum: ["vitest", "node", "python"] }, files: { type: "array", minItems: 1, maxItems: 12,
|
|
243
|
+
description: "Run supplied tests offline: runner vitest (default) for JS/TS, node for node:test, python for unittest classes and pytest-style test_ functions or Test classes in test_*.py/*_test.py (pytest.raises/approx/parametrize only; no fixtures, async tests or plugins). JS tests: *.test.js, test_*.js, test-*.js or any file importing node:test/vitest. Send the implementation with its tests in every call. Use the requested language/runner without translating tests. No workspace/config/credentials. Reports supplied-test results, not independent proof.",
|
|
244
|
+
inputSchema: { type: "object", properties: { runner: { type: "string", enum: ["vitest", "node", "python"] }, files: { type: "array", minItems: 1, maxItems: 12,
|
|
245
|
+
description: "The implementation and its tests together; nothing persists between calls. Tests: Python test_*.py or *_test.py; JS *.test.js, test_*.js, test-*.js or a file importing node:test/vitest.", items: { type: "object", properties: {
|
|
106
246
|
path: { type: "string", minLength: 1, maxLength: 160 }, content: { type: "string", maxLength: 24000 },
|
|
107
247
|
}, required: ["path", "content"], additionalProperties: false } } }, required: ["files"], additionalProperties: false },
|
|
108
248
|
handler: async (raw, context) => {
|
|
109
249
|
context.signal?.throwIfAborted();
|
|
110
250
|
const args = raw;
|
|
111
251
|
const runner = args.runner ?? "vitest";
|
|
112
|
-
const testPattern = runner === "python" ? /(?:^|\/)test_[^/]+\.py$/ : /\.test\.(?:[cm]?js|ts)$/;
|
|
113
252
|
const payload = JSON.stringify(args);
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|| typeof file.content !== "string" || file.content.length > 24000)
|
|
119
|
-
|| new Set(args.files.map(file => file.path)).size !== args.files.length || !args.files.some(file => testPattern.test(file.path))) {
|
|
120
|
-
throw new ToolExecutionError("tool_invalid_args", "Supply up to 12 bounded relative source/test files for the chosen runner: *.test.js/ts for Vitest, *.test.js/mjs/cjs for Node, test_*.py for Python. No configs or node_modules");
|
|
121
|
-
}
|
|
253
|
+
const invalid = invalidRequest(args, runner, payload);
|
|
254
|
+
if (invalid)
|
|
255
|
+
throw new ToolExecutionError("tool_invalid_args", invalid);
|
|
256
|
+
const testPaths = args.files.filter(file => isTestFile(file, runner)).map(file => file.path);
|
|
122
257
|
const runtime = runner === "vitest" ? await runnerRuntime() : undefined;
|
|
123
258
|
const root = await fs.mkdtemp(path.join(os.tmpdir(), "codali-vitest-"));
|
|
124
259
|
const started = Date.now();
|
|
@@ -132,7 +267,7 @@ export const createVitestTool = () => ({
|
|
|
132
267
|
await fs.writeFile(path.join(root, "package.json"), '{"type":"module"}');
|
|
133
268
|
await fs.mkdir(path.join(root, "artifacts"));
|
|
134
269
|
if (runner !== "vitest") {
|
|
135
|
-
const tests =
|
|
270
|
+
const tests = testPaths.map(file => path.join(root, file));
|
|
136
271
|
// Models write pytest-style tests (plain test_* functions, pytest.raises,
|
|
137
272
|
// approx, parametrize) far more often than unittest classes; cycle 6 lost
|
|
138
273
|
// twelve test runs to "pytest is not installed". A small stand-in covers
|
|
@@ -191,15 +326,24 @@ sys.exit(0 if result.wasSuccessful() and data['total']>0 and data['pendingTests'
|
|
|
191
326
|
const reportPath = path.join(root, "artifacts", "native-report.json");
|
|
192
327
|
if (runner === "python") {
|
|
193
328
|
const stat = await fs.lstat(reportPath).catch(() => undefined);
|
|
329
|
+
// A module missing from files is usually the implementation itself:
|
|
330
|
+
// nothing persists between calls (cycle 7: five runs sent only tests).
|
|
331
|
+
const absent = /ModuleNotFoundError: No module named '([A-Za-z_][\w.]*)'/.exec(output)?.[1];
|
|
332
|
+
const missing = absent && !args.files.some(file => [`${absent.replace(/\./g, "/")}.py`, `${absent.split(".")[0]}.py`, `${absent.split(".")[0]}/__init__.py`].includes(file.path))
|
|
333
|
+
? ` Module '${absent}' is not among the files: each call starts from an empty sandbox, so if it is the code under test, include ${absent.replace(/\./g, "/")}.py in files together with the tests.` : "";
|
|
194
334
|
if (!stat)
|
|
195
|
-
throw new ToolExecutionError("tool_execution_failed", `Python tests could not start
|
|
335
|
+
throw new ToolExecutionError("tool_execution_failed", `Python tests could not start.${missing} This runner loads unittest.TestCase classes and plain test_* functions, with a stand-in for pytest.raises, pytest.approx and pytest.mark.parametrize; other third-party packages are not installed. Fix the reported import/syntax error.\n${testFailureSummary(output)}`, { details: { exitCode, output } });
|
|
196
336
|
if (!stat.isFile() || stat.isSymbolicLink() || stat.size > 16000)
|
|
197
337
|
throw new Error("Invalid test report");
|
|
198
338
|
}
|
|
199
|
-
|
|
339
|
+
// node:test reports a file that declares no test as one passing test
|
|
340
|
+
// named after the file. That is not a test case: leave it out, so a
|
|
341
|
+
// helper-only run is "zero tests", never a pass.
|
|
342
|
+
const fileLevelPasses = runner === "node" ? [...output.matchAll(/^ok \d+ - (.+?)\s*$/gm)].filter(match => testPaths.some(file => match[1] === file || match[1] === path.join(root, file) || match[1].endsWith(`/${file}`))).length : 0;
|
|
343
|
+
const report = runner === "node" ? { total: count("tests") - fileLevelPasses, passedTests: count("pass") - fileLevelPasses, failedTests: count("fail"), pendingTests: count("skipped") + count("todo") + count("cancelled") }
|
|
200
344
|
: JSON.parse(await fs.readFile(reportPath, "utf8"));
|
|
201
345
|
if (!Object.values(report).every(value => Number.isSafeInteger(value) && Number(value) >= 0) || report.total < 1)
|
|
202
|
-
throw new ToolExecutionError("tool_execution_failed", `No complete test results were produced. Python requires test_* functions or unittest.TestCase methods named test_*; Node requires node:test cases. Zero executed tests cannot establish correctness.\n${testFailureSummary(output)}`, { details: { exitCode, output } });
|
|
346
|
+
throw new ToolExecutionError("tool_execution_failed", `No complete test results were produced. Python requires test_* functions or unittest.TestCase methods named test_*; Node requires node:test cases declared with test(), it() or describe(); a file without them is not a test. Zero executed tests cannot establish correctness.\n${testFailureSummary(output)}`, { details: { exitCode, output } });
|
|
203
347
|
const result = { library: runner === "node" ? "node:test" : "unittest", ...report,
|
|
204
348
|
passed: exitCode === 0 && report.failedTests === 0 && report.pendingTests === 0 && report.passedTests === report.total,
|
|
205
349
|
diagnostic: testFailureSummary(output).slice(0, 1800), sourceSha256: createHash("sha256").update(payload).digest("hex"), elapsedMs: Date.now() - started,
|
|
@@ -210,7 +354,7 @@ sys.exit(0 if result.wasSuccessful() and data['total']>0 and data['pendingTests'
|
|
|
210
354
|
throw new Error("Vitest runtime unavailable");
|
|
211
355
|
await fs.mkdir(path.join(root, "node_modules"));
|
|
212
356
|
await fs.symlink(runtime.entry, path.join(root, "node_modules", "vitest"));
|
|
213
|
-
const config = { cacheDir: path.join(root, "artifacts", "cache"), server: { host: "127.0.0.1", hmr: false }, test: { include:
|
|
357
|
+
const config = { cacheDir: path.join(root, "artifacts", "cache"), server: { host: "127.0.0.1", hmr: false }, test: { include: testPaths, environment: "node", globals: false,
|
|
214
358
|
// macOS denies signaling separate child processes inside this sandbox.
|
|
215
359
|
// Threads retain the same OS boundary without requiring signal grants.
|
|
216
360
|
pool: "threads", maxWorkers: 1, fileParallelism: false, testTimeout: 1000, hookTimeout: 1000, passWithNoTests: false, reporters: ["json"], outputFile: path.join(root, "artifacts", "report.json") } };
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"url": "https://github.com/bekirdag/mcoda/issues"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@mcoda/db": "0.1.135-codali.
|
|
13
|
-
"@mcoda/shared": "0.1.135-codali.
|
|
12
|
+
"@mcoda/db": "0.1.135-codali.47",
|
|
13
|
+
"@mcoda/shared": "0.1.135-codali.47",
|
|
14
14
|
"@modelcontextprotocol/sdk": "1.30.0",
|
|
15
15
|
"ajv": "8.20.0",
|
|
16
16
|
"browser-use": "0.9.0",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
},
|
|
59
59
|
"type": "module",
|
|
60
60
|
"types": "dist/index.d.ts",
|
|
61
|
-
"version": "0.1.135-codali.
|
|
61
|
+
"version": "0.1.135-codali.47"
|
|
62
62
|
}
|