@litfamily/litcodex 1.0.27 → 1.0.29

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 (204) hide show
  1. package/README-Ko-KR.md +10 -10
  2. package/README.md +10 -10
  3. package/dist/cli.d.ts +3 -2
  4. package/dist/cli.js +73 -4
  5. package/dist/config-migration/cli.js +11 -3
  6. package/dist/install/generated-skill-payload-hashes.d.ts +58 -30
  7. package/dist/install/generated-skill-payload-hashes.js +58 -30
  8. package/dist/install/index.js +1 -1
  9. package/dist/install/motion-runtime.d.ts +4 -1
  10. package/dist/install/motion-runtime.js +15 -4
  11. package/dist/install/office-runtime.d.ts +10 -11
  12. package/dist/install/office-runtime.js +8 -3
  13. package/dist/install/skill-catalog.d.ts +1 -1
  14. package/dist/install/skill-catalog.js +1 -0
  15. package/dist/postinstall.js +16 -3
  16. package/dist/pty-helper.d.ts +7 -0
  17. package/dist/pty-helper.js +45 -0
  18. package/dist/run.d.ts +57 -0
  19. package/dist/run.js +354 -0
  20. package/marketplace/plugins/litcodex/.codex-plugin/plugin.json +1 -1
  21. package/marketplace/plugins/litcodex/components/auto-update/dist/auto-update.d.ts +12 -0
  22. package/marketplace/plugins/litcodex/components/auto-update/dist/auto-update.js +31 -2
  23. package/marketplace/plugins/litcodex/components/auto-update/package.json +1 -1
  24. package/marketplace/plugins/litcodex/components/comment-checker/package.json +1 -1
  25. package/marketplace/plugins/litcodex/components/git-bash/package.json +1 -1
  26. package/marketplace/plugins/litcodex/components/lit-loop/directive.md +2 -1
  27. package/marketplace/plugins/litcodex/components/lit-loop/directives/deep-interview.md +2 -0
  28. package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-brainstorm.md +216 -0
  29. package/marketplace/plugins/litcodex/components/lit-loop/directives/litgoal.md +8 -1
  30. package/marketplace/plugins/litcodex/components/lit-loop/directives/review-work.md +12 -4
  31. package/marketplace/plugins/litcodex/components/lit-loop/dist/card-status.d.ts +8 -3
  32. package/marketplace/plugins/litcodex/components/lit-loop/dist/card-status.js +11 -6
  33. package/marketplace/plugins/litcodex/components/lit-loop/dist/codex-hook.d.ts +6 -1
  34. package/marketplace/plugins/litcodex/components/lit-loop/dist/codex-hook.js +16 -5
  35. package/marketplace/plugins/litcodex/components/lit-loop/dist/guards.d.ts +3 -1
  36. package/marketplace/plugins/litcodex/components/lit-loop/dist/guards.js +5 -2
  37. package/marketplace/plugins/litcodex/components/lit-loop/dist/hook-cli.d.ts +2 -0
  38. package/marketplace/plugins/litcodex/components/lit-loop/dist/hook-cli.js +53 -17
  39. package/marketplace/plugins/litcodex/components/lit-loop/dist/hud-cli.d.ts +38 -0
  40. package/marketplace/plugins/litcodex/components/lit-loop/dist/hud-cli.js +155 -0
  41. package/marketplace/plugins/litcodex/components/lit-loop/dist/hud.d.ts +42 -0
  42. package/marketplace/plugins/litcodex/components/lit-loop/dist/hud.js +297 -0
  43. package/marketplace/plugins/litcodex/components/lit-loop/dist/markers.d.ts +2 -0
  44. package/marketplace/plugins/litcodex/components/lit-loop/dist/markers.js +2 -0
  45. package/marketplace/plugins/litcodex/components/lit-loop/dist/modes.d.ts +1 -1
  46. package/marketplace/plugins/litcodex/components/lit-loop/dist/modes.js +9 -1
  47. package/marketplace/plugins/litcodex/components/lit-loop/dist/motion-route.js +2 -0
  48. package/marketplace/plugins/litcodex/components/lit-loop/dist/plan-persistence.d.ts +2 -0
  49. package/marketplace/plugins/litcodex/components/lit-loop/dist/plan-persistence.js +8 -0
  50. package/marketplace/plugins/litcodex/components/lit-loop/dist/reentry.d.ts +56 -0
  51. package/marketplace/plugins/litcodex/components/lit-loop/dist/reentry.js +171 -0
  52. package/marketplace/plugins/litcodex/components/lit-loop/dist/route-context.js +5 -2
  53. package/marketplace/plugins/litcodex/components/lit-loop/dist/route-heads.js +35 -15
  54. package/marketplace/plugins/litcodex/components/lit-loop/dist/run-filter.d.ts +23 -0
  55. package/marketplace/plugins/litcodex/components/lit-loop/dist/run-filter.js +142 -0
  56. package/marketplace/plugins/litcodex/components/lit-loop/dist/run-panel.d.ts +29 -0
  57. package/marketplace/plugins/litcodex/components/lit-loop/dist/run-panel.js +102 -0
  58. package/marketplace/plugins/litcodex/components/lit-loop/dist/screen-card.d.ts +24 -0
  59. package/marketplace/plugins/litcodex/components/lit-loop/dist/screen-card.js +104 -0
  60. package/marketplace/plugins/litcodex/components/lit-loop/dist/screen-status.d.ts +24 -0
  61. package/marketplace/plugins/litcodex/components/lit-loop/dist/screen-status.js +110 -0
  62. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-mention-scope.js +2 -0
  63. package/marketplace/plugins/litcodex/components/lit-loop/dist/statusline.d.ts +17 -0
  64. package/marketplace/plugins/litcodex/components/lit-loop/dist/statusline.js +113 -0
  65. package/marketplace/plugins/litcodex/components/lit-loop/dist/trigger.d.ts +2 -2
  66. package/marketplace/plugins/litcodex/components/lit-loop/dist/trigger.js +15 -5
  67. package/marketplace/plugins/litcodex/components/lit-loop/dist/workflow-map.d.ts +7 -0
  68. package/marketplace/plugins/litcodex/components/lit-loop/dist/workflow-map.js +59 -10
  69. package/marketplace/plugins/litcodex/components/lit-loop/package.json +1 -1
  70. package/marketplace/plugins/litcodex/components/lsp/package.json +1 -1
  71. package/marketplace/plugins/litcodex/components/rules/bundled-rules/lit-humanizer.md +2 -0
  72. package/marketplace/plugins/litcodex/components/rules/dist/deliverable-hedge-guard.d.ts +8 -0
  73. package/marketplace/plugins/litcodex/components/rules/dist/deliverable-hedge-guard.js +381 -39
  74. package/marketplace/plugins/litcodex/components/rules/dist/model-metadata.d.ts +16 -0
  75. package/marketplace/plugins/litcodex/components/rules/dist/model-metadata.js +37 -1
  76. package/marketplace/plugins/litcodex/components/rules/package.json +1 -1
  77. package/marketplace/plugins/litcodex/components/start-work-continuation/package.json +1 -1
  78. package/marketplace/plugins/litcodex/components/telemetry/package.json +1 -1
  79. package/marketplace/plugins/litcodex/components/wikify-knowledge/package.json +1 -1
  80. package/marketplace/plugins/litcodex/skills/browser-drive/scripts/capability-probe.mjs +24 -4
  81. package/marketplace/plugins/litcodex/skills/deep-interview/SKILL.md +3 -1
  82. package/marketplace/plugins/litcodex/skills/lit-brainstorm/SKILL.md +271 -0
  83. package/marketplace/plugins/litcodex/skills/lit-brainstorm/agents/openai.yaml +6 -0
  84. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/scripts/doctor.mjs +4 -3
  85. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/scripts/export.mjs +6 -5
  86. package/marketplace/plugins/litcodex/skills/lit-diagram-drawer/scripts/runtime-probes.mjs +25 -0
  87. package/marketplace/plugins/litcodex/skills/lit-docx/scripts/convert_md_to_pdf.py +31 -1
  88. package/marketplace/plugins/litcodex/skills/lit-docx/templates/latex/acs/template.tex +2 -0
  89. package/marketplace/plugins/litcodex/skills/lit-docx/templates/latex/elsevier/template.tex +2 -0
  90. package/marketplace/plugins/litcodex/skills/lit-docx/templates/latex/ieee/template.tex +2 -0
  91. package/marketplace/plugins/litcodex/skills/lit-docx/templates/latex/korean-generic/template.tex +2 -0
  92. package/marketplace/plugins/litcodex/skills/lit-docx/templates/latex/nature/template.tex +2 -0
  93. package/marketplace/plugins/litcodex/skills/lit-humanizer/SKILL.md +4 -0
  94. package/marketplace/plugins/litcodex/skills/lit-humanizer/scripts/core.mjs +5 -1
  95. package/marketplace/plugins/litcodex/skills/lit-loop/SKILL.md +10 -2
  96. package/marketplace/plugins/litcodex/skills/lit-pptx/scripts/office-run.mjs +42 -10
  97. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/SKILL.md +11 -9
  98. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/agents/openai.yaml +3 -0
  99. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/THIRD_PARTY_NOTICES +4 -0
  100. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/constants.mjs +38 -0
  101. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-assets.mjs +113 -0
  102. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-capture.mjs +161 -0
  103. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-gate.mjs +327 -0
  104. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-image.mjs +136 -0
  105. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-init.js +43 -0
  106. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-sheet.mjs +69 -0
  107. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-treatment.mjs +102 -0
  108. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover-worker.mjs +21 -0
  109. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/cover.mjs +352 -0
  110. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/driver.mjs +19 -1
  111. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/fonts.mjs +11 -0
  112. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/look.mjs +128 -2
  113. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/loop-kit.js +104 -0
  114. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/runtime.mjs +92 -18
  115. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/stage.mjs +2 -0
  116. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/treatment.mjs +3 -2
  117. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/engine/webp.mjs +140 -0
  118. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/fonts/jetbrains-mono/JetBrainsMono-wght-latin.woff2 +0 -0
  119. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/fonts/jetbrains-mono/OFL.txt +93 -0
  120. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/negatives/card-scenes/expected.json +16 -0
  121. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/negatives/card-scenes/index.html +42 -0
  122. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/negatives/reset-sweep/expected.json +16 -0
  123. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/negatives/reset-sweep/index.html +27 -0
  124. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/negatives/still-glow/expected.json +17 -0
  125. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/negatives/still-glow/index.html +29 -0
  126. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/negatives/title-slam/expected.json +17 -0
  127. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/negatives/title-slam/index.html +44 -0
  128. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/orbit-loop/expected.json +67 -0
  129. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/orbit-loop/index.html +182 -0
  130. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/painted-light/expected.json +95 -0
  131. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/painted-light/index.html +231 -0
  132. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/weight-tide/expected.json +67 -0
  133. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/recipes/weight-tide/index.html +103 -0
  134. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/cover.md +389 -0
  135. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/quality-gate.md +4 -0
  136. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/runtime.md +7 -6
  137. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/stage.md +3 -1
  138. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/references/treatment.md +2 -0
  139. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/scripts/render.mjs +37 -5
  140. package/marketplace/plugins/litcodex/skills/lit-typographic-motion/scripts/runtime.mjs +1 -1
  141. package/marketplace/plugins/litcodex/skills/litgoal/SKILL.md +8 -3
  142. package/marketplace/plugins/litcodex/skills/lsp-setup/scripts/verify-lsp.ts +43 -7
  143. package/marketplace/plugins/litcodex/skills/review-work/SKILL.md +21 -4
  144. package/node_modules/@litcodex/lit-loop/CHANGELOG.md +7 -0
  145. package/node_modules/@litcodex/lit-loop/README.md +6 -0
  146. package/node_modules/@litcodex/lit-loop/directive.md +2 -1
  147. package/node_modules/@litcodex/lit-loop/directives/deep-interview.md +2 -0
  148. package/node_modules/@litcodex/lit-loop/directives/lit-brainstorm.md +216 -0
  149. package/node_modules/@litcodex/lit-loop/directives/litgoal.md +8 -1
  150. package/node_modules/@litcodex/lit-loop/directives/review-work.md +12 -4
  151. package/node_modules/@litcodex/lit-loop/dist/card-status.d.ts +8 -3
  152. package/node_modules/@litcodex/lit-loop/dist/card-status.js +11 -6
  153. package/node_modules/@litcodex/lit-loop/dist/codex-hook.d.ts +6 -1
  154. package/node_modules/@litcodex/lit-loop/dist/codex-hook.js +16 -5
  155. package/node_modules/@litcodex/lit-loop/dist/guards.d.ts +3 -1
  156. package/node_modules/@litcodex/lit-loop/dist/guards.js +5 -2
  157. package/node_modules/@litcodex/lit-loop/dist/hook-cli.d.ts +2 -0
  158. package/node_modules/@litcodex/lit-loop/dist/hook-cli.js +53 -17
  159. package/node_modules/@litcodex/lit-loop/dist/hud-cli.d.ts +38 -0
  160. package/node_modules/@litcodex/lit-loop/dist/hud-cli.js +155 -0
  161. package/node_modules/@litcodex/lit-loop/dist/hud.d.ts +42 -0
  162. package/node_modules/@litcodex/lit-loop/dist/hud.js +297 -0
  163. package/node_modules/@litcodex/lit-loop/dist/markers.d.ts +2 -0
  164. package/node_modules/@litcodex/lit-loop/dist/markers.js +2 -0
  165. package/node_modules/@litcodex/lit-loop/dist/modes.d.ts +1 -1
  166. package/node_modules/@litcodex/lit-loop/dist/modes.js +9 -1
  167. package/node_modules/@litcodex/lit-loop/dist/motion-route.js +2 -0
  168. package/node_modules/@litcodex/lit-loop/dist/plan-persistence.d.ts +2 -0
  169. package/node_modules/@litcodex/lit-loop/dist/plan-persistence.js +8 -0
  170. package/node_modules/@litcodex/lit-loop/dist/reentry.d.ts +56 -0
  171. package/node_modules/@litcodex/lit-loop/dist/reentry.js +171 -0
  172. package/node_modules/@litcodex/lit-loop/dist/route-context.js +5 -2
  173. package/node_modules/@litcodex/lit-loop/dist/route-heads.js +35 -15
  174. package/node_modules/@litcodex/lit-loop/dist/run-filter.d.ts +23 -0
  175. package/node_modules/@litcodex/lit-loop/dist/run-filter.js +142 -0
  176. package/node_modules/@litcodex/lit-loop/dist/run-panel.d.ts +29 -0
  177. package/node_modules/@litcodex/lit-loop/dist/run-panel.js +102 -0
  178. package/node_modules/@litcodex/lit-loop/dist/screen-card.d.ts +24 -0
  179. package/node_modules/@litcodex/lit-loop/dist/screen-card.js +104 -0
  180. package/node_modules/@litcodex/lit-loop/dist/screen-status.d.ts +24 -0
  181. package/node_modules/@litcodex/lit-loop/dist/screen-status.js +110 -0
  182. package/node_modules/@litcodex/lit-loop/dist/skill-mention-scope.js +2 -0
  183. package/node_modules/@litcodex/lit-loop/dist/statusline.d.ts +17 -0
  184. package/node_modules/@litcodex/lit-loop/dist/statusline.js +113 -0
  185. package/node_modules/@litcodex/lit-loop/dist/trigger.d.ts +2 -2
  186. package/node_modules/@litcodex/lit-loop/dist/trigger.js +15 -5
  187. package/node_modules/@litcodex/lit-loop/dist/workflow-map.d.ts +7 -0
  188. package/node_modules/@litcodex/lit-loop/dist/workflow-map.js +59 -10
  189. package/node_modules/@litcodex/lit-loop/package.json +1 -1
  190. package/node_modules/@litcodex/lit-loop/skills/browser-drive/scripts/capability-probe.mjs +24 -4
  191. package/node_modules/@litcodex/lit-loop/skills/deep-interview/SKILL.md +3 -1
  192. package/node_modules/@litcodex/lit-loop/skills/lit-brainstorm/SKILL.md +271 -0
  193. package/node_modules/@litcodex/lit-loop/skills/lit-humanizer/SKILL.md +4 -0
  194. package/node_modules/@litcodex/lit-loop/skills/lit-humanizer/scripts/core.mjs +5 -1
  195. package/node_modules/@litcodex/lit-loop/skills/lit-loop/SKILL.md +10 -2
  196. package/node_modules/@litcodex/lit-loop/skills/litgoal/SKILL.md +8 -3
  197. package/node_modules/@litcodex/lit-loop/skills/review-work/SKILL.md +21 -4
  198. package/package.json +5 -2
  199. package/readme-assets/badge-version.svg +1 -1
  200. package/readme-assets/cover-motion-still.webp +0 -0
  201. package/readme-assets/cover-motion.webp +0 -0
  202. package/readme-assets/cover.webp +0 -0
  203. package/readme-assets/litfamily-machines.png +0 -0
  204. package/readme-assets/skills/lit-brainstorm.webp +0 -0
