selftune 0.1.4 → 0.2.1

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 (153) hide show
  1. package/.claude/agents/diagnosis-analyst.md +156 -0
  2. package/.claude/agents/evolution-reviewer.md +180 -0
  3. package/.claude/agents/integration-guide.md +212 -0
  4. package/.claude/agents/pattern-analyst.md +160 -0
  5. package/CHANGELOG.md +46 -1
  6. package/README.md +105 -257
  7. package/apps/local-dashboard/dist/assets/geist-cyrillic-wght-normal-CHSlOQsW.woff2 +0 -0
  8. package/apps/local-dashboard/dist/assets/geist-latin-ext-wght-normal-DMtmJ5ZE.woff2 +0 -0
  9. package/apps/local-dashboard/dist/assets/geist-latin-wght-normal-Dm3htQBi.woff2 +0 -0
  10. package/apps/local-dashboard/dist/assets/index-C4EOTFZ2.js +15 -0
  11. package/apps/local-dashboard/dist/assets/index-bl-Webyd.css +1 -0
  12. package/apps/local-dashboard/dist/assets/vendor-react-U7zYD9Rg.js +60 -0
  13. package/apps/local-dashboard/dist/assets/vendor-table-B7VF2Ipl.js +26 -0
  14. package/apps/local-dashboard/dist/assets/vendor-ui-D7_zX_qy.js +346 -0
  15. package/apps/local-dashboard/dist/favicon.png +0 -0
  16. package/apps/local-dashboard/dist/index.html +17 -0
  17. package/apps/local-dashboard/dist/logo.png +0 -0
  18. package/apps/local-dashboard/dist/logo.svg +9 -0
  19. package/assets/BeforeAfter.gif +0 -0
  20. package/assets/FeedbackLoop.gif +0 -0
  21. package/assets/logo.svg +9 -0
  22. package/assets/skill-health-badge.svg +20 -0
  23. package/cli/selftune/activation-rules.ts +171 -0
  24. package/cli/selftune/badge/badge-data.ts +108 -0
  25. package/cli/selftune/badge/badge-svg.ts +212 -0
  26. package/cli/selftune/badge/badge.ts +99 -0
  27. package/cli/selftune/canonical-export.ts +183 -0
  28. package/cli/selftune/constants.ts +103 -1
  29. package/cli/selftune/contribute/bundle.ts +314 -0
  30. package/cli/selftune/contribute/contribute.ts +214 -0
  31. package/cli/selftune/contribute/sanitize.ts +162 -0
  32. package/cli/selftune/cron/setup.ts +266 -0
  33. package/cli/selftune/dashboard-contract.ts +202 -0
  34. package/cli/selftune/dashboard-server.ts +1049 -0
  35. package/cli/selftune/dashboard.ts +43 -156
  36. package/cli/selftune/eval/baseline.ts +248 -0
  37. package/cli/selftune/eval/composability-v2.ts +273 -0
  38. package/cli/selftune/eval/composability.ts +117 -0
  39. package/cli/selftune/eval/generate-unit-tests.ts +143 -0
  40. package/cli/selftune/eval/hooks-to-evals.ts +101 -16
  41. package/cli/selftune/eval/import-skillsbench.ts +221 -0
  42. package/cli/selftune/eval/synthetic-evals.ts +172 -0
  43. package/cli/selftune/eval/unit-test-cli.ts +152 -0
  44. package/cli/selftune/eval/unit-test.ts +196 -0
  45. package/cli/selftune/evolution/deploy-proposal.ts +142 -1
  46. package/cli/selftune/evolution/evidence.ts +26 -0
  47. package/cli/selftune/evolution/evolve-body.ts +586 -0
  48. package/cli/selftune/evolution/evolve.ts +825 -116
  49. package/cli/selftune/evolution/extract-patterns.ts +105 -16
  50. package/cli/selftune/evolution/pareto.ts +314 -0
  51. package/cli/selftune/evolution/propose-body.ts +171 -0
  52. package/cli/selftune/evolution/propose-description.ts +100 -2
  53. package/cli/selftune/evolution/propose-routing.ts +166 -0
  54. package/cli/selftune/evolution/refine-body.ts +141 -0
  55. package/cli/selftune/evolution/rollback.ts +21 -4
  56. package/cli/selftune/evolution/validate-body.ts +254 -0
  57. package/cli/selftune/evolution/validate-proposal.ts +257 -35
  58. package/cli/selftune/evolution/validate-routing.ts +177 -0
  59. package/cli/selftune/grading/auto-grade.ts +200 -0
  60. package/cli/selftune/grading/grade-session.ts +513 -42
  61. package/cli/selftune/grading/pre-gates.ts +104 -0
  62. package/cli/selftune/grading/results.ts +42 -0
  63. package/cli/selftune/hooks/auto-activate.ts +185 -0
  64. package/cli/selftune/hooks/evolution-guard.ts +165 -0
  65. package/cli/selftune/hooks/prompt-log.ts +172 -2
  66. package/cli/selftune/hooks/session-stop.ts +123 -3
  67. package/cli/selftune/hooks/skill-change-guard.ts +112 -0
  68. package/cli/selftune/hooks/skill-eval.ts +119 -3
  69. package/cli/selftune/index.ts +415 -48
  70. package/cli/selftune/ingestors/claude-replay.ts +377 -0
  71. package/cli/selftune/ingestors/codex-rollout.ts +345 -46
  72. package/cli/selftune/ingestors/codex-wrapper.ts +207 -39
  73. package/cli/selftune/ingestors/openclaw-ingest.ts +573 -0
  74. package/cli/selftune/ingestors/opencode-ingest.ts +193 -17
  75. package/cli/selftune/init.ts +376 -16
  76. package/cli/selftune/last.ts +14 -5
  77. package/cli/selftune/localdb/db.ts +63 -0
  78. package/cli/selftune/localdb/materialize.ts +428 -0
  79. package/cli/selftune/localdb/queries.ts +376 -0
  80. package/cli/selftune/localdb/schema.ts +204 -0
  81. package/cli/selftune/memory/writer.ts +447 -0
  82. package/cli/selftune/monitoring/watch.ts +90 -16
  83. package/cli/selftune/normalization.ts +682 -0
  84. package/cli/selftune/observability.ts +19 -44
  85. package/cli/selftune/orchestrate.ts +1073 -0
  86. package/cli/selftune/quickstart.ts +203 -0
  87. package/cli/selftune/repair/skill-usage.ts +576 -0
  88. package/cli/selftune/schedule.ts +561 -0
  89. package/cli/selftune/status.ts +59 -33
  90. package/cli/selftune/sync.ts +627 -0
  91. package/cli/selftune/types.ts +525 -5
  92. package/cli/selftune/utils/canonical-log.ts +45 -0
  93. package/cli/selftune/utils/frontmatter.ts +217 -0
  94. package/cli/selftune/utils/hooks.ts +41 -0
  95. package/cli/selftune/utils/html.ts +27 -0
  96. package/cli/selftune/utils/llm-call.ts +103 -19
  97. package/cli/selftune/utils/math.ts +10 -0
  98. package/cli/selftune/utils/query-filter.ts +139 -0
  99. package/cli/selftune/utils/skill-discovery.ts +340 -0
  100. package/cli/selftune/utils/skill-log.ts +68 -0
  101. package/cli/selftune/utils/skill-usage-confidence.ts +18 -0
  102. package/cli/selftune/utils/transcript.ts +307 -26
  103. package/cli/selftune/utils/trigger-check.ts +89 -0
  104. package/cli/selftune/utils/tui.ts +156 -0
  105. package/cli/selftune/workflows/discover.ts +254 -0
  106. package/cli/selftune/workflows/skill-md-writer.ts +288 -0
  107. package/cli/selftune/workflows/workflows.ts +188 -0
  108. package/package.json +28 -11
  109. package/packages/telemetry-contract/README.md +11 -0
  110. package/packages/telemetry-contract/fixtures/golden.json +87 -0
  111. package/packages/telemetry-contract/fixtures/golden.test.ts +42 -0
  112. package/packages/telemetry-contract/index.ts +1 -0
  113. package/packages/telemetry-contract/package.json +19 -0
  114. package/packages/telemetry-contract/src/index.ts +2 -0
  115. package/packages/telemetry-contract/src/types.ts +163 -0
  116. package/packages/telemetry-contract/src/validators.ts +109 -0
  117. package/skill/SKILL.md +180 -33
  118. package/skill/Workflows/AutoActivation.md +145 -0
  119. package/skill/Workflows/Badge.md +124 -0
  120. package/skill/Workflows/Baseline.md +144 -0
  121. package/skill/Workflows/Composability.md +107 -0
  122. package/skill/Workflows/Contribute.md +94 -0
  123. package/skill/Workflows/Cron.md +132 -0
  124. package/skill/Workflows/Dashboard.md +214 -0
  125. package/skill/Workflows/Doctor.md +63 -14
  126. package/skill/Workflows/Evals.md +110 -18
  127. package/skill/Workflows/EvolutionMemory.md +154 -0
  128. package/skill/Workflows/Evolve.md +181 -21
  129. package/skill/Workflows/EvolveBody.md +159 -0
  130. package/skill/Workflows/Grade.md +36 -31
  131. package/skill/Workflows/ImportSkillsBench.md +117 -0
  132. package/skill/Workflows/Ingest.md +142 -21
  133. package/skill/Workflows/Initialize.md +91 -23
  134. package/skill/Workflows/Orchestrate.md +139 -0
  135. package/skill/Workflows/Replay.md +91 -0
  136. package/skill/Workflows/Rollback.md +23 -4
  137. package/skill/Workflows/Schedule.md +61 -0
  138. package/skill/Workflows/Sync.md +88 -0
  139. package/skill/Workflows/UnitTest.md +150 -0
  140. package/skill/Workflows/Watch.md +33 -1
  141. package/skill/Workflows/Workflows.md +129 -0
  142. package/skill/assets/activation-rules-default.json +26 -0
  143. package/skill/assets/multi-skill-settings.json +63 -0
  144. package/skill/assets/single-skill-settings.json +57 -0
  145. package/skill/references/invocation-taxonomy.md +2 -2
  146. package/skill/references/logs.md +164 -2
  147. package/skill/references/setup-patterns.md +65 -0
  148. package/skill/references/version-history.md +40 -0
  149. package/skill/settings_snippet.json +23 -0
  150. package/templates/activation-rules-default.json +27 -0
  151. package/templates/multi-skill-settings.json +64 -0
  152. package/templates/single-skill-settings.json +58 -0
  153. package/dashboard/index.html +0 -1119
