oneie 3.8.3 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (377) hide show
  1. package/LICENSE +86 -0
  2. package/README.md +63 -952
  3. package/dist/package.json +38 -0
  4. package/dist/src/agent.d.ts +2 -0
  5. package/dist/src/agent.js +888 -0
  6. package/dist/src/args.d.ts +9 -0
  7. package/dist/src/args.js +61 -0
  8. package/dist/src/auth.d.ts +6 -0
  9. package/dist/src/auth.js +122 -0
  10. package/dist/src/broadcast.d.ts +6 -0
  11. package/dist/src/broadcast.js +150 -0
  12. package/dist/src/catalog.d.ts +2 -0
  13. package/dist/src/catalog.js +78 -0
  14. package/dist/src/chat.d.ts +2 -0
  15. package/dist/src/chat.js +92 -0
  16. package/dist/src/client.d.ts +5 -0
  17. package/dist/src/client.js +151 -0
  18. package/dist/src/compiler.d.ts +36 -0
  19. package/dist/src/compiler.js +314 -0
  20. package/dist/src/config.d.ts +24 -0
  21. package/dist/src/config.js +70 -0
  22. package/dist/src/connect.d.ts +2 -0
  23. package/dist/src/connect.js +64 -0
  24. package/dist/src/coordinate.d.ts +3 -0
  25. package/dist/src/coordinate.js +58 -0
  26. package/dist/src/create.d.ts +2 -0
  27. package/dist/src/create.js +106 -0
  28. package/dist/src/deploy.d.ts +2 -0
  29. package/dist/src/deploy.js +19 -0
  30. package/dist/src/dev.d.ts +2 -0
  31. package/dist/src/dev.js +75 -0
  32. package/dist/src/device-flow.d.ts +57 -0
  33. package/dist/src/device-flow.js +173 -0
  34. package/dist/src/doctor.d.ts +26 -0
  35. package/dist/src/doctor.js +91 -0
  36. package/dist/src/env.d.ts +3 -0
  37. package/dist/src/env.js +37 -0
  38. package/dist/src/eval.d.ts +2 -0
  39. package/dist/src/eval.js +42 -0
  40. package/dist/src/fn.d.ts +2 -0
  41. package/dist/src/fn.js +73 -0
  42. package/dist/src/group.d.ts +2 -0
  43. package/dist/src/group.js +115 -0
  44. package/dist/src/index.d.ts +2 -0
  45. package/dist/src/index.js +101 -0
  46. package/dist/src/init.d.ts +11 -0
  47. package/dist/src/init.js +121 -0
  48. package/dist/src/lib/agent-env.d.ts +5 -0
  49. package/dist/src/lib/agent-env.js +25 -0
  50. package/dist/src/lib/api-path.d.ts +1 -0
  51. package/dist/src/lib/api-path.js +9 -0
  52. package/dist/src/lib/client.d.ts +16 -0
  53. package/dist/src/lib/client.js +57 -0
  54. package/dist/src/links.d.ts +5 -0
  55. package/dist/src/links.js +44 -0
  56. package/dist/src/onboard.d.ts +16 -0
  57. package/dist/src/onboard.js +146 -0
  58. package/dist/src/plugin.d.ts +2 -0
  59. package/dist/src/plugin.js +184 -0
  60. package/dist/src/push.d.ts +2 -0
  61. package/dist/src/push.js +114 -0
  62. package/dist/src/render.d.ts +20 -0
  63. package/dist/src/render.js +32 -0
  64. package/dist/src/setup.d.ts +6 -0
  65. package/dist/src/setup.js +118 -0
  66. package/dist/src/ship.d.ts +2 -0
  67. package/dist/src/ship.js +18 -0
  68. package/dist/src/skill-parser.d.ts +14 -0
  69. package/dist/src/skill-parser.js +113 -0
  70. package/dist/src/skill.d.ts +2 -0
  71. package/dist/src/skill.js +377 -0
  72. package/dist/src/slug.d.ts +2 -0
  73. package/dist/src/slug.js +6 -0
  74. package/dist/src/social.d.ts +2 -0
  75. package/dist/src/social.js +87 -0
  76. package/dist/src/staff.d.ts +2 -0
  77. package/dist/src/staff.js +93 -0
  78. package/dist/src/status.d.ts +2 -0
  79. package/dist/src/status.js +38 -0
  80. package/dist/src/substrate.d.ts +2 -0
  81. package/dist/src/substrate.js +243 -0
  82. package/dist/src/templates.d.ts +1 -0
  83. package/dist/src/templates.js +205 -0
  84. package/dist/src/trade.d.ts +2 -0
  85. package/dist/src/trade.js +95 -0
  86. package/dist/src/trail.d.ts +2 -0
  87. package/dist/src/trail.js +41 -0
  88. package/dist/src/validate.d.ts +13 -0
  89. package/dist/src/validate.js +35 -0
  90. package/dist/src/wallet.d.ts +9 -0
  91. package/dist/src/wallet.js +209 -0
  92. package/package.json +26 -54
  93. package/LICENSE.md +0 -89
  94. package/dist/admin/build.d.ts +0 -15
  95. package/dist/admin/build.d.ts.map +0 -1
  96. package/dist/admin/build.js +0 -295
  97. package/dist/admin/build.js.map +0 -1
  98. package/dist/admin/index.d.ts +0 -24
  99. package/dist/admin/index.d.ts.map +0 -1
  100. package/dist/admin/index.js +0 -98
  101. package/dist/admin/index.js.map +0 -1
  102. package/dist/admin/list.d.ts +0 -14
  103. package/dist/admin/list.d.ts.map +0 -1
  104. package/dist/admin/list.js +0 -90
  105. package/dist/admin/list.js.map +0 -1
  106. package/dist/admin/manifest.d.ts +0 -86
  107. package/dist/admin/manifest.d.ts.map +0 -1
  108. package/dist/admin/manifest.js +0 -183
  109. package/dist/admin/manifest.js.map +0 -1
  110. package/dist/admin/monorepo.d.ts +0 -25
  111. package/dist/admin/monorepo.d.ts.map +0 -1
  112. package/dist/admin/monorepo.js +0 -59
  113. package/dist/admin/monorepo.js.map +0 -1
  114. package/dist/admin/release.d.ts +0 -17
  115. package/dist/admin/release.d.ts.map +0 -1
  116. package/dist/admin/release.js +0 -144
  117. package/dist/admin/release.js.map +0 -1
  118. package/dist/admin/sync.d.ts +0 -14
  119. package/dist/admin/sync.d.ts.map +0 -1
  120. package/dist/admin/sync.js +0 -104
  121. package/dist/admin/sync.js.map +0 -1
  122. package/dist/admin/validate.d.ts +0 -15
  123. package/dist/admin/validate.d.ts.map +0 -1
  124. package/dist/admin/validate.js +0 -169
  125. package/dist/admin/validate.js.map +0 -1
  126. package/dist/banner.d.ts +0 -2
  127. package/dist/banner.d.ts.map +0 -1
  128. package/dist/banner.js +0 -15
  129. package/dist/banner.js.map +0 -1
  130. package/dist/clone-docs.d.ts +0 -17
  131. package/dist/clone-docs.d.ts.map +0 -1
  132. package/dist/clone-docs.js +0 -62
  133. package/dist/clone-docs.js.map +0 -1
  134. package/dist/clone-web.d.ts +0 -12
  135. package/dist/clone-web.d.ts.map +0 -1
  136. package/dist/clone-web.js +0 -50
  137. package/dist/clone-web.js.map +0 -1
  138. package/dist/commands/agent.d.ts +0 -20
  139. package/dist/commands/agent.d.ts.map +0 -1
  140. package/dist/commands/agent.js +0 -315
  141. package/dist/commands/agent.js.map +0 -1
  142. package/dist/commands/ask.d.ts +0 -4
  143. package/dist/commands/ask.d.ts.map +0 -1
  144. package/dist/commands/ask.js +0 -8
  145. package/dist/commands/ask.js.map +0 -1
  146. package/dist/commands/bounty.d.ts +0 -4
  147. package/dist/commands/bounty.d.ts.map +0 -1
  148. package/dist/commands/bounty.js +0 -24
  149. package/dist/commands/bounty.js.map +0 -1
  150. package/dist/commands/buy.d.ts +0 -19
  151. package/dist/commands/buy.d.ts.map +0 -1
  152. package/dist/commands/buy.js +0 -63
  153. package/dist/commands/buy.js.map +0 -1
  154. package/dist/commands/capabilities.d.ts +0 -4
  155. package/dist/commands/capabilities.d.ts.map +0 -1
  156. package/dist/commands/capabilities.js +0 -18
  157. package/dist/commands/capabilities.js.map +0 -1
  158. package/dist/commands/claw.d.ts +0 -4
  159. package/dist/commands/claw.d.ts.map +0 -1
  160. package/dist/commands/claw.js +0 -14
  161. package/dist/commands/claw.js.map +0 -1
  162. package/dist/commands/commend.d.ts +0 -4
  163. package/dist/commands/commend.d.ts.map +0 -1
  164. package/dist/commands/commend.js +0 -13
  165. package/dist/commands/commend.js.map +0 -1
  166. package/dist/commands/completion.d.ts +0 -4
  167. package/dist/commands/completion.d.ts.map +0 -1
  168. package/dist/commands/completion.js +0 -49
  169. package/dist/commands/completion.js.map +0 -1
  170. package/dist/commands/config.d.ts +0 -4
  171. package/dist/commands/config.d.ts.map +0 -1
  172. package/dist/commands/config.js +0 -78
  173. package/dist/commands/config.js.map +0 -1
  174. package/dist/commands/deploy.d.ts +0 -4
  175. package/dist/commands/deploy.d.ts.map +0 -1
  176. package/dist/commands/deploy.js +0 -45
  177. package/dist/commands/deploy.js.map +0 -1
  178. package/dist/commands/doctor.d.ts +0 -4
  179. package/dist/commands/doctor.d.ts.map +0 -1
  180. package/dist/commands/doctor.js +0 -72
  181. package/dist/commands/doctor.js.map +0 -1
  182. package/dist/commands/domain.d.ts +0 -4
  183. package/dist/commands/domain.d.ts.map +0 -1
  184. package/dist/commands/domain.js +0 -19
  185. package/dist/commands/domain.js.map +0 -1
  186. package/dist/commands/export.d.ts +0 -4
  187. package/dist/commands/export.d.ts.map +0 -1
  188. package/dist/commands/export.js +0 -15
  189. package/dist/commands/export.js.map +0 -1
  190. package/dist/commands/fade.d.ts +0 -4
  191. package/dist/commands/fade.d.ts.map +0 -1
  192. package/dist/commands/fade.js +0 -15
  193. package/dist/commands/fade.js.map +0 -1
  194. package/dist/commands/flag.d.ts +0 -4
  195. package/dist/commands/flag.d.ts.map +0 -1
  196. package/dist/commands/flag.js +0 -13
  197. package/dist/commands/flag.js.map +0 -1
  198. package/dist/commands/forget.d.ts +0 -4
  199. package/dist/commands/forget.d.ts.map +0 -1
  200. package/dist/commands/forget.js +0 -16
  201. package/dist/commands/forget.js.map +0 -1
  202. package/dist/commands/frontier.d.ts +0 -4
  203. package/dist/commands/frontier.d.ts.map +0 -1
  204. package/dist/commands/frontier.js +0 -11
  205. package/dist/commands/frontier.js.map +0 -1
  206. package/dist/commands/group.d.ts +0 -3
  207. package/dist/commands/group.d.ts.map +0 -1
  208. package/dist/commands/group.js +0 -123
  209. package/dist/commands/group.js.map +0 -1
  210. package/dist/commands/health.d.ts +0 -4
  211. package/dist/commands/health.d.ts.map +0 -1
  212. package/dist/commands/health.js +0 -11
  213. package/dist/commands/health.js.map +0 -1
  214. package/dist/commands/highways.d.ts +0 -4
  215. package/dist/commands/highways.d.ts.map +0 -1
  216. package/dist/commands/highways.js +0 -14
  217. package/dist/commands/highways.js.map +0 -1
  218. package/dist/commands/hire.d.ts +0 -4
  219. package/dist/commands/hire.d.ts.map +0 -1
  220. package/dist/commands/hire.js +0 -16
  221. package/dist/commands/hire.js.map +0 -1
  222. package/dist/commands/init.d.ts +0 -17
  223. package/dist/commands/init.d.ts.map +0 -1
  224. package/dist/commands/init.js +0 -308
  225. package/dist/commands/init.js.map +0 -1
  226. package/dist/commands/invite.d.ts +0 -4
  227. package/dist/commands/invite.d.ts.map +0 -1
  228. package/dist/commands/invite.js +0 -37
  229. package/dist/commands/invite.js.map +0 -1
  230. package/dist/commands/know.d.ts +0 -4
  231. package/dist/commands/know.d.ts.map +0 -1
  232. package/dist/commands/know.js +0 -8
  233. package/dist/commands/know.js.map +0 -1
  234. package/dist/commands/launch.d.ts +0 -4
  235. package/dist/commands/launch.d.ts.map +0 -1
  236. package/dist/commands/launch.js +0 -16
  237. package/dist/commands/launch.js.map +0 -1
  238. package/dist/commands/mark.d.ts +0 -4
  239. package/dist/commands/mark.d.ts.map +0 -1
  240. package/dist/commands/mark.js +0 -15
  241. package/dist/commands/mark.js.map +0 -1
  242. package/dist/commands/pay.d.ts +0 -4
  243. package/dist/commands/pay.d.ts.map +0 -1
  244. package/dist/commands/pay.js +0 -21
  245. package/dist/commands/pay.js.map +0 -1
  246. package/dist/commands/pipe.d.ts +0 -4
  247. package/dist/commands/pipe.d.ts.map +0 -1
  248. package/dist/commands/pipe.js +0 -35
  249. package/dist/commands/pipe.js.map +0 -1
  250. package/dist/commands/publish.d.ts +0 -4
  251. package/dist/commands/publish.d.ts.map +0 -1
  252. package/dist/commands/publish.js +0 -23
  253. package/dist/commands/publish.js.map +0 -1
  254. package/dist/commands/recall.d.ts +0 -4
  255. package/dist/commands/recall.d.ts.map +0 -1
  256. package/dist/commands/recall.js +0 -12
  257. package/dist/commands/recall.js.map +0 -1
  258. package/dist/commands/repl.d.ts +0 -4
  259. package/dist/commands/repl.d.ts.map +0 -1
  260. package/dist/commands/repl.js +0 -56
  261. package/dist/commands/repl.js.map +0 -1
  262. package/dist/commands/reveal.d.ts +0 -4
  263. package/dist/commands/reveal.d.ts.map +0 -1
  264. package/dist/commands/reveal.js +0 -11
  265. package/dist/commands/reveal.js.map +0 -1
  266. package/dist/commands/revenue.d.ts +0 -4
  267. package/dist/commands/revenue.d.ts.map +0 -1
  268. package/dist/commands/revenue.js +0 -11
  269. package/dist/commands/revenue.js.map +0 -1
  270. package/dist/commands/select.d.ts +0 -4
  271. package/dist/commands/select.d.ts.map +0 -1
  272. package/dist/commands/select.js +0 -19
  273. package/dist/commands/select.js.map +0 -1
  274. package/dist/commands/sell.d.ts +0 -15
  275. package/dist/commands/sell.d.ts.map +0 -1
  276. package/dist/commands/sell.js +0 -49
  277. package/dist/commands/sell.js.map +0 -1
  278. package/dist/commands/signal.d.ts +0 -4
  279. package/dist/commands/signal.d.ts.map +0 -1
  280. package/dist/commands/signal.js +0 -8
  281. package/dist/commands/signal.js.map +0 -1
  282. package/dist/commands/stats.d.ts +0 -4
  283. package/dist/commands/stats.d.ts.map +0 -1
  284. package/dist/commands/stats.js +0 -11
  285. package/dist/commands/stats.js.map +0 -1
  286. package/dist/commands/status.d.ts +0 -4
  287. package/dist/commands/status.d.ts.map +0 -1
  288. package/dist/commands/status.js +0 -18
  289. package/dist/commands/status.js.map +0 -1
  290. package/dist/commands/subscribe.d.ts +0 -14
  291. package/dist/commands/subscribe.d.ts.map +0 -1
  292. package/dist/commands/subscribe.js +0 -33
  293. package/dist/commands/subscribe.js.map +0 -1
  294. package/dist/commands/sync.d.ts +0 -4
  295. package/dist/commands/sync.d.ts.map +0 -1
  296. package/dist/commands/sync.js +0 -20
  297. package/dist/commands/sync.js.map +0 -1
  298. package/dist/commands/tail.d.ts +0 -4
  299. package/dist/commands/tail.d.ts.map +0 -1
  300. package/dist/commands/tail.js +0 -51
  301. package/dist/commands/tail.js.map +0 -1
  302. package/dist/commands/warn.d.ts +0 -4
  303. package/dist/commands/warn.d.ts.map +0 -1
  304. package/dist/commands/warn.js +0 -15
  305. package/dist/commands/warn.js.map +0 -1
  306. package/dist/copy-claude-config.d.ts +0 -2
  307. package/dist/copy-claude-config.d.ts.map +0 -1
  308. package/dist/copy-claude-config.js +0 -32
  309. package/dist/copy-claude-config.js.map +0 -1
  310. package/dist/create-org-profile.d.ts +0 -10
  311. package/dist/create-org-profile.d.ts.map +0 -1
  312. package/dist/create-org-profile.js +0 -136
  313. package/dist/create-org-profile.js.map +0 -1
  314. package/dist/create-user-profile.d.ts +0 -9
  315. package/dist/create-user-profile.d.ts.map +0 -1
  316. package/dist/create-user-profile.js +0 -115
  317. package/dist/create-user-profile.js.map +0 -1
  318. package/dist/index.d.ts +0 -3
  319. package/dist/index.d.ts.map +0 -1
  320. package/dist/index.js +0 -375
  321. package/dist/index.js.map +0 -1
  322. package/dist/lib/agent-detection.d.ts +0 -19
  323. package/dist/lib/agent-detection.d.ts.map +0 -1
  324. package/dist/lib/agent-detection.js +0 -87
  325. package/dist/lib/agent-detection.js.map +0 -1
  326. package/dist/lib/args.d.ts +0 -11
  327. package/dist/lib/args.d.ts.map +0 -1
  328. package/dist/lib/args.js +0 -57
  329. package/dist/lib/args.js.map +0 -1
  330. package/dist/lib/config.d.ts +0 -12
  331. package/dist/lib/config.d.ts.map +0 -1
  332. package/dist/lib/config.js +0 -38
  333. package/dist/lib/config.js.map +0 -1
  334. package/dist/lib/detect.d.ts +0 -45
  335. package/dist/lib/detect.d.ts.map +0 -1
  336. package/dist/lib/detect.js +0 -221
  337. package/dist/lib/detect.js.map +0 -1
  338. package/dist/lib/http.d.ts +0 -9
  339. package/dist/lib/http.d.ts.map +0 -1
  340. package/dist/lib/http.js +0 -25
  341. package/dist/lib/http.js.map +0 -1
  342. package/dist/lib/output.d.ts +0 -5
  343. package/dist/lib/output.d.ts.map +0 -1
  344. package/dist/lib/output.js +0 -32
  345. package/dist/lib/output.js.map +0 -1
  346. package/dist/lib/sdk.d.ts +0 -10
  347. package/dist/lib/sdk.d.ts.map +0 -1
  348. package/dist/lib/sdk.js +0 -22
  349. package/dist/lib/sdk.js.map +0 -1
  350. package/dist/lib/telemetry.d.ts +0 -4
  351. package/dist/lib/telemetry.d.ts.map +0 -1
  352. package/dist/lib/telemetry.js +0 -61
  353. package/dist/lib/telemetry.js.map +0 -1
  354. package/dist/sync-agents.d.ts +0 -5
  355. package/dist/sync-agents.d.ts.map +0 -1
  356. package/dist/sync-agents.js +0 -28
  357. package/dist/sync-agents.js.map +0 -1
  358. package/dist/sync-ontology.d.ts +0 -4
  359. package/dist/sync-ontology.d.ts.map +0 -1
  360. package/dist/sync-ontology.js +0 -40
  361. package/dist/sync-ontology.js.map +0 -1
  362. package/dist/utils/file-resolver.d.ts +0 -83
  363. package/dist/utils/file-resolver.d.ts.map +0 -1
  364. package/dist/utils/file-resolver.js +0 -194
  365. package/dist/utils/file-resolver.js.map +0 -1
  366. package/dist/utils/installation-setup.d.ts +0 -88
  367. package/dist/utils/installation-setup.d.ts.map +0 -1
  368. package/dist/utils/installation-setup.js +0 -409
  369. package/dist/utils/installation-setup.js.map +0 -1
  370. package/dist/utils/launch-claude.d.ts +0 -7
  371. package/dist/utils/launch-claude.d.ts.map +0 -1
  372. package/dist/utils/launch-claude.js +0 -86
  373. package/dist/utils/launch-claude.js.map +0 -1
  374. package/dist/utils/validation.d.ts +0 -48
  375. package/dist/utils/validation.d.ts.map +0 -1
  376. package/dist/utils/validation.js +0 -73
  377. package/dist/utils/validation.js.map +0 -1
