portable-agent-layer 0.117.0-canary.8 → 0.117.0

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 (502) hide show
  1. package/.claude-plugin/marketplace.json +5 -0
  2. package/README.md +7 -3
  3. package/assets/STATUSLINE.md +9 -8
  4. package/assets/agents/skill-author.md +2 -2
  5. package/assets/plugins/dark-factory/README.md +4 -2
  6. package/assets/plugins/dark-factory/scripts/build.mjs +128 -14
  7. package/assets/plugins/dark-factory/skills/build-with-agents/SKILL.md +1 -1
  8. package/assets/plugins/pal-status/.claude-plugin/plugin.json +6 -0
  9. package/assets/plugins/pal-status/hooks/hooks.json +1 -0
  10. package/assets/plugins/pal-status/hooks/register.tsx +58 -0
  11. package/assets/plugins/pal-status/types/index.d.ts +7 -0
  12. package/assets/schema/pal-settings.schema.json +2 -151
  13. package/assets/schema/settings.schema.json +155 -0
  14. package/assets/skills/analyze-pdf/tools/pdf-download.ts +3 -2
  15. package/assets/skills/consulting-report/.lintstagedrc.mjs +14 -0
  16. package/assets/skills/consulting-report/SKILL.md +1 -1
  17. package/assets/skills/consulting-report/demo/lib/report-data.ts +23 -74
  18. package/assets/skills/consulting-report/knip.json +4 -0
  19. package/assets/skills/consulting-report/template/app/page.tsx +8 -12
  20. package/assets/skills/consulting-report/template/bun.lock +93 -85
  21. package/assets/skills/consulting-report/template/components/comparison-table.tsx +1 -5
  22. package/assets/skills/consulting-report/template/components/stat-grid.tsx +2 -6
  23. package/assets/skills/consulting-report/template/lib/report-data.ts +13 -0
  24. package/assets/skills/consulting-report/template/lib/types.ts +14 -0
  25. package/assets/skills/consulting-report/template/package.json +13 -12
  26. package/assets/skills/consulting-report/template/tsconfig.json +1 -0
  27. package/assets/skills/consulting-report/tools/dev.ts +2 -4
  28. package/assets/skills/consulting-report/tools/generate-pdf.ts +15 -19
  29. package/assets/skills/consulting-report/tools/lib/copy-report.ts +25 -1
  30. package/assets/skills/consulting-report/tools/scaffold.ts +3 -14
  31. package/assets/skills/consulting-report/tsconfig.demo.json +9 -0
  32. package/assets/skills/create-pdf/tools/md-to-html-pdf.ts +4 -10
  33. package/assets/skills/create-skill/authoring-guide.md +12 -0
  34. package/assets/skills/minimum/README.md +16 -0
  35. package/assets/skills/minimum/SKILL.md +120 -0
  36. package/assets/skills/onboarding/SKILL.md +1 -1
  37. package/assets/skills/playwright/tools/shot.ts +11 -21
  38. package/assets/skills/presentation/tools/build.ts +14 -44
  39. package/assets/skills/presentation/tools/doctor.ts +2 -11
  40. package/assets/skills/presentation/tools/lib/inline.ts +0 -1
  41. package/assets/skills/presentation/tools/lib/lint-helpers.ts +4 -17
  42. package/assets/skills/presentation/tools/lib/lint-rules.ts +19 -62
  43. package/assets/skills/presentation/tools/lib/lint-types.ts +2 -8
  44. package/assets/skills/presentation/tools/lib/paths.ts +2 -4
  45. package/assets/skills/presentation/tools/new-deck.ts +5 -10
  46. package/assets/skills/presentation/tools/setup-template.ts +2 -8
  47. package/assets/skills/projects/SKILL.md +2 -2
  48. package/assets/skills/reflect/SKILL.md +2 -2
  49. package/assets/skills/rule-review/SKILL.md +3 -3
  50. package/assets/skills/telos/SKILL.md +1 -1
  51. package/assets/skills/telos/tools/update-telos.ts +3 -2
  52. package/assets/statusline.ps1 +105 -43
  53. package/assets/statusline.sh +84 -39
  54. package/assets/templates/PAL/AGENT_HOOKS.md +1 -1
  55. package/assets/templates/PAL/MEMORY_SYSTEM.md +20 -13
  56. package/assets/templates/PAL/README.md +13 -11
  57. package/assets/templates/PAL/SYSTEM_ARCHITECTURE.md +30 -11
  58. package/assets/templates/settings.claude.json +2 -1
  59. package/assets/templates/{pal-settings.json → settings.json} +1 -1
  60. package/package.json +21 -24
  61. package/src/{hooks/lib → bronze}/antigravity-transcript.ts +1 -1
  62. package/src/bronze/bronze.ts +368 -0
  63. package/src/{hooks/lib → bronze}/events.ts +76 -13
  64. package/src/bronze/import-log.ts +31 -0
  65. package/src/{hooks/lib → bronze}/ledger-hook.ts +5 -1
  66. package/src/{hooks/lib → bronze}/ledger.ts +7 -6
  67. package/src/{hooks/lib → bronze}/sensitive-path.ts +1 -1
  68. package/src/{hooks/lib → bronze}/signals.ts +15 -10
  69. package/src/bronze/tool-output.ts +18 -0
  70. package/src/bronze/transcript-lines.ts +104 -0
  71. package/src/bronze/transcript-preserve.ts +213 -0
  72. package/src/{hooks/lib → bronze}/transcript.ts +0 -5
  73. package/src/cli/algorithm-run.ts +128 -0
  74. package/src/cli/archive-layout.ts +27 -0
  75. package/src/cli/auth.ts +93 -0
  76. package/src/cli/compaction.ts +3 -3
  77. package/src/cli/content.ts +3 -3
  78. package/src/cli/correction.ts +3 -3
  79. package/src/cli/cost.ts +2 -2
  80. package/src/cli/doctor/agents.ts +2 -2
  81. package/src/cli/doctor/environment.ts +2 -2
  82. package/src/cli/doctor/finding.ts +2 -0
  83. package/src/cli/doctor/health.ts +100 -13
  84. package/src/cli/doctor/inference.ts +4 -4
  85. package/src/cli/doctor/render.ts +1 -1
  86. package/src/cli/doctor/run.ts +15 -1
  87. package/src/cli/doctor/state.ts +44 -16
  88. package/src/cli/doctor/summary.ts +38 -0
  89. package/src/cli/doctor/version-control.ts +1 -1
  90. package/src/cli/env.ts +2 -2
  91. package/src/cli/events.ts +7 -4
  92. package/src/cli/evidence.ts +1 -1
  93. package/src/cli/export-import.ts +274 -0
  94. package/src/cli/identity.ts +3 -3
  95. package/src/cli/index.ts +13 -310
  96. package/src/cli/infer.ts +2 -2
  97. package/src/cli/install-flow.ts +6 -6
  98. package/src/cli/judge.ts +3 -3
  99. package/src/cli/knowledge-add.ts +165 -0
  100. package/src/cli/knowledge-ingest.ts +70 -0
  101. package/src/cli/knowledge-research.ts +7 -7
  102. package/src/cli/knowledge-review.ts +117 -0
  103. package/src/cli/knowledge.ts +6 -352
  104. package/src/cli/ledger.ts +1 -1
  105. package/src/cli/leftovers.ts +75 -10
  106. package/src/cli/legacy-opinions.ts +94 -0
  107. package/src/cli/migrate.ts +184 -1134
  108. package/src/cli/migrations/data-backup.ts +137 -0
  109. package/src/cli/migrations/file-hash.ts +30 -0
  110. package/src/cli/migrations/late-write-sweep.ts +151 -0
  111. package/src/cli/migrations/layout-move.ts +110 -0
  112. package/src/cli/migrations/migration.ts +29 -0
  113. package/src/cli/migrations/move-guards.ts +168 -0
  114. package/src/cli/migrations/move-manifest.ts +119 -0
  115. package/src/cli/migrations/store-move.ts +40 -0
  116. package/src/cli/migrations/v1-projects.ts +62 -0
  117. package/src/cli/migrations/v10-threads-to-progress-tree.ts +88 -0
  118. package/src/cli/migrations/v11-memory-backups.ts +254 -0
  119. package/src/cli/migrations/v12-raw-to-records.ts +36 -0
  120. package/src/cli/migrations/v13-settings-to-root.ts +34 -0
  121. package/src/cli/migrations/v14-records-stores.ts +19 -0
  122. package/src/cli/migrations/v15-work-stores.ts +7 -0
  123. package/src/cli/migrations/v16-bronze-to-records.ts +7 -0
  124. package/src/cli/migrations/v2-threads-to-isc.ts +102 -0
  125. package/src/cli/migrations/v3-entities-to-knowledge.ts +196 -0
  126. package/src/cli/migrations/v4-paths-to-bindings.ts +70 -0
  127. package/src/cli/migrations/v5-attribution-keys.ts +102 -0
  128. package/src/cli/migrations/v6-history-slugs.ts +130 -0
  129. package/src/cli/migrations/v7-retired-settings-keys.ts +98 -0
  130. package/src/cli/migrations/v8-factory-home.ts +187 -0
  131. package/src/cli/migrations/v9-progress-tree-names.ts +108 -0
  132. package/src/cli/migrations/verified-move.ts +294 -0
  133. package/src/cli/patterns.ts +2 -2
  134. package/src/cli/personal-context.ts +4 -8
  135. package/src/cli/progress.ts +6 -6
  136. package/src/cli/rule.ts +70 -5
  137. package/src/cli/run-mode.ts +126 -7
  138. package/src/cli/schedule.ts +3 -3
  139. package/src/cli/server.ts +2 -2
  140. package/src/cli/session-agent.ts +2 -2
  141. package/src/cli/session-summary.ts +48 -0
  142. package/src/cli/setup-attribution.ts +3 -2
  143. package/src/cli/setup-auto-update.ts +1 -1
  144. package/src/cli/setup-identity.ts +3 -3
  145. package/src/cli/setup-telemetry.ts +1 -1
  146. package/src/cli/skill.ts +6 -5
  147. package/src/cli/telemetry.ts +1 -1
  148. package/src/cli/tree.ts +19 -3
  149. package/src/cli/ui/live.ts +4 -3
  150. package/src/cli/update-flow.ts +24 -3
  151. package/src/cli/whats-new.ts +1 -1
  152. package/src/cli/worktree.ts +1 -1
  153. package/src/cli/wrapped.ts +1 -1
  154. package/src/{hooks/lib → context}/claude-md.ts +5 -5
  155. package/src/{hooks/lib → context}/compact-recall.ts +1 -1
  156. package/src/{hooks/lib → context}/compaction-backtest.ts +2 -2
  157. package/src/{hooks/lib → context}/compaction-near.ts +12 -8
  158. package/src/context/context-overhead.ts +47 -0
  159. package/src/{hooks/lib → context}/context.ts +20 -8
  160. package/src/{hooks/lib → context}/daily-nudge.ts +8 -8
  161. package/src/{hooks/lib → context}/git-command-repo.ts +1 -1
  162. package/src/{hooks/lib → context}/post-git-info.ts +5 -5
  163. package/src/{hooks/lib → context}/repo-state.ts +50 -10
  164. package/src/{hooks/lib → context}/semi-static.ts +2 -2
  165. package/src/{hooks/lib → context}/session-context.ts +2 -2
  166. package/src/{hooks/lib → context}/skill-match.ts +3 -3
  167. package/src/context/start-refresh.ts +10 -0
  168. package/src/{hooks/lib → core}/agent.ts +5 -6
  169. package/src/{hooks/lib → core}/anchor.ts +22 -34
  170. package/src/{hooks/lib → core}/environment.ts +1 -1
  171. package/src/core/export-manifest.ts +42 -0
  172. package/src/{hooks/lib → core}/export.ts +14 -5
  173. package/src/core/hook-payload.ts +62 -0
  174. package/src/{hooks/lib → core}/import-merge.ts +29 -35
  175. package/src/{hooks/lib → core}/log.ts +0 -1
  176. package/src/core/machine-state.ts +21 -0
  177. package/src/{hooks/lib → core}/paths.ts +10 -11
  178. package/src/core/project-bindings.ts +72 -0
  179. package/src/{hooks/lib → core}/readme-sync.ts +36 -38
  180. package/src/{hooks/lib → core}/settings.ts +21 -5
  181. package/src/{hooks/lib → core}/spawn-guard.ts +1 -1
  182. package/src/hooks/AgentResponse.ts +4 -3
  183. package/src/hooks/AttentionEvent.ts +4 -4
  184. package/src/hooks/AutoUpdate.ts +2 -2
  185. package/src/hooks/CompactRecover.ts +8 -8
  186. package/src/hooks/HealthCheck.ts +16 -0
  187. package/src/hooks/InvocationContext.ts +4 -4
  188. package/src/hooks/LedgerSnapshot.ts +4 -4
  189. package/src/hooks/LoadContext.ts +17 -17
  190. package/src/hooks/PostGitInfo.ts +2 -2
  191. package/src/hooks/PostToolOrchestrator.ts +2 -2
  192. package/src/hooks/PreCompactPersist.ts +6 -6
  193. package/src/hooks/PreserveTranscripts.ts +4 -4
  194. package/src/hooks/PromptTransformed.ts +3 -3
  195. package/src/hooks/RtkWrap.ts +5 -5
  196. package/src/hooks/SecurityValidator.ts +7 -7
  197. package/src/hooks/SessionClose.ts +12 -6
  198. package/src/hooks/SkillGuard.ts +2 -2
  199. package/src/hooks/StopDeferred.ts +2 -2
  200. package/src/hooks/StopOrchestrator.ts +19 -19
  201. package/src/hooks/UserPromptOrchestrator.ts +9 -6
  202. package/src/hooks/handlers/agenda.ts +7 -7
  203. package/src/hooks/handlers/backup.ts +3 -3
  204. package/src/hooks/handlers/context-digests.ts +3 -3
  205. package/src/hooks/handlers/desktop-notify.ts +3 -3
  206. package/src/hooks/handlers/entity-extraction.ts +14 -10
  207. package/src/hooks/handlers/inject-retrieval.ts +17 -17
  208. package/src/hooks/handlers/persist-last-exchange.ts +7 -3
  209. package/src/hooks/handlers/project-touch.ts +6 -2
  210. package/src/hooks/handlers/rating.ts +20 -21
  211. package/src/hooks/handlers/readme-sync.ts +3 -3
  212. package/src/hooks/handlers/session-intelligence.ts +15 -15
  213. package/src/hooks/handlers/session-name.ts +4 -4
  214. package/src/hooks/handlers/synthesis.ts +2 -2
  215. package/src/hooks/handlers/update-check.ts +32 -7
  216. package/src/hooks/handlers/update-counts.ts +3 -3
  217. package/src/hooks/handlers/work-session.ts +8 -8
  218. package/src/hooks/lib/auto-update.ts +19 -6
  219. package/src/hooks/lib/collect-trigger.ts +23 -7
  220. package/src/hooks/lib/cursor-shadow.ts +2 -2
  221. package/src/hooks/lib/hook-turn.ts +6 -54
  222. package/src/hooks/lib/invocation-context.ts +7 -7
  223. package/src/hooks/lib/post-tool.ts +6 -6
  224. package/src/hooks/lib/prompt-capture.ts +1 -1
  225. package/src/hooks/lib/shadow-judgments.ts +3 -3
  226. package/src/hooks/lib/stdin.ts +1 -1
  227. package/src/hooks/lib/stop.ts +38 -30
  228. package/src/hooks/lib/telemetry.ts +9 -4
  229. package/src/inference/agent-login.ts +101 -0
  230. package/src/{hooks/lib → inference}/antigravity-inference.ts +2 -2
  231. package/src/{hooks/lib → inference}/detached-inference.ts +2 -2
  232. package/src/inference/inference-agents.ts +457 -0
  233. package/src/inference/inference-api.ts +143 -0
  234. package/src/inference/inference-binaries.ts +53 -0
  235. package/src/{hooks/lib → inference}/inference-events.ts +2 -2
  236. package/src/inference/inference-prompt.ts +70 -0
  237. package/src/inference/inference-spawn.ts +288 -0
  238. package/src/inference/inference-types.ts +33 -0
  239. package/src/{hooks/lib → inference}/inference-usage.ts +1 -11
  240. package/src/inference/inference.ts +371 -0
  241. package/src/{hooks/lib → inference}/judge-events.ts +1 -1
  242. package/src/{hooks/lib → inference}/judge-fallback.ts +1 -1
  243. package/src/{hooks/lib → inference}/judge.ts +3 -3
  244. package/src/inference/login-cache.ts +63 -0
  245. package/src/inference/login-rejected.ts +44 -0
  246. package/src/{hooks/lib → inference}/models.ts +1 -1
  247. package/src/{hooks/lib → inference}/opencode-config.ts +1 -1
  248. package/src/{hooks/lib → inference}/system-one-typesafe.ts +1 -1
  249. package/src/{hooks/lib → knowledge}/entity-cards.ts +2 -2
  250. package/src/{hooks/lib → knowledge}/entity-events.ts +1 -1
  251. package/src/{hooks/lib → knowledge}/entity-extraction.ts +6 -9
  252. package/src/{hooks/lib → knowledge}/entity-research.ts +3 -3
  253. package/src/{hooks/lib → knowledge}/entity-review.ts +1 -1
  254. package/src/{tools/knowledge → knowledge}/ingest.ts +5 -10
  255. package/src/{tools/knowledge → knowledge}/lib.ts +3 -73
  256. package/src/knowledge/yaml-scalars.ts +70 -0
  257. package/src/{hooks/lib → opinions}/adaptation-candidates.ts +2 -2
  258. package/src/{hooks/lib → opinions}/adaptation-rules.ts +3 -3
  259. package/src/{hooks/lib → opinions}/adaptation-steering.ts +6 -3
  260. package/src/{hooks/lib → opinions}/adaptation-turns.ts +8 -12
  261. package/src/{hooks/lib → opinions}/algorithm-review.ts +3 -2
  262. package/src/{hooks/lib → opinions}/analyze-nudge.ts +1 -1
  263. package/src/{hooks/lib → opinions}/claim-check.ts +3 -3
  264. package/src/{hooks/lib → opinions}/claim-log.ts +11 -10
  265. package/src/{hooks/lib → opinions}/correction-backfill.ts +1 -1
  266. package/src/{hooks/lib → opinions}/graduation.ts +6 -5
  267. package/src/{hooks/lib → opinions}/interaction-reaction.ts +1 -1
  268. package/src/{hooks/lib → opinions}/interaction-samples.ts +2 -2
  269. package/src/{hooks/lib → opinions}/interaction.ts +18 -9
  270. package/src/{hooks/lib → opinions}/learning-store.ts +2 -4
  271. package/src/{hooks/lib → opinions}/rating-judgments.ts +6 -6
  272. package/src/{hooks/lib → opinions}/reaction-audit.ts +1 -1
  273. package/src/{hooks/lib → opinions}/reply-checks.ts +2 -2
  274. package/src/{hooks/lib → opinions}/rule-effect.ts +2 -2
  275. package/src/{hooks/lib → opinions}/send-back-guard.ts +2 -3
  276. package/src/{hooks/lib → opinions}/steering.ts +4 -6
  277. package/src/{hooks/lib → opinions}/telos-goals.ts +1 -1
  278. package/src/{hooks/lib → opinions}/telos-topics.ts +1 -1
  279. package/src/{hooks/lib → opinions}/turn-extras.ts +1 -1
  280. package/src/{hooks/lib → progress}/agenda-store.ts +1 -1
  281. package/src/progress/algorithm-run-check-report.ts +121 -0
  282. package/src/progress/algorithm-run-checks.ts +198 -0
  283. package/src/progress/algorithm-run-facts.ts +67 -0
  284. package/src/progress/algorithm-run-replay.ts +204 -0
  285. package/src/progress/algorithm-run-report.ts +153 -0
  286. package/src/progress/algorithm-run-tools.ts +99 -0
  287. package/src/progress/algorithm-runs.ts +186 -0
  288. package/src/{hooks/lib → progress}/bindings.ts +7 -42
  289. package/src/{hooks/lib → progress}/capture-store.ts +1 -1
  290. package/src/{hooks/lib → progress}/commitment-events.ts +1 -1
  291. package/src/{hooks/lib → progress}/goal-links.ts +1 -1
  292. package/src/{hooks/lib → progress}/merged-worktrees.ts +1 -1
  293. package/src/{hooks/lib → progress}/parked-context.ts +3 -3
  294. package/src/{hooks/lib → progress}/parked-history.ts +11 -12
  295. package/src/progress/progress-artifact-match.ts +31 -0
  296. package/src/{hooks/lib → progress}/progress-session.ts +5 -1
  297. package/src/{hooks/lib → progress}/progress-tree-context.ts +2 -2
  298. package/src/{hooks/lib → progress}/progress-tree-git.ts +5 -3
  299. package/src/{hooks/lib → progress}/progress-tree-prs.ts +7 -3
  300. package/src/progress/progress-tree-stop.ts +25 -0
  301. package/src/{hooks/lib → progress}/progress-tree-tool.ts +6 -5
  302. package/src/progress/progress-tree-worktrees.ts +117 -0
  303. package/src/{hooks/lib → progress}/progress-tree.ts +3 -34
  304. package/src/progress/projects-context.ts +184 -0
  305. package/src/progress/projects-legacy.ts +51 -0
  306. package/src/{hooks/lib → progress}/projects.ts +43 -261
  307. package/src/{hooks/lib → progress}/scheduled-prompts.ts +5 -4
  308. package/src/{hooks/lib → progress}/session-names.ts +1 -1
  309. package/src/{hooks/lib → progress}/work-tracking.ts +11 -10
  310. package/src/safety/minimum-events.ts +50 -0
  311. package/src/safety/minimum-prompt.ts +136 -0
  312. package/src/{hooks/lib → safety}/run-estimates.ts +2 -2
  313. package/src/{hooks/lib → safety}/run-mode-gate.ts +88 -2
  314. package/src/{hooks/lib → safety}/run-mode.ts +55 -6
  315. package/src/{hooks/lib → safety}/security-gate.ts +15 -7
  316. package/src/{hooks/lib → safety}/security.ts +14 -2
  317. package/src/{hooks/lib → safety}/slurp-check.ts +7 -6
  318. package/src/{hooks/lib → safety}/slurp-detect.ts +1 -1
  319. package/src/targets/agent-render.ts +2 -5
  320. package/src/targets/antigravity/install.ts +3 -3
  321. package/src/targets/antigravity/uninstall.ts +2 -2
  322. package/src/targets/claude/agents.ts +1 -1
  323. package/src/targets/claude/attribution.ts +1 -1
  324. package/src/targets/claude/install.ts +2 -2
  325. package/src/targets/claude/uninstall.ts +1 -1
  326. package/src/targets/codex/install.ts +1 -1
  327. package/src/targets/codex/uninstall.ts +1 -1
  328. package/src/targets/copilot/install.ts +1 -1
  329. package/src/targets/copilot/uninstall.ts +1 -1
  330. package/src/targets/cursor/install.ts +1 -1
  331. package/src/targets/cursor/uninstall.ts +1 -1
  332. package/src/targets/opencode/install.ts +2 -2
  333. package/src/targets/opencode/permission.ts +1 -1
  334. package/src/targets/opencode/plugin.ts +37 -14
  335. package/src/targets/opencode/uninstall.ts +2 -2
  336. package/src/targets/pal-docs.ts +1 -3
  337. package/src/targets/personal-subagents.ts +2 -2
  338. package/src/targets/scaffold.ts +10 -11
  339. package/src/targets/shipped-agents.ts +2 -2
  340. package/src/targets/skill-index.ts +4 -7
  341. package/src/targets/skills.ts +13 -8
  342. package/src/targets/statusline.ts +2 -2
  343. package/src/targets/symlink.ts +1 -1
  344. package/src/tools/agent/algorithm-reflect.ts +7 -5
  345. package/src/tools/agent/algorithm-synthesize.ts +9 -7
  346. package/src/tools/agent/analyze.ts +2 -2
  347. package/src/tools/agent/interaction.ts +4 -4
  348. package/src/tools/agent/project-io.ts +42 -0
  349. package/src/tools/agent/project-isc-commands.ts +269 -0
  350. package/src/tools/agent/project-migrate.ts +56 -0
  351. package/src/tools/agent/project-task-isa.ts +62 -0
  352. package/src/tools/agent/project.ts +17 -425
  353. package/src/tools/agent/synthesize.ts +5 -49
  354. package/src/tools/control-room/attention.ts +3 -3
  355. package/src/tools/control-room/data.ts +8 -7
  356. package/src/tools/control-room/detail.ts +2 -2
  357. package/src/tools/control-room/matrix.ts +4 -8
  358. package/src/tools/control-room/prefs.ts +3 -7
  359. package/src/tools/control-room/relationship.ts +7 -11
  360. package/src/tools/control-room/server.ts +3 -3
  361. package/src/tools/control-room/snooze.ts +2 -2
  362. package/src/tools/control-room/static.ts +1 -1
  363. package/src/tools/control-room/ui/dist/assets/{index-cwDTgyVP.css → index-ClXFaob0.css} +1 -1
  364. package/src/tools/control-room/ui/dist/index.html +2 -2
  365. package/src/tools/control-room/ui/package.json +4 -4
  366. package/src/tools/control-room/ui/parts.tsx +1 -1
  367. package/src/tools/control-room/ui/screens/log.tsx +1 -1
  368. package/src/tools/control-room/ui/screens/relationship.tsx +2 -5
  369. package/src/tools/control-room/work.ts +2 -2
  370. package/src/tools/control-room/writes.ts +3 -7
  371. package/src/tools/dark-factory/stamp.ts +1 -1
  372. package/src/tools/knowledge/graph.ts +6 -5
  373. package/src/tools/ledger/query.ts +4 -4
  374. package/src/tools/ledger/view.ts +3 -3
  375. package/src/tools/lib/algorithm-reflect.ts +5 -2
  376. package/src/tools/lib/analyze-report.ts +1 -1
  377. package/src/tools/lib/backfill/entities.ts +2 -2
  378. package/src/tools/lib/backfill/git.ts +2 -2
  379. package/src/tools/lib/backfill/index.ts +3 -3
  380. package/src/tools/lib/backfill/ledger.ts +1 -5
  381. package/src/tools/lib/backfill/projects.ts +2 -2
  382. package/src/tools/lib/backfill/promises.ts +2 -2
  383. package/src/tools/lib/backfill/ratings.ts +1 -1
  384. package/src/tools/lib/backfill/rows.ts +1 -1
  385. package/src/tools/lib/backfill/sessions.ts +2 -2
  386. package/src/tools/lib/backfill/turns.ts +2 -6
  387. package/src/tools/lib/collectors/antigravity.ts +1 -1
  388. package/src/tools/lib/collectors/claude-denials.ts +240 -0
  389. package/src/tools/lib/collectors/claude.ts +93 -66
  390. package/src/tools/lib/collectors/codex.ts +2 -2
  391. package/src/tools/lib/collectors/copilot.ts +2 -2
  392. package/src/tools/lib/collectors/cursors.ts +1 -1
  393. package/src/tools/lib/collectors/index.ts +19 -11
  394. package/src/tools/lib/collectors/logged-keys.ts +61 -0
  395. package/src/tools/lib/collectors/opencode.ts +2 -2
  396. package/src/tools/lib/cost/efficiency.ts +1 -1
  397. package/src/tools/lib/cost/leaderboards.ts +1 -1
  398. package/src/tools/lib/cost/mix.ts +1 -1
  399. package/src/tools/lib/cost/overhead.ts +1 -1
  400. package/src/tools/lib/cost-report.ts +2 -2
  401. package/src/tools/lib/emit.ts +1 -1
  402. package/src/tools/lib/interaction-report.ts +5 -5
  403. package/src/tools/lib/patterns/activity.ts +1 -1
  404. package/src/tools/lib/patterns/profiles.ts +2 -2
  405. package/src/tools/lib/project-history.ts +3 -3
  406. package/src/tools/lib/project-resolver.ts +3 -7
  407. package/src/tools/lib/run-stats.ts +6 -6
  408. package/src/tools/lib/session-usage.ts +6 -2
  409. package/src/tools/lib/skill-doctor.ts +19 -144
  410. package/src/tools/lib/skill-parse.ts +134 -0
  411. package/src/tools/lib/thread.ts +2 -2
  412. package/src/tools/lib/usage-buckets.ts +7 -3
  413. package/src/tools/lib/wrapped/agents.ts +1 -1
  414. package/src/tools/lib/wrapped/habits.ts +2 -2
  415. package/src/tools/lib/wrapped/pal.ts +2 -2
  416. package/src/tools/lib/wrapped/records.ts +1 -1
  417. package/src/tools/lib/wrapped/render.ts +1 -1
  418. package/src/tools/lib/wrapped/totals.ts +1 -1
  419. package/src/tools/lib/wrapped/year.ts +2 -6
  420. package/src/tools/subagent-doctor.ts +15 -199
  421. package/src/tools/subagent-platform-checks.ts +195 -0
  422. package/src/tools/token-cost.ts +7 -7
  423. package/src/{hooks/lib → usage}/attention-events.ts +3 -3
  424. package/src/{tools/lib/collectors → usage}/billing.ts +1 -1
  425. package/src/usage/call-traits.ts +53 -0
  426. package/src/{hooks/lib → usage}/discord-events.ts +1 -1
  427. package/src/usage/health-cache.ts +105 -0
  428. package/src/{hooks/lib → usage}/hook-run.ts +1 -1
  429. package/src/{hooks/lib → usage}/hook-timing.ts +1 -1
  430. package/src/{hooks/lib → usage}/session-events.ts +3 -3
  431. package/src/{hooks/lib → usage}/tool-events.ts +42 -51
  432. package/src/{hooks/lib → usage}/waiting-on-user.ts +1 -1
  433. package/assets/skills/consulting-report/demo/app/globals.css +0 -459
  434. package/assets/skills/consulting-report/demo/app/layout.tsx +0 -32
  435. package/assets/skills/consulting-report/demo/app/page.tsx +0 -371
  436. package/assets/skills/consulting-report/demo/bun.lock +0 -243
  437. package/assets/skills/consulting-report/demo/components/callout.tsx +0 -13
  438. package/assets/skills/consulting-report/demo/components/comparison-table.tsx +0 -40
  439. package/assets/skills/consulting-report/demo/components/cover-page.tsx +0 -34
  440. package/assets/skills/consulting-report/demo/components/exhibit.tsx +0 -21
  441. package/assets/skills/consulting-report/demo/components/finding-card.tsx +0 -28
  442. package/assets/skills/consulting-report/demo/components/quote-block.tsx +0 -17
  443. package/assets/skills/consulting-report/demo/components/recommendation-card.tsx +0 -52
  444. package/assets/skills/consulting-report/demo/components/section.tsx +0 -17
  445. package/assets/skills/consulting-report/demo/components/severity-badge.tsx +0 -20
  446. package/assets/skills/consulting-report/demo/components/stat-grid.tsx +0 -26
  447. package/assets/skills/consulting-report/demo/components/table-of-contents.tsx +0 -27
  448. package/assets/skills/consulting-report/demo/components/timeline.tsx +0 -20
  449. package/assets/skills/consulting-report/demo/lib/utils.ts +0 -6
  450. package/assets/skills/consulting-report/demo/next.config.js +0 -9
  451. package/assets/skills/consulting-report/demo/package.json +0 -27
  452. package/assets/skills/consulting-report/demo/postcss.config.mjs +0 -5
  453. package/assets/skills/consulting-report/demo/tsconfig.json +0 -41
  454. package/src/hooks/lib/context-overhead.ts +0 -30
  455. package/src/hooks/lib/export-manifest.ts +0 -23
  456. package/src/hooks/lib/inference.ts +0 -1379
  457. package/src/hooks/lib/progress-tree-stop.ts +0 -14
  458. package/src/hooks/lib/progress-tree-worktrees.ts +0 -80
  459. package/src/hooks/lib/transcript-preserve.ts +0 -145
  460. /package/src/{hooks/lib → bronze}/channel.ts +0 -0
  461. /package/src/{hooks/lib → bronze}/evidence.ts +0 -0
  462. /package/src/{hooks/lib → context}/skill-triggers.ts +0 -0
  463. /package/src/{hooks/lib → core}/actor.ts +0 -0
  464. /package/src/{hooks/lib → core}/agent-definition.ts +0 -0
  465. /package/src/{hooks/lib → core}/agent-registry.ts +0 -0
  466. /package/src/{hooks/lib → core}/frontmatter.ts +0 -0
  467. /package/src/{hooks/lib → core}/identity-store.ts +0 -0
  468. /package/src/{hooks/lib → core}/machine.ts +0 -0
  469. /package/src/{hooks/lib → core}/notify.ts +0 -0
  470. /package/src/{hooks/lib → core}/pal-env.ts +0 -0
  471. /package/src/{hooks/lib → core}/prompt-text.ts +0 -0
  472. /package/src/{hooks/lib → core}/remote.ts +0 -0
  473. /package/src/{hooks/lib → core}/session-dir.ts +0 -0
  474. /package/src/{hooks/lib → core}/text-similarity.ts +0 -0
  475. /package/src/{hooks/lib → core}/time.ts +0 -0
  476. /package/src/{hooks/lib → core}/wall-clock.ts +0 -0
  477. /package/src/{hooks/lib → core}/which.ts +0 -0
  478. /package/src/{hooks/lib → inference}/judgment.ts +0 -0
  479. /package/src/{tools/lib → inference}/transcript-usage.ts +0 -0
  480. /package/src/{hooks/lib → knowledge}/company-register-router.ts +0 -0
  481. /package/src/{hooks/lib → knowledge}/company-register.ts +0 -0
  482. /package/src/{hooks/lib → knowledge}/entity-names.ts +0 -0
  483. /package/src/{hooks/lib → knowledge}/hungarian-registry.ts +0 -0
  484. /package/src/{hooks/lib → opinions}/correction-kind.ts +0 -0
  485. /package/src/{hooks/lib → opinions}/correction-rates.ts +0 -0
  486. /package/src/{hooks/lib → opinions}/interaction-hint-check.ts +0 -0
  487. /package/src/{hooks/lib → opinions}/interaction-mood.ts +0 -0
  488. /package/src/{hooks/lib → opinions}/interaction-preferences.ts +0 -0
  489. /package/src/{hooks/lib → opinions}/opinion-gate.ts +0 -0
  490. /package/src/{hooks/lib → opinions}/reaction-rating.ts +0 -0
  491. /package/src/{hooks/lib → opinions}/rule-drafter.ts +0 -0
  492. /package/src/{hooks/lib → opinions}/rule-proof.ts +0 -0
  493. /package/src/{hooks/lib → progress}/progress-tree-factory.ts +0 -0
  494. /package/src/{hooks/lib → progress}/progress-tree-render.ts +0 -0
  495. /package/src/{hooks/lib → progress}/progress-tree-session-end.ts +0 -0
  496. /package/src/{hooks/lib → progress}/progress-tree-session-node.ts +0 -0
  497. /package/src/{hooks/lib → progress}/progress-tree-tidy.ts +0 -0
  498. /package/src/{hooks/lib → progress}/serves.ts +0 -0
  499. /package/src/{hooks/lib → safety}/rtk-jq.ts +0 -0
  500. /package/src/{hooks/lib → safety}/rtk-worktree.ts +0 -0
  501. /package/src/tools/control-room/ui/dist/assets/{index-CaPwwSsD.js → index-DtUW62FY.js} +0 -0
  502. /package/src/{hooks/lib → usage}/opencode-events.ts +0 -0
