@mrciphersmith/keryx 0.4.28 → 0.4.29

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 (32) hide show
  1. package/dist/cli.js +2710 -2488
  2. package/dist/core.js +5 -5
  3. package/dist/keryx-general-worker-entry.js +335 -219
  4. package/package.json +1 -1
  5. package/src/gdskills/bundled/install-manifest.json +1 -0
  6. package/src/gdskills/bundled/rules/core/clean-architecture.mdc +25 -153
  7. package/src/gdskills/bundled/rules/core/code-style-patterns.mdc +1 -0
  8. package/src/gdskills/bundled/rules/core/error-handling.mdc +57 -108
  9. package/src/gdskills/bundled/rules/core/skill-authoring.mdc +190 -0
  10. package/src/gdskills/bundled/rules/core/skills-storage-workflow.mdc +5 -0
  11. package/src/gdskills/bundled/rules/core/solid-principles.mdc +48 -123
  12. package/src/gdskills/bundled/skills/orchestration/task-implementer/SKILL.md +2 -2
  13. package/src/gdskills/bundled/skills/quality/tests-creator/SKILL.md +1 -1
  14. package/src/gdskills/bundled/skills/review/review-architecture/SKILL.md +1 -1
  15. package/src/gdskills/bundled/skills/review/review-backend/SKILL.md +3 -5
  16. package/src/gdskills/bundled/skills/review/review-clean-code/SKILL.md +100 -421
  17. package/src/gdskills/bundled/skills/review/review-core-boundaries/SKILL.md +2 -2
  18. package/src/gdskills/bundled/skills/review/review-degradation/SKILL.md +1 -1
  19. package/src/gdskills/bundled/skills/review/review-flow-graph/SKILL.md +1 -1
  20. package/src/gdskills/bundled/skills/review/review-frontend/SKILL.md +4 -5
  21. package/src/gdskills/bundled/skills/review/review-frontend-conventions/SKILL.md +1 -1
  22. package/src/gdskills/bundled/skills/review/review-highload/SKILL.md +1 -1
  23. package/src/gdskills/bundled/skills/review/review-logic/SKILL.md +2 -3
  24. package/src/gdskills/bundled/skills/review/review-performance/SKILL.md +1 -1
  25. package/src/gdskills/bundled/skills/review/review-premise/SKILL.md +1 -1
  26. package/src/gdskills/bundled/skills/review/review-regression/SKILL.md +1 -1
  27. package/src/gdskills/bundled/skills/review/review-security-code/SKILL.md +1 -1
  28. package/src/gdskills/bundled/skills/review/review-style/SKILL.md +32 -36
  29. package/src/gdskills/bundled/skills/review/review-testing-practices/SKILL.md +1 -1
  30. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/patterns.mdc +4 -3
  31. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/coding-style.mdc +3 -3
  32. package/src/gdskills/bundled/stacks/ruby-rails/rules/coding-style.mdc +4 -4
@@ -1,149 +1,74 @@
1
1
  ---
2
- description: "SOLID principles for agent-generated code — focus on Single Responsibility, Open/Closed, and Dependency Inversion as the most commonly violated. Use when designing classes, modules, or service interfaces."
2
+ description: "SOLID and function-design standard shared by code writers and the code-quality and style reviewers, with the thresholds they use: function length, parameter count, constructor dependencies, branch chains, file length, nesting, branching. Use when designing classes, modules or functions, or reviewing them."
3
3
  alwaysApply: false
4
4
  ---
5
5
 
6
- # SOLID Principles
6
+ # SOLID Principles and Function Design
7
7
 
8
8
  ## Purpose
9
- Prevent the three most common SOLID violations in AI-generated code: god classes, hardcoded dependencies, and modification-on-every-change designs.
9
+ One standard for designing and reviewing classes and functions. The thresholds below are the ones the code-quality and style reviewers apply. A writer who stays inside them gets no finding, and a reviewer reports nothing inside them.
10
10
 
11
11
  ## When To Apply
12
- Apply when creating new classes, services, or modules; when adding logic to an existing class; when wiring up dependencies.
12
+ Apply when creating or extending classes, services, modules or functions, and when reviewing them.
13
13
 
14
14
  ---
15
15
 
