@deepstorm/cli 0.3.3 → 0.4.1

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/dist/cli.js CHANGED
@@ -8307,6 +8307,19 @@ function skillIdsToTools(skillIds, registry2) {
8307
8307
  }
8308
8308
  return [...toolSet];
8309
8309
  }
8310
+ function detectToolsFromConfig(config, registry2) {
8311
+ const knownTools = new Set(Object.keys(registry2.tools ?? {}));
8312
+ const found = /* @__PURE__ */ new Set();
8313
+ for (const key of Object.keys(config)) {
8314
+ const dotIdx = key.indexOf(".");
8315
+ if (dotIdx < 0) continue;
8316
+ const prefix = key.slice(0, dotIdx);
8317
+ if (knownTools.has(prefix)) {
8318
+ found.add(prefix);
8319
+ }
8320
+ }
8321
+ return [...found];
8322
+ }
8310
8323
  function readSettingsConfig(targetDir) {
8311
8324
  const settingsPath = path18.join(targetDir, ".claude", "settings.json");
8312
8325
  try {
@@ -8367,16 +8380,18 @@ function syncToolAssets(cliDir2, targetDir, installedSkillIds) {
8367
8380
  }
8368
8381
  const reader = new RegistryReader(registry2);
8369
8382
  const toolNames = skillIdsToTools(installedSkillIds, registry2);
8370
- if (toolNames.length === 0) {
8371
- console.log("\u26A0 \u65E0\u6CD5\u4ECE\u5DF2\u5B89\u88C5 skill \u89E3\u6790\u5DE5\u5177\u540D\u79F0\uFF0C\u8DF3\u8FC7\u8D44\u4EA7\u540C\u6B65");
8383
+ const { config, installedMcpTools } = readSettingsConfig(targetDir);
8384
+ const configTools = detectToolsFromConfig(config, registry2);
8385
+ const allTools = [.../* @__PURE__ */ new Set([...toolNames, ...configTools])];
8386
+ if (allTools.length === 0) {
8387
+ console.log("\u26A0 \u65E0\u6CD5\u4ECE\u5DF2\u5B89\u88C5 skill \u6216\u914D\u7F6E\u89E3\u6790\u5DE5\u5177\u540D\u79F0\uFF0C\u8DF3\u8FC7\u8D44\u4EA7\u540C\u6B65");
8372
8388
  return { syncedSkills: [], syncedAgents: [], syncedHooks: [], backedUpFiles: [] };
8373
8389
  }
8374
- const { config, installedMcpTools } = readSettingsConfig(targetDir);
8375
8390
  const templateVariables = buildTemplateVariables(registry2, config, installedMcpTools);
8376
8391
  const mcpSkillSet = /* @__PURE__ */ new Set();
8377
8392
  if (installedMcpTools.length > 0) {
8378
8393
  const selectedMcpSet = new Set(installedMcpTools);
8379
- for (const tool of toolNames) {
8394
+ for (const tool of allTools) {
8380
8395
  for (const skillId of reader.getToolMcpSkills(tool)) {
8381
8396
  const service = skillId.replace(/^deepstorm-mcp-/, "").replace(/-(read|write)$/, "");
8382
8397
  if (selectedMcpSet.has(service)) mcpSkillSet.add(skillId);
@@ -8385,7 +8400,7 @@ function syncToolAssets(cliDir2, targetDir, installedSkillIds) {
8385
8400
  }
8386
8401
  const mcpSkillIds = [...mcpSkillSet];
8387
8402
  const allSkillIdsForBackup = [.../* @__PURE__ */ new Set([...installedSkillIds, ...mcpSkillIds])];
8388
- const backedUpFiles = backupModifiedAssets(targetDir, allSkillIdsForBackup, toolNames, registry2);
8403
+ const backedUpFiles = backupModifiedAssets(targetDir, allSkillIdsForBackup, allTools, registry2);
8389
8404
  if (backedUpFiles.length > 0) {
8390
8405
  console.log("\n\u26A0 \u68C0\u6D4B\u5230\u7528\u6237\u4FEE\u6539\u7684\u6587\u4EF6\uFF1A");
8391
8406
  for (const info of backedUpFiles) {
@@ -8397,7 +8412,7 @@ function syncToolAssets(cliDir2, targetDir, installedSkillIds) {
8397
8412
  const syncedAgents = [];
8398
8413
  const syncedHooks = [];
8399
8414
  let hasWarning = false;
8400
- for (const tool of toolNames) {
8415
+ for (const tool of allTools) {
8401
8416
  try {
8402
8417
  reader.getToolEntry(tool);
8403
8418
  } catch {
@@ -8428,11 +8443,11 @@ function syncToolAssets(cliDir2, targetDir, installedSkillIds) {
8428
8443
  const syncedSkills = actualSkillIds.length > 0 ? actualSkillIds : [...installedSkillIds];
8429
8444
  const syncedMcpSkillIds = [];
8430
8445
  if (installedMcpTools.length > 0) {
8431
- installMcpSkills(toolNames, reader, cliDir2, targetDir, syncedMcpSkillIds, installedMcpTools);
8446
+ installMcpSkills(allTools, reader, cliDir2, targetDir, syncedMcpSkillIds, installedMcpTools);
8432
8447
  }
8433
- mergeToolHooksJson(toolNames, cliDir2, targetDir);
8448
+ mergeToolHooksJson(allTools, cliDir2, targetDir);
8434
8449
  const allSkillIds = [...installedSkillIds, ...syncedMcpSkillIds];
8435
- storeNewChecksums(targetDir, allSkillIds, toolNames, registry2);
8450
+ storeNewChecksums(targetDir, allSkillIds, allTools, registry2);
8436
8451
  if (hasWarning) {
8437
8452
  console.log("\n\u26A0 \u90E8\u5206\u5DE5\u5177\u540C\u6B65\u51FA\u9519\uFF0C\u8BF7\u68C0\u67E5\u540E\u91CD\u8BD5");
8438
8453
  }
@@ -159,6 +159,38 @@ git status --short
159
159
  - 测试全部通过 → 继续
160
160
  - 任一测试失败 → 提示用户修复后再提交
161
161
 
162
+ ### 6.5 OpenSpec 验证与归档检查
163
+
164
+ > 提交前检查关联的 OpenSpec change 是否已完成验证和归档。如果 `openspec/` 目录不存在或无活跃 change 则跳过本步骤。
165
+
166
+ **判断流程(LLM 自行推理执行):**
167
+
168
+ 1. **查找关联的 OpenSpec change:**
169
+ ```bash
170
+ BRANCH=$(git branch --show-current)
171
+ echo "当前分支: $BRANCH"
172
+
173
+ for dir in openspec/changes/*/; do
174
+ CHANGE_NAME=$(basename "$dir")
175
+ if [ -f "$dir/.openspec.yaml" ] && [ "$CHANGE_NAME" != "archive" ]; then
176
+ echo "发现活跃 OpenSpec change: $CHANGE_NAME"
177
+ cat "$dir/.openspec.yaml"
178
+ fi
179
+ done
180
+ ```
181
+
182
+ 2. **匹配规则:** 扫描 `openspec/changes/*/` 下活跃 change(不包含 `archive/`),与当前分支名比对;无匹配则跳过;多匹配则让用户选择。
183
+
184
+ 3. **检查归档状态:** 读取 `.openspec.yaml` 中 `status` 字段。`archived` → 跳过后续检查;否则继续。
185
+
186
+ 4. **运行验证:** 确认 `tasks.md` 全部 checkbox 已完成 → 通过 Skill 工具自动调用 `/opsx:verify`。有 CRITICAL 问题则中止;仅 WARNING/SUGGESTION 则通过。
187
+
188
+ 5. **运行归档:** 验证通过后 → 通过 Skill 工具自动调用 `/opsx:archive`。执行失败则提示用户手动处理。
189
+
190
+ 6. **确认已就绪:** 校验状态并向用户报告。
191
+
192
+ > **提示:** verify/archive 执行后产生额外文件变更的,后续步骤会重新检测并纳入提交。
193
+
162
194
  ### 7. 收集上下文
163
195
 
164
196
  ```bash
@@ -200,6 +200,6 @@ TypeScript union type + `type` literal 可直接利用 `@switch` 的类型窄化
200
200
  | `@JsonProperty("xAxisName") private String categoryAxisLabel` | 字段名合规,getter 合规,JSON 输出保留 `xAxisName` | ✅ |
201
201
  | 禁用 Checkstyle `ParameterNameCheck` | 全局禁用降低代码规范性 | ❌ |
202
202
 
203
- ### 5.6 Decoder 对象保持 record
203
+ ### 5.6 DTO 对象保持 record
204
204
 
205
205
  如 `MetricAnswer` 是 Java record,不能继承。改造方案为直接替换字段类型(`ChartType chartType` → `ChartView chartView`),record 紧凑语法不受影响。构建逻辑从 `determineChartType()` 改为 `buildChartView()` 并返回具体子类。
@@ -33,6 +33,9 @@
33
33
  - 局部变量优先用 `var`,避免冗余的类型声明
34
34
  - 字符串格式化用 `formatted()` / Text Block,不用 `+` 拼接
35
35
  - 用多态 / Abstract Method 替代 `instanceof` 链做类型分发
36
+ - 所有控制流语句(`if`/`else`/`for`/`while`/`do`)必须使用大括号 `{}`,禁止省略大括号的单行体(对应 Checkstyle `NeedBraces` 规则)
37
+ - 不声明未被使用的局部变量;switch 模式匹配中未被使用的模式变量用 `_`(匿名模式变量)替代命名变量(如 `case UserMessage _ ->`)
38
+ - 局部变量声明必须靠近首次使用处(相距 ≤ 3 行);从方法调用返回值赋值的局部变量用 `final var` 修饰(如 `final var axisDimList = buildAxisDimMapping(...)`),禁止在调用前提前声明可变变量
36
39
 
37
40
  ### Lombok 使用规范
38
41
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepstorm/cli",
3
- "version": "0.3.3",
3
+ "version": "0.4.1",
4
4
  "description": "DeepStorm CLI — 一键配置项目开发环境",
5
5
  "license": "MIT",
6
6
  "author": "billkang",