@generacy-ai/generacy 0.0.0-preview-20260304013206
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 +191 -0
- package/README.md +207 -0
- package/bin/generacy.js +11 -0
- package/dist/agency/index.d.ts +68 -0
- package/dist/agency/index.d.ts.map +1 -0
- package/dist/agency/index.js +28 -0
- package/dist/agency/index.js.map +1 -0
- package/dist/agency/network.d.ts +41 -0
- package/dist/agency/network.d.ts.map +1 -0
- package/dist/agency/network.js +133 -0
- package/dist/agency/network.js.map +1 -0
- package/dist/agency/subprocess.d.ts +58 -0
- package/dist/agency/subprocess.d.ts.map +1 -0
- package/dist/agency/subprocess.js +216 -0
- package/dist/agency/subprocess.js.map +1 -0
- package/dist/cli/commands/agent.d.ts +10 -0
- package/dist/cli/commands/agent.d.ts.map +1 -0
- package/dist/cli/commands/agent.js +216 -0
- package/dist/cli/commands/agent.js.map +1 -0
- package/dist/cli/commands/doctor/checks/agency-mcp.d.ts +3 -0
- package/dist/cli/commands/doctor/checks/agency-mcp.d.ts.map +1 -0
- package/dist/cli/commands/doctor/checks/agency-mcp.js +51 -0
- package/dist/cli/commands/doctor/checks/agency-mcp.js.map +1 -0
- package/dist/cli/commands/doctor/checks/anthropic-key.d.ts +3 -0
- package/dist/cli/commands/doctor/checks/anthropic-key.d.ts.map +1 -0
- package/dist/cli/commands/doctor/checks/anthropic-key.js +68 -0
- package/dist/cli/commands/doctor/checks/anthropic-key.js.map +1 -0
- package/dist/cli/commands/doctor/checks/config.d.ts +3 -0
- package/dist/cli/commands/doctor/checks/config.d.ts.map +1 -0
- package/dist/cli/commands/doctor/checks/config.js +81 -0
- package/dist/cli/commands/doctor/checks/config.js.map +1 -0
- package/dist/cli/commands/doctor/checks/devcontainer.d.ts +3 -0
- package/dist/cli/commands/doctor/checks/devcontainer.d.ts.map +1 -0
- package/dist/cli/commands/doctor/checks/devcontainer.js +58 -0
- package/dist/cli/commands/doctor/checks/devcontainer.js.map +1 -0
- package/dist/cli/commands/doctor/checks/docker.d.ts +3 -0
- package/dist/cli/commands/doctor/checks/docker.d.ts.map +1 -0
- package/dist/cli/commands/doctor/checks/docker.js +71 -0
- package/dist/cli/commands/doctor/checks/docker.js.map +1 -0
- package/dist/cli/commands/doctor/checks/env-file.d.ts +3 -0
- package/dist/cli/commands/doctor/checks/env-file.d.ts.map +1 -0
- package/dist/cli/commands/doctor/checks/env-file.js +56 -0
- package/dist/cli/commands/doctor/checks/env-file.js.map +1 -0
- package/dist/cli/commands/doctor/checks/github-token.d.ts +3 -0
- package/dist/cli/commands/doctor/checks/github-token.d.ts.map +1 -0
- package/dist/cli/commands/doctor/checks/github-token.js +99 -0
- package/dist/cli/commands/doctor/checks/github-token.js.map +1 -0
- package/dist/cli/commands/doctor/checks/npm-packages.d.ts +3 -0
- package/dist/cli/commands/doctor/checks/npm-packages.d.ts.map +1 -0
- package/dist/cli/commands/doctor/checks/npm-packages.js +117 -0
- package/dist/cli/commands/doctor/checks/npm-packages.js.map +1 -0
- package/dist/cli/commands/doctor/formatter.d.ts +27 -0
- package/dist/cli/commands/doctor/formatter.d.ts.map +1 -0
- package/dist/cli/commands/doctor/formatter.js +162 -0
- package/dist/cli/commands/doctor/formatter.js.map +1 -0
- package/dist/cli/commands/doctor/index.d.ts +5 -0
- package/dist/cli/commands/doctor/index.d.ts.map +1 -0
- package/dist/cli/commands/doctor/index.js +8 -0
- package/dist/cli/commands/doctor/index.js.map +1 -0
- package/dist/cli/commands/doctor/registry.d.ts +48 -0
- package/dist/cli/commands/doctor/registry.d.ts.map +1 -0
- package/dist/cli/commands/doctor/registry.js +166 -0
- package/dist/cli/commands/doctor/registry.js.map +1 -0
- package/dist/cli/commands/doctor/runner.d.ts +14 -0
- package/dist/cli/commands/doctor/runner.d.ts.map +1 -0
- package/dist/cli/commands/doctor/runner.js +257 -0
- package/dist/cli/commands/doctor/runner.js.map +1 -0
- package/dist/cli/commands/doctor/types.d.ts +87 -0
- package/dist/cli/commands/doctor/types.d.ts.map +1 -0
- package/dist/cli/commands/doctor/types.js +2 -0
- package/dist/cli/commands/doctor/types.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +12 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cli/commands/doctor.js +97 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/init/conflicts.d.ts +36 -0
- package/dist/cli/commands/init/conflicts.d.ts.map +1 -0
- package/dist/cli/commands/init/conflicts.js +165 -0
- package/dist/cli/commands/init/conflicts.js.map +1 -0
- package/dist/cli/commands/init/github.d.ts +32 -0
- package/dist/cli/commands/init/github.d.ts.map +1 -0
- package/dist/cli/commands/init/github.js +161 -0
- package/dist/cli/commands/init/github.js.map +1 -0
- package/dist/cli/commands/init/index.d.ts +21 -0
- package/dist/cli/commands/init/index.d.ts.map +1 -0
- package/dist/cli/commands/init/index.js +175 -0
- package/dist/cli/commands/init/index.js.map +1 -0
- package/dist/cli/commands/init/prompts.d.ts +15 -0
- package/dist/cli/commands/init/prompts.d.ts.map +1 -0
- package/dist/cli/commands/init/prompts.js +281 -0
- package/dist/cli/commands/init/prompts.js.map +1 -0
- package/dist/cli/commands/init/repo-utils.d.ts +32 -0
- package/dist/cli/commands/init/repo-utils.d.ts.map +1 -0
- package/dist/cli/commands/init/repo-utils.js +112 -0
- package/dist/cli/commands/init/repo-utils.js.map +1 -0
- package/dist/cli/commands/init/resolver.d.ts +20 -0
- package/dist/cli/commands/init/resolver.d.ts.map +1 -0
- package/dist/cli/commands/init/resolver.js +273 -0
- package/dist/cli/commands/init/resolver.js.map +1 -0
- package/dist/cli/commands/init/summary.d.ts +21 -0
- package/dist/cli/commands/init/summary.d.ts.map +1 -0
- package/dist/cli/commands/init/summary.js +100 -0
- package/dist/cli/commands/init/summary.js.map +1 -0
- package/dist/cli/commands/init/types.d.ts +53 -0
- package/dist/cli/commands/init/types.d.ts.map +1 -0
- package/dist/cli/commands/init/types.js +2 -0
- package/dist/cli/commands/init/types.js.map +1 -0
- package/dist/cli/commands/init/writer.d.ts +22 -0
- package/dist/cli/commands/init/writer.d.ts.map +1 -0
- package/dist/cli/commands/init/writer.js +96 -0
- package/dist/cli/commands/init/writer.js.map +1 -0
- package/dist/cli/commands/orchestrator.d.ts +11 -0
- package/dist/cli/commands/orchestrator.d.ts.map +1 -0
- package/dist/cli/commands/orchestrator.js +291 -0
- package/dist/cli/commands/orchestrator.js.map +1 -0
- package/dist/cli/commands/run.d.ts +10 -0
- package/dist/cli/commands/run.d.ts.map +1 -0
- package/dist/cli/commands/run.js +167 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/commands/setup/auth.d.ts +11 -0
- package/dist/cli/commands/setup/auth.d.ts.map +1 -0
- package/dist/cli/commands/setup/auth.js +108 -0
- package/dist/cli/commands/setup/auth.js.map +1 -0
- package/dist/cli/commands/setup/build.d.ts +11 -0
- package/dist/cli/commands/setup/build.d.ts.map +1 -0
- package/dist/cli/commands/setup/build.js +212 -0
- package/dist/cli/commands/setup/build.js.map +1 -0
- package/dist/cli/commands/setup/services.d.ts +11 -0
- package/dist/cli/commands/setup/services.d.ts.map +1 -0
- package/dist/cli/commands/setup/services.js +294 -0
- package/dist/cli/commands/setup/services.js.map +1 -0
- package/dist/cli/commands/setup/workspace.d.ts +11 -0
- package/dist/cli/commands/setup/workspace.d.ts.map +1 -0
- package/dist/cli/commands/setup/workspace.js +215 -0
- package/dist/cli/commands/setup/workspace.js.map +1 -0
- package/dist/cli/commands/setup.d.ts +7 -0
- package/dist/cli/commands/setup.d.ts.map +1 -0
- package/dist/cli/commands/setup.js +19 -0
- package/dist/cli/commands/setup.js.map +1 -0
- package/dist/cli/commands/validate.d.ts +10 -0
- package/dist/cli/commands/validate.d.ts.map +1 -0
- package/dist/cli/commands/validate.js +164 -0
- package/dist/cli/commands/validate.js.map +1 -0
- package/dist/cli/commands/worker.d.ts +10 -0
- package/dist/cli/commands/worker.d.ts.map +1 -0
- package/dist/cli/commands/worker.js +224 -0
- package/dist/cli/commands/worker.js.map +1 -0
- package/dist/cli/index.d.ts +14 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +68 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/utils/config.d.ts +49 -0
- package/dist/cli/utils/config.d.ts.map +1 -0
- package/dist/cli/utils/config.js +110 -0
- package/dist/cli/utils/config.js.map +1 -0
- package/dist/cli/utils/exec.d.ts +39 -0
- package/dist/cli/utils/exec.d.ts.map +1 -0
- package/dist/cli/utils/exec.js +68 -0
- package/dist/cli/utils/exec.js.map +1 -0
- package/dist/cli/utils/logger.d.ts +47 -0
- package/dist/cli/utils/logger.d.ts.map +1 -0
- package/dist/cli/utils/logger.js +97 -0
- package/dist/cli/utils/logger.js.map +1 -0
- package/dist/config/index.d.ts +10 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +13 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +104 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +266 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/schema.d.ts +304 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +160 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/config/validator.d.ts +60 -0
- package/dist/config/validator.d.ts.map +1 -0
- package/dist/config/validator.js +112 -0
- package/dist/config/validator.js.map +1 -0
- package/dist/health/server.d.ts +47 -0
- package/dist/health/server.d.ts.map +1 -0
- package/dist/health/server.js +92 -0
- package/dist/health/server.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/orchestrator/async-event-queue.d.ts +28 -0
- package/dist/orchestrator/async-event-queue.d.ts.map +1 -0
- package/dist/orchestrator/async-event-queue.js +57 -0
- package/dist/orchestrator/async-event-queue.js.map +1 -0
- package/dist/orchestrator/client.d.ts +110 -0
- package/dist/orchestrator/client.d.ts.map +1 -0
- package/dist/orchestrator/client.js +288 -0
- package/dist/orchestrator/client.js.map +1 -0
- package/dist/orchestrator/event-bus.d.ts +195 -0
- package/dist/orchestrator/event-bus.d.ts.map +1 -0
- package/dist/orchestrator/event-bus.js +557 -0
- package/dist/orchestrator/event-bus.js.map +1 -0
- package/dist/orchestrator/heartbeat.d.ts +71 -0
- package/dist/orchestrator/heartbeat.d.ts.map +1 -0
- package/dist/orchestrator/heartbeat.js +116 -0
- package/dist/orchestrator/heartbeat.js.map +1 -0
- package/dist/orchestrator/index.d.ts +25 -0
- package/dist/orchestrator/index.d.ts.map +1 -0
- package/dist/orchestrator/index.js +15 -0
- package/dist/orchestrator/index.js.map +1 -0
- package/dist/orchestrator/job-handler.d.ts +109 -0
- package/dist/orchestrator/job-handler.d.ts.map +1 -0
- package/dist/orchestrator/job-handler.js +612 -0
- package/dist/orchestrator/job-handler.js.map +1 -0
- package/dist/orchestrator/job-queue.d.ts +81 -0
- package/dist/orchestrator/job-queue.d.ts.map +1 -0
- package/dist/orchestrator/job-queue.js +206 -0
- package/dist/orchestrator/job-queue.js.map +1 -0
- package/dist/orchestrator/label-monitor-bridge.d.ts +25 -0
- package/dist/orchestrator/label-monitor-bridge.d.ts.map +1 -0
- package/dist/orchestrator/label-monitor-bridge.js +57 -0
- package/dist/orchestrator/label-monitor-bridge.js.map +1 -0
- package/dist/orchestrator/log-buffer.d.ts +74 -0
- package/dist/orchestrator/log-buffer.d.ts.map +1 -0
- package/dist/orchestrator/log-buffer.js +104 -0
- package/dist/orchestrator/log-buffer.js.map +1 -0
- package/dist/orchestrator/redis-job-queue.d.ts +44 -0
- package/dist/orchestrator/redis-job-queue.d.ts.map +1 -0
- package/dist/orchestrator/redis-job-queue.js +300 -0
- package/dist/orchestrator/redis-job-queue.js.map +1 -0
- package/dist/orchestrator/router.d.ts +125 -0
- package/dist/orchestrator/router.d.ts.map +1 -0
- package/dist/orchestrator/router.js +143 -0
- package/dist/orchestrator/router.js.map +1 -0
- package/dist/orchestrator/server.d.ts +62 -0
- package/dist/orchestrator/server.d.ts.map +1 -0
- package/dist/orchestrator/server.js +711 -0
- package/dist/orchestrator/server.js.map +1 -0
- package/dist/orchestrator/types.d.ts +184 -0
- package/dist/orchestrator/types.d.ts.map +1 -0
- package/dist/orchestrator/types.js +6 -0
- package/dist/orchestrator/types.js.map +1 -0
- package/dist/orchestrator/worker-registry.d.ts +110 -0
- package/dist/orchestrator/worker-registry.d.ts.map +1 -0
- package/dist/orchestrator/worker-registry.js +191 -0
- package/dist/orchestrator/worker-registry.js.map +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI logger setup using Pino.
|
|
3
|
+
* Provides structured logging with pretty output for dev and JSON for prod.
|
|
4
|
+
*/
|
|
5
|
+
import pino from 'pino';
|
|
6
|
+
import type { Logger as WorkflowLogger } from '@generacy-ai/workflow-engine';
|
|
7
|
+
/**
|
|
8
|
+
* Log levels supported by the CLI
|
|
9
|
+
*/
|
|
10
|
+
export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal' | 'silent';
|
|
11
|
+
/**
|
|
12
|
+
* Logger options
|
|
13
|
+
*/
|
|
14
|
+
export interface LoggerOptions {
|
|
15
|
+
level?: LogLevel;
|
|
16
|
+
pretty?: boolean;
|
|
17
|
+
name?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Create a Pino logger instance
|
|
21
|
+
*/
|
|
22
|
+
export declare function createLogger(options?: LoggerOptions): pino.Logger;
|
|
23
|
+
/**
|
|
24
|
+
* Get or create the default logger
|
|
25
|
+
*/
|
|
26
|
+
export declare function getLogger(): pino.Logger;
|
|
27
|
+
/**
|
|
28
|
+
* Set the default logger instance
|
|
29
|
+
*/
|
|
30
|
+
export declare function setLogger(logger: pino.Logger): void;
|
|
31
|
+
/**
|
|
32
|
+
* Adapter to convert Pino logger to WorkflowLogger interface
|
|
33
|
+
*/
|
|
34
|
+
export declare class PinoWorkflowLogger implements WorkflowLogger {
|
|
35
|
+
private readonly pino;
|
|
36
|
+
constructor(pino: pino.Logger);
|
|
37
|
+
info(message: string, ...args: unknown[]): void;
|
|
38
|
+
warn(message: string, ...args: unknown[]): void;
|
|
39
|
+
error(message: string, ...args: unknown[]): void;
|
|
40
|
+
debug(message: string, ...args: unknown[]): void;
|
|
41
|
+
child(bindings: Record<string, unknown>): WorkflowLogger;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Create a workflow logger from a Pino logger
|
|
45
|
+
*/
|
|
46
|
+
export declare function createWorkflowLogger(pino: pino.Logger): WorkflowLogger;
|
|
47
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE7E;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE1F;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,aAAkB,GAAG,IAAI,CAAC,MAAM,CAoBrE;AAOD;;GAEG;AACH,wBAAgB,SAAS,IAAI,IAAI,CAAC,MAAM,CAKvC;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAEnD;AAED;;GAEG;AACH,qBAAa,kBAAmB,YAAW,cAAc;IAC3C,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,IAAI,CAAC,MAAM;IAE9C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAQ/C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAQ/C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAQhD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAQhD,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,cAAc;CAGzD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,GAAG,cAAc,CAEtE"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI logger setup using Pino.
|
|
3
|
+
* Provides structured logging with pretty output for dev and JSON for prod.
|
|
4
|
+
*/
|
|
5
|
+
import pino from 'pino';
|
|
6
|
+
/**
|
|
7
|
+
* Create a Pino logger instance
|
|
8
|
+
*/
|
|
9
|
+
export function createLogger(options = {}) {
|
|
10
|
+
const level = options.level ?? process.env['LOG_LEVEL'] ?? 'info';
|
|
11
|
+
const pretty = options.pretty ?? process.env['NODE_ENV'] !== 'production';
|
|
12
|
+
const transport = pretty
|
|
13
|
+
? {
|
|
14
|
+
target: 'pino-pretty',
|
|
15
|
+
options: {
|
|
16
|
+
colorize: true,
|
|
17
|
+
translateTime: 'SYS:standard',
|
|
18
|
+
ignore: 'pid,hostname',
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
: undefined;
|
|
22
|
+
return pino({
|
|
23
|
+
name: options.name ?? 'generacy',
|
|
24
|
+
level,
|
|
25
|
+
transport,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Default CLI logger instance
|
|
30
|
+
*/
|
|
31
|
+
let defaultLogger = null;
|
|
32
|
+
/**
|
|
33
|
+
* Get or create the default logger
|
|
34
|
+
*/
|
|
35
|
+
export function getLogger() {
|
|
36
|
+
if (!defaultLogger) {
|
|
37
|
+
defaultLogger = createLogger();
|
|
38
|
+
}
|
|
39
|
+
return defaultLogger;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Set the default logger instance
|
|
43
|
+
*/
|
|
44
|
+
export function setLogger(logger) {
|
|
45
|
+
defaultLogger = logger;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Adapter to convert Pino logger to WorkflowLogger interface
|
|
49
|
+
*/
|
|
50
|
+
export class PinoWorkflowLogger {
|
|
51
|
+
pino;
|
|
52
|
+
constructor(pino) {
|
|
53
|
+
this.pino = pino;
|
|
54
|
+
}
|
|
55
|
+
info(message, ...args) {
|
|
56
|
+
if (args.length > 0) {
|
|
57
|
+
this.pino.info({ data: args }, message);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
this.pino.info(message);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
warn(message, ...args) {
|
|
64
|
+
if (args.length > 0) {
|
|
65
|
+
this.pino.warn({ data: args }, message);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
this.pino.warn(message);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
error(message, ...args) {
|
|
72
|
+
if (args.length > 0) {
|
|
73
|
+
this.pino.error({ data: args }, message);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
this.pino.error(message);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
debug(message, ...args) {
|
|
80
|
+
if (args.length > 0) {
|
|
81
|
+
this.pino.debug({ data: args }, message);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
this.pino.debug(message);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
child(bindings) {
|
|
88
|
+
return new PinoWorkflowLogger(this.pino.child(bindings));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Create a workflow logger from a Pino logger
|
|
93
|
+
*/
|
|
94
|
+
export function createWorkflowLogger(pino) {
|
|
95
|
+
return new PinoWorkflowLogger(pino);
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/cli/utils/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,IAAI,MAAM,MAAM,CAAC;AAiBxB;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,UAAyB,EAAE;IACtD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAK,OAAO,CAAC,GAAG,CAAC,WAAW,CAAc,IAAI,MAAM,CAAC;IAChF,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,YAAY,CAAC;IAE1E,MAAM,SAAS,GAAG,MAAM;QACtB,CAAC,CAAC;YACE,MAAM,EAAE,aAAa;YACrB,OAAO,EAAE;gBACP,QAAQ,EAAE,IAAI;gBACd,aAAa,EAAE,cAAc;gBAC7B,MAAM,EAAE,cAAc;aACvB;SACF;QACH,CAAC,CAAC,SAAS,CAAC;IAEd,OAAO,IAAI,CAAC;QACV,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,UAAU;QAChC,KAAK;QACL,SAAS;KACV,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,IAAI,aAAa,GAAuB,IAAI,CAAC;AAE7C;;GAEG;AACH,MAAM,UAAU,SAAS;IACvB,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,aAAa,GAAG,YAAY,EAAE,CAAC;IACjC,CAAC;IAC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,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;QAC3C,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,KAAK,CAAC,QAAiC;QACrC,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAiB;IACpD,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @generacy-ai/generacy/config
|
|
3
|
+
*
|
|
4
|
+
* Configuration schema and validation for Generacy projects.
|
|
5
|
+
* Defines the .generacy/config.yaml schema and provides type-safe validation.
|
|
6
|
+
*/
|
|
7
|
+
export { ProjectConfigSchema, type ProjectConfig, ReposConfigSchema, type ReposConfig, DefaultsConfigSchema, type DefaultsConfig, OrchestratorSettingsSchema, type OrchestratorSettings, ClusterConfigSchema, type ClusterConfig, GeneracyConfigSchema, type GeneracyConfig, validateConfig, } from './schema.js';
|
|
8
|
+
export { ConfigValidationError, validateNoDuplicateRepos, validateSemantics, } from './validator.js';
|
|
9
|
+
export { loadConfig, findConfigFile, parseConfig, type LoadConfigOptions, ConfigNotFoundError, ConfigParseError, ConfigSchemaError, } from './loader.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,mBAAmB,EACnB,KAAK,aAAa,EAClB,iBAAiB,EACjB,KAAK,WAAW,EAChB,oBAAoB,EACpB,KAAK,cAAc,EACnB,0BAA0B,EAC1B,KAAK,oBAAoB,EACzB,mBAAmB,EACnB,KAAK,aAAa,EAClB,oBAAoB,EACpB,KAAK,cAAc,EACnB,cAAc,GACf,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,UAAU,EACV,cAAc,EACd,WAAW,EACX,KAAK,iBAAiB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @generacy-ai/generacy/config
|
|
3
|
+
*
|
|
4
|
+
* Configuration schema and validation for Generacy projects.
|
|
5
|
+
* Defines the .generacy/config.yaml schema and provides type-safe validation.
|
|
6
|
+
*/
|
|
7
|
+
// Export all schemas and types
|
|
8
|
+
export { ProjectConfigSchema, ReposConfigSchema, DefaultsConfigSchema, OrchestratorSettingsSchema, ClusterConfigSchema, GeneracyConfigSchema, validateConfig, } from './schema.js';
|
|
9
|
+
// Export validation utilities
|
|
10
|
+
export { ConfigValidationError, validateNoDuplicateRepos, validateSemantics, } from './validator.js';
|
|
11
|
+
// Export loader utilities
|
|
12
|
+
export { loadConfig, findConfigFile, parseConfig, ConfigNotFoundError, ConfigParseError, ConfigSchemaError, } from './loader.js';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,+BAA+B;AAC/B,OAAO,EACL,mBAAmB,EAEnB,iBAAiB,EAEjB,oBAAoB,EAEpB,0BAA0B,EAE1B,mBAAmB,EAEnB,oBAAoB,EAEpB,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,8BAA8B;AAC9B,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AAExB,0BAA0B;AAC1B,OAAO,EACL,UAAU,EACV,cAAc,EACd,WAAW,EAEX,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { ZodError } from 'zod';
|
|
2
|
+
import { type GeneracyConfig } from './schema.js';
|
|
3
|
+
/**
|
|
4
|
+
* Error thrown when config file cannot be found
|
|
5
|
+
*/
|
|
6
|
+
export declare class ConfigNotFoundError extends Error {
|
|
7
|
+
readonly startDir: string;
|
|
8
|
+
readonly searchPath: string[];
|
|
9
|
+
constructor(startDir: string, searchPath: string[]);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Error thrown when config file contains invalid YAML
|
|
13
|
+
*/
|
|
14
|
+
export declare class ConfigParseError extends Error {
|
|
15
|
+
readonly filePath: string;
|
|
16
|
+
readonly cause: Error;
|
|
17
|
+
constructor(filePath: string, cause: Error);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Error thrown when config file fails schema validation
|
|
21
|
+
*/
|
|
22
|
+
export declare class ConfigSchemaError extends Error {
|
|
23
|
+
readonly filePath: string;
|
|
24
|
+
readonly errors: ZodError;
|
|
25
|
+
constructor(filePath: string, errors: ZodError);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Find the config file by walking up the directory tree
|
|
29
|
+
*
|
|
30
|
+
* @param startDir - Directory to start searching from
|
|
31
|
+
* @returns Absolute path to config file, or null if not found
|
|
32
|
+
*
|
|
33
|
+
* Discovery order:
|
|
34
|
+
* 1. Check for .generacy/config.yaml in current directory
|
|
35
|
+
* 2. Walk up parent directories until found
|
|
36
|
+
* 3. Stop at repository root (detected via .git/ directory)
|
|
37
|
+
* 4. Return null if not found
|
|
38
|
+
*/
|
|
39
|
+
export declare function findConfigFile(startDir?: string): string | null;
|
|
40
|
+
/**
|
|
41
|
+
* Parse and validate a YAML config string
|
|
42
|
+
*
|
|
43
|
+
* @param yamlContent - YAML content as string
|
|
44
|
+
* @returns Validated configuration
|
|
45
|
+
* @throws ConfigParseError if YAML parsing fails
|
|
46
|
+
* @throws ConfigSchemaError if validation fails
|
|
47
|
+
* @throws ConfigValidationError if semantic validation fails
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const config = parseConfig(`
|
|
52
|
+
* project:
|
|
53
|
+
* id: "proj_abc123"
|
|
54
|
+
* name: "My Project"
|
|
55
|
+
* repos:
|
|
56
|
+
* primary: "github.com/acme/main"
|
|
57
|
+
* `);
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function parseConfig(yamlContent: string): GeneracyConfig;
|
|
61
|
+
/**
|
|
62
|
+
* Options for loading configuration
|
|
63
|
+
*/
|
|
64
|
+
export interface LoadConfigOptions {
|
|
65
|
+
/**
|
|
66
|
+
* Directory to start searching from
|
|
67
|
+
* Default: process.cwd()
|
|
68
|
+
*/
|
|
69
|
+
startDir?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Explicit config file path (skips discovery)
|
|
72
|
+
* Default: undefined (will search using findConfigFile)
|
|
73
|
+
*/
|
|
74
|
+
configPath?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Load and validate configuration from filesystem
|
|
78
|
+
*
|
|
79
|
+
* Discovery process:
|
|
80
|
+
* 1. If GENERACY_CONFIG_PATH env var is set, use that path
|
|
81
|
+
* 2. If options.configPath is provided, use that path
|
|
82
|
+
* 3. Otherwise, search for .generacy/config.yaml using findConfigFile
|
|
83
|
+
*
|
|
84
|
+
* @param options - Loading options
|
|
85
|
+
* @returns Validated configuration
|
|
86
|
+
* @throws ConfigNotFoundError if config file not found
|
|
87
|
+
* @throws ConfigParseError if YAML parsing fails
|
|
88
|
+
* @throws ConfigSchemaError if validation fails
|
|
89
|
+
* @throws ConfigValidationError if semantic validation fails
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* // Auto-discover config
|
|
94
|
+
* const config = loadConfig();
|
|
95
|
+
*
|
|
96
|
+
* // Explicit path
|
|
97
|
+
* const config = loadConfig({ configPath: '/path/to/config.yaml' });
|
|
98
|
+
*
|
|
99
|
+
* // Start search from specific directory
|
|
100
|
+
* const config = loadConfig({ startDir: '/workspace/project' });
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare function loadConfig(options?: LoadConfigOptions): GeneracyConfig;
|
|
104
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,EAAE,KAAK,cAAc,EAAkB,MAAM,aAAa,CAAC;AAkBlE;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;aAE1B,QAAQ,EAAE,MAAM;aAChB,UAAU,EAAE,MAAM,EAAE;gBADpB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAAE;CAQvC;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;aAEvB,QAAQ,EAAE,MAAM;aAChB,KAAK,EAAE,KAAK;gBADZ,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,KAAK;CAK/B;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;aAExB,QAAQ,EAAE,MAAM;aAChB,MAAM,EAAE,QAAQ;gBADhB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,QAAQ;CAgBnC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,QAAQ,GAAE,MAAsB,GAAG,MAAM,GAAG,IAAI,CAsB9E;AA2BD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,CA2B/D;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,cAAc,CA4F1E"}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { readFileSync, existsSync } from 'node:fs';
|
|
2
|
+
import { resolve, dirname, join, parse } from 'node:path';
|
|
3
|
+
import { parse as parseYaml } from 'yaml';
|
|
4
|
+
import { ZodError } from 'zod';
|
|
5
|
+
import { validateConfig } from './schema.js';
|
|
6
|
+
import { validateSemantics } from './validator.js';
|
|
7
|
+
/**
|
|
8
|
+
* Environment variable for explicit config path override
|
|
9
|
+
*/
|
|
10
|
+
const CONFIG_PATH_ENV = 'GENERACY_CONFIG_PATH';
|
|
11
|
+
/**
|
|
12
|
+
* Default config file name
|
|
13
|
+
*/
|
|
14
|
+
const CONFIG_FILE_NAME = 'config.yaml';
|
|
15
|
+
/**
|
|
16
|
+
* Directory containing config file
|
|
17
|
+
*/
|
|
18
|
+
const CONFIG_DIR_NAME = '.generacy';
|
|
19
|
+
/**
|
|
20
|
+
* Error thrown when config file cannot be found
|
|
21
|
+
*/
|
|
22
|
+
export class ConfigNotFoundError extends Error {
|
|
23
|
+
startDir;
|
|
24
|
+
searchPath;
|
|
25
|
+
constructor(startDir, searchPath) {
|
|
26
|
+
super(`Config file not found. Searched in:\n${searchPath.map(p => ` - ${p}`).join('\n')}\n\n` +
|
|
27
|
+
`Create a config file at: ${join(startDir, CONFIG_DIR_NAME, CONFIG_FILE_NAME)}`);
|
|
28
|
+
this.startDir = startDir;
|
|
29
|
+
this.searchPath = searchPath;
|
|
30
|
+
this.name = 'ConfigNotFoundError';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Error thrown when config file contains invalid YAML
|
|
35
|
+
*/
|
|
36
|
+
export class ConfigParseError extends Error {
|
|
37
|
+
filePath;
|
|
38
|
+
cause;
|
|
39
|
+
constructor(filePath, cause) {
|
|
40
|
+
super(`Failed to parse config file: ${filePath}\n\n${cause.message}`);
|
|
41
|
+
this.filePath = filePath;
|
|
42
|
+
this.cause = cause;
|
|
43
|
+
this.name = 'ConfigParseError';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Error thrown when config file fails schema validation
|
|
48
|
+
*/
|
|
49
|
+
export class ConfigSchemaError extends Error {
|
|
50
|
+
filePath;
|
|
51
|
+
errors;
|
|
52
|
+
constructor(filePath, errors) {
|
|
53
|
+
const errorMessages = errors.errors
|
|
54
|
+
.map(err => {
|
|
55
|
+
const path = err.path.length > 0 ? err.path.join('.') : 'root';
|
|
56
|
+
return ` - ${path}: ${err.message}`;
|
|
57
|
+
})
|
|
58
|
+
.join('\n');
|
|
59
|
+
super(`Config validation failed: ${filePath}\n\n` +
|
|
60
|
+
`Validation errors:\n${errorMessages}\n\n` +
|
|
61
|
+
`See documentation for schema reference.`);
|
|
62
|
+
this.filePath = filePath;
|
|
63
|
+
this.errors = errors;
|
|
64
|
+
this.name = 'ConfigSchemaError';
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Find the config file by walking up the directory tree
|
|
69
|
+
*
|
|
70
|
+
* @param startDir - Directory to start searching from
|
|
71
|
+
* @returns Absolute path to config file, or null if not found
|
|
72
|
+
*
|
|
73
|
+
* Discovery order:
|
|
74
|
+
* 1. Check for .generacy/config.yaml in current directory
|
|
75
|
+
* 2. Walk up parent directories until found
|
|
76
|
+
* 3. Stop at repository root (detected via .git/ directory)
|
|
77
|
+
* 4. Return null if not found
|
|
78
|
+
*/
|
|
79
|
+
export function findConfigFile(startDir = process.cwd()) {
|
|
80
|
+
let currentDir = resolve(startDir);
|
|
81
|
+
const root = parse(currentDir).root;
|
|
82
|
+
const searchPath = [];
|
|
83
|
+
while (currentDir !== root) {
|
|
84
|
+
const configPath = join(currentDir, CONFIG_DIR_NAME, CONFIG_FILE_NAME);
|
|
85
|
+
searchPath.push(configPath);
|
|
86
|
+
if (existsSync(configPath)) {
|
|
87
|
+
return configPath;
|
|
88
|
+
}
|
|
89
|
+
// Stop at repository root
|
|
90
|
+
if (existsSync(join(currentDir, '.git'))) {
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
currentDir = dirname(currentDir);
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Load configuration from a YAML file
|
|
99
|
+
*
|
|
100
|
+
* @param filePath - Path to the config file
|
|
101
|
+
* @returns Parsed configuration object (unvalidated)
|
|
102
|
+
* @throws ConfigParseError if YAML parsing fails
|
|
103
|
+
*/
|
|
104
|
+
function loadFromFile(filePath) {
|
|
105
|
+
const absolutePath = resolve(filePath);
|
|
106
|
+
if (!existsSync(absolutePath)) {
|
|
107
|
+
throw new Error(`Configuration file not found: ${absolutePath}`);
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
const content = readFileSync(absolutePath, 'utf-8');
|
|
111
|
+
return parseYaml(content);
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
throw new ConfigParseError(absolutePath, error instanceof Error ? error : new Error(String(error)));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Parse and validate a YAML config string
|
|
119
|
+
*
|
|
120
|
+
* @param yamlContent - YAML content as string
|
|
121
|
+
* @returns Validated configuration
|
|
122
|
+
* @throws ConfigParseError if YAML parsing fails
|
|
123
|
+
* @throws ConfigSchemaError if validation fails
|
|
124
|
+
* @throws ConfigValidationError if semantic validation fails
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* const config = parseConfig(`
|
|
129
|
+
* project:
|
|
130
|
+
* id: "proj_abc123"
|
|
131
|
+
* name: "My Project"
|
|
132
|
+
* repos:
|
|
133
|
+
* primary: "github.com/acme/main"
|
|
134
|
+
* `);
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
export function parseConfig(yamlContent) {
|
|
138
|
+
let parsed;
|
|
139
|
+
try {
|
|
140
|
+
parsed = parseYaml(yamlContent);
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
throw new ConfigParseError('<string>', error instanceof Error ? error : new Error(String(error)));
|
|
144
|
+
}
|
|
145
|
+
// Structural validation (Zod schema)
|
|
146
|
+
let config;
|
|
147
|
+
try {
|
|
148
|
+
config = validateConfig(parsed);
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
if (error instanceof ZodError) {
|
|
152
|
+
throw new ConfigSchemaError('<string>', error);
|
|
153
|
+
}
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
// Semantic validation (custom validators)
|
|
157
|
+
validateSemantics(config);
|
|
158
|
+
return config;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Load and validate configuration from filesystem
|
|
162
|
+
*
|
|
163
|
+
* Discovery process:
|
|
164
|
+
* 1. If GENERACY_CONFIG_PATH env var is set, use that path
|
|
165
|
+
* 2. If options.configPath is provided, use that path
|
|
166
|
+
* 3. Otherwise, search for .generacy/config.yaml using findConfigFile
|
|
167
|
+
*
|
|
168
|
+
* @param options - Loading options
|
|
169
|
+
* @returns Validated configuration
|
|
170
|
+
* @throws ConfigNotFoundError if config file not found
|
|
171
|
+
* @throws ConfigParseError if YAML parsing fails
|
|
172
|
+
* @throws ConfigSchemaError if validation fails
|
|
173
|
+
* @throws ConfigValidationError if semantic validation fails
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```typescript
|
|
177
|
+
* // Auto-discover config
|
|
178
|
+
* const config = loadConfig();
|
|
179
|
+
*
|
|
180
|
+
* // Explicit path
|
|
181
|
+
* const config = loadConfig({ configPath: '/path/to/config.yaml' });
|
|
182
|
+
*
|
|
183
|
+
* // Start search from specific directory
|
|
184
|
+
* const config = loadConfig({ startDir: '/workspace/project' });
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
export function loadConfig(options = {}) {
|
|
188
|
+
const { startDir = process.cwd(), configPath } = options;
|
|
189
|
+
// Priority 1: Environment variable
|
|
190
|
+
const envConfigPath = process.env[CONFIG_PATH_ENV];
|
|
191
|
+
if (envConfigPath) {
|
|
192
|
+
const absolutePath = resolve(envConfigPath);
|
|
193
|
+
if (!existsSync(absolutePath)) {
|
|
194
|
+
throw new ConfigNotFoundError(startDir, [absolutePath]);
|
|
195
|
+
}
|
|
196
|
+
const rawConfig = loadFromFile(absolutePath);
|
|
197
|
+
// Structural validation
|
|
198
|
+
let config;
|
|
199
|
+
try {
|
|
200
|
+
config = validateConfig(rawConfig);
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
if (error instanceof ZodError) {
|
|
204
|
+
throw new ConfigSchemaError(absolutePath, error);
|
|
205
|
+
}
|
|
206
|
+
throw error;
|
|
207
|
+
}
|
|
208
|
+
// Semantic validation
|
|
209
|
+
validateSemantics(config);
|
|
210
|
+
return config;
|
|
211
|
+
}
|
|
212
|
+
// Priority 2: Explicit path from options
|
|
213
|
+
if (configPath) {
|
|
214
|
+
const absolutePath = resolve(configPath);
|
|
215
|
+
if (!existsSync(absolutePath)) {
|
|
216
|
+
throw new ConfigNotFoundError(startDir, [absolutePath]);
|
|
217
|
+
}
|
|
218
|
+
const rawConfig = loadFromFile(absolutePath);
|
|
219
|
+
// Structural validation
|
|
220
|
+
let config;
|
|
221
|
+
try {
|
|
222
|
+
config = validateConfig(rawConfig);
|
|
223
|
+
}
|
|
224
|
+
catch (error) {
|
|
225
|
+
if (error instanceof ZodError) {
|
|
226
|
+
throw new ConfigSchemaError(absolutePath, error);
|
|
227
|
+
}
|
|
228
|
+
throw error;
|
|
229
|
+
}
|
|
230
|
+
// Semantic validation
|
|
231
|
+
validateSemantics(config);
|
|
232
|
+
return config;
|
|
233
|
+
}
|
|
234
|
+
// Priority 3: Auto-discover
|
|
235
|
+
const discoveredPath = findConfigFile(startDir);
|
|
236
|
+
if (!discoveredPath) {
|
|
237
|
+
// Build search path for error message
|
|
238
|
+
const searchPath = [];
|
|
239
|
+
let currentDir = resolve(startDir);
|
|
240
|
+
const root = parse(currentDir).root;
|
|
241
|
+
while (currentDir !== root) {
|
|
242
|
+
searchPath.push(join(currentDir, CONFIG_DIR_NAME, CONFIG_FILE_NAME));
|
|
243
|
+
if (existsSync(join(currentDir, '.git'))) {
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
currentDir = dirname(currentDir);
|
|
247
|
+
}
|
|
248
|
+
throw new ConfigNotFoundError(startDir, searchPath);
|
|
249
|
+
}
|
|
250
|
+
const rawConfig = loadFromFile(discoveredPath);
|
|
251
|
+
// Structural validation
|
|
252
|
+
let config;
|
|
253
|
+
try {
|
|
254
|
+
config = validateConfig(rawConfig);
|
|
255
|
+
}
|
|
256
|
+
catch (error) {
|
|
257
|
+
if (error instanceof ZodError) {
|
|
258
|
+
throw new ConfigSchemaError(discoveredPath, error);
|
|
259
|
+
}
|
|
260
|
+
throw error;
|
|
261
|
+
}
|
|
262
|
+
// Semantic validation
|
|
263
|
+
validateSemantics(config);
|
|
264
|
+
return config;
|
|
265
|
+
}
|
|
266
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,C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