@mrciphersmith/keryx 0.4.28 → 0.4.30

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 (132) hide show
  1. package/dist/cli.js +4916 -3655
  2. package/dist/core.js +91 -28
  3. package/dist/keryx-general-worker-entry.js +413 -240
  4. package/package.json +1 -1
  5. package/src/gdskills/bundled/install-manifest.json +3 -0
  6. package/src/gdskills/bundled/rules/core/api-contracts.mdc +21 -136
  7. package/src/gdskills/bundled/rules/core/async-patterns.mdc +18 -171
  8. package/src/gdskills/bundled/rules/core/clean-architecture.mdc +40 -150
  9. package/src/gdskills/bundled/rules/core/cli-interface-design.mdc +63 -194
  10. package/src/gdskills/bundled/rules/core/code-style-patterns.mdc +36 -48
  11. package/src/gdskills/bundled/rules/core/concurrency-patterns.mdc +32 -0
  12. package/src/gdskills/bundled/rules/core/database-patterns.mdc +26 -148
  13. package/src/gdskills/bundled/rules/core/error-handling.mdc +57 -109
  14. package/src/gdskills/bundled/rules/core/frontend-assistant.mdc +14 -29
  15. package/src/gdskills/bundled/rules/core/layout-rendering.mdc +51 -0
  16. package/src/gdskills/bundled/rules/core/mobx-store-template.mdc +69 -511
  17. package/src/gdskills/bundled/rules/core/nestjs-dto.mdc +18 -36
  18. package/src/gdskills/bundled/rules/core/playwright-testing.mdc +35 -308
  19. package/src/gdskills/bundled/rules/core/security-baseline.mdc +18 -140
  20. package/src/gdskills/bundled/rules/core/skill-authoring.mdc +190 -0
  21. package/src/gdskills/bundled/rules/core/skills-storage-workflow.mdc +5 -0
  22. package/src/gdskills/bundled/rules/core/solid-principles.mdc +70 -121
  23. package/src/gdskills/bundled/rules/core/storybook-guidelines.mdc +20 -22
  24. package/src/gdskills/bundled/rules/core/tdd-workflow.mdc +37 -74
  25. package/src/gdskills/bundled/rules/core/ui-anti-slop.mdc +48 -37
  26. package/src/gdskills/bundled/skills/orchestration/task-implementer/SKILL.md +2 -2
  27. package/src/gdskills/bundled/skills/quality/deprecation-path/SKILL.md +1 -1
  28. package/src/gdskills/bundled/skills/quality/tests-creator/SKILL.md +1 -1
  29. package/src/gdskills/bundled/skills/review/review-architecture/SKILL.md +25 -61
  30. package/src/gdskills/bundled/skills/review/review-backend/SKILL.md +15 -69
  31. package/src/gdskills/bundled/skills/review/review-clean-code/SKILL.md +84 -418
  32. package/src/gdskills/bundled/skills/review/review-core-boundaries/SKILL.md +2 -2
  33. package/src/gdskills/bundled/skills/review/review-degradation/SKILL.md +1 -1
  34. package/src/gdskills/bundled/skills/review/review-flow-graph/SKILL.md +1 -1
  35. package/src/gdskills/bundled/skills/review/review-frontend/SKILL.md +17 -311
  36. package/src/gdskills/bundled/skills/review/review-frontend-conventions/SKILL.md +8 -22
  37. package/src/gdskills/bundled/skills/review/review-highload/SKILL.md +84 -228
  38. package/src/gdskills/bundled/skills/review/review-layout/SKILL.md +22 -28
  39. package/src/gdskills/bundled/skills/review/review-logic/SKILL.md +9 -10
  40. package/src/gdskills/bundled/skills/review/review-performance/SKILL.md +16 -38
  41. package/src/gdskills/bundled/skills/review/review-premise/SKILL.md +1 -1
  42. package/src/gdskills/bundled/skills/review/review-regression/SKILL.md +1 -1
  43. package/src/gdskills/bundled/skills/review/review-security-code/SKILL.md +8 -8
  44. package/src/gdskills/bundled/skills/review/review-style/SKILL.md +49 -88
  45. package/src/gdskills/bundled/skills/review/review-testing-practices/SKILL.md +22 -40
  46. package/src/gdskills/bundled/skills/review/review-ui-ux/SKILL.md +42 -82
  47. package/src/gdskills/bundled/stacks/angular/rules/coding-style.mdc +15 -57
  48. package/src/gdskills/bundled/stacks/angular/rules/patterns.mdc +16 -60
  49. package/src/gdskills/bundled/stacks/angular/rules/security.mdc +11 -49
  50. package/src/gdskills/bundled/stacks/angular/rules/testing.mdc +13 -52
  51. package/src/gdskills/bundled/stacks/c-cpp/rules/coding-style.mdc +33 -57
  52. package/src/gdskills/bundled/stacks/c-cpp/rules/patterns.mdc +35 -62
  53. package/src/gdskills/bundled/stacks/c-cpp/rules/security.mdc +35 -62
  54. package/src/gdskills/bundled/stacks/c-cpp/rules/testing.mdc +34 -54
  55. package/src/gdskills/bundled/stacks/ci-github-gitlab/rules/patterns.mdc +27 -56
  56. package/src/gdskills/bundled/stacks/ci-github-gitlab/rules/security.mdc +51 -119
  57. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/coding-style.mdc +42 -74
  58. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/patterns.mdc +45 -83
  59. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/security.mdc +34 -59
  60. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/testing.mdc +33 -62
  61. package/src/gdskills/bundled/stacks/django/rules/coding-style.mdc +15 -56
  62. package/src/gdskills/bundled/stacks/django/rules/patterns.mdc +16 -68
  63. package/src/gdskills/bundled/stacks/django/rules/security.mdc +13 -71
  64. package/src/gdskills/bundled/stacks/django/rules/testing.mdc +16 -62
  65. package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/coding-style.mdc +30 -53
  66. package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/patterns.mdc +20 -56
  67. package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/security.mdc +52 -122
  68. package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/testing.mdc +23 -42
  69. package/src/gdskills/bundled/stacks/fastapi/rules/coding-style.mdc +13 -47
  70. package/src/gdskills/bundled/stacks/fastapi/rules/patterns.mdc +18 -81
  71. package/src/gdskills/bundled/stacks/fastapi/rules/security.mdc +13 -75
  72. package/src/gdskills/bundled/stacks/fastapi/rules/testing.mdc +14 -58
  73. package/src/gdskills/bundled/stacks/flutter-dart/rules/coding-style.mdc +36 -74
  74. package/src/gdskills/bundled/stacks/flutter-dart/rules/patterns.mdc +30 -66
  75. package/src/gdskills/bundled/stacks/flutter-dart/rules/security.mdc +33 -67
  76. package/src/gdskills/bundled/stacks/flutter-dart/rules/testing.mdc +41 -73
  77. package/src/gdskills/bundled/stacks/go/rules/coding-style.mdc +36 -57
  78. package/src/gdskills/bundled/stacks/go/rules/patterns.mdc +27 -42
  79. package/src/gdskills/bundled/stacks/go/rules/security.mdc +26 -43
  80. package/src/gdskills/bundled/stacks/go/rules/testing.mdc +23 -41
  81. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/coding-style.mdc +21 -40
  82. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/patterns.mdc +26 -43
  83. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/security.mdc +25 -37
  84. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/testing.mdc +34 -50
  85. package/src/gdskills/bundled/stacks/kotlin-android/rules/coding-style.mdc +28 -65
  86. package/src/gdskills/bundled/stacks/kotlin-android/rules/patterns.mdc +34 -78
  87. package/src/gdskills/bundled/stacks/kotlin-android/rules/security.mdc +35 -68
  88. package/src/gdskills/bundled/stacks/kotlin-android/rules/testing.mdc +34 -68
  89. package/src/gdskills/bundled/stacks/mobx/rules/coding-style.mdc +18 -64
  90. package/src/gdskills/bundled/stacks/mobx/rules/patterns.mdc +13 -66
  91. package/src/gdskills/bundled/stacks/mobx/rules/security.mdc +8 -35
  92. package/src/gdskills/bundled/stacks/mobx/rules/testing.mdc +10 -39
  93. package/src/gdskills/bundled/stacks/nestjs/rules/coding-style.mdc +32 -45
  94. package/src/gdskills/bundled/stacks/nestjs/rules/patterns.mdc +40 -60
  95. package/src/gdskills/bundled/stacks/nestjs/rules/security.mdc +30 -50
  96. package/src/gdskills/bundled/stacks/nestjs/rules/testing.mdc +27 -47
  97. package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/coding-style.mdc +14 -48
  98. package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/patterns.mdc +15 -67
  99. package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/security.mdc +12 -50
  100. package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/testing.mdc +11 -43
  101. package/src/gdskills/bundled/stacks/php-laravel/rules/coding-style.mdc +17 -58
  102. package/src/gdskills/bundled/stacks/php-laravel/rules/patterns.mdc +15 -56
  103. package/src/gdskills/bundled/stacks/php-laravel/rules/security.mdc +13 -50
  104. package/src/gdskills/bundled/stacks/php-laravel/rules/testing.mdc +14 -55
  105. package/src/gdskills/bundled/stacks/python/rules/coding-style.mdc +13 -41
  106. package/src/gdskills/bundled/stacks/python/rules/patterns.mdc +20 -61
  107. package/src/gdskills/bundled/stacks/python/rules/security.mdc +15 -57
  108. package/src/gdskills/bundled/stacks/python/rules/testing.mdc +16 -50
  109. package/src/gdskills/bundled/stacks/react/rules/coding-style.mdc +14 -40
  110. package/src/gdskills/bundled/stacks/react/rules/patterns.mdc +15 -55
  111. package/src/gdskills/bundled/stacks/react/rules/security.mdc +13 -49
  112. package/src/gdskills/bundled/stacks/react/rules/testing.mdc +10 -37
  113. package/src/gdskills/bundled/stacks/ruby-rails/rules/coding-style.mdc +15 -48
  114. package/src/gdskills/bundled/stacks/ruby-rails/rules/patterns.mdc +18 -67
  115. package/src/gdskills/bundled/stacks/ruby-rails/rules/security.mdc +11 -60
  116. package/src/gdskills/bundled/stacks/ruby-rails/rules/testing.mdc +14 -65
  117. package/src/gdskills/bundled/stacks/rust/rules/coding-style.mdc +39 -65
  118. package/src/gdskills/bundled/stacks/rust/rules/patterns.mdc +33 -60
  119. package/src/gdskills/bundled/stacks/rust/rules/security.mdc +35 -57
  120. package/src/gdskills/bundled/stacks/rust/rules/testing.mdc +29 -52
  121. package/src/gdskills/bundled/stacks/sql-db/rules/coding-style.mdc +12 -48
  122. package/src/gdskills/bundled/stacks/sql-db/rules/patterns.mdc +22 -113
  123. package/src/gdskills/bundled/stacks/sql-db/rules/security.mdc +11 -56
  124. package/src/gdskills/bundled/stacks/sql-db/rules/testing.mdc +14 -59
  125. package/src/gdskills/bundled/stacks/swift-ios/rules/coding-style.mdc +29 -65
  126. package/src/gdskills/bundled/stacks/swift-ios/rules/patterns.mdc +41 -88
  127. package/src/gdskills/bundled/stacks/swift-ios/rules/security.mdc +28 -53
  128. package/src/gdskills/bundled/stacks/swift-ios/rules/testing.mdc +32 -65
  129. package/src/gdskills/bundled/stacks/vue/rules/coding-style.mdc +17 -52
  130. package/src/gdskills/bundled/stacks/vue/rules/patterns.mdc +17 -63
  131. package/src/gdskills/bundled/stacks/vue/rules/security.mdc +11 -41
  132. package/src/gdskills/bundled/stacks/vue/rules/testing.mdc +16 -48
