@haoyiyin/workflow 0.2.6 → 0.2.9
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi-extension.d.ts","sourceRoot":"","sources":["../../src/pi-extension.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,CAAC,OAAO,WAAW,EAAE,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"pi-extension.d.ts","sourceRoot":"","sources":["../../src/pi-extension.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,CAAC,OAAO,WAAW,EAAE,EAAE,GAAG,QAwF/B"}
|
package/dist/src/pi-extension.js
CHANGED
|
@@ -16,21 +16,72 @@ export default function (pi) {
|
|
|
16
16
|
}
|
|
17
17
|
// Classify intent
|
|
18
18
|
const intent = classifyIntent(event.text);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
19
|
+
const targetSkill = intent.skill || "quick-task";
|
|
20
|
+
// Determine reason for dispatch
|
|
21
|
+
let reason = intent.reason;
|
|
22
|
+
if (!intent.skill) {
|
|
23
|
+
const needsExternal = /^(what|how|why|when|where|who|search|find|look|weather|time|price|stock|translate)/i.test(event.text);
|
|
24
|
+
if (needsExternal) {
|
|
25
|
+
reason = "External query - needs subagent";
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
reason = "Default dispatch - no direct execution allowed";
|
|
29
|
+
}
|
|
27
30
|
}
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
ctx.ui.notify(`[yi-workflow] Dispatching to /skill:${targetSkill} (${reason})`, "info");
|
|
32
|
+
// Transform to skill command - main agent will receive "/skill:X ..."
|
|
33
|
+
// The before_agent_start hook injects constraints forcing main agent to call skill
|
|
34
|
+
return {
|
|
35
|
+
action: "transform",
|
|
36
|
+
text: `/skill:${targetSkill} ${event.text}`,
|
|
37
|
+
};
|
|
30
38
|
});
|
|
31
39
|
// Log when session starts
|
|
32
40
|
pi.on("session_start", async (event, ctx) => {
|
|
33
41
|
ctx.ui.notify("yi-workflow extension loaded", "info");
|
|
34
42
|
});
|
|
43
|
+
// CRITICAL: Inject THIN DISPATCHER rules into system prompt
|
|
44
|
+
// This ensures main agent NEVER executes work directly
|
|
45
|
+
pi.on("before_agent_start", async (event, ctx) => {
|
|
46
|
+
const systemPrompt = event.systemPrompt || "";
|
|
47
|
+
const userInput = event.userInput || "";
|
|
48
|
+
// Detect if this input was transformed to a skill command
|
|
49
|
+
const isSkillCommand = userInput.startsWith("/skill:");
|
|
50
|
+
// Prepend THIN DISPATCHER constraints
|
|
51
|
+
const thinDispatcherRules = `
|
|
52
|
+
╔══════════════════════════════════════════════════════════════════╗
|
|
53
|
+
║ THIN DISPATCHER PROTOCOL [ABSOLUTE] ║
|
|
54
|
+
╚══════════════════════════════════════════════════════════════════╝
|
|
55
|
+
|
|
56
|
+
YOU ARE A THIN DISPATCHER. YOUR ONLY JOB IS TO DISPATCH TO SKILLS.
|
|
57
|
+
|
|
58
|
+
⚠️ ABSOLUTE RULE #1: If user input starts with "/skill:", you MUST call that skill.
|
|
59
|
+
⚠️ ABSOLUTE RULE #2: You NEVER execute work yourself - only dispatch.
|
|
60
|
+
⚠️ ABSOLUTE RULE #3: Tools (Read, Edit, Bash, etc.) are FORBIDDEN unless in subagent.
|
|
61
|
+
|
|
62
|
+
FORBIDDEN ACTIONS (VIOLATION = PROTOCOL BREACH):
|
|
63
|
+
- Reading files (use /skill:review-diff)
|
|
64
|
+
- Writing/editing files (use /skill:execute-plan)
|
|
65
|
+
- Running commands (use /skill:quick-task)
|
|
66
|
+
- Writing code directly (use /skill:tdd or /skill:execute-plan)
|
|
67
|
+
- Using any tool directly (use /skill:quick-task to dispatch subagent)
|
|
68
|
+
|
|
69
|
+
CURRENT INPUT: "${userInput}"
|
|
70
|
+
IS_SKILL_COMMAND: ${isSkillCommand ? "YES - MUST CALL SKILL" : "NO"}
|
|
71
|
+
|
|
72
|
+
${isSkillCommand ? `
|
|
73
|
+
╔══════════════════════════════════════════════════════════════════╗
|
|
74
|
+
║ ⚠️ MANDATORY: CALL THE SKILL BELOW ⚠️ ║
|
|
75
|
+
╚══════════════════════════════════════════════════════════════════╝
|
|
76
|
+
The input starts with "/skill:". You MUST call that skill.
|
|
77
|
+
DO NOT process this input as a regular conversation.
|
|
78
|
+
DO NOT use tools directly.
|
|
79
|
+
CALL THE SKILL: "${userInput.split(" ")[0]}"
|
|
80
|
+
` : ""}
|
|
81
|
+
`;
|
|
82
|
+
// Prepend to system prompt
|
|
83
|
+
event.systemPrompt = thinDispatcherRules + "\n\n" + systemPrompt;
|
|
84
|
+
return { action: "continue" };
|
|
85
|
+
});
|
|
35
86
|
}
|
|
36
87
|
//# sourceMappingURL=pi-extension.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi-extension.js","sourceRoot":"","sources":["../../src/pi-extension.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,6CAA6C;AAC7C,gDAAgD;AAChD,MAAM,CAAC,OAAO,WAAW,EAAO;IAC9B,yCAAyC;IACzC,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,KAAU,EAAE,GAAQ,EAAE,EAAE;QAC5C,4CAA4C;QAC5C,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC/B,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;QAChC,CAAC;QAED,kBAAkB;QAClB,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"pi-extension.js","sourceRoot":"","sources":["../../src/pi-extension.ts"],"names":[],"mappings":"AAAA;;;;;GAKG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E,CAAC,MAAM,CAAC,8BAA8B,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,4DAA4D;IAC5D,uDAAuD;IACvD,EAAE,CAAC,EAAE,CAAC,oBAAoB,EAAE,KAAK,EAAE,KAAU,EAAE,GAAQ,EAAE,EAAE;QACzD,MAAM,YAAY,GAAG,KAAK,CAAC,YAAY,IAAI,EAAE,CAAC;QAC9C,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,IAAI,EAAE,CAAC;QAExC,0DAA0D;QAC1D,MAAM,cAAc,GAAG,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAEvD,sCAAsC;QACtC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;kBAkBd,SAAS;oBACP,cAAc,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,IAAI;;EAEjE,cAAc,CAAC,CAAC,CAAC;;;;;;;mBAOA,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACzC,CAAC,CAAC,CAAC,EAAE;CACL,CAAC;QAEE,2BAA2B;QAC3B,KAAK,CAAC,YAAY,GAAG,mBAAmB,GAAG,MAAM,GAAG,YAAY,CAAC;QAEjE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
package/src/pi-extension.ts
CHANGED
|
@@ -19,27 +19,82 @@ export default function (pi: any) {
|
|
|
19
19
|
|
|
20
20
|
// Classify intent
|
|
21
21
|
const intent = classifyIntent(event.text);
|
|
22
|
+
const targetSkill = intent.skill || "quick-task";
|
|
22
23
|
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
action: "transform",
|
|
33
|
-
text: `/skill:${intent.skill} ${event.text}`,
|
|
34
|
-
};
|
|
24
|
+
// Determine reason for dispatch
|
|
25
|
+
let reason = intent.reason;
|
|
26
|
+
if (!intent.skill) {
|
|
27
|
+
const needsExternal = /^(what|how|why|when|where|who|search|find|look|weather|time|price|stock|translate)/i.test(event.text);
|
|
28
|
+
if (needsExternal) {
|
|
29
|
+
reason = "External query - needs subagent";
|
|
30
|
+
} else {
|
|
31
|
+
reason = "Default dispatch - no direct execution allowed";
|
|
32
|
+
}
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
ctx.ui.notify(
|
|
36
|
+
`[yi-workflow] Dispatching to /skill:${targetSkill} (${reason})`,
|
|
37
|
+
"info"
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
// Transform to skill command - main agent will receive "/skill:X ..."
|
|
41
|
+
// The before_agent_start hook injects constraints forcing main agent to call skill
|
|
42
|
+
return {
|
|
43
|
+
action: "transform",
|
|
44
|
+
text: `/skill:${targetSkill} ${event.text}`,
|
|
45
|
+
};
|
|
39
46
|
});
|
|
40
47
|
|
|
41
48
|
// Log when session starts
|
|
42
49
|
pi.on("session_start", async (event: any, ctx: any) => {
|
|
43
50
|
ctx.ui.notify("yi-workflow extension loaded", "info");
|
|
44
51
|
});
|
|
52
|
+
|
|
53
|
+
// CRITICAL: Inject THIN DISPATCHER rules into system prompt
|
|
54
|
+
// This ensures main agent NEVER executes work directly
|
|
55
|
+
pi.on("before_agent_start", async (event: any, ctx: any) => {
|
|
56
|
+
const systemPrompt = event.systemPrompt || "";
|
|
57
|
+
const userInput = event.userInput || "";
|
|
58
|
+
|
|
59
|
+
// Detect if this input was transformed to a skill command
|
|
60
|
+
const isSkillCommand = userInput.startsWith("/skill:");
|
|
61
|
+
|
|
62
|
+
// Prepend THIN DISPATCHER constraints
|
|
63
|
+
const thinDispatcherRules = `
|
|
64
|
+
╔══════════════════════════════════════════════════════════════════╗
|
|
65
|
+
║ THIN DISPATCHER PROTOCOL [ABSOLUTE] ║
|
|
66
|
+
╚══════════════════════════════════════════════════════════════════╝
|
|
67
|
+
|
|
68
|
+
YOU ARE A THIN DISPATCHER. YOUR ONLY JOB IS TO DISPATCH TO SKILLS.
|
|
69
|
+
|
|
70
|
+
⚠️ ABSOLUTE RULE #1: If user input starts with "/skill:", you MUST call that skill.
|
|
71
|
+
⚠️ ABSOLUTE RULE #2: You NEVER execute work yourself - only dispatch.
|
|
72
|
+
⚠️ ABSOLUTE RULE #3: Tools (Read, Edit, Bash, etc.) are FORBIDDEN unless in subagent.
|
|
73
|
+
|
|
74
|
+
FORBIDDEN ACTIONS (VIOLATION = PROTOCOL BREACH):
|
|
75
|
+
- Reading files (use /skill:review-diff)
|
|
76
|
+
- Writing/editing files (use /skill:execute-plan)
|
|
77
|
+
- Running commands (use /skill:quick-task)
|
|
78
|
+
- Writing code directly (use /skill:tdd or /skill:execute-plan)
|
|
79
|
+
- Using any tool directly (use /skill:quick-task to dispatch subagent)
|
|
80
|
+
|
|
81
|
+
CURRENT INPUT: "${userInput}"
|
|
82
|
+
IS_SKILL_COMMAND: ${isSkillCommand ? "YES - MUST CALL SKILL" : "NO"}
|
|
83
|
+
|
|
84
|
+
${isSkillCommand ? `
|
|
85
|
+
╔══════════════════════════════════════════════════════════════════╗
|
|
86
|
+
║ ⚠️ MANDATORY: CALL THE SKILL BELOW ⚠️ ║
|
|
87
|
+
╚══════════════════════════════════════════════════════════════════╝
|
|
88
|
+
The input starts with "/skill:". You MUST call that skill.
|
|
89
|
+
DO NOT process this input as a regular conversation.
|
|
90
|
+
DO NOT use tools directly.
|
|
91
|
+
CALL THE SKILL: "${userInput.split(" ")[0]}"
|
|
92
|
+
` : ""}
|
|
93
|
+
`;
|
|
94
|
+
|
|
95
|
+
// Prepend to system prompt
|
|
96
|
+
event.systemPrompt = thinDispatcherRules + "\n\n" + systemPrompt;
|
|
97
|
+
|
|
98
|
+
return { action: "continue" };
|
|
99
|
+
});
|
|
45
100
|
}
|