natureco-cli 5.19.0 → 5.20.1

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 (196) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/package.json +1 -1
  3. package/skills/a-b-testing/SKILL.md +34 -0
  4. package/skills/accessibility-audit/SKILL.md +34 -0
  5. package/skills/agent-memory/SKILL.md +34 -0
  6. package/skills/agent-orchestration/SKILL.md +34 -0
  7. package/skills/analytics-setup/SKILL.md +34 -0
  8. package/skills/api-design/SKILL.md +34 -0
  9. package/skills/api-versioning/SKILL.md +34 -0
  10. package/skills/audio-transcription/SKILL.md +34 -0
  11. package/skills/authentication-patterns/SKILL.md +34 -0
  12. package/skills/authorization-rbac/SKILL.md +34 -0
  13. package/skills/backup-strategy/SKILL.md +34 -0
  14. package/skills/bash-scripting/SKILL.md +34 -0
  15. package/skills/batch-api-calls/SKILL.md +34 -0
  16. package/skills/batch-processing/SKILL.md +34 -0
  17. package/skills/bulk-file-operations/SKILL.md +34 -0
  18. package/skills/cache-responses/SKILL.md +34 -0
  19. package/skills/caching-strategy/SKILL.md +34 -0
  20. package/skills/calendar-optimization/SKILL.md +34 -0
  21. package/skills/changelog-generation/SKILL.md +34 -0
  22. package/skills/chat-bot-design/SKILL.md +34 -0
  23. package/skills/chunking-strategy/SKILL.md +34 -0
  24. package/skills/ci-cd-pipeline/SKILL.md +34 -0
  25. package/skills/classification-pipeline/SKILL.md +34 -0
  26. package/skills/clipboard-master/SKILL.md +34 -0
  27. package/skills/code-explanation/SKILL.md +34 -0
  28. package/skills/code-generation/SKILL.md +34 -0
  29. package/skills/code-migration/SKILL.md +34 -0
  30. package/skills/code-review-checklist/SKILL.md +34 -0
  31. package/skills/contact-management/SKILL.md +34 -0
  32. package/skills/content-generation/SKILL.md +34 -0
  33. package/skills/context-pruning/SKILL.md +34 -0
  34. package/skills/context-window-management/SKILL.md +34 -0
  35. package/skills/continuous-improvement/SKILL.md +34 -0
  36. package/skills/cron-scheduling/SKILL.md +34 -0
  37. package/skills/cross-platform-compat/SKILL.md +34 -0
  38. package/skills/csv-processing/SKILL.md +34 -0
  39. package/skills/daily-journal/SKILL.md +34 -0
  40. package/skills/data-analysis/SKILL.md +34 -0
  41. package/skills/data-backup/SKILL.md +34 -0
  42. package/skills/data-cleaning/SKILL.md +34 -0
  43. package/skills/data-extraction/SKILL.md +34 -0
  44. package/skills/data-validation/SKILL.md +34 -0
  45. package/skills/database-migrations/SKILL.md +34 -0
  46. package/skills/database-schema-design/SKILL.md +34 -0
  47. package/skills/decision-matrix/SKILL.md +34 -0
  48. package/skills/dependency-management/SKILL.md +34 -0
  49. package/skills/dev-environment-setup/SKILL.md +34 -0
  50. package/skills/distraction-blocker/SKILL.md +34 -0
  51. package/skills/docker-optimization/SKILL.md +34 -0
  52. package/skills/document-template/SKILL.md +34 -0
  53. package/skills/documentation-gen/SKILL.md +34 -0
  54. package/skills/efficient-formatting/SKILL.md +34 -0
  55. package/skills/email-management/SKILL.md +34 -0
  56. package/skills/email-service/SKILL.md +34 -0
  57. package/skills/embedding-generation/SKILL.md +34 -0
  58. package/skills/entity-extraction/SKILL.md +34 -0
  59. package/skills/environment-config/SKILL.md +34 -0
  60. package/skills/error-handling/SKILL.md +34 -0
  61. package/skills/estimation-techniques/SKILL.md +34 -0
  62. package/skills/event-driven-architecture/SKILL.md +34 -0
  63. package/skills/excel-automation/SKILL.md +34 -0
  64. package/skills/execution-monitoring/SKILL.md +34 -0
  65. package/skills/expense-tracking/SKILL.md +34 -0
  66. package/skills/feature-engineering/SKILL.md +34 -0
  67. package/skills/feature-flags/SKILL.md +34 -0
  68. package/skills/file-conversion/SKILL.md +34 -0
  69. package/skills/file-upload-handling/SKILL.md +34 -0
  70. package/skills/fine-tuning-prep/SKILL.md +34 -0
  71. package/skills/focus-mode/SKILL.md +34 -0
  72. package/skills/form-validation/SKILL.md +34 -0
  73. package/skills/function-calling/SKILL.md +34 -0
  74. package/skills/git-workflow/SKILL.md +34 -0
  75. package/skills/goal-setting/SKILL.md +34 -0
  76. package/skills/graphql-design/SKILL.md +34 -0
  77. package/skills/habit-tracker/SKILL.md +34 -0
  78. package/skills/hallucination-detection/SKILL.md +34 -0
  79. package/skills/image-processing/SKILL.md +34 -0
  80. package/skills/json-transformation/SKILL.md +34 -0
  81. package/skills/keyboard-shortcuts/SKILL.md +34 -0
  82. package/skills/knowledge-base/SKILL.md +34 -0
  83. package/skills/knowledge-graph/SKILL.md +34 -0
  84. package/skills/kubernetes-deployment/SKILL.md +34 -0
  85. package/skills/language-translation/SKILL.md +34 -0
  86. package/skills/llm-chaining/SKILL.md +34 -0
  87. package/skills/localization-i18n/SKILL.md +34 -0
  88. package/skills/logging-best-practices/SKILL.md +34 -0
  89. package/skills/machine-learning-pipeline/SKILL.md +34 -0
  90. package/skills/meeting-notes/SKILL.md +34 -0
  91. package/skills/meeting-scheduler/SKILL.md +34 -0
  92. package/skills/message-queues/SKILL.md +34 -0
  93. package/skills/message-summarization/SKILL.md +34 -0
  94. package/skills/microservices-architecture/SKILL.md +34 -0
  95. package/skills/milestone-tracking/SKILL.md +34 -0
  96. package/skills/model-deployment/SKILL.md +34 -0
  97. package/skills/model-evaluation/SKILL.md +34 -0
  98. package/skills/monitoring-setup/SKILL.md +34 -0
  99. package/skills/monorepo-setup/SKILL.md +34 -0
  100. package/skills/multi-agent-systems/SKILL.md +34 -0
  101. package/skills/network-troubleshooting/SKILL.md +34 -0
  102. package/skills/note-organization/SKILL.md +34 -0
  103. package/skills/package-publishing/SKILL.md +34 -0
  104. package/skills/password-generator/SKILL.md +34 -0
  105. package/skills/pdf-processing/SKILL.md +34 -0
  106. package/skills/performance-optimization/SKILL.md +34 -0
  107. package/skills/pomodoro-timer/SKILL.md +34 -0
  108. package/skills/powershell-automation/SKILL.md +34 -0
  109. package/skills/priority-filtering/SKILL.md +34 -0
  110. package/skills/project-tracking/SKILL.md +34 -0
  111. package/skills/prompt-compression/SKILL.md +34 -0
  112. package/skills/prompt-engineering/SKILL.md +34 -0
  113. package/skills/push-notifications/SKILL.md +34 -0
  114. package/skills/rag-implementation/SKILL.md +34 -0
  115. package/skills/rate-limiting/SKILL.md +34 -0
  116. package/skills/real-time-communication/SKILL.md +34 -0
  117. package/skills/refactoring-strategy/SKILL.md +34 -0
  118. package/skills/regex-mastery/SKILL.md +34 -0
  119. package/skills/report-generation/SKILL.md +34 -0
  120. package/skills/research-compiler/SKILL.md +34 -0
  121. package/skills/responsive-design/SKILL.md +34 -0
  122. package/skills/rest-api-patterns/SKILL.md +34 -0
  123. package/skills/retrospectives/SKILL.md +34 -0
  124. package/skills/risk-assessment/SKILL.md +34 -0
  125. package/skills/roadmap-creation/SKILL.md +34 -0
  126. package/skills/search-implementation/SKILL.md +34 -0
  127. package/skills/secrets-management/SKILL.md +34 -0
  128. package/skills/security-audit/SKILL.md +34 -0
  129. package/skills/selective-memory/SKILL.md +34 -0
  130. package/skills/semantic-search/SKILL.md +34 -0
  131. package/skills/semantic-versioning/SKILL.md +34 -0
  132. package/skills/sentiment-analysis/SKILL.md +34 -0
  133. package/skills/seo-optimization/SKILL.md +34 -0
  134. package/skills/snippet-manager/SKILL.md +34 -0
  135. package/skills/sprint-planning/SKILL.md +34 -0
  136. package/skills/sql-query-optimization/SKILL.md +34 -0
  137. package/skills/stakeholder-communication/SKILL.md +34 -0
  138. package/skills/state-management/SKILL.md +34 -0
  139. package/skills/statistical-analysis/SKILL.md +34 -0
  140. package/skills/streaming-responses/SKILL.md +34 -0
  141. package/skills/structured-output/SKILL.md +34 -0
  142. package/skills/summarization-techniques/SKILL.md +34 -0
  143. package/skills/system-diagnostics/SKILL.md +34 -0
  144. package/skills/task-decomposition/SKILL.md +34 -0
  145. package/skills/task-prioritization/SKILL.md +34 -0
  146. package/skills/template-library/SKILL.md +34 -0
  147. package/skills/test-generation/SKILL.md +34 -0
  148. package/skills/testing-strategy/SKILL.md +34 -0
  149. package/skills/text-expansion/SKILL.md +34 -0
  150. package/skills/time-blocking/SKILL.md +34 -0
  151. package/skills/token-budgeting/SKILL.md +34 -0
  152. package/skills/token-optimization/SKILL.md +34 -0
  153. package/skills/tool-calling-patterns/SKILL.md +34 -0
  154. package/skills/vector-database-setup/SKILL.md +34 -0
  155. package/skills/video-editing/SKILL.md +34 -0
  156. package/skills/visualization-creation/SKILL.md +34 -0
  157. package/skills/web-scraping/SKILL.md +34 -0
  158. package/skills/webhook-handling/SKILL.md +34 -0
  159. package/skills/weekly-review/SKILL.md +34 -0
  160. package/skills/workflow-automation/SKILL.md +34 -0
  161. package/src/commands/code_v5.js +377 -73
  162. package/src/commands/help.js +3 -1
  163. package/src/commands/naturehub.js +105 -55
  164. package/src/commands/repl.js +506 -87
  165. package/src/providers/model/anthropic.js +84 -0
  166. package/src/providers/model/gemini.js +49 -0
  167. package/src/providers/model/minimax.js +48 -0
  168. package/src/providers/model/ollama.js +42 -0
  169. package/src/providers/model/openai.js +49 -0
  170. package/src/providers/search/duckduckgo.js +45 -0
  171. package/src/providers/search/exa.js +52 -0
  172. package/src/providers/search/searxng.js +51 -0
  173. package/src/providers/search/tavily.js +47 -0
  174. package/src/tools/model_provider.js +71 -0
  175. package/src/tools/parallel_search.js +40 -49
  176. package/src/tools/search_provider.js +79 -0
  177. package/src/tools/web_search.js +42 -62
  178. package/src/tools/workflow.js +27 -10
  179. package/src/utils/cron.js +82 -126
  180. package/src/utils/effort-levels.js +42 -0
  181. package/src/utils/fallback-chain.js +72 -0
  182. package/src/utils/file-history.js +78 -0
  183. package/src/utils/model-provider.js +113 -0
  184. package/src/utils/permissions.js +147 -0
  185. package/src/utils/plan-mode.js +164 -0
  186. package/src/utils/provider-detect.js +7 -32
  187. package/src/utils/sandbox.js +60 -0
  188. package/src/utils/search-provider.js +62 -0
  189. package/src/utils/session-search.js +66 -0
  190. package/src/utils/structured-output.js +20 -0
  191. package/src/utils/system-prompt.js +28 -2
  192. package/src/utils/tasks.js +132 -0
  193. package/src/utils/tool-hooks.js +154 -0
  194. package/src/utils/tools.js +16 -0
  195. package/src/utils/ultra-review.js +59 -0
  196. package/src/utils/worktree.js +192 -0
