Skip to content

Structured multi-perspective deliberation for hard decisions. Run full councils, focused triads, or duo debates across Claude Code, Codex, Gemini CLI, and OpenCode.

feat: add Gemini CLI support (#35)

Selahattin37ba385b670a
diff --git a/SKILL.gemini.md b/SKILL.gemini.md
new file mode 100644
index 0000000..ecdad41
--- /dev/null
+++ b/SKILL.gemini.md
@@ -0,0 +1,227 @@
+---
+name: council
+description: "Convene the Council of High Intelligence in Gemini CLI when the user asks for /council, council deliberation, triads, duo debates, or multi-perspective decision analysis."
+---
+
+# /council for Gemini CLI
+
+You are the Council Coordinator. Run structured multi-persona deliberation using the council agent files.
+
+## Invocation Patterns
+
+```
+/council [problem]
+/council --quick [problem]
+/council --duo [problem]
+/council --triad [domain] [problem]
+/council --members socrates,feynman,ada [problem]
+/council --profile exploration-orthogonal [problem]
+```
+
+## Flags
+
+| Flag | Effect |
+|------|--------|
+| `--full` | Use all 18 members |
+| `--quick` | 2-round fast mode |
+| `--duo` | 2-member polarity dialectic |
+| `--triad [domain]` | Use predefined 3-member panel |
+| `--members a,b,c` | Use explicit member names |
+| `--profile [name]` | Use profile panel (`classic`, `exploration-orthogonal`, `execution-lean`) |
+
+If no panel flag is present, auto-select the best triad from problem context.
+
+## Member Roster
+
+`aristotle, socrates, sun-tzu, ada, aurelius, machiavelli, lao-tzu, feynman, torvalds, musashi, watts, karpathy, sutskever, kahneman, meadows, munger, taleb, rams`
+
+## Triads
+
+| Domain | Members |
+|--------|---------|
+| `architecture` | aristotle, ada, feynman |
+| `strategy` | sun-tzu, machiavelli, aurelius |
+| `ethics` | aurelius, socrates, lao-tzu |
+| `debugging` | feynman, socrates, ada |
+| `innovation` | ada, lao-tzu, aristotle |
+| `conflict` | socrates, machiavelli, aurelius |
+| `complexity` | lao-tzu, aristotle, ada |
+| `risk` | sun-tzu, aurelius, feynman |
+| `shipping` | torvalds, musashi, feynman |
+| `product` | torvalds, machiavelli, watts |
+| `founder` | musashi, sun-tzu, torvalds |
+| `ai` | karpathy, sutskever, ada |
+| `ai-product` | karpathy, torvalds, machiavelli |
+| `ai-safety` | sutskever, aurelius, socrates |
+| `decision` | kahneman, munger, aurelius |
+| `systems` | meadows, lao-tzu, aristotle |
+| `uncertainty` | taleb, sun-tzu, sutskever |
+| `design` | rams, torvalds, watts |
+| `economics` | munger, machiavelli, sun-tzu |
+| `bias` | kahneman, socrates, watts |
+
+## Profiles
+
+- `classic`: all 18 members
+- `exploration-orthogonal`: socrates, feynman, sun-tzu, machiavelli, ada, lao-tzu, aurelius, torvalds, karpathy, sutskever, kahneman, meadows
+- `execution-lean`: torvalds, feynman, sun-tzu, aurelius, ada
+
+## Execution Protocol
+
+### Step 1: Locate Council Assets
+
+Resolve council files in this order:
+
+1. `~/.gemini/extensions/council-of-high-intelligence/skills/council/agents/`
+2. `./agents/`
+
+If neither exists, stop and tell the user to run `./install.sh --gemini`.
+
+### Step 2: Parse Request
+
+Extract:
+
+- Mode: `full` (default), `quick`, or `duo`
+- Problem statement
+- Panel selection via `--members`, `--triad`, `--profile`, or `--full`
+
+For `--duo` without explicit members, choose a polarity pair from keywords:
+
+- architecture/structure: `aristotle` + `lao-tzu`
+- shipping/execution: `torvalds` + `musashi`
+- strategy/competition: `sun-tzu` + `aurelius`
+- ai/ml/model: `karpathy` + `sutskever`
+- decision/bias: `kahneman` + `feynman`
+- default fallback: `socrates` + `feynman`
+
+### Step 2.5: Runtime Reliability Defaults
+
+Use these defaults unless the user requests stricter/faster behavior:
+
+- `spawn_timeout_ms`: 45000 per member
+- `round_timeout_ms`: 60000 for quick/duo, 90000 for full
+- `retry_attempts`: 2 retries after initial attempt (max 3 total attempts per seat per round)
+- `retry_backoff_sec`: 2, then 5
+- `hard_min_live_seats`: 2
+
+Track seat state per member:
+
+- `live`: normal agent responses
+- `degraded`: agent timed out/failed and is being simulated from persona file
+- `offline`: could not recover enough information for this seat
+
+### Step 3: Run Restatement Gate (Parallel)
+
+Dispatch one sub-agent per selected member using the `invoke_agent` tool with `agent_name` set to `generalist`.
+
+Prompt template:
+
+```
+Read and follow this persona file exactly: {agent_file_path}
+
+Problem:
+{problem}
+
+Return only:
+1) Your restatement (one sentence)
+2) Alternative framing (one sentence)
+Maximum 50 words total.
+```
+
+If a seat fails or times out:
+
+1. Retry spawn up to `retry_attempts` using backoff.
+2. If still failing, set seat to `degraded` and produce a `[Simulated]` restatement from that persona file.
+3. If persona file cannot be read, mark seat `offline`.
+
+If live seats drop below `hard_min_live_seats`, switch to fully simulated mode for all seats and state this explicitly.
+
+### Step 3.5: OpenAI-Compatible Seats (NIM and future)
+
+For seats whose provider archetype is `openai_compatible_api` (NVIDIA NIM today; Together / Fireworks / vLLM in the future), dispatch via HTTP rather than the host runtime's `spawn_agent`:
+
+- Read `base_url` and `api_key_env` from the seat config (or detection JSON for auto-routing).
+- Resolve the API key from the env var at routing time. Never inline.
+- POST to `{base_url}/chat/completions` with an OpenAI-compatible payload (system+user messages, `temperature: 0.7`, `max_tokens: 1200`).
+- Extract `.choices[0].message.content`. If empty or non-2xx, mark the seat `degraded` and apply the standard fallback (anthropic per the agent's `model` frontmatter).
+- Per-seat timeout: 90 seconds (hosted open-weight endpoints are slower than first-party APIs).
+- The Round 2 anonymization protocol (Step 4) and Chairman selection (Step 5) apply equally to NIM seats — no special-case logic.
+
+### Step 4: Deliberation Rounds
+
+For each round, dispatch a new `invoke_agent` call to `generalist`. Since `invoke_agent` starts a fresh context, you MUST include the full history of the deliberation for that member in your prompt (i.e. "Here is your persona, here is the problem, here is your Round 1 response, and here are the peer responses...").
+
+**Round 2 anonymization (full and quick modes).** Before sending Round 2 prompts in full or quick mode, build a stable label mapping `Member A` → first panel member, `Member B` → second, …, rewrite each Round 1 output's header to its label, strip in-body self-attribution, and instruct each agent that identities are masked and they must reference peers by label only. Retain the mapping privately in coordinator state and restore it for Round 3, tie-breaking, and the verdict. Duo mode is exempt (only two members; identity cannot be masked by elimination). Rationale: Choi et al. (arXiv:2510.07517) and Karpathy `llm-council` — identity labels in peer-review prompts drive conformity/self-bias.
+
+**Anti-conformity directive (Round 2, all modes).** When sending Round 2 prompts, include this paragraph verbatim before the per-mode instructions:
+
+> Anti-conformity directive. If your Round 1 position was correct, defend it. Do not update merely because peers disagree, because consensus is forming, or because a position is repeated by multiple members. Update only when presented with sound, validity-aligned reasoning that exposes a specific flaw in your earlier argument. Naming that flaw is required when you update; if you cannot name it, you should not update.
+
+Rationale: Choi et al. (arXiv:2510.07517), Free-MAD (arXiv:2509.11035), controlled-study arXiv:2511.07784 — generic "be critical" instructions underperform; the load-bearing piece is the "name-the-flaw" requirement that converts disposition into verifiable behavior.
+
+Full mode:
+
+1. Round 1: Independent analysis, blind-first, max 300 words/member.
+2. Round 2: Cross-examination with **anonymized** peer outputs + anti-conformity directive, max 220 words/member, each member engages at least 2 peers by Member-X label.
+3. Round 3: Final position, max 100 words/member. Real names restored.
+
+Quick mode:
+
+1. Round 1: Restate + rapid analysis, max 200 words/member.
+2. Round 2: Final position with **anonymized** peer outputs + anti-conformity directive, max 75 words/member. Real names restored in the verdict.
+
+Duo mode:
+
+1. Round 1: Opening position, max 250 words/member.
+2. Round 2: Direct response to counterpart with anti-conformity directive, max 180 words/member. (No anonymization — see rationale above.)
+3. Round 3: Final statement, max 60 words/member.
+
+Round execution reliability policy:
+
+1. Send prompts to all `live` seats in parallel via `invoke_agent`.
+2. For each missing response, retry up to `retry_attempts` with a stricter prompt: "Respond now in <= {word_limit} words."
+3. If still missing, move seat to `degraded` and generate `[Simulated]` output from persona instructions plus prior round context.
+4. Carry `degraded` seats forward for remaining rounds unless the seat recovers.
+5. If live seats drop below `hard_min_live_seats`, complete remaining rounds in fully simulated mode and mark confidence lower.
+
+### Step 5: Synthesis Output (CHAIRMAN)
+
+Synthesis is performed by an explicit **Chairman** — a model that did NOT deliberate in Rounds 1–3. The Chairman is selected before Round 1 using this algorithm (first match wins):
+
+1. **Explicit override**: `--chairman <name>` was passed (provider tag or model alias).
+2. **Auto-select**: highest-tier model among available providers, **preferring one not on the panel** when possible. Tie-breaker: provider listed first by the host runtime.
+3. **Single-provider fallback**: use that provider's highest tier and note the overlap in the verdict.
+
+The Chairman is dispatched as a single call with the full audit transcript (Round 2 de-anonymized using the mapping retained in coordinator state — see Step 4 anonymization). Constraint: Chairman MUST NOT be a deliberating member in the same session.
+
+Return a verdict with this order, produced by the Chairman:
+
+1. `Selected Panel` (members + mode)
+2. `Chairman` (name, provider, model, selection rationale)
+3. `Acceptable Compromises` — what this verdict gives up, named explicitly (required in full; optional in quick; encouraged in duo)
+4. `Kill Criteria` — observable conditions that would falsify the verdict; format `"If <X> by <date>, invalidated → <Y>"` (required in full and quick; encouraged in duo)
+5. `Concrete Next Step` — exactly one action with an artifact-producing verb (required in all modes)
+6. `Unresolved Questions`
+7. `Key Agreements`
+8. `Key Disagreements`
+9. `Decision Options` (2-4 options with tradeoffs)
+10. `Recommended Next Steps` (additional actions beyond Concrete Next Step; ordered)
+11. `Confidence` (high/medium/low + why)
+12. `Execution Reliability` (live/degraded/offline seat counts and any timeout caveats)
+
+Always preserve dissent. Never flatten disagreements into fake consensus. Sections 3-5 are non-negotiable in full mode — they make the verdict operational (observable, falsifiable, actionable) instead of advisory prose.
+
+**Chairman fallback**: if the Chairman call fails or times out, the coordinator synthesizes the verdict directly and annotates `Chairman: <name> (FAILED — synthesized by coordinator fallback)`.
+
+### Step 6: Fallback Behavior
+
+If `invoke_agent` is unavailable or too many seats fail, run a local simulated council:
+
+- Read each selected persona file.
+- Produce clearly labeled `[Simulated]` outputs per member.
+- Keep the same round structure.
+- Explicitly state why fallback was used (`invoke_agent unavailable`, `timeouts`, or `seat failures`).
+
+### Step 7: Session Metadata (issue #7, Phase 1)
+
+After the verdict is emitted, append a `Session Metadata` block with `schema_version: 1` containing: `mode`, `panel_size`, `rounds_run`, `tools_used`, `provider_count`, `fallbacks_triggered`, and best-effort `input_tokens_estimate` / `output_tokens_estimate` / `duration_seconds` (write `~unknown` if not available from the host runtime). Block is delimited by `---` so it's grep-able and redirectable.
diff --git a/install.sh b/install.sh
index 2ff00c4..ee20bab 100755
--- a/install.sh
+++ b/install.sh
@@ -4,22 +4,27 @@ set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CLAUDE_DIR="${HOME}/.claude"
CODEX_DIR="${HOME}/.codex"
+GEMINI_DIR="${HOME}/.gemini"
DRY_RUN=false
COPY_CONFIGS=false
INSTALL_CLAUDE=true
INSTALL_CODEX=false
+INSTALL_GEMINI=false
usage() {
cat <<'EOF'
-Usage: ./install.sh [--claude-dir PATH] [--codex-dir PATH] [--codex] [--codex-only] [--copy-configs] [--dry-run] [--help]
+Usage: ./install.sh [--claude-dir PATH] [--codex-dir PATH] [--gemini-dir PATH] [--codex] [--codex-only] [--gemini] [--gemini-only] [--copy-configs] [--dry-run] [--help]
-Install Council of High Intelligence into Claude Code and/or Codex skill directories.
+Install Council of High Intelligence into Claude Code, Codex, and/or Gemini CLI skill directories.
Options:
--claude-dir PATH Target Claude config directory (default: ~/.claude)
--codex-dir PATH Target Codex config directory (default: ~/.codex)
+ --gemini-dir PATH Target Gemini config directory (default: ~/.gemini)
--codex Also install a Codex-compatible council skill
- --codex-only Install only the Codex skill (skip Claude install)
+ --codex-only Install only the Codex skill
+ --gemini Also install a Gemini-compatible council skill
+ --gemini-only Install only the Gemini skill
--copy-configs Also install repo configs/ into skill config folders
--dry-run Print actions without writing files
--help Show this help message
@@ -46,6 +51,15 @@ while [[ $# -gt 0 ]]; do
CODEX_DIR="$2"
shift 2
;;
+ --gemini-dir)
+ if [[ $# -lt 2 ]]; then
+ echo "Error: --gemini-dir requires a path argument" >&2
+ usage
+ exit 1
+ fi
+ GEMINI_DIR="$2"
+ shift 2
+ ;;
--codex)
INSTALL_CODEX=true
shift
@@ -55,6 +69,15 @@ while [[ $# -gt 0 ]]; do
INSTALL_CODEX=true
shift
;;
+ --gemini)
+ INSTALL_GEMINI=true
+ shift
+ ;;
+ --gemini-only)
+ INSTALL_CLAUDE=false
+ INSTALL_GEMINI=true
+ shift
+ ;;
--copy-configs)
COPY_CONFIGS=true
shift
@@ -75,7 +98,7 @@ while [[ $# -gt 0 ]]; do
esac
done
-if [[ "${INSTALL_CLAUDE}" == false ]] && [[ "${INSTALL_CODEX}" == false ]]; then
+if [[ "${INSTALL_CLAUDE}" == false ]] && [[ "${INSTALL_CODEX}" == false ]] && [[ "${INSTALL_GEMINI}" == false ]]; then
echo "Error: no install target selected" >&2
usage
exit 1
@@ -104,6 +127,11 @@ if [[ "${INSTALL_CODEX}" == true ]] && [[ ! -f "${SCRIPT_DIR}/SKILL.codex.md" ]]
exit 1
fi
+if [[ "${INSTALL_GEMINI}" == true ]] && [[ ! -f "${SCRIPT_DIR}/SKILL.gemini.md" ]]; then
+ echo "Error: SKILL.gemini.md not found at ${SCRIPT_DIR}/SKILL.gemini.md" >&2
+ exit 1
+fi
+
shopt -s nullglob
agent_files=("${SCRIPT_DIR}"/agents/council-*.md)
shopt -u nullglob
@@ -217,6 +245,71 @@ if [[ "${INSTALL_CODEX}" == true ]]; then
fi
fi
+if [[ "${INSTALL_GEMINI}" == true ]]; then
+ echo
+ GEMINI_EXT_ROOT="${GEMINI_DIR}/extensions/council-of-high-intelligence"
+ GEMINI_EXT_DEST_DIR="${GEMINI_EXT_ROOT}/skills/council"
+ GEMINI_SKILL_DEST="${GEMINI_EXT_DEST_DIR}/SKILL.md"
+ GEMINI_AGENTS_DEST_DIR="${GEMINI_EXT_DEST_DIR}/agents"
+ GEMINI_SCRIPTS_DEST_DIR="${GEMINI_EXT_DEST_DIR}/scripts"
+ GEMINI_CONFIGS_DEST_DIR="${GEMINI_EXT_DEST_DIR}/configs"
+
+ echo "Gemini target directory: ${GEMINI_DIR}"
+ echo "Creating Gemini destination directories..."
+ run_cmd mkdir -p "${GEMINI_EXT_DEST_DIR}" "${GEMINI_AGENTS_DEST_DIR}" "${GEMINI_SCRIPTS_DEST_DIR}"
+
+ echo "Writing gemini-extension.json manifest..."
+ if [[ "$DRY_RUN" == false ]]; then
+ cat <<EOF > "${GEMINI_EXT_ROOT}/gemini-extension.json"
+{
+ "name": "council-of-high-intelligence",
+ "version": "1.0.0",
+ "description": "Council of High Intelligence multiple persona deliberation system"
+}
+EOF
+ else
+ echo "[dry-run] Create ${GEMINI_EXT_ROOT}/gemini-extension.json"
+ fi
+
+ echo "Installing Gemini council skill..."
+ run_cmd install -m 0644 "${SCRIPT_DIR}/SKILL.gemini.md" "${GEMINI_SKILL_DEST}"
+
+ echo "Installing Gemini council agents..."
+ gemini_agents_installed=0
+ for agent_file in "${agent_files[@]}"; do
+ run_cmd install -m 0644 "${agent_file}" "${GEMINI_AGENTS_DEST_DIR}/"
+ ((gemini_agents_installed+=1))
+ done
+
+ echo "Installing Gemini council scripts..."
+ gemini_scripts_installed=0
+ shopt -s nullglob
+ gemini_script_files=("${SCRIPT_DIR}"/scripts/detect-*.sh)
+ shopt -u nullglob
+ for script_file in "${gemini_script_files[@]}"; do
+ run_cmd install -m 0755 "${script_file}" "${GEMINI_SCRIPTS_DEST_DIR}/"
+ ((gemini_scripts_installed+=1))
+ done
+
+ gemini_configs_installed=0
+ if [[ "$COPY_CONFIGS" == true ]]; then
+ if [[ -d "${CONFIGS_SRC_DIR}" ]]; then
+ run_cmd mkdir -p "${GEMINI_CONFIGS_DEST_DIR}"
+ shopt -s nullglob
+ gemini_config_files=("${CONFIGS_SRC_DIR}"/*)
+ shopt -u nullglob
+ for config_file in "${gemini_config_files[@]}"; do
+ if [[ -f "${config_file}" ]]; then
+ run_cmd install -m 0644 "${config_file}" "${GEMINI_CONFIGS_DEST_DIR}/"
+ ((gemini_configs_installed+=1))
+ fi
+ done
+ else
+ echo "Warning: --copy-configs was set but ${CONFIGS_SRC_DIR} does not exist."
+ fi
+ fi
+fi
+
echo
echo "Done."
if [[ "${INSTALL_CLAUDE}" == true ]]; then
@@ -235,11 +328,13 @@ if [[ "${INSTALL_CODEX}" == true ]]; then
echo " Installed ${codex_configs_installed} Codex config files to ${CODEX_CONFIGS_DEST_DIR}"
fi
fi
-
-if [[ "${INSTALL_CLAUDE}" == true ]] && [[ "${INSTALL_CODEX}" == true ]]; then
- echo "Restart Claude Code and Codex, then use /council."
-elif [[ "${INSTALL_CLAUDE}" == true ]]; then
- echo "Restart Claude Code and use /council to convene the council."
-else
- echo "Restart Codex and use /council to convene the council."
+if [[ "${INSTALL_GEMINI}" == true ]]; then
+ echo " Installed Gemini skill to ${GEMINI_SKILL_DEST}"
+ echo " Installed ${gemini_agents_installed} Gemini council agents to ${GEMINI_AGENTS_DEST_DIR}"
+ echo " Installed ${gemini_scripts_installed} Gemini scripts to ${GEMINI_SCRIPTS_DEST_DIR}"
+ if [[ "$COPY_CONFIGS" == true ]]; then
+ echo " Installed ${gemini_configs_installed} Gemini config files to ${GEMINI_CONFIGS_DEST_DIR}"
+ fi
fi
+
+echo "Restart your CLI client(s) and use /council to convene the council."