@stan-chen/simple-cli 0.2.3 → 0.2.4

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 (136) hide show
  1. package/README.md +62 -63
  2. package/dist/anyllm.py +62 -0
  3. package/dist/builtins.d.ts +726 -0
  4. package/dist/builtins.js +481 -0
  5. package/dist/cli.d.ts +0 -4
  6. package/dist/cli.js +34 -493
  7. package/dist/engine.d.ts +33 -0
  8. package/dist/engine.js +138 -0
  9. package/dist/learnings.d.ts +15 -0
  10. package/dist/learnings.js +54 -0
  11. package/dist/llm.d.ts +18 -0
  12. package/dist/llm.js +66 -0
  13. package/dist/mcp.d.ts +132 -0
  14. package/dist/mcp.js +43 -0
  15. package/dist/skills.d.ts +5 -16
  16. package/dist/skills.js +91 -253
  17. package/dist/tui.d.ts +1 -0
  18. package/dist/tui.js +10 -0
  19. package/package.json +10 -6
  20. package/dist/claw/jit.d.ts +0 -5
  21. package/dist/claw/jit.js +0 -138
  22. package/dist/claw/management.d.ts +0 -3
  23. package/dist/claw/management.js +0 -107
  24. package/dist/commands/add.d.ts +0 -9
  25. package/dist/commands/add.js +0 -50
  26. package/dist/commands/git/commit.d.ts +0 -12
  27. package/dist/commands/git/commit.js +0 -98
  28. package/dist/commands/git/status.d.ts +0 -6
  29. package/dist/commands/git/status.js +0 -42
  30. package/dist/commands/index.d.ts +0 -16
  31. package/dist/commands/index.js +0 -377
  32. package/dist/commands/mcp/status.d.ts +0 -6
  33. package/dist/commands/mcp/status.js +0 -31
  34. package/dist/commands/swarm.d.ts +0 -36
  35. package/dist/commands/swarm.js +0 -236
  36. package/dist/commands.d.ts +0 -32
  37. package/dist/commands.js +0 -427
  38. package/dist/context.d.ts +0 -116
  39. package/dist/context.js +0 -337
  40. package/dist/index.d.ts +0 -6
  41. package/dist/index.js +0 -109
  42. package/dist/lib/agent.d.ts +0 -99
  43. package/dist/lib/agent.js +0 -313
  44. package/dist/lib/editor.d.ts +0 -74
  45. package/dist/lib/editor.js +0 -441
  46. package/dist/lib/git.d.ts +0 -164
  47. package/dist/lib/git.js +0 -356
  48. package/dist/lib/shim.d.ts +0 -4
  49. package/dist/lib/shim.js +0 -30
  50. package/dist/lib/ui.d.ts +0 -159
  51. package/dist/lib/ui.js +0 -277
  52. package/dist/mcp/client.d.ts +0 -22
  53. package/dist/mcp/client.js +0 -81
  54. package/dist/mcp/manager.d.ts +0 -186
  55. package/dist/mcp/manager.js +0 -446
  56. package/dist/prompts/provider.d.ts +0 -22
  57. package/dist/prompts/provider.js +0 -79
  58. package/dist/providers/index.d.ts +0 -31
  59. package/dist/providers/index.js +0 -93
  60. package/dist/providers/multi.d.ts +0 -12
  61. package/dist/providers/multi.js +0 -28
  62. package/dist/registry.d.ts +0 -29
  63. package/dist/registry.js +0 -443
  64. package/dist/repoMap.d.ts +0 -5
  65. package/dist/repoMap.js +0 -79
  66. package/dist/router.d.ts +0 -41
  67. package/dist/router.js +0 -118
  68. package/dist/swarm/coordinator.d.ts +0 -86
  69. package/dist/swarm/coordinator.js +0 -257
  70. package/dist/swarm/index.d.ts +0 -28
  71. package/dist/swarm/index.js +0 -29
  72. package/dist/swarm/task.d.ts +0 -104
  73. package/dist/swarm/task.js +0 -221
  74. package/dist/swarm/types.d.ts +0 -132
  75. package/dist/swarm/types.js +0 -37
  76. package/dist/swarm/worker.d.ts +0 -109
  77. package/dist/swarm/worker.js +0 -369
  78. package/dist/tools/analyzeFile.d.ts +0 -16
  79. package/dist/tools/analyzeFile.js +0 -43
  80. package/dist/tools/analyze_file.d.ts +0 -16
  81. package/dist/tools/analyze_file.js +0 -43
  82. package/dist/tools/clawBrain.d.ts +0 -23
  83. package/dist/tools/clawBrain.js +0 -136
  84. package/dist/tools/claw_brain.d.ts +0 -23
  85. package/dist/tools/claw_brain.js +0 -139
  86. package/dist/tools/deleteFile.d.ts +0 -19
  87. package/dist/tools/deleteFile.js +0 -36
  88. package/dist/tools/delete_file.d.ts +0 -19
  89. package/dist/tools/delete_file.js +0 -36
  90. package/dist/tools/fileOps.d.ts +0 -22
  91. package/dist/tools/fileOps.js +0 -43
  92. package/dist/tools/file_ops.d.ts +0 -22
  93. package/dist/tools/file_ops.js +0 -43
  94. package/dist/tools/git.d.ts +0 -40
  95. package/dist/tools/git.js +0 -236
  96. package/dist/tools/glob.d.ts +0 -34
  97. package/dist/tools/glob.js +0 -165
  98. package/dist/tools/grep.d.ts +0 -53
  99. package/dist/tools/grep.js +0 -296
  100. package/dist/tools/linter.d.ts +0 -35
  101. package/dist/tools/linter.js +0 -407
  102. package/dist/tools/listDir.d.ts +0 -29
  103. package/dist/tools/listDir.js +0 -50
  104. package/dist/tools/list_dir.d.ts +0 -29
  105. package/dist/tools/list_dir.js +0 -50
  106. package/dist/tools/memory.d.ts +0 -34
  107. package/dist/tools/memory.js +0 -215
  108. package/dist/tools/organizer.d.ts +0 -1
  109. package/dist/tools/organizer.js +0 -65
  110. package/dist/tools/readFiles.d.ts +0 -25
  111. package/dist/tools/readFiles.js +0 -31
  112. package/dist/tools/read_files.d.ts +0 -25
  113. package/dist/tools/read_files.js +0 -31
  114. package/dist/tools/reloadTools.d.ts +0 -11
  115. package/dist/tools/reloadTools.js +0 -22
  116. package/dist/tools/reload_tools.d.ts +0 -11
  117. package/dist/tools/reload_tools.js +0 -22
  118. package/dist/tools/runCommand.d.ts +0 -32
  119. package/dist/tools/runCommand.js +0 -79
  120. package/dist/tools/run_command.d.ts +0 -32
  121. package/dist/tools/run_command.js +0 -103
  122. package/dist/tools/scheduler.d.ts +0 -25
  123. package/dist/tools/scheduler.js +0 -65
  124. package/dist/tools/scraper.d.ts +0 -31
  125. package/dist/tools/scraper.js +0 -211
  126. package/dist/tools/writeFiles.d.ts +0 -63
  127. package/dist/tools/writeFiles.js +0 -87
  128. package/dist/tools/write_files.d.ts +0 -84
  129. package/dist/tools/write_files.js +0 -91
  130. package/dist/tools/write_to_file.d.ts +0 -15
  131. package/dist/tools/write_to_file.js +0 -21
  132. package/dist/ui/server.d.ts +0 -5
  133. package/dist/ui/server.js +0 -74
  134. package/dist/watcher.d.ts +0 -35
  135. package/dist/watcher.js +0 -164
  136. /package/{docs/assets → assets}/logo.jpeg +0 -0