@@ -10,6 +10,11 @@
10
10
  "name": "dark-factory",
11
11
  "source": "./assets/plugins/dark-factory",
12
12
  "description": "A software factory of agents that turns a request into a green, reviewed pull request."
13
+ },
14
+ {
15
+ "name": "pal-status",
16
+ "source": "./assets/plugins/pal-status",
17
+ "description": "PAL's status above the prompt. Today it holds PAL's standing notice, such as data moves required before 1.0, until it is fixed."
13
18
  }
14
19
  ]
15
20
  }
package/README.md CHANGED
@@ -83,7 +83,7 @@ pal cli status # check your setup
83
83
  | `pal cli init` | Scaffold PAL home directory and install hooks |
84
84
  | `pal cli install` | Register hooks/skills for targets |
85
85
  | `pal cli uninstall` | Remove hooks/skills for targets |
86
- | `pal cli update` | Update PAL (git pull or npm update) and reinstall hooks. Install asks once whether to do this on its own: when a session closes PAL checks for a release (at most hourly) and installs it, so opening PAL is never slowed. A failed update waits a day before retrying. The switch lives in the control room under Settings → Updates. On a repo install an update waits while the clone has uncommitted changes. `--canary` switches a package install to the `canary` prerelease channel; from then on plain `pal cli update`, auto-update and the update notice follow canary until `--stable` switches back. Neither ever installs an older version than the one you have |
86
+ | `pal cli update` | Update PAL (git pull or npm update) and reinstall hooks. Install asks once whether to do this on its own: when a session closes PAL checks for a release (at most hourly) and installs it, so opening PAL is never slowed. A failed update waits a day before retrying. The switch lives in the control room under Settings → Updates. On a repo install an update waits while the clone has uncommitted changes. `--canary` switches a package install to the `canary` prerelease channel; from then on plain `pal cli update`, auto-update and the update notice follow canary until `--stable` switches back. Neither ever installs an older version than the one you have. Updates stay within the installed major version: a new major is installed only by `pal cli update --major`, and the update notice and statusline say so |
87
87
  | `pal cli export` | Export user state (telos, memory) to a zip |