16
- ## S — Single Responsibility Principle
17
-
18
- **One class/module = one reason to change.**
19
-
20
- ### Rules
21
- - A class that does more than one thing must be split
22
- - A function that is longer than ~30 lines almost certainly has multiple responsibilities
23
- - Mixins of data-fetching + business logic + rendering are always a violation
24
- - If you cannot name a class in ≤3 words without "and", it has too many responsibilities
25
-
26
- ### Signals of violation
27
- - Class name contains "Manager", "Handler", "Util", "Helper" (often catch-alls)
28
- - Constructor receives >5 dependencies
29
- - File is longer than 300 lines and is not a config or generated file
30
- - Method count exceeds 10 on a non-entity class
31
-
32
- ### Correct pattern
33
- ```typescript
34
- // BAD — does everything
35
- class UserService {
36
- fetchUser() { /* HTTP */ }
37
- validateUser() { /* domain logic */ }
38
- formatUserForUI() { /* presentation */ }
39
- saveToCache() { /* infrastructure */ }
40
- }
41
-
42
- // GOOD — each class has one job
43
- class UserRepository { fetchUser() {} }
44
- class UserValidator { validate() {} }
45
- class UserPresenter { format() {} }
46
- class UserCache { save() {} }
47
- ```
16
+ ## Thresholds (shared with review-clean-code)
48
17
 
49
- ---
18
+ | Signal | Threshold | When a reviewer reports it |
19
+ |---|---|---|
20
+ | Function body length | over 40 lines | Only when the function also mixes levels of abstraction or does two separable jobs. A long linear table, serializer or test is not a finding. |
21
+ | I/O mixed with a transform | any length | One function that reads or writes (file, network, store) and also transforms the data in between. Keep the transform a pure helper the I/O shell calls. |
22
+ | Positional parameters | 4 or more | When there is no options object and the parameters are not a natural ordered set the codebase already uses. |
23
+ | Boolean flag parameter | any | When the flag selects between two different behaviours, so that call sites read `run(x, true)`. |
24
+ | Constructor dependencies | more than 5 | As an SRP signal; name the two responsibilities. |
25
+ | Branch chain over a type discriminant | 4 or more branches, extended by the change | When the codebase already uses a lookup map or a strategy for the same kind of dispatch. |
26
+ | Duplicated block | 3 or more copies | Reported once, listing every copy. |
50
27
 
51
- ## O — Open/Closed Principle
52
-
53
- **Open for extension, closed for modification.**
54
-
55
- ### Rules
56
- - New behaviour must be addable without editing existing classes
57
- - Use polymorphism, strategy pattern, or configuration — not if/else chains
58
- - Every time you add an `else if` to handle a new variant, ask: "should this be a new strategy?"
59
- - Enums as switch-statement keys are the canonical violation — add a new enum value → touch N files
60
-
61
- ### Signals of violation
62
- - Switch/if-else over a type enum with 3+ cases
63
- - Adding a new payment provider / notification channel / export format requires editing core logic
64
- - A "type" field drives behaviour throughout the codebase
65
-
66
- ### Correct pattern
67
- ```typescript
68
- // BAD — every new type requires editing this function
69
- function notify(type: string, msg: string) {
70
- if (type === 'email') sendEmail(msg);
71
- else if (type === 'sms') sendSMS(msg);
72
- else if (type === 'push') sendPush(msg);
73
- }
74
-
75
- // GOOD — new channels added without touching existing code
76
- interface Notifier { send(msg: string): Promise<void>; }
77
- class EmailNotifier implements Notifier { send() {} }
78
- class SMSNotifier implements Notifier { send() {} }
79
- // registry → inject the right one
80
- ```
28
+ Under a threshold, the reviewer stays silent. At or over one, the finding is `minor` unless it names a trigger and a wrong outcome (see the review-orchestrator severity rubric).
81
29
 
82
- ---
30
+ ## Readability thresholds (shared with review-style)
83
31
 
84
- ## D — Dependency Inversion Principle
85
-
86
- **Depend on abstractions, not concretions.**
87
-
88
- ### Rules
89
- - High-level modules must not import low-level modules directly
90
- - Dependencies are injected, not constructed inside the class
91
- - `new ConcreteService()` inside a business-logic class is always a violation
92
- - Tests become trivially easy when DIP is followed — if mocking is hard, DIP is violated
93
-
94
- ### Signals of violation
95
- - `new` keyword used inside a service or use-case class body
96
- - Direct imports of `axios`, `prisma`, `fetch` in business logic layers
97
- - Constructor creates its own dependencies instead of receiving them
98
- - Testing requires monkey-patching module imports
99
-
100
- ### Correct pattern
101
- ```typescript
102
- // BAD — hard dependency on concrete HTTP client
103
- class OrderService {
104
- async createOrder(data: OrderDTO) {
105
- const client = new HttpClient(); // ← violation
106
- return client.post('/orders', data);
107
- }
108
- }
109
-
110
- // GOOD — depends on abstraction, injected externally
111
- interface HttpClient { post(url: string, body: unknown): Promise<unknown>; }
112
-
113
- class OrderService {
114
- constructor(private readonly http: HttpClient) {}
115
- async createOrder(data: OrderDTO) {
116
- return this.http.post('/orders', data);
117
- }
118
- }
119
- ```
32
+ `review-style` rates these; `review-clean-code` leaves them to it. Generated code, fixtures, migrations and test files are exempt.
120
33
 
