Repository navigation
field insert add: a pinned insert with a chooser (add-insert.md) - #155
Conversation
Adding an insert was a hand edit guessing at plugin names, with an unpinned window for check to close and chain order decided by cursor position. field insert add <track> [plugin] writes the entry already pinned — identity, version, nonzero latency from the scan, through the same comment-preserving Document machinery the pinner uses, via a resolvePluginName helper extracted from pinProject so there is one resolver and one disclosure. Unnamed plugins get an incremental- search chooser over the inventory (recents first, format tokens match, colliding rows grow the identifier, versionless rows carry the pinner's refusal); populated chains get an order chooser with --at as the scriptable spelling; a repeated plugin prompts ids for the whole identity group, disclosing the incumbent backfill, and refuses without a TTY. The picker is a hand-rolled raw-mode loop kept deliberately disposable — a full TUI is its own future stack decision. The command ends by printing the field open line it will run once editor sessions land (plugin-hosting.md chunk 3). The plan flips Active, answering §7: track addressing is bare-name- while-unique with qualified spellings in the collision refusal, and the built-ins question is scoped — the chooser lists scanned plugins only, with the rows-versus-wrappers discussion recorded on later.md where uncommitted ideas belong.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c1f9e80. Configure here.
There was a problem hiding this comment.
💡 Codex Review
https://github.com/okamnesiac/field/blob/c1f9e800ddf99c51fb7bb3d47fbd922a31ed515d/src/commands/insert.ts#L301
Avoid double-counting the inserted item
When the track already has an inserts sequence, chain aliases existing.items, so the preceding splice has already increased chain.length. Adding one again here makes the confirmation report, for example, position 2/3 after growing a one-item chain to two items.
https://github.com/okamnesiac/field/blob/c1f9e800ddf99c51fb7bb3d47fbd922a31ed515d/src/commands/insert.ts#L277
Reject duplicate IDs across the whole chain
When --id matches an ID belonging to a different plugin identity, sameIdentity is empty and this duplicate check is skipped. The command consequently writes the duplicate even though validate checks insert IDs across every hosted insert in the track and will make the resulting project fail field check; validate newId against incumbentIds regardless of whether this plugin is repeated.
https://github.com/okamnesiac/field/blob/c1f9e800ddf99c51fb7bb3d47fbd922a31ed515d/src/commands/insert.ts#L72
Escape the NUL separators in source
These template literals contain literal NUL bytes rather than escaped separators such as \0. Git therefore classifies the entire TypeScript file as binary (git show reports Bin 0 -> 11962 bytes), hiding normal line diffs and preventing ordinary text conflict resolution for future edits even though the runtime key only needs the escaped character.
https://github.com/okamnesiac/field/blob/c1f9e800ddf99c51fb7bb3d47fbd922a31ed515d/src/commands/insert.ts#L245
Resolve unpinned incumbents before checking identity
If the track already contains an unpinned - plugin: Verbatron and this command adds the same scanned plugin, identityOf returns name:Verbatron for the incumbent while the selected plugin is compared by its concrete identifier. The duplicate is therefore written without prompting for either ID; the next field check pins the incumbent and immediately rejects the chain this command produced. Resolve name-only incumbents through the inventory before forming the identity group.
AGENTS.md reference: AGENTS.md:L5-L7
https://github.com/okamnesiac/field/blob/c1f9e800ddf99c51fb7bb3d47fbd922a31ed515d/src/commands/insert.ts#L282
Reject an empty command-line ID before writing
Passing --id "" sets newId to a defined empty string, so neither the duplicate-flow prompt nor any other validation rejects it, and the insert is written with id: "". The hosted-insert schema requires IDs to contain at least one character, making the newly written track fail the next field check; validate the option before constructing the insert.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Bugbot on #155: choosePosition marked the end row "(default)" while runPicker hardwired the cursor to 0, so bare Enter — the most common gesture — placed the insert before the first existing entry, diverging from the label, the plan, and the silent non-TTY default. The initial cursor now lives in the pure layer (initialState: the named row when selectable, else forward then backward by navigation's own skip rule, clamped in range), runPicker takes it as a parameter, and the position chooser passes its defaultIndex. The regression test drives Enter from the initial state and fails against the hardwired cursor on exactly the wrong-row selection.
minjudd
left a comment
There was a problem hiding this comment.
Reviewed c1f9e80 in a scratch worktree. pnpm typecheck clean; pnpm test with FIELD_AUDIOD pointed at a prebuilt daemon → 44 files passed / 1 skipped, 683 passed / 1 skipped of 684.
The readiness gate is satisfied, and I checked it against the whole plan rather than the diff. This PR flips add-insert.md from Draft to Active, which is the moment the plan asserts it can be executed from, so it answers for every question open at that moment and not only the ones it touches. Both are answered: track addressing gets a (DECIDED, 2026-08-12) rule in §2 that the code implements — bare name while unique, <song>/<track> on collision, with the refusal listing the qualified spellings — and the built-ins question is scoped for this plan while the (a)-versus-(b) discussion moves to later.md as its own line. Scoping is a legitimate disposition rather than a dodge here, because the plan stops carrying the question and the place it moves to is where uncommitted ideas belong. The lists move in the same diff, next.md back to "Nothing committed yet." and now.md gaining a line that names its own removal condition.
The resolvePluginName extraction is faithful. Same filter, same platform preference, same two problem strings — the pinner's behaviour is unchanged, which is what makes it a safe refactor to carry in a feature PR.
Two findings — a P1 and a P2 — are on src/commands/insert.ts as file-level threads, posted just above this review rather than inside it. That is not a stylistic choice: GitHub rejected the review twice, first 422 Line could not be resolved for a line thread on that file, then Field is not defined on DraftPullRequestReviewComment for a file-level one inside a review. A binary file has no line positions, so the review API cannot carry a thread on it at all. The first finding is that the file is binary, so it spent two attempts demonstrating itself before it could be reported.
One note that blocks nothing: runPicker restores raw mode in finish, and decodeKeys deliberately turns ctrl-c into a cancel with a comment explaining that a SIGINT would skip that restore — the right call, and it covers the realistic path. What it does not cover is an abnormal exit or a throw inside the data handler (a write to a closed stdout, say), which leaves the terminal in raw mode with no echo. A try/finally around the promise would close it, and the module is small enough for that to stay cheap.
|
Starting review of eaa6462. |
minjudd on #155: four literal NUL bytes made insert.ts binary — git diffstats it as Bin, GitHub cannot render or anchor review threads on it, and every rg over the tree silently skips the file while reporting success (the exact accident #154 §1.1 spent two rounds on, landed in source). \0 compiles to the identical string and the file stays text. Swept src/ for other NUL carriers byte-wise: none.
minjudd
left a comment
There was a problem hiding this comment.
Reviewed eaa6462. Typecheck clean; full suite 44 files passed / 1 skipped, 684 passed / 1 skipped of 685.
The delta is a good fix for a real bug. At c1f9e80 choosePosition received defaultIndex and spent it only on the (default) suffix in the label — runPicker took no cursor argument and started at 0 — so bare Enter placed the insert before the first one while the row it was reading said the end was the default. Worse, that silently disagreed with the non-TTY path, which appends. Bugbot found it and the fix is the right shape: the cursor rule moves into initialState in the pure, tested layer rather than being computed in the terminal shell.
The fallback logic is right in the case that is easy to get wrong. A disabled default falls forward first and then backward from the end of the list, which lands on the nearest selectable row below the requested one rather than snapping to the top, and an out-of-range index clamps. I checked the empty-list case too, since Math.max(items.length - 1, 0) makes the clamp look suspicious there: from is 0, both searches return -1, the cursor ends at 0, and enter on an empty filtered list is already guarded by the item === undefined check — no crash, nothing selected. The three assertions added to picker.test.ts cover the default row, the disabled-default fall-back and the clamp.
This does not clear the three findings from c1f9e80, all of which I re-verified at this head rather than assuming. The diff touches cli.ts, picker.ts and picker.test.ts only:
src/commands/insert.tsstill contains 4 NUL bytes, so it is still binary and still absent from the reviewable diff — its two threads are the file-level ones above, and they are file-level precisely because of the finding they carry.identityOf(item) === plugin.identifieris unchanged at line 245, so an unpinned incumbent still escapes the duplicate check andfield insert addstill writes a file thatfield checkcomplains about.plugins.ts:63still openspinProject's comment directly aboveresolvePluginName.
The verdict stays REQUEST_CHANGES for those three rather than for anything in this push. Nothing here is churn — the order-chooser bug was worth its own commit, and finding it before a user did is the system working.
minjudd on #155, reproduced at c1f9e80: identityOf spells an unpinned instance name:<plugin>, but the duplicate filter compared only against the pinned identifier, so a hand-authored `- plugin: X` — the §1 flow this command shortcuts — slipped past the id prompts, and pinBeforeCheck then collapsed both entries into one identity group and fired the very diagnostic §2 promises the command prevents. The filter now matches both spellings; the regression test starts from an unpinned incumbent and fails against the identity-only match on the missing backfill.
minjudd on #155: the resolvePluginName extraction landed between pinProject's doc comment and pinProject, so the resolver inherited a preamble about idempotence and latency lines it does not have, and the pinner lost its own. The four older lines move down to the function they describe — the displacement only visible reading the file, not the hunk.
Codex on #155: the printed field open line discarded outcome.song, so an add that itself required closer/lead advertised field open lead/<handle> — ambiguous under the decided addressing grammar, and unable to identify the insert just added. The outcome now carries the canonical address, computed the way resolveTrack decides refusals: bare while the name is unique project-wide, qualified when it collides.
minjudd's non-blocking note on #155, taken because the module is small enough for it to stay cheap: finish() covered the selection and cancel paths, but a throw inside the data handler — a write to a closed stdout, say — escaped to the event emitter and left the terminal in raw mode with no echo. The handler now routes its throw into the promise, and the restore lives in a finally that every exit crosses.
|
minjudd's raw-mode note from the c1f9e80 review, taken in 49e8270 even though it blocked nothing: the data handler now routes a throw into the promise and the terminal restore lives in a finally every exit crosses — selection, cancel, and the abnormal path that used to leave raw mode on with no echo. The five commits since eaa6462 are one per finding, each named in its thread. |
minjudd
left a comment
There was a problem hiding this comment.
Approving 49e8270. Typecheck clean; full suite 44 files passed / 1 skipped, 685 passed / 1 skipped of 686. I re-ran each finding's own evidence against this head rather than reading the commit subjects.
P1 — fixed, and the check that matters is the diff, not the file. insert.ts now has zero NUL bytes, file calls it UTF-8 text rather than data, and rg -l 'resolvePluginName' src/ returns both files where it previously returned one. The one worth naming: git diff --stat af3e2ae..49e8270 -- src/commands/insert.ts is 322 insertions(+), not Bin. The 322 lines this PR is about are readable on GitHub now. Note that the incremental diff from the previous head still renders as Bin 11962 -> 12941 bytes, because the old blob is the binary one — that is git describing history, not a fix that did not take.
P2 — fixed, and my reproduction now produces the opposite result. Same probe, same commit under test: a track carrying one hand-authored unpinned - plugin: Verbatron, then addInsert for the same plugin with a counting askId hook.
askId called: 2 backfilled: ['h1'] handle: h2
name: lead
inserts:
- plugin: Verbatron
id: h1
- plugin: Verbatron
id: h2
vst3: aabbccdd
version: 2.1.0
diagnostics after pinBeforeCheck: []
Two prompts instead of zero, the incumbent's handle disclosed through backfilled rather than slipped in, and field check clean on the file the command just wrote. That last line is the whole of §2's promise, and it is the first time in this series it has actually held.
P3 — fixed. resolvePluginName keeps its own comment at 63-67 and pinProject's four lines are back at 92-95, directly above it.
The two fixes that were not mine are both right. Codex's is the sharper one: the printed handoff used outcome.track, so an add that itself required closer/lead advertised field open lead/<handle> — ambiguous under the addressing grammar this very PR decided, which is a good example of a decision creating an obligation two files away. outcome.address computes collision independently of how the ref was spelled, so a qualified ref for a non-colliding name still prints bare, which is the correct answer rather than an echo of the input. And the terminal-restore note came back as a try/finally that every exit crosses, with the data handler routing its throw into reject instead of the event emitter — the shape I had in mind, implemented more carefully than I described it.
On the whole change, across four heads: the readiness flip to Active answers both of the plan's open questions and the code implements the addressing rule it decided; the resolvePluginName extraction leaves the pinner's behaviour identical; and the picker's state machine is pure and tested with the terminal shell thin above it, which is what made the cursor bug, the raw-mode gap and the NUL separator each a small fix rather than a rewrite.
Four reviewers each found something the others did not on this one — Bugbot the order chooser's cursor, Codex the handoff's lost qualifier, me the binary file and the unpinned incumbent. Worth noting because the file I could not read is the file two of those bugs were in.
…s (windows-portability.md §7) (#158) Adds §7 to the [Windows portability plan](../blob/windows/inventory/docs/projects/windows-portability/readme.md): a swept inventory of every remaining Windows item, grouped by where it lands — the committed chunks, findings not yet in any chunk, the workers' own transport decision, and consumers that inherit the port rather than adding to it. Sections append at the end per the docs convention, so nothing renumbers. ## How it was gathered Every spawn site and path literal in `src/` (`grep` over `spawn|execFile|execSync` and absolute-path strings), the daemon sources, the Python workers, and the test surface — cross-checked against what chunks 1 and 2 actually hit when they ran, which is how the labels bug earned its §5 amendment and how three of the items below surfaced. Line citations are pinned to `main` at `4f90a87`. ## The finding worth reading first **`field init` plants chunk 1's defect in every new project** (`commands/init.ts:60`): the `.gitattributes` it writes carries only the seven LFS filter lines — no `* text=auto eol=lf`, no `*.state` override. A project created on or cloned to Windows gets the §1.1 checkout corruption against its own committed `.scd` programs and asset pins, and the engine repo's own fix cannot reach it. #159, open against `main`, makes `init` write both halves, and §7.2 names it. ## Also new - The `field insert add` picker (#155) decodes raw-mode CSI sequences that nobody has run under Windows Terminal/ConPTY — one manual pass needed. - `homeRelative` hardcodes `/` so tilde-shortening never fires on Windows; `defaultExportDir()` misses a OneDrive-redirected Desktop. Warts, not breaks. - `sclang`'s convenience fallback probes `/Applications/…`; PATH and `FIELD_SCLANG` already work everywhere. - The workers' Python end has no named-pipe socket family in CPython, and its `fcntl` import fails on Windows before the socket is reached, so their transport and single-owner lock are a decision of their own, not §2.1 verbatim. - The UI plan (#156) and the unlanded `field open` are consumers of this port, not additions to it — noted so their reviews ask the right question. §7.4 also states chunk 2's rule for separators: a project-relative path is slash-separated wherever it is data, and a path printed for a person keeps the platform's separator. ## Testing The change is one plan file, so the checks read it. Run these from the root of a checkout of `windows/inventory`. They need no build and change nothing in the tree. ```sh project check git diff origin/windows/gitattributes --stat git show 4f90a87:src/commands/init.ts | sed -n '55,72p' git show 4f90a87:python/worker/src/field_worker/server.py | grep -n '^import fcntl\|AF_UNIX' git show 4f90a87:src/workers/client.ts | grep -n 'brew install uv\|pkill -f' ``` `project check` prints `Project plans are valid.` The diff against the base touches only `docs/projects/windows-portability/readme.md`. The `init.ts` lines show the LFS-only `.gitattributes` §7.2 describes, at lines 60 and 71. The `server.py` grep prints line 23 (`import fcntl`) and line 129 (`AF_UNIX`), and the `client.ts` grep prints lines 122, 305, and 345, the citations §7.3 makes. The change is wrong if `project check` reports an error or if any of those greps prints a different line number than §7 cites. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- projector-summary v=1 sha=1283ef807c8d387b511a8114b3d62717bdf9bd81 --> 📽️ **Projector summary** of 1283ef8: https://field.amnes.ac/reviews/158 --------- Co-authored-by: Claude Fable 5 <[email protected]> Co-authored-by: Justin Balthrop <[email protected]>

Adding an insert was a hand edit guessing at plugin names, with an unpinned window for
field checkto close and chain order decided by cursor position.field insert add <track> [plugin]writes the entry already pinned — identity, version, nonzero latency from the scan, through the same comment-preservingDocumentmachinery the pinner uses, via aresolvePluginNamehelper extracted frompinProjectso there is one resolver and one disclosure. Unnamed plugins get an incremental-search chooser over the inventory: recents sort first (derived from identities already pinned in the project's files, no new state), search matches format tokens, rows that collide on name/format/version grow the identifier, and a versionless row carries the pinner's refusal on itself. Populated chains get an order chooser with positions named per insert, defaulting to the end;--at <position|end>is the scriptable spelling, and a non-TTY run with the plugin named appends silently. A repeated plugin prompts ids for the whole identity group — the duplicate check quantifies over every instance, so the incumbents are prompted too and the backfill is disclosed in the output — and refuses without a TTY (--idcovers the scriptable case once incumbents carry ids). The picker is a hand-rolled raw-mode loop kept deliberately disposable: a full TUI is eventually wanted and stays its own stack decision, which a prompts library adopted now would quietly pre-answer. The command ends by printing thefield openline it will run once editor sessions land (plugin-hosting.md chunk 3).The plan flips
Activein the same diff, answering §7 as the readiness rule requires: track addressing is bare-name-while-unique with the qualified<song>/<track>spellings listed in the collision refusal (a rulefield openshould adopt when chunk 3 builds it), and the built-ins question is scoped — this chooser lists scanned plugins only, with the rows-versus-wrappers discussion recorded onlater.md, where uncommitted ideas belong, and nothing here foreclosing either shape. The lists move in the same diff (next.md→now.md), and docs/tracks.md documents the command beside the hand-edit flow it shortcuts.Testing
From the repo root:
pnpm build, thenpnpm vitest run src/commands/picker.test.ts src/commands/insert.test.ts→ 18 tests (picker filtering/reduction/key-decoding; pinned write shape with hand-written comments preserved,--atplacement and its out-of-range refusal, recents-first chooser rows with versionless rows disabled, identity-group id prompting with disclosed backfill, the non-TTY refusals, and track-name collision handling). Full suite:pnpm test→ 43 files, 684 tests green.By hand, in a scratch project with a scanned inventory (or any project after
field plugins scan):field insert add <track> <plugin>writes the pinned entry andfield checkstays green — run it in a file carrying a hand-written comment and the comment survives, which is what the old serialize-from-scratch failure mode would have eaten.field insert add <track>with no plugin in a non-TTY shell refuses and names the exact command line (before this PR the command did not exist, so the wrong outcome is any hang or any unpinned write). The interactive chooser needs a real TTY:field insert add <track>, type a format token likeauplus a name fragment, arrow past a versionless row (the cursor skips it), enter — then check the file. Adding the same plugin twice interactively prompts for ids on both instances and says so;--idalone refuses until the existing instance carries one, naming plugin-hosting.md decision 6.Note
Medium Risk
Changes how track insert YAML is authored and touches plugin identity resolution shared with pinning; risk is moderate due to interactive TTY/raw-mode behavior and duplicate-instance id backfill editing existing lines.
Overview
Adds
field insert add <track> [plugin]so track YAML gets a fully pinned hosted insert (plugin,au/vst3,version, nonzerolatency) through the same comment-preserving YAML path as the pinner, instead of hand-editing and waiting onfield check.Interactive flow (TTY): incremental-search plugin picker over the scan inventory (recents-first, format tokens, disabled versionless rows, identifier disambiguation), order picker when the chain already has inserts, and id prompts when the same plugin would appear twice—including backfilling ids on existing instances with disclosed output. Scriptable spellings:
--at,--id,--au/--vst3; non-TTY runs refuse unnamed plugins and duplicate-id cases instead of hanging. Track refs resolve by bare name when unique, with<song>/<track>required on collision.Code structure:
resolvePluginNameis extracted frompinProjectfor one resolver/disclosure story; a small hand-rolledpickermodule powers the choosers. Success output notes the futurefield openhandoff until plugin-hosting chunk 3.Docs:
add-insert.mdgoes Active with §7 decisions; project lists move the work next → now;tracks.mddocuments the command; built-ins-in-chooser scope moves tolater.md.Reviewed by Cursor Bugbot for commit c1f9e80. Configure here.