@meetopenbot/pi 0.0.2 → 0.0.3

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/dist/diff.js ADDED
@@ -0,0 +1 @@
1
+ export { buildDiffWidget as runDiffWidget, diffFileFromMutationTool as diffFileFromPiTool, } from '@meetopenbot/plugin-sdk';
@@ -0,0 +1,4 @@
1
+ import type { Plugin } from '@meetopenbot/plugin-sdk';
2
+ declare const plugin: Plugin;
3
+ export { plugin };
4
+ export default plugin;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { agentOutput, definePlugin, shouldHandleInvoke, uiWidget, } from '@meetopenbot/plugin-sdk';
1
+ import { agentOutput, buildDiffWidget, definePlugin, diffFileFromMutationTool, resolveRunDiffFiles, shouldHandleInvoke, snapshotWorkspace, toolTraceWidget, uiWidget, } from '@meetopenbot/plugin-sdk';
2
2
  import { resolveConfig } from './config.js';
3
3
  import { formatPiError, formatToolResult } from './format.js';
4
4
  import { getOrCreatePiSession } from './session.js';
@@ -75,6 +75,8 @@ export default definePlugin({
75
75
  });
76
76
  let fullTextContent = '';
77
77
  const toolInfoMap = new Map();
78
+ const changedFiles = new Map();
79
+ const snapshot = snapshotWorkspace(config.cwd);
78
80
  for await (const chunk of streamPiPrompt(session, prompt, {
79
81
  streaming: session.isStreaming,
80
82
  })) {
@@ -87,14 +89,12 @@ export default definePlugin({
87
89
  yield uiWidget({
88
90
  agentId: context.agentId,
89
91
  threadId,
90
- widget: {
91
- kind: 'message',
92
+ widget: toolTraceWidget({
92
93
  widgetId: chunk.toolCallId,
94
+ groupId: 'pi:tools',
93
95
  title: chunk.statusLine,
94
96
  body: `**Input**\n\`\`\`json\n${JSON.stringify(chunk.args, null, 2)}\n\`\`\``,
95
- variant: 'basic',
96
- display: "collapsed",
97
- },
97
+ }),
98
98
  });
99
99
  break;
100
100
  case 'tool_end': {
@@ -106,30 +106,35 @@ export default definePlugin({
106
106
  yield uiWidget({
107
107
  agentId: context.agentId,
108
108
  threadId,
109
- widget: {
110
- kind: 'message',
109
+ widget: toolTraceWidget({
111
110
  widgetId: chunk.toolCallId,
111
+ groupId: 'pi:tools',
112
112
  title: chunk.statusLine || info?.statusLine || `Tool ${chunk.toolName} finished`,
113
113
  body: inputMd + outputMd,
114
- variant: 'basic',
115
- display: "collapsed",
116
114
  state: chunk.isError ? 'error' : 'submitted',
117
- },
115
+ }),
118
116
  });
117
+ if (!chunk.isError) {
118
+ const file = diffFileFromMutationTool({
119
+ toolName: chunk.toolName,
120
+ input: info?.args,
121
+ result: chunk.result,
122
+ });
123
+ if (file)
124
+ changedFiles.set(file.path, file);
125
+ }
119
126
  break;
120
127
  }
121
128
  case 'status':
122
129
  yield uiWidget({
123
130
  agentId: context.agentId,
124
131
  threadId,
125
- widget: {
126
- kind: 'message',
132
+ widget: toolTraceWidget({
127
133
  widgetId: `status-${Date.now()}`,
128
- title: "Status",
134
+ groupId: 'pi:tools',
135
+ title: 'Status',
129
136
  body: chunk.statusLine,
130
- variant: 'basic',
131
- display: "collapsed",
132
- },
137
+ }),
133
138
  });
134
139
  break;
135
140
  case 'text':
@@ -146,6 +151,20 @@ export default definePlugin({
146
151
  threadId,
147
152
  });
148
153
  }
154
+ const diff = buildDiffWidget({
155
+ widgetId: `pi-diff:${threadId ?? 'run'}:${Date.now()}`,
156
+ files: resolveRunDiffFiles({
157
+ snapshot,
158
+ fallback: changedFiles.values(),
159
+ }),
160
+ });
161
+ if (diff) {
162
+ yield uiWidget({
163
+ agentId: context.agentId,
164
+ threadId,
165
+ widget: diff,
166
+ });
167
+ }
149
168
  }
150
169
  catch (error) {
151
170
  yield agentOutput({
package/package.json CHANGED
@@ -1,30 +1,37 @@
1
1
  {
2
2
  "name": "@meetopenbot/pi",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "OpenBot agent plugin powered by the Pi coding agent SDK.",
5
5
  "type": "module",
6
- "main": "dist/index.js",
6
+ "main": "./dist/index.js",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
10
10
  "exports": {
11
- ".": "./dist/index.js"
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "default": "./dist/index.js"
15
+ }
12
16
  },
13
17
  "files": [
14
18
  "dist"
15
19
  ],
16
- "scripts": {
17
- "build": "tsc -p tsconfig.json",
18
- "typecheck": "tsc -p tsconfig.json --noEmit"
19
- },
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
22
  "@earendil-works/pi-ai": "^0.79.1",
23
23
  "@earendil-works/pi-coding-agent": "^0.79.1",
24
- "@meetopenbot/plugin-sdk": "^0.1.4"
24
+ "@meetopenbot/plugin-sdk": "^0.2.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/node": "^25.9.2",
28
28
  "typescript": "^6.0.3"
29
+ },
30
+ "types": "./dist/index.d.ts",
31
+ "scripts": {
32
+ "build": "tsc -p tsconfig.json && node ../../scripts/write-plugin-declaration.mjs",
33
+ "typecheck": "tsc -p tsconfig.json --noEmit",
34
+ "test": "node --experimental-strip-types --test src/diff.test.ts",
35
+ "dev": "tsc -p tsconfig.json --watch --preserveWatchOutput"
29
36
  }
30
- }
37
+ }