@@ -1,237 +1,106 @@
1
1
  ---
2
- description: "CLI surface rules: what an exit code means (0 clean, 1 found something, 2 cannot tell), machine-readable output on stdout and diagnostics on stderr, versioned --json shapes, and renaming a flag by aliasing it with a notice rather than removing it. Use when adding, changing, or retiring a command, subcommand, flag, or --json payload that people already run."
2
+ description: "keryx CLI decisions: exit codes (0 clean, 1 found something, 2 cannot tell), machine-readable output on stdout and diagnostics on stderr, versioned --json shapes, unknown flags refused, and flags renamed by alias with one notice or removed by refusing them by name. Use when adding, changing, or retiring a command, subcommand, flag, or --json payload that people already run."
3
3
  alwaysApply: false
4
+ stack_requires: "cli"
4
5
  ---
5
6
 
6
7
  # CLI Interface Design
7
8
 
8
9
  ## Purpose
9
- A command-line surface is a contract the moment somebody scripts it. Once a
10
- script reads an exit code, pipes stdout, or parses a `--json` payload, every
11
- later edit is either compatible or a silent breakage in someone else's CI. This
12
- rule fixes what those three channels mean and how a flag leaves the surface.
10
+ Once a script reads an exit code, pipes stdout, or parses a `--json` payload,
11
+ every later edit is compatible or a silent breakage in someone else's CI. This
12
+ rule records keryx's decisions for those channels, not general CLI practice, and
13
+ no list of current defects: known gaps live in the issue tracker.
13
14
 
