engine-internals

engine-internals is a cursor rule for Cursor from 0xranx/golembot. It costs 0 tokens per session (1,960 once invoked), scanned A, original, MIT.

Technical rules describing how Cursor's coding-agent engine starts agents and reads their streamed JSON output.

In plain words
What is it for?
Use them when modifying engine.ts, checking command-line flags, or handling initialization, assistant messages, tool calls, success results, and errors.
Why use it?
They give maintainers the exact process and event meanings needed when changing the engine or investigating agent behavior.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/. Also seen: reads .claude/ paths; mentions CLAUDE.md; mentions Claude Code.

Good fit Use them when modifying engine.ts, checking command-line flags, or handling initialization, assistant messages, tool calls, success results, and errors.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/0xranx/golembot/engine-internals
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/0xranx/golembot

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for engine-internals

README.md
[![agentmods](https://agentmods.dev/badge/rules/0xranx/golembot/engine-internals/github.svg)](https://agentmods.dev/rules/0xranx/golembot/engine-internals)
Your own site
<a href="https://agentmods.dev/rules/0xranx/golembot/engine-internals"><img src="https://agentmods.dev/badge/rules/0xranx/golembot/engine-internals/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for engine-internals

Your own site · 80×15
<a href="https://agentmods.dev/rules/0xranx/golembot/engine-internals"><img src="https://agentmods.dev/badge/rules/0xranx/golembot/engine-internals.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,960 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.01960
Opus 5.5 $0.00000 $0.00784
Sonnet 5.5 $0.00000 $0.00392
Haiku 4.5 $0.00000 $0.00196

Measured 1mo ago against content hash f0c01b0f8c9a, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

engine-internals scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

- Uses standard `child_process.spawn` — no PTY (node-pty) needed since CLI version 2026.02+
.cursor/rules/engine-internals.mdc · 136 lines

How it starts

The opening of the file, as written. The whole thing — 136 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Cursor Engine Implementation Details

Agent CLI Invocation

  • Binary path: ~/.local/bin/agent (not cursor, nor cursor agent)
  • Uses standard child_process.spawn — no PTY (node-pty) needed since CLI version 2026.02+
  • Key flags: --output-format stream-json --stream-partial-output --force --trust --sandbox disabled --approve-mcps

stream-json Output Format

Output is clean NDJSON on stdout; stripAnsi() is retained as a safety net but is not expected to be needed.

One JSON object per line, main types:

{ "type": "system", "subtype": "init", "session_id": "xxx", ... }     → Init; does not signal end of conversation
{ "type": "assistant", "message": { "content": [{ "type": "text", "text": "..." }] } }  → Assistant text delta
{ "type": "tool_call", "subtype": "started", "tool_call": { "<XxxToolCall>": { "args": {...} } } }  → Tool call started
{ "type": "tool_call", "subtype": "completed", "tool_call": { "<XxxToolCall>": { "args": {...}, "result": {...} } } }  → Tool call completed
{ "type": "result", "subtype": "success", "is_error": false, "session_id": "xxx", "duration_ms": 1234 }  → Normal end
{ "type": "result", "subtype": "error", "is_error": true, "result": "error msg" }  → Error end

Key Notes

  1. tool_call has both started and completed events — started → yield tool_call, completed → yield tool_result; do not treat both as tool_call (would duplicate)
  2. tool_call name is not a fixed field — iterate over the tool_call object keys and find the one ending with ToolCall; some tools use function format ({ "name": "...", "arguments": "..." })
  3. --stream-partial-output changes assistant event granularity — with it, each assistant event is character-level delta; without it, full paragraphs. Critical: after all deltas for each segment (text between tool calls), Cursor sends one more summary event (content = concatenation of that segment’s deltas). CursorEngine uses accumulated text comparison to detect and skip summary, avoiding duplicate text
  4. assistant.message.content is an array — multiple blocks; filter those with type === 'text' and concatenate
  5. system event is not a termination signal — do not end the stream on system event
  6. session_id appears in both system and result — use the one in result as the final session_id

Read the full file on GitHub · 136 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 136 lines · 0 tokens per session scan A f0c01b0f8c9a

Subscribe to this mod's changes

engine-internals is a cursor rule published in the GitHub repository 0xranx/golembot (322 stars, last pushed 19d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,960 tokens. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.