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.
Files changed (149) hide show
  1. package/README.md +44 -4
  2. package/SKILLS/ufoo/SKILL.md +17 -2
  3. package/SKILLS/uinit/SKILL.md +8 -3
  4. package/bin/ucode-core.js +15 -0
  5. package/bin/ucode.js +125 -0
  6. package/bin/ufoo-assistant-agent.js +5 -0
  7. package/bin/ufoo-engine.js +25 -0
  8. package/bin/ufoo.js +4 -0
  9. package/modules/AGENTS.template.md +14 -4
  10. package/modules/bus/README.md +8 -5
  11. package/modules/bus/SKILLS/ubus/SKILL.md +5 -4
  12. package/modules/context/SKILLS/uctx/SKILL.md +3 -1
  13. package/modules/online/SKILLS/ufoo-online/SKILL.md +144 -0
  14. package/package.json +12 -3
  15. package/scripts/import-pi-mono.js +124 -0
  16. package/scripts/postinstall.js +20 -49
  17. package/scripts/sync-claude-skills.sh +21 -0
  18. package/src/agent/cliRunner.js +524 -31
  19. package/src/agent/internalRunner.js +76 -9
  20. package/src/agent/launcher.js +97 -45
  21. package/src/agent/normalizeOutput.js +1 -1
  22. package/src/agent/notifier.js +144 -4
  23. package/src/agent/ptyRunner.js +480 -10
  24. package/src/agent/ptyWrapper.js +28 -3
  25. package/src/agent/readyDetector.js +16 -0
  26. package/src/agent/ucode.js +443 -0
  27. package/src/agent/ucodeBootstrap.js +113 -0
  28. package/src/agent/ucodeBuild.js +67 -0
  29. package/src/agent/ucodeDoctor.js +184 -0
  30. package/src/agent/ucodeRuntimeConfig.js +129 -0
  31. package/src/agent/ufooAgent.js +11 -2
  32. package/src/assistant/agent.js +260 -0
  33. package/src/assistant/bridge.js +172 -0
  34. package/src/assistant/engine.js +252 -0
  35. package/src/assistant/stdio.js +58 -0
  36. package/src/assistant/ufooEngineCli.js +306 -0
  37. package/src/bus/activate.js +27 -11
  38. package/src/bus/daemon.js +133 -5
  39. package/src/bus/index.js +137 -80
  40. package/src/bus/inject.js +47 -17
  41. package/src/bus/message.js +145 -17
  42. package/src/bus/nickname.js +3 -1
  43. package/src/bus/queue.js +6 -1
  44. package/src/bus/store.js +189 -0
  45. package/src/bus/subscriber.js +20 -4
  46. package/src/bus/utils.js +9 -3
  47. package/src/chat/agentBar.js +117 -0
  48. package/src/chat/agentDirectory.js +88 -0
  49. package/src/chat/agentSockets.js +225 -0
  50. package/src/chat/agentViewController.js +298 -0
  51. package/src/chat/chatLogController.js +115 -0
  52. package/src/chat/commandExecutor.js +700 -0
  53. package/src/chat/commands.js +132 -0
  54. package/src/chat/completionController.js +414 -0
  55. package/src/chat/cronScheduler.js +160 -0
  56. package/src/chat/daemonConnection.js +166 -0
  57. package/src/chat/daemonCoordinator.js +64 -0
  58. package/src/chat/daemonMessageRouter.js +257 -0
  59. package/src/chat/daemonReconnect.js +41 -0
  60. package/src/chat/daemonTransport.js +36 -0
  61. package/src/chat/daemonTransportDefaults.js +10 -0
  62. package/src/chat/dashboardKeyController.js +480 -0
  63. package/src/chat/dashboardView.js +154 -0
  64. package/src/chat/index.js +935 -2909
  65. package/src/chat/inputHistoryController.js +105 -0
  66. package/src/chat/inputListenerController.js +304 -0
  67. package/src/chat/inputMath.js +104 -0
  68. package/src/chat/inputSubmitHandler.js +171 -0
  69. package/src/chat/layout.js +165 -0
  70. package/src/chat/pasteController.js +81 -0
  71. package/src/chat/rawKeyMap.js +42 -0
  72. package/src/chat/settingsController.js +132 -0
  73. package/src/chat/statusLineController.js +177 -0
  74. package/src/chat/streamTracker.js +138 -0
  75. package/src/chat/text.js +70 -0
  76. package/src/chat/transport.js +61 -0
  77. package/src/cli/busCoreCommands.js +59 -0
  78. package/src/cli/ctxCoreCommands.js +199 -0
  79. package/src/cli/onlineCoreCommands.js +379 -0
  80. package/src/cli.js +741 -238
  81. package/src/code/README.md +29 -0
  82. package/src/code/UCODE_PROMPT.md +32 -0
  83. package/src/code/agent.js +1651 -0
  84. package/src/code/cli.js +158 -0
  85. package/src/code/config +0 -0
  86. package/src/code/dispatch.js +42 -0
  87. package/src/code/index.js +70 -0
  88. package/src/code/nativeRunner.js +1213 -0
  89. package/src/code/runtime.js +154 -0
  90. package/src/code/sessionStore.js +162 -0
  91. package/src/code/taskDecomposer.js +269 -0
  92. package/src/code/tools/bash.js +53 -0
  93. package/src/code/tools/common.js +42 -0
  94. package/src/code/tools/edit.js +70 -0
  95. package/src/code/tools/read.js +44 -0
  96. package/src/code/tools/write.js +35 -0
  97. package/src/code/tui.js +1580 -0
  98. package/src/config.js +47 -1
  99. package/src/context/decisions.js +12 -2
  100. package/src/context/index.js +18 -1
  101. package/src/context/sync.js +127 -0
  102. package/src/daemon/agentProcessManager.js +74 -0
  103. package/src/daemon/cronOps.js +241 -0
  104. package/src/daemon/index.js +661 -488
  105. package/src/daemon/ipcServer.js +99 -0
  106. package/src/daemon/ops.js +417 -179
  107. package/src/daemon/promptLoop.js +319 -0
  108. package/src/daemon/promptRequest.js +101 -0
  109. package/src/daemon/providerSessions.js +32 -17
  110. package/src/daemon/reporting.js +90 -0
  111. package/src/daemon/run.js +2 -5
  112. package/src/daemon/status.js +24 -1
  113. package/src/init/index.js +68 -14
  114. package/src/online/bridge.js +663 -0
  115. package/src/online/client.js +245 -0
  116. package/src/online/runner.js +253 -0
  117. package/src/online/server.js +992 -0
  118. package/src/online/tokens.js +103 -0
  119. package/src/report/store.js +331 -0
  120. package/src/shared/eventContract.js +35 -0
  121. package/src/shared/ptySocketContract.js +21 -0
  122. package/src/status/index.js +50 -17
  123. package/src/terminal/adapterContract.js +87 -0
  124. package/src/terminal/adapterRouter.js +84 -0
  125. package/src/terminal/adapters/externalAdapter.js +14 -0
  126. package/src/terminal/adapters/internalAdapter.js +13 -0
  127. package/src/terminal/adapters/internalPtyAdapter.js +42 -0
  128. package/src/terminal/adapters/internalQueueAdapter.js +37 -0
  129. package/src/terminal/adapters/terminalAdapter.js +31 -0
  130. package/src/terminal/adapters/tmuxAdapter.js +30 -0
  131. package/src/ufoo/agentsStore.js +69 -3
  132. package/src/utils/banner.js +5 -2
  133. package/scripts/.archived/bash-to-js-migration/README.md +0 -46
  134. package/scripts/.archived/bash-to-js-migration/banner.sh +0 -89
  135. package/scripts/.archived/bash-to-js-migration/bus-alert.sh +0 -6
  136. package/scripts/.archived/bash-to-js-migration/bus-autotrigger.sh +0 -6
  137. package/scripts/.archived/bash-to-js-migration/bus-daemon.sh +0 -231
  138. package/scripts/.archived/bash-to-js-migration/bus-inject.sh +0 -176
  139. package/scripts/.archived/bash-to-js-migration/bus-listen.sh +0 -6
  140. package/scripts/.archived/bash-to-js-migration/bus.sh +0 -986
  141. package/scripts/.archived/bash-to-js-migration/context-decisions.sh +0 -167
  142. package/scripts/.archived/bash-to-js-migration/context-doctor.sh +0 -72
  143. package/scripts/.archived/bash-to-js-migration/context-lint.sh +0 -110
  144. package/scripts/.archived/bash-to-js-migration/doctor.sh +0 -22
  145. package/scripts/.archived/bash-to-js-migration/init.sh +0 -247
  146. package/scripts/.archived/bash-to-js-migration/skills.sh +0 -113
  147. package/scripts/.archived/bash-to-js-migration/status.sh +0 -125
  148. package/scripts/banner.sh +0 -2
  149. package/src/bus/API_DESIGN.md +0 -204
