feat: scaffold redsen-lean-harness v0.1.0
Recovered from crashed session (Node OOM). Repo contains full P0-P6 scaffold: plugin.json/marketplace.json, AGENTS.md, ADRs 0001-0006, lh CLI (init/index/graph/lane/run/memory/host/report/doctor), 10 .github/agents, 12 CLI skills, instructions, context7 mcp.json, and unit/e2e test suite. Fixed: run.mjs read --in-tokens/--out-tokens but tests and CLI docs use --input-tokens/--output-tokens, so telemetry totals were always 0. Now accepts both forms. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import { mkdtempSync, rmSync, mkdirSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join, dirname } from 'node:path';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
export const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');
|
||||
export const CLI = join(ROOT, 'src', 'cli.mjs');
|
||||
|
||||
const created = [];
|
||||
|
||||
export function tempRepo(files = {}) {
|
||||
const dir = mkdtempSync(join(tmpdir(), 'lh-test-'));
|
||||
created.push(dir);
|
||||
git(dir, ['init', '-q', '-b', 'main']);
|
||||
git(dir, ['config', 'user.email', 'test@example.com']);
|
||||
git(dir, ['config', 'user.name', 'Test']);
|
||||
git(dir, ['config', 'commit.gpgsign', 'false']);
|
||||
for (const [rel, body] of Object.entries(files)) write(dir, rel, body);
|
||||
if (Object.keys(files).length) commitAll(dir, 'init');
|
||||
return dir;
|
||||
}
|
||||
|
||||
export function write(dir, rel, body) {
|
||||
const full = join(dir, rel);
|
||||
mkdirSync(dirname(full), { recursive: true });
|
||||
writeFileSync(full, body);
|
||||
return full;
|
||||
}
|
||||
|
||||
export function git(dir, args) {
|
||||
return execFileSync('git', args, { cwd: dir, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });
|
||||
}
|
||||
|
||||
export function commitAll(dir, msg) {
|
||||
git(dir, ['add', '-A']);
|
||||
git(dir, ['commit', '-qm', msg]);
|
||||
}
|
||||
|
||||
/** Run the lh CLI. Never throws — returns {code, stdout, stderr}. */
|
||||
export function lh(dir, args) {
|
||||
try {
|
||||
const stdout = execFileSync(process.execPath, [CLI, ...args], {
|
||||
cwd: dir, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'],
|
||||
});
|
||||
return { code: 0, stdout, stderr: '' };
|
||||
} catch (e) {
|
||||
return { code: e.status ?? 1, stdout: e.stdout ?? '', stderr: e.stderr ?? '' };
|
||||
}
|
||||
}
|
||||
|
||||
export function cleanup() {
|
||||
while (created.length) {
|
||||
try { rmSync(created.pop(), { recursive: true, force: true }); } catch {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user