selftune 0.2.18 → 0.2.19

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 (65) hide show
  1. package/README.md +9 -4
  2. package/apps/local-dashboard/dist/assets/index-DnhnXQm6.js +60 -0
  3. package/apps/local-dashboard/dist/assets/index-_EcLywDg.css +1 -0
  4. package/apps/local-dashboard/dist/assets/vendor-table-BIiI3YhS.js +1 -0
  5. package/apps/local-dashboard/dist/assets/vendor-ui-CGEmUayx.js +12 -0
  6. package/apps/local-dashboard/dist/index.html +5 -5
  7. package/cli/selftune/alpha-upload/stage-canonical.ts +7 -6
  8. package/cli/selftune/constants.ts +10 -0
  9. package/cli/selftune/contribute/contribute.ts +30 -2
  10. package/cli/selftune/contribution-config.ts +249 -0
  11. package/cli/selftune/contribution-relay.ts +177 -0
  12. package/cli/selftune/contribution-signals.ts +219 -0
  13. package/cli/selftune/contribution-staging.ts +147 -0
  14. package/cli/selftune/contributions.ts +532 -0
  15. package/cli/selftune/creator-contributions.ts +333 -0
  16. package/cli/selftune/dashboard-contract.ts +205 -1
  17. package/cli/selftune/dashboard-server.ts +45 -11
  18. package/cli/selftune/eval/family-overlap.ts +395 -0
  19. package/cli/selftune/eval/hooks-to-evals.ts +182 -28
  20. package/cli/selftune/eval/synthetic-evals.ts +298 -11
  21. package/cli/selftune/export.ts +2 -2
  22. package/cli/selftune/index.ts +41 -5
  23. package/cli/selftune/ingestors/codex-rollout.ts +31 -35
  24. package/cli/selftune/ingestors/codex-wrapper.ts +32 -24
  25. package/cli/selftune/localdb/db.ts +2 -2
  26. package/cli/selftune/localdb/queries.ts +701 -30
  27. package/cli/selftune/localdb/schema.ts +20 -0
  28. package/cli/selftune/recover.ts +153 -0
  29. package/cli/selftune/repair/skill-usage.ts +363 -4
  30. package/cli/selftune/routes/actions.ts +35 -1
  31. package/cli/selftune/routes/analytics.ts +14 -0
  32. package/cli/selftune/routes/index.ts +1 -0
  33. package/cli/selftune/routes/overview.ts +112 -4
  34. package/cli/selftune/routes/skill-report.ts +569 -10
  35. package/cli/selftune/status.ts +81 -2
  36. package/cli/selftune/sync.ts +56 -2
  37. package/cli/selftune/trust-model.ts +66 -0
  38. package/cli/selftune/types.ts +49 -0
  39. package/cli/selftune/utils/skill-detection.ts +43 -0
  40. package/cli/selftune/watchlist.ts +65 -0
  41. package/package.json +1 -1
  42. package/packages/ui/src/components/ActivityTimeline.tsx +165 -150
  43. package/packages/ui/src/components/EvidenceViewer.tsx +335 -144
  44. package/packages/ui/src/components/EvolutionTimeline.tsx +58 -28
  45. package/packages/ui/src/components/OrchestrateRunsPanel.tsx +33 -16
  46. package/packages/ui/src/components/RecentActivityFeed.tsx +72 -41
  47. package/packages/ui/src/components/section-cards.tsx +12 -9
  48. package/packages/ui/src/primitives/card.tsx +1 -1
  49. package/skill/SKILL.md +11 -1
  50. package/skill/Workflows/AlphaUpload.md +4 -0
  51. package/skill/Workflows/Composability.md +64 -0
  52. package/skill/Workflows/Contribute.md +6 -3
  53. package/skill/Workflows/Contributions.md +97 -0
  54. package/skill/Workflows/CreatorContributions.md +74 -0
  55. package/skill/Workflows/Dashboard.md +31 -0
  56. package/skill/Workflows/Evals.md +57 -8
  57. package/skill/Workflows/Ingest.md +7 -0
  58. package/skill/Workflows/Initialize.md +20 -1
  59. package/skill/Workflows/Recover.md +84 -0
  60. package/skill/Workflows/RepairSkillUsage.md +12 -4
  61. package/skill/Workflows/Sync.md +18 -12
  62. package/apps/local-dashboard/dist/assets/index-BMIS6uUh.css +0 -2
  63. package/apps/local-dashboard/dist/assets/index-DOu3iLD9.js +0 -16
  64. package/apps/local-dashboard/dist/assets/vendor-table-pHbDxq36.js +0 -8
  65. package/apps/local-dashboard/dist/assets/vendor-ui-DIwlrGlb.js +0 -12
