@localsummer/incspec 0.0.5 → 0.0.7

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.
@@ -1,116 +0,0 @@
1
- /**
2
- * cursor-sync command - Sync Cursor slash commands
3
- */
4
-
5
- import * as path from 'path';
6
- import {
7
- findProjectRoot,
8
- INCSPEC_DIR,
9
- } from '../lib/config.mjs';
10
- import {
11
- syncToProject,
12
- syncToGlobal,
13
- checkCursorCommands,
14
- } from '../lib/cursor.mjs';
15
- import {
16
- colors,
17
- colorize,
18
- print,
19
- printSuccess,
20
- printWarning,
21
- printInfo,
22
- confirm,
23
- select,
24
- } from '../lib/terminal.mjs';
25
-
26
- /**
27
- * Execute cursor-sync command
28
- * @param {Object} ctx - Command context
29
- */
30
- export async function cursorSyncCommand(ctx) {
31
- const { cwd, options } = ctx;
32
-
33
- print('');
34
- print(colorize(' incspec Cursor 命令同步', colors.bold, colors.cyan));
35
- print(colorize(' ──────────────────────', colors.dim));
36
- print('');
37
-
38
- // Determine sync target
39
- let syncTarget = null;
40
-
41
- if (options.project) {
42
- syncTarget = 'project';
43
- } else if (options.global) {
44
- syncTarget = 'global';
45
- } else {
46
- // Interactive selection
47
- const projectRoot = findProjectRoot(cwd);
48
-
49
- const choices = [
50
- {
51
- name: '项目目录 (.cursor/commands/incspec/)',
52
- value: 'project',
53
- description: '仅对当前项目生效',
54
- },
55
- {
56
- name: '全局目录 (~/.cursor/commands/incspec/)',
57
- value: 'global',
58
- description: '对所有项目生效',
59
- },
60
- ];
61
-
62
- if (!projectRoot) {
63
- // No project found, only allow global
64
- printWarning('未检测到 incspec 项目,将同步到全局目录。');
65
- syncTarget = 'global';
66
- } else {
67
- syncTarget = await select({
68
- message: '选择同步目标:',
69
- choices,
70
- });
71
- }
72
- }
73
-
74
- // Execute sync
75
- if (syncTarget === 'project') {
76
- const projectRoot = findProjectRoot(cwd);
77
-
78
- if (!projectRoot) {
79
- printWarning('未检测到 incspec 项目。请先运行 incspec init 或使用 --global 选项。');
80
- return;
81
- }
82
-
83
- print(colorize(`同步到项目: ${projectRoot}`, colors.dim));
84
- print('');
85
-
86
- const count = syncToProject(projectRoot);
87
-
88
- printSuccess(`已同步 ${count} 个 Cursor 命令到 .cursor/commands/incspec/`);
89
- print('');
90
- print(colorize('已创建的命令:', colors.bold));
91
- print(colorize(' /incspec/inc-analyze 步骤1: 分析代码流程', colors.dim));
92
- print(colorize(' /incspec/inc-collect-req 步骤2: 收集结构化需求', colors.dim));
93
- print(colorize(' /incspec/inc-collect-dep 步骤3: UI依赖采集', colors.dim));
94
- print(colorize(' /incspec/inc-design 步骤4: 增量设计', colors.dim));
95
- print(colorize(' /incspec/inc-apply 步骤5: 应用代码变更', colors.dim));
96
- print(colorize(' /incspec/inc-merge 步骤6: 合并到基线', colors.dim));
97
- print(colorize(' /incspec/inc-archive 归档规范文件', colors.dim));
98
- print(colorize(' /incspec/inc-status 查看工作流状态', colors.dim));
99
- print(colorize(' /incspec/inc-help 显示帮助', colors.dim));
100
-
101
- } else if (syncTarget === 'global') {
102
- print(colorize('同步到全局目录...', colors.dim));
103
- print('');
104
-
105
- const count = syncToGlobal();
106
-
107
- printSuccess(`已同步 ${count} 个 Cursor 命令到 ~/.cursor/commands/incspec/`);
108
- print('');
109
- print(colorize('全局命令将对所有项目生效。', colors.dim));
110
- print(colorize('在项目中运行 incspec cursor-sync --project 可覆盖全局命令。', colors.dim));
111
- }
112
-
113
- print('');
114
- printInfo('请重启 Cursor 以加载新命令。');
115
- print('');
116
- }