14
15
  ## When To Apply
15
16
  Apply when adding a command or subcommand, adding or renaming a flag, changing
16
17
  what a command exits with, or changing the shape of anything it prints for a
17
- machine. It governs keryx's own CLI (`src/cli.ts` and `src/commands/**`);
18
- `rules/core/api-contracts.mdc` governs HTTP surfaces, and the versioning
19
- discipline there is the same discipline stated for a different transport.
18
+ machine. It governs keryx's own CLI (`src/cli.ts`, `src/commands/**`);
19
+ `rules/core/api-contracts.mdc` governs HTTP surfaces.
20
20
 
21
21
  ---
22
22
 
23
- ## Rules
23
+ ## Decisions
24
24
 
25
- ### 1. Three exit codes, and they mean three different things
25
+ ### 1. Exit codes: three values, three meanings
26
26
 
27
- keryx already runs a three-value convention, stated where it was first needed —
28
- `src/commands/wiki.ts:561-570`, `keryx wiki sections resolve`:
29
-
30
- - **0** — the command ran and the answer is clean.
31
- - **1** — the command ran and found something the caller should act on: a
27
+ - **0**: the command ran and the answer is clean.
28
+ - **1**: the command ran and found something the caller should act on: a
32
29
  broken link, a failing gate, a finding, a refusal.
33
- - **2** — the command could not tell. The registry was unreadable; the store
34
- could not be opened; the input was not parseable.
35
-
36
- The reason 2 exists is written into that code: *"a script that treats 1 as
37
- 'gone' would otherwise read an unreadable registry as a deletion."*
38
- `keryx memory search` adopted it deliberately and says so
39
- (`src/commands/memory.ts:182-196`), calling it *"reserved for 'cannot tell',
40
- distinct from both a completed search and a validation error."*
41
-
42
- **Two shipped commands do not honour it, and converging them is this rule's
43
- reason to exist:**
44
-
45
- - `keryx health run` folds `incomplete` — *"a required check that is missing,
46
- skipped, unparsed or unfinished"* — into **1**, the same code as an
47
- established threshold violation (`src/commands/health.ts:120-132`, with the
48
- justification at `:103-112`). "Nobody ran eslint" and "eslint found 40
49
- errors" are indistinguishable to a caller reading the code.
50
- - `keryx review` goes the other way and exits **0** on the same class of
51
- answer: `reportCrossFamilyReviewProblems` and `reportFilterStatsProblems`
52
- (both in `src/commands/review.ts`; cited by name because that file moves
53
- under every review change, and a line number here has already gone stale
54
- once) filter `not-recorded` out before failing, on the stated grounds that an
55
- absence is honest. It is honest — and it is still not a pass.
56
-
57
- Three commands, one binary, three answers to "I could not tell". A new command
58
- uses 0/1/2 as defined above. An existing one moves toward it only with its
59
- consumers named, because narrowing 1 into 1-or-2 is itself a breaking change.
30
+ - **2**: the command could not tell (unreadable store, unparseable input,
31
+ unresolvable ref), so a script never reads "unreadable" as "gone".
60
32
 
