@event4u/agent-config 1.14.0 → 1.15.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 (106) hide show
  1. package/.agent-src/commands/agent-handoff.md +1 -1
  2. package/.agent-src/commands/bug-fix.md +2 -2
  3. package/.agent-src/commands/chat-history-checkpoint.md +2 -2
  4. package/.agent-src/commands/chat-history-clear.md +1 -1
  5. package/.agent-src/commands/chat-history-resume.md +2 -2
  6. package/.agent-src/commands/chat-history.md +2 -2
  7. package/.agent-src/commands/check-current-md.md +43 -32
  8. package/.agent-src/commands/commit-in-chunks.md +43 -23
  9. package/.agent-src/commands/compress.md +34 -2
  10. package/.agent-src/commands/feature-roadmap.md +2 -2
  11. package/.agent-src/commands/fix-portability.md +2 -2
  12. package/.agent-src/commands/onboard.md +14 -5
  13. package/.agent-src/commands/optimize-augmentignore.md +9 -0
  14. package/.agent-src/commands/refine-ticket.md +9 -7
  15. package/.agent-src/commands/review-changes.md +35 -8
  16. package/.agent-src/commands/roadmap-create.md +13 -2
  17. package/.agent-src/commands/roadmap-execute.md +9 -7
  18. package/.agent-src/commands/set-cost-profile.md +8 -0
  19. package/.agent-src/commands/sync-agent-settings.md +9 -0
  20. package/.agent-src/commands/tests-execute.md +2 -3
  21. package/.agent-src/rules/artifact-engagement-recording.md +1 -1
  22. package/.agent-src/rules/augment-portability.md +56 -37
  23. package/.agent-src/rules/chat-history-cadence.md +109 -0
  24. package/.agent-src/rules/chat-history-ownership.md +123 -0
  25. package/.agent-src/rules/chat-history-visibility.md +96 -0
  26. package/.agent-src/rules/cli-output-handling.md +1 -1
  27. package/.agent-src/rules/command-suggestion.md +3 -2
  28. package/.agent-src/rules/commit-policy.md +44 -34
  29. package/.agent-src/rules/direct-answers.md +1 -1
  30. package/.agent-src/rules/language-and-tone.md +19 -15
  31. package/.agent-src/rules/non-destructive-by-default.md +18 -18
  32. package/.agent-src/rules/roadmap-progress-sync.md +133 -74
  33. package/.agent-src/rules/role-mode-adherence.md +1 -1
  34. package/.agent-src/rules/size-enforcement.md +2 -1
  35. package/.agent-src/rules/user-interaction.md +28 -4
  36. package/.agent-src/scripts/update_roadmap_progress.py +56 -4
  37. package/.agent-src/skills/blade-ui/SKILL.md +29 -10
  38. package/.agent-src/skills/command-writing/SKILL.md +15 -4
  39. package/.agent-src/skills/existing-ui-audit/SKILL.md +24 -9
  40. package/.agent-src/skills/fe-design/SKILL.md +20 -15
  41. package/.agent-src/skills/file-editor/SKILL.md +9 -0
  42. package/.agent-src/skills/livewire/SKILL.md +26 -7
  43. package/.agent-src/skills/refine-ticket/SKILL.md +30 -24
  44. package/.agent-src/skills/roadmap-management/SKILL.md +22 -16
  45. package/.agent-src/skills/skill-writing/SKILL.md +3 -3
  46. package/.agent-src/skills/upstream-contribute/SKILL.md +2 -2
  47. package/.agent-src/templates/agent-settings.md +1 -1
  48. package/.agent-src/templates/roadmaps.md +9 -8
  49. package/.agent-src/templates/scripts/memory_lookup.py +1 -1
  50. package/.agent-src/templates/scripts/work_engine/__init__.py +2 -2
  51. package/.agent-src/templates/scripts/work_engine/cli.py +64 -461
  52. package/.agent-src/templates/scripts/work_engine/cli_args.py +116 -0
  53. package/.agent-src/templates/scripts/work_engine/delivery_state.py +3 -3
  54. package/.agent-src/templates/scripts/work_engine/directives/backend/__init__.py +1 -1
  55. package/.agent-src/templates/scripts/work_engine/directives/backend/implement.py +1 -1
  56. package/.agent-src/templates/scripts/work_engine/directives/backend/memory.py +1 -1
  57. package/.agent-src/templates/scripts/work_engine/directives/backend/plan.py +1 -1
  58. package/.agent-src/templates/scripts/work_engine/directives/backend/report.py +1 -1
  59. package/.agent-src/templates/scripts/work_engine/dispatcher.py +1 -1
  60. package/.agent-src/templates/scripts/work_engine/emitters.py +43 -0
  61. package/.agent-src/templates/scripts/work_engine/errors.py +19 -0
  62. package/.agent-src/templates/scripts/work_engine/hook_bootstrap.py +76 -0
  63. package/.agent-src/templates/scripts/work_engine/input_builders.py +163 -0
  64. package/.agent-src/templates/scripts/work_engine/migration/v0_to_v1.py +34 -2
  65. package/.agent-src/templates/scripts/work_engine/persona_policy.py +1 -1
  66. package/.agent-src/templates/scripts/work_engine/resolvers/prompt.py +1 -1
  67. package/.agent-src/templates/scripts/work_engine/state_io.py +202 -0
  68. package/.claude-plugin/marketplace.json +1 -1
  69. package/AGENTS.md +6 -4
  70. package/CHANGELOG.md +83 -8
  71. package/README.md +24 -23
  72. package/docs/MIGRATION.md +122 -0
  73. package/docs/architecture.md +83 -34
  74. package/docs/contracts/STABILITY.md +95 -0
  75. package/docs/contracts/adr-chat-history-split.md +132 -0
  76. package/docs/contracts/adr-command-suggestion.md +146 -0
  77. package/docs/contracts/adr-implement-ticket-runtime.md +122 -0
  78. package/docs/contracts/adr-product-ui-track.md +384 -0
  79. package/docs/contracts/adr-prompt-driven-execution.md +187 -0
  80. package/docs/contracts/agent-memory-contract.md +149 -0
  81. package/docs/contracts/artifact-engagement-flow.md +262 -0
  82. package/docs/contracts/command-clusters.md +126 -0
  83. package/docs/contracts/command-suggestion-flow.md +148 -0
  84. package/docs/contracts/implement-ticket-flow.md +628 -0
  85. package/docs/contracts/linear-ai-rules-inclusion.md +143 -0
  86. package/docs/contracts/linear-ai-three-layers.md +131 -0
  87. package/docs/contracts/rule-interactions.md +107 -0
  88. package/docs/contracts/rule-interactions.yml +142 -0
  89. package/docs/contracts/ui-stack-extension.md +236 -0
  90. package/docs/contracts/ui-track-flow.md +338 -0
  91. package/docs/getting-started.md +2 -2
  92. package/docs/installation.md +42 -6
  93. package/docs/migrations/commands-1.15.0.md +112 -0
  94. package/docs/ui-track-mental-model.md +121 -0
  95. package/package.json +1 -1
  96. package/scripts/build_linear_digest.py +4 -4
  97. package/scripts/check_portability.py +2 -0
  98. package/scripts/check_public_links.py +185 -0
  99. package/scripts/check_references.py +1 -0
  100. package/scripts/lint_no_new_atomic_commands.py +179 -0
  101. package/scripts/lint_rule_interactions.py +149 -0
  102. package/scripts/memory_lookup.py +1 -1
  103. package/scripts/release.py +297 -64
  104. package/scripts/skill_linter.py +14 -0
  105. package/scripts/update_counts.py +10 -0
  106. package/.agent-src/rules/chat-history.md +0 -200
