Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions claude-code/bundle/session-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// dist/src/hooks/session-start.js
import { fileURLToPath } from "node:url";
import { dirname, join as join4 } from "node:path";
import { mkdirSync as mkdirSync2, appendFileSync as appendFileSync2, readFileSync as readFileSync3 } from "node:fs";
import { mkdirSync as mkdirSync2, appendFileSync as appendFileSync2, readFileSync as readFileSync3, readdirSync, rmSync } from "node:fs";
import { execSync as execSync2 } from "node:child_process";
import { homedir as homedir4 } from "node:os";

Expand Down Expand Up @@ -454,8 +454,20 @@ async function main() {
log3(`autoupdate: updating ${current} \u2192 ${latest}`);
try {
const scopes = ["user", "project", "local", "managed"];
const cmd = scopes.map((s) => `claude plugin update hivemind@hivemind --scope ${s} 2>/dev/null`).join("; ");
const cmd = scopes.map((s) => `claude plugin update hivemind@hivemind --scope ${s} 2>/dev/null || true`).join("; ");
execSync2(cmd, { stdio: "ignore", timeout: 6e4 });
try {
const cacheParent = join4(homedir4(), ".claude", "plugins", "cache", "hivemind", "hivemind");
const entries = readdirSync(cacheParent, { withFileTypes: true });
for (const e of entries) {
if (e.isDirectory() && e.name !== latest) {
rmSync(join4(cacheParent, e.name), { recursive: true, force: true });
log3(`cache cleanup: removed old version ${e.name}`);
}
}
} catch (e) {
log3(`cache cleanup failed: ${e.message}`);
}
updateNotice = `

\u2705 Hivemind auto-updated: ${current} \u2192 ${latest}. Run /reload-plugins to apply.`;
Expand Down
2 changes: 1 addition & 1 deletion esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ await build({
contents: [
'import { createRequire } from "node:module";',
'const _f = createRequire(import.meta.url)("fs");',
'export const { existsSync, writeFileSync, mkdirSync, appendFileSync } = _f;',
'export const { existsSync, writeFileSync, mkdirSync, appendFileSync, unlinkSync } = _f;',
'const _k = ["rea","dFile","Sync"].join("");',
'export const rfs = _f[_k];',
'export { rfs as readFileSync };',
Expand Down
17 changes: 15 additions & 2 deletions src/hooks/session-start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { fileURLToPath } from "node:url";
import { dirname, join } from "node:path";
import { mkdirSync, appendFileSync, readFileSync } from "node:fs";
import { mkdirSync, appendFileSync, readFileSync, readdirSync, rmSync } from "node:fs";
import { execSync } from "node:child_process";
import { homedir } from "node:os";
import { loadCredentials, saveCredentials, login } from "../commands/auth.js";
Expand Down Expand Up @@ -200,9 +200,22 @@ async function main(): Promise<void> {
try {
const scopes = ["user", "project", "local", "managed"];
const cmd = scopes
.map(s => `claude plugin update hivemind@hivemind --scope ${s} 2>/dev/null`)
.map(s => `claude plugin update hivemind@hivemind --scope ${s} 2>/dev/null || true`)
.join("; ");
execSync(cmd, { stdio: "ignore", timeout: 60_000 });
// Clean up old cached versions, keep only the latest
try {
const cacheParent = join(homedir(), ".claude", "plugins", "cache", "hivemind", "hivemind");
const entries = readdirSync(cacheParent, { withFileTypes: true });
for (const e of entries) {
if (e.isDirectory() && e.name !== latest) {
rmSync(join(cacheParent, e.name), { recursive: true, force: true });
log(`cache cleanup: removed old version ${e.name}`);
}
}
} catch (e: any) {
log(`cache cleanup failed: ${e.message}`);
}
updateNotice = `\n\n✅ Hivemind auto-updated: ${current} → ${latest}. Run /reload-plugins to apply.`;
process.stderr.write(`✅ Hivemind auto-updated: ${current} → ${latest}. Run /reload-plugins to apply.\n`);
log(`autoupdate succeeded: ${current} → ${latest}`);
Expand Down
Loading