Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor: use absolute path for inter dir importing (#36822)
Yunlu Wenc0ee821d4559
diff --git a/cli/package.json b/cli/package.jsonindex 59286c2880a..90f1f31eb1a 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.tsindex 2f3c4ce2f44..cf25ddcf71a 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.tsindex f6ea7680274..769490df834 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<CommandEntrentries.push({tokens,identifier: tokensToIdentifier(tokens),- importPath: `./${tokens.join('/')}/index.js`,+ importPath: `@/commands/${tokens.join('/')}/index`,})}diff --git a/cli/src/api/app-meta.test.ts b/cli/src/api/app-meta.test.tsindex 4885a135b7b..455acb64f1f 100644--- a/cli/src/api/app-meta.test.ts+++ b/cli/src/api/app-meta.test.ts@@ -1,16 +1,16 @@-import type { DifyMock } from '../../test/fixtures/dify-mock/server.js'+import type { DifyMock } from '@test/fixtures/dify-mock/server'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, vi } 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 { FieldInfo, FieldParameters } from '../types/app-meta.js'-import { AppMetaClient } from './app-meta.js'-import { AppsClient } from './apps.js'+import { loadAppInfoCache } from '@/cache/app-info'+import { createClient } from '@/http/client'+import { ENV_CACHE_DIR } from '@/store/dir'+import { CACHE_APP_INFO, getCache } from '@/store/manager'+import { FieldInfo, FieldParameters } from '@/types/app-meta'+import { AppMetaClient } from './app-meta'+import { AppsClient } from './apps'describe('AppMetaClient', () => {let mock: DifyMockdiff --git a/cli/src/api/app-meta.ts b/cli/src/api/app-meta.tsindex 8d703850436..854c9b0eacc 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: AppsClientdiff --git a/cli/src/api/app-run.test.ts b/cli/src/api/app-run.test.tsindex 07d6a095a7b..8100ebc256b 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.tsindex 12b00e411e9..cf75ade9f80 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?: stringdiff --git a/cli/src/api/device-flow.test.ts b/cli/src/api/device-flow.test.tsindex e850add9377..3b380cfdc06 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: stringdiff --git a/cli/src/api/members.test.ts b/cli/src/api/members.test.tsindex 5442e296c39..4dafa1ce3ce 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('[email protected]')+ expect(result.data[0]?.email).toBe('[email protected]')})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.tsindex e41189054e4..1b7fee0a79f 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: DifyMockdiff --git a/cli/src/api/oauth-device.ts b/cli/src/api/oauth-device.tsindex 582b5f06b2d..dea88c82b62 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.tsindex 5c5b254c0ac..9630b309b6b 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.tsindex a7016d67141..f61cc513f31 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<typeof StorageModeSchema>diff --git a/cli/src/cache/app-info.test.ts b/cli/src/cache/app-info.test.tsindex 8604382c5be..50ac1c67d35 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.tsindex 5d8ea276428..f6f360405a3 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 * 1000diff --git a/cli/src/cache/nudge-store.test.ts b/cli/src/cache/nudge-store.test.tsindex d899260f889..737235dabbd 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.tsindex e16c4a435f9..61846b89dd2 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 * 1000diff --git a/cli/src/commands/_shared/authed-command.ts b/cli/src/commands/_shared/authed-command.tsindex 44aea53c2ba..29710eacf57 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: HostsBundlediff --git a/cli/src/commands/_shared/dify-command.ts b/cli/src/commands/_shared/dify-command.tsindex 80a25e377f3..cfde145f805 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<AuthedContext> {diff --git a/cli/src/commands/_shared/global-flags.test.ts b/cli/src/commands/_shared/global-flags.test.tsindex 2fe678726b0..914f2d2dff0 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.tsindex 20777c99f9b..e2b1d5b4866 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 = 3diff --git a/cli/src/commands/auth/devices/_shared/devices.test.ts b/cli/src/commands/auth/devices/_shared/devices.test.tsindex 6c66ef53c8a..4675a79e221 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<string, unknown>()diff --git a/cli/src/commands/auth/devices/_shared/devices.ts b/cli/src/commands/auth/devices/_shared/devices.tsindex 6734a2a9e62..9daa44da998 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: IOStreamsdiff --git a/cli/src/commands/auth/devices/list/index.ts b/cli/src/commands/auth/devices/list/index.tsindex ae64220eef8..81e1c7e4ab0 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.tsindex 709bb2ed69b..5aa98c201e7 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.tsindex 4a277883295..948779ab052 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.tsindex bf319dcceca..a6b10c871fd 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_000export const MAX_INTERVAL_MS = 60_000diff --git a/cli/src/commands/auth/login/index.ts b/cli/src/commands/auth/login/index.tsindex 0e7cd3f88e1..e6f25b0a6f6 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.tsindex 84364736344..5c9bb8c3c9b 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('[email protected]')expect(bundle.external_subject?.issuer).toBe('https://issuer.example')- const stored = await store.get(bundle.current_host, '[email protected]')+ const stored = await store.get(tokenKey(bundle.current_host, '[email protected]'))expect(stored).toBe('dfoe_test')expect(io.outBuf()).toContain('external SSO')expect(io.outBuf()).toContain('[email protected]')diff --git a/cli/src/commands/auth/login/login.ts b/cli/src/commands/auth/login/login.tsindex d30ebee26af..0048d89c06c 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: IOStreamsdiff --git a/cli/src/commands/auth/logout/index.ts b/cli/src/commands/auth/logout/index.tsindex f80f2d3fc91..9b65aff42bb 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.tsindex 621cf1555ee..fe0ca5aa3a5 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<string, unknown>()diff --git a/cli/src/commands/auth/logout/logout.ts b/cli/src/commands/auth/logout/logout.tsindex 3090ed09a78..c2a1c9d32ad 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: IOStreamsdiff --git a/cli/src/commands/auth/status/index.ts b/cli/src/commands/auth/status/index.tsindex 3e95374767f..46e9e849d74 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.tsindex f039d548669..9df4173b396 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.tsindex 83ca6268270..054b351a211 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: IOStreamsdiff --git a/cli/src/commands/auth/whoami/index.ts b/cli/src/commands/auth/whoami/index.tsindex e59db2d3035..1c10ea50eb5 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.tsindex 98ea0a9bcb6..dde6d480e76 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.tsindex 908daaddecd..e40d56787fa 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: IOStreamsdiff --git a/cli/src/commands/config/get/index.ts b/cli/src/commands/config/get/index.tsindex d02fcdb18d2..907672c577a 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.tsindex cfe7d127796..2246b111afe 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: stringdiff --git a/cli/src/commands/config/get/run.ts b/cli/src/commands/config/get/run.tsindex 8fb486e60ba..b4713fa84df 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: stringdiff --git a/cli/src/commands/config/path/index.ts b/cli/src/commands/config/path/index.tsindex 2bf22c89882..dcb2aed2590 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.tsindex d747a8783b7..36aa97d17bb 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.tsindex dcb72a40d52..6185dd87801 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: stringdiff --git a/cli/src/commands/config/set/run.ts b/cli/src/commands/config/set/run.tsindex c7a1e752b53..2794427e1a8 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: stringdiff --git a/cli/src/commands/config/unset/index.ts b/cli/src/commands/config/unset/index.tsindex a7e7d08096a..f8ae6fe15bf 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.tsindex 85a343d2569..60444578413 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: stringdiff --git a/cli/src/commands/config/unset/run.ts b/cli/src/commands/config/unset/run.tsindex 377013ff0f1..4b34e347880 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: stringdiff --git a/cli/src/commands/config/view/index.ts b/cli/src/commands/config/view/index.tsindex f9e216ade1a..b165fea1fcc 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.tsindex 336f468796a..45e3aff8ca3 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: stringdiff --git a/cli/src/commands/config/view/run.ts b/cli/src/commands/config/view/run.tsindex 78b9e1ca52e..667cb903d50 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?: booleandiff --git a/cli/src/commands/coverage.test.ts b/cli/src/commands/coverage.test.tsindex 19a64664a86..25cc4e4de78 100644--- a/cli/src/commands/coverage.test.ts+++ b/cli/src/commands/coverage.test.ts@@ -1,5 +1,6 @@+/// <reference types="vite/client" />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.tsindex 7a0ee2a9358..9253c86fcd7 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.tsindex 5c739f5a2a7..4ac72b05525 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.tsindex 0608b2fb7bc..1e4a9c3ab0f 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: stringdiff --git a/cli/src/commands/delete/member/index.ts b/cli/src/commands/delete/member/index.tsindex 1ec79565021..2e4d89b4bee 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.tsindex 15a4f66db21..db4a3c0adc8 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.tsindex f89afe86c7d..63fda52d540 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: stringdiff --git a/cli/src/commands/describe/app/handlers.ts b/cli/src/commands/describe/app/handlers.tsindex ef0f56b103d..6b934c87148 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.tsindex 61a87005d34..ce09af76d27 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.tsindex e599ee0bbf0..65da6bfa4e1 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.tsindex f332cc992af..5542fa5fd74 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: stringdiff --git a/cli/src/commands/env/list/index.ts b/cli/src/commands/env/list/index.tsindex 1ecc96fe019..777dfd133a4 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.tsindex 01e6dfcfd06..642e0d63581 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<string, string> = {}) => (name: string) => overrides[name]diff --git a/cli/src/commands/env/list/run-list.ts b/cli/src/commands/env/list/run-list.tsindex 379c81d4afd..9979e525e4d 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 | undefineddiff --git a/cli/src/commands/get/app/handlers.ts b/cli/src/commands/get/app/handlers.tsindex e0646e267a8..18acd1fdd77 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.tsindex c4ec2bd06c3..1c71428c375 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.tsindex ebabf57fe0b..e9e4d52916c 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.tsindex ccb091db571..28ae0cba4ae 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?: stringdiff --git a/cli/src/commands/get/member/handlers.ts b/cli/src/commands/get/member/handlers.tsindex b231916bec2..9d2bc1af171 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.tsindex b1b4d82033d..2e5752c46f8 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.tsindex d32b172eb9c..5e0af7fe2aa 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.tsindex 011cdb15726..b6bf995dc1b 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?: stringdiff --git a/cli/src/commands/get/workspace/handlers.test.ts b/cli/src/commands/get/workspace/handlers.test.tsindex cacbcf4b3ef..21323884936 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.tsindex a71e8a6f64d..b7d3b12155d 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.tsindex 3364f50761c..3bbc3d3f54a 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.tsindex 7ef51c9d812..df7d1bd2073 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.tsindex f3b86f3c1d9..9f35dd5906b 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.tsindex 162fbda78ab..b9f93d67dae 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.tsindex a9adfe00228..fd601230929 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.tsindex d6aad702b49..20024b0075b 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.tsindex 279c7de6d6b..e168294cf79 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.tsindex 0dfadf9d2f0..8856dd77489 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.tsindex 9925fc6c76e..31025c4c557 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.tsindex 8b52520eb3e..6b5a7311028 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.tsindex 99ef349d7be..a0cb17500d0 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.tsindex bcd109b21f9..972a6f1e8e9 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: stringdiff --git a/cli/src/commands/run/app/_strategies/index.ts b/cli/src/commands/run/app/_strategies/index.tsindex 1e7c9895e32..dc4b2326e6b 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<string, unknown> }diff --git a/cli/src/commands/run/app/_strategies/streaming-structured.ts b/cli/src/commands/run/app/_strategies/streaming-structured.tsindex b59550ca6c5..d19884cdf3c 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<string> = 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.tsindex 6f88e394dd1..49bf31eee66 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<void> {diff --git a/cli/src/commands/run/app/agent-guide.test.ts b/cli/src/commands/run/app/agent-guide.test.tsindex 454d9eecbb2..82ee99c6716 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.tsindex 87babdedec6..60d11caf69e 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.tsindex 6fbb17e3030..ea689f8c77d 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.tsindex b22bfec58d1..c8c2055433b 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.tsindex da02ecf5cb8..991c63e1112 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.tsindex 77a55cf5b09..6466bf16cfd 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.tsindex a90d7b8f8ca..a3712ca9806 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.tsindex 55bfb6448fd..a9bc41571a2 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.tsindex eb9a2e4d535..ca529e0728f 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: stringdiff --git a/cli/src/commands/run/app/sse-collector.test.ts b/cli/src/commands/run/app/sse-collector.test.tsindex e158599145b..f724c83702b 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.tsindex d7a645227e1..973a717746c 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: stringdiff --git a/cli/src/commands/run/app/stream-handlers.test.ts b/cli/src/commands/run/app/stream-handlers.test.tsindex fc584e1176a..885b059abf2 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.tsindex 53dc7466029..799bcf7fcd0 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.tsindex f9ffdb286cf..5fe47823592 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.tsindex ff987b815fb..4541fddb947 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.tsindex f77e09d4e62..0236a1ea770 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: stringdiff --git a/cli/src/commands/tree.generated.ts b/cli/src/commands/tree.generated.tsindex 51a77d1a996..9ba4fe11923 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.tsindex 14a480033f6..6be515f1f7c 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.tsindex 4b44472f885..b55fc6179f6 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.tsindex 125d1a18fd7..a26d1eba616 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.tsindex db7a539a386..c847b71c711 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: stringdiff --git a/cli/src/commands/version/index.ts b/cli/src/commands/version/index.tsindex 884824d2322..7a533f71db4 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 = 64diff --git a/cli/src/commands/version/version.test.ts b/cli/src/commands/version/version.test.tsindex afd2346478c..affa01c959f 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<typeof vi.spyOn<typeof process, 'exit'>> {+ function stubProcessExit() {const impl = (() => {throw new Error('__exit__')}) as neverdiff --git a/cli/src/config/config-loader.test.ts b/cli/src/config/config-loader.test.tsindex 53c63fe0b85..501010cabd0 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.tsindex c260d49d8ea..cd2d3601057 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 LoadResultdiff --git a/cli/src/config/keys.test.ts b/cli/src/config/keys.test.tsindex 15a7aed72da..2f2be680c11 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.tsindex 4d719b1c4c5..035b2697aba 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: stringdiff --git a/cli/src/config/schema.test.ts b/cli/src/config/schema.test.tsindex 549fab3622a..c3189486352 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.tsindex 5ea4726d6fa..9b89695b4cd 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.tsindex 7e257364ee1..a567bf01cb8 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: stringdiff --git a/cli/src/errors/base.test.ts b/cli/src/errors/base.test.tsindex 196646fae48..beb6a6296c6 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.tsindex 3ec8b6e44f4..64baead2600 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: ErrorCodeValuediff --git a/cli/src/errors/codes.test.ts b/cli/src/errors/codes.test.tsindex fcaf55e00a2..ac59a3dbf78 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.tsindex 8f736faa46a..6fb7b85f766 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.tsindex e8178906066..b67e9d8945b 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.tsindex 4b80f089008..65eb8d4b90e 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?: stringdiff --git a/cli/src/framework/command-fs.test.ts b/cli/src/framework/command-fs.test.tsindex 9d357461642..8c5d6423784 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.tsindex be5d4a1ec3a..ef898b966af 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(): Commanddiff --git a/cli/src/framework/errors.test.ts b/cli/src/framework/errors.test.tsindex 90b90616485..be54b871364 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.tsindex b1cb4e1c295..4f8a4c1c48e 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.tsindex c68d7733e43..1e0967dee8d 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.tsindex b730e0de9bf..d3db72fbbf6 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<const Opts extends {description: stringdiff --git a/cli/src/framework/help.test.ts b/cli/src/framework/help.test.tsindex 6cbcd3fada2..ca809d61689 100644--- a/cli/src/framework/help.test.ts+++ b/cli/src/framework/help.test.ts@@ -1,7 +1,7 @@-import type { CommandConstructor } from './command.js'+import type { CommandConstructor } from './command'import { describe, expect, it } from 'vitest'-import { Args, Flags } from './flags.js'-import { formatHelp } from './help.js'+import { Args, Flags } from './flags'+import { formatHelp } from './help'function makeCmd(opts: {description?: stringdiff --git a/cli/src/framework/help.ts b/cli/src/framework/help.tsindex a5f6127471e..2de5bcc6a1e 100644--- a/cli/src/framework/help.ts+++ b/cli/src/framework/help.ts@@ -1,5 +1,5 @@-import type { CommandConstructor } from './command.js'-import type { FlagDefinition } from './types.js'+import type { CommandConstructor } from './command'+import type { FlagDefinition } from './types'function flagLabel(name: string, def: FlagDefinition): string {const parts: string[] = []diff --git a/cli/src/framework/output.test.ts b/cli/src/framework/output.test.tsindex df5ba2ff268..5eaa0f54b90 100644--- a/cli/src/framework/output.test.ts+++ b/cli/src/framework/output.test.ts@@ -1,12 +1,12 @@-import type { FormattedPrintable, NamePrintable, TablePrintable } from './output.js'+import type { FormattedPrintable, NamePrintable, TablePrintable } from './output'import { describe, expect, it } from 'vitest'-import { OutputFormatNotSupportedError } from './errors.js'+import { OutputFormatNotSupportedError } from './errors'import {formatted,raw,stringifyOutput,table,-} from './output.js'+} from './output'function makeFormatted(opts: { text?: string, json?: unknown, name?: string }): FormattedPrintable & NamePrintable {return {diff --git a/cli/src/framework/registry.test.ts b/cli/src/framework/registry.test.tsindex a4a4302884e..0d208d485d9 100644--- a/cli/src/framework/registry.test.ts+++ b/cli/src/framework/registry.test.ts@@ -1,7 +1,7 @@-import type { CommandTree } from './registry.js'+import type { CommandTree } from './registry'import { describe, expect, it } from 'vitest'-import { Command } from './command.js'-import { findSuggestions, resolveCommand } from './registry.js'+import { Command } from './command'+import { findSuggestions, resolveCommand } from './registry'class FooCmd extends Command {async run(_argv: string[]) {}diff --git a/cli/src/framework/registry.ts b/cli/src/framework/registry.tsindex 76733392b42..4e64686ebe7 100644--- a/cli/src/framework/registry.ts+++ b/cli/src/framework/registry.ts@@ -1,4 +1,4 @@-import type { CommandConstructor } from './command.js'+import type { CommandConstructor } from './command'export type CommandNode = {readonly command?: CommandConstructordiff --git a/cli/src/framework/run.test.ts b/cli/src/framework/run.test.tsindex 498b45d8266..5a67cc30446 100644--- a/cli/src/framework/run.test.ts+++ b/cli/src/framework/run.test.ts@@ -1,10 +1,10 @@-import type { CommandConstructor } from './command.js'-import type { CommandTree } from './registry.js'+import type { CommandConstructor } from './command'+import type { CommandTree } from './registry'import { describe, expect, it } from 'vitest'-import { BaseError, newError } from '../errors/base.js'-import { ErrorCode, ExitCode } from '../errors/codes.js'-import { Command } from './command.js'-import { run, sniffOutputFormat } from './run.js'+import { BaseError, newError } from '@/errors/base'+import { ErrorCode, ExitCode } from '@/errors/codes'+import { Command } from './command'+import { run, sniffOutputFormat } from './run'describe('sniffOutputFormat', () => {it('returns empty for empty argv', () => {diff --git a/cli/src/framework/run.ts b/cli/src/framework/run.tsindex a8c56a604b9..4305c2dc4e2 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<void> {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.tsindex 62487c3622c..0a7672a89cd 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 | undefineddiff --git a/cli/src/http/client.test.ts b/cli/src/http/client.test.tsindex 580db2bf6d6..6faa873a855 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: DifyMockdiff --git a/cli/src/http/client.ts b/cli/src/http/client.tsindex 447b9d4649a..2637870b0ad 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_000export const DEFAULT_RETRY_ATTEMPTS = 3diff --git a/cli/src/http/error-mapper.ts b/cli/src/http/error-mapper.tsindex 4d687ccbb58..825003c60f9 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?: stringdiff --git a/cli/src/http/middleware/request-logger.ts b/cli/src/http/middleware/request-logger.tsindex 8fd31d3d81c..c7eb1c19918 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.tsindex b0823ff4bb6..71e3b973451 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.tsindex a26499fa1ad..7a798858f0a 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.tsindex 03d5879e137..ff023d731f5 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<Uint8Array> {const enc = new TextEncoder()diff --git a/cli/src/index.ts b/cli/src/index.tsindex 9fbe70478e2..65d86b25994 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.tsindex b8f377be251..aee4f5d5d50 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.tsindex 91bdd204bf5..3c1de12f323 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 = 1export const LIMIT_MAX = 200diff --git a/cli/src/printers/format-json-yaml.test.ts b/cli/src/printers/format-json-yaml.test.tsindex d37fd39652c..e780a1b614f 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.tsindex b6d895b7536..e72e9dc5454 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 constdiff --git a/cli/src/printers/format-name.test.ts b/cli/src/printers/format-name.test.tsindex c4a6ff0df0f..0b7eb719847 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.tsindex b6ba448ced1..ef8f3ee112b 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 constdiff --git a/cli/src/printers/format-table.test.ts b/cli/src/printers/format-table.test.tsindex 2652f4b0f86..78df30b614f 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.tsindex f37b92da1b7..9a72729b618 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 constconst COLUMN_PADDING = 2diff --git a/cli/src/printers/format-text.test.ts b/cli/src/printers/format-text.test.tsindex 4563555b86c..dc0f8123360 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.tsindex 61aa1fd12d8..ec8dd08a5ef 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 constdiff --git a/cli/src/printers/printer.test.ts b/cli/src/printers/printer.test.tsindex 7a1cf346fb3..25535f7373b 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.tsindex fb19f1fc366..613c6c6104a 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) => voiddiff --git a/cli/src/printers/width.test.ts b/cli/src/printers/width.test.tsindex a57e452488b..def5f93ae6c 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.tsindex 96350328773..69a3300b281 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.tsindex 79b8a23d65b..483cabcb0c1 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.tsindex c75e1dbdfd9..98984740958 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.tsindex 1082d6fdf5c..c8cd10f4382 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.tsindex 53315eec7f2..92adaface94 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.tsindex 53479b305cd..1e83c026f24 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<string, unknown>()@@ -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.tsindex 408b43eb52e..c2decd06d1f 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 = 0o600diff --git a/cli/src/sys/index.test.ts b/cli/src/sys/index.test.tsindex 6aeaff19cf2..3c422a2c858 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.tsindex 04e7c4d9fec..f0fa89b1db6 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.tsindex 62f215f31c8..d193cca4298 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.WritableStreamdiff --git a/cli/src/sys/io/think-filter.test.ts b/cli/src/sys/io/think-filter.test.tsindex c883a9dd1a0..72ec036abdd 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.tsindex d53176f7b80..b62d81579ea 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.tsindex 5ec813dd772..c647db98ebd 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.tsindex dcd6f5f3afd..e58649aafb7 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.tsindex 6b913a28b1d..dcf3f08b259 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.tsindex f21a0cad0d1..d7e2b1307ed 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.tsindex c40484bbc31..23b8624b342 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.tsindex 3e250a5040c..9aca623bb24 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.tsindex ad4c0fdde01..a6d9fe96d4b 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 formatdiff --git a/cli/src/version/probe.test.ts b/cli/src/version/probe.test.tsindex 833ebb3c83f..e8eb997b543 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> = {}): HostsBundle {return {diff --git a/cli/src/version/probe.ts b/cli/src/version/probe.tsindex 6cf136571f3..64fff384a49 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: stringdiff --git a/cli/src/version/render.test.ts b/cli/src/version/render.test.tsindex 562d1daca9c..d1f40f13e58 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']> = {}): 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.tsindex 2777eca1d36..ffedc8c5c07 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.tsindex 1be313cd638..e7aba41a61e 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?: stringdiff --git a/cli/tsconfig.json b/cli/tsconfig.jsonindex 41b24e8690c..a44a2225bdc 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.tsindex f54f035fdc8..ebc6c2fec40 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.mjsindex d939eb4d036..5140a99f123 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.yamlindex 50127e1fd8d..5a6114e814f 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/[email protected])(@voidzero-dev/[email protected])