mirror of
https://github.com/gnekt/My-Brain-Is-Full-Crew.git
synced 2026-08-26 02:04:43 +00:00
* Fix istall/update scripts * test: capture pre-refactor install snapshot for regression Adds take-snapshot.sh script and the resulting snapshot/ directory, capturing the exact vault state produced by launchme.sh before the framework-agnosticity refactor begins. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Summary: Refactor agents/skills/hooks/mcp in agentic-platform-agnostic templates. refactor: rename source CLAUDE.md → DISPATCHER.md (framework-neutral) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> refactor: convert agent frontmatter from tools: to neutral capabilities: Replace Claude Code-specific `tools:` frontmatter with framework-agnostic `mode: subagent` and `capabilities: [...]` in all 8 agent files. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> refactor: add neutral hook trigger manifests (.hook.yaml) refactor: hooks read neutral JSON schema (args.* instead of tool_input.*) refactor: convert .mcp.json to neutral mcp/servers.yaml Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Implement agentic-platform adapters skeleton. build: add adapters/lib.sh skeleton with vocabulary constants test: bash test runner for adapter helpers Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> build(adapters): parse_frontmatter helper with tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> build(adapters): parse_capabilities helper with tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> build(adapters): should_include helper with tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> build(adapters): parse_hook_yaml helper with tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> build(adapters): agent_body helper with tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> build(adapters): enumerate_agents and enumerate_hooks helpers Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Implement agentic-platform adapter for Claude Code. build(adapters): claude-code adapter skeleton with capability/event tables build(claude-code): adapter_translate_dispatcher with test build(claude-code): adapter_translate_references with test build(claude-code): adapter_translate_skills with tests build(claude-code): adapter_translate_agents with capability→tools mapping build(claude-code): hook wrapper template (CC native → neutral schema) build(claude-code): adapter_translate_hooks with wrapper generation build(claude-code): adapter_translate_mcp with hand-rolled YAML parser build(claude-code): adapter_finalize and complete adapter_build wiring build: scripts/build.sh dispatches to per-framework adapter Also fix adapter_translate_hooks and adapter_translate_agents to use while-read loops (avoiding word-splitting on paths with spaces) and guard grep calls with || true to survive set -eo pipefail when hooks have no match-tool field. Remove scripts/build.sh from .gitignore. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Refactor install/update scripts to support agentic-platform agnosticity. refactor(lib.sh): generalize install_claude_md → install_dispatcher New signature takes the full destination path instead of just the vault dir, allowing callers to install CLAUDE.md, AGENTS.md, or any dispatcher file to an explicit location. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> feat(launchme): support --framework flag, build dist/ before install Add --framework and --target arg parsing. Run build.sh before installing to populate dist/<framework>/. All install_* calls now read from dist/<framework>/ instead of the raw source dirs. MCP is now handled automatically by the adapter (no interactive prompt). Replaced install_claude_md with install_dispatcher. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> feat(updateme): support --framework flag, build dist/ before update Add --framework and --target arg parsing. Run build.sh before installing to populate dist/<framework>/. All install_* calls now read from dist/<framework>/ instead of raw source dirs. Replaced install_claude_md with install_dispatcher. Also fix set -e compatibility in lib.sh: add || true to all conditional [[ ... ]] && info "..." logging lines so they don't abort the script when VERBOSE_COPY=0. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test: regression runner diffs dist/claude-code against pre-refactor snapshot - Add tests/regression/run.sh that builds dist/claude-code and compares against snapshot, excluding runtime-only artifacts (.mbifc-manifest, .mcp.json, .claude-plugin/plugin.json) - Fix adapters/lib.sh agent_body: preserve '---' section dividers in body (awk now only skips '---' while still inside frontmatter, fm < 2) - Fix adapters/claude-code/adapter.sh: change 'read' capability to expand to only 'Read', appending 'Glob, Grep' at end of tools list to match snapshot ordering - Update snapshot to reflect intentional refactor changes: hook JSON schema (.args.* instead of .tool_input.*), wrapper scripts, settings.json with wrapper paths, and consistent tool ordering for postman/sorter Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Implement opencode adapter. 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> * Fix adapters to follow the same template. fix: restore adapter_build() contract, revert function renames Both adapters now export adapter_build() and adapter_translate_*() as the uniform public contract. scripts/build.sh sources one adapter and calls adapter_build uniformly. Private helpers (_oc_*) and vocabulary tables (cc_capability_to_tools, oc_capability_to_permission, etc.) retain their prefixes. CC regression and OC unit tests all pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> fix(tests): restore test_oc_ prefix on adapter_build end-to-end test * Fix agent format in opencode adapter * refactor: rename --framework to --platform across all scripts and tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Modify generic name for model tiers Co-Authored-By: win0na <winnie@winneon.moe> refactor: neutral model vocabulary (low/mid/high) in source agents feat(claude-code): cc_model_to_native() maps low/mid/high to haiku/sonnet/opus Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> feat(opencode): update oc_model_to_provider() for low/mid/high vocabulary Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Add gemini-cli adapter Co-Authored-By: win0na <winnie@winneon.moe> build(gemini-cli): adapter skeleton with capability/event/model tables build(gemini-cli): adapter_translate_dispatcher (DISPATCHER.md → GEMINI.md) build(gemini-cli): adapter_translate_references and adapter_translate_skills Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> build(gemini-cli): adapter_translate_agents with capability→tools mapping Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> build(gemini-cli): adapter_translate_hooks with wrapper scripts Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> feat(install): add gemini-cli platform to launchme.sh and updateme.sh Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Implement preserving config merge for opencode. Co-Authored-By: win0na <winnie@winneon.moe> feat(opencode): config-merge.sh with formatting-preserving JSON merge Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> build(opencode): source config-merge.sh from adapter Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> feat(install): use oc_config_merge for opencode.json instead of overwrite Source config-merge.sh from install scripts for opencode platform so user keys in opencode.json are preserved on reinstall and update. Fix in-place merge by writing to a temp file before moving to output. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Add mcp files to gitignore. * Fix claude-specific references in agents, skills and references * Fix: remove claude-specific reference from hooks. build: add platform_dir and dispatcher_name to all hook wrapper/plugin templates feat(hooks): platform-aware path checks using platform_dir and dispatcher_name from JSON input test: update regression snapshot for platform-aware hook wrappers and scripts * Added interactive platform choice in launchme, and platform auto-detection in updateme. * Fix: remove claude-specific references from documentation * Update documentation to reflect the new platform-agnostic architecture * fix: address Copilot review feedback on PR #32 - tests/run.sh: check source return code, report failures - tests/regression/run.sh: use mktemp + trap cleanup instead of fixed /tmp paths - tests/regression/run.sh: include .mcp.json in regression comparison - tests/regression/take-snapshot.sh: use --platform flag instead of stale scripted input - adapters/opencode/templates/plugin-stub.js.tmpl: include stdout in hook block error message * fix: address Copilot review round 2 - config-merge.sh: reword comment to only promise indentation preservation (not full formatting) - take-snapshot.sh: copy required artifacts explicitly, optional ones with existence check - adapters/lib.sh: document parse_hook_yaml single-trigger limitation * fix: address Copilot review round 3 - adapters/opencode/adapter.sh: replace python3 template substitution with pure bash (while-read loop with case matching), removing python3 dependency - adapters/lib.sh: should_include now falls back to plain YAML key read for files without frontmatter delimiters (fixes hook .yaml exclude: support) * fix: address Copilot review round 4 - scripts/launchme.sh: fix double-dot in FW_DIR_NAME display (basename already includes the dot, e.g. ".claude") - scripts/launchme.sh: replace undefined MCP_ANSWER with check on MCP_DST existence for summary banner --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
318 lines
12 KiB
Bash
Executable File
318 lines
12 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# =============================================================================
|
|
# adapters/claude-code/adapter.sh — Claude Code framework adapter
|
|
# =============================================================================
|
|
# Sourced by scripts/build.sh AFTER adapters/lib.sh.
|
|
# Translates source files into a dist/claude-code/ tree that mirrors what
|
|
# Claude Code expects in the user's vault.
|
|
# =============================================================================
|
|
|
|
CC_PLATFORM="claude-code"
|
|
CC_FW_DIR="claude"
|
|
CC_DISPATCHER="CLAUDE.md"
|
|
|
|
# Capability → CC tools mapping. Each capability expands into one or more
|
|
# Claude Code tool names. The expansion is order-preserving.
|
|
cc_capability_to_tools() {
|
|
local cap="$1"
|
|
case "$cap" in
|
|
read) echo "Read" ;;
|
|
write) echo "Write" ;;
|
|
edit) echo "Edit" ;;
|
|
bash) echo "Bash" ;;
|
|
webfetch) echo "WebFetch" ;;
|
|
websearch) echo "WebSearch" ;;
|
|
notebook) echo "NotebookEdit" ;;
|
|
task) echo "Task" ;;
|
|
todo) echo "TodoWrite" ;;
|
|
*) echo "" ;;
|
|
esac
|
|
}
|
|
|
|
# Event vocabulary → CC native event mapping.
|
|
cc_event_to_native() {
|
|
local event="$1"
|
|
case "$event" in
|
|
before-tool-use) echo "PreToolUse" ;;
|
|
after-tool-use) echo "PostToolUse" ;;
|
|
on-notification) echo "Notification" ;;
|
|
on-session-start) echo "SessionStart" ;;
|
|
on-prompt-submit) echo "UserPromptSubmit" ;;
|
|
*) echo "" ;;
|
|
esac
|
|
}
|
|
|
|
# adapter_finalize <source_root> <dest_root>
|
|
# Writes any framework-specific top-level files (plugin manifest, etc.).
|
|
adapter_finalize() {
|
|
local src="$1" dst="$2"
|
|
if [[ -f "$src/.claude-plugin/plugin.json" ]]; then
|
|
mkdir -p "$dst/.claude-plugin"
|
|
cp "$src/.claude-plugin/plugin.json" "$dst/.claude-plugin/plugin.json"
|
|
fi
|
|
}
|
|
|
|
# adapter_translate_mcp <source_mcp_dir> <dest_root>
|
|
# Reads mcp/servers.yaml and writes dst/.mcp.json with mcpServers key.
|
|
adapter_translate_mcp() {
|
|
local src="$1" dst="$2"
|
|
local yaml="$src/servers.yaml"
|
|
[[ -f "$yaml" ]] || return 0
|
|
|
|
local out="$dst/.mcp.json"
|
|
mkdir -p "$dst"
|
|
|
|
# Parse the YAML into a JSON object {server_name: {command, args, env}}
|
|
local json='{}'
|
|
local current_name="" current_cmd="" current_url="" current_type=""
|
|
|
|
while IFS= read -r line; do
|
|
case "$line" in
|
|
*"- name:"*)
|
|
# Flush previous server
|
|
if [[ -n "$current_name" ]]; then
|
|
if [[ -n "$current_cmd" ]]; then
|
|
local first_arg="${current_cmd%% *}"
|
|
local rest="${current_cmd#* }"
|
|
local args_json='[]'
|
|
if [[ "$rest" != "$current_cmd" ]]; then
|
|
args_json="$(echo "$rest" | jq -R 'split(" ")')"
|
|
fi
|
|
json="$(echo "$json" | jq --arg n "$current_name" --arg c "$first_arg" --argjson a "$args_json" '.[$n] = {command: $c, args: $a, env: {}}')"
|
|
elif [[ -n "$current_url" ]]; then
|
|
json="$(echo "$json" | jq --arg n "$current_name" --arg u "$current_url" --arg t "$current_type" '.[$n] = {type: $t, url: $u}')"
|
|
fi
|
|
fi
|
|
current_name="$(echo "$line" | sed 's/.*- name:[[:space:]]*//' | tr -d '"')"
|
|
current_cmd=""
|
|
current_url=""
|
|
current_type="http"
|
|
;;
|
|
*"command:"*"["*)
|
|
current_cmd="$(echo "$line" | sed 's/.*command:[[:space:]]*\[//' | sed 's/\][[:space:]]*$//' | tr -d '"' | sed 's/,[[:space:]]*/\ /g')"
|
|
;;
|
|
*"url:"*)
|
|
current_url="$(echo "$line" | sed 's/.*url:[[:space:]]*//' | tr -d '"')"
|
|
;;
|
|
*"type:"*)
|
|
current_type="$(echo "$line" | sed 's/.*type:[[:space:]]*//' | tr -d '"')"
|
|
;;
|
|
esac
|
|
done < "$yaml"
|
|
|
|
# Flush the last server
|
|
if [[ -n "$current_name" ]]; then
|
|
if [[ -n "$current_cmd" ]]; then
|
|
local first_arg="${current_cmd%% *}"
|
|
local rest="${current_cmd#* }"
|
|
local args_json='[]'
|
|
if [[ "$rest" != "$current_cmd" ]]; then
|
|
args_json="$(echo "$rest" | jq -R 'split(" ")')"
|
|
fi
|
|
json="$(echo "$json" | jq --arg n "$current_name" --arg c "$first_arg" --argjson a "$args_json" '.[$n] = {command: $c, args: $a, env: {}}')"
|
|
elif [[ -n "$current_url" ]]; then
|
|
json="$(echo "$json" | jq --arg n "$current_name" --arg u "$current_url" --arg t "$current_type" '.[$n] = {type: $t, url: $u}')"
|
|
fi
|
|
fi
|
|
|
|
echo "$json" | jq '{mcpServers: .}' > "$out"
|
|
}
|
|
|
|
# Helper: convert match-tool tokens to CC matcher syntax (e.g., "edit write" → "Edit|Write")
|
|
cc_match_tool_to_matcher() {
|
|
local tokens="$1"
|
|
local matcher=""
|
|
for t in $tokens; do
|
|
local cap_t
|
|
cap_t="$(echo "$t" | awk '{print toupper(substr($0,1,1)) substr($0,2)}')"
|
|
if [[ -z "$matcher" ]]; then
|
|
matcher="$cap_t"
|
|
else
|
|
matcher="$matcher|$cap_t"
|
|
fi
|
|
done
|
|
echo "$matcher"
|
|
}
|
|
|
|
# Neutral model tier → Claude Code model name.
|
|
cc_model_to_native() {
|
|
local model="$1"
|
|
case "$model" in
|
|
*/*) echo "$model" ;; # already qualified — passthrough
|
|
low) echo "haiku" ;;
|
|
mid) echo "sonnet" ;;
|
|
high) echo "opus" ;;
|
|
*) echo "$model" ;; # unknown — passthrough
|
|
esac
|
|
}
|
|
|
|
# adapter_translate_hooks <source_hooks_dir> <dest_root>
|
|
adapter_translate_hooks() {
|
|
local src="$1" dst="$2"
|
|
[[ -d "$src" ]] || return 0
|
|
local out_dir="$dst/.claude/hooks"
|
|
mkdir -p "$out_dir"
|
|
|
|
local template; template="$(dirname "${BASH_SOURCE[0]}")/templates/cc-hook-wrapper.sh.tmpl"
|
|
|
|
# Accumulate hook entries here, by event type
|
|
local pre_entries="" post_entries="" notif_entries="" sess_entries="" prompt_entries=""
|
|
|
|
while IFS= read -r yaml; do
|
|
[[ -z "$yaml" ]] && continue
|
|
should_include "$yaml" "$CC_PLATFORM" || continue
|
|
local meta; meta="$(parse_hook_yaml "$yaml")"
|
|
local name; name="$(echo "$meta" | grep '^name=' | head -1 | cut -d= -f2- || true)"
|
|
local script; script="$(echo "$meta" | grep '^script=' | head -1 | cut -d= -f2- || true)"
|
|
local event; event="$(echo "$meta" | grep '^event=' | head -1 | cut -d= -f2- || true)"
|
|
local match_tool; match_tool="$(echo "$meta" | grep '^match-tool=' | head -1 | cut -d= -f2- || true)"
|
|
|
|
# Copy the bash script
|
|
cp "$src/$script" "$out_dir/$script"
|
|
chmod +x "$out_dir/$script"
|
|
rewrite_platform_paths "$out_dir/$script" "$CC_FW_DIR" "$CC_DISPATCHER"
|
|
|
|
# Generate the wrapper
|
|
local wrapper_file="$out_dir/${name}-wrapper.sh"
|
|
local cc_event; cc_event="$(cc_event_to_native "$event")"
|
|
sed -e "s/__HOOK_NAME__/$name/g" -e "s/__EVENT_NAME__/$event/g" "$template" > "$wrapper_file"
|
|
chmod +x "$wrapper_file"
|
|
|
|
# Build the settings.json entry for this hook
|
|
local matcher=""
|
|
[[ -n "$match_tool" ]] && matcher="$(cc_match_tool_to_matcher "$match_tool")"
|
|
local entry; entry="$(jq -cn \
|
|
--arg cmd ".claude/hooks/${name}-wrapper.sh" \
|
|
--arg matcher "$matcher" \
|
|
'{matcher: $matcher, hooks: [{type: "command", command: ("bash " + $cmd)}]}')"
|
|
|
|
case "$cc_event" in
|
|
PreToolUse) pre_entries="$pre_entries$entry"$'\n' ;;
|
|
PostToolUse) post_entries="$post_entries$entry"$'\n' ;;
|
|
Notification) notif_entries="$notif_entries$entry"$'\n' ;;
|
|
SessionStart) sess_entries="$sess_entries$entry"$'\n' ;;
|
|
UserPromptSubmit) prompt_entries="$prompt_entries$entry"$'\n' ;;
|
|
esac
|
|
done < <(enumerate_hooks "$src")
|
|
|
|
# Compose the final settings.json
|
|
local settings; settings='{"hooks":{}}'
|
|
for ev_pair in "PreToolUse:$pre_entries" "PostToolUse:$post_entries" "Notification:$notif_entries" "SessionStart:$sess_entries" "UserPromptSubmit:$prompt_entries"; do
|
|
local ev_name="${ev_pair%%:*}"
|
|
local ev_data="${ev_pair#*:}"
|
|
[[ -z "$ev_data" ]] && continue
|
|
local arr; arr="$(echo "$ev_data" | jq -cs '.')"
|
|
settings="$(echo "$settings" | jq --arg ev "$ev_name" --argjson arr "$arr" '.hooks[$ev] = $arr')"
|
|
done
|
|
|
|
mkdir -p "$dst/.claude"
|
|
echo "$settings" | jq '.' > "$dst/.claude/settings.json"
|
|
}
|
|
|
|
# adapter_translate_agents <source_agents_dir> <dest_root>
|
|
# For each *.md in source_agents_dir, translate the capabilities frontmatter
|
|
# into a CC tools: allowlist and write to dest_root/.claude/agents/<name>.md.
|
|
adapter_translate_agents() {
|
|
local src="$1" dst="$2"
|
|
[[ -d "$src" ]] || return 0
|
|
local out_dir="$dst/.claude/agents"
|
|
mkdir -p "$out_dir"
|
|
|
|
while IFS= read -r agent; do
|
|
[[ -z "$agent" ]] && continue
|
|
should_include "$agent" "$CC_PLATFORM" || continue
|
|
local name; name="$(parse_frontmatter "$agent" name)"
|
|
local model; model="$(parse_frontmatter "$agent" model)"
|
|
model="$(cc_model_to_native "$model")"
|
|
local caps; caps="$(parse_capabilities "$agent")"
|
|
|
|
# Build tools allowlist by expanding each capability.
|
|
# read → Read, Glob, Grep; other capabilities follow.
|
|
local tools=""
|
|
for cap in $caps; do
|
|
local expansion; expansion="$(cc_capability_to_tools "$cap")"
|
|
[[ -n "$expansion" ]] || continue
|
|
for tool in $expansion; do
|
|
if [[ -z "$tools" ]]; then
|
|
tools="$tool"
|
|
else
|
|
tools="$tools, $tool"
|
|
fi
|
|
done
|
|
# If this was "read", immediately append Glob and Grep
|
|
if [[ "$cap" == "read" ]]; then
|
|
tools="$tools, Glob, Grep"
|
|
fi
|
|
done
|
|
|
|
local out_file="$out_dir/$(basename "$agent")"
|
|
{
|
|
echo "---"
|
|
echo "name: $name"
|
|
# Copy description block (may be folded YAML with continuation lines)
|
|
awk '/^---$/{n++; next} n==1 && /^description:/{print; in_desc=1; next} n==1 && in_desc && /^[[:space:]]/{print; next} n==1 && in_desc && !/^[[:space:]]/{in_desc=0} n>=2{exit}' "$agent"
|
|
echo "tools: $tools"
|
|
echo "model: $model"
|
|
echo "---"
|
|
agent_body "$agent"
|
|
} > "$out_file"
|
|
rewrite_platform_paths "$out_file" "$CC_FW_DIR" "$CC_DISPATCHER"
|
|
done < <(enumerate_agents "$src")
|
|
}
|
|
|
|
# adapter_translate_skills <source_skills_dir> <dest_root>
|
|
# Copies each skill directory's SKILL.md into dest_root/.claude/skills/<name>/.
|
|
adapter_translate_skills() {
|
|
local src="$1" dst="$2"
|
|
[[ -d "$src" ]] || return 0
|
|
for skill_dir in "$src"/*/; do
|
|
[[ -f "${skill_dir}SKILL.md" ]] || continue
|
|
should_include "${skill_dir}SKILL.md" "$CC_PLATFORM" || continue
|
|
local name; name="$(basename "$skill_dir")"
|
|
local out="$dst/.claude/skills/$name"
|
|
mkdir -p "$out"
|
|
cp "${skill_dir}SKILL.md" "$out/SKILL.md"
|
|
rewrite_platform_paths "$out/SKILL.md" "$CC_FW_DIR" "$CC_DISPATCHER"
|
|
done
|
|
}
|
|
|
|
# adapter_translate_references <source_refs_dir> <dest_root>
|
|
# Verbatim copy of *.md into dest_root/.claude/references/.
|
|
adapter_translate_references() {
|
|
local src="$1" dst="$2"
|
|
[[ -d "$src" ]] || return 0
|
|
local out="$dst/.claude/references"
|
|
mkdir -p "$out"
|
|
for f in "$src"/*.md; do
|
|
[[ -f "$f" ]] || continue
|
|
should_include "$f" "$CC_PLATFORM" || continue
|
|
cp "$f" "$out/"
|
|
rewrite_platform_paths "$out/$(basename "$f")" "$CC_FW_DIR" "$CC_DISPATCHER"
|
|
done
|
|
}
|
|
|
|
# adapter_translate_dispatcher <source_dispatcher_md> <dest_dir>
|
|
# Copies the source DISPATCHER.md to dest_dir/CLAUDE.md (no content change).
|
|
adapter_translate_dispatcher() {
|
|
local src="$1" dst="$2"
|
|
[[ -f "$src" ]] || return 0
|
|
mkdir -p "$dst"
|
|
cp "$src" "$dst/CLAUDE.md"
|
|
rewrite_platform_paths "$dst/CLAUDE.md" "$CC_FW_DIR" "$CC_DISPATCHER"
|
|
}
|
|
|
|
# adapter_build <source_dir> <dest_dir>
|
|
# The single entry point invoked by scripts/build.sh.
|
|
adapter_build() {
|
|
local src="$1" dst="$2"
|
|
rm -rf "$dst"
|
|
mkdir -p "$dst"
|
|
adapter_translate_dispatcher "$src/DISPATCHER.md" "$dst"
|
|
adapter_translate_references "$src/references" "$dst"
|
|
adapter_translate_skills "$src/skills" "$dst"
|
|
adapter_translate_agents "$src/agents" "$dst"
|
|
adapter_translate_hooks "$src/hooks" "$dst"
|
|
adapter_translate_mcp "$src/mcp" "$dst"
|
|
adapter_finalize "$src" "$dst"
|
|
}
|