feat(dev-tools): document dsh install and zero-LLM local checks
Memind CI / Test, build, and release guards (push) Failing after 3m44s
Memind CI / Test, build, and release guards (push) Failing after 3m44s
Pin @deepseek-ai/dsh@0.1.1-rc.2 probing in check-dsh-executor-local.mjs, keep live headless smoke opt-in only, and record the 10k-token approval gate. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,11 +1,53 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Local DeepSeek Harness executor dry-run probe.
|
||||
* Local DeepSeek Harness (dsh) smoke — dev machine only, no LLM by default.
|
||||
*
|
||||
* Always verifies the CLI. When MEMIND_TOOL_GATEWAY_DSH_ENABLED=1, also prints
|
||||
* a dry-run launch plan (does not spawn dsh).
|
||||
*
|
||||
* Live headless smoke (costs LLM tokens) is opt-in only:
|
||||
* MEMIND_DSH_RUN_LIVE_SMOKE=1 node scripts/check-dsh-executor-local.mjs
|
||||
* Any run expected to exceed 10k tokens requires explicit user approval.
|
||||
*/
|
||||
import { buildDshExecutorLaunchPlan, dshExecutorEnabled } from '../dsh-agent-launch.mjs';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { buildDshExecutorLaunchPlan, dshExecutorEnabled, resolveDshCommand } from '../dsh-agent-launch.mjs';
|
||||
|
||||
const cliName = process.env.MEMIND_DSH_BIN ?? process.env.DSH_BIN ?? 'dsh';
|
||||
const pinnedVersion = process.env.MEMIND_DSH_PINNED_VERSION ?? '0.1.1-rc.2';
|
||||
|
||||
function run(cmd, args, options = {}) {
|
||||
return spawnSync(cmd, args, { encoding: 'utf8', ...options });
|
||||
}
|
||||
|
||||
const versionResult = run(cliName, ['--version']);
|
||||
const version = (versionResult.stdout ?? versionResult.stderr ?? '').trim();
|
||||
if (versionResult.status !== 0 || !version) {
|
||||
console.error('DSH_EXECUTOR_FAIL: CLI not found');
|
||||
console.error(` install: npm install -g @deepseek-ai/dsh@${pinnedVersion}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const resolved = resolveDshCommand(process.env);
|
||||
console.log('DSH_EXECUTOR_PROBE:');
|
||||
console.log(` version=${version}`);
|
||||
console.log(` command=${resolved.command}`);
|
||||
console.log(` via_npx=${resolved.viaNpx}`);
|
||||
|
||||
if (version !== pinnedVersion) {
|
||||
console.warn(`DSH_EXECUTOR_WARN: expected ${pinnedVersion}, got ${version}`);
|
||||
}
|
||||
|
||||
const headlessHelp = run(resolved.command, resolved.viaNpx
|
||||
? ['-y', '@deepseek-ai/dsh', '--profile', 'headless', '--help']
|
||||
: ['--profile', 'headless', '--help']);
|
||||
if (headlessHelp.status !== 0) {
|
||||
console.error('DSH_EXECUTOR_FAIL: headless profile unavailable');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (!dshExecutorEnabled(process.env)) {
|
||||
console.log('DSH_EXECUTOR_SKIP: MEMIND_TOOL_GATEWAY_DSH_ENABLED is off');
|
||||
console.log('DSH_EXECUTOR_SKIP: MEMIND_TOOL_GATEWAY_DSH_ENABLED is off (launch plan not checked)');
|
||||
console.log('DSH_EXECUTOR_CLI_OK');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
@@ -23,7 +65,7 @@ console.log(JSON.stringify({
|
||||
ok: plan.ok,
|
||||
executor: plan.executor,
|
||||
command: plan.command,
|
||||
argsPreview: plan.args?.slice?.(0, 4),
|
||||
argsPreview: plan.args?.slice?.(0, 6),
|
||||
cwd: plan.cwd,
|
||||
message: plan.message ?? null,
|
||||
}, null, 2));
|
||||
@@ -33,4 +75,40 @@ if (!plan.ok) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log('DSH_EXECUTOR_OK: dry-run plan ready (use tool-gateway dry-run to execute)');
|
||||
if (process.env.MEMIND_DSH_RUN_LIVE_SMOKE !== '1') {
|
||||
console.log('DSH_EXECUTOR_OK: dry-run plan ready (no LLM; set MEMIND_DSH_RUN_LIVE_SMOKE=1 to execute once)');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
if (!process.env.DEEPSEEK_API_KEY && !process.env.OPENAI_API_KEY) {
|
||||
console.error('DSH_EXECUTOR_FAIL: live smoke requires DEEPSEEK_API_KEY or OPENAI_API_KEY');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.warn('DSH_EXECUTOR_LIVE: spawning one headless task (LLM tokens will be consumed)');
|
||||
const live = spawnSync(plan.command, plan.args, {
|
||||
cwd: plan.cwd,
|
||||
env: { ...process.env, ...plan.env },
|
||||
encoding: 'utf8',
|
||||
maxBuffer: 1024 * 1024,
|
||||
timeout: positiveTimeout(process.env.MEMIND_DSH_LIVE_TIMEOUT_MS, 120_000),
|
||||
});
|
||||
|
||||
if (live.error) {
|
||||
console.error(`DSH_EXECUTOR_FAIL: ${live.error.message}`);
|
||||
process.exit(1);
|
||||
}
|
||||
if (live.status !== 0) {
|
||||
console.error(`DSH_EXECUTOR_FAIL: exit ${live.status}`);
|
||||
if (live.stderr) console.error(live.stderr.slice(0, 2000));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const preview = (live.stdout ?? '').trim().slice(0, 500);
|
||||
console.log(`DSH_EXECUTOR_LIVE_OK: stdout_preview=${JSON.stringify(preview)}`);
|
||||
|
||||
function positiveTimeout(value, fallback) {
|
||||
const n = Number(value);
|
||||
if (!Number.isFinite(n) || n <= 0) return fallback;
|
||||
return Math.floor(n);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user