6.6 KiB
Unified Startup Config Implementation Plan
For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development.
Goal: One profiles.ts source configures runtime mode, remote URL and local/remote server selection; browser testing requires no query switches.
Architecture: STARTUP_CONFIG is the sole production source. Runtime takes an optional whole StartupConfig injection for tests and publishes a validated source snapshot. Local diagnostic consumers validate that source and derived targets, preserving account namespace and lifecycle.
Tech Stack: TypeScript, node:test/tsx, Creator 3.8.8 via funplay MCP.
Spec: docs/superpowers/specs/2026-09-05-unified-startup-config-design.md
Global Constraints
- Main checkout codex/local-platform-login only; never worktrees.
- No server changes, serialized asset changes, new assets scripts, RPC expansion or subgame selection.
- mode and useLocalServer are independent. All four combinations read remote JSON into memory; no persistent cache.
- Source values appear once in STARTUP_CONFIG: mode debug, gameserver https://tsgames.daoqi88.cn/config/update_jsonv2.txt, useLocalServer true, localServers ws://127.0.0.1:3088.
- URL mode/profile cannot override or block startup. Preserve original gameconfig injection and identity sources.
- No npm test, test:framework, scripts/run-framework-tests.mjs or resource generators.
- Protect original52 dirty paths, stage exact task files only. No merge/push.
Task 1: Integrate the unified code configuration through all existing consumers
Files: existing assets/framework/config/{profiles.ts,runtime-mode.ts,runtime-config.ts,local-startup.ts,bootstrap.ts}; existing assets/scripts/{LoginFlow.ts,local-platform-login/LocalPlatformLogin.ts}; dependent existing local-platform-login/adapters files only if required. Paths prefixed cocoscreator_projects/YouleNexus. Test files and fixtures are under cocoscreator_projects/framework-tests.
Interfaces: export StartupConfig and STARTUP_CONFIG from profiles.ts. ResolveRuntimeConfigOptions replaces mode with optional startupConfig: Readonly; production default is the exported constant, test configuration is explicit. RuntimeConfig retains mode/isDebugger/identity/servers/remoteConfig/rawConfig and exposes validated startupConfig for local consumers to validate against the same source. No independent profile selector. runtime-mode.ts may export RuntimeMode and a pure reader but contains no environment or URL defaults.
- Write RED tests in framework-tests/config/{profiles,runtime-mode,runtime-config,local-startup,bootstrap}.test.ts and local-platform-login/host.test.ts. For example, inject
{...STARTUP_CONFIG,mode:'release',useLocalServer:true}, search?mode=debug&profile=prod, fake fetch{visitor_server_tcp:'visitor:1'}; assert one fetch and local servers with mode release. Repeat mode debug/release and useLocalServer true/false, using valid remote game/player candidates when false. Assert the default no-query local host starts, and conflicting/duplicate mode/profile parameters do not select another configuration. - Run focused RED from cocoscreator_projects:
node --import tsx --test --test-concurrency=1 framework-tests/config/profiles.test.ts framework-tests/config/runtime-mode.test.ts framework-tests/config/runtime-config.test.ts framework-tests/config/local-startup.test.ts framework-tests/config/bootstrap.test.ts framework-tests/local-platform-login/host.test.ts. Repeat identical command require_escalated on known sandbox ENOMEM. - Implement source and validation: explicit mode enum, boolean useLocalServer, valid http(s) gameserver, valid loopback localServers. Freeze the source/array. Reject malformed values; no consumer defaults. Remove URL/environment mode selection and PROFILES selector. Preserve resolveGameServer original injection decoding.
- Integrate runtime:
const startupConfig = ...options.startupConfig or STARTUP_CONFIGthrough one validated source function; resolve identity/injected remote URL, await fetch, create memory view, choosestartupConfig.useLocalServer ? startupConfig.localServers : parseUrlServers(remoteConfig). Preserve errors. Derive mode/isDebugger from startupConfig. - Integrate diagnostic and facade: remove scalar mode in component; local-startup checks code source debug/local and loopback and accepts empty search. Ignore mode/profile query while retaining identity/gameconfig diagnostic restrictions. Use the same source snapshot in forged-context checks. Keep internal profile local namespace for account storage. Bootstrap uses same runtime; old LoginFlow stops after config error rather than assigning fallback identity/server, and forwards real location.search. Do not rewire the old UI or login contract.
- Update affected test literals via existing fixtures as appropriate; replace obsolete mode/profile expectations with new contract without weakening lifecycle/source tests. Add behavior tests for malformed local addresses and gameserver, remote failure, local diagnostic refusal of release/remote settings, and native injection compatibility.
- GREEN focused suite; explicit full suite:
$testPaths = @(rg --files framework-tests -g '*.test.ts' | Sort-Object); node --import tsx --test --test-concurrency=1 @testPaths; architecture:node --test framework-tests/architecture/import-boundaries.test.mjs framework-tests/architecture/presentation-boundaries.test.mjs; type:node node_modules/typescript/bin/tsc -p tsconfig.framework.json --noEmit; boundaries:node scripts/check-import-boundaries.mjs. - Self-review and exact task-only commit. Report RED/GREEN commands/results and file list in task-1-report.md; no full remote data/logged secrets.
- Independent task spec/quality review, fix loop with targeted regressions, then scoped re-review.
Task 2: Real browser and documentation acceptance (controller)
- MCP verify actual main checkout Creator project and current dirty state; refresh only modified existing TS resources.
- Open actual LocalPlatformLogin preview without query parameters, verify remote config source, local target, login ready and no failure; stop afterward. Configuration-only browser calls may verify the other source selections without creating production sockets.
- Write docs/superpowers/reports/2026-09-05-unified-startup-config-acceptance.md with exact results, final current configuration location, publishing instructions and source limitation. Keep prior completed reports as history.
- Whole-change independent review; verify original dirty hashes/status unchanged; mark plan progress and commit exact documents. No merge/push.