@ranger1/dx 0.1.11 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cli/commands/ai.js +11 -1
- package/package.json +1 -1
package/lib/cli/commands/ai.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'node:fs'
|
|
2
2
|
import { resolve } from 'node:path'
|
|
3
|
+
import { homedir } from 'node:os'
|
|
3
4
|
import { spawn, spawnSync } from 'node:child_process'
|
|
4
5
|
import { logger } from '../../logger.js'
|
|
5
6
|
import { confirmManager } from '../../confirm.js'
|
|
@@ -31,6 +32,15 @@ function resolveAiConfig(cli, name) {
|
|
|
31
32
|
return config
|
|
32
33
|
}
|
|
33
34
|
|
|
35
|
+
function expandHomePath(input) {
|
|
36
|
+
const raw = String(input ?? '')
|
|
37
|
+
if (raw === '~') return homedir()
|
|
38
|
+
if (raw.startsWith('~/') || raw.startsWith('~\\')) {
|
|
39
|
+
return resolve(homedir(), raw.slice(2))
|
|
40
|
+
}
|
|
41
|
+
return raw
|
|
42
|
+
}
|
|
43
|
+
|
|
34
44
|
export async function handleAi(cli, args = []) {
|
|
35
45
|
const name = args[0]
|
|
36
46
|
if (!name) {
|
|
@@ -70,7 +80,7 @@ export async function handleAi(cli, args = []) {
|
|
|
70
80
|
return
|
|
71
81
|
}
|
|
72
82
|
|
|
73
|
-
const promptPath = resolve(process.cwd(),
|
|
83
|
+
const promptPath = resolve(process.cwd(), expandHomePath(promptFile))
|
|
74
84
|
if (!existsSync(promptPath)) {
|
|
75
85
|
logger.error(`未找到提示词文件: ${promptFile}`)
|
|
76
86
|
logger.info(`解析后的路径: ${promptPath}`)
|