Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
#!/usr/bin/env node
import { readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { execSync } from "node:child_process";
const ROOT = new URL("..", import.meta.url).pathname.replace(/\/$/, "");
const WORKSPACE_DIRS = ["src/shared", "src/app", "src/daemon", "src/daemon/agent-driver", "src/web", "src/email-worker", "src/ws-do", "src/queue-worker", "src/desktop"];
const DEPLOY_TRIGGER_DIRS = ["src/web", "src/email-worker", "src/ws-do", "src/queue-worker"];
function readPkg(dir) {
const p = join(ROOT, dir, "package.json");
return { path: p, pkg: JSON.parse(readFileSync(p, "utf8")) };
}
function writePkg(path, pkg) {
writeFileSync(path, JSON.stringify(pkg, null, 2) + "\n");
}
function bumpSemver(current, type) {
const base = current.split("-")[0];
const [major, minor, patch] = base.split(".").map(Number);
if (type === "major") return `${major + 1}.0.0`;
if (type === "minor") return `${major}.${minor + 1}.0`;
return `${major}.${minor}.${patch + 1}`;
}
const args = process.argv.slice(2);
const updateMinCli = args.includes("--min-cli");
const includeDesktop = args.includes("--desktop");
const includeMobile = args.includes("--mobile");
const unsupportedFlag = args.find(
(arg) =>
arg.startsWith("--") &&
!["--min-cli", "--desktop", "--mobile"].includes(arg),
);
if (unsupportedFlag) {
console.error(`Unsupported flag: ${unsupportedFlag}`);
process.exit(1);
}
const filtered = args.filter((a) => !a.startsWith("--"));
const arg = filtered[0];
if (!arg) {
console.error("Usage: pnpm bump <version|patch|minor|major> [flags]");
console.error(" pnpm bump patch");
console.error(" pnpm bump patch --desktop # trigger desktop build");
console.error(" pnpm bump patch --mobile # publish this version to TestFlight");
console.error(" pnpm bump patch --min-cli # also update MIN_CLI_VERSION");
process.exit(1);
}
const BUMP_TYPES = ["patch", "minor", "major"];
let version;
if (BUMP_TYPES.includes(arg)) {
const { pkg } = readPkg(WORKSPACE_DIRS[0]);
version = bumpSemver(pkg.version, arg);
} else {
version = arg.replace(/^v/, "");
if (!/^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/.test(version)) {
console.error(`Invalid version: ${arg}`);
process.exit(1);
}
}
console.log(`\nπ¦ Bumping all packages to v${version}\n`);
const files = [];
for (const dir of WORKSPACE_DIRS) {
const { path, pkg } = readPkg(dir);
const old = pkg.version;
pkg.version = version;
writePkg(path, pkg);
files.push(path);
console.log(` ${pkg.name}: ${old} β ${version}`);
}
// CF Workers deploy triggers (always)
for (const dir of DEPLOY_TRIGGER_DIRS) {
const triggerPath = join(ROOT, dir, ".deploy-version");
writeFileSync(triggerPath, version + "\n");
files.push(triggerPath);
}
console.log(` CF deploy triggers updated`);
// Sync tauri.conf.json version (always)
const tauriConfPath = join(ROOT, "src/desktop/src-tauri/tauri.conf.json");
const tauriConf = JSON.parse(readFileSync(tauriConfPath, "utf8"));
const oldTauriVersion = tauriConf.version;
tauriConf.version = version;
writeFileSync(tauriConfPath, JSON.stringify(tauriConf, null, 2) + "\n");
files.push(tauriConfPath);
console.log(` tauri.conf.json: ${oldTauriVersion} β ${version}`);
// Sync the generated iOS project's public version (always)
const iosProjectPath = join(ROOT, "src/desktop/src-tauri/gen/apple/project.yml");
let iosProject = readFileSync(iosProjectPath, "utf8");
const oldIosVersionMatch = iosProject.match(/^\s*CFBundleShortVersionString:\s*(\S+)\s*$/m);
if (!oldIosVersionMatch) {
throw new Error("CFBundleShortVersionString is missing from the generated iOS project");
}
iosProject = iosProject.replace(
/^(\s*CFBundleShortVersionString:\s*)\S+\s*$/m,
`$1${version}`,
);
writeFileSync(iosProjectPath, iosProject);
files.push(iosProjectPath);
console.log(` iOS CFBundleShortVersionString: ${oldIosVersionMatch[1]} β ${version}`);
// Sync Cargo.toml version (always)
const cargoTomlPath = join(ROOT, "src/desktop/src-tauri/Cargo.toml");
let cargoToml = readFileSync(cargoTomlPath, "utf8");
const oldCargoMatch = cargoToml.match(/^version = "([^"]+)"/m);
const oldCargoVersion = oldCargoMatch ? oldCargoMatch[1] : "unknown";
cargoToml = cargoToml.replace(/^version = "[^"]+"/m, `version = "${version}"`);
writeFileSync(cargoTomlPath, cargoToml);
files.push(cargoTomlPath);
console.log(` Cargo.toml: ${oldCargoVersion} β ${version}`);
// Sync Cargo.lock version for alook-desktop (always)
const cargoLockPath = join(ROOT, "src/desktop/src-tauri/Cargo.lock");
let cargoLock = readFileSync(cargoLockPath, "utf8");
cargoLock = cargoLock.replace(
/(name = "alook-desktop"\nversion = ")[^"]+"/,
`$1${version}"`,
);
writeFileSync(cargoLockPath, cargoLock);
files.push(cargoLockPath);
console.log(` Cargo.lock: alook-desktop β ${version}`);
// Desktop deploy trigger (only with --desktop)
if (includeDesktop) {
const triggerPath = join(ROOT, "src/desktop/.deploy-version");
writeFileSync(triggerPath, version + "\n");
files.push(triggerPath);
console.log(` Desktop deploy trigger written`);
}
// TestFlight deploy trigger (only with --mobile)
if (includeMobile) {
const triggerPath = join(ROOT, "src/desktop/.deploy-version-mobile");
writeFileSync(triggerPath, version + "\n");
files.push(triggerPath);
console.log(` TestFlight deploy trigger written`);
}
if (updateMinCli) {
const tomlPath = join(ROOT, "src/web/wrangler.toml");
let toml = readFileSync(tomlPath, "utf8");
const oldMatch = toml.match(/MIN_CLI_VERSION\s*=\s*"([^"]+)"/);
const oldMinCli = oldMatch ? oldMatch[1] : "unknown";
toml = toml.replace(/MIN_CLI_VERSION\s*=\s*"[^"]+"/, `MIN_CLI_VERSION = "${version}"`);
writeFileSync(tomlPath, toml);
files.push(tomlPath);
console.log(` MIN_CLI_VERSION: ${oldMinCli} β ${version} (wrangler.toml)`);
}
const gitFiles = files.map((f) => f.replace(ROOT + "/", ""));
execSync(`git add ${gitFiles.join(" ")}`, { cwd: ROOT, stdio: "inherit" });
execSync(`git commit -m "release: v${version}"`, { cwd: ROOT, stdio: "inherit" });
console.log(`\nβ
Committed: v${version}`);
console.log(`\nπ Next steps:`);
console.log(` git push origin main`);
console.log(` # CI will auto-tag and trigger:`);
console.log(` # - CF Workers deploy (always)`);
if (includeDesktop) console.log(` # - Desktop build (macOS/Linux/Windows)`);
if (!includeDesktop) console.log(` # - No desktop build (add --desktop to include)`);
if (includeMobile) console.log(` # - Signed iOS build and automatic TestFlight upload`);
if (!includeMobile) console.log(` # - No TestFlight upload (add --mobile to include)`);
console.log();