@eloxiv/cli 0.0.0-stage → 0.1.1

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 (294) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -2
  3. package/dist/AgentSkills.d.ts +51 -0
  4. package/dist/AgentSkills.d.ts.map +1 -0
  5. package/dist/AgentSkills.js +264 -0
  6. package/dist/AgentSkills.js.map +1 -0
  7. package/dist/AgentWeb.d.ts +83 -0
  8. package/dist/AgentWeb.d.ts.map +1 -0
  9. package/dist/AgentWeb.js +436 -0
  10. package/dist/AgentWeb.js.map +1 -0
  11. package/dist/App.d.ts +213 -0
  12. package/dist/App.d.ts.map +1 -0
  13. package/dist/App.js +357 -0
  14. package/dist/App.js.map +1 -0
  15. package/dist/Blueprint.d.ts +47 -0
  16. package/dist/Blueprint.d.ts.map +1 -0
  17. package/dist/Blueprint.js +241 -0
  18. package/dist/Blueprint.js.map +1 -0
  19. package/dist/Brand.d.ts +42 -0
  20. package/dist/Brand.d.ts.map +1 -0
  21. package/dist/Brand.js +370 -0
  22. package/dist/Brand.js.map +1 -0
  23. package/dist/Changelog.d.ts +22 -0
  24. package/dist/Changelog.d.ts.map +1 -0
  25. package/dist/Changelog.js +117 -0
  26. package/dist/Changelog.js.map +1 -0
  27. package/dist/Cli.d.ts +17 -0
  28. package/dist/Cli.d.ts.map +1 -0
  29. package/dist/Cli.js +810 -0
  30. package/dist/Cli.js.map +1 -0
  31. package/dist/DbAdmin.d.ts +18 -0
  32. package/dist/DbAdmin.d.ts.map +1 -0
  33. package/dist/DbAdmin.js +91 -0
  34. package/dist/DbAdmin.js.map +1 -0
  35. package/dist/Dependencies.d.ts +53 -0
  36. package/dist/Dependencies.d.ts.map +1 -0
  37. package/dist/Dependencies.js +132 -0
  38. package/dist/Dependencies.js.map +1 -0
  39. package/dist/Deploy.d.ts +39 -0
  40. package/dist/Deploy.d.ts.map +1 -0
  41. package/dist/Deploy.js +458 -0
  42. package/dist/Deploy.js.map +1 -0
  43. package/dist/Docs.d.ts +71 -0
  44. package/dist/Docs.d.ts.map +1 -0
  45. package/dist/Docs.js +240 -0
  46. package/dist/Docs.js.map +1 -0
  47. package/dist/Doctor.d.ts +56 -0
  48. package/dist/Doctor.d.ts.map +1 -0
  49. package/dist/Doctor.js +368 -0
  50. package/dist/Doctor.js.map +1 -0
  51. package/dist/Dossier.d.ts +23 -0
  52. package/dist/Dossier.d.ts.map +1 -0
  53. package/dist/Dossier.js +92 -0
  54. package/dist/Dossier.js.map +1 -0
  55. package/dist/Emit.d.ts +26 -0
  56. package/dist/Emit.d.ts.map +1 -0
  57. package/dist/Emit.js +51 -0
  58. package/dist/Emit.js.map +1 -0
  59. package/dist/Errors.d.ts +26 -0
  60. package/dist/Errors.d.ts.map +1 -0
  61. package/dist/Errors.js +17 -0
  62. package/dist/Errors.js.map +1 -0
  63. package/dist/Evals.d.ts +52 -0
  64. package/dist/Evals.d.ts.map +1 -0
  65. package/dist/Evals.js +126 -0
  66. package/dist/Evals.js.map +1 -0
  67. package/dist/Files.d.ts +47 -0
  68. package/dist/Files.d.ts.map +1 -0
  69. package/dist/Files.js +145 -0
  70. package/dist/Files.js.map +1 -0
  71. package/dist/Generate.d.ts +80 -0
  72. package/dist/Generate.d.ts.map +1 -0
  73. package/dist/Generate.js +310 -0
  74. package/dist/Generate.js.map +1 -0
  75. package/dist/Guards.d.ts +45 -0
  76. package/dist/Guards.d.ts.map +1 -0
  77. package/dist/Guards.js +530 -0
  78. package/dist/Guards.js.map +1 -0
  79. package/dist/Inspect.d.ts +125 -0
  80. package/dist/Inspect.d.ts.map +1 -0
  81. package/dist/Inspect.js +270 -0
  82. package/dist/Inspect.js.map +1 -0
  83. package/dist/Keychain.d.ts +57 -0
  84. package/dist/Keychain.d.ts.map +1 -0
  85. package/dist/Keychain.js +73 -0
  86. package/dist/Keychain.js.map +1 -0
  87. package/dist/Lock.d.ts +13 -0
  88. package/dist/Lock.d.ts.map +1 -0
  89. package/dist/Lock.js +145 -0
  90. package/dist/Lock.js.map +1 -0
  91. package/dist/Mcp.d.ts +91 -0
  92. package/dist/Mcp.d.ts.map +1 -0
  93. package/dist/Mcp.js +128 -0
  94. package/dist/Mcp.js.map +1 -0
  95. package/dist/Merge.d.ts +18 -0
  96. package/dist/Merge.d.ts.map +1 -0
  97. package/dist/Merge.js +43 -0
  98. package/dist/Merge.js.map +1 -0
  99. package/dist/Migrate.d.ts +78 -0
  100. package/dist/Migrate.d.ts.map +1 -0
  101. package/dist/Migrate.js +288 -0
  102. package/dist/Migrate.js.map +1 -0
  103. package/dist/Plugins.d.ts +36 -0
  104. package/dist/Plugins.d.ts.map +1 -0
  105. package/dist/Plugins.js +304 -0
  106. package/dist/Plugins.js.map +1 -0
  107. package/dist/Postgres.d.ts +73 -0
  108. package/dist/Postgres.d.ts.map +1 -0
  109. package/dist/Postgres.js +294 -0
  110. package/dist/Postgres.js.map +1 -0
  111. package/dist/Publish.d.ts +23 -0
  112. package/dist/Publish.d.ts.map +1 -0
  113. package/dist/Publish.js +59 -0
  114. package/dist/Publish.js.map +1 -0
  115. package/dist/Registry.d.ts +539 -0
  116. package/dist/Registry.d.ts.map +1 -0
  117. package/dist/Registry.js +340 -0
  118. package/dist/Registry.js.map +1 -0
  119. package/dist/Remote.d.ts +90 -0
  120. package/dist/Remote.d.ts.map +1 -0
  121. package/dist/Remote.js +1006 -0
  122. package/dist/Remote.js.map +1 -0
  123. package/dist/Run.d.ts +120 -0
  124. package/dist/Run.d.ts.map +1 -0
  125. package/dist/Run.js +477 -0
  126. package/dist/Run.js.map +1 -0
  127. package/dist/SyncGen.d.ts +118 -0
  128. package/dist/SyncGen.d.ts.map +1 -0
  129. package/dist/SyncGen.js +392 -0
  130. package/dist/SyncGen.js.map +1 -0
  131. package/dist/Update.d.ts +301 -0
  132. package/dist/Update.d.ts.map +1 -0
  133. package/dist/Update.js +627 -0
  134. package/dist/Update.js.map +1 -0
  135. package/dist/bin.d.ts +3 -0
  136. package/dist/bin.d.ts.map +1 -0
  137. package/dist/bin.js +42 -0
  138. package/dist/bin.js.map +1 -0
  139. package/dist/docs/backlog.md +56 -0
  140. package/dist/docs/ci.md +277 -0
  141. package/dist/docs/cli.md +696 -0
  142. package/dist/docs/connectors/google.md +115 -0
  143. package/dist/docs/connectors/http-openapi.md +7 -0
  144. package/dist/docs/connectors/mcp.md +8 -0
  145. package/dist/docs/connectors/microsoft-graph.md +75 -0
  146. package/dist/docs/connectors/openai.md +25 -0
  147. package/dist/docs/connectors/slack.md +162 -0
  148. package/dist/docs/connectors/workos.md +39 -0
  149. package/dist/docs/contracts/README.md +173 -0
  150. package/dist/docs/contracts/action-consent.md +92 -0
  151. package/dist/docs/contracts/action-registry.md +85 -0
  152. package/dist/docs/contracts/actor.md +100 -0
  153. package/dist/docs/contracts/agent-resources.md +90 -0
  154. package/dist/docs/contracts/agent-runtime.md +257 -0
  155. package/dist/docs/contracts/approvals.md +126 -0
  156. package/dist/docs/contracts/audit.md +75 -0
  157. package/dist/docs/contracts/auth-provider.md +74 -0
  158. package/dist/docs/contracts/calendar-provider.md +46 -0
  159. package/dist/docs/contracts/client-sdk.md +245 -0
  160. package/dist/docs/contracts/collab-document.md +151 -0
  161. package/dist/docs/contracts/command.md +44 -0
  162. package/dist/docs/contracts/connections.md +235 -0
  163. package/dist/docs/contracts/context-accounting.md +50 -0
  164. package/dist/docs/contracts/daemon.md +243 -0
  165. package/dist/docs/contracts/db-tx.md +53 -0
  166. package/dist/docs/contracts/delegation.md +68 -0
  167. package/dist/docs/contracts/device-control.md +103 -0
  168. package/dist/docs/contracts/directory-provider.md +36 -0
  169. package/dist/docs/contracts/directory.md +161 -0
  170. package/dist/docs/contracts/document-source.md +33 -0
  171. package/dist/docs/contracts/files.md +115 -0
  172. package/dist/docs/contracts/flags.md +83 -0
  173. package/dist/docs/contracts/host.md +68 -0
  174. package/dist/docs/contracts/http-api.md +43 -0
  175. package/dist/docs/contracts/ingestion.md +130 -0
  176. package/dist/docs/contracts/ingress.md +141 -0
  177. package/dist/docs/contracts/invocation.md +260 -0
  178. package/dist/docs/contracts/local-client.md +110 -0
  179. package/dist/docs/contracts/locale.md +56 -0
  180. package/dist/docs/contracts/machine-identity.md +117 -0
  181. package/dist/docs/contracts/mail-provider.md +49 -0
  182. package/dist/docs/contracts/memory.md +53 -0
  183. package/dist/docs/contracts/messaging.md +40 -0
  184. package/dist/docs/contracts/metering.md +139 -0
  185. package/dist/docs/contracts/model-provider.md +84 -0
  186. package/dist/docs/contracts/module-manifest.md +213 -0
  187. package/dist/docs/contracts/notification-channel.md +90 -0
  188. package/dist/docs/contracts/notifications.md +123 -0
  189. package/dist/docs/contracts/outbox.md +80 -0
  190. package/dist/docs/contracts/privacy.md +110 -0
  191. package/dist/docs/contracts/progress.md +52 -0
  192. package/dist/docs/contracts/query-surface.md +108 -0
  193. package/dist/docs/contracts/readiness.md +63 -0
  194. package/dist/docs/contracts/release.md +142 -0
  195. package/dist/docs/contracts/result-rendering.md +61 -0
  196. package/dist/docs/contracts/sandbox.md +186 -0
  197. package/dist/docs/contracts/scheduler.md +148 -0
  198. package/dist/docs/contracts/screen-context.md +81 -0
  199. package/dist/docs/contracts/search.md +120 -0
  200. package/dist/docs/contracts/secrets.md +74 -0
  201. package/dist/docs/contracts/settings.md +109 -0
  202. package/dist/docs/contracts/sharing.md +77 -0
  203. package/dist/docs/contracts/slot.md +48 -0
  204. package/dist/docs/contracts/space.md +67 -0
  205. package/dist/docs/contracts/storage-adapter.md +45 -0
  206. package/dist/docs/contracts/storage-backend.md +56 -0
  207. package/dist/docs/contracts/sync.md +213 -0
  208. package/dist/docs/contracts/telemetry.md +80 -0
  209. package/dist/docs/contracts/theme-tokens.md +50 -0
  210. package/dist/docs/contracts/tool-source.md +58 -0
  211. package/dist/docs/contracts/versioning.md +99 -0
  212. package/dist/docs/contracts/view.md +65 -0
  213. package/dist/docs/contracts/work-items.md +99 -0
  214. package/dist/docs/contracts/workflow.md +82 -0
  215. package/dist/docs/decisions.md +163 -0
  216. package/dist/docs/example-app.md +192 -0
  217. package/dist/docs/getting-started.md +927 -0
  218. package/dist/docs/goal.md +54 -0
  219. package/dist/docs/parity.md +29 -0
  220. package/dist/docs/performance.md +129 -0
  221. package/dist/docs/registry/README.md +74 -0
  222. package/dist/docs/registry/app.md +38 -0
  223. package/dist/docs/registry/approvals-ui-foldkit.md +28 -0
  224. package/dist/docs/registry/calendar-ui-foldkit.md +27 -0
  225. package/dist/docs/registry/calendar.md +35 -0
  226. package/dist/docs/registry/chat-ui-foldkit.md +30 -0
  227. package/dist/docs/registry/desktop-rune.md +50 -0
  228. package/dist/docs/registry/desktop.md +32 -0
  229. package/dist/docs/registry/eloxiv-action.md +25 -0
  230. package/dist/docs/registry/eloxiv-connector.md +25 -0
  231. package/dist/docs/registry/eloxiv-module.md +25 -0
  232. package/dist/docs/registry/eloxiv-policy.md +25 -0
  233. package/dist/docs/registry/eloxiv-view.md +25 -0
  234. package/dist/docs/registry/hello-ui-foldkit.md +29 -0
  235. package/dist/docs/registry/hello.md +39 -0
  236. package/dist/docs/registry/home-ui-foldkit.md +27 -0
  237. package/dist/docs/registry/home.md +29 -0
  238. package/dist/docs/registry/inbox-ui-foldkit.md +27 -0
  239. package/dist/docs/registry/mail-ui-foldkit.md +27 -0
  240. package/dist/docs/registry/mail.md +34 -0
  241. package/dist/docs/registry/meeting-prep.md +26 -0
  242. package/dist/docs/registry/members-ui-foldkit.md +28 -0
  243. package/dist/docs/registry/mobile.md +37 -0
  244. package/dist/docs/registry/notes-ui-foldkit.md +27 -0
  245. package/dist/docs/registry/notes.md +26 -0
  246. package/dist/docs/registry/people-ui-foldkit.md +28 -0
  247. package/dist/docs/registry/people.md +38 -0
  248. package/dist/docs/registry/shell-foldkit.md +35 -0
  249. package/dist/docs/registry/theme.md +25 -0
  250. package/dist/docs/registry/ui-conformance.md +30 -0
  251. package/dist/docs/release.md +100 -0
  252. package/dist/docs/scaffold.md +826 -0
  253. package/dist/docs/security/threat-model.md +299 -0
  254. package/dist/docs/upstream/zero-cache-socket-handoff.md +105 -0
  255. package/dist/index.d.ts +8 -0
  256. package/dist/index.d.ts.map +1 -0
  257. package/dist/index.js +8 -0
  258. package/dist/index.js.map +1 -0
  259. package/package.json +48 -3
  260. package/src/AgentSkills.ts +329 -0
  261. package/src/AgentWeb.ts +507 -0
  262. package/src/App.ts +435 -0
  263. package/src/Blueprint.ts +276 -0
  264. package/src/Brand.ts +415 -0
  265. package/src/Changelog.ts +136 -0
  266. package/src/Cli.ts +1458 -0
  267. package/src/DbAdmin.ts +115 -0
  268. package/src/Dependencies.ts +170 -0
  269. package/src/Deploy.ts +563 -0
  270. package/src/Docs.ts +309 -0
  271. package/src/Doctor.ts +424 -0
  272. package/src/Dossier.ts +148 -0
  273. package/src/Emit.ts +68 -0
  274. package/src/Errors.ts +18 -0
  275. package/src/Evals.ts +153 -0
  276. package/src/Files.ts +152 -0
  277. package/src/Generate.ts +402 -0
  278. package/src/Guards.ts +541 -0
  279. package/src/Inspect.ts +358 -0
  280. package/src/Keychain.ts +107 -0
  281. package/src/Lock.ts +174 -0
  282. package/src/Mcp.ts +159 -0
  283. package/src/Merge.ts +70 -0
  284. package/src/Migrate.ts +331 -0
  285. package/src/Plugins.ts +347 -0
  286. package/src/Postgres.ts +353 -0
  287. package/src/Publish.ts +64 -0
  288. package/src/Registry.ts +405 -0
  289. package/src/Remote.ts +1158 -0
  290. package/src/Run.ts +541 -0
  291. package/src/SyncGen.ts +570 -0
  292. package/src/Update.ts +873 -0
  293. package/src/bin.ts +46 -0
  294. package/src/index.ts +7 -0
