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
5 changes: 5 additions & 0 deletions .changeset/fruity-toys-win.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/intent': patch
---

Remove the abandoned `intent-library` bin and its `./intent-library` export. The legacy library-bin discovery model was replaced by the keyword-based model; anything invoking `intent-library` directly must move to the normal `intent` discovery flow (no compatibility shim).
9 changes: 1 addition & 8 deletions knip.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,7 @@
"entry": ["scripts/*.ts"]
},
"packages/intent": {
"entry": [
"src/index.ts",
"src/cli.ts",
"src/core.ts",
"src/setup.ts",
"src/intent-library.ts",
"src/library-scanner.ts"
],
"entry": ["src/index.ts", "src/cli.ts", "src/core.ts", "src/setup.ts"],
"ignore": ["meta/**"],
"ignoreDependencies": ["verdaccio", "@verdaccio/node-api"]
}
Expand Down
5 changes: 5 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
"inputs": ["default", "^production"],
"outputs": ["{projectRoot}/coverage"]
},
"test:integration": {
"cache": true,
"dependsOn": ["build", "^build"],
"inputs": ["default", "^production"]
},
"test:eslint": {
"cache": true,
"dependsOn": ["^build"],
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
"lint:fix": "nx affected --target=lint:fix --exclude=examples/**",
"lint:fix:all": "nx run-many --targets=lint --fix",
"test": "pnpm run test:ci",
"test:ci": "tsc --noEmit && nx run-many --targets=test:eslint,test:sherif,test:knip,test:docs,test:lib,test:types,build",
"test:ci": "tsc --noEmit && nx run-many --targets=test:eslint,test:sherif,test:knip,test:docs,test:lib,test:integration,test:types,build",
"generate-docs": "node scripts/generate-docs.ts",
"test:docs": "node scripts/verify-links.ts",
"test:eslint": "nx affected --target=test:eslint --exclude=examples/**",
"test:knip": "knip",
"test:lib": "nx affected --targets=test:lib --exclude=examples/**",
"test:lib:dev": "pnpm test:lib && nx watch --all -- pnpm test:lib",
"test:pr": "tsc --noEmit && nx affected --targets=test:eslint,test:sherif,test:knip,test:docs,test:lib,test:types,build",
"test:pr": "tsc --noEmit && nx affected --targets=test:eslint,test:sherif,test:knip,test:docs,test:lib,test:integration,test:types,build",
"test:sherif": "sherif",
"test:types": "nx affected --targets=test:types --exclude=examples/**",
"watch": "pnpm run build:all && nx watch --all -- pnpm run build:all"
Expand Down
9 changes: 2 additions & 7 deletions packages/intent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,13 @@
"import": "./dist/index.mjs",
"types": "./dist/index.d.mts"
},
"./intent-library": {
"import": "./dist/intent-library.mjs",
"types": "./dist/intent-library.d.mts"
},
"./core": {
"import": "./dist/core.mjs",
"types": "./dist/core.d.mts"
}
},
"bin": {
"intent": "dist/cli.mjs",
"intent-library": "dist/intent-library.mjs"
"intent": "dist/cli.mjs"
},
"files": [
"dist",
Expand All @@ -44,7 +39,7 @@
},
"scripts": {
"prepack": "npm run build",
"build": "tsdown src/index.ts src/cli.ts src/setup.ts src/intent-library.ts src/library-scanner.ts src/core.ts --format esm --dts",
"build": "tsdown src/index.ts src/cli.ts src/setup.ts src/core.ts --format esm --dts",
"test:smoke": "pnpm run build && node dist/cli.mjs --help > /dev/null && node dist/cli.mjs load --help > /dev/null",
"test:lib": "vitest run --exclude 'tests/integration/**'",
"test:integration": "vitest run tests/integration/",
Expand Down
22 changes: 15 additions & 7 deletions packages/intent/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,22 @@ export async function main(argv: Array<string> = process.argv.slice(2)) {
}
}

let isMain = false
try {
isMain =
process.argv[1] !== undefined &&
fileURLToPath(import.meta.url) === realpathSync(process.argv[1])
} catch {}
export function isMainModule(
metaUrl: string,
argvPath: string | undefined,
realpath: (path: string) => string = realpathSync,
): boolean {
if (argvPath === undefined) {
return false
}
try {
return fileURLToPath(metaUrl) === realpath(argvPath)
} catch {
return false
}
}

