@eddacraft/anvil-core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +14 -0
- package/dist/antipattern/index.d.ts +11 -0
- package/dist/antipattern/index.d.ts.map +1 -0
- package/dist/antipattern/index.js +31 -0
- package/dist/antipattern/patterns-css.d.ts +17 -0
- package/dist/antipattern/patterns-css.d.ts.map +1 -0
- package/dist/antipattern/patterns-css.js +72 -0
- package/dist/antipattern/patterns-html.d.ts +21 -0
- package/dist/antipattern/patterns-html.d.ts.map +1 -0
- package/dist/antipattern/patterns-html.js +139 -0
- package/dist/antipattern/patterns.d.ts +72 -0
- package/dist/antipattern/patterns.d.ts.map +1 -0
- package/dist/antipattern/patterns.js +301 -0
- package/dist/antipattern/scanner.d.ts +32 -0
- package/dist/antipattern/scanner.d.ts.map +1 -0
- package/dist/antipattern/scanner.js +89 -0
- package/dist/antipattern/types.d.ts +318 -0
- package/dist/antipattern/types.d.ts.map +1 -0
- package/dist/antipattern/types.js +278 -0
- package/dist/architecture/analyzer.d.ts +123 -0
- package/dist/architecture/analyzer.d.ts.map +1 -0
- package/dist/architecture/analyzer.js +321 -0
- package/dist/architecture/baseline.d.ts +112 -0
- package/dist/architecture/baseline.d.ts.map +1 -0
- package/dist/architecture/baseline.js +245 -0
- package/dist/architecture/compiler.d.ts +24 -0
- package/dist/architecture/compiler.d.ts.map +1 -0
- package/dist/architecture/compiler.js +57 -0
- package/dist/architecture/context.d.ts +129 -0
- package/dist/architecture/context.d.ts.map +1 -0
- package/dist/architecture/context.js +116 -0
- package/dist/architecture/dc-generator.d.ts +9 -0
- package/dist/architecture/dc-generator.d.ts.map +1 -0
- package/dist/architecture/dc-generator.js +220 -0
- package/dist/architecture/definition-schema.d.ts +128 -0
- package/dist/architecture/definition-schema.d.ts.map +1 -0
- package/dist/architecture/definition-schema.js +94 -0
- package/dist/architecture/edge-detector-html.d.ts +6 -0
- package/dist/architecture/edge-detector-html.d.ts.map +1 -0
- package/dist/architecture/edge-detector-html.js +5 -0
- package/dist/architecture/edge-detector-web.d.ts +32 -0
- package/dist/architecture/edge-detector-web.d.ts.map +1 -0
- package/dist/architecture/edge-detector-web.js +133 -0
- package/dist/architecture/edge-detector.d.ts +116 -0
- package/dist/architecture/edge-detector.d.ts.map +1 -0
- package/dist/architecture/edge-detector.js +229 -0
- package/dist/architecture/entry-detector.d.ts +44 -0
- package/dist/architecture/entry-detector.d.ts.map +1 -0
- package/dist/architecture/entry-detector.js +263 -0
- package/dist/architecture/index.d.ts +21 -0
- package/dist/architecture/index.d.ts.map +1 -0
- package/dist/architecture/index.js +48 -0
- package/dist/architecture/layer-detector.d.ts +60 -0
- package/dist/architecture/layer-detector.d.ts.map +1 -0
- package/dist/architecture/layer-detector.js +331 -0
- package/dist/architecture/rego-generator.d.ts +25 -0
- package/dist/architecture/rego-generator.d.ts.map +1 -0
- package/dist/architecture/rego-generator.js +229 -0
- package/dist/architecture/templates/index.d.ts +39 -0
- package/dist/architecture/templates/index.d.ts.map +1 -0
- package/dist/architecture/templates/index.js +124 -0
- package/dist/architecture/types.d.ts +280 -0
- package/dist/architecture/types.d.ts.map +1 -0
- package/dist/architecture/types.js +269 -0
- package/dist/architecture/yaml-parser.d.ts +13 -0
- package/dist/architecture/yaml-parser.d.ts.map +1 -0
- package/dist/architecture/yaml-parser.js +234 -0
- package/dist/config/constants.d.ts +9 -0
- package/dist/config/constants.d.ts.map +1 -0
- package/dist/config/constants.js +20 -0
- package/dist/config/index.d.ts +9 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +8 -0
- package/dist/config/loader.d.ts +41 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +76 -0
- package/dist/config/nudge-config.d.ts +35 -0
- package/dist/config/nudge-config.d.ts.map +1 -0
- package/dist/config/nudge-config.js +34 -0
- package/dist/config/types.d.ts +30 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +4 -0
- package/dist/contracts/index.d.ts +14 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +13 -0
- package/dist/contracts/schemas/aps.schema.d.ts +269 -0
- package/dist/contracts/schemas/aps.schema.d.ts.map +1 -0
- package/dist/contracts/schemas/aps.schema.js +183 -0
- package/dist/contracts/schemas/index.d.ts +12 -0
- package/dist/contracts/schemas/index.d.ts.map +1 -0
- package/dist/contracts/schemas/index.js +14 -0
- package/dist/contracts/schemas/json-schema.d.ts +14 -0
- package/dist/contracts/schemas/json-schema.d.ts.map +1 -0
- package/dist/contracts/schemas/json-schema.js +31 -0
- package/dist/contracts/schemas/warning.schema.d.ts +171 -0
- package/dist/contracts/schemas/warning.schema.d.ts.map +1 -0
- package/dist/contracts/schemas/warning.schema.js +123 -0
- package/dist/contracts/types/gate.types.d.ts +194 -0
- package/dist/contracts/types/gate.types.d.ts.map +1 -0
- package/dist/contracts/types/gate.types.js +19 -0
- package/dist/contracts/types/index.d.ts +9 -0
- package/dist/contracts/types/index.d.ts.map +1 -0
- package/dist/contracts/types/index.js +8 -0
- package/dist/crypto/hash.d.ts +47 -0
- package/dist/crypto/hash.d.ts.map +1 -0
- package/dist/crypto/hash.js +110 -0
- package/dist/crypto/index.d.ts +7 -0
- package/dist/crypto/index.d.ts.map +1 -0
- package/dist/crypto/index.js +6 -0
- package/dist/drift/index.d.ts +6 -0
- package/dist/drift/index.d.ts.map +1 -0
- package/dist/drift/index.js +5 -0
- package/dist/drift/report-generator.d.ts +21 -0
- package/dist/drift/report-generator.d.ts.map +1 -0
- package/dist/drift/report-generator.js +240 -0
- package/dist/drift/snapshot-capture.d.ts +26 -0
- package/dist/drift/snapshot-capture.d.ts.map +1 -0
- package/dist/drift/snapshot-capture.js +195 -0
- package/dist/drift/snapshot-compare.d.ts +50 -0
- package/dist/drift/snapshot-compare.d.ts.map +1 -0
- package/dist/drift/snapshot-compare.js +142 -0
- package/dist/drift/snapshot-schema.d.ts +197 -0
- package/dist/drift/snapshot-schema.d.ts.map +1 -0
- package/dist/drift/snapshot-schema.js +193 -0
- package/dist/drift/snapshot-storage.d.ts +25 -0
- package/dist/drift/snapshot-storage.d.ts.map +1 -0
- package/dist/drift/snapshot-storage.js +179 -0
- package/dist/explain/antipattern-explainer.d.ts +4 -0
- package/dist/explain/antipattern-explainer.d.ts.map +1 -0
- package/dist/explain/antipattern-explainer.js +196 -0
- package/dist/explain/boundary-explainer.d.ts +5 -0
- package/dist/explain/boundary-explainer.d.ts.map +1 -0
- package/dist/explain/boundary-explainer.js +261 -0
- package/dist/explain/explain-service.d.ts +19 -0
- package/dist/explain/explain-service.d.ts.map +1 -0
- package/dist/explain/explain-service.js +106 -0
- package/dist/explain/index.d.ts +7 -0
- package/dist/explain/index.d.ts.map +1 -0
- package/dist/explain/index.js +5 -0
- package/dist/explain/template-loader.d.ts +9 -0
- package/dist/explain/template-loader.d.ts.map +1 -0
- package/dist/explain/template-loader.js +51 -0
- package/dist/explain/types.d.ts +46 -0
- package/dist/explain/types.d.ts.map +1 -0
- package/dist/explain/types.js +31 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/provenance/collector.d.ts +86 -0
- package/dist/provenance/collector.d.ts.map +1 -0
- package/dist/provenance/collector.js +425 -0
- package/dist/provenance/git-ai-standard/git-notes.d.ts +85 -0
- package/dist/provenance/git-ai-standard/git-notes.d.ts.map +1 -0
- package/dist/provenance/git-ai-standard/git-notes.js +292 -0
- package/dist/provenance/git-ai-standard/index.d.ts +44 -0
- package/dist/provenance/git-ai-standard/index.d.ts.map +1 -0
- package/dist/provenance/git-ai-standard/index.js +47 -0
- package/dist/provenance/git-ai-standard/serializer.d.ts +54 -0
- package/dist/provenance/git-ai-standard/serializer.d.ts.map +1 -0
- package/dist/provenance/git-ai-standard/serializer.js +224 -0
- package/dist/provenance/git-ai-standard/session.d.ts +51 -0
- package/dist/provenance/git-ai-standard/session.d.ts.map +1 -0
- package/dist/provenance/git-ai-standard/session.js +118 -0
- package/dist/provenance/git-ai-standard/types.d.ts +173 -0
- package/dist/provenance/git-ai-standard/types.d.ts.map +1 -0
- package/dist/provenance/git-ai-standard/types.js +109 -0
- package/dist/provenance/index.d.ts +5 -0
- package/dist/provenance/index.d.ts.map +1 -0
- package/dist/provenance/index.js +6 -0
- package/dist/provenance/store.d.ts +83 -0
- package/dist/provenance/store.d.ts.map +1 -0
- package/dist/provenance/store.js +248 -0
- package/dist/provenance/types.d.ts +160 -0
- package/dist/provenance/types.d.ts.map +1 -0
- package/dist/provenance/types.js +112 -0
- package/dist/suppression/index.d.ts +4 -0
- package/dist/suppression/index.d.ts.map +1 -0
- package/dist/suppression/index.js +3 -0
- package/dist/suppression/parser.d.ts +31 -0
- package/dist/suppression/parser.d.ts.map +1 -0
- package/dist/suppression/parser.js +219 -0
- package/dist/suppression/service.d.ts +29 -0
- package/dist/suppression/service.d.ts.map +1 -0
- package/dist/suppression/service.js +132 -0
- package/dist/suppression/store.d.ts +61 -0
- package/dist/suppression/store.d.ts.map +1 -0
- package/dist/suppression/store.js +169 -0
- package/dist/utils/debug.d.ts +48 -0
- package/dist/utils/debug.d.ts.map +1 -0
- package/dist/utils/debug.js +100 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/path-safety.d.ts +21 -0
- package/dist/utils/path-safety.d.ts.map +1 -0
- package/dist/utils/path-safety.js +49 -0
- package/dist/utils/severity.d.ts +37 -0
- package/dist/utils/severity.d.ts.map +1 -0
- package/dist/utils/severity.js +22 -0
- package/dist/validation/aps-validator.d.ts +66 -0
- package/dist/validation/aps-validator.d.ts.map +1 -0
- package/dist/validation/aps-validator.js +173 -0
- package/dist/validation/errors.d.ts +52 -0
- package/dist/validation/errors.d.ts.map +1 -0
- package/dist/validation/errors.js +115 -0
- package/dist/validation/index.d.ts +8 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +13 -0
- package/dist/warnings/index.d.ts +2 -0
- package/dist/warnings/index.d.ts.map +1 -0
- package/dist/warnings/index.js +1 -0
- package/dist/warnings/warning-id.d.ts +180 -0
- package/dist/warnings/warning-id.d.ts.map +1 -0
- package/dist/warnings/warning-id.js +257 -0
- package/package.json +79 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration Loader
|
|
3
|
+
*
|
|
4
|
+
* Loads configuration from files and environment variables.
|
|
5
|
+
* This is a placeholder - actual implementation will be enhanced.
|
|
6
|
+
*/
|
|
7
|
+
import { createDebugger } from '../utils/debug.js';
|
|
8
|
+
const debug = createDebugger('config');
|
|
9
|
+
/**
|
|
10
|
+
* Configuration loader class
|
|
11
|
+
*/
|
|
12
|
+
export class ConfigLoader {
|
|
13
|
+
_options;
|
|
14
|
+
config = new Map();
|
|
15
|
+
constructor(options = {}) {
|
|
16
|
+
this._options = {
|
|
17
|
+
baseDir: options.baseDir ?? process.cwd(),
|
|
18
|
+
envPrefix: options.envPrefix ?? 'ANVIL_',
|
|
19
|
+
fileNames: options.fileNames ?? [
|
|
20
|
+
'.anvilrc',
|
|
21
|
+
'.anvilrc.yaml',
|
|
22
|
+
'.anvilrc.json',
|
|
23
|
+
'anvil.config.js',
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
debug('ConfigLoader created', {
|
|
27
|
+
baseDir: this._options.baseDir,
|
|
28
|
+
envPrefix: this._options.envPrefix,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
get options() {
|
|
32
|
+
return this._options;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get a configuration value
|
|
36
|
+
*/
|
|
37
|
+
get(key) {
|
|
38
|
+
const entry = this.config.get(key);
|
|
39
|
+
return entry?.value;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get a configuration value with a default
|
|
43
|
+
*/
|
|
44
|
+
getOrDefault(key, defaultValue) {
|
|
45
|
+
return this.get(key) ?? defaultValue;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Check if a configuration key exists
|
|
49
|
+
*/
|
|
50
|
+
has(key) {
|
|
51
|
+
return this.config.has(key);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Set a configuration value
|
|
55
|
+
*/
|
|
56
|
+
set(key, value, source = 'default') {
|
|
57
|
+
debug('config set', { key, source });
|
|
58
|
+
this.config.set(key, { value, source });
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get all configuration values
|
|
62
|
+
*/
|
|
63
|
+
getAll() {
|
|
64
|
+
const result = {};
|
|
65
|
+
for (const [key, entry] of this.config) {
|
|
66
|
+
result[key] = entry.value;
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Create a configuration loader
|
|
73
|
+
*/
|
|
74
|
+
export function createConfigLoader(options) {
|
|
75
|
+
return new ConfigLoader(options);
|
|
76
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nudge configuration
|
|
3
|
+
*
|
|
4
|
+
* Controls coaching nudge behaviour across CLI, MCP, and IDE surfaces.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Severity threshold for nudge display.
|
|
8
|
+
* Only warnings at or above this severity will show nudges.
|
|
9
|
+
* Ordered: error > warning > info
|
|
10
|
+
*/
|
|
11
|
+
export type NudgeSeverityThreshold = 'error' | 'warning' | 'info';
|
|
12
|
+
/**
|
|
13
|
+
* Nudge configuration options
|
|
14
|
+
*/
|
|
15
|
+
export interface NudgeConfig {
|
|
16
|
+
/** Whether nudges are enabled (default: true) */
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
/** Whether interactive mode is on by default in CLI (default: false) */
|
|
19
|
+
interactive: boolean;
|
|
20
|
+
/** Minimum severity to show nudges for (default: 'warning') */
|
|
21
|
+
severityThreshold: NudgeSeverityThreshold;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Default nudge configuration
|
|
25
|
+
*/
|
|
26
|
+
export declare const DEFAULT_NUDGE_CONFIG: Readonly<NudgeConfig>;
|
|
27
|
+
/**
|
|
28
|
+
* Check whether a warning severity meets the nudge threshold.
|
|
29
|
+
*
|
|
30
|
+
* @param warningSeverity - The severity of the warning
|
|
31
|
+
* @param threshold - The minimum severity threshold
|
|
32
|
+
* @returns true if the warning severity is at or above the threshold
|
|
33
|
+
*/
|
|
34
|
+
export declare function meetsNudgeThreshold(warningSeverity: string, threshold: NudgeSeverityThreshold): boolean;
|
|
35
|
+
//# sourceMappingURL=nudge-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nudge-config.d.ts","sourceRoot":"","sources":["../../src/config/nudge-config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,iDAAiD;IACjD,OAAO,EAAE,OAAO,CAAC;IACjB,wEAAwE;IACxE,WAAW,EAAE,OAAO,CAAC;IACrB,+DAA+D;IAC/D,iBAAiB,EAAE,sBAAsB,CAAC;CAC3C;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAItD,CAAC;AAYF;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,sBAAsB,GAChC,OAAO,CAIT"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nudge configuration
|
|
3
|
+
*
|
|
4
|
+
* Controls coaching nudge behaviour across CLI, MCP, and IDE surfaces.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Default nudge configuration
|
|
8
|
+
*/
|
|
9
|
+
export const DEFAULT_NUDGE_CONFIG = {
|
|
10
|
+
enabled: true,
|
|
11
|
+
interactive: false,
|
|
12
|
+
severityThreshold: 'warning',
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Severity ordering for threshold comparison.
|
|
16
|
+
* Higher number = higher severity.
|
|
17
|
+
*/
|
|
18
|
+
const SEVERITY_ORDER = {
|
|
19
|
+
info: 0,
|
|
20
|
+
warning: 1,
|
|
21
|
+
error: 2,
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Check whether a warning severity meets the nudge threshold.
|
|
25
|
+
*
|
|
26
|
+
* @param warningSeverity - The severity of the warning
|
|
27
|
+
* @param threshold - The minimum severity threshold
|
|
28
|
+
* @returns true if the warning severity is at or above the threshold
|
|
29
|
+
*/
|
|
30
|
+
export function meetsNudgeThreshold(warningSeverity, threshold) {
|
|
31
|
+
const warningLevel = SEVERITY_ORDER[warningSeverity] ?? -1;
|
|
32
|
+
const thresholdLevel = SEVERITY_ORDER[threshold];
|
|
33
|
+
return warningLevel >= thresholdLevel;
|
|
34
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration types
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Configuration source type
|
|
6
|
+
*/
|
|
7
|
+
export type ConfigSource = 'file' | 'env' | 'default';
|
|
8
|
+
/**
|
|
9
|
+
* Configuration entry with metadata
|
|
10
|
+
*/
|
|
11
|
+
export interface ConfigEntry<T = unknown> {
|
|
12
|
+
/** The configuration value */
|
|
13
|
+
value: T;
|
|
14
|
+
/** Where the value came from */
|
|
15
|
+
source: ConfigSource;
|
|
16
|
+
/** Path to the configuration file (if file source) */
|
|
17
|
+
filePath?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Configuration loader options
|
|
21
|
+
*/
|
|
22
|
+
export interface ConfigLoaderOptions {
|
|
23
|
+
/** Base directory for configuration files */
|
|
24
|
+
baseDir?: string;
|
|
25
|
+
/** Environment variable prefix */
|
|
26
|
+
envPrefix?: string;
|
|
27
|
+
/** Configuration file names to search for */
|
|
28
|
+
fileNames?: string[];
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,KAAK,GAAG,SAAS,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,OAAO;IACtC,8BAA8B;IAC9B,KAAK,EAAE,CAAC,CAAC;IACT,gCAAgC;IAChC,MAAM,EAAE,YAAY,CAAC;IACrB,sDAAsD;IACtD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contracts — schemas, types, and events.
|
|
3
|
+
* Formerly @eddacraft/anvil-contracts, now co-located inside @eddacraft/anvil-core.
|
|
4
|
+
*
|
|
5
|
+
* Warning-related types (Warning, WarningResult, Location, etc.) are NOT
|
|
6
|
+
* re-exported here because they are already provided by the antipattern module
|
|
7
|
+
* with additional scanner-specific extensions.
|
|
8
|
+
*/
|
|
9
|
+
export { APSPlanSchema, APS_SCHEMA_VERSION, ChangeTypeSchema, ChangeSchema, ProvenanceSchema, ValidationSchema, EvidenceEntrySchema, EvidenceSchema, ApprovalSchema, ExecutionResultSchema, validatePlan, createPlan, } from './schemas/aps.schema.js';
|
|
10
|
+
export type { APSPlan, Change, ChangeType, Provenance, Validation, EvidenceEntry, Evidence, Approval, ExecutionResult, SchemaValidationResult, } from './schemas/aps.schema.js';
|
|
11
|
+
export { generateJSONSchema } from './schemas/json-schema.js';
|
|
12
|
+
export type { GateConfig, GateCheck, GateResult, GateResultDetails, GateRunResult, CheckContext, PlanData, WatchConfig, PolicyConfig, PolicyBundleConfig, PolicyVerificationConfig, SignatureAlgorithm, StackConfig, StackLayerConfig, StackValidationConfig, ArchitectureContextBase, NormaliseFilesOptions, } from './types/gate.types.js';
|
|
13
|
+
export { getWarningsFromResult, hasBlockingWarnings } from './types/gate.types.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,qBAAqB,EACrB,YAAY,EACZ,UAAU,GACX,MAAM,yBAAyB,CAAC;AAEjC,YAAY,EACV,OAAO,EACP,MAAM,EACN,UAAU,EACV,UAAU,EACV,UAAU,EACV,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAG9D,YAAY,EACV,UAAU,EACV,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contracts — schemas, types, and events.
|
|
3
|
+
* Formerly @eddacraft/anvil-contracts, now co-located inside @eddacraft/anvil-core.
|
|
4
|
+
*
|
|
5
|
+
* Warning-related types (Warning, WarningResult, Location, etc.) are NOT
|
|
6
|
+
* re-exported here because they are already provided by the antipattern module
|
|
7
|
+
* with additional scanner-specific extensions.
|
|
8
|
+
*/
|
|
9
|
+
// APS schemas & helpers
|
|
10
|
+
export { APSPlanSchema, APS_SCHEMA_VERSION, ChangeTypeSchema, ChangeSchema, ProvenanceSchema, ValidationSchema, EvidenceEntrySchema, EvidenceSchema, ApprovalSchema, ExecutionResultSchema, validatePlan, createPlan, } from './schemas/aps.schema.js';
|
|
11
|
+
// JSON Schema generation
|
|
12
|
+
export { generateJSONSchema } from './schemas/json-schema.js';
|
|
13
|
+
export { getWarningsFromResult, hasBlockingWarnings } from './types/gate.types.js';
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Change type enumeration for proposed changes
|
|
4
|
+
*/
|
|
5
|
+
export declare const ChangeTypeSchema: z.ZodEnum<{
|
|
6
|
+
file_create: "file_create";
|
|
7
|
+
file_update: "file_update";
|
|
8
|
+
file_delete: "file_delete";
|
|
9
|
+
config_update: "config_update";
|
|
10
|
+
dependency_add: "dependency_add";
|
|
11
|
+
dependency_remove: "dependency_remove";
|
|
12
|
+
dependency_update: "dependency_update";
|
|
13
|
+
script_execute: "script_execute";
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Individual change object schema
|
|
17
|
+
*/
|
|
18
|
+
export declare const ChangeSchema: z.ZodObject<{
|
|
19
|
+
type: z.ZodEnum<{
|
|
20
|
+
file_create: "file_create";
|
|
21
|
+
file_update: "file_update";
|
|
22
|
+
file_delete: "file_delete";
|
|
23
|
+
config_update: "config_update";
|
|
24
|
+
dependency_add: "dependency_add";
|
|
25
|
+
dependency_remove: "dependency_remove";
|
|
26
|
+
dependency_update: "dependency_update";
|
|
27
|
+
script_execute: "script_execute";
|
|
28
|
+
}>;
|
|
29
|
+
path: z.ZodString;
|
|
30
|
+
description: z.ZodString;
|
|
31
|
+
content: z.ZodOptional<z.ZodString>;
|
|
32
|
+
diff: z.ZodOptional<z.ZodString>;
|
|
33
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
/**
|
|
36
|
+
* Provenance information for audit trail
|
|
37
|
+
*/
|
|
38
|
+
export declare const ProvenanceSchema: z.ZodObject<{
|
|
39
|
+
timestamp: z.ZodString;
|
|
40
|
+
author: z.ZodOptional<z.ZodString>;
|
|
41
|
+
source: z.ZodEnum<{
|
|
42
|
+
cli: "cli";
|
|
43
|
+
api: "api";
|
|
44
|
+
automation: "automation";
|
|
45
|
+
manual: "manual";
|
|
46
|
+
}>;
|
|
47
|
+
version: z.ZodString;
|
|
48
|
+
repository: z.ZodOptional<z.ZodString>;
|
|
49
|
+
branch: z.ZodOptional<z.ZodString>;
|
|
50
|
+
commit: z.ZodOptional<z.ZodString>;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
/**
|
|
53
|
+
* Validation requirements and checks
|
|
54
|
+
*/
|
|
55
|
+
export declare const ValidationSchema: z.ZodObject<{
|
|
56
|
+
required_checks: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
57
|
+
policy_version: z.ZodOptional<z.ZodString>;
|
|
58
|
+
skip_checks: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
59
|
+
custom_rules: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
/**
|
|
62
|
+
* Evidence entry for gate results
|
|
63
|
+
*/
|
|
64
|
+
export declare const EvidenceEntrySchema: z.ZodObject<{
|
|
65
|
+
check: z.ZodString;
|
|
66
|
+
status: z.ZodEnum<{
|
|
67
|
+
passed: "passed";
|
|
68
|
+
failed: "failed";
|
|
69
|
+
skipped: "skipped";
|
|
70
|
+
warning: "warning";
|
|
71
|
+
}>;
|
|
72
|
+
timestamp: z.ZodString;
|
|
73
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
74
|
+
message: z.ZodOptional<z.ZodString>;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
/**
|
|
77
|
+
* Evidence bundle containing all gate results
|
|
78
|
+
*/
|
|
79
|
+
export declare const EvidenceSchema: z.ZodObject<{
|
|
80
|
+
gate_version: z.ZodString;
|
|
81
|
+
timestamp: z.ZodString;
|
|
82
|
+
overall_status: z.ZodEnum<{
|
|
83
|
+
passed: "passed";
|
|
84
|
+
failed: "failed";
|
|
85
|
+
partial: "partial";
|
|
86
|
+
}>;
|
|
87
|
+
checks: z.ZodArray<z.ZodObject<{
|
|
88
|
+
check: z.ZodString;
|
|
89
|
+
status: z.ZodEnum<{
|
|
90
|
+
passed: "passed";
|
|
91
|
+
failed: "failed";
|
|
92
|
+
skipped: "skipped";
|
|
93
|
+
warning: "warning";
|
|
94
|
+
}>;
|
|
95
|
+
timestamp: z.ZodString;
|
|
96
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
97
|
+
message: z.ZodOptional<z.ZodString>;
|
|
98
|
+
}, z.core.$strip>>;
|
|
99
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
100
|
+
artifacts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
101
|
+
}, z.core.$strip>;
|
|
102
|
+
/**
|
|
103
|
+
* Approval information
|
|
104
|
+
*/
|
|
105
|
+
export declare const ApprovalSchema: z.ZodObject<{
|
|
106
|
+
approved: z.ZodBoolean;
|
|
107
|
+
approved_by: z.ZodOptional<z.ZodString>;
|
|
108
|
+
approved_at: z.ZodOptional<z.ZodString>;
|
|
109
|
+
approval_notes: z.ZodOptional<z.ZodString>;
|
|
110
|
+
}, z.core.$strip>;
|
|
111
|
+
/**
|
|
112
|
+
* Execution result for apply/rollback operations
|
|
113
|
+
*/
|
|
114
|
+
export declare const ExecutionResultSchema: z.ZodObject<{
|
|
115
|
+
operation: z.ZodEnum<{
|
|
116
|
+
apply: "apply";
|
|
117
|
+
rollback: "rollback";
|
|
118
|
+
"dry-run": "dry-run";
|
|
119
|
+
}>;
|
|
120
|
+
status: z.ZodEnum<{
|
|
121
|
+
success: "success";
|
|
122
|
+
failed: "failed";
|
|
123
|
+
partial: "partial";
|
|
124
|
+
}>;
|
|
125
|
+
timestamp: z.ZodString;
|
|
126
|
+
executed_by: z.ZodOptional<z.ZodString>;
|
|
127
|
+
changes_applied: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
128
|
+
changes_failed: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
129
|
+
rollback_point: z.ZodOptional<z.ZodString>;
|
|
130
|
+
logs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
131
|
+
}, z.core.$strip>;
|
|
132
|
+
/**
|
|
133
|
+
* Main APS Plan Schema with branding for type safety
|
|
134
|
+
*/
|
|
135
|
+
export declare const APSPlanSchema: z.ZodObject<{
|
|
136
|
+
id: z.ZodString;
|
|
137
|
+
hash: z.ZodString;
|
|
138
|
+
intent: z.ZodString;
|
|
139
|
+
schema_version: z.ZodLiteral<"0.1.0">;
|
|
140
|
+
proposed_changes: z.ZodArray<z.ZodObject<{
|
|
141
|
+
type: z.ZodEnum<{
|
|
142
|
+
file_create: "file_create";
|
|
143
|
+
file_update: "file_update";
|
|
144
|
+
file_delete: "file_delete";
|
|
145
|
+
config_update: "config_update";
|
|
146
|
+
dependency_add: "dependency_add";
|
|
147
|
+
dependency_remove: "dependency_remove";
|
|
148
|
+
dependency_update: "dependency_update";
|
|
149
|
+
script_execute: "script_execute";
|
|
150
|
+
}>;
|
|
151
|
+
path: z.ZodString;
|
|
152
|
+
description: z.ZodString;
|
|
153
|
+
content: z.ZodOptional<z.ZodString>;
|
|
154
|
+
diff: z.ZodOptional<z.ZodString>;
|
|
155
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
156
|
+
}, z.core.$strip>>;
|
|
157
|
+
provenance: z.ZodObject<{
|
|
158
|
+
timestamp: z.ZodString;
|
|
159
|
+
author: z.ZodOptional<z.ZodString>;
|
|
160
|
+
source: z.ZodEnum<{
|
|
161
|
+
cli: "cli";
|
|
162
|
+
api: "api";
|
|
163
|
+
automation: "automation";
|
|
164
|
+
manual: "manual";
|
|
165
|
+
}>;
|
|
166
|
+
version: z.ZodString;
|
|
167
|
+
repository: z.ZodOptional<z.ZodString>;
|
|
168
|
+
branch: z.ZodOptional<z.ZodString>;
|
|
169
|
+
commit: z.ZodOptional<z.ZodString>;
|
|
170
|
+
}, z.core.$strip>;
|
|
171
|
+
validations: z.ZodObject<{
|
|
172
|
+
required_checks: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
173
|
+
policy_version: z.ZodOptional<z.ZodString>;
|
|
174
|
+
skip_checks: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
175
|
+
custom_rules: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
176
|
+
}, z.core.$strip>;
|
|
177
|
+
evidence: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
178
|
+
gate_version: z.ZodString;
|
|
179
|
+
timestamp: z.ZodString;
|
|
180
|
+
overall_status: z.ZodEnum<{
|
|
181
|
+
passed: "passed";
|
|
182
|
+
failed: "failed";
|
|
183
|
+
partial: "partial";
|
|
184
|
+
}>;
|
|
185
|
+
checks: z.ZodArray<z.ZodObject<{
|
|
186
|
+
check: z.ZodString;
|
|
187
|
+
status: z.ZodEnum<{
|
|
188
|
+
passed: "passed";
|
|
189
|
+
failed: "failed";
|
|
190
|
+
skipped: "skipped";
|
|
191
|
+
warning: "warning";
|
|
192
|
+
}>;
|
|
193
|
+
timestamp: z.ZodString;
|
|
194
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
195
|
+
message: z.ZodOptional<z.ZodString>;
|
|
196
|
+
}, z.core.$strip>>;
|
|
197
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
198
|
+
artifacts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
199
|
+
}, z.core.$strip>>>;
|
|
200
|
+
approval: z.ZodOptional<z.ZodObject<{
|
|
201
|
+
approved: z.ZodBoolean;
|
|
202
|
+
approved_by: z.ZodOptional<z.ZodString>;
|
|
203
|
+
approved_at: z.ZodOptional<z.ZodString>;
|
|
204
|
+
approval_notes: z.ZodOptional<z.ZodString>;
|
|
205
|
+
}, z.core.$strip>>;
|
|
206
|
+
executions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
207
|
+
operation: z.ZodEnum<{
|
|
208
|
+
apply: "apply";
|
|
209
|
+
rollback: "rollback";
|
|
210
|
+
"dry-run": "dry-run";
|
|
211
|
+
}>;
|
|
212
|
+
status: z.ZodEnum<{
|
|
213
|
+
success: "success";
|
|
214
|
+
failed: "failed";
|
|
215
|
+
partial: "partial";
|
|
216
|
+
}>;
|
|
217
|
+
timestamp: z.ZodString;
|
|
218
|
+
executed_by: z.ZodOptional<z.ZodString>;
|
|
219
|
+
changes_applied: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
220
|
+
changes_failed: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
221
|
+
rollback_point: z.ZodOptional<z.ZodString>;
|
|
222
|
+
logs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
223
|
+
}, z.core.$strip>>>;
|
|
224
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
225
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
226
|
+
}, z.core.$strict>;
|
|
227
|
+
/**
|
|
228
|
+
* Type exports - automatically inferred from Zod schemas
|
|
229
|
+
*/
|
|
230
|
+
export type ChangeType = z.infer<typeof ChangeTypeSchema>;
|
|
231
|
+
export type Change = z.infer<typeof ChangeSchema>;
|
|
232
|
+
export type Provenance = z.infer<typeof ProvenanceSchema>;
|
|
233
|
+
export type Validation = z.infer<typeof ValidationSchema>;
|
|
234
|
+
export type EvidenceEntry = z.infer<typeof EvidenceEntrySchema>;
|
|
235
|
+
export type Evidence = z.infer<typeof EvidenceSchema>;
|
|
236
|
+
export type Approval = z.infer<typeof ApprovalSchema>;
|
|
237
|
+
export type ExecutionResult = z.infer<typeof ExecutionResultSchema>;
|
|
238
|
+
export type APSPlan = z.infer<typeof APSPlanSchema>;
|
|
239
|
+
/**
|
|
240
|
+
* Validation result type for consistent error handling
|
|
241
|
+
*/
|
|
242
|
+
export interface SchemaValidationResult {
|
|
243
|
+
success: boolean;
|
|
244
|
+
data?: APSPlan;
|
|
245
|
+
errors?: Array<{
|
|
246
|
+
path: string;
|
|
247
|
+
message: string;
|
|
248
|
+
code?: string;
|
|
249
|
+
}>;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Parse and validate a plan with user-friendly error formatting
|
|
253
|
+
*/
|
|
254
|
+
export declare function validatePlan(data: unknown): SchemaValidationResult;
|
|
255
|
+
/**
|
|
256
|
+
* Create a new plan with defaults
|
|
257
|
+
*/
|
|
258
|
+
export declare function createPlan(params: {
|
|
259
|
+
id: string;
|
|
260
|
+
intent: string;
|
|
261
|
+
provenance: Provenance;
|
|
262
|
+
changes?: Change[];
|
|
263
|
+
validations?: Validation;
|
|
264
|
+
}): Omit<APSPlan, 'hash'>;
|
|
265
|
+
/**
|
|
266
|
+
* Schema version for external reference
|
|
267
|
+
*/
|
|
268
|
+
export declare const APS_SCHEMA_VERSION: "0.1.0";
|
|
269
|
+
//# sourceMappingURL=aps.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aps.schema.d.ts","sourceRoot":"","sources":["../../../src/contracts/schemas/aps.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;EAS3B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;iBAUvB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;iBAQ3B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;iBAK3B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;iBAM9B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;iBAUzB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;iBAKzB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;iBAShC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA4Cf,CAAC;AAGZ;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAClD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AACtD,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AACtD,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;CACJ;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,sBAAsB,CAqBlE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,CAAC,EAAE,UAAU,CAAC;CAC1B,GAAG,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAYxB;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,SAAiB,CAAC"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Schema version - using literal type for strict versioning
|
|
4
|
+
*/
|
|
5
|
+
const SCHEMA_VERSION = '0.1.0';
|
|
6
|
+
/**
|
|
7
|
+
* Change type enumeration for proposed changes
|
|
8
|
+
*/
|
|
9
|
+
export const ChangeTypeSchema = z.enum([
|
|
10
|
+
'file_create',
|
|
11
|
+
'file_update',
|
|
12
|
+
'file_delete',
|
|
13
|
+
'config_update',
|
|
14
|
+
'dependency_add',
|
|
15
|
+
'dependency_remove',
|
|
16
|
+
'dependency_update',
|
|
17
|
+
'script_execute',
|
|
18
|
+
]);
|
|
19
|
+
/**
|
|
20
|
+
* Individual change object schema
|
|
21
|
+
*/
|
|
22
|
+
export const ChangeSchema = z.object({
|
|
23
|
+
type: ChangeTypeSchema,
|
|
24
|
+
path: z.string().describe('File or resource path affected by the change'),
|
|
25
|
+
description: z.string().describe('Human-readable description of the change'),
|
|
26
|
+
content: z.string().optional().describe('New content for file changes'),
|
|
27
|
+
diff: z.string().optional().describe('Unified diff for updates'),
|
|
28
|
+
metadata: z
|
|
29
|
+
.record(z.string(), z.unknown())
|
|
30
|
+
.optional()
|
|
31
|
+
.describe('Additional change-specific metadata'),
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* Provenance information for audit trail
|
|
35
|
+
*/
|
|
36
|
+
export const ProvenanceSchema = z.object({
|
|
37
|
+
timestamp: z.string().datetime().describe('ISO 8601 timestamp of plan creation'),
|
|
38
|
+
author: z.string().optional().describe('User or system that created the plan'),
|
|
39
|
+
source: z.enum(['cli', 'api', 'automation', 'manual']).describe('Origin of the plan'),
|
|
40
|
+
version: z.string().describe('Version of the tool that created the plan'),
|
|
41
|
+
repository: z.string().optional().describe('Repository URL or identifier'),
|
|
42
|
+
branch: z.string().optional().describe('Git branch name'),
|
|
43
|
+
commit: z.string().optional().describe('Git commit hash'),
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* Validation requirements and checks
|
|
47
|
+
*/
|
|
48
|
+
export const ValidationSchema = z.object({
|
|
49
|
+
required_checks: z.array(z.string()).default([]).describe('List of required validation checks'),
|
|
50
|
+
policy_version: z.string().optional().describe('Version of the policy bundle to use'),
|
|
51
|
+
skip_checks: z.array(z.string()).default([]).describe('Checks to skip for this plan'),
|
|
52
|
+
custom_rules: z.record(z.string(), z.unknown()).optional().describe('Custom validation rules'),
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Evidence entry for gate results
|
|
56
|
+
*/
|
|
57
|
+
export const EvidenceEntrySchema = z.object({
|
|
58
|
+
check: z.string().describe('Name of the check performed'),
|
|
59
|
+
status: z.enum(['passed', 'failed', 'skipped', 'warning']).describe('Result status'),
|
|
60
|
+
timestamp: z.string().datetime().describe('When the check was performed'),
|
|
61
|
+
details: z.record(z.string(), z.unknown()).optional().describe('Detailed check results'),
|
|
62
|
+
message: z.string().optional().describe('Human-readable result message'),
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
* Evidence bundle containing all gate results
|
|
66
|
+
*/
|
|
67
|
+
export const EvidenceSchema = z.object({
|
|
68
|
+
gate_version: z.string().describe('Version of the gate that ran'),
|
|
69
|
+
timestamp: z.string().datetime().describe('When the gate was executed'),
|
|
70
|
+
overall_status: z.enum(['passed', 'failed', 'partial']).describe('Overall gate result'),
|
|
71
|
+
checks: z.array(EvidenceEntrySchema).describe('Individual check results'),
|
|
72
|
+
summary: z.string().optional().describe('Summary of gate execution'),
|
|
73
|
+
artifacts: z
|
|
74
|
+
.record(z.string(), z.string())
|
|
75
|
+
.optional()
|
|
76
|
+
.describe('Links or references to artifacts'),
|
|
77
|
+
});
|
|
78
|
+
/**
|
|
79
|
+
* Approval information
|
|
80
|
+
*/
|
|
81
|
+
export const ApprovalSchema = z.object({
|
|
82
|
+
approved: z.boolean().describe('Whether the plan is approved'),
|
|
83
|
+
approved_by: z.string().optional().describe('User who approved the plan'),
|
|
84
|
+
approved_at: z.string().datetime().optional().describe('When the plan was approved'),
|
|
85
|
+
approval_notes: z.string().optional().describe('Notes or comments on approval'),
|
|
86
|
+
});
|
|
87
|
+
/**
|
|
88
|
+
* Execution result for apply/rollback operations
|
|
89
|
+
*/
|
|
90
|
+
export const ExecutionResultSchema = z.object({
|
|
91
|
+
operation: z.enum(['apply', 'rollback', 'dry-run']).describe('Type of operation'),
|
|
92
|
+
status: z.enum(['success', 'failed', 'partial']).describe('Execution status'),
|
|
93
|
+
timestamp: z.string().datetime().describe('When the operation was performed'),
|
|
94
|
+
executed_by: z.string().optional().describe('User who executed the operation'),
|
|
95
|
+
changes_applied: z.array(z.string()).optional().describe('List of successfully applied changes'),
|
|
96
|
+
changes_failed: z.array(z.string()).optional().describe('List of failed changes'),
|
|
97
|
+
rollback_point: z.string().optional().describe('Snapshot ID for rollback'),
|
|
98
|
+
logs: z.array(z.string()).optional().describe('Execution logs'),
|
|
99
|
+
});
|
|
100
|
+
/**
|
|
101
|
+
* Main APS Plan Schema with branding for type safety
|
|
102
|
+
*/
|
|
103
|
+
export const APSPlanSchema = z
|
|
104
|
+
.object({
|
|
105
|
+
// Identification
|
|
106
|
+
id: z
|
|
107
|
+
.string()
|
|
108
|
+
.regex(/^aps-[a-f0-9]{8}(?:[a-f0-9]{8})?$/)
|
|
109
|
+
.describe('Unique plan identifier'),
|
|
110
|
+
hash: z
|
|
111
|
+
.string()
|
|
112
|
+
.regex(/^[a-f0-9]{64}$/)
|
|
113
|
+
.describe('SHA-256 hash of the plan content'),
|
|
114
|
+
// Core content
|
|
115
|
+
intent: z
|
|
116
|
+
.string()
|
|
117
|
+
.min(10, 'Intent must be at least 10 characters')
|
|
118
|
+
.max(500, 'Intent must not exceed 500 characters')
|
|
119
|
+
.describe('Human-readable description of what this plan intends to achieve'),
|
|
120
|
+
// Schema version using literal type
|
|
121
|
+
schema_version: z.literal(SCHEMA_VERSION).describe('Version of the APS schema'),
|
|
122
|
+
// Plan details
|
|
123
|
+
proposed_changes: z.array(ChangeSchema).describe('List of changes this plan will make'),
|
|
124
|
+
// Metadata
|
|
125
|
+
provenance: ProvenanceSchema.describe('Information about plan creation'),
|
|
126
|
+
validations: ValidationSchema.describe('Validation requirements for this plan'),
|
|
127
|
+
// Optional fields that get added during lifecycle
|
|
128
|
+
evidence: z
|
|
129
|
+
.array(EvidenceSchema)
|
|
130
|
+
.optional()
|
|
131
|
+
.describe('Evidence from gate executions (immutable, append-only)'),
|
|
132
|
+
approval: ApprovalSchema.optional().describe('Approval information'),
|
|
133
|
+
executions: z.array(ExecutionResultSchema).optional().describe('History of plan executions'),
|
|
134
|
+
// Additional metadata
|
|
135
|
+
tags: z.array(z.string()).optional().describe('Tags for categorization and filtering'),
|
|
136
|
+
metadata: z
|
|
137
|
+
.record(z.string(), z.unknown())
|
|
138
|
+
.optional()
|
|
139
|
+
.describe('Additional plan-specific metadata'),
|
|
140
|
+
})
|
|
141
|
+
.strict(); // Reject unknown properties
|
|
142
|
+
/**
|
|
143
|
+
* Parse and validate a plan with user-friendly error formatting
|
|
144
|
+
*/
|
|
145
|
+
export function validatePlan(data) {
|
|
146
|
+
const result = APSPlanSchema.safeParse(data);
|
|
147
|
+
if (result.success) {
|
|
148
|
+
return {
|
|
149
|
+
success: true,
|
|
150
|
+
data: result.data,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
// Format Zod errors for better user experience
|
|
154
|
+
const errors = result.error.issues.map((issue) => ({
|
|
155
|
+
path: issue.path.join('.'),
|
|
156
|
+
message: issue.message,
|
|
157
|
+
code: issue.code,
|
|
158
|
+
}));
|
|
159
|
+
return {
|
|
160
|
+
success: false,
|
|
161
|
+
errors,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Create a new plan with defaults
|
|
166
|
+
*/
|
|
167
|
+
export function createPlan(params) {
|
|
168
|
+
return {
|
|
169
|
+
id: params.id,
|
|
170
|
+
intent: params.intent,
|
|
171
|
+
schema_version: SCHEMA_VERSION,
|
|
172
|
+
proposed_changes: params.changes || [],
|
|
173
|
+
provenance: params.provenance,
|
|
174
|
+
validations: params.validations || {
|
|
175
|
+
required_checks: ['lint', 'test', 'coverage', 'secrets'],
|
|
176
|
+
skip_checks: [],
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Schema version for external reference
|
|
182
|
+
*/
|
|
183
|
+
export const APS_SCHEMA_VERSION = SCHEMA_VERSION;
|