@@ -1,8 +1,11 @@
1
1
  # selftune Contribute Workflow
2
2
 
3
- Export anonymized skill observability data as a JSON bundle for community
4
- contribution. Helps improve selftune's skill routing without exposing
5
- private data.
3
+ Export anonymized skill observability data as a JSON bundle for **community**
4
+ contribution. Helps improve selftune's skill routing without exposing private data.
5
+
6
+ This is **not** the same as `selftune contributions`, which manages per-skill
7
+ creator-directed sharing preferences, or `selftune creator-contributions`,
8
+ which manages the creator-side bundled config file.
6
9
 
7
10
  ## When to Use
8
11
 
@@ -0,0 +1,97 @@
1
+ # selftune Contributions Workflow
2
+
3
+ Manage local preferences for future creator-directed contribution flows.
4
+
5
+ This is **not** the same as `selftune contribute`:
6
+ - `selftune contributions` manages per-skill opt-in choices for creator-directed sharing
7
+ - `selftune contribute` exports a community contribution bundle
8
+ - `selftune creator-contributions` manages the creator-side `selftune.contribute.json` file
9
+
10
+ ## When to Use
11
+
12
+ - The user asks to approve or revoke sharing signals with a specific skill creator
13
+ - The user wants to see which creator-directed contribution preferences are stored locally
14
+ - The user wants to set a default behavior for future creator-directed contribution prompts
15
+
16
+ ## Default Commands
17
+
18
+ ```bash
19
+ selftune contributions
20
+ selftune contributions preview <skill>
21
+ selftune contributions approve <skill>
22
+ selftune contributions revoke <skill>
23
+ selftune contributions default <ask|always|never>
24
+ selftune contributions upload [--dry-run] [--retry-failed] [--limit <n>]
25
+ ```
26
+
27
+ ## What It Does Today
28
+
29
+ - Discovers installed skills that ship a `selftune.contribute.json` config
30
+ - Stores local opt-in / opt-out state in `~/.selftune/contribution-preferences.json`
31
+ - Stages privacy-safe creator-directed relay signals locally during `selftune sync` once a skill is approved
32
+ - Keeps creator-directed sharing preferences separate from:
33
+ - `selftune contribute` community export bundles
34
+ - `selftune alpha upload` personal cloud uploads
35
+
36
+ ## Commands
37
+
38
+ | Command | Description |
39
+ | --- | --- |
40
+ | `selftune contributions` | Show current creator-directed contribution preferences |
41
+ | `selftune contributions status` | Same as above |
42
+ | `selftune contributions preview <skill>` | Show the privacy-safe relay payload shape for one skill |
43
+ | `selftune contributions approve <skill>` | Approve creator-directed sharing for one skill |
44
+ | `selftune contributions revoke <skill>` | Revoke creator-directed sharing for one skill |
45
+ | `selftune contributions default <ask|always|never>` | Set the default behavior for future creator-directed prompts |
46
+ | `selftune contributions upload [--dry-run] [--retry-failed] [--limit <n>]` | Flush locally staged creator-directed relay signals |
47
+ | `selftune contributions reset` | Reset all creator-directed sharing preferences to defaults |
48
+
49
+ ## Upload Flags
50
+
51
+ | Flag | Type | Description |
52
+ | --- | --- | --- |
53
+ | `--dry-run` | Boolean | Show pending staged rows without uploading |
54
+ | `--retry-failed` | Boolean | Requeue failed rows before attempting upload |
55
+ | `--limit <n>` | Integer | Maximum number of staged rows to upload in one run |
56
+
57
+ ## Notes
58
+
59
+ - This workflow now shows which installed skills are requesting creator-directed sharing via `selftune.contribute.json`.
60
+ - Once approved, creator-directed contribution signals are staged locally during `selftune sync` / `selftune orchestrate`.
61
+ - Use `selftune contributions upload` to flush staged rows to the creator-directed relay endpoint.
62
+ - Relay upload is separate from `selftune alpha upload` and currently reuses the local cloud API key when available.
63
+ - Use `selftune contribute` when the user explicitly wants to export/share an anonymized community bundle.
64
+ - Use `selftune alpha upload` when the user wants to push their own cloud telemetry.
65
+
66
+ ## Common Patterns
67
+
68
+ **User asks what creator-directed sharing is configured**
69
+
70
+ > Run `selftune contributions` and summarize the global default plus any per-skill choices.
71
+
72
+ **User wants to allow contribution signals for one skill**
73
+
74
+ > Run `selftune contributions approve <skill>`.
75
+
76
+ **User wants to see what would actually be shared**
77
+
78
+ > Run `selftune contributions preview <skill>` and summarize the requested signals plus the “never shared” guarantees.
79
+
80
+ **User wants to turn off creator-directed sharing for one skill**
81
+
82
+ > Run `selftune contributions revoke <skill>`.
83
+
84
+ **User wants future creator-directed prompts to default one way**
85
+
86
+ > Run `selftune contributions default <ask|always|never>` using the user's preference.
87
+
88
+ **User wants to send staged creator-directed signals now**
89
+
90
+ > Run `selftune contributions upload`.
91
+ > Use `--dry-run` first if they want to confirm how many staged rows are pending.
92
+ > Use `--retry-failed` if earlier relay attempts failed and need to be retried.
93
+ > Use `--limit 25` when they want a smaller controlled batch.
94
+
95
+ **User wants to clear all stored creator-directed contribution preferences**
96
+
97
+ > Run `selftune contributions reset`.
@@ -0,0 +1,74 @@
1
+ # selftune Creator-Contributions Workflow
2
+
3
+ Manage the creator-side `selftune.contribute.json` file bundled with a skill.
4
+
5
+ This is **not** the same as:
6
+ - `selftune contributions` — end-user opt-in / opt-out preferences
7
+ - `selftune contribute` — community export bundle
8
+
9
+ ## When to Use
10
+
11
+ - The user is a skill creator and wants to enable creator-directed contribution for one skill
12
+ - The user wants to inspect or remove a bundled `selftune.contribute.json`
13
+ - The user wants to prepare a skill package for the future creator ← user relay pipeline
14
+
15
+ ## Default Commands
16
+
17
+ ```bash
18
+ selftune creator-contributions
19
+ selftune creator-contributions status --skill <name>
20
+ selftune creator-contributions enable --skill <name> [--skill-path <path>] [--creator-id <id>]
21
+ selftune creator-contributions enable --all [--prefix sc-] [--creator-id <id>]
22
+ selftune creator-contributions disable --skill <name> [--skill-path <path>]
23
+ ```
24
+
25
+ ## Options
26
+
27
+ | Flag | Description |
28
+ | --- | --- |
29
+ | `--skill <name>` | Skill name to inspect or configure |
30
+ | `--skill-path <path>` | Explicit path to the skill's `SKILL.md` when auto-discovery is ambiguous |
31
+ | `--creator-id <id>` | Explicit creator ID. If omitted, selftune uses `alpha.cloud_user_id` from local config when available |
32
+ | `--signals <csv>` | Comma-separated signal list for the generated config |
33
+ | `--message <text>` | Custom opt-in note stored in the config |
34
+ | `--privacy-url <url>` | Optional creator privacy URL stored in the config |
35
+ | `--all` | Enable configs for every installed skill selftune can resolve |
36
+ | `--prefix <prefix>` | Limit `--all` to installed skills whose names start with this prefix |
37
+
38
+ ## What It Does Today
39
+
40
+ - Discovers installed skills that already ship `selftune.contribute.json`
41
+ - Creates or removes that config file locally for a creator-owned skill
42
+ - Can bulk-enable configs for multiple installed skills (useful for a skill suite like `sc-*`)
43
+ - Uses a static JSON config only — no executable creator code
44
+
45
+ ## Notes
46
+
47
+ - This is local packaging/setup only. It does **not** upload creator-directed signals yet.
48
+ - The creator ID is currently sourced from `--creator-id` or the local alpha identity's `cloud_user_id`.
49
+ - Use this workflow when the user is preparing a skill package.
50
+
51
+ ## Common Patterns
52
+
53
+ **User wants to see which of their skills already request creator contributions**
54
+
55
+ > Run `selftune creator-contributions` and summarize the discovered configs.
56
+ > Example: `selftune creator-contributions status --skill sc-search`
57
+
58
+ **User wants to enable creator contributions for one skill**
59
+
60
+ > Run `selftune creator-contributions enable --skill <name>`.
61
+ > If auto-discovery fails, rerun with `--skill-path /path/to/SKILL.md`.
62
+ > If no creator identity is available locally, rerun with `--creator-id <id>`.
63
+ > Example: `selftune creator-contributions enable --skill sc-search --skill-path ./skills/sc-search/SKILL.md --creator-id cr_state_change --signals trigger,grade,miss_category --message "Share privacy-safe usage signals with the skill creator." --privacy-url https://statechange.ai/privacy`
64
+
65
+ **User wants to enable creator contributions for a whole installed skill suite**
66
+
67
+ > Run `selftune creator-contributions enable --all --prefix sc-`.
68
+ > This is the fastest path when preparing a whole family of skills like State Change skills.
69
+ > Example: `selftune creator-contributions enable --all --prefix sc- --creator-id cr_state_change`
70
+
71
+ **User wants to stop bundling creator contribution config**
72
+
73
+ > Run `selftune creator-contributions disable --skill <name>`.
74
+ > Example: `selftune creator-contributions disable --skill sc-search --skill-path ./skills/sc-search/SKILL.md`
@@ -49,6 +49,7 @@ override.
49
49
  | `POST` | `/api/actions/watch` | Trigger `selftune watch` for a skill |