@@ -114,9 +114,20 @@ If yes → switch to the `roadmap-execute` command workflow with the newly creat
114
114
 
115
115
  - **Do NOT auto-generate content** — always ask the user for input.
116
116
  - **Do NOT commit or push.**
117
- - **Do NOT include commit steps** unless user explicitly requested them.
118
- See [`commit-policy`](../rules/commit-policy.md#never-write-commit-steps-into-roadmaps-unsolicited).
117
+ - **Do NOT include commit steps in the roadmap** unless the user explicitly
118
+ requested them. See [`commit-policy`](../rules/commit-policy.md#never-write-commit-steps-into-roadmaps-unsolicited).
119
119
  Roadmaps plan **work**; commits are a separate delivery decision.
120
+ - **Every phase MUST contain at least one `- [ ]` checkbox.** A roadmap
121
+ without checkboxes is invisible to `agents/roadmaps-progress.md` and
122
+ violates [`roadmap-progress-sync`](../rules/roadmap-progress-sync.md)
123
+ Iron Law #2.
124
+ - **Status is binary: `ready` (default) or `draft`.** Create new
125
+ roadmaps as **ready** — no `status:` field needed, ready is
126
+ implicit. Only mark `status: draft` (in YAML frontmatter) when the
127
+ user explicitly says it should be hidden from the dashboard (still
128
+ being authored, awaiting upstream decisions, capture-only synthesis
129
+ without executable phases). If the user wants draft, ask once at
130
+ step 3 — do not infer it.
120
131
  - **Write the roadmap in English** (per project convention for `.md` files).
121
132
  - Follow the roadmap template from `.augment/templates/roadmaps.md`.
122
133
  - Keep the file focused: 500–1000 lines max. If larger, suggest splitting.
@@ -65,13 +65,15 @@ For each open step:
65
65
 
66
66
  ### Rules
67
67
 
68
- - **Commits per [`commit-policy`](../rules/commit-policy.md).** Default: only
69
- apply local changes and update the roadmap file — no commits.
70
- - Roadmap **without** commit steps → never commit, never ask.
71
- - Roadmap **with** commit steps:
72
- - **Non-autonomous** (`autonomy: off`, or `auto` before opt-in) → ask before each.
73
- - **Autonomous** (`autonomy: on`, or `auto` after opt-in) → pre-scan **before
74
- starting**, ask **once** upfront, then proceed silently per the answer.
68
+ - **Commits are governed by [`commit-policy`](../rules/commit-policy.md).**
69
+ By default: only apply local changes and update the roadmap file — no commits.
70
+ - If the roadmap **does not** contain explicit commit steps → never commit, never ask.
71
+ - If the roadmap **does** contain explicit commit steps:
72
+ - **Non-autonomous** (`personal.autonomy: off`, or `auto` before opt-in) →
73
+ ask before each commit step.
74
+ - **Autonomous** (`personal.autonomy: on`, or `auto` after opt-in)
75
+ pre-scan the roadmap **before starting**, ask **once** upfront whether
76
+ to execute the listed commit steps, then proceed silently per the answer.
75
77
  - **Push, merge, branch, PR, tag** stay permission-gated by [`scope-control`](../rules/scope-control.md#git-operations--permission-gated).
76
78
  - **Always ask before implementing** a step — never auto-execute.
77
79
  - **Run quality checks** after each code change.
@@ -8,6 +8,8 @@ suggestion:
8
8
  rationale: "Settings mutation — must be deliberate."
9
9
  ---
10
10
 
11
+ <!-- cloud_safe: noop -->
12
+
11
13
  # /set-cost-profile
12
14
 
13
15
  Changes `cost_profile` in `.agent-settings.yml`. Four profiles are defined in
@@ -96,6 +98,12 @@ steps here, that's the docs' job.
96
98
  - `custom` ignores the profile matrix — every per-feature toggle must be
97
99
  set explicitly afterwards. Warn the user when switching to `custom`.
98
100
 
101
+ ## Cloud Behavior
102
+
103
+ On cloud surfaces (Claude.ai Web, Skills API) this command is **fully inert** —
104
+ there is no `.agent-settings.yml` to write and no `cost_profile` toggle to
105
+ flip. Cost behaviour on those surfaces is governed by the platform itself.
106
+
99
107
  ## See also
100
108
 
101
109
  - [`agent-settings`](../templates/agent-settings.md) — profile matrix and settings reference
@@ -7,6 +7,8 @@ suggestion:
7
7
  rationale: "Settings sync — must be deliberate."
8
8
  ---
9
9
 
10
+ <!-- cloud_safe: noop -->
11
+
10
12
  # /sync-agent-settings
11
13
 
12
14
  Reconciles `.agent-settings.yml` with the shipped template
@@ -115,6 +117,13 @@ check-only workflows; report the drift and let the pipeline decide.
115
117
  presets require a package update in the consumer project before
116
118
  this command can apply them.
117
119
 
120
+ ## Cloud Behavior
121
+
122
+ On cloud surfaces (Claude.ai Web, Skills API) this command is **fully inert** —
123
+ there is no `.agent-settings.yml` on disk, no `scripts/sync_agent_settings.py`
124
+ to call, and no template/profile preset reachable. Settings reconciliation
125
+ is a local-agent concern.
126
+
118
127
  ## See also
119
128
 
120
129
  - [`scripts/sync_agent_settings.py`](../../../scripts/sync_agent_settings.py) — the helper
@@ -22,9 +22,8 @@ Check in this order — use the **first match**:
22
22
  3. **`vendor/bin/pest` exists** → Pest → `vendor/bin/pest`
23
23
  4. **Fallback** → PHPUnit → `vendor/bin/phpunit`
24
24
 
25
- **Prefer Makefile targets** over raw commands — they handle container access,
26
- environment variables, and parallel settings automatically. If the project
27
- uses a different task runner, inspect its config before falling back to raw.
25
+ **Prefer Makefile targets** over raw commands when they exist — they handle container access,
26
+ environment variables, and parallel settings automatically.
28
27
 
29
28
  ### 2. Run the tests
30
29
 
@@ -127,7 +127,7 @@ log — that is a real bug, not a swallowed error.
127
127
  ## See also
128
128
 
129
129
  - [`road-to-artifact-engagement-telemetry`](../../../agents/roadmaps/road-to-artifact-engagement-telemetry.md) — phase contract
130
- - [`agents/contexts/artifact-engagement-flow.md`](../../../agents/contexts/artifact-engagement-flow.md) — recording contract details
130
+ - [`docs/contracts/artifact-engagement-flow.md`](../../docs/contracts/artifact-engagement-flow.md) — recording contract details
131
131
  - [`/implement-ticket`](../commands/implement-ticket.md) and [`/work`](../commands/work.md) — boundary points where this rule fires
132
132
  - [`scripts/telemetry/`](../../../scripts/telemetry/) — engine source
133
133
  - [`agent-settings`](../templates/agent-settings.md) — `telemetry.artifact_engagement.*` reference
@@ -6,38 +6,47 @@ source: package
6
6
 
7
7
  # Package Portability
8
8
 
9
- Everything shipped with `event4u/agent-config` MUST be **project-agnostic**:
9
+ Everything that ships with the `event4u/agent-config` package MUST be
10
+ **project-agnostic**. That includes:
10
11
 
11
- - `.augment/` (skills, rules, commands, guidelines, templates, contexts)
12
- - Package root `AGENTS.md`
13
- - Package `.github/copilot-instructions.md`
12
+ - Everything inside `.augment/` (skills, rules, commands, guidelines,
13
+ templates, contexts)
14
+ - The package repo's own root `AGENTS.md`
15
+ - The package repo's own `.github/copilot-instructions.md`
14
16
 
15
17
  All three are either installed into consumer projects (`.augment/` via
16
- `install.sh`) or read by AI tools working on the package itself. Leaking
17
- consumer-specific content pollutes downstream or misleads agents.
18
+ `install.sh`) or read by AI tools when working on the package itself
19
+ (`AGENTS.md`, `copilot-instructions.md`). Leaking consumer-specific
20
+ content into any of them pollutes downstream projects or misleads agents.
18
21
 
19
22
  ## Rules
20
23
 
21
- - NEVER reference a specific consumer project, repo, domain, or tech
22
- stack. The package repo itself (`event4u/agent-config`) MAY appear
23
- in its own root `AGENTS.md` / `copilot-instructions.md` — meta about
24
- the package, not a leak.
24
+ - NEVER reference a specific consumer project, repo name, domain, or tech
25
+ stack directly. The package repo itself (`event4u/agent-config`) MAY be
26
+ named inside its own root `AGENTS.md` and `copilot-instructions.md` —
27
+ that is meta about the package, not a leak.
25
28
  - NEVER hardcode consumer-project paths, class names, or conventions.
26
- - Write content so it works as a reusable package across any project.
27
- - Project-specific behavior belongs in the **consumer's**
28
- `.agent-settings.yml`, `AGENTS.md`, or `agents/` — never here.
29
- - If a skill/rule needs project-specific input: read from
30
- `.agent-settings.yml` or accept as parameter.
31
- - Always ask when editing package files: "Would this still make sense
32
- in a completely different project?"
29
+ - Write content so it works as a **reusable package** across any project.
30
+ - Project-specific behavior belongs in the **consumer's** `.agent-settings.yml`,
31
+ `AGENTS.md`, or `agents/` — never in files shipped by this package.
32
+ - If a skill or rule needs project-specific input, read it from
33
+ `.agent-settings.yml` or accept it as a parameter.
34
+ - When reviewing or editing package files, always ask: "Would this still
35
+ make sense in a completely different project?"
33
36
 
34
37
  ## Runtime invocations — no `task` commands
35
38
 
36
- Skills, rules, commands, guidelines, personas, contexts shipped by this
37
- package run in **consumer projects** that may not have Task installed.
38
- NEVER reference a `task <name>` invocation inside any artefact file
39
- under `.agent-src.uncompressed/{skills,rules,commands,guidelines,personas,contexts}/`
40
- (or the compressed mirror under `.agent-src/`). Use the direct script:
39
+ Skills, rules, commands, guidelines, personas, and context docs
40
+ shipped by this package run in **consumer projects**. Consumer
41
+ projects may not have [Task](https://taskfile.dev) installed
42
+ they might use npm scripts, Composer scripts, Make, or nothing at
43
+ all. A skill that instructs an agent to run `task <something>`
44
+ silently breaks in every project without a `Taskfile.yml`.
45
+
46
+ **Rule:** Never reference a `task <something>` invocation inside any
47
+ artefact file under `.agent-src.uncompressed/{skills,rules,commands,guidelines,personas,contexts}/`
48
+ (and therefore also not in the compressed mirror under `.agent-src/`).
49
+ Use the direct script invocation instead:
41
50
 
42
51
  | ❌ Forbidden | ✅ Portable |
43
52
  |---|---|
@@ -54,19 +63,29 @@ under `.agent-src.uncompressed/{skills,rules,commands,guidelines,personas,contex
54
63
  | `task validate-schema` | `python3 scripts/validate_frontmatter.py` |
55
64
  | `task counts-check` | `python3 scripts/update_counts.py --check` |
56
65
  | `task roadmap-progress` | `./agent-config roadmap:progress` |
57
- | `task ci` | run each underlying script directly |
66
+ | `task ci` | run each underlying script directly (no single portable equivalent) |
67
+
68
+ Task remains a convenience shortcut for maintainers working on the
69
+ package repo itself — `task ci` is the recommended local gate before
70
+ a PR and lives in `Taskfile.yml`, `AGENTS.md`, and the package README.
71
+ Those maintainer-facing surfaces are outside the scope of this rule.
72
+ Artefact files must assume Task is absent.
58
73
 
59
- Task stays a convenience for package maintainers (`Taskfile.yml`,
60
- `AGENTS.md`, README). Artefact files must assume Task is absent.
74
+ The detection pattern *"if the consumer has a `Makefile` / build
75
+ script, prefer its targets over raw commands"* is still allowed when
76
+ the skill adapts to the **consumer's own** tooling (e.g.
77
+ `tests-execute` detecting `php artisan test` vs `vendor/bin/pest`).
78
+ It is not allowed to reference `task <name>` as the detected target —
79
+ every direct invocation must resolve to a real script path.
61
80
 
62
81
  ## Consumer CLI — `./agent-config`
63
82
 
64
- A subset of scripts is exposed through a project-local CLI wrapper
65
- `./agent-config` (written into the project root by the installer,
66
- gitignored). Artefacts MUST prefer the CLI over raw `python3 scripts/…`
67
- paths for every command it covers raw paths only resolve inside the
68
- package repo, in consumer projects the scripts live under
69
- `node_modules/` or `vendor/`.
83
+ A subset of package scripts is exposed through a project-local CLI
84
+ wrapper `./agent-config` (written into the project root by the
85
+ installer, gitignored). Artefacts MUST prefer the CLI over raw
86
+ `python3 scripts/…` paths for every command the CLI already covers,
87
+ because the raw paths only resolve inside the package repo — in a
88
+ consumer project the scripts live under `node_modules/` or `vendor/`.
70
89
 
71
90
  | ❌ Forbidden in artefacts | ✅ Portable |
72
91
  |---|---|
@@ -85,13 +104,13 @@ package repo, in consumer projects the scripts live under
85
104
  | `python3 scripts/refine_ticket_detect.py` | `./agent-config refine-ticket:detect` |
86
105
 
87
106
  Commands not covered by the CLI stay as direct script invocations
88
- (e.g. `bash scripts/compress.sh --sync`) — maintainer-only, not
89
- reachable from a consumer project anyway.
107
+ (e.g. `bash scripts/compress.sh --sync`) — those are maintainer-only
108
+ and not reachable from a consumer project anyway.
90
109
 
91
110
  ## Enforcement
92
111
 
93
112
  `scripts/check_portability.py` scans `.augment/`, `.agent-src.uncompressed/`,
94
- and the package root `AGENTS.md` + `.github/copilot-instructions.md` for
95
- forbidden identifiers, for any `task <name>` invocation, and for direct
96
- script invocations that bypass the `./agent-config` CLI. Runs in CI —
97
- must pass before any PR.
113
+ and the package repo's root `AGENTS.md` + `.github/copilot-instructions.md`
114
+ for forbidden identifiers, for any `task <name>` invocation inside
115
+ artefact files, and for direct script invocations that bypass the
116
+ `./agent-config` CLI. It runs in CI and must pass before any PR.
@@ -0,0 +1,109 @@
1
+ ---
2
+ type: "always"
3
+ description: "Append cadence for .agent-chat-history — when to call append (per_turn/per_phase/per_tool), turn-check ownership refusal handling, never write the file directly, cadence is the trigger not reply length"
4
+ alwaysApply: true
5
+ source: package
6
+ ---
7
+
8
+ <!-- cloud_safe: noop -->
9
+
10
+ # Chat History — Cadence
11
+
12
+ Owns gate 2 of the chat-history Iron Law: WHEN to call `append`.
13
+ Ownership (gate 1) lives in [`chat-history-ownership`](chat-history-ownership.md);
14
+ visibility (gate 3) lives in [`chat-history-visibility`](chat-history-visibility.md).
15
+ File I/O is owned by [`scripts/chat_history.py`](../../../scripts/chat_history.py)
16
+ — this rule decides the trigger boundaries, not the file format.
17
+
18
+ ## Iron Law — gate 2 (append at every cadence boundary)
19
+
20
+ ```
21
+ EVERY CADENCE BOUNDARY GETS ONE append CALL — WITH --first-user-msg.
22
+ SKIPPING IS A RULE VIOLATION. NEVER WRITE .agent-chat-history DIRECTLY.
23
+ ON HOOK / ENGINE PATHS, THE PLATFORM / ENGINE PERFORMS append STRUCTURALLY
24
+ — THE AGENT MUST NOT DUPLICATE.
25
+ ```
26
+
27
+ Cadence is **gated by ownership**: gate 1 (turn-check from
28
+ [`chat-history-ownership`](chat-history-ownership.md)) must have cleared
29
+ this turn before any append fires. Skip turn-check → append refuses with
30
+ exit `3` (`OWNERSHIP_REFUSED`).
31
+
32
+ ## Append cadence — boundaries
33
+
34
+ Cadence comes from `chat_history.frequency` in `.agent-settings.yml`:
35
+
36
+ - `per_turn` → one entry at the end of every agent turn.
37
+ - `per_phase` → at phase boundaries (user question answered, decision
38
+ taken, task-list item completed, significant tool sequence finished).
39
+ Pure clarification turns may skip.
40
+ - `per_tool` → after each tool-call sequence.
41
+
42
+ Every append goes through
43
+
44
+ ```bash
45
+ scripts/chat_history.py append --first-user-msg "<msg>" \
46
+ --type <user|agent|tool|decision|phase> --json '<obj>'
47
+ ```
48
+
49
+ Never write the file directly. Prefer `phase` over `agent` for boundaries.
50
+ **Cadence is the trigger, not reply length** — a one-line reply that
51
+ crosses a boundary still appends; a 200-line reply that doesn't cross
52
+ one still doesn't. **Do not batch missed turns** — crashes happen
53
+ between turns, and a batched append loses the timeline that crash
54
+ recovery depends on.
55
+
56
+ ## Ownership refusal — exit `3`
57
+
58
+ `append` exits `3` when the file's ownership header doesn't match the
59
+ current session (`turn-check` was skipped or the file was hijacked
60
+ between turns). Surface the failure to the user, **do not swallow it**:
61
+
62
+ 1. Stop the current append.
63
+ 2. Render the Foreign-Prompt from [`chat-history-ownership`](chat-history-ownership.md)
64
+ so the user re-handshakes.
65
+ 3. Resume cadence only after gate 1 clears again.
66
+
67
+ This is the structural enforcement layer that catches the case where
68
+ an agent technically called `turn-check` but on the wrong platform path
69
+ (e.g. HOOK platform also tried CHECKPOINT cooperative gates and the
70
+ file got into a mixed state).
71
+
72
+ ## Path-specific behavior
73
+
74
+ **CHECKPOINT path** — gates 1 + 2 are cooperative. The agent runs
75
+ `turn-check` first, then runs `append` at every cadence boundary.
76
+ `/chat-history-checkpoint` is the recommended boundary-trigger; it
77
+ captures phase entries with the right metadata.
78
+
79
+ **HOOK path** — `work_engine` and platform `SessionStart` /
80
+ `PreToolUse` hooks fire `turn-check` and `append` structurally. The
81
+ agent must **not** call either — double-write produces interleaved
82
+ entries and breaks the JSONL schema. Hooks emit the same exit codes,
83
+ so refusal handling stays identical.
84
+
85
+ **ENGINE path** — `work_engine` fires `append --type phase` per
86
+ successful step and `append --type decision` on halt. Free-form prose
87
+ around the engine output falls back to whatever path the platform
88
+ supplies (HOOK or CHECKPOINT). Engine-driven turns inherit the
89
+ structural guarantee for the duration of the dispatch cycle only.
90
+
91
+ ## What this rule does NOT do
92
+
93
+ Manage ownership decisions (handshake, foreign/returning) — those
94
+ live in [`chat-history-ownership`](chat-history-ownership.md).
95
+ Manage the heartbeat marker — that lives in [`chat-history-visibility`](chat-history-visibility.md).
96
+ Decide cadence dynamically based on reply content — cadence is
97
+ the configured frequency, period.
98
+
99
+ ## Cloud Behavior
100
+
101
+ On cloud surfaces (Claude.ai Web, Skills API) cadence is **inert** —
102
+ no append calls, no `scripts/`, no JSONL file. Treat
103
+ `chat_history.enabled` as `false`.
104
+
105
+ ## Interactions & references
106
+
107
+ - Sibling rules: [`chat-history-ownership`](chat-history-ownership.md) (gate 1 — turn-check) · [`chat-history-visibility`](chat-history-visibility.md) (gate 3 — heartbeat marker).
108
+ - `token-efficiency` — never load the full log; cadence keeps appends small and bounded.
109
+ - API: [`scripts/chat_history.py`](../../../scripts/chat_history.py) `append` subcommand. Settings: [`agent-settings`](../templates/agent-settings.md) `chat_history.frequency`. Engine hooks: [`agents/contexts/work-engine-hooks.md`](../../../agents/contexts/work-engine-hooks.md).
@@ -0,0 +1,123 @@
1
+ ---
2
+ type: "always"
3
+ description: "Detect file ownership of .agent-chat-history on first turn — match/returning/foreign/missing handshake, two-paths classification (HOOK/ENGINE/CHECKPOINT/MANUAL), Foreign/Returning numbered-options prompt"
4
+ alwaysApply: true
5
+ source: package
6
+ ---
7
+
8
+ <!-- cloud_safe: noop -->
9
+
10
+ # Chat History — Ownership
11
+
12
+ Owns gate 1 of the chat-history Iron Law: the first-turn handshake
13
+ that decides whose `.agent-chat-history` file the current session is
14
+ talking to. Cadence (gate 2) lives in [`chat-history-cadence`](chat-history-cadence.md);
15
+ visibility (gate 3) lives in [`chat-history-visibility`](chat-history-visibility.md).
16
+ File I/O is owned by [`scripts/chat_history.py`](../../../scripts/chat_history.py)
17
+ — this rule says **when** to handshake, not how the file is structured.
18
+
19
+ ## Two paths — platform decides which Iron Law applies
20
+
21
+ Population of `.agent-chat-history` is **structural** (platform-driven)
22
+ on platforms with native lifecycle hooks, and **cooperative**
23
+ (agent-driven) on platforms without. Both paths converge on the same
24
+ JSONL schema; only the trigger differs. Per-platform classification
25
+ lives in
26
+ [`agents/contexts/chat-history-platform-hooks.md`](../../../agents/contexts/chat-history-platform-hooks.md).
27
+
28
+ | Path | Platforms / Surfaces | Trigger | Agent's role |
29
+ |---|---|---|---|
30
+ | **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 |
31
+ | **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) |
32
+ | **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 |
33
+ | **MANUAL** | Cloud surfaces (Claude.ai Web, Skills API) | Rule is inert — see Cloud Behavior | None |
34
+
35
+ Detect the path on first turn: read `chat_history.platform` from
36
+ `.agent-settings.yml` if set, else fall back to `chat_history.path`
37
+ (`hook` / `checkpoint` / `manual`). Missing both → assume CHECKPOINT
38
+ (safest cooperative default; HOOK platforms install the platform
39
+ config explicitly via `scripts/install.py`).
40
+
41
+ ## Iron Law — gate 1 (turn-check is the first tool call)
42
+
43
+ ```
44
+ ON CHECKPOINT, turn-check IS THE FIRST TOOL CALL OF EVERY SESSION.
45
+ ON HOOK, THE PLATFORM FIRES turn-check STRUCTURALLY — DO NOT DUPLICATE.
46
+ ON ENGINE, work_engine FIRES turn-check BEFORE DISPATCH — DO NOT DUPLICATE.
47
+ ```
48
+
49
+ CHECKPOINT path — run silently before any other tool call:
50
+
51
+ ```bash
52
+ scripts/chat_history.py turn-check --first-user-msg "<first-user-msg>"
53
+ ```
54
+
55
+ Exit codes: `0` = `ok`/`disabled` (proceed), `10` = `missing`
56
+ (run `init --first-user-msg "..." --freq <freq>`), `11` = `foreign`
57
+ (render Foreign-Prompt + stop), `12` = `returning` (render
58
+ Returning-Prompt + stop). The script writes a one-line
59
+ `ACTION REQUIRED:` hint to stderr on non-zero exits.
60
+
61
+ ## Activation & handshake
62
+
63
+ Read `chat_history.*` from `.agent-settings.yml` **once per conversation**
64
+ (first turn) and cache. `enabled: false` or section missing → all three
65
+ chat-history rules are a **no-op** (do not read, write, or mention the
66
+ file). Otherwise cache `frequency`, `max_size_kb`, `on_overflow`, and
67
+ the **path** (HOOK / CHECKPOINT / MANUAL — see the table above).
68
+
69
+ **HOOK path** — skip `turn-check` entirely. The platform's
70
+ `SessionStart` hook already initialized the file; the agent's job is to
71
+ read `status` once for context awareness (header preview, entry count)
72
+ and otherwise leave I/O to the hook dispatcher. Foreign / Returning
73
+ prompts still apply because hooks call into the same ownership state
74
+ machine — when the dispatcher reports `foreign` or `returning` via
75
+ exit code or stderr, render the corresponding prompt.
76
+
77
+ **CHECKPOINT path** — run `turn-check` as the first tool call. State
78
+ token branches to one of: `missing` → `init`, `ok` → continue,
79
+ `foreign` → Foreign-Prompt, `returning` → Returning-Prompt.
80
+ `/chat-history-checkpoint` is the recommended way to satisfy gate 2
81
+ at phase boundaries (see [`chat-history-cadence`](chat-history-cadence.md)).
82
+
83
+ In `foreign` and `returning`, **always read the file's current contents
84
+ into the agent's working context before any write** — the user chose to
85
+ log history for a reason; losing it silently is never acceptable. The
86
+ legacy `state` subcommand still works for shell scripts; agents prefer
87
+ `turn-check` (folds in `enabled` + distinct exit codes).
88
+
89
+ ## Foreign / Returning prompts — full mechanics
90
+
91
+ When `turn-check` exits `11` (foreign) or `12` (returning), render the
92
+ matching numbered-options block from
93
+ [`agents/contexts/chat-history-handshake.md`](../../../agents/contexts/chat-history-handshake.md).
94
+ That doc holds the prompt bodies, the option → script-call mapping
95
+ (`adopt` / `init` / `prepend` / `reset`), the in-memory entries-list
96
+ shape, free-text fallbacks, and the overflow handling per
97
+ `on_overflow` (`rotate` / `compress`). Read it once on first foreign
98
+ or returning event; cache the chosen option for the rest of the
99
+ conversation.
100
+
101
+ ## What this rule does NOT do
102
+
103
+ Display/reload/clear (`/chat-history*` commands). Auto-flip `enabled` or
104
+ `on_overflow`. Run when `enabled: false`. Decide ownership
105
+ heuristically — only `turn-check` / `state` does that. Double-write on
106
+ HOOK platforms — when hooks fire structurally, the agent does **not**
107
+ also call `turn-check`. Cadence (gate 2) and heartbeat (gate 3) are
108
+ covered in their sibling rules.
109
+
110
+ ## Cloud Behavior
111
+
112
+ On cloud surfaces (Claude.ai Web, Skills API) the rule is **fully inert** —
113
+ no `.agent-chat-history`, no `scripts/`, no Iron Law gates, no foreign/returning
114
+ prompts. Treat `chat_history.enabled` as `false`; persistence is a
115
+ local-agent concern.
116
+
117
+ ## Interactions & references
118
+
119
+ - Sibling rules: [`chat-history-cadence`](chat-history-cadence.md) (gate 2 — append timing) · [`chat-history-visibility`](chat-history-visibility.md) (gate 3 — heartbeat marker).
120
+ - `ask-when-uncertain` + `user-interaction` — foreign/returning prompts use numbered options, one question per turn.
121
+ - `language-and-tone` — prompt translated at runtime; `.md` stays English.
122
+ - `onboarding-gate` — runs first; this rule activates only after it clears.
123
+ - 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).
@@ -0,0 +1,96 @@
1
+ ---
2
+ type: "always"
3
+ description: "Heartbeat marker visibility for .agent-chat-history — paste subprocess stdout verbatim or nothing, never type from memory, hybrid mode prints only on drift, slip handling per language-and-tone"
4
+ alwaysApply: true
5
+ source: package
6
+ ---
7
+
8
+ <!-- cloud_safe: noop -->
9
+
10
+ # Chat History — Visibility
11
+
12
+ Owns gate 3 of the chat-history Iron Law: the heartbeat marker that
13
+ makes append-cadence drift visible. Ownership (gate 1) lives in
14
+ [`chat-history-ownership`](chat-history-ownership.md); cadence (gate 2)
15
+ lives in [`chat-history-cadence`](chat-history-cadence.md). File I/O is
16
+ owned by [`scripts/chat_history.py`](../../../scripts/chat_history.py).
17
+
18
+ ## Iron Law — gate 3 (heartbeat is subprocess stdout, not memory)
19
+
20
+ ```
21
+ HEARTBEAT IS THE SCRIPT OUTPUT OF THE CURRENT TURN, VERBATIM, OR NOTHING.
22
+ NEVER TYPE THE LINE FROM MEMORY. NEVER REUSE THE PRIOR TURN'S MARKER.
23
+ EMPTY STDOUT → NO MARKER LINE.
24
+ ```
25
+
26
+ Run silently before emitting the final reply:
27
+
28
+ ```bash
29
+ scripts/chat_history.py heartbeat --first-user-msg "<first-user-msg>"
30
+ ```
31
+
32
+ Stdout is **at most** one line, e.g.
33
+ `📒 chat-history: ok · 9 entries · per_phase · last 30s ago`. Non-empty →
34
+ paste **verbatim** as the last line of the reply. Empty → emit nothing.
35
+ Always exits 0 — observability, not a gate.
36
+
37
+ ## Visibility modes — `chat_history.heartbeat`
38
+
39
+ | Mode | When marker prints | Token cost |
40
+ |---|---|---|
41
+ | `on` | every reply (legacy) | ~20 tokens / reply |
42
+ | `off` | never — full silence | 0 |
43
+ | `hybrid` *(default)* | drift states only (`missing`/`foreign`/`returning`) | 0 in normal flow, ~20 on drift |
44
+
45
+ `hybrid` ships zero tokens when healthy, loud on ownership drift. YAML 1.1
46
+ booleanizes bare `on`/`off`; the reader coerces both back, so
47
+ `heartbeat: on` works unquoted.
48
+
49
+ ## Memory-typing the marker — rule violation, not a slip
50
+
51
+ Format is memorizable; counts and timestamps are not. A typed-from-
52
+ memory line shows stale entries and a healthy-looking `ok` while the
53
+ file is silently behind — observability collapses, invisible until
54
+ `status` is checked. Heartbeat is the script output of the **current
55
+ turn**, verbatim, or nothing.
56
+
57
+ **Self-check before send — MANDATORY.** (1) Did `heartbeat` run on
58
+ this turn? (2) Is the line byte-identical to that subprocess stdout?
59
+ (3) Empty stdout → no marker line. Any "no" → drop it.
60
+
61
+ **Slip handling.** Stale marker called out → acknowledge once in the
62
+ user's language; run `status`; on CHECKPOINT call `append` for
63
+ missed phase-boundaries (see [`chat-history-cadence`](chat-history-cadence.md));
64
+ run a real `heartbeat`; paste stdout verbatim or nothing. Don't promise
65
+ "from now on" — only behaviour proves compliance (mirrors
66
+ `language-and-tone` § slip handling).
67
+
68
+ ## Path-specific behavior
69
+
70
+ Heartbeat (gate 3) stays useful for visibility on **every** path —
71
+ HOOK, ENGINE, CHECKPOINT — because the marker reports the file's
72
+ state, not the agent's intent. On HOOK and ENGINE paths the agent
73
+ still emits the marker even though it didn't fire `turn-check` or
74
+ `append` itself: the marker is read-only observability over whatever
75
+ the platform / engine wrote.
76
+
77
+ ## What this rule does NOT do
78
+
79
+ Manage ownership decisions — those live in [`chat-history-ownership`](chat-history-ownership.md).
80
+ Manage append timing — that lives in [`chat-history-cadence`](chat-history-cadence.md).
81
+ Auto-decide visibility mode — `chat_history.heartbeat` is the only
82
+ trigger. Insert decoration: the marker is functional output per
83
+ [`direct-answers`](direct-answers.md) emoji whitelist, not a status
84
+ badge.
85
+
86
+ ## Cloud Behavior
87
+
88
+ On cloud surfaces (Claude.ai Web, Skills API) heartbeat is **inert** —
89
+ no marker line, no `scripts/`. Treat `chat_history.enabled` as `false`.
90
+
91
+ ## Interactions & references
92
+
93
+ - Sibling rules: [`chat-history-ownership`](chat-history-ownership.md) (gate 1 — turn-check) · [`chat-history-cadence`](chat-history-cadence.md) (gate 2 — append).
94
+ - `direct-answers` — emoji whitelist permits the `📒` marker as functional output, not decoration.
95
+ - `language-and-tone` § slip handling — stale-marker acknowledgement.
96
+ - API: [`scripts/chat_history.py`](../../../scripts/chat_history.py) `heartbeat` and `status` subcommands. Settings: [`agent-settings`](../templates/agent-settings.md) `chat_history.heartbeat`.
@@ -36,7 +36,7 @@ the `rtk-output-filtering` skill.
36
36
 
37
37
  ### Use what you already have
38
38
 
39
- - Edited a file → `str-replace-editor` showed the result. Skip re-reading.
39
+ - Edited a file → the edit tool already returned the result. Skip re-reading.
40
40
  - Ran a command → you have the output. Skip re-running to "verify".
41
41
  - File in context from recent messages → skip reloading.
42
42
  - Found a symbol → use it. Skip searching again differently.
@@ -12,9 +12,10 @@ as a **numbered option** alongside an "as-is" escape hatch. The user
12
12
  always picks. **Nothing auto-executes.** The suggestion layer is a
13
13
  read-only shortcut *finder*, not an invocation path.
14
14
 
15
- Engine: `scripts/command_suggester/`. Eligibility table:
15
+ The deterministic engine lives in `scripts/command_suggester/`. The
16
+ locked eligibility table lives in
16
17
  [`agents/contexts/command-suggestion-eligibility.md`](../../agents/contexts/command-suggestion-eligibility.md).
17
- Design:
18
+ The full design lives in
18
19
  [`road-to-context-aware-command-suggestion`](../../agents/roadmaps/road-to-context-aware-command-suggestion.md).
19
20
 
20
21
  ## Iron Law — never auto-execute