code-context-control 2.129.2__py3-none-any.whl → 2.136.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. cli/_hook_utils.py +9 -1
  2. cli/c3.py +98 -12
  3. cli/commands/parser.py +27 -5
  4. cli/docs.html +59 -14
  5. cli/guide/getting-started.html +11 -1
  6. cli/guide/tools.html +38 -11
  7. cli/guide/workflow.html +2 -2
  8. cli/hook_access_guard.py +36 -0
  9. cli/hook_dispatch.py +43 -3
  10. cli/hook_session_stats.py +23 -2
  11. cli/hub_server.py +3 -2
  12. cli/hub_ui/components/mcp_manager.js +2 -2
  13. cli/hub_ui/components/modals.js +1 -0
  14. cli/hub_ui/state.js +2 -0
  15. cli/mcp_server.py +8 -4
  16. cli/server.py +3 -3
  17. cli/tools/delegate.py +1184 -143
  18. cli/tools/status.py +15 -0
  19. cli/ui/components/instructions.js +1 -0
  20. cli/ui/components/settings.js +81 -5
  21. {code_context_control-2.129.2.dist-info → code_context_control-2.136.0.dist-info}/METADATA +10 -5
  22. {code_context_control-2.129.2.dist-info → code_context_control-2.136.0.dist-info}/RECORD +50 -43
  23. core/config.py +28 -1
  24. core/grok_payload.py +121 -0
  25. core/hook_command.py +22 -0
  26. core/host.py +5 -1
  27. core/ide.py +19 -0
  28. oracle/services/c3_bridge.py +6 -1
  29. oracle/services/chat_engine.py +1 -1
  30. services/access_guard.py +8 -1
  31. services/agents.py +12 -11
  32. services/agents_workflow.py +11 -0
  33. services/bench/delegate_eval.py +575 -0
  34. services/ci_act.py +167 -7
  35. services/ci_runner.py +186 -14
  36. services/ci_workflow.py +96 -13
  37. services/claude_md.py +3 -3
  38. services/codex_integration.py +7 -8
  39. services/delegate_agents.py +108 -0
  40. services/grok_integration.py +200 -0
  41. services/grok_transcript.py +73 -0
  42. services/host_sessions.py +1 -1
  43. services/session_manager.py +4 -0
  44. services/telemetry.py +65 -0
  45. tui/screens/init_view.py +1 -1
  46. tui/screens/mcp_view.py +1 -1
  47. {code_context_control-2.129.2.dist-info → code_context_control-2.136.0.dist-info}/WHEEL +0 -0
  48. {code_context_control-2.129.2.dist-info → code_context_control-2.136.0.dist-info}/entry_points.txt +0 -0
  49. {code_context_control-2.129.2.dist-info → code_context_control-2.136.0.dist-info}/licenses/LICENSE +0 -0
  50. {code_context_control-2.129.2.dist-info → code_context_control-2.136.0.dist-info}/top_level.txt +0 -0
cli/_hook_utils.py CHANGED
@@ -392,20 +392,28 @@ def record_unlocked_files(
392
392
  # hookSpecificOutput.hookEventName is REQUIRED. Unknown keys are a
393
393
  # hard deserialization error, not a warning, so emitting the Claude
394
394
  # shape makes Codex discard the whole hook response.
395
+ # grok — Grok Build: native tool names and tagged results on the way in
396
+ # (core/grok_payload.translate); context only under
397
+ # hookSpecificOutput, and Stop context would keep the agent working.
395
398
  HOST_CLAUDE = "claude"
396
399
  HOST_GEMINI = "gemini"
397
400
  HOST_CODEX = "codex"
401
+ HOST_GROK = "grok"
398
402
 
399
403
 
400
404
  def detect_host(data: dict, explicit_host: str | None = None) -> str:
401
405
  """Use the hook's explicit host or wire identity, never its parent's env."""
402
406
  named = explicit_host or (data.get("_c3_host") if isinstance(data, dict) else None)
403
407
  aliases = {"claude-code": HOST_CLAUDE, "claude": HOST_CLAUDE,
404
- "codex": HOST_CODEX, "gemini": HOST_GEMINI, "antigravity": HOST_GEMINI}
408
+ "codex": HOST_CODEX, "gemini": HOST_GEMINI, "antigravity": HOST_GEMINI,
409
+ "grok": HOST_GROK, "grok-build": HOST_GROK}
405
410
  if named in aliases:
406
411
  return aliases[named]
407
412
  if not isinstance(data, dict):
408
413
  return HOST_CLAUDE
414
+ from core.grok_payload import is_grok_payload
415
+ if is_grok_payload(data):
416
+ return HOST_GROK
409
417
  if data.get("turn_id"):
410
418
  return HOST_CODEX
411
419
  response = data.get("tool_response")
cli/c3.py CHANGED
@@ -91,7 +91,7 @@ console = Console() if HAS_RICH else None
91
91
  # Config
92
92
  CONFIG_DIR = ".c3"
93
93
  CONFIG_FILE = ".c3/config.json"
94
- __version__ = "2.129.2"
94
+ __version__ = "2.136.0"
95
95
 
96
96
 
97
97
  def _compress_file_cli(compressor, path, mode="smart", **kw):