88
88
  | `pal cli import` | Import user state from a zip |
89
89
  | `pal cli status` | Show current PAL configuration |
@@ -94,16 +94,18 @@ pal cli status # check your setup
94
94
  | `pal cli cost` | What each month was paid against its API-equivalent cost, per agent |
95
95
  | `pal cli wrapped [--year <yyyy>]` | A year of your work in numbers, read from the event log |
96
96
  | `pal cli env [--refresh]` | The OS and script languages PAL tells every agent about; `--refresh` detects again after you install one |
97
+ | `pal cli auth [--refresh] [--json]` | When the active agent's login expires (Claude only; other agents do not report it). Reads the answer cached at session start; `--refresh` asks the agent again |
97
98
  | `pal cli patterns` | How you work across projects, read from the event log |
98
99
  | `pal cli progress [show\|list\|open\|enter\|park\|wait\|done\|stopped\|decide\|attach\|follow-up]` | The progress tree: what you are on in this project, where it stopped, what is parked or waiting, and the decisions and artifacts on each node. Detours are child nodes and `done` returns to the parent. The active node rides along in every session and prompt, and your own commits attach to it at turn end |
99
100
  | `pal cli timebox [start\|status\|end]` | Stop work at a deadline: `start --for 15m` or `--until 18:00`. After the deadline every working tool call is refused except `pal cli` and edits to the report, so the agent stops and reports what it has |
