Repository navigation
Conversation
- Introduce the tool-grok package and Grok model handling, covering tool definitions, detection, launch, session adapters, and token usage parsing - Extend hook hosts to Grok by reusing Claude/Cursor hook settings with Grok-specific dedup guards, and adapt the fast path and dispatch CLI - Add the Grok folder-trust gate so team skills, rules, hooks, and MCP load only from trusted folders - Add TOML-format MCP rendering and install/uninstall for Grok, and write model config into .grok/config.toml with scan and reconcile support - Register Grok in the tool list, default paths, types, and launch adapters, with tests and fixtures
This change tightens data handling at Grok's entry points for robustness and safety, without changing external behavior: - Tool replies, session records, usage stats, and model configs now use zod schemas for structured validation, replacing scattered ad-hoc type checks. Malformed fields degrade safely or are ignored, keeping bad data out of downstream flows. - Session, usage, and model config files are read and written through the regular-file helpers, ensuring only regular files are handled and avoiding risks from symlinks or other special files. - The linter's baseline ID set is recalibrated so vendor fields in model configs are no longer mistaken for teamai tool IDs.
This change brings two tools into teamai's supported-tool surface, covering both the member-facing docs and the test matrices that pin down where each tool reads and writes: - Adds Grok and WorkBuddy Pro to the tool support guide and every localized README matrix, including install paths, skills/rules/agents locations, hook and MCP layouts, and capability footnotes. - Registers the new tool ids with the agent catalog and the generated tool-id set so lint rules and agent lookups recognize them. - Extends the locate and channel test matrices with user and project rows for both tools, including Grok's folder-trust read gate and WorkBuddy Pro's shared MCP file layout.
Fix the misjudgment when a mapping tool has an empty record in the managed MCP manifest. An empty record was treated as owning no servers, so members' own MCP servers were mistaken for earlier teamai writes and wrongly retained, preventing the config from being cleaned up. The check now distinguishes "no tool recorded the file" from "a tool recorded it with an empty list", and only the former is conservatively treated as a leftover write, removing the misjudgment against members' own configs. Also fully integrate WorkBuddy Pro as a supported tool: register it as a platform, agent and launcher, and cover it in the MCP location matrix, conformance tests and multilingual tool-support docs, giving it the same skills, rules, MCP and session capabilities as existing tools while keeping all READMEs and the tool matrix in sync.
The ownership rewrite turned `const other` into a multiline binding but dropped the blank line before it, which `teamai/require-readable-spacing` rejects. Restore it. It also replaced `owned ? [...owned(target)] : []` with `owned?.(target) ?? []`, passing the callback's `readonly string[]` through to the mutable `owned` field on `McpFileObservation` (TS4104). Widen that field to `readonly string[]`: its only consumer calls `includes`, and the sibling `state.servers` field is already readonly.
WorkBuddy Pro was added to LAUNCH_ORDER, so the hardcoded tool lists in doctor-scorers and tool-launch-call tests no longer matched the generated messages. Add workbuddypro to those expectations. The Pi request-log test and the conversation token E2E used fixed 2026-09-01/02 timestamps. With a 90-day request-log retention those records are now filtered out, leaving requests.jsonl empty. Use the current time where the date is immaterial, and freeze Date to the fixture date where the requestDaily keys depend on it.
recordedStart kept the raw whitespace of `ps -o lstart=` while the production processesOf parser collapses it. On macOS the recorded start never matched the live one, so a recorded shell was judged a different process, nothing was signalled, and the stop returned no left pids: one test timed out with an orphaned child and another saw []. Normalize the test's start string the same way processesOf does.
Registers Grok across teamai's workflow-driven launch stack so it behaves like the other launchable tools: selectable via TEAMAI_AI_TOOL and ai.tool, and launchable from workflows with its own isolated home directory. Home resolution for launchable tools now also honors a descriptor's declared root variable, so a tool can own its home configuration without relying on a launch adapter entry. The lint rules that guard launcher imports and tool home environment variables are extended to recognize Grok, and the affected tests cover the new tool across launch, instance and global-hook scenarios. User-facing errors that enumerate launchable tools now include Grok, keeping configuration guidance accurate on every path.
Brings the member-facing tool support documentation in line with the launch stack, where Grok is now a recognized and launchable tool. Both language editions now describe Grok alongside the other supported tools and name the home-directory variable it reads, so the published support matrix stays in sync with what the CLI actually does. This matters for members who move or isolate a tool's configuration: the variable Grok reads is now discoverable in the same reference as every other supported tool, instead of having to be inferred from the source.
|
Reviewed commit Important
Nits
Pre-existing
Verification: GitHub reported 17 passing checks and one skipped remote-provider E2E for this commit. Both separate Codex review runs ended in |
Protects the credentials teamai delivers into Grok's configuration from being read or committed by others. Newly created Grok config files are written with owner-only permissions, and workspace-scoped model keys are registered in the repository's local exclude list so a delivered API key never enters git. This closes a credential-leak path in the workspace sync flow without changing how model configuration is delivered: the key stays available to Grok in the expected location, but is no longer exposed through file permissions or version control. Tests cover both the filesystem and repository sides so the protection holds for every workspace-bound Grok setup.
Makes Grok model delivery reliable across incremental snapshots and teardown. Previously delivered Grok models stay owned and tracked when later deliveries arrive, an empty snapshot removes them cleanly, and remove-http now takes those models out of the recorded Grok config instead of leaving them behind. Delivery is also transactional: a failure while committing the delivery record restores the original config and its permissions, so a broken write never leaves a partially updated Grok setup. Tests cover incremental ownership, empty-snapshot cleanup, teardown, and rollback on commit failure.
Replaces the line-based Grok TOML handling with a table-aware parser so model delivery can distinguish teamai-owned tables from member-owned ones. Tables that carry a delivered id but were not written by teamai are left untouched, and duplicate or oddly quoted headers no longer lead to duplicated or invalid configuration. Merged configs are validated as TOML before they are written, and delivery fails loudly instead of overwriting settings it does not own. Tests cover unmanaged tables, quoted keys, trailing comments, duplicate headers, and multiline values that look like headers.
Keeps the default model selection in a Grok config in sync with what a snapshot actually delivers. Defaults left behind by earlier deliveries are now repaired when their model table is replaced or removed, including the case where the table was already gone, so a stale id can no longer point at a model teamai no longer delivers. Member-owned defaults are preserved: a default that names a model teamai never delivered is left untouched, and removing one delivered model does not disturb unrelated settings. Tests cover default replacement, full removal, orphaned defaults, and defaults outside teamai's ownership.
Corrects how doctor decides whether a delivered MCP server's credentials need to be excluded from git. An empty ownership record no longer counts as proof that nothing needs excluding: when a tool currently maps the file but owns no servers, any server still on disk is reported and its credential file is offered for exclusion. This closes the case where an earlier tool mapping left a server behind and a later empty record hid it. The behavior applies consistently whether no tool noted the file or the current mapping owns nothing. A regression test covers the empty-record case where a previous mapping left a value behind.
Teaches teamai to parse Grok's headless JSON response as a step result when the tool writes no result file, so a successful step no longer loses its answer, session id, and token usage. JSON answers are exposed as structured output and plain text answers as text, with usage read from either naming convention Grok may print. Also detects errors reported inside an otherwise successful Grok response, including non-terminal stop reasons, and turns them into a tool failure instead of treating exit code zero as success. Tests cover result parsing, plain answers, and error detection from native stdout.
Moves the startup and tool timeout settings ahead of the transport-specific lines when rendering Grok's MCP configuration. When a server also emitted a nested table for headers or environment variables, the timeout keys were written after that header and ended up in the wrong table, so Grok silently ignored them. Both HTTP and stdio servers now carry the timeouts on the server itself. Tests parse the rendered TOML to confirm the shape, the headers, and the environment values all land where Grok expects them.
The claude-targeted team command used to skip delivery to Grok whenever Grok's hook file mentioned --tool grok anywhere. A single native hook could then suppress unrelated events or commands, for example a Stop entry hiding a PreToolUse command or a different team command. The guard now matches the exact event and command pair in Grok's own hook file, at both the user and workspace paths, on POSIX and PowerShell. It also falls back to the raw event name when no claude-to-Copilot mapping exists, so events outside the known set still get an accurate guard. Tests cover native hooks not replacing other commands or events and the user versus workspace hook file split.
grokModelsIn used to walk the parsed TOML by hand, checking that model was an object and parsing each entry separately. It now parses the whole document through a zod schema, so the [model.*] table is kept only when all of its entries are well formed, and unowned tables stay out of the model hash. Quoted keys and table headers now track quote state explicitly so stray characters cannot leak into keys. Write failures carry the original parse error as a cause, and the table parser has a named return type.
The claude-team-only fixture still carried the old Grok guard, which skipped a team command whenever --tool grok appeared anywhere in a hook file. The fixture now embeds the event-and-command guard instead, so a native Grok hook only suppresses the matching PostToolUse command.
|
Follow-up on Fixed in this update: Headless Grok steps now read native JSON results; MCP timeouts are emitted in the server table; an empty current MCP ownership record no longer suppresses earlier-mapping evidence. Incremental model delivery retains earlier ownership records, and manifest save failures trigger rollback. Workspace model delivery now checks Git exclusion, and HTTP source teardown cleans up recorded Grok models. Important
[P2 non-blocking] The workspace model inventory still reports at the wrong scope; the folder-trust diagnostics and session timestamp issues from the earlier review remain. Pre-existing [P2 non-blocking]: the direct TOML MCP install path can still write invalid config when an existing Verification: 17 GitHub checks passed and one remote-provider E2E was skipped. Codex Review on Assign ended in |
…al handling Makes Grok's Claude-shaped hook copy step aside only for the exact built-in being dispatched, comparing event, matcher and command on every path, so a matching entry in Grok's own file no longer suppresses unrelated hooks. Model delivery now treats any extra field in a managed model table as a member edit and refuses to replace or remove it. Writes are atomic and owner-only, non-regular files at the config path are left alone, and a merged config that would change any setting teamai does not manage is rejected outright. MCP installs in a project tree now exclude credentials carried by TOML entries from git in the same order as JSON ones, so a write failure cannot leave a manifest entry for an unprotected server. Tests cover matcher-aware hook skips, config ownership, and credential exclusion.
|
Follow-up on The model writer now replaces the config atomically with explicit
[P2 non-blocking] Workspace model inventory still reports at user scope, and Doctor can still misread folder-trust comments. The direct TOML install path also still needs merged-document validation for existing inline tables, an older Codex limitation now shared by Grok. The Grok call reader should reject explicit errors even when partial text is present, and headless steps should reject metadata-only replies when there is no result file. CI at review time: Ubuntu lint failed on Node 20, 22, and 24, and the Windows-safe unit test step failed; other jobs were still running. See CI. The separate Codex run ended in |
Grok hook and model-config readers used to accept unknown values and lean on hand-rolled type checks. They now take typed JSON and TOML inputs validated by zod schemas, so malformed hook files or member settings cannot be treated as valid data. The regenerated hook fixture now carries the event/matcher/command guard that Grok's own hook files use, keeping the test in step with the guard the CLI actually emits.
|
Follow-up on
The previously recorded |
The Grok model reader used the WithoutBigInt variants of smol-toml's table and value types. Those annotations now use the base TomlTable and TomlValue names instead. The change is types-only: parsed config and member-settings behavior stays the same.
|
Follow-up on
I still recommend holding the merge. At review time, this head had six passing checks, one skipped check, and nine unfinished checks, with no failures reported yet. This was a diff review, not a native Grok CLI run. |
…MCP delivery Keeps a member's own choices intact when teamai removes or replaces a delivered Grok model. Tables that gained settings teamai does not manage are left in place with their record, and the default model stays on the one the member selected as long as it is still delivered, instead of snapping back to the first entry. Hook guards now compare the command as Copilot and Grok actually store it, including the project gate, so the duplicate copy steps aside only when the hosts really run the same entry. MCP credential detection also understands TOML blocks and their header variants, and an install records the outcome alongside ownership so a failed write cannot leave a server unprotected while claiming it was checked. Tests cover member-edited tables, stored hook commands, TOML credentials, and the install manifest outcome.
|
Follow-up on
CI at review time: CI reported lint failures on Ubuntu Node 20, 22, and 24 and a Windows-safe unit-test failure; other checks were unfinished. Codex Review on Assign ended in |
A held team hook can outlive its manifest record. Its PowerShell command may carry the POSIX gate Grok and Copilot store as a single-quoted literal, and regating only the outer command left that embedded gate on yesterday's child roots. Regating now walks the quoted literals in a PowerShell payload and updates any POSIX gate it finds, so held hooks land on today's children on both shells. Test helpers no longer mistake quoted gate text for live code.
|
Follow-up on
I still recommend holding the merge. At review time the latest head had five passing checks, one skipped check, and ten unfinished checks, with no failures yet reported. This was a pinned-diff review, not a native Grok CLI run. |
Grok model delivery and MCP reconciliation rewrite the same config.toml, so overlapping runs could read or overwrite each other's changes. A failed model commit also had to finish restoring its snapshot before MCP could safely touch the file. Both paths now hold the MCP lock across the whole read-modify-write, including the rollback on a failed commit. Tests verify the lock is held at each write, released afterwards, and that MCP servers survive model removal.
An install against a Codex or Grok config with an inline mcp_servers table could produce invalid TOML, and ownership migration could write a legacy record before that bad edit was rejected. Installs now validate the original file and the rendered result before any ownership write, so a rejected edit leaves the config, manifest, and Git exclusions alone. An existing server's ownership is committed only after the config write succeeds; a new credential install still records it first. Shared helpers now validate a TOML config and restore its original bytes on a failed write.
Cleanup treated any read or stat failure on a recorded config as "the file is gone" and dropped its record, so a temporary EACCES or EIO left delivered models behind with no way to retry. Reads now distinguish a missing file from an access failure: only ENOENT clears the record, while other errors keep it and mark the run failed. Tests cover retrying remove-http and uninstall for Grok and WorkBuddy after open and lstat failures, along with the already-missing config case.
|
Follow-up on
CI was still running at review time: six checks passed, one was skipped, and nine were unfinished, with no failures yet reported. The separate Codex review ended in |
A Claude or Cursor copy used to step aside as soon as Grok's hook file contained the teamai marker, regardless of whether Grok actually loaded that entry for the workspace. It now asks Grok's own inspector whether a candidate is enabled, trusted for the workspace, and present in the right location, so a stale or disabled entry no longer suppresses the inherited hook. A hidden probe command carries the check into the shell guard, and command matching now ignores malformed or non-command siblings. Historical guards are still rendered for ownership recovery, tracked by a three-state guard version.
|
Follow-up on
CI was still running at review time, with a failure in the Windows-safe unit-test step. The separate Codex review ended in |
The Grok hook probe relied on teamai being on PATH and compared hook source directories by raw path, so a linked workspace or a CLI installed under ~/.teamai/bin could be missed. The probe now sets that bin on PATH for the call and compares canonical, realpath-resolved directories; a Claude settings copy no longer has to live in a .claude folder to be recognized. Uninstall now validates the TOML before and after removing a server. If the config cannot be parsed or the edit would be invalid, ownership is kept and the file is left untouched, so a repair and retry can finish the removal.
|
Follow-up on
I still recommend holding the merge for this issue. CI was in progress at review time (six passed, one skipped, nine unfinished, no reported failures). Codex Review on Assign ended in |
Summary
Type of Change
Test Plan
npx tsc --noEmitpassesnpm run lintpassesnpx vitest run <test files>); the fullnpx vitest runpasses if the change touchessrc/__tests__/helpers/, avitest*.config.ts,package.jsonorpackage-lock.json. CI runs the full suite on every push to a PR.npm run verify:world;npm run -s verify -- helpsays how, andhelp driversfor where a step runs), pasted below with its verdict, combination and entry point, commands, build line and the ledger's last line. Not needed for a docs-only, tests-only or lint-rule-only change.VERIFIED: grok x git x workspace scope via teamai pull
$ npm run verify:world
20261203T142521-f30656
Build 327ced2, teamai 0.22.0, sha256 6b05c0a4a501
$ npm run -s verify -- teamai 20261203T142521-f30656 --pass TEAMAI_NONINTERACTIVE init https://teamai.test/team/repo.git --provider git --agent grok --scope workspace
$ npm run -s verify -- sh 20261203T142521-f30656 mkdir -p .grok
$ npm run -s verify -- teamai 20261203T142521-f30656 --pass TEAMAI_NONINTERACTIVE pull
$ npm run -s verify -- ledger 20261203T142521-f30656
Ledger: CLEAN
Related Issues
Notes for Reviewers