@amirdaraee/namewise 0.5.3 → 0.5.5

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 (83) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +60 -60
  3. package/dist/index.js +0 -0
  4. package/dist/services/claude-service.d.ts.map +1 -1
  5. package/dist/services/claude-service.js +3 -0
  6. package/dist/services/claude-service.js.map +1 -1
  7. package/dist/services/lmstudio-service.d.ts +1 -0
  8. package/dist/services/lmstudio-service.d.ts.map +1 -1
  9. package/dist/services/lmstudio-service.js +16 -1
  10. package/dist/services/lmstudio-service.js.map +1 -1
  11. package/dist/services/ollama-service.d.ts +1 -0
  12. package/dist/services/ollama-service.d.ts.map +1 -1
  13. package/dist/services/ollama-service.js +16 -1
  14. package/dist/services/ollama-service.js.map +1 -1
  15. package/dist/services/openai-service.d.ts.map +1 -1
  16. package/dist/services/openai-service.js +3 -0
  17. package/dist/services/openai-service.js.map +1 -1
  18. package/package.json +8 -8
  19. package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -82
  20. package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -61
  21. package/.github/workflows/auto-release.yml +0 -81
  22. package/.github/workflows/build.yml +0 -55
  23. package/.github/workflows/publish.yml +0 -134
  24. package/.github/workflows/test.yml +0 -45
  25. package/eng.traineddata +0 -0
  26. package/src/cli/commands.ts +0 -64
  27. package/src/cli/rename.ts +0 -171
  28. package/src/index.ts +0 -54
  29. package/src/parsers/excel-parser.ts +0 -66
  30. package/src/parsers/factory.ts +0 -38
  31. package/src/parsers/pdf-parser.ts +0 -99
  32. package/src/parsers/text-parser.ts +0 -43
  33. package/src/parsers/word-parser.ts +0 -50
  34. package/src/services/ai-factory.ts +0 -39
  35. package/src/services/claude-service.ts +0 -119
  36. package/src/services/file-renamer.ts +0 -141
  37. package/src/services/lmstudio-service.ts +0 -161
  38. package/src/services/ollama-service.ts +0 -191
  39. package/src/services/openai-service.ts +0 -117
  40. package/src/types/index.ts +0 -76
  41. package/src/types/pdf-extraction.d.ts +0 -7
  42. package/src/utils/ai-prompts.ts +0 -76
  43. package/src/utils/file-templates.ts +0 -275
  44. package/src/utils/naming-conventions.ts +0 -67
  45. package/src/utils/pdf-to-image.ts +0 -137
  46. package/tests/data/console-test-1.txt +0 -1
  47. package/tests/data/console-test-2.txt +0 -1
  48. package/tests/data/console-test-long-filename-for-display-testing.txt +0 -1
  49. package/tests/data/empty-file.txt +0 -0
  50. package/tests/data/failure.txt +0 -1
  51. package/tests/data/file1.txt +0 -1
  52. package/tests/data/file2.txt +0 -1
  53. package/tests/data/much-longer-filename-to-test-clearing.txt +0 -1
  54. package/tests/data/sample-markdown.md +0 -9
  55. package/tests/data/sample-pdf.pdf +0 -0
  56. package/tests/data/sample-text.txt +0 -25
  57. package/tests/data/short.txt +0 -1
  58. package/tests/data/single-file.txt +0 -1
  59. package/tests/data/success.txt +0 -1
  60. package/tests/data/this-is-a-very-long-filename-that-should-be-truncated-for-better-display-purposes.txt +0 -1
  61. package/tests/data/very-long-filename-that-should-be-cleared-properly.txt +0 -1
  62. package/tests/data/x.txt +0 -1
  63. package/tests/integration/ai-prompting.test.ts +0 -386
  64. package/tests/integration/end-to-end.test.ts +0 -209
  65. package/tests/integration/person-name-extraction.test.ts +0 -440
  66. package/tests/integration/workflow.test.ts +0 -336
  67. package/tests/mocks/mock-ai-service.ts +0 -58
  68. package/tests/unit/cli/commands.test.ts +0 -169
  69. package/tests/unit/parsers/factory.test.ts +0 -100
  70. package/tests/unit/parsers/pdf-parser.test.ts +0 -63
  71. package/tests/unit/parsers/text-parser.test.ts +0 -85
  72. package/tests/unit/services/ai-factory.test.ts +0 -85
  73. package/tests/unit/services/claude-service.test.ts +0 -188
  74. package/tests/unit/services/file-renamer.test.ts +0 -514
  75. package/tests/unit/services/lmstudio-service.test.ts +0 -326
  76. package/tests/unit/services/ollama-service.test.ts +0 -264
  77. package/tests/unit/services/openai-service.test.ts +0 -196
  78. package/tests/unit/utils/ai-prompts.test.ts +0 -213
  79. package/tests/unit/utils/file-templates.test.ts +0 -199
  80. package/tests/unit/utils/naming-conventions.test.ts +0 -88
  81. package/tests/unit/utils/pdf-to-image.test.ts +0 -127
  82. package/tsconfig.json +0 -20
  83. package/vitest.config.ts +0 -30
