selftune 0.2.16 → 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 (91) hide show
  1. package/README.md +32 -22
  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/build-payloads.ts +14 -1
  8. package/cli/selftune/alpha-upload/client.ts +51 -1
  9. package/cli/selftune/alpha-upload/flush.ts +46 -5
  10. package/cli/selftune/alpha-upload/stage-canonical.ts +32 -10
  11. package/cli/selftune/alpha-upload-contract.ts +9 -0
  12. package/cli/selftune/constants.ts +92 -5
  13. package/cli/selftune/contribute/contribute.ts +30 -2
  14. package/cli/selftune/contribute/sanitize.ts +52 -5
  15. package/cli/selftune/contribution-config.ts +249 -0
  16. package/cli/selftune/contribution-relay.ts +177 -0
  17. package/cli/selftune/contribution-signals.ts +219 -0
  18. package/cli/selftune/contribution-staging.ts +147 -0
  19. package/cli/selftune/contributions.ts +532 -0
  20. package/cli/selftune/creator-contributions.ts +333 -0
  21. package/cli/selftune/dashboard-contract.ts +305 -1
  22. package/cli/selftune/dashboard-server.ts +47 -13
  23. package/cli/selftune/eval/family-overlap.ts +395 -0
  24. package/cli/selftune/eval/hooks-to-evals.ts +182 -28
  25. package/cli/selftune/eval/synthetic-evals.ts +298 -11
  26. package/cli/selftune/evolution/description-quality.ts +12 -11
  27. package/cli/selftune/evolution/evolve.ts +214 -51
  28. package/cli/selftune/evolution/validate-proposal.ts +9 -6
  29. package/cli/selftune/export.ts +2 -2
  30. package/cli/selftune/grading/grade-session.ts +20 -0
  31. package/cli/selftune/hooks/commit-track.ts +188 -0
  32. package/cli/selftune/hooks/prompt-log.ts +10 -1
  33. package/cli/selftune/hooks/session-stop.ts +2 -2
  34. package/cli/selftune/hooks/skill-eval.ts +15 -1
  35. package/cli/selftune/hooks/stdin-preview.ts +32 -0
  36. package/cli/selftune/index.ts +41 -5
  37. package/cli/selftune/ingestors/codex-rollout.ts +31 -35
  38. package/cli/selftune/ingestors/codex-wrapper.ts +32 -24
  39. package/cli/selftune/localdb/db.ts +2 -2
  40. package/cli/selftune/localdb/direct-write.ts +69 -6
  41. package/cli/selftune/localdb/queries.ts +1253 -37
  42. package/cli/selftune/localdb/schema.ts +66 -0
  43. package/cli/selftune/orchestrate.ts +32 -4
  44. package/cli/selftune/recover.ts +153 -0
  45. package/cli/selftune/repair/skill-usage.ts +363 -4
  46. package/cli/selftune/routes/actions.ts +35 -1
  47. package/cli/selftune/routes/analytics.ts +14 -0
  48. package/cli/selftune/routes/index.ts +1 -0
  49. package/cli/selftune/routes/overview.ts +150 -4
  50. package/cli/selftune/routes/skill-report.ts +648 -18
  51. package/cli/selftune/status.ts +81 -2
  52. package/cli/selftune/sync.ts +56 -2
  53. package/cli/selftune/trust-model.ts +66 -0
  54. package/cli/selftune/types.ts +80 -0
  55. package/cli/selftune/utils/skill-detection.ts +43 -0
  56. package/cli/selftune/utils/transcript.ts +210 -1
  57. package/cli/selftune/watchlist.ts +65 -0
  58. package/node_modules/@selftune/telemetry-contract/src/types.ts +11 -0
  59. package/package.json +1 -1
  60. package/packages/telemetry-contract/src/types.ts +11 -0
  61. package/packages/ui/src/components/ActivityTimeline.tsx +165 -150
  62. package/packages/ui/src/components/EvidenceViewer.tsx +335 -144
  63. package/packages/ui/src/components/EvolutionTimeline.tsx +58 -28
  64. package/packages/ui/src/components/OrchestrateRunsPanel.tsx +33 -16
  65. package/packages/ui/src/components/RecentActivityFeed.tsx +72 -41
  66. package/packages/ui/src/components/section-cards.tsx +12 -9
  67. package/packages/ui/src/primitives/card.tsx +1 -1
  68. package/skill/SKILL.md +40 -2
  69. package/skill/Workflows/AlphaUpload.md +4 -0
  70. package/skill/Workflows/Composability.md +64 -0
  71. package/skill/Workflows/Contribute.md +6 -3
  72. package/skill/Workflows/Contributions.md +97 -0
  73. package/skill/Workflows/CreatorContributions.md +74 -0
  74. package/skill/Workflows/Dashboard.md +31 -0
  75. package/skill/Workflows/Evals.md +57 -8
  76. package/skill/Workflows/Evolve.md +31 -13
  77. package/skill/Workflows/ExportCanonical.md +121 -0
  78. package/skill/Workflows/Hook.md +131 -0
  79. package/skill/Workflows/Ingest.md +7 -0
  80. package/skill/Workflows/Initialize.md +29 -9
  81. package/skill/Workflows/Orchestrate.md +27 -5
  82. package/skill/Workflows/Quickstart.md +94 -0
  83. package/skill/Workflows/Recover.md +84 -0
  84. package/skill/Workflows/RepairSkillUsage.md +95 -0
  85. package/skill/Workflows/Sync.md +18 -12
  86. package/skill/Workflows/Uninstall.md +82 -0
  87. package/skill/settings_snippet.json +11 -0
  88. package/apps/local-dashboard/dist/assets/index-BMIS6uUh.css +0 -2
  89. package/apps/local-dashboard/dist/assets/index-DOu3iLD9.js +0 -16
  90. package/apps/local-dashboard/dist/assets/vendor-table-pHbDxq36.js +0 -8
  91. package/apps/local-dashboard/dist/assets/vendor-ui-DIwlrGlb.js +0 -12