@@ -1,7 +1,7 @@
1
1
  # Invocation Taxonomy Reference
2
2
 
3
3
  How selftune classifies the ways users trigger (or should trigger) a skill.
4
- Used by the `evals` command and referenced by evolution workflows to understand
4
+ Used by the `selftune eval generate` command and referenced by evolution workflows to understand
5
5
  coverage gaps.
6
6
 
7
7
  ---
@@ -92,7 +92,7 @@ The invocation taxonomy directly drives the evolution feedback loop:
92
92
 
93
93
  ### Missed Implicit = Undertriggering
94
94
 
95
- When `evals` shows implicit queries that don't trigger the skill, the
95
+ When `selftune eval generate` shows implicit queries that don't trigger the skill, the
96
96
  description is too narrow. The `evolve` command will:
97
97
  1. Extract the missed implicit patterns
98
98
  2. Propose description changes that cover them
@@ -1,7 +1,8 @@
1
1
  # Log Format Reference
2
2
 
3
- selftune writes to four log files. This reference describes each format
4
- in detail for the skill to use when parsing sessions and audit trails.
3
+ selftune writes raw legacy logs plus a canonical event log. This reference
4
+ describes each format in detail for the skill to use when parsing sessions,
5
+ audit trails, and cloud-ingest exports.
5
6
 
