agen-vektor 0.1.0

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 (41) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +212 -0
  3. package/dist/agent/agent.js +90 -0
  4. package/dist/agent/context.js +106 -0
  5. package/dist/agent/loop.js +152 -0
  6. package/dist/agent/memory.js +87 -0
  7. package/dist/agent/planner.js +38 -0
  8. package/dist/agent/prompts.js +41 -0
  9. package/dist/agent/session.js +125 -0
  10. package/dist/cli/index.js +304 -0
  11. package/dist/cli/keyboard.js +283 -0
  12. package/dist/config/config.js +92 -0
  13. package/dist/config/credentials.js +127 -0
  14. package/dist/config/models.js +47 -0
  15. package/dist/providers/anthropic.js +276 -0
  16. package/dist/providers/custom.js +24 -0
  17. package/dist/providers/factory.js +58 -0
  18. package/dist/providers/gemini.js +223 -0
  19. package/dist/providers/ollama.js +195 -0
  20. package/dist/providers/openai-compat.js +296 -0
  21. package/dist/providers/openai.js +17 -0
  22. package/dist/providers/openrouter.js +23 -0
  23. package/dist/providers/provider.js +39 -0
  24. package/dist/security/command-policy.js +99 -0
  25. package/dist/security/permissions.js +66 -0
  26. package/dist/tools/filesystem.js +297 -0
  27. package/dist/tools/git.js +66 -0
  28. package/dist/tools/registry.js +39 -0
  29. package/dist/tools/search.js +184 -0
  30. package/dist/tools/shell.js +108 -0
  31. package/dist/tools/web.js +76 -0
  32. package/dist/tui/app.js +913 -0
  33. package/dist/tui/chat.js +76 -0
  34. package/dist/tui/components.js +85 -0
  35. package/dist/tui/diff.js +105 -0
  36. package/dist/tui/input.js +121 -0
  37. package/dist/tui/statusbar.js +32 -0
  38. package/dist/utils/logger.js +96 -0
  39. package/dist/utils/paths.js +90 -0
  40. package/dist/utils/terminal.js +191 -0
  41. package/package.json +56 -0
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ /**
3
+ * Terminal utilities — pure ANSI escape sequences.
4
+ * No external dependencies: works on Linux, macOS and Termux Android.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.BOX = exports.ANSI = void 0;
8
+ exports.cursorTo = cursorTo;
9
+ exports.getTerminalSize = getTerminalSize;
10
+ exports.wrapText = wrapText;
11
+ exports.stripAnsi = stripAnsi;
12
+ exports.visibleWidth = visibleWidth;
13
+ exports.pad = pad;
14
+ exports.truncate = truncate;
15
+ exports.line = line;
16
+ /** ANSI color / style codes */
17
+ exports.ANSI = {
18
+ reset: '\x1b[0m',
19
+ bold: '\x1b[1m',
20
+ dim: '\x1b[2m',
21
+ italic: '\x1b[3m',
22
+ underline: '\x1b[4m',
23
+ blink: '\x1b[5m',
24
+ reverse: '\x1b[7m',
25
+ hidden: '\x1b[8m',
26
+ // Foreground
27
+ black: '\x1b[30m',
28
+ red: '\x1b[31m',
29
+ green: '\x1b[32m',
30
+ yellow: '\x1b[33m',
31
+ blue: '\x1b[34m',
32
+ magenta: '\x1b[35m',
33
+ cyan: '\x1b[36m',
34
+ white: '\x1b[37m',
35
+ gray: '\x1b[90m',
36
+ brightRed: '\x1b[91m',
37
+ brightGreen: '\x1b[92m',
38
+ brightYellow: '\x1b[93m',
39
+ brightBlue: '\x1b[94m',
40
+ brightMagenta: '\x1b[95m',
41
+ brightCyan: '\x1b[96m',
42
+ brightWhite: '\x1b[97m',
43
+ // Background
44
+ bgBlack: '\x1b[40m',
45
+ bgRed: '\x1b[41m',
46
+ bgGreen: '\x1b[42m',
47
+ bgYellow: '\x1b[43m',
48
+ bgBlue: '\x1b[44m',
49
+ bgMagenta: '\x1b[45m',
50
+ bgCyan: '\x1b[46m',
51
+ bgWhite: '\x1b[47m',
52
+ // Cursor / screen
53
+ cursorHome: '\x1b[H',
54
+ cursorUp: (n) => `\x1b[${n}A`,
55
+ cursorDown: (n) => `\x1b[${n}B`,
56
+ cursorRight: (n) => `\x1b[${n}C`,
57
+ cursorLeft: (n) => `\x1b[${n}D`,
58
+ cursorSave: '\x1b[s',
59
+ cursorRestore: '\x1b[u',
60
+ clearScreen: '\x1b[2J',
61
+ clearLine: '\x1b[2K',
62
+ clearLineEnd: '\x1b[K',
63
+ hideCursor: '\x1b[?25l',
64
+ showCursor: '\x1b[?25h',
65
+ enableAltScreen: '\x1b[?1049h',
66
+ disableAltScreen: '\x1b[?1049l',
67
+ enableMouse: '\x1b[?1000h\x1b[?1002h\x1b[?1006h',
68
+ disableMouse: '\x1b[?1000l\x1b[?1002l\x1b[?1006l',
69
+ // SGR
70
+ fg: (code) => `\x1b[38;5;${code}m`,
71
+ bg: (code) => `\x1b[48;5;${code}m`,
72
+ };
73
+ /** Move cursor to (row, col), 1-based */
74
+ function cursorTo(row, col) {
75
+ return `\x1b[${row};${col}H`;
76
+ }
77
+ /** Get current terminal size via ioctl; fallback to 80x24. */
78
+ function getTerminalSize() {
79
+ try {
80
+ // stty is not always available on Termux; use process.stdout columns
81
+ const cols = process.stdout.columns;
82
+ const rows = process.stdout.rows;
83
+ if (cols && rows && cols > 0 && rows > 0) {
84
+ return { rows, cols };
85
+ }
86
+ }
87
+ catch {
88
+ /* fall through */
89
+ }
90
+ return { rows: 24, cols: 80 };
91
+ }
92
+ /**
93
+ * Wrap text to a given width, respecting ANSI escape sequences so they
94
+ * are not counted toward the visible length.
95
+ */
96
+ function wrapText(text, width) {
97
+ if (width <= 0)
98
+ return [text];
99
+ const lines = [];
100
+ const ESC_RE = /^\x1b\[[0-9;]*[A-Za-z]/;
101
+ let current = '';
102
+ let visibleLen = 0;
103
+ const flushLine = () => {
104
+ lines.push(current);
105
+ current = '';
106
+ visibleLen = 0;
107
+ };
108
+ let i = 0;
109
+ while (i < text.length) {
110
+ const ch = text[i];
111
+ if (ch === '\n') {
112
+ flushLine();
113
+ i++;
114
+ continue;
115
+ }
116
+ if (ch === '\r') {
117
+ i++;
118
+ continue;
119
+ }
120
+ if (ch === '\x1b') {
121
+ const rest = text.slice(i);
122
+ const m = rest.match(ESC_RE);
123
+ if (m) {
124
+ current += m[0];
125
+ i += m[0].length;
126
+ continue;
127
+ }
128
+ current += ch;
129
+ i++;
130
+ continue;
131
+ }
132
+ // Measure visible width (approximate wide chars as 2)
133
+ const w = ch.charCodeAt(0) > 0x2fff ? 2 : 1;
134
+ if (visibleLen + w > width && visibleLen > 0) {
135
+ flushLine();
136
+ }
137
+ current += ch;
138
+ visibleLen += w;
139
+ i++;
140
+ }
141
+ flushLine();
142
+ return lines;
143
+ }
144
+ /** Strip ANSI codes from a string (for length math). */
145
+ function stripAnsi(text) {
146
+ return text.replace(/\x1b\[[0-9;]*[A-Za-z]/g, '');
147
+ }
148
+ /** Visible width of a string without ANSI codes. */
149
+ function visibleWidth(text) {
150
+ let w = 0;
151
+ for (const ch of stripAnsi(text)) {
152
+ w += ch.charCodeAt(0) > 0x2fff ? 2 : 1;
153
+ }
154
+ return w;
155
+ }
156
+ /** Pad (or truncate) a string to a fixed visible width, preserving ANSI codes. */
157
+ function pad(str, width) {
158
+ const len = visibleWidth(str);
159
+ if (len >= width)
160
+ return str;
161
+ return str + ' '.repeat(width - len);
162
+ }
163
+ /** Truncate a string (with ANSI) to a max visible width. */
164
+ function truncate(str, width) {
165
+ const clean = stripAnsi(str);
166
+ if (clean.length <= width)
167
+ return str;
168
+ return clean.slice(0, Math.max(0, width - 1)) + '…';
169
+ }
170
+ /** Render a line with a trailing newline reset applied. */
171
+ function line(text = '') {
172
+ return text + exports.ANSI.reset + '\r\n';
173
+ }
174
+ /** Box-drawing helpers */
175
+ exports.BOX = {
176
+ tl: '╭',
177
+ tr: '╮',
178
+ bl: '╰',
179
+ br: '╯',
180
+ h: '─',
181
+ v: '│',
182
+ teeDown: '┬',
183
+ teeUp: '┴',
184
+ teeLeft: '┤',
185
+ teeRight: '├',
186
+ cross: '┼',
187
+ lt: '┌',
188
+ rt: '┐',
189
+ lb: '└',
190
+ rb: '┘',
191
+ };
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "agen-vektor",
3
+ "version": "0.1.0",
4
+ "description": "VECTOR (agen-vektor) — AI Coding Agent CLI/TUI for Linux & Termux. Multi-provider, tool calling, session, permission system.",
5
+ "type": "commonjs",
6
+ "bin": {
7
+ "vector": "dist/cli/index.js"
8
+ },
9
+ "main": "dist/cli/index.js",
10
+ "files": [
11
+ "dist",
12
+ "README.md",
13
+ "LICENSE"
14
+ ],
15
+ "scripts": {
16
+ "build": "tsc",
17
+ "dev": "tsx src/cli/index.ts",
18
+ "start": "node dist/cli/index.js",
19
+ "test": "tsx --test tests/*.test.ts",
20
+ "lint": "tsc --noEmit",
21
+ "typecheck": "tsc --noEmit",
22
+ "prepare": "npm run build",
23
+ "prepublishOnly": "npm run build && npm test"
24
+ },
25
+ "engines": {
26
+ "node": ">=20.0.0"
27
+ },
28
+ "keywords": [
29
+ "ai",
30
+ "agent",
31
+ "cli",
32
+ "tui",
33
+ "coding",
34
+ "terminal",
35
+ "termux",
36
+ "vector",
37
+ "llm",
38
+ "openrouter",
39
+ "ollama"
40
+ ],
41
+ "license": "MIT",
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "https://github.com/clickmamaheti-prog/vector-agent.git"
45
+ },
46
+ "homepage": "https://github.com/clickmamaheti-prog/vector-agent",
47
+ "bugs": {
48
+ "url": "https://github.com/clickmamaheti-prog/vector-agent/issues"
49
+ },
50
+ "dependencies": {},
51
+ "devDependencies": {
52
+ "@types/node": "^22.10.0",
53
+ "tsx": "^4.19.0",
54
+ "typescript": "^5.7.0"
55
+ }
56
+ }