Repository navigation
fix(setup): preserve initial backups and Codex comments #1204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ import { | |
| type ClientConfigurationDocument, | ||
| } from "./ClientConfigurationDocument.js"; | ||
| import { copyFile, lstat, readFile, realpath, rm } from "node:fs/promises"; | ||
| import { constants as fsConstants } from "node:fs"; | ||
| import { homedir } from "node:os"; | ||
| import { join } from "node:path"; | ||
|
|
||
|
|
@@ -31,6 +32,7 @@ interface ManagedPathStats { | |
| /** Injectable filesystem operations used to prove uninstall failure recovery. */ | ||
| export interface UninstallFileSystem { | ||
| readText(path: string): Promise<string>; | ||
| /** Preserve the first backup; reject an existing destination with EEXIST. */ | ||
| copy(source: string, destination: string): Promise<void>; | ||
| writeText(path: string, contents: string): Promise<void>; | ||
| stat(path: string): Promise<ManagedPathStats>; | ||
|
|
@@ -40,7 +42,8 @@ export interface UninstallFileSystem { | |
|
|
||
| const systemFileSystem: UninstallFileSystem = { | ||
| readText: (path) => readFile(path, "utf8"), | ||
| copy: (source, destination) => copyFile(source, destination), | ||
| copy: (source, destination) => | ||
| copyFile(source, destination, fsConstants.COPYFILE_EXCL), | ||
| writeText: (path, contents) => | ||
| writeFileAtomic(path, contents, { encoding: "utf8" }), | ||
| stat: (path) => lstat(path), | ||
|
|
@@ -274,12 +277,12 @@ const removeClient = async ( | |
| try { | ||
| await fileSystem.copy(transactionPath, backupPath); | ||
| } catch (cause: unknown) { | ||
| void cause; | ||
| return item( | ||
| client.name, | ||
| "failed", | ||
| "Configuration could not be backed up, so no change was made. Check file permissions, then rerun uninstall.", | ||
| ); | ||
| if (!(cause instanceof Error && "code" in cause && cause.code === "EEXIST")) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When setup has already created AGENTS.md reference: AGENTS.md:L7-L12 Useful? React with 👍 / 👎. |
||
| return item( | ||
| client.name, | ||
| "failed", | ||
| "Configuration could not be backed up, so no change was made. Check file permissions, then rerun uninstall.", | ||
| ); | ||
| } | ||
| try { | ||
| await fileSystem.writeText( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new preservation behavior only retains standalone
#lines. For a valid Codex entry such as[mcp_servers.rea] # local setup notesorcommand = "old" # explanation, the header and assignment branches discard the entire physical line, including the comment, during setup or uninstall. Retain the comment suffix before dropping those statements, or narrow this newly documented preservation guarantee.AGENTS.md reference: AGENTS.md:L53-L57
Useful? React with 👍 / 👎.