@cratis/pi 7.10.0 → 7.11.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.
Files changed (70) hide show
  1. package/package/corpus/agents/backend-developer.md +1 -1
  2. package/package/corpus/agents/code-reviewer.md +2 -2
  3. package/package/corpus/agents/coordinator.md +1 -1
  4. package/package/corpus/agents/frontend-developer.md +1 -1
  5. package/package/corpus/agents/orchestrator.md +1 -1
  6. package/package/corpus/agents/planner.md +2 -2
  7. package/package/corpus/agents/screenplay-modeler.md +1 -1
  8. package/package/corpus/agents/slice-implementer.md +1 -1
  9. package/package/corpus/agents/spec-writer.md +1 -1
  10. package/package/corpus/harnesses/pi/extensions/cratis-hooks/index.ts +6 -5
  11. package/package/corpus/harnesses/pi/extensions/cratis-hooks/quality-gate.ts +25 -4
  12. package/package/corpus/hooks/README.md +33 -7
  13. package/package/corpus/hooks/scripts/cratis-quality-gate.sh +246 -79
  14. package/package/corpus/hooks/scripts/quality-gates.json +17 -3
  15. package/package/corpus/prompts/add-reactor.prompt.md +1 -1
  16. package/package/corpus/prompts/new-vertical-slice.prompt.md +2 -2
  17. package/package/corpus/prompts/write-specs.prompt.md +2 -2
  18. package/package/corpus/rules/application-profile.md +1 -1
  19. package/package/corpus/rules/cratis-folder-is-configuration.md +28 -0
  20. package/package/corpus/rules/general.md +6 -1
  21. package/package/corpus/rules/profiles.md +4 -3
  22. package/package/corpus/rules/reactors.md +1 -1
  23. package/package/corpus/rules/vertical-slices.md +1 -1
  24. package/package/corpus/skills/cratis-application-react-specifications/SKILL.md +1 -1
  25. package/package/corpus/skills/cratis-application-slice-conformance/SKILL.md +2 -2
  26. package/package/corpus/skills/cratis-application-slice-conformance/references/contract-and-precedence.md +1 -1
  27. package/package/corpus/skills/cratis-application-slice-specifications/SKILL.md +1 -1
  28. package/package/corpus/skills/cratis-arc-command/SKILL.md +1 -1
  29. package/package/corpus/skills/cratis-arc-command-execution/SKILL.md +1 -1
  30. package/package/corpus/skills/cratis-arc-command-validation/SKILL.md +1 -1
  31. package/package/corpus/skills/cratis-arc-observable-query-http/SKILL.md +1 -1
  32. package/package/corpus/skills/cratis-arc-query-paging/SKILL.md +1 -1
  33. package/package/corpus/skills/cratis-arc-react-page/SKILL.md +1 -1
  34. package/package/corpus/skills/cratis-chronicle-event-constraints/SKILL.md +1 -1
  35. package/package/corpus/skills/cratis-chronicle-event-modeling/SKILL.md +2 -2
  36. package/package/corpus/skills/cratis-chronicle-event-type-migration/SKILL.md +1 -1
  37. package/package/corpus/skills/cratis-chronicle-projection/SKILL.md +1 -1
  38. package/package/corpus/skills/cratis-chronicle-reactor/SKILL.md +2 -2
  39. package/package/corpus/skills/cratis-chronicle-read-model/SKILL.md +1 -1
  40. package/package/corpus/skills/cratis-chronicle-read-model-specifications/SKILL.md +1 -1
  41. package/package/corpus/skills/cratis-chronicle-reducer/SKILL.md +1 -1
  42. package/package/corpus/skills/cratis-components-stepper-command-dialog/SKILL.md +1 -1
  43. package/package/corpus/skills/cratis-screenplay-captures-and-reactions/SKILL.md +5 -2
  44. package/package/corpus/skills/cratis-screenplay-captures-and-reactions/verification.json +2 -2
  45. package/package/corpus/skills/cratis-screenplay-command-surface/SKILL.md +5 -2
  46. package/package/corpus/skills/cratis-screenplay-command-surface/verification.json +2 -2
  47. package/package/corpus/skills/cratis-screenplay-discovery/SKILL.md +1 -1
  48. package/package/corpus/skills/cratis-screenplay-event-modeling/SKILL.md +9 -6
  49. package/package/corpus/skills/cratis-screenplay-event-modeling/verification.json +2 -2
  50. package/package/corpus/skills/cratis-screenplay-model-authoring/SKILL.md +12 -10
  51. package/package/corpus/skills/cratis-screenplay-model-authoring/references/mcp-loop.md +3 -4
  52. package/package/corpus/skills/cratis-screenplay-model-authoring/references/mcp-tools.md +3 -3
  53. package/package/corpus/skills/cratis-screenplay-model-authoring/verification.json +3 -3
  54. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/SKILL.md +5 -5
  55. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/opt-in.md +4 -4
  56. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/phases.md +1 -1
  57. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/verdicts-and-modes.md +1 -1
  58. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/verification.json +1 -1
  59. package/package/corpus/skills/cratis-screenplay-projections/SKILL.md +5 -2
  60. package/package/corpus/skills/cratis-screenplay-projections/verification.json +2 -2
  61. package/package/corpus/skills/cratis-screenplay-read-surface/SKILL.md +5 -2
  62. package/package/corpus/skills/cratis-screenplay-read-surface/verification.json +2 -2
  63. package/package/corpus/skills/cratis-screenplay-specifications/SKILL.md +5 -2
  64. package/package/corpus/skills/cratis-screenplay-specifications/verification.json +2 -2
  65. package/package/corpus/skills/cratis-screenplay-toolchain/SKILL.md +1 -1
  66. package/package/corpus/skills/cratis-screenplay-ui-composition/SKILL.md +5 -2
  67. package/package/corpus/skills/cratis-screenplay-ui-composition/verification.json +2 -2
  68. package/package/corpus/skills/cratis-specification-by-example/SKILL.md +1 -1
  69. package/package/corpus/skills/cratis-specifications-csharp/SKILL.md +1 -1
  70. package/package.json +1 -1