@@ -191,14 +191,17 @@ export function writeSessionTelemetryToDb(record: SessionTelemetryRecord): boole
191
191
  return safeWrite("session-telemetry", (db) => {
192
192
  getStmt(
193
193
  db,
194
- "session-telemetry",
194
+ "session-telemetry-v4",
195
195
  `
196
196
  INSERT INTO session_telemetry
197
197
  (session_id, timestamp, cwd, transcript_path, tool_calls_json,
198
198
  total_tool_calls, bash_commands_json, skills_triggered_json,
199
199
  skills_invoked_json, assistant_turns, errors_encountered,
200
- transcript_chars, last_user_query, source, input_tokens, output_tokens)
201
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
200
+ transcript_chars, last_user_query, source, input_tokens, output_tokens,
201
+ cached_input_tokens, reasoning_output_tokens, cost_usd,
202
+ files_changed, lines_added, lines_removed, lines_modified,
203
+ artifact_count, session_type, agent_summary)
204
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
202
205
  ON CONFLICT(session_id) DO UPDATE SET
203
206
  timestamp = excluded.timestamp,
204
207
  tool_calls_json = excluded.tool_calls_json,
@@ -211,7 +214,17 @@ export function writeSessionTelemetryToDb(record: SessionTelemetryRecord): boole
211
214
  transcript_chars = excluded.transcript_chars,
212
215
  last_user_query = excluded.last_user_query,
213
216
  input_tokens = COALESCE(excluded.input_tokens, session_telemetry.input_tokens),
214
- output_tokens = COALESCE(excluded.output_tokens, session_telemetry.output_tokens)
217
+ output_tokens = COALESCE(excluded.output_tokens, session_telemetry.output_tokens),
218
+ cached_input_tokens = COALESCE(excluded.cached_input_tokens, session_telemetry.cached_input_tokens),
219
+ reasoning_output_tokens = COALESCE(excluded.reasoning_output_tokens, session_telemetry.reasoning_output_tokens),
220
+ cost_usd = COALESCE(excluded.cost_usd, session_telemetry.cost_usd),
221
+ files_changed = COALESCE(excluded.files_changed, session_telemetry.files_changed),
222
+ lines_added = COALESCE(excluded.lines_added, session_telemetry.lines_added),
223
+ lines_removed = COALESCE(excluded.lines_removed, session_telemetry.lines_removed),
224
+ lines_modified = COALESCE(excluded.lines_modified, session_telemetry.lines_modified),
225
+ artifact_count = COALESCE(excluded.artifact_count, session_telemetry.artifact_count),
226
+ session_type = COALESCE(excluded.session_type, session_telemetry.session_type),
227
+ agent_summary = COALESCE(excluded.agent_summary, session_telemetry.agent_summary)
215
228
  `,
216
229
  ).run(
217
230
  record.session_id,
@@ -230,6 +243,16 @@ export function writeSessionTelemetryToDb(record: SessionTelemetryRecord): boole
230
243
  record.source ?? null,
231
244
  record.input_tokens ?? null,
232
245
  record.output_tokens ?? null,
246
+ record.cached_input_tokens ?? null,
247
+ record.reasoning_output_tokens ?? null,
248
+ record.cost_usd ?? null,
249
+ record.files_changed ?? null,
250
+ record.lines_added ?? null,
251
+ record.lines_removed ?? null,
252
+ record.lines_modified ?? null,
253
+ record.artifact_count ?? null,
254
+ record.session_type ?? null,
255
+ record.agent_summary ?? null,
233
256
  );
234
257
  });
