code-context-control 2.129.1__py3-none-any.whl → 2.131.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.
- cli/_hook_utils.py +9 -1
- cli/c3.py +38 -12
- cli/commands/parser.py +5 -5
- cli/docs.html +59 -14
- cli/guide/getting-started.html +11 -1
- cli/guide/workflow.html +2 -2
- cli/hook_dispatch.py +43 -3
- cli/hook_session_stats.py +23 -2
- cli/hub_server.py +82 -2
- cli/hub_ui/components/hub_access.js +183 -0
- cli/hub_ui/components/mcp_manager.js +2 -2
- cli/hub_ui/components/modals.js +1 -0
- cli/hub_ui/state.js +2 -0
- cli/mcp_server.py +3 -2
- cli/server.py +3 -3
- cli/tools/delegate.py +351 -28
- cli/ui/components/instructions.js +1 -0
- cli/ui/components/settings.js +80 -0
- {code_context_control-2.129.1.dist-info → code_context_control-2.131.0.dist-info}/METADATA +10 -5
- {code_context_control-2.129.1.dist-info → code_context_control-2.131.0.dist-info}/RECORD +45 -40
- core/config.py +9 -0
- core/grok_payload.py +121 -0
- core/hook_command.py +22 -0
- core/host.py +5 -1
- core/ide.py +19 -0
- oracle/services/chat_engine.py +1 -1
- oracle/services/mobile_api.py +29 -5
- services/access_guard.py +8 -1
- services/agents_workflow.py +11 -0
- services/ci_act.py +167 -7
- services/ci_runner.py +186 -14
- services/ci_workflow.py +96 -13
- services/claude_md.py +3 -3
- services/codex_integration.py +7 -8
- services/grok_integration.py +200 -0
- services/grok_transcript.py +73 -0
- services/host_sessions.py +1 -1
- services/override_policy.py +147 -0
- services/session_manager.py +4 -0
- tui/screens/init_view.py +1 -1
- tui/screens/mcp_view.py +1 -1
- {code_context_control-2.129.1.dist-info → code_context_control-2.131.0.dist-info}/WHEEL +0 -0
- {code_context_control-2.129.1.dist-info → code_context_control-2.131.0.dist-info}/entry_points.txt +0 -0
- {code_context_control-2.129.1.dist-info → code_context_control-2.131.0.dist-info}/licenses/LICENSE +0 -0
- {code_context_control-2.129.1.dist-info → code_context_control-2.131.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.
|
|
94
|
+
__version__ = "2.131.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
|
|
|
@@ -4333,9 +4335,9 @@ _C3_HOOKLESS_WORKFLOW = _adapt_workflow_for_ide(
|
|
|
4333
4335
|
|
|
4334
4336
|
_COPILOT_INSTRUCTIONS_CONTENT = _VSCODE_SESSION_INIT + "\n\n" + _C3_HOOKLESS_WORKFLOW
|
|
4335
4337
|
|
|
4336
|
-
from services.
|
|
4338
|
+
from services.agents_workflow import AGENTS_MD_WORKFLOW
|
|
4337
4339
|
|
|
4338
|
-
_AGENTS_MD_CONTENT =
|
|
4340
|
+
_AGENTS_MD_CONTENT = AGENTS_MD_WORKFLOW
|
|
4339
4341
|
|
|
4340
4342
|
_TERSE_SKILL_CONTENT = """\
|
|
4341
4343
|
# /terse — Terse Output Mode
|
|
@@ -4544,7 +4546,7 @@ def _ensure_instruction_workflow(instructions_path: Path, template: str,
|
|
|
4544
4546
|
|
|
4545
4547
|
def _ensure_codex_agents_workflow(agents_md_path: Path,
|
|
4546
4548
|
project_path: str = "") -> str:
|
|
4547
|
-
"""Ensure AGENTS.md contains the mandatory C3 workflow
|
|
4549
|
+
"""Ensure AGENTS.md contains the mandatory C3 workflow (Codex and Grok Build read it)."""
|
|
4548
4550
|
from services.claude_md import write_c3_instruction_doc
|
|
4549
4551
|
existing = agents_md_path.read_text(encoding="utf-8") if agents_md_path.exists() else None
|
|
4550
4552
|
rendered = write_c3_instruction_doc(agents_md_path, _AGENTS_MD_CONTENT, project_path or None)
|
|
@@ -4888,8 +4890,15 @@ def _uninstall_mcp_all(project_path: str, include_global: bool = True):
|
|
|
4888
4890
|
except Exception as e:
|
|
4889
4891
|
print(f" Warning: Could not update {mcp_config_path}: {e}")
|
|
4890
4892
|
|
|
4893
|
+
# Grok Build: C3 owns the whole .grok/hooks/c3.json, so it is deleted
|
|
4894
|
+
# rather than stripped (its Windows commands are encoded and would not
|
|
4895
|
+
# match the settings scanner anyway).
|
|
4896
|
+
if ide_name == "grok":
|
|
4897
|
+
from services.grok_integration import remove_hooks as remove_grok_hooks
|
|
4898
|
+
if remove_grok_hooks(target):
|
|
4899
|
+
print(f" Deleted {target / profile.settings_path}")
|
|
4891
4900
|
# Per-host hooks and settings; remove only C3-owned handlers.
|
|
4892
|
-
|
|
4901
|
+
elif profile.supports_hooks and profile.settings_path:
|
|
4893
4902
|
settings_path = target / profile.settings_path
|
|
4894
4903
|
if settings_path.exists():
|
|
4895
4904
|
try:
|
|
@@ -4970,7 +4979,7 @@ def _uninstall_mcp_all(project_path: str, include_global: bool = True):
|
|
|
4970
4979
|
print(f" Warning: Could not update {legacy_cfg}: {e}")
|
|
4971
4980
|
|
|
4972
4981
|
# Final pass: clean up empty IDE directories (.claude, .codex, .gemini, .vscode, .github)
|
|
4973
|
-
dirs_to_check = [".claude", ".codex", ".gemini", ".vscode", ".github"]
|
|
4982
|
+
dirs_to_check = [".claude", ".codex", ".grok", ".gemini", ".vscode", ".github"]
|
|
4974
4983
|
for dname in dirs_to_check:
|
|
4975
4984
|
dpath = target / dname
|
|
4976
4985
|
if dpath.exists() and dpath.is_dir():
|
|
@@ -5011,7 +5020,7 @@ back to native tools as the task progresses.
|
|
|
5011
5020
|
- **Filter**: `c3_filter(text=...)` — for terminal output >10 lines
|
|
5012
5021
|
- **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
5022
|
- **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
|
|
5023
|
+
- **Delegate**: `c3_delegate(task, backend='ollama|codex|gemini|claude|grok|auto')` — offload to other models
|
|
5015
5024
|
- **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
5025
|
- **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
5026
|
- **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 +5475,12 @@ def cmd_install_mcp(args):
|
|
|
5466
5475
|
toml_entries["startup_timeout_sec"] = 30
|
|
5467
5476
|
toml_entries["tool_timeout_sec"] = 60
|
|
5468
5477
|
toml_entries["args"] += ["--host", "codex"]
|
|
5478
|
+
elif profile.name == "grok":
|
|
5479
|
+
# Grok's default startup timeout is 30s; a cold C3 index build can
|
|
5480
|
+
# exceed it. Its tool timeout already defaults to 6000s.
|
|
5481
|
+
toml_entries["enabled"] = True
|
|
5482
|
+
toml_entries["startup_timeout_sec"] = 60
|
|
5483
|
+
toml_entries["args"] += ["--host", "grok"]
|
|
5469
5484
|
_upsert_toml_section(
|
|
5470
5485
|
mcp_config_path,
|
|
5471
5486
|
f"{profile.config_key}.c3",
|
|
@@ -5517,6 +5532,13 @@ def cmd_install_mcp(args):
|
|
|
5517
5532
|
from services.codex_integration import install_hooks
|
|
5518
5533
|
hook_state = install_hooks(target, sys.executable, cli_dir / "hook_dispatch.py")
|
|
5519
5534
|
print(f"Codex hooks installed; active: {hook_state['active']}. {hook_state['activation']}")
|
|
5535
|
+
if profile.name == "grok":
|
|
5536
|
+
from services.grok_integration import install_hooks as install_grok_hooks
|
|
5537
|
+
grok_hooks = install_grok_hooks(target, sys.executable, cli_dir / "hook_dispatch.py")
|
|
5538
|
+
from services.artifact_defs import note_pending_write
|
|
5539
|
+
note_pending_write(target, profile.settings_path, "install_mcp")
|
|
5540
|
+
print(f"Wrote {target / profile.settings_path}")
|
|
5541
|
+
print(f"Grok Build: {grok_hooks['activation']}")
|
|
5520
5542
|
if profile.name == "claude-code" and profile.supports_hooks and profile.settings_path:
|
|
5521
5543
|
settings_dir = target / Path(profile.settings_path).parent
|
|
5522
5544
|
settings_dir.mkdir(parents=True, exist_ok=True)
|
|
@@ -5812,8 +5834,8 @@ def cmd_install_mcp(args):
|
|
|
5812
5834
|
print(f"Wrote {vscode_settings_path}")
|
|
5813
5835
|
print(" Copilot: C3 instructions linked for code gen, review, and test generation")
|
|
5814
5836
|
|
|
5815
|
-
# ── Codex AGENTS.md enforcement file
|
|
5816
|
-
if profile.name
|
|
5837
|
+
# ── Codex / Grok Build AGENTS.md enforcement file ────────────
|
|
5838
|
+
if profile.name in ("codex", "grok"):
|
|
5817
5839
|
agents_md_path = target / "AGENTS.md"
|
|
5818
5840
|
agents_state = _ensure_codex_agents_workflow(agents_md_path,
|
|
5819
5841
|
str(target))
|
|
@@ -5824,6 +5846,7 @@ def cmd_install_mcp(args):
|
|
|
5824
5846
|
else:
|
|
5825
5847
|
print(f"Kept {agents_md_path} (C3 workflow present)")
|
|
5826
5848
|
|
|
5849
|
+
if profile.name == "codex":
|
|
5827
5850
|
# Warn about a common conflict: global Codex config disables c3.
|
|
5828
5851
|
global_codex_cfg = Path(os.environ.get("CODEX_HOME") or Path.home() / ".codex") / "config.toml"
|
|
5829
5852
|
global_enabled = _toml_section_bool_value(global_codex_cfg, "mcp_servers.c3", "enabled")
|
|
@@ -9303,7 +9326,10 @@ def _launch_tui() -> None:
|
|
|
9303
9326
|
|
|
9304
9327
|
|
|
9305
9328
|
def cmd_doctor(args):
|
|
9306
|
-
|
|
9329
|
+
if getattr(args, "ide", "codex") == "grok":
|
|
9330
|
+
from services.grok_integration import diagnose
|
|
9331
|
+
else:
|
|
9332
|
+
from services.codex_integration import diagnose
|
|
9307
9333
|
print(json.dumps(diagnose(Path(args.project_path).resolve()), indent=2))
|
|
9308
9334
|
|
|
9309
9335
|
|
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")
|
|
@@ -153,7 +153,7 @@ def build_parser(version: str, parse_cli_ide_arg):
|
|
|
153
153
|
|
|
154
154
|
p_install_mcp = subparsers.add_parser("install-mcp", help="Generate MCP config for your IDE")
|
|
155
155
|
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)")
|
|
156
|
+
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
157
|
p_install_mcp.add_argument("--mcp-mode", choices=["direct", "proxy"], default="direct", help="MCP entrypoint mode (default: direct)")
|
|
158
158
|
p_install_mcp.add_argument("--global-fallback", action="store_true", help="Also install the machine-wide Codex fallback")
|
|
159
159
|
p_install_mcp.add_argument("--permissions", choices=["read-only", "c3-strict", "standard", "permissive"], default=None, help="Apply Claude Code permission tier (Claude Code only)")
|
|
@@ -161,7 +161,7 @@ def build_parser(version: str, parse_cli_ide_arg):
|
|
|
161
161
|
|
|
162
162
|
p_mcp_install = subparsers.add_parser("mcp-install", help="Alias for install-mcp")
|
|
163
163
|
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)")
|
|
164
|
+
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
165
|
p_mcp_install.add_argument("--mcp-mode", choices=["direct", "proxy"], default="direct", help="MCP entrypoint mode (default: direct)")
|
|
166
166
|
p_mcp_install.add_argument("--global-fallback", action="store_true", help="Also install the machine-wide Codex fallback")
|
|
167
167
|
p_mcp_install.add_argument("--permissions", choices=["read-only", "c3-strict", "standard", "permissive"], default=None, help="Apply Claude Code permission tier (Claude Code only)")
|
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
|
|
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
|
|
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
|
|
1020
|
-
<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> — <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> — 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> — 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> — shared with Codex and Antigravity; only the C3 block is refreshed.</li>
|
|
1141
|
+
<li><strong>Folder trust</strong> — 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> — 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> —
|
|
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/
|
|
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
|
|
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 <project_path> [--ide auto|claude|vscode|cursor|codex|
|
|
2640
|
+
<pre><code>c3 init <project_path> [--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|
|
|
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 & 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 /
|
|
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>
|
cli/guide/getting-started.html
CHANGED
|
@@ -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>
|
cli/guide/workflow.html
CHANGED
|
@@ -997,7 +997,7 @@ c3_memory(action=<span class="str">'recall'</span>, query=<span class="str">'pay
|
|
|
997
997
|
<p>Everything the CLI does — plus the operations that need multi-step safety — is available in the Hub:</p>
|
|
998
998
|
<ul>
|
|
999
999
|
<li><strong>"Link project by path…"</strong> (v2.96.0) — kebab menu on any card, at any depth. Browse anywhere or paste a path; C3 inspects it before anything happens and shows you what you are about to claim — the project's name and version, whether the hub already knows it, how much is in it, who already claims it, and what sub-projects it would bring with it. One confirm registers and links an unregistered project. Unlinked nested projects it finds are offered as suggestions, never applied.</li>
|
|
1000
|
-
<li><strong>Designate</strong> — kebab menu → "Designate sub-project…" on any project card, or from the drill-in <strong>Sub-projects</strong> tab. A folder picker fenced to the parent's subtree validates the choice, shows adopt-vs-initialize expectations up front, and offers an instruction-docs/IDE picker (<code>auto | claude | vscode | cursor | codex | antigravity</code>).</li>
|
|
1000
|
+
<li><strong>Designate</strong> — kebab menu → "Designate sub-project…" on any project card, or from the drill-in <strong>Sub-projects</strong> tab. A folder picker fenced to the parent's subtree validates the choice, shows adopt-vs-initialize expectations up front, and offers an instruction-docs/IDE picker (<code>auto | claude | vscode | cursor | codex | grok | antigravity</code>).</li>
|
|
1001
1001
|
<li><strong>"Make sub-project of…"</strong> — the reverse move: pick any registered project to sit under. The only projects excluded are this one and its own descendants.</li>
|
|
1002
1002
|
<li><strong>Sub-projects drill tab</strong> — per-child rows with inline <em>Validate</em> and <em>Promote</em>; inline <em>Reconcile</em> with per-issue detail and planned repair actions; a <em>Cascade</em> launcher with operation picker, include-parent toggle, affected-children preview, live progress, and Cancel.</li>
|
|
1003
1003
|
<li><strong>Link health, passively</strong> — parents show a red "N link issues" badge and children a status badge (<code>ok · backlink_broken · unregistered · missing_folder · missing_c3 · orphan</code>), computed from config + filesystem on every listing — no manual reconcile needed to spot trouble.</li>
|
|
@@ -1022,7 +1022,7 @@ c3_memory(action=<span class="str">'recall'</span>, query=<span class="str">'pay
|
|
|
1022
1022
|
<section class="section" id="repo-map">
|
|
1023
1023
|
<div class="section-title"><span class="icon">🗺️</span> Live Repo Map (v2.60.0)</div>
|
|
1024
1024
|
|
|
1025
|
-
<p>Instruction docs (CLAUDE.md / AGENTS.md) no longer embed a frozen project tree. They carry a stable pointer to <code>.c3/MAP.md</code> — a machine-owned map C3 keeps fresh automatically. One map serves every consumer: Claude Code, Codex, Antigravity.</p>
|
|
1025
|
+
<p>Instruction docs (CLAUDE.md / AGENTS.md) no longer embed a frozen project tree. They carry a stable pointer to <code>.c3/MAP.md</code> — a machine-owned map C3 keeps fresh automatically. One map serves every consumer: Claude Code, Codex, Grok Build, Antigravity.</p>
|
|
1026
1026
|
|
|
1027
1027
|
<p>The map contains, in priority order: build/test commands, entry points, module one-liners, the depth-2 tree, and key files — under a token budget (default 1000). Sub-projects appear as boundaries and are never expanded into the parent map.</p>
|
|
1028
1028
|
|
cli/hook_dispatch.py
CHANGED
|
@@ -57,6 +57,7 @@ from cli._hook_utils import ( # noqa: E402
|
|
|
57
57
|
HOST_CLAUDE,
|
|
58
58
|
HOST_CODEX,
|
|
59
59
|
HOST_GEMINI,
|
|
60
|
+
HOST_GROK,
|
|
60
61
|
detect_host,
|
|
61
62
|
log_hook_error,
|
|
62
63
|
normalize_tool_name,
|
|
@@ -142,7 +143,10 @@ def _routes(event: str, raw_tool: str, norm_tool: str, host: str = HOST_CLAUDE):
|
|
|
142
143
|
# is also pointless — its schema has no tool_result, so the filtered
|
|
143
144
|
# text could never replace the output anyway. Skip it entirely rather
|
|
144
145
|
# than risk an allocation failure for a result we must discard.
|
|
145
|
-
|
|
146
|
+
# Grok is excluded for the same reason: it validates a built-in tool's
|
|
147
|
+
# replacement output against Grok's own tagged shape, so a filtered
|
|
148
|
+
# string could not replace the result there either.
|
|
149
|
+
if norm_tool == "Bash" and host not in (HOST_CODEX, HOST_GROK):
|
|
146
150
|
yield "hook_filter"
|
|
147
151
|
if norm_tool == "Read":
|
|
148
152
|
yield "hook_read"
|
|
@@ -164,7 +168,10 @@ def _routes(event: str, raw_tool: str, norm_tool: str, host: str = HOST_CLAUDE):
|
|
|
164
168
|
elif event == "stop":
|
|
165
169
|
yield "hook_session_stats"
|
|
166
170
|
yield "hook_codex_lifecycle" if host == HOST_CODEX else "hook_auto_snapshot"
|
|
167
|
-
|
|
171
|
+
# Advice needs a channel to the model; Grok's Stop has none that does
|
|
172
|
+
# not also keep the agent working, and its transcript is not Claude's.
|
|
173
|
+
if host != HOST_GROK:
|
|
174
|
+
yield "hook_terse_advisor"
|
|
168
175
|
elif event == "prompt":
|
|
169
176
|
yield "hook_prompt_recall"
|
|
170
177
|
elif event in ("start", "compact", "end"):
|
|
@@ -345,6 +352,34 @@ def _codex_output(event: str, deny_hso, contexts: list, tool_result,
|
|
|
345
352
|
return result or None
|
|
346
353
|
|
|
347
354
|
|
|
355
|
+
# Grok Build delivers hookSpecificOutput.additionalContext for tool events.
|
|
356
|
+
# Everything else is passive (SessionStart/End, PreCompact) or harmful: Stop
|
|
357
|
+
# context "keeps the agent working" for up to 8 continuations, and an allowing
|
|
358
|
+
# UserPromptSubmit hook's stdout is discarded. Those events print nothing.
|
|
359
|
+
_GROK_EVENT_NAMES = {"pretool": "PreToolUse", "posttool": "PostToolUse"}
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
def _grok_output(event: str, deny_hso, contexts: list, tool_result,
|
|
363
|
+
texts: list) -> dict | None:
|
|
364
|
+
"""Serialize merged sub-hook results into Grok Build's hook contract."""
|
|
365
|
+
event_name = _GROK_EVENT_NAMES.get(event)
|
|
366
|
+
if event_name is None:
|
|
367
|
+
return None
|
|
368
|
+
if deny_hso is not None and event == "pretool":
|
|
369
|
+
# A deny drops any context on Grok's side anyway; send only the verdict.
|
|
370
|
+
return {"hookSpecificOutput": {
|
|
371
|
+
"hookEventName": event_name,
|
|
372
|
+
"permissionDecision": "deny",
|
|
373
|
+
"permissionDecisionReason": str(deny_hso.get("permissionDecisionReason") or "Blocked by C3"),
|
|
374
|
+
}}
|
|
375
|
+
if tool_result is not None:
|
|
376
|
+
contexts.insert(0, str(tool_result))
|
|
377
|
+
joined = "\n".join(c for c in [*contexts, *texts] if c)
|
|
378
|
+
if not joined:
|
|
379
|
+
return None
|
|
380
|
+
return {"hookSpecificOutput": {"hookEventName": event_name, "additionalContext": joined}}
|
|
381
|
+
|
|
382
|
+
|
|
348
383
|
def merge_outputs(outputs: list, warnings: list, is_gemini: bool = False,
|
|
349
384
|
event: str = "", host: str | None = None) -> dict | None:
|
|
350
385
|
"""Compose sub-hook outputs into ONE host-appropriate hook response.
|
|
@@ -393,6 +428,8 @@ def merge_outputs(outputs: list, warnings: list, is_gemini: bool = False,
|
|
|
393
428
|
|
|
394
429
|
if host == HOST_CODEX:
|
|
395
430
|
return _codex_output(event, deny_hso, contexts, tool_result, texts)
|
|
431
|
+
if host == HOST_GROK:
|
|
432
|
+
return _grok_output(event, deny_hso, contexts, tool_result, texts)
|
|
396
433
|
|
|
397
434
|
is_gemini = host == HOST_GEMINI
|
|
398
435
|
result: dict = {}
|
|
@@ -477,6 +514,9 @@ def _collect(event: str, payload: dict, project_path: Path | None = None):
|
|
|
477
514
|
|
|
478
515
|
def dispatch(event: str, payload: dict, project_path: Path | None = None) -> dict | None:
|
|
479
516
|
host = detect_host(payload)
|
|
517
|
+
if host == HOST_GROK:
|
|
518
|
+
from core.grok_payload import translate
|
|
519
|
+
payload = translate(payload)
|
|
480
520
|
payload = {**payload, "hook_event_name": payload.get("hook_event_name") or _CODEX_EVENT_NAMES.get(event, event)}
|
|
481
521
|
if payload.get("tool_name") == "apply_patch" and event in ("pretool", "posttool"):
|
|
482
522
|
from core.codex_patch import patch_targets
|
|
@@ -517,7 +557,7 @@ def main() -> None:
|
|
|
517
557
|
import argparse
|
|
518
558
|
parser = argparse.ArgumentParser()
|
|
519
559
|
parser.add_argument("event", nargs="?", default="")
|
|
520
|
-
parser.add_argument("--host", choices=["codex", "claude", "claude-code", "gemini"])
|
|
560
|
+
parser.add_argument("--host", choices=["codex", "claude", "claude-code", "gemini", "grok"])
|
|
521
561
|
parser.add_argument("--project")
|
|
522
562
|
args = parser.parse_args()
|
|
523
563
|
event = args.event.strip().lower()
|
cli/hook_session_stats.py
CHANGED
|
@@ -100,8 +100,29 @@ def read_transcript_usage(transcript_path) -> dict:
|
|
|
100
100
|
|
|
101
101
|
def run(payload: dict, project_path: Path | None = None):
|
|
102
102
|
"""Core logic — importable by the dispatcher and tests. Returns None."""
|
|
103
|
-
from cli._hook_utils import HOST_CODEX, detect_host
|
|
104
|
-
|
|
103
|
+
from cli._hook_utils import HOST_CODEX, HOST_GROK, detect_host
|
|
104
|
+
host = detect_host(payload)
|
|
105
|
+
if host == HOST_GROK:
|
|
106
|
+
from services.grok_transcript import read_usage
|
|
107
|
+
base = Path(project_path or payload.get("cwd") or Path.cwd()).resolve()
|
|
108
|
+
usage = read_usage(payload.get("transcript_path"), str(payload.get("session_id") or ""))
|
|
109
|
+
row = {"ts": datetime.now(timezone.utc).isoformat(), "session_id": payload.get("session_id"),
|
|
110
|
+
"provider": "grok", "source": "transcript" if usage is not None else "none",
|
|
111
|
+
"stop_reason": payload.get("reason"),
|
|
112
|
+
"input_tokens": usage["input_tokens"] if usage else None,
|
|
113
|
+
"input_tokens_including_cache": usage["input_tokens_including_cache"] if usage else None,
|
|
114
|
+
"output_tokens": usage["output_tokens"] if usage else None,
|
|
115
|
+
"cache_read_tokens": usage["cache_read_tokens"] if usage else None,
|
|
116
|
+
"cache_creation_tokens": usage["cache_creation_tokens"] if usage else None,
|
|
117
|
+
"reasoning_tokens": usage["reasoning_tokens"] if usage else None,
|
|
118
|
+
# Grok measures and reports its own cost, so it is recorded as given.
|
|
119
|
+
"cost_usd": usage["cost_usd"] if usage else None,
|
|
120
|
+
"model": usage["model"] if usage else ""}
|
|
121
|
+
if (base / ".c3").is_dir():
|
|
122
|
+
with (base / ".c3" / "session_stats.jsonl").open("a", encoding="utf-8") as stream:
|
|
123
|
+
stream.write(json.dumps(row) + "\n")
|
|
124
|
+
return None
|
|
125
|
+
if host == HOST_CODEX:
|
|
105
126
|
from services.codex_transcript import read_rollout
|
|
106
127
|
base = Path(project_path or payload.get("cwd") or Path.cwd()).resolve()
|
|
107
128
|
transcript = payload.get("transcript_path")
|