selftune 0.2.0 → 0.2.2
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/.claude/agents/diagnosis-analyst.md +20 -10
- package/.claude/agents/evolution-reviewer.md +14 -1
- package/.claude/agents/integration-guide.md +18 -6
- package/.claude/agents/pattern-analyst.md +18 -5
- package/CHANGELOG.md +12 -4
- package/README.md +43 -35
- package/apps/local-dashboard/dist/assets/geist-cyrillic-wght-normal-CHSlOQsW.woff2 +0 -0
- package/apps/local-dashboard/dist/assets/geist-latin-ext-wght-normal-DMtmJ5ZE.woff2 +0 -0
- package/apps/local-dashboard/dist/assets/geist-latin-wght-normal-Dm3htQBi.woff2 +0 -0
- package/apps/local-dashboard/dist/assets/index-C4EOTFZ2.js +15 -0
- package/apps/local-dashboard/dist/assets/index-bl-Webyd.css +1 -0
- package/apps/local-dashboard/dist/assets/vendor-react-U7zYD9Rg.js +60 -0
- package/apps/local-dashboard/dist/assets/vendor-table-B7VF2Ipl.js +26 -0
- package/apps/local-dashboard/dist/assets/vendor-ui-D7_zX_qy.js +346 -0
- package/apps/local-dashboard/dist/favicon.png +0 -0
- package/apps/local-dashboard/dist/index.html +17 -0
- package/apps/local-dashboard/dist/logo.png +0 -0
- package/apps/local-dashboard/dist/logo.svg +9 -0
- package/cli/selftune/badge/badge-data.ts +1 -1
- package/cli/selftune/badge/badge.ts +4 -8
- package/cli/selftune/canonical-export.ts +183 -0
- package/cli/selftune/constants.ts +28 -0
- package/cli/selftune/contribute/contribute.ts +1 -1
- package/cli/selftune/cron/setup.ts +17 -17
- package/cli/selftune/dashboard-contract.ts +202 -0
- package/cli/selftune/dashboard-server.ts +653 -186
- package/cli/selftune/dashboard.ts +41 -176
- package/cli/selftune/eval/baseline.ts +5 -4
- package/cli/selftune/eval/composability-v2.ts +273 -0
- package/cli/selftune/eval/hooks-to-evals.ts +34 -15
- package/cli/selftune/eval/unit-test-cli.ts +1 -1
- package/cli/selftune/evolution/evidence.ts +26 -0
- package/cli/selftune/evolution/evolve-body.ts +105 -11
- package/cli/selftune/evolution/evolve.ts +371 -25
- package/cli/selftune/evolution/extract-patterns.ts +87 -29
- package/cli/selftune/evolution/rollback.ts +2 -2
- package/cli/selftune/grading/auto-grade.ts +200 -0
- package/cli/selftune/grading/grade-session.ts +448 -97
- package/cli/selftune/grading/results.ts +42 -0
- package/cli/selftune/hooks/prompt-log.ts +172 -2
- package/cli/selftune/hooks/session-stop.ts +123 -3
- package/cli/selftune/hooks/skill-eval.ts +119 -3
- package/cli/selftune/index.ts +395 -116
- package/cli/selftune/ingestors/claude-replay.ts +140 -114
- package/cli/selftune/ingestors/codex-rollout.ts +345 -46
- package/cli/selftune/ingestors/codex-wrapper.ts +207 -39
- package/cli/selftune/ingestors/openclaw-ingest.ts +141 -8
- package/cli/selftune/ingestors/opencode-ingest.ts +193 -17
- package/cli/selftune/init.ts +227 -14
- package/cli/selftune/last.ts +14 -5
- package/cli/selftune/localdb/db.ts +63 -0
- package/cli/selftune/localdb/materialize.ts +428 -0
- package/cli/selftune/localdb/queries.ts +376 -0
- package/cli/selftune/localdb/schema.ts +204 -0
- package/cli/selftune/monitoring/watch.ts +66 -15
- package/cli/selftune/normalization.ts +682 -0
- package/cli/selftune/observability.ts +19 -44
- package/cli/selftune/orchestrate.ts +1073 -0
- package/cli/selftune/quickstart.ts +203 -0
- package/cli/selftune/repair/skill-usage.ts +576 -0
- package/cli/selftune/schedule.ts +561 -0
- package/cli/selftune/status.ts +48 -26
- package/cli/selftune/sync.ts +627 -0
- package/cli/selftune/types.ts +148 -0
- package/cli/selftune/utils/canonical-log.ts +45 -0
- package/cli/selftune/utils/hooks.ts +41 -0
- package/cli/selftune/utils/html.ts +27 -0
- package/cli/selftune/utils/llm-call.ts +78 -20
- package/cli/selftune/utils/math.ts +10 -0
- package/cli/selftune/utils/query-filter.ts +139 -0
- package/cli/selftune/utils/skill-discovery.ts +340 -0
- package/cli/selftune/utils/skill-log.ts +68 -0
- package/cli/selftune/utils/skill-usage-confidence.ts +18 -0
- package/cli/selftune/utils/transcript.ts +272 -26
- package/cli/selftune/workflows/discover.ts +254 -0
- package/cli/selftune/workflows/skill-md-writer.ts +288 -0
- package/cli/selftune/workflows/workflows.ts +188 -0
- package/package.json +21 -8
- package/packages/telemetry-contract/README.md +11 -0
- package/packages/telemetry-contract/fixtures/golden.json +87 -0
- package/packages/telemetry-contract/fixtures/golden.test.ts +42 -0
- package/packages/telemetry-contract/index.ts +1 -0
- package/packages/telemetry-contract/package.json +19 -0
- package/packages/telemetry-contract/src/index.ts +2 -0
- package/packages/telemetry-contract/src/types.ts +163 -0
- package/packages/telemetry-contract/src/validators.ts +109 -0
- package/skill/SKILL.md +84 -53
- package/skill/Workflows/AutoActivation.md +17 -16
- package/skill/Workflows/Badge.md +6 -0
- package/skill/Workflows/Baseline.md +46 -23
- package/skill/Workflows/Composability.md +12 -5
- package/skill/Workflows/Contribute.md +17 -14
- package/skill/Workflows/Cron.md +56 -79
- package/skill/Workflows/Dashboard.md +45 -34
- package/skill/Workflows/Doctor.md +30 -17
- package/skill/Workflows/Evals.md +64 -40
- package/skill/Workflows/EvolutionMemory.md +2 -0
- package/skill/Workflows/Evolve.md +102 -47
- package/skill/Workflows/EvolveBody.md +6 -6
- package/skill/Workflows/Grade.md +36 -31
- package/skill/Workflows/ImportSkillsBench.md +11 -5
- package/skill/Workflows/Ingest.md +43 -36
- package/skill/Workflows/Initialize.md +44 -30
- package/skill/Workflows/Orchestrate.md +139 -0
- package/skill/Workflows/Replay.md +39 -18
- package/skill/Workflows/Rollback.md +3 -3
- package/skill/Workflows/Schedule.md +61 -0
- package/skill/Workflows/Sync.md +88 -0
- package/skill/Workflows/UnitTest.md +34 -22
- package/skill/Workflows/Watch.md +14 -4
- package/skill/Workflows/Workflows.md +129 -0
- package/skill/assets/activation-rules-default.json +26 -0
- package/skill/assets/multi-skill-settings.json +63 -0
- package/skill/assets/single-skill-settings.json +57 -0
- package/skill/references/invocation-taxonomy.md +2 -2
- package/skill/references/logs.md +164 -2
- package/skill/references/setup-patterns.md +65 -0
- package/skill/references/version-history.md +40 -0
- package/skill/settings_snippet.json +1 -1
- package/templates/multi-skill-settings.json +7 -7
- package/templates/single-skill-settings.json +6 -6
- package/dashboard/index.html +0 -1680
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
* - Hook installation checks
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { execSync } from "node:child_process";
|
|
12
11
|
import { existsSync, readFileSync } from "node:fs";
|
|
13
12
|
import { homedir } from "node:os";
|
|
14
13
|
import { join } from "node:path";
|
|
15
14
|
import { LOG_DIR, REQUIRED_FIELDS, SELFTUNE_CONFIG_PATH } from "./constants.js";
|
|
16
15
|
import type { DoctorResult, HealthCheck, HealthStatus, SelftuneConfig } from "./types.js";
|
|
16
|
+
import { missingClaudeCodeHookKeys } from "./utils/hooks.js";
|
|
17
17
|
|
|
18
|
-
const VALID_AGENT_TYPES = new Set(["claude_code", "codex", "opencode", "unknown"]);
|
|
18
|
+
const VALID_AGENT_TYPES = new Set(["claude_code", "codex", "opencode", "openclaw", "unknown"]);
|
|
19
19
|
const VALID_LLM_MODES = new Set(["agent"]);
|
|
20
20
|
|
|
21
21
|
const LOG_FILES: Record<string, string> = {
|
|
@@ -25,12 +25,20 @@ const LOG_FILES: Record<string, string> = {
|
|
|
25
25
|
evolution_audit: join(LOG_DIR, "evolution_audit_log.jsonl"),
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Maximum number of lines to validate in a JSONL health check.
|
|
30
|
+
* Large log files (60k+ lines) can take many seconds to fully parse,
|
|
31
|
+
* so we sample the first N lines for the health check.
|
|
32
|
+
*/
|
|
33
|
+
const MAX_VALIDATION_LINES = 500;
|
|
29
34
|
|
|
30
35
|
/**
|
|
31
36
|
* Validate a JSONL file: parse each line as JSON and check that all
|
|
32
37
|
* `requiredFields` are present. Returns a status/message pair suitable
|
|
33
38
|
* for embedding in a {@link HealthCheck}.
|
|
39
|
+
*
|
|
40
|
+
* For performance, only the first {@link MAX_VALIDATION_LINES} non-blank
|
|
41
|
+
* lines are validated. The total line count still reflects the full file.
|
|
34
42
|
*/
|
|
35
43
|
function validateJsonlFile(
|
|
36
44
|
filePath: string,
|
|
@@ -39,12 +47,15 @@ function validateJsonlFile(
|
|
|
39
47
|
let lineCount = 0;
|
|
40
48
|
let parseErrors = 0;
|
|
41
49
|
let schemaErrors = 0;
|
|
50
|
+
let validatedCount = 0;
|
|
42
51
|
|
|
43
52
|
const content = readFileSync(filePath, "utf-8");
|
|
44
53
|
for (const line of content.split("\n")) {
|
|
45
54
|
const trimmed = line.trim();
|
|
46
55
|
if (!trimmed) continue;
|
|
47
56
|
lineCount++;
|
|
57
|
+
if (validatedCount >= MAX_VALIDATION_LINES) continue;
|
|
58
|
+
validatedCount++;
|
|
48
59
|
try {
|
|
49
60
|
const record = JSON.parse(trimmed);
|
|
50
61
|
const keys = new Set(Object.keys(record));
|
|
@@ -62,7 +73,7 @@ function validateJsonlFile(
|
|
|
62
73
|
if (parseErrors > 0 || schemaErrors > 0) {
|
|
63
74
|
return {
|
|
64
75
|
status: "fail",
|
|
65
|
-
message: `${lineCount} records, ${parseErrors} parse errors, ${schemaErrors} schema errors`,
|
|
76
|
+
message: `${lineCount} records (${validatedCount} validated), ${parseErrors} parse errors, ${schemaErrors} schema errors`,
|
|
66
77
|
};
|
|
67
78
|
}
|
|
68
79
|
return { status: "pass", message: `${lineCount} records, all valid` };
|
|
@@ -92,37 +103,9 @@ export function checkLogHealth(): HealthCheck[] {
|
|
|
92
103
|
export function checkHookInstallation(): HealthCheck[] {
|
|
93
104
|
const checks: HealthCheck[] = [];
|
|
94
105
|
|
|
95
|
-
//
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
repoRoot = execSync("git rev-parse --show-toplevel", {
|
|
99
|
-
encoding: "utf-8",
|
|
100
|
-
timeout: 5000,
|
|
101
|
-
}).trim();
|
|
102
|
-
} catch {
|
|
103
|
-
// Not inside a git repo -- fall back to cwd
|
|
104
|
-
repoRoot = process.cwd();
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
for (const hook of HOOK_FILES) {
|
|
108
|
-
const hookPath = join(repoRoot, ".git", "hooks", hook);
|
|
109
|
-
const check: HealthCheck = {
|
|
110
|
-
name: `hook_${hook}`,
|
|
111
|
-
path: hookPath,
|
|
112
|
-
status: "pass",
|
|
113
|
-
message: "",
|
|
114
|
-
};
|
|
115
|
-
if (existsSync(hookPath)) {
|
|
116
|
-
check.status = "pass";
|
|
117
|
-
check.message = "Hook file present";
|
|
118
|
-
} else {
|
|
119
|
-
check.status = "fail";
|
|
120
|
-
check.message = "Hook file missing";
|
|
121
|
-
}
|
|
122
|
-
checks.push(check);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Also check if hooks are configured in Claude Code settings
|
|
106
|
+
// Check if hooks are configured in Claude Code settings.json
|
|
107
|
+
// Claude Code uses hook keys: UserPromptSubmit, PreToolUse, PostToolUse, Stop
|
|
108
|
+
// (not the old kebab-case names like prompt-submit, post-tool-use, session-stop)
|
|
126
109
|
const settingsPath = join(homedir(), ".claude", "settings.json");
|
|
127
110
|
const settingsCheck: HealthCheck = {
|
|
128
111
|
name: "hook_settings",
|
|
@@ -142,15 +125,7 @@ export function checkHookInstallation(): HealthCheck[] {
|
|
|
142
125
|
settingsCheck.status = "warn";
|
|
143
126
|
settingsCheck.message = "No hooks section in settings.json";
|
|
144
127
|
} else {
|
|
145
|
-
const
|
|
146
|
-
const missing = hookKeys.filter((k) => {
|
|
147
|
-
const entries = hooks[k];
|
|
148
|
-
if (!Array.isArray(entries) || entries.length === 0) return true;
|
|
149
|
-
return !entries.some(
|
|
150
|
-
(e: { command?: string }) =>
|
|
151
|
-
typeof e.command === "string" && e.command.includes("selftune"),
|
|
152
|
-
);
|
|
153
|
-
});
|
|
128
|
+
const missing = missingClaudeCodeHookKeys(hooks as Record<string, unknown>);
|
|
154
129
|
if (missing.length > 0) {
|
|
155
130
|
settingsCheck.status = "warn";
|
|
156
131
|
settingsCheck.message = `Selftune hooks not configured for: ${missing.join(", ")}`;
|