cray-code 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.
Files changed (252) hide show
  1. package/README.md +316 -0
  2. package/dist/Tool.d.ts +217 -0
  3. package/dist/Tool.d.ts.map +1 -0
  4. package/dist/Tool.js +89 -0
  5. package/dist/Tool.js.map +1 -0
  6. package/dist/branding/logo.d.ts +8 -0
  7. package/dist/branding/logo.d.ts.map +1 -0
  8. package/dist/branding/logo.js +26 -0
  9. package/dist/branding/logo.js.map +1 -0
  10. package/dist/branding/theme.d.ts +27 -0
  11. package/dist/branding/theme.d.ts.map +1 -0
  12. package/dist/branding/theme.js +28 -0
  13. package/dist/branding/theme.js.map +1 -0
  14. package/dist/commands/registry.d.ts +32 -0
  15. package/dist/commands/registry.d.ts.map +1 -0
  16. package/dist/commands/registry.js +759 -0
  17. package/dist/commands/registry.js.map +1 -0
  18. package/dist/components/MessageView.d.ts +12 -0
  19. package/dist/components/MessageView.d.ts.map +1 -0
  20. package/dist/components/MessageView.js +35 -0
  21. package/dist/components/MessageView.js.map +1 -0
  22. package/dist/components/PermissionPrompt.d.ts +11 -0
  23. package/dist/components/PermissionPrompt.d.ts.map +1 -0
  24. package/dist/components/PermissionPrompt.js +6 -0
  25. package/dist/components/PermissionPrompt.js.map +1 -0
  26. package/dist/components/PluginManager.d.ts +27 -0
  27. package/dist/components/PluginManager.d.ts.map +1 -0
  28. package/dist/components/PluginManager.js +391 -0
  29. package/dist/components/PluginManager.js.map +1 -0
  30. package/dist/components/ThinkingBlock.d.ts +27 -0
  31. package/dist/components/ThinkingBlock.d.ts.map +1 -0
  32. package/dist/components/ThinkingBlock.js +29 -0
  33. package/dist/components/ThinkingBlock.js.map +1 -0
  34. package/dist/components/ToolCallBlock.d.ts +14 -0
  35. package/dist/components/ToolCallBlock.d.ts.map +1 -0
  36. package/dist/components/ToolCallBlock.js +83 -0
  37. package/dist/components/ToolCallBlock.js.map +1 -0
  38. package/dist/components/TrustDialog.d.ts +20 -0
  39. package/dist/components/TrustDialog.d.ts.map +1 -0
  40. package/dist/components/TrustDialog.js +80 -0
  41. package/dist/components/TrustDialog.js.map +1 -0
  42. package/dist/context.d.ts +25 -0
  43. package/dist/context.d.ts.map +1 -0
  44. package/dist/context.js +268 -0
  45. package/dist/context.js.map +1 -0
  46. package/dist/cray.d.ts +114 -0
  47. package/dist/cray.d.ts.map +1 -0
  48. package/dist/cray.js +338 -0
  49. package/dist/cray.js.map +1 -0
  50. package/dist/index.d.ts +16 -0
  51. package/dist/index.d.ts.map +1 -0
  52. package/dist/index.js +122 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/plugins/registry.d.ts +106 -0
  55. package/dist/plugins/registry.d.ts.map +1 -0
  56. package/dist/plugins/registry.js +695 -0
  57. package/dist/plugins/registry.js.map +1 -0
  58. package/dist/query.d.ts +31 -0
  59. package/dist/query.d.ts.map +1 -0
  60. package/dist/query.js +637 -0
  61. package/dist/query.js.map +1 -0
  62. package/dist/queryStream.d.ts +36 -0
  63. package/dist/queryStream.d.ts.map +1 -0
  64. package/dist/queryStream.js +704 -0
  65. package/dist/queryStream.js.map +1 -0
  66. package/dist/screens/ReplScreen.d.ts +22 -0
  67. package/dist/screens/ReplScreen.d.ts.map +1 -0
  68. package/dist/screens/ReplScreen.js +763 -0
  69. package/dist/screens/ReplScreen.js.map +1 -0
  70. package/dist/services/agentRunner.d.ts +39 -0
  71. package/dist/services/agentRunner.d.ts.map +1 -0
  72. package/dist/services/agentRunner.js +115 -0
  73. package/dist/services/agentRunner.js.map +1 -0
  74. package/dist/services/compact.d.ts +34 -0
  75. package/dist/services/compact.d.ts.map +1 -0
  76. package/dist/services/compact.js +179 -0
  77. package/dist/services/compact.js.map +1 -0
  78. package/dist/services/loadPluginCommands.d.ts +55 -0
  79. package/dist/services/loadPluginCommands.d.ts.map +1 -0
  80. package/dist/services/loadPluginCommands.js +219 -0
  81. package/dist/services/loadPluginCommands.js.map +1 -0
  82. package/dist/services/mcp/index.d.ts +3 -0
  83. package/dist/services/mcp/index.d.ts.map +1 -0
  84. package/dist/services/mcp/index.js +3 -0
  85. package/dist/services/mcp/index.js.map +1 -0
  86. package/dist/services/mcp/manager.d.ts +24 -0
  87. package/dist/services/mcp/manager.d.ts.map +1 -0
  88. package/dist/services/mcp/manager.js +138 -0
  89. package/dist/services/mcp/manager.js.map +1 -0
  90. package/dist/services/mcp/types.d.ts +52 -0
  91. package/dist/services/mcp/types.d.ts.map +1 -0
  92. package/dist/services/mcp/types.js +5 -0
  93. package/dist/services/mcp/types.js.map +1 -0
  94. package/dist/services/memory.d.ts +38 -0
  95. package/dist/services/memory.d.ts.map +1 -0
  96. package/dist/services/memory.js +181 -0
  97. package/dist/services/memory.js.map +1 -0
  98. package/dist/services/permissionPrompt.d.ts +38 -0
  99. package/dist/services/permissionPrompt.d.ts.map +1 -0
  100. package/dist/services/permissionPrompt.js +83 -0
  101. package/dist/services/permissionPrompt.js.map +1 -0
  102. package/dist/services/permissions.d.ts +15 -0
  103. package/dist/services/permissions.d.ts.map +1 -0
  104. package/dist/services/permissions.js +237 -0
  105. package/dist/services/permissions.js.map +1 -0
  106. package/dist/services/sessionStorage.d.ts +51 -0
  107. package/dist/services/sessionStorage.d.ts.map +1 -0
  108. package/dist/services/sessionStorage.js +266 -0
  109. package/dist/services/sessionStorage.js.map +1 -0
  110. package/dist/setup.d.ts +22 -0
  111. package/dist/setup.d.ts.map +1 -0
  112. package/dist/setup.js +160 -0
  113. package/dist/setup.js.map +1 -0
  114. package/dist/skills/bundledSkills.d.ts +18 -0
  115. package/dist/skills/bundledSkills.d.ts.map +1 -0
  116. package/dist/skills/bundledSkills.js +277 -0
  117. package/dist/skills/bundledSkills.js.map +1 -0
  118. package/dist/skills/index.d.ts +4 -0
  119. package/dist/skills/index.d.ts.map +1 -0
  120. package/dist/skills/index.js +3 -0
  121. package/dist/skills/index.js.map +1 -0
  122. package/dist/skills/loadSkillsDir.d.ts +45 -0
  123. package/dist/skills/loadSkillsDir.d.ts.map +1 -0
  124. package/dist/skills/loadSkillsDir.js +233 -0
  125. package/dist/skills/loadSkillsDir.js.map +1 -0
  126. package/dist/state/AppState.d.ts +70 -0
  127. package/dist/state/AppState.d.ts.map +1 -0
  128. package/dist/state/AppState.js +106 -0
  129. package/dist/state/AppState.js.map +1 -0
  130. package/dist/tools/AgentTool.d.ts +62 -0
  131. package/dist/tools/AgentTool.d.ts.map +1 -0
  132. package/dist/tools/AgentTool.js +133 -0
  133. package/dist/tools/AgentTool.js.map +1 -0
  134. package/dist/tools/AskUserQuestionTool.d.ts +60 -0
  135. package/dist/tools/AskUserQuestionTool.d.ts.map +1 -0
  136. package/dist/tools/AskUserQuestionTool.js +52 -0
  137. package/dist/tools/AskUserQuestionTool.js.map +1 -0
  138. package/dist/tools/BashTool.d.ts +33 -0
  139. package/dist/tools/BashTool.d.ts.map +1 -0
  140. package/dist/tools/BashTool.js +211 -0
  141. package/dist/tools/BashTool.js.map +1 -0
  142. package/dist/tools/EditTool.d.ts +24 -0
  143. package/dist/tools/EditTool.d.ts.map +1 -0
  144. package/dist/tools/EditTool.js +102 -0
  145. package/dist/tools/EditTool.js.map +1 -0
  146. package/dist/tools/GlobTool.d.ts +17 -0
  147. package/dist/tools/GlobTool.d.ts.map +1 -0
  148. package/dist/tools/GlobTool.js +65 -0
  149. package/dist/tools/GlobTool.js.map +1 -0
  150. package/dist/tools/GrepTool.d.ts +30 -0
  151. package/dist/tools/GrepTool.d.ts.map +1 -0
  152. package/dist/tools/GrepTool.js +140 -0
  153. package/dist/tools/GrepTool.js.map +1 -0
  154. package/dist/tools/MCPTool.d.ts +24 -0
  155. package/dist/tools/MCPTool.d.ts.map +1 -0
  156. package/dist/tools/MCPTool.js +67 -0
  157. package/dist/tools/MCPTool.js.map +1 -0
  158. package/dist/tools/NotebookEditTool.d.ts +28 -0
  159. package/dist/tools/NotebookEditTool.d.ts.map +1 -0
  160. package/dist/tools/NotebookEditTool.js +213 -0
  161. package/dist/tools/NotebookEditTool.js.map +1 -0
  162. package/dist/tools/NotebookReadTool.d.ts +19 -0
  163. package/dist/tools/NotebookReadTool.d.ts.map +1 -0
  164. package/dist/tools/NotebookReadTool.js +191 -0
  165. package/dist/tools/NotebookReadTool.js.map +1 -0
  166. package/dist/tools/PlanTools.d.ts +17 -0
  167. package/dist/tools/PlanTools.d.ts.map +1 -0
  168. package/dist/tools/PlanTools.js +65 -0
  169. package/dist/tools/PlanTools.js.map +1 -0
  170. package/dist/tools/ReadTool.d.ts +21 -0
  171. package/dist/tools/ReadTool.d.ts.map +1 -0
  172. package/dist/tools/ReadTool.js +202 -0
  173. package/dist/tools/ReadTool.js.map +1 -0
  174. package/dist/tools/SkillTool.d.ts +32 -0
  175. package/dist/tools/SkillTool.d.ts.map +1 -0
  176. package/dist/tools/SkillTool.js +217 -0
  177. package/dist/tools/SkillTool.js.map +1 -0
  178. package/dist/tools/TodoWriteTool.d.ts +35 -0
  179. package/dist/tools/TodoWriteTool.d.ts.map +1 -0
  180. package/dist/tools/TodoWriteTool.js +58 -0
  181. package/dist/tools/TodoWriteTool.js.map +1 -0
  182. package/dist/tools/WebFetchTool.d.ts +17 -0
  183. package/dist/tools/WebFetchTool.d.ts.map +1 -0
  184. package/dist/tools/WebFetchTool.js +97 -0
  185. package/dist/tools/WebFetchTool.js.map +1 -0
  186. package/dist/tools/WebSearchTool.d.ts +18 -0
  187. package/dist/tools/WebSearchTool.d.ts.map +1 -0
  188. package/dist/tools/WebSearchTool.js +76 -0
  189. package/dist/tools/WebSearchTool.js.map +1 -0
  190. package/dist/tools/WriteTool.d.ts +17 -0
  191. package/dist/tools/WriteTool.d.ts.map +1 -0
  192. package/dist/tools/WriteTool.js +84 -0
  193. package/dist/tools/WriteTool.js.map +1 -0
  194. package/dist/tools/index.d.ts +21 -0
  195. package/dist/tools/index.d.ts.map +1 -0
  196. package/dist/tools/index.js +20 -0
  197. package/dist/tools/index.js.map +1 -0
  198. package/dist/tools.d.ts +34 -0
  199. package/dist/tools.d.ts.map +1 -0
  200. package/dist/tools.js +102 -0
  201. package/dist/tools.js.map +1 -0
  202. package/dist/types/events.d.ts +85 -0
  203. package/dist/types/events.d.ts.map +1 -0
  204. package/dist/types/events.js +12 -0
  205. package/dist/types/events.js.map +1 -0
  206. package/dist/types/index.d.ts +4 -0
  207. package/dist/types/index.d.ts.map +1 -0
  208. package/dist/types/index.js +4 -0
  209. package/dist/types/index.js.map +1 -0
  210. package/dist/types/message.d.ts +71 -0
  211. package/dist/types/message.d.ts.map +1 -0
  212. package/dist/types/message.js +5 -0
  213. package/dist/types/message.js.map +1 -0
  214. package/dist/types/permission.d.ts +56 -0
  215. package/dist/types/permission.d.ts.map +1 -0
  216. package/dist/types/permission.js +46 -0
  217. package/dist/types/permission.js.map +1 -0
  218. package/dist/types/processUserInput.d.ts +18 -0
  219. package/dist/types/processUserInput.d.ts.map +1 -0
  220. package/dist/types/processUserInput.js +8 -0
  221. package/dist/types/processUserInput.js.map +1 -0
  222. package/dist/types/tool.d.ts +32 -0
  223. package/dist/types/tool.d.ts.map +1 -0
  224. package/dist/types/tool.js +5 -0
  225. package/dist/types/tool.js.map +1 -0
  226. package/dist/utils/compactBoundary.d.ts +11 -0
  227. package/dist/utils/compactBoundary.d.ts.map +1 -0
  228. package/dist/utils/compactBoundary.js +26 -0
  229. package/dist/utils/compactBoundary.js.map +1 -0
  230. package/dist/utils/configStore.d.ts +41 -0
  231. package/dist/utils/configStore.d.ts.map +1 -0
  232. package/dist/utils/configStore.js +111 -0
  233. package/dist/utils/configStore.js.map +1 -0
  234. package/dist/utils/forkedAgent.d.ts +40 -0
  235. package/dist/utils/forkedAgent.d.ts.map +1 -0
  236. package/dist/utils/forkedAgent.js +231 -0
  237. package/dist/utils/forkedAgent.js.map +1 -0
  238. package/dist/utils/messages.d.ts +14 -0
  239. package/dist/utils/messages.d.ts.map +1 -0
  240. package/dist/utils/messages.js +29 -0
  241. package/dist/utils/messages.js.map +1 -0
  242. package/dist/utils/sandbox.d.ts +22 -0
  243. package/dist/utils/sandbox.d.ts.map +1 -0
  244. package/dist/utils/sandbox.js +59 -0
  245. package/dist/utils/sandbox.js.map +1 -0
  246. package/dist/utils/sideQuestion.d.ts +29 -0
  247. package/dist/utils/sideQuestion.d.ts.map +1 -0
  248. package/dist/utils/sideQuestion.js +81 -0
  249. package/dist/utils/sideQuestion.js.map +1 -0
  250. package/install.ps1 +86 -0
  251. package/install.sh +92 -0
  252. package/package.json +68 -0
