openmatrix 0.1.18 → 0.1.19

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.
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare const checkGitignoreCommand: Command;
@@ -0,0 +1,361 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.checkGitignoreCommand = void 0;
40
+ // src/cli/commands/check-gitignore.ts
41
+ const commander_1 = require("commander");
42
+ const fs = __importStar(require("fs/promises"));
43
+ const path = __importStar(require("path"));
44
+ const chalk_1 = __importDefault(require("chalk"));
45
+ /**
46
+ * 项目类型对应的 gitignore 条目
47
+ */
48
+ const GITIGNORE_TEMPLATES = {
49
+ nodejs: [
50
+ 'node_modules/',
51
+ 'dist/',
52
+ 'build/',
53
+ '.npm/',
54
+ '*.log',
55
+ 'npm-debug.log*',
56
+ 'yarn-debug.log*',
57
+ 'yarn-error.log*'
58
+ ],
59
+ typescript: [
60
+ '*.tsbuildinfo',
61
+ '.tsbuildinfo'
62
+ ],
63
+ python: [
64
+ '__pycache__/',
65
+ '*.py[cod]',
66
+ '*$py.class',
67
+ '.venv/',
68
+ 'venv/',
69
+ 'ENV/',
70
+ '.pytest_cache/',
71
+ '.mypy_cache/',
72
+ '*.egg-info/',
73
+ 'dist/',
74
+ 'build/'
75
+ ],
76
+ java: [
77
+ 'target/',
78
+ '.gradle/',
79
+ 'build/',
80
+ '*.class',
81
+ '*.jar',
82
+ '*.war'
83
+ ],
84
+ go: [
85
+ 'vendor/',
86
+ 'bin/',
87
+ '*.exe',
88
+ '*.exe~',
89
+ '*.dll',
90
+ '*.so',
91
+ '*.dylib'
92
+ ],
93
+ rust: [
94
+ 'target/',
95
+ 'Cargo.lock'
96
+ ],
97
+ dotnet: [
98
+ 'bin/',
99
+ 'obj/',
100
+ '*.nupkg',
101
+ '*.snupkg'
102
+ ],
103
+ php: [
104
+ 'vendor/',
105
+ 'composer.lock'
106
+ ],
107
+ dart: [
108
+ '.dart_tool/',
109
+ '.packages',
110
+ 'build/',
111
+ '.pub/',
112
+ 'pubspec.lock'
113
+ ],
114
+ common: [
115
+ '.env',
116
+ '.env.local',
117
+ '.env.*.local',
118
+ '.DS_Store',
119
+ 'Thumbs.db',
120
+ '*.swp',
121
+ '*.swo',
122
+ '*~',
123
+ '.idea/',
124
+ '.vscode/',
125
+ '*.iml'
126
+ ]
127
+ };
128
+ /**
129
+ * 根据项目类型检测需要的 gitignore 条目
130
+ */
131
+ async function detectProjectType(projectRoot) {
132
+ const types = [];
133
+ // 检查 package.json
134
+ try {
135
+ const packageJsonPath = path.join(projectRoot, 'package.json');
136
+ const content = await fs.readFile(packageJsonPath, 'utf-8');
137
+ const pkg = JSON.parse(content);
138
+ types.push('nodejs');
139
+ // 检查 TypeScript
140
+ if (pkg.devDependencies?.typescript || pkg.dependencies?.typescript) {
141
+ types.push('typescript');
142
+ }
143
+ }
144
+ catch {
145
+ // 不是 Node.js 项目
146
+ }
147
+ // 检查 Python
148
+ try {
149
+ await fs.access(path.join(projectRoot, 'pyproject.toml'));
150
+ types.push('python');
151
+ }
152
+ catch { }
153
+ try {
154
+ await fs.access(path.join(projectRoot, 'requirements.txt'));
155
+ if (!types.includes('python'))
156
+ types.push('python');
157
+ }
158
+ catch { }
159
+ // 检查 Java
160
+ try {
161
+ await fs.access(path.join(projectRoot, 'pom.xml'));
162
+ types.push('java');
163
+ }
164
+ catch { }
165
+ try {
166
+ await fs.access(path.join(projectRoot, 'build.gradle'));
167
+ if (!types.includes('java'))
168
+ types.push('java');
169
+ }
170
+ catch { }
171
+ // 检查 Go
172
+ try {
173
+ await fs.access(path.join(projectRoot, 'go.mod'));
174
+ types.push('go');
175
+ }
176
+ catch { }
177
+ // 检查 Rust
178
+ try {
179
+ await fs.access(path.join(projectRoot, 'Cargo.toml'));
180
+ types.push('rust');
181
+ }
182
+ catch { }
183
+ // 检查 .NET
184
+ try {
185
+ const files = await fs.readdir(projectRoot);
186
+ if (files.some(f => f.endsWith('.sln') || f.endsWith('.csproj'))) {
187
+ types.push('dotnet');
188
+ }
189
+ }
190
+ catch { }
191
+ // 检查 PHP
192
+ try {
193
+ await fs.access(path.join(projectRoot, 'composer.json'));
194
+ types.push('php');
195
+ }
196
+ catch { }
197
+ // 检查 Dart
198
+ try {
199
+ await fs.access(path.join(projectRoot, 'pubspec.yaml'));
200
+ types.push('dart');
201
+ }
202
+ catch { }
203
+ // 始终添加通用条目
204
+ types.push('common');
205
+ return types;
206
+ }
207
+ /**
208
+ * 获取所有需要的 gitignore 条目
209
+ */
210
+ function getRequiredEntries(projectTypes) {
211
+ const entries = new Set();
212
+ for (const type of projectTypes) {
213
+ const template = GITIGNORE_TEMPLATES[type];
214
+ if (template) {
215
+ for (const entry of template) {
216
+ entries.add(entry);
217
+ }
218
+ }
219
+ }
220
+ return entries;
221
+ }
222
+ /**
223
+ * 解析现有 gitignore 内容
224
+ */
225
+ function parseGitignore(content) {
226
+ const entries = new Set();
227
+ const lines = content.split('\n');
228
+ for (const line of lines) {
229
+ const trimmed = line.trim();
230
+ // 跳过注释和空行
231
+ if (trimmed && !trimmed.startsWith('#')) {
232
+ entries.add(trimmed);
233
+ }
234
+ }
235
+ return entries;
236
+ }
237
+ exports.checkGitignoreCommand = new commander_1.Command('check-gitignore')
238
+ .description('检查并自动补充 .gitignore 文件')
239
+ .option('--json', '输出 JSON 格式')
240
+ .option('--dry-run', '仅显示会添加的内容,不实际修改')
241
+ .action(async (options) => {
242
+ const projectRoot = process.cwd();
243
+ const gitignorePath = path.join(projectRoot, '.gitignore');
244
+ try {
245
+ // 检测项目类型
246
+ const projectTypes = await detectProjectType(projectRoot);
247
+ const requiredEntries = getRequiredEntries(projectTypes);
248
+ // 读取现有 gitignore
249
+ let existingEntries = new Set();
250
+ let exists = false;
251
+ try {
252
+ const content = await fs.readFile(gitignorePath, 'utf-8');
253
+ existingEntries = parseGitignore(content);
254
+ exists = true;
255
+ }
256
+ catch {
257
+ // 文件不存在
258
+ }
259
+ // 计算缺失的条目
260
+ const missingEntries = [];
261
+ for (const entry of requiredEntries) {
262
+ if (!existingEntries.has(entry)) {
263
+ missingEntries.push(entry);
264
+ }
265
+ }
266
+ // JSON 输出
267
+ if (options.json) {
268
+ console.log(JSON.stringify({
269
+ exists,
270
+ projectTypes,
271
+ missingEntries,
272
+ totalRequired: requiredEntries.size,
273
+ totalExisting: existingEntries.size
274
+ }, null, 2));
275
+ return;
276
+ }
277
+ // 没有缺失条目
278
+ if (missingEntries.length === 0) {
279
+ console.log(chalk_1.default.green('✅ .gitignore 已完善,无需修改\n'));
280
+ return;
281
+ }
282
+ // Dry run 模式
283
+ if (options.dryRun) {
284
+ console.log(chalk_1.default.cyan('🔍 检测到以下缺失条目:\n'));
285
+ for (const entry of missingEntries) {
286
+ console.log(chalk_1.default.gray(` + ${entry}`));
287
+ }
288
+ return;
289
+ }
290
+ // 自动补充
291
+ const newContent = generateGitignoreContent(missingEntries);
292
+ if (exists) {
293
+ // 追加到现有文件
294
+ await fs.appendFile(gitignorePath, `\n${newContent}`);
295
+ console.log(chalk_1.default.green(`✅ 已向 .gitignore 添加 ${missingEntries.length} 个条目:\n`));
296
+ }
297
+ else {
298
+ // 创建新文件
299
+ await fs.writeFile(gitignorePath, newContent);
300
+ console.log(chalk_1.default.green(`✅ 已创建 .gitignore,包含 ${missingEntries.length} 个条目:\n`));
301
+ }
302
+ for (const entry of missingEntries) {
303
+ console.log(chalk_1.default.gray(` + ${entry}`));
304
+ }
305
+ console.log();
306
+ }
307
+ catch (error) {
308
+ if (options.json) {
309
+ console.log(JSON.stringify({ error: String(error) }));
310
+ }
311
+ else {
312
+ console.error(chalk_1.default.red('❌ 检查失败:'), error);
313
+ }
314
+ process.exit(1);
315
+ }
316
+ });
317
+ /**
318
+ * 生成 gitignore 内容
319
+ */
320
+ function generateGitignoreContent(entries) {
321
+ const timestamp = new Date().toISOString().split('T')[0];
322
+ // 按类型分组
323
+ const groups = {
324
+ 'Dependencies': [],
325
+ 'Build': [],
326
+ 'Environment': [],
327
+ 'IDE': [],
328
+ 'OS': [],
329
+ 'Other': []
330
+ };
331
+ for (const entry of entries) {
332
+ if (entry.includes('node_modules') || entry.includes('vendor') || entry.includes('.venv')) {
333
+ groups['Dependencies'].push(entry);
334
+ }
335
+ else if (entry.includes('dist') || entry.includes('build') || entry.includes('target')) {
336
+ groups['Build'].push(entry);
337
+ }
338
+ else if (entry.includes('.env')) {
339
+ groups['Environment'].push(entry);
340
+ }
341
+ else if (entry.includes('.idea') || entry.includes('.vscode') || entry.includes('.iml')) {
342
+ groups['IDE'].push(entry);
343
+ }
344
+ else if (entry.includes('.DS_Store') || entry.includes('Thumbs.db')) {
345
+ groups['OS'].push(entry);
346
+ }
347
+ else {
348
+ groups['Other'].push(entry);
349
+ }
350
+ }
351
+ let content = `\n# Auto-generated by OpenMatrix (${timestamp})\n`;
352
+ for (const [group, items] of Object.entries(groups)) {
353
+ if (items.length > 0) {
354
+ content += `\n# ${group}\n`;
355
+ for (const item of items) {
356
+ content += `${item}\n`;
357
+ }
358
+ }
359
+ }
360
+ return content;
361
+ }
@@ -50,7 +50,7 @@ exports.checkCommand = new commander_1.Command('check')
50
50
  .option('--categories <items>', '指定检测类别 (逗号分隔)', 'bug,quality,capability,ux,style,security,common')
