@cratis/pi 7.53.1 → 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.
Files changed (54) hide show
  1. package/package/corpus/agents/backend-developer.md +1 -1
  2. package/package/corpus/agents/code-reviewer.md +1 -1
  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 +1 -1
  7. package/package/corpus/agents/screenplay-modeler.md +1 -1
  8. package/package/corpus/agents/slice-implementer.md +2 -2
  9. package/package/corpus/agents/spec-writer.md +1 -1
  10. package/package/corpus/harnesses/copilot/instructions/application-profile.instructions.md +1 -1
  11. package/package/corpus/harnesses/copilot/instructions/glossary.instructions.md +2 -0
  12. package/package/corpus/harnesses/copilot/instructions/profiles.instructions.md +1 -5
  13. package/package/corpus/harnesses/copilot/instructions/reactors.instructions.md +3 -2
  14. package/package/corpus/harnesses/copilot/instructions/vertical-slices.instructions.md +14 -1
  15. package/package/corpus/prompts/add-reactor.prompt.md +1 -1
  16. package/package/corpus/prompts/new-vertical-slice.prompt.md +1 -1
  17. package/package/corpus/prompts/write-specs.prompt.md +1 -1
  18. package/package/corpus/rules/application-profile.md +1 -1
  19. package/package/corpus/rules/glossary.md +2 -0
  20. package/package/corpus/rules/profiles.md +1 -5
  21. package/package/corpus/rules/reactors.md +3 -2
  22. package/package/corpus/rules/vertical-slices.md +14 -1
  23. package/package/corpus/skills/cratis-application-react-specifications/SKILL.md +1 -4
  24. package/package/corpus/skills/cratis-application-slice-conformance/SKILL.md +6 -10
  25. package/package/corpus/skills/cratis-application-slice-conformance/references/contract-and-precedence.md +3 -8
  26. package/package/corpus/skills/cratis-application-slice-specifications/SKILL.md +1 -3
  27. package/package/corpus/skills/cratis-arc-command/SKILL.md +1 -4
  28. package/package/corpus/skills/cratis-arc-command-execution/SKILL.md +1 -4
  29. package/package/corpus/skills/cratis-arc-command-validation/SKILL.md +1 -4
  30. package/package/corpus/skills/cratis-arc-observable-query-http/SKILL.md +1 -4
  31. package/package/corpus/skills/cratis-arc-query-paging/SKILL.md +1 -4
  32. package/package/corpus/skills/cratis-arc-react-page/SKILL.md +1 -4
  33. package/package/corpus/skills/cratis-chronicle-event-constraints/SKILL.md +1 -4
  34. package/package/corpus/skills/cratis-chronicle-event-modeling/SKILL.md +16 -5
  35. package/package/corpus/skills/cratis-chronicle-event-modeling/references/event-log-cleanup-rollout.md +53 -0
  36. package/package/corpus/skills/cratis-chronicle-event-modeling/references/event-log-hygiene.md +92 -0
  37. package/package/corpus/skills/cratis-chronicle-event-type-migration/SKILL.md +1 -4
  38. package/package/corpus/skills/cratis-chronicle-projection/SKILL.md +7 -4
  39. package/package/corpus/skills/cratis-chronicle-reactor/SKILL.md +9 -3
  40. package/package/corpus/skills/cratis-chronicle-read-model/SKILL.md +1 -4
  41. package/package/corpus/skills/cratis-chronicle-read-model-specifications/SKILL.md +1 -3
  42. package/package/corpus/skills/cratis-chronicle-reducer/SKILL.md +1 -4
  43. package/package/corpus/skills/cratis-components-stepper-command-dialog/SKILL.md +1 -4
  44. package/package/corpus/skills/cratis-screenplay-discovery/SKILL.md +1 -2
  45. package/package/corpus/skills/cratis-screenplay-event-modeling/SKILL.md +1 -7
  46. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/SKILL.md +9 -9
  47. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/opt-in.md +3 -33
  48. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/phases.md +1 -5
  49. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/scripts/model-first-self-test.mjs +104 -0
  50. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/scripts/model-first-status.mjs +141 -0
  51. package/package/corpus/skills/cratis-screenplay-toolchain/SKILL.md +1 -1
  52. package/package/corpus/skills/cratis-specification-by-example/SKILL.md +1 -3
  53. package/package/corpus/skills/cratis-specifications-csharp/SKILL.md +1 -4
  54. package/package.json +1 -1
@@ -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
- Look first in the model root: the folder holding the project's `.play` files (else `Source/` or `src/`, else `Screenplay/`), or the root the project set with `mcpServers.screenplay.root` in `.cratis/ai.json`. A folder of `.play`
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
- (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 set `mcpServers.screenplay.root`
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 (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 set
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/pi",
3
- "version": "7.53.1",
3
+ "version": "7.55.0",
4
4
  "description": "Configuration-aware Cratis AI integration for Pi",
5
5
  "type": "module",
6
6
  "files": [