@litfamily/litclaude 1.0.50 → 1.0.52

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/README.md +8 -8
  3. package/README_ko-KR.md +8 -8
  4. package/bin/extensions.mjs +602 -0
  5. package/bin/litclaude-ai.js +27 -3
  6. package/docs/assets/readme/badge-version.svg +1 -1
  7. package/docs/hooks.md +55 -2
  8. package/docs/privacy.md +1 -1
  9. package/package.json +1 -1
  10. package/plugins/litclaude/.claude-plugin/plugin.json +7 -1
  11. package/plugins/litclaude/bin/litclaude-hook.js +150 -16
  12. package/plugins/litclaude/bin/litclaude-mcp.js +1 -1
  13. package/plugins/litclaude/commands/start-work.md +25 -7
  14. package/plugins/litclaude/hooks/hooks.json +34 -0
  15. package/plugins/litclaude/lib/auto-handoff.mjs +115 -2
  16. package/plugins/litclaude/lib/canonical-skill-resources.mjs +8 -8
  17. package/plugins/litclaude/lib/check-back.mjs +155 -0
  18. package/plugins/litclaude/lib/extensions-notice.mjs +82 -5
  19. package/plugins/litclaude/lib/park-ping.mjs +57 -0
  20. package/plugins/litclaude/lib/precompact-snapshot.mjs +89 -0
  21. package/plugins/litclaude/lib/rewind/suggest.mjs +9 -2
  22. package/plugins/litclaude/lib/shown-ledger.mjs +100 -0
  23. package/plugins/litclaude/lib/start-work-cli.mjs +9 -0
  24. package/plugins/litclaude/lib/start-work-lifecycle.mjs +360 -98
  25. package/plugins/litclaude/skills/frontend-ui-ux/SKILL.md +25 -0
  26. package/plugins/litclaude/skills/lit-diagram-drawer/SKILL.md +25 -0
  27. package/plugins/litclaude/skills/lit-docx/SKILL.md +25 -0
  28. package/plugins/litclaude/skills/lit-loop/SKILL.md +15 -0
  29. package/plugins/litclaude/skills/lit-pptx/SKILL.md +25 -0
  30. package/plugins/litclaude/skills/lit-schematic/SKILL.md +25 -0
  31. package/plugins/litclaude/skills/lit-scientific-visualization/SKILL.md +25 -0
  32. package/plugins/litclaude/skills/lit-typographic-motion/SKILL.md +25 -0
  33. package/plugins/litclaude/skills/litgoal/SKILL.md +17 -0
  34. package/plugins/litclaude/skills/readme-studio/SKILL.md +25 -0
  35. package/plugins/litclaude/skills/visual-qa/SKILL.md +25 -0
  36. package/scripts/validate-plugin.mjs +1 -1
@@ -2,15 +2,18 @@
2
2
  // last three days, say once a day that `lit adhd` briefs them all on one screen. It looks only at
3
3
  // this folder's own transcript folder (no scan of other projects) and stats file times, never
4
4
  // contents, so it stays cheap on every session start. A marker under `.litclaude/adhd/` keeps it
5
- // to one nudge per calendar day per project. A symlinked `.litclaude`, folder or marker (a cloned
5
+ // to one nudge per calendar day per project, and the shown-ledger keeps the same words from coming
6
+ // back within a week. A symlinked `.litclaude`, folder or marker (a cloned
6
7
  // repository can carry one) is never followed: the nudge is then skipped, not written elsewhere.
7
8
  import { lstatSync, readFileSync, readdirSync, renameSync, writeFileSync } from "node:fs";
8
9
  import { join } from "node:path";
9
10
 
10
11
  import { prepareStateDir, STATE_WRITE_FLAG } from "../project-state-root.mjs";
12
+ import { recordShown, wasShown } from "../shown-ledger.mjs";
11
13
  import { projectSlug } from "./transcripts.mjs";
12
14
 
13
15
  export const RECENT_MS = 3 * 24 * 60 * 60 * 1000;
16
+ const REPEAT_MS = 7 * 24 * 60 * 60 * 1000;
14
17
  const SCAN_LIMIT = 400;
15
18
 
16
19
  const dayOf = (now) => new Date(now).toISOString().slice(0, 10);
