Skip to content

fix: correct MCP setup and command result messages - #287

Merged
SebTardif merged 25 commits into
mainfrom
fix/improve-mpi-20261004-s2212
Oct 5, 2026
Merged

SebTardif merged 25 commits into
mainfrom
fix/improve-mpi-20261004-s2212

Conversation

@SebTardif

@SebTardif SebTardif commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Configure MCP can write the portable workspace .mcp.json (mcpServers, type: stdio) and still writes only the targets you pick. An existing config is edited in place, so comments and trailing commas stay. A file that cannot be read is left alone. If a later target fails, the message names the targets already saved.
  • Path checks compare real paths, so a symlink prefix does not reject a file inside the workspace. An outside patch is copied into the workspace before apply or merge, and containment stays on.
  • The Windows managed install accepts patchloom.exe at the zip root as well as in the nested folder.
  • Quick Action and Batch Apply messages follow the CLI result. A missing heading, fragment anchor, insert anchor, or structured key is shown as the CLI error. A patch that writes nothing is a warning. Search no longer says every file contains the pattern when no file lacks it. A doc.update that matched nothing does not suggest Update again. Batch Apply reports a rename, a replace that matched nothing, and a delete that removed nothing, and it does not count # comment lines. The batch template uses file.prepend instead of --insert-after.
  • The path-filter job has a timeout. Status text matches the status bar item. A failed command opens the output channel.

Why

Several commands reported success, "no changes", or a completed count when the CLI had refused the write, missed the anchor, or changed a different count. MCP setup could also drop comments from an existing file or hide a partial write.

Verification

  • npm run check on 75521c1: 477 passed, line coverage 92.85%, vsce package succeeded.
  • GitHub CI on that commit is green (22 checks succeeded; Auto-merge Dependabot PRs and release-please-check skipped).
  • Live CLI 0.37 checks for the toast cases above: missing targets exit non-zero or report applied: false, and the extension message matches that result.

Checklist

  • All commits in this pull request are signed off with git commit -s
  • I ran npm run check and it passes
  • I updated docs if user-facing behavior changed
  • I am contributing this work under the repository license (MIT)

The status tests used /configured/, which also matches "not configured",
so a configured editor shown as not configured still passed. The
JSON-RPC skip test accepted any success object, including a decoy
line with no jsonrpc field.

Probe: the old regex matches "not configured". npm run check passed
449 tests, 92.58% line coverage, and vsce package.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
Configure MCP treated every read error as a missing file, parsed that
as an empty object, and wrote a patchloom-only config. A missing file
is still created. Any other read error now fails the command before
write. Status inspection still ignores read errors so the status bar
can render. The README states the same contract.

npm run check: 451 passed, line coverage 92.58%.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
The changes job in ci.yml was the only workflow job without
timeout-minutes. It runs dorny/paths-filter on pull requests.
Five minutes matches the other short jobs.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
VS Code's Add Server flow prefers a workspace-root .mcp.json
file with mcpServers, and the Agent Host reads that file directly.
Configure MCP can write that target, including type stdio, and
leaves .vscode/mcp.json alone unless that older target is selected.

Sibling servers in an existing .mcp.json stay. A second configure
of the same entry does not rewrite the file.

npm run check: 452 passed, line coverage 92.62%.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
github-actions[bot]
github-actions Bot previously approved these changes Oct 5, 2026
The configured state is "$(plug) Patchloom" plus the detected
version when known. The ready-without-MCP state is "$(check) Patchloom"
plus that version. A missing or old CLI stays "$(warning) Patchloom".

npm run check: 452 passed, line coverage 92.65%.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
github-actions[bot]
github-actions Bot previously approved these changes Oct 5, 2026
Configure MCP followed a symlink at .mcp.json or .vscode and could
replace a file outside the folder. Status refresh read that same path
on activation. Both paths now use the realpath check quick actions
already use. A Windsurf directory that does not exist yet is still
created. A symlink to an outside file is not read and is not written.

npm run check: 453 passed, line coverage 92.55%.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
github-actions[bot]
github-actions Bot previously approved these changes Oct 5, 2026
On macOS, /var and /tmp are symlinks to /private. A Quick Action or
Create could treat a file inside the folder as outside when the
workspace URI and the file path used different prefixes. The relative
path now falls back to the real directory only when that real path
stays inside the workspace.

npm run check: 454 passed, line coverage 92.56%.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
github-actions[bot]
github-actions Bot previously approved these changes Oct 5, 2026
Quick actions asked to save a dirty file only when the editor path
and the workspace path were the same string. On macOS those strings
differ for /var and /private/var, so a typed path skipped the save
prompt and the later apply could overwrite unsaved edits. Path
identity now uses realpath.

npm run check: 455 passed, line coverage 92.59%.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
github-actions[bot]
github-actions Bot previously approved these changes Oct 5, 2026

