@pi-unipi/subagents 0.1.5 → 0.1.7
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/package.json +3 -2
- package/src/index.ts +85 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-unipi/subagents",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Subagents for UniPi — parallel execution, file locking, workflow integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@pi-unipi/core": "*",
|
|
20
|
-
"@pi-unipi/workflow": "*"
|
|
20
|
+
"@pi-unipi/workflow": "*",
|
|
21
|
+
"@pi-unipi/info-screen": "*"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
24
|
"typescript": "^5.8.3"
|
package/src/index.ts
CHANGED
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
import { defineTool, type ExtensionAPI, type ExtensionContext } from "@mariozechner/pi-coding-agent";
|
|
9
9
|
import { Text } from "@mariozechner/pi-tui";
|
|
10
10
|
import { Type } from "@sinclair/typebox";
|
|
11
|
+
|
|
12
|
+
// Get info registry from global
|
|
13
|
+
function getInfoRegistry() {
|
|
14
|
+
const g = globalThis as any;
|
|
15
|
+
return g.__unipi_info_registry;
|
|
16
|
+
}
|
|
11
17
|
import { AgentManager } from "./agent-manager.js";
|
|
12
18
|
import { initConfig, saveGlobalConfig } from "./config.js";
|
|
13
19
|
import { type AgentActivity, type AgentRecord, BUILTIN_TYPES } from "./types.js";
|
|
@@ -79,6 +85,85 @@ export default function (pi: ExtensionAPI) {
|
|
|
79
85
|
const workspaceConfig = `${ctx.cwd}/.unipi/config/subagents.json`;
|
|
80
86
|
const workspaceAgents = `${ctx.cwd}/.unipi/config/agents/`;
|
|
81
87
|
|
|
88
|
+
// Register info group
|
|
89
|
+
const registry = getInfoRegistry();
|
|
90
|
+
if (registry) {
|
|
91
|
+
registry.registerGroup({
|
|
92
|
+
id: "subagents",
|
|
93
|
+
name: "Subagents",
|
|
94
|
+
icon: "🤖",
|
|
95
|
+
priority: 80,
|
|
96
|
+
config: {
|
|
97
|
+
showByDefault: true,
|
|
98
|
+
stats: [
|
|
99
|
+
{ id: "maxConcurrent", label: "Max Concurrent", show: true },
|
|
100
|
+
{ id: "activeCount", label: "Active Agents", show: true },
|
|
101
|
+
{ id: "enabled", label: "Enabled", show: true },
|
|
102
|
+
{ id: "types", label: "Available Types", show: true },
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
dataProvider: async () => {
|
|
106
|
+
// Get available agent types
|
|
107
|
+
const types = config.types || {};
|
|
108
|
+
const builtinTypes = ["explore", "work"];
|
|
109
|
+
|
|
110
|
+
// Check for custom agent types in filesystem
|
|
111
|
+
const customTypes: string[] = [];
|
|
112
|
+
try {
|
|
113
|
+
const fs = require("fs");
|
|
114
|
+
const path = require("path");
|
|
115
|
+
|
|
116
|
+
// Check global agents directory
|
|
117
|
+
if (fs.existsSync(globalAgents)) {
|
|
118
|
+
const files = fs.readdirSync(globalAgents);
|
|
119
|
+
for (const file of files) {
|
|
120
|
+
if (file.endsWith(".md")) {
|
|
121
|
+
customTypes.push(file.replace(".md", ""));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Check workspace agents directory
|
|
127
|
+
if (fs.existsSync(workspaceAgents)) {
|
|
128
|
+
const files = fs.readdirSync(workspaceAgents);
|
|
129
|
+
for (const file of files) {
|
|
130
|
+
if (file.endsWith(".md")) {
|
|
131
|
+
const name = file.replace(".md", "");
|
|
132
|
+
if (!customTypes.includes(name)) {
|
|
133
|
+
customTypes.push(name);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
} catch {
|
|
139
|
+
// Ignore errors
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Build available types list
|
|
143
|
+
const allTypes = [...new Set([...builtinTypes, ...Object.keys(types), ...customTypes])];
|
|
144
|
+
const typeList = allTypes.map(t => {
|
|
145
|
+
const isEnabled = types[t]?.enabled !== false;
|
|
146
|
+
const isBuiltin = builtinTypes.includes(t);
|
|
147
|
+
const scope = customTypes.includes(t) ? "project" : "global";
|
|
148
|
+
return `${t}(${scope})${isEnabled ? "" : " [disabled]"}`;
|
|
149
|
+
}).join(", ");
|
|
150
|
+
|
|
151
|
+
// Get active agents count
|
|
152
|
+
const activeAgents = manager.listAgents().filter(a => a.status === "running").length;
|
|
153
|
+
|
|
154
|
+
return {
|
|
155
|
+
maxConcurrent: { value: String(manager.getMaxConcurrent()) },
|
|
156
|
+
activeCount: { value: String(activeAgents) },
|
|
157
|
+
enabled: { value: config.enabled ? "yes" : "no" },
|
|
158
|
+
types: {
|
|
159
|
+
value: allTypes.length > 0 ? allTypes[0] : "none",
|
|
160
|
+
detail: allTypes.length > 1 ? typeList : undefined,
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
82
167
|
ctx.ui.notify(
|
|
83
168
|
`UniPi Subagents config:\n` +
|
|
84
169
|
`• Global: ${globalConfig}\n` +
|