@utilarium/cardigantime 0.0.24-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +65 -0
- package/README.md +398 -0
- package/dist/cardigantime.cjs +2169 -0
- package/dist/cardigantime.cjs.map +1 -0
- package/dist/cardigantime.d.ts +92 -0
- package/dist/cardigantime.js +198 -0
- package/dist/cardigantime.js.map +1 -0
- package/dist/config/executable-security.d.ts +32 -0
- package/dist/config/format-detector.d.ts +59 -0
- package/dist/configure.d.ts +55 -0
- package/dist/configure.js +125 -0
- package/dist/configure.js.map +1 -0
- package/dist/constants.d.ts +25 -0
- package/dist/constants.js +38 -0
- package/dist/constants.js.map +1 -0
- package/dist/discovery/discoverer.d.ts +62 -0
- package/dist/discovery/hierarchical-modes.d.ts +64 -0
- package/dist/discovery/index.d.ts +15 -0
- package/dist/discovery/patterns.d.ts +77 -0
- package/dist/discovery/root-detection.d.ts +100 -0
- package/dist/discovery/traversal-security.d.ts +106 -0
- package/dist/env/errors.d.ts +18 -0
- package/dist/env/index.d.ts +7 -0
- package/dist/env/naming.d.ts +38 -0
- package/dist/env/parser.d.ts +61 -0
- package/dist/env/reader.d.ts +45 -0
- package/dist/env/resolver.d.ts +25 -0
- package/dist/env/schema-utils.d.ts +33 -0
- package/dist/env/types.d.ts +43 -0
- package/dist/error/ArgumentError.d.ts +31 -0
- package/dist/error/ArgumentError.js +48 -0
- package/dist/error/ArgumentError.js.map +1 -0
- package/dist/error/ConfigParseError.d.ts +26 -0
- package/dist/error/ConfigurationError.d.ts +21 -0
- package/dist/error/ConfigurationError.js +46 -0
- package/dist/error/ConfigurationError.js.map +1 -0
- package/dist/error/FileSystemError.d.ts +30 -0
- package/dist/error/FileSystemError.js +58 -0
- package/dist/error/FileSystemError.js.map +1 -0
- package/dist/error/index.d.ts +4 -0
- package/dist/mcp/discovery.d.ts +105 -0
- package/dist/mcp/errors.d.ts +75 -0
- package/dist/mcp/index.d.ts +22 -0
- package/dist/mcp/integration.d.ts +184 -0
- package/dist/mcp/parser.d.ts +141 -0
- package/dist/mcp/resolver.d.ts +165 -0
- package/dist/mcp/tools/check-config-types.d.ts +208 -0
- package/dist/mcp/tools/check-config.d.ts +85 -0
- package/dist/mcp/tools/index.d.ts +12 -0
- package/dist/mcp/types.d.ts +210 -0
- package/dist/parsers/index.d.ts +25 -0
- package/dist/parsers/javascript-parser.d.ts +12 -0
- package/dist/parsers/json-parser.d.ts +6 -0
- package/dist/parsers/typescript-parser.d.ts +15 -0
- package/dist/parsers/yaml-parser.d.ts +6 -0
- package/dist/read.d.ts +56 -0
- package/dist/read.js +653 -0
- package/dist/read.js.map +1 -0
- package/dist/security/audit-logger.d.ts +135 -0
- package/dist/security/cli-validator.d.ts +73 -0
- package/dist/security/config-validator.d.ts +95 -0
- package/dist/security/defaults.d.ts +17 -0
- package/dist/security/index.d.ts +14 -0
- package/dist/security/numeric-guard.d.ts +111 -0
- package/dist/security/path-guard.d.ts +53 -0
- package/dist/security/profiles.d.ts +127 -0
- package/dist/security/security-validator.d.ts +109 -0
- package/dist/security/string-guard.d.ts +92 -0
- package/dist/security/types.d.ts +126 -0
- package/dist/security/zod-secure-enum.d.ts +20 -0
- package/dist/security/zod-secure-number.d.ts +39 -0
- package/dist/security/zod-secure-path.d.ts +24 -0
- package/dist/security/zod-secure-string.d.ts +38 -0
- package/dist/types.d.ts +584 -0
- package/dist/types.js +56 -0
- package/dist/types.js.map +1 -0
- package/dist/util/hierarchical.d.ts +136 -0
- package/dist/util/hierarchical.js +436 -0
- package/dist/util/hierarchical.js.map +1 -0
- package/dist/util/schema-defaults.d.ts +80 -0
- package/dist/util/schema-defaults.js +118 -0
- package/dist/util/schema-defaults.js.map +1 -0
- package/dist/util/storage.d.ts +31 -0
- package/dist/util/storage.js +154 -0
- package/dist/util/storage.js.map +1 -0
- package/dist/validate.d.ts +113 -0
- package/dist/validate.js +260 -0
- package/dist/validate.js.map +1 -0
- package/package.json +84 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for environment variable naming
|
|
3
|
+
*/
|
|
4
|
+
export interface EnvVarNamingConfig {
|
|
5
|
+
/** Application name used as prefix (e.g., 'riotplan') */
|
|
6
|
+
appName: string;
|
|
7
|
+
/** Custom env var name overrides */
|
|
8
|
+
envVarMap?: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Result of env var name generation
|
|
12
|
+
*/
|
|
13
|
+
export interface EnvVarName {
|
|
14
|
+
/** Full env var name (e.g., 'RIOTPLAN_PLAN_DIRECTORY') */
|
|
15
|
+
name: string;
|
|
16
|
+
/** Field path in config (e.g., 'planDirectory' or ['api', 'key']) */
|
|
17
|
+
fieldPath: string | string[];
|
|
18
|
+
/** Whether this is a custom override */
|
|
19
|
+
isCustom: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Result of reading an environment variable
|
|
23
|
+
*/
|
|
24
|
+
export interface EnvVarReadResult {
|
|
25
|
+
/** Full env var name that was read */
|
|
26
|
+
envVarName: string;
|
|
27
|
+
/** Value from process.env (undefined if not set) */
|
|
28
|
+
value: string | undefined;
|
|
29
|
+
/** Whether this used a custom mapping */
|
|
30
|
+
isCustom: boolean;
|
|
31
|
+
/** Field path in config */
|
|
32
|
+
fieldPath: string | string[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Source information for env var config
|
|
36
|
+
*/
|
|
37
|
+
export interface EnvVarConfigSource {
|
|
38
|
+
type: 'env';
|
|
39
|
+
/** Map of field paths to env var read results */
|
|
40
|
+
values: Map<string, EnvVarReadResult>;
|
|
41
|
+
/** When the env vars were read */
|
|
42
|
+
readAt: Date;
|
|
43
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when CLI arguments or function parameters are invalid.
|
|
3
|
+
*
|
|
4
|
+
* This error provides specific context about which argument failed validation
|
|
5
|
+
* and why, making it easier for users to fix their command-line usage or
|
|
6
|
+
* for developers to debug parameter issues.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* throw new ArgumentError('config-directory', 'Path cannot be empty');
|
|
11
|
+
* // Error message: "Path cannot be empty"
|
|
12
|
+
* // error.argument: "config-directory"
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare class ArgumentError extends Error {
|
|
16
|
+
/** The name of the argument that caused the error */
|
|
17
|
+
private argumentName;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new ArgumentError instance.
|
|
20
|
+
*
|
|
21
|
+
* @param argumentName - The name of the invalid argument
|
|
22
|
+
* @param message - Description of why the argument is invalid
|
|
23
|
+
*/
|
|
24
|
+
constructor(argumentName: string, message: string);
|
|
25
|
+
/**
|
|
26
|
+
* Gets the name of the argument that caused this error.
|
|
27
|
+
*
|
|
28
|
+
* @returns The argument name
|
|
29
|
+
*/
|
|
30
|
+
get argument(): string;
|
|
31
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Error thrown when CLI arguments or function parameters are invalid.
|
|
16
|
+
*
|
|
17
|
+
* This error provides specific context about which argument failed validation
|
|
18
|
+
* and why, making it easier for users to fix their command-line usage or
|
|
19
|
+
* for developers to debug parameter issues.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* throw new ArgumentError('config-directory', 'Path cannot be empty');
|
|
24
|
+
* // Error message: "Path cannot be empty"
|
|
25
|
+
* // error.argument: "config-directory"
|
|
26
|
+
* ```
|
|
27
|
+
*/ class ArgumentError extends Error {
|
|
28
|
+
/**
|
|
29
|
+
* Gets the name of the argument that caused this error.
|
|
30
|
+
*
|
|
31
|
+
* @returns The argument name
|
|
32
|
+
*/ get argument() {
|
|
33
|
+
return this.argumentName;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new ArgumentError instance.
|
|
37
|
+
*
|
|
38
|
+
* @param argumentName - The name of the invalid argument
|
|
39
|
+
* @param message - Description of why the argument is invalid
|
|
40
|
+
*/ constructor(argumentName, message){
|
|
41
|
+
super(`${message}`), /** The name of the argument that caused the error */ _define_property(this, "argumentName", void 0);
|
|
42
|
+
this.name = 'ArgumentError';
|
|
43
|
+
this.argumentName = argumentName;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { ArgumentError };
|
|
48
|
+
//# sourceMappingURL=ArgumentError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArgumentError.js","sources":["../../src/error/ArgumentError.ts"],"sourcesContent":["/**\n * Error thrown when CLI arguments or function parameters are invalid.\n * \n * This error provides specific context about which argument failed validation\n * and why, making it easier for users to fix their command-line usage or\n * for developers to debug parameter issues.\n * \n * @example\n * ```typescript\n * throw new ArgumentError('config-directory', 'Path cannot be empty');\n * // Error message: \"Path cannot be empty\"\n * // error.argument: \"config-directory\"\n * ```\n */\nexport class ArgumentError extends Error {\n /** The name of the argument that caused the error */\n private argumentName: string;\n\n /**\n * Creates a new ArgumentError instance.\n * \n * @param argumentName - The name of the invalid argument\n * @param message - Description of why the argument is invalid\n */\n constructor(argumentName: string, message: string) {\n super(`${message}`);\n this.name = 'ArgumentError';\n this.argumentName = argumentName;\n }\n\n /**\n * Gets the name of the argument that caused this error.\n * \n * @returns The argument name\n */\n get argument(): string {\n return this.argumentName;\n }\n}"],"names":["ArgumentError","Error","argument","argumentName","message","name"],"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;;;;IAcO,MAAMA,aAAAA,SAAsBC,KAAAA,CAAAA;AAgB/B;;;;AAIC,QACD,IAAIC,QAAAA,GAAmB;QACnB,OAAO,IAAI,CAACC,YAAY;AAC5B,IAAA;AAnBA;;;;;AAKC,QACD,WAAA,CAAYA,YAAoB,EAAEC,OAAe,CAAE;QAC/C,KAAK,CAAC,GAAGA,OAAAA,CAAAA,CAAS,CAAA,wDATtB,gBAAA,CAAA,IAAA,EAAQD,gBAAR,MAAA,CAAA;QAUI,IAAI,CAACE,IAAI,GAAG,eAAA;QACZ,IAAI,CAACF,YAAY,GAAGA,YAAAA;AACxB,IAAA;AAUJ;;;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when configuration file parsing fails.
|
|
3
|
+
* Provides detailed information about what went wrong during parsing.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ConfigParseError extends Error {
|
|
6
|
+
/**
|
|
7
|
+
* The file path where the parse error occurred
|
|
8
|
+
*/
|
|
9
|
+
readonly filePath: string;
|
|
10
|
+
/**
|
|
11
|
+
* The original error that caused the parse failure
|
|
12
|
+
*/
|
|
13
|
+
readonly cause?: Error;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new ConfigParseError.
|
|
16
|
+
*
|
|
17
|
+
* @param message - Human-readable error message
|
|
18
|
+
* @param filePath - Path to the configuration file that failed to parse
|
|
19
|
+
* @param cause - Optional underlying error that caused the parse failure
|
|
20
|
+
*/
|
|
21
|
+
constructor(message: string, filePath: string, cause?: Error);
|
|
22
|
+
/**
|
|
23
|
+
* Returns a detailed error message including file path and cause.
|
|
24
|
+
*/
|
|
25
|
+
toString(): string;
|
|
26
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when configuration validation fails
|
|
3
|
+
*/
|
|
4
|
+
export declare class ConfigurationError extends Error {
|
|
5
|
+
readonly errorType: 'validation' | 'schema' | 'extra_keys';
|
|
6
|
+
readonly details?: any;
|
|
7
|
+
readonly configPath?: string;
|
|
8
|
+
constructor(errorType: 'validation' | 'schema' | 'extra_keys', message: string, details?: any, configPath?: string);
|
|
9
|
+
/**
|
|
10
|
+
* Creates a validation error for when config doesn't match the schema
|
|
11
|
+
*/
|
|
12
|
+
static validation(message: string, zodError?: any, configPath?: string): ConfigurationError;
|
|
13
|
+
/**
|
|
14
|
+
* Creates an error for when extra/unknown keys are found
|
|
15
|
+
*/
|
|
16
|
+
static extraKeys(extraKeys: string[], allowedKeys: string[], configPath?: string): ConfigurationError;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a schema error for when the configuration schema itself is invalid
|
|
19
|
+
*/
|
|
20
|
+
static schema(message: string, details?: any): ConfigurationError;
|
|
21
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Error thrown when configuration validation fails
|
|
16
|
+
*/ class ConfigurationError extends Error {
|
|
17
|
+
/**
|
|
18
|
+
* Creates a validation error for when config doesn't match the schema
|
|
19
|
+
*/ static validation(message, zodError, configPath) {
|
|
20
|
+
return new ConfigurationError('validation', message, zodError, configPath);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates an error for when extra/unknown keys are found
|
|
24
|
+
*/ static extraKeys(extraKeys, allowedKeys, configPath) {
|
|
25
|
+
const message = `Unknown configuration keys found: ${extraKeys.join(', ')}. Allowed keys are: ${allowedKeys.join(', ')}`;
|
|
26
|
+
return new ConfigurationError('extra_keys', message, {
|
|
27
|
+
extraKeys,
|
|
28
|
+
allowedKeys
|
|
29
|
+
}, configPath);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Creates a schema error for when the configuration schema itself is invalid
|
|
33
|
+
*/ static schema(message, details) {
|
|
34
|
+
return new ConfigurationError('schema', message, details);
|
|
35
|
+
}
|
|
36
|
+
constructor(errorType, message, details, configPath){
|
|
37
|
+
super(message), _define_property(this, "errorType", void 0), _define_property(this, "details", void 0), _define_property(this, "configPath", void 0);
|
|
38
|
+
this.name = 'ConfigurationError';
|
|
39
|
+
this.errorType = errorType;
|
|
40
|
+
this.details = details;
|
|
41
|
+
this.configPath = configPath;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { ConfigurationError };
|
|
46
|
+
//# sourceMappingURL=ConfigurationError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigurationError.js","sources":["../../src/error/ConfigurationError.ts"],"sourcesContent":["/**\n * Error thrown when configuration validation fails\n */\nexport class ConfigurationError extends Error {\n public readonly errorType: 'validation' | 'schema' | 'extra_keys';\n public readonly details?: any;\n public readonly configPath?: string;\n\n constructor(\n errorType: 'validation' | 'schema' | 'extra_keys',\n message: string,\n details?: any,\n configPath?: string\n ) {\n super(message);\n this.name = 'ConfigurationError';\n this.errorType = errorType;\n this.details = details;\n this.configPath = configPath;\n }\n\n /**\n * Creates a validation error for when config doesn't match the schema\n */\n static validation(message: string, zodError?: any, configPath?: string): ConfigurationError {\n return new ConfigurationError('validation', message, zodError, configPath);\n }\n\n /**\n * Creates an error for when extra/unknown keys are found\n */\n static extraKeys(extraKeys: string[], allowedKeys: string[], configPath?: string): ConfigurationError {\n const message = `Unknown configuration keys found: ${extraKeys.join(', ')}. Allowed keys are: ${allowedKeys.join(', ')}`;\n return new ConfigurationError('extra_keys', message, { extraKeys, allowedKeys }, configPath);\n }\n\n /**\n * Creates a schema error for when the configuration schema itself is invalid\n */\n static schema(message: string, details?: any): ConfigurationError {\n return new ConfigurationError('schema', message, details);\n }\n} "],"names":["ConfigurationError","Error","validation","message","zodError","configPath","extraKeys","allowedKeys","join","schema","details","errorType","name"],"mappings":";;;;;;;;;;;;;AAAA;;IAGO,MAAMA,kBAAAA,SAA2BC,KAAAA,CAAAA;AAkBpC;;AAEC,QACD,OAAOC,UAAAA,CAAWC,OAAe,EAAEC,QAAc,EAAEC,UAAmB,EAAsB;AACxF,QAAA,OAAO,IAAIL,kBAAAA,CAAmB,YAAA,EAAcG,OAAAA,EAASC,QAAAA,EAAUC,UAAAA,CAAAA;AACnE,IAAA;AAEA;;AAEC,QACD,OAAOC,SAAAA,CAAUA,SAAmB,EAAEC,WAAqB,EAAEF,UAAmB,EAAsB;AAClG,QAAA,MAAMF,OAAAA,GAAU,CAAC,kCAAkC,EAAEG,SAAAA,CAAUE,IAAI,CAAC,IAAA,CAAA,CAAM,oBAAoB,EAAED,WAAAA,CAAYC,IAAI,CAAC,IAAA,CAAA,CAAA,CAAO;QACxH,OAAO,IAAIR,kBAAAA,CAAmB,YAAA,EAAcG,OAAAA,EAAS;AAAEG,YAAAA,SAAAA;AAAWC,YAAAA;SAAY,EAAGF,UAAAA,CAAAA;AACrF,IAAA;AAEA;;AAEC,QACD,OAAOI,MAAAA,CAAON,OAAe,EAAEO,OAAa,EAAsB;QAC9D,OAAO,IAAIV,kBAAAA,CAAmB,QAAA,EAAUG,OAAAA,EAASO,OAAAA,CAAAA;AACrD,IAAA;AAjCA,IAAA,WAAA,CACIC,SAAiD,EACjDR,OAAe,EACfO,OAAa,EACbL,UAAmB,CACrB;AACE,QAAA,KAAK,CAACF,OAAAA,CAAAA,EAVV,gBAAA,CAAA,IAAA,EAAgBQ,WAAAA,EAAhB,MAAA,CAAA,EACA,gBAAA,CAAA,IAAA,EAAgBD,SAAAA,EAAhB,MAAA,CAAA,EACA,gBAAA,CAAA,IAAA,EAAgBL,YAAAA,EAAhB,MAAA,CAAA;QASI,IAAI,CAACO,IAAI,GAAG,oBAAA;QACZ,IAAI,CAACD,SAAS,GAAGA,SAAAA;QACjB,IAAI,CAACD,OAAO,GAAGA,OAAAA;QACf,IAAI,CAACL,UAAU,GAAGA,UAAAA;AACtB,IAAA;AAuBJ;;;;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when file system operations fail
|
|
3
|
+
*/
|
|
4
|
+
export declare class FileSystemError extends Error {
|
|
5
|
+
readonly errorType: 'not_found' | 'not_readable' | 'not_writable' | 'creation_failed' | 'operation_failed';
|
|
6
|
+
readonly path: string;
|
|
7
|
+
readonly operation: string;
|
|
8
|
+
readonly originalError?: Error;
|
|
9
|
+
constructor(errorType: 'not_found' | 'not_readable' | 'not_writable' | 'creation_failed' | 'operation_failed', message: string, path: string, operation: string, originalError?: Error);
|
|
10
|
+
/**
|
|
11
|
+
* Creates an error for when a required directory doesn't exist
|
|
12
|
+
*/
|
|
13
|
+
static directoryNotFound(path: string, isRequired?: boolean): FileSystemError;
|
|
14
|
+
/**
|
|
15
|
+
* Creates an error for when a directory exists but isn't readable
|
|
16
|
+
*/
|
|
17
|
+
static directoryNotReadable(path: string): FileSystemError;
|
|
18
|
+
/**
|
|
19
|
+
* Creates an error for directory creation failures
|
|
20
|
+
*/
|
|
21
|
+
static directoryCreationFailed(path: string, originalError: Error): FileSystemError;
|
|
22
|
+
/**
|
|
23
|
+
* Creates an error for file operation failures (glob, etc.)
|
|
24
|
+
*/
|
|
25
|
+
static operationFailed(operation: string, path: string, originalError: Error): FileSystemError;
|
|
26
|
+
/**
|
|
27
|
+
* Creates an error for when a file is not found
|
|
28
|
+
*/
|
|
29
|
+
static fileNotFound(path: string): FileSystemError;
|
|
30
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Error thrown when file system operations fail
|
|
16
|
+
*/ class FileSystemError extends Error {
|
|
17
|
+
/**
|
|
18
|
+
* Creates an error for when a required directory doesn't exist
|
|
19
|
+
*/ static directoryNotFound(path, isRequired = false) {
|
|
20
|
+
const message = isRequired ? 'Configuration directory does not exist and is required' : 'Configuration directory not found';
|
|
21
|
+
return new FileSystemError('not_found', message, path, 'directory_access');
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Creates an error for when a directory exists but isn't readable
|
|
25
|
+
*/ static directoryNotReadable(path) {
|
|
26
|
+
const message = 'Configuration directory exists but is not readable';
|
|
27
|
+
return new FileSystemError('not_readable', message, path, 'directory_read');
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Creates an error for directory creation failures
|
|
31
|
+
*/ static directoryCreationFailed(path, originalError) {
|
|
32
|
+
const message = 'Failed to create directory: ' + (originalError.message || 'Unknown error');
|
|
33
|
+
return new FileSystemError('creation_failed', message, path, 'directory_create', originalError);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates an error for file operation failures (glob, etc.)
|
|
37
|
+
*/ static operationFailed(operation, path, originalError) {
|
|
38
|
+
const message = `Failed to ${operation}: ${originalError.message || 'Unknown error'}`;
|
|
39
|
+
return new FileSystemError('operation_failed', message, path, operation, originalError);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Creates an error for when a file is not found
|
|
43
|
+
*/ static fileNotFound(path) {
|
|
44
|
+
const message = 'Configuration file not found';
|
|
45
|
+
return new FileSystemError('not_found', message, path, 'file_read');
|
|
46
|
+
}
|
|
47
|
+
constructor(errorType, message, path, operation, originalError){
|
|
48
|
+
super(message), _define_property(this, "errorType", void 0), _define_property(this, "path", void 0), _define_property(this, "operation", void 0), _define_property(this, "originalError", void 0);
|
|
49
|
+
this.name = 'FileSystemError';
|
|
50
|
+
this.errorType = errorType;
|
|
51
|
+
this.path = path;
|
|
52
|
+
this.operation = operation;
|
|
53
|
+
this.originalError = originalError;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { FileSystemError };
|
|
58
|
+
//# sourceMappingURL=FileSystemError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileSystemError.js","sources":["../../src/error/FileSystemError.ts"],"sourcesContent":["/**\n * Error thrown when file system operations fail\n */\nexport class FileSystemError extends Error {\n public readonly errorType: 'not_found' | 'not_readable' | 'not_writable' | 'creation_failed' | 'operation_failed';\n public readonly path: string;\n public readonly operation: string;\n public readonly originalError?: Error;\n\n constructor(\n errorType: 'not_found' | 'not_readable' | 'not_writable' | 'creation_failed' | 'operation_failed',\n message: string,\n path: string,\n operation: string,\n originalError?: Error\n ) {\n super(message);\n this.name = 'FileSystemError';\n this.errorType = errorType;\n this.path = path;\n this.operation = operation;\n this.originalError = originalError;\n }\n\n /**\n * Creates an error for when a required directory doesn't exist\n */\n static directoryNotFound(path: string, isRequired: boolean = false): FileSystemError {\n const message = isRequired\n ? 'Configuration directory does not exist and is required'\n : 'Configuration directory not found';\n return new FileSystemError('not_found', message, path, 'directory_access');\n }\n\n /**\n * Creates an error for when a directory exists but isn't readable\n */\n static directoryNotReadable(path: string): FileSystemError {\n const message = 'Configuration directory exists but is not readable';\n return new FileSystemError('not_readable', message, path, 'directory_read');\n }\n\n /**\n * Creates an error for directory creation failures\n */\n static directoryCreationFailed(path: string, originalError: Error): FileSystemError {\n const message = 'Failed to create directory: ' + (originalError.message || 'Unknown error');\n return new FileSystemError('creation_failed', message, path, 'directory_create', originalError);\n }\n\n /**\n * Creates an error for file operation failures (glob, etc.)\n */\n static operationFailed(operation: string, path: string, originalError: Error): FileSystemError {\n const message = `Failed to ${operation}: ${originalError.message || 'Unknown error'}`;\n return new FileSystemError('operation_failed', message, path, operation, originalError);\n }\n\n /**\n * Creates an error for when a file is not found\n */\n static fileNotFound(path: string): FileSystemError {\n const message = 'Configuration file not found';\n return new FileSystemError('not_found', message, path, 'file_read');\n }\n} "],"names":["FileSystemError","Error","directoryNotFound","path","isRequired","message","directoryNotReadable","directoryCreationFailed","originalError","operationFailed","operation","fileNotFound","errorType","name"],"mappings":";;;;;;;;;;;;;AAAA;;IAGO,MAAMA,eAAAA,SAAwBC,KAAAA,CAAAA;AAqBjC;;AAEC,QACD,OAAOC,iBAAAA,CAAkBC,IAAY,EAAEC,UAAAA,GAAsB,KAAK,EAAmB;QACjF,MAAMC,OAAAA,GAAUD,aACV,wDAAA,GACA,mCAAA;AACN,QAAA,OAAO,IAAIJ,eAAAA,CAAgB,WAAA,EAAaK,OAAAA,EAASF,IAAAA,EAAM,kBAAA,CAAA;AAC3D,IAAA;AAEA;;QAGA,OAAOG,oBAAAA,CAAqBH,IAAY,EAAmB;AACvD,QAAA,MAAME,OAAAA,GAAU,oDAAA;AAChB,QAAA,OAAO,IAAIL,eAAAA,CAAgB,cAAA,EAAgBK,OAAAA,EAASF,IAAAA,EAAM,gBAAA,CAAA;AAC9D,IAAA;AAEA;;AAEC,QACD,OAAOI,uBAAAA,CAAwBJ,IAAY,EAAEK,aAAoB,EAAmB;AAChF,QAAA,MAAMH,UAAU,8BAAA,IAAkCG,aAAAA,CAAcH,OAAO,IAAI,eAAc,CAAA;AACzF,QAAA,OAAO,IAAIL,eAAAA,CAAgB,iBAAA,EAAmBK,OAAAA,EAASF,MAAM,kBAAA,EAAoBK,aAAAA,CAAAA;AACrF,IAAA;AAEA;;AAEC,QACD,OAAOC,eAAAA,CAAgBC,SAAiB,EAAEP,IAAY,EAAEK,aAAoB,EAAmB;QAC3F,MAAMH,OAAAA,GAAU,CAAC,UAAU,EAAEK,SAAAA,CAAU,EAAE,EAAEF,aAAAA,CAAcH,OAAO,IAAI,eAAA,CAAA,CAAiB;AACrF,QAAA,OAAO,IAAIL,eAAAA,CAAgB,kBAAA,EAAoBK,OAAAA,EAASF,MAAMO,SAAAA,EAAWF,aAAAA,CAAAA;AAC7E,IAAA;AAEA;;QAGA,OAAOG,YAAAA,CAAaR,IAAY,EAAmB;AAC/C,QAAA,MAAME,OAAAA,GAAU,8BAAA;AAChB,QAAA,OAAO,IAAIL,eAAAA,CAAgB,WAAA,EAAaK,OAAAA,EAASF,IAAAA,EAAM,WAAA,CAAA;AAC3D,IAAA;IAvDA,WAAA,CACIS,SAAiG,EACjGP,OAAe,EACfF,IAAY,EACZO,SAAiB,EACjBF,aAAqB,CACvB;AACE,QAAA,KAAK,CAACH,OAAAA,CAAAA,EAZV,gBAAA,CAAA,IAAA,EAAgBO,WAAAA,EAAhB,SACA,gBAAA,CAAA,IAAA,EAAgBT,MAAAA,EAAhB,MAAA,CAAA,EACA,uBAAgBO,WAAAA,EAAhB,MAAA,CAAA,EACA,gBAAA,CAAA,IAAA,EAAgBF,iBAAhB,MAAA,CAAA;QAUI,IAAI,CAACK,IAAI,GAAG,iBAAA;QACZ,IAAI,CAACD,SAAS,GAAGA,SAAAA;QACjB,IAAI,CAACT,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACO,SAAS,GAAGA,SAAAA;QACjB,IAAI,CAACF,aAAa,GAAGA,aAAAA;AACzB,IAAA;AA2CJ;;;;"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Cardigantime } from '../types';
|
|
2
|
+
import { FileConfigSource } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Options for file-based configuration discovery.
|
|
5
|
+
*/
|
|
6
|
+
export interface FileDiscoveryOptions {
|
|
7
|
+
/**
|
|
8
|
+
* CardiganTime instance to use for discovery.
|
|
9
|
+
* This provides access to the full configuration discovery functionality.
|
|
10
|
+
*/
|
|
11
|
+
cardigantime: Cardigantime<any>;
|
|
12
|
+
/**
|
|
13
|
+
* Arguments to pass to CardiganTime's read function.
|
|
14
|
+
* These typically come from CLI parsing.
|
|
15
|
+
*/
|
|
16
|
+
args?: Record<string, any>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Discovers configuration starting from a target file's location.
|
|
20
|
+
*
|
|
21
|
+
* This implements the "detective work" pattern where the tool looks at
|
|
22
|
+
* the target file's location and walks up the directory tree to find
|
|
23
|
+
* configuration files.
|
|
24
|
+
*
|
|
25
|
+
* @param targetFile - Path to the target file being operated on
|
|
26
|
+
* @param options - Discovery options
|
|
27
|
+
* @returns Promise resolving to FileConfigSource or null if not found
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const config = await discoverFromTargetFile(
|
|
32
|
+
* '/app/src/api/handler.ts',
|
|
33
|
+
* { cardigantime: myCardiganTimeInstance }
|
|
34
|
+
* );
|
|
35
|
+
*
|
|
36
|
+
* if (config) {
|
|
37
|
+
* console.log('Found config at:', config.filePath);
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function discoverFromTargetFile(targetFile: string, options: FileDiscoveryOptions): Promise<FileConfigSource | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Discovers configuration starting from a working directory.
|
|
44
|
+
*
|
|
45
|
+
* This is the fallback when no target file is specified. It starts
|
|
46
|
+
* discovery from the working directory provided by the MCP invocation.
|
|
47
|
+
*
|
|
48
|
+
* @param workingDirectory - Working directory to start discovery from
|
|
49
|
+
* @param options - Discovery options
|
|
50
|
+
* @returns Promise resolving to FileConfigSource or null if not found
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const config = await discoverFromWorkingDirectory(
|
|
55
|
+
* '/app',
|
|
56
|
+
* { cardigantime: myCardiganTimeInstance }
|
|
57
|
+
* );
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function discoverFromWorkingDirectory(workingDirectory: string, options: FileDiscoveryOptions): Promise<FileConfigSource | null>;
|
|
61
|
+
/**
|
|
62
|
+
* Creates a file discovery function for use with the MCP resolver.
|
|
63
|
+
*
|
|
64
|
+
* This is a convenience function that creates a `resolveFileConfig` function
|
|
65
|
+
* compatible with the MCP resolver. It automatically tries target file
|
|
66
|
+
* discovery first, then falls back to working directory discovery.
|
|
67
|
+
*
|
|
68
|
+
* @param options - Discovery options
|
|
69
|
+
* @returns File config resolver function
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* import { createFileDiscovery } from '@utilarium/cardigantime/mcp';
|
|
74
|
+
* import { createMCPIntegration } from '@utilarium/cardigantime/mcp';
|
|
75
|
+
*
|
|
76
|
+
* const fileDiscovery = createFileDiscovery({
|
|
77
|
+
* cardigantime: myCardiganTimeInstance,
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* const integration = createMCPIntegration({
|
|
81
|
+
* appName: 'myapp',
|
|
82
|
+
* configSchema: mySchema,
|
|
83
|
+
* resolveFileConfig: fileDiscovery,
|
|
84
|
+
* });
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export declare function createFileDiscovery(options: FileDiscoveryOptions): (workingDirectory: string, targetFile?: string) => Promise<FileConfigSource | null>;
|
|
88
|
+
/**
|
|
89
|
+
* Logs the configuration discovery process.
|
|
90
|
+
*
|
|
91
|
+
* This is useful for debugging configuration issues. It shows which
|
|
92
|
+
* directories were checked and why a particular config was selected.
|
|
93
|
+
*
|
|
94
|
+
* @param message - Log message
|
|
95
|
+
* @param details - Additional details to log
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* logDiscovery('Checking for config', {
|
|
100
|
+
* directory: '/app/src',
|
|
101
|
+
* found: true,
|
|
102
|
+
* });
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export declare function logDiscovery(message: string, details?: Record<string, any>): void;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ZodError } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Error thrown when MCP configuration is invalid or cannot be parsed.
|
|
4
|
+
*
|
|
5
|
+
* This error is thrown when:
|
|
6
|
+
* - The MCP configuration doesn't match the expected schema
|
|
7
|
+
* - Required fields are missing
|
|
8
|
+
* - Field values are invalid
|
|
9
|
+
*
|
|
10
|
+
* The error includes the original Zod validation error for detailed diagnostics.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* try {
|
|
15
|
+
* await parseMCPConfig(rawConfig, schema);
|
|
16
|
+
* } catch (error) {
|
|
17
|
+
* if (error instanceof MCPConfigError) {
|
|
18
|
+
* console.error('MCP config validation failed:', error.message);
|
|
19
|
+
* if (error.validationError) {
|
|
20
|
+
* console.error('Details:', error.validationError.format());
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class MCPConfigError extends Error {
|
|
27
|
+
readonly validationError?: ZodError | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* The name of the error class.
|
|
30
|
+
* Always set to 'MCPConfigError'.
|
|
31
|
+
*/
|
|
32
|
+
readonly name = "MCPConfigError";
|
|
33
|
+
/**
|
|
34
|
+
* Creates a new MCPConfigError.
|
|
35
|
+
*
|
|
36
|
+
* @param message - Human-readable error message
|
|
37
|
+
* @param validationError - Optional Zod validation error with detailed field-level errors
|
|
38
|
+
*/
|
|
39
|
+
constructor(message: string, validationError?: ZodError | undefined);
|
|
40
|
+
/**
|
|
41
|
+
* Returns a formatted error message including validation details.
|
|
42
|
+
*
|
|
43
|
+
* @returns Formatted error message with validation issues
|
|
44
|
+
*/
|
|
45
|
+
getDetailedMessage(): string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Error thrown when MCP invocation context is missing required information.
|
|
49
|
+
*
|
|
50
|
+
* This error is thrown when:
|
|
51
|
+
* - Neither MCP config nor working directory is provided
|
|
52
|
+
* - Required context fields are missing for the operation
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* if (!context.config && !context.workingDirectory) {
|
|
57
|
+
* throw new MCPContextError(
|
|
58
|
+
* 'MCP invocation must provide either config or workingDirectory'
|
|
59
|
+
* );
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare class MCPContextError extends Error {
|
|
64
|
+
/**
|
|
65
|
+
* The name of the error class.
|
|
66
|
+
* Always set to 'MCPContextError'.
|
|
67
|
+
*/
|
|
68
|
+
readonly name = "MCPContextError";
|
|
69
|
+
/**
|
|
70
|
+
* Creates a new MCPContextError.
|
|
71
|
+
*
|
|
72
|
+
* @param message - Human-readable error message
|
|
73
|
+
*/
|
|
74
|
+
constructor(message: string);
|
|
75
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP (Model Context Protocol) integration module.
|
|
3
|
+
*
|
|
4
|
+
* This module provides types and utilities for integrating CardiganTime
|
|
5
|
+
* with MCP servers, enabling AI assistants to provide configuration
|
|
6
|
+
* to tools at invocation time.
|
|
7
|
+
*
|
|
8
|
+
* @module mcp
|
|
9
|
+
*/
|
|
10
|
+
export type { MCPConfigSource, FileConfigSource, EnvVarConfigSource, ConfigSource, ResolvedConfig, MCPInvocationContext, } from './types';
|
|
11
|
+
export { MCPConfigError, MCPContextError, } from './errors';
|
|
12
|
+
export { parseMCPConfig, expandEnvironmentVariables, resolveConfigPaths, mergeMCPConfigWithDefaults, } from './parser';
|
|
13
|
+
export type { ParseMCPConfigOptions, } from './parser';
|
|
14
|
+
export { resolveConfig, explainResolution, isMCPConfig, isFileConfig, isEnvConfig, getConfigFiles, } from './resolver';
|
|
15
|
+
export type { ConfigResolverOptions, } from './resolver';
|
|
16
|
+
export type { CheckConfigInput, CheckConfigResult, CheckConfigToolDescriptor, ConfigSourceType, ConfigValueSource, } from './tools';
|
|
17
|
+
export { CHECK_CONFIG_TOOL_DESCRIPTOR, SENSITIVE_FIELD_PATTERNS, isSensitiveField, sanitizeValue, checkConfig, sanitizeConfig, createCheckConfigHandler, } from './tools';
|
|
18
|
+
export type { CheckConfigOptions, } from './tools';
|
|
19
|
+
export { createCheckConfigTool, createConfigResolver, withConfig, createMCPIntegration, } from './integration';
|
|
20
|
+
export type { MCPIntegrationOptions, } from './integration';
|
|
21
|
+
export { discoverFromTargetFile, discoverFromWorkingDirectory, createFileDiscovery, logDiscovery, } from './discovery';
|
|
22
|
+
export type { FileDiscoveryOptions, } from './discovery';
|