chore: drop non-code junk (pi-mono-reference, runtime state, root duplicates)
Remove files that should never have been tracked: - pi-mono-reference/: 688-file copy of an upstream monorepo, zero imports, used only as offline human reference - build/electron-builder.runtime.json: environment-specific build artifact with hardcoded local paths - state/cancel-signal-state.json: runtime state written by the app - prompt.txt, logo.svg (root): exact duplicates of the canonical copies under .planning/archive/ and assets/ Add state/ to .gitignore so future runtime state stays out.
This commit is contained in:
1 parent
34ca5b77f1
commit
1f7230fe87
691 files changed
+3
-190434
No files matched your search
@@ -1,57 +0,0 @@
|
||||
import { describe, expect, test, vi } from "vitest";
|
||||
import triggerCompactExtension from "../examples/extensions/trigger-compact.js";
|
||||
import type { ExtensionAPI, ExtensionCommandContext, ExtensionContext } from "../src/core/extensions/index.js";
|
||||
|
||||
function createContext(tokens: number | null, compact = vi.fn()): ExtensionContext {
|
||||
return {
|
||||
hasUI: false,
|
||||
ui: {} as ExtensionContext["ui"],
|
||||
cwd: process.cwd(),
|
||||
sessionManager: {} as ExtensionContext["sessionManager"],
|
||||
modelRegistry: {} as ExtensionContext["modelRegistry"],
|
||||
model: undefined,
|
||||
isIdle: () => true,
|
||||
signal: undefined,
|
||||
abort: vi.fn(),
|
||||
hasPendingMessages: () => false,
|
||||
shutdown: vi.fn(),
|
||||
getContextUsage: () => ({ tokens, contextWindow: 200_000, percent: tokens === null ? null : tokens / 2000 }),
|
||||
compact,
|
||||
getSystemPrompt: () => "",
|
||||
};
|
||||
}
|
||||
|
||||
describe("trigger-compact example extension", () => {
|
||||
test("only auto-compacts when context usage crosses the threshold", () => {
|
||||
let turnEndHandler:
|
||||
| ((event: { type: "turn_end" }, ctx: ExtensionContext | ExtensionCommandContext) => void)
|
||||
| undefined;
|
||||
|
||||
const api = {
|
||||
on: (event: string, handler: (event: { type: "turn_end" }, ctx: ExtensionContext) => void) => {
|
||||
if (event === "turn_end") {
|
||||
turnEndHandler = handler;
|
||||
}
|
||||
},
|
||||
registerCommand: vi.fn(),
|
||||
} as unknown as ExtensionAPI;
|
||||
|
||||
triggerCompactExtension(api);
|
||||
expect(turnEndHandler).toBeDefined();
|
||||
|
||||
const compact = vi.fn();
|
||||
const event = { type: "turn_end" } as const;
|
||||
|
||||
turnEndHandler?.(event, createContext(110_000, compact));
|
||||
expect(compact).not.toHaveBeenCalled();
|
||||
|
||||
turnEndHandler?.(event, createContext(120_000, compact));
|
||||
expect(compact).not.toHaveBeenCalled();
|
||||
|
||||
turnEndHandler?.(event, createContext(95_000, compact));
|
||||
expect(compact).not.toHaveBeenCalled();
|
||||
|
||||
turnEndHandler?.(event, createContext(105_000, compact));
|
||||
expect(compact).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user