psyclaw 0.31.5 → 0.33.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/dist/src/adapters/pi/extension.js +60 -11
- package/dist/src/adapters/pi/extension.js.map +1 -1
- package/dist/src/analysis/decision-points.d.ts +1 -1
- package/dist/src/analysis/decision-points.js +8 -1
- package/dist/src/analysis/decision-points.js.map +1 -1
- package/dist/src/analysis/prior/apply.d.ts +15 -0
- package/dist/src/analysis/prior/apply.js +98 -0
- package/dist/src/analysis/prior/apply.js.map +1 -0
- package/dist/src/analysis/prior/checks.d.ts +21 -0
- package/dist/src/analysis/prior/checks.js +233 -0
- package/dist/src/analysis/prior/checks.js.map +1 -0
- package/dist/src/analysis/prior/constants.d.ts +33 -0
- package/dist/src/analysis/prior/constants.js +117 -0
- package/dist/src/analysis/prior/constants.js.map +1 -0
- package/dist/src/analysis/prior/gate.d.ts +14 -0
- package/dist/src/analysis/prior/gate.js +93 -0
- package/dist/src/analysis/prior/gate.js.map +1 -0
- package/dist/src/analysis/prior/memory.d.ts +8 -0
- package/dist/src/analysis/prior/memory.js +46 -0
- package/dist/src/analysis/prior/memory.js.map +1 -0
- package/dist/src/analysis/prior/reflect.d.ts +6 -0
- package/dist/src/analysis/prior/reflect.js +48 -0
- package/dist/src/analysis/prior/reflect.js.map +1 -0
- package/dist/src/analysis/prior/render.d.ts +20 -0
- package/dist/src/analysis/prior/render.js +159 -0
- package/dist/src/analysis/prior/render.js.map +1 -0
- package/dist/src/analysis/prior/submit.d.ts +32 -0
- package/dist/src/analysis/prior/submit.js +213 -0
- package/dist/src/analysis/prior/submit.js.map +1 -0
- package/dist/src/analysis/prior/tools.d.ts +6 -0
- package/dist/src/analysis/prior/tools.js +38 -0
- package/dist/src/analysis/prior/tools.js.map +1 -0
- package/dist/src/ars/mode-editor.d.ts +1 -1
- package/dist/src/ars/mode-editor.js +1 -1
- package/dist/src/branding.js +3 -2
- package/dist/src/branding.js.map +1 -1
- package/dist/src/observability/langfuse.js +201 -5
- package/dist/src/observability/langfuse.js.map +1 -1
- package/dist/src/panel/server.js +1 -0
- package/dist/src/panel/server.js.map +1 -1
- package/dist/src/project/workspace.js +1 -1
- package/dist/src/project/workspace.js.map +1 -1
- package/dist/src/session/help.js +9 -3
- package/dist/src/session/help.js.map +1 -1
- package/dist/src/session/modes.d.ts +6 -2
- package/dist/src/session/modes.js +38 -2
- package/dist/src/session/modes.js.map +1 -1
- package/dist/src/skills/recommended.js +1 -0
- package/dist/src/skills/recommended.js.map +1 -1
- package/dist/src/style/cli-ui.js +1 -0
- package/dist/src/style/cli-ui.js.map +1 -1
- package/dist/src/updates/whats-new.js +12 -0
- package/dist/src/updates/whats-new.js.map +1 -1
- package/package.json +1 -1
- package/skills/core/analysis-plan/SKILL.md +1 -1
- package/skills/core/prior-plan/SKILL.md +53 -0
|
@@ -3,6 +3,10 @@ import { isInstructionResult, isObservationEvidence, maskToolObservationsStable,
|
|
|
3
3
|
import { outputLogFooter, persistToolOutput } from "../../analysis/output-log.js";
|
|
4
4
|
import { applyShellTimeout, isShellTimeout, SHELL_TIMEOUT_HINT, ShellClock } from "../../analysis/shell-timeout.js";
|
|
5
5
|
import { registerAnalysisRuntimeTools } from "../../analysis/runtime-tools.js";
|
|
6
|
+
import { priorToolBlock } from "../../analysis/prior/gate.js";
|
|
7
|
+
import { readPriorMemory } from "../../analysis/prior/memory.js";
|
|
8
|
+
import { priorApproved, priorPlanExists, priorRecallExists, recordPriorApproval } from "../../analysis/prior/submit.js";
|
|
9
|
+
import { registerPriorTools } from "../../analysis/prior/tools.js";
|
|
6
10
|
import { PSYCLAW_VERSION } from "../../branding.js";
|
|
7
11
|
import { takeWhatsNew } from "../../updates/whats-new.js";
|
|
8
12
|
import { formatDataAccess, loadDataAccess, redactScriptOnlyOutput, scriptOnlyBlock, setDataAccess } from "../../safety/data-access.js";
|
|
@@ -45,7 +49,7 @@ import { composeMethodInjection, injectedTopicsFor, readSkillPreferences, refere
|
|
|
45
49
|
import { formatAnalysisPlanTakeover, resolveStatsIntent, } from "../../analysis/stats-router.js";
|
|
46
50
|
import { arsRoot } from "../../ars/pi-panel-executor.js";
|
|
47
51
|
import { ArsModeEditor, isArsModeEditorText } from "../../ars/mode-editor.js";
|
|
48
|
-
import { MODE_STATUS, detectChatModeMismatch, formatChatModeMismatchNotice, nextSessionMode, parseSessionMode, sessionModePrompt, unattendedAnalysisPrompt, } from "../../session/modes.js";
|
|
52
|
+
import { MODE_STATUS, detectChatModeMismatch, formatChatModeMismatchNotice, nextSessionMode, parseSessionMode, analysisFollowsPriorPrompt, sessionModePrompt, unattendedAnalysisPrompt, unattendedPriorPrompt, } from "../../session/modes.js";
|
|
49
53
|
import { continuouslyWorkWarningText, isContinuouslyWorkEnabled, } from "../../session/continuously-work.js";
|
|
50
54
|
import { assertHumanVerifyGate, formatVerifyChecklist, isNaturalPlanConfirm, isPlanRitualConfirm, PLAN_RITUAL_PHRASE, ensureDefaultVerifyChecklist, loadVerifyChecklist, recordHumanVerification } from "../../verify/checklist.js";
|
|
51
55
|
import { formatSessionHelp, formatSessionHelpBrief } from "../../session/help.js";
|
|
@@ -106,7 +110,7 @@ async function notifyAfterSkillChange(ctx, summary, level = "info") {
|
|
|
106
110
|
return "manual-reload";
|
|
107
111
|
}
|
|
108
112
|
const activeAgentRuns = new Set();
|
|
109
|
-
const CORE_SKILLS = new Set(["academic-grill", "research-intake", "evidence-capture", "citation-audit", "analysis-plan"]);
|
|
113
|
+
const CORE_SKILLS = new Set(["academic-grill", "research-intake", "evidence-capture", "citation-audit", "analysis-plan", "prior-plan"]);
|
|
110
114
|
function findLastMatching(items, predicate) {
|
|
111
115
|
for (let index = items.length - 1; index >= 0; index -= 1) {
|
|
112
116
|
const item = items[index];
|
|
@@ -1222,7 +1226,7 @@ export default function psyclawExtension(pi) {
|
|
|
1222
1226
|
};
|
|
1223
1227
|
if (!legacyTestApi && typeof pi.registerShortcut === "function") {
|
|
1224
1228
|
pi.registerShortcut("shift+tab", {
|
|
1225
|
-
description: "Cycle chat → analysis → academic",
|
|
1229
|
+
description: "Cycle chat → analysis → academic → prior",
|
|
1226
1230
|
handler: () => {
|
|
1227
1231
|
cycleSessionMode();
|
|
1228
1232
|
},
|
|
@@ -1306,12 +1310,22 @@ export default function psyclawExtension(pi) {
|
|
|
1306
1310
|
return { systemPrompt: `${event.systemPrompt}\n\n${prompt}` };
|
|
1307
1311
|
});
|
|
1308
1312
|
if (!legacyTestApi && typeof pi.on === "function")
|
|
1309
|
-
pi.on("before_agent_start", (event, ctx) => {
|
|
1313
|
+
pi.on("before_agent_start", async (event, ctx) => {
|
|
1310
1314
|
const restored = restoreSessionMode(ctx?.sessionManager);
|
|
1311
1315
|
sessionMode = restored;
|
|
1312
|
-
const
|
|
1313
|
-
?
|
|
1314
|
-
:
|
|
1316
|
+
const priorMemory = restored === "chat" || restored === "analysis"
|
|
1317
|
+
? await readPriorMemory(ctx?.cwd ?? process.cwd())
|
|
1318
|
+
: "";
|
|
1319
|
+
let modeBlock = sessionModePrompt(restored);
|
|
1320
|
+
if (restored === "analysis" && ctx && !ctx.hasUI)
|
|
1321
|
+
modeBlock = `${modeBlock}\n\n${unattendedAnalysisPrompt()}`;
|
|
1322
|
+
if (restored === "prior" && ctx && !ctx.hasUI)
|
|
1323
|
+
modeBlock = `${modeBlock}\n\n${unattendedPriorPrompt()}`;
|
|
1324
|
+
if (priorMemory && restored === "chat") {
|
|
1325
|
+
modeBlock = `## PsyClaw mode: chat\nPlain assistant on the Pi harness. Follow the prior plan memory below for later analysis. Do not ask for a mode switch.\n\n${priorMemory}`;
|
|
1326
|
+
}
|
|
1327
|
+
if (priorMemory && restored === "analysis")
|
|
1328
|
+
modeBlock = `${modeBlock}\n\n${analysisFollowsPriorPrompt(priorMemory)}`;
|
|
1315
1329
|
if (restored === "academic" || isArsPiTurn(event.systemPrompt) || isArsPiActive(ctx?.sessionManager)) {
|
|
1316
1330
|
return {
|
|
1317
1331
|
systemPrompt: `${event.systemPrompt}\n\n${modeBlock}\n\n${psyclawArsPatch({
|
|
@@ -1431,6 +1445,24 @@ export default function psyclawExtension(pi) {
|
|
|
1431
1445
|
};
|
|
1432
1446
|
}
|
|
1433
1447
|
}
|
|
1448
|
+
if (mode === "prior" && isPlanRitualConfirm(trimmed)) {
|
|
1449
|
+
const result = await recordPriorApproval(ctx.cwd);
|
|
1450
|
+
if (result.handoff)
|
|
1451
|
+
applySessionMode("chat");
|
|
1452
|
+
ctx.ui.notify(!result.handoff
|
|
1453
|
+
? result.message
|
|
1454
|
+
: result.runFailed
|
|
1455
|
+
? "脚本已按确认结果改好,但执行失败。报错末尾在对话里,完整日志没有放进来。"
|
|
1456
|
+
: "脚本已按确认结果改好并执行。当前是普通对话,可以使用 skill。", result.ok && !result.runFailed ? "info" : "warning");
|
|
1457
|
+
return {
|
|
1458
|
+
action: "transform",
|
|
1459
|
+
text: !result.handoff
|
|
1460
|
+
? `User typed the approval phrase, but the prior plan is not ready. ${result.message} Do not execute.`
|
|
1461
|
+
: result.runFailed
|
|
1462
|
+
? result.message
|
|
1463
|
+
: `User approved the prior plan ("${PLAN_RITUAL_PHRASE}"). The script was updated from the confirmed choices and has already been run. ${result.message} The session is now plain chat. Skills may be used. Do not ask to switch modes and do not run the script again unless the researcher asks.`,
|
|
1464
|
+
};
|
|
1465
|
+
}
|
|
1434
1466
|
// Plan confirmations: soft「可以」= per-node / method acknowledge; ritual phrase = authorize execute.
|
|
1435
1467
|
if (mode === "analysis" && (isPlanRitualConfirm(trimmed) || isNaturalPlanConfirm(trimmed))) {
|
|
1436
1468
|
const plan = await readActiveAnalysisPlan(ctx.cwd);
|
|
@@ -1624,6 +1656,22 @@ export default function psyclawExtension(pi) {
|
|
|
1624
1656
|
catch {
|
|
1625
1657
|
// A broken checker must not take down unrelated tools. Defaults still apply on the next call.
|
|
1626
1658
|
}
|
|
1659
|
+
if (sessionMode === "prior") {
|
|
1660
|
+
try {
|
|
1661
|
+
const priorReason = priorToolBlock(sessionMode, event.toolName, event.input, {
|
|
1662
|
+
recallReady: await priorRecallExists(ctx.cwd),
|
|
1663
|
+
planReady: await priorPlanExists(ctx.cwd),
|
|
1664
|
+
approved: await priorApproved(ctx.cwd),
|
|
1665
|
+
});
|
|
1666
|
+
if (priorReason) {
|
|
1667
|
+
ctx.ui.notify(priorReason, "warning");
|
|
1668
|
+
return { block: true, reason: priorReason };
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
catch {
|
|
1672
|
+
// A broken prior gate must not take down unrelated tools.
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1627
1675
|
const run = await readActiveProject(ctx.cwd);
|
|
1628
1676
|
if (!run || !toolNeedsApproval(event.toolName, event.input))
|
|
1629
1677
|
return;
|
|
@@ -1732,7 +1780,7 @@ export default function psyclawExtension(pi) {
|
|
|
1732
1780
|
ctx.ui.notify([
|
|
1733
1781
|
`已检测到既有工作区,无需重新建仓:${project.id}`,
|
|
1734
1782
|
"规范目录与 psyclaw.md 已存在;跨会话可直接继续 analysis / academic。",
|
|
1735
|
-
"Shift+Tab:chat → analysis → academic · 输入 /help 查看速览。",
|
|
1783
|
+
"Shift+Tab:chat → analysis → academic → prior · 输入 /help 查看速览。",
|
|
1736
1784
|
].join("\n"), "info");
|
|
1737
1785
|
return;
|
|
1738
1786
|
}
|
|
@@ -1740,9 +1788,9 @@ export default function psyclawExtension(pi) {
|
|
|
1740
1788
|
`工作仓库已初始化:${project.id}`,
|
|
1741
1789
|
"已创建 data/raw|clean|secret、analysis/、literature/、paper/、psyclaw.md、.psyclaw/",
|
|
1742
1790
|
"data/secret 默认 script-only:模型不能直接读内容,分析脚本可以打开。/data-access 可改级别或指定其他文件。",
|
|
1743
|
-
"Shift+Tab:chat → analysis → academic",
|
|
1791
|
+
"Shift+Tab:chat → analysis → academic → prior",
|
|
1744
1792
|
"Thinking:Ctrl+Shift+T",
|
|
1745
|
-
"
|
|
1793
|
+
"prior 先回忆再出方案,确认后直接跑脚本并回到普通对话;analysis 仍可直接跑数;写作审稿切到 academic。输入 /help 查看速览。",
|
|
1746
1794
|
].join("\n"), "info");
|
|
1747
1795
|
}
|
|
1748
1796
|
catch (error) {
|
|
@@ -2324,6 +2372,7 @@ export default function psyclawExtension(pi) {
|
|
|
2324
2372
|
});
|
|
2325
2373
|
if (typeof pi.registerTool === "function") {
|
|
2326
2374
|
registerAnalysisRuntimeTools(pi);
|
|
2375
|
+
registerPriorTools(pi, () => sessionMode);
|
|
2327
2376
|
pi.registerTool({
|
|
2328
2377
|
name: "psyclaw_research_decision",
|
|
2329
2378
|
label: "Research decision",
|
|
@@ -2607,7 +2656,7 @@ export default function psyclawExtension(pi) {
|
|
|
2607
2656
|
label: "Research skill",
|
|
2608
2657
|
description: "Load one trusted bundled psyclaw core skill and make its use visible to the user. Use this instead of directly reading a core SKILL.md file.",
|
|
2609
2658
|
parameters: Type.Object({
|
|
2610
|
-
name: Type.String({ description: "Core skill name: academic-grill, research-intake, evidence-capture, citation-audit, or
|
|
2659
|
+
name: Type.String({ description: "Core skill name: academic-grill, research-intake, evidence-capture, citation-audit, analysis-plan, or prior-plan" }),
|
|
2611
2660
|
purpose: Type.Optional(Type.String({ description: "Short user-facing reason for using this skill now" })),
|
|
2612
2661
|
}),
|
|
2613
2662
|
executionMode: "sequential",
|