ai-renamer
Advanced tools
Comparing version 1.0.5 to 1.0.6
{ | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"license": "GPL-3.0", | ||
@@ -4,0 +4,0 @@ "name": "ai-renamer", |
@@ -28,2 +28,16 @@ # ai-renamer | ||
## Params | ||
```bash | ||
npx ai-renamer --help | ||
Options: | ||
-h, --help Show help [boolean] | ||
--version Show version number [boolean] | ||
-c, --set-case Set the case style (e.g. camelCase, PascalCase, snake_case, | ||
kebab-case, lower_case, UPPER_CASE) [string] | ||
-m, --set-model Set the Ollama model to use (e.g. phi3, llama3) [string] | ||
-x, --set-chars Set the maximum number of characters in the new filename | ||
(e.g. 25) [number] | ||
``` | ||
## Contribution | ||
@@ -30,0 +44,0 @@ |
@@ -40,2 +40,7 @@ const os = require('os') | ||
description: 'Set the Ollama model to use (e.g. phi3, llama3)' | ||
}) | ||
.option('set-chars', { | ||
alias: 'x', | ||
type: 'number', | ||
description: 'Set the maximum number of characters in the new filename (e.g. 25)' | ||
}).argv | ||
@@ -49,5 +54,5 @@ | ||
if (argv['set-case']) { | ||
config.case = argv['set-case'] | ||
config.defaultCase = argv['set-case'] | ||
await saveConfig({ config }) | ||
console.log(`⚪ Case set to: ${config.case}`) | ||
console.log(`⚪ Case set to: ${config.defaultCase}`) | ||
process.exit(1) | ||
@@ -57,9 +62,16 @@ } | ||
if (argv['set-model']) { | ||
config.model = argv['set-model'] | ||
config.defaultModel = argv['set-model'] | ||
await saveConfig({ config }) | ||
console.log(`⚪ Model set to: ${config.model}`) | ||
console.log(`⚪ Model set to: ${config.defaultModel}`) | ||
process.exit(1) | ||
} | ||
if (argv['set-chars']) { | ||
config.defaultChars = argv['set-chars'] | ||
await saveConfig({ config }) | ||
console.log(`⚪ Chars set to: ${config.defaultChars}`) | ||
process.exit(1) | ||
} | ||
return { argv, config } | ||
} |
const ollama = require('ollama').default | ||
module.exports = async ({ model, _case, content }) => { | ||
module.exports = async ({ model, _case, chars, content }) => { | ||
try { | ||
const prompt = `Given the following file content, suggest a concise and descriptive filename in ${_case} format. Don't include the extension. Don't include any other text or description. Just the filename.\n\n${content}` | ||
const prompt = `Given the following file content, suggest a concise and descriptive filename in ${_case} format. Make the maximum number of characters ${chars} in the new filename. Don't include the extension. Don't include any other text or description. Just the filename.\n\n${content}` | ||
const res = await ollama.generate({ model, prompt }) | ||
@@ -7,0 +7,0 @@ return res.response.trim() |
@@ -9,3 +9,3 @@ #!/usr/bin/env node | ||
const [inputPath] = argv._ | ||
const { model, case: _case } = config | ||
const { defaultCase, defaultModel, defaultChars } = config | ||
@@ -17,5 +17,5 @@ if (!inputPath) { | ||
await processPath({ model, _case, inputPath }) | ||
await processPath({ inputPath, defaultCase, defaultModel, defaultChars }) | ||
} | ||
main() |
@@ -8,3 +8,3 @@ const path = require('path') | ||
module.exports = async ({ model, _case, filePath }) => { | ||
module.exports = async ({ model, _case, chars, filePath }) => { | ||
try { | ||
@@ -26,3 +26,3 @@ const fileName = path.basename(filePath) | ||
const newName = await getNewName({ model, _case, content }) | ||
const newName = await getNewName({ model, _case, chars, content }) | ||
if (!newName) { | ||
@@ -29,0 +29,0 @@ console.log(`🔴 No new name: ${fileName}`) |
@@ -7,3 +7,3 @@ const path = require('path') | ||
module.exports = async ({ model: defaultModel, _case: defaultCase, inputPath }) => { | ||
module.exports = async ({ inputPath, defaultCase, defaultModel, defaultChars }) => { | ||
try { | ||
@@ -16,2 +16,5 @@ const model = defaultModel || await chooseModel() | ||
const chars = defaultChars || 20 | ||
console.log(`⚪ Chosen chars: ${chars}`) | ||
console.log('--------------------------------------------------') | ||
@@ -27,7 +30,7 @@ | ||
if (fileStats.isFile()) { | ||
await processFile({ model, _case, filePath }) | ||
await processFile({ model, _case, chars, filePath }) | ||
} | ||
} | ||
} else if (stats.isFile()) { | ||
await processFile({ model, _case, filePath: inputPath }) | ||
await processFile({ model, _case, chars, filePath: inputPath }) | ||
} | ||
@@ -34,0 +37,0 @@ } catch (err) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45241
237
49