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 +1 -1
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/commands/delegation.ts +14 -13
- package/test/agent-palette.test.ts +9 -13
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
|
|
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-improve-interation",
|
|
3
|
-
"version": "0.0.
|
|
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
|
|
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
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
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
|
|
22
|
+
const rawMessage =
|
|
22
23
|
trimmed.length > 0
|
|
23
|
-
?
|
|
24
|
-
: "
|
|
24
|
+
? trimmed
|
|
25
|
+
: "(no explicit task — infer the most useful one from this conversation)";
|
|
25
26
|
return [
|
|
26
|
-
|
|
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
|
-
|
|
29
|
+
`Select AGENTS: ${agentName}`,
|
|
29
30
|
"",
|
|
30
|
-
|
|
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
|
-
|
|
70
|
-
|
|
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, /
|
|
77
|
-
assert.match(withoutTask, /
|
|
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
|
-
|
|
197
|
-
|
|
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 };
|