@promptdriven/runtime-client 1.1.2 → 1.1.4
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/package.json +1 -1
- package/src/runtime/contract-refs.mjs +4 -0
- package/src/runtime/index.mjs +27 -0
- package/src/runtime/prompt-clauses.mjs +290 -0
- package/src/runtime/run-program.mjs +13 -8
- package/src/runtime/runtime-binding-plan.mjs +116 -15
- package/src/runtime/runtime-bindings.mjs +11 -5
- package/src/runtime/runtime-check-plan.mjs +40 -14
- package/src/runtime/runtime-client.mjs +559 -154
- package/src/runtime/runtime-markdown.mjs +95 -41
- package/src/runtime/runtime-outcome.mjs +156 -5
- package/src/runtime/runtime-output.mjs +54 -9
- package/src/runtime/runtime-preflight.mjs +1176 -39
- package/src/runtime/try-doors.mjs +105 -23
- package/src/runtime/try-http.mjs +232 -10
- package/src/runtime/try-mcp.mjs +7 -1
|
@@ -33,14 +33,18 @@ export function bindingCoverage({ root, found, selected, includeRuntime = false,
|
|
|
33
33
|
if (!keys(inventory, ['schema_version', 'modules']) || inventory.schema_version !== 'pdd.bindings.v1' || !Array.isArray(inventory.modules)) fail('inventory', 'expected schema_version pdd.bindings.v1 and modules array only');
|
|
34
34
|
if (inventory.modules.length > 1000) fail('inventory', 'exceeds 1000 module declarations');
|
|
35
35
|
const stories = new Set(found.stories.map(s => s.path)), chosen = new Set(selected.map(t => t.storyPath)), seen = new Set(), modules = [];
|
|
36
|
-
const reached = new Set(), context = new Set(), visited = new Set();
|
|
36
|
+
const reached = new Set(), context = new Set(), visited = new Set(), promptCache = new Map();
|
|
37
|
+
const getPrompt = path => {
|
|
38
|
+
if (!promptCache.has(path)) promptCache.set(path, readPrompt(root, found.visible, path, workspace));
|
|
39
|
+
return promptCache.get(path);
|
|
40
|
+
};
|
|
37
41
|
const queue = selected.flatMap(t => (Array.isArray(t.doc?.steps) ? t.doc.steps : []).map(s => ({path:s?.entry_path, executable:true})));
|
|
38
42
|
while (queue.length) {
|
|
39
43
|
const {path,executable} = queue.shift(), identity = `${executable ? 'call' : 'context'}:${path}`;
|
|
40
44
|
if (typeof path !== 'string' || visited.has(identity)) continue;
|
|
41
45
|
visited.add(identity);
|
|
42
46
|
(executable ? reached : context).add(path);
|
|
43
|
-
const prompt =
|
|
47
|
+
const prompt = getPrompt(path);
|
|
44
48
|
for (const call of Array.isArray(prompt?.interface?.calls) ? prompt.interface.calls : []) if (typeof call?.target === 'string') queue.push({path:call.target,executable});
|
|
45
49
|
for (const target of promptMarkdownTargets(prompt.text, path, found.visible)) queue.push({path:target,executable:false});
|
|
46
50
|
}
|
|
@@ -56,9 +60,11 @@ export function bindingCoverage({ root, found, selected, includeRuntime = false,
|
|
|
56
60
|
for (const story of itemStories) { regular(story); if (!stories.has(story)) fail(path, `unknown Story ${story}`); }
|
|
57
61
|
if (bound) { regular(item.prompt); if (!item.prompt.endsWith('.prompt.md')) fail(path, `${item.prompt} must be a *.prompt.md file`); }
|
|
58
62
|
else for (const key of ['reason', 'port_attempt']) if (typeof item[key] !== 'string' || !item[key].trim()) fail(path, `${key} must be nonblank`);
|
|
59
|
-
|
|
63
|
+
const selectedByStories = itemStories.some(story => chosen.has(story));
|
|
64
|
+
const selectedByReach = bound && !hasStories && (reached.has(item.prompt) || context.has(item.prompt));
|
|
65
|
+
if (!selectedByStories && !selectedByReach) continue;
|
|
60
66
|
if (bound) {
|
|
61
|
-
const prompt =
|
|
67
|
+
const prompt = getPrompt(item.prompt);
|
|
62
68
|
const nativeProblem = (prompt.frontmatter || prompt?.interface?.kind === 'native-only') ? promptRefusal(prompt, 'interface') : null;
|
|
63
69
|
if (nativeProblem) fail(path, nativeProblem.message);
|
|
64
70
|
if (!prompt.error && prompt?.interface?.kind === 'native-only' && typeof prompt.interface.reason === 'string' && prompt.interface.reason.trim()) {
|
|
@@ -66,7 +72,7 @@ export function bindingCoverage({ root, found, selected, includeRuntime = false,
|
|
|
66
72
|
continue;
|
|
67
73
|
}
|
|
68
74
|
const lazyMissing = allowMissingInterfaces && prompt.error === 'interface-missing';
|
|
69
|
-
if (!reached.has(item.prompt) && context.has(item.prompt) && prompt.error === 'interface-missing') {
|
|
75
|
+
if (!reached.has(item.prompt) && context.has(item.prompt) && (prompt.error === 'interface-missing' || (!hasStories && !prompt.error))) {
|
|
70
76
|
modules.push({path:item.module,state:'unbound',prompt:item.prompt,
|
|
71
77
|
reason:'Context-only module contract',
|
|
72
78
|
port_attempt:'no executable Runtime call'});
|
|
@@ -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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
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)))
|