@@ -316,7 +316,7 @@ _BASH_STANDARD = _BASH_READONLY + [
316
316
  "Bash(pip:*)", "Bash(pip3:*)", "Bash(npm:*)", "Bash(node:*)",
317
317
  "Bash(cargo:*)", "Bash(go:*)",
318
318
  # AI CLIs
319
- "Bash(claude:*)", "Bash(codex:*)", "Bash(gemini:*)",
319
+ "Bash(claude:*)", "Bash(codex:*)", "Bash(gemini:*)", "Bash(grok:*)",
320
320
  # Utilities
321
321
  "Bash(timeout:*)", "Bash(time:*)", "Bash(curl:*)", "Bash(gh:*)",
322
322
  "Bash(for:*)", "Bash(do:*)", "Bash(done:*)",
@@ -755,6 +755,7 @@ def _select_init_ide(default_ide: str) -> str:
755
755
  "Cursor — .cursor/mcp.json",
756
756
  "Codex — .codex/config.toml + AGENTS.md",
757
757
  "Antigravity — ~/.gemini/antigravity/mcp_config.json + AGENTS.md",
758
+ "Grok Build — .grok/config.toml + .grok/hooks + AGENTS.md",
758
759
  ]
759
760
  selected = _prompt_choice("Step 1/3 — Choose IDE profile", choices)
760
761
  mapping = {
@@ -764,6 +765,7 @@ def _select_init_ide(default_ide: str) -> str:
764
765
  choices[3]: "cursor",
765
766
  choices[4]: "codex",
766
767
  choices[5]: "antigravity",
768
+ choices[6]: "grok",
767
769
  }
768
770
  chosen = mapping.get(selected or "", normalize_ide_name(default_ide) if default_ide != "auto" else "auto")
769
771
  print(f" IDE profile: {chosen}")
@@ -1034,7 +1036,7 @@ def _parse_cli_ide_arg(value: str) -> str:
1034
1036
  normalized = normalize_ide_name(raw)
1035
1037
  if normalized not in PROFILES:
1036
1038
  raise argparse.ArgumentTypeError(
1037
- "Unsupported IDE. Use one of: auto, claude, vscode, cursor, codex, antigravity."
1039
+ "Unsupported IDE. Use one of: auto, claude, vscode, cursor, codex, antigravity, grok."
1038
1040
  )
1039
1041
  return normalized
1040
1042
 
@@ -1569,6 +1571,51 @@ def cmd_shell_eval(args):
1569
1571
  sys.exit(1)
1570
1572
 
1571
1573
 
1574
+ def cmd_delegate_eval(args):
1575
+ """Grade c3_delegate answers per target and name the cheapest passing tier.
1576
+
1577
+ Live by default (every case goes to the real backend and costs what that
1578
+ backend costs); --replay grades a recorded run instead. Exit status 1 when
1579
+ a --floor is given and a target's core pass rate falls under it. See
1580
+ docs/delegate-eval.md.
1581
+ """
1582
+ from services.bench import delegate_eval as de
1583
+
1584
+ targets = [t.strip() for t in (args.targets or "").split(",") if t.strip()]
1585
+ case_ids = [c.strip() for c in (args.cases or "").split(",") if c.strip()]
1586
+ overrides = json.loads(args.config) if getattr(args, "config", None) else None
1587
+ if overrides is not None and not isinstance(overrides, dict):
1588
+ raise RuntimeError("--config must be a JSON object")
1589
+
1590
+ def progress(res):
1591
+ if not args.json:
1592
+ cost = "" if res.cost_usd is None else f" ${res.cost_usd:.4f}"
1593
+ print(f" {res.target:<16} {res.id:<28} {res.status}{cost} "
1594
+ f"{res.wall_ms / 1000:.1f}s", flush=True)
1595
+
1596
+ try:
1597
+ report = de.run_suite(
1598
+ args.suite, targets=targets or None, replay=args.replay, record=args.record,
1599
+ case_ids=case_ids or None, floor=args.floor if args.floor is not None else de.DEFAULT_FLOOR,
1600
+ allow_write_delegation=args.allow_write_delegation, delegate_overrides=overrides,
1601
+ progress=progress)
1602
+ except (FileNotFoundError, ValueError) as e:
1603
+ raise RuntimeError(str(e))
1604
+
1605
+ if args.json:
1606
+ print(json.dumps(report.to_dict(), indent=2))
1607
+ else:
1608
+ print(report.render())
1609
+ if args.record and report.mode == "live":
1610
+ print(f"recorded: {args.record}")
1611
+ if args.floor is not None:
1612
+ under = [t for t, a in report.aggregates.items()
1613
+ if a["pass_rate_core"] is None or a["pass_rate_core"] < args.floor]
1614
+ if under:
1615
+ print(f"under floor {args.floor}: {', '.join(under)}", file=sys.stderr)
1616
+ sys.exit(1)
1617
+
1618
+
1572
1619
  def cmd_map_eval(args):
1573
1620
  """Run the file-map gold suite and compare it to its baseline.
1574
1621
 
@@ -4333,9 +4380,9 @@ _C3_HOOKLESS_WORKFLOW = _adapt_workflow_for_ide(
4333
4380
 
4334
4381
  _COPILOT_INSTRUCTIONS_CONTENT = _VSCODE_SESSION_INIT + "\n\n" + _C3_HOOKLESS_WORKFLOW
4335
4382
 
4336
- from services.codex_integration import CODEX_WORKFLOW
4383
+ from services.agents_workflow import AGENTS_MD_WORKFLOW
4337
4384
 
4338
- _AGENTS_MD_CONTENT = CODEX_WORKFLOW
4385
+ _AGENTS_MD_CONTENT = AGENTS_MD_WORKFLOW
4339
4386
 
4340
4387
  _TERSE_SKILL_CONTENT = """\