@@ -49,8 +52,12 @@ export const adhdSuggestion = ({ cwd, sessionId, configDir, stateRoot, now = Dat
49
52
  } catch {
50
53
  // No marker yet, or an unreadable one: suggest and rewrite it.
51
54
  }
55
+ const text = `${count} other recent ${count === 1 ? "session" : "sessions"} here · type \`lit adhd\` for a one-screen brief of where each stands`;
56
+ // The same words were already shown here within the week: a new day alone is no reason to repeat them.
57
+ if (wasShown({ stateRoot, text, now, ttlMs: REPEAT_MS })) return null;
52
58
  const staging = `${marker}.${process.pid}.tmp`;
53
59
  writeFileSync(staging, `${JSON.stringify({ day: dayOf(now) })}\n`, { flag: STATE_WRITE_FLAG });
54
60
  renameSync(staging, marker);
55
- return `${count} other recent ${count === 1 ? "session" : "sessions"} here · type \`lit adhd\` for a one-screen brief of where each stands`;
61
+ recordShown({ stateRoot, id: "adhd", text, now });
62
+ return text;
56
63
  };
@@ -0,0 +1,100 @@
1
+ // An append-only record of what LitClaude already told the user and how each run ended, kept at
2
+ // `<project state root>/.litclaude/shown/ledger.jsonl`, one JSON object per line:
3
+ // {"kind":"notice","id":"adhd","hash":"<16 hex>","at":<ms>} text LitClaude printed itself
4
+ // {"kind":"run-end","source":"start-work","id":"<work id>","outcome":"sent|nothing|waiting","at":<ms>}
5
+ // A notice is stored as a hash of its whitespace-normalised text, never the text. Only text LitClaude
6
+ // emits itself is covered; model prose is not intercepted. The record is advisory: a missing, corrupt or
7
+ // symlinked ledger reads as empty (today's behaviour: the notice is shown), and a write that fails
8
+ // changes nothing for the caller. A symlinked `.litclaude` or `shown` folder is never followed.
9
+ import { createHash } from "node:crypto";
10
+ import { closeSync, constants, fstatSync, lstatSync, openSync, readSync, writeSync } from "node:fs";
11
+ import { join } from "node:path";
12
+
13
+ import { prepareStateDir, PROJECT_STATE_DIR, STATE_APPEND_FLAG } from "./project-state-root.mjs";
14
+
15
+ export const RUN_END_OUTCOMES = Object.freeze(["sent", "nothing", "waiting"]);
16
+ const LEDGER_DIR = "shown";
17
+ const LEDGER_FILE = "ledger.jsonl";
18
+ // Only the newest part is read, so a long-lived ledger never slows a hook down.
19
+ const READ_TAIL_BYTES = 256 * 1024;
20
+ const ANSI = /\x1b\[[0-9;]*m/gu;
21
+
22
+ export const noticeHash = (text) => createHash("sha256")
23
+ .update(String(text).replace(ANSI, "").replace(/\s+/gu, " ").trim())
24
+ .digest("hex")
25
+ .slice(0, 16);
26
+
27
+ const ledgerPath = (stateRoot) => join(stateRoot, PROJECT_STATE_DIR, LEDGER_DIR, LEDGER_FILE);
28
+
29
+ const readRows = (stateRoot) => {
30
+ let fd;
31
+ try {
32
+ for (const folder of [join(stateRoot, PROJECT_STATE_DIR), join(stateRoot, PROJECT_STATE_DIR, LEDGER_DIR)]) {
33
+ const stat = lstatSync(folder);
34
+ if (stat.isSymbolicLink() || !stat.isDirectory()) return [];
35
+ }
36
+ const path = ledgerPath(stateRoot);
37
+ if (lstatSync(path).isSymbolicLink()) return [];
38
+ fd = openSync(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
39
+ const opened = fstatSync(fd);
40
+ if (!opened.isFile() || opened.size === 0) return [];
41
+ const length = Math.min(opened.size, READ_TAIL_BYTES);
42
+ const buffer = Buffer.alloc(length);
43
+ readSync(fd, buffer, 0, length, opened.size - length);
44
+ const lines = buffer.toString("utf8").split("\n");
45
+ if (opened.size > length) lines.shift();
46
+ const rows = [];
47
+ for (const line of lines) {
48
+ try {
49
+ const row = JSON.parse(line);
50
+ if (row !== null && typeof row === "object" && Number.isFinite(row.at)) rows.push(row);
51
+ } catch {
52
+ // A damaged line is skipped, not fatal.
53
+ }
54
+ }
55
+ return rows;
56
+ } catch {
57
+ return [];
58
+ } finally {
59
+ if (fd !== undefined) closeSync(fd);
60
+ }
61
+ };
62
+
63
+ const append = (stateRoot, row) => {
64
+ let fd;
65
+ try {
66
+ if (!prepareStateDir(join(stateRoot, PROJECT_STATE_DIR, LEDGER_DIR))) return false;
67
+ fd = openSync(ledgerPath(stateRoot), STATE_APPEND_FLAG, 0o600);
68
+ // The leading newline keeps a row apart from a damaged last line that has no newline of its own.
69
+ writeSync(fd, `\n${JSON.stringify(row)}\n`);
70
+ return true;
71
+ } catch {
72
+ return false;
73
+ } finally {
74
+ if (fd !== undefined) closeSync(fd);
75
+ }
76
+ };
77
+
78
+ /** Whether this text was already recorded as shown, optionally only within the last `ttlMs`. */
79
+ export const wasShown = ({ stateRoot, text, now = Date.now(), ttlMs = Number.POSITIVE_INFINITY }) => {
80
+ const hash = noticeHash(text);
81
+ return readRows(stateRoot).some((row) => row.kind === "notice" && row.hash === hash && now - row.at <= ttlMs);
82
+ };
83
+
84
+ /** Records that LitClaude printed this text. Returns false when the record could not be written. */
85
+ export const recordShown = ({ stateRoot, id, text, now = Date.now() }) =>
86
+ append(stateRoot, { kind: "notice", id, hash: noticeHash(text), at: now });
87
+
88
+ /** The newest run-end row, or null. */
89
+ export const lastRunEnd = (stateRoot) => readRows(stateRoot).filter((row) => row.kind === "run-end").at(-1) ?? null;
90
+
91
+ /** Records how a run ended, once per (source, id, outcome). Returns true when a row was written. */
92
+ export const recordRunEnd = ({ stateRoot, source, id, outcome, now = Date.now() }) => {
93
+ try {
94
+ if (!RUN_END_OUTCOMES.includes(outcome) || typeof source !== "string" || typeof id !== "string") return false;
95
+ const seen = readRows(stateRoot).some((row) => row.kind === "run-end" && row.source === source && row.id === id && row.outcome === outcome);
96
+ return seen ? false : append(stateRoot, { kind: "run-end", source, id, outcome, at: now });
97
+ } catch {
98
+ return false;
99
+ }
100
+ };
@@ -2,6 +2,7 @@ import { resolveProjectStateRoot } from "./project-state-root.mjs";
2
2
  import {
3
3
  cancelStartWork,
4
4
  completeStartWork,
5
+ finalizeStartWorkLane,
5
6
  handleStartWorkPreToolUse,
6
7
  initializeStartWork,
7
8
  pauseStartWork,
@@ -20,6 +21,7 @@ Commands:
20
21
  pause Pause only at a new non-forbidden authority boundary.
21
22
  cancel Cancel the active work as a terminal transition.
22
23
  complete Complete active verified work; open plan tasks keep it running.
24
+ lane-finalize Close a helper lane that never stopped (owner session only).
23
25
 
24
26
  Resume is intentionally not a generic CLI mutation. A user must submit exactly:
25
27
  /litclaude:start-work resume --work-id <id> --revision <n> --boundary-id <id> --prompt-id <id> --grant-id <id>
@@ -69,6 +71,7 @@ const optionsByCommand = {
69
71
  pause: new Set(["--work-id", "--session-id", "--expected-revision", "--idempotency-key", "--action", "--target-root", "--root", "--json"]),
70
72
  cancel: new Set(["--work-id", "--session-id", "--expected-revision", "--idempotency-key", "--root", "--json"]),
71
73
  complete: new Set(["--work-id", "--session-id", "--expected-revision", "--idempotency-key", "--root", "--json"]),
74
+ "lane-finalize": new Set(["--work-id", "--lane", "--session-id", "--root", "--json"]),
72
75
  };
73
76
 
74
77
  const assertExactOptions = (command, args) => {
@@ -120,6 +123,12 @@ const execute = (root, command, args) => {
120
123
  return cancelStartWork(root, commonMutation(args));
121
124
  case "complete":
122
125
  return completeStartWork(root, commonMutation(args));
126
+ case "lane-finalize":
127
+ return finalizeStartWorkLane(root, {
128
+ workId: required(args, "--work-id"),
129
+ lane: required(args, "--lane"),
130
+ sessionId: required(args, "--session-id"),
131
+ });
123
132
  case "resume":
124
133
  throw new StartWorkCliError("resume requires the exact trusted explicit UserPromptSubmit route; no generic agent-callable resume bypass exists", 77);
125
134
  default: