@drael/code 0.2.0 → 0.3.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 +21 -57
- package/package.json +1 -1
- package/src/code.js +24 -2
package/README.md
CHANGED
|
@@ -1,84 +1,48 @@
|
|
|
1
1
|
# @drael/code
|
|
2
2
|
|
|
3
|
-
Points a coding client at [Drael](https://drael.sh).
|
|
4
|
-
writes.
|
|
3
|
+
Points a coding client at [Drael](https://drael.sh).
|
|
5
4
|
|
|
6
5
|
```sh
|
|
7
6
|
npx @drael/code
|
|
8
7
|
```
|
|
9
8
|
|
|
10
|
-
It asks for your key and which client,
|
|
9
|
+
It asks for your key and which client, writes that client's own configuration file, and
|
|
10
|
+
nothing else. Whatever it touches it copies first.
|
|
11
11
|
|
|
12
12
|
```sh
|
|
13
|
-
npx @drael/code --
|
|
13
|
+
npx @drael/code --list what it knows how to configure, and where
|
|
14
|
+
npx @drael/code --dry-run exactly what it would write, changing nothing
|
|
15
|
+
npx @drael/code --uninstall every file it changed, put back
|
|
16
|
+
npx @drael/code --help the flags
|
|
14
17
|
```
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
| Client | File |
|
|
19
|
-
| ---------- | ----------------------------- |
|
|
20
|
-
| `opencode` | `~/.config/opencode/opencode.json` |
|
|
21
|
-
| `kilo` | `~/.config/kilo/kilo.jsonc` |
|
|
22
|
-
| `env` | `~/.config/drael/env.sh`, for anything reading `OPENAI_BASE_URL` |
|
|
23
|
-
|
|
24
|
-
All three are written `0600`, because a file holding an API key is not a file other
|
|
25
|
-
accounts on the machine should read.
|
|
26
|
-
|
|
27
|
-
The `kilo` file is **merged** rather than replaced: it is the whole extension's
|
|
28
|
-
configuration and not ours, so the other providers and everything else in it are kept.
|
|
29
|
-
|
|
30
|
-
## Undoing it
|
|
31
|
-
|
|
32
|
-
```sh
|
|
33
|
-
npx @drael/code --uninstall
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
Every file is copied before it is written, under `~/.local/state/drael/installer`.
|
|
37
|
-
Uninstall puts the originals back byte for byte and removes the files that did not exist
|
|
38
|
-
before. Installing twice keeps the **first** copy, so what an uninstall restores is the
|
|
39
|
-
state before this ever touched the file.
|
|
40
|
-
|
|
41
|
-
`--dry-run` prints exactly what would be written and changes nothing, including the copy.
|
|
42
|
-
|
|
43
|
-
## The flags
|
|
44
|
-
|
|
45
|
-
| Flag | What it does |
|
|
46
|
-
| ------------- | ---------------------------------------------------------------- |
|
|
47
|
-
| `--key` | The API key. Falls back to `DRAEL_KEY`, then to a prompt. |
|
|
48
|
-
| `--client` | `opencode`, `kilo` or `env`. Without it you are asked. |
|
|
49
|
-
| `--host` | For a local build or your own box. Defaults to `https://drael.sh`. |
|
|
50
|
-
| `--list` | Prints what it knows how to configure, and exits. |
|
|
51
|
-
| `--dry-run` | Prints what would be written, and changes nothing. |
|
|
52
|
-
| `--uninstall` | Restores every file it changed, and exits. |
|
|
19
|
+
Those four answer for themselves rather than being copied out here, so this page cannot
|
|
20
|
+
go stale about which clients are supported, where their files live, or what the flags are.
|
|
53
21
|
|
|
54
22
|
## Why npx rather than `curl | sh`
|
|
55
23
|
|
|
56
24
|
Piping a URL into a shell is exactly the pattern this product's own users are right to
|
|
57
|
-
refuse. npx is already on the machine of anybody running an editor extension, and it
|
|
58
|
-
|
|
25
|
+
refuse. npx is already on the machine of anybody running an editor extension, and it makes
|
|
26
|
+
Windows work without a second implementation to keep in step.
|
|
59
27
|
|
|
60
|
-
It
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
That call is not a check. The last thing it prints is the `curl` that verifies the host
|
|
65
|
-
and the key, for you to run yourself.
|
|
66
|
-
|
|
67
|
-
The source is one file with one dependency, and it is short enough to read in a sitting.
|
|
68
|
-
The people most right to distrust an opaque installer are this product's own users, so it
|
|
69
|
-
earns the trust by being readable rather than by asking.
|
|
28
|
+
It asks for no privilege, and it writes nothing outside the configuration file of the
|
|
29
|
+
client you chose. The source is one file, short enough to read in a sitting: the people
|
|
30
|
+
most right to distrust an opaque installer are this product's own users, so it earns the
|
|
31
|
+
trust by being readable rather than by asking.
|
|
70
32
|
|
|
71
33
|
## Doing it by hand
|
|
72
34
|
|
|
73
|
-
There is nothing privileged in what it writes.
|
|
74
|
-
|
|
35
|
+
There is nothing privileged in what it writes. The API is OpenAI-compatible, so any client
|
|
36
|
+
takes a base URL and a key directly:
|
|
75
37
|
|
|
76
38
|
```sh
|
|
77
39
|
export OPENAI_BASE_URL="https://drael.sh/v1"
|
|
78
40
|
export OPENAI_API_KEY="dk-YOUR-KEY"
|
|
79
41
|
```
|
|
80
42
|
|
|
81
|
-
|
|
82
|
-
|
|
43
|
+
## Everything else
|
|
44
|
+
|
|
45
|
+
[drael.sh/docs/install](https://drael.sh/docs/install) is the documentation, and it is the
|
|
46
|
+
copy that is kept current.
|
|
83
47
|
|
|
84
48
|
MIT
|
package/package.json
CHANGED
package/src/code.js
CHANGED
|
@@ -443,6 +443,26 @@ function uninstall(args) {
|
|
|
443
443
|
console.log()
|
|
444
444
|
}
|
|
445
445
|
|
|
446
|
+
/**
|
|
447
|
+
* The flags, from the tool rather than from a page about the tool. The README points here
|
|
448
|
+
* instead of repeating any of it, and a test holds this list to the flags the code reads.
|
|
449
|
+
*/
|
|
450
|
+
function help() {
|
|
451
|
+
masthead('into the editor you already use')
|
|
452
|
+
for (const [flag, said] of [
|
|
453
|
+
['--key', 'the API key. Falls back to DRAEL_KEY, then to a prompt'],
|
|
454
|
+
['--client', 'which one to configure. Without it, you are asked'],
|
|
455
|
+
['--host', `for a local build or your own box. Defaults to ${DRAEL}`],
|
|
456
|
+
['--list', 'what it knows how to configure, and where'],
|
|
457
|
+
['--dry-run', 'exactly what it would write, changing nothing'],
|
|
458
|
+
['--uninstall', 'every file it changed, put back'],
|
|
459
|
+
['--help', 'this'],
|
|
460
|
+
]) {
|
|
461
|
+
console.log(row(flag, dim(said)))
|
|
462
|
+
}
|
|
463
|
+
console.log()
|
|
464
|
+
}
|
|
465
|
+
|
|
446
466
|
function list() {
|
|
447
467
|
console.log()
|
|
448
468
|
for (const [name, client] of Object.entries(clients)) {
|
|
@@ -473,7 +493,7 @@ function parse(argv) {
|
|
|
473
493
|
const arg = argv[i]
|
|
474
494
|
if (!arg.startsWith('--')) continue
|
|
475
495
|
const name = arg.slice(2)
|
|
476
|
-
if (['list', 'uninstall', 'dry-run'].includes(name)) {
|
|
496
|
+
if (['list', 'uninstall', 'dry-run', 'help'].includes(name)) {
|
|
477
497
|
parsed[name] = true
|
|
478
498
|
continue
|
|
479
499
|
}
|
|
@@ -488,7 +508,9 @@ process.on('exit', () => process.stdout.write('\u001b[?25h'))
|
|
|
488
508
|
|
|
489
509
|
const args = parse(process.argv.slice(2))
|
|
490
510
|
|
|
491
|
-
if (args.
|
|
511
|
+
if (args.help) {
|
|
512
|
+
help()
|
|
513
|
+
} else if (args.list) {
|
|
492
514
|
list()
|
|
493
515
|
} else if (args.uninstall) {
|
|
494
516
|
uninstall(args)
|