@@ -0,0 +1,124 @@
1
+ #!/usr/bin/env node
2
+ /* eslint-disable no-console */
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const { spawnSync } = require("child_process");
6
+
7
+ function usage() {
8
+ console.log("Usage: node scripts/import-pi-mono.js <pi-mono-source-path> [--target <target-path>]");
9
+ }
10
+
11
+ function shouldSkip(name = "") {
12
+ return name === ".git" || name === "node_modules";
13
+ }
14
+
15
+ function copyRecursive(source, target) {
16
+ const stat = fs.statSync(source);
17
+ if (stat.isDirectory()) {
18
+ fs.mkdirSync(target, { recursive: true });
19
+ const entries = fs.readdirSync(source);
20
+ for (const entry of entries) {
21
+ if (shouldSkip(entry)) continue;
22
+ copyRecursive(path.join(source, entry), path.join(target, entry));
23
+ }
24
+ return;
25
+ }
26
+ fs.mkdirSync(path.dirname(target), { recursive: true });
27
+ fs.copyFileSync(source, target);
28
+ }
29
+
30
+ function parseArgs(argv = []) {
31
+ const args = Array.isArray(argv) ? argv : [];
32
+ const parsed = {
33
+ source: "",
34
+ target: "",
35
+ help: false,
36
+ };
37
+ for (let i = 0; i < args.length; i += 1) {
38
+ const item = String(args[i] || "").trim();
39
+ if (!item) continue;
40
+ if (item === "--help" || item === "-h") {
41
+ parsed.help = true;
42
+ continue;
43
+ }
44
+ if (item === "--target" || item === "-t") {
45
+ const next = String(args[i + 1] || "").trim();
46
+ if (next) parsed.target = next;
47
+ i += 1;
48
+ continue;
49
+ }
50
+ if (!parsed.source) parsed.source = item;
51
+ }
52
+ return parsed;
53
+ }
54
+
55
+ function readGitValue(sourceRoot = "", gitArgs = []) {
56
+ try {
57
+ const res = spawnSync("git", ["-C", sourceRoot, ...gitArgs], {
58
+ encoding: "utf8",
59
+ stdio: ["ignore", "pipe", "ignore"],
60
+ });
61
+ if (res.error || res.status !== 0) return "";
62
+ return String(res.stdout || "").trim();
63
+ } catch {
64
+ return "";
65
+ }
66
+ }
67
+
68
+ function readGitMetadata(sourceRoot = "") {
69
+ return {
70
+ commit: readGitValue(sourceRoot, ["rev-parse", "HEAD"]),
71
+ branch: readGitValue(sourceRoot, ["rev-parse", "--abbrev-ref", "HEAD"]),
72
+ remote: readGitValue(sourceRoot, ["config", "--get", "remote.origin.url"]),
73
+ };
74
+ }
75
+
76
+ function main() {
77
+ const parsedArgs = parseArgs(process.argv.slice(2));
78
+ if (parsedArgs.help) {
79
+ usage();
80
+ process.exit(0);
81
+ }
82
+ const sourceArg = parsedArgs.source || "";
83
+ if (!sourceArg) {
84
+ usage();
85
+ process.exit(1);
86
+ }
87
+
88
+ const sourceRoot = path.resolve(sourceArg);
89
+ const sourcePackage = path.join(sourceRoot, "package.json");
90
+ if (!fs.existsSync(sourcePackage)) {
91
+ console.error(`Invalid source: missing package.json at ${sourceRoot}`);
92
+ process.exit(2);
93
+ }
94
+
95
+ const repoRoot = path.resolve(__dirname, "..");
96
+ const targetRoot = path.resolve(parsedArgs.target || path.join(repoRoot, "src", "code", "pi-mono"));
97
+ const backupRoot = `${targetRoot}.backup-${Date.now()}`;
98
+
99
+ if (fs.existsSync(targetRoot)) {
100
+ fs.renameSync(targetRoot, backupRoot);
101
+ console.log(`Backed up existing fork to ${backupRoot}`);
102
+ }
103
+
104
+ copyRecursive(sourceRoot, targetRoot);
105
+ const upstream = readGitMetadata(sourceRoot);
106
+
107
+ const metadata = {
108
+ imported_at: new Date().toISOString(),
109
+ source_root: sourceRoot,
110
+ target: targetRoot,
111
+ upstream_commit: upstream.commit,
112
+ upstream_branch: upstream.branch,
113
+ upstream_remote: upstream.remote,
114
+ };
115
+ fs.writeFileSync(
116
+ path.join(targetRoot, ".ufoo-import.json"),
117
+ `${JSON.stringify(metadata, null, 2)}\n`,
118
+ "utf8",
119
+ );
120
+
121
+ console.log(`Imported pi-mono into ${targetRoot}${upstream.commit ? ` @ ${upstream.commit}` : ""}`);
122
+ }
123
+
124
+ main();
@@ -1,59 +1,30 @@
1
1
  /* eslint-disable no-console */
