@intelligo-dev/cli 1.0.0-beta.1 → 1.0.0-beta.14
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/NOTICE +6 -0
- package/README.md +102 -0
- package/dist/bin.js +122 -37
- package/dist/bin.js.map +1 -1
- package/dist/commands/add.d.ts +26 -1
- package/dist/commands/add.d.ts.map +1 -1
- package/dist/commands/add.js +70 -4
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/create-flow.d.ts +37 -0
- package/dist/commands/create-flow.d.ts.map +1 -0
- package/dist/commands/create-flow.js +212 -0
- package/dist/commands/create-flow.js.map +1 -0
- package/dist/commands/create.d.ts +27 -6
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +53 -13
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/doctor.d.ts +14 -3
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +295 -37
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/migrate-check.d.ts +73 -1
- package/dist/commands/migrate-check.d.ts.map +1 -1
- package/dist/commands/migrate-check.js +130 -5
- package/dist/commands/migrate-check.js.map +1 -1
- package/dist/commands/migrate.d.ts +97 -0
- package/dist/commands/migrate.d.ts.map +1 -0
- package/dist/commands/migrate.js +141 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/sync-messages.d.ts +37 -0
- package/dist/commands/sync-messages.d.ts.map +1 -0
- package/dist/commands/sync-messages.js +88 -0
- package/dist/commands/sync-messages.js.map +1 -0
- package/dist/commands/sync-scaffold.d.ts +36 -0
- package/dist/commands/sync-scaffold.d.ts.map +1 -0
- package/dist/commands/sync-scaffold.js +53 -0
- package/dist/commands/sync-scaffold.js.map +1 -0
- package/dist/commands/sync.d.ts +103 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +361 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/commands/upgrade-check.d.ts +5 -5
- package/dist/commands/upgrade-check.d.ts.map +1 -1
- package/dist/commands/upgrade-check.js +22 -6
- package/dist/commands/upgrade-check.js.map +1 -1
- package/dist/env-files.d.ts +12 -0
- package/dist/env-files.d.ts.map +1 -0
- package/dist/env-files.js +29 -0
- package/dist/env-files.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/manifest.d.ts +36 -15
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +32 -16
- package/dist/manifest.js.map +1 -1
- package/dist/migrations.d.ts +3 -6
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +3 -6
- package/dist/migrations.js.map +1 -1
- package/dist/model-catalogue.d.ts +14 -0
- package/dist/model-catalogue.d.ts.map +1 -0
- package/dist/model-catalogue.js +34 -0
- package/dist/model-catalogue.js.map +1 -0
- package/dist/module-exports.d.ts +63 -0
- package/dist/module-exports.d.ts.map +1 -0
- package/dist/module-exports.js +231 -0
- package/dist/module-exports.js.map +1 -0
- package/dist/registry-bundle.d.ts +43 -0
- package/dist/registry-bundle.d.ts.map +1 -0
- package/dist/registry-bundle.js +74 -0
- package/dist/registry-bundle.js.map +1 -0
- package/dist/registry-items.d.ts +84 -0
- package/dist/registry-items.d.ts.map +1 -0
- package/dist/registry-items.js +187 -0
- package/dist/registry-items.js.map +1 -0
- package/package.json +36 -10
- package/src/bin.ts +316 -0
- package/src/commands/add.ts +255 -0
- package/src/commands/create-flow.ts +284 -0
- package/src/commands/create.ts +149 -0
- package/src/commands/doctor.ts +487 -0
- package/src/commands/migrate-check.ts +298 -0
- package/src/commands/migrate.ts +228 -0
- package/src/commands/sync-messages.ts +114 -0
- package/src/commands/sync-scaffold.ts +83 -0
- package/src/commands/sync.ts +534 -0
- package/src/commands/upgrade-check.ts +160 -0
- package/src/env-files.ts +31 -0
- package/src/index.ts +39 -0
- package/src/manifest.ts +147 -0
- package/src/migrations-dir.ts +25 -0
- package/src/migrations.ts +133 -0
- package/src/model-catalogue.ts +35 -0
- package/src/module-exports.ts +266 -0
- package/src/registry-bundle.ts +103 -0
- package/src/registry-items.ts +237 -0
- package/templates/admin-page/admin-page.tsx.tpl +2 -3
- package/templates/app-scaffold/assistant-route.ts.tpl +2 -2
- package/templates/app-scaffold/auth-route.ts.tpl +10 -0
- package/templates/app-scaffold/components.json.tpl +6 -2
- package/templates/app-scaffold/db-schema.ts.tpl +29 -0
- package/templates/app-scaffold/drizzle-journal.json.tpl +5 -0
- package/templates/app-scaffold/drizzle.config.ts.tpl +45 -0
- package/templates/app-scaffold/env.example.tpl +65 -1
- package/templates/app-scaffold/globals.css.tpl +172 -281
- package/templates/app-scaffold/i18n-request.ts.tpl +25 -0
- package/templates/app-scaffold/instrumentation.ts.tpl +21 -0
- package/templates/app-scaffold/intelligo.ts.tpl +95 -41
- package/templates/app-scaffold/layout.tsx.tpl +18 -1
- package/templates/app-scaffold/lib-utils.ts.tpl +1 -6
- package/templates/app-scaffold/next.config.mjs.tpl +2 -0
- package/templates/app-scaffold/package.json.tpl +31 -17
- package/templates/app-scaffold/page.tsx.tpl +16 -0
- package/templates/app-scaffold/plans.ts.tpl +32 -13
- package/templates/app-scaffold/{middleware.ts.tpl → proxy.ts.tpl} +6 -0
- package/templates/app-scaffold/sonner.tsx.tpl +42 -20
- package/templates/app-scaffold/stripe-webhook-route.ts.tpl +24 -0
- package/templates/app-scaffold/theme-provider.tsx.tpl +6 -4
- package/templates/app-scaffold/tsconfig.json.tpl +20 -4
- package/templates/app-scaffold/use-mobile.ts.tpl +19 -0
- package/templates/app-scaffold/workspace-bootstrap.ts.tpl +30 -0
- package/templates/maintenance/maintenance-route.ts.tpl +119 -0
- package/templates/manifest.json +75 -17
- package/templates/registry/ai-agent-activity.json +23 -0
- package/templates/registry/ai-agent-progress.json +21 -0
- package/templates/registry/ai-approval-card.json +27 -0
- package/templates/registry/ai-artifact.json +22 -0
- package/templates/registry/ai-branch.json +21 -0
- package/templates/registry/ai-citations.json +24 -0
- package/templates/registry/ai-code-block.json +23 -0
- package/templates/registry/ai-composer-menu.json +19 -0
- package/templates/registry/ai-file-diff.json +25 -0
- package/templates/registry/ai-image-generation.json +23 -0
- package/templates/registry/ai-markdown.json +23 -0
- package/templates/registry/ai-message-bubble.json +23 -0
- package/templates/registry/ai-message-scroller.json +22 -0
- package/templates/registry/ai-message.json +21 -0
- package/templates/registry/ai-motion.json +19 -0
- package/templates/registry/ai-prompt-input.json +28 -0
- package/templates/registry/ai-reasoning-text.json +22 -0
- package/templates/registry/ai-reasoning.json +22 -0
- package/templates/registry/ai-shimmer-text.json +19 -0
- package/templates/registry/ai-sidebar.json +25 -0
- package/templates/registry/ai-speech-input.json +21 -0
- package/templates/registry/ai-streaming-response.json +24 -0
- package/templates/registry/ai-suggestion.json +19 -0
- package/templates/registry/ai-todo-list.json +22 -0
- package/templates/registry/ai-tool-approval.json +26 -0
- package/templates/registry/ai-tool-result.json +25 -0
- package/templates/registry/alert-dialog.json +23 -0
- package/templates/registry/animated-list.json +21 -0
- package/templates/registry/app-shell.json +93 -0
- package/templates/registry/artifacts.json +82 -0
- package/templates/registry/attachment.json +22 -0
- package/templates/registry/auth-email-verification.json +39 -0
- package/templates/registry/auth-login.json +72 -0
- package/templates/registry/auth-password-reset.json +53 -0
- package/templates/registry/auth-signup.json +41 -0
- package/templates/registry/billing-settings.json +60 -0
- package/templates/registry/button.json +22 -0
- package/templates/registry/chat-eve.json +19 -0
- package/templates/registry/chat-panel.json +30 -0
- package/templates/registry/chat-share.json +42 -0
- package/templates/registry/chat-widget.json +34 -0
- package/templates/registry/chat.json +326 -0
- package/templates/registry/checkbox.json +22 -0
- package/templates/registry/checkout.json +40 -0
- package/templates/registry/collapsible.json +19 -0
- package/templates/registry/command.json +23 -0
- package/templates/registry/copy-button.json +21 -0
- package/templates/registry/dashboard.json +69 -0
- package/templates/registry/dialog.json +24 -0
- package/templates/registry/document-viewer.json +22 -0
- package/templates/registry/dropdown-menu.json +23 -0
- package/templates/registry/expandable-tabs.json +22 -0
- package/templates/registry/feature-gating.json +73 -0
- package/templates/registry/file-upload.json +24 -0
- package/templates/registry/hold-action-button.json +22 -0
- package/templates/registry/input-group.json +23 -0
- package/templates/registry/input.json +19 -0
- package/templates/registry/intelligo.json +187 -0
- package/templates/registry/invitation-accept.json +64 -0
- package/templates/registry/language-switcher.json +29 -0
- package/templates/registry/morphing-modal.json +24 -0
- package/templates/registry/notification-stack.json +24 -0
- package/templates/registry/notifications.json +87 -0
- package/templates/registry/onboarding.json +83 -0
- package/templates/registry/otp-input.json +22 -0
- package/templates/registry/page-header.json +15 -0
- package/templates/registry/payment-poll.json +52 -0
- package/templates/registry/popover-morph.json +22 -0
- package/templates/registry/popover.json +22 -0
- package/templates/registry/pricing.json +111 -0
- package/templates/registry/privacy-settings.json +65 -0
- package/templates/registry/profile-settings.json +68 -0
- package/templates/registry/progress.json +19 -0
- package/templates/registry/radio-group.json +22 -0
- package/templates/registry/registry.json +2945 -0
- package/templates/registry/route-error.json +65 -0
- package/templates/registry/select-morph.json +23 -0
- package/templates/registry/select.json +23 -0
- package/templates/registry/settings-shell.json +47 -0
- package/templates/registry/sheet.json +24 -0
- package/templates/registry/sidebar.json +28 -0
- package/templates/registry/smoke.json +34 -0
- package/templates/registry/spinner.json +16 -0
- package/templates/registry/stat-card.json +18 -0
- package/templates/registry/status-badge.json +18 -0
- package/templates/registry/switch.json +20 -0
- package/templates/registry/tabs.json +23 -0
- package/templates/registry/team-settings.json +97 -0
- package/templates/registry/textarea.json +16 -0
- package/templates/registry/tooltip.json +22 -0
- package/templates/registry/trial-banner.json +43 -0
- package/templates/registry/usage.json +84 -0
- package/templates/registry/workspace-settings.json +71 -0
- package/templates/registry-items.json +116 -0
- package/templates/registry-requires.json +180 -0
- package/templates/usage-page/usage-page.tsx.tpl +23 -8
- package/templates/vitest/server-only.ts.tpl +7 -0
- package/templates/vitest/vitest.config.ts.tpl +37 -0
- package/templates/billing-page/billing-page.tsx.tpl +0 -72
package/dist/commands/doctor.js
CHANGED
|
@@ -1,27 +1,197 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `intelligo doctor` — report the problems that are invisible until
|
|
3
3
|
* they are an incident.
|
|
4
|
-
*
|
|
5
|
-
* The checks here were each chosen because something in this codebase
|
|
6
|
-
* actually went wrong that way, not because they sounded thorough.
|
|
7
4
|
*/
|
|
8
5
|
import path from "node:path";
|
|
9
|
-
import {
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
8
|
+
import { parseEnv } from "node:util";
|
|
10
9
|
import { inspectMigrationChain, readMigrationChain } from "../migrations.js";
|
|
11
10
|
import { readManifest } from "../manifest.js";
|
|
11
|
+
import { checkExports, hasObjectKey, reexportedSource, stripComments, } from "../module-exports.js";
|
|
12
|
+
import { MODEL_CATALOGUE_LOCATIONS, readCatalogueModelIds, } from "../model-catalogue.js";
|
|
12
13
|
import { MIGRATION_LOCATIONS, resolveMigrationsDir, } from "../migrations-dir.js";
|
|
14
|
+
/**
|
|
15
|
+
* templates/registry-requires.json is a build-time copy of
|
|
16
|
+
* packages/registry/requires.json (scripts/sync-registry-requires.mjs),
|
|
17
|
+
* committed so that running from source works too, and shipped so
|
|
18
|
+
* doctor can check an installed app without a registry checkout.
|
|
19
|
+
* `../../templates` resolves from src/ and from dist/commands/ alike.
|
|
20
|
+
*/
|
|
21
|
+
function bundledRequires() {
|
|
22
|
+
const file = path.resolve(
|
|
23
|
+
// fileURLToPath, not `.pathname` — see the note in bin.ts.
|
|
24
|
+
path.dirname(fileURLToPath(import.meta.url)), "..", "..", "templates", "registry-requires.json");
|
|
25
|
+
if (!existsSync(file))
|
|
26
|
+
return null;
|
|
27
|
+
return JSON.parse(readFileSync(file, "utf8"));
|
|
28
|
+
}
|
|
13
29
|
/** Variables the app cannot boot without. */
|
|
14
30
|
const REQUIRED_ENV = [
|
|
15
31
|
"DATABASE_URL",
|
|
16
32
|
"BETTER_AUTH_SECRET",
|
|
17
33
|
"NEXT_PUBLIC_APP_URL",
|
|
18
34
|
];
|
|
35
|
+
/** The app's `assertEnv` refuses a shorter BETTER_AUTH_SECRET. */
|
|
36
|
+
const MIN_AUTH_SECRET_LENGTH = 32;
|
|
37
|
+
/** Env files Next.js reads only for a production build or server. */
|
|
38
|
+
const PRODUCTION_ENV_FILES = [".env.production.local", ".env.production"];
|
|
39
|
+
const LOCAL_URL = /^https?:\/\/(?:localhost|127\.0\.0\.1|\[::1\])(?::|\/|$)/;
|
|
40
|
+
/**
|
|
41
|
+
* Where a production deployment would get a NEXT_PUBLIC_APP_URL that
|
|
42
|
+
* points at this machine: the environment itself when it says
|
|
43
|
+
* production, or a production env file in the app.
|
|
44
|
+
*/
|
|
45
|
+
function localAppUrlInProduction(root, env) {
|
|
46
|
+
if (env.NODE_ENV === "production" &&
|
|
47
|
+
LOCAL_URL.test(env.NEXT_PUBLIC_APP_URL ?? "")) {
|
|
48
|
+
return "NODE_ENV=production";
|
|
49
|
+
}
|
|
50
|
+
for (const name of PRODUCTION_ENV_FILES) {
|
|
51
|
+
const file = path.join(root, name);
|
|
52
|
+
if (!existsSync(file))
|
|
53
|
+
continue;
|
|
54
|
+
const url = parseEnv(readFileSync(file, "utf8")).NEXT_PUBLIC_APP_URL;
|
|
55
|
+
if (url && LOCAL_URL.test(url))
|
|
56
|
+
return name;
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
/** Files of the chat items that name the models a deployment runs on. */
|
|
61
|
+
const MODEL_ID_FILES = [
|
|
62
|
+
"lib/chat-model.ts",
|
|
63
|
+
"lib/chat-models.ts",
|
|
64
|
+
"lib/chat-server-config.ts",
|
|
65
|
+
];
|
|
66
|
+
/** A provider-prefixed model id literal, in any of the three quote styles. */
|
|
67
|
+
const MODEL_ID = /["'`]((?:openai|anthropic|google|xai|mistral|meta)\/[a-z0-9._-]+)["'`]/g;
|
|
68
|
+
/** `id: "provider/model"` — a model registered by a literal. */
|
|
69
|
+
const REGISTERED_ID = /\bid:\s*["'`]([a-z0-9-]+\/[a-z0-9._-]+)["'`]/g;
|
|
70
|
+
/**
|
|
71
|
+
* Required environment: present, and strong enough that the app's own
|
|
72
|
+
* startup validation will accept it.
|
|
73
|
+
*/
|
|
74
|
+
function checkEnvironment(root, env) {
|
|
75
|
+
const results = [];
|
|
76
|
+
const missing = REQUIRED_ENV.filter((k) => !env[k]);
|
|
77
|
+
const authSecret = env.BETTER_AUTH_SECRET ?? "";
|
|
78
|
+
const weakSecret = authSecret.length > 0 && authSecret.length < MIN_AUTH_SECRET_LENGTH;
|
|
79
|
+
if (missing.length > 0) {
|
|
80
|
+
results.push({
|
|
81
|
+
name: "env",
|
|
82
|
+
status: "error",
|
|
83
|
+
detail: `Missing: ${missing.join(", ")}`,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
if (weakSecret) {
|
|
87
|
+
results.push({
|
|
88
|
+
name: "env",
|
|
89
|
+
status: "error",
|
|
90
|
+
detail: `BETTER_AUTH_SECRET is ${authSecret.length} chars — the app refuses to ` +
|
|
91
|
+
`boot with fewer than ${MIN_AUTH_SECRET_LENGTH}. Generate one with: ` +
|
|
92
|
+
"openssl rand -base64 32",
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
if (missing.length === 0 && !weakSecret) {
|
|
96
|
+
results.push({
|
|
97
|
+
name: "env",
|
|
98
|
+
status: "ok",
|
|
99
|
+
detail: `${REQUIRED_ENV.length} required variables present`,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
const localUrlSource = localAppUrlInProduction(root, env);
|
|
103
|
+
if (localUrlSource) {
|
|
104
|
+
results.push({
|
|
105
|
+
name: "env",
|
|
106
|
+
status: "warn",
|
|
107
|
+
detail: `NEXT_PUBLIC_APP_URL points at localhost (${localUrlSource}) — auth ` +
|
|
108
|
+
"callbacks and email links are built from it; production needs the " +
|
|
109
|
+
"public https URL",
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return results;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Model ids. A registered catalogue still refuses an id it does not
|
|
116
|
+
* hold, so a typo in the chat seam is a refused first turn. Every
|
|
117
|
+
* provider-prefixed literal there must be in DEFAULT_MODELS (when the
|
|
118
|
+
* root registers it) or registered by a literal `id` in the root.
|
|
119
|
+
*/
|
|
120
|
+
function checkModelIds(root, source) {
|
|
121
|
+
const used = new Map();
|
|
122
|
+
for (const rel of MODEL_ID_FILES) {
|
|
123
|
+
const file = path.join(root, rel);
|
|
124
|
+
if (!existsSync(file))
|
|
125
|
+
continue;
|
|
126
|
+
const text = stripComments(readFileSync(file, "utf8"));
|
|
127
|
+
for (const match of text.matchAll(MODEL_ID)) {
|
|
128
|
+
if (!used.has(match[1]))
|
|
129
|
+
used.set(match[1], rel);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (used.size === 0)
|
|
133
|
+
return [];
|
|
134
|
+
const code = stripComments(source);
|
|
135
|
+
const known = new Set([...code.matchAll(REGISTERED_ID)].map((m) => m[1]));
|
|
136
|
+
const usesCatalogue = /\bDEFAULT_MODELS\b/.test(code);
|
|
137
|
+
const catalogue = usesCatalogue ? readCatalogueModelIds(root) : null;
|
|
138
|
+
for (const id of catalogue ?? [])
|
|
139
|
+
known.add(id);
|
|
140
|
+
const unknown = [...used].filter(([id]) => !known.has(id));
|
|
141
|
+
const listed = unknown.map(([id, rel]) => `${id} (${rel})`).join(", ");
|
|
142
|
+
if (unknown.length === 0) {
|
|
143
|
+
return [
|
|
144
|
+
{
|
|
145
|
+
name: "model-ids",
|
|
146
|
+
status: "ok",
|
|
147
|
+
detail: `${used.size} model id(s) in the chat seam, all registered`,
|
|
148
|
+
},
|
|
149
|
+
];
|
|
150
|
+
}
|
|
151
|
+
else if (usesCatalogue && !catalogue) {
|
|
152
|
+
return [
|
|
153
|
+
{
|
|
154
|
+
name: "model-ids",
|
|
155
|
+
status: "warn",
|
|
156
|
+
detail: `cannot read DEFAULT_MODELS (looked in ${MODEL_CATALOGUE_LOCATIONS.join(", ")}) ` +
|
|
157
|
+
`to check ${listed} — is @intelligo-dev/executions installed?`,
|
|
158
|
+
},
|
|
159
|
+
];
|
|
160
|
+
}
|
|
161
|
+
else if (OPAQUE_REGISTRATION.test(code)) {
|
|
162
|
+
return [
|
|
163
|
+
{
|
|
164
|
+
name: "model-ids",
|
|
165
|
+
status: "warn",
|
|
166
|
+
detail: `${listed} not found in DEFAULT_MODELS or a literal registerModel({ id }) — ` +
|
|
167
|
+
"the composition root registers a catalogue defined elsewhere, " +
|
|
168
|
+
"so confirm it holds them",
|
|
169
|
+
},
|
|
170
|
+
];
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
return [
|
|
174
|
+
{
|
|
175
|
+
name: "model-ids",
|
|
176
|
+
status: "error",
|
|
177
|
+
detail: `${listed} not registered — admission refuses an unpriced model ` +
|
|
178
|
+
"with `unknown_model`. Fix the id, or add " +
|
|
179
|
+
"`registerModel({ id, … })` to the composition root",
|
|
180
|
+
},
|
|
181
|
+
];
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* A `registerModel(s)` argument that is neither a literal nor
|
|
186
|
+
* `DEFAULT_MODELS`: a catalogue defined in another module, whose ids
|
|
187
|
+
* cannot be read from the composition root.
|
|
188
|
+
*/
|
|
189
|
+
const OPAQUE_REGISTRATION = /\bregisterModels?\s*\(\s*(?![\s[{]|DEFAULT_MODELS\s*[,)])/;
|
|
19
190
|
export function runChecks(options = {}) {
|
|
20
191
|
const root = options.root ?? process.cwd();
|
|
21
192
|
const env = options.env ?? process.env;
|
|
22
193
|
const results = [];
|
|
23
|
-
// 1. Migration chain
|
|
24
|
-
// files documentation rather than a provisioning mechanism.
|
|
194
|
+
// 1. Migration chain: drift between the journal and the .sql files.
|
|
25
195
|
const migrationsDir = resolveMigrationsDir(root);
|
|
26
196
|
if (!migrationsDir) {
|
|
27
197
|
results.push({
|
|
@@ -51,21 +221,10 @@ export function runChecks(options = {}) {
|
|
|
51
221
|
}
|
|
52
222
|
}
|
|
53
223
|
// 2. Required environment.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
status: "ok",
|
|
59
|
-
detail: `${REQUIRED_ENV.length} required variables present`,
|
|
60
|
-
}
|
|
61
|
-
: {
|
|
62
|
-
name: "env",
|
|
63
|
-
status: "error",
|
|
64
|
-
detail: `Missing: ${missing.join(", ")}`,
|
|
65
|
-
});
|
|
66
|
-
// 3. Billing product. The engine has no built-in default since the
|
|
67
|
-
// Career catalogue moved out; an unset product means every plan
|
|
68
|
-
// lookup returns nothing and quotas silently read as zero.
|
|
224
|
+
results.push(...checkEnvironment(root, env));
|
|
225
|
+
// 3. Billing product. The engine has no built-in default catalogue;
|
|
226
|
+
// an unset product means every plan lookup returns nothing and
|
|
227
|
+
// quotas silently read as zero.
|
|
69
228
|
results.push(env.INTELLIGO_BILLING_PRODUCT
|
|
70
229
|
? {
|
|
71
230
|
name: "billing",
|
|
@@ -78,28 +237,127 @@ export function runChecks(options = {}) {
|
|
|
78
237
|
detail: "INTELLIGO_BILLING_PRODUCT unset — the composition root must call " +
|
|
79
238
|
"setDefaultProductSlug(), or plan lookups resolve to nothing",
|
|
80
239
|
});
|
|
81
|
-
// 4.
|
|
82
|
-
//
|
|
83
|
-
// composition root
|
|
84
|
-
//
|
|
85
|
-
//
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
240
|
+
// 4. Installed registry items against registry/requires.json: the
|
|
241
|
+
// sibling items they import from, the scaffold files they import,
|
|
242
|
+
// the exports the composition root must provide, and the feature
|
|
243
|
+
// keys they gate on — each a `next build` or a 403 that only shows
|
|
244
|
+
// up later. An item counts as installed when its marker file is.
|
|
245
|
+
const requires = options.requires === undefined ? bundledRequires() : options.requires;
|
|
246
|
+
if (requires) {
|
|
247
|
+
const exists = (rel) => [".ts", ".tsx", ".js", ".jsx", ".json", ""].some((ext) => existsSync(path.join(root, rel + ext)));
|
|
248
|
+
// lib/plans.ts and whatever it re-exports — a catalogue defined in
|
|
249
|
+
// a workspace package counts — comments stripped.
|
|
250
|
+
const plansFile = ["lib/plans.ts", "lib/plans.tsx"]
|
|
251
|
+
.map((rel) => path.join(root, rel))
|
|
252
|
+
.find((file) => existsSync(file));
|
|
253
|
+
const plans = plansFile ? reexportedSource(plansFile, root) : null;
|
|
254
|
+
for (const [name, item] of Object.entries(requires.items)) {
|
|
255
|
+
if (!existsSync(path.join(root, item.marker)))
|
|
256
|
+
continue;
|
|
257
|
+
const problems = [];
|
|
258
|
+
const notes = [];
|
|
259
|
+
for (const dep of item.items ?? []) {
|
|
260
|
+
const marker = requires.items[dep]?.marker;
|
|
261
|
+
if (marker && !existsSync(path.join(root, marker))) {
|
|
262
|
+
problems.push(`install the ${dep} item first`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
for (const file of item.files ?? []) {
|
|
266
|
+
if (!exists(file))
|
|
267
|
+
problems.push(`create ${file} (scaffold-provided)`);
|
|
268
|
+
}
|
|
269
|
+
for (const [file, names] of Object.entries(item.exports ?? {})) {
|
|
270
|
+
const abs = [".ts", ".tsx"]
|
|
271
|
+
.map((ext) => path.join(root, file + ext))
|
|
272
|
+
.find((p) => existsSync(p));
|
|
273
|
+
if (!abs)
|
|
274
|
+
continue; // reported above as a missing file
|
|
275
|
+
const { missing, unresolved } = checkExports(abs, names, root);
|
|
276
|
+
if (missing.length) {
|
|
277
|
+
problems.push(`${file} must export ${missing.join(", ")}`);
|
|
278
|
+
}
|
|
279
|
+
else if (unresolved.length) {
|
|
280
|
+
notes.push(`${file}: could not read ${unresolved.map((u) => `\`export * from "${u}"\``).join(", ")} — assumed to provide ${names.join(", ")}`);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
for (const feature of item.features ?? []) {
|
|
284
|
+
if (!plans || hasObjectKey(plans.text, feature))
|
|
285
|
+
continue;
|
|
286
|
+
if (plans.unresolved.length) {
|
|
287
|
+
notes.push(`the "${feature}" feature key is not in lib/plans.ts, and ${plans.unresolved.join(", ")} could not be read to confirm it`);
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
problems.push(`register the "${feature}" feature key in lib/plans.ts — an unregistered key is denied (403)`);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
results.push(problems.length === 0
|
|
294
|
+
? notes.length === 0
|
|
295
|
+
? { name: `item:${name}`, status: "ok", detail: "requirements met" }
|
|
296
|
+
: { name: `item:${name}`, status: "warn", detail: notes.join("; ") }
|
|
297
|
+
: {
|
|
298
|
+
name: `item:${name}`,
|
|
299
|
+
status: "error",
|
|
300
|
+
detail: problems.join("; "),
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
// 4b. Maintenance route. It refuses to serve without a strong
|
|
305
|
+
// CRON_SECRET, and a scheduler hitting a 403 every five minutes
|
|
306
|
+
// is easy to miss.
|
|
307
|
+
if (existsSync(path.join(root, "app/api/cron/maintenance/route.ts"))) {
|
|
308
|
+
const cronSecret = env.CRON_SECRET ?? "";
|
|
309
|
+
results.push(cronSecret.length >= 32
|
|
310
|
+
? { name: "maintenance", status: "ok", detail: "CRON_SECRET set" }
|
|
311
|
+
: {
|
|
312
|
+
name: "maintenance",
|
|
313
|
+
status: "error",
|
|
314
|
+
detail: "app/api/cron/maintenance/route.ts exists but CRON_SECRET is " +
|
|
315
|
+
(cronSecret ? "shorter than 32 chars" : "unset") +
|
|
316
|
+
" — the route answers 403 until it is",
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
// 4c. Better-Auth's HTTP mount. Every auth item's form posts to
|
|
320
|
+
// `/api/auth/*` on this origin; without the catch-all route
|
|
321
|
+
// those requests 404 and the pages look broken for no visible
|
|
322
|
+
// reason.
|
|
323
|
+
if (existsSync(path.join(root, "app/[locale]/(auth)/layout.tsx"))) {
|
|
324
|
+
results.push(existsSync(path.join(root, "app/api/auth/[...all]/route.ts"))
|
|
325
|
+
? { name: "auth-mount", status: "ok", detail: "/api/auth mounted" }
|
|
326
|
+
: {
|
|
327
|
+
name: "auth-mount",
|
|
328
|
+
status: "error",
|
|
329
|
+
detail: "auth pages are installed but app/api/auth/[...all]/route.ts " +
|
|
330
|
+
"is missing — add `export { GET, POST } from " +
|
|
331
|
+
'"@intelligo-dev/next/auth";` there or every sign-in answers 404',
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
// 4d. Model prices. The registry is open and nothing self-registers,
|
|
335
|
+
// so a composition root that never calls `registerModels` leaves
|
|
336
|
+
// admission with no price to estimate against: every request is
|
|
337
|
+
// refused with `unknown_model`, at runtime, on a deployment whose
|
|
338
|
+
// only mistake was omitting one line.
|
|
339
|
+
const compositionRoot = ["lib/intelligo.ts", "lib/intelligo.tsx"]
|
|
340
|
+
.map((rel) => path.join(root, rel))
|
|
341
|
+
.find((file) => existsSync(file));
|
|
342
|
+
if (compositionRoot) {
|
|
343
|
+
const source = readFileSync(compositionRoot, "utf8");
|
|
344
|
+
const registers = /\bregisterModels?\s*\(/.test(stripComments(source));
|
|
345
|
+
results.push(registers
|
|
91
346
|
? {
|
|
92
|
-
name: "
|
|
347
|
+
name: "models",
|
|
93
348
|
status: "ok",
|
|
94
|
-
detail: "
|
|
349
|
+
detail: "the composition root registers model prices",
|
|
95
350
|
}
|
|
96
351
|
: {
|
|
97
|
-
name: "
|
|
352
|
+
name: "models",
|
|
98
353
|
status: "error",
|
|
99
|
-
detail:
|
|
100
|
-
"
|
|
101
|
-
"(
|
|
354
|
+
detail: "no registerModels() in the composition root — admission cannot " +
|
|
355
|
+
"price any model and refuses every request with `unknown_model`. " +
|
|
356
|
+
"Add `registerModels(DEFAULT_MODELS)` from @intelligo-dev/executions, " +
|
|
357
|
+
"or your own catalogue",
|
|
102
358
|
});
|
|
359
|
+
if (registers)
|
|
360
|
+
results.push(...checkModelIds(root, source));
|
|
103
361
|
}
|
|
104
362
|
// 5. Generated source. A conflict — template and consumer both
|
|
105
363
|
// moved — is the one state an upgrade cannot resolve on its own.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAe9B,6CAA6C;AAC7C,MAAM,YAAY,GAAG;IACnB,cAAc;IACd,oBAAoB;IACpB,qBAAqB;CACtB,CAAC;AAEF,MAAM,UAAU,SAAS,CAAC,UAAyB,EAAE;IACnD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAC3C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACvC,MAAM,OAAO,GAAkB,EAAE,CAAC;IAElC,iEAAiE;IACjE,+DAA+D;IAC/D,MAAM,aAAa,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;IACjD,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,CAAC,IAAI,CAAC;YACX,IAAI,EAAE,YAAY;YAClB,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,sCAAsC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,sEAAsE;SACnJ,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,MAAM,KAAK,GAAG,kBAAkB,CAAC,aAAa,CAAC,CAAC;QAChD,MAAM,QAAQ,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;QAC9C,IAAI,QAAQ,CAAC,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AAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;SAChE,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,WAAW,CAAC,OAAsB;IAChD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -15,6 +15,29 @@
|
|
|
15
15
|
* schema but no rows there at all, which this reports distinctly:
|
|
16
16
|
* "unmanaged" is a different problem from "behind", and baselining is
|
|
17
17
|
* the fix (see the migrations README).
|
|
18
|
+
*
|
|
19
|
+
* The framework's chain is one baseline. A database that ran the pre-1.0
|
|
20
|
+
* chain holds its hashes, which `legacy-chain.json` (next to the
|
|
21
|
+
* journal) lists: they are reported as `legacy`, not as unknown, and a
|
|
22
|
+
* database holding all of them is `adoptable` — its schema is the
|
|
23
|
+
* baseline's, so `migrate` records the baseline without running it.
|
|
24
|
+
*
|
|
25
|
+
* The exit code is 1 whenever anything is pending or the database is
|
|
26
|
+
* ahead, which a brand-new database and a stale one share. A deploy
|
|
27
|
+
* gate that must tell them apart reads `migrate --check --json`: one
|
|
28
|
+
* JSON object on stdout, same exit code, whose `state` is
|
|
29
|
+
*
|
|
30
|
+
* - `up_to_date` — every migration is applied;
|
|
31
|
+
* - `pending` — a migrated database is behind this checkout;
|
|
32
|
+
* - `fresh` — no migration records and none of the framework's
|
|
33
|
+
* tables: an empty database, `migrate` applies the chain;
|
|
34
|
+
* - `unmanaged` — the tables exist with no records (`db:push`);
|
|
35
|
+
* - `ahead` — applied migrations this checkout does not contain;
|
|
36
|
+
* - `legacy` — the pre-1.0 chain; `adoptable` says whether
|
|
37
|
+
* `migrate` can take it over.
|
|
38
|
+
*
|
|
39
|
+
* Beside `state` it carries `exitCode`, `chain`, `applied`, `pending`,
|
|
40
|
+
* `unknown`, `legacy`, `legacyMissing` and `adoptable`.
|
|
18
41
|
*/
|
|
19
42
|
export type MigrateCheckResult = {
|
|
20
43
|
/** Journal tags this checkout knows about, in order. */
|
|
@@ -30,15 +53,64 @@ export type MigrateCheckResult = {
|
|
|
30
53
|
* schema exists — a push-provisioned database that needs baselining.
|
|
31
54
|
*/
|
|
32
55
|
unmanaged: boolean;
|
|
56
|
+
/** Pre-1.0 migrations the database ran, by tag. */
|
|
57
|
+
legacy: string[];
|
|
58
|
+
/** Length of the pre-1.0 chain (0 when this checkout ships none). */
|
|
59
|
+
legacyChainLength: number;
|
|
60
|
+
/**
|
|
61
|
+
* Pre-1.0 migrations the database has not run, by tag, in chain
|
|
62
|
+
* order — empty unless it ran some of them.
|
|
63
|
+
*/
|
|
64
|
+
legacyMissing: string[];
|
|
65
|
+
/**
|
|
66
|
+
* The database ran the whole pre-1.0 chain and not the baseline:
|
|
67
|
+
* `migrate` records the baseline as applied without running it.
|
|
68
|
+
*/
|
|
69
|
+
adoptable: boolean;
|
|
33
70
|
};
|
|
71
|
+
/** The pre-1.0 chain's tags and hashes, if this checkout ships them. */
|
|
72
|
+
export declare function readLegacyChain(migrationsDir: string): Array<{
|
|
73
|
+
tag: string;
|
|
74
|
+
hash: string;
|
|
75
|
+
alternates?: string[];
|
|
76
|
+
}>;
|
|
34
77
|
/** Drizzle hashes the file contents with sha256. */
|
|
35
78
|
export declare function hashMigration(sql: string): string;
|
|
36
79
|
type QueryFn = (sql: string) => Promise<Array<{
|
|
37
80
|
hash: string;
|
|
38
81
|
}>>;
|
|
39
82
|
export declare function migrateCheck(migrationsDir: string, query: QueryFn): Promise<MigrateCheckResult>;
|
|
40
|
-
|
|
83
|
+
/**
|
|
84
|
+
* `schemaExists` is whether the framework's tables are in the database
|
|
85
|
+
* (`SCHEMA_PROBE_SQL`). When the caller did not probe, a database with
|
|
86
|
+
* no records gets the cautious `db:push` wording.
|
|
87
|
+
*/
|
|
88
|
+
export declare function formatMigrateCheck(r: MigrateCheckResult, schemaExists?: boolean): string;
|
|
41
89
|
/** Non-zero when deploying this code would run against a stale schema. */
|
|
42
90
|
export declare function migrateCheckExitCode(r: MigrateCheckResult): number;
|
|
91
|
+
/** A partial pre-1.0 chain: neither adoptable nor migratable from here. */
|
|
92
|
+
export declare function isPartialLegacy(r: MigrateCheckResult): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* The last pre-1.0 migration any published `@intelligo-dev/core`
|
|
95
|
+
* carries: 1.0.0-beta.6 shipped the chain through it, and the versions
|
|
96
|
+
* that carried the rest were never published.
|
|
97
|
+
*/
|
|
98
|
+
export declare const LAST_PUBLISHED_LEGACY_TAG = "0042_sessions_active_organization_id";
|
|
99
|
+
/**
|
|
100
|
+
* Why a partial pre-1.0 chain is refused and where the way forward is
|
|
101
|
+
* written down. No published version finishes the chain, so the
|
|
102
|
+
* message names what is missing and points at the README's options
|
|
103
|
+
* instead of at a version to install.
|
|
104
|
+
*/
|
|
105
|
+
export declare function partialLegacyMessage(r: MigrateCheckResult): string;
|
|
106
|
+
export type MigrateState = "up_to_date" | "pending" | "fresh" | "ahead" | "unmanaged" | "legacy";
|
|
107
|
+
/**
|
|
108
|
+
* One word for what the check found, most urgent first: a database that
|
|
109
|
+
* is ahead or on the pre-1.0 chain is that before it is anything else.
|
|
110
|
+
* `schemaExists` separates an empty database from a push-provisioned one.
|
|
111
|
+
*/
|
|
112
|
+
export declare function migrateState(r: MigrateCheckResult, schemaExists: boolean): MigrateState;
|
|
113
|
+
/** The `--json` report: `state` first, then the detail behind it. */
|
|
114
|
+
export declare function formatMigrateCheckJson(r: MigrateCheckResult, schemaExists: boolean): string;
|
|
43
115
|
export {};
|
|
44
116
|
//# sourceMappingURL=migrate-check.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-check.d.ts","sourceRoot":"","sources":["../../src/commands/migrate-check.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"migrate-check.d.ts","sourceRoot":"","sources":["../../src/commands/migrate-check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAQH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,wDAAwD;IACxD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,yCAAyC;IACzC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,iFAAiF;IACjF,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,qEAAqE;IACrE,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB,mDAAmD;IACnD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,qEAAqE;IACrE,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,wEAAwE;AACxE,wBAAgB,eAAe,CAC7B,aAAa,EAAE,MAAM,GACpB,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAO7D;AAED,oDAAoD;AACpD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,KAAK,OAAO,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CAAC;AAEjE,wBAAsB,YAAY,CAChC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,kBAAkB,CAAC,CAmE7B;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,CAAC,EAA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