@event4u/agent-config 1.19.0 → 1.21.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 (297) hide show
  1. package/.agent-src/commands/agent-handoff.md +14 -10
  2. package/.agent-src/commands/agents.md +1 -1
  3. package/.agent-src/commands/bug-fix.md +1 -1
  4. package/.agent-src/commands/bug-investigate.md +2 -2
  5. package/.agent-src/commands/chat-history/import.md +166 -0
  6. package/.agent-src/commands/chat-history/learn.md +178 -0
  7. package/.agent-src/commands/chat-history/show.md +17 -18
  8. package/.agent-src/commands/chat-history.md +26 -25
  9. package/.agent-src/commands/compress.md +12 -0
  10. package/.agent-src/commands/context/create.md +2 -2
  11. package/.agent-src/commands/context.md +1 -1
  12. package/.agent-src/commands/copilot-agents.md +1 -1
  13. package/.agent-src/commands/council/default.md +21 -12
  14. package/.agent-src/commands/council.md +1 -1
  15. package/.agent-src/commands/create-pr.md +28 -8
  16. package/.agent-src/commands/e2e-heal.md +1 -1
  17. package/.agent-src/commands/e2e-plan.md +1 -1
  18. package/.agent-src/commands/feature/dev.md +3 -3
  19. package/.agent-src/commands/feature.md +1 -1
  20. package/.agent-src/commands/fix/seeder.md +2 -2
  21. package/.agent-src/commands/fix.md +1 -1
  22. package/.agent-src/commands/jira-ticket.md +1 -1
  23. package/.agent-src/commands/judge.md +2 -2
  24. package/.agent-src/commands/memory.md +1 -1
  25. package/.agent-src/commands/mode.md +5 -5
  26. package/.agent-src/commands/module.md +1 -1
  27. package/.agent-src/commands/onboard.md +4 -4
  28. package/.agent-src/commands/optimize/augmentignore.md +1 -1
  29. package/.agent-src/commands/optimize-prompt.md +61 -0
  30. package/.agent-src/commands/optimize.md +1 -1
  31. package/.agent-src/commands/override.md +1 -1
  32. package/.agent-src/commands/review-changes.md +1 -1
  33. package/.agent-src/commands/review-routing.md +1 -1
  34. package/.agent-src/commands/roadmap.md +1 -1
  35. package/.agent-src/commands/set-cost-profile.md +3 -3
  36. package/.agent-src/commands/sync-agent-settings.md +2 -2
  37. package/.agent-src/commands/sync-gitignore.md +1 -1
  38. package/.agent-src/commands/tests/create.md +2 -2
  39. package/.agent-src/commands/tests.md +1 -1
  40. package/.agent-src/commands/threat-model.md +4 -4
  41. package/.agent-src/contexts/authority/commit-mechanics.md +14 -1
  42. package/.agent-src/contexts/authority/destructive-mechanics.md +14 -1
  43. package/.agent-src/contexts/authority/scope-mechanics.md +5 -0
  44. package/.agent-src/contexts/communication/rules-auto/guidelines-mechanics.md +76 -0
  45. package/.agent-src/contexts/communication/rules-auto/skill-quality-mechanics.md +76 -0
  46. package/.agent-src/contexts/communication/rules-auto/slash-command-routing-policy-mechanics.md +4 -4
  47. package/.agent-src/contexts/communication/rules-auto/think-before-action-mechanics.md +98 -0
  48. package/.agent-src/contexts/communication/rules-auto/token-efficiency-mechanics.md +93 -0
  49. package/.agent-src/contexts/communication/rules-auto/user-interaction-mechanics.md +125 -9
  50. package/.agent-src/contexts/execution/autonomy-mechanics.md +44 -0
  51. package/.agent-src/contexts/model-recommendations.md +2 -2
  52. package/.agent-src/contexts/override-system.md +1 -1
  53. package/.agent-src/personas/product-owner.md +2 -2
  54. package/.agent-src/personas/qa.md +1 -1
  55. package/.agent-src/rules/agent-authority.md +5 -6
  56. package/.agent-src/rules/agent-docs.md +11 -53
  57. package/.agent-src/rules/analysis-skill-routing.md +10 -40
  58. package/.agent-src/rules/architecture.md +6 -1
  59. package/.agent-src/rules/artifact-drafting-protocol.md +5 -0
  60. package/.agent-src/rules/artifact-engagement-recording.md +23 -59
  61. package/.agent-src/rules/ask-when-uncertain.md +24 -47
  62. package/.agent-src/rules/augment-portability.md +14 -62
  63. package/.agent-src/rules/augment-source-of-truth.md +10 -1
  64. package/.agent-src/rules/autonomous-execution.md +17 -98
  65. package/.agent-src/rules/capture-learnings.md +9 -80
  66. package/.agent-src/rules/cli-output-handling.md +12 -42
  67. package/.agent-src/rules/command-suggestion-policy.md +25 -73
  68. package/.agent-src/rules/commit-conventions.md +9 -58
  69. package/.agent-src/rules/commit-policy.md +16 -47
  70. package/.agent-src/rules/context-hygiene.md +5 -0
  71. package/.agent-src/rules/direct-answers.md +21 -42
  72. package/.agent-src/rules/docker-commands.md +11 -45
  73. package/.agent-src/rules/docs-sync.md +10 -56
  74. package/.agent-src/rules/downstream-changes.md +5 -0
  75. package/.agent-src/rules/e2e-testing.md +9 -44
  76. package/.agent-src/rules/guidelines.md +13 -75
  77. package/.agent-src/rules/improve-before-implement.md +10 -2
  78. package/.agent-src/rules/language-and-tone.md +35 -69
  79. package/.agent-src/rules/laravel-translations.md +11 -40
  80. package/.agent-src/rules/markdown-safe-codeblocks.md +4 -0
  81. package/.agent-src/rules/minimal-safe-diff.md +4 -0
  82. package/.agent-src/rules/missing-tool-handling.md +4 -0
  83. package/.agent-src/rules/model-recommendation.md +9 -61
  84. package/.agent-src/rules/no-attribution-footers.md +53 -0
  85. package/.agent-src/rules/no-cheap-questions.md +11 -27
  86. package/.agent-src/rules/no-council-references.md +76 -0
  87. package/.agent-src/rules/no-roadmap-references.md +8 -1
  88. package/.agent-src/rules/non-destructive-by-default.md +13 -43
  89. package/.agent-src/rules/onboarding-gate.md +9 -117
  90. package/.agent-src/rules/package-ci-checks.md +10 -37
  91. package/.agent-src/rules/php-coding.md +10 -55
  92. package/.agent-src/rules/preservation-guard.md +9 -0
  93. package/.agent-src/rules/review-routing-awareness.md +9 -97
  94. package/.agent-src/rules/reviewer-awareness.md +8 -83
  95. package/.agent-src/rules/roadmap-progress-sync.md +7 -170
  96. package/.agent-src/rules/role-mode-adherence.md +6 -2
  97. package/.agent-src/rules/rule-type-governance.md +8 -66
  98. package/.agent-src/rules/runtime-safety.md +5 -0
  99. package/.agent-src/rules/scope-control.md +17 -62
  100. package/.agent-src/rules/security-sensitive-stop.md +7 -1
  101. package/.agent-src/rules/size-enforcement.md +6 -1
  102. package/.agent-src/rules/skill-improvement-trigger.md +9 -49
  103. package/.agent-src/rules/skill-quality.md +7 -64
  104. package/.agent-src/rules/slash-command-routing-policy.md +11 -63
  105. package/.agent-src/rules/think-before-action.md +22 -87
  106. package/.agent-src/rules/token-efficiency.md +10 -74
  107. package/.agent-src/rules/token-optimizer-maintenance.md +68 -0
  108. package/.agent-src/rules/tool-safety.md +4 -0
  109. package/.agent-src/rules/ui-audit-gate.md +25 -61
  110. package/.agent-src/rules/upstream-proposal.md +9 -67
  111. package/.agent-src/rules/user-interaction.md +25 -95
  112. package/.agent-src/rules/verify-before-complete.md +1 -1
  113. package/.agent-src/skills/agent-docs-writing/SKILL.md +1 -1
  114. package/.agent-src/skills/ai-council/SKILL.md +69 -5
  115. package/.agent-src/skills/analysis-autonomous-mode/SKILL.md +1 -1
  116. package/.agent-src/skills/analysis-skill-router/SKILL.md +3 -3
  117. package/.agent-src/skills/artisan-commands/SKILL.md +2 -2
  118. package/.agent-src/skills/authz-review/SKILL.md +1 -1
  119. package/.agent-src/skills/aws-infrastructure/SKILL.md +5 -5
  120. package/.agent-src/skills/blast-radius-analyzer/SKILL.md +8 -8
  121. package/.agent-src/skills/bug-analyzer/SKILL.md +5 -5
  122. package/.agent-src/skills/code-refactoring/SKILL.md +4 -4
  123. package/.agent-src/skills/code-review/SKILL.md +2 -2
  124. package/.agent-src/skills/command-writing/SKILL.md +11 -0
  125. package/.agent-src/skills/composer-packages/SKILL.md +2 -2
  126. package/.agent-src/skills/context-authoring/SKILL.md +11 -0
  127. package/.agent-src/skills/context-document/SKILL.md +1 -1
  128. package/.agent-src/skills/copilot-agents-optimization/SKILL.md +23 -0
  129. package/.agent-src/skills/copilot-config/SKILL.md +1 -1
  130. package/.agent-src/skills/dcf-modeling/SKILL.md +89 -0
  131. package/.agent-src/skills/dependency-upgrade/SKILL.md +2 -2
  132. package/.agent-src/skills/devcontainer/SKILL.md +2 -2
  133. package/.agent-src/skills/developer-like-execution/SKILL.md +1 -1
  134. package/.agent-src/skills/docker/SKILL.md +1 -1
  135. package/.agent-src/skills/dto-creator/SKILL.md +1 -1
  136. package/.agent-src/skills/estimate-ticket/SKILL.md +2 -2
  137. package/.agent-src/skills/fe-design/SKILL.md +4 -4
  138. package/.agent-src/skills/feature-planning/SKILL.md +5 -5
  139. package/.agent-src/skills/funnel-analysis/SKILL.md +100 -0
  140. package/.agent-src/skills/laravel/SKILL.md +1 -1
  141. package/.agent-src/skills/laravel-notifications/SKILL.md +5 -5
  142. package/.agent-src/skills/laravel-pennant/SKILL.md +1 -1
  143. package/.agent-src/skills/laravel-pulse/SKILL.md +4 -4
  144. package/.agent-src/skills/laravel-reverb/SKILL.md +2 -2
  145. package/.agent-src/skills/laravel-scheduling/SKILL.md +1 -1
  146. package/.agent-src/skills/md-language-check/SKILL.md +1 -1
  147. package/.agent-src/skills/migration-creator/SKILL.md +7 -7
  148. package/.agent-src/skills/multi-tenancy/SKILL.md +8 -8
  149. package/.agent-src/skills/okr-tree-modeling/SKILL.md +93 -0
  150. package/.agent-src/skills/performance-analysis/SKILL.md +3 -3
  151. package/.agent-src/skills/pest-testing/SKILL.md +6 -6
  152. package/.agent-src/skills/php-service/SKILL.md +2 -2
  153. package/.agent-src/skills/project-analysis-hypothesis-driven/SKILL.md +3 -3
  154. package/.agent-src/skills/project-analysis-react/SKILL.md +1 -1
  155. package/.agent-src/skills/project-analysis-symfony/SKILL.md +1 -1
  156. package/.agent-src/skills/project-analysis-zend-laminas/SKILL.md +2 -2
  157. package/.agent-src/skills/project-analyzer/SKILL.md +4 -4
  158. package/.agent-src/skills/prompt-optimizer/SKILL.md +108 -0
  159. package/.agent-src/skills/readme-reviewer/SKILL.md +1 -1
  160. package/.agent-src/skills/rice-prioritization/SKILL.md +100 -0
  161. package/.agent-src/skills/rule-writing/SKILL.md +33 -0
  162. package/.agent-src/skills/sentry-integration/SKILL.md +1 -1
  163. package/.agent-src/skills/skill-writing/SKILL.md +14 -0
  164. package/.agent-src/skills/subagent-orchestration/SKILL.md +34 -2
  165. package/.agent-src/skills/terraform/SKILL.md +2 -2
  166. package/.agent-src/skills/terragrunt/SKILL.md +8 -8
  167. package/.agent-src/skills/test-performance/SKILL.md +5 -5
  168. package/.agent-src/skills/threat-modeling/SKILL.md +2 -2
  169. package/.agent-src/skills/token-optimizer/SKILL.md +110 -0
  170. package/.agent-src/skills/unit-economics-modeling/SKILL.md +104 -0
  171. package/.agent-src/skills/universal-project-analysis/SKILL.md +1 -1
  172. package/.agent-src/skills/using-git-worktrees/SKILL.md +1 -0
  173. package/.agent-src/templates/AGENTS.md +1 -1
  174. package/.agent-src/templates/agent-settings.md +25 -41
  175. package/.agent-src/templates/contexts/tenant-boundaries.md +2 -2
  176. package/.agent-src/templates/contexts.md +1 -1
  177. package/.agent-src/templates/copilot-instructions.md +21 -0
  178. package/.agent-src/templates/copilot-review-instructions.md +76 -0
  179. package/.agent-src/templates/features.md +1 -1
  180. package/.agent-src/templates/rule.md +127 -0
  181. package/.agent-src/templates/scripts/work_engine/hook_bootstrap.py +7 -5
  182. package/.agent-src/templates/scripts/work_engine/hooks/__init__.py +0 -4
  183. package/.agent-src/templates/scripts/work_engine/hooks/builtin/__init__.py +0 -4
  184. package/.agent-src/templates/scripts/work_engine/hooks/builtin/_chat_history_base.py +7 -51
  185. package/.agent-src/templates/scripts/work_engine/hooks/builtin/chat_history_append.py +1 -2
  186. package/.agent-src/templates/scripts/work_engine/hooks/builtin/chat_history_halt_append.py +1 -2
  187. package/.agent-src/templates/scripts/work_engine/hooks/builtin/memory_visibility.py +2 -3
  188. package/.agent-src/templates/skill.md +30 -1
  189. package/.claude-plugin/marketplace.json +11 -4
  190. package/AGENTS.md +71 -3
  191. package/CHANGELOG.md +180 -3
  192. package/README.md +24 -23
  193. package/config/agent-settings.template.yml +63 -23
  194. package/config/gitignore-block.txt +11 -4
  195. package/docs/architecture.md +84 -3
  196. package/docs/catalog.md +23 -11
  197. package/docs/contracts/adr-chat-history-split.md +10 -1
  198. package/docs/contracts/agent-memory-contract.md +1 -1
  199. package/docs/contracts/command-clusters.md +1 -1
  200. package/docs/contracts/context-paths.md +2 -1
  201. package/docs/contracts/cross-wing-handoff.md +133 -0
  202. package/docs/contracts/file-ownership-matrix.json +678 -609
  203. package/docs/contracts/hook-architecture-v1.md +8 -1
  204. package/docs/contracts/iron-law-overrides.txt +25 -0
  205. package/docs/contracts/kernel-membership.md +273 -0
  206. package/docs/contracts/load-context-schema.md +26 -11
  207. package/docs/contracts/memory-visibility-v1.md +8 -24
  208. package/docs/contracts/pilot/agent-authority.md +24 -0
  209. package/docs/contracts/pilot/direct-answers.md +70 -0
  210. package/docs/contracts/pilot/language-and-tone.md +63 -0
  211. package/docs/contracts/rule-classification.md +170 -0
  212. package/docs/contracts/rule-router.md +153 -0
  213. package/docs/customization.md +18 -7
  214. package/docs/decisions/ADR-001-kernel-swap-deferred.md +109 -0
  215. package/docs/decisions/ADR-002-kernel-bucket-overrides.md +124 -0
  216. package/docs/decisions/ADR-rule-kernel-and-router.md +122 -0
  217. package/docs/getting-started.md +19 -27
  218. package/docs/guidelines/agent-infra/ask-when-uncertain-demos.md +1 -1
  219. package/docs/guidelines/agent-infra/roadmap-progress-mechanics.md +176 -0
  220. package/docs/guidelines/agent-infra/rule-type-governance.md +73 -0
  221. package/docs/guidelines/agent-infra/size-and-scope.md +13 -2
  222. package/docs/guidelines/agent-infra/skill-quality-checklist.md +119 -0
  223. package/docs/guidelines/augment-portability-patterns.md +68 -0
  224. package/docs/guidelines/php/php-coding-patterns.md +62 -0
  225. package/docs/hook-payload-capture.md +221 -0
  226. package/docs/migrations/commands-1.15.0.md +17 -12
  227. package/docs/skills-catalog.md +5 -4
  228. package/llms.txt +4 -3
  229. package/package.json +1 -1
  230. package/scripts/_p43_bodies.py +235 -0
  231. package/scripts/_p43_compress.py +118 -0
  232. package/scripts/_p4_migrate.py +199 -0
  233. package/scripts/_pilot_council_question.py +57 -0
  234. package/scripts/_pilot_measure.py +53 -0
  235. package/scripts/agent-config +1 -1
  236. package/scripts/ai_council/_default_prices.py +4 -4
  237. package/scripts/ai_council/clients.py +1 -1
  238. package/scripts/ai_council/modes.py +3 -4
  239. package/scripts/ai_council/pricing.py +10 -9
  240. package/scripts/ai_council/session.py +107 -5
  241. package/scripts/build_linear_digest.py +3 -5
  242. package/scripts/build_rule_trigger_matrix.py +1 -9
  243. package/scripts/chat_history.py +952 -596
  244. package/scripts/check_always_budget.py +39 -6
  245. package/scripts/check_compressed_paths.py +213 -0
  246. package/scripts/check_compression.py +15 -0
  247. package/scripts/check_context_paths.py +1 -0
  248. package/scripts/check_council_layout.py +105 -0
  249. package/scripts/check_council_references.py +145 -0
  250. package/scripts/check_portability.py +2 -0
  251. package/scripts/check_references.py +14 -2
  252. package/scripts/check_token_optimizer_freshness.py +131 -0
  253. package/scripts/compile_router.py +148 -0
  254. package/scripts/compress.py +219 -11
  255. package/scripts/council_cli.py +63 -9
  256. package/scripts/council_prune.py +81 -0
  257. package/scripts/count_token_optimizer_usage.sh +54 -0
  258. package/scripts/hook_manifest.yaml +33 -0
  259. package/scripts/hooks/augment-chat-history.sh +10 -0
  260. package/scripts/hooks/cowork-dispatcher.sh +98 -0
  261. package/scripts/hooks/dispatch_hook.py +35 -0
  262. package/scripts/hooks_status.py +12 -1
  263. package/scripts/install-hooks.sh +2 -2
  264. package/scripts/install.sh +81 -2
  265. package/scripts/iron_law_sha.py +98 -0
  266. package/scripts/lint_handoffs.py +214 -0
  267. package/scripts/lint_hook_manifest.py +2 -1
  268. package/scripts/lint_load_context.py +35 -5
  269. package/scripts/measure_rule_budget.py +314 -0
  270. package/scripts/prototype_lint_contradictions.py +150 -0
  271. package/scripts/redact_hook_capture.py +148 -0
  272. package/scripts/schemas/rule.schema.json +55 -6
  273. package/scripts/schemas/skill.schema.json +5 -0
  274. package/scripts/skill_linter.py +359 -7
  275. package/scripts/smoke_path_resolution.py +93 -0
  276. package/scripts/update_prices.py +3 -3
  277. package/scripts/validate_frontmatter.py +41 -1
  278. package/.agent-src/commands/chat-history/checkpoint.md +0 -126
  279. package/.agent-src/commands/chat-history/clear.md +0 -103
  280. package/.agent-src/commands/chat-history/resume.md +0 -183
  281. package/.agent-src/contexts/communication/rules-auto/artifact-engagement-recording-mechanics.md +0 -72
  282. package/.agent-src/contexts/communication/rules-auto/augment-portability-mechanics.md +0 -79
  283. package/.agent-src/contexts/communication/rules-auto/cli-output-handling-mechanics.md +0 -87
  284. package/.agent-src/contexts/communication/rules-auto/command-suggestion-policy-mechanics.md +0 -62
  285. package/.agent-src/contexts/communication/rules-auto/docs-sync-mechanics.md +0 -78
  286. package/.agent-src/contexts/communication/rules-auto/package-ci-checks-mechanics.md +0 -85
  287. package/.agent-src/contexts/communication/rules-auto/review-routing-awareness-mechanics.md +0 -65
  288. package/.agent-src/contexts/communication/rules-auto/roadmap-progress-sync-mechanics.md +0 -78
  289. package/.agent-src/contexts/communication/rules-auto/ui-audit-gate-mechanics.md +0 -53
  290. package/.agent-src/rules/chat-history-cadence.md +0 -143
  291. package/.agent-src/rules/chat-history-ownership.md +0 -124
  292. package/.agent-src/rules/chat-history-visibility.md +0 -97
  293. package/.agent-src/templates/scripts/work_engine/hooks/builtin/chat_history_heartbeat.py +0 -50
  294. package/.agent-src/templates/scripts/work_engine/hooks/builtin/chat_history_turn_check.py +0 -49
  295. package/scripts/check_phase_coupling.py +0 -148
  296. /package/{docs → .agent-src/contexts}/contracts/artifact-engagement-flow.md +0 -0
  297. /package/{docs → .agent-src/contexts}/contracts/command-suggestion-flow.md +0 -0