@@ -12,8 +12,11 @@ import { claimReloadContext, evaluateAutoHandoffStop, recordCompaction, takeRelo
12
12
  import { applyAutoHandoffRoute, clearManagedCompactionWhenOff, parseAutoHandoffRoute, } from "./auto-handoff-settings.js";
13
13
  import { applyPreToolUseCreateGoalGuard, isLitUserPromptSubmitInput, runUserPromptSubmitHook } from "./codex-hook.js";
14
14
  import { endLiveStep, recordLiveStepEnd, recordLiveStepStart, recordTurnStart, writeThreadPointer, } from "./live-step.js";
15
- import { evaluatePlanPersistence, formatStopBlockOutput, recordLitPlanActivation } from "./plan-persistence.js";
16
- import { recordWorkflowTurn, workflowMapLine, workflowStopLine, workflowTurn } from "./workflow-map.js";
15
+ import { evaluatePlanPersistence, formatStopBlockOutput, rearmLitPlanIfSatisfied, recordLitPlanActivation, } from "./plan-persistence.js";
16
+ import { clearActiveRoute, isBareLit, readActiveRoute, readResumeWork, recordActiveRoute } from "./reentry.js";
17
+ import { workflowCard } from "./screen-card.js";
18
+ import { screenColor } from "./screen-status.js";
19
+ import { recordWorkflowTurn, workflowStopLine, workflowTurn } from "./workflow-map.js";
17
20
  /** Hard cap on stdin to bound memory / ReDoS exposure inside the 5 s Codex hook budget. 8 MB. */
18
21
  export const MAX_STDIN_BYTES = 8_000_000;
19
22
  const INVALID_JSON_MESSAGE = "lit hook: stdin was not valid JSON";
@@ -100,19 +103,31 @@ export async function runUserPromptSubmitHookCli(stdin, stdout, stderr, repoRoot
100
103
  }
101
104
  clearManagedCompactionWhenOff(hookCwd(parsed, repoRoot), auto.env ?? process.env);
102
105
  const pointer = hookSessionScope(parsed, repoRoot);
103
- const decision = runUserPromptSubmitHook(parsed);
106
+ const decision = runUserPromptSubmitHook(parsed, () => ({
107
+ active: pointer === null ? null : readActiveRoute(pointer.cwd, pointer.sessionId),
108
+ resume: pointer === null ? null : readResumeWork(pointer.cwd, pointer.sessionId),
109
+ }));
110
+ if (pointer !== null && decision.kind === "inject")
111
+ recordActiveRoute(pointer.cwd, pointer.sessionId, decision.mode);
104
112
  // Only a LIT thread gets a pointer: this prompt ignites LIT, or an earlier one already did.
105
113
  if (pointer !== null && (decision.kind === "inject" || workflowTurn(pointer.cwd, pointer.sessionId) !== null)) {
106
114
  writeThreadPointer(auto.env ?? process.env, pointer.sessionId, pointer.cwd, auto.now);
107
115
  recordTurnStart(pointer.cwd, pointer.sessionId, auto.now);
108
116
  }
117
+ // A continued lit-plan keeps its persistence gate as it is. A fresh activation arms it again, and so does an
118
+ // explicit `lit plan …` once the previous plan was saved (a bare `lit` carries on and never re-arms).
109
119
  if (decision.kind === "inject" && decision.mode === "lit-plan") {
110
120
  const scope = hookSessionScope(parsed, repoRoot);
111
- if (scope !== null)
112
- recordLitPlanActivation(scope.cwd, scope.sessionId);
121
+ if (scope !== null) {
122
+ if (decision.entry !== "continue")
123
+ recordLitPlanActivation(scope.cwd, scope.sessionId);
124
+ else if (isLitUserPromptSubmitInput(parsed) && !isBareLit(parsed.prompt))
125
+ rearmLitPlanIfSatisfied(scope.cwd, scope.sessionId);
126
+ }
113
127
  }
128
+ const env = auto.env ?? process.env;
114
129
  const own = decision.kind === "inject"
115
- ? withCardOffer(withWorkflowMap(decision.stdout, parsed, decision.mode), pointer, auto)
130
+ ? withCardOffer(withWorkflowMap(decision.stdout, parsed, decision.mode, env), pointer, auto, decision.entry === "continue")
116
131
  : "";
117
132
  const output = withAutoHandoffReload(own, parsed, repoRoot, auto);
118
133
  if (output !== "")
@@ -172,10 +187,11 @@ function withReloadContext(stdout, reload) {
172
187
  }
173
188
  }
