@irfnd/ape 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,52 @@
1
+ // @bun
2
+ // src/opencode-plugin.ts
3
+ var createApePlugin = (HOOK_CMD) => async ({ $, client, directory }) => {
4
+ const run = (event, payload) => $`${HOOK_CMD} opencode ${event} < ${new Response(JSON.stringify({ cwd: directory, ...payload }))}`.quiet().nothrow().text();
5
+ const MAX_DELTAS = 5;
6
+ const context = new Map;
7
+ return {
8
+ "experimental.chat.system.transform": async (input, output) => {
9
+ const id = input.sessionID ?? "default";
10
+ const blocks = context.get(id) ?? [];
11
+ const delta = (await run(blocks.length ? "sync" : "start", { sessionID: id })).trim();
12
+ if (delta)
13
+ blocks.push(delta);
14
+ if (blocks.length > MAX_DELTAS + 1)
15
+ blocks.splice(1, 1);
16
+ context.set(id, blocks);
17
+ if (blocks.length)
18
+ output.system.push(blocks.join(`
19
+
20
+ `));
21
+ },
22
+ "tool.execute.after": async (input) => {
23
+ await run("change", {
24
+ tool: input.tool,
25
+ args: input.args,
26
+ sessionID: input.sessionID
27
+ });
28
+ },
29
+ event: async ({ event }) => {
30
+ if (event.type !== "session.idle" && event.type !== "session.compacted")
31
+ return;
32
+ const sessionID = event.properties.sessionID;
33
+ const compacted = event.type === "session.compacted";
34
+ let summary = "";
35
+ try {
36
+ const res = await client.session.messages({
37
+ path: { id: sessionID }
38
+ });
39
+ const replies = (res.data ?? []).filter((m) => m.info.role === "assistant");
40
+ const last = compacted ? replies.findLast((m) => m.info.summary) : replies.at(-1);
41
+ if (last && (compacted || !last.info.summary)) {
42
+ summary = last.parts.map((p) => p.type === "text" ? p.text : "").filter(Boolean).join(`
43
+ `);
44
+ }
45
+ } catch {}
46
+ await run(compacted ? "compact" : "stop", { sessionID, summary });
47
+ }
48
+ };
49
+ };
50
+ export {
51
+ createApePlugin
52
+ };
package/package.json CHANGED
@@ -1,6 +1,48 @@
1
1
  {
2
- "name": "@irfnd/ape",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@irfnd/ape",
3
+ "version": "0.1.0",
4
+ "author": "Irfnd <irfandiabimanyu@gmail.com>",
5
+ "license": "MIT",
6
+ "description": "APE client: shared project memory hooks for coding agents and a Zed edit-prediction adapter, backed by a remote ape-server",
7
+ "type": "module",
8
+ "bin": {
9
+ "ape": "dist/ape.js"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "bunfig.toml"
14
+ ],
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "engines": {
19
+ "bun": ">=1.3.0"
20
+ },
21
+ "scripts": {
22
+ "build": "bun build bin/ape.ts --target bun --outfile dist/ape.js && bun build src/opencode-plugin.ts --target bun --outfile dist/opencode-plugin.js",
23
+ "prepublishOnly": "bun run typecheck && bun test && bun run build",
24
+ "test": "bun test",
25
+ "typecheck": "tsc --noEmit",
26
+ "format": "bun --bun prettier --write .",
27
+ "format:check": "bun --bun prettier --check ."
28
+ },
29
+ "keywords": [
30
+ "ape",
31
+ "supermemory",
32
+ "9router",
33
+ "claude-code",
34
+ "antigravity",
35
+ "opencode",
36
+ "zed"
37
+ ],
38
+ "devDependencies": {
39
+ "@irfnd/prettier-config": "^1.5.4",
40
+ "@opencode-ai/plugin": "^1.18.33",
41
+ "@types/bun": "^1.4.2",
42
+ "prettier": "^3.9.9",
43
+ "reflect-metadata": "^0.2.2",
44
+ "tsyringe": "^4.10.0",
45
+ "typescript": "^7.0.2",
46
+ "zod": "^4.0.0"
47
+ }
48
+ }