regenerate omp port from pi base via port-to-omp
Checks now self-register through the static barrel (src/checks/all.ts) like the pi base: the ?mtime registry-split workaround is gone, check modules and tests are byte-identical to the base, and registration happens in one module graph instance under omp's extension loader.
This commit is contained in:
41
README.md
41
README.md
@@ -2,8 +2,7 @@
|
||||
|
||||
Code hygiene for [omp](https://github.com/oh-my-pi) — isolated
|
||||
sub-agent checks that scan a target, apply fixes, and emit a findings + changes
|
||||
report. Port of the pi extension (was `~/.pi/agent/extensions/pygienium/`);
|
||||
inspired by piolium's sub-agent loops.
|
||||
report. Inspired by piolium's sub-agent loops.
|
||||
|
||||
Pygienium runs **highly-structured hygiene passes** over a repo to clean up the
|
||||
common quality issues LLM-generated code accumulates: restating comments,
|
||||
@@ -70,9 +69,9 @@ resumable — progress is persisted to `<cwd>/.pygienium/run-state.json`.
|
||||
|
||||
## Checks
|
||||
|
||||
The five shipped checks live in [`src/checks/`](./src/checks/) and are
|
||||
auto-discovered on load. `/pygienium-help` lists whichever checks are currently
|
||||
registered, so this table and the live help always agree on the registered set.
|
||||
The five shipped checks live in [`src/checks/`](./src/checks/) and self-register
|
||||
on load. `/pygienium-help` lists whichever checks are currently registered, so
|
||||
this table and the live help always agree on the registered set.
|
||||
|
||||
| Command | Check | Agent | What it fixes |
|
||||
| --- | --- | --- | --- |
|
||||
@@ -99,27 +98,20 @@ git (opt out with `--no-gitignore`).
|
||||
|
||||
## Adding a check
|
||||
|
||||
One file exporting a `check` definition. **No `index.ts` command-wiring changes.**
|
||||
One file + one `registerCheck()` call. **No `index.ts` command-wiring changes.**
|
||||
`index.ts` auto-discovers every `checks/*.ts` (except the registry barrel) at
|
||||
startup, registers each file's `check` export, and `/pygienium-<name>` appears
|
||||
startup, so a new file self-registers and `/pygienium-<name>` appears
|
||||
automatically.
|
||||
|
||||
Check files are **pure data modules** — they export a definition and never
|
||||
import the registry at runtime. Registration happens in `index.ts` from the
|
||||
entry's own registry instance, which keeps a single registry even under omp's
|
||||
extension loader (it cache-busts lazily imported graph modules with an
|
||||
`?mtime` suffix, which would otherwise split the registry into two module
|
||||
instances).
|
||||
|
||||
1. Create `src/checks/<name>.ts` from the template below.
|
||||
2. Edit the `name`, `label`, `description`, the rubric in the scan/fix task
|
||||
builders, and the `gate` precondition.
|
||||
3. Export it as `check`. Done.
|
||||
3. Keep the trailing `registerCheck(<name>Check)`. Done.
|
||||
|
||||
```ts
|
||||
import type { CheckDefinition, CheckScope } from "./registry.js";
|
||||
import { registerCheck, type CheckScope } from "./registry.js";
|
||||
|
||||
export const check = {
|
||||
export const myCheck = {
|
||||
name: "my-check",
|
||||
label: "My check",
|
||||
description: "What it fixes (shown in /pygienium-help).",
|
||||
@@ -129,7 +121,9 @@ export const check = {
|
||||
buildScanTask: (_cwd: string, scope: CheckScope) => `# Task: my-check scan\n…`,
|
||||
buildFixTask: (_cwd: string, scope: CheckScope, findings: string) => `# Task: my-check fix\n…`,
|
||||
gate: (cwd: string) => undefined,
|
||||
} as const satisfies CheckDefinition;
|
||||
} as const;
|
||||
|
||||
registerCheck(myCheck);
|
||||
```
|
||||
|
||||
Reload omp (or `/reload`) and run `/pygienium-help` — `/pygienium-my-check` is
|
||||
@@ -142,7 +136,7 @@ touches command plumbing.
|
||||
Each check is a "mode" running a fixed phase pipeline:
|
||||
|
||||
```
|
||||
registerCheck(def) ← index.ts discovers checks/*.ts `check` exports
|
||||
registerCheck(def) ← checks/*.ts self-register on load
|
||||
│
|
||||
▼
|
||||
/pygienium-<check> ─► runCheck(def) (src/modes/check-runner.ts)
|
||||
@@ -171,10 +165,9 @@ registerCheck(def) ← index.ts discovers checks/*.ts `check` exports
|
||||
`/pygienium-export` are pure reads over it; `/pygienium-all` shares one
|
||||
`RunState` across every check so phases accumulate in one record.
|
||||
- **The registry** (`src/checks/registry.ts`) is the extensibility seam: a
|
||||
module-level `Map` of `CheckDefinition`s. `index.ts` discovers every
|
||||
`checks/*.ts` file, registers its `check` export, then iterates the map and
|
||||
binds one `/pygienium-<name>` command per entry — adding a check is a file
|
||||
with a `check` export, nothing else.
|
||||
module-level `Map` of `CheckDefinition`s. `index.ts` iterates it and binds
|
||||
one `/pygienium-<name>` command per entry, so adding a check is a file +
|
||||
one `registerCheck()` line.
|
||||
- **The footer** (`src/footer.ts`) is the piolium-style pipeline-overview
|
||||
status strip: a single static line in the TUI footer (via
|
||||
`ui.setStatus(key, text)`) listing the full ordered pipeline with the cursor
|
||||
@@ -202,7 +195,7 @@ pygienium/
|
||||
│ ├─ phases.ts ← live chat progress widget + completion-tree helpers
|
||||
│ ├─ footer.ts ← pipeline-overview status strip (TUI footer)
|
||||
│ ├─ modes/check-runner.ts ← the per-check phase pipeline
|
||||
│ └─ checks/ ← one file per check, exporting `check`
|
||||
│ └─ checks/ ← one file per check, self-registering
|
||||
│ ├─ registry.ts ← CheckDefinition + registerCheck
|
||||
│ ├─ comments.ts deep-modules.ts dead-code.ts
|
||||
│ ├─ defensive-guards.ts
|
||||
|
||||
Reference in New Issue
Block a user