@fjall/generator 0.94.1 → 0.96.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.
Files changed (126) hide show
  1. package/dist/.minified +1 -1
  2. package/dist/src/ast/astCodeInjection.d.ts +9 -0
  3. package/dist/src/ast/astCodeInjection.js +8 -0
  4. package/dist/src/ast/astInfrastructureParser.d.ts +1 -1
  5. package/dist/src/ast/astStatementClassifier.d.ts +2 -2
  6. package/dist/src/ast/astStatementClassifier.js +1 -1
  7. package/dist/src/ast/astStatementQueries.d.ts +4 -4
  8. package/dist/src/ast/astStatementQueries.js +3 -3
  9. package/dist/src/ast/astSurgicalModification.d.ts +14 -12
  10. package/dist/src/ast/astSurgicalModification.js +6 -13
  11. package/dist/src/ast/astTestHelpers.d.ts +7 -7
  12. package/dist/src/ast/index.d.ts +3 -2
  13. package/dist/src/ast/index.js +1 -1
  14. package/dist/src/codemod/_internal.d.ts +6 -1
  15. package/dist/src/codemod/_internal.js +1 -1
  16. package/dist/src/codemod/drift/__tests__/fixtures.d.ts +55 -0
  17. package/dist/src/codemod/drift/__tests__/fixtures.js +2 -0
  18. package/dist/src/codemod/drift/detect.d.ts +11 -0
  19. package/dist/src/codemod/drift/detect.js +1 -0
  20. package/dist/src/codemod/drift/index.d.ts +4 -0
  21. package/dist/src/codemod/drift/index.js +1 -0
  22. package/dist/src/codemod/drift/merge.d.ts +19 -0
  23. package/dist/src/codemod/drift/merge.js +1 -0
  24. package/dist/src/codemod/drift/snapshot.d.ts +4 -0
  25. package/dist/src/codemod/drift/snapshot.js +1 -0
  26. package/dist/src/codemod/drift/types.d.ts +60 -0
  27. package/dist/src/codemod/drift/types.js +1 -0
  28. package/dist/src/codemod/edits/addResource/propertyBuilder.d.ts +1 -1
  29. package/dist/src/codemod/edits/addResource/propertyBuilder.js +1 -1
  30. package/dist/src/codemod/edits/addResource.d.ts +8 -3
  31. package/dist/src/codemod/edits/addResource.js +1 -1
  32. package/dist/src/codemod/edits/controlFlowPolicy.d.ts +19 -0
  33. package/dist/src/codemod/edits/controlFlowPolicy.js +1 -0
  34. package/dist/src/codemod/edits/crossPlanConnection.d.ts +24 -0
  35. package/dist/src/codemod/edits/crossPlanConnection.js +1 -0
  36. package/dist/src/codemod/edits/driftPolicy.d.ts +7 -0
  37. package/dist/src/codemod/edits/driftPolicy.js +1 -0
  38. package/dist/src/codemod/edits/findInsertionPosition.js +1 -1
  39. package/dist/src/codemod/edits/index.d.ts +3 -0
  40. package/dist/src/codemod/edits/index.js +1 -1
  41. package/dist/src/codemod/edits/modifyResource.d.ts +9 -3
  42. package/dist/src/codemod/edits/modifyResource.js +1 -1
  43. package/dist/src/codemod/edits/removeResource.d.ts +2 -2
  44. package/dist/src/codemod/edits/removeResource.js +1 -1
  45. package/dist/src/codemod/edits/vpcPeer.d.ts +28 -0
  46. package/dist/src/codemod/edits/vpcPeer.js +1 -0
  47. package/dist/src/codemod/edits/vpcPeerAccepter.d.ts +23 -0
  48. package/dist/src/codemod/edits/vpcPeerAccepter.js +1 -0
  49. package/dist/src/codemod/index.d.ts +16 -4
  50. package/dist/src/codemod/index.js +1 -1
  51. package/dist/src/codemod/llmFallback/__tests__/fixtures.d.ts +5 -0
  52. package/dist/src/codemod/llmFallback/__tests__/fixtures.js +7 -0
  53. package/dist/src/codemod/llmFallback/apply.d.ts +10 -0
  54. package/dist/src/codemod/llmFallback/apply.js +1 -0
  55. package/dist/src/codemod/llmFallback/claudeTier.d.ts +6 -0
  56. package/dist/src/codemod/llmFallback/claudeTier.js +1 -0
  57. package/dist/src/codemod/llmFallback/egressGate.d.ts +5 -0
  58. package/dist/src/codemod/llmFallback/egressGate.js +1 -0
  59. package/dist/src/codemod/llmFallback/egressGate.types.d.ts +9 -0
  60. package/dist/src/codemod/llmFallback/egressGate.types.js +0 -0
  61. package/dist/src/codemod/llmFallback/index.d.ts +6 -0
  62. package/dist/src/codemod/llmFallback/index.js +1 -0
  63. package/dist/src/codemod/llmFallback/morphTier.d.ts +2 -0
  64. package/dist/src/codemod/llmFallback/morphTier.js +3 -0
  65. package/dist/src/codemod/llmFallback/prompt.d.ts +12 -0
  66. package/dist/src/codemod/llmFallback/prompt.js +36 -0
  67. package/dist/src/codemod/llmFallback/runFallback.d.ts +13 -0
  68. package/dist/src/codemod/llmFallback/runFallback.js +1 -0
  69. package/dist/src/codemod/llmFallback/shouldTryFallback.d.ts +13 -0
  70. package/dist/src/codemod/llmFallback/shouldTryFallback.js +1 -0
  71. package/dist/src/codemod/llmFallback/signals.d.ts +4 -0
  72. package/dist/src/codemod/llmFallback/signals.js +1 -0
  73. package/dist/src/codemod/llmFallback/telemetryEvents.d.ts +141 -0
  74. package/dist/src/codemod/llmFallback/telemetryEvents.js +1 -0
  75. package/dist/src/codemod/llmFallback/tierRunner.d.ts +7 -0
  76. package/dist/src/codemod/llmFallback/tierRunner.js +1 -0
  77. package/dist/src/codemod/llmFallback/types.d.ts +104 -0
  78. package/dist/src/codemod/llmFallback/types.js +1 -0
  79. package/dist/src/codemod/registry.d.ts +4 -1
  80. package/dist/src/codemod/registry.js +1 -1
  81. package/dist/src/codemod/semanticIndex/classifyControlFlow.d.ts +2 -0
  82. package/dist/src/codemod/semanticIndex/classifyControlFlow.js +1 -0
  83. package/dist/src/codemod/semanticIndex/findReferences.js +2 -2
  84. package/dist/src/codemod/telemetry/__tests__/errorKinds.fixture.d.ts +1 -0
  85. package/dist/src/codemod/telemetry/__tests__/errorKinds.fixture.js +1 -0
  86. package/dist/src/codemod/telemetry/errorKinds.d.ts +2 -0
  87. package/dist/src/codemod/telemetry/errorKinds.js +1 -0
  88. package/dist/src/codemod/types.d.ts +105 -1
  89. package/dist/src/codemod/types.js +1 -1
  90. package/dist/src/codemod/validationGate/gates/classify.d.ts +2 -0
  91. package/dist/src/codemod/validationGate/gates/classify.js +1 -0
  92. package/dist/src/codemod/validationGate/gates/drift.d.ts +2 -0
  93. package/dist/src/codemod/validationGate/gates/drift.js +1 -0
  94. package/dist/src/codemod/validationGate/gates/locate.d.ts +7 -0
  95. package/dist/src/codemod/validationGate/gates/locate.js +1 -0
  96. package/dist/src/codemod/validationGate/gates/parse.d.ts +2 -0
  97. package/dist/src/codemod/validationGate/gates/parse.js +1 -0
  98. package/dist/src/codemod/validationGate/gates/schema.d.ts +2 -0
  99. package/dist/src/codemod/validationGate/gates/schema.js +1 -0
  100. package/dist/src/codemod/validationGate/index.d.ts +6 -0
  101. package/dist/src/codemod/validationGate/index.js +1 -0
  102. package/dist/src/codemod/validationGate/types.d.ts +35 -0
  103. package/dist/src/codemod/validationGate/types.js +1 -0
  104. package/dist/src/dns/domainFileGenerator.js +22 -183
  105. package/dist/src/index.js +1 -21
  106. package/dist/src/planning/index.d.ts +2 -1
  107. package/dist/src/planning/index.js +1 -1
  108. package/dist/src/planning/openNextPlanning.d.ts +38 -0
  109. package/dist/src/planning/openNextPlanning.js +1 -0
  110. package/dist/src/planning/resourcePlanning.d.ts +0 -46
  111. package/dist/src/planning/resourcePlanning.js +1 -1
  112. package/dist/src/schemas/applicationSchemas.d.ts +16 -0
  113. package/dist/src/schemas/applicationSchemas.js +1 -1
  114. package/dist/src/schemas/baseSchemas.d.ts +8 -5
  115. package/dist/src/schemas/baseSchemas.js +2 -2
  116. package/dist/src/schemas/networkSchemas.d.ts +119 -5
  117. package/dist/src/schemas/networkSchemas.js +1 -1
  118. package/dist/src/validation/patterns.d.ts +2 -318
  119. package/dist/src/validation/patterns.js +1 -1
  120. package/dist/src/validation/validationMessages.d.ts +314 -0
  121. package/dist/src/validation/validationMessages.js +1 -0
  122. package/dist/src/validation/validationPatterns.d.ts +20 -0
  123. package/dist/src/validation/validationPatterns.js +1 -0
  124. package/dist/src/version.d.ts +1 -1
  125. package/dist/src/version.js +1 -1
  126. package/package.json +3 -3