6
7
  ---
7
8
 
@@ -54,12 +55,30 @@ One record per skill trigger event. Populated by skill-eval.ts (PostToolUse hook
54
55
  "session_id": "abc123",
55
56
  "skill_name": "pptx",
56
57
  "skill_path": "/mnt/skills/public/pptx/SKILL.md",
58
+ "skill_scope": "project",
59
+ "skill_project_root": "/home/user/projects/myapp",
60
+ "skill_registry_dir": "/home/user/projects/myapp/.agents/skills",
61
+ "skill_path_resolution_source": "raw_log",
57
62
  "query": "Make me a slide deck for the board meeting",
58
63
  "triggered": true,
59
64
  "source": "claude_code"
60
65
  }
61
66
  ```
62
67
 
68
+ Optional provenance fields:
69
+ - `skill_scope`: `project | global | admin | system | unknown`
70
+ - `skill_project_root`: resolved repo/worktree root when the skill came from a project-local registry
71
+ - `skill_registry_dir`: the registry directory where the resolved `SKILL.md` came from
72
+ - `skill_path_resolution_source`: `raw_log | installed_scope | launcher_base_dir | fallback`
73
+
74
+ The repaired overlay at `~/.claude/skill_usage_repaired.jsonl` uses the same
75
+ record shape, but is rebuilt from source-truth transcripts/rollouts rather than
76
+ hooks alone.
77
+
78
+ Notes:
79
+ - `launcher_base_dir` means selftune recovered Claude's `Base directory for this skill:` launcher metadata. If that recovered `SKILL.md` path points into a stable registry like `~/.agents/skills`, `~/.claude/skills`, `/etc/codex/skills`, or a real project checkout, selftune now reclassifies the invocation into the matching `skill_scope`. Ephemeral temp launcher directories still remain `unknown`.
80
+ - `fallback` means selftune confirmed a skill invocation but could not yet resolve a concrete `SKILL.md` path.
81
+
63
82
  ---
64
83
 
65
84
  ## ~/.claude/all_queries_log.jsonl
@@ -77,6 +96,149 @@ Every user query, whether or not it triggered a skill. Populated by prompt-log.t
77
96
 
78
97
  ---
79
98
 
99
+ ## ~/.claude/canonical_telemetry_log.jsonl
100
+
101
+ Canonical append-only event stream. This is the normalization boundary for local
102
+ and cloud ingestion. Raw legacy logs remain unchanged; canonical events are
103
+ written separately. Parse it as JSONL: UTF-8 text, one canonical JSON object
104
+ per line, newline-delimited, with parsers reading line-by-line and allowing a
105
+ final trailing newline.
106
+
107
+ Observed record kinds:
108
+
109
+ - `session`
110
+ - `prompt`
111
+ - `skill_invocation`
112
+ - `execution_fact`
113
+ - `normalization_run` (reserved for future normalization job summaries)
114
+
115
+ Example prompt record:
116
+
117
+ ```json
118
+ {
119
+ "record_kind": "prompt",
120
+ "schema_version": "2.0",
121
+ "normalizer_version": "1.0.0",
122
+ "normalized_at": "2026-03-10T10:00:00.000Z",
123
+ "platform": "claude_code",
124
+ "capture_mode": "hook",
125
+ "source_session_kind": "interactive",
126
+ "session_id": "abc123",
127
+ "raw_source_ref": {
128
+ "event_type": "UserPromptSubmit"
129
+ },
130
+ "prompt_id": "abc123:p0",
131
+ "occurred_at": "2026-03-10T10:00:00.000Z",
132
+ "prompt_text": "Make me a slide deck for the board meeting",
133
+ "prompt_hash": "4d6c5c0b1a2f7a40",
134
+ "prompt_kind": "user",
135
+ "is_actionable": true,
136
+ "prompt_index": 0
137
+ }
138
+ ```
139
+
140
+ Example skill invocation record:
141
+
142
+ ```json
143
+ {
144
+ "record_kind": "skill_invocation",
145
+ "schema_version": "2.0",
146
+ "normalizer_version": "1.0.0",
147
+ "normalized_at": "2026-03-10T10:00:05.000Z",
148
+ "platform": "claude_code",
149
+ "capture_mode": "hook",
150
+ "source_session_kind": "interactive",
151
+ "session_id": "abc123",
152
+ "raw_source_ref": {
153
+ "path": "/home/user/.claude/projects/.../abc123.jsonl",
154
+ "event_type": "PostToolUse"
155
+ },
156
+ "skill_invocation_id": "abc123:s:pptx:0",
157
+ "occurred_at": "2026-03-10T10:00:05.000Z",
158
+ "matched_prompt_id": "abc123:p0",
159
+ "skill_name": "pptx",
160
+ "skill_path": "/mnt/skills/public/pptx/SKILL.md",
161
+ "invocation_mode": "explicit",
162
+ "triggered": true,
163
+ "confidence": 1
164
+ }
165
+ ```
166
+
167
+ Run `selftune export-canonical --out ~/.claude/canonical_telemetry_log.jsonl`
168
+ to write a canonical JSONL telemetry export ready for downstream cloud
169
+ ingestion.
170
+
171
+ ---
172
+
173
+ ## ~/.selftune/canonical-session-state-<session>.json
174
+
175
+ Per-session helper state used only to preserve deterministic canonical prompt IDs
176
+ for live Claude hooks. `<session>` is the `session_id` with every character
177
+ outside `[A-Za-z0-9_-]` replaced by `_`, so `user:abc/123` becomes
178
+ `canonical-session-state-user_abc_123.json`.
179
+
180
+ ```json
181
+ {
182
+ "session_id": "abc123",
183
+ "next_prompt_index": 2,
184
+ "last_prompt_id": "abc123:p1",
185
+ "last_actionable_prompt_id": "abc123:p1",
186
+ "updated_at": "2026-03-10T10:00:05.000Z"
187
+ }
188
+ ```
189
+
190
+ This is operational state, not an analytics source of truth.
191
+
192
+ ---
193
+
194
+ ## ~/.claude/improvement_signals.jsonl
195
+
196
+ One record per detected improvement signal. Written by `prompt-log.ts` when a
197
+ user correction or explicit skill request is detected. Read by the orchestrator
198
+ for signal-aware candidate selection, and by `session-stop.ts` to decide whether
199
+ to spawn a reactive orchestrate run.
200
+
201
+ ```json
202
+ {
203
+ "timestamp": "2026-03-15T14:00:00.000Z",
204
+ "session_id": "abc123",
205
+ "query": "why didn't you use the commit skill?",
206
+ "signal_type": "correction",
207
+ "mentioned_skill": "commit",
208
+ "consumed": false
209
+ }
210
+ ```
211
+
212
+ Signal records are append-only. When an orchestrate run processes a signal,
213
+ the original record remains unchanged and the orchestrator rewrites the file
214
+ with `consumed: true` set on processed entries. This is the one exception
215
+ to strict append-only semantics in the log system — the rewrite is atomic
216
+ and race-protected by the orchestrate lockfile.
217
+
218
+ Consumed signal example:
219
+
220
+ ```json
221
+ {
222
+ "timestamp": "2026-03-15T14:00:00.000Z",
223
+ "session_id": "abc123",
224
+ "query": "why didn't you use the commit skill?",
225
+ "signal_type": "correction",
226
+ "mentioned_skill": "commit",
227
+ "consumed": true,
228
+ "consumed_at": "2026-03-15T14:05:00.000Z",
229
+ "consumed_by_run": "run_1710511500000_a1b2c3"
230
+ }
231
+ ```
232
+
233
+ **signal_type values:**
234
+ - `correction` — User pointing out a missed skill ("why didn't you use X?", "you should have used X", "next time use X")
235
+ - `explicit_request` — User asking to use a skill ("please use the X skill", "use the commit skill")
236
+ - `manual_invocation` — Direct `/skill` invocation detected
237
+
238
+ **Detection:** Pure regex in `prompt-log.ts`, no LLM calls. Skill names are matched against installed skills in `~/.claude/skills/`.
239
+
240
+ ---
241
+
80
242
  ## ~/.claude/evolution_audit_log.jsonl
81
243
 
82
244
  One record per evolution action. Written by the evolution and rollback modules.
@@ -0,0 +1,65 @@
1
+ # selftune Setup Patterns
2
+
3
+ This reference keeps the core initialize workflow portable. Use it when the
4
+ user needs project-type-specific setup guidance after `selftune init`.
5
+
6
+ ## Single-Skill Project
7
+
8
+ Use when the workspace has one primary `SKILL.md`.
9
+
10
+ - Merge `assets/single-skill-settings.json` into `~/.claude/settings.json`
11
+ - Keep the bundled `./settings_snippet.json` from the skill root nearby as the
12
+ minimal hook reference
13
+ - Verify with `selftune doctor`
14
+
15
+ ## Multi-Skill Project
16
+
17
+ Use when the workspace has multiple `SKILL.md` files that coexist in one repo.
18
+
19
+ - Merge `assets/multi-skill-settings.json` into `~/.claude/settings.json`
20
+ - Copy `assets/activation-rules-default.json` to
21
+ `~/.selftune/activation-rules.json`
22
+ - Tune activation rules after `selftune doctor` reports healthy hooks
23
+ - Use `selftune workflows` once telemetry accumulates to discover repeated
24
+ multi-skill chains
25
+
26
+ ## Monorepo
27
+
28
+ Use the same template as a multi-skill project, but run `selftune init` from
29
+ the repo root so hook paths and telemetry cover the whole workspace.
30
+
31
+ ## Codex-Only
32
+
33
+ - Install the CLI and run `selftune init --agent codex`
34
+ - Use `selftune ingest wrap-codex -- <args>` for real-time capture or
35
+ `selftune ingest codex` for batch ingestion
36
+ - Use `selftune doctor` to verify the shared logs are healthy
37
+
38
+ ## OpenCode-Only
39
+
40
+ - Run `selftune init --agent opencode`
41
+ - Use `selftune ingest opencode` to backfill session data into the shared logs
42
+
43
+ ## OpenClaw-Only
44
+
45
+ - Run `selftune init --agent openclaw`
46
+ - Use `selftune ingest openclaw` for ingestion
47
+ - Use `selftune doctor` to verify the shared logs are healthy
48
+ - Use `selftune cron setup` if the user specifically wants OpenClaw-managed recurring runs
49
+
50
+ ## Mixed-Agent Setup
51
+
52
+ Use when telemetry from Claude Code, Codex, OpenCode, or OpenClaw should be
53
+ combined.
54
+
55
+ - Initialize each platform against the same `~/.selftune/` data directory
56
+ - Ingest platform-specific logs into the shared JSONL schema
57
+ - Use `selftune schedule --install` for the default autonomous scheduler path
58
+ - Use `selftune status`, `selftune dashboard`, and `selftune workflows` on the
59
+ merged dataset
60
+
61
+ ## Optional Repository Extensions
62
+
63
+ Some repositories also bundle Claude-specific helper agents in `.claude/agents/`
64
+ for diagnosis, evolution review, or setup help. These are optional extensions,
65
+ not part of the core skill package installed by `npx skills add`.
@@ -0,0 +1,40 @@
1
+ # selftune Skill Version History
2
+
3
+ This file is maintainer-facing. Keep operational instructions in
4
+ `../SKILL.md`; record version history here so the main skill stays focused on
5
+ agent execution.
6
+
7
+ ## Versioning Rules
8
+
9
+ - Bump the version when command coverage, routing, or user-facing workflow
10
+ guidance changes in a meaningful way.
11
+ - Update the `metadata.version` and `metadata.last_updated` fields in
12
+ `../SKILL.md` at the same time.
13
+ - Record a short, high-signal summary here. Avoid duplicating the full skill
14
+ body.
15
+
16
+ ## Change Log
17
+
18
+ ### 0.2.2 — 2026-03-09
19
+
20
+ - Tightened the top-level skill description and added an explicit
21
+ `compatibility` field
22
+ - Surfaced the bundled badge workflow in quick reference, routing, and resource
23
+ index sections
24
+ - Moved setup-pattern guidance fully inside the skill package via
25
+ `references/setup-patterns.md`
26
+ - Bundled Claude settings and activation-rule templates under `assets/` so the
27
+ installed skill no longer depends on repository-level `templates/`
28
+ - Marked Claude-specific specialist agents as optional repository extensions
29
+ rather than part of the core installed skill
30
+
31
+ ### 0.2.1 — 2026-03-09
32
+
33
+ - Added first-class routing and quick-reference coverage for
34
+ `selftune workflows`
35
+ - Added a dedicated `Workflows/Workflows.md` guide for workflow discovery and
36
+ codification
37
+ - Updated composability guidance to reflect synergy, conflicts, and workflow
38
+ candidates
39
+ - Synced workflow save documentation with the shipped
40
+ `<workflow-id|index>` behavior
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "_readme": "Merge the 'hooks' block below into your ~/.claude/settings.json",
3
3
  "_readme2": "Replace /PATH/TO/ with the actual directory where you saved the scripts",
4
+ "_readme3": "This is the comprehensive template. Portable single-skill and multi-skill variants are bundled in assets/",
4
5
 
5
6
  "hooks": {
6
7
  "UserPromptSubmit": [
@@ -10,6 +11,28 @@
10
11
  "type": "command",
11
12
  "command": "bun run /PATH/TO/cli/selftune/hooks/prompt-log.ts",
12
13
  "timeout": 5
14
+ },
15
+ {
16
+ "type": "command",
17
+ "command": "bun run /PATH/TO/cli/selftune/hooks/auto-activate.ts",
18
+ "timeout": 5
19
+ }
20
+ ]
21
+ }
22
+ ],
23
+ "PreToolUse": [
24
+ {
25
+ "matcher": "Write|Edit",
26
+ "hooks": [
27
+ {
28
+ "type": "command",
29
+ "command": "bun run /PATH/TO/cli/selftune/hooks/skill-change-guard.ts",
30
+ "timeout": 5
31
+ },
32
+ {
33
+ "type": "command",
34
+ "command": "bun run /PATH/TO/cli/selftune/hooks/evolution-guard.ts",
35
+ "timeout": 5
13
36
  }
14
37
  ]
15
38
  }
@@ -0,0 +1,27 @@
1
+ {
2
+ "_readme": "Default activation rules for selftune auto-activation. Copy to ~/.selftune/activation-rules.json to customize.",
3
+ "_docs": "See docs/integration-guide.md for details on each rule.",
4
+
5
+ "rules": [
6
+ {
7
+ "id": "post-session-diagnostic",
8
+ "enabled": true,
9
+ "description": "Suggest `selftune last` when session has >2 unmatched queries"
10
+ },
11
+ {
12
+ "id": "grading-threshold-breach",
13
+ "enabled": true,
14
+ "description": "Suggest `selftune evolve` when session pass rate < 60%"
15
+ },
16
+ {
17
+ "id": "stale-evolution",
18
+ "enabled": true,
19
+ "description": "Suggest `selftune evolve` when no evolution in >7 days and pending false negatives exist"
20
+ },
21
+ {
22
+ "id": "regression-detected",
23
+ "enabled": true,
24
+ "description": "Suggest `selftune rollback` when monitoring detects a regression"
25
+ }
26
+ ]
27
+ }
@@ -0,0 +1,64 @@
1
+ {
2
+ "_readme": "Settings template for multi-skill selftune projects. Merge into ~/.claude/settings.json.",
3
+ "_usage": "These hooks use npx selftune, which works regardless of installation path.",
4
+ "_note": "Multi-skill projects use activation rules to route queries to the correct skill. See templates/activation-rules-default.json.",
5
+
6
+ "hooks": {
7
+ "UserPromptSubmit": [
8
+ {
9
+ "hooks": [
10
+ {
11
+ "type": "command",
12
+ "command": "npx selftune hook prompt-log",
13
+ "timeout": 5
14
+ },
15
+ {
16
+ "type": "command",
17
+ "command": "npx selftune hook auto-activate",
18
+ "timeout": 5
19
+ }
20
+ ]
21
+ }
22
+ ],
23
+ "PreToolUse": [
24
+ {
25
+ "matcher": "Write|Edit",
26
+ "hooks": [
27
+ {
28
+ "type": "command",
29
+ "command": "npx selftune hook skill-change-guard",
30
+ "timeout": 5
31
+ },
32
+ {
33
+ "type": "command",
34
+ "command": "npx selftune hook evolution-guard",
35
+ "timeout": 5
36
+ }
37
+ ]
38
+ }
39
+ ],
40
+ "PostToolUse": [
41
+ {
42
+ "matcher": "Read",
43
+ "hooks": [
44
+ {
45
+ "type": "command",
46
+ "command": "npx selftune hook skill-eval",
47
+ "timeout": 5
48
+ }
49
+ ]
50
+ }
51
+ ],
52
+ "Stop": [
53
+ {
54
+ "hooks": [
55
+ {
56
+ "type": "command",
57
+ "command": "npx selftune hook session-stop",
58
+ "timeout": 15
59
+ }
60
+ ]
61
+ }
62
+ ]
63
+ }
64
+ }
@@ -0,0 +1,58 @@
1
+ {
2
+ "_readme": "Settings template for single-skill selftune projects. Merge into ~/.claude/settings.json.",
3
+ "_usage": "These hooks use npx selftune, which works regardless of installation path.",
4
+
5
+ "hooks": {
6
+ "UserPromptSubmit": [
7
+ {
8
+ "hooks": [
9
+ {
10
+ "type": "command",
11
+ "command": "npx selftune hook prompt-log",
12
+ "timeout": 5
13
+ },
14
+ {
15
+ "type": "command",
16
+ "command": "npx selftune hook auto-activate",
17
+ "timeout": 5
18
+ }
19
+ ]
20
+ }
21
+ ],
22
+ "PreToolUse": [
23
+ {
24
+ "matcher": "Write|Edit",
25
+ "hooks": [
26
+ {
27
+ "type": "command",
28
+ "command": "npx selftune hook skill-change-guard",
29
+ "timeout": 5
30
+ }
31
+ ]
32
+ }
33
+ ],
34
+ "PostToolUse": [
35
+ {
36
+ "matcher": "Read",
37
+ "hooks": [
38
+ {
39
+ "type": "command",
40
+ "command": "npx selftune hook skill-eval",
41
+ "timeout": 5
42
+ }
43
+ ]
44
+ }
45
+ ],
46
+ "Stop": [
47
+ {
48
+ "hooks": [
49
+ {
50
+ "type": "command",
51
+ "command": "npx selftune hook session-stop",
52
+ "timeout": 15
53
+ }
54
+ ]
55
+ }
56
+ ]
57
+ }
58
+ }