@llmindset/hf-mcp 0.1.16
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/LICENSE +21 -0
- package/dist/dataset-detail.d.ts +26 -0
- package/dist/dataset-detail.d.ts.map +1 -0
- package/dist/dataset-detail.js +157 -0
- package/dist/dataset-detail.js.map +1 -0
- package/dist/dataset-search.d.ts +62 -0
- package/dist/dataset-search.d.ts.map +1 -0
- package/dist/dataset-search.js +158 -0
- package/dist/dataset-search.js.map +1 -0
- package/dist/duplicate-space.d.ts +75 -0
- package/dist/duplicate-space.d.ts.map +1 -0
- package/dist/duplicate-space.js +189 -0
- package/dist/duplicate-space.js.map +1 -0
- package/dist/error-messages.d.ts +4 -0
- package/dist/error-messages.d.ts.map +1 -0
- package/dist/error-messages.js +30 -0
- package/dist/error-messages.js.map +1 -0
- package/dist/hf-api-call.d.ts +18 -0
- package/dist/hf-api-call.d.ts.map +1 -0
- package/dist/hf-api-call.js +105 -0
- package/dist/hf-api-call.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/model-detail.d.ts +26 -0
- package/dist/model-detail.d.ts.map +1 -0
- package/dist/model-detail.js +224 -0
- package/dist/model-detail.js.map +1 -0
- package/dist/model-search.d.ts +64 -0
- package/dist/model-search.d.ts.map +1 -0
- package/dist/model-search.js +161 -0
- package/dist/model-search.js.map +1 -0
- package/dist/paper-search.d.ts +58 -0
- package/dist/paper-search.d.ts.map +1 -0
- package/dist/paper-search.js +114 -0
- package/dist/paper-search.js.map +1 -0
- package/dist/paper-summary.d.ts +35 -0
- package/dist/paper-summary.d.ts.map +1 -0
- package/dist/paper-summary.js +187 -0
- package/dist/paper-summary.js.map +1 -0
- package/dist/space-files.d.ts +44 -0
- package/dist/space-files.d.ts.map +1 -0
- package/dist/space-files.js +242 -0
- package/dist/space-files.js.map +1 -0
- package/dist/space-info.d.ts +56 -0
- package/dist/space-info.d.ts.map +1 -0
- package/dist/space-info.js +135 -0
- package/dist/space-info.js.map +1 -0
- package/dist/space-search.d.ts +71 -0
- package/dist/space-search.d.ts.map +1 -0
- package/dist/space-search.js +95 -0
- package/dist/space-search.js.map +1 -0
- package/dist/tool-ids.d.ts +23 -0
- package/dist/tool-ids.d.ts.map +1 -0
- package/dist/tool-ids.js +55 -0
- package/dist/tool-ids.js.map +1 -0
- package/dist/user-summary.d.ts +56 -0
- package/dist/user-summary.d.ts.map +1 -0
- package/dist/user-summary.js +271 -0
- package/dist/user-summary.js.map +1 -0
- package/dist/utilities.d.ts +8 -0
- package/dist/utilities.d.ts.map +1 -0
- package/dist/utilities.js +53 -0
- package/dist/utilities.js.map +1 -0
- package/eslint.config.js +43 -0
- package/package.json +47 -0
- package/src/dataset-detail.ts +257 -0
- package/src/dataset-search.ts +237 -0
- package/src/duplicate-space.ts +263 -0
- package/src/error-messages.ts +57 -0
- package/src/hf-api-call.ts +182 -0
- package/src/index.ts +18 -0
- package/src/model-detail.ts +359 -0
- package/src/model-search.ts +231 -0
- package/src/paper-search.ts +188 -0
- package/src/paper-summary.ts +303 -0
- package/src/space-files.ts +325 -0
- package/src/space-info.ts +190 -0
- package/src/space-search.ts +177 -0
- package/src/tool-ids.ts +84 -0
- package/src/user-summary.ts +421 -0
- package/src/utilities.ts +64 -0
- package/test/duplicate-space.spec.ts +41 -0
- package/test/fixtures/paper_result_kazakh.json +854 -0
- package/test/fixtures/space-result.json +263 -0
- package/test/paper-search.spec.ts +57 -0
- package/test/paper-summary.spec.ts +113 -0
- package/test/space-files.spec.ts +232 -0
- package/test/space-search.spec.ts +29 -0
- package/test/user-summary.spec.ts +131 -0
- package/tsconfig.json +31 -0
- package/vitest.config.ts +11 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { extractUserIdFromInput } from '../src/user-summary.js';
|
|
3
|
+
|
|
4
|
+
describe('extractUserIdFromInput', () => {
|
|
5
|
+
describe('valid inputs', () => {
|
|
6
|
+
it('should extract user ID from plain username', () => {
|
|
7
|
+
expect(extractUserIdFromInput('evalstate')).toBe('evalstate');
|
|
8
|
+
expect(extractUserIdFromInput('meta-llama')).toBe('meta-llama');
|
|
9
|
+
expect(extractUserIdFromInput('microsoft')).toBe('microsoft');
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('should handle usernames with whitespace', () => {
|
|
13
|
+
expect(extractUserIdFromInput(' evalstate ')).toBe('evalstate');
|
|
14
|
+
expect(extractUserIdFromInput('\tevalstate\n')).toBe('evalstate');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('should extract user ID from hf.co URLs', () => {
|
|
18
|
+
expect(extractUserIdFromInput('hf.co/evalstate')).toBe('evalstate');
|
|
19
|
+
expect(extractUserIdFromInput('https://hf.co/evalstate')).toBe('evalstate');
|
|
20
|
+
expect(extractUserIdFromInput('http://hf.co/evalstate')).toBe('evalstate');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('should extract user ID from huggingface.co URLs', () => {
|
|
24
|
+
expect(extractUserIdFromInput('huggingface.co/evalstate')).toBe('evalstate');
|
|
25
|
+
expect(extractUserIdFromInput('https://huggingface.co/evalstate')).toBe('evalstate');
|
|
26
|
+
expect(extractUserIdFromInput('http://huggingface.co/evalstate')).toBe('evalstate');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should handle URLs with whitespace', () => {
|
|
30
|
+
expect(extractUserIdFromInput(' hf.co/evalstate ')).toBe('evalstate');
|
|
31
|
+
expect(extractUserIdFromInput('\thttps://hf.co/evalstate\n')).toBe('evalstate');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should handle minimum length usernames', () => {
|
|
35
|
+
expect(extractUserIdFromInput('abc')).toBe('abc');
|
|
36
|
+
expect(extractUserIdFromInput('hf.co/abc')).toBe('abc');
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('invalid inputs', () => {
|
|
41
|
+
it('should reject usernames shorter than 3 characters', () => {
|
|
42
|
+
expect(() => extractUserIdFromInput('ab')).toThrow('User ID must be at least 3 characters long');
|
|
43
|
+
expect(() => extractUserIdFromInput('a')).toThrow('User ID must be at least 3 characters long');
|
|
44
|
+
expect(() => extractUserIdFromInput('')).toThrow('User ID must be at least 3 characters long');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('should reject URLs with short usernames', () => {
|
|
48
|
+
expect(() => extractUserIdFromInput('hf.co/ab')).toThrow('User ID must be at least 3 characters long');
|
|
49
|
+
expect(() => extractUserIdFromInput('https://hf.co/a')).toThrow('User ID must be at least 3 characters long');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should reject non-Hugging Face domains', () => {
|
|
53
|
+
expect(() => extractUserIdFromInput('github.com/evalstate')).toThrow(
|
|
54
|
+
'URL must be from huggingface.co or hf.co domain'
|
|
55
|
+
);
|
|
56
|
+
expect(() => extractUserIdFromInput('https://example.com/evalstate')).toThrow(
|
|
57
|
+
'URL must be from huggingface.co or hf.co domain'
|
|
58
|
+
);
|
|
59
|
+
expect(() => extractUserIdFromInput('evil-hf.co/evalstate')).toThrow(
|
|
60
|
+
'URL must be from huggingface.co or hf.co domain'
|
|
61
|
+
);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should reject URLs with multiple path segments', () => {
|
|
65
|
+
expect(() => extractUserIdFromInput('hf.co/evalstate/models')).toThrow(
|
|
66
|
+
'URL must contain only the username (e.g., hf.co/username)'
|
|
67
|
+
);
|
|
68
|
+
expect(() => extractUserIdFromInput('https://hf.co/evalstate/models/test')).toThrow(
|
|
69
|
+
'URL must contain only the username (e.g., hf.co/username)'
|
|
70
|
+
);
|
|
71
|
+
expect(() => extractUserIdFromInput('huggingface.co/evalstate/datasets')).toThrow(
|
|
72
|
+
'URL must contain only the username (e.g., hf.co/username)'
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('should reject URLs with no path segments', () => {
|
|
77
|
+
// "hf.co" without slash is treated as username but rejected as domain
|
|
78
|
+
expect(() => extractUserIdFromInput('hf.co')).toThrow(
|
|
79
|
+
'URL must contain only the username (e.g., hf.co/username)'
|
|
80
|
+
);
|
|
81
|
+
// URLs with explicit trailing slash should be rejected
|
|
82
|
+
expect(() => extractUserIdFromInput('https://hf.co/')).toThrow(
|
|
83
|
+
'URL must contain only the username (e.g., hf.co/username)'
|
|
84
|
+
);
|
|
85
|
+
// Domain-only format should be rejected as domain
|
|
86
|
+
expect(() => extractUserIdFromInput('huggingface.co')).toThrow(
|
|
87
|
+
'URL must contain only the username (e.g., hf.co/username)'
|
|
88
|
+
);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('should reject malformed URLs', () => {
|
|
92
|
+
expect(() => extractUserIdFromInput('not://a/valid/url')).toThrow(
|
|
93
|
+
'URL must be from huggingface.co or hf.co domain'
|
|
94
|
+
);
|
|
95
|
+
// Note: hf.co//evalstate actually gets normalized by URL constructor to hf.co/evalstate
|
|
96
|
+
// so it's treated as valid. Testing a different malformed case instead:
|
|
97
|
+
expect(() => extractUserIdFromInput('://invalid')).toThrow('Invalid URL format');
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('should reject URLs with query parameters', () => {
|
|
101
|
+
expect(() => extractUserIdFromInput('hf.co/evalstate?tab=models')).toThrow(
|
|
102
|
+
'URL must contain only the username (e.g., hf.co/username)'
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('should reject URLs with fragments', () => {
|
|
107
|
+
expect(() => extractUserIdFromInput('hf.co/evalstate#models')).toThrow(
|
|
108
|
+
'URL must contain only the username (e.g., hf.co/username)'
|
|
109
|
+
);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
describe('edge cases', () => {
|
|
114
|
+
it('should handle special characters in usernames', () => {
|
|
115
|
+
expect(extractUserIdFromInput('user-name')).toBe('user-name');
|
|
116
|
+
expect(extractUserIdFromInput('user_name')).toBe('user_name');
|
|
117
|
+
expect(extractUserIdFromInput('hf.co/user-name')).toBe('user-name');
|
|
118
|
+
expect(extractUserIdFromInput('hf.co/user_name')).toBe('user_name');
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('should handle numeric usernames', () => {
|
|
122
|
+
expect(extractUserIdFromInput('123')).toBe('123');
|
|
123
|
+
expect(extractUserIdFromInput('hf.co/123')).toBe('123');
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('should handle mixed case usernames', () => {
|
|
127
|
+
expect(extractUserIdFromInput('EvalState')).toBe('EvalState');
|
|
128
|
+
expect(extractUserIdFromInput('hf.co/EvalState')).toBe('EvalState');
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"esModuleInterop": true,
|
|
4
|
+
"skipLibCheck": true,
|
|
5
|
+
"target": "es2022",
|
|
6
|
+
"allowJs": true,
|
|
7
|
+
"resolveJsonModule": true,
|
|
8
|
+
"moduleDetection": "force",
|
|
9
|
+
"isolatedModules": true,
|
|
10
|
+
"verbatimModuleSyntax": true,
|
|
11
|
+
"strict": true,
|
|
12
|
+
"noUncheckedIndexedAccess": true,
|
|
13
|
+
"noImplicitOverride": true,
|
|
14
|
+
"noUnusedLocals": true,
|
|
15
|
+
"noUnusedParameters": true,
|
|
16
|
+
"noFallthroughCasesInSwitch": true,
|
|
17
|
+
"useDefineForClassFields": true,
|
|
18
|
+
"removeComments": true,
|
|
19
|
+
"module": "NodeNext",
|
|
20
|
+
"outDir": "dist",
|
|
21
|
+
"declaration": true,
|
|
22
|
+
"declarationDir": "dist",
|
|
23
|
+
"declarationMap": true,
|
|
24
|
+
"sourceMap": true,
|
|
25
|
+
"rootDir": "src",
|
|
26
|
+
"lib": ["es2022", "dom", "dom.iterable"],
|
|
27
|
+
"emitDeclarationOnly": false
|
|
28
|
+
},
|
|
29
|
+
"include": ["src/**/*.ts"],
|
|
30
|
+
"exclude": ["node_modules", "dist"]
|
|
31
|
+
}
|
package/vitest.config.ts
ADDED