235
258
  }
@@ -444,6 +467,34 @@ export function updateSignalConsumed(
444
467
  return result?.changes > 0;
445
468
  }
446
469
 
470
+ export function writeCommitTracking(record: {
471
+ session_id: string;
472
+ commit_sha: string;
473
+ commit_title?: string;
474
+ branch?: string;
475
+ repo_remote?: string;
476
+ timestamp: string;
477
+ }): boolean {
478
+ return safeWrite("commit-tracking", (db) => {
479
+ getStmt(
480
+ db,
481
+ "commit-tracking",
482
+ `
483
+ INSERT INTO commit_tracking
484
+ (session_id, commit_sha, commit_title, branch, repo_remote, timestamp)
485
+ VALUES (?, ?, ?, ?, ?, ?)
486
+ `,
487
+ ).run(
488
+ record.session_id,
489
+ record.commit_sha,
490
+ record.commit_title ?? null,
491
+ record.branch ?? null,
492
+ record.repo_remote ?? null,
493
+ record.timestamp,
494
+ );
495
+ });
496
+ }
497
+
447
498
  // -- Internal insert helpers (used by cached statements) ----------------------
448
499
 
449
500
  function insertSession(db: Database, s: CanonicalSessionRecord): void {
@@ -581,14 +632,17 @@ function insertSkillInvocation(
581
632
  function insertExecutionFact(db: Database, ef: CanonicalExecutionFactRecord): void {
582
633
  getStmt(
583
634
  db,
584
- "execution-fact",
635
+ "execution-fact-v3",
585
636
  `
586
637
  INSERT INTO execution_facts
587
638
  (session_id, occurred_at, prompt_id, tool_calls_json, total_tool_calls,
588
639
  assistant_turns, errors_encountered, input_tokens, output_tokens,
640
+ cached_input_tokens, reasoning_output_tokens, cost_usd,
641
+ files_changed, lines_added, lines_removed, lines_modified,
642
+ artifact_count, session_type,
589
643
  duration_ms, completion_status,
590
644
  schema_version, platform, normalized_at, normalizer_version, capture_mode, raw_source_ref)
591
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
645
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
592
646
  `,
593
647
  ).run(
594
648
  ef.session_id,
@@ -600,6 +654,15 @@ function insertExecutionFact(db: Database, ef: CanonicalExecutionFactRecord): vo
600
654
  ef.errors_encountered,
601
655
  ef.input_tokens ?? null,
602
656
  ef.output_tokens ?? null,
657
+ ef.cached_input_tokens ?? null,
658
+ ef.reasoning_output_tokens ?? null,
659
+ ef.cost_usd ?? null,
660
+ ef.files_changed ?? null,
661
+ ef.lines_added ?? null,
662
+ ef.lines_removed ?? null,
663
+ ef.lines_modified ?? null,
664
+ ef.artifact_count ?? null,
665
+ ef.session_type ?? null,
603
666
  ef.duration_ms ?? null,
604
667
  ef.completion_status ?? null,
605
668
  ef.schema_version ?? null,