@agentic-sdlc-kit/contracts 0.0.0-stage → 0.8.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 +21 -0
- package/README.md +42 -2
- package/dist/agent/capability.d.ts +9 -0
- package/dist/agent/capability.d.ts.map +1 -0
- package/dist/agent/capability.js +31 -0
- package/dist/agent/capability.js.map +1 -0
- package/dist/agent/errors.d.ts +30 -0
- package/dist/agent/errors.d.ts.map +1 -0
- package/dist/agent/errors.js +62 -0
- package/dist/agent/errors.js.map +1 -0
- package/dist/agent/events.d.ts +222 -0
- package/dist/agent/events.d.ts.map +1 -0
- package/dist/agent/events.js +92 -0
- package/dist/agent/events.js.map +1 -0
- package/dist/agent/execution.d.ts +553 -0
- package/dist/agent/execution.d.ts.map +1 -0
- package/dist/agent/execution.js +229 -0
- package/dist/agent/execution.js.map +1 -0
- package/dist/agent/index.d.ts +8 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +19 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/policy.d.ts +135 -0
- package/dist/agent/policy.d.ts.map +1 -0
- package/dist/agent/policy.js +78 -0
- package/dist/agent/policy.js.map +1 -0
- package/dist/agent/provider.d.ts +82 -0
- package/dist/agent/provider.d.ts.map +1 -0
- package/dist/agent/provider.js +33 -0
- package/dist/agent/provider.js.map +1 -0
- package/dist/agent/session.d.ts +17 -0
- package/dist/agent/session.d.ts.map +1 -0
- package/dist/agent/session.js +23 -0
- package/dist/agent/session.js.map +1 -0
- package/dist/application/application-context.d.ts +512 -0
- package/dist/application/application-context.d.ts.map +1 -0
- package/dist/application/application-context.js +42 -0
- package/dist/application/application-context.js.map +1 -0
- package/dist/application/application-persistence.d.ts +846 -0
- package/dist/application/application-persistence.d.ts.map +1 -0
- package/dist/application/application-persistence.js +37 -0
- package/dist/application/application-persistence.js.map +1 -0
- package/dist/application/application-state.d.ts +89 -0
- package/dist/application/application-state.d.ts.map +1 -0
- package/dist/application/application-state.js +66 -0
- package/dist/application/application-state.js.map +1 -0
- package/dist/application/application-transitions.d.ts +23 -0
- package/dist/application/application-transitions.d.ts.map +1 -0
- package/dist/application/application-transitions.js +60 -0
- package/dist/application/application-transitions.js.map +1 -0
- package/dist/application/index.d.ts +5 -0
- package/dist/application/index.d.ts.map +1 -0
- package/dist/application/index.js +6 -0
- package/dist/application/index.js.map +1 -0
- package/dist/architecture/api-contract.d.ts +259 -0
- package/dist/architecture/api-contract.d.ts.map +1 -0
- package/dist/architecture/api-contract.js +43 -0
- package/dist/architecture/api-contract.js.map +1 -0
- package/dist/architecture/architecture-approval.d.ts +40 -0
- package/dist/architecture/architecture-approval.d.ts.map +1 -0
- package/dist/architecture/architecture-approval.js +24 -0
- package/dist/architecture/architecture-approval.js.map +1 -0
- package/dist/architecture/architecture-options.d.ts +103 -0
- package/dist/architecture/architecture-options.d.ts.map +1 -0
- package/dist/architecture/architecture-options.js +35 -0
- package/dist/architecture/architecture-options.js.map +1 -0
- package/dist/architecture/component-map.d.ts +76 -0
- package/dist/architecture/component-map.d.ts.map +1 -0
- package/dist/architecture/component-map.js +28 -0
- package/dist/architecture/component-map.js.map +1 -0
- package/dist/architecture/data-model.d.ts +252 -0
- package/dist/architecture/data-model.d.ts.map +1 -0
- package/dist/architecture/data-model.js +53 -0
- package/dist/architecture/data-model.js.map +1 -0
- package/dist/architecture/index.d.ts +8 -0
- package/dist/architecture/index.d.ts.map +1 -0
- package/dist/architecture/index.js +9 -0
- package/dist/architecture/index.js.map +1 -0
- package/dist/architecture/operational-design.d.ts +134 -0
- package/dist/architecture/operational-design.d.ts.map +1 -0
- package/dist/architecture/operational-design.js +46 -0
- package/dist/architecture/operational-design.js.map +1 -0
- package/dist/architecture/security-design.d.ts +107 -0
- package/dist/architecture/security-design.d.ts.map +1 -0
- package/dist/architecture/security-design.js +40 -0
- package/dist/architecture/security-design.js.map +1 -0
- package/dist/common/errors.d.ts +40 -0
- package/dist/common/errors.d.ts.map +1 -0
- package/dist/common/errors.js +45 -0
- package/dist/common/errors.js.map +1 -0
- package/dist/common/identifier.d.ts +12 -0
- package/dist/common/identifier.d.ts.map +1 -0
- package/dist/common/identifier.js +21 -0
- package/dist/common/identifier.js.map +1 -0
- package/dist/common/index.d.ts +4 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/index.js +5 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/result.d.ts +28 -0
- package/dist/common/result.d.ts.map +1 -0
- package/dist/common/result.js +33 -0
- package/dist/common/result.js.map +1 -0
- package/dist/evaluation/benchmark.d.ts +88 -0
- package/dist/evaluation/benchmark.d.ts.map +1 -0
- package/dist/evaluation/benchmark.js +34 -0
- package/dist/evaluation/benchmark.js.map +1 -0
- package/dist/evaluation/index.d.ts +3 -0
- package/dist/evaluation/index.d.ts.map +1 -0
- package/dist/evaluation/index.js +4 -0
- package/dist/evaluation/index.js.map +1 -0
- package/dist/evaluation/metrics.d.ts +164 -0
- package/dist/evaluation/metrics.d.ts.map +1 -0
- package/dist/evaluation/metrics.js +64 -0
- package/dist/evaluation/metrics.js.map +1 -0
- package/dist/evolution/experiment.d.ts +85 -0
- package/dist/evolution/experiment.d.ts.map +1 -0
- package/dist/evolution/experiment.js +52 -0
- package/dist/evolution/experiment.js.map +1 -0
- package/dist/evolution/improvement-hypothesis.d.ts +98 -0
- package/dist/evolution/improvement-hypothesis.d.ts.map +1 -0
- package/dist/evolution/improvement-hypothesis.js +59 -0
- package/dist/evolution/improvement-hypothesis.js.map +1 -0
- package/dist/evolution/index.d.ts +3 -0
- package/dist/evolution/index.d.ts.map +1 -0
- package/dist/evolution/index.js +4 -0
- package/dist/evolution/index.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/installer/index.d.ts +4 -0
- package/dist/installer/index.d.ts.map +1 -0
- package/dist/installer/index.js +5 -0
- package/dist/installer/index.js.map +1 -0
- package/dist/installer/install-plan.d.ts +168 -0
- package/dist/installer/install-plan.d.ts.map +1 -0
- package/dist/installer/install-plan.js +40 -0
- package/dist/installer/install-plan.js.map +1 -0
- package/dist/installer/ownership-manifest.d.ts +78 -0
- package/dist/installer/ownership-manifest.d.ts.map +1 -0
- package/dist/installer/ownership-manifest.js +30 -0
- package/dist/installer/ownership-manifest.js.map +1 -0
- package/dist/installer/package-manifest.d.ts +55 -0
- package/dist/installer/package-manifest.d.ts.map +1 -0
- package/dist/installer/package-manifest.js +46 -0
- package/dist/installer/package-manifest.js.map +1 -0
- package/dist/learning/engineering-lesson.d.ts +84 -0
- package/dist/learning/engineering-lesson.d.ts.map +1 -0
- package/dist/learning/engineering-lesson.js +47 -0
- package/dist/learning/engineering-lesson.js.map +1 -0
- package/dist/learning/engineering-memory.d.ts +66 -0
- package/dist/learning/engineering-memory.d.ts.map +1 -0
- package/dist/learning/engineering-memory.js +44 -0
- package/dist/learning/engineering-memory.js.map +1 -0
- package/dist/learning/experience-episode.d.ts +176 -0
- package/dist/learning/experience-episode.d.ts.map +1 -0
- package/dist/learning/experience-episode.js +68 -0
- package/dist/learning/experience-episode.js.map +1 -0
- package/dist/learning/experience.d.ts +68 -0
- package/dist/learning/experience.d.ts.map +1 -0
- package/dist/learning/experience.js +22 -0
- package/dist/learning/experience.js.map +1 -0
- package/dist/learning/hypothesis.d.ts +57 -0
- package/dist/learning/hypothesis.d.ts.map +1 -0
- package/dist/learning/hypothesis.js +27 -0
- package/dist/learning/hypothesis.js.map +1 -0
- package/dist/learning/index.d.ts +8 -0
- package/dist/learning/index.d.ts.map +1 -0
- package/dist/learning/index.js +9 -0
- package/dist/learning/index.js.map +1 -0
- package/dist/learning/memory.d.ts +42 -0
- package/dist/learning/memory.d.ts.map +1 -0
- package/dist/learning/memory.js +20 -0
- package/dist/learning/memory.js.map +1 -0
- package/dist/learning/promotion.d.ts +31 -0
- package/dist/learning/promotion.d.ts.map +1 -0
- package/dist/learning/promotion.js +16 -0
- package/dist/learning/promotion.js.map +1 -0
- package/dist/maintenance/bug-fix-workflow.d.ts +57 -0
- package/dist/maintenance/bug-fix-workflow.d.ts.map +1 -0
- package/dist/maintenance/bug-fix-workflow.js +100 -0
- package/dist/maintenance/bug-fix-workflow.js.map +1 -0
- package/dist/maintenance/bug-report.d.ts +62 -0
- package/dist/maintenance/bug-report.d.ts.map +1 -0
- package/dist/maintenance/bug-report.js +49 -0
- package/dist/maintenance/bug-report.js.map +1 -0
- package/dist/maintenance/index.d.ts +6 -0
- package/dist/maintenance/index.d.ts.map +1 -0
- package/dist/maintenance/index.js +7 -0
- package/dist/maintenance/index.js.map +1 -0
- package/dist/maintenance/performance-baseline.d.ts +80 -0
- package/dist/maintenance/performance-baseline.d.ts.map +1 -0
- package/dist/maintenance/performance-baseline.js +32 -0
- package/dist/maintenance/performance-baseline.js.map +1 -0
- package/dist/maintenance/refactor-contract.d.ts +158 -0
- package/dist/maintenance/refactor-contract.d.ts.map +1 -0
- package/dist/maintenance/refactor-contract.js +65 -0
- package/dist/maintenance/refactor-contract.js.map +1 -0
- package/dist/maintenance/refactor-workflow.d.ts +79 -0
- package/dist/maintenance/refactor-workflow.d.ts.map +1 -0
- package/dist/maintenance/refactor-workflow.js +100 -0
- package/dist/maintenance/refactor-workflow.js.map +1 -0
- package/dist/observer/event-schema.d.ts +49 -0
- package/dist/observer/event-schema.d.ts.map +1 -0
- package/dist/observer/event-schema.js +48 -0
- package/dist/observer/event-schema.js.map +1 -0
- package/dist/observer/index.d.ts +5 -0
- package/dist/observer/index.d.ts.map +1 -0
- package/dist/observer/index.js +6 -0
- package/dist/observer/index.js.map +1 -0
- package/dist/observer/journal.d.ts +83 -0
- package/dist/observer/journal.d.ts.map +1 -0
- package/dist/observer/journal.js +76 -0
- package/dist/observer/journal.js.map +1 -0
- package/dist/observer/retention.d.ts +25 -0
- package/dist/observer/retention.d.ts.map +1 -0
- package/dist/observer/retention.js +21 -0
- package/dist/observer/retention.js.map +1 -0
- package/dist/observer/run-summary.d.ts +260 -0
- package/dist/observer/run-summary.d.ts.map +1 -0
- package/dist/observer/run-summary.js +32 -0
- package/dist/observer/run-summary.js.map +1 -0
- package/dist/patterns/index.d.ts +2 -0
- package/dist/patterns/index.d.ts.map +1 -0
- package/dist/patterns/index.js +3 -0
- package/dist/patterns/index.js.map +1 -0
- package/dist/patterns/pattern.d.ts +106 -0
- package/dist/patterns/pattern.d.ts.map +1 -0
- package/dist/patterns/pattern.js +69 -0
- package/dist/patterns/pattern.js.map +1 -0
- package/dist/planning/index.d.ts +2 -0
- package/dist/planning/index.d.ts.map +1 -0
- package/dist/planning/index.js +3 -0
- package/dist/planning/index.js.map +1 -0
- package/dist/planning/task.d.ts +178 -0
- package/dist/planning/task.d.ts.map +1 -0
- package/dist/planning/task.js +35 -0
- package/dist/planning/task.js.map +1 -0
- package/dist/policy/index.d.ts +2 -0
- package/dist/policy/index.d.ts.map +1 -0
- package/dist/policy/index.js +3 -0
- package/dist/policy/index.js.map +1 -0
- package/dist/policy/policy.d.ts +83 -0
- package/dist/policy/policy.d.ts.map +1 -0
- package/dist/policy/policy.js +57 -0
- package/dist/policy/policy.js.map +1 -0
- package/dist/product/index.d.ts +5 -0
- package/dist/product/index.d.ts.map +1 -0
- package/dist/product/index.js +6 -0
- package/dist/product/index.js.map +1 -0
- package/dist/product/mvp-scope.d.ts +25 -0
- package/dist/product/mvp-scope.d.ts.map +1 -0
- package/dist/product/mvp-scope.js +18 -0
- package/dist/product/mvp-scope.js.map +1 -0
- package/dist/product/product-brief.d.ts +94 -0
- package/dist/product/product-brief.d.ts.map +1 -0
- package/dist/product/product-brief.js +44 -0
- package/dist/product/product-brief.js.map +1 -0
- package/dist/product/requirements.d.ts +251 -0
- package/dist/product/requirements.d.ts.map +1 -0
- package/dist/product/requirements.js +50 -0
- package/dist/product/requirements.js.map +1 -0
- package/dist/product/traceability.d.ts +50 -0
- package/dist/product/traceability.d.ts.map +1 -0
- package/dist/product/traceability.js +20 -0
- package/dist/product/traceability.js.map +1 -0
- package/dist/project/index.d.ts +3 -0
- package/dist/project/index.d.ts.map +1 -0
- package/dist/project/index.js +4 -0
- package/dist/project/index.js.map +1 -0
- package/dist/project/project-profile.d.ts +79 -0
- package/dist/project/project-profile.d.ts.map +1 -0
- package/dist/project/project-profile.js +53 -0
- package/dist/project/project-profile.js.map +1 -0
- package/dist/project/repository-scan.d.ts +82 -0
- package/dist/project/repository-scan.d.ts.map +1 -0
- package/dist/project/repository-scan.js +29 -0
- package/dist/project/repository-scan.js.map +1 -0
- package/dist/routing/capability-registry.d.ts +87 -0
- package/dist/routing/capability-registry.d.ts.map +1 -0
- package/dist/routing/capability-registry.js +26 -0
- package/dist/routing/capability-registry.js.map +1 -0
- package/dist/routing/escalation.d.ts +25 -0
- package/dist/routing/escalation.d.ts.map +1 -0
- package/dist/routing/escalation.js +21 -0
- package/dist/routing/escalation.js.map +1 -0
- package/dist/routing/index.d.ts +5 -0
- package/dist/routing/index.d.ts.map +1 -0
- package/dist/routing/index.js +6 -0
- package/dist/routing/index.js.map +1 -0
- package/dist/routing/routing-policy.d.ts +103 -0
- package/dist/routing/routing-policy.d.ts.map +1 -0
- package/dist/routing/routing-policy.js +32 -0
- package/dist/routing/routing-policy.js.map +1 -0
- package/dist/routing/routing-request.d.ts +63 -0
- package/dist/routing/routing-request.d.ts.map +1 -0
- package/dist/routing/routing-request.js +46 -0
- package/dist/routing/routing-request.js.map +1 -0
- package/dist/runtime-guard/action-classification.d.ts +54 -0
- package/dist/runtime-guard/action-classification.d.ts.map +1 -0
- package/dist/runtime-guard/action-classification.js +90 -0
- package/dist/runtime-guard/action-classification.js.map +1 -0
- package/dist/runtime-guard/audit-event.d.ts +98 -0
- package/dist/runtime-guard/audit-event.d.ts.map +1 -0
- package/dist/runtime-guard/audit-event.js +45 -0
- package/dist/runtime-guard/audit-event.js.map +1 -0
- package/dist/runtime-guard/index.d.ts +4 -0
- package/dist/runtime-guard/index.d.ts.map +1 -0
- package/dist/runtime-guard/index.js +5 -0
- package/dist/runtime-guard/index.js.map +1 -0
- package/dist/runtime-guard/policy-schema.d.ts +139 -0
- package/dist/runtime-guard/policy-schema.d.ts.map +1 -0
- package/dist/runtime-guard/policy-schema.js +50 -0
- package/dist/runtime-guard/policy-schema.js.map +1 -0
- package/dist/scaffolding/index.d.ts +3 -0
- package/dist/scaffolding/index.d.ts.map +1 -0
- package/dist/scaffolding/index.js +4 -0
- package/dist/scaffolding/index.js.map +1 -0
- package/dist/scaffolding/scaffold-contract.d.ts +528 -0
- package/dist/scaffolding/scaffold-contract.d.ts.map +1 -0
- package/dist/scaffolding/scaffold-contract.js +50 -0
- package/dist/scaffolding/scaffold-contract.js.map +1 -0
- package/dist/scaffolding/template-manifest.d.ts +105 -0
- package/dist/scaffolding/template-manifest.d.ts.map +1 -0
- package/dist/scaffolding/template-manifest.js +44 -0
- package/dist/scaffolding/template-manifest.js.map +1 -0
- package/dist/secret-guard/detection-rule.d.ts +33 -0
- package/dist/secret-guard/detection-rule.d.ts.map +1 -0
- package/dist/secret-guard/detection-rule.js +109 -0
- package/dist/secret-guard/detection-rule.js.map +1 -0
- package/dist/secret-guard/finding.d.ts +89 -0
- package/dist/secret-guard/finding.d.ts.map +1 -0
- package/dist/secret-guard/finding.js +85 -0
- package/dist/secret-guard/finding.js.map +1 -0
- package/dist/secret-guard/index.d.ts +5 -0
- package/dist/secret-guard/index.d.ts.map +1 -0
- package/dist/secret-guard/index.js +6 -0
- package/dist/secret-guard/index.js.map +1 -0
- package/dist/secret-guard/redaction-policy.d.ts +26 -0
- package/dist/secret-guard/redaction-policy.d.ts.map +1 -0
- package/dist/secret-guard/redaction-policy.js +30 -0
- package/dist/secret-guard/redaction-policy.js.map +1 -0
- package/dist/secret-guard/scanner-failure.d.ts +59 -0
- package/dist/secret-guard/scanner-failure.d.ts.map +1 -0
- package/dist/secret-guard/scanner-failure.js +40 -0
- package/dist/secret-guard/scanner-failure.js.map +1 -0
- package/dist/specification/index.d.ts +2 -0
- package/dist/specification/index.d.ts.map +1 -0
- package/dist/specification/index.js +3 -0
- package/dist/specification/index.js.map +1 -0
- package/dist/specification/specification.d.ts +229 -0
- package/dist/specification/specification.d.ts.map +1 -0
- package/dist/specification/specification.js +67 -0
- package/dist/specification/specification.js.map +1 -0
- package/dist/stack-pack/index.d.ts +2 -0
- package/dist/stack-pack/index.d.ts.map +1 -0
- package/dist/stack-pack/index.js +3 -0
- package/dist/stack-pack/index.js.map +1 -0
- package/dist/stack-pack/manifest.d.ts +88 -0
- package/dist/stack-pack/manifest.d.ts.map +1 -0
- package/dist/stack-pack/manifest.js +51 -0
- package/dist/stack-pack/manifest.js.map +1 -0
- package/dist/verification/index.d.ts +2 -0
- package/dist/verification/index.d.ts.map +1 -0
- package/dist/verification/index.js +3 -0
- package/dist/verification/index.js.map +1 -0
- package/dist/verification/report.d.ts +95 -0
- package/dist/verification/report.d.ts.map +1 -0
- package/dist/verification/report.js +57 -0
- package/dist/verification/report.js.map +1 -0
- package/dist/workflow/index.d.ts +3 -0
- package/dist/workflow/index.d.ts.map +1 -0
- package/dist/workflow/index.js +4 -0
- package/dist/workflow/index.js.map +1 -0
- package/dist/workflow/next-action.d.ts +130 -0
- package/dist/workflow/next-action.d.ts.map +1 -0
- package/dist/workflow/next-action.js +92 -0
- package/dist/workflow/next-action.js.map +1 -0
- package/dist/workflow/workflow.d.ts +68 -0
- package/dist/workflow/workflow.d.ts.map +1 -0
- package/dist/workflow/workflow.js +33 -0
- package/dist/workflow/workflow.js.map +1 -0
- package/package.json +31 -3
- package/src/agent/agent.test.ts +451 -0
- package/src/agent/capability.ts +35 -0
- package/src/agent/errors.ts +69 -0
- package/src/agent/events.ts +107 -0
- package/src/agent/execution.ts +275 -0
- package/src/agent/index.ts +19 -0
- package/src/agent/policy.ts +82 -0
- package/src/agent/provider.ts +124 -0
- package/src/agent/session.ts +29 -0
- package/src/application/application-context.ts +47 -0
- package/src/application/application-persistence.ts +44 -0
- package/src/application/application-state.test.ts +107 -0
- package/src/application/application-state.ts +81 -0
- package/src/application/application-transitions.ts +71 -0
- package/src/application/index.ts +5 -0
- package/src/architecture/api-contract.ts +56 -0
- package/src/architecture/architecture-approval.ts +27 -0
- package/src/architecture/architecture-options.ts +42 -0
- package/src/architecture/architecture.test.ts +263 -0
- package/src/architecture/component-map.ts +35 -0
- package/src/architecture/data-model.ts +66 -0
- package/src/architecture/index.ts +8 -0
- package/src/architecture/operational-design.ts +55 -0
- package/src/architecture/security-design.ts +47 -0
- package/src/common/errors.test.ts +46 -0
- package/src/common/errors.ts +114 -0
- package/src/common/identifier.test.ts +51 -0
- package/src/common/identifier.ts +33 -0
- package/src/common/index.ts +4 -0
- package/src/common/result.test.ts +52 -0
- package/src/common/result.ts +50 -0
- package/src/evaluation/benchmark.ts +42 -0
- package/src/evaluation/index.ts +3 -0
- package/src/evaluation/metrics.ts +76 -0
- package/src/evolution/experiment.ts +61 -0
- package/src/evolution/improvement-hypothesis.ts +67 -0
- package/src/evolution/index.ts +3 -0
- package/src/index.test.ts +54 -0
- package/src/index.ts +53 -0
- package/src/installer/index.ts +4 -0
- package/src/installer/install-plan.ts +49 -0
- package/src/installer/ownership-manifest.ts +36 -0
- package/src/installer/package-manifest.ts +54 -0
- package/src/learning/engineering-lesson.ts +55 -0
- package/src/learning/engineering-memory.ts +51 -0
- package/src/learning/experience-episode.ts +76 -0
- package/src/learning/experience.ts +27 -0
- package/src/learning/hypothesis.ts +33 -0
- package/src/learning/index.ts +8 -0
- package/src/learning/memory.ts +25 -0
- package/src/learning/promotion.ts +19 -0
- package/src/maintenance/bug-fix-workflow.ts +119 -0
- package/src/maintenance/bug-report.ts +58 -0
- package/src/maintenance/index.ts +6 -0
- package/src/maintenance/maintenance.test.ts +219 -0
- package/src/maintenance/performance-baseline.ts +35 -0
- package/src/maintenance/refactor-contract.ts +77 -0
- package/src/maintenance/refactor-workflow.ts +121 -0
- package/src/observer/event-schema.ts +54 -0
- package/src/observer/index.ts +5 -0
- package/src/observer/journal.test.ts +73 -0
- package/src/observer/journal.ts +84 -0
- package/src/observer/retention.ts +24 -0
- package/src/observer/run-summary.ts +37 -0
- package/src/patterns/index.ts +2 -0
- package/src/patterns/pattern.ts +80 -0
- package/src/planning/index.ts +2 -0
- package/src/planning/task.ts +47 -0
- package/src/policy/index.ts +2 -0
- package/src/policy/policy.test.ts +50 -0
- package/src/policy/policy.ts +67 -0
- package/src/product/index.ts +5 -0
- package/src/product/mvp-scope.ts +21 -0
- package/src/product/product-brief.test.ts +108 -0
- package/src/product/product-brief.ts +53 -0
- package/src/product/requirements.ts +59 -0
- package/src/product/traceability.ts +25 -0
- package/src/project/index.ts +3 -0
- package/src/project/project-profile.test.ts +98 -0
- package/src/project/project-profile.ts +65 -0
- package/src/project/repository-scan.ts +34 -0
- package/src/routing/capability-registry.ts +31 -0
- package/src/routing/escalation.ts +24 -0
- package/src/routing/index.ts +5 -0
- package/src/routing/routing-policy.ts +38 -0
- package/src/routing/routing-request.ts +55 -0
- package/src/runtime-guard/action-classification.ts +99 -0
- package/src/runtime-guard/audit-event.ts +49 -0
- package/src/runtime-guard/index.ts +4 -0
- package/src/runtime-guard/policy-schema.ts +56 -0
- package/src/runtime-guard/runtime-guard.test.ts +147 -0
- package/src/scaffolding/index.ts +3 -0
- package/src/scaffolding/scaffold-contract.test.ts +107 -0
- package/src/scaffolding/scaffold-contract.ts +63 -0
- package/src/scaffolding/template-manifest.ts +52 -0
- package/src/secret-guard/detection-rule.ts +115 -0
- package/src/secret-guard/finding.ts +93 -0
- package/src/secret-guard/index.ts +5 -0
- package/src/secret-guard/redaction-policy.ts +34 -0
- package/src/secret-guard/scanner-failure.ts +47 -0
- package/src/secret-guard/secret-guard.test.ts +130 -0
- package/src/specification/index.ts +2 -0
- package/src/specification/specification.ts +79 -0
- package/src/stack-pack/index.ts +2 -0
- package/src/stack-pack/manifest.ts +60 -0
- package/src/verification/index.ts +2 -0
- package/src/verification/report.test.ts +91 -0
- package/src/verification/report.ts +62 -0
- package/src/workflow/index.ts +3 -0
- package/src/workflow/next-action.test.ts +101 -0
- package/src/workflow/next-action.ts +101 -0
- package/src/workflow/workflow.ts +49 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// packages/contracts/src/runtime-guard/action-classification.ts
|
|
2
|
+
//
|
|
3
|
+
// Action classification contract (M10 — M10-01).
|
|
4
|
+
//
|
|
5
|
+
// Every destructive or sensitive operation the kit (or its host runtime)
|
|
6
|
+
// may perform is classified into one of these categories. The policy
|
|
7
|
+
// evaluator consumes the classification to decide allow/deny/require-approval.
|
|
8
|
+
//
|
|
9
|
+
// This extends the M1 baseline PolicyAction enum (which had 8 entries) with
|
|
10
|
+
// a richer classification that carries scope and impact. The M1
|
|
11
|
+
// PolicyAction is preserved for back-compat.
|
|
12
|
+
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
|
|
15
|
+
export const ActionCategorySchema = z.enum([
|
|
16
|
+
// File operations:
|
|
17
|
+
'file.read',
|
|
18
|
+
'file.create',
|
|
19
|
+
'file.modify',
|
|
20
|
+
'file.delete',
|
|
21
|
+
'file.bulk-modify',
|
|
22
|
+
'file.sensitive-modify', // config, env, secrets
|
|
23
|
+
// Database:
|
|
24
|
+
'db.read',
|
|
25
|
+
'db.migrate',
|
|
26
|
+
'db.mutate-dev',
|
|
27
|
+
'db.mutate-production',
|
|
28
|
+
// Git:
|
|
29
|
+
'git.read',
|
|
30
|
+
'git.commit',
|
|
31
|
+
'git.push',
|
|
32
|
+
'git.force-push',
|
|
33
|
+
'git.rebase',
|
|
34
|
+
// Dependency:
|
|
35
|
+
'dependency.add',
|
|
36
|
+
'dependency.remove',
|
|
37
|
+
'dependency.upgrade',
|
|
38
|
+
// Release / deploy:
|
|
39
|
+
'release.tag',
|
|
40
|
+
'release.publish',
|
|
41
|
+
'release.deploy',
|
|
42
|
+
// Network:
|
|
43
|
+
'network.fetch',
|
|
44
|
+
'network.mcp-call',
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
export const ActionImpactSchema = z.enum([
|
|
48
|
+
'none', // read-only
|
|
49
|
+
'local', // affects only the working copy
|
|
50
|
+
'shared-branch', // affects other contributors
|
|
51
|
+
'production', // affects end users or production data
|
|
52
|
+
]);
|
|
53
|
+
|
|
54
|
+
export const ClassifiedActionSchema = z.object({
|
|
55
|
+
category: ActionCategorySchema,
|
|
56
|
+
impact: ActionImpactSchema,
|
|
57
|
+
// Structured scope: file paths, db names, etc. — never secret values.
|
|
58
|
+
scope: z
|
|
59
|
+
.object({
|
|
60
|
+
fileCount: z.number().int().nonnegative().optional(),
|
|
61
|
+
paths: z.array(z.string()).default([]),
|
|
62
|
+
branch: z.string().optional(),
|
|
63
|
+
environment: z.string().optional(),
|
|
64
|
+
})
|
|
65
|
+
.default({}),
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export type ActionCategory = z.infer<typeof ActionCategorySchema>;
|
|
69
|
+
export type ActionImpact = z.infer<typeof ActionImpactSchema>;
|
|
70
|
+
export type ClassifiedAction = z.infer<typeof ClassifiedActionSchema>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Heuristic: is this action destructive?
|
|
74
|
+
* Used by the policy evaluator to decide whether to require approval.
|
|
75
|
+
*/
|
|
76
|
+
export function isDestructive(action: ClassifiedAction): boolean {
|
|
77
|
+
const destructiveCategories: ReadonlyArray<ActionCategory> = [
|
|
78
|
+
'file.delete',
|
|
79
|
+
'file.bulk-modify',
|
|
80
|
+
'file.sensitive-modify',
|
|
81
|
+
'db.migrate',
|
|
82
|
+
'db.mutate-dev',
|
|
83
|
+
'db.mutate-production',
|
|
84
|
+
'git.force-push',
|
|
85
|
+
'git.rebase',
|
|
86
|
+
'dependency.remove',
|
|
87
|
+
'release.tag',
|
|
88
|
+
'release.publish',
|
|
89
|
+
'release.deploy',
|
|
90
|
+
];
|
|
91
|
+
return destructiveCategories.includes(action.category);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Heuristic: is this action production-impacting?
|
|
96
|
+
*/
|
|
97
|
+
export function isProduction(action: ClassifiedAction): boolean {
|
|
98
|
+
return action.impact === 'production' || action.category === 'db.mutate-production';
|
|
99
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// packages/contracts/src/runtime-guard/audit-event.ts
|
|
2
|
+
//
|
|
3
|
+
// Audit event contract (M10 — M10-07).
|
|
4
|
+
//
|
|
5
|
+
// Every policy decision produces an audit event. Audit events are
|
|
6
|
+
// persisted under .ai-kit/reports/audit/ and never contain secret values.
|
|
7
|
+
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
import { ActionCategorySchema, ActionImpactSchema } from './action-classification.js';
|
|
10
|
+
import { VerdictSchema } from './policy-schema.js';
|
|
11
|
+
|
|
12
|
+
export const AUDIT_EVENT_SCHEMA_VERSION = 1 as const;
|
|
13
|
+
|
|
14
|
+
export const AuditEventSchema = z.object({
|
|
15
|
+
schemaVersion: z.literal(AUDIT_EVENT_SCHEMA_VERSION),
|
|
16
|
+
id: z.string(),
|
|
17
|
+
at: z.string(), // ISO 8601
|
|
18
|
+
runId: z.string().optional(),
|
|
19
|
+
// The action that was evaluated.
|
|
20
|
+
action: z.object({
|
|
21
|
+
category: ActionCategorySchema,
|
|
22
|
+
impact: ActionImpactSchema,
|
|
23
|
+
scopeSummary: z.string(), // human-readable; never raw secret values
|
|
24
|
+
}),
|
|
25
|
+
// The verdict the evaluator returned.
|
|
26
|
+
verdict: VerdictSchema,
|
|
27
|
+
// The rule that matched (if any).
|
|
28
|
+
matchedRuleId: z.string().optional(),
|
|
29
|
+
// Whether an approval was granted (if verdict was require-approval).
|
|
30
|
+
approval: z
|
|
31
|
+
.object({
|
|
32
|
+
approver: z.string(),
|
|
33
|
+
grantedAt: z.string(),
|
|
34
|
+
rationale: z.string(),
|
|
35
|
+
})
|
|
36
|
+
.optional(),
|
|
37
|
+
// Whether the action was a bypass (explicit user override).
|
|
38
|
+
bypass: z
|
|
39
|
+
.object({
|
|
40
|
+
flag: z.string(),
|
|
41
|
+
setUser: z.string(),
|
|
42
|
+
scope: z.string(),
|
|
43
|
+
})
|
|
44
|
+
.optional(),
|
|
45
|
+
// The outcome: did the action actually execute?
|
|
46
|
+
outcome: z.enum(['executed', 'denied', 'deferred', 'interrupted']),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export type AuditEvent = z.infer<typeof AuditEventSchema>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// packages/contracts/src/runtime-guard/policy-schema.ts
|
|
2
|
+
//
|
|
3
|
+
// Versioned policy configuration (M10 — M10-03).
|
|
4
|
+
//
|
|
5
|
+
// A policy pack is a versioned collection of rules. Each rule maps an
|
|
6
|
+
// action category to a verdict, optionally gated by scope thresholds
|
|
7
|
+
// (e.g., "allow file.delete if scopeFileCount <= 5, else require-approval").
|
|
8
|
+
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { ActionCategorySchema, ActionImpactSchema } from './action-classification.js';
|
|
11
|
+
// Reuse the M1 VerdictSchema so consumers see a single verdict type across
|
|
12
|
+
// the policy/policy.ts (M1 baseline) and runtime-guard/policy-schema.ts
|
|
13
|
+
// (M10 versioned policy pack) surfaces. We import the value (zod schema)
|
|
14
|
+
// and re-export it for ergonomic single-source imports.
|
|
15
|
+
import { VerdictSchema } from '../policy/policy.js';
|
|
16
|
+
export { VerdictSchema } from '../policy/policy.js';
|
|
17
|
+
|
|
18
|
+
export const POLICY_SCHEMA_VERSION = 1 as const;
|
|
19
|
+
|
|
20
|
+
export const PolicyRuleSchema = z.object({
|
|
21
|
+
id: z.string(),
|
|
22
|
+
// The category this rule applies to. Use "*" to match all categories.
|
|
23
|
+
category: z.union([ActionCategorySchema, z.literal('*')]),
|
|
24
|
+
// The impact this rule applies to. Use "*" to match all impacts.
|
|
25
|
+
impact: z.union([ActionImpactSchema, z.literal('*')]),
|
|
26
|
+
verdict: VerdictSchema,
|
|
27
|
+
// Optional scope threshold: if set, the rule only applies when
|
|
28
|
+
// scope.fileCount (or another scope field) exceeds the threshold.
|
|
29
|
+
threshold: z
|
|
30
|
+
.object({
|
|
31
|
+
field: z.enum(['fileCount']),
|
|
32
|
+
op: z.enum(['gt', 'gte', 'lt', 'lte']),
|
|
33
|
+
value: z.number().int().nonnegative(),
|
|
34
|
+
})
|
|
35
|
+
.optional(),
|
|
36
|
+
// Human-readable reason included in the audit event.
|
|
37
|
+
reason: z.string().min(1),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export const PolicyPackSchema = z.object({
|
|
41
|
+
schemaVersion: z.literal(POLICY_SCHEMA_VERSION),
|
|
42
|
+
id: z.string(),
|
|
43
|
+
version: z.string().regex(/^\d+\.\d+\.\d+$/, 'semver'),
|
|
44
|
+
name: z.string().min(1),
|
|
45
|
+
description: z.string().min(1),
|
|
46
|
+
rules: z.array(PolicyRuleSchema),
|
|
47
|
+
// Default verdict for actions not matched by any rule.
|
|
48
|
+
defaultVerdict: VerdictSchema.default('require-approval'),
|
|
49
|
+
// Whether this policy applies in non-interactive mode. If false, all
|
|
50
|
+
// rules are ignored in CI/daemon contexts and the defaultVerdict is
|
|
51
|
+
// used (typically "deny" for fail-closed behavior).
|
|
52
|
+
appliesNonInteractive: z.boolean().default(false),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export type PolicyRule = z.infer<typeof PolicyRuleSchema>;
|
|
56
|
+
export type PolicyPack = z.infer<typeof PolicyPackSchema>;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// packages/contracts/src/runtime-guard/runtime-guard.test.ts
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import {
|
|
4
|
+
ActionCategorySchema,
|
|
5
|
+
ClassifiedActionSchema,
|
|
6
|
+
isDestructive,
|
|
7
|
+
isProduction,
|
|
8
|
+
} from './action-classification.js';
|
|
9
|
+
import { PolicyPackSchema, PolicyRuleSchema } from './policy-schema.js';
|
|
10
|
+
import { AuditEventSchema } from './audit-event.js';
|
|
11
|
+
|
|
12
|
+
describe('ActionCategorySchema', () => {
|
|
13
|
+
it('accepts known categories', () => {
|
|
14
|
+
expect(ActionCategorySchema.safeParse('file.delete').success).toBe(true);
|
|
15
|
+
expect(ActionCategorySchema.safeParse('db.migrate').success).toBe(true);
|
|
16
|
+
expect(ActionCategorySchema.safeParse('git.force-push').success).toBe(true);
|
|
17
|
+
expect(ActionCategorySchema.safeParse('release.deploy').success).toBe(true);
|
|
18
|
+
});
|
|
19
|
+
it('rejects unknown categories', () => {
|
|
20
|
+
expect(ActionCategorySchema.safeParse('file.rename').success).toBe(false);
|
|
21
|
+
expect(ActionCategorySchema.safeParse('db.vacuum').success).toBe(false);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe('ClassifiedActionSchema', () => {
|
|
26
|
+
const action = {
|
|
27
|
+
category: 'file.delete',
|
|
28
|
+
impact: 'local',
|
|
29
|
+
scope: { fileCount: 1, paths: ['src/x.ts'] },
|
|
30
|
+
};
|
|
31
|
+
it('accepts a valid action', () => {
|
|
32
|
+
expect(ClassifiedActionSchema.safeParse(action).success).toBe(true);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe('isDestructive', () => {
|
|
37
|
+
it('flags file.delete as destructive', () => {
|
|
38
|
+
expect(isDestructive({ category: 'file.delete', impact: 'local', scope: {} })).toBe(true);
|
|
39
|
+
});
|
|
40
|
+
it('does NOT flag file.read as destructive', () => {
|
|
41
|
+
expect(isDestructive({ category: 'file.read', impact: 'none', scope: {} })).toBe(false);
|
|
42
|
+
});
|
|
43
|
+
it('flags release.deploy as destructive', () => {
|
|
44
|
+
expect(isDestructive({ category: 'release.deploy', impact: 'production', scope: {} })).toBe(
|
|
45
|
+
true,
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('isProduction', () => {
|
|
51
|
+
it('flags production-impact actions', () => {
|
|
52
|
+
expect(isProduction({ category: 'release.deploy', impact: 'production', scope: {} })).toBe(
|
|
53
|
+
true,
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
it('flags db.mutate-production regardless of impact field', () => {
|
|
57
|
+
expect(isProduction({ category: 'db.mutate-production', impact: 'local', scope: {} })).toBe(
|
|
58
|
+
true,
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
it('does NOT flag local-only actions', () => {
|
|
62
|
+
expect(isProduction({ category: 'file.create', impact: 'local', scope: {} })).toBe(false);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe('PolicyRuleSchema', () => {
|
|
67
|
+
it('accepts a rule with a threshold', () => {
|
|
68
|
+
expect(
|
|
69
|
+
PolicyRuleSchema.safeParse({
|
|
70
|
+
id: 'R-1',
|
|
71
|
+
category: 'file.delete',
|
|
72
|
+
impact: 'local',
|
|
73
|
+
verdict: 'require-approval',
|
|
74
|
+
threshold: { field: 'fileCount', op: 'gt', value: 5 },
|
|
75
|
+
reason: 'bulk deletes need approval',
|
|
76
|
+
}).success,
|
|
77
|
+
).toBe(true);
|
|
78
|
+
});
|
|
79
|
+
it('accepts a wildcard rule', () => {
|
|
80
|
+
expect(
|
|
81
|
+
PolicyRuleSchema.safeParse({
|
|
82
|
+
id: 'R-default',
|
|
83
|
+
category: '*',
|
|
84
|
+
impact: '*',
|
|
85
|
+
verdict: 'require-approval',
|
|
86
|
+
reason: 'default deny-soft',
|
|
87
|
+
}).success,
|
|
88
|
+
).toBe(true);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
describe('PolicyPackSchema', () => {
|
|
93
|
+
it('accepts a valid pack', () => {
|
|
94
|
+
expect(
|
|
95
|
+
PolicyPackSchema.safeParse({
|
|
96
|
+
schemaVersion: 1,
|
|
97
|
+
id: 'default',
|
|
98
|
+
version: '1.0.0',
|
|
99
|
+
name: 'Default Policy',
|
|
100
|
+
description: 'Baseline guardrails.',
|
|
101
|
+
rules: [],
|
|
102
|
+
defaultVerdict: 'require-approval',
|
|
103
|
+
appliesNonInteractive: false,
|
|
104
|
+
}).success,
|
|
105
|
+
).toBe(true);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe('AuditEventSchema', () => {
|
|
110
|
+
it('accepts a deny event', () => {
|
|
111
|
+
expect(
|
|
112
|
+
AuditEventSchema.safeParse({
|
|
113
|
+
schemaVersion: 1,
|
|
114
|
+
id: 'AE-1',
|
|
115
|
+
at: '2026-01-01T00:00:00.000Z',
|
|
116
|
+
action: {
|
|
117
|
+
category: 'git.force-push',
|
|
118
|
+
impact: 'shared-branch',
|
|
119
|
+
scopeSummary: 'branch=main',
|
|
120
|
+
},
|
|
121
|
+
verdict: 'deny',
|
|
122
|
+
outcome: 'denied',
|
|
123
|
+
}).success,
|
|
124
|
+
).toBe(true);
|
|
125
|
+
});
|
|
126
|
+
it('accepts an approved event', () => {
|
|
127
|
+
expect(
|
|
128
|
+
AuditEventSchema.safeParse({
|
|
129
|
+
schemaVersion: 1,
|
|
130
|
+
id: 'AE-2',
|
|
131
|
+
at: '2026-01-01T00:00:00.000Z',
|
|
132
|
+
action: {
|
|
133
|
+
category: 'db.migrate',
|
|
134
|
+
impact: 'local',
|
|
135
|
+
scopeSummary: 'env=dev',
|
|
136
|
+
},
|
|
137
|
+
verdict: 'require-approval',
|
|
138
|
+
approval: {
|
|
139
|
+
approver: 'lead',
|
|
140
|
+
grantedAt: '2026-01-01T00:00:01.000Z',
|
|
141
|
+
rationale: 'approved in standup',
|
|
142
|
+
},
|
|
143
|
+
outcome: 'executed',
|
|
144
|
+
}).success,
|
|
145
|
+
).toBe(true);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// packages/contracts/src/scaffolding/scaffold-contract.test.ts
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import {
|
|
4
|
+
ScaffoldPlanSchema,
|
|
5
|
+
ScaffoldRequestSchema,
|
|
6
|
+
ScaffoldResultSchema,
|
|
7
|
+
} from './scaffold-contract.js';
|
|
8
|
+
import { TemplateManifestSchema } from './template-manifest.js';
|
|
9
|
+
|
|
10
|
+
const validManifest = {
|
|
11
|
+
schemaVersion: 1,
|
|
12
|
+
id: 'node-typescript-api',
|
|
13
|
+
name: 'Node TypeScript API',
|
|
14
|
+
description: 'Express + TypeScript starter.',
|
|
15
|
+
version: '1.0.0',
|
|
16
|
+
stacks: ['node-typescript'],
|
|
17
|
+
variables: [{ name: 'projectName', description: 'Package name', required: true }],
|
|
18
|
+
files: [{ path: 'package.json', templated: true, preserve: false }],
|
|
19
|
+
kitCompatibility: '>=0.6.0',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
describe('TemplateManifestSchema', () => {
|
|
23
|
+
it('accepts a valid manifest', () => {
|
|
24
|
+
expect(TemplateManifestSchema.safeParse(validManifest).success).toBe(true);
|
|
25
|
+
});
|
|
26
|
+
it('rejects a non-semver version', () => {
|
|
27
|
+
expect(TemplateManifestSchema.safeParse({ ...validManifest, version: 'latest' }).success).toBe(
|
|
28
|
+
false,
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
it('rejects an invalid id (must be kebab-case)', () => {
|
|
32
|
+
expect(TemplateManifestSchema.safeParse({ ...validManifest, id: 'Node_TS' }).success).toBe(
|
|
33
|
+
false,
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const validRequest = {
|
|
39
|
+
templateId: 'node-typescript-api',
|
|
40
|
+
templateVersion: '1.0.0',
|
|
41
|
+
targetDir: '/tmp/new-app',
|
|
42
|
+
variables: { projectName: 'new-app' },
|
|
43
|
+
execute: false,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
describe('ScaffoldRequestSchema', () => {
|
|
47
|
+
it('accepts a valid request', () => {
|
|
48
|
+
expect(ScaffoldRequestSchema.safeParse(validRequest).success).toBe(true);
|
|
49
|
+
});
|
|
50
|
+
it('rejects an empty targetDir', () => {
|
|
51
|
+
expect(ScaffoldRequestSchema.safeParse({ ...validRequest, targetDir: '' }).success).toBe(false);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe('ScaffoldPlanSchema', () => {
|
|
56
|
+
it('accepts a valid plan', () => {
|
|
57
|
+
expect(
|
|
58
|
+
ScaffoldPlanSchema.safeParse({
|
|
59
|
+
schemaVersion: 1,
|
|
60
|
+
request: validRequest,
|
|
61
|
+
template: validManifest,
|
|
62
|
+
plannedOperations: [
|
|
63
|
+
{ path: 'package.json', kind: 'create' },
|
|
64
|
+
{ path: 'README.md', kind: 'create' },
|
|
65
|
+
],
|
|
66
|
+
validationErrors: [],
|
|
67
|
+
}).success,
|
|
68
|
+
).toBe(true);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
describe('ScaffoldResultSchema', () => {
|
|
73
|
+
it('accepts a valid result with executed ops and owned files', () => {
|
|
74
|
+
expect(
|
|
75
|
+
ScaffoldResultSchema.safeParse({
|
|
76
|
+
schemaVersion: 1,
|
|
77
|
+
plan: {
|
|
78
|
+
schemaVersion: 1,
|
|
79
|
+
request: validRequest,
|
|
80
|
+
template: validManifest,
|
|
81
|
+
plannedOperations: [{ path: 'package.json', kind: 'create' }],
|
|
82
|
+
validationErrors: [],
|
|
83
|
+
},
|
|
84
|
+
executedOperations: [{ path: 'package.json', kind: 'create', bytesWritten: 100 }],
|
|
85
|
+
ownedFiles: ['package.json'],
|
|
86
|
+
interrupted: false,
|
|
87
|
+
}).success,
|
|
88
|
+
).toBe(true);
|
|
89
|
+
});
|
|
90
|
+
it('accepts an interrupted result (recovery scenario)', () => {
|
|
91
|
+
expect(
|
|
92
|
+
ScaffoldResultSchema.safeParse({
|
|
93
|
+
schemaVersion: 1,
|
|
94
|
+
plan: {
|
|
95
|
+
schemaVersion: 1,
|
|
96
|
+
request: validRequest,
|
|
97
|
+
template: validManifest,
|
|
98
|
+
plannedOperations: [{ path: 'package.json', kind: 'create' }],
|
|
99
|
+
validationErrors: [],
|
|
100
|
+
},
|
|
101
|
+
executedOperations: [],
|
|
102
|
+
ownedFiles: [],
|
|
103
|
+
interrupted: true,
|
|
104
|
+
}).success,
|
|
105
|
+
).toBe(true);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// packages/contracts/src/scaffolding/scaffold-contract.ts
|
|
2
|
+
//
|
|
3
|
+
// Scaffold contract: the request to scaffold a project and the resulting
|
|
4
|
+
// plan + executed operations (M8 Phase D — M8-20, M8-22, M8-25).
|
|
5
|
+
//
|
|
6
|
+
// INVARIANTS (post-M7 roadmap §2.3 Phase D):
|
|
7
|
+
// - The scaffolder MUST show planned file operations before executing.
|
|
8
|
+
// - It MUST NOT overwrite existing files silently.
|
|
9
|
+
// - It MUST preserve user configuration (preserve: true files).
|
|
10
|
+
// - It MUST validate template variables.
|
|
11
|
+
// - It MUST record generated files.
|
|
12
|
+
// - It MUST support safe recovery from interrupted generation.
|
|
13
|
+
|
|
14
|
+
import { z } from 'zod';
|
|
15
|
+
import { TemplateManifestSchema } from './template-manifest.js';
|
|
16
|
+
|
|
17
|
+
export const FileOperationKindSchema = z.enum(['create', 'skip-existing', 'overwrite-approved']);
|
|
18
|
+
|
|
19
|
+
export const PlannedFileOperationSchema = z.object({
|
|
20
|
+
path: z.string().min(1),
|
|
21
|
+
kind: FileOperationKindSchema,
|
|
22
|
+
// If kind === "skip-existing" or "overwrite-approved", the reason.
|
|
23
|
+
reason: z.string().optional(),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const ScaffoldRequestSchema = z.object({
|
|
27
|
+
templateId: z.string(),
|
|
28
|
+
templateVersion: z.string(),
|
|
29
|
+
targetDir: z.string().min(1),
|
|
30
|
+
variables: z.record(z.string(), z.string()),
|
|
31
|
+
// Set to true to actually write files; false = dry-run, plan only.
|
|
32
|
+
execute: z.boolean().default(false),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const ScaffoldPlanSchema = z.object({
|
|
36
|
+
schemaVersion: z.literal(1),
|
|
37
|
+
request: ScaffoldRequestSchema,
|
|
38
|
+
template: TemplateManifestSchema,
|
|
39
|
+
plannedOperations: z.array(PlannedFileOperationSchema),
|
|
40
|
+
validationErrors: z.array(z.string()).default([]),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export const ScaffoldResultSchema = z.object({
|
|
44
|
+
schemaVersion: z.literal(1),
|
|
45
|
+
plan: ScaffoldPlanSchema,
|
|
46
|
+
executedOperations: z.array(
|
|
47
|
+
z.object({
|
|
48
|
+
path: z.string(),
|
|
49
|
+
kind: FileOperationKindSchema,
|
|
50
|
+
bytesWritten: z.number().int().nonnegative().optional(),
|
|
51
|
+
}),
|
|
52
|
+
),
|
|
53
|
+
// Files recorded in .ai-kit/manifest.json so future re-runs and
|
|
54
|
+
// uninstall know what the scaffold owns.
|
|
55
|
+
ownedFiles: z.array(z.string()),
|
|
56
|
+
interrupted: z.boolean().default(false),
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export type FileOperationKind = z.infer<typeof FileOperationKindSchema>;
|
|
60
|
+
export type PlannedFileOperation = z.infer<typeof PlannedFileOperationSchema>;
|
|
61
|
+
export type ScaffoldRequest = z.infer<typeof ScaffoldRequestSchema>;
|
|
62
|
+
export type ScaffoldPlan = z.infer<typeof ScaffoldPlanSchema>;
|
|
63
|
+
export type ScaffoldResult = z.infer<typeof ScaffoldResultSchema>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// packages/contracts/src/scaffolding/template-manifest.ts
|
|
2
|
+
//
|
|
3
|
+
// Template manifest contract (M8 Phase D — M8-20, M8-21).
|
|
4
|
+
//
|
|
5
|
+
// A template is a versioned project skeleton. Templates live under
|
|
6
|
+
// `templates/<name>/` and are tested as actual applications in CI. The
|
|
7
|
+
// manifest declares what the template produces, what variables it expects,
|
|
8
|
+
// and what compatibility range it supports.
|
|
9
|
+
//
|
|
10
|
+
// Per post-M7 roadmap §2.3 Phase D: "These templates should be versioned
|
|
11
|
+
// and tested as actual applications. They must not become collections of
|
|
12
|
+
// stale snippets."
|
|
13
|
+
|
|
14
|
+
import { z } from 'zod';
|
|
15
|
+
|
|
16
|
+
export const TEMPLATE_MANIFEST_SCHEMA_VERSION = 1 as const;
|
|
17
|
+
|
|
18
|
+
export const TemplateVariableSchema = z.object({
|
|
19
|
+
name: z.string().min(1),
|
|
20
|
+
description: z.string().min(1),
|
|
21
|
+
required: z.boolean(),
|
|
22
|
+
// Regex the value must match; e.g., project name format.
|
|
23
|
+
pattern: z.string().optional(),
|
|
24
|
+
defaultValue: z.string().optional(),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const TemplateManifestSchema = z.object({
|
|
28
|
+
schemaVersion: z.literal(TEMPLATE_MANIFEST_SCHEMA_VERSION),
|
|
29
|
+
id: z.string().regex(/^[a-z][a-z0-9-]*$/, 'template id must be kebab-case'),
|
|
30
|
+
name: z.string().min(1),
|
|
31
|
+
description: z.string().min(1),
|
|
32
|
+
version: z.string().regex(/^\d+\.\d+\.\d+$/, 'semver'),
|
|
33
|
+
// Stacks this template produces.
|
|
34
|
+
stacks: z.array(z.string()).min(1),
|
|
35
|
+
// Variables the template expects when rendered.
|
|
36
|
+
variables: z.array(TemplateVariableSchema).default([]),
|
|
37
|
+
// Files the template will generate (relative paths).
|
|
38
|
+
files: z.array(
|
|
39
|
+
z.object({
|
|
40
|
+
path: z.string().min(1),
|
|
41
|
+
// True if the file is a template (needs variable substitution).
|
|
42
|
+
templated: z.boolean(),
|
|
43
|
+
// True if the file should not be overwritten on re-generation.
|
|
44
|
+
preserve: z.boolean().default(false),
|
|
45
|
+
}),
|
|
46
|
+
),
|
|
47
|
+
// Compatibility range for the kit itself.
|
|
48
|
+
kitCompatibility: z.string().min(1),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export type TemplateVariable = z.infer<typeof TemplateVariableSchema>;
|
|
52
|
+
export type TemplateManifest = z.infer<typeof TemplateManifestSchema>;
|