chore: import ovis-composer into repo with baseline tests

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
FactorandClaude Sonnet 5.5 committed 2026-11-19 11:06:12 +01:00
1 parent edf09cf532
commit c05e252d79
21 files changed
+4312

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
import test from "node:test";
import assert from "node:assert/strict";
import {
targetAgent, agentKey, agentName, agentStatus, createGate, gatePasses, openGate, closeGate,
isPlainEnter, statusText, queueLabel, applySuggestion, insertedNewline,
} from "../mod/ovis-composer/view.js";
const agents = [{ address: "t1", app: "claude-code" }, { address: "a2" }];
test("targetAgent picks by focused.terminal, then focused.agent", () => {
assert.equal(targetAgent(agents, { terminal: "t1" }), agents[0]);
assert.equal(targetAgent(agents, { agent: "a2" }), agents[1]);
assert.equal(targetAgent(agents, { terminal: "zz" }), null);
assert.equal(targetAgent(agents, null), null);
});
test("agentKey/agentName/agentStatus", () => {
assert.equal(agentKey({ address: " x " }), "x");
assert.equal(agentName({ program: { key: "k" } }), "k");
assert.equal(agentName(null), "default");
assert.equal(agentStatus({}), "idle");
});
test("gate: opens after a seen turn, or outright", () => {
let g = createGate();
assert.equal(gatePasses(g, "idle"), false);
assert.equal(gatePasses({ sawWorking: true }, "done"), true);
g = openGate(g);
assert.equal(gatePasses(g, "working"), true);
g = closeGate(g);
assert.equal(gatePasses(g, "idle"), false);
});
test("isPlainEnter", () => {
assert.equal(isPlainEnter({}), true);
assert.equal(isPlainEnter({ shift: true }), false);
assert.equal(isPlainEnter({ secondary: true }), false);
assert.equal(isPlainEnter(null), false);
});
test("labels", () => {
assert.equal(statusText("working"), "pracuje");
assert.equal(statusText("x"), "gotowy");
assert.equal(queueLabel({ state: "queued" }), "Następna tura");
assert.equal(queueLabel({}), "");
});
test("applySuggestion replaces token and places caret", () => {
assert.deepEqual(applySuggestion("ala /re", 7, { start: 4 }, "/review "), { value: "ala /review ", caret: 12 });
});
test("insertedNewline finds the index", () => {
assert.deepEqual(insertedNewline("ab", "a\nb"), { index: 1 });
assert.equal(insertedNewline("ab", "abc"), null);
});