@omerrgocmen/crewctl 1.0.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 +182 -0
- package/orchestrator/LICENSE +21 -0
- package/orchestrator/README.md +452 -0
- package/orchestrator/config.default.json +65 -0
- package/orchestrator/roles/executor.md +49 -0
- package/orchestrator/roles/operator-chat.md +25 -0
- package/orchestrator/roles/operator.md +75 -0
- package/orchestrator/roles/planner.md +53 -0
- package/orchestrator/roles/reviewer.md +54 -0
- package/orchestrator/skills/acceptance-criteria.md +18 -0
- package/orchestrator/skills/accessibility-audit.md +16 -0
- package/orchestrator/skills/accessible-forms.md +16 -0
- package/orchestrator/skills/api-design.md +27 -0
- package/orchestrator/skills/api-documentation.md +16 -0
- package/orchestrator/skills/architecture-decision-record.md +18 -0
- package/orchestrator/skills/authentication-design.md +16 -0
- package/orchestrator/skills/authorization-review.md +16 -0
- package/orchestrator/skills/backward-compatibility.md +17 -0
- package/orchestrator/skills/changelog-writing.md +16 -0
- package/orchestrator/skills/ci-pipeline-design.md +16 -0
- package/orchestrator/skills/cli-design.md +16 -0
- package/orchestrator/skills/code-review.md +27 -0
- package/orchestrator/skills/configuration-management.md +16 -0
- package/orchestrator/skills/container-review.md +16 -0
- package/orchestrator/skills/contract-testing.md +16 -0
- package/orchestrator/skills/dashboard-design.md +16 -0
- package/orchestrator/skills/database-migration.md +16 -0
- package/orchestrator/skills/database-schema-design.md +16 -0
- package/orchestrator/skills/debugging.md +26 -0
- package/orchestrator/skills/dependency-review.md +16 -0
- package/orchestrator/skills/design-review.md +29 -0
- package/orchestrator/skills/design-system.md +16 -0
- package/orchestrator/skills/docs-api-reference.md +16 -0
- package/orchestrator/skills/docs-troubleshooting.md +16 -0
- package/orchestrator/skills/docs-tutorial.md +16 -0
- package/orchestrator/skills/docs-writing.md +25 -0
- package/orchestrator/skills/empty-error-loading-states.md +16 -0
- package/orchestrator/skills/end-to-end-testing.md +16 -0
- package/orchestrator/skills/error-handling.md +16 -0
- package/orchestrator/skills/frontend-design.md +28 -0
- package/orchestrator/skills/git-commit-writing.md +16 -0
- package/orchestrator/skills/graphql-design.md +16 -0
- package/orchestrator/skills/incident-runbook.md +18 -0
- package/orchestrator/skills/input-validation.md +16 -0
- package/orchestrator/skills/integration-testing.md +16 -0
- package/orchestrator/skills/interaction-design.md +16 -0
- package/orchestrator/skills/landing-page-design.md +16 -0
- package/orchestrator/skills/observability-design.md +16 -0
- package/orchestrator/skills/openapi-contract.md +16 -0
- package/orchestrator/skills/performance-profiling.md +16 -0
- package/orchestrator/skills/privacy-review.md +16 -0
- package/orchestrator/skills/property-based-testing.md +16 -0
- package/orchestrator/skills/pull-request-writing.md +16 -0
- package/orchestrator/skills/refactoring.md +16 -0
- package/orchestrator/skills/release-readiness.md +16 -0
- package/orchestrator/skills/responsive-design.md +16 -0
- package/orchestrator/skills/secrets-management.md +16 -0
- package/orchestrator/skills/secure-file-upload.md +16 -0
- package/orchestrator/skills/security-review.md +26 -0
- package/orchestrator/skills/semantic-versioning.md +17 -0
- package/orchestrator/skills/seo-on-page.md +16 -0
- package/orchestrator/skills/seo-structured-data.md +16 -0
- package/orchestrator/skills/seo-technical-audit.md +16 -0
- package/orchestrator/skills/sql-query-review.md +16 -0
- package/orchestrator/skills/supply-chain-security.md +16 -0
- package/orchestrator/skills/test-strategy.md +16 -0
- package/orchestrator/skills/threat-modeling.md +16 -0
- package/orchestrator/skills/unit-testing.md +16 -0
- package/orchestrator/skills/write-tests.md +28 -0
- package/orchestrator/src/checkpoints.js +187 -0
- package/orchestrator/src/cli-registry.js +579 -0
- package/orchestrator/src/cli.js +135 -0
- package/orchestrator/src/doctor.js +64 -0
- package/orchestrator/src/engine.js +1364 -0
- package/orchestrator/src/schedule.js +126 -0
- package/orchestrator/src/server.js +706 -0
- package/orchestrator/src/skill-registry.js +272 -0
- package/orchestrator/src/store.js +364 -0
- package/orchestrator/web/OrbitControls.js +1417 -0
- package/orchestrator/web/app.css +116 -0
- package/orchestrator/web/app.js +70 -0
- package/orchestrator/web/board.html +141 -0
- package/orchestrator/web/code.html +208 -0
- package/orchestrator/web/flow.html +736 -0
- package/orchestrator/web/index.html +539 -0
- package/orchestrator/web/jsm/postprocessing/EffectComposer.js +231 -0
- package/orchestrator/web/jsm/postprocessing/MaskPass.js +104 -0
- package/orchestrator/web/jsm/postprocessing/Pass.js +95 -0
- package/orchestrator/web/jsm/postprocessing/RenderPass.js +99 -0
- package/orchestrator/web/jsm/postprocessing/ShaderPass.js +77 -0
- package/orchestrator/web/jsm/postprocessing/UnrealBloomPass.js +415 -0
- package/orchestrator/web/jsm/shaders/CopyShader.js +45 -0
- package/orchestrator/web/jsm/shaders/LuminosityHighPassShader.js +66 -0
- package/orchestrator/web/three.module.min.js +6 -0
- package/package.json +51 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: security-review
|
|
3
|
+
description: Değişiklikleri yaygın güvenlik açıkları açısından denetleme rehberi (OWASP odaklı)
|
|
4
|
+
category: security
|
|
5
|
+
appliesTo: [review]
|
|
6
|
+
match: [guvenlik, güvenlik, security, auth, kimlik, yetki, injection, xss, csrf, secret, token, sql, sifre, şifre, zafiyet]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Beceri: Güvenlik İncelemesi
|
|
10
|
+
|
|
11
|
+
Salt okunur denetle; kanıtla göster. Teorik risk yerine bu kod tabanında sömürülebilir yolları ara.
|
|
12
|
+
|
|
13
|
+
## Kontrol alanları
|
|
14
|
+
|
|
15
|
+
- **Girdi doğrulama & injection:** SQL/NoSQL/komut/şablon injection; parametreli sorgu ve güvenli API kullanımı.
|
|
16
|
+
- **Çıktı kodlama & XSS:** Kullanıcı verisi güvenli kaçışla mı render ediliyor; `dangerouslySetInnerHTML`/`eval` var mı?
|
|
17
|
+
- **Kimlik & yetki:** Kimlik doğrulama ve yetki kontrolü her hassas yolda var mı? IDOR / eksik erişim kontrolü?
|
|
18
|
+
- **Sırlar:** Kod, log veya istemciye sızan API anahtarı, parola, token var mı? `.env`/secret yönetimi doğru mu?
|
|
19
|
+
- **Veri akışı:** Güvenilmeyen girdinin dosya yolu, komut, URL veya deserializasyona ulaştığı yerler.
|
|
20
|
+
- **Bağımlılık & yapılandırma:** Bilinen zafiyetli paket, güvensiz varsayılan, açık CORS, eksik güvenlik başlıkları.
|
|
21
|
+
- **Kripto & rastgelelik:** Zayıf hash/şifreleme, tahmin edilebilir token, sabit IV/anahtar.
|
|
22
|
+
|
|
23
|
+
## Teslimat
|
|
24
|
+
|
|
25
|
+
Her bulgu için: önem (HIGH/MEDIUM/LOW), dosya:satır, sömürü senaryosu ve somut düzeltme. Yıkıcı test veya
|
|
26
|
+
gerçek exploit **çalıştırma**; yalnızca statik inceleme yap. Sonunda `VERDICT: PASS` veya `VERDICT: FAIL` yaz.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: semantic-versioning
|
|
3
|
+
description: Kamuya açık sözleşme değişimine göre major, minor veya patch sürüm etkisini belirle; paket ve release işlerinde kullan.
|
|
4
|
+
category: software
|
|
5
|
+
appliesTo: [plan, implement, review]
|
|
6
|
+
match: [semver, semantic versioning, sürümleme, version bump, major, minor, patch, breaking]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Semantik Sürümleme
|
|
10
|
+
|
|
11
|
+
1. Önce “kamuya açık API”yi proje bağlamında tanımla: kod, CLI, şema, dosya biçimi veya davranış.
|
|
12
|
+
2. Uyumlu hata düzeltmesini PATCH, geriye uyumlu yeteneği MINOR, kırıcı sözleşmeyi MAJOR olarak sınıflandır.
|
|
13
|
+
3. `0.y.z`, prerelease ve proje-özel politikasını mevcut belgeden kontrol et; varsayma.
|
|
14
|
+
4. Bağımlılık güncellemesinin tüketici sözleşmesine gerçek etkisini değerlendir.
|
|
15
|
+
5. Sürüm kararını changelog ve migration notuyla tutarlı kıl.
|
|
16
|
+
|
|
17
|
+
Yalnızca commit türüne bakarak sürüm belirleme; gözlemlenebilir tüketici etkisini kanıtla.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: seo-on-page
|
|
3
|
+
description: Sayfa niyeti, başlık, içerik yapısı ve snippet öğelerini kullanıcı odaklı optimize et; on-page SEO ve içerik güncellemede kullan.
|
|
4
|
+
category: seo
|
|
5
|
+
appliesTo: [plan, implement, review]
|
|
6
|
+
match: [on page seo, sayfa içi seo, title tag, meta description, heading, search intent, arama niyeti, keyword]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Sayfa İçi SEO
|
|
10
|
+
|
|
11
|
+
- Hedef sorgu kümesinin gerçek kullanıcı niyetini ve sayfanın tek birincil amacını belirle.
|
|
12
|
+
- Benzersiz, açık ve içeriği doğru temsil eden title ile H1 yaz; doğal dili bozarak anahtar kelime doldurma.
|
|
13
|
+
- İlk bölümde soruyu doğrudan yanıtla, başlıklarla taranabilir yapı ve özgün kanıt/örnek sun.
|
|
14
|
+
- Meta description'ı kısa değer özeti olarak yaz; garanti veya yanıltıcı vaat kullanma.
|
|
15
|
+
- Açıklayıcı URL, görsel alt metni ve ilgili iç bağlantıları kullanıcı yolculuğuna göre düzenle.
|
|
16
|
+
- Canonical/index durumunu, mobil görünümü ve render edilmiş HTML'i doğrula; meta keywords ekleme.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: seo-structured-data
|
|
3
|
+
description: Görünür sayfa içeriğini doğru Schema.org/JSON-LD işaretlemesiyle ifade et; structured data ve rich result işlerinde kullan.
|
|
4
|
+
category: seo
|
|
5
|
+
appliesTo: [plan, implement, review]
|
|
6
|
+
match: [structured data, yapılandırılmış veri, schema.org, json-ld, rich result, breadcrumb schema, product schema]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Yapılandırılmış Veri
|
|
10
|
+
|
|
11
|
+
1. Sayfanın görünür birincil varlığına ve arama motorunun desteklediği özelliğe uygun en dar türü seç.
|
|
12
|
+
2. Yalnız kullanıcıya gerçekten gösterilen, doğru ve güncel alanları işaretle; sahte review/rating üretme.
|
|
13
|
+
3. JSON-LD'yi tek ve tutarlı `@id` ilişkileriyle kur; Organization, WebSite, WebPage ve ana varlığı gerektiğinde bağla.
|
|
14
|
+
4. Required/recommended alan, URL, tarih, para birimi ve stok değerlerini gerçek veri kaynağına bağla.
|
|
15
|
+
5. Syntax ve rich result doğrulamasını çalıştır; render edilmiş sayfada içerikle eşleştiğini kontrol et.
|
|
16
|
+
6. Uygunluk veya zengin sonuç garantisi verme; hata ve güncelleme sahipliğini belgeye ekle.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: seo-technical-audit
|
|
3
|
+
description: Bir sitenin taranabilirlik, indekslenebilirlik, canonical, performans ve render sorunlarını denetle; teknik SEO işlerinde kullan.
|
|
4
|
+
category: seo
|
|
5
|
+
appliesTo: [plan, implement, review, research]
|
|
6
|
+
match: [technical seo, teknik seo, crawl, index, canonical, robots, sitemap, search console, crawl budget]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Teknik SEO Denetimi
|
|
10
|
+
|
|
11
|
+
1. Önemli URL şablonlarını ve istenen index durumunu envanterle; örnek URL'leri HTTP ve render edilmiş DOM düzeyinde incele.
|
|
12
|
+
2. Status/redirect zinciri, robots kuralları, meta robots, canonical ve sitemap tutarlılığını kontrol et.
|
|
13
|
+
3. İç linkle keşif, orphan sayfa, pagination, faceted URL ve duplicate içerik kümelerini ara.
|
|
14
|
+
4. Başlık, ana içerik ve linklerin JavaScript başarısızken erişilebilirliğini değerlendir.
|
|
15
|
+
5. Mobil kullanılabilirlik, Core Web Vitals ve büyük kaynak darboğazlarını kanıtla.
|
|
16
|
+
6. Bulguları etki, kapsam, kanıt ve düzeltmeyle sırala; sıralama garantisi verme ve search engine yönergelerini baypas etme.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sql-query-review
|
|
3
|
+
description: SQL sorgusunu doğruluk, güvenlik, plan ve veri hacmi açısından incele; sorgu yazma veya performans işlerinde kullan.
|
|
4
|
+
category: software
|
|
5
|
+
appliesTo: [implement, review]
|
|
6
|
+
match: [sql, query, sorgu, explain, index, join, database performance, n+1]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# SQL Sorgu İncelemesi
|
|
10
|
+
|
|
11
|
+
- Parametre bağlamayı ve güvenilmeyen girdinin sorgu metnine karışmadığını doğrula.
|
|
12
|
+
- Join kardinalitesi, null semantiği, duplicate satır, filtre sırası ve sınır durumlarını örnek veriyle kontrol et.
|
|
13
|
+
- Beklenen veri hacminde EXPLAIN/planı incele; full scan, kötü tahmin ve gereksiz sort'u ara.
|
|
14
|
+
- Seçilen kolonları daralt, sayfalamayı kararlı sıraya bağla ve N+1 erişimi önle.
|
|
15
|
+
- Transaction, kilit ve eşzamanlı güncelleme etkisini yazma sorgularında değerlendir.
|
|
16
|
+
- İndeksi yalnızca gerçek sorgu deseniyle gerekçelendir; önce/sonra ölçümü ve doğruluk testi sun.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: supply-chain-security
|
|
3
|
+
description: Kaynak, bağımlılık, build ve yayın zincirinde bütünlük ve en az yetkiyi denetle; paket ve CI güvenliğinde kullan.
|
|
4
|
+
category: security
|
|
5
|
+
appliesTo: [plan, implement, review]
|
|
6
|
+
match: [supply chain, tedarik zinciri, sbom, provenance, dependency confusion, package security, artifact signing]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Tedarik Zinciri Güvenliği
|
|
10
|
+
|
|
11
|
+
1. Kaynaktan yayınlanan artefakta kadar repository, runner, registry ve paket güven sınırlarını çıkar.
|
|
12
|
+
2. Bağımlılık kaynağını/lockfile bütünlüğünü doğrula; namespace ve dependency confusion riskini kontrol et.
|
|
13
|
+
3. CI eylemlerini ve araç sürümlerini sabitle, izinleri daralt, güvenilmeyen koddan sırları ayır.
|
|
14
|
+
4. Build'i temiz ortamda tekrarlanabilir yap; SBOM/provenance ve artefakt checksum/imza üretimini değerlendir.
|
|
15
|
+
5. Yayın kimliğini kısa ömürlü ve onaylı kullan; registry sahipliği ile kurtarma hesaplarını koru.
|
|
16
|
+
6. İhlal halinde paket iptali, anahtar rotation ve tüketici iletişimi yolunu belgeleyip doğrula.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: test-strategy
|
|
3
|
+
description: Riski doğru test katmanına dağıtan yalın bir doğrulama stratejisi kur; özellik veya proje planlamasında kullan.
|
|
4
|
+
category: testing
|
|
5
|
+
appliesTo: [plan, implement, review]
|
|
6
|
+
match: [test strategy, test plan, test stratejisi, kalite planı, coverage, test pyramid, doğrulama planı]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Test Stratejisi
|
|
10
|
+
|
|
11
|
+
1. Kritik kullanıcı akışlarını, güven sınırlarını ve en pahalı hata türlerini sırala.
|
|
12
|
+
2. Saf mantığı birim, bileşen sınırını entegrasyon, az sayıdaki kritik akışı uçtan uca testlere ver.
|
|
13
|
+
3. Güvenlik, performans, erişilebilirlik ve migration gibi işlev dışı riskleri ayrıca ele al.
|
|
14
|
+
4. Her risk için gözlemlenebilir oracle, veri ihtiyacı ve çalıştırma katmanı belirle.
|
|
15
|
+
5. Hızlı PR kapısı ile daha pahalı gece/release kontrollerini ayır.
|
|
16
|
+
6. Kapsam yüzdesi yerine yakalanan risk, güvenilirlik ve tanılama kalitesini ölç.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: threat-modeling
|
|
3
|
+
description: Varlık, güven sınırı ve kötüye kullanım yollarından öncelikli tehditler çıkar; yeni özellik veya mimari güvenlik planında kullan.
|
|
4
|
+
category: security
|
|
5
|
+
appliesTo: [plan, review]
|
|
6
|
+
match: [threat model, tehdit modeli, stride, attack surface, saldırı yüzeyi, abuse case, trust boundary]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Tehdit Modelleme
|
|
10
|
+
|
|
11
|
+
1. Korunacak varlıkları, aktörleri, veri akışlarını ve dış bağımlılıkları çiz.
|
|
12
|
+
2. Kimliğin veya verinin güven düzeyi değiştirdiği sınırları ve giriş noktalarını işaretle.
|
|
13
|
+
3. Spoofing, tampering, repudiation, disclosure, denial ve privilege escalation kötüye kullanımlarını somut akışlara uygula.
|
|
14
|
+
4. Olasılık ile etkiyi birlikte değerlendir; teorik liste yerine öncelikli saldırı yolları üret.
|
|
15
|
+
5. Her yüksek risk için önleme, algılama, sorumlu ve doğrulama testi tanımla.
|
|
16
|
+
6. Kabul edilen riski ve varsayımı kaydet; modelin kapsamını değişiklikle birlikte güncelle.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: unit-testing
|
|
3
|
+
description: Saf davranışı hızlı, yalıtılmış ve dayanıklı birim testleriyle kanıtla; fonksiyon veya sınıf testlerinde kullan.
|
|
4
|
+
category: testing
|
|
5
|
+
appliesTo: [implement, review]
|
|
6
|
+
match: [unit test, birim testi, jest, vitest, pytest, xunit, mock, function test]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Birim Testi
|
|
10
|
+
|
|
11
|
+
- Tek bir davranış ve kamuya açık giriş noktası seç; uygulama ayrıntısını test etme.
|
|
12
|
+
- Arrange/Act/Assert akışını belirgin tut ve test adında koşul ile beklenen sonucu yaz.
|
|
13
|
+
- Eşdeğer sınıfları, sınır değerleri ve hata yollarını az ama anlamlı vakayla kapsa.
|
|
14
|
+
- Saat, rastgelelik ve I/O bağımlılıklarını sınırda enjekte et; test edilen birimi mock'lama.
|
|
15
|
+
- Her test kendi verisini kursun, küresel durumu geri temizlesin ve sıra bağımsız olsun.
|
|
16
|
+
- Hata mesajlarının neyin bozulduğunu gösterebildiğini kontrol edip ilgili test komutunu çalıştır.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: write-tests
|
|
3
|
+
description: Değişen davranış için hedefli, güvenilir test yazma ve çalıştırma disiplini
|
|
4
|
+
category: testing
|
|
5
|
+
appliesTo: [implement, review]
|
|
6
|
+
match: [test, tests, jest, pytest, mocha, vitest, coverage, kapsam, birim, unit, e2e, dogrula, doğrula]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Beceri: Test Yazma
|
|
10
|
+
|
|
11
|
+
Testin amacı davranışı kanıtlamaktır; yeşil göstermek değil.
|
|
12
|
+
|
|
13
|
+
## Yaklaşım
|
|
14
|
+
|
|
15
|
+
- **Davranışı test et, uygulamayı değil:** Gözlemlenebilir girdi→çıktı ve yan etkilere odaklan; iç
|
|
16
|
+
ayrıntıya kilitlenen kırılgan testlerden kaçın.
|
|
17
|
+
- **Önce risk:** En olası hata yollarını ve sınır durumlarını (boş, sıfır, negatif, çok büyük, eşzamanlı,
|
|
18
|
+
hatalı girdi) kapsa. Mutlu yol tek başına yetmez.
|
|
19
|
+
- **Bağımsız ve deterministik:** Testler sıralamadan, saatten, ağdan ve paylaşılan durumdan bağımsız olsun;
|
|
20
|
+
dış bağımlılıkları uygun yerde taklit et (mock/fake).
|
|
21
|
+
- **Tek iddia teması:** Her test tek bir davranışı doğrulasın; isim ne test edildiğini anlatsın.
|
|
22
|
+
- **Mevcut düzene uy:** Projenin test çatısını, klasör ve adlandırma kurallarını izle.
|
|
23
|
+
|
|
24
|
+
## Doğrulama
|
|
25
|
+
|
|
26
|
+
Testleri gerçekten çalıştır ve sonucu raporla. Yeni testin, düzeltmeden önce **kırmızı** olup düzeltmeden
|
|
27
|
+
sonra **yeşile** döndüğünü mümkünse göster. Testi geçirmek için üretim kodunu bozma veya kontrolü gevşetme.
|
|
28
|
+
Çalıştırılamayan testi "geçti" gibi sunma; nedenini belirt.
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
// checkpoints.js — gorev-basi otomatik surumleme (sifir bagimlilik).
|
|
2
|
+
// Her gorev CALISMADAN ONCE calisma klasorunun bir surumu (checkpoint) alinir; ajan kodu
|
|
3
|
+
// bozarsa tek tikla o surume donulur. Depolama daima birebir dosya KOPYASIDIR (deterministik,
|
|
4
|
+
// git durumundan bagimsiz, geri-alinabilir). "git-farkinda": klasor bir git deposuysa hangi
|
|
5
|
+
// dosyalarin yedeklenecegi `git ls-files` ile belirlenir (boylece .gitignore'a uyulur ve
|
|
6
|
+
// build ciktilari/gecici dosyalar surume girmez); depoysa degilse guvenli bir walk kullanilir.
|
|
7
|
+
// NOT: fs.cpSync Windows'ta non-ASCII yollarda (or. C:\Users\Ömer) cokebiliyor; tum kopyalar
|
|
8
|
+
// Unicode-guvenli fs.copyFileSync ile yapilir.
|
|
9
|
+
const { spawnSync } = require("child_process");
|
|
10
|
+
const fs = require("fs");
|
|
11
|
+
const path = require("path");
|
|
12
|
+
const store = require("./store");
|
|
13
|
+
|
|
14
|
+
const isWin = process.platform === "win32";
|
|
15
|
+
const CP_ROOT = path.join(store.ROOT, "state", "checkpoints");
|
|
16
|
+
const MAX_FILES = 5000; // Bundan buyuk klasorlerde surum alma (guvenlik/performans).
|
|
17
|
+
const MAX_BYTES = 200 * 1024 * 1024;
|
|
18
|
+
const DEFAULT_RETENTION = 20;
|
|
19
|
+
|
|
20
|
+
// snapshotDir (engine) ile AYNI ignore mantigi: node_modules/.git ve orkestratorun kendi
|
|
21
|
+
// runtime durumu (queue/state/memory) surume girmemeli — aksi halde checkpoint kendi icine
|
|
22
|
+
// kopyalanip sisebilir.
|
|
23
|
+
function ignored(rel) {
|
|
24
|
+
const r = String(rel).replace(/\\/g, "/");
|
|
25
|
+
return r.includes("node_modules") || r.includes(".git/") || r === ".git" || r.startsWith(".git/") ||
|
|
26
|
+
r.startsWith("orchestrator/queue") || r.startsWith("orchestrator/state") ||
|
|
27
|
+
r.startsWith("orchestrator/memory") || r.startsWith("orchestrator/node_modules");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function isGitRepo(cwd) {
|
|
31
|
+
try {
|
|
32
|
+
const r = spawnSync("git", ["-C", cwd, "rev-parse", "--is-inside-work-tree"], {
|
|
33
|
+
encoding: "utf8", timeout: 8000, windowsHide: true, shell: isWin,
|
|
34
|
+
});
|
|
35
|
+
return r.status === 0 && /true/i.test(String(r.stdout || ""));
|
|
36
|
+
} catch { return false; }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Tracked + izlenmeyen ama .gitignore'da olmayan dosyalar; NUL ayrac unicode/bosluk-guvenli.
|
|
40
|
+
function gitFileList(cwd) {
|
|
41
|
+
try {
|
|
42
|
+
const r = spawnSync("git", ["-C", cwd, "ls-files", "--cached", "--others", "--exclude-standard", "-z"], {
|
|
43
|
+
encoding: "utf8", timeout: 20000, maxBuffer: 64 * 1024 * 1024, windowsHide: true, shell: isWin,
|
|
44
|
+
});
|
|
45
|
+
if (r.status !== 0) return null;
|
|
46
|
+
return String(r.stdout || "").split("\0").filter(Boolean);
|
|
47
|
+
} catch { return null; }
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function walkFileList(cwd) {
|
|
51
|
+
const out = [];
|
|
52
|
+
let count = 0;
|
|
53
|
+
const walk = (abs, rel) => {
|
|
54
|
+
if (count > MAX_FILES + 1) return;
|
|
55
|
+
let entries;
|
|
56
|
+
try { entries = fs.readdirSync(abs, { withFileTypes: true }); } catch { return; }
|
|
57
|
+
for (const entry of entries) {
|
|
58
|
+
const childRel = rel ? `${rel}/${entry.name}` : entry.name;
|
|
59
|
+
if (ignored(childRel)) continue;
|
|
60
|
+
if (entry.isSymbolicLink()) continue; // Sembolik baglantilari izleme (klasor disina cikmasin).
|
|
61
|
+
const childAbs = path.join(abs, entry.name);
|
|
62
|
+
if (entry.isDirectory()) walk(childAbs, childRel);
|
|
63
|
+
else { out.push(childRel); count++; }
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
walk(cwd, "");
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Yedeklenecek dosya listesi (calisma klasorune GORE goreli yollar).
|
|
71
|
+
function fileList(cwd) {
|
|
72
|
+
if (isGitRepo(cwd)) {
|
|
73
|
+
const git = gitFileList(cwd);
|
|
74
|
+
// Bos liste (or. calisma klasoru gitignore'da) walk'a duser; aksi halde surum bos kalir
|
|
75
|
+
// ve restore hicbir sey yapamaz. Dolu liste .gitignore'a uyan git-farkinda yoldur.
|
|
76
|
+
if (git && git.length) return { files: git.filter((rel) => !ignored(rel)), backend: "git" };
|
|
77
|
+
}
|
|
78
|
+
return { files: walkFileList(cwd), backend: "copy" };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Yol guvenligi: hedef daima cwd icinde kalmali (path traversal / sembolik kacis engeli).
|
|
82
|
+
function within(root, rel) {
|
|
83
|
+
const base = path.resolve(root);
|
|
84
|
+
const target = path.resolve(base, rel);
|
|
85
|
+
return target === base || target.startsWith(base + path.sep) ? target : null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function ensureRoot() { fs.mkdirSync(CP_ROOT, { recursive: true }); }
|
|
89
|
+
|
|
90
|
+
function readManifest(id) {
|
|
91
|
+
try { return JSON.parse(fs.readFileSync(path.join(CP_ROOT, path.basename(String(id)), "manifest.json"), "utf8")); }
|
|
92
|
+
catch { return null; }
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function enforceRetention(cwd, retention) {
|
|
96
|
+
const keep = Math.max(1, Number(retention) || DEFAULT_RETENTION);
|
|
97
|
+
try {
|
|
98
|
+
const mine = fs.readdirSync(CP_ROOT)
|
|
99
|
+
.map(readManifest).filter((m) => m && path.resolve(m.cwd) === path.resolve(cwd))
|
|
100
|
+
.sort((a, b) => (a.at < b.at ? 1 : -1));
|
|
101
|
+
for (const m of mine.slice(keep)) {
|
|
102
|
+
try { fs.rmSync(path.join(CP_ROOT, m.id), { recursive: true, force: true }); } catch {}
|
|
103
|
+
}
|
|
104
|
+
} catch {}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Calisma klasorunun mevcut halinden bir surum (checkpoint) olusturur. Basarisiz/atlanmis
|
|
108
|
+
// durumda gorevi ASLA oldurmez; {ok:false,...} doner ve cagiran log'lar.
|
|
109
|
+
function createCheckpoint(cwd, meta = {}) {
|
|
110
|
+
try {
|
|
111
|
+
ensureRoot();
|
|
112
|
+
const resolvedCwd = path.resolve(cwd);
|
|
113
|
+
if (!fs.existsSync(resolvedCwd)) return { ok: false, skipped: true, reason: "Calisma klasoru bulunamadi." };
|
|
114
|
+
const { files, backend } = fileList(resolvedCwd);
|
|
115
|
+
if (files.length > MAX_FILES) return { ok: false, skipped: true, reason: `Klasor cok buyuk (${files.length} dosya > ${MAX_FILES}); surum alinmadi.` };
|
|
116
|
+
const id = `cp-${new Date().toISOString().replace(/[-:T.]/g, "").slice(0, 17)}-${Math.random().toString(36).slice(2, 7)}`;
|
|
117
|
+
const dir = path.join(CP_ROOT, id);
|
|
118
|
+
const filesDir = path.join(dir, "files");
|
|
119
|
+
fs.mkdirSync(filesDir, { recursive: true });
|
|
120
|
+
const stored = [];
|
|
121
|
+
let bytes = 0;
|
|
122
|
+
for (const rel of files) {
|
|
123
|
+
const src = within(resolvedCwd, rel);
|
|
124
|
+
if (!src) continue;
|
|
125
|
+
let st;
|
|
126
|
+
try { st = fs.lstatSync(src); } catch { continue; }
|
|
127
|
+
if (!st.isFile()) continue; // Sembolik baglanti / klasor / silinmis izlenen dosyayi atla.
|
|
128
|
+
bytes += st.size;
|
|
129
|
+
if (bytes > MAX_BYTES) { try { fs.rmSync(dir, { recursive: true, force: true }); } catch {} return { ok: false, skipped: true, reason: `Klasor cok buyuk (>${Math.round(MAX_BYTES / 1048576)}MB); surum alinmadi.` }; }
|
|
130
|
+
const dest = path.join(filesDir, rel);
|
|
131
|
+
try { fs.mkdirSync(path.dirname(dest), { recursive: true }); fs.copyFileSync(src, dest); stored.push(rel); } catch {}
|
|
132
|
+
}
|
|
133
|
+
const manifest = {
|
|
134
|
+
id, at: new Date().toISOString(), cwd: resolvedCwd, backend,
|
|
135
|
+
fileCount: stored.length, bytes, files: stored,
|
|
136
|
+
taskId: meta.taskId || null, label: String(meta.label || "").slice(0, 300), kind: meta.kind || "pre-task",
|
|
137
|
+
};
|
|
138
|
+
fs.writeFileSync(path.join(dir, "manifest.json"), JSON.stringify(manifest, null, 2));
|
|
139
|
+
enforceRetention(resolvedCwd, meta.retention);
|
|
140
|
+
return { ok: true, ...manifest };
|
|
141
|
+
} catch (error) { return { ok: false, error: error.message }; }
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Bir surumu geri yukler. Once MEVCUT hali de bir surum yapar (redo guvenligi), sonra:
|
|
145
|
+
// (1) surumden SONRA olusan dosyalari siler, (2) surumdeki dosyalari geri yazar.
|
|
146
|
+
function restoreCheckpoint(id, opts = {}) {
|
|
147
|
+
const manifest = readManifest(id);
|
|
148
|
+
if (!manifest) return { ok: false, error: "Surum bulunamadi." };
|
|
149
|
+
const cwd = path.resolve(manifest.cwd);
|
|
150
|
+
if (!fs.existsSync(cwd)) return { ok: false, error: "Calisma klasoru bulunamadi." };
|
|
151
|
+
let redoId = null;
|
|
152
|
+
if (opts.createRedo !== false) {
|
|
153
|
+
const redo = createCheckpoint(cwd, { taskId: manifest.taskId, kind: "pre-restore", label: `Geri alma oncesi (${manifest.id})`, retention: opts.retention });
|
|
154
|
+
if (redo.ok) redoId = redo.id;
|
|
155
|
+
}
|
|
156
|
+
const filesDir = path.join(CP_ROOT, path.basename(String(id)), "files");
|
|
157
|
+
const keep = new Set(manifest.files);
|
|
158
|
+
// (1) Surumden sonra olusturulmus (surumde olmayan) dosyalari sil.
|
|
159
|
+
let deleted = 0;
|
|
160
|
+
for (const rel of fileList(cwd).files) {
|
|
161
|
+
if (keep.has(rel)) continue;
|
|
162
|
+
const target = within(cwd, rel);
|
|
163
|
+
if (!target) continue;
|
|
164
|
+
try { if (fs.existsSync(target)) { fs.rmSync(target, { force: true }); deleted++; } } catch {}
|
|
165
|
+
}
|
|
166
|
+
// (2) Surumdeki dosyalari birebir geri yaz.
|
|
167
|
+
let restored = 0;
|
|
168
|
+
for (const rel of manifest.files) {
|
|
169
|
+
const src = path.join(filesDir, rel);
|
|
170
|
+
const dest = within(cwd, rel);
|
|
171
|
+
if (!dest) continue;
|
|
172
|
+
try { if (!fs.existsSync(src)) continue; fs.mkdirSync(path.dirname(dest), { recursive: true }); fs.copyFileSync(src, dest); restored++; } catch {}
|
|
173
|
+
}
|
|
174
|
+
return { ok: true, id: manifest.id, cwd, restored, deleted, redoId };
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Listeleme: dosya listesini disari vermeden ozet meta doner (istege bagli cwd filtresi).
|
|
178
|
+
function listCheckpoints(cwd) {
|
|
179
|
+
try {
|
|
180
|
+
ensureRoot();
|
|
181
|
+
const all = fs.readdirSync(CP_ROOT).map(readManifest).filter(Boolean);
|
|
182
|
+
const filtered = cwd ? all.filter((m) => path.resolve(m.cwd) === path.resolve(cwd)) : all;
|
|
183
|
+
return filtered.sort((a, b) => (a.at < b.at ? 1 : -1)).map(({ files, ...rest }) => rest);
|
|
184
|
+
} catch { return []; }
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
module.exports = { CP_ROOT, createCheckpoint, restoreCheckpoint, listCheckpoints, readManifest, fileList, isGitRepo, _internals: { ignored, within, walkFileList } };
|