@thegitai/cli 1.2.2 → 1.3.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 +8 -0
- package/dist/src/agent-mode.js +2 -0
- package/dist/src/api/chat.js +4 -0
- package/dist/src/help-text.js +2 -0
- package/dist/src/local-clock.js +14 -0
- package/dist/src/memory/command.js +60 -0
- package/dist/src/memory/store.js +226 -0
- package/dist/src/tools/index.js +3 -0
- package/dist/src/tools/memory.js +25 -0
- package/dist/src/ui/repl.js +24 -0
- package/dist/src/ui/slash-commands.js +1 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -295,6 +295,14 @@ repositories) or a local folder after showing what it contains; add `--project`
|
|
|
295
295
|
to install it into the current project. Ask the agent to "create a skill that
|
|
296
296
|
..." or run `/skill-creator` to make one.
|
|
297
297
|
|
|
298
|
+
## Memory
|
|
299
|
+
|
|
300
|
+
TheGitAI saves short notes when you correct it, state a lasting preference, or
|
|
301
|
+
make a decision the code does not show, and shows you when it does. Notes are
|
|
302
|
+
files on your computer, per project or personal, each with the time it was saved.
|
|
303
|
+
They are sent with a request only so the agent can use them for that turn.
|
|
304
|
+
`/memory` lists, edits and deletes them; `/memory off` turns the feature off.
|
|
305
|
+
|
|
298
306
|
## Chrome browser control
|
|
299
307
|
|
|
300
308
|
The TheGitAI Chrome extension is separately installed. After installing it,
|
package/dist/src/agent-mode.js
CHANGED
package/dist/src/api/chat.js
CHANGED
|
@@ -15,6 +15,8 @@ import { collectClientEnvironment } from '../client-environment.js';
|
|
|
15
15
|
import { collectProjectOrientation } from '../project-orientation.js';
|
|
16
16
|
import { collectProjectInstructionFiles } from '../project-instructions.js';
|
|
17
17
|
import { collectSkillRequest } from '../skills/discovery.js';
|
|
18
|
+
import { collectMemoryRequest } from '../memory/store.js';
|
|
19
|
+
import { collectLocalClock } from '../local-clock.js';
|
|
18
20
|
import { describeSessionImageStore } from '../core/session-image-store.js';
|
|
19
21
|
import { autoAttachImages } from '../core/image-path-extractor.js';
|
|
20
22
|
import { formatTurnFailureMarker } from '../turn-failure-marker.js';
|
|
@@ -767,6 +769,8 @@ async function sendServerUserMessageInner({ config, session, input, jobFollowUp
|
|
|
767
769
|
clientTurnId: randomUUID(),
|
|
768
770
|
mcpTools: await sessionMcp(session).discover(signal),
|
|
769
771
|
...collectSkillRequest(session.rootDir, session.env, jobFollowUp ? '' : requestInputBase),
|
|
772
|
+
...collectMemoryRequest(session.rootDir, session.env),
|
|
773
|
+
localClock: collectLocalClock(),
|
|
770
774
|
modelId: session.modelId,
|
|
771
775
|
reasoningEffort: projectModelEffort(readProjectModelEfforts(session.rootDir, config.serverUrl, session.env), session.modelId),
|
|
772
776
|
session: snapshotForServer(session),
|
package/dist/src/help-text.js
CHANGED
|
@@ -144,6 +144,8 @@ const HELP_MARKDOWN = [
|
|
|
144
144
|
'- `/skills add <source>` - install a skill from GitHub (`owner/repo/path`',
|
|
145
145
|
' or a GitHub URL) or from a local folder into ~/.thegitai/skills; add',
|
|
146
146
|
' `--project` to put it in this project\'s .thegitai/skills instead',
|
|
147
|
+
'- `/memory` - see what the agent has saved on this computer; also',
|
|
148
|
+
' `/memory edit <number> <text>`, `/memory delete <number>`, `/memory off`, `/memory on`',
|
|
147
149
|
'- `/<skill> [what to do]` - run a skill yourself. Skills show up in the',
|
|
148
150
|
' command picker, and the agent also loads a matching skill on its own',
|
|
149
151
|
'- `/about` - show version and platform info',
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function pad(value) {
|
|
2
|
+
return String(Math.abs(Math.trunc(value))).padStart(2, '0');
|
|
3
|
+
}
|
|
4
|
+
export function localTimestamp(now = new Date()) {
|
|
5
|
+
const offset = -now.getTimezoneOffset();
|
|
6
|
+
const sign = offset >= 0 ? '+' : '-';
|
|
7
|
+
const date = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`;
|
|
8
|
+
const time = `${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`;
|
|
9
|
+
return `${date}T${time}${sign}${pad(offset / 60)}:${pad(offset % 60)}`;
|
|
10
|
+
}
|
|
11
|
+
export function collectLocalClock(now = new Date()) {
|
|
12
|
+
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
13
|
+
return { localTime: localTimestamp(now), ...(timeZone ? { timeZone } : {}) };
|
|
14
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { deleteMemory, isMemoryEnabled, listMemories, memoryFilePaths, setMemoryEnabled, updateMemory, } from './store.js';
|
|
2
|
+
const USAGE = 'Usage: /memory, /memory edit <number> <text>, /memory delete <number>, /memory off, /memory on';
|
|
3
|
+
const shownListings = new Map();
|
|
4
|
+
function when(entry) {
|
|
5
|
+
return entry.updatedAt.slice(0, 16).replace('T', ' ');
|
|
6
|
+
}
|
|
7
|
+
function listing(rootDir, env) {
|
|
8
|
+
const entries = listMemories(rootDir, env);
|
|
9
|
+
shownListings.set(memoryFilePaths(rootDir, env).project, entries.map((entry) => entry.id));
|
|
10
|
+
const status = isMemoryEnabled(env)
|
|
11
|
+
? 'Memory is on. Notes stay on this computer.'
|
|
12
|
+
: 'Memory is off. Saved notes are kept but not used.';
|
|
13
|
+
if (entries.length === 0)
|
|
14
|
+
return `${status}\n\nNothing saved yet.`;
|
|
15
|
+
const section = (title, scope) => {
|
|
16
|
+
const lines = entries.flatMap((entry, index) => entry.scope === scope ? [`${index + 1}. ${entry.text} (${when(entry)})`] : []);
|
|
17
|
+
return lines.length ? [title, ...lines, ''] : [];
|
|
18
|
+
};
|
|
19
|
+
return [
|
|
20
|
+
status,
|
|
21
|
+
'',
|
|
22
|
+
...section('This project', 'project'),
|
|
23
|
+
...section('Everywhere', 'personal'),
|
|
24
|
+
USAGE,
|
|
25
|
+
].join('\n');
|
|
26
|
+
}
|
|
27
|
+
export function runMemoryCommand(args, rootDir, env = process.env) {
|
|
28
|
+
const trimmed = args.trim();
|
|
29
|
+
if (!trimmed || trimmed === 'list')
|
|
30
|
+
return listing(rootDir, env);
|
|
31
|
+
if (trimmed === 'off' || trimmed === 'on') {
|
|
32
|
+
setMemoryEnabled(trimmed === 'on', env);
|
|
33
|
+
return listing(rootDir, env);
|
|
34
|
+
}
|
|
35
|
+
const match = trimmed.match(/^(edit|delete)\s+(\d+)(?:\s+([\s\S]+))?$/);
|
|
36
|
+
if (!match)
|
|
37
|
+
return USAGE;
|
|
38
|
+
const shown = shownListings.get(memoryFilePaths(rootDir, env).project);
|
|
39
|
+
if (!shown)
|
|
40
|
+
return 'Run /memory first to see the note numbers.';
|
|
41
|
+
const id = shown[Number(match[2]) - 1];
|
|
42
|
+
if (!id)
|
|
43
|
+
return `There is no memory number ${match[2]}.`;
|
|
44
|
+
const entry = listMemories(rootDir, env).find((item) => item.id === id);
|
|
45
|
+
if (!entry)
|
|
46
|
+
return 'That note no longer exists. Run /memory to see the current list.';
|
|
47
|
+
if (match[1] === 'delete') {
|
|
48
|
+
try {
|
|
49
|
+
deleteMemory({ rootDir, env, id });
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
return error instanceof Error ? error.message : String(error);
|
|
53
|
+
}
|
|
54
|
+
return `Deleted: ${entry.text}`;
|
|
55
|
+
}
|
|
56
|
+
if (!match[3])
|
|
57
|
+
return USAGE;
|
|
58
|
+
const updated = updateMemory({ rootDir, env, id, text: match[3] });
|
|
59
|
+
return updated.ok ? `Updated: ${updated.entry.text}` : updated.error;
|
|
60
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { closeSync, mkdirSync, openSync, readFileSync, renameSync, rmSync, statSync, writeFileSync, } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { getClientStateDir } from '../client-state.js';
|
|
5
|
+
import { localTimestamp } from '../local-clock.js';
|
|
6
|
+
import { getSessionProjectKey } from '../project-key.js';
|
|
7
|
+
export const MEMORY_TEXT_MAX_CHARS = 400;
|
|
8
|
+
export const MEMORY_MAX_ENTRIES_PER_SCOPE = 100;
|
|
9
|
+
const LOCK_WAIT_MS = 5_000;
|
|
10
|
+
const LOCK_STALE_MS = 10_000;
|
|
11
|
+
const LOCK_RETRY_MS = 15;
|
|
12
|
+
const LOCK_BUSY_CODES = new Set(['EEXIST', 'EPERM', 'EACCES', 'EBUSY']);
|
|
13
|
+
function memoryFile(scope, rootDir, env) {
|
|
14
|
+
const base = getClientStateDir(env);
|
|
15
|
+
return scope === 'personal'
|
|
16
|
+
? path.join(base, 'memory', 'memories.json')
|
|
17
|
+
: path.join(base, 'projects', getSessionProjectKey(rootDir), 'memory', 'memories.json');
|
|
18
|
+
}
|
|
19
|
+
function settingsFile(env) {
|
|
20
|
+
return path.join(getClientStateDir(env), 'memory', 'settings.json');
|
|
21
|
+
}
|
|
22
|
+
export function memoryFilePaths(rootDir, env = process.env) {
|
|
23
|
+
return {
|
|
24
|
+
personal: memoryFile('personal', rootDir, env),
|
|
25
|
+
project: memoryFile('project', rootDir, env),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function withMemoryLock(env, mutate) {
|
|
29
|
+
const lockPath = path.join(getClientStateDir(env), 'memory', '.lock');
|
|
30
|
+
mkdirSync(path.dirname(lockPath), { recursive: true, mode: 0o700 });
|
|
31
|
+
const deadline = Date.now() + LOCK_WAIT_MS;
|
|
32
|
+
for (;;) {
|
|
33
|
+
try {
|
|
34
|
+
closeSync(openSync(lockPath, 'wx', 0o600));
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (!LOCK_BUSY_CODES.has(error?.code))
|
|
39
|
+
throw error;
|
|
40
|
+
try {
|
|
41
|
+
if (Date.now() - statSync(lockPath).mtimeMs > LOCK_STALE_MS)
|
|
42
|
+
rmSync(lockPath, { force: true });
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
}
|
|
46
|
+
if (Date.now() > deadline)
|
|
47
|
+
throw new Error('Memory is busy. Try again in a moment.');
|
|
48
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, LOCK_RETRY_MS);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
return mutate();
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
rmSync(lockPath, { force: true });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function saveFailure(error) {
|
|
59
|
+
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
60
|
+
}
|
|
61
|
+
function writeJson(filePath, value) {
|
|
62
|
+
mkdirSync(path.dirname(filePath), { recursive: true, mode: 0o700 });
|
|
63
|
+
const tempPath = `${filePath}.${process.pid}.tmp`;
|
|
64
|
+
writeFileSync(tempPath, `${JSON.stringify(value, null, 2)}\n`, { mode: 0o600 });
|
|
65
|
+
renameSync(tempPath, filePath);
|
|
66
|
+
}
|
|
67
|
+
function cleanText(value) {
|
|
68
|
+
return String(value ?? '').replace(/\s+/g, ' ').trim();
|
|
69
|
+
}
|
|
70
|
+
function readScope(scope, rootDir, env) {
|
|
71
|
+
let parsed;
|
|
72
|
+
try {
|
|
73
|
+
parsed = JSON.parse(readFileSync(memoryFile(scope, rootDir, env), 'utf8'));
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
if (!Array.isArray(parsed))
|
|
79
|
+
return [];
|
|
80
|
+
const entries = [];
|
|
81
|
+
for (const item of parsed) {
|
|
82
|
+
if (!item || typeof item !== 'object')
|
|
83
|
+
continue;
|
|
84
|
+
const record = item;
|
|
85
|
+
const text = cleanText(record.text).slice(0, MEMORY_TEXT_MAX_CHARS);
|
|
86
|
+
if (typeof record.id !== 'string' || !record.id || !text)
|
|
87
|
+
continue;
|
|
88
|
+
const createdAt = typeof record.createdAt === 'string' ? record.createdAt : '';
|
|
89
|
+
const updatedAt = typeof record.updatedAt === 'string' ? record.updatedAt : createdAt;
|
|
90
|
+
entries.push({ id: record.id, text, createdAt, updatedAt });
|
|
91
|
+
}
|
|
92
|
+
return entries;
|
|
93
|
+
}
|
|
94
|
+
function writeScope(scope, rootDir, env, entries) {
|
|
95
|
+
writeJson(memoryFile(scope, rootDir, env), entries);
|
|
96
|
+
}
|
|
97
|
+
function byNewest(a, b) {
|
|
98
|
+
return (Date.parse(b.updatedAt) || 0) - (Date.parse(a.updatedAt) || 0);
|
|
99
|
+
}
|
|
100
|
+
export function listMemories(rootDir, env = process.env) {
|
|
101
|
+
const scoped = (scope) => readScope(scope, rootDir, env)
|
|
102
|
+
.map((entry) => ({ ...entry, scope }))
|
|
103
|
+
.sort(byNewest);
|
|
104
|
+
return [...scoped('project'), ...scoped('personal')];
|
|
105
|
+
}
|
|
106
|
+
export function isMemoryEnabled(env = process.env) {
|
|
107
|
+
try {
|
|
108
|
+
return JSON.parse(readFileSync(settingsFile(env), 'utf8'))?.enabled !== false;
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
export function setMemoryEnabled(enabled, env = process.env) {
|
|
115
|
+
writeJson(settingsFile(env), { enabled });
|
|
116
|
+
}
|
|
117
|
+
export function collectMemoryRequest(rootDir, env = process.env) {
|
|
118
|
+
return isMemoryEnabled(env) ? { memories: listMemories(rootDir, env) } : {};
|
|
119
|
+
}
|
|
120
|
+
function validText(text) {
|
|
121
|
+
if (!text)
|
|
122
|
+
return 'A memory needs some text.';
|
|
123
|
+
if (text.length > MEMORY_TEXT_MAX_CHARS) {
|
|
124
|
+
return `A memory can be at most ${MEMORY_TEXT_MAX_CHARS} characters.`;
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
export function saveMemory({ rootDir, env = process.env, text: rawText, scope: rawScope, replaces, }) {
|
|
129
|
+
const text = cleanText(rawText);
|
|
130
|
+
const invalid = validText(text);
|
|
131
|
+
if (invalid)
|
|
132
|
+
return { ok: false, error: invalid };
|
|
133
|
+
const replacedId = typeof replaces === 'string' ? replaces : '';
|
|
134
|
+
try {
|
|
135
|
+
return withMemoryLock(env, () => {
|
|
136
|
+
let old = null;
|
|
137
|
+
if (replacedId) {
|
|
138
|
+
for (const candidate of ['project', 'personal']) {
|
|
139
|
+
const entry = readScope(candidate, rootDir, env).find((item) => item.id === replacedId);
|
|
140
|
+
if (entry)
|
|
141
|
+
old = { scope: candidate, entry };
|
|
142
|
+
}
|
|
143
|
+
if (!old)
|
|
144
|
+
return { ok: false, error: `No saved memory has the id ${replacedId}.` };
|
|
145
|
+
}
|
|
146
|
+
const scope = rawScope === 'personal' || rawScope === 'project' ? rawScope : (old?.scope ?? 'project');
|
|
147
|
+
const destination = readScope(scope, rootDir, env).filter((item) => !(old?.scope === scope && item.id === old.entry.id));
|
|
148
|
+
const duplicate = destination.find((item) => item.text === text);
|
|
149
|
+
if (!duplicate && destination.length >= MEMORY_MAX_ENTRIES_PER_SCOPE) {
|
|
150
|
+
return {
|
|
151
|
+
ok: false,
|
|
152
|
+
error: `Memory is full (${MEMORY_MAX_ENTRIES_PER_SCOPE} notes). Replace an outdated note, or ask the user to remove some with /memory.`,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
const now = localTimestamp();
|
|
156
|
+
const entry = duplicate ?? {
|
|
157
|
+
id: `m_${randomBytes(4).toString('hex')}`,
|
|
158
|
+
text,
|
|
159
|
+
createdAt: old?.entry.createdAt || now,
|
|
160
|
+
updatedAt: now,
|
|
161
|
+
};
|
|
162
|
+
if (!duplicate || old?.scope === scope) {
|
|
163
|
+
writeScope(scope, rootDir, env, duplicate ? destination : [...destination, entry]);
|
|
164
|
+
}
|
|
165
|
+
if (old && old.scope !== scope) {
|
|
166
|
+
const replacedEntryId = old.entry.id;
|
|
167
|
+
writeScope(old.scope, rootDir, env, readScope(old.scope, rootDir, env).filter((item) => item.id !== replacedEntryId));
|
|
168
|
+
}
|
|
169
|
+
return { ok: true, entry: { ...entry, scope } };
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
return saveFailure(error);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
export function updateMemory({ rootDir, env = process.env, id, text: rawText, }) {
|
|
177
|
+
const text = cleanText(rawText);
|
|
178
|
+
const invalid = validText(text);
|
|
179
|
+
if (invalid)
|
|
180
|
+
return { ok: false, error: invalid };
|
|
181
|
+
try {
|
|
182
|
+
return withMemoryLock(env, () => {
|
|
183
|
+
for (const scope of ['project', 'personal']) {
|
|
184
|
+
const entries = readScope(scope, rootDir, env);
|
|
185
|
+
const index = entries.findIndex((entry) => entry.id === id);
|
|
186
|
+
if (index === -1)
|
|
187
|
+
continue;
|
|
188
|
+
const entry = { ...entries[index], text, updatedAt: localTimestamp() };
|
|
189
|
+
entries[index] = entry;
|
|
190
|
+
writeScope(scope, rootDir, env, entries);
|
|
191
|
+
return { ok: true, entry: { ...entry, scope } };
|
|
192
|
+
}
|
|
193
|
+
return { ok: false, error: 'That memory no longer exists.' };
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
return saveFailure(error);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
export function deleteMemory({ rootDir, env = process.env, id, }) {
|
|
201
|
+
return withMemoryLock(env, () => {
|
|
202
|
+
for (const scope of ['project', 'personal']) {
|
|
203
|
+
const entries = readScope(scope, rootDir, env);
|
|
204
|
+
if (!entries.some((entry) => entry.id === id))
|
|
205
|
+
continue;
|
|
206
|
+
writeScope(scope, rootDir, env, entries.filter((entry) => entry.id !== id));
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
return false;
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
export function searchMemories(rootDir, env, query, limit = 10) {
|
|
213
|
+
const entries = listMemories(rootDir, env);
|
|
214
|
+
const terms = cleanText(query).toLowerCase().split(' ').filter((term) => term.length > 1);
|
|
215
|
+
if (terms.length === 0)
|
|
216
|
+
return entries.slice(0, limit);
|
|
217
|
+
return entries
|
|
218
|
+
.map((entry) => {
|
|
219
|
+
const text = entry.text.toLowerCase();
|
|
220
|
+
return { entry, score: terms.filter((term) => text.includes(term)).length };
|
|
221
|
+
})
|
|
222
|
+
.filter((match) => match.score > 0)
|
|
223
|
+
.sort((a, b) => b.score - a.score || byNewest(a.entry, b.entry))
|
|
224
|
+
.slice(0, limit)
|
|
225
|
+
.map((match) => match.entry);
|
|
226
|
+
}
|
package/dist/src/tools/index.js
CHANGED
|
@@ -20,6 +20,7 @@ import { strReplace } from './str-replace.js';
|
|
|
20
20
|
import { undoEdit } from './undo-edit.js';
|
|
21
21
|
import { updateTodos } from './update-todos.js';
|
|
22
22
|
import { useSkill } from './use-skill.js';
|
|
23
|
+
import { recallNotes, rememberNote } from './memory.js';
|
|
23
24
|
import { saveGeneratedImage } from './save-generated-image.js';
|
|
24
25
|
import { writeFile } from './write-file.js';
|
|
25
26
|
export const TOOL_MAP = {
|
|
@@ -45,6 +46,8 @@ export const TOOL_MAP = {
|
|
|
45
46
|
shell_job_kill: shellJobKill,
|
|
46
47
|
update_todos: updateTodos,
|
|
47
48
|
use_skill: (context, args) => useSkill(context, args),
|
|
49
|
+
remember: (context, args) => rememberNote(context, args),
|
|
50
|
+
recall: (context, args) => recallNotes(context, args),
|
|
48
51
|
browser: (context, args) => browserGateway(context, args),
|
|
49
52
|
browser_tabs: browserTabs,
|
|
50
53
|
browser_tab_new: (context, args) => browserTabNew(context, args),
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { isMemoryEnabled, saveMemory, searchMemories } from '../memory/store.js';
|
|
2
|
+
function memoryOff() {
|
|
3
|
+
return { ok: false, error: 'Memory is turned off.', failureCategory: 'permission_denied' };
|
|
4
|
+
}
|
|
5
|
+
export function rememberNote(context, args) {
|
|
6
|
+
if (!isMemoryEnabled(context.env))
|
|
7
|
+
return memoryOff();
|
|
8
|
+
const saved = saveMemory({
|
|
9
|
+
rootDir: context.rootDir,
|
|
10
|
+
env: context.env,
|
|
11
|
+
text: args?.text,
|
|
12
|
+
scope: args?.scope,
|
|
13
|
+
replaces: args?.replaces,
|
|
14
|
+
});
|
|
15
|
+
if (!saved.ok) {
|
|
16
|
+
return { ok: false, error: saved.error, failureCategory: 'invalid_argument' };
|
|
17
|
+
}
|
|
18
|
+
return { ok: true, ...saved.entry, output: 'Saved to memory.' };
|
|
19
|
+
}
|
|
20
|
+
export function recallNotes(context, args) {
|
|
21
|
+
if (!isMemoryEnabled(context.env))
|
|
22
|
+
return memoryOff();
|
|
23
|
+
const matches = searchMemories(context.rootDir, context.env ?? process.env, String(args?.query ?? ''));
|
|
24
|
+
return { ok: true, query: String(args?.query ?? ''), matches };
|
|
25
|
+
}
|
package/dist/src/ui/repl.js
CHANGED
|
@@ -26,6 +26,7 @@ import { getJobBufferedOutput, getJobOutputPreview, hasRunningBackgroundJobs, ki
|
|
|
26
26
|
import { clearTodos, listTodos, setTodoSession } from '../todo-list.js';
|
|
27
27
|
import { setScratchSession } from '../scratch-dir.js';
|
|
28
28
|
import { setImageStoreSession } from '../core/session-image-store.js';
|
|
29
|
+
import { runMemoryCommand } from '../memory/command.js';
|
|
29
30
|
import { cancelActiveCommand } from '../executor.js';
|
|
30
31
|
import { isTurnFailureMarker } from '../turn-failure-marker.js';
|
|
31
32
|
import { clearCliAuthConfig, logoutFromServer, } from '../api/auth.js';
|
|
@@ -750,6 +751,21 @@ export function buildWorkingToolEntry(event, label = event.call.name) {
|
|
|
750
751
|
title: call.name === 'shell_job_kill' ? 'Kill job' : 'Job output',
|
|
751
752
|
};
|
|
752
753
|
}
|
|
754
|
+
if (call.name === 'remember') {
|
|
755
|
+
return {
|
|
756
|
+
body: `${String(result?.text ?? call.args?.text ?? '').trim()}${error}`,
|
|
757
|
+
kind,
|
|
758
|
+
title: failed ? 'Memory' : 'Saved to memory',
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
if (call.name === 'recall') {
|
|
762
|
+
const found = Array.isArray(result?.matches) ? result.matches.length : 0;
|
|
763
|
+
return {
|
|
764
|
+
body: `${String(call.args?.query ?? '').trim()}${state(` · ${found} found`)}${error}`,
|
|
765
|
+
kind,
|
|
766
|
+
title: 'Searched memory',
|
|
767
|
+
};
|
|
768
|
+
}
|
|
753
769
|
if (call.name === 'use_skill') {
|
|
754
770
|
const name = String(result?.name ?? call.args?.name ?? '').trim().replace(/^\//, '');
|
|
755
771
|
return {
|
|
@@ -2761,6 +2777,14 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
|
|
|
2761
2777
|
requestExit();
|
|
2762
2778
|
return;
|
|
2763
2779
|
}
|
|
2780
|
+
if (input === '/memory' || input.startsWith('/memory ')) {
|
|
2781
|
+
appendStaticEntry({
|
|
2782
|
+
body: runMemoryCommand(input.slice('/memory'.length), session.rootDir, session.env),
|
|
2783
|
+
kind: 'system',
|
|
2784
|
+
title: 'Memory',
|
|
2785
|
+
});
|
|
2786
|
+
return;
|
|
2787
|
+
}
|
|
2764
2788
|
if (input === '/skills' || input.startsWith('/skills ')) {
|
|
2765
2789
|
await runSkillsCommand(input.slice('/skills'.length).trim());
|
|
2766
2790
|
return;
|
|
@@ -9,6 +9,7 @@ export const SLASH_COMMANDS = [
|
|
|
9
9
|
{ command: '/new', description: 'start a new conversation; this session remains saved' },
|
|
10
10
|
{ command: '/mcp', description: 'Check MCP connections and available tools' },
|
|
11
11
|
{ command: '/skills', description: 'List installed skills, or add one: /skills add <source>' },
|
|
12
|
+
{ command: '/memory', description: 'See, edit or delete saved notes, or turn memory off' },
|
|
12
13
|
{ command: '/jobs', description: 'Background jobs: pick to view output or kill' },
|
|
13
14
|
{
|
|
14
15
|
command: '/notify',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thegitai/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "TheGitAI is an agentic AI coding tool for your terminal. It reads and searches your repository, writes and edits files, runs your tests, and verifies the change before handing it back.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentic-ai",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"@lydell/node-pty-linux-x64": "1.1.0",
|
|
46
46
|
"@lydell/node-pty-win32-arm64": "1.1.0",
|
|
47
47
|
"@lydell/node-pty-win32-x64": "1.1.0",
|
|
48
|
-
"@thegitai/tui-darwin-arm64": "1.
|
|
49
|
-
"@thegitai/tui-darwin-x64": "1.
|
|
50
|
-
"@thegitai/tui-linux-arm64": "1.
|
|
51
|
-
"@thegitai/tui-linux-x64": "1.
|
|
52
|
-
"@thegitai/tui-win32-x64": "1.
|
|
48
|
+
"@thegitai/tui-darwin-arm64": "1.3.0",
|
|
49
|
+
"@thegitai/tui-darwin-x64": "1.3.0",
|
|
50
|
+
"@thegitai/tui-linux-arm64": "1.3.0",
|
|
51
|
+
"@thegitai/tui-linux-x64": "1.3.0",
|
|
52
|
+
"@thegitai/tui-win32-x64": "1.3.0",
|
|
53
53
|
"@vscode/ripgrep": "1.18.0"
|
|
54
54
|
},
|
|
55
55
|
"repository": {
|