@@ -1,88 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { applyNamingConvention, getNamingInstructions, NamingConvention } from '../../../src/utils/naming-conventions.js';
3
-
4
- describe('Naming Conventions', () => {
5
- describe('applyNamingConvention()', () => {
6
- const testText = 'Project Requirements Document 2024';
7
-
8
- it('should apply kebab-case convention', () => {
9
- const result = applyNamingConvention(testText, 'kebab-case');
10
- expect(result).toBe('project-requirements-document-2024');
11
- });
12
-
13
- it('should apply snake_case convention', () => {
14
- const result = applyNamingConvention(testText, 'snake_case');
15
- expect(result).toBe('project_requirements_document_2024');
16
- });
17
-
18
- it('should apply camelCase convention', () => {
19
- const result = applyNamingConvention(testText, 'camelCase');
20
- expect(result).toBe('projectRequirementsDocument2024');
21
- });
22
-
23
- it('should apply PascalCase convention', () => {
24
- const result = applyNamingConvention(testText, 'PascalCase');
25
- expect(result).toBe('ProjectRequirementsDocument2024');
26
- });
27
-
28
- it('should apply lowercase convention', () => {
29
- const result = applyNamingConvention(testText, 'lowercase');
30
- expect(result).toBe('projectrequirementsdocument2024');
31
- });
32
-
33
- it('should apply UPPERCASE convention', () => {
34
- const result = applyNamingConvention(testText, 'UPPERCASE');
35
- expect(result).toBe('PROJECTREQUIREMENTSDOCUMENT2024');
36
- });
37
-
38
- it('should handle text with special characters', () => {
39
- const textWithSpecialChars = 'User@Guide & Manual (v2.1)';
40
-
41
- expect(applyNamingConvention(textWithSpecialChars, 'kebab-case')).toBe('userguide-manual-v21');
42
- expect(applyNamingConvention(textWithSpecialChars, 'snake_case')).toBe('userguide_manual_v21');
43
- expect(applyNamingConvention(textWithSpecialChars, 'camelCase')).toBe('userguideManualV21');
44
- expect(applyNamingConvention(textWithSpecialChars, 'PascalCase')).toBe('UserguideManualV21');
45
- });
46
-
47
- it('should handle text with existing hyphens and underscores', () => {
48
- const textWithSeparators = 'my-file_name document';
49
-
50
- expect(applyNamingConvention(textWithSeparators, 'kebab-case')).toBe('my-file-name-document');
51
- expect(applyNamingConvention(textWithSeparators, 'snake_case')).toBe('my_file_name_document');
52
- expect(applyNamingConvention(textWithSeparators, 'camelCase')).toBe('myFileNameDocument');
53
- });
54
-
55
- it('should handle empty and whitespace-only strings', () => {
56
- expect(applyNamingConvention('', 'kebab-case')).toBe('');
57
- expect(applyNamingConvention(' ', 'kebab-case')).toBe('');
58
- });
59
-
60
- it('should normalize multiple spaces', () => {
61
- const textWithSpaces = 'Meeting Notes From Today';
62
- expect(applyNamingConvention(textWithSpaces, 'kebab-case')).toBe('meeting-notes-from-today');
63
- });
64
-
65
- it('should default to kebab-case for unknown convention', () => {
66
- const result = applyNamingConvention(testText, 'unknown' as NamingConvention);
67
- expect(result).toBe('project-requirements-document-2024');
68
- });
69
- });
70
-
71
- describe('getNamingInstructions()', () => {
72
- it('should return correct instructions for each convention', () => {
73
- expect(getNamingInstructions('kebab-case')).toContain('lowercase with hyphens');
74
- expect(getNamingInstructions('snake_case')).toContain('lowercase with underscores');
75
- expect(getNamingInstructions('camelCase')).toContain('camelCase format starting with lowercase');
76
- expect(getNamingInstructions('PascalCase')).toContain('PascalCase format starting with uppercase');
77
- expect(getNamingInstructions('lowercase')).toContain('single lowercase word');
78
- expect(getNamingInstructions('UPPERCASE')).toContain('single uppercase word');
79
- });
80
-
81
- it('should include examples in instructions', () => {
82
- expect(getNamingInstructions('kebab-case')).toContain('meeting-notes-2024');
83
- expect(getNamingInstructions('snake_case')).toContain('meeting_notes_2024');
84
- expect(getNamingInstructions('camelCase')).toContain('meetingNotes2024');
85
- expect(getNamingInstructions('PascalCase')).toContain('MeetingNotes2024');
86
- });
87
- });
88
- });
@@ -1,127 +0,0 @@
1
- import { describe, it, expect, beforeAll } from 'vitest';
2
- import { PDFToImageConverter } from '../../../src/utils/pdf-to-image.js';
3
- import fs from 'fs';
4
- import path from 'path';
5
-
6
- describe('PDFToImageConverter', () => {
7
- let samplePdfBuffer: Buffer;
8
- const testDataDir = path.join(process.cwd(), 'tests/data');
9
-
10
- beforeAll(async () => {
11
- // Load sample PDF for testing
12
- const pdfPath = path.join(testDataDir, 'sample-pdf.pdf');
13
- samplePdfBuffer = fs.readFileSync(pdfPath);
14
- });
15
-
16
- describe('Integration with PDF Parser', () => {
17
- it('should successfully convert scanned PDF through parser workflow', async () => {
18
- // This simulates what happens in the actual PDF parser
19
- const { PDFParser } = await import('../../../src/parsers/pdf-parser.js');
20
- const parser = new PDFParser();
21
-
22
- // Create a minimal scanned PDF scenario
23
- const pdfPath = path.join(testDataDir, 'sample-pdf.pdf');
24
-
25
- // Parse the PDF (this will trigger conversion if detected as scanned)
26
- const result = await parser.parse(pdfPath);
27
-
28
- // The parser should complete without throwing errors
29
- expect(result).toBeDefined();
30
- expect(result.content).toBeDefined();
31
- }, 15000);
32
- });
33
-
34
- describe('convertFirstPageToBase64()', () => {
35
- it('should convert PDF first page to base64 JPEG image', async () => {
36
- const result = await PDFToImageConverter.convertFirstPageToBase64(samplePdfBuffer);
37
-
38
- // Verify it's a base64 data URL (always JPEG for size optimization)
39
- expect(result).toMatch(/^data:image\/jpeg;base64,/);
40
-
41
- // Verify it has actual content
42
- expect(result.length).toBeGreaterThan(100);
43
-
44
- // Verify base64 encoding is valid
45
- const base64Data = result.split(',')[1];
46
- expect(() => Buffer.from(base64Data, 'base64')).not.toThrow();
47
- }, 10000); // 10 second timeout for PDF processing
48
-
49
- it('should respect format option when specified', async () => {
50
- const result = await PDFToImageConverter.convertFirstPageToBase64(samplePdfBuffer, {
51
- format: 'jpeg'
52
- });
53
-
54
- // Verify it's a base64 data URL (always JPEG for size optimization)
55
- expect(result).toMatch(/^data:image\/jpeg;base64,/);
56
-
57
- // Verify it has actual content
58
- expect(result.length).toBeGreaterThan(100);
59
- }, 10000);
60
-
61
- it('should use custom scale factor', async () => {
62
- const resultScale1 = await PDFToImageConverter.convertFirstPageToBase64(samplePdfBuffer, {
63
- scale: 1.0
64
- });
65
-
66
- const resultScale2 = await PDFToImageConverter.convertFirstPageToBase64(samplePdfBuffer, {
67
- scale: 2.0
68
- });
69
-
70
- // Both should be JPEG format
71
- expect(resultScale1).toMatch(/^data:image\/jpeg;base64,/);
72
- expect(resultScale2).toMatch(/^data:image\/jpeg;base64,/);
73
-
74
- // Higher scale should generally produce larger image (though compression may vary)
75
- expect(resultScale2.length).toBeGreaterThan(0);
76
- expect(resultScale1.length).toBeGreaterThan(0);
77
- }, 15000);
78
-
79
- it('should handle invalid PDF buffer', async () => {
80
- const invalidBuffer = Buffer.from('This is not a PDF');
81
-
82
- await expect(
83
- PDFToImageConverter.convertFirstPageToBase64(invalidBuffer)
84
- ).rejects.toThrow(/PDF to image conversion failed/);
85
- });
86
-
87
- it('should handle empty buffer', async () => {
88
- const emptyBuffer = Buffer.from([]);
89
-
90
- await expect(
91
- PDFToImageConverter.convertFirstPageToBase64(emptyBuffer)
92
- ).rejects.toThrow(/PDF to image conversion failed/);
93
- });
94
- });
95
-
96
- describe('isScannedPDF()', () => {
97
- it('should detect scanned PDF with very little text', () => {
98
- const scannedText = 'abc';
99
- expect(PDFToImageConverter.isScannedPDF(scannedText)).toBe(true);
100
- });
101
-
102
- it('should detect scanned PDF with few words', () => {
103
- const scannedText = 'one two three four';
104
- expect(PDFToImageConverter.isScannedPDF(scannedText)).toBe(true);
105
- });
106
-
107
- it('should detect scanned PDF with high non-alphabetic ratio', () => {
108
- const scannedText = '### %%% $$$ ### %%%';
109
- expect(PDFToImageConverter.isScannedPDF(scannedText)).toBe(true);
110
- });
111
-
112
- it('should not detect normal PDF as scanned', () => {
113
- const normalText = 'This is a normal document with plenty of readable text content that was generated from a text-based PDF file.';
114
- expect(PDFToImageConverter.isScannedPDF(normalText)).toBe(false);
115
- });
116
-
117
- it('should detect empty text as scanned', () => {
118
- const emptyText = '';
119
- expect(PDFToImageConverter.isScannedPDF(emptyText)).toBe(true);
120
- });
121
-
122
- it('should detect whitespace-only text as scanned', () => {
123
- const whitespaceText = ' \n \t ';
124
- expect(PDFToImageConverter.isScannedPDF(whitespaceText)).toBe(true);
125
- });
126
- });
127
- });
package/tsconfig.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "NodeNext",
5
- "moduleResolution": "NodeNext",
6
- "outDir": "./dist",
7
- "rootDir": "./src",
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "declaration": true,
13
- "declarationMap": true,
14
- "sourceMap": true,
15
- "resolveJsonModule": true,
16
- "allowSyntheticDefaultImports": true
17
- },
18
- "include": ["src/**/*"],
19
- "exclude": ["node_modules", "dist"]
20
- }
package/vitest.config.ts DELETED
@@ -1,30 +0,0 @@
1
- import { defineConfig } from 'vitest/config';
2
- import path from 'path';
3
-
4
- export default defineConfig({
5
- test: {
6
- globals: true,
7
- environment: 'node',
8
- include: ['tests/**/*.test.{ts,js}'],
9
- exclude: ['node_modules', 'dist'],
10
- coverage: {
11
- provider: 'v8',
12
- include: ['src/**/*.ts'],
13
- exclude: ['src/types/**', 'src/**/*.d.ts'],
14
- reporter: ['text', 'json', 'html'],
15
- thresholds: {
16
- global: {
17
- branches: 80,
18
- functions: 80,
19
- lines: 80,
20
- statements: 80
21
- }
22
- }
23
- }
24
- },
25
- resolve: {
26
- alias: {
27
- '@': path.resolve(__dirname, 'src')
28
- }
29
- }
30
- });