@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
package/dist/lib/git.js DELETED
@@ -1,356 +0,0 @@
1
- /**
2
- * Git Operations using simple-git
3
- * Reliable git operations leveraging the native Git binary
4
- */
5
- import simpleGit from 'simple-git';
6
- /**
7
- * GitManager - Wrapper around simple-git for reliable git operations
8
- */
9
- export class GitManager {
10
- git;
11
- cwd;
12
- constructor(config = {}) {
13
- this.cwd = config.cwd || process.cwd();
14
- this.git = simpleGit({
15
- baseDir: this.cwd,
16
- binary: 'git',
17
- maxConcurrentProcesses: 6,
18
- timeout: {
19
- block: config.timeout || 30000,
20
- },
21
- });
22
- }
23
- /**
24
- * Check if current directory is a git repository
25
- */
26
- async isRepo() {
27
- try {
28
- await this.git.revparse(['--git-dir']);
29
- return true;
30
- }
31
- catch {
32
- return false;
33
- }
34
- }
35
- /**
36
- * Initialize a new git repository
37
- */
38
- async init() {
39
- await this.git.init();
40
- }
41
- /**
42
- * Get repository status
43
- */
44
- async status() {
45
- return this.git.status();
46
- }
47
- /**
48
- * Get current branch name
49
- */
50
- async currentBranch() {
51
- try {
52
- const result = await this.git.revparse(['--abbrev-ref', 'HEAD']);
53
- return result.trim() || null;
54
- }
55
- catch {
56
- return null;
57
- }
58
- }
59
- /**
60
- * Get all branches
61
- */
62
- async branches() {
63
- return this.git.branch();
64
- }
65
- /**
66
- * Checkout a branch
67
- */
68
- async checkout(branch, create = false) {
69
- if (create) {
70
- await this.git.checkoutLocalBranch(branch);
71
- }
72
- else {
73
- await this.git.checkout(branch);
74
- }
75
- }
76
- /**
77
- * Stage files
78
- */
79
- async add(files) {
80
- const fileList = Array.isArray(files) ? files : [files];
81
- await this.git.add(fileList);
82
- }
83
- /**
84
- * Stage all changes
85
- */
86
- async addAll() {
87
- await this.git.add('-A');
88
- }
89
- /**
90
- * Commit changes
91
- */
92
- async commit(options) {
93
- const { message, files, amend, noVerify, author } = options;
94
- try {
95
- const commitOptions = {};
96
- if (amend) {
97
- commitOptions['--amend'] = null;
98
- }
99
- if (noVerify) {
100
- commitOptions['--no-verify'] = null;
101
- }
102
- if (author) {
103
- commitOptions['--author'] = author;
104
- }
105
- if (files && files.length > 0) {
106
- await this.git.add(files);
107
- }
108
- const result = await this.git.commit(message, files || [], commitOptions);
109
- if (result.commit) {
110
- return {
111
- hash: result.commit,
112
- message: message,
113
- };
114
- }
115
- return null;
116
- }
117
- catch (error) {
118
- console.error('Commit failed:', error);
119
- return null;
120
- }
121
- }
122
- /**
123
- * Get diff
124
- */
125
- async diff(options = {}) {
126
- const args = ['--no-color'];
127
- if (options.staged) {
128
- args.push('--cached');
129
- }
130
- if (options.from && options.to) {
131
- args.push(options.from, options.to);
132
- }
133
- else if (options.from) {
134
- args.push(options.from);
135
- }
136
- if (options.file) {
137
- args.push('--', options.file);
138
- }
139
- return this.git.diff(args);
140
- }
141
- /**
142
- * Get staged diff
143
- */
144
- async stagedDiff() {
145
- return this.diff({ staged: true });
146
- }
147
- /**
148
- * Get commit log
149
- */
150
- async log(maxCount = 20) {
151
- return this.git.log({ maxCount });
152
- }
153
- /**
154
- * Get the last commit
155
- */
156
- async lastCommit() {
157
- try {
158
- const log = await this.git.log({ maxCount: 1 });
159
- if (log.latest) {
160
- return {
161
- hash: log.latest.hash,
162
- message: log.latest.message,
163
- author: log.latest.author_name,
164
- date: log.latest.date,
165
- };
166
- }
167
- return null;
168
- }
169
- catch {
170
- return null;
171
- }
172
- }
173
- /**
174
- * Undo the last commit (soft reset)
175
- */
176
- async undoLastCommit() {
177
- try {
178
- await this.git.reset(['--soft', 'HEAD~1']);
179
- return true;
180
- }
181
- catch {
182
- return false;
183
- }
184
- }
185
- /**
186
- * Hard reset to a commit
187
- */
188
- async hardReset(commit = 'HEAD') {
189
- await this.git.reset(['--hard', commit]);
190
- }
191
- /**
192
- * Stash changes
193
- */
194
- async stash(message) {
195
- if (message) {
196
- await this.git.stash(['push', '-m', message]);
197
- }
198
- else {
199
- await this.git.stash();
200
- }
201
- }
202
- /**
203
- * Pop stash
204
- */
205
- async stashPop() {
206
- await this.git.stash(['pop']);
207
- }
208
- /**
209
- * Get list of tracked files
210
- */
211
- async trackedFiles() {
212
- const result = await this.git.raw(['ls-files']);
213
- return result.split('\n').filter(Boolean);
214
- }
215
- /**
216
- * Get list of changed files (staged + unstaged)
217
- */
218
- async changedFiles() {
219
- const status = await this.status();
220
- return [
221
- ...status.modified,
222
- ...status.created,
223
- ...status.deleted,
224
- ...status.renamed.map(r => r.to),
225
- ...status.not_added,
226
- ];
227
- }
228
- /**
229
- * Check if a file is ignored
230
- */
231
- async isIgnored(file) {
232
- try {
233
- await this.git.raw(['check-ignore', '-q', file]);
234
- return true;
235
- }
236
- catch {
237
- return false;
238
- }
239
- }
240
- /**
241
- * Get blame for a file
242
- */
243
- async blame(file) {
244
- return this.git.raw(['blame', '--no-color', '-l', file]);
245
- }
246
- /**
247
- * Show a specific commit
248
- */
249
- async show(commit) {
250
- return this.git.show(['--no-color', '--stat', commit]);
251
- }
252
- /**
253
- * Get the root directory of the repository
254
- */
255
- async rootDir() {
256
- try {
257
- const result = await this.git.revparse(['--show-toplevel']);
258
- const trimmed = result.trim();
259
- // Ensure Windows paths use backslashes for tests that compare exact strings
260
- if (process.platform === 'win32') {
261
- return trimmed.replace(/\//g, '\\');
262
- }
263
- return trimmed;
264
- }
265
- catch {
266
- return null;
267
- }
268
- }
269
- /**
270
- * Pull changes from remote
271
- */
272
- async pull(remote = 'origin', branch) {
273
- if (branch) {
274
- await this.git.pull(remote, branch);
275
- }
276
- else {
277
- await this.git.pull();
278
- }
279
- }
280
- /**
281
- * Push changes to remote
282
- */
283
- async push(remote = 'origin', branch, options) {
284
- const args = [];
285
- if (options?.setUpstream) {
286
- args.push('-u');
287
- }
288
- args.push(remote);
289
- if (branch) {
290
- args.push(branch);
291
- }
292
- await this.git.push(args);
293
- }
294
- /**
295
- * Create a new branch from current HEAD
296
- */
297
- async createBranch(name) {
298
- await this.git.checkoutLocalBranch(name);
299
- }
300
- /**
301
- * Delete a branch
302
- */
303
- async deleteBranch(name, force = false) {
304
- await this.git.deleteLocalBranch(name, force);
305
- }
306
- /**
307
- * Merge a branch into current branch
308
- */
309
- async merge(branch) {
310
- await this.git.merge([branch]);
311
- }
312
- /**
313
- * Get the raw simple-git instance for advanced operations
314
- */
315
- raw() {
316
- return this.git;
317
- }
318
- }
319
- // Singleton instance
320
- let gitManager = null;
321
- /**
322
- * Get or create a GitManager instance
323
- */
324
- export function getGitManager(config) {
325
- if (!gitManager || config) {
326
- gitManager = new GitManager(config);
327
- }
328
- return gitManager;
329
- }
330
- /**
331
- * Generate AI commit message from diff
332
- */
333
- export async function generateCommitMessage(diff, generateFn, context) {
334
- const prompt = `Generate a concise git commit message for these changes.
335
-
336
- Guidelines:
337
- - Start with a type: feat, fix, refactor, docs, test, chore
338
- - Keep the first line under 72 characters
339
- - Focus on the "why" not the "what"
340
- - Use imperative mood ("add" not "added")
341
-
342
- ${context ? `Context: ${context}\n` : ''}
343
- Diff:
344
- \`\`\`
345
- ${diff.slice(0, 4000)}${diff.length > 4000 ? '\n... (truncated)' : ''}
346
- \`\`\`
347
-
348
- Respond with ONLY the commit message, no explanation.`;
349
- const message = await generateFn(prompt);
350
- // Clean up the response
351
- return message
352
- .trim()
353
- .replace(/^["']|["']$/g, '') // Remove quotes
354
- .replace(/^commit:?\s*/i, '') // Remove "commit:" prefix
355
- .split('\n')[0]; // Take only first line
356
- }
@@ -1,4 +0,0 @@
1
- /**
2
- * Invoke a simple-cli tool with arguments
3
- */
4
- export declare function invoke(tool: string, args?: Record<string, any>): Promise<any>;
package/dist/lib/shim.js DELETED
@@ -1,30 +0,0 @@
1
- /**
2
- * OpenClaw RPC Shim: allow scripts to call simple-cli tools
3
- */
4
- import { execSync } from 'child_process';
5
- /**
6
- * Invoke a simple-cli tool with arguments
7
- */
8
- export async function invoke(tool, args = {}) {
9
- // Determine path to simple-cli. We assume it's in the same project or installed.
10
- // In production, we'd use the global 'simple' command.
11
- const isWindows = process.platform === 'win32';
12
- const cliCmd = 'simple'; // Or local path to dist/cli.js
13
- try {
14
- const cmd = `${cliCmd} --invoke-json "${tool}" "${JSON.stringify(args).replace(/"/g, '\\"')}"`;
15
- const output = execSync(cmd, { encoding: 'utf-8', stdio: 'pipe' });
16
- try {
17
- return JSON.parse(output.trim());
18
- }
19
- catch {
20
- return output.trim();
21
- }
22
- }
23
- catch (error) {
24
- throw new Error(`Tool invocation failed: ${error.stderr || error.message}`);
25
- }
26
- }
27
- // Global attachment for 'node.invoke' style parity
28
- if (typeof global.invoke === 'undefined') {
29
- global.invoke = invoke;
30
- }
package/dist/lib/ui.d.ts DELETED
@@ -1,159 +0,0 @@
1
- /**
2
- * Terminal UI using Clack
3
- * Modern, clean terminal prompts and spinners
4
- */
5
- import * as p from '@clack/prompts';
6
- export { p as prompts };
7
- /**
8
- * UI Theme colors
9
- */
10
- export declare const theme: {
11
- primary: import("picocolors/types").Formatter;
12
- success: import("picocolors/types").Formatter;
13
- warning: import("picocolors/types").Formatter;
14
- error: import("picocolors/types").Formatter;
15
- muted: import("picocolors/types").Formatter;
16
- highlight: import("picocolors/types").Formatter;
17
- code: import("picocolors/types").Formatter;
18
- };
19
- /**
20
- * Display intro banner
21
- */
22
- export declare function intro(message: string): void;
23
- /**
24
- * Display outro message
25
- */
26
- export declare function outro(message: string): void;
27
- /**
28
- * Display a note
29
- */
30
- export declare function note(message: string, title?: string): void;
31
- /**
32
- * Display a log message
33
- */
34
- export declare function log(message: string): void;
35
- /**
36
- * Display an info message
37
- */
38
- export declare function info(message: string): void;
39
- /**
40
- * Display a success message
41
- */
42
- export declare function success(message: string): void;
43
- /**
44
- * Display a warning message
45
- */
46
- export declare function warning(message: string): void;
47
- /**
48
- * Display an error message
49
- */
50
- export declare function error(message: string): void;
51
- /**
52
- * Display a step message
53
- */
54
- export declare function step(message: string): void;
55
- /**
56
- * Show a spinner while executing an async operation
57
- */
58
- export declare function spin<T>(message: string, fn: () => Promise<T>): Promise<T>;
59
- /**
60
- * Prompt for text input
61
- */
62
- export declare function text(options: {
63
- message: string;
64
- placeholder?: string;
65
- defaultValue?: string;
66
- validate?: (value: string) => string | undefined;
67
- }): Promise<string | symbol>;
68
- /**
69
- * Prompt for password input
70
- */
71
- export declare function password(options: {
72
- message: string;
73
- validate?: (value: string) => string | undefined;
74
- }): Promise<string | symbol>;
75
- /**
76
- * Prompt for confirmation
77
- */
78
- export declare function confirm(options: {
79
- message: string;
80
- initialValue?: boolean;
81
- }): Promise<boolean | symbol>;
82
- /**
83
- * Prompt for single selection
84
- */
85
- export declare function select<T extends string>(options: {
86
- message: string;
87
- options: Array<{
88
- value: T;
89
- label: string;
90
- hint?: string;
91
- }>;
92
- initialValue?: T;
93
- }): Promise<T | symbol>;
94
- /**
95
- * Prompt for multi-selection
96
- */
97
- export declare function multiselect<T extends string>(options: {
98
- message: string;
99
- options: Array<{
100
- value: T;
101
- label: string;
102
- hint?: string;
103
- }>;
104
- initialValues?: T[];
105
- required?: boolean;
106
- }): Promise<T[] | symbol>;
107
- /**
108
- * Group related prompts together
109
- */
110
- export declare function group<T extends Record<string, unknown>>(prompts: Record<keyof T, () => Promise<unknown>>, options?: {
111
- onCancel?: () => void;
112
- }): Promise<T>;
113
- /**
114
- * Check if user cancelled
115
- */
116
- export declare function isCancel(value: unknown): value is symbol;
117
- /**
118
- * Cancel and exit
119
- */
120
- export declare function cancel(message?: string): void;
121
- /**
122
- * Display a diff with syntax highlighting
123
- */
124
- export declare function showDiff(diffText: string): void;
125
- /**
126
- * Display a code block
127
- */
128
- export declare function showCode(code: string, language?: string): void;
129
- /**
130
- * Display a thinking/reasoning block
131
- */
132
- export declare function showThought(thought: string): void;
133
- /**
134
- * Display a tool invocation
135
- */
136
- export declare function showToolCall(name: string, args: Record<string, unknown>): void;
137
- /**
138
- * Display a tool result
139
- */
140
- export declare function showToolResult(result: string, truncate?: number): void;
141
- /**
142
- * Display file status indicators
143
- */
144
- export declare function showFileStatus(files: Array<{
145
- path: string;
146
- status: 'added' | 'modified' | 'deleted' | 'readonly';
147
- }>): void;
148
- /**
149
- * Display token count
150
- */
151
- export declare function showTokens(count: number, max?: number): void;
152
- /**
153
- * Create a task list for progress tracking
154
- */
155
- export declare function tasks(): {
156
- add: (name: string, status?: 'pending' | 'running' | 'done' | 'error') => void;
157
- update: (name: string, status: 'pending' | 'running' | 'done' | 'error') => void;
158
- render: () => void;
159
- };