refactor: restructure into herdr/herdr-composer, rename ovis-composer -> herdr-composer, migrate stored data
Co-Authored-By: Ovis Fast (Claude) <[email protected]>
This commit is contained in:
1 parent
6beecaac83
commit
74c1dfaeb8
27 files changed
+253
-97
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { LIMITS, validate, validateMany, mention, removeMention } from "../mod/ovis-composer/attachments.js";
|
||||
import { LIMITS, validate, validateMany, mention, removeMention } from "../herdr/herdr-composer/mods/herdr-composer/attachments.js";
|
||||
|
||||
test("validate rejects over 32 MiB", () => {
|
||||
const r = validate({ bytes: 33 * 2 ** 20 });
|
||||
@@ -59,7 +59,7 @@ test("removeMention takes the quoted form and the bare form out", () => {
|
||||
assert.equal(removeMention('see @"/a b/c.png"x now', "/a b/c.png"), 'see @"/a b/c.png"x now');
|
||||
});
|
||||
|
||||
import { formatBytes } from "../mod/ovis-composer/attachments.js";
|
||||
import { formatBytes } from "../herdr/herdr-composer/mods/herdr-composer/attachments.js";
|
||||
|
||||
test("formatBytes", () => {
|
||||
assert.equal(formatBytes(0), "0 B");
|
||||
@@ -71,12 +71,12 @@ test("formatBytes", () => {
|
||||
assert.equal(formatBytes(NaN), "");
|
||||
});
|
||||
|
||||
import { relativeTo } from "../mod/ovis-composer/attachments.js";
|
||||
import { relativeTo } from "../herdr/herdr-composer/mods/herdr-composer/attachments.js";
|
||||
|
||||
test("relativeTo: a file inside the folder, forward slashes, any case", () => {
|
||||
assert.equal(
|
||||
relativeTo("C:\\Users\\Factor\\.config\\herdr-app", "C:\\Users\\Factor\\.config\\herdr-app\\data\\ovis-composer\\paste\\paste-1.png"),
|
||||
"data/ovis-composer/paste/paste-1.png",
|
||||
relativeTo("C:\\Users\\Factor\\.config\\herdr-app", "C:\\Users\\Factor\\.config\\herdr-app\\data\\herdr-composer\\paste\\paste-1.png"),
|
||||
"data/herdr-composer/paste/paste-1.png",
|
||||
);
|
||||
assert.equal(relativeTo("c:/users/factor/.config/herdr-app/", "C:\\Users\\Factor\\.config\\herdr-app\\a b\\ę.png"), "a b/ę.png");
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ import assert from "node:assert/strict";
|
||||
import {
|
||||
clipboardScript, parseClipboardResult, pickerScript, parsePickerResult,
|
||||
sizeScript, parseSizeResult, staleFiles, supportsImages,
|
||||
} from "../mod/ovis-composer/clipboard.js";
|
||||
} from "../herdr/herdr-composer/mods/herdr-composer/clipboard.js";
|
||||
|
||||
const ok = (stdout) => ({ code: 0, stdout, stderr: "" });
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { decide, gateAfter, onRestart, shouldDrain, shouldStartCountdown, drain } from "../mod/ovis-composer/delivery.js";
|
||||
import { decide, gateAfter, onRestart, shouldDrain, shouldStartCountdown, drain } from "../herdr/herdr-composer/mods/herdr-composer/delivery.js";
|
||||
|
||||
test("decide idle/done -> send", () => {
|
||||
assert.equal(decide("idle").kind, "send");
|
||||
@@ -56,7 +56,7 @@ test("onRestart: countdown -> held without left, sending -> uncertain", () => {
|
||||
});
|
||||
|
||||
test("drain sends an entry whose countdown ran out", async () => {
|
||||
const { createState, reduce } = await import("../mod/ovis-composer/state.js");
|
||||
const { createState, reduce } = await import("../herdr/herdr-composer/mods/herdr-composer/state.js");
|
||||
let s = reduce(createState(), { type: "queue", agent: "t2", item: { id: "1", text: "a", createdAt: 1 } });
|
||||
s = reduce(s, { type: "countdown_start", agent: "t2", id: "1" });
|
||||
const calls = [];
|
||||
@@ -106,7 +106,7 @@ test("shouldStartCountdown tolerates a non-array queue", () => {
|
||||
assert.equal(shouldStartCountdown(sc({ queue: null })), false);
|
||||
});
|
||||
|
||||
import { queueBlocksDirectSend } from "../mod/ovis-composer/delivery.js";
|
||||
import { queueBlocksDirectSend } from "../herdr/herdr-composer/mods/herdr-composer/delivery.js";
|
||||
|
||||
test("queueBlocksDirectSend: a message that waits (queued or counting down) goes first", () => {
|
||||
assert.equal(queueBlocksDirectSend([{ state: "queued" }]), true);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { record, search, toggleFavorite, isFavorite } from "../mod/ovis-composer/history.js";
|
||||
import { loadHistory, saveHistory, loadFavorites, saveFavorites, KEYS } from "../mod/ovis-composer/storage.js";
|
||||
import { record, search, toggleFavorite, isFavorite } from "../herdr/herdr-composer/mods/herdr-composer/history.js";
|
||||
import { loadHistory, saveHistory, loadFavorites, saveFavorites, KEYS } from "../herdr/herdr-composer/mods/herdr-composer/storage.js";
|
||||
|
||||
const memStore = () => {
|
||||
const m = new Map();
|
||||
@@ -107,7 +107,7 @@ test("storage: old favourites (at) load as createdAt", () => {
|
||||
assert.equal(loadFavorites(store)[0].createdAt, 4);
|
||||
});
|
||||
|
||||
import { segments, formatMoment, entryMeta, panelState, moveIndex, otherTab } from "../mod/ovis-composer/history.js";
|
||||
import { segments, formatMoment, entryMeta, panelState, moveIndex, otherTab } from "../herdr/herdr-composer/mods/herdr-composer/history.js";
|
||||
|
||||
test("segments splits a text on the ranges", () => {
|
||||
assert.deepEqual(segments("uruchom testy", [[8, 12]]), [
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { keyIntent } from "../mod/ovis-composer/keys.js";
|
||||
import { keyIntent } from "../herdr/herdr-composer/mods/herdr-composer/keys.js";
|
||||
|
||||
const ev = (key, mods = {}) => ({ key, shift: false, ctrl: false, alt: false, composing: false, ...mods });
|
||||
const ctx = (o = {}) => ({ hasKeyboard: true, menuOpen: false, panelOpen: false, empty: false, status: null, ...o });
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { sendArgs, parseSendArgs, sendNow } from "../mod/ovis-composer/delivery.js";
|
||||
import { sendArgs, parseSendArgs, sendNow } from "../herdr/herdr-composer/mods/herdr-composer/delivery.js";
|
||||
|
||||
const ok = { code: 0, stdout: "{}", stderr: "" };
|
||||
|
||||
@@ -49,8 +49,8 @@ test("--force is only there when asked for, and before the `--`", async () => {
|
||||
});
|
||||
|
||||
test("the queue never forces: drain sends without --force", async () => {
|
||||
const { createState, reduce } = await import("../mod/ovis-composer/state.js");
|
||||
const { drain } = await import("../mod/ovis-composer/delivery.js");
|
||||
const { createState, reduce } = await import("../herdr/herdr-composer/mods/herdr-composer/state.js");
|
||||
const { drain } = await import("../herdr/herdr-composer/mods/herdr-composer/delivery.js");
|
||||
const state = reduce(createState(), { type: "queue", agent: "t2", item: { id: "1", text: "q", createdAt: 1 } });
|
||||
const calls = [];
|
||||
const result = await drain(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { createState, reduce, isSending } from "../mod/ovis-composer/state.js";
|
||||
import { createState, reduce, isSending } from "../herdr/herdr-composer/mods/herdr-composer/state.js";
|
||||
|
||||
test("createState starts empty", () => {
|
||||
const s = createState();
|
||||
|
||||
+98
-11
@@ -3,7 +3,7 @@ import assert from "node:assert/strict";
|
||||
import {
|
||||
HISTORY_LIMIT, queueKey, loadHistory, saveHistory, loadQueue, saveQueue, loadUsage, saveUsage,
|
||||
KEYS, draftKey, loadDraft, saveDraft,
|
||||
} from "../mod/ovis-composer/storage.js";
|
||||
} from "../herdr/herdr-composer/mods/herdr-composer/storage.js";
|
||||
|
||||
const memStore = () => {
|
||||
const m = new Map();
|
||||
@@ -23,12 +23,12 @@ test("saveHistory truncates to 500, keeping the newest", () => {
|
||||
|
||||
test("history drops invalid entries on load", () => {
|
||||
const store = memStore();
|
||||
store.set("ovis-composer.history", [{ id: "a", text: "x", at: 1 }, { id: "b" }, null]);
|
||||
store.set("herdr-composer.history", [{ id: "a", text: "x", at: 1 }, { id: "b" }, null]);
|
||||
assert.equal(loadHistory(store).length, 1);
|
||||
});
|
||||
|
||||
test("queueKey is per agent", () => {
|
||||
assert.equal(queueKey("a1"), "ovis-composer.queue:a1");
|
||||
assert.equal(queueKey("a1"), "herdr-composer.queue:a1");
|
||||
});
|
||||
|
||||
test("queue roundtrip; keeps sending state as written", () => {
|
||||
@@ -42,7 +42,7 @@ test("queue roundtrip; keeps sending state as written", () => {
|
||||
test("saveQueue ignores empty agent", () => {
|
||||
const store = memStore();
|
||||
saveQueue(store, "", [{ id: "1", text: "t", state: "queued", createdAt: 1 }]);
|
||||
assert.equal(store.get("ovis-composer.queue:"), undefined);
|
||||
assert.equal(store.get("herdr-composer.queue:"), undefined);
|
||||
});
|
||||
|
||||
test("usage keeps only non-negative finite numbers", () => {
|
||||
@@ -64,8 +64,8 @@ const draft = (over = {}) => ({
|
||||
});
|
||||
|
||||
test("draftKey is per agent", () => {
|
||||
assert.equal(KEYS.draft, "ovis-composer.draft");
|
||||
assert.equal(draftKey("t2"), "ovis-composer.draft:t2");
|
||||
assert.equal(KEYS.draft, "herdr-composer.draft");
|
||||
assert.equal(draftKey("t2"), "herdr-composer.draft:t2");
|
||||
});
|
||||
|
||||
test("draft roundtrip", () => {
|
||||
@@ -97,7 +97,7 @@ test("saveDraft ignores rubbish and empty agent", () => {
|
||||
saveDraft(store, "t2", "x");
|
||||
saveDraft(store, "", draft());
|
||||
assert.equal(loadDraft(store, "t2").text, "hello");
|
||||
assert.equal(store.get("ovis-composer.draft:"), undefined);
|
||||
assert.equal(store.get("herdr-composer.draft:"), undefined);
|
||||
});
|
||||
|
||||
test("empty draft overwrites the old one", () => {
|
||||
@@ -133,7 +133,7 @@ test("queue roundtrip keeps a countdown entry (restart turns it into held)", ()
|
||||
assert.deepEqual(loadQueue(store, "a"), q);
|
||||
});
|
||||
|
||||
import { loadUserMin, saveUserMin } from "../mod/ovis-composer/storage.js";
|
||||
import { loadUserMin, saveUserMin } from "../herdr/herdr-composer/mods/herdr-composer/storage.js";
|
||||
|
||||
test("userMin: the height the person dragged the composer to; 0 is none", () => {
|
||||
const store = memStore();
|
||||
@@ -142,10 +142,97 @@ test("userMin: the height the person dragged the composer to; 0 is none", () =>
|
||||
assert.equal(loadUserMin(store), 300);
|
||||
saveUserMin(store, 0);
|
||||
assert.equal(loadUserMin(store), 0);
|
||||
store.set("ovis-composer.userMin", "x");
|
||||
store.set("herdr-composer.userMin", "x");
|
||||
assert.equal(loadUserMin(store), 0);
|
||||
store.set("ovis-composer.userMin", -5);
|
||||
store.set("herdr-composer.userMin", -5);
|
||||
assert.equal(loadUserMin(store), 0);
|
||||
saveUserMin(store, NaN);
|
||||
assert.equal(store.get("ovis-composer.userMin"), -5);
|
||||
assert.equal(store.get("herdr-composer.userMin"), -5);
|
||||
});
|
||||
|
||||
// --- the rename ovis-composer -> herdr-composer: nothing the person kept is lost
|
||||
|
||||
import { LEGACY_PREFIX, loadFavorites } from "../herdr/herdr-composer/mods/herdr-composer/storage.js";
|
||||
|
||||
const OLD = "ovis-composer.";
|
||||
const NEW = "herdr-composer.";
|
||||
|
||||
test("migration: the legacy prefix", () => {
|
||||
assert.equal(LEGACY_PREFIX, "ovis-composer.");
|
||||
assert.equal(KEYS.history, "herdr-composer.history");
|
||||
assert.equal(queueKey("t2"), "herdr-composer.queue:t2");
|
||||
assert.equal(draftKey("t2"), "herdr-composer.draft:t2");
|
||||
});
|
||||
|
||||
test("migration: the new key wins over the old one", () => {
|
||||
const store = memStore();
|
||||
store.set(OLD + "history", [{ id: "old", text: "old", at: 1 }]);
|
||||
store.set(NEW + "history", [{ id: "new", text: "new", sentAt: 2 }]);
|
||||
assert.deepEqual(loadHistory(store).map((e) => e.id), ["new"]);
|
||||
});
|
||||
|
||||
test("migration: history from the old key is read and written under the new one; the old stays", () => {
|
||||
const store = memStore();
|
||||
const old = [{ id: "old", text: "old", at: 1 }];
|
||||
store.set(OLD + "history", old);
|
||||
assert.deepEqual(loadHistory(store).map((e) => e.id), ["old"]);
|
||||
assert.deepEqual(store.get(NEW + "history"), old);
|
||||
assert.deepEqual(store.get(OLD + "history"), old);
|
||||
});
|
||||
|
||||
test("migration: favourites, usage, queue, draft and userMin come across the same way", () => {
|
||||
const store = memStore();
|
||||
store.set(OLD + "favorites", [{ id: "f", text: "x", at: 4 }]);
|
||||
store.set(OLD + "usage", { review: 2 });
|
||||
store.set(OLD + "queue:t2", [{ id: "1", text: "t", state: "held", createdAt: 5 }]);
|
||||
store.set(OLD + "draft:t2", { text: "szkic", caret: 2, attachments: [], identity: { created_ms: 9, app: null }, savedAt: 1 });
|
||||
store.set(OLD + "userMin", 300);
|
||||
|
||||
assert.equal(loadFavorites(store)[0].createdAt, 4);
|
||||
assert.deepEqual(loadUsage(store), { review: 2 });
|
||||
assert.equal(loadQueue(store, "t2")[0].state, "held");
|
||||
assert.equal(loadDraft(store, "t2").text, "szkic");
|
||||
assert.equal(loadUserMin(store), 300);
|
||||
|
||||
for (const key of ["favorites", "usage", "queue:t2", "draft:t2", "userMin"]) {
|
||||
assert.notEqual(store.get(NEW + key), undefined, key);
|
||||
assert.notEqual(store.get(OLD + key), undefined, key);
|
||||
}
|
||||
});
|
||||
|
||||
test("migration: neither key -> the defaults, and nothing is written", () => {
|
||||
const store = memStore();
|
||||
assert.deepEqual(loadHistory(store), []);
|
||||
assert.deepEqual(loadFavorites(store), []);
|
||||
assert.deepEqual(loadUsage(store), {});
|
||||
assert.deepEqual(loadQueue(store, "t2"), []);
|
||||
assert.equal(loadDraft(store, "t2"), null);
|
||||
assert.equal(loadUserMin(store), 0);
|
||||
assert.equal(store.get(NEW + "history"), undefined);
|
||||
assert.equal(store.get(NEW + "draft:t2"), undefined);
|
||||
});
|
||||
|
||||
test("migration: rubbish in the old key is ignored as before, and not copied", () => {
|
||||
const store = memStore();
|
||||
store.set(OLD + "history", "x");
|
||||
store.set(OLD + "favorites", [{ nope: 1 }]);
|
||||
store.set(OLD + "queue:t2", [{ id: "1" }]);
|
||||
store.set(OLD + "draft:t2", [1, 2]);
|
||||
store.set(OLD + "usage", { a: -1, b: "x" });
|
||||
store.set(OLD + "userMin", -3);
|
||||
assert.deepEqual(loadHistory(store), []);
|
||||
assert.deepEqual(loadFavorites(store), []);
|
||||
assert.deepEqual(loadQueue(store, "t2"), []);
|
||||
assert.equal(loadDraft(store, "t2"), null);
|
||||
assert.deepEqual(loadUsage(store), {});
|
||||
assert.equal(loadUserMin(store), 0);
|
||||
for (const key of ["history", "favorites", "queue:t2", "draft:t2", "usage", "userMin"]) {
|
||||
assert.equal(store.get(NEW + key), undefined, key);
|
||||
}
|
||||
});
|
||||
|
||||
test("migration: a store that cannot be written to still reads the old data", () => {
|
||||
const raw = new Map([[OLD + "history", [{ id: "old", text: "old", at: 1 }]]]);
|
||||
const store = { get: (k) => raw.get(k), set: () => { throw new Error("read-only"); } };
|
||||
assert.deepEqual(loadHistory(store).map((e) => e.id), ["old"]);
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { detect, startsLine, rank, merge, GROUPS } from "../mod/ovis-composer/suggest.js";
|
||||
import { detect, startsLine, rank, merge, GROUPS } from "../herdr/herdr-composer/mods/herdr-composer/suggest.js";
|
||||
|
||||
test("detect finds a slash command at caret", () => {
|
||||
assert.deepEqual(detect("ala /re", 7), { trigger: "/", needle: "re", start: 4 });
|
||||
|
||||
+6
-6
@@ -3,7 +3,7 @@ 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";
|
||||
} from "../herdr/herdr-composer/mods/herdr-composer/view.js";
|
||||
|
||||
const agents = [{ address: "t1", app: "claude-code" }, { address: "a2" }];
|
||||
|
||||
@@ -55,7 +55,7 @@ test("insertedNewline finds the index", () => {
|
||||
});
|
||||
|
||||
test("canAutoSend waits for the draft/identity check of the agent", async () => {
|
||||
const { canAutoSend } = await import("../mod/ovis-composer/view.js");
|
||||
const { canAutoSend } = await import("../herdr/herdr-composer/mods/herdr-composer/view.js");
|
||||
assert.equal(canAutoSend(new Set(), "t2"), false);
|
||||
assert.equal(canAutoSend(new Set(["t2"]), "t2"), true);
|
||||
assert.equal(canAutoSend(new Set(["t3"]), "t2"), false);
|
||||
@@ -70,7 +70,7 @@ test("queueLabel for every state", () => {
|
||||
assert.equal(queueLabel({ state: "countdown", left: 2 }), "Wysyłam za 2 s");
|
||||
});
|
||||
|
||||
import { stillSameAgent } from "../mod/ovis-composer/view.js";
|
||||
import { stillSameAgent } from "../herdr/herdr-composer/mods/herdr-composer/view.js";
|
||||
|
||||
test("stillSameAgent: only when the field and the focus are on one agent", () => {
|
||||
assert.equal(stillSameAgent({ before: "t2", after: "t2", target: "t2" }), true);
|
||||
@@ -82,7 +82,7 @@ test("stillSameAgent: only when the field and the focus are on one agent", () =>
|
||||
assert.equal(stillSameAgent({ before: "", after: "t2", target: "t2" }), false);
|
||||
});
|
||||
|
||||
import { directSendBlocked } from "../mod/ovis-composer/view.js";
|
||||
import { directSendBlocked } from "../herdr/herdr-composer/mods/herdr-composer/view.js";
|
||||
|
||||
test("directSendBlocked: who must wait behind the queue", () => {
|
||||
const queue = [{ state: "queued" }];
|
||||
@@ -101,7 +101,7 @@ test("directSendBlocked: who must wait behind the queue", () => {
|
||||
assert.equal(directSendBlocked({ draining: false, mode: "auto", status: "idle", queue: [{ state: "held" }] }), false);
|
||||
});
|
||||
|
||||
import { blockTargetPx, shouldResize, isManualResize } from "../mod/ovis-composer/view.js";
|
||||
import { blockTargetPx, shouldResize, isManualResize } from "../herdr/herdr-composer/mods/herdr-composer/view.js";
|
||||
|
||||
const fit = (over = {}) => ({ contentHeight: 100, padding: 16, zoom: 1.2, userMin: 0, min: 120, max: 520, ...over });
|
||||
|
||||
@@ -145,7 +145,7 @@ test("isManualResize: a height nobody ordered is the person's drag", () => {
|
||||
assert.equal(isManualResize({ reportedPx: NaN, orderedPx: 200 }), false);
|
||||
});
|
||||
|
||||
import { luminance, fieldBackground } from "../mod/ovis-composer/view.js";
|
||||
import { luminance, fieldBackground } from "../herdr/herdr-composer/mods/herdr-composer/view.js";
|
||||
|
||||
test("luminance: black is darker than grey is darker than white; alpha and rubbish are tolerated", () => {
|
||||
assert.ok(luminance("#000000") < luminance("#808080"));
|
||||
|
||||
Reference in new issue
Block a user