61
- Two settled corollaries, both worth keeping:
33
+ A new command uses 0/1/2. An existing command moves toward it only with its
34
+ consumers named, because narrowing 1 into 1-or-2 is itself a breaking change.
35
+ Corollaries:
62
36
 
63
- - **A checker that reports defects and exits 0 is a checker nothing can gate
64
- on** (`src/commands/skills.ts:927-951`). That code also exits non-zero on an
65
- *empty* denominator — `findings: 0` over zero skills evaluated is not a pass.
66
- - **A wrapper forwards its child's code unchanged.** `keryx ctx run` sets
67
- `process.exitCode = result.exitCode` (`src/commands/ctx.ts:210`); a wrapper
68
- that collapsed every child failure to 1 would make the wrapped command
69
- unusable under `set -e`.
37
+ - A checker that reports defects and exits 0 cannot be gated on. Zero items
38
+ evaluated is not a pass.
39
+ - A wrapper forwards its child's exit code unchanged, as `keryx ctx run` does.
70
40
 
71
41
  ### 2. stdout is the answer, stderr is everything else
72
42
 
73
- The canonical statement is `src/commands/mcp.ts:78-92`: the deprecation notice
74
- goes to stderr *"because a bare `keryx mcp` IS the stdio MCP server: stdout
75
- carries JSON-RPC frames there, and a notice written to it corrupts every client
76
- session rather than informing anyone."* The same file routes every consumer
77
- diagnostic to stderr for that reason (`:41-44`).
78
-
79
- The discipline, applied:
80
-
81
- - Structured output — `--json` payloads, rendered reports, the thing a pipe is
82
- for — goes to **stdout**, alone. `keryx skills verify --bundled --json`
83
- writes parseable JSON to stdout and its diagnostic to stderr, and still exits
84
- 1 (`src/commands/skills.ts:934-947`). Verified: stdout parses, stderr is
85
- empty on the clean path.
86
- - Progress, warnings, deprecation notices, usage errors go to **stderr**.
87
- - Under `--json`, a failure is *data on stdout*, not prose on stderr:
88
- `keryx memory search --json` emits `{ outcome: "store-unreadable", … }` on
89
- stdout and exits 2, where the plain mode prints to stderr
90
- (`src/commands/memory.ts:190-195`). A machine reader gets a discriminated
91
- result either way.
92
- - **Where this is broken today:** an unrecognised command prints its one-line
93
- diagnostic to stderr and then dumps the full help to **stdout**
94
- (`src/cli.ts:147-149`, `printHelp` at `:152`). Measured: `keryx bogusverb`
95
- writes 9,503 bytes of help to stdout; `keryx wiki check --bogus` writes
96
- 4,150. Both numbers are the help text's own size and move whenever a command
97
- is added — a later reading that differs is growth, not a correction to this
98
- paragraph. A caller piping stdout for JSON receives a help screen instead, and
99
- only the exit code says otherwise. **Help printed because of an error belongs
100
- on stderr. Help printed because `--help` was asked for belongs on stdout.**
43
+ - Structured output (`--json` payloads, rendered reports, whatever a pipe is for)
44
+ goes to stdout, alone.
45
+ - Progress, warnings, deprecation notices and usage errors go to stderr. A bare
46
+ `keryx mcp` is the stdio MCP server, so a notice on stdout corrupts its frames.
47
+ - Under `--json`, a failure is data on stdout, not prose on stderr: a
48
+ discriminated object such as `{ outcome: "store-unreadable", ... }` with the
49
+ exit code the failure earns (2 for "could not tell").
50
+ - Help printed because of an error goes to stderr. Help printed because `--help`
51
+ was asked for goes to stdout. A new flag appears in that command's help text in
52
+ the same change.
101
53
 
102
54
  ### 3. A `--json` shape is versioned, deterministic, and pinned
103
55
 
