@cogenta/cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/bin.d.ts +3 -0
  2. package/dist/bin.d.ts.map +1 -0
  3. package/dist/bin.js +31 -0
  4. package/dist/bin.js.map +1 -0
  5. package/dist/commands/doctor.d.ts +45 -0
  6. package/dist/commands/doctor.d.ts.map +1 -0
  7. package/dist/commands/doctor.js +147 -0
  8. package/dist/commands/doctor.js.map +1 -0
  9. package/dist/commands/generate.d.ts +19 -0
  10. package/dist/commands/generate.d.ts.map +1 -0
  11. package/dist/commands/generate.js +60 -0
  12. package/dist/commands/generate.js.map +1 -0
  13. package/dist/commands/import.d.ts +22 -0
  14. package/dist/commands/import.d.ts.map +1 -0
  15. package/dist/commands/import.js +77 -0
  16. package/dist/commands/import.js.map +1 -0
  17. package/dist/commands/migrate.d.ts +38 -0
  18. package/dist/commands/migrate.d.ts.map +1 -0
  19. package/dist/commands/migrate.js +272 -0
  20. package/dist/commands/migrate.js.map +1 -0
  21. package/dist/commands/serve.d.ts +81 -0
  22. package/dist/commands/serve.d.ts.map +1 -0
  23. package/dist/commands/serve.js +515 -0
  24. package/dist/commands/serve.js.map +1 -0
  25. package/dist/commands/skin.d.ts +24 -0
  26. package/dist/commands/skin.d.ts.map +1 -0
  27. package/dist/commands/skin.js +199 -0
  28. package/dist/commands/skin.js.map +1 -0
  29. package/dist/commands/users.d.ts +22 -0
  30. package/dist/commands/users.d.ts.map +1 -0
  31. package/dist/commands/users.js +107 -0
  32. package/dist/commands/users.js.map +1 -0
  33. package/dist/index.d.ts +41 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +244 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/output.d.ts +17 -0
  38. package/dist/output.d.ts.map +1 -0
  39. package/dist/output.js +39 -0
  40. package/dist/output.js.map +1 -0
  41. package/package.json +53 -0
