§9 acceptance: grep-zero sweep — every internal x.ai/grok identifier renamed

The PRD's first acceptance gate now holds: grep -RinE '\bx\.ai\b|grok'
crates/ --include='*.rs' → 0 matches (exempt: NOTICE and third-party
license archives, README provenance, and the required 'Based on Grok
Build Open Source' attribution, now sourced from version_attribution.txt).

Wire-visible renames (both sides in this repo, changed in lockstep):
- Auth method id 'grok.com' → 'kimi-code' (AuthMethodKind::KimiCode).
- Every x.ai/* and _x.ai/* ACP ext method and meta key → kigi/* /
  _kigi/* (~200 names; grokShell → kigiShell). Session-file replay keeps
  a read-side alias for the legacy '_x.ai/session/update' method so
  existing updates.jsonl histories load; writes emit only the new name
  (both directions test-pinned).
- Agent types grok-build* → kigi* with a documented legacy-prefix alias
  at resolution time so persisted sessions keep resolving.
- ToolNamespace/BuiltinAgentName GrokBuild* → Kigi* (wire snake_case
  kigi/kigi_concise/kigi_hashline; schema regenerated); grok_build
  implementation dirs renamed to kigi*.
- x-grok-* headers → x-kigi-*, __GROK_* sentinels → __KIGI_*, themes
  grokday/groknight → kigiday/kiginight (old persisted values fall back
  to the default theme), web_fetch allowlist xAI hosts → kimi.com +
  moonshot platforms, changelog CDN → this repo, grok-build changelog
  archives deleted.
- BYOK default endpoint removed: [endpoints] api_base_url is now truly
  optional with NO default — consumers fail fast with the flag name when
  unset (no silent x.ai egress). Mock harnesses inject it explicitly.
- System-prompt identity fixed: 'released by xAI' → 'an unofficial
  community CLI for Kimi' (template + regenerated encrypted form).

Also repaired pre-existing grok-era test debt found by the sweep: the
stale trace_classify default-model pin, the grok-pager UA label test,
pty-harness stale-binary reuse and non-hermetic moonshot routing (a PTY
test could previously reach the real api.moonshot.cn), and the outdated
oauth fixture scope key.

Gates: §9 grep 0; fmt clean; workspace check/clippy 0/0 (-D warnings);
FULL cargo test --workspace: 234 suites, 21,961 passed, 0 failed;
deny advisories ok.
This commit is contained in:
2026-07-18 02:48:46 -04:00
parent 86e3724310
commit 6f31415ed6
1056 changed files with 8410 additions and 18307 deletions
@@ -1,6 +1,6 @@
# Session Management
Grok saves every conversation to disk automatically. Whether you work in the TUI, in headless mode, or over agent stdio, Grok records the exchange as a session. You can resume, rewind, or compact it. This document describes how to manage sessions.
Kigi saves every conversation to disk automatically. Whether you work in the TUI, in headless mode, or over agent stdio, Kigi records the exchange as a session. You can resume, rewind, or compact it. This document describes how to manage sessions.
---
@@ -15,13 +15,13 @@ A session is a persistent conversation with full history. It includes:
- Token usage and turn counts
- Subagent sessions (when enabled)
Sessions are identified by a unique session ID (a UUIDv7 when Grok generates it; a client may supply its own ID with `-s`) and stored on disk under `~/.kigi/sessions/`. Set `KIGI_SHARE_DIR` to override the base directory; when it is unset, Grok uses `~/.kigi`.
Sessions are identified by a unique session ID (a UUIDv7 when Kigi generates it; a client may supply its own ID with `-s`) and stored on disk under `~/.kigi/sessions/`. Set `KIGI_SHARE_DIR` to override the base directory; when it is unset, Kigi uses `~/.kigi`.
---
## Storage Layout
Grok stores each session in its own directory, grouped by working directory. It URL-encodes the working directory to name the group. When the encoded name exceeds 255 bytes, it instead uses a slug plus a hash and records the original path in a `.cwd` file inside the group.
Kigi stores each session in its own directory, grouped by working directory. It URL-encodes the working directory to name the group. When the encoded name exceeds 255 bytes, it instead uses a slug plus a hash and records the original path in a `.cwd` file inside the group.
```
~/.kigi/sessions/<encoded-cwd>/<session-id>/
@@ -54,13 +54,13 @@ This clears the current context and begins a new conversation. Alias: `/clear`.
### Exit
End the session and quit Grok:
End the session and quit Kigi:
```
/quit
```
Alias: `/exit`. To leave the current session but stay in Grok, use `/home` to return to the welcome screen.
Alias: `/exit`. To leave the current session but stay in Kigi, use `/home` to return to the welcome screen.
---
@@ -85,14 +85,14 @@ To switch between, rename, or close the sessions that are currently active (the
Resume a specific session by ID:
```bash
grok --resume <session-id>
kigi --resume <session-id>
```
Run `grok --resume` without an ID to resume the most recent session for the current directory.
Run `kigi --resume` without an ID to resume the most recent session for the current directory.
### From the Welcome Screen
When you launch `grok`, the welcome screen lists recent sessions for the current directory. Select one to resume it.
When you launch `kigi`, the welcome screen lists recent sessions for the current directory. Select one to resume it.
---
@@ -128,7 +128,7 @@ Alias: `/title`.
/rewind
```
When you run `/rewind` (or press **Esc Esc** within 800ms while idle with an empty prompt and conversation messages), Grok:
When you run `/rewind` (or press **Esc Esc** within 800ms while idle with an empty prompt and conversation messages), Kigi:
1. Shows a list of rewind points (one per user prompt)
2. Lets you select which point to rewind to
@@ -154,7 +154,7 @@ The optional `context` argument lets you provide additional instructions about w
### Auto-Compact
Grok automatically compacts the conversation when the context window approaches its limit. You will see a notification when auto-compact triggers. The `context_window` setting on your model configuration controls when this threshold is reached.
Kigi automatically compacts the conversation when the context window approaches its limit. You will see a notification when auto-compact triggers. The `context_window` setting on your model configuration controls when this threshold is reached.
---
@@ -184,13 +184,13 @@ In headless mode, you manage sessions through command-line flags:
```bash
# New session each time (default)
grok -p "Hello"
kigi -p "Hello"
# Resume an existing session by ID (errors if it does not exist)
grok -p "Continue where we left off" -r <session-id>
kigi -p "Continue where we left off" -r <session-id>
# Continue the most recent session in the current directory
grok -p "What were we doing?" -c
kigi -p "What were we doing?" -c
```
In headless mode, resume an existing session with `-r`/`--resume`, which errors if the session does not exist, or continue the most recent session in the current directory with `-c`/`--continue`. Pass the session ID from JSON output (see below) to `-r`.
@@ -200,7 +200,7 @@ Use `-s`/`--session-id` only to **create** a new session with a **UUID** (errors
To read the session ID back, request JSON output:
```bash
grok -p "Hello" --output-format json | jq -r '.sessionId'
kigi -p "Hello" --output-format json | jq -r '.sessionId'
```
---
@@ -228,28 +228,28 @@ The agent persists all session updates automatically. Clients can reconnect and
---
## The grok sessions Subcommand
## The kigi sessions Subcommand
List or search sessions from the command line. `grok sessions` requires a subcommand:
List or search sessions from the command line. `kigi sessions` requires a subcommand:
```bash
# List recent sessions for the current directory
grok sessions list
kigi sessions list
# Limit the number of results (default 20)
grok sessions list --limit 50
kigi sessions list --limit 50
# Search sessions by keyword (matches titles and prompts)
grok sessions search "rate limit"
kigi sessions search "rate limit"
```
`grok sessions list` shows sessions for the current working directory, grouped by worktree label. Each row lists the session ID, the creation and update dates, the source status, and the summary. `grok sessions search` combines a local SQLite index with remote results.
`kigi sessions list` shows sessions for the current working directory, grouped by worktree label. Each row lists the session ID, the creation and update dates, the source status, and the summary. `kigi sessions search` combines a local SQLite index with remote results.
---
## Worktree Sessions
When working with subagents or session forks, Grok can create isolated git worktrees per session. Each worktree gets its own copy of the working directory, so file changes in one session do not affect another.
When working with subagents or session forks, Kigi can create isolated git worktrees per session. Each worktree gets its own copy of the working directory, so file changes in one session do not affect another.
Worktree sessions are managed internally through the `x.ai/git/worktree/*` extension methods. Key operations:
@@ -257,7 +257,7 @@ Worktree sessions are managed internally through the `x.ai/git/worktree/*` exten
- **Apply**: Merge worktree changes back into the main working directory
- **Remove**: Clean up a worktree when the session is done
Resume a session in a fresh worktree with `grok -w -r <session-id>`.
Resume a session in a fresh worktree with `kigi -w -r <session-id>`.
---
@@ -265,13 +265,13 @@ Resume a session in a fresh worktree with `grok -w -r <session-id>`.
### Persistence Format
Grok stores the conversation as newline-delimited JSON (JSONL). Each line in `updates.jsonl` is a self-contained ACP session update event. This format supports:
Kigi stores the conversation as newline-delimited JSON (JSONL). Each line in `updates.jsonl` is a self-contained ACP session update event. This format supports:
- Incremental writes (append-only during a session)
- Efficient streaming reads (for session restore)
- Easy debugging (each line is valid JSON)
The smaller state files -- `summary.json`, `plan.json`, and `signals.json` -- are plain JSON rather than JSONL. JSONL is the source of truth for session content; `grok sessions search` additionally maintains a local SQLite FTS5 index over session titles and prompts for fast keyword search.
The smaller state files -- `summary.json`, `plan.json`, and `signals.json` -- are plain JSON rather than JSONL. JSONL is the source of truth for session content; `kigi sessions search` additionally maintains a local SQLite FTS5 index over session titles and prompts for fast keyword search.
### Session Metadata