function normalizeRealFilePath(value: string): string {
const resolved = path.resolve(value);
let normalized = resolved;
Create, doc get, doc keys, doc len, and undo returned on a non-zero
exit before writing the CLI streams. Initialize, Configure MCP, Verify
MCP, and managed install or update failures left the text in a toast
or an unopened channel. With tracing off, the full error was easy to
miss. Those failures now open the Patchloom output channel.

npm run check: 455 passed, line coverage 92.53%.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
github-actions[bot]
github-actions Bot previously approved these changes Oct 5, 2026
Configure MCP parsed mcp.json and wrote it back with JSON.stringify.
A comment or a trailing comma in .vscode/mcp.json disappeared the first
time the patchloom server was added, and a matching entry was rewritten
when its keys were in a different order. Existing files are now edited
in place. A servers value that is not an object is left unchanged.

npm run check: 457 passed, line coverage 92.56%.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
github-actions[bot]
github-actions Bot previously approved these changes Oct 5, 2026
patchloom batch skips blank lines and lines whose first
non-whitespace character is #. Batch Apply counted those
lines, so a comment-only plan still reported that operations
were applied, and a commented plan over-counted. The count
now matches the CLI, and a comment-only plan is refused
before the command runs.

npm run check: 458 passed, line coverage 92.55%.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
The README said patch apply and patch merge skip containment
when the patch file is outside the workspace. Those commands
copy that file into the workspace and still pass --contain.

npm run check: 458 passed, line coverage 92.57%.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
github-actions[bot]
github-actions Bot previously approved these changes Oct 5, 2026
Quick Action preview treated exit 3 as "No changes to preview" for every command except doc update and delete-where. patchloom 0.37 uses exit 3 when an md section command cannot find the heading, so a typo looked like a no-op. Those previews now show the CLI error.

npm run check: 459 passed, line coverage 92.56%.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
Set structured value asked for servers[port>8000]. patchloom 0.37 rejects that selector on doc set (exit 1, file unchanged) and accepts it on doc update and doc get. The set box now asks for a concrete path. The compare example stays on Update matching structured values and on Read structured value.

npm run check: 460 passed, line coverage 92.57%.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
Quick Action preview treated exit 3 as "No changes to preview" for doc append, prepend, merge, and move. patchloom 0.37 uses that exit when the key is missing, so a bad path looked like a no-op. Those previews now show the CLI error. Delete of an absent key still exits 0, and text replace still treats exit 3 as no matches.

npm run check: 461 passed, line coverage 92.58%.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
The default Batch Apply plan used replace PATH "anchor_line" --insert-after="...". patchloom 0.37 does not treat --insert-after as a batch flag, so that token becomes the new text and the matched line is replaced. The plan now uses file.prepend, which inserts a line. The other eleven template lines still apply on a matching tree.

npm run check: 461 passed, line coverage 92.60%.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
github-actions[bot]
github-actions Bot previously approved these changes Oct 5, 2026
The 0.37.0 Windows zip extracts patchloom.exe at the archive root.
Unix archives still nest the binary under patchloom-<triple>/.
Managed install only looked in the nested directory, so Windows
install tried to promote a binary that was never moved.

Look in the nested path, then the archive root. When neither copy
is present, report an extract failure instead of a replace failure.

npm run check: 463 passed, line coverage 92.67%, vsce package succeeded.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
Configure MCP wrote earlier config files, then a later target whose
server map was not an object threw. The toast only said the command
failed, so a saved VS Code config looked unchanged. The error now
keeps the completed results, and the message says how many targets
were updated before the stop.

npm run check: 464 passed, line coverage 92.75%, vsce package.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
github-actions[bot]
github-actions Bot previously approved these changes Oct 5, 2026
Batch Apply counted every plan line as applied when patchloom exited 0.
CLI 0.37 keeps earlier writes when another replace matches nothing and
records that on the JSON refused list, or as match_count 0 when the
miss is on a file the plan also wrote. The command now requests --json
and the toast names those refused operations.

Live probe: doc.set plus a missing replace exited 0 and the message
named b.txt (no matches). npm run check: 468 passed, line coverage
92.79%, vsce package.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
CLI 0.37 exits 0 when doc.delete does not remove a key, including when
an earlier doc.set in the same plan already wrote. The JSON records
mutations[].changed false and omits refused. The completion message
now names that operation.

Live probe: doc.set plus doc.delete of a missing key exited 0 and the
message named d.json (doc.delete changed nothing). npm run check: 470
passed, line coverage 92.82%, vsce package.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
github-actions[bot]
github-actions Bot previously approved these changes Oct 5, 2026
patch apply and patch merge exit 0 with applied set to false when every hunk is already present. Quick Actions now request JSON and show a warning instead of a success toast. A patch that writes a file still reports success.

npm run check: 472 passed, line coverage 92.83%.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
Search files without a match exits 3 when the list is empty. An empty folder and a glob that matches nothing use that same exit, so the Quick Action no longer says every scanned file contains the pattern.

npm run check: 473 passed, line coverage 92.83%.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
A doc.update that matches nothing names itself in the error. The Quick Action toast treated that name as a suggestion to run the same action. A real "Use: doc update" hint still points at the Update action.

npm run check: 475 passed, line coverage 92.83%.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
apply-fragment and insert-before or insert-after exit 3 when the anchor is not in the file. Preview treated that like a text replace with nothing to change. Those misses now show the CLI error.

npm run check: 476 passed, line coverage 92.86%.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
github-actions[bot]
github-actions Bot previously approved these changes Oct 5, 2026
A rename-only batch plan exits 0 with files_changed 0 and files_renamed 1. The toast said no files changed. It now counts renames.

npm run check: 477 passed, line coverage 92.85%.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
@SebTardif SebTardif changed the title fix: protect MCP configs and add the portable target fix: correct MCP setup and command result messages Oct 5, 2026
@SebTardif
SebTardif marked this pull request as ready for review October 5, 2026 22:56
@SebTardif
SebTardif merged commit 463a4fc into main Oct 5, 2026
25 checks passed
@SebTardif
SebTardif deleted the fix/improve-mpi-20261004-s2212 branch October 5, 2026 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant