@stan-chen/simple-cli 0.2.2 → 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 (100) hide show
  1. package/README.md +58 -271
  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 +37 -279
  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 +88 -78
  20. package/dist/commands/add.d.ts +0 -9
  21. package/dist/commands/add.js +0 -50
  22. package/dist/commands/git/commit.d.ts +0 -12
  23. package/dist/commands/git/commit.js +0 -97
  24. package/dist/commands/git/status.d.ts +0 -6
  25. package/dist/commands/git/status.js +0 -42
  26. package/dist/commands/index.d.ts +0 -16
  27. package/dist/commands/index.js +0 -376
  28. package/dist/commands/mcp/status.d.ts +0 -6
  29. package/dist/commands/mcp/status.js +0 -31
  30. package/dist/commands/swarm.d.ts +0 -36
  31. package/dist/commands/swarm.js +0 -236
  32. package/dist/commands.d.ts +0 -32
  33. package/dist/commands.js +0 -427
  34. package/dist/context.d.ts +0 -116
  35. package/dist/context.js +0 -327
  36. package/dist/index.d.ts +0 -6
  37. package/dist/index.js +0 -109
  38. package/dist/lib/agent.d.ts +0 -98
  39. package/dist/lib/agent.js +0 -281
  40. package/dist/lib/editor.d.ts +0 -74
  41. package/dist/lib/editor.js +0 -441
  42. package/dist/lib/git.d.ts +0 -164
  43. package/dist/lib/git.js +0 -351
  44. package/dist/lib/ui.d.ts +0 -159
  45. package/dist/lib/ui.js +0 -252
  46. package/dist/mcp/client.d.ts +0 -22
  47. package/dist/mcp/client.js +0 -81
  48. package/dist/mcp/manager.d.ts +0 -186
  49. package/dist/mcp/manager.js +0 -446
  50. package/dist/prompts/provider.d.ts +0 -22
  51. package/dist/prompts/provider.js +0 -78
  52. package/dist/providers/index.d.ts +0 -15
  53. package/dist/providers/index.js +0 -82
  54. package/dist/providers/multi.d.ts +0 -11
  55. package/dist/providers/multi.js +0 -28
  56. package/dist/registry.d.ts +0 -24
  57. package/dist/registry.js +0 -379
  58. package/dist/repoMap.d.ts +0 -5
  59. package/dist/repoMap.js +0 -79
  60. package/dist/router.d.ts +0 -41
  61. package/dist/router.js +0 -108
  62. package/dist/swarm/coordinator.d.ts +0 -86
  63. package/dist/swarm/coordinator.js +0 -257
  64. package/dist/swarm/index.d.ts +0 -28
  65. package/dist/swarm/index.js +0 -29
  66. package/dist/swarm/task.d.ts +0 -104
  67. package/dist/swarm/task.js +0 -221
  68. package/dist/swarm/types.d.ts +0 -132
  69. package/dist/swarm/types.js +0 -37
  70. package/dist/swarm/worker.d.ts +0 -107
  71. package/dist/swarm/worker.js +0 -299
  72. package/dist/tools/analyzeFile.d.ts +0 -16
  73. package/dist/tools/analyzeFile.js +0 -43
  74. package/dist/tools/git.d.ts +0 -40
  75. package/dist/tools/git.js +0 -236
  76. package/dist/tools/glob.d.ts +0 -34
  77. package/dist/tools/glob.js +0 -165
  78. package/dist/tools/grep.d.ts +0 -53
  79. package/dist/tools/grep.js +0 -296
  80. package/dist/tools/linter.d.ts +0 -35
  81. package/dist/tools/linter.js +0 -349
  82. package/dist/tools/listDir.d.ts +0 -29
  83. package/dist/tools/listDir.js +0 -50
  84. package/dist/tools/memory.d.ts +0 -34
  85. package/dist/tools/memory.js +0 -215
  86. package/dist/tools/readFiles.d.ts +0 -25
  87. package/dist/tools/readFiles.js +0 -31
  88. package/dist/tools/reloadTools.d.ts +0 -11
  89. package/dist/tools/reloadTools.js +0 -22
  90. package/dist/tools/runCommand.d.ts +0 -32
  91. package/dist/tools/runCommand.js +0 -79
  92. package/dist/tools/scraper.d.ts +0 -31
  93. package/dist/tools/scraper.js +0 -211
  94. package/dist/tools/writeFiles.d.ts +0 -63
  95. package/dist/tools/writeFiles.js +0 -87
  96. package/dist/ui/server.d.ts +0 -5
  97. package/dist/ui/server.js +0 -74
  98. package/dist/watcher.d.ts +0 -35
  99. package/dist/watcher.js +0 -164
  100. /package/{docs/assets → assets}/logo.jpeg +0 -0