50
50
  | `POST` | `/api/actions/evolve` | Trigger `selftune evolve` for a skill |
51
51
  | `POST` | `/api/actions/rollback` | Trigger `selftune evolve rollback` for a skill |
52
+ | `POST` | `/api/actions/watchlist` | Persist creator watchlist preferences |
52
53
 
53
54
  ### Live Updates (SSE)
54
55
 
@@ -98,6 +99,36 @@ All action endpoints return:
98
99
 
99
100
  On failure, `success` is `false` and `error` contains the error message.
100
101
 
102
+ **Watchlist** request body:
103
+
104
+ ```json
105
+ {
106
+ "skills": ["pptx", "sc-search"]
107
+ }
108
+ ```
109
+
110
+ `skills` must be an array of skill names. The action replaces the full persisted
111
+ watchlist for the local dashboard.
112
+
113
+ Watchlist success response:
114
+
115
+ ```json
116
+ {
117
+ "success": true,
118
+ "watched_skills": ["pptx", "sc-search"],
119
+ "error": null
120
+ }
121
+ ```
122
+
123
+ Watchlist failure response:
124
+
125
+ ```json
126
+ {
127
+ "success": false,
128
+ "error": "Missing required field: skills[]"
129
+ }
130
+ ```
131
+
101
132
  ### Browser and Shutdown
