diff --git a/cli/package.json b/cli/package.json index 59286c2880..90f1f31eb1 100644 --- a/cli/package.json +++ b/cli/package.json @@ -32,7 +32,7 @@ "test:coverage": "vp test --coverage", "lint": "eslint", "lint:fix": "eslint --fix", - "type-check": "tsc", + "type-check": "tsgo", "tree:gen": "bun scripts/generate-command-tree.ts", "tree:check": "bun scripts/generate-command-tree.ts --check", "prebuild": "pnpm tree:gen", @@ -63,6 +63,7 @@ "@types/js-yaml": "catalog:", "@types/lockfile": "catalog:", "@types/node": "catalog:", + "@typescript/native-preview": "catalog:", "@vitest/coverage-v8": "catalog:", "eslint": "catalog:", "hono": "catalog:", diff --git a/cli/scripts/generate-command-tree.test.ts b/cli/scripts/generate-command-tree.test.ts index 2f3c4ce2f4..cf25ddcf71 100644 --- a/cli/scripts/generate-command-tree.test.ts +++ b/cli/scripts/generate-command-tree.test.ts @@ -49,9 +49,9 @@ describe('tokensToIdentifier', () => { describe('buildTree', () => { it('assembles a nested tree from entries', () => { const entries = [ - { tokens: ['auth', 'login'], identifier: 'AuthLogin', importPath: './auth/login/index.js' }, - { tokens: ['auth', 'devices', 'list'], identifier: 'AuthDevicesList', importPath: './auth/devices/list/index.js' }, - { tokens: ['version'], identifier: 'Version', importPath: './version/index.js' }, + { tokens: ['auth', 'login'], identifier: 'AuthLogin', importPath: '@/commands/auth/login/index' }, + { tokens: ['auth', 'devices', 'list'], identifier: 'AuthDevicesList', importPath: '@/commands/auth/devices/list/index' }, + { tokens: ['version'], identifier: 'Version', importPath: '@/commands/version/index' }, ] const tree = buildTree(entries) expect(tree.subcommands.get('auth')?.command).toBeUndefined() @@ -63,8 +63,8 @@ describe('buildTree', () => { it('supports a parent command with its own children', () => { const entries = [ - { tokens: ['run', 'app'], identifier: 'RunApp', importPath: './run/app/index.js' }, - { tokens: ['run', 'app', 'resume'], identifier: 'RunAppResume', importPath: './run/app/resume/index.js' }, + { tokens: ['run', 'app'], identifier: 'RunApp', importPath: '@/commands/run/app/index' }, + { tokens: ['run', 'app', 'resume'], identifier: 'RunAppResume', importPath: '@/commands/run/app/resume/index' }, ] const tree = buildTree(entries) const runApp = tree.subcommands.get('run')?.subcommands.get('app') @@ -76,9 +76,9 @@ describe('buildTree', () => { describe('formatModule', () => { it('produces a deterministic ESM file with imports + tree literal', () => { const entries: CommandEntry[] = [ - { tokens: ['auth', 'login'], identifier: 'AuthLogin', importPath: './auth/login/index.js' }, - { tokens: ['version'], identifier: 'Version', importPath: './version/index.js' }, - { tokens: ['auth', 'devices', 'list'], identifier: 'AuthDevicesList', importPath: './auth/devices/list/index.js' }, + { tokens: ['auth', 'login'], identifier: 'AuthLogin', importPath: '@/commands/auth/login/index' }, + { tokens: ['version'], identifier: 'Version', importPath: '@/commands/version/index' }, + { tokens: ['auth', 'devices', 'list'], identifier: 'AuthDevicesList', importPath: '@/commands/auth/devices/list/index' }, ] const tree = buildTree(entries) const out = formatModule(entries, tree) @@ -86,10 +86,10 @@ describe('formatModule', () => { `// @generated by scripts/generate-command-tree.ts — DO NOT EDIT. // Regenerate via \`pnpm tree:gen\`. Drift gated by \`pnpm tree:check\` in CI. -import type { CommandTree } from '../framework/registry.js' -import AuthDevicesList from './auth/devices/list/index.js' -import AuthLogin from './auth/login/index.js' -import Version from './version/index.js' +import type { CommandTree } from '@/framework/registry' +import AuthDevicesList from '@/commands/auth/devices/list/index' +import AuthLogin from '@/commands/auth/login/index' +import Version from '@/commands/version/index' export const commandTree: CommandTree = { auth: { @@ -110,8 +110,8 @@ export const commandTree: CommandTree = { it('emits parent-with-own-command shape', () => { const entries: CommandEntry[] = [ - { tokens: ['run', 'app'], identifier: 'RunApp', importPath: './run/app/index.js' }, - { tokens: ['run', 'app', 'resume'], identifier: 'RunAppResume', importPath: './run/app/resume/index.js' }, + { tokens: ['run', 'app'], identifier: 'RunApp', importPath: '@/commands/run/app/index' }, + { tokens: ['run', 'app', 'resume'], identifier: 'RunAppResume', importPath: '@/commands/run/app/resume/index' }, ] const tree = buildTree(entries) const out = formatModule(entries, tree) @@ -129,8 +129,8 @@ export const commandTree: CommandTree = { it('imports sorted alphabetically by import path', () => { const entries: CommandEntry[] = [ - { tokens: ['version'], identifier: 'Version', importPath: './version/index.js' }, - { tokens: ['auth', 'login'], identifier: 'AuthLogin', importPath: './auth/login/index.js' }, + { tokens: ['version'], identifier: 'Version', importPath: '@/commands/version/index' }, + { tokens: ['auth', 'login'], identifier: 'AuthLogin', importPath: '@/commands/auth/login/index' }, ] const out = formatModule(entries, buildTree(entries)) const authIdx = out.indexOf('AuthLogin') diff --git a/cli/scripts/generate-command-tree.ts b/cli/scripts/generate-command-tree.ts index f6ea768027..769490df83 100644 --- a/cli/scripts/generate-command-tree.ts +++ b/cli/scripts/generate-command-tree.ts @@ -112,7 +112,7 @@ function compareStrings(a: string, b: string): number { function emitImports(entries: readonly CommandEntry[]): string { const sorted = [...entries].sort((a, b) => compareStrings(a.importPath, b.importPath)) - const lines = [`import type { CommandTree } from '../framework/registry.js'`] + const lines = [`import type { CommandTree } from '@/framework/registry'`] for (const e of sorted) lines.push(`import ${e.identifier} from '${e.importPath}'`) return lines.join('\n') @@ -219,7 +219,7 @@ export async function discoverCommands(commandsDir: string): Promise { let mock: DifyMock diff --git a/cli/src/api/app-meta.ts b/cli/src/api/app-meta.ts index 8d70385043..854c9b0eac 100644 --- a/cli/src/api/app-meta.ts +++ b/cli/src/api/app-meta.ts @@ -1,7 +1,7 @@ -import type { AppInfoCache } from '../cache/app-info.js' -import type { AppMeta, AppMetaFieldKey } from '../types/app-meta.js' -import type { AppsClient } from './apps.js' -import { covers, fromDescribe, mergeMeta } from '../types/app-meta.js' +import type { AppsClient } from './apps' +import type { AppInfoCache } from '@/cache/app-info' +import type { AppMeta, AppMetaFieldKey } from '@/types/app-meta' +import { covers, fromDescribe, mergeMeta } from '@/types/app-meta' export type AppMetaClientOptions = { readonly apps: AppsClient diff --git a/cli/src/api/app-run.test.ts b/cli/src/api/app-run.test.ts index 07d6a095a7..8100ebc256 100644 --- a/cli/src/api/app-run.test.ts +++ b/cli/src/api/app-run.test.ts @@ -1,8 +1,8 @@ -import type { DifyMock } from '../../test/fixtures/dify-mock/server.js' +import type { DifyMock } from '@test/fixtures/dify-mock/server' +import { startMock } from '@test/fixtures/dify-mock/server' import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { startMock } from '../../test/fixtures/dify-mock/server.js' -import { createClient } from '../http/client.js' -import { AppRunClient, buildRunBody } from './app-run.js' +import { createClient } from '@/http/client' +import { AppRunClient, buildRunBody } from './app-run' describe('buildRunBody', () => { it('does not include response_mode', () => { diff --git a/cli/src/api/app-run.ts b/cli/src/api/app-run.ts index 12b00e411e..cf75ade9f8 100644 --- a/cli/src/api/app-run.ts +++ b/cli/src/api/app-run.ts @@ -1,7 +1,7 @@ import type { KyInstance } from 'ky' -import type { SseEvent } from '../http/sse.js' -import { normalizeDifyStream } from '../http/sse-dify.js' -import { parseSSE } from '../http/sse.js' +import type { SseEvent } from '@/http/sse' +import { parseSSE } from '@/http/sse' +import { normalizeDifyStream } from '@/http/sse-dify' export type RunBodyArgs = { readonly message?: string diff --git a/cli/src/api/device-flow.test.ts b/cli/src/api/device-flow.test.ts index e850add937..3b380cfdc0 100644 --- a/cli/src/api/device-flow.test.ts +++ b/cli/src/api/device-flow.test.ts @@ -1,14 +1,14 @@ +import type { DifyMock } from '@test/fixtures/dify-mock/server' import type { AddressInfo } from 'node:net' -import type { DifyMock } from '../../test/fixtures/dify-mock/server.js' -import type { CodeResponse } from './oauth-device.js' +import type { CodeResponse } from './oauth-device' import { Buffer } from 'node:buffer' import * as http from 'node:http' +import { startMock } from '@test/fixtures/dify-mock/server' import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { startMock } from '../../test/fixtures/dify-mock/server.js' -import { isBaseError } from '../errors/base.js' -import { ErrorCode } from '../errors/codes.js' -import { createClient } from '../http/client.js' -import { DEFAULT_CLIENT_ID, DeviceFlowApi } from './oauth-device.js' +import { isBaseError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' +import { createClient } from '@/http/client' +import { DEFAULT_CLIENT_ID, DeviceFlowApi } from './oauth-device' type StubServer = { url: string diff --git a/cli/src/api/members.test.ts b/cli/src/api/members.test.ts index 5442e296c3..4dafa1ce3c 100644 --- a/cli/src/api/members.test.ts +++ b/cli/src/api/members.test.ts @@ -2,9 +2,9 @@ import type { AddressInfo } from 'node:net' import { Buffer } from 'node:buffer' import * as http from 'node:http' import { afterEach, describe, expect, it } from 'vitest' -import { isBaseError } from '../errors/base.js' -import { createClient } from '../http/client.js' -import { MembersClient } from './members.js' +import { isBaseError } from '@/errors/base' +import { createClient } from '@/http/client' +import { MembersClient } from './members' type StubServer = { url: string @@ -84,7 +84,7 @@ describe('MembersClient.list', () => { const result = await makeClient(stub.url).list('ws-1') expect(captured.method).toBe('GET') expect(captured.url).toBe('/openapi/v1/workspaces/ws-1/members') - expect(result.data[0].email).toBe('mia@e.com') + expect(result.data[0]?.email).toBe('mia@e.com') }) it('URL-encodes workspace id', async () => { @@ -259,7 +259,7 @@ describe('WorkspacesClient.switch (integration with stub)', () => { ) stub.lastRequest = captured - const { WorkspacesClient } = await import('./workspaces.js') + const { WorkspacesClient } = await import('./workspaces') const client = new WorkspacesClient(createClient({ host: stub.url, bearer: 'dfoa_test' })) const result = await client.switch('ws-1') expect(captured.method).toBe('POST') @@ -271,7 +271,7 @@ describe('WorkspacesClient.switch (integration with stub)', () => { const captured: StubServer['lastRequest'] = {} stub = await startServer(jsonResponder(404, { error: 'not found' }, captured)) - const { WorkspacesClient } = await import('./workspaces.js') + const { WorkspacesClient } = await import('./workspaces') const client = new WorkspacesClient(createClient({ host: stub.url, bearer: 'dfoa_test' })) await expect(client.switch('ws-x')).rejects.toSatisfy( err => isBaseError(err) && err.httpStatus === 404, diff --git a/cli/src/api/meta.test.ts b/cli/src/api/meta.test.ts index e41189054e..1b7fee0a79 100644 --- a/cli/src/api/meta.test.ts +++ b/cli/src/api/meta.test.ts @@ -1,8 +1,8 @@ -import type { DifyMock } from '../../test/fixtures/dify-mock/server.js' +import type { DifyMock } from '@test/fixtures/dify-mock/server' +import { startMock } from '@test/fixtures/dify-mock/server' import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { startMock } from '../../test/fixtures/dify-mock/server.js' -import { createClient } from '../http/client.js' -import { MetaClient } from './meta.js' +import { createClient } from '@/http/client' +import { MetaClient } from './meta' describe('MetaClient', () => { let mock: DifyMock diff --git a/cli/src/api/oauth-device.ts b/cli/src/api/oauth-device.ts index 582b5f06b2..dea88c82b6 100644 --- a/cli/src/api/oauth-device.ts +++ b/cli/src/api/oauth-device.ts @@ -1,6 +1,6 @@ import type { KyInstance } from 'ky' -import { BaseError } from '../errors/base.js' -import { ErrorCode } from '../errors/codes.js' +import { BaseError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' export const DEFAULT_CLIENT_ID = 'difyctl' diff --git a/cli/src/auth/hosts.test.ts b/cli/src/auth/hosts.test.ts index 5c5b254c0a..9630b309b6 100644 --- a/cli/src/auth/hosts.test.ts +++ b/cli/src/auth/hosts.test.ts @@ -2,8 +2,8 @@ import { mkdtemp, rm } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { ENV_CONFIG_DIR } from '../store/dir.js' -import { HostsBundleSchema, loadHosts, saveHosts } from './hosts.js' +import { ENV_CONFIG_DIR } from '@/store/dir' +import { HostsBundleSchema, loadHosts, saveHosts } from './hosts' describe('HostsBundleSchema', () => { it('parses a minimal logged-out bundle', () => { diff --git a/cli/src/auth/hosts.ts b/cli/src/auth/hosts.ts index a7016d6714..f61cc513f3 100644 --- a/cli/src/auth/hosts.ts +++ b/cli/src/auth/hosts.ts @@ -1,6 +1,6 @@ -import type { Store } from '../store/store.js' +import type { Store } from '@/store/store' import { z } from 'zod' -import { getHostStore, tokenKey } from '../store/manager.js' +import { getHostStore, tokenKey } from '@/store/manager' const StorageModeSchema = z.enum(['keychain', 'file']) export type StorageMode = z.infer diff --git a/cli/src/cache/app-info.test.ts b/cli/src/cache/app-info.test.ts index 8604382c5b..50ac1c67d3 100644 --- a/cli/src/cache/app-info.test.ts +++ b/cli/src/cache/app-info.test.ts @@ -1,14 +1,14 @@ -import type { AppMeta } from '../types/app-meta.js' +import type { AppMeta } from '@/types/app-meta' import { mkdtemp, readFile, rm } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' import yaml from 'js-yaml' import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { ENV_CACHE_DIR } from '../store/dir.js' -import { CACHE_APP_INFO, cachePath, getCache } from '../store/manager.js' -import { platform } from '../sys/index.js' -import { FieldInfo, FieldParameters } from '../types/app-meta.js' -import { APP_INFO_TTL_MS, loadAppInfoCache } from './app-info.js' +import { ENV_CACHE_DIR } from '@/store/dir' +import { CACHE_APP_INFO, cachePath, getCache } from '@/store/manager' +import { platform } from '@/sys/index' +import { FieldInfo, FieldParameters } from '@/types/app-meta' +import { APP_INFO_TTL_MS, loadAppInfoCache } from './app-info' function appInfoPath(dir: string): string { return cachePath(dir, CACHE_APP_INFO) diff --git a/cli/src/cache/app-info.ts b/cli/src/cache/app-info.ts index 5d8ea27642..f6f360405a 100644 --- a/cli/src/cache/app-info.ts +++ b/cli/src/cache/app-info.ts @@ -1,7 +1,7 @@ -import type { Store } from '../store/store.js' -import type { AppMeta, AppMetaCacheRecord, AppMetaFieldKey } from '../types/app-meta.js' -import { CACHE_APP_INFO, getCache } from '../store/manager.js' -import { FieldInfo, FieldInputSchema, FieldParameters } from '../types/app-meta.js' +import type { Store } from '@/store/store' +import type { AppMeta, AppMetaCacheRecord, AppMetaFieldKey } from '@/types/app-meta' +import { CACHE_APP_INFO, getCache } from '@/store/manager' +import { FieldInfo, FieldInputSchema, FieldParameters } from '@/types/app-meta' export const APP_INFO_TTL_MS = 60 * 60 * 1000 diff --git a/cli/src/cache/nudge-store.test.ts b/cli/src/cache/nudge-store.test.ts index d899260f88..737235dabb 100644 --- a/cli/src/cache/nudge-store.test.ts +++ b/cli/src/cache/nudge-store.test.ts @@ -3,9 +3,9 @@ import { tmpdir } from 'node:os' import { dirname, join } from 'node:path' import yaml from 'js-yaml' import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { ENV_CACHE_DIR } from '../store/dir.js' -import { CACHE_NUDGE, cachePath, getCache } from '../store/manager.js' -import { loadNudgeStore, WARN_INTERVAL_MS } from './nudge-store.js' +import { ENV_CACHE_DIR } from '@/store/dir' +import { CACHE_NUDGE, cachePath, getCache } from '@/store/manager' +import { loadNudgeStore, WARN_INTERVAL_MS } from './nudge-store' function nudgeStorePath(dir: string): string { return cachePath(dir, CACHE_NUDGE) diff --git a/cli/src/cache/nudge-store.ts b/cli/src/cache/nudge-store.ts index e16c4a435f..61846b89dd 100644 --- a/cli/src/cache/nudge-store.ts +++ b/cli/src/cache/nudge-store.ts @@ -1,5 +1,5 @@ -import type { Store } from '../store/store.js' -import { CACHE_NUDGE, getCache } from '../store/manager.js' +import type { Store } from '@/store/store' +import { CACHE_NUDGE, getCache } from '@/store/manager' export const WARN_INTERVAL_MS = 24 * 60 * 60 * 1000 diff --git a/cli/src/commands/_shared/authed-command.ts b/cli/src/commands/_shared/authed-command.ts index 44aea53c2b..29710eacf5 100644 --- a/cli/src/commands/_shared/authed-command.ts +++ b/cli/src/commands/_shared/authed-command.ts @@ -1,22 +1,22 @@ import type { KyInstance } from 'ky' -import type { HostsBundle } from '../../auth/hosts.js' -import type { AppInfoCache } from '../../cache/app-info.js' -import type { Command } from '../../framework/command.js' -import type { IOStreams } from '../../sys/io/streams' -import { META_PROBE_TIMEOUT_MS, MetaClient } from '../../api/meta.js' -import { loadHosts } from '../../auth/hosts.js' -import { loadAppInfoCache } from '../../cache/app-info.js' -import { loadNudgeStore } from '../../cache/nudge-store.js' -import { getEnv } from '../../env/registry.js' -import { BaseError } from '../../errors/base.js' -import { ErrorCode } from '../../errors/codes.js' -import { formatErrorForCli } from '../../errors/format.js' -import { createClient } from '../../http/client.js' -import { realStreams } from '../../sys/io/streams' -import { hostWithScheme } from '../../util/host.js' -import { versionInfo } from '../../version/info.js' -import { maybeNudgeCompat } from '../../version/nudge.js' -import { resolveRetryAttempts } from './global-flags.js' +import type { HostsBundle } from '@/auth/hosts' +import type { AppInfoCache } from '@/cache/app-info' +import type { Command } from '@/framework/command' +import type { IOStreams } from '@/sys/io/streams' +import { META_PROBE_TIMEOUT_MS, MetaClient } from '@/api/meta' +import { loadHosts } from '@/auth/hosts' +import { loadAppInfoCache } from '@/cache/app-info' +import { loadNudgeStore } from '@/cache/nudge-store' +import { getEnv } from '@/env/registry' +import { BaseError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' +import { formatErrorForCli } from '@/errors/format' +import { createClient } from '@/http/client' +import { realStreams } from '@/sys/io/streams' +import { hostWithScheme } from '@/util/host' +import { versionInfo } from '@/version/info' +import { maybeNudgeCompat } from '@/version/nudge' +import { resolveRetryAttempts } from './global-flags' export type AuthedContext = { readonly bundle: HostsBundle diff --git a/cli/src/commands/_shared/dify-command.ts b/cli/src/commands/_shared/dify-command.ts index 80a25e377f..cfde145f80 100644 --- a/cli/src/commands/_shared/dify-command.ts +++ b/cli/src/commands/_shared/dify-command.ts @@ -1,6 +1,6 @@ -import type { AuthedContext, AuthedContextOptions } from './authed-command.js' -import { Command } from '../../framework/command.js' -import { buildAuthedContext } from './authed-command.js' +import type { AuthedContext, AuthedContextOptions } from './authed-command' +import { Command } from '@/framework/command' +import { buildAuthedContext } from './authed-command' export abstract class DifyCommand extends Command { protected async authedCtx(opts: AuthedContextOptions): Promise { diff --git a/cli/src/commands/_shared/global-flags.test.ts b/cli/src/commands/_shared/global-flags.test.ts index 2fe678726b..914f2d2dff 100644 --- a/cli/src/commands/_shared/global-flags.test.ts +++ b/cli/src/commands/_shared/global-flags.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { resolveRetryAttempts } from './global-flags.js' +import { resolveRetryAttempts } from './global-flags' describe('resolveRetryAttempts', () => { it('returns flag value when given', () => { diff --git a/cli/src/commands/_shared/global-flags.ts b/cli/src/commands/_shared/global-flags.ts index 20777c99f9..e2b1d5b486 100644 --- a/cli/src/commands/_shared/global-flags.ts +++ b/cli/src/commands/_shared/global-flags.ts @@ -1,6 +1,6 @@ -import { newError } from '../../errors/base.js' -import { ErrorCode } from '../../errors/codes.js' -import { Flags } from '../../framework/flags.js' +import { newError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' +import { Flags } from '@/framework/flags' export const HTTP_RETRY_DEFAULT = 3 diff --git a/cli/src/commands/auth/devices/_shared/devices.test.ts b/cli/src/commands/auth/devices/_shared/devices.test.ts index 6c66ef53c8..4675a79e22 100644 --- a/cli/src/commands/auth/devices/_shared/devices.test.ts +++ b/cli/src/commands/auth/devices/_shared/devices.test.ts @@ -1,19 +1,19 @@ import type { SessionListResponse, SessionRow } from '@dify/contracts/api/openapi/types.gen' -import type { DifyMock } from '../../../../../test/fixtures/dify-mock/server.js' -import type { AccountSessionsClient } from '../../../../api/account-sessions.js' -import type { HostsBundle } from '../../../../auth/hosts.js' -import type { Key, Store } from '../../../../store/store.js' +import type { DifyMock } from '@test/fixtures/dify-mock/server' +import type { AccountSessionsClient } from '@/api/account-sessions' +import type { HostsBundle } from '@/auth/hosts' +import type { Key, Store } from '@/store/store' import { mkdtemp, readFile, rm } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' +import { startMock } from '@test/fixtures/dify-mock/server' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import { startMock } from '../../../../../test/fixtures/dify-mock/server.js' -import { saveHosts } from '../../../../auth/hosts.js' -import { createClient } from '../../../../http/client.js' -import { ENV_CONFIG_DIR, resolveConfigDir } from '../../../../store/dir.js' -import { tokenKey } from '../../../../store/manager.js' -import { bufferStreams } from '../../../../sys/io/streams' -import { listAllSessions, runDevicesList, runDevicesRevoke } from './devices.js' +import { saveHosts } from '@/auth/hosts' +import { createClient } from '@/http/client' +import { ENV_CONFIG_DIR, resolveConfigDir } from '@/store/dir' +import { tokenKey } from '@/store/manager' +import { bufferStreams } from '@/sys/io/streams' +import { listAllSessions, runDevicesList, runDevicesRevoke } from './devices' class MemStore implements Store { readonly entries = new Map() diff --git a/cli/src/commands/auth/devices/_shared/devices.ts b/cli/src/commands/auth/devices/_shared/devices.ts index 6734a2a9e6..9daa44da99 100644 --- a/cli/src/commands/auth/devices/_shared/devices.ts +++ b/cli/src/commands/auth/devices/_shared/devices.ts @@ -1,16 +1,16 @@ import type { SessionRow } from '@dify/contracts/api/openapi/types.gen' import type { KyInstance } from 'ky' -import type { HostsBundle } from '../../../../auth/hosts.js' -import type { Store } from '../../../../store/store.js' -import type { IOStreams } from '../../../../sys/io/streams' -import { AccountSessionsClient } from '../../../../api/account-sessions.js' -import { clearLocal } from '../../../../auth/hosts.js' -import { BaseError } from '../../../../errors/base.js' -import { ErrorCode } from '../../../../errors/codes.js' -import { LIMIT_DEFAULT, LIMIT_MAX, parseLimit } from '../../../../limit/limit.js' -import { getTokenStore } from '../../../../store/manager.js' -import { colorEnabled, colorScheme } from '../../../../sys/io/color.js' -import { runWithSpinner } from '../../../../sys/io/spinner.js' +import type { HostsBundle } from '@/auth/hosts' +import type { Store } from '@/store/store' +import type { IOStreams } from '@/sys/io/streams' +import { AccountSessionsClient } from '@/api/account-sessions' +import { clearLocal } from '@/auth/hosts' +import { BaseError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' +import { LIMIT_DEFAULT, LIMIT_MAX, parseLimit } from '@/limit/limit' +import { getTokenStore } from '@/store/manager' +import { colorEnabled, colorScheme } from '@/sys/io/color' +import { runWithSpinner } from '@/sys/io/spinner' export type DevicesListOptions = { readonly io: IOStreams diff --git a/cli/src/commands/auth/devices/list/index.ts b/cli/src/commands/auth/devices/list/index.ts index ae64220eef..81e1c7e4ab 100644 --- a/cli/src/commands/auth/devices/list/index.ts +++ b/cli/src/commands/auth/devices/list/index.ts @@ -1,7 +1,7 @@ -import { Flags } from '../../../../framework/flags.js' -import { DifyCommand } from '../../../_shared/dify-command.js' -import { httpRetryFlag } from '../../../_shared/global-flags.js' -import { runDevicesList } from '../_shared/devices.js' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { httpRetryFlag } from '@/commands/_shared/global-flags' +import { runDevicesList } from '@/commands/auth/devices/_shared/devices' +import { Flags } from '@/framework/flags' export default class DevicesList extends DifyCommand { static override description = 'List active sessions for the current bearer' diff --git a/cli/src/commands/auth/devices/revoke/index.ts b/cli/src/commands/auth/devices/revoke/index.ts index 709bb2ed69..5aa98c201e 100644 --- a/cli/src/commands/auth/devices/revoke/index.ts +++ b/cli/src/commands/auth/devices/revoke/index.ts @@ -1,7 +1,7 @@ -import { Args, Flags } from '../../../../framework/flags.js' -import { DifyCommand } from '../../../_shared/dify-command.js' -import { httpRetryFlag } from '../../../_shared/global-flags.js' -import { runDevicesRevoke } from '../_shared/devices.js' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { httpRetryFlag } from '@/commands/_shared/global-flags' +import { runDevicesRevoke } from '@/commands/auth/devices/_shared/devices' +import { Args, Flags } from '@/framework/flags' export default class DevicesRevoke extends DifyCommand { static override description = 'Revoke one or all session devices' diff --git a/cli/src/commands/auth/login/device-flow.test.ts b/cli/src/commands/auth/login/device-flow.test.ts index 4a27788329..948779ab05 100644 --- a/cli/src/commands/auth/login/device-flow.test.ts +++ b/cli/src/commands/auth/login/device-flow.test.ts @@ -1,8 +1,8 @@ -import type { CodeResponse, PollRequest, PollResult, PollSuccess } from '../../../api/oauth-device.js' -import type { Clock } from './device-flow.js' +import type { Clock } from './device-flow' +import type { CodeResponse, PollRequest, PollResult, PollSuccess } from '@/api/oauth-device' import { describe, expect, it, vi } from 'vitest' -import { BaseError } from '../../../errors/base.js' -import { ErrorCode } from '../../../errors/codes.js' +import { BaseError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' import { awaitAuthorization, DEFAULT_INTERVAL_MS, @@ -10,7 +10,7 @@ import { POLL_RETRY_ATTEMPTS, POLL_RETRY_CAP_MS, POLL_RETRY_INITIAL_MS, -} from './device-flow.js' +} from './device-flow' const successPayload: PollSuccess = { token: 'dfoa_xyz', diff --git a/cli/src/commands/auth/login/device-flow.ts b/cli/src/commands/auth/login/device-flow.ts index bf319dccec..a6b10c871f 100644 --- a/cli/src/commands/auth/login/device-flow.ts +++ b/cli/src/commands/auth/login/device-flow.ts @@ -1,7 +1,7 @@ -import type { CodeResponse, PollRequest, PollResult, PollSuccess } from '../../../api/oauth-device.js' -import { DEFAULT_CLIENT_ID } from '../../../api/oauth-device.js' -import { BaseError } from '../../../errors/base.js' -import { ErrorCode } from '../../../errors/codes.js' +import type { CodeResponse, PollRequest, PollResult, PollSuccess } from '@/api/oauth-device' +import { DEFAULT_CLIENT_ID } from '@/api/oauth-device' +import { BaseError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' export const DEFAULT_INTERVAL_MS = 5_000 export const MAX_INTERVAL_MS = 60_000 diff --git a/cli/src/commands/auth/login/index.ts b/cli/src/commands/auth/login/index.ts index 0e7cd3f88e..e6f25b0a6f 100644 --- a/cli/src/commands/auth/login/index.ts +++ b/cli/src/commands/auth/login/index.ts @@ -1,7 +1,7 @@ -import { Flags } from '../../../framework/flags.js' -import { realStreams } from '../../../sys/io/streams' -import { DifyCommand } from '../../_shared/dify-command.js' -import { runLogin } from './login.js' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { Flags } from '@/framework/flags' +import { realStreams } from '@/sys/io/streams' +import { runLogin } from './login' export default class Login extends DifyCommand { static override description = 'Sign in to Dify via OAuth device flow' diff --git a/cli/src/commands/auth/login/login.test.ts b/cli/src/commands/auth/login/login.test.ts index 8436473634..5c9bb8c3c9 100644 --- a/cli/src/commands/auth/login/login.test.ts +++ b/cli/src/commands/auth/login/login.test.ts @@ -1,17 +1,17 @@ -import type { DifyMock } from '../../../../test/fixtures/dify-mock/server.js' -import type { Key, Store } from '../../../store/store.js' -import type { Clock } from './device-flow.js' +import type { DifyMock } from '@test/fixtures/dify-mock/server' +import type { Clock } from './device-flow' +import type { Key, Store } from '@/store/store' import { mkdtemp, readFile, rm } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' +import { startMock } from '@test/fixtures/dify-mock/server' import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { startMock } from '../../../../test/fixtures/dify-mock/server.js' -import { DeviceFlowApi } from '../../../api/oauth-device.js' -import { createClient } from '../../../http/client.js' -import { ENV_CONFIG_DIR } from '../../../store/dir.js' -import { tokenKey } from '../../../store/manager.js' -import { bufferStreams } from '../../../sys/io/streams' -import { runLogin } from './login.js' +import { DeviceFlowApi } from '@/api/oauth-device' +import { createClient } from '@/http/client' +import { ENV_CONFIG_DIR } from '@/store/dir' +import { tokenKey } from '@/store/manager' +import { bufferStreams } from '@/sys/io/streams' +import { runLogin } from './login' const noopClock: Clock = { sleepMs: async () => { /* immediate */ }, @@ -106,7 +106,7 @@ describe('runLogin', () => { expect(bundle.account).toBeUndefined() expect(bundle.external_subject?.email).toBe('sso@dify.ai') expect(bundle.external_subject?.issuer).toBe('https://issuer.example') - const stored = await store.get(bundle.current_host, 'sso@dify.ai') + const stored = await store.get(tokenKey(bundle.current_host, 'sso@dify.ai')) expect(stored).toBe('dfoe_test') expect(io.outBuf()).toContain('external SSO') expect(io.outBuf()).toContain('sso@dify.ai') diff --git a/cli/src/commands/auth/login/login.ts b/cli/src/commands/auth/login/login.ts index d30ebee26a..0048d89c06 100644 --- a/cli/src/commands/auth/login/login.ts +++ b/cli/src/commands/auth/login/login.ts @@ -1,19 +1,19 @@ -import type { CodeResponse, PollSuccess } from '../../../api/oauth-device.js' -import type { HostsBundle, Workspace } from '../../../auth/hosts.js' -import type { StorageMode, Store } from '../../../store/store.js' -import type { IOStreams } from '../../../sys/io/streams' -import type { BrowserEnv, BrowserOpener } from '../../../util/browser.js' -import type { Clock } from './device-flow.js' +import type { Clock } from './device-flow' +import type { CodeResponse, PollSuccess } from '@/api/oauth-device' +import type { HostsBundle, Workspace } from '@/auth/hosts' +import type { StorageMode, Store } from '@/store/store' +import type { IOStreams } from '@/sys/io/streams' +import type { BrowserEnv, BrowserOpener } from '@/util/browser' import * as os from 'node:os' import * as readline from 'node:readline' -import { DeviceFlowApi } from '../../../api/oauth-device.js' -import { saveHosts } from '../../../auth/hosts.js' -import { createClient } from '../../../http/client.js' -import { getTokenStore, tokenKey } from '../../../store/manager.js' -import { colorEnabled, colorScheme } from '../../../sys/io/color.js' -import { decideOpen, OpenDecision, openUrl, realEnv } from '../../../util/browser.js' -import { bareHost, DEFAULT_HOST, resolveHost, validateVerificationURI } from '../../../util/host.js' -import { awaitAuthorization, realClock } from './device-flow.js' +import { DeviceFlowApi } from '@/api/oauth-device' +import { saveHosts } from '@/auth/hosts' +import { createClient } from '@/http/client' +import { getTokenStore, tokenKey } from '@/store/manager' +import { colorEnabled, colorScheme } from '@/sys/io/color' +import { decideOpen, OpenDecision, openUrl, realEnv } from '@/util/browser' +import { bareHost, DEFAULT_HOST, resolveHost, validateVerificationURI } from '@/util/host' +import { awaitAuthorization, realClock } from './device-flow' export type LoginOptions = { readonly io: IOStreams diff --git a/cli/src/commands/auth/logout/index.ts b/cli/src/commands/auth/logout/index.ts index f80f2d3fc9..9b65aff42b 100644 --- a/cli/src/commands/auth/logout/index.ts +++ b/cli/src/commands/auth/logout/index.ts @@ -1,11 +1,11 @@ import type { KyInstance } from 'ky' -import { loadHosts } from '../../../auth/hosts.js' -import { createClient } from '../../../http/client.js' -import { runWithSpinner } from '../../../sys/io/spinner.js' -import { realStreams } from '../../../sys/io/streams' -import { hostWithScheme } from '../../../util/host.js' -import { DifyCommand } from '../../_shared/dify-command.js' -import { runLogout } from './logout.js' +import { loadHosts } from '@/auth/hosts' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { createClient } from '@/http/client' +import { runWithSpinner } from '@/sys/io/spinner' +import { realStreams } from '@/sys/io/streams' +import { hostWithScheme } from '@/util/host' +import { runLogout } from './logout' export default class Logout extends DifyCommand { static override description = 'Log out of the active Dify host' diff --git a/cli/src/commands/auth/logout/logout.test.ts b/cli/src/commands/auth/logout/logout.test.ts index 621cf1555e..fe0ca5aa3a 100644 --- a/cli/src/commands/auth/logout/logout.test.ts +++ b/cli/src/commands/auth/logout/logout.test.ts @@ -1,17 +1,17 @@ -import type { DifyMock } from '../../../../test/fixtures/dify-mock/server.js' -import type { HostsBundle } from '../../../auth/hosts.js' -import type { Key, Store } from '../../../store/store.js' +import type { DifyMock } from '@test/fixtures/dify-mock/server' +import type { HostsBundle } from '@/auth/hosts' +import type { Key, Store } from '@/store/store' import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' +import { startMock } from '@test/fixtures/dify-mock/server' import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { startMock } from '../../../../test/fixtures/dify-mock/server.js' -import { saveHosts } from '../../../auth/hosts.js' -import { createClient } from '../../../http/client.js' -import { ENV_CONFIG_DIR } from '../../../store/dir.js' -import { tokenKey } from '../../../store/manager.js' -import { bufferStreams } from '../../../sys/io/streams' -import { runLogout } from './logout.js' +import { saveHosts } from '@/auth/hosts' +import { createClient } from '@/http/client' +import { ENV_CONFIG_DIR } from '@/store/dir' +import { tokenKey } from '@/store/manager' +import { bufferStreams } from '@/sys/io/streams' +import { runLogout } from './logout' class MemStore implements Store { readonly entries = new Map() diff --git a/cli/src/commands/auth/logout/logout.ts b/cli/src/commands/auth/logout/logout.ts index 3090ed09a7..c2a1c9d32a 100644 --- a/cli/src/commands/auth/logout/logout.ts +++ b/cli/src/commands/auth/logout/logout.ts @@ -1,13 +1,13 @@ import type { KyInstance } from 'ky' -import type { HostsBundle } from '../../../auth/hosts.js' -import type { Store } from '../../../store/store.js' -import type { IOStreams } from '../../../sys/io/streams' -import { AccountSessionsClient } from '../../../api/account-sessions.js' -import { clearLocal } from '../../../auth/hosts.js' -import { BaseError } from '../../../errors/base.js' -import { ErrorCode } from '../../../errors/codes.js' -import { getTokenStore } from '../../../store/manager.js' -import { colorEnabled, colorScheme } from '../../../sys/io/color.js' +import type { HostsBundle } from '@/auth/hosts' +import type { Store } from '@/store/store' +import type { IOStreams } from '@/sys/io/streams' +import { AccountSessionsClient } from '@/api/account-sessions' +import { clearLocal } from '@/auth/hosts' +import { BaseError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' +import { getTokenStore } from '@/store/manager' +import { colorEnabled, colorScheme } from '@/sys/io/color' export type LogoutOptions = { readonly io: IOStreams diff --git a/cli/src/commands/auth/status/index.ts b/cli/src/commands/auth/status/index.ts index 3e95374767..46e9e849d7 100644 --- a/cli/src/commands/auth/status/index.ts +++ b/cli/src/commands/auth/status/index.ts @@ -1,8 +1,8 @@ -import { loadHosts } from '../../../auth/hosts.js' -import { Flags } from '../../../framework/flags.js' -import { realStreams } from '../../../sys/io/streams' -import { DifyCommand } from '../../_shared/dify-command.js' -import { runStatus } from './status.js' +import { loadHosts } from '@/auth/hosts' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { Flags } from '@/framework/flags' +import { realStreams } from '@/sys/io/streams' +import { runStatus } from './status' export default class Status extends DifyCommand { static override description = 'Show authentication status for the active host' diff --git a/cli/src/commands/auth/status/status.test.ts b/cli/src/commands/auth/status/status.test.ts index f039d54866..9df4173b39 100644 --- a/cli/src/commands/auth/status/status.test.ts +++ b/cli/src/commands/auth/status/status.test.ts @@ -1,7 +1,7 @@ -import type { HostsBundle } from '../../../auth/hosts.js' +import type { HostsBundle } from '@/auth/hosts' import { describe, expect, it } from 'vitest' -import { bufferStreams } from '../../../sys/io/streams' -import { runStatus } from './status.js' +import { bufferStreams } from '@/sys/io/streams' +import { runStatus } from './status' function accountBundle(): HostsBundle { return { diff --git a/cli/src/commands/auth/status/status.ts b/cli/src/commands/auth/status/status.ts index 83ca626827..054b351a21 100644 --- a/cli/src/commands/auth/status/status.ts +++ b/cli/src/commands/auth/status/status.ts @@ -1,7 +1,7 @@ -import type { HostsBundle } from '../../../auth/hosts.js' -import type { IOStreams } from '../../../sys/io/streams' -import { BaseError } from '../../../errors/base.js' -import { ErrorCode } from '../../../errors/codes.js' +import type { HostsBundle } from '@/auth/hosts' +import type { IOStreams } from '@/sys/io/streams' +import { BaseError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' export type StatusOptions = { readonly io: IOStreams diff --git a/cli/src/commands/auth/whoami/index.ts b/cli/src/commands/auth/whoami/index.ts index e59db2d303..1c10ea50eb 100644 --- a/cli/src/commands/auth/whoami/index.ts +++ b/cli/src/commands/auth/whoami/index.ts @@ -1,8 +1,8 @@ -import { loadHosts } from '../../../auth/hosts.js' -import { Flags } from '../../../framework/flags.js' -import { realStreams } from '../../../sys/io/streams' -import { DifyCommand } from '../../_shared/dify-command.js' -import { runWhoami } from './whoami.js' +import { loadHosts } from '@/auth/hosts' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { Flags } from '@/framework/flags' +import { realStreams } from '@/sys/io/streams' +import { runWhoami } from './whoami' export default class Whoami extends DifyCommand { static override description = 'Print the active subject\'s identity' diff --git a/cli/src/commands/auth/whoami/whoami.test.ts b/cli/src/commands/auth/whoami/whoami.test.ts index 98ea0a9bcb..dde6d480e7 100644 --- a/cli/src/commands/auth/whoami/whoami.test.ts +++ b/cli/src/commands/auth/whoami/whoami.test.ts @@ -1,7 +1,7 @@ -import type { HostsBundle } from '../../../auth/hosts.js' +import type { HostsBundle } from '@/auth/hosts' import { describe, expect, it } from 'vitest' -import { bufferStreams } from '../../../sys/io/streams' -import { runWhoami } from './whoami.js' +import { bufferStreams } from '@/sys/io/streams' +import { runWhoami } from './whoami' function accountBundle(): HostsBundle { return { diff --git a/cli/src/commands/auth/whoami/whoami.ts b/cli/src/commands/auth/whoami/whoami.ts index 908daaddec..e40d56787f 100644 --- a/cli/src/commands/auth/whoami/whoami.ts +++ b/cli/src/commands/auth/whoami/whoami.ts @@ -1,7 +1,7 @@ -import type { HostsBundle } from '../../../auth/hosts.js' -import type { IOStreams } from '../../../sys/io/streams' -import { BaseError } from '../../../errors/base.js' -import { ErrorCode } from '../../../errors/codes.js' +import type { HostsBundle } from '@/auth/hosts' +import type { IOStreams } from '@/sys/io/streams' +import { BaseError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' export type WhoamiOptions = { readonly io: IOStreams diff --git a/cli/src/commands/config/get/index.ts b/cli/src/commands/config/get/index.ts index d02fcdb18d..907672c577 100644 --- a/cli/src/commands/config/get/index.ts +++ b/cli/src/commands/config/get/index.ts @@ -1,8 +1,8 @@ -import { Args } from '../../../framework/flags.js' -import { raw } from '../../../framework/output.js' -import { getConfigurationStore } from '../../../store/manager.js' -import { DifyCommand } from '../../_shared/dify-command.js' -import { runConfigGet } from './run.js' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { Args } from '@/framework/flags' +import { raw } from '@/framework/output' +import { getConfigurationStore } from '@/store/manager' +import { runConfigGet } from './run' export default class ConfigGet extends DifyCommand { static override description = 'Print one config key\'s value' diff --git a/cli/src/commands/config/get/run.test.ts b/cli/src/commands/config/get/run.test.ts index cfe7d12779..2246b111af 100644 --- a/cli/src/commands/config/get/run.test.ts +++ b/cli/src/commands/config/get/run.test.ts @@ -2,11 +2,11 @@ import { mkdtemp, rm } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { isBaseError } from '../../../errors/base.js' -import { ErrorCode } from '../../../errors/codes.js' -import { ENV_CONFIG_DIR } from '../../../store/dir.js' -import { getConfigurationStore } from '../../../store/manager.js' -import { runConfigGet } from './run.js' +import { isBaseError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' +import { ENV_CONFIG_DIR } from '@/store/dir' +import { getConfigurationStore } from '@/store/manager' +import { runConfigGet } from './run' describe('runConfigGet', () => { let dir: string diff --git a/cli/src/commands/config/get/run.ts b/cli/src/commands/config/get/run.ts index 8fb486e60b..b4713fa84d 100644 --- a/cli/src/commands/config/get/run.ts +++ b/cli/src/commands/config/get/run.ts @@ -1,8 +1,8 @@ -import type { ConfigFile } from '../../../config/schema.js' -import type { YamlStore } from '../../../store/store.js' -import { loadConfig } from '../../../config/config-loader.js' -import { getKey } from '../../../config/keys.js' -import { emptyConfig } from '../../../config/schema.js' +import type { ConfigFile } from '@/config/schema' +import type { YamlStore } from '@/store/store' +import { loadConfig } from '@/config/config-loader' +import { getKey } from '@/config/keys' +import { emptyConfig } from '@/config/schema' export type RunConfigGetOptions = { readonly key: string diff --git a/cli/src/commands/config/path/index.ts b/cli/src/commands/config/path/index.ts index 2bf22c8988..dcb2aed259 100644 --- a/cli/src/commands/config/path/index.ts +++ b/cli/src/commands/config/path/index.ts @@ -1,8 +1,8 @@ import { join } from 'node:path' -import { raw } from '../../../framework/output.js' -import { resolveConfigDir } from '../../../store/dir.js' -import { CONFIG_FILE_NAME } from '../../../store/manager.js' -import { DifyCommand } from '../../_shared/dify-command.js' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { raw } from '@/framework/output' +import { resolveConfigDir } from '@/store/dir' +import { CONFIG_FILE_NAME } from '@/store/manager' export default class ConfigPath extends DifyCommand { static override description = 'Print the resolved config.yml path' diff --git a/cli/src/commands/config/set/index.ts b/cli/src/commands/config/set/index.ts index d747a8783b..36aa97d17b 100644 --- a/cli/src/commands/config/set/index.ts +++ b/cli/src/commands/config/set/index.ts @@ -1,8 +1,8 @@ -import { Args } from '../../../framework/flags.js' -import { raw } from '../../../framework/output.js' -import { getConfigurationStore } from '../../../store/manager.js' -import { DifyCommand } from '../../_shared/dify-command.js' -import { runConfigSet } from './run.js' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { Args } from '@/framework/flags' +import { raw } from '@/framework/output' +import { getConfigurationStore } from '@/store/manager' +import { runConfigSet } from './run' export default class ConfigSet extends DifyCommand { static override description = 'Set a config key (validates value)' diff --git a/cli/src/commands/config/set/run.test.ts b/cli/src/commands/config/set/run.test.ts index dcb72a40d5..6185dd8780 100644 --- a/cli/src/commands/config/set/run.test.ts +++ b/cli/src/commands/config/set/run.test.ts @@ -2,12 +2,12 @@ import { mkdtemp, rm } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { loadConfig } from '../../../config/config-loader.js' -import { isBaseError } from '../../../errors/base.js' -import { ErrorCode, ExitCode } from '../../../errors/codes.js' -import { ENV_CONFIG_DIR } from '../../../store/dir.js' -import { getConfigurationStore } from '../../../store/manager.js' -import { runConfigSet } from './run.js' +import { loadConfig } from '@/config/config-loader' +import { isBaseError } from '@/errors/base' +import { ErrorCode, ExitCode } from '@/errors/codes' +import { ENV_CONFIG_DIR } from '@/store/dir' +import { getConfigurationStore } from '@/store/manager' +import { runConfigSet } from './run' describe('runConfigSet', () => { let dir: string diff --git a/cli/src/commands/config/set/run.ts b/cli/src/commands/config/set/run.ts index c7a1e752b5..2794427e1a 100644 --- a/cli/src/commands/config/set/run.ts +++ b/cli/src/commands/config/set/run.ts @@ -1,9 +1,9 @@ -import type { ConfigFile } from '../../../config/schema.js' -import type { YamlStore } from '../../../store/store.js' -import { loadConfig } from '../../../config/config-loader.js' -import { setKey } from '../../../config/keys.js' -import { emptyConfig } from '../../../config/schema.js' -import { saveConfig } from '../../../store/config-writer.js' +import type { ConfigFile } from '@/config/schema' +import type { YamlStore } from '@/store/store' +import { loadConfig } from '@/config/config-loader' +import { setKey } from '@/config/keys' +import { emptyConfig } from '@/config/schema' +import { saveConfig } from '@/store/config-writer' export type RunConfigSetOptions = { readonly key: string diff --git a/cli/src/commands/config/unset/index.ts b/cli/src/commands/config/unset/index.ts index a7e7d08096..f8ae6fe15b 100644 --- a/cli/src/commands/config/unset/index.ts +++ b/cli/src/commands/config/unset/index.ts @@ -1,8 +1,8 @@ -import { Args } from '../../../framework/flags.js' -import { raw } from '../../../framework/output.js' -import { getConfigurationStore } from '../../../store/manager.js' -import { DifyCommand } from '../../_shared/dify-command.js' -import { runConfigUnset } from './run.js' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { Args } from '@/framework/flags' +import { raw } from '@/framework/output' +import { getConfigurationStore } from '@/store/manager' +import { runConfigUnset } from './run' export default class ConfigUnset extends DifyCommand { static override description = 'Reset a config key to its zero value' diff --git a/cli/src/commands/config/unset/run.test.ts b/cli/src/commands/config/unset/run.test.ts index 85a343d256..6044457841 100644 --- a/cli/src/commands/config/unset/run.test.ts +++ b/cli/src/commands/config/unset/run.test.ts @@ -2,12 +2,12 @@ import { mkdtemp, rm } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { loadConfig } from '../../../config/config-loader.js' -import { isBaseError } from '../../../errors/base.js' -import { ErrorCode } from '../../../errors/codes.js' -import { ENV_CONFIG_DIR } from '../../../store/dir.js' -import { getConfigurationStore } from '../../../store/manager.js' -import { runConfigUnset } from './run.js' +import { loadConfig } from '@/config/config-loader' +import { isBaseError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' +import { ENV_CONFIG_DIR } from '@/store/dir' +import { getConfigurationStore } from '@/store/manager' +import { runConfigUnset } from './run' describe('runConfigUnset', () => { let dir: string diff --git a/cli/src/commands/config/unset/run.ts b/cli/src/commands/config/unset/run.ts index 377013ff0f..4b34e34788 100644 --- a/cli/src/commands/config/unset/run.ts +++ b/cli/src/commands/config/unset/run.ts @@ -1,9 +1,9 @@ -import type { ConfigFile } from '../../../config/schema.js' -import type { YamlStore } from '../../../store/store.js' -import { loadConfig } from '../../../config/config-loader.js' -import { unsetKey } from '../../../config/keys.js' -import { emptyConfig } from '../../../config/schema.js' -import { saveConfig } from '../../../store/config-writer.js' +import type { ConfigFile } from '@/config/schema' +import type { YamlStore } from '@/store/store' +import { loadConfig } from '@/config/config-loader' +import { unsetKey } from '@/config/keys' +import { emptyConfig } from '@/config/schema' +import { saveConfig } from '@/store/config-writer' export type RunConfigUnsetOptions = { readonly key: string diff --git a/cli/src/commands/config/view/index.ts b/cli/src/commands/config/view/index.ts index f9e216ade1..b165fea1fc 100644 --- a/cli/src/commands/config/view/index.ts +++ b/cli/src/commands/config/view/index.ts @@ -1,8 +1,8 @@ -import { Flags } from '../../../framework/flags.js' -import { raw } from '../../../framework/output.js' -import { getConfigurationStore } from '../../../store/manager.js' -import { DifyCommand } from '../../_shared/dify-command.js' -import { runConfigView } from './run.js' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { Flags } from '@/framework/flags' +import { raw } from '@/framework/output' +import { getConfigurationStore } from '@/store/manager' +import { runConfigView } from './run' export default class ConfigView extends DifyCommand { static override description = 'Print the resolved config' diff --git a/cli/src/commands/config/view/run.test.ts b/cli/src/commands/config/view/run.test.ts index 336f468796..45e3aff8ca 100644 --- a/cli/src/commands/config/view/run.test.ts +++ b/cli/src/commands/config/view/run.test.ts @@ -2,9 +2,9 @@ import { mkdtemp, rm } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { ENV_CONFIG_DIR } from '../../../store/dir.js' -import { getConfigurationStore } from '../../../store/manager.js' -import { runConfigView } from './run.js' +import { ENV_CONFIG_DIR } from '@/store/dir' +import { getConfigurationStore } from '@/store/manager' +import { runConfigView } from './run' describe('runConfigView', () => { let dir: string diff --git a/cli/src/commands/config/view/run.ts b/cli/src/commands/config/view/run.ts index 78b9e1ca52..667cb903d5 100644 --- a/cli/src/commands/config/view/run.ts +++ b/cli/src/commands/config/view/run.ts @@ -1,8 +1,8 @@ -import type { ConfigFile } from '../../../config/schema.js' -import type { YamlStore } from '../../../store/store.js' -import { loadConfig } from '../../../config/config-loader.js' -import { knownKeyNames, lookupKey } from '../../../config/keys.js' -import { emptyConfig } from '../../../config/schema.js' +import type { ConfigFile } from '@/config/schema' +import type { YamlStore } from '@/store/store' +import { loadConfig } from '@/config/config-loader' +import { knownKeyNames, lookupKey } from '@/config/keys' +import { emptyConfig } from '@/config/schema' export type RunConfigViewOptions = { readonly json?: boolean diff --git a/cli/src/commands/coverage.test.ts b/cli/src/commands/coverage.test.ts index 19a64664a8..25cc4e4de7 100644 --- a/cli/src/commands/coverage.test.ts +++ b/cli/src/commands/coverage.test.ts @@ -1,5 +1,6 @@ +/// import { describe, expect, it } from 'vitest' -import { isExcludedCommandPath } from '../framework/command-fs.js' +import { isExcludedCommandPath } from '@/framework/command-fs' const INDEX_MODULES = import.meta.glob<{ default?: unknown }>( './**/index.ts', diff --git a/cli/src/commands/create/member/index.ts b/cli/src/commands/create/member/index.ts index 7a0ee2a935..9253c86fcd 100644 --- a/cli/src/commands/create/member/index.ts +++ b/cli/src/commands/create/member/index.ts @@ -1,8 +1,8 @@ -import { Flags } from '../../../framework/flags.js' -import { formatted, OutputFormat } from '../../../framework/output.js' -import { DifyCommand } from '../../_shared/dify-command.js' -import { httpRetryFlag } from '../../_shared/global-flags.js' -import { runCreateMember } from './run.js' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { httpRetryFlag } from '@/commands/_shared/global-flags' +import { Flags } from '@/framework/flags' +import { formatted, OutputFormat } from '@/framework/output' +import { runCreateMember } from './run' export default class CreateMember extends DifyCommand { static override description = 'Invite a member to the active (or specified) workspace by email' diff --git a/cli/src/commands/create/member/run.test.ts b/cli/src/commands/create/member/run.test.ts index 5c739f5a2a..4ac72b0552 100644 --- a/cli/src/commands/create/member/run.test.ts +++ b/cli/src/commands/create/member/run.test.ts @@ -1,8 +1,8 @@ import type { KyInstance } from 'ky' -import type { HostsBundle } from '../../../auth/hosts.js' +import type { HostsBundle } from '@/auth/hosts' import { describe, expect, it, vi } from 'vitest' -import { bufferStreams } from '../../../sys/io/streams.js' -import { runCreateMember } from './run.js' +import { bufferStreams } from '@/sys/io/streams' +import { runCreateMember } from './run' function bundle(): HostsBundle { return { diff --git a/cli/src/commands/create/member/run.ts b/cli/src/commands/create/member/run.ts index 0608b2fb7b..1e4a9c3ab0 100644 --- a/cli/src/commands/create/member/run.ts +++ b/cli/src/commands/create/member/run.ts @@ -1,14 +1,14 @@ import type { KyInstance } from 'ky' -import type { HostsBundle } from '../../../auth/hosts.js' -import type { IOStreams } from '../../../sys/io/streams.js' -import { MembersClient } from '../../../api/members.js' -import { BaseError } from '../../../errors/base.js' -import { ErrorCode } from '../../../errors/codes.js' -import { colorEnabled, colorScheme } from '../../../sys/io/color.js' -import { runWithSpinner } from '../../../sys/io/spinner.js' -import { nullStreams } from '../../../sys/io/streams.js' -import { resolveWorkspaceId } from '../../../workspace/resolver.js' -import { InviteOutput } from './handlers.js' +import type { HostsBundle } from '@/auth/hosts' +import type { IOStreams } from '@/sys/io/streams' +import { MembersClient } from '@/api/members' +import { BaseError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' +import { colorEnabled, colorScheme } from '@/sys/io/color' +import { runWithSpinner } from '@/sys/io/spinner' +import { nullStreams } from '@/sys/io/streams' +import { resolveWorkspaceId } from '@/workspace/resolver' +import { InviteOutput } from './handlers' export type CreateMemberOptions = { readonly email: string diff --git a/cli/src/commands/delete/member/index.ts b/cli/src/commands/delete/member/index.ts index 1ec7956502..2e4d89b4be 100644 --- a/cli/src/commands/delete/member/index.ts +++ b/cli/src/commands/delete/member/index.ts @@ -1,8 +1,8 @@ -import { Args, Flags } from '../../../framework/flags.js' -import { formatted, OutputFormat } from '../../../framework/output.js' -import { DifyCommand } from '../../_shared/dify-command.js' -import { httpRetryFlag } from '../../_shared/global-flags.js' -import { runDeleteMember } from './run.js' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { httpRetryFlag } from '@/commands/_shared/global-flags' +import { Args, Flags } from '@/framework/flags' +import { formatted, OutputFormat } from '@/framework/output' +import { runDeleteMember } from './run' export default class DeleteMember extends DifyCommand { static override description = 'Remove a member from the active (or specified) workspace' diff --git a/cli/src/commands/delete/member/run.test.ts b/cli/src/commands/delete/member/run.test.ts index 15a4f66db2..db4a3c0adc 100644 --- a/cli/src/commands/delete/member/run.test.ts +++ b/cli/src/commands/delete/member/run.test.ts @@ -1,8 +1,8 @@ import type { KyInstance } from 'ky' -import type { HostsBundle } from '../../../auth/hosts.js' +import type { HostsBundle } from '@/auth/hosts' import { describe, expect, it, vi } from 'vitest' -import { bufferStreams } from '../../../sys/io/streams.js' -import { runDeleteMember } from './run.js' +import { bufferStreams } from '@/sys/io/streams' +import { runDeleteMember } from './run' function bundle(): HostsBundle { return { diff --git a/cli/src/commands/delete/member/run.ts b/cli/src/commands/delete/member/run.ts index f89afe86c7..63fda52d54 100644 --- a/cli/src/commands/delete/member/run.ts +++ b/cli/src/commands/delete/member/run.ts @@ -1,15 +1,15 @@ import type { KyInstance } from 'ky' -import type { HostsBundle } from '../../../auth/hosts.js' -import type { IOStreams } from '../../../sys/io/streams.js' +import type { HostsBundle } from '@/auth/hosts' +import type { IOStreams } from '@/sys/io/streams' import * as readline from 'node:readline' -import { MembersClient } from '../../../api/members.js' -import { BaseError } from '../../../errors/base.js' -import { ErrorCode } from '../../../errors/codes.js' -import { colorEnabled, colorScheme } from '../../../sys/io/color.js' -import { runWithSpinner } from '../../../sys/io/spinner.js' -import { nullStreams } from '../../../sys/io/streams.js' -import { resolveWorkspaceId } from '../../../workspace/resolver.js' -import { DeleteMemberOutput } from './handlers.js' +import { MembersClient } from '@/api/members' +import { BaseError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' +import { colorEnabled, colorScheme } from '@/sys/io/color' +import { runWithSpinner } from '@/sys/io/spinner' +import { nullStreams } from '@/sys/io/streams' +import { resolveWorkspaceId } from '@/workspace/resolver' +import { DeleteMemberOutput } from './handlers' export type DeleteMemberOptions = { readonly memberId: string diff --git a/cli/src/commands/describe/app/handlers.ts b/cli/src/commands/describe/app/handlers.ts index ef0f56b103..6b934c8714 100644 --- a/cli/src/commands/describe/app/handlers.ts +++ b/cli/src/commands/describe/app/handlers.ts @@ -1,5 +1,5 @@ import type { AppDescribeInfo, TagItem } from '@dify/contracts/api/openapi/types.gen' -import type { AppMeta } from '../../../types/app-meta.js' +import type { AppMeta } from '@/types/app-meta' export const APP_DESCRIBE_MODE_KEY = 'app-describe' diff --git a/cli/src/commands/describe/app/index.ts b/cli/src/commands/describe/app/index.ts index 61a87005d3..ce09af76d2 100644 --- a/cli/src/commands/describe/app/index.ts +++ b/cli/src/commands/describe/app/index.ts @@ -1,8 +1,8 @@ -import { Args, Flags } from '../../../framework/flags.js' -import { formatted, OutputFormat } from '../../../framework/output.js' -import { DifyCommand } from '../../_shared/dify-command.js' -import { httpRetryFlag } from '../../_shared/global-flags.js' -import { runDescribeApp } from './run.js' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { httpRetryFlag } from '@/commands/_shared/global-flags' +import { Args, Flags } from '@/framework/flags' +import { formatted, OutputFormat } from '@/framework/output' +import { runDescribeApp } from './run' export default class DescribeApp extends DifyCommand { static override description = 'Describe a single app (kubectl-describe-style)' diff --git a/cli/src/commands/describe/app/run.test.ts b/cli/src/commands/describe/app/run.test.ts index e599ee0bbf..65da6bfa4e 100644 --- a/cli/src/commands/describe/app/run.test.ts +++ b/cli/src/commands/describe/app/run.test.ts @@ -1,16 +1,16 @@ -import type { DifyMock } from '../../../../test/fixtures/dify-mock/server.js' -import type { HostsBundle } from '../../../auth/hosts.js' +import type { DifyMock } from '@test/fixtures/dify-mock/server' +import type { HostsBundle } from '@/auth/hosts' import { mkdtemp, rm } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' +import { startMock } from '@test/fixtures/dify-mock/server' import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { startMock } from '../../../../test/fixtures/dify-mock/server.js' -import { loadAppInfoCache } from '../../../cache/app-info.js' -import { formatted, stringifyOutput } from '../../../framework/output.js' -import { createClient } from '../../../http/client.js' -import { ENV_CACHE_DIR } from '../../../store/dir.js' -import { CACHE_APP_INFO, getCache } from '../../../store/manager.js' -import { runDescribeApp } from './run.js' +import { loadAppInfoCache } from '@/cache/app-info' +import { formatted, stringifyOutput } from '@/framework/output' +import { createClient } from '@/http/client' +import { ENV_CACHE_DIR } from '@/store/dir' +import { CACHE_APP_INFO, getCache } from '@/store/manager' +import { runDescribeApp } from './run' function bundle(): HostsBundle { return { diff --git a/cli/src/commands/describe/app/run.ts b/cli/src/commands/describe/app/run.ts index f332cc992a..5542fa5fd7 100644 --- a/cli/src/commands/describe/app/run.ts +++ b/cli/src/commands/describe/app/run.ts @@ -1,15 +1,15 @@ import type { KyInstance } from 'ky' -import type { HostsBundle } from '../../../auth/hosts.js' -import type { AppInfoCache } from '../../../cache/app-info.js' -import type { IOStreams } from '../../../sys/io/streams' -import { AppMetaClient } from '../../../api/app-meta.js' -import { AppsClient } from '../../../api/apps.js' -import { getEnv } from '../../../sys/index.js' -import { runWithSpinner } from '../../../sys/io/spinner.js' -import { nullStreams } from '../../../sys/io/streams' -import { FieldInfo, FieldInputSchema, FieldParameters } from '../../../types/app-meta.js' -import { resolveWorkspaceId } from '../../../workspace/resolver.js' -import { AppDescribeOutput } from './handlers.js' +import type { HostsBundle } from '@/auth/hosts' +import type { AppInfoCache } from '@/cache/app-info' +import type { IOStreams } from '@/sys/io/streams' +import { AppMetaClient } from '@/api/app-meta' +import { AppsClient } from '@/api/apps' +import { getEnv } from '@/sys/index' +import { runWithSpinner } from '@/sys/io/spinner' +import { nullStreams } from '@/sys/io/streams' +import { FieldInfo, FieldInputSchema, FieldParameters } from '@/types/app-meta' +import { resolveWorkspaceId } from '@/workspace/resolver' +import { AppDescribeOutput } from './handlers' export type DescribeAppOptions = { readonly appId: string diff --git a/cli/src/commands/env/list/index.ts b/cli/src/commands/env/list/index.ts index 1ecc96fe01..777dfd133a 100644 --- a/cli/src/commands/env/list/index.ts +++ b/cli/src/commands/env/list/index.ts @@ -1,7 +1,7 @@ -import { Flags } from '../../../framework/flags.js' -import { raw } from '../../../framework/output.js' -import { DifyCommand } from '../../_shared/dify-command.js' -import { runEnvList } from './run-list.js' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { Flags } from '@/framework/flags' +import { raw } from '@/framework/output' +import { runEnvList } from './run-list' export default class EnvList extends DifyCommand { static override description = 'Show every DIFY_* env var difyctl reads' diff --git a/cli/src/commands/env/list/run-list.test.ts b/cli/src/commands/env/list/run-list.test.ts index 01e6dfcfd0..642e0d6358 100644 --- a/cli/src/commands/env/list/run-list.test.ts +++ b/cli/src/commands/env/list/run-list.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { runEnvList } from './run-list.js' +import { runEnvList } from './run-list' const stub = (overrides: Record = {}) => (name: string) => overrides[name] diff --git a/cli/src/commands/env/list/run-list.ts b/cli/src/commands/env/list/run-list.ts index 379c81d4af..9979e525e4 100644 --- a/cli/src/commands/env/list/run-list.ts +++ b/cli/src/commands/env/list/run-list.ts @@ -1,5 +1,5 @@ -import { ENV_REGISTRY } from '../../../env/registry.js' -import { getEnv } from '../../../sys/index.js' +import { ENV_REGISTRY } from '@/env/registry' +import { getEnv } from '@/sys/index' export type EnvLookup = (name: string) => string | undefined diff --git a/cli/src/commands/get/app/handlers.ts b/cli/src/commands/get/app/handlers.ts index e0646e267a..18acd1fdd7 100644 --- a/cli/src/commands/get/app/handlers.ts +++ b/cli/src/commands/get/app/handlers.ts @@ -1,6 +1,6 @@ import type { AppListResponse, AppListRow, TagItem } from '@dify/contracts/api/openapi/types.gen' -import type { TableCell } from '../../../framework/output.js' -import type { TableColumn } from '../../../printers/format-table.js' +import type { TableCell } from '@/framework/output' +import type { TableColumn } from '@/printers/format-table' export const APP_MODE_KEY = 'app' diff --git a/cli/src/commands/get/app/index.ts b/cli/src/commands/get/app/index.ts index c4ec2bd06c..1c71428c37 100644 --- a/cli/src/commands/get/app/index.ts +++ b/cli/src/commands/get/app/index.ts @@ -1,9 +1,9 @@ import type { AppMode } from '@dify/contracts/api/openapi/types.gen' -import { Args, Flags } from '../../../framework/flags.js' -import { OutputFormat, table } from '../../../framework/output.js' -import { DifyCommand } from '../../_shared/dify-command.js' -import { httpRetryFlag } from '../../_shared/global-flags.js' -import { runGetApp } from './run.js' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { httpRetryFlag } from '@/commands/_shared/global-flags' +import { Args, Flags } from '@/framework/flags' +import { OutputFormat, table } from '@/framework/output' +import { runGetApp } from './run' const APP_MODE_VALUES: readonly AppMode[] = [ 'advanced-chat', diff --git a/cli/src/commands/get/app/run.test.ts b/cli/src/commands/get/app/run.test.ts index ebabf57fe0..e9e4d52916 100644 --- a/cli/src/commands/get/app/run.test.ts +++ b/cli/src/commands/get/app/run.test.ts @@ -1,11 +1,11 @@ -import type { DifyMock } from '../../../../test/fixtures/dify-mock/server.js' -import type { HostsBundle } from '../../../auth/hosts.js' +import type { DifyMock } from '@test/fixtures/dify-mock/server' +import type { HostsBundle } from '@/auth/hosts' +import { startMock } from '@test/fixtures/dify-mock/server' import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { startMock } from '../../../../test/fixtures/dify-mock/server.js' -import { stringifyOutput, table } from '../../../framework/output.js' -import { createClient } from '../../../http/client.js' -import { AppListOutput } from './handlers.js' -import { runGetApp } from './run.js' +import { stringifyOutput, table } from '@/framework/output' +import { createClient } from '@/http/client' +import { AppListOutput } from './handlers' +import { runGetApp } from './run' const baseBundle: HostsBundle = { current_host: '127.0.0.1', diff --git a/cli/src/commands/get/app/run.ts b/cli/src/commands/get/app/run.ts index ccb091db57..28ae0cba4a 100644 --- a/cli/src/commands/get/app/run.ts +++ b/cli/src/commands/get/app/run.ts @@ -1,15 +1,15 @@ import type { AppDescribeResponse, AppListResponse, AppMode } from '@dify/contracts/api/openapi/types.gen' import type { KyInstance } from 'ky' -import type { HostsBundle } from '../../../auth/hosts.js' -import type { IOStreams } from '../../../sys/io/streams' -import { AppsClient } from '../../../api/apps.js' -import { WorkspacesClient } from '../../../api/workspaces.js' -import { LIMIT_DEFAULT, parseLimit } from '../../../limit/limit.js' -import { getEnv } from '../../../sys/index.js' -import { runWithSpinner } from '../../../sys/io/spinner.js' -import { nullStreams } from '../../../sys/io/streams' -import { resolveWorkspaceId } from '../../../workspace/resolver.js' -import { AppListOutput, AppRow } from './handlers.js' +import type { HostsBundle } from '@/auth/hosts' +import type { IOStreams } from '@/sys/io/streams' +import { AppsClient } from '@/api/apps' +import { WorkspacesClient } from '@/api/workspaces' +import { LIMIT_DEFAULT, parseLimit } from '@/limit/limit' +import { getEnv } from '@/sys/index' +import { runWithSpinner } from '@/sys/io/spinner' +import { nullStreams } from '@/sys/io/streams' +import { resolveWorkspaceId } from '@/workspace/resolver' +import { AppListOutput, AppRow } from './handlers' export type GetAppOptions = { readonly appId?: string diff --git a/cli/src/commands/get/member/handlers.ts b/cli/src/commands/get/member/handlers.ts index b231916bec..9d2bc1af17 100644 --- a/cli/src/commands/get/member/handlers.ts +++ b/cli/src/commands/get/member/handlers.ts @@ -1,6 +1,6 @@ import type { MemberListResponse, MemberResponse } from '@dify/contracts/api/openapi/types.gen' -import type { TableCell } from '../../../framework/output.js' -import type { TableColumn } from '../../../printers/format-table.js' +import type { TableCell } from '@/framework/output' +import type { TableColumn } from '@/printers/format-table' export const MEMBER_MODE_KEY = 'member' const CURRENT_MARKER = '*' diff --git a/cli/src/commands/get/member/index.ts b/cli/src/commands/get/member/index.ts index b1b4d82033..2e5752c46f 100644 --- a/cli/src/commands/get/member/index.ts +++ b/cli/src/commands/get/member/index.ts @@ -1,8 +1,8 @@ -import { Flags } from '../../../framework/flags.js' -import { OutputFormat, table } from '../../../framework/output.js' -import { DifyCommand } from '../../_shared/dify-command.js' -import { httpRetryFlag } from '../../_shared/global-flags.js' -import { runGetMember } from './run.js' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { httpRetryFlag } from '@/commands/_shared/global-flags' +import { Flags } from '@/framework/flags' +import { OutputFormat, table } from '@/framework/output' +import { runGetMember } from './run' export default class GetMember extends DifyCommand { static override description = 'List members of the active (or specified) workspace' diff --git a/cli/src/commands/get/member/run.test.ts b/cli/src/commands/get/member/run.test.ts index d32b172eb9..5e0af7fe2a 100644 --- a/cli/src/commands/get/member/run.test.ts +++ b/cli/src/commands/get/member/run.test.ts @@ -1,9 +1,9 @@ import type { MemberListResponse } from '@dify/contracts/api/openapi/types.gen' import type { KyInstance } from 'ky' -import type { HostsBundle } from '../../../auth/hosts.js' +import type { HostsBundle } from '@/auth/hosts' import { describe, expect, it, vi } from 'vitest' -import { bufferStreams } from '../../../sys/io/streams.js' -import { runGetMember } from './run.js' +import { bufferStreams } from '@/sys/io/streams' +import { runGetMember } from './run' function bundle(): HostsBundle { return { diff --git a/cli/src/commands/get/member/run.ts b/cli/src/commands/get/member/run.ts index 011cdb1572..b6bf995dc1 100644 --- a/cli/src/commands/get/member/run.ts +++ b/cli/src/commands/get/member/run.ts @@ -1,12 +1,12 @@ import type { KyInstance } from 'ky' -import type { HostsBundle } from '../../../auth/hosts.js' -import type { IOStreams } from '../../../sys/io/streams.js' -import { MembersClient } from '../../../api/members.js' -import { LIMIT_DEFAULT, parseLimit } from '../../../limit/limit.js' -import { runWithSpinner } from '../../../sys/io/spinner.js' -import { nullStreams } from '../../../sys/io/streams.js' -import { resolveWorkspaceId } from '../../../workspace/resolver.js' -import { MemberListOutput, MemberRow } from './handlers.js' +import type { HostsBundle } from '@/auth/hosts' +import type { IOStreams } from '@/sys/io/streams' +import { MembersClient } from '@/api/members' +import { LIMIT_DEFAULT, parseLimit } from '@/limit/limit' +import { runWithSpinner } from '@/sys/io/spinner' +import { nullStreams } from '@/sys/io/streams' +import { resolveWorkspaceId } from '@/workspace/resolver' +import { MemberListOutput, MemberRow } from './handlers' export type GetMemberOptions = { readonly workspace?: string diff --git a/cli/src/commands/get/workspace/handlers.test.ts b/cli/src/commands/get/workspace/handlers.test.ts index cacbcf4b3e..2132388493 100644 --- a/cli/src/commands/get/workspace/handlers.test.ts +++ b/cli/src/commands/get/workspace/handlers.test.ts @@ -1,6 +1,6 @@ import type { WorkspaceListResponse } from '@dify/contracts/api/openapi/types.gen' import { describe, expect, it } from 'vitest' -import { newWorkspaceObject, WORKSPACE_MODE_KEY, WorkspaceListOutput, WorkspaceRow } from './handlers.js' +import { newWorkspaceObject, WORKSPACE_MODE_KEY, WorkspaceListOutput, WorkspaceRow } from './handlers' function env(): WorkspaceListResponse { return { diff --git a/cli/src/commands/get/workspace/handlers.ts b/cli/src/commands/get/workspace/handlers.ts index a71e8a6f64..b7d3b12155 100644 --- a/cli/src/commands/get/workspace/handlers.ts +++ b/cli/src/commands/get/workspace/handlers.ts @@ -1,7 +1,7 @@ import type { WorkspaceListResponse } from '@dify/contracts/api/openapi/types.gen' -import type { TableCell } from '../../../framework/output.js' -import type { TableColumn, TableHandler, TableRow } from '../../../printers/format-table.js' -import { isPayloadShape } from '../app/payload-shape.js' +import type { TableCell } from '@/framework/output' +import type { TableColumn, TableHandler, TableRow } from '@/printers/format-table' +import { isPayloadShape } from '@/commands/get/app/payload-shape' export const WORKSPACE_MODE_KEY = 'workspace' const CURRENT_MARKER = '*' diff --git a/cli/src/commands/get/workspace/index.ts b/cli/src/commands/get/workspace/index.ts index 3364f50761..3bbc3d3f54 100644 --- a/cli/src/commands/get/workspace/index.ts +++ b/cli/src/commands/get/workspace/index.ts @@ -1,8 +1,8 @@ -import { Flags } from '../../../framework/flags.js' -import { OutputFormat, raw, table } from '../../../framework/output.js' -import { DifyCommand } from '../../_shared/dify-command.js' -import { httpRetryFlag } from '../../_shared/global-flags.js' -import { runGetWorkspace } from './run.js' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { httpRetryFlag } from '@/commands/_shared/global-flags' +import { Flags } from '@/framework/flags' +import { OutputFormat, raw, table } from '@/framework/output' +import { runGetWorkspace } from './run' export default class GetWorkspace extends DifyCommand { static override description = 'List workspaces visible to the current bearer' diff --git a/cli/src/commands/get/workspace/run.test.ts b/cli/src/commands/get/workspace/run.test.ts index 7ef51c9d81..df7d1bd207 100644 --- a/cli/src/commands/get/workspace/run.test.ts +++ b/cli/src/commands/get/workspace/run.test.ts @@ -1,11 +1,11 @@ -import type { DifyMock } from '../../../../test/fixtures/dify-mock/server.js' -import type { HostsBundle } from '../../../auth/hosts.js' +import type { DifyMock } from '@test/fixtures/dify-mock/server' +import type { HostsBundle } from '@/auth/hosts' +import { startMock } from '@test/fixtures/dify-mock/server' import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { startMock } from '../../../../test/fixtures/dify-mock/server.js' -import { stringifyOutput, table } from '../../../framework/output.js' -import { createClient } from '../../../http/client.js' -import { WorkspaceListOutput } from './handlers.js' -import { EMPTY_WORKSPACES_MESSAGE, runGetWorkspace } from './run.js' +import { stringifyOutput, table } from '@/framework/output' +import { createClient } from '@/http/client' +import { WorkspaceListOutput } from './handlers' +import { EMPTY_WORKSPACES_MESSAGE, runGetWorkspace } from './run' const baseBundle: HostsBundle = { current_host: '127.0.0.1', diff --git a/cli/src/commands/get/workspace/run.ts b/cli/src/commands/get/workspace/run.ts index f3b86f3c1d..9f35dd5906 100644 --- a/cli/src/commands/get/workspace/run.ts +++ b/cli/src/commands/get/workspace/run.ts @@ -1,10 +1,10 @@ import type { KyInstance } from 'ky' -import type { HostsBundle } from '../../../auth/hosts.js' -import type { IOStreams } from '../../../sys/io/streams' -import { WorkspacesClient } from '../../../api/workspaces.js' -import { runWithSpinner } from '../../../sys/io/spinner.js' -import { nullStreams } from '../../../sys/io/streams' -import { WorkspaceListOutput, WorkspaceRow } from './handlers.js' +import type { HostsBundle } from '@/auth/hosts' +import type { IOStreams } from '@/sys/io/streams' +import { WorkspacesClient } from '@/api/workspaces' +import { runWithSpinner } from '@/sys/io/spinner' +import { nullStreams } from '@/sys/io/streams' +import { WorkspaceListOutput, WorkspaceRow } from './handlers' export const EMPTY_WORKSPACES_MESSAGE = 'No workspaces visible to this bearer (external-SSO subjects see empty data).\n' diff --git a/cli/src/commands/help/account/account.test.ts b/cli/src/commands/help/account/account.test.ts index 162fbda78a..b9f93d67da 100644 --- a/cli/src/commands/help/account/account.test.ts +++ b/cli/src/commands/help/account/account.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { runHelpAccount } from './account.js' +import { runHelpAccount } from './account' describe('runHelpAccount', () => { it('mentions auth login device flow', () => { diff --git a/cli/src/commands/help/account/index.ts b/cli/src/commands/help/account/index.ts index a9adfe0022..fd60123092 100644 --- a/cli/src/commands/help/account/index.ts +++ b/cli/src/commands/help/account/index.ts @@ -1,6 +1,6 @@ -import { raw } from '../../../framework/output.js' -import { DifyCommand } from '../../_shared/dify-command.js' -import { runHelpAccount } from './account.js' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { raw } from '@/framework/output' +import { runHelpAccount } from './account' export default class HelpAccount extends DifyCommand { static override description = 'Agent-onboarding text for account bearers (dfoa_)' diff --git a/cli/src/commands/help/environment/environment.test.ts b/cli/src/commands/help/environment/environment.test.ts index d6aad702b4..20024b0075 100644 --- a/cli/src/commands/help/environment/environment.test.ts +++ b/cli/src/commands/help/environment/environment.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { ENV_REGISTRY } from '../../../env/registry.js' -import { runHelpEnvironment } from './environment.js' +import { ENV_REGISTRY } from '@/env/registry' +import { runHelpEnvironment } from './environment' describe('runHelpEnvironment', () => { it('starts with the ENVIRONMENT VARIABLES header', () => { diff --git a/cli/src/commands/help/environment/environment.ts b/cli/src/commands/help/environment/environment.ts index 279c7de6d6..e168294cf7 100644 --- a/cli/src/commands/help/environment/environment.ts +++ b/cli/src/commands/help/environment/environment.ts @@ -1,4 +1,4 @@ -import { ENV_REGISTRY } from '../../../env/registry.js' +import { ENV_REGISTRY } from '@/env/registry' export function runHelpEnvironment(): string { let out = 'ENVIRONMENT VARIABLES\n\n' diff --git a/cli/src/commands/help/environment/index.ts b/cli/src/commands/help/environment/index.ts index 0dfadf9d2f..8856dd7748 100644 --- a/cli/src/commands/help/environment/index.ts +++ b/cli/src/commands/help/environment/index.ts @@ -1,6 +1,6 @@ -import { raw } from '../../../framework/output.js' -import { DifyCommand } from '../../_shared/dify-command.js' -import { runHelpEnvironment } from './environment.js' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { raw } from '@/framework/output' +import { runHelpEnvironment } from './environment' export default class HelpEnvironment extends DifyCommand { static override description = 'Long-form documentation for every DIFY_* env var' diff --git a/cli/src/commands/help/external/external.test.ts b/cli/src/commands/help/external/external.test.ts index 9925fc6c76..31025c4c55 100644 --- a/cli/src/commands/help/external/external.test.ts +++ b/cli/src/commands/help/external/external.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { runHelpExternal } from './external.js' +import { runHelpExternal } from './external' describe('runHelpExternal', () => { it('mentions external bearer prefix and login flag', () => { diff --git a/cli/src/commands/help/external/index.ts b/cli/src/commands/help/external/index.ts index 8b52520eb3..6b5a731102 100644 --- a/cli/src/commands/help/external/index.ts +++ b/cli/src/commands/help/external/index.ts @@ -1,6 +1,6 @@ -import { raw } from '../../../framework/output.js' -import { DifyCommand } from '../../_shared/dify-command.js' -import { runHelpExternal } from './external.js' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { raw } from '@/framework/output' +import { runHelpExternal } from './external' export default class HelpExternal extends DifyCommand { static override description = 'Agent-onboarding text for external-SSO bearers (dfoe_)' diff --git a/cli/src/commands/resume/app/index.ts b/cli/src/commands/resume/app/index.ts index 99ef349d7b..a0cb17500d 100644 --- a/cli/src/commands/resume/app/index.ts +++ b/cli/src/commands/resume/app/index.ts @@ -1,8 +1,8 @@ -import { Args, Flags } from '../../../framework/flags.js' -import { OutputFormat } from '../../../framework/output.js' -import { DifyCommand } from '../../_shared/dify-command.js' -import { httpRetryFlag } from '../../_shared/global-flags.js' -import { resumeApp } from './run.js' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { httpRetryFlag } from '@/commands/_shared/global-flags' +import { Args, Flags } from '@/framework/flags' +import { OutputFormat } from '@/framework/output' +import { resumeApp } from './run' export default class ResumeApp extends DifyCommand { static override description = 'Resume a paused workflow app after submitting a human input form' diff --git a/cli/src/commands/resume/app/run.ts b/cli/src/commands/resume/app/run.ts index bcd109b21f..972a6f1e8e 100644 --- a/cli/src/commands/resume/app/run.ts +++ b/cli/src/commands/resume/app/run.ts @@ -1,18 +1,18 @@ import type { KyInstance } from 'ky' -import type { HostsBundle } from '../../../auth/hosts.js' -import type { AppInfoCache } from '../../../cache/app-info.js' -import type { IOStreams } from '../../../sys/io/streams' -import type { RunContext } from '../../run/app/_strategies/index.js' -import { AppMetaClient } from '../../../api/app-meta.js' -import { AppRunClient } from '../../../api/app-run.js' -import { AppsClient } from '../../../api/apps.js' -import { getEnv, processExit } from '../../../sys/index.js' -import { colorEnabled, colorScheme } from '../../../sys/io/color.js' -import { FieldInfo } from '../../../types/app-meta.js' -import { resolveWorkspaceId } from '../../../workspace/resolver.js' -import { pickStrategy } from '../../run/app/_strategies/index.js' -import { RUN_MODES } from '../../run/app/handlers.js' -import { AppRunPrintFlags } from '../../run/app/print-flags.js' +import type { HostsBundle } from '@/auth/hosts' +import type { AppInfoCache } from '@/cache/app-info' +import type { RunContext } from '@/commands/run/app/_strategies/index' +import type { IOStreams } from '@/sys/io/streams' +import { AppMetaClient } from '@/api/app-meta' +import { AppRunClient } from '@/api/app-run' +import { AppsClient } from '@/api/apps' +import { pickStrategy } from '@/commands/run/app/_strategies/index' +import { RUN_MODES } from '@/commands/run/app/handlers' +import { AppRunPrintFlags } from '@/commands/run/app/print-flags' +import { getEnv, processExit } from '@/sys/index' +import { colorEnabled, colorScheme } from '@/sys/io/color' +import { FieldInfo } from '@/types/app-meta' +import { resolveWorkspaceId } from '@/workspace/resolver' export type ResumeAppOptions = { readonly appId: string diff --git a/cli/src/commands/run/app/_strategies/index.ts b/cli/src/commands/run/app/_strategies/index.ts index 1e7c9895e3..dc4b2326e6 100644 --- a/cli/src/commands/run/app/_strategies/index.ts +++ b/cli/src/commands/run/app/_strategies/index.ts @@ -1,8 +1,8 @@ -import type { AppRunClient } from '../../../../api/app-run.js' -import type { AppRunPrintFlags } from '../print-flags.js' -import type { RunAppDeps, RunAppOptions } from '../run.js' -import { StreamingStructuredStrategy } from './streaming-structured.js' -import { StreamingTextStrategy } from './streaming-text.js' +import type { AppRunClient } from '@/api/app-run' +import type { AppRunPrintFlags } from '@/commands/run/app/print-flags' +import type { RunAppDeps, RunAppOptions } from '@/commands/run/app/run' +import { StreamingStructuredStrategy } from './streaming-structured' +import { StreamingTextStrategy } from './streaming-text' export type RunContext = { readonly opts: RunAppOptions & { inputs: Record } diff --git a/cli/src/commands/run/app/_strategies/streaming-structured.ts b/cli/src/commands/run/app/_strategies/streaming-structured.ts index b59550ca6c..d19884cdf3 100644 --- a/cli/src/commands/run/app/_strategies/streaming-structured.ts +++ b/cli/src/commands/run/app/_strategies/streaming-structured.ts @@ -1,12 +1,12 @@ -import type { SseEvent } from '../../../../http/sse.js' -import type { RunContext, RunStrategy } from './index.js' -import { buildRunBody } from '../../../../api/app-run.js' -import { colorEnabled, colorScheme } from '../../../../sys/io/color.js' -import { startSpinner } from '../../../../sys/io/spinner.js' -import { extractThinkBlocks, stripThinkBlocks } from '../../../../sys/io/think-filter.js' -import { chatConversationHint, newAppRunObject, RUN_MODES } from '../handlers.js' -import { renderHitlHint, renderHitlOutput } from '../hitl-render.js' -import { collect, HitlPauseError } from '../sse-collector.js' +import type { RunContext, RunStrategy } from './index' +import type { SseEvent } from '@/http/sse' +import { buildRunBody } from '@/api/app-run' +import { chatConversationHint, newAppRunObject, RUN_MODES } from '@/commands/run/app/handlers' +import { renderHitlHint, renderHitlOutput } from '@/commands/run/app/hitl-render' +import { collect, HitlPauseError } from '@/commands/run/app/sse-collector' +import { colorEnabled, colorScheme } from '@/sys/io/color' +import { startSpinner } from '@/sys/io/spinner' +import { extractThinkBlocks, stripThinkBlocks } from '@/sys/io/think-filter' const CHAT_MODES: ReadonlySet = new Set([RUN_MODES.Chat, RUN_MODES.AgentChat, RUN_MODES.AdvancedChat]) diff --git a/cli/src/commands/run/app/_strategies/streaming-text.ts b/cli/src/commands/run/app/_strategies/streaming-text.ts index 6f88e394dd..49bf31eee6 100644 --- a/cli/src/commands/run/app/_strategies/streaming-text.ts +++ b/cli/src/commands/run/app/_strategies/streaming-text.ts @@ -1,8 +1,8 @@ -import type { RunContext, RunStrategy } from './index.js' -import { buildRunBody } from '../../../../api/app-run.js' -import { handle, unhandle } from '../../../../sys/index.js' -import { renderHitlHint, renderHitlOutput } from '../hitl-render.js' -import { decodeStreamError, HitlPauseError } from '../sse-collector.js' +import type { RunContext, RunStrategy } from './index' +import { buildRunBody } from '@/api/app-run' +import { renderHitlHint, renderHitlOutput } from '@/commands/run/app/hitl-render' +import { decodeStreamError, HitlPauseError } from '@/commands/run/app/sse-collector' +import { handle, unhandle } from '@/sys/index' export class StreamingTextStrategy implements RunStrategy { async execute(ctx: RunContext): Promise { diff --git a/cli/src/commands/run/app/agent-guide.test.ts b/cli/src/commands/run/app/agent-guide.test.ts index 454d9eecbb..82ee99c671 100644 --- a/cli/src/commands/run/app/agent-guide.test.ts +++ b/cli/src/commands/run/app/agent-guide.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import RunApp from './index.js' +import RunApp from './index' describe('run app agentGuide', () => { it('exposes non-empty agentGuide string', () => { diff --git a/cli/src/commands/run/app/file-flags.test.ts b/cli/src/commands/run/app/file-flags.test.ts index 87babdedec..60d11caf69 100644 --- a/cli/src/commands/run/app/file-flags.test.ts +++ b/cli/src/commands/run/app/file-flags.test.ts @@ -1,6 +1,6 @@ -import type { ParsedFileFlag } from './file-flags.js' +import type { ParsedFileFlag } from './file-flags' import { describe, expect, it, vi } from 'vitest' -import { difyFileType, parseFileFlag, resolveFileInputs } from './file-flags.js' +import { difyFileType, parseFileFlag, resolveFileInputs } from './file-flags' describe('parseFileFlag', () => { it('parses local file with @ prefix', () => { diff --git a/cli/src/commands/run/app/file-flags.ts b/cli/src/commands/run/app/file-flags.ts index 6fbb17e303..ea689f8c77 100644 --- a/cli/src/commands/run/app/file-flags.ts +++ b/cli/src/commands/run/app/file-flags.ts @@ -1,6 +1,6 @@ import { basename } from 'node:path' -import { BaseError } from '../../../errors/base.js' -import { ErrorCode } from '../../../errors/codes.js' +import { BaseError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' export type ParsedFileFlag = | { varname: string, kind: 'local', path: string } diff --git a/cli/src/commands/run/app/handlers.ts b/cli/src/commands/run/app/handlers.ts index b22bfec58d..c8c2055433 100644 --- a/cli/src/commands/run/app/handlers.ts +++ b/cli/src/commands/run/app/handlers.ts @@ -1,5 +1,5 @@ -import type { TextHandler } from '../../../printers/format-text.js' -import type { ColorScheme } from '../../../sys/io/color.js' +import type { TextHandler } from '@/printers/format-text' +import type { ColorScheme } from '@/sys/io/color' export const RUN_MODES = { Chat: 'chat', diff --git a/cli/src/commands/run/app/hitl-render.ts b/cli/src/commands/run/app/hitl-render.ts index da02ecf5cb..991c63e111 100644 --- a/cli/src/commands/run/app/hitl-render.ts +++ b/cli/src/commands/run/app/hitl-render.ts @@ -1,5 +1,5 @@ -import type { HitlPausePayload } from './sse-collector.js' -import { colorEnabled, colorScheme } from '../../../sys/io/color.js' +import type { HitlPausePayload } from './sse-collector' +import { colorEnabled, colorScheme } from '@/sys/io/color' export type HitlExitObject = { status: 'paused' diff --git a/cli/src/commands/run/app/index.ts b/cli/src/commands/run/app/index.ts index 77a55cf5b0..6466bf16cf 100644 --- a/cli/src/commands/run/app/index.ts +++ b/cli/src/commands/run/app/index.ts @@ -1,9 +1,9 @@ -import { Args, Flags } from '../../../framework/flags.js' -import { OutputFormat } from '../../../framework/output.js' -import { DifyCommand } from '../../_shared/dify-command.js' -import { httpRetryFlag } from '../../_shared/global-flags.js' -import { agentGuide } from './guide.js' -import { runApp } from './run.js' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { httpRetryFlag } from '@/commands/_shared/global-flags' +import { Args, Flags } from '@/framework/flags' +import { OutputFormat } from '@/framework/output' +import { agentGuide } from './guide' +import { runApp } from './run' export default class RunApp extends DifyCommand { static override description = 'Run an app and print the response' diff --git a/cli/src/commands/run/app/print-flags.ts b/cli/src/commands/run/app/print-flags.ts index a90d7b8f8c..a3712ca980 100644 --- a/cli/src/commands/run/app/print-flags.ts +++ b/cli/src/commands/run/app/print-flags.ts @@ -1,10 +1,10 @@ -import type { PrintFlags } from '../../../printers/printer.js' -import type { StreamPrinter } from '../../../printers/stream-printer.js' -import { JsonYamlPrintFlags } from '../../../printers/format-json-yaml.js' -import { TextPrintFlags } from '../../../printers/format-text.js' -import { CompositePrintFlags } from '../../../printers/printer.js' -import { chatTextHandler, completionTextHandler, RUN_MODES, workflowTextHandler } from './handlers.js' -import { streamPrinterFor } from './stream-handlers.js' +import type { PrintFlags } from '@/printers/printer' +import type { StreamPrinter } from '@/printers/stream-printer' +import { JsonYamlPrintFlags } from '@/printers/format-json-yaml' +import { TextPrintFlags } from '@/printers/format-text' +import { CompositePrintFlags } from '@/printers/printer' +import { chatTextHandler, completionTextHandler, RUN_MODES, workflowTextHandler } from './handlers' +import { streamPrinterFor } from './stream-handlers' export class AppRunPrintFlags extends CompositePrintFlags { private readonly jsonYaml = new JsonYamlPrintFlags() diff --git a/cli/src/commands/run/app/run.test.ts b/cli/src/commands/run/app/run.test.ts index 55bfb6448f..a9bc41571a 100644 --- a/cli/src/commands/run/app/run.test.ts +++ b/cli/src/commands/run/app/run.test.ts @@ -1,17 +1,17 @@ -import type { DifyMock } from '../../../../test/fixtures/dify-mock/server.js' -import type { HostsBundle } from '../../../auth/hosts.js' +import type { DifyMock } from '@test/fixtures/dify-mock/server' +import type { HostsBundle } from '@/auth/hosts' import { mkdtemp, rm } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' +import { startMock } from '@test/fixtures/dify-mock/server' import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { startMock } from '../../../../test/fixtures/dify-mock/server.js' -import { loadAppInfoCache } from '../../../cache/app-info.js' -import { createClient } from '../../../http/client.js' -import { ENV_CACHE_DIR } from '../../../store/dir.js' -import { CACHE_APP_INFO, getCache } from '../../../store/manager.js' -import { bufferStreams } from '../../../sys/io/streams' -import { resumeApp } from '../../resume/app/run.js' -import { runApp } from './run.js' +import { loadAppInfoCache } from '@/cache/app-info' +import { resumeApp } from '@/commands/resume/app/run' +import { createClient } from '@/http/client' +import { ENV_CACHE_DIR } from '@/store/dir' +import { CACHE_APP_INFO, getCache } from '@/store/manager' +import { bufferStreams } from '@/sys/io/streams' +import { runApp } from './run' function bundle(): HostsBundle { return { diff --git a/cli/src/commands/run/app/run.ts b/cli/src/commands/run/app/run.ts index eb9a2e4d53..ca529e0728 100644 --- a/cli/src/commands/run/app/run.ts +++ b/cli/src/commands/run/app/run.ts @@ -1,20 +1,20 @@ import type { KyInstance } from 'ky' -import type { HostsBundle } from '../../../auth/hosts.js' -import type { AppInfoCache } from '../../../cache/app-info.js' -import type { IOStreams } from '../../../sys/io/streams' -import { AppMetaClient } from '../../../api/app-meta.js' -import { AppRunClient } from '../../../api/app-run.js' -import { AppsClient } from '../../../api/apps.js' -import { FileUploadClient } from '../../../api/file-upload.js' -import { BaseError } from '../../../errors/base.js' -import { ErrorCode } from '../../../errors/codes.js' -import { getEnv, processExit } from '../../../sys/index.js' -import { FieldInfo } from '../../../types/app-meta.js' -import { resolveWorkspaceId } from '../../../workspace/resolver.js' -import { pickStrategy } from './_strategies/index.js' -import { resolveFileInputs } from './file-flags.js' -import { RUN_MODES } from './handlers.js' -import { AppRunPrintFlags } from './print-flags.js' +import type { HostsBundle } from '@/auth/hosts' +import type { AppInfoCache } from '@/cache/app-info' +import type { IOStreams } from '@/sys/io/streams' +import { AppMetaClient } from '@/api/app-meta' +import { AppRunClient } from '@/api/app-run' +import { AppsClient } from '@/api/apps' +import { FileUploadClient } from '@/api/file-upload' +import { pickStrategy } from '@/commands/run/app/_strategies/index' +import { BaseError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' +import { getEnv, processExit } from '@/sys/index' +import { FieldInfo } from '@/types/app-meta' +import { resolveWorkspaceId } from '@/workspace/resolver' +import { resolveFileInputs } from './file-flags' +import { RUN_MODES } from './handlers' +import { AppRunPrintFlags } from './print-flags' export type RunAppOptions = { readonly appId: string diff --git a/cli/src/commands/run/app/sse-collector.test.ts b/cli/src/commands/run/app/sse-collector.test.ts index e158599145..f724c83702 100644 --- a/cli/src/commands/run/app/sse-collector.test.ts +++ b/cli/src/commands/run/app/sse-collector.test.ts @@ -1,6 +1,6 @@ -import type { SseEvent } from '../../../http/sse.js' +import type { SseEvent } from '@/http/sse' import { describe, expect, it } from 'vitest' -import { collect, collectorFor, decodeStreamError, HitlPauseError } from './sse-collector.js' +import { collect, collectorFor, decodeStreamError, HitlPauseError } from './sse-collector' const enc = new TextEncoder() function ev(name: string, data: object): SseEvent { diff --git a/cli/src/commands/run/app/sse-collector.ts b/cli/src/commands/run/app/sse-collector.ts index d7a645227e..973a717746 100644 --- a/cli/src/commands/run/app/sse-collector.ts +++ b/cli/src/commands/run/app/sse-collector.ts @@ -1,8 +1,8 @@ -import type { BaseError } from '../../../errors/base.js' -import type { SseEvent } from '../../../http/sse.js' -import { newError } from '../../../errors/base.js' -import { ErrorCode } from '../../../errors/codes.js' -import { RUN_MODES } from './handlers.js' +import type { BaseError } from '@/errors/base' +import type { SseEvent } from '@/http/sse' +import { newError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' +import { RUN_MODES } from './handlers' export type HitlPauseData = { form_id: string diff --git a/cli/src/commands/run/app/stream-handlers.test.ts b/cli/src/commands/run/app/stream-handlers.test.ts index fc584e1176..885b059abf 100644 --- a/cli/src/commands/run/app/stream-handlers.test.ts +++ b/cli/src/commands/run/app/stream-handlers.test.ts @@ -1,9 +1,9 @@ -import type { SseEvent } from '../../../http/sse.js' +import type { SseEvent } from '@/http/sse' import { Buffer } from 'node:buffer' import { PassThrough, Writable } from 'node:stream' import { describe, expect, it } from 'vitest' -import { HitlPauseError } from './sse-collector.js' -import { streamPrinterFor } from './stream-handlers.js' +import { HitlPauseError } from './sse-collector' +import { streamPrinterFor } from './stream-handlers' const enc = new TextEncoder() function ev(name: string, data: object): SseEvent { diff --git a/cli/src/commands/run/app/stream-handlers.ts b/cli/src/commands/run/app/stream-handlers.ts index 53dc746602..799bcf7fcd 100644 --- a/cli/src/commands/run/app/stream-handlers.ts +++ b/cli/src/commands/run/app/stream-handlers.ts @@ -1,12 +1,12 @@ -import type { SseEvent } from '../../../http/sse.js' -import type { StreamPrinter } from '../../../printers/stream-printer.js' -import type { HitlPausePayload } from './sse-collector.js' -import { newError } from '../../../errors/base.js' -import { ErrorCode } from '../../../errors/codes.js' -import { colorEnabled, colorScheme } from '../../../sys/io/color.js' -import { ThinkChunkFilter } from '../../../sys/io/think-filter.js' -import { RUN_MODES } from './handlers.js' -import { HitlPauseError } from './sse-collector.js' +import type { HitlPausePayload } from './sse-collector' +import type { SseEvent } from '@/http/sse' +import type { StreamPrinter } from '@/printers/stream-printer' +import { newError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' +import { colorEnabled, colorScheme } from '@/sys/io/color' +import { ThinkChunkFilter } from '@/sys/io/think-filter' +import { RUN_MODES } from './handlers' +import { HitlPauseError } from './sse-collector' const dec = new TextDecoder() diff --git a/cli/src/commands/set/member/index.ts b/cli/src/commands/set/member/index.ts index f9ffdb286c..5fe4782359 100644 --- a/cli/src/commands/set/member/index.ts +++ b/cli/src/commands/set/member/index.ts @@ -1,8 +1,8 @@ -import { Args, Flags } from '../../../framework/flags.js' -import { formatted, OutputFormat } from '../../../framework/output.js' -import { DifyCommand } from '../../_shared/dify-command.js' -import { httpRetryFlag } from '../../_shared/global-flags.js' -import { runSetMember } from './run.js' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { httpRetryFlag } from '@/commands/_shared/global-flags' +import { Args, Flags } from '@/framework/flags' +import { formatted, OutputFormat } from '@/framework/output' +import { runSetMember } from './run' export default class SetMember extends DifyCommand { static override description = 'Change a member\'s role in the active (or specified) workspace' diff --git a/cli/src/commands/set/member/run.test.ts b/cli/src/commands/set/member/run.test.ts index ff987b815f..4541fddb94 100644 --- a/cli/src/commands/set/member/run.test.ts +++ b/cli/src/commands/set/member/run.test.ts @@ -1,8 +1,8 @@ import type { KyInstance } from 'ky' -import type { HostsBundle } from '../../../auth/hosts.js' +import type { HostsBundle } from '@/auth/hosts' import { describe, expect, it, vi } from 'vitest' -import { bufferStreams } from '../../../sys/io/streams' -import { runSetMember } from './run.js' +import { bufferStreams } from '@/sys/io/streams' +import { runSetMember } from './run' function bundle(): HostsBundle { return { diff --git a/cli/src/commands/set/member/run.ts b/cli/src/commands/set/member/run.ts index f77e09d4e6..0236a1ea77 100644 --- a/cli/src/commands/set/member/run.ts +++ b/cli/src/commands/set/member/run.ts @@ -1,14 +1,14 @@ import type { KyInstance } from 'ky' -import type { HostsBundle } from '../../../auth/hosts.js' -import type { IOStreams } from '../../../sys/io/streams.js' -import { MembersClient } from '../../../api/members.js' -import { BaseError } from '../../../errors/base.js' -import { ErrorCode } from '../../../errors/codes.js' -import { colorEnabled, colorScheme } from '../../../sys/io/color.js' -import { runWithSpinner } from '../../../sys/io/spinner.js' -import { nullStreams } from '../../../sys/io/streams.js' -import { resolveWorkspaceId } from '../../../workspace/resolver.js' -import { SetMemberOutput } from './handlers.js' +import type { HostsBundle } from '@/auth/hosts' +import type { IOStreams } from '@/sys/io/streams' +import { MembersClient } from '@/api/members' +import { BaseError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' +import { colorEnabled, colorScheme } from '@/sys/io/color' +import { runWithSpinner } from '@/sys/io/spinner' +import { nullStreams } from '@/sys/io/streams' +import { resolveWorkspaceId } from '@/workspace/resolver' +import { SetMemberOutput } from './handlers' export type SetMemberOptions = { readonly memberId: string diff --git a/cli/src/commands/tree.generated.ts b/cli/src/commands/tree.generated.ts index 51a77d1a99..9ba4fe1192 100644 --- a/cli/src/commands/tree.generated.ts +++ b/cli/src/commands/tree.generated.ts @@ -1,33 +1,33 @@ // @generated by scripts/generate-command-tree.ts — DO NOT EDIT. // Regenerate via `pnpm tree:gen`. Drift gated by `pnpm tree:check` in CI. -import type { CommandTree } from '../framework/registry.js' -import AuthDevicesList from './auth/devices/list/index.js' -import AuthDevicesRevoke from './auth/devices/revoke/index.js' -import AuthLogin from './auth/login/index.js' -import AuthLogout from './auth/logout/index.js' -import AuthStatus from './auth/status/index.js' -import AuthWhoami from './auth/whoami/index.js' -import ConfigGet from './config/get/index.js' -import ConfigPath from './config/path/index.js' -import ConfigSet from './config/set/index.js' -import ConfigUnset from './config/unset/index.js' -import ConfigView from './config/view/index.js' -import CreateMember from './create/member/index.js' -import DeleteMember from './delete/member/index.js' -import DescribeApp from './describe/app/index.js' -import EnvList from './env/list/index.js' -import GetApp from './get/app/index.js' -import GetMember from './get/member/index.js' -import GetWorkspace from './get/workspace/index.js' -import HelpAccount from './help/account/index.js' -import HelpEnvironment from './help/environment/index.js' -import HelpExternal from './help/external/index.js' -import ResumeApp from './resume/app/index.js' -import RunApp from './run/app/index.js' -import SetMember from './set/member/index.js' -import UseWorkspace from './use/workspace/index.js' -import Version from './version/index.js' +import type { CommandTree } from '@/framework/registry' +import AuthDevicesList from '@/commands/auth/devices/list/index' +import AuthDevicesRevoke from '@/commands/auth/devices/revoke/index' +import AuthLogin from '@/commands/auth/login/index' +import AuthLogout from '@/commands/auth/logout/index' +import AuthStatus from '@/commands/auth/status/index' +import AuthWhoami from '@/commands/auth/whoami/index' +import ConfigGet from '@/commands/config/get/index' +import ConfigPath from '@/commands/config/path/index' +import ConfigSet from '@/commands/config/set/index' +import ConfigUnset from '@/commands/config/unset/index' +import ConfigView from '@/commands/config/view/index' +import CreateMember from '@/commands/create/member/index' +import DeleteMember from '@/commands/delete/member/index' +import DescribeApp from '@/commands/describe/app/index' +import EnvList from '@/commands/env/list/index' +import GetApp from '@/commands/get/app/index' +import GetMember from '@/commands/get/member/index' +import GetWorkspace from '@/commands/get/workspace/index' +import HelpAccount from '@/commands/help/account/index' +import HelpEnvironment from '@/commands/help/environment/index' +import HelpExternal from '@/commands/help/external/index' +import ResumeApp from '@/commands/resume/app/index' +import RunApp from '@/commands/run/app/index' +import SetMember from '@/commands/set/member/index' +import UseWorkspace from '@/commands/use/workspace/index' +import Version from '@/commands/version/index' export const commandTree: CommandTree = { auth: { diff --git a/cli/src/commands/tree.ts b/cli/src/commands/tree.ts index 14a480033f..6be515f1f7 100644 --- a/cli/src/commands/tree.ts +++ b/cli/src/commands/tree.ts @@ -1 +1 @@ -export { commandTree } from './tree.generated.js' +export { commandTree } from './tree.generated' diff --git a/cli/src/commands/use/workspace/index.ts b/cli/src/commands/use/workspace/index.ts index 4b44472f88..b55fc6179f 100644 --- a/cli/src/commands/use/workspace/index.ts +++ b/cli/src/commands/use/workspace/index.ts @@ -1,7 +1,7 @@ -import { Args } from '../../../framework/flags.js' -import { DifyCommand } from '../../_shared/dify-command.js' -import { httpRetryFlag } from '../../_shared/global-flags.js' -import { runUseWorkspace } from './use.js' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { httpRetryFlag } from '@/commands/_shared/global-flags' +import { Args } from '@/framework/flags' +import { runUseWorkspace } from './use' export default class UseWorkspace extends DifyCommand { static override description = 'Switch the active workspace on the server and refresh hosts.yml' diff --git a/cli/src/commands/use/workspace/use.test.ts b/cli/src/commands/use/workspace/use.test.ts index 125d1a18fd..a26d1eba61 100644 --- a/cli/src/commands/use/workspace/use.test.ts +++ b/cli/src/commands/use/workspace/use.test.ts @@ -3,15 +3,15 @@ import type { WorkspaceListResponse, } from '@dify/contracts/api/openapi/types.gen' import type { KyInstance } from 'ky' -import type { HostsBundle } from '../../../auth/hosts.js' +import type { HostsBundle } from '@/auth/hosts' import { mkdtemp, rm } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import { loadHosts, saveHosts } from '../../../auth/hosts.js' -import { ENV_CONFIG_DIR } from '../../../store/dir.js' -import { bufferStreams } from '../../../sys/io/streams.js' -import { runUseWorkspace } from './use.js' +import { loadHosts, saveHosts } from '@/auth/hosts' +import { ENV_CONFIG_DIR } from '@/store/dir' +import { bufferStreams } from '@/sys/io/streams' +import { runUseWorkspace } from './use' function bundle(): HostsBundle { return { diff --git a/cli/src/commands/use/workspace/use.ts b/cli/src/commands/use/workspace/use.ts index db7a539a38..c847b71c71 100644 --- a/cli/src/commands/use/workspace/use.ts +++ b/cli/src/commands/use/workspace/use.ts @@ -1,12 +1,12 @@ import type { KyInstance } from 'ky' -import type { HostsBundle, Workspace } from '../../../auth/hosts.js' -import type { IOStreams } from '../../../sys/io/streams.js' -import { WorkspacesClient } from '../../../api/workspaces.js' -import { saveHosts } from '../../../auth/hosts.js' -import { BaseError } from '../../../errors/base.js' -import { ErrorCode } from '../../../errors/codes.js' -import { colorEnabled, colorScheme } from '../../../sys/io/color.js' -import { runWithSpinner } from '../../../sys/io/spinner.js' +import type { HostsBundle, Workspace } from '@/auth/hosts' +import type { IOStreams } from '@/sys/io/streams' +import { WorkspacesClient } from '@/api/workspaces' +import { saveHosts } from '@/auth/hosts' +import { BaseError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' +import { colorEnabled, colorScheme } from '@/sys/io/color' +import { runWithSpinner } from '@/sys/io/spinner' export type UseWorkspaceOptions = { readonly workspaceId: string diff --git a/cli/src/commands/version/index.ts b/cli/src/commands/version/index.ts index 884824d232..7a533f71db 100644 --- a/cli/src/commands/version/index.ts +++ b/cli/src/commands/version/index.ts @@ -1,11 +1,11 @@ -import { Flags } from '../../framework/flags.js' -import { formatted, OutputFormat, raw, stringifyOutput } from '../../framework/output.js' -import { colorEnabled } from '../../sys/io/color.js' -import { realStreams } from '../../sys/io/streams' -import { versionInfo } from '../../version/info.js' -import { runVersionProbe } from '../../version/probe.js' -import { renderVersionText } from '../../version/render.js' -import { DifyCommand } from '../_shared/dify-command.js' +import { DifyCommand } from '@/commands/_shared/dify-command' +import { Flags } from '@/framework/flags' +import { formatted, OutputFormat, raw, stringifyOutput } from '@/framework/output' +import { colorEnabled } from '@/sys/io/color' +import { realStreams } from '@/sys/io/streams' +import { versionInfo } from '@/version/info' +import { runVersionProbe } from '@/version/probe' +import { renderVersionText } from '@/version/render' export const COMPAT_FAIL_EXIT_CODE = 64 diff --git a/cli/src/commands/version/version.test.ts b/cli/src/commands/version/version.test.ts index afd2346478..affa01c959 100644 --- a/cli/src/commands/version/version.test.ts +++ b/cli/src/commands/version/version.test.ts @@ -1,7 +1,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import * as info from '../../version/info.js' -import * as probe from '../../version/probe.js' -import Version, { COMPAT_FAIL_EXIT_CODE } from './index.js' +import * as info from '@/version/info' +import * as probe from '@/version/probe' +import Version, { COMPAT_FAIL_EXIT_CODE } from './index' function fakeReport(overrides: { channel?: probe.VersionReport['client']['channel'] @@ -101,7 +101,7 @@ describe('Version command', () => { expect(spy).toHaveBeenCalledWith({ skipServer: true }) }) - function stubProcessExit(): ReturnType> { + function stubProcessExit() { const impl = (() => { throw new Error('__exit__') }) as never diff --git a/cli/src/config/config-loader.test.ts b/cli/src/config/config-loader.test.ts index 53c63fe0b8..501010cabd 100644 --- a/cli/src/config/config-loader.test.ts +++ b/cli/src/config/config-loader.test.ts @@ -1,12 +1,12 @@ -import type { YamlStore } from '../store/store' +import type { YamlStore } from '@/store/store' import { mkdtemp, rm } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { isBaseError } from '../errors/base' -import { ErrorCode } from '../errors/codes' -import { ENV_CONFIG_DIR } from '../store/dir' -import { getConfigurationStore } from '../store/manager' +import { isBaseError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' +import { ENV_CONFIG_DIR } from '@/store/dir' +import { getConfigurationStore } from '@/store/manager' import { loadConfig } from './config-loader' describe('loadConfig', () => { diff --git a/cli/src/config/config-loader.ts b/cli/src/config/config-loader.ts index c260d49d8e..cd2d360105 100644 --- a/cli/src/config/config-loader.ts +++ b/cli/src/config/config-loader.ts @@ -1,7 +1,7 @@ -import type { YamlStore } from '../store/store' import type { ConfigFile } from './schema' -import { newError } from '../errors/base' -import { ErrorCode } from '../errors/codes' +import type { YamlStore } from '@/store/store' +import { newError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' import { ConfigFileSchema, CURRENT_SCHEMA_VERSION } from './schema' export type LoadResult diff --git a/cli/src/config/keys.test.ts b/cli/src/config/keys.test.ts index 15a7aed72d..2f2be680c1 100644 --- a/cli/src/config/keys.test.ts +++ b/cli/src/config/keys.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { isBaseError } from '../errors/base.js' -import { ErrorCode } from '../errors/codes.js' +import { isBaseError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' import { getKey, knownKeyNames, @@ -8,8 +8,8 @@ import { lookupKey, setKey, unsetKey, -} from './keys.js' -import { emptyConfig } from './schema.js' +} from './keys' +import { emptyConfig } from './schema' describe('config keys', () => { it('exposes the v1.0 key set: defaults.format, defaults.limit, state.current_app', () => { diff --git a/cli/src/config/keys.ts b/cli/src/config/keys.ts index 4d719b1c4c..035b2697ab 100644 --- a/cli/src/config/keys.ts +++ b/cli/src/config/keys.ts @@ -1,8 +1,8 @@ -import type { AllowedFormat, ConfigFile } from './schema.js' -import { newError } from '../errors/base.js' -import { ErrorCode } from '../errors/codes.js' -import { parseLimit } from '../limit/limit.js' -import { ALLOWED_FORMATS } from './schema.js' +import type { AllowedFormat, ConfigFile } from './schema' +import { newError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' +import { parseLimit } from '@/limit/limit' +import { ALLOWED_FORMATS } from './schema' export type KeySpec = { readonly name: string diff --git a/cli/src/config/schema.test.ts b/cli/src/config/schema.test.ts index 549fab3622..c318948635 100644 --- a/cli/src/config/schema.test.ts +++ b/cli/src/config/schema.test.ts @@ -1,11 +1,11 @@ import { describe, expect, it } from 'vitest' -import { CONFIG_FILE_NAME } from '../store/manager.js' +import { CONFIG_FILE_NAME } from '@/store/manager' import { ALLOWED_FORMATS, ConfigFileSchema, CURRENT_SCHEMA_VERSION, emptyConfig, -} from './schema.js' +} from './schema' describe('config schema', () => { it('CURRENT_SCHEMA_VERSION is 1', () => { diff --git a/cli/src/env/registry.test.ts b/cli/src/env/registry.test.ts index 5ea4726d6f..9b89695b4c 100644 --- a/cli/src/env/registry.test.ts +++ b/cli/src/env/registry.test.ts @@ -4,7 +4,7 @@ import { getEnv, lookupEnv, resolveEnv, -} from './registry.js' +} from './registry' describe('env registry', () => { it('contains every DIFY_* var from the v1.0 spec', () => { diff --git a/cli/src/env/registry.ts b/cli/src/env/registry.ts index 7e257364ee..a567bf01cb 100644 --- a/cli/src/env/registry.ts +++ b/cli/src/env/registry.ts @@ -1,5 +1,5 @@ -import { parseLimit } from '../limit/limit.js' -import { getEnv } from '../sys/index.js' +import { parseLimit } from '@/limit/limit' +import { getEnv } from '@/sys/index' export type EnvVar = { readonly name: string diff --git a/cli/src/errors/base.test.ts b/cli/src/errors/base.test.ts index 196646fae4..beb6a6296c 100644 --- a/cli/src/errors/base.test.ts +++ b/cli/src/errors/base.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { BaseError, isBaseError, newError, unknownError } from './base.js' -import { ErrorCode, ExitCode } from './codes.js' +import { BaseError, isBaseError, newError, unknownError } from './base' +import { ErrorCode, ExitCode } from './codes' describe('BaseError', () => { it('captures code, message, optional fields', () => { diff --git a/cli/src/errors/base.ts b/cli/src/errors/base.ts index 3ec8b6e44f..64baead260 100644 --- a/cli/src/errors/base.ts +++ b/cli/src/errors/base.ts @@ -1,5 +1,5 @@ -import type { ErrorCodeValue, ExitCodeValue } from './codes.js' -import { ErrorCode, exitFor } from './codes.js' +import type { ErrorCodeValue, ExitCodeValue } from './codes' +import { ErrorCode, exitFor } from './codes' export type BaseErrorOptions = { readonly code: ErrorCodeValue diff --git a/cli/src/errors/codes.test.ts b/cli/src/errors/codes.test.ts index fcaf55e00a..ac59a3dbf7 100644 --- a/cli/src/errors/codes.test.ts +++ b/cli/src/errors/codes.test.ts @@ -5,7 +5,7 @@ import { ErrorCode, ExitCode, exitFor, -} from './codes.js' +} from './codes' describe('error codes', () => { it('has correct number codes (parity with internal/api/errors)', () => { diff --git a/cli/src/errors/envelope.test.ts b/cli/src/errors/envelope.test.ts index 8f736faa46..6fb7b85f76 100644 --- a/cli/src/errors/envelope.test.ts +++ b/cli/src/errors/envelope.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest' -import { newError } from './base.js' -import { ErrorCode } from './codes.js' -import { renderEnvelope, toEnvelope } from './envelope.js' +import { newError } from './base' +import { ErrorCode } from './codes' +import { renderEnvelope, toEnvelope } from './envelope' describe('error envelope', () => { it('emits required fields only when minimal', () => { diff --git a/cli/src/errors/envelope.ts b/cli/src/errors/envelope.ts index e817890606..b67e9d8945 100644 --- a/cli/src/errors/envelope.ts +++ b/cli/src/errors/envelope.ts @@ -1,4 +1,4 @@ -import type { BaseError } from './base.js' +import type { BaseError } from './base' export type ErrorEnvelope = { error: { diff --git a/cli/src/errors/format.ts b/cli/src/errors/format.ts index 4b80f08900..65eb8d4b90 100644 --- a/cli/src/errors/format.ts +++ b/cli/src/errors/format.ts @@ -1,6 +1,6 @@ -import type { BaseError } from './base.js' -import { colorEnabled, colorScheme } from '../sys/io/color.js' -import { renderEnvelope } from './envelope.js' +import type { BaseError } from './base' +import { colorEnabled, colorScheme } from '@/sys/io/color' +import { renderEnvelope } from './envelope' export type FormatErrorOptions = { readonly format?: string diff --git a/cli/src/framework/command-fs.test.ts b/cli/src/framework/command-fs.test.ts index 9d35746164..8c5d642378 100644 --- a/cli/src/framework/command-fs.test.ts +++ b/cli/src/framework/command-fs.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { isCommandIndexPath, isExcludedCommandPath } from './command-fs.js' +import { isCommandIndexPath, isExcludedCommandPath } from './command-fs' describe('isExcludedCommandPath', () => { it('excludes any path with an underscore-prefixed segment', () => { diff --git a/cli/src/framework/command.ts b/cli/src/framework/command.ts index be5d4a1ec3..ef898b966a 100644 --- a/cli/src/framework/command.ts +++ b/cli/src/framework/command.ts @@ -1,6 +1,6 @@ -import type { CommandOutput } from './output.js' -import type { ArgDefinition, FlagDefinition, ICommand, InferArgs, InferFlags, OptionalArgValueType } from './types.js' -import { parseArgv } from './flags.js' +import type { CommandOutput } from './output' +import type { ArgDefinition, FlagDefinition, ICommand, InferArgs, InferFlags, OptionalArgValueType } from './types' +import { parseArgv } from './flags' export type CommandConstructor = { new(): Command diff --git a/cli/src/framework/errors.test.ts b/cli/src/framework/errors.test.ts index 90b9061648..be54b87136 100644 --- a/cli/src/framework/errors.test.ts +++ b/cli/src/framework/errors.test.ts @@ -1,6 +1,6 @@ -import type { FlagDefinition } from './types.js' +import type { FlagDefinition } from './types' import { describe, expect, it } from 'vitest' -import { OutputFormatNotSupportedError, UnsupportedArgValueError } from './errors.js' +import { OutputFormatNotSupportedError, UnsupportedArgValueError } from './errors' describe('OutputFormatNotSupportedError', () => { it('states the offending format in the message', () => { diff --git a/cli/src/framework/errors.ts b/cli/src/framework/errors.ts index b1cb4e1c29..4f8a4c1c48 100644 --- a/cli/src/framework/errors.ts +++ b/cli/src/framework/errors.ts @@ -1,6 +1,6 @@ import type { FlagDefinition } from './types' -import { BaseError } from '../errors/base' -import { ErrorCode } from '../errors/codes' +import { BaseError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' export class OutputFormatNotSupportedError extends BaseError { constructor(format: string) { diff --git a/cli/src/framework/flags.test.ts b/cli/src/framework/flags.test.ts index c68d7733e4..1e0967dee8 100644 --- a/cli/src/framework/flags.test.ts +++ b/cli/src/framework/flags.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { UnsupportedArgValueError } from './errors.js' -import { Args, Flags, parseArgv } from './flags.js' +import { UnsupportedArgValueError } from './errors' +import { Args, Flags, parseArgv } from './flags' const meta = { flags: { diff --git a/cli/src/framework/flags.ts b/cli/src/framework/flags.ts index b730e0de9b..d3db72fbbf 100644 --- a/cli/src/framework/flags.ts +++ b/cli/src/framework/flags.ts @@ -1,5 +1,5 @@ -import type { ArgDefinition, CommandMeta, FlagDefinition, ParsedArgs, ParsedFlags } from './types.js' -import { UnsupportedArgValueError } from './errors.js' +import type { ArgDefinition, CommandMeta, FlagDefinition, ParsedArgs, ParsedFlags } from './types' +import { UnsupportedArgValueError } from './errors' function stringFlag { it('returns empty for empty argv', () => { diff --git a/cli/src/framework/run.ts b/cli/src/framework/run.ts index a8c56a604b..4305c2dc4e 100644 --- a/cli/src/framework/run.ts +++ b/cli/src/framework/run.ts @@ -1,9 +1,9 @@ -import type { CommandTree } from './registry.js' -import { BaseError } from '../errors/base.js' -import { formatErrorForCli } from '../errors/format.js' -import { formatHelp } from './help.js' -import { stringifyOutput } from './output.js' -import { findSuggestions, resolveCommand } from './registry.js' +import type { CommandTree } from './registry' +import { BaseError } from '@/errors/base' +import { formatErrorForCli } from '@/errors/format' +import { formatHelp } from './help' +import { stringifyOutput } from './output' +import { findSuggestions, resolveCommand } from './registry' export async function run(tree: CommandTree, argv: string[]): Promise { if (argv.length === 0 || argv[0] === 'help' || argv.includes('--help') || argv.includes('-h')) { diff --git a/cli/src/framework/types.ts b/cli/src/framework/types.ts index 62487c3622..0a7672a89c 100644 --- a/cli/src/framework/types.ts +++ b/cli/src/framework/types.ts @@ -1,4 +1,4 @@ -import type { CommandOutput } from './output.js' +import type { CommandOutput } from './output' export type ArgValueType = string | boolean | number | string[] export type OptionalArgValueType = ArgValueType | undefined diff --git a/cli/src/http/client.test.ts b/cli/src/http/client.test.ts index 580db2bf6d..6faa873a85 100644 --- a/cli/src/http/client.test.ts +++ b/cli/src/http/client.test.ts @@ -1,9 +1,9 @@ -import type { DifyMock } from '../../test/fixtures/dify-mock/server.js' +import type { DifyMock } from '@test/fixtures/dify-mock/server' +import { startMock } from '@test/fixtures/dify-mock/server' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import { startMock } from '../../test/fixtures/dify-mock/server.js' -import { isBaseError } from '../errors/base.js' -import { ErrorCode } from '../errors/codes.js' -import { createClient } from './client.js' +import { isBaseError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' +import { createClient } from './client' describe('http client', () => { let mock: DifyMock diff --git a/cli/src/http/client.ts b/cli/src/http/client.ts index 447b9d4649..2637870b0a 100644 --- a/cli/src/http/client.ts +++ b/cli/src/http/client.ts @@ -1,13 +1,13 @@ import type { AfterResponseHook, BeforeErrorHook, KyInstance } from 'ky' -import type { HttpFactoryOptions, HttpLogger } from './types.js' +import type { HttpFactoryOptions, HttpLogger } from './types' import ky from 'ky' -import { BaseError } from '../errors/base.js' -import { userAgent as defaultUserAgent } from '../version/info.js' -import { classifyResponse, classifyTransportError } from './error-mapper.js' -import { applyBearer } from './middleware/auth.js' -import { logBeforeRequest, logBeforeRetry } from './middleware/request-logger.js' -import { applyUserAgent } from './middleware/user-agent.js' -import { redactBearer } from './sanitize.js' +import { BaseError } from '@/errors/base' +import { applyBearer } from '@/http/middleware/auth' +import { logBeforeRequest, logBeforeRetry } from '@/http/middleware/request-logger' +import { applyUserAgent } from '@/http/middleware/user-agent' +import { userAgent as defaultUserAgent } from '@/version/info' +import { classifyResponse, classifyTransportError } from './error-mapper' +import { redactBearer } from './sanitize' export const DEFAULT_TIMEOUT_MS = 30_000 export const DEFAULT_RETRY_ATTEMPTS = 3 diff --git a/cli/src/http/error-mapper.ts b/cli/src/http/error-mapper.ts index 4d687ccbb5..825003c60f 100644 --- a/cli/src/http/error-mapper.ts +++ b/cli/src/http/error-mapper.ts @@ -1,7 +1,7 @@ -import type { BaseError } from '../errors/base.js' -import { newError } from '../errors/base.js' -import { ErrorCode } from '../errors/codes.js' -import { redactBearer } from './sanitize.js' +import type { BaseError } from '@/errors/base' +import { newError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' +import { redactBearer } from './sanitize' type WireFields = { code?: string diff --git a/cli/src/http/middleware/request-logger.ts b/cli/src/http/middleware/request-logger.ts index 8fd31d3d81..c7eb1c1991 100644 --- a/cli/src/http/middleware/request-logger.ts +++ b/cli/src/http/middleware/request-logger.ts @@ -1,6 +1,6 @@ import type { BeforeRequestHook, BeforeRetryHook } from 'ky' -import type { HttpLogger } from '../types.js' -import { redactBearer } from '../sanitize.js' +import type { HttpLogger } from '@/http/types' +import { redactBearer } from '@/http/sanitize' const START_TIME = Symbol('difyctl-http-start') diff --git a/cli/src/http/sse-dify.test.ts b/cli/src/http/sse-dify.test.ts index b0823ff4bb..71e3b97345 100644 --- a/cli/src/http/sse-dify.test.ts +++ b/cli/src/http/sse-dify.test.ts @@ -1,6 +1,6 @@ -import type { SseEvent } from './sse.js' +import type { SseEvent } from './sse' import { describe, expect, it } from 'vitest' -import { eventNameFromDifyData, normalizeDifyStream } from './sse-dify.js' +import { eventNameFromDifyData, normalizeDifyStream } from './sse-dify' const enc = new TextEncoder() @@ -73,8 +73,8 @@ describe('normalizeDifyStream', () => { const ev: SseEvent = { name: '', data: bytes('{"answer":"hi"}') } const out = await collect(normalizeDifyStream(fromArray([ev]))) expect(out).toHaveLength(1) - expect(out[0].name).toBe('') - expect(out[0].data).toBe(ev.data) + expect(out[0]?.name).toBe('') + expect(out[0]?.data).toBe(ev.data) }) it('forwards unchanged when data is malformed JSON', async () => { @@ -82,7 +82,7 @@ describe('normalizeDifyStream', () => { { name: '', data: bytes('not-json') }, ]))) expect(out).toHaveLength(1) - expect(out[0].name).toBe('') + expect(out[0]?.name).toBe('') }) it('forwards empty-data events with empty name', async () => { @@ -90,6 +90,6 @@ describe('normalizeDifyStream', () => { { name: '', data: bytes('') }, ]))) expect(out).toHaveLength(1) - expect(out[0].name).toBe('') + expect(out[0]?.name).toBe('') }) }) diff --git a/cli/src/http/sse-dify.ts b/cli/src/http/sse-dify.ts index a26499fa1a..7a798858f0 100644 --- a/cli/src/http/sse-dify.ts +++ b/cli/src/http/sse-dify.ts @@ -1,4 +1,4 @@ -import type { SseEvent } from './sse.js' +import type { SseEvent } from './sse' const dec = new TextDecoder() diff --git a/cli/src/http/sse.test.ts b/cli/src/http/sse.test.ts index 03d5879e13..ff023d731f 100644 --- a/cli/src/http/sse.test.ts +++ b/cli/src/http/sse.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { parseSSE } from './sse.js' +import { parseSSE } from './sse' function streamOf(...chunks: string[]): ReadableStream { const enc = new TextEncoder() diff --git a/cli/src/index.ts b/cli/src/index.ts index 9fbe70478e..65d86b2599 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -1,2 +1,2 @@ -export { longVersion, shortVersion, userAgent, versionInfo } from './version/info.js' -export type { Channel, VersionInfo } from './version/info.js' +export { longVersion, shortVersion, userAgent, versionInfo } from '@/version/info' +export type { Channel, VersionInfo } from '@/version/info' diff --git a/cli/src/limit/limit.test.ts b/cli/src/limit/limit.test.ts index b8f377be25..aee4f5d5d5 100644 --- a/cli/src/limit/limit.test.ts +++ b/cli/src/limit/limit.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest' -import { isBaseError } from '../errors/base.js' -import { ExitCode } from '../errors/codes.js' -import { LIMIT_DEFAULT, LIMIT_MAX, LIMIT_MIN, parseLimit } from './limit.js' +import { isBaseError } from '@/errors/base' +import { ExitCode } from '@/errors/codes' +import { LIMIT_DEFAULT, LIMIT_MAX, LIMIT_MIN, parseLimit } from './limit' describe('limit', () => { it('constants match Go original', () => { diff --git a/cli/src/limit/limit.ts b/cli/src/limit/limit.ts index 91bdd204bf..3c1de12f32 100644 --- a/cli/src/limit/limit.ts +++ b/cli/src/limit/limit.ts @@ -1,5 +1,5 @@ -import { newError } from '../errors/base.js' -import { ErrorCode } from '../errors/codes.js' +import { newError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' export const LIMIT_MIN = 1 export const LIMIT_MAX = 200 diff --git a/cli/src/printers/format-json-yaml.test.ts b/cli/src/printers/format-json-yaml.test.ts index d37fd39652..e780a1b614 100644 --- a/cli/src/printers/format-json-yaml.test.ts +++ b/cli/src/printers/format-json-yaml.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { JsonYamlPrintFlags } from './format-json-yaml.js' -import { isNoCompatiblePrinter } from './printer.js' +import { JsonYamlPrintFlags } from './format-json-yaml' +import { isNoCompatiblePrinter } from './printer' describe('JsonYamlPrintFlags.allowedFormats', () => { it('returns json + yaml', () => { diff --git a/cli/src/printers/format-json-yaml.ts b/cli/src/printers/format-json-yaml.ts index b6d895b753..e72e9dc545 100644 --- a/cli/src/printers/format-json-yaml.ts +++ b/cli/src/printers/format-json-yaml.ts @@ -1,6 +1,6 @@ -import type { Printer, PrintFlags } from './printer.js' +import type { Printer, PrintFlags } from './printer' import yaml from 'js-yaml' -import { NoCompatiblePrinterError, payload } from './printer.js' +import { NoCompatiblePrinterError, payload } from './printer' const ALLOWED = ['json', 'yaml'] as const diff --git a/cli/src/printers/format-name.test.ts b/cli/src/printers/format-name.test.ts index c4a6ff0df0..0b7eb71984 100644 --- a/cli/src/printers/format-name.test.ts +++ b/cli/src/printers/format-name.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { NamePrintFlags } from './format-name.js' -import { isNoCompatiblePrinter } from './printer.js' +import { NamePrintFlags } from './format-name' +import { isNoCompatiblePrinter } from './printer' const fakeMode = (m: string) => ({ mode: () => m }) diff --git a/cli/src/printers/format-name.ts b/cli/src/printers/format-name.ts index b6ba448ced..ef8f3ee112 100644 --- a/cli/src/printers/format-name.ts +++ b/cli/src/printers/format-name.ts @@ -1,5 +1,5 @@ -import type { Printer, PrintFlags } from './printer.js' -import { isModer, NoCompatiblePrinterError, payload } from './printer.js' +import type { Printer, PrintFlags } from './printer' +import { isModer, NoCompatiblePrinterError, payload } from './printer' const ALLOWED = ['name'] as const diff --git a/cli/src/printers/format-table.test.ts b/cli/src/printers/format-table.test.ts index 2652f4b0f8..78df30b614 100644 --- a/cli/src/printers/format-table.test.ts +++ b/cli/src/printers/format-table.test.ts @@ -1,7 +1,7 @@ -import type { TableColumn, TableHandler } from './format-table.js' +import type { TableColumn, TableHandler } from './format-table' import { describe, expect, it } from 'vitest' -import { TablePrintFlags } from './format-table.js' -import { isNoCompatiblePrinter } from './printer.js' +import { TablePrintFlags } from './format-table' +import { isNoCompatiblePrinter } from './printer' const fakeMode = (m: string) => ({ mode: () => m }) diff --git a/cli/src/printers/format-table.ts b/cli/src/printers/format-table.ts index f37b92da1b..9a72729b61 100644 --- a/cli/src/printers/format-table.ts +++ b/cli/src/printers/format-table.ts @@ -1,5 +1,5 @@ -import type { Printer, PrintFlags } from './printer.js' -import { isModer, NoCompatiblePrinterError, payload } from './printer.js' +import type { Printer, PrintFlags } from './printer' +import { isModer, NoCompatiblePrinterError, payload } from './printer' const ALLOWED = ['', 'wide'] as const const COLUMN_PADDING = 2 diff --git a/cli/src/printers/format-text.test.ts b/cli/src/printers/format-text.test.ts index 4563555b86..dc0f812336 100644 --- a/cli/src/printers/format-text.test.ts +++ b/cli/src/printers/format-text.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { TextPrintFlags } from './format-text.js' +import { TextPrintFlags } from './format-text' describe('TextPrintFlags', () => { it('routes to handler by mode', () => { diff --git a/cli/src/printers/format-text.ts b/cli/src/printers/format-text.ts index 61aa1fd12d..ec8dd08a5e 100644 --- a/cli/src/printers/format-text.ts +++ b/cli/src/printers/format-text.ts @@ -1,5 +1,5 @@ -import type { Printer, PrintFlags } from './printer.js' -import { isModer, NoCompatiblePrinterError, payload } from './printer.js' +import type { Printer, PrintFlags } from './printer' +import { isModer, NoCompatiblePrinterError, payload } from './printer' const ALLOWED = ['', 'text'] as const diff --git a/cli/src/printers/printer.test.ts b/cli/src/printers/printer.test.ts index 7a1cf346fb..25535f7373 100644 --- a/cli/src/printers/printer.test.ts +++ b/cli/src/printers/printer.test.ts @@ -5,7 +5,7 @@ import { isRawObject, NoCompatiblePrinterError, payload, -} from './printer.js' +} from './printer' describe('NoCompatiblePrinterError', () => { it('mentions format and allowed list when allowed is non-empty', () => { diff --git a/cli/src/printers/stream-printer.ts b/cli/src/printers/stream-printer.ts index fb19f1fc36..613c6c6104 100644 --- a/cli/src/printers/stream-printer.ts +++ b/cli/src/printers/stream-printer.ts @@ -1,4 +1,4 @@ -import type { SseEvent } from '../http/sse.js' +import type { SseEvent } from '@/http/sse' export type StreamPrinter = { onEvent: (out: NodeJS.WritableStream, errOut: NodeJS.WritableStream, ev: SseEvent) => void diff --git a/cli/src/printers/width.test.ts b/cli/src/printers/width.test.ts index a57e452488..def5f93ae6 100644 --- a/cli/src/printers/width.test.ts +++ b/cli/src/printers/width.test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { TERMINAL_WIDTH_FALLBACK, terminalWidth, truncate } from './width.js' +import { TERMINAL_WIDTH_FALLBACK, terminalWidth, truncate } from './width' describe('truncate', () => { it('returns the input unchanged when shorter than max', () => { diff --git a/cli/src/store/config-writer.test.ts b/cli/src/store/config-writer.test.ts index 9635032877..69a3300b28 100644 --- a/cli/src/store/config-writer.test.ts +++ b/cli/src/store/config-writer.test.ts @@ -2,8 +2,8 @@ import { mkdtemp, rm } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { loadConfig } from '../config/config-loader' -import { emptyConfig } from '../config/schema' +import { loadConfig } from '@/config/config-loader' +import { emptyConfig } from '@/config/schema' import { saveConfig } from './config-writer' import { ENV_CONFIG_DIR } from './dir' import { getConfigurationStore } from './manager' diff --git a/cli/src/store/config-writer.ts b/cli/src/store/config-writer.ts index 79b8a23d65..483cabcb0c 100644 --- a/cli/src/store/config-writer.ts +++ b/cli/src/store/config-writer.ts @@ -1,6 +1,6 @@ -import type { ConfigFile } from '../config/schema' import type { YamlStore } from './store' -import { CURRENT_SCHEMA_VERSION } from '../config/schema' +import type { ConfigFile } from '@/config/schema' +import { CURRENT_SCHEMA_VERSION } from '@/config/schema' export function saveConfig(store: YamlStore, config: ConfigFile): void { const stamped: ConfigFile = { ...config, schema_version: CURRENT_SCHEMA_VERSION } diff --git a/cli/src/store/dir.ts b/cli/src/store/dir.ts index c75e1dbdfd..9898474095 100644 --- a/cli/src/store/dir.ts +++ b/cli/src/store/dir.ts @@ -1,4 +1,4 @@ -import { getEnv, resolvePlatform } from '../sys' +import { getEnv, resolvePlatform } from '@/sys' export const ENV_CONFIG_DIR = 'DIFY_CONFIG_DIR' export const ENV_CACHE_DIR = 'DIFY_CACHE_DIR' diff --git a/cli/src/store/errors.ts b/cli/src/store/errors.ts index 1082d6fdf5..c8cd10f438 100644 --- a/cli/src/store/errors.ts +++ b/cli/src/store/errors.ts @@ -1,5 +1,5 @@ -import { BaseError } from '../errors/base' -import { ErrorCode } from '../errors/codes' +import { BaseError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' export class ConcurrentAccessError extends BaseError { constructor(filePath: string) { diff --git a/cli/src/store/keyring-based-store.test.ts b/cli/src/store/keyring-based-store.test.ts index 53315eec7f..92adaface9 100644 --- a/cli/src/store/keyring-based-store.test.ts +++ b/cli/src/store/keyring-based-store.test.ts @@ -34,7 +34,7 @@ vi.mock('@napi-rs/keyring', () => ({ Entry: FakeEntry, })) -const { KeyringBasedStore } = await import('./store.js') +const { KeyringBasedStore } = await import('./store') const SERVICE = 'difyctl-test' diff --git a/cli/src/store/manager.test.ts b/cli/src/store/manager.test.ts index 53479b305c..1e83c026f2 100644 --- a/cli/src/store/manager.test.ts +++ b/cli/src/store/manager.test.ts @@ -1,6 +1,6 @@ -import type { Key, Store } from './store.js' +import type { Key, Store } from './store' import { describe, expect, it, vi } from 'vitest' -import { getTokenStore } from './manager.js' +import { getTokenStore } from './manager' function memStore(label: string): Store & { _label: string } { const map = new Map() @@ -47,7 +47,7 @@ describe('getTokenStore', () => { it('falls back to file when probe round-trip mismatches', () => { const k = memStore('keyring') const f = memStore('file') - k.get = vi.fn(() => 'something-else') + k.get = vi.fn(() => 'something-else') as Store['get'] const result = getTokenStore({ factory: { keyring: () => k, file: () => f }, }) diff --git a/cli/src/store/store.ts b/cli/src/store/store.ts index 408b43eb52..c2decd06d1 100644 --- a/cli/src/store/store.ts +++ b/cli/src/store/store.ts @@ -1,10 +1,10 @@ -import type { Platform } from '../sys' +import type { Platform } from '@/sys' import fs from 'node:fs' import { dirname } from 'node:path' import { Entry } from '@napi-rs/keyring' import yaml from 'js-yaml' import lockfile from 'lockfile' -import { pid, resolvePlatform } from '../sys' +import { pid, resolvePlatform } from '@/sys' import { BadYamlFormatError, ConcurrentAccessError } from './errors' const FILE_PERM = 0o600 diff --git a/cli/src/sys/index.test.ts b/cli/src/sys/index.test.ts index 6aeaff19cf..3c422a2c85 100644 --- a/cli/src/sys/index.test.ts +++ b/cli/src/sys/index.test.ts @@ -1,7 +1,7 @@ import { homedir } from 'node:os' import { join } from 'node:path' import { describe, expect, it } from 'vitest' -import { resolvePlatform, SUBDIR } from './index.js' +import { resolvePlatform, SUBDIR } from './index' describe('resolvePlatform', () => { it('id matches process.platform', () => { diff --git a/cli/src/sys/io/spinner.ts b/cli/src/sys/io/spinner.ts index 04e7c4d9fe..f0fa89b1db 100644 --- a/cli/src/sys/io/spinner.ts +++ b/cli/src/sys/io/spinner.ts @@ -1,4 +1,4 @@ -import type { IOStreams } from './streams.js' +import type { IOStreams } from './streams' import oraImport from 'ora' const DIFY_FRAMES = ['Dify', 'dIfy', 'diFy', 'difY', 'diFy', 'dIfy'] diff --git a/cli/src/sys/io/streams.ts b/cli/src/sys/io/streams.ts index 62f215f31c..d193cca429 100644 --- a/cli/src/sys/io/streams.ts +++ b/cli/src/sys/io/streams.ts @@ -1,6 +1,6 @@ import { Buffer } from 'node:buffer' import { PassThrough, Readable, Writable } from 'node:stream' -import { io } from '..' +import { io } from '@/sys' export type IOStreams = { out: NodeJS.WritableStream diff --git a/cli/src/sys/io/think-filter.test.ts b/cli/src/sys/io/think-filter.test.ts index c883a9dd1a..72ec036abd 100644 --- a/cli/src/sys/io/think-filter.test.ts +++ b/cli/src/sys/io/think-filter.test.ts @@ -1,7 +1,7 @@ import { Buffer } from 'node:buffer' import { PassThrough } from 'node:stream' import { describe, expect, it } from 'vitest' -import { extractThinkBlocks, stripThinkBlocks, ThinkChunkFilter } from './think-filter.js' +import { extractThinkBlocks, stripThinkBlocks, ThinkChunkFilter } from './think-filter' function captures() { const out = new PassThrough() diff --git a/cli/src/types/app-meta.test.ts b/cli/src/types/app-meta.test.ts index d53176f7b8..b62d81579e 100644 --- a/cli/src/types/app-meta.test.ts +++ b/cli/src/types/app-meta.test.ts @@ -1,6 +1,6 @@ import type { AppDescribeResponse } from '@dify/contracts/api/openapi/types.gen' import { describe, expect, it } from 'vitest' -import { covers, FieldInfo, FieldInputSchema, FieldParameters, fromDescribe, mergeMeta } from './app-meta.js' +import { covers, FieldInfo, FieldInputSchema, FieldParameters, fromDescribe, mergeMeta } from './app-meta' function describeResp(): AppDescribeResponse { return { diff --git a/cli/src/util/browser.ts b/cli/src/util/browser.ts index 5ec813dd77..c647db98eb 100644 --- a/cli/src/util/browser.ts +++ b/cli/src/util/browser.ts @@ -1,5 +1,5 @@ import openModule from 'open' -import { platform } from '../sys' +import { platform } from '@/sys' export const OpenDecision = { Auto: 'auto-open', diff --git a/cli/src/util/host.ts b/cli/src/util/host.ts index dcd6f5f3af..e58649aafb 100644 --- a/cli/src/util/host.ts +++ b/cli/src/util/host.ts @@ -1,5 +1,5 @@ -import { BaseError } from '../errors/base.js' -import { ErrorCode } from '../errors/codes.js' +import { BaseError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' export const DEFAULT_HOST = 'https://cloud.dify.ai' diff --git a/cli/src/version/compat.test.ts b/cli/src/version/compat.test.ts index 6b913a28b1..dcf3f08b25 100644 --- a/cli/src/version/compat.test.ts +++ b/cli/src/version/compat.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { compatString, difyCompat, evaluateCompat } from './compat.js' +import { compatString, difyCompat, evaluateCompat } from './compat' describe('difyCompat', () => { it('exposes minDify and maxDify as readonly strings', () => { diff --git a/cli/src/version/info.test.ts b/cli/src/version/info.test.ts index f21a0cad0d..d7e2b1307e 100644 --- a/cli/src/version/info.test.ts +++ b/cli/src/version/info.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { longVersion, shortVersion, userAgent } from './info.js' +import { longVersion, shortVersion, userAgent } from './info' describe('version info', () => { it('shortVersion returns the build-injected version string', () => { diff --git a/cli/src/version/info.ts b/cli/src/version/info.ts index c40484bbc3..23b8624b34 100644 --- a/cli/src/version/info.ts +++ b/cli/src/version/info.ts @@ -1,5 +1,5 @@ -import { arch, platform } from '../sys/index.js' -import { compatString } from './compat.js' +import { arch, platform } from '@/sys/index' +import { compatString } from './compat' export type Channel = 'dev' | 'rc' | 'stable' diff --git a/cli/src/version/nudge.test.ts b/cli/src/version/nudge.test.ts index 3e250a5040..9aca623bb2 100644 --- a/cli/src/version/nudge.test.ts +++ b/cli/src/version/nudge.test.ts @@ -1,13 +1,13 @@ import type { ServerVersionResponse } from '@dify/contracts/api/openapi/types.gen' -import type { NudgeStore } from '../cache/nudge-store.js' +import type { NudgeStore } from '@/cache/nudge-store' import { mkdtemp, rm } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import { loadNudgeStore } from '../cache/nudge-store.js' -import { ENV_CACHE_DIR } from '../store/dir.js' -import { CACHE_NUDGE, getCache } from '../store/manager.js' -import { maybeNudgeCompat } from './nudge.js' +import { loadNudgeStore } from '@/cache/nudge-store' +import { ENV_CACHE_DIR } from '@/store/dir' +import { CACHE_NUDGE, getCache } from '@/store/manager' +import { maybeNudgeCompat } from './nudge' const HOST = 'https://cloud.dify.ai' const NOW = new Date('2026-05-20T12:00:00.000Z') diff --git a/cli/src/version/nudge.ts b/cli/src/version/nudge.ts index ad4c0fdde0..a6d9fe96d4 100644 --- a/cli/src/version/nudge.ts +++ b/cli/src/version/nudge.ts @@ -1,7 +1,7 @@ import type { ServerVersionResponse } from '@dify/contracts/api/openapi/types.gen' -import type { NudgeStore } from '../cache/nudge-store.js' -import { colorScheme } from '../sys/io/color.js' -import { difyCompat, evaluateCompat } from './compat.js' +import type { NudgeStore } from '@/cache/nudge-store' +import { colorScheme } from '@/sys/io/color' +import { difyCompat, evaluateCompat } from './compat' // Formats whose stdout is structured data (json/yaml) or a single name token — // any stderr banner from us would pollute machine parsing. Default text format diff --git a/cli/src/version/probe.test.ts b/cli/src/version/probe.test.ts index 833ebb3c83..e8eb997b54 100644 --- a/cli/src/version/probe.test.ts +++ b/cli/src/version/probe.test.ts @@ -1,14 +1,14 @@ import type { ServerVersionResponse } from '@dify/contracts/api/openapi/types.gen' -import type { HostsBundle } from '../auth/hosts.js' +import type { HostsBundle } from '@/auth/hosts' import { mkdtemp, rm } from 'node:fs/promises' import { platform, tmpdir } from 'node:os' import { join } from 'node:path' +import { startMock } from '@test/fixtures/dify-mock/server' import { describe, expect, it } from 'vitest' -import { startMock } from '../../test/fixtures/dify-mock/server.js' -import { saveHosts } from '../auth/hosts.js' -import { ENV_CONFIG_DIR } from '../store/dir.js' -import { arch } from '../sys/index.js' -import { runVersionProbe } from './probe.js' +import { saveHosts } from '@/auth/hosts' +import { ENV_CONFIG_DIR } from '@/store/dir' +import { arch } from '@/sys/index' +import { runVersionProbe } from './probe' function bundle(overrides: Partial = {}): HostsBundle { return { diff --git a/cli/src/version/probe.ts b/cli/src/version/probe.ts index 6cf136571f..64fff384a4 100644 --- a/cli/src/version/probe.ts +++ b/cli/src/version/probe.ts @@ -1,14 +1,14 @@ import type { ServerVersionResponse } from '@dify/contracts/api/openapi/types.gen' -import type { HostsBundle } from '../auth/hosts.js' -import type { CompatVerdict } from './compat.js' -import type { Channel } from './info.js' -import { META_PROBE_TIMEOUT_MS, MetaClient } from '../api/meta.js' -import { loadHosts } from '../auth/hosts.js' -import { createClient } from '../http/client.js' -import { arch, platform } from '../sys/index.js' -import { hostWithScheme } from '../util/host.js' -import { difyCompat, evaluateCompat } from './compat.js' -import { versionInfo } from './info.js' +import type { CompatVerdict } from './compat' +import type { Channel } from './info' +import type { HostsBundle } from '@/auth/hosts' +import { META_PROBE_TIMEOUT_MS, MetaClient } from '@/api/meta' +import { loadHosts } from '@/auth/hosts' +import { createClient } from '@/http/client' +import { arch, platform } from '@/sys/index' +import { hostWithScheme } from '@/util/host' +import { difyCompat, evaluateCompat } from './compat' +import { versionInfo } from './info' export type ClientBlock = { readonly version: string diff --git a/cli/src/version/render.test.ts b/cli/src/version/render.test.ts index 562d1daca9..d1f40f13e5 100644 --- a/cli/src/version/render.test.ts +++ b/cli/src/version/render.test.ts @@ -1,6 +1,6 @@ -import type { VersionReport } from './probe.js' +import type { VersionReport } from './probe' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import { renderVersionText } from './render.js' +import { renderVersionText } from './render' function baseClient(overrides: Partial = {}): VersionReport['client'] { return { @@ -133,7 +133,7 @@ describe('renderVersionText', () => { }) it('color=true emits ANSI sequences for verdict and RC warning lines', async () => { - const { renderVersionText: render } = await import('./render.js') + const { renderVersionText: render } = await import('./render') const report: VersionReport = { client: baseClient({ channel: 'rc' }), server: { endpoint: 'https://cloud.dify.ai', reachable: true, version: '99.0.0', edition: 'SELF_HOSTED' }, diff --git a/cli/src/version/render.ts b/cli/src/version/render.ts index 2777eca1d3..ffedc8c5c0 100644 --- a/cli/src/version/render.ts +++ b/cli/src/version/render.ts @@ -1,5 +1,5 @@ -import type { VersionReport } from './probe.js' -import { colorScheme } from '../sys/io/color.js' +import type { VersionReport } from './probe' +import { colorScheme } from '@/sys/io/color' const RC_WARNING_LINES = [ 'WARNING: This build is a release candidate. It is in beta test, not stable,', diff --git a/cli/src/workspace/resolver.ts b/cli/src/workspace/resolver.ts index 1be313cd63..e7aba41a61 100644 --- a/cli/src/workspace/resolver.ts +++ b/cli/src/workspace/resolver.ts @@ -1,6 +1,6 @@ -import type { HostsBundle } from '../auth/hosts.js' -import { BaseError } from '../errors/base.js' -import { ErrorCode } from '../errors/codes.js' +import type { HostsBundle } from '@/auth/hosts' +import { BaseError } from '@/errors/base' +import { ErrorCode } from '@/errors/codes' export type WorkspaceResolveInputs = { readonly flag?: string diff --git a/cli/tsconfig.json b/cli/tsconfig.json index 41b24e8690..a44a2225bd 100644 --- a/cli/tsconfig.json +++ b/cli/tsconfig.json @@ -1,13 +1,13 @@ { "extends": "@dify/tsconfig/node.json", "compilerOptions": { - "rootDir": "src", + "moduleResolution": "bundler", "paths": { "@/*": [ - "./*" + "./src/*" ], - "~@/*": [ - "./*" + "@test/*": [ + "./test/*" ] }, "types": ["node"], @@ -17,6 +17,5 @@ "outDir": "dist", "sourceMap": true }, - "include": ["src/**/*.ts"], - "exclude": ["node_modules", "**/*.test.ts"] + "include": ["src/**/*.ts", "test/**/*.ts"] } diff --git a/cli/vite.config.ts b/cli/vite.config.ts index f54f035fdc..ebc6c2fec4 100644 --- a/cli/vite.config.ts +++ b/cli/vite.config.ts @@ -1,9 +1,16 @@ +import { fileURLToPath } from 'node:url' import { defineConfig } from 'vite-plus' import { resolveBuildInfo } from './scripts/lib/resolve-buildinfo.js' const buildInfo = resolveBuildInfo() export default defineConfig({ + resolve: { + alias: { + '@': fileURLToPath(new URL('./src', import.meta.url)), + '@test': fileURLToPath(new URL('./test', import.meta.url)), + }, + }, pack: { entry: ['src/index.ts', 'src/commands/**/*.ts', 'src/framework/**/*.ts'], format: ['esm'], diff --git a/eslint.config.mjs b/eslint.config.mjs index d939eb4d03..5140a99f12 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -78,4 +78,17 @@ export default antfu( 'node/prefer-global/process': 'off', }, }, + { + files: ['cli/src/**/*.ts'], + rules: { + 'no-restricted-imports': ['error', { + patterns: [ + { + group: ['../**', './*/**', '..'], + message: 'Use the @/ (or @test/) alias for parent-directory or nested relative imports; keep ./ only for same-folder siblings.', + }, + ], + }], + }, + }, ) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 50127e1fd8..5a6114e814 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -693,6 +693,9 @@ importers: '@types/node': specifier: 'catalog:' version: 25.9.1 + '@typescript/native-preview': + specifier: 'catalog:' + version: 7.0.0-dev.20260523.1 '@vitest/coverage-v8': specifier: 'catalog:' version: 4.1.7(@vitest/browser@4.1.7)(@voidzero-dev/vite-plus-test@0.1.22)