mirror of
https://github.com/gnekt/My-Brain-Is-Full-Crew.git
synced 2026-09-04 14:35:36 +00:00
Co-Authored-By: win0na <winnie@winneon.moe> feat(lib.sh): add install_plugins helper for opencode JS plugins build(adapters): opencode adapter skeleton with capability/event tables build(opencode): adapter_translate_dispatcher (DISPATCHER.md → AGENTS.md) build(opencode): adapter_translate_references and adapter_translate_skills Implements Task 4 and Task 5: - adapter_translate_references: Copies reference markdown files to .opencode/references/ - adapter_translate_skills: Copies skill SKILL.md files to .opencode/skills/<name>/ with exclude filtering Both functions respect framework filtering via should_include(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> build(opencode): adapter_translate_agents with capability→permission mapping Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> build(opencode): bash-executor template for spawning hook scripts build(opencode): plugin-stub template for mbifc-hooks.js build(opencode): adapter_translate_hooks with JS plugin generation Implements _oc_hook_registry_json and adapter_translate_hooks in the opencode adapter. Copies hook scripts to .opencode/hooks/, generates a single .opencode/plugins/mbifc-hooks.js by inlining bash-executor.js and synthesising a hook registry from *.hook.yaml files. Uses python3 for template substitution to safely handle multi-line JS content. Adds 3 unit tests (copies scripts, registry entries, noop when no hooks dir). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> build(opencode): adapter_translate_mcp with local/remote handling build(opencode): adapter_finalize and complete adapter_build wiring Add adapter_finalize placeholder and wire adapter_translate_mcp into adapter_build; add end-to-end integration test (14/14 pass). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> feat(launchme): branch on --framework for opencode install layout Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> feat(updateme): branch on --framework for opencode install layout Mirror the same case "$FRAMEWORK" block from launchme.sh: framework-specific DIST_COMPONENTS_DIR, VAULT_COMPONENTS_DIR, DISPATCHER_SRC/DST, MCP_SRC/DST, HAS_PLUGINS; conditional install_plugins; conditional install_settings; framework-aware vault-setup check; framework-neutral summary messages. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
44 lines
1.6 KiB
JavaScript
Executable File
44 lines
1.6 KiB
JavaScript
Executable File
// =============================================================================
|
|
// bash-executor.js — Spawn a bash script and pipe neutral JSON context to stdin
|
|
// =============================================================================
|
|
// This file is vendored verbatim into the generated mbifc-hooks.js plugin at
|
|
// build time. It must not require any npm modules beyond Node.js builtins so
|
|
// that opencode's embedded runtime can execute it without installation.
|
|
// =============================================================================
|
|
const { spawn } = require("node:child_process");
|
|
|
|
/**
|
|
* Run a bash script with a JSON payload on stdin.
|
|
*
|
|
* @param {string} scriptPath Absolute path to the .sh file.
|
|
* @param {object} payload Neutral-schema object to pipe in as JSON.
|
|
* @param {object} [env] Extra environment variables (merged with process.env).
|
|
* @returns {Promise<{exitCode:number, stdout:string, stderr:string}>}
|
|
*/
|
|
function runBashHook(scriptPath, payload, env = {}) {
|
|
return new Promise((resolve, reject) => {
|
|
const child = spawn("bash", [scriptPath], {
|
|
env: { ...process.env, ...env },
|
|
stdio: ["pipe", "pipe", "pipe"],
|
|
});
|
|
|
|
let stdout = "";
|
|
let stderr = "";
|
|
child.stdout.on("data", (d) => { stdout += d.toString(); });
|
|
child.stderr.on("data", (d) => { stderr += d.toString(); });
|
|
child.on("error", reject);
|
|
child.on("close", (exitCode) => {
|
|
resolve({ exitCode: exitCode ?? 0, stdout, stderr });
|
|
});
|
|
|
|
try {
|
|
child.stdin.write(JSON.stringify(payload));
|
|
child.stdin.end();
|
|
} catch (err) {
|
|
reject(err);
|
|
}
|
|
});
|
|
}
|
|
|
|
module.exports = { runBashHook };
|