feat(install): add CodeBuddy(Tencent) adaptation with installation scripts (#1038)

* feat(install): add CodeBuddy(Tencent) adaptation with installation scripts

* fix: add codebuddy to SUPPORTED_INSTALL_TARGETS

* fix(codebuddy): resolve installer path issues, unused vars, and uninstall safety
This commit is contained in:
轻舟Joshua
2026-04-01 05:06:26 +08:00
committed by GitHub
parent 477d23a34f
commit c38bc799fd
13 changed files with 1418 additions and 21 deletions

View File

@@ -41,6 +41,7 @@ function runTests() {
assert.ok(targets.includes('antigravity'), 'Should include antigravity target');
assert.ok(targets.includes('codex'), 'Should include codex target');
assert.ok(targets.includes('opencode'), 'Should include opencode target');
assert.ok(targets.includes('codebuddy'), 'Should include codebuddy target');
})) passed++; else failed++;
if (test('resolves cursor adapter root and install-state path from project root', () => {
@@ -216,6 +217,119 @@ function runTests() {
);
})) passed++; else failed++;
if (test('resolves codebuddy adapter root and install-state path from project root', () => {
const adapter = getInstallTargetAdapter('codebuddy');
const projectRoot = '/workspace/app';
const root = adapter.resolveRoot({ projectRoot });
const statePath = adapter.getInstallStatePath({ projectRoot });
assert.strictEqual(adapter.id, 'codebuddy-project');
assert.strictEqual(adapter.target, 'codebuddy');
assert.strictEqual(adapter.kind, 'project');
assert.strictEqual(root, path.join(projectRoot, '.codebuddy'));
assert.strictEqual(statePath, path.join(projectRoot, '.codebuddy', 'ecc-install-state.json'));
})) passed++; else failed++;
if (test('codebuddy adapter supports lookup by target and adapter id', () => {
const byTarget = getInstallTargetAdapter('codebuddy');
const byId = getInstallTargetAdapter('codebuddy-project');
assert.strictEqual(byTarget.id, 'codebuddy-project');
assert.strictEqual(byId.id, 'codebuddy-project');
assert.ok(byTarget.supports('codebuddy'));
assert.ok(byTarget.supports('codebuddy-project'));
})) passed++; else failed++;
if (test('plans codebuddy rules with flat namespaced filenames', () => {
const repoRoot = path.join(__dirname, '..', '..');
const projectRoot = '/workspace/app';
const plan = planInstallTargetScaffold({
target: 'codebuddy',
repoRoot,
projectRoot,
modules: [
{
id: 'rules-core',
paths: ['rules'],
},
],
});
assert.strictEqual(plan.adapter.id, 'codebuddy-project');
assert.strictEqual(plan.targetRoot, path.join(projectRoot, '.codebuddy'));
assert.strictEqual(plan.installStatePath, path.join(projectRoot, '.codebuddy', 'ecc-install-state.json'));
assert.ok(
plan.operations.some(operation => (
normalizedRelativePath(operation.sourceRelativePath) === 'rules/common/coding-style.md'
&& operation.destinationPath === path.join(projectRoot, '.codebuddy', 'rules', 'common-coding-style.md')
)),
'Should flatten common rules into namespaced files for codebuddy'
);
assert.ok(
!plan.operations.some(operation => (
operation.destinationPath === path.join(projectRoot, '.codebuddy', 'rules', 'common', 'coding-style.md')
)),
'Should not preserve nested rule directories for codebuddy installs'
);
})) passed++; else failed++;
if (test('exposes validate and planOperations on codebuddy adapter', () => {
const codebuddyAdapter = getInstallTargetAdapter('codebuddy');
assert.strictEqual(typeof codebuddyAdapter.planOperations, 'function');
assert.strictEqual(typeof codebuddyAdapter.validate, 'function');
assert.deepStrictEqual(
codebuddyAdapter.validate({ projectRoot: '/workspace/app', repoRoot: '/repo/ecc' }),
[]
);
})) passed++; else failed++;
if (test('every schema target enum value has a matching adapter (regression guard)', () => {
const schemaPath = path.join(__dirname, '..', '..', 'schemas', 'ecc-install-config.schema.json');
const schema = JSON.parse(require('fs').readFileSync(schemaPath, 'utf8'));
const schemaTargets = schema.properties.target.enum;
const adapters = listInstallTargetAdapters();
const adapterTargets = adapters.map(a => a.target);
for (const target of schemaTargets) {
assert.ok(
adapterTargets.includes(target),
`Schema target "${target}" has no matching adapter. ` +
`Available adapter targets: ${adapterTargets.join(', ')}`
);
}
})) passed++; else failed++;
if (test('every adapter target is listed in the schema enum (regression guard)', () => {
const schemaPath = path.join(__dirname, '..', '..', 'schemas', 'ecc-install-config.schema.json');
const schema = JSON.parse(require('fs').readFileSync(schemaPath, 'utf8'));
const schemaTargets = schema.properties.target.enum;
const adapters = listInstallTargetAdapters();
for (const adapter of adapters) {
assert.ok(
schemaTargets.includes(adapter.target),
`Adapter target "${adapter.target}" is not in schema enum. ` +
`Schema targets: ${schemaTargets.join(', ')}`
);
}
})) passed++; else failed++;
if (test('every adapter target is in SUPPORTED_INSTALL_TARGETS (regression guard)', () => {
const { SUPPORTED_INSTALL_TARGETS } = require('../../scripts/lib/install-manifests');
const adapters = listInstallTargetAdapters();
for (const adapter of adapters) {
assert.ok(
SUPPORTED_INSTALL_TARGETS.includes(adapter.target),
`Adapter target "${adapter.target}" is not in SUPPORTED_INSTALL_TARGETS. ` +
`Supported: ${SUPPORTED_INSTALL_TARGETS.join(', ')}`
);
}
})) passed++; else failed++;
console.log(`\nResults: Passed: ${passed}, Failed: ${failed}`);
process.exit(failed > 0 ? 1 : 0);
}