llm-sentry-tools 1.2.0 → 1.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "llm-sentry-tools",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "基于 Sentry MCP 的错误分析和修复工具,支持 Claude Code、Cursor 等 AI 工具",
5
5
  "type": "module",
6
6
  "bin": {
@@ -14,20 +14,24 @@ console.log('🚀 AI 工具命令配置\n');
14
14
  const AI_TOOLS = {
15
15
  'claude-code': {
16
16
  name: 'Claude Code',
17
- configDir: '.claude/skills',
17
+ configDir: '.claude/commands/sentry-tools',
18
18
  fileExtension: 'md',
19
- useSkillDirectory: true, // 每个 skill 是一个目录
19
+ useSkillDirectory: false, // commands 是单个文件
20
20
  createCommand: (commandName, promptContent) => {
21
21
  const descriptions = {
22
22
  'analyze-sentry-error': '从 Sentry 获取错误详情并进行深度分析,定位问题代码,提供详细分析报告',
23
23
  'fix-sentry-error': '分析 Sentry 错误并自动修复代码,提供验证建议'
24
24
  };
25
+ const argumentHints = {
26
+ 'analyze-sentry-error': '<sentry-url> | <issue-id>',
27
+ 'fix-sentry-error': '<sentry-url> | <issue-id>'
28
+ };
25
29
  return `---
26
- name: ${commandName}
27
30
  description: ${descriptions[commandName] || commandName}
31
+ argument-hint: ${argumentHints[commandName] || '[参数]'}
28
32
  ---
29
33
 
30
- ${promptContent}`;
34
+ ${promptContent.replace(/用户输入:\n```\n\/\S+/g, '用户输入:$ARGUMENTS')}`;
31
35
  }
32
36
  },
33
37
  'cursor': {
@@ -107,26 +111,18 @@ const detectConfiguredTools = (projectPath) => {
107
111
  for (const [key, tool] of Object.entries(AI_TOOLS)) {
108
112
  const configPath = join(projectPath, tool.configDir);
109
113
 
110
- if (tool.useSkillDirectory) {
111
- // Claude Code: 检查 skills 目录中是否有任何 skill 目录
112
- if (existsSync(configPath)) {
113
- try {
114
- const items = readdirSync(configPath);
115
- // 检查是否有包含 SKILL.md 的目录
116
- configured[key] = items.some(item => {
117
- const itemPath = join(configPath, item);
118
- const skillPath = join(itemPath, 'SKILL.md');
119
- return statSync(itemPath).isDirectory() && existsSync(skillPath);
120
- });
121
- } catch {
122
- configured[key] = false;
123
- }
124
- } else {
114
+ if (existsSync(configPath)) {
115
+ try {
116
+ const items = readdirSync(configPath);
117
+ // 检查是否存在我们的命令文件
118
+ const hasAnalyze = items.includes(`analyze-sentry-error.${tool.fileExtension}`);
119
+ const hasFix = items.includes(`fix-sentry-error.${tool.fileExtension}`);
120
+ configured[key] = hasAnalyze || hasFix;
121
+ } catch {
125
122
  configured[key] = false;
126
123
  }
127
124
  } else {
128
- // 其他工具: 检查配置目录是否存在
129
- configured[key] = existsSync(configPath);
125
+ configured[key] = false;
130
126
  }
131
127
  }
132
128
 
@@ -200,22 +196,10 @@ const setupCommands = async () => {
200
196
  // 创建命令文件
201
197
  for (const command of commands) {
202
198
  const commandContent = tool.createCommand(command.name, command.content);
203
-
204
- let commandFilePath;
205
- if (tool.useSkillDirectory) {
206
- // Claude Code: 创建目录结构 skill-name/SKILL.md
207
- const skillDir = join(toolConfigDir, command.name);
208
- if (!existsSync(skillDir)) {
209
- mkdirSync(skillDir, { recursive: true });
210
- }
211
- commandFilePath = join(skillDir, `SKILL.${tool.fileExtension}`);
212
- } else {
213
- // 其他工具: 创建单个文件 skill-name.md
214
- commandFilePath = join(
215
- toolConfigDir,
216
- `${command.name}.${tool.fileExtension}`
217
- );
218
- }
199
+ const commandFilePath = join(
200
+ toolConfigDir,
201
+ `${command.name}.${tool.fileExtension}`
202
+ );
219
203
 
220
204
  writeFileSync(commandFilePath, commandContent, 'utf-8');
221
205
  console.log(`✓ 创建命令: ${commandFilePath}`);
@@ -229,9 +213,9 @@ const setupCommands = async () => {
229
213
  console.log(' - 分析错误: /analyze-sentry-error <sentry-url>');
230
214
  console.log(' - 修复错误: /fix-sentry-error <sentry-url>\n');
231
215
 
232
- // 如果配置了 Claude Code,提示需要重启
216
+ // 如果配置了 Claude Code,提示命令已就绪
233
217
  if (selectedTools.includes('claude-code')) {
234
- console.log('💡 提示:如果正在运行 Claude Code,请重启以加载新的 skills\n');
218
+ console.log('💡 提示:在 Claude Code 中输入 / 可以看到可用的命令\n');
235
219
  }
236
220
 
237
221
  } catch (error) {