102
133
 
103
134
  The live server auto-opens the dashboard URL in the default browser on
@@ -25,7 +25,7 @@ selftune eval generate --skill <name> [options]
25
25
  | Flag | Description | Default |
26
26
  | ---------------------------------- | ----------------------------------------------------- | --------------------------------- |
27
27
  | `--skill <name>` | Skill to generate evals for | Required (unless `--list-skills`) |
28
- | `--list-skills` | List all logged skills with query counts | Off |
28
+ | `--list-skills` | List skills with trusted-vs-raw readiness counts | Off |
29
29
  | `--stats` | Show aggregate telemetry stats for the skill | Off |
30
30
  | `--max <n>` | Maximum eval entries per side | 50 |
31
31
  | `--seed <n>` | Seed for deterministic shuffling | 42 |
@@ -36,6 +36,7 @@ selftune eval generate --skill <name> [options]
36
36
  | `--query-log <path>` | Path to all_queries_log.jsonl | Default log path |
37
37
  | `--telemetry-log <path>` | Path to session_telemetry_log.jsonl | Default log path |
38
38
  | `--synthetic` | Generate evals from SKILL.md via LLM (no logs needed) | Off |
39
+ | `--auto-synthetic` | Fall back to SKILL.md-based cold-start evals when no trusted triggers exist | Off |
39
40
  | `--skill-path <path>` | Path to SKILL.md (required with `--synthetic`) | — |
40
41
  | `--model <model>` | LLM model to use for synthetic generation | Agent default |
41
42
 
@@ -65,8 +66,22 @@ and optional `invocation_type` (omitted when `--no-taxonomy` is set).
65
66
  ```json
66
67
  {
67
68
  "skills": [
68
- { "name": "pptx", "query_count": 42, "session_count": 15 },
69
- { "name": "selftune", "query_count": 28, "session_count": 10 }
69
+ {
70
+ "name": "pptx",
71
+ "trusted_trigger_count": 42,
72
+ "raw_trigger_count": 42,
73
+ "trusted_session_count": 15,
74
+ "raw_session_count": 15,
75
+ "readiness": "log-ready"
76
+ },
77
+ {
78
+ "name": "sc-search",
79
+ "trusted_trigger_count": 0,
80
+ "raw_trigger_count": 1,
81
+ "trusted_session_count": 0,
82
+ "raw_session_count": 1,
83
+ "readiness": "cold-start"
84
+ }
70
85
  ]
71
86
  }
72
87
  ```
