refactor: jsc-mod 改名 jsc-mod-statusline、jsc-companion 改名 jsc-mod-companion,指令拆成獨立指令
- jsc-mod-statusline:/jsc-mod-statusline:enable、compact、disable - jsc-mod-companion:/jsc-mod-companion:status、switch、disable、setup、todo、quiet - 同步更新 plugin.json、marketplace.json 與各 README - 補上 statusline band 測試缺少的 ui.render 底層處理 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
0e7636c185
commit
ea17f1cb2d
@@ -0,0 +1,33 @@
|
||||
// 檔案系統與時鐘由外部注入,核心不直接碰真實環境
|
||||
export interface Fs {
|
||||
read(path: string): Promise<string | null>
|
||||
/** 原子寫入:先寫暫存檔再改名 */
|
||||
write(path: string, data: string): Promise<void>
|
||||
}
|
||||
|
||||
export type Clock = () => number
|
||||
|
||||
export function memoryFs(): Fs & { files: Map<string, string> } {
|
||||
const files = new Map<string, string>()
|
||||
return {
|
||||
files,
|
||||
async read(p) {
|
||||
return files.get(p) ?? null
|
||||
},
|
||||
async write(p, d) {
|
||||
files.set(p, d)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export async function readJson<T>(fs: Fs, path: string, fallback: T): Promise<T> {
|
||||
const raw = await fs.read(path)
|
||||
if (raw === null) return fallback
|
||||
try {
|
||||
return JSON.parse(raw) as T
|
||||
} catch {
|
||||
return fallback
|
||||
}
|
||||
}
|
||||
|
||||
export const writeJson = (fs: Fs, path: string, value: unknown) => fs.write(path, JSON.stringify(value, null, 2))
|
||||
Reference in New Issue
Block a user