@leing2021/super-pi 0.28.0 → 0.30.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.json
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Code Smells — Fowler Baseline
|
|
2
|
+
|
|
3
|
+
A fixed baseline of code smells (Fowler, _Refactoring_, ch.3) for the **Standards axis** of review. Applies even when a repo documents no conventions. Used by `04-review`, and by `03-work` REFACTOR phase as a check list.
|
|
4
|
+
|
|
5
|
+
## Two binding rules
|
|
6
|
+
|
|
7
|
+
1. **The repo overrides.** A documented repo standard (in `rules/` or `CODING_STANDARDS.md` / `CONTRIBUTING.md`) always wins. Where a repo endorses something this baseline would flag, suppress the smell.
|
|
8
|
+
2. **Always a judgement call.** Each smell is a labelled heuristic — report it as "possible Feature Envy", never a hard violation. Skip anything tooling (compiler, formatter, linter, type checker) already enforces.
|
|
9
|
+
|
|
10
|
+
## Severity mapping
|
|
11
|
+
|
|
12
|
+
These smells are orthogonal to the P0/P1/P2 severity ladder:
|
|
13
|
+
|
|
14
|
+
- Default **P2** (建议) — pure maintainability/readability smell with no correctness impact.
|
|
15
|
+
- Escalate to **P1** (重要) when the smell is endorsed by a repo doc, or when it materially harms this codebase's data flow / testability.
|
|
16
|
+
- Escalate to **P0** (阻断) only when the smell coincides with a real defect (e.g. Duplicated Code that diverges and causes a bug).
|
|
17
|
+
|
|
18
|
+
## The 12 smells (diff-friendly)
|
|
19
|
+
|
|
20
|
+
Each entry reads *what it is* → *how to fix*. Match against the diff, not the whole file.
|
|
21
|
+
|
|
22
|
+
- **Mysterious Name** — a function, variable, or type whose name doesn't reveal what it does or holds. → rename it; if no honest name comes, the design's murky.
|
|
23
|
+
- **Duplicated Code** — the same logic shape appears in more than one hunk or file in the change. → extract the shared shape, call it from both.
|
|
24
|
+
- **Feature Envy** — a method that reaches into another object's data more than its own. → move the method onto the data it envies.
|
|
25
|
+
- **Data Clumps** — the same few fields or params keep travelling together (a type wanting to be born). → bundle them into one type, pass that.
|
|
26
|
+
- **Primitive Obsession** — a primitive or string standing in for a domain concept that deserves its own type. → give the concept its own small type.
|
|
27
|
+
- **Repeated Switches** — the same `switch`/`if`-cascade on the same type recurs across the change. → replace with polymorphism, or one map both sites share.
|
|
28
|
+
- **Shotgun Surgery** — one logical change forces scattered edits across many files in the diff. → gather what changes together into one module.
|
|
29
|
+
- **Divergent Change** — one file or module is edited for several unrelated reasons. → split so each module changes for one reason.
|
|
30
|
+
- **Speculative Generality** — abstraction, parameters, or hooks added for needs the spec doesn't have. → delete it; inline back until a real need shows.
|
|
31
|
+
- **Message Chains** — long `a.b().c().d()` navigation the caller shouldn't depend on. → hide the walk behind one method on the first object.
|
|
32
|
+
- **Middle Man** — a class or function that mostly just delegates onward. → cut it, call the real target direct.
|
|
33
|
+
- **Refused Bequest** — a subclass or implementer that ignores or overrides most of what it inherits. → drop the inheritance, use composition.
|
|
34
|
+
|
|
35
|
+
## What is deliberately NOT here
|
|
36
|
+
|
|
37
|
+
These are Fowler's file-level smells, **excluded from the review baseline** because they read against a whole file, not a diff — weak signal in a diff-based review. They belong in architecture audit (`references/module-design.md`) and `03-work` REFACTOR, not in `04-review` Standards axis:
|
|
38
|
+
|
|
39
|
+
- Long Method, Large Class, Long Parameter List, Data Class, Dead Code, Comments, Divergent … (full file-level set).
|
|
40
|
+
|
|
41
|
+
If a review surfaces one of these against the whole file anyway, report it as an **architecture-axis** finding using `module-design.md` vocabulary (shallow module, missing seam), not as a smell.
|
|
@@ -12,21 +12,22 @@ See [shared pipeline instructions](../references/pipeline-config.md) for model r
|
|
|
12
12
|
## Core rules
|
|
13
13
|
|
|
14
14
|
1. Load project rules (4 steps):
|
|
15
|
-
- Load
|
|
15
|
+
- Load `../../rules/common/code-review.md` and `../../rules/common/code-smells.md`
|
|
16
16
|
- Detect language from changed files via [language detection](../references/language-detection.md)
|
|
17
17
|
- Load matching language-specific rules (e.g., `rules/typescript/`)
|
|
18
18
|
- If frontend/browser changes, also load `rules/web/` files
|
|
19
19
|
2. **Priority:** project-level `{repo-root}/rules/` overrides package defaults
|
|
20
|
-
3.
|
|
21
|
-
4.
|
|
22
|
-
5.
|
|
23
|
-
6.
|
|
20
|
+
3. **Standards axis baseline:** apply [`../../rules/common/code-smells.md`](../../rules/common/code-smells.md) (Fowler smell baseline). Two binding rules: a documented repo standard overrides the baseline; every smell is a judgement call (report as "possible Feature Envy"), never a hard violation. Map severity via P0/P1/P2 — default P2, escalate when a repo doc endorses it or it harms data flow/testability.
|
|
21
|
+
4. Determine **diff scope** before selecting reviewers
|
|
22
|
+
5. Use **`review_router`** tool to select reviewer personas based on diff metadata
|
|
23
|
+
6. Read relevant **plan** artifact when exists
|
|
24
|
+
7. Run solution search (see `references/solution-search.md`):
|
|
24
25
|
- Extract keywords → `grep -rl "tags:.*keyword" docs/solutions/ ~/.pi/agent/docs/solutions/`
|
|
25
26
|
- Read **frontmatter** only (first 15 lines) of matches → score by severity + tag relevance
|
|
26
27
|
- Fully read top 3 candidates
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
8. **Spec axis:** determine spec source in priority order — (a) plan artifact; (b) brainstorm artifact (trace back to original wording to catch directional misunderstandings the plan encoded); (c) issue references in commit messages (`git log <base>..HEAD --oneline`, scan for `#123` / `Closes #45` / `!67`) — identify the ref and ask the user whether to treat it as spec source, do **not** auto-fetch; (d) skip if none. Against the chosen spec, report **missing** requirements, **scope creep** (unrequested behaviour), and **wrong implementation** (looks done but isn't).
|
|
29
|
+
9. Produce structured findings using `references/findings-schema.md`
|
|
30
|
+
10. **Autofixable findings:** apply and re-review (max 3 iterations)
|
|
30
31
|
|
|
31
32
|
## Review discipline
|
|
32
33
|
|
|
@@ -58,9 +59,9 @@ Code review is **technical evaluation**, not social performance:
|
|
|
58
59
|
## Workflow
|
|
59
60
|
|
|
60
61
|
1. **Load context**: consume latest handoff before any broad file reads — `context_handoff load` or read `.context/compound-engineering/handoffs/latest.md`. If found, use `activeFiles`, `artifacts.plan` as starting point. If not found, proceed normally. Read `CONTEXT.md` if it exists at root — see `../references/domain-language.md`.
|
|
61
|
-
2. Determine diff scope
|
|
62
|
+
2. Determine diff scope — prefer `branch`/`base` from latest handoff if present; else from explicit target; else ask user
|
|
62
63
|
3. Collect stats (files, insertions, deletions) → call `review_router`
|
|
63
|
-
4. Read matching plan artifact
|
|
64
|
+
4. Read matching plan artifact. If absent, scan commit messages for issue refs (`git log <base>..HEAD --oneline`) and ask user whether to use as spec source — do not auto-fetch
|
|
64
65
|
5. Run solution search
|
|
65
66
|
6. Apply each reviewer persona from `review_router`
|
|
66
67
|
7. Merge into structured findings
|
|
@@ -109,6 +109,10 @@ When a stage produces or updates handoff-lite, use this evidence-first structure
|
|
|
109
109
|
## Recently Accessed Files
|
|
110
110
|
- files recently read or edited
|
|
111
111
|
|
|
112
|
+
## Git Context
|
|
113
|
+
- branch: <current branch or N/A>
|
|
114
|
+
- base: <diff base ref, e.g. main / N/A>
|
|
115
|
+
|
|
112
116
|
## Artifacts
|
|
113
117
|
- requirements: <path or N/A>
|
|
114
118
|
- plan: <path or N/A>
|