@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.
Files changed (95) hide show
  1. package/README.md +182 -0
  2. package/orchestrator/LICENSE +21 -0
  3. package/orchestrator/README.md +452 -0
  4. package/orchestrator/config.default.json +65 -0
  5. package/orchestrator/roles/executor.md +49 -0
  6. package/orchestrator/roles/operator-chat.md +25 -0
  7. package/orchestrator/roles/operator.md +75 -0
  8. package/orchestrator/roles/planner.md +53 -0
  9. package/orchestrator/roles/reviewer.md +54 -0
  10. package/orchestrator/skills/acceptance-criteria.md +18 -0
  11. package/orchestrator/skills/accessibility-audit.md +16 -0
  12. package/orchestrator/skills/accessible-forms.md +16 -0
  13. package/orchestrator/skills/api-design.md +27 -0
  14. package/orchestrator/skills/api-documentation.md +16 -0
  15. package/orchestrator/skills/architecture-decision-record.md +18 -0
  16. package/orchestrator/skills/authentication-design.md +16 -0
  17. package/orchestrator/skills/authorization-review.md +16 -0
  18. package/orchestrator/skills/backward-compatibility.md +17 -0
  19. package/orchestrator/skills/changelog-writing.md +16 -0
  20. package/orchestrator/skills/ci-pipeline-design.md +16 -0
  21. package/orchestrator/skills/cli-design.md +16 -0
  22. package/orchestrator/skills/code-review.md +27 -0
  23. package/orchestrator/skills/configuration-management.md +16 -0
  24. package/orchestrator/skills/container-review.md +16 -0
  25. package/orchestrator/skills/contract-testing.md +16 -0
  26. package/orchestrator/skills/dashboard-design.md +16 -0
  27. package/orchestrator/skills/database-migration.md +16 -0
  28. package/orchestrator/skills/database-schema-design.md +16 -0
  29. package/orchestrator/skills/debugging.md +26 -0
  30. package/orchestrator/skills/dependency-review.md +16 -0
  31. package/orchestrator/skills/design-review.md +29 -0
  32. package/orchestrator/skills/design-system.md +16 -0
  33. package/orchestrator/skills/docs-api-reference.md +16 -0
  34. package/orchestrator/skills/docs-troubleshooting.md +16 -0
  35. package/orchestrator/skills/docs-tutorial.md +16 -0
  36. package/orchestrator/skills/docs-writing.md +25 -0
  37. package/orchestrator/skills/empty-error-loading-states.md +16 -0
  38. package/orchestrator/skills/end-to-end-testing.md +16 -0
  39. package/orchestrator/skills/error-handling.md +16 -0
  40. package/orchestrator/skills/frontend-design.md +28 -0
  41. package/orchestrator/skills/git-commit-writing.md +16 -0
  42. package/orchestrator/skills/graphql-design.md +16 -0
  43. package/orchestrator/skills/incident-runbook.md +18 -0
  44. package/orchestrator/skills/input-validation.md +16 -0
  45. package/orchestrator/skills/integration-testing.md +16 -0
  46. package/orchestrator/skills/interaction-design.md +16 -0
  47. package/orchestrator/skills/landing-page-design.md +16 -0
  48. package/orchestrator/skills/observability-design.md +16 -0
  49. package/orchestrator/skills/openapi-contract.md +16 -0
  50. package/orchestrator/skills/performance-profiling.md +16 -0
  51. package/orchestrator/skills/privacy-review.md +16 -0
  52. package/orchestrator/skills/property-based-testing.md +16 -0
  53. package/orchestrator/skills/pull-request-writing.md +16 -0
  54. package/orchestrator/skills/refactoring.md +16 -0
  55. package/orchestrator/skills/release-readiness.md +16 -0
  56. package/orchestrator/skills/responsive-design.md +16 -0
  57. package/orchestrator/skills/secrets-management.md +16 -0
  58. package/orchestrator/skills/secure-file-upload.md +16 -0
  59. package/orchestrator/skills/security-review.md +26 -0
  60. package/orchestrator/skills/semantic-versioning.md +17 -0
  61. package/orchestrator/skills/seo-on-page.md +16 -0
  62. package/orchestrator/skills/seo-structured-data.md +16 -0
  63. package/orchestrator/skills/seo-technical-audit.md +16 -0
  64. package/orchestrator/skills/sql-query-review.md +16 -0
  65. package/orchestrator/skills/supply-chain-security.md +16 -0
  66. package/orchestrator/skills/test-strategy.md +16 -0
  67. package/orchestrator/skills/threat-modeling.md +16 -0
  68. package/orchestrator/skills/unit-testing.md +16 -0
  69. package/orchestrator/skills/write-tests.md +28 -0
  70. package/orchestrator/src/checkpoints.js +187 -0
  71. package/orchestrator/src/cli-registry.js +579 -0
  72. package/orchestrator/src/cli.js +135 -0
  73. package/orchestrator/src/doctor.js +64 -0
  74. package/orchestrator/src/engine.js +1364 -0
  75. package/orchestrator/src/schedule.js +126 -0
  76. package/orchestrator/src/server.js +706 -0
  77. package/orchestrator/src/skill-registry.js +272 -0
  78. package/orchestrator/src/store.js +364 -0
  79. package/orchestrator/web/OrbitControls.js +1417 -0
  80. package/orchestrator/web/app.css +116 -0
  81. package/orchestrator/web/app.js +70 -0
  82. package/orchestrator/web/board.html +141 -0
  83. package/orchestrator/web/code.html +208 -0
  84. package/orchestrator/web/flow.html +736 -0
  85. package/orchestrator/web/index.html +539 -0
  86. package/orchestrator/web/jsm/postprocessing/EffectComposer.js +231 -0
  87. package/orchestrator/web/jsm/postprocessing/MaskPass.js +104 -0
  88. package/orchestrator/web/jsm/postprocessing/Pass.js +95 -0
  89. package/orchestrator/web/jsm/postprocessing/RenderPass.js +99 -0
  90. package/orchestrator/web/jsm/postprocessing/ShaderPass.js +77 -0
  91. package/orchestrator/web/jsm/postprocessing/UnrealBloomPass.js +415 -0
  92. package/orchestrator/web/jsm/shaders/CopyShader.js +45 -0
  93. package/orchestrator/web/jsm/shaders/LuminosityHighPassShader.js +66 -0
  94. package/orchestrator/web/three.module.min.js +6 -0
  95. package/package.json +51 -0
