feat: per-change-block hunk actions (#50), codex lanes without a pipeline, macOS LaunchAgent
- git (#50): stage-hunk/discard-hunk take an optional `block` — one run of consecutive +/- lines inside an @@ hunk. `onlyBlock` (server/lib/git-diff.js) cuts git's fresh hunk down to it, folding the other blocks into the side being checked; LaneDiffView hangs one review bar per block (unified + split) and its arrows walk blocks. - git exclude: entries AgentHub writes for a lane go to the COMMON git dir with the lane's path prefix (server/lib/git-exclude.js, used by router-apply and lane-mcp) — a linked worktree's own info/exclude is never read by git, and a subdir lane has no .git. MCP sync no longer fails with ENOTDIR on a worktree lane or creates a stray .git in a non-repo lane. - codex lanes carry no pipeline: codex-ingest mirrors only idle/running, codex-nudge is removed, agents install writes nothing for codex, the Workspace hides stage/pipeline/feature pickers/PipelineMap for them, and every server start clears leftover codex stage data and the old AGENTS.md stage block. - Changes panel: a whole file opens for reading and enters the editor on a click on its text (caret at the clicked line), not automatically. - macOS: LaunchAgent start-at-login (scripts/launchd-service.js, picked by scripts/service-manager.js). - Adds the AgentHub introduction slides and their image-embedding script.
This commit is contained in:
@@ -18,7 +18,7 @@ const { describe, it, after } = require("node:test");
|
||||
const assert = require("node:assert/strict");
|
||||
|
||||
const lanesLib = require("../lib/lanes");
|
||||
const { installAgents } = require("../lib/lane-agents");
|
||||
const { installAgents, removeStageDoc } = require("../lib/lane-agents");
|
||||
|
||||
after(() => fs.rmSync(SUITE_ROOT, { recursive: true, force: true }));
|
||||
|
||||
@@ -116,29 +116,77 @@ describe("installAgents", () => {
|
||||
assert.ok(fs.existsSync(path.join(cwd, ".claude", "agents")));
|
||||
});
|
||||
|
||||
it("installs the AGENTS.md stage block for a codex lane, not .claude/agents/", async () => {
|
||||
it("installs nothing for a codex lane — no .claude/agents/, no AGENTS.md", async () => {
|
||||
const cwd = makeRepoDir();
|
||||
const lane = lanesLib.createLane({ title: "cx", cwd, kind: "managed", tool: "codex" });
|
||||
|
||||
const result = await installAgents(lane);
|
||||
assert.deepEqual(result.installed, ["AGENTS.md"]);
|
||||
assert.deepEqual(result.installed, []);
|
||||
assert.equal(fs.existsSync(path.join(cwd, ".claude", "agents")), false);
|
||||
const doc = fs.readFileSync(path.join(cwd, "AGENTS.md"), "utf8");
|
||||
assert.match(doc, /agenthub stage <stage> --tool codex/);
|
||||
});
|
||||
|
||||
it("preserves the user's own AGENTS.md prose and replaces only the block", async () => {
|
||||
const cwd = makeRepoDir();
|
||||
const lane = lanesLib.createLane({ title: "cx", cwd, kind: "managed", tool: "codex" });
|
||||
const file = path.join(cwd, "AGENTS.md");
|
||||
fs.writeFileSync(file, "# House rules\n\nNever force-push.\n");
|
||||
|
||||
await installAgents(lane);
|
||||
await installAgents(lane); // reinstall must not duplicate the block
|
||||
|
||||
const doc = fs.readFileSync(file, "utf8");
|
||||
assert.match(doc, /Never force-push\./);
|
||||
assert.equal(doc.split("<!-- agenthub:stage:start -->").length - 1, 1);
|
||||
assert.equal(doc.split("<!-- agenthub:stage:end -->").length - 1, 1);
|
||||
assert.equal(fs.existsSync(path.join(cwd, "AGENTS.md")), false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("codex pipeline cleanup", () => {
|
||||
const START = "<!-- agenthub:stage:start -->";
|
||||
const END = "<!-- agenthub:stage:end -->";
|
||||
const BLOCK = `${START}\n## Declare your lane stage as you work\n\nagenthub stage …\n${END}\n`;
|
||||
|
||||
it("removes only the AgentHub block, keeping the user's own AGENTS.md prose", () => {
|
||||
const cwd = makeRepoDir();
|
||||
const file = path.join(cwd, "AGENTS.md");
|
||||
fs.writeFileSync(file, `# House rules\n\nNever force-push.\n\n${BLOCK}\n## More\n\nKeep me.\n`);
|
||||
|
||||
assert.equal(removeStageDoc(cwd), true);
|
||||
const doc = fs.readFileSync(file, "utf8");
|
||||
assert.ok(!doc.includes(START) && !doc.includes(END));
|
||||
assert.match(doc, /Never force-push\./);
|
||||
assert.match(doc, /Keep me\./);
|
||||
});
|
||||
|
||||
it("deletes an AGENTS.md that held nothing but the block", () => {
|
||||
const cwd = makeRepoDir();
|
||||
fs.writeFileSync(path.join(cwd, "AGENTS.md"), BLOCK);
|
||||
assert.equal(removeStageDoc(cwd), true);
|
||||
assert.equal(fs.existsSync(path.join(cwd, "AGENTS.md")), false);
|
||||
});
|
||||
|
||||
it("leaves a file without the block, or no file at all, untouched", () => {
|
||||
const cwd = makeRepoDir();
|
||||
assert.equal(removeStageDoc(cwd), false);
|
||||
fs.writeFileSync(path.join(cwd, "AGENTS.md"), "# Mine\n");
|
||||
assert.equal(removeStageDoc(cwd), false);
|
||||
assert.equal(fs.readFileSync(path.join(cwd, "AGENTS.md"), "utf8"), "# Mine\n");
|
||||
});
|
||||
|
||||
it("wipes a codex lane's stage, detection, stage log and features — and no claude lane's", () => {
|
||||
const codex = lanesLib.createLane({ title: "cx", cwd: makeRepoDir(), tool: "codex" });
|
||||
const claude = lanesLib.createLane({ title: "cc", cwd: makeRepoDir(), tool: "claude" });
|
||||
for (const lane of [codex, claude]) {
|
||||
lanesLib.setStage(lane.id, { stage: "tests", evidence: "old" });
|
||||
lanesLib.recordDetection(lane.id, { nodeId: "review", signal: "npm test" });
|
||||
}
|
||||
const { db } = require("../db");
|
||||
const insertFeature = db.prepare("INSERT INTO lane_features (lane_id, slug) VALUES (?, ?)");
|
||||
insertFeature.run(codex.id, "old-feature");
|
||||
insertFeature.run(claude.id, "kept-feature");
|
||||
|
||||
assert.equal(lanesLib.clearCodexPipelines(), 1);
|
||||
|
||||
const cx = lanesLib.getLane(codex.id);
|
||||
assert.equal(cx.stage, "idle");
|
||||
assert.deepEqual(cx.stages, {});
|
||||
assert.equal(cx.detected_stage, null);
|
||||
const count = (table, id) =>
|
||||
db.prepare(`SELECT COUNT(*) AS n FROM ${table} WHERE lane_id = ?`).get(id).n;
|
||||
assert.equal(count("lane_stage_events", codex.id), 0);
|
||||
assert.equal(count("lane_features", codex.id), 0);
|
||||
|
||||
const cc = lanesLib.getLane(claude.id);
|
||||
assert.equal(cc.stage, "tests");
|
||||
assert.ok(count("lane_stage_events", claude.id) > 0);
|
||||
assert.equal(count("lane_features", claude.id), 1);
|
||||
|
||||
assert.equal(lanesLib.clearCodexPipelines(), 0); // idempotent
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user