4341
4388
  # /terse — Terse Output Mode
@@ -4544,7 +4591,7 @@ def _ensure_instruction_workflow(instructions_path: Path, template: str,
4544
4591
 
4545
4592
  def _ensure_codex_agents_workflow(agents_md_path: Path,
4546
4593
  project_path: str = "") -> str:
4547
- """Ensure AGENTS.md contains the mandatory C3 workflow for Codex sessions."""
4594
+ """Ensure AGENTS.md contains the mandatory C3 workflow (Codex and Grok Build read it)."""
4548
4595
  from services.claude_md import write_c3_instruction_doc
4549
4596
  existing = agents_md_path.read_text(encoding="utf-8") if agents_md_path.exists() else None
4550
4597
  rendered = write_c3_instruction_doc(agents_md_path, _AGENTS_MD_CONTENT, project_path or None)
@@ -4888,8 +4935,15 @@ def _uninstall_mcp_all(project_path: str, include_global: bool = True):
4888
4935
  except Exception as e:
4889
4936
  print(f" Warning: Could not update {mcp_config_path}: {e}")
4890
4937
 
4938
+ # Grok Build: C3 owns the whole .grok/hooks/c3.json, so it is deleted
4939
+ # rather than stripped (its Windows commands are encoded and would not
4940
+ # match the settings scanner anyway).
4941
+ if ide_name == "grok":
4942
+ from services.grok_integration import remove_hooks as remove_grok_hooks
4943
+ if remove_grok_hooks(target):
4944
+ print(f" Deleted {target / profile.settings_path}")
4891
4945
  # Per-host hooks and settings; remove only C3-owned handlers.
4892
- if profile.supports_hooks and profile.settings_path:
4946
+ elif profile.supports_hooks and profile.settings_path:
4893
4947
  settings_path = target / profile.settings_path
4894
4948
  if settings_path.exists():
4895
4949
  try:
@@ -4970,7 +5024,7 @@ def _uninstall_mcp_all(project_path: str, include_global: bool = True):
4970
5024
  print(f" Warning: Could not update {legacy_cfg}: {e}")
4971
5025
 
4972
5026
  # Final pass: clean up empty IDE directories (.claude, .codex, .gemini, .vscode, .github)
4973
- dirs_to_check = [".claude", ".codex", ".gemini", ".vscode", ".github"]
5027
+ dirs_to_check = [".claude", ".codex", ".grok", ".gemini", ".vscode", ".github"]
4974
5028
  for dname in dirs_to_check:
4975
5029
  dpath = target / dname
4976
5030
  if dpath.exists() and dpath.is_dir():
@@ -5011,7 +5065,7 @@ back to native tools as the task progresses.
5011
5065
  - **Filter**: `c3_filter(text=...)` — for terminal output >10 lines
5012
5066
  - **Shell**: `c3_shell(cmd, timeout=60)` — structured shell exec (tests/git/build). Auto-filters output, logs git mutations to the ledger. Native Bash for interactive/TTY only
5013
5067
  - **Memory**: `c3_memory(action='recall')` — full recall. `index` + `fetch` for token-efficient two-step retrieval
5014
- - **Delegate**: `c3_delegate(task, backend='ollama|codex|gemini|claude|auto')` — offload to other models
5068
+ - **Delegate**: `c3_delegate(task, task_type, context|file_path)` — your own provider one tier down (default `backend='host'`, `tier='small'`; Claude Code: Haiku) for bounded answers: summarize a diff/log, explain a function, triage a traceback. `scout=true` lets it look files up itself. Multi-step work: the `c3-scout` (haiku) / `c3-worker` (sonnet) subagents
5015
5069
  - **Local CI** (v2.79.0+): `c3_ci(action='inspect|run|rerun|failures')` — run THIS repo's real `.github/workflows` here instead of pushing for feedback. `run` executes in `needs` order; `failures` gives {file,line,message}; `rerun` retries only what failed. Only `FULL_CI_PASS` means safe to push — `PARTIAL_PASS` means something did not run (other OS, unsupported action, or your selection).
5016
5070
  - **Bitbucket** (v2.30.0+, when `c3 bitbucket login` has run): `c3_bitbucket(action='list_prs|get_pr|merge_pr|...')` — self-hosted Bitbucket Data Center / Server. Token in OS keyring; mutating actions auto-log to the edit ledger.
5017
5071
  - **Cross-project** (v2.31.0+): `c3_project(action='list|scan|search|read|edit|...', project='<name|path>')` — discover and operate on OTHER c3-installed projects. Reads run freely; writes (edit/shell/memory) need `allow_write=true`.
@@ -5466,6 +5520,12 @@ def cmd_install_mcp(args):
5466
5520
  toml_entries["startup_timeout_sec"] = 30
5467
5521
  toml_entries["tool_timeout_sec"] = 60
5468
5522
  toml_entries["args"] += ["--host", "codex"]
5523
+ elif profile.name == "grok":
5524
+ # Grok's default startup timeout is 30s; a cold C3 index build can
5525
+ # exceed it. Its tool timeout already defaults to 6000s.
5526
+ toml_entries["enabled"] = True
5527
+ toml_entries["startup_timeout_sec"] = 60
5528
+ toml_entries["args"] += ["--host", "grok"]
5469
5529
  _upsert_toml_section(
5470
5530
  mcp_config_path,
5471
5531
  f"{profile.config_key}.c3",
@@ -5517,6 +5577,13 @@ def cmd_install_mcp(args):
5517
5577
  from services.codex_integration import install_hooks
5518
5578
  hook_state = install_hooks(target, sys.executable, cli_dir / "hook_dispatch.py")
5519
5579
  print(f"Codex hooks installed; active: {hook_state['active']}. {hook_state['activation']}")
5580
+ if profile.name == "grok":
5581
+ from services.grok_integration import install_hooks as install_grok_hooks
5582
+ grok_hooks = install_grok_hooks(target, sys.executable, cli_dir / "hook_dispatch.py")
5583
+ from services.artifact_defs import note_pending_write
5584
+ note_pending_write(target, profile.settings_path, "install_mcp")
5585
+ print(f"Wrote {target / profile.settings_path}")
5586
+ print(f"Grok Build: {grok_hooks['activation']}")
5520
5587
  if profile.name == "claude-code" and profile.supports_hooks and profile.settings_path:
5521
5588
  settings_dir = target / Path(profile.settings_path).parent
5522
5589
  settings_dir.mkdir(parents=True, exist_ok=True)
@@ -5812,8 +5879,8 @@ def cmd_install_mcp(args):
5812
5879
  print(f"Wrote {vscode_settings_path}")
5813
5880
  print(" Copilot: C3 instructions linked for code gen, review, and test generation")
5814
5881
 
5815
- # ── Codex AGENTS.md enforcement file ──────────────────────
5816
- if profile.name == "codex":
5882
+ # ── Codex / Grok Build AGENTS.md enforcement file ────────────
5883
+ if profile.name in ("codex", "grok"):
5817
5884
  agents_md_path = target / "AGENTS.md"
5818
5885
  agents_state = _ensure_codex_agents_workflow(agents_md_path,
5819
5886
  str(target))
@@ -5824,6 +5891,7 @@ def cmd_install_mcp(args):
5824
5891
  else:
5825
5892
  print(f"Kept {agents_md_path} (C3 workflow present)")
5826
5893
 
5894
+ if profile.name == "codex":
5827
5895
  # Warn about a common conflict: global Codex config disables c3.
5828
5896
  global_codex_cfg = Path(os.environ.get("CODEX_HOME") or Path.home() / ".codex") / "config.toml"
5829
5897
  global_enabled = _toml_section_bool_value(global_codex_cfg, "mcp_servers.c3", "enabled")
@@ -5855,6 +5923,20 @@ def cmd_install_mcp(args):
5855
5923
  except Exception as e:
5856
5924
  print(f"Warning: Could not install /terse skill: {e}")
5857
5925
 
5926
+ # ── Downshift subagents (c3-scout on haiku, c3-worker on sonnet) ──
5927
+ if profile.name == "claude-code" and not getattr(args, "no_agents", False):
5928
+ try:
5929
+ from services.delegate_agents import install_delegate_agents
5930
+ for path, action in install_delegate_agents(target):
5931
+ if action == "skipped":
5932
+ print(f"Kept {path} (no C3 marker: yours, left untouched)")
5933
+ elif action == "kept":
5934
+ print(f"Kept {path} (subagent up to date)")
5935
+ else:
5936
+ print(f"{action.capitalize()} {path} (subagent)")
5937
+ except Exception as e:
5938
+ print(f"Warning: Could not install c3-scout/c3-worker subagents: {e}")
5939
+
5858
5940
  print(f"IDE: {profile.display_name}")
5859
5941
  print(f"MCP Mode: {mcp_mode}")
5860
5942
  print(f"Server: {server_script}")
@@ -9303,7 +9385,10 @@ def _launch_tui() -> None:
9303
9385
 
9304
9386
 
9305
9387
  def cmd_doctor(args):
9306
- from services.codex_integration import diagnose
9388
+ if getattr(args, "ide", "codex") == "grok":
9389
+ from services.grok_integration import diagnose
9390
+ else:
9391
+ from services.codex_integration import diagnose
9307
9392
  print(json.dumps(diagnose(Path(args.project_path).resolve()), indent=2))
9308
9393
 
9309
9394
 
@@ -9354,6 +9439,7 @@ def main():
9354
9439
  "search-eval": cmd_search_eval,
9355
9440
  "shell-eval": cmd_shell_eval,
9356
9441
  "map-eval": cmd_map_eval,
9442
+ "delegate-eval": cmd_delegate_eval,
9357
9443
  "benchmark": cmd_benchmark,
9358
9444
  "session-benchmark": cmd_session_benchmark,
9359
9445
  "benchmark-e2e": cmd_benchmark_e2e,
cli/commands/parser.py CHANGED
@@ -17,15 +17,15 @@ def build_parser(version: str, parse_cli_ide_arg):
17
17
  )
18
18
  subparsers = parser.add_subparsers(dest="command")
19
19
 
20
- p_doctor = subparsers.add_parser("doctor", help="Inspect native Codex integration without a model call")
20
+ p_doctor = subparsers.add_parser("doctor", help="Inspect native Codex or Grok Build integration without a model call")
21
21
  p_doctor.add_argument("project_path", nargs="?", default=".")
22
- p_doctor.add_argument("--ide", choices=["codex"], default="codex")
22
+ p_doctor.add_argument("--ide", choices=["codex", "grok"], default="codex")
23
23
 
24
24
  p_init = subparsers.add_parser("init", help="Initialize C3 for a project")
25
25
  p_init.add_argument("project_path", nargs="?", default=".")
26
26
  p_init.add_argument("--force", action="store_true", help="Skip prompts and apply update non-interactively")
27
27
  p_init.add_argument("--clear", action="store_true", help="Remove all C3 files and exit without rebuilding")
28
- p_init.add_argument("--ide", default="auto", type=parse_cli_ide_arg, metavar="{auto,claude,vscode,cursor,codex,antigravity}", help="Target IDE for MCP config (default: auto-detect)")
28
+ p_init.add_argument("--ide", default="auto", type=parse_cli_ide_arg, metavar="{auto,claude,vscode,cursor,codex,antigravity,grok}", help="Target IDE for MCP config (default: auto-detect)")
29
29
  p_init.add_argument("--mcp-mode", choices=["direct", "proxy"], default="direct", help="Default MCP mode if install is selected during init (default: direct)")
30
30
  p_init.add_argument("--git", action="store_true", help="Initialize a local Git repository during init/update")
31
31
  p_init.add_argument("--no-embed", action="store_true", help="Skip building the semantic embedding index during init")
@@ -89,6 +89,26 @@ def build_parser(version: str, parse_cli_ide_arg):
89
89
  help='With --update-baseline: JSON object of metric ceilings, e.g. \'{"tokens_p95": 4000}\'')
90
90
  p_map_eval.add_argument("--json", action="store_true", help="Emit the full report as JSON")
91
91
 
92
+ p_delegate_eval = subparsers.add_parser(
93
+ "delegate-eval", help="Grade c3_delegate answers per backend/tier (docs/delegate-eval.md)")
94
+ p_delegate_eval.add_argument("--suite", default="gold",
95
+ help="'gold' (bundled) or a .jsonl path")
96
+ p_delegate_eval.add_argument("--targets", default="",
97
+ help="Comma-separated backend[:tier] list, e.g. 'claude:small,claude:medium'")
98
+ p_delegate_eval.add_argument("--cases", default="", help="Comma-separated case ids (default: all)")
99
+ p_delegate_eval.add_argument("--replay", default=None,
100
+ help="Grade a recorded run instead of calling backends")
101
+ p_delegate_eval.add_argument("--record", default=None, help="Write the live answers to this JSON file")
102
+ p_delegate_eval.add_argument("--floor", type=float, default=None,
103
+ help="Core pass-rate floor; exit 1 when a target falls under it")
104
+ p_delegate_eval.add_argument("--allow-write-delegation", action="store_true",
105
+ help="Pass allow_write_delegation=true (needed for write-capable backends "
106
+ "when Access Guard rules exist)")
107
+ p_delegate_eval.add_argument("--config", default=None,
108
+ help='JSON object merged over the delegate config for this run, '
109
+ 'e.g. \'{"allow_model_fallback": false}\'')
110
+ p_delegate_eval.add_argument("--json", action="store_true", help="Emit the full report as JSON")
111
+
92
112
  p_compress = subparsers.add_parser("compress", help="Compress a file")
