@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,288 @@
1
+ /**
2
+ * Compatibility migrations (docs/cli.md, "Compatibility migrations"): a registry item's version can declare what it
3
+ * moved, so apps that import it keep building after an update.
4
+ *
5
+ * "migrations": [{ "since": "0.5.0", "note": "...", "moves": [
6
+ * { "from": "./modules/hello/contract.ts", "symbol": "greet", "to": "./modules/hello/api.ts", "as": "greetPerson" },
7
+ * { "from": "@eloxiv/kernel", "symbol": "runServer", "to": "@eloxiv/kernel/runtime/bun" },
8
+ * { "from": "./shell-foldkit/src/old.css", "to": "./shell-foldkit/src/theme.css" } ] }]
9
+ *
10
+ * A move names a module (`./` and a path from the app's root, or a package specifier) and optionally one of its
11
+ * exports; `to` is where it now lives and `as` its new name. `eloxiv update` applies the migrations of every version
12
+ * it moves an item past (`since` after the installed version, up to the new one) to the app's own files: an import of
13
+ * a moved module is pointed at the new one; a moved export is imported from its new module under its old local name
14
+ * (`import { greetPerson as greet }`), so no other line of the file changes; a stylesheet's `@import` follows its
15
+ * file. What a codemod cannot rewrite safely (a namespace import of a module an export left) is reported for a
16
+ * person or agent to finish. `eloxiv migrate` applies them again (code written since), `--dossier` prints a portable
17
+ * migration brief, and `eloxiv doctor` fails while an app file still imports something a migration moved.
18
+ */
19
+ import { parse } from "@babel/parser";
20
+ import { lstatSync, readdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
21
+ import { dirname, extname, join, relative, resolve, sep } from "node:path";
22
+ import { Schema } from "effect";
23
+ export const Move = Schema.Struct({
24
+ /** The module that held it: `./<path from the app's root>` or a package specifier. */
25
+ from: Schema.String,
26
+ /** One export of `from` that moved; without it, the whole module moved. */
27
+ symbol: Schema.optional(Schema.String),
28
+ /** Where it now lives (the same as `from` for a rename). */
29
+ to: Schema.String,
30
+ /** The export's new name (default: `symbol`). */
31
+ as: Schema.optional(Schema.String),
32
+ });
33
+ export const Migration = Schema.Struct({
34
+ /** The version that made the change: applied when an app moves from an earlier version to this one or later. */
35
+ since: Schema.String,
36
+ moves: Schema.optional(Schema.Array(Move)),
37
+ /** What a person or agent must still do by hand (shown by update, migrate and the dossier). */
38
+ note: Schema.optional(Schema.String),
39
+ });
40
+ /** Numeric, dot-separated comparison; a prerelease (`-x`) sorts before its release. */
41
+ export const compareVersions = (a, b) => {
42
+ const [mainA = "", preA] = a.split("-", 2);
43
+ const [mainB = "", preB] = b.split("-", 2);
44
+ const pa = mainA.split(".").map(Number);
45
+ const pb = mainB.split(".").map(Number);
46
+ for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
47
+ const d = (pa[i] ?? 0) - (pb[i] ?? 0);
48
+ if (d !== 0)
49
+ return d;
50
+ }
51
+ if (preA === undefined)
52
+ return preB === undefined ? 0 : 1;
53
+ if (preB === undefined)
54
+ return -1;
55
+ return preA.localeCompare(preB);
56
+ };
57
+ /** The migrations of versions after `from` up to and including `to` (`from` undefined: every one up to `to`). */
58
+ export const migrationsBetween = (migrations, from, to) => migrations
59
+ .filter((m) => (from === undefined || compareVersions(m.since, from) > 0) && compareVersions(m.since, to) <= 0)
60
+ .sort((a, b) => compareVersions(a.since, b.since));
61
+ const SOURCE = new Set([".ts", ".tsx", ".mts", ".cts", ".js", ".mjs", ".jsx", ".css"]);
62
+ const SKIP = new Set(["node_modules", "dist", ".eloxiv", ".git", "target", ".vite"]);
63
+ /** The app's own source files a migration may rewrite (relative paths), skipping `exclude` and symbolic links. */
64
+ export const appSources = (dir, exclude = new Set()) => {
65
+ const out = [];
66
+ const walk = (sub) => {
67
+ for (const name of readdirSync(join(dir, sub))) {
68
+ if (SKIP.has(name) || name.startsWith("."))
69
+ continue;
70
+ const rel = sub === "" ? name : `${sub}/${name}`;
71
+ // Never through a symbolic link: a linked directory may be another checkout's, a linked file anyone's.
72
+ const info = lstatSync(join(dir, rel), { throwIfNoEntry: false });
73
+ if (info === undefined || info.isSymbolicLink())
74
+ continue;
75
+ if (info.isDirectory())
76
+ walk(rel);
77
+ else if (SOURCE.has(extname(name)) && !exclude.has(rel) && info.size < 2_000_000)
78
+ out.push(rel);
79
+ }
80
+ };
81
+ walk("");
82
+ return out;
83
+ };
84
+ const stripExtension = (path) => path.replace(/\.(ts|tsx|mts|cts|js|mjs|jsx)$/, "");
85
+ /** Whether `specifier`, written in the app file `file`, names the module `module` (a move's `from`). */
86
+ const names = (file, specifier, module) => {
87
+ if (!module.startsWith("./"))
88
+ return specifier === module;
89
+ if (!specifier.startsWith("."))
90
+ return false;
91
+ const target = relative(".", join(dirname(file), specifier))
92
+ .split(sep)
93
+ .join("/");
94
+ const wanted = module.slice(2);
95
+ return target === wanted || (extname(wanted) !== ".css" && stripExtension(target) === stripExtension(wanted));
96
+ };
97
+ /** How the app file `file` writes an import of `module` (a move's `to`). */
98
+ const specifierFor = (file, module) => {
99
+ if (!module.startsWith("./"))
100
+ return module;
101
+ const path = relative(dirname(file), module.slice(2)).split(sep).join("/");
102
+ return path.startsWith(".") ? path : `./${path}`;
103
+ };
104
+ const CSS_IMPORT = /@import\s+(?:url\(\s*)?(["'])([^"']+)\1/g;
105
+ const lineAt = (text, index) => text.slice(0, index).split("\n").length;
106
+ /** The name an import or export specifier refers to (an identifier, or a string literal `"a-b"`). */
107
+ const nameOf = (node) => node.type === "StringLiteral" ? String(node.value) : (node.name ?? "");
108
+ const PARSE_PLUGINS = {
109
+ ts: ["typescript"],
110
+ tsx: ["typescript", "jsx"],
111
+ js: ["jsx"],
112
+ };
113
+ /**
114
+ * Apply `moves` to one file's text: returns the new text and what changed. The file is parsed (Babel's parser, with
115
+ * TypeScript and JSX), and only the spans of real import and export declarations are rewritten; every rewrite keeps
116
+ * the file's local names, so no other line changes. A file that does not parse is left as it is and reported.
117
+ */
118
+ export const migrateText = (file, text, moves) => {
119
+ const rewrites = [];
120
+ const changes = [];
121
+ if (extname(file) === ".css") {
122
+ for (const match of text.matchAll(CSS_IMPORT)) {
123
+ const move = moves.find((m) => m.symbol === undefined && names(file, match[2], m.from));
124
+ if (move === undefined)
125
+ continue;
126
+ const start = match.index + match[0].lastIndexOf(match[2]);
127
+ rewrites.push({ start, end: start + match[2].length, text: specifierFor(file, move.to) });
128
+ changes.push({
129
+ file,
130
+ line: lineAt(text, match.index),
131
+ kind: "module",
132
+ detail: `@import ${match[2]} → ${specifierFor(file, move.to)}`,
133
+ });
134
+ }
135
+ return { text: apply(text, rewrites), changes };
136
+ }
137
+ const ext = extname(file).slice(1);
138
+ let program;
139
+ try {
140
+ program = parse(text, {
141
+ sourceType: "module",
142
+ // Declarations Babel finds wrong but can still read (a name imported twice) are the compiler's to report.
143
+ errorRecovery: true,
144
+ plugins: PARSE_PLUGINS[ext === "tsx" ? "tsx" : ext.startsWith("ts") || ext === "mts" || ext === "cts" ? "ts" : "js"] ??
145
+ [],
146
+ }).program;
147
+ }
148
+ catch (e) {
149
+ return {
150
+ text,
151
+ changes: [
152
+ {
153
+ file,
154
+ line: 1,
155
+ kind: "manual",
156
+ detail: `could not be parsed (${e instanceof Error ? e.message : String(e)}): migrate its imports by hand`,
157
+ },
158
+ ],
159
+ };
160
+ }
161
+ for (const node of program.body) {
162
+ if (node.type !== "ImportDeclaration" &&
163
+ node.type !== "ExportNamedDeclaration" &&
164
+ node.type !== "ExportAllDeclaration")
165
+ continue;
166
+ const source = node.source;
167
+ if (source === null || source === undefined)
168
+ continue;
169
+ const specifier = source.value;
170
+ const relevant = moves.filter((m) => names(file, specifier, m.from));
171
+ if (relevant.length === 0)
172
+ continue;
173
+ const line = node.loc?.start.line ?? lineAt(text, node.start ?? 0);
174
+ const quote = text[source.start] === "'" ? "'" : '"';
175
+ const q = (value) => `${quote}${value}${quote}`;
176
+ const semi = text[node.end - 1] === ";" ? ";" : "";
177
+ const whole = relevant.find((m) => m.symbol === undefined);
178
+ const symbolMoves = relevant.filter((m) => m.symbol !== undefined);
179
+ const target = whole === undefined ? specifier : specifierFor(file, whole.to);
180
+ const typeOnly = (node.type === "ImportDeclaration" ? node.importKind : node.exportKind) === "type" ? " type" : "";
181
+ const keyword = node.type === "ImportDeclaration" ? "import" : "export";
182
+ if (node.type === "ExportAllDeclaration") {
183
+ if (whole === undefined)
184
+ continue;
185
+ rewrites.push({ start: source.start, end: source.end, text: q(target) });
186
+ changes.push({ file, line, kind: "module", detail: `${specifier} → ${target}` });
187
+ continue;
188
+ }
189
+ const specifiers = node.specifiers;
190
+ // For an import: the name in the module and the local binding; for a re-export: the name and the exported one.
191
+ const named = specifiers
192
+ .filter((sp) => sp.type === "ImportSpecifier" || sp.type === "ExportSpecifier")
193
+ .map((sp) => ({
194
+ sp,
195
+ name: nameOf(sp.type === "ImportSpecifier" ? sp.imported : sp.local),
196
+ binding: nameOf(sp.type === "ImportSpecifier" ? sp.local : sp.exported),
197
+ type: sp.importKind === "type" || sp.exportKind === "type",
198
+ }));
199
+ const moved = named.flatMap((n) => {
200
+ const move = symbolMoves.find((m) => m.symbol === n.name);
201
+ return move === undefined ? [] : [{ n, move }];
202
+ });
203
+ if (moved.length === 0 && whole === undefined) {
204
+ // A namespace import: its uses of a moved export (`K.runServer`) are left for a person.
205
+ const namespace = specifiers.find((sp) => sp.type === "ImportNamespaceSpecifier")?.local?.name;
206
+ const used = symbolMoves.filter((m) => namespace !== undefined && new RegExp(`(^|[^\\w$.])${namespace}\\s*\\.\\s*${m.symbol}\\b`).test(text));
207
+ if (used.length > 0) {
208
+ changes.push({
209
+ file,
210
+ line,
211
+ kind: "manual",
212
+ detail: `${used.map((m) => `${namespace}.${m.symbol}`).join(", ")}: ${used.map((m) => `${m.symbol} moved to ${m.to}${m.as === undefined ? "" : ` as ${m.as}`}`).join("; ")}; change these uses by hand`,
213
+ });
214
+ }
215
+ continue;
216
+ }
217
+ const raw = (sp) => text.slice(sp.start, sp.end);
218
+ const keep = named.filter((n) => !moved.some((m) => m.n === n));
219
+ const head = specifiers
220
+ .filter((sp) => sp.type === "ImportDefaultSpecifier" ||
221
+ sp.type === "ImportNamespaceSpecifier" ||
222
+ sp.type === "ExportNamespaceSpecifier")
223
+ .map(raw);
224
+ const parts = [];
225
+ const clause = [...head, ...(keep.length > 0 ? [`{ ${keep.map((k) => raw(k.sp)).join(", ")} }`] : [])].join(", ");
226
+ if (clause !== "")
227
+ parts.push(`${keyword}${typeOnly} ${clause} from ${q(target)}`);
228
+ else if (specifiers.length === 0 && node.type === "ImportDeclaration")
229
+ parts.push(`import ${q(target)}`);
230
+ for (const { n, move } of moved) {
231
+ const now = move.as ?? move.symbol;
232
+ const toSpecifier = specifierFor(file, move.to);
233
+ const binding = now === n.binding ? now : `${now} as ${n.binding}`;
234
+ parts.push(`${keyword}${typeOnly} { ${n.type ? "type " : ""}${binding} } from ${q(toSpecifier)}`);
235
+ changes.push({ file, line, kind: "symbol", detail: `${n.name} from ${specifier} → ${now} from ${toSpecifier}` });
236
+ }
237
+ if (whole !== undefined && (keep.length > 0 || head.length > 0 || specifiers.length === 0)) {
238
+ changes.push({ file, line, kind: "module", detail: `${specifier} → ${target}` });
239
+ }
240
+ rewrites.push({ start: node.start, end: node.end, text: parts.map((p) => `${p}${semi}`).join("\n") });
241
+ }
242
+ return { text: apply(text, rewrites), changes };
243
+ };
244
+ const apply = (text, rewrites) => {
245
+ let out = text;
246
+ for (const r of [...rewrites].sort((a, b) => b.start - a.start))
247
+ out = out.slice(0, r.start) + r.text + out.slice(r.end);
248
+ return out;
249
+ };
250
+ /**
251
+ * Whether the app file `path` may be written: a regular file, not a symbolic link, whose real path is inside the
252
+ * app's (the CLI's one rule for writes, as `Files.ts`'s `safeAppPath` applies it).
253
+ */
254
+ const writableInside = (root, path) => {
255
+ const info = lstatSync(path, { throwIfNoEntry: false });
256
+ if (info === undefined || info.isSymbolicLink() || !info.isFile())
257
+ return false;
258
+ const real = realpathSync(path);
259
+ return real.startsWith(realpathSync(root) + sep);
260
+ };
261
+ /**
262
+ * Apply each item's migrations to the app's own files (`exclude`: files the caller writes itself). With `dryRun`
263
+ * nothing is written; the changes are what would be.
264
+ */
265
+ export const applyMigrations = (dir, pending, options) => {
266
+ const withMoves = pending.filter((p) => (p.migration.moves ?? []).length > 0);
267
+ if (withMoves.length === 0)
268
+ return [];
269
+ const changes = [];
270
+ for (const file of appSources(resolve(dir), options.exclude)) {
271
+ const path = join(dir, file);
272
+ let text = readFileSync(path, "utf8");
273
+ const original = text;
274
+ for (const { item, migration } of withMoves) {
275
+ const result = migrateText(file, text, migration.moves ?? []);
276
+ text = result.text;
277
+ for (const change of result.changes)
278
+ changes.push(Object.assign({}, change, { item, since: migration.since }));
279
+ }
280
+ if (!options.dryRun && text !== original && writableInside(dir, path))
281
+ writeFileSync(path, text);
282
+ }
283
+ return changes;
284
+ };
285
+ export const formatMigrationChanges = (changes, dryRun) => changes.map((c) => c.kind === "manual"
286
+ ? ` MANUAL ${c.file}:${c.line} ${c.detail} (${c.item} ${c.since})`
287
+ : ` ${dryRun ? "would migrate" : "migrated"} ${c.file}:${c.line} ${c.detail} (${c.item} ${c.since})`);
288
+ //# sourceMappingURL=Migrate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Migrate.js","sourceRoot":"","sources":["../src/Migrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,KAAK,EAAsB,MAAM,eAAe,CAAA;AACzD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC3F,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC;IAChC,sFAAsF;IACtF,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,2EAA2E;IAC3E,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACtC,4DAA4D;IAC5D,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,iDAAiD;IACjD,EAAE,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;CACnC,CAAC,CAAA;AAGF,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC;IACrC,gHAAgH;IAChH,KAAK,EAAE,MAAM,CAAC,MAAM;IACpB,KAAK,EAAE,MAAM,CAAC,QAAQ,C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C,OAAO,CAAC,MAAM,IAAI,IAAI,KAAK,QAAQ,IAAI,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC;YAAE,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAClG,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,OAAuC,EAAE,MAAe,EAAE,EAAE,CACjG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAChB,CAAC,CAAC,IAAI,KAAK,QAAQ;IACjB,CAAC,CAAC,eAAe,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,GAAG;IACtE,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,GAAG,CACxG,CAAA"}
@@ -0,0 +1,36 @@
1
+ import { Command } from "effect/cli";
2
+ import { Effect, FileSystem, Path } from "effect";
3
+ import { CliError } from "./Errors.ts";
4
+ import { type McpHost } from "./Mcp.ts";
5
+ export interface PluginReport {
6
+ readonly plugin: string;
7
+ readonly version: string;
8
+ readonly skills: ReadonlyArray<string>;
9
+ readonly servers: ReadonlyArray<string>;
10
+ /** What was not imported, and why. */
11
+ readonly skipped: ReadonlyArray<{
12
+ readonly what: string;
13
+ readonly why: string;
14
+ }>;
15
+ }
16
+ /** The YAML frontmatter's `key: value` lines (strings, quoted or not): all a skill's header needs. */
17
+ export declare const frontmatterOf: (document: string) => Readonly<Record<string, string>>;
18
+ /** Whether a URL carries a credential: a user or password, or a query parameter named for one. */
19
+ export declare const carriesCredential: (url: string) => boolean;
20
+ export declare const importPlugin: (dir: string, source: string, options: {
21
+ readonly hosts: ReadonlyArray<McpHost>;
22
+ readonly dryRun: boolean;
23
+ readonly replace?: boolean;
24
+ }) => Effect.Effect<{
25
+ plugin: string;
26
+ version: string;
27
+ skills: string[];
28
+ servers: string[];
29
+ skipped: {
30
+ what: string;
31
+ why: string;
32
+ }[];
33
+ }, CliError | import("effect/PlatformError").PlatformError, FileSystem.FileSystem | Path.Path>;
34
+ export declare const formatPlugin: (report: PluginReport, dryRun: boolean) => string;
35
+ export declare const pluginCommand: Command.Command<"plugin", {}, {}, CliError | import("effect/PlatformError").PlatformError, FileSystem.FileSystem | Path.Path>;
36
+ //# sourceMappingURL=Plugins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Plugins.d.ts","sourceRoot":"","sources":["../src/Plugins.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAY,OAAO,EAAQ,MAAM,YAAY,CAAA;AACpD,OAAO,EAAW,MAAM,EAAE,UAAU,EAAU,IAAI,EAAE,MAAM,QAAQ,CAAA;AAElE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,OAAO,EAA6B,KAAK,OAAO,EAAE,MAAM,UAAU,CAAA;AAMlE,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IACtC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IACvC,sCAAsC;IACtC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACjF;AAED,sGAAsG;AACtG,eAAO,MAAM,aAAa,aAAc,MAAM,KAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EA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