mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 11:00:22 +08:00
fix: 二次 Apply 不再误报 #26/#27,重启等到会话树落地再进页面
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
6c88f4d075
commit
fd4dfa4e38
11 files changed
+254
-432
No files matched your search
+2
-12
@@ -1,6 +1,3 @@
|
||||
// 规则集:多套 AGENTS.md / CLAUDE.md;激活时写入目标文件,并被 systemPrompt 段实时注入
|
||||
// 存储: $DSH_HOME/rules/<id>.md + <id>.json ;状态: rules/state.json
|
||||
|
||||
import fs from "node:fs";
|
||||
import { promises as fsp } from "node:fs";
|
||||
import path from "node:path";
|
||||
@@ -86,13 +83,12 @@ export async function listRules(dshHome) {
|
||||
try {
|
||||
size = (await fsp.stat(path.join(dir, e.name))).size;
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
const meta = await readRuleMeta(dshHome, id);
|
||||
out.push({ id, name: meta.name, target: meta.target, size });
|
||||
}
|
||||
} catch {
|
||||
/* rules dir missing → empty */
|
||||
// rules 目录不存在时按空列表返回
|
||||
}
|
||||
out.sort((a, b) => a.id.localeCompare(b.id));
|
||||
return out;
|
||||
@@ -136,7 +132,6 @@ export async function deleteRule(dshHome, id) {
|
||||
try {
|
||||
await fsp.unlink(stateFile(dshHome));
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,7 +151,6 @@ export async function setActive(dshHome, id) {
|
||||
await fsp.writeFile(stateFile(dshHome), JSON.stringify({ active: id }, null, 2), "utf8");
|
||||
}
|
||||
|
||||
/** Sync read for systemPrompt.section text(); empty string if none. */
|
||||
export function activeRuleText(dshHome) {
|
||||
try {
|
||||
const parsed = JSON.parse(fs.readFileSync(stateFile(dshHome), "utf8"));
|
||||
@@ -184,7 +178,6 @@ export async function ensureInitialState(dshHome) {
|
||||
try {
|
||||
await fsp.unlink(stateFile(dshHome));
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
active = null;
|
||||
}
|
||||
@@ -199,7 +192,7 @@ export async function ensureInitialState(dshHome) {
|
||||
return { active: "default", imported: target };
|
||||
}
|
||||
} catch {
|
||||
/* file missing, try next target */
|
||||
// 当前 target 文件不存在,试下一个
|
||||
}
|
||||
}
|
||||
return { active: null };
|
||||
@@ -222,13 +215,11 @@ export async function resetToOriginal(dshHome) {
|
||||
skipped.push(fp);
|
||||
}
|
||||
} catch {
|
||||
/* 目标文件不存在 */
|
||||
}
|
||||
}
|
||||
try {
|
||||
await fsp.unlink(stateFile(dshHome));
|
||||
} catch {
|
||||
/* 无状态文件 */
|
||||
}
|
||||
return { removed, skipped };
|
||||
}
|
||||
@@ -250,7 +241,6 @@ export async function rulesStatus(dshHome) {
|
||||
const ruleContent = await readRule(dshHome, active);
|
||||
agents_synced = ruleContent !== null && ruleContent === content;
|
||||
} catch {
|
||||
/* target file missing */
|
||||
}
|
||||
}
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user