@bobsworkshop/cli 0.7.1 → 1.0.0

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 (35) hide show
  1. package/README.md +139 -5
  2. package/dist/agent-store-DUAYA6SK.js +34 -0
  3. package/dist/agent-store-PI4KOFBE.js +35 -0
  4. package/dist/agent-store-PTYRRKJ5.js +35 -0
  5. package/dist/analyse-auto-BY4BAC2U.js +529 -0
  6. package/dist/analyse-auto-DCC6UDFV.js +529 -0
  7. package/dist/analyse-auto-F3O5DPS2.js +530 -0
  8. package/dist/analyse-auto-FOHKFESD.js +530 -0
  9. package/dist/analyse-auto-I7TIDS4E.js +530 -0
  10. package/dist/analyse-auto-MD6IA3VH.js +529 -0
  11. package/dist/analyse-auto-PJUTCRBW.js +530 -0
  12. package/dist/analyse-auto-RCY7F4TU.js +530 -0
  13. package/dist/analyse-results-42IGEWAQ.js +9 -0
  14. package/dist/analyse-results-4S577CG5.js +8 -0
  15. package/dist/analyse-results-5SAMUHHK.js +9 -0
  16. package/dist/analyse-results-CAXJXEXA.js +9 -0
  17. package/dist/analyse-results-FV5G6X3P.js +9 -0
  18. package/dist/analyse-results-L26WBPUH.js +8 -0
  19. package/dist/analyse-results-QSTTMRQE.js +9 -0
  20. package/dist/analyse-results-XMY3HWMA.js +8 -0
  21. package/dist/bob.js +4776 -394
  22. package/dist/chunk-3RG5ZIWI.js +10 -0
  23. package/dist/chunk-AQGIC65Q.js +922 -0
  24. package/dist/chunk-AYXEMVQS.js +925 -0
  25. package/dist/chunk-B23KYYX3.js +1196 -0
  26. package/dist/chunk-CAF7EJSC.js +213 -0
  27. package/dist/chunk-HU5PQOJI.js +1196 -0
  28. package/dist/chunk-JTMMSCF7.js +1212 -0
  29. package/dist/chunk-NUMFL5IZ.js +1204 -0
  30. package/dist/chunk-NZW7H2BY.js +1196 -0
  31. package/dist/chunk-PNKVD2UK.js +26 -0
  32. package/dist/persona-loader-3I5Y6CRD.js +15 -0
  33. package/dist/persona-loader-EVL7ORNP.js +15 -0
  34. package/dist/persona-loader-SEDW2PPJ.js +14 -0
  35. package/package.json +60 -59
