@eloxiv/cli 0.0.0-stage → 0.1.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 (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 +108 -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 +49 -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 +34 -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,47 @@
1
+ export declare const BLUEPRINTS: readonly ["connector", "channel", "action", "module", "make"];
2
+ export type BlueprintKind = (typeof BLUEPRINTS)[number];
3
+ /** The capability contracts a connector can implement, with the key `defineConnector`'s `capabilities` uses. */
4
+ export declare const CAPABILITIES: {
5
+ readonly MailProvider: {
6
+ readonly key: "mail";
7
+ readonly kit: "mailProviderConformance";
8
+ };
9
+ readonly CalendarProvider: {
10
+ readonly key: "calendar";
11
+ readonly kit: "calendarProviderConformance";
12
+ };
13
+ readonly DirectoryProvider: {
14
+ readonly key: "directory";
15
+ readonly kit: "directoryProviderConformance";
16
+ };
17
+ readonly DocumentSource: {
18
+ readonly key: "documents";
19
+ readonly kit: "documentSourceConformance";
20
+ };
21
+ readonly Messaging: {
22
+ readonly key: "messaging";
23
+ readonly kit: "messagingConformance";
24
+ };
25
+ };
26
+ export type CapabilityName = keyof typeof CAPABILITIES;
27
+ export interface BlueprintOptions {
28
+ readonly name?: string;
29
+ readonly provides?: ReadonlyArray<string>;
30
+ readonly module?: string;
31
+ }
32
+ /** The blueprint for `kind` in the app at `dir`, as Markdown. */
33
+ export declare const blueprint: (dir: string, kind: BlueprintKind, options: BlueprintOptions) => string;
34
+ export interface PackageInfo {
35
+ readonly name: string;
36
+ readonly version: string;
37
+ readonly directory: string;
38
+ readonly entryPoints: ReadonlyArray<string>;
39
+ /** What the main entry exports: its `export const/function/class/interface/type` names and re-exported modules. */
40
+ readonly exports: ReadonlyArray<string>;
41
+ readonly readme: boolean;
42
+ readonly docs: string;
43
+ }
44
+ /** `eloxiv info @eloxiv/<package>`: the app's installed package. */
45
+ export declare const packageInfo: (dir: string, name: string) => PackageInfo;
46
+ export declare const formatPackageInfo: (info: PackageInfo) => string;
47
+ //# sourceMappingURL=Blueprint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Blueprint.d.ts","sourceRoot":"","sources":["../src/Blueprint.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,UAAU,YAAI,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAU,CAAA;AACvF,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAA;AAEvD,gHAAgH;AAChH,eAAO,MAAM,YAAY;aACvB,YAAY;iBAAI,GAAG,EAAE,MAAM;iBAAE,GAAG,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"blueprint" and "info"):
3
+ *
4
+ * eloxiv blueprint <connector|channel|action|module|make> [...] Markdown instructions for a coding agent to
5
+ * write that kind of code in this app
6
+ * eloxiv info @eloxiv/<package> an installed package: version, entry points,
7
+ * what its main entry exports, source and docs
8
+ *
9
+ * A blueprint is written for the app it runs in: capability operations come from the installed
10
+ * `@eloxiv/contracts` package's published schemas (so they match the version the app runs), and paths and names
11
+ * from the arguments. It prints; it writes nothing. The registry's own items are the worked examples it points to
12
+ * (`eloxiv info <item> --markdown`).
13
+ */
14
+ import { existsSync, readdirSync, readFileSync, realpathSync } from "node:fs";
15
+ import { join } from "node:path";
16
+ import { CliError } from "./Errors.js";
17
+ import { installedPackages } from "./Docs.js";
18
+ import { identifier } from "./Generate.js";
19
+ export const BLUEPRINTS = ["connector", "channel", "action", "module", "make"];
20
+ /** The capability contracts a connector can implement, with the key `defineConnector`'s `capabilities` uses. */
21
+ export const CAPABILITIES = {
22
+ MailProvider: { key: "mail", kit: "mailProviderConformance" },
23
+ CalendarProvider: { key: "calendar", kit: "calendarProviderConformance" },
24
+ DirectoryProvider: { key: "directory", kit: "directoryProviderConformance" },
25
+ DocumentSource: { key: "documents", kit: "documentSourceConformance" },
26
+ Messaging: { key: "messaging", kit: "messagingConformance" },
27
+ };
28
+ /** A capability contract as the app's installed `@eloxiv/contracts` publishes it, or undefined when not installed. */
29
+ const contractSchema = (dir, name) => {
30
+ const pkg = join(dir, "node_modules", "@eloxiv", "contracts");
31
+ if (!existsSync(pkg))
32
+ return undefined;
33
+ const file = join(realpathSync(pkg), "schema", "contracts", `${name}.json`);
34
+ return existsSync(file) ? JSON.parse(readFileSync(file, "utf8")) : undefined;
35
+ };
36
+ const firstSentence = (text) => (text ?? "").split(/(?<=\.)\s/)[0] ?? "";
37
+ const operationsOf = (dir, name) => {
38
+ const schema = contractSchema(dir, name);
39
+ if (schema === undefined)
40
+ return [`(install the app's dependencies to list ${name}'s operations: pnpm install)`];
41
+ return [
42
+ `${name} ${schema.version}: ${firstSentence(schema.description)}`,
43
+ "",
44
+ ...Object.entries(schema.operations).map(([op, spec]) => `- \`${op}\`: ${firstSentence(spec.description)}`),
45
+ ];
46
+ };
47
+ const kebab = /^[a-z][a-z0-9-]{0,62}$/;
48
+ const ident = /^[a-z][a-zA-Z0-9]*$/;
49
+ /** The blueprint for `kind` in the app at `dir`, as Markdown. */
50
+ export const blueprint = (dir, kind, options) => {
51
+ switch (kind) {
52
+ case "connector":
53
+ case "channel": {
54
+ const name = options.name ?? "acme";
55
+ if (!kebab.test(name))
56
+ throw new CliError({ message: `A connector's name is lower case letters, digits and '-' (got ${name})` });
57
+ const provides = kind === "channel" ? ["Messaging"] : (options.provides ?? []);
58
+ const unknown = provides.filter((p) => !(p in CAPABILITIES));
59
+ if (provides.length === 0 || unknown.length > 0) {
60
+ throw new CliError({
61
+ message: `--provides names capability contracts: ${Object.keys(CAPABILITIES).join(", ")}${unknown.length > 0 ? ` (unknown: ${unknown.join(", ")})` : ""}`,
62
+ });
63
+ }
64
+ const caps = provides;
65
+ const env = `ELOXIV_CONNECTOR_${name.toUpperCase().replaceAll("-", "_")}__`;
66
+ return [
67
+ `# Blueprint: the ${name} ${kind === "channel" ? "messaging channel" : "connector"} (${caps.join(", ")})`,
68
+ "",
69
+ `A connector is registry-style code the app owns: it implements kernel capability contracts over a kernel Connection (one OAuth grant per account, merged scopes, token custody, refresh, 401 versus 403). Modules never call the provider: they call the capability. Worked examples: \`eloxiv info ${kind === "channel" ? "slack" : "google"} --markdown\`, docs/contracts/connections.md.`,
70
+ "",
71
+ "## What to implement",
72
+ "",
73
+ ...caps.flatMap((cap) => [...operationsOf(dir, cap), ""]),
74
+ "## Files",
75
+ "",
76
+ `1. \`connectors/${name}/connector.ts\`: \`export const ${name.replace(/-([a-z])/g, (_, c) => c.toUpperCase())} = defineConnector({ ... })\` from \`@eloxiv/kernel\`, with`,
77
+ ` - \`name: "${name}"\`, \`displayName\`;`,
78
+ ` - \`oauth: (settings) => ({ authorizeUrl, tokenUrl, clientId: requiredSetting(settings, "${name}", "clientId"), clientSecret: ..., baseScopes, pkce })\`: settings come from \`${env}<KEY>\` (\`${env}CLIENT_ID\`, \`${env}CLIENT_SECRET\`), never from \`process.env\` in the connector (doctor's guard fails that);`,
79
+ " - `identify(accessToken, settings)`: the provider account the token belongs to (an Effect);",
80
+ " - `apiOrigins(settings)`: the only origins the kernel sends the token to;",
81
+ " - `classify` (and `classifySuccess` if the provider reports errors in a 200) mapping provider answers to `unauthorized`, `insufficient-scope`, rate limits and the standard capability errors;",
82
+ ` - \`capabilities: { ${caps.map((c) => `${CAPABILITIES[c].key}: { flags, scopes, make: (http, settings) => ({ ...operations }) }`).join(", ")} }\`: \`scopes\` maps each abstract scope the contract's operations name to the provider's scopes; \`make\` gets the kernel's authorised \`http\` (it attaches the token and handles refresh), so the connector never sees a refresh token.`,
83
+ `2. \`connectors/${name}/README.md\`: what to register at the provider (redirect URI \`<ELOXIV_BASE_URL>/connections/callback\`), the settings, the scopes.`,
84
+ ...(kind === "channel"
85
+ ? [
86
+ `3. \`connectors/${name}/events.ts\`: the inbound side as an Ingress source (signature verification, replay window, durable acceptance, linked platform identities): see slack's \`slackEvents\` and docs/contracts/ingress.md; export it from connector.ts and declare it in \`server/main.ts\`'s \`KernelApp.ingress\` (the provider then posts to \`<ELOXIV_BASE_URL>/ingress/<source name>\`).`,
87
+ ]
88
+ : []),
89
+ "",
90
+ "## Prove it",
91
+ "",
92
+ `- A protocol fake of the provider (an HTTP server answering like it), and a test running ${caps.map((c) => `\`${CAPABILITIES[c].kit}\``).join(", ")} from \`@eloxiv/testing\` against the connector through a real kernel: correct 401 versus 403, merged scopes on one Connection, refresh, and cursor-based delta sync that resumes after interruption.`,
93
+ `- Add the connector to the composition (\`eloxiv.server.ts\` lists \`connectors\`; an item of kind \`connector\` is composed by \`eloxiv generate\`), then \`eloxiv doctor\`.`,
94
+ "",
95
+ ].join("\n");
96
+ }
97
+ case "action": {
98
+ const module = options.module ?? "notes";
99
+ const action = options.name ?? "archive";
100
+ if (!kebab.test(module) || !ident.test(action)) {
101
+ throw new CliError({
102
+ message: "--module is a module's name (lower case) and --name an action's (camelCase), e.g. --module notes --name archive",
103
+ });
104
+ }
105
+ const qualified = `${module}.${action}`;
106
+ const exists = existsSync(join(dir, "modules", module, "contract.ts"));
107
+ return [
108
+ `# Blueprint: the action \`${qualified}\``,
109
+ "",
110
+ `One definition gives the typed client, HTTP (\`POST /api/actions/${qualified}\`), MCP and the agent's tool, all through one invocation path: identity, policy, consent or approval, idempotency, execute, audit, events. ${exists ? "" : `(This app has no \`modules/${module}\`: write the module first, \`eloxiv blueprint module --name ${module}\`.)`}`,
111
+ "",
112
+ "## Files",
113
+ "",
114
+ `1. \`modules/${module}/contract.ts\`: \`export const ${action} = defineAction({ name: "${qualified}", description, input: Schema.Struct({...}), output: Schema.Struct({...}), writes: "<entity>" })\` (from \`@eloxiv/contracts\`), and add it to the module contract's \`actions\`. Write the description for an agent: what it does, when to use it, what each optional field means. Mark a read \`readOnly: true\`; declare \`optimistic\` (\`optimistic.insert/update/remove\`) when a replica should show the change before the server confirms it.`,
115
+ `2. \`modules/${module}/server.ts\`: the handler in \`defineModule(contract, { handlers: { ${action}: (input, ctx) => Effect.gen(...) } })\`. Write through \`ctx.sql\` (row-level security applies), emit events with \`ctx.emit\`, reach other modules only through their contracts' actions and events.`,
116
+ `3. \`modules/${module}/policy.cedar\`: \`@id("${qualified}") permit (principal, action == <Module>::Action::"${action}", resource is <Module>::<Entity>) when { ... };\`. Without a permit the action is refused on every surface.`,
117
+ `4. A migration in \`modules/${module}/migrations/\` if the action needs new columns (additive; \`eloxiv setup\` runs it), then \`eloxiv generate\`.`,
118
+ `5. If the module has skills, add an eval case for the action (\`skills/<skill>/evals.json\`) and run \`eloxiv eval\`.`,
119
+ "",
120
+ "## Prove it",
121
+ "",
122
+ `- A test calling it through the typed client (or \`eloxiv call ${qualified} --input '{...}'\` against \`eloxiv dev\`): the result, the row, a refused caller, and a retry with the same idempotency key replayed.`,
123
+ "- `eloxiv doctor` (module boundaries, ambient credentials) and `eloxiv typecheck`.",
124
+ "",
125
+ ].join("\n");
126
+ }
127
+ case "module": {
128
+ const name = options.name ?? "tasks";
129
+ if (!/^[a-z][a-z0-9_]{0,40}$/.test(name))
130
+ throw new CliError({ message: `A module's name is lower case letters, digits and _ (got ${name})` });
131
+ return [
132
+ `# Blueprint: the module \`${name}\``,
133
+ "",
134
+ `A module is a code, schema and ownership boundary: its own PostgreSQL schema and roles, reached by other modules only through its contract (actions, events, entity references). Worked example: \`eloxiv info hello --markdown\` (or read \`modules/hello\` if installed). Contract: docs/contracts/module-manifest.md.`,
135
+ "",
136
+ "## Files",
137
+ "",
138
+ `1. \`modules/${name}/schema.ts\`: the Drizzle tables in \`pgSchema("${name}")\`, each with an organisation column. Fields are declared here once (decision 9).`,
139
+ `2. \`modules/${name}/contract.ts\`: entities over the tables (\`defineEntity(table, { name, cedarType, policyAttributes })\` from \`@eloxiv/contracts/drizzle\`), actions (\`eloxiv blueprint action\`), events, then \`export const ${identifier(name)} = defineModuleContract({ name: "${name}", entities, actions, events, ... })\`. Export only contract values and types: other modules import this file.`,
140
+ `3. \`modules/${name}/policy.cedar\`: permits for each action and for reads (what each person's replica holds).`,
141
+ `4. \`modules/${name}/migrations/\`: \`drizzle-kit generate\` writes them from \`schema.ts\` with a \`drizzle.config.ts\` (\`0000_<name>.sql\` first, with its \`meta/\` journal); run it in \`modules/${name}\` with the app's own copy (\`../../node_modules/.bin/drizzle-kit generate\`). Every later migration is additive.`,
142
+ `5. \`modules/${name}/server.ts\`: \`export const ${identifier(name)}Module = defineModule(${identifier(name)}, { policy, migrationsDir, handlers })\`.`,
143
+ `6. \`modules/${name}/sync.ts\`: named queries over its tables (through \`@eloxiv/client\`, never \`@rocicorp/zero\`).`,
144
+ `7. Optional: \`modules/${name}/skills/<skill>/SKILL.md\` and its evals, declared in the contract's \`skills\`.`,
145
+ "",
146
+ "## Wire it",
147
+ "",
148
+ `- Add the module to the composition: as a registry item, \`eloxiv add\` does it; as the app's own, list its name in \`eloxiv.json\`'s \`modules\` (\`"modules": ["${name}"]\`: the composition takes the contract export \`${identifier(name)}\` and the server export \`${identifier(name)}Module\`) and run \`eloxiv generate\`.`,
149
+ "- `eloxiv generate` (its `sync.gen.ts` and the app's sync schema), `eloxiv setup` (schema, roles, migrations), `eloxiv doctor`, `eloxiv typecheck`.",
150
+ "",
151
+ "## Prove it",
152
+ "",
153
+ "- An action test through the typed client; a sync test that a second person's replica holds only what policy lets them read; `eloxiv eval` for its skills.",
154
+ "",
155
+ ].join("\n");
156
+ }
157
+ case "make": {
158
+ const name = options.name ?? "tracker";
159
+ return [
160
+ `# Blueprint: a MAKE module (\`${name}\`), drafted for the sandbox`,
161
+ "",
162
+ "A MAKE module is made by a person or their agent at run time, not shipped in the repository: the same manifest as a built-in module, with a capability profile, its handlers run in the sandbox (QuickJS in WebAssembly, no ambient authority). It goes draft → preview → approve → install → version → roll back. Contract: docs/contracts/sandbox.md.",
163
+ "",
164
+ "## The draft",
165
+ "",
166
+ "1. The manifest in its JSON form: name, entities, actions (input and output as JSON Schema), permission vocabulary, an optional view.",
167
+ "2. A Cedar policy for its actions and reads.",
168
+ "3. The capability profile: which host functions its handlers get (`sql`, through the guard over PostgreSQL's parse tree; `emit`; `call` of other modules' read-only actions; `setting`). Ask for no more than it needs: the approver sees it.",
169
+ "4. Additive, rollback-safe migrations (`CREATE TABLE`, `ADD COLUMN`, `CREATE INDEX`).",
170
+ "5. Its code as one ES module exporting a handler per action; no imports, no network, no clock beyond what the host gives.",
171
+ "",
172
+ "## The lifecycle",
173
+ "",
174
+ "- Through the agent (`make.*` actions) or the typed client: draft, preview in its own preview database, ask to install; an organisation administrator approves (seeing the source hash and the profile); then it is served at `POST /make/actions/<module>.<action>` and as agent tools.",
175
+ "- A new version is additive; a rollback runs the previous version's code over the same schema.",
176
+ "",
177
+ ].join("\n");
178
+ }
179
+ }
180
+ };
181
+ /** `eloxiv info @eloxiv/<package>`: the app's installed package. */
182
+ export const packageInfo = (dir, name) => {
183
+ const pkg = installedPackages(dir).find((p) => p.name === name);
184
+ if (pkg === undefined) {
185
+ throw new CliError({
186
+ message: `${name} is not installed in ${dir} (node_modules/${name}); installed: ${installedPackages(dir)
187
+ .map((p) => p.name)
188
+ .join(", ") || "none"}`,
189
+ });
190
+ }
191
+ const manifest = JSON.parse(readFileSync(join(pkg.dir, "package.json"), "utf8"));
192
+ const entryPoints = Object.keys(manifest.exports ?? { ".": "" });
193
+ const exports = [];
194
+ /** The names a module file exports, following `export * from "./x"` into the package's own files (three levels). */
195
+ const collect = (file, depth) => {
196
+ const text = readFileSync(file, "utf8");
197
+ for (const m of text.matchAll(/^export\s+(?:declare\s+)?(?:async\s+)?(?:const|function\*?|class|interface|type|enum)\s+([\w$]+)/gm))
198
+ exports.push(m[1]);
199
+ for (const m of text.matchAll(/^export\s+(?:type\s+)?\{([^}]*)\}(?:\s+from)?/gm)) {
200
+ for (const part of m[1].split(",")) {
201
+ const local = part
202
+ .trim()
203
+ .split(/\s+as\s+/)
204
+ .pop()
205
+ ?.replace(/^type\s+/, "");
206
+ if (local)
207
+ exports.push(local);
208
+ }
209
+ }
210
+ for (const m of text.matchAll(/^export\s+\*\s+from\s+["']([^"']+)["']/gm)) {
211
+ const target = join(file, "..", m[1]);
212
+ if (depth > 0 && m[1].startsWith(".") && existsSync(target))
213
+ collect(target, depth - 1);
214
+ else
215
+ exports.push(`* from ${m[1]}`);
216
+ }
217
+ };
218
+ const main = [join(pkg.dir, "src", "index.ts"), join(pkg.dir, "dist", "index.d.ts")].find((f) => existsSync(f));
219
+ if (main !== undefined)
220
+ collect(main, 3);
221
+ const docsDir = join(pkg.dir, "docs");
222
+ return {
223
+ name: pkg.name,
224
+ version: pkg.version,
225
+ directory: pkg.dir,
226
+ entryPoints,
227
+ exports: [...new Set(exports)],
228
+ readme: existsSync(join(pkg.dir, "README.md")),
229
+ docs: existsSync(docsDir)
230
+ ? `${readdirSync(docsDir).length} files in docs/`
231
+ : `its source's doc comments: eloxiv docs search <words>`,
232
+ };
233
+ };
234
+ export const formatPackageInfo = (info) => [
235
+ `${info.name}@${info.version}`,
236
+ ` source ${info.directory}`,
237
+ ` entry points ${info.entryPoints.map((e) => (e === "." ? info.name : `${info.name}/${e.replace(/^\.\//, "")}`)).join(", ")}`,
238
+ ` exports ${info.exports.length === 0 ? "(none found in src/index.ts)" : info.exports.join(", ")}`,
239
+ ` docs ${info.readme ? "README.md; " : ""}${info.docs}`,
240
+ ].join("\n");
241
+ //# sourceMappingURL=Blueprint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Blueprint.js","sourceRoot":"","sources":["../src/Blueprint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAU,CAAA;AAGvF,gHAAgH;AAChH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,YAAY,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,yBAAyB,EAAE;IAC7D,gBAAgB,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,6BAA6B,EAAE;IACzE,iBAAiB,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,8BAA8B,EAAE;IAC5E,cAAc,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,2BAA2B,EAAE;IAC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AC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;IACxG,kBAAkB,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE;CACjE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * WCAG contrast of two `#rrggbb` or `oklch()` colours, measured as ThemeTokens measures it (`@eloxiv/shell-core`'s
3
+ * `contrastRatio`, the same OKLab matrices; the CLI may not depend on shell-core, so the arithmetic is repeated).
4
+ */
5
+ export declare const contrastRatio: (a: string, b: string) => number | undefined;
6
+ export interface BrandColor {
7
+ /** `#rrggbb`, or the `oklch(...)` it was written as. */
8
+ readonly value: string;
9
+ readonly count: number;
10
+ /** Custom properties that hold it (`--brand-primary`). */
11
+ readonly names: ReadonlyArray<string>;
12
+ }
13
+ export interface BrandReport {
14
+ readonly sources: ReadonlyArray<string>;
15
+ readonly colors: ReadonlyArray<BrandColor>;
16
+ readonly fonts: ReadonlyArray<{
17
+ readonly family: string;
18
+ readonly count: number;
19
+ }>;
20
+ /** Custom properties as declared (the last value wins). */
21
+ readonly variables: Readonly<Record<string, string>>;
22
+ readonly themeColor?: string;
23
+ /** Theme token overrides (light scheme) and font stacks, with the contrast of each foreground pair. */
24
+ readonly proposal: {
25
+ readonly colors: Readonly<Record<string, string>>;
26
+ readonly fonts: {
27
+ readonly sans?: string;
28
+ readonly mono?: string;
29
+ };
30
+ readonly contrast: ReadonlyArray<{
31
+ readonly pair: string;
32
+ readonly ratio: number | undefined;
33
+ readonly passes: boolean;
34
+ }>;
35
+ };
36
+ }
37
+ /** A CSS colour as `#rrggbb` (hex, rgb(), hsl()), its `oklch(...)` text, or undefined for anything else. */
38
+ export declare const normalizeColor: (raw: string) => string | undefined;
39
+ /** Read every source and propose theme overrides. */
40
+ export declare const extractBrand: (sources: ReadonlyArray<string>, cwd: string) => Promise<BrandReport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