From ab86d5e25c0c1d1a1e90b0662a03b52058402ff7 Mon Sep 17 00:00:00 2001 From: jparker2006 <85816763+jparker2006@users.noreply.github.com> Date: Mon, 23 Nov 2026 03:00:18 +0000 Subject: [PATCH 1/7] #2473: an empty cursor row fails the harness-row runner, red first --- .../local/harnesses/cursor/evidence/red.txt | 27 +++++++++++++++++++ adapters/local/harnesses/cursor/row.json | 1 + 2 files changed, 28 insertions(+) create mode 100644 adapters/local/harnesses/cursor/evidence/red.txt create mode 100644 adapters/local/harnesses/cursor/row.json diff --git a/adapters/local/harnesses/cursor/evidence/red.txt b/adapters/local/harnesses/cursor/evidence/red.txt new file mode 100644 index 000000000..4ed2bf502 --- /dev/null +++ b/adapters/local/harnesses/cursor/evidence/red.txt @@ -0,0 +1,27 @@ +# HR5 #2473 red: an empty cursor row (row.json is {}) fails the runner (31 refusing agent CLI stubs first on PATH) +$ python3 -I adapters/local/test_harnesses.py +fail claude: row.json harness: claude is built in, and no row may use a built-in name +fail credential-env: row.json env: a value looks like a credential; env holds only fixed settings that are not credentials +fail daemon-survives: daemon: the background process the row declares still runs after stop +pass effort-crowded: the contract, the folder, the kit's five checks, and the session, env, background process and effort checks +fail effort-missing: row.json effort: it has no effort form; give an effort map or "none: " +fail effort-unpassed: row.json effort: it maps effort values to arguments, but start has no {effort} to pass them +pass example: the contract, the folder, the kit's five checks, and the session, env, background process and effort checks +pass example-none: the contract, the folder, the kit's five checks, and the session, env, background process and effort checks +fail larger-argument: row.json start: a placeholder sits inside a larger argument; each fills a whole argument +fail row-missing: row.json is missing +fail session-differs: session: the wake turn got a different session id from the start turn +fail signed-out-bad-pattern: row.json signed_out: a pattern does not compile +pass signed-out-json: the contract, the folder, the kit's five checks, and the session, env, background process and effort checks +fail wake-no-session: row.json wake: it has no {session} +pass driver: a broken row's D3 error names its row file and fits the error schema: a row folder with no row.json, a harness that is not a string, and a 60-character harness with a missing field +pass driver: a row's session id and signed_out patterns are read from its first turn's output, never the clone's, and the first line that has the session's JSON path decides it +pass driver: an effort the row can't take is refused before the driver looks for its program, and a row's effort ids are lower-case words of up to 20 characters +pass driver: a row whose fixed arguments in start, wake, modes or effort look like a credential, joined or as a flag and its value, is refused naming only its field +pass driver: a row's env and effort setting reach only the harness, never the turn's supervisor +pass driver: an unknown harness is a D3 error that lists the built-ins and the row folders, and starts nothing +pass driver: a wake before the reported session id is known is a D3 error that starts nothing, whether the first turn has ended or still runs +pass driver: a wake while the first turn runs saves its newly reported session id, and once it is saved answers woke with no state write and starts nothing +rows in adapters/local/harnesses: cursor +fail cursor: row.json effort: it has no effort form; give an effort map or "none: " +exit 1 diff --git a/adapters/local/harnesses/cursor/row.json b/adapters/local/harnesses/cursor/row.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/adapters/local/harnesses/cursor/row.json @@ -0,0 +1 @@ +{} From e058c4df7b5d439bd565937c5af6203951672efb Mon Sep 17 00:00:00 2001 From: jparker2006 <85816763+jparker2006@users.noreply.github.com> Date: Mon, 23 Nov 2026 03:03:32 +0000 Subject: [PATCH 2/7] #2473: the cursor row, its fake, README and test_row.py pass the runner --- adapters/local/harnesses/cursor/README.md | 43 +++++++++ .../local/harnesses/cursor/evidence/green.txt | 50 +++++++++++ adapters/local/harnesses/cursor/fake | 89 +++++++++++++++++++ adapters/local/harnesses/cursor/row.json | 46 +++++++++- adapters/local/harnesses/cursor/test_row.py | 65 ++++++++++++++ 5 files changed, 292 insertions(+), 1 deletion(-) create mode 100644 adapters/local/harnesses/cursor/README.md create mode 100644 adapters/local/harnesses/cursor/evidence/green.txt create mode 100755 adapters/local/harnesses/cursor/fake create mode 100644 adapters/local/harnesses/cursor/test_row.py diff --git a/adapters/local/harnesses/cursor/README.md b/adapters/local/harnesses/cursor/README.md new file mode 100644 index 000000000..cf715dda6 --- /dev/null +++ b/adapters/local/harnesses/cursor/README.md @@ -0,0 +1,43 @@ +# cursor: Cursor CLI on the local driver + +Login: agent's own login: `agent login` saves it locally (the macOS keychain, or ~/.config/cursor/auth.json on Linux), or the CURSOR_API_KEY the user set for the CLI; the driver never reads or passes it + +Effort: none + +Live check: #2478 + +The `cursor` harness row runs Cursor CLI (`agent`) as a builder through the user's own sign-in, under the [harness-row contract](../../harness-row.md). Everything here was read at **Cursor CLI 2026.11.22-e9042b2**, the version [`https://cursor.com/install`](https://cursor.com/install) installed on 2026-11-23, and from Cursor's CLI docs on that day. Its `--help` text was read from that package's own source (`index.js`), never by running the CLI. + +## Commands + +| Turn | Command line | +| --- | --- | +| Start | `agent --print --output-format stream-json --trust --model ` | +| Wake | `agent --print --output-format stream-json --trust --resume --model ` | +| Stop | the driver's own stop: it ends the turn's whole process tree | + +- **Session id:** the first JSON line with a `session_id` key. In `stream-json` that is the `system`/`init` event, which the CLI prints once at the beginning of the session ([output format](https://cursor.com/docs/cli/reference/output-format#system-initialization)), so the id is known as soon as the run starts. +- **`--trust`:** print mode refuses a workspace the user hasn't trusted with `Workspace Trust Required` and exit 1, unless `--trust`, `--yolo` or `-f` is passed. The driver's clone is a new folder each run, so both lines pass `--trust` ([parameters](https://cursor.com/docs/cli/reference/parameters#global-options): "Trust the workspace without prompting (headless mode only)"). +- **Signed out:** in print mode the CLI exits 1 with `Error: Authentication required. Please run 'agent login' first, or set CURSOR_API_KEY environment variable.`, or a server message followed by `Please run 'agent login' to authenticate.` The row's `signed_out` pattern matches the second form too, and `start` then names `agent login` ([authentication](https://cursor.com/docs/cli/reference/authentication#troubleshooting)). +- **Background process:** `agent` runs each shell tool command as its own detached process group under the turn, and in print mode waits for background shells after its last message before it aborts them (the hidden `--background-shell-timeout` option's help). Stop ends them with the process tree; the fake simulates one such process. + +## Modes + +| Mode | Arguments | What it does | +| --- | --- | --- | +| `force` | `--force` | "Force allow commands unless explicitly denied": every action runs except what `permissions.deny` and team policies block ([headless](https://cursor.com/docs/cli/headless#file-modification-in-scripts)) | +| `allowlist` | none | Print mode's default approval rules: workspace edits and allowlisted or sandboxed commands run, and anything that needs approval is rejected ([headless](https://cursor.com/docs/cli/headless#file-modification-in-scripts)) | + +## The census check: do `-p` and `--resume` work together? + +**Yes.** `--print` and `--resume [chatId]` are both global options that "can be used with any command" ([parameters](https://cursor.com/docs/cli/reference/parameters#global-options)), and the CLI's source agrees: its one agent action reads `--resume `, then starts the same `resume` session in print mode as interactively. Print mode refuses a resume only when that chat is running inside an `agent persist` session ("Chat … may still be running"), and this row never uses `agent persist`. A bare `--resume` with no id opens an interactive picker, so the wake line always passes the saved id. The census's `--output-format json` is not used: it prints `session_id` only in the one object at the end of a successful run ([output format](https://cursor.com/docs/cli/reference/output-format#json-format)), so a wake during a long first turn would find no session id. + +## Effort + +The row's effort is `none`. Cursor CLI 2026.11.22-e9042b2 has no effort flag and no effort environment setting: its options list none ([parameters](https://cursor.com/docs/cli/reference/parameters#global-options)), and its own `--model` help says "Parameterized models accept quoted bracket overrides, e.g. 'claude-opus-4-8[context=1m,effort=high,fast=false]'". Effort is part of some model ids, never a separate argument, so a fixed argument can't add it and a start with an effort is refused. + +## The fake + +`fake` parses the documented global options in any order, as `--name value` or `--name=value`, and exits 2 on anything else: an unknown option, a missing value, a value outside `--output-format`, `--mode` or `--sandbox`'s choices, `--stream-partial-output` without `stream-json`, `--resume` with `--continue`, or a bare `--resume` in print mode. It simulates only the start and wake above, exits 3 on any other documented command line (a subcommand, `--api-key`, or a run other than print mode with `stream-json`), and, without `--trust`, `--force` or `--yolo`, exits 1 as the real CLI does. `test_row.py` checks each of these. + +Synthetic: `fake` is the only CLI here. diff --git a/adapters/local/harnesses/cursor/evidence/green.txt b/adapters/local/harnesses/cursor/evidence/green.txt new file mode 100644 index 000000000..a525b1083 --- /dev/null +++ b/adapters/local/harnesses/cursor/evidence/green.txt @@ -0,0 +1,50 @@ +# HR5 #2473 green: the cursor row passes the runner, and its test_row.py (31 refusing agent CLI stubs first on PATH) +$ python3 -I adapters/local/test_harnesses.py +fail claude: row.json harness: claude is built in, and no row may use a built-in name +fail credential-env: row.json env: a value looks like a credential; env holds only fixed settings that are not credentials +fail daemon-survives: daemon: the background process the row declares still runs after stop +pass effort-crowded: the contract, the folder, the kit's five checks, and the session, env, background process and effort checks +fail effort-missing: row.json effort: it has no effort form; give an effort map or "none: " +fail effort-unpassed: row.json effort: it maps effort values to arguments, but start has no {effort} to pass them +pass example: the contract, the folder, the kit's five checks, and the session, env, background process and effort checks +pass example-none: the contract, the folder, the kit's five checks, and the session, env, background process and effort checks +fail larger-argument: row.json start: a placeholder sits inside a larger argument; each fills a whole argument +fail row-missing: row.json is missing +fail session-differs: session: the wake turn got a different session id from the start turn +fail signed-out-bad-pattern: row.json signed_out: a pattern does not compile +pass signed-out-json: the contract, the folder, the kit's five checks, and the session, env, background process and effort checks +fail wake-no-session: row.json wake: it has no {session} +pass driver: a broken row's D3 error names its row file and fits the error schema: a row folder with no row.json, a harness that is not a string, and a 60-character harness with a missing field +pass driver: a row's session id and signed_out patterns are read from its first turn's output, never the clone's, and the first line that has the session's JSON path decides it +pass driver: an effort the row can't take is refused before the driver looks for its program, and a row's effort ids are lower-case words of up to 20 characters +pass driver: a row whose fixed arguments in start, wake, modes or effort look like a credential, joined or as a flag and its value, is refused naming only its field +pass driver: a row's env and effort setting reach only the harness, never the turn's supervisor +pass driver: an unknown harness is a D3 error that lists the built-ins and the row folders, and starts nothing +pass driver: a wake before the reported session id is known is a D3 error that starts nothing, whether the first turn has ended or still runs +pass driver: a wake while the first turn runs saves its newly reported session id, and once it is saved answers woke with no state write and starts nothing +rows in adapters/local/harnesses: cursor +pass cursor: the contract, the folder, the kit's five checks, and the session, env, background process and effort checks +exit 0 +$ python3 -I adapters/local/harnesses/cursor/test_row.py +pass an unknown option: exit 2 +pass the hidden --new-session-id: exit 2 +pass a --model with no value: exit 2 +pass an --output-format outside its choices: exit 2 +pass a --sandbox outside its choices: exit 2 +pass a --mode outside its choices: exit 2 +pass --stream-partial-output without stream-json: exit 2 +pass --resume with --continue: exit 2 +pass a bare --resume in print mode: exit 2 +pass a wake prompt without --resume: exit 2 +pass a start prompt with --resume: exit 2 +pass the login command: exit 3 +pass a login in argv: exit 3 +pass the json output format: exit 3 +pass a run without --print: exit 3 +pass a run with no --model: exit 3 +pass an untrusted workspace: exit 1 +pass the row's start with mode force reaches the turn: exit 1 +pass the row's wake with mode force reaches the turn: exit 1 +pass the row's start with mode allowlist reaches the turn: exit 1 +pass the row's wake with mode allowlist reaches the turn: exit 1 +exit 0 diff --git a/adapters/local/harnesses/cursor/fake b/adapters/local/harnesses/cursor/fake new file mode 100755 index 000000000..79347cd08 --- /dev/null +++ b/adapters/local/harnesses/cursor/fake @@ -0,0 +1,89 @@ +#!/usr/bin/env python3 +import json, os, sys +sys.dont_write_bytecode = True +sys.path.insert(0, os.environ['FAKE_CLI_LIB']) +import fake_cli + +HELP = '''The fake agent (Cursor CLI 2026.11.22-e9042b2). It parses the global options of +https://cursor.com/docs/cli/reference/parameters and exits 2 on anything else. It simulates only: + agent --print --output-format stream-json (--trust | --force | --yolo) [--resume ] --model +in any option order, and exits 3 on a documented command line it does not simulate.''' +FLAGS = {'-p': '--print', '--print': '--print', '-f': '--force', '--force': '--force', '--yolo': '--yolo', + '--stream-partial-output': None, '--continue': None, '--plan': None, '--list-models': None, + '--approve-mcps': None, '--trust': None, '--skip-worktree-setup': None, '-v': '--version', + '--version': '--version', '-h': '--help', '--help': '--help'} +VALUES = {'--api-key': None, '-H': '--header', '--header': '--header', '--output-format': ('text', 'json', 'stream-json'), + '--model': None, '--mode': ('plan', 'ask'), '--sandbox': ('enabled', 'disabled'), '--workspace': None, + '--plugin-dir': None, '--worktree-base': None} +OPTIONAL = {'--resume': None, '-w': '--worktree', '--worktree': '--worktree'} +COMMANDS = ('agent', 'login', 'logout', 'status', 'whoami', 'about', 'models', 'mcp', 'sandbox', 'worker', 'acp', + 'update', 'ls', 'resume', 'create-chat', 'generate-rule', 'rule', 'install-shell-integration', + 'uninstall-shell-integration', 'help') +SIGNED_OUT = ("Error: Authentication required. Please run 'agent login' first, or set CURSOR_API_KEY " + "environment variable.") + + +def parse(argv): + seen, words, i = {}, [], 0 + while i < len(argv): + a = argv[i] + name, eq, value = a.partition('=') if a.startswith('--') else (a, '', '') + if a == '--': + words += argv[i + 1:] + break + if not a.startswith('-') or a == '-': + words.append(a) + elif name in FLAGS and not eq: + seen[FLAGS[name] or name] = True + elif name in VALUES: + if not eq: + i += 1 + if i == len(argv): + fake_cli.refuse() + value = argv[i] + choices = VALUES[name] + if isinstance(choices, tuple) and value not in choices: + fake_cli.refuse() + seen[choices if isinstance(choices, str) else name] = value + elif name in OPTIONAL: + if not eq and i + 1 < len(argv) and not argv[i + 1].startswith('-'): + i += 1 + value, eq = argv[i], '=' + seen[OPTIONAL[name] or name] = value if eq else True + else: + fake_cli.refuse() + i += 1 + return seen, words + + +def not_simulated(why): + print('fake agent: %s is documented, but this fake does not simulate it' % why, file=sys.stderr) + sys.exit(3) + + +if sys.argv[1:] in (['--help'], ['-h']): + print(HELP) + sys.exit(0) +seen, words = parse(sys.argv[1:]) +if seen.get('--stream-partial-output') and seen.get('--output-format') != 'stream-json': + fake_cli.refuse() +if '--resume' in seen and seen.get('--continue'): + fake_cli.refuse() +if seen.get('--print') and seen.get('--resume') is True: + fake_cli.refuse() +if words[:1] and words[0] in COMMANDS: + not_simulated('the %s command' % words[0]) +if '--api-key' in seen: + not_simulated('a login in argv (--api-key)') +if not seen.get('--print') or seen.get('--output-format') != 'stream-json' or not seen.get('--model') or not words: + not_simulated('a run other than --print --output-format stream-json with --model and a prompt') +if not (seen.get('--trust') or seen.get('--force') or seen.get('--yolo')): + print('Workspace Trust Required: pass --trust, --yolo, or -f if you trust this directory', file=sys.stderr) + sys.exit(1) +prompt, session = ' '.join(words), seen.get('--resume') +if (session is not None) != prompt.startswith('You were woken'): + fake_cli.refuse() +init = lambda sid: json.dumps({'type': 'system', 'subtype': 'init', 'apiKeySource': 'login', + 'cwd': '/synthetic/workspace', 'session_id': sid, 'model': seen['--model'], + 'permissionMode': 'default'}) +fake_cli.turn(prompt, seen['--model'], session, init, daemon='tree', signed_out=SIGNED_OUT) diff --git a/adapters/local/harnesses/cursor/row.json b/adapters/local/harnesses/cursor/row.json index 0967ef424..7085406a7 100644 --- a/adapters/local/harnesses/cursor/row.json +++ b/adapters/local/harnesses/cursor/row.json @@ -1 +1,45 @@ -{} +{ + "harness": "cursor", + "program": "agent", + "start": [ + "--print", + "--output-format", + "stream-json", + "--trust", + "--model", + "{model}", + "{mode}", + "{prompt}" + ], + "wake": [ + "--print", + "--output-format", + "stream-json", + "--trust", + "--resume", + "{session}", + "--model", + "{model}", + "{mode}", + "{prompt}" + ], + "session": { + "json": [ + "session_id" + ] + }, + "modes": { + "force": [ + "--force" + ], + "allowlist": [] + }, + "env": {}, + "effort": "none: agent (Cursor CLI 2026.11.22-e9042b2) has no effort flag or env setting; its --help puts effort only inside a parameterized model id, such as 'claude-opus-4-8[effort=high]'", + "login": "agent's own login: `agent login` saves it locally (the macOS keychain, or ~/.config/cursor/auth.json on Linux), or the CURSOR_API_KEY the user set for the CLI; the driver never reads or passes it", + "daemon": "agent runs each shell tool command as its own detached process group under the turn, and may keep background shells after its last message; stop ends them with the process tree", + "signed_out": [ + "please run '(?:agent|cursor-agent) login'" + ], + "login_command": "agent login" +} diff --git a/adapters/local/harnesses/cursor/test_row.py b/adapters/local/harnesses/cursor/test_row.py new file mode 100644 index 000000000..c580b9ea9 --- /dev/null +++ b/adapters/local/harnesses/cursor/test_row.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 +import json, os, subprocess, sys + +sys.dont_write_bytecode = True +HERE = os.path.dirname(os.path.abspath(__file__)) +FAKE = os.path.join(HERE, 'fake') +ENV = dict(os.environ, FAKE_CLI_LIB=os.path.join(HERE, '..', '..', 'fixtures'), FAKE_CLI_SIGNED_OUT='1') +START = 'Build the ticket: example/site#7, with the build-ticket skill. Keep one status note there.' +WAKE = 'You were woken: take up example/site#7 again, with the build-ticket skill. Edit your own status note there.' +SID = '00000000-0000-4000-8000-000000000000' +PRINT = ['--print', '--output-format', 'stream-json', '--trust', '--model', 'synthetic-1'] +CASES = [ + (2, 'an unknown option', PRINT + ['--effort', 'high', START]), + (2, 'the hidden --new-session-id', PRINT + ['--new-session-id', SID, START]), + (2, 'a --model with no value', ['--print', '--output-format', 'stream-json', '--trust', '--model']), + (2, 'an --output-format outside its choices', ['--print', '--output-format', 'ndjson', '--trust', '--model', + 'synthetic-1', START]), + (2, 'a --sandbox outside its choices', PRINT + ['--sandbox', 'on', START]), + (2, 'a --mode outside its choices', PRINT + ['--mode', 'agent', START]), + (2, '--stream-partial-output without stream-json', ['--print', '--output-format', 'json', '--trust', + '--stream-partial-output', '--model', 'synthetic-1', START]), + (2, '--resume with --continue', PRINT + ['--resume', SID, '--continue', WAKE]), + (2, 'a bare --resume in print mode', PRINT + [WAKE, '--resume']), + (2, 'a wake prompt without --resume', PRINT + [WAKE]), + (2, 'a start prompt with --resume', PRINT + ['--resume', SID, START]), + (3, 'the login command', ['login']), + (3, 'a login in argv', PRINT + ['--api-key', 'synthetic', START]), + (3, 'the json output format', ['--print', '--output-format', 'json', '--trust', '--model', 'synthetic-1', START]), + (3, 'a run without --print', ['--output-format', 'stream-json', '--trust', '--model', 'synthetic-1', START]), + (3, 'a run with no --model', ['--print', '--output-format', 'stream-json', '--trust', START]), + (1, 'an untrusted workspace', ['--print', '--output-format', 'stream-json', '--model', 'synthetic-1', START]), +] + + +def run(args): + p = subprocess.run([FAKE] + args, env=ENV, capture_output=True, text=True, timeout=30) + return p.returncode, p.stdout + + +def row_lines(): + with open(os.path.join(HERE, 'row.json')) as f: + row = json.load(f) + for mode, extra in row['modes'].items(): + for field, text in (('start', START), ('wake', WAKE)): + fills = {'{prompt}': [text], '{model}': ['synthetic-1'], '{session}': [SID], '{mode}': extra, + '{effort}': []} + yield '%s with mode %s' % (field, mode), [b for a in row[field] for b in fills.get(a, [a])] + + +def main(): + failed = 0 + for want, what, args in CASES: + got = run(args)[0] + print('%s %s: exit %d' % ('pass' if got == want else 'fail', what, got)) + failed += got != want + for what, args in row_lines(): + code, out = run(args) + ok = code == 1 and "Please run 'agent login'" in out + print('%s the row\'s %s reaches the turn: exit %d' % ('pass' if ok else 'fail', what, code)) + failed += not ok + return 1 if failed else 0 + + +if __name__ == '__main__': + sys.exit(main()) From ddc057228e02ff76e65579291fe25e83ee5febc3 Mon Sep 17 00:00:00 2001 From: jparker2006 <85816763+jparker2006@users.noreply.github.com> Date: Mon, 23 Nov 2026 03:05:36 +0000 Subject: [PATCH 3/7] #2473: the cursor row passes the harness-row runner on its fake; green --- adapters/local/harnesses/cursor/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapters/local/harnesses/cursor/README.md b/adapters/local/harnesses/cursor/README.md index cf715dda6..73b2d0349 100644 --- a/adapters/local/harnesses/cursor/README.md +++ b/adapters/local/harnesses/cursor/README.md @@ -19,7 +19,7 @@ The `cursor` harness row runs Cursor CLI (`agent`) as a builder through the user - **Session id:** the first JSON line with a `session_id` key. In `stream-json` that is the `system`/`init` event, which the CLI prints once at the beginning of the session ([output format](https://cursor.com/docs/cli/reference/output-format#system-initialization)), so the id is known as soon as the run starts. - **`--trust`:** print mode refuses a workspace the user hasn't trusted with `Workspace Trust Required` and exit 1, unless `--trust`, `--yolo` or `-f` is passed. The driver's clone is a new folder each run, so both lines pass `--trust` ([parameters](https://cursor.com/docs/cli/reference/parameters#global-options): "Trust the workspace without prompting (headless mode only)"). - **Signed out:** in print mode the CLI exits 1 with `Error: Authentication required. Please run 'agent login' first, or set CURSOR_API_KEY environment variable.`, or a server message followed by `Please run 'agent login' to authenticate.` The row's `signed_out` pattern matches the second form too, and `start` then names `agent login` ([authentication](https://cursor.com/docs/cli/reference/authentication#troubleshooting)). -- **Background process:** `agent` runs each shell tool command as its own detached process group under the turn, and in print mode waits for background shells after its last message before it aborts them (the hidden `--background-shell-timeout` option's help). Stop ends them with the process tree; the fake simulates one such process. +- **Background process:** `agent` runs each shell tool command as its own detached process group under the turn (its bundled `shell-exec` module spawns each one with `detached: true`), and in print mode waits for background shells after its last message before it aborts them (the hidden `--background-shell-timeout` option's help). Stop ends them with the process tree; the fake simulates one such process. ## Modes From 1b445bd5364596a33a9dee1fb9d11591e6d06d7e Mon Sep 17 00:00:00 2001 From: openwiz-lead Date: Mon, 23 Nov 2026 08:09:38 +0000 Subject: [PATCH 4/7] Resync the pull request's diff now that #2608 has merged (no change) From ca68dad6cbde306c299a13ff87bc73d84a1d7751 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 26 Nov 2026 21:44:31 +0000 Subject: [PATCH 5/7] #2473: let the privacy scan read the corrected pull request body The failing check is T3 on the pull request body: the self-check line embedded a home-folder path inside a search pattern. That sentence now describes the search without the path. A rerun would reuse the old event, so this commit publishes a new head for a fresh scan. The tree is unchanged. Co-authored-by: Jake Parker From cab32b62a5d0a2a5ccf05f965457b74b5e725f8e Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 26 Nov 2026 22:12:47 +0000 Subject: [PATCH 6/7] #2473: add the changelog line the product diff now needs The parent row's changelog file is on main, so this pull request's diff is only the cursor harness row. The changelog check requires this ticket's own line for that product change. Co-authored-by: Jake Parker --- changes/2473.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changes/2473.md diff --git a/changes/2473.md b/changes/2473.md new file mode 100644 index 000000000..a81d82842 --- /dev/null +++ b/changes/2473.md @@ -0,0 +1,3 @@ +kind: added + +On synthetic fixtures, the local driver runs Cursor CLI as the `cursor` harness row. From 1961932931b8cc2561c2a9429d44a402c3c0be43 Mon Sep 17 00:00:00 2001 From: jparker2006 <85816763+jparker2006@users.noreply.github.com> Date: Fri, 27 Nov 2026 14:40:42 +0000 Subject: [PATCH 7/7] #2473: require explicit force mode and validate fake --header syntax - Drop the un-enforced allowlist mode from adapters/local/harnesses/cursor/row.json so owners must explicitly approve force rather than getting Run Everything from effective Cursor config under allowlist, and document why in README.md. - Validate -H / --header values in adapters/local/harnesses/cursor/fake as non-empty Name: Value headers (exiting 2 on malformed syntax). - Add tests for both fixes in adapters/local/harnesses/cursor/test_row.py and refresh evidence/green.txt. --- adapters/local/harnesses/cursor/README.md | 5 +- .../local/harnesses/cursor/evidence/green.txt | 13 +++- adapters/local/harnesses/cursor/fake | 8 ++- adapters/local/harnesses/cursor/row.json | 3 +- adapters/local/harnesses/cursor/test_row.py | 68 +++++++++++++++++-- 5 files changed, 85 insertions(+), 12 deletions(-) diff --git a/adapters/local/harnesses/cursor/README.md b/adapters/local/harnesses/cursor/README.md index 73b2d0349..83161f007 100644 --- a/adapters/local/harnesses/cursor/README.md +++ b/adapters/local/harnesses/cursor/README.md @@ -26,7 +26,8 @@ The `cursor` harness row runs Cursor CLI (`agent`) as a builder through the user | Mode | Arguments | What it does | | --- | --- | --- | | `force` | `--force` | "Force allow commands unless explicitly denied": every action runs except what `permissions.deny` and team policies block ([headless](https://cursor.com/docs/cli/headless#file-modification-in-scripts)) | -| `allowlist` | none | Print mode's default approval rules: workspace edits and allowlisted or sandboxed commands run, and anything that needs approval is rejected ([headless](https://cursor.com/docs/cli/headless#file-modification-in-scripts)) | + +No `allowlist` mode is offered: Cursor CLI 2026.11.22-e9042b2 has no flag to enforce `allowlist` over an effective `approvalMode: "unrestricted"` from user or merged project config, so omitting `--force` can still run every action in print mode ([headless](https://cursor.com/docs/cli/headless#file-modification-in-scripts), [configuration](https://cursor.com/docs/cli/reference/configuration#optional-fields)). Requiring explicit approval of `force` prevents an owner from approving `allowlist` and getting Run Everything silently. ## The census check: do `-p` and `--resume` work together? @@ -38,6 +39,6 @@ The row's effort is `none`. Cursor CLI 2026.11.22-e9042b2 has no effort flag and ## The fake -`fake` parses the documented global options in any order, as `--name value` or `--name=value`, and exits 2 on anything else: an unknown option, a missing value, a value outside `--output-format`, `--mode` or `--sandbox`'s choices, `--stream-partial-output` without `stream-json`, `--resume` with `--continue`, or a bare `--resume` in print mode. It simulates only the start and wake above, exits 3 on any other documented command line (a subcommand, `--api-key`, or a run other than print mode with `stream-json`), and, without `--trust`, `--force` or `--yolo`, exits 1 as the real CLI does. `test_row.py` checks each of these. +`fake` parses the documented global options in any order, as `--name value` or `--name=value`, and exits 2 on anything else: an unknown option, a missing value, a value outside `--output-format`, `--mode` or `--sandbox`'s choices, a `-H` or `--header` value without a non-empty `Name: Value` header, `--stream-partial-output` without `stream-json`, `--resume` with `--continue`, or a bare `--resume` in print mode. It simulates only the start and wake above, exits 3 on any other documented command line (a subcommand, `--api-key`, or a run other than print mode with `stream-json`), and, without `--trust`, `--force` or `--yolo`, exits 1 as the real CLI does. `test_row.py` checks each of these. Synthetic: `fake` is the only CLI here. diff --git a/adapters/local/harnesses/cursor/evidence/green.txt b/adapters/local/harnesses/cursor/evidence/green.txt index a525b1083..6196082a7 100644 --- a/adapters/local/harnesses/cursor/evidence/green.txt +++ b/adapters/local/harnesses/cursor/evidence/green.txt @@ -32,6 +32,14 @@ pass a --model with no value: exit 2 pass an --output-format outside its choices: exit 2 pass a --sandbox outside its choices: exit 2 pass a --mode outside its choices: exit 2 +pass a --header without a colon: exit 2 +pass a -H without a colon: exit 2 +pass a --header= without a colon: exit 2 +pass a --header with an empty name: exit 2 +pass a --header with a blank name: exit 2 +pass a --header with whitespace in the name: exit 2 +pass a bad second --header after a valid one: exit 2 +pass a bad first --header before a valid one: exit 2 pass --stream-partial-output without stream-json: exit 2 pass --resume with --continue: exit 2 pass a bare --resume in print mode: exit 2 @@ -43,8 +51,9 @@ pass the json output format: exit 3 pass a run without --print: exit 3 pass a run with no --model: exit 3 pass an untrusted workspace: exit 1 +pass valid --header and -H reach the turn: exit 1 +pass row.json requires explicit force mode: force +pass driver refuses allowlist approval: refused pass the row's start with mode force reaches the turn: exit 1 pass the row's wake with mode force reaches the turn: exit 1 -pass the row's start with mode allowlist reaches the turn: exit 1 -pass the row's wake with mode allowlist reaches the turn: exit 1 exit 0 diff --git a/adapters/local/harnesses/cursor/fake b/adapters/local/harnesses/cursor/fake index 79347cd08..2888269de 100755 --- a/adapters/local/harnesses/cursor/fake +++ b/adapters/local/harnesses/cursor/fake @@ -44,7 +44,13 @@ def parse(argv): choices = VALUES[name] if isinstance(choices, tuple) and value not in choices: fake_cli.refuse() - seen[choices if isinstance(choices, str) else name] = value + key = choices if isinstance(choices, str) else name + if key == '--header': + header_name, sep, _ = value.partition(':') + if not sep or '\r' in value or '\n' in value or not header_name.strip() or \ + any(c.isspace() or ord(c) < 33 for c in header_name.strip()): + fake_cli.refuse() + seen[key] = value elif name in OPTIONAL: if not eq and i + 1 < len(argv) and not argv[i + 1].startswith('-'): i += 1 diff --git a/adapters/local/harnesses/cursor/row.json b/adapters/local/harnesses/cursor/row.json index 7085406a7..d6c928c42 100644 --- a/adapters/local/harnesses/cursor/row.json +++ b/adapters/local/harnesses/cursor/row.json @@ -31,8 +31,7 @@ "modes": { "force": [ "--force" - ], - "allowlist": [] + ] }, "env": {}, "effort": "none: agent (Cursor CLI 2026.11.22-e9042b2) has no effort flag or env setting; its --help puts effort only inside a parameterized model id, such as 'claude-opus-4-8[effort=high]'", diff --git a/adapters/local/harnesses/cursor/test_row.py b/adapters/local/harnesses/cursor/test_row.py index c580b9ea9..4b638417b 100644 --- a/adapters/local/harnesses/cursor/test_row.py +++ b/adapters/local/harnesses/cursor/test_row.py @@ -1,10 +1,13 @@ #!/usr/bin/env python3 -import json, os, subprocess, sys +import json, os, subprocess, sys, tempfile sys.dont_write_bytecode = True HERE = os.path.dirname(os.path.abspath(__file__)) +LOCAL = os.path.join(HERE, '..', '..') +FIXTURES = os.path.join(LOCAL, 'fixtures') +DRIVER = os.path.join(LOCAL, 'driver') FAKE = os.path.join(HERE, 'fake') -ENV = dict(os.environ, FAKE_CLI_LIB=os.path.join(HERE, '..', '..', 'fixtures'), FAKE_CLI_SIGNED_OUT='1') +ENV = dict(os.environ, FAKE_CLI_LIB=FIXTURES, FAKE_CLI_SIGNED_OUT='1') START = 'Build the ticket: example/site#7, with the build-ticket skill. Keep one status note there.' WAKE = 'You were woken: take up example/site#7 again, with the build-ticket skill. Edit your own status note there.' SID = '00000000-0000-4000-8000-000000000000' @@ -17,6 +20,16 @@ 'synthetic-1', START]), (2, 'a --sandbox outside its choices', PRINT + ['--sandbox', 'on', START]), (2, 'a --mode outside its choices', PRINT + ['--mode', 'agent', START]), + (2, 'a --header without a colon', PRINT + ['--header', 'missing-colon', START]), + (2, 'a -H without a colon', PRINT + ['-H', 'missing-colon', START]), + (2, 'a --header= without a colon', PRINT + ['--header=missing-colon', START]), + (2, 'a --header with an empty name', PRINT + ['--header', ': value', START]), + (2, 'a --header with a blank name', PRINT + ['--header', ' : value', START]), + (2, 'a --header with whitespace in the name', PRINT + ['--header', 'Bad Name: value', START]), + (2, 'a bad second --header after a valid one', PRINT + ['--header', 'X-Test: ok', '--header', 'missing-colon', + START]), + (2, 'a bad first --header before a valid one', PRINT + ['--header', 'missing-colon', '--header', 'X-Test: ok', + START]), (2, '--stream-partial-output without stream-json', ['--print', '--output-format', 'json', '--trust', '--stream-partial-output', '--model', 'synthetic-1', START]), (2, '--resume with --continue', PRINT + ['--resume', SID, '--continue', WAKE]), @@ -37,9 +50,12 @@ def run(args): return p.returncode, p.stdout -def row_lines(): +def load_row(): with open(os.path.join(HERE, 'row.json')) as f: - row = json.load(f) + return json.load(f) + + +def row_lines(row): for mode, extra in row['modes'].items(): for field, text in (('start', START), ('wake', WAKE)): fills = {'{prompt}': [text], '{model}': ['synthetic-1'], '{session}': [SID], '{mode}': extra, @@ -47,13 +63,55 @@ def row_lines(): yield '%s with mode %s' % (field, mode), [b for a in row[field] for b in fills.get(a, [a])] +def refuses_allowlist(): + with tempfile.TemporaryDirectory(prefix='cursor-allowlist-') as tmp: + bin_dir, state = os.path.join(tmp, 'bin'), os.path.join(tmp, 'state') + repo = os.path.join(tmp, 'repos', 'example', 'site', 'docs', 'agents') + for d in (bin_dir, state, repo): + os.makedirs(d, mode=0o700) + os.symlink(FAKE, os.path.join(bin_dir, 'agent')) + os.symlink(os.path.join(FIXTURES, 'gh'), os.path.join(bin_dir, 'gh')) + with open(os.path.join(repo, 'fleet.md'), 'w') as f: + f.write('# Fleet\n\n| Setting | Value |\n| --- | --- |\n| Harness permission mode | `allowlist` |\n') + with open(os.open(os.path.join(state, 'approvals.json'), os.O_WRONLY | os.O_CREAT, 0o600), 'w') as f: + json.dump({'example/site': {'cursor': 'allowlist'}}, f) + record = os.path.join(tmp, 'rec') + env = dict(os.environ, PATH=os.pathsep.join([bin_dir, os.environ.get('PATH', '')]), + OPENWIZ_LOCAL_STATE=state, OPENWIZ_LOCAL_SETTLE='1', + FAKE_REPOS=os.path.join(tmp, 'repos'), FAKE_CLI_LIB=FIXTURES, + FAKE_CLI_RECORD=record, FAKE_CLI_RECORD_ONLY='1', PYTHONDONTWRITEBYTECODE='1') + req = {'repository': 'example/site', 'ticket': 7, 'skill': 'build-ticket', + 'harness': 'cursor', 'model': 'synthetic-1'} + p = subprocess.run([sys.executable, '-I', DRIVER, 'start'], input=json.dumps(req), + env=env, capture_output=True, text=True, timeout=30) + try: + out = json.loads(p.stdout) + except ValueError: + out = {} + if p.returncode == 0 and 'run' in out: + subprocess.run([sys.executable, '-I', DRIVER, 'stop'], input=json.dumps(out), + env=env, capture_output=True, text=True, timeout=30) + return p.returncode == 1 and 'not one its row lists' in out.get('error', '') and not os.path.exists(record) + + def main(): failed = 0 for want, what, args in CASES: got = run(args)[0] print('%s %s: exit %d' % ('pass' if got == want else 'fail', what, got)) failed += got != want - for what, args in row_lines(): + code, out = run(PRINT + ['--force', '--header', 'X-Test: ok', '-H', 'X-Two: a:b', START]) + ok = code == 1 and "Please run 'agent login'" in out + print('%s valid --header and -H reach the turn: exit %d' % ('pass' if ok else 'fail', code)) + failed += not ok + row = load_row() + ok = row['modes'] == {'force': ['--force']} + print('%s row.json requires explicit force mode: %s' % ('pass' if ok else 'fail', ', '.join(row['modes']))) + failed += not ok + ok = refuses_allowlist() + print('%s driver refuses allowlist approval: %s' % ('pass' if ok else 'fail', 'refused' if ok else 'accepted')) + failed += not ok + for what, args in row_lines(row): code, out = run(args) ok = code == 1 and "Please run 'agent login'" in out print('%s the row\'s %s reaches the turn: exit %d' % ('pass' if ok else 'fail', what, code))