@illusoryai/pi-agents 0.1.2 → 0.1.4

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.
Files changed (2) hide show
  1. package/install.mjs +61 -0
  2. package/package.json +4 -1
package/install.mjs ADDED
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @illusoryai/pi-agents postinstall
4
+ * Auto-installs peer dependencies and registers them in pi settings.
5
+ */
6
+ import { execSync } from "node:child_process";
7
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
8
+ import { join, dirname } from "node:path";
9
+ import { homedir } from "node:os";
10
+ import { fileURLToPath } from "node:url";
11
+
12
+ const PEERS = ["pi-subagents"];
13
+
14
+ const __dirname = dirname(fileURLToPath(import.meta.url));
15
+ const globalModules = join(__dirname, "..", "..");
16
+
17
+ // 1. Install missing peer deps globally
18
+ for (const peer of PEERS) {
19
+ const peerPath = join(globalModules, peer);
20
+ if (!existsSync(peerPath)) {
21
+ console.log(`[pi-agents] Installing peer: ${peer}`);
22
+ try {
23
+ execSync(`npm install -g ${peer}`, { stdio: "pipe" });
24
+ console.log(`[pi-agents] Installed ${peer}`);
25
+ } catch {
26
+ console.warn(
27
+ `[pi-agents] Could not auto-install ${peer}. Run: pi install npm:${peer}`
28
+ );
29
+ }
30
+ }
31
+ }
32
+
33
+ // 2. Ensure peer deps are registered in pi settings
34
+ const home = process.env.SUDO_USER
35
+ ? join("/home", process.env.SUDO_USER)
36
+ : homedir();
37
+ const settingsPath = join(home, ".pi", "agent", "settings.json");
38
+
39
+ if (existsSync(settingsPath)) {
40
+ try {
41
+ const settings = JSON.parse(readFileSync(settingsPath, "utf8"));
42
+ const packages = settings.packages || [];
43
+ let changed = false;
44
+
45
+ for (const peer of PEERS) {
46
+ const entry = `npm:${peer}`;
47
+ if (!packages.includes(entry)) {
48
+ packages.push(entry);
49
+ changed = true;
50
+ }
51
+ }
52
+
53
+ if (changed) {
54
+ settings.packages = packages;
55
+ writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n");
56
+ console.log("[pi-agents] Updated pi settings with peer deps");
57
+ }
58
+ } catch {
59
+ // Don't fail install on settings update error
60
+ }
61
+ }
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "@illusoryai/pi-agents",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "pi-package"
8
8
  ],
9
9
  "description": "Agent orchestration and governance definitions for pi",
10
+ "scripts": {
11
+ "postinstall": "node install.mjs"
12
+ },
10
13
  "pi": {
11
14
  "agents": [
12
15
  "./agents"