-
-
Notifications
You must be signed in to change notification settings - Fork 9
Improve Intent core loading for monorepos and agent adapters #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
d41ef13
fall back to Yarn PnP for stale node_modules
LadyBluenotes 2f62aa7
add shared core skill API
LadyBluenotes df39889
route list and load through core
LadyBluenotes 8b61953
add hard package excludes
LadyBluenotes 467e5e1
fast-path load resolution
LadyBluenotes 75e7fa7
resolve package-prefixed skills by short name
LadyBluenotes ed8d94c
split core implementation helpers
LadyBluenotes 3a7b315
add debug output for list and load
LadyBluenotes aa4d813
ci: apply automated fixes
autofix-ci[bot] 7d98ac7
skip content reads for path loads
LadyBluenotes 975b30f
Merge branch 'core-load-feedback' of https://github.com/TanStack/inte…
LadyBluenotes 2146c51
harden load resolution and list identity
LadyBluenotes a9d7668
reduce direct load path filesystem work
LadyBluenotes fff866a
reduce CLI and load path overhead
LadyBluenotes a21e1a0
cover load content and large workspace paths
LadyBluenotes c943255
ci: apply automated fixes
autofix-ci[bot] 312942f
fix intent core cwd handling and review feedback
LadyBluenotes 36cdc86
changeset
LadyBluenotes 0685eb5
changset
LadyBluenotes c93ff00
ci: apply automated fixes
autofix-ci[bot] 5153bf4
update docs
LadyBluenotes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@tanstack/intent': patch | ||
| --- | ||
|
|
||
| Add the `@tanstack/intent/core` entrypoint for programmatic skill discovery and loading. | ||
|
|
||
| `intent load` now uses the core APIs and a direct dependency fast path, avoiding broad workspace scans when a requested skill can be resolved from the target package. This significantly improves load performance, especially in large workspaces, while preserving markdown link rewriting, warnings, debug output, and existing CLI behavior. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,208 @@ | ||
| import { rmSync } from 'node:fs' | ||
| import { join } from 'node:path' | ||
| import { afterAll, beforeAll, bench, describe } from 'vitest' | ||
| import { | ||
| createBenchOptions, | ||
| createCliRunner, | ||
| createConsoleSilencer, | ||
| createTempDir, | ||
| writeFile, | ||
| writeJson, | ||
| writePackage, | ||
| } from './helpers.js' | ||
|
|
||
| type LoadFixture = { | ||
| root: string | ||
| runner: ReturnType<typeof createCliRunner> | ||
| workspaceRoot: string | ||
| } | ||
|
|
||
| const consoleSilencer = createConsoleSilencer() | ||
| let fixture: LoadFixture | null = null | ||
|
|
||
| function createFixture(): LoadFixture { | ||
| const root = createTempDir('load') | ||
| const workspaceRoot = createTempDir('load-workspace') | ||
|
|
||
| writeLoadProject(root) | ||
| writeLargeWorkspaceProject(workspaceRoot) | ||
|
|
||
| return { | ||
| root, | ||
| runner: createCliRunner({ cwd: root }), | ||
| workspaceRoot, | ||
| } | ||
| } | ||
|
|
||
| function writeLoadProject(root: string): void { | ||
| writeJson(join(root, 'package.json'), { | ||
| name: 'intent-load-benchmark', | ||
| private: true, | ||
| dependencies: { | ||
| '@bench/query': '1.0.0', | ||
| }, | ||
| }) | ||
|
|
||
| writePackage(join(root, 'node_modules'), '@bench/query', '1.0.0', { | ||
| skills: ['query/core', 'query/cache', 'query/testing'], | ||
| }) | ||
|
|
||
| writeQueryCacheContent(join(root, 'node_modules', '@bench', 'query')) | ||
| } | ||
|
|
||
| function writeLargeWorkspaceProject(root: string): void { | ||
| writeJson(join(root, 'package.json'), { | ||
| name: 'intent-large-workspace-load-benchmark', | ||
| private: true, | ||
| workspaces: ['packages/*'], | ||
| dependencies: { | ||
| '@bench/query': '1.0.0', | ||
| }, | ||
| }) | ||
| writeFile(join(root, 'pnpm-workspace.yaml'), "packages:\n - 'packages/*'\n") | ||
|
|
||
| for (let index = 0; index < 120; index++) { | ||
| writeJson(join(root, 'packages', `pkg-${index}`, 'package.json'), { | ||
| name: `@bench/workspace-pkg-${index}`, | ||
| version: '1.0.0', | ||
| dependencies: | ||
| index % 10 === 0 | ||
| ? { | ||
| '@bench/query': '1.0.0', | ||
| } | ||
| : undefined, | ||
| }) | ||
| } | ||
|
|
||
| writePackage(join(root, 'node_modules'), '@bench/query', '1.0.0', { | ||
| skills: ['query/core', 'query/cache', 'query/testing'], | ||
| }) | ||
|
|
||
| writeQueryCacheContent(join(root, 'node_modules', '@bench', 'query')) | ||
| } | ||
|
|
||
| function writeQueryCacheContent(packageRoot: string): void { | ||
| writeFile( | ||
| join(packageRoot, 'docs', 'cache-guide.md'), | ||
| '# Cache guide\n\nUse the cache workflow for repeated queries.\n', | ||
| ) | ||
| writeFile( | ||
| join(packageRoot, 'assets', 'cache.txt'), | ||
| 'cache diagram placeholder\n', | ||
| ) | ||
| writeFile( | ||
| join(packageRoot, 'skills', 'query', 'cache', 'setup.md'), | ||
| '# Cache setup\n\nConfigure query cache defaults.\n', | ||
| ) | ||
| writeFile( | ||
| join(packageRoot, 'skills', 'query', 'cache', 'SKILL.md'), | ||
| [ | ||
| '---', | ||
| 'name: "query/cache"', | ||
| 'description: "query/cache benchmark guidance"', | ||
| 'type: "framework"', | ||
| 'requires:', | ||
| ' - "query"', | ||
| '---', | ||
| '', | ||
| '# Query Cache', | ||
| '', | ||
| 'See [cache guide](../../../docs/cache-guide.md).', | ||
| 'Use [local setup](setup.md#configure).', | ||
| '', | ||
| '', | ||
| '```md', | ||
| '[ignored code link](setup.md)', | ||
| '```', | ||
| '', | ||
| ...Array.from( | ||
| { length: 20 }, | ||
| (_, index) => | ||
| `${index + 1}. Keep cache guidance aligned with [setup](setup.md) and [guide](../../../docs/cache-guide.md#cache).`, | ||
| ), | ||
| '', | ||
| ].join('\n'), | ||
| ) | ||
| } | ||
|
|
||
| function getFixture(): LoadFixture { | ||
| if (!fixture) { | ||
| consoleSilencer.silence() | ||
| try { | ||
| fixture = createFixture() | ||
| } catch (err) { | ||
| consoleSilencer.restore() | ||
| throw err | ||
| } | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| return fixture | ||
| } | ||
|
|
||
| async function setup(): Promise<void> { | ||
| await getFixture().runner.setup() | ||
| } | ||
|
|
||
| function teardown(): void { | ||
| if (fixture) { | ||
| fixture.runner.teardown() | ||
| rmSync(fixture.root, { recursive: true, force: true }) | ||
| rmSync(fixture.workspaceRoot, { recursive: true, force: true }) | ||
| fixture = null | ||
| } | ||
|
|
||
| consoleSilencer.restore() | ||
| } | ||
|
|
||
| async function runInCwd( | ||
| cwd: string, | ||
| callback: () => Promise<void>, | ||
| ): Promise<void> { | ||
| const previousCwd = process.cwd() | ||
| process.chdir(cwd) | ||
| try { | ||
| await callback() | ||
| } finally { | ||
| process.chdir(previousCwd) | ||
| } | ||
| } | ||
|
|
||
| describe('intent load', () => { | ||
| beforeAll(setup) | ||
| afterAll(teardown) | ||
|
|
||
| bench( | ||
| 'loads a direct dependency skill', | ||
| async () => { | ||
| const state = getFixture() | ||
| for (let index = 0; index < 10; index++) { | ||
| await state.runner.run(['load', '@bench/query#query/cache', '--path']) | ||
| } | ||
| }, | ||
| createBenchOptions(setup, teardown), | ||
| ) | ||
|
|
||
| bench( | ||
| 'loads direct dependency content as json', | ||
| async () => { | ||
| const state = getFixture() | ||
| for (let index = 0; index < 10; index++) { | ||
| await state.runner.run(['load', '@bench/query#query/cache', '--json']) | ||
| } | ||
| }, | ||
| createBenchOptions(setup, teardown), | ||
| ) | ||
|
|
||
| bench( | ||
| 'loads a direct dependency from a large workspace', | ||
| async () => { | ||
| const state = getFixture() | ||
| await runInCwd(state.workspaceRoot, async () => { | ||
| for (let index = 0; index < 10; index++) { | ||
| await state.runner.run(['load', '@bench/query#query/cache', '--path']) | ||
| } | ||
| }) | ||
| }, | ||
| createBenchOptions(setup, teardown), | ||
| ) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.