Skip to content

add Grok Build as a detected local agent CLI - #150

Open
modelpath-dev wants to merge 1 commit into
nexu-io:mainfrom
modelpath-dev:feat/grok-build-agent
Open

add Grok Build as a detected local agent CLI#150
modelpath-dev wants to merge 1 commit into
nexu-io:mainfrom
modelpath-dev:feat/grok-build-agent

Conversation

@modelpath-dev

@modelpath-dev modelpath-dev commented Sep 12, 2026

Copy link
Copy Markdown

Summary

  • Detects the grok binary on PATH (and GROK_BIN) as Grok Build.
  • Headless invoke is grok --no-auto-update --output-format streaming-json --always-approve -p <prompt>. The prompt goes on argv, not stdin.
  • Parses Grok's streaming-json text/end events and the final json object, so CI can verify the contract without a live Grok session.

Fixes #136

Test plan

  • pnpm --filter @html-anything/next exec vitest run src/lib/agents/__tests__/argv.test.ts src/lib/agents/__tests__/detect.test.ts (18 passed)
  • pnpm --filter @html-anything/cli exec vitest run src/__tests__/agents-detect.test.ts src/__tests__/agents-invoke.test.ts (48 passed)
  • CI

Grok Build is a headless `grok -p` runtime, not a project build step.
Detect it on PATH and invoke with the documented non-interactive flags
so HTML Anything can reuse an existing grok login without a live session
in CI.
@lefarcen
lefarcen requested a review from PerishCode September 12, 2026 01:21
@lefarcen lefarcen added size/L Large change: 300-699 changed lines risk/medium Medium risk change type/feature Feature or new user-facing capability labels Sep 12, 2026

@PerishCode PerishCode left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Grok CLI contract and streaming parser are otherwise consistent with the published headless interface, but the new argv prompt delivery creates a Windows command-injection path in both the Next app and standalone CLI. This needs to be resolved before the adapter is safe to ship.

🔁 Powered by Looper · runner=reviewer · agent=codex · An autonomous AI dev team for your GitHub repos.

bin: "grok",
envOverride: "GROK_BIN",
vendor: "xAI",
protocol: "argv",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BLOCKING: Do not route the user-controlled Grok prompt through the generic argv protocol while Windows spawning uses a shell. This new protocol: "argv" makes invoke.ts append the complete prompt to argv; on Windows that function then calls spawn(..., { shell: true }). Node constructs a shell command from those arguments, so prompt content containing shell metacharacters can be interpreted by cmd.exe instead of remaining a literal -p value. The standalone CLI has the same combination in cli/src/agents-detect.ts and cli/src/agents-invoke.ts. This is remotely reachable from the conversion/draft input and can execute commands with the server user's privileges. Add a Grok-specific safe delivery path, such as writing the prompt to a securely created temporary file and invoking grok --prompt-file <path> with guaranteed cleanup on close/error/abort, or replace the Windows shell launch with a launcher that preserves an argument boundary for npm shims. Apply the same fix to both implementations and add a Windows-oriented regression test using metacharacters such as &, |, and %...% to prove the prompt is passed as data.

🔁 Powered by Looper · runner=reviewer · agent=codex · An autonomous AI dev team for your GitHub repos.

@lefarcen lefarcen added the needs-product-review Feature PR awaiting product sign-off before merge (see roadmap) label Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-product-review Feature PR awaiting product sign-off before merge (see roadmap) risk/medium Medium risk change size/L Large change: 300-699 changed lines type/feature Feature or new user-facing capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider supporting grok build?

3 participants