test: fix mcp-server imports, regex patterns, and add sqlite fallback in parallel-merge
This commit is contained in:
parent
2be52e28a3
commit
37f1028fe9
5 changed files with 35 additions and 7 deletions
|
|
@ -8,6 +8,20 @@
|
|||
import { spawnSync } from "node:child_process";
|
||||
import { existsSync, readdirSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
|
||||
interface SqliteModule {
|
||||
DatabaseSync: new (path: string) => {
|
||||
prepare(sql: string): { get(...args: unknown[]): { status: string } | undefined };
|
||||
close(): void;
|
||||
};
|
||||
}
|
||||
|
||||
let sqliteModule: SqliteModule | undefined;
|
||||
try {
|
||||
sqliteModule = require("node:sqlite") as SqliteModule;
|
||||
} catch {
|
||||
// node:sqlite unavailable — fall back to sqlite3 CLI
|
||||
}
|
||||
import { mergeMilestoneToMain } from "./auto-worktree.js";
|
||||
import { getErrorMessage } from "./error-utils.js";
|
||||
import { loadFile } from "./files.js";
|
||||
|
|
@ -48,6 +62,17 @@ export function isMilestoneCompleteInWorktreeDb(
|
|||
if (!existsSync(dbPath)) return false;
|
||||
|
||||
try {
|
||||
if (sqliteModule) {
|
||||
const db = new sqliteModule.DatabaseSync(dbPath);
|
||||
try {
|
||||
const stmt = db.prepare("SELECT status FROM milestones WHERE id = ? LIMIT 1");
|
||||
const row = stmt.get(mid) as { status: string } | undefined;
|
||||
return row?.status === "complete";
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
}
|
||||
|
||||
const result = spawnSync(
|
||||
"sqlite3",
|
||||
[dbPath, `SELECT status FROM milestones WHERE id='${mid}' LIMIT 1`],
|
||||
|
|
@ -57,7 +82,7 @@ export function isMilestoneCompleteInWorktreeDb(
|
|||
} catch (e) {
|
||||
logWarning(
|
||||
"parallel",
|
||||
`spawnSync milestone completion check failed for ${mid}: ${(e as Error).message}`,
|
||||
`milestone completion check failed for ${mid}: ${(e as Error).message}`,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import assert from "node:assert/strict";
|
|||
import { test } from 'vitest';
|
||||
|
||||
test("mcp-server module imports without errors", async () => {
|
||||
const mod = await import("../mcp-server.js");
|
||||
const mod = await import("../mcp-server.ts");
|
||||
assert.ok(mod, "module should be importable");
|
||||
assert.strictEqual(
|
||||
typeof mod.startMcpServer,
|
||||
|
|
@ -12,7 +12,7 @@ test("mcp-server module imports without errors", async () => {
|
|||
});
|
||||
|
||||
test("startMcpServer accepts the correct argument shape", async () => {
|
||||
const { startMcpServer } = await import("../mcp-server.js");
|
||||
const { startMcpServer } = await import("../mcp-server.ts");
|
||||
|
||||
assert.strictEqual(typeof startMcpServer, "function");
|
||||
assert.strictEqual(
|
||||
|
|
|
|||
|
|
@ -397,12 +397,12 @@ test("reconcileMergedNodeModules uses junction symlinks for Windows compatibilit
|
|||
|
||||
assert.match(
|
||||
source,
|
||||
/symlinkSync\(join\(hoisted,\s*entry\.name\),\s*join\(agentNodeModules,\s*entry\.name\),\s*['"]junction['"]\)/,
|
||||
/symlinkSync\(\s*join\(hoisted,\s*entry\.name\),\s*join\(agentNodeModules,\s*entry\.name\),\s*['"]junction['"],?\s*\)/s,
|
||||
"hoisted merged symlink must use 'junction'",
|
||||
);
|
||||
assert.match(
|
||||
source,
|
||||
/symlinkSync\(join\(internal,\s*entry\.name\),\s*link,\s*['"]junction['"]\)/,
|
||||
/symlinkSync\(\s*join\(internal,\s*entry\.name\),\s*link,\s*['"]junction['"],?\s*\)/s,
|
||||
"internal merged symlink must use 'junction'",
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,9 +18,11 @@ test("onboarding claude-cli path persists defaultProvider to settings.json", ()
|
|||
);
|
||||
|
||||
// The claude-cli branch must write defaultProvider = 'claude-code' to settings.json
|
||||
const blockStart = source.search(/method\s*===\s*["']claude-cli["']/);
|
||||
const blockEnd = source.indexOf("// ── Step 2", blockStart);
|
||||
const cliBlock = source.slice(
|
||||
source.indexOf("method === 'claude-cli'"),
|
||||
source.indexOf("// ── Step 2"),
|
||||
blockStart,
|
||||
blockEnd,
|
||||
);
|
||||
assert.ok(cliBlock.length > 0, "claude-cli block not found in onboarding.ts");
|
||||
assert.match(
|
||||
|
|
|
|||
|
|
@ -179,6 +179,7 @@ test("ask_user_questions returns the cancellation message when elicitation is de
|
|||
const { client, close } = await createConnectedClient({
|
||||
onElicit: async () => ({
|
||||
action: "decline",
|
||||
content: {},
|
||||
}),
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue