Skip to content

Commit 4f56662

Browse files
author
Harald Kirschner
committed
fix: address PR review comments (#55)
- Always emit dry-run JSON even when files array is empty - Normalize all dry-run paths to repo-relative (consistent across --repo) - Surface nested generation warnings in dry-run mode - Guard config write-back against non-object JSON (arrays, primitives) - Add single-root runtime guard to batch instructions command
1 parent 1dfe2b8 commit 4f56662

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

src/commands/instructions.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ export async function instructionsCommand(options: InstructionsOptions): Promise
117117
}))
118118
);
119119
}
120+
for (const warning of nestedResult.warnings) {
121+
if (shouldLog(options)) progress.update(`Warning: ${warning}`);
122+
}
120123
} else {
121124
const actions = await writeNestedInstructions(repoPath, nestedResult, options.force);
122125
for (const action of actions) {
@@ -170,10 +173,11 @@ export async function instructionsCommand(options: InstructionsOptions): Promise
170173

171174
if (content) {
172175
if (options.dryRun) {
173-
const relPath = path.relative(process.cwd(), outputPath);
176+
const relPath = path.relative(repoPath, outputPath);
177+
const displayPath = path.relative(process.cwd(), outputPath);
174178
const byteCount = Buffer.byteLength(content, "utf8");
175179
if (shouldLog(options)) {
176-
progress.update(`[dry-run] Would write ${relPath} (${byteCount} bytes)`);
180+
progress.update(`[dry-run] Would write ${displayPath} (${byteCount} bytes)`);
177181
}
178182
if (options.json) {
179183
dryRunFiles.push({ path: relPath, bytes: byteCount });
@@ -348,7 +352,7 @@ export async function instructionsCommand(options: InstructionsOptions): Promise
348352
}
349353
if (options.json) {
350354
dryRunFiles.push({
351-
path: path.relative(process.cwd(), areaInstructionPath(repoPath, area)),
355+
path: path.relative(repoPath, areaInstructionPath(repoPath, area)),
352356
bytes: Buffer.byteLength(body, "utf8")
353357
});
354358
}
@@ -383,7 +387,7 @@ export async function instructionsCommand(options: InstructionsOptions): Promise
383387
}
384388
}
385389

386-
if (options.dryRun && options.json && dryRunFiles.length > 0) {
390+
if (options.dryRun && options.json) {
387391
outputResult(
388392
{ ok: true, status: "noop" as const, data: { dryRun: true, files: dryRunFiles } },
389393
true

vscode-extension/src/commands/batch.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ export async function batchInstructionsCommand(): Promise<void> {
99
vscode.window.showWarningMessage("AgentRC: No workspace folders open.");
1010
return;
1111
}
12+
if (folders.length === 1) {
13+
vscode.window.showInformationMessage(
14+
"AgentRC: Only one workspace root — use 'Generate Instructions' instead."
15+
);
16+
return;
17+
}
1218

1319
const model = vscode.workspace.getConfiguration("agentrc").get<string>("model");
1420

vscode-extension/src/commands/instructions.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ export async function instructionsCommand(): Promise<void> {
101101
let existing: Record<string, unknown> = {};
102102
try {
103103
const raw = await fs.promises.readFile(configPath, "utf-8");
104-
existing = JSON.parse(raw);
104+
const parsed: unknown = JSON.parse(raw);
105+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
106+
existing = parsed as Record<string, unknown>;
107+
}
105108
} catch (err: unknown) {
106109
if ((err as NodeJS.ErrnoException).code !== "ENOENT") {
107110
throw err; // Malformed JSON — bubble to outer non-fatal catch

0 commit comments

Comments
 (0)