@gabrihhh/jarvis 2.1.0 → 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 -0
- 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
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
|
}
|