104
- `keryx skills export` is the worked example. Removing one boolean from its
105
- manifest moved the version, and the code says why
106
- (`src/gdskills/export.ts:167-193`): *"Removing a field is a breaking change for
107
- anything parsing this file, so the version moves with it: a reader that still
108
- expects the boolean sees `schemaVersion: 2` and knows why it is absent instead
109
- of reading `undefined` as `false`."* The plugin manifest is a different shape
110
- and stays at its own `schemaVersion: 1` (`src/gdskills/export-plugin.ts:153`) —
111
- versions are per-shape, not per-repo. A test pins the number
112
- (`src/gdskills/export-runtime-builds.test.ts:108`).
113
-
114
- `keryx modules status --json` carries the other half: a `schemaVersion`, a
115
- deterministic key order sorted independently of authoring order *"which is what
116
- makes it safe to diff and to consume from a harness"*
117
- (`src/commands/modules.ts:197-210`), and a test that pins the version
118
- (`src/commands/modules.test.ts:26`).
119
-
120
- So the standard for any new machine-readable payload is:
121
-
122
- 1. A top-level **object** with a `schemaVersion`. Not an array — an array
123
- cannot grow a field. `rules/core/skills-storage-workflow.mdc` has said "One
124
- top-level JSON object only" since it was written.
125
- 2. Deterministic ordering, so two runs of an unchanged tree are byte-identical.
126
- 3. A test that asserts the version and the required keys, in the same change.
127
- 4. Adding an optional field is compatible. **Removing or renaming one bumps the
128
- version**, in the same commit as the removal.
129
-
130
- **Where this is inconsistent today:** `keryx skills` serialises internal
131
- TypeScript objects straight to stdout at eleven call sites
132
- (`src/commands/skills.ts:222`, `:288`, `:398`, `:693`, `:735`, `:785`, `:822`,
133
- `:883`, `:935`, `:989`, `:1101`). Three of the eleven print a type that
134
- declares one — `LearningProposal` (`src/gdskills/learn.ts:17`, set at `:100`)
135
- at `:785`, and `ProjectSkillVerificationReport` (`src/gdskills/verify.ts:25`,
136
- set at `:96`) at `:883` and `:989`. The other eight carry no version at all.
137
-
138
- **The gap is the envelope, and it is the worse half.** `verify --bundled
139
- --json` emits an unversioned object (`root`, `skills`, `documents`,
140
- `skillNames`, `findings`); `verify --all --json` emits a bare array — `[]` when
141
- the registry is empty (`:973`), a list of reports otherwise (`:989`). So
142
- `keryx skills verify --all --json` ships `[{ "schemaVersion": 1, … }]`: each
143
- element versioned, the payload a caller actually parses not. That is standard 1
144
- failing in the direction it warns about — an array cannot grow a field, so the
145
- envelope can never be versioned later without the breaking change the version
146
- existed to avoid, however carefully each element inside it is versioned. One
147
- test pins one field of one of them
148
- (`src/commands/skills.bundled-verify.test.ts:58` asserts `findings` is `[]`). A
149
- rename inside any of the eight unversioned types is a CLI breaking change that
150
- nothing in the repository would catch.
56
+ 1. A top-level object with a `schemaVersion`, per shape. Never a bare array: it
57
+ cannot grow a field, so its envelope could never be versioned later.
58
+ 2. Deterministic key order, so two runs on an unchanged tree are byte-identical.
59
+ 3. A test asserts the version and the required keys, in the same change.
60
+ 4. Adding an optional field is compatible. Removing or renaming one bumps the
61
+ version in the same commit.
151
62
 
152
63
  ### 4. An unknown flag is refused, never ignored
153
64
 