93
113
  p_compress.add_argument("file", help="File to compress")
94
114
  p_compress.add_argument("--mode", choices=["map", "smart", "structure", "outline"], default="map",
@@ -153,19 +173,21 @@ def build_parser(version: str, parse_cli_ide_arg):
153
173
 
154
174
  p_install_mcp = subparsers.add_parser("install-mcp", help="Generate MCP config for your IDE")
155
175
  p_install_mcp.add_argument("targets", nargs="*", help="Optional project path and/or IDE shorthand (for example: `claude` or `. codex`)")
156
- p_install_mcp.add_argument("--ide", default="auto", type=parse_cli_ide_arg, metavar="{auto,claude,vscode,cursor,codex,antigravity}", help="Target IDE (default: auto-detect)")
176
+ p_install_mcp.add_argument("--ide", default="auto", type=parse_cli_ide_arg, metavar="{auto,claude,vscode,cursor,codex,antigravity,grok}", help="Target IDE (default: auto-detect)")
157
177
  p_install_mcp.add_argument("--mcp-mode", choices=["direct", "proxy"], default="direct", help="MCP entrypoint mode (default: direct)")
158
178
  p_install_mcp.add_argument("--global-fallback", action="store_true", help="Also install the machine-wide Codex fallback")
159
179
  p_install_mcp.add_argument("--permissions", choices=["read-only", "c3-strict", "standard", "permissive"], default=None, help="Apply Claude Code permission tier (Claude Code only)")
160
180
  p_install_mcp.add_argument("--include-mcp-wildcard", action="store_true", help="Add mcp__* wildcard so non-C3 MCP servers don't prompt per-call")
181
+ p_install_mcp.add_argument("--no-agents", action="store_true", help="Do not write the c3-scout/c3-worker subagents to .claude/agents (Claude Code only)")
161
182
 
162
183
  p_mcp_install = subparsers.add_parser("mcp-install", help="Alias for install-mcp")
163
184
  p_mcp_install.add_argument("targets", nargs="*", help="Optional project path and/or IDE shorthand")
164
- p_mcp_install.add_argument("--ide", default="auto", type=parse_cli_ide_arg, metavar="{auto,claude,vscode,cursor,codex,antigravity}", help="Target IDE (default: auto-detect)")
185
+ p_mcp_install.add_argument("--ide", default="auto", type=parse_cli_ide_arg, metavar="{auto,claude,vscode,cursor,codex,antigravity,grok}", help="Target IDE (default: auto-detect)")
165
186
  p_mcp_install.add_argument("--mcp-mode", choices=["direct", "proxy"], default="direct", help="MCP entrypoint mode (default: direct)")
166
187
  p_mcp_install.add_argument("--global-fallback", action="store_true", help="Also install the machine-wide Codex fallback")
167
188
  p_mcp_install.add_argument("--permissions", choices=["read-only", "c3-strict", "standard", "permissive"], default=None, help="Apply Claude Code permission tier (Claude Code only)")
168
189
  p_mcp_install.add_argument("--include-mcp-wildcard", action="store_true", help="Add mcp__* wildcard so non-C3 MCP servers don't prompt per-call")
190
+ p_mcp_install.add_argument("--no-agents", action="store_true", help="Do not write the c3-scout/c3-worker subagents to .claude/agents (Claude Code only)")
169
191
 
170
192
  p_mcp_remove = subparsers.add_parser("mcp-remove", help="Remove an MCP server from your IDE config")
171
193
  p_mcp_remove.add_argument("name", help="Name of the MCP server to remove (e.g. 'c3')")
cli/docs.html CHANGED
@@ -789,7 +789,7 @@
789
789
  <h1 id="overview">Code <span>Companion</span></h1>
790
790
  <div class="subtitle">
791
791
  A local code intelligence system that reduces AI coding assistant token usage through compression,
792
- indexing, and persistent memory. Works with <strong>Claude Code</strong>, <strong>Google Antigravity</strong>,
792
+ indexing, and persistent memory. Works with <strong>Claude Code</strong>, <strong>OpenAI Codex</strong>, <strong>Grok Build</strong>, <strong>Google Antigravity</strong>,
793
793
  <strong>VS Code Copilot</strong>, and <strong>Cursor</strong> via MCP. Available as an <strong>MCP
794
794
  server</strong>,
795
795
  <strong>CLI</strong>, and <strong>web dashboard</strong>.
@@ -958,7 +958,9 @@ c3 init /path/to/your/project</code></pre>
958
958
  <code>.github/copilot-instructions.md</code> (hard enforcement language) and
959
959
  <code>.vscode/settings.json</code> (Copilot instruction links). For Codex, generates
960
960
  <code>AGENTS.md</code> with the C3 session protocol. Use <code>--ide vscode</code>,
961
- <code>--ide cursor</code>, or <code>--ide codex</code> to override IDE detection.
961
+ <code>--ide cursor</code>, <code>--ide codex</code>, or <code>--ide grok</code> to override IDE detection.
962
+ For Grok Build, writes <code>.grok/config.toml</code>, <code>.grok/hooks/c3.json</code> and
963
+ <code>AGENTS.md</code>.
962
964
  </div>
963
965
  </div>
964
966
  </div>
@@ -968,7 +970,9 @@ c3 init /path/to/your/project</code></pre>
968
970
  <div class="step-desc">Open your IDE in the project. For Claude Code, run <code>/mcp</code> to verify C3
969
971
  tools appear. For Google Antigravity, the MCP tools will be loaded based on your config.
970
972
  For VS Code, check MCP tools in the Copilot agent panel. For Codex, the <code>.codex/config.toml</code> is
971
- picked up automatically on next session start.</div>
973
+ picked up automatically on next session start. For Grok Build, launch <code>grok --trust</code> once in
974
+ the project (Grok ignores project MCP servers, hooks and <code>AGENTS.md</code> in an untrusted folder),
975
+ then run <code>c3 doctor --ide grok</code>.</div>
972
976
  </div>
973
977
  </div>
974
978
  </div>
@@ -1016,8 +1020,16 @@ c3 init /path/to/your/project</code></pre>
1016
1020
  <td><strong>OpenAI Codex</strong></td>
1017
1021
  <td><code>.codex/config.toml</code></td>
1018
1022
  <td><code>AGENTS.md</code></td>
1019
- <td>—</td>
1020
- <td>No</td>
1023
+ <td><code>.codex/hooks.json</code></td>
1024
+ <td>Yes</td>
1025
+ <td>Yes</td>
1026
+ </tr>
1027
+ <tr>
1028
+ <td><strong>Grok Build</strong></td>
1029
+ <td><code>.grok/config.toml</code></td>
1030
+ <td><code>AGENTS.md</code></td>
1031
+ <td><code>.grok/hooks/c3.json</code></td>
1032
+ <td>Yes (after <code>grok --trust</code>)</td>
1021
1033
  <td>No</td>
1022
1034
  </tr>
1023
1035
  <tr>
@@ -1050,11 +1062,13 @@ python cli/c3.py install-mcp /path/to/project --ide vscode
1050
1062
  python cli/c3.py install-mcp /path/to/project --ide cursor
1051
1063
  python cli/c3.py install-mcp /path/to/project --ide claude
1052
1064
  python cli/c3.py install-mcp /path/to/project --ide codex
1065
+ python cli/c3.py install-mcp /path/to/project --ide grok
1053
1066
  python cli/c3.py install-mcp /path/to/project --ide antigravity
1054
1067
 
1055
1068
  # IDE shorthand when already inside the project directory
1056
1069
  python cli/c3.py install-mcp claude
1057
1070
  python cli/c3.py install-mcp codex
1071
+ python cli/c3.py install-mcp grok
1058
1072
  python cli/c3.py install-mcp . antigravity</code></pre>
1059
1073
 
1060
1074
  <p><code>--git</code> runs a local-only <code>git init</code>. It does not create remotes or connect to GitHub,
@@ -1111,6 +1125,32 @@ python cli/c3.py install-mcp . antigravity</code></pre>
1111
1125
  </li>
1112
1126
  </ul>
1113
1127
 
1128
+ <p><strong>Grok Build</strong> &mdash; <code>install-mcp --ide grok</code> (and <code>c3 init --ide grok</code>)
1129
+ configure xAI's <code>grok</code> CLI. Everything is project-local:</p>
1130
+ <ul>
1131
+ <li><code>.grok/config.toml</code> &mdash; a <code>[mcp_servers.c3]</code> table (the same TOML shape as Codex)
1132
+ with <code>--host grok</code> and <code>startup_timeout_sec = 60</code>. Other servers and keys are kept.
1133
+ Auto-detected when <code>.grok/config.toml</code> or a <code>.grok/</code> directory exists.
1134
+ </li>
1135
+ <li><code>.grok/hooks/c3.json</code> &mdash; C3's handlers for PreToolUse, PostToolUse, SessionStart,
1136
+ PreCompact, Stop and SessionEnd. C3 owns the whole file. On Windows each command is a
1137
+ <code>powershell.exe -NoLogo -NoProfile -NonInteractive -EncodedCommand</code> line so it runs under
1138
+ whichever shell Grok picks.
1139
+ </li>
1140
+ <li><code>AGENTS.md</code> &mdash; shared with Codex and Antigravity; only the C3 block is refreshed.</li>
1141
+ <li><strong>Folder trust</strong> &mdash; Grok loads none of these until the folder is trusted. Launch
1142
+ <code>grok --trust</code> once in the project (or run <code>/hooks-trust</code> inside Grok). C3 never
1143
+ writes <code>~/.grok/trusted_folders.toml</code> or <code>~/.grok/config.toml</code>;
1144
+ <code>c3 doctor --ide grok</code> reports the CLI version, hook install and trust state.
1145
+ </li>
1146
+ <li><strong>Limitations</strong> &mdash; C3 tools are reached through Grok's <code>search_tool</code> /
1147
+ <code>use_tool</code> and appear as <code>c3__c3_search</code> and so on; PreToolUse hints reach the model
1148
+ after the call runs (denies still block before it); there is no prompt-time memory recall; Stop-hook output
1149
+ is never emitted; with both <code>AGENTS.md</code> and <code>CLAUDE.md</code> present, Grok loads the C3
1150
+ block twice. Full guide: <code>docs/grok-native.md</code>.
1151
+ </li>
1152
+ </ul>
1153
+
1114
1154
  <h3>Graceful Degradation</h3>
1115
1155
  <p>All core C3 tools (search, compress, file_map, memory, sessions) work identically in every IDE. Claude-specific
1116
1156
  features degrade gracefully:</p>
@@ -1118,7 +1158,7 @@ python cli/c3.py install-mcp . antigravity</code></pre>
1118
1158
  <li><strong>Transcript search</strong> — returns a helpful message suggesting <code>c3_memory(action='recall')</code> or
1119
1159
  <code>c3_memory(action='query')</code> as alternatives
1120
1160
  </li>
1121
- <li><strong>Hooks</strong> — only installed for Claude Code; VS Code, Cursor, and Codex use hard-language
1161
+ <li><strong>Hooks</strong> — installed for Claude Code, Codex and Grok Build; VS Code and Cursor use hard-language
1122
1162
  workflow instructions in their instructions file instead</li>
1123
1163
  <li><strong>Instructions file</strong> — <code>c3_claudemd_generate</code> writes to the IDE-appropriate file
1124
1164
  (CLAUDE.md, copilot-instructions.md, .cursorrules, AGENTS.md, or GEMINI.md). All IDEs use MANDATORY/NEVER
@@ -2053,10 +2093,12 @@ c3 ui /path/to/your/project --silent # Hide API request logs in terminal
2053
2093
  <div class="tab-name"><span class="badge badge-green">11</span> Settings</div>
2054
2094
  <div class="tab-desc">Project info (editable name, tech stack, description), quick actions (rebuild index,
2055
2095
  save instructions file), project data management (view sizes and item counts per .c3/ category, clear
2056
- actions), instructions file management, and MCP management: target IDE selector (Claude/Gemini/VS
2057
- Code/Cursor/Codex/Antigravity), custom MCP add form, installed MCP cards, and per-card trash removal.
2096
+ actions), instructions file management, and MCP management: target IDE selector (Claude/VS
2097
+ Code/Cursor/Codex/Grok Build/Antigravity), custom MCP add form, installed MCP cards, and per-card trash removal.
2058
2098
  Removing <code>c3</code> can also clean related IDE files/hooks. Includes IDE selector for C3 MCP
