phonton-cli 0.2.0

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-APACHE ADDED
@@ -0,0 +1,117 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the
13
+ copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other
16
+ entities that control, are controlled by, or are under common control with
17
+ that entity. For the purposes of this definition, "control" means (i) the
18
+ power, direct or indirect, to cause the direction or management of such
19
+ entity, whether by contract or otherwise, or (ii) ownership of fifty percent
20
+ (50%) or more of the outstanding shares, or (iii) beneficial ownership of such
21
+ entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
24
+ permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation source, and
28
+ configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical transformation or
31
+ translation of a Source form, including but not limited to compiled object
32
+ code, generated documentation, and conversions to other media types.
33
+
34
+ "Work" shall mean the work of authorship, whether in Source or Object form,
35
+ made available under the License, as indicated by a copyright notice that is
36
+ included in or attached to the work.
37
+
38
+ "Derivative Works" shall mean any work, whether in Source or Object form,
39
+ that is based on or derived from the Work and for which the editorial
40
+ revisions, annotations, elaborations, or other modifications represent, as a
41
+ whole, an original work of authorship. For the purposes of this License,
42
+ Derivative Works shall not include works that remain separable from, or merely
43
+ link (or bind by name) to the interfaces of, the Work and Derivative Works
44
+ thereof.
45
+
46
+ "Contribution" shall mean any work of authorship, including the original
47
+ version of the Work and any modifications or additions to that Work or
48
+ Derivative Works thereof, that is intentionally submitted to Licensor for
49
+ inclusion in the Work by the copyright owner or by an individual or Legal
50
+ Entity authorized to submit on behalf of the copyright owner. For the purposes
51
+ of this definition, "submitted" means any form of electronic, verbal, or
52
+ written communication sent to the Licensor or its representatives, including
53
+ but not limited to communication on electronic mailing lists, source code
54
+ control systems, and issue tracking systems that are managed by, or on behalf
55
+ of, the Licensor for the purpose of discussing and improving the Work, but
56
+ excluding communication that is conspicuously marked or otherwise designated
57
+ in writing by the copyright owner as "Not a Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
60
+ of whom a Contribution has been received by Licensor and subsequently
61
+ incorporated within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
64
+ License, each Contributor hereby grants to You a perpetual, worldwide,
65
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
66
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
67
+ sublicense, and distribute the Work and such Derivative Works in Source or
68
+ Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of this
71
+ License, each Contributor hereby grants to You a perpetual, worldwide,
72
+ non-exclusive, no-charge, royalty-free, irrevocable patent license to make,
73
+ have made, use, offer to sell, sell, import, and otherwise transfer the Work.
74
+
75
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
76
+ Derivative Works thereof in any medium, with or without modifications, and in
77
+ Source or Object form, provided that You meet the following conditions:
78
+
79
+ (a) You must give any other recipients of the Work or Derivative Works a copy
80
+ of this License; and
81
+
82
+ (b) You must cause any modified files to carry prominent notices stating that
83
+ You changed the files; and
84
+
85
+ (c) You must retain, in the Source form of any Derivative Works that You
86
+ distribute, all copyright, patent, trademark, and attribution notices from the
87
+ Source form of the Work, excluding those notices that do not pertain to any
88
+ part of the Derivative Works; and
89
+
90
+ (d) If the Work includes a "NOTICE" text file as part of its distribution,
91
+ then any Derivative Works that You distribute must include a readable copy of
92
+ the attribution notices contained within such NOTICE file.
93
+
94
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
95
+ Contribution intentionally submitted for inclusion in the Work by You to the
96
+ Licensor shall be under the terms and conditions of this License, without any
97
+ additional terms or conditions.
98
+
99
+ 6. Trademarks. This License does not grant permission to use the trade names,
100
+ trademarks, service marks, or product names of the Licensor, except as
101
+ required for reasonable and customary use in describing the origin of the Work.
102
+
103
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
104
+ writing, Licensor provides the Work on an "AS IS" BASIS, WITHOUT WARRANTIES OR
105
+ CONDITIONS OF ANY KIND, either express or implied.
106
+
107
+ 8. Limitation of Liability. In no event and under no legal theory, whether in
108
+ tort, contract, or otherwise, unless required by applicable law, shall any
109
+ Contributor be liable to You for damages, including any direct, indirect,
110
+ special, incidental, or consequential damages arising as a result of this
111
+ License or out of the use or inability to use the Work.
112
+
113
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or
114
+ Derivative Works thereof, You may choose to offer support, warranty,
115
+ indemnity, or other liability obligations. However, in accepting such
116
+ obligations, You may act only on Your own behalf and on Your sole
117
+ responsibility, not on behalf of any other Contributor.
package/LICENSE-MIT ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Phonton contributors
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,349 @@
1
+ <p align="center">
2
+ <img src="assets/readme/phonton-cli-logo.png" width="112" alt="Phonton CLI logo">
3
+ </p>
4
+
5
+ <h1 align="center">Phonton CLI · v0.2.0</h1>
6
+
7
+ <p align="center">
8
+ <strong>Verified code changes with repo memory.</strong><br>
9
+ A local-first agentic development environment for developers who want autonomous code changes without giving up review control.
10
+ </p>
11
+
12
+ <p align="center">
13
+ <a href="https://github.com/phonton-dev/phonton-cli/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/phonton-dev/phonton-cli/actions/workflows/ci.yml/badge.svg"></a>
14
+ <a href="https://github.com/phonton-dev/phonton-cli/stargazers"><img alt="GitHub stars" src="https://img.shields.io/github/stars/phonton-dev/phonton-cli?style=flat&label=stars"></a>
15
+ <img alt="release" src="https://img.shields.io/badge/release-v0.2.0-6c63ff">
16
+ <img alt="license" src="https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue">
17
+ <img alt="status" src="https://img.shields.io/badge/status-public_alpha-f97316">
18
+ </p>
19
+
20
+ ---
21
+
22
+ Phonton plans the work, routes it through local repo context, verifies changes before handoff, and keeps the result reviewable. The goal is not to be the loudest coding agent. The goal is to make AI-assisted development feel less reckless.
23
+
24
+ > Current status: pre-1.0 public-alpha quality. The core loop is real, the CLI runs, and the Rust workspace is tested. Public launch claims should stay tied to reproducible benchmarks.
25
+
26
+ <p align="center">
27
+ <img src="assets/readme/phonton-cli-hero.png" alt="Phonton CLI hero with terminal UI preview">
28
+ </p>
29
+
30
+ ## Why Phonton
31
+
32
+ Most coding agents start with chat. Phonton starts with the engineering loop:
33
+
34
+ ```mermaid
35
+ flowchart LR
36
+ A["Goal"] --> B["Plan preview"]
37
+ B --> C["Repo-aware worker"]
38
+ C --> D["Verification gate"]
39
+ D --> E["Reviewable diff"]
40
+ E --> F["Memory and history"]
41
+ F --> B
42
+ ```
43
+
44
+ That gives Phonton a different shape from an IDE assistant or a terminal chatbot:
45
+
46
+ - **Review first:** plans and diffs are first-class surfaces, not buried in a conversation.
47
+ - **Verification first:** generated work is expected to pass checks before it is treated as ready.
48
+ - **Local first:** config, trust, store, memory, and repo context live on your machine.
49
+ - **BYOK:** use your own provider account instead of routing every task through a Phonton-hosted model bill.
50
+ - **Measured claims:** token and cost efficiency should be benchmarked per task, not guessed.
51
+
52
+ ## What Works Today
53
+
54
+ - Interactive Ratatui TUI with goal, task, ask, settings, git, and flight-log surfaces.
55
+ - `phonton doctor` setup diagnostics for config, provider key, store, trust, git, cargo, and Nexus config.
56
+ - `phonton plan` preview for task DAGs before edits happen.
57
+ - `phonton review` surfaces for verified diff review payloads, approvals, rejections, and rollback.
58
+ - `phonton memory` commands for inspecting, editing, deleting, pinning, and unpinning local decision memory.
59
+ - BYOK provider adapters for Anthropic, OpenAI, OpenRouter, Gemini, AgentRouter, DeepSeek, xAI/Grok, Groq, Together, Ollama, and custom OpenAI-compatible endpoints. `phonton doctor --provider` verifies your configured provider by checking model discovery and a tiny completion call through the same adapter used for runs.
60
+ - Local store, memory, planner, worker, diff, sandbox, verification, and orchestration crates.
61
+ - Semantic indexing behind the CLI stack for repo-aware workflows.
62
+
63
+ ## What Is Still Early
64
+
65
+ Phonton is not yet as polished as Codex, Claude Code, Cursor, or Windsurf. It has fewer integrations, less onboarding polish, narrower public documentation, and no mature hosted/team workflow yet.
66
+
67
+ The current release target is a public alpha for real Rust repo tasks. Phonton can ask configured models to write app-sized changes, but quality is only claimed after plan review, sandboxed edits, verification, and human review. Use it if you are comfortable running a Rust binary, reading diagnostics, and filing sharp bug reports.
68
+
69
+ ## Install
70
+
71
+ The easiest install path is npm. This downloads a prebuilt GitHub Release binary when the package installs.
72
+
73
+ ```bash
74
+ npm install -g phonton-cli
75
+ phonton
76
+ ```
77
+
78
+ Run without installing:
79
+
80
+ ```bash
81
+ npx phonton-cli
82
+ ```
83
+
84
+ Cargo still works if you prefer building from source. Rust is required for the Cargo path.
85
+
86
+ macOS/Linux:
87
+
88
+ ```bash
89
+ curl -fsSL https://raw.githubusercontent.com/phonton-dev/phonton-cli/main/scripts/install.sh | sh
90
+ ```
91
+
92
+ Windows PowerShell:
93
+
94
+ ```powershell
95
+ & ([scriptblock]::Create((irm https://raw.githubusercontent.com/phonton-dev/phonton-cli/main/scripts/install.ps1)))
96
+ ```
97
+
98
+ Direct Cargo install:
99
+
100
+ ```bash
101
+ cargo install --git https://github.com/phonton-dev/phonton-cli --tag v0.2.0 phonton-cli --locked --force
102
+ ```
103
+
104
+ Check the install:
105
+
106
+ ```bash
107
+ phonton version
108
+ phonton doctor
109
+ ```
110
+
111
+ ## Release Channels
112
+
113
+ Phonton uses GitHub branches and releases as install channels:
114
+
115
+ | Channel | Install | Use when |
116
+ |---|---|---|
117
+ | Stable | `cargo install --git https://github.com/phonton-dev/phonton-cli --tag v0.2.0 phonton-cli --locked --force` | You want the best validated public alpha |
118
+ | Dev | `cargo install --git https://github.com/phonton-dev/phonton-cli --branch dev phonton-cli --locked --force` | You want next-release integration changes |
119
+ | Nightly | `cargo install --git https://github.com/phonton-dev/phonton-cli --branch nightly phonton-cli --locked --force` | You want daily snapshots and can tolerate breakage |
120
+ | Main | `cargo install --git https://github.com/phonton-dev/phonton-cli --branch main phonton-cli --locked --force` | You want the current release branch tip |
121
+
122
+ For the channel policy and automation, read [docs/RELEASE_CHANNELS.md](docs/RELEASE_CHANNELS.md).
123
+
124
+ ## Build From Source
125
+
126
+ ```bash
127
+ git clone https://github.com/phonton-dev/phonton-cli.git
128
+ cd phonton-cli
129
+ cargo build --release -p phonton-cli
130
+ ```
131
+
132
+ Run the binary:
133
+
134
+ ```bash
135
+ ./target/release/phonton
136
+ ```
137
+
138
+ On Windows:
139
+
140
+ ```powershell
141
+ .\target\release\phonton.exe
142
+ ```
143
+
144
+ ## Configure A Provider
145
+
146
+ Phonton reads `~/.phonton/config.toml` and also checks provider-specific environment variables.
147
+
148
+ Minimal config:
149
+
150
+ ```toml
151
+ [provider]
152
+ name = "gemini"
153
+ model = "gemma-4-31b-it"
154
+
155
+ [budget]
156
+ max_tokens = 120000
157
+ max_usd_cents = 200
158
+ ```
159
+
160
+ Environment-variable setup examples:
161
+
162
+ ```bash
163
+ export ANTHROPIC_API_KEY="..."
164
+ export OPENAI_API_KEY="..."
165
+ export GEMINI_API_KEY="..."
166
+ export OPENROUTER_API_KEY="..."
167
+ ```
168
+
169
+ Windows PowerShell:
170
+
171
+ ```powershell
172
+ $env:GEMINI_API_KEY = "..."
173
+ ```
174
+
175
+ Check the install:
176
+
177
+ ```bash
178
+ phonton doctor
179
+ phonton doctor --provider
180
+ ```
181
+
182
+ `phonton doctor --provider` proves the configured key/model/base URL can make a real completion call. It does not claim every listed provider works for every account, model name, quota state, or proxy configuration.
183
+
184
+ ## CLI Commands
185
+
186
+ ```text
187
+ phonton Launch the interactive TUI
188
+ phonton ask <question> One-shot Q&A using the configured provider
189
+ phonton doctor Check config, store, trust, git, cargo, and Nexus
190
+ phonton plan <goal> Preview the task DAG without changing files
191
+ phonton review Show verified diff review payloads
192
+ phonton memory list Inspect local decision memory
193
+ phonton config path Print the resolved config file path
194
+ phonton config show Dump resolved config as TOML
195
+ phonton version Print version
196
+ ```
197
+
198
+ Plan preview:
199
+
200
+ ```bash
201
+ phonton plan --json "add input validation to config loading"
202
+ ```
203
+
204
+ Review latest completed task:
205
+
206
+ ```bash
207
+ phonton review latest
208
+ phonton review approve latest
209
+ phonton review reject latest
210
+ ```
211
+
212
+ Memory management:
213
+
214
+ ```bash
215
+ phonton memory list --json
216
+ phonton memory edit <id> "updated rationale"
217
+ phonton memory pin <id>
218
+ phonton memory delete <id>
219
+ ```
220
+
221
+ ## How Phonton Handles Context
222
+
223
+ <p align="center">
224
+ <img src="assets/readme/context-efficiency.png" alt="Diagram contrasting whole repo context with compact context packs and verified diffs">
225
+ </p>
226
+
227
+ Phonton is built around a simple rule: do not blindly dump the whole repo into the model.
228
+
229
+ ```mermaid
230
+ flowchart TD
231
+ Repo["Local repo"] --> Index["Source index"]
232
+ Index --> Planner["Planner"]
233
+ Planner --> Pack["Task-specific context"]
234
+ Pack --> Worker["Worker"]
235
+ Worker --> Verify["Verify"]
236
+ Verify --> Review["Review"]
237
+ Review --> Store["Memory and event store"]
238
+ Store --> Planner
239
+ ```
240
+
241
+ The intended result is lower context waste and better reviewability. The honest way to prove that is with benchmarks, so this repo includes a benchmark harness instead of hard-coded marketing numbers.
242
+
243
+ ## Benchmarks
244
+
245
+ Run the plan benchmark harness:
246
+
247
+ ```powershell
248
+ .\scripts\benchmark-plan.ps1
249
+ ```
250
+
251
+ It runs repeatable planning tasks, captures estimated Phonton tokens versus the planner's naive baseline, and writes Markdown plus JSON reports to `benchmarks/results/`.
252
+
253
+ Read the methodology in [docs/BENCHMARKS.md](docs/BENCHMARKS.md).
254
+
255
+ Important: benchmark output is evidence, not a slogan. Do not claim "X percent savings" publicly until you can reproduce it on multiple real tasks and include the raw report.
256
+
257
+ ## Architecture
258
+
259
+ ```mermaid
260
+ flowchart TB
261
+ CLI["phonton-cli"] --> Planner["phonton-planner"]
262
+ CLI --> Orchestrator["phonton-orchestrator"]
263
+ Orchestrator --> Worker["phonton-worker"]
264
+ Orchestrator --> Verify["phonton-verify"]
265
+ Worker --> Providers["phonton-providers"]
266
+ Worker --> Context["phonton-context"]
267
+ Context --> Index["phonton-index"]
268
+ Verify --> Diff["phonton-diff"]
269
+ Verify --> Sandbox["phonton-sandbox"]
270
+ Planner --> Memory["phonton-memory"]
271
+ Memory --> Store["phonton-store"]
272
+ Types["phonton-types"] --> CLI
273
+ Types --> Orchestrator
274
+ Types --> Worker
275
+ ```
276
+
277
+ Repository layout:
278
+
279
+ - `phonton-cli` - terminal UI and user-facing command surface.
280
+ - `phonton-planner` - goal decomposition and plan preview.
281
+ - `phonton-orchestrator` - task state, dependencies, retries, and event flow.
282
+ - `phonton-worker` - model-call loop, tool policy, and patch generation.
283
+ - `phonton-verify` - syntax/type/test/decision checks before review.
284
+ - `phonton-index` - local source indexing and semantic retrieval.
285
+ - `phonton-context` - task-specific context compilation.
286
+ - `phonton-diff` - diff application and rollback support.
287
+ - `phonton-memory` / `phonton-store` - local persistence and decision memory.
288
+ - `phonton-providers` - BYOK provider adapters.
289
+ - `phonton-sandbox` - command execution policy.
290
+ - `phonton-types` - shared domain contracts.
291
+
292
+ ## Release Checks
293
+
294
+ Before cutting a release:
295
+
296
+ ```powershell
297
+ .\scripts\release-check.ps1
298
+ ```
299
+
300
+ The script runs formatting, clippy, tests, release build, doctor, and the plan benchmark harness.
301
+
302
+ Manual checks worth doing before a public release:
303
+
304
+ - Fresh clone install on Windows, macOS, and Linux.
305
+ - `phonton doctor --provider` with at least one hosted provider, confirming both model discovery and a completion call.
306
+ - One real repo task from goal to reviewable verified diff.
307
+ - Benchmark report committed or attached to the release notes.
308
+ - No secrets printed in logs, screenshots, or benchmark output.
309
+
310
+ ## Comparison
311
+
312
+ Phonton is not trying to win by pretending the incumbents are weak.
313
+
314
+ | Tool | Strongest fit | Where Phonton is trying to be different |
315
+ |---|---|---|
316
+ | Codex | Mature agent workflow, cloud/editor/CLI integration | Local-first ADE kernel, BYOK, explicit verification and review surfaces |
317
+ | Claude Code | Excellent terminal-native coding agent | Less chat-first, more plan/verify/review oriented |
318
+ | Cursor | Polished AI editor experience | Less editor polish, more auditable repo workflow |
319
+ | Windsurf | Agentic IDE workflow | Narrower release scope, stronger local-first positioning |
320
+ | Phonton CLI | Verified local ADE loop for serious repo tasks | Early product, smaller ecosystem, benchmark claims still being built |
321
+
322
+ ## Development
323
+
324
+ ```bash
325
+ cargo fmt --all -- --check
326
+ cargo clippy --locked --workspace --all-targets -- -D warnings
327
+ cargo test --locked --workspace
328
+ cargo build --locked --release -p phonton-cli
329
+ ```
330
+
331
+ Run from source:
332
+
333
+ ```bash
334
+ cargo run -p phonton-cli -- doctor
335
+ cargo run -p phonton-cli -- plan "add input validation to config loading"
336
+ ```
337
+
338
+ ## License
339
+
340
+ Licensed under either of:
341
+
342
+ - Apache License, Version 2.0
343
+ - MIT License
344
+
345
+ at your option.
346
+
347
+ ## Star History
348
+
349
+ [![Star History Chart](https://api.star-history.com/chart?repos=phonton-dev/phonton-cli&type=date&legend=top-left)](https://www.star-history.com/?repos=phonton-dev%2Fphonton-cli&type=date&legend=top-left)
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const { spawn, spawnSync } = require("child_process");
6
+
7
+ const binaryName = process.platform === "win32" ? "phonton.exe" : "phonton";
8
+ const binaryPath = path.join(__dirname, "..", "vendor", binaryName);
9
+
10
+ function ensureBinary() {
11
+ if (fs.existsSync(binaryPath)) {
12
+ return;
13
+ }
14
+
15
+ const installScript = path.join(__dirname, "..", "install.js");
16
+ const result = spawnSync(process.execPath, [installScript], { stdio: "inherit" });
17
+ if (result.status !== 0 || !fs.existsSync(binaryPath)) {
18
+ process.exit(result.status || 1);
19
+ }
20
+ }
21
+
22
+ ensureBinary();
23
+
24
+ const child = spawn(binaryPath, process.argv.slice(2), { stdio: "inherit" });
25
+ child.on("exit", (code, signal) => {
26
+ if (signal) {
27
+ process.kill(process.pid, signal);
28
+ return;
29
+ }
30
+ process.exit(code ?? 0);
31
+ });
package/npm/install.js ADDED
@@ -0,0 +1,115 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require("fs");
4
+ const https = require("https");
5
+ const os = require("os");
6
+ const path = require("path");
7
+ const { spawnSync } = require("child_process");
8
+
9
+ const packageJson = require("../package.json");
10
+
11
+ const repo = "phonton-dev/phonton-cli";
12
+ const version = packageJson.version;
13
+ const tag = process.env.PHONTON_RELEASE_TAG || (version.includes("nightly") ? "nightly" : `v${version}`);
14
+ const vendorDir = path.join(__dirname, "vendor");
15
+
16
+ const targets = {
17
+ "linux-x64": {
18
+ asset: "phonton-x86_64-unknown-linux-gnu.tar.gz",
19
+ binary: "phonton",
20
+ extract: "tar",
21
+ },
22
+ "darwin-arm64": {
23
+ asset: "phonton-aarch64-apple-darwin.tar.gz",
24
+ binary: "phonton",
25
+ extract: "tar",
26
+ },
27
+ "win32-x64": {
28
+ asset: "phonton-x86_64-pc-windows-msvc.zip",
29
+ binary: "phonton.exe",
30
+ extract: "zip",
31
+ },
32
+ };
33
+
34
+ const target = targets[`${process.platform}-${process.arch}`];
35
+ if (!target) {
36
+ console.error(`Unsupported platform for prebuilt Phonton CLI: ${process.platform}-${process.arch}`);
37
+ console.error("Install from source instead:");
38
+ console.error(`cargo install --git https://github.com/${repo} --tag ${tag} phonton-cli --locked --force`);
39
+ process.exit(1);
40
+ }
41
+
42
+ const url = `https://github.com/${repo}/releases/download/${tag}/${target.asset}`;
43
+ const archivePath = path.join(os.tmpdir(), target.asset);
44
+
45
+ fs.rmSync(vendorDir, { recursive: true, force: true });
46
+ fs.mkdirSync(vendorDir, { recursive: true });
47
+
48
+ download(url, archivePath)
49
+ .then(() => extract(archivePath, target.extract))
50
+ .then(() => {
51
+ const binaryPath = path.join(vendorDir, target.binary);
52
+ if (!fs.existsSync(binaryPath)) {
53
+ throw new Error(`expected binary missing after install: ${binaryPath}`);
54
+ }
55
+ if (process.platform !== "win32") {
56
+ fs.chmodSync(binaryPath, 0o755);
57
+ }
58
+ console.log(`Installed Phonton CLI ${tag} for ${process.platform}-${process.arch}`);
59
+ })
60
+ .catch((error) => {
61
+ console.error(error.message || error);
62
+ process.exit(1);
63
+ });
64
+
65
+ function download(from, to) {
66
+ return new Promise((resolve, reject) => {
67
+ const file = fs.createWriteStream(to);
68
+ https
69
+ .get(from, (response) => {
70
+ if ([301, 302, 303, 307, 308].includes(response.statusCode)) {
71
+ file.close();
72
+ fs.rmSync(to, { force: true });
73
+ download(response.headers.location, to).then(resolve, reject);
74
+ return;
75
+ }
76
+ if (response.statusCode !== 200) {
77
+ reject(new Error(`download failed (${response.statusCode}): ${from}`));
78
+ return;
79
+ }
80
+ response.pipe(file);
81
+ file.on("finish", () => {
82
+ file.close(resolve);
83
+ });
84
+ })
85
+ .on("error", (error) => {
86
+ file.close();
87
+ fs.rmSync(to, { force: true });
88
+ reject(error);
89
+ });
90
+ });
91
+ }
92
+
93
+ function extract(archive, kind) {
94
+ if (kind === "tar") {
95
+ run("tar", ["-xzf", archive, "-C", vendorDir]);
96
+ return;
97
+ }
98
+
99
+ const command = "powershell";
100
+ const args = [
101
+ "-NoProfile",
102
+ "-ExecutionPolicy",
103
+ "Bypass",
104
+ "-Command",
105
+ `Expand-Archive -LiteralPath '${archive.replace(/'/g, "''")}' -DestinationPath '${vendorDir.replace(/'/g, "''")}' -Force`,
106
+ ];
107
+ run(command, args);
108
+ }
109
+
110
+ function run(command, args) {
111
+ const result = spawnSync(command, args, { stdio: "inherit" });
112
+ if (result.status !== 0) {
113
+ throw new Error(`${command} ${args.join(" ")} failed`);
114
+ }
115
+ }
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "phonton-cli",
3
+ "version": "0.2.0",
4
+ "description": "Local-first agentic development terminal with context packs, source handles, and verification gates.",
5
+ "license": "MIT OR Apache-2.0",
6
+ "homepage": "https://github.com/phonton-dev/phonton-cli#readme",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/phonton-dev/phonton-cli.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/phonton-dev/phonton-cli/issues"
13
+ },
14
+ "bin": {
15
+ "phonton": "npm/bin/phonton.js",
16
+ "phonton-cli": "npm/bin/phonton.js"
17
+ },
18
+ "scripts": {
19
+ "postinstall": "node npm/install.js",
20
+ "test:npm-wrapper": "node npm/bin/phonton.js version"
21
+ },
22
+ "files": [
23
+ "npm/bin/phonton.js",
24
+ "npm/install.js",
25
+ "README.md",
26
+ "LICENSE-MIT",
27
+ "LICENSE-APACHE"
28
+ ],
29
+ "keywords": [
30
+ "ai",
31
+ "agent",
32
+ "coding-agent",
33
+ "cli",
34
+ "terminal",
35
+ "rust",
36
+ "developer-tools",
37
+ "local-first",
38
+ "code-review",
39
+ "verification"
40
+ ],
41
+ "engines": {
42
+ "node": ">=18"
43
+ }
44
+ }