@draht/coding-agent 2026.3.2-7 → 2026.3.2-9
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/CHANGELOG.md +12 -0
- package/README.md +85 -94
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/migrations.d.ts +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +3 -3
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +1 -1
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/dark.json +1 -1
- package/dist/modes/interactive/theme/light.json +1 -1
- package/docs/compaction.md +12 -12
- package/docs/custom-provider.md +6 -6
- package/docs/development.md +1 -1
- package/docs/extensions.md +8 -8
- package/docs/json.md +4 -4
- package/docs/providers.md +1 -1
- package/docs/session.md +5 -5
- package/docs/themes.md +2 -2
- package/docs/tui.md +1 -1
- package/examples/extensions/README.md +2 -2
- package/examples/extensions/doom-overlay/README.md +1 -1
- package/examples/extensions/dynamic-resources/dynamic.json +1 -1
- package/examples/extensions/subagent/README.md +11 -11
- package/examples/sdk/README.md +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2026.3.2-9] - 2026-03-02
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- update repo URLs from badlogic/pi-mono to draht-dev/draht
|
|
8
|
+
|
|
9
|
+
## [2026.3.2-8] - 2026-03-02
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- rebrand all READMEs to draht naming and conventions
|
|
14
|
+
|
|
3
15
|
## [2026.3.2-7] - 2026-03-02
|
|
4
16
|
|
|
5
17
|
### Fixed
|
package/README.md
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
|
+
<h1 align="center">@draht/coding-agent</h1>
|
|
2
|
+
|
|
1
3
|
<p align="center">
|
|
2
|
-
<a href="https://shittycodingagent.ai">
|
|
3
|
-
<img src="https://shittycodingagent.ai/logo.svg" alt="pi logo" width="128">
|
|
4
|
-
</a>
|
|
5
|
-
</p>
|
|
6
|
-
<p align="center">
|
|
7
|
-
<a href="https://discord.com/invite/3cU7Bz4UPx"><img alt="Discord" src="https://img.shields.io/badge/discord-community-5865F2?style=flat-square&logo=discord&logoColor=white" /></a>
|
|
8
4
|
<a href="https://www.npmjs.com/package/@draht/coding-agent"><img alt="npm" src="https://img.shields.io/npm/v/@draht/coding-agent?style=flat-square" /></a>
|
|
9
|
-
<a href="https://github.com/
|
|
10
|
-
</p>
|
|
11
|
-
<p align="center">
|
|
12
|
-
<a href="https://pi.dev">pi.dev</a> domain graciously donated by
|
|
13
|
-
<br /><br />
|
|
14
|
-
<a href="https://exe.dev"><img src="docs/images/exy.png" alt="Exy mascot" width="48" /><br />exe.dev</a>
|
|
5
|
+
<a href="https://github.com/draht-dev/draht/actions/workflows/ci.yml"><img alt="Build status" src="https://img.shields.io/github/actions/workflow/status/draht-dev/draht/ci.yml?style=flat-square&branch=main" /></a>
|
|
15
6
|
</p>
|
|
16
7
|
|
|
17
|
-
|
|
8
|
+
Draht is a minimal terminal coding harness. Adapt it to your workflows, not the other way around, without having to fork and modify internals. Extend it with TypeScript [Extensions](#extensions), [Skills](#skills), [Prompt Templates](#prompt-templates), and [Themes](#themes). Put your extensions, skills, prompt templates, and themes in [Draht Packages](#draht-packages) and share them with others via npm or git.
|
|
18
9
|
|
|
19
|
-
|
|
10
|
+
Draht ships with powerful defaults but skips features like sub agents and plan mode. Instead, you can ask draht to build what you want or install a third party package that matches your workflow.
|
|
20
11
|
|
|
21
|
-
|
|
12
|
+
Draht runs in four modes: interactive, print or JSON, RPC for process integration, and an SDK for embedding in your own apps.
|
|
22
13
|
|
|
23
14
|
## Table of Contents
|
|
24
15
|
|
|
@@ -39,7 +30,7 @@ Pi runs in four modes: interactive, print or JSON, RPC for process integration,
|
|
|
39
30
|
- [Skills](#skills)
|
|
40
31
|
- [Extensions](#extensions)
|
|
41
32
|
- [Themes](#themes)
|
|
42
|
-
- [
|
|
33
|
+
- [Draht Packages](#draht-packages)
|
|
43
34
|
- [Programmatic Usage](#programmatic-usage)
|
|
44
35
|
- [Philosophy](#philosophy)
|
|
45
36
|
- [CLI Reference](#cli-reference)
|
|
@@ -49,24 +40,24 @@ Pi runs in four modes: interactive, print or JSON, RPC for process integration,
|
|
|
49
40
|
## Quick Start
|
|
50
41
|
|
|
51
42
|
```bash
|
|
52
|
-
|
|
43
|
+
bun add -g @draht/coding-agent
|
|
53
44
|
```
|
|
54
45
|
|
|
55
46
|
Authenticate with an API key:
|
|
56
47
|
|
|
57
48
|
```bash
|
|
58
49
|
export ANTHROPIC_API_KEY=sk-ant-...
|
|
59
|
-
|
|
50
|
+
draht
|
|
60
51
|
```
|
|
61
52
|
|
|
62
53
|
Or use your existing subscription:
|
|
63
54
|
|
|
64
55
|
```bash
|
|
65
|
-
|
|
56
|
+
draht
|
|
66
57
|
/login # Then select provider
|
|
67
58
|
```
|
|
68
59
|
|
|
69
|
-
Then just talk to
|
|
60
|
+
Then just talk to draht. By default, draht gives the model four tools: `read`, `write`, `edit`, and `bash`. The model uses these to fulfill your requests. Add capabilities via [skills](#skills), [prompt templates](#prompt-templates), [extensions](#extensions), or [draht packages](#draht-packages).
|
|
70
61
|
|
|
71
62
|
**Platform notes:** [Windows](docs/windows.md) | [Termux (Android)](docs/termux.md) | [Terminal setup](docs/terminal-setup.md) | [Shell aliases](docs/shell-aliases.md)
|
|
72
63
|
|
|
@@ -74,7 +65,7 @@ Then just talk to pi. By default, pi gives the model four tools: `read`, `write`
|
|
|
74
65
|
|
|
75
66
|
## Providers & Models
|
|
76
67
|
|
|
77
|
-
For each built-in provider,
|
|
68
|
+
For each built-in provider,draht maintains a list of tool-capable models, updated with every release. Authenticate via subscription (`/login`) or API key, then select any model from that provider via `/model` (or Ctrl+L).
|
|
78
69
|
|
|
79
70
|
**Subscriptions:**
|
|
80
71
|
- Anthropic Claude Pro/Max
|
|
@@ -104,7 +95,7 @@ For each built-in provider, pi maintains a list of tool-capable models, updated
|
|
|
104
95
|
|
|
105
96
|
See [docs/providers.md](docs/providers.md) for detailed setup instructions.
|
|
106
97
|
|
|
107
|
-
**Custom providers & models:** Add providers via `~/.
|
|
98
|
+
**Custom providers & models:** Add providers via `~/.draht/agent/models.json` if they speak a supported API (OpenAI, Anthropic, Google). For custom APIs or OAuth, use extensions. See [docs/models.md](docs/models.md) and [docs/custom-provider.md](docs/custom-provider.md).
|
|
108
99
|
|
|
109
100
|
---
|
|
110
101
|
|
|
@@ -156,11 +147,11 @@ Type `/` in the editor to trigger commands. [Extensions](#extensions) can regist
|
|
|
156
147
|
| `/reload` | Reload extensions, skills, prompts, context files (themes hot-reload automatically) |
|
|
157
148
|
| `/hotkeys` | Show all keyboard shortcuts |
|
|
158
149
|
| `/changelog` | Display version history |
|
|
159
|
-
| `/quit`, `/exit` |
|
|
150
|
+
| `/quit`, `/exit` | Quitdraht |
|
|
160
151
|
|
|
161
152
|
### Keyboard Shortcuts
|
|
162
153
|
|
|
163
|
-
See `/hotkeys` for the full list. Customize via `~/.
|
|
154
|
+
See `/hotkeys` for the full list. Customize via `~/.draht/agent/keybindings.json`. See [docs/keybindings.md](docs/keybindings.md).
|
|
164
155
|
|
|
165
156
|
**Commonly used:**
|
|
166
157
|
|
|
@@ -195,13 +186,13 @@ Sessions are stored as JSONL files with a tree structure. Each entry has an `id`
|
|
|
195
186
|
|
|
196
187
|
### Management
|
|
197
188
|
|
|
198
|
-
Sessions auto-save to `~/.
|
|
189
|
+
Sessions auto-save to `~/.draht/agent/sessions/` organized by working directory.
|
|
199
190
|
|
|
200
191
|
```bash
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
192
|
+
draht -c # Continue most recent session
|
|
193
|
+
draht -r # Browse and select from past sessions
|
|
194
|
+
draht --no-session # Ephemeral mode (don't save)
|
|
195
|
+
draht --session <path> # Use specific session file or ID
|
|
205
196
|
```
|
|
206
197
|
|
|
207
198
|
### Branching
|
|
@@ -234,8 +225,8 @@ Use `/settings` to modify common options, or edit JSON files directly:
|
|
|
234
225
|
|
|
235
226
|
| Location | Scope |
|
|
236
227
|
|----------|-------|
|
|
237
|
-
| `~/.
|
|
238
|
-
| `.
|
|
228
|
+
| `~/.draht/agent/settings.json` | Global (all projects) |
|
|
229
|
+
| `.draht/settings.json` | Project (overrides global) |
|
|
239
230
|
|
|
240
231
|
See [docs/settings.md](docs/settings.md) for all options.
|
|
241
232
|
|
|
@@ -243,8 +234,8 @@ See [docs/settings.md](docs/settings.md) for all options.
|
|
|
243
234
|
|
|
244
235
|
## Context Files
|
|
245
236
|
|
|
246
|
-
|
|
247
|
-
- `~/.
|
|
237
|
+
Draht loads `AGENTS.md` (or `CLAUDE.md`) at startup from:
|
|
238
|
+
- `~/.draht/agent/AGENTS.md` (global)
|
|
248
239
|
- Parent directories (walking up from cwd)
|
|
249
240
|
- Current directory
|
|
250
241
|
|
|
@@ -252,7 +243,7 @@ Use for project instructions, conventions, common commands. All matching files a
|
|
|
252
243
|
|
|
253
244
|
### System Prompt
|
|
254
245
|
|
|
255
|
-
Replace the default system prompt with `.
|
|
246
|
+
Replace the default system prompt with `.draht/SYSTEM.md` (project) or `~/.draht/agent/SYSTEM.md` (global). Append without replacing via `APPEND_SYSTEM.md`.
|
|
256
247
|
|
|
257
248
|
---
|
|
258
249
|
|
|
@@ -263,19 +254,19 @@ Replace the default system prompt with `.pi/SYSTEM.md` (project) or `~/.pi/agent
|
|
|
263
254
|
Reusable prompts as Markdown files. Type `/name` to expand.
|
|
264
255
|
|
|
265
256
|
```markdown
|
|
266
|
-
<!-- ~/.
|
|
257
|
+
<!-- ~/.draht/agent/prompts/review.md -->
|
|
267
258
|
Review this code for bugs, security issues, and performance problems.
|
|
268
259
|
Focus on: {{focus}}
|
|
269
260
|
```
|
|
270
261
|
|
|
271
|
-
Place in `~/.
|
|
262
|
+
Place in `~/.draht/agent/prompts/`, `.draht/prompts/`, or a [pi package](#draht-packages) to share with others. See [docs/prompt-templates.md](docs/prompt-templates.md).
|
|
272
263
|
|
|
273
264
|
### Skills
|
|
274
265
|
|
|
275
266
|
On-demand capability packages following the [Agent Skills standard](https://agentskills.io). Invoke via `/skill:name` or let the agent load them automatically.
|
|
276
267
|
|
|
277
268
|
```markdown
|
|
278
|
-
<!-- ~/.
|
|
269
|
+
<!-- ~/.draht/agent/skills/my-skill/SKILL.md -->
|
|
279
270
|
# My Skill
|
|
280
271
|
Use this skill when the user asks about X.
|
|
281
272
|
|
|
@@ -284,19 +275,19 @@ Use this skill when the user asks about X.
|
|
|
284
275
|
2. Then that
|
|
285
276
|
```
|
|
286
277
|
|
|
287
|
-
Place in `~/.
|
|
278
|
+
Place in `~/.draht/agent/skills/`, `~/.agents/skills/`, `.draht/skills/`, or `.agents/skills/` (from `cwd` up through parent directories) or a [pi package](#draht-packages) to share with others. See [docs/skills.md](docs/skills.md).
|
|
288
279
|
|
|
289
280
|
### Extensions
|
|
290
281
|
|
|
291
282
|
<p align="center"><img src="docs/images/doom-extension.png" alt="Doom Extension" width="600"></p>
|
|
292
283
|
|
|
293
|
-
TypeScript modules that
|
|
284
|
+
TypeScript modules that extenddraht with custom tools, commands, keyboard shortcuts, event handlers, and UI components.
|
|
294
285
|
|
|
295
286
|
```typescript
|
|
296
|
-
export default function (
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
287
|
+
export default function (draht: ExtensionAPI) {
|
|
288
|
+
draht.registerTool({ name: "deploy", ... });
|
|
289
|
+
draht.registerCommand("stats", { ... });
|
|
290
|
+
draht.on("tool_call", async (event, ctx) => { ... });
|
|
300
291
|
}
|
|
301
292
|
```
|
|
302
293
|
|
|
@@ -310,50 +301,50 @@ export default function (pi: ExtensionAPI) {
|
|
|
310
301
|
- Git checkpointing and auto-commit
|
|
311
302
|
- SSH and sandbox execution
|
|
312
303
|
- MCP server integration
|
|
313
|
-
-
|
|
304
|
+
- Makedraht look like Claude Code
|
|
314
305
|
- Games while waiting (yes, Doom runs)
|
|
315
306
|
- ...anything you can dream up
|
|
316
307
|
|
|
317
|
-
Place in `~/.
|
|
308
|
+
Place in `~/.draht/agent/extensions/`, `.draht/extensions/`, or a [pi package](#draht-packages) to share with others. See [docs/extensions.md](docs/extensions.md) and [examples/extensions/](examples/extensions/).
|
|
318
309
|
|
|
319
310
|
### Themes
|
|
320
311
|
|
|
321
|
-
Built-in: `dark`, `light`. Themes hot-reload: modify the active theme file
|
|
312
|
+
Built-in: `dark`, `light`. Themes hot-reload: modify the active theme file anddraht immediately applies changes.
|
|
322
313
|
|
|
323
|
-
Place in `~/.
|
|
314
|
+
Place in `~/.draht/agent/themes/`, `.draht/themes/`, or a [pi package](#draht-packages) to share with others. See [docs/themes.md](docs/themes.md).
|
|
324
315
|
|
|
325
|
-
###
|
|
316
|
+
### Draht Packages
|
|
326
317
|
|
|
327
|
-
Bundle and share extensions, skills, prompts, and themes via npm or git. Find packages on [npmjs.com](https://www.npmjs.com/search?q=keywords%
|
|
318
|
+
Bundle and share extensions, skills, prompts, and themes via npm or git. Find packages on [npmjs.com](https://www.npmjs.com/search?q=keywords%3Adraht-package) or [Discord](https://discord.com/channels/1456806362351669492/1457744485428629628).
|
|
328
319
|
|
|
329
|
-
> **Security:**
|
|
320
|
+
> **Security:** Draht packages run with full system access. Extensions execute arbitrary code, and skills can instruct the model to perform any action including running executables. Review source code before installing third-party packages.
|
|
330
321
|
|
|
331
322
|
```bash
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
323
|
+
draht install npm:@foo/draht-tools
|
|
324
|
+
draht install npm:@foo/draht-tools@1.2.3 # pinned version
|
|
325
|
+
draht install git:github.com/user/repo
|
|
326
|
+
draht install git:github.com/user/repo@v1 # tag or commit
|
|
327
|
+
draht install git:git@github.com:user/repo
|
|
328
|
+
draht install git:git@github.com:user/repo@v1 # tag or commit
|
|
329
|
+
draht install https://github.com/user/repo
|
|
330
|
+
draht install https://github.com/user/repo@v1 # tag or commit
|
|
331
|
+
draht install ssh://git@github.com/user/repo
|
|
332
|
+
draht install ssh://git@github.com/user/repo@v1 # tag or commit
|
|
333
|
+
draht remove npm:@foo/draht-tools
|
|
334
|
+
draht list
|
|
335
|
+
draht update # skips pinned packages
|
|
336
|
+
draht config # enable/disable extensions, skills, prompts, themes
|
|
346
337
|
```
|
|
347
338
|
|
|
348
|
-
Packages install to `~/.
|
|
339
|
+
Packages install to `~/.draht/agent/git/` (git) or global npm. Use `-l` for project-local installs (`.draht/git/`, `.draht/npm/`).
|
|
349
340
|
|
|
350
|
-
Create a package by adding a `
|
|
341
|
+
Create a package by adding a `draht` key to `package.json`:
|
|
351
342
|
|
|
352
343
|
```json
|
|
353
344
|
{
|
|
354
|
-
"name": "my-
|
|
355
|
-
"keywords": ["
|
|
356
|
-
"
|
|
345
|
+
"name": "my-draht-package",
|
|
346
|
+
"keywords": ["draht-package"],
|
|
347
|
+
"draht": {
|
|
357
348
|
"extensions": ["./extensions"],
|
|
358
349
|
"skills": ["./skills"],
|
|
359
350
|
"prompts": ["./prompts"],
|
|
@@ -362,7 +353,7 @@ Create a package by adding a `pi` key to `package.json`:
|
|
|
362
353
|
}
|
|
363
354
|
```
|
|
364
355
|
|
|
365
|
-
Without a `
|
|
356
|
+
Without a `draht` manifest,draht auto-discovers from conventional directories (`extensions/`, `skills/`, `prompts/`, `themes/`).
|
|
366
357
|
|
|
367
358
|
See [docs/packages.md](docs/packages.md).
|
|
368
359
|
|
|
@@ -391,7 +382,7 @@ See [docs/sdk.md](docs/sdk.md) and [examples/sdk/](examples/sdk/).
|
|
|
391
382
|
For non-Node.js integrations, use RPC mode over stdin/stdout:
|
|
392
383
|
|
|
393
384
|
```bash
|
|
394
|
-
|
|
385
|
+
draht --mode rpc
|
|
395
386
|
```
|
|
396
387
|
|
|
397
388
|
See [docs/rpc.md](docs/rpc.md) for the protocol.
|
|
@@ -400,11 +391,11 @@ See [docs/rpc.md](docs/rpc.md) for the protocol.
|
|
|
400
391
|
|
|
401
392
|
## Philosophy
|
|
402
393
|
|
|
403
|
-
|
|
394
|
+
Draht is aggressively extensible so it doesn't have to dictate your workflow. Features that other tools bake in can be built with [extensions](#extensions), [skills](#skills), or installed from third-party [pi packages](#draht-packages). This keeps the core minimal while letting you shapedraht to fit how you work.
|
|
404
395
|
|
|
405
396
|
**No MCP.** Build CLI tools with READMEs (see [Skills](#skills)), or build an extension that adds MCP support. [Why?](https://mariozechner.at/posts/2025-11-02-what-if-you-dont-need-mcp/)
|
|
406
397
|
|
|
407
|
-
**No sub-agents.** There's many ways to do this.
|
|
398
|
+
**No sub-agents.** There's many ways to do this. Spawndraht instances via tmux, or build your own with [extensions](#extensions), or install a package that does it your way.
|
|
408
399
|
|
|
409
400
|
**No permission popups.** Run in a container, or build your own confirmation flow with [extensions](#extensions) inline with your environment and security requirements.
|
|
410
401
|
|
|
@@ -421,17 +412,17 @@ Read the [blog post](https://mariozechner.at/posts/2025-11-30-pi-coding-agent/)
|
|
|
421
412
|
## CLI Reference
|
|
422
413
|
|
|
423
414
|
```bash
|
|
424
|
-
|
|
415
|
+
draht [options] [@files...] [messages...]
|
|
425
416
|
```
|
|
426
417
|
|
|
427
418
|
### Package Commands
|
|
428
419
|
|
|
429
420
|
```bash
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
421
|
+
draht install <source> [-l] # Install package, -l for project-local
|
|
422
|
+
draht remove <source> [-l] # Remove package
|
|
423
|
+
draht update [source] # Update packages (skips pinned)
|
|
424
|
+
draht list # List installed packages
|
|
425
|
+
draht config # Enable/disable package resources
|
|
435
426
|
```
|
|
436
427
|
|
|
437
428
|
### Modes
|
|
@@ -504,47 +495,47 @@ Combine `--no-*` with explicit flags to load exactly what you need, ignoring set
|
|
|
504
495
|
Prefix files with `@` to include in the message:
|
|
505
496
|
|
|
506
497
|
```bash
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
498
|
+
draht @prompt.md "Answer this"
|
|
499
|
+
draht -p @screenshot.png "What's in this image?"
|
|
500
|
+
draht @code.ts @test.ts "Review these files"
|
|
510
501
|
```
|
|
511
502
|
|
|
512
503
|
### Examples
|
|
513
504
|
|
|
514
505
|
```bash
|
|
515
506
|
# Interactive with initial prompt
|
|
516
|
-
|
|
507
|
+
draht "List all .ts files in src/"
|
|
517
508
|
|
|
518
509
|
# Non-interactive
|
|
519
|
-
|
|
510
|
+
draht -p "Summarize this codebase"
|
|
520
511
|
|
|
521
512
|
# Different model
|
|
522
|
-
|
|
513
|
+
draht --provider openai --model gpt-4o "Help me refactor"
|
|
523
514
|
|
|
524
515
|
# Model with provider prefix (no --provider needed)
|
|
525
|
-
|
|
516
|
+
draht --model openai/gpt-4o "Help me refactor"
|
|
526
517
|
|
|
527
518
|
# Model with thinking level shorthand
|
|
528
|
-
|
|
519
|
+
draht --model sonnet:high "Solve this complex problem"
|
|
529
520
|
|
|
530
521
|
# Limit model cycling
|
|
531
|
-
|
|
522
|
+
draht --models "claude-*,gpt-4o"
|
|
532
523
|
|
|
533
524
|
# Read-only mode
|
|
534
|
-
|
|
525
|
+
draht --tools read,grep,find,ls -p "Review the code"
|
|
535
526
|
|
|
536
527
|
# High thinking level
|
|
537
|
-
|
|
528
|
+
draht --thinking high "Solve this complex problem"
|
|
538
529
|
```
|
|
539
530
|
|
|
540
531
|
### Environment Variables
|
|
541
532
|
|
|
542
533
|
| Variable | Description |
|
|
543
534
|
|----------|-------------|
|
|
544
|
-
| `
|
|
545
|
-
| `
|
|
546
|
-
| `
|
|
547
|
-
| `
|
|
535
|
+
| `DRAHT_CODING_AGENT_DIR` | Override config directory (default: `~/.draht/agent`) |
|
|
536
|
+
| `DRAHT_PACKAGE_DIR` | Override package directory (useful for Nix/Guix where store paths tokenize poorly) |
|
|
537
|
+
| `DRAHT_SKIP_VERSION_CHECK` | Skip version check at startup |
|
|
538
|
+
| `DRAHT_CACHE_RETENTION` | Set to `long` for extended prompt cache (Anthropic: 1h, OpenAI: 24h) |
|
|
548
539
|
| `VISUAL`, `EDITOR` | External editor for Ctrl+G |
|
|
549
540
|
|
|
550
541
|
---
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,eAAO,MAAM,WAAW,SACqF,CAAC;AAE9G,gEAAgE;AAChE,eAAO,MAAM,YAAY,SAAyB,CAAC;AAMnD,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,SAAS,CAAC;AAEvF,wBAAgB,mBAAmB,IAAI,aAAa,CAqBnD;AAED,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAgBhE;AAMD;;;;;GAKG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAuBtC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAQrC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAO7C;AAED,+BAA+B;AAC/B,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,4BAA4B;AAC5B,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,iCAAiC;AACjC,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,qCAAqC;AACrC,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,+BAA+B;AAC/B,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAQD,eAAO,MAAM,QAAQ,EAAE,MAAyC,CAAC;AACjE,eAAO,MAAM,eAAe,EAAE,MAA+C,CAAC;AAC9E,eAAO,MAAM,OAAO,EAAE,MAAoB,CAAC;AAG3C,eAAO,MAAM,aAAa,QAA+C,CAAC;AAI1E,6CAA6C;AAC7C,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAGxD;AAMD,6DAA6D;AAC7D,wBAAgB,WAAW,IAAI,MAAM,CASpC;AAED,iDAAiD;AACjD,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,8BAA8B;AAC9B,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,4BAA4B;AAC5B,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,gCAAgC;AAChC,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,kCAAkC;AAClC,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,sDAAsD;AACtD,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED,6CAA6C;AAC7C,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAK7C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAK3C;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAKhD;AAED,qCAAqC;AACrC,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,iCAAiC;AACjC,wBAAgB,eAAe,IAAI,MAAM,CAExC","sourcesContent":["import { existsSync, readFileSync } from \"fs\";\nimport { homedir } from \"os\";\nimport { dirname, join, resolve } from \"path\";\nimport { fileURLToPath } from \"url\";\n\n// =============================================================================\n// Package Detection\n// =============================================================================\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Detect if we're running as a Bun compiled binary.\n * Bun binaries have import.meta.url containing \"$bunfs\", \"~BUN\", or \"%7EBUN\" (Bun's virtual filesystem path)\n */\nexport const isBunBinary =\n\timport.meta.url.includes(\"$bunfs\") || import.meta.url.includes(\"~BUN\") || import.meta.url.includes(\"%7EBUN\");\n\n/** Detect if Bun is the runtime (compiled binary or bun run) */\nexport const isBunRuntime = !!process.versions.bun;\n\n// =============================================================================\n// Install Method Detection\n// =============================================================================\n\nexport type InstallMethod = \"bun-binary\" | \"npm\" | \"pnpm\" | \"yarn\" | \"bun\" | \"unknown\";\n\nexport function detectInstallMethod(): InstallMethod {\n\tif (isBunBinary) {\n\t\treturn \"bun-binary\";\n\t}\n\n\tconst resolvedPath = `${__dirname}\\0${process.execPath || \"\"}`.toLowerCase();\n\n\tif (resolvedPath.includes(\"/pnpm/\") || resolvedPath.includes(\"/.pnpm/\") || resolvedPath.includes(\"\\\\pnpm\\\\\")) {\n\t\treturn \"pnpm\";\n\t}\n\tif (resolvedPath.includes(\"/yarn/\") || resolvedPath.includes(\"/.yarn/\") || resolvedPath.includes(\"\\\\yarn\\\\\")) {\n\t\treturn \"yarn\";\n\t}\n\tif (isBunRuntime) {\n\t\treturn \"bun\";\n\t}\n\tif (resolvedPath.includes(\"/npm/\") || resolvedPath.includes(\"/node_modules/\") || resolvedPath.includes(\"\\\\npm\\\\\")) {\n\t\treturn \"npm\";\n\t}\n\n\treturn \"unknown\";\n}\n\nexport function getUpdateInstruction(packageName: string): string {\n\tconst method = detectInstallMethod();\n\tswitch (method) {\n\t\tcase \"bun-binary\":\n\t\t\treturn `Download from: https://github.com/badlogic/pi-mono/releases/latest`;\n\t\tcase \"pnpm\":\n\t\t\treturn `Run: pnpm install -g ${packageName}`;\n\t\tcase \"yarn\":\n\t\t\treturn `Run: yarn global add ${packageName}`;\n\t\tcase \"bun\":\n\t\t\treturn `Run: bun install -g ${packageName}`;\n\t\tcase \"npm\":\n\t\t\treturn `Run: npm install -g ${packageName}`;\n\t\tdefault:\n\t\t\treturn `Run: npm install -g ${packageName}`;\n\t}\n}\n\n// =============================================================================\n// Package Asset Paths (shipped with executable)\n// =============================================================================\n\n/**\n * Get the base directory for resolving package assets (themes, package.json, README.md, CHANGELOG.md).\n * - For Bun binary: returns the directory containing the executable\n * - For Node.js (dist/): returns __dirname (the dist/ directory)\n * - For tsx (src/): returns parent directory (the package root)\n */\nexport function getPackageDir(): string {\n\t// Allow override via environment variable (useful for Nix/Guix where store paths tokenize poorly)\n\tconst envDir = process.env.DRAHT_PACKAGE_DIR;\n\tif (envDir) {\n\t\tif (envDir === \"~\") return homedir();\n\t\tif (envDir.startsWith(\"~/\")) return homedir() + envDir.slice(1);\n\t\treturn envDir;\n\t}\n\n\tif (isBunBinary) {\n\t\t// Bun binary: process.execPath points to the compiled executable\n\t\treturn dirname(process.execPath);\n\t}\n\t// Node.js: walk up from __dirname until we find package.json\n\tlet dir = __dirname;\n\twhile (dir !== dirname(dir)) {\n\t\tif (existsSync(join(dir, \"package.json\"))) {\n\t\t\treturn dir;\n\t\t}\n\t\tdir = dirname(dir);\n\t}\n\t// Fallback (shouldn't happen)\n\treturn __dirname;\n}\n\n/**\n * Get path to built-in themes directory (shipped with package)\n * - For Bun binary: theme/ next to executable\n * - For Node.js (dist/): dist/modes/interactive/theme/\n * - For tsx (src/): src/modes/interactive/theme/\n */\nexport function getThemesDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"theme\");\n\t}\n\t// Theme is in modes/interactive/theme/ relative to src/ or dist/\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"modes\", \"interactive\", \"theme\");\n}\n\n/**\n * Get path to HTML export template directory (shipped with package)\n * - For Bun binary: export-html/ next to executable\n * - For Node.js (dist/): dist/core/export-html/\n * - For tsx (src/): src/core/export-html/\n */\nexport function getExportTemplateDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"export-html\");\n\t}\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"core\", \"export-html\");\n}\n\n/** Get path to package.json */\nexport function getPackageJsonPath(): string {\n\treturn join(getPackageDir(), \"package.json\");\n}\n\n/** Get path to README.md */\nexport function getReadmePath(): string {\n\treturn resolve(join(getPackageDir(), \"README.md\"));\n}\n\n/** Get path to docs directory */\nexport function getDocsPath(): string {\n\treturn resolve(join(getPackageDir(), \"docs\"));\n}\n\n/** Get path to examples directory */\nexport function getExamplesPath(): string {\n\treturn resolve(join(getPackageDir(), \"examples\"));\n}\n\n/** Get path to CHANGELOG.md */\nexport function getChangelogPath(): string {\n\treturn resolve(join(getPackageDir(), \"CHANGELOG.md\"));\n}\n\n// =============================================================================\n// App Config (from package.json drahtConfig)\n// =============================================================================\n\nconst pkg = JSON.parse(readFileSync(getPackageJsonPath(), \"utf-8\"));\n\nexport const APP_NAME: string = pkg.drahtConfig?.name || \"draht\";\nexport const CONFIG_DIR_NAME: string = pkg.drahtConfig?.configDir || \".draht\";\nexport const VERSION: string = pkg.version;\n\n// e.g., DRAHT_CODING_AGENT_DIR or TAU_CODING_AGENT_DIR\nexport const ENV_AGENT_DIR = `${APP_NAME.toUpperCase()}_CODING_AGENT_DIR`;\n\nconst DEFAULT_SHARE_VIEWER_URL = \"https://draht.dev/session/\";\n\n/** Get the share viewer URL for a gist ID */\nexport function getShareViewerUrl(gistId: string): string {\n\tconst baseUrl = process.env.DRAHT_SHARE_VIEWER_URL || DEFAULT_SHARE_VIEWER_URL;\n\treturn `${baseUrl}#${gistId}`;\n}\n\n// =============================================================================\n// User Config Paths (~/.draht/agent/*)\n// =============================================================================\n\n/** Get the agent config directory (e.g., ~/.draht/agent/) */\nexport function getAgentDir(): string {\n\tconst envDir = process.env[ENV_AGENT_DIR];\n\tif (envDir) {\n\t\t// Expand tilde to home directory\n\t\tif (envDir === \"~\") return homedir();\n\t\tif (envDir.startsWith(\"~/\")) return homedir() + envDir.slice(1);\n\t\treturn envDir;\n\t}\n\treturn join(homedir(), CONFIG_DIR_NAME, \"agent\");\n}\n\n/** Get path to user's custom themes directory */\nexport function getCustomThemesDir(): string {\n\treturn join(getAgentDir(), \"themes\");\n}\n\n/** Get path to models.json */\nexport function getModelsPath(): string {\n\treturn join(getAgentDir(), \"models.json\");\n}\n\n/** Get path to auth.json */\nexport function getAuthPath(): string {\n\treturn join(getAgentDir(), \"auth.json\");\n}\n\n/** Get path to settings.json */\nexport function getSettingsPath(): string {\n\treturn join(getAgentDir(), \"settings.json\");\n}\n\n/** Get path to tools directory */\nexport function getToolsDir(): string {\n\treturn join(getAgentDir(), \"tools\");\n}\n\n/** Get path to managed binaries directory (fd, rg) */\nexport function getBinDir(): string {\n\treturn join(getAgentDir(), \"bin\");\n}\n\n/** Get path to prompt templates directory */\nexport function getPromptsDir(): string {\n\treturn join(getAgentDir(), \"prompts\");\n}\n\n/**\n * Get path to shipped prompt templates (bundled with the package).\n * - For Bun binary: prompts/ next to executable\n * - For Node.js: prompts/ at package root\n */\nexport function getShippedPromptsDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"prompts\");\n\t}\n\treturn join(getPackageDir(), \"prompts\");\n}\n\n/**\n * Get path to shipped hooks (bundled with the package).\n */\nexport function getShippedHooksDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"hooks\");\n\t}\n\treturn join(getPackageDir(), \"hooks\");\n}\n\n/**\n * Get path to shipped extensions (bundled with the package).\n * These are loaded automatically for every user — batteries included.\n * - For Bun binary: extensions/ next to executable\n * - For Node.js: extensions/ at package root\n */\nexport function getShippedExtensionsDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"extensions\");\n\t}\n\treturn join(getPackageDir(), \"extensions\");\n}\n\n/** Get path to sessions directory */\nexport function getSessionsDir(): string {\n\treturn join(getAgentDir(), \"sessions\");\n}\n\n/** Get path to debug log file */\nexport function getDebugLogPath(): string {\n\treturn join(getAgentDir(), `${APP_NAME}-debug.log`);\n}\n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AAI,MAAM,CAEtC;AAED,4BAA4B;AAC5B,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,gCAAgC;AAChC,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,kCAAkC;AAClC,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,sDAAsD;AACtD,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED,6CAA6C;AAC7C,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAK7C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAK3C;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAKhD;AAED,qCAAqC;AACrC,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,iCAAiC;AACjC,wBAAgB,eAAe,IAAI,MAAM,CAExC","sourcesContent":["import { existsSync, readFileSync } from \"fs\";\nimport { homedir } from \"os\";\nimport { dirname, join, resolve } from \"path\";\nimport { fileURLToPath } from \"url\";\n\n// =============================================================================\n// Package Detection\n// =============================================================================\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Detect if we're running as a Bun compiled binary.\n * Bun binaries have import.meta.url containing \"$bunfs\", \"~BUN\", or \"%7EBUN\" (Bun's virtual filesystem path)\n */\nexport const isBunBinary =\n\timport.meta.url.includes(\"$bunfs\") || import.meta.url.includes(\"~BUN\") || import.meta.url.includes(\"%7EBUN\");\n\n/** Detect if Bun is the runtime (compiled binary or bun run) */\nexport const isBunRuntime = !!process.versions.bun;\n\n// =============================================================================\n// Install Method Detection\n// =============================================================================\n\nexport type InstallMethod = \"bun-binary\" | \"npm\" | \"pnpm\" | \"yarn\" | \"bun\" | \"unknown\";\n\nexport function detectInstallMethod(): InstallMethod {\n\tif (isBunBinary) {\n\t\treturn \"bun-binary\";\n\t}\n\n\tconst resolvedPath = `${__dirname}\\0${process.execPath || \"\"}`.toLowerCase();\n\n\tif (resolvedPath.includes(\"/pnpm/\") || resolvedPath.includes(\"/.pnpm/\") || resolvedPath.includes(\"\\\\pnpm\\\\\")) {\n\t\treturn \"pnpm\";\n\t}\n\tif (resolvedPath.includes(\"/yarn/\") || resolvedPath.includes(\"/.yarn/\") || resolvedPath.includes(\"\\\\yarn\\\\\")) {\n\t\treturn \"yarn\";\n\t}\n\tif (isBunRuntime) {\n\t\treturn \"bun\";\n\t}\n\tif (resolvedPath.includes(\"/npm/\") || resolvedPath.includes(\"/node_modules/\") || resolvedPath.includes(\"\\\\npm\\\\\")) {\n\t\treturn \"npm\";\n\t}\n\n\treturn \"unknown\";\n}\n\nexport function getUpdateInstruction(packageName: string): string {\n\tconst method = detectInstallMethod();\n\tswitch (method) {\n\t\tcase \"bun-binary\":\n\t\t\treturn `Download from: https://github.com/draht-dev/draht/releases/latest`;\n\t\tcase \"pnpm\":\n\t\t\treturn `Run: pnpm install -g ${packageName}`;\n\t\tcase \"yarn\":\n\t\t\treturn `Run: yarn global add ${packageName}`;\n\t\tcase \"bun\":\n\t\t\treturn `Run: bun install -g ${packageName}`;\n\t\tcase \"npm\":\n\t\t\treturn `Run: npm install -g ${packageName}`;\n\t\tdefault:\n\t\t\treturn `Run: npm install -g ${packageName}`;\n\t}\n}\n\n// =============================================================================\n// Package Asset Paths (shipped with executable)\n// =============================================================================\n\n/**\n * Get the base directory for resolving package assets (themes, package.json, README.md, CHANGELOG.md).\n * - For Bun binary: returns the directory containing the executable\n * - For Node.js (dist/): returns __dirname (the dist/ directory)\n * - For tsx (src/): returns parent directory (the package root)\n */\nexport function getPackageDir(): string {\n\t// Allow override via environment variable (useful for Nix/Guix where store paths tokenize poorly)\n\tconst envDir = process.env.DRAHT_PACKAGE_DIR;\n\tif (envDir) {\n\t\tif (envDir === \"~\") return homedir();\n\t\tif (envDir.startsWith(\"~/\")) return homedir() + envDir.slice(1);\n\t\treturn envDir;\n\t}\n\n\tif (isBunBinary) {\n\t\t// Bun binary: process.execPath points to the compiled executable\n\t\treturn dirname(process.execPath);\n\t}\n\t// Node.js: walk up from __dirname until we find package.json\n\tlet dir = __dirname;\n\twhile (dir !== dirname(dir)) {\n\t\tif (existsSync(join(dir, \"package.json\"))) {\n\t\t\treturn dir;\n\t\t}\n\t\tdir = dirname(dir);\n\t}\n\t// Fallback (shouldn't happen)\n\treturn __dirname;\n}\n\n/**\n * Get path to built-in themes directory (shipped with package)\n * - For Bun binary: theme/ next to executable\n * - For Node.js (dist/): dist/modes/interactive/theme/\n * - For tsx (src/): src/modes/interactive/theme/\n */\nexport function getThemesDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"theme\");\n\t}\n\t// Theme is in modes/interactive/theme/ relative to src/ or dist/\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"modes\", \"interactive\", \"theme\");\n}\n\n/**\n * Get path to HTML export template directory (shipped with package)\n * - For Bun binary: export-html/ next to executable\n * - For Node.js (dist/): dist/core/export-html/\n * - For tsx (src/): src/core/export-html/\n */\nexport function getExportTemplateDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"export-html\");\n\t}\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"core\", \"export-html\");\n}\n\n/** Get path to package.json */\nexport function getPackageJsonPath(): string {\n\treturn join(getPackageDir(), \"package.json\");\n}\n\n/** Get path to README.md */\nexport function getReadmePath(): string {\n\treturn resolve(join(getPackageDir(), \"README.md\"));\n}\n\n/** Get path to docs directory */\nexport function getDocsPath(): string {\n\treturn resolve(join(getPackageDir(), \"docs\"));\n}\n\n/** Get path to examples directory */\nexport function getExamplesPath(): string {\n\treturn resolve(join(getPackageDir(), \"examples\"));\n}\n\n/** Get path to CHANGELOG.md */\nexport function getChangelogPath(): string {\n\treturn resolve(join(getPackageDir(), \"CHANGELOG.md\"));\n}\n\n// =============================================================================\n// App Config (from package.json drahtConfig)\n// =============================================================================\n\nconst pkg = JSON.parse(readFileSync(getPackageJsonPath(), \"utf-8\"));\n\nexport const APP_NAME: string = pkg.drahtConfig?.name || \"draht\";\nexport const CONFIG_DIR_NAME: string = pkg.drahtConfig?.configDir || \".draht\";\nexport const VERSION: string = pkg.version;\n\n// e.g., DRAHT_CODING_AGENT_DIR or TAU_CODING_AGENT_DIR\nexport const ENV_AGENT_DIR = `${APP_NAME.toUpperCase()}_CODING_AGENT_DIR`;\n\nconst DEFAULT_SHARE_VIEWER_URL = \"https://draht.dev/session/\";\n\n/** Get the share viewer URL for a gist ID */\nexport function getShareViewerUrl(gistId: string): string {\n\tconst baseUrl = process.env.DRAHT_SHARE_VIEWER_URL || DEFAULT_SHARE_VIEWER_URL;\n\treturn `${baseUrl}#${gistId}`;\n}\n\n// =============================================================================\n// User Config Paths (~/.draht/agent/*)\n// =============================================================================\n\n/** Get the agent config directory (e.g., ~/.draht/agent/) */\nexport function getAgentDir(): string {\n\tconst envDir = process.env[ENV_AGENT_DIR];\n\tif (envDir) {\n\t\t// Expand tilde to home directory\n\t\tif (envDir === \"~\") return homedir();\n\t\tif (envDir.startsWith(\"~/\")) return homedir() + envDir.slice(1);\n\t\treturn envDir;\n\t}\n\treturn join(homedir(), CONFIG_DIR_NAME, \"agent\");\n}\n\n/** Get path to user's custom themes directory */\nexport function getCustomThemesDir(): string {\n\treturn join(getAgentDir(), \"themes\");\n}\n\n/** Get path to models.json */\nexport function getModelsPath(): string {\n\treturn join(getAgentDir(), \"models.json\");\n}\n\n/** Get path to auth.json */\nexport function getAuthPath(): string {\n\treturn join(getAgentDir(), \"auth.json\");\n}\n\n/** Get path to settings.json */\nexport function getSettingsPath(): string {\n\treturn join(getAgentDir(), \"settings.json\");\n}\n\n/** Get path to tools directory */\nexport function getToolsDir(): string {\n\treturn join(getAgentDir(), \"tools\");\n}\n\n/** Get path to managed binaries directory (fd, rg) */\nexport function getBinDir(): string {\n\treturn join(getAgentDir(), \"bin\");\n}\n\n/** Get path to prompt templates directory */\nexport function getPromptsDir(): string {\n\treturn join(getAgentDir(), \"prompts\");\n}\n\n/**\n * Get path to shipped prompt templates (bundled with the package).\n * - For Bun binary: prompts/ next to executable\n * - For Node.js: prompts/ at package root\n */\nexport function getShippedPromptsDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"prompts\");\n\t}\n\treturn join(getPackageDir(), \"prompts\");\n}\n\n/**\n * Get path to shipped hooks (bundled with the package).\n */\nexport function getShippedHooksDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"hooks\");\n\t}\n\treturn join(getPackageDir(), \"hooks\");\n}\n\n/**\n * Get path to shipped extensions (bundled with the package).\n * These are loaded automatically for every user — batteries included.\n * - For Bun binary: extensions/ next to executable\n * - For Node.js: extensions/ at package root\n */\nexport function getShippedExtensionsDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"extensions\");\n\t}\n\treturn join(getPackageDir(), \"extensions\");\n}\n\n/** Get path to sessions directory */\nexport function getSessionsDir(): string {\n\treturn join(getAgentDir(), \"sessions\");\n}\n\n/** Get path to debug log file */\nexport function getDebugLogPath(): string {\n\treturn join(getAgentDir(), `${APP_NAME}-debug.log`);\n}\n"]}
|
package/dist/config.js
CHANGED
|
@@ -37,7 +37,7 @@ export function getUpdateInstruction(packageName) {
|
|
|
37
37
|
const method = detectInstallMethod();
|
|
38
38
|
switch (method) {
|
|
39
39
|
case "bun-binary":
|
|
40
|
-
return `Download from: https://github.com/
|
|
40
|
+
return `Download from: https://github.com/draht-dev/draht/releases/latest`;
|
|
41
41
|
case "pnpm":
|
|
42
42
|
return `Run: pnpm install -g ${packageName}`;
|
|
43
43
|
case "yarn":
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/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ACvC;AAED,iCAAiC;AACjC,MAAM,UAAU,eAAe,GAAW;IACzC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,GAAG,QAAQ,YAAY,CAAC,CAAC;AAAA,CACpD","sourcesContent":["import { existsSync, readFileSync } from \"fs\";\nimport { homedir } from \"os\";\nimport { dirname, join, resolve } from \"path\";\nimport { fileURLToPath } from \"url\";\n\n// =============================================================================\n// Package Detection\n// =============================================================================\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Detect if we're running as a Bun compiled binary.\n * Bun binaries have import.meta.url containing \"$bunfs\", \"~BUN\", or \"%7EBUN\" (Bun's virtual filesystem path)\n */\nexport const isBunBinary =\n\timport.meta.url.includes(\"$bunfs\") || import.meta.url.includes(\"~BUN\") || import.meta.url.includes(\"%7EBUN\");\n\n/** Detect if Bun is the runtime (compiled binary or bun run) */\nexport const isBunRuntime = !!process.versions.bun;\n\n// =============================================================================\n// Install Method Detection\n// =============================================================================\n\nexport type InstallMethod = \"bun-binary\" | \"npm\" | \"pnpm\" | \"yarn\" | \"bun\" | \"unknown\";\n\nexport function detectInstallMethod(): InstallMethod {\n\tif (isBunBinary) {\n\t\treturn \"bun-binary\";\n\t}\n\n\tconst resolvedPath = `${__dirname}\\0${process.execPath || \"\"}`.toLowerCase();\n\n\tif (resolvedPath.includes(\"/pnpm/\") || resolvedPath.includes(\"/.pnpm/\") || resolvedPath.includes(\"\\\\pnpm\\\\\")) {\n\t\treturn \"pnpm\";\n\t}\n\tif (resolvedPath.includes(\"/yarn/\") || resolvedPath.includes(\"/.yarn/\") || resolvedPath.includes(\"\\\\yarn\\\\\")) {\n\t\treturn \"yarn\";\n\t}\n\tif (isBunRuntime) {\n\t\treturn \"bun\";\n\t}\n\tif (resolvedPath.includes(\"/npm/\") || resolvedPath.includes(\"/node_modules/\") || resolvedPath.includes(\"\\\\npm\\\\\")) {\n\t\treturn \"npm\";\n\t}\n\n\treturn \"unknown\";\n}\n\nexport function getUpdateInstruction(packageName: string): string {\n\tconst method = detectInstallMethod();\n\tswitch (method) {\n\t\tcase \"bun-binary\":\n\t\t\treturn `Download from: https://github.com/badlogic/pi-mono/releases/latest`;\n\t\tcase \"pnpm\":\n\t\t\treturn `Run: pnpm install -g ${packageName}`;\n\t\tcase \"yarn\":\n\t\t\treturn `Run: yarn global add ${packageName}`;\n\t\tcase \"bun\":\n\t\t\treturn `Run: bun install -g ${packageName}`;\n\t\tcase \"npm\":\n\t\t\treturn `Run: npm install -g ${packageName}`;\n\t\tdefault:\n\t\t\treturn `Run: npm install -g ${packageName}`;\n\t}\n}\n\n// =============================================================================\n// Package Asset Paths (shipped with executable)\n// =============================================================================\n\n/**\n * Get the base directory for resolving package assets (themes, package.json, README.md, CHANGELOG.md).\n * - For Bun binary: returns the directory containing the executable\n * - For Node.js (dist/): returns __dirname (the dist/ directory)\n * - For tsx (src/): returns parent directory (the package root)\n */\nexport function getPackageDir(): string {\n\t// Allow override via environment variable (useful for Nix/Guix where store paths tokenize poorly)\n\tconst envDir = process.env.DRAHT_PACKAGE_DIR;\n\tif (envDir) {\n\t\tif (envDir === \"~\") return homedir();\n\t\tif (envDir.startsWith(\"~/\")) return homedir() + envDir.slice(1);\n\t\treturn envDir;\n\t}\n\n\tif (isBunBinary) {\n\t\t// Bun binary: process.execPath points to the compiled executable\n\t\treturn dirname(process.execPath);\n\t}\n\t// Node.js: walk up from __dirname until we find package.json\n\tlet dir = __dirname;\n\twhile (dir !== dirname(dir)) {\n\t\tif (existsSync(join(dir, \"package.json\"))) {\n\t\t\treturn dir;\n\t\t}\n\t\tdir = dirname(dir);\n\t}\n\t// Fallback (shouldn't happen)\n\treturn __dirname;\n}\n\n/**\n * Get path to built-in themes directory (shipped with package)\n * - For Bun binary: theme/ next to executable\n * - For Node.js (dist/): dist/modes/interactive/theme/\n * - For tsx (src/): src/modes/interactive/theme/\n */\nexport function getThemesDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"theme\");\n\t}\n\t// Theme is in modes/interactive/theme/ relative to src/ or dist/\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"modes\", \"interactive\", \"theme\");\n}\n\n/**\n * Get path to HTML export template directory (shipped with package)\n * - For Bun binary: export-html/ next to executable\n * - For Node.js (dist/): dist/core/export-html/\n * - For tsx (src/): src/core/export-html/\n */\nexport function getExportTemplateDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"export-html\");\n\t}\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"core\", \"export-html\");\n}\n\n/** Get path to package.json */\nexport function getPackageJsonPath(): string {\n\treturn join(getPackageDir(), \"package.json\");\n}\n\n/** Get path to README.md */\nexport function getReadmePath(): string {\n\treturn resolve(join(getPackageDir(), \"README.md\"));\n}\n\n/** Get path to docs directory */\nexport function getDocsPath(): string {\n\treturn resolve(join(getPackageDir(), \"docs\"));\n}\n\n/** Get path to examples directory */\nexport function getExamplesPath(): string {\n\treturn resolve(join(getPackageDir(), \"examples\"));\n}\n\n/** Get path to CHANGELOG.md */\nexport function getChangelogPath(): string {\n\treturn resolve(join(getPackageDir(), \"CHANGELOG.md\"));\n}\n\n// =============================================================================\n// App Config (from package.json drahtConfig)\n// =============================================================================\n\nconst pkg = JSON.parse(readFileSync(getPackageJsonPath(), \"utf-8\"));\n\nexport const APP_NAME: string = pkg.drahtConfig?.name || \"draht\";\nexport const CONFIG_DIR_NAME: string = pkg.drahtConfig?.configDir || \".draht\";\nexport const VERSION: string = pkg.version;\n\n// e.g., DRAHT_CODING_AGENT_DIR or TAU_CODING_AGENT_DIR\nexport const ENV_AGENT_DIR = `${APP_NAME.toUpperCase()}_CODING_AGENT_DIR`;\n\nconst DEFAULT_SHARE_VIEWER_URL = \"https://draht.dev/session/\";\n\n/** Get the share viewer URL for a gist ID */\nexport function getShareViewerUrl(gistId: string): string {\n\tconst baseUrl = process.env.DRAHT_SHARE_VIEWER_URL || DEFAULT_SHARE_VIEWER_URL;\n\treturn `${baseUrl}#${gistId}`;\n}\n\n// =============================================================================\n// User Config Paths (~/.draht/agent/*)\n// =============================================================================\n\n/** Get the agent config directory (e.g., ~/.draht/agent/) */\nexport function getAgentDir(): string {\n\tconst envDir = process.env[ENV_AGENT_DIR];\n\tif (envDir) {\n\t\t// Expand tilde to home directory\n\t\tif (envDir === \"~\") return homedir();\n\t\tif (envDir.startsWith(\"~/\")) return homedir() + envDir.slice(1);\n\t\treturn envDir;\n\t}\n\treturn join(homedir(), CONFIG_DIR_NAME, \"agent\");\n}\n\n/** Get path to user's custom themes directory */\nexport function getCustomThemesDir(): string {\n\treturn join(getAgentDir(), \"themes\");\n}\n\n/** Get path to models.json */\nexport function getModelsPath(): string {\n\treturn join(getAgentDir(), \"models.json\");\n}\n\n/** Get path to auth.json */\nexport function getAuthPath(): string {\n\treturn join(getAgentDir(), \"auth.json\");\n}\n\n/** Get path to settings.json */\nexport function getSettingsPath(): string {\n\treturn join(getAgentDir(), \"settings.json\");\n}\n\n/** Get path to tools directory */\nexport function getToolsDir(): string {\n\treturn join(getAgentDir(), \"tools\");\n}\n\n/** Get path to managed binaries directory (fd, rg) */\nexport function getBinDir(): string {\n\treturn join(getAgentDir(), \"bin\");\n}\n\n/** Get path to prompt templates directory */\nexport function getPromptsDir(): string {\n\treturn join(getAgentDir(), \"prompts\");\n}\n\n/**\n * Get path to shipped prompt templates (bundled with the package).\n * - For Bun binary: prompts/ next to executable\n * - For Node.js: prompts/ at package root\n */\nexport function getShippedPromptsDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"prompts\");\n\t}\n\treturn join(getPackageDir(), \"prompts\");\n}\n\n/**\n * Get path to shipped hooks (bundled with the package).\n */\nexport function getShippedHooksDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"hooks\");\n\t}\n\treturn join(getPackageDir(), \"hooks\");\n}\n\n/**\n * Get path to shipped extensions (bundled with the package).\n * These are loaded automatically for every user — batteries included.\n * - For Bun binary: extensions/ next to executable\n * - For Node.js: extensions/ at package root\n */\nexport function getShippedExtensionsDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"extensions\");\n\t}\n\treturn join(getPackageDir(), \"extensions\");\n}\n\n/** Get path to sessions directory */\nexport function getSessionsDir(): string {\n\treturn join(getAgentDir(), \"sessions\");\n}\n\n/** Get path to debug log file */\nexport function getDebugLogPath(): string {\n\treturn join(getAgentDir(), `${APP_NAME}-debug.log`);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,gFAAgF;AAChF,oBAAoB;AACpB,gFAAgF;AAEhF,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GACvB,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAE9G,gEAAgE;AAChE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC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AAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,IAAI,CAAC,aAAa,EAAE,EAAE,OAAO,CAAC,CAAC;AAAA,CACtC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,GAAW;IACjD,IAAI,WAAW,EAAE,CAAC;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,IAAI,CAAC,aAAa,EAAE,EAAE,YAAY,CAAC,CAAC;AAAA,CAC3C;AAED,qCAAqC;AACrC,MAAM,UAAU,cAAc,GAAW;IACxC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,UAAU,CAAC,CAAC;AAAA,CACvC;AAED,iCAAiC;AACjC,MAAM,UAAU,eAAe,GAAW;IACzC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,GAAG,QAAQ,YAAY,CAAC,CAAC;AAAA,CACpD","sourcesContent":["import { existsSync, readFileSync } from \"fs\";\nimport { homedir } from \"os\";\nimport { dirname, join, resolve } from \"path\";\nimport { fileURLToPath } from \"url\";\n\n// =============================================================================\n// Package Detection\n// =============================================================================\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Detect if we're running as a Bun compiled binary.\n * Bun binaries have import.meta.url containing \"$bunfs\", \"~BUN\", or \"%7EBUN\" (Bun's virtual filesystem path)\n */\nexport const isBunBinary =\n\timport.meta.url.includes(\"$bunfs\") || import.meta.url.includes(\"~BUN\") || import.meta.url.includes(\"%7EBUN\");\n\n/** Detect if Bun is the runtime (compiled binary or bun run) */\nexport const isBunRuntime = !!process.versions.bun;\n\n// =============================================================================\n// Install Method Detection\n// =============================================================================\n\nexport type InstallMethod = \"bun-binary\" | \"npm\" | \"pnpm\" | \"yarn\" | \"bun\" | \"unknown\";\n\nexport function detectInstallMethod(): InstallMethod {\n\tif (isBunBinary) {\n\t\treturn \"bun-binary\";\n\t}\n\n\tconst resolvedPath = `${__dirname}\\0${process.execPath || \"\"}`.toLowerCase();\n\n\tif (resolvedPath.includes(\"/pnpm/\") || resolvedPath.includes(\"/.pnpm/\") || resolvedPath.includes(\"\\\\pnpm\\\\\")) {\n\t\treturn \"pnpm\";\n\t}\n\tif (resolvedPath.includes(\"/yarn/\") || resolvedPath.includes(\"/.yarn/\") || resolvedPath.includes(\"\\\\yarn\\\\\")) {\n\t\treturn \"yarn\";\n\t}\n\tif (isBunRuntime) {\n\t\treturn \"bun\";\n\t}\n\tif (resolvedPath.includes(\"/npm/\") || resolvedPath.includes(\"/node_modules/\") || resolvedPath.includes(\"\\\\npm\\\\\")) {\n\t\treturn \"npm\";\n\t}\n\n\treturn \"unknown\";\n}\n\nexport function getUpdateInstruction(packageName: string): string {\n\tconst method = detectInstallMethod();\n\tswitch (method) {\n\t\tcase \"bun-binary\":\n\t\t\treturn `Download from: https://github.com/draht-dev/draht/releases/latest`;\n\t\tcase \"pnpm\":\n\t\t\treturn `Run: pnpm install -g ${packageName}`;\n\t\tcase \"yarn\":\n\t\t\treturn `Run: yarn global add ${packageName}`;\n\t\tcase \"bun\":\n\t\t\treturn `Run: bun install -g ${packageName}`;\n\t\tcase \"npm\":\n\t\t\treturn `Run: npm install -g ${packageName}`;\n\t\tdefault:\n\t\t\treturn `Run: npm install -g ${packageName}`;\n\t}\n}\n\n// =============================================================================\n// Package Asset Paths (shipped with executable)\n// =============================================================================\n\n/**\n * Get the base directory for resolving package assets (themes, package.json, README.md, CHANGELOG.md).\n * - For Bun binary: returns the directory containing the executable\n * - For Node.js (dist/): returns __dirname (the dist/ directory)\n * - For tsx (src/): returns parent directory (the package root)\n */\nexport function getPackageDir(): string {\n\t// Allow override via environment variable (useful for Nix/Guix where store paths tokenize poorly)\n\tconst envDir = process.env.DRAHT_PACKAGE_DIR;\n\tif (envDir) {\n\t\tif (envDir === \"~\") return homedir();\n\t\tif (envDir.startsWith(\"~/\")) return homedir() + envDir.slice(1);\n\t\treturn envDir;\n\t}\n\n\tif (isBunBinary) {\n\t\t// Bun binary: process.execPath points to the compiled executable\n\t\treturn dirname(process.execPath);\n\t}\n\t// Node.js: walk up from __dirname until we find package.json\n\tlet dir = __dirname;\n\twhile (dir !== dirname(dir)) {\n\t\tif (existsSync(join(dir, \"package.json\"))) {\n\t\t\treturn dir;\n\t\t}\n\t\tdir = dirname(dir);\n\t}\n\t// Fallback (shouldn't happen)\n\treturn __dirname;\n}\n\n/**\n * Get path to built-in themes directory (shipped with package)\n * - For Bun binary: theme/ next to executable\n * - For Node.js (dist/): dist/modes/interactive/theme/\n * - For tsx (src/): src/modes/interactive/theme/\n */\nexport function getThemesDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"theme\");\n\t}\n\t// Theme is in modes/interactive/theme/ relative to src/ or dist/\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"modes\", \"interactive\", \"theme\");\n}\n\n/**\n * Get path to HTML export template directory (shipped with package)\n * - For Bun binary: export-html/ next to executable\n * - For Node.js (dist/): dist/core/export-html/\n * - For tsx (src/): src/core/export-html/\n */\nexport function getExportTemplateDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"export-html\");\n\t}\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"core\", \"export-html\");\n}\n\n/** Get path to package.json */\nexport function getPackageJsonPath(): string {\n\treturn join(getPackageDir(), \"package.json\");\n}\n\n/** Get path to README.md */\nexport function getReadmePath(): string {\n\treturn resolve(join(getPackageDir(), \"README.md\"));\n}\n\n/** Get path to docs directory */\nexport function getDocsPath(): string {\n\treturn resolve(join(getPackageDir(), \"docs\"));\n}\n\n/** Get path to examples directory */\nexport function getExamplesPath(): string {\n\treturn resolve(join(getPackageDir(), \"examples\"));\n}\n\n/** Get path to CHANGELOG.md */\nexport function getChangelogPath(): string {\n\treturn resolve(join(getPackageDir(), \"CHANGELOG.md\"));\n}\n\n// =============================================================================\n// App Config (from package.json drahtConfig)\n// =============================================================================\n\nconst pkg = JSON.parse(readFileSync(getPackageJsonPath(), \"utf-8\"));\n\nexport const APP_NAME: string = pkg.drahtConfig?.name || \"draht\";\nexport const CONFIG_DIR_NAME: string = pkg.drahtConfig?.configDir || \".draht\";\nexport const VERSION: string = pkg.version;\n\n// e.g., DRAHT_CODING_AGENT_DIR or TAU_CODING_AGENT_DIR\nexport const ENV_AGENT_DIR = `${APP_NAME.toUpperCase()}_CODING_AGENT_DIR`;\n\nconst DEFAULT_SHARE_VIEWER_URL = \"https://draht.dev/session/\";\n\n/** Get the share viewer URL for a gist ID */\nexport function getShareViewerUrl(gistId: string): string {\n\tconst baseUrl = process.env.DRAHT_SHARE_VIEWER_URL || DEFAULT_SHARE_VIEWER_URL;\n\treturn `${baseUrl}#${gistId}`;\n}\n\n// =============================================================================\n// User Config Paths (~/.draht/agent/*)\n// =============================================================================\n\n/** Get the agent config directory (e.g., ~/.draht/agent/) */\nexport function getAgentDir(): string {\n\tconst envDir = process.env[ENV_AGENT_DIR];\n\tif (envDir) {\n\t\t// Expand tilde to home directory\n\t\tif (envDir === \"~\") return homedir();\n\t\tif (envDir.startsWith(\"~/\")) return homedir() + envDir.slice(1);\n\t\treturn envDir;\n\t}\n\treturn join(homedir(), CONFIG_DIR_NAME, \"agent\");\n}\n\n/** Get path to user's custom themes directory */\nexport function getCustomThemesDir(): string {\n\treturn join(getAgentDir(), \"themes\");\n}\n\n/** Get path to models.json */\nexport function getModelsPath(): string {\n\treturn join(getAgentDir(), \"models.json\");\n}\n\n/** Get path to auth.json */\nexport function getAuthPath(): string {\n\treturn join(getAgentDir(), \"auth.json\");\n}\n\n/** Get path to settings.json */\nexport function getSettingsPath(): string {\n\treturn join(getAgentDir(), \"settings.json\");\n}\n\n/** Get path to tools directory */\nexport function getToolsDir(): string {\n\treturn join(getAgentDir(), \"tools\");\n}\n\n/** Get path to managed binaries directory (fd, rg) */\nexport function getBinDir(): string {\n\treturn join(getAgentDir(), \"bin\");\n}\n\n/** Get path to prompt templates directory */\nexport function getPromptsDir(): string {\n\treturn join(getAgentDir(), \"prompts\");\n}\n\n/**\n * Get path to shipped prompt templates (bundled with the package).\n * - For Bun binary: prompts/ next to executable\n * - For Node.js: prompts/ at package root\n */\nexport function getShippedPromptsDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"prompts\");\n\t}\n\treturn join(getPackageDir(), \"prompts\");\n}\n\n/**\n * Get path to shipped hooks (bundled with the package).\n */\nexport function getShippedHooksDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"hooks\");\n\t}\n\treturn join(getPackageDir(), \"hooks\");\n}\n\n/**\n * Get path to shipped extensions (bundled with the package).\n * These are loaded automatically for every user — batteries included.\n * - For Bun binary: extensions/ next to executable\n * - For Node.js: extensions/ at package root\n */\nexport function getShippedExtensionsDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"extensions\");\n\t}\n\treturn join(getPackageDir(), \"extensions\");\n}\n\n/** Get path to sessions directory */\nexport function getSessionsDir(): string {\n\treturn join(getAgentDir(), \"sessions\");\n}\n\n/** Get path to debug log file */\nexport function getDebugLogPath(): string {\n\treturn join(getAgentDir(), `${APP_NAME}-debug.log`);\n}\n"]}
|
package/dist/migrations.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare function migrateAuthToAuthJson(): string[];
|
|
|
14
14
|
* ~/.draht/agent/sessions/<encoded-cwd>/. This migration moves them
|
|
15
15
|
* to the correct location based on the cwd in their session header.
|
|
16
16
|
*
|
|
17
|
-
* See: https://github.com/
|
|
17
|
+
* See: https://github.com/draht-dev/draht/issues/320
|
|
18
18
|
*/
|
|
19
19
|
export declare function migrateSessionsFromAgentRoot(): void;
|
|
20
20
|
/**
|