@amirdaraee/namewise 0.3.1 → 0.4.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.
- package/.github/workflows/build.yml +55 -0
- package/.github/workflows/publish.yml +113 -22
- package/.github/workflows/test.yml +18 -8
- package/README.md +85 -9
- package/RELEASE.md +167 -0
- package/dist/cli/commands.d.ts.map +1 -1
- package/dist/cli/commands.js +44 -7
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/rename.d.ts.map +1 -1
- package/dist/cli/rename.js +27 -12
- package/dist/cli/rename.js.map +1 -1
- package/dist/index.js +39 -2
- package/dist/index.js.map +1 -1
- package/dist/services/ai-factory.d.ts +6 -1
- package/dist/services/ai-factory.d.ts.map +1 -1
- package/dist/services/ai-factory.js +11 -1
- package/dist/services/ai-factory.js.map +1 -1
- package/dist/services/claude-service.d.ts.map +1 -1
- package/dist/services/claude-service.js +9 -55
- package/dist/services/claude-service.js.map +1 -1
- package/dist/services/file-renamer.d.ts.map +1 -1
- package/dist/services/file-renamer.js +20 -4
- package/dist/services/file-renamer.js.map +1 -1
- package/dist/services/lmstudio-service.d.ts +14 -0
- package/dist/services/lmstudio-service.d.ts.map +1 -0
- package/dist/services/lmstudio-service.js +99 -0
- package/dist/services/lmstudio-service.js.map +1 -0
- package/dist/services/ollama-service.d.ts +14 -0
- package/dist/services/ollama-service.d.ts.map +1 -0
- package/dist/services/ollama-service.js +97 -0
- package/dist/services/ollama-service.js.map +1 -0
- package/dist/services/openai-service.d.ts.map +1 -1
- package/dist/services/openai-service.js +9 -55
- package/dist/services/openai-service.js.map +1 -1
- package/dist/types/index.d.ts +6 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/ai-prompts.d.ts +20 -0
- package/dist/utils/ai-prompts.d.ts.map +1 -0
- package/dist/utils/ai-prompts.js +71 -0
- package/dist/utils/ai-prompts.js.map +1 -0
- package/package.json +1 -1
- package/src/cli/commands.ts +44 -7
- package/src/cli/rename.ts +26 -12
- package/src/index.ts +39 -2
- package/src/services/ai-factory.ts +24 -1
- package/src/services/claude-service.ts +10 -48
- package/src/services/file-renamer.ts +22 -4
- package/src/services/lmstudio-service.ts +152 -0
- package/src/services/ollama-service.ts +138 -0
- package/src/services/openai-service.ts +10 -48
- package/src/types/index.ts +7 -2
- package/src/utils/ai-prompts.ts +76 -0
- package/tests/data/console-test-1.txt +1 -0
- package/tests/data/console-test-2.txt +1 -0
- package/tests/data/console-test-long-filename-for-display-testing.txt +1 -0
- package/tests/data/failure.txt +1 -0
- package/tests/data/file1.txt +1 -0
- package/tests/data/file2.txt +1 -0
- package/tests/data/much-longer-filename-to-test-clearing.txt +1 -0
- package/tests/data/short.txt +1 -0
- package/tests/data/single-file.txt +1 -0
- package/tests/data/success.txt +1 -0
- package/tests/data/this-is-a-very-long-filename-that-should-be-truncated-for-better-display-purposes.txt +1 -0
- package/tests/data/very-long-filename-that-should-be-cleared-properly.txt +1 -0
- package/tests/data/x.txt +1 -0
- package/tests/integration/ai-prompting.test.ts +386 -0
- package/tests/integration/end-to-end.test.ts +2 -2
- package/tests/integration/person-name-extraction.test.ts +440 -0
- package/tests/unit/cli/commands.test.ts +5 -5
- package/tests/unit/services/ai-factory.test.ts +49 -1
- package/tests/unit/services/file-renamer.test.ts +215 -0
- package/tests/unit/services/lmstudio-service.test.ts +326 -0
- package/tests/unit/services/ollama-service.test.ts +264 -0
- package/tests/unit/utils/ai-prompts.test.ts +213 -0
- package/.github/workflows/ci.yml +0 -78
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
name: Build Pipeline
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch: # Allows manual triggering
|
|
5
|
+
push:
|
|
6
|
+
branches: [ main ]
|
|
7
|
+
workflow_call: # Allows this workflow to be called by other workflows
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
name: Run Tests Before Build
|
|
12
|
+
uses: ./.github/workflows/test.yml
|
|
13
|
+
|
|
14
|
+
build:
|
|
15
|
+
name: Build Project
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
needs: [test]
|
|
18
|
+
if: ${{ needs.test.result == 'success' }}
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- name: Checkout code
|
|
22
|
+
uses: actions/checkout@v4
|
|
23
|
+
|
|
24
|
+
- name: Setup Node.js
|
|
25
|
+
uses: actions/setup-node@v4
|
|
26
|
+
with:
|
|
27
|
+
node-version: '22'
|
|
28
|
+
cache: 'npm'
|
|
29
|
+
|
|
30
|
+
- name: Install dependencies
|
|
31
|
+
run: npm ci
|
|
32
|
+
|
|
33
|
+
- name: Build project
|
|
34
|
+
run: npm run build
|
|
35
|
+
|
|
36
|
+
- name: Test CLI build
|
|
37
|
+
run: |
|
|
38
|
+
node dist/index.js --help
|
|
39
|
+
node dist/index.js --version
|
|
40
|
+
|
|
41
|
+
- name: Upload build artifacts
|
|
42
|
+
uses: actions/upload-artifact@v4
|
|
43
|
+
with:
|
|
44
|
+
name: build-artifacts-${{ github.sha }}
|
|
45
|
+
path: |
|
|
46
|
+
dist/
|
|
47
|
+
package.json
|
|
48
|
+
package-lock.json
|
|
49
|
+
README.md
|
|
50
|
+
LICENSE
|
|
51
|
+
CHANGELOG.md
|
|
52
|
+
retention-days: 30
|
|
53
|
+
|
|
54
|
+
- name: Build success notification
|
|
55
|
+
run: echo "✅ Build completed successfully for commit ${{ github.sha }}"
|
|
@@ -1,43 +1,134 @@
|
|
|
1
|
-
name: Publish
|
|
1
|
+
name: Publish Pipeline
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
|
+
workflow_dispatch: # Allows manual triggering
|
|
5
|
+
inputs:
|
|
6
|
+
use_artifact:
|
|
7
|
+
description: 'Use build artifact (provide artifact name or "latest")'
|
|
8
|
+
required: false
|
|
9
|
+
default: ''
|
|
4
10
|
release:
|
|
5
|
-
types: [
|
|
11
|
+
types: [published]
|
|
6
12
|
|
|
7
13
|
jobs:
|
|
8
|
-
|
|
14
|
+
build:
|
|
15
|
+
name: Build for Publishing
|
|
16
|
+
uses: ./.github/workflows/build.yml
|
|
17
|
+
if: ${{ github.event.inputs.use_artifact == '' }}
|
|
18
|
+
|
|
19
|
+
publish:
|
|
20
|
+
name: Publish Package
|
|
9
21
|
runs-on: ubuntu-latest
|
|
22
|
+
needs: [build]
|
|
23
|
+
if: ${{ always() && (needs.build.result == 'success' || github.event.inputs.use_artifact != '') }}
|
|
24
|
+
environment: production # Requires environment approval for production
|
|
25
|
+
|
|
10
26
|
steps:
|
|
11
|
-
-
|
|
12
|
-
|
|
27
|
+
- name: Checkout code
|
|
28
|
+
uses: actions/checkout@v4
|
|
29
|
+
|
|
30
|
+
- name: Setup Node.js
|
|
31
|
+
uses: actions/setup-node@v4
|
|
13
32
|
with:
|
|
14
33
|
node-version: '22'
|
|
15
|
-
registry-url: https://registry.npmjs.org
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
-
|
|
19
|
-
|
|
34
|
+
registry-url: 'https://registry.npmjs.org'
|
|
35
|
+
cache: 'npm'
|
|
36
|
+
|
|
37
|
+
- name: Download build artifacts (from current run)
|
|
38
|
+
if: ${{ github.event.inputs.use_artifact == '' }}
|
|
39
|
+
uses: actions/download-artifact@v4
|
|
40
|
+
with:
|
|
41
|
+
name: build-artifacts-${{ github.sha }}
|
|
42
|
+
path: ./
|
|
43
|
+
|
|
44
|
+
- name: Download build artifacts (from specific run)
|
|
45
|
+
if: ${{ github.event.inputs.use_artifact != '' && github.event.inputs.use_artifact != 'latest' }}
|
|
46
|
+
uses: actions/download-artifact@v4
|
|
47
|
+
with:
|
|
48
|
+
name: ${{ github.event.inputs.use_artifact }}
|
|
49
|
+
path: ./
|
|
50
|
+
|
|
51
|
+
- name: Download latest build artifacts
|
|
52
|
+
if: ${{ github.event.inputs.use_artifact == 'latest' }}
|
|
53
|
+
run: |
|
|
54
|
+
echo "Downloading latest build artifacts..."
|
|
55
|
+
gh run download --name "build-artifacts-*" --limit 1
|
|
56
|
+
env:
|
|
57
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
58
|
+
|
|
59
|
+
- name: Install dependencies (only for package.json)
|
|
60
|
+
run: npm ci --production
|
|
61
|
+
|
|
62
|
+
- name: Publish to NPM
|
|
63
|
+
run: npm publish
|
|
20
64
|
env:
|
|
21
65
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
66
|
+
|
|
67
|
+
- name: Publish success notification
|
|
68
|
+
run: echo "✅ Package published to NPM successfully"
|
|
22
69
|
|
|
23
|
-
publish-
|
|
70
|
+
publish-github:
|
|
71
|
+
name: Publish to GitHub Packages
|
|
24
72
|
runs-on: ubuntu-latest
|
|
73
|
+
needs: [build, publish]
|
|
74
|
+
if: ${{ always() && needs.publish.result == 'success' }}
|
|
25
75
|
permissions:
|
|
26
76
|
contents: read
|
|
27
77
|
packages: write
|
|
78
|
+
|
|
28
79
|
steps:
|
|
29
|
-
-
|
|
30
|
-
|
|
80
|
+
- name: Checkout code
|
|
81
|
+
uses: actions/checkout@v4
|
|
82
|
+
|
|
83
|
+
- name: Setup Node.js
|
|
84
|
+
uses: actions/setup-node@v4
|
|
31
85
|
with:
|
|
32
86
|
node-version: '22'
|
|
33
|
-
registry-url: https://npm.pkg.github.com
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
-
|
|
37
|
-
|
|
87
|
+
registry-url: 'https://npm.pkg.github.com'
|
|
88
|
+
cache: 'npm'
|
|
89
|
+
|
|
90
|
+
- name: Download build artifacts (reuse from publish job)
|
|
91
|
+
if: ${{ github.event.inputs.use_artifact == '' }}
|
|
92
|
+
uses: actions/download-artifact@v4
|
|
93
|
+
with:
|
|
94
|
+
name: build-artifacts-${{ github.sha }}
|
|
95
|
+
path: ./
|
|
96
|
+
|
|
97
|
+
- name: Download build artifacts (from specific run)
|
|
98
|
+
if: ${{ github.event.inputs.use_artifact != '' && github.event.inputs.use_artifact != 'latest' }}
|
|
99
|
+
uses: actions/download-artifact@v4
|
|
100
|
+
with:
|
|
101
|
+
name: ${{ github.event.inputs.use_artifact }}
|
|
102
|
+
path: ./
|
|
103
|
+
|
|
104
|
+
- name: Download latest build artifacts
|
|
105
|
+
if: ${{ github.event.inputs.use_artifact == 'latest' }}
|
|
38
106
|
run: |
|
|
39
|
-
echo "
|
|
40
|
-
|
|
41
|
-
|
|
107
|
+
echo "Downloading latest build artifacts..."
|
|
108
|
+
gh run download --name "build-artifacts-*" --limit 1
|
|
109
|
+
env:
|
|
110
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
111
|
+
|
|
112
|
+
- name: Install dependencies (only for package.json)
|
|
113
|
+
run: npm ci --production
|
|
114
|
+
|
|
115
|
+
- name: Configure package for GitHub Packages
|
|
116
|
+
run: |
|
|
117
|
+
cp package.json package.json.backup
|
|
118
|
+
node -e "
|
|
119
|
+
const pkg = require('./package.json');
|
|
120
|
+
pkg.name = '@${{ github.repository_owner }}/' + pkg.name.split('/').pop();
|
|
121
|
+
require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2));
|
|
122
|
+
"
|
|
123
|
+
|
|
124
|
+
- name: Publish to GitHub Packages
|
|
125
|
+
run: npm publish
|
|
42
126
|
env:
|
|
43
|
-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
127
|
+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
128
|
+
|
|
129
|
+
- name: Restore original package.json
|
|
130
|
+
run: mv package.json.backup package.json
|
|
131
|
+
if: always()
|
|
132
|
+
|
|
133
|
+
- name: GitHub Packages success notification
|
|
134
|
+
run: echo "✅ Package published to GitHub Packages successfully"
|
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
name: Test
|
|
1
|
+
name: Test Pipeline
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
|
+
workflow_dispatch: # Allows manual triggering
|
|
5
|
+
workflow_call: # Allows this workflow to be called by other workflows
|
|
4
6
|
push:
|
|
5
|
-
branches: [ main ]
|
|
7
|
+
branches: [ main, develop ]
|
|
6
8
|
pull_request:
|
|
7
9
|
branches: [ main ]
|
|
8
10
|
|
|
9
11
|
jobs:
|
|
10
12
|
test:
|
|
13
|
+
name: Run Tests
|
|
11
14
|
runs-on: ubuntu-latest
|
|
12
15
|
|
|
13
16
|
strategy:
|
|
14
17
|
matrix:
|
|
15
18
|
node-version: [18, 20, 22]
|
|
16
|
-
|
|
19
|
+
|
|
17
20
|
steps:
|
|
18
|
-
-
|
|
21
|
+
- name: Checkout code
|
|
22
|
+
uses: actions/checkout@v4
|
|
19
23
|
|
|
20
24
|
- name: Setup Node.js ${{ matrix.node-version }}
|
|
21
25
|
uses: actions/setup-node@v4
|
|
@@ -26,12 +30,18 @@ jobs:
|
|
|
26
30
|
- name: Install dependencies
|
|
27
31
|
run: npm ci
|
|
28
32
|
|
|
29
|
-
- name:
|
|
30
|
-
run: npm run
|
|
33
|
+
- name: Run linter (if available)
|
|
34
|
+
run: npm run lint --if-present
|
|
31
35
|
|
|
32
36
|
- name: Run tests
|
|
33
37
|
run: npm run test:run
|
|
34
38
|
|
|
35
|
-
- name:
|
|
39
|
+
- name: Generate coverage report
|
|
36
40
|
run: npm run test:coverage
|
|
37
|
-
if: matrix.node-version == '22'
|
|
41
|
+
if: matrix.node-version == '22'
|
|
42
|
+
|
|
43
|
+
- name: Upload coverage reports
|
|
44
|
+
uses: codecov/codecov-action@v3
|
|
45
|
+
if: matrix.node-version == '22'
|
|
46
|
+
with:
|
|
47
|
+
fail_ci_if_error: false
|
package/README.md
CHANGED
|
@@ -8,13 +8,15 @@
|
|
|
8
8
|
|
|
9
9
|
🤖 **AI-Powered File Renaming CLI Tool**
|
|
10
10
|
|
|
11
|
-
Automatically rename files based on their content using Claude
|
|
11
|
+
Automatically rename files based on their content using AI providers (Claude, OpenAI, Ollama, LMStudio). Transform messy filenames like `document1.pdf` or `IMG_20240315_143022.pdf` into descriptive names like `project-requirements-document.pdf` or `quarterly-sales-report-q4-2023.pdf`.
|
|
12
12
|
|
|
13
13
|
> **Perfect for**: Document management, file organization, bulk renaming based on content analysis
|
|
14
14
|
|
|
15
15
|
## Features
|
|
16
16
|
|
|
17
|
-
- **AI-Powered Renaming**: Uses Claude or
|
|
17
|
+
- **AI-Powered Renaming**: Uses cloud providers (Claude, OpenAI) or local LLMs (Ollama, LMStudio) to generate descriptive filenames
|
|
18
|
+
- **Privacy First**: Local LLM support means your files never leave your machine
|
|
19
|
+
- **Cost Effective**: Use free local models or pay-per-use cloud APIs
|
|
18
20
|
- **Personal File Templates**: Customizable templates for different file categories (documents, movies, music, series, photos, books)
|
|
19
21
|
- **Smart Categorization**: Automatic file type detection or manual category selection
|
|
20
22
|
- **Naming Convention Options**: 6 different formats (kebab-case, snake_case, camelCase, PascalCase, lowercase, UPPERCASE)
|
|
@@ -63,7 +65,9 @@ namewise rename <directory> [options]
|
|
|
63
65
|
### Options Reference
|
|
64
66
|
| Option | Description | Default |
|
|
65
67
|
|--------|-------------|---------|
|
|
66
|
-
| `--provider` | AI provider (`claude`
|
|
68
|
+
| `--provider` | AI provider (`claude`, `openai`, `ollama`, `lmstudio`) | `claude` |
|
|
69
|
+
| `--base-url` | Base URL for local LLM providers | Auto-detected |
|
|
70
|
+
| `--model` | Model name for local LLM providers | Provider default |
|
|
67
71
|
| `--api-key` | API key for the chosen provider | Interactive prompt |
|
|
68
72
|
| `--case` | Naming convention (kebab-case, snake_case, camelCase, PascalCase, lowercase, UPPERCASE) | `kebab-case` |
|
|
69
73
|
| `--template` | File category template (document, movie, music, series, photo, book, general, auto) | `general` |
|
|
@@ -110,6 +114,35 @@ namewise rename ./docs --case snake_case --dry-run
|
|
|
110
114
|
# Result: project_requirements_document.pdf
|
|
111
115
|
```
|
|
112
116
|
|
|
117
|
+
**Local LLMs (Privacy-First, No API Keys):**
|
|
118
|
+
```bash
|
|
119
|
+
# Ollama - requires 'ollama serve' running
|
|
120
|
+
namewise rename ./documents --provider ollama --dry-run
|
|
121
|
+
# Result: quarterly-financial-report.pdf
|
|
122
|
+
|
|
123
|
+
# Custom Ollama model
|
|
124
|
+
namewise rename ./code --provider ollama --model codellama --dry-run
|
|
125
|
+
# Result: user-authentication-service.js
|
|
126
|
+
|
|
127
|
+
# LMStudio - requires local server enabled
|
|
128
|
+
namewise rename ./contracts --provider lmstudio --dry-run
|
|
129
|
+
# Result: employment-agreement-template.docx
|
|
130
|
+
|
|
131
|
+
# Remote Ollama server
|
|
132
|
+
namewise rename ./files --provider ollama --base-url http://192.168.1.100:11434 --model llama3.1
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Cloud Providers (API Keys Required):**
|
|
136
|
+
```bash
|
|
137
|
+
# Claude (recommended for accuracy)
|
|
138
|
+
export CLAUDE_API_KEY=your-key
|
|
139
|
+
namewise rename ./documents --provider claude --dry-run
|
|
140
|
+
|
|
141
|
+
# OpenAI
|
|
142
|
+
export OPENAI_API_KEY=your-key
|
|
143
|
+
namewise rename ./files --provider openai --max-size 20 --dry-run
|
|
144
|
+
```
|
|
145
|
+
|
|
113
146
|
**Before and After Example:**
|
|
114
147
|
```
|
|
115
148
|
📁 Before:
|
|
@@ -147,19 +180,54 @@ Choose from specialized templates for different file types:
|
|
|
147
180
|
| `book` | `{author}-{content}` | `george-orwell-1984.pdf` | Books and ebooks |
|
|
148
181
|
| `auto` | *Automatic* | *Varies by detected type* | Let AI detect and choose best template |
|
|
149
182
|
|
|
150
|
-
## 🔑
|
|
183
|
+
## 🔑 AI Provider Setup
|
|
184
|
+
|
|
185
|
+
### 🏠 Local LLMs (Privacy-First, No API Keys)
|
|
151
186
|
|
|
152
|
-
|
|
187
|
+
**Ollama** - Recommended for privacy
|
|
188
|
+
1. Install: Download from [ollama.ai](https://ollama.ai)
|
|
189
|
+
2. Start server: `ollama serve`
|
|
190
|
+
3. Pull model: `ollama pull llama3.1` (or your preferred model)
|
|
191
|
+
4. Use: `--provider ollama`
|
|
192
|
+
|
|
193
|
+
**LMStudio** - User-friendly interface
|
|
194
|
+
1. Install: Download from [lmstudio.ai](https://lmstudio.ai)
|
|
195
|
+
2. Download and load a model in LMStudio
|
|
196
|
+
3. Enable "Local Server" mode in LMStudio
|
|
197
|
+
4. Use: `--provider lmstudio`
|
|
198
|
+
|
|
199
|
+
### ☁️ Cloud Providers (Require API Keys)
|
|
200
|
+
|
|
201
|
+
**Claude (Anthropic)** - Recommended for accuracy
|
|
153
202
|
1. Visit [Anthropic Console](https://console.anthropic.com/)
|
|
154
203
|
2. Create an account and generate an API key
|
|
155
204
|
3. Set as environment variable: `export CLAUDE_API_KEY=your-key`
|
|
156
205
|
|
|
157
|
-
|
|
206
|
+
**OpenAI**
|
|
158
207
|
1. Visit [OpenAI Platform](https://platform.openai.com/api-keys)
|
|
159
208
|
2. Create an API key
|
|
160
209
|
3. Set as environment variable: `export OPENAI_API_KEY=your-key`
|
|
161
210
|
|
|
162
|
-
|
|
211
|
+
### 🚀 Quick Start by Privacy Preference
|
|
212
|
+
|
|
213
|
+
**Maximum Privacy (Local Processing):**
|
|
214
|
+
```bash
|
|
215
|
+
# Setup Ollama
|
|
216
|
+
ollama serve
|
|
217
|
+
ollama pull llama3.1
|
|
218
|
+
|
|
219
|
+
# Use locally - no data leaves your machine
|
|
220
|
+
namewise rename ./documents --provider ollama --dry-run
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Balanced (Cloud with API key):**
|
|
224
|
+
```bash
|
|
225
|
+
# Use Claude for best accuracy
|
|
226
|
+
export CLAUDE_API_KEY=your-key
|
|
227
|
+
namewise rename ./documents --provider claude --dry-run
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
> 💡 **Tip**: Local LLMs require no API keys and keep your data private. Cloud providers may offer better accuracy but require API keys and send data externally.
|
|
163
231
|
|
|
164
232
|
## ⚙️ How It Works
|
|
165
233
|
|
|
@@ -214,7 +282,9 @@ The project includes comprehensive tests with 65 test cases covering all functio
|
|
|
214
282
|
|
|
215
283
|
- **Node.js**: 18.0.0 or higher
|
|
216
284
|
- **TypeScript**: 5.0.0 or higher
|
|
217
|
-
- **
|
|
285
|
+
- **AI Provider**: Choose one:
|
|
286
|
+
- **Local**: Ollama or LMStudio (no API key needed)
|
|
287
|
+
- **Cloud**: Claude (Anthropic) or OpenAI API key
|
|
218
288
|
|
|
219
289
|
## 🐛 Troubleshooting
|
|
220
290
|
|
|
@@ -226,11 +296,17 @@ The project includes comprehensive tests with 65 test cases covering all functio
|
|
|
226
296
|
- Check file is not corrupted
|
|
227
297
|
- Try reducing max-size limit
|
|
228
298
|
|
|
229
|
-
**API errors:**
|
|
299
|
+
**API errors (Cloud providers):**
|
|
230
300
|
- Verify API key is valid
|
|
231
301
|
- Check internet connection
|
|
232
302
|
- Ensure sufficient API credits
|
|
233
303
|
|
|
304
|
+
**Local LLM connection errors:**
|
|
305
|
+
- Ensure Ollama server is running (`ollama serve`)
|
|
306
|
+
- Check LMStudio local server is enabled
|
|
307
|
+
- Verify correct base URL and port
|
|
308
|
+
- Confirm model is loaded/available
|
|
309
|
+
|
|
234
310
|
**Permission errors:**
|
|
235
311
|
- Check file permissions
|
|
236
312
|
- Run with appropriate user privileges
|
package/RELEASE.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# Release Process Documentation
|
|
2
|
+
|
|
3
|
+
This document explains how to release a new version of the Namewise CLI tool.
|
|
4
|
+
|
|
5
|
+
## Quick Release Commands
|
|
6
|
+
|
|
7
|
+
Based on your `package.json` scripts, you can use these commands for automated releases:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm run release # Patch version (1.0.0 → 1.0.1)
|
|
11
|
+
npm run release:minor # Minor version (1.0.0 → 1.1.0)
|
|
12
|
+
npm run release:major # Major version (1.0.0 → 2.0.0)
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
These commands will:
|
|
16
|
+
1. Run tests and build
|
|
17
|
+
2. Bump the version in `package.json`
|
|
18
|
+
3. Trigger the auto-release workflow
|
|
19
|
+
|
|
20
|
+
## Manual Release Process
|
|
21
|
+
|
|
22
|
+
If you prefer to do it manually:
|
|
23
|
+
|
|
24
|
+
### 1. Prepare the Release
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Ensure you're on main branch with latest changes
|
|
28
|
+
git checkout main
|
|
29
|
+
git pull origin main
|
|
30
|
+
|
|
31
|
+
# Run tests and build to ensure everything works
|
|
32
|
+
npm run test:run
|
|
33
|
+
npm run build
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 2. Update Version
|
|
37
|
+
|
|
38
|
+
Choose the appropriate version bump:
|
|
39
|
+
- **Patch** (bug fixes): `1.0.0 → 1.0.1`
|
|
40
|
+
- **Minor** (new features): `1.0.0 → 1.1.0`
|
|
41
|
+
- **Major** (breaking changes): `1.0.0 → 2.0.0`
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Update version in package.json
|
|
45
|
+
npm version patch # or minor, or major
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 3. Push Changes
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Push the version bump commit
|
|
52
|
+
git push origin main
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
This will trigger the `auto-release.yml` workflow which will:
|
|
56
|
+
- Create a Git tag
|
|
57
|
+
- Publish to NPM automatically
|
|
58
|
+
|
|
59
|
+
### 4. Create GitHub Release (Optional)
|
|
60
|
+
|
|
61
|
+
To also publish to GitHub Packages:
|
|
62
|
+
|
|
63
|
+
1. Go to your GitHub repository
|
|
64
|
+
2. Click "Releases" → "Create a new release"
|
|
65
|
+
3. Choose the tag that was just created (e.g., `v1.0.1`)
|
|
66
|
+
4. Add release notes
|
|
67
|
+
5. Click "Publish release"
|
|
68
|
+
|
|
69
|
+
This triggers the `publish.yml` workflow.
|
|
70
|
+
|
|
71
|
+
## GitHub Workflows
|
|
72
|
+
|
|
73
|
+
Your project has three separate, independently runnable workflows:
|
|
74
|
+
|
|
75
|
+
### 1. Test Pipeline (`test.yml`)
|
|
76
|
+
- **Triggers**: Push to main/develop, PRs, manual dispatch, called by other workflows
|
|
77
|
+
- **Purpose**: Run tests and linting across Node.js versions
|
|
78
|
+
- **Manual run**: Go to Actions → Test Pipeline → "Run workflow"
|
|
79
|
+
|
|
80
|
+
### 2. Build Pipeline (`build.yml`)
|
|
81
|
+
- **Triggers**: Push to main, manual dispatch, or called by other workflows
|
|
82
|
+
- **Purpose**: Run tests first, then build the project and create artifacts
|
|
83
|
+
- **Dependencies**: Calls Test Pipeline automatically
|
|
84
|
+
- **Manual run**: Go to Actions → Build Pipeline → "Run workflow"
|
|
85
|
+
|
|
86
|
+
### 3. Publish Pipeline (`publish.yml`)
|
|
87
|
+
- **Triggers**: GitHub releases, manual dispatch
|
|
88
|
+
- **Purpose**: Publish to NPM and GitHub Packages using build artifacts
|
|
89
|
+
- **Features**:
|
|
90
|
+
- Uses artifacts from build pipeline (no rebuilding)
|
|
91
|
+
- Can use existing artifacts from previous builds
|
|
92
|
+
- Option to specify which artifact to use
|
|
93
|
+
- **Manual run**: Go to Actions → Publish Pipeline → "Run workflow"
|
|
94
|
+
|
|
95
|
+
### 4. Auto Release (`auto-release.yml`)
|
|
96
|
+
- **Triggers**: Push to main when package.json version changes
|
|
97
|
+
- **Purpose**: Automatically create tags and publish when version is bumped
|
|
98
|
+
|
|
99
|
+
## Prerequisites
|
|
100
|
+
|
|
101
|
+
### NPM Token
|
|
102
|
+
Add `NPM_TOKEN` to your GitHub repository secrets:
|
|
103
|
+
1. Go to npmjs.com → Access Tokens → Generate New Token
|
|
104
|
+
2. Copy the token
|
|
105
|
+
3. In GitHub: Settings → Secrets → Actions → New repository secret
|
|
106
|
+
4. Name: `NPM_TOKEN`, Value: your token
|
|
107
|
+
|
|
108
|
+
### Production Environment (Optional)
|
|
109
|
+
For extra safety, create a production environment:
|
|
110
|
+
1. GitHub → Settings → Environments → New environment
|
|
111
|
+
2. Name: `production`
|
|
112
|
+
3. Add protection rules (require reviews, etc.)
|
|
113
|
+
|
|
114
|
+
## Version Strategy
|
|
115
|
+
|
|
116
|
+
Follow [Semantic Versioning](https://semver.org/):
|
|
117
|
+
|
|
118
|
+
- **Major** (`X.0.0`): Breaking changes that require user action
|
|
119
|
+
- **Minor** (`0.X.0`): New features that are backward compatible
|
|
120
|
+
- **Patch** (`0.0.X`): Bug fixes and small improvements
|
|
121
|
+
|
|
122
|
+
## Troubleshooting
|
|
123
|
+
|
|
124
|
+
### Release Failed
|
|
125
|
+
- Check the Actions tab for error details
|
|
126
|
+
- Ensure NPM_TOKEN is valid
|
|
127
|
+
- Verify package.json version was actually changed
|
|
128
|
+
- Make sure tests pass: `npm run test:run`
|
|
129
|
+
|
|
130
|
+
### Package Already Published
|
|
131
|
+
- NPM doesn't allow republishing the same version
|
|
132
|
+
- Bump the version: `npm version patch`
|
|
133
|
+
- Push: `git push origin main`
|
|
134
|
+
|
|
135
|
+
### Using Existing Build Artifacts
|
|
136
|
+
|
|
137
|
+
You can publish using previously built artifacts:
|
|
138
|
+
|
|
139
|
+
1. **Use latest build**: Go to Actions → Publish Pipeline → Run workflow → Use artifact: `latest`
|
|
140
|
+
2. **Use specific build**: Find the artifact name from a previous build run → Run workflow → Use artifact: `build-artifacts-abc123def`
|
|
141
|
+
|
|
142
|
+
### Manual Publishing
|
|
143
|
+
If workflows fail, you can publish manually:
|
|
144
|
+
```bash
|
|
145
|
+
npm run build
|
|
146
|
+
npm run test:run
|
|
147
|
+
npm publish
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Example Release Workflow
|
|
151
|
+
|
|
152
|
+
Here's a complete example of releasing version 1.2.3:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
# 1. Prepare
|
|
156
|
+
git checkout main
|
|
157
|
+
git pull origin main
|
|
158
|
+
npm run test:run
|
|
159
|
+
|
|
160
|
+
# 2. Release (this does everything)
|
|
161
|
+
npm run release:minor # 1.2.2 → 1.2.3
|
|
162
|
+
|
|
163
|
+
# 3. Create GitHub release (optional)
|
|
164
|
+
# Go to GitHub → Releases → Create release from v1.2.3 tag
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
That's it! The automation handles the rest.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/cli/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/cli/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAqDpD"}
|
package/dist/cli/commands.js
CHANGED
|
@@ -2,16 +2,53 @@ import { renameFiles } from './rename.js';
|
|
|
2
2
|
export function setupCommands(program) {
|
|
3
3
|
program
|
|
4
4
|
.command('rename')
|
|
5
|
-
.description('Rename files in a directory based on their content')
|
|
5
|
+
.description('🚀 Rename files in a directory based on their content using AI analysis')
|
|
6
6
|
.argument('<directory>', 'Directory containing files to rename')
|
|
7
|
-
.option('-p, --provider <provider>', 'AI provider (claude|openai)', 'claude')
|
|
8
|
-
.option('-k, --api-key <key>', 'API key for
|
|
7
|
+
.option('-p, --provider <provider>', 'AI provider (claude|openai|ollama|lmstudio)', 'claude')
|
|
8
|
+
.option('-k, --api-key <key>', 'API key for cloud providers (or set CLAUDE_API_KEY/OPENAI_API_KEY)')
|
|
9
9
|
.option('-c, --case <convention>', 'Naming convention (kebab-case|snake_case|camelCase|PascalCase|lowercase|UPPERCASE)', 'kebab-case')
|
|
10
10
|
.option('-t, --template <category>', 'File category template (document|movie|music|series|photo|book|general|auto)', 'general')
|
|
11
|
-
.option('-n, --name <personalName>', 'Personal name to include in filenames')
|
|
12
|
-
.option('-d, --date <format>', 'Date format (YYYY-MM-DD|YYYY|YYYYMMDD|none)', 'none')
|
|
13
|
-
.option('--dry-run', 'Preview changes without renaming files', false)
|
|
14
|
-
.option('--max-size <size>', 'Maximum file size in MB', '10')
|
|
11
|
+
.option('-n, --name <personalName>', 'Personal name to include in filenames (for document/photo templates)')
|
|
12
|
+
.option('-d, --date <format>', 'Date format to include (YYYY-MM-DD|YYYY|YYYYMMDD|none)', 'none')
|
|
13
|
+
.option('--dry-run', 'Preview changes without actually renaming files (RECOMMENDED first!)', false)
|
|
14
|
+
.option('--max-size <size>', 'Maximum file size in MB to process', '10')
|
|
15
|
+
.option('--base-url <url>', 'Base URL for local LLM providers (default: ollama=http://localhost:11434, lmstudio=http://localhost:1234)')
|
|
16
|
+
.option('--model <name>', 'Model name for local LLM providers (default: ollama=llama3.1, lmstudio=local-model)')
|
|
17
|
+
.addHelpText('after', `
|
|
18
|
+
|
|
19
|
+
🔍 How it works:
|
|
20
|
+
1. Scans directory for supported files (PDF, DOCX, XLSX, TXT, MD, RTF)
|
|
21
|
+
2. Extracts content and metadata from each file
|
|
22
|
+
3. Uses AI to analyze content and generate descriptive names
|
|
23
|
+
4. Applies your chosen template and naming convention
|
|
24
|
+
5. Renames files (or shows preview with --dry-run)
|
|
25
|
+
|
|
26
|
+
💡 Pro Tips:
|
|
27
|
+
• Always use --dry-run first to preview changes
|
|
28
|
+
• Use 'auto' template for smart file type detection
|
|
29
|
+
• Personal templates work great for documents and photos
|
|
30
|
+
• Set API keys as environment variables for cloud providers
|
|
31
|
+
• Local LLMs (Ollama/LMStudio) require running servers first
|
|
32
|
+
|
|
33
|
+
🖥️ Local LLM Setup:
|
|
34
|
+
• Ollama: Start with 'ollama serve' (default: http://localhost:11434)
|
|
35
|
+
• LMStudio: Enable local server mode (default: http://localhost:1234)
|
|
36
|
+
|
|
37
|
+
📝 Examples:
|
|
38
|
+
# Safe preview first
|
|
39
|
+
namewise rename ./documents --dry-run
|
|
40
|
+
|
|
41
|
+
# Cloud providers (require API keys)
|
|
42
|
+
namewise rename ./docs --provider claude --template document --name "alice"
|
|
43
|
+
namewise rename ./media --provider openai --template auto
|
|
44
|
+
|
|
45
|
+
# Local LLMs (no API key needed)
|
|
46
|
+
namewise rename ./documents --provider ollama --model llama3.1 --dry-run
|
|
47
|
+
namewise rename ./contracts --provider lmstudio --base-url http://localhost:1234
|
|
48
|
+
|
|
49
|
+
# Custom Ollama setup
|
|
50
|
+
namewise rename ./files --provider ollama --base-url http://192.168.1.100:11434 --model codellama
|
|
51
|
+
`)
|
|
15
52
|
.action(async (directory, options) => {
|
|
16
53
|
await renameFiles(directory, options);
|
|
17
54
|
});
|
package/dist/cli/commands.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/cli/commands.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,UAAU,aAAa,CAAC,OAAgB;IAC5C,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/cli/commands.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,UAAU,aAAa,CAAC,OAAgB;IAC5C,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,yEAAyE,CAAC;SACtF,QAAQ,CAAC,aAAa,EAAE,sCAAsC,CAAC;SAC/D,MAAM,CAAC,2BAA2B,EAAE,6CAA6C,EAAE,QAAQ,CAAC;SAC5F,MAAM,CAAC,qBAAqB,EAAE,oEAAoE,CAAC;SACnG,MAAM,CAAC,yBAAyB,EAAE,oFAAoF,EAAE,YAAY,CAAC;SACrI,MAAM,CAAC,2BAA2B,EAAE,8EAA8E,EAAE,SAAS,CAAC;SAC9H,MAAM,CAAC,2BAA2B,EAAE,sEAAsE,CAAC;SAC3G,MAAM,CAAC,qBAAqB,EAAE,wDAAwD,EAAE,MAAM,CAAC;SAC/F,MAAM,CAAC,WAAW,EAAE,sEAAsE,EAAE,KAAK,CAAC;SAClG,MAAM,CAAC,mBAAmB,EAAE,oCAAoC,EAAE,IAAI,CAAC;SACvE,MAAM,CAAC,kBAAkB,EAAE,2GAA2G,CAAC;SACvI,MAAM,CAAC,gBAAgB,EAAE,qFAAqF,CAAC;SAC/G,WAAW,CAAC,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCzB,CAAC;SACG,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE;QACnC,MAAM,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/cli/rename.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rename.d.ts","sourceRoot":"","sources":["../../src/cli/rename.ts"],"names":[],"mappings":"AAQA,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"rename.d.ts","sourceRoot":"","sources":["../../src/cli/rename.ts"],"names":[],"mappings":"AAQA,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CA+FhF"}
|