@cratis/pi 7.54.0 → 7.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package/corpus/agents/backend-developer.md +1 -1
- package/package/corpus/agents/code-reviewer.md +1 -1
- package/package/corpus/agents/coordinator.md +1 -1
- package/package/corpus/agents/frontend-developer.md +1 -1
- package/package/corpus/agents/orchestrator.md +1 -1
- package/package/corpus/agents/planner.md +1 -1
- package/package/corpus/agents/screenplay-modeler.md +1 -1
- package/package/corpus/agents/slice-implementer.md +2 -2
- package/package/corpus/agents/spec-writer.md +1 -1
- package/package/corpus/harnesses/copilot/instructions/application-profile.instructions.md +1 -1
- package/package/corpus/harnesses/copilot/instructions/profiles.instructions.md +1 -5
- package/package/corpus/harnesses/copilot/instructions/reactors.instructions.md +1 -1
- package/package/corpus/harnesses/copilot/instructions/vertical-slices.instructions.md +1 -1
- package/package/corpus/prompts/add-reactor.prompt.md +1 -1
- package/package/corpus/prompts/new-vertical-slice.prompt.md +1 -1
- package/package/corpus/prompts/write-specs.prompt.md +1 -1
- package/package/corpus/rules/application-profile.md +1 -1
- package/package/corpus/rules/profiles.md +1 -5
- package/package/corpus/rules/reactors.md +1 -1
- package/package/corpus/rules/vertical-slices.md +1 -1
- package/package/corpus/skills/cratis-application-react-specifications/SKILL.md +1 -4
- package/package/corpus/skills/cratis-application-slice-conformance/SKILL.md +6 -10
- package/package/corpus/skills/cratis-application-slice-conformance/references/contract-and-precedence.md +3 -8
- package/package/corpus/skills/cratis-application-slice-specifications/SKILL.md +1 -3
- package/package/corpus/skills/cratis-arc-command/SKILL.md +1 -4
- package/package/corpus/skills/cratis-arc-command-execution/SKILL.md +1 -4
- package/package/corpus/skills/cratis-arc-command-validation/SKILL.md +1 -4
- package/package/corpus/skills/cratis-arc-observable-query-http/SKILL.md +1 -4
- package/package/corpus/skills/cratis-arc-query-paging/SKILL.md +1 -4
- package/package/corpus/skills/cratis-arc-react-page/SKILL.md +1 -4
- package/package/corpus/skills/cratis-chronicle-event-constraints/SKILL.md +1 -4
- package/package/corpus/skills/cratis-chronicle-event-modeling/SKILL.md +2 -5
- package/package/corpus/skills/cratis-chronicle-event-type-migration/SKILL.md +1 -4
- package/package/corpus/skills/cratis-chronicle-projection/SKILL.md +1 -4
- package/package/corpus/skills/cratis-chronicle-reactor/SKILL.md +1 -3
- package/package/corpus/skills/cratis-chronicle-read-model/SKILL.md +1 -4
- package/package/corpus/skills/cratis-chronicle-read-model-specifications/SKILL.md +1 -3
- package/package/corpus/skills/cratis-chronicle-reducer/SKILL.md +1 -4
- package/package/corpus/skills/cratis-components-stepper-command-dialog/SKILL.md +1 -4
- package/package/corpus/skills/cratis-screenplay-discovery/SKILL.md +1 -2
- package/package/corpus/skills/cratis-screenplay-event-modeling/SKILL.md +1 -7
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/SKILL.md +9 -9
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/opt-in.md +3 -33
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/phases.md +1 -5
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/scripts/model-first-self-test.mjs +104 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/scripts/model-first-status.mjs +141 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/SKILL.md +1 -1
- package/package/corpus/skills/cratis-specification-by-example/SKILL.md +1 -3
- package/package/corpus/skills/cratis-specifications-csharp/SKILL.md +1 -4
- 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:
|
|
52
|
+
0. **Find the contract.** Apply Phase 0 of `application-profile.md` first: decide opt-in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts. 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
|
-
|
|
34
|
+
Decide opt-in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` once per review for the decision, model root and drafts. 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
|
|
|
@@ -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?**
|
|
48
|
+
2. **Opted in?** Apply `general.md` "Model first" for opt-in; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts. 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
|
|
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 (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts). 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?**
|
|
49
|
+
2. **Opted in?** Apply `general.md` "Model first" for opt-in; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts. 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?**
|
|
47
|
+
2. **Opted in?** Apply `general.md` "Model first" for opt-in; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts. 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).
|
|
@@ -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
|
|
25
|
+
1. Decide opt-in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts. 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,10 +41,10 @@ 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
|
|
44
|
+
1. **Look for a Screenplay model** under the model root (opted in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, root and drafts) and search it for the slice, command, event and read-model names. 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
|
-
4. **Not opted in (
|
|
47
|
+
4. **Not opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`):** 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.
|
|
48
48
|
|
|
49
49
|
Load **cratis-application-slice-conformance** and keep its inventory open through every later phase. **Gate:** you can name the contract and its specification list.
|
|
50
50
|
|
|
@@ -36,7 +36,7 @@ Select from these canonical rules in `.cratis/ai/rules/` only after applying the
|
|
|
36
36
|
## Inputs you expect
|
|
37
37
|
|
|
38
38
|
- Feature name, slice name, and slice type (specs are **mandatory for every slice type**)
|
|
39
|
-
- 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,
|
|
39
|
+
- 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, per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`: 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.
|
|
40
40
|
- The complete slice file (`<Slice>.cs`) so you understand what behaviors to specify
|
|
41
41
|
- Any business rules or constraints that must be validated
|
|
42
42
|
- The namespace root (read from existing source files)
|
|
@@ -69,7 +69,7 @@ Tagged **[contract]** (framework-enforced) or **[convention]** (house default).
|
|
|
69
69
|
|
|
70
70
|
- **Starting a brand-new application:** scaffold it instead of hand-writing the skeleton: `dotnet new install Cratis.Templates`, then `dotnet new cratis -n MyApp -o MyApp` (`--language Kotlin|Java`, `--Database MongoDB|PostgreSQL|MsSql|SQLite`; `cratis-aspire` for Aspire; `cratis-chronicle-console` or `cratis-chronicle-web` for a Chronicle client only). Non-interactive runs need `--allow-scripts yes`; the .NET templates target `net10.0`. The template writes `.cratis/ai.json`; run `cratis ai update` afterwards. Its `SomeModule/SomeFeature/Registration/` slice is the house shape. There is no Go, Python or Elixir template (verified at Cratis.Templates `v1.7.4`).
|
|
71
71
|
- **Phase 0 — Find the contract / choose the level.** Before writing slice code, find what the code must match, and choose the level once for the whole scope.
|
|
72
|
-
1. **Look for a Screenplay model** under the model root (
|
|
72
|
+
1. **Look for a Screenplay model** under the model root (opted in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, root and drafts) for the slice, command, event and read-model names.
|
|
73
73
|
2. **Model level** — an accepted model under the root covers the scope, or the repository is opted in and this scope has no model yet. The `.play` slice and its specs are the contract: change the model first (new behavior starts in discovery), verify it (V1–V3), get an independent review, then render with Stage or gap-fill by hand only what the renderer rejects. Hand-written code stays checked against the model (**cratis-application-slice-conformance**). Never edit Stage-managed output, never implement behavior the model does not state, never change the model to match existing code, never weaken protection to make it compile or render. Start with **cratis-screenplay-event-modeling** (decision rule), then **cratis-screenplay-modeling-lifecycle**. If the Screenplay skills are not installed, say so; do not author `.play` from memory.
|
|
74
74
|
3. **Code level** — infrastructure (hosting, DI composition, identity wiring, CI, deployment), clients, Screenplay code attachments and handlers, adapters in the render's customization area, and scope Stage cannot render yet (the model remains the contract). Framework repositories and brownfield work that is not opted in also stay code-first. Only the entry-point session may propose a model, at most once per session and never for trivial, bug-fix, infrastructure, client, framework or brownfield-maintenance work; if declined, do not ask again. Confirm Module/Feature, slice name, slice type and domain requirements as before; for new behavior or unclear event vocabulary run **cratis-chronicle-event-modeling** first, and record the agreed outline (fields, events, rules, scenarios) where the team tracks work, if anywhere. If you write code first where a model exists, say the model now lags.
|
|
75
75
|
4. **Trivial changes** keep the proportional-delegation policy; Phases 1–3 below apply to code you write at either level.
|
|
@@ -227,11 +227,7 @@ The MCP catalog has no install-hints field and does not install the executable.
|
|
|
227
227
|
|
|
228
228
|
### Event modeling with Screenplay
|
|
229
229
|
|
|
230
|
-
**Model first.**
|
|
231
|
-
`.play` files live: normally under `Source/` or `src/`, else `Screenplay/`) 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
|
|
232
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install output, an
|
|
233
|
-
installed profile or skill, a `.play` file outside the root or an untracked or uncommitted draft is not
|
|
234
|
-
opt-in. An accepted model under the root covering the scope is the contract and the source
|
|
230
|
+
**Model first.** Decide opt-in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts. An accepted model under the root covering the scope is the contract and the source
|
|
235
231
|
of truth for behavior. Change the model, verify and independently review it, then render
|
|
236
232
|
or gap-fill from its contract; never edit Stage-managed output or weaken protection.
|
|
237
233
|
Otherwise stay code-first; only the entry-point session may propose a model, at most once
|
|
@@ -10,7 +10,7 @@ profile: application
|
|
|
10
10
|
|
|
11
11
|
Reactors are the "if this then that" of event sourcing — they observe events and produce side effects. Unlike projections (which build state), reactors *do things*: send emails, trigger commands in other slices, call external APIs.
|
|
12
12
|
|
|
13
|
-
**Model first:** when an accepted model under the model root covers this scope (or the repository is opted in
|
|
13
|
+
**Model first:** when an accepted model under the model root covers this scope (or the repository is opted in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`), a reactor implements an automation that the model owns (`produces` / `invokes`); read the modeled slice first and keep the reactor to what the model leaves to code (gap-fill). Otherwise (not opted in) stay code-first: this file and the **cratis-chronicle-reactor** skill are the guide, and the entry-point session may propose a model at most once per session. See `cratis-screenplay-modeling-lifecycle`'s `scripts/model-first-status.mjs` for the decision, root and drafts.
|
|
14
14
|
|
|
15
15
|
## IReactor — Marker Interface
|
|
16
16
|
|
|
@@ -15,7 +15,7 @@ A vertical slice owns a single behavior: the command or query, the events it pro
|
|
|
15
15
|
|
|
16
16
|
This file is the reference for *what* goes in each part of a slice. Layout, slice types, workflow, and quality gates are in [general.md](../../../rules/general.md).
|
|
17
17
|
|
|
18
|
-
**Model-first check.** Before changing a slice, look for it in the accepted `.play` model
|
|
18
|
+
**Model-first check.** Before changing a slice, look for it in the accepted `.play` model under the model root (opted in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, root and drafts). If an accepted model covers it, change the model and render or gap-fill from it; never edit Stage-managed files. See Phase 0 in [application-profile.md](./application-profile.instructions.md).
|
|
19
19
|
|
|
20
20
|
## Technical stack
|
|
21
21
|
|
|
@@ -9,7 +9,7 @@ Add a reactor that observes events and produces side effects. Invoke the **crati
|
|
|
9
9
|
|
|
10
10
|
## Confirm first
|
|
11
11
|
|
|
12
|
-
- **Model first:** if an accepted model under the model root covers this scope, or the repository is opted in (
|
|
12
|
+
- **Model first:** if an accepted model under the model root covers this scope, or the repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`), the automation belongs in the model (`produces` / `invokes`); check there before writing code and follow the model-first routing in `.cratis/ai/rules/general.md`. Reactor code is then gap-fill against the modeled contract. If not opted in, stay code-first.
|
|
13
13
|
- **Events to react to**, the **side effect**, and the slice type: `Automation` (our own event causes an external side effect, a follow-up event, or a follow-up command) or `Translation` (data from an outside system recorded as our own facts).
|
|
14
14
|
- **Contract details to settle:** where each output field comes from (the trigger event, an injected read model, or a stated mapping), every condition that skips an event, and what must not happen twice.
|
|
15
15
|
|
|
@@ -12,7 +12,7 @@ Implement a complete **vertical slice** end-to-end. Follow the Implementation Wo
|
|
|
12
12
|
Before any slice code, find what the code must match. Decide the route once:
|
|
13
13
|
|
|
14
14
|
1. **The slice is in an accepted Screenplay model** (search the model root for the slice, command, event and read-model names; the project's `**/*.play`, or the configured root). The `.play` slice and its specifications are the contract. Change behavior in the model first (the `cratis-screenplay-*` skills), then render it (`cratis-stage-rendering-and-sandbox`). Hand-write C# only for scope the renderer rejects, or for adapters, infrastructure and clients; the model stays the oracle for that code (`cratis-application-slice-conformance`). Never hand-edit rendered, managed output, and never change the model to match existing code.
|
|
15
|
-
2. **The repository is opted in, but the slice is not modeled** (
|
|
15
|
+
2. **The repository is opted in, but the slice is not modeled** (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts): model it first, then continue with route 1. Write code first only when the user chooses to, or the behavior cannot be expressed in `.play`; say then that the model lags the code.
|
|
16
16
|
3. **No accepted model covers this scope and the repository is not opted in:** stay code-first and never force a model. Only the entry-point session may propose one, at most once per session, never for trivial, bug-fix, infrastructure, client, framework or brownfield-maintenance work, and not again if declined. Framework, brownfield, infrastructure, client and adapter work keep their code-first path. For new behavior or unclear event vocabulary, run **cratis-chronicle-event-modeling** first; the agreed outline (fields, events, rules, scenarios) is the contract, recorded where the team tracks work, if anywhere.
|
|
17
17
|
|
|
18
18
|
Whether the Screenplay skills are installed is a separate question from consent: if the route needs them and they are missing, say so and ask; do not author `.play` from memory.
|
|
@@ -13,7 +13,7 @@ The slice file (`.cs`) **and its contract**: the `.play` slice with its specific
|
|
|
13
13
|
|
|
14
14
|
If no contract can be found, decide once:
|
|
15
15
|
|
|
16
|
-
- **An accepted model under the model root covers the scope, or the repository is opted in** (
|
|
16
|
+
- **An accepted model under the model root covers the scope, or the repository is opted in** (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts): do not write code-derived specs in its place. Route to the `cratis-screenplay-*` skills (`cratis-screenplay-specifications`, `cratis-screenplay-scenario-coverage`) to add the slice's specifications to the model first. If those skills are not installed, say so and stop; do not author `.play` from memory.
|
|
17
17
|
- **No model coverage and no opt-in:** stay code-first. Write from the code, report every case as a proposal rather than as agreed behavior. A model is proposed only by the entry-point session, at most once per session, and not for trivial, bug-fix, infrastructure, client, framework or brownfield-maintenance work.
|
|
18
18
|
|
|
19
19
|
## Coverage (every slice type)
|
|
@@ -68,7 +68,7 @@ Tagged **[contract]** (framework-enforced) or **[convention]** (house default).
|
|
|
68
68
|
|
|
69
69
|
- **Starting a brand-new application:** scaffold it instead of hand-writing the skeleton: `dotnet new install Cratis.Templates`, then `dotnet new cratis -n MyApp -o MyApp` (`--language Kotlin|Java`, `--Database MongoDB|PostgreSQL|MsSql|SQLite`; `cratis-aspire` for Aspire; `cratis-chronicle-console` or `cratis-chronicle-web` for a Chronicle client only). Non-interactive runs need `--allow-scripts yes`; the .NET templates target `net10.0`. The template writes `.cratis/ai.json`; run `cratis ai update` afterwards. Its `SomeModule/SomeFeature/Registration/` slice is the house shape. There is no Go, Python or Elixir template (verified at Cratis.Templates `v1.7.4`).
|
|
70
70
|
- **Phase 0 — Find the contract / choose the level.** Before writing slice code, find what the code must match, and choose the level once for the whole scope.
|
|
71
|
-
1. **Look for a Screenplay model** under the model root (
|
|
71
|
+
1. **Look for a Screenplay model** under the model root (opted in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, root and drafts) for the slice, command, event and read-model names.
|
|
72
72
|
2. **Model level** — an accepted model under the root covers the scope, or the repository is opted in and this scope has no model yet. The `.play` slice and its specs are the contract: change the model first (new behavior starts in discovery), verify it (V1–V3), get an independent review, then render with Stage or gap-fill by hand only what the renderer rejects. Hand-written code stays checked against the model (**cratis-application-slice-conformance**). Never edit Stage-managed output, never implement behavior the model does not state, never change the model to match existing code, never weaken protection to make it compile or render. Start with **cratis-screenplay-event-modeling** (decision rule), then **cratis-screenplay-modeling-lifecycle**. If the Screenplay skills are not installed, say so; do not author `.play` from memory.
|
|
73
73
|
3. **Code level** — infrastructure (hosting, DI composition, identity wiring, CI, deployment), clients, Screenplay code attachments and handlers, adapters in the render's customization area, and scope Stage cannot render yet (the model remains the contract). Framework repositories and brownfield work that is not opted in also stay code-first. Only the entry-point session may propose a model, at most once per session and never for trivial, bug-fix, infrastructure, client, framework or brownfield-maintenance work; if declined, do not ask again. Confirm Module/Feature, slice name, slice type and domain requirements as before; for new behavior or unclear event vocabulary run **cratis-chronicle-event-modeling** first, and record the agreed outline (fields, events, rules, scenarios) where the team tracks work, if anywhere. If you write code first where a model exists, say the model now lags.
|
|
74
74
|
4. **Trivial changes** keep the proportional-delegation policy; Phases 1–3 below apply to code you write at either level.
|
|
@@ -226,11 +226,7 @@ The MCP catalog has no install-hints field and does not install the executable.
|
|
|
226
226
|
|
|
227
227
|
### Event modeling with Screenplay
|
|
228
228
|
|
|
229
|
-
**Model first.**
|
|
230
|
-
`.play` files live: normally under `Source/` or `src/`, else `Screenplay/`) 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
|
|
231
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install output, an
|
|
232
|
-
installed profile or skill, a `.play` file outside the root or an untracked or uncommitted draft is not
|
|
233
|
-
opt-in. An accepted model under the root covering the scope is the contract and the source
|
|
229
|
+
**Model first.** Decide opt-in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts. An accepted model under the root covering the scope is the contract and the source
|
|
234
230
|
of truth for behavior. Change the model, verify and independently review it, then render
|
|
235
231
|
or gap-fill from its contract; never edit Stage-managed output or weaken protection.
|
|
236
232
|
Otherwise stay code-first; only the entry-point session may propose a model, at most once
|
|
@@ -9,7 +9,7 @@ profile: application
|
|
|
9
9
|
|
|
10
10
|
Reactors are the "if this then that" of event sourcing — they observe events and produce side effects. Unlike projections (which build state), reactors *do things*: send emails, trigger commands in other slices, call external APIs.
|
|
11
11
|
|
|
12
|
-
**Model first:** when an accepted model under the model root covers this scope (or the repository is opted in
|
|
12
|
+
**Model first:** when an accepted model under the model root covers this scope (or the repository is opted in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`), a reactor implements an automation that the model owns (`produces` / `invokes`); read the modeled slice first and keep the reactor to what the model leaves to code (gap-fill). Otherwise (not opted in) stay code-first: this file and the **cratis-chronicle-reactor** skill are the guide, and the entry-point session may propose a model at most once per session. See `cratis-screenplay-modeling-lifecycle`'s `scripts/model-first-status.mjs` for the decision, root and drafts.
|
|
13
13
|
|
|
14
14
|
## IReactor — Marker Interface
|
|
15
15
|
|
|
@@ -14,7 +14,7 @@ A vertical slice owns a single behavior: the command or query, the events it pro
|
|
|
14
14
|
|
|
15
15
|
This file is the reference for *what* goes in each part of a slice. Layout, slice types, workflow, and quality gates are in [general.md](./general.md).
|
|
16
16
|
|
|
17
|
-
**Model-first check.** Before changing a slice, look for it in the accepted `.play` model
|
|
17
|
+
**Model-first check.** Before changing a slice, look for it in the accepted `.play` model under the model root (opted in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, root and drafts). If an accepted model covers it, change the model and render or gap-fill from it; never edit Stage-managed files. See Phase 0 in [application-profile.md](./application-profile.md).
|
|
18
18
|
|
|
19
19
|
## Technical stack
|
|
20
20
|
|
|
@@ -183,10 +183,7 @@ them.
|
|
|
183
183
|
## Route near misses
|
|
184
184
|
|
|
185
185
|
- An accepted `.play` model under the model root covers the behavior, or the
|
|
186
|
-
repository is opted in (
|
|
187
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install
|
|
188
|
-
output, an uncommitted `.play` draft or a `.play` file outside the root does not count; master definition:
|
|
189
|
-
`cratis-screenplay-modeling-lifecycle`): change the model first with
|
|
186
|
+
repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`): change the model first with
|
|
190
187
|
`cratis-screenplay-event-modeling`. If the Screenplay skills are not installed,
|
|
191
188
|
say so and do not author `.play` from memory.
|
|
192
189
|
Edit code here only for infrastructure, clients, adapters, Screenplay code
|
|
@@ -52,17 +52,13 @@ This skill is a method: it names no API of its own. When the Screenplay skills a
|
|
|
52
52
|
Find the contract before touching code; say which one you are using. These steps are enough on
|
|
53
53
|
their own when the Screenplay skills are not installed; the master decision rule, when they
|
|
54
54
|
are, is `cratis-screenplay-modeling-lifecycle` ("Decide the level first").
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
Decide opt-in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts.
|
|
56
|
+
Staged or untracked `.play` files are drafts, not the contract; a `.play` outside the model root is not a contract.
|
|
57
|
+
For a committed model with working-tree edits, HEAD remains the contract until the change is committed.
|
|
58
|
+
1. An accepted `.play` model under the model root covers the slice (search
|
|
57
59
|
`**/*.play` for the slice, command, event and read-model names): the `.play` slice and its
|
|
58
|
-
specifications are the contract.
|
|
59
|
-
|
|
60
|
-
root are drafts, not contracts; a file outside the root is not a contract. A committed file
|
|
61
|
-
with uncommitted working-tree edits is a model change in progress: its HEAD version is the
|
|
62
|
-
contract until the change is committed.
|
|
63
|
-
2. The repository is opted in (the root holds a committed `.play` file, or the project
|
|
64
|
-
explicitly set that root, even if it is empty; an empty unconfigured directory, install
|
|
65
|
-
output, an installed skill or an uncommitted draft does not count) but this
|
|
60
|
+
specifications are the contract.
|
|
61
|
+
2. The repository is opted in but this
|
|
66
62
|
scope has no model yet: new behaviour starts in discovery and slice design
|
|
67
63
|
(`cratis-screenplay-discovery`, `cratis-screenplay-slice-design`); do not code first. If those
|
|
68
64
|
skills are not installed, say so and do not author `.play` from memory.
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
# Contract, precedence and conflicting evidence
|
|
2
2
|
|
|
3
3
|
## Which contract
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured), or the root holds a committed `.play`
|
|
8
|
-
file or was explicitly set in `.cratis/ai.json` (even if empty). Staged or untracked files under
|
|
9
|
-
the root are drafts. A committed file with uncommitted working-tree edits is a model change
|
|
10
|
-
in progress; its HEAD version is the contract until the change is committed. An empty directory, install
|
|
11
|
-
output, an uncommitted `.play` draft or a `.play` file outside the root does not count. Otherwise stay code-first.
|
|
4
|
+
Decide opt-in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts. SKILL.md step 1 suffices when the Screenplay skills are not installed.
|
|
5
|
+
Staged or untracked `.play` files are drafts, not the contract; a `.play` outside the model root is not a contract.
|
|
6
|
+
For a committed model with working-tree edits, HEAD remains the contract until the change is committed.
|
|
12
7
|
|
|
13
8
|
| Situation | Contract | Code's role |
|
|
14
9
|
| --- | --- | --- |
|
|
@@ -53,9 +53,7 @@ repository before claiming support for another version.
|
|
|
53
53
|
the contract for this skill). Decide this with the decision rule in
|
|
54
54
|
`cratis-screenplay-modeling-lifecycle`: model-first only when an accepted
|
|
55
55
|
model under the model root covers this scope, or the repository is opted in
|
|
56
|
-
(
|
|
57
|
-
in `.cratis/ai.json`); an empty directory, install output, a `.play` file
|
|
58
|
-
outside the root or an uncommitted draft does not count, and framework, infrastructure, client, adapter and not-opted-in
|
|
56
|
+
(opted in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`); framework, infrastructure, client, adapter and not-opted-in
|
|
59
57
|
brownfield work stays code-first. Opted in but no model for this scope: model
|
|
60
58
|
it first (`cratis-screenplay-discovery`, then `cratis-screenplay-slice-design`)
|
|
61
59
|
before writing specifications. If those Screenplay skills are not installed,
|
|
@@ -12,10 +12,7 @@ whatever `Handle()` returns into events, server-executed operations, a response,
|
|
|
12
12
|
or a combination.
|
|
13
13
|
|
|
14
14
|
- An accepted `.play` model under the model root covers the behavior, or the
|
|
15
|
-
repository is opted in (
|
|
16
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install
|
|
17
|
-
output, an uncommitted `.play` draft or a `.play` file outside the root does not count; master definition:
|
|
18
|
-
`cratis-screenplay-modeling-lifecycle`): change the model first with
|
|
15
|
+
repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`): change the model first with
|
|
19
16
|
`cratis-screenplay-event-modeling`. If the Screenplay skills are not installed,
|
|
20
17
|
say so and do not author `.play` from memory.
|
|
21
18
|
Edit code here only for infrastructure, clients, adapters, Screenplay code
|
|
@@ -234,10 +234,7 @@ Recovery can redeliver the trigger even with `[OnceOnly]`, and a command whose o
|
|
|
234
234
|
- Adding or changing a rule: the Arc command validation guidance.
|
|
235
235
|
- Designing what a reactor should observe: the Chronicle reactor guidance.
|
|
236
236
|
- An accepted `.play` model under the model root covers the behavior, or the
|
|
237
|
-
repository is opted in (
|
|
238
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install
|
|
239
|
-
output, an uncommitted `.play` draft or a `.play` file outside the root does not count; master definition:
|
|
240
|
-
`cratis-screenplay-modeling-lifecycle`): change the model first with
|
|
237
|
+
repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`): change the model first with
|
|
241
238
|
`cratis-screenplay-event-modeling`. If the Screenplay skills are not installed,
|
|
242
239
|
say so and do not author `.play` from memory.
|
|
243
240
|
Edit code here only for infrastructure, clients, adapters, Screenplay code
|
|
@@ -47,10 +47,7 @@ another version.
|
|
|
47
47
|
- Writing the specification for the rejection: use
|
|
48
48
|
`cratis-application-slice-specifications`.
|
|
49
49
|
- An accepted `.play` model under the model root covers the behavior, or the
|
|
50
|
-
repository is opted in (
|
|
51
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install
|
|
52
|
-
output, an uncommitted `.play` draft or a `.play` file outside the root does not count; master definition:
|
|
53
|
-
`cratis-screenplay-modeling-lifecycle`): change the model first with
|
|
50
|
+
repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`): change the model first with
|
|
54
51
|
`cratis-screenplay-event-modeling`. If the Screenplay skills are not installed,
|
|
55
52
|
say so and do not author `.play` from memory.
|
|
56
53
|
Edit code here only for infrastructure, clients, adapters, Screenplay code
|
|
@@ -204,10 +204,7 @@ apply. Do not construct or suggest credentials.
|
|
|
204
204
|
- Diagnosing a whole slice rather than one endpoint: the slice diagnostics
|
|
205
205
|
guidance.
|
|
206
206
|
- An accepted `.play` model under the model root covers the behavior, or the
|
|
207
|
-
repository is opted in (
|
|
208
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install
|
|
209
|
-
output, an uncommitted `.play` draft or a `.play` file outside the root does not count; master definition:
|
|
210
|
-
`cratis-screenplay-modeling-lifecycle`): change the model first with
|
|
207
|
+
repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`): change the model first with
|
|
211
208
|
`cratis-screenplay-event-modeling`. If the Screenplay skills are not installed,
|
|
212
209
|
say so and do not author `.play` from memory.
|
|
213
210
|
Edit code here only for infrastructure, clients, adapters, Screenplay code
|
|
@@ -10,10 +10,7 @@ Arc applies paging and sorting for you. You never write `Skip`/`Take` or read
|
|
|
10
10
|
the query string — you choose a **return shape** that the framework can narrow.
|
|
11
11
|
|
|
12
12
|
- An accepted `.play` model under the model root covers the behavior, or the
|
|
13
|
-
repository is opted in (
|
|
14
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install
|
|
15
|
-
output, an uncommitted `.play` draft or a `.play` file outside the root does not count; master definition:
|
|
16
|
-
`cratis-screenplay-modeling-lifecycle`): change the model first with
|
|
13
|
+
repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`): change the model first with
|
|
17
14
|
`cratis-screenplay-event-modeling`. If the Screenplay skills are not installed,
|
|
18
15
|
say so and do not author `.play` from memory.
|
|
19
16
|
Edit code here only for infrastructure, clients, adapters, Screenplay code
|
|
@@ -10,10 +10,7 @@ Build the page from the generated Arc proxies and the Cratis Components
|
|
|
10
10
|
wrappers. Do not hand-roll a table, a dialog, or a fetch.
|
|
11
11
|
|
|
12
12
|
- An accepted `.play` model under the model root covers the behavior, or the
|
|
13
|
-
repository is opted in (
|
|
14
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install
|
|
15
|
-
output, an uncommitted `.play` draft or a `.play` file outside the root does not count; master definition:
|
|
16
|
-
`cratis-screenplay-modeling-lifecycle`): change the model first with
|
|
13
|
+
repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`): change the model first with
|
|
17
14
|
`cratis-screenplay-event-modeling`. If the Screenplay skills are not installed,
|
|
18
15
|
say so and do not author `.play` from memory.
|
|
19
16
|
Read the model's `screen` and `form` with
|
|
@@ -51,10 +51,7 @@ memory.
|
|
|
51
51
|
- You are writing the specification and want the `EventScenario` mechanics in
|
|
52
52
|
depth: use `cratis-chronicle-event-specifications`.
|
|
53
53
|
- An accepted `.play` model under the model root covers the behavior, or the
|
|
54
|
-
repository is opted in (
|
|
55
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install
|
|
56
|
-
output, an uncommitted `.play` draft or a `.play` file outside the root does not count; master definition:
|
|
57
|
-
`cratis-screenplay-modeling-lifecycle`): change the model first with
|
|
54
|
+
repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`): change the model first with
|
|
58
55
|
`cratis-screenplay-event-modeling`. If the Screenplay skills are not installed,
|
|
59
56
|
say so and do not author `.play` from memory.
|
|
60
57
|
Edit code here only for infrastructure, clients, adapters, Screenplay code
|
|
@@ -7,13 +7,10 @@ license: MIT
|
|
|
7
7
|
# Chronicle event modeling
|
|
8
8
|
|
|
9
9
|
> **Model-first check.** If an accepted model under the model root covers this scope, or the
|
|
10
|
-
> repository is opted in (
|
|
11
|
-
> 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
|
|
12
|
-
> `.cratis/ai.json`), the model is the source of truth: use
|
|
10
|
+
> repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`), the model is the source of truth: use
|
|
13
11
|
> `cratis-screenplay-event-modeling` (and the lifecycle in
|
|
14
12
|
> `cratis-screenplay-modeling-lifecycle`, which holds the master definition)
|
|
15
|
-
> instead of this skill.
|
|
16
|
-
> outside the root or an untracked or uncommitted draft is not consent. This skill is for
|
|
13
|
+
> instead of this skill. This skill is for
|
|
17
14
|
> hand-written C# models where the repository has not opted in (never force a
|
|
18
15
|
> model; only the entry-point session proposes one, at most once per session), and for
|
|
19
16
|
> code-level work against an already accepted contract (stream identity,
|
|
@@ -19,10 +19,7 @@ events.
|
|
|
19
19
|
## Route near misses
|
|
20
20
|
|
|
21
21
|
- An accepted `.play` model under the model root covers the behavior, or the
|
|
22
|
-
repository is opted in (
|
|
23
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install
|
|
24
|
-
output, an uncommitted `.play` draft or a `.play` file outside the root does not count; master definition:
|
|
25
|
-
`cratis-screenplay-modeling-lifecycle`): change the model first with
|
|
22
|
+
repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`): change the model first with
|
|
26
23
|
`cratis-screenplay-event-modeling`. If the Screenplay skills are not installed,
|
|
27
24
|
say so and do not author `.play` from memory.
|
|
28
25
|
Edit code here only for infrastructure, clients, adapters, Screenplay code
|
|
@@ -277,10 +277,7 @@ projection spans streams.
|
|
|
277
277
|
## Route near misses
|
|
278
278
|
|
|
279
279
|
- An accepted `.play` model under the model root covers the behavior, or the
|
|
280
|
-
repository is opted in (
|
|
281
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install
|
|
282
|
-
output, an uncommitted `.play` draft or a `.play` file outside the root does not count; master definition:
|
|
283
|
-
`cratis-screenplay-modeling-lifecycle`): change the model first with
|
|
280
|
+
repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`): change the model first with
|
|
284
281
|
`cratis-screenplay-event-modeling`. If the Screenplay skills are not installed,
|
|
285
282
|
say so and do not author `.play` from memory.
|
|
286
283
|
Edit code here only for infrastructure, clients, adapters, Screenplay code
|
|
@@ -20,9 +20,7 @@ effects. If the answer is "populate a queryable model", it is not a reactor.
|
|
|
20
20
|
| both a model and an effect | one projection *and* one reactor |
|
|
21
21
|
|
|
22
22
|
> **Model first.** If an accepted model under the model root covers this scope, or
|
|
23
|
-
> the repository is opted in (
|
|
24
|
-
> 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
|
|
25
|
-
> `.cratis/ai.json`; master definition in `cratis-screenplay-modeling-lifecycle`), the automation is
|
|
23
|
+
> the repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`), the automation is
|
|
26
24
|
> a modeled slice: find it (`Automation` or `Translate`), treat its `produces` /
|
|
27
25
|
> `invokes`, conditions and fields as the contract, and write the reactor only as
|
|
28
26
|
> gap-fill for what the model leaves to code (Stage renders supported event-triggered Automation;
|
|
@@ -249,10 +249,7 @@ spans streams.
|
|
|
249
249
|
## Route near misses
|
|
250
250
|
|
|
251
251
|
- An accepted `.play` model under the model root covers the behavior, or the
|
|
252
|
-
repository is opted in (
|
|
253
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install
|
|
254
|
-
output, an uncommitted `.play` draft or a `.play` file outside the root does not count; master definition:
|
|
255
|
-
`cratis-screenplay-modeling-lifecycle`): change the model first with
|
|
252
|
+
repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`): change the model first with
|
|
256
253
|
`cratis-screenplay-event-modeling`. If the Screenplay skills are not installed,
|
|
257
254
|
say so and do not author `.play` from memory.
|
|
258
255
|
Edit code here only for infrastructure, clients, adapters, Screenplay code
|
|
@@ -49,9 +49,7 @@ version.
|
|
|
49
49
|
readmodel` rows are the contract). Decide this with the decision rule in
|
|
50
50
|
`cratis-screenplay-modeling-lifecycle`: model-first only when an accepted
|
|
51
51
|
model under the model root covers this scope, or the repository is opted in
|
|
52
|
-
(
|
|
53
|
-
in `.cratis/ai.json`); an empty directory, install output, a `.play` file
|
|
54
|
-
outside the root or an uncommitted draft does not count, and framework, infrastructure, client, adapter and not-opted-in
|
|
52
|
+
(opted in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`); framework, infrastructure, client, adapter and not-opted-in
|
|
55
53
|
brownfield work stays code-first. Opted in but no model for this scope: model
|
|
56
54
|
it first (`cratis-screenplay-discovery`, then `cratis-screenplay-slice-design`)
|
|
57
55
|
before writing specifications. If those Screenplay skills are not installed,
|
|
@@ -272,10 +272,7 @@ prove transport, replay, encryption, erasure or sink migration. Cover, at minimu
|
|
|
272
272
|
## Route near misses
|
|
273
273
|
|
|
274
274
|
- An accepted `.play` model under the model root covers the behavior, or the
|
|
275
|
-
repository is opted in (
|
|
276
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install
|
|
277
|
-
output, an uncommitted `.play` draft or a `.play` file outside the root does not count; master definition:
|
|
278
|
-
`cratis-screenplay-modeling-lifecycle`): change the model first with
|
|
275
|
+
repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`): change the model first with
|
|
279
276
|
`cratis-screenplay-event-modeling`. If the Screenplay skills are not installed,
|
|
280
277
|
say so and do not author `.play` from memory.
|
|
281
278
|
Edit code here only for infrastructure, clients, adapters, Screenplay code
|
|
@@ -207,10 +207,7 @@ validation failures), and guards against double submission.
|
|
|
207
207
|
## Route near misses
|
|
208
208
|
|
|
209
209
|
- An accepted `.play` model under the model root covers the behavior, or the
|
|
210
|
-
repository is opted in (
|
|
211
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install
|
|
212
|
-
output, an uncommitted `.play` draft or a `.play` file outside the root does not count; master definition:
|
|
213
|
-
`cratis-screenplay-modeling-lifecycle`): change the model first with
|
|
210
|
+
repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`): change the model first with
|
|
214
211
|
`cratis-screenplay-event-modeling`. If the Screenplay skills are not installed,
|
|
215
212
|
say so and do not author `.play` from memory.
|
|
216
213
|
Edit code here only for infrastructure, clients, adapters, Screenplay code
|
|
@@ -28,8 +28,7 @@ syntax and tool commands in `cratis-screenplay-toolchain`.
|
|
|
28
28
|
existing code or a database as the source (`cratis-screenplay-legacy-extraction`).
|
|
29
29
|
- Small change to an existing model (one or two events): enter at step 5.
|
|
30
30
|
- Model-first: work in `.play` where an accepted model under the model root covers the scope or
|
|
31
|
-
the repository is opted in (
|
|
32
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`). Otherwise stay code-first; only the
|
|
31
|
+
the repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`). Otherwise stay code-first; only the
|
|
33
32
|
entry-point session proposes a model, at most once per session; the master definition is in
|
|
34
33
|
`cratis-screenplay-modeling-lifecycle`. A direct request to model this scope is itself consent.
|
|
35
34
|
|
|
@@ -29,13 +29,7 @@ into the work that acts on them. Flag a real trade-off to the user instead of re
|
|
|
29
29
|
|
|
30
30
|
**1. Decide the level (short form; master copy in `cratis-screenplay-modeling-lifecycle`).**
|
|
31
31
|
Check first that the method skills are installed; installing them never opts a
|
|
32
|
-
repository in.
|
|
33
|
-
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
|
|
34
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`. An empty directory, install output,
|
|
35
|
-
an installed skill, a `.play` file outside the root or an untracked or uncommitted draft is not
|
|
36
|
-
opt-in; staged or untracked files under the root are drafts. A committed file with uncommitted
|
|
37
|
-
working-tree edits is a model change in progress; its HEAD version is the contract until the
|
|
38
|
-
change is committed. A behavior is a contract only when an accepted model under the root covers it.
|
|
32
|
+
repository in. Decide opt-in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts.
|
|
39
33
|
Otherwise stay code-first. Only the entry-point session proposes a model (at most once
|
|
40
34
|
per session, never for trivial, bug-fix, infrastructure, client, framework or
|
|
41
35
|
brownfield-maintenance work; unattended: record the recommendation in the final report).
|
|
@@ -18,16 +18,16 @@ an unproven pass.
|
|
|
18
18
|
|
|
19
19
|
## Decide the level first (master copy; run once per request, from any entry point)
|
|
20
20
|
|
|
21
|
-
1. **Opted in?**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
root counts). **Not opt-in:** an empty model folder or the MCP entry that `cratis ai
|
|
25
|
-
install`/`update` creates; an installed profile or skill; a `.play` file outside the root; a
|
|
26
|
-
staged or untracked `.play` file under the root (a draft). Committing a model under the root
|
|
27
|
-
is the team's act of acceptance and opts the repository in.
|
|
28
|
-
A committed file with uncommitted working-tree edits is a model change in progress: its HEAD version is the contract until the change is committed.
|
|
21
|
+
1. **Opted in?** A committed `.play` file under the model root or an explicitly configured
|
|
22
|
+
`mcpServers.screenplay.root` in `.cratis/ai.json` opts in (even an empty configured root).
|
|
23
|
+
The invariant is in `general.md` ("Model first").
|
|
29
24
|
A behavior is a **contract** only when an accepted (committed) model under the root covers it.
|
|
30
|
-
A direct user request to model a scope is consent for that scope.
|
|
25
|
+
A direct user request to model a scope is consent for that scope. Run `scripts/model-first-status.mjs` from the repository with Node.js and Git:
|
|
26
|
+
`node <skill-directory>/scripts/model-first-status.mjs [--root <repository-relative-dir>] [--json]`.
|
|
27
|
+
Read-only roots: `--root`, configuration, then discovery from HEAD project paths (drafts only if none). Discovery prefers legacy `.cratis/screenplay/`, else the common folder, else `Source/`, `src/`, `Screenplay/`. It excludes hidden/build/docs/samples/examples/scratch/test fixtures from discovery and acceptance, including at `.`; explicit roots include everything beneath them.
|
|
28
|
+
Output: root, reason, file counts, drafts and model changes. Exits: **0 opted in**, **1 not opted in**, **2 could not run** (Git/configuration/arguments). Treat 2 as blocked, not code-first.
|
|
29
|
+
Run `scripts/model-first-status.mjs --self-test` to plant and check verdict fixtures; it executes `scripts/model-first-self-test.mjs` and prints the checked count on success.
|
|
30
|
+
Read `references/opt-in.md` when checking the project configuration mechanism.
|
|
31
31
|
2. **Not opted in:** continue code-first; never force a model (framework, brownfield,
|
|
32
32
|
infrastructure, client and adapter work stays code-first). Only the entry-point agent or session
|
|
33
33
|
may **propose a model**: at most once per session, never for trivial, bug-fix, infrastructure,
|
|
@@ -23,40 +23,10 @@ project-owned `mcpServers` property in `.cratis/ai.json` overrides the model dir
|
|
|
23
23
|
disables registration"; `AiConfiguration.McpServers`, read by `AiMcpDescriptor.Root`). Verify with
|
|
24
24
|
`Source/Cli/Commands/Ai/AiMcpDescriptor.cs` in the CLI repository.
|
|
25
25
|
|
|
26
|
-
## Model root and
|
|
27
|
-
|
|
28
|
-
model, use `Source/` or `src/`, else `Screenplay/` at the repository root, never
|
|
29
|
-
under `.cratis/`. An explicitly configured `mcpServers.screenplay.root` selects
|
|
30
|
-
the root. A committed `.play` there is rule (a)'s opt-in signal without requiring
|
|
31
|
-
the setting; setting a root is independently rule (b), even when empty. The legacy
|
|
32
|
-
CLI discovery behavior above is historical evidence, not a default corpus root.
|
|
33
|
-
Do not count unrelated documentation, samples or scratch files as the project model.
|
|
34
|
-
|
|
35
|
-
## Edge cases
|
|
36
|
-
- `.play` files only under `.ai-work/`, a docs folder or a sample: not under the root, so not opt-in.
|
|
37
|
-
- Acceptance is visible in the repository: the model root holds at least one `.play` file in
|
|
38
|
-
the committed tree (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured). Committing a model
|
|
39
|
-
under the root is the team's act of acceptance and opts the repository in. P6 commits the
|
|
40
|
-
accepted `.play` files and `.screenplay/identities.json` when present.
|
|
41
|
-
- Staged or untracked files under the root are drafts: they do not opt the repository in and
|
|
42
|
-
are not a contract for code agents. The modeler writes drafts into the root as before; they
|
|
43
|
-
stay drafts until committed. A local STATE.md alone proves nothing to another clone.
|
|
44
|
-
- A committed file with uncommitted working-tree edits is a model change in progress. Its HEAD
|
|
45
|
-
version is the contract until the change is committed; `git diff --quiet HEAD -- <file>`
|
|
46
|
-
detects whether the working copy differs.
|
|
47
|
-
- An explicitly configured root (`mcpServers.screenplay.root`) that is empty still counts as
|
|
48
|
-
opted in; rule (b) is independent of rule (a).
|
|
26
|
+
## Model root and edge cases
|
|
27
|
+
Run `cratis-screenplay-modeling-lifecycle`'s `scripts/model-first-status.mjs` for root resolution, the opt-in verdict, drafts and model changes in progress.
|
|
49
28
|
- Declined proposals: a team that wants a lasting "no model" answer writes it in its own
|
|
50
29
|
repository instructions, never in managed corpus files.
|
|
51
30
|
|
|
52
31
|
## Acceptance test cases
|
|
53
|
-
|
|
54
|
-
except in the last row. A committed model is a contract only for the slice it covers.
|
|
55
|
-
|
|
56
|
-
| Case under the model root | Opted in? | Contract for code agents |
|
|
57
|
-
|---|---|---|
|
|
58
|
-
| Untracked `.play` file | No | None; draft |
|
|
59
|
-
| Staged-only `.play` file, absent from HEAD | No | None; draft |
|
|
60
|
-
| Committed `.play` file | Yes | Its HEAD version |
|
|
61
|
-
| Committed `.play` file with working-tree edits | Yes | Its HEAD version; edits are a model change in progress until committed |
|
|
62
|
-
| Explicitly configured empty root | Yes | None yet; model the slice first |
|
|
32
|
+
Run `scripts/model-first-status.mjs --self-test` for the executable verdict fixtures.
|
|
@@ -111,11 +111,7 @@ phase, a decision important enough that a later reader could misread the model (
|
|
|
111
111
|
- **Carry-forward**: the accepted **source identity** (`verdicts-and-modes.md`).
|
|
112
112
|
- **Commit at P6**: the accepted `.play` files and `.screenplay/identities.json` when present.
|
|
113
113
|
The user commits, or explicitly authorizes the owning session to commit; the modeler never
|
|
114
|
-
commits on its own.
|
|
115
|
-
and opts the repository in (`git ls-tree -r --name-only HEAD -- <root>` lists the `.play`
|
|
116
|
-
file). Staged or untracked files under the root are drafts, not contracts for code agents.
|
|
117
|
-
A committed file with working-tree edits is a model change in progress; its HEAD version is
|
|
118
|
-
the contract until the change is committed.
|
|
114
|
+
commits on its own. Run `cratis-screenplay-modeling-lifecycle`'s `scripts/model-first-status.mjs` to check acceptance, drafts and model changes in progress.
|
|
119
115
|
- **Gate**: explicit acceptance and the model commit before P7-P9. After committing, recompute
|
|
120
116
|
the source identity. Its digest must equal the digest reviewed at P5; only the commit part may
|
|
121
117
|
differ. If the digest differs, return to P4/P5 for the changed scope. Record the post-commit
|
package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/scripts/model-first-self-test.mjs
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
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 assert from 'node:assert/strict';
|
|
5
|
+
import { spawnSync } from 'node:child_process';
|
|
6
|
+
import { mkdirSync, mkdtempSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';
|
|
7
|
+
import { tmpdir } from 'node:os';
|
|
8
|
+
import { dirname, join, resolve } from 'node:path';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
export function selfTest(modelFirstStatus) {
|
|
11
|
+
const temporary = mkdtempSync(join(tmpdir(), 'model-first-self-test-'));
|
|
12
|
+
let cases = 0;
|
|
13
|
+
const write = (path, content) => {
|
|
14
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
15
|
+
writeFileSync(path, content);
|
|
16
|
+
};
|
|
17
|
+
const git = (repository, args) => {
|
|
18
|
+
const result = spawnSync('git', ['-c', 'user.name=Model first self-test', '-c', 'user.email=specs@example.invalid',
|
|
19
|
+
'-c', 'commit.gpgsign=false', '-c', 'core.hooksPath=/dev/null', ...args], { cwd: repository, encoding: 'utf8', timeout: 10000 });
|
|
20
|
+
assert.equal(result.status, 0, result.stderr || result.error?.message);
|
|
21
|
+
};
|
|
22
|
+
const repo = name => {
|
|
23
|
+
const repository = join(temporary, name);
|
|
24
|
+
mkdirSync(repository);
|
|
25
|
+
git(repository, ['init', '--quiet']);
|
|
26
|
+
return repository;
|
|
27
|
+
};
|
|
28
|
+
const check = (repository, expected, root) => {
|
|
29
|
+
const report = modelFirstStatus(repository, root);
|
|
30
|
+
assert.equal(report.optedIn, expected);
|
|
31
|
+
cases++;
|
|
32
|
+
return report;
|
|
33
|
+
};
|
|
34
|
+
try {
|
|
35
|
+
const drafts = repo('drafts');
|
|
36
|
+
check(drafts, false);
|
|
37
|
+
write(join(drafts, 'Screenplay/model.play'), 'module Test\n');
|
|
38
|
+
assert.equal(check(drafts, false).drafts.untracked.length, 1);
|
|
39
|
+
git(drafts, ['add', 'Screenplay/model.play']);
|
|
40
|
+
assert.equal(check(drafts, false).drafts.staged.length, 1);
|
|
41
|
+
git(drafts, ['commit', '--quiet', '-m', 'Accept model']);
|
|
42
|
+
assert.equal(check(drafts, true).contract, 'HEAD');
|
|
43
|
+
write(join(drafts, 'Screenplay/model.play'), 'module Changed\n');
|
|
44
|
+
assert.equal(check(drafts, true).modelChangesInProgress.length, 1);
|
|
45
|
+
const configured = repo('configured');
|
|
46
|
+
write(join(configured, '.cratis/ai.json'), JSON.stringify({ mcpServers: { screenplay: { root: 'Models' } } }));
|
|
47
|
+
check(configured, true, 'Models');
|
|
48
|
+
write(join(configured, 'Models/model.play'), 'module Test\n');
|
|
49
|
+
assert.equal(check(configured, true, 'Models').committed.length, 0);
|
|
50
|
+
const outside = repo('outside');
|
|
51
|
+
write(join(outside, 'docs/example.play'), 'module Example\n');
|
|
52
|
+
git(outside, ['add', '.']);
|
|
53
|
+
git(outside, ['commit', '--quiet', '-m', 'Add example']);
|
|
54
|
+
check(outside, false);
|
|
55
|
+
assert.throws(() => modelFirstStatus(temporary), /git rev-parse/);
|
|
56
|
+
cases++;
|
|
57
|
+
write(join(configured, '.cratis/ai.json'), '{');
|
|
58
|
+
assert.throws(() => modelFirstStatus(configured));
|
|
59
|
+
cases++;
|
|
60
|
+
for (const [name, path] of [
|
|
61
|
+
['fixture', 'Source/X.Specs/Projections/for_model/Cases/fixture.play'],
|
|
62
|
+
['example', 'Source/examples/example.play'],
|
|
63
|
+
['docs', 'src/docs/example.play'],
|
|
64
|
+
]) {
|
|
65
|
+
const repository = repo(name);
|
|
66
|
+
write(join(repository, path), 'module Example\n');
|
|
67
|
+
git(repository, ['add', '.']);
|
|
68
|
+
git(repository, ['commit', '--quiet', '-m', 'Add non-project model']);
|
|
69
|
+
assert.equal(check(repository, false, undefined).modelFilesExamined, 0);
|
|
70
|
+
}
|
|
71
|
+
const project = repo('project');
|
|
72
|
+
write(join(project, 'Source/model.play'), 'module Test\n');
|
|
73
|
+
git(project, ['add', '.']);
|
|
74
|
+
git(project, ['commit', '--quiet', '-m', 'Accept project model']);
|
|
75
|
+
assert.equal(check(project, true, undefined).modelRoot, 'Source');
|
|
76
|
+
write(join(project, '.cratis/screenplay/draft.play'), 'module Draft\n');
|
|
77
|
+
assert.equal(check(project, true, undefined).modelRoot, 'Source');
|
|
78
|
+
git(project, ['add', '.cratis/screenplay/draft.play']);
|
|
79
|
+
assert.equal(check(project, true, undefined).modelRoot, 'Source');
|
|
80
|
+
const broad = repo('broad');
|
|
81
|
+
for (const path of ['Source/model.play', 'Other/model.play', 'Source/samples/example.play']) {
|
|
82
|
+
write(join(broad, path), 'module Test\n');
|
|
83
|
+
}
|
|
84
|
+
git(broad, ['add', '.']);
|
|
85
|
+
git(broad, ['commit', '--quiet', '-m', 'Add project and sample models']);
|
|
86
|
+
const broadReport = check(broad, true, undefined);
|
|
87
|
+
assert.equal(broadReport.modelRoot, '.');
|
|
88
|
+
assert.equal(broadReport.committed.length, 2);
|
|
89
|
+
write(join(broad, '.cratis/ai.json'), JSON.stringify({ mcpServers: { screenplay: { root: '.' } } }));
|
|
90
|
+
assert.equal(check(broad, true, undefined).committed.length, 3);
|
|
91
|
+
const aliasRepository = repo('alias');
|
|
92
|
+
const alias = join(aliasRepository, 'skills');
|
|
93
|
+
symlinkSync(resolve(dirname(fileURLToPath(import.meta.url)), '../..'), alias, 'dir');
|
|
94
|
+
const result = spawnSync(process.execPath, [join(alias, 'cratis-screenplay-modeling-lifecycle/scripts/model-first-status.mjs'), '--json'], {
|
|
95
|
+
cwd: aliasRepository, encoding: 'utf8', timeout: 20000,
|
|
96
|
+
});
|
|
97
|
+
assert.equal(result.status, 1, result.stderr);
|
|
98
|
+
assert.equal(JSON.parse(result.stdout).optedIn, false);
|
|
99
|
+
cases++;
|
|
100
|
+
console.log(`model-first-status self-test: checked ${cases} fixtures/verdicts; passed`);
|
|
101
|
+
} finally {
|
|
102
|
+
rmSync(temporary, { recursive: true, force: true });
|
|
103
|
+
}
|
|
104
|
+
}
|
package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/scripts/model-first-status.mjs
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
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 { spawnSync } from 'node:child_process';
|
|
5
|
+
import { readFileSync, realpathSync, statSync } from 'node:fs';
|
|
6
|
+
import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
|
|
9
|
+
function git(repository, args, allowed = [0]) {
|
|
10
|
+
const result = spawnSync('git', args, { cwd: repository, encoding: 'utf8', timeout: 10000, maxBuffer: 16 * 1024 * 1024 });
|
|
11
|
+
if (result.error || !allowed.includes(result.status)) {
|
|
12
|
+
throw new Error(`git ${args[0]}: ${result.error?.message ?? result.stderr.trim() ?? result.status}`);
|
|
13
|
+
}
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const names = result => result.stdout.split('\0').filter(Boolean);
|
|
18
|
+
const play = path => path.toLowerCase().endsWith('.play');
|
|
19
|
+
const under = (path, root) => root === '.' || path.startsWith(`${root}/`);
|
|
20
|
+
const ignored = /(^|\/)(\.[^/]+|node_modules|bin|obj|build|artifacts|dist|out|packages|documentation|docs|samples?|examples?|scratch|[^/]+\.(?:Specs|Tests)|Specs|Tests|for_[^/]+|fixtures|Cases|test[-_]?assets)(\/|$)/i;
|
|
21
|
+
// The legacy model location is a project root, not arbitrary hidden-folder content.
|
|
22
|
+
const projectModel = path => !ignored.test(path.startsWith('.cratis/screenplay/') ? path.slice('.cratis/screenplay/'.length) : path);
|
|
23
|
+
|
|
24
|
+
function configuredRoot(repository) {
|
|
25
|
+
let text;
|
|
26
|
+
try {
|
|
27
|
+
text = readFileSync(join(repository, '.cratis/ai.json'), 'utf8');
|
|
28
|
+
} catch (error) {
|
|
29
|
+
if (error.code === 'ENOENT') return undefined;
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
const config = JSON.parse(text);
|
|
33
|
+
if (!config || typeof config !== 'object' || Array.isArray(config)) throw new Error('.cratis/ai.json must be an object');
|
|
34
|
+
const root = config.mcpServers?.screenplay?.root;
|
|
35
|
+
if (root === undefined || root === null) return undefined;
|
|
36
|
+
if (typeof root !== 'string' || !root.trim()) throw new Error('mcpServers.screenplay.root must be a nonempty directory path');
|
|
37
|
+
return root;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function normalizeRoot(repository, root) {
|
|
41
|
+
if (typeof root !== 'string' || !root.trim()) throw new Error('--root requires a nonempty directory path');
|
|
42
|
+
if (isAbsolute(root)) throw new Error('Model root must be repository-relative');
|
|
43
|
+
const path = relative(repository, resolve(repository, root)).replaceAll('\\', '/');
|
|
44
|
+
if (path === '..' || path.startsWith('../')) throw new Error('Model root must stay inside the repository');
|
|
45
|
+
try {
|
|
46
|
+
if (!statSync(join(repository, path)).isDirectory()) throw new Error(`Model root is not a directory: ${root}`);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (error.code !== 'ENOENT') throw error;
|
|
49
|
+
}
|
|
50
|
+
return path || '.';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function locateRoot(repository, paths) {
|
|
54
|
+
if (paths.some(path => path.startsWith('.cratis/screenplay/'))) return '.cratis/screenplay';
|
|
55
|
+
const directories = paths.map(path => dirname(path));
|
|
56
|
+
if (directories.length) {
|
|
57
|
+
let common = directories[0].split('/');
|
|
58
|
+
for (const directory of directories.slice(1)) {
|
|
59
|
+
const parts = directory.split('/');
|
|
60
|
+
const mismatch = common.findIndex((part, index) => part !== parts[index]);
|
|
61
|
+
if (mismatch >= 0) common = common.slice(0, mismatch);
|
|
62
|
+
}
|
|
63
|
+
return common.join('/') || '.';
|
|
64
|
+
}
|
|
65
|
+
for (const folder of ['Source', 'src']) {
|
|
66
|
+
try {
|
|
67
|
+
if (statSync(join(repository, folder)).isDirectory()) return folder;
|
|
68
|
+
} catch (error) {
|
|
69
|
+
if (error.code !== 'ENOENT') throw error;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return 'Screenplay';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Inspect HEAD and drafts without writing, staging or accepting a model. */
|
|
76
|
+
export function modelFirstStatus(cwd = process.cwd(), rootOverride) {
|
|
77
|
+
const repository = git(cwd, ['rev-parse', '--show-toplevel']).stdout.trim();
|
|
78
|
+
const configured = configuredRoot(repository);
|
|
79
|
+
const head = git(repository, ['rev-parse', '--verify', '--quiet', 'HEAD'], [0, 1]);
|
|
80
|
+
const committed = head.status === 0
|
|
81
|
+
? names(git(repository, ['ls-tree', '-r', '--name-only', '-z', 'HEAD'])).filter(play) : [];
|
|
82
|
+
const indexed = names(git(repository, ['ls-files', '-z', '--cached'])).filter(play);
|
|
83
|
+
const untracked = names(git(repository, ['ls-files', '-z', '--others', '--exclude-standard'])).filter(play);
|
|
84
|
+
const paths = [...new Set([...committed, ...indexed, ...untracked])].sort();
|
|
85
|
+
const projectCommitted = committed.filter(projectModel);
|
|
86
|
+
const discoveryPaths = projectCommitted.length ? projectCommitted : paths.filter(projectModel);
|
|
87
|
+
const root = normalizeRoot(repository, rootOverride ?? configured ?? locateRoot(repository, discoveryPaths));
|
|
88
|
+
const inModel = path => under(path, root) && (rootOverride !== undefined || configured !== undefined || projectModel(path));
|
|
89
|
+
const accepted = committed.filter(inModel).sort();
|
|
90
|
+
const staged = indexed.filter(path => inModel(path) && !committed.includes(path)).sort();
|
|
91
|
+
const drafts = { untracked: untracked.filter(inModel).sort(), staged };
|
|
92
|
+
const modified = head.status === 0
|
|
93
|
+
? names(git(repository, ['diff', '--name-only', '-z', 'HEAD', '--'])).filter(path => accepted.includes(path)).sort() : [];
|
|
94
|
+
const optedIn = configured !== undefined || accepted.length > 0;
|
|
95
|
+
return {
|
|
96
|
+
optedIn,
|
|
97
|
+
reason: configured !== undefined ? 'configured-root' : accepted.length ? 'committed-model' : 'no-accepted-model',
|
|
98
|
+
repository, modelRoot: root,
|
|
99
|
+
rootSource: rootOverride !== undefined ? 'argument' : configured !== undefined ? 'configuration' : 'discovery',
|
|
100
|
+
filesExamined: paths.length, modelFilesExamined: paths.filter(inModel).length,
|
|
101
|
+
committed: accepted, drafts, modelChangesInProgress: modified,
|
|
102
|
+
contract: accepted.length ? 'HEAD' : null,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function argumentsFor(args) {
|
|
107
|
+
const options = {};
|
|
108
|
+
for (let index = 0; index < args.length; index++) {
|
|
109
|
+
if (args[index] === '--json') options.json = true;
|
|
110
|
+
else if (args[index] === '--self-test') options.selfTest = true;
|
|
111
|
+
else if (args[index] === '--root' && args[index + 1] && !args[index + 1].startsWith('--')) options.root = args[++index];
|
|
112
|
+
else throw new Error('Usage: node model-first-status.mjs [--root <dir>] [--json] | --self-test');
|
|
113
|
+
}
|
|
114
|
+
return options;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async function main() {
|
|
118
|
+
let options;
|
|
119
|
+
try {
|
|
120
|
+
options = argumentsFor(process.argv.slice(2));
|
|
121
|
+
if (options.selfTest) {
|
|
122
|
+
const { selfTest } = await import('./model-first-self-test.mjs');
|
|
123
|
+
selfTest(modelFirstStatus);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const report = modelFirstStatus(process.cwd(), options.root);
|
|
127
|
+
console.log(options.json ? JSON.stringify(report) : [
|
|
128
|
+
`Model first: ${report.optedIn ? 'opted in' : 'not opted in'} (${report.reason}); root=${report.modelRoot}`,
|
|
129
|
+
`Examined ${report.filesExamined} .play files; ${report.modelFilesExamined} under the root; ${report.committed.length} committed`,
|
|
130
|
+
`Drafts: ${report.drafts.untracked.length} untracked, ${report.drafts.staged.length} staged; ${report.modelChangesInProgress.length} model changes in progress; contract=${report.contract ?? 'none'}`,
|
|
131
|
+
].join('\n'));
|
|
132
|
+
process.exitCode = report.optedIn ? 0 : 1;
|
|
133
|
+
} catch (error) {
|
|
134
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
135
|
+
if (options?.json || process.argv.includes('--json')) console.log(JSON.stringify({ error: message }));
|
|
136
|
+
console.error(`model-first-status: could not run: ${message}`);
|
|
137
|
+
process.exitCode = 2;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (process.argv[1] && realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url))) await main();
|
|
@@ -17,7 +17,7 @@ skill answers "does it compile, bind, render, and which compiler said so". The m
|
|
|
17
17
|
|
|
18
18
|
## Locate the model
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
Decide opt-in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` to locate the model root. A folder of `.play`
|
|
21
21
|
files is one application: always check the folder, never one file of it.
|
|
22
22
|
|
|
23
23
|
## Tool versions and the contract
|
|
@@ -61,9 +61,7 @@ the documentation it produces.
|
|
|
61
61
|
model). Decide this with the decision rule in
|
|
62
62
|
`cratis-screenplay-modeling-lifecycle`: model-first only when an accepted
|
|
63
63
|
model under the model root covers this scope, or the repository is opted in
|
|
64
|
-
(
|
|
65
|
-
in `.cratis/ai.json`); an empty directory, install output, a `.play` file
|
|
66
|
-
outside the root or an uncommitted draft does not count, and framework, infrastructure, client, adapter and not-opted-in
|
|
64
|
+
(opted in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`); framework, infrastructure, client, adapter and not-opted-in
|
|
67
65
|
brownfield work stays code-first. Opted in but no model for this scope: model
|
|
68
66
|
it first (`cratis-screenplay-discovery`, then `cratis-screenplay-slice-design`)
|
|
69
67
|
before writing specifications. If those Screenplay skills are not installed,
|
|
@@ -54,10 +54,7 @@ another version. Never translate an assertion or helper name from memory.
|
|
|
54
54
|
plain `Specification` base in this file and do not reach for the scenario
|
|
55
55
|
family except to test the very engine that repository provides.
|
|
56
56
|
- An accepted `.play` model under the model root covers the behavior, or the
|
|
57
|
-
repository is opted in (
|
|
58
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install
|
|
59
|
-
output, an uncommitted `.play` draft or a `.play` file outside the root does not count; master definition:
|
|
60
|
-
`cratis-screenplay-modeling-lifecycle`): change the model first with
|
|
57
|
+
repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`): change the model first with
|
|
61
58
|
`cratis-screenplay-event-modeling`. If the Screenplay skills are not installed,
|
|
62
59
|
say so and do not author `.play` from memory.
|
|
63
60
|
Edit code here only for infrastructure, clients, adapters, Screenplay code
|