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,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildAdvisoryHandoff = buildAdvisoryHandoff;
|
|
4
|
+
exports.formatAdvisoryHandoffMarkdown = formatAdvisoryHandoffMarkdown;
|
|
5
|
+
const execution_analyzer_1 = require("./execution-analyzer");
|
|
6
|
+
function resolveAnalysis(backend, options) {
|
|
7
|
+
var _a;
|
|
8
|
+
const analyses = backend.getExecutionAnalyses((_a = options.searchLimit) !== null && _a !== void 0 ? _a : 50);
|
|
9
|
+
if (analyses.length === 0) {
|
|
10
|
+
throw new Error('No execution analyses recorded yet.');
|
|
11
|
+
}
|
|
12
|
+
if (!options.analysisId)
|
|
13
|
+
return analyses[0];
|
|
14
|
+
const match = analyses.find((analysis) => analysis.id.startsWith(options.analysisId));
|
|
15
|
+
if (!match) {
|
|
16
|
+
throw new Error(`No advisory analysis found for id prefix: ${options.analysisId}`);
|
|
17
|
+
}
|
|
18
|
+
return match;
|
|
19
|
+
}
|
|
20
|
+
function resolveSkillName(analysis, explicitSkill) {
|
|
21
|
+
var _a;
|
|
22
|
+
if (explicitSkill)
|
|
23
|
+
return explicitSkill;
|
|
24
|
+
return (_a = analysis.skill_judgments.find((judgment) => judgment.selected || judgment.applied)) === null || _a === void 0 ? void 0 : _a.skill;
|
|
25
|
+
}
|
|
26
|
+
function buildNextStep(consumer, action, skill) {
|
|
27
|
+
const subject = skill !== null && skill !== void 0 ? skill : 'the affected skill';
|
|
28
|
+
if (consumer === 'cm-skill-health') {
|
|
29
|
+
return `Run cm-skill-health on ${subject} and confirm whether ${action} is still the truthful recovery path.`;
|
|
30
|
+
}
|
|
31
|
+
return `Run cm-skill-evolution in ${action} mode for ${subject} using this advisory evidence as the starting note.`;
|
|
32
|
+
}
|
|
33
|
+
function buildAdvisoryHandoff(backend, options) {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
const analysis = resolveAnalysis(backend, options);
|
|
36
|
+
const skillName = resolveSkillName(analysis, options.skill);
|
|
37
|
+
const judgment = skillName
|
|
38
|
+
? analysis.skill_judgments.find((item) => item.skill === skillName)
|
|
39
|
+
: undefined;
|
|
40
|
+
const metric = skillName ? backend.getSkillMetric(skillName) : null;
|
|
41
|
+
const action = (_a = analysis.recommended_action) !== null && _a !== void 0 ? _a : 'NONE';
|
|
42
|
+
return {
|
|
43
|
+
version: 1,
|
|
44
|
+
generated_at: new Date().toISOString(),
|
|
45
|
+
consumer: options.consumer,
|
|
46
|
+
recommendation: {
|
|
47
|
+
action,
|
|
48
|
+
confidence: analysis.confidence,
|
|
49
|
+
},
|
|
50
|
+
source: {
|
|
51
|
+
analysis_id: analysis.id,
|
|
52
|
+
task_title: analysis.task_title,
|
|
53
|
+
task_status: analysis.status,
|
|
54
|
+
source_task_type: analysis.source_task_type,
|
|
55
|
+
created_at: analysis.created_at,
|
|
56
|
+
},
|
|
57
|
+
skill: {
|
|
58
|
+
name: skillName,
|
|
59
|
+
judgment,
|
|
60
|
+
metric: metric ? Object.assign(Object.assign({}, metric), { quality_weight: (0, execution_analyzer_1.qualityWeight)(metric) }) : null,
|
|
61
|
+
},
|
|
62
|
+
evidence: {
|
|
63
|
+
summary: analysis.summary,
|
|
64
|
+
selected_skills: (_b = analysis.selected_skills) !== null && _b !== void 0 ? _b : [],
|
|
65
|
+
target_skills: analysis.skill_judgments
|
|
66
|
+
.filter((item) => item.selected || item.applied)
|
|
67
|
+
.map((item) => item.skill),
|
|
68
|
+
},
|
|
69
|
+
next_step: buildNextStep(options.consumer, action, skillName),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function formatAdvisoryHandoffMarkdown(handoff) {
|
|
73
|
+
var _a, _b, _c;
|
|
74
|
+
return [
|
|
75
|
+
'## Advisory Handoff',
|
|
76
|
+
`- Consumer: ${handoff.consumer}`,
|
|
77
|
+
`- Skill: ${(_a = handoff.skill.name) !== null && _a !== void 0 ? _a : '-'}`,
|
|
78
|
+
`- Recovery path: ${handoff.recommendation.action}`,
|
|
79
|
+
`- Confidence: ${(_c = (_b = handoff.recommendation.confidence) === null || _b === void 0 ? void 0 : _b.toFixed(2)) !== null && _c !== void 0 ? _c : '-'}`,
|
|
80
|
+
`- Source analysis: ${handoff.source.analysis_id}`,
|
|
81
|
+
`- Task: ${handoff.source.task_title}`,
|
|
82
|
+
`- Status: ${handoff.source.task_status}`,
|
|
83
|
+
`- Evidence: ${handoff.evidence.summary}`,
|
|
84
|
+
`- Selected skills: ${handoff.evidence.selected_skills.join(', ') || '-'}`,
|
|
85
|
+
`- Target skills: ${handoff.evidence.target_skills.join(', ') || '-'}`,
|
|
86
|
+
`- Quality weight: ${handoff.skill.metric ? handoff.skill.metric.quality_weight.toFixed(2) : '-'}`,
|
|
87
|
+
`- Next step: ${handoff.next_step}`,
|
|
88
|
+
].join('\n');
|
|
89
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildAdvisoryReportData = buildAdvisoryReportData;
|
|
4
|
+
exports.buildAdvisoryMetricsData = buildAdvisoryMetricsData;
|
|
5
|
+
exports.formatAdvisoryReport = formatAdvisoryReport;
|
|
6
|
+
exports.formatAdvisoryMetrics = formatAdvisoryMetrics;
|
|
7
|
+
const execution_analyzer_1 = require("./execution-analyzer");
|
|
8
|
+
function fmtConfidence(value) {
|
|
9
|
+
if (typeof value !== 'number')
|
|
10
|
+
return '-';
|
|
11
|
+
return value.toFixed(2);
|
|
12
|
+
}
|
|
13
|
+
function summarizeTargetSkills(analysis) {
|
|
14
|
+
const targets = analysis.skill_judgments
|
|
15
|
+
.filter((judgment) => judgment.selected || judgment.applied)
|
|
16
|
+
.map((judgment) => judgment.skill);
|
|
17
|
+
return targets.length > 0 ? targets.join(', ') : '-';
|
|
18
|
+
}
|
|
19
|
+
function formatAnalysisLine(analysis) {
|
|
20
|
+
var _a;
|
|
21
|
+
const action = (_a = analysis.recommended_action) !== null && _a !== void 0 ? _a : 'NONE';
|
|
22
|
+
return [
|
|
23
|
+
`- ${analysis.task_title}`,
|
|
24
|
+
`status=${analysis.status}`,
|
|
25
|
+
`action=${action}`,
|
|
26
|
+
`confidence=${fmtConfidence(analysis.confidence)}`,
|
|
27
|
+
`skills=${summarizeTargetSkills(analysis)}`,
|
|
28
|
+
].join(' | ');
|
|
29
|
+
}
|
|
30
|
+
function formatMetricLine(metric) {
|
|
31
|
+
var _a;
|
|
32
|
+
return [
|
|
33
|
+
`- ${metric.skill}`,
|
|
34
|
+
`quality=${metric.quality_weight.toFixed(2)}`,
|
|
35
|
+
`selected=${metric.selections}`,
|
|
36
|
+
`applied=${metric.applications}`,
|
|
37
|
+
`completed=${metric.task_completions}`,
|
|
38
|
+
`fallbacks=${metric.fallbacks}`,
|
|
39
|
+
`action=${(_a = metric.last_recommended_action) !== null && _a !== void 0 ? _a : '-'}`,
|
|
40
|
+
].join(' | ');
|
|
41
|
+
}
|
|
42
|
+
function buildAdvisoryReportData(backend, options = {}) {
|
|
43
|
+
var _a;
|
|
44
|
+
const limit = (_a = options.limit) !== null && _a !== void 0 ? _a : 10;
|
|
45
|
+
return backend.getExecutionAnalyses(limit).map((analysis) => ({
|
|
46
|
+
id: analysis.id,
|
|
47
|
+
task_title: analysis.task_title,
|
|
48
|
+
status: analysis.status,
|
|
49
|
+
summary: analysis.summary,
|
|
50
|
+
source_task_type: analysis.source_task_type,
|
|
51
|
+
recommended_action: analysis.recommended_action,
|
|
52
|
+
confidence: analysis.confidence,
|
|
53
|
+
created_at: analysis.created_at,
|
|
54
|
+
active_skills: analysis.skill_judgments
|
|
55
|
+
.filter((judgment) => judgment.selected || judgment.applied)
|
|
56
|
+
.map((judgment) => judgment.skill),
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
function buildAdvisoryMetricsData(backend, options = {}) {
|
|
60
|
+
var _a;
|
|
61
|
+
const limit = (_a = options.limit) !== null && _a !== void 0 ? _a : 10;
|
|
62
|
+
return backend.listSkillMetrics(limit).map((metric) => ({
|
|
63
|
+
skill: metric.skill,
|
|
64
|
+
quality_weight: (0, execution_analyzer_1.qualityWeight)(metric),
|
|
65
|
+
selections: metric.selections,
|
|
66
|
+
applications: metric.applications,
|
|
67
|
+
task_completions: metric.task_completions,
|
|
68
|
+
fallbacks: metric.fallbacks,
|
|
69
|
+
total_token_estimate: metric.total_token_estimate,
|
|
70
|
+
last_task_type: metric.last_task_type,
|
|
71
|
+
last_recommended_action: metric.last_recommended_action,
|
|
72
|
+
last_used_at: metric.last_used_at,
|
|
73
|
+
updated_at: metric.updated_at,
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
function formatAdvisoryReport(backend, options = {}) {
|
|
77
|
+
const analyses = buildAdvisoryReportData(backend, options);
|
|
78
|
+
if (analyses.length === 0) {
|
|
79
|
+
return [
|
|
80
|
+
'Advisory Report',
|
|
81
|
+
'',
|
|
82
|
+
'No execution analyses recorded yet.',
|
|
83
|
+
].join('\n');
|
|
84
|
+
}
|
|
85
|
+
return [
|
|
86
|
+
'Advisory Report',
|
|
87
|
+
'',
|
|
88
|
+
...analyses.map((analysis) => formatAnalysisLine(Object.assign(Object.assign({}, analysis), { skill_judgments: analysis.active_skills.map((skill) => ({ skill, selected: true })) }))),
|
|
89
|
+
].join('\n');
|
|
90
|
+
}
|
|
91
|
+
function formatAdvisoryMetrics(backend, options = {}) {
|
|
92
|
+
const metrics = buildAdvisoryMetricsData(backend, options);
|
|
93
|
+
if (metrics.length === 0) {
|
|
94
|
+
return [
|
|
95
|
+
'Skill Metrics',
|
|
96
|
+
'',
|
|
97
|
+
'No skill metrics recorded yet.',
|
|
98
|
+
].join('\n');
|
|
99
|
+
}
|
|
100
|
+
return [
|
|
101
|
+
'Skill Metrics',
|
|
102
|
+
'',
|
|
103
|
+
...metrics.map(formatMetricLine),
|
|
104
|
+
].join('\n');
|
|
105
|
+
}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Local HTTP browse daemon (Playwright + Express). Bearer auth.
|
|
4
|
+
* Refs: POST /refs/refresh tags interactive elements with data-cm-ref.
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
40
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
41
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
42
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
43
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
44
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
45
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
49
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
50
|
+
};
|
|
51
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
|
+
exports.BrowseDaemon = void 0;
|
|
53
|
+
const express_1 = __importDefault(require("express"));
|
|
54
|
+
function createRing(max) {
|
|
55
|
+
const buf = [];
|
|
56
|
+
return {
|
|
57
|
+
push(item) {
|
|
58
|
+
buf.push(item);
|
|
59
|
+
while (buf.length > max)
|
|
60
|
+
buf.shift();
|
|
61
|
+
},
|
|
62
|
+
snapshot: () => [...buf],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
class BrowseDaemon {
|
|
66
|
+
constructor(opts) {
|
|
67
|
+
this.opts = opts;
|
|
68
|
+
this.app = (0, express_1.default)();
|
|
69
|
+
this.httpServer = null;
|
|
70
|
+
this.browser = null;
|
|
71
|
+
this.context = null;
|
|
72
|
+
this.page = null;
|
|
73
|
+
this.consoleBuf = createRing(200);
|
|
74
|
+
this.networkBuf = createRing(200);
|
|
75
|
+
this.refMap = {};
|
|
76
|
+
this.app.use(express_1.default.json({ limit: '2mb' }));
|
|
77
|
+
this.app.use(this.authMiddleware.bind(this));
|
|
78
|
+
this.routes();
|
|
79
|
+
}
|
|
80
|
+
authMiddleware(req, res, next) {
|
|
81
|
+
if (req.path === '/health')
|
|
82
|
+
return next();
|
|
83
|
+
const h = req.headers.authorization || '';
|
|
84
|
+
const want = `Bearer ${this.opts.token}`;
|
|
85
|
+
if (h !== want) {
|
|
86
|
+
res.status(401).json({ error: 'unauthorized' });
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
next();
|
|
90
|
+
}
|
|
91
|
+
routes() {
|
|
92
|
+
this.app.get('/health', (_req, res) => {
|
|
93
|
+
res.json({ ok: true, hasPage: !!this.page });
|
|
94
|
+
});
|
|
95
|
+
this.app.post('/session/start', (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
var _a, _b, _c;
|
|
97
|
+
try {
|
|
98
|
+
const headless = (_c = (_b = (_a = req.body) === null || _a === void 0 ? void 0 : _a.headless) !== null && _b !== void 0 ? _b : this.opts.headless) !== null && _c !== void 0 ? _c : true;
|
|
99
|
+
const pw = yield Promise.resolve().then(() => __importStar(require('playwright')));
|
|
100
|
+
this.browser = yield pw.chromium.launch({ headless });
|
|
101
|
+
this.context = yield this.browser.newContext();
|
|
102
|
+
this.page = yield this.context.newPage();
|
|
103
|
+
this.page.on('console', (msg) => {
|
|
104
|
+
this.consoleBuf.push({
|
|
105
|
+
type: msg.type(),
|
|
106
|
+
text: msg.text(),
|
|
107
|
+
ts: new Date().toISOString(),
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
this.context.on('response', (response) => {
|
|
111
|
+
try {
|
|
112
|
+
this.networkBuf.push({
|
|
113
|
+
url: response.url(),
|
|
114
|
+
method: response.request().method(),
|
|
115
|
+
status: response.status(),
|
|
116
|
+
ts: new Date().toISOString(),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
catch (_a) {
|
|
120
|
+
/* ignore */
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
res.json({ ok: true });
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
res.status(500).json({ error: e.message });
|
|
127
|
+
}
|
|
128
|
+
}));
|
|
129
|
+
this.app.post('/navigate', (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
var _a;
|
|
131
|
+
try {
|
|
132
|
+
const url = (_a = req.body) === null || _a === void 0 ? void 0 : _a.url;
|
|
133
|
+
if (!url || !this.page) {
|
|
134
|
+
res.status(400).json({ error: 'url required and session must be started' });
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
yield this.page.goto(url, { waitUntil: 'domcontentloaded', timeout: 60000 });
|
|
138
|
+
res.json({ ok: true, url: this.page.url() });
|
|
139
|
+
}
|
|
140
|
+
catch (e) {
|
|
141
|
+
res.status(500).json({ error: e.message });
|
|
142
|
+
}
|
|
143
|
+
}));
|
|
144
|
+
this.app.post('/refs/refresh', (_req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
try {
|
|
146
|
+
if (!this.page) {
|
|
147
|
+
res.status(400).json({ error: 'no session' });
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const mapping = yield this.page.evaluate(() => {
|
|
151
|
+
const sel = 'a[href],button,input,textarea,select,[role="button"],[onclick]';
|
|
152
|
+
const nodes = Array.from(document.querySelectorAll(sel));
|
|
153
|
+
const out = {};
|
|
154
|
+
nodes.forEach((el, i) => {
|
|
155
|
+
const id = `e${i + 1}`;
|
|
156
|
+
el.setAttribute('data-cm-ref', id);
|
|
157
|
+
const tag = el.tagName.toLowerCase();
|
|
158
|
+
const txt = (el.textContent || '').trim().slice(0, 80);
|
|
159
|
+
out[id] = `${tag}${txt ? `: ${txt}` : ''}`;
|
|
160
|
+
});
|
|
161
|
+
return out;
|
|
162
|
+
});
|
|
163
|
+
this.refMap = mapping;
|
|
164
|
+
res.json({ ok: true, refs: mapping });
|
|
165
|
+
}
|
|
166
|
+
catch (e) {
|
|
167
|
+
res.status(500).json({ error: e.message });
|
|
168
|
+
}
|
|
169
|
+
}));
|
|
170
|
+
this.app.post('/click', (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
171
|
+
var _a, _b;
|
|
172
|
+
try {
|
|
173
|
+
const ref = (_b = (_a = req.body) === null || _a === void 0 ? void 0 : _a.ref) === null || _b === void 0 ? void 0 : _b.replace(/^@/, '');
|
|
174
|
+
if (!ref || !this.page) {
|
|
175
|
+
res.status(400).json({ error: 'ref required' });
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
yield this.page.click(`[data-cm-ref="${ref}"]`, { timeout: 15000 });
|
|
179
|
+
res.json({ ok: true });
|
|
180
|
+
}
|
|
181
|
+
catch (e) {
|
|
182
|
+
res.status(500).json({ error: e.message });
|
|
183
|
+
}
|
|
184
|
+
}));
|
|
185
|
+
this.app.post('/fill', (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
186
|
+
var _a, _b, _c;
|
|
187
|
+
try {
|
|
188
|
+
const ref = (_b = (_a = req.body) === null || _a === void 0 ? void 0 : _a.ref) === null || _b === void 0 ? void 0 : _b.replace(/^@/, '');
|
|
189
|
+
const value = (_c = req.body) === null || _c === void 0 ? void 0 : _c.value;
|
|
190
|
+
if (!ref || value === undefined || !this.page) {
|
|
191
|
+
res.status(400).json({ error: 'ref and value required' });
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
yield this.page.fill(`[data-cm-ref="${ref}"]`, value, { timeout: 15000 });
|
|
195
|
+
res.json({ ok: true });
|
|
196
|
+
}
|
|
197
|
+
catch (e) {
|
|
198
|
+
res.status(500).json({ error: e.message });
|
|
199
|
+
}
|
|
200
|
+
}));
|
|
201
|
+
this.app.get('/screenshot', (_req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
202
|
+
try {
|
|
203
|
+
if (!this.page) {
|
|
204
|
+
res.status(400).json({ error: 'no session' });
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const buf = yield this.page.screenshot({ type: 'png' });
|
|
208
|
+
res.setHeader('Content-Type', 'image/png');
|
|
209
|
+
res.send(buf);
|
|
210
|
+
}
|
|
211
|
+
catch (e) {
|
|
212
|
+
res.status(500).json({ error: e.message });
|
|
213
|
+
}
|
|
214
|
+
}));
|
|
215
|
+
this.app.get('/console', (_req, res) => {
|
|
216
|
+
res.json({ entries: this.consoleBuf.snapshot() });
|
|
217
|
+
});
|
|
218
|
+
this.app.get('/network', (_req, res) => {
|
|
219
|
+
res.json({ entries: this.networkBuf.snapshot() });
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
listen() {
|
|
223
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
224
|
+
var _a;
|
|
225
|
+
const host = this.opts.host || '127.0.0.1';
|
|
226
|
+
const port = (_a = this.opts.port) !== null && _a !== void 0 ? _a : 17395;
|
|
227
|
+
return new Promise((resolve, reject) => {
|
|
228
|
+
this.httpServer = this.app.listen(port, host, () => resolve());
|
|
229
|
+
this.httpServer.on('error', reject);
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
close() {
|
|
234
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
235
|
+
if (this.page)
|
|
236
|
+
yield this.page.close().catch(() => { });
|
|
237
|
+
if (this.context)
|
|
238
|
+
yield this.context.close().catch(() => { });
|
|
239
|
+
if (this.browser)
|
|
240
|
+
yield this.browser.close().catch(() => { });
|
|
241
|
+
this.page = null;
|
|
242
|
+
this.context = null;
|
|
243
|
+
this.browser = null;
|
|
244
|
+
if (this.httpServer) {
|
|
245
|
+
yield new Promise((r) => this.httpServer.close(() => r()));
|
|
246
|
+
this.httpServer = null;
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
exports.BrowseDaemon = BrowseDaemon;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerAllCommands = registerAllCommands;
|
|
4
|
+
const agent_1 = require("./commands/agent");
|
|
5
|
+
const dashboard_1 = require("./commands/dashboard");
|
|
6
|
+
const project_1 = require("./commands/project");
|
|
7
|
+
const skill_chain_1 = require("./commands/skill-chain");
|
|
8
|
+
const system_1 = require("./commands/system");
|
|
9
|
+
const task_1 = require("./commands/task");
|
|
10
|
+
const engineering_1 = require("./commands/engineering");
|
|
11
|
+
const design_studio_1 = require("./commands/design-studio");
|
|
12
|
+
const distro_1 = require("./commands/distro");
|
|
13
|
+
const mcp_serve_1 = require("./commands/mcp-serve");
|
|
14
|
+
const bench_1 = require("./commands/bench");
|
|
15
|
+
const brain_1 = require("./commands/brain");
|
|
16
|
+
const evolve_1 = require("./commands/evolve");
|
|
17
|
+
/**
|
|
18
|
+
* Registers all CLI commands with the provided program instance.
|
|
19
|
+
*/
|
|
20
|
+
function registerAllCommands(program) {
|
|
21
|
+
(0, agent_1.registerAgentCommands)(program);
|
|
22
|
+
(0, dashboard_1.registerDashboardCommands)(program);
|
|
23
|
+
(0, project_1.registerProjectCommands)(program);
|
|
24
|
+
(0, skill_chain_1.registerSkillChainCommands)(program);
|
|
25
|
+
(0, system_1.registerSystemCommands)(program);
|
|
26
|
+
(0, task_1.registerTaskCommands)(program);
|
|
27
|
+
(0, engineering_1.registerEngineeringCommands)(program);
|
|
28
|
+
(0, design_studio_1.registerDesignStudioCommands)(program);
|
|
29
|
+
(0, distro_1.registerDistroCommands)(program);
|
|
30
|
+
(0, mcp_serve_1.registerMcpServeCommands)(program);
|
|
31
|
+
(0, bench_1.registerBenchCommands)(program);
|
|
32
|
+
(0, brain_1.registerBrainCommands)(program);
|
|
33
|
+
(0, evolve_1.registerEvolveCommands)(program);
|
|
34
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.registerAgentCommands = registerAgentCommands;
|
|
13
|
+
const continuity_1 = require("../../continuity");
|
|
14
|
+
const box_1 = require("../../ui/box");
|
|
15
|
+
const theme_1 = require("../../ui/theme");
|
|
16
|
+
const cli_utils_1 = require("../../utils/cli-utils");
|
|
17
|
+
function registerAgentCommands(program) {
|
|
18
|
+
program
|
|
19
|
+
.command('agent [cmd] [args...]')
|
|
20
|
+
.alias('a')
|
|
21
|
+
.description('Agent management (status|memory|brain|learn)')
|
|
22
|
+
.action((cmd, args) => {
|
|
23
|
+
switch (cmd) {
|
|
24
|
+
case 'status':
|
|
25
|
+
case 'st':
|
|
26
|
+
agentStatus();
|
|
27
|
+
break;
|
|
28
|
+
case 'memory':
|
|
29
|
+
case 'mem':
|
|
30
|
+
agentMemory();
|
|
31
|
+
break;
|
|
32
|
+
case 'brain':
|
|
33
|
+
case 'br':
|
|
34
|
+
agentBrain();
|
|
35
|
+
break;
|
|
36
|
+
case 'learn':
|
|
37
|
+
agentLearn(args.join(' '));
|
|
38
|
+
break;
|
|
39
|
+
default: agentStatus();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
program
|
|
43
|
+
.command('brain')
|
|
44
|
+
.alias('br')
|
|
45
|
+
.description('Show AI brain/working memory')
|
|
46
|
+
.action(() => agentBrain());
|
|
47
|
+
}
|
|
48
|
+
function agentStatus() {
|
|
49
|
+
const summary = (0, continuity_1.getContinuityStatus)(process.cwd());
|
|
50
|
+
if (!summary.initialized) {
|
|
51
|
+
console.log((0, box_1.renderResult)('warning', 'No active CodyMaster brain initialized in this directory.', [
|
|
52
|
+
(0, theme_1.dim)('Run `cm init` to start.')
|
|
53
|
+
]));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
console.log((0, box_1.renderCommandHeader)('Agent Status: Hamster v4.6', '🐹'));
|
|
57
|
+
console.log((0, theme_1.brand)(' 🧠 Memory Index:'));
|
|
58
|
+
console.log((0, theme_1.dim)(` Iterations: ${summary.iteration}`));
|
|
59
|
+
console.log((0, theme_1.dim)(` Current Goal: ${summary.activeGoal}`));
|
|
60
|
+
console.log((0, theme_1.dim)(` Current Phase: ${summary.phase}`));
|
|
61
|
+
console.log((0, theme_1.dim)(` Tasks Completed: ${summary.completedCount}`));
|
|
62
|
+
console.log((0, theme_1.dim)(` Active Blockers: ${summary.blockerCount}`));
|
|
63
|
+
console.log(`\n ${(0, theme_1.brand)('📊 Activity Summary:')}`);
|
|
64
|
+
console.log((0, theme_1.dim)(` Learnings: ${summary.learningCount}`));
|
|
65
|
+
console.log((0, theme_1.dim)(` Decisions: ${summary.decisionCount}`));
|
|
66
|
+
console.log();
|
|
67
|
+
}
|
|
68
|
+
function agentMemory() {
|
|
69
|
+
const learnings = (0, continuity_1.getLearnings)(process.cwd()).slice(0, 5);
|
|
70
|
+
if (learnings.length === 0) {
|
|
71
|
+
console.log((0, box_1.renderResult)('info', 'No memories stored yet.'));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
console.log((0, box_1.renderCommandHeader)('Agent Memory (Latest)', '🧠'));
|
|
75
|
+
learnings.forEach((l) => {
|
|
76
|
+
console.log(` ${(0, theme_1.success)('●')} ${(0, theme_1.brand)(l.whatFailed)}`);
|
|
77
|
+
console.log((0, theme_1.dim)(` ${l.howToPrevent} (${(0, cli_utils_1.formatTimeAgoCli)(l.timestamp)})`));
|
|
78
|
+
});
|
|
79
|
+
console.log();
|
|
80
|
+
}
|
|
81
|
+
function agentBrain() {
|
|
82
|
+
const state = (0, continuity_1.readContinuityState)(process.cwd());
|
|
83
|
+
if (!state) {
|
|
84
|
+
console.log((0, box_1.renderResult)('warning', 'Brain not initialized.'));
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
console.log((0, box_1.renderCommandHeader)(`Agent Brain: ${state.project}`, '🧠'));
|
|
88
|
+
console.log((0, theme_1.brand)(` Goal: ${state.activeGoal}`));
|
|
89
|
+
console.log((0, theme_1.dim)(` Phase: ${state.currentPhase} (Iter ${state.currentIteration})`));
|
|
90
|
+
console.log(`\n ${(0, theme_1.brand)('Next Actions:')}`);
|
|
91
|
+
state.nextActions.slice(0, 5).forEach((act, idx) => {
|
|
92
|
+
console.log(` ${idx + 1}. ${act}`);
|
|
93
|
+
});
|
|
94
|
+
if (state.activeBlockers.length > 0) {
|
|
95
|
+
console.log(`\n ${(0, theme_1.warning)('Blockers:')}`);
|
|
96
|
+
state.activeBlockers.forEach((b) => console.log(` ⚠️ ${b}`));
|
|
97
|
+
}
|
|
98
|
+
console.log();
|
|
99
|
+
}
|
|
100
|
+
function agentLearn(content) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
var _a;
|
|
103
|
+
if (!content) {
|
|
104
|
+
console.log((0, box_1.renderResult)('error', 'Please provide a learning to record.'));
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const state = (0, continuity_1.readContinuityState)(process.cwd());
|
|
108
|
+
const learning = {
|
|
109
|
+
whatFailed: content,
|
|
110
|
+
whyFailed: 'Manual entry',
|
|
111
|
+
howToPrevent: 'Recorded via CLI',
|
|
112
|
+
timestamp: new Date().toISOString(),
|
|
113
|
+
agent: 'CLI User',
|
|
114
|
+
taskId: ((_a = state === null || state === void 0 ? void 0 : state.currentTask) === null || _a === void 0 ? void 0 : _a.id) || 'manual',
|
|
115
|
+
module: 'system'
|
|
116
|
+
};
|
|
117
|
+
(0, continuity_1.addLearning)(process.cwd(), learning);
|
|
118
|
+
console.log((0, box_1.renderResult)('success', 'Learning recorded in brain.'));
|
|
119
|
+
});
|
|
120
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.registerBenchCommands = registerBenchCommands;
|
|
16
|
+
const fs_1 = __importDefault(require("fs"));
|
|
17
|
+
const path_1 = __importDefault(require("path"));
|
|
18
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
19
|
+
const tdd_regression_1 = require("../../codybench/suites/tdd-regression");
|
|
20
|
+
const token_efficiency_1 = require("../../codybench/suites/token-efficiency");
|
|
21
|
+
const memory_retention_1 = require("../../codybench/suites/memory-retention");
|
|
22
|
+
const claude_code_1 = require("../../codybench/runners/claude-code");
|
|
23
|
+
const automated_1 = require("../../codybench/judges/automated");
|
|
24
|
+
const SUITES = [tdd_regression_1.tddRegressionSuite, token_efficiency_1.tokenEfficiencySuite, memory_retention_1.memoryRetentionSuite];
|
|
25
|
+
function registerBenchCommands(program) {
|
|
26
|
+
program
|
|
27
|
+
.command('bench')
|
|
28
|
+
.description('Run CodyBench evaluation suites (v0.1)')
|
|
29
|
+
.option('--suite <id>', 'Run specific suite (default: all enabled)')
|
|
30
|
+
.option('--runs <n>', 'Override repeat count per suite', parseInt)
|
|
31
|
+
.option('--output <path>', 'Output JSON file path')
|
|
32
|
+
.action((opts) => __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
var _a;
|
|
34
|
+
const projectPath = process.cwd();
|
|
35
|
+
const configPath = path_1.default.join(projectPath, 'codybench', 'config.json');
|
|
36
|
+
let config;
|
|
37
|
+
try {
|
|
38
|
+
config = JSON.parse(fs_1.default.readFileSync(configPath, 'utf-8'));
|
|
39
|
+
}
|
|
40
|
+
catch (_b) {
|
|
41
|
+
console.error(chalk_1.default.red('Error: codybench/config.json not found. Run from project root.'));
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
// Override repeat if --runs provided
|
|
45
|
+
if (opts.runs)
|
|
46
|
+
config.evals = config.evals.map(e => (Object.assign(Object.assign({}, e), { repeat: opts.runs })));
|
|
47
|
+
const suitesToRun = opts.suite
|
|
48
|
+
? SUITES.filter(s => s.id === opts.suite)
|
|
49
|
+
: SUITES.filter(s => config.evals.find(e => e.id === s.id && e.enabled));
|
|
50
|
+
if (suitesToRun.length === 0) {
|
|
51
|
+
console.error(chalk_1.default.red(`No suites found${opts.suite ? ` matching "${opts.suite}"` : ''}.`));
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
console.log(chalk_1.default.bold(`\nCodyBench v${config.version} — running ${suitesToRun.length} suite(s)\n`));
|
|
55
|
+
const allResults = [];
|
|
56
|
+
for (const suite of suitesToRun) {
|
|
57
|
+
process.stdout.write(chalk_1.default.dim(` Running ${suite.name}...`));
|
|
58
|
+
const results = yield (0, claude_code_1.runSuite)(suite, config, projectPath);
|
|
59
|
+
allResults.push(...results);
|
|
60
|
+
console.log(chalk_1.default.green(' done'));
|
|
61
|
+
}
|
|
62
|
+
const aggregates = (0, automated_1.aggregateResults)(allResults);
|
|
63
|
+
console.log('\n' + (0, automated_1.formatLeaderboard)(aggregates) + '\n');
|
|
64
|
+
const outputPath = (_a = opts.output) !== null && _a !== void 0 ? _a : path_1.default.join(projectPath, config.output_dir, `results-${Date.now()}.json`);
|
|
65
|
+
fs_1.default.mkdirSync(path_1.default.dirname(outputPath), { recursive: true });
|
|
66
|
+
fs_1.default.writeFileSync(outputPath, JSON.stringify({ config, results: allResults, aggregates }, null, 2));
|
|
67
|
+
console.log(chalk_1.default.dim(`Results saved to: ${outputPath}`));
|
|
68
|
+
}));
|
|
69
|
+
}
|