selftune 0.2.9 → 0.2.12
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.
- package/README.md +35 -35
- package/apps/local-dashboard/dist/assets/index-4_dAY17K.js +16 -0
- package/apps/local-dashboard/dist/assets/index-BxV5WZHc.css +2 -0
- package/apps/local-dashboard/dist/assets/rolldown-runtime-Dw2cE7zH.js +1 -0
- package/apps/local-dashboard/dist/assets/vendor-react-CKkiCskZ.js +11 -0
- package/apps/local-dashboard/dist/assets/vendor-table-pHbDxq36.js +8 -0
- package/apps/local-dashboard/dist/assets/vendor-ui-7xD7fNEU.js +12 -0
- package/apps/local-dashboard/dist/index.html +16 -15
- package/bin/selftune.cjs +1 -1
- package/cli/selftune/activation-rules.ts +1 -0
- package/cli/selftune/alpha-upload/build-payloads.ts +18 -2
- package/cli/selftune/alpha-upload/stage-canonical.ts +94 -0
- package/cli/selftune/auth/device-code.ts +32 -0
- package/cli/selftune/auto-update.ts +12 -0
- package/cli/selftune/badge/badge.ts +1 -0
- package/cli/selftune/canonical-export.ts +5 -0
- package/cli/selftune/claude-agents.ts +154 -0
- package/cli/selftune/contribute/bundle.ts +1 -0
- package/cli/selftune/contribute/contribute.ts +1 -0
- package/cli/selftune/cron/setup.ts +2 -2
- package/cli/selftune/dashboard-server.ts +1 -0
- package/cli/selftune/eval/hooks-to-evals.ts +1 -0
- package/cli/selftune/eval/import-skillsbench.ts +1 -0
- package/cli/selftune/eval/synthetic-evals.ts +2 -3
- package/cli/selftune/eval/unit-test.ts +1 -0
- package/cli/selftune/evolution/deploy-proposal.ts +9 -238
- package/cli/selftune/evolution/evolve-body.ts +93 -6
- package/cli/selftune/evolution/evolve.ts +3 -7
- package/cli/selftune/evolution/propose-body.ts +3 -2
- package/cli/selftune/evolution/propose-routing.ts +3 -2
- package/cli/selftune/evolution/refine-body.ts +3 -2
- package/cli/selftune/evolution/rollback.ts +1 -1
- package/cli/selftune/export.ts +1 -0
- package/cli/selftune/grading/grade-session.ts +8 -0
- package/cli/selftune/hooks/auto-activate.ts +1 -0
- package/cli/selftune/hooks/evolution-guard.ts +1 -1
- package/cli/selftune/hooks/prompt-log.ts +1 -0
- package/cli/selftune/hooks/session-stop.ts +34 -40
- package/cli/selftune/hooks/skill-change-guard.ts +1 -0
- package/cli/selftune/hooks/skill-eval.ts +1 -1
- package/cli/selftune/index.ts +23 -14
- package/cli/selftune/ingestors/claude-replay.ts +1 -0
- package/cli/selftune/ingestors/codex-rollout.ts +1 -0
- package/cli/selftune/ingestors/codex-wrapper.ts +1 -0
- package/cli/selftune/ingestors/openclaw-ingest.ts +1 -0
- package/cli/selftune/ingestors/opencode-ingest.ts +1 -0
- package/cli/selftune/init.ts +121 -29
- package/cli/selftune/localdb/db.ts +1 -0
- package/cli/selftune/localdb/direct-write.ts +39 -0
- package/cli/selftune/localdb/materialize.ts +2 -0
- package/cli/selftune/localdb/queries.ts +53 -0
- package/cli/selftune/localdb/schema.ts +28 -0
- package/cli/selftune/normalization.ts +1 -0
- package/cli/selftune/observability.ts +1 -0
- package/cli/selftune/repair/skill-usage.ts +1 -0
- package/cli/selftune/routes/orchestrate-runs.ts +1 -0
- package/cli/selftune/routes/overview.ts +1 -0
- package/cli/selftune/routes/report.ts +1 -1
- package/cli/selftune/routes/skill-report.ts +2 -1
- package/cli/selftune/status.ts +1 -1
- package/cli/selftune/sync.ts +30 -1
- package/cli/selftune/uninstall.ts +412 -0
- package/cli/selftune/utils/canonical-log.ts +2 -0
- package/cli/selftune/utils/frontmatter.ts +50 -7
- package/cli/selftune/utils/jsonl.ts +1 -0
- package/cli/selftune/utils/llm-call.ts +131 -3
- package/cli/selftune/utils/skill-log.ts +1 -0
- package/cli/selftune/utils/transcript.ts +1 -0
- package/cli/selftune/utils/trigger-check.ts +1 -1
- package/cli/selftune/workflows/skill-md-writer.ts +5 -5
- package/cli/selftune/workflows/workflows.ts +1 -0
- package/package.json +37 -33
- package/packages/telemetry-contract/fixtures/golden.test.ts +1 -0
- package/packages/telemetry-contract/package.json +1 -1
- package/packages/telemetry-contract/src/schemas.ts +1 -0
- package/packages/telemetry-contract/tests/compatibility.test.ts +1 -0
- package/packages/ui/README.md +35 -34
- package/packages/ui/package.json +3 -3
- package/packages/ui/src/components/ActivityTimeline.tsx +50 -43
- package/packages/ui/src/components/EvidenceViewer.tsx +306 -182
- package/packages/ui/src/components/EvolutionTimeline.tsx +83 -72
- package/packages/ui/src/components/InfoTip.tsx +4 -3
- package/packages/ui/src/components/OrchestrateRunsPanel.tsx +60 -53
- package/packages/ui/src/components/section-cards.tsx +20 -25
- package/packages/ui/src/components/skill-health-grid.tsx +213 -193
- package/packages/ui/src/lib/constants.tsx +1 -0
- package/packages/ui/src/primitives/badge.tsx +12 -15
- package/packages/ui/src/primitives/button.tsx +7 -7
- package/packages/ui/src/primitives/card.tsx +15 -26
- package/packages/ui/src/primitives/checkbox.tsx +7 -8
- package/packages/ui/src/primitives/collapsible.tsx +5 -5
- package/packages/ui/src/primitives/dropdown-menu.tsx +45 -55
- package/packages/ui/src/primitives/label.tsx +6 -6
- package/packages/ui/src/primitives/select.tsx +28 -37
- package/packages/ui/src/primitives/table.tsx +17 -44
- package/packages/ui/src/primitives/tabs.tsx +14 -21
- package/packages/ui/src/primitives/tooltip.tsx +10 -22
- package/skill/SKILL.md +70 -57
- package/skill/Workflows/AlphaUpload.md +4 -4
- package/skill/Workflows/AutoActivation.md +11 -6
- package/skill/Workflows/Badge.md +22 -16
- package/skill/Workflows/Baseline.md +34 -36
- package/skill/Workflows/Composability.md +16 -11
- package/skill/Workflows/Contribute.md +26 -21
- package/skill/Workflows/Cron.md +23 -22
- package/skill/Workflows/Dashboard.md +32 -27
- package/skill/Workflows/Doctor.md +33 -27
- package/skill/Workflows/Evals.md +48 -47
- package/skill/Workflows/EvolutionMemory.md +31 -21
- package/skill/Workflows/Evolve.md +84 -82
- package/skill/Workflows/EvolveBody.md +58 -47
- package/skill/Workflows/Grade.md +16 -13
- package/skill/Workflows/ImportSkillsBench.md +9 -6
- package/skill/Workflows/Ingest.md +36 -21
- package/skill/Workflows/Initialize.md +108 -40
- package/skill/Workflows/Orchestrate.md +22 -16
- package/skill/Workflows/Replay.md +12 -7
- package/skill/Workflows/Rollback.md +13 -6
- package/skill/Workflows/Schedule.md +6 -6
- package/skill/Workflows/Sync.md +18 -11
- package/skill/Workflows/UnitTest.md +28 -17
- package/skill/Workflows/Watch.md +28 -21
- package/skill/agents/diagnosis-analyst.md +11 -0
- package/skill/agents/evolution-reviewer.md +15 -1
- package/skill/agents/integration-guide.md +10 -0
- package/skill/agents/pattern-analyst.md +12 -1
- package/skill/references/grading-methodology.md +23 -24
- package/skill/references/interactive-config.md +7 -7
- package/skill/references/invocation-taxonomy.md +22 -20
- package/skill/references/logs.md +14 -6
- package/skill/references/setup-patterns.md +4 -2
- package/.claude/agents/diagnosis-analyst.md +0 -156
- package/.claude/agents/evolution-reviewer.md +0 -180
- package/.claude/agents/integration-guide.md +0 -212
- package/.claude/agents/pattern-analyst.md +0 -160
- package/apps/local-dashboard/dist/assets/index-Bs3Y4ixf.css +0 -1
- package/apps/local-dashboard/dist/assets/index-C4UYGWKr.js +0 -15
- package/apps/local-dashboard/dist/assets/vendor-react-BQH_6WrG.js +0 -60
- package/apps/local-dashboard/dist/assets/vendor-table-dK1QMLq9.js +0 -26
- package/apps/local-dashboard/dist/assets/vendor-ui-CO2mrx6e.js +0 -341
|
@@ -8,13 +8,13 @@ Covers five sub-commands: `ingest claude`, `ingest codex`, `ingest opencode`,
|
|
|
8
8
|
|
|
9
9
|
## When to Use Each
|
|
10
10
|
|
|
11
|
-
| Sub-command
|
|
12
|
-
|
|
13
|
-
| `ingest claude`
|
|
14
|
-
| `ingest codex`
|
|
15
|
-
| `ingest opencode`
|
|
16
|
-
| `ingest openclaw`
|
|
17
|
-
| `ingest wrap-codex` | Codex
|
|
11
|
+
| Sub-command | Platform | Mode | When |
|
|
12
|
+
| ------------------- | ----------- | --------- | --------------------------------------------------- |
|
|
13
|
+
| `ingest claude` | Claude Code | Batch | Backfill logs from existing Claude Code transcripts |
|
|
14
|
+
| `ingest codex` | Codex | Batch | Import existing Codex rollout logs |
|
|
15
|
+
| `ingest opencode` | OpenCode | Batch | Import existing OpenCode sessions |
|
|
16
|
+
| `ingest openclaw` | OpenClaw | Batch | Import existing OpenClaw agent sessions |
|
|
17
|
+
| `ingest wrap-codex` | Codex | Real-time | Wrap `codex exec` to capture telemetry live |
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
@@ -30,13 +30,13 @@ selftune ingest claude
|
|
|
30
30
|
|
|
31
31
|
### Options
|
|
32
32
|
|
|
33
|
-
| Flag
|
|
34
|
-
|
|
35
|
-
| `--since <date>`
|
|
36
|
-
| `--dry-run`
|
|
37
|
-
| `--force`
|
|
38
|
-
| `--verbose`
|
|
39
|
-
| `--projects-dir <path>` | Override default `~/.claude/projects/` directory
|
|
33
|
+
| Flag | Description |
|
|
34
|
+
| ----------------------- | ------------------------------------------------------------------ |
|
|
35
|
+
| `--since <date>` | Only ingest sessions modified after this date (e.g., `2026-01-01`) |
|
|
36
|
+
| `--dry-run` | Show what would be ingested without writing to logs |
|
|
37
|
+
| `--force` | Re-ingest all sessions, ignoring the marker file |
|
|
38
|
+
| `--verbose` | Show per-file progress during ingestion |
|
|
39
|
+
| `--projects-dir <path>` | Override default `~/.claude/projects/` directory |
|
|
40
40
|
|
|
41
41
|
### Source
|
|
42
42
|
|
|
@@ -46,6 +46,7 @@ transcript files Claude Code automatically saves for every session.
|
|
|
46
46
|
### Output
|
|
47
47
|
|
|
48
48
|
Writes to:
|
|
49
|
+
|
|
49
50
|
- `~/.claude/all_queries_log.jsonl` -- extracted user queries (one per query, not just last)
|
|
50
51
|
- `~/.claude/session_telemetry_log.jsonl` -- per-session metrics with `source: "claude_code_replay"`
|
|
51
52
|
- `~/.claude/skill_usage_log.jsonl` -- skill triggers with `source: "claude_code_replay"`
|
|
@@ -88,6 +89,7 @@ JSONL format. See `references/logs.md` for the Codex rollout format.
|
|
|
88
89
|
### Output
|
|
89
90
|
|
|
90
91
|
Writes to:
|
|
92
|
+
|
|
91
93
|
- `~/.claude/all_queries_log.jsonl` -- extracted user queries
|
|
92
94
|
- `~/.claude/session_telemetry_log.jsonl` -- per-session metrics with `source: "codex_rollout"`
|
|
93
95
|
|
|
@@ -124,6 +126,7 @@ See `references/logs.md` for the OpenCode message format.
|
|
|
124
126
|
### Output
|
|
125
127
|
|
|
126
128
|
Writes to:
|
|
129
|
+
|
|
127
130
|
- `~/.claude/all_queries_log.jsonl` -- extracted user queries
|
|
128
131
|
- `~/.claude/session_telemetry_log.jsonl` -- per-session metrics with `source: "opencode"` or `"opencode_json"`
|
|
129
132
|
|
|
@@ -149,23 +152,25 @@ selftune ingest openclaw
|
|
|
149
152
|
|
|
150
153
|
### Options
|
|
151
154
|
|
|
152
|
-
| Flag
|
|
153
|
-
|
|
154
|
-
| `--agents-dir <path>` | Override default `~/.openclaw/agents/` directory
|
|
155
|
-
| `--since <date>`
|
|
156
|
-
| `--dry-run`
|
|
157
|
-
| `--force`
|
|
158
|
-
| `--verbose` / `-v`
|
|
155
|
+
| Flag | Description |
|
|
156
|
+
| --------------------- | ------------------------------------------------------------------ |
|
|
157
|
+
| `--agents-dir <path>` | Override default `~/.openclaw/agents/` directory |
|
|
158
|
+
| `--since <date>` | Only ingest sessions modified after this date (e.g., `2026-01-01`) |
|
|
159
|
+
| `--dry-run` | Show what would be ingested without writing to logs |
|
|
160
|
+
| `--force` | Re-ingest all sessions, ignoring the marker file |
|
|
161
|
+
| `--verbose` / `-v` | Show per-session progress during ingestion |
|
|
159
162
|
|
|
160
163
|
### Source
|
|
161
164
|
|
|
162
165
|
Reads from `~/.openclaw/agents/<agentId>/sessions/*.jsonl`. Each JSONL file contains:
|
|
166
|
+
|
|
163
167
|
- Line 1 (session header): `{"type":"session","version":5,"id":"<uuid>","timestamp":"<iso>","cwd":"<path>"}`
|
|
164
168
|
- Line 2+ (messages): `{"role":"user|assistant|toolResult","content":[...],"timestamp":<ms>}`
|
|
165
169
|
|
|
166
170
|
### Output
|
|
167
171
|
|
|
168
172
|
Writes to:
|
|
173
|
+
|
|
169
174
|
- `~/.claude/all_queries_log.jsonl` -- extracted user queries
|
|
170
175
|
- `~/.claude/session_telemetry_log.jsonl` -- per-session metrics with `source: "openclaw"`
|
|
171
176
|
- `~/.claude/skill_usage_log.jsonl` -- skill triggers with `source: "openclaw"`
|
|
@@ -210,6 +215,7 @@ selftune ingest wrap-codex -- --model o3 "Fix the failing tests"
|
|
|
210
215
|
### Output
|
|
211
216
|
|
|
212
217
|
Writes to:
|
|
218
|
+
|
|
213
219
|
- `~/.claude/all_queries_log.jsonl` -- the user query
|
|
214
220
|
- `~/.claude/session_telemetry_log.jsonl` -- session metrics with `source: "codex"`
|
|
215
221
|
|
|
@@ -233,30 +239,39 @@ through hooks.
|
|
|
233
239
|
## Common Patterns
|
|
234
240
|
|
|
235
241
|
**"Backfill Claude Code sessions"**
|
|
242
|
+
|
|
236
243
|
> Run `selftune ingest claude`. No options needed. Reads from `~/.claude/projects/`.
|
|
237
244
|
|
|
238
245
|
**"Replay only recent Claude Code sessions"**
|
|
246
|
+
|
|
239
247
|
> Run `selftune ingest claude --since 2026-02-01` with an appropriate date.
|
|
240
248
|
|
|
241
249
|
**"Ingest codex logs"**
|
|
250
|
+
|
|
242
251
|
> Run `selftune ingest codex`. No options needed. Reads from `$CODEX_HOME/sessions/`.
|
|
243
252
|
|
|
244
253
|
**"Import opencode sessions"**
|
|
254
|
+
|
|
245
255
|
> Run `selftune ingest opencode`. Reads from the SQLite database automatically.
|
|
246
256
|
|
|
247
257
|
**"Ingest OpenClaw sessions"**
|
|
258
|
+
|
|
248
259
|
> Run `selftune ingest openclaw`. Reads from `~/.openclaw/agents/` automatically.
|
|
249
260
|
|
|
250
261
|
**"Import only recent OpenClaw sessions"**
|
|
262
|
+
|
|
251
263
|
> Run `selftune ingest openclaw --since 2026-02-01` with an appropriate date.
|
|
252
264
|
|
|
253
265
|
**"Run codex through selftune"**
|
|
266
|
+
|
|
254
267
|
> Use `selftune ingest wrap-codex -- <codex args>` instead of `codex exec <args>` directly.
|
|
255
268
|
|
|
256
269
|
**"Batch ingest vs real-time"**
|
|
270
|
+
|
|
257
271
|
> Use `selftune ingest codex` or `selftune ingest opencode` for historical sessions.
|
|
258
272
|
> Use `selftune ingest wrap-codex` for ongoing sessions. Both produce the same log format.
|
|
259
273
|
|
|
260
274
|
**"How do I know it worked?"**
|
|
275
|
+
|
|
261
276
|
> Run `selftune doctor` after ingestion. Check that log files exist and are parseable.
|
|
262
277
|
> Run `selftune eval generate --list-skills` to see if the ingested sessions appear.
|
|
@@ -18,17 +18,19 @@ selftune init --no-alpha [--force]
|
|
|
18
18
|
|
|
19
19
|
## Options
|
|
20
20
|
|
|
21
|
-
| Flag
|
|
22
|
-
|
|
23
|
-
| `--agent <type>`
|
|
24
|
-
| `--cli-path <path>`
|
|
25
|
-
| `--force`
|
|
26
|
-
| `--
|
|
27
|
-
| `--
|
|
28
|
-
| `--
|
|
29
|
-
| `--
|
|
30
|
-
| `--alpha
|
|
31
|
-
| `--alpha
|
|
21
|
+
| Flag | Description | Default |
|
|
22
|
+
| ------------------------- | ------------------------------------------------------------------------- | ------------- |
|
|
23
|
+
| `--agent <type>` | Agent platform: `claude_code`, `codex`, `opencode`, `openclaw` | Auto-detected |
|
|
24
|
+
| `--cli-path <path>` | Override auto-detected CLI entry-point path | Auto-detected |
|
|
25
|
+
| `--force` | Reinitialize even if config already exists | Off |
|
|
26
|
+
| `--no-sync` | Skip historical transcript backfill during init | Sync on |
|
|
27
|
+
| `--no-autonomy` | Skip autonomous scheduling setup during init | Autonomy on |
|
|
28
|
+
| `--enable-autonomy` | (Deprecated alias) Enable autonomous scheduling — now on by default | On |
|
|
29
|
+
| `--schedule-format <fmt>` | Schedule format: `cron`, `launchd`, `systemd` | Auto-detected |
|
|
30
|
+
| `--alpha` | Enroll in the selftune alpha program (opens browser for device-code auth) | Off |
|
|
31
|
+
| `--no-alpha` | Unenroll from the alpha program (preserves user_id) | Off |
|
|
32
|
+
| `--alpha-email <email>` | Email for alpha enrollment (required with `--alpha`) | - |
|
|
33
|
+
| `--alpha-name <name>` | Display name for alpha enrollment | - |
|
|
32
34
|
|
|
33
35
|
## Output Format
|
|
34
36
|
|
|
@@ -57,23 +59,23 @@ Creates `~/.selftune/config.json`:
|
|
|
57
59
|
|
|
58
60
|
### Field Descriptions
|
|
59
61
|
|
|
60
|
-
| Field
|
|
61
|
-
|
|
62
|
-
| `agent_type`
|
|
63
|
-
| `cli_path`
|
|
64
|
-
| `llm_mode`
|
|
65
|
-
| `agent_cli`
|
|
66
|
-
| `hooks_installed`
|
|
67
|
-
| `initialized_at`
|
|
68
|
-
| `alpha`
|
|
69
|
-
| `alpha.enrolled`
|
|
70
|
-
| `alpha.user_id`
|
|
71
|
-
| `alpha.cloud_user_id`
|
|
72
|
-
| `alpha.cloud_org_id`
|
|
73
|
-
| `alpha.email`
|
|
74
|
-
| `alpha.display_name`
|
|
75
|
-
| `alpha.consent_timestamp` | string
|
|
76
|
-
| `alpha.api_key`
|
|
62
|
+
| Field | Type | Description |
|
|
63
|
+
| ------------------------- | ------- | ----------------------------------------------------------------- |
|
|
64
|
+
| `agent_type` | string | Detected or specified agent platform |
|
|
65
|
+
| `cli_path` | string | Absolute path to the CLI entry point |
|
|
66
|
+
| `llm_mode` | string | How LLM calls are made: `agent` or `api` |
|
|
67
|
+
| `agent_cli` | string | CLI binary name for the detected agent |
|
|
68
|
+
| `hooks_installed` | boolean | Whether telemetry hooks are installed |
|
|
69
|
+
| `initialized_at` | string | ISO 8601 timestamp |
|
|
70
|
+
| `alpha` | object? | Alpha program enrollment (present only if enrolled) |
|
|
71
|
+
| `alpha.enrolled` | boolean | Whether the user is currently enrolled |
|
|
72
|
+
| `alpha.user_id` | string | Stable UUID, generated once, preserved across reinits |
|
|
73
|
+
| `alpha.cloud_user_id` | string? | Cloud account UUID (set by device-code flow) |
|
|
74
|
+
| `alpha.cloud_org_id` | string? | Cloud organization UUID (set by device-code flow) |
|
|
75
|
+
| `alpha.email` | string? | Email provided at enrollment |
|
|
76
|
+
| `alpha.display_name` | string? | Optional display name |
|
|
77
|
+
| `alpha.consent_timestamp` | string | ISO 8601 timestamp of consent |
|
|
78
|
+
| `alpha.api_key` | string? | Upload credential (provisioned automatically by device-code flow) |
|
|
77
79
|
|
|
78
80
|
## Steps
|
|
79
81
|
|
|
@@ -117,22 +119,29 @@ The init output will report what was installed, e.g.:
|
|
|
117
119
|
[INFO] Installed 4 selftune hook(s) into ~/.claude/settings.json: UserPromptSubmit, PreToolUse, PostToolUse, Stop
|
|
118
120
|
```
|
|
119
121
|
|
|
122
|
+
For Claude Code, `selftune init` also syncs selftune's bundled specialized
|
|
123
|
+
agents from `skill/agents/` into `~/.claude/agents/`. The bundled files remain
|
|
124
|
+
the source of truth; the `~/.claude/agents/` copies exist only so native Claude
|
|
125
|
+
Code subagent calls stay up to date.
|
|
126
|
+
|
|
120
127
|
**Hook reference** (for troubleshooting):
|
|
121
128
|
|
|
122
|
-
| Hook
|
|
123
|
-
|
|
124
|
-
| `UserPromptSubmit`
|
|
125
|
-
| `UserPromptSubmit`
|
|
126
|
-
| `PreToolUse` (Write/Edit)
|
|
127
|
-
| `PreToolUse` (Write/Edit)
|
|
128
|
-
| `PostToolUse` (Read/Skill) | `hooks/skill-eval.ts`
|
|
129
|
-
| `Stop`
|
|
129
|
+
| Hook | Script | Purpose |
|
|
130
|
+
| -------------------------- | ----------------------------- | ----------------------------------------------- |
|
|
131
|
+
| `UserPromptSubmit` | `hooks/prompt-log.ts` | Log every user query |
|
|
132
|
+
| `UserPromptSubmit` | `hooks/auto-activate.ts` | Suggest skills before prompt processing |
|
|
133
|
+
| `PreToolUse` (Write/Edit) | `hooks/skill-change-guard.ts` | Detect uncontrolled skill edits |
|
|
134
|
+
| `PreToolUse` (Write/Edit) | `hooks/evolution-guard.ts` | Block SKILL.md edits on monitored skills |
|
|
135
|
+
| `PostToolUse` (Read/Skill) | `hooks/skill-eval.ts` | Track skill triggers and Skill tool invocations |
|
|
136
|
+
| `Stop` | `hooks/session-stop.ts` | Capture session telemetry |
|
|
130
137
|
|
|
131
138
|
**Codex agents:**
|
|
139
|
+
|
|
132
140
|
- Use `selftune ingest wrap-codex` for real-time telemetry capture (see `Workflows/Ingest.md`)
|
|
133
141
|
- Or batch-ingest existing sessions with `selftune ingest codex`
|
|
134
142
|
|
|
135
143
|
**OpenCode agents:**
|
|
144
|
+
|
|
136
145
|
- Use `selftune ingest opencode` to import sessions from the SQLite database
|
|
137
146
|
- See `Workflows/Ingest.md` for details
|
|
138
147
|
|
|
@@ -145,6 +154,7 @@ mkdir -p ~/.selftune/memory
|
|
|
145
154
|
```
|
|
146
155
|
|
|
147
156
|
The memory system stores three files at `~/.selftune/memory/`:
|
|
157
|
+
|
|
148
158
|
- `context.md` -- active evolution state and session context
|
|
149
159
|
- `decisions.md` -- evolution decisions and rollback history
|
|
150
160
|
- `plan.md` -- current priorities and evolution strategy
|
|
@@ -171,12 +181,61 @@ selftune doctor
|
|
|
171
181
|
Parse the JSON output. All checks should pass. If any fail, address the
|
|
172
182
|
reported issues before proceeding.
|
|
173
183
|
|
|
184
|
+
### 8. Sync Historical Transcripts
|
|
185
|
+
|
|
186
|
+
Init automatically runs `selftune sync` to backfill existing session
|
|
187
|
+
transcripts into the SQLite database. This replays Claude Code transcripts,
|
|
188
|
+
Codex rollouts, OpenCode sessions, and OpenClaw sessions so the eval set
|
|
189
|
+
and evolution pipeline have data to work with immediately.
|
|
190
|
+
|
|
191
|
+
The sync step is fail-open — if it encounters errors, init continues.
|
|
192
|
+
Skip with `--no-sync` if you only want hooks for forward-looking data.
|
|
193
|
+
|
|
194
|
+
### 9. Autonomy Scheduling
|
|
195
|
+
|
|
196
|
+
Init automatically installs OS-level scheduling (launchd on macOS, cron/systemd
|
|
197
|
+
on Linux) so `selftune orchestrate` runs in the background. This is equivalent
|
|
198
|
+
to running `selftune cron setup` manually.
|
|
199
|
+
|
|
200
|
+
Skip with `--no-autonomy` if you prefer manual orchestration only.
|
|
201
|
+
|
|
202
|
+
### 10. Offer Alpha Enrollment
|
|
203
|
+
|
|
204
|
+
After local setup passes, always offer alpha enrollment before ending the setup
|
|
205
|
+
workflow.
|
|
206
|
+
|
|
207
|
+
Use the `AskUserQuestion` tool to ask:
|
|
208
|
+
|
|
209
|
+
- `Would you like to enroll in the selftune alpha program for cloud-synced analytics?`
|
|
210
|
+
|
|
211
|
+
Options:
|
|
212
|
+
|
|
213
|
+
- `Yes — enable alpha uploads and richer cloud analytics`
|
|
214
|
+
- `No — keep local-only selftune`
|
|
215
|
+
|
|
216
|
+
If the user chooses yes, continue with the Alpha Enrollment steps below. If they
|
|
217
|
+
choose no, explicitly confirm that local-only setup is complete.
|
|
218
|
+
|
|
219
|
+
### 11. Initial Data Upload
|
|
220
|
+
|
|
221
|
+
After alpha enrollment succeeds and sync has backfilled historical data, init
|
|
222
|
+
automatically triggers an upload cycle to push data to the cloud immediately.
|
|
223
|
+
This ensures the cloud has data from the moment the user finishes setup — they
|
|
224
|
+
don't have to wait for the next scheduled orchestrate run.
|
|
225
|
+
|
|
226
|
+
The upload is fail-open — if it fails, init still completes successfully.
|
|
227
|
+
|
|
228
|
+
Additionally, every `selftune sync` run now triggers an upload cycle when alpha
|
|
229
|
+
is enrolled, so data flows to the cloud every 30 minutes (matching the sync
|
|
230
|
+
schedule) rather than waiting for the 2-hour orchestrate cycle.
|
|
231
|
+
|
|
174
232
|
## Integration Guide
|
|
175
233
|
|
|
176
234
|
For project-type-specific setup (single-skill, multi-skill, monorepo, Codex,
|
|
177
235
|
OpenCode, mixed agents), see [docs/integration-guide.md](../../docs/integration-guide.md).
|
|
178
236
|
|
|
179
237
|
Templates for each project type are bundled with the skill:
|
|
238
|
+
|
|
180
239
|
- `skill/settings_snippet.json` — hooks for Claude Code projects
|
|
181
240
|
- `assets/activation-rules-default.json` — default auto-activation rule configuration
|
|
182
241
|
|
|
@@ -193,7 +252,11 @@ workflow covers.
|
|
|
193
252
|
Enroll the user in the selftune alpha program for early access features.
|
|
194
253
|
|
|
195
254
|
Before running the alpha command:
|
|
196
|
-
|
|
255
|
+
|
|
256
|
+
1. Use `AskUserQuestion` to ask whether the user wants to opt into the selftune alpha data-sharing program
|
|
257
|
+
Options:
|
|
258
|
+
- `Yes — enable cloud-synced analytics and alpha uploads`
|
|
259
|
+
- `No — keep local-only selftune`
|
|
197
260
|
2. If they opt in, ask for their email and optional display name
|
|
198
261
|
3. If they decline, skip alpha enrollment and continue with plain `selftune init`
|
|
199
262
|
|
|
@@ -208,7 +271,7 @@ Enrollment uses a device-code flow — one command, one browser approval, fully
|
|
|
208
271
|
### Setup Sequence
|
|
209
272
|
|
|
210
273
|
1. **Check local config**: Run `selftune status` — look for the "Alpha Upload" section
|
|
211
|
-
2. **If not linked**:
|
|
274
|
+
2. **If not linked**: First use `AskUserQuestion` for the opt-in decision. Only if the user says yes, collect their email and run:
|
|
212
275
|
|
|
213
276
|
```bash
|
|
214
277
|
selftune init --alpha --alpha-email <user-email> --force
|
|
@@ -238,6 +301,7 @@ selftune init --alpha --alpha-email user@example.com --alpha-name "User Name" --
|
|
|
238
301
|
```
|
|
239
302
|
|
|
240
303
|
The `--alpha-email` flag is required. The command will:
|
|
304
|
+
|
|
241
305
|
1. Generate a stable UUID (preserved across reinits)
|
|
242
306
|
2. Request a device code from the cloud API
|
|
243
307
|
3. Open the browser to the verification URL
|
|
@@ -292,19 +356,23 @@ retrying with `selftune init --alpha --alpha-email <email> --force`.
|
|
|
292
356
|
## Common Patterns
|
|
293
357
|
|
|
294
358
|
**User asks to set up or initialize selftune**
|
|
359
|
+
|
|
295
360
|
> Run `which selftune` to check installation. If missing, install with
|
|
296
361
|
> `npm install -g selftune`. Run `selftune init`, then verify with
|
|
297
362
|
> `selftune doctor`. Report results to the user.
|
|
298
363
|
|
|
299
364
|
**User wants alpha enrollment**
|
|
300
|
-
|
|
301
|
-
>
|
|
365
|
+
|
|
366
|
+
> Use `AskUserQuestion` for the yes or no opt-in decision. If yes, collect email
|
|
367
|
+
> and optional display name in chat, then run `selftune init --alpha --alpha-email ...`.
|
|
302
368
|
> The browser opens automatically for approval. No manual key management needed.
|
|
303
369
|
|
|
304
370
|
**Hooks not capturing data**
|
|
371
|
+
|
|
305
372
|
> Run `selftune doctor` to check hook installation. Parse the JSON output
|
|
306
373
|
> for failed hook checks. If paths are wrong, update
|
|
307
374
|
> `~/.claude/settings.json` to point to actual files.
|
|
308
375
|
|
|
309
376
|
**Config exists but appears stale**
|
|
377
|
+
|
|
310
378
|
> Run `selftune init --force` to reinitialize. Verify with `selftune doctor`.
|
|
@@ -22,17 +22,17 @@ selftune orchestrate
|
|
|
22
22
|
|
|
23
23
|
## Flags
|
|
24
24
|
|
|
25
|
-
| Flag
|
|
26
|
-
|
|
27
|
-
| `--dry-run`
|
|
28
|
-
| `--review-required`
|
|
29
|
-
| `--auto-approve`
|
|
30
|
-
| `--skill <name>`
|
|
31
|
-
| `--max-skills <n>`
|
|
32
|
-
| `--recent-window <hours>`
|
|
33
|
-
| `--sync-force`
|
|
34
|
-
| `--loop`
|
|
35
|
-
| `--loop-interval <seconds>` | Pause between cycles (minimum 60)
|
|
25
|
+
| Flag | Description | Default |
|
|
26
|
+
| --------------------------- | ---------------------------------------------------------- | ---------- |
|
|
27
|
+
| `--dry-run` | Plan and validate without deploying changes | Off |
|
|
28
|
+
| `--review-required` | Keep validated changes in review mode instead of deploying | Off |
|
|
29
|
+
| `--auto-approve` | _(Deprecated)_ Autonomous mode is now the default | — |
|
|
30
|
+
| `--skill <name>` | Limit the loop to one skill | All skills |
|
|
31
|
+
| `--max-skills <n>` | Cap how many candidates are processed in one run | `5` |
|
|
32
|
+
| `--recent-window <hours>` | Window for post-deploy watch/rollback checks | `48` |
|
|
33
|
+
| `--sync-force` | Force a full source replay before candidate selection | Off |
|
|
34
|
+
| `--loop` | Run as a long-lived process that cycles continuously | Off |
|
|
35
|
+
| `--loop-interval <seconds>` | Pause between cycles (minimum 60) | `3600` |
|
|
36
36
|
|
|
37
37
|
## Default Behavior
|
|
38
38
|
|
|
@@ -46,22 +46,27 @@ Use `--review-required` only when you want a stricter policy for a specific run.
|
|
|
46
46
|
## Common Patterns
|
|
47
47
|
|
|
48
48
|
**User asks to improve skills or run the full loop**
|
|
49
|
+
|
|
49
50
|
> Run `selftune orchestrate`. Parse the JSON output from stdout and the
|
|
50
51
|
> phased report from stderr. Report the summary to the user.
|
|
51
52
|
|
|
52
53
|
**User wants to preview changes before deploying**
|
|
54
|
+
|
|
53
55
|
> Run `selftune orchestrate --dry-run`. Report the planned actions without
|
|
54
56
|
> making any changes.
|
|
55
57
|
|
|
56
58
|
**User wants to focus on a single skill**
|
|
59
|
+
|
|
57
60
|
> Run `selftune orchestrate --skill <name>`. This limits the loop to the
|
|
58
61
|
> specified skill only.
|
|
59
62
|
|
|
60
63
|
**User wants manual review before deployment**
|
|
64
|
+
|
|
61
65
|
> Run `selftune orchestrate --review-required`. Validated changes stay in
|
|
62
66
|
> review mode instead of auto-deploying.
|
|
63
67
|
|
|
64
68
|
**Agent needs fresh source data before orchestrating**
|
|
69
|
+
|
|
65
70
|
> Run `selftune orchestrate --sync-force`. This forces a full source replay
|
|
66
71
|
> before candidate selection.
|
|
67
72
|
|
|
@@ -94,11 +99,11 @@ This is the recommended runtime for recurring autonomous scheduling.
|
|
|
94
99
|
|
|
95
100
|
`selftune orchestrate` runs in two contexts with different callers:
|
|
96
101
|
|
|
97
|
-
| Context
|
|
98
|
-
|
|
99
|
-
| **Interactive**
|
|
100
|
-
| **Automated (cron)** | OS scheduler (cron/launchd/systemd)
|
|
101
|
-
| **Automated (loop)** | `selftune orchestrate --loop`
|
|
102
|
+
| Context | Caller | Token cost | When |
|
|
103
|
+
| -------------------- | ------------------------------------- | ----------------------------------------------------- | --------------------- |
|
|
104
|
+
| **Interactive** | Agent (user says "improve my skills") | Uses agent subscription | On demand |
|
|
105
|
+
| **Automated (cron)** | OS scheduler (cron/launchd/systemd) | No agent session; LLM cost only if evolution triggers | Every 6 hours |
|
|
106
|
+
| **Automated (loop)** | `selftune orchestrate --loop` | No agent session; LLM cost only if evolution triggers | Configurable interval |
|
|
102
107
|
|
|
103
108
|
In automated mode, the OS calls the CLI binary directly. No agent session
|
|
104
109
|
is created. LLM calls only happen during the evolution step (proposing and
|
|
@@ -123,6 +128,7 @@ reactive path complements the scheduled cron/loop modes by responding to signals
|
|
|
123
128
|
immediately after the session that produced them.
|
|
124
129
|
|
|
125
130
|
Guard rails:
|
|
131
|
+
|
|
126
132
|
- Only spawns if unconsumed signals exist in `improvement_signals.jsonl`
|
|
127
133
|
- Respects the orchestrate lock file — skips if another run started within 30 minutes
|
|
128
134
|
- Fire-and-forget: the hook exits immediately, orchestrate runs independently
|
|
@@ -27,13 +27,13 @@ selftune ingest claude
|
|
|
27
27
|
|
|
28
28
|
## Options
|
|
29
29
|
|
|
30
|
-
| Flag
|
|
31
|
-
|
|
32
|
-
| `--since <date>`
|
|
33
|
-
| `--dry-run`
|
|
34
|
-
| `--force`
|
|
35
|
-
| `--verbose`
|
|
36
|
-
| `--projects-dir <path>` | Override default `~/.claude/projects/` path
|
|
30
|
+
| Flag | Description |
|
|
31
|
+
| ----------------------- | ------------------------------------------------- |
|
|
32
|
+
| `--since <date>` | Only include transcripts modified after this date |
|
|
33
|
+
| `--dry-run` | Preview what would be ingested without writing |
|
|
34
|
+
| `--force` | Re-ingest all transcripts (ignore marker file) |
|
|
35
|
+
| `--verbose` | Show detailed progress per file |
|
|
36
|
+
| `--projects-dir <path>` | Override default `~/.claude/projects/` path |
|
|
37
37
|
|
|
38
38
|
## Source
|
|
39
39
|
|
|
@@ -43,6 +43,7 @@ Each transcript is a JSONL file containing user and assistant messages.
|
|
|
43
43
|
## Output
|
|
44
44
|
|
|
45
45
|
Writes to:
|
|
46
|
+
|
|
46
47
|
- `~/.claude/all_queries_log.jsonl` -- one record per user query (all messages, not just last)
|
|
47
48
|
- `~/.claude/session_telemetry_log.jsonl` -- per-session metrics with `source: "claude_code_replay"`
|
|
48
49
|
- `~/.claude/skill_usage_log.jsonl` -- skill triggers detected in transcripts
|
|
@@ -76,16 +77,20 @@ Report the number of sessions ingested and any skills discovered to the user.
|
|
|
76
77
|
## Common Patterns
|
|
77
78
|
|
|
78
79
|
**User wants to backfill logs from Claude Code history**
|
|
80
|
+
|
|
79
81
|
> Run `selftune ingest claude`. No options needed for a full backfill.
|
|
80
82
|
> Parse the output and report ingested session counts.
|
|
81
83
|
|
|
82
84
|
**User wants to ingest only recent sessions**
|
|
85
|
+
|
|
83
86
|
> Run `selftune ingest claude --since <date>` with the user's specified date.
|
|
84
87
|
|
|
85
88
|
**User wants to re-ingest everything from scratch**
|
|
89
|
+
|
|
86
90
|
> Run `selftune ingest claude --force`. This ignores the marker file and
|
|
87
91
|
> rescans all transcripts.
|
|
88
92
|
|
|
89
93
|
**Agent needs to verify ingestion succeeded**
|
|
94
|
+
|
|
90
95
|
> Run `selftune doctor` after ingestion. Parse the JSON output to check
|
|
91
96
|
> that log file entry counts increased.
|
|
@@ -11,11 +11,11 @@ selftune evolve rollback --skill <name> --skill-path <path> [options]
|
|
|
11
11
|
|
|
12
12
|
## Options
|
|
13
13
|
|
|
14
|
-
| Flag
|
|
15
|
-
|
|
16
|
-
| `--skill <name>`
|
|
17
|
-
| `--skill-path <path>` | Path to the skill's SKILL.md
|
|
18
|
-
| `--proposal-id <id>`
|
|
14
|
+
| Flag | Description | Default |
|
|
15
|
+
| --------------------- | ----------------------------- | ---------------- |
|
|
16
|
+
| `--skill <name>` | Skill name | Required |
|
|
17
|
+
| `--skill-path <path>` | Path to the skill's SKILL.md | Required |
|
|
18
|
+
| `--proposal-id <id>` | Specific proposal to rollback | Latest evolution |
|
|
19
19
|
|
|
20
20
|
## Output Format
|
|
21
21
|
|
|
@@ -31,7 +31,7 @@ The command writes a `rolled_back` entry to `~/.claude/evolution_audit_log.jsonl
|
|
|
31
31
|
"total": 50,
|
|
32
32
|
"passed": 35,
|
|
33
33
|
"failed": 15,
|
|
34
|
-
"pass_rate": 0.
|
|
34
|
+
"pass_rate": 0.7
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
```
|
|
@@ -78,6 +78,7 @@ Manual restoration from version control is required.
|
|
|
78
78
|
### 0. Read Evolution Context
|
|
79
79
|
|
|
80
80
|
Before starting, read `~/.selftune/memory/context.md` for session context:
|
|
81
|
+
|
|
81
82
|
- Active evolutions and their current status
|
|
82
83
|
- Previous rollback history
|
|
83
84
|
- Last update timestamp
|
|
@@ -107,6 +108,7 @@ selftune evolve rollback --skill pptx --skill-path /path/to/SKILL.md --proposal-
|
|
|
107
108
|
### 3. Verify Restoration
|
|
108
109
|
|
|
109
110
|
After rollback, verify the SKILL.md content is restored:
|
|
111
|
+
|
|
110
112
|
- Read the file and confirm it matches the pre-evolution version
|
|
111
113
|
- Check the audit log for the `rolled_back` entry
|
|
112
114
|
- Optionally re-run evals to confirm the original pass rate
|
|
@@ -114,6 +116,7 @@ After rollback, verify the SKILL.md content is restored:
|
|
|
114
116
|
### 4. Update Memory
|
|
115
117
|
|
|
116
118
|
After rollback completes, the memory writer updates:
|
|
119
|
+
|
|
117
120
|
- `~/.selftune/memory/decisions.md` -- records the rollback decision and reason
|
|
118
121
|
- `~/.selftune/memory/context.md` -- clears the active evolution state and notes the rollback
|
|
119
122
|
|
|
@@ -128,16 +131,20 @@ audit trail and can use it to avoid repeating failed evolution patterns.
|
|
|
128
131
|
## Common Patterns
|
|
129
132
|
|
|
130
133
|
**"Rollback the last evolution"**
|
|
134
|
+
|
|
131
135
|
> Run rollback with `--skill` and `--skill-path`. The command automatically
|
|
132
136
|
> finds the latest `deployed` entry in the audit log.
|
|
133
137
|
|
|
134
138
|
**"Undo the pptx skill change"**
|
|
139
|
+
|
|
135
140
|
> Same as above, specifying `--skill pptx`.
|
|
136
141
|
|
|
137
142
|
**"Restore the original description"**
|
|
143
|
+
|
|
138
144
|
> If multiple evolutions have occurred, use `--proposal-id` to target a
|
|
139
145
|
> specific one. Without it, only the most recent evolution is rolled back.
|
|
140
146
|
|
|
141
147
|
**"The rollback says no backup found"**
|
|
148
|
+
|
|
142
149
|
> Check version control (git) for the pre-evolution SKILL.md. The audit
|
|
143
150
|
> trail may also contain the original description in a `created` entry.
|
|
@@ -36,12 +36,12 @@ Outputs examples for all three scheduling systems (cron, launchd, systemd).
|
|
|
36
36
|
|
|
37
37
|
## Flags
|
|
38
38
|
|
|
39
|
-
| Flag
|
|
40
|
-
|
|
41
|
-
| `--format <type>` | Output only one format: `cron`, `launchd`, or `systemd`
|
|
42
|
-
| `--install`
|
|
43
|
-
| `--dry-run`
|
|
44
|
-
| `--help`
|
|
39
|
+
| Flag | Description | Default |
|
|
40
|
+
| ----------------- | ------------------------------------------------------------------------ | ----------- |
|
|
41
|
+
| `--format <type>` | Output only one format: `cron`, `launchd`, or `systemd` | All formats |
|
|
42
|
+
| `--install` | Write and activate scheduler artifacts for the selected/default platform | Off |
|
|
43
|
+
| `--dry-run` | Preview installed files and activation commands without writing | Off |
|
|
44
|
+
| `--help` | Show help message | — |
|
|
45
45
|
|
|
46
46
|
## Steps
|
|
47
47
|
|