Skip to content

Commit 674652e

Browse files
committed
fix(demo/ctx): include i18n.json in candidates and defer clearState until rewrite confirmed
Made-with: Cursor
1 parent e0b7403 commit 674652e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

demo/ctx/agent.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ async function run() {
8989
}
9090

9191
const agent = (system: string, message: string, tools: Anthropic.Tool[], review = false) =>
92-
runAgent(client, model, system, message, tools, listFiles, review);
92+
runAgent(client, model, system, message, tools, listFiles, targetDir, review);
9393

9494
const printDone = () => fs.existsSync(outPath) ? ok(`Done → ${outPath}`) : warn(`Output file was not created`);
9595
const modeLabel = isCommitMode ? `last ${commitCount} commit(s)` : "uncommitted";
@@ -154,7 +154,7 @@ You MUST call write_file to write lingo-context.md. Do NOT output the file conte
154154
dbg(`gitChanged:`, gitChanged);
155155
const allBucket = resolveBucketFiles();
156156
dbg(`resolveBucketFiles:`, allBucket);
157-
const candidates = [...new Set([...gitChanged.filter(matchesBucket), ...allBucket])];
157+
const candidates = [...new Set([...gitChanged.filter(f => matchesBucket(f) || path.basename(f) === 'i18n.json'), ...allBucket])];
158158
dbg(`candidates:`, candidates);
159159
earlyChangedFiles = filterNewFiles(candidates, state);
160160
dbg(`earlyChangedFiles:`, earlyChangedFiles.map(([f]) => f));
@@ -166,9 +166,11 @@ You MUST call write_file to write lingo-context.md. Do NOT output the file conte
166166

167167
const override = values.prompt ?? await textPrompt("What should the full regeneration cover?", "blank for default");
168168
const regen = override || "Generate a comprehensive lingo-context.md for this project.";
169-
clearState(outPath);
169+
const prevMtime = fs.existsSync(outPath) ? fs.statSync(outPath).mtimeMs : null;
170170
await agent(freshSystem, freshMessage(regen), allTools, true);
171-
if (!fs.existsSync(outPath)) { warn(SKIPPED_MSG); return; }
171+
const newMtime = fs.existsSync(outPath) ? fs.statSync(outPath).mtimeMs : null;
172+
if (newMtime === null || newMtime === prevMtime) { warn(SKIPPED_MSG); return; }
173+
clearState(outPath);
172174
phase("JSONC Injection");
173175
const jsoncEntries1 = await runJsoncInjection(client, model, jsoncSourceFiles, outPath, true);
174176
phase("Provider Sync");

0 commit comments

Comments
 (0)