u-foo 1.0.0 → 1.0.2
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 +4 -3
- package/package.json +1 -1
- package/src/chat/index.js +40 -10
package/README.md
CHANGED
|
@@ -139,12 +139,13 @@ Built-in skills triggered by slash commands:
|
|
|
139
139
|
|
|
140
140
|
## Codex CLI Notes
|
|
141
141
|
|
|
142
|
-
|
|
142
|
+
`ufoo chat` automatically starts the daemon if not running - no need to run `ufoo daemon start` separately.
|
|
143
|
+
|
|
144
|
+
If Codex CLI fails with permission errors under `~/.codex` (e.g. sessions dir), set `CODEX_HOME` to a writable path:
|
|
143
145
|
|
|
144
146
|
```bash
|
|
145
147
|
export CODEX_HOME="$PWD/.ufoo/codex"
|
|
146
|
-
ufoo daemon
|
|
147
|
-
ufoo chat
|
|
148
|
+
ufoo chat # daemon auto-starts
|
|
148
149
|
```
|
|
149
150
|
|
|
150
151
|
## Development
|
package/package.json
CHANGED
package/src/chat/index.js
CHANGED
|
@@ -13,8 +13,15 @@ function connectSocket(sockPath) {
|
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
function resolveProjectFile(projectRoot, relativePath, fallbackRelativePath) {
|
|
17
|
+
const local = path.join(projectRoot, relativePath);
|
|
18
|
+
if (fs.existsSync(local)) return local;
|
|
19
|
+
return path.join(__dirname, "..", "..", fallbackRelativePath);
|
|
20
|
+
}
|
|
21
|
+
|
|
16
22
|
function startDaemon(projectRoot) {
|
|
17
|
-
const
|
|
23
|
+
const daemonBin = resolveProjectFile(projectRoot, path.join("bin", "ufoo.js"), path.join("bin", "ufoo.js"));
|
|
24
|
+
const child = spawn(process.execPath, [daemonBin, "daemon", "--start"], {
|
|
18
25
|
detached: true,
|
|
19
26
|
stdio: "ignore",
|
|
20
27
|
cwd: projectRoot,
|
|
@@ -22,9 +29,24 @@ function startDaemon(projectRoot) {
|
|
|
22
29
|
child.unref();
|
|
23
30
|
}
|
|
24
31
|
|
|
32
|
+
async function connectWithRetry(sockPath, retries, delayMs) {
|
|
33
|
+
for (let i = 0; i < retries; i += 1) {
|
|
34
|
+
try {
|
|
35
|
+
// eslint-disable-next-line no-await-in-loop
|
|
36
|
+
const client = await connectSocket(sockPath);
|
|
37
|
+
return client;
|
|
38
|
+
} catch {
|
|
39
|
+
// eslint-disable-next-line no-await-in-loop
|
|
40
|
+
await new Promise((r) => setTimeout(r, delayMs));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
25
46
|
async function runChat(projectRoot) {
|
|
26
47
|
if (!fs.existsSync(path.join(projectRoot, ".ufoo"))) {
|
|
27
|
-
|
|
48
|
+
const initScript = resolveProjectFile(projectRoot, path.join("scripts", "init.sh"), path.join("scripts", "init.sh"));
|
|
49
|
+
spawnSync("bash", [initScript, "--modules", "context,bus", "--project", projectRoot], {
|
|
28
50
|
stdio: "inherit",
|
|
29
51
|
});
|
|
30
52
|
}
|
|
@@ -33,16 +55,24 @@ async function runChat(projectRoot) {
|
|
|
33
55
|
}
|
|
34
56
|
|
|
35
57
|
const sock = socketPath(projectRoot);
|
|
36
|
-
let client =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} catch {
|
|
42
|
-
await new Promise((r) => setTimeout(r, 200));
|
|
58
|
+
let client = await connectWithRetry(sock, 25, 200);
|
|
59
|
+
if (!client) {
|
|
60
|
+
// Retry once with a fresh daemon start and longer wait.
|
|
61
|
+
if (!isRunning(projectRoot)) {
|
|
62
|
+
startDaemon(projectRoot);
|
|
43
63
|
}
|
|
64
|
+
client = await connectWithRetry(sock, 50, 200);
|
|
65
|
+
}
|
|
66
|
+
if (!client) {
|
|
67
|
+
// Check if daemon failed to start
|
|
68
|
+
if (!isRunning(projectRoot)) {
|
|
69
|
+
const logFile = path.join(projectRoot, ".ufoo", "run", "ufoo-daemon.log");
|
|
70
|
+
// eslint-disable-next-line no-console
|
|
71
|
+
console.error("Failed to start ufoo daemon. Check logs at:", logFile);
|
|
72
|
+
throw new Error("Daemon failed to start. Check the daemon log for details.");
|
|
73
|
+
}
|
|
74
|
+
throw new Error("Failed to connect to ufoo daemon (timeout). The daemon may still be starting.");
|
|
44
75
|
}
|
|
45
|
-
if (!client) throw new Error("Failed to connect to ufoo daemon");
|
|
46
76
|
|
|
47
77
|
const screen = blessed.screen({
|
|
48
78
|
smartCSR: true,
|