Skip to content

feat: replace bin.intent detection with tanstack-intent keyword#81

Merged
KyleAMathews merged 6 commits intomainfrom
feat/keyword-based-detection
Mar 15, 2026
Merged

feat: replace bin.intent detection with tanstack-intent keyword#81
KyleAMathews merged 6 commits intomainfrom
feat/keyword-based-detection

Conversation

@KyleAMathews
Copy link
Collaborator

@KyleAMathews KyleAMathews commented Mar 15, 2026

Summary

Replace the bin shim-based package detection with a simpler "tanstack-intent" keyword check. Remove the entire add-library-bin command and bin shim generation system — packages are now identified solely by having "tanstack-intent" in their keywords array, which was already required for registry discovery and now serves both purposes.

Net: -349 lines added, +136 lines (213 lines removed).

Approach

Why keyword instead of bin.intent?

The old approach required three coordinated pieces: a generated bin/intent.js shim file, a bin.intent entry in package.json, and "bin" in the files array. The tanstack-intent keyword was already being added by edit-package-json for npm registry discovery. Using it for local detection too eliminates the entire shim layer — one field serves both purposes.

What changed:

  • library-scanner.ts: hasIntentBin()hasIntentKeyword() — checks keywords.includes('tanstack-intent') instead of bin.intent presence
  • setup.ts: Removed ~130 lines — AddLibraryBinResult, getShimContent, detectShimExtension, findExistingShim, runAddLibraryBin, runAddLibraryBinAll, and all bin field wiring from runEditPackageJson. The files array no longer includes "bin".
  • cli.ts: Removed add-library-bin command (USAGE, help, switch case). Packaging warnings now check for tanstack-intent keyword instead of bin entries. Fixed collectPackagingWarnings to skip !skills/_artifacts warning for monorepo packages (matching edit-package-json behavior).
  • index.ts: Removed runAddLibraryBin and AddLibraryBinResult exports

Key invariants:

  • scanner.ts (consumer-side intent list) is unchanged — still uses skills/ directory + intent config
  • library-scanner.ts (library dependency walking) now gates on keyword instead of bin
  • edit-package-json still adds the keyword, so existing setup workflows continue to work

Non-goals:

  • Did not address pre-existing empty catch blocks in library-scanner.ts (flagged by review but out of scope)
  • Did not change the consumer-side scanner detection logic

Verification

pnpm exec tsc --noEmit     # types clean
pnpm exec vitest run        # 204 tests pass (up from 151 — new keyword tests added)
pnpm exec knip              # no unused exports

New tests added:

  • 3 tests for keyword addition in runEditPackageJson (adds when missing, appends to existing, reports already-present)
  • 1 test for hasIntentKeyword with non-matching keywords array

Files changed

