Skip to content

refactor: Phase 2 architectural refactor (2A-2E)#41

Merged
digitarald merged 2 commits intomainfrom
tech-debt/phase2-architectural-refactor
Mar 5, 2026
Merged

refactor: Phase 2 architectural refactor (2A-2E)#41
digitarald merged 2 commits intomainfrom
tech-debt/phase2-architectural-refactor

Conversation

@digitarald
Copy link
Collaborator

Technical Debt Phase 2: Architectural Refactor

Extract a shared-core package, modularize oversized services, harden build boundaries, and add facade tests. No breaking changes to command names, flags, or extension command IDs.

Changes

Item Summary
2A Create @agentrc/core workspace package under packages/core/ — move all services, utils, config; wire npm workspaces, TypeScript paths, vitest alias, esbuild alias
2B Fix SDK build-time fragility — add shim guard for @github/copilot-sdk resolution in vscode-extension/esbuild.mjs
2C Modularize readiness service (1381 LOC -> 6 submodules): types, scoring, checkers, criteria, extras, index
2D Modularize analyzer service (1373 LOC -> 6 submodules): types, apps, areas, config, workspaces, index
2E Add 12 facade boundary tests verifying @agentrc/core re-exports match original module surface

New structure

packages/core/
  package.json
  tsconfig.json
  src/
    index.ts              # barrel re-exports
    config.ts
    services/
      analyzer/           # 6 submodules (was 1373-line monolith)
      readiness/          # 6 submodules (was 1381-line monolith)
      ... (other services unchanged)
    utils/
      fs.ts, logger.ts, output.ts, pr.ts, repo.ts

Verification

  • npm run typecheck - clean
  • npm run lint - 0 errors, 0 warnings
  • npm run test - 552/552 passing
  • Extension typecheck - clean
  • Extension build - clean

Extract shared-core package, modularize large services, add facade tests.

2A: Create @agentrc/core workspace package under packages/core/
    - Move all services, utils, config to packages/core/src/
    - Configure npm workspaces, TypeScript paths, vitest alias, esbuild alias
    - CLI commands import from @agentrc/core; extension resolves via path alias

2B: Fix SDK build-time fragility in vscode-extension/esbuild.mjs
    - Add shim guard for @github/copilot-sdk resolution
    - Graceful fallback when SDK not installed

2C: Modularize readiness service (1381 LOC → 6 submodules)
    - packages/core/src/services/readiness/{types,scoring,checkers,criteria,extras,index}.ts

2D: Modularize analyzer service (1373 LOC → 6 submodules)
    - packages/core/src/services/analyzer/{types,apps,areas,config,workspaces,index}.ts

2E: Add facade boundary tests (12 tests)
    - Verify @agentrc/core re-exports match original module surface

Verification:
Extract shared-core package, modularize large services, a
@digitarald digitarald requested a review from pierceboggan as a code owner March 5, 2026 02:50
Copilot AI review requested due to automatic review settings March 5, 2026 02:50
tsup externalized @agentrc/core (matched /^[^./]/ regex), causing
ERR_MODULE_NOT_FOUND at runtime since workspace exports point to .ts
source files. Add noExternal + esbuild alias to inline the package.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR advances the Phase 2 architectural refactor by introducing a shared @agentrc/core workspace and rewiring the CLI + VS Code extension to consume it, alongside build/test wiring and a Copilot SDK shim for extension bundling stability.

Changes:

  • Add packages/core workspace package and shift extension/CLI imports to @agentrc/core/*.
  • Add an esbuild shim guard for @github/copilot-sdk’s import.meta.resolve usage in the VS Code extension bundle.
  • Add facade/boundary tests and update vitest/tsconfig path resolution for the new package layout.

Reviewed changes

Copilot reviewed 63 out of 92 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
vscode-extension/tsconfig.json Updates TS path mapping to @agentrc/core/* for extension typechecking.
vscode-extension/src/types.ts Re-points extension type re-exports to @agentrc/core.
vscode-extension/src/services.ts Re-points extension service facade re-exports to @agentrc/core.
vscode-extension/src/progress.ts Updates ProgressReporter import to @agentrc/core.
vscode-extension/esbuild.mjs Adds guarded Copilot SDK shim + switches esbuild alias to @agentrc/core.
vitest.config.ts Adds Vitest alias for @agentrc/core to core sources.
tsconfig.json Adds TS path mapping for @agentrc/core/* and includes core sources.
src/ui/*.tsx Repoints TUI imports from local services/utils to @agentrc/core.
src/services/tests/*.test.ts Updates tests to import from @agentrc/core and adds facade boundary test.
src/commands/*.ts(x) Repoints CLI commands to use @agentrc/core services/utils.
src/cli.ts Imports defaults from @agentrc/core/config.
packages/core/* Introduces the new core workspace package (services/utils/config, policy + readiness/analyzer refactors).
package.json / package-lock.json Enables npm workspaces and links @agentrc/core locally.

@digitarald digitarald merged commit 06df6e4 into main Mar 5, 2026
11 checks passed
@digitarald digitarald deleted the tech-debt/phase2-architectural-refactor branch March 5, 2026 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants