feat(web): Add the web console server, security and setup planner - #111
Merged
Merged
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



First implementation wave of the web console spec (#108): tasks T1 to T9 and T14. No user-facing web setup or usage page yet; those land in the next PRs on top of this base.
What changes:
src/web/server.tsis the shared local server, extracted fromcodedeck review. It binds 127.0.0.1 (default port 3100), dispatches a route table, reads the real port fromserver.address()after listen, and takes injectableclose/exitso shutdown is testable.src/web/security.tsrejects any Host other than127.0.0.1:<port>orlocalhost:<port>with 403, requires the per-start token cookie plus a matching Origin on every POST, and setsframe-ancestors 'none'on pages. The token (32 random bytes) travels only in the URL thatopenBrowseropens or the CLI prints; the GET carrying it setscodedeck_ui_token_<port>and redirects with 303 to strip it.codedeck reviewnow runs on the shared server with the same routes (/,/review,GET /api/review), port and flags.codedeck uiserves a home page that links only to registered routes, so today it lists Review only.src/cli/index.tsbuilds the program increateCliProgram()and parses only when it is the entry point (resolved throughrealpathSync), so tests can load it. Checked by hand:node dist/cli/index.js, a symlinked bin, and the~/.run-agent/bin/codedecklauncher all still run.src/config/setup.tsholds the pure setup planner (buildSetupPlan) plusdiffConfig, the binding validation andresolveSetupTarget, moved out of the CLI so the config layer imports nothing fromsrc/cli. The wizard andrunSetupBatchboth call it. Existing cases insetup-wizard.test.tsandsetup-cli-contract.test.tsare unchanged.src/core/usage-query.tsholdsbuildUsageQueryParams, extracted fromusage.tswithout behavior change, so/api/usagecan reuse it later.Verification on this branch (scoped batches, never the full suite):
Mutation probes. Each fault was injected in place, the file was restored, and
cmpconfirmed it was identical afterwards:server.address()for the URLeffortfrom planned bindings--days 7to30dKnown leftover: the Host check runs twice, in
dispatchRequestand incheckWebRequest. It is harmless but redundant; turning off only one of them does not change behavior. It will be cleaned up in a later slice.Spec status: 27 requirements are marked Implemented in the traceability table, and
tasks.mdrecords T1 to T9 and T14 as done.