174
189
  /**
175
- * Add the workflow map under the activation banner and remember the turn for the Stop line. Only an
176
- * event that names its own absolute `cwd` is mapped, so the map always describes the session's repo.
190
+ * Add the LIT card (map and checklist) under the activation banner and remember the turn for the Stop
191
+ * card. Only an event that names its own absolute `cwd` is mapped, so the card always describes the
192
+ * session's repo.
177
193
  */
178
- function withWorkflowMap(stdout, parsed, mode) {
194
+ function withWorkflowMap(stdout, parsed, mode, env) {
179
195
  if (!isRecord(parsed) || typeof parsed["cwd"] !== "string" || !isAbsolute(parsed["cwd"]))
180
196
  return stdout;
181
197
  const cwd = parsed["cwd"];
@@ -184,13 +200,16 @@ function withWorkflowMap(stdout, parsed, mode) {
184
200
  if (sessionId !== null && typeof parsed["turn_id"] === "string") {
185
201
  recordWorkflowTurn(cwd, sessionId, parsed["turn_id"], mode);
186
202
  }
187
- const map = workflowMapLine(cwd, sessionId, mode);
188
- if (map === null)
203
+ const card = workflowCard(cwd, sessionId, mode, "turn started", {
204
+ color: screenColor(env),
205
+ quietWhenEmpty: true,
206
+ });
207
+ if (card === null)
189
208
  return stdout;
190
209
  const output = JSON.parse(stdout);
191
210
  if (!isRecord(output) || typeof output["systemMessage"] !== "string")
192
211
  return stdout;
193
- output["systemMessage"] = `${output["systemMessage"]}\n${map}`;
212
+ output["systemMessage"] = `${output["systemMessage"]}\n${card}`;
194
213
  return `${JSON.stringify(output)}\n`;
195
214
  }
196
215
  catch {
@@ -202,14 +221,17 @@ function withWorkflowMap(stdout, parsed, mode) {
202
221
  * instead of scrolling away with the first one. In the terminal `codex` the same tool returns the map as text.
203
222
  */
204
223
  export const CARD_OFFER_CONTEXT = "LIT card: if the `lit_card` tool (litcodex MCP server) is available, call the `lit_card` tool once now, with no arguments, so the user sees the live LIT card for this turn. It replaces the previous turn's card, which folds itself into one line. Do not call it again in this turn; it updates by itself.";
224
+ /** The card request for a continued discipline: the model already read the full one when it was activated. */
225
+ export const CARD_OFFER_CONTINUE_CONTEXT = "LIT card: if the `lit_card` tool is available, call it once now with no arguments; it updates by itself.";
205
226
  /**
206
227
  * Add the card request to every LIT activation, right under the banner line so it stays inside the part
207
228
  * of the context Codex always shows, and remember when it was last made.
208
229
  */
209
- function withCardOffer(stdout, scope, auto) {
230
+ function withCardOffer(stdout, scope, auto, continued = false) {
210
231
  if (scope === null || stdout === "")
211
232
  return stdout;
212
- const merged = withContextAfterBanner(stdout, CARD_OFFER_CONTEXT) ?? withReloadContext(stdout, CARD_OFFER_CONTEXT);
233
+ const offer = continued ? CARD_OFFER_CONTINUE_CONTEXT : CARD_OFFER_CONTEXT;
234
+ const merged = withContextAfterBanner(stdout, offer) ?? withReloadContext(stdout, offer);
213
235
  if (merged === null)
214
236
  return stdout;
215
237
  writeThreadPointer(auto.env ?? process.env, scope.sessionId, scope.cwd, auto.now, { cardOffered: true });
@@ -237,6 +259,10 @@ function withContextAfterBanner(stdout, text) {
237
259
  function isRecord(value) {
238
260
  return typeof value === "object" && value !== null && !Array.isArray(value);
239
261
  }
262
+ /** A subagent's hooks carry the root session id, so its Stop must not end the parent's turn card. */
263
+ function isSubagent(parsed) {
264
+ return isRecord(parsed) && typeof parsed["agent_id"] === "string" && parsed["agent_id"] !== "";
265
+ }
240
266
  /** Absolute `cwd` from a hook event, else the fallback root. */
241
267
  function hookCwd(parsed, repoRoot) {
242
268
  if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
@@ -299,15 +325,22 @@ export async function runStopPlanPersistenceHookCli(stdin, stdout, stderr, repoR
299
325
  stdout.write(formatStopBlockOutput(handoff.reason));
300
326
  return 0;
301
327
  }
328
+ // A subagent's Stop carries the parent's session id; the parent's turn is still running.
329
+ if (isSubagent(parsed))
330
+ return 0;
302
331
  endLiveStep(scope.cwd, scope.sessionId, auto.now);
332
+ const env = auto.env ?? process.env;
303
333
  const line = typeof record["turn_id"] === "string"
304
334
  ? workflowStopLine(scope.cwd, scope.sessionId, record["turn_id"], {
305
335
  stopHookActive: record["stop_hook_active"] === true,
306
336
  transcriptPath: typeof record["transcript_path"] === "string" ? record["transcript_path"] : null,
307
337
  })
308
338
  : null;
309
- if (line !== null)
310
- stdout.write(`${JSON.stringify({ systemMessage: line })}\n`);
339
+ const turn = line === null ? null : workflowTurn(scope.cwd, scope.sessionId);
340
+ const card = turn === null ? null : workflowCard(scope.cwd, scope.sessionId, turn.mode, line, { color: screenColor(env) });
341
+ // Codex puts a hook label before the first row, so the card starts on the next one.
342
+ if (card !== null)
343
+ stdout.write(`${JSON.stringify({ systemMessage: `\n${card}` })}\n`);
311
344
  }
312
345
  return 0;
313
346
  }
@@ -356,8 +389,11 @@ export async function runPostCompactHookCli(stdin, _stdout, stderr, repoRoot = p
356
389
  return event.exit;
357
390
  clearManagedCompactionWhenOff(hookCwd(event.parsed, repoRoot), auto.env ?? process.env);
358
391
  const scope = hookSessionScope(event.parsed, repoRoot);
359
- if (scope !== null)
392
+ if (scope !== null) {
360
393
  recordCompaction(scope.cwd, scope.sessionId);
394
+ // The activation text may be gone from the model's context, so the next lit prompt sends it in full.
395
+ clearActiveRoute(scope.cwd, scope.sessionId);
396
+ }
361
397
  return 0;
362
398
  }
363
399
  export async function runPreToolUseCreateGoalGuardCli(stdin, stdout, stderr) {
@@ -0,0 +1,38 @@
1
+ export declare const HUD_HELP_TEXT = "litcodex hud [--session <id>] [--once]\n\nWatch the LIT card of your newest Codex session from a second terminal window or tab.\nIt reads only LIT's own records, never writes a file and never touches Codex. Ctrl-C quits.\n\nOptions:\n --session <id> Follow this session (an exact id or a unique prefix) instead of the newest.\n --once Print one plain frame and exit.\n --help Show this help.\n";
2
+ export interface HudOutput {
3
+ write(text: string): unknown;
4
+ readonly isTTY?: boolean;
5
+ readonly columns?: number | undefined;
6
+ on?(event: "error", listener: (error: unknown) => void): unknown;
7
+ }
8
+ export interface HudLoopOptions {
9
+ readonly env: NodeJS.ProcessEnv;
10
+ readonly wanted: string | null;
11
+ readonly out: HudOutput;
12
+ readonly color: boolean;
13
+ readonly now: () => number;
14
+ }
15
+ /**
16
+ * A frame writer: each `tick` reads and renders once, and writes only when the frame text changed or the
17
+ * terminal was resized. On a terminal the frame stays one column short of the edge, where a full line
18
+ * followed by erase-to-end would lose its last glyph or wrap.
19
+ */
20
+ export declare function createHudLoop(options: HudLoopOptions): {
21
+ tick(): boolean;
22
+ };
23
+ /** The process events the command listens to; a test passes its own emitter. */
24
+ interface HudSignals {
25
+ on(event: string, listener: (...args: unknown[]) => void): unknown;
26
+ off(event: string, listener: (...args: unknown[]) => void): unknown;
27
+ }
28
+ export interface HudIo {
29
+ readonly stdout: HudOutput;
30
+ readonly stderr: {
31
+ write(text: string): unknown;
32
+ };
33
+ readonly env: NodeJS.ProcessEnv;
34
+ readonly signals?: HudSignals;
35
+ readonly now?: () => number;
36
+ }
37
+ export declare function hudCommand(args: readonly string[], io: HudIo): Promise<number>;
38
+ export {};
@@ -0,0 +1,155 @@
1
+ // src/hud-cli.ts — `litcodex hud`: the LIT card, kept live in a second terminal window.
2
+ //
3
+ // One 1 s timer reads the small, size-capped LIT records (hud.ts), builds the frame and writes it only
4
+ // when its text changed; a running step changes it once a second through its clock. On a terminal the
5
+ // frame is drawn in place on the alternate screen with the cursor hidden, and both come back on every
6
+ // way out: a signal, an unexpected error or process exit. The command resolves its exit code and never
7
+ // calls `process.exit`; it writes no file, starts no process and opens no Codex rollout.
8
+ import { readHud, renderHud } from "./hud.js";
9
+ const TICK_MS = 1_000;
10
+ const DEFAULT_WIDTH = 80;
11
+ const ENTER_SCREEN = "\u001b[?1049h\u001b[?25l";
12
+ const LEAVE_SCREEN = "\u001b[?25h\u001b[?1049l";
13
+ const HOME = "\u001b[H";
14
+ const CLEAR_LINE = "\u001b[K";
15
+ const CLEAR_BELOW = "\u001b[J";
16
+ const USAGE_EXIT_CODE = 64;
17
+ const STOP_EVENTS = ["SIGINT", "SIGTERM", "SIGHUP"];
18
+ export const HUD_HELP_TEXT = `litcodex hud [--session <id>] [--once]
19
+
20
+ Watch the LIT card of your newest Codex session from a second terminal window or tab.
21
+ It reads only LIT's own records, never writes a file and never touches Codex. Ctrl-C quits.
22
+
23
+ Options:
24
+ --session <id> Follow this session (an exact id or a unique prefix) instead of the newest.
25
+ --once Print one plain frame and exit.
26
+ --help Show this help.
27
+ `;
28
+ /**
29
+ * A frame writer: each `tick` reads and renders once, and writes only when the frame text changed or the
30
+ * terminal was resized. On a terminal the frame stays one column short of the edge, where a full line
31
+ * followed by erase-to-end would lose its last glyph or wrap.
32
+ */
33
+ export function createHudLoop(options) {
34
+ let last = null;
35
+ let lastColumns;
36
+ return {
37
+ tick() {
38
+ const now = options.now();
39
+ const tty = options.out.isTTY === true;
40
+ const columns = options.out.columns;
41
+ if (columns !== lastColumns)
42
+ last = null;
43
+ lastColumns = columns;
44
+ const width = columns ?? DEFAULT_WIDTH;
45
+ const frame = renderHud(readHud(options.env, options.wanted, now), {
46
+ width: tty ? width - 1 : width,
47
+ color: options.color,
48
+ now,
49
+ });
50
+ if (frame === last)
51
+ return false;
52
+ last = frame;
53
+ options.out.write(tty ? `${HOME}${frame.split("\n").join(`${CLEAR_LINE}\n`)}${CLEAR_LINE}${CLEAR_BELOW}` : `${frame}\n`);
54
+ return true;
55
+ },
56
+ };
57
+ }
58
+ function parseArgs(args) {
59
+ let help = false;
60
+ let once = false;
61
+ let session = null;
62
+ for (let index = 0; index < args.length; index++) {
63
+ const arg = args[index];
64
+ if (arg === "--help" || arg === "-h")
65
+ help = true;
66
+ else if (arg === "--once")
67
+ once = true;
68
+ else if (arg === "--session") {
69
+ const value = args[index + 1];
70
+ if (value === undefined || value.startsWith("-") || value.trim() === "")
71
+ return "--session needs a session id";
72
+ session = value.trim();
73
+ index++;
74
+ }
75
+ else
76
+ return `unknown option "${arg}"`;
77
+ }
78
+ return { help, once, session };
79
+ }
80
+ function colorAllowed(env) {
81
+ const noColor = env["NO_COLOR"];
82
+ return noColor === undefined || noColor === "";
83
+ }
84
+ export async function hudCommand(args, io) {
85
+ const parsed = parseArgs(args);
86
+ if (typeof parsed === "string") {
87
+ io.stderr.write(`litcodex hud: ${parsed}.\n\n${HUD_HELP_TEXT}`);
88
+ return USAGE_EXIT_CODE;
89
+ }
90
+ if (parsed.help) {
91
+ io.stdout.write(HUD_HELP_TEXT);
92
+ return 0;
93
+ }
94
+ const now = io.now ?? Date.now;
95
+ if (parsed.once) {
96
+ createHudLoop({ env: io.env, wanted: parsed.session, out: plain(io.stdout), color: false, now }).tick();
97
+ return 0;
98
+ }
99
+ const tty = io.stdout.isTTY === true;
100
+ const loop = createHudLoop({
101
+ env: io.env,
102
+ wanted: parsed.session,
103
+ out: io.stdout,
104
+ color: tty && colorAllowed(io.env),
105
+ now,
106
+ });
107
+ const signals = io.signals ?? process;
108
+ // A write to a terminal that has gone away (SIGHUP) fails with EIO; it must not become a stack trace.
109
+ io.stdout.on?.("error", () => undefined);
110
+ return new Promise((resolve) => {
111
+ let restored = false;
112
+ let timer;
113
+ const restore = () => {
114
+ if (restored)
115
+ return;
116
+ restored = true;
117
+ clearInterval(timer);
118
+ for (const event of STOP_EVENTS)
119
+ signals.off(event, stop);
120
+ signals.off("uncaughtException", crash);
121
+ signals.off("exit", restore);
122
+ if (tty)
123
+ io.stdout.write(LEAVE_SCREEN);
124
+ };
125
+ const stop = () => {
126
+ restore();
127
+ resolve(0);
128
+ };
129
+ const crash = (error) => {
130
+ restore();
131
+ io.stderr.write(`litcodex hud: stopped: ${error instanceof Error ? error.message : String(error)}\n`);
132
+ resolve(1);
133
+ };
134
+ for (const event of STOP_EVENTS)
135
+ signals.on(event, stop);
136
+ signals.on("uncaughtException", crash);
137
+ signals.on("exit", restore);
138
+ if (tty)
139
+ io.stdout.write(ENTER_SCREEN);
140
+ const tick = () => {
141
+ try {
142
+ loop.tick();
143
+ }
144
+ catch (error) {
145
+ crash(error);
146
+ }
147
+ };
148
+ timer = setInterval(tick, TICK_MS);
149
+ tick();
150
+ });
151
+ }
152
+ /** The stream as a plain, non-terminal writer: one frame, no cursor moves. */
153
+ function plain(out) {
154
+ return { write: (text) => out.write(text), columns: out.isTTY === true ? out.columns : DEFAULT_WIDTH };
155
+ }
@@ -0,0 +1,42 @@
1
+ import { type CardStatus } from "./card-status.js";
2
+ export interface HudSession {
3
+ readonly id: string;
4
+ readonly cwd: string;
5
+ readonly updatedAt: number;
6
+ /** The newest LIT activity: the pointer time or a time the live step or workflow record carries. */
7
+ readonly activeAt: number;
8
+ }
9
+ export interface HudView {
10
+ /** What `--session` asked for, or null to follow the newest session. */
11
+ readonly wanted: string | null;
12
+ readonly session: {
13
+ readonly id: string;
14
+ readonly folder: string;
15
+ readonly lastSeen: number;
16
+ } | null;
17
+ readonly status: CardStatus | null;
18
+ /** Records that exist but could not be read, named for the user. */
19
+ readonly unreadable: readonly string[];
20
+ /** How many sessions `wanted` matched when it named more than one. */
21
+ readonly matches?: number;
22
+ }
23
+ export interface HudRenderOptions {
24
+ readonly width: number;
25
+ readonly color: boolean;
26
+ readonly now: number;
27
+ }
28
+ /** Every session with a readable pointer, newest LIT activity first. */
29
+ export declare function listSessions(env: NodeJS.ProcessEnv): HudSession[];
30
+ /** The most recently active session, or the one `wanted` names by exact id or unique prefix; else null. */
31
+ export declare function pickSession(env: NodeJS.ProcessEnv, wanted?: string | null): HudSession | null;
32
+ /** Everything one frame needs, read once. Never throws and never writes. */
33
+ export declare function readHud(env: NodeJS.ProcessEnv, wanted: string | null, now: number): HudView;
34
+ export declare function clean(text: string): string;
35
+ /** The card with every record-derived string stripped of control characters. */
36
+ export declare function cleanStatus(status: CardStatus): CardStatus;
37
+ /** Terminal cells a plain string takes: CJK and emoji take two, combining marks none. */
38
+ export declare function displayWidth(text: string): number;
39
+ /** The line cut to `width` terminal cells, ending in `…` when anything was cut. */
40
+ export declare function fit(line: string, width: number): string;
41
+ /** One frame as text: a header, the card, and at most one "cannot read" line. Pure. */
42
+ export declare function renderHud(view: HudView, options: HudRenderOptions): string;