@event4u/agent-config 1.18.0 → 1.20.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 (181) hide show
  1. package/.agent-src/commands/agent-handoff.md +14 -10
  2. package/.agent-src/commands/chat-history/import.md +170 -0
  3. package/.agent-src/commands/chat-history/learn.md +178 -0
  4. package/.agent-src/commands/chat-history/show.md +17 -18
  5. package/.agent-src/commands/chat-history.md +26 -25
  6. package/.agent-src/commands/council/default.md +77 -82
  7. package/.agent-src/commands/create-pr.md +28 -8
  8. package/.agent-src/commands/feature/roadmap.md +22 -0
  9. package/.agent-src/commands/roadmap/create.md +38 -6
  10. package/.agent-src/commands/roadmap/execute.md +36 -9
  11. package/.agent-src/commands/sync-gitignore.md +1 -1
  12. package/.agent-src/contexts/communication/rules-auto/skill-quality-mechanics.md +76 -0
  13. package/.agent-src/contexts/communication/rules-auto/slash-command-routing-policy-mechanics.md +3 -3
  14. package/.agent-src/contexts/communication/rules-auto/user-interaction-mechanics.md +5 -12
  15. package/.agent-src/rules/agent-authority.md +1 -0
  16. package/.agent-src/rules/agent-docs.md +1 -0
  17. package/.agent-src/rules/analysis-skill-routing.md +1 -0
  18. package/.agent-src/rules/architecture.md +1 -0
  19. package/.agent-src/rules/artifact-drafting-protocol.md +1 -0
  20. package/.agent-src/rules/artifact-engagement-recording.md +1 -0
  21. package/.agent-src/rules/ask-when-uncertain.md +1 -0
  22. package/.agent-src/rules/augment-portability.md +1 -0
  23. package/.agent-src/rules/augment-source-of-truth.md +1 -0
  24. package/.agent-src/rules/autonomous-execution.md +1 -0
  25. package/.agent-src/rules/capture-learnings.md +1 -0
  26. package/.agent-src/rules/cli-output-handling.md +2 -2
  27. package/.agent-src/rules/command-suggestion-policy.md +1 -0
  28. package/.agent-src/rules/commit-conventions.md +1 -0
  29. package/.agent-src/rules/commit-policy.md +1 -0
  30. package/.agent-src/rules/context-hygiene.md +22 -0
  31. package/.agent-src/rules/direct-answers.md +11 -2
  32. package/.agent-src/rules/docker-commands.md +1 -0
  33. package/.agent-src/rules/docs-sync.md +1 -0
  34. package/.agent-src/rules/downstream-changes.md +1 -0
  35. package/.agent-src/rules/e2e-testing.md +1 -0
  36. package/.agent-src/rules/guidelines.md +1 -0
  37. package/.agent-src/rules/improve-before-implement.md +1 -0
  38. package/.agent-src/rules/language-and-tone.md +38 -6
  39. package/.agent-src/rules/laravel-translations.md +1 -0
  40. package/.agent-src/rules/markdown-safe-codeblocks.md +1 -0
  41. package/.agent-src/rules/minimal-safe-diff.md +1 -0
  42. package/.agent-src/rules/missing-tool-handling.md +1 -0
  43. package/.agent-src/rules/model-recommendation.md +1 -0
  44. package/.agent-src/rules/no-attribution-footers.md +48 -0
  45. package/.agent-src/rules/no-cheap-questions.md +1 -0
  46. package/.agent-src/rules/no-roadmap-references.md +2 -1
  47. package/.agent-src/rules/non-destructive-by-default.md +1 -0
  48. package/.agent-src/rules/onboarding-gate.md +26 -0
  49. package/.agent-src/rules/package-ci-checks.md +1 -0
  50. package/.agent-src/rules/php-coding.md +1 -0
  51. package/.agent-src/rules/preservation-guard.md +1 -0
  52. package/.agent-src/rules/review-routing-awareness.md +1 -0
  53. package/.agent-src/rules/reviewer-awareness.md +1 -0
  54. package/.agent-src/rules/roadmap-progress-sync.md +22 -0
  55. package/.agent-src/rules/role-mode-adherence.md +2 -2
  56. package/.agent-src/rules/rule-type-governance.md +1 -0
  57. package/.agent-src/rules/runtime-safety.md +1 -0
  58. package/.agent-src/rules/scope-control.md +1 -0
  59. package/.agent-src/rules/security-sensitive-stop.md +1 -0
  60. package/.agent-src/rules/size-enforcement.md +1 -0
  61. package/.agent-src/rules/skill-improvement-trigger.md +1 -0
  62. package/.agent-src/rules/skill-quality.md +50 -0
  63. package/.agent-src/rules/slash-command-routing-policy.md +39 -0
  64. package/.agent-src/rules/think-before-action.md +1 -0
  65. package/.agent-src/rules/token-efficiency.md +1 -0
  66. package/.agent-src/rules/tool-safety.md +1 -0
  67. package/.agent-src/rules/ui-audit-gate.md +1 -0
  68. package/.agent-src/rules/upstream-proposal.md +1 -0
  69. package/.agent-src/rules/user-interaction.md +22 -5
  70. package/.agent-src/rules/verify-before-complete.md +1 -0
  71. package/.agent-src/skills/ai-council/SKILL.md +4 -5
  72. package/.agent-src/skills/dcf-modeling/SKILL.md +89 -0
  73. package/.agent-src/skills/funnel-analysis/SKILL.md +100 -0
  74. package/.agent-src/skills/md-language-check/SKILL.md +1 -1
  75. package/.agent-src/skills/okr-tree-modeling/SKILL.md +93 -0
  76. package/.agent-src/skills/rice-prioritization/SKILL.md +100 -0
  77. package/.agent-src/skills/roadmap-management/SKILL.md +29 -4
  78. package/.agent-src/skills/subagent-orchestration/SKILL.md +34 -2
  79. package/.agent-src/skills/unit-economics-modeling/SKILL.md +104 -0
  80. package/.agent-src/skills/using-git-worktrees/SKILL.md +1 -0
  81. package/.agent-src/skills/verify-completion-evidence/SKILL.md +8 -1
  82. package/.agent-src/templates/agent-settings.md +21 -26
  83. package/.agent-src/templates/roadmaps.md +8 -3
  84. package/.agent-src/templates/scripts/work_engine/hook_bootstrap.py +16 -5
  85. package/.agent-src/templates/scripts/work_engine/hooks/__init__.py +4 -4
  86. package/.agent-src/templates/scripts/work_engine/hooks/builtin/__init__.py +4 -4
  87. package/.agent-src/templates/scripts/work_engine/hooks/builtin/_chat_history_base.py +7 -51
  88. package/.agent-src/templates/scripts/work_engine/hooks/builtin/chat_history_append.py +1 -2
  89. package/.agent-src/templates/scripts/work_engine/hooks/builtin/chat_history_halt_append.py +1 -2
  90. package/.agent-src/templates/scripts/work_engine/hooks/builtin/decision_trace.py +163 -0
  91. package/.agent-src/templates/scripts/work_engine/hooks/builtin/memory_visibility.py +110 -0
  92. package/.agent-src/templates/scripts/work_engine/hooks/settings.py +36 -0
  93. package/.agent-src/templates/scripts/work_engine/scoring/decision_trace.py +141 -0
  94. package/.agent-src/templates/scripts/work_engine/scoring/memory_visibility.py +125 -0
  95. package/.agent-src/templates/skill.md +30 -1
  96. package/.claude-plugin/marketplace.json +8 -4
  97. package/AGENTS.md +44 -3
  98. package/CHANGELOG.md +173 -0
  99. package/README.md +22 -22
  100. package/config/agent-settings.template.yml +42 -13
  101. package/config/gitignore-block.txt +4 -4
  102. package/docs/architecture.md +3 -3
  103. package/docs/catalog.md +18 -13
  104. package/docs/contracts/adr-chat-history-split.md +10 -1
  105. package/docs/contracts/adr-settings-sync-engine.md +127 -0
  106. package/docs/contracts/command-clusters.md +1 -1
  107. package/docs/contracts/cross-wing-handoff.md +133 -0
  108. package/docs/contracts/decision-trace-v1.md +146 -0
  109. package/docs/contracts/file-ownership-matrix.json +348 -126
  110. package/docs/contracts/hook-architecture-v1.md +220 -0
  111. package/docs/contracts/memory-visibility-v1.md +122 -0
  112. package/docs/contracts/one-off-script-lifecycle.md +109 -0
  113. package/docs/contracts/rule-interactions.yml +22 -0
  114. package/docs/customization.md +2 -1
  115. package/docs/development.md +4 -1
  116. package/docs/getting-started.md +21 -29
  117. package/docs/guidelines/agent-infra/ask-when-uncertain-demos.md +1 -1
  118. package/docs/guidelines/agent-infra/layered-settings.md +32 -13
  119. package/docs/hook-payload-capture.md +221 -0
  120. package/docs/migrations/commands-1.15.0.md +17 -12
  121. package/docs/skills-catalog.md +5 -4
  122. package/llms.txt +4 -3
  123. package/package.json +1 -1
  124. package/scripts/agent-config +45 -1
  125. package/scripts/ai_council/_default_prices.py +4 -4
  126. package/scripts/ai_council/bundler.py +3 -3
  127. package/scripts/ai_council/clients.py +25 -9
  128. package/scripts/ai_council/modes.py +3 -4
  129. package/scripts/ai_council/one_off_archive/2026-05/README.md +22 -0
  130. package/scripts/ai_council/one_off_archive/2026-05/_one_off_roundtrip.py +13 -8
  131. package/scripts/ai_council/one_off_archive/2026-05/_one_off_tier_retrofit.py +180 -0
  132. package/scripts/ai_council/pricing.py +10 -9
  133. package/scripts/ai_council/session.py +92 -0
  134. package/scripts/build_rule_trigger_matrix.py +1 -9
  135. package/scripts/capture_showcase_session.py +361 -0
  136. package/scripts/chat_history.py +963 -597
  137. package/scripts/check_always_budget.py +7 -2
  138. package/scripts/check_references.py +12 -2
  139. package/scripts/context_hygiene_hook.py +14 -6
  140. package/scripts/council_cli.py +407 -0
  141. package/scripts/hook_manifest.yaml +217 -0
  142. package/scripts/hooks/__init__.py +1 -0
  143. package/scripts/hooks/augment-chat-history.sh +10 -0
  144. package/scripts/hooks/augment-dispatcher.sh +72 -0
  145. package/scripts/hooks/cline-dispatcher.sh +86 -0
  146. package/scripts/hooks/cowork-dispatcher.sh +98 -0
  147. package/scripts/hooks/cursor-dispatcher.sh +76 -0
  148. package/scripts/hooks/dispatch_hook.py +383 -0
  149. package/scripts/hooks/envelope.py +98 -0
  150. package/scripts/hooks/gemini-dispatcher.sh +117 -0
  151. package/scripts/hooks/state_io.py +122 -0
  152. package/scripts/hooks/windsurf-dispatcher.sh +123 -0
  153. package/scripts/hooks_status.py +157 -0
  154. package/scripts/install-hooks.sh +2 -2
  155. package/scripts/install.py +725 -87
  156. package/scripts/install.sh +38 -1
  157. package/scripts/lint_handoffs.py +214 -0
  158. package/scripts/lint_hook_manifest.py +217 -0
  159. package/scripts/lint_one_off_age.py +184 -0
  160. package/scripts/lint_rule_tiers.py +78 -0
  161. package/scripts/lint_showcase_sessions.py +148 -0
  162. package/scripts/minimal_safe_diff_hook.py +245 -0
  163. package/scripts/onboarding_gate_hook.py +13 -8
  164. package/scripts/readme_linter.py +12 -3
  165. package/scripts/redact_hook_capture.py +148 -0
  166. package/scripts/roadmap_progress_hook.py +5 -0
  167. package/scripts/schemas/skill.schema.json +5 -0
  168. package/scripts/skill_linter.py +163 -1
  169. package/scripts/sync_agent_settings.py +32 -129
  170. package/scripts/sync_yaml_rt.py +734 -0
  171. package/scripts/update_prices.py +3 -3
  172. package/scripts/verify_before_complete_hook.py +216 -0
  173. package/.agent-src/commands/chat-history/checkpoint.md +0 -126
  174. package/.agent-src/commands/chat-history/clear.md +0 -103
  175. package/.agent-src/commands/chat-history/resume.md +0 -183
  176. package/.agent-src/rules/chat-history-cadence.md +0 -109
  177. package/.agent-src/rules/chat-history-ownership.md +0 -123
  178. package/.agent-src/rules/chat-history-visibility.md +0 -96
  179. package/.agent-src/templates/scripts/work_engine/hooks/builtin/chat_history_heartbeat.py +0 -50
  180. package/.agent-src/templates/scripts/work_engine/hooks/builtin/chat_history_turn_check.py +0 -49
  181. package/scripts/check_phase_coupling.py +0 -148
