Skip to content

[Request]: Reduce duplicated middleware sources, MCP test execution paths and shared authoring guidance #1095

Closed

Description

@jimhoyd

Problem or use case

Follow-up to the deep audit: the maintainer asked whether AI tooling looks good and whether unnecessary code, examples and tests can be removed. Reviewed current main 6a04c45; no code deleted. These are consolidation candidates with observed evidence, not proof that the public features are unused.

  1. examples/cookbook/middleware/*.mjs and recipes/middleware/middleware/*.mjs contain 14 byte-identical files: 259 duplicate lines / 14,297 bytes. test/recipes.test.ts explicitly checks the mirror. Both deliverables are used (full cookbook versus copyable recipe), but maintaining two authored versions is unnecessary. Make one canonical and derive the other during build/generation, keeping shipped copies standalone and testing actual packed output.
  2. MCP offers both run_tests in mcp.ts (in-process, structured events) and run_test in mcp-authoring.ts (CLI subprocess, bounded stdout/exit status). Both execute request fixtures and are authoring-gated, but policy, environment, timeout, host lifecycle and result contracts differ. [Bug]: verification commands and MCP subprocess runners drop the supplied extension host #778 and MCP in-process run_tests and get_context's suggested commands lack the local review (follow-up to #940) #964 document past fixes that had to reach both paths. Assess one execution implementation with result adapters/compatibility names; do not blindly alias them and change security or caller behavior. If deliberately retaining both, make the distinct use cases explicit. There is no usage evidence here authorizing deletion of either public name.
  3. skills/urlcode/SKILL.md (150 lines) and .claude/skills/urlcode-authoring/SKILL.md (311 lines) separately maintain overlapping local authoring, declarative-first, verification and trust instructions. The Claude skill also owns hosted-assisted bootstrap behavior, so it is not a duplicate file to delete. Consider one source for shared sections plus small client/mode sections. The marketplace copies and starter AGENTS.md already have generators; do not add another hand-maintained copy or remove their drift guards.

Proposed behavior and alternatives

Start with the byte-identical middleware source consolidation. Then consider the MCP runner and common skill facts as separate focused changes with explicit compatibility constraints. Measure reduced authored lines/maintenance surfaces and unchanged packaged behavior, rather than optimizing a test/file count.

Keep the distinct contract coverage: source unit tests, packed-consumer smoke, real HTTP/sandbox refusal tests, and Better Auth/Auth.js/native-storage/Hono proofs. Matching frontend files or route shapes do not make those provider/embedding tests redundant. json-api demonstrates a dynamic echo function while json-endpoint demonstrates declarative validation/respond; those are also different lessons despite similar names. No particular regression test was proven safe to delete in this pass.

Public changes need docs in the same PR; packaging/generator changes need full verify and test:package. This issue is a scoped cleanup assessment, not authorization to restore the retired universal adapter roadmap.

Activity

  1. jimhoyd commented on Sep 30, 2026

    @jimhoyd
    CollaboratorAuthor

    Item 1 is addressed in #1103 (the cookbook is the only authored copy, and the recipe copies are generated and checked, including in the packed archive). Below is an assessment of items 2 and 3. No behavior changed. Both items stay open.

    Item 2: MCP run_tests (mcp.ts) vs run_test (mcp-authoring.ts). These are two execution models, not one duplicated path:

    Their policy forwarding, host lifecycle, timeouts and result contracts differ, and callers depend on both result shapes. Recommendation: do not alias them.

    Item 3: skills/urlcode/SKILL.md (150 lines) vs .claude/skills/urlcode-authoring/SKILL.md (311 lines). The overlap is real (local authoring loop, declarative-first, verification, trust model), but the Claude skill also owns hosted-assisted bootstrap. Recommendation: pick one source for the shared sections, for example a fragment file rendered into both by the existing generate-agent-assets.ts pipeline with --check. Keep the client- and mode-specific sections hand-written. Keep check-guidance-claims.ts and the marketplace drift guards as they are.

  2. jimhoyd commented on Sep 30, 2026

    @jimhoyd
    CollaboratorAuthor

    Taking this: coordinator session. Item 1 is in #1103; items 2 and 3 are in progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions