codymaster 4.6.0 → 5.2.0
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/CHANGELOG.md +74 -8
- package/README.md +192 -95
- package/dist/advisory-handoff.js +89 -0
- package/dist/advisory-report.js +105 -0
- package/dist/browse-server.js +251 -0
- package/dist/cli/command-registry.js +34 -0
- package/dist/cli/commands/agent.js +120 -0
- package/dist/cli/commands/bench.js +69 -0
- package/dist/cli/commands/brain.js +108 -0
- package/dist/cli/commands/dashboard.js +93 -0
- package/dist/cli/commands/design-studio.js +111 -0
- package/dist/cli/commands/distro.js +25 -0
- package/dist/cli/commands/engineering.js +596 -0
- package/dist/cli/commands/evolve.js +123 -0
- package/dist/cli/commands/mcp-serve.js +104 -0
- package/dist/cli/commands/project.js +324 -0
- package/dist/cli/commands/skill-chain.js +269 -0
- package/dist/cli/commands/system.js +89 -0
- package/dist/cli/commands/task.js +254 -0
- package/dist/cli/update-check.js +83 -0
- package/dist/cm-config.js +92 -0
- package/dist/cm-suggest.js +77 -0
- package/dist/codybench/judges/automated.js +31 -0
- package/dist/codybench/runners/claude-code.js +32 -0
- package/dist/codybench/suites/memory-retention.js +85 -0
- package/dist/codybench/suites/tdd-regression.js +35 -0
- package/dist/codybench/suites/token-efficiency.js +55 -0
- package/dist/codybench/types.js +2 -0
- package/dist/context-db.js +157 -0
- package/dist/continuity.js +2 -6
- package/dist/distro-validate.js +54 -0
- package/dist/execution-analyzer.js +138 -0
- package/dist/guardian-core.js +74 -0
- package/dist/index.js +36 -2759
- package/dist/indexer/skills-lib.js +533 -0
- package/dist/indexer/skills-map.js +1374 -0
- package/dist/indexer/skills.js +16 -0
- package/dist/learning-promoter.js +246 -0
- package/dist/mcp-context-server.js +289 -1
- package/dist/mcp-skills-tools.js +81 -0
- package/dist/retro-summary.js +70 -0
- package/dist/second-opinion-providers.js +79 -0
- package/dist/skill-chain.js +63 -1
- package/dist/skill-evolver.js +456 -0
- package/dist/skill-execution-cache.js +254 -0
- package/dist/smart-brain-router.js +184 -0
- package/dist/sprint-pipeline.js +228 -0
- package/dist/storage-backend.js +14 -67
- package/dist/token-budget.js +88 -0
- package/dist/utils/cli-utils.js +76 -0
- package/dist/utils/skill-utils.js +32 -0
- package/package.json +17 -7
- package/scripts/build-skills.mjs +51 -0
- package/scripts/gate-0-repo-hygiene.js +75 -0
- package/scripts/postinstall.js +34 -28
- package/scripts/security-scan.js +1 -1
- package/scripts/validate-skills.mjs +42 -0
- package/skills/CLAUDE.md +2 -7
- package/skills/_shared/helpers.md +2 -8
- package/skills/cm-ads-tracker/SKILL.md +3 -6
- package/skills/cm-browse/SKILL.md +34 -0
- package/skills/cm-conductor-worktrees/SKILL.md +28 -0
- package/skills/cm-content-factory/SKILL.md +1 -1
- package/skills/cm-content-factory/landing/docs/content/changelog.md +36 -0
- package/skills/cm-content-factory/landing/docs/content/deployment.md +46 -0
- package/skills/cm-content-factory/landing/docs/content/execution-flow.md +67 -0
- package/skills/cm-content-factory/landing/docs/content/memory-system.md +38 -0
- package/skills/cm-content-factory/landing/docs/content/openspace.md +27 -0
- package/skills/cm-content-factory/landing/docs/content/use-cases.md +26 -0
- package/skills/cm-content-factory/landing/docs/content/v5-intro.md +28 -0
- package/skills/cm-content-factory/landing/docs/index.html +240 -0
- package/skills/cm-content-factory/landing/index.html +100 -100
- package/skills/cm-content-factory/landing/script.js +42 -0
- package/skills/cm-content-factory/landing/translations.js +400 -400
- package/skills/cm-continuity/SKILL.md +32 -33
- package/skills/cm-design-studio/SKILL.md +34 -0
- package/skills/cm-ecosystem-roadmap/SKILL.md +15 -0
- package/skills/cm-engineering-meta/SKILL.md +73 -0
- package/skills/cm-growth-hacking/SKILL.md +1 -12
- package/skills/cm-guardian-runtime/SKILL.md +26 -0
- package/skills/cm-mcp-engineering/SKILL.md +22 -0
- package/skills/cm-notebooklm/SKILL.md +1 -17
- package/skills/cm-post-deploy-canary/SKILL.md +22 -0
- package/skills/cm-project-bootstrap/SKILL.md +11 -0
- package/skills/cm-qa-visual-cli/SKILL.md +22 -0
- package/skills/cm-retro-cli/SKILL.md +23 -0
- package/skills/cm-second-opinion-cli/SKILL.md +23 -0
- package/skills/cm-secret-shield/SKILL.md +2 -2
- package/skills/cm-security-gate/SKILL.md +1 -0
- package/skills/cm-skill-chain/SKILL.md +25 -4
- package/skills/cm-skill-evolution/SKILL.md +83 -0
- package/skills/cm-skill-health/SKILL.md +83 -0
- package/skills/cm-skill-index/SKILL.md +11 -3
- package/skills/cm-skill-search/SKILL.md +49 -0
- package/skills/cm-skill-share/SKILL.md +58 -0
- package/skills/cm-sprint-bus/SKILL.md +33 -0
- package/skills/cm-start/SKILL.md +0 -10
- package/skills/cm-tdd/SKILL.md +59 -72
- package/skills/profiles/README.md +21 -0
- package/skills/profiles/core.txt +23 -0
- package/skills/profiles/design.txt +6 -0
- package/skills/profiles/full.txt +62 -0
- package/skills/profiles/growth.txt +10 -0
- package/skills/profiles/knowledge.txt +7 -0
- package/install.sh +0 -901
- package/scripts/test-gemini.js +0 -13
- package/skills/cm-frappe-agent/SKILL.md +0 -134
- package/skills/cm-frappe-agent/agents/doctype-architect.md +0 -596
- package/skills/cm-frappe-agent/agents/erpnext-customizer.md +0 -643
- package/skills/cm-frappe-agent/agents/frappe-backend.md +0 -814
- package/skills/cm-frappe-agent/agents/frappe-custom-frontend.md +0 -557
- package/skills/cm-frappe-agent/agents/frappe-debugger.md +0 -625
- package/skills/cm-frappe-agent/agents/frappe-fixer.md +0 -275
- package/skills/cm-frappe-agent/agents/frappe-frontend.md +0 -660
- package/skills/cm-frappe-agent/agents/frappe-installer.md +0 -158
- package/skills/cm-frappe-agent/agents/frappe-performance.md +0 -307
- package/skills/cm-frappe-agent/agents/frappe-planner.md +0 -419
- package/skills/cm-frappe-agent/agents/frappe-remote-ops.md +0 -153
- package/skills/cm-frappe-agent/agents/github-workflow.md +0 -286
- package/skills/cm-frappe-agent/commands/frappe-app.md +0 -351
- package/skills/cm-frappe-agent/commands/frappe-backend.md +0 -162
- package/skills/cm-frappe-agent/commands/frappe-bench.md +0 -254
- package/skills/cm-frappe-agent/commands/frappe-debug.md +0 -263
- package/skills/cm-frappe-agent/commands/frappe-doctype-create.md +0 -272
- package/skills/cm-frappe-agent/commands/frappe-doctype-field.md +0 -310
- package/skills/cm-frappe-agent/commands/frappe-erpnext.md +0 -210
- package/skills/cm-frappe-agent/commands/frappe-fix.md +0 -59
- package/skills/cm-frappe-agent/commands/frappe-frontend.md +0 -210
- package/skills/cm-frappe-agent/commands/frappe-fullstack.md +0 -243
- package/skills/cm-frappe-agent/commands/frappe-github.md +0 -57
- package/skills/cm-frappe-agent/commands/frappe-install.md +0 -52
- package/skills/cm-frappe-agent/commands/frappe-plan.md +0 -442
- package/skills/cm-frappe-agent/commands/frappe-remote.md +0 -58
- package/skills/cm-frappe-agent/commands/frappe-test.md +0 -356
- package/skills/cm-frappe-agent/docs/README.md +0 -51
- package/skills/cm-frappe-agent/docs/agents-catalog.md +0 -113
- package/skills/cm-frappe-agent/docs/architecture.md +0 -149
- package/skills/cm-frappe-agent/docs/commands-catalog.md +0 -82
- package/skills/cm-frappe-agent/docs/resources-catalog.md +0 -66
- package/skills/cm-frappe-agent/docs/sitemap-urls.txt +0 -52
- package/skills/cm-frappe-agent/docs/sitemap.md +0 -81
- package/skills/cm-frappe-agent/docs/sop/user-guide.md +0 -178
- package/skills/cm-frappe-agent/docs/sop/vibe-coding-guide.md +0 -122
- package/skills/cm-frappe-agent/resources/7-layer-architecture.md +0 -985
- package/skills/cm-frappe-agent/resources/bench_commands.md +0 -73
- package/skills/cm-frappe-agent/resources/code-patterns-guide.md +0 -948
- package/skills/cm-frappe-agent/resources/common_pitfalls.md +0 -266
- package/skills/cm-frappe-agent/resources/doctype-registry.md +0 -158
- package/skills/cm-frappe-agent/resources/installation-guide.md +0 -289
- package/skills/cm-frappe-agent/resources/rest-api-patterns.md +0 -182
- package/skills/cm-frappe-agent/resources/scaffold_checklist.md +0 -82
- package/skills/cm-frappe-agent/resources/upgrade_patterns.md +0 -113
- package/skills/cm-frappe-agent/resources/web-form-patterns.md +0 -252
- package/skills/cm-frappe-agent/skills/bench-commands/SKILL.md +0 -621
- package/skills/cm-frappe-agent/skills/client-scripts/SKILL.md +0 -642
- package/skills/cm-frappe-agent/skills/doctype-patterns/SKILL.md +0 -576
- package/skills/cm-frappe-agent/skills/frappe-api/SKILL.md +0 -740
- package/skills/cm-frappe-agent/skills/remote-operations/SKILL.md +0 -47
- package/skills/cm-frappe-agent/skills/server-scripts/SKILL.md +0 -608
- package/skills/cm-frappe-agent/skills/web-forms/SKILL.md +0 -46
- package/skills/frappe-app-builder.zip +0 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Aggregate `.cm/operational-learnings.jsonl` for `cm retro summary`.
|
|
4
|
+
*/
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.loadRetroEntries = loadRetroEntries;
|
|
10
|
+
exports.filterSince = filterSince;
|
|
11
|
+
exports.countByTool = countByTool;
|
|
12
|
+
exports.formatRetroMarkdown = formatRetroMarkdown;
|
|
13
|
+
exports.formatRetroJson = formatRetroJson;
|
|
14
|
+
const fs_1 = __importDefault(require("fs"));
|
|
15
|
+
function loadRetroEntries(filePath) {
|
|
16
|
+
if (!fs_1.default.existsSync(filePath))
|
|
17
|
+
return [];
|
|
18
|
+
const out = [];
|
|
19
|
+
for (const line of fs_1.default.readFileSync(filePath, 'utf8').split('\n')) {
|
|
20
|
+
const t = line.trim();
|
|
21
|
+
if (!t)
|
|
22
|
+
continue;
|
|
23
|
+
try {
|
|
24
|
+
const o = JSON.parse(t);
|
|
25
|
+
if (typeof o.ts === 'string' && typeof o.note === 'string') {
|
|
26
|
+
out.push({
|
|
27
|
+
ts: o.ts,
|
|
28
|
+
tool: typeof o.tool === 'string' ? o.tool : 'unknown',
|
|
29
|
+
note: o.note,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (_a) {
|
|
34
|
+
/* skip malformed line */
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
function filterSince(entries, sinceIso) {
|
|
40
|
+
const t0 = new Date(sinceIso).getTime();
|
|
41
|
+
if (Number.isNaN(t0))
|
|
42
|
+
return entries;
|
|
43
|
+
return entries.filter((e) => new Date(e.ts).getTime() >= t0);
|
|
44
|
+
}
|
|
45
|
+
function countByTool(entries) {
|
|
46
|
+
const m = {};
|
|
47
|
+
for (const e of entries) {
|
|
48
|
+
m[e.tool] = (m[e.tool] || 0) + 1;
|
|
49
|
+
}
|
|
50
|
+
return m;
|
|
51
|
+
}
|
|
52
|
+
function formatRetroMarkdown(entries, byTool) {
|
|
53
|
+
const lines = ['# Retro summary', '', `**Total entries:** ${entries.length}`, ''];
|
|
54
|
+
lines.push('## By tool');
|
|
55
|
+
for (const [tool, n] of Object.entries(byTool).sort((a, b) => b[1] - a[1])) {
|
|
56
|
+
lines.push(`- **${tool}:** ${n}`);
|
|
57
|
+
}
|
|
58
|
+
lines.push('', '## Entries (chronological)');
|
|
59
|
+
for (const e of entries.sort((a, b) => a.ts.localeCompare(b.ts))) {
|
|
60
|
+
lines.push(`- \`${e.ts}\` [${e.tool}] ${e.note}`);
|
|
61
|
+
}
|
|
62
|
+
return lines.join('\n');
|
|
63
|
+
}
|
|
64
|
+
function formatRetroJson(entries, byTool) {
|
|
65
|
+
return JSON.stringify({
|
|
66
|
+
total: entries.length,
|
|
67
|
+
by_tool: byTool,
|
|
68
|
+
entries: entries.sort((a, b) => a.ts.localeCompare(b.ts)),
|
|
69
|
+
}, null, 2);
|
|
70
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Redaction + secondary-model review for `cm second-opinion`.
|
|
4
|
+
*/
|
|
5
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.redactDiffForReview = redactDiffForReview;
|
|
16
|
+
exports.reviewWithOpenAI = reviewWithOpenAI;
|
|
17
|
+
exports.reviewWithAnthropic = reviewWithAnthropic;
|
|
18
|
+
const SYSTEM = 'You are a senior reviewer. List risks, bugs, and missing tests. Be concise. Do not restate the entire diff.';
|
|
19
|
+
function redactDiffForReview(text, maxLen = 120000) {
|
|
20
|
+
let t = text.slice(0, maxLen);
|
|
21
|
+
t = t.replace(/^(\s*(?:#\s*)?(?:API_KEY|API_SECRET|SECRET|PASSWORD|ACCESS_TOKEN|AUTH_TOKEN|BEARER|Authorization)\s*[:=]\s*)\S+.*$/gim, '$1[REDACTED]');
|
|
22
|
+
t = t.replace(/\b(sk-[a-zA-Z0-9]{20,}|xox[baprs]-[A-Za-z0-9-]{10,}|ghp_[A-Za-z0-9]{36,}|gho_[A-Za-z0-9]{36,}|AKIA[0-9A-Z]{16})\b/g, '[REDACTED_TOKEN]');
|
|
23
|
+
return t;
|
|
24
|
+
}
|
|
25
|
+
function reviewWithOpenAI(diffText) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
var _a, _b, _c, _d;
|
|
28
|
+
const key = process.env.OPENAI_API_KEY;
|
|
29
|
+
if (!key)
|
|
30
|
+
throw new Error('OPENAI_API_KEY is not set');
|
|
31
|
+
const model = process.env.CM_SECOND_OPINION_MODEL || 'gpt-4o-mini';
|
|
32
|
+
const res = yield fetch('https://api.openai.com/v1/chat/completions', {
|
|
33
|
+
method: 'POST',
|
|
34
|
+
headers: {
|
|
35
|
+
'Content-Type': 'application/json',
|
|
36
|
+
Authorization: `Bearer ${key}`,
|
|
37
|
+
},
|
|
38
|
+
body: JSON.stringify({
|
|
39
|
+
model,
|
|
40
|
+
messages: [
|
|
41
|
+
{ role: 'system', content: SYSTEM },
|
|
42
|
+
{ role: 'user', content: `Review this diff:\n\n${diffText}` },
|
|
43
|
+
],
|
|
44
|
+
}),
|
|
45
|
+
});
|
|
46
|
+
if (!res.ok)
|
|
47
|
+
throw new Error(yield res.text());
|
|
48
|
+
const data = (yield res.json());
|
|
49
|
+
return (_d = (_c = (_b = (_a = data.choices) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.message) === null || _c === void 0 ? void 0 : _c.content) !== null && _d !== void 0 ? _d : '';
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function reviewWithAnthropic(diffText) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
const key = process.env.ANTHROPIC_API_KEY;
|
|
56
|
+
if (!key)
|
|
57
|
+
throw new Error('ANTHROPIC_API_KEY is not set');
|
|
58
|
+
const model = process.env.CM_ANTHROPIC_MODEL || 'claude-3-5-haiku-20241022';
|
|
59
|
+
const res = yield fetch('https://api.anthropic.com/v1/messages', {
|
|
60
|
+
method: 'POST',
|
|
61
|
+
headers: {
|
|
62
|
+
'Content-Type': 'application/json',
|
|
63
|
+
'x-api-key': key,
|
|
64
|
+
'anthropic-version': '2023-06-01',
|
|
65
|
+
},
|
|
66
|
+
body: JSON.stringify({
|
|
67
|
+
model,
|
|
68
|
+
max_tokens: 4096,
|
|
69
|
+
system: SYSTEM,
|
|
70
|
+
messages: [{ role: 'user', content: `Review this diff:\n\n${diffText}` }],
|
|
71
|
+
}),
|
|
72
|
+
});
|
|
73
|
+
if (!res.ok)
|
|
74
|
+
throw new Error(yield res.text());
|
|
75
|
+
const data = (yield res.json());
|
|
76
|
+
const block = (_a = data.content) === null || _a === void 0 ? void 0 : _a.find((c) => c.type === 'text');
|
|
77
|
+
return (_b = block === null || block === void 0 ? void 0 : block.text) !== null && _b !== void 0 ? _b : '';
|
|
78
|
+
});
|
|
79
|
+
}
|
package/dist/skill-chain.js
CHANGED
|
@@ -4,6 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.matchChain = matchChain;
|
|
7
|
+
exports.scoreStepRelevance = scoreStepRelevance;
|
|
8
|
+
exports.selectTopSkills = selectTopSkills;
|
|
7
9
|
exports.listChains = listChains;
|
|
8
10
|
exports.findChain = findChain;
|
|
9
11
|
exports.createChainExecution = createChainExecution;
|
|
@@ -17,6 +19,8 @@ exports.getCurrentSkill = getCurrentSkill;
|
|
|
17
19
|
const crypto_1 = __importDefault(require("crypto"));
|
|
18
20
|
const builtin_1 = require("./chains/builtin");
|
|
19
21
|
const context_bus_1 = require("./context-bus");
|
|
22
|
+
const execution_analyzer_1 = require("./execution-analyzer");
|
|
23
|
+
const storage_backend_1 = require("./storage-backend");
|
|
20
24
|
// ─── Chain Matching ─────────────────────────────────────────────────────────
|
|
21
25
|
// TRIZ #10: Preliminary Action — analyze task BEFORE dispatching
|
|
22
26
|
/**
|
|
@@ -43,6 +47,53 @@ function matchChain(taskTitle) {
|
|
|
43
47
|
}
|
|
44
48
|
return bestMatch;
|
|
45
49
|
}
|
|
50
|
+
// ─── Intelligent Skill Selection (SkillsBench: 2-3 skills = +18.6pp) ────────
|
|
51
|
+
// TRIZ #1: Segmentation — select only relevant sub-components
|
|
52
|
+
/**
|
|
53
|
+
* Score a single chain step's relevance to the given task title.
|
|
54
|
+
* Mandatory steps (optional=false, condition='always') receive a +100 base bonus
|
|
55
|
+
* to ensure they are always prioritised over optional ones.
|
|
56
|
+
*/
|
|
57
|
+
function scoreStepRelevance(taskTitle, step) {
|
|
58
|
+
const taskTokens = new Set(taskTitle.toLowerCase().split(/\W+/).filter(t => t.length > 2));
|
|
59
|
+
const descTokens = step.description.toLowerCase().split(/\W+/).filter(t => t.length > 2);
|
|
60
|
+
const overlap = descTokens.filter(t => taskTokens.has(t)).length;
|
|
61
|
+
const mandatoryBonus = (!step.optional && step.condition === 'always') ? 100 : 0;
|
|
62
|
+
return overlap + mandatoryBonus;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Select the most relevant skills for a task, capped at maxSkills.
|
|
66
|
+
*
|
|
67
|
+
* Rules:
|
|
68
|
+
* - Mandatory steps (optional=false AND condition='always') are ALWAYS included,
|
|
69
|
+
* even if their count exceeds maxSkills (safety > optimisation).
|
|
70
|
+
* - Remaining slots are filled with the highest-scoring optional steps.
|
|
71
|
+
* - If mandatory count > maxSkills, a performance warning is emitted.
|
|
72
|
+
*/
|
|
73
|
+
function selectTopSkills(taskTitle, chain, maxSkills = 3, options = {}) {
|
|
74
|
+
const mandatory = chain.steps.filter(s => !s.optional && s.condition === 'always');
|
|
75
|
+
const optional = chain.steps.filter(s => s.optional || s.condition !== 'always');
|
|
76
|
+
if (mandatory.length > maxSkills) {
|
|
77
|
+
process.stderr.write(`[CodyMaster] Chain "${chain.name}" has ${mandatory.length} mandatory steps (>${maxSkills}). ` +
|
|
78
|
+
`Consider splitting this chain. (SkillsBench: 2-3 skills = +18.6pp)\n`);
|
|
79
|
+
return mandatory; // include all mandatory — cannot safely drop them
|
|
80
|
+
}
|
|
81
|
+
const remaining = maxSkills - mandatory.length;
|
|
82
|
+
const scoredOptional = optional
|
|
83
|
+
.map(step => {
|
|
84
|
+
var _a, _b;
|
|
85
|
+
const relevance = scoreStepRelevance(taskTitle, step);
|
|
86
|
+
const metric = (_b = (_a = options.getSkillMetric) === null || _a === void 0 ? void 0 : _a.call(options, step.skill)) !== null && _b !== void 0 ? _b : null;
|
|
87
|
+
const quality = (0, execution_analyzer_1.qualityWeight)(metric);
|
|
88
|
+
return { step, score: relevance + quality, relevance, quality };
|
|
89
|
+
})
|
|
90
|
+
.sort((a, b) => b.score - a.score)
|
|
91
|
+
.slice(0, remaining)
|
|
92
|
+
.map(({ step }) => step);
|
|
93
|
+
// Preserve original chain order
|
|
94
|
+
const selected = new Set([...mandatory, ...scoredOptional]);
|
|
95
|
+
return chain.steps.filter(s => selected.has(s));
|
|
96
|
+
}
|
|
46
97
|
/**
|
|
47
98
|
* List all available chains (built-in + user-defined in the future).
|
|
48
99
|
*/
|
|
@@ -62,7 +113,18 @@ function findChain(chainId) {
|
|
|
62
113
|
*/
|
|
63
114
|
function createChainExecution(chain, projectId, taskTitle, agent, projectPath) {
|
|
64
115
|
const now = new Date().toISOString();
|
|
65
|
-
const
|
|
116
|
+
const backend = projectPath ? (0, storage_backend_1.getBackend)(projectPath) : undefined;
|
|
117
|
+
let selectedSteps;
|
|
118
|
+
backend === null || backend === void 0 ? void 0 : backend.initialize();
|
|
119
|
+
try {
|
|
120
|
+
selectedSteps = selectTopSkills(taskTitle, chain, 3, {
|
|
121
|
+
getSkillMetric: backend ? (skill) => backend.getSkillMetric(skill) : undefined,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
finally {
|
|
125
|
+
backend === null || backend === void 0 ? void 0 : backend.close();
|
|
126
|
+
}
|
|
127
|
+
const steps = selectedSteps.map((step, index) => ({
|
|
66
128
|
index,
|
|
67
129
|
skill: step.skill,
|
|
68
130
|
description: step.description,
|