glitool 2.0.1 → 2.0.2
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/dist/agent.js +9 -2
- package/dist/agents/explainer.js +1 -1
- package/dist/index.js +4 -3
- package/dist/ui/App.js +24 -4
- package/package.json +1 -1
package/dist/agent.js
CHANGED
|
@@ -26,10 +26,17 @@ const __dirname = dirname(__filename);
|
|
|
26
26
|
loadEnv({ path: join(os.homedir(), '.glitool', '.env') });
|
|
27
27
|
const MAX_HISTORY_CHARS = 60_000;
|
|
28
28
|
// const simpleLlm = makeLlm('meta-llama/Llama-3.3-70B-Instruct-Turbo');
|
|
29
|
-
|
|
29
|
+
// const simpleLlm = makeLlm('meta-llama/Llama-3.3-70B-Instruct-Turbo');
|
|
30
30
|
function createLlm(model) {
|
|
31
31
|
return makeLlm(model);
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Lazy default LLM. Fresh instance each call so it picks up the
|
|
35
|
+
* current request_id set by startNewRequest() at the top of chat().
|
|
36
|
+
*/
|
|
37
|
+
export function getDefaultLlm() {
|
|
38
|
+
return createLlm('meta-llama/Llama-3.3-70B-Instruct-Turbo');
|
|
39
|
+
}
|
|
33
40
|
// const config = loadConfig();
|
|
34
41
|
const tools = [listFilesTool, readFileTool, searchCodeTool, writeFileTool, editFileTool, bashTool, readBackgroundOutputTool, webFetchTool];
|
|
35
42
|
process.on('exit', cleanupAll);
|
|
@@ -48,7 +55,7 @@ function buildSystemPrompt() {
|
|
|
48
55
|
if (!summary) {
|
|
49
56
|
const rawSession = loadSession();
|
|
50
57
|
if (rawSession.length > 4) {
|
|
51
|
-
generateAndSaveSummary(rawSession,
|
|
58
|
+
generateAndSaveSummary(rawSession, getDefaultLlm());
|
|
52
59
|
summary = loadSummary();
|
|
53
60
|
}
|
|
54
61
|
}
|
package/dist/agents/explainer.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { makeLlm } from '../llm/factory.js';
|
|
2
2
|
import { SystemMessage, HumanMessage } from "@langchain/core/messages";
|
|
3
|
-
const explainerLlm = makeLlm('meta-llama/Llama-3.3-70B-Instruct-Turbo');
|
|
4
3
|
export async function explainResponse(response) {
|
|
5
4
|
if (!response || response.length < 50)
|
|
6
5
|
return '';
|
|
6
|
+
const explainerLlm = makeLlm('meta-llama/Llama-3.3-70B-Instruct-Turbo');
|
|
7
7
|
const result = await explainerLlm.invoke([
|
|
8
8
|
new SystemMessage(`You are a coding teacher. Give what an AI coding assistant just did, explain it in 2-4 simple sentences a biginner would underStand.
|
|
9
9
|
Focus on:
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { render } from "ink";
|
|
|
9
9
|
import { App } from "./ui/App.js";
|
|
10
10
|
import { loadConfig, saveConfig } from "./config.js";
|
|
11
11
|
import { generateAndSaveSummary } from "./memory.js";
|
|
12
|
-
import {
|
|
12
|
+
import { getDefaultLlm, sessionMessages } from "./agent.js";
|
|
13
13
|
import { extractAndSaveProjectMemory } from "./projectMemory.js";
|
|
14
14
|
import os from 'os';
|
|
15
15
|
// import { mkdirSync, writeFileSync, existsSync } from 'fs';
|
|
@@ -70,8 +70,9 @@ async function ensureApiKey() {
|
|
|
70
70
|
}
|
|
71
71
|
const saveAndExit = async () => {
|
|
72
72
|
try {
|
|
73
|
-
|
|
74
|
-
await
|
|
73
|
+
const summaryLlm = getDefaultLlm();
|
|
74
|
+
await generateAndSaveSummary(sessionMessages, summaryLlm);
|
|
75
|
+
await extractAndSaveProjectMemory(sessionMessages, summaryLlm);
|
|
75
76
|
}
|
|
76
77
|
catch {
|
|
77
78
|
// exit cleanly even if LLM is unreachable
|
package/dist/ui/App.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import React, { useState, useRef } from "react";
|
|
3
3
|
import { Box, Text, useApp, Static } from 'ink';
|
|
4
4
|
import TextInput from "ink-text-input";
|
|
5
|
-
import { chat, clearSession,
|
|
5
|
+
import { chat, clearSession, getDefaultLlm, sessionMessages } from '../agent.js';
|
|
6
6
|
import { clearSummary, generateAndSaveSummary } from "../memory.js";
|
|
7
7
|
import { clearProjectMemory, extractAndSaveProjectMemory } from "../projectMemory.js";
|
|
8
8
|
import { useInput } from 'ink';
|
|
@@ -129,8 +129,9 @@ export const App = ({ explainMode = false }) => {
|
|
|
129
129
|
setPaletteIndex(0);
|
|
130
130
|
};
|
|
131
131
|
const handleExit = async () => {
|
|
132
|
-
|
|
133
|
-
await
|
|
132
|
+
const summaryLlm = getDefaultLlm();
|
|
133
|
+
await generateAndSaveSummary(sessionMessages, summaryLlm);
|
|
134
|
+
await extractAndSaveProjectMemory(sessionMessages, summaryLlm);
|
|
134
135
|
exit();
|
|
135
136
|
};
|
|
136
137
|
useInput((inputKey, key) => {
|
|
@@ -420,9 +421,28 @@ export const App = ({ explainMode = false }) => {
|
|
|
420
421
|
}
|
|
421
422
|
}
|
|
422
423
|
catch (err) {
|
|
424
|
+
const raw = err?.message ?? 'Something went wrong.';
|
|
425
|
+
let friendly = raw;
|
|
426
|
+
if (raw.includes('anon_limit') || raw.includes('"anon_limit"')) {
|
|
427
|
+
friendly =
|
|
428
|
+
"Your free trial (5 requests) is over.\n\n" +
|
|
429
|
+
"→ Type /signup to continue with 50 free requests/month.\n" +
|
|
430
|
+
" It takes one click — sign in with GitHub.";
|
|
431
|
+
}
|
|
432
|
+
else if (raw.includes('monthly_limit') || raw.includes('"monthly_limit"')) {
|
|
433
|
+
friendly =
|
|
434
|
+
"You've reached your monthly limit of 50 requests.\n\n" +
|
|
435
|
+
"→ Upgrade to Pro for unlimited at https://glit.in/upgrade\n" +
|
|
436
|
+
"Or wait until next month — your limit resets on the 1st.";
|
|
437
|
+
}
|
|
438
|
+
else if (raw.includes('Token expired') || raw.includes('Invalid token')) {
|
|
439
|
+
friendly =
|
|
440
|
+
"Your session expired.\n\n" +
|
|
441
|
+
"→ Type /signup to sign in again.";
|
|
442
|
+
}
|
|
423
443
|
setMessages(prev => [...prev, {
|
|
424
444
|
role: 'error',
|
|
425
|
-
content:
|
|
445
|
+
content: friendly
|
|
426
446
|
}]);
|
|
427
447
|
}
|
|
428
448
|
finally {
|