@@ -0,0 +1,277 @@
1
+ /**
2
+ * Bundled Skills System for Cray Code.
3
+ *
4
+ * Skills extend agent capabilities with specialized knowledge and instructions.
5
+ * They can restrict tool access, set preferred models, and provide reference files.
6
+ *
7
+ * Two types:
8
+ * - Bundled skills: compiled into the framework (defined here)
9
+ * - Disk-based skills: loaded from .cray/skills/ directories at runtime
10
+ */
11
+ // ─── Bundled Skill Registry ──────────────────────────────────────────────
12
+ const bundledSkills = new Map();
13
+ /** Register a bundled skill */
14
+ export function registerBundledSkill(skill) {
15
+ bundledSkills.set(skill.name, skill);
16
+ }
17
+ /** Get all registered bundled skills */
18
+ export function getBundledSkills() {
19
+ return [...bundledSkills.values()];
20
+ }
21
+ /** Get a specific bundled skill by name */
22
+ export function getBundledSkill(name) {
23
+ return bundledSkills.get(name);
24
+ }
25
+ // ─── Built-in Skills ────────────────────────────────────────────────────
26
+ //
27
+ // Each skill below follows Claude Code's pattern: a full SKILL.md-like body
28
+ // that gets injected into the conversation when the model invokes SkillTool.
29
+ registerBundledSkill({
30
+ name: 'code-review',
31
+ description: 'Review code for bugs, logic errors, security vulnerabilities, and code quality issues.',
32
+ whenToUse: 'When asked to review code, check PRs, or audit code quality.',
33
+ allowedTools: ['read', 'glob', 'grep'],
34
+ context: 'inline',
35
+ source: 'bundled',
36
+ content: `# Code Review Skill
37
+
38
+ ## When to Use
39
+ Invoke this skill when the user asks you to review code, audit code quality, or check for bugs.
40
+
41
+ ## Instructions
42
+
43
+ When performing a code review, focus on these categories in order of priority:
44
+
45
+ 1. **Correctness bugs** — logic errors, off-by-one, null/undefined access, race conditions
46
+ 2. **Security vulnerabilities** — injection attacks, XSS, CSRF, insecure crypto, exposed secrets
47
+ 3. **Logic & design issues** — dead code, incorrect abstractions, error handling gaps
48
+ 4. **Code quality** — readability, naming, comments, unnecessary complexity
49
+
50
+ For each finding, report:
51
+ - Severity (critical / high / medium / low)
52
+ - File path and line range
53
+ - What the issue is
54
+ - Why it matters
55
+ - Suggested fix
56
+
57
+ Only report findings that truly matter. Skip style nitpicks that don't affect correctness or maintainability.
58
+ `,
59
+ });
60
+ registerBundledSkill({
61
+ name: 'brainstorming',
62
+ description: 'Brainstorm ideas and design approaches before implementation.',
63
+ whenToUse: 'When planning new features, designing architecture, or exploring alternative approaches.',
64
+ allowedTools: ['read', 'glob', 'grep', 'web_search'],
65
+ context: 'inline',
66
+ source: 'bundled',
67
+ content: `# Brainstorming Skill
68
+
69
+ ## When to Use
70
+ Invoke this skill when the user asks you to brainstorm, design, or explore approaches before writing code.
71
+
72
+ ## Instructions
73
+
74
+ 1. **Understand the problem** — restate what the user wants in your own words
75
+ 2. **Explore the codebase** — use read/glob/grep to understand existing patterns and constraints
76
+ 3. **Generate 2-3 alternatives** — for each, cover:
77
+ - Approach description (2-3 sentences)
78
+ - Key files that would change
79
+ - Pros and cons (trade-offs)
80
+ - Estimated complexity
81
+ 4. **Recommend one approach** — explain why it's the best fit
82
+
83
+ Do NOT start implementing. Stay in exploration mode. The user will
84
+ give a clear signal when they are ready to proceed to implementation.
85
+ `,
86
+ });
87
+ registerBundledSkill({
88
+ name: 'debugging',
89
+ description: 'Systematic debugging approach: reproduce, isolate, fix, verify.',
90
+ whenToUse: 'When fixing bugs, investigating errors, or troubleshooting unexpected behavior.',
91
+ allowedTools: ['read', 'bash', 'edit', 'write', 'glob', 'grep'],
92
+ context: 'fork',
93
+ source: 'bundled',
94
+ content: `# Systematic Debugging Skill
95
+
96
+ ## When to Use
97
+ Invoke this skill when the user reports a bug, an error, or unexpected behavior.
98
+
99
+ ## Instructions
100
+
101
+ You are a debugging specialist. Follow this systematic process:
102
+
103
+ 1. **Reproduce** — understand exactly what triggers the bug. If possible, run the failing command or test.
104
+ 2. **Isolate** — read relevant code, add diagnostic logging, narrow down the cause.
105
+ 3. **Form hypotheses** — list possible root causes ranked by likelihood.
106
+ 4. **Test each hypothesis** — use bash to run tests, add temporary logs, or inspect state.
107
+ 5. **Fix** — once the root cause is confirmed, make the minimal fix.
108
+ 6. **Verify** — run the original reproducer to confirm the fix works.
109
+ 7. **Regression check** — run related tests to make sure nothing else broke.
110
+
111
+ Report your findings at each step. Do NOT skip to the fix without
112
+ confirming the root cause first.
113
+ `,
114
+ });
115
+ registerBundledSkill({
116
+ name: 'test-driven-development',
117
+ description: 'Write tests first, then implement to make them pass.',
118
+ whenToUse: 'When implementing new features or fixing bugs where tests should be written first.',
119
+ allowedTools: ['read', 'write', 'edit', 'bash', 'glob', 'grep'],
120
+ context: 'fork',
121
+ source: 'bundled',
122
+ content: `# Test-Driven Development Skill
123
+
124
+ ## When to Use
125
+ Invoke this skill when the user asks for TDD, writing tests, or implementing features with test coverage.
126
+
127
+ ## Instructions
128
+
129
+ Follow the TDD cycle strictly:
130
+
131
+ 1. **Write a failing test** — add the simplest test that captures the desired behavior
132
+ 2. **Run the test** — confirm it FAILS (red)
133
+ 3. **Write minimal code** — implement just enough to make the test pass (green)
134
+ 4. **Refactor** — clean up both test and production code while tests stay green
135
+ 5. **Repeat** — go back to step 1 for the next behavior
136
+
137
+ Key rules:
138
+ - Never write production code without a failing test first
139
+ - Keep each test focused on one behavior
140
+ - Tests should be readable — name them after what they verify
141
+ - If you're unsure what to test, ask the user for clarification
142
+ `,
143
+ });
144
+ registerBundledSkill({
145
+ name: 'frontend-design',
146
+ description: 'Design and implement frontend UI components with best practices.',
147
+ whenToUse: 'When building UI components, styling pages, or implementing visual designs.',
148
+ allowedTools: ['read', 'write', 'edit', 'glob', 'grep', 'web_fetch', 'web_search'],
149
+ context: 'fork',
150
+ source: 'bundled',
151
+ content: `# Frontend Design Skill
152
+
153
+ ## When to Use
154
+ Invoke this skill when building or modifying UI components, pages, or visual elements.
155
+
156
+ ## Instructions
157
+
158
+ Design and implement frontend features following these principles:
159
+
160
+ 1. **Understand the existing design system** — read existing components, CSS/Tailwind config, theme files
161
+ 2. **Consistency first** — reuse existing patterns, spacing, colors, and typography
162
+ 3. **Accessibility** — ensure keyboard navigation, screen reader support, and proper ARIA labels
163
+ 4. **Responsive** — handle mobile, tablet, and desktop breakpoints
164
+ 5. **Performance** — avoid unnecessary re-renders, lazy load where appropriate
165
+ 6. **Testing** — add component tests for key interactions
166
+
167
+ Before implementing:
168
+ - Check if there's an existing component that can be extended
169
+ - Confirm the state management pattern (local state, context, store)
170
+ - Verify the design with the user if visually ambiguous
171
+ `,
172
+ });
173
+ registerBundledSkill({
174
+ name: 'writing-plans',
175
+ description: 'Write detailed implementation plans with architectural decisions.',
176
+ whenToUse: 'Before implementing complex features that require planning.',
177
+ allowedTools: ['read', 'glob', 'grep', 'web_search'],
178
+ context: 'inline',
179
+ source: 'bundled',
180
+ content: `# Writing Plans Skill
181
+
182
+ ## When to Use
183
+ Invoke this skill when the user asks you to plan an implementation before coding.
184
+
185
+ ## Instructions
186
+
187
+ Produce a structured implementation plan:
188
+
189
+ 1. **Goal** — one sentence describing what we're building
190
+ 2. **Files to create/modify** — sorted by dependency order
191
+ 3. **Architecture decisions** — patterns, libraries, data flow
192
+ 4. **Step-by-step sequence** — numbered steps, each checkable
193
+ 5. **Risks & edge cases** — what could go wrong
194
+ 6. **Test plan** — how to verify the implementation works
195
+
196
+ Be specific. Use actual file paths. Reference existing patterns in the codebase.
197
+ The user should be able to hand this plan to another developer (or a fork agent) to execute.
198
+ `,
199
+ });
200
+ registerBundledSkill({
201
+ name: 'executing-plans',
202
+ description: 'Execute approved implementation plans step by step.',
203
+ whenToUse: 'When an approved implementation plan needs to be executed systematically.',
204
+ allowedTools: ['read', 'write', 'edit', 'bash', 'glob', 'grep'],
205
+ context: 'fork',
206
+ source: 'bundled',
207
+ content: `# Executing Plans Skill
208
+
209
+ ## When to Use
210
+ Invoke this skill when executing an approved implementation plan step by step.
211
+
212
+ ## Instructions
213
+
214
+ You are an implementation specialist executing an approved plan:
215
+
216
+ 1. **Read the plan** in full before starting
217
+ 2. **Work through steps sequentially** — do NOT skip ahead
218
+ 3. **Complete each step fully** before moving to the next
219
+ 4. **Verify after each step** — run tests, check lint, confirm the change works
220
+ 5. **Flag blockers immediately** — if something prevents progress, report it
221
+ 6. **Track progress** — mark each step done as you complete it
222
+
223
+ Do NOT deviate from the plan unless you explicitly flag it and get approval.
224
+ `,
225
+ });
226
+ registerBundledSkill({
227
+ name: 'systematic-debugging',
228
+ description: 'Methodical debugging: gather symptoms, form hypotheses, test systematically.',
229
+ whenToUse: 'When debugging complex issues that require a structured approach.',
230
+ allowedTools: ['read', 'bash', 'edit', 'glob', 'grep', 'web_search'],
231
+ context: 'fork',
232
+ source: 'bundled',
233
+ content: `# Systematic Debugging Skill
234
+
235
+ ## When to Use
236
+ Invoke this skill for methodical debugging of complex issues.
237
+
238
+ ## Instructions
239
+
240
+ 1. **Gather symptoms** — read error logs, reproduce the issue, note exact behavior
241
+ 2. **Map the code path** — trace the execution flow through affected files
242
+ 3. **Form hypotheses** — list at least 2 possible root causes
243
+ 4. **Design diagnostic tests** — for each hypothesis, what would prove it right or wrong
244
+ 5. **Execute diagnostics** — run the tests, add logging, inspect state
245
+ 6. **Identify root cause** — confirm which hypothesis is correct
246
+ 7. **Fix and verify** — apply the minimal fix and confirm it resolves the issue
247
+
248
+ Document each step so the user can follow your reasoning.
249
+ `,
250
+ });
251
+ registerBundledSkill({
252
+ name: 'verification-before-completion',
253
+ description: 'Verify changes work correctly before reporting completion.',
254
+ whenToUse: 'After implementing changes, before reporting the task as complete.',
255
+ allowedTools: ['read', 'bash', 'glob', 'grep'],
256
+ context: 'inline',
257
+ source: 'bundled',
258
+ content: `# Verification Before Completion Skill
259
+
260
+ ## When to Use
261
+ Invoke this skill after making code changes, before telling the user the task is done.
262
+
263
+ ## Instructions
264
+
265
+ Before reporting a task as complete, verify:
266
+
267
+ 1. **Tests pass** — run relevant test suites (unit, integration, e2e if applicable)
268
+ 2. **Build succeeds** — the project compiles without errors
269
+ 3. **No regressions** — check that existing functionality still works
270
+ 4. **Edge cases** — test at least 2 edge cases for the change
271
+ 5. **Manual check** — if it's a UI change, verify visually; if it's a CLI change, run the command
272
+
273
+ If any check fails, fix the issue before reporting completion.
274
+ Report what you verified and the results.
275
+ `,
276
+ });
277
+ //# sourceMappingURL=bundledSkills.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundledSkills.js","sourceRoot":"","sources":["../../src/skills/bundledSkills.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,4EAA4E;AAE5E,MAAM,aAAa,GAAG,IAAI,GAAG,EAAqB,CAAC;AAEnD,+BAA+B;AAC/B,MAAM,UAAU,oBAAoB,CAAC,KAAgB;IACnD,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACvC,CAAC;AAED,wCAAwC;AACxC,MAAM,UAAU,gBAAgB;IAC9B,OAAO,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC;AACrC,CAAC;AAED,2CAA2C;AAC3C,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AAED,2EAA2E;AAC3E,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAE7E,oBAAoB,CAAC;IACnB,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,wFAAwF;IACrG,SAAS,EAAE,8DAA8D;IACzE,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;IACtC,OAAO,EAAE,QAAQ;IACjB,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE;;;;;;;;;;;;;;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{ registerBundledSkill, getBundledSkills, getBundledSkill } from './bundledSkills.js';
2
+ export { loadDiskSkills, getSkillDirectories, discoverSkillDirsForPaths } from './loadSkillsDir.js';
3
+ export type { DiskSkill } from './loadSkillsDir.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/skills/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AACpG,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { registerBundledSkill, getBundledSkills, getBundledSkill } from './bundledSkills.js';
2
+ export { loadDiskSkills, getSkillDirectories, discoverSkillDirsForPaths } from './loadSkillsDir.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/skills/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Disk-based Skill Loader for Cray Code.
3
+ *
4
+ * Skills are markdown files in .cray/skills/ directories.
5
+ * Supports install, create, and auto-discovery.
6
+ */
7
+ import type { SkillInfo } from '../Tool.js';
8
+ export interface DiskSkill {
9
+ name: string;
10
+ description: string;
11
+ whenToUse?: string;
12
+ path: string;
13
+ content: string;
14
+ baseDir?: string;
15
+ allowedTools?: string[];
16
+ model?: string;
17
+ context?: 'inline' | 'fork';
18
+ }
19
+ export declare function getSkillDirectories(projectRoot?: string): string[];
20
+ export declare function loadAllSkills(projectRoot?: string): Promise<SkillInfo[]>;
21
+ /** Backward-compat alias */
22
+ export declare const loadDiskSkills: typeof loadAllSkills;
23
+ export declare function loadSkillsFromDir(dir: string): Promise<SkillInfo[]>;
24
+ export declare function installSkill(source: string, projectRoot?: string): Promise<{
25
+ success: boolean;
26
+ message: string;
27
+ skillName?: string;
28
+ }>;
29
+ export declare function createSkill(name: string, destDir?: string): {
30
+ success: boolean;
31
+ message: string;
32
+ };
33
+ interface SkillRegistryEntry {
34
+ name: string;
35
+ description: string;
36
+ author: string;
37
+ url: string;
38
+ version: string;
39
+ }
40
+ /** Fetch the Cray Skills registry (offline cache = built-in list). */
41
+ export declare function getBuiltInSkillRegistry(): SkillRegistryEntry[];
42
+ export declare function fetchSkillRegistry(): Promise<SkillRegistryEntry[]>;
43
+ export declare function discoverSkillDirsForPaths(paths: string[], projectRoot?: string): string[];
44
+ export {};
45
+ //# sourceMappingURL=loadSkillsDir.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadSkillsDir.d.ts","sourceRoot":"","sources":["../../src/skills/loadSkillsDir.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;CAC7B;AAID,wBAAgB,mBAAmB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CASlE;AAID,wBAAsB,aAAa,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAQ9E;AAED,4BAA4B;AAC5B,eAAO,MAAM,cAAc,sBAAgB,CAAC;AAE5C,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAmCzE;AAID,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA8B3I;AAID,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CA0BjG;AAID,UAAU,kBAAkB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACjB;AAID,sEAAsE;AACtE,wBAAgB,uBAAuB,IAAI,kBAAkB,EAAE,CAY9D;AAED,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAMxE;AAiDD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAazF"}
@@ -0,0 +1,233 @@
1
+ /**
2
+ * Disk-based Skill Loader for Cray Code.
3
+ *
4
+ * Skills are markdown files in .cray/skills/ directories.
5
+ * Supports install, create, and auto-discovery.
6
+ */
7
+ import { readdir, readFile, stat } from 'fs/promises';
8
+ import { join, extname, basename, dirname } from 'path';
9
+ import { existsSync, mkdirSync, writeFileSync, readFileSync, readdirSync, statSync } from 'fs';
10
+ import { homedir } from 'os';
11
+ // ─── Directory Discovery ────────────────────────────────────────────
12
+ export function getSkillDirectories(projectRoot) {
13
+ const dirs = [];
14
+ const userDir = join(homedir(), '.cray', 'skills');
15
+ if (existsSync(userDir))
16
+ dirs.push(userDir);
17
+ if (projectRoot) {
18
+ const projDir = join(projectRoot, '.cray', 'skills');
19
+ if (existsSync(projDir))
20
+ dirs.push(projDir);
21
+ }
22
+ return dirs;
23
+ }
24
+ // ─── Full Skill Loader ──────────────────────────────────────────────
25
+ export async function loadAllSkills(projectRoot) {
26
+ const dirs = getSkillDirectories(projectRoot);
27
+ const skills = [];
28
+ for (const dir of dirs) {
29
+ const loaded = await loadSkillsFromDir(dir);
30
+ skills.push(...loaded);
31
+ }
32
+ return skills;
33
+ }
34
+ /** Backward-compat alias */
35
+ export const loadDiskSkills = loadAllSkills;
36
+ export async function loadSkillsFromDir(dir) {
37
+ const skills = [];
38
+ try {
39
+ const entries = await readdir(dir);
40
+ for (const entry of entries) {
41
+ const full = join(dir, entry);
42
+ try {
43
+ const st = await stat(full);
44
+ // Flat .md file: use filename as skill name (e.g., my-skill.md → "my-skill")
45
+ if (st.isFile() && extname(entry).toLowerCase() === '.md') {
46
+ const content = await readFile(full, 'utf-8');
47
+ const s = parseSkillMarkdown(entry, content, full);
48
+ if (s)
49
+ skills.push(s);
50
+ continue;
51
+ }
52
+ // Directory: use directory name as skill name,
53
+ // read the first .md file inside as the skill content.
54
+ if (st.isDirectory()) {
55
+ const sf = await readdir(full);
56
+ for (const f of sf) {
57
+ if (extname(f).toLowerCase() === '.md') {
58
+ const p = join(full, f);
59
+ try {
60
+ const c = await readFile(p, 'utf-8');
61
+ // Key fix: use directory name, not inner filename
62
+ const s = parseSkillMarkdown(entry, c, p);
63
+ if (s)
64
+ skills.push(s);
65
+ }
66
+ catch { /* skip */ }
67
+ }
68
+ }
69
+ }
70
+ }
71
+ catch { /* skip */ }
72
+ }
73
+ }
74
+ catch { /* dir may not exist */ }
75
+ return skills;
76
+ }
77
+ // ─── Install Skill ─────────────────────────────────────────────────
78
+ export async function installSkill(source, projectRoot) {
79
+ const destDir = join(projectRoot ?? homedir(), '.cray', 'skills');
80
+ mkdirSync(destDir, { recursive: true });
81
+ // Source is a URL (e.g., GitHub repo path) — try to fetch it
82
+ if (source.startsWith('http://') || source.startsWith('https://')) {
83
+ try {
84
+ const res = await fetch(source + '/raw/main/SKILL.md');
85
+ if (res.ok) {
86
+ const content = await res.text();
87
+ const name = new URL(source).pathname.split('/').filter(Boolean).slice(-1)[0] || 'installed-skill';
88
+ const skillDir = join(destDir, name);
89
+ mkdirSync(skillDir, { recursive: true });
90
+ writeFileSync(join(skillDir, 'SKILL.md'), content, 'utf-8');
91
+ return { success: true, message: `Skill "${name}" installed from URL.`, skillName: name };
92
+ }
93
+ }
94
+ catch { /* fall through */ }
95
+ return { success: false, message: `Could not fetch skill from ${source}` };
96
+ }
97
+ // Source is a local path
98
+ const abs = join(process.cwd(), source);
99
+ if (!existsSync(abs)) {
100
+ return { success: false, message: `Source not found: ${abs}` };
101
+ }
102
+ const name = basename(abs);
103
+ const dest = join(destDir, name);
104
+ copyDirSync(abs, dest);
105
+ return { success: true, message: `Skill "${name}" installed to ${dest}`, skillName: name };
106
+ }
107
+ // ─── Create Skill ──────────────────────────────────────────────────
108
+ export function createSkill(name, destDir) {
109
+ const dir = destDir ?? join(homedir(), '.cray', 'skills', name);
110
+ mkdirSync(dir, { recursive: true });
111
+ const template = [
112
+ '---',
113
+ `description: "${name} — custom skill"`,
114
+ 'allowed_tools: [read, glob, grep, bash]',
115
+ 'context: inline',
116
+ '---',
117
+ '',
118
+ `# ${name}`,
119
+ '',
120
+ '## Purpose',
121
+ '',
122
+ 'Describe what this skill does and when it should be used.',
123
+ '',
124
+ '## Instructions',
125
+ '',
126
+ 'These instructions are injected into the model\'s system prompt.',
127
+ '',
128
+ '## Allowed Tools',
129
+ '',
130
+ '`read` `glob` `grep` `bash`',
131
+ ].join('\n');
132
+ writeFileSync(join(dir, 'SKILL.md'), template, 'utf-8');
133
+ return { success: true, message: `Skill "${name}" created at ${dir}/SKILL.md` };
134
+ }
135
+ const SKILL_REGISTRY_URL = 'https://raw.githubusercontent.com/example/cray-skills/main/registry.json';
136
+ /** Fetch the Cray Skills registry (offline cache = built-in list). */
137
+ export function getBuiltInSkillRegistry() {
138
+ return [
139
+ { name: 'code-review', description: 'Review code for bugs and quality issues.', author: 'cray', url: 'builtin', version: '1.0.0' },
140
+ { name: 'brainstorming', description: 'Brainstorm design approaches before implementing.', author: 'cray', url: 'builtin', version: '1.0.0' },
141
+ { name: 'debugging', description: 'Systematic debugging: reproduce, isolate, fix, verify.', author: 'cray', url: 'builtin', version: '1.0.0' },
142
+ { name: 'test-driven-development', description: 'Write tests first, then implement.', author: 'cray', url: 'builtin', version: '1.0.0' },
143
+ { name: 'frontend-design', description: 'Design and implement frontend UI components.', author: 'cray', url: 'builtin', version: '1.0.0' },
144
+ { name: 'writing-plans', description: 'Write detailed implementation plans.', author: 'cray', url: 'builtin', version: '1.0.0' },
145
+ { name: 'executing-plans', description: 'Execute approved implementation plans.', author: 'cray', url: 'builtin', version: '1.0.0' },
146
+ { name: 'systematic-debugging', description: 'Methodical debugging approach.', author: 'cray', url: 'builtin', version: '1.0.0' },
147
+ { name: 'verification-before-completion', description: 'Verify changes work before reporting completion.', author: 'cray', url: 'builtin', version: '1.0.0' },
148
+ ];
149
+ }
150
+ export async function fetchSkillRegistry() {
151
+ try {
152
+ const res = await fetch(SKILL_REGISTRY_URL);
153
+ if (res.ok)
154
+ return (await res.json());
155
+ }
156
+ catch { /* offline — use cache */ }
157
+ return getBuiltInSkillRegistry();
158
+ }
159
+ // ─── Markdown Parser ───────────────────────────────────────────────
160
+ function parseSkillMarkdown(filename, content, filePath) {
161
+ const name = basename(filename, '.md');
162
+ let description = '', model;
163
+ let allowedTools;
164
+ let context;
165
+ let whenToUse;
166
+ let body = '';
167
+ if (content.startsWith('---')) {
168
+ const endIdx = content.indexOf('---', 3);
169
+ if (endIdx > 0) {
170
+ body = content.slice(endIdx + 3).trim();
171
+ for (const line of content.slice(3, endIdx).trim().split('\n')) {
172
+ const ci = line.indexOf(':');
173
+ if (ci < 0)
174
+ continue;
175
+ const k = line.slice(0, ci).trim();
176
+ const v = line.slice(ci + 1).trim().replace(/^["']|["']$/g, '');
177
+ switch (k) {
178
+ case 'description':
179
+ description = v;
180
+ break;
181
+ case 'model':
182
+ model = v;
183
+ break;
184
+ case 'when_to_use':
185
+ whenToUse = v;
186
+ break;
187
+ case 'allowed_tools':
188
+ case 'allowed-tools':
189
+ allowedTools = v.replace(/^\[|\]$/g, '').split(',').map(t => t.trim().replace(/^["']|["']$/g, '')).filter(Boolean);
190
+ break;
191
+ case 'context':
192
+ if (v === 'inline' || v === 'fork')
193
+ context = v;
194
+ break;
195
+ }
196
+ }
197
+ }
198
+ }
199
+ else {
200
+ body = content.trim();
201
+ }
202
+ if (!description) {
203
+ description = body.split('\n')[0]?.replace(/^#+\s*/, '').trim() || name;
204
+ }
205
+ // Extract base directory from file path
206
+ const baseDir = filePath ? filePath.slice(0, filePath.lastIndexOf('/') !== -1 ? filePath.lastIndexOf('/') : filePath.lastIndexOf('\\')).replace(/[/\\]SKILL\.md$/i, '') : undefined;
207
+ return { name, description, whenToUse, content: body, baseDir, allowedTools, model, context, source: 'disk' };
208
+ }
209
+ export function discoverSkillDirsForPaths(paths, projectRoot) {
210
+ const dirs = new Set();
211
+ for (const p of paths) {
212
+ let cur = p;
213
+ while (cur && cur !== projectRoot) {
214
+ const sd = join(cur, '.cray', 'skills');
215
+ if (existsSync(sd))
216
+ dirs.add(sd);
217
+ const parent = dirname(cur);
218
+ if (parent === cur)
219
+ break;
220
+ cur = parent;
221
+ }
222
+ }
223
+ return [...dirs];
224
+ }
225
+ // ─── File System Helpers ───────────────────────────────────────────
226
+ function copyDirSync(src, dest) {
227
+ mkdirSync(dest, { recursive: true });
228
+ for (const entry of readdirSync(src)) {
229
+ const s = join(src, entry), d = join(dest, entry);
230
+ statSync(s).isDirectory() ? copyDirSync(s, d) : writeFileSync(d, readFileSync(s));
231
+ }
232
+ }
233
+ //# sourceMappingURL=loadSkillsDir.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadSkillsDir.js","sourceRoot":"","sources":["../../src/skills/loadSkillsDir.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAoB,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC/F,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAe7B,uEAAuE;AAEvE,MAAM,UAAU,mBAAmB,CAAC,WAAoB;IACtD,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACnD,IAAI,UAAU,CAAC,OAAO,CAAC;QAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5C,IAAI,WAAW,EAAE,CAAC;QAChB,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QACrD,IAAI,UAAU,CAAC,OAAO,CAAC;YAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,uEAAuE;AAEvE,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,WAAoB;IACtD,MAAM,IAAI,GAAG,mBAAmB,CAAC,WAAW,CAAC,CAAC;IAC9C,MAAM,MAAM,GAAgB,EAAE,CAAC;IAC/B,KAAK,MAAM,GAAG,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