@omerrgocmen/crewctl 1.0.2 → 1.0.3
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/orchestrator/README.md +462 -462
- package/orchestrator/config.default.json +71 -71
- package/orchestrator/roles/operator.md +77 -77
- package/orchestrator/roles/reviewer.md +63 -63
- package/orchestrator/skills/acceptance-criteria.md +18 -18
- package/orchestrator/skills/accessibility-audit.md +16 -16
- package/orchestrator/skills/accessible-forms.md +16 -16
- package/orchestrator/skills/api-design.md +27 -27
- package/orchestrator/skills/api-documentation.md +16 -16
- package/orchestrator/skills/architecture-decision-record.md +18 -18
- package/orchestrator/skills/authentication-design.md +16 -16
- package/orchestrator/skills/authorization-review.md +16 -16
- package/orchestrator/skills/backward-compatibility.md +17 -17
- package/orchestrator/skills/changelog-writing.md +16 -16
- package/orchestrator/skills/ci-pipeline-design.md +16 -16
- package/orchestrator/skills/cli-design.md +16 -16
- package/orchestrator/skills/code-review.md +27 -27
- package/orchestrator/skills/configuration-management.md +16 -16
- package/orchestrator/skills/container-review.md +16 -16
- package/orchestrator/skills/contract-testing.md +16 -16
- package/orchestrator/skills/dashboard-design.md +16 -16
- package/orchestrator/skills/database-migration.md +16 -16
- package/orchestrator/skills/database-schema-design.md +16 -16
- package/orchestrator/skills/debugging.md +26 -26
- package/orchestrator/skills/dependency-review.md +16 -16
- package/orchestrator/skills/design-review.md +29 -29
- package/orchestrator/skills/design-system.md +16 -16
- package/orchestrator/skills/docs-api-reference.md +16 -16
- package/orchestrator/skills/docs-troubleshooting.md +16 -16
- package/orchestrator/skills/docs-tutorial.md +16 -16
- package/orchestrator/skills/docs-writing.md +25 -25
- package/orchestrator/skills/empty-error-loading-states.md +16 -16
- package/orchestrator/skills/end-to-end-testing.md +16 -16
- package/orchestrator/skills/error-handling.md +16 -16
- package/orchestrator/skills/frontend-design.md +28 -28
- package/orchestrator/skills/git-commit-writing.md +16 -16
- package/orchestrator/skills/graphql-design.md +16 -16
- package/orchestrator/skills/incident-runbook.md +18 -18
- package/orchestrator/skills/input-validation.md +16 -16
- package/orchestrator/skills/integration-testing.md +16 -16
- package/orchestrator/skills/interaction-design.md +16 -16
- package/orchestrator/skills/landing-page-design.md +16 -16
- package/orchestrator/skills/observability-design.md +16 -16
- package/orchestrator/skills/openapi-contract.md +16 -16
- package/orchestrator/skills/performance-profiling.md +16 -16
- package/orchestrator/skills/privacy-review.md +16 -16
- package/orchestrator/skills/property-based-testing.md +16 -16
- package/orchestrator/skills/pull-request-writing.md +16 -16
- package/orchestrator/skills/refactoring.md +16 -16
- package/orchestrator/skills/release-readiness.md +16 -16
- package/orchestrator/skills/responsive-design.md +16 -16
- package/orchestrator/skills/secrets-management.md +16 -16
- package/orchestrator/skills/secure-file-upload.md +16 -16
- package/orchestrator/skills/security-review.md +26 -26
- package/orchestrator/skills/semantic-versioning.md +17 -17
- package/orchestrator/skills/seo-on-page.md +16 -16
- package/orchestrator/skills/seo-structured-data.md +16 -16
- package/orchestrator/skills/seo-technical-audit.md +16 -16
- package/orchestrator/skills/sql-query-review.md +16 -16
- package/orchestrator/skills/supply-chain-security.md +16 -16
- package/orchestrator/skills/test-strategy.md +16 -16
- package/orchestrator/skills/threat-modeling.md +16 -16
- package/orchestrator/skills/unit-testing.md +16 -16
- package/orchestrator/skills/write-tests.md +28 -28
- package/orchestrator/src/cli-registry.js +616 -616
- package/orchestrator/src/cli.js +131 -131
- package/orchestrator/src/doctor.js +64 -64
- package/orchestrator/src/engine.js +162 -31
- package/orchestrator/src/server.js +766 -766
- package/orchestrator/src/skill-registry.js +272 -272
- package/orchestrator/src/store.js +399 -399
- package/orchestrator/web/OrbitControls.js +1417 -1417
- package/orchestrator/web/flow.html +740 -740
- package/orchestrator/web/index.html +587 -557
- package/orchestrator/web/jsm/postprocessing/EffectComposer.js +231 -231
- package/orchestrator/web/jsm/postprocessing/MaskPass.js +104 -104
- package/orchestrator/web/jsm/postprocessing/Pass.js +95 -95
- package/orchestrator/web/jsm/postprocessing/RenderPass.js +99 -99
- package/orchestrator/web/jsm/postprocessing/ShaderPass.js +77 -77
- package/orchestrator/web/jsm/postprocessing/UnrealBloomPass.js +415 -415
- package/orchestrator/web/jsm/shaders/CopyShader.js +45 -45
- package/orchestrator/web/jsm/shaders/LuminosityHighPassShader.js +66 -66
- package/orchestrator/web/three.module.min.js +6 -6
- package/package.json +1 -1
|
@@ -240,37 +240,71 @@ function extractVerdict(text) {
|
|
|
240
240
|
return /PASS/i.test(matches[matches.length - 1]) ? "PASS" : "FAIL";
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
+
// Siniflandirilamayan hatada "gemini cikis kodu 1." gibi bilgisiz bir ilk satir yerine metnin
|
|
244
|
+
// icindeki GERCEK hata cumlesini bulur; kullaniciya gosterilen tek satir buysa anlamli olmali.
|
|
245
|
+
function meaningfulErrorLine(raw) {
|
|
246
|
+
const all = String(raw).split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
247
|
+
// Yigin izleri ve motorun kendi sardigi "<cli> cikis kodu N." satiri teshis tasimaz;
|
|
248
|
+
// gercek neden hemen arkalarindaki satirdadir.
|
|
249
|
+
const useful = all.filter((line) => !/^at\s|^node:internal|^[{}[\]]+$/.test(line) && !/cikis kodu/i.test(line));
|
|
250
|
+
const signal = useful.find((line) => /error|hata|failed|failure|denied|invalid|exceeded|limit|quota|unable|cannot|must/i.test(line) && line.length > 20);
|
|
251
|
+
return signal || useful[0] || all[0] || String(raw).trim();
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Ham CLI ciktisini kullaniciya "ne oldu + ne yapmali" seklinde anlamli bir teshise cevirir.
|
|
255
|
+
// SIRA ONEMLIDIR: spesifik desenler once gelmeli. Ornegin Gemini'nin "GEMINI_API_KEY ...
|
|
256
|
+
// not found" mesaji bir PATH/kurulum sorunu DEGILDIR; genis /not found/ deseni bu yuzden
|
|
257
|
+
// daraltildi ve kimlik kontrollerinin arkasina alindi.
|
|
243
258
|
function classifyCliError(error) {
|
|
244
259
|
const raw = String(error?.message || error || "Bilinmeyen CLI hatasi");
|
|
260
|
+
const of = (code, summary, action) => ({ code, summary, action, raw: clip(raw, 5000) });
|
|
245
261
|
if (/requires a newer version|upgrade to the latest|model metadata.*not found|unsupported.*model|model.*unsupported/i.test(raw)) {
|
|
246
|
-
return
|
|
262
|
+
return of("VERSION_INCOMPATIBLE", "CLI sürümü seçilen modeli desteklemiyor.", "CLI aracını güncelleyin veya desteklenen bir model seçin.");
|
|
247
263
|
}
|
|
248
264
|
if (/sessiz kaldi|cikti uretmedi|CLI_STALLED/i.test(raw)) {
|
|
249
|
-
return
|
|
265
|
+
return of("CLI_STALLED", "CLI uzun süre yeni çıktı üretmeyince otomatik durduruldu.", "Önceki ilerleme kayıtları korundu; operatör bu oturumda farklı bir agent kullanacak.");
|
|
266
|
+
}
|
|
267
|
+
if (/API key not valid|API_KEY_INVALID|invalid[_ ]api[_ ]key|incorrect api key/i.test(raw)) {
|
|
268
|
+
return of("AUTH_INVALID", "API anahtarı geçersiz veya reddedildi.", "Agent ayarlarındaki API anahtarını yenileyin (Gemini için GEMINI_API_KEY / GOOGLE_API_KEY).");
|
|
250
269
|
}
|
|
251
|
-
|
|
252
|
-
|
|
270
|
+
// Gemini CLI oturum acilmadiginda "Please set an Auth method" / "GEMINI_API_KEY environment
|
|
271
|
+
// variable not found" yazar; her ikisi de kurulum degil OTURUM sorunudur.
|
|
272
|
+
if (/set an auth method|GEMINI_API_KEY|GOOGLE_API_KEY|unauthorized|unauthenticated|authentication|login required|not logged in|please (run )?login|credentials? (not found|missing|expired)|PERMISSION_DENIED|\b40[13]\b/i.test(raw)) {
|
|
273
|
+
return of("AUTH_REQUIRED", "CLI oturum açmamış; kimlik doğrulaması gerekiyor.", "Terminalde ilgili CLI ile oturum açın (Gemini: `gemini` çalıştırıp 'Login with Google' veya GEMINI_API_KEY tanımlayın), sonra görevi tekrar deneyin.");
|
|
253
274
|
}
|
|
254
|
-
|
|
255
|
-
|
|
275
|
+
// Kota (gunluk/aylik hak bitti) ile hiz siniri (kisa sureli) AYRI teshislerdir: ilki
|
|
276
|
+
// beklemekle gecmez, ikincisi gecer. Kullanicinin sordugu "limitim mi bitti" ayrimi budur.
|
|
277
|
+
if (/RESOURCE_EXHAUSTED|quota exceeded|exceeded your current quota|daily limit|günlük limit|gunluk limit|out of credits|insufficient (credit|balance|quota)|billing/i.test(raw)) {
|
|
278
|
+
return of("QUOTA_EXCEEDED", "Sağlayıcı kotanız doldu (günlük/aylık hak veya bakiye bitti).", "Kota yenilenene kadar bu agent kullanılamaz; başka bir agent seçin, faturalandırmayı yükseltin veya API anahtarını kotası olan bir hesapla değiştirin.");
|
|
256
279
|
}
|
|
257
|
-
if (/rate.?limit|too many requests
|
|
258
|
-
return
|
|
280
|
+
if (/rate.?limit|too many requests|\b429\b/i.test(raw)) {
|
|
281
|
+
return of("RATE_LIMIT", "İstek hızı sınırına takıldı (kota bitmedi, çok sık istek gönderildi).", "Kısa bir süre bekleyip tekrar deneyin; operatör bu turda alternatif bir agent kullanabilir.");
|
|
282
|
+
}
|
|
283
|
+
if (/overloaded|\bUNAVAILABLE\b|\b(503|500)\b|internal error|try again later/i.test(raw)) {
|
|
284
|
+
return of("MODEL_OVERLOADED", "Model sağlayıcısı geçici olarak aşırı yüklü ya da hata döndürdü.", "Sağlayıcı kaynaklı geçici bir sorun; birkaç dakika sonra tekrar deneyin.");
|
|
285
|
+
}
|
|
286
|
+
if (/location is not supported|not available in your country|region.*not supported/i.test(raw)) {
|
|
287
|
+
return of("REGION_BLOCKED", "Model bulunduğunuz bölgede kullanıma kapalı.", "Desteklenen bir bölge/hesap kullanın veya başka bir sağlayıcının agent'ını seçin.");
|
|
259
288
|
}
|
|
260
289
|
if (/ConnectionRefused|Unable to connect|provider hatasi|provider error|ECONNREFUSED/i.test(raw)) {
|
|
261
|
-
return
|
|
290
|
+
return of("PROVIDER_UNAVAILABLE", "Seçilen model sağlayıcısına bağlanılamadı.", "Sağlayıcı bağlantısını kontrol edin veya başka bir model seçin.");
|
|
291
|
+
}
|
|
292
|
+
if (/ENOTFOUND|EAI_AGAIN|ECONNRESET|ETIMEDOUT|getaddrinfo|fetch failed|socket hang up|network (error|unreachable)|proxy/i.test(raw)) {
|
|
293
|
+
return of("NETWORK_ERROR", "Ağ bağlantısı kurulamadı (DNS/proxy/internet).", "İnternet veya kurumsal proxy ayarlarınızı kontrol edip görevi tekrar çalıştırın.");
|
|
262
294
|
}
|
|
263
|
-
if (/not recognized as an internal|
|
|
264
|
-
return
|
|
295
|
+
if (/not recognized as an internal|is not recognized|command not found|spawn .*ENOENT|\bENOENT\b|no such file or directory/i.test(raw)) {
|
|
296
|
+
return of("CLI_NOT_FOUND", "CLI komutu bulunamadı; kurulu değil veya PATH üzerinde görünmüyor.", "CLI'yi kurun (Gemini: `npm install -g @google/gemini-cli`) ve Ayarlar → Agent'lar bölümünde komut adını doğrulayın.");
|
|
265
297
|
}
|
|
266
298
|
if (/timeout|timed out|zaman asim|zaman aşım/i.test(raw)) {
|
|
267
|
-
return
|
|
299
|
+
return of("TIMEOUT", "CLI ayrılan süre içinde tamamlanamadı.", "Agent ayarlarından timeout değerini artırın veya görevi daha küçük parçalara bölün.");
|
|
268
300
|
}
|
|
269
|
-
return
|
|
301
|
+
return of("CLI_FAILED", clip(meaningfulErrorLine(raw), 500), "Ham CLI çıktısı teknik ayrıntılarda saklandı; sorun sürerse alternatif bir agent deneyin.");
|
|
270
302
|
}
|
|
271
303
|
|
|
272
|
-
const RECOVERABLE_CLI_ERRORS = new Set(["AUTH_INVALID", "AUTH_REQUIRED", "RATE_LIMIT", "PROVIDER_UNAVAILABLE", "CLI_NOT_FOUND", "TIMEOUT", "CLI_STALLED", "CLI_FAILED", "VERSION_INCOMPATIBLE"]);
|
|
273
|
-
|
|
304
|
+
const RECOVERABLE_CLI_ERRORS = new Set(["AUTH_INVALID", "AUTH_REQUIRED", "RATE_LIMIT", "QUOTA_EXCEEDED", "MODEL_OVERLOADED", "NETWORK_ERROR", "REGION_BLOCKED", "PROVIDER_UNAVAILABLE", "CLI_NOT_FOUND", "TIMEOUT", "CLI_STALLED", "CLI_FAILED", "VERSION_INCOMPATIBLE"]);
|
|
305
|
+
// Karantina = bu oturumda tekrar denemek anlamsiz. Kota/bolge kisiti beklemekle gecmez;
|
|
306
|
+
// hiz siniri (RATE_LIMIT) ve gecici saglayici hatasi (MODEL_OVERLOADED) gecer, karantinaya alinmaz.
|
|
307
|
+
const QUARANTINE_CLI_ERRORS = new Set(["AUTH_INVALID", "AUTH_REQUIRED", "QUOTA_EXCEEDED", "REGION_BLOCKED", "PROVIDER_UNAVAILABLE", "CLI_NOT_FOUND", "CLI_STALLED", "VERSION_INCOMPATIBLE"]);
|
|
274
308
|
|
|
275
309
|
function resolveExecutionMode(task) {
|
|
276
310
|
if (["fast", "balanced", "deep"].includes(task.executionMode)) return task.executionMode;
|
|
@@ -316,18 +350,81 @@ function normalizeCliOutput(agent, stdout) {
|
|
|
316
350
|
return { text: texts.join("\n").trim(), error: errors.join("\n").trim() };
|
|
317
351
|
}
|
|
318
352
|
|
|
353
|
+
// Metindeki DENGELI suslu parantezli en dis JSON nesnesi adaylarini cikarir. String icindeki
|
|
354
|
+
// parantez/kacis karakterleri sayilmaz; boylece "final" metninde gecen bir { veya } eski
|
|
355
|
+
// "ilk-{ .. son-}" kestirmesini bozmaz. Ayrica model aciklama + nesne + ek aciklama yazdiginda
|
|
356
|
+
// (ya da birden fazla nesne dondurdugunde) her nesne ayri aday olur.
|
|
357
|
+
function jsonObjectCandidates(text) {
|
|
358
|
+
const src = String(text);
|
|
359
|
+
const found = [];
|
|
360
|
+
const stack = [];
|
|
361
|
+
let inString = false, escaped = false;
|
|
362
|
+
for (let i = 0; i < src.length; i++) {
|
|
363
|
+
const ch = src[i];
|
|
364
|
+
if (inString) {
|
|
365
|
+
if (escaped) escaped = false;
|
|
366
|
+
else if (ch === "\\") escaped = true;
|
|
367
|
+
else if (ch === '"') inString = false;
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
if (ch === '"') inString = true;
|
|
371
|
+
else if (ch === "{") stack.push(i);
|
|
372
|
+
else if (ch === "}" && stack.length) {
|
|
373
|
+
const start = stack.pop();
|
|
374
|
+
if (!stack.length) found.push(src.slice(start, i + 1));
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
return found;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// Model bazen JSON'u tek tirnak, sondaki virgul veya akilli tirnakla yazar. Kati parse
|
|
381
|
+
// basarisiz oldugunda son care olarak bu yaygin sapmalari onarip bir kez daha dener.
|
|
382
|
+
function repairJsonText(candidate) {
|
|
383
|
+
return String(candidate)
|
|
384
|
+
.replace(/[“”]/g, '"')
|
|
385
|
+
.replace(/[‘’]/g, "'")
|
|
386
|
+
.replace(/,\s*([}\]])/g, "$1");
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
const PROTOCOL_KEYS = /"(status|assignments|summary|completionCriteria|final)"\s*:/;
|
|
390
|
+
|
|
319
391
|
function parseJson(text, label) {
|
|
392
|
+
const raw = String(text);
|
|
320
393
|
const candidates = [];
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
const
|
|
326
|
-
|
|
394
|
+
for (const fence of raw.matchAll(/```(?:json)?\s*([\s\S]*?)```/gi)) candidates.push(fence[1]);
|
|
395
|
+
candidates.push(raw.trim());
|
|
396
|
+
// Protokol anahtari iceren nesneler once denenir; ayni onem sirasinda SONDAKI nesne kazanir
|
|
397
|
+
// (modeller once dusunce/aciklama, en sona nihai protokol nesnesini yazar).
|
|
398
|
+
const objects = jsonObjectCandidates(raw).reverse();
|
|
399
|
+
candidates.push(...objects.filter((o) => PROTOCOL_KEYS.test(o)), ...objects.filter((o) => !PROTOCOL_KEYS.test(o)));
|
|
327
400
|
for (const candidate of candidates) {
|
|
328
|
-
|
|
401
|
+
for (const attempt of [candidate, repairJsonText(candidate)]) {
|
|
402
|
+
try {
|
|
403
|
+
const parsed = JSON.parse(attempt);
|
|
404
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) return parsed;
|
|
405
|
+
} catch {}
|
|
406
|
+
}
|
|
329
407
|
}
|
|
330
|
-
|
|
408
|
+
const error = new Error(`${label} gecerli JSON dondurmedi.`);
|
|
409
|
+
error.rawText = raw;
|
|
410
|
+
throw error;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// Protokol hatasinda operatorun ham metnini kullaniciya gosterilebilir bir cevaba cevirir.
|
|
414
|
+
// Yarim kalmis/kirik JSON parcalarini ve kod bloklarini atar; geriye anlamli duz metin
|
|
415
|
+
// kalmiyorsa null doner (o zaman normal hata akisi calisir).
|
|
416
|
+
function conversationalAnswer(error) {
|
|
417
|
+
if (!/gecerli JSON dondurmedi/i.test(String(error?.message || ""))) return null;
|
|
418
|
+
const raw = String(error.rawText || "");
|
|
419
|
+
if (!raw.trim()) return null;
|
|
420
|
+
const stripped = raw
|
|
421
|
+
.replace(/```[\s\S]*?```/g, " ")
|
|
422
|
+
.replace(/\{[\s\S]*\}/g, " ")
|
|
423
|
+
.replace(/[\s\S]*?^\s*\{[\s\S]*$/m, (match) => match.split("{")[0])
|
|
424
|
+
.replace(/\n{3,}/g, "\n\n")
|
|
425
|
+
.trim();
|
|
426
|
+
// Cok kisa artiklar (or. tek noktalama) cevap sayilmaz.
|
|
427
|
+
return stripped.length >= 8 ? stripped : null;
|
|
331
428
|
}
|
|
332
429
|
|
|
333
430
|
function capabilitiesFor(agent) {
|
|
@@ -689,16 +786,20 @@ class Engine extends EventEmitter {
|
|
|
689
786
|
} catch (error) {
|
|
690
787
|
if (!this.salvage(task, error)) {
|
|
691
788
|
const found = store.findTask(task.id);
|
|
789
|
+
const failure = classifyCliError(error);
|
|
692
790
|
task.status = "failed";
|
|
693
791
|
task.error = error.message;
|
|
792
|
+
// Siniflandirilmis teshis gorevle birlikte saklanir; arayuz "ne oldu / ne yapmali"
|
|
793
|
+
// ayrimini ham hata metnini kirparak tahmin etmek yerine buradan okur.
|
|
794
|
+
task.failure = failure;
|
|
694
795
|
task.finishedAt = new Date().toISOString();
|
|
695
796
|
if (found) store.moveTask(found.state, "failed", task);
|
|
696
|
-
this.publish("log", { level: "error", msg: `HATA: ${
|
|
797
|
+
this.publish("log", { level: "error", msg: `HATA (${failure.code}): ${failure.summary}` }, task.id);
|
|
798
|
+
this.publish("log", { level: "warn", msg: `Ne yapmali: ${failure.action}` }, task.id);
|
|
697
799
|
if (task.kind === "operator-chat") {
|
|
698
|
-
|
|
699
|
-
this.publish("result", { id: task.id, kind: "operator-chat", parentTaskId: task.parentTaskId, status: "failed", error: failure.summary }, task.id);
|
|
800
|
+
this.publish("result", { id: task.id, kind: "operator-chat", parentTaskId: task.parentTaskId, status: "failed", error: failure.summary, failure }, task.id);
|
|
700
801
|
}
|
|
701
|
-
this.notifyOutcome(task, "failed", { error:
|
|
802
|
+
this.notifyOutcome(task, "failed", { error: failure.summary, failureCode: failure.code, action: failure.action });
|
|
702
803
|
this.emit("queue");
|
|
703
804
|
}
|
|
704
805
|
} finally {
|
|
@@ -847,7 +948,12 @@ class Engine extends EventEmitter {
|
|
|
847
948
|
this.publish("activity", { ...base, kind: "process.finished", exitCode: code, signal, durationMs, reason: silenceTimedOut ? "silence-timeout" : (timedOut ? "timeout" : null) });
|
|
848
949
|
if (silenceTimedOut) return reject(new Error(`CLI_STALLED: ${agent.cmd} ${Math.round(silenceTimeoutMs / 1000)} saniye boyunca cikti uretmedi ve otomatik durduruldu.`));
|
|
849
950
|
if (timedOut) return reject(new Error(`${agent.cmd} ${Math.round(timeoutMs / 1000)} saniyede zaman asimina ugradi${signal ? ` (signal=${signal})` : ""}. ${clip(stdout || stderr, 500)}`));
|
|
850
|
-
|
|
951
|
+
// Teshis icin HER IKI akis da gerekir: bazi CLI'lar (Gemini dahil) kota/oturum hatasini
|
|
952
|
+
// stdout'a, yigin izini stderr'e yazar. Yalnizca birini almak siniflandiriciyi kor birakiyordu.
|
|
953
|
+
if (code !== 0) {
|
|
954
|
+
const detail = [stderr, stdout].map((stream) => String(stream || "").trim()).filter(Boolean).join("\n");
|
|
955
|
+
return reject(new Error(`${agent.cmd} cikis kodu ${code ?? "yok"}${signal ? ` (signal=${signal})` : ""}.\n${clip(detail, 2000)}`));
|
|
956
|
+
}
|
|
851
957
|
const normalized = normalizeCliOutput(agent, stdout);
|
|
852
958
|
if (normalized.error) return reject(new Error(`OpenCode model/provider hatasi: ${clip(normalized.error, 500)}`));
|
|
853
959
|
if (!normalized.text) return reject(new Error(`${agent.cmd} kullanilabilir cikti dondurmedi.${stderr ? ` ${clip(stderr, 300)}` : ""}`));
|
|
@@ -897,7 +1003,13 @@ class Engine extends EventEmitter {
|
|
|
897
1003
|
// auth/timeout veya proses hatasi ayni operatoru tekrar calistirmamalidir.
|
|
898
1004
|
if (!/gecerli JSON dondurmedi/i.test(String(error?.message || ""))) throw error;
|
|
899
1005
|
if (attempt >= retries) break;
|
|
900
|
-
|
|
1006
|
+
// Modelin ne dondurdugunu duzeltme istegine geri veriyoruz: "yalnizca JSON dondur"
|
|
1007
|
+
// talimatini tekrarlamak, hatayi goremeyen model icin cogu zaman ayni cevabi uretiyordu.
|
|
1008
|
+
correction = `\n\nONCEKI CEVAP PROTOKOLE UYMADI: ${error.message}\n` +
|
|
1009
|
+
`Senin onceki cevabin (kirpilmis):\n"""\n${clip(String(error.rawText || ""), 1200)}\n"""\n` +
|
|
1010
|
+
`Bu cevap gecerli bir JSON nesnesi degildi. Simdi SADECE tek bir JSON nesnesi dondur: ` +
|
|
1011
|
+
`ilk karakter { ve son karakter } olsun; oncesinde/sonrasinda selamlama, aciklama, dusunce, ` +
|
|
1012
|
+
`Markdown veya \`\`\` kod bloğu OLMASIN. Metin alanlarindaki cift tirnaklari \\" ile kacir.`;
|
|
901
1013
|
this.publish("log", { level: "warn", msg: `${label} protokol hatasi; operator yeniden deneniyor (${attempt + 2}/${retries + 1}).` });
|
|
902
1014
|
}
|
|
903
1015
|
}
|
|
@@ -959,7 +1071,8 @@ class Engine extends EventEmitter {
|
|
|
959
1071
|
: "";
|
|
960
1072
|
const protocol = phase === "plan"
|
|
961
1073
|
? `Yalnizca gecerli JSON dondur. Gorev bir is/degisiklik/arastirma gerektiriyorsa delege et: {"summary":"yaklasim", "completionCriteria":["..."], "assignments":[{"id":"benzersiz-id", "agent":"catalog-name", "kind":"implement|review|research|plan", "instruction":"net gorev ve teslimat", "dependsOn":[]${skillField}}]} (en az bir assignment). ` +
|
|
962
|
-
`Gorev yalnizca bir bilgi/soru
|
|
1074
|
+
`Gorev yalnizca bir bilgi/soru VEYA bir selamlasma/sohbet mesaji ise (or. "merhaba", "nasilsin", "kac beceri var") ve yaniti dogrudan verebiliyorsan, HICBIR delegasyon acmadan: {"status":"complete", "final":"kullaniciya gosterilecek CEVABIN TAM METNI", "verification":"cevabin dayandigi kaynak"}. ` +
|
|
1075
|
+
`Selamlasmalarda bile cevabi JSON DISINA yazma: kullaniciya gosterilen tek alan "final"dir, nesnenin disindaki her metin atilir. Gercek is gerektiren gorevi bu kestirmeyle atlatma.${skillProtocol}`
|
|
963
1076
|
: `Yalnizca gecerli JSON dondur. Is tamamlanmadiysa {"status":"continue", "reason":"...", "assignments":[{"id":"...", "agent":"...", "kind":"implement|review|research|plan", "instruction":"...", "dependsOn":[]${skillField}}]}; tum kabul kriterleri karsilandiysa {"status":"complete", "final":"en fazla 5 kisa maddeyle ne yapildi", "verification":"tek satir dogrulama"}. Dosya listesini motor ekleyecek; final icinde uzun log veya ham agent cevabi tekrarlama. Continue icin en az bir yeni assignment zorunlu.${skillProtocol}\n` +
|
|
964
1077
|
`INCELEME DISIPLINI: Bagimsiz denetim VERDICT: PASS verdiyse ayni teslimat icin YENI review delegasyonu acma; complete dondur ve dusuk/orta onemdeki kalan notlari final metninde kalan risk olarak belirt. Ekipte bulunmayan dogrulama yetenegini (or. canli tarayici) tamamlanma sarti yapma; NOT RUN kalan dusuk riskli kontroller teslimati engellemez.`;
|
|
965
1078
|
const strategy = task.executionMode === "fast"
|
|
@@ -968,6 +1081,11 @@ class Engine extends EventEmitter {
|
|
|
968
1081
|
? "DERIN MOD: Isi uygun uzmanliklar arasinda dagit — planlama, uygulama, test ve bagimsiz inceleme icin AYRI ve dogru uzmanlari kullan."
|
|
969
1082
|
: "DENGELI MOD: Katalogda planner, executor ve reviewer varsa ucunu da ILK planda kullan. PLANLAMA -> UYGULAMA -> BAGIMSIZ INCELEME delegasyonlarini dependsOn ile ayni turda zincirle ve isi tek turda bitirmeyi hedefle. Ayni rolde birden fazla esdeger agent varsa yalnizca en uygun olani sec.";
|
|
970
1083
|
return `${role}\n\n---\n## Operator protokolu\n${protocol}\n` +
|
|
1084
|
+
// OpenCode gibi sohbet odakli CLI'lar varsayilan olarak once bir cumle yazip JSON'u
|
|
1085
|
+
// arkasina ekliyor; motor bunu ayiklayabilse de belirsizlik protokol hatasi uretiyordu.
|
|
1086
|
+
`## Cikti bicimi (KATI)\nCevabin TAMAMI tek bir JSON nesnesi olmali: ilk karakter { , son karakter } . ` +
|
|
1087
|
+
`Oncesinde/sonrasinda selamlama, aciklama, dusunce notu, Markdown basligi veya \`\`\` kod bloğu YAZMA. ` +
|
|
1088
|
+
`Kullaniciya iletmek istedigin her seyi ilgili JSON alanina ("final" veya "summary") koy; nesnenin disindaki metin kullaniciya ULASMAZ.\n` +
|
|
971
1089
|
`Yalnizca katalogdaki agent adlarini kullan. Her assignment kind degeri secilen agentin allowedKinds listesinde olmali. Kendine gorev atama. Ayni delegasyon id'sini tekrar kullanma.\n` +
|
|
972
1090
|
`Bir agent basarisiz veya kullanilamaz raporlandiysa ayni isi ona tekrar verme; katalogdaki alternatif bir uzmani sec.\n` +
|
|
973
1091
|
`AJAN SECIMI: Her alt gorevi, katalogdaki YETENEKLERE ve role gore o ise EN UYGUN uzmana ata; tum isi tek bir CLI'ye yigma. Isin ihtiyac duydugu her uzmanlik icin dogru uzmani sec (plan/tasarim -> planlama yetenegi; uygulama -> implementation; inceleme/dogrulama -> review/test; arastirma -> research/web). Ayni KIND icin birden fazla eşdeğer agent varsa YALNIZCA birini (en uygun ve en dusuk maliyetli) kullan; ayni isi iki eşdeğer agente verme. Farkli roller (or. bir uygulayici + bir inceleyici) FARKLI islerdir, tekrar sayilmaz.\n` +
|
|
@@ -1128,7 +1246,19 @@ class Engine extends EventEmitter {
|
|
|
1128
1246
|
const shortcutRetries = requiresWork ? Math.max(1, cfg.operator?.protocolRetries ?? 1) : 0;
|
|
1129
1247
|
let plan, shortcutAttempt = 0, planCorrection = "";
|
|
1130
1248
|
while (true) {
|
|
1131
|
-
|
|
1249
|
+
try {
|
|
1250
|
+
plan = await this.invokeOperatorJson(operatorCli, this.operatorPrompt(task, cfg, memory, state, "plan") + planCorrection, cfg, "operator-plan", "Operator plani");
|
|
1251
|
+
} catch (error) {
|
|
1252
|
+
// Sohbet kurtarma: gorev delegasyon gerektirmiyorsa (selamlasma, kisa soru) ve operator
|
|
1253
|
+
// protokol nesnesi yerine duz metinle cevap verdiyse, kullaniciyi "gecerli JSON
|
|
1254
|
+
// dondurmedi" hatasiyla karsilamak yanlistir — istenen sey zaten o metindi. Yalnizca
|
|
1255
|
+
// is gerektirmeyen gorevlerde ve elde gercek bir metin varken devreye girer.
|
|
1256
|
+
const prose = conversationalAnswer(error);
|
|
1257
|
+
if (requiresWork || !prose) throw error;
|
|
1258
|
+
this.publish("log", { level: "warn", msg: "Operator protokol nesnesi dondurmedi; gorev is gerektirmedigi icin duz metin cevabi teslimat sayildi." }, task.id);
|
|
1259
|
+
task.teamState = state;
|
|
1260
|
+
return this.complete(task, state, "done", prose, { verification: "Operatorun dogrudan yaniti (protokol nesnesi yerine duz metin)." });
|
|
1261
|
+
}
|
|
1132
1262
|
const isShortcut = plan && String(plan.status).toLowerCase() === "complete" && !Array.isArray(plan.assignments);
|
|
1133
1263
|
if (!isShortcut) break;
|
|
1134
1264
|
if (!requiresWork) {
|
|
@@ -1418,4 +1548,5 @@ module.exports = new Engine();
|
|
|
1418
1548
|
module.exports._internals = {
|
|
1419
1549
|
normalizeAssignments, ensureBalancedRoleChain, extractVerdict, clipMiddle, snapshotDir, diffSnapshots,
|
|
1420
1550
|
captureTextSnapshot, buildLineDiff, describeFileDiff, isSensitiveDiffPath, taskRequiresDelegation,
|
|
1551
|
+
parseJson, conversationalAnswer, classifyCliError, RECOVERABLE_CLI_ERRORS, QUARANTINE_CLI_ERRORS,
|
|
1421
1552
|
};
|