@cratis/pi 7.159.1 → 7.160.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/package/corpus/harnesses/pi/extensions/subagent/agents.ts +11 -2
- package/package/corpus/harnesses/pi/extensions/subagent/index.ts +136 -96
- package/package/corpus/harnesses/pi/extensions/subagent/modelTiers.ts +123 -0
- package/package/corpus/skills/cratis-screenplay-captures-and-reactions/SKILL.md +1 -1
- package/package/corpus/skills/cratis-screenplay-captures-and-reactions/references/reaction-forms.md +23 -0
- package/package/corpus/skills/cratis-screenplay-captures-and-reactions/verification.json +4 -1
- package/package/corpus/skills/cratis-screenplay-projections/SKILL.md +3 -0
- package/package/corpus/skills/cratis-screenplay-projections/verification.json +2 -1
- package/package/corpus/skills/cratis-screenplay-read-surface/references/screen-patterns.md +8 -1
- package/package/corpus/skills/cratis-screenplay-read-surface/verification.json +2 -0
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/SKILL.md +3 -1
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/verification.json +3 -1
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/spec-forms-by-mode.md +1 -1
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/verification.json +2 -1
- package/package/corpus/skills/cratis-screenplay-specifications/SKILL.md +1 -1
- package/package/corpus/skills/cratis-screenplay-specifications/references/producerless-events.md +63 -0
- package/package/corpus/skills/cratis-screenplay-specifications/references/worked-example.md +2 -1
- package/package/corpus/skills/cratis-screenplay-specifications/verification.json +4 -1
- package/package/corpus/skills/cratis-screenplay-toolchain/SKILL.md +2 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/references/executable-subset.md +3 -1
- package/package/corpus/skills/cratis-screenplay-toolchain/references/language-admission.md +5 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/references/read-model-property-order.md +26 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/references/unknown-preserving-reader.md +57 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/verification.json +11 -1
- package/package/corpus/skills/cratis-screenplay-ui-composition/references/action-subjects.md +27 -1
- package/package/corpus/skills/cratis-screenplay-ui-composition/references/guarded-interactions.md +2 -1
- package/package/corpus/skills/cratis-screenplay-ui-composition/verification.json +5 -1
- package/package/corpus/skills/cratis-stage-rendering-and-sandbox/SKILL.md +3 -1
- package/package/corpus/skills/cratis-stage-rendering-and-sandbox/verification.json +2 -1
- package/package.json +1 -1
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Agent discovery + format normalization for the Cratis subagent tool.
|
|
3
6
|
*
|
|
@@ -5,8 +8,8 @@
|
|
|
5
8
|
* surfaced to Pi through generated Pi-native adapters in `.pi/agents/*.md`. The canonical
|
|
6
9
|
* files use Claude/Copilot tool names such as `Read`/`Glob`/`Bash`; generated files use
|
|
7
10
|
* Pi's lowercase names. This loader also normalizes canonical, user and legacy files
|
|
8
|
-
* with the same tool-name map used by generation.
|
|
9
|
-
*
|
|
11
|
+
* with the same tool-name map used by generation. Model overrides, tiers and reviewer
|
|
12
|
+
* independence are retained for resolution against user configuration at dispatch.
|
|
10
13
|
*/
|
|
11
14
|
|
|
12
15
|
import * as fs from "node:fs";
|
|
@@ -32,6 +35,8 @@ export interface AgentConfig {
|
|
|
32
35
|
*/
|
|
33
36
|
toolsError?: string;
|
|
34
37
|
model?: string;
|
|
38
|
+
modelTier?: string;
|
|
39
|
+
reviewIndependence?: string;
|
|
35
40
|
systemPrompt: string;
|
|
36
41
|
source: "package" | "user" | "project";
|
|
37
42
|
filePath: string;
|
|
@@ -47,6 +52,8 @@ type AgentFrontmatter = {
|
|
|
47
52
|
description?: unknown;
|
|
48
53
|
tools?: unknown;
|
|
49
54
|
model?: unknown;
|
|
55
|
+
modelTier?: unknown;
|
|
56
|
+
reviewIndependence?: unknown;
|
|
50
57
|
};
|
|
51
58
|
|
|
52
59
|
/**
|
|
@@ -96,6 +103,8 @@ function loadAgentsFromDir(dir: string, source: "package" | "user" | "project"):
|
|
|
96
103
|
tools: normalizeTools(frontmatter.tools),
|
|
97
104
|
toolsError: toolsErrorFor(frontmatter.name, frontmatter.tools),
|
|
98
105
|
model: typeof frontmatter.model === "string" ? frontmatter.model.trim() : undefined,
|
|
106
|
+
modelTier: typeof frontmatter.modelTier === "string" ? frontmatter.modelTier.trim() : undefined,
|
|
107
|
+
reviewIndependence: typeof frontmatter.reviewIndependence === "string" ? frontmatter.reviewIndependence.trim() : undefined,
|
|
99
108
|
systemPrompt: body,
|
|
100
109
|
source,
|
|
101
110
|
filePath,
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Cratis Subagent tool for the Pi coding agent.
|
|
3
6
|
*
|
|
@@ -23,11 +26,12 @@ import * as fs from "node:fs";
|
|
|
23
26
|
import * as os from "node:os";
|
|
24
27
|
import * as path from "node:path";
|
|
25
28
|
import { fileURLToPath } from "node:url";
|
|
26
|
-
import { CONFIG_DIR_NAME, type ExtensionAPI, getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
29
|
+
import { CONFIG_DIR_NAME, type ExtensionAPI, type ExtensionContext, getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
27
30
|
import { StringEnum } from "@earendil-works/pi-ai";
|
|
28
|
-
import { Type } from "typebox";
|
|
31
|
+
import { Type, type Static } from "typebox";
|
|
29
32
|
import { type AgentConfig, type AgentScope, discoverAgents } from "./agents.ts";
|
|
30
33
|
import { foreignDelegationTool, standDownNotice, SUBAGENT_TOOL_NAME } from "./delegation.ts";
|
|
34
|
+
import { readModelTierConfig, resolveModel, type ModelResolution, type ModelTierInputs } from "./modelTiers.ts";
|
|
31
35
|
|
|
32
36
|
const extensionPath = fileURLToPath(import.meta.url);
|
|
33
37
|
const isPackagedExtension = extensionPath.includes(`${path.sep}package${path.sep}corpus${path.sep}`);
|
|
@@ -43,6 +47,8 @@ interface SingleResult {
|
|
|
43
47
|
finalText: string;
|
|
44
48
|
stderr: string;
|
|
45
49
|
model?: string;
|
|
50
|
+
modelOutcome?: ModelResolution['outcome'];
|
|
51
|
+
modelNotice?: string;
|
|
46
52
|
stopReason?: string;
|
|
47
53
|
errorMessage?: string;
|
|
48
54
|
step?: number;
|
|
@@ -52,9 +58,10 @@ function isFailed(r: SingleResult): boolean {
|
|
|
52
58
|
return r.exitCode !== 0 || r.stopReason === "error" || r.stopReason === "aborted";
|
|
53
59
|
}
|
|
54
60
|
|
|
55
|
-
function resultOutput(r: SingleResult): string {
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
function resultOutput(r: SingleResult, results: SingleResult[] = [r]): string {
|
|
62
|
+
const output = isFailed(r) ? r.errorMessage || r.stderr || r.finalText || "(no output)" : r.finalText || "(no output)";
|
|
63
|
+
const notices = [...new Set(results.map(result => result.modelNotice).filter(Boolean))];
|
|
64
|
+
return [...notices, output].join("\n\n");
|
|
58
65
|
}
|
|
59
66
|
|
|
60
67
|
function capOutput(output: string): string {
|
|
@@ -76,9 +83,30 @@ function piInvocation(args: string[]): { command: string; args: string[] } {
|
|
|
76
83
|
return { command: "pi", args };
|
|
77
84
|
}
|
|
78
85
|
|
|
86
|
+
type OutputEvent = { type?: string; message?: { role?: string; content?: { type?: string; text?: string }[]; model?: string; stopReason?: string; errorMessage?: string } };
|
|
87
|
+
|
|
88
|
+
function assistantMessage(line: string): OutputEvent['message'] {
|
|
89
|
+
let event: OutputEvent;
|
|
90
|
+
try { event = JSON.parse(line); } catch { return undefined; }
|
|
91
|
+
if (event.type !== "message_end") return undefined;
|
|
92
|
+
return event.message?.role === "assistant" ? event.message : undefined;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function updateAssistantResult(result: SingleResult, message: NonNullable<OutputEvent['message']>, onText?: (text: string) => void): void {
|
|
96
|
+
for (const part of message.content ?? []) {
|
|
97
|
+
if (part.type === "text" && typeof part.text === "string") {
|
|
98
|
+
result.finalText = part.text;
|
|
99
|
+
onText?.(part.text);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (!result.model && message.model) result.model = message.model;
|
|
103
|
+
if (message.stopReason) result.stopReason = message.stopReason;
|
|
104
|
+
if (message.errorMessage) result.errorMessage = message.errorMessage;
|
|
105
|
+
}
|
|
106
|
+
|
|
79
107
|
async function runSingleAgent(
|
|
80
108
|
defaultCwd: string,
|
|
81
|
-
dispatch: { model?: string; thinkingLevel?: string },
|
|
109
|
+
dispatch: Omit<ModelTierInputs, 'agent' | 'dispatchModel'> & { model?: string; thinkingLevel?: string; onNotice: (notice: string) => void },
|
|
82
110
|
agents: AgentConfig[],
|
|
83
111
|
agentName: string,
|
|
84
112
|
task: string,
|
|
@@ -115,11 +143,12 @@ async function runSingleAgent(
|
|
|
115
143
|
};
|
|
116
144
|
}
|
|
117
145
|
|
|
118
|
-
|
|
119
|
-
const model =
|
|
146
|
+
const resolution = resolveModel({ ...dispatch, agent, dispatchModel: dispatch.model });
|
|
147
|
+
const { model } = resolution;
|
|
148
|
+
if (resolution.notice) dispatch.onNotice(resolution.notice);
|
|
120
149
|
const args: string[] = ["--mode", "json", "-p", "--no-session"];
|
|
121
150
|
if (model) args.push("--model", model);
|
|
122
|
-
if (
|
|
151
|
+
if (resolution.thinkingInherited && dispatch.thinkingLevel) args.push("--thinking", dispatch.thinkingLevel);
|
|
123
152
|
if (agent.tools && agent.tools.length > 0) args.push("--tools", agent.tools.join(","));
|
|
124
153
|
|
|
125
154
|
const result: SingleResult = {
|
|
@@ -130,6 +159,8 @@ async function runSingleAgent(
|
|
|
130
159
|
finalText: "",
|
|
131
160
|
stderr: "",
|
|
132
161
|
model,
|
|
162
|
+
modelOutcome: resolution.outcome,
|
|
163
|
+
modelNotice: resolution.notice,
|
|
133
164
|
step,
|
|
134
165
|
};
|
|
135
166
|
|
|
@@ -155,24 +186,8 @@ async function runSingleAgent(
|
|
|
155
186
|
let buffer = "";
|
|
156
187
|
const processLine = (line: string) => {
|
|
157
188
|
if (!line.trim()) return;
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
event = JSON.parse(line);
|
|
161
|
-
} catch {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
if (event.type === "message_end" && event.message?.role === "assistant") {
|
|
165
|
-
const msg = event.message;
|
|
166
|
-
for (const part of msg.content ?? []) {
|
|
167
|
-
if (part.type === "text" && typeof part.text === "string") {
|
|
168
|
-
result.finalText = part.text;
|
|
169
|
-
onText?.(part.text);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
if (!result.model && msg.model) result.model = msg.model;
|
|
173
|
-
if (msg.stopReason) result.stopReason = msg.stopReason;
|
|
174
|
-
if (msg.errorMessage) result.errorMessage = msg.errorMessage;
|
|
175
|
-
}
|
|
189
|
+
const message = assistantMessage(line);
|
|
190
|
+
if (message) updateAssistantResult(result, message, onText);
|
|
176
191
|
};
|
|
177
192
|
proc.stdout.on("data", (data) => {
|
|
178
193
|
buffer += data.toString();
|
|
@@ -250,6 +265,91 @@ const SubagentParams = Type.Object({
|
|
|
250
265
|
cwd: Type.Optional(Type.String({ description: "Working directory for the agent process (single mode)" })),
|
|
251
266
|
});
|
|
252
267
|
|
|
268
|
+
type AgentTask = Static<typeof TaskItem>;
|
|
269
|
+
type RunTask = (task: AgentTask, step?: number) => Promise<SingleResult>;
|
|
270
|
+
|
|
271
|
+
function modelDispatch(ctx: ExtensionContext) {
|
|
272
|
+
let modelNoticeShown = false;
|
|
273
|
+
return {
|
|
274
|
+
...readModelTierConfig(getAgentDir()),
|
|
275
|
+
model: ctx.model ? `${ctx.model.provider}/${ctx.model.id}` : undefined,
|
|
276
|
+
thinkingLevel: ctx.thinkingLevel,
|
|
277
|
+
available: ctx.modelRegistry.getAvailable().map(model => `${model.provider}/${model.id}`),
|
|
278
|
+
onNotice: (notice: string) => {
|
|
279
|
+
if (ctx.hasUI && !modelNoticeShown) {
|
|
280
|
+
modelNoticeShown = true;
|
|
281
|
+
ctx.ui.notify(notice, 'warning');
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function needsProjectConfirmation(params: Static<typeof SubagentParams>, ctx: ExtensionContext): boolean {
|
|
288
|
+
if (params.agentScope === 'user') return false;
|
|
289
|
+
return (params.confirmProjectAgents ?? false) && Boolean(ctx.hasUI);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
async function approveProjectAgents(params: Static<typeof SubagentParams>, ctx: ExtensionContext, discovery: ReturnType<typeof discoverAgents>): Promise<boolean> {
|
|
293
|
+
if (!needsProjectConfirmation(params, ctx)) return true;
|
|
294
|
+
const requested = new Set<string>();
|
|
295
|
+
for (const task of params.chain ?? []) requested.add(task.agent);
|
|
296
|
+
for (const task of params.tasks ?? []) requested.add(task.agent);
|
|
297
|
+
if (params.agent) requested.add(params.agent);
|
|
298
|
+
const projectRequested = Array.from(requested)
|
|
299
|
+
.map(name => discovery.agents.find(agent => agent.name === name))
|
|
300
|
+
.filter((agent): agent is AgentConfig => agent?.source === 'project');
|
|
301
|
+
if (projectRequested.length === 0) return true;
|
|
302
|
+
return ctx.ui.confirm(
|
|
303
|
+
"Run project-local agents?",
|
|
304
|
+
`Agents: ${projectRequested.map(agent => agent.name).join(", ")}\nSource: ${discovery.projectAgentsDir ?? "(unknown)"}\n\nProject agents are repo-controlled. Only continue for trusted repositories.`,
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function exactlyOneMode(params: Static<typeof SubagentParams>): boolean {
|
|
309
|
+
const hasChain = (params.chain?.length ?? 0) > 0;
|
|
310
|
+
const hasTasks = (params.tasks?.length ?? 0) > 0;
|
|
311
|
+
const hasSingle = Boolean(params.agent && params.task);
|
|
312
|
+
return Number(hasChain) + Number(hasTasks) + Number(hasSingle) === 1;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
async function runChain(chain: AgentTask[], run: RunTask) {
|
|
316
|
+
const results: SingleResult[] = [];
|
|
317
|
+
let previous = "";
|
|
318
|
+
for (let i = 0; i < chain.length; i++) {
|
|
319
|
+
const stepDef = chain[i];
|
|
320
|
+
const task = stepDef.task.replace(/\{previous\}/g, previous);
|
|
321
|
+
const result = await run({ ...stepDef, task }, i + 1);
|
|
322
|
+
results.push(result);
|
|
323
|
+
if (isFailed(result)) {
|
|
324
|
+
return {
|
|
325
|
+
content: [{ type: "text" as const, text: `Chain stopped at step ${i + 1} (${stepDef.agent}): ${resultOutput(result, results)}` }],
|
|
326
|
+
details: { mode: "chain", results },
|
|
327
|
+
isError: true,
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
previous = result.finalText;
|
|
331
|
+
}
|
|
332
|
+
return { content: [{ type: "text" as const, text: resultOutput(results[results.length - 1], results) }], details: { mode: "chain", results } };
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function parallelSummary(result: SingleResult): string {
|
|
336
|
+
const reason = result.stopReason && result.stopReason !== "end" ? ` (${result.stopReason})` : "";
|
|
337
|
+
const status = isFailed(result) ? `failed${reason}` : "completed";
|
|
338
|
+
return `### [${result.agent}] ${status}\n\n${capOutput(resultOutput(result))}`;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
async function runParallel(tasks: AgentTask[], run: RunTask) {
|
|
342
|
+
if (tasks.length > MAX_PARALLEL_TASKS) {
|
|
343
|
+
return { content: [{ type: "text" as const, text: `Too many parallel tasks (${tasks.length}). Max is ${MAX_PARALLEL_TASKS}.` }], details: {} };
|
|
344
|
+
}
|
|
345
|
+
const results = await mapLimit(tasks, MAX_CONCURRENCY, task => run(task));
|
|
346
|
+
const ok = results.filter(result => !isFailed(result)).length;
|
|
347
|
+
return {
|
|
348
|
+
content: [{ type: "text" as const, text: `Parallel: ${ok}/${results.length} succeeded\n\n${results.map(parallelSummary).join("\n\n---\n\n")}` }],
|
|
349
|
+
details: { mode: "parallel", results },
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
|
|
253
353
|
export default function (pi: ExtensionAPI) {
|
|
254
354
|
if (isPackagedExtension && fs.existsSync(path.join(process.cwd(), ".cratis", "ai.manifest.json"))) return;
|
|
255
355
|
// Discover once at registration so the tool description can name the valid agents — the model
|
|
@@ -295,16 +395,11 @@ export default function (pi: ExtensionAPI) {
|
|
|
295
395
|
|
|
296
396
|
async execute(_toolCallId, params, signal, _onUpdate, ctx) {
|
|
297
397
|
const agentScope: AgentScope = (params.agentScope as AgentScope) ?? "both";
|
|
298
|
-
const dispatch =
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
};
|
|
302
|
-
const { agents, projectAgentsDir } = discoverAgents(ctx.cwd, agentScope);
|
|
398
|
+
const dispatch = modelDispatch(ctx);
|
|
399
|
+
const discovery = discoverAgents(ctx.cwd, agentScope);
|
|
400
|
+
const { agents } = discovery;
|
|
303
401
|
|
|
304
|
-
|
|
305
|
-
const hasTasks = (params.tasks?.length ?? 0) > 0;
|
|
306
|
-
const hasSingle = Boolean(params.agent && params.task);
|
|
307
|
-
if (Number(hasChain) + Number(hasTasks) + Number(hasSingle) !== 1) {
|
|
402
|
+
if (!exactlyOneMode(params)) {
|
|
308
403
|
const available = agents.map((a) => `${a.name} (${a.source})`).join(", ") || "none";
|
|
309
404
|
return {
|
|
310
405
|
content: [{ type: "text", text: `Provide exactly one mode (single, parallel, or chain).\nAvailable agents: ${available}` }],
|
|
@@ -313,68 +408,13 @@ export default function (pi: ExtensionAPI) {
|
|
|
313
408
|
}
|
|
314
409
|
|
|
315
410
|
// Optional security gate for callers that want an extra confirmation for project agents.
|
|
316
|
-
if (
|
|
317
|
-
|
|
318
|
-
for (const s of params.chain ?? []) requested.add(s.agent);
|
|
319
|
-
for (const t of params.tasks ?? []) requested.add(t.agent);
|
|
320
|
-
if (params.agent) requested.add(params.agent);
|
|
321
|
-
const projectRequested = Array.from(requested)
|
|
322
|
-
.map((n) => agents.find((a) => a.name === n))
|
|
323
|
-
.filter((a): a is AgentConfig => a?.source === "project");
|
|
324
|
-
if (projectRequested.length > 0) {
|
|
325
|
-
const ok = await ctx.ui.confirm(
|
|
326
|
-
"Run project-local agents?",
|
|
327
|
-
`Agents: ${projectRequested.map((a) => a.name).join(", ")}\nSource: ${projectAgentsDir ?? "(unknown)"}\n\nProject agents are repo-controlled. Only continue for trusted repositories.`,
|
|
328
|
-
);
|
|
329
|
-
if (!ok) return { content: [{ type: "text", text: "Canceled: project-local agents not approved." }], details: {} };
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// ── chain ──
|
|
334
|
-
if (params.chain && params.chain.length > 0) {
|
|
335
|
-
const results: SingleResult[] = [];
|
|
336
|
-
let previous = "";
|
|
337
|
-
for (let i = 0; i < params.chain.length; i++) {
|
|
338
|
-
const stepDef = params.chain[i];
|
|
339
|
-
const task = stepDef.task.replace(/\{previous\}/g, previous);
|
|
340
|
-
const r = await runSingleAgent(ctx.cwd, dispatch, agents, stepDef.agent, task, stepDef.cwd, i + 1, signal, undefined);
|
|
341
|
-
results.push(r);
|
|
342
|
-
if (isFailed(r)) {
|
|
343
|
-
return {
|
|
344
|
-
content: [{ type: "text", text: `Chain stopped at step ${i + 1} (${stepDef.agent}): ${resultOutput(r)}` }],
|
|
345
|
-
details: { mode: "chain", results },
|
|
346
|
-
isError: true,
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
previous = r.finalText;
|
|
350
|
-
}
|
|
351
|
-
return {
|
|
352
|
-
content: [{ type: "text", text: resultOutput(results[results.length - 1]) }],
|
|
353
|
-
details: { mode: "chain", results },
|
|
354
|
-
};
|
|
411
|
+
if (!await approveProjectAgents(params, ctx, discovery)) {
|
|
412
|
+
return { content: [{ type: "text", text: "Canceled: project-local agents not approved." }], details: {} };
|
|
355
413
|
}
|
|
356
414
|
|
|
357
|
-
|
|
358
|
-
if (params.
|
|
359
|
-
|
|
360
|
-
return {
|
|
361
|
-
content: [{ type: "text", text: `Too many parallel tasks (${params.tasks.length}). Max is ${MAX_PARALLEL_TASKS}.` }],
|
|
362
|
-
details: {},
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
const results = await mapLimit(params.tasks, MAX_CONCURRENCY, (t) =>
|
|
366
|
-
runSingleAgent(ctx.cwd, dispatch, agents, t.agent, t.task, t.cwd, undefined, signal, undefined),
|
|
367
|
-
);
|
|
368
|
-
const ok = results.filter((r) => !isFailed(r)).length;
|
|
369
|
-
const summaries = results.map((r) => {
|
|
370
|
-
const status = isFailed(r) ? `failed${r.stopReason && r.stopReason !== "end" ? ` (${r.stopReason})` : ""}` : "completed";
|
|
371
|
-
return `### [${r.agent}] ${status}\n\n${capOutput(resultOutput(r))}`;
|
|
372
|
-
});
|
|
373
|
-
return {
|
|
374
|
-
content: [{ type: "text", text: `Parallel: ${ok}/${results.length} succeeded\n\n${summaries.join("\n\n---\n\n")}` }],
|
|
375
|
-
details: { mode: "parallel", results },
|
|
376
|
-
};
|
|
377
|
-
}
|
|
415
|
+
const run: RunTask = (task, step) => runSingleAgent(ctx.cwd, dispatch, agents, task.agent, task.task, task.cwd, step, signal, undefined);
|
|
416
|
+
if (params.chain && params.chain.length > 0) return runChain(params.chain, run);
|
|
417
|
+
if (params.tasks && params.tasks.length > 0) return runParallel(params.tasks, run);
|
|
378
418
|
|
|
379
419
|
// ── single ──
|
|
380
420
|
const r = await runSingleAgent(ctx.cwd, dispatch, agents, params.agent!, params.task!, params.cwd, undefined, signal, undefined);
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import * as fs from 'node:fs';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
|
|
7
|
+
export interface ModelTierConfig {
|
|
8
|
+
schemaVersion: string;
|
|
9
|
+
tiers: Partial<Record<string, string | string[]>>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ModelTierInputs {
|
|
13
|
+
agent: { model?: string; modelTier?: string; reviewIndependence?: string };
|
|
14
|
+
dispatchModel?: string;
|
|
15
|
+
config?: ModelTierConfig;
|
|
16
|
+
available?: string[];
|
|
17
|
+
notice?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ModelResolution {
|
|
21
|
+
model?: string;
|
|
22
|
+
thinkingInherited: boolean;
|
|
23
|
+
outcome: 'explicit' | 'tier' | 'inherited' | 'single-provider';
|
|
24
|
+
notice?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const maximumConfigBytes = 65536;
|
|
28
|
+
const knownTiers = ['scoped', 'strongest', 'reviewer'];
|
|
29
|
+
|
|
30
|
+
function record(value: unknown): Record<string, unknown> {
|
|
31
|
+
if (Object.prototype.toString.call(value) !== '[object Object]') throw new Error('Expected an object');
|
|
32
|
+
return value as Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function providerOf(model?: string): string | undefined {
|
|
36
|
+
const separator = model?.indexOf('/') ?? -1;
|
|
37
|
+
return separator > 0 ? model!.slice(0, separator) : undefined;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function configuredModel(value: unknown): string {
|
|
41
|
+
if (typeof value !== 'string') throw new Error('Expected a model string');
|
|
42
|
+
const model = value.trim();
|
|
43
|
+
if (!/^[^/\s]+\/[^\s]*[^/\s]$/.test(model)) throw new Error('Expected provider/id');
|
|
44
|
+
return model;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function parseConfig(value: unknown): ModelTierConfig {
|
|
48
|
+
const parsed = record(value);
|
|
49
|
+
if (typeof parsed.schemaVersion !== 'string' || !/^1\.\d+$/.test(parsed.schemaVersion)) throw new Error('Unsupported schema');
|
|
50
|
+
const tiers = record(parsed.tiers);
|
|
51
|
+
const config: ModelTierConfig = { schemaVersion: parsed.schemaVersion, tiers: {} };
|
|
52
|
+
for (const tier of knownTiers) {
|
|
53
|
+
if (!(tier in tiers)) continue;
|
|
54
|
+
const candidates = tiers[tier];
|
|
55
|
+
config.tiers[tier] = Array.isArray(candidates) ? candidates.map(configuredModel) : configuredModel(candidates);
|
|
56
|
+
}
|
|
57
|
+
return config;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Read only user-owned configuration; malformed input must never prevent dispatch. */
|
|
61
|
+
export function readModelTierConfig(directory: string): { config?: ModelTierConfig; notice?: string } {
|
|
62
|
+
let descriptor: number | undefined;
|
|
63
|
+
try {
|
|
64
|
+
descriptor = fs.openSync(join(directory, 'cratis-models.json'), 'r');
|
|
65
|
+
const buffer = Buffer.alloc(maximumConfigBytes + 1);
|
|
66
|
+
const length = fs.readSync(descriptor, buffer, 0, buffer.length, 0);
|
|
67
|
+
if (length > maximumConfigBytes) throw new Error('Configuration too large');
|
|
68
|
+
return { config: parseConfig(JSON.parse(buffer.toString('utf8', 0, length))) };
|
|
69
|
+
} catch (error) {
|
|
70
|
+
if ((error as NodeJS.ErrnoException).code === 'ENOENT') return {};
|
|
71
|
+
return { notice: 'Ignoring invalid cratis-models.json (expected schema 1.x tier mappings of provider/id; maximum 64 KiB).' };
|
|
72
|
+
} finally {
|
|
73
|
+
if (descriptor !== undefined) fs.closeSync(descriptor);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function candidatesFor({ agent, config, available }: ModelTierInputs): string[] {
|
|
78
|
+
const configured = agent.modelTier ? config?.tiers[agent.modelTier] : undefined;
|
|
79
|
+
const candidates = typeof configured === 'string' ? [configured] : configured ?? [];
|
|
80
|
+
return candidates.filter(model => available === undefined || available.includes(model));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function singleProvider(model: string | undefined): ModelResolution {
|
|
84
|
+
return {
|
|
85
|
+
model,
|
|
86
|
+
thinkingInherited: false,
|
|
87
|
+
outcome: 'single-provider',
|
|
88
|
+
notice: `single-provider: no different-provider model configured/available for reviewer tier; reviewing on ${model ?? '(session default)'} — not independent`,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function differentProvider(model: string, dispatchModel?: string): boolean {
|
|
93
|
+
const authorProvider = providerOf(dispatchModel);
|
|
94
|
+
const candidateProvider = providerOf(model);
|
|
95
|
+
if (!authorProvider || !candidateProvider) return false;
|
|
96
|
+
return candidateProvider !== authorProvider;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function explicitModel(inputs: ModelTierInputs, model: string): ModelResolution {
|
|
100
|
+
if (inputs.agent.reviewIndependence === 'different-provider' && !differentProvider(model, inputs.dispatchModel)) return singleProvider(model);
|
|
101
|
+
return { model, thinkingInherited: false, outcome: 'explicit' };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function independentModel(inputs: ModelTierInputs, candidates: string[]): ModelResolution {
|
|
105
|
+
const model = candidates.find(candidate => differentProvider(candidate, inputs.dispatchModel));
|
|
106
|
+
return model ? { model, thinkingInherited: false, outcome: 'tier' } : singleProvider(candidates[0] ?? inputs.dispatchModel);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function chooseModel(inputs: ModelTierInputs): ModelResolution {
|
|
110
|
+
if (inputs.agent.model) return explicitModel(inputs, inputs.agent.model);
|
|
111
|
+
const candidates = candidatesFor(inputs);
|
|
112
|
+
if (inputs.agent.reviewIndependence === 'different-provider') return independentModel(inputs, candidates);
|
|
113
|
+
return candidates.length > 0
|
|
114
|
+
? { model: candidates[0], thinkingInherited: false, outcome: 'tier' }
|
|
115
|
+
: { model: inputs.dispatchModel, thinkingInherited: true, outcome: 'inherited' };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Resolve explicit overrides, then user tiers, then the dispatching session, without I/O. */
|
|
119
|
+
export function resolveModel(inputs: ModelTierInputs): ModelResolution {
|
|
120
|
+
const resolution = chooseModel(inputs);
|
|
121
|
+
if (inputs.notice) resolution.notice = [inputs.notice, resolution.notice].filter(Boolean).join('\n');
|
|
122
|
+
return resolution;
|
|
123
|
+
}
|
|
@@ -149,7 +149,7 @@ Read [references/capture-map-and-example.md](references/capture-map-and-example.
|
|
|
149
149
|
|
|
150
150
|
## `reaction`
|
|
151
151
|
|
|
152
|
-
Read [reaction forms](references/reaction-forms.md) when choosing a trigger,
|
|
152
|
+
Read [reaction forms](references/reaction-forms.md) (including how a host provider runs a reaction body) when choosing a trigger,
|
|
153
153
|
selecting occurrence values or mapping `produces` and `invokes`; complete documents
|
|
154
154
|
remain in `references/complete-examples.md`.
|
|
155
155
|
|
package/package/corpus/skills/cratis-screenplay-captures-and-reactions/references/reaction-forms.md
CHANGED
|
@@ -57,3 +57,26 @@ refusals and reference unsupported outcomes remain separate checks.
|
|
|
57
57
|
with `and`/`or`. Its source grammar includes `contains` and `starts with`, but the
|
|
58
58
|
executable binder refuses those operators with PLAY0268. Use the literal property
|
|
59
59
|
rules for validation, not as a way around condition admission.
|
|
60
|
+
|
|
61
|
+
## Reaction bodies run through a host provider
|
|
62
|
+
|
|
63
|
+
Requires Screenplay 4.258.0 or later (`screenplay --version`). Source: Screenplay
|
|
64
|
+
`Documentation/screenplay/reactions.md`.
|
|
65
|
+
|
|
66
|
+
A reference run executes an attached reaction body only when the host supplies an
|
|
67
|
+
`ISemanticBodyExecutionProvider` and a resolved, content-verified attachment. The run calls
|
|
68
|
+
`ReactAsync` for a standalone body on a reaction with exactly one event trigger and no `produces`,
|
|
69
|
+
`invokes` or routing override, after `where` passes.
|
|
70
|
+
|
|
71
|
+
- `ReactAsync` returns exactly one of nothing, an ordered event batch or an ordered command batch
|
|
72
|
+
(`SemanticReactionBodyResult`). A missing, default or mixed result is Unsupported with the
|
|
73
|
+
Reaction capability, never an empty result.
|
|
74
|
+
- The run validates every target and payload of the whole batch before settling anything. Command
|
|
75
|
+
payloads cannot supply generated properties. Commands settled earlier are not rolled back when a
|
|
76
|
+
later one is refused, as with `invokes` without `on refused`.
|
|
77
|
+
- Every other shape stays Unsupported (Reaction): clock and application triggers, unverified
|
|
78
|
+
bodies, provider failure and a run with no provider.
|
|
79
|
+
- A body that also declares `reads` stays refused (`PLAY0268`); return or invoke a command and put
|
|
80
|
+
the protected decision there.
|
|
81
|
+
- `PerformAsync` is a provider contract only. Performer queries are not admitted to the executable
|
|
82
|
+
model, so never present a performer as runnable.
|
|
@@ -69,6 +69,9 @@
|
|
|
69
69
|
{
|
|
70
70
|
"kind": "skill-contains",
|
|
71
71
|
"value": "[ExecuteCommandsAsSystem]"
|
|
72
|
-
}
|
|
72
|
+
},
|
|
73
|
+
{ "kind": "skill-contains", "value": "ISemanticBodyExecutionProvider", "file": "references/reaction-forms.md" },
|
|
74
|
+
{ "kind": "skill-contains", "value": "`PerformAsync` is a provider contract only", "file": "references/reaction-forms.md" },
|
|
75
|
+
{ "kind": "skill-contains", "value": "Requires Screenplay 4.258.0", "file": "references/reaction-forms.md" }
|
|
73
76
|
]
|
|
74
77
|
}
|
|
@@ -146,6 +146,9 @@ nested and variant block starts fresh sets. See [event scope](references/pdl-gra
|
|
|
146
146
|
|
|
147
147
|
## Property mapping and AutoMap
|
|
148
148
|
|
|
149
|
+
The order of a read model's properties is not a projection input; only a C# host's opt-in ESM 37.1
|
|
150
|
+
metadata records it ([property order](../cratis-screenplay-toolchain/references/read-model-property-order.md)).
|
|
151
|
+
|
|
149
152
|
⚠️ **AutoMap is on by default.** Matching property names are copied before your
|
|
150
153
|
explicit mappings run, and explicit mappings win. Turn it off with `no automap` at
|
|
151
154
|
**projection**, `every`/`all`, `join`, `children` or `nested` level — it
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
{ "kind": "skill-contains", "value": "PLAY0690", "file": "references/reducer-identity.md" },
|
|
31
31
|
{ "kind": "skill-contains", "value": "**A builder never names a sink.**" },
|
|
32
32
|
{ "kind": "skill-contains", "value": "sink People for graphs", "file": "references/graphs.md" },
|
|
33
|
-
{ "kind": "skill-contains", "value": "every `sink` line in it is the directive", "file": "references/graphs.md" }
|
|
33
|
+
{ "kind": "skill-contains", "value": "every `sink` line in it is the directive", "file": "references/graphs.md" },
|
|
34
|
+
{ "kind": "skill-contains", "value": "read-model-property-order.md" }
|
|
34
35
|
]
|
|
35
36
|
}
|
|
@@ -121,7 +121,14 @@ module Berths
|
|
|
121
121
|
State what an action acts on: `action CancelBooking for item` acts on the selected row or the record the screen shows,
|
|
122
122
|
`action BookBerth for screen` does not depend on a selection. An omitted subject is inferred from the declared data
|
|
123
123
|
and identifier types and reported as `PLAY0818` (and `PLAY0819` when the row binding differs from legacy name matching),
|
|
124
|
-
so write the clause.
|
|
124
|
+
so write the clause. With a header record beside one table of rows, `for item` acts on that table's collection
|
|
125
|
+
(Requires Screenplay 6.18.0 or later; see the UI composition skill's
|
|
126
|
+
[table narrowing](../../cratis-screenplay-ui-composition/references/action-subjects.md#table-narrowing)).
|
|
127
|
+
Source: Screenplay `Documentation/screenplay/action-subjects.md`.
|
|
128
|
+
|
|
129
|
+
Property declaration order is not preserved by default; a C# host can opt in to ESM 37.1 metadata,
|
|
130
|
+
but it does not let a model control a generated constructor (see
|
|
131
|
+
[read-model property order](../../cratis-screenplay-toolchain/references/read-model-property-order.md)).
|
|
125
132
|
|
|
126
133
|
## What a screen pattern is not
|
|
127
134
|
|
|
@@ -32,6 +32,8 @@
|
|
|
32
32
|
{ "kind": "skill-contains", "value": "| `PLAY0935` | Error | A `passive` read model names a sink |", "file": "references/sinks.md" },
|
|
33
33
|
{ "kind": "skill-contains", "value": "The model never names a database", "file": "references/sinks.md" },
|
|
34
34
|
{ "kind": "skill-contains", "value": "Read [sinks](references/sinks.md) before naming a sink." },
|
|
35
|
+
{ "kind": "skill-contains", "value": "acts on that table's collection", "file": "references/screen-patterns.md" },
|
|
36
|
+
{ "kind": "skill-contains", "value": "Property declaration order is not preserved by default", "file": "references/screen-patterns.md" },
|
|
35
37
|
{ "kind": "skill-contains", "value": "[passive read models](references/passive.md) before declaring one" },
|
|
36
38
|
{ "kind": "skill-contains", "value": "| `PLAY0859` | Error | A `query` returns a passive read model", "file": "references/passive.md" },
|
|
37
39
|
{ "kind": "skill-contains", "value": "Requires Screenplay 5.3.0", "file": "references/passive.md" }
|
|
@@ -35,7 +35,9 @@ Tool versions are covered in `cratis-screenplay-toolchain` `SKILL.md`; read it b
|
|
|
35
35
|
## Language modes that block target delivery
|
|
36
36
|
|
|
37
37
|
Read [language admission](../cratis-screenplay-toolchain/references/language-admission.md)
|
|
38
|
-
for version selection
|
|
38
|
+
for version selection ([unknown-preserving reads](../cratis-screenplay-toolchain/references/unknown-preserving-reader.md)
|
|
39
|
+
are not render admission; read-model [property order](../cratis-screenplay-toolchain/references/read-model-property-order.md)
|
|
40
|
+
is opt-in 37.1 metadata, not a constructor-order promise), and [current Stage boundaries](../cratis-stage-rendering-and-sandbox/references/current-boundaries.md)
|
|
39
41
|
for realization. Bounded atomic batches, source-event Translate captures/publication and resolved
|
|
40
42
|
C# validation bodies now render. Described handlers still refuse even in Stub
|
|
41
43
|
mode; query-performer gaps are a separate contract, not completed behavior. Protected reads still need an admitted shape. Semantic Host/executor
|
|
@@ -50,6 +50,8 @@
|
|
|
50
50
|
{ "kind": "skill-contains", "value": "Unsupported generated\ntypes (`STAGE-ESM-028`) and result combinations (`-038`)" },
|
|
51
51
|
{ "kind": "skill-contains", "value": "authored-UI parity" },
|
|
52
52
|
{ "kind": "skill-contains", "value": "responsible tool version" },
|
|
53
|
-
{ "kind": "skill-contains", "value": "`GraphSinks` into its render input, or a changed `sink` line never triggers a re-render" }
|
|
53
|
+
{ "kind": "skill-contains", "value": "`GraphSinks` into its render input, or a changed `sink` line never triggers a re-render" },
|
|
54
|
+
{ "kind": "skill-contains", "value": "unknown-preserving-reader.md" },
|
|
55
|
+
{ "kind": "skill-contains", "value": "not a constructor-order promise" }
|
|
54
56
|
]
|
|
55
57
|
}
|
package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/spec-forms-by-mode.md
CHANGED
|
@@ -18,7 +18,7 @@ Typed example/override forms: `cratis-screenplay-specifications`
|
|
|
18
18
|
| Form | design | executable | renderable |
|
|
19
19
|
|---|---|---|---|
|
|
20
20
|
| `when <Cmd>` -> `then <Event>` / `then error` / `then denied` | yes | yes | yes |
|
|
21
|
-
| `given <Event>` with `for` | yes | yes (needed for keyed views) | yes |
|
|
21
|
+
| `given <Event>` with `for` | yes | yes (needed for keyed views); no producing command needed when a root projection supplies the identity type, see `cratis-screenplay-specifications` `references/producerless-events.md` | yes |
|
|
22
22
|
| `given readmodel` | yes | yes (complete instance with key) | only as the query-only lookup below |
|
|
23
23
|
| `when append <Event>` | yes | yes | supported single-hop reaction effects/invocation only; fan-out, deeper cascades and other refused assertions retain STAGE-ESM-011 |
|
|
24
24
|
| `then readmodel` / `then query` (keyed `ById`, `arguments`, `result`) | yes | yes | yes |
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
{ "kind": "skill-contains", "value": "One behaviour per spec" },
|
|
15
15
|
{ "kind": "skill-contains", "value": "No command has only two specs" },
|
|
16
16
|
{ "kind": "skill-contains", "value": "not scenario-complete" },
|
|
17
|
-
{ "kind": "skill-contains", "value": "per-view judgment was skipped" }
|
|
17
|
+
{ "kind": "skill-contains", "value": "per-view judgment was skipped" },
|
|
18
|
+
{ "kind": "skill-contains", "value": "references/producerless-events.md", "file": "references/spec-forms-by-mode.md" }
|
|
18
19
|
]
|
|
19
20
|
}
|
|
@@ -28,7 +28,7 @@ reference execution. Use `screenplay test` or MCP `run-specifications` for V4; S
|
|
|
28
28
|
tests are separate evidence. Propose → review → `run-specifications` with `proposalId` → apply.
|
|
29
29
|
PLAY0285 (an impossible `then`) unbinds the whole model and blocks every spec.
|
|
30
30
|
Unsupported/unbound is never a pass. Typed examples and
|
|
31
|
-
|
|
31
|
+
routes: [examples](references/examples-and-routes.md); [producerless events](references/producerless-events.md).
|
|
32
32
|
|
|
33
33
|
Requires Screenplay 4.145.0 or later (`screenplay --version`) for `run-specifications` with `proposalId`.
|
|
34
34
|
|
package/package/corpus/skills/cratis-screenplay-specifications/references/producerless-events.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<!-- Copyright (c) Cratis. All rights reserved. -->
|
|
2
|
+
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
|
3
|
+
|
|
4
|
+
# Events without a producing command
|
|
5
|
+
|
|
6
|
+
Requires Screenplay 6.15.0 or later (`screenplay --version`). Source: Screenplay
|
|
7
|
+
`Documentation/screenplay/specifications.md`, "Event sources without one producing command".
|
|
8
|
+
|
|
9
|
+
A `given <Event> for <literal>`, a `when append <Event> for <literal>`, a named event example and
|
|
10
|
+
`for case.<parameter>` need an event-source identity type. A single producing command, or an
|
|
11
|
+
explicit route, supplies it and wins first. When no single producer supplies one distinct
|
|
12
|
+
destination type, a root read-model projection that consumes the event can supply it instead. Never
|
|
13
|
+
add a producer command only to make a specification compile: the model would then claim a
|
|
14
|
+
behavior nobody asked for.
|
|
15
|
+
|
|
16
|
+
The projection supplies the identity type when:
|
|
17
|
+
|
|
18
|
+
- it consumes the event by the event's own event source (the default key or `$eventSourceId`),
|
|
19
|
+
never by an event payload property;
|
|
20
|
+
- every matching root projection has exactly one required scalar read-model key, and all those keys
|
|
21
|
+
have the same type;
|
|
22
|
+
- the `for` value is a literal that fits that type.
|
|
23
|
+
|
|
24
|
+
Protected (`pii` or `secret`), optional, collection, structured, missing or conflicting identity
|
|
25
|
+
types stay refused, and an optional `for case.<parameter>` cannot supply a required identity even
|
|
26
|
+
when one row holds non-null text. When no identity type can be determined, `PLAY0273` names the
|
|
27
|
+
event and asks for a projection keyed on the event source or a producing command with a required
|
|
28
|
+
scalar destination. The `for` syntax and the selected ESM version do not change.
|
|
29
|
+
|
|
30
|
+
A view that counts slots per day, specified with `then readmodel`; a `then query` over `DayById`
|
|
31
|
+
asserts the same row. Both facts fold into one instance, so initialize required counters in the
|
|
32
|
+
projection that establishes the row:
|
|
33
|
+
|
|
34
|
+
```screenplay
|
|
35
|
+
module Demo
|
|
36
|
+
feature Days
|
|
37
|
+
slice StateView Calendar
|
|
38
|
+
event DayOpened
|
|
39
|
+
dayId String
|
|
40
|
+
event SlotTaken
|
|
41
|
+
dayId String
|
|
42
|
+
readmodel DayView
|
|
43
|
+
dayId String
|
|
44
|
+
slots Int
|
|
45
|
+
query DayById => DayView optional
|
|
46
|
+
by dayId String
|
|
47
|
+
projection DayProjection => DayView
|
|
48
|
+
from DayOpened
|
|
49
|
+
dayId = dayId
|
|
50
|
+
slots = 0
|
|
51
|
+
from SlotTaken
|
|
52
|
+
increment slots
|
|
53
|
+
specification CountingSlots
|
|
54
|
+
given DayOpened
|
|
55
|
+
for "2026-11-10"
|
|
56
|
+
dayId = "2026-11-10"
|
|
57
|
+
given SlotTaken
|
|
58
|
+
for "2026-11-10"
|
|
59
|
+
dayId = "2026-11-10"
|
|
60
|
+
then readmodel DayView
|
|
61
|
+
dayId = "2026-11-10"
|
|
62
|
+
slots = 1
|
|
63
|
+
```
|
|
@@ -105,7 +105,8 @@ module Invoicing
|
|
|
105
105
|
command. A `when append` specification may sit in a `StateView` slice, even for an
|
|
106
106
|
event another slice declares, as long as the event's producer gives it one
|
|
107
107
|
unambiguous destination type (binding resolves it from commands in other slices);
|
|
108
|
-
otherwise `for` fails with `PLAY0273
|
|
108
|
+
otherwise `for` fails with `PLAY0273` unless a root projection supplies the identity
|
|
109
|
+
([producerless events](producerless-events.md)). Only `when <Command>` needs the command's
|
|
109
110
|
own slice.
|
|
110
111
|
- `LookingUpAnExistingInvoice` performs the query as its action. It binds to
|
|
111
112
|
exactly what `then query` with `arguments` and `result` would, so on a version
|
|
@@ -84,6 +84,9 @@
|
|
|
84
84
|
"value": "never delete the reaction", "file": "references/reactions-and-cascades.md"
|
|
85
85
|
},
|
|
86
86
|
{ "kind": "skill-contains", "value": "Examples typed from another document", "file": "references/examples-and-routes.md" },
|
|
87
|
-
{ "kind": "skill-contains", "value": "`PLAY0520`", "file": "references/examples-and-routes.md" }
|
|
87
|
+
{ "kind": "skill-contains", "value": "`PLAY0520`", "file": "references/examples-and-routes.md" },
|
|
88
|
+
{ "kind": "skill-contains", "value": "Requires Screenplay 6.15.0", "file": "references/producerless-events.md" },
|
|
89
|
+
{ "kind": "skill-contains", "value": "Never\nadd a producer command only to make a specification compile", "file": "references/producerless-events.md" },
|
|
90
|
+
{ "kind": "skill-contains", "value": "references/producerless-events.md" }
|
|
88
91
|
]
|
|
89
92
|
}
|
|
@@ -140,6 +140,8 @@ with ordered imports means future files need explicit imports.
|
|
|
140
140
|
report PLAY0268); one explicit `key` keeps its earlier version. Read
|
|
141
141
|
`references/production-routes-and-filters.md`, [language admission](references/language-admission.md)
|
|
142
142
|
and read-surface `references/named-keys.md`.
|
|
143
|
+
- **Minor versions:** read [unknown-preserving reader](references/unknown-preserving-reader.md) and
|
|
144
|
+
[read-model property order](references/read-model-property-order.md).
|
|
143
145
|
- **Enum numbers (v12):** read command-surface `references/enum-numbers.md` for
|
|
144
146
|
pins, stored numbers and Stage output; `references/diagnostics.md` owns PLAY0667–0671.
|
|
145
147
|
- **Concept strategies (v15):** read
|
|
@@ -344,7 +344,9 @@ query with PLAY0268 and leave the whole model unbound. Everything else binds as
|
|
|
344
344
|
execute: reducer transitions, rule predicates, command and concept code validation, policy
|
|
345
345
|
predicates and reaction effects. Reaction effects bind only when the trigger has no
|
|
346
346
|
`reads`; a trigger with `reads` plus a `file` or inline effect fails binding. Reaction
|
|
347
|
-
bodies still leave their owner non-executable
|
|
347
|
+
bodies still leave their owner non-executable, unless the host supplies a body execution provider for a
|
|
348
|
+
standalone single-event reaction body (Requires Screenplay 4.258.0; see
|
|
349
|
+
[reaction bodies](../../cratis-screenplay-captures-and-reactions/references/reaction-forms.md#reaction-bodies-run-through-a-host-provider)).
|
|
348
350
|
|
|
349
351
|
- A `file` constraint **never binds**: PLAY0268 "file implementation is not admitted by
|
|
350
352
|
the executable model". Chronicle file constraints
|
|
@@ -37,6 +37,9 @@ exact language/semantic pairs; binding, reference execution and rendering are se
|
|
|
37
37
|
|
|
38
38
|
Constructs of decision 0098 with no executable-model content need no version: application-level hooks in a layout's actions outlet (`default <id> title "..." slice <Slice>` with an optional indented `authorize <Policy>`), and a capture over events that copies a list (`lines = $.lines`) or fans out with `children lines identified by sku`. Check `screenplay --version` against the release that admitted v29 and v30 before relying on them. Decision 0115 withdrew 0098's command specification that states the public event its outbound Translate slice publishes: a specification runs only its own slice, so the Translate slice states the public event in its own `when append` specification.
|
|
39
39
|
|
|
40
|
+
Read-model property order is opt-in ESM 37.1 metadata: see
|
|
41
|
+
[read-model property order](read-model-property-order.md).
|
|
42
|
+
|
|
40
43
|
## Compiler and target minimums
|
|
41
44
|
|
|
42
45
|
Requires Screenplay 4.181.0 or later (`screenplay --version`) for atomic batches; older compilers cannot admit the preamble.
|
|
@@ -131,3 +134,5 @@ Requires Stage 4.145.0 for reach-scoped reducer/validation-body refusals
|
|
|
131
134
|
handlers retain STAGE-IMPL-002; renderer implementation admission is unchanged.
|
|
132
135
|
Read [sandbox boundaries](../../cratis-stage-rendering-and-sandbox/references/sandbox-and-specrunner.md)
|
|
133
136
|
when a semantic run reaches a body or uses an authored reaction clock.
|
|
137
|
+
Read [unknown-preserving reader](unknown-preserving-reader.md) when a consumer
|
|
138
|
+
must retain unknown additions of a minor it does not register, without executing them.
|
package/package/corpus/skills/cratis-screenplay-toolchain/references/read-model-property-order.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!-- Copyright (c) Cratis. All rights reserved. -->
|
|
2
|
+
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
|
3
|
+
|
|
4
|
+
# Read-model property order (ESM 37.1)
|
|
5
|
+
|
|
6
|
+
Requires Screenplay 5.6.0 or later (`screenplay --version`). Read-model declaration order is optional,
|
|
7
|
+
ignorable metadata and is **not** preserved by default: the CLI, MCP, TypeScript compiler and editors
|
|
8
|
+
never request it, and it adds no `.play` syntax or diagnostic. A C# host opts in with
|
|
9
|
+
`SemanticModelBinder.Bind(name, document, documents, new SemanticBindingOptions(PreserveReadModelPropertyOrder: true))`,
|
|
10
|
+
which returns a `SemanticBindingOptionsResult` (`Compilation`, `Refusal`, `Success`).
|
|
11
|
+
|
|
12
|
+
- Only when the option is used and removing the metadata leaves a valid 37.0 model that reads the
|
|
13
|
+
application calendar or a clock does the model select language/semantic **37.1**. `schemaVersion`
|
|
14
|
+
stays 37 and each read model gains an optional `propertyOrder` after `properties`: a permutation of
|
|
15
|
+
every property identity, key included. `properties` stays id-sorted.
|
|
16
|
+
- A model that emits no metadata (no read models, or every read model already in canonical property
|
|
17
|
+
order) keeps its version and binds successfully. Any other model that is not a 37.0 candidate gets
|
|
18
|
+
`PropertyOrderMetadataRefusal` with no executable value. Default `Bind` and default options keep existing versions, bytes and
|
|
19
|
+
revisions.
|
|
20
|
+
- The golden is `full-esm-v37.1.json`, reached with `EsmGoldenVectors.GetMinor(SemanticVersion.V37_1)`;
|
|
21
|
+
`Get(int)` and `Versions` describe only `.0` goldens.
|
|
22
|
+
- A 37.0 consumer that reads through the [unknown-preserving reader](unknown-preserving-reader.md)
|
|
23
|
+
keeps the member as opaque bytes with the same revision.
|
|
24
|
+
|
|
25
|
+
Do not tell modelers that declaration order controls a generated constructor's parameter order: that
|
|
26
|
+
rendering is a Stage change; confirm it shipped before claiming otherwise.
|
package/package/corpus/skills/cratis-screenplay-toolchain/references/unknown-preserving-reader.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<!-- Copyright (c) Cratis. All rights reserved. -->
|
|
2
|
+
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
|
3
|
+
|
|
4
|
+
# Unknown-preserving semantic model reader
|
|
5
|
+
|
|
6
|
+
Requires Screenplay 4.256.0 or later (`screenplay --version`). Source: Screenplay
|
|
7
|
+
`Documentation/screenplay/interoperability.md` ("Minor versions and unknown-preserving
|
|
8
|
+
admission").
|
|
9
|
+
|
|
10
|
+
A consumer that must retain unknown additions without executing them reads a model with
|
|
11
|
+
`UnknownPreservingSemanticModelReader.Read(bytes, EsmAdmissionRange)`. It is an opt-in reader beside
|
|
12
|
+
the strict reader, which is unchanged and still refuses every unknown member and unregistered
|
|
13
|
+
version. Reading carries no producer trust and no execution, rendering or reverse-recovery
|
|
14
|
+
authority; those admissions stay separate decisions.
|
|
15
|
+
|
|
16
|
+
## Admission
|
|
17
|
+
|
|
18
|
+
- The caller supplies one major with inclusive minimum and maximum minor. Both wire versions must
|
|
19
|
+
lie in that range, and the package must ship a frozen baseline descriptor for that major. The
|
|
20
|
+
reader is not limited to the latest major.
|
|
21
|
+
- Unknowns are admitted only above the major's highest registered minor. An exact registered pair
|
|
22
|
+
admits none.
|
|
23
|
+
- Classify admission from the document's own wire pair, not from the pair of the validated known
|
|
24
|
+
projection, which uses the highest registered pair of the major.
|
|
25
|
+
|
|
26
|
+
## What the reader keeps
|
|
27
|
+
|
|
28
|
+
- The original bytes, wire versions and full revision; a validated known projection; and
|
|
29
|
+
owner-addressable diagnostics for each unknown.
|
|
30
|
+
- Known or unknown is decided from the document's own major against the frozen baseline field set,
|
|
31
|
+
which holds what the published writer emits (for example `predecessor` and `priorRevisions` only
|
|
32
|
+
from major 4). Members after the baseline sit in an ordinal extension region.
|
|
33
|
+
- An unknown is security flagged only through a known structural position: authorization, policies,
|
|
34
|
+
callers and claims; identity mapping; compliance, personal and secret data; event-stream routing.
|
|
35
|
+
Every other unknown is Unclassified, not automatically unsafe. Never infer meaning inside an opaque
|
|
36
|
+
unknown subtree; consumers decide degradation and whether to disable an owner.
|
|
37
|
+
- Preserved unknowns are re-emitted byte-identically and never executed.
|
|
38
|
+
|
|
39
|
+
## Refusal boundary
|
|
40
|
+
|
|
41
|
+
A breach refuses the whole document with `InvalidSemanticContract`; nothing is truncated:
|
|
42
|
+
|
|
43
|
+
- a malformed or missing wire version, a version outside the range, or a language and semantic pair
|
|
44
|
+
that does not match;
|
|
45
|
+
- no frozen baseline descriptor for the major;
|
|
46
|
+
- duplicate members, non-NFC text or bytes that are not canonical, and a revision that does not match
|
|
47
|
+
the canonical bytes;
|
|
48
|
+
- container depth over 64, input over 8,388,608 bytes, more than 64 unknown boundaries per owner or
|
|
49
|
+
1,024 per document, more than 1,048,576 unknown value bytes, or an unknown name outside
|
|
50
|
+
`[a-z][A-Za-z0-9]*` of at most 64 characters (nested names included);
|
|
51
|
+
- an unknown discriminator value, or a known dangling reference.
|
|
52
|
+
|
|
53
|
+
Inside an opaque extension, object names are ordinal at every depth, arrays keep received order,
|
|
54
|
+
and absent stays distinct from null.
|
|
55
|
+
|
|
56
|
+
Renderer admission of an unknown-bearing model is separate work: this reader proves the bytes
|
|
57
|
+
were preserved, not that a Stage renderer accepts them.
|
|
@@ -89,6 +89,16 @@
|
|
|
89
89
|
{ "kind": "skill-contains", "value": "| PLAY0935 | E | A `passive` read model names a sink", "file": "references/diagnostics.md" },
|
|
90
90
|
{ "kind": "skill-contains", "value": "| PLAY0859 | E | A `query` returns a passive read model", "file": "references/diagnostics.md" },
|
|
91
91
|
{ "kind": "skill-contains", "value": "| PLAY0939 | W | A read-model property `sink`", "file": "references/diagnostics.md" },
|
|
92
|
-
{ "kind": "skill-contains", "value": "`ApplicationSyntax.sinks` (`SinkSyntax` with `name`, `stores`)", "file": "references/executable-subset.md" }
|
|
92
|
+
{ "kind": "skill-contains", "value": "`ApplicationSyntax.sinks` (`SinkSyntax` with `name`, `stores`)", "file": "references/executable-subset.md" },
|
|
93
|
+
{ "kind": "skill-contains", "value": "reaction-forms.md#reaction-bodies-run-through-a-host-provider", "file": "references/executable-subset.md" },
|
|
94
|
+
{ "kind": "skill-contains", "value": "UnknownPreservingSemanticModelReader.Read(bytes, EsmAdmissionRange)", "file": "references/unknown-preserving-reader.md" },
|
|
95
|
+
{ "kind": "skill-contains", "value": "Requires Screenplay 4.256.0", "file": "references/unknown-preserving-reader.md" },
|
|
96
|
+
{ "kind": "skill-contains", "value": "InvalidSemanticContract", "file": "references/unknown-preserving-reader.md" },
|
|
97
|
+
{ "kind": "skill-contains", "value": "unknown-preserving-reader.md", "file": "references/language-admission.md" },
|
|
98
|
+
{ "kind": "skill-contains", "value": "# Read-model property order (ESM 37.1)", "file": "references/read-model-property-order.md" },
|
|
99
|
+
{ "kind": "skill-contains", "value": "PropertyOrderMetadataRefusal", "file": "references/read-model-property-order.md" },
|
|
100
|
+
{ "kind": "skill-contains", "value": "is **not** preserved by default", "file": "references/read-model-property-order.md" },
|
|
101
|
+
{ "kind": "skill-contains", "value": "references/read-model-property-order.md" },
|
|
102
|
+
{ "kind": "skill-contains", "value": "references/unknown-preserving-reader.md" }
|
|
93
103
|
]
|
|
94
104
|
}
|
package/package/corpus/skills/cratis-screenplay-ui-composition/references/action-subjects.md
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
# Action subjects: `for item` and `for screen`
|
|
2
2
|
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- Table narrowing
|
|
6
|
+
- Repair repeated advisories one occurrence at a time
|
|
7
|
+
|
|
3
8
|
Requires Screenplay 4.248.0 or later (`screenplay --version`). Source: Screenplay
|
|
4
9
|
`Documentation/screenplay/action-subjects.md` (decision 0110).
|
|
5
10
|
|
|
6
11
|
A plain or toolbar `action` states whether it acts on one chosen record or on the screen:
|
|
7
12
|
|
|
8
|
-
- `for item`: the nearest single `data` record, or the selected row of a collection.
|
|
13
|
+
- `for item`: the nearest single `data` record, or the selected row of a collection. When a screen
|
|
14
|
+
declares several `data` and a `table` in scope shows exactly one collection, that collection is the
|
|
15
|
+
subject (see [table narrowing](#table-narrowing)). Inputs bind
|
|
9
16
|
from it: explicit `with <input> from item.<field>` first, then case-sensitive same-name
|
|
10
17
|
fields, then one key field with the same declared concept.
|
|
11
18
|
- `for screen`: independent of selection; no row fills the inputs. Use it for actions that
|
|
@@ -56,6 +63,25 @@ module Work
|
|
|
56
63
|
column title label "Task"
|
|
57
64
|
```
|
|
58
65
|
|
|
66
|
+
## Table narrowing
|
|
67
|
+
|
|
68
|
+
Requires Screenplay 6.18.0 or later (`screenplay --version`). A screen often shows a header
|
|
69
|
+
record next to a table of rows. An authored plain or toolbar `for item` action then acts on the
|
|
70
|
+
one collection `data` that a `table` in scope shows, so the header does not make it ambiguous:
|
|
71
|
+
|
|
72
|
+
```play
|
|
73
|
+
data Header via query HeaderOf
|
|
74
|
+
data Row[] via query Rows
|
|
75
|
+
table Row
|
|
76
|
+
action RetryItem for item
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Unchanged and still ambiguous: a table over a record, two tables over two collections, and no
|
|
80
|
+
table. Guarded actions and inferred (omitted) subjects are unchanged. PLAY0346 names the candidate
|
|
81
|
+
`data`; use that list to pick the explicit fix: show one table, or move the action into a screen
|
|
82
|
+
section or slot with its own local `data`. The subject is a modeling statement, so do not
|
|
83
|
+
restructure a screen only to satisfy `for item`.
|
|
84
|
+
|
|
59
85
|
State the subject on every plain and toolbar action. Without it, the compiler infers `for item`
|
|
60
86
|
when there is exactly one collection `data`, one required non-generated identifier and one key
|
|
61
87
|
with the same concept, and `for screen` otherwise. Inference follows types, not intent: here
|
package/package/corpus/skills/cratis-screenplay-ui-composition/references/guarded-interactions.md
CHANGED
|
@@ -52,7 +52,8 @@ item, and clearing selection runs nothing; change uses the item that changed (se
|
|
|
52
52
|
single item or selected row, with guarded actions' sibling precedence. Check named
|
|
53
53
|
behaviors at each `uses` site. Component `context` or `selectedItem` bindings do
|
|
54
54
|
not supply the subject in this version; unresolved/equally near subjects report
|
|
55
|
-
PLAY0346
|
|
55
|
+
PLAY0346, which names the candidate data (see
|
|
56
|
+
[table narrowing](action-subjects.md#table-narrowing)).
|
|
56
57
|
|
|
57
58
|
Submit, event, interval and application triggers have no alternatives.
|
|
58
59
|
The one-line `on row-click navigate to … by …` remains unchanged. Opaque `where`
|
|
@@ -262,6 +262,10 @@
|
|
|
262
262
|
{ "kind": "skill-contains", "value": "where item.status == \"accepted\"", "file": "references/change-alternatives.md" },
|
|
263
263
|
{ "kind": "skill-contains", "value": "including the `otherwise` list", "file": "references/change-alternatives.md" },
|
|
264
264
|
{ "kind": "skill-contains", "value": "Compiler admission is not proof that a Stage renderer executes the gesture.", "file": "references/change-alternatives.md" },
|
|
265
|
-
{ "kind": "skill-contains", "value": "references/change-alternatives.md" }
|
|
265
|
+
{ "kind": "skill-contains", "value": "references/change-alternatives.md" },
|
|
266
|
+
{ "kind": "skill-contains", "value": "## Table narrowing", "file": "references/action-subjects.md" },
|
|
267
|
+
{ "kind": "skill-contains", "value": "Requires Screenplay 6.18.0", "file": "references/action-subjects.md" },
|
|
268
|
+
{ "kind": "skill-contains", "value": "PLAY0346 names the candidate", "file": "references/action-subjects.md" },
|
|
269
|
+
{ "kind": "skill-contains", "value": "action-subjects.md#table-narrowing", "file": "references/guarded-interactions.md" }
|
|
266
270
|
]
|
|
267
271
|
}
|
|
@@ -26,7 +26,9 @@ against Stage v4.197.0: matched language/ESM 1.0–30.0 and 32.0 are admitted, n
|
|
|
26
26
|
Stage then applies matched-pair and construct gates. V32 needs a direct caller of
|
|
27
27
|
the reviewed Stage baseline. See [CLI bundle details](../cratis-screenplay-toolchain/references/language-admission.md#stage-admission-and-execution).
|
|
28
28
|
Renderer, semantic Host/specification execution and legacy syntax admission are
|
|
29
|
-
separate gates.
|
|
29
|
+
separate gates. Reading a model that carries unknown additions is a further separate gate:
|
|
30
|
+
[the unknown-preserving reader](../cratis-screenplay-toolchain/references/unknown-preserving-reader.md)
|
|
31
|
+
retains them without executing or rendering them, so renderer admission of such a model is not implied.
|
|
30
32
|
Bounded atomic batches render; unverifiable query performers can produce explicit
|
|
31
33
|
gaps, not completed behavior. Described handlers still refuse even in Stub mode.
|
|
32
34
|
Keep protection and report remaining refusals.
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
{ "kind": "skill-contains", "value": "Stage#847 lands, which needs Chronicle#5427", "file": "references/current-boundaries.md" },
|
|
66
66
|
{ "kind": "skill-contains", "value": "required single non-date, non-decimal primitive/concept", "file": "references/current-boundaries.md" },
|
|
67
67
|
{ "kind": "skill-contains", "value": "Single-instance lookup by parts remains `STAGE-ESM-047`", "file": "references/current-boundaries.md" },
|
|
68
|
-
{ "kind": "skill-contains", "value": "including DateTime and decimal key parts", "file": "SKILL.md" }
|
|
68
|
+
{ "kind": "skill-contains", "value": "including DateTime and decimal key parts", "file": "SKILL.md" },
|
|
69
|
+
{ "kind": "skill-contains", "value": "unknown-preserving-reader.md", "file": "SKILL.md" }
|
|
69
70
|
]
|
|
70
71
|
}
|