selftune 0.2.22 → 0.2.24

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 (270) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +95 -15
  3. package/apps/local-dashboard/dist/assets/index-DgY2KGP-.css +1 -0
  4. package/apps/local-dashboard/dist/assets/index-Dmx7LPVX.js +15 -0
  5. package/apps/local-dashboard/dist/assets/vendor-react-C5oyHiV1.js +11 -0
  6. package/apps/local-dashboard/dist/assets/{vendor-table-BIiI3YhS.js → vendor-table-Bc_bbKd8.js} +1 -1
  7. package/apps/local-dashboard/dist/assets/vendor-ui-B3BPIYy7.js +1 -0
  8. package/apps/local-dashboard/dist/index.html +5 -5
  9. package/cli/selftune/adapters/codex/install.ts +310 -78
  10. package/cli/selftune/adapters/opencode/install.ts +3 -4
  11. package/cli/selftune/adapters/pi/hook.ts +273 -0
  12. package/cli/selftune/adapters/pi/install.ts +207 -0
  13. package/cli/selftune/alpha-upload/build-payloads.ts +3 -3
  14. package/cli/selftune/alpha-upload/stage-canonical.ts +17 -11
  15. package/cli/selftune/auto-update.ts +200 -8
  16. package/cli/selftune/canonical-export.ts +55 -25
  17. package/cli/selftune/command-surface.ts +397 -0
  18. package/cli/selftune/constants.ts +10 -1
  19. package/cli/selftune/contribute/contribute.ts +64 -13
  20. package/cli/selftune/contribution-config.ts +57 -3
  21. package/cli/selftune/contribution-preferences.ts +117 -0
  22. package/cli/selftune/contribution-signals.ts +8 -4
  23. package/cli/selftune/contribution-staging.ts +13 -2
  24. package/cli/selftune/contributions.ts +55 -121
  25. package/cli/selftune/creator-contributions.ts +29 -10
  26. package/cli/selftune/cron/setup.ts +7 -3
  27. package/cli/selftune/dashboard-contract.ts +87 -0
  28. package/cli/selftune/dashboard-server.ts +168 -17
  29. package/cli/selftune/dashboard.ts +350 -17
  30. package/cli/selftune/eval/baseline.ts +21 -5
  31. package/cli/selftune/eval/execution-eval.ts +170 -0
  32. package/cli/selftune/eval/family-overlap.ts +2 -2
  33. package/cli/selftune/eval/hooks-to-evals.ts +228 -82
  34. package/cli/selftune/eval/import-skillsbench.ts +2 -2
  35. package/cli/selftune/eval/invocation-classifier.ts +56 -0
  36. package/cli/selftune/eval/synthetic-evals.ts +5 -3
  37. package/cli/selftune/eval/unit-test-cli.ts +7 -4
  38. package/cli/selftune/evolution/apply-proposal.ts +295 -0
  39. package/cli/selftune/evolution/engines/judge-engine.ts +96 -0
  40. package/cli/selftune/evolution/engines/replay-engine.ts +180 -0
  41. package/cli/selftune/evolution/evidence.ts +2 -6
  42. package/cli/selftune/evolution/evolve-body.ts +152 -38
  43. package/cli/selftune/evolution/evolve.ts +244 -52
  44. package/cli/selftune/evolution/rollback.ts +0 -1
  45. package/cli/selftune/evolution/validate-body.ts +111 -49
  46. package/cli/selftune/evolution/validate-host-replay.ts +510 -60
  47. package/cli/selftune/evolution/validate-proposal.ts +11 -150
  48. package/cli/selftune/evolution/validate-routing.ts +51 -108
  49. package/cli/selftune/evolution/validation-contract.ts +91 -0
  50. package/cli/selftune/grading/auto-grade.ts +11 -7
  51. package/cli/selftune/grading/grade-session.ts +10 -16
  52. package/cli/selftune/hooks/skill-eval.ts +2 -1
  53. package/cli/selftune/hooks-shared/types.ts +1 -0
  54. package/cli/selftune/index.ts +58 -15
  55. package/cli/selftune/ingestors/claude-replay.ts +15 -10
  56. package/cli/selftune/ingestors/codex-wrapper.ts +3 -3
  57. package/cli/selftune/ingestors/opencode-ingest.ts +2 -2
  58. package/cli/selftune/ingestors/pi-ingest.ts +727 -0
  59. package/cli/selftune/init.ts +38 -4
  60. package/cli/selftune/localdb/direct-write.ts +120 -1
  61. package/cli/selftune/localdb/materialize.ts +6 -7
  62. package/cli/selftune/localdb/queries/cron.ts +34 -0
  63. package/cli/selftune/localdb/queries/dashboard.ts +834 -0
  64. package/cli/selftune/localdb/queries/evolution.ts +158 -0
  65. package/cli/selftune/localdb/queries/execution.ts +133 -0
  66. package/cli/selftune/localdb/queries/json.ts +18 -0
  67. package/cli/selftune/localdb/queries/monitoring.ts +263 -0
  68. package/cli/selftune/localdb/queries/raw.ts +95 -0
  69. package/cli/selftune/localdb/queries/staging.ts +270 -0
  70. package/cli/selftune/localdb/queries/trust.ts +392 -0
  71. package/cli/selftune/localdb/queries.ts +60 -2162
  72. package/cli/selftune/localdb/schema.ts +59 -0
  73. package/cli/selftune/monitoring/watch.ts +96 -29
  74. package/cli/selftune/normalization.ts +3 -0
  75. package/cli/selftune/observability.ts +12 -3
  76. package/cli/selftune/orchestrate/cli.ts +161 -0
  77. package/cli/selftune/orchestrate/execute.ts +295 -0
  78. package/cli/selftune/orchestrate/finalize.ts +157 -0
  79. package/cli/selftune/orchestrate/locks.ts +40 -0
  80. package/cli/selftune/orchestrate/plan.ts +131 -0
  81. package/cli/selftune/orchestrate/post-run.ts +59 -0
  82. package/cli/selftune/orchestrate/prepare.ts +334 -0
  83. package/cli/selftune/orchestrate/report.ts +182 -0
  84. package/cli/selftune/orchestrate/runtime.ts +120 -0
  85. package/cli/selftune/orchestrate/signals.ts +48 -0
  86. package/cli/selftune/orchestrate.ts +162 -1142
  87. package/cli/selftune/registry/client.ts +74 -0
  88. package/cli/selftune/registry/history.ts +54 -0
  89. package/cli/selftune/registry/index.ts +90 -0
  90. package/cli/selftune/registry/install.ts +141 -0
  91. package/cli/selftune/registry/list.ts +44 -0
  92. package/cli/selftune/registry/push.ts +171 -0
  93. package/cli/selftune/registry/rollback.ts +49 -0
  94. package/cli/selftune/registry/status.ts +62 -0
  95. package/cli/selftune/registry/sync.ts +125 -0
  96. package/cli/selftune/repair/skill-usage.ts +9 -3
  97. package/cli/selftune/routes/overview.ts +5 -2
  98. package/cli/selftune/routes/skill-report.ts +15 -2
  99. package/cli/selftune/schedule.ts +5 -5
  100. package/cli/selftune/status.ts +70 -2
  101. package/cli/selftune/sync.ts +127 -23
  102. package/cli/selftune/testing-readiness.ts +597 -0
  103. package/cli/selftune/types.ts +46 -5
  104. package/cli/selftune/uninstall.ts +2 -1
  105. package/cli/selftune/utils/canonical-log.ts +1 -9
  106. package/cli/selftune/utils/cli-error.ts +9 -0
  107. package/cli/selftune/utils/jsonl.ts +1 -30
  108. package/cli/selftune/utils/llm-call.ts +126 -6
  109. package/cli/selftune/utils/skill-discovery.ts +24 -0
  110. package/cli/selftune/workflows/proposals.ts +184 -0
  111. package/cli/selftune/workflows/skill-scaffold.ts +241 -0
  112. package/cli/selftune/workflows/workflows.ts +100 -26
  113. package/node_modules/@selftune/telemetry-contract/fixtures/complete-push.ts +1 -1
  114. package/node_modules/@selftune/telemetry-contract/fixtures/evidence-only-push.ts +2 -2
  115. package/node_modules/@selftune/telemetry-contract/fixtures/golden.test.ts +0 -1
  116. package/node_modules/@selftune/telemetry-contract/fixtures/partial-push-no-sessions.ts +1 -1
  117. package/node_modules/@selftune/telemetry-contract/fixtures/partial-push-unresolved-parents.ts +2 -2
  118. package/node_modules/@selftune/telemetry-contract/package.json +1 -1
  119. package/node_modules/@selftune/telemetry-contract/src/index.ts +1 -0
  120. package/node_modules/@selftune/telemetry-contract/src/schemas.ts +63 -5
  121. package/node_modules/@selftune/telemetry-contract/src/types.ts +97 -7
  122. package/node_modules/@selftune/telemetry-contract/tests/compatibility.test.ts +0 -1
  123. package/package.json +25 -9
  124. package/packages/dashboard-core/AGENTS.md +18 -0
  125. package/packages/dashboard-core/README.md +30 -0
  126. package/packages/dashboard-core/index.ts +3 -0
  127. package/packages/dashboard-core/package.json +39 -0
  128. package/packages/dashboard-core/src/chrome/DashboardChrome.tsx +74 -0
  129. package/packages/dashboard-core/src/chrome/DashboardHeader.tsx +200 -0
  130. package/packages/dashboard-core/src/chrome/DashboardSidebar.tsx +219 -0
  131. package/packages/dashboard-core/src/chrome/RuntimeBadge.tsx +46 -0
  132. package/packages/dashboard-core/src/chrome/index.ts +14 -0
  133. package/packages/dashboard-core/src/chrome/types.ts +81 -0
  134. package/packages/dashboard-core/src/chrome/utils.ts +23 -0
  135. package/packages/dashboard-core/src/gates/FeatureGate.tsx +11 -0
  136. package/packages/dashboard-core/src/gates/LockedRoute.tsx +29 -0
  137. package/packages/dashboard-core/src/gates/UpgradeCard.tsx +89 -0
  138. package/packages/dashboard-core/src/gates/index.ts +3 -0
  139. package/packages/dashboard-core/src/host/DashboardHostProvider.tsx +62 -0
  140. package/packages/dashboard-core/src/host/adapter.ts +47 -0
  141. package/packages/dashboard-core/src/host/capabilities.ts +55 -0
  142. package/packages/dashboard-core/src/host/index.ts +3 -0
  143. package/packages/dashboard-core/src/models/analytics.ts +39 -0
  144. package/packages/dashboard-core/src/models/index.ts +4 -0
  145. package/packages/dashboard-core/src/models/overview.ts +98 -0
  146. package/packages/dashboard-core/src/models/runtime.ts +7 -0
  147. package/packages/dashboard-core/src/models/skills.ts +34 -0
  148. package/packages/dashboard-core/src/routes/index.ts +2 -0
  149. package/packages/dashboard-core/src/routes/manifest.test.ts +70 -0
  150. package/packages/dashboard-core/src/routes/manifest.ts +451 -0
  151. package/packages/dashboard-core/src/routes/types.ts +39 -0
  152. package/packages/dashboard-core/src/screens/analytics/AnalyticsScreen.tsx +278 -0
  153. package/packages/dashboard-core/src/screens/analytics/index.ts +1 -0
  154. package/packages/dashboard-core/src/screens/index.ts +37 -0
  155. package/packages/dashboard-core/src/screens/overview/OverviewComparisonSurface.test.ts +101 -0
  156. package/packages/dashboard-core/src/screens/overview/OverviewComparisonSurface.tsx +393 -0
  157. package/packages/dashboard-core/src/screens/overview/OverviewCompositionSurface.test.tsx +113 -0
  158. package/packages/dashboard-core/src/screens/overview/OverviewCompositionSurface.tsx +72 -0
  159. package/packages/dashboard-core/src/screens/overview/OverviewCoreSurface.tsx +71 -0
  160. package/packages/dashboard-core/src/screens/overview/OverviewOnboardingBanner.tsx +90 -0
  161. package/packages/dashboard-core/src/screens/overview/OverviewRunSummary.tsx +40 -0
  162. package/packages/dashboard-core/src/screens/overview/index.ts +16 -0
  163. package/packages/dashboard-core/src/screens/overview/types.ts +13 -0
  164. package/packages/dashboard-core/src/screens/skill-report/SkillReportDailyBreakdownSection.tsx +99 -0
  165. package/packages/dashboard-core/src/screens/skill-report/SkillReportDataQualityTabContent.tsx +35 -0
  166. package/packages/dashboard-core/src/screens/skill-report/SkillReportEvidenceRail.tsx +71 -0
  167. package/packages/dashboard-core/src/screens/skill-report/SkillReportEvidenceSection.tsx +63 -0
  168. package/packages/dashboard-core/src/screens/skill-report/SkillReportEvidenceTabContent.tsx +25 -0
  169. package/packages/dashboard-core/src/screens/skill-report/SkillReportInvocationsSection.tsx +24 -0
  170. package/packages/dashboard-core/src/screens/skill-report/SkillReportMissedQueriesSection.tsx +79 -0
  171. package/packages/dashboard-core/src/screens/skill-report/SkillReportScaffold.tsx +150 -0
  172. package/packages/dashboard-core/src/screens/skill-report/SkillReportSections.test.tsx +224 -0
  173. package/packages/dashboard-core/src/screens/skill-report/SkillReportTabs.test.tsx +76 -0
  174. package/packages/dashboard-core/src/screens/skill-report/SkillReportTabs.tsx +88 -0
  175. package/packages/dashboard-core/src/screens/skill-report/SkillReportTrendSection.tsx +33 -0
  176. package/packages/dashboard-core/src/screens/skill-report/SkillReportTrustBadge.tsx +67 -0
  177. package/packages/dashboard-core/src/screens/skill-report/index.ts +45 -0
  178. package/packages/dashboard-core/src/screens/skills/SkillsLibraryScreen.tsx +162 -0
  179. package/packages/dashboard-core/src/screens/skills/index.ts +6 -0
  180. package/packages/telemetry-contract/fixtures/complete-push.ts +1 -1
  181. package/packages/telemetry-contract/fixtures/evidence-only-push.ts +2 -2
  182. package/packages/telemetry-contract/fixtures/golden.test.ts +0 -1
  183. package/packages/telemetry-contract/fixtures/partial-push-no-sessions.ts +1 -1
  184. package/packages/telemetry-contract/fixtures/partial-push-unresolved-parents.ts +2 -2
  185. package/packages/telemetry-contract/package.json +1 -1
  186. package/packages/telemetry-contract/src/index.ts +1 -0
  187. package/packages/telemetry-contract/src/schemas.ts +63 -5
  188. package/packages/telemetry-contract/src/types.ts +97 -7
  189. package/packages/telemetry-contract/tests/compatibility.test.ts +0 -1
  190. package/packages/ui/AGENTS.md +16 -0
  191. package/packages/ui/README.md +1 -1
  192. package/packages/ui/package.json +1 -1
  193. package/packages/ui/src/components/ActivityTimeline.tsx +152 -168
  194. package/packages/ui/src/components/AnalyticsCharts.tsx +344 -0
  195. package/packages/ui/src/components/EvidenceViewer.tsx +229 -464
  196. package/packages/ui/src/components/EvolutionTimeline.tsx +34 -87
  197. package/packages/ui/src/components/InfoTip.tsx +1 -2
  198. package/packages/ui/src/components/InvocationsPanel.tsx +413 -0
  199. package/packages/ui/src/components/JobHistoryTimeline.tsx +156 -0
  200. package/packages/ui/src/components/OrchestrateRunsPanel.tsx +18 -36
  201. package/packages/ui/src/components/OverviewPanels.tsx +693 -0
  202. package/packages/ui/src/components/PipelineStatusBar.tsx +65 -0
  203. package/packages/ui/src/components/SkillReportGuide.tsx +215 -0
  204. package/packages/ui/src/components/SkillReportPanels.tsx +919 -0
  205. package/packages/ui/src/components/SkillsLibrary.tsx +437 -0
  206. package/packages/ui/src/components/index.ts +56 -1
  207. package/packages/ui/src/components/section-cards.tsx +18 -35
  208. package/packages/ui/src/components/skill-health-grid.tsx +47 -37
  209. package/packages/ui/src/lib/constants.tsx +0 -1
  210. package/packages/ui/src/primitives/card.tsx +1 -1
  211. package/packages/ui/src/primitives/checkbox.tsx +1 -1
  212. package/packages/ui/src/primitives/dropdown-menu.tsx +2 -2
  213. package/packages/ui/src/primitives/select.tsx +2 -2
  214. package/packages/ui/src/primitives/tabs.tsx +7 -6
  215. package/packages/ui/src/types.ts +182 -4
  216. package/skill/SKILL.md +130 -318
  217. package/skill/agents/diagnosis-analyst.md +3 -3
  218. package/skill/agents/evolution-reviewer.md +3 -3
  219. package/skill/agents/integration-guide.md +3 -3
  220. package/skill/agents/pattern-analyst.md +2 -2
  221. package/skill/references/cli-quick-reference.md +89 -0
  222. package/skill/references/creator-playbook.md +131 -0
  223. package/skill/references/examples.md +48 -0
  224. package/skill/references/troubleshooting.md +47 -0
  225. package/skill/references/version-history.md +1 -1
  226. package/skill/selftune.contribute.json +11 -0
  227. package/skill/{Workflows → workflows}/Baseline.md +20 -1
  228. package/skill/{Workflows → workflows}/Contribute.md +23 -10
  229. package/skill/{Workflows → workflows}/Contributions.md +13 -5
  230. package/skill/workflows/CreateTestDeploy.md +170 -0
  231. package/skill/{Workflows → workflows}/CreatorContributions.md +18 -6
  232. package/skill/{Workflows → workflows}/Cron.md +1 -1
  233. package/skill/{Workflows → workflows}/Dashboard.md +20 -0
  234. package/skill/{Workflows → workflows}/Doctor.md +1 -1
  235. package/skill/{Workflows → workflows}/Evals.md +67 -2
  236. package/skill/{Workflows → workflows}/Evolve.md +119 -30
  237. package/skill/{Workflows → workflows}/EvolveBody.md +41 -1
  238. package/skill/{Workflows → workflows}/Grade.md +1 -1
  239. package/skill/{Workflows → workflows}/Ingest.md +60 -2
  240. package/skill/{Workflows → workflows}/Initialize.md +16 -9
  241. package/skill/{Workflows → workflows}/Orchestrate.md +13 -3
  242. package/skill/{Workflows → workflows}/PlatformHooks.md +19 -3
  243. package/skill/workflows/Registry.md +99 -0
  244. package/skill/{Workflows → workflows}/Schedule.md +3 -3
  245. package/skill/workflows/SignalsDashboard.md +87 -0
  246. package/skill/{Workflows → workflows}/Sync.md +3 -1
  247. package/skill/{Workflows → workflows}/UnitTest.md +19 -0
  248. package/skill/{Workflows → workflows}/Watch.md +42 -2
  249. package/skill/{Workflows → workflows}/Workflows.md +39 -2
  250. package/apps/local-dashboard/dist/assets/index-D8O-RG1I.js +0 -60
  251. package/apps/local-dashboard/dist/assets/index-_EcLywDg.css +0 -1
  252. package/apps/local-dashboard/dist/assets/vendor-react-CKkiCskZ.js +0 -11
  253. package/apps/local-dashboard/dist/assets/vendor-ui-CGEmUayx.js +0 -12
  254. package/cli/selftune/utils/html.ts +0 -27
  255. package/packages/ui/src/components/RecentActivityFeed.tsx +0 -117
  256. /package/skill/{Workflows → workflows}/AlphaUpload.md +0 -0
  257. /package/skill/{Workflows → workflows}/AutoActivation.md +0 -0
  258. /package/skill/{Workflows → workflows}/Badge.md +0 -0
  259. /package/skill/{Workflows → workflows}/Composability.md +0 -0
  260. /package/skill/{Workflows → workflows}/EvolutionMemory.md +0 -0
  261. /package/skill/{Workflows → workflows}/ExportCanonical.md +0 -0
  262. /package/skill/{Workflows → workflows}/Hook.md +0 -0
  263. /package/skill/{Workflows → workflows}/ImportSkillsBench.md +0 -0
  264. /package/skill/{Workflows → workflows}/Quickstart.md +0 -0
  265. /package/skill/{Workflows → workflows}/Recover.md +0 -0
  266. /package/skill/{Workflows → workflows}/RepairSkillUsage.md +0 -0
  267. /package/skill/{Workflows → workflows}/Replay.md +0 -0
  268. /package/skill/{Workflows → workflows}/Rollback.md +0 -0
  269. /package/skill/{Workflows → workflows}/Telemetry.md +0 -0
  270. /package/skill/{Workflows → workflows}/Uninstall.md +0 -0
