t1k:cocos:playable:modularize-reuse-scan
| Field | Value |
|---|---|
| Module | playable |
| Version | 0.15.0 |
| Effort | high |
| Tools | — |
Keywords: cpm-package, doc-search, knowledge-retrieval, modularize, playablelabs, reuse, reuse-scan, subsystem
How to invoke
Section titled “How to invoke”/t1k:cocos:playable:modularize-reuse-scan<project-root> [--apply|--json]reuse-scan (Pillar B)
Section titled “reuse-scan (Pillar B)”Classify every local framework-ish subsystem as REUSE (duplicates an upstream foundation
subsystem → swap for a package import), KEEP (game-specific glue), or CONTRIBUTE (novel,
self-contained, general → hand to contribute). Part of the t1k-cocos-playable-modularize set —
obeys the shared CLI contract.
When to invoke
Section titled “When to invoke”- After
structure-auditflags embedded framework (R1 DRIFT): decide which subsystems to reuse. - “Which of our local systems already exist as
@playablelabspackages?” - Before
refactor: produce the REUSE/KEEP/CONTRIBUTE input its migration plan consumes.
Hard dependency — the knowledge-retrieval MCP
Section titled “Hard dependency — the knowledge-retrieval MCP”The REUSE signal requires mcp__knowledge-retrieval__doc_search live in the session.
- If the MCP is absent: the skill MUST error
reuse-scan requires the knowledge-retrieval MCP (mcp.the1studio.org); restart the sessionand exit 3. It MUST NOT report “0 packages found” — that would falsely mark every subsystem CONTRIBUTE (errors over silent fallbacks). - Corpus reality (verified): doc_search indexes the TheOne .NET/Unity API corpus PLUS the Cocos
template’s own subsystems (
objectPool,signalBus,async,gameControl,GameFoundation.*, …). It is NOT a@playablelabsnpm registry. Full contract + how to filter .NET noise:references/doc-search-contract.md.
Module contract (do not re-derive)
Section titled “Module contract (do not re-derive)”Composition is plain import; there is no register(ctx). A REUSE swap replaces
embedded-source imports with the owning package’s import and records the package in playableSync +
assets/packages/@playablelabs/. Install SSOT + the package↔subsystem folder map:
references/playablesync-ssot.md.
Workflow
Section titled “Workflow”- Validate
<project-root>; check the MCP — absent → exit 3 with the restart message. - Enumerate:
node scripts/enumerate-subsystems.cjs <project-root>→ per-subsystem JSON with a self-containment /reuseLikelihoodheuristic (game-coupled = low, self-contained = high). - Query per subsystem: one behaviour-keyword
doc_searcheach (see the contract). Read the top hits’assembly; a high-similarity hit on a known foundation subsystem = “exists upstream”. - Classify via
references/classification-rubric.md(exists-upstream × game-coupled → REUSE / KEEP / CONTRIBUTE). Map REUSE subsystems to their owning package via the folder map. - Report + suggest installs →
reports/; persist JSON. For each REUSE subsystem, the report names the owning@playablelabs/*package and gives an install suggestion — the manual steps (npm/package-managerinstall-package, which appendsplayableSync+ copies toassets/packages/@playablelabs/) so the dev can run it, or so--applycan do it. The REUSE/KEEP/CONTRIBUTE lists are the direct input torefactor(andcontributereads CONTRIBUTE). - (
--applyonly) Decide via AskUserQuestion — with approval, reuse-scan may perform the suggested install via the package-managerinstall-packagehandler (appendplayableSync+ copy the package). It NEVER rewrites game source imports (that isrefactor). Gate per package.
Scripts
Section titled “Scripts”node scripts/enumerate-subsystems.cjs <project-root> # subsystem list + heuristic (report-only)node scripts/enumerate-subsystems.cjs <project-root> --roots assets/PLAGameFoundation,assets/PlayableParamterToolReferences
Section titled “References”references/doc-search-contract.md— VERIFIED corpus reality, query/result shape, REUSE-signal rule, .NET-noise filter, MCP-absence guard.references/classification-rubric.md— REUSE/KEEP/CONTRIBUTE decision table + guards.references/playablesync-ssot.md—playableSyncinstall SSOT, real package-manager handlers, package↔subsystem folder map.
Gotchas
Section titled “Gotchas”- A doc_search miss is only meaningful when the MCP ran. Never classify CONTRIBUTE off a miss caused by an absent MCP — error instead.
- Filter .NET noise. The corpus is mostly Unity/.NET
TheOne.*; treat a hit as REUSE evidence ONLY when itsassemblyis a known Cocos foundation subsystem. Useassembly_prefixto constrain. - doc_search proves existence, not the package name. Resolve the
@playablelabs/*target from the folder map, not the hit. - No
register(ctx). If you catch yourself designing a DI seam, stop — it does not exist. - AnimalHunter: embedded
PLAGameFoundation/*andPlayableParamterTool/*are mostly REUSE (they mirrorgame-foundation/parameter-tool);scripts/AnimalHunterPLA/wiring is KEEP.