100
101
  | `pal cli schedule [add\|list\|remove]` | Prompts added at a time of day, for you or for one project: `add --from 20:00 "suggest tasks that can run overnight"`. A due schedule is added to the next prompt you write inside its window, once a day by default (`--every-session`, `--every-prompt`), and nothing fires while no session is open |
102
+ | `pal cli minimum [start\|round\|status\|end]` | Keep working at least until a floor: `start --for 30m --goal … --bar "clarity: 9/10, reread against the brief"`. Before the floor a stop is sent back with the goal, the bar, the last round's weakest point and a rotating lens (fresh-context critic, skeptic, simplify, …); questions and the agent's own `end` are refused, so only you end it early |
101
103
  | `pal cli unattended [start\|log\|status\|done\|end]` | Work without you until a deadline: `start --until 05:30 --task … --fallback …`. Questions and subagents are refused, the agent cannot stop while approved tasks are left, and the rules, tasks and log come back after a compaction |
102
- | `pal cli content preserve` | Copy every Claude Code transcript, gzipped, into `memory/content/` before Claude Code deletes it (30 days by default). Runs on its own whenever a session closes; the content store never leaves the machine, so `export` skips it |
104
+ | `pal cli content preserve` | Copy every Claude Code transcript, gzipped, into `records/raw/claude/` before Claude Code deletes it (30 days by default). Runs on its own whenever a session closes; the content store never leaves the machine, so `export` skips it |
103
105
  | `pal cli events discord-nag <sent\|answered>` | For a bot outside PAL: record a nag it sent (`--kind <kind>`), or the answer to one and how long it took (`--after-sec <n>`), in the local event log |
