@tjcoder/cli 0.9.164

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 TJ Coder
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,122 @@
1
+ # @tjcoder/cli
2
+
3
+ > Terminal-first AI coding assistant by TJ Coder / AI Labs.
4
+
5
+ `coder` is a Go TUI that pairs a conversational AI agent with real
6
+ developer tools, streams the model's reasoning live in a "cognition"
7
+ pane, and ships 7 specialized agents plus 31 tools. It defaults to local
8
+ Ollama models (your code never leaves your machine) and optionally uses
9
+ Google Gemini. This package is the npm distribution: it downloads the
10
+ right prebuilt binary for your platform on `npm install`, so you don't
11
+ need a Go toolchain.
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install -g @tjcoder/cli
17
+ ```
18
+
19
+ That's it. After install, `coder` is on your `PATH`:
20
+
21
+ ```bash
22
+ coder --version
23
+ ```
24
+
25
+ ### Prerequisites
26
+
27
+ `coder` itself is a self-contained Go binary — the only requirement is
28
+ `node >= 18` (to run the postinstall downloader). To actually use the
29
+ TUI you'll also need:
30
+
31
+ - An [Ollama](https://ollama.com) server running locally
32
+ (default: `http://localhost:11434`)
33
+ - At least one model pulled (`ollama pull gemma4:cloud` or similar)
34
+
35
+ Don't have Ollama yet? The shell installer can set it up in one go:
36
+
37
+ ```bash
38
+ INSTALL_OLLAMA=1 curl -fsSL https://raw.githubusercontent.com/tjcoder-labs/cli/main/install.sh | bash
39
+ ```
40
+
41
+ ## Features
42
+
43
+ - **Live cognition pane** — watch the model reason in real time
44
+ - **7 specialized agents** — software engineer, terminal specialist, code reviewer, Android assistant, cloud expert, social researcher, storyteller
45
+ - **31 tools** — filesystem, shell, Git, browser automation (CDP), Cloudflare DNS, email, and more
46
+ - **Multi-line paste** — paste code blocks or documents; they're kept as one message
47
+ - **Headless mode** — script it with `coder -p "…"` for CI and automation
48
+ - **Session persistence** — conversation history, tasks, and memories survive across runs
49
+ - **Local-first privacy** — defaults to Ollama; your code never leaves your machine
50
+
51
+ ## Updating
52
+
53
+ ```bash
54
+ npm update -g @tjcoder/cli
55
+ ```
56
+
57
+ The `postinstall` hook is idempotent and won't redownload a binary
58
+ that's already present.
59
+
60
+ ## Uninstalling
61
+
62
+ ```bash
63
+ npm uninstall -g @tjcoder/cli
64
+ ```
65
+
66
+ The `preuninstall` hook removes the cached binary.
67
+
68
+ ## Usage
69
+
70
+ ```bash
71
+ coder # launch the TUI
72
+ coder --version # print version and exit
73
+ coder --provider ollama --host http://localhost:11434
74
+ coder --provider gemini --gemini-api-key $GEMINI_API_KEY
75
+ coder --provider gemini models # list available Gemini models
76
+ coder --workspace-root ~/code/foo
77
+ coder --model gemma4:cloud
78
+ coder --timeout 30m
79
+ ```
80
+
81
+ ### Environment variables
82
+
83
+ | Var | Default | Purpose |
84
+ |---|---|---|
85
+ | `GEMINI_API_KEY` | _(required for gemini)_ | API key for Google's Gemini API |
86
+ | `CODER_HTTP_TIMEOUT` | `5m` | HTTP client timeout (`time.ParseDuration`) |
87
+ | `CODER_CLI_REPO` | `tjcoder-labs/cli` | Override the GitHub repo used by `postinstall` |
88
+ | `CODER_CLI_VERSION` | _(matches this package)_ | Pin a specific `coder` binary version |
89
+ | `CODER_CLI_REQUIRE_DOWNLOAD` | _(unset)_ | Set to `1` to make a failed download fatal |
90
+
91
+ ## Pinning a version
92
+
93
+ ```bash
94
+ # install a specific coder version regardless of the @tjcoder/cli wrapper version
95
+ CODER_CLI_VERSION=v0.9.164 npm install -g @tjcoder/cli
96
+ ```
97
+
98
+ ## Troubleshooting
99
+
100
+ **`coder: native binary not found at .../lib/coder`**
101
+
102
+ The postinstall hook was skipped. Re-run with scripts enabled:
103
+
104
+ ```bash
105
+ npm rebuild @tjcoder/cli
106
+ # or
107
+ npm install -g @tjcoder/cli --foreground-scripts
108
+ ```
109
+
110
+ **`coder: download failed: 404 ...`**
111
+
112
+ There is no published release for your platform/arch, or the version
113
+ you pinned doesn't exist. Try a different version, or fall back to the
114
+ Go-based installer:
115
+
116
+ ```bash
117
+ curl -fsSL https://raw.githubusercontent.com/tjcoder-labs/cli/main/install.sh | bash
118
+ ```
119
+
120
+ ## License
121
+
122
+ MIT — see the [LICENSE](./LICENSE) file. Built by [TJ Coder / AI Labs](https://github.com/tjcoder-labs).
package/bin/coder.js ADDED
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env node
2
+ // coder.js - thin Node shim that exec()s the native `coder` binary.
3
+ //
4
+ // This file is registered as the `coder` bin in package.json so that
5
+ // `npm install -g @tjcoder/cli` puts `coder` on the user's PATH.
6
+ // The actual implementation is a Go binary that is downloaded by
7
+ // ./lib/fetch-binary.js during `postinstall`.
8
+
9
+ const { spawn } = require("node:child_process");
10
+ const path = require("node:path");
11
+ const fs = require("node:fs");
12
+ const os = require("node:os");
13
+
14
+ // Resolve the platform-specific binary name. Windows gets a .exe suffix.
15
+ const ext = process.platform === "win32" ? ".exe" : "";
16
+ const binName = `coder${ext}`;
17
+
18
+ // The binary is downloaded next to this file under lib/<bin>.
19
+ const binPath = path.join(__dirname, "..", "lib", binName);
20
+
21
+ if (!fs.existsSync(binPath)) {
22
+ console.error(
23
+ [
24
+ `coder: native binary not found at ${binPath}`,
25
+ ``,
26
+ `This usually means the postinstall hook was skipped (e.g. when`,
27
+ `installing with --ignore-scripts). To fix:`,
28
+ ``,
29
+ ` npm rebuild @tjcoder/cli`,
30
+ ` # or`,
31
+ ` npm install -g @tjcoder/cli --foreground-scripts`,
32
+ ``,
33
+ `If the problem persists, install via the Go-based installer instead:`,
34
+ ` curl -fsSL https://raw.githubusercontent.com/tjcoder-labs/cli/main/install.sh | bash`,
35
+ ].join("\n"),
36
+ );
37
+ process.exit(1);
38
+ }
39
+
40
+ // Spawn the binary, inheriting stdio so the TUI / streaming output works
41
+ // exactly as if the user had run `coder` directly. Forward signals so
42
+ // Ctrl+C cleanly tears down the child.
43
+ const child = spawn(binPath, process.argv.slice(2), {
44
+ stdio: "inherit",
45
+ env: process.env,
46
+ windowsHide: true,
47
+ });
48
+
49
+ const forward = (sig) => () => {
50
+ if (!child.killed) child.kill(sig);
51
+ };
52
+ process.on("SIGINT", forward("SIGINT"));
53
+ process.on("SIGTERM", forward("SIGTERM"));
54
+ process.on("SIGHUP", forward("SIGHUP"));
55
+
56
+ child.on("exit", (code, signal) => {
57
+ if (signal) {
58
+ // Mirror the conventional shell behavior: 128 + signal number.
59
+ const map = { SIGHUP: 1, SIGINT: 2, SIGTERM: 15 };
60
+ process.exit(128 + (map[signal] || 15));
61
+ }
62
+ process.exit(code ?? 0);
63
+ });
64
+
65
+ child.on("error", (err) => {
66
+ console.error(`coder: failed to exec ${binPath}: ${err.message}`);
67
+ process.exit(1);
68
+ });
package/lib/cleanup.js ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ // cleanup.js - remove the platform-specific `coder` binary on uninstall.
3
+ //
4
+ // Invoked by the package.json `preuninstall` script. Best-effort: never
5
+ // throws, so a cleanup failure can't block `npm rm`.
6
+
7
+ const fs = require("node:fs");
8
+ const path = require("node:path");
9
+
10
+ const ext = process.platform === "win32" ? ".exe" : "";
11
+ const candidates = [
12
+ path.join(__dirname, `coder${ext}`),
13
+ path.join(__dirname, "coder"),
14
+ path.join(__dirname, "coder.exe"),
15
+ path.join(__dirname, "coder.sha256"),
16
+ ];
17
+
18
+ for (const p of candidates) {
19
+ try {
20
+ if (fs.existsSync(p)) fs.unlinkSync(p);
21
+ } catch {
22
+ // ignore — best effort
23
+ }
24
+ }
@@ -0,0 +1,201 @@
1
+ #!/usr/bin/env node
2
+ // fetch-binary.js - download the platform-appropriate `coder` binary from
3
+ // the project's GitHub Releases page during `npm install`.
4
+ //
5
+ // This is invoked by the package.json `postinstall` script. It is
6
+ // idempotent: if the binary is already present for the current
7
+ // platform/arch, it does nothing.
8
+
9
+ const fs = require("node:fs");
10
+ const path = require("node:path");
11
+ const https = require("node:https");
12
+ const { URL } = require("node:url");
13
+
14
+ // --- configuration ---------------------------------------------------------
15
+
16
+ const pkg = require("../package.json");
17
+ const REPO = process.env.CODER_CLI_REPO || "tjcoder-labs/cli";
18
+ // Allow pinning a version (matches the @tjcoder/cli package version by
19
+ // default so that `npm i @tjcoder/cli@0.9.164` installs coder v0.9.164).
20
+ const VERSION = process.env.CODER_CLI_VERSION || `v${pkg.version}`;
21
+
22
+ // --- platform detection ----------------------------------------------------
23
+
24
+ function detect() {
25
+ // Map Node's platform/arch names to the suffixes we use in release assets.
26
+ const platformMap = {
27
+ darwin: "darwin",
28
+ linux: "linux",
29
+ win32: "windows",
30
+ freebsd: "freebsd",
31
+ };
32
+ const archMap = {
33
+ x64: "amd64",
34
+ arm64: "arm64",
35
+ x32: "386",
36
+ };
37
+
38
+ const os = platformMap[process.platform];
39
+ const arch = archMap[process.arch];
40
+
41
+ if (!os) {
42
+ throw new Error(
43
+ `unsupported platform: ${process.platform} ` +
44
+ `(coder publishes darwin, linux, windows, freebsd)`,
45
+ );
46
+ }
47
+ if (!arch) {
48
+ throw new Error(
49
+ `unsupported architecture: ${process.arch} ` +
50
+ `(coder publishes amd64, arm64, 386)`,
51
+ );
52
+ }
53
+
54
+ const ext = os === "windows" ? ".zip" : ".tar.gz";
55
+ const asset = `coder_${VERSION}_${os}_${arch}${ext}`;
56
+ return { os, arch, ext, asset };
57
+ }
58
+
59
+ // --- download --------------------------------------------------------------
60
+
61
+ function download(url, dest) {
62
+ return new Promise((resolve, reject) => {
63
+ const req = https.get(
64
+ url,
65
+ { headers: { "User-Agent": `${pkg.name}/${pkg.version}` } },
66
+ (res) => {
67
+ // GitHub returns 301/302 to the S3-backed download URL. Follow.
68
+ if (
69
+ res.statusCode &&
70
+ [301, 302, 303, 307, 308].includes(res.statusCode) &&
71
+ res.headers.location
72
+ ) {
73
+ res.resume();
74
+ download(new URL(res.headers.location, url).toString(), dest)
75
+ .then(resolve)
76
+ .catch(reject);
77
+ return;
78
+ }
79
+ if (res.statusCode !== 200) {
80
+ reject(
81
+ new Error(
82
+ `download failed: ${res.statusCode} ${res.statusMessage} for ${url}`,
83
+ ),
84
+ );
85
+ return;
86
+ }
87
+ const out = fs.createWriteStream(dest);
88
+ res.pipe(out);
89
+ out.on("finish", () => out.close(() => resolve(dest)));
90
+ out.on("error", reject);
91
+ },
92
+ );
93
+ req.on("error", reject);
94
+ req.setTimeout(60_000, () => {
95
+ req.destroy(new Error(`download timeout after 60s: ${url}`));
96
+ });
97
+ });
98
+ }
99
+
100
+ function extract(archivePath, workDir, info) {
101
+ const { execFileSync } = require("node:child_process");
102
+ const binName = info.os === "windows" ? "coder.exe" : "coder";
103
+ if (info.ext === ".tar.gz") {
104
+ execFileSync("tar", ["-xzf", archivePath, "-C", workDir], {
105
+ stdio: "ignore",
106
+ });
107
+ } else if (info.ext === ".zip") {
108
+ // `tar` on Windows 10+ and modern macOS handles .zip too; fall back to
109
+ // a system unzip if not.
110
+ try {
111
+ execFileSync("tar", ["-xf", archivePath, "-C", workDir], {
112
+ stdio: "ignore",
113
+ });
114
+ } catch {
115
+ execFileSync("unzip", ["-q", archivePath, "-d", workDir], {
116
+ stdio: "ignore",
117
+ });
118
+ }
119
+ } else {
120
+ throw new Error(`unknown archive extension: ${info.ext}`);
121
+ }
122
+ // The archive contains a top-level `coder` (or `coder.exe`) binary.
123
+ const extracted = path.join(workDir, binName);
124
+ if (!fs.existsSync(extracted)) {
125
+ // Some releases nest the binary in a subdirectory; try one level.
126
+ const nested = path.join(workDir, `coder_${VERSION}_${info.os}_${info.arch}`, binName);
127
+ if (fs.existsSync(nested)) return nested;
128
+ throw new Error(
129
+ `expected binary not found in archive: ${extracted} (and ${nested})`,
130
+ );
131
+ }
132
+ return extracted;
133
+ }
134
+
135
+ async function checksum(filePath) {
136
+ // Optional SHA256 verification against a sibling .sha256 file. We try, but
137
+ // never fail the install if the file is missing — that keeps dev installs
138
+ // working before the first signed release.
139
+ const fs = require("node:fs/promises");
140
+ const crypto = require("node:crypto");
141
+ const shaPath = `${filePath}.sha256`;
142
+ if (!fs.existsSync(shaPath)) return;
143
+ const expected = (await fs.readFile(shaPath, "utf8")).trim().split(/\s+/)[0];
144
+ const actual = crypto
145
+ .createHash("sha256")
146
+ .update(await fs.readFile(filePath))
147
+ .digest("hex");
148
+ if (expected.toLowerCase() !== actual.toLowerCase()) {
149
+ throw new Error(
150
+ `sha256 mismatch: expected ${expected}, got ${actual} for ${filePath}`,
151
+ );
152
+ }
153
+ }
154
+
155
+ // --- main ------------------------------------------------------------------
156
+
157
+ async function main() {
158
+ const info = detect();
159
+ const libDir = path.join(__dirname);
160
+ const binName = info.os === "windows" ? "coder.exe" : "coder";
161
+ const binPath = path.join(libDir, binName);
162
+
163
+ if (fs.existsSync(binPath)) {
164
+ // Already installed (e.g. `npm rebuild`); leave the existing binary
165
+ // alone so we don't clobber a working install with a broken download.
166
+ return;
167
+ }
168
+
169
+ const url = `https://github.com/${REPO}/releases/download/${VERSION}/${info.asset}`;
170
+ process.stdout.write(`coder: downloading ${info.asset} ...\n`);
171
+
172
+ const tmp = fs.mkdtempSync(path.join(require("node:os").tmpdir(), "coder-"));
173
+ const archivePath = path.join(tmp, info.asset);
174
+ try {
175
+ await download(url, archivePath);
176
+ const extracted = extract(archivePath, tmp, info);
177
+ if (info.os !== "windows") {
178
+ fs.chmodSync(extracted, 0o755);
179
+ }
180
+ await checksum(extracted);
181
+ fs.renameSync(extracted, binPath);
182
+ process.stdout.write(`coder: installed ${binPath}\n`);
183
+ } catch (err) {
184
+ process.stderr.write(
185
+ `coder: ${err.message}\n` +
186
+ `coder: install via the Go-based installer instead:\n` +
187
+ `coder: curl -fsSL https://raw.githubusercontent.com/${REPO}/main/install.sh | bash\n`,
188
+ );
189
+ // Don't fail the install for an optional postinstall: leave the JS shim
190
+ // in place so users can still see the error when they run `coder`.
191
+ // Set CODER_CLI_REQUIRE_DOWNLOAD=1 to make this fatal.
192
+ if (process.env.CODER_CLI_REQUIRE_DOWNLOAD === "1") process.exit(1);
193
+ } finally {
194
+ fs.rmSync(tmp, { recursive: true, force: true });
195
+ }
196
+ }
197
+
198
+ main().catch((err) => {
199
+ process.stderr.write(`coder: unexpected error: ${err.stack || err}\n`);
200
+ process.exit(1);
201
+ });
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@tjcoder/cli",
3
+ "version": "0.9.164",
4
+ "description": "Terminal-first AI coding assistant by TJ Coder / AI Labs. A keyboard-driven TUI with a live cognition pane, 7 specialized agents, and 31 tools, running on local Ollama models by default.",
5
+ "license": "MIT",
6
+ "private": false,
7
+ "bin": {
8
+ "coder": "bin/coder.js"
9
+ },
10
+ "files": [
11
+ "bin/",
12
+ "lib/",
13
+ "README.md",
14
+ "LICENSE"
15
+ ],
16
+ "scripts": {
17
+ "postinstall": "node ./lib/fetch-binary.js",
18
+ "preuninstall": "node ./lib/cleanup.js"
19
+ },
20
+ "engines": {
21
+ "node": ">=18"
22
+ },
23
+ "os": [
24
+ "darwin",
25
+ "linux",
26
+ "win32"
27
+ ],
28
+ "cpu": [
29
+ "x64",
30
+ "arm64"
31
+ ],
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/tjcoder-labs/cli.git",
35
+ "directory": "npm/coder-cli"
36
+ },
37
+ "bugs": {
38
+ "url": "https://github.com/tjcoder-labs/cli/issues"
39
+ },
40
+ "homepage": "https://github.com/tjcoder-labs/cli#readme",
41
+ "keywords": [
42
+ "ai",
43
+ "coding",
44
+ "cli",
45
+ "tui",
46
+ "terminal",
47
+ "ollama",
48
+ "gemini",
49
+ "agent",
50
+ "assistant"
51
+ ]
52
+ }