u-foo 2.3.30 → 2.3.32
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 +5 -1
- package/scripts/chat-app-smoke.js +30 -0
- package/scripts/ink-demo.js +23 -0
- package/scripts/ink-smoke.js +30 -0
- package/scripts/ucode-app-smoke.js +36 -0
- package/src/chat/commandExecutor.js +6 -2
- package/src/chat/daemonMessageRouter.js +9 -1
- package/src/chat/daemonTransport.js +2 -1
- package/src/chat/dashboardKeyController.js +0 -40
- package/src/chat/dashboardView.js +0 -20
- package/src/chat/index.js +9 -1
- package/src/chat/inputSubmitHandler.js +34 -0
- package/src/chat/projectCloseController.js +1 -1
- package/src/chat/shellCommand.js +42 -0
- package/src/chat/transport.js +16 -3
- package/src/cli.js +4 -3
- package/src/code/agent.js +4 -0
- package/src/code/nativeRunner.js +74 -0
- package/src/code/taskDecomposer.js +5 -4
- package/src/code/tui.js +73 -561
- package/src/daemon/index.js +169 -27
- package/src/daemon/ipcServer.js +23 -1
- package/src/daemon/promptRequest.js +6 -1
- package/src/daemon/run.js +11 -4
- package/src/projects/runtimes.js +1 -1
- package/src/ufoo/agentRegistryDiagnostics.js +43 -0
- package/src/ui/MIGRATION.md +382 -0
- package/src/ui/components/ChatApp.js +2950 -0
- package/src/ui/components/DashboardBar.js +417 -0
- package/src/ui/components/InkDemo.js +96 -0
- package/src/ui/components/MultilineInput.js +387 -0
- package/src/ui/components/UcodeApp.js +813 -0
- package/src/ui/components/agentMirror.js +725 -0
- package/src/ui/components/chatReducer.js +337 -0
- package/src/ui/format/index.js +997 -0
- package/src/ui/index.js +9 -0
- package/src/ui/runInk.js +57 -0
- package/src/utils/nodeExecutable.js +26 -0
package/src/ui/index.js
ADDED
package/src/ui/runInk.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Ink runtime launcher for ufoo TUIs.
|
|
5
|
+
*
|
|
6
|
+
* ufoo is CommonJS, ink@5 is ESM-only. We bridge by dynamic-importing ink
|
|
7
|
+
* and exposing a CJS-friendly API that takes a `createRoot(React, ink)`
|
|
8
|
+
* factory instead of a pre-built React element. The factory is invoked with
|
|
9
|
+
* the loaded `React` module and ink namespace so callers don't need to
|
|
10
|
+
* import them themselves.
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* const { runInk } = require("./runInk");
|
|
14
|
+
* const handle = await runInk(
|
|
15
|
+
* (React, ink) => React.createElement(App, props),
|
|
16
|
+
* { stdin, stdout },
|
|
17
|
+
* );
|
|
18
|
+
* await handle.waitUntilExit();
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
async function runInk(createRoot, options = {}) {
|
|
22
|
+
const ink = await import("ink");
|
|
23
|
+
const React = require("react");
|
|
24
|
+
const element = createRoot(React, ink);
|
|
25
|
+
if (!element) throw new Error("runInk: createRoot returned no element");
|
|
26
|
+
const stdout = options.stdout || process.stdout;
|
|
27
|
+
const inst = ink.render(element, {
|
|
28
|
+
stdin: options.stdin || process.stdin,
|
|
29
|
+
stdout,
|
|
30
|
+
stderr: options.stderr || process.stderr,
|
|
31
|
+
exitOnCtrlC: options.exitOnCtrlC !== false,
|
|
32
|
+
patchConsole: options.patchConsole === true,
|
|
33
|
+
});
|
|
34
|
+
// ink keeps the final rendered frame on screen when it unmounts (it writes
|
|
35
|
+
// the frame as plain stdout output), which leaves the TUI lingering after
|
|
36
|
+
// Ctrl+C. Clear and home the cursor on every clean exit so the shell prompt
|
|
37
|
+
// returns to the top of a blank screen.
|
|
38
|
+
const wrappedExit = inst.waitUntilExit().then((value) => {
|
|
39
|
+
try {
|
|
40
|
+
if (stdout && stdout.isTTY && typeof stdout.write === "function") {
|
|
41
|
+
stdout.write("\x1b[2J\x1b[H");
|
|
42
|
+
}
|
|
43
|
+
} catch { /* ignore */ }
|
|
44
|
+
return value;
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
waitUntilExit: () => wrappedExit,
|
|
48
|
+
rerender: (next) => inst.rerender(next),
|
|
49
|
+
unmount: () => inst.unmount(),
|
|
50
|
+
cleanup: () => inst.cleanup(),
|
|
51
|
+
instance: inst,
|
|
52
|
+
React,
|
|
53
|
+
ink,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module.exports = { runInk };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
|
|
5
|
+
function resolveNodeExecutable(options = {}) {
|
|
6
|
+
const {
|
|
7
|
+
execPath = process.execPath,
|
|
8
|
+
env = process.env,
|
|
9
|
+
fsModule = fs,
|
|
10
|
+
} = options;
|
|
11
|
+
const override = String((env && env.UFOO_NODE_EXECUTABLE) || "").trim();
|
|
12
|
+
if (override) return override;
|
|
13
|
+
const current = String(execPath || "").trim();
|
|
14
|
+
if (current) {
|
|
15
|
+
try {
|
|
16
|
+
if (fsModule.existsSync(current)) return current;
|
|
17
|
+
} catch {
|
|
18
|
+
// Fall through to PATH lookup.
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return "node";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = {
|
|
25
|
+
resolveNodeExecutable,
|
|
26
|
+
};
|