package/dist/mcp.d.ts ADDED
@@ -0,0 +1,132 @@
1
+ export declare class MCP {
2
+ private clients;
3
+ init(): Promise<void>;
4
+ getTools(): Promise<{
5
+ execute: (args: any) => Promise<{
6
+ [x: string]: unknown;
7
+ content: ({
8
+ type: "text";
9
+ text: string;
10
+ annotations?: {
11
+ audience?: ("user" | "assistant")[] | undefined;
12
+ priority?: number | undefined;
13
+ lastModified?: string | undefined;
14
+ } | undefined;
15
+ _meta?: Record<string, unknown> | undefined;
16
+ } | {
17
+ type: "image";
18
+ data: string;
19
+ mimeType: string;
20
+ annotations?: {
21
+ audience?: ("user" | "assistant")[] | undefined;
22
+ priority?: number | undefined;
23
+ lastModified?: string | undefined;
24
+ } | undefined;
25
+ _meta?: Record<string, unknown> | undefined;
26
+ } | {
27
+ type: "audio";
28
+ data: string;
29
+ mimeType: string;
30
+ annotations?: {
31
+ audience?: ("user" | "assistant")[] | undefined;
32
+ priority?: number | undefined;
33
+ lastModified?: string | undefined;
34
+ } | undefined;
35
+ _meta?: Record<string, unknown> | undefined;
36
+ } | {
37
+ type: "resource";
38
+ resource: {
39
+ uri: string;
40
+ text: string;
41
+ mimeType?: string | undefined;
42
+ _meta?: Record<string, unknown> | undefined;
43
+ } | {
44
+ uri: string;
45
+ blob: string;
46
+ mimeType?: string | undefined;
47
+ _meta?: Record<string, unknown> | undefined;
48
+ };
49
+ annotations?: {
50
+ audience?: ("user" | "assistant")[] | undefined;
51
+ priority?: number | undefined;
52
+ lastModified?: string | undefined;
53
+ } | undefined;
54
+ _meta?: Record<string, unknown> | undefined;
55
+ } | {
56
+ uri: string;
57
+ name: string;
58
+ type: "resource_link";
59
+ description?: string | undefined;
60
+ mimeType?: string | undefined;
61
+ annotations?: {
62
+ audience?: ("user" | "assistant")[] | undefined;
63
+ priority?: number | undefined;
64
+ lastModified?: string | undefined;
65
+ } | undefined;
66
+ _meta?: {
67
+ [x: string]: unknown;
68
+ } | undefined;
69
+ icons?: {
70
+ src: string;
71
+ mimeType?: string | undefined;
72
+ sizes?: string[] | undefined;
73
+ theme?: "light" | "dark" | undefined;
74
+ }[] | undefined;
75
+ title?: string | undefined;
76
+ })[];
77
+ _meta?: {
78
+ [x: string]: unknown;
79
+ progressToken?: string | number | undefined;
80
+ "io.modelcontextprotocol/related-task"?: {
81
+ taskId: string;
82
+ } | undefined;
83
+ } | undefined;
84
+ structuredContent?: Record<string, unknown> | undefined;
85
+ isError?: boolean | undefined;
86
+ } | {
87
+ [x: string]: unknown;
88
+ toolResult: unknown;
89
+ _meta?: {
90
+ [x: string]: unknown;
91
+ progressToken?: string | number | undefined;
92
+ "io.modelcontextprotocol/related-task"?: {
93
+ taskId: string;
94
+ } | undefined;
95
+ } | undefined;
96
+ }>;
97
+ source: "mcp";
98
+ server: string;
99
+ inputSchema: {
100
+ [x: string]: unknown;
101
+ type: "object";
102
+ properties?: Record<string, object> | undefined;
103
+ required?: string[] | undefined;
104
+ };
105
+ name: string;
106
+ description?: string | undefined;
107
+ outputSchema?: {
108
+ [x: string]: unknown;
109
+ type: "object";
110
+ properties?: Record<string, object> | undefined;
111
+ required?: string[] | undefined;
112
+ } | undefined;
113
+ annotations?: {
114
+ title?: string | undefined;
115
+ readOnlyHint?: boolean | undefined;
116
+ destructiveHint?: boolean | undefined;
117
+ idempotentHint?: boolean | undefined;
118
+ openWorldHint?: boolean | undefined;
119
+ } | undefined;
120
+ execution?: {
121
+ taskSupport?: "optional" | "required" | "forbidden" | undefined;
122
+ } | undefined;
123
+ _meta?: Record<string, unknown> | undefined;
124
+ icons?: {
125
+ src: string;
126
+ mimeType?: string | undefined;
127
+ sizes?: string[] | undefined;
128
+ theme?: "light" | "dark" | undefined;
129
+ }[] | undefined;
130
+ title?: string | undefined;
131
+ }[]>;
132
+ }
package/dist/mcp.js ADDED
@@ -0,0 +1,43 @@
1
+ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
2
+ import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
3
+ import { existsSync, readFileSync } from 'fs';
4
+ import { join } from 'path';
5
+ export class MCP {
6
+ clients = new Map();
7
+ async init() {
8
+ const configPath = join(process.cwd(), 'mcp.json');
9
+ if (!existsSync(configPath))
10
+ return;
11
+ const config = JSON.parse(readFileSync(configPath, 'utf-8'));
12
+ const servers = config.mcpServers || config.servers || {};
13
+ for (const [name, cfg] of Object.entries(servers)) {
14
+ try {
15
+ const client = new Client({ name: 'simple-cli', version: '1.0.0' }, { capabilities: {} });
16
+ const transport = new StdioClientTransport({
17
+ command: cfg.command,
18
+ args: cfg.args || [],
19
+ env: { ...process.env, ...(cfg.env || {}) }
20
+ });
21
+ await client.connect(transport);
22
+ this.clients.set(name, client);
23
+ console.log(`✓ Connected to MCP: ${name}`);
24
+ }
25
+ catch (e) {
26
+ console.error(`✗ Failed to connect to MCP ${name}:`, e);
27
+ }
28
+ }
29
+ }
30
+ async getTools() {
31
+ const all = [];
32
+ for (const [name, client] of this.clients) {
33
+ const { tools } = await client.listTools();
34
+ all.push(...tools.map(t => ({
35
+ ...t,
36
+ execute: (args) => client.callTool({ name: t.name, arguments: args }),
37
+ source: 'mcp',
38
+ server: name
39
+ })));
40
+ }
41
+ return all;
42
+ }
43
+ }
package/dist/skills.d.ts CHANGED
@@ -1,25 +1,14 @@
1
- /**
2
- * Skills/Presets System
3
- * Based on OpenHands skills and Aider prompts
4
- * Provides specialized behavior presets for different tasks
5
- */
6
1
  export interface Skill {
7
2
  name: string;
8
- description: string;
3
+ description?: string;
9
4
  systemPrompt: string;
10
5
  tools?: string[];
11
- modelPreference?: string;
12
- autoActions?: string[];
13
6
  }
