fix(3584): address coderabbit findings on PR #3606
CodeRabbit surfaced one outstanding inline finding plus an outside-diff finding and a finer point on two already-remediated sites; all addressed: 1. (inline, Minor) runtime-slash.cjs:31 — a degenerate input like `/gsd:`, `gsd:`, or `gsd-` normalizes to empty and the previous fallback returned the original colon-form input, reintroducing the deprecated shape the module exists to suppress. Now returns `''` (empty string) so callers see "no command" instead of an unroutable string. Also catches whitespace-only inputs the same way. New unit tests pin the contract. 2. (inline, Major) drift.cjs library purity — the earlier remediation passed `projectDir` into `detectDrift` and re-resolved runtime inside the library. CodeRabbit (correctly) flagged this as breaking the module's pure-library contract. detectDrift now accepts `input.runtime` directly; verify.cmdVerifyCodebaseDrift resolves the runtime once and passes the literal name in. drift.cjs no longer reads env or config at all. 3. (duplicate inline, Minor) gsd2-import.cjs:475 — when `gsd2-import --path <dir>` targets a project that isn't the process cwd, the preview command was formatted for the wrong runtime. buildPreview now receives the resolved `projectDir` (the same one used to find the .gsd/ root) instead of the raw `cwd`. 4. (outside-diff, Minor) tests/copilot-install.test.cjs:1-5 — the `allow-test-rule: integration-test-input` rationale block specifically named verify.cjs as the fixture, but #3584 changed that test to use a synthetic input. Comment now describes the real shape of the file's readFileSync usage (commands/, agents/, install.js source inputs to the installer/converter functions under test) and notes the synthetic substitution for the bin/lib path. Full suite: 9366/9366 pass (+1 new test). Lint clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -116,6 +116,9 @@ function isPathMapped(file, structureMd) {
|
||||
* @param {string|null|undefined} input.structureMd - contents of STRUCTURE.md
|
||||
* @param {number} [input.threshold=3] - min number of drift elements that triggers action
|
||||
* @param {'warn'|'auto-remap'} [input.action='warn']
|
||||
* @param {string} [input.runtime='claude'] - runtime name (claude, codex, ...) used
|
||||
* to format the slash-command in the remediation message. Caller resolves and
|
||||
* passes this in to keep drift.cjs a pure library with no env/config reads.
|
||||
* @returns {object} result
|
||||
*/
|
||||
function detectDrift(input) {
|
||||
@@ -190,7 +193,7 @@ function detectDrift(input) {
|
||||
if (action === 'auto-remap') {
|
||||
spawnMapper = true;
|
||||
}
|
||||
message = buildMessage(elements, affectedPaths, action, input.projectDir);
|
||||
message = buildMessage(elements, affectedPaths, action, input.runtime);
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -228,7 +231,7 @@ function skipped(reason) {
|
||||
};
|
||||
}
|
||||
|
||||
function buildMessage(elements, affectedPaths, action, projectDir) {
|
||||
function buildMessage(elements, affectedPaths, action, runtime) {
|
||||
const byCat = {};
|
||||
for (const e of elements) {
|
||||
(byCat[e.category] ||= []).push(e.path);
|
||||
@@ -253,8 +256,12 @@ function buildMessage(elements, affectedPaths, action, projectDir) {
|
||||
if (action === 'auto-remap') {
|
||||
lines.push(`Auto-remap scheduled for paths: ${affectedPaths.join(', ')}`);
|
||||
} else {
|
||||
const { formatGsdSlash, resolveRuntime } = require('./runtime-slash.cjs');
|
||||
const mapCmd = formatGsdSlash('map-codebase', resolveRuntime(projectDir));
|
||||
// drift.cjs is a pure library — it must never read env/config. The
|
||||
// caller (verify.cmdVerifyCodebaseDrift) resolves the runtime once and
|
||||
// passes it in via input.runtime so emitted commands match the project
|
||||
// the caller is targeting, not the current process directory.
|
||||
const { formatGsdSlash } = require('./runtime-slash.cjs');
|
||||
const mapCmd = formatGsdSlash('map-codebase', runtime || 'claude');
|
||||
lines.push(
|
||||
`Run ${mapCmd} --paths ${affectedPaths.join(',')} to refresh planning context.`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user