@@ -49,7 +49,7 @@ Load **cratis-application-slice-conformance** when it is installed; read the ski
49
49
 
50
50
  ## Process
51
51
 
52
- 0. **Find the contract.** Apply Phase 0 of `application-profile.md` first: the repository is opted in only when the model root (default `.cratis/screenplay/`, or the root set by `mcpServers.screenplay.root` in `.cratis/ai.json`) holds a committed `.play` file (`git ls-tree -r --name-only HEAD -- <root>` lists it) or the project explicitly set that root; an empty directory, install output, an installed skill, a `.play` file outside the root or an untracked or uncommitted draft is not opt-in. When opted in, an accepted model under the root is the contract, and new behaviour missing from the model is a request to add it, not a reason to use an outline. Skill availability is checked separately from opt-in. Without opt-in, an agreed outline is the contract and code-first work (infrastructure, clients, adapters, framework) is preserved. If the slice is in a Screenplay model, the `.play` slice and its specifications are the contract: write C# only for scope the renderer rejects or for adapters, never edit Stage-managed output, and never change the model to match code. If the contract is ambiguous or contradictory, do not guess: stop that scope and return one specific question (for `.play`, an edit request: address, change, reason).
52
+ 0. **Find the contract.** Apply Phase 0 of `application-profile.md` first: the repository is opted in only when the model root (the folder holding the project's `.play` files, or the root set by `mcpServers.screenplay.root` in `.cratis/ai.json`) holds a committed `.play` file (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured) or the project explicitly set that root; an empty directory, install output, an installed skill, a `.play` file outside the root or an untracked or uncommitted draft is not opt-in. When opted in, an accepted model under the root is the contract, and new behaviour missing from the model is a request to add it, not a reason to use an outline. Skill availability is checked separately from opt-in. Without opt-in, an agreed outline is the contract and code-first work (infrastructure, clients, adapters, framework) is preserved. If the slice is in a Screenplay model, the `.play` slice and its specifications are the contract: write C# only for scope the renderer rejects or for adapters, never edit Stage-managed output, and never change the model to match code. If the contract is ambiguous or contradictory, do not guess: stop that scope and return one specific question (for `.play`, an edit request: address, change, reason).
53
53
  1. **Determine the namespace root** by reading an existing source file to identify the convention (e.g. `Studio`, `Library`, `MyApp`).
54
54
  2. **Read existing slices** in the same feature to understand naming, existing concepts, and events you may reference.
55
55
  3. **Create a single `.cs` file** at `<Feature>/<Slice>/<Slice>.cs` (under the app source root; an optional `<Module>/` may group the feature — there is **no** top-level `Features/` wrapper).
@@ -31,7 +31,7 @@ Select only diff-relevant, profile-applicable canonical rules in `.cratis/ai/rul
31
31
 
32
32
  ## Model-first check
33
33
 
34
- Run the model-first decision once per review (master text: `cratis-screenplay-modeling-lifecycle`): the repository is opted in only when the model root (default `.cratis/screenplay/`) holds a committed `.play` file (`git ls-tree -r --name-only HEAD -- <root>` lists it) or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install output, an installed skill, a `.play` file outside the root or an untracked or uncommitted draft is not opt-in, and a behavior is a contract only when an accepted model under the root covers it. Otherwise skip this section, and do not demand a model from framework, brownfield or not-opted-in work. If the Screenplay skills are missing, say so in the report rather than reviewing model content from memory.
34
+ Run the model-first decision once per review (master text: `cratis-screenplay-modeling-lifecycle`): the repository is opted in only when the model root (the folder holding the project's `.play` files) holds a committed `.play` file (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured) or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install output, an installed skill, a `.play` file outside the root or an untracked or uncommitted draft is not opt-in, and a behavior is a contract only when an accepted model under the root covers it. Otherwise skip this section, and do not demand a model from framework, brownfield or not-opted-in work. If the Screenplay skills are missing, say so in the report rather than reviewing model content from memory.
35
35
 
36
36
  In an opted-in repository:
37
37
 
@@ -41,7 +41,7 @@ In an opted-in repository:
41
41
  - [ ] The model was not changed to match existing code
42
42
  - [ ] Specs derived from `.play` specifications were not weakened or removed
43
43
 
44
- Changes under `.cratis/screenplay/**` (or the model root) are not reviewed here beyond noting them: route them to `screenplay-reviewer` for an independent, fresh-context model review and list that routing in the report. Review the surrounding code changes as usual.
44
+ Changes to `.play` files (the model root) are not reviewed here beyond noting them: route them to `screenplay-reviewer` for an independent, fresh-context model review and list that routing in the report. Review the surrounding code changes as usual.
45
45
 
46
46
  ---
47
47
 
@@ -45,7 +45,7 @@ After selecting the profile and lane, read the applicable entries only:
45
45
  Run this once per request, before choosing an implementer; the master text is in `cratis-screenplay-modeling-lifecycle`.
46
46
 
47
47
  1. **Skill availability is separate from consent.** Check that the Screenplay method skills you need are installed. If they are missing, report which and stop for model work; never author Screenplay from memory and never install anything. Installed skills never opt a repository in.
48
- 2. **Opted in?** Yes only when the model root (default `.cratis/screenplay/`) holds a committed `.play` file (`git ls-tree -r --name-only HEAD -- <root>` lists it), or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json`. An empty directory, install output, an installed skill, a `.play` file outside the root or an untracked or uncommitted draft is not opt-in; a behavior is a contract only when an accepted model under the root covers it. If your brief already states the decision, use it. Then the `.play` model is the source of truth and the plan starts from it.
48
+ 2. **Opted in?** Yes only when the model root (the folder holding the project's `.play` files) holds a committed `.play` file (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured), or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json`. An empty directory, install output, an installed skill, a `.play` file outside the root or an untracked or uncommitted draft is not opt-in; a behavior is a contract only when an accepted model under the root covers it. If your brief already states the decision, use it. Then the `.play` model is the source of truth and the plan starts from it.
49
49
  3. **Not opted in:** stay code-first. Only the entry-point agent or session proposes a model (never when your brief carries the decision), at most once per session, naming the feature it would start with, and never for trivial, bug-fix, infrastructure, client, framework or brownfield-maintenance work; if declined, do not ask again, and put the decision in the brief of every delegated agent. Unattended: record the recommendation in the final report. Framework, brownfield, infrastructure, client and adapter work stays code-first and is never forced into a model.
50
50
  4. **Code is the right level for** infrastructure, clients, Screenplay code attachments and handlers, adapters, and scope Stage cannot render yet (gap-fill, with the `.play` slice and specs as the contract). Never use code as a shortcut around the model, change the model to match existing code, edit Stage-managed output, leave a modeled rule living only in code, or weaken protection (authorization, `@pii`, rules) to make a model compile or render.
51
51
  5. **Proportional execution still applies.** A model-first request does not require a multi-agent hierarchy: a trivial change is one short plan for one implementer (or the parent).
@@ -52,7 +52,7 @@ Confirm that the TypeScript proxies exist in the slice folder before writing any
52
52
 
53
53
  ## Model-first check
54
54
 
55
- Before writing slice UI, decide the level. The model is the source of truth when an accepted `.play` model covers the slice, or when the repository has opted in: the model root (default `.cratis/screenplay/`) holds a committed `.play` file (`git ls-tree -r --name-only HEAD -- <root>` lists it) or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json`. An empty directory, install output, an installed skill, a `.play` file outside the root or an untracked or uncommitted draft is not opt-in (master: `cratis-screenplay-modeling-lifecycle`). The page is then the model's implementation:
55
+ Before writing slice UI, decide the level. The model is the source of truth when an accepted `.play` model covers the slice, or when the repository has opted in: the model root (the folder holding the project's `.play` files) holds a committed `.play` file (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured) or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json`. An empty directory, install output, an installed skill, a `.play` file outside the root or an untracked or uncommitted draft is not opt-in (master: `cratis-screenplay-modeling-lifecycle`). The page is then the model's implementation:
56
56
 
57
57
  - Read the slice's `screen` and `form` declarations first, and follow `cratis-arc-react-page` `references/from-screenplay.md` for the declaration-to-component mapping. Use `cratis-screenplay-modeling-lifecycle` for the model-first decision rule.
58
58
  - Where the model and the request disagree, fix the model first (through the modeler, or ask) and report it. Never change the model to match existing code, and never add data or actions in the page that the model lacks.
@@ -46,7 +46,7 @@ After selecting the profile and lane, read the applicable entries only:
46
46
  Run this once per request, before choosing an implementer; the master text is in `cratis-screenplay-modeling-lifecycle`.
47
47
 
48
48
  1. **Skill availability is separate from consent.** Check that the Screenplay method skills you need are installed. If they are missing, report which and stop for model work; never author Screenplay from memory and never install anything. Installed skills never opt a repository in.
49
- 2. **Opted in?** Yes only when the model root (default `.cratis/screenplay/`) holds a committed `.play` file (`git ls-tree -r --name-only HEAD -- <root>` lists it), or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json`. An empty directory, install output, an installed skill, a `.play` file outside the root or an untracked or uncommitted draft is not opt-in; a behavior is a contract only when an accepted model under the root covers it. If your brief already states the decision, use it. Then the `.play` model is the source of truth and the plan starts from it.
49
+ 2. **Opted in?** Yes only when the model root (the folder holding the project's `.play` files) holds a committed `.play` file (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured), or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json`. An empty directory, install output, an installed skill, a `.play` file outside the root or an untracked or uncommitted draft is not opt-in; a behavior is a contract only when an accepted model under the root covers it. If your brief already states the decision, use it. Then the `.play` model is the source of truth and the plan starts from it.
50
50
  3. **Not opted in:** stay code-first. Only the entry-point agent or session proposes a model (never when your brief carries the decision), at most once per session, naming the feature it would start with, and never for trivial, bug-fix, infrastructure, client, framework or brownfield-maintenance work; if declined, do not ask again, and put the decision in the brief of every delegated agent. Unattended: record the recommendation in the final report. Framework, brownfield, infrastructure, client and adapter work stays code-first and is never forced into a model.
51
51
  4. **Code is the right level for** infrastructure, clients, Screenplay code attachments and handlers, adapters, and scope Stage cannot render yet (gap-fill, with the `.play` slice and specs as the contract). Never use code as a shortcut around the model, change the model to match existing code, edit Stage-managed output, leave a modeled rule living only in code, or weaken protection (authorization, `@pii`, rules) to make a model compile or render.
52
52
  5. **Proportional execution still applies.** A model-first request does not require a multi-agent hierarchy: a trivial change is one short plan for one implementer (or the parent).
@@ -44,7 +44,7 @@ After selecting the profile and lane, read the applicable entries only:
44
44
  Run this once per request, before choosing an implementer; the master text is in `cratis-screenplay-modeling-lifecycle`.
45
45
 
46
46
  1. **Skill availability is separate from consent.** Check that the Screenplay method skills you need are installed. If they are missing, report which and stop for model work; never author Screenplay from memory and never install anything. Installed skills never opt a repository in.
47
- 2. **Opted in?** Yes only when the model root (default `.cratis/screenplay/`) holds a committed `.play` file (`git ls-tree -r --name-only HEAD -- <root>` lists it), or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json`. An empty directory, install output, an installed skill, a `.play` file outside the root or an untracked or uncommitted draft is not opt-in; a behavior is a contract only when an accepted model under the root covers it. If your brief already states the decision, use it. Then the `.play` model is the source of truth and the plan starts from it.
47
+ 2. **Opted in?** Yes only when the model root (the folder holding the project's `.play` files) holds a committed `.play` file (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured), or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json`. An empty directory, install output, an installed skill, a `.play` file outside the root or an untracked or uncommitted draft is not opt-in; a behavior is a contract only when an accepted model under the root covers it. If your brief already states the decision, use it. Then the `.play` model is the source of truth and the plan starts from it.
48
48
  3. **Not opted in:** stay code-first. Only the entry-point agent or session proposes a model (never when your brief carries the decision), at most once per session, naming the feature it would start with, and never for trivial, bug-fix, infrastructure, client, framework or brownfield-maintenance work; if declined, do not ask again, and put the decision in the brief of every delegated agent. Unattended: record the recommendation in the final report. Framework, brownfield, infrastructure, client and adapter work stays code-first and is never forced into a model.
49
49
  4. **Code is the right level for** infrastructure, clients, Screenplay code attachments and handlers, adapters, and scope Stage cannot render yet (gap-fill, with the `.play` slice and specs as the contract). Never use code as a shortcut around the model, change the model to match existing code, edit Stage-managed output, leave a modeled rule living only in code, or weaken protection (authorization, `@pii`, rules) to make a model compile or render.
50
50
  5. **Proportional execution still applies.** A model-first request does not require a multi-agent hierarchy: a trivial change is one short plan for one implementer (or the parent).
@@ -53,7 +53,7 @@ Run this once per request, before choosing an implementer; the master text is in
53
53
 
54
54
  When the decision above says the repository is opted in and the scope is model-owned behavior or a model change (infrastructure, client, adapter and code-attachment/handler work is planned directly as code, keeping any model or spec contract it touches):
55
55
 
56
- - Plan from the `.play` slice and its specifications, not from C# conventions. Detect the slice by name under the model root (configured root, else `.cratis/screenplay/`); an empty root means the feature starts in discovery and slice design.
56
+ - Plan from the `.play` slice and its specifications, not from C# conventions. Detect the slice by name under the model root (configured root, else the folder holding the project's `.play` files); an empty root means the feature starts in discovery and slice design.
57
57
  - Consumed events are orientation, not build order. The "State View waits for State Change" rule in the parallelisation rules below applies to hand-written C# only; it does not order model work.
58
58
  - Order: `screenplay-modeler` -> `screenplay-reviewer` (fresh context) -> user acceptance -> `screenplay-renderer`. Use `slice-implementer` for gap-fill only, after the renderer reports what Stage cannot render and the work is authorized.
59
59
  - The Backend/Specs/Build/Frontend template below is for code-first work and gap-fill; do not use it to bypass an accepted model.
@@ -22,7 +22,7 @@ You author and change the `.play` model, the source of truth for behavior. Code
22
22
 
23
23
  ## Capability guard (first, before anything else)
24
24
 
25
- 1. Decide the level with the decision procedure in `cratis-screenplay-modeling-lifecycle`: the repository is opted in only when the model root (default `.cratis/screenplay/`) holds a committed `.play` file (`git ls-tree -r --name-only HEAD -- <root>` lists it) or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install output, an installed skill, a `.play` file outside the root or an untracked or uncommitted draft is not opt-in. A direct user request to model this scope is itself the consent for that scope. Your work in the model root stays a draft until the user commits it; recommend the commit at P6 and never commit yourself. Otherwise stop and report that the repository is not opted in (never propose a model yourself when delegated); the code-first path belongs to the code agents.
25
+ 1. Decide the level with the decision procedure in `cratis-screenplay-modeling-lifecycle`: the repository is opted in only when the model root (the folder holding the project's `.play` files) holds a committed `.play` file (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured) or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install output, an installed skill, a `.play` file outside the root or an untracked or uncommitted draft is not opt-in. A direct user request to model this scope is itself the consent for that scope. Your work in the model root stays a draft until the user commits it; recommend the commit at P6 and never commit yourself. Otherwise stop and report that the repository is not opted in (never propose a model yourself when delegated); the code-first path belongs to the code agents.
26
26
  2. Availability is separate from consent. If `cratis-screenplay-modeling-lifecycle` (or the phase skill the step needs) is not installed, say that the `cratis/screenplay` profile is not installed, name the missing skill, and stop with `Outcome: blocked`. Never author Screenplay from memory, never install anything.
27
27
  3. Read the `.play` slice, its specifications and STATE.md before concluding something is missing.
28
28
 
@@ -41,7 +41,7 @@ A new vertical slice (State Change, State View, Automation, Translation), or a n
41
41
 
42
42
  ### Phase 1 — Contract
43
43
  Find what the code must match before writing any of it.
44
- 1. **Look for a Screenplay model** under the repository's model root (default `.cratis/screenplay/`; search `**/*.play`) and search it for the slice, command, event and read-model names. The repository is opted in only when the model root holds a `.play` file in the committed tree (`git ls-tree -r --name-only HEAD -- <root>` lists it) or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json` (even if that root is empty); an empty unconfigured directory, install output, an installed skill, a `.play` file outside the root (ignore it) or an untracked or uncommitted draft is not opt-in, and a behaviour is a contract only when an accepted model (committed; its HEAD version remains the contract while working-tree edits are a model change in progress until committed) under the root covers it (master: `cratis-screenplay-modeling-lifecycle`). Use the decision in your brief if it carries one. If the Screenplay skills are not installed, say so and do not author `.play` from memory.
44
+ 1. **Look for a Screenplay model** under the repository's model root (the folder holding the project's `.play` files; search `**/*.play`) and search it for the slice, command, event and read-model names. The repository is opted in only when the model root holds a `.play` file in the committed tree (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured) or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json` (even if that root is empty); an empty unconfigured directory, install output, an installed skill, a `.play` file outside the root (ignore it) or an untracked or uncommitted draft is not opt-in, and a behaviour is a contract only when an accepted model (committed; its HEAD version remains the contract while working-tree edits are a model change in progress until committed) under the root covers it (master: `cratis-screenplay-modeling-lifecycle`). Use the decision in your brief if it carries one. If the Screenplay skills are not installed, say so and do not author `.play` from memory.
45
45
  2. **An accepted model under the root covers the slice:** the `.play` slice and its specifications are the contract. Change behaviour in the model first, then render it; write C# by hand only for scope the renderer rejects (gap-fill, per `cratis-screenplay-render-and-gap-fill`) or for adapters and infrastructure. Never hand-edit Stage-managed output; never change the model to match existing code.
46
46
  3. **Opted in (an accepted model under the root, or a configured root, even if empty) but no accepted model covers this behaviour:** return a request to add it to the model (address, change, reason); new behaviour starts in discovery and slice design (`cratis-screenplay-discovery`, `cratis-screenplay-slice-design`). Write code first only when the user chooses to, or the behaviour cannot be expressed in `.play`; then report that the model lags the code.
47
47
  4. **Not opted in (neither an accepted model under the root nor a configured root):** stay code-first; do not propose a model (only the entry-point agent or session does, at most once per session; a declined proposal is not repeated). Confirm Module/Feature, slice name and type, the behaviour in one sentence, whether a UI surface is needed. For new behaviour, unclear event names/stream boundaries or multi-slice flows, run **cratis-chronicle-event-modeling**. Confirm the domain requirements as before; the agreed outline (fields, events, rules, scenarios) is the contract, recorded where the team tracks work, if anywhere.
@@ -35,7 +35,7 @@ Select from these canonical rules in `.cratis/ai/rules/` only after applying the
35
35
  ## Inputs you expect
36
36
 
37
37
  - Feature name, slice name, and slice type (specs are **mandatory for every slice type**)
38
- - The slice's contract and its specification list: the `.play` slice's specifications, or the agreed outline. Before accepting an outline, apply Phase 0 of `application-profile.md` (an accepted model under the model root covers the scope, or the repository is opted in, meaning the root holds a committed `.play` file (`git ls-tree -r --name-only HEAD -- <root>` lists it) or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json`: the contract is the `.play` slice's specifications; if the model lacks the behaviour, request it be added; check skill availability separately). Without opt-in, an agreed outline is the contract and code-first work is preserved. Existing code is not the contract.
38
+ - The slice's contract and its specification list: the `.play` slice's specifications, or the agreed outline. Before accepting an outline, apply Phase 0 of `application-profile.md` (an accepted model under the model root covers the scope, or the repository is opted in, meaning the root holds a committed `.play` file (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured) or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json`: the contract is the `.play` slice's specifications; if the model lacks the behaviour, request it be added; check skill availability separately). Without opt-in, an agreed outline is the contract and code-first work is preserved. Existing code is not the contract.
39
39
  - The complete slice file (`<Slice>.cs`) so you understand what behaviors to specify
40
40
  - Any business rules or constraints that must be validated
41
41
  - The namespace root (read from existing source files)
@@ -287,7 +287,7 @@ export default function (pi: ExtensionAPI) {
287
287
  const gates = parseGatePlan(run.stderr);
288
288
  if (run.aborted) return { gates: [], problem: "its dry run was cancelled" };
289
289
  if (run.timedOut) return { gates, problem: `its dry run did not finish within ${PLAN_TIMEOUT_MS / 1000}s` };
290
- if (run.failed || run.code !== 0) return { gates, problem: `its dry run could not be completed (exit ${run.code ?? "none"})` };
290
+ if (run.failed || run.code !== 0) return { gates, problem: `its dry run could not be completed (exit ${run.code ?? "none"})${run.stderr.trim() ? `\n\n${run.stderr.trim()}` : ""}` };
291
291
  return { gates };
292
292
  }
293
293
 
@@ -342,7 +342,7 @@ export default function (pi: ExtensionAPI) {
342
342
  const reportTimedOut = () => {
343
343
  const last = latestGateLog(gateLogDirectory(sessionId), started);
344
344
  const tail = last ? tailLines(last.file, TAIL_LINES) : "";
345
- throw new Error(`The Cratis quality gate TIMED OUT after ${duration(timeoutSeconds * 1000)}${last ? ` while running '${last.gate}'` : ""}. This is not a pass: nothing was verified.` +
345
+ throw new Error(`The Cratis quality gate TIMED OUT after ${duration(timeoutSeconds * 1000)}${last ? ` while running '${last.gate}'${last.cwd ? ` (cwd: ${last.cwd})` : ""}` : ""}. This is not a pass: nothing was verified.` +
346
346
  (last ? `\n\nGate log: ${last.file}` : "") +
347
347
  (tail ? `\n\n--- last ${TAIL_LINES} lines ---\n${tail}\n--- end ---` : ""));
348
348
  };
@@ -363,15 +363,16 @@ export default function (pi: ExtensionAPI) {
363
363
  if (plan.problem) throw new Error(`The Cratis quality gate plan could not be completed: ${plan.problem}. Nothing was verified.`);
364
364
  const planned = plan.gates.length > 0 ? plan.gates.join(", ") : "none planned";
365
365
  const progress = (elapsedMs: number) => {
366
- const current = latestGateLog(logDirectory, started)?.gate;
366
+ const currentLog = latestGateLog(logDirectory, started);
367
+ const current = currentLog?.gate;
367
368
  onUpdate?.({
368
369
  content: [
369
370
  {
370
371
  type: "text",
371
- text: `Cratis quality gate running${current ? ` ${current}` : ""}: ${duration(elapsedMs)} of ${duration(timeoutSeconds * 1000)} (gates: ${planned}). Escape cancels.`,
372
+ text: `Cratis quality gate running${current ? ` ${current}${currentLog?.cwd ? ` (cwd: ${currentLog.cwd})` : ""}` : ""}: ${duration(elapsedMs)} of ${duration(timeoutSeconds * 1000)} (gates: ${planned}). Escape cancels.`,
372
373
  },
373
374
  ],
374
- details: { status: "running", gates: plan.gates, current, elapsedMs, timeoutSeconds },
375
+ details: { status: "running", gates: plan.gates, current, cwd: currentLog?.cwd, elapsedMs, timeoutSeconds },
375
376
  });
376
377
  };
377
378
  progress(Date.now() - started);
@@ -202,9 +202,15 @@ export function gateTimeoutSeconds(requested?: number, environment = process.env
202
202
  return Math.min(MAX_GATE_TIMEOUT_SECONDS, Math.max(MIN_GATE_TIMEOUT_SECONDS, Math.round(candidate)));
203
203
  }
204
204
 
205
- /** The gate ids a `CRATIS_HOOKS_GATE_DRYRUN=1` run says it would execute, in order. */
205
+ /** Unique planned gate labels, in order, with package counts for multi-directory runs. */
206
206
  export function parseGatePlan(dryRunStderr: string): string[] {
207
- return [...dryRunStderr.matchAll(/^cratis-quality-gate: RUN\s+(\S+)/gm)].map((match) => match[1]);
207
+ const directories = new Map<string, Set<string>>();
208
+ for (const match of dryRunStderr.matchAll(/^cratis-quality-gate: RUN[ \t]+(\S+)[^\n]*(?:\n[ \t]+\$[^\n]*\(cwd: (.*)\))?/gm)) {
209
+ const locations = directories.get(match[1]) ?? new Set<string>();
210
+ locations.add(match[2] ?? "unknown");
211
+ directories.set(match[1], locations);
212
+ }
213
+ return [...directories].map(([gate, locations]) => locations.size > 1 ? `${gate} (${locations.size} packages)` : gate);
208
214
  }
209
215
 
210
216
  /** Where cratis-quality-gate.sh writes each gate's full log for a session (mirrors hook_state_dir in hook-lib.sh). */
@@ -215,7 +221,7 @@ export function gateLogDirectory(sessionId: string, environment = process.env):
215
221
  }
216
222
 
217
223
  /** The gate log written most recently since `sinceMs` — the gate that is running, or was when it stopped. */
218
- export function latestGateLog(directory: string, sinceMs: number): { gate: string; file: string } | undefined {
224
+ export function latestGateLog(directory: string, sinceMs: number): { gate: string; cwd?: string; file: string } | undefined {
219
225
  let latest: { gate: string; file: string; mtime: number } | undefined;
220
226
  try {
221
227
  for (const name of fs.readdirSync(directory)) {
@@ -228,7 +234,22 @@ export function latestGateLog(directory: string, sinceMs: number): { gate: strin
228
234
  } catch {
229
235
  return undefined;
230
236
  }
231
- return latest && { gate: latest.gate, file: latest.file };
237
+ if (!latest) return undefined;
238
+ // The script writes identity before command output. Bound the read even for enormous logs.
239
+ let descriptor: number | undefined;
240
+ try {
241
+ descriptor = fs.openSync(latest.file, "r");
242
+ const buffer = Buffer.alloc(8192);
243
+ const length = fs.readSync(descriptor, buffer, 0, buffer.length, 0);
244
+ const header = buffer.subarray(0, length).toString("utf8").split("\n", 1)[0];
245
+ const identity = /^cratis-quality-gate: LOG (\S+) \(cwd: (.*)\)$/.exec(header);
246
+ if (identity) return { gate: identity[1], cwd: identity[2], file: latest.file };
247
+ } catch {
248
+ // Older or unreadable logs keep their existing filename-based display.
249
+ } finally {
250
+ if (descriptor !== undefined) fs.closeSync(descriptor);
251
+ }
252
+ return { gate: latest.gate, file: latest.file };
232
253
  }
233
254
 
234
255
  const MAX_LOG_TAIL_BYTES = 64 * 1024;
@@ -183,8 +183,10 @@ property is only reported when it really sits inside an `[EventType]`.
183
183
  ### Project-specific gate configuration
184
184
 
185
185
  The shipped gates discover the repository's own solution and package, so most repositories need no
186
- configuration at all. A repository whose project is not where discovery lands — several packages, a
187
- frontend under `Source/<App>` — states only what differs in its own
186
+ configuration at all. An eligible root workspace or solution keeps repository-wide dispatch. Without
187
+ one, discovery uses only each gate's matching, non-excluded changes and runs it once per affected
188
+ project directory, choosing the deepest containing project for each path. A repository
189
+ that needs a different location or has changes outside several candidate projects states only what differs in its own
188
190
  `.cratis/ai/quality-gates.project.json`, which the gate merges over the managed file by gate id:
189
191
 
190
192
  ```json
@@ -402,7 +404,10 @@ A gate whose `requires.commands` are not on `PATH`, whose `requires.paths` do no
402
404
  script may instead be defined in the root `package.json` — this assumes Yarn Berry, where a
403
405
  root-defined `g:` script runs from every workspace, and no workspace `package.json` is inspected), or whose `workingDirectoryFrom` matches