@@ -0,0 +1,126 @@
1
+ // schedule.js — zamanlanmis gorevlerin saf (yan etkisiz) mantigi: dogrulama ve sonraki
2
+ // calisma zamani hesabi. Sifir bagimlilik. Yan etkiler (task uretimi, broadcast) server.js
3
+ // zamanlayici tik'indedir; bu modul yalnizca hesap yapar ve boylece kolayca test edilebilir.
4
+
5
+ const TRIGGER_TYPES = ["interval", "daily", "weekly"];
6
+ const VALID_MODES = new Set(["auto", "fast", "balanced", "deep"]);
7
+ // Makul ust sinir: 1 dakika .. 60 gun. Cok buyuk araliklar setInterval/Date tasmasi yaratmasin.
8
+ const MAX_INTERVAL_MINUTES = 60 * 24 * 60;
9
+
10
+ function isPlainObject(value) {
11
+ return value != null && typeof value === "object" && !Array.isArray(value);
12
+ }
13
+
14
+ // "HH:MM" -> {hours, minutes} veya null. 00:00 .. 23:59 araligi disi gecersizdir.
15
+ function parseTimeOfDay(value) {
16
+ if (typeof value !== "string") return null;
17
+ const match = value.trim().match(/^(\d{1,2}):(\d{2})$/);
18
+ if (!match) return null;
19
+ const hours = Number(match[1]);
20
+ const minutes = Number(match[2]);
21
+ if (!Number.isInteger(hours) || !Number.isInteger(minutes)) return null;
22
+ if (hours < 0 || hours > 23 || minutes < 0 || minutes > 59) return null;
23
+ return { hours, minutes };
24
+ }
25
+
26
+ function pad2(n) {
27
+ return String(n).padStart(2, "0");
28
+ }
29
+
30
+ // Ham girdiyi dogrulanmis bir tetik nesnesine cevir; gecersizse Error at.
31
+ function normalizeTrigger(raw) {
32
+ if (!isPlainObject(raw)) throw new Error("trigger nesnesi gerekli.");
33
+ const type = String(raw.type || "").toLowerCase();
34
+ if (!TRIGGER_TYPES.includes(type)) throw new Error(`trigger.type interval|daily|weekly olmali (verilen: ${type || "yok"}).`);
35
+ if (type === "interval") {
36
+ const everyMinutes = Number(raw.everyMinutes);
37
+ if (!Number.isInteger(everyMinutes) || everyMinutes < 1) throw new Error("trigger.everyMinutes en az 1 tamsayi olmali.");
38
+ if (everyMinutes > MAX_INTERVAL_MINUTES) throw new Error(`trigger.everyMinutes en fazla ${MAX_INTERVAL_MINUTES} olabilir.`);
39
+ return { type, everyMinutes };
40
+ }
41
+ const time = parseTimeOfDay(raw.at);
42
+ if (!time) throw new Error('trigger.at "HH:MM" (00:00–23:59) olmali.');
43
+ const at = `${pad2(time.hours)}:${pad2(time.minutes)}`;
44
+ if (type === "daily") return { type, at };
45
+ // weekly
46
+ const days = Array.isArray(raw.days) ? [...new Set(raw.days.map(Number))].filter((d) => Number.isInteger(d) && d >= 0 && d <= 6).sort((a, b) => a - b) : [];
47
+ if (!days.length) throw new Error("trigger.days en az bir gun (0=Pazar .. 6=Cumartesi) icermeli.");
48
+ return { type, at, days };
49
+ }
50
+
51
+ // Ham zamanlama girdisini dogrulanmis nesneye cevir; gecersizse Error at. Saf: girdiyi
52
+ // degistirmez, yeni nesne dondurur. id/createdAt korunur (verilmisse), yoksa cagiran atar.
53
+ function normalizeSchedule(raw) {
54
+ if (!isPlainObject(raw)) throw new Error("Zamanlama nesnesi gerekli.");
55
+ const prompt = typeof raw.prompt === "string" ? raw.prompt.trim() : "";
56
+ if (!prompt) throw new Error("prompt gerekli.");
57
+ const trigger = normalizeTrigger(raw.trigger);
58
+ const executionMode = VALID_MODES.has(raw.executionMode) ? raw.executionMode : "auto";
59
+ const schedule = {
60
+ id: raw.id ? String(raw.id) : "",
61
+ prompt,
62
+ executionMode,
63
+ trigger,
64
+ enabled: raw.enabled !== false,
65
+ createdAt: raw.createdAt || new Date().toISOString(),
66
+ };
67
+ if (raw.targetDir && String(raw.targetDir).trim()) schedule.targetDir = String(raw.targetDir).trim();
68
+ if (raw.operatorCli && String(raw.operatorCli).trim()) schedule.operatorCli = String(raw.operatorCli).trim();
69
+ if (raw.lastRunAt) schedule.lastRunAt = raw.lastRunAt;
70
+ if (raw.lastTaskId) schedule.lastTaskId = raw.lastTaskId;
71
+ return schedule;
72
+ }
73
+
74
+ // Bir zamanlamanin `from`'dan SONRAKI ilk calisma zamanini hesapla. Donen deger her zaman
75
+ // from'dan kesinlikle ileridedir (esitlik degil), boylece ayni tik iki kez tetiklemez.
76
+ function computeNextRun(schedule, from = new Date()) {
77
+ const trigger = schedule && schedule.trigger;
78
+ if (!trigger || !TRIGGER_TYPES.includes(trigger.type)) return null;
79
+ const base = from instanceof Date ? from : new Date(from);
80
+ if (Number.isNaN(base.getTime())) return null;
81
+
82
+ if (trigger.type === "interval") {
83
+ if (!Number.isInteger(trigger.everyMinutes) || trigger.everyMinutes < 1) return null;
84
+ return new Date(base.getTime() + trigger.everyMinutes * 60000);
85
+ }
86
+
87
+ const time = parseTimeOfDay(trigger.at);
88
+ if (!time) return null;
89
+
90
+ if (trigger.type === "daily") {
91
+ const next = new Date(base);
92
+ next.setHours(time.hours, time.minutes, 0, 0);
93
+ if (next.getTime() <= base.getTime()) next.setDate(next.getDate() + 1);
94
+ return next;
95
+ }
96
+
97
+ if (trigger.type === "weekly") {
98
+ const days = Array.isArray(trigger.days) ? trigger.days : [];
99
+ if (!days.length) return null;
100
+ // Bugun dahil sonraki 7 gunu tara; ilk uygun gun+saat kombinasyonunu dondur.
101
+ for (let offset = 0; offset <= 7; offset++) {
102
+ const candidate = new Date(base);
103
+ candidate.setDate(candidate.getDate() + offset);
104
+ candidate.setHours(time.hours, time.minutes, 0, 0);
105
+ if (days.includes(candidate.getDay()) && candidate.getTime() > base.getTime()) return candidate;
106
+ }
107
+ return null;
108
+ }
109
+
110
+ return null;
111
+ }
112
+
113
+ // enabled ve zamani gelmis (nextRunAt <= now) zamanlamalari dondur. nextRunAt yoksa
114
+ // (ör. yeni tanimlanmis ama hesaplanmamis) zamani gelmemis sayilir; server tik'i yaratirken
115
+ // nextRunAt'i doldurur.
116
+ function dueSchedules(schedules, now = new Date()) {
117
+ const at = now instanceof Date ? now.getTime() : new Date(now).getTime();
118
+ if (!Array.isArray(schedules)) return [];
119
+ return schedules.filter((s) => {
120
+ if (!s || s.enabled === false) return false;
121
+ const next = s.nextRunAt ? Date.parse(s.nextRunAt) : NaN;
122
+ return Number.isFinite(next) && next <= at;
123
+ });
124
+ }
125
+
126
+ module.exports = { normalizeSchedule, normalizeTrigger, computeNextRun, dueSchedules, parseTimeOfDay, TRIGGER_TYPES, MAX_INTERVAL_MINUTES };