@fjall/generator 0.95.0 → 0.99.1
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/dist/.minified +1 -1
- package/dist/src/ast/astClickHouseParser.d.ts +25 -0
- package/dist/src/ast/astClickHouseParser.js +1 -0
- package/dist/src/ast/astCodeInjection.d.ts +9 -0
- package/dist/src/ast/astCodeInjection.js +8 -0
- package/dist/src/ast/astComputeParser.js +1 -1
- package/dist/src/ast/astComputeParserHelpers.js +1 -1
- package/dist/src/ast/astDatabaseParser.d.ts +5 -2
- package/dist/src/ast/astDatabaseParser.js +1 -1
- package/dist/src/ast/astInfrastructureParser.d.ts +7 -1
- package/dist/src/ast/astInfrastructureParser.js +1 -1
- package/dist/src/ast/astPlanConverter.js +2 -2
- package/dist/src/ast/astScheduleParser.d.ts +18 -0
- package/dist/src/ast/astScheduleParser.js +1 -0
- package/dist/src/ast/astStatementClassifier.d.ts +2 -2
- package/dist/src/ast/astStatementClassifier.js +1 -1
- package/dist/src/ast/astStatementQueries.d.ts +4 -4
- package/dist/src/ast/astStatementQueries.js +3 -3
- package/dist/src/ast/astSurgicalModification.d.ts +14 -12
- package/dist/src/ast/astSurgicalModification.js +6 -13
- package/dist/src/ast/astTestHelpers.d.ts +41 -7
- package/dist/src/ast/index.d.ts +3 -2
- package/dist/src/ast/index.js +1 -1
- package/dist/src/codemod/_internal.d.ts +6 -1
- package/dist/src/codemod/_internal.js +1 -1
- package/dist/src/codemod/drift/detect.d.ts +11 -0
- package/dist/src/codemod/drift/detect.js +1 -0
- package/dist/src/codemod/drift/index.d.ts +4 -0
- package/dist/src/codemod/drift/index.js +1 -0
- package/dist/src/codemod/drift/merge.d.ts +19 -0
- package/dist/src/codemod/drift/merge.js +1 -0
- package/dist/src/codemod/drift/snapshot.d.ts +4 -0
- package/dist/src/codemod/drift/snapshot.js +1 -0
- package/dist/src/codemod/drift/types.d.ts +60 -0
- package/dist/src/codemod/drift/types.js +1 -0
- package/dist/src/codemod/edits/addResource/propertyBuilder.d.ts +1 -1
- package/dist/src/codemod/edits/addResource/propertyBuilder.js +1 -1
- package/dist/src/codemod/edits/addResource.d.ts +8 -3
- package/dist/src/codemod/edits/addResource.js +1 -1
- package/dist/src/codemod/edits/controlFlowPolicy.d.ts +19 -0
- package/dist/src/codemod/edits/controlFlowPolicy.js +1 -0
- package/dist/src/codemod/edits/crossPlanConnection.d.ts +20 -0
- package/dist/src/codemod/edits/crossPlanConnection.js +1 -0
- package/dist/src/codemod/edits/driftPolicy.d.ts +7 -0
- package/dist/src/codemod/edits/driftPolicy.js +1 -0
- package/dist/src/codemod/edits/findInsertionPosition.js +1 -1
- package/dist/src/codemod/edits/index.d.ts +3 -0
- package/dist/src/codemod/edits/index.js +1 -1
- package/dist/src/codemod/edits/modifyResource.d.ts +9 -3
- package/dist/src/codemod/edits/modifyResource.js +1 -1
- package/dist/src/codemod/edits/removeResource.d.ts +2 -2
- package/dist/src/codemod/edits/removeResource.js +1 -1
- package/dist/src/codemod/edits/vpcPeer.d.ts +24 -0
- package/dist/src/codemod/edits/vpcPeer.js +1 -0
- package/dist/src/codemod/edits/vpcPeerAccepter.d.ts +20 -0
- package/dist/src/codemod/edits/vpcPeerAccepter.js +1 -0
- package/dist/src/codemod/index.d.ts +16 -4
- package/dist/src/codemod/index.js +1 -1
- package/dist/src/codemod/llmFallback/apply.d.ts +10 -0
- package/dist/src/codemod/llmFallback/apply.js +1 -0
- package/dist/src/codemod/llmFallback/claudeTier.d.ts +6 -0
- package/dist/src/codemod/llmFallback/claudeTier.js +1 -0
- package/dist/src/codemod/llmFallback/egressGate.d.ts +5 -0
- package/dist/src/codemod/llmFallback/egressGate.js +1 -0
- package/dist/src/codemod/llmFallback/egressGate.types.d.ts +9 -0
- package/dist/src/codemod/llmFallback/egressGate.types.js +0 -0
- package/dist/src/codemod/llmFallback/index.d.ts +6 -0
- package/dist/src/codemod/llmFallback/index.js +1 -0
- package/dist/src/codemod/llmFallback/morphTier.d.ts +2 -0
- package/dist/src/codemod/llmFallback/morphTier.js +3 -0
- package/dist/src/codemod/llmFallback/prompt.d.ts +12 -0
- package/dist/src/codemod/llmFallback/prompt.js +36 -0
- package/dist/src/codemod/llmFallback/runFallback.d.ts +13 -0
- package/dist/src/codemod/llmFallback/runFallback.js +1 -0
- package/dist/src/codemod/llmFallback/shouldTryFallback.d.ts +13 -0
- package/dist/src/codemod/llmFallback/shouldTryFallback.js +1 -0
- package/dist/src/codemod/llmFallback/signals.d.ts +4 -0
- package/dist/src/codemod/llmFallback/signals.js +1 -0
- package/dist/src/codemod/llmFallback/telemetryEvents.d.ts +141 -0
- package/dist/src/codemod/llmFallback/telemetryEvents.js +1 -0
- package/dist/src/codemod/llmFallback/tierRunner.d.ts +7 -0
- package/dist/src/codemod/llmFallback/tierRunner.js +1 -0
- package/dist/src/codemod/llmFallback/types.d.ts +104 -0
- package/dist/src/codemod/llmFallback/types.js +1 -0
- package/dist/src/codemod/registry.d.ts +4 -1
- package/dist/src/codemod/registry.js +1 -1
- package/dist/src/codemod/semanticIndex/classifyControlFlow.d.ts +2 -0
- package/dist/src/codemod/semanticIndex/classifyControlFlow.js +1 -0
- package/dist/src/codemod/semanticIndex/findReferences.js +2 -2
- package/dist/src/codemod/telemetry/errorKinds.d.ts +2 -0
- package/dist/src/codemod/telemetry/errorKinds.js +1 -0
- package/dist/src/codemod/types.d.ts +110 -1
- package/dist/src/codemod/types.js +1 -1
- package/dist/src/codemod/validationGate/gates/classify.d.ts +2 -0
- package/dist/src/codemod/validationGate/gates/classify.js +1 -0
- package/dist/src/codemod/validationGate/gates/drift.d.ts +2 -0
- package/dist/src/codemod/validationGate/gates/drift.js +1 -0
- package/dist/src/codemod/validationGate/gates/locate.d.ts +7 -0
- package/dist/src/codemod/validationGate/gates/locate.js +1 -0
- package/dist/src/codemod/validationGate/gates/parse.d.ts +2 -0
- package/dist/src/codemod/validationGate/gates/parse.js +1 -0
- package/dist/src/codemod/validationGate/gates/schema.d.ts +2 -0
- package/dist/src/codemod/validationGate/gates/schema.js +1 -0
- package/dist/src/codemod/validationGate/index.d.ts +6 -0
- package/dist/src/codemod/validationGate/index.js +1 -0
- package/dist/src/codemod/validationGate/types.d.ts +35 -0
- package/dist/src/codemod/validationGate/types.js +1 -0
- package/dist/src/detection/index.d.ts +148 -0
- package/dist/src/detection/index.js +1 -0
- package/dist/src/generation/common.d.ts +22 -0
- package/dist/src/generation/common.js +5 -4
- package/dist/src/generation/compute/ec2.d.ts +2 -0
- package/dist/src/generation/compute/ec2.js +4 -0
- package/dist/src/generation/compute/ecs.d.ts +2 -0
- package/dist/src/generation/compute/ecs.js +42 -0
- package/dist/src/generation/compute/lambda.d.ts +3 -0
- package/dist/src/generation/compute/lambda.js +26 -0
- package/dist/src/generation/compute/shared.d.ts +22 -0
- package/dist/src/generation/compute/shared.js +4 -0
- package/dist/src/generation/compute.d.ts +4 -5
- package/dist/src/generation/compute.js +6 -86
- package/dist/src/generation/database.d.ts +11 -0
- package/dist/src/generation/database.js +23 -12
- package/dist/src/generation/index.d.ts +1 -1
- package/dist/src/generation/index.js +1 -1
- package/dist/src/generation/infrastructure.js +5 -5
- package/dist/src/generation/storage.js +30 -30
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/planning/index.d.ts +2 -1
- package/dist/src/planning/index.js +1 -1
- package/dist/src/planning/openNextPlanning.d.ts +38 -0
- package/dist/src/planning/openNextPlanning.js +1 -0
- package/dist/src/planning/resourceAddition.d.ts +5 -1
- package/dist/src/planning/resourceAddition.js +1 -1
- package/dist/src/planning/resourcePlanning.d.ts +0 -46
- package/dist/src/planning/resourcePlanning.js +1 -1
- package/dist/src/presets/clickhouseTierPreset.d.ts +35 -0
- package/dist/src/presets/clickhouseTierPreset.js +0 -0
- package/dist/src/presets/tierPresets.d.ts +5 -12
- package/dist/src/presets/tierPresets.js +1 -1
- package/dist/src/presets/tierTypes.d.ts +9 -19
- package/dist/src/schemas/applicationSchemas.d.ts +67 -8
- package/dist/src/schemas/applicationSchemas.js +1 -1
- package/dist/src/schemas/baseSchemas.d.ts +24 -5
- package/dist/src/schemas/baseSchemas.js +2 -2
- package/dist/src/schemas/computeSchemas.d.ts +108 -14
- package/dist/src/schemas/computeSchemas.js +1 -1
- package/dist/src/schemas/constants.d.ts +14 -0
- package/dist/src/schemas/constants.js +1 -1
- package/dist/src/schemas/databaseSchemas.d.ts +80 -0
- package/dist/src/schemas/databaseSchemas.js +1 -1
- package/dist/src/schemas/networkSchemas.d.ts +126 -11
- package/dist/src/schemas/networkSchemas.js +1 -1
- package/dist/src/schemas/patternSchemas.js +1 -1
- package/dist/src/schemas/sharedTypes.d.ts +1 -1
- package/dist/src/schemas/sharedTypes.js +1 -1
- package/dist/src/validation/patterns.d.ts +2 -318
- package/dist/src/validation/patterns.js +1 -1
- package/dist/src/validation/validationMessages.d.ts +315 -0
- package/dist/src/validation/validationMessages.js +1 -0
- package/dist/src/validation/validationPatterns.d.ts +34 -0
- package/dist/src/validation/validationPatterns.js +1 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +19 -13
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{gateEgress as o}from"./egressGate.js";import{buildPrompt as g}from"./prompt.js";import{withTierTimeout as m}from"./tierRunner.js";import{PARSE_GATE as T}from"./types.js";const k=15e3,t="morph";async function M(e,r){if(!e.orgAllowsFallback)return{state:"disabled",reason:"org-opt-out"};if(!r.isAvailable())return{state:"disabled",reason:"env-flag"};const s=o(e.content,t);if(s!==void 0)return s;const i=o(JSON.stringify(e.intent.properties),t);if(i!==void 0)return i;const{systemPrompt:c,userPrompt:p}=g({content:e.content,intent:e.intent,tier:t});return m(e.abortSignal,t,k,async({signal:u,started:l})=>{const n=await r.apply({originalFile:e.content,update:`${c}
|
|
2
|
+
|
|
3
|
+
${p}`,signal:u}),d=Date.now()-l;if(n.content===e.content)return{state:"rejected",tier:t,failedGate:T,diagnostics:"Morph returned unchanged content"};const a=o(n.content,t);if(a!==void 0)return a;const f={tier:t,elapsedMs:d,inputTokens:n.usage?.inputTokens??0,outputTokens:n.usage?.outputTokens??0,opsApplied:1};return{state:"applied",content:n.content,telemetry:f}})}export{M as runMorphTier};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LlmFallbackTier } from "../types.js";
|
|
2
|
+
import type { FallbackIntent } from "./types.js";
|
|
3
|
+
export interface BuildPromptInput {
|
|
4
|
+
content: string;
|
|
5
|
+
intent: FallbackIntent;
|
|
6
|
+
tier: LlmFallbackTier;
|
|
7
|
+
}
|
|
8
|
+
export interface BuiltPrompt {
|
|
9
|
+
systemPrompt: string;
|
|
10
|
+
userPrompt: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function buildPrompt(input: BuildPromptInput): BuiltPrompt;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import{z as u}from"zod";import{STATEMENT_REGISTRY as s}from"../registry.js";const p=[...new Set(Object.values(s).map(e=>e.factoryIdentifier))].join(", "),a=`You are a Fjall infrastructure code editor. You modify TypeScript infrastructure files that use the Fjall CDK factory pattern.
|
|
2
|
+
|
|
3
|
+
Each resource is declared as a factory call:
|
|
4
|
+
\`XFactory.build("ResourceName", { ...properties })\`
|
|
5
|
+
|
|
6
|
+
where X is one of: ${p}.
|
|
7
|
+
|
|
8
|
+
## Rules
|
|
9
|
+
|
|
10
|
+
1. Use ONLY the str_replace command to make changes. Never rewrite the entire file.
|
|
11
|
+
2. Each str_replace must match EXACTLY ONE location in the file. If the old_str appears more than once, include enough surrounding context to make it unique.
|
|
12
|
+
3. Preserve all existing imports. Do not remove or reorder import statements.
|
|
13
|
+
4. Preserve the quote style used in the file (single or double quotes).
|
|
14
|
+
5. Do not move resource declarations into conditional blocks, loops, or function bodies. All factory calls must remain at module top level.
|
|
15
|
+
6. If you cannot produce a valid edit, respond with an empty tool_use \u2014 do not guess.
|
|
16
|
+
7. Properties must conform to the schema provided below. Do not invent property names.`;function d(e){return e==="morph"?`${a}
|
|
17
|
+
|
|
18
|
+
You are operating as a fast-apply tier. Produce minimal, precise edits only.`:a}function m(e){const t=s[e.type].factoryIdentifier;switch(e.op){case"add":return`Add a new ${e.type} resource named "${e.name}" using ${t}.build("${e.name}", { ... }) with the properties specified below.`;case"remove":return`Remove the ${e.type} resource named "${e.name}" (the ${t}.build("${e.name}", ...) call and any directly related code). Preserve all other resources.`;case"modify":return`Modify the ${e.type} resource named "${e.name}" by updating its properties to match the values specified below. Keep properties not mentioned in the update unchanged.`;case"resolve-drift-merge":return`Resolve a drift conflict on the ${e.type} resource named "${e.name}". The resource has been edited manually since Fjall last wrote it, and the requested properties conflict with the manual edits. Merge the two sets of changes: apply the requested properties below while preserving any manual edits to OTHER properties not listed in the update. Use ${t}.build("${e.name}", { ... }) with the merged property set.`}}function h(e){const o=s[e.type],t=u.toJSONSchema(o.schemaFragment,{io:"input"}),r=JSON.stringify(t,null,2),n=i(r);return`## Property Schema for ${e.type}
|
|
19
|
+
|
|
20
|
+
${n}json
|
|
21
|
+
${r}
|
|
22
|
+
${n}`}function f(e){if(e.op==="remove")return"";const o=Object.fromEntries(Object.entries(e.properties).filter(([,n])=>n!==void 0));if(Object.keys(o).length===0)return"";const t=JSON.stringify(o,null,2),r=i(t);return`## Target Properties
|
|
23
|
+
|
|
24
|
+
${r}json
|
|
25
|
+
${t}
|
|
26
|
+
${r}`}function i(e){const o=e.match(/`+/g)??[];let t=0;for(const r of o)r.length>t&&(t=r.length);return"`".repeat(Math.max(3,t+1))}function b(e){const o=d(e.tier),t=m(e.intent),r=h(e.intent),n=f(e.intent),c=i(e.content),l=`## Task
|
|
27
|
+
|
|
28
|
+
${t}
|
|
29
|
+
|
|
30
|
+
${r}
|
|
31
|
+
${n}
|
|
32
|
+
## Current File
|
|
33
|
+
|
|
34
|
+
${c}typescript
|
|
35
|
+
${e.content}
|
|
36
|
+
${c}`.trim();return{systemPrompt:o,userPrompt:l}}export{b as buildPrompt};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AnthropicClientProvider, FallbackInput, FallbackOutput, MorphClientProvider } from "./types.js";
|
|
2
|
+
export interface FallbackClients {
|
|
3
|
+
claude: AnthropicClientProvider;
|
|
4
|
+
morph?: MorphClientProvider;
|
|
5
|
+
}
|
|
6
|
+
export interface RunFallbackInput {
|
|
7
|
+
content: string;
|
|
8
|
+
intent: FallbackInput["intent"];
|
|
9
|
+
orgAllowsFallback: boolean;
|
|
10
|
+
morphTierEnabled: boolean;
|
|
11
|
+
abortSignal?: AbortSignal;
|
|
12
|
+
}
|
|
13
|
+
export declare function runFallback(input: RunFallbackInput, clients: FallbackClients): Promise<FallbackOutput>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{runClaudeTier as n}from"./claudeTier.js";import{runMorphTier as a}from"./morphTier.js";function o(r,e){return{content:r.content,intent:r.intent,tier:e,orgAllowsFallback:r.orgAllowsFallback,abortSignal:r.abortSignal}}async function u(r,e){const t=await n(o(r,"claude"),e.claude);return!(t.state==="rejected"||t.state==="timeout")||!r.morphTierEnabled||e.morph===void 0?t:a(o(r,"morph"),e.morph)}export{u as runFallback};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CodemodError } from "../types.js";
|
|
2
|
+
import type { TriggerReason } from "./types.js";
|
|
3
|
+
export interface FallbackGuardConfig {
|
|
4
|
+
envEnabled: boolean;
|
|
5
|
+
orgAllowsFallback: boolean;
|
|
6
|
+
}
|
|
7
|
+
export type FallbackDecision = {
|
|
8
|
+
shouldTry: true;
|
|
9
|
+
trigger: TriggerReason;
|
|
10
|
+
} | {
|
|
11
|
+
shouldTry: false;
|
|
12
|
+
};
|
|
13
|
+
export declare function shouldTryFallback(error: CodemodError, config: FallbackGuardConfig): FallbackDecision;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={shouldTry:!1};function o(r,n){if(!n.envEnabled||!n.orgAllowsFallback)return e;const t=l(r);return t===void 0?e:{shouldTry:!0,trigger:t}}function l(r){switch(r.kind){case"TemplateLiteralNameError":return"template-literal-name";case"ResourceNotFoundError":return"resource-not-found";case"ControlFlowClassifierError":return r.reason==="anonymous-helper"?"control-flow-unclassifiable":void 0;case"DriftUnmergeableError":return"drift-unmergeable";default:return}}export{o as shouldTryFallback};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(a,n){if(a===void 0)return{signal:n.signal,cleanup:()=>{}};if(a.aborted)return n.abort(),{signal:n.signal,cleanup:()=>{}};const i=()=>n.abort();return a.addEventListener("abort",i,{once:!0}),{signal:n.signal,cleanup:()=>a.removeEventListener("abort",i)}}export{e as linkAbortSignals};
|
|
@@ -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{maskSensitiveOutput as m}from"@fjall/util";import{linkAbortSignals as d}from"./signals.js";import{RUNTIME_GATE as f}from"./types.js";async function w(r,n,l,s){const i=new AbortController,{signal:u,cleanup:c}=d(r,i);let t,a=!1;const o=Date.now();try{return t=setTimeout(()=>{a=!0,i.abort()},l),await s({signal:u,started:o})}catch(e){return r?.aborted?{state:"cancelled"}:a?{state:"timeout",tier:n,elapsedMs:Date.now()-o}:{state:"rejected",tier:n,failedGate:f,diagnostics:m(e instanceof Error?e.message:String(e))}}finally{t!==void 0&&clearTimeout(t),c()}}export{w 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
|
|
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 @@
|
|
|
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
|
|
2
|
-
`)[e-1]??"",
|
|
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;
|
|
@@ -121,6 +157,11 @@ export declare const CodemodSuccessSchema: z.ZodObject<{
|
|
|
121
157
|
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
122
158
|
}, z.core.$strict>;
|
|
123
159
|
export type CodemodSuccess = z.infer<typeof CodemodSuccessSchema>;
|
|
160
|
+
export interface EditOrchestratorSuccess {
|
|
161
|
+
content: string;
|
|
162
|
+
linesChanged: LinesChanged;
|
|
163
|
+
warnings?: string[];
|
|
164
|
+
}
|
|
124
165
|
/** @internal Bridging tuple across the ts-morph / recast boundary (ADR §1). */
|
|
125
166
|
export interface NodeLocation {
|
|
126
167
|
filePath: string;
|
|
@@ -169,4 +210,72 @@ export interface SemanticQueryError {
|
|
|
169
210
|
reason: string;
|
|
170
211
|
cause?: unknown;
|
|
171
212
|
}
|
|
172
|
-
export
|
|
213
|
+
export declare const PropertyDeltaSchema: z.ZodObject<{
|
|
214
|
+
property: z.ZodString;
|
|
215
|
+
base: z.ZodOptional<z.ZodUnknown>;
|
|
216
|
+
theirs: z.ZodUnknown;
|
|
217
|
+
ours: z.ZodUnknown;
|
|
218
|
+
verdict: z.ZodEnum<{
|
|
219
|
+
clean: "clean";
|
|
220
|
+
"no-op": "no-op";
|
|
221
|
+
compatible: "compatible";
|
|
222
|
+
conflict: "conflict";
|
|
223
|
+
}>;
|
|
224
|
+
}, z.core.$strict>;
|
|
225
|
+
export type PropertyDelta = z.infer<typeof PropertyDeltaSchema>;
|
|
226
|
+
export interface DriftConflictError {
|
|
227
|
+
kind: "DriftConflictError";
|
|
228
|
+
resource: {
|
|
229
|
+
type: StatementType;
|
|
230
|
+
name: string;
|
|
231
|
+
};
|
|
232
|
+
deltas: PropertyDelta[];
|
|
233
|
+
baselineSource: "pr" | "persistent" | "file" | "unknown";
|
|
234
|
+
remediation?: string;
|
|
235
|
+
}
|
|
236
|
+
export interface DriftUnmergeableError {
|
|
237
|
+
kind: "DriftUnmergeableError";
|
|
238
|
+
resource: {
|
|
239
|
+
type: StatementType;
|
|
240
|
+
name: string;
|
|
241
|
+
};
|
|
242
|
+
reason: string;
|
|
243
|
+
}
|
|
244
|
+
export interface PermissionError {
|
|
245
|
+
kind: "PermissionError";
|
|
246
|
+
reason: "cross-account-peer-requires-trust" | "cross-org-connection-refused" | "unknown-remote-app" | "wildcard-principal-rejected" | "wildcard-resource-rejected";
|
|
247
|
+
details: string;
|
|
248
|
+
remediation?: string;
|
|
249
|
+
}
|
|
250
|
+
export type ControlFlowRefusalReason = "try-catch" | "switch-fall-through" | "nested-ternary" | "loop" | "generator-function" | "async-iterator" | "anonymous-helper" | "decorator-return";
|
|
251
|
+
export interface ControlFlowClassifierError {
|
|
252
|
+
kind: "ControlFlowClassifierError";
|
|
253
|
+
reason: ControlFlowRefusalReason;
|
|
254
|
+
resource: {
|
|
255
|
+
type: StatementType;
|
|
256
|
+
name: string;
|
|
257
|
+
};
|
|
258
|
+
location?: {
|
|
259
|
+
line: number;
|
|
260
|
+
column: number;
|
|
261
|
+
};
|
|
262
|
+
remediation?: string;
|
|
263
|
+
}
|
|
264
|
+
export type LlmFallbackTier = "claude" | "morph";
|
|
265
|
+
export interface LlmFallbackRejectedError {
|
|
266
|
+
kind: "LlmFallbackRejectedError";
|
|
267
|
+
tier: LlmFallbackTier;
|
|
268
|
+
failedGate: GateId;
|
|
269
|
+
diagnostics: string;
|
|
270
|
+
}
|
|
271
|
+
export interface LlmFallbackTimeoutError {
|
|
272
|
+
kind: "LlmFallbackTimeoutError";
|
|
273
|
+
tier: LlmFallbackTier;
|
|
274
|
+
elapsedMs: number;
|
|
275
|
+
}
|
|
276
|
+
export interface LlmFallbackUnsafeInputError {
|
|
277
|
+
kind: "LlmFallbackUnsafeInputError";
|
|
278
|
+
reason: EgressRiskReason;
|
|
279
|
+
count: number;
|
|
280
|
+
}
|
|
281
|
+
export type CodemodError = ParseError | TemplateLiteralNameError | DuplicateResourceError | ResourceNotFoundError | ReferencesRemainError | InvalidPropertyError | SemanticQueryError | DriftConflictError | DriftUnmergeableError | PermissionError | ControlFlowClassifierError | LlmFallbackRejectedError | LlmFallbackTimeoutError | LlmFallbackUnsafeInputError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as
|
|
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 @@
|
|
|
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 @@
|
|
|
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};
|