14
7
  export declare const builtinSkills: Record<string, Skill>;
15
- export declare function getActiveSkill(): Skill;
8
+ export declare function loadSkillFromFile(path: string): Promise<Skill | null>;
9
+ export declare function getActiveSkill(cwd?: string): Promise<Skill>;
16
10
  export declare function setActiveSkill(name: string): Skill | undefined;
17
11
  export declare function listSkills(): Skill[];
18
- export declare function loadSkillFromFile(path: string): Promise<Skill | null>;
19
- export declare function saveSkillToFile(skill: Skill, path: string): Promise<void>;
20
12
  export declare function loadCustomSkills(dir: string): Promise<Record<string, Skill>>;
21
- export declare function buildSkillPrompt(skill: Skill, context?: {
22
- files?: string[];
23
- repoMap?: string;
24
- history?: string;
25
- }): string;
13
+ export declare function buildSkillPrompt(skill: Skill, context?: any): string;
14
+ export declare function saveSkillToFile(skill: Skill, path: string): Promise<void>;
package/dist/skills.js CHANGED
@@ -1,229 +1,87 @@
1
- /**
2
- * Skills/Presets System
3
- * Based on OpenHands skills and Aider prompts
4
- * Provides specialized behavior presets for different tasks
5
- */
6
- import { readFile, writeFile, readdir } from 'fs/promises';
1
+ import { readFile, readdir, writeFile } from 'fs/promises';
2
+ import { join, basename, extname } from 'path';
7
3
  import { existsSync } from 'fs';
