mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-03-31 22:23:27 +08:00
feat: self-improving skills loop — observe, inspect, amend, evaluate
- Add skill health observation layer (execution logging, success/failure tracking) - Add skill health inspector (trace recurring failures across runs) - Add amendify mechanism (propose SKILL.md patches from failure evidence) - Add evaluation scaffolding (compare amended vs original performance) - Wire into session-inspect CLI: skills:health, skills:amendify, skills:evaluate - 1145/1145 tests passing (+3 new)
This commit is contained in:
@@ -5,6 +5,10 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const { createAdapterRegistry, inspectSessionTarget } = require('./lib/session-adapters/registry');
|
||||
const { readSkillObservations } = require('./lib/skill-improvement/observations');
|
||||
const { buildSkillHealthReport } = require('./lib/skill-improvement/health');
|
||||
const { proposeSkillAmendment } = require('./lib/skill-improvement/amendify');
|
||||
const { buildSkillEvaluationScaffold } = require('./lib/skill-improvement/evaluate');
|
||||
|
||||
function usage() {
|
||||
console.log([
|
||||
@@ -18,12 +22,17 @@ function usage() {
|
||||
' claude:latest Most recent Claude session history entry',
|
||||
' claude:<id|alias> Specific Claude session or alias',
|
||||
' <session.tmp> Direct path to a Claude session file',
|
||||
' skills:health Inspect skill failure/success patterns from observations',
|
||||
' skills:amendify Propose a SKILL.md patch from failure evidence',
|
||||
' skills:evaluate Compare baseline vs amended skill outcomes',
|
||||
'',
|
||||
'Examples:',
|
||||
' node scripts/session-inspect.js .claude/plan/workflow.json',
|
||||
' node scripts/session-inspect.js workflow-visual-proof',
|
||||
' node scripts/session-inspect.js claude:latest',
|
||||
' node scripts/session-inspect.js latest --target-type claude-history',
|
||||
' node scripts/session-inspect.js skills:health',
|
||||
' node scripts/session-inspect.js skills:amendify --skill api-design',
|
||||
' node scripts/session-inspect.js claude:a1b2c3d4 --write /tmp/session.json'
|
||||
].join('\n'));
|
||||
}
|
||||
@@ -39,14 +48,57 @@ function parseArgs(argv) {
|
||||
const targetTypeIndex = args.indexOf('--target-type');
|
||||
const targetType = targetTypeIndex >= 0 ? args[targetTypeIndex + 1] : null;
|
||||
|
||||
const skillIndex = args.indexOf('--skill');
|
||||
const skillId = skillIndex >= 0 ? args[skillIndex + 1] : null;
|
||||
|
||||
const amendmentIndex = args.indexOf('--amendment-id');
|
||||
const amendmentId = amendmentIndex >= 0 ? args[amendmentIndex + 1] : null;
|
||||
|
||||
const observationsIndex = args.indexOf('--observations');
|
||||
const observationsPath = observationsIndex >= 0 ? args[observationsIndex + 1] : null;
|
||||
|
||||
const writeIndex = args.indexOf('--write');
|
||||
const writePath = writeIndex >= 0 ? args[writeIndex + 1] : null;
|
||||
|
||||
return { target, adapterId, targetType, writePath, listAdapters };
|
||||
return { target, adapterId, targetType, writePath, listAdapters, skillId, amendmentId, observationsPath };
|
||||
}
|
||||
|
||||
function inspectSkillLoopTarget(target, options = {}) {
|
||||
const observations = readSkillObservations({
|
||||
cwd: options.cwd,
|
||||
projectRoot: options.cwd,
|
||||
observationsPath: options.observationsPath
|
||||
});
|
||||
|
||||
if (target === 'skills:health') {
|
||||
return buildSkillHealthReport(observations, {
|
||||
skillId: options.skillId || null
|
||||
});
|
||||
}
|
||||
|
||||
if (target === 'skills:amendify') {
|
||||
if (!options.skillId) {
|
||||
throw new Error('skills:amendify requires --skill <id>');
|
||||
}
|
||||
|
||||
return proposeSkillAmendment(options.skillId, observations);
|
||||
}
|
||||
|
||||
if (target === 'skills:evaluate') {
|
||||
if (!options.skillId) {
|
||||
throw new Error('skills:evaluate requires --skill <id>');
|
||||
}
|
||||
|
||||
return buildSkillEvaluationScaffold(options.skillId, observations, {
|
||||
amendmentId: options.amendmentId || null
|
||||
});
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function main() {
|
||||
const { target, adapterId, targetType, writePath, listAdapters } = parseArgs(process.argv);
|
||||
const { target, adapterId, targetType, writePath, listAdapters, skillId, amendmentId, observationsPath } = parseArgs(process.argv);
|
||||
|
||||
if (listAdapters) {
|
||||
const registry = createAdapterRegistry();
|
||||
@@ -59,12 +111,20 @@ function main() {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const inspectTarget = targetType ? { type: targetType, value: target } : target;
|
||||
const snapshot = inspectSessionTarget(inspectTarget, {
|
||||
const skillLoopPayload = inspectSkillLoopTarget(target, {
|
||||
cwd: process.cwd(),
|
||||
adapterId
|
||||
skillId,
|
||||
amendmentId,
|
||||
observationsPath
|
||||
});
|
||||
const payload = JSON.stringify(snapshot, null, 2);
|
||||
const payloadObject = skillLoopPayload || inspectSessionTarget(
|
||||
targetType ? { type: targetType, value: target } : target,
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
adapterId
|
||||
}
|
||||
);
|
||||
const payload = JSON.stringify(payloadObject, null, 2);
|
||||
|
||||
if (writePath) {
|
||||
const absoluteWritePath = path.resolve(writePath);
|
||||
|
||||
Reference in New Issue
Block a user