Skip to content

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

Open
KyleAMathews wants to merge 5 commits intomainfrom
feat/keyword-based-detection
Open

feat: replace bin.intent detection with tanstack-intent keyword#81
KyleAMathews wants to merge 5 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 detection now uses the tanstack-intent keyword instead of a bin-based marker.
    • Setup workflow simplified from three steps to two.
    • Packaging warnings adjusted to skip certain artifact warnings for monorepos.
  • Documentation

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

    • Version bump and corresponding test updates.

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: b042a75

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: e715dacc-b910-434b-ab53-b4d9e89b4103

📥 Commits

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

📒 Files selected for processing (2)
  • packages/intent/src/library-scanner.ts
  • packages/intent/tests/library-scanner.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/intent/src/library-scanner.ts

📝 Walkthrough

Walkthrough

Replaces bin.intent-based detection with keyword-based detection that checks for "tanstack-intent" (with a legacy fallback to bin.intent). 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 references to add-library-bin and shim creation; updated setup/validate docs to require tanstack-intent keyword and note that setup-github-actions skips existing files.
Core detection
packages/intent/src/library-scanner.ts
Introduced isIntentPackage(pkg) which checks keywords for "tanstack-intent" with a legacy fallback to bin.intent; replaced previous hasIntentBin usage across dependency 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 focus on tanstack-intent keyword and adjusted monorepo-aware requiredFiles handling.
CLI surface
packages/intent/src/cli.ts
Removed CLI command and help text for add-library-bin; updated packaging checks to validate keywords instead of bin; made packaging warnings monorepo-aware (skip !skills/_artifacts for monorepos).
Public exports
packages/intent/src/index.ts
Removed exports of 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
Replaced bin.intent fixtures with keywords: ['tanstack-intent']; swapped shimPath usages to scriptPath; removed tests/imports 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, just keywords — tanstack-intent.
Old bins remembered, if they still remain,
Cleaner trails now guide the rabbit's brain. 🥕

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

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.
Description check ❓ Inconclusive The PR description provides comprehensive detail on changes, rationale, and verification, but the required checklist section is missing or incomplete. Ensure the description includes the standard checklist with items checked (Contributing guide, test verification) and the Release Impact section with changeset generation confirmed.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: replace bin.intent detection with tanstack-intent keyword' accurately and concisely summarizes the main change: replacing bin-based detection with keyword-based detection.

✏️ 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: b042a75

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

EditPackageJsonResult,
AddLibraryBinResult,
} from '../src/setup.js'
import type { MonorepoResult, EditPackageJsonResult } from '../src/setup.js'
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix import member ordering.

Static analysis indicates the import members should be sorted alphabetically.

🔧 Proposed fix
-import type { MonorepoResult, EditPackageJsonResult } from '../src/setup.js'
+import type { EditPackageJsonResult, MonorepoResult } from '../src/setup.js'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import type { MonorepoResult, EditPackageJsonResult } from '../src/setup.js'
import type { EditPackageJsonResult, MonorepoResult } from '../src/setup.js'
🧰 Tools
🪛 ESLint

[error] 17-17: Member 'EditPackageJsonResult' of the import declaration should be sorted alphabetically.

(sort-imports)

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

In `@packages/intent/tests/setup.test.ts` at 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.

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>
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