@igorjpimenta/winch-opencode 0.0.0-stage → 2026.10.29-beta.1
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.
- package/hooks.js +19 -0
- package/identity.js +16 -0
- package/index.js +5 -0
- package/package.json +23 -4
- package/README.md +0 -3
package/hooks.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { stampWinchIdentity } from "./identity.js";
|
|
2
|
+
|
|
3
|
+
// The agent is not on the tool call, only the session: remember it from the
|
|
4
|
+
// chat events that carry both, then stamp the pair on every winch call.
|
|
5
|
+
export function createWinchHooks() {
|
|
6
|
+
const agents = new Map();
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
"chat.message": async (input) => {
|
|
10
|
+
if (input?.sessionID && input?.agent) agents.set(input.sessionID, input.agent);
|
|
11
|
+
},
|
|
12
|
+
"chat.params": async (input) => {
|
|
13
|
+
if (input?.sessionID && input?.agent) agents.set(input.sessionID, input.agent);
|
|
14
|
+
},
|
|
15
|
+
"tool.execute.before": async (input, output) => {
|
|
16
|
+
stampWinchIdentity(input, output, { agent: agents.get(input?.sessionID) ?? process.env.WINCH_AGENT });
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
package/identity.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// identity.js — opencode can mutate tool args but not request _meta, so the
|
|
2
|
+
// winch server accepts a whole agent+session pair as winch_agent/winch_session
|
|
3
|
+
// args (src/identity.js, args channel). The hook overwrites them
|
|
4
|
+
// unconditionally: a model-supplied pair must never survive.
|
|
5
|
+
|
|
6
|
+
export function isWinchTool(name) {
|
|
7
|
+
return typeof name === "string" && name.includes("winch");
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function stampWinchIdentity(input, output, { agent = null } = {}) {
|
|
11
|
+
if (!isWinchTool(input?.tool)) return false;
|
|
12
|
+
output.args = output.args ?? {};
|
|
13
|
+
if (agent) output.args.winch_agent = agent;
|
|
14
|
+
if (input?.sessionID) output.args.winch_session = input.sessionID;
|
|
15
|
+
return true;
|
|
16
|
+
}
|
package/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@igorjpimenta/winch-opencode",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "2026.10.29-beta.1",
|
|
4
|
+
"description": "OpenCode companion for winch: stamps agent and session identity on winch tool calls.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/igorjpimenta/winch.git",
|
|
10
|
+
"directory": "plugins/opencode/winch"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"registry": "https://registry.npmjs.org",
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
".": "./index.js"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"index.js",
|
|
21
|
+
"hooks.js",
|
|
22
|
+
"identity.js"
|
|
23
|
+
],
|
|
24
|
+
"main": "index.js"
|
|
25
|
+
}
|
package/README.md
DELETED