@leing2021/super-pi 0.31.0 → 0.32.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/README.md CHANGED
@@ -190,9 +190,9 @@ Commit everything to git — these files are the project's traceable memory.
190
190
  | Tools | 12 CE + 10 Pi built-in |
191
191
  | Rules | 78 |
192
192
  | TypeScript lines | ~4,100 |
193
- | Tests | 180 (727 assertions) |
193
+ | Tests | 219 (882 assertions) |
194
194
 
195
- Rules in `rules/` cover 11 common topics + language-specific sets (TypeScript, Rust, Go, Python, Java, Kotlin, C++, C#, Dart, Swift, Perl, PHP). Project-level overrides take priority.
195
+ Rules in `rules/` cover 12 common topics + language-specific sets (TypeScript, Rust, Go, Python, Java, Kotlin, C++, C#, Dart, Swift, Perl, PHP). Project-level overrides take priority; projects can also add new languages via a project-level `rules/language-detection.md` marker map (append + same-marker wins).
196
196
 
197
197
  ---
198
198
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leing2021/super-pi",
3
- "version": "0.31.0",
3
+ "version": "0.32.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Pi-native Compound Engineering package for iterative development workflows",
package/rules/README.md CHANGED
@@ -17,34 +17,24 @@ rules/
17
17
  ├── typescript/ # TypeScript/JavaScript specific
18
18
  ├── python/ # Python specific
19
19
  ├── golang/ # Go specific
20
- ├── web/ # Web and frontend specific
20
+ ├── rust/ # Rust specific
21
+ ├── java/ # Java specific
22
+ ├── kotlin/ # Kotlin specific
21
23
  ├── swift/ # Swift specific
22
- └── php/ # PHP specific
24
+ ├── csharp/ # C# specific
25
+ ├── cpp/ # C++ specific
26
+ ├── dart/ # Dart specific
27
+ ├── php/ # PHP specific
28
+ ├── perl/ # Perl specific
29
+ └── web/ # Web and frontend specific
23
30
  ```
24
31
 
25
32
  - **common/** contains universal principles — no language-specific code examples.
26
33
  - **Language directories** extend the common rules with framework-specific patterns, tools, and code examples. Each file references its common counterpart.
27
- - **`review-checklist.md`** (optional, per language) holds precise, actionable defect patterns for code review — distinct from `patterns.md` which holds reusable design patterns. Currently used by `golang/` and `python/`.
34
+ - **`review-checklist.md`** (optional, per language) holds precise, actionable defect patterns for code review — distinct from `patterns.md` which holds reusable design patterns. Currently used by `golang/`, `python/`, and `typescript/`.
28
35
 
29
36
  ## Installation
30
37
 
31
- ### Option 1: Install Script (Recommended)
32
-
33
- ```bash
34
- # Install common + one or more language-specific rule sets
35
- ./install.sh typescript
36
- ./install.sh python
37
- ./install.sh golang
38
- ./install.sh web
39
- ./install.sh swift
40
- ./install.sh php
41
-
42
- # Install multiple languages at once
43
- ./install.sh typescript python
44
- ```
45
-
46
- ### Option 2: Manual Installation
47
-
48
38
  > **Important:** Copy entire directories — do NOT flatten with `/*`.
49
39
  > Common and language-specific directories contain files with the same names.
50
40
  > Flattening them into one directory causes language-specific files to overwrite
@@ -75,7 +65,7 @@ Language-specific rule files reference relevant skills where appropriate. Rules
75
65
 
76
66
  ## Adding a New Language
77
67
 
78
- To add support for a new language (e.g., `rust/`):
68
+ To add support for a new language (e.g., `zig/`):
79
69
 
80
70
  1. Create a `rules/rust/` directory
81
71
  2. Add files that extend the common rules:
@@ -93,6 +83,8 @@ To add support for a new language (e.g., `rust/`):
93
83
 
94
84
  For non-language domains like `web/`, follow the same layered pattern when there is enough reusable domain-specific guidance to justify a standalone ruleset.
95
85
 
86
+ End users of this package do not need to modify it to support a new language: create a project-level `{repo-root}/rules/<lang>/` directory and a marker row in `{repo-root}/rules/language-detection.md` — see "Project-level extensions" in `skills/references/language-detection.md`.
87
+
96
88
  ## Rule Priority
97
89
 
98
90
  When language-specific rules and common rules conflict, **language-specific rules take precedence** (specific overrides general). This follows the standard layered configuration pattern (similar to CSS specificity or `.gitignore` precedence).
@@ -0,0 +1,80 @@
1
+ ---
2
+ paths:
3
+ - "**/*.ts"
4
+ - "**/*.tsx"
5
+ - "**/*.js"
6
+ ---
7
+ # TypeScript Review Checklist
8
+
9
+ > TypeScript/JavaScript-specific defect patterns for code review. Used together with [common/code-review.md](../common/code-review.md).
10
+ > **Precision over recall:** only raise an issue when confident it is a real defect. Stay silent when surrounding context is unclear. Treat security/correctness as blocking; style/idiom as non-blocking.
11
+
12
+ ## Null and Undefined Handling
13
+
14
+ - Optional chaining missing where a value can legitimately be `null`/`undefined`: `obj.prop.deep` crashing when `obj.prop` is optional. Use `obj?.prop` or an explicit guard.
15
+ - Non-null assertion (`!`) used to silence the compiler without evidence the value exists — every `!` must rest on a proven invariant (checked above, or constructed non-null).
16
+ - Array access `arr[i]` assumed defined when the index can be out of bounds or the array empty (`noUncheckedIndexedAccess` reveals these; without it, check length first).
17
+ - `value ?? fallback` vs `value || fallback` confusion: `||` also swallows `0`, `""`, `false`. Do not report when the falsy values are intended to fall through.
18
+
19
+ ## Type Safety
20
+
21
+ - `any` leaking through a public API boundary (parameter, return type, or generic default) instead of `unknown` + narrowing.
22
+ - Unsafe assertions (`as Foo`) on data crossing a trust boundary (`JSON.parse`, `fetch`, user input) without a runtime validation step.
23
+ - Type assertions that claim more than they prove: `x as Foo` followed by unconditional `x.bar` access.
24
+ - Object spread of optional sources (`{...defaults, ...partial}`) when `partial` may contain explicit `undefined` values that override defaults; merge field-by-field when the distinction matters.
25
+ - Do not report `any` in test fixtures, or in third-party type shims the project has accepted.
26
+
27
+ ## Async and Promise Handling
28
+
29
+ - Floating promises: promise created without `await`, `.then`, `.catch`, or `void` — rejections vanish silently. Especially fire-and-forget `async` calls in event handlers.
30
+ - `async` functions without any `await` — callers may not expect a promise; drop `async` or await inside.
31
+ - Sequential `await` in a loop over independent operations where `Promise.all` (or `allSettled` when partial failure is acceptable) is correct — confirm independence before flagging.
32
+ - `Promise.all` on operations where one rejection should not cancel the rest; `Promise.allSettled` is the right tool.
33
+ - `forEach` with an `async` callback — it does not wait; use `for...of` + `await`, or `Promise.all(map(...))`.
34
+ - Missing `try/catch` (or `.catch`) around awaited calls whose rejection is a realistic user-visible failure mode.
35
+ - Do not report when an upstream caller demonstrably handles the rejection, or the runtime treats unhandled rejections as fatal.
36
+
37
+ ## Error Handling
38
+
39
+ - Empty `catch {}` that swallows errors without logging or re-raising.
40
+ - `catch` blocks that lose the original error; wrap with `new Error(msg, { cause: e })` or a typed error class instead.
41
+ - Broad `try` wrapping many statements where only one line can throw, hiding the real failure point.
42
+ - Errors converted to sentinel values (`return null` / `-1`) without the caller checking; prefer throwing or a result type.
43
+ - Do not report re-throws at top-level CLI handlers or framework-managed boundaries (Express error middleware, React error boundaries).
44
+
45
+ ## Equality and Value Semantics
46
+
47
+ - `NaN` compared with `===`/`==` (always false); use `Number.isNaN`.
48
+ - Loose `==` against non-null literals (except the idiomatic `x == null` covering both null and undefined).
49
+ - Object/array compared with `===` where value equality was intended.
50
+ - `Object.is` semantics surprising at `0`/`-0` and `NaN` — flag only when those values are realistic.
51
+
52
+ ## Resource Management
53
+
54
+ - Event listeners, timers (`setInterval`/`setTimeout`), subscriptions, or observers added without removal on teardown/dispose paths.
55
+ - Missing `AbortController` on long-lived fetches that can be cancelled (unmount, navigation, shutdown).
56
+ - DB connections / file handles opened without `finally` cleanup or an owning pool.
57
+ - Do not report short-lived scripts, or teardown already managed by a framework lifecycle.
58
+
59
+ ## Concurrency and Shared State
60
+
61
+ Only flag with evidence of concurrent access (confirm via `code_search`):
62
+ - Module-level mutable state (singletons, caches, module-scoped arrays) mutated across requests or sessions.
63
+ - Check-then-act on shared state without synchronization; React stale-closure writes (`setX(x + 1)` in async callbacks) where `setX(v => v + 1)` is required.
64
+ - `await` gaps between read and write of shared in-memory state.
65
+ - Do not report single-threaded local variables or immutable data.
66
+
67
+ ## Performance
68
+
69
+ Confirm hot path and data scale before flagging:
70
+ - Spread-in-loop `O(n²)` accumulation (`arr = [...arr, item]`); accumulate into a local array instead.
71
+ - Repeated expensive computation without memoization when inputs are stable and the call is hot.
72
+ - `.filter().map()` double pass where a single loop or `.reduce` is clearer and faster.
73
+ - Synchronous heavy work (`JSON.parse` of large payloads, `fs.readFileSync`) on request paths; move async.
74
+ - Do not report micro-optimizations in cold paths, or code the project has profiled and accepted.
75
+
76
+ ## Not for this rule
77
+
78
+ - Do not report style issues the formatter/linter (`prettier`, `eslint`, `tsc --strict`) already catches, unless the diff shows a concrete user-visible consequence those tools miss.
79
+ - Do not report missing types in `.d.ts` shims, or `// @ts-expect-error` sites that are deliberate and localized.
80
+ - Do not report dead code intentionally kept for future use.
@@ -11,11 +11,7 @@ See [shared pipeline instructions](../references/pipeline-config.md) for model r
11
11
 
12
12
  ## Core rules
13
13
 
14
- 1. Load project rules (4 steps):
15
- - Load `rules/common/development-workflow.md` and `rules/common/testing.md`
16
- - Detect project language via [language detection](../references/language-detection.md)
17
- - Load matching language-specific rules
18
- - If frontend/browser concerns, also load `rules/web/` files
14
+ 1. Load project rules before writing any code: detect language via repo markers (map in Workflow step 2), then load `rules/common/development-workflow.md`, `rules/common/testing.md`, matching `rules/{lang}/` files, plus `rules/web/` for frontend/browser concerns. Emit a `Rules loaded:` manifest — **no manifest, no implementation**
19
15
  2. **Priority:** project-level `{repo-root}/rules/` overrides package defaults
20
16
  3. **Distinguish input:** plan path vs bare prompt
21
17
  4. Derive tasks from plan **implementation units**
@@ -79,19 +75,24 @@ If the same tool, command, or implementation unit fails 3 consecutive times, sto
79
75
 
80
76
  ## Workflow
81
77
 
82
- 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`, `blocker`, `verification`, `activeRules` as starting point. If not found, proceed normally. Read `CONTEXT.md` if it exists at root — see `../references/domain-language.md`.
83
- 2. Detect input type (plan path vs bare prompt)
84
- 3. Read implementation units if plan path
85
- 4. Load `session_checkpoint` to skip completed units
86
- 5. Use `task_splitter` for dependency analysis
87
- 6. Execute: **inline mode**all units run in the current session
88
- 7. Follow TDD per unit: RED minimal code → GREEN → refactor → unit-level **verification**
89
- 8. **Source-driven gate:** Before implementing framework/library-specific code, verify the API or pattern against official documentation. Flag unverified patterns as UNVERIFIED in output.
90
- 9. Record progress via `references/progress-update-format.md`
91
- 9. Save `session_checkpoint` after each unit
92
- 10. On failure: `session_checkpoint` `fail` `retry` follow strategy
93
- 11. Provide completion report (see `references/completion-report.md`)
94
- 12. **Save handoff**: `context_handoff save` with current stage, next stage, activeFiles, blocker, verification, activeRules
95
- 13. Handoff to `04-review` using `references/handoff.md`
78
+ 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`, `blocker`, `verification`, `activeRules` as starting point; `activeRules` may already list loaded rules — verify against the repo, do not blindly trust. If not found, proceed normally. Read `CONTEXT.md` if it exists at root — see `../references/domain-language.md`.
79
+ 2. **Load project rules** (blocking no implementation before this completes):
80
+ - Detect language: merge `{repo-root}/rules/language-detection.md` (project-level map, same marker wins) with the built-in table: `tsconfig.json`/`package.json`→typescript, `Cargo.toml`→rust, `go.mod`→golang, `pyproject.toml`/`requirements.txt`→python, `pom.xml`/`build.gradle(.kts)`→java/kotlin; others in [language detection](../references/language-detection.md)
81
+ - Check `{repo-root}/rules/` first (overrides package defaults); then load `rules/common/development-workflow.md`, `rules/common/testing.md`, matching `rules/{lang}/` files, `rules/web/` only for frontend/browser concerns
82
+ - Emit manifest before any code: `Rules loaded: language=<lang> (via <marker>[, project-level map]), common=<files>, lang=<files>, web=<files or N/A>`
83
+ - **Same-session re-entry:** if the transcript already contains a `Rules loaded:` manifest for the same language, do not re-read the rule files reuse them, cite the earlier manifest, and note the skip
84
+ 3. Detect input type (plan path vs bare prompt)
85
+ 4. Read implementation units if plan path
86
+ 5. Load `session_checkpoint` to skip completed units
87
+ 6. Use `task_splitter` for dependency analysis
88
+ 7. Execute: **inline mode** all units run in the current session
89
+ 8. Follow TDD per unit: RED → minimal code → GREEN → refactor → unit-level **verification**
90
+ 9. **Source-driven gate:** Before implementing framework/library-specific code, verify the API or pattern against official documentation. Flag unverified patterns as UNVERIFIED in output.
91
+ 10. Record progress via `references/progress-update-format.md`
92
+ 11. Save `session_checkpoint` after each unit
93
+ 12. On failure: `session_checkpoint` `fail` → `retry` → follow strategy
94
+ 13. Provide completion report (see `references/completion-report.md`) — include the `Rules applied` section
95
+ 14. **Save handoff**: `context_handoff save` with current stage, next stage, activeFiles, blocker, verification, activeRules (carry loaded rules in `activeRules`)
96
+ 15. Handoff to `04-review` using `references/handoff.md`
96
97
 
97
98
  Before finishing this skill, apply the completion checklist in [shared pipeline instructions](../references/pipeline-config.md).
@@ -18,6 +18,12 @@ Brief description of what was completed.
18
18
  - Created: `path/to/file`
19
19
  - Modified: `path/to/file`
20
20
 
21
+ ## Rules applied
22
+
23
+ | Language | Rule files | Detected via |
24
+ |---|---|---|
25
+ | typescript | `rules/typescript/coding-style.md`, `rules/typescript/testing.md` | `tsconfig.json` |
26
+
21
27
  ## Commands run
22
28
 
23
29
  | Command | Result |
@@ -44,6 +50,7 @@ All tests pass. Build succeeds. No regressions.
44
50
 
45
51
  **Completed:** list of unit names
46
52
  **Files changed:** all created/modified files
53
+ **Rules applied:** language + rule files loaded
47
54
  **Commands run:** all verification commands
48
55
  **Verification:** pass/fail status for each
49
56
 
@@ -11,11 +11,7 @@ See [shared pipeline instructions](../references/pipeline-config.md) for model r
11
11
 
12
12
  ## Core rules
13
13
 
14
- 1. Load project rules (4 steps):
15
- - Load `../../rules/common/code-review.md` and `../../rules/common/code-smells.md`
16
- - Detect language from changed files via [language detection](../references/language-detection.md)
17
- - Load matching language-specific rules (e.g., `rules/typescript/`)
18
- - If frontend/browser changes, also load `rules/web/` files
14
+ 1. Load project rules before producing findings (detailed in Workflow step 3): load `../../rules/common/code-review.md` + `code-smells.md`, detect language from changed files, load matching `rules/{lang}/` files including `review-checklist.md` (mark `missing (fell back to common)` when absent), plus `rules/web/` for frontend/browser changes. Emit a `Rules loaded:` manifest — **no manifest, no findings**
19
15
  2. **Priority:** project-level `{repo-root}/rules/` overrides package defaults
20
16
  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
17
  4. Determine **diff scope** before selecting reviewers
@@ -60,13 +56,18 @@ Code review is **technical evaluation**, not social performance:
60
56
 
61
57
  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`.
62
58
  2. Determine diff scope — prefer `branch`/`base` from latest handoff if present; else from explicit target; else ask user
63
- 3. Collect stats (files, insertions, deletions) call `review_router`
64
- 4. Read matching plan artifact; if absent, follow [`references/spec-source-detection.md`](references/spec-source-detection.md) to probe brainstorm and commit issue refs
65
- 5. Run solution search
66
- 6. Apply each reviewer persona from `review_router`
67
- 7. Merge into structured findings
68
- 8. Verify each finding against codebase
69
- 9. Apply autofixes, re-run tests, re-review if needed
59
+ 3. **Load project rules** (blocking no findings before this completes):
60
+ - Detect language from changed files (`.ts`/`.tsx`→typescript, `.py`→python, `.go`→golang, `.rs`→rust, `.java`→java) or repo markers, merging `{repo-root}/rules/language-detection.md` (project-level map, same marker wins); full map in [language detection](../references/language-detection.md). Mixed-language diffs: load per language
61
+ - Check `{repo-root}/rules/` first (overrides package defaults); load `rules/common/code-review.md`, `code-smells.md`, matching `rules/{lang}/` files including `review-checklist.md`, `rules/web/` for frontend/browser changes
62
+ - Emit manifest before any finding: `Rules loaded: language=<lang> (via <files/markers>[, project-level map]), common=<files>, lang=<files>, web=<files or N/A>`
63
+ - **Same-session re-entry:** if the transcript already contains a `Rules loaded:` manifest for the same language, do not re-read the rule files — reuse them, cite the earlier manifest, and note the skip
64
+ 4. Collect stats (files, insertions, deletions) → call `review_router`
65
+ 5. Read matching plan artifact; if absent, follow [`references/spec-source-detection.md`](references/spec-source-detection.md) to probe brainstorm and commit issue refs
66
+ 6. Run solution search
67
+ 7. Apply each reviewer persona from `review_router`
68
+ 8. Merge into structured findings — include `rules applied` in the review summary (see `references/findings-schema.md`)
69
+ 9. Verify each finding against codebase
70
+ 10. Apply autofixes, re-run tests, re-review if needed
70
71
 
71
72
  ## Optional: QA Test Mode
72
73
 
@@ -15,3 +15,11 @@ Optional fields:
15
15
  - `autofixable` — whether this finding can be automatically fixed
16
16
  - `autofix applied` — whether the autofix was applied
17
17
  - `autofix summary` — description of what was changed
18
+
19
+ ## Review summary block
20
+
21
+ End every review with a summary that includes:
22
+
23
+ - `rules applied` — language + rule files actually loaded for this review (mirror of the `Rules loaded:` manifest)
24
+ - findings count by severity: `high / moderate / low`
25
+ - verification status of confirmed findings (fixed / pushed back / deferred)
@@ -26,6 +26,18 @@ Rules are loaded from two locations with priority:
26
26
 
27
27
  Check project-level first. If a file exists there for the topic, use it. Otherwise fall back to package-level.
28
28
 
29
+ ## Project-level extensions
30
+
31
+ A repo can extend the built-in marker table at the top of this file by creating `{repo-root}/rules/language-detection.md` with additional rows in the same table format (`File(s)` | `Language` | `Rules directory`). Use it when your project uses a language that is not in the built-in table.
32
+
33
+ Merge semantics (applied before detection):
34
+
35
+ - **Append:** project-level rows add new languages on top of the built-in table.
36
+ - **Same marker → project-level wins:** if a marker file appears in both tables, the project-level row replaces the built-in one.
37
+ - **Fall back:** if the project-level file is missing, empty, or a row is malformed, the built-in table applies — behavior never changes silently. A row pointing at a rules directory that does not exist is detected as the language but surfaces as `lang: missing` in the `Rules loaded:` manifest.
38
+
39
+ The `Rules loaded:` manifest must state the mapping source, e.g. `language=zig (via build.zig, project-level map)` so a broken project-level row is visible in output.
40
+
29
41
  ## Rule precedence
30
42
 
31
43
  ```
@@ -85,6 +85,16 @@ Next step mapping:
85
85
  - `04-review` → `/skill:05-learn`
86
86
  - `05-learn` → `Completed`
87
87
 
88
+ ## End of skill: completion checklist
89
+
90
+ Before declaring a stage complete, verify every item. A failed item means not done — fix it or stop and report:
91
+
92
+ 1. **Rules loaded and listed** — for stages whose workflow includes a rules-loading step (02-plan, 03-work, 04-review), session output contains a `Rules loaded:` manifest (language + rule files). If missing, load the rules now before finishing.
93
+ 2. **All workflow steps executed** — every numbered step in the stage's SKILL.md ran, or was explicitly skipped with a stated reason.
94
+ 3. **Artifacts saved** — plan / checkpoint / findings / handoff written to their artifact paths.
95
+ 4. **Verification evidence recorded** — exact command plus result in output, not a claim of success.
96
+ 5. **Pipeline Status + Context Status blocks output** — both present, real values, no placeholders.
97
+
88
98
  ### Handoff-lite template
89
99
 
90
100
  When a stage produces or updates handoff-lite, use this evidence-first structure and keep it concise (target <= 1500 tokens):