psyclaw 0.33.1 → 0.34.0-preview.3
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/apps/panel/index.html +16 -16
- package/dist/src/adapters/pi/arg-repair.d.ts +27 -0
- package/dist/src/adapters/pi/arg-repair.js +177 -0
- package/dist/src/adapters/pi/arg-repair.js.map +1 -0
- package/dist/src/adapters/pi/extension.js +1845 -606
- package/dist/src/adapters/pi/extension.js.map +1 -1
- package/dist/src/adapters/pi/observation-mask.d.ts +19 -0
- package/dist/src/adapters/pi/observation-mask.js +107 -2
- package/dist/src/adapters/pi/observation-mask.js.map +1 -1
- package/dist/src/adapters/pi/session.js +1 -1
- package/dist/src/adapters/pi/session.js.map +1 -1
- package/dist/src/analysis/decision-points.d.ts +4 -9
- package/dist/src/analysis/decision-points.js +20 -74
- package/dist/src/analysis/decision-points.js.map +1 -1
- package/dist/src/analysis/estimand.d.ts +127 -0
- package/dist/src/analysis/estimand.js +526 -0
- package/dist/src/analysis/estimand.js.map +1 -0
- package/dist/src/analysis/method-rules.d.ts +6 -0
- package/dist/src/analysis/method-rules.js +20 -3
- package/dist/src/analysis/method-rules.js.map +1 -1
- package/dist/src/analysis/package-net.d.ts +106 -0
- package/dist/src/analysis/package-net.js +277 -0
- package/dist/src/analysis/package-net.js.map +1 -0
- package/dist/src/analysis/plan.d.ts +6 -2
- package/dist/src/analysis/plan.js +34 -17
- package/dist/src/analysis/plan.js.map +1 -1
- package/dist/src/analysis/runtime-tools.d.ts +0 -6
- package/dist/src/analysis/runtime-tools.js +0 -156
- package/dist/src/analysis/runtime-tools.js.map +1 -1
- package/dist/src/analysis/shell-timeout.d.ts +21 -0
- package/dist/src/analysis/shell-timeout.js +87 -1
- package/dist/src/analysis/shell-timeout.js.map +1 -1
- package/dist/src/analysis/skill-resolution.d.ts +18 -2
- package/dist/src/analysis/skill-resolution.js +32 -17
- package/dist/src/analysis/skill-resolution.js.map +1 -1
- package/dist/src/analysis/stats-router.d.ts +4 -8
- package/dist/src/analysis/stats-router.js +21 -23
- package/dist/src/analysis/stats-router.js.map +1 -1
- package/dist/src/ars/academic-router.d.ts +8 -8
- package/dist/src/ars/academic-router.js +22 -35
- package/dist/src/ars/academic-router.js.map +1 -1
- package/dist/src/ars/doctor.js +1 -2
- package/dist/src/ars/doctor.js.map +1 -1
- package/dist/src/ars/mode-editor.d.ts +7 -2
- package/dist/src/ars/mode-editor.js +15 -16
- package/dist/src/ars/mode-editor.js.map +1 -1
- package/dist/src/brain/brain.d.ts +64 -0
- package/dist/src/brain/brain.js +206 -0
- package/dist/src/brain/brain.js.map +1 -0
- package/dist/src/brain/preferences.d.ts +19 -0
- package/dist/src/brain/preferences.js +80 -0
- package/dist/src/brain/preferences.js.map +1 -0
- package/dist/src/branding.d.ts +19 -0
- package/dist/src/branding.js +65 -33
- package/dist/src/branding.js.map +1 -1
- package/dist/src/chat.d.ts +2 -2
- package/dist/src/chat.js +20 -4
- package/dist/src/chat.js.map +1 -1
- package/dist/src/index.d.ts +1 -2
- package/dist/src/index.js +1 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/install/installer.js +0 -5
- package/dist/src/install/installer.js.map +1 -1
- package/dist/src/integrations/mcp-config.d.ts +27 -0
- package/dist/src/integrations/mcp-config.js +120 -0
- package/dist/src/integrations/mcp-config.js.map +1 -0
- package/dist/src/integrations/mcp-format.d.ts +6 -0
- package/dist/src/integrations/mcp-format.js +52 -0
- package/dist/src/integrations/mcp-format.js.map +1 -0
- package/dist/src/orchestration/research-agents.js +1 -1
- package/dist/src/orchestration/research-agents.js.map +1 -1
- package/dist/src/orchestration/runner.d.ts +0 -1
- package/dist/src/orchestration/runner.js +0 -3
- package/dist/src/orchestration/runner.js.map +1 -1
- package/dist/src/orchestration/scheduler.js +0 -31
- package/dist/src/orchestration/scheduler.js.map +1 -1
- package/dist/src/panel/server.js +11 -14
- package/dist/src/panel/server.js.map +1 -1
- package/dist/src/project/hitl.js +3 -3
- package/dist/src/project/hitl.js.map +1 -1
- package/dist/src/project/workspace.js +8 -20
- package/dist/src/project/workspace.js.map +1 -1
- package/dist/src/research/decisions.d.ts +115 -0
- package/dist/src/research/decisions.js +284 -0
- package/dist/src/research/decisions.js.map +1 -0
- package/dist/src/research/intent.d.ts +90 -0
- package/dist/src/research/intent.js +175 -0
- package/dist/src/research/intent.js.map +1 -0
- package/dist/src/research/plan-message.d.ts +117 -0
- package/dist/src/research/plan-message.js +187 -0
- package/dist/src/research/plan-message.js.map +1 -0
- package/dist/src/research/practice.d.ts +33 -0
- package/dist/src/research/practice.js +160 -0
- package/dist/src/research/practice.js.map +1 -0
- package/dist/src/router/decision-model.d.ts +73 -0
- package/dist/src/router/decision-model.js +206 -0
- package/dist/src/router/decision-model.js.map +1 -0
- package/dist/src/router/llm-judge.d.ts +13 -0
- package/dist/src/router/llm-judge.js +38 -0
- package/dist/src/router/llm-judge.js.map +1 -0
- package/dist/src/rules/user-rules.js.map +1 -1
- package/dist/src/safety/data-access.js +4 -4
- package/dist/src/safety/data-access.js.map +1 -1
- package/dist/src/safety/secret-marks.d.ts +44 -0
- package/dist/src/safety/secret-marks.js +88 -0
- package/dist/src/safety/secret-marks.js.map +1 -0
- package/dist/src/session/continuously-work.js +1 -1
- package/dist/src/session/continuously-work.js.map +1 -1
- package/dist/src/session/help.js +30 -38
- package/dist/src/session/help.js.map +1 -1
- package/dist/src/session/modes.d.ts +24 -21
- package/dist/src/session/modes.js +82 -131
- package/dist/src/session/modes.js.map +1 -1
- package/dist/src/session/skill-invoke.d.ts +71 -0
- package/dist/src/session/skill-invoke.js +244 -0
- package/dist/src/session/skill-invoke.js.map +1 -0
- package/dist/src/session/skill-reference.d.ts +15 -0
- package/dist/src/session/skill-reference.js +35 -0
- package/dist/src/session/skill-reference.js.map +1 -0
- package/dist/src/skills/recommended.js +0 -2
- package/dist/src/skills/recommended.js.map +1 -1
- package/dist/src/skills/skill-pick.d.ts +25 -0
- package/dist/src/skills/skill-pick.js +83 -0
- package/dist/src/skills/skill-pick.js.map +1 -0
- package/dist/src/skills/user-skills.d.ts +52 -3
- package/dist/src/skills/user-skills.js +107 -23
- package/dist/src/skills/user-skills.js.map +1 -1
- package/dist/src/style/cli-ui.js +16 -13
- package/dist/src/style/cli-ui.js.map +1 -1
- package/dist/src/tui/biosignal-wizard.js +2 -2
- package/dist/src/tui/biosignal-wizard.js.map +1 -1
- package/dist/src/tui/wake-options.d.ts +2 -2
- package/dist/src/tui/wake-options.js +8 -5
- package/dist/src/tui/wake-options.js.map +1 -1
- package/dist/src/updates/check.js +4 -2
- package/dist/src/updates/check.js.map +1 -1
- package/dist/src/updates/registry.d.ts +2 -1
- package/dist/src/updates/registry.js +2 -2
- package/dist/src/updates/registry.js.map +1 -1
- package/dist/src/updates/status.d.ts +9 -2
- package/dist/src/updates/status.js +43 -6
- package/dist/src/updates/status.js.map +1 -1
- package/dist/src/updates/update.js +7 -3
- package/dist/src/updates/update.js.map +1 -1
- package/dist/src/verify/checklist.d.ts +1 -1
- package/dist/src/verify/checklist.js +5 -5
- package/dist/src/verify/checklist.js.map +1 -1
- package/dist/src/wake-options/runtime.d.ts +9 -0
- package/dist/src/wake-options/runtime.js +39 -1
- package/dist/src/wake-options/runtime.js.map +1 -1
- package/dist/src/workflows/academic-export.js.map +1 -1
- package/dist/src/workflows/meta-analysis.js +1 -1
- package/dist/src/workflows/meta-analysis.js.map +1 -1
- package/package.json +5 -4
- package/scripts/psyclaw.mjs +5 -0
- package/scripts/rebrand-pi.mjs +62 -3
- package/skills/core/academic-grill/SKILL.md +3 -3
- package/skills/core/analysis-plan/SKILL.md +64 -35
- package/skills/core/manifest.json +12 -4
- package/skills/core/package-install/SKILL.md +35 -0
- package/skills/core/package-install/pkgnet.py +178 -0
- package/skills/recommended/mcp-catalog.json +1 -1
- package/dist/src/analysis/prior/apply.d.ts +0 -15
- package/dist/src/analysis/prior/apply.js +0 -98
- package/dist/src/analysis/prior/apply.js.map +0 -1
- package/dist/src/analysis/prior/checks.d.ts +0 -21
- package/dist/src/analysis/prior/checks.js +0 -233
- package/dist/src/analysis/prior/checks.js.map +0 -1
- package/dist/src/analysis/prior/constants.d.ts +0 -33
- package/dist/src/analysis/prior/constants.js +0 -117
- package/dist/src/analysis/prior/constants.js.map +0 -1
- package/dist/src/analysis/prior/gate.d.ts +0 -14
- package/dist/src/analysis/prior/gate.js +0 -93
- package/dist/src/analysis/prior/gate.js.map +0 -1
- package/dist/src/analysis/prior/memory.d.ts +0 -8
- package/dist/src/analysis/prior/memory.js +0 -46
- package/dist/src/analysis/prior/memory.js.map +0 -1
- package/dist/src/analysis/prior/reflect.d.ts +0 -6
- package/dist/src/analysis/prior/reflect.js +0 -48
- package/dist/src/analysis/prior/reflect.js.map +0 -1
- package/dist/src/analysis/prior/render.d.ts +0 -20
- package/dist/src/analysis/prior/render.js +0 -159
- package/dist/src/analysis/prior/render.js.map +0 -1
- package/dist/src/analysis/prior/submit.d.ts +0 -32
- package/dist/src/analysis/prior/submit.js +0 -213
- package/dist/src/analysis/prior/submit.js.map +0 -1
- package/dist/src/analysis/prior/tools.d.ts +0 -6
- package/dist/src/analysis/prior/tools.js +0 -38
- package/dist/src/analysis/prior/tools.js.map +0 -1
- package/dist/src/research/choice.d.ts +0 -16
- package/dist/src/research/choice.js +0 -25
- package/dist/src/research/choice.js.map +0 -1
- package/dist/src/skills/registry.d.ts +0 -28
- package/dist/src/skills/registry.js +0 -550
- package/dist/src/skills/registry.js.map +0 -1
- package/skills/core/prior-plan/SKILL.md +0 -53
|
@@ -1,70 +1,37 @@
|
|
|
1
1
|
import { RESIDENT_METHOD_RULES } from "../analysis/method-rules.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export const SESSION_MODES = ["chat", "analysis", "academic", "prior"];
|
|
2
|
+
import { ESTIMAND_PROMPT } from "../analysis/estimand.js";
|
|
3
|
+
export const SESSION_MODES = ["basic", "research", "estimand"];
|
|
5
4
|
/** Footer status label. */
|
|
6
5
|
export const MODE_STATUS = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
prior: "prior",
|
|
6
|
+
basic: "基础",
|
|
7
|
+
research: "研究",
|
|
8
|
+
estimand: "分析",
|
|
11
9
|
};
|
|
12
10
|
export const MODE_BORDER = {
|
|
13
|
-
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
// violet for prior (recall before data)
|
|
19
|
-
prior: (text) => `\x1b[38;2;180;142;214m${text}\x1b[39m`,
|
|
11
|
+
basic: undefined,
|
|
12
|
+
// teal for research mode
|
|
13
|
+
research: (text) => `\x1b[38;2;46;196;182m${text}\x1b[39m`,
|
|
14
|
+
// amber for analysis (estimand) mode
|
|
15
|
+
estimand: (text) => `\x1b[38;2;229;192;123m${text}\x1b[39m`,
|
|
20
16
|
};
|
|
17
|
+
/** Shift+Tab cycle: basic → research → analysis (estimand) → basic. */
|
|
21
18
|
export function nextSessionMode(current) {
|
|
22
|
-
|
|
23
|
-
return SESSION_MODES[(index + 1) % SESSION_MODES.length] ?? "chat";
|
|
19
|
+
return current === "basic" ? "research" : current === "research" ? "estimand" : "basic";
|
|
24
20
|
}
|
|
25
21
|
export function parseSessionMode(value) {
|
|
26
|
-
if (value === "
|
|
22
|
+
if (value === "basic" || value === "research" || value === "estimand")
|
|
27
23
|
return value;
|
|
24
|
+
if (value === "分析")
|
|
25
|
+
return "estimand";
|
|
26
|
+
if (value === "chat" || value === "default")
|
|
27
|
+
return "basic";
|
|
28
|
+
if (value === "analysis" || value === "academic" || value === "prior" || value === "plan")
|
|
29
|
+
return "research";
|
|
28
30
|
return undefined;
|
|
29
31
|
}
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*/
|
|
34
|
-
export function detectChatModeMismatch(text) {
|
|
35
|
-
// Explicit literature/writing/review intent wins when the same request also
|
|
36
|
-
// mentions an analysis construct (for example, a literature review about
|
|
37
|
-
// multiple mediation). The research topic must not reroute the requested
|
|
38
|
-
// academic task into analysis mode.
|
|
39
|
-
if (resolveAcademicSoftRoute(text)) {
|
|
40
|
-
return {
|
|
41
|
-
target: "academic",
|
|
42
|
-
notify: "当前是 chat 模式,但请求像是文献调研/写作/审稿。请按 Shift+Tab 直到底部显示 academic 后再继续(不会自动切换)。",
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
if (resolveStatsIntent(text)) {
|
|
46
|
-
return {
|
|
47
|
-
target: "analysis",
|
|
48
|
-
notify: "当前是 chat 模式,但请求像是数据分析。请按 Shift+Tab 直到底部显示 analysis 后再继续(不会自动切换)。",
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
/** Transform user text so the model must surface the mode reminder in its reply. */
|
|
54
|
-
export function formatChatModeMismatchNotice(mismatch, userText) {
|
|
55
|
-
const targetLabel = mismatch.target === "analysis" ? "analysis(数据分析)" : "academic(文献/写作/审稿)";
|
|
56
|
-
return [
|
|
57
|
-
"[PsyClaw mode notice — mandatory]",
|
|
58
|
-
`The user is in chat mode, but this request fits ${targetLabel}.`,
|
|
59
|
-
`You MUST open your reply with an explicit reminder to press Shift+Tab until the footer shows "${mismatch.target}".`,
|
|
60
|
-
"Do not auto-switch modes. Do not run analysis-plan or academic soft-route takeover while still in chat.",
|
|
61
|
-
mismatch.target === "analysis"
|
|
62
|
-
? "You may briefly discuss options, but do not start a structured analysis workflow as if analysis mode were active."
|
|
63
|
-
: "You may briefly discuss options, but do not load ARS/Nature/compose skills as if academic mode were active.",
|
|
64
|
-
"",
|
|
65
|
-
"User request:",
|
|
66
|
-
userText.trim(),
|
|
67
|
-
].join("\n");
|
|
32
|
+
/** Starting mode when the session has none saved: PSYCLAW_MODE, else research in a PsyClaw workspace. */
|
|
33
|
+
export function startingSessionMode(hasWorkspace, env = process.env) {
|
|
34
|
+
return parseSessionMode(env.PSYCLAW_MODE?.trim()) ?? (hasWorkspace ? "research" : "basic");
|
|
68
35
|
}
|
|
69
36
|
/** Extra analysis-mode guidance for unattended runs (no UI, e.g. `psyclaw run` / Pi --print). */
|
|
70
37
|
export function unattendedAnalysisPrompt() {
|
|
@@ -72,100 +39,84 @@ export function unattendedAnalysisPrompt() {
|
|
|
72
39
|
"## Unattended run (no interactive UI)",
|
|
73
40
|
"Nobody can review intermediate files in this run, so skip the steps that only serve an interactive reviewer. These rules take precedence over the analysis workflow above where they conflict.",
|
|
74
41
|
"- Take the task from the brief and the files it names. Do not explore plan or HANDOFF templates to understand the task. Skills listed in the system prompt may be read.",
|
|
75
|
-
"- If the task names where deliverables go, write the analysis
|
|
42
|
+
"- If the task names where deliverables go, write the analysis modules and entrypoint there and run them from there. Do not keep a second copy under analysis/scripts/.",
|
|
76
43
|
"- One-off exploratory checks (value counts, cross-tabs, a variable's range) may run inline through bash with `Rscript -e` or `python3 -c`. Write a script file only for analyses that belong in the reproducible pipeline.",
|
|
77
44
|
"- Explore the data in one or two batched checks (structure, codings, value counts, missingness, group cross-tabs together), not one variable per call.",
|
|
78
|
-
"- Write the
|
|
45
|
+
"- Write the analysis modules once the plan lists every model. Each module reads the previous step's saved files; fix errors in the module that failed and rerun only it; add a late analysis as one new module.",
|
|
79
46
|
"- Have the script print a short summary and write every reported number to tables or a key-numbers file. Read that file; do not page through long logs with sed, awk or tail.",
|
|
80
47
|
"- When an approver tool is available, ask only about decisions the brief leaves open that change the analysis, that is, the decision points settled by intent (sample rules, coding and scoring, missing data, model specification, inference and decision rules). Settle one decision per question: each option is one way to settle that single point, within the tool's option limit. Do not bundle several choices (for example interval type, number of resamples and a decision rule) into one option.",
|
|
81
48
|
"- Offer the standard alternatives for that point first (for example 1000, 5000 or 10000 bootstrap resamples; a percentile or BCa interval; each exclusion rule as its own question rather than a final N), and state the facts each option relies on so that their counts add up to the total.",
|
|
82
49
|
"- If every option is rejected, do not switch to a new bundle: split the rejected options into single components and ask about each until each is settled. When the approver says which part of a plan is wrong, ask about the rules of that part one at a time, not about its result (each exclusion rule, not which N).",
|
|
83
|
-
"- Without an approver,
|
|
84
|
-
"- Lock the verdict rules (alpha, multiplicity family and method, what counts as support) in the plan before the first outcome model. Record any later change
|
|
50
|
+
"- Without an approver, record each decision point with psyclaw_decide: by brief (quote the materials) or by analyst (the convention, as the reason); a point that depends on the researcher's intent is by analyst with the reason 'the researcher was not available'. For each such point, make the option closest to the brief's wording primary and run the main alternative as a labelled sensitivity analysis; when their conclusions differ, report both in the conclusion. A framework default or method rule does not settle an intent row.",
|
|
51
|
+
"- Lock the verdict rules (alpha, multiplicity family and method, what counts as support) in the plan before the first outcome model. Record any later change with psyclaw_decide (same id) as a deviation with its reason.",
|
|
85
52
|
"- Before settling a standard element yourself, ask whether it was planned: scale scoring, missing-data handling, a latent or measurement model and its estimator, fit criteria, and decision rules such as an equivalence bound.",
|
|
86
53
|
"- Ask for each approval of a whole plan or report once; if it does not settle, proceed and record that in the report.",
|
|
87
|
-
"- Costly computations: time a bootstrap, permutation test, simulation or repeated refit at a small size first (for example B = 50 or a subsample) and estimate the full run time. If it exceeds a few minutes, use an analytic equivalent or fewer draws yourself, without asking, and record the timing and the choice
|
|
54
|
+
"- Costly computations: time a bootstrap, permutation test, simulation or repeated refit at a small size first (for example B = 50 or a subsample) and estimate the full run time. If it exceeds a few minutes, use an analytic equivalent or fewer draws yourself, without asking, and record the timing and the choice with psyclaw_decide (by analyst).",
|
|
88
55
|
"- Keep each timing probe under a minute: start at a few hundred rows or units and scale up only if it finishes fast, and wrap it in `timeout 120`. A probe that needs longer already tells you the full run is too slow.",
|
|
89
56
|
"- Once a script takes more than a few minutes, save each fitted model and costly result to disk (saveRDS or pickle) and load it when the inputs have not changed. After an edit, rerun only the section that changed, not the whole script; run the full script once more at the end.",
|
|
90
|
-
"- Do not run /
|
|
57
|
+
"- Do not run /check quick, /check full or a re-implementation of the analysis in a second language unless the task asks for it. State in the report that the results were not cross-checked (未经核对).",
|
|
91
58
|
"- Do not produce figures unless the task asks for them.",
|
|
92
59
|
"- Fill in analysis/plans/plan.md once, before executing. Do not write analysis/HANDOFF.md unless the task asks for it.",
|
|
93
60
|
].join("\n");
|
|
94
61
|
}
|
|
95
|
-
/**
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
].join("\n");
|
|
105
|
-
}
|
|
106
|
-
/** Analysis already has a settled prior plan. These lines take precedence over filling or re-approving that plan. */
|
|
107
|
-
export function analysisFollowsPriorPrompt(memory) {
|
|
108
|
-
return [
|
|
109
|
-
"## Settled prior plan",
|
|
110
|
-
"This plan is already approved. Do not refill analysis/plans/plan.md and do not ask for 「我已审阅并批准本方案」 again. Continue from the script and the rows below.",
|
|
111
|
-
memory,
|
|
112
|
-
].join("\n\n");
|
|
113
|
-
}
|
|
114
|
-
/** Mode-specific guidance appended while that sticky mode is active. */
|
|
115
|
-
export function sessionModePrompt(mode) {
|
|
116
|
-
if (mode === "chat") {
|
|
117
|
-
return [
|
|
118
|
-
"## PsyClaw mode: chat",
|
|
119
|
-
"Plain assistant on the Pi harness. Do not force research workflows or ARS stages.",
|
|
120
|
-
"If the user expresses data-analysis or academic writing/review intent while in chat, you MUST remind them to press Shift+Tab to analysis or academic. Never silently treat chat as those modes. Never auto-switch.",
|
|
121
|
-
"If the workspace already has a canonical layout (psyclaw.md + data/ analysis/ literature/ paper/ .psyclaw/), do not ask to /init again. Only suggest /init when those markers are missing.",
|
|
122
|
-
"If the request is vague without a clear research question, remind them they can use /grill. If they seem short on ideas, remind them they can use /brainstorm.",
|
|
123
|
-
"Soft-route takeover only happens after the user switches mode.",
|
|
124
|
-
].join("\n");
|
|
125
|
-
}
|
|
126
|
-
if (mode === "analysis") {
|
|
127
|
-
return [
|
|
128
|
-
"## PsyClaw mode: analysis",
|
|
129
|
-
"Pipeline: clarify → per-analysis human choices → overall typed ritual「我已审阅并批准本方案」→ analyze → ask before AI /crosscheck|/verify → human Panel verify → analysis report → hand off to academic.",
|
|
130
|
-
"Write under data/clean, analysis/scripts|configs|results|plans, and analysis/HANDOFF.md. Never overwrite data/raw (or legacy .psyclaw/data/raw).",
|
|
131
|
-
"Default: write local reproducible analysis scripts under analysis/scripts/ with mature libraries. Use MCP only for special backends (SPSS/Mplus/MNE/Stata) or when the user asks. Do not invent numerical results.",
|
|
132
|
-
"Use psyclaw_data_profile for row counts, columns, and missingness, and with query to look up variables in an xlsx codebook; psyclaw_run_analysis to run any project R or Python script, exploratory or the full pipeline; psyclaw_read_results for a saved confirmatory table. Those results stay in context. A long bash or read result is clipped after you reply; its tail names a log under .psyclaw/cache/tool-output. Use psyclaw_recall_output with a line range to bring that middle back. Edit scripts with edit or write. Do not use bash for cat, sed, ls, grep, find, or python/heredoc file patches. bash is only for a command none of those tools can run.",
|
|
133
|
-
"data/secret is script-only unless .psyclaw/data-access.json sets it to full: do not read, cat, head, or grep its contents. Analysis scripts may open it on disk. data/raw stays readable. The researcher sets other files with /data-access; do not edit that config.",
|
|
134
|
-
"Soft「可以」only settles the current choice card. Script execution requires the typed ritual (unless /plan auto).",
|
|
135
|
-
`Standing method rules: ${RESIDENT_METHOD_RULES}`,
|
|
136
|
-
"Costly computations: before a bootstrap, permutation test, simulation or repeated refit, time it at a small size (for example B = 50 or a subsample) and estimate the full run time. If it exceeds a few minutes, do not decide yourself: present a choice card with the estimate and the options (run in full, fewer draws, an analytic equivalent, or skip), and wait for the user's choice. Keep the timing probe itself under a minute (a few hundred rows or units, wrapped in `timeout 120`).",
|
|
137
|
-
"Slow scripts: once a script takes more than a few minutes, save fitted models and costly results to disk and reload them while their inputs are unchanged; after an edit, rerun only the changed section.",
|
|
138
|
-
"Before asking for plan approval, fill in the hypotheses-to-models table, the decision points and the verdict rules already laid out in analysis/plans/plan.md (one row per hypothesis and exploratory variable; keep the columns). Put each decision point settled by intent on a choice card; settle the brief, data and convention rows yourself and list them in the plan. When the approver can only pick options, the approval card lists approve plus one revise_<element> option per element, each with its concrete alternative.",
|
|
139
|
-
"Do not auto-start `/crosscheck` or `/verify`. Ask first; only run after explicit agreement. Final human approval remains via Panel「核实」or wake-options.",
|
|
140
|
-
"Do not claim analysis complete, write final HANDOFF as done, or invite academic mode until the human verify gate passes.",
|
|
141
|
-
"When proposing more analyses, never close with「已经足够」as prose — offer a concrete new method first and put「已经足够」only as a selectable last option.",
|
|
142
|
-
analysisSoftRoutePrompt(),
|
|
143
|
-
].join("\n");
|
|
144
|
-
}
|
|
145
|
-
if (mode === "prior") {
|
|
62
|
+
/**
|
|
63
|
+
* Mode-specific guidance appended while that sticky mode is active. In research mode the stage
|
|
64
|
+
* picks one section (analyst or writer); before any routing both sections are included. The
|
|
65
|
+
* text changes only when the stage changes, so the prompt cache holds within a stage.
|
|
66
|
+
*/
|
|
67
|
+
export function sessionModePrompt(mode, stage) {
|
|
68
|
+
if (mode === "estimand")
|
|
69
|
+
return ESTIMAND_PROMPT;
|
|
70
|
+
if (mode === "basic") {
|
|
146
71
|
return [
|
|
147
|
-
"## PsyClaw mode:
|
|
148
|
-
"
|
|
149
|
-
"Order: read only BRIEF.md or psyclaw.md → psyclaw_submit_recall → then data profiles are allowed → write labeled constants → psyclaw_submit_plan_script. The script is checked and rendered to analysis/plans/plan.md.",
|
|
150
|
-
"Recall, one block per hypothesis: construct, internal validity, statistical conclusion, dependence. Each recalled approach is a line `- id: description`, and that id must be an option of some constant.",
|
|
151
|
-
"Constants: `NAME = value # @intent value | other — why`, `@declare — why`, or `@pseudo — why`. @intent only for sample, variable construction, or model specification when no common practice settles it and another option would change a named hypothesis verdict. Stage 4 (alpha, tails, multiplicity, equivalence bounds, what counts as support) is always @declare.",
|
|
152
|
-
"If the options agree in this data but could differ in other data, @declare them as equivalent in this data. @pseudo is only when the options must agree for any data.",
|
|
153
|
-
"An @intent constant must be used by a hypothesis-test step. A constant that only appears in a description, an exploration, or a covariate screen is @declare.",
|
|
154
|
-
"Order @intent constants with the largest verdict change first. Ask core cards one at a time, confirm the remaining technical settings on one card, and hold dependent questions until the parent choice is known. Use psyclaw_wake_options, and record each answer with psyclaw_record_choice. Put the constant name in the prompt and the chosen option id in selectedIds.",
|
|
155
|
-
"Soft「可以」settles only the current card. Approval is the typed sentence「我已审阅并批准本方案」. That writes the confirmed values into the constants, runs the script, and returns the session to plain chat. Skills are available only then.",
|
|
156
|
-
"Before labelling a choice @intent, answer: if the researcher picked the other option, which hypothesis verdict would change? If you cannot name it, @declare it.",
|
|
72
|
+
"## PsyClaw mode: basic",
|
|
73
|
+
"No research workflow or approval gates unless the user asks. Shift+Tab switches to research mode; mention it once at most, when the user starts a formal analysis or a paper.",
|
|
157
74
|
].join("\n");
|
|
158
75
|
}
|
|
159
|
-
|
|
160
|
-
"## PsyClaw mode:
|
|
161
|
-
"
|
|
76
|
+
const common = [
|
|
77
|
+
"## PsyClaw mode: research",
|
|
78
|
+
"PsyClaw's research architecture: conversation, data analysis and academic work in one place. Read the request and follow the matching workflow below; do not ask the user to switch modes for analysis or writing.",
|
|
79
|
+
"Skills and MCP servers are available. In research mode a skill is reference material: use its methods and knowledge, but the workflow here (choice cards, plan approval, verify gates) and the researcher's decisions take precedence over any process the skill describes.",
|
|
80
|
+
"If a request to analyse data or write a paper has no clear research question (no stated question, hypothesis, outcome or comparison), do not plan or analyse yet. Ask with psyclaw_ask how to start: brainstorm 2-4 answerable questions from the data (recommended when they have no question yet), grill their rough idea one point at a time, or a short exploratory profile only. For brainstorm or grill, load academic-grill with psyclaw_skill and follow it. /ars brainstorm and /ars grill start the same directly.",
|
|
81
|
+
"",
|
|
82
|
+
];
|
|
83
|
+
const analysis = [
|
|
84
|
+
"### Data analysis",
|
|
85
|
+
"Start from the researcher's intent. Before any plan, ask them openly, with no options, what they want to find out, which outcome matters most, and how they themselves planned to analyse it (several questions in one message are fine). Then restate it with psyclaw_intent action=restate: each item with their words or the materials' words as the quote (leave quote out for what you infer), and flow theory (hypotheses first, then data) or data (explore first, then literature). Post the message it returns and wait; record their reply with psyclaw_intent action=confirm. The plan waits for the confirmed intent.",
|
|
86
|
+
"The whole plan goes to the researcher once: after the intent is confirmed and the data profiled, submit it with psyclaw_plan action=submit and every decision point in `decisions` (per research question: sample and exclusions, outcome coding, contrast, summary measure, model, covariates and reference groups, missing data, intervals and multiplicity, what to report). Mark each point's impact: key when the choice changes the answer to a research question or the conclusion (give why: what changes; at most 4 are shown in full), intent when it depends on what the researcher wants, convention when the field settles it. Open points get 2-3 options and your recommendation; the brief settles a point with by brief + quote; only a convention can be settled by analyst + reason (code puts a research-intent decision to the researcher anyway). Analyses you add beyond the request go into agentAdditions with the reason. Code returns one message: post it as your whole reply and stop. The researcher settles everything in one reply and names missed analyses; record it with psyclaw_plan action=answers. Use psyclaw_ask cards only for what that reply leaves unclear, not before it.",
|
|
87
|
+
"While executing: an analysis you add later is recorded with psyclaw_decide action=add (and the reason); a change to something the researcher or the brief settled is recorded with psyclaw_decide action=change (id, what you do instead, why) and told to the researcher in your next message. Before the final report, call psyclaw_plan action=compare with one check per item the researcher asked for (done + the file that shows it + evidence: words copied from that file showing it was done as decided; changed + what instead and why; or not-done + why) and put the 做法对照 section it returns at the top of the report, unchanged.",
|
|
88
|
+
"Pipeline: intent (open questions → restated intent confirmed) → the whole plan in one message → the researcher's one reply → approval → analyze → 做法对照 → ask before AI /check quick|/check full → human verify → analysis report → hand off to writing.",
|
|
89
|
+
"Write under data/clean, analysis/scripts|configs|results|plans, and analysis/HANDOFF.md. Never overwrite data/raw (or legacy .psyclaw/data/raw).",
|
|
90
|
+
"Check each step as you go in a session that keeps data in memory (use a configured MCP whenever one fits the data, e.g. MNE MCP for EEG/MEG; local scripts only when none fits). Keep the pipeline decoupled: one module per step under analysis/scripts/ plus a thin entrypoint; each module reads the files the previous step saved and writes its own outputs, so it runs on its own. Fix the module that has the problem and rerun only it and the modules after it, never from step 1; run the whole pipeline once at the end. Do not invent numerical results.",
|
|
91
|
+
"Use psyclaw_data_profile for row counts, columns, and missingness, and with query to look up variables in an xlsx codebook; psyclaw_read_results for a saved confirmatory table. Those results stay in context. A long bash or read result is clipped after you reply; its tail names a log under .psyclaw/cache/tool-output. Use psyclaw_recall_output with a line range to bring that middle back. Edit scripts with edit or write. Run project scripts with bash. Do not use bash for cat, sed, ls, grep or find (use read, grep, find, ls), or for python/heredoc file patches (use edit or write).",
|
|
92
|
+
"data/secret is script-only unless .psyclaw/data-access.json sets it to full: do not read, cat, head, or grep its contents. Analysis scripts may open it on disk. data/raw stays readable. The researcher sets other files with /secret; do not edit that config.",
|
|
93
|
+
"Each choice card settles only its own choice. Running the confirmatory scripts needs the researcher's approval of the whole plan: put it on an approval card (approve, or revise one element) or take a plain yes such as「可以」or「批准」once every choice is settled.",
|
|
94
|
+
`Standing method rules: ${RESIDENT_METHOD_RULES}`,
|
|
95
|
+
"Costly computations: before a bootstrap, permutation test, simulation or repeated refit, time it at a small size (for example B = 50 or a subsample) and estimate the full run time. If it exceeds a few minutes, do not decide yourself: present a choice card with the estimate and the options (run in full, fewer draws, an analytic equivalent, or skip), and wait for the user's choice. Keep the timing probe itself under a minute (a few hundred rows or units, wrapped in `timeout 120`).",
|
|
96
|
+
"Slow scripts: once a script takes more than a few minutes, save fitted models and costly results to disk and reload them while their inputs are unchanged; after an edit, rerun only the changed section.",
|
|
97
|
+
"Before submitting the plan, fill in the hypotheses-to-models table in analysis/plans/plan.md (one row per hypothesis and exploratory variable; keep the columns). Plan approval waits until no decision is open.",
|
|
98
|
+
"Do not auto-start `/check quick` or `/check full` (here or in writing). Ask first; only run after explicit agreement. Final human approval remains via Panel「核实」or a choice card.",
|
|
99
|
+
"Do not claim analysis complete, write final HANDOFF as done, or move on to writing until the human verify gate passes.",
|
|
100
|
+
"Reporting: give model coefficients on the model's own scale (log-odds for logit or ordinal logit, with 95% intervals), say how the outcome is coded and which direction a positive coefficient means; an odds ratio may be added but not instead of the coefficient. For a moderation or heterogeneity question, list every interaction term of the model in the report itself (estimate and 95% interval), not only the block test or a file.",
|
|
101
|
+
"While building the plan, when proposing more analyses, never close with「已经足够」as prose — offer a concrete new method first and put「已经足够」only as a selectable last option. Once the deliverables the request names are done, open no more cards for further analyses. With a time budget left, complete the analysis in the same deliverables (standard sensitivity analyses, every model term, the usual breakdowns) without asking; then mention possible extensions in one sentence and stop.",
|
|
102
|
+
"If the researcher ran `/plan auto`, plan approval is skipped but every result must state 未经人审批. After the plan and results, update analysis/HANDOFF.md before writing.",
|
|
103
|
+
"",
|
|
104
|
+
];
|
|
105
|
+
const writing = [
|
|
106
|
+
"### Academic work (literature, writing, review)",
|
|
107
|
+
"Stages stay research → write → review → revise. The know-how for each stage (how to report results, structure a section, word claims, design figures, follow APA and reporting standards) is in PsyClaw's brain: the system prompt lists the pages for this stage; read the ones the task needs with psyclaw_brain action=read and follow the researcher's confirmed preferences. Do not load whole writing skills for know-how the brain has. For a review with separate reviewer seats, psyclaw_ars_multi_agent remains available.",
|
|
162
108
|
"Pace the work: split into human-confirmable nodes (e.g. how the lit review will be done → what will be shown → then retrieval/writing). Do not rush multiple heavy stages in one burst.",
|
|
163
|
-
"
|
|
164
|
-
"
|
|
165
|
-
"Manuscripts go to paper/. Before claiming the full text is done or ready to export/submit: ask before AI `/crosscheck` + `/verify`, then mandatory human Panel/wake verify. Soft mid-draft warnings are fine; finalization is a hard human gate.",
|
|
109
|
+
"Consume analysis/HANDOFF.md and analysis/results when present; do not invent statistics while writing — run the analysis first if numbers are missing.",
|
|
110
|
+
"Manuscripts go to paper/. Finalizing or exporting the full text needs the human Panel/choice-card verify; mid-draft warnings are fine.",
|
|
166
111
|
"Prefer downloading verified open-access fulltexts into literature/pdfs/ — but always ask before each OA download; if download fails or no OA exists, explain and give the DOI link.",
|
|
167
|
-
"
|
|
168
|
-
|
|
169
|
-
|
|
112
|
+
"Writing requests are routed in code to a writing skill, which arrives as an index: its process steps apply; for know-how, prefer the brain's pages.",
|
|
113
|
+
];
|
|
114
|
+
const persona = stage === "analysis"
|
|
115
|
+
? ["You are working as the study's analyst now. If the user turns to literature or writing, the writing workflow loads."]
|
|
116
|
+
: stage === "writing"
|
|
117
|
+
? ["You are working as the academic writer now. If the user asks for a new data analysis, the analysis workflow loads."]
|
|
118
|
+
: [];
|
|
119
|
+
const sections = stage === "analysis" ? analysis : stage === "writing" ? writing : [...analysis, "", ...writing];
|
|
120
|
+
return [...common, ...persona, ...sections].join("\n");
|
|
170
121
|
}
|
|
171
122
|
//# sourceMappingURL=modes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modes.js","sourceRoot":"","sources":["../../../src/session/modes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"modes.js","sourceRoot":"","sources":["../../../src/session/modes.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/** Whether the skill body is already in this conversation (Pi wraps it in `<skill name="...">`). */
|
|
2
|
+
export declare function skillLoaded(branch: readonly unknown[] | undefined, name: string): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Text that loads `name` and then carries `rest`. When the body is already loaded,
|
|
5
|
+
* a reminder replaces it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function invokeSkill(name: string, rest: string, loaded: boolean): string;
|
|
8
|
+
export declare function setSkillPathResolver(resolver: ((name: string) => string | undefined) | undefined): void;
|
|
9
|
+
/** Skill files above this size are loaded as a digest; their specialised sections load on demand. */
|
|
10
|
+
export declare const SKILL_DIGEST_MIN_CHARS = 20000;
|
|
11
|
+
/** The "## " sections of a skill body: heading line plus text. */
|
|
12
|
+
export declare function skillSections(body: string): {
|
|
13
|
+
heading: string;
|
|
14
|
+
text: string;
|
|
15
|
+
}[];
|
|
16
|
+
/**
|
|
17
|
+
* The skill in Pi's <skill> block format with its on-demand sections left out and listed by name,
|
|
18
|
+
* or undefined when the file is small (Pi then expands it whole). The skill's own text is not changed.
|
|
19
|
+
*/
|
|
20
|
+
export declare function skillDigestBlock(name: string, path: string): string | undefined;
|
|
21
|
+
/** A skill of this size or more is put into a message as an index; smaller ones go in whole. */
|
|
22
|
+
export declare const SKILL_INDEX_MIN_CHARS = 3000;
|
|
23
|
+
/**
|
|
24
|
+
* Progressive disclosure (11-29): a skill goes into a message as an index (what it is for, the text before
|
|
25
|
+
* its first section, one line per section), and the model loads a section with psyclaw_skill section=… when
|
|
26
|
+
* the task reaches it. Returns undefined for a small skill, which goes in whole.
|
|
27
|
+
*/
|
|
28
|
+
export declare function skillIndexFromText(name: string, text: string, location?: string): string | undefined;
|
|
29
|
+
/** The index of a skill file on disk, or undefined when it is small or unreadable. */
|
|
30
|
+
export declare function skillIndexBlock(name: string, path: string): string | undefined;
|
|
31
|
+
/** One "## " section of a skill file, by heading (case-insensitive prefix match). */
|
|
32
|
+
export declare function readSkillSection(path: string, heading: string): string | undefined;
|
|
33
|
+
export declare function branchOf(ctx: {
|
|
34
|
+
sessionManager?: {
|
|
35
|
+
getBranch?: () => unknown[];
|
|
36
|
+
};
|
|
37
|
+
}): unknown[] | undefined;
|
|
38
|
+
/** First sentence of a description, at most `max` characters. */
|
|
39
|
+
export declare function firstSentence(text: string, max?: number): string;
|
|
40
|
+
/**
|
|
41
|
+
* Research mode lists every enabled skill by its first sentence only; the model reads
|
|
42
|
+
* SKILL.md (at the listed location) for the full description when it picks one. The rule
|
|
43
|
+
* is deterministic, so the system prompt stays the same across turns (prompt cache).
|
|
44
|
+
*/
|
|
45
|
+
export declare function compactSkillListing(systemPrompt: string, max?: number): string;
|
|
46
|
+
export interface RegisteredSkill {
|
|
47
|
+
name: string;
|
|
48
|
+
description: string;
|
|
49
|
+
location: string;
|
|
50
|
+
group: "PsyClaw" | "Writing" | "Yours";
|
|
51
|
+
}
|
|
52
|
+
/** Skills listed in Pi's <available_skills> block. */
|
|
53
|
+
export declare function parseSkillListing(systemPrompt: string): RegisteredSkill[];
|
|
54
|
+
/** Budget for the skill list in the system prompt; past it, a group falls back to names only. */
|
|
55
|
+
export declare const SKILL_LISTING_BUDGET = 5000;
|
|
56
|
+
/**
|
|
57
|
+
* Skill registry, stage 2 of skill use (11-29: discover headers → match → inject): the system prompt lists
|
|
58
|
+
* each loaded skill with its header (name and the first sentence of its description), grouped and sorted,
|
|
59
|
+
* so the model matches the task against what each skill is for. Local skills are opt-in, so the list is
|
|
60
|
+
* short; past SKILL_LISTING_BUDGET the largest groups fall back to names. psyclaw_skill then loads a matched
|
|
61
|
+
* skill as its index and a section at a time (stage 3). The text depends only on the set of skills, so it
|
|
62
|
+
* stays the same across turns (prompt cache).
|
|
63
|
+
*/
|
|
64
|
+
export declare function registrySkillListing(systemPrompt: string,
|
|
65
|
+
/** Which of the user's own skills ("Yours") the model sees: the background pick or the researcher's choice. */
|
|
66
|
+
visibleLocal?: (skill: RegisteredSkill) => boolean): {
|
|
67
|
+
systemPrompt: string;
|
|
68
|
+
skills: RegisteredSkill[];
|
|
69
|
+
};
|
|
70
|
+
/** Skills whose name or description match the query words, best first. */
|
|
71
|
+
export declare function findSkills(skills: readonly RegisteredSkill[], query: string, limit?: number): RegisteredSkill[];
|