154
- `rejectUnknownFlags` (`src/commands/review.ts:307-318`) is the standard, and
155
- its message is the argument: *"Refused rather than ignored — a flag that is
156
- silently dropped writes nothing and reports success."* (`:315`) It names the
157
- offending flag, lists what is accepted, and refuses. Every `keryx review`
158
- subcommand calls it.
159
-
160
- The same rule applies to a flag's **value**, not just its name. An unknown
161
- `--verifier` is refused because *"an unrecognised method would silently leave
162
- the tier at its default"* (`src/commands/review.ts:754`), and an unknown
163
- `--deny-tools` name is refused with the deniable names listed, because
164
- *"`--deny-tools web_serch` must not leave the session with web search and a
165
- clear conscience"* (`src/commands/interactive-agent-tools.ts:140-156`,
166
- `src/commands/shell.ts:1797-1798`).
167
-
168
- **Where this is inconsistent today:** the guard is per-command, and two
169
- implementations exist — `rejectUnknownFlags` and `rejectUnknownOptions`
170
- (`src/commands/workspace.ts:296-300`). Most commands have neither. Measured on
171
- this tree: `keryx review scope --bogus` exits 1 with a named refusal, while
172
- `keryx modules status --bogus --json` and `keryx skills verify --bundled
173
- --bogus` both exit **0** and ignore the flag. The same binary answers the same
174
- typo two different ways.
175
-
176
- A new command validates its flags. A flag that takes a fixed set of values
177
- validates the value too.
178
-
179
- ### 5. A flag is renamed by aliasing it, and removed by refusing it out loud
180
-
181
- keryx has never deleted a spelling. Three patterns, all shipped, all correct:
182
-
183
- - **Rename → alias + one notice.** `keryx mcp install|uninstall` became
184
- `keryx integrate` and the old spelling still works: one module translates the
185
- old argument shape and calls the new implementation, so there is *"one
186
- implementation and nothing to drift"* (`src/commands/mcp.ts:1-14`). It prints
187
- exactly one line, on stderr, per invocation — *"A line a reader sees three
188
- times in one command is a line they learn to skip, which is how deprecation
189
- notices stop working at all"* (`:78-92`). A contract test asserts the retired
190
- spellings still work, still write the same files, and name the replacement
191
- **once** (`src/commands/mcp-naming.test.ts:453`, `:470`, `:490`).
192
- - **Removal → refuse by name, with the reason.** `keryx workspace handoff
193
- --from` was removed because a caller could not be allowed to state it. It is
194
- refused by name rather than as a generic unknown option, *"so anyone who
195
- scripted it learns why it is gone instead of reading it as a typo"*
196
- (`src/commands/workspace.ts:221-231`).
197
- - **A wrapper's own flag is consumed, not forwarded.** `keryx ctx rg --json` is
198
- keryx's flag, stripped before the child command is built, because `rg --json`
199
- means something else (`src/commands/ctx.ts:213-219`). Check the namespace
200
- before claiming a flag name a wrapped tool already owns.
201
-
202
- **Where this is inconsistent today:** `keryx review` accepts both `--ref` and
203
- `--target-ref` for the same value, `--ref` winning
204
- (`src/commands/review.ts:147`, `:409`). There is no notice, and `--target-ref`
205
- appears nowhere in `keryx review --help`. An unannounced, undocumented alias is
206
- indistinguishable from an accidental duplicate: nothing tells a caller to
207
- migrate, so nothing will ever justify retiring it.
208
-
209
- A rename therefore ships four things in one change: the new spelling, the old
210
- one still working through the same implementation, one stderr notice naming the
211
- replacement, and a test that asserts both.
65
+ - A command refuses an unrecognised flag: it names the flag, lists what is
66
+ accepted, and exits 1. A dropped flag writes nothing and reports success.
67
+ - A flag with a fixed value set refuses an unknown value and lists the valid
68
+ ones, rather than silently keeping the default.
69
+ - A new command validates its flags with the shared refusal, not a private copy.
70
+
71
+ ### 5. A flag is renamed by aliasing, and removed by refusing it out loud
72
+
73
+ keryx does not delete a published spelling.
74
+
75
+ - **Rename**: the old spelling keeps working through the same implementation (no
76
+ second implementation to drift) and prints exactly one stderr line per
77
+ invocation naming the replacement. A contract test asserts both.
78
+ - **Removal**: refuse by name with the reason, never as a generic unknown
79
+ option, so a script that used it learns why it is gone instead of reading it
80
+ as a typo.
81
+ - **Wrapper flags**: a wrapper's own flag is consumed, not forwarded. Check the
82
+ wrapped tool's namespace before claiming a flag name it already owns.
83
+ - An alias is documented in `--help`; an undocumented one reads as an
84
+ accidental duplicate and can never be retired.
212
85
 
213
86
  ---
214
87
 
215
88
  ## The three that are not negotiable
216
89
 
217
90
  A nonzero exit never means "I could not tell" in a command that also uses
218
- nonzero to mean "I found something" — pick 2 for the first. A `--json` payload
91
+ nonzero to mean "I found something": pick 2 for the first. A `--json` payload
219
92
  never loses or renames a field without a `schemaVersion` bump in the same
220
93
  commit. An old flag spelling is never deleted: it is aliased with a notice, or
221
94
  refused by name with the reason.
222
95
 
223
96
  ---
224
97
 
225
- ## Red Flags — Stop and re-read this rule if you are thinking:
98
+ ## Red Flags: stop and re-read this rule if you are thinking
226
99
 
227
100
  | Rationalization | Why it's wrong |
228
101
  |---|---|
229
- | "Exit 1 is fine, the message explains which kind of failure it was" | Messages are for people; scripts read the code. `keryx health run` cannot distinguish "eslint was skipped" from "eslint failed" today, and that is the gap, not a style preference |
230
- | "Nobody parses this `--json` yet, so I can change the shape freely" | You cannot observe who parses a published CLI's output. The version field costs one line and is the only thing that lets a reader tell absence from a downgrade |
231
- | "I'll print the warning to stdout, it's more visible there" | stdout is the pipe. A warning there corrupts every consumer that expected data — which is why `keryx mcp` routes its notice to stderr instead |
232
- | "The old flag is unused, I'll just delete it" | "Unused" means "no usage you can see". Alias it with a notice, or refuse it by name with the reason — both cost less than a silent breakage in someone's CI |
233
- | "An unrecognised flag is harmless, the command still does the right thing" | It does less than the operator asked and reports success. That is the failure `rejectUnknownFlags` was written for |
234
- | "It's just a help screen on stdout, who cares" | Nine kilobytes of it, where the caller expected JSON. Error output is error output regardless of how friendly it reads |
235
- | "I'll add the schemaVersion when the shape actually changes" | The first change is the one that needs it, and by then the unversioned readers already exist |
236
-
237
- **IRON LAW: ONCE A COMMAND IS PUBLISHED, ITS EXIT CODE, ITS STDOUT, AND ITS `--json` SHAPE ARE A CONTRACT — CHANGE THEM THE WAY YOU WOULD CHANGE AN API, OR NOT AT ALL.**
102
+ | "Exit 1 is fine, the message says which kind of failure it was" | Scripts read the code, not the message |
103
+ | "Nobody parses this `--json` yet, so I can change the shape freely" | You cannot observe who parses a published CLI's output |
104
+ | "The old flag is unused, I'll just delete it" | "Unused" means no usage you can see |
105
+
106
+ **IRON LAW: ONCE A COMMAND IS PUBLISHED, ITS EXIT CODE, ITS STDOUT, AND ITS `--json` SHAPE ARE A CONTRACT. CHANGE THEM THE WAY YOU WOULD CHANGE AN API, OR NOT AT ALL.**
@@ -1,55 +1,43 @@
1
1
  ---