@@ -0,0 +1,213 @@
1
+ // src/core/agent-store.ts
2
+ import * as fs from "fs";
3
+ import * as path from "path";
4
+ import * as os from "os";
5
+ var BOB_DIR = path.join(os.homedir(), ".bob");
6
+ function resolveAgentName(input, workingDir) {
7
+ const cwd = workingDir || process.cwd();
8
+ const baseName = input.toLowerCase().endsWith("bob") ? input : `${input}Bob`;
9
+ if (!agentExists(baseName, cwd)) return baseName;
10
+ let counter = 2;
11
+ while (agentExists(`${baseName}${counter}`, cwd)) {
12
+ counter++;
13
+ }
14
+ return `${baseName}${counter}`;
15
+ }
16
+ function getAgentsDir(workingDir) {
17
+ const cwd = workingDir || process.cwd();
18
+ const projectName = path.basename(cwd);
19
+ return path.join(BOB_DIR, "projects", projectName, "agents");
20
+ }
21
+ function getAgentDir(agentName, workingDir) {
22
+ return path.join(getAgentsDir(workingDir), agentName);
23
+ }
24
+ function getRegistryPath(workingDir) {
25
+ return path.join(getAgentsDir(workingDir), "registry.json");
26
+ }
27
+ function getSessionPath(agentName, workingDir) {
28
+ return path.join(getAgentDir(agentName, workingDir), "session.json");
29
+ }
30
+ function getMessagesDir(agentName, workingDir) {
31
+ return path.join(getAgentDir(agentName, workingDir), "messages");
32
+ }
33
+ function getSummaryPath(agentName, workingDir) {
34
+ return path.join(getAgentDir(agentName, workingDir), "summary.txt");
35
+ }
36
+ function ensureAgentDir(agentName, workingDir) {
37
+ const agentDir = getAgentDir(agentName, workingDir);
38
+ const messagesDir = getMessagesDir(agentName, workingDir);
39
+ if (!fs.existsSync(agentDir)) fs.mkdirSync(agentDir, { recursive: true });
40
+ if (!fs.existsSync(messagesDir)) fs.mkdirSync(messagesDir, { recursive: true });
41
+ }
42
+ function ensureAgentsDir(workingDir) {
43
+ const agentsDir = getAgentsDir(workingDir);
44
+ if (!fs.existsSync(agentsDir)) fs.mkdirSync(agentsDir, { recursive: true });
45
+ }
46
+ function loadRegistry(workingDir) {
47
+ ensureAgentsDir(workingDir);
48
+ const registryPath = getRegistryPath(workingDir);
49
+ if (!fs.existsSync(registryPath)) return { agents: [] };
50
+ try {
51
+ return JSON.parse(fs.readFileSync(registryPath, "utf-8"));
52
+ } catch {
53
+ return { agents: [] };
54
+ }
55
+ }
56
+ function saveRegistry(registry, workingDir) {
57
+ ensureAgentsDir(workingDir);
58
+ fs.writeFileSync(
59
+ getRegistryPath(workingDir),
60
+ JSON.stringify(registry, null, 2)
61
+ );
62
+ }
63
+ function getRegistryEntry(agentName, workingDir) {
64
+ const registry = loadRegistry(workingDir);
65
+ return registry.agents.find((a) => a.name === agentName) || null;
66
+ }
67
+ function upsertRegistryEntry(entry, workingDir) {
68
+ const registry = loadRegistry(workingDir);
69
+ const idx = registry.agents.findIndex((a) => a.name === entry.name);
70
+ if (idx >= 0) {
71
+ registry.agents[idx] = entry;
72
+ } else {
73
+ registry.agents.push(entry);
74
+ }
75
+ saveRegistry(registry, workingDir);
76
+ }
77
+ function removeRegistryEntry(agentName, workingDir) {
78
+ const registry = loadRegistry(workingDir);
79
+ registry.agents = registry.agents.filter((a) => a.name !== agentName);
80
+ saveRegistry(registry, workingDir);
81
+ }
82
+ function loadSession(agentName, workingDir) {
83
+ const sessionPath = getSessionPath(agentName, workingDir);
84
+ if (!fs.existsSync(sessionPath)) return null;
85
+ try {
86
+ return JSON.parse(fs.readFileSync(sessionPath, "utf-8"));
87
+ } catch {
88
+ return null;
89
+ }
90
+ }
91
+ function saveSession(session, workingDir) {
92
+ ensureAgentDir(session.name, workingDir);
93
+ fs.writeFileSync(
94
+ getSessionPath(session.name, workingDir),
95
+ JSON.stringify(session, null, 2)
96
+ );
97
+ upsertRegistryEntry(
98
+ {
99
+ name: session.name,
100
+ task: session.task,
101
+ personaId: session.personaId,
102
+ status: session.status,
103
+ createdAt: session.createdAt,
104
+ lastActive: session.lastActive
105
+ },
106
+ workingDir
107
+ );
108
+ }
109
+ function saveAgentMessage(agentName, message, workingDir) {
110
+ ensureAgentDir(agentName, workingDir);
111
+ const messagesDir = getMessagesDir(agentName, workingDir);
112
+ const filename = `${Date.now()}_${message.sender}.json`;
113
+ fs.writeFileSync(
114
+ path.join(messagesDir, filename),
115
+ JSON.stringify(message, null, 2)
116
+ );
117
+ const session = loadSession(agentName, workingDir);
118
+ if (session) {
119
+ session.messageCount += 1;
120
+ session.lastActive = (/* @__PURE__ */ new Date()).toISOString();
121
+ saveSession(session, workingDir);
122
+ }
123
+ }
124
+ function loadAgentMessages(agentName, workingDir) {
125
+ const messagesDir = getMessagesDir(agentName, workingDir);
126
+ if (!fs.existsSync(messagesDir)) return [];
127
+ return fs.readdirSync(messagesDir).filter((f) => f.endsWith(".json")).sort().map((file) => {
128
+ try {
129
+ return JSON.parse(
130
+ fs.readFileSync(path.join(messagesDir, file), "utf-8")
131
+ );
132
+ } catch {
133
+ return null;
134
+ }
135
+ }).filter(Boolean);
136
+ }
137
+ function saveAgentSummary(agentName, summary, workingDir) {
138
+ ensureAgentDir(agentName, workingDir);
139
+ fs.writeFileSync(getSummaryPath(agentName, workingDir), summary, "utf-8");
140
+ const session = loadSession(agentName, workingDir);
141
+ if (session) {
142
+ session.lastSummary = summary;
143
+ saveSession(session, workingDir);
144
+ }
145
+ }
146
+ function loadAgentSummary(agentName, workingDir) {
147
+ const summaryPath = getSummaryPath(agentName, workingDir);
148
+ if (!fs.existsSync(summaryPath)) return null;
149
+ try {
150
+ return fs.readFileSync(summaryPath, "utf-8");
151
+ } catch {
152
+ return null;
153
+ }
154
+ }
155
+ function createAgent(name, task, personaId, workingDir) {
156
+ const now = (/* @__PURE__ */ new Date()).toISOString();
157
+ const session = {
158
+ id: `agent_${name}_${Date.now()}`,
159
+ name,
160
+ task,
161
+ personaId,
162
+ status: "active",
163
+ messageCount: 0,
164
+ lastSummary: null,
165
+ createdAt: now,
166
+ lastActive: now
167
+ };
168
+ ensureAgentDir(name, workingDir);
169
+ saveSession(session, workingDir);
170
+ return session;
171
+ }
172
+ function resetAgent(agentName, workingDir) {
173
+ const agentDir = getAgentDir(agentName, workingDir);
174
+ if (fs.existsSync(agentDir)) {
175
+ fs.rmSync(agentDir, { recursive: true, force: true });
176
+ }
177
+ removeRegistryEntry(agentName, workingDir);
178
+ }
179
+ function stopAgent(agentName, workingDir) {
180
+ const session = loadSession(agentName, workingDir);
181
+ if (session) {
182
+ session.status = "stopped";
183
+ session.lastActive = (/* @__PURE__ */ new Date()).toISOString();
184
+ saveSession(session, workingDir);
185
+ }
186
+ }
187
+ function agentExists(agentName, workingDir) {
188
+ return fs.existsSync(getSessionPath(agentName, workingDir));
189
+ }
190
+ function getActiveAgentCount(workingDir) {
191
+ const registry = loadRegistry(workingDir);
192
+ return registry.agents.filter(
193
+ (a) => a.status === "active" || a.status === "idle"
194
+ ).length;
195
+ }
196
+
197
+ export {
198
+ resolveAgentName,
199
+ getAgentsDir,
200
+ loadRegistry,
201
+ getRegistryEntry,
202
+ loadSession,
203
+ saveSession,
204
+ saveAgentMessage,
205
+ loadAgentMessages,
206
+ saveAgentSummary,
207
+ loadAgentSummary,
208
+ createAgent,
209
+ resetAgent,
210
+ stopAgent,
211
+ agentExists,
212
+ getActiveAgentCount
213
+ };