psyche-ai 10.2.1 → 10.2.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/README.md +21 -27
- package/dist/adapters/mcp.js +0 -0
- package/dist/adapters/proxy.js +0 -0
- package/dist/cli.js +132 -50
- package/package.json +1 -1
- package/server.json +2 -2
package/README.md
CHANGED
|
@@ -192,52 +192,46 @@ Luna 在安慰用户时情绪下沉 → 广播化学态 → Kai 感知到 Luna
|
|
|
192
192
|
|
|
193
193
|
---
|
|
194
194
|
|
|
195
|
-
##
|
|
195
|
+
## 一条命令,给任何 Agent 加上主观性
|
|
196
196
|
|
|
197
197
|
```bash
|
|
198
|
-
|
|
198
|
+
npx psyche-ai setup --mbti ENFP --name Luna
|
|
199
199
|
```
|
|
200
200
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
```
|
|
201
|
+
这一条命令会:
|
|
202
|
+
- 自动检测本机的 Claude Code / Claude Desktop / Cursor / Windsurf
|
|
203
|
+
- 写入 MCP 配置(Claude Code 即时生效,其他重启后生效)
|
|
204
|
+
- 不需要知道配置文件在哪,不需要手动编辑任何 JSON
|
|
206
205
|
|
|
207
|
-
|
|
206
|
+
**覆盖非 MCP 的 Agent(Codex、自定义 agent 等)——透明代理:**
|
|
208
207
|
|
|
209
208
|
```bash
|
|
210
|
-
|
|
211
|
-
# 看到 "psyche │ loaded" 就行了
|
|
209
|
+
npx psyche-ai setup --proxy -t https://api.openai.com/v1 --mbti ENFP
|
|
212
210
|
```
|
|
213
211
|
|
|
214
|
-
|
|
212
|
+
这会启动一个本地代理 + 自动设置 `OPENAI_BASE_URL`。所有使用 OpenAI SDK 的程序自动走代理。Agent 完全不知道 Psyche 存在——镜子,不是麦克风。
|
|
215
213
|
|
|
216
|
-
|
|
214
|
+
**两条路径覆盖所有 agent:**
|
|
217
215
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
psyche
|
|
216
|
+
| 路径 | 覆盖范围 | 原理 |
|
|
217
|
+
|------|---------|------|
|
|
218
|
+
| MCP (`psyche setup`) | Claude Code / Desktop / Cursor / Windsurf | MCP 工具协议 |
|
|
219
|
+
| Proxy (`setup --proxy`) | 任意使用 OpenAI/Anthropic SDK 的 agent | 环境变量重定向 HTTP |
|
|
221
220
|
|
|
222
|
-
|
|
223
|
-
psyche upgrade
|
|
221
|
+
**验证是否生效:**
|
|
224
222
|
|
|
225
|
-
|
|
226
|
-
|
|
223
|
+
```bash
|
|
224
|
+
npx psyche-ai probe --json
|
|
225
|
+
# ok: true, processInputCalled: true → 在用了
|
|
227
226
|
```
|
|
228
227
|
|
|
229
|
-
|
|
230
|
-
- `git` 工作树和本地路径安装不会偷偷改你的代码;脏工作树只会提示手动命令。
|
|
231
|
-
- OpenClaw 如果是从当前仓库本地加载,升级后记得重启 gateway 以载入新的 `dist/`。
|
|
232
|
-
|
|
233
|
-
## 透明代理(推荐:任意 LLM 一行接入)
|
|
228
|
+
**升级:**
|
|
234
229
|
|
|
235
230
|
```bash
|
|
236
|
-
psyche-
|
|
231
|
+
npx psyche-ai upgrade --check # 检查
|
|
232
|
+
npx psyche-ai upgrade # 升级
|
|
237
233
|
```
|
|
238
234
|
|
|
239
|
-
然后把客户端的 API 地址改成 `http://localhost:3340/v1`。Agent 获得持续主观性,但完全不知道 Psyche 存在。Psyche 像内分泌系统一样在后台观测行为、注入偏置——镜子,不是麦克风。
|
|
240
|
-
|
|
241
235
|
## 给本机其他 Agent 的真实验收
|
|
242
236
|
|
|
243
237
|
如果另一个 agent 声称“已经在用 Psyche”,不要接受口头解释,直接让它跑:
|
package/dist/adapters/mcp.js
CHANGED
|
File without changes
|
package/dist/adapters/proxy.js
CHANGED
|
File without changes
|
package/dist/cli.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// psyche upgrade [--check]
|
|
16
16
|
// psyche probe [--json]
|
|
17
17
|
// psyche profiles [--json] [--mbti TYPE]
|
|
18
|
-
// psyche setup [--name NAME] [--mbti TYPE] [--locale LOCALE] [--dry-run]
|
|
18
|
+
// psyche setup [--name NAME] [--mbti TYPE] [--locale LOCALE] [--proxy --target URL] [--dry-run]
|
|
19
19
|
// ============================================================
|
|
20
20
|
import { resolve, join } from "node:path";
|
|
21
21
|
import { homedir } from "node:os";
|
|
@@ -510,66 +510,130 @@ async function fileExists(path) {
|
|
|
510
510
|
return false;
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
|
-
async function cmdSetup(
|
|
514
|
-
const
|
|
515
|
-
const
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
for (
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
513
|
+
async function cmdSetup(opts) {
|
|
514
|
+
const { name, mbti, locale, proxy, target, port, dryRun } = opts;
|
|
515
|
+
const env = {};
|
|
516
|
+
if (name)
|
|
517
|
+
env.PSYCHE_NAME = name;
|
|
518
|
+
if (mbti)
|
|
519
|
+
env.PSYCHE_MBTI = mbti.toUpperCase();
|
|
520
|
+
if (locale)
|
|
521
|
+
env.PSYCHE_LOCALE = locale;
|
|
522
|
+
let actions = 0;
|
|
523
|
+
// ── 1. MCP clients ────────────────────────────────────
|
|
524
|
+
const mcpEntry = { command: "npx", args: ["-y", "psyche-mcp"], env };
|
|
525
|
+
const { execFileSync } = await import("node:child_process");
|
|
526
|
+
// Claude Code — use `claude mcp add` for hot-reload (no restart needed)
|
|
527
|
+
let claudeCodeDone = false;
|
|
528
|
+
try {
|
|
529
|
+
const out = execFileSync("claude", ["mcp", "list"], { encoding: "utf-8", timeout: 5000 });
|
|
530
|
+
if (out.includes("psyche")) {
|
|
531
|
+
console.log(" ✓ Claude Code — already configured");
|
|
532
|
+
claudeCodeDone = true;
|
|
533
|
+
}
|
|
534
|
+
else if (dryRun) {
|
|
535
|
+
console.log(" → Claude Code — would configure via `claude mcp add`");
|
|
536
|
+
claudeCodeDone = true;
|
|
537
|
+
actions++;
|
|
538
|
+
}
|
|
539
|
+
else {
|
|
540
|
+
const addArgs = ["mcp", "add", "psyche", "-e", "PSYCHE_LOCALE=" + (locale || "zh")];
|
|
541
|
+
if (name)
|
|
542
|
+
addArgs.push("-e", "PSYCHE_NAME=" + name);
|
|
543
|
+
if (mbti)
|
|
544
|
+
addArgs.push("-e", "PSYCHE_MBTI=" + mbti.toUpperCase());
|
|
545
|
+
addArgs.push("--", "npx", "-y", "psyche-mcp");
|
|
546
|
+
execFileSync("claude", addArgs, { encoding: "utf-8", timeout: 10000 });
|
|
547
|
+
console.log(" ✓ Claude Code — configured (live, no restart needed)");
|
|
548
|
+
claudeCodeDone = true;
|
|
549
|
+
actions++;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
catch { /* claude CLI not available, fall through to JSON method */ }
|
|
553
|
+
// Other clients — edit config JSON
|
|
554
|
+
for (const t of getMCPTargets()) {
|
|
555
|
+
if (claudeCodeDone && t.name === "Claude Code")
|
|
530
556
|
continue;
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
557
|
+
const dir = resolve(t.configPath, "..");
|
|
558
|
+
if (!(await fileExists(dir)))
|
|
559
|
+
continue;
|
|
560
|
+
let cfg = {};
|
|
561
|
+
if (await fileExists(t.configPath)) {
|
|
534
562
|
try {
|
|
535
|
-
|
|
536
|
-
}
|
|
537
|
-
catch {
|
|
538
|
-
config = {};
|
|
563
|
+
cfg = JSON.parse(await readFile(t.configPath, "utf-8"));
|
|
539
564
|
}
|
|
565
|
+
catch { /* fresh */ }
|
|
540
566
|
}
|
|
541
|
-
|
|
542
|
-
const servers = config[target.mcpKey] ?? {};
|
|
567
|
+
const servers = cfg[t.mcpKey] ?? {};
|
|
543
568
|
if (servers["psyche"]) {
|
|
544
|
-
console.log(` ✓ ${
|
|
545
|
-
skipped++;
|
|
569
|
+
console.log(` ✓ ${t.name} — already configured`);
|
|
546
570
|
continue;
|
|
547
571
|
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
config[target.mcpKey] = servers;
|
|
572
|
+
servers["psyche"] = mcpEntry;
|
|
573
|
+
cfg[t.mcpKey] = servers;
|
|
551
574
|
if (dryRun) {
|
|
552
|
-
console.log(` → ${
|
|
553
|
-
|
|
575
|
+
console.log(` → ${t.name} — would configure`);
|
|
576
|
+
actions++;
|
|
554
577
|
continue;
|
|
555
578
|
}
|
|
556
|
-
|
|
557
|
-
await
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
if (
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
579
|
+
await mkdir(dir, { recursive: true });
|
|
580
|
+
await writeFile(t.configPath, JSON.stringify(cfg, null, 2) + "\n", "utf-8");
|
|
581
|
+
console.log(` ✓ ${t.name} (restart to activate)`);
|
|
582
|
+
actions++;
|
|
583
|
+
}
|
|
584
|
+
// ── 2. Proxy + env var ────────────────────────────────
|
|
585
|
+
if (proxy && target) {
|
|
586
|
+
const proxyUrl = `http://127.0.0.1:${port}/v1`;
|
|
587
|
+
const shell = process.env.SHELL ?? "/bin/zsh";
|
|
588
|
+
const rcFile = shell.includes("zsh") ? join(homedir(), ".zshrc")
|
|
589
|
+
: shell.includes("bash") ? join(homedir(), ".bashrc")
|
|
590
|
+
: null;
|
|
591
|
+
// Determine which env var to set based on target URL
|
|
592
|
+
const envVar = target.includes("anthropic") ? "ANTHROPIC_BASE_URL" : "OPENAI_BASE_URL";
|
|
593
|
+
const exportLine = `export ${envVar}="${proxyUrl}" # psyche-proxy`;
|
|
594
|
+
// Build proxy launch command
|
|
595
|
+
const proxyArgs = [`-t`, target, `-p`, String(port)];
|
|
596
|
+
if (name)
|
|
597
|
+
proxyArgs.push(`-n`, name);
|
|
598
|
+
if (mbti)
|
|
599
|
+
proxyArgs.push(`--mbti`, mbti.toUpperCase());
|
|
600
|
+
if (locale)
|
|
601
|
+
proxyArgs.push(`-l`, locale);
|
|
602
|
+
const launchCmd = `npx psyche-proxy ${proxyArgs.join(" ")}`;
|
|
603
|
+
if (dryRun) {
|
|
604
|
+
console.log(` → proxy — would start: ${launchCmd}`);
|
|
605
|
+
if (rcFile)
|
|
606
|
+
console.log(` → shell — would append to ${rcFile}: ${exportLine}`);
|
|
607
|
+
actions++;
|
|
608
|
+
}
|
|
609
|
+
else {
|
|
610
|
+
// Append env var to shell rc (idempotent)
|
|
611
|
+
if (rcFile) {
|
|
612
|
+
const rc = await fileExists(rcFile) ? await readFile(rcFile, "utf-8") : "";
|
|
613
|
+
if (!rc.includes("# psyche-proxy")) {
|
|
614
|
+
await writeFile(rcFile, rc + (rc.endsWith("\n") ? "" : "\n") + exportLine + "\n", "utf-8");
|
|
615
|
+
console.log(` ✓ ${envVar} → ${proxyUrl} (${rcFile})`);
|
|
616
|
+
}
|
|
617
|
+
else {
|
|
618
|
+
console.log(` ✓ shell env — already configured`);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
// Start proxy in background
|
|
622
|
+
const { spawn } = await import("node:child_process");
|
|
623
|
+
const child = spawn("npx", ["-y", "psyche-proxy", ...proxyArgs], {
|
|
624
|
+
detached: true, stdio: "ignore",
|
|
625
|
+
});
|
|
626
|
+
child.unref();
|
|
627
|
+
console.log(` ✓ proxy — pid ${child.pid} → ${target}`);
|
|
628
|
+
actions++;
|
|
629
|
+
}
|
|
566
630
|
}
|
|
567
|
-
|
|
568
|
-
if (
|
|
569
|
-
console.log(
|
|
631
|
+
// ── Summary ───────────────────────────────────────────
|
|
632
|
+
if (actions === 0) {
|
|
633
|
+
console.log(" Nothing to do. All targets already configured.");
|
|
570
634
|
}
|
|
571
|
-
if (
|
|
572
|
-
console.log(
|
|
635
|
+
else if (!dryRun) {
|
|
636
|
+
console.log("\nDone. Claude Code is live. Other MCP clients need restart.");
|
|
573
637
|
}
|
|
574
638
|
}
|
|
575
639
|
function usage() {
|
|
@@ -587,6 +651,7 @@ Usage:
|
|
|
587
651
|
psyche intensity Show info about personality intensity config
|
|
588
652
|
psyche reset <dir> [--full]
|
|
589
653
|
psyche diagnose <dir> [--github] Run health checks & show diagnostic report
|
|
654
|
+
psyche setup [--proxy -t URL] [-n NAME] [--mbti TYPE] Auto-configure MCP + proxy
|
|
590
655
|
psyche upgrade [--check] Check/apply package updates safely
|
|
591
656
|
psyche probe [--json] Verify the runtime is truly callable
|
|
592
657
|
psyche profiles [--mbti TYPE] [--json]
|
|
@@ -619,6 +684,12 @@ Examples:
|
|
|
619
684
|
psyche profiles
|
|
620
685
|
psyche profiles --mbti ENFP
|
|
621
686
|
|
|
687
|
+
# Auto-configure all MCP clients
|
|
688
|
+
psyche setup --mbti ENFP --name Luna
|
|
689
|
+
|
|
690
|
+
# Universal proxy — works with any agent using OpenAI SDK
|
|
691
|
+
psyche setup --proxy -t https://api.openai.com/v1 --mbti ENFP
|
|
692
|
+
|
|
622
693
|
# Check for new package versions without applying them
|
|
623
694
|
psyche upgrade --check
|
|
624
695
|
|
|
@@ -782,12 +853,23 @@ async function main() {
|
|
|
782
853
|
name: { type: "string", short: "n" },
|
|
783
854
|
mbti: { type: "string" },
|
|
784
855
|
locale: { type: "string", short: "l" },
|
|
856
|
+
proxy: { type: "boolean", default: false },
|
|
857
|
+
target: { type: "string", short: "t" },
|
|
858
|
+
port: { type: "string", short: "p" },
|
|
785
859
|
"dry-run": { type: "boolean", default: false },
|
|
786
860
|
},
|
|
787
861
|
allowPositionals: true,
|
|
788
862
|
});
|
|
789
863
|
console.log("\npsyche setup — auto-configuring MCP clients\n");
|
|
790
|
-
await cmdSetup(
|
|
864
|
+
await cmdSetup({
|
|
865
|
+
name: values.name ?? "",
|
|
866
|
+
mbti: values.mbti ?? "",
|
|
867
|
+
locale: values.locale ?? "",
|
|
868
|
+
proxy: values.proxy ?? false,
|
|
869
|
+
target: values.target ?? "",
|
|
870
|
+
port: parseInt(values.port ?? "3340", 10),
|
|
871
|
+
dryRun: values["dry-run"] ?? false,
|
|
872
|
+
});
|
|
791
873
|
break;
|
|
792
874
|
}
|
|
793
875
|
default:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "psyche-ai",
|
|
3
|
-
"version": "10.2.
|
|
3
|
+
"version": "10.2.3",
|
|
4
4
|
"description": "AI-first subjectivity kernel for agents with continuous appraisal, relation dynamics, and adaptive reply loops",
|
|
5
5
|
"mcpName": "io.github.Shangri-la-0428/psyche-ai",
|
|
6
6
|
"type": "module",
|
package/server.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"url": "https://github.com/Shangri-la-0428/oasyce_psyche",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "10.
|
|
9
|
+
"version": "10.2.3",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "psyche-ai",
|
|
14
|
-
"version": "10.
|
|
14
|
+
"version": "10.2.3",
|
|
15
15
|
"transport": {
|
|
16
16
|
"type": "stdio"
|
|
17
17
|
},
|