primocode 1.0.1 → 4.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.
- package/README.md +146 -88
- package/bin/primocode.js +574 -390
- package/lib/act.js +500 -495
- package/lib/api.js +39 -39
- package/lib/browser.js +492 -492
- package/lib/config.js +76 -71
- package/lib/mascot.js +121 -0
- package/lib/memory.js +179 -0
- package/lib/mouse.js +144 -0
- package/lib/platform.js +245 -0
- package/lib/tools.js +503 -503
- package/lib/ui.js +104 -132
- package/package.json +32 -31
- package/lib/jarvis.js +0 -666
package/lib/ui.js
CHANGED
|
@@ -1,132 +1,104 @@
|
|
|
1
|
-
// UI PrimoCode — minimalista e profissional
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
const os = require('os');
|
|
6
|
-
const path = require('path');
|
|
7
|
-
|
|
8
|
-
const supportsColor = process.stdout.isTTY && process.env.TERM !== 'dumb' && !process.env.NO_COLOR;
|
|
9
|
-
const wrap = (open, close) => (s) => supportsColor ? `\x1b[${open}m${s}\x1b[${close}m` : String(s);
|
|
10
|
-
|
|
11
|
-
const c = {
|
|
12
|
-
reset: '\x1b[0m',
|
|
13
|
-
brand: wrap('38;5;51', '39'),
|
|
14
|
-
brandDim: wrap('38;5;44', '39'),
|
|
15
|
-
accent: wrap('38;5;123', '39'),
|
|
16
|
-
bold: wrap('1', '22'),
|
|
17
|
-
dim: wrap('2', '22'),
|
|
18
|
-
italic: wrap('3', '23'),
|
|
19
|
-
ok: wrap('38;5;42', '39'),
|
|
20
|
-
warn: wrap('38;5;220', '39'),
|
|
21
|
-
err: wrap('38;5;203', '39'),
|
|
22
|
-
muted: wrap('38;5;244', '39'),
|
|
23
|
-
white: wrap('97', '39'),
|
|
24
|
-
magenta: wrap('38;5;177', '39'),
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
function stripAnsi(s) { return String(s).replace(/\x1b\[[0-9;]*m/g, ''); }
|
|
28
|
-
|
|
29
|
-
function welcomeBox(config) {
|
|
30
|
-
const width = Math.min((process.stdout.columns || 80) - 2, 76);
|
|
31
|
-
const inner = width - 4;
|
|
32
|
-
const home = os.homedir();
|
|
33
|
-
let cwd = process.cwd();
|
|
34
|
-
if (cwd.startsWith(home)) cwd = '~' + cwd.slice(home.length);
|
|
35
|
-
if (cwd.length > inner - 6) cwd = '...' + cwd.slice(-(inner - 7));
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
`${c.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
this.
|
|
64
|
-
this.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
this.active
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
out = out.replace(/^\s*[-*]\s+/gm, c.brand(' · '));
|
|
106
|
-
out = out.replace(/\*\*([^*]+)\*\*/g, (_, x) => c.bold(x));
|
|
107
|
-
return out;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function preview(s, maxLines = 6, maxCols = 76) {
|
|
111
|
-
if (!s) return c.muted('(vazio)');
|
|
112
|
-
const lines = String(s).replace(/\r/g, '').split('\n');
|
|
113
|
-
const shown = lines.slice(0, maxLines).map(l => (l.length > maxCols ? l.slice(0, maxCols - 1) + '...' : l));
|
|
114
|
-
const suffix = lines.length > maxLines ? c.muted(`\n ... +${lines.length - maxLines} linhas`) : '';
|
|
115
|
-
return shown.join('\n') + suffix;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function toolLine(name, args) {
|
|
119
|
-
return `${c.brand('●')} ${c.bold(name)}${c.muted('(')}${c.muted(args || '')}${c.muted(')')}`;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function toolResult(text) {
|
|
123
|
-
if (!text) return '';
|
|
124
|
-
const lines = String(text).split('\n');
|
|
125
|
-
return lines.map(l => c.muted(' ⎿ ') + c.muted(l)).join('\n');
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function actionHeader(icon, name, detail) {
|
|
129
|
-
return toolLine(name, detail || '');
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
module.exports = { c, welcomeBox, hr, Spinner, stripAnsi, renderMarkdown, preview, actionHeader, toolLine, toolResult, supportsColor };
|
|
1
|
+
// UI PrimoCode — minimalista e profissional
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const os = require('os');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
|
|
8
|
+
const supportsColor = process.stdout.isTTY && process.env.TERM !== 'dumb' && !process.env.NO_COLOR;
|
|
9
|
+
const wrap = (open, close) => (s) => supportsColor ? `\x1b[${open}m${s}\x1b[${close}m` : String(s);
|
|
10
|
+
|
|
11
|
+
const c = {
|
|
12
|
+
reset: '\x1b[0m',
|
|
13
|
+
brand: wrap('38;5;51', '39'),
|
|
14
|
+
brandDim: wrap('38;5;44', '39'),
|
|
15
|
+
accent: wrap('38;5;123', '39'),
|
|
16
|
+
bold: wrap('1', '22'),
|
|
17
|
+
dim: wrap('2', '22'),
|
|
18
|
+
italic: wrap('3', '23'),
|
|
19
|
+
ok: wrap('38;5;42', '39'),
|
|
20
|
+
warn: wrap('38;5;220', '39'),
|
|
21
|
+
err: wrap('38;5;203', '39'),
|
|
22
|
+
muted: wrap('38;5;244', '39'),
|
|
23
|
+
white: wrap('97', '39'),
|
|
24
|
+
magenta: wrap('38;5;177', '39'),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
function stripAnsi(s) { return String(s).replace(/\x1b\[[0-9;]*m/g, ''); }
|
|
28
|
+
|
|
29
|
+
function welcomeBox(config) {
|
|
30
|
+
const width = Math.min((process.stdout.columns || 80) - 2, 76);
|
|
31
|
+
const inner = width - 4;
|
|
32
|
+
const home = os.homedir();
|
|
33
|
+
let cwd = process.cwd();
|
|
34
|
+
if (cwd.startsWith(home)) cwd = '~' + cwd.slice(home.length);
|
|
35
|
+
if (cwd.length > inner - 6) cwd = '...' + cwd.slice(-(inner - 7));
|
|
36
|
+
|
|
37
|
+
const mode = config.mode || 'Primo Code';
|
|
38
|
+
|
|
39
|
+
const lines = [
|
|
40
|
+
`${c.brand('◆')} ${c.bold('PrimoCode')}`,
|
|
41
|
+
``,
|
|
42
|
+
`${c.muted('/help · /mode Primo Code | Chat')}`,
|
|
43
|
+
`${c.muted('Diretorio')} ${c.dim(cwd)}`,
|
|
44
|
+
`${c.muted('Modo')} ${c.dim(mode)}`,
|
|
45
|
+
];
|
|
46
|
+
const pad = (s) => {
|
|
47
|
+
const raw = stripAnsi(s);
|
|
48
|
+
return ' ' + s + ' '.repeat(Math.max(1, inner - raw.length + 1));
|
|
49
|
+
};
|
|
50
|
+
const top = c.brandDim(`╭${'─'.repeat(width - 2)}╮`);
|
|
51
|
+
const bottom = c.brandDim(`╰${'─'.repeat(width - 2)}╯`);
|
|
52
|
+
const body = lines.map(l => c.brandDim('│') + pad(l) + c.brandDim('│')).join('\n');
|
|
53
|
+
return `\n${top}\n${body}\n${bottom}\n`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function hr() {
|
|
57
|
+
const w = Math.min(process.stdout.columns || 80, 72);
|
|
58
|
+
return c.dim(c.muted('─'.repeat(w)));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
class Spinner {
|
|
62
|
+
constructor(text = '') {
|
|
63
|
+
this.frames = ['⠋','⠙','⠹','⠸','⠼','⠴','⠦','⠧','⠇','⠏'];
|
|
64
|
+
this.i = 0;
|
|
65
|
+
this.text = text;
|
|
66
|
+
this.timer = null;
|
|
67
|
+
this.active = false;
|
|
68
|
+
}
|
|
69
|
+
start(text) {
|
|
70
|
+
if (text !== undefined) this.text = text;
|
|
71
|
+
if (!process.stdout.isTTY) {
|
|
72
|
+
if (this.text) process.stdout.write(c.muted(` ${this.text}...\n`));
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
this.active = true;
|
|
76
|
+
process.stdout.write('\x1b[?25l');
|
|
77
|
+
this.timer = setInterval(() => {
|
|
78
|
+
process.stdout.write(`\r ${c.brand(this.frames[this.i])} ${c.muted(this.text)} `);
|
|
79
|
+
this.i = (this.i + 1) % this.frames.length;
|
|
80
|
+
}, 80);
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
83
|
+
update(text) { this.text = text; return this; }
|
|
84
|
+
stop(finalText) {
|
|
85
|
+
if (this.timer) clearInterval(this.timer);
|
|
86
|
+
this.timer = null;
|
|
87
|
+
if (this.active && process.stdout.isTTY) {
|
|
88
|
+
process.stdout.write('\r\x1b[2K\x1b[?25h');
|
|
89
|
+
}
|
|
90
|
+
this.active = false;
|
|
91
|
+
if (finalText) process.stdout.write(c.muted(` ${finalText}\n`));
|
|
92
|
+
return this;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function actionHeader(name, detail) {
|
|
97
|
+
return `${c.brand('▶')} ${c.bold(name)} ${c.muted(detail || '')}`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function toolLine(name, detail) {
|
|
101
|
+
return `${c.brand('▶')} ${c.bold(name)} ${c.muted(detail || '')}`;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
module.exports = { c, welcomeBox, hr, Spinner, actionHeader, toolLine, stripAnsi };
|
package/package.json
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "primocode",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"description": "PrimoCode — assistente de engenharia com IA.
|
|
5
|
-
"main": "bin/primocode.js",
|
|
6
|
-
"bin": {
|
|
7
|
-
"primocode": "bin/primocode.js"
|
|
8
|
-
},
|
|
9
|
-
"scripts": {
|
|
10
|
-
"start": "node bin/primocode.js"
|
|
11
|
-
},
|
|
12
|
-
"engines": {
|
|
13
|
-
"node": ">=18.17.0"
|
|
14
|
-
},
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "primocode",
|
|
3
|
+
"version": "4.1.0",
|
|
4
|
+
"description": "PrimoCode v4.1 — assistente de engenharia com IA multi-agente. Funciona em Windows, macOS, Linux e Termux (Android).",
|
|
5
|
+
"main": "bin/primocode.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"primocode": "bin/primocode.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"start": "node bin/primocode.js"
|
|
11
|
+
},
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=18.17.0"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {},
|
|
16
|
+
"keywords": ["cli", "ai", "coding-assistant", "agent", "primocode", "termux", "android"],
|
|
17
|
+
"author": "ConectaPrimoAI <conectaprimoai@gmail.com>",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/ConectaPrimoAI/primocode.git"
|
|
22
|
+
},
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/ConectaPrimoAI/primocode/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/ConectaPrimoAI/primocode#readme",
|
|
27
|
+
"files": [
|
|
28
|
+
"bin/",
|
|
29
|
+
"lib/",
|
|
30
|
+
"README.md"
|
|
31
|
+
]
|
|
32
|
+
}
|