@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.
- package/LICENSE +21 -0
- package/README.md +12 -2
- package/dist/AgentSkills.d.ts +51 -0
- package/dist/AgentSkills.d.ts.map +1 -0
- package/dist/AgentSkills.js +264 -0
- package/dist/AgentSkills.js.map +1 -0
- package/dist/AgentWeb.d.ts +83 -0
- package/dist/AgentWeb.d.ts.map +1 -0
- package/dist/AgentWeb.js +436 -0
- package/dist/AgentWeb.js.map +1 -0
- package/dist/App.d.ts +213 -0
- package/dist/App.d.ts.map +1 -0
- package/dist/App.js +357 -0
- package/dist/App.js.map +1 -0
- package/dist/Blueprint.d.ts +47 -0
- package/dist/Blueprint.d.ts.map +1 -0
- package/dist/Blueprint.js +241 -0
- package/dist/Blueprint.js.map +1 -0
- package/dist/Brand.d.ts +42 -0
- package/dist/Brand.d.ts.map +1 -0
- package/dist/Brand.js +370 -0
- package/dist/Brand.js.map +1 -0
- package/dist/Changelog.d.ts +22 -0
- package/dist/Changelog.d.ts.map +1 -0
- package/dist/Changelog.js +117 -0
- package/dist/Changelog.js.map +1 -0
- package/dist/Cli.d.ts +17 -0
- package/dist/Cli.d.ts.map +1 -0
- package/dist/Cli.js +810 -0
- package/dist/Cli.js.map +1 -0
- package/dist/DbAdmin.d.ts +18 -0
- package/dist/DbAdmin.d.ts.map +1 -0
- package/dist/DbAdmin.js +91 -0
- package/dist/DbAdmin.js.map +1 -0
- package/dist/Dependencies.d.ts +53 -0
- package/dist/Dependencies.d.ts.map +1 -0
- package/dist/Dependencies.js +132 -0
- package/dist/Dependencies.js.map +1 -0
- package/dist/Deploy.d.ts +39 -0
- package/dist/Deploy.d.ts.map +1 -0
- package/dist/Deploy.js +458 -0
- package/dist/Deploy.js.map +1 -0
- package/dist/Docs.d.ts +71 -0
- package/dist/Docs.d.ts.map +1 -0
- package/dist/Docs.js +240 -0
- package/dist/Docs.js.map +1 -0
- package/dist/Doctor.d.ts +56 -0
- package/dist/Doctor.d.ts.map +1 -0
- package/dist/Doctor.js +368 -0
- package/dist/Doctor.js.map +1 -0
- package/dist/Dossier.d.ts +23 -0
- package/dist/Dossier.d.ts.map +1 -0
- package/dist/Dossier.js +92 -0
- package/dist/Dossier.js.map +1 -0
- package/dist/Emit.d.ts +26 -0
- package/dist/Emit.d.ts.map +1 -0
- package/dist/Emit.js +51 -0
- package/dist/Emit.js.map +1 -0
- package/dist/Errors.d.ts +26 -0
- package/dist/Errors.d.ts.map +1 -0
- package/dist/Errors.js +17 -0
- package/dist/Errors.js.map +1 -0
- package/dist/Evals.d.ts +52 -0
- package/dist/Evals.d.ts.map +1 -0
- package/dist/Evals.js +126 -0
- package/dist/Evals.js.map +1 -0
- package/dist/Files.d.ts +47 -0
- package/dist/Files.d.ts.map +1 -0
- package/dist/Files.js +145 -0
- package/dist/Files.js.map +1 -0
- package/dist/Generate.d.ts +80 -0
- package/dist/Generate.d.ts.map +1 -0
- package/dist/Generate.js +310 -0
- package/dist/Generate.js.map +1 -0
- package/dist/Guards.d.ts +45 -0
- package/dist/Guards.d.ts.map +1 -0
- package/dist/Guards.js +530 -0
- package/dist/Guards.js.map +1 -0
- package/dist/Inspect.d.ts +125 -0
- package/dist/Inspect.d.ts.map +1 -0
- package/dist/Inspect.js +270 -0
- package/dist/Inspect.js.map +1 -0
- package/dist/Keychain.d.ts +57 -0
- package/dist/Keychain.d.ts.map +1 -0
- package/dist/Keychain.js +73 -0
- package/dist/Keychain.js.map +1 -0
- package/dist/Lock.d.ts +13 -0
- package/dist/Lock.d.ts.map +1 -0
- package/dist/Lock.js +145 -0
- package/dist/Lock.js.map +1 -0
- package/dist/Mcp.d.ts +91 -0
- package/dist/Mcp.d.ts.map +1 -0
- package/dist/Mcp.js +128 -0
- package/dist/Mcp.js.map +1 -0
- package/dist/Merge.d.ts +18 -0
- package/dist/Merge.d.ts.map +1 -0
- package/dist/Merge.js +43 -0
- package/dist/Merge.js.map +1 -0
- package/dist/Migrate.d.ts +78 -0
- package/dist/Migrate.d.ts.map +1 -0
- package/dist/Migrate.js +288 -0
- package/dist/Migrate.js.map +1 -0
- package/dist/Plugins.d.ts +36 -0
- package/dist/Plugins.d.ts.map +1 -0
- package/dist/Plugins.js +304 -0
- package/dist/Plugins.js.map +1 -0
- package/dist/Postgres.d.ts +73 -0
- package/dist/Postgres.d.ts.map +1 -0
- package/dist/Postgres.js +294 -0
- package/dist/Postgres.js.map +1 -0
- package/dist/Publish.d.ts +23 -0
- package/dist/Publish.d.ts.map +1 -0
- package/dist/Publish.js +59 -0
- package/dist/Publish.js.map +1 -0
- package/dist/Registry.d.ts +539 -0
- package/dist/Registry.d.ts.map +1 -0
- package/dist/Registry.js +340 -0
- package/dist/Registry.js.map +1 -0
- package/dist/Remote.d.ts +90 -0
- package/dist/Remote.d.ts.map +1 -0
- package/dist/Remote.js +1006 -0
- package/dist/Remote.js.map +1 -0
- package/dist/Run.d.ts +120 -0
- package/dist/Run.d.ts.map +1 -0
- package/dist/Run.js +477 -0
- package/dist/Run.js.map +1 -0
- package/dist/SyncGen.d.ts +118 -0
- package/dist/SyncGen.d.ts.map +1 -0
- package/dist/SyncGen.js +392 -0
- package/dist/SyncGen.js.map +1 -0
- package/dist/Update.d.ts +301 -0
- package/dist/Update.d.ts.map +1 -0
- package/dist/Update.js +627 -0
- package/dist/Update.js.map +1 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +42 -0
- package/dist/bin.js.map +1 -0
- package/dist/docs/backlog.md +56 -0
- package/dist/docs/ci.md +277 -0
- package/dist/docs/cli.md +696 -0
- package/dist/docs/connectors/google.md +115 -0
- package/dist/docs/connectors/http-openapi.md +7 -0
- package/dist/docs/connectors/mcp.md +8 -0
- package/dist/docs/connectors/microsoft-graph.md +75 -0
- package/dist/docs/connectors/openai.md +25 -0
- package/dist/docs/connectors/slack.md +162 -0
- package/dist/docs/connectors/workos.md +39 -0
- package/dist/docs/contracts/README.md +173 -0
- package/dist/docs/contracts/action-consent.md +92 -0
- package/dist/docs/contracts/action-registry.md +85 -0
- package/dist/docs/contracts/actor.md +100 -0
- package/dist/docs/contracts/agent-resources.md +90 -0
- package/dist/docs/contracts/agent-runtime.md +257 -0
- package/dist/docs/contracts/approvals.md +126 -0
- package/dist/docs/contracts/audit.md +75 -0
- package/dist/docs/contracts/auth-provider.md +74 -0
- package/dist/docs/contracts/calendar-provider.md +46 -0
- package/dist/docs/contracts/client-sdk.md +245 -0
- package/dist/docs/contracts/collab-document.md +151 -0
- package/dist/docs/contracts/command.md +44 -0
- package/dist/docs/contracts/connections.md +235 -0
- package/dist/docs/contracts/context-accounting.md +50 -0
- package/dist/docs/contracts/daemon.md +243 -0
- package/dist/docs/contracts/db-tx.md +53 -0
- package/dist/docs/contracts/delegation.md +68 -0
- package/dist/docs/contracts/device-control.md +103 -0
- package/dist/docs/contracts/directory-provider.md +36 -0
- package/dist/docs/contracts/directory.md +161 -0
- package/dist/docs/contracts/document-source.md +33 -0
- package/dist/docs/contracts/files.md +115 -0
- package/dist/docs/contracts/flags.md +83 -0
- package/dist/docs/contracts/host.md +68 -0
- package/dist/docs/contracts/http-api.md +43 -0
- package/dist/docs/contracts/ingestion.md +130 -0
- package/dist/docs/contracts/ingress.md +141 -0
- package/dist/docs/contracts/invocation.md +260 -0
- package/dist/docs/contracts/local-client.md +108 -0
- package/dist/docs/contracts/locale.md +56 -0
- package/dist/docs/contracts/machine-identity.md +117 -0
- package/dist/docs/contracts/mail-provider.md +49 -0
- package/dist/docs/contracts/memory.md +53 -0
- package/dist/docs/contracts/messaging.md +40 -0
- package/dist/docs/contracts/metering.md +139 -0
- package/dist/docs/contracts/model-provider.md +84 -0
- package/dist/docs/contracts/module-manifest.md +213 -0
- package/dist/docs/contracts/notification-channel.md +90 -0
- package/dist/docs/contracts/notifications.md +123 -0
- package/dist/docs/contracts/outbox.md +80 -0
- package/dist/docs/contracts/privacy.md +110 -0
- package/dist/docs/contracts/progress.md +52 -0
- package/dist/docs/contracts/query-surface.md +108 -0
- package/dist/docs/contracts/readiness.md +63 -0
- package/dist/docs/contracts/release.md +142 -0
- package/dist/docs/contracts/result-rendering.md +61 -0
- package/dist/docs/contracts/sandbox.md +186 -0
- package/dist/docs/contracts/scheduler.md +148 -0
- package/dist/docs/contracts/screen-context.md +81 -0
- package/dist/docs/contracts/search.md +120 -0
- package/dist/docs/contracts/secrets.md +74 -0
- package/dist/docs/contracts/settings.md +109 -0
- package/dist/docs/contracts/sharing.md +77 -0
- package/dist/docs/contracts/slot.md +48 -0
- package/dist/docs/contracts/space.md +67 -0
- package/dist/docs/contracts/storage-adapter.md +45 -0
- package/dist/docs/contracts/storage-backend.md +56 -0
- package/dist/docs/contracts/sync.md +213 -0
- package/dist/docs/contracts/telemetry.md +80 -0
- package/dist/docs/contracts/theme-tokens.md +50 -0
- package/dist/docs/contracts/tool-source.md +58 -0
- package/dist/docs/contracts/versioning.md +99 -0
- package/dist/docs/contracts/view.md +65 -0
- package/dist/docs/contracts/work-items.md +99 -0
- package/dist/docs/contracts/workflow.md +82 -0
- package/dist/docs/decisions.md +163 -0
- package/dist/docs/example-app.md +192 -0
- package/dist/docs/getting-started.md +927 -0
- package/dist/docs/goal.md +54 -0
- package/dist/docs/parity.md +29 -0
- package/dist/docs/performance.md +129 -0
- package/dist/docs/registry/README.md +74 -0
- package/dist/docs/registry/app.md +38 -0
- package/dist/docs/registry/approvals-ui-foldkit.md +28 -0
- package/dist/docs/registry/calendar-ui-foldkit.md +27 -0
- package/dist/docs/registry/calendar.md +35 -0
- package/dist/docs/registry/chat-ui-foldkit.md +30 -0
- package/dist/docs/registry/desktop-rune.md +49 -0
- package/dist/docs/registry/desktop.md +32 -0
- package/dist/docs/registry/eloxiv-action.md +25 -0
- package/dist/docs/registry/eloxiv-connector.md +25 -0
- package/dist/docs/registry/eloxiv-module.md +25 -0
- package/dist/docs/registry/eloxiv-policy.md +25 -0
- package/dist/docs/registry/eloxiv-view.md +25 -0
- package/dist/docs/registry/hello-ui-foldkit.md +29 -0
- package/dist/docs/registry/hello.md +39 -0
- package/dist/docs/registry/home-ui-foldkit.md +27 -0
- package/dist/docs/registry/home.md +29 -0
- package/dist/docs/registry/inbox-ui-foldkit.md +27 -0
- package/dist/docs/registry/mail-ui-foldkit.md +27 -0
- package/dist/docs/registry/mail.md +34 -0
- package/dist/docs/registry/meeting-prep.md +26 -0
- package/dist/docs/registry/members-ui-foldkit.md +28 -0
- package/dist/docs/registry/mobile.md +37 -0
- package/dist/docs/registry/notes-ui-foldkit.md +27 -0
- package/dist/docs/registry/notes.md +26 -0
- package/dist/docs/registry/people-ui-foldkit.md +28 -0
- package/dist/docs/registry/people.md +38 -0
- package/dist/docs/registry/shell-foldkit.md +34 -0
- package/dist/docs/registry/theme.md +25 -0
- package/dist/docs/registry/ui-conformance.md +30 -0
- package/dist/docs/release.md +100 -0
- package/dist/docs/scaffold.md +826 -0
- package/dist/docs/security/threat-model.md +299 -0
- package/dist/docs/upstream/zero-cache-socket-handoff.md +105 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -3
- package/src/AgentSkills.ts +329 -0
- package/src/AgentWeb.ts +507 -0
- package/src/App.ts +435 -0
- package/src/Blueprint.ts +276 -0
- package/src/Brand.ts +415 -0
- package/src/Changelog.ts +136 -0
- package/src/Cli.ts +1458 -0
- package/src/DbAdmin.ts +115 -0
- package/src/Dependencies.ts +170 -0
- package/src/Deploy.ts +563 -0
- package/src/Docs.ts +309 -0
- package/src/Doctor.ts +424 -0
- package/src/Dossier.ts +148 -0
- package/src/Emit.ts +68 -0
- package/src/Errors.ts +18 -0
- package/src/Evals.ts +153 -0
- package/src/Files.ts +152 -0
- package/src/Generate.ts +402 -0
- package/src/Guards.ts +541 -0
- package/src/Inspect.ts +358 -0
- package/src/Keychain.ts +107 -0
- package/src/Lock.ts +174 -0
- package/src/Mcp.ts +159 -0
- package/src/Merge.ts +70 -0
- package/src/Migrate.ts +331 -0
- package/src/Plugins.ts +347 -0
- package/src/Postgres.ts +353 -0
- package/src/Publish.ts +64 -0
- package/src/Registry.ts +405 -0
- package/src/Remote.ts +1158 -0
- package/src/Run.ts +541 -0
- package/src/SyncGen.ts +570 -0
- package/src/Update.ts +873 -0
- package/src/bin.ts +46 -0
- package/src/index.ts +7 -0
package/src/Cli.ts
ADDED
|
@@ -0,0 +1,1458 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `eloxiv` command-line tool (Effect CLI). See docs/cli.md.
|
|
3
|
+
*
|
|
4
|
+
* eloxiv init <dir> start an app: package.json, tsconfig.json, eloxiv.json
|
|
5
|
+
* eloxiv add <items...> copy registry items into the app, with provenance
|
|
6
|
+
* eloxiv diff [items...] local edits and upstream changes of installed items
|
|
7
|
+
* eloxiv update [items...] three-way merge the registry's latest versions into the app
|
|
8
|
+
* eloxiv update --continue record that the last update's conflicts are resolved
|
|
9
|
+
* eloxiv eject <items...> take items over: diff and update leave them alone
|
|
10
|
+
* eloxiv restore <item> [paths] put an item's locally edited or deleted files back as installed
|
|
11
|
+
* eloxiv info <item> a registry item as published (what it is, needs and installs)
|
|
12
|
+
* eloxiv list the installed items and whether each needs attention
|
|
13
|
+
* eloxiv generate rewrite the modules' sync tables and the composition files
|
|
14
|
+
* eloxiv setup [--seed] set up the app's database: roles, schemas, pending migrations
|
|
15
|
+
* eloxiv doctor check the app's assembly
|
|
16
|
+
* eloxiv clean [--yes] remove build outputs and caches
|
|
17
|
+
* eloxiv login [--url] sign in to a kernel with the device flow
|
|
18
|
+
* eloxiv logout [--url] revoke and forget that sign-in
|
|
19
|
+
* eloxiv whoami [--url] the sign-in and the organisations it acts for
|
|
20
|
+
* eloxiv actions [--url] list the kernel's actions
|
|
21
|
+
* eloxiv call <action> [--input] invoke an action and print its result envelope
|
|
22
|
+
* eloxiv agent <prompt> one turn of your agent, followed to its end
|
|
23
|
+
* eloxiv mcp install|uninstall|status the kernel's MCP server in coding agents' project configuration
|
|
24
|
+
* eloxiv dev | build | start [role] | typecheck run the app with its own tools
|
|
25
|
+
* eloxiv deploy <docker|fly|railway> | check deployment recipes (written, never deployed) and a preflight
|
|
26
|
+
* eloxiv db host <provider> | check [--live] PostgreSQL host recipes and the deployment's URLs checked
|
|
27
|
+
*
|
|
28
|
+
* Exit codes: 0 success (for diff: nothing differs); 1 diff found differences, or update left conflicts
|
|
29
|
+
* or was blocked; 2 the command failed.
|
|
30
|
+
*/
|
|
31
|
+
import { MCP_IDENTITY_PATH, mcpServerName } from "@eloxiv/contracts"
|
|
32
|
+
import { Console, Effect, FileSystem, Option, Path } from "effect"
|
|
33
|
+
import { Argument, Command, Flag } from "effect/cli"
|
|
34
|
+
import { ChildProcess, ChildProcessSpawner } from "effect/process"
|
|
35
|
+
import {
|
|
36
|
+
CLI_VERSION,
|
|
37
|
+
CliError,
|
|
38
|
+
CONFIG_FILE,
|
|
39
|
+
defaultRegistry,
|
|
40
|
+
ExitStatus,
|
|
41
|
+
frameworkDevDependencies,
|
|
42
|
+
generateSyncTables,
|
|
43
|
+
install,
|
|
44
|
+
LOCK_FILE,
|
|
45
|
+
readConfig,
|
|
46
|
+
readLock,
|
|
47
|
+
regenerate,
|
|
48
|
+
sortKeys,
|
|
49
|
+
writeJson,
|
|
50
|
+
type AppConfig,
|
|
51
|
+
} from "./App.ts"
|
|
52
|
+
import { DEPLOY_TARGETS, deployFiles, deployNextSteps, parseEnvFile, preflight } from "./Deploy.ts"
|
|
53
|
+
import { BLUEPRINTS, blueprint, formatPackageInfo, packageInfo, type BlueprintKind } from "./Blueprint.ts"
|
|
54
|
+
import { addEntry, CHANGE_TYPES, formatReleases, listReleases, release } from "./Changelog.ts"
|
|
55
|
+
import { extractBrand, formatBrand } from "./Brand.ts"
|
|
56
|
+
import { agentWebFiles, auditAgentWeb, readAgentWebConfig } from "./AgentWeb.ts"
|
|
57
|
+
import { adminTarget, rows, runSql, schemas, tables } from "./DbAdmin.ts"
|
|
58
|
+
import { DOCS_MAX_RESULTS, formatDocs, searchDocs } from "./Docs.ts"
|
|
59
|
+
import { addCase, evalEntry, promoteTrace } from "./Evals.ts"
|
|
60
|
+
import { dossier, migrate } from "./Dossier.ts"
|
|
61
|
+
import { formatMigrationChanges } from "./Migrate.ts"
|
|
62
|
+
import { skillsCommand } from "./AgentSkills.ts"
|
|
63
|
+
import { clean, doctor, formatDoctor } from "./Doctor.ts"
|
|
64
|
+
import { emitFiles } from "./Emit.ts"
|
|
65
|
+
import { pluginCommand } from "./Plugins.ts"
|
|
66
|
+
import { formatInfo, formatInfoMarkdown, formatList, info, list, restore } from "./Inspect.ts"
|
|
67
|
+
import { formatMcpStatus, installMcp, MCP_HOST_NAMES, mcpStatus, uninstallMcp, type McpHost } from "./Mcp.ts"
|
|
68
|
+
import { checkLive, checkUrls, formatRecipe, PROVIDERS, recipe, type Provider } from "./Postgres.ts"
|
|
69
|
+
import { actions, agent, call, fetchRunEvents, login, logout, mcpServe, resolveKernelUrl, whoami } from "./Remote.ts"
|
|
70
|
+
import { build, dev, runTool, shellDir, start, START_ROLES, typecheck, type Running, type StartRole } from "./Run.ts"
|
|
71
|
+
import {
|
|
72
|
+
continueUpdate,
|
|
73
|
+
diff,
|
|
74
|
+
eject,
|
|
75
|
+
formatContinue,
|
|
76
|
+
formatDiff,
|
|
77
|
+
formatUpdate,
|
|
78
|
+
needsInstall,
|
|
79
|
+
update,
|
|
80
|
+
} from "./Update.ts"
|
|
81
|
+
|
|
82
|
+
export {
|
|
83
|
+
AppConfig,
|
|
84
|
+
CLI_VERSION,
|
|
85
|
+
CliError,
|
|
86
|
+
CONFIG_FILE,
|
|
87
|
+
ExitStatus,
|
|
88
|
+
generateSyncTables,
|
|
89
|
+
install,
|
|
90
|
+
LOCK_FILE,
|
|
91
|
+
parseSpec,
|
|
92
|
+
readLock,
|
|
93
|
+
} from "./App.ts"
|
|
94
|
+
|
|
95
|
+
const cwdFlag = Flag.String("cwd").pipe(
|
|
96
|
+
Flag.withDescription("App directory (default: current directory)"),
|
|
97
|
+
Flag.optional,
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
const noInstallFlag = Flag.Boolean("no-install").pipe(
|
|
101
|
+
Flag.withDescription("Do not run the package manager"),
|
|
102
|
+
Flag.withDefault(false),
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
const jsonFlag = Flag.Boolean("json").pipe(
|
|
106
|
+
Flag.withDescription("Print a machine-readable JSON report"),
|
|
107
|
+
Flag.withDefault(false),
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
/** `eloxiv init --preset`: the items each kind of app starts from (their registry dependencies come with them). */
|
|
111
|
+
export const PRESETS = {
|
|
112
|
+
/** The server, no UI: modules are added to it as the app grows. */
|
|
113
|
+
headless: ["app"],
|
|
114
|
+
/** The server and the web shell (Foldkit, StyleX and Vite: decision 10). */
|
|
115
|
+
web: ["app", "shell-foldkit"],
|
|
116
|
+
/** The server, the web shell and the desktop host (Tauri), which embeds the shell it is built with. */
|
|
117
|
+
desktop: ["app", "shell-foldkit", "desktop"],
|
|
118
|
+
} as const
|
|
119
|
+
|
|
120
|
+
const appDir = (cwd: Option.Option<string>) =>
|
|
121
|
+
Effect.gen(function* () {
|
|
122
|
+
const path = yield* Path.Path
|
|
123
|
+
return path.resolve(Option.getOrElse(cwd, () => process.cwd()))
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
const runInstall = (dir: string) =>
|
|
127
|
+
Effect.gen(function* () {
|
|
128
|
+
yield* Console.log("installing dependencies (pnpm install)")
|
|
129
|
+
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner
|
|
130
|
+
const exitCode = yield* spawner
|
|
131
|
+
.exitCode(ChildProcess.make("pnpm", ["install"], { cwd: dir, stdout: "inherit", stderr: "inherit" }))
|
|
132
|
+
.pipe(Effect.mapError((e) => new CliError({ message: `pnpm install failed: ${String(e)}` })))
|
|
133
|
+
if (exitCode !== ChildProcessSpawner.ExitCode(0)) {
|
|
134
|
+
return yield* new CliError({ message: `pnpm install exited with ${exitCode}` })
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Run the app's server entry (`server/main.ts`, the `app` item's) with `command` on this runtime, with the same
|
|
140
|
+
* runtime flags as this process (so a workspace app resolves the workspace's sources), its output shown as it comes.
|
|
141
|
+
*/
|
|
142
|
+
const runServerEntry = (dir: string, command: string) =>
|
|
143
|
+
Effect.gen(function* () {
|
|
144
|
+
const fs = yield* FileSystem.FileSystem
|
|
145
|
+
const path = yield* Path.Path
|
|
146
|
+
if (!(yield* fs.exists(path.join(dir, "server/main.ts")))) {
|
|
147
|
+
return yield* new CliError({ message: `${dir} has no server/main.ts: add the app item first (eloxiv add app)` })
|
|
148
|
+
}
|
|
149
|
+
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner
|
|
150
|
+
const exitCode = yield* spawner
|
|
151
|
+
.exitCode(
|
|
152
|
+
ChildProcess.make(process.execPath, [...process.execArgv, "server/main.ts", command], {
|
|
153
|
+
cwd: dir,
|
|
154
|
+
stdout: "inherit",
|
|
155
|
+
stderr: "inherit",
|
|
156
|
+
}),
|
|
157
|
+
)
|
|
158
|
+
.pipe(
|
|
159
|
+
Effect.mapError((e) => new CliError({ message: `server/main.ts ${command} could not start: ${String(e)}` })),
|
|
160
|
+
)
|
|
161
|
+
if (exitCode !== ChildProcessSpawner.ExitCode(0)) {
|
|
162
|
+
return yield* new CliError({ message: `server/main.ts ${command} failed (exit ${exitCode})` })
|
|
163
|
+
}
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
const setupCommand = Command.make(
|
|
167
|
+
"setup",
|
|
168
|
+
{
|
|
169
|
+
cwd: cwdFlag,
|
|
170
|
+
seed: Flag.Boolean("seed").pipe(
|
|
171
|
+
Flag.withDescription("Then create the demo organisation and users (server/main.ts prepare)"),
|
|
172
|
+
Flag.withDefault(false),
|
|
173
|
+
),
|
|
174
|
+
},
|
|
175
|
+
Effect.fn(function* ({ cwd, seed }) {
|
|
176
|
+
yield* runServerEntry(yield* appDir(cwd), seed ? "prepare" : "setup")
|
|
177
|
+
}),
|
|
178
|
+
).pipe(
|
|
179
|
+
Command.withDescription(
|
|
180
|
+
"Set up the app's database (ELOXIV_DATABASE_URL, as ELOXIV_ADMIN_DATABASE_URL): roles, schemas, and every pending migration, each checked before it runs; safe to run again",
|
|
181
|
+
),
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
const init = Command.make(
|
|
185
|
+
"init",
|
|
186
|
+
{
|
|
187
|
+
dir: Argument.String("dir").pipe(Argument.withDescription("Directory to create the app in")),
|
|
188
|
+
name: Flag.String("name").pipe(Flag.withDescription("Package name (default: the directory name)"), Flag.optional),
|
|
189
|
+
registry: Flag.String("registry").pipe(
|
|
190
|
+
Flag.withDescription(
|
|
191
|
+
"Registry location: a directory of built items, an https URL, or npm:<package> (default: npm:@eloxiv/registry, the CLI's own dependency; from a checkout, Eloxiv's registry on GitHub)",
|
|
192
|
+
),
|
|
193
|
+
Flag.withDefault(defaultRegistry()),
|
|
194
|
+
),
|
|
195
|
+
preset: Flag.String("preset").pipe(
|
|
196
|
+
Flag.withDescription(
|
|
197
|
+
`Items to add at once: ${Object.entries(PRESETS)
|
|
198
|
+
.map(([preset, items]) => `${preset} (${items.join(", ")})`)
|
|
199
|
+
.join("; ")}`,
|
|
200
|
+
),
|
|
201
|
+
Flag.optional,
|
|
202
|
+
),
|
|
203
|
+
noInstall: noInstallFlag,
|
|
204
|
+
},
|
|
205
|
+
Effect.fn(function* ({ dir, name, registry, preset, noInstall }) {
|
|
206
|
+
const presetItems: ReadonlyArray<string> | undefined = Option.isNone(preset)
|
|
207
|
+
? []
|
|
208
|
+
: (PRESETS as Record<string, ReadonlyArray<string>>)[preset.value]
|
|
209
|
+
if (presetItems === undefined) {
|
|
210
|
+
return yield* new CliError({
|
|
211
|
+
message: `Unknown preset ${Option.getOrElse(preset, () => "")}: one of ${Object.keys(PRESETS).join(", ")}`,
|
|
212
|
+
})
|
|
213
|
+
}
|
|
214
|
+
const fs = yield* FileSystem.FileSystem
|
|
215
|
+
const path = yield* Path.Path
|
|
216
|
+
const target = path.resolve(dir)
|
|
217
|
+
if (yield* fs.exists(path.join(target, CONFIG_FILE)))
|
|
218
|
+
return yield* new CliError({ message: `${target} is already an Eloxiv app` })
|
|
219
|
+
yield* fs.makeDirectory(target, { recursive: true })
|
|
220
|
+
const appName = Option.getOrElse(name, () => path.basename(target))
|
|
221
|
+
yield* writeJson(path.join(target, "package.json"), {
|
|
222
|
+
name: appName,
|
|
223
|
+
version: "0.0.0",
|
|
224
|
+
private: true,
|
|
225
|
+
type: "module",
|
|
226
|
+
scripts: {
|
|
227
|
+
setup: "bun server/main.ts setup",
|
|
228
|
+
seed: "bun server/main.ts seed",
|
|
229
|
+
server: "bun server/main.ts",
|
|
230
|
+
// The shell is the shell-foldkit item (`eloxiv add shell-foldkit`, or a UI item that brings it).
|
|
231
|
+
shell: "cd shell-foldkit && vite",
|
|
232
|
+
typecheck: "tsc -p tsconfig.json --noEmit",
|
|
233
|
+
},
|
|
234
|
+
dependencies: {},
|
|
235
|
+
devDependencies: sortKeys({ typescript: "7.0.2", "@types/node": "24.19.2", ...frameworkDevDependencies() }),
|
|
236
|
+
})
|
|
237
|
+
yield* writeJson(path.join(target, CONFIG_FILE), { name: appName, registry } satisfies AppConfig)
|
|
238
|
+
yield* writeJson(path.join(target, "tsconfig.json"), {
|
|
239
|
+
compilerOptions: {
|
|
240
|
+
target: "es2024",
|
|
241
|
+
lib: ["es2024"],
|
|
242
|
+
module: "nodenext",
|
|
243
|
+
moduleResolution: "nodenext",
|
|
244
|
+
types: ["node"],
|
|
245
|
+
strict: true,
|
|
246
|
+
noUncheckedIndexedAccess: true,
|
|
247
|
+
exactOptionalPropertyTypes: true,
|
|
248
|
+
noImplicitOverride: true,
|
|
249
|
+
noImplicitReturns: true,
|
|
250
|
+
noFallthroughCasesInSwitch: true,
|
|
251
|
+
noPropertyAccessFromIndexSignature: true,
|
|
252
|
+
verbatimModuleSyntax: true,
|
|
253
|
+
allowImportingTsExtensions: true,
|
|
254
|
+
erasableSyntaxOnly: true,
|
|
255
|
+
skipLibCheck: true,
|
|
256
|
+
noEmit: true,
|
|
257
|
+
},
|
|
258
|
+
include: ["server", "modules", "eloxiv.*.ts"],
|
|
259
|
+
})
|
|
260
|
+
yield* fs.writeFileString(path.join(target, ".gitignore"), "node_modules/\ndist/\n.eloxiv/\n")
|
|
261
|
+
yield* fs.writeFileString(
|
|
262
|
+
path.join(target, LOCK_FILE),
|
|
263
|
+
`${JSON.stringify({ lockfileVersion: 1, items: {} }, null, 2)}\n`,
|
|
264
|
+
)
|
|
265
|
+
yield* regenerate(target, { lockfileVersion: 1, items: {} })
|
|
266
|
+
if (presetItems.length === 0) {
|
|
267
|
+
return yield* Console.log(`created ${appName} in ${target}; next: eloxiv add app --cwd ${dir}`)
|
|
268
|
+
}
|
|
269
|
+
yield* Console.log(`created ${appName} in ${target}; adding ${presetItems.join(", ")}`)
|
|
270
|
+
const added = yield* install(target, presetItems, false)
|
|
271
|
+
if (added.length > 0 && !noInstall) yield* runInstall(target)
|
|
272
|
+
}),
|
|
273
|
+
).pipe(Command.withDescription("Create an Eloxiv app (with --preset, assembled from the registry at once)"))
|
|
274
|
+
|
|
275
|
+
const add = Command.make(
|
|
276
|
+
"add",
|
|
277
|
+
{
|
|
278
|
+
items: Argument.String("items").pipe(Argument.withDescription("Registry items to add"), Argument.atLeast(1)),
|
|
279
|
+
cwd: cwdFlag,
|
|
280
|
+
overwrite: Flag.Boolean("overwrite").pipe(
|
|
281
|
+
Flag.withDescription("Replace files that differ"),
|
|
282
|
+
Flag.withDefault(false),
|
|
283
|
+
),
|
|
284
|
+
noInstall: noInstallFlag,
|
|
285
|
+
},
|
|
286
|
+
Effect.fn(function* ({ items, cwd, overwrite, noInstall }) {
|
|
287
|
+
const dir = yield* appDir(cwd)
|
|
288
|
+
const added = yield* install(dir, items, overwrite)
|
|
289
|
+
if (added.length > 0 && !noInstall) yield* runInstall(dir)
|
|
290
|
+
}),
|
|
291
|
+
).pipe(Command.withDescription("Copy registry items into the app and record their provenance"))
|
|
292
|
+
|
|
293
|
+
const diffCommand = Command.make(
|
|
294
|
+
"diff",
|
|
295
|
+
{
|
|
296
|
+
items: Argument.String("items").pipe(
|
|
297
|
+
Argument.withDescription("Installed items to compare (default: all)"),
|
|
298
|
+
Argument.variadic(),
|
|
299
|
+
),
|
|
300
|
+
cwd: cwdFlag,
|
|
301
|
+
json: jsonFlag,
|
|
302
|
+
nameOnly: Flag.Boolean("name-only").pipe(
|
|
303
|
+
Flag.withDescription("List changed files without unified diffs"),
|
|
304
|
+
Flag.withDefault(false),
|
|
305
|
+
),
|
|
306
|
+
},
|
|
307
|
+
Effect.fn(function* ({ items, cwd, json, nameOnly }) {
|
|
308
|
+
const dir = yield* appDir(cwd)
|
|
309
|
+
const report = yield* diff(dir, items)
|
|
310
|
+
yield* Console.log(json ? JSON.stringify(report, null, 2) : formatDiff(report, { patches: !nameOnly }))
|
|
311
|
+
if (report.differences) return yield* new ExitStatus({ code: 1, reason: "differences" })
|
|
312
|
+
}),
|
|
313
|
+
).pipe(
|
|
314
|
+
Command.withDescription(
|
|
315
|
+
"Show local edits (against the installed version) and upstream changes (installed against the registry's latest). Exits 1 when anything differs",
|
|
316
|
+
),
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
const updateCommand = Command.make(
|
|
320
|
+
"update",
|
|
321
|
+
{
|
|
322
|
+
items: Argument.String("items").pipe(
|
|
323
|
+
Argument.withDescription("Installed items to update (default: all)"),
|
|
324
|
+
Argument.variadic(),
|
|
325
|
+
),
|
|
326
|
+
cwd: cwdFlag,
|
|
327
|
+
dryRun: Flag.Boolean("dry-run").pipe(
|
|
328
|
+
Flag.withDescription("Show what would happen and write nothing"),
|
|
329
|
+
Flag.withDefault(false),
|
|
330
|
+
),
|
|
331
|
+
continue: Flag.Boolean("continue").pipe(
|
|
332
|
+
Flag.withDescription("Record that the conflicts of the last update are resolved"),
|
|
333
|
+
Flag.withDefault(false),
|
|
334
|
+
),
|
|
335
|
+
json: jsonFlag,
|
|
336
|
+
noInstall: noInstallFlag,
|
|
337
|
+
},
|
|
338
|
+
Effect.fn(function* ({ items, cwd, dryRun, continue: resume, json, noInstall }) {
|
|
339
|
+
const dir = yield* appDir(cwd)
|
|
340
|
+
if (resume) {
|
|
341
|
+
const report = yield* continueUpdate(dir, items)
|
|
342
|
+
yield* Console.log(json ? JSON.stringify(report, null, 2) : formatContinue(report))
|
|
343
|
+
if (report.unresolved.length > 0) return yield* new ExitStatus({ code: 1, reason: "unresolved conflicts" })
|
|
344
|
+
return
|
|
345
|
+
}
|
|
346
|
+
const report = yield* update(dir, items, { dryRun })
|
|
347
|
+
yield* Console.log(json ? JSON.stringify(report, null, 2) : formatUpdate(report))
|
|
348
|
+
if (!dryRun && !noInstall && needsInstall(report)) yield* runInstall(dir)
|
|
349
|
+
if (report.needsAttention) return yield* new ExitStatus({ code: 1, reason: "needs attention" })
|
|
350
|
+
}),
|
|
351
|
+
).pipe(
|
|
352
|
+
Command.withDescription(
|
|
353
|
+
"Three-way merge the registry's latest version of installed items into the app (base: the installed version). Exits 1 when conflicts remain or an item is blocked",
|
|
354
|
+
),
|
|
355
|
+
)
|
|
356
|
+
|
|
357
|
+
const ejectCommand = Command.make(
|
|
358
|
+
"eject",
|
|
359
|
+
{
|
|
360
|
+
items: Argument.String("items").pipe(Argument.withDescription("Installed items to take over"), Argument.atLeast(1)),
|
|
361
|
+
cwd: cwdFlag,
|
|
362
|
+
undo: Flag.Boolean("undo").pipe(
|
|
363
|
+
Flag.withDescription("Hand the items back to the registry: diff and update manage them again"),
|
|
364
|
+
Flag.withDefault(false),
|
|
365
|
+
),
|
|
366
|
+
},
|
|
367
|
+
Effect.fn(function* ({ items, cwd, undo }) {
|
|
368
|
+
const dir = yield* appDir(cwd)
|
|
369
|
+
const names = yield* eject(dir, items, undo)
|
|
370
|
+
for (const name of names)
|
|
371
|
+
yield* Console.log(
|
|
372
|
+
undo
|
|
373
|
+
? `${name} is managed by the registry again; the next update merges from its installed version`
|
|
374
|
+
: `${name} is app-owned: diff and update leave it alone. Its files are yours to change or replace.`,
|
|
375
|
+
)
|
|
376
|
+
}),
|
|
377
|
+
).pipe(Command.withDescription("Take installed items over so diff and update leave them alone"))
|
|
378
|
+
|
|
379
|
+
const generate = Command.make(
|
|
380
|
+
"generate",
|
|
381
|
+
{ cwd: cwdFlag },
|
|
382
|
+
Effect.fn(function* ({ cwd }) {
|
|
383
|
+
const dir = yield* appDir(cwd)
|
|
384
|
+
const lock = yield* readLock(dir)
|
|
385
|
+
const tables = yield* generateSyncTables(dir, lock)
|
|
386
|
+
const modules = yield* regenerate(dir, lock)
|
|
387
|
+
yield* Console.log(`sync tables: ${tables.length === 0 ? "none" : tables.join(", ")}`)
|
|
388
|
+
yield* Console.log(`composition: ${modules.join(", ")}`)
|
|
389
|
+
}),
|
|
390
|
+
).pipe(
|
|
391
|
+
Command.withDescription(
|
|
392
|
+
"Regenerate each installed module's sync tables (sync.gen.ts, from its Drizzle tables and entities) and the composition files eloxiv.modules.ts, eloxiv.server.ts, eloxiv.schema.ts and eloxiv.sync.ts",
|
|
393
|
+
),
|
|
394
|
+
)
|
|
395
|
+
|
|
396
|
+
const restoreCommand = Command.make(
|
|
397
|
+
"restore",
|
|
398
|
+
{
|
|
399
|
+
item: Argument.String("item").pipe(Argument.withDescription("The installed item")),
|
|
400
|
+
paths: Argument.String("paths").pipe(
|
|
401
|
+
Argument.withDescription("Its files to restore (default: every edited or deleted one)"),
|
|
402
|
+
Argument.variadic(),
|
|
403
|
+
),
|
|
404
|
+
cwd: cwdFlag,
|
|
405
|
+
dryRun: Flag.Boolean("dry-run").pipe(
|
|
406
|
+
Flag.withDescription("Show what would be restored and write nothing"),
|
|
407
|
+
Flag.withDefault(false),
|
|
408
|
+
),
|
|
409
|
+
},
|
|
410
|
+
Effect.fn(function* ({ item, paths, cwd, dryRun }) {
|
|
411
|
+
yield* restore(yield* appDir(cwd), item, paths, { dryRun })
|
|
412
|
+
}),
|
|
413
|
+
).pipe(
|
|
414
|
+
Command.withDescription(
|
|
415
|
+
"Put an item's locally edited or deleted files back as its installed version has them (discarding the edits)",
|
|
416
|
+
),
|
|
417
|
+
)
|
|
418
|
+
|
|
419
|
+
const infoCommand = Command.make(
|
|
420
|
+
"info",
|
|
421
|
+
{
|
|
422
|
+
item: Argument.String("item").pipe(Argument.withDescription("A registry item")),
|
|
423
|
+
version: Flag.String("version").pipe(
|
|
424
|
+
Flag.withDescription("A published version (default: the latest)"),
|
|
425
|
+
Flag.optional,
|
|
426
|
+
),
|
|
427
|
+
registry: Flag.String("registry").pipe(
|
|
428
|
+
Flag.withDescription("Registry location (default: the app's, from eloxiv.json)"),
|
|
429
|
+
Flag.optional,
|
|
430
|
+
),
|
|
431
|
+
cwd: cwdFlag,
|
|
432
|
+
json: jsonFlag,
|
|
433
|
+
markdown: Flag.Boolean("markdown").pipe(
|
|
434
|
+
Flag.withDescription("Print it as a blueprint for a coding agent to apply"),
|
|
435
|
+
Flag.withDefault(false),
|
|
436
|
+
),
|
|
437
|
+
},
|
|
438
|
+
Effect.fn(function* ({ item, version, registry, cwd, json, markdown }) {
|
|
439
|
+
if (item.startsWith("@")) {
|
|
440
|
+
const dir = yield* appDir(cwd)
|
|
441
|
+
const pkg = yield* promised(() => packageInfo(dir, item))
|
|
442
|
+
return yield* Console.log(json ? JSON.stringify(pkg, null, 2) : formatPackageInfo(pkg))
|
|
443
|
+
}
|
|
444
|
+
const report = yield* info(yield* appDir(cwd), item, {
|
|
445
|
+
version: Option.getOrUndefined(version),
|
|
446
|
+
registry: Option.getOrUndefined(registry),
|
|
447
|
+
})
|
|
448
|
+
yield* Console.log(
|
|
449
|
+
json ? JSON.stringify(report, null, 2) : markdown ? formatInfoMarkdown(report) : formatInfo(report),
|
|
450
|
+
)
|
|
451
|
+
}),
|
|
452
|
+
).pipe(
|
|
453
|
+
Command.withDescription(
|
|
454
|
+
"Show a registry item as published (kind, version, dependencies, files, what the composition imports, next steps); nothing of it runs",
|
|
455
|
+
),
|
|
456
|
+
)
|
|
457
|
+
|
|
458
|
+
const listCommand = Command.make(
|
|
459
|
+
"list",
|
|
460
|
+
{
|
|
461
|
+
cwd: cwdFlag,
|
|
462
|
+
kind: Flag.String("kind").pipe(Flag.withDescription("Only items of this kind (module, skill, ...)"), Flag.optional),
|
|
463
|
+
json: jsonFlag,
|
|
464
|
+
},
|
|
465
|
+
Effect.fn(function* ({ cwd, kind, json }) {
|
|
466
|
+
const items = yield* list(yield* appDir(cwd), Option.getOrUndefined(kind))
|
|
467
|
+
yield* Console.log(json ? JSON.stringify(items, null, 2) : formatList(items))
|
|
468
|
+
}),
|
|
469
|
+
).pipe(
|
|
470
|
+
Command.withDescription(
|
|
471
|
+
"List the installed items: kind, version, owner, and whether each is up to date, edited, has an update or conflicts",
|
|
472
|
+
),
|
|
473
|
+
)
|
|
474
|
+
|
|
475
|
+
const doctorCommand = Command.make(
|
|
476
|
+
"doctor",
|
|
477
|
+
{ cwd: cwdFlag, json: jsonFlag },
|
|
478
|
+
Effect.fn(function* ({ cwd, json }) {
|
|
479
|
+
const report = yield* doctor(yield* appDir(cwd))
|
|
480
|
+
yield* Console.log(json ? JSON.stringify(report, null, 2) : formatDoctor(report))
|
|
481
|
+
if (report.failed) return yield* new ExitStatus({ code: 1, reason: "checks failed" })
|
|
482
|
+
}),
|
|
483
|
+
).pipe(
|
|
484
|
+
Command.withDescription(
|
|
485
|
+
"Check the app's assembly: runtime, config, lockfile, each item's files and base, composition, dependencies, sync tables. Exits 1 when a check fails",
|
|
486
|
+
),
|
|
487
|
+
)
|
|
488
|
+
|
|
489
|
+
const cleanCommand = Command.make(
|
|
490
|
+
"clean",
|
|
491
|
+
{
|
|
492
|
+
cwd: cwdFlag,
|
|
493
|
+
yes: Flag.Boolean("yes").pipe(
|
|
494
|
+
Flag.withDescription("Remove them (default: only list them)"),
|
|
495
|
+
Flag.withDefault(false),
|
|
496
|
+
),
|
|
497
|
+
},
|
|
498
|
+
Effect.fn(function* ({ cwd, yes }) {
|
|
499
|
+
yield* clean(yield* appDir(cwd), { yes })
|
|
500
|
+
}),
|
|
501
|
+
).pipe(Command.withDescription("Remove build outputs and caches the tools write again (a dry run unless --yes)"))
|
|
502
|
+
|
|
503
|
+
const urlFlag = Flag.String("url").pipe(
|
|
504
|
+
Flag.withDescription("The kernel's base URL (default: ELOXIV_URL, else the kernel last signed in to)"),
|
|
505
|
+
Flag.optional,
|
|
506
|
+
)
|
|
507
|
+
|
|
508
|
+
const loginCommand = Command.make(
|
|
509
|
+
"login",
|
|
510
|
+
{
|
|
511
|
+
url: urlFlag,
|
|
512
|
+
scope: Flag.String("scope").pipe(
|
|
513
|
+
Flag.withDescription("OAuth scopes, space-separated (default: actions, every action you may call)"),
|
|
514
|
+
Flag.optional,
|
|
515
|
+
),
|
|
516
|
+
},
|
|
517
|
+
Effect.fn(function* ({ url, scope }) {
|
|
518
|
+
yield* login({ url: Option.getOrUndefined(url), scope: Option.getOrUndefined(scope) })
|
|
519
|
+
}),
|
|
520
|
+
).pipe(Command.withDescription("Sign in to a kernel with the OAuth device flow; the token is stored with mode 0600"))
|
|
521
|
+
|
|
522
|
+
const logoutCommand = Command.make(
|
|
523
|
+
"logout",
|
|
524
|
+
{ url: urlFlag },
|
|
525
|
+
Effect.fn(function* ({ url }) {
|
|
526
|
+
yield* logout({ url: Option.getOrUndefined(url) })
|
|
527
|
+
}),
|
|
528
|
+
).pipe(Command.withDescription("Revoke the stored sign-in to a kernel and forget it"))
|
|
529
|
+
|
|
530
|
+
const actionsCommand = Command.make(
|
|
531
|
+
"actions",
|
|
532
|
+
{ url: urlFlag, json: jsonFlag },
|
|
533
|
+
Effect.fn(function* ({ url, json }) {
|
|
534
|
+
yield* actions({ url: Option.getOrUndefined(url), json })
|
|
535
|
+
}),
|
|
536
|
+
).pipe(Command.withDescription("List the kernel's actions (with --json: their input schemas)"))
|
|
537
|
+
|
|
538
|
+
const callCommand = Command.make(
|
|
539
|
+
"call",
|
|
540
|
+
{
|
|
541
|
+
action: Argument.String("action").pipe(Argument.withDescription("The action, e.g. hello.greet")),
|
|
542
|
+
input: Flag.String("input").pipe(
|
|
543
|
+
Flag.withDescription("The input: JSON, or @<file> (@- for standard input)"),
|
|
544
|
+
Flag.withDefault("{}"),
|
|
545
|
+
),
|
|
546
|
+
org: Flag.String("org").pipe(Flag.withDescription("The organisation to act in (x-eloxiv-org)"), Flag.optional),
|
|
547
|
+
idempotencyKey: Flag.String("idempotency-key").pipe(
|
|
548
|
+
Flag.withDescription("Run at most once per key; a retry returns the first call's receipt"),
|
|
549
|
+
Flag.optional,
|
|
550
|
+
),
|
|
551
|
+
url: urlFlag,
|
|
552
|
+
},
|
|
553
|
+
Effect.fn(function* ({ action, input, org, idempotencyKey, url }) {
|
|
554
|
+
yield* call({
|
|
555
|
+
action,
|
|
556
|
+
input,
|
|
557
|
+
url: Option.getOrUndefined(url),
|
|
558
|
+
org: Option.getOrUndefined(org),
|
|
559
|
+
idempotencyKey: Option.getOrUndefined(idempotencyKey),
|
|
560
|
+
})
|
|
561
|
+
}),
|
|
562
|
+
).pipe(
|
|
563
|
+
Command.withDescription(
|
|
564
|
+
"Invoke an action through the kernel's HTTP surface and print the result envelope. Exits 1 when the action fails",
|
|
565
|
+
),
|
|
566
|
+
)
|
|
567
|
+
|
|
568
|
+
const whoamiCommand = Command.make(
|
|
569
|
+
"whoami",
|
|
570
|
+
{ url: urlFlag, json: jsonFlag },
|
|
571
|
+
Effect.fn(function* ({ url, json }) {
|
|
572
|
+
yield* whoami({ url: Option.getOrUndefined(url), json })
|
|
573
|
+
}),
|
|
574
|
+
).pipe(Command.withDescription("Show the kernel, your sign-in and the organisations (with roles) it acts for"))
|
|
575
|
+
|
|
576
|
+
const agentCommand = Command.make(
|
|
577
|
+
"agent",
|
|
578
|
+
{
|
|
579
|
+
prompt: Argument.String("prompt").pipe(Argument.withDescription("What to ask your agent")),
|
|
580
|
+
conversation: Flag.String("conversation").pipe(
|
|
581
|
+
Flag.withDescription("Continue this conversation (its id, printed after each turn)"),
|
|
582
|
+
Flag.optional,
|
|
583
|
+
),
|
|
584
|
+
url: urlFlag,
|
|
585
|
+
json: jsonFlag,
|
|
586
|
+
},
|
|
587
|
+
Effect.fn(function* ({ prompt, conversation, url, json }) {
|
|
588
|
+
yield* agent({ prompt, url: Option.getOrUndefined(url), conversation: Option.getOrUndefined(conversation), json })
|
|
589
|
+
}),
|
|
590
|
+
).pipe(
|
|
591
|
+
Command.withDescription(
|
|
592
|
+
"Ask your agent on the kernel one thing and follow the run to its end: the answer on standard output, tool calls on standard error. Exits 1 when the run does not succeed",
|
|
593
|
+
),
|
|
594
|
+
)
|
|
595
|
+
|
|
596
|
+
const hostsFlag = Flag.String("host").pipe(
|
|
597
|
+
Flag.withDescription(`Agent hosts, comma-separated: ${MCP_HOST_NAMES.join(", ")}, or all (default: claude)`),
|
|
598
|
+
Flag.withDefault("claude"),
|
|
599
|
+
)
|
|
600
|
+
const serverFlag = Flag.String("name").pipe(
|
|
601
|
+
Flag.withDescription("The server's name in the hosts' configuration (default: the app's name, else eloxiv)"),
|
|
602
|
+
Flag.optional,
|
|
603
|
+
)
|
|
604
|
+
|
|
605
|
+
const parseHosts = (value: string) =>
|
|
606
|
+
Effect.gen(function* () {
|
|
607
|
+
const hosts = value === "all" ? MCP_HOST_NAMES : value.split(",").map((host) => host.trim())
|
|
608
|
+
const unknown = hosts.filter((host) => !(MCP_HOST_NAMES as ReadonlyArray<string>).includes(host))
|
|
609
|
+
if (unknown.length > 0)
|
|
610
|
+
return yield* new CliError({
|
|
611
|
+
message: `Unknown host ${unknown.join(", ")}: one of ${MCP_HOST_NAMES.join(", ")}, or all`,
|
|
612
|
+
})
|
|
613
|
+
return hosts as ReadonlyArray<McpHost>
|
|
614
|
+
})
|
|
615
|
+
|
|
616
|
+
/** The MCP server's default name: the app's (`eloxiv.json`), else `eloxiv`. */
|
|
617
|
+
const defaultServerName = (dir: string, flag: Option.Option<string>) =>
|
|
618
|
+
Option.isSome(flag)
|
|
619
|
+
? Effect.succeed(flag.value)
|
|
620
|
+
: readConfig(dir).pipe(
|
|
621
|
+
Effect.map(({ config }) => mcpServerName(config.name)),
|
|
622
|
+
Effect.orElseSucceed(() => "eloxiv"),
|
|
623
|
+
)
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* The server name to list: `--name`, else the name the kernel gives its MCP server (`/.well-known/mcp.json`), else
|
|
627
|
+
* the app's own (when the kernel cannot be reached).
|
|
628
|
+
*/
|
|
629
|
+
const serverNameFromKernel = (dir: string, flag: Option.Option<string>, url: Option.Option<string>) =>
|
|
630
|
+
Option.isSome(flag)
|
|
631
|
+
? Effect.succeed(flag.value)
|
|
632
|
+
: resolveKernelUrl(Option.getOrUndefined(url)).pipe(
|
|
633
|
+
Effect.flatMap((base) =>
|
|
634
|
+
Effect.tryPromise(async () => {
|
|
635
|
+
// A kernel that does not answer quickly leaves the app's own name, rather than stalling the command.
|
|
636
|
+
const response = await fetch(`${base.replace(/\/+$/u, "")}${MCP_IDENTITY_PATH}`, {
|
|
637
|
+
signal: AbortSignal.timeout(3_000),
|
|
638
|
+
})
|
|
639
|
+
if (!response.ok) throw new Error(String(response.status))
|
|
640
|
+
const identity = (await response.json()) as { readonly name?: unknown }
|
|
641
|
+
if (typeof identity.name !== "string" || !/^[A-Za-z0-9._-]+$/.test(identity.name))
|
|
642
|
+
throw new Error("no name")
|
|
643
|
+
return identity.name
|
|
644
|
+
}),
|
|
645
|
+
),
|
|
646
|
+
Effect.catch(() => defaultServerName(dir, flag)),
|
|
647
|
+
)
|
|
648
|
+
|
|
649
|
+
const mcpCommand = Command.make("mcp").pipe(
|
|
650
|
+
Command.withDescription("Connect coding agents (Claude Code, Cursor, VS Code) to the kernel's MCP server"),
|
|
651
|
+
Command.withSubcommands([
|
|
652
|
+
Command.make(
|
|
653
|
+
"login",
|
|
654
|
+
{ url: urlFlag },
|
|
655
|
+
Effect.fn(function* ({ url }) {
|
|
656
|
+
yield* login({ url: Option.getOrUndefined(url), scope: undefined, resource: "mcp" })
|
|
657
|
+
}),
|
|
658
|
+
).pipe(
|
|
659
|
+
Command.withDescription(
|
|
660
|
+
"Sign in for the kernel's MCP endpoint (a grant of its own, for mcp serve) with the OAuth device flow",
|
|
661
|
+
),
|
|
662
|
+
),
|
|
663
|
+
Command.make(
|
|
664
|
+
"logout",
|
|
665
|
+
{ url: urlFlag },
|
|
666
|
+
Effect.fn(function* ({ url }) {
|
|
667
|
+
yield* logout({ url: Option.getOrUndefined(url), resource: "mcp" })
|
|
668
|
+
}),
|
|
669
|
+
).pipe(Command.withDescription("Revoke and forget the MCP grant")),
|
|
670
|
+
Command.make(
|
|
671
|
+
"serve",
|
|
672
|
+
{ url: urlFlag },
|
|
673
|
+
Effect.fn(function* ({ url }) {
|
|
674
|
+
yield* mcpServe({ url: Option.getOrUndefined(url) })
|
|
675
|
+
}),
|
|
676
|
+
).pipe(
|
|
677
|
+
Command.withDescription(
|
|
678
|
+
"Serve the kernel's MCP tools over stdio (for hosts that start local servers), with the grant of eloxiv mcp login or ELOXIV_TOKEN",
|
|
679
|
+
),
|
|
680
|
+
),
|
|
681
|
+
Command.make(
|
|
682
|
+
"install",
|
|
683
|
+
{ url: urlFlag, host: hostsFlag, name: serverFlag, cwd: cwdFlag },
|
|
684
|
+
Effect.fn(function* ({ url, host, name, cwd }) {
|
|
685
|
+
const dir = yield* appDir(cwd)
|
|
686
|
+
yield* installMcp(dir, {
|
|
687
|
+
url: Option.getOrUndefined(url),
|
|
688
|
+
hosts: yield* parseHosts(host),
|
|
689
|
+
name: yield* serverNameFromKernel(dir, name, url),
|
|
690
|
+
})
|
|
691
|
+
}),
|
|
692
|
+
).pipe(
|
|
693
|
+
Command.withDescription(
|
|
694
|
+
"List the kernel's MCP endpoint in the hosts' project configuration (no token is written)",
|
|
695
|
+
),
|
|
696
|
+
),
|
|
697
|
+
Command.make(
|
|
698
|
+
"uninstall",
|
|
699
|
+
{ host: hostsFlag, name: serverFlag, cwd: cwdFlag },
|
|
700
|
+
Effect.fn(function* ({ host, name, cwd }) {
|
|
701
|
+
const dir = yield* appDir(cwd)
|
|
702
|
+
yield* uninstallMcp(dir, { hosts: yield* parseHosts(host), name: yield* defaultServerName(dir, name) })
|
|
703
|
+
}),
|
|
704
|
+
).pipe(Command.withDescription("Remove the kernel's MCP server from the hosts' project configuration")),
|
|
705
|
+
Command.make(
|
|
706
|
+
"status",
|
|
707
|
+
{ url: urlFlag, name: serverFlag, cwd: cwdFlag, json: jsonFlag },
|
|
708
|
+
Effect.fn(function* ({ url, name, cwd, json }) {
|
|
709
|
+
const dir = yield* appDir(cwd)
|
|
710
|
+
const status = yield* mcpStatus(dir, {
|
|
711
|
+
url: Option.getOrUndefined(url),
|
|
712
|
+
name: yield* serverNameFromKernel(dir, name, url),
|
|
713
|
+
})
|
|
714
|
+
yield* Console.log(json ? JSON.stringify(status, null, 2) : formatMcpStatus(status))
|
|
715
|
+
}),
|
|
716
|
+
).pipe(
|
|
717
|
+
Command.withDescription("Which hosts list the kernel's MCP server, and whether the kernel serves MCP with OAuth"),
|
|
718
|
+
),
|
|
719
|
+
]),
|
|
720
|
+
)
|
|
721
|
+
|
|
722
|
+
/** Run a promise-returning step of the CLI (Run.ts, Deploy.ts): a thrown CliError stays one, anything else becomes one. */
|
|
723
|
+
const promised = <A>(step: () => Promise<A> | A) =>
|
|
724
|
+
Effect.tryPromise({
|
|
725
|
+
try: async () => step(),
|
|
726
|
+
catch: (e) => (e instanceof CliError ? e : new CliError({ message: e instanceof Error ? e.message : String(e) })),
|
|
727
|
+
})
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Run long-running processes (Run.ts's `Running`) until they end; when the command is interrupted (Ctrl-C, SIGTERM)
|
|
731
|
+
* they are stopped and waited for before the CLI exits.
|
|
732
|
+
*/
|
|
733
|
+
const running = (make: () => Promise<Running> | Running) =>
|
|
734
|
+
Effect.callback<number, CliError>((resume) => {
|
|
735
|
+
let handle: Running | undefined
|
|
736
|
+
Promise.resolve()
|
|
737
|
+
.then(make)
|
|
738
|
+
.then(
|
|
739
|
+
(started) => {
|
|
740
|
+
handle = started
|
|
741
|
+
void started.done.then((code) => resume(Effect.succeed(code)))
|
|
742
|
+
return undefined
|
|
743
|
+
},
|
|
744
|
+
(e) =>
|
|
745
|
+
resume(
|
|
746
|
+
Effect.fail(
|
|
747
|
+
e instanceof CliError ? e : new CliError({ message: e instanceof Error ? e.message : String(e) }),
|
|
748
|
+
),
|
|
749
|
+
),
|
|
750
|
+
)
|
|
751
|
+
return Effect.promise(async () => {
|
|
752
|
+
await handle?.stop()
|
|
753
|
+
})
|
|
754
|
+
})
|
|
755
|
+
|
|
756
|
+
/** A tool's exit code as the CLI's: 0 passes, anything else is something to act on (exit 1). */
|
|
757
|
+
const toolExit = (code: number, what: string) =>
|
|
758
|
+
code === 0 ? Effect.void : Effect.fail(new ExitStatus({ code: 1, reason: `${what} exited with ${code}` }))
|
|
759
|
+
|
|
760
|
+
const devCommand = Command.make(
|
|
761
|
+
"dev",
|
|
762
|
+
{
|
|
763
|
+
cwd: cwdFlag,
|
|
764
|
+
noShell: Flag.Boolean("no-shell").pipe(
|
|
765
|
+
Flag.withDescription("Do not start the shell's dev server"),
|
|
766
|
+
Flag.withDefault(false),
|
|
767
|
+
),
|
|
768
|
+
},
|
|
769
|
+
Effect.fn(function* ({ cwd, noShell }) {
|
|
770
|
+
const dir = yield* appDir(cwd)
|
|
771
|
+
yield* toolExit(yield* running(() => dev(dir, { shell: !noShell })), "dev")
|
|
772
|
+
}),
|
|
773
|
+
).pipe(
|
|
774
|
+
Command.withDescription(
|
|
775
|
+
"Run the app in development: the kernel (setup, seed, serve), zero-cache and the shell's dev server, until Ctrl-C (PostgreSQL from ELOXIV_DATABASE_URL)",
|
|
776
|
+
),
|
|
777
|
+
)
|
|
778
|
+
|
|
779
|
+
const kernelUrlFlag = Flag.String("kernel-url").pipe(
|
|
780
|
+
Flag.withDescription("The kernel's public URL the shell talks to (default: VITE_ELOXIV_URL, else ELOXIV_BASE_URL)"),
|
|
781
|
+
Flag.optional,
|
|
782
|
+
)
|
|
783
|
+
const syncUrlFlag = Flag.String("sync-url").pipe(
|
|
784
|
+
Flag.withDescription(
|
|
785
|
+
"zero-cache's public URL the shell talks to (default: VITE_ELOXIV_SYNC_URL, else ELOXIV_ZERO_URL)",
|
|
786
|
+
),
|
|
787
|
+
Flag.optional,
|
|
788
|
+
)
|
|
789
|
+
|
|
790
|
+
const buildCommand = Command.make(
|
|
791
|
+
"build",
|
|
792
|
+
{ cwd: cwdFlag, kernelUrl: kernelUrlFlag, syncUrl: syncUrlFlag },
|
|
793
|
+
Effect.fn(function* ({ cwd, kernelUrl, syncUrl }) {
|
|
794
|
+
const dir = yield* appDir(cwd)
|
|
795
|
+
const code = yield* promised(() =>
|
|
796
|
+
build(dir, {
|
|
797
|
+
kernelUrl: Option.getOrUndefined(kernelUrl) ?? process.env["VITE_ELOXIV_URL"] ?? process.env["ELOXIV_BASE_URL"],
|
|
798
|
+
syncUrl:
|
|
799
|
+
Option.getOrUndefined(syncUrl) ?? process.env["VITE_ELOXIV_SYNC_URL"] ?? process.env["ELOXIV_ZERO_URL"],
|
|
800
|
+
}),
|
|
801
|
+
)
|
|
802
|
+
yield* toolExit(code, "vite build")
|
|
803
|
+
}),
|
|
804
|
+
).pipe(
|
|
805
|
+
Command.withDescription("Build the shell for production (shell-foldkit/dist); a headless app has nothing to build"),
|
|
806
|
+
)
|
|
807
|
+
|
|
808
|
+
const startCommand = Command.make(
|
|
809
|
+
"start",
|
|
810
|
+
{
|
|
811
|
+
role: Argument.String("role").pipe(
|
|
812
|
+
Argument.withDescription(`What to run: ${START_ROLES.join(", ")} (default: kernel)`),
|
|
813
|
+
Argument.optional,
|
|
814
|
+
),
|
|
815
|
+
cwd: cwdFlag,
|
|
816
|
+
port: Flag.Int("port").pipe(Flag.withDescription("The shell's port (default: PORT, else 8080)"), Flag.optional),
|
|
817
|
+
kernelUrl: kernelUrlFlag,
|
|
818
|
+
syncUrl: syncUrlFlag,
|
|
819
|
+
},
|
|
820
|
+
Effect.fn(function* ({ role, cwd, port, kernelUrl, syncUrl }) {
|
|
821
|
+
const which = Option.getOrElse(role, () => "kernel")
|
|
822
|
+
if (!(START_ROLES as ReadonlyArray<string>).includes(which)) {
|
|
823
|
+
return yield* new CliError({ message: `Unknown role ${which}: one of ${START_ROLES.join(", ")}` })
|
|
824
|
+
}
|
|
825
|
+
const dir = yield* appDir(cwd)
|
|
826
|
+
const code = yield* running(() =>
|
|
827
|
+
start(dir, which as StartRole, {
|
|
828
|
+
...(Option.isSome(port) ? { port: port.value } : {}),
|
|
829
|
+
...(Option.isSome(kernelUrl) ? { kernelUrl: kernelUrl.value } : {}),
|
|
830
|
+
...(Option.isSome(syncUrl) ? { syncUrl: syncUrl.value } : {}),
|
|
831
|
+
}),
|
|
832
|
+
)
|
|
833
|
+
yield* toolExit(code, which)
|
|
834
|
+
}),
|
|
835
|
+
).pipe(
|
|
836
|
+
Command.withDescription(
|
|
837
|
+
"Run one production process of the app: kernel (default), zero (zero-cache with Eloxiv's sync settings), shell (the built shell with its security headers) or setup",
|
|
838
|
+
),
|
|
839
|
+
)
|
|
840
|
+
|
|
841
|
+
const typecheckCommand = Command.make(
|
|
842
|
+
"typecheck",
|
|
843
|
+
{ cwd: cwdFlag },
|
|
844
|
+
Effect.fn(function* ({ cwd }) {
|
|
845
|
+
const dir = yield* appDir(cwd)
|
|
846
|
+
yield* toolExit(yield* promised(() => typecheck(dir)), "tsc")
|
|
847
|
+
}),
|
|
848
|
+
).pipe(Command.withDescription("Typecheck the app and its shell with the app's own TypeScript"))
|
|
849
|
+
|
|
850
|
+
const printChecks = (
|
|
851
|
+
checks: ReadonlyArray<{ readonly id: string; readonly status: string; readonly detail: string }>,
|
|
852
|
+
json: boolean,
|
|
853
|
+
) =>
|
|
854
|
+
Effect.gen(function* () {
|
|
855
|
+
const failed = checks.some((c) => c.status === "fail")
|
|
856
|
+
if (json) yield* Console.log(JSON.stringify({ checks, failed }, null, 2))
|
|
857
|
+
else {
|
|
858
|
+
const label = { pass: "ok", warn: "warn", fail: "FAIL", "not-run": "skip" } as Record<string, string>
|
|
859
|
+
for (const c of checks) yield* Console.log(`${(label[c.status] ?? c.status).padEnd(5)} ${c.id}: ${c.detail}`)
|
|
860
|
+
}
|
|
861
|
+
if (failed) return yield* new ExitStatus({ code: 1, reason: "checks failed" })
|
|
862
|
+
})
|
|
863
|
+
|
|
864
|
+
const dryRunFlag = Flag.Boolean("dry-run").pipe(
|
|
865
|
+
Flag.withDescription("Show what would be written and write nothing"),
|
|
866
|
+
Flag.withDefault(false),
|
|
867
|
+
)
|
|
868
|
+
const overwriteFlag = Flag.Boolean("overwrite").pipe(
|
|
869
|
+
Flag.withDescription("Replace files that differ (your edits)"),
|
|
870
|
+
Flag.withDefault(false),
|
|
871
|
+
)
|
|
872
|
+
|
|
873
|
+
const envFileFlag = Flag.String("env-file").pipe(
|
|
874
|
+
Flag.withDescription("Read the environment to check from this dotenv file (over the process's)"),
|
|
875
|
+
Flag.optional,
|
|
876
|
+
)
|
|
877
|
+
|
|
878
|
+
const environmentOf = (dir: string, envFile: Option.Option<string>) =>
|
|
879
|
+
Effect.gen(function* () {
|
|
880
|
+
if (Option.isNone(envFile)) return process.env
|
|
881
|
+
const fs = yield* FileSystem.FileSystem
|
|
882
|
+
const path = yield* Path.Path
|
|
883
|
+
const text = yield* fs
|
|
884
|
+
.readFileString(path.resolve(dir, envFile.value))
|
|
885
|
+
.pipe(Effect.mapError(() => new CliError({ message: `Cannot read ${envFile.value}` })))
|
|
886
|
+
return { ...process.env, ...parseEnvFile(text) }
|
|
887
|
+
})
|
|
888
|
+
|
|
889
|
+
const deployCommand = Command.make("deploy").pipe(
|
|
890
|
+
Command.withDescription(
|
|
891
|
+
"Deployment recipes for long-running hosts (written into the app, never deployed) and a production preflight",
|
|
892
|
+
),
|
|
893
|
+
Command.withSubcommands([
|
|
894
|
+
...DEPLOY_TARGETS.map((target) =>
|
|
895
|
+
Command.make(
|
|
896
|
+
target,
|
|
897
|
+
{ cwd: cwdFlag, dryRun: dryRunFlag, overwrite: overwriteFlag },
|
|
898
|
+
Effect.fn(function* ({ cwd, dryRun, overwrite }) {
|
|
899
|
+
const dir = yield* appDir(cwd)
|
|
900
|
+
const { config } = yield* readConfig(dir)
|
|
901
|
+
yield* emitFiles(dir, deployFiles(dir, target, config.name), { dryRun, overwrite })
|
|
902
|
+
if (dryRun) return yield* Console.log("dry run: nothing written")
|
|
903
|
+
yield* Console.log("\nNothing was built, pushed or deployed. Next:")
|
|
904
|
+
for (const step of deployNextSteps(target)) yield* Console.log(`- ${step}`)
|
|
905
|
+
}),
|
|
906
|
+
).pipe(
|
|
907
|
+
Command.withDescription(
|
|
908
|
+
`Write the ${target} recipe's files into the app (deploy/...); nothing is built or deployed`,
|
|
909
|
+
),
|
|
910
|
+
),
|
|
911
|
+
),
|
|
912
|
+
Command.make(
|
|
913
|
+
"check",
|
|
914
|
+
{ cwd: cwdFlag, envFile: envFileFlag, json: jsonFlag },
|
|
915
|
+
Effect.fn(function* ({ cwd, envFile, json }) {
|
|
916
|
+
const dir = yield* appDir(cwd)
|
|
917
|
+
yield* printChecks(preflight(dir, yield* environmentOf(dir, envFile)), json)
|
|
918
|
+
}),
|
|
919
|
+
).pipe(
|
|
920
|
+
Command.withDescription(
|
|
921
|
+
"Check the production environment (secrets, URLs, database endpoints) before a deploy. Exits 1 when a check fails",
|
|
922
|
+
),
|
|
923
|
+
),
|
|
924
|
+
]),
|
|
925
|
+
)
|
|
926
|
+
|
|
927
|
+
const blueprintCommand = Command.make(
|
|
928
|
+
"blueprint",
|
|
929
|
+
{
|
|
930
|
+
kind: Argument.String("kind").pipe(Argument.withDescription(`What to write: ${BLUEPRINTS.join(", ")}`)),
|
|
931
|
+
name: Flag.String("name").pipe(Flag.withDescription("The connector's, module's or action's name"), Flag.optional),
|
|
932
|
+
provides: Flag.String("provides").pipe(
|
|
933
|
+
Flag.withDescription(
|
|
934
|
+
"connector: the capability contracts it implements, comma-separated (MailProvider, CalendarProvider, ...)",
|
|
935
|
+
),
|
|
936
|
+
Flag.optional,
|
|
937
|
+
),
|
|
938
|
+
module: Flag.String("module").pipe(Flag.withDescription("action: the module it belongs to"), Flag.optional),
|
|
939
|
+
cwd: cwdFlag,
|
|
940
|
+
},
|
|
941
|
+
Effect.fn(function* ({ kind, name, provides, module, cwd }) {
|
|
942
|
+
if (!(BLUEPRINTS as ReadonlyArray<string>).includes(kind)) {
|
|
943
|
+
return yield* new CliError({ message: `Unknown blueprint ${kind}: one of ${BLUEPRINTS.join(", ")}` })
|
|
944
|
+
}
|
|
945
|
+
const dir = yield* appDir(cwd)
|
|
946
|
+
const text = yield* promised(() =>
|
|
947
|
+
blueprint(dir, kind as BlueprintKind, {
|
|
948
|
+
...(Option.isSome(name) ? { name: name.value } : {}),
|
|
949
|
+
...(Option.isSome(provides)
|
|
950
|
+
? {
|
|
951
|
+
provides: provides.value
|
|
952
|
+
.split(",")
|
|
953
|
+
.map((p) => p.trim())
|
|
954
|
+
.filter((p) => p !== ""),
|
|
955
|
+
}
|
|
956
|
+
: {}),
|
|
957
|
+
...(Option.isSome(module) ? { module: module.value } : {}),
|
|
958
|
+
}),
|
|
959
|
+
)
|
|
960
|
+
yield* Console.log(text)
|
|
961
|
+
}),
|
|
962
|
+
).pipe(
|
|
963
|
+
Command.withDescription(
|
|
964
|
+
"Print Markdown instructions for a coding agent to write a connector, a messaging channel, an action, a module or a MAKE module in this app (writes nothing)",
|
|
965
|
+
),
|
|
966
|
+
)
|
|
967
|
+
|
|
968
|
+
const changelogCommand = Command.make("changelog").pipe(
|
|
969
|
+
Command.withDescription("The app's release notes (CHANGELOG.md, Keep a Changelog)"),
|
|
970
|
+
Command.withSubcommands([
|
|
971
|
+
Command.make(
|
|
972
|
+
"add",
|
|
973
|
+
{
|
|
974
|
+
type: Argument.String("type").pipe(Argument.withDescription(CHANGE_TYPES.join(", "))),
|
|
975
|
+
text: Argument.String("text").pipe(Argument.withDescription("The entry"), Argument.atLeast(1)),
|
|
976
|
+
cwd: cwdFlag,
|
|
977
|
+
},
|
|
978
|
+
Effect.fn(function* ({ type, text, cwd }) {
|
|
979
|
+
const dir = yield* appDir(cwd)
|
|
980
|
+
const unreleased = yield* promised(() => addEntry(dir, type, text.join(" ")))
|
|
981
|
+
yield* Console.log(
|
|
982
|
+
`Unreleased: ${unreleased.entries.length} entr${unreleased.entries.length === 1 ? "y" : "ies"}`,
|
|
983
|
+
)
|
|
984
|
+
}),
|
|
985
|
+
).pipe(Command.withDescription("Add an entry under Unreleased")),
|
|
986
|
+
Command.make(
|
|
987
|
+
"release",
|
|
988
|
+
{
|
|
989
|
+
version: Argument.String("version").pipe(
|
|
990
|
+
Argument.withDescription("The new version (newer than the last release)"),
|
|
991
|
+
),
|
|
992
|
+
date: Flag.String("date").pipe(Flag.withDescription("YYYY-MM-DD (default: today)"), Flag.optional),
|
|
993
|
+
cwd: cwdFlag,
|
|
994
|
+
},
|
|
995
|
+
Effect.fn(function* ({ version, date, cwd }) {
|
|
996
|
+
const dir = yield* appDir(cwd)
|
|
997
|
+
const released = yield* promised(() => release(dir, version, Option.getOrUndefined(date)))
|
|
998
|
+
yield* Console.log(
|
|
999
|
+
`released ${released.version} (${released.date}) with ${released.entries.length} entries; package.json version ${released.version}`,
|
|
1000
|
+
)
|
|
1001
|
+
}),
|
|
1002
|
+
).pipe(Command.withDescription("Turn Unreleased into a dated release and set package.json's version")),
|
|
1003
|
+
Command.make(
|
|
1004
|
+
"list",
|
|
1005
|
+
{
|
|
1006
|
+
version: Flag.String("version").pipe(Flag.withDescription("Only this release"), Flag.optional),
|
|
1007
|
+
cwd: cwdFlag,
|
|
1008
|
+
json: jsonFlag,
|
|
1009
|
+
},
|
|
1010
|
+
Effect.fn(function* ({ version, cwd, json }) {
|
|
1011
|
+
const dir = yield* appDir(cwd)
|
|
1012
|
+
const releases = yield* promised(() => listReleases(dir, Option.getOrUndefined(version)))
|
|
1013
|
+
yield* Console.log(json ? JSON.stringify(releases, null, 2) : formatReleases(releases))
|
|
1014
|
+
}),
|
|
1015
|
+
).pipe(Command.withDescription("List the releases and their entries")),
|
|
1016
|
+
]),
|
|
1017
|
+
)
|
|
1018
|
+
|
|
1019
|
+
const listFlag = (name: string, description: string) =>
|
|
1020
|
+
Flag.String(name).pipe(Flag.withDescription(description), Flag.atLeast(0))
|
|
1021
|
+
const commaList = (values: ReadonlyArray<string>) =>
|
|
1022
|
+
values
|
|
1023
|
+
.flatMap((v) => v.split(","))
|
|
1024
|
+
.map((v) => v.trim())
|
|
1025
|
+
.filter((v) => v !== "")
|
|
1026
|
+
|
|
1027
|
+
const evalPromote = Command.make(
|
|
1028
|
+
"promote",
|
|
1029
|
+
{
|
|
1030
|
+
run: Argument.String("run").pipe(Argument.withDescription("The finished run's id (eloxiv agent prints it)")),
|
|
1031
|
+
name: Flag.String("name").pipe(Flag.withDescription("The case's name")),
|
|
1032
|
+
prompt: Flag.String("prompt").pipe(
|
|
1033
|
+
Flag.withDescription(`The case's prompt, written or reviewed by you (at most 2000 characters)`),
|
|
1034
|
+
),
|
|
1035
|
+
allowTool: listFlag("allow-tool", "A tool the run may have called (repeat, or comma-separate)"),
|
|
1036
|
+
allowView: listFlag("allow-view", "A query view the run may have read"),
|
|
1037
|
+
keepInput: listFlag("keep-input", "<tool>.<field>: an input field the case keeps (every other is dropped)"),
|
|
1038
|
+
answerIncludes: listFlag("answer-includes", "A word or phrase the answer must contain"),
|
|
1039
|
+
forbid: listFlag("forbid", "A tool the case must not call"),
|
|
1040
|
+
into: Flag.String("into").pipe(
|
|
1041
|
+
Flag.withDescription("Add the case to this skill eval file (needs --reviewed)"),
|
|
1042
|
+
Flag.optional,
|
|
1043
|
+
),
|
|
1044
|
+
reviewed: Flag.Boolean("reviewed").pipe(
|
|
1045
|
+
Flag.withDescription("You reviewed the prompt, the allowlists and the kept inputs: write the case into --into"),
|
|
1046
|
+
Flag.withDefault(false),
|
|
1047
|
+
),
|
|
1048
|
+
url: urlFlag,
|
|
1049
|
+
},
|
|
1050
|
+
Effect.fn(function* (o) {
|
|
1051
|
+
const keepInput: Record<string, Array<string>> = {}
|
|
1052
|
+
for (const entry of commaList(o.keepInput)) {
|
|
1053
|
+
const at = entry.indexOf(".")
|
|
1054
|
+
if (at <= 0) return yield* new CliError({ message: `--keep-input takes <tool>.<field>, not ${entry}` })
|
|
1055
|
+
;(keepInput[entry.slice(0, at)] ??= []).push(entry.slice(at + 1))
|
|
1056
|
+
}
|
|
1057
|
+
const events = yield* fetchRunEvents({ url: Option.getOrUndefined(o.url), runId: o.run })
|
|
1058
|
+
const promotion = yield* promised(() =>
|
|
1059
|
+
promoteTrace(events, {
|
|
1060
|
+
name: o.name,
|
|
1061
|
+
prompt: o.prompt,
|
|
1062
|
+
allowTools: commaList(o.allowTool),
|
|
1063
|
+
allowViews: commaList(o.allowView),
|
|
1064
|
+
keepInput,
|
|
1065
|
+
answerIncludes: commaList(o.answerIncludes),
|
|
1066
|
+
forbiddenTools: commaList(o.forbid),
|
|
1067
|
+
}),
|
|
1068
|
+
)
|
|
1069
|
+
if (promotion.dropped.length > 0) yield* Console.error(`dropped from the trace: ${promotion.dropped.join(", ")}`)
|
|
1070
|
+
if (Option.isNone(o.into)) return yield* Console.log(JSON.stringify(promotion.case, null, 2))
|
|
1071
|
+
if (!o.reviewed) {
|
|
1072
|
+
yield* Console.log(JSON.stringify(promotion.case, null, 2))
|
|
1073
|
+
return yield* new CliError({ message: "Not written: review the case above, then run again with --reviewed" })
|
|
1074
|
+
}
|
|
1075
|
+
const file = o.into.value
|
|
1076
|
+
const count = yield* promised(() => addCase(file, promotion.case))
|
|
1077
|
+
yield* Console.log(`added ${promotion.case.name} to ${file} (${count} cases)`)
|
|
1078
|
+
}),
|
|
1079
|
+
).pipe(
|
|
1080
|
+
Command.withDescription(
|
|
1081
|
+
"Turn a finished run of your agent into an eval case: only with your prompt, the tools and views you allow and the input fields you keep",
|
|
1082
|
+
),
|
|
1083
|
+
)
|
|
1084
|
+
|
|
1085
|
+
const evalCommand = Command.make(
|
|
1086
|
+
"eval",
|
|
1087
|
+
{
|
|
1088
|
+
cwd: cwdFlag,
|
|
1089
|
+
module: listFlag("module", "Only this module's skills (repeat for several)"),
|
|
1090
|
+
model: Flag.String("model").pipe(
|
|
1091
|
+
Flag.withDescription(
|
|
1092
|
+
"<provider>:<model> (default: ELOXIV_EVAL_MODEL, else the scripted provider playing each case's script)",
|
|
1093
|
+
),
|
|
1094
|
+
Flag.optional,
|
|
1095
|
+
),
|
|
1096
|
+
repeat: Flag.Int("repeat").pipe(
|
|
1097
|
+
Flag.withDescription("Run the whole suite this many times (fresh database each)"),
|
|
1098
|
+
Flag.withDefault(1),
|
|
1099
|
+
),
|
|
1100
|
+
permission: listFlag("permission", "A module permission every evaluator holds (repeat)"),
|
|
1101
|
+
database: Flag.String("database").pipe(
|
|
1102
|
+
Flag.withDescription("The scratch database, dropped before and after (default: eloxiv_evals)"),
|
|
1103
|
+
Flag.optional,
|
|
1104
|
+
),
|
|
1105
|
+
},
|
|
1106
|
+
Effect.fn(function* (o) {
|
|
1107
|
+
const dir = yield* appDir(o.cwd)
|
|
1108
|
+
const entry = yield* promised(() => evalEntry(dir))
|
|
1109
|
+
const args = [
|
|
1110
|
+
"--app",
|
|
1111
|
+
dir,
|
|
1112
|
+
...commaList(o.module).flatMap((m) => ["--module", m]),
|
|
1113
|
+
...(Option.isSome(o.model) ? ["--model", o.model.value] : []),
|
|
1114
|
+
"--repeat",
|
|
1115
|
+
String(o.repeat),
|
|
1116
|
+
...commaList(o.permission).flatMap((p) => ["--permission", p]),
|
|
1117
|
+
...(Option.isSome(o.database) ? ["--database", o.database.value] : []),
|
|
1118
|
+
]
|
|
1119
|
+
const code = yield* promised(() => runTool(process.execPath, [...process.execArgv, entry, ...args], { cwd: dir }))
|
|
1120
|
+
if (code === 1) return yield* new ExitStatus({ code: 1, reason: "below threshold" })
|
|
1121
|
+
if (code !== 0) return yield* new CliError({ message: `the eval run failed (exit ${code})` })
|
|
1122
|
+
}),
|
|
1123
|
+
).pipe(
|
|
1124
|
+
Command.withDescription(
|
|
1125
|
+
"Run the app's module skills' eval cases through the real agent runtime and score them against their thresholds (exits 1 below a threshold); promote turns a finished run into a case",
|
|
1126
|
+
),
|
|
1127
|
+
Command.withSubcommands([evalPromote]),
|
|
1128
|
+
)
|
|
1129
|
+
|
|
1130
|
+
const configFlag = Flag.String("config").pipe(
|
|
1131
|
+
Flag.withDescription("The agent-web config (default: agent-web.json)"),
|
|
1132
|
+
Flag.withDefault("agent-web.json"),
|
|
1133
|
+
)
|
|
1134
|
+
|
|
1135
|
+
const agentWebCommand = Command.make("agent-web").pipe(
|
|
1136
|
+
Command.withDescription(
|
|
1137
|
+
"Public agent-readable pages: robots.txt, sitemaps, llms.txt, Markdown mirrors, JSON-LD; and an audit of a deployed site",
|
|
1138
|
+
),
|
|
1139
|
+
Command.withSubcommands([
|
|
1140
|
+
Command.make(
|
|
1141
|
+
"generate",
|
|
1142
|
+
{
|
|
1143
|
+
cwd: cwdFlag,
|
|
1144
|
+
config: configFlag,
|
|
1145
|
+
out: Flag.String("out").pipe(
|
|
1146
|
+
Flag.withDescription(
|
|
1147
|
+
"Directory to write into, in the app (default: shell-foldkit/public with a shell, else public)",
|
|
1148
|
+
),
|
|
1149
|
+
Flag.optional,
|
|
1150
|
+
),
|
|
1151
|
+
dryRun: dryRunFlag,
|
|
1152
|
+
overwrite: overwriteFlag,
|
|
1153
|
+
},
|
|
1154
|
+
Effect.fn(function* ({ cwd, config, out, dryRun, overwrite }) {
|
|
1155
|
+
const dir = yield* appDir(cwd)
|
|
1156
|
+
const parsed = yield* promised(() => readAgentWebConfig(dir, config))
|
|
1157
|
+
const base = Option.getOrElse(out, () =>
|
|
1158
|
+
shellDir(dir) === undefined ? "public" : "shell-foldkit/public",
|
|
1159
|
+
).replace(/\/+$/, "")
|
|
1160
|
+
const files = yield* promised(() => agentWebFiles(dir, parsed))
|
|
1161
|
+
yield* emitFiles(
|
|
1162
|
+
dir,
|
|
1163
|
+
files.map((f) => ({ path: `${base}/${f.path}`, content: f.content })),
|
|
1164
|
+
{ dryRun, overwrite },
|
|
1165
|
+
)
|
|
1166
|
+
yield* Console.log(
|
|
1167
|
+
`Each page's JSON-LD is in ${base}/jsonld/: put it in that page's <head> as <script type="application/ld+json">. Then: eloxiv agent-web audit <site>.`,
|
|
1168
|
+
)
|
|
1169
|
+
}),
|
|
1170
|
+
).pipe(
|
|
1171
|
+
Command.withDescription(
|
|
1172
|
+
"Write robots.txt, sitemap.xml (a sitemap per group), llms.txt, Markdown mirrors and JSON-LD from agent-web.json",
|
|
1173
|
+
),
|
|
1174
|
+
),
|
|
1175
|
+
Command.make(
|
|
1176
|
+
"audit",
|
|
1177
|
+
{
|
|
1178
|
+
url: Argument.String("url").pipe(Argument.withDescription("The deployed site")),
|
|
1179
|
+
cwd: cwdFlag,
|
|
1180
|
+
config: Flag.String("config").pipe(
|
|
1181
|
+
Flag.withDescription("The agent-web config, for the kernel's URL and public tools"),
|
|
1182
|
+
Flag.optional,
|
|
1183
|
+
),
|
|
1184
|
+
json: jsonFlag,
|
|
1185
|
+
},
|
|
1186
|
+
Effect.fn(function* ({ url, cwd, config, json }) {
|
|
1187
|
+
const dir = yield* appDir(cwd)
|
|
1188
|
+
const parsed = Option.isSome(config) ? yield* promised(() => readAgentWebConfig(dir, config.value)) : undefined
|
|
1189
|
+
const checks = yield* promised(() => auditAgentWeb(url, parsed))
|
|
1190
|
+
yield* printChecks(checks, json)
|
|
1191
|
+
}),
|
|
1192
|
+
).pipe(
|
|
1193
|
+
Command.withDescription(
|
|
1194
|
+
"Check a deployed site's agent-readable surfaces, and that its MCP endpoint offers anonymous clients only the tools declared public. Exits 1 when a check fails",
|
|
1195
|
+
),
|
|
1196
|
+
),
|
|
1197
|
+
]),
|
|
1198
|
+
)
|
|
1199
|
+
|
|
1200
|
+
const brandCommand = Command.make("brand").pipe(
|
|
1201
|
+
Command.withDescription(
|
|
1202
|
+
"Brand tooling: colours, fonts and design tokens read from a site or files, as theme overrides",
|
|
1203
|
+
),
|
|
1204
|
+
Command.withSubcommands([
|
|
1205
|
+
Command.make(
|
|
1206
|
+
"extract",
|
|
1207
|
+
{
|
|
1208
|
+
sources: Argument.String("sources").pipe(
|
|
1209
|
+
Argument.withDescription("Websites (https), stylesheets, a Tailwind config, token JSON or directories"),
|
|
1210
|
+
Argument.atLeast(1),
|
|
1211
|
+
),
|
|
1212
|
+
cwd: cwdFlag,
|
|
1213
|
+
out: Flag.String("out").pipe(
|
|
1214
|
+
Flag.withDescription("Also write the report as JSON to this file in the app"),
|
|
1215
|
+
Flag.optional,
|
|
1216
|
+
),
|
|
1217
|
+
overwrite: overwriteFlag,
|
|
1218
|
+
json: jsonFlag,
|
|
1219
|
+
},
|
|
1220
|
+
Effect.fn(function* ({ sources, cwd, out, overwrite, json }) {
|
|
1221
|
+
const dir = yield* appDir(cwd)
|
|
1222
|
+
const report = yield* promised(() => extractBrand(sources, dir))
|
|
1223
|
+
yield* Console.log(json ? JSON.stringify(report, null, 2) : formatBrand(report))
|
|
1224
|
+
if (Option.isSome(out)) {
|
|
1225
|
+
yield* emitFiles(dir, [{ path: out.value, content: `${JSON.stringify(report, null, 2)}\n` }], {
|
|
1226
|
+
dryRun: false,
|
|
1227
|
+
overwrite,
|
|
1228
|
+
})
|
|
1229
|
+
}
|
|
1230
|
+
}),
|
|
1231
|
+
).pipe(
|
|
1232
|
+
Command.withDescription(
|
|
1233
|
+
"Read a brand's colours, fonts and custom properties (bounded: https, 10 stylesheets, 1 MiB each; 500 local files) and propose theme overrides with their contrast; changes no theme",
|
|
1234
|
+
),
|
|
1235
|
+
),
|
|
1236
|
+
]),
|
|
1237
|
+
)
|
|
1238
|
+
|
|
1239
|
+
const migrateCommand = Command.make(
|
|
1240
|
+
"migrate",
|
|
1241
|
+
{
|
|
1242
|
+
items: Argument.String("items").pipe(
|
|
1243
|
+
Argument.withDescription("Installed items (default: all)"),
|
|
1244
|
+
Argument.variadic(),
|
|
1245
|
+
),
|
|
1246
|
+
cwd: cwdFlag,
|
|
1247
|
+
dryRun: dryRunFlag,
|
|
1248
|
+
dossier: Flag.Boolean("dossier").pipe(
|
|
1249
|
+
Flag.withDescription(
|
|
1250
|
+
"Print a migration dossier (Markdown) for moving the items to the registry's latest versions; writes nothing",
|
|
1251
|
+
),
|
|
1252
|
+
Flag.withDefault(false),
|
|
1253
|
+
),
|
|
1254
|
+
json: jsonFlag,
|
|
1255
|
+
},
|
|
1256
|
+
Effect.fn(function* ({ items, cwd, dryRun, dossier: brief, json }) {
|
|
1257
|
+
const dir = yield* appDir(cwd)
|
|
1258
|
+
if (brief) return yield* Console.log(yield* dossier(dir, items))
|
|
1259
|
+
const changes = yield* migrate(dir, items, { dryRun })
|
|
1260
|
+
if (json) yield* Console.log(JSON.stringify({ dryRun, changes }, null, 2))
|
|
1261
|
+
else if (changes.length === 0) yield* Console.log("nothing to migrate")
|
|
1262
|
+
else for (const line of formatMigrationChanges(changes, dryRun)) yield* Console.log(line.trimStart())
|
|
1263
|
+
if (changes.some((c) => c.kind === "manual")) return yield* new ExitStatus({ code: 1, reason: "changes by hand" })
|
|
1264
|
+
}),
|
|
1265
|
+
).pipe(
|
|
1266
|
+
Command.withDescription(
|
|
1267
|
+
"Apply the installed items' compatibility migrations (moved modules, exports, stylesheets) to the app's own files; --dossier prints a migration brief. Exits 1 when a change is left for you",
|
|
1268
|
+
),
|
|
1269
|
+
)
|
|
1270
|
+
|
|
1271
|
+
const docsCommand = Command.make("docs").pipe(
|
|
1272
|
+
Command.withDescription("Version-matched documentation for coding agents"),
|
|
1273
|
+
Command.withSubcommands([
|
|
1274
|
+
Command.make(
|
|
1275
|
+
"search",
|
|
1276
|
+
{
|
|
1277
|
+
query: Argument.String("query").pipe(
|
|
1278
|
+
Argument.withDescription("Words to find (case-insensitive)"),
|
|
1279
|
+
Argument.atLeast(1),
|
|
1280
|
+
),
|
|
1281
|
+
cwd: cwdFlag,
|
|
1282
|
+
in: Flag.String("in").pipe(
|
|
1283
|
+
Flag.withDescription(
|
|
1284
|
+
"docs (this CLI's documentation), source (the app's installed @eloxiv packages) or all (default)",
|
|
1285
|
+
),
|
|
1286
|
+
Flag.withDefault("all"),
|
|
1287
|
+
),
|
|
1288
|
+
limit: Flag.Int("limit").pipe(
|
|
1289
|
+
Flag.withDescription(`At most this many results from each source (default 5, at most ${DOCS_MAX_RESULTS})`),
|
|
1290
|
+
Flag.withDefault(5),
|
|
1291
|
+
),
|
|
1292
|
+
json: jsonFlag,
|
|
1293
|
+
},
|
|
1294
|
+
Effect.fn(function* ({ query, cwd, in: where, limit, json }) {
|
|
1295
|
+
if (where !== "docs" && where !== "source" && where !== "all") {
|
|
1296
|
+
return yield* new CliError({ message: `--in is docs, source or all (got ${where})` })
|
|
1297
|
+
}
|
|
1298
|
+
const found = searchDocs(yield* appDir(cwd), query.join(" "), { limit, in: where })
|
|
1299
|
+
yield* Console.log(json ? JSON.stringify(found, null, 2) : formatDocs(found, where))
|
|
1300
|
+
}),
|
|
1301
|
+
).pipe(
|
|
1302
|
+
Command.withDescription(
|
|
1303
|
+
"Search the framework documentation shipped with this CLI and the source of the app's installed @eloxiv packages, at their versions: the best few sections and lines",
|
|
1304
|
+
),
|
|
1305
|
+
),
|
|
1306
|
+
]),
|
|
1307
|
+
)
|
|
1308
|
+
|
|
1309
|
+
const dbCommand = Command.make("db").pipe(
|
|
1310
|
+
Command.withDescription("PostgreSQL: host recipes and the deployment's database URLs checked"),
|
|
1311
|
+
Command.withSubcommands([
|
|
1312
|
+
Command.make(
|
|
1313
|
+
"host",
|
|
1314
|
+
{
|
|
1315
|
+
provider: Argument.String("provider").pipe(Argument.withDescription(`One of ${PROVIDERS.join(", ")}`)),
|
|
1316
|
+
json: jsonFlag,
|
|
1317
|
+
},
|
|
1318
|
+
Effect.fn(function* ({ provider, json }) {
|
|
1319
|
+
if (!(PROVIDERS as ReadonlyArray<string>).includes(provider)) {
|
|
1320
|
+
return yield* new CliError({ message: `Unknown provider ${provider}: one of ${PROVIDERS.join(", ")}` })
|
|
1321
|
+
}
|
|
1322
|
+
const r = recipe(provider as Provider)
|
|
1323
|
+
yield* Console.log(json ? JSON.stringify(r, null, 2) : formatRecipe(r))
|
|
1324
|
+
}),
|
|
1325
|
+
).pipe(Command.withDescription("What to enable on a PostgreSQL host and which endpoint each connection uses")),
|
|
1326
|
+
Command.make(
|
|
1327
|
+
"check",
|
|
1328
|
+
{
|
|
1329
|
+
cwd: cwdFlag,
|
|
1330
|
+
envFile: envFileFlag,
|
|
1331
|
+
live: Flag.Boolean("live").pipe(
|
|
1332
|
+
Flag.withDescription("Also query the host through ELOXIV_ADMIN_DATABASE_URL with psql (read only)"),
|
|
1333
|
+
Flag.withDefault(false),
|
|
1334
|
+
),
|
|
1335
|
+
json: jsonFlag,
|
|
1336
|
+
},
|
|
1337
|
+
Effect.fn(function* ({ cwd, envFile, live, json }) {
|
|
1338
|
+
const env = yield* environmentOf(yield* appDir(cwd), envFile)
|
|
1339
|
+
const admin = env["ELOXIV_ADMIN_DATABASE_URL"]
|
|
1340
|
+
const liveChecks = !live
|
|
1341
|
+
? []
|
|
1342
|
+
: admin === undefined
|
|
1343
|
+
? [{ id: "live", status: "not-run" as const, detail: "ELOXIV_ADMIN_DATABASE_URL is not set" }]
|
|
1344
|
+
: checkLive(admin)
|
|
1345
|
+
yield* printChecks(
|
|
1346
|
+
[...checkUrls(env).map((c) => ({ id: c.env, status: c.status, detail: c.detail })), ...liveChecks],
|
|
1347
|
+
json,
|
|
1348
|
+
)
|
|
1349
|
+
}),
|
|
1350
|
+
).pipe(
|
|
1351
|
+
Command.withDescription(
|
|
1352
|
+
"Classify the deployment's database URLs (direct, pooler, proxy) against what each connection needs; --live reads the host",
|
|
1353
|
+
),
|
|
1354
|
+
),
|
|
1355
|
+
Command.make(
|
|
1356
|
+
"schemas",
|
|
1357
|
+
{ json: jsonFlag },
|
|
1358
|
+
Effect.fn(function* ({ json }) {
|
|
1359
|
+
const list = yield* promised(() => schemas(adminTarget(process.env)))
|
|
1360
|
+
yield* Console.log(
|
|
1361
|
+
json
|
|
1362
|
+
? JSON.stringify(list, null, 2)
|
|
1363
|
+
: list.map((s) => `${s.schema.padEnd(28)} ${String(s.tables).padStart(4)} tables ${s.owner}`).join("\n"),
|
|
1364
|
+
)
|
|
1365
|
+
}),
|
|
1366
|
+
).pipe(Command.withDescription("Development only: the app database's schemas")),
|
|
1367
|
+
Command.make(
|
|
1368
|
+
"tables",
|
|
1369
|
+
{
|
|
1370
|
+
schema: Argument.String("schema").pipe(Argument.withDescription("Only this schema"), Argument.optional),
|
|
1371
|
+
json: jsonFlag,
|
|
1372
|
+
},
|
|
1373
|
+
Effect.fn(function* ({ schema, json }) {
|
|
1374
|
+
const list = yield* promised(() => tables(adminTarget(process.env), Option.getOrUndefined(schema)))
|
|
1375
|
+
yield* Console.log(
|
|
1376
|
+
json
|
|
1377
|
+
? JSON.stringify(list, null, 2)
|
|
1378
|
+
: list
|
|
1379
|
+
.map((t) => `${t.table.padEnd(48)} ~${t.rows} rows${t.rls ? " (row-level security)" : ""}`)
|
|
1380
|
+
.join("\n"),
|
|
1381
|
+
)
|
|
1382
|
+
}),
|
|
1383
|
+
).pipe(Command.withDescription("Development only: tables with their row estimates")),
|
|
1384
|
+
Command.make(
|
|
1385
|
+
"rows",
|
|
1386
|
+
{
|
|
1387
|
+
table: Argument.String("table").pipe(Argument.withDescription("<schema>.<table>")),
|
|
1388
|
+
limit: Flag.Int("limit").pipe(
|
|
1389
|
+
Flag.withDescription("At most this many rows (default 20, at most 1000)"),
|
|
1390
|
+
Flag.withDefault(20),
|
|
1391
|
+
),
|
|
1392
|
+
},
|
|
1393
|
+
Effect.fn(function* ({ table, limit }) {
|
|
1394
|
+
const found = yield* promised(() => rows(adminTarget(process.env), table, limit))
|
|
1395
|
+
yield* Console.log(JSON.stringify(found, null, 2))
|
|
1396
|
+
}),
|
|
1397
|
+
).pipe(Command.withDescription("Development only: a table's rows as JSON (past row-level security)")),
|
|
1398
|
+
Command.make(
|
|
1399
|
+
"sql",
|
|
1400
|
+
{
|
|
1401
|
+
sql: Argument.String("sql").pipe(Argument.withDescription("The SQL to run")),
|
|
1402
|
+
write: Flag.Boolean("write").pipe(
|
|
1403
|
+
Flag.withDescription("Allow writes (default: read-only transactions)"),
|
|
1404
|
+
Flag.withDefault(false),
|
|
1405
|
+
),
|
|
1406
|
+
},
|
|
1407
|
+
Effect.fn(function* ({ sql, write }) {
|
|
1408
|
+
yield* Console.log((yield* promised(() => runSql(adminTarget(process.env), sql, { write }))).trimEnd())
|
|
1409
|
+
}),
|
|
1410
|
+
).pipe(
|
|
1411
|
+
Command.withDescription(
|
|
1412
|
+
"Development only: run SQL on the app's database as the setup role, read-only unless --write",
|
|
1413
|
+
),
|
|
1414
|
+
),
|
|
1415
|
+
]),
|
|
1416
|
+
)
|
|
1417
|
+
|
|
1418
|
+
export const eloxiv = Command.make("eloxiv").pipe(
|
|
1419
|
+
Command.withDescription("Assemble Eloxiv apps from the registry, and call a running kernel"),
|
|
1420
|
+
Command.withSubcommands([
|
|
1421
|
+
init,
|
|
1422
|
+
add,
|
|
1423
|
+
diffCommand,
|
|
1424
|
+
updateCommand,
|
|
1425
|
+
ejectCommand,
|
|
1426
|
+
restoreCommand,
|
|
1427
|
+
infoCommand,
|
|
1428
|
+
listCommand,
|
|
1429
|
+
generate,
|
|
1430
|
+
setupCommand,
|
|
1431
|
+
doctorCommand,
|
|
1432
|
+
cleanCommand,
|
|
1433
|
+
loginCommand,
|
|
1434
|
+
logoutCommand,
|
|
1435
|
+
whoamiCommand,
|
|
1436
|
+
actionsCommand,
|
|
1437
|
+
callCommand,
|
|
1438
|
+
agentCommand,
|
|
1439
|
+
mcpCommand,
|
|
1440
|
+
devCommand,
|
|
1441
|
+
buildCommand,
|
|
1442
|
+
startCommand,
|
|
1443
|
+
typecheckCommand,
|
|
1444
|
+
deployCommand,
|
|
1445
|
+
dbCommand,
|
|
1446
|
+
docsCommand,
|
|
1447
|
+
migrateCommand,
|
|
1448
|
+
blueprintCommand,
|
|
1449
|
+
changelogCommand,
|
|
1450
|
+
evalCommand,
|
|
1451
|
+
agentWebCommand,
|
|
1452
|
+
brandCommand,
|
|
1453
|
+
skillsCommand,
|
|
1454
|
+
pluginCommand,
|
|
1455
|
+
]),
|
|
1456
|
+
)
|
|
1457
|
+
|
|
1458
|
+
export const run = Command.run(eloxiv, { version: CLI_VERSION })
|