@@ -115,7 +130,11 @@ Discover which skills have telemetry data and how many queries each has.
115
130
  selftune eval generate --list-skills
116
131
  ```
117
132
 
118
- Run this first to identify which skills have enough data for eval generation.
133
+ Run this first to identify which skills have enough trusted data for eval generation.
134
+ Installed skills with no trusted trigger history now appear as `cold-start`, which means the
135
+ skill is installed locally and ready for `--auto-synthetic` / `--synthetic` eval generation.
136
+ If raw trigger history exists but trusted positives do not, the list now shows both counts so the
137
+ creator can see that telemetry exists without being misled into thinking the skill is fully ready.
119
138
 
120
139
  ### Generate Synthetic Evals (Cold Start)
121
140
 
@@ -126,20 +145,36 @@ queries directly from the SKILL.md content via an LLM.
126
145
  selftune eval generate --skill pptx --synthetic --skill-path /path/to/skills/pptx/SKILL.md
127
146
  ```
128
147
 
148
+ If the skill is installed locally but has no trusted trigger history yet, use the faster creator
149
+ onboarding path:
150
+
151
+ ```bash
152
+ selftune eval generate --skill pptx --auto-synthetic --skill-path /path/to/skills/pptx/SKILL.md
153
+ ```
154
+
155
+ `--auto-synthetic` keeps the normal log-based path when real trigger data exists, but falls back
156
+ to synthetic cold-start generation when it does not.
157
+
129
158
  The command:
130
159
 
131
160
  1. Reads the SKILL.md file content
132
161
  2. Loads real user queries from the database (if available) as few-shot style examples so synthetic queries match real phrasing patterns
133
- 3. Sends skill content and real examples to an LLM with a prompt requesting realistic test queries
134
- 4. Parses the response into eval entries with invocation type annotations
135
- 5. Classifies each positive query using the deterministic `classifyInvocation()` heuristic
136
- 6. Writes the eval set to the output file
162
+ 3. Detects nearby installed sibling skills to generate harder negative controls
163
+ 4. Over-generates a candidate pool with a balanced prompt family mix (explicit / implicit / contextual positives plus sibling-confusion / adjacent / unrelated negatives)
164
+ 5. Runs a second critique/prune pass to remove weak paraphrases, overlaps, and blurry boundary cases
165
+ 6. Parses the response into eval entries with invocation type annotations
166
+ 7. Classifies each positive query using the deterministic `classifyInvocation()` heuristic
167
+ 8. Writes the eval set to the output file
137
168
 
138
169
  **Note:** When real query data exists in the database, synthetic generation
139
170
  automatically includes high-confidence positive triggers and general queries as
140
171
  phrasing references. This produces more natural-sounding eval queries. If no
141
172
  database is available, generation proceeds without real examples (fail-open).
142
173
 
174
+ The synthetic cold-start path is intentionally small and targeted. It is meant to bootstrap a
175
+ creator skill into its first supervised evolution cycle, not serve as the long-term source of
176
+ truth once real telemetry exists.
177
+
143
178
  Use `--model` to override the default LLM model:
144
179
 