2
- description: "Code style and architecture patterns for TypeScript, React, and MobX."
2
+ description: "React and TypeScript standard for the frontend, shared by code writers and reviewers, with the severities reviewers use: observer on every component that reads observables, layers (service IO, store logic, component render), where state lives, stores created once, effects that clean up, stable keys, accessibility basics, and TypeScript safety. Use when writing or reviewing React/TypeScript components."
3
3
  alwaysApply: false
4
4
  stack_requires: "react,mobx"
5
5
  ---
6
6
 
7
7
  # Code Style and Architecture Patterns
8
8
 
9
- ## Purpose
10
- Enforce consistent code style and architecture patterns across TypeScript, React, and MobX code in the frontend project.
11
-
12
- ## When To Apply
13
- Apply when reviewing or implementing TypeScript/React/MobX code in the frontend project.
14
-
15
- ## TypeScript
16
- - Enforce strict typing; avoid `any`.
17
- - Use interfaces for component props.
18
- - Prefer `?.` and `??` over unsafe assertions.
19
- - Do not use imports like `from \"src/...\"`; use relative paths or approved aliases.
20
-
21
- ## MobX Patterns
22
-
23
- For complete MobX store patterns, see `core/mobx-store-template.mdc`.
24
-
25
- Key principles (see canonical source for full detail with examples):
26
- - All state must use `makeObservable(this)` with explicit decorators
27
- - Store layout should stay predictable: private fields → public fields → constructor → public methods → private methods
28
- - Public UI entrypoints called from React should be `@action.bound`, usually as thin `on...` methods
29
- - Public non-mutating helpers/selectors are not actions and do not use `runInAction`
30
- - Private API/IO and orchestration belong in private methods; async private methods use `try/catch/finally`
31
- - Use `runInAction` for private mutation blocks after `await`, and for private orchestration-state updates
32
- - Wrap React components with `observer`
33
- - Inter-store callbacks and internal handlers must be private (see `core/mobx-store-template.mdc` for the canonical callback rules)
34
- - Use equality guards, not truthy checks, when optional values must propagate clearing
35
- - Implement bounce protection for bidirectional sync
36
-
37
- ## React
38
- - Wrap observable-consuming components with `observer`.
39
- - Keep business logic in stores/services.
40
- - Avoid heavy logic in render.
41
-
42
- ## Architecture
43
- - Service layer: IO/API only.
44
- - Store layer: business logic and state transitions.
45
- - Component layer: view rendering.
46
- - UI components should preferably have their own local MobX store to manage their specific view state and encapsulate UI-specific logic, implementing reactivity via MobX instead of `useState` where possible.
47
-
48
- ## Review Flags
49
- - API calls directly in UI components.
50
- - Missing `observer` where store values are consumed.
51
- - Direct observable mutation outside actions.
52
- - Large inline render logic better suited for computed/store methods.
53
- - Public inter-store callbacks/handlers that should be `private` (e.g. `onChangeEditorState`, `onFireExecutorChange`).
54
- - Bidirectional store sync without equality guard — risk of infinite callback bounce.
55
- - Truthy guard (`if (x && x !== y)`) on optional/nullable field — blocks propagation of `undefined`/falsy clearing.
9
+ Canon applies: the React documentation (rules of hooks, effects, keys), WAI-ARIA basics and the TypeScript handbook. Store internals are `mobx-store-template.mdc`; backend layering is `clean-architecture.mdc`. This rule holds only this project's frontend decisions.
10
+
11
+ ## Rules
12
+
13
+ 1. **`observer` on every component that reads an observable**, conditional reads included, as the outermost wrapper: `observer(withRouter(View))`. A component that reads only props needs none.
14
+ 2. **Layers.** A service does IO only; a store holds state, logic and state transitions; a component renders and forwards events to store actions. No API/IO call and no business logic (validation, transformation, branching on domain state) in a component, its handlers or its effects.
15
+ 3. **Where state lives.** UI-only state that one component uses (an open flag, a hover, an input draft) is `useState`. State with logic, or read by another component or a store, lives in a store; it is never copied into `useState`. `useMemo`/`useCallback` do not wrap store values or store methods.
16
+ 4. **A store is created once per mount**: `useState(() => new PageStore(api))[0]` or `useLocalObservable`, never `new Store()` in the component body.
17
+ 5. **An effect that subscribes, listens or starts a timer returns its cleanup.** Data loading is not started from an effect (see `mobx-store-template.mdc` Rule 8).
18
+ 6. **List keys** are on the element `.map()` returns and are stable ids; an index key only for a static list that never reorders or filters.
19
+ 7. **Accessibility.** `<img>` has `alt` (`""` when decorative); an icon-only button or link has `aria-label`; a form input has a label; a clickable element is a `<button>` or `<a>`, not a `<div onClick>`.
20
+ 8. **TypeScript.** No `any` (use `unknown` and a guard, or the named type). A `!` assertion carries a comment that proves it; otherwise use `?.`/`??` and handle the missing case. Props types are `XProps`, no `I` prefix. Imports use relative paths or the configured aliases, never `from "src/..."`.
21
+
22
+ ---
23
+
24
+ ## Review severities (shared with reviewers)
25
+
26
+ `review-frontend` rates these patterns by this table. Change a row here, never in a reviewer.
27
+
28
+ | Signal | A finding when | Default | Not a finding |
29
+ |---|---|---|---|
30
+ | Component reads observables without `observer` (Rule 1) | always | `major` (the UI does not update when the observable changes) | a component that reads only props |
31
+ | `observer` inside another HOC (Rule 1) | always | `minor`; `major` with a named defect | — |
32
+ | API/IO or business logic in a component (Rule 2) | always | `minor`; `major` with a named defect it causes | — |
33
+ | Shared or store-owned state kept in `useState`, or copied from a store (Rule 3) | two owners of the value can diverge, named | `major` | UI-only state one component uses |
34
+ | `useMemo`/`useCallback` around a store value or method (Rule 3) | always | `minor` | a memo over values that are not store state |
35
+ | Store constructed in the component body (Rule 4) | always | `major` (recreated on each render, state lost) | `useState(() => new Store())`, `useLocalObservable` |
36
+ | Subscription, listener or timer without cleanup (Rule 5) | always | `major` | — |
37
+ | Missing `key` (Rule 6) | always | `major` | — |
38
+ | Index key on a list that reorders, filters or paginates (Rule 6) | always | `minor` | a static list |
39
+ | `<img>` without `alt`; interactive element without an accessible name (Rule 7) | always | rated by the missing-accessible-name row of `ui-anti-slop.mdc` Review severities | — |
40
+ | Clickable non-semantic element without keyboard support (Rule 7) | always | rated by the keyboard-reachability row of `ui-anti-slop.mdc` Review severities | — |
41
+ | `!` on a value the types allow to be missing (Rule 8) | a named input reaches it | `blocker` when it throws during render; `major` elsewhere; `minor` with no input shown | a `!` with a comment that proves it |
42
+ | `any` in new code (Rule 8) | always | `minor`; `major` with a named input and the wrong value it lets through | — |
43
+ | `I`-prefixed props type, `from "src/..."` import (Rule 8) | introduced by the change | `minor` | — |
@@ -0,0 +1,32 @@
1
+ ---
2
+ description: "Concurrency standard for the CLI and for several sessions sharing one checkout, shared by code writers and reviewers, with the severities reviewers use: a lock file is taken by exclusive create, files are written via temp file and rename, one write per JSONL record, child-process fan-out is bounded, child output is capped. Use when writing or reviewing code that touches shared state files, lock files, JSONL logs or spawned child processes."
3
+ alwaysApply: false
4
+ ---
5
+
6
+ # Concurrency Patterns
7
+
8
+ Canon applies: POSIX `rename(2)` atomicity, `O_EXCL` / the Node.js `wx` open flag, and `child_process` stream semantics. This rule holds only this project's decisions for state shared by concurrent sessions and processes.
9
+
10
+ ## Rules
11
+
12
+ 1. **A lock file is taken by exclusive create** (`wx`), never check-then-create. It is released in `finally`, and a stale lock is recovered by the holder's PID or age without taking a live holder's lock.
13
+ 2. **A shared state file is written to a temp file in the same directory and renamed over the target.** A read-modify-write of it holds a lock (Rule 1).
14
+ 3. **One JSONL record is one write.** A record is serialised whole, with its newline, and appended in a single call.
15
+ 4. **Child-process fan-out is bounded.** One child per file, flow, finding or input item goes through a concurrency limit; default 4.
16
+ 5. **Child output is capped.** Child stdout and stderr, and logs, are held in a ring buffer or written to a file, never concatenated whole in memory.
17
+
18
+ ---
19
+
20
+ ## Review severities (shared with reviewers)
21
+
22
+ `review-highload` rates these patterns by this table. Change a row here, never in a reviewer.
23
+
24
+ | Signal | A finding when | Default | Not a finding |
25
+ |---|---|---|---|
26
+ | Read-modify-write of a shared state file with no lock, or a write with no temp file and rename (Rules 1, 2) | two sessions or processes can reach it, named | `blocker` if the interleaving can corrupt or lose data, or a reader parses a half-written file; otherwise `major` | a file only one process writes, shown |
27
+ | Lock file taken by check-then-create (Rule 1) | always | `major`; `blocker` where the duplicate holder is shown to persist a lost or doubled write | an exclusive create |
28
+ | Lock released outside `finally`, or no stale-lock recovery (Rule 1) | a crash or throw leaves it held and a later session waits on it | `major` | a lock with a holder PID or age check |
29
+ | Stale-lock recovery that can take a live holder's lock (Rule 1) | the recovery test can pass while the holder runs | `major`; `blocker` where two holders are shown to write | — |
30
+ | JSONL record appended in more than one write (Rule 3) | several processes append to the file | `major` | a file one process appends to |
31
+ | One child process per input item with no bound (Rule 4) | the item count is not fixed small, named | `major` when the stall or exhaustion it causes is named; `blocker` only if the crash is shown | a fixed small count |
32
+ | Child stdout, stderr or log accumulated whole in memory (Rule 5) | the child's output size is not bounded | `major` when a named child can print without limit; else `minor` | output known small, or read from a file |