Skip to content

Refactor: dead-code cleanup, dependency upgrades, and Gemini request-shape fix (0.11.2)#101

Merged
shinpr merged 11 commits into
mainfrom
refactor/dead-code-cleanup
Jun 7, 2026
Merged

Refactor: dead-code cleanup, dependency upgrades, and Gemini request-shape fix (0.11.2)#101
shinpr merged 11 commits into
mainfrom
refactor/dead-code-cleanup

Conversation

@shinpr

@shinpr shinpr commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Summary

A refactoring pass that removes dead code, tightens the public API surface, upgrades all dependencies (including majors), adopts knip for ongoing dead-code detection, and fixes two latent Gemini request-shape bugs uncovered along the way. Releases 0.11.2.

Every step was verified with the full gate (npm run check:all: lint / format / circular deps / knip / build / tests) staying green, and the Gemini fix was additionally confirmed against the real API.

Changes

Dead code & API surface

  • Remove 4 orphaned test helper/mock files (~1,415 lines, zero references) and unused SecurityManager methods (validateDirectoryPath, isPathAllowed, generateSecureTempPath) plus hasImageExtension. This also eliminates Windows-incompatible /tmp hardcoding.
  • Narrow over-broad exports to internal-only: validateImagePath, McpContent, ErrorWithCode.
  • Remove thin type aliases (GeminiApiParams / GeminiGenerationMetadata / GeminiClient) in favor of the shared Image* abstraction types.

Tooling & dependencies

  • Activate husky git hooks via a prepare script (previously dormant) and drop the unused tsx devDependency.
  • Update minor/patch dependencies within range.
  • Major upgrades: TypeScript 6, lint-staged 17, and @google/genai 2.8.0. Removed unused baseUrl/paths from tsconfig (resolving the TS6 deprecation) and the now-redundant tsc-alias build step.
  • Adopt knip for unused-code detection, wired into check:all and CI. Removed the orphaned .rmdrc.cjs (ts-prune config) and the dead report-missing-dependencies CI step.

Fix: Gemini generateContent request shape

A hand-written GeminiClientInstance interface loosely typed the request, hiding two runtime bugs:

  • useGoogleSearch was sent as a top-level tools field, which is not part of GenerateContentParameters — the SDK silently dropped it, so grounding never activated.
  • The balanced preset sent thinkingLevel: 'high' (lowercase), not matching the SDK ThinkingLevel enum ('HIGH'), so the thinking config was silently ignored.

Root-cause fix: type the request against the real SDK types (GenerateContentParameters / GenerateContentConfig / Content / ImageConfig) and use the ThinkingLevel enum. tools now lives under config.tools, and the compiler catches future drift. Tests assert config.tools and the 'HIGH' value; the genai mock preserves real exports via importActual.

Verification

  • npm run check:all green (234 tests, lint, format, circular deps, knip, build).
  • Real-API smoke test of the Gemini fix: quality: 'balanced' + useGoogleSearch: true generated successfully with no API error, confirming the new payload shape is accepted end-to-end.

🤖 Generated with Claude Code

shinpr and others added 11 commits June 7, 2026 20:26
…ager methods)

- Delete 4 orphaned test helper/mock files (~1415 lines, zero references)
- Remove unused SecurityManager methods: validateDirectoryPath, isPathAllowed,
  generateSecureTempPath (also eliminates Windows-incompatible /tmp hardcoding)
- Remove unused hasImageExtension from mimeUtils
- Drop orphaned tests and now-unused randomBytes import

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Drop unnecessary export from validateImagePath, McpContent, and ErrorWithCode
(all consumed only within their own module), shrinking the public API surface.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Drop GeminiGenerationMetadata/GeminiApiParams/GeminiClient aliases that merely
renamed the shared ImageClient abstraction types, and use the base types
directly. Removes duplicate naming left over from the provider abstraction.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Add 'prepare': 'husky' so git hooks are installed on npm install
  (previously .husky/ hooks were dormant without a prepare script)
- Remove tsx, which was not referenced by any script, source, or CI

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bump biome, @types/node, vitest tooling, and openai to their latest
compatible releases via npm update (lockfile only; ranges unchanged).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Bump typescript ^5.9 -> ^6.0 and lint-staged ^16 -> ^17
- Remove unused baseUrl/paths from tsconfig (src/* alias had zero imports);
  this also resolves the TS6 baseUrl deprecation error without ignoreDeprecations
- Drop tsc-alias, now a no-op build step with no path aliases to rewrite

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The v2 breaking changes are confined to the Interactions API, which this
codebase does not use. GenerateContent usage (GoogleGenAI constructor +
models.generateContent) is unchanged. Verified via tsc type check against
the v2 type definitions, full test suite, and a runtime API-surface smoke test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Add knip devDependency + knip.json declaring bin/install-skills.js as an
  entry (it is dynamically imported via a computed path in src/index.ts, so
  static analysis cannot see it) and ignoring the npx-invoked
  report-missing-dependencies binary
- Wire 'check:unused' into check:all and CI so dead code is caught going forward
- Remove orphaned .rmdrc.cjs (ts-prune config; ts-prune was never installed
  and is superseded by knip)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The CI step ran 'npx report-missing-dependencies', a tool that was never a
project dependency and provided no working dependency check. knip's
check:unused now covers unused/unlisted dependencies, so drop the step and
the now-redundant knip ignoreBinaries entry.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Two latent bugs were hidden by a hand-written GeminiClientInstance interface
that loosely typed the generateContent parameters:

- Google Search grounding (useGoogleSearch) was passed as a top-level 'tools'
  field, which is not part of GenerateContentParameters, so the SDK silently
  dropped it and grounding never activated.
- The 'balanced' quality preset sent thinkingLevel: 'high' (lowercase), which
  does not match the SDK ThinkingLevel enum ('HIGH'), so the thinking config
  was silently ignored.

Root cause fix: type the request against the real SDK types
(GenerateContentParameters/GenerateContentConfig, Content, ImageConfig) and use
the ThinkingLevel enum. tools now correctly lives under config.tools, and the
compiler will catch any future drift. Tests assert config.tools and the 'HIGH'
enum value; the genai mock preserves real module exports via importActual.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@shinpr shinpr self-assigned this Jun 7, 2026
@shinpr shinpr merged commit 76f6080 into main Jun 7, 2026
1 check passed
@shinpr shinpr deleted the refactor/dead-code-cleanup branch June 7, 2026 12:21
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