Skip to content

Commit e274631

Browse files
jimgqyuclaude
andcommitted
feat: bundle CLI into kode-agent npm package with bin entry
Make `npm install -g kode-agent` create a working `kode` command by shipping the CLI dist bundled into the root package. Previously the npm package only contained the SDK core with no executable binary, breaking the install.sh flow on fresh environments. - Remove `private: true` so the root package can be published - Add `bin.kode` pointing to bundled CLI entry point - Add all CLI runtime dependencies (workspace:* → auto-resolved on publish) - Add postbuild script to copy CLI dist into root dist/ - Add prepublishOnly hook to guarantee build before publish - Extend publish.sh to publish root kode-agent as the final step Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 57ea836 commit e274631

4 files changed

Lines changed: 85 additions & 3 deletions

File tree

package.json

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
{
22
"name": "kode-agent",
33
"version": "0.1.0",
4-
"private": true,
54
"description": "Kode Agent — An open-source, enterprise-grade CLI coding agent with multi-provider support, Agent Teams, and a powerful hook system",
65
"type": "module",
6+
"bin": {
7+
"kode": "./dist/entry.js"
8+
},
9+
"files": [
10+
"dist",
11+
"README.md",
12+
"LICENSE"
13+
],
714
"scripts": {
815
"dev": "pnpm --recursive run dev",
916
"build": "pnpm --recursive run build",
17+
"postbuild": "node scripts/bundle-packages.js",
18+
"prepublishOnly": "pnpm build",
1019
"test": "vitest run",
1120
"test:watch": "vitest",
1221
"test:coverage": "vitest run --coverage",
@@ -24,6 +33,19 @@
2433
"node": ">=22.0.0"
2534
},
2635
"packageManager": "pnpm@9.15.4",
36+
"dependencies": {
37+
"@kode/core": "workspace:*",
38+
"@kode/provider": "workspace:*",
39+
"@kode/shared": "workspace:*",
40+
"@kode/tools": "workspace:*",
41+
"@kode/tui": "workspace:*",
42+
"@nanostores/react": "^1.1.0",
43+
"ink": "^6.8.0",
44+
"ink-text-input": "^6.0.0",
45+
"nanostores": "^1.2.0",
46+
"react": "^19.2.4",
47+
"unicode-animations": "^1.0.3"
48+
},
2749
"devDependencies": {
2850
"@eslint/js": "^9.16.0",
2951
"@types/node": "^22.10.0",

pnpm-lock.yaml

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/bundle-packages.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { cp, mkdir } from 'node:fs/promises';
2+
import { resolve } from 'node:path';
3+
4+
const root = import.meta.dirname
5+
? resolve(import.meta.dirname, '..')
6+
: resolve(process.cwd());
7+
8+
const cliDist = resolve(root, 'packages', 'cli', 'dist');
9+
const rootDist = resolve(root, 'dist');
10+
11+
await mkdir(rootDist, { recursive: true });
12+
await cp(cliDist, rootDist, { recursive: true });
13+
14+
console.log('✅ CLI dist bundled into root dist/');

scripts/publish.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# 5. @kode/skills — Skills system (depends on shared)
1414
# 6. @kode/core — Core runtime engine (depends on shared)
1515
# 7. @kode/cli — CLI entrypoint (depends on all above)
16+
# 8. kode-agent — Root CLI bundle with bin entry (depends on all above)
1617
set -euo pipefail
1718

1819
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
@@ -54,7 +55,7 @@ PACKAGES=(
5455
)
5556

5657
echo ""
57-
echo "=== Publishing ${#PACKAGES[@]} packages ==="
58+
echo "=== Publishing ${#PACKAGES[@]} workspace packages ==="
5859

5960
FAILED_PACKAGES=()
6061

@@ -70,14 +71,25 @@ for pkg in "${PACKAGES[@]}"; do
7071
fi
7172
done
7273

74+
# --- Publish root kode-agent (CLI bundle) ---
75+
echo ""
76+
echo "--- Publishing kode-agent (root CLI bundle) ---"
77+
78+
if pnpm publish --access public --no-git-checks 2>&1; then
79+
echo "✅ kode-agent (root) published successfully"
80+
else
81+
echo "❌ kode-agent (root) publish failed"
82+
FAILED_PACKAGES+=("kode-agent (root)")
83+
fi
84+
7385
# ---------------------------------------------------------------------------
7486
# 4. Report results
7587
# ---------------------------------------------------------------------------
7688
echo ""
7789
echo "=== Publish Summary ==="
7890

7991
if [ ${#FAILED_PACKAGES[@]} -eq 0 ]; then
80-
echo "✅ All ${#PACKAGES[@]} packages published to npm"
92+
echo "✅ All packages published to npm"
8193
echo ""
8294
echo "Install with: npm install -g kode-agent"
8395
exit 0

0 commit comments

Comments
 (0)