@@ -0,0 +1,192 @@
1
+ /**
2
+ * worktree — Isolated development worktrees (Claude Code EnterWorktree/ExitWorktree)
3
+ *
4
+ * Creates temporary git worktrees for experimental changes without
5
+ * affecting the main working directory.
6
+ *
7
+ * Tools:
8
+ * EnterWorktree — create a temp branch + worktree at .natureco/worktrees/<id>
9
+ * ExitWorktree — merge/collapse worktree changes back
10
+ *
11
+ * Falls back to a copytree (non-git) strategy when not in a git repo.
12
+ */
13
+
14
+ const fs = require('fs');
15
+ const path = require('path');
16
+ const os = require('os');
17
+ const { execSync } = require('child_process');
18
+
19
+ const WORKTREE_DIR = path.join(process.cwd(), '.natureco', 'worktrees');
20
+
21
+ class Worktree {
22
+ constructor() {
23
+ this.active = null; // { id, branch, dir, strategy }
24
+ this.history = [];
25
+ this._mockGitRepo = null; // For testing override
26
+ }
27
+
28
+ get isGitRepo() {
29
+ if (this._mockGitRepo !== null) return this._mockGitRepo;
30
+ try {
31
+ execSync('git rev-parse --git-dir', { cwd: process.cwd(), stdio: 'pipe' });
32
+ return true;
33
+ } catch {
34
+ return false;
35
+ }
36
+ }
37
+
38
+ get currentBranch() {
39
+ try {
40
+ return execSync('git rev-parse --abbrev-ref HEAD', { cwd: process.cwd(), stdio: 'pipe' }).toString().trim();
41
+ } catch {
42
+ return 'main';
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Enter worktree — create isolated copy for experimentation.
48
+ */
49
+ enter(opts = {}) {
50
+ if (this.active) return { error: `Zaten worktree aktif: ${this.active.id}` };
51
+
52
+ const id = opts.id || `wt-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
53
+ const branch = opts.branch || `wt/${id}`;
54
+ const targetDir = path.join(WORKTREE_DIR, id);
55
+
56
+ fs.mkdirSync(targetDir, { recursive: true });
57
+
58
+ if (this.isGitRepo) {
59
+ try {
60
+ // Create orphan branch + worktree
61
+ execSync(`git branch -f "${branch}" HEAD`, { cwd: process.cwd(), stdio: 'pipe' });
62
+ execSync(`git worktree add --detach "${targetDir}" "${branch}"`, { cwd: process.cwd(), stdio: 'pipe' });
63
+ this.active = { id, branch, dir: targetDir, strategy: 'git-worktree' };
64
+ } catch (e) {
65
+ // Fallback: simple copy
66
+ this._copyTree(process.cwd(), targetDir);
67
+ this.active = { id, branch: null, dir: targetDir, strategy: 'copytree' };
68
+ }
69
+ } else {
70
+ this._copyTree(process.cwd(), targetDir);
71
+ this.active = { id, branch: null, dir: targetDir, strategy: 'copytree' };
72
+ }
73
+
74
+ this.history.push({ action: 'enter', id, at: Date.now() });
75
+ return {
76
+ result: `Worktree oluşturuldu: ${id}\nDizin: ${targetDir}\nStrateji: ${this.active.strategy}${this.active.branch ? `\nBranch: ${this.active.branch}` : ''}`,
77
+ worktreeId: id,
78
+ worktreeDir: targetDir,
79
+ };
80
+ }
81
+
82
+ /**
83
+ * Exit worktree — merge changes back and clean up.
84
+ */
85
+ exit(opts = {}) {
86
+ if (!this.active) return { error: 'Aktif worktree yok.' };
87
+
88
+ const merge = opts.merge !== false;
89
+ const result = { merged: false, changes: [] };
90
+
91
+ if (merge && this.active.strategy === 'git-worktree') {
92
+ try {
93
+ // Diff the worktree against current HEAD
94
+ const diff = execSync(`git diff HEAD --name-status`, { cwd: this.active.dir, stdio: 'pipe' }).toString().trim();
95
+ if (diff) {
96
+ result.changes = diff.split('\n').filter(Boolean);
97
+ // Cherry-pick changes if any commits were made
98
+ const log = execSync(`git log --oneline HEAD --not --all`, { cwd: this.active.dir, stdio: 'pipe' }).toString().trim();
99
+ if (log) {
100
+ execSync(`git fetch . "${this.active.branch}"`, { cwd: process.cwd(), stdio: 'pipe' });
101
+ result.merged = true;
102
+ }
103
+ }
104
+ } catch (e) {
105
+ result.mergeError = e.message;
106
+ }
107
+ }
108
+
109
+ // Cleanup
110
+ this._cleanup();
111
+ this.history.push({ action: 'exit', id: this.active.id, merged: result.merged, at: Date.now() });
112
+ this.active = null;
113
+
114
+ return {
115
+ result: `Worktree kapatıldı.${result.merged ? ' Değişiklikler merge edildi.' : ' Değişiklikler atıldı.'}` +
116
+ (result.changes.length ? `\nDeğişiklikler:\n${result.changes.join('\n')}` : ''),
117
+ ...result,
118
+ };
119
+ }
120
+
121
+ /**
122
+ * Get current worktree info.
123
+ */
124
+ status() {
125
+ if (!this.active) return { active: false };
126
+ return {
127
+ active: true,
128
+ id: this.active.id,
129
+ dir: this.active.dir,
130
+ branch: this.active.branch,
131
+ strategy: this.active.strategy,
132
+ };
133
+ }
134
+
135
+ /**
136
+ * Validate if a tool call is operating within the worktree.
137
+ * If active, redirect file paths from cwd to worktree dir.
138
+ */
139
+ resolvePath(filePath) {
140
+ if (!this.active || !filePath) return filePath;
141
+ const abs = path.resolve(filePath);
142
+ const cwd = process.cwd();
143
+ if (abs.startsWith(cwd)) {
144
+ const rel = path.relative(cwd, abs);
145
+ return path.join(this.active.dir, rel);
146
+ }
147
+ return filePath;
148
+ }
149
+
150
+ /**
151
+ * Copy entire directory tree (fallback for non-git repos).
152
+ */
153
+ _copyTree(src, dest) {
154
+ const skipDirs = new Set(['node_modules', '.git', '.natureco']);
155
+ const entries = fs.readdirSync(src, { withFileTypes: true });
156
+ for (const entry of entries) {
157
+ if (entry.name.startsWith('.') || skipDirs.has(entry.name)) continue;
158
+ const s = path.join(src, entry.name);
159
+ const d = path.join(dest, entry.name);
160
+ if (entry.isDirectory()) {
161
+ fs.mkdirSync(d, { recursive: true });
162
+ this._copyTree(s, d);
163
+ } else if (entry.isFile()) {
164
+ try { fs.copyFileSync(s, d); } catch {}
165
+ }
166
+ }
167
+ }
168
+
169
+ /**
170
+ * Clean up worktree files.
171
+ */
172
+ _cleanup() {
173
+ if (!this.active) return;
174
+ try {
175
+ if (this.active.strategy === 'git-worktree') {
176
+ execSync(`git worktree remove --force "${this.active.dir}"`, { stdio: 'pipe' });
177
+ execSync(`git branch -D "${this.active.branch}" 2>/dev/null`, { stdio: 'pipe' });
178
+ }
179
+ if (fs.existsSync(this.active.dir)) {
180
+ fs.rmSync(this.active.dir, { recursive: true, force: true });
181
+ }
182
+ } catch {}
183
+ }
184
+ }
185
+
186
+ let _instance = null;
187
+ function getWorktree() {
188
+ if (!_instance) _instance = new Worktree();
189
+ return _instance;
190
+ }
191
+
192
+ module.exports = { Worktree, getWorktree };