File Change
src/library-scanner.ts hasIntentBinhasIntentKeyword
src/setup.ts Remove bin shim system, remove bin from files/runEditPackageJson
src/cli.ts Remove add-library-bin command, keyword-based packaging warnings, monorepo-aware !skills/_artifacts
src/index.ts Remove bin-related exports
tests/library-scanner.test.ts Fixtures use keywords, renamed shimPathscriptPath, added keyword-mismatch test
tests/setup.test.ts Remove bin tests, add 3 keyword tests
tests/cli.test.ts Update fixture to use keywords
docs/*.md Remove all bin shim references

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Removed Features

    • Removed the add-library-bin CLI command and its shim-generation step.
  • Changed Features

    • Package discovery now relies on the tanstack-intent keyword instead of a bin marker.
    • Setup workflow simplified from three steps to two.
    • Packaging warnings updated to skip certain artifact warnings for monorepos.
  • Documentation

    • CLI guides, setup, and quick-start docs updated to match the new workflow.
  • Chores

    • Package version bumped and tests updated.

KyleAMathews and others added 2 commits March 15, 2026 10:43
Replace the bin shim-based package detection in library-scanner with a
simpler check for the "tanstack-intent" keyword in the keywords array.
Remove the entire add-library-bin command and bin shim generation system,
since the keyword already existed for registry discovery and now serves
both purposes.

Also fix collectPackagingWarnings to not warn about !skills/_artifacts
in monorepo packages (matching edit-package-json behavior), and add
dedicated test coverage for keyword addition in runEditPackageJson.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@changeset-bot
Copy link

changeset-bot bot commented Mar 15, 2026

🦋 Changeset detected

Latest commit: 70b8ee2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tanstack/intent Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Mar 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 29c9543d-1825-4c4f-9ce1-e28e0e6823fc

📥 Commits

Reviewing files that changed from the base of the PR and between b042a75 and 70b8ee2.

📒 Files selected for processing (1)
  • packages/intent/tests/setup.test.ts

📝 Walkthrough

Walkthrough

Replaces bin.intent detection with keyword-based detection for "tanstack-intent" (legacy bin.intent fallback); removes the add-library-bin command and all shim generation; updates CLI, setup logic, tests, docs, and bumps package version.

Changes

Cohort / File(s) Summary
Documentation
docs/cli/intent-scaffold.md, docs/cli/intent-setup.md, docs/cli/intent-validate.md, docs/getting-started/quick-start-maintainers.md
Removed add-library-bin and shim generation references; updated setup/validate guidance to require the tanstack-intent keyword and note that setup-github-actions skips existing files; adjusted required-files guidance for monorepos.
Core detection
packages/intent/src/library-scanner.ts
Added isIntentPackage(pkg) to detect tanstack-intent in keywords with legacy fallback to bin.intent; replaced hasIntentBin usage across traversal.
Setup implementation
packages/intent/src/setup.ts
Removed shim-related helpers and all add-library-bin code/exports (runAddLibraryBin, runAddLibraryBinAll, AddLibraryBinResult); simplified runEditPackageJson to add/check tanstack-intent and adjusted monorepo-aware requiredFiles handling.
CLI surface
packages/intent/src/cli.ts
Removed CLI command/help for add-library-bin; switched packaging checks from bin to tanstack-intent keyword; made packaging warnings monorepo-aware (skip !skills/_artifacts for monorepos).
Public exports
packages/intent/src/index.ts
Removed exports for runAddLibraryBin and AddLibraryBinResult; retained runEditPackageJson and runSetupGithubActions.
Tests
packages/intent/tests/cli.test.ts, packages/intent/tests/library-scanner.test.ts, packages/intent/tests/setup.test.ts
Updated fixtures to use keywords: ['tanstack-intent']; replaced shimPath with scriptPath; removed imports/tests for runAddLibraryBin/runAddLibraryBinAll; added legacy/fallback and exclusion test cases.
Version
packages/intent/package.json
Bumped version from 0.0.19 to 0.0.20.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I hopped through packages, sniffed a hint,
No shims to bind — just tanstack-intent.
Old bins remembered, tucked in the past,
Keywords now lead the rabbit fast. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.77% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main change: replacing bin.intent detection with tanstack-intent keyword, which is the core objective of this PR.
Description check ✅ Passed The PR description is comprehensive and follows the required template structure with all major sections completed (Summary, Approach, Verification, Files changed) and includes necessary implementation details.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/keyword-based-detection
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 15, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@tanstack/intent@81

commit: 70b8ee2

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/intent/src/cli.ts (1)

259-288: Consider extracting duplicated monorepo detection logic.

This monorepo detection IIFE (lines 263-282) is nearly identical to the one in setup.ts (lines 267-285). Both walk up the directory tree looking for a parent package.json with workspaces.

Consider extracting this into a shared utility function in utils.ts to reduce duplication and ensure consistent behavior.

♻️ Suggested shared helper
// In utils.ts
export function isInsideMonorepo(startDir: string): boolean {
  let dir = join(startDir, '..')
  for (let i = 0; i < 5; i++) {
    const parentPkg = join(dir, 'package.json')
    if (existsSync(parentPkg)) {
      try {
        const parent = JSON.parse(readFileSync(parentPkg, 'utf8'))
        return Array.isArray(parent.workspaces) || !!parent.workspaces?.packages
      } catch {
        return false
      }
    }
    const next = dirname(dir)
    if (next === dir) break
    dir = next
  }
  return false
}

Then use isInsideMonorepo(root) in both cli.ts and setup.ts.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/intent/src/cli.ts` around lines 259 - 288, Extract the duplicated
monorepo detection IIFE (currently assigned to isMonorepoPkg in cli.ts) into a
shared utility function like isInsideMonorepo(startDir: string) in utils.ts,
implementing the same logic (walk up to 5 parents, check parent package.json for
workspaces, handle JSON parse errors, return boolean); then replace the IIFE in
cli.ts with a call to isInsideMonorepo(root) and update the similar block in
setup.ts to call the same helper so both files use the single shared
implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/intent/tests/setup.test.ts`:
- Line 17: The import member order in packages/intent/tests/setup.test.ts is not
alphabetized; update the import statement that imports MonorepoResult and
EditPackageJsonResult from '../src/setup.js' so the imported identifiers are
sorted alphabetically (EditPackageJsonResult before MonorepoResult) to satisfy
the static analysis rule.

---

Nitpick comments:
In `@packages/intent/src/cli.ts`:
- Around line 259-288: Extract the duplicated monorepo detection IIFE (currently
assigned to isMonorepoPkg in cli.ts) into a shared utility function like
isInsideMonorepo(startDir: string) in utils.ts, implementing the same logic
(walk up to 5 parents, check parent package.json for workspaces, handle JSON
parse errors, return boolean); then replace the IIFE in cli.ts with a call to
isInsideMonorepo(root) and update the similar block in setup.ts to call the same
helper so both files use the single shared implementation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4907a80a-63b0-4e23-9647-d8c42878b7df

📥 Commits

Reviewing files that changed from the base of the PR and between 9447688 and 24b8c98.

📒 Files selected for processing (13)
  • .changeset/keyword-based-detection.md
  • docs/cli/intent-scaffold.md
  • docs/cli/intent-setup.md
  • docs/cli/intent-validate.md
  • docs/getting-started/quick-start-maintainers.md
  • packages/intent/package.json
  • packages/intent/src/cli.ts
  • packages/intent/src/index.ts
  • packages/intent/src/library-scanner.ts
  • packages/intent/src/setup.ts
  • packages/intent/tests/cli.test.ts
  • packages/intent/tests/library-scanner.test.ts
  • packages/intent/tests/setup.test.ts
💤 Files with no reviewable changes (1)
  • docs/cli/intent-scaffold.md

KyleAMathews and others added 2 commits March 15, 2026 11:16
Packages already published with bin.intent but without the
tanstack-intent keyword would silently lose transitive skill
discovery. Keep both signals during the transition period.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@KyleAMathews KyleAMathews merged commit 0f2ead5 into main Mar 15, 2026
5 checks passed
@KyleAMathews KyleAMathews deleted the feat/keyword-based-detection branch March 15, 2026 21:13
Rees1993 added a commit to Rees1993/vite-plugin-shopify-theme-islands that referenced this pull request Mar 16, 2026
- Remove bin/intent.js — package detection now uses the tanstack-intent
  keyword, not a bin shim (TanStack/intent#81)
- Regenerate workflows via setup-github-actions (latest templates)
- Fix notify-intent.yml dispatch target: TanStack/intent → github.repository
  so it self-dispatches to trigger skill review in this repo (TanStack/intent#82)
- Fix YAML formatting typo in notify-intent.yml paths block

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

3 participants