@@ -3,7 +3,7 @@
3
3
  * selftune CLI entry point.
4
4
  *
5
5
  * Usage:
6
- * selftune ingest <agent> — Ingest agent sessions (claude, codex, opencode, openclaw, wrap-codex)
6
+ * selftune ingest <agent> — Ingest agent sessions (claude, codex, opencode, openclaw, pi, wrap-codex)
7
7
  * selftune grade [mode] — Grade skill sessions (auto, baseline)
8
8
  * selftune evolve [target] — Evolve skill descriptions (body, rollback)
9
9
  * selftune eval <action> — Evaluation tools (generate, unit-test, import, composability, family-overlap)
@@ -21,21 +21,24 @@
21
21
  * selftune contribute — Export anonymized skill data for community
22
22
  * selftune contributions — Manage creator-directed sharing preferences
23
23
  * selftune creator-contributions — Manage creator-side contribution configs
24
- * selftune workflows — Discover and manage multi-skill workflows
24
+ * selftune workflows — Discover workflows and scaffold workflow skills
25
25
  * selftune quickstart — Guided onboarding: init, ingest, status, and suggestions
26
26
  * selftune repair-skill-usage — Rebuild trustworthy skill usage from transcripts
27
27
  * selftune export — Export SQLite data to JSONL snapshots