@@ -0,0 +1,217 @@
1
+ # Hook manifest — single source of truth for which concerns fire on which
2
+ # (platform, event) tuples. Consumed by:
3
+ # - scripts/hooks/dispatch_hook.py (runtime resolver)
4
+ # - scripts/lint_hook_manifest.py (CI gate; Phase 7.10)
5
+ # - scripts/install.py (per-platform config writer)
6
+ #
7
+ # Schema and event vocabulary: docs/contracts/hook-architecture-v1.md.
8
+ # Per-platform event-name mapping: agents/contexts/chat-history-platform-hooks.md.
9
+ #
10
+ # When you add or remove a concern, also update:
11
+ # - scripts/agent-config (CLI subcommand wiring, if exposed)
12
+ # - the source rule's "Copilot fallback" section (Phase 7.9)
13
+ # - the relevant snapshot tests under tests/hooks/ (Phase 7.11)
14
+ schema_version: 1
15
+
16
+ concerns:
17
+ chat-history:
18
+ script: scripts/chat_history.py
19
+ args: [hook-dispatch]
20
+ fail_closed: false
21
+ roadmap-progress:
22
+ script: scripts/roadmap_progress_hook.py
23
+ args: []
24
+ fail_closed: false
25
+ onboarding-gate:
26
+ script: scripts/onboarding_gate_hook.py
27
+ args: []
28
+ fail_closed: false
29
+ context-hygiene:
30
+ script: scripts/context_hygiene_hook.py
31
+ args: []
32
+ fail_closed: false
33
+ # Phase 5 — Tier-1 hook for the verify-before-complete rule. Records
34
+ # observable evidence of verification commands (tests, quality tools,
35
+ # builds) into agents/state/verify-before-complete.json. The rule body
36
+ # cites that file as the source of truth for "verified this turn?".
37
+ verify-before-complete:
38
+ script: scripts/verify_before_complete_hook.py
39
+ args: []
40
+ fail_closed: false
41
+ # Phase 5 — Tier-1 hook for the minimal-safe-diff rule. Counts unique
42
+ # files touched per turn into agents/state/minimal-safe-diff.json and
43
+ # flips warning=true past hooks.minimal_safe_diff.threshold.
44
+ minimal-safe-diff:
45
+ script: scripts/minimal_safe_diff_hook.py
46
+ args: []
47
+ fail_closed: false
48
+
49
+ platforms:
50
+ augment:
51
+ session_start: [chat-history, onboarding-gate, verify-before-complete, minimal-safe-diff]
52
+ session_end: [chat-history]
53
+ stop: [chat-history, verify-before-complete]
54
+ post_tool_use: [chat-history, roadmap-progress, context-hygiene, verify-before-complete, minimal-safe-diff]
55
+
56
+ claude:
57
+ session_start: [chat-history, onboarding-gate, verify-before-complete, minimal-safe-diff]
58
+ session_end: [chat-history]
59
+ stop: [chat-history, verify-before-complete]
60
+ user_prompt_submit: [chat-history, verify-before-complete, minimal-safe-diff]
61
+ post_tool_use: [chat-history, roadmap-progress, context-hygiene, verify-before-complete, minimal-safe-diff]
62
+
63
+ # Cowork — the Claude desktop app's local-agent-mode runtime, built
64
+ # on top of the Claude Code CLI. Same lifecycle vocabulary, same
65
+ # event-payload shape (PascalCase native names; Stop carries
66
+ # `transcript_path`). Listed as a separate platform so chat-history
67
+ # entries can attribute events to Cowork vs CLI Claude Code via the
68
+ # `agent` field.
69
+ #
70
+ # Upstream caveat (anthropics/claude-code#40495, #27398): Cowork
71
+ # sessions currently ignore all three Claude Code settings sources
72
+ # (user, project, env), and `--setting-sources user` excludes
73
+ # plugin-scope hooks. Until those land, the dispatcher binding
74
+ # below is structurally ready but lifecycle events do not fire.
75
+ # Decision matrix + upstream blockers tracked in
76
+ # agents/contexts/chat-history-platform-hooks.md § Cowork.
77
+ cowork:
78
+ session_start: [chat-history, onboarding-gate, verify-before-complete, minimal-safe-diff]
79
+ session_end: [chat-history]
80
+ stop: [chat-history, verify-before-complete]
81
+ user_prompt_submit: [chat-history, verify-before-complete, minimal-safe-diff]
82
+ post_tool_use: [chat-history, roadmap-progress, context-hygiene, verify-before-complete, minimal-safe-diff]
83
+
84
+ # Phase 7.5 — Cursor. `.cursor/hooks.json` (project) is read by the
85
+ # IDE and CLI; `~/.cursor/hooks.json` (user) is opt-in via
86
+ # `install.py --cursor-user-hooks` and uses scripts/hooks/cursor-dispatcher.sh
87
+ # to route into the active workspace. UserPromptSubmit maps to
88
+ # `beforeSubmitPrompt` (Cursor third-party-hooks table). Stop is
89
+ # IDE-only — CLI-only users fall back to /checkpoint per
90
+ # agents/contexts/chat-history-platform-hooks.md.
91
+ cursor:
92
+ session_start: [chat-history, onboarding-gate, verify-before-complete, minimal-safe-diff]
93
+ session_end: [chat-history]
94
+ stop: [chat-history, verify-before-complete]
95
+ user_prompt_submit: [chat-history, verify-before-complete, minimal-safe-diff]
96
+ post_tool_use: [chat-history, roadmap-progress, context-hygiene, verify-before-complete, minimal-safe-diff]
97
+
98
+ # Phase 7.6 — Cline. Hooks live under `.clinerules/hooks/<HookName>`
99
+ # (project, no file extension, must be executable per Cline docs) or
100
+ # `~/Documents/Cline/Hooks/<HookName>` (global). Each script reads a
101
+ # JSON payload from stdin (`taskId`, `hookName`, `workspaceRoots`,
102
+ # `model`, plus a hook-specific field). Cline emits two distinct
103
+ # task-start events — TaskStart (new) and TaskResume (continue) —
104
+ # both map to session_start. TaskCancel maps to stop because the
105
+ # session is interrupted with partial state (mirrors Augment Stop).
106
+ cline:
107
+ session_start: [chat-history, onboarding-gate, verify-before-complete, minimal-safe-diff]
108
+ session_end: [chat-history]
109
+ stop: [chat-history, verify-before-complete]
110
+ user_prompt_submit: [chat-history, verify-before-complete, minimal-safe-diff]
111
+ post_tool_use: [chat-history, roadmap-progress, context-hygiene, verify-before-complete, minimal-safe-diff]
112
+
113
+ # Phase 7.7 — Windsurf (Cascade). Hooks live at `.windsurf/hooks.json`
114
+ # (project) or `~/.codeium/windsurf/hooks.json` (user). Cascade has
115
+ # no generic post-tool-use surface — roadmap-progress and
116
+ # context-hygiene therefore have no Windsurf binding (documented
117
+ # platform limitation). chat-history wires through the per-turn
118
+ # cycle: pre_user_prompt for the turn-check, post_cascade_response
119
+ # for the per-turn append, and post_setup_worktree for first-run
120
+ # init (rare, fires only on worktree creation; advisory not
121
+ # blocking — Windsurf docs).
122
+ # Windsurf — verify-before-complete tracks lifecycle only (no post_tool_use
123
+ # surface to record verification commands; documented limitation).
124
+ # minimal-safe-diff is omitted entirely on Windsurf for the same reason.
125
+ windsurf:
126
+ session_start: [chat-history, onboarding-gate, verify-before-complete]
127
+ stop: [chat-history, verify-before-complete]
128
+ user_prompt_submit: [chat-history, verify-before-complete]
129
+
130
+ # Phase 7.8 — Gemini CLI. Hooks live at `.gemini/settings.json`
131
+ # (project) or `~/.gemini/settings.json` (user). Per Gemini docs
132
+ # (geminicli.com/docs/hooks/reference/), each event maps to an
133
+ # array of hook groups; each group has a `matcher` (regex for
134
+ # tool events, exact string for lifecycle) and a `hooks` array of
135
+ # `{type: "command", command: "..."}`. SessionStart/SessionEnd are
136
+ # advisory (cannot block); BeforeAgent fires after the user
137
+ # submits a prompt and before agent planning, so it carries the
138
+ # turn-check semantics. AfterAgent fires when the agent loop ends
139
+ # — this is our `stop` slot.
140
+ gemini:
141
+ session_start: [chat-history, onboarding-gate, verify-before-complete, minimal-safe-diff]
142
+ session_end: [chat-history]
143
+ stop: [chat-history, verify-before-complete]
144
+ user_prompt_submit: [chat-history, verify-before-complete, minimal-safe-diff]
145
+ post_tool_use: [chat-history, roadmap-progress, context-hygiene, verify-before-complete, minimal-safe-diff]
146
+
147
+ # Phase 7.9 — Copilot has no hook surface. Concerns route through
148
+ # rule-only fallback; the dispatcher silently no-ops on --platform copilot.
149
+ copilot:
150
+ fallback_only: true
151
+
152
+ # Native-event → agent-config-event translation table. Used by per-platform
153
+ # trampolines when the platform speaks a different vocabulary. Trampolines
154
+ # pass --native-event for traceability; the dispatcher does NOT branch on it.
155
+ native_event_aliases:
156
+ augment:
157
+ SessionStart: session_start
158
+ SessionEnd: session_end
159
+ Stop: stop
160
+ PostToolUse: post_tool_use
161
+ PreToolUse: pre_tool_use
162
+ claude:
163
+ SessionStart: session_start
164
+ SessionEnd: session_end
165
+ Stop: stop
166
+ UserPromptSubmit: user_prompt_submit
167
+ PostToolUse: post_tool_use
168
+ PreToolUse: pre_tool_use
169
+ PreCompact: pre_compact
170
+ # Cowork shares Claude Code's PascalCase event vocabulary verbatim
171
+ # (Cowork is Claude Code under the hood). Native names are duplicated
172
+ # here rather than aliased so dispatcher logs / feedback carry the
173
+ # platform tag the operator expects.
174
+ cowork:
175
+ SessionStart: session_start
176
+ SessionEnd: session_end
177
+ Stop: stop
178
+ UserPromptSubmit: user_prompt_submit
179
+ PostToolUse: post_tool_use
180
+ PreToolUse: pre_tool_use
181
+ PreCompact: pre_compact
182
+ cursor:
183
+ sessionStart: session_start
184
+ sessionEnd: session_end
185
+ stop: stop
186
+ beforeSubmitPrompt: user_prompt_submit
187
+ postToolUse: post_tool_use
188
+ preToolUse: pre_tool_use
189
+ preCompact: pre_compact
190
+ cline:
191
+ TaskStart: session_start
192
+ TaskResume: session_start
193
+ TaskComplete: session_end
194
+ TaskCancel: stop
195
+ UserPromptSubmit: user_prompt_submit
196
+ PostToolUse: post_tool_use
197
+ PreToolUse: pre_tool_use
198
+ PreCompact: pre_compact
199
+ # Windsurf (Cascade) — snake_case event names per
200
+ # docs.windsurf.com/windsurf/cascade/hooks. post_cascade_response is
201
+ # async (off the critical path) so the per-turn append safely lands
202
+ # in the `stop` slot rather than `session_end`.
203
+ windsurf:
204
+ pre_user_prompt: user_prompt_submit
205
+ post_cascade_response: stop
206
+ post_setup_worktree: session_start
207
+ # Gemini CLI — PascalCase event names per geminicli.com/docs/hooks/.
208
+ # BeforeAgent fires after the user submits a prompt and before
209
+ # planning (carries the turn-check / append-on-prompt semantics).
210
+ # AfterAgent fires when the agent loop ends — our `stop` slot.
211
+ gemini:
212
+ SessionStart: session_start
213
+ SessionEnd: session_end
214
+ BeforeAgent: user_prompt_submit
215
+ AfterAgent: stop
216
+ BeforeTool: pre_tool_use
217
+ AfterTool: post_tool_use
@@ -0,0 +1 @@
1
+
@@ -21,6 +21,16 @@ set -u
21
21
 