2
2
  const path = require("path");
3
3
  const fs = require("fs");
4
- const { spawnSync } = require("child_process");
5
-
6
- function run(args) {
7
- const bin = path.join(__dirname, "..", "bin", "ufoo.js");
8
- const res = spawnSync(process.execPath, [bin, ...args], {
9
- stdio: "ignore",
10
- });
11
- return res.status === 0;
12
- }
13
-
14
- function tryInstall(args, label) {
15
- try {
16
- run(args);
17
- } catch (err) {
18
- console.warn(`[postinstall] ${label} failed: ${err.message || String(err)}`);
19
- }
20
- }
21
4
 
22
5
  // Fix node-pty spawn-helper permissions on macOS (both arm64 and x64)
23
- function fixNodePtyPermissions() {
24
- const platforms = ["darwin-arm64", "darwin-x64"];
6
+ const platforms = ["darwin-arm64", "darwin-x64"];
25
7
 
26
- for (const platform of platforms) {
27
- try {
28
- const spawnHelperPath = path.join(
29
- __dirname,
30
- "..",
31
- "node_modules",
32
- "node-pty",
33
- "prebuilds",
34
- platform,
35
- "spawn-helper"
36
- );
37
-
38
- if (fs.existsSync(spawnHelperPath)) {
39
- const stats = fs.statSync(spawnHelperPath);
40
- // Check if executable bit is missing
41
- if ((stats.mode & 0o111) === 0) {
42
- fs.chmodSync(spawnHelperPath, 0o755);
43
- console.log(`[postinstall] Fixed node-pty spawn-helper permissions (${platform})`);
44
- }
8
+ for (const platform of platforms) {
9
+ try {
10
+ const spawnHelperPath = path.join(
11
+ __dirname,
12
+ "..",
13
+ "node_modules",
14
+ "node-pty",
15
+ "prebuilds",
16
+ platform,
17
+ "spawn-helper"
18
+ );
19
+
20
+ if (fs.existsSync(spawnHelperPath)) {
21
+ const stats = fs.statSync(spawnHelperPath);
22
+ if ((stats.mode & 0o111) === 0) {
23
+ fs.chmodSync(spawnHelperPath, 0o755);
24
+ console.log(`[postinstall] Fixed node-pty spawn-helper permissions (${platform})`);
45
25
  }
46
- } catch {
47
- // Silently ignore errors - not critical for non-macOS or if node-pty not installed
48
26
  }
27
+ } catch {
28
+ // Silently ignore - not critical for non-macOS or if node-pty not installed
49
29
  }
50
30
  }
51
-
52
- fixNodePtyPermissions();
53
-
54
- const skills = ["ufoo", "ubus", "uctx"];
55
-
56
- for (const skill of skills) {
57
- tryInstall(["skills", "install", skill, "--codex"], `install ${skill} skill (codex)`);
58
- tryInstall(["skills", "install", skill], `install ${skill} skill (claude)`);
59
- }
@@ -0,0 +1,21 @@
1
+ #!/bin/bash
2
+ # Sync SKILLS to .claude/commands for Claude Code slash commands
3
+
4
+ set -e
5
+
6
+ SKILLS_DIR="SKILLS"
7
+ CLAUDE_COMMANDS_DIR=".claude/commands"
8
+
9
+ # Create commands directory if it doesn't exist
10
+ mkdir -p "$CLAUDE_COMMANDS_DIR"
11
+
12
+ # Copy all SKILL.md files to .claude/commands/
13
+ for skill_dir in "$SKILLS_DIR"/*; do
14
+ if [ -d "$skill_dir" ] && [ -f "$skill_dir/SKILL.md" ]; then
15
+ skill_name=$(basename "$skill_dir")
16
+ echo "Syncing $skill_name..."
17
+ cp "$skill_dir/SKILL.md" "$CLAUDE_COMMANDS_DIR/$skill_name.md"
18
+ fi
19
+ done
20
+
21
+ echo "Skills synced to Claude Code commands directory!"