@axiomatic-labs/claudeflow 2.0.54 → 2.0.56

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.
Files changed (2) hide show
  1. package/bin/cli.js +125 -44
  2. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -1,50 +1,131 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const command = process.argv[2];
4
-
5
- switch (command) {
6
- case 'init':
7
- require('../lib/init.js')();
8
- break;
9
- case 'update':
10
- require('../lib/update.js')();
11
- break;
12
- case 'version':
13
- require('../lib/version.js')();
14
- break;
15
- case 'logout': {
16
- const ui = require('../lib/ui.js');
17
- const { clearCachedToken } = require('../lib/auth.js');
18
- if (clearCachedToken()) {
19
- ui.success('Token removed from ~/.claudeflow/config.json');
20
- } else {
21
- ui.info('No cached token found.');
22
- }
23
- break;
3
+ // npm shim: downloads the Go binary if needed, then delegates all commands to it.
4
+
5
+ const { spawn } = require('child_process');
6
+ const path = require('path');
7
+ const fs = require('fs');
8
+ const os = require('os');
9
+ const https = require('https');
10
+
11
+ const OWNER = 'axiomatic-labs';
12
+ const REPO = 'axiomatic-cli';
13
+ const BIN_DIR = path.join(os.homedir(), '.claudeflow', 'bin');
14
+ const isWindows = os.platform() === 'win32';
15
+ const BIN_PATH = path.join(BIN_DIR, isWindows ? 'claudeflow.exe' : 'claudeflow');
16
+ const VERSION_PATH = path.join(os.homedir(), '.claudeflow', 'binary-version');
17
+
18
+ // Detect platform: darwin-arm64, darwin-amd64, linux-amd64, windows-amd64
19
+ function getPlatformBinary() {
20
+ const platform = os.platform(); // darwin, linux, win32
21
+ const arch = os.arch(); // arm64, x64
22
+ const goArch = arch === 'x64' ? 'amd64' : arch;
23
+ const goPlatform = platform === 'win32' ? 'windows' : platform;
24
+ const ext = platform === 'win32' ? '.exe' : '';
25
+ return `claudeflow-${goPlatform}-${goArch}${ext}`;
26
+ }
27
+
28
+ function fetchUrl(url, headers = {}) {
29
+ return new Promise((resolve, reject) => {
30
+ const mod = url.startsWith('https') ? https : require('http');
31
+ mod.get(url, { headers: { 'User-Agent': 'claudeflow-cli', ...headers } }, (res) => {
32
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
33
+ return fetchUrl(res.headers.location, {}).then(resolve).catch(reject);
34
+ }
35
+ if (res.statusCode !== 200) {
36
+ let body = '';
37
+ res.on('data', (d) => body += d);
38
+ res.on('end', () => reject(new Error(`HTTP ${res.statusCode}: ${body.slice(0, 200)}`)));
39
+ return;
40
+ }
41
+ const chunks = [];
42
+ res.on('data', (d) => chunks.push(d));
43
+ res.on('end', () => resolve(Buffer.concat(chunks)));
44
+ }).on('error', reject);
45
+ });
46
+ }
47
+
48
+ async function downloadBinary(token) {
49
+ const ui = require('../lib/ui.js');
50
+
51
+ ui.step('Fetching latest release...');
52
+
53
+ const releaseData = await fetchUrl(
54
+ `https://api.github.com/repos/${OWNER}/${REPO}/releases/latest`,
55
+ { Authorization: `Bearer ${token}`, Accept: 'application/vnd.github+json' }
56
+ );
57
+ const release = JSON.parse(releaseData.toString());
58
+
59
+ const binaryName = getPlatformBinary();
60
+ const asset = release.assets.find((a) => a.name === binaryName);
61
+ if (!asset) {
62
+ ui.error(`No binary found for your platform: ${binaryName}`);
63
+ ui.info(`Available: ${release.assets.map((a) => a.name).join(', ')}`);
64
+ process.exit(1);
65
+ }
66
+
67
+ ui.step(`Downloading ${release.tag_name} (${binaryName})...`);
68
+
69
+ const binaryData = await fetchUrl(
70
+ `https://api.github.com/repos/${OWNER}/${REPO}/releases/assets/${asset.id}`,
71
+ { Authorization: `Bearer ${token}`, Accept: 'application/octet-stream' }
72
+ );
73
+
74
+ fs.mkdirSync(BIN_DIR, { recursive: true });
75
+ fs.writeFileSync(BIN_PATH, binaryData, { mode: 0o755 });
76
+ fs.writeFileSync(VERSION_PATH, release.tag_name + '\n');
77
+
78
+ ui.success(`Claudeflow ${release.tag_name} installed to ~/.claudeflow/bin/`);
79
+ return release.tag_name;
80
+ }
81
+
82
+ async function ensureBinary() {
83
+ if (fs.existsSync(BIN_PATH)) {
84
+ return; // Binary exists
24
85
  }
25
- case '--version':
26
- case '-v':
27
- console.log(`claudeflow v${require('../package.json').version}`);
28
- break;
29
- case '--help':
30
- case '-h':
31
- case undefined: {
32
- const ui = require('../lib/ui.js');
33
- ui.banner();
34
- console.log(` ${ui.BOLD}Usage:${ui.RESET}`);
35
- console.log(` claudeflow ${ui.CYAN}init${ui.RESET} Install the latest template files`);
36
- console.log(` claudeflow ${ui.CYAN}update${ui.RESET} Update templates to latest version`);
37
- console.log(` claudeflow ${ui.CYAN}version${ui.RESET} Show version info`);
38
- console.log(` claudeflow ${ui.CYAN}logout${ui.RESET} Remove cached GitHub token`);
39
- console.log('');
40
- console.log(` ${ui.BOLD}Options:${ui.RESET}`);
41
- console.log(` --version, -v Show CLI version`);
42
- console.log(` --help, -h Show this help`);
43
- console.log('');
44
- break;
86
+
87
+ const ui = require('../lib/ui.js');
88
+ const { requireAuth } = require('../lib/auth.js');
89
+ ui.banner();
90
+ ui.step('First run — downloading Claudeflow binary...');
91
+
92
+ const token = await requireAuth();
93
+ try {
94
+ await downloadBinary(token);
95
+ } catch (err) {
96
+ ui.error('Could not download Claudeflow binary.');
97
+ ui.info('Ensure your token has access to the axiomatic-labs/axiomatic-cli repository.');
98
+ process.exit(1);
45
99
  }
46
- default:
47
- console.error(`Unknown command: ${command}`);
48
- console.error('Run "claudeflow --help" for usage.');
100
+ }
101
+
102
+ async function main() {
103
+ const args = process.argv.slice(2);
104
+
105
+ // These commands need the Go binary
106
+ await ensureBinary();
107
+
108
+ // Delegate to Go binary with transparent I/O
109
+ const child = spawn(BIN_PATH, args, {
110
+ stdio: 'inherit',
111
+ env: process.env,
112
+ });
113
+
114
+ child.on('exit', (code) => {
115
+ process.exit(code || 0);
116
+ });
117
+
118
+ child.on('error', (err) => {
119
+ if (err.code === 'ENOENT') {
120
+ console.error('Claudeflow binary not found. Try reinstalling: npx @axiomatic-labs/claudeflow');
121
+ } else {
122
+ console.error(`Failed to start claudeflow: ${err.message}`);
123
+ }
49
124
  process.exit(1);
125
+ });
50
126
  }
127
+
128
+ main().catch((err) => {
129
+ console.error(err.message || err);
130
+ process.exit(1);
131
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axiomatic-labs/claudeflow",
3
- "version": "2.0.54",
3
+ "version": "2.0.56",
4
4
  "description": "Claudeflow — AI-powered development toolkit for Claude Code. Skills, agents, hooks, and quality gates that ship production apps.",
5
5
  "bin": {
6
6
  "claudeflow": "./bin/cli.js"