51
51
  .option('--min-priority <level>', '最小优先级 (critical|high|medium|low)', 'low')
52
52
  .option('--max <number>', '最大建议数量', '50')
53
- .option('--scan <dirs>', '扫描目录 (逗号分隔)', 'src,skills,tests,docs')
53
+ .option('--scan <dirs>', '扫描目录 (逗号分隔)', 'src,skills,docs')
54
54
  .option('--interactive', '交互式选择要执行的改进', false)
55
55
  .action(async (hint, options) => {
56
56
  const projectRoot = process.cwd();
package/dist/cli/index.js CHANGED
@@ -12,6 +12,7 @@ const meeting_js_1 = require("./commands/meeting.js");
12
12
  const auto_js_1 = require("./commands/auto.js");
13
13
  const install_skills_js_1 = require("./commands/install-skills.js");
14
14
  const check_js_1 = require("./commands/check.js");
15
+ const check_gitignore_js_1 = require("./commands/check-gitignore.js");
15
16
  const analyze_js_1 = require("./commands/analyze.js");
16
17
  const program = new commander_1.Command();
17
18
  program
@@ -29,6 +30,7 @@ program.addCommand(meeting_js_1.meetingCommand);
29
30
  program.addCommand(auto_js_1.autoCommand);
30
31
  program.addCommand(install_skills_js_1.installSkillsCommand);
31
32
  program.addCommand(check_js_1.checkCommand);
33
+ program.addCommand(check_gitignore_js_1.checkGitignoreCommand);
32
34
  program.addCommand(analyze_js_1.analyzeCommand);
33
35
  // 默认帮助
34
36
  program.parse();
@@ -41,8 +41,8 @@ const path = __importStar(require("path"));
41
41
  * 默认配置
42
42
  */
43
43
  exports.DEFAULT_DETECTOR_CONFIG = {
44
- scanDirs: ['src', 'skills', 'tests', 'docs', 'prompts', '.claude', '.cursor'],
45
- excludeDirs: ['node_modules', 'dist', '.git', '.openmatrix'],
44
+ scanDirs: ['src', 'skills', 'docs', 'prompts', '.claude', '.cursor'],
45
+ excludeDirs: ['node_modules', 'dist', '.git', '.openmatrix', 'tests'],
46
46
  categories: ['bug', 'quality', 'capability', 'ux', 'style', 'security', 'common', 'prompt', 'skill', 'agent'],
47
47
  minPriority: 'low'
48
48
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openmatrix",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "description": "AI Agent task orchestration system with Claude Code Skills integration",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/skills/check.md CHANGED
@@ -106,9 +106,7 @@ description: 自动检测项目可改进点并提供升级建议,用户确认
106
106
 
107
107
  ---
108
108
 
109
- ## ✅ 下一步
110
-
111
- 回复 **"继续"**、**"可以"**、**"执行"** 或 **"好"** 开始自动修复这些问题。
109
+ **是否继续?**
112
110
  ```
113
111
 
114
112
  如果没有发现问题:
@@ -118,19 +116,7 @@ description: 自动检测项目可改进点并提供升级建议,用户确认
118
116
 
119
117
  4. **等待用户确认**
120
118
 
121
- 展示报告后,等待用户回复。检测用户回复中的确认词语:
122
-
123
- **确认词语列表**:
124
- - 继续、可以、执行、好、是、ok、OK、确认、同意
125
- - continue、yes、ok、sure、go、do it
126
- - 中文变体:行、好的、没问题、没问题啊、走起、开始吧
127
-
128
- **取消词语列表** (用户不想执行):
129
- - 不、不要、取消、算了、跳过
130
- - no、skip、cancel
131
-
132
- 如果用户回复包含确认词语,立即执行下一步。
133
- 如果用户回复包含取消词语,结束流程。
119
+ 展示报告后,等待用户回复。用户回复确认词语(如"是"、"继续"、"好"、"可以"等)即执行下一步。
134
120
 
135
121
  5. **调用 /om:start 执行改进**
136
122
 
@@ -165,8 +151,8 @@ $ARGUMENTS
165
151
  </arguments>
166
152
 
167
153
  <examples>
168
- /check # 自动扫描 → 展示报告 → 用户回复"继续" → 自动执行
169
- /check 安全 # 聚焦安全问题 → 展示报告 → 用户回复"可以" → 自动修复
154
+ /check # 自动扫描 → 展示报告 → 用户回复"" → 自动执行
155
+ /check 安全 # 聚焦安全问题 → 展示报告 → 用户回复"继续" → 自动修复
170
156
  </examples>
171
157
 
172
158
  <notes>
@@ -180,7 +166,7 @@ $ARGUMENTS
180
166
  ├── 2. 展示报告 ──→ 输出 Markdown 格式的检测报告
181
167
  │ (不使用交互式对话框,让用户能看到完整文档)
182
168
 
183
- ├── 3. 等待确认 ──→ 用户回复 "继续" 或 "可以"
169
+ ├── 3. 等待确认 ──→ 用户回复 "" 或 "继续"
184
170
 
185
171
  └── 4. 自动执行 ──→ 调用 /om:start
186
172
 
@@ -210,27 +196,5 @@ $ARGUMENTS
210
196
  1. 完整查看所有检测到的问题
211
197
  2. 仔细阅读每个问题的描述和建议
212
198
  3. 自由决定是否执行修复
213
- 4. 简单回复"继续"即可开始执行
214
-
215
- ## 确认词语检测
216
-
217
- 检测用户回复中是否包含以下词语(不区分大小写):
218
-
219
- | 中文确认 | 英文确认 |
220
- |---------|---------|
221
- | 继续 | continue |
222
- | 可以 | yes / ok / sure |
223
- | 执行 | go / do it |
224
- | 好 / 是 | |
225
- | 确认 / 同意 | |
226
- | 行 / 好的 | |
227
- | 没问题 | |
228
- | 走起 / 开始吧 | |
229
-
230
- 用户回复示例:
231
- - "继续" → 执行
232
- - "可以,开始吧" → 执行
233
- - "好" → 执行
234
- - "先不要" → 不执行
235
- - "跳过" → 不执行
199
+ 4. 简单回复确认即可开始执行
236
200
  </notes>
package/skills/start.md CHANGED
@@ -34,7 +34,40 @@ description: 启动新的任务执行周期
34
34
  - 检查是否有远程仓库配置:
35
35
  - 如果没有远程仓库,提示用户添加: `git remote add origin <url>`
36
36
 
37
- 4. **解析任务输入**
37
+ 4. **智能检测 .gitignore**
38
+
39
+ 检查 `.gitignore` 文件是否存在并完善:
40
+ ```bash
41
+ openmatrix check-gitignore --json
42
+ ```
43
+
44
+ 返回结果:
45
+ ```json
46
+ {
47
+ "exists": true,
48
+ "missingEntries": ["node_modules", "dist", ".env"],
49
+ "suggestedContent": "# Node.js\nnode_modules/\ndist/\n\n# Environment\n.env\n.env.local"
50
+ }
51
+ ```
52
+
53
+ **如果缺少常见忽略项**:
54
+ - 自动补充缺失的条目到 `.gitignore`
55
+ - 不询问用户,静默完成
56
+
57
+ **常见忽略项清单** (按项目类型):
58
+
59
+ | 类型 | 忽略项 |
60
+ |------|--------|
61
+ | Node.js | `node_modules/`, `dist/`, `build/`, `.npm/`, `*.log` |
62
+ | TypeScript | `*.tsbuildinfo`, `.tsbuildinfo` |
63
+ | Python | `__pycache__/`, `*.pyc`, `.venv/`, `venv/`, `.pytest_cache/` |
64
+ | Java | `target/`, `.gradle/`, `build/`, `*.class` |
65
+ | Go | `vendor/`, `bin/`, `*.exe` |
66
+ | Rust | `target/`, `Cargo.lock` (库项目) |
67
+ | 通用 | `.env`, `.env.local`, `.DS_Store`, `Thumbs.db`, `*.swp` |
68
+ | IDE | `.idea/`, `.vscode/`, `*.iml` |
69
+
70
+ 5. **解析任务输入**
38
71
  - 如果 `$ARGUMENTS` 提供文件路径 → 读取文件内容
39
72
  - 如果 `$ARGUMENTS` 是任务描述 → 直接使用
40
73
  - 如果无参数 → **使用 AskUserQuestion 询问用户要执行的任务**