psyclaw 0.30.18 → 0.30.20
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/dist/src/adapters/pi/extension.js +42 -6
- package/dist/src/adapters/pi/extension.js.map +1 -1
- package/dist/src/branding.js +1 -0
- package/dist/src/branding.js.map +1 -1
- package/dist/src/chat.d.ts +34 -0
- package/dist/src/chat.js +54 -45
- package/dist/src/chat.js.map +1 -1
- package/dist/src/cli.js +12 -0
- package/dist/src/cli.js.map +1 -1
- package/dist/src/headless/cli.d.ts +27 -0
- package/dist/src/headless/cli.js +259 -0
- package/dist/src/headless/cli.js.map +1 -0
- package/dist/src/headless/run.d.ts +69 -0
- package/dist/src/headless/run.js +172 -0
- package/dist/src/headless/run.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/safety/irreversible-host-ops.d.ts +22 -0
- package/dist/src/safety/irreversible-host-ops.js +71 -0
- package/dist/src/safety/irreversible-host-ops.js.map +1 -0
- package/dist/src/skills/install-guidance.d.ts +6 -0
- package/dist/src/skills/install-guidance.js +15 -4
- package/dist/src/skills/install-guidance.js.map +1 -1
- package/dist/src/skills/recommended.js +3 -3
- package/dist/src/skills/recommended.js.map +1 -1
- package/dist/src/skills/registry.js +3 -0
- package/dist/src/skills/registry.js.map +1 -1
- package/dist/src/skills/user-skills.js +5 -2
- package/dist/src/skills/user-skills.js.map +1 -1
- package/dist/src/style/cli-ui.js +1 -0
- package/dist/src/style/cli-ui.js.map +1 -1
- package/package.json +1 -1
|
@@ -25,6 +25,7 @@ import { panelHub } from "../../panel/hub.js";
|
|
|
25
25
|
import { appendChoiceRecord } from "../../research/choice.js";
|
|
26
26
|
import { enabledLocalSkillPaths, enabledLocalPromptPaths, readUserSkillState, scanLocalSkills, setLocalSkillEnabled, setLocalSkillsEnabled, skillNamesInPaths, userSkillId, } from "../../skills/user-skills.js";
|
|
27
27
|
import { RuntimeMcpRegistry, setUserMcpConfigEnabled, } from "../../integrations/mcp-runtime.js";
|
|
28
|
+
import { classifyIrreversibleHostCommand, extractToolCommandText, irreversibleHostBlockReason, } from "../../safety/irreversible-host-ops.js";
|
|
28
29
|
import { SecretInputComponent, TextInputComponent, ProviderPickerComponent, } from "../../tui/provider-picker.js";
|
|
29
30
|
import { resolveProviderBaseUrl } from "../../core/provider-endpoint.js";
|
|
30
31
|
import { isArsPiActive, isArsPiTurn, psyclawArsPatch, setArsPiSessionActive, } from "../../ars/profile.js";
|
|
@@ -81,6 +82,26 @@ async function notifyError(ctx, error, extra = {}) {
|
|
|
81
82
|
await captureAgentError(error, { phase: "extension", cwd: ctx.cwd, ...extra });
|
|
82
83
|
ctx.ui.notify(error instanceof Error ? error.message : String(error), "error");
|
|
83
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Reload Pi skills/prompts after enablement changes.
|
|
87
|
+
* Pi treats `ctx.reload()` as terminal for the current handler: notify first,
|
|
88
|
+
* then reload, and never use the old ctx afterward (`"reloaded"` = stop).
|
|
89
|
+
*/
|
|
90
|
+
async function notifyAfterSkillChange(ctx, summary, level = "info") {
|
|
91
|
+
if (typeof ctx.reload === "function") {
|
|
92
|
+
try {
|
|
93
|
+
ctx.ui.notify(`${summary}正在重新加载资源…`, level);
|
|
94
|
+
await ctx.reload();
|
|
95
|
+
return "reloaded";
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
ctx.ui.notify(`${summary}自动加载失败(${error instanceof Error ? error.message : String(error)})。请执行 /reload。`, "warning");
|
|
99
|
+
return "manual-reload";
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
ctx.ui.notify(`${summary}请执行 /reload 重新加载。`, level);
|
|
103
|
+
return "manual-reload";
|
|
104
|
+
}
|
|
84
105
|
const activeAgentRuns = new Set();
|
|
85
106
|
const CORE_SKILLS = new Set(["academic-grill", "research-intake", "evidence-capture", "citation-audit", "analysis-plan"]);
|
|
86
107
|
function findLastMatching(items, predicate) {
|
|
@@ -1010,9 +1031,11 @@ async function showSkillManager(pi, ctx) {
|
|
|
1010
1031
|
const ids = locals.map((row) => row.name);
|
|
1011
1032
|
await setLocalSkillsEnabled(ctx.cwd, ids, true);
|
|
1012
1033
|
}
|
|
1013
|
-
ctx
|
|
1014
|
-
? `已启用其余可管理的 Skill(${failed.join("、")} 未启用:缺少 SKILL.md
|
|
1015
|
-
:
|
|
1034
|
+
const outcome = await notifyAfterSkillChange(ctx, failed.length > 0
|
|
1035
|
+
? `已启用其余可管理的 Skill(${failed.join("、")} 未启用:缺少 SKILL.md 或未通过校验,请在列表中单独安装或修复)。`
|
|
1036
|
+
: "已启用全部可管理的 Skill。", failed.length > 0 ? "warning" : "info");
|
|
1037
|
+
if (outcome === "reloaded")
|
|
1038
|
+
return;
|
|
1016
1039
|
}
|
|
1017
1040
|
else {
|
|
1018
1041
|
for (const row of managed) {
|
|
@@ -1025,7 +1048,8 @@ async function showSkillManager(pi, ctx) {
|
|
|
1025
1048
|
const ids = locals.map((row) => row.name);
|
|
1026
1049
|
await setLocalSkillsEnabled(ctx.cwd, ids, false);
|
|
1027
1050
|
}
|
|
1028
|
-
ctx
|
|
1051
|
+
if ((await notifyAfterSkillChange(ctx, "已停用全部可管理的 Skill。")) === "reloaded")
|
|
1052
|
+
return;
|
|
1029
1053
|
}
|
|
1030
1054
|
continue;
|
|
1031
1055
|
}
|
|
@@ -1039,7 +1063,8 @@ async function showSkillManager(pi, ctx) {
|
|
|
1039
1063
|
if (action.type === "toggle") {
|
|
1040
1064
|
if (row.source === "local") {
|
|
1041
1065
|
await setLocalSkillEnabled(ctx.cwd, row.name, action.enabled);
|
|
1042
|
-
ctx
|
|
1066
|
+
if ((await notifyAfterSkillChange(ctx, `已${action.enabled ? "启用" : "停用"}本地 Skill ${row.name}。`)) === "reloaded")
|
|
1067
|
+
return;
|
|
1043
1068
|
}
|
|
1044
1069
|
else {
|
|
1045
1070
|
const result = await setRecommendedSkillEnabled(ctx.cwd, row.id, action.enabled);
|
|
@@ -1053,7 +1078,8 @@ async function showSkillManager(pi, ctx) {
|
|
|
1053
1078
|
ctx.ui.notify(result.message, "error");
|
|
1054
1079
|
continue;
|
|
1055
1080
|
}
|
|
1056
|
-
ctx
|
|
1081
|
+
if ((await notifyAfterSkillChange(ctx, `已${action.enabled ? "启用" : "停用"} ${row.name}。`)) === "reloaded")
|
|
1082
|
+
return;
|
|
1057
1083
|
}
|
|
1058
1084
|
}
|
|
1059
1085
|
}
|
|
@@ -1487,6 +1513,16 @@ export default function psyclawExtension(pi) {
|
|
|
1487
1513
|
});
|
|
1488
1514
|
if (!legacyTestApi && typeof pi.on === "function")
|
|
1489
1515
|
pi.on("tool_call", async (event, ctx) => {
|
|
1516
|
+
// Host-teardown hard block runs even without /init — project approvals do not cover this.
|
|
1517
|
+
const commandText = extractToolCommandText(event.toolName, event.input);
|
|
1518
|
+
if (commandText) {
|
|
1519
|
+
const hostOp = classifyIrreversibleHostCommand(commandText);
|
|
1520
|
+
if (hostOp) {
|
|
1521
|
+
const reason = irreversibleHostBlockReason(hostOp);
|
|
1522
|
+
ctx.ui.notify(reason, "error");
|
|
1523
|
+
return { block: true, terminate: true, reason };
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1490
1526
|
const run = await readActiveProject(ctx.cwd);
|
|
1491
1527
|
if (!run || !toolNeedsApproval(event.toolName, event.input))
|
|
1492
1528
|
return;
|