@takimcizgisi/ajan 0.2.5 → 0.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.
Potentially problematic release.
This version of @takimcizgisi/ajan might be problematic. Click here for more details.
- package/LICENSE +227 -674
- package/README.md +243 -305
- package/ajan-logo.txt +2 -0
- package/dist/config/configManager.js +122 -19
- package/dist/config/types.d.ts +37 -0
- package/dist/core/agent.d.ts +1 -1
- package/dist/core/agent.js +25 -4
- package/dist/discord/presence.d.ts +65 -0
- package/dist/discord/presence.js +401 -0
- package/dist/engine/llama.d.ts +5 -0
- package/dist/engine/llama.js +19 -5
- package/dist/engine/modelManager.d.ts +0 -1
- package/dist/engine/modelManager.js +0 -8
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/service.js +0 -1
- package/dist/tools/playground.d.ts +4 -0
- package/dist/tools/playground.js +125 -0
- package/dist/tools/registry.d.ts +0 -1
- package/dist/tools/registry.js +5 -4
- package/dist/tools/taskComplete.js +16 -4
- package/dist/tools/terminal.js +12 -12
- package/dist/utils/paths.d.ts +1 -0
- package/dist/utils/paths.js +29 -11
- package/package.json +78 -106
- package/scripts/build-vscode.mjs +28 -0
- package/scripts/ensure-tgz.mjs +27 -0
- package/scripts/install-vscode.mjs +236 -0
- package/scripts/release.mjs +19 -0
- package/scripts/smoke-new-tools.ts +79 -0
- package/scripts/smoke-tools.ts +201 -0
- package/src/vscode/LICENSE +674 -0
- package/src/vscode/README.md +54 -0
- package/src/vscode/media/assets/Anton.ttf +0 -0
- package/src/vscode/media/chat.js +634 -0
- package/src/vscode/media/style.css +767 -0
- package/src/vscode/out/extension.js +598 -0
- package/src/vscode/package.json +243 -0
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.js +0 -741
- package/dist/cli/tui.d.ts +0 -145
- package/dist/cli/tui.js +0 -1003
- package/dist/electron/main.d.ts +0 -1
- package/dist/electron/main.js +0 -364
- package/dist/electron/preload.d.ts +0 -1
- package/dist/electron/preload.js +0 -67
- package/dist/utils/clipboard.d.ts +0 -2
- package/dist/utils/clipboard.js +0 -40
- package/dist/utils/lock.d.ts +0 -12
- package/dist/utils/lock.js +0 -68
- package/dist/utils/sacGuard.d.ts +0 -4
- package/dist/utils/sacGuard.js +0 -47
- package/dist/utils/spinner.d.ts +0 -10
- package/dist/utils/spinner.js +0 -32
- package/src/gui/assets/image/logo.svg +0 -1
- package/src/gui/assets/image/opencode.svg +0 -18
- package/src/gui/css/style.css +0 -430
- package/src/gui/html/chat.html +0 -34
- package/src/gui/html/downloads.html +0 -11
- package/src/gui/html/hakkinda.html +0 -26
- package/src/gui/html/index.html +0 -82
- package/src/gui/html/projects.html +0 -12
- package/src/gui/html/settings.html +0 -4
- package/src/gui/js/app.js +0 -197
- package/src/gui/js/chat.js +0 -434
- package/src/gui/js/downloads.js +0 -172
- package/src/gui/js/hakkinda.js +0 -16
- package/src/gui/js/projects.js +0 -113
- package/src/gui/js/settings.js +0 -177
- /package/src/{gui/assets/image → vscode/media/assets}/AJAN_LOGO.svg +0 -0
- /package/src/{gui/assets/image → vscode/media/assets}/ajan.png +0 -0
|
@@ -0,0 +1,598 @@
|
|
|
1
|
+
// src/extension.ts
|
|
2
|
+
import * as vscode2 from "vscode";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
|
|
5
|
+
// src/ajanService.ts
|
|
6
|
+
import { AjanService } from "@takimcizgisi/ajan";
|
|
7
|
+
var AjanBackend = class {
|
|
8
|
+
service;
|
|
9
|
+
constructor(events, cwd) {
|
|
10
|
+
process.chdir(cwd);
|
|
11
|
+
this.service = new AjanService(events);
|
|
12
|
+
}
|
|
13
|
+
async sendMessage(message, modelId) {
|
|
14
|
+
return await this.service.sendMessage(message, modelId);
|
|
15
|
+
}
|
|
16
|
+
abort() {
|
|
17
|
+
this.service.abort();
|
|
18
|
+
}
|
|
19
|
+
async reset() {
|
|
20
|
+
await this.service.reset();
|
|
21
|
+
}
|
|
22
|
+
async newSession() {
|
|
23
|
+
await this.service.reset();
|
|
24
|
+
}
|
|
25
|
+
getConfig() {
|
|
26
|
+
return this.service.getConfig();
|
|
27
|
+
}
|
|
28
|
+
async setConfig(patch) {
|
|
29
|
+
await this.service.setConfig(patch);
|
|
30
|
+
}
|
|
31
|
+
listModels() {
|
|
32
|
+
return this.service.listModels();
|
|
33
|
+
}
|
|
34
|
+
getModelInfo() {
|
|
35
|
+
return this.service.getModelInfo();
|
|
36
|
+
}
|
|
37
|
+
async installModel(id) {
|
|
38
|
+
return await this.service.installModel(id);
|
|
39
|
+
}
|
|
40
|
+
async removeModel(id) {
|
|
41
|
+
return await this.service.removeModel(id);
|
|
42
|
+
}
|
|
43
|
+
async useModel(id) {
|
|
44
|
+
return await this.service.useModel(id);
|
|
45
|
+
}
|
|
46
|
+
async refreshModels() {
|
|
47
|
+
return await this.service.refreshModels();
|
|
48
|
+
}
|
|
49
|
+
getModelsRegistry() {
|
|
50
|
+
return this.service.getModelsRegistry();
|
|
51
|
+
}
|
|
52
|
+
async listProjects() {
|
|
53
|
+
return this.service.listProjects();
|
|
54
|
+
}
|
|
55
|
+
async addProject(path) {
|
|
56
|
+
return await this.service.addProject(path);
|
|
57
|
+
}
|
|
58
|
+
async removeProject(path) {
|
|
59
|
+
return await this.service.removeProject(path);
|
|
60
|
+
}
|
|
61
|
+
async setActiveProject(path) {
|
|
62
|
+
return await this.service.setActiveProject(path);
|
|
63
|
+
}
|
|
64
|
+
async listSessions() {
|
|
65
|
+
return await this.service.listSessions();
|
|
66
|
+
}
|
|
67
|
+
async loadSession(id) {
|
|
68
|
+
return await this.service.loadSession(id);
|
|
69
|
+
}
|
|
70
|
+
async saveSession(session) {
|
|
71
|
+
await this.service.saveSession(session);
|
|
72
|
+
}
|
|
73
|
+
generateSessionId() {
|
|
74
|
+
return this.service.generateSessionId();
|
|
75
|
+
}
|
|
76
|
+
getChatHistory() {
|
|
77
|
+
return this.service.getChatHistory();
|
|
78
|
+
}
|
|
79
|
+
getContextStats() {
|
|
80
|
+
return this.service.getContextStats();
|
|
81
|
+
}
|
|
82
|
+
async detectGpu() {
|
|
83
|
+
return await this.service.detectGpu();
|
|
84
|
+
}
|
|
85
|
+
get isActive() {
|
|
86
|
+
return this.service.isActive;
|
|
87
|
+
}
|
|
88
|
+
async dispose() {
|
|
89
|
+
await this.service.dispose();
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// src/panel.ts
|
|
94
|
+
import * as vscode from "vscode";
|
|
95
|
+
|
|
96
|
+
// src/backend.ts
|
|
97
|
+
var AjanBackendBridge = class {
|
|
98
|
+
backend;
|
|
99
|
+
poster;
|
|
100
|
+
loading = false;
|
|
101
|
+
constructor(backend2, poster) {
|
|
102
|
+
this.backend = backend2;
|
|
103
|
+
this.poster = poster;
|
|
104
|
+
}
|
|
105
|
+
send(message) {
|
|
106
|
+
void Promise.resolve(this.poster(message));
|
|
107
|
+
}
|
|
108
|
+
async handle(msg) {
|
|
109
|
+
switch (msg.type) {
|
|
110
|
+
case "send": {
|
|
111
|
+
const result = await this.backend.sendMessage(msg.text, msg.modelId);
|
|
112
|
+
this.send({ type: "found", ok: result.ok, error: result.error });
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
case "abort":
|
|
116
|
+
this.backend.abort();
|
|
117
|
+
this.send({ type: "busy", active: false });
|
|
118
|
+
break;
|
|
119
|
+
case "new-chat":
|
|
120
|
+
await this.backend.newSession();
|
|
121
|
+
this.send({ type: "new-chat-ok" });
|
|
122
|
+
break;
|
|
123
|
+
case "get-state":
|
|
124
|
+
await this.sendState();
|
|
125
|
+
break;
|
|
126
|
+
case "get-status":
|
|
127
|
+
this.send({
|
|
128
|
+
type: "status",
|
|
129
|
+
...this.statusPayload()
|
|
130
|
+
});
|
|
131
|
+
break;
|
|
132
|
+
case "set-config":
|
|
133
|
+
await this.backend.setConfig(msg.patch);
|
|
134
|
+
await this.sendState();
|
|
135
|
+
break;
|
|
136
|
+
case "model-install": {
|
|
137
|
+
this.loading = true;
|
|
138
|
+
this.send({ type: "busy", active: true, loading: true });
|
|
139
|
+
let result;
|
|
140
|
+
try {
|
|
141
|
+
result = await this.backend.installModel(msg.id);
|
|
142
|
+
} catch (err) {
|
|
143
|
+
result = { ok: false, error: String(err?.message ?? err) };
|
|
144
|
+
} finally {
|
|
145
|
+
this.loading = false;
|
|
146
|
+
this.send({ type: "busy", active: false, loading: false });
|
|
147
|
+
}
|
|
148
|
+
this.send({ type: "model-result", id: msg.id, action: "install", ok: result.ok, error: result.error });
|
|
149
|
+
await this.sendState();
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
case "model-remove": {
|
|
153
|
+
const result = await this.backend.removeModel(msg.id);
|
|
154
|
+
this.send({ type: "model-result", id: msg.id, action: "remove", ok: result.ok, error: result.error });
|
|
155
|
+
await this.sendState();
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
case "model-use": {
|
|
159
|
+
const result = await this.backend.useModel(msg.id);
|
|
160
|
+
this.send({ type: "model-result", id: msg.id, action: "use", ok: result.ok, error: result.error });
|
|
161
|
+
await this.sendState();
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
case "model-refresh": {
|
|
165
|
+
const result = await this.backend.refreshModels();
|
|
166
|
+
this.send({ type: "model-refresh-result", ok: result.ok, count: result.count, error: result.error });
|
|
167
|
+
await this.sendState();
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
case "session-list": {
|
|
171
|
+
const sessions = await this.backend.listSessions();
|
|
172
|
+
this.send({ type: "sessions", sessions: sessions.map((s) => ({ id: s.id, title: s.title, updatedAt: s.updatedAt })) });
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
case "session-load": {
|
|
176
|
+
const data = await this.backend.loadSession(msg.id);
|
|
177
|
+
this.send({ type: "session-loaded", ok: !!data, data });
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
case "session-save": {
|
|
181
|
+
try {
|
|
182
|
+
await this.backend.service.saveSession(msg.session);
|
|
183
|
+
this.send({ type: "session-saved", ok: true });
|
|
184
|
+
} catch {
|
|
185
|
+
this.send({ type: "session-saved", ok: false });
|
|
186
|
+
}
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
default:
|
|
190
|
+
this.send({ type: "error", message: `Bilinmeyen mesaj: ${msg.type}` });
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
async sendState() {
|
|
194
|
+
const config = this.backend.getConfig();
|
|
195
|
+
const models = this.backend.listModels();
|
|
196
|
+
const modelInfo = this.backend.getModelInfo();
|
|
197
|
+
const sessions = await this.backend.listSessions();
|
|
198
|
+
const projects = await this.backend.listProjects();
|
|
199
|
+
const gpu = await this.getGpu();
|
|
200
|
+
this.send({
|
|
201
|
+
type: "state",
|
|
202
|
+
payload: {
|
|
203
|
+
config,
|
|
204
|
+
models,
|
|
205
|
+
modelInfo,
|
|
206
|
+
sessions: sessions.map((s) => ({ id: s.id, title: s.title, updatedAt: s.updatedAt })),
|
|
207
|
+
projects,
|
|
208
|
+
gpu,
|
|
209
|
+
cwd: process.cwd(),
|
|
210
|
+
status: this.statusPayload()
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
gpuCache;
|
|
215
|
+
async getGpu() {
|
|
216
|
+
const now = Date.now();
|
|
217
|
+
if (this.gpuCache) {
|
|
218
|
+
if (now - this.gpuCache.at < 6e4) return this.gpuCache.value;
|
|
219
|
+
}
|
|
220
|
+
const value = await this.backend.detectGpu().catch(() => []);
|
|
221
|
+
this.gpuCache = { at: now, value };
|
|
222
|
+
return value;
|
|
223
|
+
}
|
|
224
|
+
statusPayload() {
|
|
225
|
+
return {
|
|
226
|
+
active: this.backend.isActive,
|
|
227
|
+
loading: this.loading,
|
|
228
|
+
context: this.backend.getContextStats(),
|
|
229
|
+
cwd: process.cwd()
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
async dispose() {
|
|
233
|
+
await this.backend.dispose();
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
// src/panel.ts
|
|
238
|
+
var MEDIA_DIR = "media";
|
|
239
|
+
var AjanViewProvider = class {
|
|
240
|
+
constructor(context, getBackend) {
|
|
241
|
+
this.context = context;
|
|
242
|
+
this.getBackend = getBackend;
|
|
243
|
+
}
|
|
244
|
+
static viewType = "ajanView";
|
|
245
|
+
view;
|
|
246
|
+
backend;
|
|
247
|
+
bridge;
|
|
248
|
+
disposables = [];
|
|
249
|
+
resolveWebviewView(webviewView) {
|
|
250
|
+
this.view = webviewView;
|
|
251
|
+
webviewView.webview.options = {
|
|
252
|
+
enableScripts: true,
|
|
253
|
+
localResourceRoots: [vscode.Uri.joinPath(this.context.extensionUri, MEDIA_DIR)]
|
|
254
|
+
};
|
|
255
|
+
webviewView.webview.html = this.getHtml(webviewView.webview);
|
|
256
|
+
webviewView.webview.onDidReceiveMessage(
|
|
257
|
+
(raw) => {
|
|
258
|
+
const backend2 = this.getBackend();
|
|
259
|
+
if (!backend2) return;
|
|
260
|
+
if (!this.bridge) this.bridge = new AjanBackendBridge(backend2, (m) => webviewView.webview.postMessage(m));
|
|
261
|
+
const msg = raw;
|
|
262
|
+
if (msg.type === "ready") {
|
|
263
|
+
void this.bridge.handle({ type: "get-state" }).catch(() => void 0);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
if (msg.type === "open-playground") {
|
|
267
|
+
void vscode.commands.executeCommand("ajan.openPlayground");
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
void this.bridge.handle(msg).catch((err) => {
|
|
271
|
+
void webviewView.webview.postMessage({ type: "error", message: String(err?.message ?? err) });
|
|
272
|
+
});
|
|
273
|
+
},
|
|
274
|
+
void 0,
|
|
275
|
+
this.disposables
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
getUri(webview, ...pathSegments) {
|
|
279
|
+
return webview.asWebviewUri(vscode.Uri.joinPath(this.context.extensionUri, ...pathSegments));
|
|
280
|
+
}
|
|
281
|
+
getHtml(webview) {
|
|
282
|
+
const cssUri = this.getUri(webview, MEDIA_DIR, "style.css");
|
|
283
|
+
const jsUri = this.getUri(webview, MEDIA_DIR, "chat.js");
|
|
284
|
+
const logoUri = this.getUri(webview, MEDIA_DIR, "assets", "ajan.png");
|
|
285
|
+
const brandUri = this.getUri(webview, MEDIA_DIR, "assets", "AJAN_LOGO.svg");
|
|
286
|
+
return `<!DOCTYPE html>
|
|
287
|
+
<html lang="tr">
|
|
288
|
+
<head>
|
|
289
|
+
<meta charset="UTF-8">
|
|
290
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
291
|
+
<meta http-equiv="Content-Security-Policy"
|
|
292
|
+
content="default-src 'none'; img-src ${webview.cspSource} data:; style-src ${webview.cspSource} 'unsafe-inline'; font-src ${webview.cspSource}; script-src ${webview.cspSource};">
|
|
293
|
+
<title>AJAN AI</title>
|
|
294
|
+
<link rel="stylesheet" href="${cssUri}">
|
|
295
|
+
</head>
|
|
296
|
+
<body>
|
|
297
|
+
<div id="app">
|
|
298
|
+
<header class="brand-header">
|
|
299
|
+
<button class="icon-btn" id="btn-toggle-ss" title="Ayarlar (Sohbet/Sistem)">
|
|
300
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>
|
|
301
|
+
</button>
|
|
302
|
+
<div class="brand-wrap">
|
|
303
|
+
<img src="${logoUri}" class="brand-mark" alt="AJAN">
|
|
304
|
+
</div>
|
|
305
|
+
<button class="icon-btn" id="btn-new-chat" title="Yeni Sohbet">
|
|
306
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
|
|
307
|
+
</button>
|
|
308
|
+
<button class="icon-btn" id="btn-playground" title="Test Alan\u0131n\u0131 A\xE7 (A\xE7\u0131k klas\xF6r i\xE7inde .ajan)">
|
|
309
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/><path d="M3.3 7l8.7 5 8.7-5"/><path d="M12 22V12"/><path d="M9.5 4.8 7 6"/></svg>
|
|
310
|
+
</button>
|
|
311
|
+
</header>
|
|
312
|
+
|
|
313
|
+
<div class="load-bar" id="load-bar" style="display:none">
|
|
314
|
+
<div class="load-fill" id="load-fill" style="width:0%"></div>
|
|
315
|
+
<span class="load-text" id="load-text"></span>
|
|
316
|
+
</div>
|
|
317
|
+
|
|
318
|
+
<main id="main">
|
|
319
|
+
<section id="chat-panel" class="panel chat-panel">
|
|
320
|
+
<div id="chat-logo-wrap" class="chat-logo-wrap">
|
|
321
|
+
<img src="${brandUri}" class="chat-logo" id="chat-logo" alt="AJAN">
|
|
322
|
+
</div>
|
|
323
|
+
<div id="chat-logs" class="chat-logs"></div>
|
|
324
|
+
<form id="chat-form" class="chat-form" autocomplete="off">
|
|
325
|
+
<div class="chat-input-wrap">
|
|
326
|
+
<input type="text" id="chat-input" class="chat-input"
|
|
327
|
+
placeholder="Yapay zekaya talimat verin\u2026" autofocus>
|
|
328
|
+
</div>
|
|
329
|
+
<div class="form-row">
|
|
330
|
+
<select id="model-select" class="model-select" title="Model">
|
|
331
|
+
<option value="">Model y\xFCkleniyor\u2026</option>
|
|
332
|
+
</select>
|
|
333
|
+
<span class="form-spacer"></span>
|
|
334
|
+
<button type="button" class="send-btn" id="chat-send-btn" title="G\xF6nder">
|
|
335
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="m22 2-7 20-4-9-9-4z"/><path d="M22 2 11 13"/></svg>
|
|
336
|
+
</button>
|
|
337
|
+
<button type="button" class="stop-btn" id="chat-stop-btn" title="Durdur" style="display:none">
|
|
338
|
+
<svg viewBox="0 0 24 24" fill="currentColor"><rect x="6" y="6" width="12" height="12" rx="2"/></svg>
|
|
339
|
+
</button>
|
|
340
|
+
</div>
|
|
341
|
+
</form>
|
|
342
|
+
<div class="ui-status-bar">
|
|
343
|
+
<div class="sb-left">
|
|
344
|
+
<span class="sb-item">
|
|
345
|
+
<span class="sb-dot status-dot idle" id="ui-status-dot"></span>
|
|
346
|
+
Yerel
|
|
347
|
+
</span>
|
|
348
|
+
<span class="sb-item" id="ui-status-text">AJAN ba\u015Flat\u0131l\u0131yor\u2026</span>
|
|
349
|
+
</div>
|
|
350
|
+
<div class="sb-right">
|
|
351
|
+
<span class="sb-item">AJAN AI</span>
|
|
352
|
+
</div>
|
|
353
|
+
</div>
|
|
354
|
+
</section>
|
|
355
|
+
|
|
356
|
+
<section id="settings-panel" class="panel settings-panel" style="display:none">
|
|
357
|
+
<h2 class="settings-title">Ayarlar</h2>
|
|
358
|
+
|
|
359
|
+
<div class="settings-group">
|
|
360
|
+
<div class="group-title">Durum</div>
|
|
361
|
+
<div class="kv-row"><span>\xC7al\u0131\u015Fma dizini</span><span id="kv-cwd" class="kv-mono">-</span></div>
|
|
362
|
+
<div class="kv-row"><span>Mevcut model</span><span id="kv-model" class="kv-accent">-</span></div>
|
|
363
|
+
<div class="kv-row"><span>Ba\u011Flam kullan\u0131m\u0131</span><span id="kv-context" class="kv-mono">-</span></div>
|
|
364
|
+
<div class="kv-row"><span>GPU</span><span id="kv-gpu" class="kv-mono">-</span></div>
|
|
365
|
+
<div class="kv-row"><span>S\xFCr\xFCm</span><span id="kv-version" class="kv-mono">-</span></div>
|
|
366
|
+
</div>
|
|
367
|
+
|
|
368
|
+
<div class="settings-group">
|
|
369
|
+
<div class="group-title">Modeller</div>
|
|
370
|
+
<div id="models-list" class="models-list">
|
|
371
|
+
<div class="empty-hint">Model listesi y\xFCkleniyor\u2026</div>
|
|
372
|
+
</div>
|
|
373
|
+
<div class="settings-row">
|
|
374
|
+
<button class="btn btn-outline" id="btn-refresh-models">Listeyi Yenile</button>
|
|
375
|
+
</div>
|
|
376
|
+
</div>
|
|
377
|
+
|
|
378
|
+
<div class="settings-group">
|
|
379
|
+
<div class="group-title">Oturum Parametreleri</div>
|
|
380
|
+
<label class="settings-item">
|
|
381
|
+
<span>Temperature</span>
|
|
382
|
+
<input type="number" id="cfg-temperature" class="number-input" min="0" max="2" step="0.1">
|
|
383
|
+
</label>
|
|
384
|
+
<label class="settings-item">
|
|
385
|
+
<span>Maks. ad\u0131m</span>
|
|
386
|
+
<input type="number" id="cfg-maxsteps" class="number-input" min="1" max="100" step="1">
|
|
387
|
+
</label>
|
|
388
|
+
</div>
|
|
389
|
+
|
|
390
|
+
<div class="settings-group">
|
|
391
|
+
<div class="group-title">Oturumlar</div>
|
|
392
|
+
<div id="sessions-list" class="sessions-list">
|
|
393
|
+
<div class="empty-hint">Oturum listesi y\xFCkleniyor\u2026</div>
|
|
394
|
+
</div>
|
|
395
|
+
</div>
|
|
396
|
+
</section>
|
|
397
|
+
</main>
|
|
398
|
+
|
|
399
|
+
<div class="toast" id="toast"></div>
|
|
400
|
+
</div>
|
|
401
|
+
<script src="${jsUri}"></script>
|
|
402
|
+
</body>
|
|
403
|
+
</html>`;
|
|
404
|
+
}
|
|
405
|
+
/** Uzantı dış komutlarından (ajan.newChat, ajan.stop vs.) webview'e bildir */
|
|
406
|
+
postCommand(command) {
|
|
407
|
+
void this.view?.webview.postMessage({ type: "command", command });
|
|
408
|
+
}
|
|
409
|
+
/** AJAN servis olaylarını doğrudan webview'e aktar */
|
|
410
|
+
post(payload) {
|
|
411
|
+
void this.view?.webview.postMessage(payload);
|
|
412
|
+
}
|
|
413
|
+
dispose() {
|
|
414
|
+
for (const d of this.disposables) d.dispose();
|
|
415
|
+
this.disposables.length = 0;
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
// src/extension.ts
|
|
420
|
+
var backend;
|
|
421
|
+
var provider;
|
|
422
|
+
var statusBar;
|
|
423
|
+
function getActiveFolder() {
|
|
424
|
+
const folder = vscode2.workspace.workspaceFolders?.[0];
|
|
425
|
+
const wsDir = vscode2.workspace.getConfiguration("ajan").get("workspaceDir");
|
|
426
|
+
if (folder) return folder.uri.fsPath;
|
|
427
|
+
if (wsDir) return wsDir;
|
|
428
|
+
return process.env.USERPROFILE ?? process.env.HOME ?? process.cwd();
|
|
429
|
+
}
|
|
430
|
+
function getWorkspaceConfig() {
|
|
431
|
+
return vscode2.workspace.getConfiguration("ajan");
|
|
432
|
+
}
|
|
433
|
+
function explicitConfigValue(cfg, key) {
|
|
434
|
+
const info = cfg.inspect(key);
|
|
435
|
+
const val = info?.workspaceFolderValue ?? info?.workspaceValue ?? info?.globalValue;
|
|
436
|
+
return val;
|
|
437
|
+
}
|
|
438
|
+
function buildConfigPatch() {
|
|
439
|
+
const cfg = getWorkspaceConfig();
|
|
440
|
+
const patch = {};
|
|
441
|
+
const modelId = explicitConfigValue(cfg, "modelId");
|
|
442
|
+
if (modelId) patch.modelId = modelId;
|
|
443
|
+
const gpu = explicitConfigValue(cfg, "gpu");
|
|
444
|
+
if (gpu) patch.gpu = gpu;
|
|
445
|
+
const gpuLayersRaw = explicitConfigValue(cfg, "gpuLayers");
|
|
446
|
+
if (gpuLayersRaw) {
|
|
447
|
+
patch.gpuLayers = gpuLayersRaw === "max" || gpuLayersRaw === "auto" ? gpuLayersRaw : Number(gpuLayersRaw);
|
|
448
|
+
}
|
|
449
|
+
const contextRaw = explicitConfigValue(cfg, "contextSize");
|
|
450
|
+
if (contextRaw) {
|
|
451
|
+
patch.contextSize = contextRaw === "auto" ? "auto" : Number(contextRaw);
|
|
452
|
+
}
|
|
453
|
+
const session = {};
|
|
454
|
+
const temperature = explicitConfigValue(cfg, "temperature");
|
|
455
|
+
if (typeof temperature === "number") session.temperature = temperature;
|
|
456
|
+
const sMax = explicitConfigValue(cfg, "maxTokens");
|
|
457
|
+
if (typeof sMax === "number") session.maxTokens = sMax;
|
|
458
|
+
if (Object.keys(session).length > 0) patch.session = session;
|
|
459
|
+
const maxSteps = explicitConfigValue(cfg, "maxSteps");
|
|
460
|
+
if (typeof maxSteps === "number") patch.maxSteps = maxSteps;
|
|
461
|
+
const toolTimeout = explicitConfigValue(cfg, "toolTimeout");
|
|
462
|
+
if (typeof toolTimeout === "number") patch.toolTimeout = toolTimeout;
|
|
463
|
+
const maxToolOutput = explicitConfigValue(cfg, "maxToolOutput");
|
|
464
|
+
if (typeof maxToolOutput === "number") patch.maxToolOutput = maxToolOutput;
|
|
465
|
+
const beep = explicitConfigValue(cfg, "beepOnComplete");
|
|
466
|
+
if (typeof beep === "boolean") patch.beepOnComplete = beep;
|
|
467
|
+
return patch;
|
|
468
|
+
}
|
|
469
|
+
function ensureBackend() {
|
|
470
|
+
if (backend) return backend;
|
|
471
|
+
backend = new AjanBackend(
|
|
472
|
+
{
|
|
473
|
+
onTextChunk: (text) => void provider?.post({ type: "agent:text-chunk", text }),
|
|
474
|
+
onThinkingChunk: (text) => void provider?.post({ type: "agent:thinking-chunk", text }),
|
|
475
|
+
onToolCall: (name, params) => void provider?.post({ type: "agent:tool-call", name, params }),
|
|
476
|
+
onToolResult: (name, ok, output) => void provider?.post({ type: "agent:tool-result", name, ok, output }),
|
|
477
|
+
onStepStart: (step, max) => void provider?.post({ type: "agent:step-start", step, max }),
|
|
478
|
+
onStepEnd: () => void 0,
|
|
479
|
+
onContextTrimmed: (removed) => void provider?.post({ type: "agent:context-trimmed", removed }),
|
|
480
|
+
onError: (error) => void provider?.post({ type: "agent:error", message: error.message }),
|
|
481
|
+
onComplete: (response) => void provider?.post({ type: "agent:complete", response }),
|
|
482
|
+
onModelLoadProgress: (pct) => void provider?.post({ type: "agent:load-progress", pct }),
|
|
483
|
+
onModelLoadComplete: () => void provider?.post({ type: "agent:load-complete" })
|
|
484
|
+
},
|
|
485
|
+
getActiveFolder()
|
|
486
|
+
);
|
|
487
|
+
const patch = buildConfigPatch();
|
|
488
|
+
if (Object.keys(patch).length > 0) {
|
|
489
|
+
void backend.service.setConfig(patch).catch(() => void 0);
|
|
490
|
+
}
|
|
491
|
+
return backend;
|
|
492
|
+
}
|
|
493
|
+
function updateStatusBar() {
|
|
494
|
+
if (!statusBar) return;
|
|
495
|
+
const running = backend?.isActive ?? false;
|
|
496
|
+
statusBar.text = running ? "$(loading~spin) AJAN" : "$(comment-discussion) AJAN";
|
|
497
|
+
statusBar.tooltip = running ? "AJAN \xE7al\u0131\u015F\u0131yor \u2014 durdurmak i\xE7in AJAN: \xDCretimi Durdur" : "AJAN";
|
|
498
|
+
statusBar.backgroundColor = running ? new vscode2.ThemeColor("statusBarItem.warningBackground") : void 0;
|
|
499
|
+
statusBar.show();
|
|
500
|
+
}
|
|
501
|
+
async function openPlayground() {
|
|
502
|
+
const root = getActiveFolder();
|
|
503
|
+
const playground = join(root, ".ajan");
|
|
504
|
+
const uri = vscode2.Uri.file(playground);
|
|
505
|
+
try {
|
|
506
|
+
await vscode2.workspace.fs.stat(uri);
|
|
507
|
+
} catch {
|
|
508
|
+
await vscode2.workspace.fs.createDirectory(uri);
|
|
509
|
+
}
|
|
510
|
+
const entries = await vscode2.workspace.fs.readDirectory(uri);
|
|
511
|
+
if (entries.length > 0) {
|
|
512
|
+
const answer = await vscode2.window.showWarningMessage(
|
|
513
|
+
`".ajan" test klas\xF6r\xFC bo\u015F de\u011Fil (${entries.length} \xF6\u011Fe). Bombo\u015F bir kum havuzu a\xE7mak i\xE7in s\u0131f\u0131rlamak ister misin?`,
|
|
514
|
+
{ modal: true },
|
|
515
|
+
"S\u0131f\u0131rla ve Bo\u015F A\xE7",
|
|
516
|
+
"Oldu\u011Fu Gibi A\xE7"
|
|
517
|
+
);
|
|
518
|
+
if (answer === "S\u0131f\u0131rla ve Bo\u015F A\xE7") {
|
|
519
|
+
let removed = 0;
|
|
520
|
+
for (const [name] of entries) {
|
|
521
|
+
try {
|
|
522
|
+
await vscode2.workspace.fs.delete(vscode2.Uri.joinPath(uri, name), { recursive: true, useTrash: false });
|
|
523
|
+
removed++;
|
|
524
|
+
} catch {
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
void vscode2.window.showInformationMessage(`".ajan" test klas\xF6r\xFC s\u0131f\u0131rland\u0131 (${removed} \xF6\u011Fe silindi).`);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
void vscode2.commands.executeCommand("revealInExplorer", uri);
|
|
531
|
+
const terminal = vscode2.window.createTerminal({ name: "AJAN Test Alan\u0131 (.ajan)", cwd: playground });
|
|
532
|
+
terminal.show();
|
|
533
|
+
provider?.post({ type: "playground-opened", path: playground });
|
|
534
|
+
}
|
|
535
|
+
async function activate(context) {
|
|
536
|
+
statusBar = vscode2.window.createStatusBarItem(vscode2.StatusBarAlignment.Left, 10);
|
|
537
|
+
statusBar.command = "ajan.chat";
|
|
538
|
+
context.subscriptions.push(statusBar);
|
|
539
|
+
updateStatusBar();
|
|
540
|
+
provider = new AjanViewProvider(context, () => ensureBackend());
|
|
541
|
+
context.subscriptions.push(
|
|
542
|
+
vscode2.window.registerWebviewViewProvider(AjanViewProvider.viewType, provider)
|
|
543
|
+
);
|
|
544
|
+
context.subscriptions.push(
|
|
545
|
+
vscode2.commands.registerCommand("ajan.chat", () => {
|
|
546
|
+
void vscode2.commands.executeCommand("ajanView.focus");
|
|
547
|
+
updateStatusBar();
|
|
548
|
+
}),
|
|
549
|
+
vscode2.commands.registerCommand("ajan.newChat", () => {
|
|
550
|
+
void ensureBackend()?.newSession();
|
|
551
|
+
provider?.postCommand("new-chat");
|
|
552
|
+
}),
|
|
553
|
+
vscode2.commands.registerCommand("ajan.stop", () => {
|
|
554
|
+
ensureBackend()?.abort();
|
|
555
|
+
provider?.postCommand("stop");
|
|
556
|
+
updateStatusBar();
|
|
557
|
+
}),
|
|
558
|
+
vscode2.commands.registerCommand("ajan.refreshModels", async () => {
|
|
559
|
+
const b = ensureBackend();
|
|
560
|
+
if (!b) return;
|
|
561
|
+
const result = await b.refreshModels();
|
|
562
|
+
void vscode2.window.showInformationMessage(result.ok ? `Model listesi g\xFCncellendi (${result.count ?? 0} model)` : `Hata: ${result.error ?? "Bilinmeyen"}`);
|
|
563
|
+
provider?.postCommand("refresh-models");
|
|
564
|
+
updateStatusBar();
|
|
565
|
+
}),
|
|
566
|
+
vscode2.commands.registerCommand("ajan.openSettings", () => {
|
|
567
|
+
void vscode2.commands.executeCommand("workbench.action.openSettings", "@ext:takimcizgisi.ajan-ai");
|
|
568
|
+
updateStatusBar();
|
|
569
|
+
}),
|
|
570
|
+
vscode2.commands.registerCommand("ajan.openPlayground", () => {
|
|
571
|
+
void openPlayground();
|
|
572
|
+
})
|
|
573
|
+
);
|
|
574
|
+
context.subscriptions.push(
|
|
575
|
+
vscode2.workspace.onDidChangeConfiguration((e) => {
|
|
576
|
+
if (!e.affectsConfiguration("ajan")) return;
|
|
577
|
+
if (!backend) return;
|
|
578
|
+
const patch = buildConfigPatch();
|
|
579
|
+
if (Object.keys(patch).length > 0) {
|
|
580
|
+
void backend.service.setConfig(patch).catch(() => void 0);
|
|
581
|
+
}
|
|
582
|
+
provider?.postCommand("config-changed");
|
|
583
|
+
})
|
|
584
|
+
);
|
|
585
|
+
const statusTimer = setInterval(updateStatusBar, 2e3);
|
|
586
|
+
context.subscriptions.push(new vscode2.Disposable(() => clearInterval(statusTimer)));
|
|
587
|
+
void vscode2.commands.executeCommand("ajanView.focus");
|
|
588
|
+
}
|
|
589
|
+
async function deactivate() {
|
|
590
|
+
await backend?.dispose();
|
|
591
|
+
backend = void 0;
|
|
592
|
+
provider?.dispose();
|
|
593
|
+
provider = void 0;
|
|
594
|
+
}
|
|
595
|
+
export {
|
|
596
|
+
activate,
|
|
597
|
+
deactivate
|
|
598
|
+
};
|