package/dist/bin.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=bin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
package/dist/bin.js ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+ import process from 'node:process';
3
+ import { run } from './index.js';
4
+ /**
5
+ * Node prints "ExperimentalWarning: SQLite is an experimental feature" on every
6
+ * command that opens a database, which is every useful command. It is Node's
7
+ * notice about its own module, not something a Cogenta user can act on, and it
8
+ * would train people to ignore warnings — including the ones that matter.
9
+ *
10
+ * Only that one warning is dropped. Everything else is re-emitted exactly as
11
+ * Node would have printed it.
12
+ */
13
+ process.removeAllListeners('warning');
14
+ process.on('warning', (warning) => {
15
+ const isSqliteNotice = warning.name === 'ExperimentalWarning' && warning.message.includes('SQLite');
16
+ if (!isSqliteNotice)
17
+ process.stderr.write(`${warning.stack ?? warning.message}\n`);
18
+ });
19
+ // Only `serve` reads this; every other command finishes on its own and
20
+ // nothing ever calls `abort()`. Ctrl-C or a process manager's SIGTERM should
21
+ // close the listening socket and the database cleanly rather than dropping
22
+ // whatever request was in flight.
23
+ const shutdown = new AbortController();
24
+ process.once('SIGINT', () => shutdown.abort());
25
+ process.once('SIGTERM', () => shutdown.abort());
26
+ process.exitCode = await run({
27
+ argv: process.argv.slice(2),
28
+ isTty: process.stdout.isTTY === true,
29
+ signal: shutdown.signal,
30
+ });
31
+ //# sourceMappingURL=bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAA;AAEhC;;;;;;;;GAQG;AACH,OAAO,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAA;AACrC,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE;IAChC,MAAM,cAAc,GAClB,OAAO,CAAC,IAAI,KAAK,qBAAqB,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAE9E,IAAI,CAAC,cAAc;QAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,OAAO,IAAI,CAAC,CAAA;AACpF,CAAC,CAAC,CAAA;AAEF,uEAAuE;AACvE,6EAA6E;AAC7E,2EAA2E;AAC3E,kCAAkC;AAClC,MAAM,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAA;AACtC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;AAC9C,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;AAE/C,OAAO,CAAC,QAAQ,GAAG,MAAM,GAAG,CAAC;IAC3B,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3B,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI;IACpC,MAAM,EAAE,QAAQ,CAAC,MAAM;CACxB,CAAC,CAAA"}
@@ -0,0 +1,45 @@
1
+ import { type DriverTier, type Logger } from '@cogenta/core';
2
+ import type { Output } from '../output.js';
3
+ export interface DoctorCheck {
4
+ readonly need: string;
5
+ readonly status: 'ok' | 'degraded' | 'down';
6
+ readonly driver: string;
7
+ readonly tier: DriverTier;
8
+ readonly reason: string;
9
+ readonly message: string | undefined;
10
+ readonly skipped: readonly {
11
+ driver: string;
12
+ tier: DriverTier;
13
+ reason: string;
14
+ }[];
15
+ }
16
+ export interface DoctorReport {
17
+ readonly node: string;
18
+ readonly platform: string;
19
+ readonly arch: string;
20
+ readonly configPath: string | null;
21
+ readonly site: {
22
+ name: string;
23
+ url: string;
24
+ locales: readonly string[];
25
+ } | undefined;
26
+ readonly checks: readonly DoctorCheck[];
27
+ readonly notes: readonly string[];
28
+ readonly problems: readonly string[];
29
+ }
30
+ export interface DoctorOptions {
31
+ readonly cwd?: string;
32
+ readonly env?: Record<string, string | undefined>;
33
+ readonly logger?: Logger;
34
+ }
35
+ /**
36
+ * Diagnoses an install: which driver is running for each need, why that one, and
37
+ * what it costs.
38
+ *
39
+ * "Why" is not decoration. The registry can silently fall back from Redis to the
40
+ * filesystem, and an operator who cannot see that has a site that is slower than
41
+ * they think for a reason nothing told them.
42
+ */
43
+ export declare function runDoctor(options?: DoctorOptions): Promise<DoctorReport>;
44
+ export declare function formatDoctorReport(report: DoctorReport, out: Output): void;
45
+ //# sourceMappingURL=doctor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AACA,OAAO,EAOL,KAAK,UAAU,EAEf,KAAK,MAAM,EAEZ,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,IAAI,GAAG,UAAU,GAAG,MAAM,CAAA;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IACpC,QAAQ,CAAC,OAAO,EAAE,SAAS;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,UAAU,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAClF;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,QAAQ,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,GAAG,SAAS,CAAA;IACpF,QAAQ,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAA;IACvC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;IACjC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;CACrC;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;IACjD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CACzB;AASD;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,CA6GlF;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAsC1E"}
@@ -0,0 +1,147 @@
1
+ import process from 'node:process';
2
+ import { createCacheRegistry, createDatabaseRegistry, createLogger, createStorageRegistry, isCogentaError, loadConfig, } from '@cogenta/core';
3
+ function describe(error) {
4
+ if (isCogentaError(error)) {
5
+ return error.hint === undefined ? error.message : `${error.message}\n${error.hint}`;
6
+ }
7
+ return error instanceof Error ? error.message : String(error);
8
+ }
9
+ /**
10
+ * Diagnoses an install: which driver is running for each need, why that one, and
11
+ * what it costs.
12
+ *
13
+ * "Why" is not decoration. The registry can silently fall back from Redis to the
14
+ * filesystem, and an operator who cannot see that has a site that is slower than
15
+ * they think for a reason nothing told them.
16
+ */
17
+ export async function runDoctor(options = {}) {
18
+ const env = options.env ?? process.env;
19
+ const checks = [];
20
+ const notes = [];
21
+ const problems = [];
22
+ const base = {
23
+ node: process.versions.node,
24
+ platform: process.platform,
25
+ arch: process.arch,
26
+ };
27
+ let config;
28
+ let configPath = null;
29
+ try {
30
+ const loaded = await loadConfig({
31
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
32
+ env,
33
+ });
34
+ config = loaded.config;
35
+ configPath = loaded.path;
36
+ }
37
+ catch (error) {
38
+ return {
39
+ ...base,
40
+ configPath: null,
41
+ site: undefined,
42
+ checks: [],
43
+ notes: [],
44
+ problems: [describe(error)],
45
+ };
46
+ }
47
+ if (configPath === null) {
48
+ notes.push('No cogenta.config file found. The configuration came from the environment.');
49
+ }
50
+ // Silent unless the caller asks otherwise. A human report on stdout must not
51
+ // be interleaved with NDJSON: piping doctor into a file should give something
52
+ // a person can read, and `--verbose` sends the structured lines to stderr.
53
+ const registryOptions = { logger: options.logger ?? createLogger({ level: 'silent' }) };
54
+ /** Selects a driver and turns the outcome — success or failure — into a check. */
55
+ const check = async (need, select) => {
56
+ let selection;
57
+ try {
58
+ selection = await select();
59
+ const health = await selection.health();
60
+ checks.push({
61
+ need,
62
+ status: health.status,
63
+ driver: selection.driver,
64
+ tier: selection.tier,
65
+ reason: selection.requested ? 'named in the configuration' : selection.reason,
66
+ message: health.message,
67
+ skipped: selection.skipped,
68
+ });
69
+ }
70
+ catch (error) {
71
+ problems.push(`${need}: ${describe(error)}`);
72
+ }
73
+ finally {
74
+ await selection?.dispose();
75
+ }
76
+ };
77
+ await check('database', () => createDatabaseRegistry(registryOptions).select(config.database));
78
+ await check('cache', () => createCacheRegistry(registryOptions).select(config.cache));
79
+ await check('storage', () => createStorageRegistry(registryOptions).select(config.storage));
80
+ // Rule R2, stated out loud rather than left to be discovered: no provider is a
81
+ // supported configuration, not a broken one.
82
+ notes.push(config.llm === undefined
83
+ ? 'No LLM provider configured. Everything works except the agents.'
84
+ : `LLM provider: ${config.llm.provider} (${config.llm.model}).${config.llm.apiKey === undefined
85
+ ? ' No API key in the environment, so the agents will not run.'
86
+ : ''}`);
87
+ if (config.database.driver === 'sqlite') {
88
+ notes.push('SQLite: one machine, no vector index. Fine for a single site, not for a fleet.');
89
+ }
90
+ if (config.storage.driver !== 's3' && env['COGENTA_STORAGE_SIGNING_KEY'] === undefined) {
91
+ notes.push('COGENTA_STORAGE_SIGNING_KEY is not set, so signed media URLs stop working after a restart.');
92
+ }
93
+ const [major, minor] = process.versions.node.split('.').map(Number);
94
+ if (major !== undefined && minor !== undefined && (major < 22 || (major === 22 && minor < 13))) {
95
+ problems.push(`Node ${process.versions.node} has no built-in SQLite. Upgrade to 22.13 or later, or use Postgres or MySQL.`);
96
+ }
97
+ return {
98
+ ...base,
99
+ configPath,
100
+ site: { name: config.site.name, url: config.site.url, locales: config.site.locales },
101
+ checks,
102
+ notes,
103
+ problems,
104
+ };
105
+ }
106
+ export function formatDoctorReport(report, out) {
107
+ out.heading('Environment');
108
+ out.ok(`Node ${report.node} on ${report.platform} ${report.arch}`);
109
+ out.ok(report.configPath ?? 'configuration from the environment');
110
+ if (report.site !== undefined) {
111
+ out.heading('Site');
112
+ out.ok(`${report.site.name} — ${report.site.url}`);
113
+ out.detail(`locales: ${report.site.locales.join(', ')}`);
114
+ }
115
+ if (report.checks.length > 0) {
116
+ out.heading('Drivers');
117
+ for (const item of report.checks) {
118
+ const label = `${item.need}: ${item.driver} (${item.tier}) — ${item.reason}`;
119
+ if (item.status === 'ok')
120
+ out.ok(label);
121
+ else if (item.status === 'degraded')
122
+ out.warn(label);
123
+ else
124
+ out.bad(label);
125
+ if (item.message !== undefined)
126
+ out.detail(item.message);
127
+ for (const skipped of item.skipped)
128
+ out.detail(`${skipped.driver}: ${skipped.reason}`);
129
+ }
130
+ }
131
+ if (report.notes.length > 0) {
132
+ out.heading('Notes');
133
+ for (const note of report.notes)
134
+ out.warn(note);
135
+ }
136
+ if (report.problems.length > 0) {
137
+ out.heading('Problems');
138
+ for (const problem of report.problems)
139
+ out.bad(problem);
140
+ }
141
+ out.line();
142
+ if (report.problems.length === 0)
143
+ out.line('Nothing is broken.');
144
+ else
145
+ out.line(`${report.problems.length} problem(s) to fix.`);
146
+ }
147
+ //# sourceMappingURL=doctor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EAEL,mBAAmB,EACnB,sBAAsB,EACtB,YAAY,EACZ,qBAAqB,EAGrB,cAAc,EAEd,UAAU,GACX,MAAM,eAAe,CAAA;AA8BtB,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,IAAI,EAAE,CAAA;IACrF,CAAC;IACD,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC/D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAO,GAAkB,EAAE;IACzD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAA;IACtC,MAAM,MAAM,GAAkB,EAAE,CAAA;IAChC,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,MAAM,QAAQ,GAAa,EAAE,CAAA;IAE7B,MAAM,IAAI,GAAG;QACX,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI;QAC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E,CAAC,CAAA;QACxF,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5B,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QACpB,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK;YAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACjD,CAAC;IAED,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;QACvB,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ;YAAE,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IACzD,CAAC;IAED,GAAG,CAAC,IAAI,EAAE,CAAA;IACV,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,GAAG,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA;;QAC3D,GAAG,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,qBAAqB,CAAC,CAAA;AAC/D,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { type Logger } from '@cogenta/core';
2
+ import type { Output, Writer } from '../output.js';
3
+ export type GenerateSubcommand = 'types';
4
+ export interface GenerateOptions {
5
+ readonly subcommand: string | undefined;
6
+ readonly cwd?: string;
7
+ readonly env?: Record<string, string | undefined>;
8
+ readonly logger?: Logger;
9
+ readonly out: Output;
10
+ readonly stderr: Writer;
11
+ /** Overrides the default `.cogenta/types/schema.d.ts` output path. */
12
+ readonly outFile?: string;
13
+ }
14
+ /**
15
+ * `cogenta generate` — only `types` is real (see USAGE). 0 written. 1 the
16
+ * schema failed to load. 2 the command line was wrong.
17
+ */
18
+ export declare function runGenerate(options: GenerateOptions): Promise<number>;
19
+ //# sourceMappingURL=generate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAkB,KAAK,MAAM,EAAc,MAAM,eAAe,CAAA;AAEvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAGlD,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAA;AAExC,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IACvC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;IACjD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,sEAAsE;IACtE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAC1B;AAgBD;;;GAGG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAqC3E"}
@@ -0,0 +1,60 @@
1
+ import { mkdir, writeFile } from 'node:fs/promises';
2
+ import { dirname, join, resolve as resolvePath } from 'node:path';
3
+ import process from 'node:process';
4
+ import { isCogentaError, loadConfig } from '@cogenta/core';
5
+ import { renderTypeDeclarations } from '@cogenta/schema';
6
+ import { loadCollections } from './serve.js';
7
+ const DEFAULT_OUTPUT = join('.cogenta', 'types', 'schema.d.ts');
8
+ const USAGE = `Usage
9
+ cogenta generate types [--out <file>]
10
+
11
+ Writes TypeScript declarations for every collection in cogenta.schema.(m)js —
12
+ the same generator "cogenta doctor"'s type checks rely on being accurate.
13
+ Defaults to ${DEFAULT_OUTPUT}, relative to the project root.
14
+
15
+ "generate schema" and "generate migrations" do not exist yet: nothing in this
16
+ codebase can diff a schema into a migration file today — migrations are
17
+ still hand-written (see the write-migration skill). Only "types" is real.
18
+ `;
19
+ /**
20
+ * `cogenta generate` — only `types` is real (see USAGE). 0 written. 1 the
21
+ * schema failed to load. 2 the command line was wrong.
22
+ */
23
+ export async function runGenerate(options) {
24
+ const { out, stderr } = options;
25
+ const env = options.env ?? process.env;
26
+ if (options.subcommand === undefined) {
27
+ stderr(`cogenta generate needs a subcommand.\n\n${USAGE}`);
28
+ return 2;
29
+ }
30
+ if (options.subcommand !== 'types') {
31
+ stderr(`Unknown subcommand "${options.subcommand}". Only "types" exists today.\n\n${USAGE}`);
32
+ return 2;
33
+ }
34
+ const loaded = await loadConfig({
35
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
36
+ env,
37
+ });
38
+ const projectRoot = loaded.path === null ? resolvePath(options.cwd ?? process.cwd()) : dirname(loaded.path);
39
+ try {
40
+ const collections = await loadCollections(projectRoot);
41
+ const declarations = renderTypeDeclarations(collections);
42
+ const outFile = options.outFile ?? join(projectRoot, DEFAULT_OUTPUT);
43
+ await mkdir(dirname(outFile), { recursive: true });
44
+ await writeFile(outFile, declarations, 'utf8');
45
+ out.ok(`Wrote types for ${collections.length} collection(s) to ${outFile}`);
46
+ return 0;
47
+ }
48
+ catch (error) {
49
+ if (isCogentaError(error)) {
50
+ stderr(`${error.code}: ${error.message}\n`);
51
+ if (error.hint !== undefined)
52
+ stderr(`${error.hint}\n`);
53
+ }
54
+ else {
55
+ stderr(`${error instanceof Error ? error.stack : String(error)}\n`);
56
+ }
57
+ return 1;
58
+ }
59
+ }
60
+ //# sourceMappingURL=generate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAA;AACjE,OAAO,OA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;IAEzF,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,MAAM,eAAe,CAAC,WAAW,CAAC,CAAA;QACtD,MAAM,YAAY,GAAG,sBAAsB,CAAC,WAAW,CAAC,CAAA;QACxD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAA;QACpE,MAAM,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QAClD,MAAM,SAAS,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,CAAC,CAAA;QAC9C,GAAG,CAAC,EAAE,CAAC,mBAAmB,WAAW,CAAC,MAAM,qBAAqB,OAAO,EAAE,CAAC,CAAA;QAC3E,OAAO,CAAC,CAAA;IACV,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,IAAI,CAAC,CAAA;YAC3C,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;gBAAE,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,CAAC,CAAA;QACzD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACrE,CAAC;QACD,OAAO,CAAC,CAAA;IACV,CAAC;AACH,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { type Logger } from '@cogenta/core';
2
+ import type { Output, Writer } from '../output.js';
3
+ export type ImportSubcommand = 'wordpress';
4
+ export interface ImportOptions {
5
+ readonly subcommand: string | undefined;
6
+ readonly file: string | undefined;
7
+ readonly cwd?: string;
8
+ readonly env?: Record<string, string | undefined>;
9
+ readonly logger?: Logger;
10
+ readonly out: Output;
11
+ readonly stderr: Writer;
12
+ }
13
+ /**
14
+ * Runs one `import` subcommand and returns its exit code.
15
+ *
16
+ * 0 the import ran, even with items reported as unconverted (that report *is*
17
+ * success — see `formatConversionReport`'s own framing). 1 the file could not
18
+ * be read or parsed at all, or the database refused. 2 the command line was
19
+ * wrong.
20
+ */
21
+ export declare function runImport(options: ImportOptions): Promise<number>;
22
+ //# sourceMappingURL=import.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../src/commands/import.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,MAAM,EAGZ,MAAM,eAAe,CAAA;AAEtB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAElD,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAA;AAE1C,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;IACjC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;IACjD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AA+BD;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CA6CvE"}
@@ -0,0 +1,77 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import process from 'node:process';
3
+ import { createDatabaseRegistry, createLogger, createStorageRegistry, isCogentaError, loadConfig, } from '@cogenta/core';
4
+ import { formatConversionReport, importWordPress } from '@cogenta/import';
5
+ const USAGE = `Usage
6
+ cogenta import wordpress <file.xml>
7
+
8
+ Imports a WordPress "Export All Content" WXR file: posts, pages, categories,
9
+ tags, media, authors, comments and redirects. Prints a report of what could
10
+ not be converted — a partial import with a report is the expected outcome for
11
+ a real-world export, not a failure.
12
+ `;
13
+ async function withSite(options, logger, use) {
14
+ const env = options.env ?? process.env;
15
+ const loaded = await loadConfig({
16
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
17
+ env,
18
+ });
19
+ const dbSelection = await createDatabaseRegistry({ logger }).select(loaded.config.database);
20
+ const storageSelection = await createStorageRegistry({ logger }).select(loaded.config.storage);
21
+ try {
22
+ return await use(dbSelection.instance, storageSelection.instance);
23
+ }
24
+ finally {
25
+ await dbSelection.dispose();
26
+ }
27
+ }
28
+ /**
29
+ * Runs one `import` subcommand and returns its exit code.
30
+ *
31
+ * 0 the import ran, even with items reported as unconverted (that report *is*
32
+ * success — see `formatConversionReport`'s own framing). 1 the file could not
33
+ * be read or parsed at all, or the database refused. 2 the command line was
34
+ * wrong.
35
+ */
36
+ export async function runImport(options) {
37
+ const { out, stderr } = options;
38
+ if (options.subcommand === undefined) {
39
+ stderr(`cogenta import needs a subcommand.\n\n${USAGE}`);
40
+ return 2;
41
+ }
42
+ if (options.subcommand !== 'wordpress') {
43
+ stderr(`Unknown subcommand "${options.subcommand}".\n\n${USAGE}`);
44
+ return 2;
45
+ }
46
+ if (options.file === undefined || options.file.trim().length === 0) {
47
+ stderr(`A file path is required.\n\n${USAGE}`);
48
+ return 2;
49
+ }
50
+ const logger = options.logger ?? createLogger({ level: 'silent' });
51
+ let xml;
52
+ try {
53
+ xml = await readFile(options.file, 'utf8');
54
+ }
55
+ catch (error) {
56
+ stderr(`Could not read "${options.file}": ${error instanceof Error ? error.message : String(error)}\n`);
57
+ return 1;
58
+ }
59
+ try {
60
+ const report = await withSite(options, logger, (db, storage) => importWordPress(xml, { db, storage }));
61
+ out.heading('WordPress import');
62
+ out.line(formatConversionReport(report));
63
+ return 0;
64
+ }
65
+ catch (error) {
66
+ if (isCogentaError(error)) {
67
+ stderr(`${error.code}: ${error.message}\n`);
68
+ if (error.hint !== undefined)
69
+ stderr(`${error.hint}\n`);
70
+ }
71
+ else {
72
+ stderr(`${error instanceof Error ? error.stack : String(error)}\n`);
73
+ }
74
+ return 1;
75
+ }
76
+ }
77
+ //# sourceMappingURL=import.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import.js","sourceRoot":"","sources":["../../src/commands/import.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EACL,sBAAsB,EACtB,YAAY,EACZ,qBAAqB,EAErB,cAAc,EAEd,UAAU,GAEX,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAezE,MAAM,KAAK,GAAG;;;;;;;CAOb,CAAA;AAED,KAAK,UAAU,QAAQ,CACrB,OAAsB,EACtB,MAAc,EACd,GAA+D;IAE/D,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAA;IACtC,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC;QAC9B,GAAG,CAAC,OAAO,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;QAC1D,GAAG;KACJ,CAAC,CAAA;IAEF,MAAM,WAAW,GAAG,MAAM,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC3F,MAAM,gBAAgB,GAAG,MAAM,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAC9F,IAAI,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I,CAChG,CAAA;QACD,OAAO,CAAC,CAAA;IACV,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,CAC7D,eAAe,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CACtC,CAAA;QAED,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAA;QAC/B,GAAG,CAAC,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAA;QACxC,OAAO,CAAC,CAAA;IACV,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,IAAI,CAAC,CAAA;YAC3C,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;gBAAE,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,CAAC,CAAA;QACzD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACrE,CAAC;QACD,OAAO,CAAC,CAAA;IACV,CAAC;AACH,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { type Logger, type Migration } from '@cogenta/core';
2
+ import type { Output, Writer } from '../output.js';
3
+ /** The directory a project keeps its migrations in, relative to the config file. */
4
+ export declare const MIGRATIONS_DIRECTORY = "migrations";
5
+ export type MigrateSubcommand = 'status' | 'up' | 'down';
6
+ export interface MigrateOptions {
7
+ readonly subcommand: string | undefined;
8
+ readonly cwd?: string;
9
+ readonly env?: Record<string, string | undefined>;
10
+ readonly logger?: Logger;
11
+ /** Where the human-readable report goes. */
12
+ readonly out: Output;
13
+ /** Where refusals and failures go, so a piped report stays clean. */
14
+ readonly stderr: Writer;
15
+ readonly to?: string;
16
+ readonly steps?: number;
17
+ readonly confirmDestructive?: boolean;
18
+ readonly backupVerified?: boolean;
19
+ /** Overrides the `migrations/` directory next to the configuration file. */
20
+ readonly directory?: string;
21
+ }
22
+ /**
23
+ * Loads every migration from a directory, in file-name order.
24
+ *
25
+ * A missing directory is not an error. L0 ships no business schema at all, so a
26
+ * fresh project legitimately has nothing to migrate, and failing there would
27
+ * make `migrate status` unusable exactly when an operator wants to check.
28
+ */
29
+ export declare function loadMigrations(directory: string): Promise<Migration[]>;
30
+ /**
31
+ * Runs one `migrate` subcommand and returns its exit code.
32
+ *
33
+ * 0 succeeded, 1 the database or a migration said no, 2 the command line was
34
+ * wrong. Nothing calls `process.exit` and nothing writes to a stream directly,
35
+ * so a test drives this exactly as a shell does.
36
+ */
37
+ export declare function runMigrate(options: MigrateOptions): Promise<number>;
38
+ //# sourceMappingURL=migrate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"AAKA,OAAO,EAOL,KAAK,MAAM,EAEX,KAAK,SAAS,EAIf,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAElD,oFAAoF;AACpF,eAAO,MAAM,oBAAoB,eAAe,CAAA;AAShD,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,IAAI,GAAG,MAAM,CAAA;AAExD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IACvC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;IACjD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IAC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