@raidou/pi-pm-subagents 0.1.3 → 0.1.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raidou/pi-pm-subagents",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Coordinator mode for pi: a read-only coordinator agent that drives isolated subagents, including a planner role.",
5
5
  "keywords": [
6
6
  "pi",
@@ -12,6 +12,10 @@
12
12
  "coordinator"
13
13
  ],
14
14
  "license": "MIT",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/weirongxu/pi-pm-subagents.git"
18
+ },
15
19
  "type": "module",
16
20
  "pi": {
17
21
  "extensions": [
@@ -145,6 +145,37 @@ describe('MessageBatcher', () => {
145
145
  expect(firstFlush?.[1]).toContain('Subagent activity update')
146
146
  })
147
147
 
148
+ it('formats plan items with reviewed-by-user tag', () => {
149
+ vi.useFakeTimers()
150
+ const flushed: string[][] = []
151
+ const batcher = new MessageBatcher((items) => flushed.push(items), 100)
152
+ const subagent = makeSubagent(1, 'plan-1', 'done')
153
+
154
+ batcher.add(subagent, 'plan', 'The implementation plan')
155
+ batcher.flushNow()
156
+
157
+ expect(flushed).toHaveLength(1)
158
+ const item = flushed[0]?.[0]
159
+ expect(item).toContain('<subagent-plan>')
160
+ expect(item).toContain('</subagent-plan>')
161
+ expect(item).toContain('<type>plan</type>')
162
+ expect(item).toContain('<reviewed-by-user>true</reviewed-by-user>')
163
+ expect(item).toContain('<message>The implementation plan</message>')
164
+ })
165
+
166
+ it('does not add reviewed-by-user tag to non-plan items', () => {
167
+ vi.useFakeTimers()
168
+ const flushed: string[][] = []
169
+ const batcher = new MessageBatcher((items) => flushed.push(items), 100)
170
+ const subagent = makeSubagent(1, 'task-1', 'done')
171
+
172
+ batcher.add(subagent, 'done', 'Task completed')
173
+ batcher.flushNow()
174
+
175
+ const item = flushed[0]?.[0]
176
+ expect(item).not.toContain('reviewed-by-user')
177
+ })
178
+
148
179
  it('resets timer on each add', () => {
149
180
  vi.useFakeTimers()
150
181
  const flushed: string[][] = []
@@ -1,5 +1,11 @@
1
1
  import { formatSubagentSummary, type LiveSubagent } from './manager.js'
2
2
 
3
+ const TAG_NAMES: Record<string, string> = {
4
+ done: 'subagent-done',
5
+ plan: 'subagent-plan',
6
+ notify: 'subagent-notify',
7
+ }
8
+
3
9
  export class MessageBatcher {
4
10
  private items: string[] = []
5
11
  private timer: ReturnType<typeof setTimeout> | undefined
@@ -14,14 +20,15 @@ export class MessageBatcher {
14
20
  }
15
21
 
16
22
  add(subagent: LiveSubagent, type: string, message: string): void {
17
- const tagName = type === 'done' ? 'subagent-done' : 'subagent-notify'
18
- const item = [
19
- `<${tagName}>`,
20
- `<type>${type}</type>`,
23
+ const tagName = TAG_NAMES[type] ?? 'subagent-notify'
24
+ const lines = [`<${tagName}>`, `<type>${type}</type>`]
25
+ if (type === 'plan') lines.push('<reviewed-by-user>true</reviewed-by-user>')
26
+ lines.push(
21
27
  `<job>${formatSubagentSummary(subagent)}</job>`,
22
28
  `<message>${message}</message>`,
23
29
  `</${tagName}>`,
24
- ].join('\n')
30
+ )
31
+ const item = lines.join('\n')
25
32
  this.items.push(item)
26
33
  if (this.timer !== undefined) clearTimeout(this.timer)
27
34
  this.timer = setTimeout(() => {
@@ -181,7 +181,7 @@ export function registerSubagentTools(
181
181
  id: 'send-to-coordinator',
182
182
  label: 'Send plan to coordinator',
183
183
  action: () => {
184
- batcher.add(subagent, 'done', lastMessage)
184
+ batcher.add(subagent, 'plan', lastMessage)
185
185
  },
186
186
  },
187
187
  {