104
106
  | `pal cli evidence [turns\|show\|forget\|unforget\|forgotten]` | What PAL learns from: `turns` lists the turns you typed (`--days <n>`, `--json`) with their text and the reply each got, and `show <id>` prints one event's stored text. `forget <id>` keeps a turn or reply out of everything PAL learns without deleting its text; `forgotten` lists every forgotten event and `unforget <id>` undoes one. Every forget and unforget stays in the event log |
105
107
  | `pal cli infer` | One model call for scripts and bots, on the active agent's route: prompt on stdin, reply on stdout. `--tier small\|medium\|large\|flagship` (on Claude: Haiku, Sonnet, Opus, Fable; on Codex: Luna, Sol, Sol at high effort, Astra; on Antigravity: Flash at low, medium and high effort, and no flagship; an agent without the tier asked refuses it), `--system <file>`, `--schema <file>` for a JSON reply checked against it, `--timeout <seconds>`. The call loads no PAL hooks or context; exits 1 with the reason when no route answers |
106
- | `pal cli judge [file]` | Answer typed questions (`choice`, `noul`, `score`) about a state, from a JSON request in the file or on stdin; prints the answers and the route as JSON. With `systemOne` in `pal-settings.json` (`provider: "typesafe"`, optional `model`, default `jev-1.14.0`, and `callers` set to `shadow` or `live`), the named callers also ask that provider, which sends their text to it; the key is `PAL_TYPESAFE_API_KEY`, else `TYPESAFE_API_KEY`. Without it, or when the provider fails, the small tier answers |
108
+ | `pal cli judge [file]` | Answer typed questions (`choice`, `noul`, `score`) about a state, from a JSON request in the file or on stdin; prints the answers and the route as JSON. With `systemOne` in `~/.pal/settings.json` (`provider: "typesafe"`, optional `model`, default `jev-1.14.0`, and `callers` set to `shadow` or `live`), the named callers also ask that provider, which sends their text to it; the key is `PAL_TYPESAFE_API_KEY`, else `TYPESAFE_API_KEY`. Without it, or when the provider fails, the small tier answers |
107
109
  | `pal cli actor [label <name>]` | Show or rename the actor — who caused a record. Travels with an export, so a shared memory can tell two people apart |
108
110
  | `pal cli machine [label <name>]` | Show or rename this install — where a record was written. Never leaves the machine |
109
111
  | `pal cli telos` | Which TELOS topics are answered, in interview order, and which one comes next |
@@ -113,6 +115,7 @@ pal cli status # check your setup
113
115
  | `pal cli rule` | Review the rules drafted from your corrections — `list [--all] [--json]`, `approve <id>`, `opinion <id>`, `deny <id>`, `retire <id>`, `add-opinion --kind --when --steering`. A draft steers nothing until approved; a denied one is never drafted again. An opinion has no trigger and steers every session, at most 8 of them and one per correction kind; `list --all` shows each one's correction-kind rate before and after approval |
114
116
  | `pal cli correction` | The kinds of mistakes you corrected — `kinds [--days N] [--split DATE] [--json]` shows each kind per 100 turns, before and after a date with `--split`; `backfill` labels confirmed corrections without a kind or with one from an older prompt, and `--relabel` labels every one again |
115
117
  | `pal cli compaction backtest` | Score the shadow "compaction is close" rule against logged history. Labels each auto compaction `threshold`, `idle`, `no_context` or `unexplained`, and per margin reports the threshold compactions it warned and missed, its false alarms, and the median lead in minutes and tokens. `--margin <fraction>[,...]` (default 0.2), `--days <n>` (default 30), `--window <tokens>[@<until>]` (repeatable), `--json` |
118
+ | `pal cli algorithm-run report` | Shadow numbers for ALGORITHM runs, recorded per progress-tree node: turns and runs started, how runs ended (finished, superseded, open), verdicts with the share of `no-node`, turns without a reflection by the last phase reached, and every `over-open-run` case to label; then the run checks: run types (code, research, explain), exemptions, would-nudge verdicts per check (`no-reflection`, `no-check-after-edit`, `uncited-fetch`), the verdicts on exempt turns by exemption reason, and one line per case to label. Records only; warns and blocks nothing. `--since <date>`, `--json` |
116
119
  | `pal cli server` | The morning screen: a local page to open before a terminal — three moves for today, an urgent/important grid over every project *and* every stated goal, where you left off, and a drawer holding the signal and the action ledger — `start [--port <n>]`, `stop`, `status`. Loopback only, default port 7250. No model runs on page load |
117
120
  | `pal cli skill link <name>` | Link a personal `~/.pal/skills/<name>/` into every installed agent so it is discoverable |
118
121
  | `pal cli skill doctor <name>` | Evaluate a skill against the authoring best practices (folder/file-name match, name, description, body length, point-of-view, reference depth) |
@@ -198,6 +201,7 @@ pal cli debug # show current status and log path
198
201
  | `PAL_INFERENCE_DISABLED` | Set to `1` to disable all inference (used by the test suite to prevent real CLI spawns) |
199
202
  | `PAL_NOTIFICATIONS_DISABLED` | Set to `1` to suppress desktop notifications (used by the test suite) |
200
203
  | `PAL_TEST_SANDBOX` | Set by the test suite. Without a `PAL_HOME`, state goes to a temp directory instead of `~/.pal`, and installers refuse to touch real agent directories |
204
+ | `PAL_TEST_ROOT` | Set by the test suite: the folder test homes live in. Each mutation-testing worker gets its own, so parallel workers never share a test home |
201
205
 
202
206
  ### Telemetry
203
207
 
@@ -4,19 +4,21 @@ A customizable status line for Claude Code that displays context usage, active m
4
4
 
