glyphcode 0.0.0-stage → 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.
Files changed (3) hide show
  1. package/README.md +297 -2
  2. package/dist/index.js +497955 -0
  3. package/package.json +36 -4
package/README.md CHANGED
@@ -1,3 +1,298 @@
1
- # Temporary Holding Version
1
+ # glyph
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **An AI coding agent for the terminal.** Talk to LLMs, run tools, and get work done without leaving your shell.
4
+
5
+ ```
6
+ ┌─ glyph ─────────────────────────────────────────┐
7
+ │ ██████ ██ ██ ███████ ███████ │
8
+ │ ██ ██ ██ ██ ██ ██ │
9
+ │ ██████ ██ ██ █████ █████ │
10
+ │ ██ ██ ██ ██ ██ │
11
+ │ ██ ██████ ███████ ██ │
12
+ │ │
13
+ │ v0.1.0 • anthropic/claude-3-5-sonnet │
14
+ │ /home/user/my-project │
15
+ └─────────────────────────────────────────────────┘
16
+ ```
17
+
18
+ ## Features
19
+
20
+ - **Multiple providers** — Anthropic, OpenAI, Google Gemini, OpenRouter
21
+ - **Interactive TUI** — Full-screen terminal UI built with Ink/React
22
+ - **Tool calling** — Models can run tools (weather, file ops, shell, etc.)
23
+ - **Markdown rendering** — Responses render with syntax highlighting
24
+ - **Scrollable history** — Arrow keys / PgUp / PgDn to browse conversation
25
+ - **One-shot mode** — `glyph chat "question"` for quick queries
26
+ - **Config wizard** — `glyph setup` walks you through provider/model/key
27
+
28
+ ## Quick Start
29
+
30
+ ```bash
31
+ # Install globally
32
+ npm i -g glyph
33
+
34
+ # Or run locally
35
+ npx glyph setup
36
+ ```
37
+
38
+ ```bash
39
+ # First run: configure your provider and API key
40
+ glyph setup
41
+
42
+ # Start the interactive TUI
43
+ glyph
44
+
45
+ # Quick one-off question
46
+ glyph chat "explain async/await in JavaScript"
47
+ ```
48
+
49
+ ## Installation
50
+
51
+ ### From npm (recommended)
52
+ ```bash
53
+ npm i -g glyph
54
+ # or
55
+ pnpm add -g glyph
56
+ # or
57
+ yarn global add glyph
58
+ ```
59
+
60
+ ### From source
61
+ ```bash
62
+ git clone https://github.com/yourusername/glyph.git
63
+ cd glyph
64
+ npm install
65
+ npm run build
66
+ npm link # makes `glyph` available globally
67
+ ```
68
+
69
+ ### Requirements
70
+ - **Node.js 18+** (for built-in fetch, ESM support)
71
+ - A terminal with TTY support (for the interactive TUI)
72
+
73
+ ## Configuration
74
+
75
+ Run the setup wizard:
76
+ ```bash
77
+ glyph setup
78
+ ```
79
+
80
+ It will ask:
81
+ 1. **Provider** — Anthropic, OpenAI, Google, or OpenRouter
82
+ 2. **Model** — Pick from the provider's model list
83
+ 3. **API Key** — Paste your key (hidden input)
84
+
85
+ Config is saved to:
86
+ - **Windows:** `%APPDATA%\.glyph\config.json`
87
+ - **macOS/Linux:** `~/.config/glyph/config.json` (or `~/.glyph/config.json`)
88
+
89
+ The file is created with **owner-only permissions (600)**.
90
+
91
+ ### Non-interactive setup (CI/scripts)
92
+ ```bash
93
+ # Not yet implemented — run `glyph setup` interactively
94
+ ```
95
+
96
+ ## Commands
97
+
98
+ | Command | Description |
99
+ |---------|-------------|
100
+ | `glyph` | Start the interactive TUI (default) |
101
+ | `glyph setup` | Interactive configuration wizard |
102
+ | `glyph config show` | Display current config (key masked) |
103
+ | `glyph config set-key` | Update just the API key |
104
+ | `glyph chat "prompt"` | One-shot query, prints response and exits |
105
+ | `glyph version` | Show version number |
106
+ | `glyph --help` | Show all commands |
107
+ | `glyph -d setup` | Enable debug logging |
108
+
109
+ ### Examples
110
+
111
+ ```bash
112
+ # Interactive coding session
113
+ glyph
114
+
115
+ # Quick question without TUI
116
+ glyph chat "how do I center a div in CSS?"
117
+
118
+ # Override model for one query
119
+ glyph chat "write a quicksort in Python" --model gpt-4o --provider openai
120
+
121
+ # View config
122
+ glyph config show
123
+
124
+ # Rotate API key
125
+ glyph config set-key
126
+ ```
127
+
128
+ ## TUI Controls
129
+
130
+ | Key | Action |
131
+ |-----|--------|
132
+ | `↑` / `↓` | Scroll history by 1 message |
133
+ | `PgUp` / `PgDn` | Scroll by page |
134
+ | `Home` / `End` | Jump to top/bottom |
135
+ | `Esc` | Interrupt current agent turn |
136
+ | `Ctrl+C` | Interrupt / quit (when idle) |
137
+ | `/exit` | Quit the app |
138
+
139
+ **Auto-scroll:** New messages auto-scroll to bottom. Scroll up to pin and read history — scroll to bottom to resume auto-scroll.
140
+
141
+ ## Supported Providers
142
+
143
+ | Provider | Models | API Key Env Var |
144
+ |----------|--------|-----------------|
145
+ | **Anthropic** | Claude 3.5 Sonnet, Haiku, Opus | `ANTHROPIC_API_KEY` |
146
+ | **OpenAI** | GPT-4o, 4o-mini, 4-turbo, 3.5-turbo | `OPENAI_API_KEY` |
147
+ | **Google Gemini** | 1.5 Pro, 1.5 Flash | `GEMINI_API_KEY` |
148
+ | **OpenRouter** | Auto, Claude via OR, GPT via OR | `OPENROUTER_API_KEY` |
149
+
150
+ Get keys from:
151
+ - Anthropic: <https://console.anthropic.com/>
152
+ - OpenAI: <https://platform.openai.com/api-keys>
153
+ - Google: <https://aistudio.google.com/apikey>
154
+ - OpenRouter: <https://openrouter.ai/keys>
155
+
156
+ ## Tools
157
+
158
+ Tools let the agent take actions. Currently built-in:
159
+
160
+ | Tool | Description |
161
+ |------|-------------|
162
+ | `weather` | Live weather lookup via OpenWeatherMap |
163
+
164
+ More tools coming (file read/write, shell, web search, etc.).
165
+
166
+ ## Project Structure
167
+
168
+ ```
169
+ glyph/
170
+ ├── package.json
171
+ ├── tsconfig.json
172
+ ├── dist/ # Built output (gitignored)
173
+ ├── commands/ # CLI commands (Commander)
174
+ │ ├── index.ts # Entry point, command registry
175
+ │ ├── setup.ts # Interactive setup wizard
176
+ │ ├── config.ts # config show / set-key
177
+ │ ├── chat.ts # One-shot chat command
178
+ │ ├── verify.ts # API key verification
179
+ │ ├── config/ # Config file layer
180
+ │ │ ├── path.ts # Cross-platform config paths
181
+ │ │ ├── schema.ts # Zod schema + types
182
+ │ │ ├── read.ts # Load & validate config
183
+ │ │ └── write.ts # Atomic write (tmp→rename, chmod 600)
184
+ │ └── catalogue/
185
+ │ └── provider.ts # Provider catalog (models, endpoints)
186
+ ├── provider/ # LLM provider runtime
187
+ │ ├── index.ts # Lazy OpenAI client from config
188
+ │ ├── model_selector.ts # Model resolution (async + sync)
189
+ │ └── context.ts # Conversation context/history
190
+ ├── core/
191
+ │ ├── agent.ts # Agent loop (streaming, tools)
192
+ │ └── events.ts # Event types
193
+ ├── tools/ # Tool definitions
194
+ │ ├── index.ts # Registry
195
+ │ ├── types.ts # Tool types
196
+ │ └── weather.ts # Weather tool
197
+ ├── ui/ # Ink TUI
198
+ │ ├── App.tsx # Root component
199
+ │ ├── useAgent.ts # Agent ↔ React bridge
200
+ │ ├── theme.ts # Color palette
201
+ │ ├── format.ts # Text formatting helpers
202
+ │ ├── types.ts # UI types
203
+ │ └── components/ # React components (Header, History, Input, etc.)
204
+ └── simple-cli/ # Legacy CLI (being phased out)
205
+ ```
206
+
207
+ ## Development
208
+
209
+ ```bash
210
+ # Install deps
211
+ npm install
212
+
213
+ # Dev mode (runs with Bun, hot reload)
214
+ npm run dev
215
+
216
+ # Build for distribution
217
+ npm run build
218
+
219
+ # Run built version
220
+ node dist/index.js
221
+
222
+ # Type check
223
+ npx tsc --noEmit
224
+ ```
225
+
226
+ ### Adding a Tool
227
+
228
+ 1. Create `tools/mytool.ts`:
229
+ ```ts
230
+ import type { Tool } from "./types";
231
+
232
+ export const myTool: Tool = {
233
+ name: "my_tool",
234
+ description: "Does something useful",
235
+ needsPermission: false,
236
+ schema: { /* Zod schema */ },
237
+ async run(args, signal) {
238
+ // implementation
239
+ return { result: "ok" };
240
+ },
241
+ };
242
+ ```
243
+
244
+ 2. Register in `tools/index.ts`:
245
+ ```ts
246
+ export const registry = { ..., my_tool: myTool };
247
+ export const toolDefinitions = [..., myTool.schema];
248
+ ```
249
+
250
+ ### Adding a Provider
251
+
252
+ Edit `commands/catalogue/provider.ts`:
253
+ ```ts
254
+ export const PROVIDERS = {
255
+ ...existing,
256
+ myprovider: {
257
+ label: "My Provider",
258
+ envVar: "MYPROVIDER_API_KEY",
259
+ models: ["model-1", "model-2"],
260
+ baseURL: "https://api.myprovider.com/v1",
261
+ },
262
+ } as const;
263
+ ```
264
+
265
+ ## Security
266
+
267
+ - **API keys** stored in `config.json` with `chmod 600` (owner read/write only)
268
+ - **Never logged** — keys are masked in all output (`••••••••a1b2`)
269
+ - **No telemetry** — nothing leaves your machine except LLM API calls
270
+ - **Verification** — `glyph setup` tests the key before saving
271
+
272
+ ## Troubleshooting
273
+
274
+ | Issue | Fix |
275
+ |-------|-----|
276
+ | `Raw mode is not supported` | Run in a real terminal (not VS Code output pane, not CI) |
277
+ | `glyph: command not found` | Reinstall: `npm i -g glyph` or add `~/.npm-global/bin` to PATH |
278
+ | `No configuration found` | Run `glyph setup` first |
279
+ | `Could not verify key` | Check key is valid; try `glyph config set-key` |
280
+ | Permission denied on config | `chmod 600 ~/.config/glyph/config.json` |
281
+
282
+ ## Roadmap
283
+
284
+ - [ ] File read/write tools
285
+ - [ ] Shell command execution
286
+ - [ ] Web search tool
287
+ - [ ] Multiple config profiles (`glyph setup --profile work`)
288
+ - [ ] OS keychain storage (optional)
289
+ - [ ] Plugin system for custom tools
290
+ - [ ] Session persistence / export
291
+
292
+ ## License
293
+
294
+ MIT — see [LICENSE](LICENSE) for details.
295
+
296
+ ---
297
+
298
+ **Built with:** TypeScript, Node.js, Ink, Commander, @clack/prompts, Zod, OpenAI SDK, Opencode