Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/intent/src/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export async function scanForIntents(root?: string): Promise<ScanResult> {
}

for (const entry of topEntries) {
if (!entry.isDirectory()) continue
if (!entry.isDirectory() && !entry.isSymbolicLink()) continue
const dirPath = join(nodeModulesDir, entry.name)

if (entry.name.startsWith('@')) {
Expand All @@ -228,7 +228,7 @@ export async function scanForIntents(root?: string): Promise<ScanResult> {
continue
}
for (const scoped of scopedEntries) {
if (!scoped.isDirectory()) continue
if (!scoped.isDirectory() && !scoped.isSymbolicLink()) continue
packageDirs.push({ dirPath: join(dirPath, scoped.name) })
}
} else if (!entry.name.startsWith('.')) {
Expand Down
51 changes: 50 additions & 1 deletion packages/intent/tests/scanner.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
import {
mkdirSync,
mkdtempSync,
rmSync,
symlinkSync,
writeFileSync,
} from 'node:fs'
import { join } from 'node:path'
import { tmpdir } from 'node:os'
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
Expand Down Expand Up @@ -86,6 +92,49 @@ describe('scanForIntents', () => {
)
})

it('discovers packages through symlinks (pnpm layout)', async () => {
// pnpm stores packages outside node_modules and symlinks them in
const store = createDir(root, '.pnpm-store', '@tanstack', 'db')
writeJson(join(store, 'package.json'), {
name: '@tanstack/db',
version: '0.5.2',
intent: { version: 1, repo: 'TanStack/db', docs: 'docs/' },
})
const skillDir = createDir(store, 'skills', 'db-core')
writeSkillMd(skillDir, {
name: 'db-core',
description: 'Core database concepts',
type: 'core',
})

// Create the scoped dir, then symlink the package (like pnpm does)
createDir(root, 'node_modules', '@tanstack')
symlinkSync(store, join(root, 'node_modules', '@tanstack', 'db'))

const result = await scanForIntents(root)
expect(result.packages).toHaveLength(1)
expect(result.packages[0]!.name).toBe('@tanstack/db')
expect(result.packages[0]!.skills).toHaveLength(1)
})

it('discovers unscoped packages through symlinks (pnpm layout)', async () => {
const store = createDir(root, '.pnpm-store', 'my-lib')
writeJson(join(store, 'package.json'), {
name: 'my-lib',
version: '1.0.0',
intent: { version: 1, repo: 'foo/my-lib', docs: 'docs/' },
})
const skillDir = createDir(store, 'skills', 'my-skill')
writeSkillMd(skillDir, { name: 'my-skill', description: 'A skill' })

createDir(root, 'node_modules')
symlinkSync(store, join(root, 'node_modules', 'my-lib'))

const result = await scanForIntents(root)
expect(result.packages).toHaveLength(1)
expect(result.packages[0]!.name).toBe('my-lib')
})

it('discovers sub-skills', async () => {
const pkgDir = createDir(root, 'node_modules', '@tanstack', 'db')
writeJson(join(pkgDir, 'package.json'), {
Expand Down
Loading