@indiccoder/mentis-cli 1.0.5 → 1.0.9
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.
- package/dist/index.js +6 -0
- package/dist/repl/ReplManager.js +160 -17
- package/dist/skills/LoadSkillTool.js +133 -0
- package/dist/skills/Skill.js +6 -0
- package/dist/skills/SkillCreator.js +247 -0
- package/dist/skills/SkillsManager.js +337 -0
- package/dist/ui/UIManager.js +46 -8
- package/dist/utils/UpdateManager.js +81 -0
- package/docs/SKILLS.md +319 -0
- package/examples/skills/code-reviewer/SKILL.md +88 -0
- package/examples/skills/commit-helper/SKILL.md +66 -0
- package/examples/skills/pdf-processing/SKILL.md +108 -0
- package/package.json +3 -2
- package/src/index.ts +7 -0
- package/src/repl/ReplManager.ts +193 -17
- package/src/skills/LoadSkillTool.ts +168 -0
- package/src/skills/Skill.ts +51 -0
- package/src/skills/SkillCreator.ts +237 -0
- package/src/skills/SkillsManager.ts +354 -0
- package/src/ui/UIManager.ts +61 -15
- package/src/utils/UpdateManager.ts +83 -0
package/docs/SKILLS.md
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
# Agent Skills - User Guide
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Agent Skills allow you to package your expertise into modular, reusable capabilities that Mentis can autonomously discover and use. Skills are organized folders containing instructions, scripts, and resources that extend Mentis's functionality.
|
|
6
|
+
|
|
7
|
+
## How Skills Work
|
|
8
|
+
|
|
9
|
+
1. **Discovery**: Mentis scans `~/.mentis/skills/` (personal) and `.mentis/skills/` (project) for skills
|
|
10
|
+
2. **Metadata Injection**: At startup, skill names and descriptions are added to the system context
|
|
11
|
+
3. **Model-Invoked**: When Mentis determines a skill is relevant to your request, it automatically loads the full skill content
|
|
12
|
+
4. **Progressive Disclosure**: Supporting files are only loaded when explicitly referenced
|
|
13
|
+
|
|
14
|
+
## Skill Structure
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
skill-directory/
|
|
18
|
+
├── SKILL.md # Required: YAML frontmatter + instructions
|
|
19
|
+
├── reference.md # Optional: Additional documentation
|
|
20
|
+
├── examples.md # Optional: Usage examples
|
|
21
|
+
├── scripts/ # Optional: Executable utilities
|
|
22
|
+
│ └── helper.py
|
|
23
|
+
└── templates/ # Optional: File templates
|
|
24
|
+
└── template.txt
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## SKILL.md Format
|
|
28
|
+
|
|
29
|
+
```yaml
|
|
30
|
+
---
|
|
31
|
+
name: your-skill-name
|
|
32
|
+
description: What this skill does and when to use it
|
|
33
|
+
allowed-tools: Read, Grep, Glob # Optional: Restrict tools
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
# Your Skill Name
|
|
37
|
+
|
|
38
|
+
## Instructions
|
|
39
|
+
Step-by-step guidance for Mentis.
|
|
40
|
+
|
|
41
|
+
## Examples
|
|
42
|
+
Concrete usage examples.
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Required Fields
|
|
46
|
+
|
|
47
|
+
- **name**: Lowercase letters, numbers, hyphens only (max 64 characters)
|
|
48
|
+
- **description**: What the skill does + when to use it (max 1024 characters)
|
|
49
|
+
|
|
50
|
+
### Optional Fields
|
|
51
|
+
|
|
52
|
+
- **allowed-tools**: List of tools the skill can use without permission
|
|
53
|
+
|
|
54
|
+
## Creating Your First Skill
|
|
55
|
+
|
|
56
|
+
### Option 1: Interactive Wizard
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
/skills create
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Follow the prompts:
|
|
63
|
+
1. Enter skill name (e.g., `my-custom-skill`)
|
|
64
|
+
2. Choose type (personal or project)
|
|
65
|
+
3. Write description (include "Use when..." for better discovery)
|
|
66
|
+
4. Optionally restrict allowed tools
|
|
67
|
+
|
|
68
|
+
### Option 2: Manual Creation
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# Create directory
|
|
72
|
+
mkdir -p ~/.mentis/skills/my-skill
|
|
73
|
+
|
|
74
|
+
# Create SKILL.md
|
|
75
|
+
cat > ~/.mentis/skills/my-skill/SKILL.md << 'EOF'
|
|
76
|
+
---
|
|
77
|
+
name: my-skill
|
|
78
|
+
description: Does something useful. Use when the user mentions specific keywords.
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
# My Skill
|
|
82
|
+
|
|
83
|
+
## Instructions
|
|
84
|
+
1. Do this first
|
|
85
|
+
2. Then do that
|
|
86
|
+
|
|
87
|
+
## Examples
|
|
88
|
+
Example usage...
|
|
89
|
+
EOF
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Skill Commands
|
|
93
|
+
|
|
94
|
+
| Command | Description |
|
|
95
|
+
|---------|-------------|
|
|
96
|
+
| `/skills` | List all available skills |
|
|
97
|
+
| `/skills list` | List all available skills |
|
|
98
|
+
| `/skills show <name>` | Display full skill content |
|
|
99
|
+
| `/skills create [name]` | Interactive skill creator |
|
|
100
|
+
| `/skills validate` | Validate all skills for errors |
|
|
101
|
+
|
|
102
|
+
## Skill Types
|
|
103
|
+
|
|
104
|
+
### Personal Skills
|
|
105
|
+
|
|
106
|
+
Stored in `~/.mentis/skills/` - available across all projects.
|
|
107
|
+
|
|
108
|
+
**Use for**:
|
|
109
|
+
- Individual workflows and preferences
|
|
110
|
+
- Experimental skills in development
|
|
111
|
+
- Personal productivity tools
|
|
112
|
+
|
|
113
|
+
### Project Skills
|
|
114
|
+
|
|
115
|
+
Stored in `.mentis/skills/` - shared with your team via git.
|
|
116
|
+
|
|
117
|
+
**Use for**:
|
|
118
|
+
- Team workflows and conventions
|
|
119
|
+
- Project-specific expertise
|
|
120
|
+
- Shared utilities and scripts
|
|
121
|
+
|
|
122
|
+
## Best Practices
|
|
123
|
+
|
|
124
|
+
### 1. Write Clear Descriptions
|
|
125
|
+
|
|
126
|
+
❌ **Too vague**:
|
|
127
|
+
```yaml
|
|
128
|
+
description: Helps with data
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
✅ **Specific**:
|
|
132
|
+
```yaml
|
|
133
|
+
description: Analyze Excel spreadsheets, generate pivot tables, create charts. Use when working with Excel files, spreadsheets, or .xlsx files.
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Tip**: Include both what the skill does AND when to use it.
|
|
137
|
+
|
|
138
|
+
### 2. Use Progressive Disclosure
|
|
139
|
+
|
|
140
|
+
Keep `SKILL.md` lean. Move detailed content to supporting files:
|
|
141
|
+
|
|
142
|
+
**SKILL.md**:
|
|
143
|
+
```markdown
|
|
144
|
+
## Quick Start
|
|
145
|
+
Basic instructions here.
|
|
146
|
+
|
|
147
|
+
For advanced patterns, see [reference.md](reference.md).
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**reference.md**:
|
|
151
|
+
```markdown
|
|
152
|
+
# Advanced Reference
|
|
153
|
+
Detailed documentation...
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### 3. Validate Your Skills
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
/skills validate
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Check for:
|
|
163
|
+
- Missing required fields
|
|
164
|
+
- Invalid name format
|
|
165
|
+
- Description length
|
|
166
|
+
- Unknown tools in allowed-tools
|
|
167
|
+
|
|
168
|
+
### 4. Test Skills
|
|
169
|
+
|
|
170
|
+
After creating a skill:
|
|
171
|
+
1. Restart Mentis to load it
|
|
172
|
+
2. Ask a question that should trigger the skill
|
|
173
|
+
3. Verify Mentis loads and uses the skill
|
|
174
|
+
|
|
175
|
+
## Example Skills
|
|
176
|
+
|
|
177
|
+
### commit-helper
|
|
178
|
+
|
|
179
|
+
```yaml
|
|
180
|
+
---
|
|
181
|
+
name: commit-helper
|
|
182
|
+
description: Generates clear, conventional commit messages from git diffs. Use when writing commit messages or reviewing staged changes.
|
|
183
|
+
allowed-tools: ["GitStatus", "GitDiff", "GitCommit"]
|
|
184
|
+
---
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### code-reviewer
|
|
188
|
+
|
|
189
|
+
```yaml
|
|
190
|
+
---
|
|
191
|
+
name: code-reviewer
|
|
192
|
+
description: Reviews code for best practices, potential bugs, security issues. Use when reviewing code or checking PRs.
|
|
193
|
+
allowed-tools: ["Read", "Grep", "Glob"]
|
|
194
|
+
---
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
See `examples/skills/` for complete examples.
|
|
198
|
+
|
|
199
|
+
## Troubleshooting
|
|
200
|
+
|
|
201
|
+
### Skill Not Loading
|
|
202
|
+
|
|
203
|
+
**Check 1**: File location
|
|
204
|
+
```bash
|
|
205
|
+
# Personal skills
|
|
206
|
+
ls ~/.mentis/skills/my-skill/SKILL.md
|
|
207
|
+
|
|
208
|
+
# Project skills
|
|
209
|
+
ls .mentis/skills/my-skill/SKILL.md
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
**Check 2**: YAML syntax
|
|
213
|
+
```bash
|
|
214
|
+
# Verify frontmatter format
|
|
215
|
+
cat ~/.mentis/skills/my-skill/SKILL.md | head -n 10
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Ensure:
|
|
219
|
+
- `---` on line 1
|
|
220
|
+
- `---` closes frontmatter
|
|
221
|
+
- Valid YAML (no tabs, correct indentation)
|
|
222
|
+
|
|
223
|
+
**Check 3**: Validation
|
|
224
|
+
```bash
|
|
225
|
+
/skills validate
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Mentis Not Using Skill
|
|
229
|
+
|
|
230
|
+
**Problem**: Skill exists but Mentis doesn't invoke it.
|
|
231
|
+
|
|
232
|
+
**Solution**: Improve description to include trigger keywords.
|
|
233
|
+
|
|
234
|
+
❌ **Vague**:
|
|
235
|
+
```yaml
|
|
236
|
+
description: Code improvement
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
✅ **Clear with triggers**:
|
|
240
|
+
```yaml
|
|
241
|
+
description: Refactor code for better performance and readability. Use when the user mentions optimization, refactoring, performance, or code cleanup.
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### allowed-tools Not Working
|
|
245
|
+
|
|
246
|
+
**Check**: Tool names must match Mentis tool names exactly.
|
|
247
|
+
|
|
248
|
+
Valid tools: `Read`, `Write`, `Edit`, `Grep`, `Glob`, `ListDir`, `SearchFile`, `RunShell`, `WebSearch`, `GitStatus`, `GitDiff`, `GitCommit`, `GitPush`, `GitPull`
|
|
249
|
+
|
|
250
|
+
## Sharing Skills
|
|
251
|
+
|
|
252
|
+
### Via Git (Project Skills)
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
# Add to repository
|
|
256
|
+
git add .mentis/skills/
|
|
257
|
+
git commit -m "Add team skill for X"
|
|
258
|
+
git push
|
|
259
|
+
|
|
260
|
+
# Team members get it automatically
|
|
261
|
+
git pull
|
|
262
|
+
# Skill is now available
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Via Manual Copy
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
# Export
|
|
269
|
+
tar czf my-skill.tar.gz -C ~/.mentis/skills my-skill
|
|
270
|
+
|
|
271
|
+
# Import on another machine
|
|
272
|
+
tar xzf my-skill.tar.gz -C ~/.mentis/skills
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## Advanced Topics
|
|
276
|
+
|
|
277
|
+
### Code Execution in Skills
|
|
278
|
+
|
|
279
|
+
Skills can include executable scripts:
|
|
280
|
+
|
|
281
|
+
```markdown
|
|
282
|
+
## Running the Script
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
python scripts/analyze.py data.csv
|
|
286
|
+
```
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Mentis will execute the script and return results.
|
|
290
|
+
|
|
291
|
+
### Tool Permissions
|
|
292
|
+
|
|
293
|
+
Use `allowed-tools` to:
|
|
294
|
+
- Restrict read-only skills from making changes
|
|
295
|
+
- Limit scope of specialized skills
|
|
296
|
+
- Add security for sensitive operations
|
|
297
|
+
|
|
298
|
+
```yaml
|
|
299
|
+
---
|
|
300
|
+
allowed-tools: ["Read", "Grep", "Glob"]
|
|
301
|
+
---
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
When this skill is active, only these tools can be used without explicit permission.
|
|
305
|
+
|
|
306
|
+
### Dynamic Tool Loading
|
|
307
|
+
|
|
308
|
+
The model can invoke tools to load skills:
|
|
309
|
+
|
|
310
|
+
```
|
|
311
|
+
load_skill({ name: "pdf-processing" })
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
This loads the full SKILL.md content into context.
|
|
315
|
+
|
|
316
|
+
## Resources
|
|
317
|
+
|
|
318
|
+
- [Claude Code Agent Skills](https://www.anthropic.com/engineering/equipping-agents-for-the-real-world-with-agent-skills) - Official announcement
|
|
319
|
+
- [examples/skills/](../examples/skills/) - Example skills directory
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-reviewer
|
|
3
|
+
description: Reviews code for best practices, potential bugs, security issues, and improvements. Use when reviewing code, checking pull requests, or analyzing code quality.
|
|
4
|
+
allowed-tools: ["Read", "Grep", "Glob"]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Code Reviewer
|
|
8
|
+
|
|
9
|
+
This skill provides systematic code review to identify issues and suggest improvements.
|
|
10
|
+
|
|
11
|
+
## Review Checklist
|
|
12
|
+
|
|
13
|
+
### 1. Code Organization
|
|
14
|
+
- [ ] Single Responsibility Principle followed
|
|
15
|
+
- [ ] Clear and descriptive names
|
|
16
|
+
- [ ] Proper separation of concerns
|
|
17
|
+
- [ ] Appropriate abstraction levels
|
|
18
|
+
|
|
19
|
+
### 2. Error Handling
|
|
20
|
+
- [ ] Proper error handling for all operations
|
|
21
|
+
- [ ] Meaningful error messages
|
|
22
|
+
- [ ] Graceful degradation
|
|
23
|
+
- [ ] No silent failures
|
|
24
|
+
|
|
25
|
+
### 3. Performance
|
|
26
|
+
- [ ] No obvious performance issues
|
|
27
|
+
- [ ] Appropriate data structures used
|
|
28
|
+
- [ ] Caching where applicable
|
|
29
|
+
- [ ] Resource cleanup (no memory leaks)
|
|
30
|
+
|
|
31
|
+
### 4. Security
|
|
32
|
+
- [ ] Input validation
|
|
33
|
+
- [ ] No hardcoded credentials
|
|
34
|
+
- [ ] SQL injection prevention
|
|
35
|
+
- [ ] XSS prevention (web apps)
|
|
36
|
+
- [ ] Proper authentication/authorization
|
|
37
|
+
|
|
38
|
+
### 5. Testing
|
|
39
|
+
- [ ] Test coverage adequate
|
|
40
|
+
- [ ] Edge cases considered
|
|
41
|
+
- [ ] Error scenarios tested
|
|
42
|
+
|
|
43
|
+
### 6. Documentation
|
|
44
|
+
- [ ] Complex logic explained
|
|
45
|
+
- [ ] Public API documented
|
|
46
|
+
- [ ] Usage examples provided
|
|
47
|
+
|
|
48
|
+
## How to Review
|
|
49
|
+
|
|
50
|
+
1. **Understand the purpose**: What is this code supposed to do?
|
|
51
|
+
2. **Read the code**: Follow the execution flow
|
|
52
|
+
3. **Check against checklist**: Go through each category
|
|
53
|
+
4. **Provide feedback**:
|
|
54
|
+
- **Critical**: Must fix before merge
|
|
55
|
+
- **Important**: Should fix
|
|
56
|
+
- **Suggestion**: Nice to have
|
|
57
|
+
5. **Explain why**: Don't just point out problems
|
|
58
|
+
|
|
59
|
+
## Feedback Format
|
|
60
|
+
|
|
61
|
+
```markdown
|
|
62
|
+
## Critical Issues
|
|
63
|
+
- Issue description
|
|
64
|
+
- Location: file.ts:123
|
|
65
|
+
- Why: [reason]
|
|
66
|
+
- Suggestion: [fix]
|
|
67
|
+
|
|
68
|
+
## Important Notes
|
|
69
|
+
- Note description
|
|
70
|
+
- Location: file.ts:456
|
|
71
|
+
|
|
72
|
+
## Suggestions
|
|
73
|
+
- Suggestion description
|
|
74
|
+
- Could improve [aspect]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Common Issues to Look For
|
|
78
|
+
|
|
79
|
+
| Issue | Example |
|
|
80
|
+
|-------|---------|
|
|
81
|
+
| Unhandled promises | No `.catch()` or `await` without try/catch |
|
|
82
|
+
| Missing null checks | Accessing properties without null check |
|
|
83
|
+
| Race conditions | Async operations without proper ordering |
|
|
84
|
+
| Resource leaks | File handles, connections not closed |
|
|
85
|
+
| Type coercion | Using `==` instead of `===` |
|
|
86
|
+
| Magic numbers | Unexplained numeric literals |
|
|
87
|
+
| Large functions | Functions > 50 lines |
|
|
88
|
+
| Deep nesting | More than 3 levels of nesting |
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: commit-helper
|
|
3
|
+
description: Generates clear, conventional commit messages from git diffs. Use when writing commit messages, reviewing staged changes, or when the user asks for help with git commits.
|
|
4
|
+
allowed-tools: ["GitStatus", "GitDiff", "GitCommit"]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Commit Message Helper
|
|
8
|
+
|
|
9
|
+
This skill helps you write clear, informative git commit messages following conventional commit format.
|
|
10
|
+
|
|
11
|
+
## Instructions
|
|
12
|
+
|
|
13
|
+
When the user wants to commit changes:
|
|
14
|
+
|
|
15
|
+
1. **Check git status** to see what files are staged
|
|
16
|
+
2. **Review the diff** to understand what changed
|
|
17
|
+
3. **Generate a commit message** with:
|
|
18
|
+
- **Type**: One of `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore`
|
|
19
|
+
- **Scope**: (optional) The component or module affected
|
|
20
|
+
- **Summary**: Brief description under 50 characters
|
|
21
|
+
- **Body**: Detailed explanation of what and why (not how)
|
|
22
|
+
- **Footer**: (optional) Breaking changes or references
|
|
23
|
+
|
|
24
|
+
## Commit Types
|
|
25
|
+
|
|
26
|
+
| Type | Description |
|
|
27
|
+
|------|-------------|
|
|
28
|
+
| `feat` | New feature |
|
|
29
|
+
| `fix` | Bug fix |
|
|
30
|
+
| `docs` | Documentation changes |
|
|
31
|
+
| `style` | Code style changes (formatting, etc.) |
|
|
32
|
+
| `refactor` | Code refactoring |
|
|
33
|
+
| `test` | Adding or updating tests |
|
|
34
|
+
| `chore` | Maintenance tasks |
|
|
35
|
+
|
|
36
|
+
## Examples
|
|
37
|
+
|
|
38
|
+
### Feature Addition
|
|
39
|
+
```
|
|
40
|
+
feat(api): add user authentication endpoint
|
|
41
|
+
|
|
42
|
+
Add OAuth2 authentication for the REST API.
|
|
43
|
+
Implements login, logout, and token refresh.
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Bug Fix
|
|
47
|
+
```
|
|
48
|
+
fix(cli): prevent crash when config file is missing
|
|
49
|
+
|
|
50
|
+
Check for config file existence before reading.
|
|
51
|
+
Show helpful error message if file not found.
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Documentation
|
|
55
|
+
```
|
|
56
|
+
docs: update README with new installation instructions
|
|
57
|
+
|
|
58
|
+
Clarify NPM installation steps and add troubleshooting section.
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Best Practices
|
|
62
|
+
|
|
63
|
+
- Use present tense ("add" not "added")
|
|
64
|
+
- Explain what and why, not how
|
|
65
|
+
- Keep summary under 50 characters
|
|
66
|
+
- Reference issues in footer: `Closes #123`
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pdf-processing
|
|
3
|
+
description: Extract text, fill forms, merge PDFs, and manipulate PDF documents. Use when working with PDF files, forms, or document extraction. Requires pdf-parse package.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# PDF Processing
|
|
7
|
+
|
|
8
|
+
This skill provides PDF manipulation capabilities for text extraction, form filling, and document operations.
|
|
9
|
+
|
|
10
|
+
## Prerequisites
|
|
11
|
+
|
|
12
|
+
Install required packages:
|
|
13
|
+
```bash
|
|
14
|
+
npm install pdf-parse
|
|
15
|
+
# or
|
|
16
|
+
pnpm add pdf-parse
|
|
17
|
+
# or
|
|
18
|
+
yarn add pdf-parse
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Capabilities
|
|
22
|
+
|
|
23
|
+
### 1. Text Extraction
|
|
24
|
+
Extract plain text from PDF files with page-by-page information.
|
|
25
|
+
|
|
26
|
+
### 2. Form Field Detection
|
|
27
|
+
Identify and extract form fields from PDF documents.
|
|
28
|
+
|
|
29
|
+
### 3. Metadata Reading
|
|
30
|
+
Access PDF metadata like author, creation date, title.
|
|
31
|
+
|
|
32
|
+
### 4. Page Count & Info
|
|
33
|
+
Get total pages and document dimensions.
|
|
34
|
+
|
|
35
|
+
## Common Operations
|
|
36
|
+
|
|
37
|
+
### Extract All Text
|
|
38
|
+
```typescript
|
|
39
|
+
import fs from 'fs';
|
|
40
|
+
import pdf from 'pdf-parse';
|
|
41
|
+
|
|
42
|
+
const dataBuffer = fs.readFileSync('document.pdf');
|
|
43
|
+
const data = await pdf(dataBuffer);
|
|
44
|
+
|
|
45
|
+
console.log(data.text); // Full text content
|
|
46
|
+
console.log(data.numpages); // Number of pages
|
|
47
|
+
console.log(data.info); // PDF metadata
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Extract Text by Page
|
|
51
|
+
```typescript
|
|
52
|
+
const data = await pdf(dataBuffer);
|
|
53
|
+
// Text includes page breaks
|
|
54
|
+
// Split by page markers if needed
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Get PDF Info
|
|
58
|
+
```typescript
|
|
59
|
+
const data = await pdf(dataBuffer);
|
|
60
|
+
console.log({
|
|
61
|
+
pages: data.numpages,
|
|
62
|
+
info: data.info,
|
|
63
|
+
metadata: data.metadata
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Troubleshooting
|
|
68
|
+
|
|
69
|
+
### "pdf-parse not found"
|
|
70
|
+
Install the package: `npm install pdf-parse`
|
|
71
|
+
|
|
72
|
+
### Scanned PDFs return no text
|
|
73
|
+
Scanned PDFs are images. Use OCR (tesseract.js) instead.
|
|
74
|
+
|
|
75
|
+
### Encrypted PDFs
|
|
76
|
+
Password-protected PDFs cannot be read. Remove password first.
|
|
77
|
+
|
|
78
|
+
### Memory Issues with Large Files
|
|
79
|
+
For very large PDFs (>100MB), process in chunks or use streaming.
|
|
80
|
+
|
|
81
|
+
## Advanced Topics
|
|
82
|
+
|
|
83
|
+
For advanced PDF operations like filling forms, merging, or creating PDFs, see [ADVANCED.md](ADVANCED.md).
|
|
84
|
+
|
|
85
|
+
## Examples
|
|
86
|
+
|
|
87
|
+
### Quick Text Extraction
|
|
88
|
+
```bash
|
|
89
|
+
# User asks: "Extract text from this PDF"
|
|
90
|
+
# 1. Read the PDF file
|
|
91
|
+
# 2. Use pdf-parse to extract text
|
|
92
|
+
# 3. Return the text content
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Get Page Count
|
|
96
|
+
```bash
|
|
97
|
+
# User asks: "How many pages in this PDF?"
|
|
98
|
+
# 1. Parse the PDF
|
|
99
|
+
# 2. Return numpages value
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Form Analysis
|
|
103
|
+
```bash
|
|
104
|
+
# User asks: "What fields are in this PDF form?"
|
|
105
|
+
# 1. Parse the PDF
|
|
106
|
+
# 2. Look for form field patterns
|
|
107
|
+
# 3. List detected fields
|
|
108
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@indiccoder/mentis-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -50,7 +50,8 @@
|
|
|
50
50
|
"screenshot-desktop": "^1.15.3",
|
|
51
51
|
"uuid": "^13.0.0",
|
|
52
52
|
"vscode-ripgrep": "^1.13.2",
|
|
53
|
-
"xlsx": "^0.18.5"
|
|
53
|
+
"xlsx": "^0.18.5",
|
|
54
|
+
"yaml": "^2.7.0"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
57
|
"@types/figlet": "^1.7.0",
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
import { ReplManager } from './repl/ReplManager';
|
|
3
3
|
|
|
4
4
|
async function main() {
|
|
5
|
+
if (process.argv.includes('update')) {
|
|
6
|
+
const { UpdateManager } = require('./utils/UpdateManager');
|
|
7
|
+
const updater = new UpdateManager();
|
|
8
|
+
await updater.checkAndPerformUpdate(true);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
5
12
|
const repl = new ReplManager();
|
|
6
13
|
await repl.start();
|
|
7
14
|
}
|