@tianhai/pi-workflow-kit 0.7.0 → 0.7.1
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/extensions/workflow-guard.ts +12 -7
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
1
2
|
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -28,15 +29,17 @@ export default function (pi: ExtensionAPI) {
|
|
|
28
29
|
|
|
29
30
|
pi.on("input", (event) => {
|
|
30
31
|
const text = event.text ?? "";
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const match = text.match(/^\/skill:([\w-]+)/);
|
|
33
|
+
if (match) {
|
|
34
|
+
const skill = match[1];
|
|
35
|
+
if (skill in SKILL_TO_PHASE) {
|
|
36
|
+
phase = SKILL_TO_PHASE[skill];
|
|
34
37
|
return;
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
40
|
if (
|
|
38
|
-
text.
|
|
39
|
-
text.
|
|
41
|
+
text.startsWith("/skill:executing-tasks") ||
|
|
42
|
+
text.startsWith("/skill:finalizing")
|
|
40
43
|
) {
|
|
41
44
|
phase = null;
|
|
42
45
|
}
|
|
@@ -50,7 +53,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
50
53
|
const filePath = (event.input as { path?: string }).path ?? "";
|
|
51
54
|
if (!filePath) return;
|
|
52
55
|
|
|
53
|
-
|
|
56
|
+
const absolute = resolve(ctx.cwd, filePath);
|
|
57
|
+
const plansDir = resolve(ctx.cwd, "docs/plans");
|
|
58
|
+
if (absolute.startsWith(plansDir + "/")) return;
|
|
54
59
|
|
|
55
60
|
if (ctx.hasUI) {
|
|
56
61
|
ctx.ui.notify(
|
|
@@ -60,7 +65,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
return {
|
|
63
|
-
|
|
68
|
+
block: true,
|
|
64
69
|
reason: `⚠️ ${phase.toUpperCase()} PHASE: Cannot ${event.toolName} to ${filePath}. Only docs/plans/ is writable during brainstorming and planning.`,
|
|
65
70
|
};
|
|
66
71
|
});
|