Merge commit 'refs/review/3987'; commit 'refs/review/4031'; commit 'refs/review/4037'; commit 'refs/review/4038' into review/adapters-20261119

This commit is contained in:
haelyra committed 2026-11-19 15:14:26 -05:00
11 files changed
+351 -61

No files matched your search

+62
View File
@@ -0,0 +1,62 @@
const fs = require('node:fs');
const path = require('node:path');
const yaml = require('js-yaml');
const repoRoot = path.resolve(__dirname, '..');
const outputDir = path.join(repoRoot, '.opencode', 'agents');
const agentNames = [
'code-simplifier',
'comment-analyzer',
'pr-test-analyzer',
'silent-failure-hunter',
'type-design-analyzer',
'react-reviewer',
'typescript-reviewer',
'react-build-resolver',
'vue-reviewer',
'code-architect',
'code-explorer',
'fastapi-reviewer',
'flutter-reviewer',
'dart-build-resolver',
'gan-planner',
'gan-generator',
'gan-evaluator',
'conversation-analyzer',
'marketing-agent',
];
function convertAgent(source, sourcePath) {
const match = source.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/);
if (!match) throw new Error(`Expected YAML frontmatter in ${sourcePath}`);
const [, frontmatter, prompt] = match;
const agent = yaml.load(frontmatter);
const tools = Array.isArray(agent.tools)
? agent.tools
: String(agent.tools ?? '').split(',').map(tool => tool.trim());
const definition = {
description: agent.description,
mode: 'subagent',
permission: {
edit: tools.includes('Edit') || tools.includes('Write') ? 'allow' : 'deny',
bash: tools.includes('Bash') ? 'ask' : 'deny',
},
};
return `---\n${yaml.dump(definition)}---\n${prompt}`;
}
function buildOpencodeAgents() {
fs.mkdirSync(outputDir, { recursive: true });
for (const name of agentNames) {
const sourcePath = path.join(repoRoot, 'agents', `${name}.md`);
const source = fs.readFileSync(sourcePath, 'utf8');
const output = convertAgent(source, sourcePath);
fs.writeFileSync(path.join(outputDir, `${name}.md`), output);
}
}
module.exports = { buildOpencodeAgents, convertAgent };
+1
View File
@@ -24,3 +24,4 @@ execFileSync(process.execPath, [tscEntrypoint, "-p", path.join(opencodeDir, "tsc
cwd: rootDir,
stdio: "inherit",
})
require("./build-opencode-agents").buildOpencodeAgents()
+20 -7
View File
@@ -1,5 +1,7 @@
'use strict';
const path = require('path');
const { stripPluginNamespace } = require('./plugin-namespace');
const { adaptAntigravityAgent } = require('./antigravity-agent');
const { adaptAntigravityRule } = require('./antigravity-rule');
@@ -180,15 +182,26 @@ function transformInstallContent(operation, content) {
}
if (operation.contentTransform === 'opencode-home-skills-path') {
const config = JSON.parse(content);
if (!Array.isArray(config?.skills?.paths) || !config.skills.paths.includes('../skills')) {
return content;
}
const { opencodeHomeInstructions } = operation;
const hasProjection = Array.isArray(opencodeHomeInstructions);
const hasInstructions = hasProjection && Array.isArray(config.instructions);
const hasBundledSkillsPath = Array.isArray(config.skills?.paths)
&& config.skills.paths.includes('../skills');
if (!hasInstructions && !hasBundledSkillsPath) return content;
// OpenCode resolves relative paths from the active project. Preserve the
// old transform for install records created without a path projection.
const bundledSkills = hasProjection
? path.join(path.dirname(operation.destinationPath), 'skills')
: './skills';
const installedConfig = {
...config,
skills: {
...config.skills,
paths: config.skills.paths.map(skillPath => skillPath === '../skills' ? './skills' : skillPath),
},
...(hasInstructions ? { instructions: opencodeHomeInstructions } : {}),
...(hasBundledSkillsPath ? {
skills: {
...config.skills,
paths: config.skills.paths.map(skillPath => skillPath === '../skills' ? bundledSkills : skillPath),
},
} : {}),
};
return `${JSON.stringify(installedConfig, null, 2)}\n`;
}
+23 -2
View File
@@ -7,7 +7,7 @@ const { execFileSync } = require('child_process');
const { resolveInstallPlan } = require('../install-manifests');
const { getInstallTargetAdapter } = require('../install-targets/registry');
const { resolveInvocationEnvironment } = require('../invocation-environment');
const { disableUnselectedOpenCodeHooks } = require('./hook-consent');
const { disableUnselectedOpenCodeHooks, parseJsoncConfig } = require('./hook-consent');
const { readHooksConfig } = require('../hooks-config');
const { isPackageSourcePath, resolvePackageSourcePath } = require('./package-source');
const {
@@ -263,6 +263,24 @@ function dedupeCopyFileOperations(operations) {
});
}
function projectOpenCodeHomeInstructions(operations) {
const installedFiles = new Set(operations.filter(operation => operation.kind === 'copy-file')
.map(operation => operation.destinationPath));
return operations.map(operation => {
if (operation.contentTransform !== 'opencode-home-skills-path') return operation;
const { instructions } = parseJsoncConfig(
fs.readFileSync(operation.sourcePath, 'utf8'),
operation.sourceRelativePath
);
const configRoot = path.dirname(operation.destinationPath);
const opencodeHomeInstructions = (Array.isArray(instructions) ? instructions : [])
.map(instruction => path.resolve(configRoot, instruction))
.filter(instruction => installedFiles.has(instruction));
// Record the projection so repair uses the same profile-specific paths.
return { ...operation, opencodeHomeInstructions };
});
}
function createManifestInstallPlan(options = {}) {
const requestedSourceRoot = options.sourceRoot || getSourceRoot();
const projectRoot = options.projectRoot || process.cwd();
@@ -320,13 +338,16 @@ function createManifestInstallPlan(options = {}) {
return operation;
});
const ruleLanguages = Array.isArray(options.ruleLanguages) ? [...options.ruleLanguages] : [];
const operations = dedupeCopyFileOperations(
const dedupedOperations = dedupeCopyFileOperations(
options.legacyMode && target === 'antigravity'
? materializedOperations.filter(operation => (
isSelectedAntigravityLegacyRule(operation, ruleLanguages)
))
: materializedOperations
);
const operations = target === 'opencode'
? projectOpenCodeHomeInstructions(dedupedOperations)
: dedupedOperations;
const source = {
repoVersion: preparedSource.sourceVersion || getPackageVersion(sourceRoot),
repoUrl: preparedSource.sourceUrl || null,