diff --git a/clawdhub b/clawdhub index 006e1b1f..8229010b 100755 --- a/clawdhub +++ b/clawdhub @@ -1,3 +1,30 @@ #!/usr/bin/env bun -import './packages/clawdhub/bin/clawdhub.js' +import { existsSync } from 'node:fs' +import { stat } from 'node:fs/promises' +import { fileURLToPath } from 'node:url' +const distCliUrl = new URL('./packages/clawdhub/dist/cli.js', import.meta.url) +const distCliPath = fileURLToPath(distCliUrl) +const srcCliPath = fileURLToPath(new URL('./packages/clawdhub/src/cli.ts', import.meta.url)) + +const shouldBuild = await (async () => { + if (!existsSync(distCliPath)) return true + try { + const [src, dist] = await Promise.all([stat(srcCliPath), stat(distCliPath)]) + return src.mtimeMs > dist.mtimeMs + } catch { + return true + } +})() + +if (shouldBuild) { + const proc = Bun.spawn(['bunx', 'tsc', '-p', 'packages/clawdhub/tsconfig.json'], { + stdin: 'inherit', + stdout: 'inherit', + stderr: 'inherit', + }) + const code = await proc.exited + if (code !== 0) process.exit(code) +} + +await import(distCliUrl.href) diff --git a/docs/refactor/jan4.md b/docs/refactor/jan4.md index b1c2ffe5..f4a5d24e 100644 --- a/docs/refactor/jan4.md +++ b/docs/refactor/jan4.md @@ -1,6 +1,6 @@ - [ ] Browser-based CLI login (`clawdhub auth login`) via loopback + auto token creation (deps: none) - [ ] Web route `/cli/auth` to mint API token + redirect back to CLI (deps: none) -- [ ] Local repo shortcut `bun clawdhub …` with auto-build of CLI dist (deps: none) +- [x] ~~Local repo shortcut `bun clawdhub …` with auto-build of CLI dist (deps: none)~~ - [ ] CLI: prefer stored `registry` from global config for all network commands (deps: none) - [ ] Confirm shared runtime schemas are used across CLI + Convex (`@clawdhub/schema`, `arktype`) - [ ] Dependency audit/update (deps: `@biomejs/biome`, `oxlint`, `vitest`, etc.)