Skip to content

Refactor large modules for readability - #147

Merged
Minitour merged 3 commits into
version-2.0from
chore/code-cleanup-readability
Aug 1, 2026
Merged

Refactor large modules for readability#147
Minitour merged 3 commits into
version-2.0from
chore/code-cleanup-readability

Conversation

@Minitour

@Minitour Minitour commented Aug 1, 2026

Copy link
Copy Markdown
Member

Summary

  • Split oversized server, CLI, shared-provider, and web-ui modules into focused files with stable re-export shims (behavior unchanged).
  • Deduped web-ui capaIdErrorMessage, Biome-format server/shared/db, and small hygiene/test/tsc fixes.
  • Ignore local .cursor/ agent config in git (alongside existing .claude/).

Test plan

  • bunx tsc --noEmit
  • bun test (1228 pass)
  • cd web-ui; bunx tsc --noEmit
  • bun run build:web
  • Spot-check project tools UI (servers/configured tools dialogs) after merge
  • Spot-check capa add / capa sh / passthrough install smoke

Split oversized server, CLI, provider, and web-ui files into focused modules with stable re-export shims, and keep local Cursor agent config out of git.

Co-authored-by: Cursor <cursoragent@cursor.com>
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Aug 1, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Plugin validation bypass ✓ Resolved 🐞 Bug ≡ Correctness
Description
parsePluginSource() returns plugin definitions for GitLab inputs and for URL-based inputs without
calling validatePluginDef(), so malformed def.repo / subpath values can be accepted by `capa add
--plugin` and persisted into the capabilities file. This creates a deferred-error path (and
inconsistent behavior vs the GitHub shorthand branches which do validate).
Code

src/cli/commands/add-parse-plugin.ts[R12-87]

