Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"node": ">=22.0.0"
},
"dependencies": {
"@sgba/arm-emulator": "^0.1.0",
"@sgba/gba-emulator": "^0.1.0",
"@sgba/gba-node": "^0.1.0",
"@anthropic-ai/claude-agent-sdk": "^0.2.70",
"@ast-grep/lang-c": "^0.0.5",
"@ast-grep/napi": "^0.41.0",
Expand Down
4 changes: 4 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ export default {
'path',
'url',
'os',
// @sgba packages
'@sgba/arm-emulator',
'@sgba/gba-emulator',
'@sgba/gba-node',
// External dependencies (don't bundle these)
'@anthropic-ai/claude-agent-sdk',
'@ast-grep/napi',
Expand Down
2 changes: 2 additions & 0 deletions src/cli/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ global:
promptsDir: '/custom/prompts',
projectPath: '/decomp/myproject',
target: 'gba',
verificationMode: 'objdiff',
mapFilePath: '/decomp/myproject/build/myproject.map',
nonMatchingAsmFolders: [],
},
Expand All @@ -130,6 +131,7 @@ global:
promptsDir: '/custom/prompts',
projectPath: '/decomp/myproject',
target: 'gba',
verificationMode: 'objdiff',
mapFilePath: '/decomp/myproject/build/myproject.map',
nonMatchingAsmFolders: [],
},
Expand Down
1 change: 1 addition & 0 deletions src/cli/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export function buildPipelineConfig(
projectPath: fileConfig.global?.projectPath ?? defaults.projectPath,
mapFilePath: fileConfig.global?.mapFilePath ?? defaults.mapFilePath,
target: fileConfig.global?.target ?? defaults.target,
verificationMode: fileConfig.global?.verificationMode ?? defaults.verificationMode,
nonMatchingAsmFolders: fileConfig.global?.nonMatchingAsmFolders ?? defaults.nonMatchingAsmFolders,
};

Expand Down
45 changes: 32 additions & 13 deletions src/commands/run.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import {
validatePaths,
} from '~/cli/config.js';
import { PluginManager } from '~/plugin-manager.js';
import {
BehavioralMatchConfig,
BehavioralMatchPlugin,
behavioralMatchConfigSchema,
} from '~/plugins/behavioral-match/behavioral-match-plugin.js';
import {
ClaudeRunnerConfig,
ClaudeRunnerPlugin,
Expand Down Expand Up @@ -782,27 +787,41 @@ async function runPipeline(
claudeRunnerConfigSchema,
);

const objdiffConfig: ObjdiffConfig = getPluginConfigFromFile<ObjdiffConfig>(
fileConfig,
'objdiff',
objdiffConfigSchema,
);

// Create shared CCompiler and Objdiff instances
// Create shared CCompiler instance
const cCompiler = new CCompiler(pipelineConfig.compilerScript);
const objdiff = new Objdiff(objdiffConfig.diffSettings);

// Create verification plugin based on mode
const useBehavioral = pipelineConfig.verificationMode === 'behavioral-match';
let verificationPlugin: ObjdiffPlugin | BehavioralMatchPlugin;
let objdiff: Objdiff | undefined;

if (useBehavioral) {
const behavioralConfig: BehavioralMatchConfig = getPluginConfigFromFile<BehavioralMatchConfig>(
fileConfig,
'behavioral-match',
behavioralMatchConfigSchema,
);
verificationPlugin = new BehavioralMatchPlugin(behavioralConfig);
} else {
const objdiffConfig: ObjdiffConfig = getPluginConfigFromFile<ObjdiffConfig>(
fileConfig,
'objdiff',
objdiffConfigSchema,
);
objdiff = new Objdiff(objdiffConfig.diffSettings);
verificationPlugin = new ObjdiffPlugin(objdiffConfig);
}

// Create plugins
const getContextPlugin = new GetContextPlugin(pipelineConfig.getContextScript);
claudePlugin = new ClaudeRunnerPlugin({
config: claudeRunnerConfig,
pipelineConfig,
cCompiler,
objdiff,
objdiff: objdiff ?? new Objdiff(), // Claude Runner needs objdiff for its MCP tool
cliPrompt,
});
compilerPlugin = new CompilerPlugin(cCompiler);
const objdiffPlugin = new ObjdiffPlugin(objdiffConfig);

// Register setup phase plugins
manager.registerSetupPhase(getContextPlugin);
Expand All @@ -820,10 +839,10 @@ async function runPipeline(

if (decompPermuterConfig.enable) {
const decompPermuterPlugin = new DecompPermuterPlugin(decompPermuterConfig, cCompiler);
manager.registerProgrammaticPhase([m2cPlugin, compilerPlugin, objdiffPlugin], [decompPermuterPlugin]);
manager.registerProgrammaticPhase([m2cPlugin, compilerPlugin, verificationPlugin], [decompPermuterPlugin]);
backgroundCoordinator = new BackgroundTaskCoordinator([decompPermuterPlugin], onEvent);
} else {
manager.registerProgrammaticPhase([m2cPlugin, compilerPlugin, objdiffPlugin]);
manager.registerProgrammaticPhase([m2cPlugin, compilerPlugin, verificationPlugin]);
}
}

Expand All @@ -835,7 +854,7 @@ async function runPipeline(
}

// Register plugins for the ai-powered phase
manager.register(claudePlugin).register(compilerPlugin).register(objdiffPlugin);
manager.register(claudePlugin).register(compilerPlugin).register(verificationPlugin);

// Compute timestamp and file paths up front so partial and final files share the same timestamp
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
Expand Down
Loading
Loading