28
28
  * selftune export-canonical — Export canonical telemetry for downstream ingestion
29
29
  * selftune recover — Recover SQLite from legacy/exported JSONL
30
30
  * selftune telemetry — Manage anonymous usage analytics (status, enable, disable)
31
+ * selftune registry <sub> — Team skill distribution (push, install, sync, status, rollback, history, list)
31
32
  * selftune alpha <subcommand> — Alpha program management (upload)
32
33
  * selftune hook <name> — Run a hook by name (prompt-log, session-stop, etc.)
33
34
  * selftune codex <subcommand> — Codex platform hooks (hook, install)
34
35
  * selftune opencode <sub> — OpenCode platform hooks (hook, install)
35
36
  * selftune cline <subcommand> — Cline platform hooks (hook, install)
37
+ * selftune pi <subcommand> — Pi platform hooks (hook, install)
36
38
  */
37
39
 
38
40
  import { CLIError, handleCLIError } from "./utils/cli-error.js";
41
+ import { PUBLIC_COMMAND_SURFACES, renderCommandHelp } from "./command-surface.js";
39
42
 
40
43
  process.on("uncaughtException", handleCLIError);
41
44
  process.on("unhandledRejection", handleCLIError);
@@ -49,7 +52,7 @@ Usage:
49
52
  selftune <command> [options]
