@matterailab/orbcode 0.1.3

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 (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +471 -0
  3. package/bin/orbcode.js +2 -0
  4. package/dist/api/client.js +141 -0
  5. package/dist/api/headers.js +14 -0
  6. package/dist/api/models.js +49 -0
  7. package/dist/api/stream.js +1 -0
  8. package/dist/auth/auth.js +172 -0
  9. package/dist/branding.js +31 -0
  10. package/dist/config/promptHistory.js +33 -0
  11. package/dist/config/settings.js +112 -0
  12. package/dist/core/agent.js +459 -0
  13. package/dist/core/events.js +1 -0
  14. package/dist/core/sessions.js +44 -0
  15. package/dist/headless.js +64 -0
  16. package/dist/index.js +84 -0
  17. package/dist/prompts/system.js +379 -0
  18. package/dist/tools/executors/executeCommand.js +58 -0
  19. package/dist/tools/executors/files.js +197 -0
  20. package/dist/tools/executors/listFiles.js +65 -0
  21. package/dist/tools/executors/searchFiles.js +104 -0
  22. package/dist/tools/executors/web.js +72 -0
  23. package/dist/tools/index.js +85 -0
  24. package/dist/tools/schemas/ask_followup_question.js +40 -0
  25. package/dist/tools/schemas/attempt_completion.js +19 -0
  26. package/dist/tools/schemas/browser_action.js +60 -0
  27. package/dist/tools/schemas/check_past_chat_memories.js +23 -0
  28. package/dist/tools/schemas/codebase_search.js +23 -0
  29. package/dist/tools/schemas/execute_command.js +31 -0
  30. package/dist/tools/schemas/fetch_instructions.js +20 -0
  31. package/dist/tools/schemas/file_edit.js +31 -0
  32. package/dist/tools/schemas/file_write.js +27 -0
  33. package/dist/tools/schemas/generate_image.js +27 -0
  34. package/dist/tools/schemas/index.js +29 -0
  35. package/dist/tools/schemas/list_code_definition_names.js +19 -0
  36. package/dist/tools/schemas/list_files.js +23 -0
  37. package/dist/tools/schemas/lsp.js +46 -0
  38. package/dist/tools/schemas/multi_file_edit.js +42 -0
  39. package/dist/tools/schemas/new_task.js +27 -0
  40. package/dist/tools/schemas/read_file.js +27 -0
  41. package/dist/tools/schemas/run_slash_command.js +23 -0
  42. package/dist/tools/schemas/search_files.js +27 -0
  43. package/dist/tools/schemas/switch_mode.js +23 -0
  44. package/dist/tools/schemas/update_todo_list.js +19 -0
  45. package/dist/tools/schemas/use_skill.js +19 -0
  46. package/dist/tools/schemas/web_fetch.js +19 -0
  47. package/dist/tools/schemas/web_search.js +19 -0
  48. package/dist/tools/types.js +7 -0
  49. package/dist/ui/App.js +569 -0
  50. package/dist/ui/LoginView.js +82 -0
  51. package/dist/ui/components/ApprovalPrompt.js +21 -0
  52. package/dist/ui/components/FollowupPrompt.js +45 -0
  53. package/dist/ui/components/Header.js +12 -0
  54. package/dist/ui/components/InputBox.js +220 -0
  55. package/dist/ui/components/ModelPicker.js +51 -0
  56. package/dist/ui/components/SessionPicker.js +52 -0
  57. package/dist/ui/components/Spinner.js +19 -0
  58. package/dist/ui/components/StatusBar.js +18 -0
  59. package/dist/ui/components/rows.js +106 -0
  60. package/dist/ui/markdown.js +64 -0
  61. package/dist/utils/diff.js +144 -0
  62. package/dist/utils/shell.js +19 -0
  63. package/package.json +62 -0
@@ -0,0 +1,144 @@
1
+ // Minimal unified-diff generator for showing file edits in the TUI.
2
+ /** LCS-based line diff. Falls back to whole-block replace on very large inputs. */
3
+ function diffLines(oldLines, newLines) {
4
+ // Trim common prefix/suffix so the DP table only covers the changed middle.
5
+ let start = 0;
6
+ while (start < oldLines.length && start < newLines.length && oldLines[start] === newLines[start]) {
7
+ start++;
8
+ }
9
+ let oldEnd = oldLines.length;
10
+ let newEnd = newLines.length;
11
+ while (oldEnd > start && newEnd > start && oldLines[oldEnd - 1] === newLines[newEnd - 1]) {
12
+ oldEnd--;
13
+ newEnd--;
14
+ }
15
+ const a = oldLines.slice(start, oldEnd);
16
+ const b = newLines.slice(start, newEnd);
17
+ let middle;
18
+ if (a.length * b.length > 1_000_000) {
19
+ // Too large for DP; show as a block replace.
20
+ middle = [
21
+ ...a.map((text) => ({ type: "-", text })),
22
+ ...b.map((text) => ({ type: "+", text })),
23
+ ];
24
+ }
25
+ else {
26
+ // Standard LCS dynamic program.
27
+ const rows = a.length + 1;
28
+ const cols = b.length + 1;
29
+ const table = new Uint32Array(rows * cols);
30
+ for (let i = a.length - 1; i >= 0; i--) {
31
+ for (let j = b.length - 1; j >= 0; j--) {
32
+ table[i * cols + j] =
33
+ a[i] === b[j]
34
+ ? table[(i + 1) * cols + j + 1] + 1
35
+ : Math.max(table[(i + 1) * cols + j], table[i * cols + j + 1]);
36
+ }
37
+ }
38
+ middle = [];
39
+ let i = 0;
40
+ let j = 0;
41
+ while (i < a.length && j < b.length) {
42
+ if (a[i] === b[j]) {
43
+ middle.push({ type: " ", text: a[i] });
44
+ i++;
45
+ j++;
46
+ }
47
+ else if (table[(i + 1) * cols + j] >= table[i * cols + j + 1]) {
48
+ middle.push({ type: "-", text: a[i] });
49
+ i++;
50
+ }
51
+ else {
52
+ middle.push({ type: "+", text: b[j] });
53
+ j++;
54
+ }
55
+ }
56
+ while (i < a.length)
57
+ middle.push({ type: "-", text: a[i++] });
58
+ while (j < b.length)
59
+ middle.push({ type: "+", text: b[j++] });
60
+ }
61
+ return [
62
+ ...oldLines.slice(0, start).map((text) => ({ type: " ", text })),
63
+ ...middle,
64
+ ...oldLines.slice(oldEnd).map((text) => ({ type: " ", text })),
65
+ ];
66
+ }
67
+ /**
68
+ * Produce unified-diff hunks (without file headers) for two file contents.
69
+ * Returns "" when the contents are identical.
70
+ */
71
+ export function unifiedDiff(oldText, newText, contextLines = 3) {
72
+ if (oldText === newText)
73
+ return "";
74
+ // An empty file is zero lines, not one empty line.
75
+ const ops = diffLines(oldText === "" ? [] : oldText.split("\n"), newText === "" ? [] : newText.split("\n"));
76
+ const out = [];
77
+ let oldLine = 1;
78
+ let newLine = 1;
79
+ let hunk = [];
80
+ let hunkOldStart = 1;
81
+ let hunkNewStart = 1;
82
+ let hunkOldCount = 0;
83
+ let hunkNewCount = 0;
84
+ let trailingContext = 0;
85
+ const flush = () => {
86
+ if (hunk.length === 0)
87
+ return;
88
+ // Drop context beyond the hunk's trailing window.
89
+ const extra = Math.max(0, trailingContext - contextLines);
90
+ if (extra > 0) {
91
+ hunk = hunk.slice(0, hunk.length - extra);
92
+ hunkOldCount -= extra;
93
+ hunkNewCount -= extra;
94
+ }
95
+ out.push(`@@ -${hunkOldStart},${hunkOldCount} +${hunkNewStart},${hunkNewCount} @@`);
96
+ out.push(...hunk);
97
+ hunk = [];
98
+ hunkOldCount = 0;
99
+ hunkNewCount = 0;
100
+ trailingContext = 0;
101
+ };
102
+ let pendingContext = [];
103
+ for (const op of ops) {
104
+ if (op.type === " ") {
105
+ if (hunk.length > 0) {
106
+ hunk.push(` ${op.text}`);
107
+ hunkOldCount++;
108
+ hunkNewCount++;
109
+ trailingContext++;
110
+ if (trailingContext > contextLines * 2)
111
+ flush();
112
+ }
113
+ else {
114
+ pendingContext.push(op.text);
115
+ if (pendingContext.length > contextLines)
116
+ pendingContext.shift();
117
+ }
118
+ oldLine++;
119
+ newLine++;
120
+ }
121
+ else {
122
+ if (hunk.length === 0) {
123
+ hunkOldStart = oldLine - pendingContext.length;
124
+ hunkNewStart = newLine - pendingContext.length;
125
+ hunk = pendingContext.map((text) => ` ${text}`);
126
+ hunkOldCount = pendingContext.length;
127
+ hunkNewCount = pendingContext.length;
128
+ pendingContext = [];
129
+ }
130
+ trailingContext = 0;
131
+ hunk.push(`${op.type}${op.text}`);
132
+ if (op.type === "-") {
133
+ hunkOldCount++;
134
+ oldLine++;
135
+ }
136
+ else {
137
+ hunkNewCount++;
138
+ newLine++;
139
+ }
140
+ }
141
+ }
142
+ flush();
143
+ return out.join("\n");
144
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Cross-platform shell selection. On Windows, $SHELL is normally unset and
3
+ * unix paths like /bin/sh do not exist, so we use ComSpec (cmd.exe); on
4
+ * POSIX systems we honor the user's shell with a /bin/sh fallback.
5
+ */
6
+ export function getShell() {
7
+ if (process.platform === "win32") {
8
+ return process.env.ComSpec || "cmd.exe";
9
+ }
10
+ return process.env.SHELL || "/bin/sh";
11
+ }
12
+ /** Arguments that make the shell run a single command string. */
13
+ export function getShellRunArgs(command) {
14
+ if (process.platform === "win32") {
15
+ // /d skips AutoRun, /s preserves quotes in the command string.
16
+ return ["/d", "/s", "/c", command];
17
+ }
18
+ return ["-c", command];
19
+ }
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@matterailab/orbcode",
3
+ "version": "0.1.3",
4
+ "description": "OrbCode CLI — agentic coding in your terminal, powered by Axon models by MatterAI",
5
+ "type": "module",
6
+ "bin": {
7
+ "orbcode": "./bin/orbcode.js"
8
+ },
9
+ "main": "./dist/index.js",
10
+ "files": [
11
+ "bin",
12
+ "dist",
13
+ "README.md",
14
+ "LICENSE"
15
+ ],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/MatterAIOrg/OrbCode.git"
19
+ },
20
+ "homepage": "https://github.com/MatterAIOrg/OrbCode#readme",
21
+ "bugs": {
22
+ "url": "https://github.com/MatterAIOrg/OrbCode/issues"
23
+ },
24
+ "author": "MatterAI",
25
+ "engines": {
26
+ "node": ">=20.0.0"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "scripts": {
32
+ "build": "tsc -p tsconfig.json",
33
+ "typecheck": "tsc -p tsconfig.json --noEmit",
34
+ "dev": "tsx src/index.tsx",
35
+ "start": "node dist/index.js",
36
+ "prepublishOnly": "npm run typecheck && npm run build"
37
+ },
38
+ "dependencies": {
39
+ "chalk": "^5.3.0",
40
+ "ink": "^5.2.1",
41
+ "open": "^10.1.0",
42
+ "openai": "^4.78.0",
43
+ "picomatch": "^4.0.2",
44
+ "react": "^18.3.1"
45
+ },
46
+ "devDependencies": {
47
+ "@types/node": "^20.17.0",
48
+ "@types/picomatch": "^3.0.1",
49
+ "@types/react": "^18.3.12",
50
+ "tsx": "^4.19.2",
51
+ "typescript": "^5.7.2"
52
+ },
53
+ "keywords": [
54
+ "orbcode",
55
+ "matterai",
56
+ "axon",
57
+ "cli",
58
+ "ai",
59
+ "coding-agent"
60
+ ],
61
+ "license": "MIT"
62
+ }