@cryer/star-cli 0.1.0 → 0.1.2
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/README.md +80 -11
- package/dist/main.js +2899 -664
- package/dist/main.js.map +1 -1
- package/dist/stream-Y55NRF2S.js +82 -0
- package/dist/stream-Y55NRF2S.js.map +1 -0
- package/package.json +1 -1
- package/dist/stream-FJQZGETE.js +0 -51
- package/dist/stream-FJQZGETE.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
# Star CLI
|
|
2
2
|
|
|
3
|
+
[](https://github.com/cryer/star-cli/actions/workflows/ci.yml)
|
|
4
|
+
|
|
3
5
|
An AI agent command-line interface written in TypeScript — multi-model LLM access, streaming terminal UI, tool calling, permission control, and session persistence.
|
|
4
6
|
|
|
7
|
+
Features: streaming REPL with slash commands (+ autocomplete) · OpenAI / Anthropic / OpenAI-compatible providers · built-in fs / bash / web tools with a permission gate · thinking spinner with dim reasoning preview · diff preview on write/edit approval · `@file` mentions · `!cmd` shell passthrough · custom slash commands from Markdown files · conversation compaction (`/compact`) · session persistence and resume (`/resume`, `star -r`) · file-write snapshots with `/undo` · persistent permission allow-rules · TODO task tracking · background shell tasks with status-bar visibility (`/tasks`) · Markdown session export (`/export`) · `/init` + `/doctor` project scaffolding and environment checks · cost estimation · update notifier · `--json` NDJSON output for scripting.
|
|
8
|
+
|
|
5
9
|
## Requirements
|
|
6
10
|
|
|
7
11
|
- Node.js >= 20
|
|
@@ -20,19 +24,29 @@ star -p "hi" # non-interactive print mode
|
|
|
20
24
|
```bash
|
|
21
25
|
pnpm install
|
|
22
26
|
pnpm build
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
npm link # one-time: registers the `star` command globally
|
|
28
|
+
star # interactive REPL
|
|
29
|
+
star -p "hi" # non-interactive print mode
|
|
25
30
|
```
|
|
26
31
|
|
|
32
|
+
Without `npm link` you can run the bundle directly: `node dist/main.js` (re-run `pnpm build` after code changes; the linked `star` always points at `dist/`).
|
|
33
|
+
|
|
27
34
|
## Configuration
|
|
28
35
|
|
|
29
36
|
Config file: `~/.star-cli/config.toml` (project-level override: `.star/config.toml` in cwd; CLI flags win over both).
|
|
30
37
|
|
|
31
38
|
```toml
|
|
32
39
|
defaultModel = "gpt"
|
|
33
|
-
permissionMode = "ask" # auto |
|
|
40
|
+
permissionMode = "ask" # ask | auto | readonly | yolo
|
|
34
41
|
contextMaxTokens = 100000
|
|
35
42
|
contextCompaction = "summary" # summary | truncate — how over-budget history is compacted
|
|
43
|
+
# Seconds with no stream output before a stalled response is ended gracefully
|
|
44
|
+
# (some relays never close the stream). The first token gets a fixed 120s allowance.
|
|
45
|
+
streamIdleTimeoutSec = 20
|
|
46
|
+
|
|
47
|
+
[permissions]
|
|
48
|
+
# persistent allow-rules, written automatically when you pick "a" (always) on a permission prompt
|
|
49
|
+
allow = ["bash(npm test)", "read_file"] # <tool> or <tool(<pattern>)>, * is a glob wildcard
|
|
36
50
|
|
|
37
51
|
[[providers]]
|
|
38
52
|
name = "openai"
|
|
@@ -45,6 +59,9 @@ apiKeyEnv = "OPENAI_API_KEY"
|
|
|
45
59
|
name = "gpt"
|
|
46
60
|
provider = "openai"
|
|
47
61
|
model = "gpt-4o"
|
|
62
|
+
# optional per-model pricing (USD per 1M tokens) — enables the $ estimate in /cost
|
|
63
|
+
promptPrice = 2.5
|
|
64
|
+
completionPrice = 10
|
|
48
65
|
|
|
49
66
|
[[providers]]
|
|
50
67
|
name = "claude"
|
|
@@ -65,8 +82,9 @@ API keys resolve from the environment variable first (`apiKeyEnv`), then the `ap
|
|
|
65
82
|
```
|
|
66
83
|
star start the interactive REPL
|
|
67
84
|
star -p "prompt" non-interactive print mode (pipe-friendly)
|
|
85
|
+
star -p "prompt" --json NDJSON event stream on stdout (text/tool/usage/error lines)
|
|
68
86
|
star -m gpt pick a model
|
|
69
|
-
star --permission-mode auto auto |
|
|
87
|
+
star --permission-mode auto ask | auto | readonly | yolo
|
|
70
88
|
star -r <sessionId> resume a previous session
|
|
71
89
|
```
|
|
72
90
|
|
|
@@ -78,17 +96,65 @@ star -r <sessionId> resume a previous session
|
|
|
78
96
|
| `/model [name]` | list / switch models |
|
|
79
97
|
| `/resume [id]` | list / resume sessions |
|
|
80
98
|
| `/todo` | show TODO list |
|
|
81
|
-
| `/
|
|
99
|
+
| `/tasks` | list background tasks (id, status, runtime, exit code) |
|
|
100
|
+
| `/cost` | show API token usage and estimated $ cost (needs per-model pricing in config) |
|
|
82
101
|
| `/config` | show resolved config |
|
|
102
|
+
| `/permission [mode]` | show / set the global permission mode (`ask`, `auto`, `readonly`, `yolo`) — saved to config |
|
|
103
|
+
| `/compact` | compact conversation history to free up context |
|
|
104
|
+
| `/export [path]` | export the current session to a Markdown file |
|
|
105
|
+
| `/undo` | undo the last conversation turn: revert its file changes (write_file/edit_file) and retract its messages — earlier turns are never touched |
|
|
106
|
+
| `/init [force]` | scan the project and generate an AGENTS.md (LLM-polished when a model is available) |
|
|
107
|
+
| `/doctor` | environment self-check (Node, shell, config, API key status, sessions dir writability) |
|
|
83
108
|
| `/clear` | clear the screen |
|
|
84
109
|
| `/exit` | quit |
|
|
85
110
|
| `/q` | quit (alias of `/exit`) |
|
|
86
111
|
|
|
87
|
-
Keys: `ESC` / `Ctrl+C` interrupts the current stream; on a permission prompt: `y` allow, `n` deny, `a` always allow
|
|
112
|
+
Keys: `ESC` / `Ctrl+C` interrupts the current stream; on a permission prompt: `y` allow, `n` deny, `a` always allow — the generated allow-rule (e.g. `bash(npm test)`) is saved to `permissions.allow` in the config file and survives restarts. Write/edit prompts include a colored diff preview of the pending change. Input editing: arrow keys move the cursor, `Ctrl+A`/`Ctrl+E` jump to start/end, `Ctrl+U`/`Ctrl+K` delete before/after the cursor, `Ctrl+W` deletes the previous word, up/down recall history. Typing `/` shows slash-command suggestions — `↑`/`↓` to highlight, `Tab` (or `→` at end of input) to complete, `ESC` to dismiss.
|
|
113
|
+
|
|
114
|
+
While the model is working, a spinner (`- \ | /`) shows `star is thinking…`; reasoning models also stream a dimmed tail of their thinking (last ~200 chars), which collapses to a one-line summary once the answer starts.
|
|
115
|
+
|
|
116
|
+
## !shell passthrough
|
|
117
|
+
|
|
118
|
+
Prefix input with `!` to run a command locally without involving the model:
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
!git status
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Output renders as a tool card and is injected into the conversation so the model can see it afterwards. Dangerous commands are still blocked, and `ESC` / `Ctrl+C` aborts execution.
|
|
125
|
+
|
|
126
|
+
## Background tasks
|
|
127
|
+
|
|
128
|
+
The model can run long shell commands in the background via `bash` with `run_in_background: true` (same permission gate as foreground commands). While anything runs in the background, the status bar shows `bg: N`; when a task finishes, fails, times out, or is stopped, a system message reports the outcome. `/tasks` lists every task with status, runtime, and exit code, and the model can inspect or stop tasks with the `task_list` / `task_output` / `task_kill` tools. Remaining tasks are killed when the REPL exits.
|
|
129
|
+
|
|
130
|
+
## Custom slash commands
|
|
131
|
+
|
|
132
|
+
Drop Markdown files into `.star/commands/<name>.md` (project) or `~/.star-cli/commands/<name>.md` (global) to define your own commands — `/review src/` then sends the file's contents (with `$ARGUMENTS` replaced by your arguments) to the model as a prompt. An optional first line `<!-- description: does a thing -->` sets the description shown in `/help` and autocomplete. Names must match `[a-z0-9-]+`; built-in commands win on conflicts.
|
|
133
|
+
|
|
134
|
+
```markdown
|
|
135
|
+
<!-- description: review code for issues -->
|
|
136
|
+
Review the following code and list concrete issues: $ARGUMENTS
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
The REPL also checks npm for a newer release on startup (async, non-blocking; disable with `STAR_NO_UPDATE_CHECK=1`).
|
|
140
|
+
|
|
141
|
+
## @file mentions
|
|
142
|
+
|
|
143
|
+
Prefix a path with `@` in any prompt to attach its content (REPL and print mode alike):
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
star -p "summarize @README.md and @src/main.tsx"
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Missing, binary, oversized (>100KB), or sensitive files (`.env`, private keys) are skipped with a note. The chat history keeps your original `@path` text, so resumed sessions don't carry the injected bulk.
|
|
88
150
|
|
|
89
151
|
## Built-in tools
|
|
90
152
|
|
|
91
|
-
`read_file`, `write_file`, `edit_file`, `glob`, `grep`, `bash`, `web_fetch`, `todo_read`, `todo_write` — each declares a permission level (`read` / `write` / `exec`) enforced by the permission gate. Hard safety rules (dangerous shell commands, paths outside the working directory, secret files like `.env` / private keys) are denied in
|
|
153
|
+
`read_file`, `write_file`, `edit_file`, `glob`, `grep`, `bash`, `web_fetch`, `web_search` (DuckDuckGo, no API key needed), `todo_read`, `todo_write`, `task_list`, `task_output`, `task_kill` — each declares a permission level (`read` / `write` / `exec`) enforced by the permission gate. Hard safety rules (dangerous shell commands, paths outside the working directory, secret files like `.env` / private keys) are denied in `ask` / `auto` / `readonly` and cannot be overridden by allow-rules.
|
|
154
|
+
|
|
155
|
+
Permission modes: `ask` (reads allowed, writes/exec ask) · `auto` (everything allowed except the hard-denied rules above) · `readonly` (read-only) · `yolo` (allow everything, never ask — **all safety checks disabled**, use at your own risk). Switch at runtime with `/permission` (persisted to the config file) or at startup with `--permission-mode`.
|
|
156
|
+
|
|
157
|
+
Every successful `write_file` / `edit_file` first snapshots the file's previous content (in-memory, last 50 writes per session); `/undo` restores the most recent snapshot, deleting the file if it didn't exist before.
|
|
92
158
|
|
|
93
159
|
## Sessions
|
|
94
160
|
|
|
@@ -97,10 +163,13 @@ Sessions persist under `~/.star-cli/sessions/<id>/` (messages as JSONL + `meta.j
|
|
|
97
163
|
## Development
|
|
98
164
|
|
|
99
165
|
```bash
|
|
100
|
-
pnpm build
|
|
101
|
-
pnpm test
|
|
102
|
-
pnpm typecheck
|
|
103
|
-
pnpm lint
|
|
166
|
+
pnpm build # tsup bundle to dist/
|
|
167
|
+
pnpm test # vitest unit tests (no network)
|
|
168
|
+
pnpm typecheck # tsc --noEmit
|
|
169
|
+
pnpm lint # biome
|
|
170
|
+
pnpm test:pipeline # layered pipeline incl. optional live LLM smoke (needs an API key)
|
|
104
171
|
```
|
|
105
172
|
|
|
173
|
+
CI runs lint, typecheck, tests, and build on Ubuntu + Windows against Node 20/22 (`.github/workflows/ci.yml`).
|
|
174
|
+
|
|
106
175
|
Architecture: `src/cli` (Ink UI), `src/agent` (main loop), `src/llm` (Vercel AI SDK provider layer), `src/tools`, `src/context` (token budget + compaction), `src/permissions`, `src/session`, `src/config`.
|