+export function buildPluginSourceFromRepoUrl(
+  providerId: 'github' | 'gitlab',
+  parsed: { owner: string; repo: string; ref?: string; path?: string }
+): ParsedPluginSource {
+  const repoString = providerId === 'gitlab'
+    ? (parsed.path ? `${parsed.owner}::${parsed.path}` : parsed.owner)
+    : (parsed.path ? `${parsed.owner}/${parsed.repo}::${parsed.path}` : `${parsed.owner}/${parsed.repo}`);
+  const def: PluginDefinition = { repo: repoString };
+  if (parsed.ref) {
+    if (/^[a-f0-9]{7,40}$/i.test(parsed.ref)) def.ref = parsed.ref;
+    else if (/^v?\d+\.\d+/.test(parsed.ref)) def.version = parsed.ref;
+  }
+  const idHint = parsed.path
+    ? basename(parsed.path)
+    : (providerId === 'gitlab' ? parsed.owner.split('/').pop()! : parsed.repo);
+  return {
+    type: providerId,
+    def,
+    idHint,
+  };
+}
+
+/**
+ * Parse a plugin source string into a structured plugin definition.
+ *
+ * Accepted grammars:
+ *   owner/repo                             — GitHub, plugin at repo root
+ *   owner/repo::subpath/in/repo            — GitHub, plugin pinned at an exact path
+ *   owner/repo@plugin-name                 — GitHub, recursive-search by basename or manifest "name"
+ *   owner/repo:v1.2.0 / owner/repo#sha     — version / ref pinning (any of the forms above)
+ *   gitlab:group/project[::sub|@name]     — GitLab (nested groups: ≥2 segments)
+ *   https://github.com/owner/repo          — URL form
+ *   https://github.com/owner/repo/tree/<ref>/<subpath>
+ *   https://gitlab.com/group/.../project/-/tree/<ref>/<subpath>
+ *
+ * Use `::` when you know the exact subpath; use `@` when the repo hosts many
+ * plugins and you'd rather match by directory basename or manifest `name`.
+ */
+export function parsePluginSource(source: string): ParsedPluginSource {
+  for (const gp of getAllGitProviders()) {
+    if (!gp.parseRepoUrl) continue;
+    const parsed = gp.parseRepoUrl(source);
+    if (!parsed) continue;
+    return buildPluginSourceFromRepoUrl(gp.id as 'github' | 'gitlab', parsed);
+  }
+
+  // GitLab `@name` search: gitlab:group/sub/project@plugin-name[:version|#sha]
+  const gitlabAtMatch = source.match(
+    /^gitlab:([\w.-]+(?:\/[\w.-]+)+)@([\w.-]+)(?::([\w.-]+))?(?:#([a-f0-9]{7,40}))?$/i
+  );
+  if (gitlabAtMatch) {
+    const [, repoPath, searchName, version, ref] = gitlabAtMatch;
+    const def: PluginDefinition = { repo: `${repoPath}@${searchName}` };
+    if (version) def.version = version;
+    if (ref) def.ref = ref;
+    return { type: 'gitlab', def, idHint: searchName };
+  }
+
+  // GitLab prefix (exact / root): gitlab:group/sub/project[::subpath][:version][#sha]
+  const gitlabMatch = source.match(
+    /^gitlab:([\w.-]+(?:\/[\w.-]+)+?)(?:::([\w./-]+?))?(?::([\w.-]+))?(?:#([a-f0-9]{7,40}))?$/i
+  );
+  if (gitlabMatch) {
+    const [, repoPath, subpath, version, ref] = gitlabMatch;
+    const def: PluginDefinition = {
+      repo: subpath ? `${repoPath}::${subpath}` : repoPath,
+    };
+    if (version) def.version = version;
+    if (ref) def.ref = ref;
+    const repoSegments = repoPath.split('/');
+    return {
+      type: 'gitlab',
+      def,
+      idHint: subpath ? basename(subpath) : repoSegments[repoSegments.length - 1],
+    };
+  }
Evidence
The GitLab and URL branches return parsed plugin defs without validation, while GitHub shorthand
branches do validate. The validator rejects ./.. segments, and capa add --plugin writes the
parsed result directly to the capabilities file, so invalid definitions can be persisted.

src/cli/commands/add-parse-plugin.ts[12-31]
src/cli/commands/add-parse-plugin.ts[50-87]
src/cli/commands/add-parse-plugin.ts[93-126]
src/shared/plugin-source.ts[11-20]
src/shared/plugin-source.ts[85-167]
src/cli/commands/add.ts[209-237]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`src/cli/commands/add-parse-plugin.ts` validates only the GitHub shorthand branches, but **does not validate**:
- URL-derived plugin sources returned via `buildPluginSourceFromRepoUrl(...)`
- GitLab `gitlab:` forms (`gitlabAtMatch` and `gitlabMatch`)
As a result, `capa add --plugin` can write malformed plugin entries (e.g., subpaths containing `.`/`..`) into the capabilities file.
### Issue Context
`validatePluginDef()` is the canonical validator for plugin repo/subpath/search rules and explicitly rejects dangerous/invalid path segments. `add.ts` persists the `parsePluginSource()` output directly into the capabilities file.
### Fix Focus Areas
- src/cli/commands/add-parse-plugin.ts[12-31]
- src/cli/commands/add-parse-plugin.ts[50-87]
- src/cli/commands/add.ts[209-237]
### Implementation notes
- After constructing any `ParsedPluginSource` (including URL and GitLab branches), run:
- `const validation = validatePluginDef({ type: result.type, def: result.def })`
- if `"error" in validation`, throw `new Error(validation.error)`
- Prefer centralizing this in a small helper like `assertValid(result)` to avoid missing branches.
- (Optional but recommended) add unit tests for `parsePluginSource()` covering GitLab `::` subpaths with `..` and ensuring it throws.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Qodo Logo

Comment thread src/cli/commands/add-parse-plugin.ts
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Split large server/CLI/shared/web-ui modules into focused files (stable re-exports)

✨ Enhancement ⚙️ Configuration changes 🧪 Tests 🕐 40+ Minutes

Grey Divider

AI Description

• Split oversized server, CLI, shared, and web-ui modules into focused files via re-export shims.
• Deduplicate small UI helpers and apply Biome formatting across server/shared/db.
• Fix small test/tsc hygiene issues and keep local agent config out of git.
Diagram

graph TD
  WebUI["Web UI (React)"] --> Server["Server (HTTP)"] --> DB[("SQLite DB")]
  CLI["CLI"] --> Shared["Shared libs"] --> Server
  Server --> OAuth["OAuth modules"]
  Server --> Routes["Route modules"]

  subgraph Legend
    direction LR
    _mod["Module"] ~~~ _svc["Service"] ~~~ _db[("Database")]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Keep monoliths + add internal regions only
  • ➕ Smaller diff and fewer moved symbols
  • ➕ Less churn for callsites and imports
  • ➖ Doesn’t materially improve long-term maintainability
  • ➖ Harder to enforce boundaries and reuse shared logic cleanly
2. Use path aliases + stronger barrel conventions
  • ➕ Cleaner imports and less relative-path noise
  • ➕ Easier future reshuffling without touching callsites
  • ➖ Requires consistent tsconfig/bundler alignment across packages
  • ➖ Barrels can obscure dependency direction if overused
3. Incremental subsystem-by-subsystem refactor PRs
  • ➕ Lower per-PR risk and easier review/bisection
  • ➕ Less chance of conflicts across active development areas
  • ➖ Longer migration window with inconsistent structure
  • ➖ More overhead and prolonged merge-conflict exposure

Recommendation: The chosen approach—splitting into focused modules while preserving stable re-export shims—is the best tradeoff for readability without breaking downstream imports. Review should concentrate on verifying that shims preserve the previous public surface (exports, types, route wiring) and that moved code didn’t subtly change defaults/edge-case behavior.

Files changed (170) +24470 / -22295

Refactor (167) +24468 / -22292
adapter.tsAdd section dividers for claude-plugins adapter readability +20/-0

Add section dividers for claude-plugins adapter readability

• Adds structured comment headers to separate major logical areas (HTML utilities, listing scrape, marketplace manifest, detail/install). Intended behavior is unchanged.

registries/claude-plugins/adapter.ts

add-parse-plugin.tsExtract plugin source parsing from add command +150/-0

Extract plugin source parsing from add command

• Introduces a dedicated module to parse plugin source strings into a normalized structure used by add/install flows.

src/cli/commands/add-parse-plugin.ts

add-parse-skill.tsExtract skill source parsing from add command +190/-0

Extract skill source parsing from add command

• Introduces a dedicated module to parse skill source strings (repo syntaxes, pinning) into a normalized structure.

src/cli/commands/add-parse-skill.ts

add.tsSlim add command by delegating parsing to new modules +5/-359

Slim add command by delegating parsing to new modules

• Removes large inline parsing logic for skills/plugins and imports parseSkillSource/parsePluginSource. Keeps the command’s external behavior stable.

src/cli/commands/add.ts

sh.tsReplace monolithic sh command with shim +3/-804

Replace monolithic sh command with shim

• Reduces src/cli/commands/sh.ts to a thin entrypoint that delegates to the new sh/* modules.

src/cli/commands/sh.ts

args.tsAdd sh argument parsing module +121/-0

Add sh argument parsing module

• Extracts and centralizes sh CLI argument parsing and validation.

src/cli/commands/sh/args.ts

fetch.tsAdd sh tool discovery and schema fetch module +187/-0

Add sh tool discovery and schema fetch module

• Extracts tool listing and lazy schema resolution logic used by sh execution and help rendering.

src/cli/commands/sh/fetch.ts

help.tsAdd sh help rendering module +97/-0

Add sh help rendering module

• Extracts sh usage/tool help rendering into a focused module.

src/cli/commands/sh/help.ts

index.tsAdd sh command implementation module +219/-0

Add sh command implementation module

• Provides the main sh orchestration implementation wiring args, discovery, help, and execution.

src/cli/commands/sh/index.ts

registry.tsAdd sh tool registry/grouping module +169/-0

Add sh tool registry/grouping module

• Extracts tool grouping/slug mapping and top-level vs grouped command registry behavior.

src/cli/commands/sh/registry.ts

agents-file.tsConvert agents-file monolith into re-export shim +17/-640

Convert agents-file monolith into re-export shim

• Replaces a large implementation with a small module that re-exports from src/cli/utils/agents-file/* to preserve import stability.

src/cli/utils/agents-file.ts

index.tsAdd agents-file barrel exports +23/-0

Add agents-file barrel exports

• Defines the public export surface for the refactored agents-file utilities.

src/cli/utils/agents-file/index.ts

install.tsMove agents file install/update logic into module +300/-0

Move agents file install/update logic into module

• Hosts the logic for writing/updating provider instruction files and capa-managed snippet blocks.

src/cli/utils/agents-file/install.ts

md-io.tsExtract agents markdown IO helpers +20/-0

Extract agents markdown IO helpers

• Centralizes read/write/delete helpers for provider instruction markdown files.

src/cli/utils/agents-file/md-io.ts

remote.tsExtract agents remote/repo content helpers +97/-0

Extract agents remote/repo content helpers

• Moves remote/repo content fetching and safety checks into a focused module.

src/cli/utils/agents-file/remote.ts

snippets.tsExtract capa marker/snippet operations +47/-0

Extract capa marker/snippet operations

• Centralizes marker formatting and snippet upsert/remove operations used by agents file management.

src/cli/utils/agents-file/snippets.ts

subagents.tsExtract subagent rendering helpers for agents files +155/-0

Extract subagent rendering helpers for agents files

• Moves subagent content generation and provider-specific rendering into a dedicated module.

src/cli/utils/agents-file/subagents.ts

hooks-installer.tsConvert hooks installer monolith into re-export shim +13/-710

Convert hooks installer monolith into re-export shim

• Replaces a large hooks installer implementation with a thin shim that re-exports from src/cli/utils/hooks/*.

src/cli/utils/hooks-installer.ts

config-apply.tsExtract provider hook config apply logic +146/-0

Extract provider hook config apply logic

• Implements the provider-config write/update steps for hook install and removal.

src/cli/utils/hooks/config-apply.ts

index.tsAdd hooks installer barrel exports +38/-0

Add hooks installer barrel exports

• Defines a stable export surface for hook install/prune/clean operations after the split.

src/cli/utils/hooks/index.ts

install.tsExtract end-to-end hook installation flow +247/-0

Extract end-to-end hook installation flow

• Moves hook source resolution, script materialization, provider upsert, and DB tracking into a focused module.

src/cli/utils/hooks/install.ts

json-io.tsExtract JSON IO helpers for hook configs +61/-0

Extract JSON IO helpers for hook configs

• Centralizes safe read/parse/write behavior for JSON-backed hook configuration files.

src/cli/utils/hooks/json-io.ts

provider-map.tsExtract provider event mapping helpers +32/-0

Extract provider event mapping helpers

• Adds helpers for mapping canonical hook events to provider-specific event names/slots.

src/cli/utils/hooks/provider-map.ts

prune.tsExtract hook pruning flow +70/-0

Extract hook pruning flow

• Moves orphan hook detection and surgical removal logic into its own module.

src/cli/utils/hooks/prune.ts

resolve-body.tsExtract hook body/source resolution helpers +103/-0

Extract hook body/source resolution helpers

• Moves inline/remote/git/local hook body resolution and validation into a dedicated helper module.

src/cli/utils/hooks/resolve-body.ts

add.tsExtract passthrough add logic +252/-0

Extract passthrough add logic

• Moves core passthrough add behavior (skills/plugins/servers/rules/hooks) into a dedicated module.

src/cli/utils/passthrough/add.ts

env.tsExtract passthrough environment handling +60/-0

Extract passthrough environment handling

• Moves .env loading and ${VAR} expansion helpers into a dedicated module.

src/cli/utils/passthrough/env.ts

index.tsConvert passthrough index into thin entrypoint +5/-640

Convert passthrough index into thin entrypoint

• Shrinks a large passthrough implementation file into a small delegating entrypoint using extracted helpers.

src/cli/utils/passthrough/index.ts

install-plugin.tsExtract passthrough plugin install path +99/-0

Extract passthrough plugin install path

• Moves plugin installation logic (native vs unpacked) into a focused helper module.

src/cli/utils/passthrough/install-plugin.ts

install-skill.tsExtract passthrough skill install path +46/-0

Extract passthrough skill install path

• Moves skill installation logic into a dedicated helper module.

src/cli/utils/passthrough/install-skill.ts

install.tsExtract passthrough end-to-end install orchestration +208/-0

Extract passthrough end-to-end install orchestration

• Moves provider resolution, lockfile behavior, and install orchestration into a dedicated module.

src/cli/utils/passthrough/install.ts

database.tsReformat and reorganize DB wiring +384/-348

Reformat and reorganize DB wiring

• Applies Biome formatting and import organization for CapaDatabase and repo wiring; behavior intended unchanged.

src/db/database.ts

git-integrations.tsReformat git-integrations repo +108/-95

Reformat git-integrations repo

• Applies formatting and small readability refactors with no intended behavior changes.

src/db/git-integrations.ts

managed-files.tsReformat managed-files repo +24/-24

Reformat managed-files repo

• Applies formatting and minor cleanup for consistency; logic unchanged.

src/db/managed-files.ts

managed-hooks.tsReformat managed-hooks repo +68/-68

Reformat managed-hooks repo

• Applies formatting and minor cleanup for consistency; logic unchanged.

src/db/managed-hooks.ts

mcp-subprocesses.tsReformat mcp-subprocesses repo +56/-45

Reformat mcp-subprocesses repo

• Applies formatting and small readability improvements to subprocess tracking; behavior unchanged.

src/db/mcp-subprocesses.ts

oauth-flow-state.tsReformat oauth-flow-state repo +35/-28

Reformat oauth-flow-state repo

• Applies formatting and minor cleanup; behavior unchanged.

src/db/oauth-flow-state.ts

oauth-tokens.tsReformat oauth-tokens repo +54/-38

Reformat oauth-tokens repo

• Applies formatting and minor cleanup; behavior unchanged.

src/db/oauth-tokens.ts

projects.tsReformat projects repo +91/-74

Reformat projects repo

• Applies formatting and minor cleanup; behavior unchanged.

src/db/projects.ts

registries.tsReformat registries repo +111/-98

Reformat registries repo

• Applies formatting and minor readability improvements; behavior unchanged.

src/db/registries.ts

schema.tsReformat schema initialization +22/-22

Reformat schema initialization

• Applies formatting and minor cleanup to schema init; no intended DDL change.

src/db/schema.ts

sessions.tsReformat sessions repo +36/-34

Reformat sessions repo

• Applies formatting and minor cleanup; behavior unchanged.

src/db/sessions.ts

sub-agents.tsReformat sub-agents repo +20/-20

Reformat sub-agents repo

• Applies formatting and minor cleanup; behavior unchanged.

src/db/sub-agents.ts

tool-init-state.tsReformat tool-init-state repo +21/-15

Reformat tool-init-state repo

• Applies formatting and minor cleanup; behavior unchanged.

src/db/tool-init-state.ts

variables.tsReformat variables repo +31/-31

Reformat variables repo

• Applies formatting and minor cleanup; behavior unchanged.

src/db/variables.ts

auth-middleware.tsReformat auth middleware +109/-105

Reformat auth middleware

• Applies Biome formatting and small readability refactors; behavior intended unchanged.

src/server/auth-middleware.ts

capabilities-mutations.tsExtract capabilities mutation operations +305/-0

Extract capabilities mutation operations

• Moves capability section mutation operations (append/update/remove/reorder) into a dedicated module used by routes.

src/server/capabilities-mutations.ts

capabilities-route-helpers.tsExtract shared helpers for capabilities routes +136/-0

Extract shared helpers for capabilities routes

• Adds helpers for JSON responses, validation, and common route plumbing used by capabilities endpoints.

src/server/capabilities-route-helpers.ts

capabilities-routes.tsSlim capabilities routes by delegating to helpers +105/-574

Slim capabilities routes by delegating to helpers

• Refactors the capabilities routes layer to compose helper/mutation modules rather than embedding all logic in one file.

src/server/capabilities-routes.ts

capabilities-special-routes.tsAdd module for special-case capabilities routes +146/-0

Add module for special-case capabilities routes

• Extracts less-common/special endpoints into a dedicated file to reduce main route complexity.

src/server/capabilities-special-routes.ts

capabilities-watcher.tsReformat and refactor capabilities file watcher +199/-180

Reformat and refactor capabilities file watcher

• Applies formatting and small structural cleanup to self-write suppression and watcher behavior.

src/server/capabilities-watcher.ts

configure-routes.tsExtract project configure route handlers +402/-0

Extract project configure route handlers

• Introduces a dedicated module for configure endpoints and dependency wiring from the server entrypoint.

src/server/configure-routes.ts

cors-origin.tsExtract CORS origin validation helper +30/-0

Extract CORS origin validation helper

• Centralizes allowed-origin checks into a small module used by the server.

src/server/cors-origin.ts

git-integration-manager.tsRefactor git integration manager for readability +485/-425

Refactor git integration manager for readability

• Applies formatting and internal organization improvements while keeping the integration behavior stable.

src/server/git-integration-manager.ts

git-integrations-routes.tsExtract git integrations routes module +338/-0

Extract git integrations routes module

• Adds a dedicated routes module for listing/connecting/disconnecting integrations and related callbacks.

src/server/git-integrations-routes.ts

http-mcp-transport.tsExtract HTTP MCP transport module +236/-0

Extract HTTP MCP transport module

• Introduces a dedicated module implementing MCP-over-HTTP transport plumbing.

src/server/http-mcp-transport.ts

index.tsRefactor server entrypoint into composed modules +1701/-2857

Refactor server entrypoint into composed modules

• Reorganizes the main server file to import/compose extracted route modules and shared managers; also bundles SPA HTML as text for distribution.

src/server/index.ts

mcp-handler.tsRefactor MCP handler for readability +1638/-1556

Refactor MCP handler for readability

• Applies formatting and internal reorganization to the MCP handler while preserving external semantics.

src/server/mcp-handler.ts

mcp-meta-routes.tsExtract MCP meta routes +217/-0

Extract MCP meta routes

• Adds a focused module for MCP metadata endpoints previously embedded in larger modules.

src/server/mcp-meta-routes.ts

mcp-proxy-errors.tsExtract MCP proxy error helpers +21/-0

Extract MCP proxy error helpers

• Adds a small module to standardize MCP proxy error mapping/formatting.

src/server/mcp-proxy-errors.ts

mcp-proxy.tsRefactor MCP proxy implementation +467/-661

Refactor MCP proxy implementation

• Applies formatting and internal restructuring to improve readability while preserving behavior.

src/server/mcp-proxy.ts

mcp-tool-defaults.tsExtract MCP tool defaults helpers +141/-0

Extract MCP tool defaults helpers

• Introduces a module for tool defaults logic used across tool execution/formatting paths.

src/server/mcp-tool-defaults.ts

oauth-bridge.tsReformat OAuth bridge +13/-13

Reformat OAuth bridge

• Applies formatting and minor readability improvements; behavior unchanged.

src/server/oauth-bridge.ts

oauth-discovery.tsExtract OAuth discovery/detection logic +202/-0

Extract OAuth discovery/detection logic

• Moves OAuth requirement detection and discovery behavior into a standalone module.

src/server/oauth-discovery.ts

oauth-endpoint-resolve.tsExtract OAuth endpoint resolution helpers +20/-0

Extract OAuth endpoint resolution helpers

• Adds helpers to normalize/resolve mixed endpoint field names from config/discovery sources.

src/server/oauth-endpoint-resolve.ts

oauth-manager.tsSlim OAuth2Manager by composing new OAuth modules +134/-572

Slim OAuth2Manager by composing new OAuth modules

• Refactors OAuth2Manager to delegate discovery, PKCE flow, and token storage to dedicated modules; keeps backward-compat exports.

src/server/oauth-manager.ts

oauth-pkce-flow.tsExtract PKCE authorization URL/callback handling +247/-0

Extract PKCE authorization URL/callback handling

• Adds a dedicated module to generate authorization URLs and process OAuth callbacks with PKCE.

src/server/oauth-pkce-flow.ts

oauth-token-store.tsExtract OAuth token store operations +165/-0

Extract OAuth token store operations

• Centralizes token persistence/retrieval/refresh/disconnect and connected-state checks.

src/server/oauth-token-store.ts

project-fs.tsReformat project filesystem helpers +162/-147

Reformat project filesystem helpers

• Applies formatting and small readability improvements; behavior intended unchanged.

src/server/project-fs.ts

project-routes.tsExtract project routes module +557/-0

Extract project routes module

• Introduces a dedicated module for project endpoints, reducing server/index.ts size.

src/server/project-routes.ts

registries-routes.tsRefactor registries routes for readability +240/-230

Refactor registries routes for readability

• Applies formatting and internal reorganization while preserving handler behavior.

src/server/registries-routes.ts

resolve-effective-capabilities.tsRefactor effective capabilities resolution module +187/-168

Refactor effective capabilities resolution module

• Applies formatting and internal cleanup to effective capability computation/caching.

src/server/resolve-effective-capabilities.ts

session-manager.tsRefactor session manager module +364/-342

Refactor session manager module

• Applies formatting and readability improvements to session lifecycle management.

src/server/session-manager.ts

skill-content.tsRefactor skill content module +229/-205

Refactor skill content module

• Applies formatting and minor internal cleanup; behavior unchanged.

src/server/skill-content.ts

stdio-client-transport.tsRefactor stdio client transport module +166/-159

Refactor stdio client transport module

• Applies formatting and internal cleanup for readability; behavior unchanged.

src/server/stdio-client-transport.ts

subprocess-manager.tsRefactor subprocess manager module +320/-292

Refactor subprocess manager module

• Applies formatting and internal organization improvements to subprocess lifecycle management.

src/server/subprocess-manager.ts

token-refresh-routes.tsExtract token refresh routes module +41/-0

Extract token refresh routes module

• Adds a focused module for token refresh endpoints separate from scheduler logic.

src/server/token-refresh-routes.ts

token-refresh-scheduler.tsRefactor token refresh scheduler +277/-253

Refactor token refresh scheduler

• Applies formatting and internal restructuring to refresh scheduling and retry behavior.

src/server/token-refresh-scheduler.ts

tool-executor.tsRefactor tool executor module +247/-220

Refactor tool executor module

• Applies formatting and internal cleanup to tool execution pipeline; behavior intended unchanged.

src/server/tool-executor.ts

tool-formatter.tsRefactor tool formatter module +137/-128

Refactor tool formatter module

• Applies formatting and internal cleanup to tool formatting and raw-arg behavior; behavior unchanged.

src/server/tool-formatter.ts

variables-routes.tsExtract variables routes module +85/-0

Extract variables routes module

• Adds a focused module for variables endpoints to reduce server/index.ts complexity.

src/server/variables-routes.ts

authenticated-fetch.tsRefactor authenticated-fetch helpers +267/-255

Refactor authenticated-fetch helpers

• Applies formatting and minor internal cleanup to authenticated fetch creation and helpers.

src/shared/authenticated-fetch.ts

git-cli.tsReformat git-cli cache helpers +34/-34

Reformat git-cli cache helpers

• Formatting-only readability changes; behavior unchanged.

src/shared/cache/git-cli.ts

index.tsTidy cache module exports +23/-24

Tidy cache module exports

• Adjusts exports/import ordering to match reorganized cache modules; behavior unchanged.

src/shared/cache/index.ts

mirror.tsReformat mirror cache module +126/-127

Reformat mirror cache module

• Applies formatting and minor internal cleanup; behavior unchanged.

src/shared/cache/mirror.ts

paths.tsReformat cache path helpers +20/-14

Reformat cache path helpers

• Applies formatting and minor cleanup; behavior unchanged.

src/shared/cache/paths.ts

snapshot.tsReformat snapshot cache module +145/-129

Reformat snapshot cache module

• Applies formatting and minor internal cleanup; behavior unchanged.

src/shared/cache/snapshot.ts

stats.tsReformat cache stats module +95/-95

Reformat cache stats module

• Formatting-only readability changes; behavior unchanged.

src/shared/cache/stats.ts

validate.tsReformat cache validation helpers +15/-15

Reformat cache validation helpers

• Formatting-only readability changes; behavior unchanged.

src/shared/cache/validate.ts

capabilities.tsRefactor capabilities parsing/mutation utilities +377/-370

Refactor capabilities parsing/mutation utilities

• Applies formatting and internal cleanup to capability parsing and mutation helpers; behavior intended unchanged.

src/shared/capabilities.ts

config.tsReformat shared config helpers +51/-51

Reformat shared config helpers

• Applies formatting and minor readability improvements; behavior unchanged.

src/shared/config.ts

env-parser.tsReformat env parser +35/-33

Reformat env parser

• Applies formatting and minor readability improvements; behavior unchanged.

src/shared/env-parser.ts

parsers.tsReformat git provider parsers +140/-126

Reformat git provider parsers

• Applies formatting and internal cleanup to ref/url parsing; behavior unchanged.

src/shared/git-providers/parsers.ts

registry.tsReformat git provider registry +58/-53

Reformat git provider registry

• Applies formatting and minor cleanup; behavior unchanged.

src/shared/git-providers/registry.ts

hooks-validate.tsReformat hooks validation helpers +177/-177

Reformat hooks validation helpers

• Formatting-only readability changes; behavior unchanged.

src/shared/hooks-validate.ts

lockfile.tsRefactor lockfile builder/serializer for readability +287/-252

Refactor lockfile builder/serializer for readability

• Applies formatting and internal cleanup to lockfile read/write and builder utilities; behavior intended unchanged.

src/shared/lockfile.ts

logger.tsReformat logger utilities +167/-160

Reformat logger utilities

• Applies formatting and minor internal cleanup; behavior unchanged.

src/shared/logger.ts

mcp-icons.tsReformat MCP icons map +6/-6

Reformat MCP icons map

• Formatting-only readability changes; behavior unchanged.

src/shared/mcp-icons.ts

oauth-refresh.tsReformat OAuth refresh helpers +19/-13

Reformat OAuth refresh helpers

• Applies formatting and minor readability improvements; behavior unchanged.

src/shared/oauth-refresh.ts

paths.tsReformat shared path helpers +58/-53

Reformat shared path helpers

• Applies formatting and minor cleanup; behavior unchanged.

src/shared/paths.ts

claude-parser.tsNormalize formatting in Claude plugin manifest parser +30/-25

Normalize formatting in Claude plugin manifest parser

• Applies formatting/quote normalization and minor cleanup; behavior unchanged.

src/shared/plugin-manifest/claude-parser.ts

cursor-parser.tsNormalize formatting in Cursor plugin manifest parser +47/-40

Normalize formatting in Cursor plugin manifest parser

• Applies formatting/quote normalization and minor cleanup; behavior unchanged.

src/shared/plugin-manifest/cursor-parser.ts

detect.tsRefactor plugin manifest detection for readability +214/-188

Refactor plugin manifest detection for readability

• Applies formatting and internal cleanup to manifest detection across providers; behavior intended unchanged.

src/shared/plugin-manifest/detect.ts

index.tsReformat plugin manifest exports +6/-6

Reformat plugin manifest exports

• Formatting-only changes to match new module organization.

src/shared/plugin-manifest/index.ts

mcp-parser.tsRefactor MCP plugin manifest parser +186/-158

Refactor MCP plugin manifest parser

• Applies formatting and internal readability improvements; behavior unchanged.

src/shared/plugin-manifest/mcp-parser.ts

types-helpers.tsReformat plugin manifest type helpers +68/-63

Reformat plugin manifest type helpers

• Applies formatting and internal cleanup; behavior unchanged.

src/shared/plugin-manifest/types-helpers.ts

plugin-source.tsReformat plugin source validation/resolution +141/-118

Reformat plugin source validation/resolution

• Applies formatting and internal cleanup to plugin source handling; behavior unchanged.

src/shared/plugin-source.ts

claude-code.tsAdd provider entry for Claude Code +68/-0

Add provider entry for Claude Code

• Moves Claude Code integration facts (paths, hooks config, manifests) into entries/claude-code for assembly by the registry.

src/shared/providers/entries/claude-code.ts

codex.tsAdd provider entry for Codex +78/-0

Add provider entry for Codex

• Moves Codex integration facts into entries/codex for assembly by the registry.

src/shared/providers/entries/codex.ts

cursor.tsAdd provider entry for Cursor +78/-0

Add provider entry for Cursor

• Moves Cursor integration facts (including .cursor paths) into entries/cursor for assembly by the registry.

src/shared/providers/entries/cursor.ts

gemini-cli.tsAdd provider entry for Gemini CLI +70/-0

Add provider entry for Gemini CLI

• Moves Gemini CLI integration facts into entries/gemini-cli for assembly by the registry.

src/shared/providers/entries/gemini-cli.ts

github-copilot.tsAdd provider entry for GitHub Copilot +35/-0

Add provider entry for GitHub Copilot

• Moves GitHub Copilot integration facts into entries/github-copilot for assembly by the registry.

src/shared/providers/entries/github-copilot.ts

opencode.tsAdd provider entry for OpenCode +48/-0

Add provider entry for OpenCode

• Moves OpenCode integration facts into entries/opencode for assembly by the registry.

src/shared/providers/entries/opencode.ts

partial-integration.tsAdd module grouping partial-integration providers +393/-0

Add module grouping partial-integration providers

• Extracts providers with partial integration behavior into a dedicated module consumed by the registry.

src/shared/providers/entries/partial-integration.ts

skills-only.tsAdd module grouping skills-only providers +144/-0

Add module grouping skills-only providers

• Extracts providers that currently only support skill paths into a dedicated module consumed by the registry.

src/shared/providers/entries/skills-only.ts

handlers.tsRefactor provider handlers for readability +221/-191

Refactor provider handlers for readability

• Applies formatting and internal cleanup to provider handlers used by installers and rendering paths.

src/shared/providers/handlers.ts

hook-handlers.tsRefactor provider hook handlers for readability +221/-220

Refactor provider hook handlers for readability

• Applies formatting and minor internal cleanup to hook entry builders/upserters across provider formats.

src/shared/providers/hook-handlers.ts

index.tsUpdate provider exports after registry split +82/-68

Update provider exports after registry split

• Adjusts exports/imports to align with the new provider registry assembly and helper modules while keeping a stable public API.

src/shared/providers/index.ts

paths.tsExtract shared provider path resolution helpers +20/-0

Extract shared provider path resolution helpers

• Adds shared path helpers (e.g., config homes) used by provider entry modules.

src/shared/providers/paths.ts

registry.tsReplace monolithic provider registry with entry assembly +18/-866

Replace monolithic provider registry with entry assembly

• Collapses a large inline registry into a small assembler importing entries/* and exporting the providers map.

src/shared/providers/registry.ts

resolve.tsRefactor provider resolution logic +109/-107

Refactor provider resolution logic

• Applies formatting and minor internal cleanup around provider selection/resolution; behavior unchanged.

src/shared/providers/resolve.ts

installer.tsRefactor registries installer for readability +331/-299

Refactor registries installer for readability

• Applies formatting and minor internal cleanup to registry install/update paths; behavior unchanged.

src/shared/registries/installer.ts

loader.tsRefactor registries loader for readability +132/-120

Refactor registries loader for readability

• Applies formatting and minor internal cleanup to registry loading/validation; behavior unchanged.

src/shared/registries/loader.ts

manager.tsRefactor registries manager for readability +88/-72

Refactor registries manager for readability

• Applies formatting and minor internal cleanup; behavior unchanged.

src/shared/registries/manager.ts

seed.tsRefactor default registry seeding for readability +98/-90

Refactor default registry seeding for readability

• Applies formatting and minor internal cleanup; behavior unchanged.

src/shared/registries/seed.ts

repo-file.tsRefactor repo-file utilities for readability +252/-226

Refactor repo-file utilities for readability

• Applies formatting and internal cleanup to repo file fetching and safe path enforcement; behavior unchanged.

src/shared/repo-file.ts

repo-string.tsRefactor repo string parsing for readability +126/-112

Refactor repo string parsing for readability

• Applies formatting and internal cleanup to repo string parsing helpers; behavior unchanged.

src/shared/repo-string.ts

safe-remote-url.tsRefactor safe remote URL helpers +137/-125

Refactor safe remote URL helpers

• Applies formatting and internal cleanup; behavior unchanged.

src/shared/safe-remote-url.ts

skill-copy.tsRefactor skill copy utilities +163/-147

Refactor skill copy utilities

• Applies formatting and internal cleanup around skill file copying/layout; behavior unchanged.

src/shared/skill-copy.ts

skill-md.tsRefactor skill markdown helpers +50/-44

Refactor skill markdown helpers

• Applies formatting and internal cleanup; behavior unchanged.

src/shared/skill-md.ts

skill-security.tsRefactor skill security checks +147/-117

Refactor skill security checks

• Applies formatting and internal cleanup around sanitization/blocked phrases; behavior unchanged.

src/shared/skill-security.ts

slug.tsReformat slug helper +7/-7

Reformat slug helper

• Formatting-only readability changes; behavior unchanged.

src/shared/slug.ts

tls-skip-verify.tsRefactor TLS skip-verify helper +28/-25

Refactor TLS skip-verify helper

• Applies formatting and minor cleanup; behavior unchanged.

src/shared/tls-skip-verify.ts

toml-io.tsRefactor TOML IO utilities +57/-47

Refactor TOML IO utilities

• Applies formatting and internal cleanup to TOML read/write helpers; behavior unchanged.

src/shared/toml-io.ts

tty.tsReformat TTY helper +3/-3

Reformat TTY helper

• Formatting-only readability changes; behavior unchanged.

src/shared/tty.ts

ui-urls.tsRefactor UI URL helpers +22/-15

Refactor UI URL helpers

• Applies formatting and minor internal cleanup around URL construction; behavior unchanged.

src/shared/ui-urls.ts

variable-resolver.tsRefactor variable resolver for readability +70/-68

Refactor variable resolver for readability

• Applies formatting and minor internal cleanup to variable extraction/resolution; behavior unchanged.

src/shared/variable-resolver.ts

paths.tsReformat workspace paths helper +15/-15

Reformat workspace paths helper

• Formatting-only readability changes; behavior unchanged.

src/shared/workspaces/paths.ts

AgentsEditor.tsxReplace AgentsEditor monolith with re-export shim +1/-556

Replace AgentsEditor monolith with re-export shim

• Collapses the old AgentsEditor component file to a thin shim exporting the split implementation under components/agents/.

<a href='https://github.co...

Minitour and others added 2 commits August 1, 2026 10:57
Centralize validatePluginDef via assertValidPluginSource so GitLab and URL forms reject unsafe subpaths the same way GitHub shorthand already did.

Co-authored-by: Cursor <cursoragent@cursor.com>
…er bugs.

Keep one wrap workspace per project id and provider, skip lockfile rewrites when pins are unchanged, avoid wrap overwriting install providers, and clean subagent files from capabilities when providers are unset.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Minitour
Minitour merged commit 565e336 into version-2.0 Aug 1, 2026
@Minitour
Minitour deleted the chore/code-cleanup-readability branch August 1, 2026 09:04
@Minitour Minitour mentioned this pull request Aug 2, 2026
9 tasks
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.

1 participant