5
5
  ## What It Shows
6
6
 
7
- **Line 1:** Model name, current directory, git branch, hook health, open ISCs, signal trend
7
+ **Line 1:** Model name, current directory, git branch, open ISCs
8
8
  **Line 2:** Context usage progress bar, percentage used, session cost, remaining context, rate limits
9
- **Line 3:** Update notice (only when a new PAL version is available)
9
+ **Line 3:** Update notice (only when a new PAL version is available)
10
+ **Run line:** The timebox, unattended or minimum run of this folder or project: its deadline (or floor) in your PAL timezone, time left and, for a minimum run, rounds logged (only while one is on)
11
+ **Health line:** The worst failing check in red, or the warning count in yellow, pointing to `pal cli doctor` (only when something needs attention)
10
12
 
11
13
  Example output (macOS/Linux):
12
14
  ```
13
- [Opus] 📁 portable-agent-layer 🌿 main 📋 21 open ISCs sig: 3.0/10 ↓
15
+ [Opus] 📁 portable-agent-layer 🌿 main 📋 21 open ISCs
14
16
  ████████░░░░░░░░░░░░ 45% │ $0.12 │ 55% free
15
17
  ```
16
18
 
17
19
  Example output (Windows):
18
20
  ```
19
- [Opus] folder: portable-agent-layer (git: main) 21 open ISCs sig: 3.0/10 v
21
+ [Opus] folder: portable-agent-layer (git: main) 21 open ISCs
20
22
  ########------------ 45% - $0.12 - 55% free
21
23
  ```
22
24
 
@@ -67,7 +69,7 @@ chmod +x ~/.cursor/statusline.sh
67
69
 
68
70
  Copy `assets/statusline.sh` to `~/.cursor/statusline.sh` (or symlink). Restart the Cursor CLI after editing config.
69
71
 
70
- On Cursor, session cost and rate limits are usually absent from stdin — the script omits the cost segment and hides rate limits automatically. PAL indicators (hooks, ISCs, signal, update) still read from `~/.pal/memory/state/`.
72
+ On Cursor, session cost and rate limits are usually absent from stdin — the script omits the cost segment and hides rate limits automatically. PAL indicators (hooks, ISCs, update) still read from `~/.pal/memory/state/`.
71
73
 
72
74
  ### On Windows
73
75
 
@@ -95,15 +97,14 @@ The statusline script is at: `portable-agent-layer/assets/statusline.ps1`
95
97
  - **Model:** Active Claude model (Opus, Sonnet, Haiku, etc.)
96
98
  - **Directory:** Repository name (if in a git repo) or folder name
97
99
  - **Git Branch:** Current branch, fetched from git worktree or `git` command
98
- - **Hook Health:** Count of ERROR lines in `~/.pal/memory/state/debug.log` from last 24h (hidden when 0)
99
100
  - **Open ISCs:** Count of unchecked ISCs for the current project (hidden when 0)
100
- - **Signal Trend:** Session quality score from `~/.pal/memory/state/signal-cache.json` with trend arrow
101
101
  - **Context Bar:** Visual progress bar showing token usage
102
102
  - **Context %:** Percentage of context window used
103
103
  - **Cost:** Estimated session cost in USD (shows "free" if <$0.01 on macOS/Linux, `$0.00` on Windows)
104
104
  - **Remaining %:** Percentage of context window remaining
105
105
  - **Rate Limits:** 5h and 7d usage percentages (Pro/Max plans only — hidden on other plans)
106
- - **Update Notice:** Shown on line 3 when `~/.pal/memory/state/update-available.json` flags a new version
106
+ - **Update Notice:** Shown on line 3 when `~/.pal/cache/update-available.json` flags a new version
107
+ - **Health:** Read from `~/.pal/cache/health.json`, which every doctor run writes (PAL starts one in the background at session start when it is missing or over 6 hours old), and `~/.pal/cache/login-rejected.json`, which a rejected background Claude call writes at once. Shows `Claude token rejected` or `Claude login rejected` first, else the worst failing check (with `(+N more)` when several fail), else `N warnings`; hidden when all is fine. Run `pal cli doctor` for the details and fixes
107
108
 
108
109
  ## Dependencies
109
110
 
@@ -43,7 +43,7 @@ You author a single new personal skill for this user. You are handed a **skill n
43
43
 
44
44
  1. Read `~/.pal/skills/create-skill/authoring-guide.md` with your file-reading tool — it is the single source of truth for what a good skill is and the exact anatomy to follow.
45
45
  2. Validate the name: lowercase-kebab, no spaces, not colliding with an existing skill (check `~/.pal/skills/` and the active skill list). If it collides or is malformed, stop and report the conflict instead of overwriting.
46
- 3. Create the skill and write its `SKILL.md` to `~/.pal/skills/<name>/SKILL.md`, creating the folder if it does not exist, populated per the guide's anatomy (frontmatter + Workflow + Output format + When to use).
46
+ 3. Create the skill and write its `SKILL.md` to `~/.pal/skills/<name>/SKILL.md`, creating the folder if it does not exist, populated per the guide's anatomy (frontmatter + Workflow + Output format + When to use + Self-check).
47
47
  4. If the skill needs runtime tooling, scaffold a `tools/` subdir alongside `SKILL.md` and write the scripts there.
48
48
  5. Link the skill into every installed agent:
49
49
  ```bash
@@ -54,7 +54,7 @@ You author a single new personal skill for this user. You are handed a **skill n
54
54
  pal cli skill doctor <name>
55
55
  ```
56
56
  A name/folder mismatch or a misnamed file makes the skill silently fail to load — never skip this.
57
- 7. Hand-check what the doctor can't: trigger clarity, step concreteness (every step has a verb and an object), output specification, and scope discipline (one skill, one job).
57
+ 7. Hand-check what the doctor can't: trigger clarity, step concreteness (every step has a verb and an object), output specification, scope discipline (one skill, one job), and the Self-check section naming this skill's folder.
58
58
 
59
59
  ## Output
60
60
 
@@ -115,11 +115,13 @@ Each repository the factory works on has a `.dark-factory.json` at its root:
115
115
  }
116
116
  ```
117
117
 
118
- The build keeps the code step from editing a test. Right before the code step it fingerprints the worktree, and every test file in it is protected; after the code step a protected file that changed or was deleted is listed in a `test_edits_restored` event and restored by the fix ladder, and a second change stops the task stuck. A file is a test file when its path starts with an entry of `testPaths`, for example `"testPaths": ["spec/"]`. Without `testPaths`, a file is a test file when its name contains `.test.` or `.spec.`, or a directory in its path is named `test`, `tests` or `__tests__`. New test files are allowed.
118
+ The build keeps the code step from editing a test. Right before the code step it fingerprints the worktree, and every test file in it is protected; after the code step a protected file that changed or was deleted is listed in a `test_edits_restored` event and restored by the fix ladder, and a second change stops the task stuck. A file is a test file when its path starts with an entry of `testPaths`, for example `"testPaths": ["spec/"]`. Without `testPaths`, a file is a test file when its name contains `.test.` or `.spec.`, or a directory in its path is named `test`, `tests` or `__tests__`. New test files are allowed. Before a restore, the build asks the PO, with each file's diff: a file the PO names in `testFix` keeps its change, logged as `test_edits_kept`, and is protected from then on in its new content. The ruling counts toward the run's 2 test fixes; once they are spent, edits are restored without asking. `step.mjs test-edits` still only lists the files.
119
119
 
120
120
  A spec can name the test files the task is meant to change in a section headed exactly `## Test files this task changes`, with one repo-relative path per `- ` bullet, backticks optional. The guard leaves those files out: they are not restored, not listed, and a second change does not stop the build. Only `spec.md` grants this, and the same section in `plan.md`, `tests.md`, `repro.md` or `design.md` exempts nothing. The list is read each time the guard runs, so a spec changed during the build counts. The review, tester and CI fix ladders are guarded like the code step: each fingerprints the worktree before its first rung, and once it passes the gate a protected test file it changed is restored the same way.
121
121
 
122
- The categories with a test writer (`bug`, `feature` and `big-feature`) need a gate check named exactly `tests`. The build runs it right after the test writer, and the task is stuck when no test fails. Before that check, the build runs the gate for the role `test-writer`; when it fails, the test writer runs again with the failed checks, at most 2 more times, and then the task is stuck.
122
+ The categories with a test writer (`bug`, `feature` and `big-feature`) need a gate check named exactly `tests`. The build runs it right after the test writer, and the task is stuck when no test fails. Before that check, the build runs the gate for the role `test-writer`; when it fails, the test writer runs again with the failed checks, at most 2 more times, and then the task is stuck. The unit tests typed from plan.md may add the code the plan defines as stubs that only fail when they run (`todo!()` in Rust), so that in a compiled language they compile and fail with a count. When they do not compile, the build sends the test writer back once with the first compile error; a second failure is stuck with `the tests do not compile: <first error>`. A stub left in place fails the gate, because the test that names it still runs it.
123
+
124
+ The `tests` check must run every test file even when one fails, because the build counts failures to prove the new tests fail. Give `cargo test` the `--no-fail-fast` flag, and do not join two suites with `&&`, which skips the second when the first fails. Run both and keep the first one's failure, for example `cargo test --no-fail-fast; status=$?; bun run test && exit $status`. The build adds up every per-test summary it finds: cargo's `test result:` line for each test binary, bun's ` N fail`, and jest's or vitest's `Tests` line. Per-file lines (`Test Suites`, `Test Files`) are not counted. When the output has none of these lines, the last `N fail` or `N failed` in it is the count.
123
125
 
