micro-contracts 0.18.9 → 0.18.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -14
- package/cli-contract.yaml +15 -27
- package/dist/agents/context-builder.d.ts +5 -0
- package/dist/agents/context-builder.d.ts.map +1 -0
- package/dist/agents/context-builder.js +239 -0
- package/dist/agents/context-builder.js.map +1 -0
- package/dist/agents/formatter.d.ts +9 -0
- package/dist/agents/formatter.d.ts.map +1 -0
- package/dist/agents/formatter.js +124 -0
- package/dist/agents/formatter.js.map +1 -0
- package/dist/agents/index.d.ts +6 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +4 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/orchestrator.d.ts +5 -0
- package/dist/agents/orchestrator.d.ts.map +1 -0
- package/dist/agents/orchestrator.js +46 -0
- package/dist/agents/orchestrator.js.map +1 -0
- package/dist/agents/types.d.ts +29 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/types.js +7 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/cli/templates.d.ts +15 -0
- package/dist/cli/templates.d.ts.map +1 -0
- package/dist/cli/templates.js +445 -0
- package/dist/cli/templates.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +1201 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/audit-guardrails.d.ts +15 -0
- package/dist/commands/audit-guardrails.d.ts.map +1 -0
- package/dist/commands/audit-guardrails.js +33 -0
- package/dist/commands/audit-guardrails.js.map +1 -0
- package/dist/commands/audit-openapi.d.ts +15 -0
- package/dist/commands/audit-openapi.d.ts.map +1 -0
- package/dist/commands/audit-openapi.js +33 -0
- package/dist/commands/audit-openapi.js.map +1 -0
- package/dist/commands/insights.d.ts +8 -0
- package/dist/commands/insights.d.ts.map +1 -0
- package/dist/commands/insights.js +13 -0
- package/dist/commands/insights.js.map +1 -0
- package/dist/commands/propose-overlays.d.ts +15 -0
- package/dist/commands/propose-overlays.d.ts.map +1 -0
- package/dist/commands/propose-overlays.js +33 -0
- package/dist/commands/propose-overlays.js.map +1 -0
- package/dist/commands/review-published.d.ts +15 -0
- package/dist/commands/review-published.d.ts.map +1 -0
- package/dist/commands/review-published.js +33 -0
- package/dist/commands/review-published.js.map +1 -0
- package/dist/external/insight-provider.d.ts.map +1 -0
- package/dist/external/insight-provider.js.map +1 -0
- package/dist/generated/commands.d.ts +2 -0
- package/dist/generated/commands.d.ts.map +1 -0
- package/dist/generated/commands.js +2 -0
- package/dist/generated/commands.js.map +1 -0
- package/dist/generated/contract.d.ts +3 -0
- package/dist/generated/contract.d.ts.map +1 -0
- package/dist/generated/contract.js +5 -0
- package/dist/generated/contract.js.map +1 -0
- package/dist/generated/dsl/agents.d.ts +34 -0
- package/dist/generated/dsl/agents.d.ts.map +1 -0
- package/dist/generated/dsl/agents.js +98 -0
- package/dist/generated/dsl/agents.js.map +1 -0
- package/dist/generated/dsl/dsl-data.d.ts +7 -0
- package/dist/generated/dsl/dsl-data.d.ts.map +1 -0
- package/dist/generated/dsl/dsl-data.js +1041 -0
- package/dist/generated/dsl/dsl-data.js.map +1 -0
- package/dist/generated/dsl/handoffs.d.ts +457 -0
- package/dist/generated/dsl/handoffs.d.ts.map +1 -0
- package/dist/generated/dsl/handoffs.js +205 -0
- package/dist/generated/dsl/handoffs.js.map +1 -0
- package/dist/generated/dsl/index.d.ts +14 -0
- package/dist/generated/dsl/index.d.ts.map +1 -0
- package/dist/generated/dsl/index.js +11 -0
- package/dist/generated/dsl/index.js.map +1 -0
- package/dist/generated/dsl/tasks.d.ts +28 -0
- package/dist/generated/dsl/tasks.d.ts.map +1 -0
- package/dist/generated/dsl/tasks.js +137 -0
- package/dist/generated/dsl/tasks.js.map +1 -0
- package/dist/generated/dsl/workflows.d.ts +34 -0
- package/dist/generated/dsl/workflows.d.ts.map +1 -0
- package/dist/generated/dsl/workflows.js +84 -0
- package/dist/generated/dsl/workflows.js.map +1 -0
- package/dist/generated/index.d.ts +8 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +8 -0
- package/dist/generated/index.js.map +1 -0
- package/dist/generated/policy-runtime.d.ts +114 -0
- package/dist/generated/policy-runtime.d.ts.map +1 -0
- package/dist/generated/policy-runtime.js +195 -0
- package/dist/generated/policy-runtime.js.map +1 -0
- package/dist/generated/policy.d.ts +658 -0
- package/dist/generated/policy.d.ts.map +1 -0
- package/dist/generated/policy.js +844 -0
- package/dist/generated/policy.js.map +1 -0
- package/dist/generated/program.d.ts +120 -0
- package/dist/generated/program.d.ts.map +1 -0
- package/dist/generated/program.js +370 -0
- package/dist/generated/program.js.map +1 -0
- package/dist/generated/schemas.d.ts +779 -0
- package/dist/generated/schemas.d.ts.map +1 -0
- package/dist/generated/schemas.js +1006 -0
- package/dist/generated/schemas.js.map +1 -0
- package/dist/generated/types.d.ts +786 -0
- package/dist/generated/types.d.ts.map +1 -0
- package/dist/generated/types.js +3 -0
- package/dist/generated/types.js.map +1 -0
- package/dist/generator/dependencyGenerator.d.ts +16 -0
- package/dist/generator/dependencyGenerator.d.ts.map +1 -0
- package/dist/generator/dependencyGenerator.js +25 -0
- package/dist/generator/dependencyGenerator.js.map +1 -0
- package/dist/generator/index.d.ts +47 -0
- package/dist/generator/index.d.ts.map +1 -0
- package/dist/generator/index.js +707 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/generator/inputHash.d.ts +23 -0
- package/dist/generator/inputHash.d.ts.map +1 -0
- package/dist/generator/inputHash.js +138 -0
- package/dist/generator/inputHash.js.map +1 -0
- package/dist/generator/linter.d.ts +26 -0
- package/dist/generator/linter.d.ts.map +1 -0
- package/dist/generator/linter.js +441 -0
- package/dist/generator/linter.js.map +1 -0
- package/dist/generator/overlayProcessor.d.ts +71 -0
- package/dist/generator/overlayProcessor.d.ts.map +1 -0
- package/dist/generator/overlayProcessor.js +500 -0
- package/dist/generator/overlayProcessor.js.map +1 -0
- package/dist/generator/schemaGenerator.d.ts +10 -0
- package/dist/generator/schemaGenerator.d.ts.map +1 -0
- package/dist/generator/schemaGenerator.js +296 -0
- package/dist/generator/schemaGenerator.js.map +1 -0
- package/dist/generator/serviceGenerator.d.ts +20 -0
- package/dist/generator/serviceGenerator.d.ts.map +1 -0
- package/dist/generator/serviceGenerator.js +293 -0
- package/dist/generator/serviceGenerator.js.map +1 -0
- package/dist/generator/templateProcessor.d.ts +208 -0
- package/dist/generator/templateProcessor.d.ts.map +1 -0
- package/dist/generator/templateProcessor.js +604 -0
- package/dist/generator/templateProcessor.js.map +1 -0
- package/dist/generator/typeGenerator.d.ts +22 -0
- package/dist/generator/typeGenerator.d.ts.map +1 -0
- package/dist/generator/typeGenerator.js +439 -0
- package/dist/generator/typeGenerator.js.map +1 -0
- package/dist/generator/typeGenerator.test.d.ts +2 -0
- package/dist/generator/typeGenerator.test.d.ts.map +1 -0
- package/dist/generator/typeGenerator.test.js +155 -0
- package/dist/generator/typeGenerator.test.js.map +1 -0
- package/dist/glob.d.ts +22 -0
- package/dist/glob.d.ts.map +1 -0
- package/dist/glob.js +103 -0
- package/dist/glob.js.map +1 -0
- package/dist/guardrails/allowlist.d.ts +30 -0
- package/dist/guardrails/allowlist.d.ts.map +1 -0
- package/dist/guardrails/allowlist.js +174 -0
- package/dist/guardrails/allowlist.js.map +1 -0
- package/dist/guardrails/config.d.ts +40 -0
- package/dist/guardrails/config.d.ts.map +1 -0
- package/dist/guardrails/config.js +177 -0
- package/dist/guardrails/config.js.map +1 -0
- package/dist/guardrails/drift.d.ts +19 -0
- package/dist/guardrails/drift.d.ts.map +1 -0
- package/dist/guardrails/drift.js +115 -0
- package/dist/guardrails/drift.js.map +1 -0
- package/dist/guardrails/index.d.ts +18 -0
- package/dist/guardrails/index.d.ts.map +1 -0
- package/dist/guardrails/index.js +21 -0
- package/dist/guardrails/index.js.map +1 -0
- package/dist/guardrails/lint.d.ts +16 -0
- package/dist/guardrails/lint.d.ts.map +1 -0
- package/dist/guardrails/lint.js +172 -0
- package/dist/guardrails/lint.js.map +1 -0
- package/dist/guardrails/manifest.d.ts +63 -0
- package/dist/guardrails/manifest.d.ts.map +1 -0
- package/dist/guardrails/manifest.js +310 -0
- package/dist/guardrails/manifest.js.map +1 -0
- package/dist/guardrails/runner.d.ts +53 -0
- package/dist/guardrails/runner.d.ts.map +1 -0
- package/dist/guardrails/runner.js +387 -0
- package/dist/guardrails/runner.js.map +1 -0
- package/dist/guardrails/types.d.ts +196 -0
- package/dist/guardrails/types.d.ts.map +1 -0
- package/dist/guardrails/types.js +8 -0
- package/dist/guardrails/types.js.map +1 -0
- package/dist/index.d.ts +21 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -4
- package/dist/index.js.map +1 -0
- package/dist/micro-contracts.bundle.mjs +358 -383
- package/dist/micro-contracts.bundle.mjs.map +3 -3
- package/dist/types.d.ts +502 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +409 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +10 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +31 -0
- package/dist/version.js.map +1 -0
- package/docs/cli-reference.md +13 -15
- package/docs/development-guardrails.md +3 -3
- package/docs/screen-spec.md +3 -3
- package/package.json +13 -12
package/dist/types.js
ADDED
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAPI specification types for code generation
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Parse dependency reference string
|
|
6
|
+
*/
|
|
7
|
+
function parseDependencyRef(ref) {
|
|
8
|
+
const parts = ref.split('.');
|
|
9
|
+
if (parts.length !== 3)
|
|
10
|
+
return null;
|
|
11
|
+
return {
|
|
12
|
+
module: parts[0],
|
|
13
|
+
service: parts[1],
|
|
14
|
+
method: parts[2],
|
|
15
|
+
raw: ref,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
// =============================================================================
|
|
19
|
+
// Config Utilities
|
|
20
|
+
// =============================================================================
|
|
21
|
+
/**
|
|
22
|
+
* Check if config is multi-module format
|
|
23
|
+
*/
|
|
24
|
+
export function isMultiModuleConfig(config) {
|
|
25
|
+
return typeof config === 'object' && config !== null && 'modules' in config;
|
|
26
|
+
}
|
|
27
|
+
const SERVER_KEYS = { output: null, template: null, servicesPath: null };
|
|
28
|
+
const FRONTEND_KEYS = { output: null, template: null, client: null, service: null };
|
|
29
|
+
const OUTPUT_KEYS = {
|
|
30
|
+
output: null, template: null, overwrite: null, condition: null, enabled: null, config: null,
|
|
31
|
+
};
|
|
32
|
+
const CONTRACT_KEYS = { output: null, serviceTemplate: null };
|
|
33
|
+
const MODULE_KEYS = {
|
|
34
|
+
openapi: null,
|
|
35
|
+
screen: null,
|
|
36
|
+
contract: CONTRACT_KEYS,
|
|
37
|
+
contractPublic: { output: null },
|
|
38
|
+
server: { ...SERVER_KEYS, enabled: null },
|
|
39
|
+
frontend: { ...FRONTEND_KEYS, enabled: null },
|
|
40
|
+
overlays: null,
|
|
41
|
+
outputs: { '*': OUTPUT_KEYS },
|
|
42
|
+
dependsOn: null,
|
|
43
|
+
};
|
|
44
|
+
const CONFIG_KEYS = {
|
|
45
|
+
defaults: {
|
|
46
|
+
contract: CONTRACT_KEYS,
|
|
47
|
+
contractPublic: { output: null },
|
|
48
|
+
server: SERVER_KEYS,
|
|
49
|
+
frontend: FRONTEND_KEYS,
|
|
50
|
+
overlays: { shared: null, collision: null },
|
|
51
|
+
outputs: { '*': OUTPUT_KEYS },
|
|
52
|
+
},
|
|
53
|
+
modules: { '*': MODULE_KEYS },
|
|
54
|
+
};
|
|
55
|
+
/** Keys removed from the config format, with the replacement to use instead. */
|
|
56
|
+
const REMOVED_KEYS = {
|
|
57
|
+
'defaults.docs': 'documentation generation was removed; run @redocly/cli against the generated spec',
|
|
58
|
+
'defaults.spectral': 'declare a Spectral command under checks in guardrails.yaml',
|
|
59
|
+
'defaults.sharedModuleName': 'never had an effect',
|
|
60
|
+
'spec': 'never had an effect; module spec paths come from modules.<name>.openapi',
|
|
61
|
+
'defaults.templates': 'use defaults.server.template / defaults.frontend.template / defaults.contract.serviceTemplate',
|
|
62
|
+
'defaults.server.routes': 'the file name is part of server.output (e.g. server/src/{module}/routes.generated.ts)',
|
|
63
|
+
'defaults.frontend.shared': 'no longer generated; declare an entry under outputs instead',
|
|
64
|
+
};
|
|
65
|
+
function collectUnknownKeys(value, spec, trail, found) {
|
|
66
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
67
|
+
return;
|
|
68
|
+
const wildcard = spec['*'];
|
|
69
|
+
for (const [key, child] of Object.entries(value)) {
|
|
70
|
+
const keyPath = trail ? `${trail}.${key}` : key;
|
|
71
|
+
if (wildcard !== undefined) {
|
|
72
|
+
if (wildcard)
|
|
73
|
+
collectUnknownKeys(child, wildcard, keyPath, found);
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (!(key in spec)) {
|
|
77
|
+
// Report against the shape, not the module name, so `modules.a.templates`
|
|
78
|
+
// and `defaults.templates` share one migration hint.
|
|
79
|
+
const shapePath = trail.replace(/^modules\.[^.]+/, 'defaults');
|
|
80
|
+
const hint = REMOVED_KEYS[shapePath ? `${shapePath}.${key}` : key]
|
|
81
|
+
?? REMOVED_KEYS[`defaults.${key}`];
|
|
82
|
+
found.push(`${keyPath}${hint ? ` (${hint})` : ''}`);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const childSpec = spec[key];
|
|
86
|
+
if (childSpec)
|
|
87
|
+
collectUnknownKeys(child, childSpec, keyPath, found);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Reject unknown config keys. A mistyped or removed key must fail loudly:
|
|
92
|
+
* silently ignoring it looks like the setting was honored.
|
|
93
|
+
*/
|
|
94
|
+
export function validateConfigKeys(config) {
|
|
95
|
+
const unknown = [];
|
|
96
|
+
collectUnknownKeys(config, CONFIG_KEYS, '', unknown);
|
|
97
|
+
if (unknown.length > 0) {
|
|
98
|
+
throw new Error(`Unknown configuration ${unknown.length === 1 ? 'key' : 'keys'}:\n` +
|
|
99
|
+
unknown.map(k => ` - ${k}`).join('\n'));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Expand placeholders in a string
|
|
104
|
+
*/
|
|
105
|
+
export function expandPlaceholders(template, moduleName) {
|
|
106
|
+
const pascalCase = moduleName.charAt(0).toUpperCase() + moduleName.slice(1);
|
|
107
|
+
const upperSnake = moduleName.toUpperCase().replace(/-/g, '_');
|
|
108
|
+
return template
|
|
109
|
+
.replace(/\{module\}/g, moduleName)
|
|
110
|
+
.replace(/\{Module\}/g, pascalCase)
|
|
111
|
+
.replace(/\{MODULE\}/g, upperSnake);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Resolve outputs configuration
|
|
115
|
+
*/
|
|
116
|
+
function resolveOutputs(moduleName, moduleConfig, defaults) {
|
|
117
|
+
const expand = (s) => expandPlaceholders(s, moduleName);
|
|
118
|
+
const resolvedOutputs = [];
|
|
119
|
+
// Merge default outputs with module overrides
|
|
120
|
+
const defaultOutputs = defaults.outputs || {};
|
|
121
|
+
const moduleOutputs = moduleConfig.outputs || {};
|
|
122
|
+
const allOutputIds = new Set([
|
|
123
|
+
...Object.keys(defaultOutputs),
|
|
124
|
+
...Object.keys(moduleOutputs),
|
|
125
|
+
]);
|
|
126
|
+
for (const id of allOutputIds) {
|
|
127
|
+
const defaultConfig = defaultOutputs[id];
|
|
128
|
+
const moduleOverride = moduleOutputs[id];
|
|
129
|
+
// Skip if explicitly disabled
|
|
130
|
+
if (moduleOverride?.enabled === false)
|
|
131
|
+
continue;
|
|
132
|
+
const output = expand(moduleOverride?.output ?? defaultConfig?.output ?? '');
|
|
133
|
+
const template = moduleOverride?.template ?? defaultConfig?.template ?? '';
|
|
134
|
+
// An output that resolves to no file or no template generates nothing:
|
|
135
|
+
// say so instead of skipping it silently.
|
|
136
|
+
if (!output || !template) {
|
|
137
|
+
const missing = [!output && 'output', !template && 'template'].filter(Boolean).join(' and ');
|
|
138
|
+
throw new Error(`outputs.${id} for module '${moduleName}' is missing ${missing}. ` +
|
|
139
|
+
`Set it under defaults.outputs.${id} or modules.${moduleName}.outputs.${id}, ` +
|
|
140
|
+
`or disable it with enabled: false.`);
|
|
141
|
+
}
|
|
142
|
+
resolvedOutputs.push({
|
|
143
|
+
id,
|
|
144
|
+
output,
|
|
145
|
+
template,
|
|
146
|
+
overwrite: moduleOverride?.overwrite ?? defaultConfig?.overwrite ?? true,
|
|
147
|
+
condition: moduleOverride?.condition ?? defaultConfig?.condition ?? 'always',
|
|
148
|
+
enabled: moduleOverride?.enabled ?? defaultConfig?.enabled ?? true,
|
|
149
|
+
config: {
|
|
150
|
+
...(defaultConfig?.config || {}),
|
|
151
|
+
...(moduleOverride?.config || {}),
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return resolvedOutputs;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Resolve module config by applying defaults and expanding placeholders
|
|
159
|
+
*/
|
|
160
|
+
export function resolveModuleConfig(moduleName, moduleConfig, defaults = {}) {
|
|
161
|
+
const expand = (s) => expandPlaceholders(s, moduleName);
|
|
162
|
+
// Contract output
|
|
163
|
+
const contractOutput = expand(moduleConfig.contract?.output ??
|
|
164
|
+
defaults.contract?.output ??
|
|
165
|
+
`packages/contract/${moduleName}`);
|
|
166
|
+
// Public contract output
|
|
167
|
+
const contractPublicOutput = expand(moduleConfig.contractPublic?.output ??
|
|
168
|
+
defaults.contractPublic?.output ??
|
|
169
|
+
`packages/contract-published/${moduleName}`);
|
|
170
|
+
// Service template (module overrides defaults)
|
|
171
|
+
const serviceTemplate = moduleConfig.contract?.serviceTemplate ?? defaults.contract?.serviceTemplate;
|
|
172
|
+
// Server config (legacy). Only generated when the section is declared:
|
|
173
|
+
// an undeclared section must not demand a template.
|
|
174
|
+
const serverEnabled = (moduleConfig.server !== undefined || defaults.server !== undefined) &&
|
|
175
|
+
moduleConfig.server?.enabled !== false;
|
|
176
|
+
const server = serverEnabled ? {
|
|
177
|
+
output: expand(moduleConfig.server?.output ??
|
|
178
|
+
defaults.server?.output ??
|
|
179
|
+
`server/src/${moduleName}/routes.generated.ts`),
|
|
180
|
+
template: moduleConfig.server?.template ?? defaults.server?.template,
|
|
181
|
+
servicesPath: expand(moduleConfig.server?.servicesPath ??
|
|
182
|
+
defaults.server?.servicesPath ??
|
|
183
|
+
`fastify.services.${moduleName}`),
|
|
184
|
+
} : null;
|
|
185
|
+
// Frontend config (legacy). Declared-only, as with server above.
|
|
186
|
+
const frontendEnabled = (moduleConfig.frontend !== undefined || defaults.frontend !== undefined) &&
|
|
187
|
+
moduleConfig.frontend?.enabled !== false;
|
|
188
|
+
const frontendDefaults = defaults.frontend;
|
|
189
|
+
const frontendOverride = moduleConfig.frontend;
|
|
190
|
+
const frontend = frontendEnabled ? {
|
|
191
|
+
output: expand(frontendOverride?.output ??
|
|
192
|
+
frontendDefaults?.output ??
|
|
193
|
+
`frontend/src/${moduleName}`),
|
|
194
|
+
template: frontendOverride?.template ?? frontendDefaults?.template,
|
|
195
|
+
client: frontendOverride?.client ?? frontendDefaults?.client ?? 'api.generated.ts',
|
|
196
|
+
service: frontendOverride?.service ?? frontendDefaults?.service ?? 'service.generated.ts',
|
|
197
|
+
} : null;
|
|
198
|
+
// Overlays (shared + module-specific)
|
|
199
|
+
const overlays = [
|
|
200
|
+
...(defaults.overlays?.shared || []),
|
|
201
|
+
...(moduleConfig.overlays || []),
|
|
202
|
+
];
|
|
203
|
+
const overlayCollision = defaults.overlays?.collision || 'error';
|
|
204
|
+
// New outputs system
|
|
205
|
+
const outputs = resolveOutputs(moduleName, moduleConfig, defaults);
|
|
206
|
+
return {
|
|
207
|
+
name: moduleName,
|
|
208
|
+
openapi: moduleConfig.openapi,
|
|
209
|
+
screen: moduleConfig.screen === true,
|
|
210
|
+
contractOutput,
|
|
211
|
+
contractPublicOutput,
|
|
212
|
+
serviceTemplate,
|
|
213
|
+
server,
|
|
214
|
+
frontend,
|
|
215
|
+
overlays,
|
|
216
|
+
overlayCollision,
|
|
217
|
+
outputs,
|
|
218
|
+
dependsOn: moduleConfig.dependsOn,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
// Helper to check if object is a reference
|
|
222
|
+
export function isReference(obj) {
|
|
223
|
+
return typeof obj === 'object' && obj !== null && '$ref' in obj;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* True when `name` can be emitted verbatim as a TypeScript identifier.
|
|
227
|
+
* Names that fail this must be quoted (property keys) or rejected (type names).
|
|
228
|
+
*/
|
|
229
|
+
export function isTsIdentifier(name) {
|
|
230
|
+
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);
|
|
231
|
+
}
|
|
232
|
+
// Extract schema name from $ref
|
|
233
|
+
export function getRefName(ref) {
|
|
234
|
+
// "#/components/schemas/EntryListResponse" -> "EntryListResponse"
|
|
235
|
+
const parts = ref.split('/');
|
|
236
|
+
return parts[parts.length - 1];
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Extract dependencies from OpenAPI spec
|
|
240
|
+
*/
|
|
241
|
+
export function extractDependencies(spec) {
|
|
242
|
+
const moduleLevelDeps = [];
|
|
243
|
+
const operationLevelDeps = new Map();
|
|
244
|
+
const allDepsSet = new Set();
|
|
245
|
+
// Module-level dependencies
|
|
246
|
+
const moduleDepRefs = spec.info['x-micro-contracts-depend-on'] || [];
|
|
247
|
+
for (const ref of moduleDepRefs) {
|
|
248
|
+
const parsed = parseDependencyRef(ref);
|
|
249
|
+
if (parsed) {
|
|
250
|
+
moduleLevelDeps.push(parsed);
|
|
251
|
+
allDepsSet.add(ref);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
// Operation-level dependencies
|
|
255
|
+
for (const [, pathItem] of Object.entries(spec.paths)) {
|
|
256
|
+
for (const method of ['get', 'post', 'put', 'patch', 'delete']) {
|
|
257
|
+
const operation = pathItem[method];
|
|
258
|
+
if (!operation)
|
|
259
|
+
continue;
|
|
260
|
+
const opId = operation.operationId || '';
|
|
261
|
+
const opDepRefs = operation['x-micro-contracts-depend-on'] || [];
|
|
262
|
+
if (opDepRefs.length > 0) {
|
|
263
|
+
const parsedDeps = [];
|
|
264
|
+
for (const ref of opDepRefs) {
|
|
265
|
+
const parsed = parseDependencyRef(ref);
|
|
266
|
+
if (parsed) {
|
|
267
|
+
parsedDeps.push(parsed);
|
|
268
|
+
allDepsSet.add(ref);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (parsedDeps.length > 0) {
|
|
272
|
+
operationLevelDeps.set(opId, parsedDeps);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
// All unique deps
|
|
278
|
+
const allDeps = [];
|
|
279
|
+
for (const ref of allDepsSet) {
|
|
280
|
+
const parsed = parseDependencyRef(ref);
|
|
281
|
+
if (parsed)
|
|
282
|
+
allDeps.push(parsed);
|
|
283
|
+
}
|
|
284
|
+
return { moduleLevelDeps, operationLevelDeps, allDeps };
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Walk a schema graph, visiting the schema and every subschema reachable from
|
|
288
|
+
* it: properties, array items, additionalProperties, allOf/oneOf/anyOf members,
|
|
289
|
+
* and the targets of $ref.
|
|
290
|
+
*
|
|
291
|
+
* The single traversal of the schema graph. Everything that asks a question
|
|
292
|
+
* about "this schema and everything it pulls in" goes through here, so a branch
|
|
293
|
+
* can never be reachable for one question and invisible to another — which is
|
|
294
|
+
* how an x-private schema behind additionalProperties reached the published
|
|
295
|
+
* contract while passing the x-private check.
|
|
296
|
+
*
|
|
297
|
+
* `visit` receives each resolved (non-reference) schema and, when the schema
|
|
298
|
+
* was reached through a $ref, its component name. Returning false from `visit`
|
|
299
|
+
* stops the walk.
|
|
300
|
+
*/
|
|
301
|
+
function walkSchemaGraph(schema, spec, visit, visited = new Set()) {
|
|
302
|
+
let refName;
|
|
303
|
+
let resolved;
|
|
304
|
+
if (isReference(schema)) {
|
|
305
|
+
refName = getRefName(schema.$ref);
|
|
306
|
+
if (visited.has(refName))
|
|
307
|
+
return true;
|
|
308
|
+
visited.add(refName);
|
|
309
|
+
resolved = spec.components?.schemas?.[refName];
|
|
310
|
+
if (!resolved)
|
|
311
|
+
return true;
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
resolved = schema;
|
|
315
|
+
}
|
|
316
|
+
if (visit(resolved, refName) === false)
|
|
317
|
+
return false;
|
|
318
|
+
if (resolved.properties) {
|
|
319
|
+
for (const propSchema of Object.values(resolved.properties)) {
|
|
320
|
+
if (!walkSchemaGraph(propSchema, spec, visit, visited))
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
if (resolved.items) {
|
|
325
|
+
if (!walkSchemaGraph(resolved.items, spec, visit, visited))
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
if (resolved.additionalProperties && typeof resolved.additionalProperties !== 'boolean') {
|
|
329
|
+
if (!walkSchemaGraph(resolved.additionalProperties, spec, visit, visited))
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
for (const composite of [resolved.allOf, resolved.oneOf, resolved.anyOf]) {
|
|
333
|
+
if (composite) {
|
|
334
|
+
for (const member of composite) {
|
|
335
|
+
if (!walkSchemaGraph(member, spec, visit, visited))
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return true;
|
|
341
|
+
}
|
|
342
|
+
// Check if a schema contains x-private properties
|
|
343
|
+
export function hasPrivateProperties(schema, spec) {
|
|
344
|
+
let found = false;
|
|
345
|
+
walkSchemaGraph(schema, spec, (node) => {
|
|
346
|
+
if (node['x-private']) {
|
|
347
|
+
found = true;
|
|
348
|
+
return false;
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
return found;
|
|
352
|
+
}
|
|
353
|
+
const COMPONENT_SECTIONS = ['schemas', 'responses', 'parameters', 'requestBodies'];
|
|
354
|
+
/**
|
|
355
|
+
* Every component reachable from `root`, as "<section>/<name>".
|
|
356
|
+
*
|
|
357
|
+
* Walks arbitrary spec JSON, following $ref across component sections and
|
|
358
|
+
* expanding each referenced component in turn: a response pulls in its schema,
|
|
359
|
+
* a requestBody pulls in its schema, and so on.
|
|
360
|
+
*
|
|
361
|
+
* The single answer to "what does this reach". Filtering the published contract
|
|
362
|
+
* and checking it for private data both consume it, so a component cannot be
|
|
363
|
+
* copied into the public surface while being invisible to the checks — which is
|
|
364
|
+
* how a private schema behind an error response and behind a $ref requestBody
|
|
365
|
+
* reached contract-published.
|
|
366
|
+
*/
|
|
367
|
+
export function collectReachableComponents(root, spec, reached = new Set()) {
|
|
368
|
+
const pending = [root];
|
|
369
|
+
while (pending.length > 0) {
|
|
370
|
+
const node = pending.pop();
|
|
371
|
+
if (!node || typeof node !== 'object')
|
|
372
|
+
continue;
|
|
373
|
+
if (Array.isArray(node)) {
|
|
374
|
+
pending.push(...node);
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
const record = node;
|
|
378
|
+
if (typeof record.$ref === 'string') {
|
|
379
|
+
const parsed = parseComponentRef(record.$ref);
|
|
380
|
+
if (parsed && !reached.has(`${parsed.section}/${parsed.name}`)) {
|
|
381
|
+
reached.add(`${parsed.section}/${parsed.name}`);
|
|
382
|
+
const target = spec.components?.[parsed.section]?.[parsed.name];
|
|
383
|
+
if (target)
|
|
384
|
+
pending.push(target);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
pending.push(...Object.values(record));
|
|
388
|
+
}
|
|
389
|
+
return reached;
|
|
390
|
+
}
|
|
391
|
+
/** Parse "#/components/<section>/<name>" into its parts. */
|
|
392
|
+
function parseComponentRef(ref) {
|
|
393
|
+
const match = ref.match(/^#\/components\/([^/]+)\/(.+)$/);
|
|
394
|
+
if (!match)
|
|
395
|
+
return null;
|
|
396
|
+
const section = match[1];
|
|
397
|
+
if (!COMPONENT_SECTIONS.includes(section))
|
|
398
|
+
return null;
|
|
399
|
+
return { section, name: match[2] };
|
|
400
|
+
}
|
|
401
|
+
// Collect all schemas referenced by a schema
|
|
402
|
+
export function collectReferencedSchemas(schema, spec, result = new Set()) {
|
|
403
|
+
walkSchemaGraph(schema, spec, (_node, refName) => {
|
|
404
|
+
if (refName)
|
|
405
|
+
result.add(refName);
|
|
406
|
+
});
|
|
407
|
+
return result;
|
|
408
|
+
}
|
|
409
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AA+QH;;GAEG;AACH,SAAS,kBAAkB,CAAC,GAAW;IACrC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACpC,OAAO;QACL,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;QAChB,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;QACjB,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;QAChB,GAAG,EAAE,GAAG;KACT,CAAC;AACJ,CAAC;AAkND,gFAAgF;AAChF,mBAAmB;AACnB,gFAAgF;AAEhF;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAe;IACjD,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,SAAS,IAAI,MAAM,CAAC;AAC9E,CAAC;AAkBD,MAAM,WAAW,GAAY,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;AAClF,MAAM,aAAa,GAAY,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAA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AAO,OAAO,CAAC;AACjB,CAAC;AAED,4DAA4D;AAC5D,SAAS,iBAAiB,CAAC,GAAW;IACpC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;IAC1D,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAqB,CAAC;IAC7C,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IACvD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACrC,CAAC;AAED,6CAA6C;AAC7C,MAAM,UAAU,wBAAwB,CACtC,MAAsC,EACtC,IAAiB,EACjB,SAAS,IAAI,GAAG,EAAU;IAE1B,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QAC/C,IAAI,OAAO;YAAE,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package version — single source of truth.
|
|
3
|
+
*
|
|
4
|
+
* Resolved by walking up from this module's own location to the nearest
|
|
5
|
+
* package.json. Hard-coded relative paths cannot be used here: this module is
|
|
6
|
+
* shipped both as `dist/*.js` (tsc), `dist/external/*.js` (tsc) and inlined
|
|
7
|
+
* into `dist/micro-contracts.bundle.mjs` (esbuild), each at a different depth.
|
|
8
|
+
*/
|
|
9
|
+
export declare const VERSION: string;
|
|
10
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA0BH,eAAO,MAAM,OAAO,QAAgB,CAAC"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package version — single source of truth.
|
|
3
|
+
*
|
|
4
|
+
* Resolved by walking up from this module's own location to the nearest
|
|
5
|
+
* package.json. Hard-coded relative paths cannot be used here: this module is
|
|
6
|
+
* shipped both as `dist/*.js` (tsc), `dist/external/*.js` (tsc) and inlined
|
|
7
|
+
* into `dist/micro-contracts.bundle.mjs` (esbuild), each at a different depth.
|
|
8
|
+
*/
|
|
9
|
+
import fs from 'fs';
|
|
10
|
+
import path from 'path';
|
|
11
|
+
import { fileURLToPath } from 'url';
|
|
12
|
+
function readVersion() {
|
|
13
|
+
let dir = path.dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
for (;;) {
|
|
15
|
+
const candidate = path.join(dir, 'package.json');
|
|
16
|
+
if (fs.existsSync(candidate)) {
|
|
17
|
+
const parsed = JSON.parse(fs.readFileSync(candidate, 'utf-8'));
|
|
18
|
+
if (!parsed.version) {
|
|
19
|
+
throw new Error(`package.json without a version field: ${candidate}`);
|
|
20
|
+
}
|
|
21
|
+
return parsed.version;
|
|
22
|
+
}
|
|
23
|
+
const parent = path.dirname(dir);
|
|
24
|
+
if (parent === dir) {
|
|
25
|
+
throw new Error('package.json not found above ' + fileURLToPath(import.meta.url));
|
|
26
|
+
}
|
|
27
|
+
dir = parent;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export const VERSION = readVersion();
|
|
31
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,SAAS,WAAW;IAClB,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAEvD,SAAS,CAAC;QACR,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QACjD,IAAI,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAyB,CAAC;YACvF,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpB,MAAM,IAAI,KAAK,CAAC,yCAAyC,SAAS,EAAE,CAAC,CAAC;YACxE,CAAC;YACD,OAAO,MAAM,CAAC,OAAO,CAAC;QACxB,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,+BAA+B,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACpF,CAAC;QACD,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC"}
|
package/docs/cli-reference.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Contract-first OpenAPI toolchain for TypeScript Web/API systems. Generates contract packages, server routes, and frontend clients from OpenAPI specifications with enforceable guardrails.
|
|
4
4
|
|
|
5
|
-
**Version:** 0.18.
|
|
5
|
+
**Version:** 0.18.11
|
|
6
6
|
|
|
7
7
|
## Table of Contents
|
|
8
8
|
|
|
@@ -68,9 +68,8 @@ micro-contracts generate --force
|
|
|
68
68
|
| `--contracts-only` | | No | `false` | Generate contract packages only. |
|
|
69
69
|
| `--server-only` | | No | `false` | Generate the built-in server section only. Not valid with an outputs configuration — select outputs with --output instead. |
|
|
70
70
|
| `--frontend-only` | | No | `false` | Generate the built-in frontend section only. Not valid with an outputs configuration — select outputs with --output instead. |
|
|
71
|
-
| `--docs-only` | | No | `false` | Generate documentation only. |
|
|
72
71
|
| `--skip-lint` | | No | `false` | Skip Spectral linting before generation. |
|
|
73
|
-
| `--manifest` | | No | `true` | Generate manifest after generation. Enabled by default when guardrails.yaml has a generated section. Use --no-manifest to disable. |
|
|
72
|
+
| `--manifest` | | No | `true` | Generate manifest after generation. Enabled by default when micro-contracts.guardrails.yaml has a generated section. Use --no-manifest to disable. |
|
|
74
73
|
| `--manifest-dir` | | No | `"packages/"` | Directory for manifest output. |
|
|
75
74
|
| `--force` | | No | `false` | Bypass input hash cache and always regenerate. |
|
|
76
75
|
| `--cache` | | No | `true` | Enable input hash caching. Enabled by default. Use --no-cache to disable both reading and writing cache. |
|
|
@@ -257,7 +256,7 @@ micro-contracts check --list-gates
|
|
|
257
256
|
| `--gate` | | No | | Run checks for specific gates only (comma-separated, 1-5). |
|
|
258
257
|
| `--verbose` | -v | No | `false` | Enable verbose output. |
|
|
259
258
|
| `--fix` | | No | `false` | Auto-fix issues where possible. |
|
|
260
|
-
| `--guardrails` | -g | No | | Path to guardrails.yaml. |
|
|
259
|
+
| `--guardrails` | -g | No | | Path to micro-contracts.guardrails.yaml. |
|
|
261
260
|
| `--generated-dir` | -d | No | `"packages/"` | Path to generated files directory. |
|
|
262
261
|
| `--changed-files` | | No | | Path to file containing list of changed files (for CI). |
|
|
263
262
|
| `--list` | | No | `false` | List available checks and exit. |
|
|
@@ -319,14 +318,13 @@ micro-contracts pipeline --contracts-only --skip-lint
|
|
|
319
318
|
| `--verbose` | -v | No | `false` | Enable verbose output (show detailed logs). |
|
|
320
319
|
| `--skip` | | No | | Skip specific checks (comma-separated). |
|
|
321
320
|
| `--continue-on-error` | | No | `false` | Continue running even if a step fails. |
|
|
322
|
-
| `--guardrails` | -g | No | | Path to guardrails.yaml. |
|
|
321
|
+
| `--guardrails` | -g | No | | Path to micro-contracts.guardrails.yaml. |
|
|
323
322
|
| `--generated-dir` | -d | No | `"packages/"` | Path to generated files directory. |
|
|
324
323
|
| `--manifest` | | No | `true` | Generate manifest after generation. Enabled by default. Use --no-manifest to disable. |
|
|
325
324
|
| `--skip-lint` | | No | `false` | Skip Spectral linting before generation. |
|
|
326
325
|
| `--contracts-only` | | No | `false` | Generate contract packages only. |
|
|
327
326
|
| `--server-only` | | No | `false` | Generate the built-in server section only. Not valid with an outputs configuration — select outputs with --output instead. |
|
|
328
327
|
| `--frontend-only` | | No | `false` | Generate the built-in frontend section only. Not valid with an outputs configuration — select outputs with --output instead. |
|
|
329
|
-
| `--docs-only` | | No | `false` | Generate documentation only. |
|
|
330
328
|
| `--force` | | No | `false` | Bypass input hash cache and always regenerate. |
|
|
331
329
|
| `--cache` | | No | `true` | Enable input hash caching. Enabled by default. Use --no-cache to disable both reading and writing cache. |
|
|
332
330
|
|
|
@@ -352,7 +350,7 @@ x-agent:
|
|
|
352
350
|
side_effects:
|
|
353
351
|
- file_write
|
|
354
352
|
recommended_before_use:
|
|
355
|
-
- Ensure micro-contracts.config.yaml and guardrails.yaml exist.
|
|
353
|
+
- Ensure micro-contracts.config.yaml and micro-contracts.guardrails.yaml exist.
|
|
356
354
|
- Verify OpenAPI specs are valid.
|
|
357
355
|
```
|
|
358
356
|
|
|
@@ -467,9 +465,9 @@ x-agent:
|
|
|
467
465
|
|
|
468
466
|
### guardrails-init
|
|
469
467
|
|
|
470
|
-
Create a guardrails.yaml configuration file.
|
|
468
|
+
Create a micro-contracts.guardrails.yaml configuration file.
|
|
471
469
|
|
|
472
|
-
Generates a starter guardrails.yaml with default check configuration. Fails if the target file already exists.
|
|
470
|
+
Generates a starter micro-contracts.guardrails.yaml with default check configuration. Fails if the target file already exists.
|
|
473
471
|
|
|
474
472
|
**Usage:**
|
|
475
473
|
|
|
@@ -477,18 +475,18 @@ Generates a starter guardrails.yaml with default check configuration. Fails if t
|
|
|
477
475
|
micro-contracts guardrails-init
|
|
478
476
|
```
|
|
479
477
|
```
|
|
480
|
-
micro-contracts guardrails-init -o custom-guardrails.yaml
|
|
478
|
+
micro-contracts guardrails-init -o custom-micro-contracts.guardrails.yaml
|
|
481
479
|
```
|
|
482
480
|
|
|
483
481
|
#### Options
|
|
484
482
|
|
|
485
483
|
| Option | Aliases | Required | Default | Description |
|
|
486
484
|
|---|---|---|---|---|
|
|
487
|
-
| `--output` | -o | No | `"guardrails.yaml"` | Output path for guardrails.
|
|
485
|
+
| `--output` | -o | No | `"micro-contracts.guardrails.yaml"` | Output path for the guardrails configuration. |
|
|
488
486
|
|
|
489
487
|
#### Exit Codes
|
|
490
488
|
|
|
491
|
-
**Exit 0:**
|
|
489
|
+
**Exit 0:** Guardrails configuration created successfully.
|
|
492
490
|
|
|
493
491
|
- **stdout:** format=`text`
|
|
494
492
|
|
|
@@ -781,7 +779,7 @@ x-agent:
|
|
|
781
779
|
|
|
782
780
|
Audit guardrails configuration for drift and lint coverage.
|
|
783
781
|
|
|
784
|
-
Checks that guardrails.yaml configuration covers all generated output directories for drift detection and that OpenAPI lint rules are properly configured. Note: file permission and editing checks have been moved to artifact-contracts. Requires agent-contracts-runtime.
|
|
782
|
+
Checks that micro-contracts.guardrails.yaml configuration covers all generated output directories for drift detection and that OpenAPI lint rules are properly configured. Note: file permission and editing checks have been moved to artifact-contracts. Requires agent-contracts-runtime.
|
|
785
783
|
|
|
786
784
|
**Usage:**
|
|
787
785
|
|
|
@@ -797,7 +795,7 @@ micro-contracts audit-guardrails --adapter mock --report-format json
|
|
|
797
795
|
| Option | Aliases | Required | Default | Description |
|
|
798
796
|
|---|---|---|---|---|
|
|
799
797
|
| `--config` | -c | No | | Path to config file (micro-contracts.config.yaml). |
|
|
800
|
-
| `--guardrails` | -g | No | | Path to guardrails.yaml. |
|
|
798
|
+
| `--guardrails` | -g | No | | Path to micro-contracts.guardrails.yaml. |
|
|
801
799
|
| `--adapter` | -a | No | | SDK adapter to use for LLM execution. |
|
|
802
800
|
| `--model` | | No | | LLM model override. |
|
|
803
801
|
| `--fail-on` | | No | `"error"` | Minimum severity that causes a non-zero exit. |
|
|
@@ -815,7 +813,7 @@ micro-contracts audit-guardrails --adapter mock --report-format json
|
|
|
815
813
|
|
|
816
814
|
- **stderr:** format=`text`
|
|
817
815
|
|
|
818
|
-
**Exit 3:** Input validation failed (guardrails.yaml not found).
|
|
816
|
+
**Exit 3:** Input validation failed (micro-contracts.guardrails.yaml not found).
|
|
819
817
|
|
|
820
818
|
- **stderr:** format=`text`
|
|
821
819
|
|
|
@@ -38,7 +38,7 @@ The following diagram illustrates the overall architecture of the guardrails sys
|
|
|
38
38
|
| **4** | Code Quality | `server/**`, `frontend/**` | Type errors, lint issues, failing tests |
|
|
39
39
|
| **5** | Doc & Architectural Consistency | `docs/**`, all code | Doc/code mismatch, broken references, architecture drift |
|
|
40
40
|
|
|
41
|
-
Checks are executed in gate order (G1 → G2 → ... → G5), and within the same gate, checks run in the order they are defined in `guardrails.yaml`.
|
|
41
|
+
Checks are executed in gate order (G1 → G2 → ... → G5), and within the same gate, checks run in the order they are defined in `micro-contracts.guardrails.yaml`.
|
|
42
42
|
|
|
43
43
|
---
|
|
44
44
|
|
|
@@ -60,7 +60,7 @@ Options:
|
|
|
60
60
|
--gate <gates> Run checks for specific gates only (comma-separated, 1-5)
|
|
61
61
|
-v, --verbose Enable verbose output (groups by gate)
|
|
62
62
|
--fix Auto-fix issues where possible
|
|
63
|
-
-g, --guardrails <path> Path to guardrails.yaml
|
|
63
|
+
-g, --guardrails <path> Path to micro-contracts.guardrails.yaml
|
|
64
64
|
-d, --generated-dir <path> Path to generated files directory (default: "packages/")
|
|
65
65
|
--changed-files <path> Path to file containing list of changed files (for CI)
|
|
66
66
|
--list List available checks with gate assignments
|
|
@@ -100,7 +100,7 @@ Options:
|
|
|
100
100
|
-v, --verbose Enable verbose output
|
|
101
101
|
--skip <checks> Skip specific checks (comma-separated)
|
|
102
102
|
--continue-on-error Continue running even if a step fails
|
|
103
|
-
-g, --guardrails <path> Path to guardrails.yaml
|
|
103
|
+
-g, --guardrails <path> Path to micro-contracts.guardrails.yaml
|
|
104
104
|
-c, --config <path> Path to config file (micro-contracts.config.yaml)
|
|
105
105
|
-d, --generated-dir <path> Path to generated files directory (default: "packages/")
|
|
106
106
|
--no-manifest Skip manifest generation
|
package/docs/screen-spec.md
CHANGED
|
@@ -106,10 +106,10 @@ modules:
|
|
|
106
106
|
enabled: false # Not needed for screen modules
|
|
107
107
|
screen-navigation:
|
|
108
108
|
output: frontend/src/screens/navigation.generated.ts
|
|
109
|
-
template: screen-navigation.hbs
|
|
109
|
+
template: spec/default/templates/screen-navigation.hbs
|
|
110
110
|
screen-events:
|
|
111
111
|
output: frontend/src/screens/events.generated.ts
|
|
112
|
-
template: screen-events.hbs
|
|
112
|
+
template: spec/default/templates/screen-events.hbs
|
|
113
113
|
```
|
|
114
114
|
|
|
115
115
|
Effects of `screen: true`:
|
|
@@ -497,7 +497,7 @@ Add to config:
|
|
|
497
497
|
outputs:
|
|
498
498
|
screen-view-props:
|
|
499
499
|
output: frontend/src/screens/view-props.generated.ts
|
|
500
|
-
template: screen-view-props.hbs
|
|
500
|
+
template: spec/default/templates/screen-view-props.hbs
|
|
501
501
|
```
|
|
502
502
|
|
|
503
503
|
### Available Template Context
|