404
406
  nothing in the repository, is a **no-op with a message on stderr**
405
- rather than a failure — that is how a repository with no .NET solution or no frontend stays quiet.
407
+ rather than a failure — a repository with no .NET solution or no frontend runs no corresponding gate.
408
+ With no working-tree changes the script exits silently. An empty plan for a changed tree reports
409
+ `cratis-quality-gate: no gates selected — product verification was not performed.` on stderr; this
410
+ is not evidence of product verification.
406
411
 
407
412
  An override in `.cratis/ai/quality-gates.project.json` is merged shallowly: a field it states
408
413
  replaces the managed one. The one exception is `requires.packageScripts`: an override that sets
@@ -421,10 +426,31 @@ gates it needs in `.cratis/ai/quality-gates.project.json`.
421
426
  repository and silently no-op in every other, which is the worst of both: it looks configured and
422
427
  checks nothing. So the .NET and frontend gates state *what kind of project* they build and let the
423
428
  gate script find it — `workingDirectoryFrom: ["*.slnx", "*.sln", "**/*.slnx", "**/*.sln"]` runs
424
- `dotnet build` in whichever directory holds the repository's own solution, preferring one at the
425
- root because the globs are tried in order. The frontend gates discover `package.json` the same way.
426
- The same shipped file therefore activates in an application repository, activates in a framework
427
- repository, and stays quiet in a repository that has no project at all.
429
+ `dotnet build` in the directories holding the affected solutions. The frontend gates discover
430
+ `package.json` the same way. For each changed path surviving the gate's `changed`/`excludeChanged`
431
+ filters, discovery preserves an eligible root project and otherwise selects its deepest containing
432
+ project within the first glob holding eligible candidates, running once per affected directory.
433
+ The default root-first glob order retains dependent-workspace coverage; explicit glob preferences
434
+ remain honored. Unrelated
435
+ README edits and excluded `dist`, `bin`, or `obj` changes never influence that selection. A single
436
+ eligible project may own source outside its directory; multiple candidates with an uncontained
437
+ trigger report `UNVERIFIED` and exit 2, requiring explicit configuration rather than checking one
438
+ arbitrary package.
439
+
440
+ When `.cratis/ai.manifest.json` exists, discovery excludes the installed `.cratis/ai/` tree and
441
+ symlinks resolving into it. Without the install manifest, authored corpus packages remain eligible.
442
+ Containment resolves paths physically with `cd -P`, including directory symlinks followed by `..`;
443
+ both the project-file target and the execution directory must be inside the task-owning repository
444
+ and outside the managed tree. This depends on actual targets, not a global exclusion of similarly
445
+ named authored directories. Candidate resolution is cached across gates, and path filtering and
446
+ prefix selection use batch passes rather than per-path subprocesses.
447
+
448
+ Gate commands read from `/dev/null`, never the remaining directory list. If some affected directories
449
+ run while others have unmet requirements, the gate reports `UNVERIFIED` and exits 2; a wholly
450
+ inapplicable gate remains a no-op. Pi preserves the script's diagnostics when planning fails.
451
+
452
+ The same shipped file therefore activates in application and framework repositories, and reports
453
+ an empty plan without running gates in a repository that has no project at all.
428
454
 
429
455
  **Overriding it, in order of increasing force.** Set `workingDirectory` on a gate to pin one of
430
456
  several candidate projects; drop a `quality-gates.json` of your own in place of the shipped one; or