124
126
  A gate entry may carry `"roles"`, a list of the roles it gates, for example `{ "name": "lint", "run": "bun run lint", "roles": ["test-writer", "code-writer", "debugger"] }`. An entry without `"roles"` gates the code writer and the debugger, as before; an entry with `"roles"` gates exactly the roles listed. The build gates the test writer and the code-writing rungs; `"roles"` may name other roles, but nothing gates them. A config without any `"roles"` gates exactly as it did.
125
127
 
@@ -82,8 +82,9 @@ const ACCEPTANCE_TESTS_INSTRUCTIONS =
82
82
  "Write the failing acceptance tests from spec.md only; there is no plan yet, so do not read plan.md. Write tests.md in the task folder mapping each test to the acceptance criteria it covers. Leave the tests uncommitted; the code writer commits them with the code.";
83
83
  const PLAN_AFTER_TESTS_INSTRUCTIONS =
84
84
  "Write plan.md for this change. Failing acceptance tests already exist in the worktree (see tests.md in the task folder); the plan must make them pass without changing them.";
85
- const UNIT_TESTS_INSTRUCTIONS =
86
- "Type one unit test per row of each example table in plan.md, in the test files the plan names. Test only what the tables state, change no other file, and leave the tests uncommitted. When plan.md has no example tables, change nothing.";
85
+ const STUB_RULE =
86
+ "When a test names a function, type or method that plan.md defines and that does not exist yet, add it where plan.md puts it, with the plan's signature and a body that only fails when it runs (todo!() in Rust, panic in Go, a thrown error elsewhere), so the tests compile and fail; the code writer replaces it.";
87
+ const UNIT_TESTS_INSTRUCTIONS = `Type one unit test per row of each example table in plan.md, in the test files the plan names. Test only what the tables state, change no other file except for those stubs, and leave everything uncommitted. ${STUB_RULE} When plan.md has no example tables, change nothing.`;
87
88
  const SETTLE_PLAN_INSTRUCTIONS =
88
89
  "The plan gate ended with findings it could not settle, and their answers are now in the spec's Decisions. Read spec.md again and apply its Decisions to plan.md.";
89
90
  const REPLAN_INSTRUCTIONS =
@@ -105,7 +106,10 @@ export const FINGERPRINT_UNREADABLE =
105
106
  const TEST_FIX_DIFF_UNREADABLE =
106
107
  "could not list the files the test fix changed: git diff --name-only failed";
107
108
  const TEST_EDITS_EVENT = "test_edits_restored";
109
+ const TEST_EDITS_KEPT_EVENT = "test_edits_kept";
110
+ const TEST_EDIT_DIFF_LIMIT = 4000;
108
111
  const UNIT_TESTS_NO_RISE_EVENT = "unit_tests_no_rise";
112
+ const UNIT_TESTS_NO_COMPILE_EVENT = "unit_tests_do_not_compile";
109
113
 
110
114
  function stuck(message) {
111
115
  return { status: "stuck", message };
@@ -247,6 +251,13 @@ ${changed}
247
251
  Move the tests you added into a new test file that no other test uses, keep the tests themselves as they are, leave them uncommitted, and change no other file.`;
248
252
  }
249
253
 
254
+ function noCompileRetryInstructions(error) {
255
+ return `Your unit tests do not compile, so the test run reports no failing test count. The first error:
256
+ ${error}
257
+
258
+ ${STUB_RULE} Keep the tests as they are, leave everything uncommitted, and change no other file.`;
259
+ }
260
+
250
261
  function unchangedNamedMessage(named, outside) {
251
262
  const base = `the test the PO ruled wrong was not changed: the test writer changed none of ${named.join(", ")}`;
252
263
 
@@ -501,13 +512,40 @@ function untilGreen(run, ladder, instructions, reason) {
501
512
  return { passed: false, failure };
502
513
  }
503
514
 
504
- export function failingTestCount(output) {
515
+ const PER_TEST_SUMMARY_LINES = [
516
+ /^test result: .*?\b(\d+) failed\b/,
517
+ /^\s*(\d+) fail\s*$/,
518
+ /^\s*Tests:?\s+.*?\b(\d+) failed\b/,
519
+ ];
520
+
521
+ function summaryLineFailures(line) {
522
+ const match = PER_TEST_SUMMARY_LINES.map((pattern) => line.match(pattern)).find(
523
+ Boolean
524
+ );
525
+
526
+ return match ? Number(match[1]) : null;
527
+ }
528
+
529
+ function summedSummaryFailures(output) {
530
+ const counts = String(output)
531
+ .split(/\r?\n/)
532
+ .map(summaryLineFailures)
533
+ .filter((count) => count !== null);
534
+
535
+ return counts.length === 0 ? null : counts.reduce((sum, count) => sum + count, 0);
536
+ }
537
+
538
+ function lastFailureMention(output) {
505
539
  const matches = Array.from(String(output).matchAll(/\b(\d+) fail(?:ed)?\b/g));
506
540
  const last = matches.at(-1);
507
541
 
508
542
  return last ? Number(last[1]) : null;
509
543
  }
510
544
 
545
+ export function failingTestCount(output) {
546
+ return summedSummaryFailures(output) ?? lastFailureMention(output);
547
+ }
548
+
511
549
  export function planGateEndedWithFindings(events, taskId) {
512
550
  const gates = events.filter(
513
551
  (event) => event.event === "plan_gate" && event.task === taskId
@@ -527,8 +565,19 @@ function redTestCheck(run) {
527
565
  return run.config.gate.find((entry) => entry.name === RED_TEST_CHECK);
528
566
  }
529
567
 
568
+ const COMPILE_ERROR_LINE =
569
+ /^error(?:\[[A-Z]\d+\])?: (?!could not compile|test failed|\d+ targets? failed).*$/m;
570
+
571
+ export function firstCompileError(output) {
572
+ return String(output).match(COMPILE_ERROR_LINE)?.[0] ?? null;
573
+ }
574
+
530
575
  function missingCountMessage(output) {
531
- return `the test run failed but reported no failing test count, so it does not prove the new tests fail:\n${output.slice(-FAILURE_TAIL)}`;
576
+ const tail = output.slice(-FAILURE_TAIL);
577
+ const compileError = firstCompileError(output);
578
+ if (compileError) return `the tests do not compile: ${compileError}\n${tail}`;
579
+
580
+ return `the test run failed but reported no failing test count, so it does not prove the new tests fail:\n${tail}`;
532
581
  }
533
582
 
534
583
  function noRiseMessage(baseline, failing, output) {
@@ -564,7 +613,11 @@ function measureTestsRed(run, baseline) {
564
613
  ),
565
614
  };
566
615
 
567
- if (failing === null) return { stop: stuck(missingCountMessage(output)) };
616
+ if (failing === null)
617
+ return {
618
+ stop: stuck(missingCountMessage(output)),
619
+ compileError: firstCompileError(output),
620
+ };
568
621
 
569
622
  if (baseline !== undefined && failing <= baseline)
570
623
  return { noRise: { failing, output } };
@@ -779,28 +832,49 @@ function testsAfterReplan(run) {
779
832
  : null;
780
833
  }
781
834
 
835
+ function retryTypistOnce(run, baseline, instructions, typist) {
836
+ const retried = gatedTestWriter(run, instructions, {
837
+ tier: "small",
838
+ resumeSessionId: typist.sessionId ?? undefined,
839
+ });
840
+ const stop = roleStop("test-writer", retried);
841
+ if (stop) return stop;
842
+
843
+ return proveTestsRed(run, baseline);
844
+ }
845
+
782
846
  function retryUnitTests(run, baseline, failing, typist) {
783
847
  const files = typistChangedFiles(run, typist.before, typist.after);
784
848
  appendEvent(
785
849
  { event: UNIT_TESTS_NO_RISE_EVENT, task: run.id, baseline, failing, files },
786
850
  run.env
787
851
  );
788
- const retried = gatedTestWriter(
852
+
853
+ return retryTypistOnce(
789
854
  run,
855
+ baseline,
790
856
  noRiseRetryInstructions(baseline, failing, files),
791
- { tier: "small", resumeSessionId: typist.sessionId ?? undefined }
857
+ typist
792
858
  );
793
- const stop = roleStop("test-writer", retried);
794
- if (stop) return stop;
859
+ }
795
860
 
796
- return proveTestsRed(run, baseline);
861
+ function retryUncompiledUnitTests(run, baseline, error, typist) {
862
+ appendEvent(
863
+ { event: UNIT_TESTS_NO_COMPILE_EVENT, task: run.id, baseline, error },
864
+ run.env
865
+ );
866
+
867
+ return retryTypistOnce(run, baseline, noCompileRetryInstructions(error), typist);
797
868
  }
798
869
 
799
870
  function proveUnitTestsRed(run, baseline, typist) {
800
871
  const proof = measureTestsRed(run, baseline);
801
- if (!proof.noRise) return proof.stop ?? null;
872
+ if (proof.noRise) return retryUnitTests(run, baseline, proof.noRise.failing, typist);
873
+
874
+ if (proof.compileError)
875
+ return retryUncompiledUnitTests(run, baseline, proof.compileError, typist);
802
876
 
803
- return retryUnitTests(run, baseline, proof.noRise.failing, typist);
877
+ return proof.stop ?? null;
804
878
  }
805
879
 
806
880
  function unitTestsStep(run) {
@@ -1044,7 +1118,43 @@ export function editedTestFiles(run, start, fixesFrom) {
1044
1118
  const changedByTree = changedFilesByTree(run, baselines, end);
1045
1119
  if (changedByTree === null) return { stop: stuck(FINGERPRINT_UNREADABLE) };
1046
1120
 
1047
- return { edits: editedBaselines(baselines, changedByTree) };
1121
+ return { edits: editedBaselines(baselines, changedByTree), end };
1122
+ }
1123
+
1124
+ function testEditDiff(run, edit, end) {
1125
+ const diff = gitOutput(run, ["diff", edit.tree, end, "--", edit.file]) ?? "";
1126
+
1127
+ return `### ${edit.file}\n${diff.slice(0, TEST_EDIT_DIFF_LIMIT)}`;
1128
+ }
1129
+
1130
+ function testEditsQuestion(run, edits, end) {
1131
+ const diffs = edits.map((edit) => testEditDiff(run, edit, end)).join("\n\n");
1132
+
1133
+ return `The code step changed these test files, and the code writer and the debugger never edit a test:
1134
+
1135
+ ${diffs}
1136
+
1137
+ When a change only makes its test correct, contradicting no acceptance criterion and no Decision and weakening no check the spec asks for, put that file in testFix.files, and the change stays. Leave out every file whose change is not right: the build restores it, and the code writer makes the gate pass without it.`;
1138
+ }
1139
+
1140
+ function keepRuledTestEdits(run, edits, end, reply) {
1141
+ const named = requestedTestFix(reply.testFix)?.files ?? [];
1142
+ const kept = edits.filter((edit) => named.includes(edit.file)).map((edit) => edit.file);
1143
+ if (kept.length === 0) return edits;
1144
+ run.testFixTrees.push({ tree: end, files: kept });
1145
+ appendEvent({ event: TEST_EDITS_KEPT_EVENT, task: run.id, files: kept }, run.env);
1146
+
1147
+ return edits.filter((edit) => !kept.includes(edit.file));
1148
+ }
1149
+
1150
+ function poRulesOnTestEdits(run, found) {
1151
+ if (run.testFixes >= TEST_FIX_LIMIT) return { edits: found.edits };
1152
+ run.testFixes += 1;
1153
+ const question = testEditsQuestion(run, found.edits, found.end);
1154
+ const reply = askPo(run, UNPLANNED_FILES_ASKER, question);
1155
+ if (reply.userQuestion) return { stop: waiting(reply.userQuestion) };
1156
+
1157
+ return { edits: keepRuledTestEdits(run, found.edits, found.end, reply) };
1048
1158
  }
