fix(opencode): align generated opencode.json(c) with schema (instructions as strings; agent.prompt; command.template; remove unsupported fields)
This commit is contained in:
parent
6b0e70eb23
commit
79442df3f0
|
|
@ -111,14 +111,8 @@ class IdeSetup extends BaseIdeSetup {
|
||||||
const ref = './.bmad-core/core-config.yaml';
|
const ref = './.bmad-core/core-config.yaml';
|
||||||
if (!obj.instructions) obj.instructions = [];
|
if (!obj.instructions) obj.instructions = [];
|
||||||
if (!Array.isArray(obj.instructions)) obj.instructions = [obj.instructions];
|
if (!Array.isArray(obj.instructions)) obj.instructions = [obj.instructions];
|
||||||
const hasRef = obj.instructions.some((it) =>
|
const hasRef = obj.instructions.some((it) => typeof it === 'string' && it === ref);
|
||||||
typeof it === 'string'
|
if (!hasRef) obj.instructions.push(ref);
|
||||||
? it === ref
|
|
||||||
: it && typeof it.file === 'string'
|
|
||||||
? it.file === ref
|
|
||||||
: false,
|
|
||||||
);
|
|
||||||
if (!hasRef) obj.instructions.push({ file: ref });
|
|
||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -133,19 +127,20 @@ class IdeSetup extends BaseIdeSetup {
|
||||||
const key = agentId.startsWith('bmad-') ? agentId : `bmad-${agentId}`;
|
const key = agentId.startsWith('bmad-') ? agentId : `bmad-${agentId}`;
|
||||||
const existing = configObj.agent[key];
|
const existing = configObj.agent[key];
|
||||||
const agentDef = {
|
const agentDef = {
|
||||||
instructions: [{ file: `./.bmad-core/agents/${agentId}.md` }],
|
prompt: `{file:./.bmad-core/agents/${agentId}.md}`,
|
||||||
tools: ['write', 'edit', 'bash'],
|
|
||||||
mode: 'subagent',
|
mode: 'subagent',
|
||||||
bmadManaged: true,
|
|
||||||
};
|
};
|
||||||
if (!existing) {
|
if (!existing) {
|
||||||
configObj.agent[key] = agentDef;
|
configObj.agent[key] = agentDef;
|
||||||
} else if (existing && existing.bmadManaged) {
|
} else if (
|
||||||
// Update to latest shape without clobbering non-BMAD entries
|
existing &&
|
||||||
existing.instructions = agentDef.instructions;
|
typeof existing === 'object' &&
|
||||||
existing.tools = agentDef.tools;
|
typeof existing.prompt === 'string' &&
|
||||||
|
existing.prompt.includes(`./.bmad-core/agents/${agentId}.md`)
|
||||||
|
) {
|
||||||
|
// Update only BMAD-managed entries detected by prompt path
|
||||||
|
existing.prompt = agentDef.prompt;
|
||||||
existing.mode = agentDef.mode;
|
existing.mode = agentDef.mode;
|
||||||
existing.bmadManaged = true;
|
|
||||||
configObj.agent[key] = existing;
|
configObj.agent[key] = existing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -156,14 +151,18 @@ class IdeSetup extends BaseIdeSetup {
|
||||||
const key = `bmad:tasks:${taskId}`;
|
const key = `bmad:tasks:${taskId}`;
|
||||||
const existing = configObj.command[key];
|
const existing = configObj.command[key];
|
||||||
const cmdDef = {
|
const cmdDef = {
|
||||||
instructions: [{ file: `./.bmad-core/tasks/${taskId}.md` }],
|
template: `{file:./.bmad-core/tasks/${taskId}.md}`,
|
||||||
bmadManaged: true,
|
|
||||||
};
|
};
|
||||||
if (!existing) {
|
if (!existing) {
|
||||||
configObj.command[key] = cmdDef;
|
configObj.command[key] = cmdDef;
|
||||||
} else if (existing && existing.bmadManaged) {
|
} else if (
|
||||||
existing.instructions = cmdDef.instructions;
|
existing &&
|
||||||
existing.bmadManaged = true;
|
typeof existing === 'object' &&
|
||||||
|
typeof existing.template === 'string' &&
|
||||||
|
existing.template.includes(`./.bmad-core/tasks/${taskId}.md`)
|
||||||
|
) {
|
||||||
|
// Update only BMAD-managed entries detected by template path
|
||||||
|
existing.template = cmdDef.template;
|
||||||
configObj.command[key] = existing;
|
configObj.command[key] = existing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -197,7 +196,7 @@ class IdeSetup extends BaseIdeSetup {
|
||||||
// Create minimal opencode.jsonc
|
// Create minimal opencode.jsonc
|
||||||
const minimal = {
|
const minimal = {
|
||||||
$schema: 'https://opencode.ai/config.json',
|
$schema: 'https://opencode.ai/config.json',
|
||||||
instructions: [{ file: './.bmad-core/core-config.yaml' }],
|
instructions: ['./.bmad-core/core-config.yaml'],
|
||||||
agent: {},
|
agent: {},
|
||||||
command: {},
|
command: {},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue