@gonzih/cc-discord 0.2.13 → 0.2.15
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/bot.js +1 -1
- package/dist/meta-agent-manager.d.ts +4 -1
- package/dist/meta-agent-manager.js +17 -1
- package/package.json +1 -1
package/dist/bot.js
CHANGED
|
@@ -1293,7 +1293,7 @@ export class CcDiscordBot {
|
|
|
1293
1293
|
startMetaAgentPolling() {
|
|
1294
1294
|
if (!this.wire)
|
|
1295
1295
|
return;
|
|
1296
|
-
this.metaAgentManager.startPolling(this.wire, () => Array.from(this.channelNamespaceMap.values())
|
|
1296
|
+
this.metaAgentManager.startPolling(this.wire, () => Array.from(this.channelNamespaceMap.values()));
|
|
1297
1297
|
}
|
|
1298
1298
|
stop() {
|
|
1299
1299
|
for (const [key, session] of this.sessions) {
|
|
@@ -39,7 +39,10 @@ export declare function spawnSession(ns: string, message: string, token: string,
|
|
|
39
39
|
export interface MetaAgentManager {
|
|
40
40
|
ensureWorkspace: (ns: string, repoUrl: string) => Promise<void>;
|
|
41
41
|
injectMcp: (ns: string, token: string) => void;
|
|
42
|
-
startPolling: (wire: Wire, getNamespaces: () =>
|
|
42
|
+
startPolling: (wire: Wire, getNamespaces: () => Array<{
|
|
43
|
+
namespace: string;
|
|
44
|
+
repoUrl: string;
|
|
45
|
+
}>) => void;
|
|
43
46
|
stop: () => void;
|
|
44
47
|
}
|
|
45
48
|
/**
|
|
@@ -34,6 +34,13 @@ export async function ensureWorkspace(ns, repoUrl) {
|
|
|
34
34
|
console.log(`[meta-agent-manager] cloning ${repoUrl} → ${wsPath}`);
|
|
35
35
|
execSync(`git clone ${repoUrl} ${wsPath}`, { stdio: "pipe" });
|
|
36
36
|
console.log(`[meta-agent-manager] clone complete for namespace=${ns}`);
|
|
37
|
+
try {
|
|
38
|
+
execSync(`/opt/homebrew/bin/git-kb init`, { cwd: wsPath, stdio: "pipe" });
|
|
39
|
+
console.log(`[meta-agent-manager] gitkb initialized for namespace=${ns}`);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
console.warn(`[meta-agent-manager] gitkb init failed (ns=${ns}):`, err.message);
|
|
43
|
+
}
|
|
37
44
|
}
|
|
38
45
|
/**
|
|
39
46
|
* Write .mcp.json to the workspace so the claude session has MCP tool access.
|
|
@@ -61,6 +68,10 @@ export function injectMcp(ns, wsPath, token) {
|
|
|
61
68
|
const systemPath = process.env.PATH ?? "/usr/local/bin:/usr/bin:/bin";
|
|
62
69
|
const config = {
|
|
63
70
|
mcpServers: {
|
|
71
|
+
"gitkb": {
|
|
72
|
+
command: "/opt/homebrew/bin/git-kb",
|
|
73
|
+
args: ["mcp"],
|
|
74
|
+
},
|
|
64
75
|
"cc-agent": {
|
|
65
76
|
command: "/opt/homebrew/bin/npx",
|
|
66
77
|
args: ["-y", "--prefer-online", "@gonzih/cc-agent"],
|
|
@@ -190,7 +201,7 @@ export function createMetaAgentManager() {
|
|
|
190
201
|
const namespaces = getNamespaces();
|
|
191
202
|
if (namespaces.length === 0)
|
|
192
203
|
return;
|
|
193
|
-
for (const ns of namespaces) {
|
|
204
|
+
for (const { namespace: ns, repoUrl } of namespaces) {
|
|
194
205
|
if (activeNamespaces.has(ns))
|
|
195
206
|
continue;
|
|
196
207
|
wire.discord.dequeue(ns)
|
|
@@ -228,6 +239,11 @@ export function createMetaAgentManager() {
|
|
|
228
239
|
});
|
|
229
240
|
return;
|
|
230
241
|
}
|
|
242
|
+
// Ensure the workspace directory exists — idempotent if already cloned.
|
|
243
|
+
// This guards against the workspace being absent after a bot restart.
|
|
244
|
+
const wsPath = workspacePath(ns);
|
|
245
|
+
await ensureWorkspace(ns, repoUrl);
|
|
246
|
+
injectMcp(ns, wsPath, token);
|
|
231
247
|
spawnSession(ns, content, token, wire)
|
|
232
248
|
.catch((err) => {
|
|
233
249
|
console.error(`[meta-agent-manager] session error (ns=${ns}):`, err.message);
|