@@ -0,0 +1,141 @@
1
+ import type { GateId } from "../validationGate/types.js";
2
+ import type { FallbackOp, FallbackTelemetry, TriggerReason } from "./types.js";
3
+ import type { EgressRiskReason } from "./egressGate.types.js";
4
+ import type { LlmFallbackTier } from "../types.js";
5
+ export declare const FALLBACK_EVENTS: {
6
+ readonly FIRED: "codemod.llm_fallback.fired";
7
+ readonly SUCCEEDED: "codemod.llm_fallback.succeeded";
8
+ readonly REJECTED: "codemod.llm_fallback.rejected";
9
+ readonly TIMEOUT: "codemod.llm_fallback.timeout";
10
+ readonly EGRESS_BLOCKED: "codemod.llm_fallback.egress_blocked";
11
+ };
12
+ export declare const GATE_EVENTS: {
13
+ readonly PASSED: "codemod.gate.passed";
14
+ readonly FAILED: "codemod.gate.failed";
15
+ };
16
+ export type TelemetrySource = "cli" | "webapp_service" | "webapp_api" | "webapp_ui" | "mcp";
17
+ export interface FallbackFiredEvent {
18
+ event: typeof FALLBACK_EVENTS.FIRED;
19
+ properties: {
20
+ source: TelemetrySource;
21
+ operation: FallbackOp;
22
+ tier: LlmFallbackTier;
23
+ trigger: TriggerReason;
24
+ organisationId: string;
25
+ };
26
+ }
27
+ export interface FallbackSucceededEvent {
28
+ event: typeof FALLBACK_EVENTS.SUCCEEDED;
29
+ properties: {
30
+ source: TelemetrySource;
31
+ operation: FallbackOp;
32
+ tier: LlmFallbackTier;
33
+ durationMs: number;
34
+ estimatedCostUsd: number;
35
+ organisationId: string;
36
+ };
37
+ }
38
+ export interface FallbackRejectedEvent {
39
+ event: typeof FALLBACK_EVENTS.REJECTED;
40
+ properties: {
41
+ source: TelemetrySource;
42
+ operation: FallbackOp;
43
+ tier: LlmFallbackTier;
44
+ failedGate: GateId;
45
+ durationMs: number;
46
+ organisationId: string;
47
+ };
48
+ }
49
+ export interface FallbackTimeoutEvent {
50
+ event: typeof FALLBACK_EVENTS.TIMEOUT;
51
+ properties: {
52
+ source: TelemetrySource;
53
+ operation: FallbackOp;
54
+ tier: LlmFallbackTier;
55
+ elapsedMs: number;
56
+ organisationId: string;
57
+ };
58
+ }
59
+ export interface FallbackEgressBlockedEvent {
60
+ event: typeof FALLBACK_EVENTS.EGRESS_BLOCKED;
61
+ properties: {
62
+ source: TelemetrySource;
63
+ operation: FallbackOp;
64
+ tier: LlmFallbackTier;
65
+ reason: EgressRiskReason;
66
+ count: number;
67
+ organisationId: string;
68
+ };
69
+ }
70
+ export interface GatePassedEvent {
71
+ event: typeof GATE_EVENTS.PASSED;
72
+ properties: {
73
+ gate: GateId;
74
+ operation: FallbackOp | "validate";
75
+ durationMs: number;
76
+ source: TelemetrySource;
77
+ organisationId: string;
78
+ };
79
+ }
80
+ export interface GateFailedEvent {
81
+ event: typeof GATE_EVENTS.FAILED;
82
+ properties: {
83
+ gate: GateId;
84
+ operation: FallbackOp | "validate";
85
+ durationMs: number;
86
+ source: TelemetrySource;
87
+ organisationId: string;
88
+ };
89
+ }
90
+ export type FallbackTelemetryEvent = FallbackFiredEvent | FallbackSucceededEvent | FallbackRejectedEvent | FallbackTimeoutEvent | FallbackEgressBlockedEvent | GatePassedEvent | GateFailedEvent;
91
+ export declare function estimateCostUsd(telemetry: FallbackTelemetry): number;
92
+ export declare function buildFiredEvent(params: {
93
+ source: TelemetrySource;
94
+ operation: FallbackOp;
95
+ tier: LlmFallbackTier;
96
+ trigger: TriggerReason;
97
+ organisationId: string;
98
+ }): FallbackFiredEvent;
99
+ export declare function buildSucceededEvent(params: {
100
+ source: TelemetrySource;
101
+ operation: FallbackOp;
102
+ telemetry: FallbackTelemetry;
103
+ organisationId: string;
104
+ }): FallbackSucceededEvent;
105
+ export declare function buildRejectedEvent(params: {
106
+ source: TelemetrySource;
107
+ operation: FallbackOp;
108
+ tier: LlmFallbackTier;
109
+ failedGate: GateId;
110
+ durationMs: number;
111
+ organisationId: string;
112
+ }): FallbackRejectedEvent;
113
+ export declare function buildTimeoutEvent(params: {
114
+ source: TelemetrySource;
115
+ operation: FallbackOp;
116
+ tier: LlmFallbackTier;
117
+ elapsedMs: number;
118
+ organisationId: string;
119
+ }): FallbackTimeoutEvent;
120
+ export declare function buildEgressBlockedEvent(params: {
121
+ source: TelemetrySource;
122
+ operation: FallbackOp;
123
+ tier: LlmFallbackTier;
124
+ reason: EgressRiskReason;
125
+ count: number;
126
+ organisationId: string;
127
+ }): FallbackEgressBlockedEvent;
128
+ export declare function buildGatePassedEvent(params: {
129
+ gate: GateId;
130
+ operation: FallbackOp | "validate";
131
+ durationMs: number;
132
+ source: TelemetrySource;
133
+ organisationId: string;
134
+ }): GatePassedEvent;
135
+ export declare function buildGateFailedEvent(params: {
136
+ gate: GateId;
137
+ operation: FallbackOp | "validate";
138
+ durationMs: number;
139
+ source: TelemetrySource;
140
+ organisationId: string;
141
+ }): GateFailedEvent;
@@ -0,0 +1 @@
1
+ const t={FIRED:"codemod.llm_fallback.fired",SUCCEEDED:"codemod.llm_fallback.succeeded",REJECTED:"codemod.llm_fallback.rejected",TIMEOUT:"codemod.llm_fallback.timeout",EGRESS_BLOCKED:"codemod.llm_fallback.egress_blocked"},o={PASSED:"codemod.gate.passed",FAILED:"codemod.gate.failed"},E=3/1e6,d=15/1e6;function i(e){if(e.tier!=="claude")return 0;const n=e.inputTokens*E,r=e.outputTokens*d;return Math.round((n+r)*1e6)/1e6}function u(e){return{event:t.FIRED,properties:e}}function c(e){return{event:t.SUCCEEDED,properties:{source:e.source,operation:e.operation,tier:e.telemetry.tier,durationMs:e.telemetry.elapsedMs,estimatedCostUsd:i(e.telemetry),organisationId:e.organisationId}}}function l(e){return{event:t.REJECTED,properties:e}}function s(e){return{event:t.TIMEOUT,properties:e}}function p(e){return{event:t.EGRESS_BLOCKED,properties:e}}function _(e){return{event:o.PASSED,properties:e}}function a(e){return{event:o.FAILED,properties:e}}export{t as FALLBACK_EVENTS,o as GATE_EVENTS,p as buildEgressBlockedEvent,u as buildFiredEvent,a as buildGateFailedEvent,_ as buildGatePassedEvent,l as buildRejectedEvent,c as buildSucceededEvent,s as buildTimeoutEvent,i as estimateCostUsd};
@@ -0,0 +1,7 @@
1
+ import type { LlmFallbackTier } from "../types.js";
2
+ import { type FallbackOutput } from "./types.js";
3
+ export interface TierTimeoutContext {
4
+ signal: AbortSignal;
5
+ started: number;
6
+ }
7
+ export declare function withTierTimeout(abortSignal: AbortSignal | undefined, tier: LlmFallbackTier, timeoutMs: number, fn: (ctx: TierTimeoutContext) => Promise<FallbackOutput>): Promise<FallbackOutput>;
@@ -0,0 +1 @@
1
+ import{linkAbortSignals as d}from"./signals.js";import{RUNTIME_GATE as f}from"./types.js";async function p(n,r,l,s){const a=new AbortController,{signal:c,cleanup:u}=d(n,a);let t,i=!1;const o=Date.now();try{return t=setTimeout(()=>{i=!0,a.abort()},l),await s({signal:c,started:o})}catch(e){return n?.aborted?{state:"cancelled"}:i?{state:"timeout",tier:r,elapsedMs:Date.now()-o}:{state:"rejected",tier:r,failedGate:f,diagnostics:e instanceof Error?e.message:String(e)}}finally{t!==void 0&&clearTimeout(t),u()}}export{p as withTierTimeout};
@@ -0,0 +1,104 @@
1
+ import type { StatementType, ResourceName, LlmFallbackTier } from "../types.js";
2
+ import type { GateId } from "../validationGate/types.js";
3
+ import type { EgressRiskReason } from "./egressGate.types.js";
4
+ export declare const PARSE_GATE: GateId;
5
+ export declare const RUNTIME_GATE: GateId;
6
+ export type FallbackOp = "add" | "modify" | "remove" | "resolve-drift-merge";
7
+ export interface FallbackIntent {
8
+ op: FallbackOp;
9
+ type: StatementType;
10
+ name: ResourceName;
11
+ properties: Record<string, unknown>;
12
+ }
13
+ export interface FallbackInput {
14
+ content: string;
15
+ intent: FallbackIntent;
16
+ tier: LlmFallbackTier;
17
+ orgAllowsFallback: boolean;
18
+ abortSignal?: AbortSignal;
19
+ }
20
+ export type FallbackOutput = {
21
+ state: "applied";
22
+ content: string;
23
+ telemetry: FallbackTelemetry;
24
+ } | {
25
+ state: "egress-blocked";
26
+ tier: LlmFallbackTier;
27
+ reason: EgressRiskReason;
28
+ count: number;
29
+ } | {
30
+ state: "timeout";
31
+ tier: LlmFallbackTier;
32
+ elapsedMs: number;
33
+ } | {
34
+ state: "rejected";
35
+ tier: LlmFallbackTier;
36
+ failedGate: GateId;
37
+ diagnostics: string;
38
+ } | {
39
+ state: "cancelled";
40
+ } | {
41
+ state: "disabled";
42
+ reason: "env-flag" | "org-opt-out";
43
+ };
44
+ export interface FallbackTelemetry {
45
+ tier: LlmFallbackTier;
46
+ elapsedMs: number;
47
+ inputTokens: number;
48
+ outputTokens: number;
49
+ opsApplied: number;
50
+ }
51
+ export type TriggerReason = "template-literal-name" | "resource-not-found" | "control-flow-unclassifiable" | "drift-unmergeable";
52
+ export interface StrReplaceOp {
53
+ old_str: string;
54
+ new_str: string;
55
+ }
56
+ export interface ApplyResult {
57
+ content: string;
58
+ appliedCount: number;
59
+ skippedCount: number;
60
+ }
61
+ export interface AnthropicClientProvider {
62
+ create(params: {
63
+ model: string;
64
+ max_tokens: number;
65
+ system: string;
66
+ messages: Array<{
67
+ role: "user";
68
+ content: string;
69
+ }>;
70
+ tools: readonly unknown[];
71
+ signal?: AbortSignal;
72
+ }): Promise<AnthropicResponse>;
73
+ resolveModelId(): string;
74
+ }
75
+ export interface AnthropicResponse {
76
+ content: readonly AnthropicContentBlock[];
77
+ usage?: {
78
+ input_tokens?: number;
79
+ output_tokens?: number;
80
+ };
81
+ }
82
+ export type AnthropicContentBlock = {
83
+ type: "text";
84
+ text: string;
85
+ } | {
86
+ type: "tool_use";
87
+ name: string;
88
+ input: Record<string, unknown>;
89
+ };
90
+ export interface MorphClientProvider {
91
+ apply(params: {
92
+ originalFile: string;
93
+ update: string;
94
+ signal?: AbortSignal;
95
+ }): Promise<MorphResponse>;
96
+ isAvailable(): boolean;
97
+ }
98
+ export interface MorphResponse {
99
+ content: string;
100
+ usage?: {
101
+ inputTokens?: number;
102
+ outputTokens?: number;
103
+ };
104
+ }
@@ -0,0 +1 @@
1
+ const t="parse",e="runtime";export{t as PARSE_GATE,e as RUNTIME_GATE};
@@ -25,7 +25,7 @@ export interface StatementTypeEntry {
25
25
  factoryIdentifier: FactoryIdentifier;
26
26
  locator: StatementLocator;
27
27
  generator: StatementGenerator;
28
- schemaFragment: z.ZodObject;
28
+ schemaFragment: z.ZodObject<z.ZodRawShape>;
29
29
  }
