psyclaw 0.34.0-preview.2 → 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/src/adapters/pi/extension.js +422 -140
- package/dist/src/adapters/pi/extension.js.map +1 -1
- package/dist/src/adapters/pi/observation-mask.js +5 -3
- package/dist/src/adapters/pi/observation-mask.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/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 +9 -0
- package/dist/src/branding.js +25 -0
- package/dist/src/branding.js.map +1 -1
- package/dist/src/chat.d.ts +2 -2
- package/dist/src/chat.js +9 -3
- package/dist/src/chat.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/panel/server.js +8 -10
- package/dist/src/panel/server.js.map +1 -1
- package/dist/src/router/decision-model.d.ts +23 -4
- package/dist/src/router/decision-model.js +87 -10
- package/dist/src/router/decision-model.js.map +1 -1
- 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/session/help.js +3 -2
- package/dist/src/session/help.js.map +1 -1
- package/dist/src/session/modes.js +2 -2
- package/dist/src/session/modes.js.map +1 -1
- package/dist/src/session/skill-invoke.d.ts +21 -4
- package/dist/src/session/skill-invoke.js +83 -16
- package/dist/src/session/skill-invoke.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 +96 -23
- package/dist/src/skills/user-skills.js.map +1 -1
- package/dist/src/style/cli-ui.js +3 -2
- package/dist/src/style/cli-ui.js.map +1 -1
- package/dist/src/tui/biosignal-wizard.js +1 -1
- package/dist/src/tui/biosignal-wizard.js.map +1 -1
- package/package.json +4 -4
- package/scripts/psyclaw.mjs +5 -0
- package/scripts/rebrand-pi.mjs +62 -3
- package/skills/core/analysis-plan/SKILL.md +67 -41
package/scripts/rebrand-pi.mjs
CHANGED
|
@@ -17,7 +17,7 @@ import { basename, dirname, join, resolve } from "node:path";
|
|
|
17
17
|
import { fileURLToPath } from "node:url";
|
|
18
18
|
|
|
19
19
|
const NAME = "PsyClaw";
|
|
20
|
-
const LOCKED_PI_VERSION = "
|
|
20
|
+
const LOCKED_PI_VERSION = "1.7.0";
|
|
21
21
|
// PsyClaw's own user config directory. Retained as the sole Pi config dir so
|
|
22
22
|
// models, themes, packages, and skills live under `~/.psyclaw` consistently
|
|
23
23
|
// with the project data directory name.
|
|
@@ -370,8 +370,10 @@ async function applyModePatches(modePath) {
|
|
|
370
370
|
// that a previous build appended to, instead of declaring the banner twice.
|
|
371
371
|
const dynamicBannerRegex = /(?:const (?:bannerCandidates|wideBannerVariants|BANNER_VARIANTS)[\s\S]*?const logo = \[[\s\S]*?\]\.join\("\\n"\);|const logo = (?:`[\s\S]*?`|\[[\s\S]*?\]\.join\("\\n"\)|theme\.bold[^;]*);)/g;
|
|
372
372
|
const matches = [...content.matchAll(dynamicBannerRegex)];
|
|
373
|
-
|
|
374
|
-
const
|
|
373
|
+
// Pi 1.x draws a two-line logo from components/pi-logo.js instead (patched in applyLogoPatches).
|
|
374
|
+
const logoHeader = content.includes("piLogoLines()");
|
|
375
|
+
if (matches.length !== 1 && !logoHeader) throw new Error(`Expected exactly one Pi startup banner, found ${matches.length}`);
|
|
376
|
+
const currentMatch = matches.length === 1 ? matches[0] : undefined;
|
|
375
377
|
if (currentMatch && currentMatch[0] !== PSYCLAW_DYNAMIC_BANNER) {
|
|
376
378
|
content = `${content.slice(0, currentMatch.index)}${PSYCLAW_DYNAMIC_BANNER}${content.slice(currentMatch.index + currentMatch[0].length)}`;
|
|
377
379
|
applied.push("const logo = ... [Updated Curated 4-Style psyclaw Banner Rotation Pool]");
|
|
@@ -404,6 +406,62 @@ const SETTINGS_PATCHES = [
|
|
|
404
406
|
},
|
|
405
407
|
];
|
|
406
408
|
|
|
409
|
+
// Pi 1.x keeps setting defaults in core/settings-defaults.js.
|
|
410
|
+
const SETTINGS_DEFAULTS_PATCHES = [
|
|
411
|
+
{ old: " hideThinkingBlock: false,", next: " hideThinkingBlock: true," },
|
|
412
|
+
];
|
|
413
|
+
|
|
414
|
+
// Pi 1.x: the header shows a two-line logo (the version beside the top line, key hints beside the bottom
|
|
415
|
+
// line) and hides itself under quietStartup. PsyClaw shows its own name there and keeps the header.
|
|
416
|
+
const PSYCLAW_LOGO_LINES = `export function piLogoLines() {
|
|
417
|
+
const mode = theme.getColorMode();
|
|
418
|
+
const fg = (color) => foregroundAnsi(color, mode);
|
|
419
|
+
// PsyClaw: the name in the research-mode teal; the bottom line pads to the same width for the key hints.
|
|
420
|
+
const top = \`\${fg(rgbColor(46, 196, 182))}ψ PsyClaw\${RESET}\`;
|
|
421
|
+
const bottom = " ".repeat(9);
|
|
422
|
+
return [top, bottom];
|
|
423
|
+
}`;
|
|
424
|
+
const PSYCLAW_WORDMARK = `export function piWordmark() {
|
|
425
|
+
const mode = theme.getColorMode();
|
|
426
|
+
return \`\${foregroundAnsi(rgbColor(46, 196, 182), mode)}ψ PsyClaw\${RESET}\`;
|
|
427
|
+
}`;
|
|
428
|
+
const HEADER_PATCHES = [
|
|
429
|
+
{
|
|
430
|
+
// The header shows PsyClaw's version (psyclaw.mjs sets PSYCLAW_VERSION), not the bundled Pi's.
|
|
431
|
+
old: 'theme.fg("dim", `v${this.version}`)',
|
|
432
|
+
next: 'theme.fg("dim", `v${process.env.PSYCLAW_VERSION ?? this.version}`)',
|
|
433
|
+
all: true,
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
old: "return this.options.verbose === true || this.settingsManager.getQuietStartup() !== true;",
|
|
437
|
+
next: "return true; // PsyClaw keeps its header even when quietStartup hides inventories",
|
|
438
|
+
},
|
|
439
|
+
];
|
|
440
|
+
|
|
441
|
+
async function applyLogoPatches(pkgDir) {
|
|
442
|
+
const applied = [];
|
|
443
|
+
const logoPath = join(pkgDir, "dist", "modes", "interactive", "components", "pi-logo.js");
|
|
444
|
+
let logo;
|
|
445
|
+
try { logo = await readFile(logoPath, "utf8"); } catch { return applied; } // Pi 0.84: no such file
|
|
446
|
+
const next = logo
|
|
447
|
+
.replace(/export function piLogoLines\(\) \{[\s\S]*?\n\}/, PSYCLAW_LOGO_LINES)
|
|
448
|
+
.replace(/export function piWordmark\(\) \{[\s\S]*?\n\}/, PSYCLAW_WORDMARK);
|
|
449
|
+
if (next !== logo) { await atomicReplace(logoPath, next, true); applied.push("ψ PsyClaw logo"); }
|
|
450
|
+
const modePath = join(pkgDir, "dist", "modes", "interactive", "interactive-mode.js");
|
|
451
|
+
let mode = await readFile(modePath, "utf8");
|
|
452
|
+
let headerChanged = false;
|
|
453
|
+
for (const { old, next: n, all } of HEADER_PATCHES) if (mode.includes(old)) { mode = all ? mode.replaceAll(old, n) : mode.replace(old, n); headerChanged = true; applied.push(`header: ${old.slice(0, 40)}`); }
|
|
454
|
+
if (headerChanged) await atomicReplace(modePath, mode, true);
|
|
455
|
+
const defaultsPath = join(pkgDir, "dist", "core", "settings-defaults.js");
|
|
456
|
+
try {
|
|
457
|
+
let defaults = await readFile(defaultsPath, "utf8");
|
|
458
|
+
let changed = false;
|
|
459
|
+
for (const { old, next: n } of SETTINGS_DEFAULTS_PATCHES) if (defaults.includes(old)) { defaults = defaults.replace(old, n); changed = true; }
|
|
460
|
+
if (changed) { await atomicReplace(defaultsPath, defaults, true); applied.push("thinking collapsed by default"); }
|
|
461
|
+
} catch { /* Pi 0.84: defaults live in settings-manager.js */ }
|
|
462
|
+
return applied;
|
|
463
|
+
}
|
|
464
|
+
|
|
407
465
|
// PsyClaw owns provider setup through /provider. Keep Pi's authentication
|
|
408
466
|
// implementation available underneath, but do not expose its lower-level
|
|
409
467
|
// /login and /logout commands in autocomplete or command help.
|
|
@@ -544,6 +602,7 @@ export async function rebrandPiRuntime(options = {}) {
|
|
|
544
602
|
const footerApplied = await applyFooterPatches(footerPath);
|
|
545
603
|
const commandApplied = await applySlashCommandPatches(slashCommandsPath);
|
|
546
604
|
const managedToolsRestored = await restoreManagedToolManager(toolsManagerPath);
|
|
605
|
+
applied.push(...await applyLogoPatches(pkgDir));
|
|
547
606
|
|
|
548
607
|
if (!options.quiet) {
|
|
549
608
|
process.stdout.write(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: analysis-plan
|
|
3
|
-
description:
|
|
3
|
+
description: Research-mode analysis process — the researcher's intent first, the hypotheses-to-models table, the whole plan in one numbered message, the researcher's one reply, execution step by step, and 做法对照 before the report. Method detail comes from the method skills.
|
|
4
4
|
license: MIT
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -8,46 +8,72 @@ license: MIT
|
|
|
8
8
|
|
|
9
9
|
Use this skill only in **analysis** mode. Do not start academic/ARS writing from here.
|
|
10
10
|
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
11
|
+
## Stage 1. The researcher's intent first (required)
|
|
12
|
+
|
|
13
|
+
Before profiling in depth or planning, ask the researcher 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; asking more here is better than guessing later.
|
|
14
|
+
- Restate it with `psyclaw_intent` action=restate: one item per point (field `question`, `outcome`, `approach`, `hypothesis`, `data` or `scope`; label such as RQ1), each with the researcher's or the materials' words as the quote; leave the quote out for what you infer, and code lists those apart for the researcher to check. Give `flow`: `theory` (hypotheses and predictions first, then data) or `data` (explore first, then literature, written up as exploratory).
|
|
15
|
+
- Post the message it returns and wait. Record the reply with `psyclaw_intent` action=confirm; restate again if they correct something substantial. `psyclaw_plan` action=submit waits for the confirmed intent.
|
|
16
|
+
- Then inspect `data/clean` once and write a compact profile.
|
|
17
|
+
- No clear research question (no stated question, hypothesis, outcome or comparison)? Do not build a plan yet. Ask with `psyclaw_ask`: brainstorm 2-4 answerable questions from the data (recommended when there is none yet), grill a rough idea one point at a time, or a short exploratory profile only. For the first two, load `academic-grill` with `psyclaw_skill` and follow it; come back to stage 2 once a question is chosen.
|
|
18
|
+
|
|
19
|
+
## Stage 2. From hypotheses to models (required table)
|
|
20
|
+
|
|
21
|
+
Before submitting the plan, fill in the table under "Hypotheses to models" in `analysis/plans/plan.md` (the workspace template already has its header; keep the columns), one row per hypothesis and one per exploratory variable:
|
|
22
|
+
|
|
23
|
+
| ID | Scope as worded | Outcome | Focal term | Implied tests | Status |
|
|
24
|
+
| --- | --- | --- | --- | --- | --- |
|
|
25
|
+
|
|
26
|
+
- **Scope as worded**: `whole sample`, `restricted to <group>` (wording such as "among X" or "no specific prediction for Y"), `moderation`, or `exploratory, no direction`.
|
|
27
|
+
- **Implied tests** follow the standing method rules in the plan template. Detail for change scores, interactions, mediation, multilevel models, SEM, and reporting is injected from the matching method skill. Do not treat this process skill as that reference.
|
|
28
|
+
- **Status**: `confirmatory` or `exploratory`; every implied test enters the multiplicity plan.
|
|
29
|
+
|
|
30
|
+
Re-read the table before writing the report and state, for each implied test, the result or why it was not run. These tests belong in the plan message, and the table goes into the plan you submit.
|
|
31
|
+
|
|
32
|
+
## Stage 2b. Decision points and verdict rules (required, before any outcome model)
|
|
33
|
+
|
|
34
|
+
Every analytic fork is one decision in the project's decision record. Code writes `notes/decisions.md` and the plan's Decisions section from it; do not write decision tables by hand.
|
|
35
|
+
- One decision per analytic fork: sample and exclusion rules, coding and scoring keys, unit of analysis, groups analysed separately or pooled, model family and estimator, random effects and covariates, missing data, alpha, multiplicity family and method, criteria for support.
|
|
36
|
+
- Who settles it: the brief (by `brief`, with the quote), a convention almost any competent analyst would choose (by `analyst`, with the reason), or the researcher when the brief and data leave it open and reasonable analysts differ (open, with options and your recommendation). A standing method rule or an injected method skill is a default, not a settlement: when the brief does not settle a fork that such a rule covers, leave it open. Alpha, tails, multiplicity, and support rules are declarations, not questions: settle them by `analyst`.
|
|
37
|
+
- With no one to ask (unattended), make the option closest to the brief's wording primary, run the main alternative as a labelled sensitivity analysis, and report both when their conclusions differ.
|
|
38
|
+
- Verdict rules are locked before the first outcome model. A later change is a deviation: record it with `psyclaw_decide` (same id) and its reason.
|
|
39
|
+
|
|
40
|
+
## Stage 3. The whole plan in one message (required)
|
|
41
|
+
|
|
42
|
+
Give every point its `impact`: `key` when the choice changes the answer to a research question or the conclusion, with `why` (one line on what changes; at most 4 key points 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. Only a convention can be settled by `analyst`; code puts a research-intent decision (sample, coding, primary outcome, model, covariates, missing data, inference rules) to the researcher with your choice as the recommendation. Analyses you add beyond the request go into `agentAdditions` with the reason; the message lists them as 我打算补的分析. Submit the plan with `psyclaw_plan` action=submit, every decision point in `decisions` (with its `rq` label). Code numbers them D1…Dn and returns one message: post it as your whole reply, unchanged, and stop. Do not ask cards before the researcher's reply.
|
|
43
|
+
- For each research question, offer the analyses a reviewer would expect (the tests the hypotheses-to-models table implies, standard breakdowns and sensitivity analyses) as points or as listed analyses; the message asks the researcher to name what is missing.
|
|
44
|
+
|
|
45
|
+
## Stage 4. The researcher's reply (required unless `/plan auto`)
|
|
46
|
+
|
|
47
|
+
Record it with one `psyclaw_plan` action=answers call: the reply as `quote`, one answer per point it names (option number, or their own approach as text), `rest` = recommended when it accepts the recommendations for the rest, `approved` when it approves, `additions` for the analyses it says are missing. Code records each decision and approves the plan once nothing is open.
|
|
48
|
+
- Ask a `psyclaw_ask` card only for a point the reply leaves unclear, one card per point, the same id. If they answer in text, record it with `psyclaw_decide` (by `researcher`, their words as the quote, the same id).
|
|
49
|
+
- Once every point is settled, a plain yes (可以 / 批准 / ok) approves the plan.
|
|
50
|
+
|
|
51
|
+
## Stage 5. Auto mode
|
|
52
|
+
|
|
53
|
+
If the researcher ran `/plan auto`, proceed without ritual, but every report/script summary must state **「未经人审批」**.
|
|
54
|
+
|
|
55
|
+
## Stage 6. Crosscheck / verify (human-gated)
|
|
56
|
+
|
|
57
|
+
Do **not** start `/check quick` or `/check full` automatically. After scripts (or before a costly pass), ask whether to open that block; only run it after an explicit yes. Skipping must mark **「未经核对」**.
|
|
58
|
+
|
|
59
|
+
## Stage 7. Execute: decoupled steps, checked as you go
|
|
60
|
+
|
|
61
|
+
- If the researcher named a tool ("用 MNE MCP", a package, a backend), use it.
|
|
62
|
+
- If an MCP server is configured that can run this analysis (its tools are named `mcp__<server>__<tool>`; find them with `tool_search`, e.g. MNE for EEG/MEG/fNIRS, a stats backend), use it: work in its session, which keeps data in memory between calls. Fall back to local scripts only when no configured MCP fits or it fails.
|
|
63
|
+
- Without a fitting MCP, still work one step at a time and look at each result before the next step: run short exploration scripts on saved intermediate files.
|
|
64
|
+
- Check each step, not only whether it ran: which criterion removed trials, whether projections are active, whether the whitened baseline is near 1 and why not, whether a peak sits where the modality predicts, whether an effect is large enough to matter.
|
|
65
|
+
- Keep the pipeline decoupled: one module per step (load, prepare, each analysis, figures, export) under `analysis/scripts/` (or the path the researcher named), plus a thin entrypoint that runs them in order. Do not put everything in one script.
|
|
66
|
+
- Every module runs on its own: it reads its inputs from the files the previous step saved (`.fif`, `.npy`, `.csv`, `.parquet`, `.json`) and writes its outputs to disk. No state passes in memory between modules, so a module can be run, checked and fixed by itself (for example `python analysis/scripts/s06_roi.py`).
|
|
67
|
+
- When a step has a problem, fix that module and rerun only that module (and the modules after it that read its output). Never rerun from step 1 to test a fix.
|
|
68
|
+
- Run the whole pipeline through the entrypoint once at the end to confirm it reproduces (twice at most).
|
|
69
|
+
|
|
70
|
+
## Stage 8. 做法对照 (required before the report)
|
|
71
|
+
|
|
72
|
+
An analysis added during execution: `psyclaw_decide` action=add with the reason. A change to what the researcher or the brief settled: `psyclaw_decide` action=change (id, what instead, why), and tell 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` copied verbatim from that file, `changed` + `to` and `note`, `not-done` + `note`); if the file does not do what was decided, the item is `changed`, not `done` and put the section it returns at the top of the report, unchanged.
|
|
73
|
+
|
|
74
|
+
## Stage 9. Handoff
|
|
75
|
+
|
|
76
|
+
Update `analysis/HANDOFF.md` before academic mode. Final Panel「核实」remains required for completion.
|
|
51
77
|
|
|
52
78
|
## Volume rule
|
|
53
79
|
|