feat: replace bin.intent detection with tanstack-intent keyword#81
feat: replace bin.intent detection with tanstack-intent keyword#81KyleAMathews wants to merge 5 commits intomainfrom
Conversation
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 detectedLatest commit: b042a75 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughReplaces 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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
commit: |
There was a problem hiding this comment.
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 parentpackage.jsonwithworkspaces.Consider extracting this into a shared utility function in
utils.tsto 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 bothcli.tsandsetup.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
📒 Files selected for processing (13)
.changeset/keyword-based-detection.mddocs/cli/intent-scaffold.mddocs/cli/intent-setup.mddocs/cli/intent-validate.mddocs/getting-started/quick-start-maintainers.mdpackages/intent/package.jsonpackages/intent/src/cli.tspackages/intent/src/index.tspackages/intent/src/library-scanner.tspackages/intent/src/setup.tspackages/intent/tests/cli.test.tspackages/intent/tests/library-scanner.test.tspackages/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' |
There was a problem hiding this comment.
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.
| 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.
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>
Summary
Replace the bin shim-based package detection with a simpler
"tanstack-intent"keyword check. Remove the entireadd-library-bincommand and bin shim generation system — packages are now identified solely by having"tanstack-intent"in theirkeywordsarray, 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.jsshim file, abin.intententry in package.json, and"bin"in thefilesarray. Thetanstack-intentkeyword was already being added byedit-package-jsonfor 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()— checkskeywords.includes('tanstack-intent')instead ofbin.intentpresencesetup.ts: Removed ~130 lines —AddLibraryBinResult,getShimContent,detectShimExtension,findExistingShim,runAddLibraryBin,runAddLibraryBinAll, and all bin field wiring fromrunEditPackageJson. Thefilesarray no longer includes"bin".cli.ts: Removedadd-library-bincommand (USAGE, help, switch case). Packaging warnings now check fortanstack-intentkeyword instead of bin entries. FixedcollectPackagingWarningsto skip!skills/_artifactswarning for monorepo packages (matchingedit-package-jsonbehavior).index.ts: RemovedrunAddLibraryBinandAddLibraryBinResultexportsKey invariants:
scanner.ts(consumer-sideintent list) is unchanged — still usesskills/directory + intent configlibrary-scanner.ts(library dependency walking) now gates on keyword instead of binedit-package-jsonstill adds the keyword, so existing setup workflows continue to workNon-goals:
Verification
New tests added:
runEditPackageJson(adds when missing, appends to existing, reports already-present)hasIntentKeywordwith non-matching keywords arrayFiles changed
src/library-scanner.tshasIntentBin→hasIntentKeywordsrc/setup.tsfiles/runEditPackageJsonsrc/cli.tsadd-library-bincommand, keyword-based packaging warnings, monorepo-aware!skills/_artifactssrc/index.tstests/library-scanner.test.tskeywords, renamedshimPath→scriptPath, added keyword-mismatch testtests/setup.test.tstests/cli.test.tsdocs/*.md🤖 Generated with Claude Code
Summary by CodeRabbit
Removed Features
Changed Features
Documentation
Chores