145
180
  ```bash
@@ -165,6 +200,20 @@ The command:
165
200
  5. Annotates each entry with invocation type
166
201
  6. Writes the eval set to the output file
167
202
 
203
+ After generation, the current validation path is:
204
+
205
+ ```bash
206
+ selftune evolve --skill <name> --skill-path /path/to/SKILL.md --eval-set <generated-file> --dry-run
207
+ ```
208
+
209
+ That dry run validates a proposal against the generated eval set without deploying.
210
+
211
+ If the selected skill has no trusted positives yet but selftune can resolve a local `SKILL.md`,
212
+ the command now prints the exact `--auto-synthetic` rerun hint instead of leaving the creator to
213
+ guess the cold-start path.
214
+
215
+ After reviewing a dry-run proposal, deploy by rerunning without `--dry-run`.
216
+
168
217
  ### Show Stats
169
218
 
170
219
  View aggregate telemetry for a skill: average turns, tool call breakdown,
@@ -93,6 +93,13 @@ Writes to:
93
93
  - `~/.claude/all_queries_log.jsonl` -- extracted user queries
94
94
  - `~/.claude/session_telemetry_log.jsonl` -- per-session metrics with `source: "codex_rollout"`
95
95
 
96
+ ### Notes
97
+
98
+ - Conservative skill attribution: Codex rollout ingest only attributes a skill when it has
99
+ explicit evidence, such as a skill file/path read or an explicit user mention that invokes
100
+ the skill. Incidental mentions inside assistant reasoning, optimizer prompts, or eval text do
101
+ not count as triggers.
102
+
96
103
  ### Steps
97
104
 
98
105
  1. Verify `$CODEX_HOME/sessions/` directory exists and contains session files
@@ -192,6 +192,25 @@ and evolution pipeline have data to work with immediately.
192
192
  The sync step is fail-open — if it encounters errors, init continues.
193
193
  Skip with `--no-sync` if you only want hooks for forward-looking data.
194
194
 
195
+ If the user is migrating from a much older pre-SQLite install and wants to
196
+ recover legacy selftune JSONL history itself, use `selftune recover` as a
197
+ separate recovery step. That is not part of normal first-time setup.
198
+
199
+ Recovery quick reference:
200
+
201
+ | Flag | Description |
202
+ | --- | --- |
203
+ | `--full` | Rebuild SQLite from the available JSONL/export sources |
204
+ | `--force` | Skip the SQLite-only preflight guard during a full rebuild |
205
+ | `--since <date>` | Recover only rows on or after the given date |
206
+ | `--json` | Output JSON summary instead of human-readable text |
207
+
208
+ Example:
209
+
210
+ ```bash
211
+ selftune recover --full --force
212
+ ```
213
+
195
214
  ### 9. Autonomy Scheduling
196
215
 
197
216
  Init automatically installs OS-level scheduling (launchd on macOS, cron/systemd
@@ -271,7 +290,7 @@ Enrollment uses a device-code flow — one command, one browser approval, fully
271
290
 
272
291
  ### Setup Sequence
273
292
 
274
- 1. **Check local config**: Run `selftune status` — look for the "Alpha Upload" section
293
+ 1. **Check local config**: Run `selftune status` — use the first summary line and compact `Highlights` section to explain current skill health, then look for the "Alpha Upload" section
275
294
  2. **If not linked**: First use `AskUserQuestion` for the opt-in decision. Only if the user says yes, collect their email and run:
276
295
 
277
296
  ```bash