@@ -1,221 +0,0 @@
1
- /**
2
- * Task Queue - Priority-based task queue with dependency tracking
3
- */
4
- import { swarmTaskSchema } from './types.js';
5
- export class TaskQueue {
6
- tasks = new Map();
7
- pending = new Set();
8
- running = new Set();
9
- completed = new Set();
10
- failed = new Set();
11
- results = new Map();
12
- failures = new Map();
13
- attempts = new Map();
14
- /**
15
- * Add a task to the queue
16
- */
17
- addTask(task) {
18
- const validated = swarmTaskSchema.parse(task);
19
- this.tasks.set(validated.id, validated);
20
- this.pending.add(validated.id);
21
- this.attempts.set(validated.id, 0);
22
- }
23
- /**
24
- * Add multiple tasks
25
- */
26
- addTasks(tasks) {
27
- for (const task of tasks) {
28
- this.addTask(task);
29
- }
30
- }
31
- /**
32
- * Get next available task (respects dependencies and priorities)
33
- */
34
- getNextTask() {
35
- const available = this.getAvailableTasks();
36
- if (available.length === 0)
37
- return null;
38
- // Sort by priority (1 = highest)
39
- available.sort((a, b) => a.priority - b.priority);
40
- const task = available[0];
41
- this.pending.delete(task.id);
42
- this.running.add(task.id);
43
- return task;
44
- }
45
- /**
46
- * Get all tasks that are ready to run
47
- */
48
- getAvailableTasks() {
49
- const available = [];
50
- for (const taskId of this.pending) {
51
- const task = this.tasks.get(taskId);
52
- if (this.areDependenciesMet(task)) {
53
- available.push(task);
54
- }
55
- }
56
- return available;
57
- }
58
- /**
59
- * Check if a task's dependencies are all completed
60
- */
61
- areDependenciesMet(task) {
62
- if (!task.dependencies || task.dependencies.length === 0) {
63
- return true;
64
- }
65
- return task.dependencies.every(depId => this.completed.has(depId));
66
- }
67
- /**
68
- * Mark a task as completed
69
- */
70
- completeTask(taskId, result) {
71
- this.running.delete(taskId);
72
- this.completed.add(taskId);
73
- this.results.set(taskId, result);
74
- }
75
- /**
76
- * Mark a task as failed (may retry)
77
- */
78
- failTask(taskId, error, maxRetries) {
79
- const attempts = (this.attempts.get(taskId) || 0) + 1;
80
- this.attempts.set(taskId, attempts);
81
- if (attempts < maxRetries) {
82
- // Retry: move back to pending
83
- this.running.delete(taskId);
84
- this.pending.add(taskId);
85
- return true; // Will retry
86
- }
87
- // Max retries exceeded
88
- this.running.delete(taskId);
89
- this.failed.add(taskId);
90
- const task = this.tasks.get(taskId);
91
- this.failures.set(taskId, {
92
- task,
93
- error,
94
- attempts,
95
- });
96
- return false; // No more retries
97
- }
98
- /**
99
- * Get number of attempts for a task
100
- */
101
- getAttempts(taskId) {
102
- return this.attempts.get(taskId) || 0;
103
- }
104
- /**
105
- * Peek at next task without removing it
106
- */
107
- peekNextTask() {
108
- const available = this.getAvailableTasks();
109
- if (available.length === 0)
110
- return null;
111
- available.sort((a, b) => a.priority - b.priority);
112
- return available[0];
113
- }
114
- /**
115
- * Check if all tasks are done (completed or failed)
116
- */
117
- isDone() {
118
- return this.pending.size === 0 && this.running.size === 0;
119
- }
120
- /**
121
- * Check if there's any work to do
122
- */
123
- hasWork() {
124
- return this.pending.size > 0 || this.running.size > 0;
125
- }
126
- /**
127
- * Check if any tasks are currently running
128
- */
129
- hasRunning() {
130
- return this.running.size > 0;
131
- }
132
- /**
133
- * Get queue statistics
134
- */
135
- getStats() {
136
- return {
137
- total: this.tasks.size,
138
- pending: this.pending.size,
139
- running: this.running.size,
140
- completed: this.completed.size,
141
- failed: this.failed.size,
142
- };
143
- }
144
- /**
145
- * Get all results
146
- */
147
- getResults() {
148
- return Array.from(this.results.values());
149
- }
150
- /**
151
- * Get all failures
152
- */
153
- getFailures() {
154
- return Array.from(this.failures.values());
155
- }
156
- /**
157
- * Get a specific task
158
- */
159
- getTask(taskId) {
160
- return this.tasks.get(taskId);
161
- }
162
- /**
163
- * Get all tasks
164
- */
165
- getAllTasks() {
166
- return Array.from(this.tasks.values());
167
- }
168
- /**
169
- * Clear the queue
170
- */
171
- clear() {
172
- this.tasks.clear();
173
- this.pending.clear();
174
- this.running.clear();
175
- this.completed.clear();
176
- this.failed.clear();
177
- this.results.clear();
178
- this.failures.clear();
179
- this.attempts.clear();
180
- }
181
- /**
182
- * Cancel a pending task
183
- */
184
- cancelTask(taskId) {
185
- if (this.pending.has(taskId)) {
186
- this.pending.delete(taskId);
187
- this.tasks.delete(taskId);
188
- return true;
189
- }
190
- return false;
191
- }
192
- /**
193
- * Check if a task is blocked by failed dependencies
194
- */
195
- isBlocked(taskId) {
196
- const task = this.tasks.get(taskId);
197
- if (!task || !task.dependencies)
198
- return false;
199
- return task.dependencies.some(depId => this.failed.has(depId));
200
- }
201
- /**
202
- * Skip tasks that are blocked by failed dependencies
203
- */
204
- skipBlockedTasks() {
205
- const skipped = [];
206
- for (const taskId of [...this.pending]) {
207
- if (this.isBlocked(taskId)) {
208
- this.pending.delete(taskId);
209
- this.failed.add(taskId);
210
- const task = this.tasks.get(taskId);
211
- this.failures.set(taskId, {
212
- task,
213
- error: 'Skipped due to failed dependency',
214
- attempts: 0,
215
- });
216
- skipped.push(taskId);
217
- }
218
- }
219
- return skipped;
220
- }
221
- }
@@ -1,132 +0,0 @@
1
- /**
2
- * Swarm Types - Type definitions for swarm coordination
3
- */
4
- import { z } from 'zod';
5
- export type Priority = 1 | 2 | 3;
6
- export type TaskType = 'implement' | 'test' | 'refactor' | 'review' | 'fix';
7
- export type WorkerState = 'idle' | 'running' | 'completed' | 'failed';
8
- export declare const taskScopeSchema: z.ZodObject<{
9
- files: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
10
- directories: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
11
- pattern: z.ZodOptional<z.ZodString>;
12
- }, "strip", z.ZodTypeAny, {
13
- files?: string[] | undefined;
14
- pattern?: string | undefined;
15
- directories?: string[] | undefined;
16
- }, {
17
- files?: string[] | undefined;
18
- pattern?: string | undefined;
19
- directories?: string[] | undefined;
20
- }>;
21
- export type TaskScope = z.infer<typeof taskScopeSchema>;
22
- export declare const swarmTaskSchema: z.ZodObject<{
23
- id: z.ZodString;
24
- type: z.ZodEnum<["implement", "test", "refactor", "review", "fix"]>;
25
- description: z.ZodString;
26
- scope: z.ZodObject<{
27
- files: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
28
- directories: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
29
- pattern: z.ZodOptional<z.ZodString>;
30
- }, "strip", z.ZodTypeAny, {
31
- files?: string[] | undefined;
32
- pattern?: string | undefined;
33
- directories?: string[] | undefined;
34
- }, {
35
- files?: string[] | undefined;
36
- pattern?: string | undefined;
37
- directories?: string[] | undefined;
38
- }>;
39
- dependencies: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
40
- priority: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>>;
41
- timeout: z.ZodDefault<z.ZodNumber>;
42
- retries: z.ZodDefault<z.ZodNumber>;
43
- }, "strip", z.ZodTypeAny, {
44
- type: "test" | "refactor" | "review" | "implement" | "fix";
45
- timeout: number;
46
- description: string;
47
- id: string;
48
- scope: {
49
- files?: string[] | undefined;
50
- pattern?: string | undefined;
51
- directories?: string[] | undefined;
52
- };
53
- dependencies: string[];
54
- priority: 1 | 2 | 3;
55
- retries: number;
56
- }, {
57
- type: "test" | "refactor" | "review" | "implement" | "fix";
58
- description: string;
59
- id: string;
60
- scope: {
61
- files?: string[] | undefined;
62
- pattern?: string | undefined;
63
- directories?: string[] | undefined;
64
- };
65
- timeout?: number | undefined;
66
- dependencies?: string[] | undefined;
67
- priority?: 1 | 2 | 3 | undefined;
68
- retries?: number | undefined;
69
- }>;
70
- export type SwarmTask = z.infer<typeof swarmTaskSchema>;
71
- export interface WorkerResult {
72
- success: boolean;
73
- filesChanged: string[];
74
- commitHash?: string;
75
- error?: string;
76
- duration: number;
77
- output?: string;
78
- }
79
- export interface WorkerStatus {
80
- id: string;
81
- pid?: number;
82
- state: WorkerState;
83
- currentTask?: string;
84
- startedAt?: number;
85
- completedAt?: number;
86
- result?: WorkerResult;
87
- }
88
- export interface RetryPolicy {
89
- maxRetries: number;
90
- backoffMs: number;
91
- backoffMultiplier: number;
92
- maxBackoffMs: number;
93
- }
94
- export interface CoordinatorOptions {
95
- cwd?: string;
96
- concurrency?: number;
97
- branch?: string;
98
- yolo?: boolean;
99
- retryPolicy?: Partial<RetryPolicy>;
100
- timeout?: number;
101
- }
102
- export interface SwarmResult {
103
- total: number;
104
- completed: number;
105
- failed: number;
106
- skipped: number;
107
- duration: number;
108
- successRate: number;
109
- results: TaskResult[];
110
- failedTasks: FailedTask[];
111
- }
112
- export interface TaskResult {
113
- task: SwarmTask;
114
- workerId: string;
115
- result: WorkerResult;
116
- }
117
- export interface FailedTask {
118
- task: SwarmTask;
119
- error: string;
120
- attempts: number;
121
- }
122
- export type SwarmEventMap = {
123
- 'task:start': (task: SwarmTask, workerId: string) => void;
124
- 'task:complete': (task: SwarmTask, result: WorkerResult) => void;
125
- 'task:fail': (task: SwarmTask, error: Error) => void;
126
- 'task:retry': (task: SwarmTask, attempt: number) => void;
127
- 'worker:spawn': (worker: WorkerStatus) => void;
128
- 'worker:exit': (worker: WorkerStatus, code: number) => void;
129
- 'swarm:complete': (result: SwarmResult) => void;
130
- };
131
- export declare const DEFAULT_RETRY_POLICY: RetryPolicy;
132
- export declare const DEFAULT_COORDINATOR_OPTIONS: Required<CoordinatorOptions>;
@@ -1,37 +0,0 @@
1
- /**
2
- * Swarm Types - Type definitions for swarm coordination
3
- */
4
- import { z } from 'zod';
5
- // Task scope schema
6
- export const taskScopeSchema = z.object({
7
- files: z.array(z.string()).optional(),
8
- directories: z.array(z.string()).optional(),
9
- pattern: z.string().optional(),
10
- });
11
- // Task definition schema
12
- export const swarmTaskSchema = z.object({
13
- id: z.string(),
14
- type: z.enum(['implement', 'test', 'refactor', 'review', 'fix']),
15
- description: z.string(),
16
- scope: taskScopeSchema,
17
- dependencies: z.array(z.string()).optional().default([]),
18
- priority: z.union([z.literal(1), z.literal(2), z.literal(3)]).default(2),
19
- timeout: z.number().default(300000), // 5 minutes
20
- retries: z.number().default(2),
21
- });
22
- // Default retry policy
23
- export const DEFAULT_RETRY_POLICY = {
24
- maxRetries: 3,
25
- backoffMs: 1000,
26
- backoffMultiplier: 2,
27
- maxBackoffMs: 30000,
28
- };
29
- // Default coordinator options
30
- export const DEFAULT_COORDINATOR_OPTIONS = {
31
- cwd: process.cwd(),
32
- concurrency: 4,
33
- branch: 'main',
34
- yolo: false,
35
- retryPolicy: DEFAULT_RETRY_POLICY,
36
- timeout: 600000, // 10 minutes
37
- };
@@ -1,109 +0,0 @@
1
- /**
2
- * Worker - Spawns and manages Simple-CLI worker processes
3
- */
4
- import { EventEmitter } from 'events';
5
- import type { SwarmTask, WorkerStatus, WorkerResult } from './types.js';
6
- export interface WorkerOptions {
7
- cwd: string;
8
- yolo: boolean;
9
- timeout: number;
10
- env?: Record<string, string>;
11
- }
12
- export declare class Worker extends EventEmitter {
13
- readonly id: string;
14
- private process;
15
- private state;
16
- private currentTask;
17
- private startedAt;
18
- private output;
19
- private options;
20
- private isTerminating;
21
- private onUnexpectedExit;
22
- constructor(options: WorkerOptions);
23
- /**
24
- * Get current worker status
25
- */
26
- getStatus(): WorkerStatus;
27
- /**
28
- * Execute a task
29
- */
30
- execute(task: SwarmTask): Promise<WorkerResult>;
31
- /**
32
- * Build prompt from task
33
- */
34
- private buildPrompt;
35
- /**
36
- * Parse changed files from output
37
- */
38
- private parseChangedFiles;
39
- /**
40
- * Parse commit hash from output
41
- */
42
- private parseCommitHash;
43
- /**
44
- * Kill the worker process
45
- */
46
- kill(): void;
47
- /**
48
- * Check if worker is busy
49
- */
50
- isBusy(): boolean;
51
- /**
52
- * Check if worker is available
53
- */
54
- isAvailable(): boolean;
55
- /**
56
- * Reset worker for reuse
57
- */
58
- reset(): void;
59
- /**
60
- * Get task output
61
- */
62
- getOutput(): string;
63
- }
64
- /**
65
- * Worker pool for managing multiple workers
66
- */
67
- export declare class WorkerPool {
68
- private workers;
69
- private inUse;
70
- private options;
71
- private maxWorkers;
72
- constructor(maxWorkers: number, options: WorkerOptions);
73
- /**
74
- * Get an available worker (or create one if pool not full)
75
- */
76
- getWorker(): Worker | null;
77
- /**
78
- * Release a worker back to the pool
79
- */
80
- releaseWorker(worker: Worker): void;
81
- /**
82
- * Get all workers
83
- */
84
- getAllWorkers(): Worker[];
85
- /**
86
- * Get worker by ID
87
- */
88
- getWorkerById(id: string): Worker | undefined;
89
- /**
90
- * Get number of busy workers
91
- */
92
- getBusyCount(): number;
93
- /**
94
- * Get number of available workers
95
- */
96
- getAvailableCount(): number;
97
- /**
98
- * Kill all workers
99
- */
100
- killAll(): void;
101
- /**
102
- * Get pool status
103
- */
104
- getStatus(): {
105
- total: number;
106
- busy: number;
107
- available: number;
108
- };
109
- }