@skillsmith/cli 0.2.2 → 0.2.4
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/README.md +147 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/src/commands/author.d.ts +44 -1
- package/dist/src/commands/author.d.ts.map +1 -1
- package/dist/src/commands/author.js +524 -4
- package/dist/src/commands/author.js.map +1 -1
- package/dist/src/commands/index.d.ts +1 -1
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +1 -1
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/index.js +16 -6
- package/dist/src/index.js.map +1 -1
- package/dist/src/templates/index.d.ts +2 -0
- package/dist/src/templates/index.d.ts.map +1 -1
- package/dist/src/templates/index.js +2 -0
- package/dist/src/templates/index.js.map +1 -1
- package/dist/src/templates/mcp-server.template.d.ts +97 -0
- package/dist/src/templates/mcp-server.template.d.ts.map +1 -0
- package/dist/src/templates/mcp-server.template.js +529 -0
- package/dist/src/templates/mcp-server.template.js.map +1 -0
- package/dist/src/templates/subagent.md.template.d.ts +38 -0
- package/dist/src/templates/subagent.md.template.d.ts.map +1 -0
- package/dist/src/templates/subagent.md.template.js +128 -0
- package/dist/src/templates/subagent.md.template.js.map +1 -0
- package/dist/src/utils/tool-analyzer.d.ts +54 -0
- package/dist/src/utils/tool-analyzer.d.ts.map +1 -0
- package/dist/src/utils/tool-analyzer.js +156 -0
- package/dist/src/utils/tool-analyzer.js.map +1 -0
- package/dist/tests/author.test.js +419 -0
- package/dist/tests/author.test.js.map +1 -1
- package/dist/tests/mcp-server-template.test.d.ts +7 -0
- package/dist/tests/mcp-server-template.test.d.ts.map +1 -0
- package/dist/tests/mcp-server-template.test.js +351 -0
- package/dist/tests/mcp-server-template.test.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SMI-1389: Subagent Definition Template
|
|
3
|
+
*
|
|
4
|
+
* Templates for generating companion specialist agents that enable
|
|
5
|
+
* parallel skill execution with 37-97% token savings.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Main subagent definition template
|
|
9
|
+
* Generates ~/.claude/agents/[skill-name]-specialist.md
|
|
10
|
+
*/
|
|
11
|
+
export const SUBAGENT_MD_TEMPLATE = `---
|
|
12
|
+
name: {{skillName}}-specialist
|
|
13
|
+
description: {{description}} Use when {{triggerPhrases}}.
|
|
14
|
+
skills: {{skillName}}
|
|
15
|
+
tools: {{tools}}
|
|
16
|
+
model: {{model}}
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Operating Protocol
|
|
20
|
+
|
|
21
|
+
1. Execute the {{skillName}} skill for the delegated task
|
|
22
|
+
2. Process all intermediate results internally
|
|
23
|
+
3. Return ONLY a structured summary to the orchestrator
|
|
24
|
+
|
|
25
|
+
## Output Format
|
|
26
|
+
|
|
27
|
+
- **Task:** [what was requested]
|
|
28
|
+
- **Actions:** [what you did]
|
|
29
|
+
- **Results:** [key outcomes, max 3-5 bullet points]
|
|
30
|
+
- **Artifacts:** [file paths or outputs created]
|
|
31
|
+
|
|
32
|
+
Keep response under 500 tokens unless explicitly requested otherwise.
|
|
33
|
+
|
|
34
|
+
## Tool Usage Guidelines
|
|
35
|
+
|
|
36
|
+
{{toolGuidelines}}
|
|
37
|
+
|
|
38
|
+
## Error Handling
|
|
39
|
+
|
|
40
|
+
If the task cannot be completed:
|
|
41
|
+
- Report specific blocking issue
|
|
42
|
+
- Suggest alternative approaches
|
|
43
|
+
- Do not retry indefinitely
|
|
44
|
+
`;
|
|
45
|
+
/**
|
|
46
|
+
* CLAUDE.md integration snippet template
|
|
47
|
+
* Users can copy this to their project's CLAUDE.md
|
|
48
|
+
*/
|
|
49
|
+
export const CLAUDE_MD_SNIPPET_TEMPLATE = `
|
|
50
|
+
### Subagent Delegation: {{skillName}}
|
|
51
|
+
|
|
52
|
+
When tasks match {{skillName}} triggers, delegate to the {{skillName}}-specialist
|
|
53
|
+
subagent instead of executing directly. This provides context isolation and
|
|
54
|
+
~37-97% token savings.
|
|
55
|
+
|
|
56
|
+
**Trigger Patterns:**
|
|
57
|
+
{{triggerPatterns}}
|
|
58
|
+
|
|
59
|
+
**Delegation Example:**
|
|
60
|
+
\`\`\`
|
|
61
|
+
Task("{{skillName}}-specialist", "{{exampleTask}}", "{{skillName}}-specialist")
|
|
62
|
+
\`\`\`
|
|
63
|
+
`;
|
|
64
|
+
/**
|
|
65
|
+
* Generate tool usage guidelines based on detected tools
|
|
66
|
+
*/
|
|
67
|
+
function generateToolGuidelines(tools) {
|
|
68
|
+
const guidelines = [];
|
|
69
|
+
if (tools.includes('Read')) {
|
|
70
|
+
guidelines.push('- **Read**: Use to examine files before modifications');
|
|
71
|
+
}
|
|
72
|
+
if (tools.includes('Write')) {
|
|
73
|
+
guidelines.push('- **Write**: Use for creating new files only');
|
|
74
|
+
}
|
|
75
|
+
if (tools.includes('Edit')) {
|
|
76
|
+
guidelines.push('- **Edit**: Use for modifying existing files');
|
|
77
|
+
}
|
|
78
|
+
if (tools.includes('Bash')) {
|
|
79
|
+
guidelines.push('- **Bash**: Use for command execution, prefer non-destructive commands');
|
|
80
|
+
}
|
|
81
|
+
if (tools.includes('Grep')) {
|
|
82
|
+
guidelines.push('- **Grep**: Use for searching file contents');
|
|
83
|
+
}
|
|
84
|
+
if (tools.includes('Glob')) {
|
|
85
|
+
guidelines.push('- **Glob**: Use for finding files by pattern');
|
|
86
|
+
}
|
|
87
|
+
if (tools.includes('WebFetch')) {
|
|
88
|
+
guidelines.push('- **WebFetch**: Use for fetching web content');
|
|
89
|
+
}
|
|
90
|
+
if (tools.includes('WebSearch')) {
|
|
91
|
+
guidelines.push('- **WebSearch**: Use for searching the web');
|
|
92
|
+
}
|
|
93
|
+
return guidelines.length > 0 ? guidelines.join('\n') : '- Use tools minimally and efficiently';
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Render the subagent definition template
|
|
97
|
+
*
|
|
98
|
+
* @param data - Template data including skill name, description, tools, etc.
|
|
99
|
+
* @returns Rendered subagent markdown content
|
|
100
|
+
*/
|
|
101
|
+
export function renderSubagentTemplate(data) {
|
|
102
|
+
const toolGuidelines = generateToolGuidelines(data.tools);
|
|
103
|
+
const triggerPhrasesFormatted = data.triggerPhrases.length > 0
|
|
104
|
+
? data.triggerPhrases.map((p) => `"${p}"`).join(', ')
|
|
105
|
+
: '[describe trigger conditions]';
|
|
106
|
+
return SUBAGENT_MD_TEMPLATE.replace(/\{\{skillName\}\}/g, data.skillName)
|
|
107
|
+
.replace(/\{\{description\}\}/g, data.description)
|
|
108
|
+
.replace(/\{\{triggerPhrases\}\}/g, triggerPhrasesFormatted)
|
|
109
|
+
.replace(/\{\{tools\}\}/g, data.tools.join(', '))
|
|
110
|
+
.replace(/\{\{model\}\}/g, data.model)
|
|
111
|
+
.replace(/\{\{toolGuidelines\}\}/g, toolGuidelines);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Render the CLAUDE.md integration snippet
|
|
115
|
+
*
|
|
116
|
+
* @param data - Template data
|
|
117
|
+
* @returns Rendered CLAUDE.md snippet
|
|
118
|
+
*/
|
|
119
|
+
export function renderClaudeMdSnippet(data) {
|
|
120
|
+
const triggerPatterns = data.triggerPhrases.length > 0
|
|
121
|
+
? data.triggerPhrases.map((p) => `- "${p}"`).join('\n')
|
|
122
|
+
: '- [add trigger patterns]';
|
|
123
|
+
const exampleTask = data.triggerPhrases.length > 0 ? `${data.triggerPhrases[0]}` : `execute ${data.skillName} task`;
|
|
124
|
+
return CLAUDE_MD_SNIPPET_TEMPLATE.replace(/\{\{skillName\}\}/g, data.skillName)
|
|
125
|
+
.replace(/\{\{triggerPatterns\}\}/g, triggerPatterns)
|
|
126
|
+
.replace(/\{\{exampleTask\}\}/g, exampleTask);
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=subagent.md.template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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AAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QACvD,CAAC,CAAC,0BAA0B,CAAA;IAEhC,MAAM,WAAW,GACf,IAAI,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,IAAI,CAAC,SAAS,OAAO,CAAA;IAEjG,OAAO,0BAA0B,CAAC,OAAO,CAAC,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC;SAC5E,OAAO,CAAC,0BAA0B,EAAE,eAAe,CAAC;SACpD,OAAO,CAAC,sBAAsB,EAAE,WAAW,CAAC,CAAA;AACjD,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SMI-1389: Tool Detection for Subagent Generation
|
|
3
|
+
*
|
|
4
|
+
* Analyzes SKILL.md content to determine minimal required tools
|
|
5
|
+
* for subagent execution, enabling context isolation and token savings.
|
|
6
|
+
*/
|
|
7
|
+
export interface ToolAnalysis {
|
|
8
|
+
requiredTools: string[];
|
|
9
|
+
recommendedTools: string[];
|
|
10
|
+
detectedPatterns: string[];
|
|
11
|
+
confidence: 'high' | 'medium' | 'low';
|
|
12
|
+
}
|
|
13
|
+
interface ToolPattern {
|
|
14
|
+
always?: boolean;
|
|
15
|
+
patterns: string[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Tool detection patterns
|
|
19
|
+
* Each tool has patterns that indicate its requirement
|
|
20
|
+
*/
|
|
21
|
+
export declare const TOOL_PATTERNS: Record<string, ToolPattern>;
|
|
22
|
+
/**
|
|
23
|
+
* Analyze skill content to determine required tools
|
|
24
|
+
*
|
|
25
|
+
* @param skillContent - The full SKILL.md content
|
|
26
|
+
* @returns Analysis of required and recommended tools
|
|
27
|
+
*/
|
|
28
|
+
export declare function analyzeToolRequirements(skillContent: string): ToolAnalysis;
|
|
29
|
+
/**
|
|
30
|
+
* Format tool list for YAML output
|
|
31
|
+
*
|
|
32
|
+
* @param tools - Array of tool names
|
|
33
|
+
* @returns Formatted string for YAML tools field
|
|
34
|
+
*/
|
|
35
|
+
export declare function formatToolList(tools: string[]): string;
|
|
36
|
+
/**
|
|
37
|
+
* Parse comma-separated tools string into array
|
|
38
|
+
*
|
|
39
|
+
* @param toolsString - Comma-separated tools (e.g., "Read, Write, Bash")
|
|
40
|
+
* @returns Array of tool names
|
|
41
|
+
*/
|
|
42
|
+
export declare function parseToolsString(toolsString: string): string[];
|
|
43
|
+
/**
|
|
44
|
+
* Validate that all tools in the list are recognized
|
|
45
|
+
*
|
|
46
|
+
* @param tools - Array of tool names to validate
|
|
47
|
+
* @returns Object with valid boolean and any unrecognized tools
|
|
48
|
+
*/
|
|
49
|
+
export declare function validateTools(tools: string[]): {
|
|
50
|
+
valid: boolean;
|
|
51
|
+
unrecognized: string[];
|
|
52
|
+
};
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=tool-analyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-analyzer.d.ts","sourceRoot":"","sources":["../../../src/utils/tool-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,YAAY;IAC3B,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,UAAU,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAA;CACtC;AAED,UAAU,WAAW;IACnB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAsErD,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,MAAM,GAAG,YAAY,CAmC1E;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAKtD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAK9D;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,MAAM,EAAE,CAAA;CAAE,CAQzF"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SMI-1389: Tool Detection for Subagent Generation
|
|
3
|
+
*
|
|
4
|
+
* Analyzes SKILL.md content to determine minimal required tools
|
|
5
|
+
* for subagent execution, enabling context isolation and token savings.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Tool detection patterns
|
|
9
|
+
* Each tool has patterns that indicate its requirement
|
|
10
|
+
*/
|
|
11
|
+
export const TOOL_PATTERNS = {
|
|
12
|
+
Read: { always: true, patterns: [] },
|
|
13
|
+
Write: {
|
|
14
|
+
patterns: [
|
|
15
|
+
'write',
|
|
16
|
+
'create file',
|
|
17
|
+
'save',
|
|
18
|
+
'output to file',
|
|
19
|
+
'generate file',
|
|
20
|
+
'write to',
|
|
21
|
+
'create new file',
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
Edit: {
|
|
25
|
+
patterns: [
|
|
26
|
+
'edit',
|
|
27
|
+
'modify',
|
|
28
|
+
'update file',
|
|
29
|
+
'patch',
|
|
30
|
+
'change file',
|
|
31
|
+
'replace in file',
|
|
32
|
+
'refactor',
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
Bash: {
|
|
36
|
+
patterns: [
|
|
37
|
+
'bash',
|
|
38
|
+
'npm',
|
|
39
|
+
'npx',
|
|
40
|
+
'run command',
|
|
41
|
+
'execute',
|
|
42
|
+
'terminal',
|
|
43
|
+
'shell',
|
|
44
|
+
'command line',
|
|
45
|
+
'cli',
|
|
46
|
+
'git ',
|
|
47
|
+
'docker',
|
|
48
|
+
'yarn',
|
|
49
|
+
'pnpm',
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
Grep: {
|
|
53
|
+
patterns: [
|
|
54
|
+
'search',
|
|
55
|
+
'find text',
|
|
56
|
+
'grep',
|
|
57
|
+
'pattern match',
|
|
58
|
+
'search for',
|
|
59
|
+
'look for',
|
|
60
|
+
'find in files',
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
Glob: {
|
|
64
|
+
patterns: ['find file', 'glob', 'file pattern', 'locate file', 'list files', 'find files'],
|
|
65
|
+
},
|
|
66
|
+
WebFetch: {
|
|
67
|
+
patterns: [
|
|
68
|
+
'fetch',
|
|
69
|
+
'http',
|
|
70
|
+
'api call',
|
|
71
|
+
'url',
|
|
72
|
+
'web request',
|
|
73
|
+
'download',
|
|
74
|
+
'get from url',
|
|
75
|
+
'request',
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
WebSearch: {
|
|
79
|
+
patterns: ['web search', 'search online', 'google', 'lookup online', 'search the web'],
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Analyze skill content to determine required tools
|
|
84
|
+
*
|
|
85
|
+
* @param skillContent - The full SKILL.md content
|
|
86
|
+
* @returns Analysis of required and recommended tools
|
|
87
|
+
*/
|
|
88
|
+
export function analyzeToolRequirements(skillContent) {
|
|
89
|
+
const content = skillContent.toLowerCase();
|
|
90
|
+
const tools = new Set();
|
|
91
|
+
const patterns = [];
|
|
92
|
+
for (const [tool, config] of Object.entries(TOOL_PATTERNS)) {
|
|
93
|
+
// Always include tools marked as 'always'
|
|
94
|
+
if (config.always) {
|
|
95
|
+
tools.add(tool);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
// Check each pattern for the tool
|
|
99
|
+
for (const pattern of config.patterns) {
|
|
100
|
+
if (content.includes(pattern)) {
|
|
101
|
+
tools.add(tool);
|
|
102
|
+
patterns.push(`${tool}: matched "${pattern}"`);
|
|
103
|
+
break; // Only need one match per tool
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// Determine confidence based on pattern matches
|
|
108
|
+
const matchCount = patterns.length;
|
|
109
|
+
const confidence = matchCount >= 3 ? 'high' : matchCount >= 1 ? 'medium' : 'low';
|
|
110
|
+
const toolList = Array.from(tools);
|
|
111
|
+
return {
|
|
112
|
+
requiredTools: toolList,
|
|
113
|
+
recommendedTools: toolList,
|
|
114
|
+
detectedPatterns: patterns,
|
|
115
|
+
confidence,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Format tool list for YAML output
|
|
120
|
+
*
|
|
121
|
+
* @param tools - Array of tool names
|
|
122
|
+
* @returns Formatted string for YAML tools field
|
|
123
|
+
*/
|
|
124
|
+
export function formatToolList(tools) {
|
|
125
|
+
if (tools.length === 0) {
|
|
126
|
+
return 'Read';
|
|
127
|
+
}
|
|
128
|
+
return tools.join(', ');
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Parse comma-separated tools string into array
|
|
132
|
+
*
|
|
133
|
+
* @param toolsString - Comma-separated tools (e.g., "Read, Write, Bash")
|
|
134
|
+
* @returns Array of tool names
|
|
135
|
+
*/
|
|
136
|
+
export function parseToolsString(toolsString) {
|
|
137
|
+
return toolsString
|
|
138
|
+
.split(',')
|
|
139
|
+
.map((t) => t.trim())
|
|
140
|
+
.filter((t) => t.length > 0);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Validate that all tools in the list are recognized
|
|
144
|
+
*
|
|
145
|
+
* @param tools - Array of tool names to validate
|
|
146
|
+
* @returns Object with valid boolean and any unrecognized tools
|
|
147
|
+
*/
|
|
148
|
+
export function validateTools(tools) {
|
|
149
|
+
const validTools = new Set(Object.keys(TOOL_PATTERNS));
|
|
150
|
+
const unrecognized = tools.filter((t) => !validTools.has(t));
|
|
151
|
+
return {
|
|
152
|
+
valid: unrecognized.length === 0,
|
|
153
|
+
unrecognized,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=tool-analyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-analyzer.js","sourceRoot":"","sources":["../../../src/utils/tool-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAgC;IACxD,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;IACpC,KAAK,EAAE;QACL,QAAQ,EAAE;YACR,OAAO;YACP,aAAa;YACb,MAAM;YACN,gBAAgB;YAChB,eAAe;YACf,UAAU;YACV,iBAAiB;SAClB;KACF;IACD,IAAI,EAAE;QACJ,QAAQ,EAAE;YACR,MAAM;YACN,QAAQ;YACR,aAAa;YACb,OAAO;YACP,aAAa;YACb,iBAAiB;YACjB,UAAU;SACX;KACF;IACD,IAAI,EAAE;QACJ,QAAQ,EAAE;YACR,MAAM;YACN,KAAK;YACL,KAAK;YACL,aAAa;YACb,SAAS;YACT,UAAU;YACV,OAAO;YACP,cAAc;YACd,KAAK;YACL,MAAM;YACN,QAAQ;YACR,MAAM;YACN,MAAM;SACP;KACF;IACD,IAAI,EAAE;QACJ,QAAQ,EAAE;YACR,QAAQ;YACR,WAAW;YACX,MAAM;YACN,eAAe;YACf,YAAY;YACZ,UAAU;YACV,eAAe;SAChB;KACF;IACD,IAAI,EAAE;QACJ,QAAQ,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,CAAC;KAC3F;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE;YACR,OAAO;YACP,MAAM;YACN,UAAU;YACV,KAAK;YACL,aAAa;YACb,UAAU;YACV,cAAc;YACd,SAAS;SACV;KACF;IACD,SAAS,EAAE;QAC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