@spader/dotllm 1.2.0 → 1.2.3

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 CHANGED
@@ -1,4 +1,20 @@
1
- # motivation
1
+ # dotllm
2
+ `dotllm` manages a system-wide cache of commonly referenced repositories and provides a beautiful command line for linking them anywhere on your system
3
+
4
+ ```bash
5
+ > tree .llm/reference/
6
+ ```
7
+
8
+ ```
9
+ .llm/reference/
10
+ ├── cloudflare-docs -> /home/spader/.local/share/dotllm/store/cloudflare-docs
11
+ ├── cuda-toolkit -> /home/spader/.local/share/dotllm/store/cuda-toolkit
12
+ ├── ghostty -> /home/spader/.local/share/dotllm/store/ghostty
13
+ ├── node-llama-cpp -> /home/spader/.local/share/dotllm/store/node-llama-cpp
14
+ ├── opencode -> /home/spader/.local/share/dotllm/store/opencode
15
+ └── sprites-docs -> /home/spader/.local/share/dotllm/store/sprites-docs
16
+ ```
17
+
2
18
  LLMs work best with references. If you're like me, every project has loose repositories lying around half a dozen places because some LLM needed it.
3
19
 
4
20
  Instead, keep a cache of such repositories and use `dotllm` to link them to `.llm`. Check in `.llm/dotllm.json`, and a simple `dotllm sync` will restore all of your references.
@@ -9,7 +25,7 @@ bun install -g @spader/dotllm
9
25
  ```
10
26
 
11
27
  # usage
12
- Register a repository (by HTTPS, SSH, or path)
28
+ Register a repository (by HTTPS, SSH, or local path)
13
29
  ```bash
14
30
  dotllm add https://github.com/tspader/dotllm.git
15
31
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spader/dotllm",
3
- "version": "1.2.0",
3
+ "version": "1.2.3",
4
4
  "description": "A simple CLI to clone, manage, and link repositories for LLM reference",
5
5
  "type": "module",
