psyche-ai 10.2.0 → 10.2.2
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/cli.js +181 -3
- package/package.json +1 -1
- package/server.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -15,10 +15,12 @@
|
|
|
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] [--proxy --target URL] [--dry-run]
|
|
18
19
|
// ============================================================
|
|
19
|
-
import { resolve } from "node:path";
|
|
20
|
+
import { resolve, join } from "node:path";
|
|
21
|
+
import { homedir } from "node:os";
|
|
20
22
|
import { parseArgs } from "node:util";
|
|
21
|
-
import { readFile } from "node:fs/promises";
|
|
23
|
+
import { readFile, writeFile, mkdir, access } from "node:fs/promises";
|
|
22
24
|
import { loadState, saveState, decayAndSave, initializeState, mergeUpdates, generatePsycheMd, getRelationship, } from "./psyche-file.js";
|
|
23
25
|
import { describeEmotionalState, getExpressionHint, detectEmotions } from "./chemistry.js";
|
|
24
26
|
import { generateReport, formatReport, toGitHubIssueBody } from "./diagnostics.js";
|
|
@@ -459,7 +461,150 @@ async function cmdProbe(json) {
|
|
|
459
461
|
console.log(` replyEnvelope: ${result.canonicalHostSurface ? "present" : "missing"}`);
|
|
460
462
|
console.log(` externalContinuity: ${result.externalContinuityAvailable ? "present" : "missing"}`);
|
|
461
463
|
}
|
|
462
|
-
|
|
464
|
+
function getMCPTargets() {
|
|
465
|
+
const home = homedir();
|
|
466
|
+
const isMac = process.platform === "darwin";
|
|
467
|
+
const isWin = process.platform === "win32";
|
|
468
|
+
const targets = [];
|
|
469
|
+
// Claude Desktop
|
|
470
|
+
if (isMac) {
|
|
471
|
+
targets.push({
|
|
472
|
+
name: "Claude Desktop",
|
|
473
|
+
configPath: join(home, "Library/Application Support/Claude/claude_desktop_config.json"),
|
|
474
|
+
mcpKey: "mcpServers",
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
else if (isWin) {
|
|
478
|
+
targets.push({
|
|
479
|
+
name: "Claude Desktop",
|
|
480
|
+
configPath: join(process.env.APPDATA ?? join(home, "AppData/Roaming"), "Claude/claude_desktop_config.json"),
|
|
481
|
+
mcpKey: "mcpServers",
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
// Cursor
|
|
485
|
+
targets.push({
|
|
486
|
+
name: "Cursor",
|
|
487
|
+
configPath: join(home, ".cursor/mcp.json"),
|
|
488
|
+
mcpKey: "mcpServers",
|
|
489
|
+
});
|
|
490
|
+
// Claude Code
|
|
491
|
+
targets.push({
|
|
492
|
+
name: "Claude Code",
|
|
493
|
+
configPath: join(home, ".claude/settings.json"),
|
|
494
|
+
mcpKey: "mcpServers",
|
|
495
|
+
});
|
|
496
|
+
// Windsurf
|
|
497
|
+
targets.push({
|
|
498
|
+
name: "Windsurf",
|
|
499
|
+
configPath: join(home, ".windsurf/mcp.json"),
|
|
500
|
+
mcpKey: "mcpServers",
|
|
501
|
+
});
|
|
502
|
+
return targets;
|
|
503
|
+
}
|
|
504
|
+
async function fileExists(path) {
|
|
505
|
+
try {
|
|
506
|
+
await access(path);
|
|
507
|
+
return true;
|
|
508
|
+
}
|
|
509
|
+
catch {
|
|
510
|
+
return false;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
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
|
+
for (const t of getMCPTargets()) {
|
|
526
|
+
const dir = resolve(t.configPath, "..");
|
|
527
|
+
if (!(await fileExists(dir)))
|
|
528
|
+
continue;
|
|
529
|
+
let cfg = {};
|
|
530
|
+
if (await fileExists(t.configPath)) {
|
|
531
|
+
try {
|
|
532
|
+
cfg = JSON.parse(await readFile(t.configPath, "utf-8"));
|
|
533
|
+
}
|
|
534
|
+
catch { /* fresh */ }
|
|
535
|
+
}
|
|
536
|
+
const servers = cfg[t.mcpKey] ?? {};
|
|
537
|
+
if (servers["psyche"]) {
|
|
538
|
+
console.log(` ✓ ${t.name} — already configured`);
|
|
539
|
+
continue;
|
|
540
|
+
}
|
|
541
|
+
servers["psyche"] = mcpEntry;
|
|
542
|
+
cfg[t.mcpKey] = servers;
|
|
543
|
+
if (dryRun) {
|
|
544
|
+
console.log(` → ${t.name} — would configure`);
|
|
545
|
+
actions++;
|
|
546
|
+
continue;
|
|
547
|
+
}
|
|
548
|
+
await mkdir(dir, { recursive: true });
|
|
549
|
+
await writeFile(t.configPath, JSON.stringify(cfg, null, 2) + "\n", "utf-8");
|
|
550
|
+
console.log(` ✓ ${t.name}`);
|
|
551
|
+
actions++;
|
|
552
|
+
}
|
|
553
|
+
// ── 2. Proxy + env var ────────────────────────────────
|
|
554
|
+
if (proxy && target) {
|
|
555
|
+
const proxyUrl = `http://127.0.0.1:${port}/v1`;
|
|
556
|
+
const shell = process.env.SHELL ?? "/bin/zsh";
|
|
557
|
+
const rcFile = shell.includes("zsh") ? join(homedir(), ".zshrc")
|
|
558
|
+
: shell.includes("bash") ? join(homedir(), ".bashrc")
|
|
559
|
+
: null;
|
|
560
|
+
// Determine which env var to set based on target URL
|
|
561
|
+
const envVar = target.includes("anthropic") ? "ANTHROPIC_BASE_URL" : "OPENAI_BASE_URL";
|
|
562
|
+
const exportLine = `export ${envVar}="${proxyUrl}" # psyche-proxy`;
|
|
563
|
+
// Build proxy launch command
|
|
564
|
+
const proxyArgs = [`-t`, target, `-p`, String(port)];
|
|
565
|
+
if (name)
|
|
566
|
+
proxyArgs.push(`-n`, name);
|
|
567
|
+
if (mbti)
|
|
568
|
+
proxyArgs.push(`--mbti`, mbti.toUpperCase());
|
|
569
|
+
if (locale)
|
|
570
|
+
proxyArgs.push(`-l`, locale);
|
|
571
|
+
const launchCmd = `npx psyche-proxy ${proxyArgs.join(" ")}`;
|
|
572
|
+
if (dryRun) {
|
|
573
|
+
console.log(` → proxy — would start: ${launchCmd}`);
|
|
574
|
+
if (rcFile)
|
|
575
|
+
console.log(` → shell — would append to ${rcFile}: ${exportLine}`);
|
|
576
|
+
actions++;
|
|
577
|
+
}
|
|
578
|
+
else {
|
|
579
|
+
// Append env var to shell rc (idempotent)
|
|
580
|
+
if (rcFile) {
|
|
581
|
+
const rc = await fileExists(rcFile) ? await readFile(rcFile, "utf-8") : "";
|
|
582
|
+
if (!rc.includes("# psyche-proxy")) {
|
|
583
|
+
await writeFile(rcFile, rc + (rc.endsWith("\n") ? "" : "\n") + exportLine + "\n", "utf-8");
|
|
584
|
+
console.log(` ✓ ${envVar} → ${proxyUrl} (${rcFile})`);
|
|
585
|
+
}
|
|
586
|
+
else {
|
|
587
|
+
console.log(` ✓ shell env — already configured`);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
// Start proxy in background
|
|
591
|
+
const { spawn } = await import("node:child_process");
|
|
592
|
+
const child = spawn("npx", ["-y", "psyche-proxy", ...proxyArgs], {
|
|
593
|
+
detached: true, stdio: "ignore",
|
|
594
|
+
});
|
|
595
|
+
child.unref();
|
|
596
|
+
console.log(` ✓ proxy — pid ${child.pid} → ${target}`);
|
|
597
|
+
actions++;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
// ── Summary ───────────────────────────────────────────
|
|
601
|
+
if (actions === 0) {
|
|
602
|
+
console.log(" Nothing to do. All targets already configured.");
|
|
603
|
+
}
|
|
604
|
+
else if (!dryRun) {
|
|
605
|
+
console.log("\nDone. Restart MCP clients to activate. Proxy is running.");
|
|
606
|
+
}
|
|
607
|
+
}
|
|
463
608
|
function usage() {
|
|
464
609
|
console.log(`
|
|
465
610
|
psyche — Artificial Psyche CLI (v0.2)
|
|
@@ -475,6 +620,7 @@ Usage:
|
|
|
475
620
|
psyche intensity Show info about personality intensity config
|
|
476
621
|
psyche reset <dir> [--full]
|
|
477
622
|
psyche diagnose <dir> [--github] Run health checks & show diagnostic report
|
|
623
|
+
psyche setup [--proxy -t URL] [-n NAME] [--mbti TYPE] Auto-configure MCP + proxy
|
|
478
624
|
psyche upgrade [--check] Check/apply package updates safely
|
|
479
625
|
psyche probe [--json] Verify the runtime is truly callable
|
|
480
626
|
psyche profiles [--mbti TYPE] [--json]
|
|
@@ -507,6 +653,12 @@ Examples:
|
|
|
507
653
|
psyche profiles
|
|
508
654
|
psyche profiles --mbti ENFP
|
|
509
655
|
|
|
656
|
+
# Auto-configure all MCP clients
|
|
657
|
+
psyche setup --mbti ENFP --name Luna
|
|
658
|
+
|
|
659
|
+
# Universal proxy — works with any agent using OpenAI SDK
|
|
660
|
+
psyche setup --proxy -t https://api.openai.com/v1 --mbti ENFP
|
|
661
|
+
|
|
510
662
|
# Check for new package versions without applying them
|
|
511
663
|
psyche upgrade --check
|
|
512
664
|
|
|
@@ -663,6 +815,32 @@ async function main() {
|
|
|
663
815
|
await cmdProbe(values.json ?? false);
|
|
664
816
|
break;
|
|
665
817
|
}
|
|
818
|
+
case "setup": {
|
|
819
|
+
const { values } = parseArgs({
|
|
820
|
+
args: rest,
|
|
821
|
+
options: {
|
|
822
|
+
name: { type: "string", short: "n" },
|
|
823
|
+
mbti: { type: "string" },
|
|
824
|
+
locale: { type: "string", short: "l" },
|
|
825
|
+
proxy: { type: "boolean", default: false },
|
|
826
|
+
target: { type: "string", short: "t" },
|
|
827
|
+
port: { type: "string", short: "p" },
|
|
828
|
+
"dry-run": { type: "boolean", default: false },
|
|
829
|
+
},
|
|
830
|
+
allowPositionals: true,
|
|
831
|
+
});
|
|
832
|
+
console.log("\npsyche setup — auto-configuring MCP clients\n");
|
|
833
|
+
await cmdSetup({
|
|
834
|
+
name: values.name ?? "",
|
|
835
|
+
mbti: values.mbti ?? "",
|
|
836
|
+
locale: values.locale ?? "",
|
|
837
|
+
proxy: values.proxy ?? false,
|
|
838
|
+
target: values.target ?? "",
|
|
839
|
+
port: parseInt(values.port ?? "3340", 10),
|
|
840
|
+
dryRun: values["dry-run"] ?? false,
|
|
841
|
+
});
|
|
842
|
+
break;
|
|
843
|
+
}
|
|
666
844
|
default:
|
|
667
845
|
die(`unknown command: ${command}. Run 'psyche help' for usage.`);
|
|
668
846
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "psyche-ai",
|
|
3
|
-
"version": "10.2.
|
|
3
|
+
"version": "10.2.2",
|
|
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.2",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "psyche-ai",
|
|
14
|
-
"version": "10.
|
|
14
|
+
"version": "10.2.2",
|
|
15
15
|
"transport": {
|
|
16
16
|
"type": "stdio"
|
|
17
17
|
},
|