pi-improve-interation 0.0.1 → 0.0.2

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/README.en.md CHANGED
@@ -4,7 +4,7 @@ English | [中文](./README.md)
4
4
 
5
5
  ## Summary
6
6
 
7
- A companion pi package that layers enhancements on top of interactions you already use pi-native and upstream pi plugins alike. One idea only: keep the interactions you know, make them stronger.
7
+ A companion pi package that layers enhancements on top of interactions you already use, whether pi-native or from upstream pi plugins. The interactions stay the same; they just get stronger.
8
8
 
9
9
  - No fork of upstream: public extension APIs only, so an upstream upgrade costs at most one adapter change
10
10
  - No parallel concepts: it enhances the `@` you already type and the work you already delegate
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## Summary
6
6
 
7
- 给 pi 原生与上游 pi 插件**已有交互**叠加增强的伴生包。核心只有一件事:让你继续用熟悉的交互,但更强。
7
+ 给 pi 原生与上游 pi 插件已有交互叠加增强的伴生包。交互不变,能力更强。
8
8
 
9
9
  - 不 fork 上游:只走宿主公开扩展 API,上游升级最多改一处 adapter
10
10
  - 不引入平行概念:增强的就是你已经在敲的 `@`、已经在派的活
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-improve-interation",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Companion enhancement layer over pi-subagents (and future open-source pi packages) — adapter framework for orchestration add-ons, no fork required",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,15 +1,16 @@
1
1
  /**
2
2
  * @agent:<name> mention → delegation instruction for the main session.
3
3
  *
4
- * Design (the main agent stays in charge of the actual child prompt):
4
+ * Design (the main agent is the dispatcher, not the prompt author):
5
5
  * 1. the mention is routing only — "@agent:reviewer" names the target agent;
6
6
  * the remaining message text is the task
7
- * 2. the transform makes the convention explicit: the main agent receives a
8
- * "delegate via the subagent tool" instruction, not a bare @token to guess
9
- * 3. the main agent decides the exact child prompt (carrying context), runs
10
- * the agent through pi-subagents' `subagent` tool, and integrates results
11
- * 4. when no task text accompanies the mention, the main agent picks the most
12
- * useful task itself and asks before delegating when scope is unclear
7
+ * 2. the transform keeps the main agent's effort low: it must quickly grasp
8
+ * the user's intent, then only organize the work and optimize the handoff
9
+ * prompt not recreate the handoff from scratch
10
+ * 3. the main agent dispatches immediately and integrates the child result;
11
+ * it does not re-derive context or pause to ask on a clear task
12
+ * 4. when no task text accompanies the mention, the main agent infers the
13
+ * most useful task from the conversation
13
14
  */
14
15
  export const AGENT_MENTION_TOKEN_PATTERN = /(?:^|\s)@agent:([\w.-]+)/;
15
16
 
@@ -18,15 +19,15 @@ export function buildDelegationInstruction(
18
19
  task: string,
19
20
  ): string {
20
21
  const trimmed = task.trim();
21
- const taskSection =
22
+ const rawMessage =
22
23
  trimmed.length > 0
23
- ? `Task: ${trimmed}`
24
- : "Task: not specifiedpick the most useful task for this agent given the current conversation.";
24
+ ? trimmed
25
+ : "(no explicit taskinfer the most useful one from this conversation)";
25
26
  return [
26
- `Delegate to the ${agentName} subagent via the subagent tool.`,
27
+ "[Must] The user wants to use a subagent. Quickly grasp the intent of the user's raw message below, then focus solely on how to organize the work of the specified agent(s) and how to optimize the prompt you hand off. Then dispatch the subagent.",
27
28
  "",
28
- taskSection,
29
+ `Select AGENTS: ${agentName}`,
29
30
  "",
30
- "You own the handoff: decide the exact child prompt yourself (carry over relevant context from this conversation), run the agent, and integrate its result here. If the task is ambiguous, ask me before delegating.",
31
+ `User Request: \n${rawMessage}`,
31
32
  ].join("\n");
32
33
  }
@@ -65,16 +65,14 @@ test("mergeAgentEntries: later groups override earlier by name", () => {
65
65
 
66
66
  test("buildDelegationInstruction: with task and without task", () => {
67
67
  const withTask = buildDelegationInstruction("reviewer", " review my diff ");
68
- assert.match(
69
- withTask,
70
- /^Delegate to the reviewer subagent via the subagent tool\./,
71
- );
72
- assert.match(withTask, /Task: review my diff/);
73
- assert.match(withTask, /decide the exact child prompt yourself/);
68
+ assert.match(withTask, /^\[Must\]/);
69
+ assert.match(withTask, /Select AGENTS: reviewer/);
70
+ assert.match(withTask, /User Request: \nreview my diff/);
74
71
 
75
72
  const withoutTask = buildDelegationInstruction("scout", "");
76
- assert.match(withoutTask, /Task: not specified/);
77
- assert.match(withoutTask, /ask me before delegating/);
73
+ assert.match(withoutTask, /Select AGENTS: scout/);
74
+ assert.match(withoutTask, /User Request:/);
75
+ assert.match(withoutTask, /no explicit task/);
78
76
  });
79
77
 
80
78
  function makeCurrent() {
@@ -192,11 +190,9 @@ test("input handler transforms @agent: mentions into delegation instructions", (
192
190
  text: string;
193
191
  };
194
192
  assert.equal(transformed.action, "transform");
195
- assert.match(
196
- transformed.text,
197
- /^Delegate to the reviewer subagent via the subagent tool\./,
198
- );
199
- assert.match(transformed.text, /Task: review my diff/);
193
+ assert.match(transformed.text, /^\[Must\]/);
194
+ assert.match(transformed.text, /Select AGENTS: reviewer/);
195
+ assert.match(transformed.text, /User Request: \nreview my diff/);
200
196
  assert.doesNotMatch(transformed.text, /@agent:/);
201
197
 
202
198
  const passthrough = handler({ text: "hello world" }) as { action: string };