8
- import { join } from 'path';
9
- // Built-in skills
10
4
  export const builtinSkills = {
11
- // Code editing skill (default)
12
5
  code: {
13
6
  name: 'code',
14
- description: 'General coding assistant with file editing and custom skill creation capabilities',
15
- systemPrompt: `You are a coding assistant. You help users write, modify, and debug code.
16
-
17
- ## Custom Skills (Self-Evolution)
18
- You can create your own specialized tools in \`skills/\`, \`scripts/\`, or \`tools/\`:
19
- 1. **TypeScript/JS**: Standard native exports.
20
- 2. **Scripts & Binaries**:
21
- - Write any script (Python, Bash, PowerShell, etc.) or binary.
22
- - **Documentation**: Provide a matching \`.md\` or \`.txt\` file (e.g., \`tool.py\` + \`tool.md\`).
23
- - **Internal Documentation**: Alternatively, put Markdown in a comment block at the very top of your script.
24
-
25
- 3. **AI Attribution**: All self-created tools MUST include a marker as the first line:
26
- - **Scripts**: A comment e.g. \`# [Simple-CLI AI-Created]\` or \`// [Simple-CLI AI-Created]\`.
27
- - **Documentation**: A hidden comment e.g. \`<!-- [Simple-CLI AI-Created] -->\`.
28
-
29
- **Markdown Specification Example**:
30
- \`\`\`markdown
31
- <!-- [Simple-CLI AI-Created] -->
32
- # toolName
33
- Brief description.
34
-
35
- ## Command
36
- python scripts/tool.py
37
- \`\`\`
38
- Inputs are passed via **stdin** (JSON) and the \`TOOL_INPUT\` env var.
39
- After creating/modifying, call \`reloadTools\`.
40
-
41
- 4. **Self-Orchestration**: If a project lacks clear success criteria (missing \`.agent/\` or \`.simple/\` directories), you should take the initiative to create them. Use these folders to store implementation plans, SPEC/PRDs, and validation tests.
42
-
43
- When making changes to files:
44
- 1. Read the file first to understand the context
45
- 2. Make precise, targeted changes using search/replace
46
- 3. Verify changes don't break existing functionality
47
- 4. Follow the existing code style`,
48
- tools: ['readFiles', 'writeFiles', 'runCommand', 'glob', 'grep', 'lint', 'reloadTools'],
49
- },
50
- // Architect skill for planning
51
- architect: {
52
- name: 'architect',
53
- description: 'Design and planning mode - focuses on architecture decisions',
54
- systemPrompt: `You are a software architect assistant. Your role is to:
55
-
56
- 1. Help design system architecture
57
- 2. Make technology decisions
58
- 3. Plan implementation strategies
59
- 4. Review and improve existing designs
60
-
61
- When working on architecture:
62
- - Ask clarifying questions about requirements
63
- - Consider scalability, maintainability, and security
64
- - Provide multiple options when appropriate
65
- - Document decisions and trade-offs
66
-
67
- Focus on high-level design rather than implementation details.
68
- Generate diagrams and documentation when helpful.`,
69
- tools: ['readFiles', 'glob', 'grep', 'memory'],
70
- modelPreference: 'orchestrator',
71
- },
72
- // Ask skill for questions only
73
- ask: {
74
- name: 'ask',
75
- description: 'Question-answering mode - no file modifications',
76
- systemPrompt: `You are a helpful coding assistant in read-only mode.
77
-
78
- You can:
79
- - Answer questions about the codebase
80
- - Explain how code works
81
- - Suggest improvements
82
- - Help with debugging
83
-
84
- You should NOT:
85
- - Modify any files
86
- - Run commands that change state
87
- - Create new files
88
-
89
- Always read files before answering questions about them.`,
90
- tools: ['readFiles', 'glob', 'grep'],
91
- },
92
- // Help/docs skill
93
- help: {
94
- name: 'help',
95
- description: 'Help and documentation assistant',
96
- systemPrompt: `You are a documentation assistant. Help users understand:
97
-
98
- - How to use this CLI tool
99
- - Programming concepts and patterns
100
- - Best practices and conventions
101
- - Error messages and debugging
102
-
103
- Be concise and provide examples when helpful.
104
- Reference official documentation when available.`,
105
- tools: ['readFiles', 'scrapeUrl'],
106
- },
107
- // Test skill
108
- test: {
109
- name: 'test',
110
- description: 'Test writing and debugging assistant',
111
- systemPrompt: `You are a test engineering assistant. Your focus is:
112
-
113
- 1. Writing comprehensive tests
114
- 2. Debugging failing tests
115
- 3. Improving test coverage
116
- 4. Setting up test infrastructure
117
-
118
- Test guidelines:
119
- - Follow the project's existing test patterns
120
- - Cover edge cases and error conditions
121
- - Write clear test descriptions
122
- - Use appropriate mocking when needed
123
-
124
- After writing tests, run them to verify they pass.`,
125
- tools: ['readFiles', 'writeFiles', 'runCommand', 'glob', 'grep', 'lint'],
126
- },
127
- // Debug skill
128
- debug: {
129
- name: 'debug',
130
- description: 'Debugging assistant for troubleshooting issues',
131
- systemPrompt: `You are a debugging assistant. Your process:
132
-
133
- 1. Understand the error or unexpected behavior
134
- 2. Reproduce the issue if possible
135
- 3. Analyze logs, stack traces, and code
136
- 4. Form hypotheses about the cause
137
- 5. Test fixes incrementally
138
-
139
- Debugging tips:
140
- - Add logging to understand program flow
141
- - Check recent changes that might have caused the issue
142
- - Look for common patterns (null checks, async issues, etc.)
143
- - Use the linter to catch syntax errors`,
144
- tools: ['readFiles', 'writeFiles', 'runCommand', 'grep', 'lint', 'git'],
145
- },
146
- // Refactor skill
147
- refactor: {
148
- name: 'refactor',
149
- description: 'Code refactoring with safety focus',
150
- systemPrompt: `You are a refactoring assistant. Your approach:
151
-
152
- 1. Understand the current implementation
153
- 2. Identify areas for improvement
154
- 3. Make incremental, safe changes
155
- 4. Verify behavior is preserved
156
-
157
- Refactoring principles:
158
- - Small, focused changes
159
- - Maintain existing tests
160
- - Improve readability and maintainability
161
- - Reduce duplication
162
- - Follow SOLID principles
163
-
164
- Always run tests after refactoring to ensure nothing broke.`,
165
- tools: ['readFiles', 'writeFiles', 'runCommand', 'glob', 'grep', 'lint', 'git'],
166
- },
167
- // Review skill
168
- review: {
169
- name: 'review',
170
- description: 'Code review assistant',
171
- systemPrompt: `You are a code reviewer. Review code for:
172
-
173
- 1. Correctness - Does it work as intended?
174
- 2. Security - Are there vulnerabilities?
175
- 3. Performance - Are there inefficiencies?
176
- 4. Style - Does it follow conventions?
177
- 5. Maintainability - Is it easy to understand?
178
-
179
- Provide constructive feedback with specific suggestions.
180
- Prioritize critical issues over minor style concerns.`,
181
- tools: ['readFiles', 'glob', 'grep', 'git', 'lint'],
182
- },
183
- // Shell skill
184
- shell: {
185
- name: 'shell',
186
- description: 'Shell/command-line assistant',
187
- systemPrompt: `You are a shell/command-line assistant. Help with:
188
-
189
- - Writing shell scripts
190
- - Running and debugging commands
191
- - System administration tasks
192
- - Build and deployment scripts
193
-
194
- Safety guidelines:
195
- - Explain what commands do before running
196
- - Use safe defaults (no force flags unless needed)
197
- - Be careful with destructive operations
198
- - Test commands before applying to production`,
199
- tools: ['runCommand', 'readFiles', 'writeFiles', 'glob'],
200
- },
201
- // Git skill
202
- git: {
203
- name: 'git',
204
- description: 'Git version control assistant',
205
- systemPrompt: `You are a Git assistant. Help with:
206
-
207
- - Understanding git history and changes
208
- - Creating meaningful commits
209
- - Managing branches
210
- - Resolving merge conflicts
211
- - Best practices for version control
212
-
213
- Git guidelines:
214
- - Write clear, descriptive commit messages
215
- - Make small, focused commits
216
- - Keep branches up to date
217
- - Review changes before committing`,
218
- tools: ['git', 'readFiles', 'glob', 'grep'],
219
- },
7
+ description: 'A helpful coding assistant.',
8
+ systemPrompt: `You are a helpful coding assistant. Use tools to solve tasks.
9
+ You must output your response in JSON format.
10
+ The JSON should have the following structure:
11
+ {
12
+ "thought": "Your reasoning here",
13
+ "tool": "tool_name",
14
+ "args": { "arg_name": "value" }
15
+ }
16
+ If you don't need to use a tool, use "tool": "none" and provide a "message".
17
+ {
18
+ "thought": "Reasoning",
19
+ "tool": "none",
20
+ "message": "Response to user"
21
+ }
22
+ Important:
23
+ - If a task requires multiple steps, perform them one by one.
24
+ - Do not ask for confirmation if you have enough information to proceed.
25
+ - When writing to files that might exist (like logs), read them first and append to them if necessary, unless instructed to overwrite.
26
+ `
27
+ }
220
28
  };