2059
- installation and optimization suggestions.</div>
2099
+ installation and optimization suggestions. Delegate backend sections (Codex, Gemini, Grok Build) hold each
2100
+ backend's enable switch, model, timeouts and auto-routed task types; the Grok Build section adds max turns
2101
+ and the write-mode switch (<code>grok_allow_write</code>).</div>
2060
2102
  </div>
2061
2103
  </div>
2062
2104
 
@@ -2595,13 +2637,13 @@ c3 ui /path/to/your/project --silent # Hide API request logs in terminal
2595
2637
  </p>
2596
2638
 
2597
2639
  <h3>Project Setup</h3>
2598
- <pre><code>c3 init &lt;project_path&gt; [--ide auto|claude|vscode|cursor|codex|gemini] [--force]
2640
+ <pre><code>c3 init &lt;project_path&gt; [--ide auto|claude|vscode|cursor|codex|grok|antigravity] [--force]
2599
2641
  # Initialize C3: builds index, creates config, generates instructions file,
2600
2642
  # and automatically installs the MCP config for your IDE.
2601
2643
  # Re-running on an existing project now migrates config defaults and
2602
2644
  # refreshes instruction workflow files (Update / Clear / Reset options).
2603
2645
  c3 index [--max-files 500] # Rebuild the code index
