@zhuan-ai/zhuanspec 2.17.5 → 2.17.6

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.
@@ -44,6 +44,7 @@ export declare class InitCommand {
44
44
  */
45
45
  private executeDomainSync;
46
46
  private generateDomainProjectMdPlaceholder;
47
+ private syncBusinessDirectionAssets;
47
48
  private validate;
48
49
  private getConfiguration;
49
50
  private getSelectedTools;
package/dist/core/init.js CHANGED
@@ -311,66 +311,14 @@ export class InitCommand {
311
311
  // Step 2: Select business direction and sync Claude assets BEFORE configureAITools
312
312
  // This ensures .claude directory is not deleted after slash commands are generated
313
313
  if (this.domain) {
314
- // Domain mode: skip business direction prompt, sync from specs/<domain>/zhuanspec/
314
+ // Domain mode: use domain as business direction first, then let
315
+ // specs/<domain>/zhuanspec/ override same-path template files.
315
316
  await this.executeDomainSync(projectPath, zhuanspecPath);
316
317
  }
317
318
  else {
318
319
  await this.promptForBusinessDirection();
319
320
  if (this.businessDirection) {
320
- const directionMetaPath = path.join(zhuanspecPath, '.business-direction');
321
- await FileSystemUtils.writeFile(directionMetaPath, `${this.businessDirection.toLowerCase()}\n`);
322
- const archSpinner = this.startSpinner(`正在获取 ${this.businessDirection} 业务架构文档...`);
323
- const architectureContent = await this.fetchArchitectureFile();
324
- if (architectureContent) {
325
- const projectMdPath = path.join(zhuanspecPath, 'project.md');
326
- const projectMdExists = await FileSystemUtils.fileExists(projectMdPath);
327
- await FileSystemUtils.writeFile(projectMdPath, architectureContent);
328
- archSpinner.stopAndPersist({
329
- symbol: PALETTE.white('▌'),
330
- text: PALETTE.white(projectMdExists
331
- ? `已使用 ${this.businessDirection} 业务架构文档覆盖 project.md`
332
- : `已应用 ${this.businessDirection} 业务架构文档到 project.md`),
333
- });
334
- }
335
- else {
336
- archSpinner.stopAndPersist({
337
- symbol: PALETTE.midGray('▌'),
338
- text: PALETTE.midGray(`未找到 ${this.businessDirection} 业务架构文档,使用默认模板`),
339
- });
340
- }
341
- const specTemplateSpinner = this.startSpinner(`正在同步 ${this.businessDirection} 业务规范模板...`);
342
- const syncResult = this.syncBusinessSpecTemplate(zhuanspecPath);
343
- if (syncResult.syncedSpecs || syncResult.syncedChanges || syncResult.syncedKnowledge) {
344
- const syncedParts = [];
345
- if (syncResult.syncedSpecs) {
346
- syncedParts.push('specs');
347
- }
348
- if (syncResult.syncedChanges) {
349
- syncedParts.push('changes');
350
- }
351
- if (syncResult.syncedKnowledge) {
352
- syncedParts.push('knowledge');
353
- }
354
- specTemplateSpinner.stopAndPersist({
355
- symbol: PALETTE.white('▌'),
356
- text: PALETTE.white(`已从远端模板同步 ${syncedParts.join('、')} 目录`),
357
- });
358
- }
359
- else {
360
- specTemplateSpinner.stopAndPersist({
361
- symbol: PALETTE.midGray('▌'),
362
- text: PALETTE.midGray(`未找到 ${this.businessDirection} 业务规范模板目录,保留默认模板`),
363
- });
364
- }
365
- // Sync Claude assets BEFORE configureAITools to avoid deletion
366
- const claudeAssetSpinner = this.startSpinner(`正在同步 ${this.businessDirection} 业务 Claude 规范资产...`);
367
- const claudeAssetResult = this.syncBusinessClaudeAssets(projectPath);
368
- const claudeMdText = this.describeClaudeAssetResult('CLAUDE.md', claudeAssetResult.claudeMd);
369
- const dotClaudeText = this.describeClaudeAssetResult('.claude', claudeAssetResult.dotClaude);
370
- claudeAssetSpinner.stopAndPersist({
371
- symbol: PALETTE.white('▌'),
372
- text: PALETTE.white(`Claude 规范资产同步完成:${claudeMdText};${dotClaudeText}`),
373
- });
321
+ await this.syncBusinessDirectionAssets(projectPath, zhuanspecPath);
374
322
  }
375
323
  } // end domain else
376
324
  // Step 3: Configure AI tools (after Claude assets sync to preserve generated files)
@@ -391,9 +339,11 @@ export class InitCommand {
391
339
  */
392
340
  async executeDomainSync(projectPath, zhuanspecPath) {
393
341
  const domain = this.domain;
342
+ this.businessDirection = domain;
394
343
  // Save domain code to .domain meta file (used by archive for push routing)
395
344
  const domainMetaPath = path.join(zhuanspecPath, '.domain');
396
345
  await FileSystemUtils.writeFile(domainMetaPath, `${domain}\n`);
346
+ await this.syncBusinessDirectionAssets(projectPath, zhuanspecPath);
397
347
  const syncSpinner = this.startSpinner(`正在从远端同步 ${domain} 主领域模板(specs/${domain}/zhuanspec/)...`);
398
348
  const tempDir = this.cloneRemoteArchitectureRepoToTemp();
399
349
  if (!tempDir) {
@@ -430,15 +380,6 @@ export class InitCommand {
430
380
  if (!(await FileSystemUtils.fileExists(projectMdPath))) {
431
381
  await this.generateDomainProjectMdPlaceholder(projectMdPath, domain);
432
382
  }
433
- // Sync Claude assets from common
434
- const claudeAssetSpinner = this.startSpinner('正在同步 Claude 规范资产(common)...');
435
- const claudeAssetResult = this.syncBusinessClaudeAssets(projectPath);
436
- const claudeMdText = this.describeClaudeAssetResult('CLAUDE.md', claudeAssetResult.claudeMd);
437
- const dotClaudeText = this.describeClaudeAssetResult('.claude', claudeAssetResult.dotClaude);
438
- claudeAssetSpinner.stopAndPersist({
439
- symbol: PALETTE.white('▌'),
440
- text: PALETTE.white(`Claude 规范资产同步完成:${claudeMdText};${dotClaudeText}`),
441
- });
442
383
  // Remind user to run spec-service-architecture skill to generate project.md
443
384
  console.log();
444
385
  console.log(PALETTE.white('domain 模式提示'));
@@ -455,6 +396,65 @@ export class InitCommand {
455
396
  `;
456
397
  await FileSystemUtils.writeFile(projectMdPath, placeholder);
457
398
  }
399
+ async syncBusinessDirectionAssets(projectPath, zhuanspecPath) {
400
+ if (!this.businessDirection) {
401
+ return;
402
+ }
403
+ const directionMetaPath = path.join(zhuanspecPath, '.business-direction');
404
+ await FileSystemUtils.writeFile(directionMetaPath, `${this.businessDirection.toLowerCase()}\n`);
405
+ const archSpinner = this.startSpinner(`正在获取 ${this.businessDirection} 业务架构文档...`);
406
+ const architectureContent = await this.fetchArchitectureFile();
407
+ if (architectureContent) {
408
+ const projectMdPath = path.join(zhuanspecPath, 'project.md');
409
+ const projectMdExists = await FileSystemUtils.fileExists(projectMdPath);
410
+ await FileSystemUtils.writeFile(projectMdPath, architectureContent);
411
+ archSpinner.stopAndPersist({
412
+ symbol: PALETTE.white('▌'),
413
+ text: PALETTE.white(projectMdExists
414
+ ? `已使用 ${this.businessDirection} 业务架构文档覆盖 project.md`
415
+ : `已应用 ${this.businessDirection} 业务架构文档到 project.md`),
416
+ });
417
+ }
418
+ else {
419
+ archSpinner.stopAndPersist({
420
+ symbol: PALETTE.midGray('▌'),
421
+ text: PALETTE.midGray(`未找到 ${this.businessDirection} 业务架构文档,使用默认模板`),
422
+ });
423
+ }
424
+ const specTemplateSpinner = this.startSpinner(`正在同步 ${this.businessDirection} 业务规范模板...`);
425
+ const syncResult = this.syncBusinessSpecTemplate(zhuanspecPath);
426
+ if (syncResult.syncedSpecs || syncResult.syncedChanges || syncResult.syncedKnowledge) {
427
+ const syncedParts = [];
428
+ if (syncResult.syncedSpecs) {
429
+ syncedParts.push('specs');
430
+ }
431
+ if (syncResult.syncedChanges) {
432
+ syncedParts.push('changes');
433
+ }
434
+ if (syncResult.syncedKnowledge) {
435
+ syncedParts.push('knowledge');
436
+ }
437
+ specTemplateSpinner.stopAndPersist({
438
+ symbol: PALETTE.white('▌'),
439
+ text: PALETTE.white(`已从远端模板同步 ${syncedParts.join('、')} 目录`),
440
+ });
441
+ }
442
+ else {
443
+ specTemplateSpinner.stopAndPersist({
444
+ symbol: PALETTE.midGray('▌'),
445
+ text: PALETTE.midGray(`未找到 ${this.businessDirection} 业务规范模板目录,保留默认模板`),
446
+ });
447
+ }
448
+ // Sync Claude assets BEFORE configureAITools to avoid deletion
449
+ const claudeAssetSpinner = this.startSpinner(`正在同步 ${this.businessDirection} 业务 Claude 规范资产...`);
450
+ const claudeAssetResult = this.syncBusinessClaudeAssets(projectPath);
451
+ const claudeMdText = this.describeClaudeAssetResult('CLAUDE.md', claudeAssetResult.claudeMd);
452
+ const dotClaudeText = this.describeClaudeAssetResult('.claude', claudeAssetResult.dotClaude);
453
+ claudeAssetSpinner.stopAndPersist({
454
+ symbol: PALETTE.white('▌'),
455
+ text: PALETTE.white(`Claude 规范资产同步完成:${claudeMdText};${dotClaudeText}`),
456
+ });
457
+ }
458
458
  async validate(projectPath, _zhuanspecPath) {
459
459
  const extendMode = await FileSystemUtils.directoryExists(_zhuanspecPath);
460
460
  // Check write permissions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhuan-ai/zhuanspec",
3
- "version": "2.17.5",
3
+ "version": "2.17.6",
4
4
  "description": "AI-native system for spec-driven development",
5
5
  "keywords": [
6
6
  "zhuanspec",