50
53
 
51
54
  Commands:
52
- ingest <agent> Ingest agent sessions (claude, codex, opencode, openclaw, wrap-codex)
55
+ ingest <agent> Ingest agent sessions (claude, codex, opencode, openclaw, pi, wrap-codex)
53
56
  grade [mode] Grade skill sessions (auto, baseline)
54
57
  evolve [target] Evolve skill descriptions (body, rollback)
55
58
  eval <action> Evaluation tools (generate, unit-test, import, composability, family-overlap)
@@ -67,25 +70,27 @@ Commands:
67
70
  contribute Export anonymized skill data for community
68
71
  contributions Manage creator-directed sharing preferences
69
72
  creator-contributions Manage creator-side contribution configs
70
- workflows Discover and manage multi-skill workflows
73
+ workflows Discover workflows and scaffold workflow skills
71
74
  quickstart Guided onboarding: init, ingest, status, and suggestions
72
75
  repair-skill-usage Rebuild trustworthy skill usage from transcripts
73
76
  export Export SQLite data to JSONL snapshots
74
77
  export-canonical Export canonical telemetry for downstream ingestion
75
78
  recover Recover SQLite from legacy/exported JSONL
79
+ registry <sub> Team skill distribution (push, install, sync, status, rollback, history, list)
76
80
  alpha <subcommand> Alpha program management (upload)
77
81
  telemetry Manage anonymous usage analytics (status, enable, disable)
78
82
  hook <name> Run a hook by name (prompt-log, session-stop, etc.)
79
83
  codex <sub> Codex platform hooks (hook, install)
80
84
  opencode <sub> OpenCode platform hooks (hook, install)
81
85
  cline <sub> Cline platform hooks (hook, install)
86
+ pi <sub> Pi platform hooks (hook, install)
82
87
 
83
88
  Run 'selftune <command> --help' for command-specific options.`);
84
89
  process.exit(0);
85
90
  }
86
91
 
87
92
  // Fast-path commands (real-time hooks) — skip analytics and auto-update to minimize latency
88
- const FAST_COMMANDS: ReadonlySet<string> = new Set(["hook", "codex", "opencode", "cline"]);
93
+ const FAST_COMMANDS: ReadonlySet<string> = new Set(["hook", "codex", "opencode", "cline", "pi"]);
89
94
 
90
95
  // Track command usage (lazy import — skip for hooks and --help to avoid loading crypto/os)
91
96
  if (command && !FAST_COMMANDS.has(command) && command !== "--help" && command !== "-h") {
@@ -129,6 +134,7 @@ Agents:
129
134
  codex Ingest Codex rollout logs (experimental)
130
135
  opencode Ingest OpenCode sessions (experimental)
131
136
  openclaw Ingest OpenClaw sessions (experimental)
137
+ pi Ingest Pi sessions (experimental)
132
138
  wrap-codex Wrap codex exec with real-time telemetry (experimental)
133
139
 
134
140
  Run 'selftune ingest <agent> --help' for agent-specific options.`);