@@ -1,124 +0,0 @@
1
- ---
2
- type: "auto"
3
- tier: "1"
4
- description: "First turn or reference to .agent-chat-history — detects ownership (match/returning/foreign/missing) and HOOK/ENGINE/CHECKPOINT/MANUAL path classification with numbered-options prompt"
5
- alwaysApply: false
6
- source: package
7
- ---
8
-
9
- <!-- cloud_safe: noop -->
10
-
11
- # Chat History — Ownership
12
-
13
- Owns gate 1 of the chat-history Iron Law: the first-turn handshake
14
- that decides whose `.agent-chat-history` file the current session is
15
- talking to. Cadence (gate 2) lives in [`chat-history-cadence`](chat-history-cadence.md);
16
- visibility (gate 3) lives in [`chat-history-visibility`](chat-history-visibility.md).
17
- File I/O is owned by [`scripts/chat_history.py`](../../../scripts/chat_history.py)
18
- — this rule says **when** to handshake, not how the file is structured.
19
-
20
- ## Two paths — platform decides which Iron Law applies
21
-
22
- Population of `.agent-chat-history` is **structural** (platform-driven)
23
- on platforms with native lifecycle hooks, and **cooperative**
24
- (agent-driven) on platforms without. Both paths converge on the same
25
- JSONL schema; only the trigger differs. Per-platform classification
26
- lives in
27
- [`agents/contexts/chat-history-platform-hooks.md`](../../../agents/contexts/chat-history-platform-hooks.md).
28
-
29
- | Path | Platforms / Surfaces | Trigger | Agent's role |
30
- |---|---|---|---|
31
- | **HOOK** | Claude Code, Augment CLI, Cursor 1.7+, Cline non-Windows, Windsurf, Gemini CLI | Platform fires native lifecycle hooks → `./agent-config chat-history:hook --platform <name>` | Read-only — observe, do not duplicate appends |
32
- | **ENGINE** | `/implement-ticket`, `/work`, any flow driven by `scripts/work_engine/cli.py` | `work_engine` fires `turn-check` (before-dispatch), `append --type phase` (per successful step), `--type decision` (on-halt), `heartbeat` (after-dispatch) via the hook layer | Read-only during engine-driven turns — do not duplicate appends. See [`agents/contexts/work-engine-hooks.md`](../../../agents/contexts/work-engine-hooks.md) |
33
- | **CHECKPOINT** | Augment IDE plugin, Cursor < 1.7, Cline on Windows | Agent invokes `/chat-history-checkpoint` at phase boundaries | Cooperative — gates 1 + 2 + 3 are mandatory |
34
- | **MANUAL** | Cloud surfaces (Claude.ai Web, Skills API) | Rule is inert — see Cloud Behavior | None |
35
-
36
- Detect the path on first turn: read `chat_history.platform` from
37
- `.agent-settings.yml` if set, else fall back to `chat_history.path`
38
- (`hook` / `checkpoint` / `manual`). Missing both → assume CHECKPOINT
39
- (safest cooperative default; HOOK platforms install the platform
40
- config explicitly via `scripts/install.py`).
41
-
42
- ## Iron Law — gate 1 (turn-check is the first tool call)
43
-
44
- ```
45
- ON CHECKPOINT, turn-check IS THE FIRST TOOL CALL OF EVERY SESSION.
46
- ON HOOK, THE PLATFORM FIRES turn-check STRUCTURALLY — DO NOT DUPLICATE.
47
- ON ENGINE, work_engine FIRES turn-check BEFORE DISPATCH — DO NOT DUPLICATE.
48
- ```
49
-
50
- CHECKPOINT path — run silently before any other tool call:
51
-
52
- ```bash
53
- scripts/chat_history.py turn-check --first-user-msg "<first-user-msg>"
54
- ```
55
-
56
- Exit codes: `0` = `ok`/`disabled` (proceed), `10` = `missing`
57
- (run `init --first-user-msg "..." --freq <freq>`), `11` = `foreign`
58
- (render Foreign-Prompt + stop), `12` = `returning` (render
59
- Returning-Prompt + stop). The script writes a one-line
60
- `ACTION REQUIRED:` hint to stderr on non-zero exits.
61
-
62
- ## Activation & handshake
63
-
64
- Read `chat_history.*` from `.agent-settings.yml` **once per conversation**
65
- (first turn) and cache. `enabled: false` or section missing → all three
66
- chat-history rules are a **no-op** (do not read, write, or mention the
67
- file). Otherwise cache `frequency`, `max_size_kb`, `on_overflow`, and
68
- the **path** (HOOK / CHECKPOINT / MANUAL — see the table above).
69
-
70
- **HOOK path** — skip `turn-check` entirely. The platform's
71
- `SessionStart` hook already initialized the file; the agent's job is to
72
- read `status` once for context awareness (header preview, entry count)
73
- and otherwise leave I/O to the hook dispatcher. Foreign / Returning
74
- prompts still apply because hooks call into the same ownership state
75
- machine — when the dispatcher reports `foreign` or `returning` via
76
- exit code or stderr, render the corresponding prompt.
77
-
78
- **CHECKPOINT path** — run `turn-check` as the first tool call. State
79
- token branches to one of: `missing` → `init`, `ok` → continue,
80
- `foreign` → Foreign-Prompt, `returning` → Returning-Prompt.
81
- `/chat-history-checkpoint` is the recommended way to satisfy gate 2
82
- at phase boundaries (see [`chat-history-cadence`](chat-history-cadence.md)).
83
-
84
- In `foreign` and `returning`, **always read the file's current contents
85
- into the agent's working context before any write** — the user chose to
86
- log history for a reason; losing it silently is never acceptable. The
87
- legacy `state` subcommand still works for shell scripts; agents prefer
88
- `turn-check` (folds in `enabled` + distinct exit codes).
89
-
90
- ## Foreign / Returning prompts — full mechanics
91
-
92
- When `turn-check` exits `11` (foreign) or `12` (returning), render the
93
- matching numbered-options block from
94
- [`agents/contexts/chat-history-handshake.md`](../../../agents/contexts/chat-history-handshake.md).
95
- That doc holds the prompt bodies, the option → script-call mapping
96
- (`adopt` / `init` / `prepend` / `reset`), the in-memory entries-list
97
- shape, free-text fallbacks, and the overflow handling per
98
- `on_overflow` (`rotate` / `compress`). Read it once on first foreign
99
- or returning event; cache the chosen option for the rest of the
100
- conversation.
101
-
102
- ## What this rule does NOT do
103
-
104
- Display/reload/clear (`/chat-history*` commands). Auto-flip `enabled` or
105
- `on_overflow`. Run when `enabled: false`. Decide ownership
106
- heuristically — only `turn-check` / `state` does that. Double-write on
107
- HOOK platforms — when hooks fire structurally, the agent does **not**
108
- also call `turn-check`. Cadence (gate 2) and heartbeat (gate 3) are
109
- covered in their sibling rules.
110
-
111
- ## Cloud Behavior
112
-
113
- On cloud surfaces (Claude.ai Web, Skills API) the rule is **fully inert** —
114
- no `.agent-chat-history`, no `scripts/`, no Iron Law gates, no foreign/returning
115
- prompts. Treat `chat_history.enabled` as `false`; persistence is a
116
- local-agent concern.
117
-
118
- ## Interactions & references
119
-
120
- - Sibling rules: [`chat-history-cadence`](chat-history-cadence.md) (gate 2 — append timing) · [`chat-history-visibility`](chat-history-visibility.md) (gate 3 — heartbeat marker).
121
- - `ask-when-uncertain` + `user-interaction` — foreign/returning prompts use numbered options, one question per turn.
122
- - `language-and-tone` — prompt translated at runtime; `.md` stays English.
123
- - `onboarding-gate` — runs first; this rule activates only after it clears.
124
- - API: [`scripts/chat_history.py`](../../../scripts/chat_history.py). Commands: [`/chat-history`](../commands/chat-history.md), [`/chat-history-resume`](../commands/chat-history-resume.md), [`/chat-history-clear`](../commands/chat-history-clear.md), [`/chat-history-checkpoint`](../commands/chat-history-checkpoint.md). Settings: [`agent-settings`](../templates/agent-settings.md). Platform classification: [`agents/contexts/chat-history-platform-hooks.md`](../../../agents/contexts/chat-history-platform-hooks.md). Types: [`rule-type-governance`](rule-type-governance.md).
@@ -1,97 +0,0 @@
1
- ---
2
- type: "auto"
3
- tier: "mechanical-already"
4
- description: "Emitting the chat-history heartbeat marker — paste subprocess stdout verbatim or nothing, never type from memory, hybrid mode prints on drift only, slip handling per language-and-tone"
5
- alwaysApply: false
6
- source: package
7
- ---
8
-
9
- <!-- cloud_safe: noop -->
10
-
11
- # Chat History — Visibility
12
-
13
- Owns gate 3 of the chat-history Iron Law: the heartbeat marker that
14
- makes append-cadence drift visible. Ownership (gate 1) lives in
15
- [`chat-history-ownership`](chat-history-ownership.md); cadence (gate 2)
16
- lives in [`chat-history-cadence`](chat-history-cadence.md). File I/O is
17
- owned by [`scripts/chat_history.py`](../../../scripts/chat_history.py).
18
-
19
- ## Iron Law — gate 3 (heartbeat is subprocess stdout, not memory)
20
-
21
- ```
22
- HEARTBEAT IS THE SCRIPT OUTPUT OF THE CURRENT TURN, VERBATIM, OR NOTHING.
23
- NEVER TYPE THE LINE FROM MEMORY. NEVER REUSE THE PRIOR TURN'S MARKER.
24
- EMPTY STDOUT → NO MARKER LINE.
25
- ```
26
-
27
- Run silently before emitting the final reply:
28
-
29
- ```bash
30
- scripts/chat_history.py heartbeat --first-user-msg "<first-user-msg>"
31
- ```
32
-
33
- Stdout is **at most** one line, e.g.
34
- `📒 chat-history: ok · 9 entries · per_phase · last 30s ago`. Non-empty →
35
- paste **verbatim** as the last line of the reply. Empty → emit nothing.
36
- Always exits 0 — observability, not a gate.
37
-
38
- ## Visibility modes — `chat_history.heartbeat`
39
-
40
- | Mode | When marker prints | Token cost |
41
- |---|---|---|
42
- | `on` | every reply (legacy) | ~20 tokens / reply |
43
- | `off` | never — full silence | 0 |
44
- | `hybrid` *(default)* | drift states only (`missing`/`foreign`/`returning`) | 0 in normal flow, ~20 on drift |
45
-
46
- `hybrid` ships zero tokens when healthy, loud on ownership drift. YAML 1.1
47
- booleanizes bare `on`/`off`; the reader coerces both back, so
48
- `heartbeat: on` works unquoted.
49
-
50
- ## Memory-typing the marker — rule violation, not a slip
51
-
52
- Format is memorizable; counts and timestamps are not. A typed-from-
53
- memory line shows stale entries and a healthy-looking `ok` while the
54
- file is silently behind — observability collapses, invisible until
55
- `status` is checked. Heartbeat is the script output of the **current
56
- turn**, verbatim, or nothing.
57
-
58
- **Self-check before send — MANDATORY.** (1) Did `heartbeat` run on
59
- this turn? (2) Is the line byte-identical to that subprocess stdout?
60
- (3) Empty stdout → no marker line. Any "no" → drop it.
61
-
62
- **Slip handling.** Stale marker called out → acknowledge once in the
63
- user's language; run `status`; on CHECKPOINT call `append` for
64
- missed phase-boundaries (see [`chat-history-cadence`](chat-history-cadence.md));
65
- run a real `heartbeat`; paste stdout verbatim or nothing. Don't promise
66
- "from now on" — only behaviour proves compliance (mirrors
67
- `language-and-tone` § slip handling).
68
-
69
- ## Path-specific behavior
70
-
71
- Heartbeat (gate 3) stays useful for visibility on **every** path —
72
- HOOK, ENGINE, CHECKPOINT — because the marker reports the file's
73
- state, not the agent's intent. On HOOK and ENGINE paths the agent
74
- still emits the marker even though it didn't fire `turn-check` or
75
- `append` itself: the marker is read-only observability over whatever
76
- the platform / engine wrote.
77
-
78
- ## What this rule does NOT do
79
-
80
- Manage ownership decisions — those live in [`chat-history-ownership`](chat-history-ownership.md).
81
- Manage append timing — that lives in [`chat-history-cadence`](chat-history-cadence.md).
82
- Auto-decide visibility mode — `chat_history.heartbeat` is the only
83
- trigger. Insert decoration: the marker is functional output per
84
- [`direct-answers`](direct-answers.md) emoji whitelist, not a status
85
- badge.
86
-
87
- ## Cloud Behavior
88
-
89
- On cloud surfaces (Claude.ai Web, Skills API) heartbeat is **inert** —
90
- no marker line, no `scripts/`. Treat `chat_history.enabled` as `false`.
91
-
92
- ## Interactions & references
93
-
94
- - Sibling rules: [`chat-history-ownership`](chat-history-ownership.md) (gate 1 — turn-check) · [`chat-history-cadence`](chat-history-cadence.md) (gate 2 — append).
95
- - `direct-answers` — emoji whitelist permits the `📒` marker as functional output, not decoration.
96
- - `language-and-tone` § slip handling — stale-marker acknowledgement.
97
- - API: [`scripts/chat_history.py`](../../../scripts/chat_history.py) `heartbeat` and `status` subcommands. Settings: [`agent-settings`](../templates/agent-settings.md) `chat_history.heartbeat`.
@@ -1,50 +0,0 @@
1
- """``ChatHistoryHeartbeatHook`` — visibility marker before save.
2
-
3
- Fires on ``before_save``. Runs ``chat_history.py heartbeat`` and,
4
- if the script emits a marker line, threads it onto ``state.report``
5
- so the agent's reply naturally carries the heartbeat without manual
6
- copy/paste.
7
-
8
- Why ``before_save`` and not ``after_dispatch``: the marker must land
9
- in the report that gets persisted. ``cli._sync_back`` runs between
10
- ``after_dispatch`` and ``before_save`` and reassigns
11
- ``work.report = delivery.report`` — a marker written on
12
- ``after_dispatch`` would be overwritten before ``_save``. Firing on
13
- ``before_save`` runs after the sync, so the marker survives.
14
- """
15
- from __future__ import annotations
16
-
17
- from ..context import HookContext
18
- from ..events import HookEvent
19
- from ..exceptions import HookError
20
- from ..registry import HookRegistry
21
- from ._chat_history_base import EXIT_OK, _ChatHistoryHookBase
22
-
23
-
24
- class ChatHistoryHeartbeatHook(_ChatHistoryHookBase):
25
- """Run heartbeat before save; thread marker into ``state.report``."""
26
-
27
- def register(self, registry: HookRegistry) -> None:
28
- registry.register(HookEvent.BEFORE_SAVE, self._on_before_save)
29
-
30
- def _on_before_save(self, ctx: HookContext) -> None:
31
- msg = self._resolve_msg(ctx)
32
- proc = self._invoke("heartbeat", "--first-user-msg", msg)
33
- if proc.returncode != EXIT_OK:
34
- raise HookError(
35
- f"chat-history heartbeat failed (exit {proc.returncode})"
36
- )
37
- marker = (proc.stdout or "").strip()
38
- if not marker or ctx.work is None:
39
- return
40
- existing = getattr(ctx.work, "report", "") or ""
41
- if marker in existing:
42
- return
43
- sep = "\n\n" if existing else ""
44
- try:
45
- ctx.work.report = f"{existing}{sep}{marker}"
46
- except AttributeError:
47
- raise HookError("chat-history heartbeat: state.report not writable")
48
-
49
-
50
- __all__ = ["ChatHistoryHeartbeatHook"]
@@ -1,49 +0,0 @@
1
- """``ChatHistoryTurnCheckHook`` — guards engine-driven turns.
2
-
3
- Fires on ``before_dispatch``; classifies the chat-history file via
4
- ``scripts/chat_history.py turn-check``:
5
-
6
- - exit 0 (``ok``) → continue
7
- - exit 10 (``missing``) → continue (auto-init handled by chat_history.py)
8
- - exit 11 (``foreign``) → raise :class:`HookHalt` so CLI exits 2
9
- - exit 12 (``returning``)→ raise :class:`HookHalt` so CLI exits 2
10
- - any other exit → raise :class:`HookError` (warn, continue)
11
- """
12
- from __future__ import annotations
13
-
14
- from ..context import HookContext
15
- from ..events import HookEvent
16
- from ..exceptions import HookError, HookHalt
17
- from ..registry import HookRegistry
18
- from ._chat_history_base import (
19
- EXIT_FOREIGN,
20
- EXIT_MISSING,
21
- EXIT_OK,
22
- EXIT_RETURNING,
23
- _ChatHistoryHookBase,
24
- )
25
-
26
-
27
- class ChatHistoryTurnCheckHook(_ChatHistoryHookBase):
28
- """Run ``turn-check`` at the start of dispatch; halt on drift."""
29
-
30
- def register(self, registry: HookRegistry) -> None:
31
- registry.register(HookEvent.BEFORE_DISPATCH, self._on_before_dispatch)
32
-
33
- def _on_before_dispatch(self, ctx: HookContext) -> None:
34
- msg = self._resolve_msg(ctx)
35
- result = self._invoke("turn-check", "--first-user-msg", msg)
36
- code = result.returncode
37
- if code in (EXIT_OK, EXIT_MISSING):
38
- return
39
- if code in (EXIT_FOREIGN, EXIT_RETURNING):
40
- text = (result.stderr or result.stdout or "").strip()
41
- reason = "foreign" if code == EXIT_FOREIGN else "returning"
42
- surface = [line for line in text.splitlines() if line] or [
43
- f"chat-history turn-check: {reason}",
44
- ]
45
- raise HookHalt(f"chat_history_turn_check_{reason}", surface=surface)
46
- raise HookError(f"chat-history turn-check failed (exit {code})")
47
-
48
-
49
- __all__ = ["ChatHistoryTurnCheckHook"]
@@ -1,148 +0,0 @@
1
- #!/usr/bin/env python3
2
- """Phase 6 → Phase 2B coupling guard (Phase 0.3.3).
3
-
4
- Re-runs the audit recorded in `agents/roadmaps/phase6-2b-coupling.md`
5
- on every CI run. Fails the build if any of the 13 Phase-2B target
6
- rules introduces a reference to one of the three Phase-6-owned rules
7
- (`chat-history-cadence`, `chat-history-ownership`,
8
- `chat-history-visibility`) — by rule name, `load_context:` entry, or
9
- body link / cite.
10
-
11
- Excluded from the coupling probe (separate infrastructure, not
12
- reshaped by Phase 6):
13
-
14
- - The CLI dispatcher subcommand `./agent-config chat-history:hook`
15
- and any other `chat-history:*` colon-suffix command surface.
16
-
17
- Exit codes: 0 = decoupling intact, 1 = coupling detected,
18
- 3 = internal error (target rule missing, unreadable file).
19
- """
20
-
21
- from __future__ import annotations
22
-
23
- import argparse
24
- import re
25
- import sys
26
- from pathlib import Path
27
-
28
- REPO_ROOT = Path(__file__).resolve().parents[1]
29
- SRC_RULES = REPO_ROOT / ".agent-src.uncompressed" / "rules"
30
- COMP_RULES = REPO_ROOT / ".agent-src" / "rules"
31
-
32
- # Phase 2B priority list — see road-to-structural-optimization.md § Phase 2 → 2B.
33
- TARGET_RULES: tuple[str, ...] = (
34
- "roadmap-progress-sync",
35
- "user-interaction",
36
- "augment-source-of-truth",
37
- "command-suggestion-policy",
38
- "artifact-engagement-recording",
39
- "review-routing-awareness",
40
- "autonomous-execution",
41
- "docs-sync",
42
- "cli-output-handling",
43
- "augment-portability",
44
- "ui-audit-gate",
45
- "skill-quality",
46
- "package-ci-checks",
47
- )
48
-
49
- # Phase 6 owns these three rule names. Match must be a *rule reference*,
50
- # not a *dispatcher reference* (chat-history:hook etc).
51
- PHASE6_RULES: tuple[str, ...] = (
52
- "chat-history-cadence",
53
- "chat-history-ownership",
54
- "chat-history-visibility",
55
- )
56
-
57
- # Rule-reference pattern: rule name not immediately followed by `:` (which
58
- # would mark it as a CLI subcommand like `chat-history:hook`). Allows
59
- # trailing word-boundary characters typical of Markdown / YAML contexts.
60
- _RULE_REF_RE = re.compile(
61
- r"\bchat-history-(?:cadence|ownership|visibility)\b(?!:)"
62
- )
63
-
64
-
65
- def _scan(file: Path) -> list[tuple[int, str]]:
66
- """Return [(line_no, line)] of rule-reference matches in `file`."""
67
- if not file.is_file():
68
- return []
69
- hits: list[tuple[int, str]] = []
70
- for i, line in enumerate(file.read_text(encoding="utf-8").splitlines(), 1):
71
- if _RULE_REF_RE.search(line):
72
- hits.append((i, line.strip()))
73
- return hits
74
-
75
-
76
- def _check_surface(label: str, base: Path) -> tuple[int, list[str]]:
77
- """Scan `base` for all 13 Phase-2B targets; return (#hits, formatted lines)."""
78
- if not base.is_dir():
79
- return 0, [f"❌ {label} dir missing: {base}"]
80
- out: list[str] = []
81
- total = 0
82
- for rule in TARGET_RULES:
83
- path = base / f"{rule}.md"
84
- if not path.is_file():
85
- return 0, [f"❌ target rule missing: {path}"]
86
- hits = _scan(path)
87
- if not hits:
88
- continue
89
- total += len(hits)
90
- for line_no, line in hits:
91
- out.append(f" {label}/{rule}.md:{line_no} {line}")
92
- return total, out
93
-
94
-
95
- def main() -> int:
96
- parser = argparse.ArgumentParser(description=__doc__)
97
- parser.add_argument(
98
- "--quiet",
99
- action="store_true",
100
- help="suppress the per-rule breakdown when no coupling found",
101
- )
102
- args = parser.parse_args()
103
-
104
- hits_src, lines_src = _check_surface("uncompressed", SRC_RULES)
105
- if any(line.startswith("❌") for line in lines_src):
106
- for line in lines_src:
107
- print(line, file=sys.stderr)
108
- return 3
109
- hits_comp, lines_comp = _check_surface("compressed", COMP_RULES)
110
- if any(line.startswith("❌") for line in lines_comp):
111
- for line in lines_comp:
112
- print(line, file=sys.stderr)
113
- return 3
114
-
115
- total = hits_src + hits_comp
116
-
117
- if total == 0:
118
- if not args.quiet:
119
- print(
120
- f"✅ Phase 6 → 2B decoupling intact: 0 rule-references "
121
- f"across {len(TARGET_RULES)} Phase-2B targets "
122
- f"(uncompressed + compressed surfaces)."
123
- )
124
- print(
125
- " probe: rule names, load_context: entries, body "
126
- "link/cite — dispatcher subcommand chat-history:hook "
127
- "excluded by design."
128
- )
129
- return 0
130
-
131
- print(
132
- f"❌ Phase 6 → 2B coupling detected: {total} rule-reference(s) "
133
- f"across Phase-2B targets:"
134
- )
135
- for line in lines_src + lines_comp:
136
- print(line)
137
- print(
138
- "\n Action: see agents/roadmaps/phase6-2b-coupling.md. "
139
- "Either drop the new reference, migrate it to the dispatcher "
140
- "(chat-history:hook), or trigger the >0-hits branch in 0.3.2 "
141
- "(Phase 6 ships call-signature contract before Phase 2B "
142
- "touches the coupled rule)."
143
- )
144
- return 1
145
-
146
-
147
- if __name__ == "__main__":
148
- sys.exit(main())