refactor(agent): WIP move agent and shared source trees (A2b) - #1299
Merged
gewenyu99 merged 10 commits intoSep 23, 2026
Merged
Conversation
Generated-By: PostHog Desktop Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Generated-By: PostHog Desktop Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Generated-By: PostHog Desktop Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Generated-By: PostHog Desktop Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Generated-By: PostHog Desktop Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
🧙 Wizard CIRun the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands: Test all apps:
Test all apps in a directory:
Test an individual app:
Show more apps
Test against a Context Mill branch:
Add Results will be posted here when complete. |
Collaborator
Author
|
/wizard-ci basic-integration/tanstack-start |
🧙 Wizard CI ResultsTrigger ID:
Configuration
|
gewenyu99
added this pull request to stack #1304
September 22, 2026 19:57
edwinyjlim
approved these changes
Sep 22, 2026
Carries main's eight fixes and A1's per-request ask signal and host-owned analytics shutdown onto the moved tree. Seven conflicts, all import lines, resolved to the incoming side with this PR's aliases. main's new detection retry test moves from @lib/agent and @lib/host-resolution to @agent and @shared. Generated-By: PostHog Desktop Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Carries the guard that keeps a successful run successful when its terminal analytics flush fails. Generated-By: PostHog Desktop Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Carries the fence's directory-import patterns and the handoff, benchmark and scan-summary wiring tests. One conflict, in .eslintrc.cjs: the new patterns and comment land on A2b's collapsed src/agent/** fence, where @lib/** already covers the alias forms. The handoff tools test moves to src/agent/tools with its aliases rewritten. Generated-By: PostHog Desktop Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Brings in main (#1319). No conflicts. Generated-By: PostHog Desktop Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
gewenyu99
marked this pull request as ready for review
September 23, 2026 21:15
gewenyu99
requested review from
TueHaulund,
arnohillen,
fasyy612,
hpouillot and
ksvat
and removed request for
a team
September 23, 2026 21:15
gewenyu99
added a commit
that referenced
this pull request
Sep 24, 2026
Release A landed on main as squash commits (#1293, #1297, #1299, #1303). B1 already carries that content through the A3 branch, so the merge keeps B1's tree and adds #1334, the one change main has beyond A3, with B1 import paths. Generated-By: PostHog Desktop Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
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.
Stacked on #1297 (A2a). Second of the two PRs that replace the plan's A2′: A2a cut the agent's outside edges and fenced them, this one moves the files so the fence is a directory. No logic in it, review with
git diff -M.Intent
Isolates the agent behind a defined boundary. The agent runs a program's prompt against a harness and reports back through progress events and asks, so nothing under
src/agent/may reach the UI, the session, detection, the runners or the CLI.Two things that buys:
src/agent/is the agent,src/shared/is what every area may import,src/lib/is what's left to sort in B and C. A file's directory says which rules apply to it.Impact
People running the wizard. Nothing changes. No command, flag, prompt or network call moved. The bundle differs only in module paths.
People maintaining it. Two roots are now load bearing.
src/agent/is fenced the moment it exists. ESLint refuses@ui, every@libpath except@lib/programs/**types, detection, runners, commands, steps, frameworks,setup-utils,oauthandwizardAbort. Its tests run undervitest run --project agent. Team wizard-docs owns it.src/shared/is the floor the agent may stand on. A file both the TUI and the agent need goes there, which is whyclaude-settings.ts,agent-phase.tsandtoken-pricing.tsleft the agent in this PR.@utils/*still resolves, now tosrc/shared/utils/*. The three alias lines live twice, intsconfig.build.jsonandvitest.config.ts, and must match.src/agentintosrc/libneeds aknown-violations.jsonentry or a move intosrc/shared. The custom scanner stays the enforcement mechanism here; standard tooling is deferred to C2, see Enforcement below.Map
%%{init: {"block": {"padding": 20}}}%% block-beta columns 11 hostBand["src/lib/runners and src/ui old, moves in C1"]:11 runWizard["runWizard / runNonInteractive"]:3 space:1 InkUI["WizardUI"]:7 adapterBand["src/lib/programs run-agent-legacy temporary until B1"]:11 runProgramAgent["runProgramAgent"]:3 space:1 createUiReducer["createUiReducer"]:3 space:1 uiInteraction["uiInteraction"]:3 agentBand["src/agent new root, ESLint fenced"]:11 runAgent["runAgent"]:3 space:8 runLinearProgram["runLinearProgram"]:3 space:5 askBridge["createAskBridge"]:3 anthropicBackend["anthropicBackend"]:3 space:1 collector["createProgressCollector"]:3 space:1 wizard_ask["wizard_ask"]:3 sharedBand["src/shared new root, imported by every row above"]:11 sdk["Claude Agent SDK query loop"]:11 runWizard --> runProgramAgent runProgramAgent -- "RunConfig, RunInput, options" --> runAgent runAgent --> runLinearProgram runLinearProgram --> anthropicBackend runLinearProgram --> askBridge anthropicBackend --> sdk anthropicBackend -- "emit" --> collector sdk --> wizard_ask wizard_ask --> askBridge askBridge --> uiInteraction collector -- "onProgress" --> createUiReducer createUiReducer --> InkUI uiInteraction --> InkUI classDef old fill:#f3f4f6,stroke:#6b7280,color:#111827 classDef temp fill:#fef3c7,stroke:#b45309,color:#78350f classDef new fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a classDef ext fill:#ffffff,stroke:#6b7280,color:#111827,stroke-dasharray:4 3 classDef oldBand fill:#e5e7eb,stroke:#e5e7eb,color:#374151 classDef tempBand fill:#fde68a,stroke:#fde68a,color:#78350f classDef newBand fill:#bfdbfe,stroke:#bfdbfe,color:#1e3a8a class runWizard,InkUI old class runProgramAgent,createUiReducer,uiInteraction temp class runAgent,runLinearProgram,anthropicBackend,collector,askBridge,wizard_ask new class sdk ext class hostBand oldBand class adapterBand tempBand class agentBand,sharedBand newBandLeft lane is the call down, middle lane is progress back up, right lane is questions back up. Blue is the two new roots this PR creates, grey is untouched, amber is the legacy adapter that dies in B1, dashed is outside the repo. No arrow changed direction. Every node kept its name and lost its
src/lib/prefix.Blocks
runWizard,runNonInteractive(run-wizard.ts, run-non-interactive.ts). Hosts. Own the session and the TUI, call the adapter. Untouched except import lines.runProgramAgent(run-agent-legacy.ts:66). Legacy adapter. BuildsRunConfigandRunInputfrom the session, wirescreateUiReducerasonProgressanduiInteractionas the answerer, callsrunAgent. Only file that imports both@uiand@agent. Dies in B1.createUiReducer,uiInteraction(agent-progress.ts:12, :67). Map progress events toWizardUIcalls and asks to the TUI overlay. Untouched.runAgent(runner/index.ts:74). The agent's one public entry. Takes config, input, options, returnsRunResult. Never exits the process. Wassrc/lib/agent/runner/index.ts.runLinearProgram(sequence/linear.ts:30). Picks the harness, builds the ask bridge, runs the prompt once. Was undersrc/lib/agent.anthropicBackend(harness/anthropic/index.ts:20). Drives the SDK, mounts the MCP tools, emits every message.piharness sits beside it, same shape.createProgressCollector(progress-collector.ts:25). Foldsemitcalls into aRunSnapshotand forwards toonProgress.createAskBridge,wizard_ask(ask.ts:18, tools/mcp.ts:117). The model calls the tool, the bridge parks a promise, the answerer resolves it.src/lib/wizard-toolsis nowsrc/agent/tools.src/shared. Constants, errors, health checks,utils/*,claude-settings,token-pricing,agent-phase, generatedversion.ts. Counting@shared/*and@utils/*import lines at head: 176 from the agent, 113 from the UI, 88 from programs. Classifiedlegacyby the architecture test until A3 zeroes its outward edges — 8 of them across 7 files, 3 intosrc/agent(claude-settings.ts,errors/agent-map.ts,errors/skill-map.ts) and 5 intosrc/ui(utils/debug.ts,utils/oauth.ts,utils/setup-utils.ts,utils/wizard-abort.ts).Code
Every renamed file's non-import content is byte-identical to the A2a head, except three comment-only path updates in the last commit:
src/shared/constants.ts,src/lib/wizard-session.tsandsrc/lib/programs/__tests__/mcp-analytics.test.ts.git grepundersrc/at head finds no old spelling outsideknown-violations.json.Moves.
src/lib/agent/**→src/agent/**, minusclaude-settings.ts,token-pricing.ts,agent-phase.tsand their tests, which go tosrc/sharedsrc/lib/middleware/**→src/agent/middleware/**src/lib/wizard-tools/**→src/agent/tools/**yara-hooks,yara-policy,gateway-session,wizard-ask-bridge,safe-tools→src/agent/*.tssrc/utils/**→src/shared/utils/**whole.setup-utils.tsandoauth.tsride along and leave for tui in C1src/lib/errors/**,src/lib/health-checks/**→ same names undersrc/sharedconstants,api,host-resolution,skill-install,secret-vault,local-dev,version,fetch-retry,auth-session-state,status-history,audit-ledger→src/shared/*.tssrc/agent/__tests__andsrc/shared/__tests__Stays in
src/libuntil B/C: programs, detection, runners, registry, task-stream, warehouse-sources, framework-config, wizard-session, wizard-spellbook, mcp-*, headless-mode, file-watcher, cloudflare-detection,oauth/program-scopes.ts.Config, read these.
@agent/*,@shared/*new,@utils/*nowsrc/shared/utils/*AGENT_TESTSis one globsrc/agent/**filesissrc/agent/**/*.ts, patterns collapse to@lib/**blocked with!@lib/programs/**,wizardAbortalso blocked at its@sharedspellingSURFACE_RULESmapssrc/agent/to agent,src/sharedstayslegacywizard-tools/tools.tswaslegacyat base and is agent nowsrc/agent/andsrc/shared/version.tssrc/lib/**/*includeEverything else in the diff is an import line following a move, or a doc path.
Review by commit. Five commits, move only. Each leaves typecheck, lint and the full suite green.
2b8c672dsrc/utils→src/shared/utils,@utils/*retargeted. 50 renames, 23 files touched.8210a647errors, health-checks and the shared singles →src/shared,@shared/*alias, version script,.gitignore. 38 renames, 205 files of import lines.0de7b0b1claude-settings,token-pricing,agent-phaseand tests →src/shared. 5 renames, 20 files of import lines.719737a0agent tree, middleware, tools, 5 singles, 9 tests →src/agent,@agent/*alias, vitest globs, fence, arch rules,known-violations.json. 132 renames, 59 files of import lines.273cd0eadocs and comment paths, 20 files, no prose change.Enforcement
A sixth commit was written on this branch and has been reverted: it swapped the repo's custom import scanner for
eslint-plugin-importboundary configuration, addedsrc/agent/index.tsandtypes.tsentry modules, and banned deep agent imports outside tests.The boundary matrix cannot be configured once while four of its seven layers do not exist yet. B1 and C1 would each rewrite it, so the tooling choice is deferred to C2, where it is made once against the final tree.
What that means for this PR:
node_modules/eslint-plugin-importsymlink into a temp directory was removed;package.jsonis unchanged.workbench/wizard-functional-evidence/a2b-commit6-eslint-enforcement.patch— 84 files, +1253/−613, verified to reapply.Evidence on the head, re-run at
273cd0eaafter the revert.pnpm typecheckclean.pnpm test:arch4 tests pass.pnpm lint0 errors, 482 pre-existing warnings.Next: A3 zeroes the 8
src/sharededges and reclassifies it. B1 removes the amber row.Created with PostHog Desktop