6
6
  "repository": {
@@ -35,20 +35,42 @@ function stem(value) {
35
35
  return base;
36
36
  }
37
37
  function github(uri) {
38
- const https = uri.match(/^https?:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?\/?$/);
38
+ return hosted(uri, "github.com");
39
+ }
40
+ function codeberg(uri) {
41
+ return hosted(uri, "codeberg.org");
42
+ }
43
+ function hosted(uri, host) {
44
+ const escaped = host.replace(/\./g, "\\.");
45
+ const https = uri.match(new RegExp(`^https?:\\/\\/${escaped}\\/([^/]+)\\/([^/]+?)(?:\\.git)?\\/?$`));
39
46
  if (https) {
40
47
  return { owner: https[1], repo: https[2] };
41
48
  }
42
- const ssh = uri.match(/^ssh:\/\/git@github\.com\/([^/]+)\/([^/]+?)(?:\.git)?\/?$/);
49
+ const ssh = uri.match(new RegExp(`^ssh:\\/\\/git@${escaped}\\/([^/]+)\\/([^/]+?)(?:\\.git)?\\/?$`));
43
50
  if (ssh) {
44
51
  return { owner: ssh[1], repo: ssh[2] };
45
52
  }
46
- const scp = uri.match(/^git@github\.com:([^/]+)\/([^/]+?)(?:\.git)?$/);
53
+ const scp = uri.match(new RegExp(`^git@${escaped}:([^/]+)\\/([^/]+?)(?:\\.git)?$`));
47
54
  if (scp) {
48
55
  return { owner: scp[1], repo: scp[2] };
49
56
  }
50
57
  return null;
51
58
  }
59
+ async function apiDescription(url, accept) {
60
+ const response = await fetch(url, {
61
+ headers: {
62
+ accept,
63
+ "user-agent": "dotllm"
64
+ }
65
+ });
66
+ if (!response.ok)
67
+ return "";
68
+ const raw = await response.json();
69
+ const result = RepoShape.safeParse(raw);
70
+ if (!result.success)
71
+ return "";
72
+ return result.data.description ?? "";
73
+ }
52
74
  function gitName(uri) {
53
75
  const dir = path.resolve(uri);
54
76
  if (!fs.existsSync(dir))
@@ -68,23 +90,17 @@ function gitName(uri) {
68
90
  return stem(out);
69
91
  }
70
92
  async function remoteDescription(uri) {
71
- const repo = github(uri);
72
- if (!repo)
73
- return "";
74
- const url = `https://api.github.com/repos/${repo.owner}/${repo.repo}`;
75
- const response = await fetch(url, {
76
- headers: {
77
- accept: "application/vnd.github+json",
78
- "user-agent": "dotllm"
79
- }
80
- });
81
- if (!response.ok)
82
- return "";
83
- const raw = await response.json();
84
- const result = RepoShape.safeParse(raw);
85
- if (!result.success)
86
- return "";
87
- return result.data.description ?? "";
93
+ const gh = github(uri);
94
+ if (gh) {
95
+ const url = `https://api.github.com/repos/${gh.owner}/${gh.repo}`;
96
+ return apiDescription(url, "application/vnd.github+json");
97
+ }
98
+ const cb = codeberg(uri);
99
+ if (cb) {
100
+ const url = `https://codeberg.org/api/v1/repos/${cb.owner}/${cb.repo}`;
101
+ return apiDescription(url, "application/json");
102
+ }
103
+ return "";
88
104
  }
89
105
  async function prefill(uri) {
90
106
  const remote = isUrl(uri);
@@ -181,5 +197,6 @@ var command = {
181
197
  export {
182
198
  stem,
183
199
  github,
184
- command
200
+ command,
201
+ codeberg
185
202
  };
package/src/cli/index.js CHANGED
@@ -6,25 +6,28 @@ import { build } from "@spader/dotllm/cli/yargs";
6
6
  import { add, remove, list, link, sync, which, cd } from "@spader/dotllm/cli/commands/index";
7
7
  var DotLlmCli;
8
8
  ((DotLlmCli) => {
9
- DotLlmCli.def = {
10
- name: "dotllm",
11
- description: "Manage git repo references symlinked into .llm/reference/",
12
- commands: {
13
- add,
14
- remove,
15
- list,
16
- link,
17
- sync,
18
- which,
19
- cd
20
- }
21
- };
22
- function run() {
23
- build(DotLlmCli.def).parse();
9
+ async function run() {
10
+ const raw = await Bun.file(new URL("../../package.json", import.meta.url)).json();
11
+ const version = typeof raw.version === "string" ? raw.version : undefined;
12
+ const def = {
13
+ name: "dotllm",
14
+ description: "Manage git repo references symlinked into .llm/reference/",
15
+ version,
16
+ commands: {
17
+ add,
18
+ remove,
19
+ list,
20
+ link,
21
+ sync,
22
+ which,
23
+ cd
24
+ }
25
+ };
26
+ build(def).parse();
24
27
  }
25
28
  DotLlmCli.run = run;
26
29
  })(DotLlmCli ||= {});
27
- DotLlmCli.run();
30
+ await DotLlmCli.run();
28
31
  export {
29
32
  DotLlmCli
30
33
  };
package/src/cli/yargs.js CHANGED
@@ -58,6 +58,9 @@ function help(def, name, path = [], t = defaultTheme) {
58
58
  ...def.options ?? {},
59
59
  help: { alias: "h", type: "boolean", description: "Show help" }
60
60
  };
61
+ if ("version" in def && def.version) {
62
+ opts.version = { alias: "v", type: "boolean", description: "Show version" };
63
+ }
61
64
  if (Object.keys(opts).length > 0) {
62
65
  if (prev)
63
66
  console.log("");
@@ -145,6 +148,9 @@ function configure(y, def, root, path) {
145
148
  y.demandCommand(1, "You must specify a command");
146
149
  }
147
150
  y.help(false).option("help", { alias: "h", type: "boolean", describe: "Show help" }).check(check(def, root, path)).fail(fail(def, root, path));
151
+ if (path.length === 0 && "version" in def && def.version) {
152
+ y.version(def.version).alias("version", "v");
153
+ }
148
154
  }
149
155
  function command(y, name, def, root, path) {
150
156
  let cmd = name;