增加历史版本保存功能
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { tool } from "@opencode-ai/plugin";
|
||||
import { join, posix } from "node:path";
|
||||
|
||||
import { config } from "../../src/config.js";
|
||||
import { ResultReferenceStore } from "../../src/results/store.js";
|
||||
import { ToolSessionContextStore } from "../../src/session/toolContextStore.js";
|
||||
import {
|
||||
atomicWriteFile,
|
||||
atomicWriteFileWithHistory,
|
||||
ensureDirectory,
|
||||
readTextFile,
|
||||
} from "../../src/utils/fileStore.js";
|
||||
@@ -17,6 +18,7 @@ const initializePromise = Promise.all([
|
||||
toolContextStore.initialize(),
|
||||
]);
|
||||
const SKILLS_ROOT_DIR = ".opencode/skills";
|
||||
const SKILLS_HISTORY_DIR = join(config.PERSISTENCE_HISTORY_DIR, "skills");
|
||||
const LEARNED_PATTERNS_MARKER = "## Learned Patterns";
|
||||
let writeQueue: Promise<void> = Promise.resolve();
|
||||
|
||||
@@ -118,7 +120,10 @@ const appendLearnedSkillPattern = async (skillPath: string, pattern: string) =>
|
||||
: `${current.trimEnd()}\n\n${LEARNED_PATTERNS_MARKER}\n- ${pattern}\n`;
|
||||
|
||||
await ensureDirectory(join(SKILLS_ROOT_DIR, skillPath));
|
||||
await atomicWriteFile(target, next);
|
||||
await atomicWriteFileWithHistory(target, next, {
|
||||
historyDir: SKILLS_HISTORY_DIR,
|
||||
rootDir: SKILLS_ROOT_DIR,
|
||||
});
|
||||
return { changed: true, target };
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user