gnosys 5.5.0 → 5.7.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 +44 -0
- package/dist/cli.js +959 -438
- package/dist/cli.js.map +1 -1
- package/dist/lib/audit.d.ts +13 -0
- package/dist/lib/audit.d.ts.map +1 -1
- package/dist/lib/audit.js +42 -0
- package/dist/lib/audit.js.map +1 -1
- package/dist/lib/chat/choose.d.ts +75 -0
- package/dist/lib/chat/choose.d.ts.map +1 -0
- package/dist/lib/chat/choose.js +146 -0
- package/dist/lib/chat/choose.js.map +1 -0
- package/dist/lib/chat/commands.d.ts +96 -0
- package/dist/lib/chat/commands.d.ts.map +1 -0
- package/dist/lib/chat/commands.js +367 -0
- package/dist/lib/chat/commands.js.map +1 -0
- package/dist/lib/chat/focus.d.ts +70 -0
- package/dist/lib/chat/focus.d.ts.map +1 -0
- package/dist/lib/chat/focus.js +120 -0
- package/dist/lib/chat/focus.js.map +1 -0
- package/dist/lib/chat/index.d.ts +32 -0
- package/dist/lib/chat/index.d.ts.map +1 -0
- package/dist/lib/chat/index.js +151 -0
- package/dist/lib/chat/index.js.map +1 -0
- package/dist/lib/chat/intent.d.ts +100 -0
- package/dist/lib/chat/intent.d.ts.map +1 -0
- package/dist/lib/chat/intent.js +192 -0
- package/dist/lib/chat/intent.js.map +1 -0
- package/dist/lib/chat/llmTurn.d.ts +55 -0
- package/dist/lib/chat/llmTurn.d.ts.map +1 -0
- package/dist/lib/chat/llmTurn.js +103 -0
- package/dist/lib/chat/llmTurn.js.map +1 -0
- package/dist/lib/chat/recall.d.ts +58 -0
- package/dist/lib/chat/recall.d.ts.map +1 -0
- package/dist/lib/chat/recall.js +109 -0
- package/dist/lib/chat/recall.js.map +1 -0
- package/dist/lib/chat/render.d.ts +30 -0
- package/dist/lib/chat/render.d.ts.map +1 -0
- package/dist/lib/chat/render.js +755 -0
- package/dist/lib/chat/render.js.map +1 -0
- package/dist/lib/chat/session.d.ts +121 -0
- package/dist/lib/chat/session.d.ts.map +1 -0
- package/dist/lib/chat/session.js +148 -0
- package/dist/lib/chat/session.js.map +1 -0
- package/dist/lib/chat/toolFence.d.ts +54 -0
- package/dist/lib/chat/toolFence.d.ts.map +1 -0
- package/dist/lib/chat/toolFence.js +90 -0
- package/dist/lib/chat/toolFence.js.map +1 -0
- package/dist/lib/chat/tools.d.ts +48 -0
- package/dist/lib/chat/tools.d.ts.map +1 -0
- package/dist/lib/chat/tools.js +338 -0
- package/dist/lib/chat/tools.js.map +1 -0
- package/dist/lib/chat/types.d.ts +42 -0
- package/dist/lib/chat/types.d.ts.map +1 -0
- package/dist/lib/chat/types.js +6 -0
- package/dist/lib/chat/types.js.map +1 -0
- package/dist/lib/chat/write.d.ts +66 -0
- package/dist/lib/chat/write.d.ts.map +1 -0
- package/dist/lib/chat/write.js +203 -0
- package/dist/lib/chat/write.js.map +1 -0
- package/dist/lib/db.d.ts +41 -1
- package/dist/lib/db.d.ts.map +1 -1
- package/dist/lib/db.js +136 -28
- package/dist/lib/db.js.map +1 -1
- package/dist/lib/exportProject.d.ts +51 -0
- package/dist/lib/exportProject.d.ts.map +1 -0
- package/dist/lib/exportProject.js +72 -0
- package/dist/lib/exportProject.js.map +1 -0
- package/dist/lib/importProject.d.ts +35 -0
- package/dist/lib/importProject.d.ts.map +1 -0
- package/dist/lib/importProject.js +135 -0
- package/dist/lib/importProject.js.map +1 -0
- package/dist/lib/remote.d.ts +23 -0
- package/dist/lib/remote.d.ts.map +1 -1
- package/dist/lib/remote.js +88 -0
- package/dist/lib/remote.js.map +1 -1
- package/dist/lib/remoteWizard.d.ts.map +1 -1
- package/dist/lib/remoteWizard.js +13 -17
- package/dist/lib/remoteWizard.js.map +1 -1
- package/dist/lib/setup/sections/ides.d.ts +20 -0
- package/dist/lib/setup/sections/ides.d.ts.map +1 -0
- package/dist/lib/setup/sections/ides.js +124 -0
- package/dist/lib/setup/sections/ides.js.map +1 -0
- package/dist/lib/setup/sections/preferences.d.ts +30 -0
- package/dist/lib/setup/sections/preferences.d.ts.map +1 -0
- package/dist/lib/setup/sections/preferences.js +128 -0
- package/dist/lib/setup/sections/preferences.js.map +1 -0
- package/dist/lib/setup/sections/routing.d.ts +21 -0
- package/dist/lib/setup/sections/routing.d.ts.map +1 -0
- package/dist/lib/setup/sections/routing.js +160 -0
- package/dist/lib/setup/sections/routing.js.map +1 -0
- package/dist/lib/setup/summary.d.ts +42 -0
- package/dist/lib/setup/summary.d.ts.map +1 -0
- package/dist/lib/setup/summary.js +206 -0
- package/dist/lib/setup/summary.js.map +1 -0
- package/dist/lib/timeline.d.ts +7 -0
- package/dist/lib/timeline.d.ts.map +1 -1
- package/dist/lib/timeline.js +19 -5
- package/dist/lib/timeline.js.map +1 -1
- package/package.json +7 -1
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slash command dispatcher for the chat TUI.
|
|
3
|
+
*
|
|
4
|
+
* Each command receives the chat state and returns a result describing what
|
|
5
|
+
* happened. The TUI translates the result into UI updates (system messages,
|
|
6
|
+
* exit, conversation buffer changes, etc.). Commands run synchronously when
|
|
7
|
+
* possible; async ones return a Promise.
|
|
8
|
+
*
|
|
9
|
+
* Phase 2 commands: /help, /clear, /history, /read, /list, /tags, /dashboard,
|
|
10
|
+
* /quit, /provider. Phases 3–7 add /pin, /scope, /recall, /threshold,
|
|
11
|
+
* /reinforce, /remember, /save-turn, /attach, /focus, /branch, /resume-focus,
|
|
12
|
+
* /dream-here, /search-chats, /export.
|
|
13
|
+
*/
|
|
14
|
+
// ─── Built-in commands ──────────────────────────────────────────────────
|
|
15
|
+
const helpCmd = {
|
|
16
|
+
name: "/help",
|
|
17
|
+
summary: "Show available commands",
|
|
18
|
+
handler: (_ctx, _args) => {
|
|
19
|
+
const all = listCommands();
|
|
20
|
+
const lines = ["Available commands:"];
|
|
21
|
+
for (const c of all) {
|
|
22
|
+
const alias = c.aliases?.length ? ` (alias: ${c.aliases.join(", ")})` : "";
|
|
23
|
+
lines.push(` ${c.name.padEnd(14)}${c.summary}${alias}`);
|
|
24
|
+
if (c.usage)
|
|
25
|
+
lines.push(` ${c.usage}`);
|
|
26
|
+
}
|
|
27
|
+
lines.push("");
|
|
28
|
+
lines.push("Type any other text to chat with the model.");
|
|
29
|
+
return { kind: "show", lines };
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
const clearCmd = {
|
|
33
|
+
name: "/clear",
|
|
34
|
+
summary: "Clear the visible conversation buffer (session log preserved)",
|
|
35
|
+
handler: () => ({ kind: "clear-buffer" }),
|
|
36
|
+
};
|
|
37
|
+
const quitCmd = {
|
|
38
|
+
name: "/quit",
|
|
39
|
+
aliases: ["/exit", "/q"],
|
|
40
|
+
summary: "Exit chat (session log preserved)",
|
|
41
|
+
handler: () => ({ kind: "exit" }),
|
|
42
|
+
};
|
|
43
|
+
const historyCmd = {
|
|
44
|
+
name: "/history",
|
|
45
|
+
summary: "Show the visible buffer turn-by-turn",
|
|
46
|
+
handler: (ctx) => {
|
|
47
|
+
if (ctx.buffer.length === 0) {
|
|
48
|
+
return { kind: "show", lines: ["(no turns yet)"] };
|
|
49
|
+
}
|
|
50
|
+
const lines = [`Buffer has ${ctx.buffer.length} turn(s):`];
|
|
51
|
+
ctx.buffer.forEach((t, i) => {
|
|
52
|
+
const preview = t.text.length > 80 ? t.text.slice(0, 77) + "..." : t.text;
|
|
53
|
+
lines.push(` [${i}] ${t.role.padEnd(9)} ${preview}`);
|
|
54
|
+
});
|
|
55
|
+
return { kind: "show", lines };
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
const providerCmd = {
|
|
59
|
+
name: "/provider",
|
|
60
|
+
usage: "/provider <name> [model]",
|
|
61
|
+
summary: "Switch LLM provider mid-session (anthropic, openai, groq, ollama, etc.)",
|
|
62
|
+
handler: (_ctx, args) => {
|
|
63
|
+
if (args.length === 0) {
|
|
64
|
+
return { kind: "error", message: "Usage: /provider <name> [model]" };
|
|
65
|
+
}
|
|
66
|
+
return { kind: "switch-provider", provider: args[0], model: args[1] };
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
const readCmd = {
|
|
70
|
+
name: "/read",
|
|
71
|
+
usage: "/read <memoryId>",
|
|
72
|
+
summary: "Read a specific memory by ID",
|
|
73
|
+
handler: async (_ctx, args) => {
|
|
74
|
+
if (args.length === 0) {
|
|
75
|
+
return { kind: "error", message: "Usage: /read <memoryId>" };
|
|
76
|
+
}
|
|
77
|
+
const { GnosysDB } = await import("../db.js");
|
|
78
|
+
const db = GnosysDB.openCentral();
|
|
79
|
+
if (!db.isAvailable()) {
|
|
80
|
+
db.close();
|
|
81
|
+
return { kind: "error", message: "Central DB unavailable" };
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const mem = db.getMemory(args[0]);
|
|
85
|
+
if (!mem)
|
|
86
|
+
return { kind: "error", message: `Memory not found: ${args[0]}` };
|
|
87
|
+
return {
|
|
88
|
+
kind: "show",
|
|
89
|
+
lines: [
|
|
90
|
+
`# ${mem.title}`,
|
|
91
|
+
`id: ${mem.id}`,
|
|
92
|
+
`category: ${mem.category}`,
|
|
93
|
+
`confidence: ${mem.confidence}`,
|
|
94
|
+
`tags: ${mem.tags}`,
|
|
95
|
+
``,
|
|
96
|
+
mem.content,
|
|
97
|
+
],
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
db.close();
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
const listCmd = {
|
|
106
|
+
name: "/list",
|
|
107
|
+
usage: "/list [limit]",
|
|
108
|
+
summary: "List recent chat sessions",
|
|
109
|
+
handler: async (_ctx, args) => {
|
|
110
|
+
const { listSessions } = await import("./session.js");
|
|
111
|
+
const limit = args[0] ? parseInt(args[0], 10) : 20;
|
|
112
|
+
const sessions = listSessions().slice(0, limit);
|
|
113
|
+
if (sessions.length === 0) {
|
|
114
|
+
return { kind: "show", lines: ["(no sessions yet)"] };
|
|
115
|
+
}
|
|
116
|
+
const lines = [`Recent ${sessions.length} session(s):`];
|
|
117
|
+
for (const s of sessions) {
|
|
118
|
+
const proj = s.project_id ? s.project_id.slice(0, 8) : "—";
|
|
119
|
+
const sizeKb = (s.size_bytes / 1024).toFixed(1);
|
|
120
|
+
lines.push(` ${s.id.slice(0, 12)}… ${s.last_active.slice(0, 19)} proj=${proj} turns=${s.turns} ${sizeKb}KB`);
|
|
121
|
+
}
|
|
122
|
+
return { kind: "show", lines };
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
const tagsCmd = {
|
|
126
|
+
name: "/tags",
|
|
127
|
+
summary: "Show the tag registry for the current store",
|
|
128
|
+
handler: async () => {
|
|
129
|
+
const { GnosysResolver } = await import("../resolver.js");
|
|
130
|
+
const { GnosysTagRegistry } = await import("../tags.js");
|
|
131
|
+
const r = new GnosysResolver();
|
|
132
|
+
await r.resolve();
|
|
133
|
+
const stores = r.getStores();
|
|
134
|
+
if (stores.length === 0)
|
|
135
|
+
return { kind: "error", message: "No store found." };
|
|
136
|
+
const reg = new GnosysTagRegistry(stores[0].path);
|
|
137
|
+
await reg.load();
|
|
138
|
+
const all = reg.getAllTags();
|
|
139
|
+
if (all.length === 0)
|
|
140
|
+
return { kind: "show", lines: ["(no tags registered)"] };
|
|
141
|
+
return {
|
|
142
|
+
kind: "show",
|
|
143
|
+
lines: [`Tags (${all.length}):`, ...all.map((t) => ` ${t}`)],
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
const dashboardCmd = {
|
|
148
|
+
name: "/dashboard",
|
|
149
|
+
summary: "Show project memory dashboard",
|
|
150
|
+
handler: async () => {
|
|
151
|
+
const { GnosysDB } = await import("../db.js");
|
|
152
|
+
const db = GnosysDB.openCentral();
|
|
153
|
+
if (!db.isAvailable()) {
|
|
154
|
+
db.close();
|
|
155
|
+
return { kind: "error", message: "Central DB unavailable" };
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
const projects = db.getAllProjects();
|
|
159
|
+
const counts = db.getMemoryCount();
|
|
160
|
+
const lines = [
|
|
161
|
+
`Projects: ${projects.length}`,
|
|
162
|
+
`Active memories: ${counts.active}`,
|
|
163
|
+
`Archived memories: ${counts.archived}`,
|
|
164
|
+
``,
|
|
165
|
+
...projects.slice(0, 10).map((p) => ` ${p.id.slice(0, 8)} ${p.name}`),
|
|
166
|
+
];
|
|
167
|
+
return { kind: "show", lines };
|
|
168
|
+
}
|
|
169
|
+
finally {
|
|
170
|
+
db.close();
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
// ─── Phase 3 commands: recall, pinning, scope, threshold, reinforce ───
|
|
175
|
+
const pinCmd = {
|
|
176
|
+
name: "/pin",
|
|
177
|
+
usage: "/pin <memoryId>",
|
|
178
|
+
summary: "Pin a memory so it's included in every recall (until /unpin)",
|
|
179
|
+
handler: (_ctx, args) => {
|
|
180
|
+
if (args.length === 0)
|
|
181
|
+
return { kind: "error", message: "Usage: /pin <memoryId>" };
|
|
182
|
+
return { kind: "pin", memoryId: args[0] };
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
const unpinCmd = {
|
|
186
|
+
name: "/unpin",
|
|
187
|
+
usage: "/unpin <memoryId>",
|
|
188
|
+
summary: "Remove a pinned memory",
|
|
189
|
+
handler: (_ctx, args) => {
|
|
190
|
+
if (args.length === 0)
|
|
191
|
+
return { kind: "error", message: "Usage: /unpin <memoryId>" };
|
|
192
|
+
return { kind: "unpin", memoryId: args[0] };
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
const scopeCmd = {
|
|
196
|
+
name: "/scope",
|
|
197
|
+
usage: "/scope project|user|global|federated",
|
|
198
|
+
summary: "Change recall scope mid-session (default: federated)",
|
|
199
|
+
handler: (_ctx, args) => {
|
|
200
|
+
if (args.length === 0)
|
|
201
|
+
return { kind: "error", message: "Usage: /scope project|user|global|federated" };
|
|
202
|
+
const valid = ["project", "user", "global", "federated"];
|
|
203
|
+
if (!valid.includes(args[0])) {
|
|
204
|
+
return { kind: "error", message: `Invalid scope. Use one of: ${valid.join(", ")}` };
|
|
205
|
+
}
|
|
206
|
+
return { kind: "scope", scope: args[0] };
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
const thresholdCmd = {
|
|
210
|
+
name: "/threshold",
|
|
211
|
+
usage: "/threshold <0.0-1.0>",
|
|
212
|
+
summary: "Drop recalled memories below this confidence (0 disables)",
|
|
213
|
+
handler: (_ctx, args) => {
|
|
214
|
+
if (args.length === 0)
|
|
215
|
+
return { kind: "error", message: "Usage: /threshold <0.0-1.0>" };
|
|
216
|
+
const v = parseFloat(args[0]);
|
|
217
|
+
if (Number.isNaN(v) || v < 0 || v > 1) {
|
|
218
|
+
return { kind: "error", message: "Threshold must be between 0.0 and 1.0" };
|
|
219
|
+
}
|
|
220
|
+
return { kind: "threshold", value: v };
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
const recallCmd = {
|
|
224
|
+
name: "/recall",
|
|
225
|
+
usage: "/recall <query>",
|
|
226
|
+
summary: "Preview what would be recalled for this query (metadata only, no LLM call)",
|
|
227
|
+
handler: (_ctx, args) => {
|
|
228
|
+
if (args.length === 0)
|
|
229
|
+
return { kind: "error", message: "Usage: /recall <query>" };
|
|
230
|
+
return { kind: "preview-recall", query: args.join(" ") };
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
const reinforceCmd = {
|
|
234
|
+
name: "/reinforce",
|
|
235
|
+
usage: "/reinforce <memoryId>",
|
|
236
|
+
summary: "Mark a memory as useful — boosts future ranking",
|
|
237
|
+
handler: (_ctx, args) => {
|
|
238
|
+
if (args.length === 0)
|
|
239
|
+
return { kind: "error", message: "Usage: /reinforce <memoryId>" };
|
|
240
|
+
return { kind: "reinforce", memoryId: args[0] };
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
// ─── Phase 4 commands: memory writing ────────────────────────────────────
|
|
244
|
+
const rememberCmd = {
|
|
245
|
+
name: "/remember",
|
|
246
|
+
usage: "/remember <text>",
|
|
247
|
+
summary: "Save text as a new memory in the current project",
|
|
248
|
+
handler: (_ctx, args) => {
|
|
249
|
+
if (args.length === 0)
|
|
250
|
+
return { kind: "error", message: "Usage: /remember <text>" };
|
|
251
|
+
return { kind: "remember", text: args.join(" ") };
|
|
252
|
+
},
|
|
253
|
+
};
|
|
254
|
+
const saveTurnCmd = {
|
|
255
|
+
name: "/save-turn",
|
|
256
|
+
summary: "Distill the most recent user+assistant exchange into a memory",
|
|
257
|
+
handler: () => ({ kind: "save-turn" }),
|
|
258
|
+
};
|
|
259
|
+
const attachCmd = {
|
|
260
|
+
name: "/attach",
|
|
261
|
+
usage: "/attach <filePath>",
|
|
262
|
+
summary: "Ingest a file (PDF, image, audio, video, DOCX, MD) and pin it to this session",
|
|
263
|
+
handler: (_ctx, args) => {
|
|
264
|
+
if (args.length === 0)
|
|
265
|
+
return { kind: "error", message: "Usage: /attach <filePath>" };
|
|
266
|
+
return { kind: "attach", filePath: args.join(" ") };
|
|
267
|
+
},
|
|
268
|
+
};
|
|
269
|
+
// ─── Phase 7 commands: focus boundaries ──────────────────────────────────
|
|
270
|
+
const focusCmd = {
|
|
271
|
+
name: "/focus",
|
|
272
|
+
usage: "/focus <topic>",
|
|
273
|
+
summary: "Clear the working buffer and declare a new focus (session log preserved)",
|
|
274
|
+
handler: (_ctx, args) => {
|
|
275
|
+
if (args.length === 0)
|
|
276
|
+
return { kind: "error", message: "Usage: /focus <topic>" };
|
|
277
|
+
return { kind: "focus", topic: args.join(" ") };
|
|
278
|
+
},
|
|
279
|
+
};
|
|
280
|
+
const branchCmd = {
|
|
281
|
+
name: "/branch",
|
|
282
|
+
summary: "Fork the working buffer — explore a what-if without losing this thread",
|
|
283
|
+
handler: () => ({ kind: "branch" }),
|
|
284
|
+
};
|
|
285
|
+
const resumeFocusCmd = {
|
|
286
|
+
name: "/resume-focus",
|
|
287
|
+
usage: "/resume-focus [topic]",
|
|
288
|
+
summary: "Restore a prior focus (no arg = pop the most recent branch)",
|
|
289
|
+
handler: (_ctx, args) => {
|
|
290
|
+
return { kind: "resume-focus", topic: args[0] };
|
|
291
|
+
},
|
|
292
|
+
};
|
|
293
|
+
// ─── Phase 8 commands: polish ────────────────────────────────────────────
|
|
294
|
+
const exportSessionCmd = {
|
|
295
|
+
name: "/export",
|
|
296
|
+
usage: "/export <file.md>",
|
|
297
|
+
summary: "Dump the current chat session as markdown",
|
|
298
|
+
handler: (_ctx, args) => {
|
|
299
|
+
if (args.length === 0)
|
|
300
|
+
return { kind: "error", message: "Usage: /export <file.md>" };
|
|
301
|
+
return { kind: "export-session", filePath: args.join(" ") };
|
|
302
|
+
},
|
|
303
|
+
};
|
|
304
|
+
const searchChatsCmd = {
|
|
305
|
+
name: "/search-chats",
|
|
306
|
+
usage: "/search-chats <query>",
|
|
307
|
+
summary: "Full-text search across all chat session logs",
|
|
308
|
+
handler: (_ctx, args) => {
|
|
309
|
+
if (args.length === 0)
|
|
310
|
+
return { kind: "error", message: "Usage: /search-chats <query>" };
|
|
311
|
+
return { kind: "search-chats", query: args.join(" ") };
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
const dreamHereCmd = {
|
|
315
|
+
name: "/dream-here",
|
|
316
|
+
summary: "Run a dream cycle scoped to memories surfaced in this session",
|
|
317
|
+
handler: () => ({ kind: "dream-here" }),
|
|
318
|
+
};
|
|
319
|
+
const REGISTRY = [
|
|
320
|
+
helpCmd,
|
|
321
|
+
clearCmd,
|
|
322
|
+
quitCmd,
|
|
323
|
+
historyCmd,
|
|
324
|
+
providerCmd,
|
|
325
|
+
readCmd,
|
|
326
|
+
listCmd,
|
|
327
|
+
tagsCmd,
|
|
328
|
+
dashboardCmd,
|
|
329
|
+
pinCmd,
|
|
330
|
+
unpinCmd,
|
|
331
|
+
scopeCmd,
|
|
332
|
+
thresholdCmd,
|
|
333
|
+
recallCmd,
|
|
334
|
+
reinforceCmd,
|
|
335
|
+
rememberCmd,
|
|
336
|
+
saveTurnCmd,
|
|
337
|
+
attachCmd,
|
|
338
|
+
focusCmd,
|
|
339
|
+
branchCmd,
|
|
340
|
+
resumeFocusCmd,
|
|
341
|
+
exportSessionCmd,
|
|
342
|
+
searchChatsCmd,
|
|
343
|
+
dreamHereCmd,
|
|
344
|
+
];
|
|
345
|
+
export function listCommands() {
|
|
346
|
+
return REGISTRY;
|
|
347
|
+
}
|
|
348
|
+
export function findCommand(name) {
|
|
349
|
+
const lower = name.toLowerCase();
|
|
350
|
+
return REGISTRY.find((c) => c.name.toLowerCase() === lower ||
|
|
351
|
+
c.aliases?.some((a) => a.toLowerCase() === lower));
|
|
352
|
+
}
|
|
353
|
+
/** Parse a raw input line and dispatch if it's a slash command. Returns null if it's not a command. */
|
|
354
|
+
export async function dispatchCommand(raw, ctx) {
|
|
355
|
+
const trimmed = raw.trim();
|
|
356
|
+
if (!trimmed.startsWith("/"))
|
|
357
|
+
return null;
|
|
358
|
+
const parts = trimmed.split(/\s+/);
|
|
359
|
+
const name = parts[0];
|
|
360
|
+
const args = parts.slice(1);
|
|
361
|
+
const cmd = findCommand(name);
|
|
362
|
+
if (!cmd) {
|
|
363
|
+
return { kind: "error", message: `Unknown command: ${name}. Type /help.` };
|
|
364
|
+
}
|
|
365
|
+
return await cmd.handler(ctx, args);
|
|
366
|
+
}
|
|
367
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../../src/lib/chat/commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AA8CH,2EAA2E;AAE3E,MAAM,OAAO,GAAgB;IAC3B,IAAI,EAAE,OAAO;IACb,OAAO,EAAE,yBAAyB;IAClC,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACvB,MAAM,GAAG,GAAG,YAAY,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAa,CAAC,qBAAqB,CAAC,CA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AACvG,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,GAAW,EACX,GAAmB;IAEnB,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAC3B,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAE1C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACnC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACtB,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE5B,MAAM,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,oBAAoB,IAAI,eAAe,EAAE,CAAC;IAC7E,CAAC;IACD,OAAO,MAAM,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Focus boundaries — replaces the traditional "new chat" model.
|
|
3
|
+
*
|
|
4
|
+
* With perfect memory in gnosys, sessions don't need to be containers of
|
|
5
|
+
* context. The conversation log is the audit trail; focus boundaries are
|
|
6
|
+
* the working framing. /focus clears the working buffer (what the LLM sees)
|
|
7
|
+
* but preserves the session log + the prior focus's buffer for /resume-focus.
|
|
8
|
+
*
|
|
9
|
+
* /branch is a sibling primitive: same focus, but with the current buffer
|
|
10
|
+
* preserved so you can explore a hypothetical and come back.
|
|
11
|
+
*
|
|
12
|
+
* Auto-summarize fires when the buffer approaches the model's context
|
|
13
|
+
* window — distills the buffer into a memory, replaces it with a single
|
|
14
|
+
* system reference. Transparent to the user.
|
|
15
|
+
*/
|
|
16
|
+
import { Turn } from "./types.js";
|
|
17
|
+
export interface FocusSnapshot {
|
|
18
|
+
/** Focus name. */
|
|
19
|
+
topic: string;
|
|
20
|
+
/** When this snapshot was created. */
|
|
21
|
+
ts: string;
|
|
22
|
+
/** Conversation buffer at the moment of the snapshot. */
|
|
23
|
+
buffer: Turn[];
|
|
24
|
+
/** True for snapshots created by /branch (not /focus). */
|
|
25
|
+
branched?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface FocusState {
|
|
28
|
+
/** Currently declared focus (null = "general" / no focus declared). */
|
|
29
|
+
current: string | null;
|
|
30
|
+
/** Snapshots keyed by topic. /focus saves the prior focus here before clearing. */
|
|
31
|
+
snapshots: Map<string, FocusSnapshot>;
|
|
32
|
+
/** Branch stack — LIFO of forked buffers from /branch. */
|
|
33
|
+
branches: FocusSnapshot[];
|
|
34
|
+
}
|
|
35
|
+
export declare function newFocusState(): FocusState;
|
|
36
|
+
/**
|
|
37
|
+
* Apply /focus — save current state under the prior focus name, then clear.
|
|
38
|
+
* Returns the new state and the new (empty) buffer.
|
|
39
|
+
*/
|
|
40
|
+
export declare function applyFocus(state: FocusState, buffer: Turn[], newTopic: string, nowIso: string): {
|
|
41
|
+
state: FocusState;
|
|
42
|
+
buffer: Turn[];
|
|
43
|
+
previousTopic: string | null;
|
|
44
|
+
};
|
|
45
|
+
/** Apply /branch — preserve buffer onto the branch stack, keep editing same buffer. */
|
|
46
|
+
export declare function applyBranch(state: FocusState, buffer: Turn[], nowIso: string): FocusState;
|
|
47
|
+
/**
|
|
48
|
+
* Apply /resume-focus — load a snapshot back into the buffer.
|
|
49
|
+
* Returns null if no snapshot exists for the requested topic.
|
|
50
|
+
*/
|
|
51
|
+
export declare function applyResumeFocus(state: FocusState, buffer: Turn[], topic: string, nowIso: string): {
|
|
52
|
+
state: FocusState;
|
|
53
|
+
buffer: Turn[];
|
|
54
|
+
} | null;
|
|
55
|
+
/** Pop the most recent branch off the stack and restore it. Returns null when empty. */
|
|
56
|
+
export declare function popBranch(state: FocusState): {
|
|
57
|
+
state: FocusState;
|
|
58
|
+
buffer: Turn[];
|
|
59
|
+
topic: string;
|
|
60
|
+
} | null;
|
|
61
|
+
/** Rough token estimate — 1 token ≈ 4 chars for English / code. */
|
|
62
|
+
export declare function estimateTokens(buffer: Turn[]): number;
|
|
63
|
+
/** Threshold check: returns true when the buffer is near the context window cap. */
|
|
64
|
+
export declare function shouldAutoSummarize(buffer: Turn[], contextWindowTokens: number, ratio?: number): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Build the prompt that asks the LLM to distill a buffer.
|
|
67
|
+
* Used in Phase 7's auto-summarize and exposed for /save-turn-style flows.
|
|
68
|
+
*/
|
|
69
|
+
export declare function buildSummaryPrompt(buffer: Turn[], focus: string | null): string;
|
|
70
|
+
//# sourceMappingURL=focus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/focus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,MAAM,WAAW,aAAa;IAC5B,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,yDAAyD;IACzD,MAAM,EAAE,IAAI,EAAE,CAAC;IACf,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,uEAAuE;IACvE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,mFAAmF;IACnF,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACtC,0DAA0D;IAC1D,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC3B;AAED,wBAAgB,aAAa,IAAI,UAAU,CAE1C;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,IAAI,EAAE,EACd,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,IAAI,EAAE,CAAC;IAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAmBrE;AAED,uFAAuF;AACvF,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAWzF;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,IAAI,EAAE,EACd,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,IAAI,EAAE,CAAA;CAAE,GAAG,IAAI,CAe9C;AAED,wFAAwF;AACxF,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,IAAI,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CASxG;AAID,mEAAmE;AACnE,wBAAgB,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAIrD;AAED,oFAAoF;AACpF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,mBAAmB,EAAE,MAAM,EAAE,KAAK,SAAM,GAAG,OAAO,CAErG;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAkB/E"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Focus boundaries — replaces the traditional "new chat" model.
|
|
3
|
+
*
|
|
4
|
+
* With perfect memory in gnosys, sessions don't need to be containers of
|
|
5
|
+
* context. The conversation log is the audit trail; focus boundaries are
|
|
6
|
+
* the working framing. /focus clears the working buffer (what the LLM sees)
|
|
7
|
+
* but preserves the session log + the prior focus's buffer for /resume-focus.
|
|
8
|
+
*
|
|
9
|
+
* /branch is a sibling primitive: same focus, but with the current buffer
|
|
10
|
+
* preserved so you can explore a hypothetical and come back.
|
|
11
|
+
*
|
|
12
|
+
* Auto-summarize fires when the buffer approaches the model's context
|
|
13
|
+
* window — distills the buffer into a memory, replaces it with a single
|
|
14
|
+
* system reference. Transparent to the user.
|
|
15
|
+
*/
|
|
16
|
+
export function newFocusState() {
|
|
17
|
+
return { current: null, snapshots: new Map(), branches: [] };
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Apply /focus — save current state under the prior focus name, then clear.
|
|
21
|
+
* Returns the new state and the new (empty) buffer.
|
|
22
|
+
*/
|
|
23
|
+
export function applyFocus(state, buffer, newTopic, nowIso) {
|
|
24
|
+
const previousTopic = state.current;
|
|
25
|
+
const newSnapshots = new Map(state.snapshots);
|
|
26
|
+
// Save current buffer under the prior focus (skip if there's nothing to save)
|
|
27
|
+
if (buffer.length > 0) {
|
|
28
|
+
const key = previousTopic ?? "general";
|
|
29
|
+
newSnapshots.set(key, {
|
|
30
|
+
topic: key,
|
|
31
|
+
ts: nowIso,
|
|
32
|
+
buffer,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
state: { ...state, current: newTopic, snapshots: newSnapshots },
|
|
37
|
+
buffer: [],
|
|
38
|
+
previousTopic,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** Apply /branch — preserve buffer onto the branch stack, keep editing same buffer. */
|
|
42
|
+
export function applyBranch(state, buffer, nowIso) {
|
|
43
|
+
const branches = [
|
|
44
|
+
...state.branches,
|
|
45
|
+
{
|
|
46
|
+
topic: state.current ?? "general",
|
|
47
|
+
ts: nowIso,
|
|
48
|
+
buffer: [...buffer],
|
|
49
|
+
branched: true,
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
return { ...state, branches };
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Apply /resume-focus — load a snapshot back into the buffer.
|
|
56
|
+
* Returns null if no snapshot exists for the requested topic.
|
|
57
|
+
*/
|
|
58
|
+
export function applyResumeFocus(state, buffer, topic, nowIso) {
|
|
59
|
+
const snap = state.snapshots.get(topic);
|
|
60
|
+
if (!snap)
|
|
61
|
+
return null;
|
|
62
|
+
// Save current buffer under the active focus before swapping
|
|
63
|
+
const newSnapshots = new Map(state.snapshots);
|
|
64
|
+
if (buffer.length > 0 && state.current) {
|
|
65
|
+
newSnapshots.set(state.current, { topic: state.current, ts: nowIso, buffer });
|
|
66
|
+
}
|
|
67
|
+
newSnapshots.delete(topic); // consumed
|
|
68
|
+
return {
|
|
69
|
+
state: { ...state, current: topic, snapshots: newSnapshots },
|
|
70
|
+
buffer: [...snap.buffer],
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/** Pop the most recent branch off the stack and restore it. Returns null when empty. */
|
|
74
|
+
export function popBranch(state) {
|
|
75
|
+
if (state.branches.length === 0)
|
|
76
|
+
return null;
|
|
77
|
+
const last = state.branches[state.branches.length - 1];
|
|
78
|
+
const branches = state.branches.slice(0, -1);
|
|
79
|
+
return {
|
|
80
|
+
state: { ...state, current: last.topic, branches },
|
|
81
|
+
buffer: [...last.buffer],
|
|
82
|
+
topic: last.topic,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
// ─── Auto-summarize ──────────────────────────────────────────────────────
|
|
86
|
+
/** Rough token estimate — 1 token ≈ 4 chars for English / code. */
|
|
87
|
+
export function estimateTokens(buffer) {
|
|
88
|
+
let chars = 0;
|
|
89
|
+
for (const t of buffer)
|
|
90
|
+
chars += t.text.length;
|
|
91
|
+
return Math.ceil(chars / 4);
|
|
92
|
+
}
|
|
93
|
+
/** Threshold check: returns true when the buffer is near the context window cap. */
|
|
94
|
+
export function shouldAutoSummarize(buffer, contextWindowTokens, ratio = 0.8) {
|
|
95
|
+
return estimateTokens(buffer) >= contextWindowTokens * ratio;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Build the prompt that asks the LLM to distill a buffer.
|
|
99
|
+
* Used in Phase 7's auto-summarize and exposed for /save-turn-style flows.
|
|
100
|
+
*/
|
|
101
|
+
export function buildSummaryPrompt(buffer, focus) {
|
|
102
|
+
const transcript = buffer
|
|
103
|
+
.map((t) => {
|
|
104
|
+
if (t.role === "user")
|
|
105
|
+
return `User: ${t.text}`;
|
|
106
|
+
if (t.role === "assistant")
|
|
107
|
+
return `Assistant: ${t.text}`;
|
|
108
|
+
return "";
|
|
109
|
+
})
|
|
110
|
+
.filter((s) => s.length > 0)
|
|
111
|
+
.join("\n\n");
|
|
112
|
+
const focusLine = focus ? `Focus: ${focus}\n\n` : "";
|
|
113
|
+
return `${focusLine}Distill this chat transcript into a single concise memory the user can reference later. Capture decisions made, conclusions reached, and open questions surfaced. Skip pleasantries.
|
|
114
|
+
|
|
115
|
+
Transcript:
|
|
116
|
+
${transcript}
|
|
117
|
+
|
|
118
|
+
Output the distilled memory as plain markdown. No fences, no commentary.`;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=focus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus.js","sourceRoot":"","sources":["../../../src/lib/chat/focus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAwBH,MAAM,UAAU,aAAa;IAC3B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,GAAG,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CACxB,KAAiB,EACjB,MAAc,EACd,QAAgB,EAChB,MAAc;IAEd,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC;IACpC,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAE9C,8EAA8E;IAC9E,IAAI,MAAM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,mBAAmB,GAAG,KAAK,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAc,EAAE,KAAoB;IACrE,MAAM,UAAU,GAAG,MAAM;SACtB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM;YAAE,OAAO,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC;QAChD,IAAI,CAAC,CAAC,IAAI,KAAK,WAAW;YAAE,OAAO,cAAc,CAAC,CAAC,IAAI,EAAE,CAAC;QAC1D,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;SAC3B,IAAI,CAAC,MAAM,CAAC,CAAC;IAEhB,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,UAAU,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IAErD,OAAO,GAAG,SAAS;;;EAGnB,UAAU;;yEAE6D,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat orchestrator — the entry point invoked by `gnosys chat`.
|
|
3
|
+
*
|
|
4
|
+
* Phase 2 responsibilities:
|
|
5
|
+
* - Start or resume a session (writes start event to log)
|
|
6
|
+
* - Resolve project context (auto-detect from cwd)
|
|
7
|
+
* - Pick the LLM provider/model
|
|
8
|
+
* - Mount the ink ChatApp
|
|
9
|
+
* - On exit, flush a session_end event
|
|
10
|
+
*/
|
|
11
|
+
import { GnosysConfig } from "../config.js";
|
|
12
|
+
import { SessionEvent } from "./session.js";
|
|
13
|
+
import { Turn } from "./types.js";
|
|
14
|
+
export interface StartChatOptions {
|
|
15
|
+
config: GnosysConfig;
|
|
16
|
+
resume?: string;
|
|
17
|
+
projectId?: string;
|
|
18
|
+
providerName?: string;
|
|
19
|
+
modelName?: string;
|
|
20
|
+
}
|
|
21
|
+
/** Reconstruct the conversation buffer from session log events. */
|
|
22
|
+
export declare function bufferFromEvents(events: SessionEvent[]): Turn[];
|
|
23
|
+
/**
|
|
24
|
+
* Start an interactive chat. Mounts the ink TUI, blocks until /quit or Ctrl-C.
|
|
25
|
+
* Lazily imports React/ink so non-chat CLI commands aren't paying for them.
|
|
26
|
+
*/
|
|
27
|
+
export declare function startChat(opts: StartChatOptions): Promise<void>;
|
|
28
|
+
/** Print recent sessions to stdout (for `gnosys chat --list`). */
|
|
29
|
+
export declare function printSessionList(limit?: number): void;
|
|
30
|
+
/** Print search results across all session logs (for `gnosys chat --search`). */
|
|
31
|
+
export declare function printSearchResults(query: string, limit?: number): void;
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/chat/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAML,YAAY,EACb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,IAAI,EAAkB,MAAM,YAAY,CAAC;AAGlD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,mEAAmE;AACnE,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,EAAE,CAgB/D;AAmBD;;;GAGG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4DrE;AAED,kEAAkE;AAClE,wBAAgB,gBAAgB,CAAC,KAAK,SAAK,GAAG,IAAI,CAcjD;AAED,iFAAiF;AACjF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAK,GAAG,IAAI,CA2BlE"}
|