@reconcrap/boss-recommend-mcp 1.2.3 → 1.2.4
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/bin/boss-recommend-mcp.js +2 -2
- package/config/screening-config.example.json +7 -7
- package/package.json +62 -62
- package/scripts/postinstall.cjs +44 -44
- package/skills/boss-recommend-pipeline/README.md +12 -12
- package/skills/boss-recommend-pipeline/SKILL.md +244 -244
- package/src/index.js +182 -51
- package/src/pipeline.js +1432 -1432
- package/src/run-state.js +351 -351
- package/src/test-adapters-runtime.js +469 -469
- package/src/test-index-async.js +264 -264
- package/src/test-run-state.js +152 -152
- package/vendor/boss-recommend-screen-cli/boss-recommend-screen-cli.cjs +3721 -3840
- package/vendor/boss-recommend-screen-cli/scripts/stitch_resume_chunks.py +141 -141
- package/vendor/boss-recommend-screen-cli/test-recoverable-resume-failures.cjs +832 -880
- package/vendor/boss-recommend-search-cli/src/cli.js +1650 -1650
- package/vendor/boss-recommend-search-cli/src/test-job-selection.js +211 -211
package/src/test-run-state.js
CHANGED
|
@@ -1,152 +1,152 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import os from "node:os";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import {
|
|
6
|
-
RUN_MODE_ASYNC,
|
|
7
|
-
RUN_STATE_PAUSED,
|
|
8
|
-
RUN_STAGE_SCREEN,
|
|
9
|
-
RUN_STATE_COMPLETED,
|
|
10
|
-
RUN_STATE_QUEUED,
|
|
11
|
-
RUN_STATE_RUNNING,
|
|
12
|
-
cleanupExpiredRuns,
|
|
13
|
-
createRunId,
|
|
14
|
-
createRunStateSnapshot,
|
|
15
|
-
getRunsDir,
|
|
16
|
-
readRunState,
|
|
17
|
-
touchRunHeartbeat,
|
|
18
|
-
updateRunProgress,
|
|
19
|
-
updateRunState,
|
|
20
|
-
writeRunState
|
|
21
|
-
} from "./run-state.js";
|
|
22
|
-
|
|
23
|
-
function withTempHome(testFn) {
|
|
24
|
-
const previous = process.env.BOSS_RECOMMEND_HOME;
|
|
25
|
-
const tempHome = fs.mkdtempSync(path.join(os.tmpdir(), "boss-recommend-run-state-"));
|
|
26
|
-
process.env.BOSS_RECOMMEND_HOME = tempHome;
|
|
27
|
-
try {
|
|
28
|
-
testFn(tempHome);
|
|
29
|
-
} finally {
|
|
30
|
-
if (previous === undefined) {
|
|
31
|
-
delete process.env.BOSS_RECOMMEND_HOME;
|
|
32
|
-
} else {
|
|
33
|
-
process.env.BOSS_RECOMMEND_HOME = previous;
|
|
34
|
-
}
|
|
35
|
-
fs.rmSync(tempHome, { recursive: true, force: true });
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function testRunStateLifecycle() {
|
|
40
|
-
withTempHome(() => {
|
|
41
|
-
const runId = createRunId();
|
|
42
|
-
const queued = writeRunState(createRunStateSnapshot({
|
|
43
|
-
runId,
|
|
44
|
-
mode: RUN_MODE_ASYNC,
|
|
45
|
-
state: RUN_STATE_QUEUED,
|
|
46
|
-
stage: "preflight",
|
|
47
|
-
context: {
|
|
48
|
-
workspace_root: "C:/workspace",
|
|
49
|
-
instruction: "筛选有 MCP 经验候选人",
|
|
50
|
-
confirmation: {
|
|
51
|
-
final_confirmed: true
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
control: {
|
|
55
|
-
pause_requested: false
|
|
56
|
-
},
|
|
57
|
-
resume: {
|
|
58
|
-
checkpoint_path: `C:/workspace/.state/${runId}.checkpoint.json`,
|
|
59
|
-
pause_control_path: `C:/workspace/.state/${runId}.json`,
|
|
60
|
-
output_csv: "C:/workspace/result.csv"
|
|
61
|
-
}
|
|
62
|
-
}));
|
|
63
|
-
assert.equal(queued.run_id, runId);
|
|
64
|
-
assert.equal(queued.state, RUN_STATE_QUEUED);
|
|
65
|
-
assert.equal(queued.context.workspace_root, "C:/workspace");
|
|
66
|
-
assert.equal(queued.resume.output_csv, "C:/workspace/result.csv");
|
|
67
|
-
assert.equal(queued.control.cancel_requested, false);
|
|
68
|
-
|
|
69
|
-
const running = updateRunState(runId, {
|
|
70
|
-
state: RUN_STATE_RUNNING,
|
|
71
|
-
stage: RUN_STAGE_SCREEN,
|
|
72
|
-
last_message: "screening in progress"
|
|
73
|
-
});
|
|
74
|
-
assert.equal(running.state, RUN_STATE_RUNNING);
|
|
75
|
-
assert.equal(running.stage, RUN_STAGE_SCREEN);
|
|
76
|
-
const heartbeatBeforeProgress = running.heartbeat_at;
|
|
77
|
-
|
|
78
|
-
const progressed = updateRunProgress(runId, {
|
|
79
|
-
processed: 7,
|
|
80
|
-
passed: 2,
|
|
81
|
-
skipped: 5,
|
|
82
|
-
greet_count: 1
|
|
83
|
-
});
|
|
84
|
-
assert.equal(progressed.progress.processed, 7);
|
|
85
|
-
assert.equal(progressed.progress.passed, 2);
|
|
86
|
-
assert.equal(progressed.progress.skipped, 5);
|
|
87
|
-
assert.equal(progressed.progress.greet_count, 1);
|
|
88
|
-
assert.equal(progressed.heartbeat_at, heartbeatBeforeProgress);
|
|
89
|
-
|
|
90
|
-
const paused = updateRunState(runId, {
|
|
91
|
-
state: RUN_STATE_PAUSED,
|
|
92
|
-
control: {
|
|
93
|
-
pause_requested: true,
|
|
94
|
-
pause_requested_at: "2026-01-01T00:00:00.000Z",
|
|
95
|
-
pause_requested_by: "pause_recommend_pipeline_run",
|
|
96
|
-
cancel_requested: true
|
|
97
|
-
},
|
|
98
|
-
resume: {
|
|
99
|
-
output_csv: "C:/workspace/result-partial.csv",
|
|
100
|
-
last_paused_at: "2026-01-01T00:00:01.000Z"
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
assert.equal(paused.state, RUN_STATE_PAUSED);
|
|
104
|
-
assert.equal(paused.control.pause_requested, true);
|
|
105
|
-
assert.equal(paused.control.pause_requested_by, "pause_recommend_pipeline_run");
|
|
106
|
-
assert.equal(paused.control.cancel_requested, true);
|
|
107
|
-
assert.equal(paused.resume.output_csv, "C:/workspace/result-partial.csv");
|
|
108
|
-
|
|
109
|
-
const heartbeated = touchRunHeartbeat(runId, "still running");
|
|
110
|
-
assert.equal(heartbeated.last_message, "still running");
|
|
111
|
-
assert.equal(Date.parse(heartbeated.heartbeat_at) >= Date.parse(heartbeatBeforeProgress), true);
|
|
112
|
-
|
|
113
|
-
const completed = updateRunState(runId, {
|
|
114
|
-
state: RUN_STATE_COMPLETED,
|
|
115
|
-
stage: "finalize",
|
|
116
|
-
result: {
|
|
117
|
-
status: "COMPLETED",
|
|
118
|
-
result: {
|
|
119
|
-
processed_count: 7
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
assert.equal(completed.state, RUN_STATE_COMPLETED);
|
|
124
|
-
assert.equal(completed.result.status, "COMPLETED");
|
|
125
|
-
|
|
126
|
-
const reloaded = readRunState(runId);
|
|
127
|
-
assert.equal(reloaded.state, RUN_STATE_COMPLETED);
|
|
128
|
-
assert.equal(reloaded.progress.processed, 7);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function testRunStateCleanup() {
|
|
133
|
-
withTempHome(() => {
|
|
134
|
-
const runId = createRunId();
|
|
135
|
-
writeRunState(createRunStateSnapshot({ runId, mode: RUN_MODE_ASYNC }));
|
|
136
|
-
const runFile = path.join(getRunsDir(), `${runId}.json`);
|
|
137
|
-
const oldSeconds = Math.floor((Date.now() - 3 * 24 * 60 * 60 * 1000) / 1000);
|
|
138
|
-
fs.utimesSync(runFile, oldSeconds, oldSeconds);
|
|
139
|
-
|
|
140
|
-
const cleaned = cleanupExpiredRuns(1000);
|
|
141
|
-
assert.equal(cleaned.removed.some((item) => item.endsWith(`${runId}.json`)), true);
|
|
142
|
-
assert.equal(fs.existsSync(runFile), false);
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function main() {
|
|
147
|
-
testRunStateLifecycle();
|
|
148
|
-
testRunStateCleanup();
|
|
149
|
-
console.log("run-state tests passed");
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
main();
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import {
|
|
6
|
+
RUN_MODE_ASYNC,
|
|
7
|
+
RUN_STATE_PAUSED,
|
|
8
|
+
RUN_STAGE_SCREEN,
|
|
9
|
+
RUN_STATE_COMPLETED,
|
|
10
|
+
RUN_STATE_QUEUED,
|
|
11
|
+
RUN_STATE_RUNNING,
|
|
12
|
+
cleanupExpiredRuns,
|
|
13
|
+
createRunId,
|
|
14
|
+
createRunStateSnapshot,
|
|
15
|
+
getRunsDir,
|
|
16
|
+
readRunState,
|
|
17
|
+
touchRunHeartbeat,
|
|
18
|
+
updateRunProgress,
|
|
19
|
+
updateRunState,
|
|
20
|
+
writeRunState
|
|
21
|
+
} from "./run-state.js";
|
|
22
|
+
|
|
23
|
+
function withTempHome(testFn) {
|
|
24
|
+
const previous = process.env.BOSS_RECOMMEND_HOME;
|
|
25
|
+
const tempHome = fs.mkdtempSync(path.join(os.tmpdir(), "boss-recommend-run-state-"));
|
|
26
|
+
process.env.BOSS_RECOMMEND_HOME = tempHome;
|
|
27
|
+
try {
|
|
28
|
+
testFn(tempHome);
|
|
29
|
+
} finally {
|
|
30
|
+
if (previous === undefined) {
|
|
31
|
+
delete process.env.BOSS_RECOMMEND_HOME;
|
|
32
|
+
} else {
|
|
33
|
+
process.env.BOSS_RECOMMEND_HOME = previous;
|
|
34
|
+
}
|
|
35
|
+
fs.rmSync(tempHome, { recursive: true, force: true });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function testRunStateLifecycle() {
|
|
40
|
+
withTempHome(() => {
|
|
41
|
+
const runId = createRunId();
|
|
42
|
+
const queued = writeRunState(createRunStateSnapshot({
|
|
43
|
+
runId,
|
|
44
|
+
mode: RUN_MODE_ASYNC,
|
|
45
|
+
state: RUN_STATE_QUEUED,
|
|
46
|
+
stage: "preflight",
|
|
47
|
+
context: {
|
|
48
|
+
workspace_root: "C:/workspace",
|
|
49
|
+
instruction: "筛选有 MCP 经验候选人",
|
|
50
|
+
confirmation: {
|
|
51
|
+
final_confirmed: true
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
control: {
|
|
55
|
+
pause_requested: false
|
|
56
|
+
},
|
|
57
|
+
resume: {
|
|
58
|
+
checkpoint_path: `C:/workspace/.state/${runId}.checkpoint.json`,
|
|
59
|
+
pause_control_path: `C:/workspace/.state/${runId}.json`,
|
|
60
|
+
output_csv: "C:/workspace/result.csv"
|
|
61
|
+
}
|
|
62
|
+
}));
|
|
63
|
+
assert.equal(queued.run_id, runId);
|
|
64
|
+
assert.equal(queued.state, RUN_STATE_QUEUED);
|
|
65
|
+
assert.equal(queued.context.workspace_root, "C:/workspace");
|
|
66
|
+
assert.equal(queued.resume.output_csv, "C:/workspace/result.csv");
|
|
67
|
+
assert.equal(queued.control.cancel_requested, false);
|
|
68
|
+
|
|
69
|
+
const running = updateRunState(runId, {
|
|
70
|
+
state: RUN_STATE_RUNNING,
|
|
71
|
+
stage: RUN_STAGE_SCREEN,
|
|
72
|
+
last_message: "screening in progress"
|
|
73
|
+
});
|
|
74
|
+
assert.equal(running.state, RUN_STATE_RUNNING);
|
|
75
|
+
assert.equal(running.stage, RUN_STAGE_SCREEN);
|
|
76
|
+
const heartbeatBeforeProgress = running.heartbeat_at;
|
|
77
|
+
|
|
78
|
+
const progressed = updateRunProgress(runId, {
|
|
79
|
+
processed: 7,
|
|
80
|
+
passed: 2,
|
|
81
|
+
skipped: 5,
|
|
82
|
+
greet_count: 1
|
|
83
|
+
});
|
|
84
|
+
assert.equal(progressed.progress.processed, 7);
|
|
85
|
+
assert.equal(progressed.progress.passed, 2);
|
|
86
|
+
assert.equal(progressed.progress.skipped, 5);
|
|
87
|
+
assert.equal(progressed.progress.greet_count, 1);
|
|
88
|
+
assert.equal(progressed.heartbeat_at, heartbeatBeforeProgress);
|
|
89
|
+
|
|
90
|
+
const paused = updateRunState(runId, {
|
|
91
|
+
state: RUN_STATE_PAUSED,
|
|
92
|
+
control: {
|
|
93
|
+
pause_requested: true,
|
|
94
|
+
pause_requested_at: "2026-01-01T00:00:00.000Z",
|
|
95
|
+
pause_requested_by: "pause_recommend_pipeline_run",
|
|
96
|
+
cancel_requested: true
|
|
97
|
+
},
|
|
98
|
+
resume: {
|
|
99
|
+
output_csv: "C:/workspace/result-partial.csv",
|
|
100
|
+
last_paused_at: "2026-01-01T00:00:01.000Z"
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
assert.equal(paused.state, RUN_STATE_PAUSED);
|
|
104
|
+
assert.equal(paused.control.pause_requested, true);
|
|
105
|
+
assert.equal(paused.control.pause_requested_by, "pause_recommend_pipeline_run");
|
|
106
|
+
assert.equal(paused.control.cancel_requested, true);
|
|
107
|
+
assert.equal(paused.resume.output_csv, "C:/workspace/result-partial.csv");
|
|
108
|
+
|
|
109
|
+
const heartbeated = touchRunHeartbeat(runId, "still running");
|
|
110
|
+
assert.equal(heartbeated.last_message, "still running");
|
|
111
|
+
assert.equal(Date.parse(heartbeated.heartbeat_at) >= Date.parse(heartbeatBeforeProgress), true);
|
|
112
|
+
|
|
113
|
+
const completed = updateRunState(runId, {
|
|
114
|
+
state: RUN_STATE_COMPLETED,
|
|
115
|
+
stage: "finalize",
|
|
116
|
+
result: {
|
|
117
|
+
status: "COMPLETED",
|
|
118
|
+
result: {
|
|
119
|
+
processed_count: 7
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
assert.equal(completed.state, RUN_STATE_COMPLETED);
|
|
124
|
+
assert.equal(completed.result.status, "COMPLETED");
|
|
125
|
+
|
|
126
|
+
const reloaded = readRunState(runId);
|
|
127
|
+
assert.equal(reloaded.state, RUN_STATE_COMPLETED);
|
|
128
|
+
assert.equal(reloaded.progress.processed, 7);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function testRunStateCleanup() {
|
|
133
|
+
withTempHome(() => {
|
|
134
|
+
const runId = createRunId();
|
|
135
|
+
writeRunState(createRunStateSnapshot({ runId, mode: RUN_MODE_ASYNC }));
|
|
136
|
+
const runFile = path.join(getRunsDir(), `${runId}.json`);
|
|
137
|
+
const oldSeconds = Math.floor((Date.now() - 3 * 24 * 60 * 60 * 1000) / 1000);
|
|
138
|
+
fs.utimesSync(runFile, oldSeconds, oldSeconds);
|
|
139
|
+
|
|
140
|
+
const cleaned = cleanupExpiredRuns(1000);
|
|
141
|
+
assert.equal(cleaned.removed.some((item) => item.endsWith(`${runId}.json`)), true);
|
|
142
|
+
assert.equal(fs.existsSync(runFile), false);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function main() {
|
|
147
|
+
testRunStateLifecycle();
|
|
148
|
+
testRunStateCleanup();
|
|
149
|
+
console.log("run-state tests passed");
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
main();
|