solvdex 1.0.0
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 +274 -0
- package/dist/hooks/error-lookup.d.ts +4 -0
- package/dist/hooks/error-lookup.d.ts.map +1 -0
- package/dist/hooks/error-lookup.js +92 -0
- package/dist/hooks/error-lookup.js.map +1 -0
- package/dist/hooks/post-task.d.ts +15 -0
- package/dist/hooks/post-task.d.ts.map +1 -0
- package/dist/hooks/post-task.js +246 -0
- package/dist/hooks/post-task.js.map +1 -0
- package/dist/hooks/prompt-enrich.d.ts +16 -0
- package/dist/hooks/prompt-enrich.d.ts.map +1 -0
- package/dist/hooks/prompt-enrich.js +141 -0
- package/dist/hooks/prompt-enrich.js.map +1 -0
- package/dist/hooks/session-start-cli.d.ts +3 -0
- package/dist/hooks/session-start-cli.d.ts.map +1 -0
- package/dist/hooks/session-start-cli.js +81 -0
- package/dist/hooks/session-start-cli.js.map +1 -0
- package/dist/hooks/session-start.d.ts +4 -0
- package/dist/hooks/session-start.d.ts.map +1 -0
- package/dist/hooks/session-start.js +134 -0
- package/dist/hooks/session-start.js.map +1 -0
- package/dist/src/audit.d.ts +63 -0
- package/dist/src/audit.d.ts.map +1 -0
- package/dist/src/audit.js +229 -0
- package/dist/src/audit.js.map +1 -0
- package/dist/src/cache.d.ts +54 -0
- package/dist/src/cache.d.ts.map +1 -0
- package/dist/src/cache.js +167 -0
- package/dist/src/cache.js.map +1 -0
- package/dist/src/config.d.ts +52 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +175 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/entry.d.ts +154 -0
- package/dist/src/entry.d.ts.map +1 -0
- package/dist/src/entry.js +469 -0
- package/dist/src/entry.js.map +1 -0
- package/dist/src/errors.d.ts +65 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +121 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/frontmatter.d.ts +28 -0
- package/dist/src/frontmatter.d.ts.map +1 -0
- package/dist/src/frontmatter.js +111 -0
- package/dist/src/frontmatter.js.map +1 -0
- package/dist/src/index.d.ts +35 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +188 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/maturity.d.ts +31 -0
- package/dist/src/maturity.d.ts.map +1 -0
- package/dist/src/maturity.js +96 -0
- package/dist/src/maturity.js.map +1 -0
- package/dist/src/quality.d.ts +23 -0
- package/dist/src/quality.d.ts.map +1 -0
- package/dist/src/quality.js +236 -0
- package/dist/src/quality.js.map +1 -0
- package/dist/src/search.d.ts +35 -0
- package/dist/src/search.d.ts.map +1 -0
- package/dist/src/search.js +263 -0
- package/dist/src/search.js.map +1 -0
- package/dist/src/similarity.d.ts +42 -0
- package/dist/src/similarity.d.ts.map +1 -0
- package/dist/src/similarity.js +111 -0
- package/dist/src/similarity.js.map +1 -0
- package/dist/src/stats.d.ts +56 -0
- package/dist/src/stats.d.ts.map +1 -0
- package/dist/src/stats.js +198 -0
- package/dist/src/stats.js.map +1 -0
- package/dist/src/templates.d.ts +63 -0
- package/dist/src/templates.d.ts.map +1 -0
- package/dist/src/templates.js +347 -0
- package/dist/src/templates.js.map +1 -0
- package/dist/src/transfer.d.ts +92 -0
- package/dist/src/transfer.d.ts.map +1 -0
- package/dist/src/transfer.js +215 -0
- package/dist/src/transfer.js.map +1 -0
- package/dist/src/types.d.ts +270 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +153 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/validate.d.ts +90 -0
- package/dist/src/validate.d.ts.map +1 -0
- package/dist/src/validate.js +295 -0
- package/dist/src/validate.js.map +1 -0
- package/hooks/error-lookup.ts +110 -0
- package/hooks/hooks.json +49 -0
- package/hooks/post-task.ts +309 -0
- package/hooks/prompt-enrich.ts +162 -0
- package/hooks/session-start-cli.ts +96 -0
- package/hooks/session-start.ts +159 -0
- package/package.json +40 -0
- package/scripts/error-lookup.py +64 -0
- package/scripts/post-task.py +60 -0
- package/scripts/prompt-enrich.py +64 -0
- package/scripts/session-start.py +64 -0
- package/skills/wiki/SKILL.md +61 -0
- package/skills/wiki-add/SKILL.md +90 -0
- package/skills/wiki-browse/SKILL.md +108 -0
- package/skills/wiki-capture/SKILL.md +265 -0
- package/skills/wiki-explorer/SKILL.md +223 -0
- package/skills/wiki-export/SKILL.md +101 -0
- package/skills/wiki-fix/SKILL.md +86 -0
- package/skills/wiki-flag/SKILL.md +47 -0
- package/skills/wiki-import/SKILL.md +128 -0
- package/skills/wiki-init/SKILL.md +72 -0
- package/skills/wiki-scan/SKILL.md +98 -0
- package/skills/wiki-search/SKILL.md +86 -0
- package/skills/wiki-stats/SKILL.md +129 -0
- package/skills/wiki-status/SKILL.md +78 -0
- package/skills/wiki-test-trigger/SKILL.md +173 -0
- package/skills/wiki-validate/SKILL.md +62 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/templates.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.CATEGORY_TEMPLATES = void 0;
|
|
5
|
+
exports.getTemplate = getTemplate;
|
|
6
|
+
exports.generateStubContent = generateStubContent;
|
|
7
|
+
exports.generateOverviewContent = generateOverviewContent;
|
|
8
|
+
exports.getAvailableTemplates = getAvailableTemplates;
|
|
9
|
+
exports.hasTemplate = hasTemplate;
|
|
10
|
+
exports.getCategoryDescription = getCategoryDescription;
|
|
11
|
+
exports.generateWikiReadme = generateWikiReadme;
|
|
12
|
+
/**
|
|
13
|
+
* Template definitions for each default category.
|
|
14
|
+
* Maps category names to their template sections.
|
|
15
|
+
*/
|
|
16
|
+
exports.CATEGORY_TEMPLATES = {
|
|
17
|
+
issues: [
|
|
18
|
+
{ heading: 'Problem', placeholder: 'Describe the error message or unexpected behavior.\n\nExample: `Error: ENOENT: no such file or directory`' },
|
|
19
|
+
{ heading: 'Cause', placeholder: 'Explain why this happens.\n\nExample: The config file is missing because `npm install` was not run.' },
|
|
20
|
+
{ heading: 'Solution', placeholder: 'Step-by-step fix:\n1. First step\n2. Second step\n\n```bash\n# Command example\nnpm install\n```' },
|
|
21
|
+
{ heading: 'Verification', placeholder: 'How to confirm the fix worked:\n- Run `npm test` - should pass\n- Check that X file exists' },
|
|
22
|
+
{ heading: 'Related', placeholder: `## Wiki Entries
|
|
23
|
+
- [[issues/related-issue]]
|
|
24
|
+
|
|
25
|
+
## Source Files
|
|
26
|
+
- \`src/services/auth.ts:45\` - where the fix was applied
|
|
27
|
+
|
|
28
|
+
## Tests (optional)
|
|
29
|
+
- \`tests/auth.test.ts\` - related test coverage
|
|
30
|
+
|
|
31
|
+
## C3 Components (optional)
|
|
32
|
+
- [[c3-2-authentication]] - architecture context
|
|
33
|
+
|
|
34
|
+
## External Docs
|
|
35
|
+
- [Library docs](https://example.com/docs)` }
|
|
36
|
+
],
|
|
37
|
+
patterns: [
|
|
38
|
+
{ heading: 'Intent', placeholder: 'What problem this pattern solves and when to use it.' },
|
|
39
|
+
{ heading: 'Structure', placeholder: 'Key components:\n- Component A: does X\n- Component B: does Y' },
|
|
40
|
+
{ heading: 'Example', placeholder: '```typescript\n// Code example showing the pattern\nfunction example() {\n // implementation\n}\n```' },
|
|
41
|
+
{ heading: 'Applies To', placeholder: '- `src/services/*.ts` - service layer\n- `src/handlers/*.ts` - request handlers' },
|
|
42
|
+
{ heading: 'Related', placeholder: `## Wiki Entries
|
|
43
|
+
- [[patterns/related-pattern]]
|
|
44
|
+
|
|
45
|
+
## Source Files
|
|
46
|
+
- \`src/utils/helpers.ts\` - pattern implementation reference
|
|
47
|
+
|
|
48
|
+
## Tests (optional)
|
|
49
|
+
- \`tests/utils.test.ts\` - pattern usage examples
|
|
50
|
+
|
|
51
|
+
## C3 Components (optional)
|
|
52
|
+
- [[c3-3-data-layer]] - architecture context
|
|
53
|
+
|
|
54
|
+
## External Docs
|
|
55
|
+
- [Design pattern reference](https://example.com/patterns)` }
|
|
56
|
+
],
|
|
57
|
+
gotchas: [
|
|
58
|
+
{ heading: 'Trap', placeholder: 'The pitfall or unexpected behavior that catches people off guard.' },
|
|
59
|
+
{ heading: 'Why It Happens', placeholder: 'Technical explanation of the underlying cause.' },
|
|
60
|
+
{ heading: 'Correct Approach', placeholder: 'The right way to handle this:\n```go\n// Correct example\n```\n\nNEVER do: X, Y, Z' },
|
|
61
|
+
{ heading: 'Related', placeholder: `## Wiki Entries
|
|
62
|
+
- [[gotchas/related-gotcha]]
|
|
63
|
+
|
|
64
|
+
## Source Files
|
|
65
|
+
- \`src/config/settings.ts:12\` - where the gotcha manifests
|
|
66
|
+
|
|
67
|
+
## Tests (optional)
|
|
68
|
+
- \`tests/config.test.ts\` - test demonstrating the edge case
|
|
69
|
+
|
|
70
|
+
## C3 Components (optional)
|
|
71
|
+
- [[c3-4-configuration]] - architecture context
|
|
72
|
+
|
|
73
|
+
## External Docs
|
|
74
|
+
- [Language spec](https://example.com/spec) - official documentation
|
|
75
|
+
- Compliance: GDPR, Security Policy` }
|
|
76
|
+
],
|
|
77
|
+
testing: [
|
|
78
|
+
{ heading: 'Scenario', placeholder: 'What test scenario or behavior is being tested.\n\nExample: User login with invalid credentials returns 401.' },
|
|
79
|
+
{ heading: 'Setup', placeholder: 'Test environment setup:\n- Dependencies/mocks required\n- Test data fixtures\n- Configuration' },
|
|
80
|
+
{ heading: 'Assertions', placeholder: 'Key assertions to verify:\n```typescript\nexpect(result.status).toBe(401);\nexpect(result.body.error).toBeDefined();\n```' },
|
|
81
|
+
{ heading: 'Mocks/Fixtures', placeholder: 'Mock implementations and test fixtures:\n```typescript\nconst mockUser = { id: 1, email: "test@example.com" };\njest.mock("./auth", () => ({ validate: jest.fn() }));\n```' },
|
|
82
|
+
{ heading: 'Edge Cases', placeholder: '- Empty input\n- Null values\n- Boundary conditions\n- Error scenarios' },
|
|
83
|
+
{ heading: 'Related', placeholder: `## Wiki Entries
|
|
84
|
+
- [[testing/related-test]]
|
|
85
|
+
|
|
86
|
+
## Source Files
|
|
87
|
+
- \`src/services/auth.ts\` - code under test
|
|
88
|
+
|
|
89
|
+
## Tests
|
|
90
|
+
- \`tests/auth.test.ts\` - test file location
|
|
91
|
+
|
|
92
|
+
## External Docs
|
|
93
|
+
- [Testing library docs](https://example.com/docs)` }
|
|
94
|
+
],
|
|
95
|
+
docs: [
|
|
96
|
+
{ heading: 'Audience', placeholder: 'Who this documentation is for:\n- Developers (internal)\n- API consumers (external)\n- End users' },
|
|
97
|
+
{ heading: 'Template', placeholder: '## Section Structure\n\n### Overview\nBrief description...\n\n### Usage\nHow to use...\n\n### Examples\nCode examples...' },
|
|
98
|
+
{ heading: 'Examples', placeholder: '```typescript\n// Example code demonstrating usage\nconst client = new ApiClient();\nawait client.connect();\n```' },
|
|
99
|
+
{ heading: 'Style Notes', placeholder: '- Use active voice\n- Include code examples for every endpoint\n- Keep paragraphs short (3-4 sentences max)' },
|
|
100
|
+
{ heading: 'Related', placeholder: `## Wiki Entries
|
|
101
|
+
- [[docs/related-doc]]
|
|
102
|
+
|
|
103
|
+
## Source Files
|
|
104
|
+
- \`docs/api/\` - API documentation
|
|
105
|
+
- \`README.md\` - project readme
|
|
106
|
+
|
|
107
|
+
## External Docs
|
|
108
|
+
- [Style guide](https://example.com/style)` }
|
|
109
|
+
],
|
|
110
|
+
security: [
|
|
111
|
+
{ heading: 'Vulnerability', placeholder: 'Type: [XSS | CSRF | SQL Injection | Auth Bypass | etc.]\n\nDescription of the security vulnerability or concern.' },
|
|
112
|
+
{ heading: 'Impact', placeholder: 'Severity: [Critical | High | Medium | Low]\n\nPotential impact:\n- Data exposure\n- Unauthorized access\n- System compromise' },
|
|
113
|
+
{ heading: 'Mitigation', placeholder: 'Immediate fix:\n```typescript\n// Sanitize input\nconst safe = escapeHtml(userInput);\n```\n\nSteps to remediate the issue.' },
|
|
114
|
+
{ heading: 'Prevention', placeholder: 'Long-term prevention:\n- Input validation patterns\n- Security headers to add\n- Code review checklist items' },
|
|
115
|
+
{ heading: 'Related', placeholder: `## Wiki Entries
|
|
116
|
+
- [[security/related-security]]
|
|
117
|
+
|
|
118
|
+
## Source Files
|
|
119
|
+
- \`src/middleware/auth.ts\` - authentication middleware
|
|
120
|
+
- \`src/utils/sanitize.ts\` - input sanitization
|
|
121
|
+
|
|
122
|
+
## External Docs
|
|
123
|
+
- [OWASP Guide](https://owasp.org/)
|
|
124
|
+
- Compliance: SOC2, GDPR` }
|
|
125
|
+
],
|
|
126
|
+
performance: [
|
|
127
|
+
{ heading: 'Bottleneck', placeholder: 'Performance issue identified:\n- Slow database queries\n- Memory leak\n- CPU-bound operation\n- Network latency' },
|
|
128
|
+
{ heading: 'Measurement', placeholder: 'How the issue was measured:\n```\n// Before: 2500ms average response time\n// Memory: 512MB peak usage\n```\n\nProfiling tools used: Chrome DevTools, node --inspect, etc.' },
|
|
129
|
+
{ heading: 'Optimization', placeholder: 'Applied optimization:\n```typescript\n// Add index\ndb.collection.createIndex({ field: 1 });\n\n// Use connection pooling\nconst pool = new Pool({ max: 20 });\n```' },
|
|
130
|
+
{ heading: 'Benchmarks', placeholder: 'Results after optimization:\n```\n// After: 150ms average response time (94% improvement)\n// Memory: 128MB peak usage (75% reduction)\n```' },
|
|
131
|
+
{ heading: 'Related', placeholder: `## Wiki Entries
|
|
132
|
+
- [[performance/related-perf]]
|
|
133
|
+
|
|
134
|
+
## Source Files
|
|
135
|
+
- \`src/db/queries.ts\` - optimized queries
|
|
136
|
+
|
|
137
|
+
## Tests
|
|
138
|
+
- \`tests/benchmark/\` - performance test suite
|
|
139
|
+
|
|
140
|
+
## External Docs
|
|
141
|
+
- [Database tuning guide](https://example.com/perf)` }
|
|
142
|
+
]
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Category descriptions for overview generation.
|
|
146
|
+
*/
|
|
147
|
+
const CATEGORY_DESCRIPTIONS = {
|
|
148
|
+
issues: 'Bug fixes, error solutions, and troubleshooting guides.',
|
|
149
|
+
patterns: 'Reusable code patterns, templates, and best practices.',
|
|
150
|
+
gotchas: 'Common pitfalls, edge cases, and unexpected behaviors to watch out for.',
|
|
151
|
+
testing: 'Test strategies, mocking patterns, fixtures, and test coverage approaches.',
|
|
152
|
+
docs: 'Documentation templates, writing guides, and API documentation patterns.',
|
|
153
|
+
security: 'Security vulnerabilities, authentication patterns, and prevention strategies.',
|
|
154
|
+
performance: 'Performance optimizations, profiling techniques, and benchmark results.'
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Usage instructions for each category.
|
|
158
|
+
*/
|
|
159
|
+
const CATEGORY_USAGE = {
|
|
160
|
+
issues: `When encountering an error:
|
|
161
|
+
1. Check if the error message matches any trigger patterns
|
|
162
|
+
2. Search by tags or keywords
|
|
163
|
+
3. Apply the documented solution
|
|
164
|
+
4. If solution fails, flag the entry for review`,
|
|
165
|
+
patterns: `When implementing features:
|
|
166
|
+
1. Search for applicable patterns
|
|
167
|
+
2. Adapt patterns to your use case
|
|
168
|
+
3. Document new patterns discovered`,
|
|
169
|
+
gotchas: `When working with unfamiliar code:
|
|
170
|
+
1. Review gotchas for the relevant area
|
|
171
|
+
2. Apply documented workarounds
|
|
172
|
+
3. Add new gotchas when discovered`,
|
|
173
|
+
testing: `When writing tests:
|
|
174
|
+
1. Search for existing test patterns
|
|
175
|
+
2. Use documented mocking strategies
|
|
176
|
+
3. Follow fixture patterns
|
|
177
|
+
4. Document new testing approaches`,
|
|
178
|
+
docs: `When writing documentation:
|
|
179
|
+
1. Identify target audience
|
|
180
|
+
2. Follow existing templates
|
|
181
|
+
3. Include working code examples
|
|
182
|
+
4. Apply style guide recommendations`,
|
|
183
|
+
security: `When addressing security:
|
|
184
|
+
1. Check for known vulnerabilities
|
|
185
|
+
2. Apply documented mitigations
|
|
186
|
+
3. Follow prevention patterns
|
|
187
|
+
4. Document new security findings`,
|
|
188
|
+
performance: `When optimizing performance:
|
|
189
|
+
1. Measure before optimizing
|
|
190
|
+
2. Apply documented optimizations
|
|
191
|
+
3. Benchmark after changes
|
|
192
|
+
4. Document results for future reference`
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Gets the template sections for a given category.
|
|
196
|
+
* Falls back to 'issues' template if category is not found.
|
|
197
|
+
*
|
|
198
|
+
* @param category - The category name
|
|
199
|
+
* @returns Array of template sections for the category
|
|
200
|
+
*/
|
|
201
|
+
function getTemplate(category) {
|
|
202
|
+
return exports.CATEGORY_TEMPLATES[category] || exports.CATEGORY_TEMPLATES.issues;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Generates stub content with TODO placeholders for a given category.
|
|
206
|
+
* Useful for creating new entries that need to be filled in later.
|
|
207
|
+
*
|
|
208
|
+
* @param category - The category name
|
|
209
|
+
* @returns Record mapping heading names to placeholder content with TODO markers
|
|
210
|
+
*/
|
|
211
|
+
function generateStubContent(category) {
|
|
212
|
+
const template = getTemplate(category);
|
|
213
|
+
const content = {};
|
|
214
|
+
for (const section of template) {
|
|
215
|
+
content[section.heading] = `<!-- TODO: ${section.placeholder} -->`;
|
|
216
|
+
}
|
|
217
|
+
return content;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Generates category overview markdown content.
|
|
221
|
+
* Creates a formatted overview page for a category with usage instructions
|
|
222
|
+
* and placeholders for auto-populated sections.
|
|
223
|
+
*
|
|
224
|
+
* @param category - The category name
|
|
225
|
+
* @returns Formatted markdown string for the category overview
|
|
226
|
+
*/
|
|
227
|
+
function generateOverviewContent(category) {
|
|
228
|
+
const capitalizedCategory = category.charAt(0).toUpperCase() + category.slice(1);
|
|
229
|
+
const description = CATEGORY_DESCRIPTIONS[category] || `Entries related to ${category}.`;
|
|
230
|
+
const usage = CATEGORY_USAGE[category] || `Search and browse ${category} entries as needed.`;
|
|
231
|
+
return `# ${capitalizedCategory}
|
|
232
|
+
|
|
233
|
+
${description}
|
|
234
|
+
|
|
235
|
+
## How to Use
|
|
236
|
+
|
|
237
|
+
${usage}
|
|
238
|
+
|
|
239
|
+
## Recent Entries
|
|
240
|
+
|
|
241
|
+
<!-- Auto-populated -->
|
|
242
|
+
|
|
243
|
+
## Common Tags
|
|
244
|
+
|
|
245
|
+
<!-- Auto-populated -->
|
|
246
|
+
`;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Gets all available template category names.
|
|
250
|
+
*
|
|
251
|
+
* @returns Array of category names that have templates defined
|
|
252
|
+
*/
|
|
253
|
+
function getAvailableTemplates() {
|
|
254
|
+
return Object.keys(exports.CATEGORY_TEMPLATES);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Checks if a template exists for the given category.
|
|
258
|
+
*
|
|
259
|
+
* @param category - The category name to check
|
|
260
|
+
* @returns True if a template exists for the category
|
|
261
|
+
*/
|
|
262
|
+
function hasTemplate(category) {
|
|
263
|
+
return category in exports.CATEGORY_TEMPLATES;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Gets the description for a category.
|
|
267
|
+
*
|
|
268
|
+
* @param category - The category name
|
|
269
|
+
* @returns The category description or a default message
|
|
270
|
+
*/
|
|
271
|
+
function getCategoryDescription(category) {
|
|
272
|
+
return CATEGORY_DESCRIPTIONS[category] || `Entries related to ${category}.`;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Generates the content for the wiki README.md file.
|
|
276
|
+
* @returns Formatted markdown string for the wiki README
|
|
277
|
+
*/
|
|
278
|
+
function generateWikiReadme() {
|
|
279
|
+
return `# Project Wiki
|
|
280
|
+
|
|
281
|
+
This wiki contains project-specific knowledge captured during development.
|
|
282
|
+
|
|
283
|
+
## Categories
|
|
284
|
+
|
|
285
|
+
| Category | Purpose | Default Confidence |
|
|
286
|
+
|----------|---------|-------------------|
|
|
287
|
+
| **issues/** | Bug fixes, error solutions, troubleshooting | 50 |
|
|
288
|
+
| **patterns/** | Reusable code patterns, best practices | 50 |
|
|
289
|
+
| **gotchas/** | Pitfalls, edge cases, unexpected behaviors | 80 |
|
|
290
|
+
| **testing/** | Test strategies, mocking patterns, fixtures | 50 |
|
|
291
|
+
| **docs/** | Documentation templates, writing guides | 50 |
|
|
292
|
+
| **security/** | Security vulnerabilities, prevention strategies | 50 |
|
|
293
|
+
| **performance/** | Performance optimizations, benchmarks | 50 |
|
|
294
|
+
|
|
295
|
+
## Quick Commands
|
|
296
|
+
|
|
297
|
+
| Command | Description |
|
|
298
|
+
|---------|-------------|
|
|
299
|
+
| \`/wiki init\` | Create wiki structure in current project |
|
|
300
|
+
| \`/wiki add\` | Create new entry from current context |
|
|
301
|
+
| \`/wiki search <query>\` | Search entries by keyword |
|
|
302
|
+
| \`/wiki browse\` | List all entries |
|
|
303
|
+
| \`/wiki status\` | Show wiki health and stats |
|
|
304
|
+
| \`/wiki validate\` | Check for broken links and issues |
|
|
305
|
+
| \`/wiki scan\` | Analyze project, generate stub entries |
|
|
306
|
+
| \`/wiki flag <entry>\` | Mark entry as needs review |
|
|
307
|
+
| \`/wiki fix <entry>\` | Update flagged entry |
|
|
308
|
+
|
|
309
|
+
## Entry Format
|
|
310
|
+
|
|
311
|
+
Each entry is a markdown file with YAML frontmatter:
|
|
312
|
+
|
|
313
|
+
\`\`\`yaml
|
|
314
|
+
---
|
|
315
|
+
title: Entry Title
|
|
316
|
+
tags: [keyword1, keyword2]
|
|
317
|
+
trigger: "error pattern regex" # issues only
|
|
318
|
+
confidence: 80 # 0-100 scale
|
|
319
|
+
status: active # active | flagged | deprecated
|
|
320
|
+
---
|
|
321
|
+
\`\`\`
|
|
322
|
+
|
|
323
|
+
### Confidence Scale
|
|
324
|
+
|
|
325
|
+
| Score | Level | Meaning |
|
|
326
|
+
|-------|-------|---------|
|
|
327
|
+
| 80-100 | High | Verified, used multiple times |
|
|
328
|
+
| 40-79 | Medium | Worked once, partially verified |
|
|
329
|
+
| 0-39 | Low | Stub or unverified, needs review |
|
|
330
|
+
|
|
331
|
+
## Auto-Lookup
|
|
332
|
+
|
|
333
|
+
The wiki automatically suggests entries when:
|
|
334
|
+
- **Error match** - Error text matches a trigger pattern
|
|
335
|
+
- **Task start** - Scans for relevant context
|
|
336
|
+
- **Uncertainty** - Claude detects hesitation
|
|
337
|
+
|
|
338
|
+
## Contributing
|
|
339
|
+
|
|
340
|
+
When you solve a problem or discover a pattern:
|
|
341
|
+
1. Use \`/wiki add\` to capture it
|
|
342
|
+
2. Fill in all template sections
|
|
343
|
+
3. Add relevant tags for searchability
|
|
344
|
+
4. Set appropriate confidence level
|
|
345
|
+
`;
|
|
346
|
+
}
|
|
347
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/templates.ts"],"names":[],"mappings":";AAAA,mBAAmB;;;AA0MnB,kCAEC;AASD,kDASC;AAUD,0DAqBC;AAOD,sDAEC;AAQD,kCAEC;AAQD,wDAEC;AAMD,gDAoEC;AA1VD;;;GAGG;AACU,QAAA,kBAAkB,GAAsC;IACnE,MAAM,EAAE;QACN,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,2GAA2G,EAAE;QAChJ,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,qGAAqG,EAAE;QACxI,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,kGAAkG,EAAE;QACxI,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,4FAA4F,EAAE;QACtI,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE;;;;;;;;;;;;;2CAaI,EAAE;KAC1C;IACD,QAAQ,EAAE;QACR,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,sDAAsD,EAAE;QAC1F,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,+DAA+D,EAAE;QACtG,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,uGAAuG,EAAE;QAC5I,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,i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;;;;;;;;;;;;;;;;;;;;CAkER,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { WikiConfig } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Wiki export format containing all entries and config.
|
|
4
|
+
*/
|
|
5
|
+
export interface WikiExport {
|
|
6
|
+
version: string;
|
|
7
|
+
exportedAt: string;
|
|
8
|
+
projectName: string;
|
|
9
|
+
config: WikiConfig;
|
|
10
|
+
entries: WikiExportEntry[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Individual entry in export format.
|
|
14
|
+
*/
|
|
15
|
+
export interface WikiExportEntry {
|
|
16
|
+
path: string;
|
|
17
|
+
category: string;
|
|
18
|
+
frontmatter: Record<string, unknown>;
|
|
19
|
+
content: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Export options.
|
|
23
|
+
*/
|
|
24
|
+
export interface ExportOptions {
|
|
25
|
+
categories?: string[];
|
|
26
|
+
includeDeprecated?: boolean;
|
|
27
|
+
format?: 'json' | 'yaml';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Import options.
|
|
31
|
+
*/
|
|
32
|
+
export interface ImportOptions {
|
|
33
|
+
overwrite?: boolean;
|
|
34
|
+
skipDuplicates?: boolean;
|
|
35
|
+
dryRun?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Import result.
|
|
39
|
+
*/
|
|
40
|
+
export interface ImportResult {
|
|
41
|
+
imported: number;
|
|
42
|
+
skipped: number;
|
|
43
|
+
errors: {
|
|
44
|
+
path: string;
|
|
45
|
+
error: string;
|
|
46
|
+
}[];
|
|
47
|
+
dryRun: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Exports wiki entries to a portable format.
|
|
51
|
+
*
|
|
52
|
+
* @param projectRoot - The root directory of the project
|
|
53
|
+
* @param options - Export options
|
|
54
|
+
* @returns WikiExport object
|
|
55
|
+
*/
|
|
56
|
+
export declare function exportWiki(projectRoot: string, options?: ExportOptions): Promise<WikiExport>;
|
|
57
|
+
/**
|
|
58
|
+
* Exports wiki to a file.
|
|
59
|
+
*
|
|
60
|
+
* @param projectRoot - The root directory of the project
|
|
61
|
+
* @param outputPath - Path to write the export file
|
|
62
|
+
* @param options - Export options
|
|
63
|
+
*/
|
|
64
|
+
export declare function exportWikiToFile(projectRoot: string, outputPath: string, options?: ExportOptions): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Imports wiki entries from an export.
|
|
67
|
+
*
|
|
68
|
+
* @param projectRoot - The root directory of the project
|
|
69
|
+
* @param data - WikiExport data
|
|
70
|
+
* @param options - Import options
|
|
71
|
+
* @returns ImportResult with counts and errors
|
|
72
|
+
*/
|
|
73
|
+
export declare function importWiki(projectRoot: string, data: WikiExport, options?: ImportOptions): Promise<ImportResult>;
|
|
74
|
+
/**
|
|
75
|
+
* Imports wiki from a file.
|
|
76
|
+
*
|
|
77
|
+
* @param projectRoot - The root directory of the project
|
|
78
|
+
* @param inputPath - Path to the export file
|
|
79
|
+
* @param options - Import options
|
|
80
|
+
* @returns ImportResult
|
|
81
|
+
*/
|
|
82
|
+
export declare function importWikiFromFile(projectRoot: string, inputPath: string, options?: ImportOptions): Promise<ImportResult>;
|
|
83
|
+
/**
|
|
84
|
+
* Merges two wikis, combining entries from a source into the target.
|
|
85
|
+
*
|
|
86
|
+
* @param targetRoot - The target project root
|
|
87
|
+
* @param sourceRoot - The source project root to merge from
|
|
88
|
+
* @param options - Import options for handling conflicts
|
|
89
|
+
* @returns ImportResult
|
|
90
|
+
*/
|
|
91
|
+
export declare function mergeWikis(targetRoot: string, sourceRoot: string, options?: ImportOptions): Promise<ImportResult>;
|
|
92
|
+
//# sourceMappingURL=transfer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../../src/transfer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU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AAI,CAAC,CAOf;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC9B,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,UAAU,EAChB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAgFvB;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC,CA0BvB;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAGvB"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.exportWiki = exportWiki;
|
|
37
|
+
exports.exportWikiToFile = exportWikiToFile;
|
|
38
|
+
exports.importWiki = importWiki;
|
|
39
|
+
exports.importWikiFromFile = importWikiFromFile;
|
|
40
|
+
exports.mergeWikis = mergeWikis;
|
|
41
|
+
// src/transfer.ts
|
|
42
|
+
const fs = __importStar(require("fs"));
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
const glob_1 = require("glob");
|
|
45
|
+
const config_js_1 = require("./config.js");
|
|
46
|
+
const entry_js_1 = require("./entry.js");
|
|
47
|
+
const errors_js_1 = require("./errors.js");
|
|
48
|
+
/**
|
|
49
|
+
* Exports wiki entries to a portable format.
|
|
50
|
+
*
|
|
51
|
+
* @param projectRoot - The root directory of the project
|
|
52
|
+
* @param options - Export options
|
|
53
|
+
* @returns WikiExport object
|
|
54
|
+
*/
|
|
55
|
+
async function exportWiki(projectRoot, options = {}) {
|
|
56
|
+
if (!(0, config_js_1.wikiExists)(projectRoot)) {
|
|
57
|
+
throw new Error('Wiki not initialized');
|
|
58
|
+
}
|
|
59
|
+
const config = (0, config_js_1.readConfig)(projectRoot);
|
|
60
|
+
if (!config) {
|
|
61
|
+
throw new Error('Wiki config not found');
|
|
62
|
+
}
|
|
63
|
+
const wikiPath = (0, config_js_1.getWikiPath)(projectRoot);
|
|
64
|
+
const entries = [];
|
|
65
|
+
// Determine which categories to export
|
|
66
|
+
const categories = options.categories || config.categories;
|
|
67
|
+
for (const category of categories) {
|
|
68
|
+
const categoryPath = path.join(wikiPath, category);
|
|
69
|
+
if (!fs.existsSync(categoryPath))
|
|
70
|
+
continue;
|
|
71
|
+
const pattern = path.join(categoryPath, '*.md');
|
|
72
|
+
const files = await (0, glob_1.glob)(pattern, { nodir: true });
|
|
73
|
+
for (const filePath of files) {
|
|
74
|
+
const relativePath = path.relative(wikiPath, filePath);
|
|
75
|
+
const entry = (0, entry_js_1.readEntry)(projectRoot, relativePath);
|
|
76
|
+
if (!entry)
|
|
77
|
+
continue;
|
|
78
|
+
// Skip deprecated unless requested
|
|
79
|
+
if (!options.includeDeprecated && entry.frontmatter.status === 'deprecated') {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
entries.push({
|
|
83
|
+
path: relativePath,
|
|
84
|
+
category: entry.category,
|
|
85
|
+
frontmatter: entry.frontmatter,
|
|
86
|
+
content: entry.content
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
version: '1.0.0',
|
|
92
|
+
exportedAt: new Date().toISOString(),
|
|
93
|
+
projectName: config.project,
|
|
94
|
+
config,
|
|
95
|
+
entries
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Exports wiki to a file.
|
|
100
|
+
*
|
|
101
|
+
* @param projectRoot - The root directory of the project
|
|
102
|
+
* @param outputPath - Path to write the export file
|
|
103
|
+
* @param options - Export options
|
|
104
|
+
*/
|
|
105
|
+
async function exportWikiToFile(projectRoot, outputPath, options = {}) {
|
|
106
|
+
const exportData = await exportWiki(projectRoot, options);
|
|
107
|
+
const content = JSON.stringify(exportData, null, 2);
|
|
108
|
+
(0, errors_js_1.wrapFileOperation)('write', outputPath, () => fs.writeFileSync(outputPath, content, 'utf-8'));
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Imports wiki entries from an export.
|
|
112
|
+
*
|
|
113
|
+
* @param projectRoot - The root directory of the project
|
|
114
|
+
* @param data - WikiExport data
|
|
115
|
+
* @param options - Import options
|
|
116
|
+
* @returns ImportResult with counts and errors
|
|
117
|
+
*/
|
|
118
|
+
async function importWiki(projectRoot, data, options = {}) {
|
|
119
|
+
const result = {
|
|
120
|
+
imported: 0,
|
|
121
|
+
skipped: 0,
|
|
122
|
+
errors: [],
|
|
123
|
+
dryRun: options.dryRun || false
|
|
124
|
+
};
|
|
125
|
+
// Initialize wiki if not exists
|
|
126
|
+
if (!(0, config_js_1.wikiExists)(projectRoot)) {
|
|
127
|
+
if (options.dryRun) {
|
|
128
|
+
// Can't do dry run on non-existent wiki
|
|
129
|
+
throw new Error('Wiki not initialized. Run /wiki init first.');
|
|
130
|
+
}
|
|
131
|
+
// Create wiki structure
|
|
132
|
+
const wikiPath = (0, config_js_1.getWikiPath)(projectRoot);
|
|
133
|
+
(0, errors_js_1.wrapFileOperation)('create', wikiPath, () => fs.mkdirSync(wikiPath, { recursive: true }));
|
|
134
|
+
const config = (0, config_js_1.getDefaultConfig)(data.projectName || path.basename(projectRoot));
|
|
135
|
+
(0, config_js_1.writeConfig)(projectRoot, config);
|
|
136
|
+
}
|
|
137
|
+
const wikiPath = (0, config_js_1.getWikiPath)(projectRoot);
|
|
138
|
+
for (const exportEntry of data.entries) {
|
|
139
|
+
try {
|
|
140
|
+
const entryPath = path.join(wikiPath, exportEntry.path);
|
|
141
|
+
// Check if entry already exists
|
|
142
|
+
if (fs.existsSync(entryPath)) {
|
|
143
|
+
if (options.skipDuplicates) {
|
|
144
|
+
result.skipped++;
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (!options.overwrite) {
|
|
148
|
+
result.errors.push({
|
|
149
|
+
path: exportEntry.path,
|
|
150
|
+
error: 'Entry already exists (use overwrite option)'
|
|
151
|
+
});
|
|
152
|
+
result.skipped++;
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (options.dryRun) {
|
|
157
|
+
result.imported++;
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
// Ensure category directory exists
|
|
161
|
+
const categoryDir = path.join(wikiPath, exportEntry.category);
|
|
162
|
+
if (!fs.existsSync(categoryDir)) {
|
|
163
|
+
(0, errors_js_1.wrapFileOperation)('create', categoryDir, () => fs.mkdirSync(categoryDir, { recursive: true }));
|
|
164
|
+
}
|
|
165
|
+
// Reconstruct the markdown file
|
|
166
|
+
const { stringifyFrontmatter } = await import('./frontmatter.js');
|
|
167
|
+
const fileContent = stringifyFrontmatter(exportEntry.frontmatter, exportEntry.content);
|
|
168
|
+
(0, errors_js_1.wrapFileOperation)('write', entryPath, () => fs.writeFileSync(entryPath, fileContent, 'utf-8'));
|
|
169
|
+
result.imported++;
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
result.errors.push({
|
|
173
|
+
path: exportEntry.path,
|
|
174
|
+
error: error instanceof Error ? error.message : String(error)
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return result;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Imports wiki from a file.
|
|
182
|
+
*
|
|
183
|
+
* @param projectRoot - The root directory of the project
|
|
184
|
+
* @param inputPath - Path to the export file
|
|
185
|
+
* @param options - Import options
|
|
186
|
+
* @returns ImportResult
|
|
187
|
+
*/
|
|
188
|
+
async function importWikiFromFile(projectRoot, inputPath, options = {}) {
|
|
189
|
+
const content = (0, errors_js_1.wrapFileOperation)('read', inputPath, () => fs.readFileSync(inputPath, 'utf-8'));
|
|
190
|
+
let data;
|
|
191
|
+
try {
|
|
192
|
+
data = JSON.parse(content);
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
throw new errors_js_1.FileSystemError('read', inputPath, new Error(`Invalid JSON format: ${error instanceof Error ? error.message : String(error)}`));
|
|
196
|
+
}
|
|
197
|
+
// Validate export format
|
|
198
|
+
if (!data.version || !data.entries) {
|
|
199
|
+
throw new errors_js_1.FileSystemError('read', inputPath, new Error('Invalid wiki export format: missing version or entries'));
|
|
200
|
+
}
|
|
201
|
+
return importWiki(projectRoot, data, options);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Merges two wikis, combining entries from a source into the target.
|
|
205
|
+
*
|
|
206
|
+
* @param targetRoot - The target project root
|
|
207
|
+
* @param sourceRoot - The source project root to merge from
|
|
208
|
+
* @param options - Import options for handling conflicts
|
|
209
|
+
* @returns ImportResult
|
|
210
|
+
*/
|
|
211
|
+
async function mergeWikis(targetRoot, sourceRoot, options = {}) {
|
|
212
|
+
const exportData = await exportWiki(sourceRoot, { includeDeprecated: true });
|
|
213
|
+
return importWiki(targetRoot, exportData, options);
|
|
214
|
+
}
|
|
215
|
+
//# sourceMappingURL=transfer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer.js","sourceRoot":"","sources":["../../src/transfer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,gCAqDC;AASD,4CAWC;AAUD,gCAoFC;AAUD,gDA8BC;AAUD,gCAOC;AAjSD,kBAAkB;AAClB,uCAAyB;AACzB,2CAA6B;AAC7B,+BAA4B;AAE5B,2CAAiG;AACjG,yCAAuC;AACvC,2CAAiE;AAmDjE;;;;;;GAMG;AACI,KAAK,UAAU,UAAU,CAC9B,WAAmB,EACnB,UAAyB,EAAE;IAE3B,IAAI,CAAC,IAAA,sBAAU,EAAC,WAAW,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,MAAM,GAAG,IAAA,sBAAU,EAAC,WAAW,CAAC,CAAC;IACvC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,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