@cogitator-ai/cli 0.5.20 → 0.6.1
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/README.md +98 -40
- package/dist/commands/add.d.ts +11 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/add.js +79 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/assistant.d.ts.map +1 -1
- package/dist/commands/assistant.js +14 -12
- package/dist/commands/assistant.js.map +1 -1
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +12 -10
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/daemon.d.ts.map +1 -1
- package/dist/commands/daemon.js +17 -13
- package/dist/commands/daemon.js.map +1 -1
- package/dist/commands/deploy.d.ts +35 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +134 -76
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.d.ts +14 -0
- package/dist/commands/dev.d.ts.map +1 -0
- package/dist/commands/dev.js +84 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/commands/doctor.d.ts +5 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +52 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/eval.d.ts +12 -0
- package/dist/commands/eval.d.ts.map +1 -0
- package/dist/commands/eval.js +90 -0
- package/dist/commands/eval.js.map +1 -0
- package/dist/commands/init.d.ts +9 -51
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +87 -400
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/logs.d.ts.map +1 -1
- package/dist/commands/logs.js +9 -6
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/mcp.d.ts +18 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +155 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/models.d.ts.map +1 -1
- package/dist/commands/models.js +43 -15
- package/dist/commands/models.js.map +1 -1
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +16 -11
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/skill.d.ts.map +1 -1
- package/dist/commands/skill.js +23 -23
- package/dist/commands/skill.js.map +1 -1
- package/dist/commands/status.d.ts +21 -0
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +64 -39
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +26 -24
- package/dist/commands/up.js.map +1 -1
- package/dist/commands/wizard.d.ts.map +1 -1
- package/dist/commands/wizard.js +5 -0
- package/dist/commands/wizard.js.map +1 -1
- package/dist/index.js +9 -42
- package/dist/index.js.map +1 -1
- package/dist/program.d.ts +4 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +61 -0
- package/dist/program.js.map +1 -0
- package/dist/utils/add.d.ts +81 -0
- package/dist/utils/add.d.ts.map +1 -0
- package/dist/utils/add.js +151 -0
- package/dist/utils/add.js.map +1 -0
- package/dist/utils/cli.d.ts +49 -0
- package/dist/utils/cli.d.ts.map +1 -0
- package/dist/utils/cli.js +106 -0
- package/dist/utils/cli.js.map +1 -0
- package/dist/utils/docs.d.ts +39 -0
- package/dist/utils/docs.d.ts.map +1 -0
- package/dist/utils/docs.js +198 -0
- package/dist/utils/docs.js.map +1 -0
- package/dist/utils/doctor.d.ts +41 -0
- package/dist/utils/doctor.d.ts.map +1 -0
- package/dist/utils/doctor.js +378 -0
- package/dist/utils/doctor.js.map +1 -0
- package/dist/utils/evals.d.ts +50 -0
- package/dist/utils/evals.d.ts.map +1 -0
- package/dist/utils/evals.js +78 -0
- package/dist/utils/evals.js.map +1 -0
- package/dist/utils/provider-models.d.ts +8 -2
- package/dist/utils/provider-models.d.ts.map +1 -1
- package/dist/utils/provider-models.js +32 -52
- package/dist/utils/provider-models.js.map +1 -1
- package/dist/utils/registry-worker.d.ts +2 -0
- package/dist/utils/registry-worker.d.ts.map +1 -0
- package/dist/utils/registry-worker.js +35 -0
- package/dist/utils/registry-worker.js.map +1 -0
- package/dist/utils/registry.d.ts +19 -0
- package/dist/utils/registry.d.ts.map +1 -0
- package/dist/utils/registry.js +58 -0
- package/dist/utils/registry.js.map +1 -0
- package/package.json +12 -8
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { examplesHelp } from '../utils/cli.js';
|
|
4
|
+
import { loadProjectEnv, runDoctor } from '../utils/doctor.js';
|
|
5
|
+
const ICONS = {
|
|
6
|
+
pass: chalk.green('✓'),
|
|
7
|
+
warn: chalk.yellow('!'),
|
|
8
|
+
fail: chalk.red('✗'),
|
|
9
|
+
};
|
|
10
|
+
export function formatChecks(checks) {
|
|
11
|
+
const width = Math.max(...checks.map((check) => check.label.length));
|
|
12
|
+
const lines = checks.map((check) => {
|
|
13
|
+
const line = ` ${ICONS[check.status]} ${check.label.padEnd(width)} ${check.detail}`;
|
|
14
|
+
return check.fix ? `${line}\n ${' '.repeat(width + 4)}${chalk.dim(`→ ${check.fix}`)}` : line;
|
|
15
|
+
});
|
|
16
|
+
const failed = checks.filter((check) => check.status === 'fail').length;
|
|
17
|
+
const warned = checks.filter((check) => check.status === 'warn').length;
|
|
18
|
+
const summary = failed > 0
|
|
19
|
+
? chalk.red(`${failed} problem${failed === 1 ? '' : 's'} to fix`)
|
|
20
|
+
: warned > 0
|
|
21
|
+
? chalk.yellow(`Ready, with ${warned} warning${warned === 1 ? '' : 's'}`)
|
|
22
|
+
: chalk.green('Everything is ready');
|
|
23
|
+
return ['', ...lines, '', ` ${summary}`, ''].join('\n');
|
|
24
|
+
}
|
|
25
|
+
export const doctorCommand = new Command('doctor')
|
|
26
|
+
.description('Check that a project can run: Node, packages, config, keys, models and services')
|
|
27
|
+
.option('--json', 'print the checks as JSON')
|
|
28
|
+
.option('--offline', 'skip checks that call the model provider or connect to services')
|
|
29
|
+
.addHelpText('after', examplesHelp([
|
|
30
|
+
['cogitator doctor', 'check what the project needs to run'],
|
|
31
|
+
['cogitator doctor --offline', 'skip the provider and service probes'],
|
|
32
|
+
['cogitator doctor --json', 'the checks for CI'],
|
|
33
|
+
]))
|
|
34
|
+
.action(async (options) => {
|
|
35
|
+
const projectDir = process.cwd();
|
|
36
|
+
loadProjectEnv(projectDir);
|
|
37
|
+
const checks = await runDoctor({
|
|
38
|
+
projectDir,
|
|
39
|
+
env: process.env,
|
|
40
|
+
nodeVersion: process.version,
|
|
41
|
+
probe: !options.offline,
|
|
42
|
+
});
|
|
43
|
+
const ok = checks.every((check) => check.status !== 'fail');
|
|
44
|
+
if (options.json) {
|
|
45
|
+
console.log(JSON.stringify({ ok, checks }, null, 2));
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
console.log(formatChecks(checks));
|
|
49
|
+
}
|
|
50
|
+
process.exitCode = ok ? 0 : 1;
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=doctor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,SAAS,EAAoB,MAAM,oBAAoB,CAAC;AAEjF,MAAM,KAAK,GAA0C;IACnD,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;IACtB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC;IACvB,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;CACrB,CAAC;AAEF,MAAM,UAAU,YAAY,CAAC,MAA8B;IACzD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,C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,OAAO,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
interface EvalFlags {
|
|
3
|
+
json?: boolean;
|
|
4
|
+
report?: string;
|
|
5
|
+
maxCases?: string;
|
|
6
|
+
skipWithoutKey?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/** Runs the eval suites and resolves with the exit code. */
|
|
9
|
+
export declare function runEvals(files: readonly string[], flags: EvalFlags): Promise<number>;
|
|
10
|
+
export declare const evalCommand: Command;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=eval.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eval.d.ts","sourceRoot":"","sources":["../../src/commands/eval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAepC,UAAU,SAAS;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAUD,4DAA4D;AAC5D,wBAAsB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAwD1F;AAED,eAAO,MAAM,WAAW,SA4BpB,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { join, relative } from 'node:path';
|
|
4
|
+
import { loadConfig } from '@cogitator-ai/config';
|
|
5
|
+
import { CommandError, examplesHelp, reportFailure, UsageError } from '../utils/cli.js';
|
|
6
|
+
import { loadProjectEnv } from '../utils/doctor.js';
|
|
7
|
+
import { isEvalSuite, missingCredential, outcomeOf, resolveEvalFiles, } from '../utils/evals.js';
|
|
8
|
+
import { importUserModule } from '../utils/module-loader.js';
|
|
9
|
+
function positiveInteger(value) {
|
|
10
|
+
if (value === undefined)
|
|
11
|
+
return undefined;
|
|
12
|
+
const parsed = Number(value);
|
|
13
|
+
if (!Number.isInteger(parsed) || parsed < 1)
|
|
14
|
+
throw new UsageError('--max-cases takes a positive integer');
|
|
15
|
+
return parsed;
|
|
16
|
+
}
|
|
17
|
+
/** Runs the eval suites and resolves with the exit code. */
|
|
18
|
+
export async function runEvals(files, flags) {
|
|
19
|
+
const projectDir = process.cwd();
|
|
20
|
+
loadProjectEnv(projectDir);
|
|
21
|
+
const print = (line) => {
|
|
22
|
+
if (!flags.json)
|
|
23
|
+
console.log(line);
|
|
24
|
+
};
|
|
25
|
+
if (flags.skipWithoutKey) {
|
|
26
|
+
const missing = missingCredential(loadConfig());
|
|
27
|
+
if (missing) {
|
|
28
|
+
if (flags.json)
|
|
29
|
+
console.log(JSON.stringify({ ok: true, skipped: true, reason: `${missing} is not set` }));
|
|
30
|
+
else
|
|
31
|
+
print(chalk.yellow(`Skipping evals: ${missing} is not set`));
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const paths = resolveEvalFiles(projectDir, files);
|
|
36
|
+
if (paths.length === 0) {
|
|
37
|
+
throw new CommandError('No eval files found: add evals/<name>.eval.ts exporting an EvalSuite as default');
|
|
38
|
+
}
|
|
39
|
+
const outcomes = [];
|
|
40
|
+
for (const path of paths) {
|
|
41
|
+
const module = await importUserModule(path, projectDir);
|
|
42
|
+
const suite = module.default;
|
|
43
|
+
if (!isEvalSuite(suite)) {
|
|
44
|
+
throw new CommandError(`${path} must export an EvalSuite as its default export`);
|
|
45
|
+
}
|
|
46
|
+
print(chalk.bold(`\n${relative(projectDir, path)}`));
|
|
47
|
+
const result = await suite.run({ maxCases: positiveInteger(flags.maxCases) });
|
|
48
|
+
if (!flags.json)
|
|
49
|
+
result.report('console');
|
|
50
|
+
if (flags.report) {
|
|
51
|
+
const target = paths.length === 1 ? flags.report : join(flags.report, `${outcomes.length}.json`);
|
|
52
|
+
result.report('json', { path: target });
|
|
53
|
+
}
|
|
54
|
+
outcomes.push(outcomeOf(projectDir, path, result));
|
|
55
|
+
}
|
|
56
|
+
const ok = outcomes.every((outcome) => outcome.passed);
|
|
57
|
+
if (flags.json) {
|
|
58
|
+
console.log(JSON.stringify({ ok, skipped: false, suites: outcomes }, null, 2));
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
const failed = outcomes.filter((outcome) => !outcome.passed);
|
|
62
|
+
print(failed.length === 0
|
|
63
|
+
? chalk.green(`\n${outcomes.length} eval suite${outcomes.length === 1 ? '' : 's'} passed`)
|
|
64
|
+
: chalk.red(`\n${failed.length} of ${outcomes.length} eval suites failed: ${failed.map((f) => f.file).join(', ')}`));
|
|
65
|
+
}
|
|
66
|
+
return ok ? 0 : 1;
|
|
67
|
+
}
|
|
68
|
+
export const evalCommand = new Command('eval')
|
|
69
|
+
.description('Run the eval suites in evals/ (or the files given) and fail when an assertion fails')
|
|
70
|
+
.argument('[files...]', 'eval files or directories, default: every *.eval.ts under evals/')
|
|
71
|
+
.option('--json', 'print the results as JSON')
|
|
72
|
+
.option('--report <path>', 'also write a JSON report to this path')
|
|
73
|
+
.option('--max-cases <n>', 'run only the first n cases of each suite')
|
|
74
|
+
.option('--skip-without-key', 'exit 0 without running when the model has no API key, for CI on forks')
|
|
75
|
+
.addHelpText('after', examplesHelp([
|
|
76
|
+
['cogitator eval', 'run every evals/*.eval.ts'],
|
|
77
|
+
['cogitator eval evals/answers.eval.ts --max-cases 5', 'a quick subset'],
|
|
78
|
+
['cogitator eval --json --report eval-report.json', 'results for CI'],
|
|
79
|
+
]))
|
|
80
|
+
.action(async (files, flags) => {
|
|
81
|
+
let code;
|
|
82
|
+
try {
|
|
83
|
+
code = await runEvals(files, flags);
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
code = reportFailure(error, { json: flags.json === true });
|
|
87
|
+
}
|
|
88
|
+
process.exit(code);
|
|
89
|
+
});
|
|
90
|
+
//# sourceMappingURL=eval.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eval.js","sourceRoot":"","sources":["../../src/commands/eval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,gBAAgB,GAEjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAS7D,SAAS,eAAe,CAAC,KAAyB;IAChD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC;QACzC,MAAM,IAAI,UAAU,CAAC,sCAAsC,CAAC,CAAC;IAC/D,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,4DAA4D;AAC5D,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,KAAwB,EAAE,KAAgB;IACvE,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IACjC,cAAc,CAAC,UAAU,CAAC,CAAC;IAC3B,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,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C,IAAI,CAAC,CAAC;AACrB,CAAC,CAAC,CAAC"}
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import { validateProjectName, type ProjectSpecInput } from 'create-cogitator-app';
|
|
2
3
|
import { type SetupProvider } from '../utils/provider-models.js';
|
|
3
4
|
export type InitChannel = 'telegram' | 'discord' | 'slack' | 'webchat';
|
|
4
5
|
export type InitMemory = 'memory' | 'sqlite' | 'postgres';
|
|
5
|
-
export type PackageManager = 'pnpm' | 'npm' | 'yarn' | 'bun';
|
|
6
6
|
export interface InitAnswers {
|
|
7
7
|
projectName: string;
|
|
8
8
|
provider: SetupProvider;
|
|
9
9
|
apiKey: string;
|
|
10
|
+
/** `provider/model`, as the model prompt offers it. */
|
|
10
11
|
model: string;
|
|
11
12
|
channels: InitChannel[];
|
|
12
13
|
telegramToken?: string;
|
|
@@ -17,58 +18,15 @@ export interface InitAnswers {
|
|
|
17
18
|
memory: InitMemory;
|
|
18
19
|
databaseUrl?: string;
|
|
19
20
|
}
|
|
20
|
-
export interface ScaffoldOptions {
|
|
21
|
-
dependencyVersions: Record<string, string>;
|
|
22
|
-
/** When `pnpm`, a pnpm-workspace.yaml allowing the native dependency builds is generated */
|
|
23
|
-
packageManager?: PackageManager;
|
|
24
|
-
/** `name@version` written to the `packageManager` field, e.g. `pnpm@10.26.0` */
|
|
25
|
-
packageManagerSpec?: string;
|
|
26
|
-
}
|
|
27
|
-
/** Port the WebChat channel listens on. */
|
|
28
|
-
export declare const WEBCHAT_PORT = 18789;
|
|
29
|
-
/**
|
|
30
|
-
* pnpm 10.26+ skips dependency build scripts unless they are allowed, and pnpm 11 fails the
|
|
31
|
-
* install instead. These are the native/binary packages a Cogitator project pulls in.
|
|
32
|
-
*/
|
|
33
|
-
export declare const PNPM_ALLOWED_BUILDS: readonly ["better-sqlite3", "esbuild", "sharp"];
|
|
34
21
|
export declare const DEFAULT_POSTGRES_URL = "postgresql://cogitator:cogitator@localhost:5432/cogitator";
|
|
35
|
-
export
|
|
36
|
-
export declare function resolveDependencyVersions(cliPackageJson?: string): Record<string, string>;
|
|
37
|
-
export declare function detectPackageManager(userAgent?: string | undefined): PackageManager;
|
|
38
|
-
/**
|
|
39
|
-
* The `packageManager` field for the pnpm, Yarn or Bun that runs the
|
|
40
|
-
* scaffolder, e.g. `pnpm@10.26.0`, so corepack and the deploy image install
|
|
41
|
-
* with the same version instead of the latest one. Undefined for npm, which
|
|
42
|
-
* corepack leaves alone, and when the version is unknown.
|
|
43
|
-
*/
|
|
44
|
-
export declare function detectPackageManagerSpec(userAgent?: string | undefined): string | undefined;
|
|
45
|
-
export declare function buildPackageJson(answers: InitAnswers, options: ScaffoldOptions): string;
|
|
46
|
-
export declare function buildEnvFile(answers: InitAnswers): string | null;
|
|
47
|
-
export declare function buildGatewayFile(answers: InitAnswers): string;
|
|
48
|
-
export declare function buildAgentFile(answers: InitAnswers): string;
|
|
49
|
-
export declare function buildGitignore(answers: InitAnswers): string;
|
|
22
|
+
export { validateProjectName };
|
|
50
23
|
/**
|
|
51
|
-
* `cogitator
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* gateway serves no HTTP health check), publishes the WebChat port, keeps
|
|
55
|
-
* the SQLite database on a volume and needs the API key and channel tokens.
|
|
24
|
+
* The project `cogitator init` creates: the `channels` preset of
|
|
25
|
+
* create-cogitator-app with the answers, so both commands generate the same
|
|
26
|
+
* code from the same engine.
|
|
56
27
|
*/
|
|
57
|
-
export declare function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
target: string;
|
|
61
|
-
module: string;
|
|
62
|
-
moduleResolution: string;
|
|
63
|
-
strict: boolean;
|
|
64
|
-
esModuleInterop: boolean;
|
|
65
|
-
skipLibCheck: boolean;
|
|
66
|
-
outDir: string;
|
|
67
|
-
rootDir: string;
|
|
68
|
-
};
|
|
69
|
-
include: string[];
|
|
70
|
-
};
|
|
71
|
-
export declare function buildProjectFiles(answers: InitAnswers, options: ScaffoldOptions): Record<string, string>;
|
|
72
|
-
export declare function writeProjectFiles(projectPath: string, files: Record<string, string>): void;
|
|
28
|
+
export declare function initSpec(answers: InitAnswers, packageManager?: "pnpm" | "npm" | "yarn" | "bun"): ProjectSpecInput;
|
|
29
|
+
/** What `cogitator init` writes to `.env`: the provider key, the channel tokens and a custom database URL. */
|
|
30
|
+
export declare function initSecrets(answers: InitAnswers): Record<string, string>;
|
|
73
31
|
export declare const initCommand: Command;
|
|
74
32
|
//# sourceMappingURL=init.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,OAAO,EASL,mBAAmB,EACnB,KAAK,gBAAgB,EAEtB,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,6BAA6B,CAAC;AAErC,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AACvE,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE1D,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,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