@@ -0,0 +1,105 @@
1
+ # Upstream issue (draft): zero-cache loses a client's first messages in the WebSocket handoff
2
+
3
+ Text for an issue on [rocicorp/mono](https://github.com/rocicorp/mono) (Zero's repository). **Filing approved**
4
+ (owner decision, 2026-11-16: keep the maintained patch and file upstream). The text filed is a revised draft,
5
+ checked against zero 1.12.0 and the 1.13 head build (both still have the bug), with a companion issue for backlog 33.
6
+ The coordinator posts both after review. Eloxiv's side: backlog 23, the patch
7
+ [`registry/app/patches/@rocicorp__zero@1.11.3.patch`](../../registry/app/patches/@rocicorp__zero@1.11.3.patch)
8
+ (which this repository and every app assembled from the registry apply), and the tests
9
+ [`packages/testing/test/zero-handoff.test.ts`](../../packages/testing/test/zero-handoff.test.ts) and
10
+ [`packages/testing/test/optimistic.test.ts`](../../packages/testing/test/optimistic.test.ts) ("queues writes while
11
+ offline").
12
+
13
+ ---
14
+
15
+ **Title:** zero-cache drops bytes a client sends while its WebSocket is handed to another process (pending pushes lost on reconnect)
16
+
17
+ **Version:** `@rocicorp/zero` 1.11.3, zero-cache run from its CLI (several processes, the default), Node 24.22.2,
18
+ Linux. The code involved is unchanged on `main` as of 2026-11-10.
19
+
20
+ **What happens.** A client that reconnects with pending mutations pushes them as soon as it is `connected`. Now and
21
+ then zero-cache never receives those pushes: the client shows them as sent, zero-cache's later messages and pings on
22
+ the same connection arrive, and the mutations stay unconfirmed until the client happens to reconnect again (which,
23
+ with zero-cache's keepalive pongs answering the client's pings, can be never). We saw it in about 7 of 104 runs of an
24
+ offline-then-reconnect test under CPU contention: the test's TCP relay had forwarded the client's pushes (658 bytes,
25
+ 3 ms after `connected`) and zero-cache's push handler never saw them.
26
+
27
+ **Cause.** `createWebSocketHandoffHandler` (`zero-cache/src/types/websocket-handoff.ts`) hands the upgraded socket to
28
+ another process with `sender.send(data, socket)`. Node's `child_process` sends the socket's handle and, until the
29
+ receiving process acknowledges it (`NODE_HANDLE_ACK`), keeps the handle open in the sending process with a no-op
30
+ `onread` (`lib/internal/child_process.js`, `handleConversion['net.Socket'].send`: `handle.onread = nop`, closed in
31
+ `postSend` only once acknowledged). The handle is still reading. Bytes the client sends in that window are read by the
32
+ sending process and discarded. A process that receives a handed-off socket also starts reading it at once (a
33
+ `net.Socket` made from a handle calls `read(0)`), so each hop of a handoff has this window. The receiver is only slow
34
+ to acknowledge under load, which is why it is intermittent.
35
+
36
+ **Reproduction (Node only, deterministic).** The parent hands each accepted socket to a child that is busy for
37
+ 500 ms (so the acknowledgement is late); the client sends 100 ms after connecting.
38
+
39
+ ```js
40
+ // handoff.mjs: node handoff.mjs -> the child got ""
41
+ // node handoff.mjs readStop -> the child got the bytes
42
+ import { fork } from "node:child_process"
43
+ import { connect, createServer } from "node:net"
44
+
45
+ if (process.argv[2] === "child") {
46
+ const until = Date.now() + 500
47
+ while (Date.now() < until) {} // busy: the handle (and its acknowledgement) wait
48
+ process.on("message", (_message, socket) => {
49
+ let got = ""
50
+ socket.on("data", (d) => (got += d))
51
+ setTimeout(() => process.send(got.includes("hello") ? "the child got the bytes" : `the child got ${JSON.stringify(got)}`), 500)
52
+ })
53
+ } else {
54
+ const readStop = process.argv[2] === "readStop"
55
+ const child = fork(new URL(import.meta.url).pathname, ["child"])
56
+ const server = createServer((socket) => {
57
+ if (readStop) socket._handle?.readStop?.()
58
+ child.send("socket", socket)
59
+ })
60
+ server.listen(0, "127.0.0.1", () => {
61
+ const client = connect(server.address().port, "127.0.0.1", () => setTimeout(() => client.write("hello\n"), 100))
62
+ })
63
+ child.on("message", (m) => {
64
+ console.log(m)
65
+ child.kill()
66
+ process.exit(0)
67
+ })
68
+ }
69
+ ```
70
+
71
+ With zero-cache itself: connect a client, take its network away, make a mutation, give the network back while
72
+ zero-cache's processes are loaded (we pinned the test and zero-cache to two cores shared with two busy loops); the
73
+ mutation is sometimes never confirmed.
74
+
75
+ **Fix.** Stop reading in the sending process before the handle is sent; the bytes stay in the kernel's socket buffer
76
+ and the receiving process reads them. Only when the socket really goes to another process: in `SINGLE_PROCESS` mode
77
+ the in-process channel passes the same socket object to the receiver, which goes on reading it, and stopping the
78
+ handle under it (`readStop` leaves the socket's JS `reading` flag set, so nothing starts it again) means its first
79
+ message never arrives. A sender to another process has an IPC `channel`; the in-process channel does not.
80
+
81
+ ```diff
82
+ --- a/out/zero-cache/src/types/websocket-handoff.js
83
+ +++ b/out/zero-cache/src/types/websocket-handoff.js
84
+ @@ -22,6 +22,10 @@ function createWebSocketHandoffHandler(lc, handoff, serverOptions) {
85
+ head,
86
+ payload
87
+ }];
88
+ + // Stop reading in this process before the socket goes to another one: Node keeps the sent handle reading
89
+ + // with a no-op onread until the receiver acknowledges it, discarding what it reads. In one process
90
+ + // (SINGLE_PROCESS) the receiver goes on reading this same socket: nothing to stop.
91
+ + if (sender.channel) socket._handle?.readStop?.();
92
+ sender.send(data, socket);
93
+ }
94
+ ```
95
+
96
+ (In the TypeScript source, the same line before `sender.send(data, socket)` in `websocket-handoff.ts`.) With it, the
97
+ offline-then-reconnect test passed 59 of 59 contended runs and then 30 of 30 (before: 7 failures in about 104), and a
98
+ client's first messages arrive in both modes.
99
+
100
+ **Related, client side.** Zero's client re-sends every pending mutation on each new connection (`#lastMutationIDsSent`
101
+ is cleared on connect and disconnect), so a push lost with a broken connection is recovered. A connection on which the
102
+ server stops reading but which stays open is not: zero-cache sends `pong` unasked as a keepalive (`#maybeSendPong`)
103
+ and the client takes any `pong` as the answer to its `ping`, so the connection looks alive while its pushes go
104
+ nowhere. Matching a `pong` to the `ping` it answers (or a push timeout that reconnects) would let the client recover
105
+ from server-side losses like this one.
@@ -0,0 +1,8 @@
1
+ export * from "./Cli.ts";
2
+ export * from "./Generate.ts";
3
+ export * from "./Merge.ts";
4
+ export * from "./Publish.ts";
5
+ export * from "./Registry.ts";
6
+ export * from "./SyncGen.ts";
7
+ export * from "./Update.ts";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ export * from "./Cli.js";
2
+ export * from "./Generate.js";
3
+ export * from "./Merge.js";
4
+ export * from "./Publish.js";
5
+ export * from "./Registry.js";
6
+ export * from "./SyncGen.js";
7
+ export * from "./Update.js";
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
2
  "name": "@eloxiv/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "description": "The eloxiv command-line tool",
5
+ "homepage": "https://github.com/eloxiv/eloxiv/tree/main/packages/cli#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/eloxiv/eloxiv/issues"
8
+ },
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/eloxiv/eloxiv.git",
13
+ "directory": "packages/cli"
14
+ },
15
+ "bin": {
16
+ "eloxiv": "./dist/bin.js"
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "src"
21
+ ],
22
+ "type": "module",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "default": "./dist/index.js"
27
+ }
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "dependencies": {
33
+ "@babel/parser": "7.29.12",
34
+ "@effect/platform-bun": "4.1.2",
35
+ "@effect/platform-node": "4.1.2",
36
+ "@eloxiv/contracts": "^0.1.1",
37
+ "@eloxiv/registry": "^0.1.1",
38
+ "@napi-rs/keyring": "2.1.2",
39
+ "@rocicorp/zero": "1.11.3",
40
+ "diff": "9.0.0",
41
+ "drizzle-orm": "0.45.4",
42
+ "drizzle-zero": "0.21.0",
43
+ "effect": "4.1.2",
44
+ "node-diff3": "3.2.1"
45
+ },
46
+ "scripts": {
47
+ "build": "tsc -p tsconfig.build.json && node scripts/copy-docs.ts",
48
+ "typecheck": "tsc -p tsconfig.json --noEmit",
49
+ "test": "vitest run"
50
+ }
6
51
  }
