Files
msd-core/sdk/src/query/detect-custom-files.ts
Tom Boucher 57bbfe652b fix: exclude non-wiped dirs from custom-file scan; warn on non-Claude model profiles (#2511)
* fix(detect-custom-files): exclude skills and command dirs not wiped by installer (closes #2505)

GSD_MANAGED_DIRS included 'skills' and 'command' directories, but the
installer never wipes those paths. Users with third-party skills installed
(40+ files, none in GSD's manifest) had every skill flagged as a "custom
file" requiring backup, producing noisy false-positive reports on every
/gsd-update run.

Removes 'skills' and 'command' from both gsd-tools.cjs and the SDK's
detect-custom-files.ts. Adds two regression tests confirming neither
directory is scanned.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(settings): warn that model profiles are no-ops on non-Claude runtimes (closes #2506)

settings.md presented Quality/Balanced/Budget model profiles without any
indication that these tiers map to Claude models (Opus/Sonnet/Haiku) and
have no effect on non-Claude runtimes (Codex, Gemini CLI, OpenRouter).
Users on Codex saw the profile chooser as if it would meaningfully select
models, but all agents silently used the runtime default regardless.

Adds a non-Claude runtime note before the profile question (shown in
TEXT_MODE, the path all non-Claude runtimes take) explaining the profiles
are no-ops and directing users to either choose Inherit or configure
model_overrides manually. Also updates the Inherit option description to
explicitly name the runtimes where it is the correct choice.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 10:10:10 -04:00

96 lines
2.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Detect user-added files under GSD-managed install dirs not listed in the manifest.
*
* Port of `detect-custom-files` from `get-shit-done/bin/gsd-tools.cjs` (lines 1161–1239).
*/
import { existsSync, readdirSync, readFileSync } from 'node:fs';
import { join, relative, resolve } from 'node:path';
import type { QueryHandler } from './utils.js';
const GSD_MANAGED_DIRS = [
'get-shit-done',
'agents',
join('commands', 'gsd'),
'hooks',
];
function walkDir(dir: string, baseDir: string): string[] {
const results: string[] = [];
if (!existsSync(dir)) return results;
for (const entry of readdirSync(dir, { withFileTypes: true })) {
const fullPath = join(dir, entry.name);
if (entry.isDirectory()) {
results.push(...walkDir(fullPath, baseDir));
} else {
const relPath = relative(baseDir, fullPath).split('\\').join('/');
results.push(relPath);
}
}
return results;
}
/**
* Args: `--config-dir <path>` (required) — runtime config directory to scan.
*/
export const detectCustomFiles: QueryHandler = async (args) => {
const configDirIdx = args.indexOf('--config-dir');
const configDir = configDirIdx !== -1 ? args[configDirIdx + 1] : null;
if (!configDir) {
return { data: { error: 'Usage: detect-custom-files --config-dir <path>' } };
}
const resolvedConfigDir = resolve(configDir);
if (!existsSync(resolvedConfigDir)) {
return { data: { error: `Config directory not found: ${resolvedConfigDir}` } };
}
const manifestPath = join(resolvedConfigDir, 'gsd-file-manifest.json');
if (!existsSync(manifestPath)) {
return {
data: {
custom_files: [] as string[],
custom_count: 0,
manifest_found: false,
},
};
}
let manifest: { version?: string; files?: Record<string, unknown> };
try {
manifest = JSON.parse(readFileSync(manifestPath, 'utf8')) as { version?: string; files?: Record<string, unknown> };
} catch {
return {
data: {
custom_files: [] as string[],
custom_count: 0,
manifest_found: false,
error: 'manifest parse error',
},
};
}
const manifestKeys = new Set(Object.keys(manifest.files || {}));
const customFiles: string[] = [];
for (const managedDir of GSD_MANAGED_DIRS) {
const absDir = join(resolvedConfigDir, managedDir);
if (!existsSync(absDir)) continue;
for (const relPath of walkDir(absDir, resolvedConfigDir)) {
if (!manifestKeys.has(relPath)) {
customFiles.push(relPath);
}
}
}
return {
data: {
custom_files: customFiles,
custom_count: customFiles.length,
manifest_found: true,
manifest_version: manifest.version ?? null,
},
};
};