@gabrihhh/jarvis 2.1.1 → 2.2.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/bin/jarvis.js +1 -1
- package/package.json +1 -1
- package/src/memory/query-by-path.js +1 -23
- package/src/statusline.js +27 -15
package/bin/jarvis.js
CHANGED
|
@@ -21,7 +21,7 @@ function saveMemoryConfig(cfg) {
|
|
|
21
21
|
function setHook(settings, enabled) {
|
|
22
22
|
if (!settings.hooks) settings.hooks = {};
|
|
23
23
|
if (enabled) {
|
|
24
|
-
settings.hooks.UserPromptSubmit = [{ type: 'command', command: 'jarvis --query' }];
|
|
24
|
+
settings.hooks.UserPromptSubmit = [{ matcher: '', hooks: [{ type: 'command', command: 'jarvis --query' }] }];
|
|
25
25
|
} else {
|
|
26
26
|
delete settings.hooks.UserPromptSubmit;
|
|
27
27
|
if (!Object.keys(settings.hooks).length) delete settings.hooks;
|
package/package.json
CHANGED
|
@@ -1,28 +1,8 @@
|
|
|
1
|
-
import { existsSync, writeFileSync, readFileSync, readdirSync, statSync
|
|
1
|
+
import { existsSync, writeFileSync, readFileSync, readdirSync, statSync } from 'fs';
|
|
2
2
|
import { join } from 'path';
|
|
3
3
|
import { tmpdir, homedir } from 'os';
|
|
4
4
|
import { runQuery, closeDriver } from './neo4j-client.js';
|
|
5
5
|
|
|
6
|
-
const GREEN = '\x1b[38;2;74;222;128m\x1b[1m';
|
|
7
|
-
const RESET = '\x1b[0m';
|
|
8
|
-
|
|
9
|
-
async function flashLoaded(projectName, branch) {
|
|
10
|
-
try {
|
|
11
|
-
const inner = ` ⬡ ${projectName} [${branch}] loaded `;
|
|
12
|
-
const top = `╭${'─'.repeat(inner.length)}╮`;
|
|
13
|
-
const bottom = `╰${'─'.repeat(inner.length)}╯`;
|
|
14
|
-
|
|
15
|
-
const tty = openSync('/dev/tty', 'w');
|
|
16
|
-
writeSync(tty, `${GREEN}${top}${RESET}\n${GREEN}│${inner}│${RESET}\n${GREEN}${bottom}${RESET}\n`);
|
|
17
|
-
closeSync(tty);
|
|
18
|
-
|
|
19
|
-
await new Promise(r => setTimeout(r, 1500));
|
|
20
|
-
|
|
21
|
-
const tty2 = openSync('/dev/tty', 'w');
|
|
22
|
-
writeSync(tty2, `\x1b[3A\x1b[2K\x1b[1B\x1b[2K\x1b[1B\x1b[2K\x1b[3A`);
|
|
23
|
-
closeSync(tty2);
|
|
24
|
-
} catch { /* ambiente sem TTY — silencioso */ }
|
|
25
|
-
}
|
|
26
6
|
|
|
27
7
|
const CONFIG_PATH = join(homedir(), '.claude-memory.json');
|
|
28
8
|
|
|
@@ -78,8 +58,6 @@ export async function queryByPath(cwd) {
|
|
|
78
58
|
const concepts = [...new Set(r.get('concepts'))].filter(Boolean);
|
|
79
59
|
const patterns = [...new Set(r.get('patterns'))].filter(Boolean);
|
|
80
60
|
|
|
81
|
-
if (mode === 'session') await flashLoaded(p.name, p.branch);
|
|
82
|
-
|
|
83
61
|
return [
|
|
84
62
|
`## Contexto do Repositório (jarvis-memory)`,
|
|
85
63
|
`**Projeto:** ${p.name} [${p.branch}]${p.description ? ' — ' + p.description : ''}`,
|
package/src/statusline.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Chalk } from 'chalk';
|
|
2
2
|
import { readFileSync, existsSync } from 'fs';
|
|
3
3
|
import { join } from 'path';
|
|
4
|
-
import { homedir } from 'os';
|
|
4
|
+
import { homedir, tmpdir } from 'os';
|
|
5
5
|
import { readAllUsage, getCurrentSessionFile, readCurrentSessionUsage } from './reader.js';
|
|
6
6
|
import { aggregateStats, aggregateSession } from './calculator.js';
|
|
7
7
|
|
|
@@ -9,6 +9,7 @@ const chalk = new Chalk({ level: 3 });
|
|
|
9
9
|
|
|
10
10
|
const PINK = '#f472b6';
|
|
11
11
|
const CYAN = '#22d3ee';
|
|
12
|
+
const GREEN = '#4ade80';
|
|
12
13
|
|
|
13
14
|
function bar(percent, width = 8) {
|
|
14
15
|
const filled = Math.round((percent / 100) * width);
|
|
@@ -31,37 +32,48 @@ function buildBox(inner, color) {
|
|
|
31
32
|
];
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
function joinBoxes(
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
function joinBoxes(...boxes) {
|
|
36
|
+
return boxes[0][0] + boxes.slice(1).map(b => b[0]).join('') + '\n' +
|
|
37
|
+
boxes[0][1] + boxes.slice(1).map(b => b[1]).join('') + '\n' +
|
|
38
|
+
boxes[0][2] + boxes.slice(1).map(b => b[2]).join('');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function isMemoryLoaded(sessionId) {
|
|
42
|
+
if (!sessionId) return false;
|
|
43
|
+
return existsSync(join(tmpdir(), `jarvis-memory-${sessionId}.lock`));
|
|
38
44
|
}
|
|
39
45
|
|
|
40
46
|
export function renderLine() {
|
|
41
47
|
const mode = readTriggerMode();
|
|
42
48
|
const triggerInner = ` TRIGGER ${mode.toUpperCase()} `;
|
|
43
|
-
const
|
|
49
|
+
const triggerBox = buildBox(triggerInner, PINK);
|
|
50
|
+
|
|
51
|
+
const sessionMeta = getCurrentSessionFile();
|
|
52
|
+
const sessionId = sessionMeta?.sessionId;
|
|
53
|
+
const loaded = isMemoryLoaded(sessionId);
|
|
54
|
+
const loadedBox = loaded ? buildBox(' ⬡ ', GREEN) : null;
|
|
44
55
|
|
|
45
56
|
const allEntries = readAllUsage();
|
|
46
57
|
|
|
58
|
+
const boxes = (contextBox) => loadedBox
|
|
59
|
+
? joinBoxes(contextBox, triggerBox, loadedBox)
|
|
60
|
+
: joinBoxes(contextBox, triggerBox);
|
|
61
|
+
|
|
47
62
|
if (!allEntries.length) {
|
|
48
|
-
const
|
|
49
|
-
process.stdout.write(
|
|
63
|
+
const contextBox = buildBox(` CONTEXT ${'░'.repeat(8)} 0% `, CYAN);
|
|
64
|
+
process.stdout.write(boxes(contextBox));
|
|
50
65
|
return;
|
|
51
66
|
}
|
|
52
67
|
|
|
53
|
-
const stats = aggregateStats(allEntries);
|
|
54
|
-
const sessionMeta = getCurrentSessionFile();
|
|
55
|
-
const sessionId = sessionMeta?.sessionId;
|
|
56
68
|
const sessionEntries = sessionId ? readCurrentSessionUsage(sessionId) : [];
|
|
57
69
|
const session = aggregateSession(sessionEntries);
|
|
58
70
|
|
|
59
71
|
if (!session) {
|
|
60
|
-
const
|
|
61
|
-
process.stdout.write(
|
|
72
|
+
const contextBox = buildBox(` CONTEXT ${'░'.repeat(8)} 0% `, CYAN);
|
|
73
|
+
process.stdout.write(boxes(contextBox));
|
|
62
74
|
return;
|
|
63
75
|
}
|
|
64
76
|
|
|
65
|
-
const
|
|
66
|
-
process.stdout.write(
|
|
77
|
+
const contextBox = buildBox(` CONTEXT ${bar(session.percent)} ${session.percent}% `, CYAN);
|
|
78
|
+
process.stdout.write(boxes(contextBox));
|
|
67
79
|
}
|