@@ -0,0 +1,329 @@
1
+ /**
2
+ * The app's skills for the coding agents that build it (docs/cli.md, "skills"):
3
+ *
4
+ * eloxiv skills link [--host ...] write each of the app's skills (`skills/<name>/`) into the hosts' project skill
5
+ * directories, as the hosts load them (a SKILL.md with name and description)
6
+ * eloxiv skills unlink [--host ...] remove what link wrote, and nothing else
7
+ * eloxiv skills ensure [--mcp] check every skill is linked and current (and, with --mcp, that the hosts list
8
+ * the app's MCP server, so a skill that works through the app can reach it);
9
+ * exits 1 when anything is missing or stale, `--fix` links again
10
+ *
11
+ * `link --mcp` also lists the app's kernel as an MCP server in the hosts that take one (`eloxiv mcp install`): no
12
+ * credential is written; the host signs the person in through the kernel's OAuth. The app itself runs with
13
+ * `eloxiv dev`.
14
+ *
15
+ * A registry skill item (or one `eloxiv plugin import` brought in) keeps its document in `skills/<name>/SKILL.md`;
16
+ * coding agents (Claude Code, Codex) load skills from their own directories, each a `SKILL.md` that starts with YAML
17
+ * frontmatter. Linking writes that form, generated and marked, so the app's directory stays the one to edit and a
18
+ * later link refreshes it. A host skill without the mark is the person's own: it is never overwritten or removed.
19
+ */
20
+ import { mcpServerName } from "@eloxiv/contracts"
21
+ import { Command, Flag } from "effect/cli"
22
+ import { Console, Effect, FileSystem, Option, Path } from "effect"
23
+ import { readConfig } from "./App.ts"
24
+ import { CliError } from "./Errors.ts"
25
+ import { writablePath, writeAppFile } from "./Files.ts"
26
+ import { installMcp, MCP_HOST_NAMES, mcpStatus, type McpHost } from "./Mcp.ts"
27
+
28
+ /** Where each coding agent loads a project's skills from. */
29
+ export const SKILL_HOSTS = { claude: ".claude/skills", codex: ".agents/skills" } as const
30
+ export type SkillHost = keyof typeof SKILL_HOSTS
31
+ export const SKILL_HOST_NAMES = Object.keys(SKILL_HOSTS) as ReadonlyArray<SkillHost>
32
+
33
+ const markerOf = (name: string) =>
34
+ `<!-- Generated by eloxiv skills link from skills/${name}/SKILL.md: edit that, not this. -->`
35
+ const MARKER = /^<!-- Generated by eloxiv skills link from skills\//mu
36
+
37
+ export interface AppSkillDocument {
38
+ readonly name: string
39
+ readonly description: string
40
+ readonly document: string
41
+ /** The skill's other documents (Markdown and text beside SKILL.md), by path relative to its directory. */
42
+ readonly references: Readonly<Record<string, string>>
43
+ }
44
+
45
+ /** What a skill's directory holds for a coding agent besides SKILL.md: its Markdown and text references. */
46
+ const REFERENCE = /\.(md|txt)$/iu
47
+
48
+ /** The skill's description: its `skill.ts` (`defineAppSkill({ description: "..." })`), else its document's first paragraph. */
49
+ const descriptionOf = (source: string | undefined, document: string) => {
50
+ const declared = source === undefined ? null : /description:\s*("(?:[^"\\]|\\.)*")/u.exec(source)
51
+ if (declared !== null) {
52
+ try {
53
+ return JSON.parse(declared[1]!) as string
54
+ } catch {
55
+ // The document's first paragraph, below.
56
+ }
57
+ }
58
+ const paragraph = document
59
+ .split(/\n\s*\n/u)
60
+ .map((p) => p.trim())
61
+ .find((p) => p !== "" && !p.startsWith("#"))
62
+ return (paragraph ?? "").replace(/\s+/gu, " ").slice(0, 300)
63
+ }
64
+
65
+ /** The app's skills: every `skills/<name>/SKILL.md`. */
66
+ export const appSkillDocuments = (dir: string) =>
67
+ Effect.gen(function* () {
68
+ const fs = yield* FileSystem.FileSystem
69
+ const path = yield* Path.Path
70
+ const root = path.join(dir, "skills")
71
+ if (!(yield* fs.exists(root))) return []
72
+ const skills: Array<AppSkillDocument> = []
73
+ for (const name of (yield* fs.readDirectory(root)).sort()) {
74
+ const file = path.join(root, name, "SKILL.md")
75
+ if (!(yield* fs.exists(file))) continue
76
+ const document = yield* fs.readFileString(file)
77
+ const sourceFile = path.join(root, name, "skill.ts")
78
+ const source = (yield* fs.exists(sourceFile)) ? yield* fs.readFileString(sourceFile) : undefined
79
+ const references: Record<string, string> = {}
80
+ for (const entry of (yield* fs.readDirectory(path.join(root, name), { recursive: true })).sort()) {
81
+ const relative = entry.split("\\").join("/")
82
+ if (
83
+ relative === "SKILL.md" ||
84
+ !REFERENCE.test(relative) ||
85
+ relative.split("/").some((p) => p.startsWith("."))
86
+ ) {
87
+ continue
88
+ }
89
+ const info = yield* fs.stat(path.join(root, name, entry))
90
+ if (info.type === "File") references[relative] = yield* fs.readFileString(path.join(root, name, entry))
91
+ }
92
+ skills.push({
93
+ name,
94
+ description: descriptionOf(source, document),
95
+ document: stripFrontmatter(document),
96
+ references,
97
+ })
98
+ }
99
+ return skills
100
+ })
101
+
102
+ /** A document without its YAML frontmatter, if it has one. */
103
+ export const stripFrontmatter = (document: string) => document.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/u, "")
104
+
105
+ const hostDocument = (skill: AppSkillDocument) =>
106
+ `---\nname: ${skill.name}\ndescription: ${JSON.stringify(skill.description)}\n---\n${markerOf(skill.name)}\n\n${skill.document.trimStart()}`
107
+
108
+ export interface LinkReport {
109
+ readonly written: ReadonlyArray<string>
110
+ readonly removed: ReadonlyArray<string>
111
+ /** Host skills of the same name that link did not write: left as they are. */
112
+ readonly kept: ReadonlyArray<string>
113
+ }
114
+
115
+ const isGenerated = (dir: string, relative: string) =>
116
+ Effect.gen(function* () {
117
+ const fs = yield* FileSystem.FileSystem
118
+ const path = yield* Path.Path
119
+ const file = path.join(dir, relative, "SKILL.md")
120
+ if (!(yield* fs.exists(file))) return false
121
+ return MARKER.test(yield* fs.readFileString(file))
122
+ })
123
+
124
+ /** Write the app's skills into each host's directory, and remove generated ones whose skill is gone. */
125
+ export const linkSkills = (dir: string, hosts: ReadonlyArray<SkillHost>) =>
126
+ Effect.gen(function* () {
127
+ const fs = yield* FileSystem.FileSystem
128
+ const path = yield* Path.Path
129
+ const skills = yield* appSkillDocuments(dir)
130
+ const written: Array<string> = []
131
+ const removed: Array<string> = []
132
+ const kept: Array<string> = []
133
+ for (const host of hosts) {
134
+ const base = SKILL_HOSTS[host]
135
+ for (const skill of skills) {
136
+ const relative = `${base}/${skill.name}`
137
+ if ((yield* fs.exists(path.join(dir, relative))) && !(yield* isGenerated(dir, relative))) {
138
+ kept.push(relative)
139
+ continue
140
+ }
141
+ yield* writeAppFile(dir, `${relative}/SKILL.md`, hostDocument(skill))
142
+ // Its references beside it, so the document's relative links resolve in the host too.
143
+ for (const [file, content] of Object.entries(skill.references)) {
144
+ yield* writeAppFile(dir, `${relative}/${file}`, content)
145
+ }
146
+ written.push(relative)
147
+ }
148
+ // Generated copies of skills the app no longer has.
149
+ const hostRoot = path.join(dir, base)
150
+ if (!(yield* fs.exists(hostRoot))) continue
151
+ for (const name of yield* fs.readDirectory(hostRoot)) {
152
+ const relative = `${base}/${name}`
153
+ if (skills.some((s) => s.name === name) || !(yield* isGenerated(dir, relative))) continue
154
+ yield* fs.remove(yield* writablePath(dir, relative), { recursive: true })
155
+ removed.push(relative)
156
+ }
157
+ }
158
+ return { written, removed, kept } satisfies LinkReport
159
+ })
160
+
161
+ /** Remove every skill link wrote from the hosts' directories; anything else stays. */
162
+ export const unlinkSkills = (dir: string, hosts: ReadonlyArray<SkillHost>) =>
163
+ Effect.gen(function* () {
164
+ const fs = yield* FileSystem.FileSystem
165
+ const path = yield* Path.Path
166
+ const removed: Array<string> = []
167
+ for (const host of hosts) {
168
+ const hostRoot = path.join(dir, SKILL_HOSTS[host])
169
+ if (!(yield* fs.exists(hostRoot))) continue
170
+ for (const name of yield* fs.readDirectory(hostRoot)) {
171
+ const relative = `${SKILL_HOSTS[host]}/${name}`
172
+ if (!(yield* isGenerated(dir, relative))) continue
173
+ yield* fs.remove(yield* writablePath(dir, relative), { recursive: true })
174
+ removed.push(relative)
175
+ }
176
+ }
177
+ return removed
178
+ })
179
+
180
+ export interface EnsureReport {
181
+ /** Skills linked and current in every host. */
182
+ readonly current: ReadonlyArray<string>
183
+ /** Host copies missing, out of date, or kept (the person's own of the same name). */
184
+ readonly problems: ReadonlyArray<string>
185
+ }
186
+
187
+ /** The app's MCP server name (`eloxiv mcp`'s default): its name in eloxiv.json. */
188
+ const serverNameOf = (dir: string) =>
189
+ readConfig(dir).pipe(
190
+ Effect.map(({ config }) => mcpServerName(config.name)),
191
+ Effect.orElseSucceed(() => "eloxiv"),
192
+ )
193
+
194
+ /** The skill hosts that also take an MCP server (Codex's project configuration is not one the CLI writes). */
195
+ const mcpHostsOf = (hosts: ReadonlyArray<SkillHost>): ReadonlyArray<McpHost> =>
196
+ hosts.flatMap((h) => ((MCP_HOST_NAMES as ReadonlyArray<string>).includes(h) ? [h as McpHost] : []))
197
+
198
+ /** Whether every skill is linked and current in every host, and (with `mcp`) the app's MCP server is listed. */
199
+ export const ensureSkills = (dir: string, hosts: ReadonlyArray<SkillHost>, options: { readonly mcp: boolean }) =>
200
+ Effect.gen(function* () {
201
+ const fs = yield* FileSystem.FileSystem
202
+ const path = yield* Path.Path
203
+ const current: Array<string> = []
204
+ const problems: Array<string> = []
205
+ for (const skill of yield* appSkillDocuments(dir)) {
206
+ let ok = true
207
+ for (const host of hosts) {
208
+ const relative = `${SKILL_HOSTS[host]}/${skill.name}/SKILL.md`
209
+ const file = path.join(dir, relative)
210
+ if (!(yield* fs.exists(file))) {
211
+ problems.push(`${relative}: missing (run eloxiv skills link)`)
212
+ ok = false
213
+ } else if (!(yield* isGenerated(dir, `${SKILL_HOSTS[host]}/${skill.name}`))) {
214
+ problems.push(`${relative}: the person's own skill of that name, not the app's`)
215
+ ok = false
216
+ } else if ((yield* fs.readFileString(file)) !== hostDocument(skill)) {
217
+ problems.push(`${relative}: out of date (run eloxiv skills link)`)
218
+ ok = false
219
+ } else {
220
+ for (const [reference, content] of Object.entries(skill.references)) {
221
+ const copy = path.join(dir, SKILL_HOSTS[host], skill.name, reference)
222
+ if (!(yield* fs.exists(copy)) || (yield* fs.readFileString(copy)) !== content) {
223
+ problems.push(
224
+ `${SKILL_HOSTS[host]}/${skill.name}/${reference}: missing or out of date (run eloxiv skills link)`,
225
+ )
226
+ ok = false
227
+ }
228
+ }
229
+ }
230
+ }
231
+ if (ok) current.push(skill.name)
232
+ }
233
+ if (options.mcp) {
234
+ const status = yield* mcpStatus(dir, { url: undefined, name: yield* serverNameOf(dir) })
235
+ for (const host of mcpHostsOf(hosts)) {
236
+ if (status.hosts.find((h) => h.host === host)?.url == null) {
237
+ problems.push(`${host}: the app's MCP server is not listed (run eloxiv skills link --mcp)`)
238
+ }
239
+ }
240
+ }
241
+ return { current, problems } satisfies EnsureReport
242
+ })
243
+
244
+ export const parseSkillHosts = (value: Option.Option<string>) => {
245
+ if (Option.isNone(value)) return Effect.succeed(SKILL_HOST_NAMES)
246
+ const hosts = value.value.split(",").map((h) => h.trim())
247
+ const unknown = hosts.filter((h) => !(SKILL_HOST_NAMES as ReadonlyArray<string>).includes(h))
248
+ return unknown.length > 0
249
+ ? Effect.fail(
250
+ new CliError({ message: `Unknown host ${unknown.join(", ")} (hosts: ${SKILL_HOST_NAMES.join(", ")})` }),
251
+ )
252
+ : Effect.succeed(hosts as ReadonlyArray<SkillHost>)
253
+ }
254
+
255
+ const cwd = Flag.String("cwd").pipe(Flag.withDescription("The app's directory (default: here)"), Flag.optional)
256
+ const host = Flag.String("host").pipe(
257
+ Flag.withDescription(`Hosts, comma-separated (default: ${SKILL_HOST_NAMES.join(", ")})`),
258
+ Flag.optional,
259
+ )
260
+ const mcp = Flag.Boolean("mcp").pipe(
261
+ Flag.withDescription("Also the app's kernel as an MCP server in the hosts that take one (no credential written)"),
262
+ Flag.withDefault(false),
263
+ )
264
+ const fix = Flag.Boolean("fix").pipe(Flag.withDescription("Link again before checking"), Flag.withDefault(false))
265
+ const url = Flag.String("url").pipe(Flag.withDescription("The kernel's URL (default: ELOXIV_URL)"), Flag.optional)
266
+ const dirOf = (value: Option.Option<string>) =>
267
+ Effect.gen(function* () {
268
+ const path = yield* Path.Path
269
+ return path.resolve(Option.getOrElse(value, () => process.cwd()))
270
+ })
271
+
272
+ export const skillsCommand = Command.make("skills").pipe(
273
+ Command.withDescription("The app's skills for the coding agents that build it (Claude Code, Codex)"),
274
+ Command.withSubcommands([
275
+ Command.make(
276
+ "link",
277
+ { cwd, host, mcp, url },
278
+ Effect.fn(function* ({ cwd, host, mcp, url }) {
279
+ const dir = yield* dirOf(cwd)
280
+ const hosts = yield* parseSkillHosts(host)
281
+ const report = yield* linkSkills(dir, hosts)
282
+ if (mcp) {
283
+ yield* installMcp(dir, {
284
+ url: Option.getOrUndefined(url),
285
+ hosts: mcpHostsOf(hosts),
286
+ name: yield* serverNameOf(dir),
287
+ })
288
+ }
289
+ for (const relative of report.written) yield* Console.log(`wrote ${relative}`)
290
+ for (const relative of report.removed) yield* Console.log(`removed ${relative} (its skill is gone)`)
291
+ for (const relative of report.kept) yield* Console.log(`kept ${relative}: not written by eloxiv, left as it is`)
292
+ }),
293
+ ).pipe(
294
+ Command.withDescription(
295
+ "Write the app's skills into the hosts' project skill directories (--mcp: and list the app's MCP server)",
296
+ ),
297
+ ),
298
+ Command.make(
299
+ "ensure",
300
+ { cwd, host, mcp, fix },
301
+ Effect.fn(function* ({ cwd, host, mcp, fix }) {
302
+ const dir = yield* dirOf(cwd)
303
+ const hosts = yield* parseSkillHosts(host)
304
+ if (fix) {
305
+ yield* linkSkills(dir, hosts)
306
+ if (mcp) yield* installMcp(dir, { url: undefined, hosts: mcpHostsOf(hosts), name: yield* serverNameOf(dir) })
307
+ }
308
+ const report = yield* ensureSkills(dir, hosts, { mcp })
309
+ for (const name of report.current) yield* Console.log(`ok ${name}`)
310
+ for (const problem of report.problems) yield* Console.log(`missing ${problem}`)
311
+ if (report.problems.length > 0) {
312
+ return yield* new CliError({ message: `${report.problems.length} skill link(s) need attention` })
313
+ }
314
+ }),
315
+ ).pipe(
316
+ Command.withDescription(
317
+ "Check every skill is linked and current in the hosts (--mcp: and the app's MCP server listed); --fix links again",
318
+ ),
319
+ ),
320
+ Command.make(
321
+ "unlink",
322
+ { cwd, host },
323
+ Effect.fn(function* ({ cwd, host }) {
324
+ const removed = yield* unlinkSkills(yield* dirOf(cwd), yield* parseSkillHosts(host))
325
+ for (const relative of removed) yield* Console.log(`removed ${relative}`)
326
+ }),
327
+ ).pipe(Command.withDescription("Remove the skills link wrote; anything else in those directories stays")),
328
+ ]),
329
+ )