qualiloop 0.0.0-stage → 0.2.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/LICENSE +202 -0
- package/README.md +258 -3
- package/dist/api.js +165 -0
- package/dist/auth.js +73 -0
- package/dist/catalog.js +24 -0
- package/dist/catalog.json +7943 -0
- package/dist/cli.js +2777 -0
- package/dist/config.js +76 -0
- package/dist/connect.js +357 -0
- package/dist/export.js +114 -0
- package/dist/mcp/install.js +142 -0
- package/dist/mcp/server.js +523 -0
- package/dist/output.js +43 -0
- package/dist/workflows.js +147 -0
- package/package.json +47 -4
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { ApiError, EXIT } from './api.js';
|
|
2
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
3
|
+
export const isTransient = (error) => error instanceof ApiError &&
|
|
4
|
+
(error.status === 0 || error.status === 408 || error.status === 429 || error.status >= 500);
|
|
5
|
+
export const READ_TRIES = 5;
|
|
6
|
+
export const readPatiently = async (read, pauseMs = 2000) => {
|
|
7
|
+
for (let attempt = 1;; attempt += 1) {
|
|
8
|
+
try {
|
|
9
|
+
return await read();
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
if (attempt >= READ_TRIES || !isTransient(error))
|
|
13
|
+
throw error;
|
|
14
|
+
await sleep(pauseMs * 2 ** (attempt - 1));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
export const batchProgress = (runs) => {
|
|
19
|
+
const done = runs.filter((run) => run.finished).length;
|
|
20
|
+
const working = new Map();
|
|
21
|
+
for (const run of runs) {
|
|
22
|
+
if (run.finished)
|
|
23
|
+
continue;
|
|
24
|
+
const label = (run.status_label ?? run.status).toLowerCase();
|
|
25
|
+
working.set(label, (working.get(label) ?? 0) + 1);
|
|
26
|
+
}
|
|
27
|
+
const doing = [...working].map(([label, count]) => `${count} ${label}`).join(', ');
|
|
28
|
+
return `${done} of ${runs.length} runs finished${doing ? `; ${doing}` : ''}`;
|
|
29
|
+
};
|
|
30
|
+
export const waitForBatch = async (client, project, batchId, waiting) => {
|
|
31
|
+
const deadline = Date.now() + waiting.timeoutMinutes * 60_000;
|
|
32
|
+
let errors = 0;
|
|
33
|
+
for (;;) {
|
|
34
|
+
try {
|
|
35
|
+
const listed = await client.action('list_runs', {
|
|
36
|
+
project,
|
|
37
|
+
batch: batchId,
|
|
38
|
+
limit: 500,
|
|
39
|
+
});
|
|
40
|
+
errors = 0;
|
|
41
|
+
if (!listed.runs.length) {
|
|
42
|
+
throw new ApiError(`No runs in batch ${batchId}${project ? ` of project ${project}` : ''}. A run --wait or suites run --wait prints its batch.`, 404, EXIT.notFound);
|
|
43
|
+
}
|
|
44
|
+
waiting.onProgress?.(batchProgress(listed.runs));
|
|
45
|
+
if (listed.all_finished)
|
|
46
|
+
return listed.runs;
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (error instanceof ApiError && error.exitCode === EXIT.notFound)
|
|
50
|
+
throw error;
|
|
51
|
+
errors += 1;
|
|
52
|
+
if (errors >= 10 || (error instanceof ApiError && error.exitCode === EXIT.auth))
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
if (Date.now() > deadline) {
|
|
56
|
+
throw new ApiError(`The runs did not finish within ${waiting.timeoutMinutes} minutes. They keep running in QualiLoop.`, 408, EXIT.timeout);
|
|
57
|
+
}
|
|
58
|
+
await sleep((waiting.pollSeconds ?? 10) * 1000);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
export const runsExitCode = (runs, failOn) => {
|
|
62
|
+
if (failOn === 'none')
|
|
63
|
+
return EXIT.ok;
|
|
64
|
+
const failed = runs.some((run) => {
|
|
65
|
+
if (run.test_passed === false)
|
|
66
|
+
return true;
|
|
67
|
+
if (['failed', 'stopped'].includes(run.status))
|
|
68
|
+
return true;
|
|
69
|
+
return failOn === 'minor' && (run.minor_problems ?? 0) > 0;
|
|
70
|
+
});
|
|
71
|
+
return failed ? EXIT.failed : EXIT.ok;
|
|
72
|
+
};
|
|
73
|
+
export const compareBatch = (client, project, batchId) => client.action('compare_batch', { project, batch: batchId });
|
|
74
|
+
const CHANGE_WORDS = [
|
|
75
|
+
['fixed', 'fixed'],
|
|
76
|
+
['regressed', 'regressed'],
|
|
77
|
+
['still_failing', 'still failing'],
|
|
78
|
+
['still_passing', 'still passing'],
|
|
79
|
+
['new', 'new'],
|
|
80
|
+
['unfinished', 'unfinished'],
|
|
81
|
+
];
|
|
82
|
+
export const comparisonText = (comparison, projectFlag = '') => {
|
|
83
|
+
const counts = CHANGE_WORDS.filter(([change]) => comparison.counts[change])
|
|
84
|
+
.map(([change, words]) => `${comparison.counts[change]} ${words}`)
|
|
85
|
+
.join(', ');
|
|
86
|
+
const compared = ['fixed', 'regressed', 'still_failing', 'still_passing'].some((change) => comparison.counts[change]);
|
|
87
|
+
const { major, minor } = comparison.problems;
|
|
88
|
+
const lines = [
|
|
89
|
+
`vs previous: ${counts || 'nothing to compare'}` +
|
|
90
|
+
(compared ? `; major problems ${major.previous} -> ${major.now}, minor ${minor.previous} -> ${minor.now}` : ''),
|
|
91
|
+
];
|
|
92
|
+
const regressed = comparison.tests.filter((test) => test.change === 'regressed');
|
|
93
|
+
if (regressed.length) {
|
|
94
|
+
lines.push('Regressed (passed last time):');
|
|
95
|
+
for (const test of regressed) {
|
|
96
|
+
lines.push(` #${test.run_number} ${test.name} (was #${test.previous_run_number}): qualiloop problems --run ${test.run_number}${projectFlag}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return lines.join('\n');
|
|
100
|
+
};
|
|
101
|
+
const waitForGate = async (read, waiting) => {
|
|
102
|
+
const deadline = Date.now() + waiting.timeoutMinutes * 60_000;
|
|
103
|
+
let errors = 0;
|
|
104
|
+
for (;;) {
|
|
105
|
+
try {
|
|
106
|
+
const run = await read();
|
|
107
|
+
errors = 0;
|
|
108
|
+
waiting.onProgress?.(`${run.status}: ${run.completed_tests ?? 0}/${run.total_tests ?? 0} tests done, ${run.pass_percentage ?? 0}% passing`);
|
|
109
|
+
if (run.status === 'completed')
|
|
110
|
+
return run;
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
errors += 1;
|
|
114
|
+
if (errors >= 20 || (error instanceof ApiError && error.exitCode === EXIT.auth))
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
if (Date.now() > deadline) {
|
|
118
|
+
throw new ApiError(`No gate decision within ${waiting.timeoutMinutes} minutes. Failing, as the gate's CI time limit says.`, 408, EXIT.timeout);
|
|
119
|
+
}
|
|
120
|
+
await sleep((waiting.pollSeconds ?? 15) * 1000);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
export const waitForGateRun = (client, number, waiting) => waitForGate(() => client.action('get_gate_run', { gate_run_number: number }), waiting);
|
|
124
|
+
export const startGateWithKey = (client, key, body) => client.request('POST', '/v1/release-gates/hooks/runs', { token: key, body });
|
|
125
|
+
export const waitForGateRunWithKey = (client, key, runId, waiting) => waitForGate(() => client.request('GET', `/v1/release-gates/hooks/runs/${runId}`, { token: key }), waiting);
|
|
126
|
+
export const startGeneration = (client, options) => client.action('generate_tests', {
|
|
127
|
+
project: options.project,
|
|
128
|
+
prompt: options.prompt,
|
|
129
|
+
suite: options.suite === undefined ? undefined : /^\d+$/.test(options.suite) ? Number(options.suite) : options.suite,
|
|
130
|
+
new_suite_name: options.newSuite,
|
|
131
|
+
max_count: options.max,
|
|
132
|
+
});
|
|
133
|
+
export const getGeneration = (client, id) => client.action('get_generation', { generation: id });
|
|
134
|
+
export const cancelGeneration = (client, id) => client.action('cancel_generation', { generation: id });
|
|
135
|
+
export const waitForGeneration = async (client, id, waiting) => {
|
|
136
|
+
const deadline = Date.now() + waiting.timeoutMinutes * 60_000;
|
|
137
|
+
for (;;) {
|
|
138
|
+
const generation = await readPatiently(() => getGeneration(client, id));
|
|
139
|
+
waiting.onProgress?.(`${generation.step_label ?? generation.step ?? generation.status}${generation.planned ? `: ${generation.written ?? 0}/${generation.planned} written` : ''}`);
|
|
140
|
+
if (generation.finished)
|
|
141
|
+
return generation;
|
|
142
|
+
if (Date.now() > deadline) {
|
|
143
|
+
throw new ApiError(`The generation did not finish within ${waiting.timeoutMinutes} minutes. It keeps going in QualiLoop.`, 408, EXIT.timeout);
|
|
144
|
+
}
|
|
145
|
+
await sleep((waiting.pollSeconds ?? 5) * 1000);
|
|
146
|
+
}
|
|
147
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qualiloop",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"mcpName": "com.qualiloop/qualiloop",
|
|
5
|
+
"description": "QualiLoop from the terminal, scripts, CI and coding agents: run tests and release gates, read problems, write tests. The qualiloop CLI and its MCP server.",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"homepage": "https://www.qualiloop.com",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"qualiloop",
|
|
10
|
+
"ai-agent",
|
|
11
|
+
"llm",
|
|
12
|
+
"testing",
|
|
13
|
+
"evaluation",
|
|
14
|
+
"release-gate",
|
|
15
|
+
"ci",
|
|
16
|
+
"cli",
|
|
17
|
+
"mcp",
|
|
18
|
+
"mcp-server"
|
|
19
|
+
],
|
|
20
|
+
"type": "module",
|
|
21
|
+
"bin": {
|
|
22
|
+
"qualiloop": "dist/cli.js",
|
|
23
|
+
"ql": "dist/cli.js"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md",
|
|
28
|
+
"LICENSE"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
32
|
+
"build": "npm run clean && tsc -p tsconfig.json && node scripts/copy-catalog.mjs",
|
|
33
|
+
"type-check": "tsc -p tsconfig.json --noEmit",
|
|
34
|
+
"test": "npm run build && node --test test/unit.test.mjs test/smoke.test.mjs",
|
|
35
|
+
"start": "node dist/cli.js",
|
|
36
|
+
"prepack": "npm run build"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=20"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@modelcontextprotocol/sdk": "1.32.1",
|
|
43
|
+
"commander": "14.0.3"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "22.20.5",
|
|
47
|
+
"typescript": "5.9.3"
|
|
48
|
+
}
|
|
49
|
+
}
|