t1k:unity:base:lib-candidates
| Field | Value |
|---|---|
| Module | base |
| Version | 5.116.6 |
| Effort | medium |
| Tools | Bash, Read |
Keywords: adopt candidates, contribution candidates, game code worth contributing, lib candidates, lib-candidates scan, library candidates, library-grade code
How to invoke
Section titled “How to invoke”/t1k:unity:base:lib-candidatesUnity Library Candidates: detect game code that belongs in a library
Section titled “Unity Library Candidates: detect game code that belongs in a library”Answers “which first-party types in this game are generic enough to live in a studio library, and which
did the game rebuild although a library already ships it?” without spending a token on the question.
The deterministic half lives here (scripts/lib-candidates.cjs); judging a candidate is the detached
t1k-corpus-scout hop, and the PR is t1k-lib-contribute’s. The CLI contract is the Unity port of the
Cocos stdlib-candidates.cjs (state schema v2); a core Stop hook drives it, a human or agent can too.
Read-only on the game: it never edits Assets/. State lives in
~/.claude/session-state/lib-candidates/<sha1(project)>.json (plus a per-project type-index cache).
Two classes
Section titled “Two classes”| Class | Meaning | Next step |
|---|---|---|
contribute | library-grade, and no library type matches by name + public-member overlap | corpus-scout confirms, then t1k-lib-contribute (rule: docs/library-first-contribute-back.md) |
adopt | an equivalent already exists (overlap >= libCandidate.adoptThreshold) | the game consumes the library type instead of keeping its copy |
An adopt row carries localPath, libraryRepo, libraryPackage, equivalentType, equivalentPath,
overlap: the one-line frame core prints needs exactly these.
Commands
Section titled “Commands”CLI=.claude/skills/t1k-unity-base-lib-candidates/scripts/lib-candidates.cjsbun $CLI scan --project <root> --all # first run: ranks the existing tree as `baseline`bun $CLI scan --project <root> --files Assets/A.cs,B.cs # changed files -> `pending`bun $CLI status --project <root>bun $CLI brief --project <root> [--max N] # claims a batch, prints the scout promptbun $CLI ingest --project <root> --batch <id> --result <file>bun $CLI report --project <root> [--format md|json] [--include-skip]bun $CLI ack --project <root> --ids a,b --decision approved|dismissed|consumed|resetbun $CLI purge --project <root>Every command prints one JSON document (exit 0; 2 usage; 1 internal), except report which prints markdown
by default. scan prints scanned, candidatesFound, added[], rejected{reason:n}, wallMs, and an
equivalence block naming every library source it indexed. If equivalence.sources is empty every
candidate is contribute by default, not by proof: say that, never “no equivalent exists”. unsearched[] names
the registry libraries with no local clone (no libRoots / not cloned), and decompiledExport: true flags a
project laid out like a raw decompiled export (candidates from decompiled files are rejected per file, never offered).
Flags: --config <file> (else T1K_UNITY_CONFIG, else t1k-config-unity.json found upward from the
script), --registry <file>, --lib-roots a,b (or T1K_LIB_ROOTS; directories holding clones named like the
registry repos), --no-write (scan without touching state).
What counts as a candidate
Section titled “What counts as a candidate”All of: a top-level non-partial class/struct/interface/record, public or internal; outside
Tests/Editor/Plugins/ThirdParty/Generated, vendor directories and vendor namespaces (config data); no
package.json ancestor; >= 3 public members; 40..1500 code lines; the coupling budget; and a generic
name score read from libCandidate.nameTokens (a type with no token hit needs zero coupling and >= 6
members). Exact rules, the module exemption, rejection reasons and the stage-1 score formula:
references/detector.md.
Every candidate also carries facts.provenance (kind: submodule | tracked | ignored | untracked | unknown, plus ownerRepo/mount for a submodule mount) — whose repository the file belongs to. The
scout reads it BEFORE judging portability: a framework mirror mounted at Assets/_Game/<Framework>/ is
another repository’s code, and an ignored/untracked file cannot be contributed back as-is. It is a
fact, never a filter: nothing is rejected or re-ranked for its provenance (references/detector.md →
“Git provenance”).
State lifecycle
Section titled “State lifecycle”baseline (parked by scan --all) -> pending (new or changed file) -> triaging (brief) -> triaged
(ingest; verdict CONTRIBUTE / REUSE / SKIP / unverified) -> approved | dismissed | consumed.
brief feeds at most maxPerBatch baseline types per UTC day, so a 3,000-file game cannot flood the
steward. A dismissed fingerprint is never re-proposed unless the file changed and its rank rose. Full
schema, verdict grammar and the contract core relies on: references/state-and-contract.md.
Config (all in t1k-config-unity.json, this kit owns them)
Section titled “Config (all in t1k-config-unity.json, this kit owns them)”features.autoLibTriage, libContribute.mode (auto default), and libCandidate.*: nameTokens,
minPublicMembers, minLoc, maxLoc, maxGameTypeRefs, zeroTokenMinMembers, adoptThreshold,
moduleMaxShare, dataOnlyRankPenalty, maxPending, maxPerBatch, batchSize, maxWaitHours, vendorPathSegments,
vendorNamespaceRoots, libRoots. Thresholds are uncalibrated first guesses; the replay on real
projects tunes them. A new generic word is a config edit, never a code change.
Fleet-wide view (which types several games copied, ranked, on demand only): references/harvest.md.
Executed by
Section titled “Executed by”Runs inline in the main session or an inline sub-agent Bash call: every subcommand is a deterministic script
invocation that prints one JSON document. The judgment step (stage 2) is the detached t1k-corpus-scout hop
that brief describes; this skill never spawns it.
Do not
Section titled “Do not”- Do not treat
contributeas a verdict: it is a hypothesis until the scout (stage 2) confirms it. - Do not read
rejectedcounts as precision; they are filter hits, not judgments. - Do not run it against a worktree you do not own: it reads every
.csunderAssets/.