* fix(#2771): unify user-owned-artifacts list to suppress false patches warning USER-PROFILE.md was both preserved across reinstalls (correctly) AND tracked in gsd-file-manifest.json (incorrectly). On the next install, saveLocalPatches() hashed the on-disk file, found it differed from the stale manifest hash (because /gsd-profile-user --refresh regenerated it), and reported it as a "locally modified GSD file" — a spurious warning every time the profile refreshed. A file is either distribution (manifest-tracked, diff'd against manifest) or user artifact (preserved across installs, never diff'd). Never both. This extracts USER_OWNED_ARTIFACTS as a single source of truth, referenced by both the preserveUserArtifacts call site and writeManifest, so the invariant cannot drift again. Adds a regression test that exercises the full reproduction path: install, create USER-PROFILE.md, reinstall, refresh USER-PROFILE.md, reinstall, assert no patch backup and no warning text. Closes #2771 * test(#2771): use centralized helpers from helpers.cjs per CONTRIBUTING * fix(#2771): normalize legacy USER_OWNED_ARTIFACTS entries from manifest + tighten test
This commit is contained in:
@@ -4505,6 +4505,24 @@ function copyCommandsAsAntigravitySkills(srcDir, skillsDir, prefix, isGlobal = f
|
||||
recurse(srcDir, prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Single source of truth for user-owned artifacts inside get-shit-done/.
|
||||
*
|
||||
* These files are created/refreshed by user-facing workflows (e.g.
|
||||
* /gsd-profile-user) and must be preserved across reinstalls. Critically, they
|
||||
* MUST be excluded from gsd-file-manifest.json — otherwise saveLocalPatches()
|
||||
* will compare a refreshed file against a stale manifest hash and emit a
|
||||
* spurious "locally modified GSD file" warning (bug #2771).
|
||||
*
|
||||
* Invariant: a file is either distribution (manifest-tracked, diff'd against
|
||||
* manifest) or user artifact (preserved across installs, never diff'd). Never
|
||||
* both. Both preserveUserArtifacts call sites and writeManifest must agree on
|
||||
* this list, which is why it lives here as a single constant.
|
||||
*
|
||||
* Paths are relative to the get-shit-done/ directory.
|
||||
*/
|
||||
const USER_OWNED_ARTIFACTS = ['USER-PROFILE.md'];
|
||||
|
||||
/**
|
||||
* Save user-generated files from destDir to an in-memory map before a wipe.
|
||||
*
|
||||
@@ -5687,6 +5705,12 @@ function writeManifest(configDir, runtime = 'claude', options = {}) {
|
||||
|
||||
const gsdHashes = generateManifest(gsdDir);
|
||||
for (const [rel, hash] of Object.entries(gsdHashes)) {
|
||||
// Skip user-owned artifacts (e.g. USER-PROFILE.md). They are preserved
|
||||
// across reinstalls by preserveUserArtifacts and must NOT be hashed into
|
||||
// the manifest — otherwise saveLocalPatches() would flag every refresh
|
||||
// as a "local patch" (bug #2771). Single source of truth:
|
||||
// USER_OWNED_ARTIFACTS at top of file.
|
||||
if (USER_OWNED_ARTIFACTS.includes(rel)) continue;
|
||||
manifest.files['get-shit-done/' + rel] = hash;
|
||||
}
|
||||
if (isGemini && fs.existsSync(commandsDir)) {
|
||||
@@ -5756,6 +5780,14 @@ function saveLocalPatches(configDir) {
|
||||
let manifest;
|
||||
try { manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8')); } catch { return []; }
|
||||
|
||||
// Normalize legacy manifests written before #2771 fix: strip user-owned artifacts
|
||||
// that were incorrectly recorded so refreshes don't surface false patches warnings.
|
||||
if (manifest.files) {
|
||||
for (const artifact of USER_OWNED_ARTIFACTS) {
|
||||
delete manifest.files[`get-shit-done/${artifact}`];
|
||||
}
|
||||
}
|
||||
|
||||
const patchesDir = path.join(configDir, PATCHES_DIR_NAME);
|
||||
const pristineDir = path.join(configDir, 'gsd-pristine');
|
||||
const modified = [];
|
||||
@@ -6109,7 +6141,7 @@ function install(isGlobal, runtime = 'claude') {
|
||||
// Preserve user-generated files before the wipe-and-copy so they survive re-install
|
||||
const skillSrc = path.join(src, 'get-shit-done');
|
||||
const skillDest = path.join(targetDir, 'get-shit-done');
|
||||
const savedGsdArtifacts = preserveUserArtifacts(skillDest, ['USER-PROFILE.md']);
|
||||
const savedGsdArtifacts = preserveUserArtifacts(skillDest, USER_OWNED_ARTIFACTS);
|
||||
copyWithPathReplacement(skillSrc, skillDest, pathPrefix, runtime, false, isGlobal);
|
||||
restoreUserArtifacts(skillDest, savedGsdArtifacts);
|
||||
if (verifyInstalled(skillDest, 'get-shit-done')) {
|
||||
@@ -7532,6 +7564,7 @@ if (process.env.GSD_TEST_MODE) {
|
||||
validateHookFields,
|
||||
preserveUserArtifacts,
|
||||
restoreUserArtifacts,
|
||||
USER_OWNED_ARTIFACTS,
|
||||
finishInstall,
|
||||
homePathCoveredByRc,
|
||||
maybeSuggestPathExport,
|
||||
|
||||
Reference in New Issue
Block a user