@@ -157,6 +163,11 @@ Run 'selftune ingest <agent> --help' for agent-specific options.`);
157
163
  cliMain();
158
164
  break;
159
165
  }
166
+ case "pi": {
167
+ const { cliMain } = await import("./ingestors/pi-ingest.js");
168
+ cliMain();
169
+ break;
170
+ }
160
171
  case "wrap-codex": {
161
172
  const { cliMain } = await import("./ingestors/codex-wrapper.js");
162
173
  await cliMain();
@@ -217,12 +228,12 @@ Run 'selftune grade <subcommand> --help' for subcommand-specific options.`);
217
228
  case "evolve": {
218
229
  const sub = process.argv[2];
219
230
  if (sub === "--help" || sub === "-h") {
220
- console.log(`selftune evolve — Evolve skill descriptions
231
+ console.log(`${renderCommandHelp(PUBLIC_COMMAND_SURFACES.evolve)}
221
232
 
222
- Usage:
223
- selftune evolve [options] Run description evolution
224
- selftune evolve body [options] Evolve full body or routing table
225
- selftune evolve rollback [options] Rollback a previous evolution
233
+ Subcommands:
234
+ selftune evolve body [options] Evolve full body or routing table
235
+ selftune evolve rollback [options] Rollback a previous evolution
236
+ selftune evolve apply-proposal [options] Apply an approved contributor proposal
226
237
 
227
238
  Run 'selftune evolve <subcommand> --help' for subcommand-specific options.`);
228
239
  process.exit(0);
@@ -245,6 +256,11 @@ Run 'selftune evolve <subcommand> --help' for subcommand-specific options.`);
245
256
  await cliMain();
246
257
  break;
247
258
  }
259
+ case "apply-proposal": {
260
+ const { cliMain } = await import("./evolution/apply-proposal.js");
261
+ await cliMain();
262
+ break;
263
+ }
248
264
  default:
249
265
  throw new CLIError(
250
266
  `Unknown evolve target: ${sub}`,
@@ -271,6 +287,12 @@ Actions:
271
287
  composability Analyze skill co-occurrence conflicts
272
288
  family-overlap Detect sibling-skill overlap and consolidation pressure
273
289
 
290
+ Recommended creator loop:
291
+ 1. selftune eval generate --skill <name>
292
+ 2. selftune eval unit-test --skill <name> --generate --skill-path <path>
293
+ 3. selftune evolve --skill <name> --skill-path <path> --dry-run --validation-mode replay
294
+ 4. selftune grade baseline --skill <name> --skill-path <path>
295
+
274
296
  Run 'selftune eval <action> --help' for action-specific options.`);
275
297
  process.exit(0);
276
298
  }
@@ -327,7 +349,8 @@ Run 'selftune eval <action> --help' for action-specific options.`);
327
349
  "selftune eval composability --skill <name>",
328
350
  );
329
351
  }
330
- const logPath = values["telemetry-log"] ?? TELEMETRY_LOG;
352
+ const logPath =
353
+ typeof values["telemetry-log"] === "string" ? values["telemetry-log"] : TELEMETRY_LOG;
331
354
  let telemetry: unknown[];
332
355
  if (logPath === TELEMETRY_LOG) {
333
356
  try {
@@ -353,7 +376,19 @@ Run 'selftune eval <action> --help' for action-specific options.`);
353
376
  );
354
377
  }
355
378
  const windowSize = rawWindow === undefined ? undefined : Number(rawWindow);
356
- const report = analyzeComposability(values.skill, telemetry, windowSize);
379
+ const skillName = typeof values.skill === "string" ? values.skill : undefined;
380
+ if (!skillName) {
381
+ throw new CLIError(
382
+ "--skill <name> is required.",
383
+ "MISSING_FLAG",
384
+ "selftune eval composability --skill <name>",
385
+ );
386
+ }
387
+ const report = analyzeComposability(
388
+ skillName,
389
+ telemetry as import("./types.js").SessionTelemetryRecord[],
390
+ windowSize,
391
+ );
357
392
  console.log(JSON.stringify(report, null, 2));
358
393
  break;
359
394
  }
@@ -620,6 +655,11 @@ Options:
620
655
  await cliMain();
621
656
  break;
622
657
  }
658
+ case "registry": {
659
+ const { cliMain } = await import("./registry/index.js");
660
+ await cliMain();
661
+ break;
662
+ }
623
663
  case "alpha": {
624
664
  const sub = process.argv[2];
625
665
  if (!sub || sub === "--help" || sub === "-h") {
@@ -705,7 +745,7 @@ Output:
705
745
  userId: identity.user_id,
706
746
  agentType: readConfiguredAgentType(SELFTUNE_CONFIG_PATH, "unknown"),
707
747
  selftuneVersion: getSelftuneVersion(),
708
- dryRun: values["dry-run"] ?? false,
748
+ dryRun: values["dry-run"] === true,
709
749
  apiKey: identity.api_key,
710
750
  });
711
751
 
@@ -828,9 +868,12 @@ Output:
828
868
 
829
869
  case "codex":
830
870
  case "opencode":
831
- case "cline": {
871
+ case "cline":
872
+ case "pi": {
832
873
  const platform = command;
833
- const displayName = { codex: "Codex", opencode: "OpenCode", cline: "Cline" }[platform];
874
+ const displayName = { codex: "Codex", opencode: "OpenCode", cline: "Cline", pi: "Pi" }[
875
+ platform
876
+ ];
834
877
  const sub = process.argv[2];
835
878
  if (!sub || sub === "--help" || sub === "-h") {
836
879
  console.log(`selftune ${platform} — ${displayName} platform hooks
@@ -347,13 +347,15 @@ export function cliMain(): void {
347
347
  );
348
348
  }
349
349
 
350
- const projectsDir = values["projects-dir"] ?? CLAUDE_CODE_PROJECTS_DIR;
350
+ const projectsDir =
351
+ typeof values["projects-dir"] === "string" ? values["projects-dir"] : CLAUDE_CODE_PROJECTS_DIR;
351
352
  let since: Date | undefined;
352
- if (values.since) {
353
- since = new Date(values.since);
353
+ const sinceValue = typeof values.since === "string" ? values.since : undefined;
354
+ if (sinceValue) {
355
+ since = new Date(sinceValue);
354
356
  if (Number.isNaN(since.getTime())) {
355
357
  throw new CLIError(
356
- `Invalid --since date: "${values.since}"`,
358
+ `Invalid --since date: "${sinceValue}"`,
357
359
  "INVALID_FLAG",
358
360
  "selftune ingest claude --since 2026-01-01",
359
361
  );
@@ -376,32 +378,35 @@ export function cliMain(): void {
376
378
  );
377
379
 
378
380
  if (since) {
379
- console.log(` Filtering to sessions from ${values.since} onward.`);
381
+ console.log(` Filtering to sessions from ${sinceValue} onward.`);
380
382
  }
381
383
 
382
384
  let ingestedCount = 0;
383
385
  let skippedCount = 0;
384
386
 
387
+ const dryRun = values["dry-run"] === true;
388
+ const verbose = values.verbose === true;
389
+
385
390
  for (const transcriptFile of pending) {
386
391
  const session = parseSession(transcriptFile);
387
392
  if (session === null) {
388
- if (values.verbose) {
393
+ if (verbose) {
389
394
  console.log(` SKIP (empty/no queries): ${basename(transcriptFile)}`);
390
395
  }
391
396
  skippedCount += 1;
392
397
  continue;
393
398
  }
394
399
 
395
- if (values.verbose || values["dry-run"]) {
396
- console.log(` ${values["dry-run"] ? "[DRY] " : ""}Ingesting: ${basename(transcriptFile)}`);
400
+ if (verbose || dryRun) {
401
+ console.log(` ${dryRun ? "[DRY] " : ""}Ingesting: ${basename(transcriptFile)}`);
397
402
  }
398
403
 
399
- writeSession(session, values["dry-run"]);
404
+ writeSession(session, dryRun);
400
405
  newIngested.add(transcriptFile);
401
406
  ingestedCount += 1;
402
407
  }
403
408
 
404
- if (!values["dry-run"]) {
409
+ if (!dryRun) {
405
410
  saveMarker(CLAUDE_CODE_MARKER, new Set([...alreadyIngested, ...newIngested]));
406
411
  }
407
412
 
@@ -87,7 +87,7 @@ export function extractPromptFromArgs(args: string[]): string {
87
87
  }
88
88
 
89
89
  export interface ParsedCodexStream {
90
- thread_id: string;
90
+ thread_id?: string;
91
91
  tool_calls: Record<string, number>;
92
92
  total_tool_calls: number;
93
93
  bash_commands: string[];
@@ -96,7 +96,7 @@ export interface ParsedCodexStream {
96
96
  errors_encountered: number;
97
97
  input_tokens: number;
98
98
  output_tokens: number;
99
- agent_summary: string;
99
+ agent_summary?: string;
100
100
  transcript_chars: number;
101
101
  }
102
102
 
@@ -475,7 +475,7 @@ export async function cliMain(): Promise<void> {
475
475
  // Parse and log
476
476
  const metrics = parseJsonlStream(collectedLines, skillNames);
477
477
  const actualThreadId = metrics.thread_id;
478
- const sessionId = actualThreadId !== "unknown" ? actualThreadId : threadId;
478
+ const sessionId = actualThreadId && actualThreadId !== "unknown" ? actualThreadId : threadId;
479
479
 
480
480
  const { thread_id: _, ...metricsWithoutThread } = metrics;
481
481
 
@@ -210,7 +210,7 @@ export function readSessionsFromSqlite(
210
210
 
211
211
  // Get sessions
212
212
  let whereClause = "";
213
- const queryParams: unknown[] = [];
213
+ const queryParams: number[] = [];
214
214
  if (sinceTs) {
215
215
  whereClause = "WHERE created > ?";
216
216
  queryParams.push(Math.floor(sinceTs * 1000));
@@ -239,7 +239,7 @@ export function readSessionsFromSqlite(
239
239
  try {
240
240
  msgRows = db
241
241
  .query(`SELECT * FROM ${safeMessagesTable} WHERE session_id = ? ORDER BY created ASC`)
242
- .all(sessionRow.id) as Array<Record<string, unknown>>;
242
+ .all(String(sessionRow.id)) as Array<Record<string, unknown>>;
243
243
  } catch {
244
244
  continue;
245
245
  }