30
30
  declare const FACTORY_IDENTIFIERS: {
31
31
  readonly database: "DatabaseFactory";
@@ -35,6 +35,9 @@ declare const FACTORY_IDENTIFIERS: {
35
35
  readonly cdn: "CdnFactory";
36
36
  readonly network: "NetworkFactory";
37
37
  readonly pattern: "PatternFactory";
38
+ readonly "vpc-peer": "VpcPeerFactory";
39
+ readonly "vpc-peer-accepter": "VpcPeerAccepterFactory";
40
+ readonly "cross-plan-connection": "CrossPlanConnectionFactory";
38
41
  };
39
42
  export type FactoryIdentifier = (typeof FACTORY_IDENTIFIERS)[StatementType];
40
43
  export declare const STATEMENT_REGISTRY: Record<StatementType, StatementTypeEntry>;
@@ -1 +1 @@
1
- import{z as c}from"zod";import{CDNResourcePlanSchema as m,ComputeResourcePlanSchema as u,DatabaseResourcePlanSchema as p,NetworkResourcePlanSchema as g,NextJSPatternConfigSchema as d,PayloadPatternConfigSchema as h,S3ResourcePlanSchema as S,SQSResourcePlanSchema as l}from"../schemas/index.js";import{failure as y}from"../types/Result.js";const r={database:"DatabaseFactory",storage:"StorageFactory",compute:"ComputeFactory",messaging:"MessagingFactory",cdn:"CdnFactory",network:"NetworkFactory",pattern:"PatternFactory"};function n(t){const{name:e,...o}=t.shape;return c.object(o).partial().strict()}const f=n(p),F=n(S),b=(()=>{const{name:t,...e}=u.shape;return c.object(e).partial().strict()})(),E=n(l),w=n(m),P=n(g),R=(()=>{const{name:t,...e}=h.shape,{name:o,...i}=d.shape;return c.object({...e,...i}).partial().strict()})();function s(t,e){return y({kind:"SemanticQueryError",reason:`StatementTypeEntry.${t} for ${e} is not wired; existing types dispatch through the shared locator/generator.`})}function C(t){return{factoryIdentifier:t,findByShape:()=>s("locator.findByShape",t),validateContext:()=>s("locator.validateContext",t)}}function T(t){return{build:()=>{throw new Error(`StatementTypeEntry.generator.build for ${t} is not wired; existing types dispatch through the shared buildFactoryStatement.`)}}}function a(t,e){return{factoryIdentifier:t,locator:C(t),generator:T(t),schemaFragment:e}}const x={database:a(r.database,f),storage:a(r.storage,F),compute:a(r.compute,b),messaging:a(r.messaging,E),cdn:a(r.cdn,w),network:a(r.network,P),pattern:a(r.pattern,R)};function j(t){for(const[e,o]of Object.entries(x))if(o.factoryIdentifier===t)return e}export{x as STATEMENT_REGISTRY,j as findTypeByIdentifier};
1
+ import{z as c}from"zod";import{CDNResourcePlanSchema as i,ComputeResourcePlanSchema as u,CrossPlanConnectionResourcePlanSchema as g,DatabaseResourcePlanSchema as l,NetworkResourcePlanSchema as h,NextJSPatternConfigSchema as d,PayloadPatternConfigSchema as y,S3ResourcePlanSchema as S,SQSResourcePlanSchema as F,VpcPeerAccepterResourcePlanSchema as P,VpcPeerResourcePlanSchema as f}from"../schemas/index.js";import{failure as C}from"../types/Result.js";const r={database:"DatabaseFactory",storage:"StorageFactory",compute:"ComputeFactory",messaging:"MessagingFactory",cdn:"CdnFactory",network:"NetworkFactory",pattern:"PatternFactory","vpc-peer":"VpcPeerFactory","vpc-peer-accepter":"VpcPeerAccepterFactory","cross-plan-connection":"CrossPlanConnectionFactory"};function a(e){const{name:t,...o}=e.shape;return c.object(o).partial().strict()}const b=a(l),R=a(S),v=(()=>{const{name:e,...t}=u.shape;return c.object(t).partial().strict()})(),E=a(F),w=a(i),k=a(h),T=(()=>{const{name:e,type:t,...o}=y.shape,{name:D,type:V,...m}=d.shape;return c.object({...o,...m}).partial().strict()})(),_=a(f),x=a(P),N=a(g);function s(e,t){return C({kind:"SemanticQueryError",reason:`StatementTypeEntry.${e} for ${t} is not wired; existing types dispatch through the shared locator/generator.`})}function j(e){return{factoryIdentifier:e,findByShape:()=>s("locator.findByShape",e),validateContext:()=>s("locator.validateContext",e)}}function A(e){return{build:()=>{const t=s("generator.build",e);throw new Error(t.success?"unreachable":t.error.reason)}}}function n(e,t){return{factoryIdentifier:e,locator:j(e),generator:A(e),schemaFragment:t}}const p={database:n(r.database,b),storage:n(r.storage,R),compute:n(r.compute,v),messaging:n(r.messaging,E),cdn:n(r.cdn,w),network:n(r.network,k),pattern:n(r.pattern,T),"vpc-peer":n(r["vpc-peer"],_),"vpc-peer-accepter":n(r["vpc-peer-accepter"],x),"cross-plan-connection":n(r["cross-plan-connection"],N)};function I(e){const t=Object.keys(p);for(const o of t)if(p[o].factoryIdentifier===e)return o}export{p as STATEMENT_REGISTRY,I as findTypeByIdentifier};
@@ -0,0 +1,2 @@
1
+ export type ControlFlowClassification = "top-level" | "conditional" | "loop" | "function-body" | "unknown";
2
+ export declare function classifyControlFlow(node: unknown, ancestors: readonly unknown[]): ControlFlowClassification;
@@ -0,0 +1 @@
1
+ const u=new Set(["IfStatement","ConditionalExpression","SwitchStatement","SwitchCase","CatchClause"]),c=new Set(["ForStatement","ForInStatement","ForOfStatement","WhileStatement","DoWhileStatement"]),a=new Set(["FunctionDeclaration","FunctionExpression","ArrowFunctionExpression","ObjectMethod","ClassMethod"]);function p(n,t){if(t.length===0)return S(n);let e=n;for(let r=t.length-1;r>=0;r-=1){const o=t[r],i=f(o);if(i===void 0){e=o;continue}if(i==="TryStatement"){if(s(o,e))return"conditional";e=o;continue}if(u.has(i))return"conditional";if(c.has(i))return"loop";if(a.has(i))return"function-body";e=o}const l=f(t[0]);return l==="Program"||l==="File"?"top-level":"unknown"}function f(n){if(typeof n!="object"||n===null)return;const t=n.type;return typeof t=="string"?t:void 0}function s(n,t){if(typeof n!="object"||n===null)return!1;const e=n.finalizer;return e!==void 0&&e===t}function S(n){const t=f(n);return t==="Program"||t==="File"?"top-level":"unknown"}export{p as classifyControlFlow};
@@ -1,2 +1,2 @@
1
- import{Node as d,SyntaxKind as m}from"ts-morph";import{failure as a,success as l}from"../../types/Result.js";import{DEFAULT_FILE_PATH as y}from"../_internal.js";import{getProject as S}from"./projectCache.js";const f=120;function T(r,n,e=y){let i;try{i=S().createSourceFile(e,r,{overwrite:!0})}catch(t){return a({kind:"SemanticQueryError",reason:"Failed to create source file",cause:t})}let o;try{o=p(i,n.start)}catch(t){return a({kind:"SemanticQueryError",reason:"Failed to resolve declaration at the supplied offset",cause:t})}if(o===void 0)return l([]);let s;try{s=o.getSymbol()}catch(t){return a({kind:"SemanticQueryError",reason:"Failed to resolve symbol for declaration",cause:t})}if(s===void 0)return l([]);let c;try{c=o.findReferencesAsNodes()}catch(t){return a({kind:"SemanticQueryError",reason:"findReferencesAsNodes failed",cause:t})}const u=[];try{for(const t of c)g(t,s)&&(F(t,o)||u.push(b(t)))}catch(t){return a({kind:"SemanticQueryError",reason:"Failed to map references to plain-data locations",cause:t})}return l(u)}function p(r,n){const e=r.getDescendantAtPos(n);return e===void 0?void 0:d.isVariableDeclaration(e)?e:e.getFirstAncestorByKind(m.VariableDeclaration)}function g(r,n){const e=r.getSymbol();return e===void 0?!1:e===n?!0:e.compilerSymbol===n.compilerSymbol}function F(r,n){const e=n.getNameNode();return r===e||r.getStart()===e.getStart()}function b(r){const n=r.getStart(),{line:e,column:i}=r.getSourceFile().getLineAndColumnAtPos(n),c=r.getSourceFile().getFullText().split(`
2
- `)[e-1]??"",u=c.length>f?c.slice(0,f):c;return{line:e,column:i,context:u}}export{T as findReferences};
1
+ import{Node as m,SyntaxKind as y}from"ts-morph";import{failure as a,success as u}from"../../types/Result.js";import{DEFAULT_FILE_PATH as S}from"../_internal.js";import{getProject as p}from"./projectCache.js";const f=120;function D(r,n,e=S){let o;try{o=p().createSourceFile(e,r,{overwrite:!0})}catch(t){return a({kind:"SemanticQueryError",reason:"Failed to create source file",cause:t})}let c;try{c=g(o,n.start)}catch(t){return a({kind:"SemanticQueryError",reason:"Failed to resolve declaration at the supplied offset",cause:t})}if(c===void 0)return u([]);let i;try{i=c.getSymbol()}catch(t){return a({kind:"SemanticQueryError",reason:"Failed to resolve symbol for declaration",cause:t})}if(i===void 0)return u([]);let s;try{s=c.findReferencesAsNodes()}catch(t){return a({kind:"SemanticQueryError",reason:"findReferencesAsNodes failed",cause:t})}const d=o.getFullText().split(`
2
+ `),l=[];try{for(const t of s)F(t,i)&&(b(t,c)||l.push(A(t,d)))}catch(t){return a({kind:"SemanticQueryError",reason:"Failed to map references to plain-data locations",cause:t})}return u(l)}function g(r,n){const e=r.getDescendantAtPos(n);return e===void 0?void 0:m.isVariableDeclaration(e)?e:e.getFirstAncestorByKind(y.VariableDeclaration)}function F(r,n){const e=r.getSymbol();return e===void 0?!1:e===n?!0:e.compilerSymbol===n.compilerSymbol}function b(r,n){const e=n.getNameNode();return r===e||r.getStart()===e.getStart()}function A(r,n){const e=r.getStart(),{line:o,column:c}=r.getSourceFile().getLineAndColumnAtPos(e),i=n[o-1]??"",s=i.length>f?i.slice(0,f):i;return{line:o,column:c,context:s}}export{D as findReferences};
@@ -0,0 +1,2 @@
1
+ export declare const CODEMOD_ERROR_KINDS: readonly ["ParseError", "ResourceNotFoundError", "DuplicateResourceError", "ReferencesRemainError", "InvalidPropertyError", "TemplateLiteralNameError", "SemanticQueryError", "ValidationError", "IoError", "DriftConflictError", "DriftUnmergeableError", "PermissionError", "ControlFlowClassifierError", "LlmFallbackRejectedError", "LlmFallbackTimeoutError", "LlmFallbackUnsafeInputError"];
2
+ export type CodemodErrorKind = (typeof CODEMOD_ERROR_KINDS)[number];
@@ -0,0 +1 @@
1
+ const r=["ParseError","ResourceNotFoundError","DuplicateResourceError","ReferencesRemainError","InvalidPropertyError","TemplateLiteralNameError","SemanticQueryError","ValidationError","IoError","DriftConflictError","DriftUnmergeableError","PermissionError","ControlFlowClassifierError","LlmFallbackRejectedError","LlmFallbackTimeoutError","LlmFallbackUnsafeInputError"],e=!0;export{r as CODEMOD_ERROR_KINDS};
@@ -1,4 +1,11 @@
1
1
  import { z } from "zod";
2
+ import type { GateId } from "./validationGate/types.js";
3
+ import type { EgressRiskReason } from "./llmFallback/egressGate.types.js";
4
+ export declare const DriftPolicySchema: z.ZodObject<{
5
+ force: z.ZodOptional<z.ZodBoolean>;
6
+ resolutionMap: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
7
+ }, z.core.$strict>;
8
+ export type DriftPolicy = z.infer<typeof DriftPolicySchema>;
2
9
  /**
3
10
  * The wider `StatementTypeSchema` in `schemas/baseSchemas.ts` also
4
11
  * carries non-factory kinds (import, app-init, tags, custom) that the
@@ -12,6 +19,9 @@ export declare const StatementTypeSchema: z.ZodEnum<{
12
19
  network: "network";
13
20
  messaging: "messaging";
14
21
  cdn: "cdn";
22
+ "vpc-peer": "vpc-peer";
23
+ "vpc-peer-accepter": "vpc-peer-accepter";
24
+ "cross-plan-connection": "cross-plan-connection";
15
25
  }>;
16
26
  export type StatementType = z.infer<typeof StatementTypeSchema>;
17
27
  export declare const ResourceNameSchema: z.ZodString;
@@ -25,10 +35,18 @@ export declare const AddOptionsSchema: z.ZodObject<{
25
35
  network: "network";
26
36
  messaging: "messaging";
27
37
  cdn: "cdn";
38
+ "vpc-peer": "vpc-peer";
39
+ "vpc-peer-accepter": "vpc-peer-accepter";
40
+ "cross-plan-connection": "cross-plan-connection";
28
41
  }>;
29
42
  name: z.ZodString;
30
43
  properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
31
44
  filePath: z.ZodOptional<z.ZodString>;
45
+ driftPolicy: z.ZodOptional<z.ZodObject<{
46
+ force: z.ZodOptional<z.ZodBoolean>;
47
+ resolutionMap: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
48
+ }, z.core.$strict>>;
49
+ branch: z.ZodOptional<z.ZodString>;
32
50
  }, z.core.$strict>;
33
51
  export type AddOptions = z.infer<typeof AddOptionsSchema>;
34
52
  export declare const RemoveOptionsSchema: z.ZodObject<{
@@ -40,10 +58,14 @@ export declare const RemoveOptionsSchema: z.ZodObject<{
40
58
  network: "network";
41
59
  messaging: "messaging";
42
60
  cdn: "cdn";
61
+ "vpc-peer": "vpc-peer";
62
+ "vpc-peer-accepter": "vpc-peer-accepter";
63
+ "cross-plan-connection": "cross-plan-connection";
43
64
  }>;
44
65
  name: z.ZodString;
45
66
  filePath: z.ZodOptional<z.ZodString>;
46
67
  force: z.ZodOptional<z.ZodBoolean>;
68
+ branch: z.ZodOptional<z.ZodString>;
47
69
  }, z.core.$strict>;
48
70
  export type RemoveOptions = z.infer<typeof RemoveOptionsSchema>;
49
71
  export declare const ModifyOptionsSchema: z.ZodObject<{
@@ -55,10 +77,18 @@ export declare const ModifyOptionsSchema: z.ZodObject<{
55
77
  network: "network";
56
78
  messaging: "messaging";
57
79
  cdn: "cdn";
80
+ "vpc-peer": "vpc-peer";
81
+ "vpc-peer-accepter": "vpc-peer-accepter";
82
+ "cross-plan-connection": "cross-plan-connection";
58
83
  }>;
59
84
  name: z.ZodString;
60
85
  properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
61
86
  filePath: z.ZodOptional<z.ZodString>;
87
+ driftPolicy: z.ZodOptional<z.ZodObject<{
88
+ force: z.ZodOptional<z.ZodBoolean>;
89
+ resolutionMap: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
90
+ }, z.core.$strict>>;
91
+ branch: z.ZodOptional<z.ZodString>;
62
92
  }, z.core.$strict>;
63
93
  export type ModifyOptions = z.infer<typeof ModifyOptionsSchema>;
64
94
  export declare const ReferenceLocationSchema: z.ZodObject<{
@@ -81,6 +111,9 @@ export declare const ResourceListingEntrySchema: z.ZodObject<{
81
111
  network: "network";
82
112
  messaging: "messaging";
83
113
  cdn: "cdn";
114
+ "vpc-peer": "vpc-peer";
115
+ "vpc-peer-accepter": "vpc-peer-accepter";
116
+ "cross-plan-connection": "cross-plan-connection";
84
117
  }>;
85
118
  name: z.ZodString;
86
119
  filePath: z.ZodString;
@@ -99,6 +132,9 @@ export declare const ResourceListingSchema: z.ZodObject<{
99
132
  network: "network";
100
133
  messaging: "messaging";
101
134
  cdn: "cdn";
135
+ "vpc-peer": "vpc-peer";
136
+ "vpc-peer-accepter": "vpc-peer-accepter";
137
+ "cross-plan-connection": "cross-plan-connection";
102
138
  }>;
103
139
  name: z.ZodString;
104
140
  filePath: z.ZodString;
@@ -169,4 +205,72 @@ export interface SemanticQueryError {
169
205
  reason: string;
170
206
  cause?: unknown;
171
207
  }
172
- export type CodemodError = ParseError | TemplateLiteralNameError | DuplicateResourceError | ResourceNotFoundError | ReferencesRemainError | InvalidPropertyError | SemanticQueryError;
208
+ export declare const PropertyDeltaSchema: z.ZodObject<{
209
+ property: z.ZodString;
210
+ base: z.ZodOptional<z.ZodUnknown>;
211
+ theirs: z.ZodUnknown;
212
+ ours: z.ZodUnknown;
213
+ verdict: z.ZodEnum<{
214
+ clean: "clean";
215
+ "no-op": "no-op";
216
+ compatible: "compatible";
217
+ conflict: "conflict";
218
+ }>;
219
+ }, z.core.$strict>;
220
+ export type PropertyDelta = z.infer<typeof PropertyDeltaSchema>;
221
+ export interface DriftConflictError {
222
+ kind: "DriftConflictError";
223
+ resource: {
224
+ type: StatementType;
225
+ name: string;
226
+ };
227
+ deltas: PropertyDelta[];
228
+ baselineSource: "pr" | "persistent" | "file" | "unknown";
229
+ remediation?: string;
230
+ }
231
+ export interface DriftUnmergeableError {
232
+ kind: "DriftUnmergeableError";
233
+ resource: {
234
+ type: StatementType;
235
+ name: string;
236
+ };
237
+ reason: string;
238
+ }
239
+ export interface PermissionError {
240
+ kind: "PermissionError";
241
+ reason: "cross-account-peer-requires-trust" | "cross-org-connection-refused" | "unknown-remote-app" | "wildcard-principal-rejected" | "wildcard-resource-rejected";
242
+ details: string;
243
+ remediation?: string;
244
+ }
245
+ export type ControlFlowRefusalReason = "try-catch" | "switch-fall-through" | "nested-ternary" | "loop" | "generator-function" | "async-iterator" | "anonymous-helper" | "decorator-return";
246
+ export interface ControlFlowClassifierError {
247
+ kind: "ControlFlowClassifierError";
248
+ reason: ControlFlowRefusalReason;
249
+ resource: {
250
+ type: StatementType;
251
+ name: string;
252
+ };
253
+ location?: {
254
+ line: number;
255
+ column: number;
256
+ };
257
+ remediation?: string;
258
+ }
259
+ export type LlmFallbackTier = "claude" | "morph";
260
+ export interface LlmFallbackRejectedError {
261
+ kind: "LlmFallbackRejectedError";
262
+ tier: LlmFallbackTier;
263
+ failedGate: GateId;
264
+ diagnostics: string;
265
+ }
266
+ export interface LlmFallbackTimeoutError {
267
+ kind: "LlmFallbackTimeoutError";
268
+ tier: LlmFallbackTier;
269
+ elapsedMs: number;
270
+ }
271
+ export interface LlmFallbackUnsafeInputError {
272
+ kind: "LlmFallbackUnsafeInputError";
273
+ reason: EgressRiskReason;
274
+ count: number;
275
+ }
276
+ export type CodemodError = ParseError | TemplateLiteralNameError | DuplicateResourceError | ResourceNotFoundError | ReferencesRemainError | InvalidPropertyError | SemanticQueryError | DriftConflictError | DriftUnmergeableError | PermissionError | ControlFlowClassifierError | LlmFallbackRejectedError | LlmFallbackTimeoutError | LlmFallbackUnsafeInputError;
@@ -1 +1 @@
1
- import{z as e}from"zod";const t=e.enum(["database","storage","compute","messaging","cdn","network","pattern"]),n=e.string().regex(/^[A-Z][A-Za-z0-9]*$/,"Resource name must start with an uppercase letter and contain only alphanumerics (PascalCase)."),o=e.record(e.string(),e.unknown()),c=e.object({type:t,name:n,properties:o,filePath:e.string().optional()}).strict(),m=e.object({type:t,name:n,filePath:e.string().optional(),force:e.boolean().optional()}).strict(),p=e.object({type:t,name:n,properties:o,filePath:e.string().optional()}).strict(),r=e.object({line:e.number().int().nonnegative(),column:e.number().int().nonnegative(),context:e.string()}).strict(),a=e.object({added:e.number().int().nonnegative(),removed:e.number().int().nonnegative()}).strict(),i=e.object({type:t,name:e.string(),filePath:e.string(),start:e.number().int().nonnegative(),length:e.number().int().nonnegative()}).strict(),g=e.object({filePath:e.string(),resources:e.array(i)}).strict(),h=e.object({content:e.string(),linesChanged:a,references:e.array(r).optional(),warnings:e.array(e.string()).optional()}).strict();export{c as AddOptionsSchema,h as CodemodSuccessSchema,a as LinesChangedSchema,p as ModifyOptionsSchema,r as ReferenceLocationSchema,m as RemoveOptionsSchema,i as ResourceListingEntrySchema,g as ResourceListingSchema,n as ResourceNameSchema,t as StatementTypeSchema};
1
+ import{z as t}from"zod";import{VALIDATION_MESSAGES as i,VALIDATION_PATTERNS as c}from"../validation/patterns.js";const o=t.object({force:t.boolean().optional(),resolutionMap:t.record(t.string(),t.unknown()).optional()}).strict(),e=t.enum(["database","storage","compute","messaging","cdn","network","pattern","vpc-peer","vpc-peer-accepter","cross-plan-connection"]),n=t.string().regex(c.PASCAL_CASE,i.PASCAL_CASE),r=t.record(t.string(),t.unknown()),g=t.object({type:e,name:n,properties:r,filePath:t.string().optional(),driftPolicy:o.optional(),branch:t.string().optional()}).strict(),h=t.object({type:e,name:n,filePath:t.string().optional(),force:t.boolean().optional(),branch:t.string().optional()}).strict(),b=t.object({type:e,name:n,properties:r,filePath:t.string().optional(),driftPolicy:o.optional(),branch:t.string().optional()}).strict(),a=t.object({line:t.number().int().positive(),column:t.number().int().positive(),context:t.string()}).strict(),s=t.object({added:t.number().int().nonnegative(),removed:t.number().int().nonnegative()}).strict(),p=t.object({type:e,name:t.string(),filePath:t.string(),start:t.number().int().nonnegative(),length:t.number().int().nonnegative()}).strict(),S=t.object({filePath:t.string(),resources:t.array(p)}).strict(),u=t.object({content:t.string(),linesChanged:s,references:t.array(a).optional(),warnings:t.array(t.string()).optional()}).strict(),d=t.object({property:t.string(),base:t.unknown().optional(),theirs:t.unknown(),ours:t.unknown(),verdict:t.enum(["clean","no-op","compatible","conflict"])}).strict();export{g as AddOptionsSchema,u as CodemodSuccessSchema,o as DriftPolicySchema,s as LinesChangedSchema,b as ModifyOptionsSchema,d as PropertyDeltaSchema,a as ReferenceLocationSchema,h as RemoveOptionsSchema,p as ResourceListingEntrySchema,S as ResourceListingSchema,n as ResourceNameSchema,e as StatementTypeSchema};
@@ -0,0 +1,2 @@
1
+ import type { Gate } from "../types.js";
2
+ export declare const classifyGate: Gate;
@@ -0,0 +1 @@
1
+ import{success as p,failure as y}from"../../../types/Result.js";import{parse as m}from"../../fileRewriter/parse.js";import{classifyControlFlow as h}from"../../semanticIndex/classifyControlFlow.js";import{locateAllShapes as A}from"../../semanticIndex/locateByShape.js";const C=new Set(["loc","tokens","comments","original","range"]);function f(o){return typeof o=="object"&&o!==null&&typeof o.type=="string"}function S(o,i){if(!f(o))return;const e=[{node:o,ancestors:[]}];for(;e.length>0;){const t=e.pop();if(t===void 0)continue;const{node:n,ancestors:s}=t;if(n.type==="StringLiteral"&&typeof n.start=="number"&&n.start===i)return{node:n,ancestors:s};const c=[...s,n];for(const u of Object.keys(n)){if(C.has(u))continue;const r=n[u];if(Array.isArray(r))for(let a=r.length-1;a>=0;a-=1){const l=r[a];f(l)&&e.push({node:l,ancestors:c})}else f(r)&&e.push({node:r,ancestors:c})}}}const g={conditional:"try-catch",loop:"loop","function-body":"anonymous-helper",unknown:"anonymous-helper"};function d(o){const i=A(o);if(!i.success)return[];const e=m(o);if(!e.success)return[];const t=[];for(const n of i.data){const s=S(e.data,n.start);if(s===void 0)continue;const c=h(s.node,s.ancestors);t.push({name:n.symbolName,type:n.type,classification:c})}return t}const O={id:"classify",run(o){if(o.inputContent===void 0)return p({action:"proceed"});const i=d(o.inputContent),e=d(o.content);for(const t of e){const n=i.find(s=>s.name===t.name&&s.type===t.type);if(n!==void 0&&n.classification==="top-level"&&t.classification!=="top-level")return y({kind:"ControlFlowClassifierError",reason:g[t.classification],resource:{type:t.type,name:t.name},location:void 0,remediation:"The LLM output moved a resource into a conditional or loop scope."})}return p({action:"proceed"})}};export{O as classifyGate};
@@ -0,0 +1,2 @@
1
+ import type { Gate } from "../types.js";
2
+ export declare const driftGate: Gate;
@@ -0,0 +1 @@
1
+ import{failure as i,success as o}from"../../../types/Result.js";import{detectDrift as n}from"../../drift/index.js";import{resolveDriftPolicy as f}from"../../edits/driftPolicy.js";const d={id:"drift",run(r){if(r.baseline===void 0)return o({action:"proceed"});const t=n(r.content,r.plan,r.baseline);if(!t.success)return i(t.error);const e=f(t.data,r.plan.op,r.policy);return e.action==="reject"?i({kind:"DriftConflictError",resource:e.driftState.resource,deltas:e.driftState.deltas,baselineSource:"file"}):o({action:e.action,driftState:e.driftState})}};export{d as driftGate};
@@ -0,0 +1,7 @@
1
+ import type { Gate } from "../types.js";
2
+ export type LocateMode = "present" | "absent";
3
+ export interface LocateGateOptions {
4
+ mode: LocateMode;
5
+ }
6
+ export declare function createLocateGate(options: LocateGateOptions): Gate;
7
+ export declare const locateGate: Gate;
@@ -0,0 +1 @@
1
+ import{success as o,failure as r}from"../../../types/Result.js";import{locateByShape as p}from"../../semanticIndex/locateByShape.js";function u(t){return{id:"locate",run(e){const n=p(e.content,{type:e.plan.type,name:e.plan.name});if(!n.success)return r(n.error);const a=n.data!==void 0;return t.mode==="present"&&!a?r({kind:"ResourceNotFoundError",type:e.plan.type,name:e.plan.name,knownNames:[]}):t.mode==="absent"&&a?r({kind:"DuplicateResourceError",type:e.plan.type,name:e.plan.name}):o({action:"proceed"})}}}const c=u({mode:"present"});export{u as createLocateGate,c as locateGate};
@@ -0,0 +1,2 @@
1
+ import type { Gate } from "../types.js";
2
+ export declare const parseGate: Gate;
@@ -0,0 +1 @@
1
+ import{success as o,failure as t}from"../../../types/Result.js";import{parse as i}from"../../fileRewriter/parse.js";const d={id:"parse",run(s){const r=i(s.content);if(!r.success){const e=r.error,n=e.line!==void 0&&e.column!==void 0?`${String(e.line)}:${String(e.column)}`:void 0;return t({...e,kind:"ParseError",message:n!==void 0?`${e.message} at ${n}`:e.message})}return o({action:"proceed"})}};export{d as parseGate};
@@ -0,0 +1,2 @@
1
+ import type { Gate } from "../types.js";
2
+ export declare const schemaGate: Gate;
@@ -0,0 +1 @@
1
+ import{success as c}from"../../../types/Result.js";const t={id:"schema",run(e){return c({action:"proceed"})}};export{t as schemaGate};
@@ -0,0 +1,6 @@
1
+ export { runPipeline, runPipelineAsync, type AsyncGate, type Gate, type GateAction, type GateContext, type GateId, type GateOutcome, type GateResult, } from "./types.js";
2
+ export { driftGate } from "./gates/drift.js";
3
+ export { schemaGate } from "./gates/schema.js";
4
+ export { parseGate } from "./gates/parse.js";
5
+ export { locateGate } from "./gates/locate.js";
6
+ export { classifyGate } from "./gates/classify.js";
@@ -0,0 +1 @@
1
+ import{runPipeline as o,runPipelineAsync as t}from"./types.js";import{driftGate as p}from"./gates/drift.js";import{schemaGate as m}from"./gates/schema.js";import{parseGate as x}from"./gates/parse.js";import{locateGate as s}from"./gates/locate.js";import{classifyGate as c}from"./gates/classify.js";export{c as classifyGate,p as driftGate,s as locateGate,x as parseGate,o as runPipeline,t as runPipelineAsync,m as schemaGate};
@@ -0,0 +1,35 @@
1
+ import { type Result } from "../../types/Result.js";
2
+ import type { DriftOp, DriftPolicy, DriftState, ResourceSnapshot } from "../drift/index.js";
3
+ import type { CodemodError, ResourceName, StatementType } from "../types.js";
4
+ export type GateId = "parse" | "tsc" | "classify" | "locate" | "schema" | "drift" | "runtime";
5
+ export type GateAction = "proceed" | "skip" | "reject";
6
+ export interface GateContext {
7
+ content: string;
8
+ plan: {
9
+ type: StatementType;
10
+ name: ResourceName;
11
+ properties: Record<string, unknown>;
12
+ op: DriftOp;
13
+ };
14
+ baseline?: ResourceSnapshot;
15
+ policy?: DriftPolicy;
16
+ signal?: AbortSignal;
17
+ inputContent?: string;
18
+ }
19
+ export interface GateOutcome {
20
+ action: GateAction;
21
+ driftState?: DriftState;
22
+ failedGate?: GateId;
23
+ diagnostics?: string;
24
+ }
25
+ export type GateResult = Result<GateOutcome, CodemodError>;
26
+ export interface Gate {
27
+ readonly id: GateId;
28
+ run(ctx: GateContext): GateResult;
29
+ }
30
+ export interface AsyncGate {
31
+ readonly id: GateId;
32
+ run(ctx: GateContext): Promise<GateResult>;
33
+ }
34
+ export declare function runPipeline(gates: readonly Gate[], ctx: GateContext): GateResult;
35
+ export declare function runPipelineAsync(gates: ReadonlyArray<Gate | AsyncGate>, ctx: GateContext): Promise<GateResult>;
@@ -0,0 +1 @@
1
+ import{success as o}from"../../types/Result.js";function i(n,r){for(const t of n){const e=t.run(r);if(!e.success||e.data.action!=="proceed")return e}return o({action:"proceed"})}async function a(n,r){for(const t of n){if(r.signal?.aborted===!0)return o({action:"reject",failedGate:t.id,diagnostics:"aborted"});const e=await t.run(r);if(!e.success||e.data.action!=="proceed")return e}return o({action:"proceed"})}export{i as runPipeline,a as runPipelineAsync};