Files
My-Brain-Is-Full-Crew/tests/scripts/platform-parity.test.sh
Arpit Behera 3dde38e284 feat: add Codex CLI as a first-class fourth platform
Rebuilt from scratch following Codex CLI's actual architecture (as
outlined in the review on PR #26). Closes the integration gap with a
proper build adapter, correct install paths, TOML agent files, and
all the architectural differences documented and tested.

What changed vs the previous attempt (PR #26):

- Agents: build adapter generates .toml files (name/description/
  developer_instructions) into dist/codex-cli/.codex/agents/ instead
  of copying .md files with sed transforms
- Skills: installed to .agents/skills/ (correct Codex discovery path)
  instead of .codex/skills/
- Dispatcher: AGENTS.md uses a root-context orchestration header that
  works within agents.max_depth=1 constraints; named-agent routing
  replaced with embedded-instructions workaround for the known
  spawn_agents limitation (openai/codex#15250)
- Tool compat: AskUserQuestion and request_user_input removed; all
  prompts adapted to Codex's actual tool set and approval/confirmation
  flow
- Installer/updater: launchme.sh --platform codex-cli and updateme.sh
  with Codex auto-detection, creating the correct split layout
  (AGENTS.md + .codex/agents/ + .codex/config.toml + .agents/skills/)
- Tests: new per-adapter test suite (tests/adapters/codex-cli/),
  install/update smoke (tests/scripts/codex-cli-install.test.sh), and
  a four-platform parity gate that proves Codex changes do not regress
  Claude Code, Gemini CLI, or OpenCode
- Docs: new codex-cli.md guide, codex-migration.md for users switching
  from other platforms, and README/getting-started/examples updated for
  four-platform positioning
- Bash harness: .gitattributes added to enforce LF on .sh files;
  harness LF-normalized so tests/run.sh works on Windows checkouts
- .gitignore: .planning/ added (internal GSD workflow artifacts)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-12 17:45:10 +03:00

90 lines
4.3 KiB
Bash

#!/usr/bin/env bash
# =============================================================================
# tests/scripts/platform-parity.test.sh — Four-platform build parity suite
# =============================================================================
# Proves that Codex CLI changes did not regress Claude Code, Gemini CLI,
# OpenCode, or Codex CLI build artifacts. Runs as part of tests/run.sh.
# =============================================================================
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
# ---------------------------------------------------------------------------
# test_platform_build_matrix_produces_expected_dispatchers_and_roots
#
# Builds all four platforms and asserts each produces the correct dispatcher,
# platform config directory, and at least one canonical agent file.
# ---------------------------------------------------------------------------
test_platform_build_matrix_produces_expected_dispatchers_and_roots() {
local result=0
# Platform → expected artifacts map
# Format: "<dispatcher>|<agent_file>|<config_file>"
declare -A EXPECTED
EXPECTED["claude-code"]="dist/claude-code/CLAUDE.md|dist/claude-code/.claude/agents/architect.md|dist/claude-code/.mcp.json"
EXPECTED["gemini-cli"]="dist/gemini-cli/GEMINI.md|dist/gemini-cli/.gemini/agents/architect.md|dist/gemini-cli/.gemini/settings.json"
EXPECTED["opencode"]="dist/opencode/AGENTS.md|dist/opencode/.opencode/agents/architect.md|dist/opencode/opencode.json"
EXPECTED["codex-cli"]="dist/codex-cli/AGENTS.md|dist/codex-cli/.codex/agents/architect.toml|dist/codex-cli/.codex/config.toml"
for platform in claude-code gemini-cli opencode codex-cli; do
if ! bash "$ROOT/scripts/build.sh" --platform "$platform" >/dev/null 2>&1; then
echo "FAIL: build failed for platform: $platform"
result=1
continue
fi
IFS='|' read -r dispatcher agent_file config_file <<< "${EXPECTED[$platform]}"
[[ -f "$ROOT/$dispatcher" ]] \
|| { echo "FAIL [$platform]: dispatcher missing: $dispatcher"; result=1; }
[[ -f "$ROOT/$agent_file" ]] \
|| { echo "FAIL [$platform]: agent file missing: $agent_file"; result=1; }
[[ -f "$ROOT/$config_file" ]] \
|| { echo "FAIL [$platform]: config file missing: $config_file"; result=1; }
done
# Additional Codex-specific: skills directory
[[ -f "$ROOT/dist/codex-cli/.agents/skills/onboarding/SKILL.md" ]] \
|| { echo "FAIL [codex-cli]: .agents/skills/onboarding/SKILL.md missing"; result=1; }
return $result
}
# ---------------------------------------------------------------------------
# test_claude_snapshot_regression_still_passes_after_codex_changes
#
# Runs the Claude Code snapshot regression test. Fails immediately if the
# snapshot diff reports any drift — Codex changes must not touch Claude output.
# ---------------------------------------------------------------------------
test_claude_snapshot_regression_still_passes_after_codex_changes() {
local log; log="$(mktemp)"
if ! bash "$ROOT/tests/regression/run.sh" >"$log" 2>&1; then
echo "FAIL: Claude snapshot regression reported drift:"
cat "$log"
rm -f "$log"
return 1
fi
rm -f "$log"
return 0
}
# ---------------------------------------------------------------------------
# test_codex_install_update_gate_remains_in_the_full_suite
#
# Asserts that the Codex CLI install/update test file still exists and
# defines both required test function names. This gate ensures the parity
# suite does not accidentally exclude Codex install regression coverage.
# ---------------------------------------------------------------------------
test_codex_install_update_gate_remains_in_the_full_suite() {
local install_test="$ROOT/tests/scripts/codex-cli-install.test.sh"
local result=0
[[ -f "$install_test" ]] \
|| { echo "FAIL: tests/scripts/codex-cli-install.test.sh does not exist"; return 1; }
grep -q 'test_launchme_installs_codex_cli_layout' "$install_test" \
|| { echo "FAIL: test_launchme_installs_codex_cli_layout not found in codex-cli-install.test.sh"; result=1; }
grep -q 'test_updateme_auto_detects_and_refreshes_codex_cli_install' "$install_test" \
|| { echo "FAIL: test_updateme_auto_detects_and_refreshes_codex_cli_install not found in codex-cli-install.test.sh"; result=1; }
return $result
}