swift-skills 0.0.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/LICENSE +21 -0
- package/README.md +410 -0
- package/build/cli/auth.d.ts +3 -0
- package/build/cli/auth.d.ts.map +1 -0
- package/build/cli/auth.js +44 -0
- package/build/cli/auth.js.map +1 -0
- package/build/cli/setup.d.ts +2 -0
- package/build/cli/setup.d.ts.map +1 -0
- package/build/cli/setup.js +150 -0
- package/build/cli/setup.js.map +1 -0
- package/build/cli/source-manager.d.ts +3 -0
- package/build/cli/source-manager.d.ts.map +1 -0
- package/build/cli/source-manager.js +117 -0
- package/build/cli/source-manager.js.map +1 -0
- package/build/config/creators.d.ts +11 -0
- package/build/config/creators.d.ts.map +1 -0
- package/build/config/creators.js +32 -0
- package/build/config/creators.js.map +1 -0
- package/build/config/sources.d.ts +91 -0
- package/build/config/sources.d.ts.map +1 -0
- package/build/config/sources.js +231 -0
- package/build/config/sources.js.map +1 -0
- package/build/config/sources.test.d.ts +2 -0
- package/build/config/sources.test.d.ts.map +1 -0
- package/build/config/sources.test.js +199 -0
- package/build/config/sources.test.js.map +1 -0
- package/build/config/swift-keywords.d.ts +29 -0
- package/build/config/swift-keywords.d.ts.map +1 -0
- package/build/config/swift-keywords.js +77 -0
- package/build/config/swift-keywords.js.map +1 -0
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +181 -0
- package/build/index.js.map +1 -0
- package/build/integration/cache-behavior.test.d.ts +2 -0
- package/build/integration/cache-behavior.test.d.ts.map +1 -0
- package/build/integration/cache-behavior.test.js +521 -0
- package/build/integration/cache-behavior.test.js.map +1 -0
- package/build/integration/mcp-client.test.d.ts +2 -0
- package/build/integration/mcp-client.test.d.ts.map +1 -0
- package/build/integration/mcp-client.test.js +82 -0
- package/build/integration/mcp-client.test.js.map +1 -0
- package/build/integration/response-quality.test.d.ts +2 -0
- package/build/integration/response-quality.test.d.ts.map +1 -0
- package/build/integration/response-quality.test.js +230 -0
- package/build/integration/response-quality.test.js.map +1 -0
- package/build/integration/test-client.d.ts +25 -0
- package/build/integration/test-client.d.ts.map +1 -0
- package/build/integration/test-client.js +93 -0
- package/build/integration/test-client.js.map +1 -0
- package/build/sources/free/nilcoalescing.d.ts +8 -0
- package/build/sources/free/nilcoalescing.d.ts.map +1 -0
- package/build/sources/free/nilcoalescing.js +26 -0
- package/build/sources/free/nilcoalescing.js.map +1 -0
- package/build/sources/free/nilcoalescing.test.d.ts +2 -0
- package/build/sources/free/nilcoalescing.test.d.ts.map +1 -0
- package/build/sources/free/nilcoalescing.test.js +63 -0
- package/build/sources/free/nilcoalescing.test.js.map +1 -0
- package/build/sources/free/pointfree.d.ts +15 -0
- package/build/sources/free/pointfree.d.ts.map +1 -0
- package/build/sources/free/pointfree.js +175 -0
- package/build/sources/free/pointfree.js.map +1 -0
- package/build/sources/free/pointfree.test.d.ts +2 -0
- package/build/sources/free/pointfree.test.d.ts.map +1 -0
- package/build/sources/free/pointfree.test.js +86 -0
- package/build/sources/free/pointfree.test.js.map +1 -0
- package/build/sources/free/rssPatternSource.d.ts +42 -0
- package/build/sources/free/rssPatternSource.d.ts.map +1 -0
- package/build/sources/free/rssPatternSource.js +109 -0
- package/build/sources/free/rssPatternSource.js.map +1 -0
- package/build/sources/free/rssPatternSource.test.d.ts +2 -0
- package/build/sources/free/rssPatternSource.test.d.ts.map +1 -0
- package/build/sources/free/rssPatternSource.test.js +89 -0
- package/build/sources/free/rssPatternSource.test.js.map +1 -0
- package/build/sources/free/sundell.d.ts +8 -0
- package/build/sources/free/sundell.d.ts.map +1 -0
- package/build/sources/free/sundell.js +17 -0
- package/build/sources/free/sundell.js.map +1 -0
- package/build/sources/free/sundell.test.d.ts +2 -0
- package/build/sources/free/sundell.test.d.ts.map +1 -0
- package/build/sources/free/sundell.test.js +63 -0
- package/build/sources/free/sundell.test.js.map +1 -0
- package/build/sources/free/vanderlee.d.ts +8 -0
- package/build/sources/free/vanderlee.d.ts.map +1 -0
- package/build/sources/free/vanderlee.js +63 -0
- package/build/sources/free/vanderlee.js.map +1 -0
- package/build/sources/free/vanderlee.test.d.ts +2 -0
- package/build/sources/free/vanderlee.test.d.ts.map +1 -0
- package/build/sources/free/vanderlee.test.js +77 -0
- package/build/sources/free/vanderlee.test.js.map +1 -0
- package/build/sources/premium/patreon-dl.d.ts +45 -0
- package/build/sources/premium/patreon-dl.d.ts.map +1 -0
- package/build/sources/premium/patreon-dl.js +189 -0
- package/build/sources/premium/patreon-dl.js.map +1 -0
- package/build/sources/premium/patreon-fetch.d.ts +3 -0
- package/build/sources/premium/patreon-fetch.d.ts.map +1 -0
- package/build/sources/premium/patreon-fetch.js +18 -0
- package/build/sources/premium/patreon-fetch.js.map +1 -0
- package/build/sources/premium/patreon-oauth.d.ts +24 -0
- package/build/sources/premium/patreon-oauth.d.ts.map +1 -0
- package/build/sources/premium/patreon-oauth.js +208 -0
- package/build/sources/premium/patreon-oauth.js.map +1 -0
- package/build/sources/premium/patreon-zip.d.ts +17 -0
- package/build/sources/premium/patreon-zip.d.ts.map +1 -0
- package/build/sources/premium/patreon-zip.js +127 -0
- package/build/sources/premium/patreon-zip.js.map +1 -0
- package/build/sources/premium/patreon.d.ts +48 -0
- package/build/sources/premium/patreon.d.ts.map +1 -0
- package/build/sources/premium/patreon.js +221 -0
- package/build/sources/premium/patreon.js.map +1 -0
- package/build/sources/premium/youtube.d.ts +14 -0
- package/build/sources/premium/youtube.d.ts.map +1 -0
- package/build/sources/premium/youtube.js +92 -0
- package/build/sources/premium/youtube.js.map +1 -0
- package/build/tools/extract-cookie.d.ts +2 -0
- package/build/tools/extract-cookie.d.ts.map +1 -0
- package/build/tools/extract-cookie.js +40 -0
- package/build/tools/extract-cookie.js.map +1 -0
- package/build/tools/handlers/enableSource.d.ts +3 -0
- package/build/tools/handlers/enableSource.d.ts.map +1 -0
- package/build/tools/handlers/enableSource.js +25 -0
- package/build/tools/handlers/enableSource.js.map +1 -0
- package/build/tools/handlers/getPatreonPatterns.d.ts +3 -0
- package/build/tools/handlers/getPatreonPatterns.d.ts.map +1 -0
- package/build/tools/handlers/getPatreonPatterns.js +43 -0
- package/build/tools/handlers/getPatreonPatterns.js.map +1 -0
- package/build/tools/handlers/getSwiftPattern.d.ts +3 -0
- package/build/tools/handlers/getSwiftPattern.d.ts.map +1 -0
- package/build/tools/handlers/getSwiftPattern.js +72 -0
- package/build/tools/handlers/getSwiftPattern.js.map +1 -0
- package/build/tools/handlers/handlers.test.d.ts +2 -0
- package/build/tools/handlers/handlers.test.d.ts.map +1 -0
- package/build/tools/handlers/handlers.test.js +359 -0
- package/build/tools/handlers/handlers.test.js.map +1 -0
- package/build/tools/handlers/listContentSources.d.ts +3 -0
- package/build/tools/handlers/listContentSources.d.ts.map +1 -0
- package/build/tools/handlers/listContentSources.js +34 -0
- package/build/tools/handlers/listContentSources.js.map +1 -0
- package/build/tools/handlers/searchSwiftContent.d.ts +3 -0
- package/build/tools/handlers/searchSwiftContent.d.ts.map +1 -0
- package/build/tools/handlers/searchSwiftContent.js +121 -0
- package/build/tools/handlers/searchSwiftContent.js.map +1 -0
- package/build/tools/handlers/setupPatreon.d.ts +3 -0
- package/build/tools/handlers/setupPatreon.d.ts.map +1 -0
- package/build/tools/handlers/setupPatreon.js +40 -0
- package/build/tools/handlers/setupPatreon.js.map +1 -0
- package/build/tools/index.d.ts +3 -0
- package/build/tools/index.d.ts.map +1 -0
- package/build/tools/index.js +18 -0
- package/build/tools/index.js.map +1 -0
- package/build/tools/registry.d.ts +14 -0
- package/build/tools/registry.d.ts.map +1 -0
- package/build/tools/registry.js +21 -0
- package/build/tools/registry.js.map +1 -0
- package/build/tools/registry.test.d.ts +2 -0
- package/build/tools/registry.test.d.ts.map +1 -0
- package/build/tools/registry.test.js +54 -0
- package/build/tools/registry.test.js.map +1 -0
- package/build/tools/types.d.ts +67 -0
- package/build/tools/types.d.ts.map +1 -0
- package/build/tools/types.js +3 -0
- package/build/tools/types.js.map +1 -0
- package/build/utils/cache.d.ts +20 -0
- package/build/utils/cache.d.ts.map +1 -0
- package/build/utils/cache.js +186 -0
- package/build/utils/cache.js.map +1 -0
- package/build/utils/concurrency.d.ts +13 -0
- package/build/utils/concurrency.d.ts.map +1 -0
- package/build/utils/concurrency.js +33 -0
- package/build/utils/concurrency.js.map +1 -0
- package/build/utils/errors.d.ts +19 -0
- package/build/utils/errors.d.ts.map +1 -0
- package/build/utils/errors.js +35 -0
- package/build/utils/errors.js.map +1 -0
- package/build/utils/fetch.d.ts +6 -0
- package/build/utils/fetch.d.ts.map +1 -0
- package/build/utils/fetch.js +6 -0
- package/build/utils/fetch.js.map +1 -0
- package/build/utils/http.d.ts +21 -0
- package/build/utils/http.d.ts.map +1 -0
- package/build/utils/http.js +53 -0
- package/build/utils/http.js.map +1 -0
- package/build/utils/intent-cache.d.ts +94 -0
- package/build/utils/intent-cache.d.ts.map +1 -0
- package/build/utils/intent-cache.js +164 -0
- package/build/utils/intent-cache.js.map +1 -0
- package/build/utils/intent-cache.test.d.ts +2 -0
- package/build/utils/intent-cache.test.d.ts.map +1 -0
- package/build/utils/intent-cache.test.js +290 -0
- package/build/utils/intent-cache.test.js.map +1 -0
- package/build/utils/logger.d.ts +4 -0
- package/build/utils/logger.d.ts.map +1 -0
- package/build/utils/logger.js +9 -0
- package/build/utils/logger.js.map +1 -0
- package/build/utils/paths.d.ts +27 -0
- package/build/utils/paths.d.ts.map +1 -0
- package/build/utils/paths.js +43 -0
- package/build/utils/paths.js.map +1 -0
- package/build/utils/pattern-formatter.d.ts +40 -0
- package/build/utils/pattern-formatter.d.ts.map +1 -0
- package/build/utils/pattern-formatter.js +124 -0
- package/build/utils/pattern-formatter.js.map +1 -0
- package/build/utils/response-helpers.d.ts +17 -0
- package/build/utils/response-helpers.d.ts.map +1 -0
- package/build/utils/response-helpers.js +34 -0
- package/build/utils/response-helpers.js.map +1 -0
- package/build/utils/search-terms.d.ts +17 -0
- package/build/utils/search-terms.d.ts.map +1 -0
- package/build/utils/search-terms.js +71 -0
- package/build/utils/search-terms.js.map +1 -0
- package/build/utils/search-terms.test.d.ts +2 -0
- package/build/utils/search-terms.test.d.ts.map +1 -0
- package/build/utils/search-terms.test.js +107 -0
- package/build/utils/search-terms.test.js.map +1 -0
- package/build/utils/search.d.ts +48 -0
- package/build/utils/search.d.ts.map +1 -0
- package/build/utils/search.js +158 -0
- package/build/utils/search.js.map +1 -0
- package/build/utils/search.test.d.ts +2 -0
- package/build/utils/search.test.d.ts.map +1 -0
- package/build/utils/search.test.js +199 -0
- package/build/utils/search.test.js.map +1 -0
- package/build/utils/semantic-recall.d.ts +38 -0
- package/build/utils/semantic-recall.d.ts.map +1 -0
- package/build/utils/semantic-recall.js +134 -0
- package/build/utils/semantic-recall.js.map +1 -0
- package/build/utils/semantic-recall.test.d.ts +2 -0
- package/build/utils/semantic-recall.test.d.ts.map +1 -0
- package/build/utils/semantic-recall.test.js +326 -0
- package/build/utils/semantic-recall.test.js.map +1 -0
- package/build/utils/source-registry.d.ts +45 -0
- package/build/utils/source-registry.d.ts.map +1 -0
- package/build/utils/source-registry.js +113 -0
- package/build/utils/source-registry.js.map +1 -0
- package/build/utils/source-registry.test.d.ts +2 -0
- package/build/utils/source-registry.test.d.ts.map +1 -0
- package/build/utils/source-registry.test.js +206 -0
- package/build/utils/source-registry.test.js.map +1 -0
- package/build/utils/swift-analysis.d.ts +61 -0
- package/build/utils/swift-analysis.d.ts.map +1 -0
- package/build/utils/swift-analysis.js +339 -0
- package/build/utils/swift-analysis.js.map +1 -0
- package/build/utils/swift-analysis.test.d.ts +2 -0
- package/build/utils/swift-analysis.test.d.ts.map +1 -0
- package/build/utils/swift-analysis.test.js +473 -0
- package/build/utils/swift-analysis.test.js.map +1 -0
- package/package.json +85 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
// src/utils/source-registry.test.ts
|
|
2
|
+
import { describe, it, expect, beforeEach, vi, afterEach } from 'vitest';
|
|
3
|
+
import { getSource, getAllFreeSources, getSources, getSourceNames, searchMultipleSources, prefetchAllSources } from './source-registry.js';
|
|
4
|
+
// Mock pattern data for tests
|
|
5
|
+
const mockPattern = {
|
|
6
|
+
id: 'test-1',
|
|
7
|
+
title: 'Test Pattern',
|
|
8
|
+
url: 'https://example.com/test',
|
|
9
|
+
publishDate: '2024-01-01',
|
|
10
|
+
excerpt: 'Test excerpt',
|
|
11
|
+
content: 'Test content',
|
|
12
|
+
topics: ['swift'],
|
|
13
|
+
relevanceScore: 80,
|
|
14
|
+
hasCode: true,
|
|
15
|
+
};
|
|
16
|
+
describe('source-registry', () => {
|
|
17
|
+
// Mock the searchPatterns and fetchPatterns methods before each test
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
const sources = getAllFreeSources();
|
|
20
|
+
sources.forEach(source => {
|
|
21
|
+
vi.spyOn(source, 'searchPatterns').mockResolvedValue([mockPattern]);
|
|
22
|
+
vi.spyOn(source, 'fetchPatterns').mockResolvedValue([mockPattern]);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
afterEach(() => {
|
|
26
|
+
vi.restoreAllMocks();
|
|
27
|
+
});
|
|
28
|
+
describe('getSource singleton caching', () => {
|
|
29
|
+
it('should return the same instance for multiple calls with the same source name', () => {
|
|
30
|
+
const source1 = getSource('sundell');
|
|
31
|
+
const source2 = getSource('sundell');
|
|
32
|
+
expect(source1).toBe(source2);
|
|
33
|
+
});
|
|
34
|
+
it('should return different instances for different source names', () => {
|
|
35
|
+
const sundell = getSource('sundell');
|
|
36
|
+
const vanderlee = getSource('vanderlee');
|
|
37
|
+
expect(sundell).not.toBe(vanderlee);
|
|
38
|
+
});
|
|
39
|
+
it('should cache all source types independently', () => {
|
|
40
|
+
const sources = ['sundell', 'vanderlee', 'nilcoalescing', 'pointfree'];
|
|
41
|
+
const instances = sources.map(name => getSource(name));
|
|
42
|
+
// Verify all instances are different
|
|
43
|
+
const uniqueInstances = new Set(instances);
|
|
44
|
+
expect(uniqueInstances.size).toBe(sources.length);
|
|
45
|
+
// Verify second calls return cached instances
|
|
46
|
+
sources.forEach((name, index) => {
|
|
47
|
+
expect(getSource(name)).toBe(instances[index]);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
it('should persist cache across multiple calls', () => {
|
|
51
|
+
const first = getSource('nilcoalescing');
|
|
52
|
+
const second = getSource('nilcoalescing');
|
|
53
|
+
const third = getSource('nilcoalescing');
|
|
54
|
+
expect(first).toBe(second);
|
|
55
|
+
expect(second).toBe(third);
|
|
56
|
+
});
|
|
57
|
+
it('should have searchPatterns method on cached instances', () => {
|
|
58
|
+
const source = getSource('sundell');
|
|
59
|
+
expect(source).toHaveProperty('searchPatterns');
|
|
60
|
+
expect(typeof source.searchPatterns).toBe('function');
|
|
61
|
+
});
|
|
62
|
+
it('should have fetchPatterns method on cached instances', () => {
|
|
63
|
+
const source = getSource('pointfree');
|
|
64
|
+
expect(source).toHaveProperty('fetchPatterns');
|
|
65
|
+
expect(typeof source.fetchPatterns).toBe('function');
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
describe('getAllFreeSources', () => {
|
|
69
|
+
it('should return all source instances', () => {
|
|
70
|
+
const sources = getAllFreeSources();
|
|
71
|
+
expect(sources).toHaveLength(4);
|
|
72
|
+
});
|
|
73
|
+
it('should return cached instances', () => {
|
|
74
|
+
const sources1 = getAllFreeSources();
|
|
75
|
+
const sources2 = getAllFreeSources();
|
|
76
|
+
// Compare instances at each index
|
|
77
|
+
sources1.forEach((source, index) => {
|
|
78
|
+
expect(source).toBe(sources2[index]);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
describe('getSources', () => {
|
|
83
|
+
it('should return single source when given one name', () => {
|
|
84
|
+
const sources = getSources('sundell');
|
|
85
|
+
expect(sources).toHaveLength(1);
|
|
86
|
+
expect(sources[0]).toBe(getSource('sundell'));
|
|
87
|
+
});
|
|
88
|
+
it('should return multiple sources when given array of names', () => {
|
|
89
|
+
const sources = getSources(['sundell', 'vanderlee']);
|
|
90
|
+
expect(sources).toHaveLength(2);
|
|
91
|
+
expect(sources[0]).toBe(getSource('sundell'));
|
|
92
|
+
expect(sources[1]).toBe(getSource('vanderlee'));
|
|
93
|
+
});
|
|
94
|
+
it('should return all sources when given "all"', () => {
|
|
95
|
+
const sources = getSources('all');
|
|
96
|
+
expect(sources).toHaveLength(4);
|
|
97
|
+
});
|
|
98
|
+
it('should return cached instances', () => {
|
|
99
|
+
const sources1 = getSources(['pointfree', 'nilcoalescing']);
|
|
100
|
+
const sources2 = getSources(['pointfree', 'nilcoalescing']);
|
|
101
|
+
expect(sources1[0]).toBe(sources2[0]);
|
|
102
|
+
expect(sources1[1]).toBe(sources2[1]);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
describe('getSourceNames', () => {
|
|
106
|
+
it('should return single name in array for single source', () => {
|
|
107
|
+
const names = getSourceNames('sundell');
|
|
108
|
+
expect(names).toEqual(['sundell']);
|
|
109
|
+
});
|
|
110
|
+
it('should return array of names for array input', () => {
|
|
111
|
+
const names = getSourceNames(['sundell', 'vanderlee']);
|
|
112
|
+
expect(names).toEqual(['sundell', 'vanderlee']);
|
|
113
|
+
});
|
|
114
|
+
it('should return all source names for "all"', () => {
|
|
115
|
+
const names = getSourceNames('all');
|
|
116
|
+
expect(names).toHaveLength(4);
|
|
117
|
+
expect(names).toContain('sundell');
|
|
118
|
+
expect(names).toContain('vanderlee');
|
|
119
|
+
expect(names).toContain('nilcoalescing');
|
|
120
|
+
expect(names).toContain('pointfree');
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
describe('searchMultipleSources', () => {
|
|
124
|
+
it('should search all sources by default', async () => {
|
|
125
|
+
const results = await searchMultipleSources('swift async');
|
|
126
|
+
expect(Array.isArray(results)).toBe(true);
|
|
127
|
+
});
|
|
128
|
+
it('should handle individual source searches', async () => {
|
|
129
|
+
const results = await searchMultipleSources('swift', 'sundell');
|
|
130
|
+
expect(Array.isArray(results)).toBe(true);
|
|
131
|
+
});
|
|
132
|
+
it('should handle array of sources', async () => {
|
|
133
|
+
const results = await searchMultipleSources('swift', ['sundell', 'vanderlee']);
|
|
134
|
+
expect(Array.isArray(results)).toBe(true);
|
|
135
|
+
});
|
|
136
|
+
it('should collect results even if some sources fail', async () => {
|
|
137
|
+
// This tests the Promise.allSettled behavior
|
|
138
|
+
const results = await searchMultipleSources('test query');
|
|
139
|
+
// Should not throw even if individual sources fail
|
|
140
|
+
expect(Array.isArray(results)).toBe(true);
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
describe('prefetchAllSources', () => {
|
|
144
|
+
it('should return SettledResult array', async () => {
|
|
145
|
+
const results = await prefetchAllSources();
|
|
146
|
+
expect(Array.isArray(results)).toBe(true);
|
|
147
|
+
expect(results.length).toBe(4);
|
|
148
|
+
});
|
|
149
|
+
it('should return results with status property', async () => {
|
|
150
|
+
const results = await prefetchAllSources();
|
|
151
|
+
results.forEach(result => {
|
|
152
|
+
expect(result).toHaveProperty('status');
|
|
153
|
+
expect(['fulfilled', 'rejected']).toContain(result.status);
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
it('should handle partial failures gracefully', async () => {
|
|
157
|
+
// Even if some sources fail, the function should complete
|
|
158
|
+
const results = await prefetchAllSources();
|
|
159
|
+
expect(results).toBeDefined();
|
|
160
|
+
expect(results.length).toBe(4);
|
|
161
|
+
// Count successful and failed
|
|
162
|
+
const successful = results.filter(r => r.status === 'fulfilled').length;
|
|
163
|
+
const failed = results.filter(r => r.status === 'rejected').length;
|
|
164
|
+
expect(successful + failed).toBe(4);
|
|
165
|
+
});
|
|
166
|
+
it('should provide access to fulfilled results', async () => {
|
|
167
|
+
const results = await prefetchAllSources();
|
|
168
|
+
const fulfilled = results.filter((r) => r.status === 'fulfilled');
|
|
169
|
+
fulfilled.forEach(result => {
|
|
170
|
+
expect(result).toHaveProperty('value');
|
|
171
|
+
expect(Array.isArray(result.value)).toBe(true);
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
it('should provide access to rejection reasons', async () => {
|
|
175
|
+
const results = await prefetchAllSources();
|
|
176
|
+
const rejected = results.filter((r) => r.status === 'rejected');
|
|
177
|
+
rejected.forEach(result => {
|
|
178
|
+
expect(result).toHaveProperty('reason');
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
describe('cache persistence integration', () => {
|
|
183
|
+
it('should maintain same instances across different function calls', () => {
|
|
184
|
+
const direct = getSource('sundell');
|
|
185
|
+
const fromArray = getSources(['sundell'])[0];
|
|
186
|
+
const fromAll = getAllFreeSources()[0]; // Assuming sundell is first
|
|
187
|
+
expect(direct).toBe(fromArray);
|
|
188
|
+
// Note: fromAll might be in a different order, so we just check it's in the set
|
|
189
|
+
const allSources = getAllFreeSources();
|
|
190
|
+
expect(allSources).toContain(direct);
|
|
191
|
+
});
|
|
192
|
+
it('should use cached instances in search operations', async () => {
|
|
193
|
+
const sourceBefore = getSource('sundell');
|
|
194
|
+
await searchMultipleSources('test', 'sundell');
|
|
195
|
+
const sourceAfter = getSource('sundell');
|
|
196
|
+
expect(sourceBefore).toBe(sourceAfter);
|
|
197
|
+
});
|
|
198
|
+
it('should use cached instances in prefetch operations', async () => {
|
|
199
|
+
const sourceBefore = getSource('pointfree');
|
|
200
|
+
await prefetchAllSources();
|
|
201
|
+
const sourceAfter = getSource('pointfree');
|
|
202
|
+
expect(sourceBefore).toBe(sourceAfter);
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
//# sourceMappingURL=source-registry.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-registry.test.js","sourceRoot":"","sources":["../../src/utils/source-registry.test.ts"],"names":[],"mappings":"AAAA,oCAAoC;AAEpC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EACL,SAAS,EAC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vC,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,kDAAkD,EAAE,KAAK,IAAI,EAAE;YAChE,MAAM,YAAY,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;YAC1C,MAAM,qBAAqB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;YAC/C,MAAM,WAAW,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;YAEzC,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,oDAAoD,EAAE,KAAK,IAAI,EAAE;YAClE,MAAM,YAAY,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;YAC5C,MAAM,kBAAkB,EAAE,CAAC;YAC3B,MAAM,WAAW,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;YAE3C,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for analyzing Swift code content and detecting topics
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Detect topics from text based on keyword matching
|
|
6
|
+
* @param text The text to analyze
|
|
7
|
+
* @param keywords Map of topic names to keyword arrays
|
|
8
|
+
* @returns Array of detected topic names
|
|
9
|
+
*/
|
|
10
|
+
export declare function detectTopics(text: string, keywords: Record<string, string[]>): string[];
|
|
11
|
+
/**
|
|
12
|
+
* Check if content contains Swift code patterns
|
|
13
|
+
* @param content The content to check
|
|
14
|
+
* @returns True if Swift code patterns are detected
|
|
15
|
+
*/
|
|
16
|
+
export declare function hasCodeContent(content: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Calculate relevance score based on keyword presence and code content
|
|
19
|
+
* @param text The text to analyze
|
|
20
|
+
* @param hasCode Whether the content has code
|
|
21
|
+
* @param qualitySignals Map of quality signals to point values
|
|
22
|
+
* @param baseScore Starting score (default: 50)
|
|
23
|
+
* @param codeBonus Bonus points for having code (default: 10-15)
|
|
24
|
+
* @returns Relevance score (0-100)
|
|
25
|
+
*/
|
|
26
|
+
export declare function calculateRelevance(text: string, hasCode: boolean, qualitySignals: Record<string, number>, baseScore?: number, codeBonus?: number): number;
|
|
27
|
+
/**
|
|
28
|
+
* Extract code snippets from content
|
|
29
|
+
* @param content The content to extract from
|
|
30
|
+
* @param maxSnippets Maximum number of snippets to return (default: 2)
|
|
31
|
+
* @returns Array of code snippets
|
|
32
|
+
*/
|
|
33
|
+
export declare function extractCodeSnippets(content: string, maxSnippets?: number): string[];
|
|
34
|
+
/**
|
|
35
|
+
* Extract Swift-specific techniques and APIs from content
|
|
36
|
+
* @param content The content to analyze
|
|
37
|
+
* @returns Array of detected techniques (max 5, unique)
|
|
38
|
+
*/
|
|
39
|
+
export declare function extractTechniques(content: string): string[];
|
|
40
|
+
/**
|
|
41
|
+
* Detect complexity level of content
|
|
42
|
+
* @param content The content to analyze
|
|
43
|
+
* @param topics Detected topics
|
|
44
|
+
* @returns Complexity level
|
|
45
|
+
*/
|
|
46
|
+
export declare function detectComplexity(content: string, topics: string[]): 'beginner' | 'intermediate' | 'advanced';
|
|
47
|
+
/**
|
|
48
|
+
* Truncate text at sentence boundary
|
|
49
|
+
* @param text Text to truncate
|
|
50
|
+
* @param maxLength Maximum length
|
|
51
|
+
* @returns Truncated text without trailing ellipsis
|
|
52
|
+
*/
|
|
53
|
+
export declare function truncateAtSentence(text: string, maxLength: number): string;
|
|
54
|
+
/**
|
|
55
|
+
* Extract descriptive title from content
|
|
56
|
+
* @param content Content to extract from
|
|
57
|
+
* @param fallbackTitle Fallback if no good title found
|
|
58
|
+
* @returns Extracted or fallback title
|
|
59
|
+
*/
|
|
60
|
+
export declare function extractDescriptiveTitle(content: string, fallbackTitle: string): string;
|
|
61
|
+
//# sourceMappingURL=swift-analysis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swift-analysis.d.ts","sourceRoot":"","sources":["../../src/utils/swift-analysis.ts"],"names":[],"mappings":"AAEA;;GAEG;AAEH;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,CAWvF;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CA8BvD;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACtC,SAAS,GAAE,MAAW,EACtB,SAAS,GAAE,MAAW,GACrB,MAAM,CAkBR;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,GAAE,MAAU,GAAG,MAAM,EAAE,CAiCtF;AAWD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAqE3D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,GAAG,cAAc,GAAG,UAAU,CA2C5G;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAyC1E;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAsCtF"}
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
// src/utils/swift-analysis.ts
|
|
2
|
+
/**
|
|
3
|
+
* Shared utilities for analyzing Swift code content and detecting topics
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Detect topics from text based on keyword matching
|
|
7
|
+
* @param text The text to analyze
|
|
8
|
+
* @param keywords Map of topic names to keyword arrays
|
|
9
|
+
* @returns Array of detected topic names
|
|
10
|
+
*/
|
|
11
|
+
export function detectTopics(text, keywords) {
|
|
12
|
+
const topics = [];
|
|
13
|
+
const lower = text.toLowerCase();
|
|
14
|
+
for (const [topic, words] of Object.entries(keywords)) {
|
|
15
|
+
if (words.some(w => lower.includes(w))) {
|
|
16
|
+
topics.push(topic);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return topics;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Check if content contains Swift code patterns
|
|
23
|
+
* @param content The content to check
|
|
24
|
+
* @returns True if Swift code patterns are detected
|
|
25
|
+
*/
|
|
26
|
+
export function hasCodeContent(content) {
|
|
27
|
+
// Check for common Swift code patterns
|
|
28
|
+
if (/\b(func|class|struct|protocol|extension|enum|actor)\s+\w+/.test(content)) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
// Check for markdown code blocks
|
|
32
|
+
if (content.includes('```')) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
// Check for HTML code tags
|
|
36
|
+
if (content.includes('<code>') || content.includes('<pre>')) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
// Check for additional Swift-specific patterns
|
|
40
|
+
const codeIndicators = [
|
|
41
|
+
/\blet\s+\w+\s*[=:]/,
|
|
42
|
+
/\bvar\s+\w+\s*[=:]/,
|
|
43
|
+
/\breturn\s+\w+/,
|
|
44
|
+
/\bguard\s+let/,
|
|
45
|
+
/\bif\s+let/,
|
|
46
|
+
/\basync\s+(func|let|var|throws)/,
|
|
47
|
+
/\bawait\s+\w+/,
|
|
48
|
+
/\b\w+\s*\(\s*\)\s*->\s*\w+/,
|
|
49
|
+
/@\w+\s+(struct|class|func|var)/,
|
|
50
|
+
];
|
|
51
|
+
return codeIndicators.some(pattern => pattern.test(content));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Calculate relevance score based on keyword presence and code content
|
|
55
|
+
* @param text The text to analyze
|
|
56
|
+
* @param hasCode Whether the content has code
|
|
57
|
+
* @param qualitySignals Map of quality signals to point values
|
|
58
|
+
* @param baseScore Starting score (default: 50)
|
|
59
|
+
* @param codeBonus Bonus points for having code (default: 10-15)
|
|
60
|
+
* @returns Relevance score (0-100)
|
|
61
|
+
*/
|
|
62
|
+
export function calculateRelevance(text, hasCode, qualitySignals, baseScore = 50, codeBonus = 10) {
|
|
63
|
+
const lower = text.toLowerCase();
|
|
64
|
+
let score = baseScore;
|
|
65
|
+
// Add points for quality signals
|
|
66
|
+
for (const [keyword, points] of Object.entries(qualitySignals)) {
|
|
67
|
+
if (lower.includes(keyword)) {
|
|
68
|
+
score += points;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Bonus for code content
|
|
72
|
+
if (hasCode) {
|
|
73
|
+
score += codeBonus;
|
|
74
|
+
}
|
|
75
|
+
// Cap at 100
|
|
76
|
+
return Math.min(100, score);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Extract code snippets from content
|
|
80
|
+
* @param content The content to extract from
|
|
81
|
+
* @param maxSnippets Maximum number of snippets to return (default: 2)
|
|
82
|
+
* @returns Array of code snippets
|
|
83
|
+
*/
|
|
84
|
+
export function extractCodeSnippets(content, maxSnippets = 2) {
|
|
85
|
+
const snippets = [];
|
|
86
|
+
// Extract markdown code blocks (```swift or ```)
|
|
87
|
+
const markdownRegex = /```(?:swift)?\n?([\s\S]*?)```/g;
|
|
88
|
+
let match;
|
|
89
|
+
while ((match = markdownRegex.exec(content)) !== null) {
|
|
90
|
+
const code = match[1].trim();
|
|
91
|
+
if (code && code.split('\n').length >= 2) {
|
|
92
|
+
snippets.push(truncateSnippet(code));
|
|
93
|
+
}
|
|
94
|
+
if (snippets.length >= maxSnippets)
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
// Extract HTML code blocks if we don't have enough snippets
|
|
98
|
+
if (snippets.length < maxSnippets) {
|
|
99
|
+
const htmlRegex = /<pre><code[^>]*>([\s\S]*?)<\/code><\/pre>/g;
|
|
100
|
+
while ((match = htmlRegex.exec(content)) !== null) {
|
|
101
|
+
const code = match[1]
|
|
102
|
+
.replace(/<[^>]+>/g, '') // Remove HTML tags
|
|
103
|
+
.replace(/</g, '<')
|
|
104
|
+
.replace(/>/g, '>')
|
|
105
|
+
.replace(/&/g, '&')
|
|
106
|
+
.replace(/"/g, '"')
|
|
107
|
+
.trim();
|
|
108
|
+
if (code && code.split('\n').length >= 2) {
|
|
109
|
+
snippets.push(truncateSnippet(code));
|
|
110
|
+
}
|
|
111
|
+
if (snippets.length >= maxSnippets)
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return snippets.slice(0, maxSnippets);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Truncate a code snippet to ~10 lines
|
|
119
|
+
*/
|
|
120
|
+
function truncateSnippet(code) {
|
|
121
|
+
const lines = code.split('\n');
|
|
122
|
+
if (lines.length <= 10)
|
|
123
|
+
return code;
|
|
124
|
+
return lines.slice(0, 10).join('\n') + '\n// ...';
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Extract Swift-specific techniques and APIs from content
|
|
128
|
+
* @param content The content to analyze
|
|
129
|
+
* @returns Array of detected techniques (max 5, unique)
|
|
130
|
+
*/
|
|
131
|
+
export function extractTechniques(content) {
|
|
132
|
+
const techniques = new Set();
|
|
133
|
+
// Swift attributes
|
|
134
|
+
const attributes = [
|
|
135
|
+
'@Observable', '@MainActor', '@State', '@Binding', '@Environment',
|
|
136
|
+
'@Query', '@Model', '@Published', '@StateObject', '@ObservedObject',
|
|
137
|
+
'@ViewBuilder', '@resultBuilder', '@available'
|
|
138
|
+
];
|
|
139
|
+
for (const attr of attributes) {
|
|
140
|
+
if (content.includes(attr)) {
|
|
141
|
+
techniques.add(attr);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// Concurrency patterns
|
|
145
|
+
const concurrencyPatterns = [
|
|
146
|
+
{ pattern: /\basync\s+(?:func|let|var|throws)/, name: 'async/await' },
|
|
147
|
+
{ pattern: /\bawait\s+/, name: 'async/await' },
|
|
148
|
+
{ pattern: /\bTask\s*{/, name: 'Task' },
|
|
149
|
+
{ pattern: /\bTaskGroup/, name: 'TaskGroup' },
|
|
150
|
+
{ pattern: /\bwithCheckedContinuation/, name: 'withCheckedContinuation' },
|
|
151
|
+
{ pattern: /\bwithCheckedThrowingContinuation/, name: 'withCheckedThrowingContinuation' },
|
|
152
|
+
{ pattern: /\bactor\s+\w+/, name: 'actor' },
|
|
153
|
+
{ pattern: /\bSendable/, name: 'Sendable' },
|
|
154
|
+
];
|
|
155
|
+
for (const { pattern, name } of concurrencyPatterns) {
|
|
156
|
+
if (pattern.test(content)) {
|
|
157
|
+
techniques.add(name);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// SwiftUI patterns
|
|
161
|
+
const swiftUIPatterns = [
|
|
162
|
+
'NavigationStack', 'NavigationSplitView', '.navigationDestination',
|
|
163
|
+
'.sheet', '.fullScreenCover', '.toolbar', '.searchable',
|
|
164
|
+
'List', 'Form', 'ScrollView', 'LazyVStack', 'LazyHStack'
|
|
165
|
+
];
|
|
166
|
+
for (const pattern of swiftUIPatterns) {
|
|
167
|
+
if (content.includes(pattern)) {
|
|
168
|
+
techniques.add(pattern);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// SwiftData patterns
|
|
172
|
+
const swiftDataPatterns = ['@Model', '@Query', 'ModelContext', 'ModelContainer'];
|
|
173
|
+
for (const pattern of swiftDataPatterns) {
|
|
174
|
+
if (content.includes(pattern)) {
|
|
175
|
+
techniques.add(pattern);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// Frameworks (when used in code context)
|
|
179
|
+
const frameworks = ['SwiftUI', 'Combine', 'SwiftData', 'CoreData', 'UIKit'];
|
|
180
|
+
for (const framework of frameworks) {
|
|
181
|
+
// Check if framework appears near code indicators
|
|
182
|
+
if (content.includes(framework) && (content.includes(`import ${framework}`) ||
|
|
183
|
+
content.includes(`${framework}.`))) {
|
|
184
|
+
techniques.add(framework);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
// Return up to 5 techniques
|
|
188
|
+
return Array.from(techniques).slice(0, 5);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Detect complexity level of content
|
|
192
|
+
* @param content The content to analyze
|
|
193
|
+
* @param topics Detected topics
|
|
194
|
+
* @returns Complexity level
|
|
195
|
+
*/
|
|
196
|
+
export function detectComplexity(content, topics) {
|
|
197
|
+
const lower = content.toLowerCase();
|
|
198
|
+
// Advanced indicators
|
|
199
|
+
const advancedKeywords = [
|
|
200
|
+
'performance', 'optimization', 'benchmark', 'profiling',
|
|
201
|
+
'unsafe', 'pointer', 'memory management',
|
|
202
|
+
'macro', '@attached', '@freestanding',
|
|
203
|
+
'race condition', 'thread safety', 'atomic',
|
|
204
|
+
'custom property wrapper', 'type erasure',
|
|
205
|
+
'protocol witness', 'existential'
|
|
206
|
+
];
|
|
207
|
+
const hasAdvancedKeyword = advancedKeywords.some(kw => lower.includes(kw));
|
|
208
|
+
// Beginner indicators
|
|
209
|
+
const beginnerKeywords = [
|
|
210
|
+
'introduction', 'getting started', 'basics', 'tutorial',
|
|
211
|
+
'hello world', 'first', 'simple example'
|
|
212
|
+
];
|
|
213
|
+
const hasBeginnerKeyword = beginnerKeywords.some(kw => lower.includes(kw));
|
|
214
|
+
// Count complexity signals
|
|
215
|
+
const wordCount = content.split(/\s+/).length;
|
|
216
|
+
const codeBlocks = (content.match(/```/g) || []).length / 2;
|
|
217
|
+
const topicCount = topics.length;
|
|
218
|
+
// Decision logic
|
|
219
|
+
if (hasAdvancedKeyword || (topicCount >= 4 && codeBlocks >= 3)) {
|
|
220
|
+
return 'advanced';
|
|
221
|
+
}
|
|
222
|
+
if (hasBeginnerKeyword && topicCount <= 1 && wordCount < 500) {
|
|
223
|
+
return 'beginner';
|
|
224
|
+
}
|
|
225
|
+
if (topicCount <= 1 && codeBlocks <= 1 && wordCount < 300) {
|
|
226
|
+
return 'beginner';
|
|
227
|
+
}
|
|
228
|
+
// Default to intermediate for most content
|
|
229
|
+
return 'intermediate';
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Truncate text at sentence boundary
|
|
233
|
+
* @param text Text to truncate
|
|
234
|
+
* @param maxLength Maximum length
|
|
235
|
+
* @returns Truncated text without trailing ellipsis
|
|
236
|
+
*/
|
|
237
|
+
export function truncateAtSentence(text, maxLength) {
|
|
238
|
+
if (text.length <= maxLength) {
|
|
239
|
+
return text;
|
|
240
|
+
}
|
|
241
|
+
// Find sentence boundaries within reasonable range (60% allows more flexibility)
|
|
242
|
+
const minLength = Math.floor(maxLength * 0.6);
|
|
243
|
+
// Look for sentence endings (. ! ?) - check both with and without space
|
|
244
|
+
let bestPos = -1;
|
|
245
|
+
// Try to find sentence ending with space after (cleaner break)
|
|
246
|
+
for (const punct of ['. ', '! ', '? ']) {
|
|
247
|
+
const pos = text.lastIndexOf(punct, maxLength);
|
|
248
|
+
if (pos >= minLength && pos > bestPos) {
|
|
249
|
+
bestPos = pos + punct.length - 1; // Include punctuation, exclude trailing space
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
// If no sentence ending with space, try just the punctuation
|
|
253
|
+
if (bestPos === -1) {
|
|
254
|
+
for (const punct of ['.', '!', '?']) {
|
|
255
|
+
const pos = text.lastIndexOf(punct, maxLength);
|
|
256
|
+
if (pos >= minLength && pos > bestPos) {
|
|
257
|
+
bestPos = pos + 1; // Include the punctuation
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
if (bestPos > 0) {
|
|
262
|
+
return text.substring(0, bestPos).trim();
|
|
263
|
+
}
|
|
264
|
+
// Fall back to word boundary
|
|
265
|
+
const wordBoundary = text.lastIndexOf(' ', maxLength);
|
|
266
|
+
if (wordBoundary > minLength) {
|
|
267
|
+
return text.substring(0, wordBoundary).trim();
|
|
268
|
+
}
|
|
269
|
+
// Last resort: cut at maxLength but try to avoid mid-word
|
|
270
|
+
return text.substring(0, maxLength).trim();
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Extract descriptive title from content
|
|
274
|
+
* @param content Content to extract from
|
|
275
|
+
* @param fallbackTitle Fallback if no good title found
|
|
276
|
+
* @returns Extracted or fallback title
|
|
277
|
+
*/
|
|
278
|
+
export function extractDescriptiveTitle(content, fallbackTitle) {
|
|
279
|
+
// Try to find H1 in markdown
|
|
280
|
+
const h1Match = content.match(/^#\s+(.+)$/m);
|
|
281
|
+
if (h1Match) {
|
|
282
|
+
const title = cleanTitle(h1Match[1]);
|
|
283
|
+
if (!isGenericTitle(title)) {
|
|
284
|
+
return title;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
// Try HTML H1
|
|
288
|
+
const htmlH1Match = content.match(/<h1[^>]*>(.*?)<\/h1>/i);
|
|
289
|
+
if (htmlH1Match) {
|
|
290
|
+
const title = cleanTitle(htmlH1Match[1]);
|
|
291
|
+
if (!isGenericTitle(title)) {
|
|
292
|
+
return title;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
// Try H2 if H1 was generic
|
|
296
|
+
const h2Match = content.match(/^##\s+(.+)$/m);
|
|
297
|
+
if (h2Match) {
|
|
298
|
+
const title = cleanTitle(h2Match[1]);
|
|
299
|
+
if (!isGenericTitle(title)) {
|
|
300
|
+
return title;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
// Try HTML H2
|
|
304
|
+
const htmlH2Match = content.match(/<h2[^>]*>(.*?)<\/h2>/i);
|
|
305
|
+
if (htmlH2Match) {
|
|
306
|
+
const title = cleanTitle(htmlH2Match[1]);
|
|
307
|
+
if (!isGenericTitle(title)) {
|
|
308
|
+
return title;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return fallbackTitle;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Clean title by removing HTML tags and extra whitespace
|
|
315
|
+
*/
|
|
316
|
+
function cleanTitle(title) {
|
|
317
|
+
return title
|
|
318
|
+
.replace(/<[^>]+>/g, '') // Remove HTML tags
|
|
319
|
+
.replace(/</g, '<')
|
|
320
|
+
.replace(/>/g, '>')
|
|
321
|
+
.replace(/&/g, '&')
|
|
322
|
+
.replace(/"/g, '"')
|
|
323
|
+
.replace(/\s+/g, ' ')
|
|
324
|
+
.trim();
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Check if title is too generic to be useful
|
|
328
|
+
*/
|
|
329
|
+
function isGenericTitle(title) {
|
|
330
|
+
const genericPatterns = [
|
|
331
|
+
/^newsletter\s*#?\d+$/i,
|
|
332
|
+
/^issue\s*#?\d+$/i,
|
|
333
|
+
/^swift by sundell$/i,
|
|
334
|
+
/^blog$/i,
|
|
335
|
+
/^article$/i,
|
|
336
|
+
];
|
|
337
|
+
return genericPatterns.some(pattern => pattern.test(title));
|
|
338
|
+
}
|
|
339
|
+
//# sourceMappingURL=swift-analysis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swift-analysis.js","sourceRoot":"","sources":["../../src/utils/swift-analysis.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAE9B;;GAEG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,QAAkC;IAC3E,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAEjC,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtD,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAA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