121
- ---
34
+ | Signal | Threshold | Default |
35
+ |---|---|---|
36
+ | File length | over 500 lines; over 800 lines | `info`; `minor` |
37
+ | Nesting depth (callbacks or `if/else`) | more than 3 levels | `minor` |
38
+ | Decision branches in one function | more than 10 | `minor` |
39
+ | Boolean condition | more than 3 clauses without grouping | `minor` |
40
+ | Unrelated exports from one file | more than 5 | `minor` |
122
41
 
123
- ## L & I (Brief Notes)
42
+ A threshold in either table counts only when the change crosses it.
124
43
 
125
- **Liskov Substitution (L):** A subclass must be usable wherever the parent is expected. If overriding a method throws where the parent would not — that is a violation.
126
-
127
- **Interface Segregation (I):** Prefer small, focused interfaces. A class should not be forced to implement methods it does not use. Split fat interfaces into role interfaces.
44
+ A stack rule may refine a threshold for its language. It names the row it overrides and gives its own value; for that language, writers and reviewers use the stack value.
128
45
 
129
46
  ---
130
47
 
131
- ## Iron Laws
48
+ ## S — Single Responsibility
49
+ **One class or module, one reason to change.**
50
+ - Do not mix fetching, business rules and presentation or persistence in one class or function.
51
+ - If you cannot name it in three words without "and", it does too much.
52
+ - A constructor assigns. It does not perform I/O or start async work.
132
53
 
133
- **IRON LAW 1: A class with a name ending in "Manager", "Helper", or "Utils" MUST be reviewed for SRP before committing.**
134
- **IRON LAW 2: `new ConcreteClass()` inside business logic is forbidden. Pass dependencies via constructor.**
135
- **IRON LAW 3: Adding a new variant must not require editing more than 1 existing file. If it does, refactor first.**
54
+ ## O — Open/Closed
55
+ - Adding a variant should not mean editing a growing `if/else` or `switch` when the codebase already dispatches that kind of thing through a map or a strategy.
136
56
 
137
- ---
57
+ ## L — Liskov Substitution
58
+ - An override must work wherever the base type is used. An override that throws "not supported", or rejects input the base accepts, breaks callers that hold the base type.
59
+
60
+ ## I — Interface Segregation
61
+ - An implementation that leaves methods as stubs or no-ops means the interface is too wide.
138
62
 
139
- ## Red Flags — Stop and re-read this rule if you are thinking:
63
+ ## D — Dependency Inversion
64
+ - Business logic receives the dependencies it calls into (I/O, network, clock) instead of constructing them. Inside a module, constructing a plain helper or value object is fine.
65
+ - An interface belongs at an I/O or substitution boundary (repository, external client, clock). A single internal implementation gets none. Interfaces are named without an `I` prefix.
140
66
 
141
- | Rationalization | Why it's wrong |
142
- |---|---|
143
- | "It's just one extra method, I'll add it here" | Each small addition is how god classes are built — one method at a time |
144
- | "I'll inject it later, for now I'll just `new` it" | "Later" never comes; the hard dependency ships to production |
145
- | "An interface is overkill for this simple case" | Interfaces cost nothing at compile time and enable testing at zero extra effort |
146
- | "I'll use a switch, there are only 3 cases" | 3 cases becomes 10 over time — the OCP violation compounds |
147
- | "The constructor is getting long but refactoring is risky" | A long constructor is a signal the class has too many responsibilities — refactor now, not later |
67
+ ---
68
+
69
+ ## Iron Laws
148
70
 
149
- **IRON LAW: CODE THAT CANNOT BE TESTED WITHOUT MOCKING FILESYSTEM OR NETWORK IN BUSINESS LOGIC HAS A DIP VIOLATION.**
71
+ **IRON LAW 1: An override never throws where its base type would not.**
72
+ **IRON LAW 2: A constructor performs no I/O.**
73
+ **IRON LAW 3: The thresholds in this file are the standard for both writing and review. Change them here, never in a reviewer.**
74
+ </content>
@@ -204,8 +204,8 @@ Rules `resolve-context` listed are already read (2.0c); load the rest by what yo
204
204
 
