mirror of
https://github.com/bendtherules/opencode-plugin-compaction-prompt.git
synced 2026-08-18 21:52:46 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
edb5bb47f4 | ||
|
|
57c96fcd3b | ||
|
|
2fe522b99e | ||
|
|
3d26f61a2b | ||
|
|
55db9835a2 |
@@ -1,5 +1,13 @@
|
||||
# Changelog
|
||||
|
||||
## 0.2.4
|
||||
|
||||
- Normalize npm package repository metadata.
|
||||
|
||||
## 0.2.3
|
||||
|
||||
- Always ask the model to report whether custom compaction instructions were applied.
|
||||
|
||||
## 0.2.2
|
||||
|
||||
- Add explicit markers for applied and skipped custom compaction instructions.
|
||||
|
||||
@@ -47,7 +47,7 @@ Create `.opencode/compaction.md` in the project when you have project-specific c
|
||||
|
||||
Append mode is the recommended default because it preserves OpenCode's built-in compaction behavior. Replace mode is available when the complete prompt needs to be controlled by this plugin.
|
||||
|
||||
When neither a prompt nor a memory file is available, the plugin adds `opencode-plugin-compaction-prompt: No custom compaction applied.` instead.
|
||||
When neither a prompt nor a memory file is available, the plugin asks the model to echo `opencode-plugin-compaction-prompt: No custom compaction applied.` instead.
|
||||
|
||||
## Development
|
||||
|
||||
|
||||
+2
-2
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "opencode-plugin-compaction-prompt",
|
||||
"version": "0.2.2",
|
||||
"version": "0.2.4",
|
||||
"description": "Customize OpenCode's compaction prompt to preserve important context and omit unnecessary details.",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/bendtherules/opencode-plugin-compaction-prompt.git"
|
||||
"url": "git+https://github.com/bendtherules/opencode-plugin-compaction-prompt.git"
|
||||
},
|
||||
"homepage": "https://github.com/bendtherules/opencode-plugin-compaction-prompt#readme",
|
||||
"bugs": {
|
||||
|
||||
+4
-16
@@ -31,11 +31,7 @@ function buildInstructions(
|
||||
prompt: string,
|
||||
completionMarker: string,
|
||||
memory: string,
|
||||
): string | undefined {
|
||||
if (!prompt && !memory) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
): string {
|
||||
const sections = [
|
||||
"## User Compaction Instructions",
|
||||
`These instructions take precedence over previous instructions if there is conflict. At the very end of the summary, echo exactly: **${completionMarker}**`,
|
||||
@@ -115,17 +111,9 @@ export const CompactionPromptPlugin: Plugin = async (
|
||||
output,
|
||||
): Promise<void> => {
|
||||
const memory = await readMemory(memoryPath, logError);
|
||||
const instructions = buildInstructions(prompt, completionMarker, memory);
|
||||
|
||||
if (!instructions) {
|
||||
if (mode === "replace") {
|
||||
output.prompt = skippedCompactionMarker;
|
||||
} else {
|
||||
output.context.push(skippedCompactionMarker);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
const marker =
|
||||
prompt || memory ? completionMarker : skippedCompactionMarker;
|
||||
const instructions = buildInstructions(prompt, marker, memory);
|
||||
|
||||
if (mode === "replace") {
|
||||
output.prompt = instructions;
|
||||
|
||||
+10
-10
@@ -116,9 +116,9 @@ describe("CompactionPromptPlugin", () => {
|
||||
);
|
||||
|
||||
expect(context.logs).toHaveLength(0);
|
||||
expect(output.context).toEqual([
|
||||
"opencode-plugin-compaction-prompt: No custom compaction applied.",
|
||||
]);
|
||||
expect(output.context[0]).toContain(
|
||||
"echo exactly: **opencode-plugin-compaction-prompt: No custom compaction applied.**",
|
||||
);
|
||||
});
|
||||
|
||||
test("adds a skipped marker when no instructions are provided", async () => {
|
||||
@@ -133,10 +133,10 @@ describe("CompactionPromptPlugin", () => {
|
||||
output,
|
||||
);
|
||||
|
||||
expect(output.context).toEqual([
|
||||
"Existing context",
|
||||
"opencode-plugin-compaction-prompt: No custom compaction applied.",
|
||||
]);
|
||||
expect(output.context[0]).toBe("Existing context");
|
||||
expect(output.context[1]).toContain(
|
||||
"echo exactly: **opencode-plugin-compaction-prompt: No custom compaction applied.**",
|
||||
);
|
||||
expect(output.prompt).toBeUndefined();
|
||||
});
|
||||
|
||||
@@ -154,8 +154,8 @@ describe("CompactionPromptPlugin", () => {
|
||||
);
|
||||
|
||||
expect(context.logs).toHaveLength(1);
|
||||
expect(output.context).toEqual([
|
||||
"opencode-plugin-compaction-prompt: No custom compaction applied.",
|
||||
]);
|
||||
expect(output.context[0]).toContain(
|
||||
"echo exactly: **opencode-plugin-compaction-prompt: No custom compaction applied.**",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user