2604
- c3 install-mcp [project_path] [ide] [--ide auto|claude|vscode|cursor|codex|gemini] # (Re-)generate MCP config manually
2646
+ c3 install-mcp [project_path] [ide] [--ide auto|claude|vscode|cursor|codex|grok|antigravity] # (Re-)generate MCP config manually
2605
2647
  c3 ui [project_path] [--port 3333] [--nano] [--silent] # Launch web dashboard (full or nano)</code></pre>
2606
2648
 
2607
2649
  <h3>Compression &amp; Search</h3>
@@ -2652,7 +2694,7 @@ c3 session load | claude --resume</code></pre>
2652
2694
 
2653
2695
  <div class="arch">
2654
2696
  <pre>
2655
- <strong>IDE</strong> (Claude Code / VS Code Copilot / Cursor / Codex / Gemini CLI)
2697
+ <strong>IDE</strong> (Claude Code / VS Code Copilot / Cursor / Codex / Grok Build / Antigravity)
2656
2698
  | MCP Protocol (IDE-specific config file)
2657
2699
  v
2658
2700
  <strong>MCP Proxy</strong> ──── Dynamic tool filtering + context injection (optional, opt-in via MCP config)
@@ -2872,7 +2914,7 @@ c3 session load | claude --resume</code></pre>
2872
2914
  protocol.py # Compression protocol encoder/decoder