221
- // Get active skill from environment or default
222
- export function getActiveSkill() {
223
- const skillName = process.env.SIMPLE_CLI_SKILL || 'code';
224
- return builtinSkills[skillName] || builtinSkills.code;
29
+ export async function loadSkillFromFile(path) {
30
+ if (!existsSync(path))
31
+ return null;
32
+ try {
33
+ const content = await readFile(path, 'utf-8');
34
+ const ext = extname(path).toLowerCase();
35
+ if (ext === '.json') {
36
+ const skill = JSON.parse(content);
37
+ if (!skill.name || !skill.systemPrompt)
38
+ return null;
39
+ return skill;
40
+ }
41
+ else if (ext === '.md') {
42
+ // Parse markdown:
43
+ // Title (# Title) -> Name
44
+ // Content -> System Prompt
45
+ let name = basename(path, '.md');
46
+ const titleMatch = content.match(/^#\s+(.+)$/m);
47
+ if (titleMatch) {
48
+ name = titleMatch[1].trim();
49
+ }
50
+ return {
51
+ name,
52
+ description: `Loaded from ${basename(path)}`,
53
+ systemPrompt: content
54
+ };
55
+ }
56
+ }
57
+ catch (e) {
58
+ return null;
59
+ }
60
+ return null;
61
+ }
62
+ export async function getActiveSkill(cwd = process.cwd()) {
63
+ // 1. Env var
64
+ if (process.env.SIMPLE_CLI_SKILL) {
65
+ if (builtinSkills[process.env.SIMPLE_CLI_SKILL]) {
66
+ return builtinSkills[process.env.SIMPLE_CLI_SKILL];
67
+ }
68
+ }
69
+ // 2. Project config (.agent/AGENT.md or .agent/SOUL.md)
70
+ const agentMd = join(cwd, '.agent', 'AGENT.md');
71
+ if (existsSync(agentMd)) {
72
+ const skill = await loadSkillFromFile(agentMd);
73
+ if (skill)
74
+ return skill;
75
+ }
76
+ const soulMd = join(cwd, '.agent', 'SOUL.md');
77
+ if (existsSync(soulMd)) {
78
+ const skill = await loadSkillFromFile(soulMd);
79
+ if (skill)
80
+ return skill;
81
+ }
82
+ // 3. Default
83
+ return builtinSkills.code;
225
84
  }
226
- // Set active skill
227
85
  export function setActiveSkill(name) {
228
86
  if (builtinSkills[name]) {
229
87
  process.env.SIMPLE_CLI_SKILL = name;
@@ -231,58 +89,38 @@ export function setActiveSkill(name) {
231
89
  }
232
90
  return undefined;
233
91
  }
234
- // List available skills
235
92
  export function listSkills() {
236
93
  return Object.values(builtinSkills);
237
94
  }
238
- // Load custom skill from file
239
- export async function loadSkillFromFile(path) {
240
- try {
241
- const content = await readFile(path, 'utf-8');
242
- const skill = JSON.parse(content);
243
- if (!skill.name || !skill.systemPrompt) {
244
- return null;
245
- }
246
- return skill;
247
- }
248
- catch {
249
- return null;
250
- }
251
- }
252
- // Save custom skill to file
253
- export async function saveSkillToFile(skill, path) {
254
- await writeFile(path, JSON.stringify(skill, null, 2));
255
- }
256
- // Load all custom skills from a directory
257
95
  export async function loadCustomSkills(dir) {
258
96
  const skills = {};
259
- if (!existsSync(dir)) {
97
+ if (!existsSync(dir))
260
98
  return skills;
261
- }
262
99
  try {
263
- const files = await readdir(dir);
264
- for (const file of files) {
265
- if (file.endsWith('.json')) {
266
- const skill = await loadSkillFromFile(join(dir, file));
100
+ const entries = await readdir(dir, { withFileTypes: true });
101
+ for (const entry of entries) {
102
+ if (entry.isFile()) {
103
+ const path = join(dir, entry.name);
104
+ const skill = await loadSkillFromFile(path);
267
105
  if (skill) {
268
106
  skills[skill.name] = skill;
269
107
  }
270
108
  }
271
109
  }
272
110
  }
273
- catch {
274
- // Ignore errors
275
- }
111
+ catch { }
276
112
  return skills;
277
113
  }
278
- // Get skill system prompt with context
279
114
  export function buildSkillPrompt(skill, context) {
280
115
  let prompt = skill.systemPrompt;
281
- if (context?.files?.length) {
282
- prompt += `\n\n## Active Files\nYou are working with these files:\n${context.files.join('\n')}`;
283
- }
284
116
  if (context?.repoMap) {
285
117
  prompt += `\n\n## Repository Structure\n${context.repoMap}`;
286
118
  }
119
+ if (context?.files && context.files.length > 0) {
120
+ prompt += `\n\n## Active Files\n${context.files.join('\n')}`;
121
+ }
287
122
  return prompt;
288
123
  }
124
+ export async function saveSkillToFile(skill, path) {
125
+ await writeFile(path, JSON.stringify(skill, null, 2));
126
+ }
package/dist/tui.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function showBanner(): void;
package/dist/tui.js ADDED
@@ -0,0 +1,10 @@
1
+ import pc from 'picocolors';
2
+ export function showBanner() {
3
+ const cat = `
4
+ /\\_/\\
5
+ ( o.o )
6
+ > ^ <
7
+ `;
8
+ console.log(pc.magenta(cat));
9
+ console.log(` ${pc.bgMagenta(pc.black(' SIMPLE-CLI '))} ${pc.dim('v0.4.0')}\n`);
10
+ }