@vijaypjavvadi/bdd2pw 3.3.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +161 -0
- package/dist/index.js +35 -13
- package/dist/index.js.map +1 -1
- package/dist/llm/anthropicClient.d.ts +14 -0
- package/dist/llm/anthropicClient.js +216 -0
- package/dist/llm/anthropicClient.js.map +1 -1
- package/dist/llm/index.d.ts +1 -1
- package/dist/llm/index.js +2 -1
- package/dist/llm/index.js.map +1 -1
- package/dist/llm/llmStepMatcher.d.ts +37 -0
- package/dist/llm/llmStepMatcher.js +117 -0
- package/dist/llm/llmStepMatcher.js.map +1 -1
- package/dist/llm/prompt.d.ts +26 -0
- package/dist/llm/prompt.js +75 -0
- package/dist/llm/prompt.js.map +1 -1
- package/dist/llm/types.d.ts +22 -0
- package/dist/transformers/domains/banking.d.ts +37 -0
- package/dist/transformers/domains/banking.js +279 -0
- package/dist/transformers/domains/banking.js.map +1 -0
- package/dist/transformers/domains/healthcare.d.ts +20 -0
- package/dist/transformers/domains/healthcare.js +216 -0
- package/dist/transformers/domains/healthcare.js.map +1 -0
- package/dist/transformers/domains/insurance.d.ts +15 -0
- package/dist/transformers/domains/insurance.js +214 -0
- package/dist/transformers/domains/insurance.js.map +1 -0
- package/dist/transformers/stepMatcher.d.ts +12 -0
- package/dist/transformers/stepMatcher.js +34 -1
- package/dist/transformers/stepMatcher.js.map +1 -1
- package/dist/types.d.ts +20 -0
- package/package.json +1 -1
package/dist/llm/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type { LLMClient, LLMClientOptions } from "./types";
|
|
|
11
11
|
export { AnthropicLLMClient } from "./anthropicClient";
|
|
12
12
|
export { CandidateRulesWriter } from "./candidateRules";
|
|
13
13
|
export { GovernanceClient, GovernanceUnreachableError } from "./governanceClient";
|
|
14
|
-
export { matchStepWithLLM, matchStepsWithLLM, type MatchStepWithLLMContext, } from "./llmStepMatcher";
|
|
14
|
+
export { matchStepWithLLM, matchStepsWithLLM, matchScenarioWithLLM, type MatchStepWithLLMContext, } from "./llmStepMatcher";
|
|
15
15
|
export type { CandidateRuleEntry, GenerateBindingInput, GenerateBindingResult, LLMClient, LLMClientOptions, LLMLogEvent, } from "./types";
|
|
16
16
|
/**
|
|
17
17
|
* Construct the right LLMClient for the given options. Today the only
|
package/dist/llm/index.js
CHANGED
|
@@ -42,7 +42,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
42
42
|
};
|
|
43
43
|
})();
|
|
44
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.matchStepsWithLLM = exports.matchStepWithLLM = exports.GovernanceUnreachableError = exports.GovernanceClient = exports.CandidateRulesWriter = exports.AnthropicLLMClient = void 0;
|
|
45
|
+
exports.matchScenarioWithLLM = exports.matchStepsWithLLM = exports.matchStepWithLLM = exports.GovernanceUnreachableError = exports.GovernanceClient = exports.CandidateRulesWriter = exports.AnthropicLLMClient = void 0;
|
|
46
46
|
exports.createLLMClient = createLLMClient;
|
|
47
47
|
const path = __importStar(require("path"));
|
|
48
48
|
const anthropicClient_1 = require("./anthropicClient");
|
|
@@ -56,6 +56,7 @@ Object.defineProperty(exports, "GovernanceUnreachableError", { enumerable: true,
|
|
|
56
56
|
var llmStepMatcher_1 = require("./llmStepMatcher");
|
|
57
57
|
Object.defineProperty(exports, "matchStepWithLLM", { enumerable: true, get: function () { return llmStepMatcher_1.matchStepWithLLM; } });
|
|
58
58
|
Object.defineProperty(exports, "matchStepsWithLLM", { enumerable: true, get: function () { return llmStepMatcher_1.matchStepsWithLLM; } });
|
|
59
|
+
Object.defineProperty(exports, "matchScenarioWithLLM", { enumerable: true, get: function () { return llmStepMatcher_1.matchScenarioWithLLM; } });
|
|
59
60
|
/**
|
|
60
61
|
* Construct the right LLMClient for the given options. Today the only
|
|
61
62
|
* provider is "anthropic"; the factory exists so v2.1 (OpenAI/Gemini)
|
package/dist/llm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/llm/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/llm/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCH,0CAiBC;AAnDD,2CAA6B;AAC7B,uDAAuD;AAGvD,qDAAuD;AAA9C,qHAAA,kBAAkB,OAAA;AAC3B,mDAAwD;AAA/C,sHAAA,oBAAoB,OAAA;AAC7B,uDAAkF;AAAzE,oHAAA,gBAAgB,OAAA;AAAE,8HAAA,0BAA0B,OAAA;AACrD,mDAK0B;AAJxB,kHAAA,gBAAgB,OAAA;AAChB,mHAAA,iBAAiB,OAAA;AACjB,sHAAA,oBAAoB,OAAA;AAYtB;;;;;;;;;;;GAWG;AACH,SAAgB,eAAe,CAC7B,IAAkC,EAClC,QAAgB;IAEhB,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC9C,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAChC,QAAQ,EACR,SAAS,EACT,kBAAkB,CACnB,CAAC;IACF,QAAQ,IAAI,CAAC,QAAQ,EAAE,CAAC;QACtB,KAAK,WAAW;YACd,OAAO,IAAI,oCAAkB,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;QACxD;YACE,iCAAiC;YACjC,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC"}
|
|
@@ -35,6 +35,15 @@ export interface MatchStepWithLLMContext {
|
|
|
35
35
|
* stalled on disk, governance fetch stalled below the SDK).
|
|
36
36
|
*/
|
|
37
37
|
stepDeadlineMs?: number;
|
|
38
|
+
/**
|
|
39
|
+
* v3.5.0 — opt out of per-scenario batching. When true,
|
|
40
|
+
* `matchScenarioWithLLM` walks step-by-step through
|
|
41
|
+
* `matchStepWithLLM` instead of folding unmatched steps into a
|
|
42
|
+
* single batch call. Use only if you've hit a provider per-prompt
|
|
43
|
+
* token limit on large batches, or want strict 1:1 call accounting
|
|
44
|
+
* for audit reasons.
|
|
45
|
+
*/
|
|
46
|
+
disableBatch?: boolean;
|
|
38
47
|
}
|
|
39
48
|
export declare function matchStepWithLLM(step: StepIR, pom: PageObjectIR, pageVar: string, ctx: MatchStepWithLLMContext): Promise<StepBinding>;
|
|
40
49
|
/**
|
|
@@ -44,3 +53,31 @@ export declare function matchStepWithLLM(step: StepIR, pom: PageObjectIR, pageVa
|
|
|
44
53
|
* the cache and pay for the same step twice.
|
|
45
54
|
*/
|
|
46
55
|
export declare function matchStepsWithLLM(steps: StepIR[], pom: PageObjectIR, pageVar: string, ctx: MatchStepWithLLMContext): Promise<StepBinding[]>;
|
|
56
|
+
/**
|
|
57
|
+
* v3.5.0 — batch the LLM fallback per scenario.
|
|
58
|
+
*
|
|
59
|
+
* Per-scenario, this is significantly cheaper than per-step:
|
|
60
|
+
* - Each unmatched step is ONE entry in a single batch prompt.
|
|
61
|
+
* - Shared POM context is sent ONCE per batch (not per step).
|
|
62
|
+
* - One round-trip latency, not N.
|
|
63
|
+
* - One budget tick, not N.
|
|
64
|
+
*
|
|
65
|
+
* The cache still works exactly as before — each step has the same
|
|
66
|
+
* cache key it would have in the per-step path. AnthropicLLMClient's
|
|
67
|
+
* `generateBatchBindings` checks the cache per-step first; only
|
|
68
|
+
* cache-misses go into the batch prompt.
|
|
69
|
+
*
|
|
70
|
+
* Failure modes:
|
|
71
|
+
* - LLM client doesn't implement `generateBatchBindings` (e.g.
|
|
72
|
+
* custom client, older MockLLMClient): falls back to per-step
|
|
73
|
+
* `matchStepWithLLM` for every unmatched step.
|
|
74
|
+
* - Batch parse error: every slot in the batch comes back with an
|
|
75
|
+
* `error` result, which we then annotate as a per-step warning.
|
|
76
|
+
* - One bad slot in an otherwise-good batch: only that slot's
|
|
77
|
+
* step gets the warning annotation; the rest succeed.
|
|
78
|
+
*
|
|
79
|
+
* The candidate-rules.jsonl writer still receives one entry per
|
|
80
|
+
* successful LLM binding (same as per-step) so the offline review
|
|
81
|
+
* pipeline doesn't notice the batching change.
|
|
82
|
+
*/
|
|
83
|
+
export declare function matchScenarioWithLLM(steps: StepIR[], pom: PageObjectIR, pageVar: string, ctx: MatchStepWithLLMContext): Promise<StepBinding[]>;
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.matchStepWithLLM = matchStepWithLLM;
|
|
18
18
|
exports.matchStepsWithLLM = matchStepsWithLLM;
|
|
19
|
+
exports.matchScenarioWithLLM = matchScenarioWithLLM;
|
|
19
20
|
const stepMatcher_1 = require("../transformers/stepMatcher");
|
|
20
21
|
const commentSafe_1 = require("../utils/commentSafe");
|
|
21
22
|
async function matchStepWithLLM(step, pom, pageVar, ctx) {
|
|
@@ -123,4 +124,120 @@ async function matchStepsWithLLM(steps, pom, pageVar, ctx) {
|
|
|
123
124
|
}
|
|
124
125
|
return out;
|
|
125
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* v3.5.0 — batch the LLM fallback per scenario.
|
|
129
|
+
*
|
|
130
|
+
* Per-scenario, this is significantly cheaper than per-step:
|
|
131
|
+
* - Each unmatched step is ONE entry in a single batch prompt.
|
|
132
|
+
* - Shared POM context is sent ONCE per batch (not per step).
|
|
133
|
+
* - One round-trip latency, not N.
|
|
134
|
+
* - One budget tick, not N.
|
|
135
|
+
*
|
|
136
|
+
* The cache still works exactly as before — each step has the same
|
|
137
|
+
* cache key it would have in the per-step path. AnthropicLLMClient's
|
|
138
|
+
* `generateBatchBindings` checks the cache per-step first; only
|
|
139
|
+
* cache-misses go into the batch prompt.
|
|
140
|
+
*
|
|
141
|
+
* Failure modes:
|
|
142
|
+
* - LLM client doesn't implement `generateBatchBindings` (e.g.
|
|
143
|
+
* custom client, older MockLLMClient): falls back to per-step
|
|
144
|
+
* `matchStepWithLLM` for every unmatched step.
|
|
145
|
+
* - Batch parse error: every slot in the batch comes back with an
|
|
146
|
+
* `error` result, which we then annotate as a per-step warning.
|
|
147
|
+
* - One bad slot in an otherwise-good batch: only that slot's
|
|
148
|
+
* step gets the warning annotation; the rest succeed.
|
|
149
|
+
*
|
|
150
|
+
* The candidate-rules.jsonl writer still receives one entry per
|
|
151
|
+
* successful LLM binding (same as per-step) so the offline review
|
|
152
|
+
* pipeline doesn't notice the batching change.
|
|
153
|
+
*/
|
|
154
|
+
async function matchScenarioWithLLM(steps, pom, pageVar, ctx) {
|
|
155
|
+
// 1) Rule pass for every step. Cheap; pure-sync inside.
|
|
156
|
+
const ruleBindings = steps.map((s) => (0, stepMatcher_1.matchStep)(s, pom, pageVar));
|
|
157
|
+
// 2) Identify warning slots. If no LLM client or budget exhausted,
|
|
158
|
+
// bail out with the rule bindings — same as the per-step path.
|
|
159
|
+
if (!ctx.llm)
|
|
160
|
+
return ruleBindings;
|
|
161
|
+
const warningIndexes = ruleBindings
|
|
162
|
+
.map((b, i) => (b.warning ? i : -1))
|
|
163
|
+
.filter((i) => i >= 0);
|
|
164
|
+
if (warningIndexes.length === 0)
|
|
165
|
+
return ruleBindings;
|
|
166
|
+
if (ctx.llm.budgetExhausted())
|
|
167
|
+
return ruleBindings;
|
|
168
|
+
// 3) Choose the path: batch when the client supports it, otherwise
|
|
169
|
+
// fall back to per-step. Single-warning batches also fall through
|
|
170
|
+
// to the per-step path so the existing watchdog / deadline /
|
|
171
|
+
// candidate-rules-writer machinery handles them.
|
|
172
|
+
const batchCapable = typeof ctx.llm.generateBatchBindings === "function";
|
|
173
|
+
if (!batchCapable || warningIndexes.length === 1 || ctx.disableBatch) {
|
|
174
|
+
const out = [...ruleBindings];
|
|
175
|
+
for (const idx of warningIndexes) {
|
|
176
|
+
out[idx] = await matchStepWithLLM(steps[idx], pom, pageVar, ctx);
|
|
177
|
+
}
|
|
178
|
+
return out;
|
|
179
|
+
}
|
|
180
|
+
// 4) Batch path. Build inputs in the same order as warningIndexes.
|
|
181
|
+
const inputs = warningIndexes.map((idx) => ({
|
|
182
|
+
step: steps[idx],
|
|
183
|
+
pom,
|
|
184
|
+
pageVar,
|
|
185
|
+
url: ctx.url,
|
|
186
|
+
scaffoldId: ctx.scaffoldId,
|
|
187
|
+
}));
|
|
188
|
+
let batchResults;
|
|
189
|
+
try {
|
|
190
|
+
batchResults = await ctx.llm.generateBatchBindings(inputs);
|
|
191
|
+
}
|
|
192
|
+
catch (err) {
|
|
193
|
+
// Wrap-failure: annotate every warning slot with the throw message
|
|
194
|
+
// and continue. Matches the per-step path's `LLM fallback threw`
|
|
195
|
+
// annotation.
|
|
196
|
+
const message = (0, commentSafe_1.flattenForComment)(err instanceof Error ? err.message : err);
|
|
197
|
+
const out = [...ruleBindings];
|
|
198
|
+
for (const idx of warningIndexes) {
|
|
199
|
+
out[idx] = {
|
|
200
|
+
...ruleBindings[idx],
|
|
201
|
+
warning: `${ruleBindings[idx].warning} (LLM batch threw: ${message})`,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
return out;
|
|
205
|
+
}
|
|
206
|
+
// 5) Distribute results back to their original positions. Write
|
|
207
|
+
// candidate-rules.jsonl for every success; annotate warnings
|
|
208
|
+
// for every failure.
|
|
209
|
+
const out = [...ruleBindings];
|
|
210
|
+
for (let j = 0; j < warningIndexes.length; j++) {
|
|
211
|
+
const idx = warningIndexes[j];
|
|
212
|
+
const result = batchResults[j];
|
|
213
|
+
if (!result || !result.binding) {
|
|
214
|
+
out[idx] = {
|
|
215
|
+
...ruleBindings[idx],
|
|
216
|
+
warning: result?.error
|
|
217
|
+
? `${ruleBindings[idx].warning} (LLM fallback also failed: ${(0, commentSafe_1.flattenForComment)(result.error)})`
|
|
218
|
+
: ruleBindings[idx].warning,
|
|
219
|
+
};
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
if (ctx.candidates) {
|
|
223
|
+
await ctx.candidates.append({
|
|
224
|
+
ts: new Date().toISOString(),
|
|
225
|
+
scaffoldId: ctx.scaffoldId,
|
|
226
|
+
stepText: steps[idx].text,
|
|
227
|
+
stepKeyword: steps[idx].keyword,
|
|
228
|
+
binding: result.binding,
|
|
229
|
+
pomSignature: {
|
|
230
|
+
className: pom.className,
|
|
231
|
+
fieldNames: pom.fields.map((f) => f.fieldName),
|
|
232
|
+
methodNames: pom.methods.map((m) => m.name),
|
|
233
|
+
},
|
|
234
|
+
provider: "anthropic",
|
|
235
|
+
model: result.model ?? "(unknown)",
|
|
236
|
+
fromCache: result.fromCache,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
out[idx] = result.binding;
|
|
240
|
+
}
|
|
241
|
+
return out;
|
|
242
|
+
}
|
|
126
243
|
//# sourceMappingURL=llmStepMatcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llmStepMatcher.js","sourceRoot":"","sources":["../../src/llm/llmStepMatcher.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;
|
|
1
|
+
{"version":3,"file":"llmStepMatcher.js","sourceRoot":"","sources":["../../src/llm/llmStepMatcher.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;AAuCH,4CAwGC;AAQD,8CAWC;AA6BD,oDAkGC;AA/RD,6DAAwD;AAExD,sDAAyD;AAmClD,KAAK,UAAU,gBAAgB,CACpC,IAAY,EACZ,GAAiB,EACjB,OAAe,EACf,GAA4B;IAE5B,kCAAkC;IAClC,MAAM,SAAS,GAAG,IAAA,uBAAS,EAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAEhD,uEAAuE;IACvE,IAAI,CAAC,SAAS,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAEzC,kEAAkE;IAClE,IAAI,CAAC,GAAG,CAAC,GAAG;QAAE,OAAO,SAAS,CAAC;IAE/B,mEAAmE;IACnE,+DAA+D;I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,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;oBAC9C,WAAW,EAAE,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;iBAC5C;gBACD,QAAQ,EAAE,WAAW;gBACrB,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,WAAW;gBAClC,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAC,CAAC;QACL,CAAC;QACD,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC;IAC5B,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/llm/prompt.d.ts
CHANGED
|
@@ -31,6 +31,32 @@ export declare const SYSTEM_PROMPT = "You are a deterministic step-binding gener
|
|
|
31
31
|
* - The pageVar variable name to use in pomCall.page.
|
|
32
32
|
*/
|
|
33
33
|
export declare function buildUserPrompt(input: GenerateBindingInput): string;
|
|
34
|
+
/**
|
|
35
|
+
* v3.5.0 — batch prompt builder for `generateBatchBindings`.
|
|
36
|
+
*
|
|
37
|
+
* Why batching exists: a single scenario with N unmatched steps used to
|
|
38
|
+
* fire N separate Anthropic calls. Each call paid full round-trip
|
|
39
|
+
* latency + system-prompt tokens + POM-context tokens. Batching folds
|
|
40
|
+
* all N into one call. Cost reduction is roughly proportional to N when
|
|
41
|
+
* N > 1.
|
|
42
|
+
*
|
|
43
|
+
* The shared POM context (className, fields, methods, URL) is emitted
|
|
44
|
+
* ONCE at the top of the prompt — same as the single-step builder.
|
|
45
|
+
* Each step appears as a numbered entry:
|
|
46
|
+
*
|
|
47
|
+
* STEP 0001:
|
|
48
|
+
* <keyword> <text>
|
|
49
|
+
* <doc string / data table when present>
|
|
50
|
+
*
|
|
51
|
+
* STEP 0002:
|
|
52
|
+
* ...
|
|
53
|
+
*
|
|
54
|
+
* The model is instructed to return a JSON ARRAY of N binding objects,
|
|
55
|
+
* one per step, in the SAME ORDER. IDs are 4-digit zero-padded so the
|
|
56
|
+
* model can echo them back for sanity (we don't require it; callers
|
|
57
|
+
* parse by position).
|
|
58
|
+
*/
|
|
59
|
+
export declare function buildBatchUserPrompt(inputs: GenerateBindingInput[]): string;
|
|
34
60
|
/**
|
|
35
61
|
* Cache key — stable across runs given identical inputs. Determinism plus
|
|
36
62
|
* cost control: the same step text + POM signature returns the same binding
|
package/dist/llm/prompt.js
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.SYSTEM_PROMPT = void 0;
|
|
26
26
|
exports.buildUserPrompt = buildUserPrompt;
|
|
27
|
+
exports.buildBatchUserPrompt = buildBatchUserPrompt;
|
|
27
28
|
exports.cacheKey = cacheKey;
|
|
28
29
|
/** System prompt — shared across all generations. */
|
|
29
30
|
exports.SYSTEM_PROMPT = `You are a deterministic step-binding generator for bdd2pw, a Gherkin → Playwright TypeScript scaffolder.
|
|
@@ -102,6 +103,80 @@ ${methodsBlock}
|
|
|
102
103
|
|
|
103
104
|
Return the JSON binding now.`;
|
|
104
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* v3.5.0 — batch prompt builder for `generateBatchBindings`.
|
|
108
|
+
*
|
|
109
|
+
* Why batching exists: a single scenario with N unmatched steps used to
|
|
110
|
+
* fire N separate Anthropic calls. Each call paid full round-trip
|
|
111
|
+
* latency + system-prompt tokens + POM-context tokens. Batching folds
|
|
112
|
+
* all N into one call. Cost reduction is roughly proportional to N when
|
|
113
|
+
* N > 1.
|
|
114
|
+
*
|
|
115
|
+
* The shared POM context (className, fields, methods, URL) is emitted
|
|
116
|
+
* ONCE at the top of the prompt — same as the single-step builder.
|
|
117
|
+
* Each step appears as a numbered entry:
|
|
118
|
+
*
|
|
119
|
+
* STEP 0001:
|
|
120
|
+
* <keyword> <text>
|
|
121
|
+
* <doc string / data table when present>
|
|
122
|
+
*
|
|
123
|
+
* STEP 0002:
|
|
124
|
+
* ...
|
|
125
|
+
*
|
|
126
|
+
* The model is instructed to return a JSON ARRAY of N binding objects,
|
|
127
|
+
* one per step, in the SAME ORDER. IDs are 4-digit zero-padded so the
|
|
128
|
+
* model can echo them back for sanity (we don't require it; callers
|
|
129
|
+
* parse by position).
|
|
130
|
+
*/
|
|
131
|
+
function buildBatchUserPrompt(inputs) {
|
|
132
|
+
if (inputs.length === 0) {
|
|
133
|
+
throw new Error("buildBatchUserPrompt: inputs must be non-empty");
|
|
134
|
+
}
|
|
135
|
+
// POM context is the same across all inputs in a batch (same scaffold,
|
|
136
|
+
// same scenario, same POM). Use the first input as the source of
|
|
137
|
+
// truth.
|
|
138
|
+
const head = inputs[0];
|
|
139
|
+
const { pom, pageVar, url } = head;
|
|
140
|
+
const fieldsBlock = pom.fields.length
|
|
141
|
+
? pom.fields
|
|
142
|
+
.map((f) => ` - ${f.fieldName}: ${pageVar}.${f.fieldName} (page.${f.api}(${f.args}))`)
|
|
143
|
+
.join("\n")
|
|
144
|
+
: " (no fields discovered yet)";
|
|
145
|
+
const methodsBlock = pom.methods.length
|
|
146
|
+
? pom.methods
|
|
147
|
+
.map((m) => ` - ${m.name}(${m.params.map((p) => `${p.name}: ${p.type}`).join(", ")})`)
|
|
148
|
+
.join("\n")
|
|
149
|
+
: " (no methods)";
|
|
150
|
+
const stepBlocks = inputs
|
|
151
|
+
.map((input, idx) => {
|
|
152
|
+
const id = String(idx + 1).padStart(4, "0");
|
|
153
|
+
const arg = input.step.argument
|
|
154
|
+
? typeof input.step.argument === "string"
|
|
155
|
+
? `\n Doc string:\n ${input.step.argument.replace(/\n/g, "\n ")}`
|
|
156
|
+
: `\n Data table:\n ${JSON.stringify(input.step.argument)}`
|
|
157
|
+
: "";
|
|
158
|
+
return `STEP ${id}:\n ${input.step.keyword} ${input.step.text}${arg}`;
|
|
159
|
+
})
|
|
160
|
+
.join("\n\n");
|
|
161
|
+
return `Multiple Gherkin steps from the same scenario didn't match any rule. Produce one StepBinding per step.
|
|
162
|
+
|
|
163
|
+
POM context (shared across all steps):
|
|
164
|
+
className: ${pom.className}
|
|
165
|
+
pageVar: ${pageVar}
|
|
166
|
+
url: ${url ?? "(none)"}
|
|
167
|
+
|
|
168
|
+
POM fields:
|
|
169
|
+
${fieldsBlock}
|
|
170
|
+
|
|
171
|
+
POM methods:
|
|
172
|
+
${methodsBlock}
|
|
173
|
+
|
|
174
|
+
Steps:
|
|
175
|
+
|
|
176
|
+
${stepBlocks}
|
|
177
|
+
|
|
178
|
+
Return a JSON ARRAY of ${inputs.length} StepBinding object(s) — one per step, IN THE SAME ORDER as the STEP ${String(1).padStart(4, "0")}..STEP ${String(inputs.length).padStart(4, "0")} list above. Same per-binding shape and rules as the single-step prompt. Do NOT wrap the array in any other object; the response must be a bare \`[...]\`.`;
|
|
179
|
+
}
|
|
105
180
|
/**
|
|
106
181
|
* Cache key — stable across runs given identical inputs. Determinism plus
|
|
107
182
|
* cost control: the same step text + POM signature returns the same binding
|
package/dist/llm/prompt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/llm/prompt.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;AAiDH,0CA0CC;AAOD,4BAaC;
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/llm/prompt.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;AAiDH,0CA0CC;AA2BD,oDA0DC;AAOD,4BAaC;AAhMD,qDAAqD;AACxC,QAAA,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iVAmCoT,CAAC;AAElV;;;;;;GAMG;AACH,SAAgB,eAAe,CAAC,KAA2B;IACzD,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;IAE1C,MA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AC,GAAG,CAAC,CAAC;IAC1E,sEAAsE;IACtE,OAAO;QACL,IAAI;QACJ,KAAK;QACL,KAAK,CAAC,IAAI,CAAC,OAAO;QAClB,KAAK,CAAC,IAAI,CAAC,IAAI;QACf,KAAK,CAAC,GAAG,CAAC,SAAS;QACnB,UAAU;QACV,WAAW;KACZ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACd,CAAC"}
|
package/dist/llm/types.d.ts
CHANGED
|
@@ -67,6 +67,14 @@ export interface LLMClientOptions {
|
|
|
67
67
|
* Default: 15_000 (15 s).
|
|
68
68
|
*/
|
|
69
69
|
governanceTimeoutMs?: number;
|
|
70
|
+
/**
|
|
71
|
+
* v3.5.0 — disable the batch fallback path. When true, every
|
|
72
|
+
* unmatched step fires its own provider call (the pre-v3.5 default).
|
|
73
|
+
* Use only if a customer hits a provider-side per-prompt token
|
|
74
|
+
* limit on large batches, or wants strict 1:1 call accounting for
|
|
75
|
+
* audit reasons.
|
|
76
|
+
*/
|
|
77
|
+
disableBatch?: boolean;
|
|
70
78
|
}
|
|
71
79
|
export type LLMLogEvent = {
|
|
72
80
|
kind: "cache_hit";
|
|
@@ -139,6 +147,20 @@ export interface GenerateBindingResult {
|
|
|
139
147
|
export interface LLMClient {
|
|
140
148
|
/** Generate a StepBinding for an unmatched step. */
|
|
141
149
|
generateBinding(input: GenerateBindingInput): Promise<GenerateBindingResult>;
|
|
150
|
+
/**
|
|
151
|
+
* v3.5.0 — generate bindings for MULTIPLE unmatched steps in one
|
|
152
|
+
* provider call. The implementation must:
|
|
153
|
+
* 1. Honour cache per-step (skip steps already cached, return their
|
|
154
|
+
* cached results in order, fold the rest into a batch prompt).
|
|
155
|
+
* 2. Count the batch as ONE call against `budgetExhausted`.
|
|
156
|
+
* 3. Return results in the same order as `inputs`.
|
|
157
|
+
* 4. Soft-fail per-step on parse error (one bad slot doesn't kill
|
|
158
|
+
* the whole batch).
|
|
159
|
+
*
|
|
160
|
+
* Optional — older clients (or test stubs) that don't implement it
|
|
161
|
+
* make `matchScenarioWithLLM` fall back to per-step `generateBinding`.
|
|
162
|
+
*/
|
|
163
|
+
generateBatchBindings?(inputs: GenerateBindingInput[]): Promise<GenerateBindingResult[]>;
|
|
142
164
|
/** Have we hit the max-calls budget for this scaffold? */
|
|
143
165
|
budgetExhausted(): boolean;
|
|
144
166
|
/** Successful provider responses (parsed bindings). */
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v3.4.0 — Banking domain rule pack.
|
|
3
|
+
*
|
|
4
|
+
* Opt-in via `ScaffoldOptions.domains: ["banking"]`. When activated,
|
|
5
|
+
* these rules slot into the matcher registry BEFORE the URL-slug
|
|
6
|
+
* guardrails so banking-specific prose ("the account balance is
|
|
7
|
+
* $1,234.56") intercepts before drifting into the generic catch-all.
|
|
8
|
+
*
|
|
9
|
+
* Each rule emits `customBody` rather than a pomCall/assertion so the
|
|
10
|
+
* downstream emitter doesn't need to invent a POM field. The body
|
|
11
|
+
* lines reference standard test helpers (`page.evaluate`,
|
|
12
|
+
* `expect(text).toMatch`) that work against any banking app.
|
|
13
|
+
*
|
|
14
|
+
* Coverage:
|
|
15
|
+
* - Account balance (toContainText with currency-formatted value)
|
|
16
|
+
* - Transfers between accounts
|
|
17
|
+
* - Transaction fees
|
|
18
|
+
* - Statement transaction counts
|
|
19
|
+
* - Daily withdrawal / deposit limits
|
|
20
|
+
* - Regulation E (dispute filing windows)
|
|
21
|
+
* - Regulation D (savings withdrawal counts)
|
|
22
|
+
* - KYC / AML statuses
|
|
23
|
+
* - Transaction dates
|
|
24
|
+
* - Account opening / closing
|
|
25
|
+
*
|
|
26
|
+
* Patterns intentionally accept either `$1,234.56` or `"$1,234.56"`
|
|
27
|
+
* (LLM-emitted .feature files sometimes quote the currency). Numeric
|
|
28
|
+
* captures preserve commas — they're surfaced to the test as-is so
|
|
29
|
+
* the assertion matches what the page actually renders.
|
|
30
|
+
*/
|
|
31
|
+
import type { PageObjectIR, StepBinding, StepIR } from "../../types";
|
|
32
|
+
interface Rule {
|
|
33
|
+
pattern: RegExp;
|
|
34
|
+
build(m: RegExpMatchArray, step: StepIR, pom: PageObjectIR, pageVar: string): StepBinding | null;
|
|
35
|
+
}
|
|
36
|
+
export declare const BANKING_RULES: Rule[];
|
|
37
|
+
export {};
|