205
205
  **Always load (all task types):**
206
206
  - `tdd-workflow.mdc` — red-green-refactor, STATUS: DONE requires passing tests
207
- - `error-handling.mdc` — Result pattern, no silent failures
208
- - `solid-principles.mdc` — SRP, OCP, DIP (load for any task that creates new classes/services)
207
+ - `error-handling.mdc` — failure signalled explicitly (throw by default, a discriminated result where callers branch), context and `cause` kept, no silent failures
208
+ - `solid-principles.mdc` — SRP, OCP, DIP and the function-design thresholds the code-quality reviewer applies (load for any task that creates or grows classes, services or functions)
209
209
 
210
210
  **Load by task type:**
211
211
 
@@ -90,7 +90,7 @@ not a hardcoded `cat`/`ls`/`find` invocation).
90
90
  - Fixture/factory patterns (how test data is created)
91
91
  - Before/after hook usage
92
92
 
93
- **1.2b Load test-convention rules, project first.** Read the testing rules the task touches (`testing-conventions`, `tdd-workflow`, and any rule the task names) in this order: `.metaproject/rules/project/<rule>.mdc` first, then `.metaproject/rules/core/<rule>.mdc`. A project rule with the same name replaces the bundled one; a project rule with a different name adds to it. Take the list from `workspace.resolved_context_file` when the task carries one, otherwise run `keryx skills resolve-context --for test --files <target_files, comma-joined> --task-text '<task description, each ' written as '\''>' --out <project-relative path>` (`--task-text` lets a declared keyword promote a document); read its `must_read` entries in full and record each in `project_context_applied` with the resolver's `sha256`. An entry with reason `condition:glob:<g>` or `condition:keyword:<k>` was promoted by a declared condition: read its anchored section, and its item needs the `path`, the `sha256` of the whole file as pinned, the `anchor` exactly as declared, a `summary` (at least 40 characters, in your own words, naming at least three distinct words of five or more letters from that section) and `how` `read` or `followed`, never `n/a`. Where a project test convention and a bundled one conflict, the project wins. A project skill only supplements these steps; it never replaces this skill.
93
+ **1.2b Load test-convention rules, project first.** Read the testing rules the task touches (`tdd-workflow`, the installed stack pack's `testing.mdc`, and any rule the task names) in this order: `.metaproject/rules/project/<rule>.mdc` first, then `.metaproject/rules/core/<rule>.mdc`. A project rule with the same name replaces the bundled one; a project rule with a different name adds to it. Take the list from `workspace.resolved_context_file` when the task carries one, otherwise run `keryx skills resolve-context --for test --files <target_files, comma-joined> --task-text '<task description, each ' written as '\''>' --out <project-relative path>` (`--task-text` lets a declared keyword promote a document); read its `must_read` entries in full and record each in `project_context_applied` with the resolver's `sha256`. An entry with reason `condition:glob:<g>` or `condition:keyword:<k>` was promoted by a declared condition: read its anchored section, and its item needs the `path`, the `sha256` of the whole file as pinned, the `anchor` exactly as declared, a `summary` (at least 40 characters, in your own words, naming at least three distinct words of five or more letters from that section) and `how` `read` or `followed`, never `n/a`. Where a project test convention and a bundled one conflict, the project wins. A project skill only supplements these steps; it never replaces this skill.
94
94
 
95
95
  **1.3 Identify test file naming:**
96
96
  - Pattern (`<component>.test.ts`, `<service>.spec.ts`, `test_<module>.py`) and location (co-located, or `__tests__`/`tests/`)
@@ -26,7 +26,7 @@ license: "MIT"
26
26
 
27
27
  Specialized reviewer for **architectural patterns and structural decisions**.
28
28
  Reviews only changes introduced in the current branch (merge-base to HEAD).
29
- Focuses exclusively on verifiable structural violations — not style opinions or hypothetical concerns. Its inputs are the reviewer payload only; session memory and earlier conversation are not inputs. It runs no command unless its payload's `allowed_tools` says `run-tests`, except the read-only `git log`, `git blame` and `git show` where its host gives a read-only child git (keryx shell does not: there the payload supplies the history), and the read-only layer commands the orchestrator lists (`keryx gdgraph affected|find`, `keryx test related`, `keryx wiki ask`, `keryx memory search`, `keryx ctx rg|read`); it never writes in the reviewed tree.
29
+ Focuses exclusively on verifiable structural violations — not style opinions or hypothetical concerns. Its inputs are the reviewer payload only; session memory and earlier conversation are not inputs. It runs no command unless its payload's `allowed_tools` says `run-tests`, except the read-only `git log`, `git blame` and `git show` where its host gives a read-only child git (keryx shell does not: there the payload supplies the history).
30
30
 
31
31
  ---
32
32
 
@@ -26,7 +26,7 @@ license: "MIT"
26
26
 
27
27
  Focused backend reviewer covering NestJS patterns, REST API design, database access patterns,
28
28
  and TypeScript correctness for service-layer code. This skill does NOT duplicate security or
29
- performance checks — those belong to `review-security-code` and `review-performance`. Its inputs are the reviewer payload only; session memory and earlier conversation are not inputs. It runs no command unless its payload's `allowed_tools` says `run-tests`, except the read-only `git log`, `git blame` and `git show` where its host gives a read-only child git (keryx shell does not: there the payload supplies the history), and the read-only layer commands the orchestrator lists (`keryx gdgraph affected|find`, `keryx test related`, `keryx wiki ask`, `keryx memory search`, `keryx ctx rg|read`); it never writes in the reviewed tree.
29
+ performance checks — those belong to `review-security-code` and `review-performance`. Its inputs are the reviewer payload only; session memory and earlier conversation are not inputs. It runs no command unless its payload's `allowed_tools` says `run-tests`, except the read-only `git log`, `git blame` and `git show` where its host gives a read-only child git (keryx shell does not: there the payload supplies the history).
30
30
 
31
31
  ---
32
32
 
@@ -128,8 +128,7 @@ git diff --name-status "${BASE_SHA}" && git diff "${BASE_SHA}" && git ls-files -
128
128
  - Missing pagination on a list endpoint flagged as `major` when no obvious bound exists
129
129
 
130
130
  **Error handling**
131
- - Async controller methods must have error handling: either `try/catch` or a global exception filter
132
- - Unhandled promise rejections (async method without try/catch, no global filter) — **blocker**
131
+ - Unhandled promise rejections are rated by `.metaproject/rules/core/error-handling.mdc` (**Review severities**): a rejection Nest's exception layer answers with an error response is not a crash; rate that response
133
132
  - Exception messages must not leak internal details (stack traces, ORM error strings) to the HTTP response — leaking is rated by the stack-trace row of the conditions table
134
133
  - NestJS built-in exceptions (`NotFoundException`, `BadRequestException`, etc.) preferred over generic `Error`
135
134
 
@@ -166,7 +165,7 @@ git diff --name-status "${BASE_SHA}" && git diff "${BASE_SHA}" && git ls-files -
166
165
 
167
166
  - No `any` in new code — suggest `unknown` with type guards, or correct typed return
168
167
  - Public service methods must have explicit return types (`Promise<UserDto>`, not inferred)
169
- - Service contracts expressed as interfaces (`IUserService`), not just class implementations
168
+ - Interfaces only at an I/O or substitution boundary, named without an `I` prefix (`solid-principles.mdc`, D)
170
169
  - No `as any` or unsafe casts (`as unknown as T`) without a comment explaining why
171
170
  - `@ts-ignore` / `@ts-expect-error` without explanation comment — flag as `minor`
172
171
 
@@ -209,7 +208,6 @@ is, and a condition that cannot name one is not a `blocker`.
209
208
  | Leaking stack trace / raw ORM error to API response | `blocker` with an attack vector stated (what is disclosed, to whom, through which entry point); `major` when the leak is shown reaching a response; else `info` | Exploitable vulnerability only when the vector is shown; a shown leak is a wrong outcome |
210
209
  | Missing auth guard on an endpoint that should be protected | `blocker` with an attack vector stated (caller, entry point, impact); `major` with a named caller and the wrong outcome it gets; else `info` | Exploitable vulnerability only when the vector is shown |
211
210
  | `REQUEST`-scoped provider injected into a `Singleton` | `blocker` | Data corruption — one request's state is served to another |
212
- | Unhandled promise rejection in a controller method | `blocker` | Crash |
213
211
  | `NOT NULL` column added without a default to a populated table | `major` — the migration fails on deploy against existing rows; `blocker` only where the tool shown truncates or backfills wrong values | Data loss only when rows are shown destroyed or wrong. Same rating as `review-highload` |
214
212
  | N+1 query (relation loaded in a loop) | `major` with the reachable loop size or call frequency named; else `info` | Cost stated with its frequency; degradation, not an outage |
215
213
  | Missing transaction on a multi-step atomic mutation | `major` — `blocker` where a partial write corrupts persisted state | The outcome decides |