@litfamily/litclaude 1.0.44 → 1.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/README.md +8 -8
- package/README_ko-KR.md +8 -8
- package/bin/litclaude-ai.js +173 -4
- package/docs/assets/readme/badge-version.svg +1 -1
- package/package.json +1 -1
- package/plugins/litclaude/.claude-plugin/plugin.json +1 -1
- package/plugins/litclaude/bin/litclaude-ai +1 -0
- package/plugins/litclaude/bin/litclaude-hook.js +21 -7
- package/plugins/litclaude/bin/litclaude-mcp.js +1 -1
- package/plugins/litclaude/hooks/hooks.json +1 -1
- package/plugins/litclaude/lib/agent-file/apply.mjs +150 -0
- package/plugins/litclaude/lib/agent-file/attribution.mjs +62 -0
- package/plugins/litclaude/lib/agent-file/block.md +12 -0
- package/plugins/litclaude/lib/agent-file/cli.mjs +71 -0
- package/plugins/litclaude/lib/agent-file/managed-block.mjs +82 -0
- package/plugins/litclaude/lib/agent-file/project-block.md +9 -0
- package/plugins/litclaude/lib/canonical-skill-resources.mjs +8 -8
- package/plugins/litclaude/lib/mark.mjs +23 -6
- package/plugins/litclaude/lib/rewind/brief.mjs +12 -2
- package/plugins/litclaude/lib/rewind/collect.mjs +25 -7
- package/plugins/litclaude/lib/rewind/next-step.mjs +21 -3
- package/plugins/litclaude/lib/start-work-lifecycle.mjs +4 -2
- package/plugins/litclaude/skills/lit-adhd/SKILL.md +5 -4
- package/plugins/litclaude/skills/lit-init/SKILL.md +12 -0
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage.mjs +4 -1
- package/plugins/litclaude/skills/lit-typographic-motion/engine/stage/init.js +13 -0
- package/plugins/litclaude/skills/readme-studio/templates/hyperframes-cover/package-lock.json +4 -4
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// The LitFamily block on disk: the global `CLAUDE.md` that Claude Code reads every session, and a
|
|
2
|
+
// project's `AGENTS.md`. Writes are atomic (temporary file, then rename) and keep the file's mode; a
|
|
3
|
+
// symlinked, non-regular or non-UTF-8 file is refused rather than rewritten; a file system error comes
|
|
4
|
+
// back as `refused-io` instead of stopping the installer. The user's original global file is copied
|
|
5
|
+
// once, the first time a block goes in. The on/off setting is `agentFile` in LitClaude's own
|
|
6
|
+
// config.json; LITCLAUDE_AGENT_FILE overrides it.
|
|
7
|
+
|
|
8
|
+
import { randomUUID } from "node:crypto";
|
|
9
|
+
import { chmodSync, copyFileSync, lstatSync, mkdirSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
10
|
+
import { dirname, join } from "node:path";
|
|
11
|
+
import { fileURLToPath } from "node:url";
|
|
12
|
+
|
|
13
|
+
import { readLitConfigKey, writeLitConfigKey } from "../mark.mjs";
|
|
14
|
+
import { ATTRIBUTION_LINE } from "./attribution.mjs";
|
|
15
|
+
import { inspectBlock, ManagedBlockError, removeBlock, upsertBlock } from "./managed-block.mjs";
|
|
16
|
+
|
|
17
|
+
export const AGENT_FILE_ID = "litclaude";
|
|
18
|
+
export const AGENT_FILE_MODES = Object.freeze(["on", "off"]);
|
|
19
|
+
// The global block is read on every turn of every session, so it stays small.
|
|
20
|
+
export const AGENT_FILE_MAX_BYTES = 1200;
|
|
21
|
+
|
|
22
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
23
|
+
const BODIES = { global: "block.md", project: "project-block.md" };
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The shipped block text: `global` for CLAUDE.md, `project` for a repo's AGENTS.md. With attribution
|
|
27
|
+
* `off` it carries the no-attribution line, before the global block's closing off-switch line.
|
|
28
|
+
*/
|
|
29
|
+
export const agentFileBody = (kind = "global", { attribution = "keep" } = {}) => {
|
|
30
|
+
const body = readFileSync(join(here, BODIES[kind]), "utf8");
|
|
31
|
+
if (attribution !== "off") return body;
|
|
32
|
+
const offSwitch = body.indexOf("\n- Turn this block off");
|
|
33
|
+
return offSwitch === -1
|
|
34
|
+
? `${body.replace(/\n*$/u, "\n")}${ATTRIBUTION_LINE}\n`
|
|
35
|
+
: `${body.slice(0, offSwitch + 1)}${ATTRIBUTION_LINE}\n${body.slice(offSwitch + 1)}`;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const readAgentFileMode = ({ env = process.env, litHome }) => {
|
|
39
|
+
const override = String(env.LITCLAUDE_AGENT_FILE ?? "").trim().toLowerCase();
|
|
40
|
+
if (AGENT_FILE_MODES.includes(override)) return override;
|
|
41
|
+
const stored = readLitConfigKey(litHome, "agentFile");
|
|
42
|
+
return AGENT_FILE_MODES.includes(stored) ? stored : "on";
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const writeAgentFileMode = (litHome, mode) => {
|
|
46
|
+
if (!AGENT_FILE_MODES.includes(mode)) throw new Error(`agentFile takes one of: ${AGENT_FILE_MODES.join(", ")}`);
|
|
47
|
+
return writeLitConfigKey(litHome, "agentFile", mode);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// "missing", "file", "symlink" or "other", without following a link.
|
|
51
|
+
const entryKind = (path) => {
|
|
52
|
+
try {
|
|
53
|
+
const stats = lstatSync(path);
|
|
54
|
+
return stats.isSymbolicLink() ? "symlink" : stats.isFile() ? "file" : "other";
|
|
55
|
+
} catch (error) {
|
|
56
|
+
if (error.code === "ENOENT") return "missing";
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// The file's text, or null when it is not UTF-8 (a UTF-16 file from Notepad, Latin-1): rewriting
|
|
62
|
+
// those would corrupt the user's bytes outside the markers.
|
|
63
|
+
const readUtf8 = (path) => {
|
|
64
|
+
const bytes = readFileSync(path);
|
|
65
|
+
if (bytes.includes(0) || (bytes[0] === 0xff && bytes[1] === 0xfe) || (bytes[0] === 0xfe && bytes[1] === 0xff)) return null;
|
|
66
|
+
try {
|
|
67
|
+
return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes);
|
|
68
|
+
} catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// A unique staging name, so a leftover from a crashed run never blocks the next one, removed on failure.
|
|
74
|
+
const writeAtomic = (path, text, { createParent }) => {
|
|
75
|
+
if (createParent) mkdirSync(dirname(path), { recursive: true });
|
|
76
|
+
const staging = `${path}.litfamily-${randomUUID()}.tmp`;
|
|
77
|
+
let mode = null;
|
|
78
|
+
try {
|
|
79
|
+
mode = statSync(path).mode & 0o7777;
|
|
80
|
+
} catch {
|
|
81
|
+
// A new file takes the default mode.
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
writeFileSync(staging, text, { flag: "wx" });
|
|
85
|
+
if (mode !== null) chmodSync(staging, mode);
|
|
86
|
+
renameSync(staging, path);
|
|
87
|
+
} finally {
|
|
88
|
+
try {
|
|
89
|
+
unlinkSync(staging);
|
|
90
|
+
} catch {
|
|
91
|
+
// Renamed into place, or never written.
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Installs or removes block `id` in `path`. Returns `{status, path, backup?, preview?}` with status
|
|
98
|
+
* created | updated | unchanged | removed | absent | dry-run | refused-symlink | refused-not-file |
|
|
99
|
+
* refused-not-utf8 | refused-malformed | refused-io. `backup: false` skips the first-insert copy (a
|
|
100
|
+
* repo's AGENTS.md, where a copy would sit beside tracked files); `createParent: false` never makes
|
|
101
|
+
* the folder.
|
|
102
|
+
*/
|
|
103
|
+
export const applyAgentFile = ({ path, id = AGENT_FILE_ID, version, body, action, dryRun = false, now = new Date(), backup = true, createParent = true }) => {
|
|
104
|
+
try {
|
|
105
|
+
const kind = entryKind(path);
|
|
106
|
+
if (kind === "symlink") return { status: "refused-symlink", path };
|
|
107
|
+
if (kind === "other") return { status: "refused-not-file", path };
|
|
108
|
+
const text = kind === "file" ? readUtf8(path) : "";
|
|
109
|
+
if (text === null) return { status: "refused-not-utf8", path };
|
|
110
|
+
let next;
|
|
111
|
+
try {
|
|
112
|
+
next = action === "uninstall" ? removeBlock(text, id) : upsertBlock(text, { id, version, body }, { created: kind === "missing" });
|
|
113
|
+
} catch (error) {
|
|
114
|
+
if (error instanceof ManagedBlockError) return { status: "refused-malformed", path };
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
if (!next.changed) return { status: action === "uninstall" ? "absent" : "unchanged", path };
|
|
118
|
+
if (dryRun) return { status: "dry-run", path, preview: next.text };
|
|
119
|
+
if (action === "uninstall") {
|
|
120
|
+
if (next.text === "" && next.created) unlinkSync(path);
|
|
121
|
+
else writeAtomic(path, next.text, { createParent: false });
|
|
122
|
+
return { status: "removed", path };
|
|
123
|
+
}
|
|
124
|
+
let copy;
|
|
125
|
+
if (backup && kind === "file" && inspectBlock(text, id).state === "absent") {
|
|
126
|
+
copy = `${path}.litfamily-backup-${now.toISOString().replace(/[:.]/gu, "-")}`;
|
|
127
|
+
copyFileSync(path, copy);
|
|
128
|
+
}
|
|
129
|
+
writeAtomic(path, next.text, { createParent });
|
|
130
|
+
return { status: kind === "file" ? "updated" : "created", path, ...(copy ? { backup: copy } : {}) };
|
|
131
|
+
} catch (error) {
|
|
132
|
+
return { status: "refused-io", path, error: error?.code ?? error?.message };
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* `present v=<x>` (current), `stale v=<x>` (an older install's block), `absent`, `malformed`, or
|
|
138
|
+
* `symlink` / `not-file` / `not-utf8` for a file LitClaude will not write.
|
|
139
|
+
*/
|
|
140
|
+
export const agentFileState = ({ path, id = AGENT_FILE_ID, version }) => {
|
|
141
|
+
const kind = entryKind(path);
|
|
142
|
+
if (kind === "missing") return "absent";
|
|
143
|
+
if (kind === "symlink") return "symlink";
|
|
144
|
+
if (kind === "other") return "not-file";
|
|
145
|
+
const text = readUtf8(path);
|
|
146
|
+
if (text === null) return "not-utf8";
|
|
147
|
+
const found = inspectBlock(text, id);
|
|
148
|
+
if (found.state !== "present") return found.state;
|
|
149
|
+
return `${found.version === version ? "present" : "stale"} v=${found.version}`;
|
|
150
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// The attribution switch. `keep` (the default) leaves Claude Code's own Co-Authored-By trailer and pull
|
|
2
|
+
// request line as the host writes them; `off` hides them through Claude Code's native `attribution`
|
|
3
|
+
// setting and adds one line to the LitFamily block. The object form below hides all three parts on every
|
|
4
|
+
// Claude Code version (`attribution: false` needs 2.1.281, and older versions skip the whole file).
|
|
5
|
+
// Before the first change LitClaude keeps the user's earlier value in its own settings record, and
|
|
6
|
+
// restoring puts exactly that value back.
|
|
7
|
+
|
|
8
|
+
import { readLitConfigKey, writeLitConfigKey } from "../mark.mjs";
|
|
9
|
+
|
|
10
|
+
export const ATTRIBUTION_MODES = Object.freeze(["keep", "off"]);
|
|
11
|
+
export const HIDDEN_ATTRIBUTION = Object.freeze({ commit: "", pr: "", sessionUrl: false });
|
|
12
|
+
export const ATTRIBUTION_LINE = "- Do not add `Co-Authored-By` lines or other AI attribution to commits or pull requests.";
|
|
13
|
+
|
|
14
|
+
/** The stored choice, or undefined when the user never made one. */
|
|
15
|
+
export const storedAttributionMode = (litHome) => {
|
|
16
|
+
const stored = readLitConfigKey(litHome, "attribution");
|
|
17
|
+
return ATTRIBUTION_MODES.includes(stored) ? stored : undefined;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const readAttributionMode = ({ env = process.env, litHome }) => {
|
|
21
|
+
const override = String(env.LITCLAUDE_ATTRIBUTION ?? "").trim().toLowerCase();
|
|
22
|
+
if (ATTRIBUTION_MODES.includes(override)) return override;
|
|
23
|
+
return storedAttributionMode(litHome) ?? "keep";
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const writeAttributionMode = (litHome, mode) => {
|
|
27
|
+
if (!ATTRIBUTION_MODES.includes(mode)) throw new Error(`attribution takes one of: ${ATTRIBUTION_MODES.join(", ")}`);
|
|
28
|
+
return writeLitConfigKey(litHome, "attribution", mode);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const isHidden = (value) => JSON.stringify(value) === JSON.stringify(HIDDEN_ATTRIBUTION);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Hides attribution in `settings`; `record` (LitClaude's settings entry) keeps the earlier value once.
|
|
35
|
+
* When LitClaude hid it before and the user has since set their own value, that value wins: nothing is
|
|
36
|
+
* changed and the result is `user-changed` (otherwise `hidden`).
|
|
37
|
+
*/
|
|
38
|
+
export const applyAttribution = (settings, record) => {
|
|
39
|
+
if (Object.hasOwn(record, "attributionPrior")) {
|
|
40
|
+
if (Object.hasOwn(settings, "attribution") && !isHidden(settings.attribution)) return "user-changed";
|
|
41
|
+
} else {
|
|
42
|
+
record.attributionPrior = Object.hasOwn(settings, "attribution")
|
|
43
|
+
? { had: true, value: structuredClone(settings.attribution) }
|
|
44
|
+
: { had: false };
|
|
45
|
+
}
|
|
46
|
+
settings.attribution = { ...HIDDEN_ATTRIBUTION };
|
|
47
|
+
return "hidden";
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Puts back the value `applyAttribution` replaced, but only while the setting still holds what
|
|
52
|
+
* LitClaude wrote; a value the user set since, or one LitClaude never touched, is left alone.
|
|
53
|
+
*/
|
|
54
|
+
export const restoreAttribution = (settings, record) => {
|
|
55
|
+
if (!record || !Object.hasOwn(record, "attributionPrior")) return;
|
|
56
|
+
const prior = record.attributionPrior;
|
|
57
|
+
if (isHidden(settings.attribution)) {
|
|
58
|
+
if (prior?.had) settings.attribution = prior.value;
|
|
59
|
+
else delete settings.attribution;
|
|
60
|
+
}
|
|
61
|
+
delete record.attributionPrior;
|
|
62
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
## LitFamily · LitClaude
|
|
2
|
+
|
|
3
|
+
LitClaude adds the lit workflows to Claude Code (lit-plan, start-work, lit-loop, review-work, lit-adhd,
|
|
4
|
+
litresearch). Its hooks load the full rules on each turn, so this block only sets the ground rules.
|
|
5
|
+
|
|
6
|
+
- `lit` at the start of a prompt is LitClaude's activation word, not the Lit web library.
|
|
7
|
+
- Plans live in `plans/`, the session handoff in `HANDOFF.md`, run state in `.litclaude/`. Read them
|
|
8
|
+
before resuming work in a repo.
|
|
9
|
+
- Never push, publish, tag or bump a version without the user's explicit yes for that action.
|
|
10
|
+
- Call work done only after its tests pass and the changed surface was checked for real.
|
|
11
|
+
- In a new repo, `lit init` writes a short project `AGENTS.md` with these conventions.
|
|
12
|
+
- Turn this block off with `litclaude-ai config agentFile off`.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// `agent-file project [--dir <path>]`, shared by the npm CLI and the plugin's in-session `litclaude-ai`
|
|
2
|
+
// (lit-init runs it inside a session): the project block in the repo's AGENTS.md, plus a CLAUDE.md that
|
|
3
|
+
// imports it when the repo has none. An existing CLAUDE.md is the user's and is left alone.
|
|
4
|
+
|
|
5
|
+
import { lstatSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
6
|
+
import { dirname, join, resolve } from "node:path";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
|
|
9
|
+
import { markLitHome } from "../mark.mjs";
|
|
10
|
+
import { AGENT_FILE_ID, agentFileBody, applyAgentFile } from "./apply.mjs";
|
|
11
|
+
import { readAttributionMode } from "./attribution.mjs";
|
|
12
|
+
|
|
13
|
+
const manifestPath = join(dirname(fileURLToPath(import.meta.url)), "..", "..", ".claude-plugin", "plugin.json");
|
|
14
|
+
const pluginVersion = () => JSON.parse(readFileSync(manifestPath, "utf8")).version;
|
|
15
|
+
|
|
16
|
+
export const agentFileLine = (result) => `AGENT_FILE: ${result.status} ${result.path}${result.backup ? ` (backup: ${result.backup})` : ""}`;
|
|
17
|
+
|
|
18
|
+
/** Returns the exit code; prints `AGENT_FILE:` lines. */
|
|
19
|
+
export const runAgentFileCli = (rest, { cwd = process.cwd(), dryRun = false, out = process.stdout, err = process.stderr } = {}) => {
|
|
20
|
+
const [sub, ...args] = rest;
|
|
21
|
+
if (sub === "--help" || sub === "-h") {
|
|
22
|
+
out.write("Usage: litclaude-ai agent-file project [--dir <path>]\n");
|
|
23
|
+
return 0;
|
|
24
|
+
}
|
|
25
|
+
if (sub !== "project") {
|
|
26
|
+
err.write("Usage: litclaude-ai agent-file project [--dir <path>]\n");
|
|
27
|
+
return 64;
|
|
28
|
+
}
|
|
29
|
+
let dir = cwd;
|
|
30
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
31
|
+
if (args[index] === "--dir" && args[index + 1]) {
|
|
32
|
+
dir = resolve(cwd, args[index + 1]);
|
|
33
|
+
index += 1;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
err.write(`Unknown agent-file option: ${args[index]}\n`);
|
|
37
|
+
return 64;
|
|
38
|
+
}
|
|
39
|
+
let isDirectory = false;
|
|
40
|
+
try {
|
|
41
|
+
isDirectory = statSync(dir).isDirectory();
|
|
42
|
+
} catch {
|
|
43
|
+
// Missing: reported below, never created.
|
|
44
|
+
}
|
|
45
|
+
if (!isDirectory) {
|
|
46
|
+
err.write(`agent-file: ${dir} is not an existing folder\n`);
|
|
47
|
+
return 64;
|
|
48
|
+
}
|
|
49
|
+
const body = agentFileBody("project", { attribution: readAttributionMode({ litHome: markLitHome() }) });
|
|
50
|
+
// No backup copy here: in a repo it would sit untracked beside AGENTS.md and could be committed.
|
|
51
|
+
const agents = applyAgentFile({ path: join(dir, "AGENTS.md"), id: AGENT_FILE_ID, version: pluginVersion(), body, action: "install", dryRun, backup: false, createParent: false });
|
|
52
|
+
out.write(`${agentFileLine(agents)}\n`);
|
|
53
|
+
if (agents.status.startsWith("refused")) return 1;
|
|
54
|
+
const claude = join(dir, "CLAUDE.md");
|
|
55
|
+
let claudeKind = "missing";
|
|
56
|
+
try {
|
|
57
|
+
const stats = lstatSync(claude);
|
|
58
|
+
claudeKind = stats.isSymbolicLink() ? "symlink" : stats.isFile() ? "file" : "other";
|
|
59
|
+
} catch {
|
|
60
|
+
// Missing.
|
|
61
|
+
}
|
|
62
|
+
if (claudeKind === "missing") {
|
|
63
|
+
if (!dryRun) writeFileSync(claude, "@AGENTS.md\n", { flag: "wx" });
|
|
64
|
+
out.write(`AGENT_FILE: ${dryRun ? "dry-run" : "created"} ${claude} (imports AGENTS.md)\n`);
|
|
65
|
+
} else if (claudeKind !== "file") {
|
|
66
|
+
out.write(`AGENT_FILE: ${claudeKind === "symlink" ? "refused-symlink" : "refused-not-file"} ${claude}; left as it is\n`);
|
|
67
|
+
} else if (!readFileSync(claude, "utf8").includes("@AGENTS.md")) {
|
|
68
|
+
out.write(`AGENT_FILE: kept ${claude}; add \`@AGENTS.md\` to it so Claude Code loads the project block\n`);
|
|
69
|
+
}
|
|
70
|
+
return 0;
|
|
71
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// A LitFamily block inside a user-owned instruction file (CLAUDE.md, AGENTS.md): the lines between
|
|
2
|
+
// `<!-- litfamily:<id>:start v=<version> … -->` and `<!-- litfamily:<id>:end -->`. Only those lines are
|
|
3
|
+
// ever written; the user's text before and after them stays byte for byte. The start marker records
|
|
4
|
+
// what was added in front of the block (`pre=`, hex) and whether the file was created for it (`new=1`),
|
|
5
|
+
// so removing the block takes back exactly that and an add-then-remove returns the original bytes,
|
|
6
|
+
// whatever the file's line endings. A start without its end, or two of either, is malformed: it is
|
|
7
|
+
// reported and refused, never guessed at.
|
|
8
|
+
|
|
9
|
+
export class ManagedBlockError extends Error {}
|
|
10
|
+
|
|
11
|
+
const startPrefix = (id) => `<!-- litfamily:${id}:start`;
|
|
12
|
+
const endMarker = (id) => `<!-- litfamily:${id}:end -->`;
|
|
13
|
+
const eolOf = (text) => (text.includes("\r\n") ? "\r\n" : "\n");
|
|
14
|
+
const START_LINE = /^<!-- litfamily:[^:\s]+:start v=(\S+)((?: [a-z]+=[0-9a-f]*)*) -->/u;
|
|
15
|
+
|
|
16
|
+
const occurrences = (text, needle) => {
|
|
17
|
+
const found = [];
|
|
18
|
+
for (let at = text.indexOf(needle); at !== -1; at = text.indexOf(needle, at + needle.length)) found.push(at);
|
|
19
|
+
return found;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// The block's span `[start, end)`, end just past the end marker, and its recorded attributes; or null.
|
|
23
|
+
const locate = (text, id) => {
|
|
24
|
+
const starts = occurrences(text, startPrefix(id));
|
|
25
|
+
const ends = occurrences(text, endMarker(id));
|
|
26
|
+
if (starts.length === 0 && ends.length === 0) return null;
|
|
27
|
+
if (starts.length !== 1 || ends.length !== 1 || ends[0] < starts[0]) {
|
|
28
|
+
throw new ManagedBlockError(`malformed LitFamily ${id} block: expected one start and one end marker`);
|
|
29
|
+
}
|
|
30
|
+
const head = START_LINE.exec(text.slice(starts[0]));
|
|
31
|
+
if (!head) throw new ManagedBlockError(`malformed LitFamily ${id} block: unreadable start marker`);
|
|
32
|
+
const attrs = Object.fromEntries(head[2].trim().split(" ").filter(Boolean).map((pair) => pair.split("=")));
|
|
33
|
+
return {
|
|
34
|
+
start: starts[0],
|
|
35
|
+
end: ends[0] + endMarker(id).length,
|
|
36
|
+
version: head[1],
|
|
37
|
+
pre: attrs.pre ? Buffer.from(attrs.pre, "hex").toString("utf8") : "",
|
|
38
|
+
created: attrs.new === "1",
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const render = ({ id, version, body }, eol, { pre, created }) => [
|
|
43
|
+
`${startPrefix(id)} v=${version}${pre ? ` pre=${Buffer.from(pre, "utf8").toString("hex")}` : ""}${created ? " new=1" : ""} -->`,
|
|
44
|
+
...String(body).replace(/\r?\n$/u, "").split(/\r?\n/u),
|
|
45
|
+
endMarker(id),
|
|
46
|
+
].join(eol);
|
|
47
|
+
|
|
48
|
+
/** `{state: "absent" | "present" | "malformed", version, created}` for block `id` in `text`. */
|
|
49
|
+
export const inspectBlock = (text, id) => {
|
|
50
|
+
let span;
|
|
51
|
+
try {
|
|
52
|
+
span = locate(text, id);
|
|
53
|
+
} catch {
|
|
54
|
+
return { state: "malformed", version: null, created: false };
|
|
55
|
+
}
|
|
56
|
+
return span ? { state: "present", version: span.version, created: span.created } : { state: "absent", version: null, created: false };
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/** Adds or replaces block `id`; `created` marks a file made for the block. Returns `{text, changed}`. */
|
|
60
|
+
export const upsertBlock = (text, block, { created = false } = {}) => {
|
|
61
|
+
const eol = eolOf(text);
|
|
62
|
+
const span = locate(text, block.id);
|
|
63
|
+
if (span) {
|
|
64
|
+
const rendered = render(block, eol, span);
|
|
65
|
+
const next = `${text.slice(0, span.start)}${rendered}${text.slice(span.end)}`;
|
|
66
|
+
return { text: next, changed: next !== text };
|
|
67
|
+
}
|
|
68
|
+
const pre = text === "" ? "" : `${text.endsWith("\n") ? "" : eol}${eol}`;
|
|
69
|
+
return { text: `${text}${pre}${render(block, eol, { pre, created })}${eol}`, changed: true };
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/** Removes block `id`, the line ending after it and what was added before it; `created` is from its marker. */
|
|
73
|
+
export const removeBlock = (text, id) => {
|
|
74
|
+
const span = locate(text, id);
|
|
75
|
+
if (!span) return { text, changed: false, created: false };
|
|
76
|
+
let before = text.slice(0, span.start);
|
|
77
|
+
let after = text.slice(span.end);
|
|
78
|
+
const eol = after.startsWith("\r\n") ? "\r\n" : after.startsWith("\n") ? "\n" : "";
|
|
79
|
+
after = after.slice(eol.length);
|
|
80
|
+
if (span.pre && before.endsWith(span.pre)) before = before.slice(0, -span.pre.length);
|
|
81
|
+
return { text: `${before}${after}`, changed: true, created: span.created };
|
|
82
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
## LitFamily · project conventions
|
|
2
|
+
|
|
3
|
+
This repo is worked with LitClaude's lit workflows (lit-plan, start-work, lit-loop, review-work).
|
|
4
|
+
|
|
5
|
+
- Plans live in `plans/`, the session handoff in `HANDOFF.md`, run state in `.litclaude/` (keep it out
|
|
6
|
+
of commits). Read the handoff and the active plan before resuming.
|
|
7
|
+
- Never push, publish, tag or bump a version without the user's explicit yes for that action.
|
|
8
|
+
- Pair every behaviour change with a test that failed first, and check the changed surface for real
|
|
9
|
+
before calling it done.
|
|
@@ -11,7 +11,7 @@ export const canonicalSkillResourceManifest = Object.freeze(
|
|
|
11
11
|
["lib/durable-plan.mjs", "33fc7c2ba6305602c73650c8f29e6141e93b8ac32a444f772807e11bf8c22e44"],
|
|
12
12
|
["lib/immutable-expected-file-map.mjs", "4061486bc8eda8a53e56b7b346a1e400e7c858c0a682c83362fea460b46dfd4b"],
|
|
13
13
|
["lib/lit-mark.mjs", "b6b501e1d6fbf6c8e1797ba87a46b169423f909b039dab0067314d055cec33e7"],
|
|
14
|
-
["lib/mark.mjs", "
|
|
14
|
+
["lib/mark.mjs", "8f3d1c3ff2c471d264e8d73fca97595c93cf4b43d7935c285d72ee1ddfa8c67c"],
|
|
15
15
|
["lib/npm-invocation.mjs", "8d7b98e65836f5400b33163083cfa842fcbbf0659923290b0c680395737d3716"],
|
|
16
16
|
["lib/office-runtime-lock/package-lock.json", "16d19b420b410035e9ca6886133368444a2b438121919857b3e8915be280c6a6"],
|
|
17
17
|
["lib/office-runtime-lock/package.json", "5e4b0c7ee7bd5ff88c888f7f46152c605caf128cc4e7bfd16423571210925394"],
|
|
@@ -25,10 +25,10 @@ export const canonicalSkillResourceManifest = Object.freeze(
|
|
|
25
25
|
["lib/plan-task-rows.mjs", "ca45412631cdfa805102a42dbb3cfc9a43f6f1ecbcdabe1cc5059d2dcb5e58df"],
|
|
26
26
|
["lib/rename-aliases.mjs", "3ee93aec10d0dbe785c554ab3040173ee94fde27da1b440a54b0513e5d11a508"],
|
|
27
27
|
["lib/render_pages.py", "56312e376659a83a8547f60491ca2eac8ef2f3ddd763132cac0016f4d0cce542"],
|
|
28
|
-
["lib/rewind/brief.mjs", "
|
|
29
|
-
["lib/rewind/collect.mjs", "
|
|
28
|
+
["lib/rewind/brief.mjs", "11904c66063ff7c66556c22d198be746768ef0b5a31d40e3b4c6988dbf4b537c"],
|
|
29
|
+
["lib/rewind/collect.mjs", "35f092dd1b0c5464e56bc17f7283758aa6b86679a44cae508eb6887f6a189e7a"],
|
|
30
30
|
["lib/rewind/gauge.mjs", "347095c1d36492bb996a679b67847261d15388b29962ed2ebaabec3cf0a5d9df"],
|
|
31
|
-
["lib/rewind/next-step.mjs", "
|
|
31
|
+
["lib/rewind/next-step.mjs", "75936e3f80ce3328f0a1487a5001dd73c625c996f14d43e4ffbc07c70b56fdd2"],
|
|
32
32
|
["lib/rewind/redact.mjs", "5bff5f69191f2ec07720f2dde20a850730fed884efb47a43f2604d7295a1615a"],
|
|
33
33
|
["lib/rewind/transcripts.mjs", "3fe82276cea0c51f4d89868e3a8fc315f2e099bdefcbde193ffceffe16e0325c"],
|
|
34
34
|
["lib/rules/constants.mjs", "de97cc08ca834c35ba89a3d384517ae3f24fd52502b8ccd7a3c8227981e3f6c9"],
|
|
@@ -135,7 +135,7 @@ export const canonicalSkillResourceManifest = Object.freeze(
|
|
|
135
135
|
["skills/frontend-ui-ux/scripts/search.mjs", "a08531cf2fece7b4cf4a7290cb7afbdbf90b72c0cf6cd0101df86986da86b517"],
|
|
136
136
|
["skills/frontend-ui-ux/scripts/source-replay.mjs", "2c24537a8b9f2161c1d06e42e7d5d44ab921b083f41d93d3e44da835cf932fb8"],
|
|
137
137
|
["skills/frontend-ui-ux/scripts/validate-design-contract.mjs", "f05997c3836764b9f6326efe457b91fe187ca5735bb0ce10f54f14b5b1ca0e3a"],
|
|
138
|
-
["skills/lit-adhd/SKILL.md", "
|
|
138
|
+
["skills/lit-adhd/SKILL.md", "b56a6fbe36205d58a47c95c515855571a1d26a3b9d023b6b6aa5f21730e95d69"],
|
|
139
139
|
["skills/lit-adhd/references/card-examples.md", "7466a0b73ecb9dce5e08cc12362fbc21dce1ef5cdb85c359fec5bfddfc684a62"],
|
|
140
140
|
["skills/lit-adhd/references/status-taxonomy.md", "ad647edea7394d8927e68ac5d9dd638285a4e19743cb0371e3b3c9a105ace321"],
|
|
141
141
|
["skills/lit-adhd/scripts/rewind.mjs", "23810ec5afaf9b90cfb784d380739d85a752a9405c594052b3dc21af74ecd175"],
|
|
@@ -875,7 +875,7 @@ export const canonicalSkillResourceManifest = Object.freeze(
|
|
|
875
875
|
["skills/lit-typographic-motion/engine/node/stage-gate.mjs", "9c8bc7287cd833d250a35a647a46ef930a45f5394ea37d9ff908a49c55111e92"],
|
|
876
876
|
["skills/lit-typographic-motion/engine/node/stage-qa.mjs", "409c5fd3dc17bb998647245b6bb2bf58b96d2a6538f96c7d8ca9e2847c5988fe"],
|
|
877
877
|
["skills/lit-typographic-motion/engine/node/stage-serve.mjs", "4c737b2a9bb55873cec8441814e478137def2bbcbee3f024a1014bbf3c8a6a5b"],
|
|
878
|
-
["skills/lit-typographic-motion/engine/node/stage.mjs", "
|
|
878
|
+
["skills/lit-typographic-motion/engine/node/stage.mjs", "acd9e3cf0d159e25347aafdfc79c112407a2268d07cff90bbe54e580c642f4b8"],
|
|
879
879
|
["skills/lit-typographic-motion/engine/node/stills.mjs", "be783fa50136be4dcbee7edfac8fcd60e3130ba7aeebb53cb11251a7c49ddbb7"],
|
|
880
880
|
["skills/lit-typographic-motion/engine/node/styles.mjs", "16533b7d404781788d25d0d7d0be3d876f0e4b05d13df929d04f871c1c86109b"],
|
|
881
881
|
["skills/lit-typographic-motion/engine/node/treatment.mjs", "4cbf449bf7d4611c5803ed21dbd6449b326358bd82a180be78c559bd0e9e8482"],
|
|
@@ -884,7 +884,7 @@ export const canonicalSkillResourceManifest = Object.freeze(
|
|
|
884
884
|
["skills/lit-typographic-motion/engine/package-lock.json", "33aeaa044cd7539f591e94cac090c49d54a0e56b84428a947e7bd6ad040cb681"],
|
|
885
885
|
["skills/lit-typographic-motion/engine/package.json", "b39e7c72ca63e630caed5a3f4dfd7871c96046aaf2ebbea500556b9a731be8d6"],
|
|
886
886
|
["skills/lit-typographic-motion/engine/stage/cover-init.js", "4897e1851d5e8a7b4a761d606d522c8d7f80827cfad518d38651dab00209a30a"],
|
|
887
|
-
["skills/lit-typographic-motion/engine/stage/init.js", "
|
|
887
|
+
["skills/lit-typographic-motion/engine/stage/init.js", "c5b76f3e3242ab5d4f39abda72eb4040af2e6c8c329c71f8def99ef023d91832"],
|
|
888
888
|
["skills/lit-typographic-motion/engine/stage/loop-kit.js", "dd2839c093c20ae1a0deca3a7a7099af2b4700e70ebcd38435d3bf6ff16f121f"],
|
|
889
889
|
["skills/lit-typographic-motion/engine/stage/qa.js", "9240b2b2f15955ccaec7b8447b69ce7335ffcea95336ed262323a4392f610b22"],
|
|
890
890
|
["skills/lit-typographic-motion/engine/stage/stage-kit.js", "2b5675cf6356d9168af19dc44c57ba7b13a70e078f9bc5319a9ec4190e89ce07"],
|
|
@@ -989,7 +989,7 @@ export const canonicalSkillResourceManifest = Object.freeze(
|
|
|
989
989
|
["skills/readme-studio/templates/cover-source.json", "55f681cf523a94b5403f5ad74b9e437dcaec02245ccba9176c2042c53a05b9c9"],
|
|
990
990
|
["skills/readme-studio/templates/hyperframes-cover/index.html", "7ea1282f05b5bde71317a312c028a64f719628f695a04c717d76e0fb34f7a41b"],
|
|
991
991
|
["skills/readme-studio/templates/hyperframes-cover/index.motion.json", "bef879ce5abe7810d73cc733ab635884ec807eccd7bc5e1c9bc9900049187249"],
|
|
992
|
-
["skills/readme-studio/templates/hyperframes-cover/package-lock.json", "
|
|
992
|
+
["skills/readme-studio/templates/hyperframes-cover/package-lock.json", "52240d8136c929bfe7b6102130a5af3c6a1db87588f1d94cb7c739ee42fc7469"],
|
|
993
993
|
["skills/readme-studio/templates/hyperframes-cover/package.json", "0993c6f04892f5a318cc99030de653b7c68d3ea6789c69b30b6a2ae80e4120f0"],
|
|
994
994
|
["skills/readme-studio/templates/readme-cover-section.md", "1dc4c536f65d3437f12e09a76170a8dc76557225587c7453631a06604a21573d"],
|
|
995
995
|
["skills/readme-studio/templates/readme-facts.json", "fb95b8aece0e8591726d3a36e25cc66712b0c6e57835c848db0f07b745e73205"],
|
|
@@ -46,23 +46,40 @@ export const readMarkMode = ({ env = process.env, litHome = markLitHome(env) } =
|
|
|
46
46
|
return MARK_MODES.includes(stored) ? stored : "on";
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
/**
|
|
50
|
-
export const
|
|
51
|
-
|
|
49
|
+
/** One key of `<litHome>/config.json`, or undefined when the file or key is unreadable. */
|
|
50
|
+
export const readLitConfigKey = (litHome, key) => readConfig(markConfigPath(litHome))?.[key];
|
|
51
|
+
|
|
52
|
+
/** Stores one key, keeping the file's other keys; a symlinked config or home is refused, not followed. */
|
|
53
|
+
export const writeLitConfigKey = (litHome, key, value) => {
|
|
52
54
|
const path = markConfigPath(litHome);
|
|
53
55
|
for (const p of [litHome, path]) {
|
|
54
56
|
try {
|
|
55
|
-
if (lstatSync(p).isSymbolicLink()) throw new Error(`refusing to write the
|
|
57
|
+
if (lstatSync(p).isSymbolicLink()) throw new Error(`refusing to write the ${key} setting through a symlink: ${p}`);
|
|
56
58
|
} catch (error) {
|
|
57
59
|
if (error.code !== "ENOENT") throw error;
|
|
58
60
|
}
|
|
59
61
|
}
|
|
62
|
+
let current = {};
|
|
63
|
+
try {
|
|
64
|
+
lstatSync(path);
|
|
65
|
+
current = readConfig(path);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
if (error.code !== "ENOENT") throw error;
|
|
68
|
+
}
|
|
69
|
+
// A config.json that exists but does not read as an object holds the user's other settings.
|
|
70
|
+
if (current === null) throw new Error(`refusing to overwrite ${path}: it is not readable JSON; fix or remove it first`);
|
|
60
71
|
mkdirSync(litHome, { recursive: true, mode: 0o700 });
|
|
61
|
-
const next = { ...
|
|
72
|
+
const next = { ...current, [key]: value };
|
|
62
73
|
const staging = `${path}.${process.pid}.tmp`;
|
|
63
74
|
writeFileSync(staging, `${JSON.stringify(next, null, 2)}\n`, { flag: STATE_WRITE_FLAG, mode: 0o600 });
|
|
64
75
|
renameSync(staging, path);
|
|
65
|
-
return
|
|
76
|
+
return value;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/** Stores the mode, keeping the file's other keys; a symlinked config or home is refused, not followed. */
|
|
80
|
+
export const writeMarkMode = (litHome, mode) => {
|
|
81
|
+
if (!MARK_MODES.includes(mode)) throw new Error(`mark takes one of: ${MARK_MODES.join(", ")}`);
|
|
82
|
+
return writeLitConfigKey(litHome, "mark", mode);
|
|
66
83
|
};
|
|
67
84
|
|
|
68
85
|
/** `LitClaude <version> · github.com/wjgoarxiv/litclaude`, the version taken from the plugin manifest. */
|
|
@@ -69,6 +69,8 @@ const WORDS = {
|
|
|
69
69
|
},
|
|
70
70
|
goLine: (say) => `Type **\`${say}\`** to continue.`,
|
|
71
71
|
noGo: "Nothing runs on its own here: open that session, or say what to do.",
|
|
72
|
+
lanesAtWork: (n) => `${n} other ${n === 1 ? "lane is" : "lanes are"} still at work: wait for ${n === 1 ? "it" : "them"} to finish`,
|
|
73
|
+
noGoWhileLanes: "Do not type **`go`** now: run `lit adhd` again once the lanes finish.",
|
|
72
74
|
unknownSources: (list) => `Not read: ${list}.`,
|
|
73
75
|
older: "Older sessions were not read (read budget used up).",
|
|
74
76
|
plansSkipped: (n) => `${n} ${n === 1 ? "plan was" : "plans were"} not read (read budget used up).`,
|
|
@@ -133,6 +135,8 @@ const WORDS = {
|
|
|
133
135
|
},
|
|
134
136
|
goLine: (say) => `**\`${say}\`** 라고 입력하면 이어갑니다.`,
|
|
135
137
|
noGo: "저절로 실행되는 단계는 아닙니다. 그 세션을 열거나 할 일을 말해 주세요.",
|
|
138
|
+
lanesAtWork: (n) => `다른 레인 ${n}개가 아직 일하는 중이에요. 끝날 때까지 기다리세요`,
|
|
139
|
+
noGoWhileLanes: "지금은 **`go`는 입력하지 마세요.** 레인이 끝나면 `lit adhd`로 다시 확인하세요.",
|
|
136
140
|
unknownSources: (list) => `읽지 못함: ${list}.`,
|
|
137
141
|
older: "오래된 세션은 읽지 않았습니다(읽기 예산 소진).",
|
|
138
142
|
plansSkipped: (n) => `계획 ${n}개는 읽지 못했습니다(읽기 예산 소진).`,
|
|
@@ -211,6 +215,7 @@ const actionOf = (session, escape = plain) => {
|
|
|
211
215
|
const nextOf = (session, data, w) => {
|
|
212
216
|
const frames = (data.workflows ?? []).filter((frame) => frame.id8 === session.id8);
|
|
213
217
|
const paused = frames.find((frame) => frame.status === "paused");
|
|
218
|
+
if (paused && session.self && data.next?.wait?.lanes) return w.lanesAtWork(data.next.wait.lanes);
|
|
214
219
|
if (paused) return w.resume(paused.skill, paused.stage, session.self);
|
|
215
220
|
if (session.waitingReason === "start-work boundary") return w.approve;
|
|
216
221
|
if (session.status === "waiting-on-user") {
|
|
@@ -387,8 +392,13 @@ export const renderBrief = (data, { lang = "en", now = Date.parse(data.generated
|
|
|
387
392
|
const sessions = data.sessions ?? [];
|
|
388
393
|
const summary = data.summary ?? { sessions: sessions.length, waitingOnUser: 0, active: 0 };
|
|
389
394
|
// With no step for `go`, this worktree's HANDOFF.md Next item comes before the generic suggestion.
|
|
395
|
+
// While other lanes work, the step is to answer the one waiting on the user, or else to wait.
|
|
390
396
|
const handoffNext = (data.handoffs ?? []).find((handoff) => handoff.local && handoff.next)?.next ?? null;
|
|
391
|
-
const
|
|
397
|
+
const lanes = data.next?.wait?.lanes ?? 0;
|
|
398
|
+
const waiting = sessions.some((session) => session.status === "waiting-on-user" && !session.self);
|
|
399
|
+
const step = data.next?.kind && data.next.kind !== "none"
|
|
400
|
+
? stepText(data.next, w)
|
|
401
|
+
: lanes ? bare(waiting ? suggestion(data, w) : w.lanesAtWork(lanes)) : bare(handoffNext ?? suggestion(data, w));
|
|
392
402
|
const out = [...openerLines(data, step, w), ""];
|
|
393
403
|
out.push(`## 🧭 ${[w.sessions(summary.sessions), w.waiting(summary.waitingOnUser), w.active(summary.active)].join(" · ")} · ${w.next}: ${plain(step)}`);
|
|
394
404
|
out.push(`*${w.window(data.scope?.since ?? "7d", (data.scope?.worktrees ?? []).length || 1)}*`);
|
|
@@ -415,7 +425,7 @@ export const renderBrief = (data, { lang = "en", now = Date.parse(data.generated
|
|
|
415
425
|
if (data.next?.command) body.push(clipToWidth(data.next.command, width - 4));
|
|
416
426
|
if (say) body.push(`${w.type}: ${say}`);
|
|
417
427
|
out.push("", box(w.recommended, body));
|
|
418
|
-
out.push("", say ? w.goLine(say) : w.noGo);
|
|
428
|
+
out.push("", say ? w.goLine(say) : lanes ? w.noGoWhileLanes : w.noGo);
|
|
419
429
|
const unknown = Object.entries(data.sources ?? {}).filter(([, status]) => status !== "ok").map(([name]) => name);
|
|
420
430
|
const notes = [
|
|
421
431
|
unknown.length ? w.unknownSources(unknown.join(", ")) : null,
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { execFileSync } from "node:child_process";
|
|
8
8
|
import { closeSync, constants, fstatSync, lstatSync, openSync, readSync, readdirSync } from "node:fs";
|
|
9
9
|
import { homedir } from "node:os";
|
|
10
|
-
import { basename, join, resolve } from "node:path";
|
|
10
|
+
import { basename, join, resolve, sep } from "node:path";
|
|
11
11
|
|
|
12
12
|
import { parsePlanTaskRows } from "../plan-task-rows.mjs";
|
|
13
13
|
import { resolveProjectStateRoot } from "../project-state-root.mjs";
|
|
@@ -184,7 +184,10 @@ const litgoalOf = (root, budget, redact) => {
|
|
|
184
184
|
};
|
|
185
185
|
};
|
|
186
186
|
|
|
187
|
-
//
|
|
187
|
+
// An item already marked done (✅, ✓, [x], ~~struck~~, DONE, SHIPPED) is history, not a next step.
|
|
188
|
+
const DONE_ITEM = /✅|✓|^\[[xX]\]|^~~|\b(?:DONE|SHIPPED)\b/u;
|
|
189
|
+
|
|
190
|
+
// The first open list item or line of text under a `## Next` or `## Next Steps` heading, without its marker.
|
|
188
191
|
const handoffNext = (text) => {
|
|
189
192
|
const lines = text.split("\n");
|
|
190
193
|
const start = lines.findIndex((line) => /^#{1,6}\s+Next(?:\s+Steps)?\s*$/iu.test(line.trim()));
|
|
@@ -192,7 +195,7 @@ const handoffNext = (text) => {
|
|
|
192
195
|
for (const line of lines.slice(start + 1)) {
|
|
193
196
|
if (/^#{1,6}\s/u.test(line.trim())) return null;
|
|
194
197
|
const item = line.trim().replace(/^(?:[-*+]|\d+[.)])\s+/u, "");
|
|
195
|
-
if (item) return item;
|
|
198
|
+
if (item && !DONE_ITEM.test(item.replace(/^\*\*/u, ""))) return item;
|
|
196
199
|
}
|
|
197
200
|
return null;
|
|
198
201
|
};
|
|
@@ -297,11 +300,26 @@ const livenessOf = (root, budget) => {
|
|
|
297
300
|
});
|
|
298
301
|
};
|
|
299
302
|
|
|
300
|
-
|
|
303
|
+
// `herdr agent list` answers one JSON document. Only agents in this herdr workspace or inside the
|
|
304
|
+
// folders read are kept, so a lane the brief can see is one that could race this project's `go`.
|
|
305
|
+
const herdrOf = (env, exec, redact, roots) => {
|
|
301
306
|
if (env.HERDR_ENV !== "1") return { status: "unknown", agents: [] };
|
|
302
307
|
try {
|
|
303
|
-
const
|
|
304
|
-
return { status: "
|
|
308
|
+
const listed = JSON.parse(exec("herdr", ["agent", "list"], { timeout: HERDR_TIMEOUT_MS }))?.result?.agents;
|
|
309
|
+
if (!Array.isArray(listed)) return { status: "unknown", agents: [] };
|
|
310
|
+
const inside = (path) => typeof path === "string" && roots.some((root) => path === root || path.startsWith(`${root}${sep}`));
|
|
311
|
+
const agents = listed
|
|
312
|
+
.filter((agent) => (env.HERDR_WORKSPACE_ID && agent?.workspace_id === env.HERDR_WORKSPACE_ID) || inside(agent?.foreground_cwd) || inside(agent?.cwd))
|
|
313
|
+
.slice(0, 20)
|
|
314
|
+
.map((agent) => ({
|
|
315
|
+
agent: clipToWidth(redact(String(agent.agent ?? "unknown")), 20),
|
|
316
|
+
status: typeof agent.agent_status === "string" ? agent.agent_status : "unknown",
|
|
317
|
+
pane: typeof agent.pane_id === "string" ? agent.pane_id : "unknown",
|
|
318
|
+
id8: typeof agent.agent_session?.value === "string" ? agent.agent_session.value.slice(0, 8) : null,
|
|
319
|
+
title: clipToWidth(redact(String(agent.terminal_title_stripped ?? "")), 60),
|
|
320
|
+
self: Boolean(env.HERDR_PANE_ID) && agent.pane_id === env.HERDR_PANE_ID,
|
|
321
|
+
}));
|
|
322
|
+
return { status: "ok", agents };
|
|
305
323
|
} catch {
|
|
306
324
|
return { status: "unknown", agents: [] };
|
|
307
325
|
}
|
|
@@ -372,7 +390,7 @@ export const collectRewind = ({
|
|
|
372
390
|
}
|
|
373
391
|
|
|
374
392
|
const commits = collectEach((root) => commitsOf(root, sinceMs, now, exec, redact));
|
|
375
|
-
const herdr = herdrOf(env, exec, redact);
|
|
393
|
+
const herdr = herdrOf(env, exec, redact, roots.map((root) => resolve(root)));
|
|
376
394
|
|
|
377
395
|
// A session waits on the user when it asked something, or holds a paused frame or boundary.
|
|
378
396
|
for (const session of sessions) {
|