@promus/cli 0.24.23 → 0.24.25
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/package.json +1 -1
- package/src/commands/init.ts +14 -1
- package/src/config/load.ts +10 -0
- package/src/index.ts +4 -0
package/package.json
CHANGED
package/src/commands/init.ts
CHANGED
|
@@ -48,7 +48,20 @@ import { pickOperatorSigner } from './init/operator-picker'
|
|
|
48
48
|
import { initialWizardState, updateWizardState, writeWizardState } from './init/wizard-state'
|
|
49
49
|
|
|
50
50
|
export async function runInit(opts?: { cwd?: string; resume?: boolean }): Promise<void> {
|
|
51
|
-
const
|
|
51
|
+
const globalConfig = agentPaths.config
|
|
52
|
+
const localConfig = join(process.cwd(), 'promus.config.ts')
|
|
53
|
+
// Use local config if it exists, else global, else create in cwd
|
|
54
|
+
const configPath = existsSync(localConfig)
|
|
55
|
+
? localConfig
|
|
56
|
+
: existsSync(globalConfig)
|
|
57
|
+
? globalConfig
|
|
58
|
+
: localConfig
|
|
59
|
+
|
|
60
|
+
// When init creates a config in cwd, set PROMUS_ROOT so agent data
|
|
61
|
+
// (keystore, sessions, etc.) also lives in cwd.
|
|
62
|
+
if (configPath === localConfig && !process.env.PROMUS_ROOT) {
|
|
63
|
+
process.env.PROMUS_ROOT = process.cwd()
|
|
64
|
+
}
|
|
52
65
|
|
|
53
66
|
intro('promus init')
|
|
54
67
|
|
package/src/config/load.ts
CHANGED
|
@@ -13,6 +13,15 @@ import { type PromusConfig, agentPaths } from '@promus/core'
|
|
|
13
13
|
export async function findAndLoadConfig(
|
|
14
14
|
startDir: string = process.cwd(),
|
|
15
15
|
): Promise<{ config: PromusConfig; path: string } | null> {
|
|
16
|
+
// 1. Check cwd first (project-local config)
|
|
17
|
+
const localCandidate = resolve(startDir, 'promus.config.ts')
|
|
18
|
+
if (existsSync(localCandidate)) {
|
|
19
|
+
const mod = (await import(localCandidate)) as { default: PromusConfig }
|
|
20
|
+
if (!mod.default) throw new Error(`promus.config.ts at ${localCandidate} has no default export`)
|
|
21
|
+
return { config: mod.default, path: localCandidate }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// 2. Fall back to global ~/.promus/config.ts
|
|
16
25
|
const canonical = agentPaths.config
|
|
17
26
|
if (existsSync(canonical)) {
|
|
18
27
|
const mod = (await import(canonical)) as { default: PromusConfig }
|
|
@@ -20,6 +29,7 @@ export async function findAndLoadConfig(
|
|
|
20
29
|
return { config: mod.default, path: canonical }
|
|
21
30
|
}
|
|
22
31
|
|
|
32
|
+
// 3. Walk upward from cwd (legacy v0.5.0 pattern)
|
|
23
33
|
let dir = resolve(startDir)
|
|
24
34
|
while (true) {
|
|
25
35
|
const candidate = resolve(dir, 'promus.config.ts')
|
package/src/index.ts
CHANGED
|
@@ -36,6 +36,10 @@ async function main(): Promise<void> {
|
|
|
36
36
|
return
|
|
37
37
|
}
|
|
38
38
|
case 'init': {
|
|
39
|
+
// `promus init .` → init in current directory
|
|
40
|
+
if (argv.includes('.')) {
|
|
41
|
+
process.env.PROMUS_ROOT = process.cwd()
|
|
42
|
+
}
|
|
39
43
|
if (argv.includes('--resume')) {
|
|
40
44
|
const { findAndLoadConfig } = await import('./config/load')
|
|
41
45
|
const loaded = await findAndLoadConfig()
|