@@ -0,0 +1,84 @@
1
+ # selftune Recover Workflow
2
+
3
+ Recover or backfill the local SQLite database from legacy JSONL files or an
4
+ explicit `selftune export` snapshot.
5
+
6
+ This is a recovery-only workflow. Normal operation should use `selftune sync`,
7
+ which replays native source data into SQLite and also triggers alpha upload
8
+ when enrolled.
9
+
10
+ ## When to Use
11
+
12
+ - The user is migrating from a pre-SQLite selftune install and still has
13
+ legacy JSONL history that is not in SQLite yet
14
+ - The user exported SQLite to JSONL and now needs to rebuild a fresh DB from
15
+ that snapshot
16
+ - The user explicitly asks to recover, rebuild, or backfill SQLite from JSONL
17
+
18
+ ## Default Command
19
+
20
+ ```bash
21
+ selftune recover
22
+ ```
23
+
24
+ ## Options
25
+
26
+ | Flag | Description |
27
+ | ------------------------------ | ------------------------------------------------------------- |
28
+ | `--full` | Rebuild SQLite tables from scratch |
29
+ | `--force` | Skip the preflight guard for SQLite-only rows during rebuild |
30
+ | `--since <date>` | Incrementally materialize records on/after this date |
31
+ | `--canonical-log <path>` | Canonical JSONL path override |
32
+ | `--telemetry-log <path>` | Session telemetry JSONL path override |
33
+ | `--evolution-audit-log <path>` | Evolution audit JSONL path override |
34
+ | `--evolution-evidence-log <path>` | Evolution evidence JSONL path override |
35
+ | `--orchestrate-run-log <path>` | Orchestrate runs JSONL path override |
36
+ | `--json` | Output a JSON summary |
37
+
38
+ ## Output
39
+
40
+ The command prints a summary of what was materialized into SQLite:
41
+
42
+ - sessions
43
+ - prompts
44
+ - skill invocations
45
+ - execution facts
46
+ - session telemetry
47
+ - legacy skill usage
48
+ - evolution audit
49
+ - evolution evidence
50
+ - orchestrate runs
51
+
52
+ With `--json`, the result includes `mode`, `source`, `since`, `force`, and the
53
+ full count breakdown.
54
+
55
+ ## Common Patterns
56
+
57
+ **Backfill legacy JSONL into an existing SQLite DB**
58
+
59
+ > Run `selftune recover`.
60
+
61
+ **Rebuild a deleted DB from an explicit export snapshot**
62
+
63
+ > Run `selftune export --output ./recovery-snapshot`, then recover from the exported JSONL files explicitly:
64
+ >
65
+ > `selftune recover --full --force --telemetry-log ./recovery-snapshot/session_telemetry_log.jsonl --evolution-audit-log ./recovery-snapshot/evolution_audit_log.jsonl --evolution-evidence-log ./recovery-snapshot/evolution_evidence_log.jsonl --orchestrate-run-log ./recovery-snapshot/orchestrate_run_log.jsonl`
66
+
67
+ **Recover only recent JSONL rows**
68
+
69
+ > Run `selftune recover --since 2026-01-01`.
70
+
71
+ ## Important Notes
72
+
73
+ - Do **not** use this as a normal freshness command. Use `selftune sync` for day-to-day operation.
74
+ - Alpha upload remains SQLite-first. Recovery only repopulates SQLite so the normal upload pipeline can stage and send data afterward.
75
+ - If you are recovering from post-cutover data, prefer a SQLite backup or `selftune export` snapshot. Passive legacy JSONL files do not contain all post-cutover records.
76
+
77
+ ## Example Flags Used Above
78
+
79
+ | Flag | Description |
80
+ | --- | --- |
81
+ | `-o, --output <dir>` | Export SQLite into a portable snapshot directory |
82
+ | `--full` | Rebuild SQLite tables from scratch |
83
+ | `--force` | Skip the SQLite-only preflight guard during full rebuild |
84
+ | `--telemetry-log <path>` | Point recover at the exported telemetry JSONL file |
@@ -1,9 +1,11 @@
1
1
  # selftune Repair Skill Usage Workflow
2
2
 
3
3
  Rebuild trustworthy skill-usage records by replaying Claude Code transcripts
4
- and Codex rollouts. Produces a repaired overlay (`skill_usage_repaired.jsonl`)
5
- that corrects missing or inaccurate skill paths, scopes, and query associations
6
- from the raw hook-captured data.
4
+ and Codex rollouts. Repairs the canonical SQLite `skill_invocations` table for
5
+ historical legacy rows, and also writes a compatibility/export overlay
6
+ (`skill_usage_repaired.jsonl`) that corrects missing or inaccurate skill paths,
7
+ scopes, and query associations from the raw hook-captured data. The overlay is
8
+ for compatibility/export only; SQLite is the operational source of truth.
7
9
 
8
10
  ## When to Use
9
11
 
@@ -37,7 +39,7 @@ selftune repair-skill-usage
37
39
  2. **Bootstrap path lookup** — Reads existing skill usage records from SQLite (or `--skill-log` JSONL) to build a skill-name-to-path lookup table.
38
40
  3. **Replay transcripts** — For each transcript, parses the conversation to find Skill tool invocations, associates them with the preceding user query, and resolves skill paths via installed-scope discovery or the lookup table.
39
41
  4. **Replay Codex rollouts** — Same process for Codex rollout files, using Codex-specific path resolution.
40
- 5. **Write repaired overlay** — Writes deduplicated records to the repaired log and updates the session marker.
42
+ 5. **Repair SQLite + write overlay** — Replaces legacy triggered skill rows in SQLite when safe, inserts repaired canonical rows for legacy-only session/skill pairs, reconstructs contextual missed triggers from `Read .../SKILL.md` evidence, then writes deduplicated records to the repaired log and updates the session marker.
41
43
 
42
44
  ## Output Format
43
45
 
@@ -59,6 +61,11 @@ JSON summary printed to stdout:
59
61
 
60
62
  With `--dry-run`, the same summary is printed but no files are written.
61
63
 
64
+ On non-dry runs, the JSON summary also includes a `sqlite` object with counts
65
+ for deleted legacy rows, inserted repair rows, and skipped pairs that already
66
+ had canonical data. Repaired rows can be either triggered invocations or
67
+ contextual misses reconstructed from transcript reads of `SKILL.md`.
68
+
62
69
  ## Common Patterns
63
70
 
64
71
  **Preview repair scope**
