// src/engine/opencode/adapter.ts — SPEC-966: OpenCode adapter orchestrator
import { detectOpenCodeWorkspace } from './detect.js';
import { getCoachRules } from './coach.js';
import { scaffoldOpenCodeConfig } from './config-scaffold.js';
// eslint-disable-next-line @typescript-eslint/require-await -- Must return Promise for caller compatibility
export async function runOpenCodeAdapter(input) {
    const { projectPath, action } = input;
    const workspace = detectOpenCodeWorkspace(projectPath);
    if (action === 'detect') {
        return {
            detected: workspace.detected,
            markers: workspace.markers,
            configPath: workspace.configPath,
        };
    }
    if (action === 'coach') {
        return {
            detected: workspace.detected,
            markers: workspace.markers,
            configPath: workspace.configPath,
            coachRules: getCoachRules().map((r) => `[${r.severity}] ${r.id}: ${r.rule}`),
        };
    }
    // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- action is a union type, not always 'scaffold'
    if (action === 'scaffold') {
        const scaffold = scaffoldOpenCodeConfig(projectPath);
        return {
            detected: workspace.detected,
            markers: workspace.markers,
            configPath: workspace.configPath,
            scaffoldedFiles: scaffold.files,
        };
    }
    return {
        detected: workspace.detected,
        markers: workspace.markers,
        configPath: workspace.configPath,
    };
}
//# sourceMappingURL=adapter.js.map