@every-env/spiral-cli 0.1.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/README.md +245 -0
- package/package.json +69 -0
- package/src/api.ts +520 -0
- package/src/attachments/index.ts +174 -0
- package/src/auth.ts +160 -0
- package/src/cli.ts +952 -0
- package/src/config.ts +49 -0
- package/src/drafts/editor.ts +105 -0
- package/src/drafts/index.ts +208 -0
- package/src/notes/index.ts +130 -0
- package/src/styles/index.ts +45 -0
- package/src/suggestions/diff.ts +33 -0
- package/src/suggestions/index.ts +205 -0
- package/src/suggestions/parser.ts +83 -0
- package/src/theme.ts +23 -0
- package/src/tools/renderer.ts +104 -0
- package/src/types/marked-terminal.d.ts +31 -0
- package/src/types.ts +170 -0
- package/src/workspaces/index.ts +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
# spiral-cli
|
|
2
|
+
|
|
3
|
+
A command-line interface for interacting with the Spiral API from your terminal.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### Prerequisites
|
|
8
|
+
|
|
9
|
+
- macOS (Safari cookie extraction)
|
|
10
|
+
- [Bun](https://bun.sh/) >= 1.1.0
|
|
11
|
+
- Full Disk Access for terminal (macOS Sonoma+)
|
|
12
|
+
|
|
13
|
+
### Install from source
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
git clone <repo>
|
|
17
|
+
cd spiral-cli
|
|
18
|
+
bun install
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Build standalone binary
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
bun run build
|
|
25
|
+
# Output: dist/spiral
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
1. **Login to Spiral** at https://app.writewithspiral.com in Safari
|
|
31
|
+
2. **Run the CLI:**
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# Interactive chat
|
|
35
|
+
bun run src/cli.ts chat
|
|
36
|
+
|
|
37
|
+
# Send a single message (agent-native)
|
|
38
|
+
bun run src/cli.ts send "Write a haiku about coding"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
### Core Commands
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Interactive chat mode
|
|
47
|
+
spiral chat [--session <id>] [--new]
|
|
48
|
+
|
|
49
|
+
# Send single message (non-interactive, for scripts/agents)
|
|
50
|
+
spiral send <message> [--session <id>] [--json] [--attach file...]
|
|
51
|
+
|
|
52
|
+
# List sessions
|
|
53
|
+
spiral sessions [--json] [--limit N]
|
|
54
|
+
|
|
55
|
+
# View session history
|
|
56
|
+
spiral history <session-id> [--json] [--limit N]
|
|
57
|
+
|
|
58
|
+
# Authentication
|
|
59
|
+
spiral auth status
|
|
60
|
+
spiral auth clear
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Content Management
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Writing styles
|
|
67
|
+
spiral styles [--json]
|
|
68
|
+
|
|
69
|
+
# Workspaces
|
|
70
|
+
spiral workspaces [--json]
|
|
71
|
+
|
|
72
|
+
# Draft management
|
|
73
|
+
spiral drafts --session <id> [--json]
|
|
74
|
+
spiral draft view <id> --session <id>
|
|
75
|
+
spiral draft edit <id> --session <id> # Opens in $EDITOR
|
|
76
|
+
spiral draft update <id> --session <id> --content "New text" # Agent-native
|
|
77
|
+
spiral draft versions <id> --session <id>
|
|
78
|
+
spiral draft restore <id> --session <id> --versionId <vid>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Notes & Suggestions
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Local notes/scratchpad
|
|
85
|
+
spiral notes # List notes
|
|
86
|
+
spiral notes add "Remember X" # Add note
|
|
87
|
+
spiral notes clear # Clear all
|
|
88
|
+
spiral notes remove <id> # Remove specific
|
|
89
|
+
|
|
90
|
+
# Suggestions (parsed from AI responses)
|
|
91
|
+
spiral suggestions # List pending
|
|
92
|
+
spiral suggestions preview <id>
|
|
93
|
+
spiral suggestions apply <id> --session <id>
|
|
94
|
+
spiral suggestions dismiss <id>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Options
|
|
98
|
+
|
|
99
|
+
| Option | Description |
|
|
100
|
+
|--------|-------------|
|
|
101
|
+
| `--help, -h` | Show help |
|
|
102
|
+
| `--version, -v` | Show version |
|
|
103
|
+
| `--session, -s <id>` | Resume session by ID |
|
|
104
|
+
| `--json` | Output as JSON (for scripting) |
|
|
105
|
+
| `--quiet, -q` | Suppress spinners and progress |
|
|
106
|
+
| `--new, -n` | Start new session |
|
|
107
|
+
| `--limit <N>` | Limit results |
|
|
108
|
+
| `--debug, -d` | Enable debug output |
|
|
109
|
+
| `--attach, -a <files>` | Attach files to message |
|
|
110
|
+
| `--style <id>` | Use writing style |
|
|
111
|
+
| `--workspace <id>` | Use workspace context |
|
|
112
|
+
| `--force, -f` | Skip confirmations |
|
|
113
|
+
| `--content <text>` | Content for agent-native draft update |
|
|
114
|
+
| `--title <text>` | Title for draft |
|
|
115
|
+
| `--versionId <id>` | Version ID for restore |
|
|
116
|
+
|
|
117
|
+
### REPL Commands (in chat mode)
|
|
118
|
+
|
|
119
|
+
| Command | Description |
|
|
120
|
+
|---------|-------------|
|
|
121
|
+
| `/help` | Show all commands |
|
|
122
|
+
| `/exit` | Exit chat |
|
|
123
|
+
| `/clear` | Clear screen |
|
|
124
|
+
| `/history` | Show session history |
|
|
125
|
+
| `/sessions` | List all sessions |
|
|
126
|
+
| `/new` | Start new session |
|
|
127
|
+
| `/session <id>` | Switch to session |
|
|
128
|
+
| `/debug` | Toggle debug mode |
|
|
129
|
+
|
|
130
|
+
**Content Management:**
|
|
131
|
+
|
|
132
|
+
| Command | Description |
|
|
133
|
+
|---------|-------------|
|
|
134
|
+
| `/drafts` | List drafts in session |
|
|
135
|
+
| `/draft view <id>` | View a draft |
|
|
136
|
+
| `/draft edit <id>` | Edit in $EDITOR |
|
|
137
|
+
| `/draft versions <id>` | Show version history |
|
|
138
|
+
| `/styles` | List writing styles |
|
|
139
|
+
| `/style <id>` | Set writing style |
|
|
140
|
+
| `/workspaces` | List workspaces |
|
|
141
|
+
| `/workspace <id>` | Set workspace |
|
|
142
|
+
|
|
143
|
+
**Notes & Suggestions:**
|
|
144
|
+
|
|
145
|
+
| Command | Description |
|
|
146
|
+
|---------|-------------|
|
|
147
|
+
| `/note <text>` | Add a note |
|
|
148
|
+
| `/notes` | List all notes |
|
|
149
|
+
| `/notes clear` | Clear all notes |
|
|
150
|
+
| `/suggestions` | List pending suggestions |
|
|
151
|
+
| `/apply <id>` | Apply a suggestion |
|
|
152
|
+
| `/dismiss <id>` | Dismiss a suggestion |
|
|
153
|
+
| `/attach <files>` | Queue files for next message |
|
|
154
|
+
|
|
155
|
+
## Agent-Native Usage
|
|
156
|
+
|
|
157
|
+
spiral-cli is designed for use by AI agents and scripts:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
# JSON output for parsing
|
|
161
|
+
spiral send "Summarize this article" --json
|
|
162
|
+
|
|
163
|
+
# Pipe input
|
|
164
|
+
echo "Explain quantum computing" | spiral send --json
|
|
165
|
+
|
|
166
|
+
# With file attachments
|
|
167
|
+
spiral send "Analyze this data" --attach data.csv --json
|
|
168
|
+
|
|
169
|
+
# Agent-native draft updates (no $EDITOR)
|
|
170
|
+
spiral draft update <id> --session <sid> --content "Updated content"
|
|
171
|
+
|
|
172
|
+
# Check exit codes
|
|
173
|
+
spiral send "Hello" && echo "Success" || echo "Failed"
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Exit Codes
|
|
177
|
+
|
|
178
|
+
| Code | Meaning |
|
|
179
|
+
|------|---------|
|
|
180
|
+
| 0 | Success |
|
|
181
|
+
| 1 | General error |
|
|
182
|
+
| 2 | Authentication failed |
|
|
183
|
+
| 3 | API error |
|
|
184
|
+
| 4 | Network error |
|
|
185
|
+
| 5 | Invalid arguments |
|
|
186
|
+
|
|
187
|
+
## Environment Variables
|
|
188
|
+
|
|
189
|
+
| Variable | Description |
|
|
190
|
+
|----------|-------------|
|
|
191
|
+
| `SPIRAL_API_URL` | Override API endpoint |
|
|
192
|
+
| `SPIRAL_TOKEN` | Provide auth token directly (for CI) |
|
|
193
|
+
| `EDITOR` | Editor for draft editing (default: vi) |
|
|
194
|
+
| `DEBUG` | Enable verbose logging |
|
|
195
|
+
|
|
196
|
+
## Configuration
|
|
197
|
+
|
|
198
|
+
spiral-cli stores local configuration in `~/.config/spiral-cli/`:
|
|
199
|
+
|
|
200
|
+
- Current workspace and style preferences
|
|
201
|
+
- Local notes/scratchpad
|
|
202
|
+
- Draft cache for offline editing
|
|
203
|
+
|
|
204
|
+
## Authentication
|
|
205
|
+
|
|
206
|
+
spiral-cli automatically extracts your session from Safari cookies. No manual token management needed.
|
|
207
|
+
|
|
208
|
+
**Requirements:**
|
|
209
|
+
- Safari must be logged into https://app.writewithspiral.com
|
|
210
|
+
- Terminal needs Full Disk Access (macOS Sonoma+)
|
|
211
|
+
|
|
212
|
+
### Granting Full Disk Access
|
|
213
|
+
|
|
214
|
+
1. Open **System Preferences** > **Privacy & Security**
|
|
215
|
+
2. Click **Full Disk Access**
|
|
216
|
+
3. Add your terminal app (Terminal.app, iTerm2, etc.)
|
|
217
|
+
|
|
218
|
+
## Security Notes
|
|
219
|
+
|
|
220
|
+
- **$EDITOR Integration**: Only trusted editors (vim, nvim, nano, code, etc.) are allowed
|
|
221
|
+
- **File Attachments**: Path traversal and sensitive paths are blocked
|
|
222
|
+
- **Temp Files**: Created with restrictive permissions, securely deleted
|
|
223
|
+
|
|
224
|
+
## Development
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
# Run in dev mode
|
|
228
|
+
bun run src/cli.ts --help
|
|
229
|
+
|
|
230
|
+
# Type check
|
|
231
|
+
bun run typecheck
|
|
232
|
+
|
|
233
|
+
# Run tests
|
|
234
|
+
bun test
|
|
235
|
+
|
|
236
|
+
# Lint
|
|
237
|
+
bun run lint
|
|
238
|
+
|
|
239
|
+
# Build binaries
|
|
240
|
+
bun run build:all
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## License
|
|
244
|
+
|
|
245
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@every-env/spiral-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI for Spiral API - create content from your terminal",
|
|
5
|
+
"author": "Kieran Klaassen",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"bin": {
|
|
9
|
+
"spiral": "./src/cli.ts"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"src",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/EveryInc/spiral-next.git",
|
|
18
|
+
"directory": "spiral-cli"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://github.com/EveryInc/spiral-next/tree/main/spiral-cli#readme",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/EveryInc/spiral-next/issues"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"spiral",
|
|
26
|
+
"cli",
|
|
27
|
+
"ai",
|
|
28
|
+
"writing",
|
|
29
|
+
"content",
|
|
30
|
+
"every"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"dev": "bun run src/cli.ts",
|
|
34
|
+
"build": "bun build src/cli.ts --compile --minify --outfile dist/spiral",
|
|
35
|
+
"build:all": "bun run build:darwin-arm64 && bun run build:darwin-x64",
|
|
36
|
+
"build:darwin-arm64": "bun build src/cli.ts --compile --minify --target=bun-darwin-arm64 --outfile dist/spiral-darwin-arm64",
|
|
37
|
+
"build:darwin-x64": "bun build src/cli.ts --compile --minify --target=bun-darwin-x64 --outfile dist/spiral-darwin-x64",
|
|
38
|
+
"test": "bun test",
|
|
39
|
+
"test:watch": "bun test --watch",
|
|
40
|
+
"lint": "biome check src",
|
|
41
|
+
"lint:fix": "biome check --write src",
|
|
42
|
+
"format": "biome format --write src",
|
|
43
|
+
"typecheck": "tsc --noEmit",
|
|
44
|
+
"prepublishOnly": "bun run typecheck"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@inquirer/prompts": "^8.1.0",
|
|
48
|
+
"@steipete/sweet-cookie": "^0.1.0",
|
|
49
|
+
"chalk": "^5.3.0",
|
|
50
|
+
"conf": "^15.0.2",
|
|
51
|
+
"eventsource-parser": "^3.0.0",
|
|
52
|
+
"marked": "^15.0.0",
|
|
53
|
+
"marked-terminal": "^7.0.0",
|
|
54
|
+
"ora": "^8.0.0"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@biomejs/biome": "^1.9.0",
|
|
58
|
+
"@types/bun": "latest",
|
|
59
|
+
"typescript": "^5.6.0"
|
|
60
|
+
},
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"access": "public"
|
|
63
|
+
},
|
|
64
|
+
"engines": {
|
|
65
|
+
"bun": ">=1.1.0"
|
|
66
|
+
},
|
|
67
|
+
"os": ["darwin"],
|
|
68
|
+
"cpu": ["arm64", "x64"]
|
|
69
|
+
}
|