@@ -72,6 +79,7 @@ With `--dry-run`, the same summary is printed but no files are written.
72
79
  **Full rebuild from scratch**
73
80
 
74
81
  > Run `selftune repair-skill-usage` without `--since` to rebuild the entire overlay from all available transcripts.
82
+ > This also repairs SQLite-backed skill invocations for legacy-only historical rows.
75
83
 
76
84
  **Agent chaining into evolution**
77
85
 
@@ -1,15 +1,18 @@
1
1
  # selftune Sync Workflow
2
2
 
3
- Refresh source-truth telemetry across supported agent CLIs, then rebuild the
4
- repaired skill-usage overlay so status, dashboard, grading, and evolution work
5
- from real transcripts/rollouts instead of stale hook data.
3
+ Refresh source-truth telemetry across supported agent CLIs into SQLite, then
4
+ rebuild the repaired skill-usage layer so status, dashboard, grading, and
5
+ evolution work from real transcripts/rollouts instead of stale hook data. The
6
+ repair phase updates canonical SQLite skill invocations for legacy historical
7
+ rows, reconstructs contextual misses from transcript `SKILL.md` reads, and
8
+ also writes the compatibility repaired overlay JSONL.
6
9
 
7
10
  ## When to Use
8
11
 
9
12
  - Before running `status`, `dashboard`, `watch`, or `evolve` when data may be stale
10
13
  - The user has run many Claude Code, Codex, OpenCode, or OpenClaw sessions since last sync
11
14
  - The agent detects host logs may be polluted and needs the repaired/source-first view
12
- - Before exporting data to cloud ingest
15
+ - Before inspecting alpha-upload readiness or pushing fresh cloud data
13
16
 
14
17
  ## Default Command
15
18
 
@@ -22,24 +25,25 @@ selftune sync
22
25
  | Flag | Description |
23
26
  | ---------------- | ----------------------------------------------- |
24
27
  | `--since <date>` | Only sync sessions modified on/after this date |
25
- | `--dry-run` | Show summary without writing files |
28
+ | `--dry-run` | Show summary without writing to SQLite or files |
26
29
  | `--force` | Ignore per-source markers and rescan everything |
27
30
  | `--no-claude` | Skip Claude transcript replay |
28
31
  | `--no-codex` | Skip Codex rollout ingest |
29
32
  | `--no-opencode` | Skip OpenCode ingest |
30
33
  | `--no-openclaw` | Skip OpenClaw ingest |
31
- | `--no-repair` | Skip rebuilding `skill_usage_repaired.jsonl` |
34
+ | `--no-repair` | Skip rebuilding repaired skill-usage data |
32
35
  | `--json` | Output results as JSON |
33
36
 
34
37
  ## Output
35
38
 
36
39
  Writes/refreshed data:
37
40
 
38
- - `~/.claude/session_telemetry_log.jsonl`
39
- - `~/.claude/all_queries_log.jsonl`
40
- - `~/.claude/skill_usage_log.jsonl`
41
- - `~/.claude/skill_usage_repaired.jsonl`
41
+ - SQLite operational tables in `~/.selftune/selftune.db`
42
+ - canonical SQLite `skill_invocations` repair rows / legacy-row cleanup
43
+ - `~/.claude/skill_usage_repaired.jsonl` compatibility/export overlay
44
+ - local creator-directed contribution staging rows for approved skills
42
45
  - per-source marker files
46
+ - alpha upload queue/staging activity when alpha is enrolled
43
47
 
44
48
  ## Steps
45
49
 
@@ -53,8 +57,10 @@ counts. Report the preview summary to the user.
53
57
  Run `selftune sync`. The output includes:
54
58
 
55
59
  - Per-source `scanned`, `synced`, and `skipped` counts
56
- - Repaired overlay totals
60
+ - Repaired skill-usage totals
61
+ - Creator-directed contribution staging totals when approved skills are installed
57
62
  - Any errors or warnings
63
+ - Alpha upload summary when cloud upload is enabled
58
64
 
59
65
  ### 3. Verify Results
60
66
 
@@ -67,7 +73,7 @@ sync reports source/hook failures or expected active sources are missing.
67
73
 
68
74
  After sync completes, proceed with the user's intended workflow:
69
75
  `selftune status`, `selftune dashboard`, `selftune watch --sync-first`,
70
- or `selftune evolve --sync-first`.
76
+ `selftune evolve --sync-first`, or `selftune alpha upload` for a manual upload.
71
77
 
72
78
  ## `--json` Usage
73
79