psyche-ai 10.2.1 → 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 +101 -50
- package/package.json +1 -1
- package/server.json +2 -2
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,99 @@ 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
|
-
|
|
527
|
-
|
|
528
|
-
const configDir = resolve(target.configPath, "..");
|
|
529
|
-
if (!(await fileExists(configDir)))
|
|
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)))
|
|
530
528
|
continue;
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
if (await fileExists(target.configPath)) {
|
|
529
|
+
let cfg = {};
|
|
530
|
+
if (await fileExists(t.configPath)) {
|
|
534
531
|
try {
|
|
535
|
-
|
|
536
|
-
}
|
|
537
|
-
catch {
|
|
538
|
-
config = {};
|
|
532
|
+
cfg = JSON.parse(await readFile(t.configPath, "utf-8"));
|
|
539
533
|
}
|
|
534
|
+
catch { /* fresh */ }
|
|
540
535
|
}
|
|
541
|
-
|
|
542
|
-
const servers = config[target.mcpKey] ?? {};
|
|
536
|
+
const servers = cfg[t.mcpKey] ?? {};
|
|
543
537
|
if (servers["psyche"]) {
|
|
544
|
-
console.log(` ✓ ${
|
|
545
|
-
skipped++;
|
|
538
|
+
console.log(` ✓ ${t.name} — already configured`);
|
|
546
539
|
continue;
|
|
547
540
|
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
config[target.mcpKey] = servers;
|
|
541
|
+
servers["psyche"] = mcpEntry;
|
|
542
|
+
cfg[t.mcpKey] = servers;
|
|
551
543
|
if (dryRun) {
|
|
552
|
-
console.log(` → ${
|
|
553
|
-
|
|
544
|
+
console.log(` → ${t.name} — would configure`);
|
|
545
|
+
actions++;
|
|
554
546
|
continue;
|
|
555
547
|
}
|
|
556
|
-
|
|
557
|
-
await
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
if (
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
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
|
+
}
|
|
566
599
|
}
|
|
567
|
-
|
|
568
|
-
if (
|
|
569
|
-
console.log(
|
|
600
|
+
// ── Summary ───────────────────────────────────────────
|
|
601
|
+
if (actions === 0) {
|
|
602
|
+
console.log(" Nothing to do. All targets already configured.");
|
|
570
603
|
}
|
|
571
|
-
if (
|
|
572
|
-
console.log(
|
|
604
|
+
else if (!dryRun) {
|
|
605
|
+
console.log("\nDone. Restart MCP clients to activate. Proxy is running.");
|
|
573
606
|
}
|
|
574
607
|
}
|
|
575
608
|
function usage() {
|
|
@@ -587,6 +620,7 @@ Usage:
|
|
|
587
620
|
psyche intensity Show info about personality intensity config
|
|
588
621
|
psyche reset <dir> [--full]
|
|
589
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
|
|
590
624
|
psyche upgrade [--check] Check/apply package updates safely
|
|
591
625
|
psyche probe [--json] Verify the runtime is truly callable
|
|
592
626
|
psyche profiles [--mbti TYPE] [--json]
|
|
@@ -619,6 +653,12 @@ Examples:
|
|
|
619
653
|
psyche profiles
|
|
620
654
|
psyche profiles --mbti ENFP
|
|
621
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
|
+
|
|
622
662
|
# Check for new package versions without applying them
|
|
623
663
|
psyche upgrade --check
|
|
624
664
|
|
|
@@ -782,12 +822,23 @@ async function main() {
|
|
|
782
822
|
name: { type: "string", short: "n" },
|
|
783
823
|
mbti: { type: "string" },
|
|
784
824
|
locale: { type: "string", short: "l" },
|
|
825
|
+
proxy: { type: "boolean", default: false },
|
|
826
|
+
target: { type: "string", short: "t" },
|
|
827
|
+
port: { type: "string", short: "p" },
|
|
785
828
|
"dry-run": { type: "boolean", default: false },
|
|
786
829
|
},
|
|
787
830
|
allowPositionals: true,
|
|
788
831
|
});
|
|
789
832
|
console.log("\npsyche setup — auto-configuring MCP clients\n");
|
|
790
|
-
await cmdSetup(
|
|
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
|
+
});
|
|
791
842
|
break;
|
|
792
843
|
}
|
|
793
844
|
default:
|
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
|
},
|