@promptdriven/runtime-client 1.1.2 → 1.1.3

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.
@@ -1,7 +1,7 @@
1
1
  // Generated from prompts/cli/runtime-check-plan.prompt.md (sha256: 081b45f925041a79c1e7ecf6b9b36ff3c4b10166ae0faecccfc138c2c0904780).
2
2
  import { spawnSync } from 'node:child_process';
3
3
  import { isAbsolute, posix } from 'node:path';
4
- import { captureSource, readPrompt, sourceFilePort, analyzeStepCallCost, hasSimulationBindings, LAZY_INTERFACE_SYNTHESIS_CALLS } from './runtime-preflight.mjs';
4
+ import { captureSource, captureStoryClosures, readPrompt, sourceFilePort, analyzeStepCallCost, hasSimulationBindings, LAZY_INTERFACE_SYNTHESIS_CALLS } from './runtime-preflight.mjs';
5
5
  import { resultOutcome } from './runtime-outcome.mjs';
6
6
  import { allowsRuntimePath, loadRuntimeWorkspace } from './runtime-workspace.mjs';
7
7
 
@@ -142,6 +142,12 @@ export function buildCheckPlan({ root, found, selected, rows = [], full, base =
142
142
  groups.get(key).push(test);
143
143
  }
144
144
  const capture = ports.capture ?? ((r, opts) => captureSource(r, opts, ports));
145
+ const hasSelectionPorts = typeof ports.isStoryPath === 'function'
146
+ && typeof ports.hasAcceptance === 'function'
147
+ && typeof ports.matchTests === 'function'
148
+ && typeof ports.orphanSummary === 'function';
149
+ const isBuiltInCapture = (!ports.capture || ports.capture === captureSource || ports.capture.isDefaultCapture === true)
150
+ && (!ports.capture || hasSelectionPorts);
145
151
  let footprints = new Map();
146
152
  const targets = new Map();
147
153
  const rememberTargets = captured => {
@@ -149,20 +155,40 @@ export function buildCheckPlan({ root, found, selected, rows = [], full, base =
149
155
  return captured;
150
156
  };
151
157
  const captureExtra = allowMissingInterfaces ? { allowMissingInterfaces: true } : {};
152
- try {
153
- const captured = rememberTargets(capture(root,{tests:selected.map(test=>test.path),appMap:null,excludeFixtureProjects:full,...captureExtra}));
154
- footprints = new Map((captured.stories ?? []).map(story=>[story.story_path,story]));
155
- } catch (error) { if (error?.unboundPort) throw error; /* Keep a broken Story from hiding other Stories' closures. */ }
156
- const classified = [...groups].map(([story_path, tests]) => {
157
- let closure = [], unavailable = false;
158
- const footprint = footprints.get(story_path);
158
+ let classified;
159
+ if (isBuiltInCapture) {
160
+ const batched = captureStoryClosures(root, {
161
+ groups: [...groups].map(([story_path, tests]) => ({ story_path, tests: tests.map(test => test.path) })),
162
+ workspace,
163
+ excludeFixtureProjects: full,
164
+ ...captureExtra,
165
+ }, ports);
166
+ for (const [k, v] of batched.targets) targets.set(k, v);
167
+ classified = [...groups].map(([story_path, tests]) => {
168
+ const entry = batched.closures.get(story_path);
169
+ return {
170
+ story_path,
171
+ tests,
172
+ closure: entry && !entry.unavailable ? sorted(entry.closure) : [],
173
+ unavailable: !entry || entry.unavailable === true,
174
+ };
175
+ });
176
+ } else {
159
177
  try {
160
- if (footprint?.unavailable) unavailable = true;
161
- else closure = sorted((footprint?.files ?? rememberTargets(capture(root, {tests:tests.map(test=>test.path),appMap:null,excludeFixtureProjects:full,...captureExtra})).files).map(file=>file.path));
162
- }
163
- catch (error) { if (error?.unboundPort) throw error; unavailable = true; }
164
- return {story_path,tests,closure,unavailable};
165
- });
178
+ const captured = rememberTargets(capture(root,{tests:selected.map(test=>test.path),appMap:null,excludeFixtureProjects:full,...captureExtra}));
179
+ footprints = new Map((captured.stories ?? []).map(story=>[story.story_path,story]));
180
+ } catch (error) { if (error?.unboundPort) throw error; /* Keep a broken Story from hiding other Stories' closures. */ }
181
+ classified = [...groups].map(([story_path, tests]) => {
182
+ let closure = [], unavailable = false;
183
+ const footprint = footprints.get(story_path);
184
+ try {
185
+ if (footprint?.unavailable) unavailable = true;
186
+ else closure = sorted((footprint?.files ?? rememberTargets(capture(root, {tests:tests.map(test=>test.path),appMap:null,excludeFixtureProjects:full,...captureExtra})).files).map(file=>file.path));
187
+ }
188
+ catch (error) { if (error?.unboundPort) throw error; unavailable = true; }
189
+ return {story_path,tests,closure,unavailable};
190
+ });
191
+ }
166
192
  let conservative = '';
167
193
  if (affected && changed?.length) {
168
194
  if (changed.some(path=>['pdd-source.json','pdd-workspace.json','pdd-bindings.json'].includes(path)))