22
22
  EVENT_DATA="$(cat)"
23
23
 
24
+ # Debug-only: when ~/.augment/.chat-history-debug exists, dump the raw
25
+ # stdin payload for offline inspection. No-op otherwise. Used to probe
26
+ # what Augment's hook events actually carry.
27
+ if [ -f "$HOME/.augment/.chat-history-debug" ]; then
28
+ DUMP_DIR="$HOME/.augment/chat-history-debug"
29
+ mkdir -p "$DUMP_DIR" 2>/dev/null
30
+ printf '%s' "$EVENT_DATA" \
31
+ > "$DUMP_DIR/event-$(date +%Y%m%d-%H%M%S)-$$.json" 2>/dev/null || true
32
+ fi
33
+
24
34
  # Extract workspace_roots[0] using whichever JSON tool is available.
25
35
  WORKSPACE=""
26
36
  if command -v jq >/dev/null 2>&1; then
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env bash
2
+ # Augment Code universal hook trampoline (Phase 7.3, hook-architecture-v1.md).
3
+ #
4
+ # Replaces the four per-concern trampolines (augment-chat-history.sh,
5
+ # augment-roadmap-progress.sh, augment-onboarding-gate.sh,
6
+ # augment-context-hygiene.sh). One script, dispatched per (platform, event)
7
+ # tuple via scripts/hooks/dispatch_hook.py reading scripts/hook_manifest.yaml.
8
+ #
9
+ # Augment requires hook scripts to use the .sh extension and live at user
10
+ # scope (~/.augment/hooks/) — same constraint as the legacy trampolines.
11
+ #
12
+ # Behaviour:
13
+ # - Read the JSON event from stdin into a buffer.
14
+ # - Extract workspace_roots[0]; bail silently when missing.
15
+ # - cd into that workspace; bail silently when it is not a directory
16
+ # or does not contain ./agent-config.
17
+ # - Re-pipe the original JSON into
18
+ # ./agent-config dispatch:hook --platform augment \
19
+ # --event $1 --native-event $2
20
+ # - Always exit 0 — Augment hooks must never block the agent loop
21
+ # (chat-history / roadmap-progress / context-hygiene are observe-only;
22
+ # onboarding-gate writes state but does not deny SessionStart).
23
+
24
+ set -u
25
+
26
+ # Args from the platform's settings.json hook entry:
27
+ # $1 = agent-config event name (session_start, post_tool_use, …)
28
+ # $2 = Augment-native event name (SessionStart, PostToolUse, …)
29
+ EVENT="${1-}"
30
+ NATIVE_EVENT="${2-}"
31
+
32
+ if [ -z "$EVENT" ]; then
33
+ exit 0
34
+ fi
35
+
36
+ EVENT_DATA="$(cat)"
37
+
38
+ WORKSPACE=""
39
+ if command -v jq >/dev/null 2>&1; then
40
+ WORKSPACE="$(printf '%s' "$EVENT_DATA" \
41
+ | jq -r '.workspace_roots[0] // empty' 2>/dev/null)"
42
+ elif command -v python3 >/dev/null 2>&1; then
43
+ WORKSPACE="$(printf '%s' "$EVENT_DATA" | python3 -c '
44
+ import json, sys
45
+ try:
46
+ data = json.load(sys.stdin)
47
+ except Exception:
48
+ sys.exit(0)
49
+ roots = data.get("workspace_roots") or []
50
+ if roots:
51
+ print(roots[0])
52
+ ' 2>/dev/null)"
53
+ fi
54
+
55
+ if [ -z "$WORKSPACE" ] || [ ! -d "$WORKSPACE" ]; then
56
+ exit 0
57
+ fi
58
+
59
+ cd "$WORKSPACE" 2>/dev/null || exit 0
60
+
61
+ if [ ! -x ./agent-config ]; then
62
+ exit 0
63
+ fi
64
+
65
+ printf '%s' "$EVENT_DATA" \
66
+ | ./agent-config dispatch:hook \
67
+ --platform augment \
68
+ --event "$EVENT" \
69
+ --native-event "$NATIVE_EVENT" \
70
+ >/dev/null 2>&1 || true
71
+
72
+ exit 0
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env bash
2
+ # Cline universal hook trampoline (Phase 7.6, hook-architecture-v1.md).
3
+ #
4
+ # Routes user-scope `~/Documents/Cline/Hooks/<HookName>` events into
5
+ # the active workspace's `./agent-config dispatch:hook`. Project-scope
6
+ # `.clinerules/hooks/<HookName>` does NOT need this trampoline —
7
+ # install.py `ensure_cline_bridge()` writes per-event scripts there
8
+ # that dispatch directly because Cline fires project hooks with the
9
+ # workspace as cwd.
10
+ #
11
+ # Cline event payload (per docs.cline.bot/customization/hooks):
12
+ # { "taskId": "...", "hookName": "...", "clineVersion": "...",
13
+ # "timestamp": "...", "workspaceRoots": ["<path>"], "userId": "...",
14
+ # "model": { ... }, "<hookName-camelCase>": { ... }, ... }
15
+ #
16
+ # Output (read by Cline): JSON `{ cancel: bool, contextModification?,
17
+ # errorMessage? }`. Per agent-config we always emit an empty `{}` —
18
+ # concerns are observe-only at this layer; chat-history /
19
+ # roadmap-progress / context-hygiene never block, and onboarding-gate
20
+ # blocks via state file, not via cancel-on-TaskStart.
21
+ #
22
+ # Phase 7.6 amendment — Windows path guard: Cline upstream issue
23
+ # cline#8073 reports `workspaceRoots` containing CRLF or
24
+ # Windows-style paths on certain hosts. We only act when the first
25
+ # entry is a directory; other shapes silently no-op.
26
+
27
+ set -u
28
+
29
+ # Args from the hook script that wraps this trampoline:
30
+ # $1 = agent-config event name (session_start, post_tool_use, …)
31
+ # $2 = Cline-native hook name (TaskStart, PostToolUse, …)
32
+ EVENT="${1-}"
33
+ NATIVE_EVENT="${2-}"
34
+
35
+ if [ -z "$EVENT" ]; then
36
+ printf '%s\n' '{}'
37
+ exit 0
38
+ fi
39
+
40
+ EVENT_DATA="$(cat)"
41
+
42
+ WORKSPACE=""
43
+ if command -v jq >/dev/null 2>&1; then
44
+ WORKSPACE="$(printf '%s' "$EVENT_DATA" \
45
+ | jq -r '.workspaceRoots[0] // empty' 2>/dev/null)"
46
+ elif command -v python3 >/dev/null 2>&1; then
47
+ WORKSPACE="$(printf '%s' "$EVENT_DATA" | python3 -c '
48
+ import json, sys
49
+ try:
50
+ data = json.load(sys.stdin)
51
+ except Exception:
52
+ sys.exit(0)
53
+ roots = data.get("workspaceRoots") or []
54
+ if roots:
55
+ print(roots[0])
56
+ ' 2>/dev/null)"
57
+ fi
58
+
59
+ # Strip CR (cline#8073 — Windows hosts can emit CRLF) and reject
60
+ # obviously-bogus shapes before the cd.
61
+ WORKSPACE="${WORKSPACE%$'\r'}"
62
+
63
+ if [ -z "$WORKSPACE" ] || [ ! -d "$WORKSPACE" ]; then
64
+ printf '%s\n' '{}'
65
+ exit 0
66
+ fi
67
+
68
+ cd "$WORKSPACE" 2>/dev/null || { printf '%s\n' '{}'; exit 0; }
69
+
70
+ if [ ! -x ./agent-config ]; then
71
+ printf '%s\n' '{}'
72
+ exit 0
73
+ fi
74
+
75
+ printf '%s' "$EVENT_DATA" \
76
+ | ./agent-config dispatch:hook \
77
+ --platform cline \
78
+ --event "$EVENT" \
79
+ --native-event "$NATIVE_EVENT" \
80
+ >/dev/null 2>&1 || true
81
+
82
+ # Cline expects a JSON envelope on stdout; empty object = "no cancel,
83
+ # no context modification, no error". Errors from concerns surface
84
+ # through agents/state/.dispatcher/<session_id>/ per Phase 7.3.
85
+ printf '%s\n' '{}'
86
+ exit 0
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env bash
2
+ # Cowork universal hook trampoline.
3
+ #
4
+ # Cowork is the Claude desktop app's local-agent-mode runtime. It runs
5
+ # the Claude Code CLI inside a sandbox VM, so hook events use the
6
+ # Claude Code shape (PascalCase native names; Stop carries
7
+ # `transcript_path`). The payload typically carries `cwd` (Claude
8
+ # Code's standard field) rather than Augment's `workspace_roots[0]`.
9
+ # We accept either, falling back through both.
10
+ #
11
+ # Upstream caveat: as of writing this trampoline, lifecycle events do
12
+ # not actually fire from Cowork sessions —
13
+ # anthropics/claude-code#40495 reports all three Claude Code settings
14
+ # sources (user, project, env) are ignored inside Cowork's sandbox,
15
+ # and #27398 reports plugin-scope `hooks/hooks.json` is excluded
16
+ # because Cowork spawns the CLI with `--setting-sources user`. The
17
+ # trampoline is structurally ready; install plumbing is deferred
18
+ # until upstream resolves the bugs and a stable settings location is
19
+ # documented. See `agents/contexts/chat-history-platform-hooks.md`
20
+ # § Cowork.
21
+ #
22
+ # Behaviour mirrors cursor-dispatcher.sh:
23
+ # - Read JSON event from stdin into a buffer.
24
+ # - Extract cwd (Claude Code) or workspace_roots[0] (fallback);
25
+ # bail silently when neither resolves to a directory.
26
+ # - cd into that workspace; bail silently when it lacks ./agent-config.
27
+ # - Re-pipe the original JSON into
28
+ # ./agent-config dispatch:hook --platform cowork \
29
+ # --event $1 --native-event $2
30
+ # - Always exit 0 — chat-history must never block the agent loop.
31
+
32
+ set -u
33
+
34
+ # Args from the platform's hooks config (whatever shape Cowork ends up
35
+ # using once upstream lands the fix):
36
+ # $1 = agent-config event name (session_start, post_tool_use, …)
37
+ # $2 = Cowork-native event name (SessionStart, PostToolUse, …)
38
+ EVENT="${1-}"
39
+ NATIVE_EVENT="${2-}"
40
+
41
+ if [ -z "$EVENT" ]; then
42
+ exit 0
43
+ fi
44
+
45
+ EVENT_DATA="$(cat)"
46
+
47
+ # Debug-only: when ~/.claude/.cowork-chat-history-debug exists, dump
48
+ # the raw stdin payload for offline inspection. No-op otherwise.
49
+ # Useful once upstream fixes #40495 to verify the actual payload shape.
50
+ if [ -f "$HOME/.claude/.cowork-chat-history-debug" ]; then
51
+ DUMP_DIR="$HOME/.claude/cowork-chat-history-debug"
52
+ mkdir -p "$DUMP_DIR" 2>/dev/null
53
+ printf '%s' "$EVENT_DATA" \
54
+ > "$DUMP_DIR/event-$(date +%Y%m%d-%H%M%S)-$$.json" 2>/dev/null || true
55
+ fi
56
+
57
+ # Extract workspace path. Try Claude Code's `cwd` first, then fall
58
+ # back to Augment-style `workspace_roots[0]`. Either is acceptable —
59
+ # we need a directory containing ./agent-config.
60
+ WORKSPACE=""
61
+ if command -v jq >/dev/null 2>&1; then
62
+ WORKSPACE="$(printf '%s' "$EVENT_DATA" \
63
+ | jq -r '.cwd // .workspace_roots[0] // empty' 2>/dev/null)"
64
+ elif command -v python3 >/dev/null 2>&1; then
65
+ WORKSPACE="$(printf '%s' "$EVENT_DATA" | python3 -c '
66
+ import json, sys
67
+ try:
68
+ data = json.load(sys.stdin)
69
+ except Exception:
70
+ sys.exit(0)
71
+ cwd = data.get("cwd")
72
+ if isinstance(cwd, str) and cwd:
73
+ print(cwd)
74
+ sys.exit(0)
75
+ roots = data.get("workspace_roots") or []
76
+ if roots:
77
+ print(roots[0])
78
+ ' 2>/dev/null)"
79
+ fi
80
+
81
+ if [ -z "$WORKSPACE" ] || [ ! -d "$WORKSPACE" ]; then
82
+ exit 0
83
+ fi
84
+
85
+ cd "$WORKSPACE" 2>/dev/null || exit 0
86
+
87
+ if [ ! -x ./agent-config ]; then
88
+ exit 0
89
+ fi
90
+
91
+ printf '%s' "$EVENT_DATA" \
92
+ | ./agent-config dispatch:hook \
93
+ --platform cowork \
94
+ --event "$EVENT" \
95
+ --native-event "$NATIVE_EVENT" \
96
+ >/dev/null 2>&1 || true
97
+
98
+ exit 0
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env bash
2
+ # Cursor universal hook trampoline (Phase 7.5, hook-architecture-v1.md).
3
+ #
4
+ # Routes user-scope `~/.cursor/hooks.json` events into the active
5
+ # workspace's `./agent-config dispatch:hook`. Project-scope
6
+ # `.cursor/hooks.json` does NOT need this trampoline — install.py
7
+ # `ensure_cursor_bridge()` writes direct dispatch:hook commands there
8
+ # because the project hooks fire with the workspace as cwd.
9
+ #
10
+ # Cursor event payload (per https://cursor.com/docs/hooks):
11
+ # { "conversation_id": "...", "generation_id": "...",
12
+ # "model": "...", "hook_event_name": "...",
13
+ # "cursor_version": "...", "workspace_roots": ["<path>"],
14
+ # "user_email": "...|null", "transcript_path": "...|null", ... }
15
+ #
16
+ # Behaviour mirrors augment-dispatcher.sh:
17
+ # - Read JSON event from stdin into a buffer.
18
+ # - Extract workspace_roots[0]; bail silently when missing.
19
+ # - cd into that workspace; bail silently when it lacks ./agent-config.
20
+ # - Re-pipe the original JSON into
21
+ # ./agent-config dispatch:hook --platform cursor \
22
+ # --event $1 --native-event $2
23
+ # - Always exit 0 — Cursor's pre-hooks can block via exit code, but
24
+ # none of our concerns block; chat-history / roadmap-progress /
25
+ # context-hygiene are observe-only and onboarding-gate writes
26
+ # state without denying sessionStart.
27
+
28
+ set -u
29
+
30
+ # Args from the platform's hooks.json command string:
31
+ # $1 = agent-config event name (session_start, post_tool_use, …)
32
+ # $2 = Cursor-native event name (sessionStart, postToolUse, …)
33
+ EVENT="${1-}"
34
+ NATIVE_EVENT="${2-}"
35
+
36
+ if [ -z "$EVENT" ]; then
37
+ exit 0
38
+ fi
39
+
40
+ EVENT_DATA="$(cat)"
41
+
42
+ WORKSPACE=""
43
+ if command -v jq >/dev/null 2>&1; then
44
+ WORKSPACE="$(printf '%s' "$EVENT_DATA" \
45
+ | jq -r '.workspace_roots[0] // empty' 2>/dev/null)"
46
+ elif command -v python3 >/dev/null 2>&1; then
47
+ WORKSPACE="$(printf '%s' "$EVENT_DATA" | python3 -c '
48
+ import json, sys
49
+ try:
50
+ data = json.load(sys.stdin)
51
+ except Exception:
52
+ sys.exit(0)
53
+ roots = data.get("workspace_roots") or []
54
+ if roots:
55
+ print(roots[0])
56
+ ' 2>/dev/null)"
57
+ fi
58
+
59
+ if [ -z "$WORKSPACE" ] || [ ! -d "$WORKSPACE" ]; then
60
+ exit 0
61
+ fi
62
+
63
+ cd "$WORKSPACE" 2>/dev/null || exit 0
64
+
65
+ if [ ! -x ./agent-config ]; then
66
+ exit 0
67
+ fi
68
+
69
+ printf '%s' "$EVENT_DATA" \
70
+ | ./agent-config dispatch:hook \
71
+ --platform cursor \
72
+ --event "$EVENT" \
73
+ --native-event "$NATIVE_EVENT" \
74
+ >/dev/null 2>&1 || true
75
+
76
+ exit 0