1049
1159
 
1050
1160
  function testEditsStep(run, start, fixesFrom) {
@@ -1052,8 +1162,12 @@ function testEditsStep(run, start, fixesFrom) {
1052
1162
  if (found.stop) return found.stop;
1053
1163
 
1054
1164
  if (found.edits.length === 0) return null;
1165
+ const ruled = poRulesOnTestEdits(run, found);
1166
+ if (ruled.stop) return ruled.stop;
1167
+
1168
+ if (ruled.edits.length === 0) return null;
1055
1169
 
1056
- return restoreTestEdits(run, start, fixesFrom, found.edits);
1170
+ return restoreTestEdits(run, start, fixesFrom, ruled.edits);
1057
1171
  }
1058
1172
 
1059
1173
  function restoreTestEdits(run, start, fixesFrom, edits) {
@@ -48,7 +48,7 @@ The task's category decides the roles before and after the code (`roles.mjs` `CA
48
48
  - **test-writer**, acceptance tests (sonnet): run `node $S/step.mjs baseline <id>` first. Instructions: "Write the failing acceptance tests from spec.md only; there is no plan yet, so do not read plan.md. Write tests.md in the task folder mapping each test to the acceptance criteria it covers. Leave the tests uncommitted; the code writer commits them with the code." Then gate it: `node $S/gate.mjs <worktree> <id> test-writer <attempt> sonnet`, attempt 1 to 3. A non-zero exit starts the test writer again with the gate's failed checks, at most 2 more times; a third failure stops the build `stuck` with the failed checks. When no gate entry in `.dark-factory.json` lists `test-writer`, the command runs nothing and passes. Then `node $S/step.mjs prove-red <id>`; a non-zero exit stops the build `stuck` with its message.
49
49
  - **planner** (opus): "Write plan.md for this change. Failing acceptance tests already exist in the worktree (see tests.md in the task folder); the plan must make them pass without changing them." Without a test writer: "Write plan.md for this change."
50
50
  - **Plan gate**, up to 2 rounds: start **reviewer** (sonnet) with "This is the plan gate: there is no code and no diff yet. Review plan.md against spec.md only. Report one finding for each place where the plan narrows an acceptance criterion; adds behaviour, events, options, flags, files or dependencies that no criterion asks for; contradicts the spec, its Decisions or its Must not change; or leaves a decision to the code writer." Settle each finding in the spec's Decisions and have the planner apply them.
51
- - **Unit tests**, when there is a test writer and a plan: `step.mjs baseline`, then **test-writer** (haiku): "Type one unit test per row of each example table in plan.md, in the test files the plan names. Test only what the tables state, change no other file, and leave the tests uncommitted. When plan.md has no example tables, change nothing." Gate it as the acceptance test writer is gated, with `node $S/gate.mjs <worktree> <id> test-writer <attempt> haiku`, also after a no-rise retry. When it changed files, `step.mjs prove-red`. On a no-rise, send it back once with the counts and the files it changed: a test file that fails to load counts as one failure, so it moves its tests into a new test file. A second no-rise stops `stuck`.
51
+ - **Unit tests**, when there is a test writer and a plan: `step.mjs baseline`, then **test-writer** (haiku): "Type one unit test per row of each example table in plan.md, in the test files the plan names. Test only what the tables state, change no other file except for those stubs, and leave everything uncommitted. When a test names a function, type or method that plan.md defines and that does not exist yet, add it where plan.md puts it, with the plan's signature and a body that only fails when it runs (todo!() in Rust, panic in Go, a thrown error elsewhere), so the tests compile and fail; the code writer replaces it. When plan.md has no example tables, change nothing." Gate it as the acceptance test writer is gated, with `node $S/gate.mjs <worktree> <id> test-writer <attempt> haiku`, also after a retry. When it changed files, `step.mjs prove-red`. On a no-rise, send it back once with the counts and the files it changed: a test file that fails to load counts as one failure, so it moves its tests into a new test file. When `prove-red` says the tests do not compile, send it back once with the first error and the stub rule above. A second failure of either kind stops `stuck`.
52
52
 
53
53
  ### 2. The code
54
54
 
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "pal-status",
3
+ "version": "0.1.0",
4
+ "description": "PAL's status above the prompt. Today it holds PAL's standing notice (such as data moves required before 1.0) until it is fixed.",
5
+ "types": "./types/index.d.ts"
6
+ }
@@ -0,0 +1 @@
1
+ { "modules": ["./register.tsx"] }
@@ -0,0 +1,58 @@
1
+ import type { EngineInterface, Register } from "claude-code";
2
+ import { atom, read, update } from "claude-code";
3
+
4
+ import type { Notice } from "../types";
5
+
6
+ const notice = atom({ plugin: "pal-status", key: "notice" } as const, null as Notice);
7
+
8
+ const READ_HEALTH = ["sh", "-c", 'cat "$HOME/.pal/cache/health.json"'] as const;
9
+ const RECHECK_MS = 60_000;
10
+
11
+ function noticeIn(text: string): Notice {
12
+ try {
13
+ const parsed = JSON.parse(text) as { notice?: unknown };
14
+
15
+ return typeof parsed.notice === "string" && parsed.notice !== ""
16
+ ? parsed.notice
17
+ : null;
18
+ } catch {
19
+ return null;
20
+ }
21
+ }
22
+
23
+ async function refresh($: EngineInterface): Promise<void> {
24
+ const run = await $.process.run(READ_HEALTH);
25
+ const current = run.exitCode === 0 ? noticeIn(run.stdout) : null;
26
+ await update($, notice, () => current);
27
+ }
28
+
29
+ export const register: Register = (on) => {
30
+ on("session.start", async ($, e, next) => {
31
+ await refresh($);
32
+ $.clock.every(RECHECK_MS, () => refresh($));
33
+
34
+ return next(e);
35
+ });
36
+
37
+ on("turn.complete", async ($, e, next) => {
38
+ await refresh($);
39
+
40
+ return next(e);
41
+ });
42
+
43
+ on("ui.render", { component: "AbovePrompt" }, async ($, e, next) => {
44
+ const text = await read($, notice);
45
+
46
+ if (e.props.hasSurvey || text === null) {
47
+ return next(e);
48
+ }
49
+
50
+ const { Box, Text } = $.ui.resolve(e);
51
+
52
+ return (
53
+ <Box>
54
+ <Text color="yellow">⚠ {text} — pal cli doctor</Text>
55
+ </Box>
56
+ );
57
+ });
58
+ };
@@ -0,0 +1,7 @@
1
+ export type Notice = string | null;
2
+
3
+ declare module "claude-code" {
4
+ interface PluginState {
5
+ "pal-status": { notice: Notice };
6
+ }
7
+ }