/wbRefactor — Live Demo ()
What /wbRefactor would actually do on wb-labs right now. The candidate target files and their tests are real.
1. Live target
| Field | Live value |
|---|---|
| Most-refactor-worthy file in the active plan | core2/packages/wb-core/src/WBC.js (row 3, deferred) |
| Refactor-worthy despite being deferred | Yes — the plan defers row 3 because the architectural shape needs discussion, not because the surgery is unsafe |
| Test coverage on WBC.js | Existing — core2/packages/wb-core/tests/WBC.spec.js (per typical layout) |
| Memory note flagging caution | wbc-ui2-tech-debt.md records the parked nature of certain restructure work |
| Other refactor candidates | tierEnforcement.js (security finding mixed with structural concern); various sibling-package files in core2/packages/wbc-ui2-cdn/ (parked, do not refactor) |
The first row is the most useful — there's a real candidate (WBC.js) where the refactor is deferred, so /wbRefactor would correctly refuse pre-conversation.
2. What each input form would resolve to today
| Input | Live resolution |
|---|---|
/wbRefactor core2/packages/wb-core/src/WBC.js | Would propose decomposition shape; ask for confirmation. Memory-aware caveat: the row is deferred — agent surfaces this and asks if the architectural conversation has happened. |
/wbRefactor core2/packages/wb-core/src/tierEnforcement.js | Would propose strategy-table refactor; flag (but not fix) the security and cleanup findings. |
/wbRefactor core2/packages/wbc-ui2-cdn/src/index.js | Refuse — memory says this package is parked tech debt. Refactoring would re-trigger the dist-folder mismatch conversation. |
/wbRefactor "extract the parser" | Halt — file-required. |
/wbRefactor core2/packages/wb-core/ | Halt — directory targets refused. |
/wbRefactor src/index.js,src/types.ts (atomic) | Permitted if both files exist; atomic transformation. |
3. Per-input behavior, applied live
/wbRefactor has no flags. The behavior matrix is by input shape:
| Input shape | Live behavior |
|---|---|
| Single file with passing tests | Standard refactor flow: propose → confirm → edit → test → report. |
| Single file with no test coverage | Warns prominently; asks to confirm. Suggests adding a test first. |
| File where memory says "parked" | Refuse. Explains why; suggests the architectural conversation as the actual blocker. |
| Two-file atomic target | Both must exist; both succeed or both revert. |
| Directory target | Halt. |
| Free-text only | Halt. |
4. Pipelines
/wbRefactor core2/packages/wb-core/src/WBC.js> /wbRefactor core2/packages/wb-core/src/WBC.js💠 Pipeline The right refusal for WBC.js right now
Running /wbRefactor on the deferred row's target file:
💠 Pipeline The "surface findings, refactor only" pipeline on tierEnforcement.js
Assuming the architectural conversation happened and tierEnforcement.js is on the table for a strategy-table refactor:
💠 Pipeline The atomic two-file move
Hypothetical but realistic: escape.js is a one-function utility and renderString.js is its only consumer. Time to inline:
5. What would refuse today
| Trigger | Live response |
|---|---|
/wbRefactor (no target) | Halt. Refactor is target-required. |
/wbRefactor core2/packages/wb-core/ | Halt. Directory targets refused. |
/wbRefactor "extract the parser" | Halt. File required. |
/wbRefactor core2/packages/wbc-ui2-cdn/src/index.js | Refuse + memory citation (parked tech debt). |
/wbRefactor core2/packages/wb-core/src/WBC.js | Memory-aware refuse: row 3 deferred pending architectural conversation. |
/wbRefactor on a file with no test coverage | Warn prominently; asks to confirm. Suggests /wbTest first if helpers exist. |
/wbRefactor proposal that changes external API | Halt — external API change is a /wbWork job (corresponds to a plan row), not a refactor. |
| Tests fail post-refactor | Auto-revert. Edit-set rolled back atomically. |
The pattern: /wbRefactor is behavior-preserving, target-required, memory-aware, and atomic. No flags, no scope creep, no silent feature additions. It refuses targets that memory marks as parked, and refuses scope shapes (directories, free-text) that would dilute the surgical premise. When unrelated findings surface during scan, they're logged as follow-ups with the right next command — never auto-actioned.
