@factadev/cli 0.2.9 → 0.2.11

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 (4) hide show
  1. package/bin/nest.cjs +69 -99
  2. package/package.json +26 -96
  3. package/LICENSE +0 -17
  4. package/README.md +0 -97
package/bin/nest.cjs CHANGED
@@ -1,129 +1,99 @@
1
1
  #!/usr/bin/env node
2
-
3
- const { execFileSync, execSync } = require('child_process');
2
+ /**
3
+ * NEST CLI launcher resolves and runs the platform-specific binary.
4
+ * npm install @factadev/cli installs one optional dependency matching this machine
5
+ * (os/cpu); this script finds that binary and execs it. No runtime npm install.
6
+ */
7
+ const { execFileSync } = require('child_process');
4
8
  const path = require('path');
5
9
  const fs = require('fs');
6
10
 
7
11
  const platform = process.platform;
8
12
  const arch = process.arch;
13
+
9
14
  const RELEASE_URL = 'https://github.com/Facta-Dev/ctx0_nest/releases';
10
- const SUPPORTED_PLATFORMS = [
11
- { key: 'darwin-arm64', label: 'darwin-arm64 (macOS Apple Silicon)' },
12
- { key: 'darwin-x64', label: 'darwin-x64 (macOS Intel)' },
13
- { key: 'linux-arm64', label: 'linux-arm64' },
14
- { key: 'linux-x64', label: 'linux-x64' },
15
- { key: 'win32-x64', label: 'win32-x64' },
15
+
16
+ // Map Node platform/arch to our package suffix (must match @factadev/cli-<name>)
17
+ const PLATFORM_MAP = [
18
+ { os: 'darwin', cpu: 'arm64', key: 'darwin-arm64' },
19
+ { os: 'darwin', cpu: 'x64', key: 'darwin-x64' },
20
+ { os: 'linux', cpu: 'arm64', key: 'linux-arm64' },
21
+ { os: 'linux', cpu: 'x64', key: 'linux-x64' },
22
+ { os: 'win32', cpu: 'x64', key: 'win32-x64' },
16
23
  ];
17
24
 
18
- function getPlatformKey(p = platform, a = arch) {
19
- return `${p}-${a}`;
25
+ function getPlatformKey() {
26
+ const entry = PLATFORM_MAP.find(
27
+ (e) => e.os === platform && e.cpu === arch
28
+ );
29
+ return entry ? entry.key : null;
20
30
  }
21
31
 
22
- function isSupportedPlatform(p = platform, a = arch) {
23
- return SUPPORTED_PLATFORMS.some(item => item.key === getPlatformKey(p, a));
24
- }
32
+ function getBinaryPath() {
33
+ const platformKey = getPlatformKey();
34
+ if (!platformKey) return null;
25
35
 
26
- function getBinaryPath(platformName = platform, archName = arch) {
27
- const pkgName = `@factadev/cli-${platformName}-${archName}`;
28
- try {
29
- const pkgPath = require.resolve(`${pkgName}/package.json`);
30
- const binName = platformName === 'win32' ? 'nest.exe' : 'nest';
31
- return path.join(path.dirname(pkgPath), 'bin', binName);
32
- } catch (e) {
33
- return null;
34
- }
35
- }
36
+ const pkgName = `@factadev/cli-${platformKey}`;
37
+ const binName = platform === 'win32' ? 'nest.exe' : 'nest';
36
38
 
37
- function installPlatformPackage(platformName = platform, archName = arch) {
38
- const pkgName = `@factadev/cli-${platformName}-${archName}`;
39
- console.log(`Installing ${pkgName}...`);
40
- try {
41
- execSync(`npm install -g ${pkgName}`, { stdio: 'inherit' });
42
- return true;
43
- } catch (e) {
44
- return false;
45
- }
46
- }
39
+ // Main package root (where this script lives: .../bin/nest.cjs)
40
+ const mainRoot = path.resolve(__dirname, '..');
47
41
 
48
- function getInstalledVersion(platformName = platform, archName = arch) {
49
- const pkgName = `@factadev/cli-${platformName}-${archName}`;
50
- try {
51
- const pkgPath = require.resolve(`${pkgName}/package.json`);
52
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
53
- return pkg.version;
54
- } catch (e) {
55
- return null;
56
- }
57
- }
58
-
59
- function getLatestVersion(platformName = platform, archName = arch) {
60
- const pkgName = `@factadev/cli-${platformName}-${archName}`;
61
- try {
62
- const result = execSync(`npm view ${pkgName} version`, { encoding: 'utf8' });
63
- return result.trim();
64
- } catch (e) {
65
- return null;
66
- }
67
- }
68
-
69
- function getBunPath() {
70
- const bunPaths = [
71
- path.join(__dirname, '..', 'node_modules', '.bin', 'bun'),
72
- path.join(process.env.HOME || '', '.bun', 'bin', 'bun'),
73
- path.join(process.env.APPDATA || '', 'bun', 'bin', 'bun.exe'),
74
- '/usr/local/bin/bun',
75
- '/opt/homebrew/bin/bun',
42
+ const candidates = [
43
+ // 1. Optional dep nested under main package (npm/yarn typical)
44
+ path.join(mainRoot, 'node_modules', pkgName, 'bin', binName),
45
+ // 2. Sibling under same scope (global npm: .../node_modules/@factadev/cli, .../cli-*)
46
+ path.join(mainRoot, '..', `cli-${platformKey}`, 'bin', binName),
47
+ // 3. Unix global: PREFIX/lib/node_modules/@factadev/cli-*
48
+ path.join(
49
+ process.env.npm_config_prefix || process.env.PREFIX || '/usr/local',
50
+ 'lib',
51
+ 'node_modules',
52
+ pkgName,
53
+ 'bin',
54
+ binName
55
+ ),
56
+ // 4. Windows global (prefix often = npm dir with node_modules)
57
+ path.join(
58
+ process.env.npm_config_prefix ||
59
+ path.join(process.env.APPDATA || '', 'npm'),
60
+ 'node_modules',
61
+ pkgName,
62
+ 'bin',
63
+ binName
64
+ ),
76
65
  ];
77
- for (const p of bunPaths) {
78
- try { fs.accessSync(p, fs.constants.X_OK); return p; } catch {}
66
+
67
+ for (const binPath of candidates) {
68
+ if (fs.existsSync(binPath)) return binPath;
79
69
  }
80
- return 'bun';
70
+ return null;
81
71
  }
82
72
 
83
73
  function main() {
84
- if (!isSupportedPlatform()) {
85
- console.error(`Unsupported platform: ${platform}-${arch}`);
86
- process.exit(1);
87
- }
88
-
89
74
  const platformKey = getPlatformKey();
90
- let binPath = getBinaryPath();
91
-
92
- // Check if platform package needs update or install
93
- if (!binPath) {
94
- console.log('No platform binary found. Installing...');
95
- installPlatformPackage();
96
- binPath = getBinaryPath();
97
- } else {
98
- // Check version and update if needed
99
- const currentVer = getInstalledVersion();
100
- const latestVer = getLatestVersion();
101
- if (currentVer && latestVer && currentVer !== latestVer) {
102
- console.log(`Updating from v${currentVer} to v${latestVer}...`);
103
- installPlatformPackage();
104
- binPath = getBinaryPath();
105
- }
75
+ if (!platformKey) {
76
+ console.error(
77
+ `Unsupported platform: ${platform}-${arch}. Supported: darwin-arm64, darwin-x64, linux-arm64, linux-x64, win32-x64.`
78
+ );
79
+ console.error(`See ${RELEASE_URL}`);
80
+ process.exit(1);
106
81
  }
107
82
 
108
- // Fallback to bun if no binary
83
+ const binPath = getBinaryPath();
109
84
  if (!binPath) {
110
- const bunPath = getBunPath();
111
- const cliPath = path.join(__dirname, '..', 'src', 'index.ts');
112
- console.log('No pre-built binary. Using bun...\n');
113
- try {
114
- execFileSync(bunPath, [cliPath, ...process.argv.slice(2)], { stdio: 'inherit' });
115
- return;
116
- } catch (error) {
117
- console.error(`Failed to run with bun: ${error.message}`);
118
- process.exit(1);
119
- }
85
+ console.error(
86
+ `Platform binary not found for ${platformKey}. Reinstall so npm can fetch the matching optional dependency:`
87
+ );
88
+ console.error(' npm install -g @factadev/cli');
89
+ console.error('Or download the binary manually from:', RELEASE_URL);
90
+ process.exit(1);
120
91
  }
121
92
 
122
- // Run the binary
123
93
  try {
124
94
  execFileSync(binPath, process.argv.slice(2), { stdio: 'inherit' });
125
- } catch (error) {
126
- process.exit(error.status || 1);
95
+ } catch (err) {
96
+ process.exit(typeof err.status === 'number' ? err.status : 1);
127
97
  }
128
98
  }
129
99
 
package/package.json CHANGED
@@ -1,99 +1,29 @@
1
1
  {
2
- "name": "@factadev/cli",
3
- "version": "0.2.9",
4
- "description": "NEST CLI - Enterprise AI coding agent control center. Run Claude Code, Codex, Cursor, Gemini, OpenCode locally and control remotely via web.",
5
- "author": "Carlos Matias Baglieri",
6
- "license": "AGPL-3.0-only",
7
- "keywords": [
8
- "nest",
9
- "claude",
10
- "codex",
11
- "cursor",
12
- "gemini",
13
- "opencode",
14
- "ai",
15
- "coding",
16
- "agent",
17
- "remote",
18
- "cli"
19
- ],
20
- "type": "module",
21
- "homepage": "https://github.com/Facta-Dev/ctx0_nest_terminal",
22
- "bugs": "https://github.com/Facta-Dev/ctx0_nest_terminal/issues",
23
- "repository": {
24
- "type": "git",
25
- "url": "git+https://github.com/Facta-Dev/ctx0_nest_terminal.git",
26
- "directory": "cli"
27
- },
28
- "bin": {
29
- "nest": "bin/nest.cjs"
30
- },
31
- "files": [
32
- "bin/nest.cjs",
33
- "NOTICE"
34
- ],
35
- "imports": {
36
- "#embedded-assets": {
37
- "bun": "./src/runtime/embeddedAssets.bun.ts",
38
- "default": "./src/runtime/embeddedAssets.stub.ts"
2
+ "name": "@factadev/cli",
3
+ "version": "0.2.11",
4
+ "description": "NEST CLI - Enterprise AI coding agent control center. Run Claude Code, Codex, Cursor, Gemini, OpenCode locally and control remotely via web.",
5
+ "author": "Carlos Matias Baglieri",
6
+ "license": "AGPL-3.0-only",
7
+ "type": "module",
8
+ "homepage": "https://github.com/Facta-Dev/ctx0_nest_terminal",
9
+ "bugs": "https://github.com/Facta-Dev/ctx0_nest_terminal/issues",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/Facta-Dev/ctx0_nest_terminal.git",
13
+ "directory": "cli"
14
+ },
15
+ "bin": {
16
+ "nest": "bin/nest.cjs"
17
+ },
18
+ "files": [
19
+ "bin/nest.cjs",
20
+ "NOTICE"
21
+ ],
22
+ "optionalDependencies": {
23
+ "@factadev/cli-darwin-arm64": "0.2.11",
24
+ "@factadev/cli-darwin-x64": "0.2.11",
25
+ "@factadev/cli-linux-arm64": "0.2.11",
26
+ "@factadev/cli-linux-x64": "0.2.11",
27
+ "@factadev/cli-win32-x64": "0.2.11"
39
28
  }
40
- },
41
- "dependencies": {
42
- "@factadev/api-nest": "0.1.2",
43
- "@modelcontextprotocol/sdk": "^1.25.1",
44
- "@types/cross-spawn": "^6.0.6",
45
- "@types/ps-list": "^6.2.1",
46
- "@types/react": "^19.2.7",
47
- "axios": "^1.13.2",
48
- "chalk": "^5.6.2",
49
- "cross-spawn": "^7.0.6",
50
- "fastify": "^5.6.2",
51
- "fastify-type-provider-zod": "6.1.0",
52
- "ink": "^6.6.0",
53
- "ps-list": "^9.0.0",
54
- "react": "^19.2.3",
55
- "socket.io-client": "^4.8.3",
56
- "tar": "^7.5.2",
57
- "yaml": "^2.8.2",
58
- "zod": "^4.2.1"
59
- },
60
- "scripts": {
61
- "postinstall": "node -e \"try{require('fs').chmodSync(require('path').join(__dirname,'bin','nest.cjs'),0o755)}catch(e){}\"",
62
- "typecheck": "tsc --noEmit",
63
- "build:exe": "bun run scripts/build-executable.ts",
64
- "build:exe:all": "bun run scripts/build-executable.ts --all",
65
- "build:exe:allinone": "bun run scripts/build-executable.ts --with-web-assets",
66
- "build:exe:allinone:all": "bun run scripts/build-executable.ts --with-web-assets --all",
67
- "prepare-npm-packages": "bun run scripts/prepare-npm-packages.ts",
68
- "prepack": "bun run prepare-npm-packages",
69
- "tools:unpack": "bun run scripts/unpack-tools.ts",
70
- "update-homebrew-formula": "bun run scripts/update-homebrew-formula.ts",
71
- "test": "bun run tools:unpack && vitest run",
72
- "test:win": "vitest run",
73
- "publish": "bash scripts/publish.sh",
74
- "dev": "bun src/index.ts",
75
- "dev:local-server": "bun --env-file .env.dev-local-server src/index.ts",
76
- "dev:integration-test-env": "bun --env-file .env.integration-test src/index.ts",
77
- "release-all": "bun run scripts/release-all.ts"
78
- },
79
- "devDependencies": {
80
- "@types/node": ">=25",
81
- "bun-types": "^1.3.5",
82
- "dotenv": "^17.2.3",
83
- "typescript": "^5",
84
- "vitest": "^4.0.16"
85
- },
86
- "resolutions": {
87
- "whatwg-url": "14.2.0",
88
- "parse-path": "7.0.3",
89
- "@types/parse-path": "7.0.3"
90
- },
91
- "packageManager": "bun@1.3.5",
92
- "optionalDependencies": {
93
- "@factadev/cli-darwin-arm64": "0.2.9",
94
- "@factadev/cli-darwin-x64": "0.2.9",
95
- "@factadev/cli-linux-arm64": "0.2.9",
96
- "@factadev/cli-linux-x64": "0.2.9",
97
- "@factadev/cli-win32-x64": "0.2.9"
98
- }
99
29
  }
package/LICENSE DELETED
@@ -1,17 +0,0 @@
1
- NEST Software License
2
- Copyright © 2026 Carlos Matias Baglieri
3
-
4
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to use the Software for personal or internal business purposes, subject to the following conditions:
5
-
6
- 1. Restrictions
7
- No Modifications: The Software must be used exactly as provided. You may not alter, transform, or build upon this work.
8
-
9
- No Redistribution: You may not redistribute, sub-license, or sell the Software to third parties without express written authorization from the owner.
10
-
11
- Authorization: Any use case not explicitly covered by this license requires prior written consent. Please contact matias@facta.dev for authorization inquiries.
12
-
13
- 2. Disclaimer of Warranty
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT.
15
-
16
- 3. Limitation of Liability
17
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS (CARLOS MATIAS BAGLIERI) BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OF THE SOFTWARE. THE USERS USE THIS SOFTWARE AT THEIR OWN RISK AND RESPONSIBILITY.
package/README.md DELETED
@@ -1,97 +0,0 @@
1
- # NEST CLI
2
-
3
- Run Claude Code, Codex, Cursor Agent, Gemini, or OpenCode in your terminal and control sessions remotely through the NEST server—from a browser, PWA, or Telegram.
4
-
5
- ## What it does
6
-
7
- - **Unified AI coding** — Start and manage Claude Code, Codex, Cursor Agent, Gemini, and OpenCode from one CLI. Sessions sync with the NEST server for remote access.
8
- - **Remote control** — Monitor and steer sessions from the web app or Telegram Mini App. Approve permissions, send messages, and run commands from your phone.
9
- - **Background worker** — Run a worker so sessions can be started remotely without keeping a terminal open. Your machine stays available in the NEST dashboard.
10
- - **MCP bridge** — Expose tools to external clients via the MCP stdio bridge.
11
- - **Diagnostics and auth** — Check connectivity, token, and agent setup with `nest diagnose`. Manage credentials with `nest auth login` / `logout`.
12
-
13
- ## Quick start
14
-
15
- 1. Start the NEST server and set `CLI_API_TOKEN` (see server docs).
16
- 2. On this machine: set the same `CLI_API_TOKEN` or run `nest auth login`.
17
- 3. Run `nest` to start a Claude Code session.
18
- 4. Open the web app or Telegram Mini App to monitor and control.
19
-
20
- ## Commands
21
-
22
- ### Sessions
23
-
24
- - `nest` — Start a Claude Code session (forwards Claude CLI flags).
25
- - `nest codex` — Codex mode (OpenAI). Use `nest codex resume <sessionId>` to resume.
26
- - `nest cursor` — Cursor Agent mode. Supports resume, `--continue`, `--mode plan|ask`, `--yolo`, `--model`. Local and remote.
27
- - `nest gemini` — Gemini via ACP (remote mode; receives messages from server UI/Telegram).
28
- - `nest opencode` — OpenCode via ACP. Local and remote modes.
29
-
30
- ### Auth
31
-
32
- - `nest auth status` — Show auth config and token source.
33
- - `nest auth login` — Save `CLI_API_TOKEN` interactively.
34
- - `nest auth logout` — Clear saved credentials.
35
-
36
- ### Worker
37
-
38
- - `nest worker start` — Start worker (detached).
39
- - `nest worker stop` — Stop worker.
40
- - `nest worker status` — Worker diagnostics.
41
- - `nest worker list` — Active sessions.
42
- - `nest worker stop-session <sessionId>` — End a session.
43
- - `nest worker logs` — Path to latest worker log.
44
-
45
- ### Other
46
-
47
- - `nest diagnose` — Full diagnostics (version, worker, logs, processes).
48
- - `nest diagnose clean` — Kill runaway NEST processes.
49
- - `nest mcp` — Start MCP stdio bridge.
50
- - `nest server` — Start the bundled server (single-binary workflow).
51
-
52
- ## Configuration
53
-
54
- **Required**
55
-
56
- - `CLI_API_TOKEN` — Shared secret; must match the server. Env or `~/.nest/settings.json` (env wins).
57
- - `NEST_API_URL` — Server URL (default: `http://localhost:3006`).
58
-
59
- **Optional**
60
-
61
- - `NEST_HOME` — Config directory (default: `~/.nest`).
62
- - `NEST_EXPERIMENTAL` — Enable experimental features (`true` / `1` / `yes`).
63
- - `NEST_CLAUDE_PATH` — Path to `claude` executable.
64
- - `NEST_HTTP_MCP_URL` — Default MCP target for `nest mcp`.
65
-
66
- **Worker**
67
-
68
- - `NEST_RUNNER_HEARTBEAT_INTERVAL` — Heartbeat ms (default: 60000).
69
- - `NEST_RUNNER_HTTP_TIMEOUT` — HTTP timeout for worker control ms (default: 10000).
70
-
71
- **Worktree** (set by worker when spawning in a worktree)
72
-
73
- - `NEST_WORKTREE_BASE_PATH`, `NEST_WORKTREE_BRANCH`, `NEST_WORKTREE_NAME`, `NEST_WORKTREE_PATH`, `NEST_WORKTREE_CREATED_AT`.
74
-
75
- ## Storage
76
-
77
- Under `~/.nest/` (or `$NEST_HOME`):
78
-
79
- - `settings.json` — Machine id, token, onboarding.
80
- - `runner.state.json` — Worker state (pid, port, version, heartbeat).
81
- - `logs/` — Log files.
82
-
83
- ## Requirements
84
-
85
- - Claude CLI on PATH (for `nest`).
86
- - Cursor Agent CLI on PATH for `nest cursor`: `curl https://cursor.com/install -fsS | bash` (macOS/Linux), or Windows install from Cursor.
87
- - OpenCode CLI on PATH for `nest opencode`.
88
-
89
- ## License
90
-
91
- AGPL-3.0-only. See [LICENSE](https://github.com/Facta-Dev/ctx0_nest_terminal/blob/main/LICENSE) in the repository.
92
-
93
- ## Links
94
-
95
- - [Server and setup](https://github.com/Facta-Dev/ctx0_nest_terminal)
96
- - [Web app](https://github.com/Facta-Dev/ctx0_nest_terminal)
97
- - [Issues](https://github.com/Facta-Dev/ctx0_nest_terminal/issues)