@@ -0,0 +1,58 @@
1
+ import { askPath } from './lib/api-path.js';
2
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
3
+ function apiKey() {
4
+ return process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
5
+ }
6
+ function base(opts) {
7
+ return (opts.api ?? DEFAULT_API).replace(/\/$/, '');
8
+ }
9
+ function authHeaders() {
10
+ const h = { 'Content-Type': 'application/json' };
11
+ const k = apiKey();
12
+ if (k)
13
+ h['Authorization'] = `Bearer ${k}`;
14
+ return h;
15
+ }
16
+ export const REPUTATION_PENDING = 'reputation: pending — meta:reputation is not yet shipped (agent-first follow-on).\n' +
17
+ ' Standing lives in TypeDB paths; until the receiver lands, one shows no score (no stub).';
18
+ function formatRecall(out) {
19
+ const hyps = (out?.hypotheses ?? []);
20
+ if (!hyps.length)
21
+ return ' (no memory yet — recall returns what this caller has learned)';
22
+ return hyps.map((h) => ` · [${h.status}] ${h.claim}${h.confidence != null ? ` (${h.confidence})` : ''}`).join('\n');
23
+ }
24
+ export function coordinateCommands(program) {
25
+ program
26
+ .command('recall')
27
+ .description('Read cross-session memory (meta:recall)')
28
+ .option('--about <term>', 'Filter by keyword')
29
+ .option('--limit <n>', 'Max results', '20')
30
+ .option('--api <url>', 'API base URL', DEFAULT_API)
31
+ .option('--json', 'Output raw JSON')
32
+ .action(async (opts) => {
33
+ const payload = { limit: Number(opts.limit) };
34
+ if (opts.about)
35
+ payload.match = opts.about;
36
+ const res = await fetch(askPath(base(opts), 'meta:recall'), {
37
+ method: 'POST',
38
+ headers: authHeaders(),
39
+ body: JSON.stringify({ data: payload }),
40
+ });
41
+ if (!res.ok) {
42
+ process.stderr.write(`meta:recall → ${res.status}\n`);
43
+ process.exit(1);
44
+ }
45
+ const data = await res.json();
46
+ if (opts.json) {
47
+ process.stdout.write(JSON.stringify(data, null, 2) + '\n');
48
+ return;
49
+ }
50
+ process.stdout.write(formatRecall(data) + '\n');
51
+ });
52
+ program
53
+ .command('reputation')
54
+ .description('Agent reputation standing (pending)')
55
+ .action(() => {
56
+ process.stdout.write(REPUTATION_PENDING + '\n');
57
+ });
58
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function createCmd(): Command;
@@ -0,0 +1,106 @@
1
+ import { Command } from 'commander';
2
+ import { mkdirSync, readFileSync, writeFileSync, existsSync } from 'node:fs';
3
+ import { resolve, join } from 'node:path';
4
+ import { spawnSync } from 'node:child_process';
5
+ const SAFE_REF = /^[A-Za-z0-9._/-]+$/;
6
+ function downloadTarball(url, targetDir) {
7
+ mkdirSync(targetDir, { recursive: true });
8
+ // No shell — pipe curl stdout directly into tar stdin as a buffer
9
+ const curl = spawnSync('curl', ['-fsSL', '--location', url], {
10
+ maxBuffer: 512 * 1024 * 1024,
11
+ stdio: ['ignore', 'pipe', 'inherit'],
12
+ });
13
+ if (curl.status !== 0 || !curl.stdout)
14
+ throw new Error(`curl failed: ${url}`);
15
+ const tar = spawnSync('tar', ['-xz', '--strip-components=1', '-C', targetDir], {
16
+ input: curl.stdout,
17
+ stdio: ['pipe', 'inherit', 'inherit'],
18
+ });
19
+ if (tar.status !== 0)
20
+ throw new Error(`tar failed extracting to ${targetDir}`);
21
+ }
22
+ export function createCmd() {
23
+ const cmd = new Command('create').description('Scaffold a new ONE node');
24
+ // ── one create [name] ───────────────────────────────────────────────────
25
+ // github.com/one-ie/one is itself one node — ai/ data/ site/ workspace.toml
26
+ // at its root — so scaffolding is a plain whole-repo download, no subdir
27
+ // composition. .claude/ + .mcp.json come along for free: open the scaffold
28
+ // in Claude Code and it's connected from its first `git init`.
29
+ cmd
30
+ .command('node [name]', { isDefault: true })
31
+ .description('Scaffold a ONE business node from github.com/one-ie/one — free plan, no credit card')
32
+ .option('--ref <ref>', 'Git ref to download', 'main')
33
+ .option('--slug <slug>', 'Workspace slug (written into workspace.toml)')
34
+ .option('--name <name>', 'Display name (written into workspace.toml)')
35
+ .action((dirName, opts) => {
36
+ if (!SAFE_REF.test(opts.ref)) {
37
+ process.stderr.write(`Invalid ref: ${opts.ref}\n`);
38
+ process.exit(1);
39
+ }
40
+ const label = dirName ?? opts.slug ?? 'my-business';
41
+ const dir = resolve(process.cwd(), label);
42
+ if (existsSync(dir)) {
43
+ process.stderr.write(`Directory already exists: ${dir}\n`);
44
+ process.exit(1);
45
+ }
46
+ process.stdout.write(`Creating business node at ${dir}...\n`);
47
+ downloadTarball(`https://api.github.com/repos/one-ie/one/tarball/${opts.ref}`, dir);
48
+ const tomlPath = join(dir, 'workspace.toml');
49
+ if (existsSync(tomlPath) && (opts.slug ?? opts.name)) {
50
+ let toml = readFileSync(tomlPath, 'utf8');
51
+ if (opts.slug)
52
+ toml = toml.replace(/^slug\s*=\s*"[^"]*"/m, `slug = "${opts.slug}"`);
53
+ if (opts.name)
54
+ toml = toml.replace(/^name\s*=\s*"[^"]*"/m, `name = "${opts.name}"`);
55
+ writeFileSync(tomlPath, toml);
56
+ }
57
+ process.stdout.write(`\nNode created — free plan, no credit card.\n\n`);
58
+ process.stdout.write(`Next steps:\n`);
59
+ process.stdout.write(` cd ${label}\n`);
60
+ process.stdout.write(` bun install\n`);
61
+ process.stdout.write(` cp .env.example .env.local\n`);
62
+ process.stdout.write(` # Edit .env.local — set WORKSPACE_OWNER_EMAIL\n`);
63
+ if (!opts.slug)
64
+ process.stdout.write(` # Edit workspace.toml — set slug and name\n`);
65
+ process.stdout.write(` one setup\n`);
66
+ });
67
+ // ── one create partner [name] ────────────────────────────────────────────
68
+ cmd
69
+ .command('partner [name]')
70
+ .description('Scaffold a new partner node from github.com/one-ie/partner')
71
+ .option('--ref <ref>', 'Git ref to download', 'main')
72
+ .option('--slug <slug>', 'Your partner slug (written into partner.toml)')
73
+ .option('--name <name>', 'Your display name (written into partner.toml)')
74
+ .action((dirName, opts) => {
75
+ if (!SAFE_REF.test(opts.ref)) {
76
+ process.stderr.write(`Invalid ref: ${opts.ref}\n`);
77
+ process.exit(1);
78
+ }
79
+ const label = dirName ?? opts.slug ?? 'my-partner';
80
+ const dir = resolve(process.cwd(), label);
81
+ if (existsSync(dir)) {
82
+ process.stderr.write(`Directory already exists: ${dir}\n`);
83
+ process.exit(1);
84
+ }
85
+ process.stdout.write(`Creating partner node at ${dir}...\n`);
86
+ downloadTarball(`https://api.github.com/repos/one-ie/partner/tarball/${opts.ref}`, dir);
87
+ const tomlPath = join(dir, 'partner.toml');
88
+ if (existsSync(tomlPath) && (opts.slug ?? opts.name)) {
89
+ let toml = readFileSync(tomlPath, 'utf8');
90
+ if (opts.slug)
91
+ toml = toml.replace(/^slug\s*=\s*"[^"]*"/m, `slug = "${opts.slug}"`);
92
+ if (opts.name)
93
+ toml = toml.replace(/^name\s*=\s*"[^"]*"/m, `name = "${opts.name}"`);
94
+ writeFileSync(tomlPath, toml);
95
+ }
96
+ process.stdout.write(`\nPartner node created.\n\n`);
97
+ process.stdout.write(`Next steps:\n`);
98
+ process.stdout.write(` cd ${label}\n`);
99
+ process.stdout.write(` cp .env.example .env.local\n`);
100
+ process.stdout.write(` # Edit .env.local — set ONE_API_KEY\n`);
101
+ if (!opts.slug)
102
+ process.stdout.write(` # Edit partner.toml — set slug and name\n`);
103
+ process.stdout.write(` one setup\n`);
104
+ });
105
+ return cmd;
106
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function deployCmd(): Command;
@@ -0,0 +1,19 @@
1
+ import { Command } from 'commander';
2
+ import { spawnSync } from 'node:child_process';
3
+ import { existsSync } from 'node:fs';
4
+ export function deployCmd() {
5
+ return new Command('deploy')
6
+ .description('Deploy site/ to Cloudflare Pages via wrangler')
7
+ .argument('[path]', 'Path to deploy (default: site/dist)')
8
+ .option('--project <name>', 'Cloudflare Pages project name')
9
+ .action((path, opts) => {
10
+ const target = path ?? (existsSync('site/dist') ? 'site/dist' : 'dist');
11
+ const args = ['pages', 'deploy', target];
12
+ if (opts.project)
13
+ args.push('--project-name', opts.project);
14
+ process.stdout.write(`Deploying ${target}...\n`);
15
+ const result = spawnSync('wrangler', args, { stdio: 'inherit' });
16
+ if (result.status !== 0)
17
+ process.exit(result.status ?? 1);
18
+ });
19
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function devCmd(): Command;
@@ -0,0 +1,75 @@
1
+ import { Command } from 'commander';
2
+ import { spawn } from 'node:child_process';
3
+ import { existsSync, readFileSync } from 'node:fs';
4
+ import { resolve } from 'node:path';
5
+ export function devCmd() {
6
+ const cmd = new Command('dev')
7
+ .description('Run the full Cloudflare stack locally (build + migrate + wrangler dev)')
8
+ .option('-p, --port <port>', 'HTTP port', '8787')
9
+ .option('--ip <ip>', 'Bind address', '127.0.0.1')
10
+ .option('--remote', 'Use remote bindings (real D1/KV/R2)', false)
11
+ .option('--skip-build', 'Skip astro build before wrangler dev', false)
12
+ .option('--skip-migrate', 'Skip D1 migrations', false)
13
+ .option('--cwd <path>', 'Project directory (must contain wrangler.toml)', process.cwd())
14
+ .action(async (opts) => {
15
+ const cwd = resolve(opts.cwd);
16
+ const wranglerToml = resolve(cwd, 'wrangler.toml');
17
+ if (!existsSync(wranglerToml)) {
18
+ process.stderr.write(`no wrangler.toml at ${cwd}\n`);
19
+ process.exit(1);
20
+ }
21
+ if (opts.remote) {
22
+ // Remote mode: full build → migrate → wrangler dev --remote
23
+ if (!opts.skipBuild) {
24
+ const built = await run('npm', ['run', 'build'], cwd);
25
+ if (built !== 0)
26
+ process.exit(built);
27
+ }
28
+ if (!opts.skipMigrate) {
29
+ for (const binding of d1Bindings(wranglerToml)) {
30
+ const code = await run('npx', ['wrangler', 'd1', 'migrations', 'apply', binding, '--remote'], cwd);
31
+ if (code !== 0) {
32
+ process.stderr.write(`d1 migrations failed for ${binding}\n`);
33
+ process.exit(code);
34
+ }
35
+ }
36
+ }
37
+ const args = ['dev', '--port', opts.port, '--ip', opts.ip, '--remote'];
38
+ const code = await run('npx', ['wrangler', ...args], cwd);
39
+ process.exit(code);
40
+ }
41
+ else {
42
+ // Local mode: astro dev with Vite HMR
43
+ if (!opts.skipMigrate) {
44
+ for (const binding of d1Bindings(wranglerToml)) {
45
+ const code = await run('npx', ['wrangler', 'd1', 'migrations', 'apply', binding, '--local'], cwd);
46
+ if (code !== 0) {
47
+ process.stderr.write(`d1 migrations failed for ${binding}\n`);
48
+ process.exit(code);
49
+ }
50
+ }
51
+ }
52
+ const code = await run('npm', ['run', 'dev'], cwd);
53
+ process.exit(code);
54
+ }
55
+ });
56
+ return cmd;
57
+ }
58
+ function d1Bindings(wranglerToml) {
59
+ const text = readFileSync(wranglerToml, 'utf8');
60
+ const blocks = text.match(/\[\[d1_databases\]\][^[]*/g) ?? [];
61
+ const bindings = [];
62
+ for (const block of blocks) {
63
+ const m = block.match(/binding\s*=\s*["']([^"']+)["']/);
64
+ if (m)
65
+ bindings.push(m[1]);
66
+ }
67
+ return bindings;
68
+ }
69
+ function run(bin, args, cwd) {
70
+ return new Promise(resolveP => {
71
+ const child = spawn(bin, args, { cwd, stdio: 'inherit', env: process.env });
72
+ child.on('exit', code => resolveP(code ?? 0));
73
+ child.on('error', err => { process.stderr.write(`${err.message}\n`); resolveP(1); });
74
+ });
75
+ }
@@ -0,0 +1,57 @@
1
+ /**
2
+ * device-flow.ts — RFC 8628 device-authorization-grant primitives
3
+ *
4
+ * Pure functions. auth.ts orchestrates; this module only does I/O
5
+ * against the network + browser open. No Commander, no key-write here.
6
+ */
7
+ export interface DeviceCodeResponse {
8
+ device_code: string;
9
+ user_code: string;
10
+ verification_uri: string;
11
+ expires_in: number;
12
+ interval: number;
13
+ }
14
+ export interface TokenResponse {
15
+ access_token: string;
16
+ token_type: string;
17
+ expires_in?: number;
18
+ refresh_token?: string;
19
+ scope?: string;
20
+ userId?: string;
21
+ }
22
+ /** Returned by pollForToken when still waiting */
23
+ export interface PollPending {
24
+ status: 'pending' | 'slow_down';
25
+ }
26
+ /** Returned by pollForToken on success */
27
+ export interface PollSuccess {
28
+ status: 'success';
29
+ token: TokenResponse;
30
+ }
31
+ /** Returned by pollForToken on terminal error */
32
+ export interface PollError {
33
+ status: 'error';
34
+ code: string;
35
+ message: string;
36
+ }
37
+ export type PollResult = PollPending | PollSuccess | PollError;
38
+ export declare function requestDeviceCode(base: string, clientId: string, scope: string): Promise<DeviceCodeResponse>;
39
+ /**
40
+ * Open `url` in the default browser.
41
+ * Tries `open` package first; falls back to platform child_process.execSync.
42
+ */
43
+ export declare function openBrowser(url: string): Promise<void>;
44
+ /**
45
+ * Poll until token, expiry, or terminal error.
46
+ *
47
+ * Respects server `interval` (RFC 8628 §3.5).
48
+ * Backs off on `slow_down` by doubling interval (minimum +5 s per RFC).
49
+ *
50
+ * @param base API base URL (e.g. https://one.ie)
51
+ * @param clientId OAuth client_id
52
+ * @param deviceCode device_code from requestDeviceCode
53
+ * @param intervalSec initial polling interval from server
54
+ * @param expiresIn seconds until device_code expires
55
+ * @returns TokenResponse on success, throws on failure/expiry
56
+ */
57
+ export declare function pollForToken(base: string, clientId: string, deviceCode: string, intervalSec: number, expiresIn: number): Promise<TokenResponse>;
@@ -0,0 +1,173 @@
1
+ /**
2
+ * device-flow.ts — RFC 8628 device-authorization-grant primitives
3
+ *
4
+ * Pure functions. auth.ts orchestrates; this module only does I/O
5
+ * against the network + browser open. No Commander, no key-write here.
6
+ */
7
+ import { execSync } from 'node:child_process';
8
+ // ---------------------------------------------------------------------------
9
+ // Step (a): Request device code
10
+ // ---------------------------------------------------------------------------
11
+ export async function requestDeviceCode(base, clientId, scope) {
12
+ const url = `${base}/api/auth/mcp/device/code`;
13
+ const res = await fetch(url, {
14
+ method: 'POST',
15
+ headers: { 'Content-Type': 'application/json' },
16
+ body: JSON.stringify({ client_id: clientId, scope }),
17
+ });
18
+ if (!res.ok) {
19
+ let detail = '';
20
+ try {
21
+ detail = await res.text();
22
+ }
23
+ catch { /* ignore */ }
24
+ throw new Error(`device-code request failed ${res.status}: ${detail}`);
25
+ }
26
+ const data = (await res.json());
27
+ if (!data.device_code || !data.user_code || !data.verification_uri) {
28
+ throw new Error('Malformed device-code response from server');
29
+ }
30
+ return data;
31
+ }
32
+ // ---------------------------------------------------------------------------
33
+ // Step (b): Open browser
34
+ // ---------------------------------------------------------------------------
35
+ /**
36
+ * Open `url` in the default browser.
37
+ * Tries `open` package first; falls back to platform child_process.execSync.
38
+ */
39
+ export async function openBrowser(url) {
40
+ // Attempt dynamic import of `open` package (optional dep)
41
+ try {
42
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
43
+ const mod = await import('open');
44
+ const openFn = mod.default ?? mod;
45
+ if (typeof openFn === 'function') {
46
+ await openFn(url);
47
+ return;
48
+ }
49
+ }
50
+ catch {
51
+ // `open` not installed — fall back to child_process
52
+ }
53
+ const platform = process.platform;
54
+ let cmd;
55
+ if (platform === 'darwin') {
56
+ cmd = 'open';
57
+ }
58
+ else if (platform === 'win32') {
59
+ cmd = 'start';
60
+ }
61
+ else {
62
+ cmd = 'xdg-open';
63
+ }
64
+ try {
65
+ execSync(`${cmd} "${url}"`, { stdio: 'ignore' });
66
+ }
67
+ catch (err) {
68
+ // Non-fatal: user can open manually
69
+ if (process.env.DEBUG) {
70
+ process.stderr.write(`browser open failed: ${err.message}\n`);
71
+ }
72
+ }
73
+ }
74
+ // ---------------------------------------------------------------------------
75
+ // Step (c): Poll for token
76
+ // ---------------------------------------------------------------------------
77
+ /**
78
+ * Single poll attempt against `/api/auth/mcp/device/token`.
79
+ * Returns a PollResult discriminated union.
80
+ */
81
+ async function pollOnce(base, clientId, deviceCode) {
82
+ const url = `${base}/api/auth/mcp/device/token`;
83
+ let res;
84
+ try {
85
+ res = await fetch(url, {
86
+ method: 'POST',
87
+ headers: { 'Content-Type': 'application/json' },
88
+ body: JSON.stringify({ device_code: deviceCode, client_id: clientId }),
89
+ });
90
+ }
91
+ catch (err) {
92
+ return { status: 'error', code: 'network_error', message: err.message };
93
+ }
94
+ // 200 = success
95
+ if (res.ok) {
96
+ const token = (await res.json());
97
+ if (!token.access_token) {
98
+ return { status: 'error', code: 'invalid_response', message: 'access_token missing' };
99
+ }
100
+ return { status: 'success', token };
101
+ }
102
+ // OAuth error body
103
+ let body = {};
104
+ try {
105
+ body = (await res.json());
106
+ }
107
+ catch { /* ignore */ }
108
+ const code = body.error ?? 'unknown';
109
+ switch (code) {
110
+ case 'authorization_pending':
111
+ return { status: 'pending' };
112
+ case 'slow_down':
113
+ return { status: 'slow_down' };
114
+ case 'expired_token':
115
+ case 'access_denied':
116
+ case 'invalid_grant':
117
+ case 'invalid_client':
118
+ return {
119
+ status: 'error',
120
+ code,
121
+ message: body.error_description ?? code,
122
+ };
123
+ default:
124
+ return {
125
+ status: 'error',
126
+ code,
127
+ message: body.error_description ?? `HTTP ${res.status}`,
128
+ };
129
+ }
130
+ }
131
+ /**
132
+ * Poll until token, expiry, or terminal error.
133
+ *
134
+ * Respects server `interval` (RFC 8628 §3.5).
135
+ * Backs off on `slow_down` by doubling interval (minimum +5 s per RFC).
136
+ *
137
+ * @param base API base URL (e.g. https://one.ie)
138
+ * @param clientId OAuth client_id
139
+ * @param deviceCode device_code from requestDeviceCode
140
+ * @param intervalSec initial polling interval from server
141
+ * @param expiresIn seconds until device_code expires
142
+ * @returns TokenResponse on success, throws on failure/expiry
143
+ */
144
+ export async function pollForToken(base, clientId, deviceCode, intervalSec, expiresIn) {
145
+ const deadline = Date.now() + expiresIn * 1000;
146
+ let currentInterval = Math.max(intervalSec, 5); // never below 5 s
147
+ while (Date.now() < deadline) {
148
+ await sleep(currentInterval * 1000);
149
+ const result = await pollOnce(base, clientId, deviceCode);
150
+ if (result.status === 'success') {
151
+ return result.token;
152
+ }
153
+ if (result.status === 'slow_down') {
154
+ // RFC 8628 §3.5: increase interval by 5 s minimum
155
+ currentInterval += 5;
156
+ continue;
157
+ }
158
+ if (result.status === 'pending') {
159
+ continue;
160
+ }
161
+ // Terminal error — narrow off the discriminant so code/message are present
162
+ if (result.status === 'error') {
163
+ throw new Error(`auth failed [${result.code}]: ${result.message}`);
164
+ }
165
+ }
166
+ throw new Error('Device code expired. Run `oneie auth login` to try again.');
167
+ }
168
+ // ---------------------------------------------------------------------------
169
+ // Internal helpers
170
+ // ---------------------------------------------------------------------------
171
+ function sleep(ms) {
172
+ return new Promise((resolve) => setTimeout(resolve, ms));
173
+ }
@@ -0,0 +1,26 @@
1
+ import { Command } from 'commander';
2
+ /** api.one.ie (the gateway) answers `GET /health`; one.ie/web has no /health
3
+ * route, so a HEAD / 200 is the reachability signal there — same host split
4
+ * askPath() already makes for /ask. */
5
+ export declare function isGatewayHost(base: string): boolean;
6
+ export declare function checkReachability(base: string, timeoutMs?: number): Promise<{
7
+ ok: boolean;
8
+ ms: number;
9
+ }>;
10
+ export interface DoctorCheck {
11
+ name: string;
12
+ ok: boolean;
13
+ detail: string;
14
+ }
15
+ export interface DoctorResult {
16
+ ok: boolean;
17
+ checks: DoctorCheck[];
18
+ }
19
+ export declare function runDoctor(dir: string, opts?: {
20
+ api?: string;
21
+ keyFile?: string;
22
+ }): Promise<DoctorResult>;
23
+ /** No `auth:whoami` receiver exists — an authenticated `dashboard:usage` call
24
+ * proves the key is live, alongside the env echo. */
25
+ export declare function whoamiCmd(): Command;
26
+ export declare function doctorCmd(): Command;
@@ -0,0 +1,91 @@
1
+ import { Command } from 'commander';
2
+ import { existsSync, readFileSync } from 'node:fs';
3
+ import { homedir } from 'node:os';
4
+ import { resolve } from 'node:path';
5
+ import { mergeEnv } from './env.js';
6
+ import { resolveBase, resolveKey, authHeaders } from './lib/client.js';
7
+ import { askPath } from './lib/api-path.js';
8
+ const KEY_FILE = resolve(homedir(), '.config', 'oneie', 'key');
9
+ /** api.one.ie (the gateway) answers `GET /health`; one.ie/web has no /health
10
+ * route, so a HEAD / 200 is the reachability signal there — same host split
11
+ * askPath() already makes for /ask. */
12
+ export function isGatewayHost(base) {
13
+ return new URL(base).hostname === 'api.one.ie';
14
+ }
15
+ export async function checkReachability(base, timeoutMs = 5000) {
16
+ const start = Date.now();
17
+ const controller = new AbortController();
18
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
19
+ try {
20
+ const res = await fetch(isGatewayHost(base) ? `${base}/health` : base, {
21
+ method: isGatewayHost(base) ? 'GET' : 'HEAD',
22
+ signal: controller.signal,
23
+ });
24
+ return { ok: res.ok, ms: Date.now() - start };
25
+ }
26
+ catch {
27
+ return { ok: false, ms: Date.now() - start };
28
+ }
29
+ finally {
30
+ clearTimeout(timer);
31
+ }
32
+ }
33
+ export async function runDoctor(dir, opts = {}) {
34
+ const keyFile = opts.keyFile ?? KEY_FILE;
35
+ const env = mergeEnv(dir);
36
+ const checks = [];
37
+ const hasConfig = existsSync(keyFile) || Boolean(env.ONE_API_KEY) || Boolean(env.ONEIE_API_KEY);
38
+ checks.push({
39
+ name: 'config',
40
+ ok: hasConfig,
41
+ detail: hasConfig ? `${keyFile} (0600)` : `${keyFile} missing — run \`one setup\` or \`one login\``,
42
+ });
43
+ const key = env.ONE_API_KEY || env.ONEIE_API_KEY || (existsSync(keyFile) ? readFileSync(keyFile, 'utf8').trim() : '');
44
+ checks.push({ name: 'key', ok: Boolean(key), detail: key ? `${key.slice(0, 4)}***…` : 'no key found' });
45
+ const base = resolveBase({ api: opts.api });
46
+ const reach = await checkReachability(base);
47
+ checks.push({ name: 'substrate', ok: reach.ok, detail: `${base} ${reach.ms}ms` });
48
+ return { ok: checks.every((c) => c.ok), checks };
49
+ }
50
+ /** No `auth:whoami` receiver exists — an authenticated `dashboard:usage` call
51
+ * proves the key is live, alongside the env echo. */
52
+ export function whoamiCmd() {
53
+ return new Command('whoami')
54
+ .description('Who the key is, which workspace — proves the key is live')
55
+ .option('--api <url>', 'API base URL')
56
+ .action(async (opts) => {
57
+ const dir = process.cwd();
58
+ const env = mergeEnv(dir);
59
+ const base = resolveBase({ api: opts.api });
60
+ const key = resolveKey({});
61
+ if (!key) {
62
+ process.stderr.write('no key found — run `one setup` or `one login`\n');
63
+ process.exitCode = 1;
64
+ return;
65
+ }
66
+ const res = await fetch(askPath(base, 'dashboard:usage'), {
67
+ method: 'POST',
68
+ headers: authHeaders({}),
69
+ body: JSON.stringify({ data: {} }),
70
+ });
71
+ const live = res.ok;
72
+ process.stdout.write(`workspace ${env.WORKSPACE_SLUG ?? env.AGENCY_SLUG ?? '(unset)'}\n`);
73
+ process.stdout.write(`key ${key.slice(0, 4)}***… ${live ? '(live)' : `(unreachable — ${base})`}\n`);
74
+ process.stdout.write(`base ${base}\n`);
75
+ if (!live)
76
+ process.exitCode = 1;
77
+ });
78
+ }
79
+ export function doctorCmd() {
80
+ return new Command('doctor')
81
+ .description('Config / key / reachability checks — exit 0 or 1 for CI')
82
+ .option('--api <url>', 'API base URL to check (defaults to the resolved base)')
83
+ .action(async (opts) => {
84
+ const result = await runDoctor(process.cwd(), opts);
85
+ for (const c of result.checks) {
86
+ process.stdout.write(`[${c.ok ? 'ok' : 'fail'}] ${c.name.padEnd(10)} ${c.detail}\n`);
87
+ }
88
+ if (!result.ok)
89
+ process.exitCode = 1;
90
+ });
91
+ }
@@ -0,0 +1,3 @@
1
+ export declare function readEnvFile(path: string): Record<string, string>;
2
+ export declare function mergeEnv(dir: string): Record<string, string>;
3
+ export declare function writeEnvLocal(dir: string, updates: Record<string, string>): void;
@@ -0,0 +1,37 @@
1
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
2
+ const LINE = /^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*?)\s*$/;
3
+ export function readEnvFile(path) {
4
+ if (!existsSync(path))
5
+ return {};
6
+ const out = {};
7
+ for (const raw of readFileSync(path, 'utf8').split('\n')) {
8
+ if (raw.trim().startsWith('#') || !raw.trim())
9
+ continue;
10
+ const m = raw.match(LINE);
11
+ if (m)
12
+ out[m[1]] = m[2].replace(/^["']|["']$/g, '');
13
+ }
14
+ return out;
15
+ }
16
+ function fromProcess() {
17
+ const out = {};
18
+ for (const k of ['ONE_API_URL', 'ONE_API_KEY', 'ONEIE_API_KEY', 'AGENCY_SLUG', 'AGENCY_NAME', 'AGENCY_WSID', 'CC_ACTOR_ID', 'WORKSPACE_OWNER_EMAIL', 'WORKSPACE_ID', 'WORKSPACE_SLUG']) {
19
+ const v = process.env[k];
20
+ if (v)
21
+ out[k] = v;
22
+ }
23
+ return out;
24
+ }
25
+ export function mergeEnv(dir) {
26
+ return {
27
+ ...readEnvFile(`${dir}/.env`),
28
+ ...readEnvFile(`${dir}/.env.local`),
29
+ ...fromProcess(),
30
+ };
31
+ }
32
+ export function writeEnvLocal(dir, updates) {
33
+ const path = `${dir}/.env.local`;
34
+ const merged = { ...readEnvFile(path), ...updates };
35
+ const body = Object.entries(merged).map(([k, v]) => `${k}=${v}`).join('\n') + '\n';
36
+ writeFileSync(path, body, 'utf8');
37
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function evalCmd(): Command;