Repository navigation
fix(#1100): finish #1071 — keep JSONC comments on the run.agent update, test the blank-file branch, drop two non-discriminating assertions - #1102
Merged
admarble merged 4 commits intoSep 19, 2026
Conversation
Entire-Checkpoint: 11d4af5c5dad
Entire-Checkpoint: 3eca27aeaa20
…omment-only run blocks
QA reproduced three inputs for which updateAgentInRawContent wrote a file the settings loader rejects: an empty run block, a whitespace-only run block and a comment-only run block all got a trailing comma after the inserted agent line, and a // comment quoting "run": { could capture the bare-regex key lookup. The run and agent keys are now located by a string- and comment-aware scan at the right object depth, the insert path omits the comma when the block has no members, and an empty block is edited on its one line. The AC-1 case now strips via the exported stripJsoncComments as AC-5's evidence clause states, and the four shapes are cases of their own.
Entire-Checkpoint: e434964affc8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
init --agent <name>on a tuned repo no longer strips JSONC comments from.sequant/settings.json. The update path used to round-trip throughJSON.stringify(merged, null, 2), silently dropping every//commentinit --yeshad generated."run": {...}block via a string- and comment-aware brace scan (reusing the in-string/escaped character scanstripJsoncCommentsalready uses) and replaces or inserts only the"agent"line in place — every other byte, comments included, is untouched.AC Verification
init --agent codexover existing JSONC preserves comments, recordsrun.agent1100 AC-1test passes; mutation-verified belowrun.agentline1100 AC-2test passes (LCS-based line diff = 1 changed/inserted line)created1100 AC-3test passes; mutation-verified belowonDiskassertions removedsed -n '960,975p' src/commands/init.test.ts | grep -c "onDisk"prints0JSON.parseyieldsrun.agent === "codex",run.timeout === 5400)Manual end-to-end repro (AC-6)
Mutation verification
Mutation-verified: AC-1 — reverted the write to
JSON.stringify(merged, null, 2);1100 AC-1: preserves JSONC comments on the run.agent updatefailed; restored.Mutation-verified: AC-3 — deleted the
!content.trim()blank-file branch;1100 AC-3: a blank settings file gets defaults with run.agent set, action createdfailed; restored.Test plan
npx vitest run src/commands/init.test.ts -t "1100"— 3 passednpx vitest run src/commands/init.test.ts— 49 passed (full file, no regressions)npm run build— passesnpm run lint— passesCloses #1100
Runner fix after the second AC_NOT_MET (82574ea, 2026-09-19)
QA twice reproduced three
run-block shapes for whichupdateAgentInRawContentwrote a filestripJsoncComments+JSON.parserejects, and the second exec pass made no commit against that finding, so the runner applied the fix directly:runandagentare located by a string- and comment-aware scan at the correct object depth (findValueStartOfKey), replacing the bare regexes. A//comment quoting"run": {, a string value equal to the key, or a nested object with arunkey can no longer capture the edit."run": {}is edited on its one line so AC-2's single-changed-line property holds.1100 AC-1case now strips via the exportedstripJsoncComments, as AC-5's evidence clause states, and four new1100 AC-5cases cover the empty, whitespace-only, comment-only and comment-quoting shapes, each asserting the written content re-parses and that exactly one line changed.End-to-end against this worktree's
dist/bin/cli.js,init --agent codex --yesover each shape, then the written file through the loader's comment stripper +JSON.parse:"run": {}run.agent = codex"run": { }run.agent = codexrunblockrun.agent = codex//comment quoting"run": {before the real blockrun.agent = codex, comment line untouchednpx vitest run src/commands/init.test.ts -t "1100"→Tests 7 passed; whole file 53 passed;npm run buildandnpm run lint --max-warnings 0clean.Full suite — runner result (2026-09-19,
82574eae)Run once in this worktree, foreground, from a shell with no
SEQUANT_*variables:Test Files 321 passed (321),Tests 6515 passed | 1 expected fail | 3 skipped, 349s, exit 0. The 8 failures QA saw earlier were theSEQUANT_*env-leak class (#1086) from running under the orchestrator, not this diff.