u-foo 1.0.6 → 1.1.9
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 +44 -4
- package/SKILLS/ufoo/SKILL.md +17 -2
- package/SKILLS/uinit/SKILL.md +8 -3
- package/bin/ucode-core.js +15 -0
- package/bin/ucode.js +125 -0
- package/bin/ufoo-assistant-agent.js +5 -0
- package/bin/ufoo-engine.js +25 -0
- package/bin/ufoo.js +4 -0
- package/modules/AGENTS.template.md +14 -4
- package/modules/bus/README.md +8 -5
- package/modules/bus/SKILLS/ubus/SKILL.md +5 -4
- package/modules/context/SKILLS/uctx/SKILL.md +3 -1
- package/modules/online/SKILLS/ufoo-online/SKILL.md +144 -0
- package/package.json +12 -3
- package/scripts/import-pi-mono.js +124 -0
- package/scripts/postinstall.js +20 -49
- package/scripts/sync-claude-skills.sh +21 -0
- package/src/agent/cliRunner.js +524 -31
- package/src/agent/internalRunner.js +76 -9
- package/src/agent/launcher.js +97 -45
- package/src/agent/normalizeOutput.js +1 -1
- package/src/agent/notifier.js +144 -4
- package/src/agent/ptyRunner.js +480 -10
- package/src/agent/ptyWrapper.js +28 -3
- package/src/agent/readyDetector.js +16 -0
- package/src/agent/ucode.js +443 -0
- package/src/agent/ucodeBootstrap.js +113 -0
- package/src/agent/ucodeBuild.js +67 -0
- package/src/agent/ucodeDoctor.js +184 -0
- package/src/agent/ucodeRuntimeConfig.js +129 -0
- package/src/agent/ufooAgent.js +11 -2
- package/src/assistant/agent.js +260 -0
- package/src/assistant/bridge.js +172 -0
- package/src/assistant/engine.js +252 -0
- package/src/assistant/stdio.js +58 -0
- package/src/assistant/ufooEngineCli.js +306 -0
- package/src/bus/activate.js +27 -11
- package/src/bus/daemon.js +133 -5
- package/src/bus/index.js +137 -80
- package/src/bus/inject.js +47 -17
- package/src/bus/message.js +145 -17
- package/src/bus/nickname.js +3 -1
- package/src/bus/queue.js +6 -1
- package/src/bus/store.js +189 -0
- package/src/bus/subscriber.js +20 -4
- package/src/bus/utils.js +9 -3
- package/src/chat/agentBar.js +117 -0
- package/src/chat/agentDirectory.js +88 -0
- package/src/chat/agentSockets.js +225 -0
- package/src/chat/agentViewController.js +298 -0
- package/src/chat/chatLogController.js +115 -0
- package/src/chat/commandExecutor.js +700 -0
- package/src/chat/commands.js +132 -0
- package/src/chat/completionController.js +414 -0
- package/src/chat/cronScheduler.js +160 -0
- package/src/chat/daemonConnection.js +166 -0
- package/src/chat/daemonCoordinator.js +64 -0
- package/src/chat/daemonMessageRouter.js +257 -0
- package/src/chat/daemonReconnect.js +41 -0
- package/src/chat/daemonTransport.js +36 -0
- package/src/chat/daemonTransportDefaults.js +10 -0
- package/src/chat/dashboardKeyController.js +480 -0
- package/src/chat/dashboardView.js +154 -0
- package/src/chat/index.js +935 -2909
- package/src/chat/inputHistoryController.js +105 -0
- package/src/chat/inputListenerController.js +304 -0
- package/src/chat/inputMath.js +104 -0
- package/src/chat/inputSubmitHandler.js +171 -0
- package/src/chat/layout.js +165 -0
- package/src/chat/pasteController.js +81 -0
- package/src/chat/rawKeyMap.js +42 -0
- package/src/chat/settingsController.js +132 -0
- package/src/chat/statusLineController.js +177 -0
- package/src/chat/streamTracker.js +138 -0
- package/src/chat/text.js +70 -0
- package/src/chat/transport.js +61 -0
- package/src/cli/busCoreCommands.js +59 -0
- package/src/cli/ctxCoreCommands.js +199 -0
- package/src/cli/onlineCoreCommands.js +379 -0
- package/src/cli.js +741 -238
- package/src/code/README.md +29 -0
- package/src/code/UCODE_PROMPT.md +32 -0
- package/src/code/agent.js +1651 -0
- package/src/code/cli.js +158 -0
- package/src/code/config +0 -0
- package/src/code/dispatch.js +42 -0
- package/src/code/index.js +70 -0
- package/src/code/nativeRunner.js +1213 -0
- package/src/code/runtime.js +154 -0
- package/src/code/sessionStore.js +162 -0
- package/src/code/taskDecomposer.js +269 -0
- package/src/code/tools/bash.js +53 -0
- package/src/code/tools/common.js +42 -0
- package/src/code/tools/edit.js +70 -0
- package/src/code/tools/read.js +44 -0
- package/src/code/tools/write.js +35 -0
- package/src/code/tui.js +1580 -0
- package/src/config.js +47 -1
- package/src/context/decisions.js +12 -2
- package/src/context/index.js +18 -1
- package/src/context/sync.js +127 -0
- package/src/daemon/agentProcessManager.js +74 -0
- package/src/daemon/cronOps.js +241 -0
- package/src/daemon/index.js +661 -488
- package/src/daemon/ipcServer.js +99 -0
- package/src/daemon/ops.js +417 -179
- package/src/daemon/promptLoop.js +319 -0
- package/src/daemon/promptRequest.js +101 -0
- package/src/daemon/providerSessions.js +32 -17
- package/src/daemon/reporting.js +90 -0
- package/src/daemon/run.js +2 -5
- package/src/daemon/status.js +24 -1
- package/src/init/index.js +68 -14
- package/src/online/bridge.js +663 -0
- package/src/online/client.js +245 -0
- package/src/online/runner.js +253 -0
- package/src/online/server.js +992 -0
- package/src/online/tokens.js +103 -0
- package/src/report/store.js +331 -0
- package/src/shared/eventContract.js +35 -0
- package/src/shared/ptySocketContract.js +21 -0
- package/src/status/index.js +50 -17
- package/src/terminal/adapterContract.js +87 -0
- package/src/terminal/adapterRouter.js +84 -0
- package/src/terminal/adapters/externalAdapter.js +14 -0
- package/src/terminal/adapters/internalAdapter.js +13 -0
- package/src/terminal/adapters/internalPtyAdapter.js +42 -0
- package/src/terminal/adapters/internalQueueAdapter.js +37 -0
- package/src/terminal/adapters/terminalAdapter.js +31 -0
- package/src/terminal/adapters/tmuxAdapter.js +30 -0
- package/src/ufoo/agentsStore.js +69 -3
- package/src/utils/banner.js +5 -2
- package/scripts/.archived/bash-to-js-migration/README.md +0 -46
- package/scripts/.archived/bash-to-js-migration/banner.sh +0 -89
- package/scripts/.archived/bash-to-js-migration/bus-alert.sh +0 -6
- package/scripts/.archived/bash-to-js-migration/bus-autotrigger.sh +0 -6
- package/scripts/.archived/bash-to-js-migration/bus-daemon.sh +0 -231
- package/scripts/.archived/bash-to-js-migration/bus-inject.sh +0 -176
- package/scripts/.archived/bash-to-js-migration/bus-listen.sh +0 -6
- package/scripts/.archived/bash-to-js-migration/bus.sh +0 -986
- package/scripts/.archived/bash-to-js-migration/context-decisions.sh +0 -167
- package/scripts/.archived/bash-to-js-migration/context-doctor.sh +0 -72
- package/scripts/.archived/bash-to-js-migration/context-lint.sh +0 -110
- package/scripts/.archived/bash-to-js-migration/doctor.sh +0 -22
- package/scripts/.archived/bash-to-js-migration/init.sh +0 -247
- package/scripts/.archived/bash-to-js-migration/skills.sh +0 -113
- package/scripts/.archived/bash-to-js-migration/status.sh +0 -125
- package/scripts/banner.sh +0 -2
- package/src/bus/API_DESIGN.md +0 -204
package/src/code/cli.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
const {
|
|
2
|
+
submitTask,
|
|
3
|
+
runOnce,
|
|
4
|
+
listResults,
|
|
5
|
+
} = require("./runtime");
|
|
6
|
+
const { runUcodeCoreAgent } = require("./agent");
|
|
7
|
+
|
|
8
|
+
function parseArgs(argv = []) {
|
|
9
|
+
const args = Array.isArray(argv) ? argv.slice() : [];
|
|
10
|
+
const out = {
|
|
11
|
+
command: String(args[0] || "").trim().toLowerCase(),
|
|
12
|
+
json: false,
|
|
13
|
+
tool: "",
|
|
14
|
+
argsJson: "",
|
|
15
|
+
workspace: "",
|
|
16
|
+
max: 1,
|
|
17
|
+
num: 20,
|
|
18
|
+
taskId: "",
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
for (let i = 1; i < args.length; i += 1) {
|
|
22
|
+
const item = String(args[i] || "").trim();
|
|
23
|
+
if (!item) continue;
|
|
24
|
+
if (item === "--json") {
|
|
25
|
+
out.json = true;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (item === "--tool") {
|
|
29
|
+
out.tool = String(args[i + 1] || "").trim();
|
|
30
|
+
i += 1;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (item === "--args-json") {
|
|
34
|
+
out.argsJson = String(args[i + 1] || "");
|
|
35
|
+
i += 1;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (item === "--workspace") {
|
|
39
|
+
out.workspace = String(args[i + 1] || "").trim();
|
|
40
|
+
i += 1;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (item === "--max") {
|
|
44
|
+
const parsed = Number(args[i + 1]);
|
|
45
|
+
if (Number.isFinite(parsed)) out.max = parsed;
|
|
46
|
+
i += 1;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (item === "--num") {
|
|
50
|
+
const parsed = Number(args[i + 1]);
|
|
51
|
+
if (Number.isFinite(parsed)) out.num = parsed;
|
|
52
|
+
i += 1;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (item === "--task-id") {
|
|
56
|
+
out.taskId = String(args[i + 1] || "").trim();
|
|
57
|
+
i += 1;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function usage() {
|
|
65
|
+
return [
|
|
66
|
+
"ucode-core native runtime CLI",
|
|
67
|
+
"",
|
|
68
|
+
"Commands:",
|
|
69
|
+
" submit --tool <read|write|edit|bash> --args-json <json> [--workspace <path>] [--task-id <id>]",
|
|
70
|
+
" run-once [--max <n>] [--workspace <path>]",
|
|
71
|
+
" list [--num <n>]",
|
|
72
|
+
"",
|
|
73
|
+
"Flags:",
|
|
74
|
+
" --json Output JSON",
|
|
75
|
+
].join("\n");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function parseArgsJson(text = "") {
|
|
79
|
+
const raw = String(text || "").trim();
|
|
80
|
+
if (!raw) return {};
|
|
81
|
+
try {
|
|
82
|
+
const parsed = JSON.parse(raw);
|
|
83
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
|
|
84
|
+
return parsed;
|
|
85
|
+
} catch {
|
|
86
|
+
throw new Error("invalid --args-json payload");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function runUcodeCoreCli({
|
|
91
|
+
argv = process.argv.slice(2),
|
|
92
|
+
projectRoot = process.cwd(),
|
|
93
|
+
} = {}) {
|
|
94
|
+
const options = parseArgs(argv);
|
|
95
|
+
const cmd = options.command || "help";
|
|
96
|
+
|
|
97
|
+
if (cmd === "help" || cmd === "--help" || cmd === "-h") {
|
|
98
|
+
return { exitCode: 0, output: `${usage()}\n` };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (cmd === "agent") {
|
|
102
|
+
await runUcodeCoreAgent({
|
|
103
|
+
workspaceRoot: projectRoot,
|
|
104
|
+
});
|
|
105
|
+
return { exitCode: 0, output: "" };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (cmd === "submit") {
|
|
109
|
+
if (!options.tool) {
|
|
110
|
+
return { exitCode: 1, output: "missing --tool\n" };
|
|
111
|
+
}
|
|
112
|
+
let args = {};
|
|
113
|
+
try {
|
|
114
|
+
args = parseArgsJson(options.argsJson);
|
|
115
|
+
} catch (err) {
|
|
116
|
+
return { exitCode: 1, output: `${err.message}\n` };
|
|
117
|
+
}
|
|
118
|
+
const task = submitTask(projectRoot, {
|
|
119
|
+
tool: options.tool,
|
|
120
|
+
args,
|
|
121
|
+
workspace_root: options.workspace || "",
|
|
122
|
+
task_id: options.taskId || "",
|
|
123
|
+
});
|
|
124
|
+
if (options.json) {
|
|
125
|
+
return { exitCode: 0, output: `${JSON.stringify({ ok: true, task })}\n` };
|
|
126
|
+
}
|
|
127
|
+
return { exitCode: 0, output: `submitted ${task.task_id}\n` };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (cmd === "run-once") {
|
|
131
|
+
const result = runOnce(projectRoot, {
|
|
132
|
+
maxTasks: options.max,
|
|
133
|
+
workspaceRoot: options.workspace || "",
|
|
134
|
+
});
|
|
135
|
+
if (options.json) {
|
|
136
|
+
return { exitCode: 0, output: `${JSON.stringify({ ok: true, ...result })}\n` };
|
|
137
|
+
}
|
|
138
|
+
return { exitCode: 0, output: `processed ${result.processed}, offset=${result.offset}\n` };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (cmd === "list") {
|
|
142
|
+
const rows = listResults(projectRoot, { num: options.num });
|
|
143
|
+
if (options.json) {
|
|
144
|
+
return { exitCode: 0, output: `${JSON.stringify({ ok: true, results: rows })}\n` };
|
|
145
|
+
}
|
|
146
|
+
const lines = rows.map((row) => `${row.task_id || "-"} ${row.tool || "-"} ${row.ok === false ? "error" : "ok"}`);
|
|
147
|
+
return { exitCode: 0, output: `${lines.join("\n")}${lines.length ? "\n" : ""}` };
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return { exitCode: 1, output: `unknown command: ${cmd}\n` };
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
module.exports = {
|
|
154
|
+
parseArgs,
|
|
155
|
+
usage,
|
|
156
|
+
parseArgsJson,
|
|
157
|
+
runUcodeCoreCli,
|
|
158
|
+
};
|
package/src/code/config
ADDED
|
File without changes
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const { runReadTool } = require("./tools/read");
|
|
2
|
+
const { runWriteTool } = require("./tools/write");
|
|
3
|
+
const { runEditTool } = require("./tools/edit");
|
|
4
|
+
const { runBashTool } = require("./tools/bash");
|
|
5
|
+
|
|
6
|
+
const TOOL_NAMES = ["read", "write", "edit", "bash"];
|
|
7
|
+
|
|
8
|
+
function normalizeToolName(value = "") {
|
|
9
|
+
const text = String(value || "").trim().toLowerCase();
|
|
10
|
+
if (text === "read") return "read";
|
|
11
|
+
if (text === "write") return "write";
|
|
12
|
+
if (text === "edit") return "edit";
|
|
13
|
+
if (text === "bash") return "bash";
|
|
14
|
+
return "";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function runToolCall(input = {}, options = {}) {
|
|
18
|
+
const tool = normalizeToolName(input.tool || input.name);
|
|
19
|
+
const args = input.args && typeof input.args === "object" ? input.args : {};
|
|
20
|
+
if (!tool) {
|
|
21
|
+
return {
|
|
22
|
+
ok: false,
|
|
23
|
+
error: "unknown tool",
|
|
24
|
+
supported_tools: TOOL_NAMES.slice(),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (tool === "read") return runReadTool(args, options);
|
|
28
|
+
if (tool === "write") return runWriteTool(args, options);
|
|
29
|
+
if (tool === "edit") return runEditTool(args, options);
|
|
30
|
+
if (tool === "bash") return runBashTool(args, options);
|
|
31
|
+
return {
|
|
32
|
+
ok: false,
|
|
33
|
+
error: "unknown tool",
|
|
34
|
+
supported_tools: TOOL_NAMES.slice(),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = {
|
|
39
|
+
TOOL_NAMES,
|
|
40
|
+
normalizeToolName,
|
|
41
|
+
runToolCall,
|
|
42
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const { TOOL_NAMES, normalizeToolName, runToolCall } = require("./dispatch");
|
|
2
|
+
const { runReadTool } = require("./tools/read");
|
|
3
|
+
const { runWriteTool } = require("./tools/write");
|
|
4
|
+
const { runEditTool } = require("./tools/edit");
|
|
5
|
+
const { runBashTool } = require("./tools/bash");
|
|
6
|
+
const {
|
|
7
|
+
getRuntimePaths,
|
|
8
|
+
ensureRuntimeDir,
|
|
9
|
+
parseJsonLines,
|
|
10
|
+
loadState,
|
|
11
|
+
saveState,
|
|
12
|
+
submitTask,
|
|
13
|
+
runOnce,
|
|
14
|
+
listResults,
|
|
15
|
+
} = require("./runtime");
|
|
16
|
+
const { parseArgs, usage, parseArgsJson, runUcodeCoreCli } = require("./cli");
|
|
17
|
+
const {
|
|
18
|
+
runUcodeCoreAgent,
|
|
19
|
+
runSingleCommand,
|
|
20
|
+
runNaturalLanguageTask,
|
|
21
|
+
formatNlResult,
|
|
22
|
+
resolvePlannerProvider,
|
|
23
|
+
parseAgentArgs,
|
|
24
|
+
} = require("./agent");
|
|
25
|
+
const {
|
|
26
|
+
getSessionsDir,
|
|
27
|
+
normalizeSessionId,
|
|
28
|
+
createSessionId,
|
|
29
|
+
resolveSessionId,
|
|
30
|
+
buildSessionSnapshot,
|
|
31
|
+
getSessionFilePath,
|
|
32
|
+
saveSessionSnapshot,
|
|
33
|
+
loadSessionSnapshot,
|
|
34
|
+
} = require("./sessionStore");
|
|
35
|
+
|
|
36
|
+
module.exports = {
|
|
37
|
+
TOOL_NAMES,
|
|
38
|
+
normalizeToolName,
|
|
39
|
+
runToolCall,
|
|
40
|
+
runReadTool,
|
|
41
|
+
runWriteTool,
|
|
42
|
+
runEditTool,
|
|
43
|
+
runBashTool,
|
|
44
|
+
getRuntimePaths,
|
|
45
|
+
ensureRuntimeDir,
|
|
46
|
+
parseJsonLines,
|
|
47
|
+
loadState,
|
|
48
|
+
saveState,
|
|
49
|
+
submitTask,
|
|
50
|
+
runOnce,
|
|
51
|
+
listResults,
|
|
52
|
+
parseArgs,
|
|
53
|
+
usage,
|
|
54
|
+
parseArgsJson,
|
|
55
|
+
runUcodeCoreCli,
|
|
56
|
+
runUcodeCoreAgent,
|
|
57
|
+
runSingleCommand,
|
|
58
|
+
runNaturalLanguageTask,
|
|
59
|
+
formatNlResult,
|
|
60
|
+
resolvePlannerProvider,
|
|
61
|
+
parseAgentArgs,
|
|
62
|
+
getSessionsDir,
|
|
63
|
+
normalizeSessionId,
|
|
64
|
+
createSessionId,
|
|
65
|
+
resolveSessionId,
|
|
66
|
+
buildSessionSnapshot,
|
|
67
|
+
getSessionFilePath,
|
|
68
|
+
saveSessionSnapshot,
|
|
69
|
+
loadSessionSnapshot,
|
|
70
|
+
};
|