selftune 0.2.16 → 0.2.18
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 +24 -19
- package/cli/selftune/alpha-upload/build-payloads.ts +14 -1
- package/cli/selftune/alpha-upload/client.ts +51 -1
- package/cli/selftune/alpha-upload/flush.ts +46 -5
- package/cli/selftune/alpha-upload/stage-canonical.ts +25 -4
- package/cli/selftune/alpha-upload-contract.ts +9 -0
- package/cli/selftune/constants.ts +82 -5
- package/cli/selftune/contribute/sanitize.ts +52 -5
- package/cli/selftune/dashboard-contract.ts +100 -0
- package/cli/selftune/dashboard-server.ts +2 -2
- package/cli/selftune/evolution/description-quality.ts +12 -11
- package/cli/selftune/evolution/evolve.ts +214 -51
- package/cli/selftune/evolution/validate-proposal.ts +9 -6
- package/cli/selftune/grading/grade-session.ts +20 -0
- package/cli/selftune/hooks/commit-track.ts +188 -0
- package/cli/selftune/hooks/prompt-log.ts +10 -1
- package/cli/selftune/hooks/session-stop.ts +2 -2
- package/cli/selftune/hooks/skill-eval.ts +15 -1
- package/cli/selftune/hooks/stdin-preview.ts +32 -0
- package/cli/selftune/localdb/direct-write.ts +69 -6
- package/cli/selftune/localdb/queries.ts +552 -7
- package/cli/selftune/localdb/schema.ts +46 -0
- package/cli/selftune/orchestrate.ts +32 -4
- package/cli/selftune/routes/overview.ts +41 -3
- package/cli/selftune/routes/skill-report.ts +88 -17
- package/cli/selftune/types.ts +31 -0
- package/cli/selftune/utils/transcript.ts +210 -1
- package/node_modules/@selftune/telemetry-contract/src/types.ts +11 -0
- package/package.json +1 -1
- package/packages/telemetry-contract/src/types.ts +11 -0
- package/skill/SKILL.md +29 -1
- package/skill/Workflows/Evolve.md +31 -13
- package/skill/Workflows/ExportCanonical.md +121 -0
- package/skill/Workflows/Hook.md +131 -0
- package/skill/Workflows/Initialize.md +9 -8
- package/skill/Workflows/Orchestrate.md +27 -5
- package/skill/Workflows/Quickstart.md +94 -0
- package/skill/Workflows/RepairSkillUsage.md +87 -0
- package/skill/Workflows/Uninstall.md +82 -0
- package/skill/settings_snippet.json +11 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# selftune Repair Skill Usage Workflow
|
|
2
|
+
|
|
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.
|
|
7
|
+
|
|
8
|
+
## When to Use
|
|
9
|
+
|
|
10
|
+
- Skill usage data appears incomplete or has missing `skill_path` values
|
|
11
|
+
- The user says "repair", "rebuild usage", "fix skill usage", or "trustworthy usage"
|
|
12
|
+
- Before evolution or grading when hook data may be unreliable
|
|
13
|
+
- After changing skill directory layouts or reinstalling skills
|
|
14
|
+
|
|
15
|
+
## Default Command
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
selftune repair-skill-usage
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Options
|
|
22
|
+
|
|
23
|
+
| Flag | Description |
|
|
24
|
+
| --------------------------- | -------------------------------------------------------- |
|
|
25
|
+
| `--projects-dir <dir>` | Claude transcript directory (default: `~/.claude/projects`) |
|
|
26
|
+
| `--codex-home <dir>` | Codex home directory (default: `~/.codex`) |
|
|
27
|
+
| `--since <date>` | Only repair sessions modified on/after this date |
|
|
28
|
+
| `--out <path>` | Repaired overlay log output path |
|
|
29
|
+
| `--sessions-marker <path>` | Repaired session-id marker file path |
|
|
30
|
+
| `--skill-log <path>` | Raw skill usage log path (for path lookup bootstrap) |
|
|
31
|
+
| `--dry-run` | Show summary counts without writing files |
|
|
32
|
+
| `--help` | Show usage information |
|
|
33
|
+
|
|
34
|
+
## How It Works
|
|
35
|
+
|
|
36
|
+
1. **Discover transcripts** — Finds all Claude Code transcript JSONL files under `--projects-dir` and Codex rollout files under `--codex-home`.
|
|
37
|
+
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
|
+
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
|
+
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.
|
|
41
|
+
|
|
42
|
+
## Output Format
|
|
43
|
+
|
|
44
|
+
JSON summary printed to stdout:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"transcripts_scanned": 42,
|
|
49
|
+
"codex_rollouts_scanned": 8,
|
|
50
|
+
"repaired_sessions": 35,
|
|
51
|
+
"repaired_records": 127,
|
|
52
|
+
"codex_repaired_records": 12,
|
|
53
|
+
"unique_matched_queries": 98,
|
|
54
|
+
"reins_queries_seen": 5,
|
|
55
|
+
"reins_skill_matches": 3,
|
|
56
|
+
"output": "~/.claude/skill_usage_repaired.jsonl"
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
With `--dry-run`, the same summary is printed but no files are written.
|
|
61
|
+
|
|
62
|
+
## Common Patterns
|
|
63
|
+
|
|
64
|
+
**Preview repair scope**
|
|
65
|
+
|
|
66
|
+
> Run `selftune repair-skill-usage --dry-run` to see how many sessions and records would be repaired.
|
|
67
|
+
|
|
68
|
+
**Repair only recent sessions**
|
|
69
|
+
|
|
70
|
+
> Run `selftune repair-skill-usage --since 2025-01-01` to limit the repair to sessions from this year.
|
|
71
|
+
|
|
72
|
+
**Full rebuild from scratch**
|
|
73
|
+
|
|
74
|
+
> Run `selftune repair-skill-usage` without `--since` to rebuild the entire overlay from all available transcripts.
|
|
75
|
+
|
|
76
|
+
**Agent chaining into evolution**
|
|
77
|
+
|
|
78
|
+
> Run repair before evolution to ensure skill usage data is accurate: `selftune repair-skill-usage && selftune evolve --skill my-skill`.
|
|
79
|
+
|
|
80
|
+
## Troubleshooting
|
|
81
|
+
|
|
82
|
+
| Symptom | Cause | Fix |
|
|
83
|
+
| --- | --- | --- |
|
|
84
|
+
| `repaired_records: 0` | No Skill tool invocations found in transcripts | Verify skills are being invoked in sessions; check `selftune status` |
|
|
85
|
+
| Many `(repaired:name)` paths | Skill not installed or path not discoverable | Install the skill or provide a `--skill-log` with known paths |
|
|
86
|
+
| `transcripts_scanned: 0` | No transcripts in projects directory | Verify `~/.claude/projects/` contains session directories |
|
|
87
|
+
| Invalid `--since` date error | Date format not parseable | Use ISO format: `--since 2025-01-15` |
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# selftune Uninstall Workflow
|
|
2
|
+
|
|
3
|
+
Clean removal of all selftune data, configuration, hooks, and scheduling
|
|
4
|
+
artifacts. Surgically removes selftune entries from shared config files
|
|
5
|
+
(like `settings.json`) without affecting user-owned entries.
|
|
6
|
+
|
|
7
|
+
## When to Use
|
|
8
|
+
|
|
9
|
+
- The user wants to completely remove selftune
|
|
10
|
+
- The user says "uninstall", "remove selftune", "clean up", or "teardown"
|
|
11
|
+
- The agent needs to undo all selftune installation side effects
|
|
12
|
+
|
|
13
|
+
## Default Command
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
selftune uninstall
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Options
|
|
20
|
+
|
|
21
|
+
| Flag | Description |
|
|
22
|
+
| ----------------- | ---------------------------------------------------------- |
|
|
23
|
+
| `--dry-run` | Preview what would be removed without deleting anything |
|
|
24
|
+
| `--keep-logs` | Preserve JSONL telemetry logs (remove everything else) |
|
|
25
|
+
| `--npm-uninstall` | Also run `npm uninstall -g selftune` to remove the binary |
|
|
26
|
+
| `--help` | Show usage information |
|
|
27
|
+
|
|
28
|
+
## Removal Steps
|
|
29
|
+
|
|
30
|
+
The uninstall command removes artifacts in this order:
|
|
31
|
+
|
|
32
|
+
1. **Autonomy scheduling** — Removes launchd plist (`~/Library/LaunchAgents/dev.selftune.orchestrate.plist`) on macOS, or cron jobs via `selftune cron remove` on other platforms.
|
|
33
|
+
2. **Hooks from settings.json** — Surgically removes only selftune hook entries from `~/.claude/settings.json`. Preserves all user-defined hooks.
|
|
34
|
+
3. **Claude subagents** — Removes selftune-managed agent files from `~/.claude/agents/`.
|
|
35
|
+
4. **JSONL telemetry logs** — Removes all selftune log files from `~/.claude/` (session telemetry, skill usage, evolution audit, orchestrate runs, etc.). Skipped with `--keep-logs`.
|
|
36
|
+
5. **Config directory** — Removes `~/.selftune/` and all contents.
|
|
37
|
+
6. **Ingest markers** — Removes per-source marker files that track which sessions have been ingested.
|
|
38
|
+
7. **npm package** — Runs `npm uninstall -g selftune` only when `--npm-uninstall` is passed.
|
|
39
|
+
|
|
40
|
+
## Output Format
|
|
41
|
+
|
|
42
|
+
Output is JSON with per-step results:
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"dryRun": false,
|
|
47
|
+
"schedule": { "removed": true, "details": "Removed launchd plist: ..." },
|
|
48
|
+
"hooks": { "removed": 6, "details": "Removed 6 selftune hook entries from ..." },
|
|
49
|
+
"agents": { "removed": 4, "files": ["..."] },
|
|
50
|
+
"logs": { "removed": 10, "skipped": false, "files": ["..."] },
|
|
51
|
+
"config": { "removed": true, "path": "~/.selftune" },
|
|
52
|
+
"markers": { "removed": 5, "files": ["..."] },
|
|
53
|
+
"npm": { "uninstalled": false, "skipped": true }
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Common Patterns
|
|
58
|
+
|
|
59
|
+
**Preview before removing**
|
|
60
|
+
|
|
61
|
+
> Run `selftune uninstall --dry-run` first to see what would be removed.
|
|
62
|
+
|
|
63
|
+
**Keep telemetry data for later**
|
|
64
|
+
|
|
65
|
+
> Run `selftune uninstall --keep-logs` to remove config and hooks but preserve log files for potential re-installation.
|
|
66
|
+
|
|
67
|
+
**Full removal including npm package**
|
|
68
|
+
|
|
69
|
+
> Run `selftune uninstall --npm-uninstall` for a complete teardown.
|
|
70
|
+
|
|
71
|
+
**Re-install after uninstall**
|
|
72
|
+
|
|
73
|
+
> Run `npx skills add selftune-dev/selftune` followed by `selftune quickstart` to set up again from scratch.
|
|
74
|
+
|
|
75
|
+
## Troubleshooting
|
|
76
|
+
|
|
77
|
+
| Symptom | Cause | Fix |
|
|
78
|
+
| --- | --- | --- |
|
|
79
|
+
| Hooks still present after uninstall | `settings.json` was not writable | Check file permissions on `~/.claude/settings.json` |
|
|
80
|
+
| Scheduling still active | launchd/cron removal failed | Manually run `launchctl unload ~/Library/LaunchAgents/dev.selftune.orchestrate.plist` or remove cron entries |
|
|
81
|
+
| npm package still installed | `--npm-uninstall` was not passed | Run `npm uninstall -g selftune` manually or re-run with `--npm-uninstall` |
|
|
82
|
+
| Some log files remain | Files were locked by another process | Stop any running `selftune` processes and retry, or delete manually |
|
|
@@ -68,6 +68,17 @@
|
|
|
68
68
|
"statusMessage": "selftune: evaluating skill usage"
|
|
69
69
|
}
|
|
70
70
|
]
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"matcher": "Bash",
|
|
74
|
+
"hooks": [
|
|
75
|
+
{
|
|
76
|
+
"type": "command",
|
|
77
|
+
"command": "node /PATH/TO/bin/run-hook.cjs /PATH/TO/cli/selftune/hooks/commit-track.ts",
|
|
78
|
+
"timeout": 8,
|
|
79
|
+
"statusMessage": "selftune: tracking git commit"
|
|
80
|
+
}
|
|
81
|
+
]
|
|
71
82
|
}
|
|
72
83
|
],
|
|
73
84
|
"Stop": [
|