Initial import of streamline
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* 把 shared/src/code_conventions.ts 的现行规范块写进三份执行模板的源码。
|
||||
*
|
||||
* bun scripts/sync-code-conventions.ts # 改写 shared/src/run_prompt.ts
|
||||
* bun scripts/sync-code-conventions.ts --check # 只检查,不一致时退出码 1
|
||||
*
|
||||
* 为什么不用 `${}` 插值:RSI 批准上线时由 rsi-ship 直接改写这几个模板常量的源码
|
||||
* (shared/src/rsi_ship.ts::replaceLiteralConst),它只认纯字面量。所以规范块的原文抄在模板里,
|
||||
* code_conventions.ts 是唯一的来源,这个脚本负责抄,control-server/test/review_mining.test.ts 守住两边一致。
|
||||
* 改完记得重抓提示词夹具(satellite/test/run_prompt_parity.test.ts 头注释)。
|
||||
*/
|
||||
import { readFileSync, writeFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { replaceConventionsBlock } from "../shared/src/code_conventions";
|
||||
import { replaceLiteralConst } from "../shared/src/rsi_ship";
|
||||
import * as runPrompt from "../shared/src/run_prompt";
|
||||
|
||||
const SYMBOLS = ["DEFAULT_BUG_RUN_TEMPLATE", "DEFAULT_FEATURE_RUN_FIRST_TEMPLATE", "DEFAULT_FEATURE_RUN_SECOND_TEMPLATE"] as const;
|
||||
const file = join(import.meta.dir, "../shared/src/run_prompt.ts");
|
||||
let src = readFileSync(file, "utf-8");
|
||||
const stale: string[] = [];
|
||||
for (const sym of SYMBOLS) {
|
||||
const cur = (runPrompt as Record<string, string>)[sym];
|
||||
const next = replaceConventionsBlock(cur);
|
||||
if (next === cur) continue;
|
||||
stale.push(sym);
|
||||
const r = replaceLiteralConst(src, sym, next);
|
||||
if ("error" in r) { console.error(r.error); process.exit(2); }
|
||||
src = r.source;
|
||||
}
|
||||
if (process.argv.includes("--check")) {
|
||||
if (stale.length) { console.error(`规范块与 code_conventions.ts 不一致:${stale.join(", ")} —— 跑 bun scripts/sync-code-conventions.ts`); process.exit(1); }
|
||||
console.log("规范块一致");
|
||||
} else if (stale.length) {
|
||||
writeFileSync(file, src);
|
||||
console.log(`已更新:${stale.join(", ")}`);
|
||||
} else {
|
||||
console.log("无需更新");
|
||||
}
|
||||
Reference in New Issue
Block a user