if (isMain) {
if (isMainModule(import.meta.url, process.argv[1])) {
const exitCode = await main()
process.exit(exitCode)
}
2 changes: 1 addition & 1 deletion packages/intent/src/commands/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import {
coreOptionsFromGlobalFlags,
printDebugInfo,
printWarnings,
type GlobalScanFlags,
} from '../cli-support.js'
import { formatIntentCommand } from '../command-runner.js'
import { listIntentSkills } from '../core.js'
import type { GlobalScanFlags } from '../cli-support.js'
import type {
IntentPackageSummary,
IntentSkillList,
Expand Down
6 changes: 2 additions & 4 deletions packages/intent/src/commands/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ import { appendFileSync, existsSync, readFileSync } from 'node:fs'
import { basename, dirname, join, relative, resolve, sep } from 'node:path'
import { fail, isCliFailure } from '../cli-error.js'
import { printWarnings } from '../cli-support.js'
import {
type ProjectContext,
resolveProjectContext,
} from '../core/project-context.js'
import { resolveProjectContext } from '../core/project-context.js'
import { findWorkspacePackages } from '../workspace-patterns.js'
import type { ProjectContext } from '../core/project-context.js'

interface ValidationError {
file: string
Expand Down
12 changes: 5 additions & 7 deletions packages/intent/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,23 @@ import {
isPackageExcluded,
warningMentionsPackage,
} from './core/excludes.js'
import { createIntentFsCache, type IntentFsCache } from './fs-cache.js'
import { createIntentFsCache } from './fs-cache.js'
import { rewriteLoadedSkillMarkdownDestinations } from './core/markdown.js'
import { resolveSkillUseFastPath } from './core/load-resolution.js'
import { resolveProjectContext } from './core/project-context.js'
import {
ResolveSkillUseError,
resolveSkillUse,
type ResolveSkillResult,
} from './resolver.js'
import { ResolveSkillUseError, resolveSkillUse } from './resolver.js'
import { formatSkillUse, parseSkillUse } from './skill-use.js'
import { scanForIntents } from './scanner.js'
import type { ResolveSkillResult } from './resolver.js'
import type { IntentFsCache } from './fs-cache.js'
import type { ScanOptions, ScanScope } from './types.js'
import type {
IntentCoreErrorCode,
IntentCoreOptions,
IntentSkillList,
IntentSkillSummary,
LoadedIntentSkillDebug,
LoadedIntentSkill,
LoadedIntentSkillDebug,
ResolvedIntentSkill,
} from './core/types.js'

Expand Down
17 changes: 7 additions & 10 deletions packages/intent/src/core/excludes.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { dirname, isAbsolute, relative, resolve } from 'node:path'
import {
resolveProjectContext,
type ProjectContext,
} from './project-context.js'
import { resolveProjectContext } from './project-context.js'
import { readPackageJson } from './package-json.js'
import type { ProjectContext } from './project-context.js'
import type { IntentCoreOptions } from './types.js'

const MAX_EXCLUDE_PATTERN_LENGTH = 200
Expand Down Expand Up @@ -117,12 +115,9 @@ export function warningMentionsPackage(
warning: string,
packageName: string,
): boolean {
let fromIndex = 0

while (true) {
const idx = warning.indexOf(packageName, fromIndex)
if (idx === -1) return false
let idx = warning.indexOf(packageName)

while (idx !== -1) {
const before = warning[idx - 1]
const after = warning[idx + packageName.length]
if (
Expand All @@ -132,6 +127,8 @@ export function warningMentionsPackage(
return true
}

fromIndex = idx + packageName.length
idx = warning.indexOf(packageName, idx + packageName.length)
}

return false
}
24 changes: 13 additions & 11 deletions packages/intent/src/core/load-resolution.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { existsSync } from 'node:fs'
import { dirname, join, resolve } from 'node:path'
import { createIntentFsCache, type IntentFsCache } from '../fs-cache.js'
import { resolveSkillEntry, type ResolveSkillResult } from '../resolver.js'
import { createIntentFsCache } from '../fs-cache.js'
import { resolveSkillEntry } from '../resolver.js'
import { scanIntentPackageAtRoot } from '../scanner.js'
import { findWorkspacePackages } from '../workspace-patterns.js'
import { getDeps, resolveDepDir } from '../utils.js'
import { warningMentionsPackage } from './excludes.js'
import {
resolveProjectContext,
type ProjectContext,
} from './project-context.js'
import { resolveProjectContext } from './project-context.js'
import type { ResolveSkillResult } from '../resolver.js'
import type { IntentFsCache } from '../fs-cache.js'
import type { ProjectContext } from './project-context.js'
import type { SkillUse } from '../skill-use.js'
import type { IntentCoreOptions } from './types.js'

Expand Down Expand Up @@ -70,15 +70,17 @@ function findVisibleDependencyDir(
fromDir: string,
): string | null {
let dir = fromDir
let prev: string | undefined

while (true) {
while (dir !== prev) {
const candidate = join(dir, 'node_modules', packageName)
if (existsSync(join(candidate, 'package.json'))) return candidate

const next = dirname(dir)
if (next === dir) return null
dir = next
prev = dir
dir = dirname(dir)
}

return null
}

function resolveDependencyPackageDir(
Expand Down Expand Up @@ -134,7 +136,7 @@ function getDirectLoadFastPathCandidateDirs(
seen,
resolveDependencyPackageDir(
packageName,
context.packageRoot ?? context.workspaceRoot ?? cwd,
context.packageRoot ?? context.workspaceRoot,
),
)

Expand Down
13 changes: 6 additions & 7 deletions packages/intent/src/core/project-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,18 @@ export function resolveProjectContext({

function findOwningPackageRoot(startPath: string): string | null {
let dir = toSearchDir(startPath)
let prev: string | undefined

while (true) {
while (dir !== prev) {
if (existsSync(join(dir, 'package.json'))) {
return dir
}

const next = dirname(dir)
if (next === dir) {
return null
}

dir = next
prev = dir
dir = dirname(dir)
}

return null
}

function toSearchDir(path: string): string {
Expand Down
101 changes: 0 additions & 101 deletions packages/intent/src/intent-library.ts

This file was deleted.

Loading
Loading