2873
2915
  core/
2874
2916
  __init__.py # Token counting utilities
2875
- ide.py # IDE profile registry (Claude Code, VS Code, Cursor, Codex) + auto-detection
2917
+ ide.py # IDE profile registry (Claude Code, VS Code, Cursor, Codex, Antigravity, Grok Build) + auto-detection
2876
2918
  config.py # Hybrid, proxy, delegate, and agent configuration loaders
2877
2919
  install.bat # Windows installer
2878
2920
  install.sh # Linux/macOS installer
@@ -3023,8 +3065,11 @@ c3 session load | claude --resume</code></pre>
3023
3065
  <ul>
3024
3066
  <li>Make sure the MCP config file exists (<code>.mcp.json</code> for Claude Code,
3025
3067
  <code>.vscode/mcp.json</code> for VS Code, <code>.cursor/mcp.json</code> for Cursor,
3026
- <code>.codex/config.toml</code> for Codex)
3068
+ <code>.codex/config.toml</code> for Codex, <code>.grok/config.toml</code> for Grok Build)
3027
3069
  </li>
3070
+ <li>For Grok Build, trust the folder first (<code>grok --trust</code> or <code>/hooks-trust</code>), then
3071
+ check <code>c3 doctor --ide grok</code>, <code>grok mcp doctor c3 --json</code> and <code>grok inspect</code>.
3072
+ Run <code>/hooks</code> inside Grok to see whether C3's hooks loaded.</li>
3028
3073
  <li>Check that the Python path in the config is correct (<code>"command"</code> field for JSON configs;
3029
3074
  <code>command</code> key for Codex TOML)
3030
3075
  </li>
@@ -174,7 +174,11 @@ c3 init</code></pre>
174
174
  </tr>
175
175
  <tr>
176
176
  <td><code>AGENTS.md</code></td>
177
- <td>Instructions for Codex sessions</td>
177
+ <td>Instructions for Codex, Grok Build and Antigravity sessions</td>
178
+ </tr>
179
+ <tr>
180
+ <td><code>.grok/config.toml</code>, <code>.grok/hooks/c3.json</code></td>
181
+ <td>Grok Build only: project MCP entry and C3's hooks (written by <code>--ide grok</code>)</td>
178
182
  </tr>
179
183
  </tbody>
180
184
  </table>
@@ -231,6 +235,12 @@ c3 init</code></pre>
231
235
  <pre><code>c3 install-mcp antigravity</code></pre>
232
236
  <p>Updates the user-global <code>~/.gemini/antigravity/mcp_config.json</code> and <code>AGENTS.md</code>.</p>
233
237
 
238
+ <h3>Grok Build</h3>
239
+ <pre><code>c3 install-mcp grok
240
+ grok --trust
241
+ c3 doctor --ide grok</code></pre>
242
+ <p>Updates <code>.grok/config.toml</code> (<code>[mcp_servers.c3]</code>), writes C3's hooks to <code>.grok/hooks/c3.json</code>, and refreshes the C3 block in <code>AGENTS.md</code>. Grok loads none of them until the folder is trusted, so launch <code>grok --trust</code> once in the project (or run <code>/hooks-trust</code> inside Grok). C3 never writes Grok's trust store or <code>~/.grok/config.toml</code>. In Grok, C3's tools are reached through <code>search_tool</code> / <code>use_tool</code> as <code>c3__c3_search</code> and so on. Details and limitations: <code>docs/grok-native.md</code>.</p>
243
+
234
244
  <p><em>The Gemini CLI profile was removed in v2.52 — use Antigravity instead. <code>c3 uninstall</code> still cleans up legacy <code>.gemini/settings.json</code> and <code>GEMINI.md</code> files.</em></p>
235
245
 
236
246
  <h3>All IDEs at once</h3>