u-foo 1.2.10 → 1.2.11
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/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/package.json +1 -1
- package/src/agent/ucodeRuntimeConfig.js +6 -2
- package/src/config.js +16 -1
package/README.md
CHANGED
|
@@ -156,7 +156,7 @@ Configure AI providers in `.ufoo/config.json`:
|
|
|
156
156
|
}
|
|
157
157
|
```
|
|
158
158
|
|
|
159
|
-
`ucode` writes these into a
|
|
159
|
+
`ucode` writes these into a global config directory (`~/.ufoo/agent/ucode/config`) and uses them for native planner/engine calls. Configure once, use across all projects. Project-level `.ufoo/config.json` can override global settings when needed.
|
|
160
160
|
|
|
161
161
|
## Architecture
|
|
162
162
|
|
package/README.zh-CN.md
CHANGED
|
@@ -156,7 +156,7 @@ ucode-core list --json
|
|
|
156
156
|
}
|
|
157
157
|
```
|
|
158
158
|
|
|
159
|
-
`ucode`
|
|
159
|
+
`ucode` 会将配置写入全局目录(`~/.ufoo/agent/ucode/config`),用于原生 planner/engine 调用。配置一次,所有项目通用。项目级 `.ufoo/config.json` 可按需覆盖全局配置。
|
|
160
160
|
|
|
161
161
|
## 架构
|
|
162
162
|
|
package/package.json
CHANGED
|
@@ -30,7 +30,9 @@ function resolveRuntimeValues({
|
|
|
30
30
|
const model = String(env.UFOO_UCODE_MODEL || config.ucodeModel || "").trim();
|
|
31
31
|
const apiKey = String(env.UFOO_UCODE_API_KEY || config.ucodeApiKey || "").trim();
|
|
32
32
|
const baseUrl = String(env.UFOO_UCODE_BASE_URL || config.ucodeBaseUrl || "").trim();
|
|
33
|
-
const
|
|
33
|
+
const os = require("os");
|
|
34
|
+
const globalDefault = path.join(os.homedir(), ".ufoo", "agent", "ucode", "config");
|
|
35
|
+
const projectDefault = path.join(root, ".ufoo", "agent", "ucode", "config");
|
|
34
36
|
const legacyDefault = path.join(root, ".ufoo", "agent", "ucode", "pi-agent");
|
|
35
37
|
const agentDir = path.resolve(
|
|
36
38
|
String(
|
|
@@ -38,7 +40,9 @@ function resolveRuntimeValues({
|
|
|
38
40
|
|| env.PI_CODING_AGENT_DIR
|
|
39
41
|
|| env.UFOO_UCODE_AGENT_DIR
|
|
40
42
|
|| config.ucodeAgentDir
|
|
41
|
-
|| (fs.existsSync(legacyDefault)
|
|
43
|
+
|| (fs.existsSync(legacyDefault) ? legacyDefault
|
|
44
|
+
: fs.existsSync(projectDefault) ? projectDefault
|
|
45
|
+
: globalDefault)
|
|
42
46
|
).trim()
|
|
43
47
|
);
|
|
44
48
|
return {
|
package/src/config.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const fs = require("fs");
|
|
2
|
+
const os = require("os");
|
|
2
3
|
const path = require("path");
|
|
3
4
|
|
|
4
5
|
const DEFAULT_CONFIG = {
|
|
@@ -39,13 +40,27 @@ function normalizeAssistantEngine(value) {
|
|
|
39
40
|
return "auto";
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
function globalConfigPath() {
|
|
44
|
+
return path.join(os.homedir(), ".ufoo", "config.json");
|
|
45
|
+
}
|
|
46
|
+
|
|
42
47
|
function configPath(projectRoot) {
|
|
43
48
|
return path.join(projectRoot, ".ufoo", "config.json");
|
|
44
49
|
}
|
|
45
50
|
|
|
51
|
+
function loadJsonSafe(filePath) {
|
|
52
|
+
try {
|
|
53
|
+
return JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
54
|
+
} catch {
|
|
55
|
+
return {};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
46
59
|
function loadConfig(projectRoot) {
|
|
47
60
|
try {
|
|
48
|
-
const
|
|
61
|
+
const globalRaw = loadJsonSafe(globalConfigPath());
|
|
62
|
+
const projectRaw = loadJsonSafe(configPath(projectRoot));
|
|
63
|
+
const raw = { ...globalRaw, ...projectRaw };
|
|
49
64
|
return {
|
|
50
65
|
...DEFAULT_CONFIG,
|
|
51
66
|
...raw,
|