6aspec 2.0.0-dev.2 → 2.0.0-dev.20
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/.6aspec/rules/brown/brown_archive_sop.md +8 -8
- package/.6aspec/rules/brown/brown_constitution.md +11 -0
- package/.6aspec/rules/brown/brown_continue_sop.md +5 -2
- package/.6aspec/rules/brown/brown_design_sop.md +168 -28
- package/.6aspec/rules/brown/brown_explore_sop.md +314 -0
- package/.6aspec/rules/brown/brown_ff_sop.md +31 -18
- package/.6aspec/rules/brown/brown_impact_sop.md +105 -36
- package/.6aspec/rules/brown/brown_implement_sop.md +3 -3
- package/.6aspec/rules/brown/brown_list_sop.md +12 -12
- package/.6aspec/rules/brown/brown_new_sop.md +58 -34
- package/.6aspec/rules/brown/brown_proposal_sop.md +293 -75
- package/.6aspec/rules/brown/brown_quick_sop.md +5 -5
- package/.6aspec/rules/brown/brown_review_sop.md +4 -4
- package/.6aspec/rules/brown/brown_rollback_sop.md +29 -19
- package/.6aspec/rules/brown/brown_specs_sop.md +370 -120
- package/.6aspec/rules/brown/brown_status_sop.md +13 -3
- package/.6aspec/rules/brown/brown_tasks_sop.md +18 -5
- package/.6aspec/rules/brown/brown_understand_sop.md +111 -40
- package/.6aspec/rules/brown/brown_verify_sop.md +1 -1
- package/.6aspec/rules/green/{6A_archive_sop.md → green_archive_sop.md} +3 -3
- package/.6aspec/rules/green/{6A_clarify_sop.md → green_clarify_sop.md} +1 -1
- package/.6aspec/rules/green/{6A_code_implementation_sop.md → green_code_implementation_sop.md} +3 -3
- package/.6aspec/rules/green/{6A_continue_sop.md → green_continue_sop.md} +3 -3
- package/.6aspec/rules/green/green_status_schema.md +4 -4
- package/.6aspec/rules/green/{6A_status_sop.md → green_status_sop.md} +3 -3
- package/.6aspec/rules/green/{6A_tasks_sop.md → green_tasks_sop.md} +1 -1
- package/.claude/commands/6aspec/brown/explore.md +11 -0
- package/.claude/commands/6aspec/green/archive.md +1 -1
- package/.claude/commands/6aspec/green/clarify.md +2 -2
- package/.claude/commands/6aspec/green/continue.md +1 -1
- package/.claude/commands/6aspec/green/design.md +2 -2
- package/.claude/commands/6aspec/green/{execute-task.md → implement.md} +1 -1
- package/.claude/commands/6aspec/green/import-model-table.md +1 -1
- package/.claude/commands/6aspec/green/init.md +2 -2
- package/.claude/commands/6aspec/green/model.md +2 -2
- package/.claude/commands/6aspec/green/new.md +2 -2
- package/.claude/commands/6aspec/green/rollback.md +1 -1
- package/.claude/commands/6aspec/green/status.md +1 -1
- package/.claude/commands/6aspec/green/tasks.md +2 -2
- package/.claude/commands/6aspec/green/visual-logic.md +2 -2
- package/.claude/commands/opsx/apply.md +152 -0
- package/.claude/commands/opsx/archive.md +157 -0
- package/.claude/commands/opsx/bulk-archive.md +242 -0
- package/.claude/commands/opsx/continue.md +114 -0
- package/.claude/commands/opsx/explore.md +174 -0
- package/.claude/commands/opsx/ff.md +94 -0
- package/.claude/commands/opsx/new.md +69 -0
- package/.claude/commands/opsx/onboard.md +525 -0
- package/.claude/commands/opsx/sync.md +134 -0
- package/.claude/commands/opsx/verify.md +164 -0
- package/.claude/settings.local.json +21 -1
- package/.cursor/commands/6aspec/brown/explore.md +11 -0
- package/.cursor/commands/6aspec/green/archive.md +1 -1
- package/.cursor/commands/6aspec/green/clarify.md +2 -2
- package/.cursor/commands/6aspec/green/continue.md +1 -1
- package/.cursor/commands/6aspec/green/design.md +2 -2
- package/.cursor/commands/6aspec/green/{execute-task.md → implement.md} +1 -1
- package/.cursor/commands/6aspec/green/import-model-table.md +1 -1
- package/.cursor/commands/6aspec/green/init.md +2 -2
- package/.cursor/commands/6aspec/green/model.md +2 -2
- package/.cursor/commands/6aspec/green/new.md +2 -2
- package/.cursor/commands/6aspec/green/rollback.md +1 -1
- package/.cursor/commands/6aspec/green/status.md +1 -1
- package/.cursor/commands/6aspec/green/tasks.md +2 -2
- package/.cursor/commands/6aspec/green/visual-logic.md +2 -2
- package/.cursor/commands/opsx-apply.md +152 -0
- package/.cursor/commands/opsx-archive.md +157 -0
- package/.cursor/commands/opsx-bulk-archive.md +242 -0
- package/.cursor/commands/opsx-continue.md +114 -0
- package/.cursor/commands/opsx-explore.md +174 -0
- package/.cursor/commands/opsx-ff.md +94 -0
- package/.cursor/commands/opsx-new.md +69 -0
- package/.cursor/commands/opsx-onboard.md +525 -0
- package/.cursor/commands/opsx-sync.md +134 -0
- package/.cursor/commands/opsx-verify.md +164 -0
- package/README.md +1 -1
- package/bin/6aspec +17 -1
- package/lib/cli.js +178 -45
- package/package.json +1 -1
- /package/.6aspec/rules/green/{6A_constitution.md → green_constitution.md} +0 -0
- /package/.6aspec/rules/green/{6A_design_sop.md → green_design_sop.md} +0 -0
- /package/.6aspec/rules/green/{6A_import_model_table_sop.md → green_import_model_table_sop.md} +0 -0
- /package/.6aspec/rules/green/{6A_init_event_list_sop.md → green_init_event_list_sop.md} +0 -0
- /package/.6aspec/rules/green/{6A_init_map_sop.md → green_init_map_sop.md} +0 -0
- /package/.6aspec/rules/green/{6A_model_sop.md → green_model_sop.md} +0 -0
- /package/.6aspec/rules/green/{6A_new_sop.md → green_new_sop.md} +0 -0
- /package/.6aspec/rules/green/{6A_rollback_sop.md → green_rollback_sop.md} +0 -0
- /package/.6aspec/rules/green/{6A_visual_logic_sop.md → green_visual_logic_sop.md} +0 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: /opsx-verify
|
|
3
|
+
id: opsx-verify
|
|
4
|
+
category: Workflow
|
|
5
|
+
description: Verify implementation matches change artifacts before archiving
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Verify that an implementation matches the change artifacts (specs, tasks, design).
|
|
9
|
+
|
|
10
|
+
**Input**: Optionally specify a change name after `/opsx:verify` (e.g., `/opsx:verify add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
|
|
11
|
+
|
|
12
|
+
**Steps**
|
|
13
|
+
|
|
14
|
+
1. **If no change name provided, prompt for selection**
|
|
15
|
+
|
|
16
|
+
Run `openspec list --json` to get available changes. Use the **AskUserQuestion tool** to let the user select.
|
|
17
|
+
|
|
18
|
+
Show changes that have implementation tasks (tasks artifact exists).
|
|
19
|
+
Include the schema used for each change if available.
|
|
20
|
+
Mark changes with incomplete tasks as "(In Progress)".
|
|
21
|
+
|
|
22
|
+
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
|
|
23
|
+
|
|
24
|
+
2. **Check status to understand the schema**
|
|
25
|
+
```bash
|
|
26
|
+
openspec status --change "<name>" --json
|
|
27
|
+
```
|
|
28
|
+
Parse the JSON to understand:
|
|
29
|
+
- `schemaName`: The workflow being used (e.g., "spec-driven")
|
|
30
|
+
- Which artifacts exist for this change
|
|
31
|
+
|
|
32
|
+
3. **Get the change directory and load artifacts**
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
openspec instructions apply --change "<name>" --json
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
This returns the change directory and context files. Read all available artifacts from `contextFiles`.
|
|
39
|
+
|
|
40
|
+
4. **Initialize verification report structure**
|
|
41
|
+
|
|
42
|
+
Create a report structure with three dimensions:
|
|
43
|
+
- **Completeness**: Track tasks and spec coverage
|
|
44
|
+
- **Correctness**: Track requirement implementation and scenario coverage
|
|
45
|
+
- **Coherence**: Track design adherence and pattern consistency
|
|
46
|
+
|
|
47
|
+
Each dimension can have CRITICAL, WARNING, or SUGGESTION issues.
|
|
48
|
+
|
|
49
|
+
5. **Verify Completeness**
|
|
50
|
+
|
|
51
|
+
**Task Completion**:
|
|
52
|
+
- If tasks.md exists in contextFiles, read it
|
|
53
|
+
- Parse checkboxes: `- [ ]` (incomplete) vs `- [x]` (complete)
|
|
54
|
+
- Count complete vs total tasks
|
|
55
|
+
- If incomplete tasks exist:
|
|
56
|
+
- Add CRITICAL issue for each incomplete task
|
|
57
|
+
- Recommendation: "Complete task: <description>" or "Mark as done if already implemented"
|
|
58
|
+
|
|
59
|
+
**Spec Coverage**:
|
|
60
|
+
- If delta specs exist in `openspec/changes/<name>/specs/`:
|
|
61
|
+
- Extract all requirements (marked with "### Requirement:")
|
|
62
|
+
- For each requirement:
|
|
63
|
+
- Search codebase for keywords related to the requirement
|
|
64
|
+
- Assess if implementation likely exists
|
|
65
|
+
- If requirements appear unimplemented:
|
|
66
|
+
- Add CRITICAL issue: "Requirement not found: <requirement name>"
|
|
67
|
+
- Recommendation: "Implement requirement X: <description>"
|
|
68
|
+
|
|
69
|
+
6. **Verify Correctness**
|
|
70
|
+
|
|
71
|
+
**Requirement Implementation Mapping**:
|
|
72
|
+
- For each requirement from delta specs:
|
|
73
|
+
- Search codebase for implementation evidence
|
|
74
|
+
- If found, note file paths and line ranges
|
|
75
|
+
- Assess if implementation matches requirement intent
|
|
76
|
+
- If divergence detected:
|
|
77
|
+
- Add WARNING: "Implementation may diverge from spec: <details>"
|
|
78
|
+
- Recommendation: "Review <file>:<lines> against requirement X"
|
|
79
|
+
|
|
80
|
+
**Scenario Coverage**:
|
|
81
|
+
- For each scenario in delta specs (marked with "#### Scenario:"):
|
|
82
|
+
- Check if conditions are handled in code
|
|
83
|
+
- Check if tests exist covering the scenario
|
|
84
|
+
- If scenario appears uncovered:
|
|
85
|
+
- Add WARNING: "Scenario not covered: <scenario name>"
|
|
86
|
+
- Recommendation: "Add test or implementation for scenario: <description>"
|
|
87
|
+
|
|
88
|
+
7. **Verify Coherence**
|
|
89
|
+
|
|
90
|
+
**Design Adherence**:
|
|
91
|
+
- If design.md exists in contextFiles:
|
|
92
|
+
- Extract key decisions (look for sections like "Decision:", "Approach:", "Architecture:")
|
|
93
|
+
- Verify implementation follows those decisions
|
|
94
|
+
- If contradiction detected:
|
|
95
|
+
- Add WARNING: "Design decision not followed: <decision>"
|
|
96
|
+
- Recommendation: "Update implementation or revise design.md to match reality"
|
|
97
|
+
- If no design.md: Skip design adherence check, note "No design.md to verify against"
|
|
98
|
+
|
|
99
|
+
**Code Pattern Consistency**:
|
|
100
|
+
- Review new code for consistency with project patterns
|
|
101
|
+
- Check file naming, directory structure, coding style
|
|
102
|
+
- If significant deviations found:
|
|
103
|
+
- Add SUGGESTION: "Code pattern deviation: <details>"
|
|
104
|
+
- Recommendation: "Consider following project pattern: <example>"
|
|
105
|
+
|
|
106
|
+
8. **Generate Verification Report**
|
|
107
|
+
|
|
108
|
+
**Summary Scorecard**:
|
|
109
|
+
```
|
|
110
|
+
## Verification Report: <change-name>
|
|
111
|
+
|
|
112
|
+
### Summary
|
|
113
|
+
| Dimension | Status |
|
|
114
|
+
|--------------|------------------|
|
|
115
|
+
| Completeness | X/Y tasks, N reqs|
|
|
116
|
+
| Correctness | M/N reqs covered |
|
|
117
|
+
| Coherence | Followed/Issues |
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Issues by Priority**:
|
|
121
|
+
|
|
122
|
+
1. **CRITICAL** (Must fix before archive):
|
|
123
|
+
- Incomplete tasks
|
|
124
|
+
- Missing requirement implementations
|
|
125
|
+
- Each with specific, actionable recommendation
|
|
126
|
+
|
|
127
|
+
2. **WARNING** (Should fix):
|
|
128
|
+
- Spec/design divergences
|
|
129
|
+
- Missing scenario coverage
|
|
130
|
+
- Each with specific recommendation
|
|
131
|
+
|
|
132
|
+
3. **SUGGESTION** (Nice to fix):
|
|
133
|
+
- Pattern inconsistencies
|
|
134
|
+
- Minor improvements
|
|
135
|
+
- Each with specific recommendation
|
|
136
|
+
|
|
137
|
+
**Final Assessment**:
|
|
138
|
+
- If CRITICAL issues: "X critical issue(s) found. Fix before archiving."
|
|
139
|
+
- If only warnings: "No critical issues. Y warning(s) to consider. Ready for archive (with noted improvements)."
|
|
140
|
+
- If all clear: "All checks passed. Ready for archive."
|
|
141
|
+
|
|
142
|
+
**Verification Heuristics**
|
|
143
|
+
|
|
144
|
+
- **Completeness**: Focus on objective checklist items (checkboxes, requirements list)
|
|
145
|
+
- **Correctness**: Use keyword search, file path analysis, reasonable inference - don't require perfect certainty
|
|
146
|
+
- **Coherence**: Look for glaring inconsistencies, don't nitpick style
|
|
147
|
+
- **False Positives**: When uncertain, prefer SUGGESTION over WARNING, WARNING over CRITICAL
|
|
148
|
+
- **Actionability**: Every issue must have a specific recommendation with file/line references where applicable
|
|
149
|
+
|
|
150
|
+
**Graceful Degradation**
|
|
151
|
+
|
|
152
|
+
- If only tasks.md exists: verify task completion only, skip spec/design checks
|
|
153
|
+
- If tasks + specs exist: verify completeness and correctness, skip design
|
|
154
|
+
- If full artifacts: verify all three dimensions
|
|
155
|
+
- Always note which checks were skipped and why
|
|
156
|
+
|
|
157
|
+
**Output Format**
|
|
158
|
+
|
|
159
|
+
Use clear markdown with:
|
|
160
|
+
- Table for summary scorecard
|
|
161
|
+
- Grouped lists for issues (CRITICAL/WARNING/SUGGESTION)
|
|
162
|
+
- Code references in format: `file.ts:123`
|
|
163
|
+
- Specific, actionable recommendations
|
|
164
|
+
- No vague suggestions like "consider reviewing"
|
package/README.md
CHANGED
|
@@ -118,7 +118,7 @@ npm install -g 6aspec@2.0.0
|
|
|
118
118
|
|------|------|
|
|
119
119
|
| `/6aspec:green:new` | 创建一个模块 |
|
|
120
120
|
| `/6aspec:green:continue` | 生成下一个工件 |
|
|
121
|
-
| `/6aspec:green:
|
|
121
|
+
| `/6aspec:green:implement` | 执行任务 |
|
|
122
122
|
| `/6aspec:green:init` | 初始化项目 |
|
|
123
123
|
| `/6aspec:green:status` | 查看状态 |
|
|
124
124
|
| `/6aspec:green:model` | 数据建模 |
|
package/bin/6aspec
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const path = require('path');
|
|
4
|
+
const pkg = require('../package.json');
|
|
4
5
|
const cli = require('../lib/cli');
|
|
5
6
|
|
|
6
7
|
const args = process.argv.slice(2);
|
|
@@ -8,7 +9,7 @@ const command = args[0];
|
|
|
8
9
|
|
|
9
10
|
if (!command || command === '--help' || command === '-h') {
|
|
10
11
|
console.log(`
|
|
11
|
-
\x1b[36m6Aspec\x1b[0m - 轻量级 spec 驱动开发框架
|
|
12
|
+
\x1b[36m6Aspec\x1b[0m v${pkg.version} - 轻量级 spec 驱动开发框架
|
|
12
13
|
|
|
13
14
|
用法:
|
|
14
15
|
6aspec <command>
|
|
@@ -16,6 +17,7 @@ if (!command || command === '--help' || command === '-h') {
|
|
|
16
17
|
命令:
|
|
17
18
|
init 交互式初始化(选择工具 + 安装配置)
|
|
18
19
|
update 更新已安装的工具配置(merge 模式)
|
|
20
|
+
version 显示当前 CLI 版本
|
|
19
21
|
--help 显示帮助信息
|
|
20
22
|
|
|
21
23
|
示例:
|
|
@@ -27,6 +29,20 @@ if (!command || command === '--help' || command === '-h') {
|
|
|
27
29
|
process.exit(0);
|
|
28
30
|
}
|
|
29
31
|
|
|
32
|
+
if (command === '--version' || command === '-v' || command === 'version') {
|
|
33
|
+
const fs = require('fs');
|
|
34
|
+
const configPath = path.join(process.cwd(), '.6aspec/init.json');
|
|
35
|
+
let projectInfo = '';
|
|
36
|
+
if (fs.existsSync(configPath)) {
|
|
37
|
+
try {
|
|
38
|
+
const cfg = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
39
|
+
projectInfo = `\n\x1b[2m 当前项目已安装: ${cfg.tools.join(', ')} (版本 ${cfg.version || 'unknown'})\x1b[0m`;
|
|
40
|
+
} catch {}
|
|
41
|
+
}
|
|
42
|
+
console.log(`\x1b[36m6Aspec\x1b[0m v${pkg.version}${projectInfo}`);
|
|
43
|
+
process.exit(0);
|
|
44
|
+
}
|
|
45
|
+
|
|
30
46
|
(async () => {
|
|
31
47
|
try {
|
|
32
48
|
switch (command) {
|
package/lib/cli.js
CHANGED
|
@@ -19,20 +19,58 @@ const TOOLS = [
|
|
|
19
19
|
{ id: 'claude', name: 'Claude Code', desc: 'Claude Code CLI 配置' },
|
|
20
20
|
];
|
|
21
21
|
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
// Only the 6aspec-owned subdirectory is removed — user's own commands are untouched
|
|
23
|
+
const TOOL_DIRS = {
|
|
24
|
+
cursor: ['.cursor/commands/6aspec'],
|
|
25
|
+
claude: ['.claude/commands/6aspec'],
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// ─── Welcome Screen with Animation ──────────────────────────────────
|
|
29
|
+
|
|
30
|
+
// Braille spinner frames
|
|
31
|
+
const SPINNER_CHARS = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
32
|
+
|
|
33
|
+
// 4-phase ornament pulse: dim → mid → bright → mid
|
|
34
|
+
const ORN_FRAMES = [
|
|
35
|
+
{ ch: '░░', c: DIM + CYAN },
|
|
36
|
+
{ ch: '▒▒', c: CYAN },
|
|
37
|
+
{ ch: '██', c: BOLD + CYAN },
|
|
38
|
+
{ ch: '▒▒', c: CYAN },
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
// Logo: 18 lines tall to match right-side content height
|
|
42
|
+
// Visible width of each line = 20 chars (" ████ ")
|
|
43
|
+
function buildLogoLines(ornIdx, spinIdx) {
|
|
44
|
+
const { ch, c } = ORN_FRAMES[ornIdx % ORN_FRAMES.length];
|
|
45
|
+
const sp = SPINNER_CHARS[spinIdx % SPINNER_CHARS.length];
|
|
46
|
+
const B = BOLD + CYAN;
|
|
47
|
+
const R = RESET;
|
|
48
|
+
const _ = ' '; // 20-char blank line
|
|
49
|
+
|
|
50
|
+
return [
|
|
51
|
+
_,
|
|
52
|
+
` ${B}████${R} `,
|
|
53
|
+
` ${B}████${R} `,
|
|
54
|
+
` ${c}${ch}${R} ${c}${ch}${R} `,
|
|
55
|
+
` ${c}${ch}${R} ${c}${ch}${R} `,
|
|
56
|
+
` ${B}████${R} `,
|
|
57
|
+
` ${B}████${R} `,
|
|
58
|
+
` ${B}████${R} `,
|
|
59
|
+
` ${B}████${R} `,
|
|
60
|
+
` ${c}${ch}${R} ${c}${ch}${R} `,
|
|
61
|
+
` ${c}${ch}${R} ${c}${ch}${R} `,
|
|
62
|
+
` ${B}████${R} `,
|
|
63
|
+
` ${B}████${R} `,
|
|
64
|
+
_,
|
|
65
|
+
` ${CYAN}${sp}${R} `,
|
|
66
|
+
_,
|
|
67
|
+
_,
|
|
68
|
+
_,
|
|
33
69
|
];
|
|
70
|
+
}
|
|
34
71
|
|
|
35
|
-
|
|
72
|
+
function buildRightLines() {
|
|
73
|
+
return [
|
|
36
74
|
`${BOLD}${WHITE}Welcome to 6Aspec${RESET}`,
|
|
37
75
|
`${DIM}A lightweight spec-driven framework${RESET}`,
|
|
38
76
|
``,
|
|
@@ -41,51 +79,89 @@ function buildWelcomeScreen() {
|
|
|
41
79
|
` ${GREEN}•${RESET} /6aspec:* slash commands`,
|
|
42
80
|
``,
|
|
43
81
|
`${YELLOW}Quick start after setup:${RESET}`,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const brownCmds = [
|
|
82
|
+
``,
|
|
83
|
+
` ${MAGENTA}Brownfield (existing project):${RESET}`,
|
|
47
84
|
` ${GREEN}/6aspec:brown:new${RESET} Create a change`,
|
|
48
85
|
` ${GREEN}/6aspec:brown:continue${RESET} Next artifact`,
|
|
49
86
|
` ${GREEN}/6aspec:brown:implement${RESET} Implement tasks`,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const greenCmds = [
|
|
87
|
+
``,
|
|
88
|
+
` ${MAGENTA}Greenfield (new project):${RESET}`,
|
|
53
89
|
` ${GREEN}/6aspec:green:new${RESET} Create a module`,
|
|
54
90
|
` ${GREEN}/6aspec:green:continue${RESET} Next artifact`,
|
|
55
|
-
` ${GREEN}/6aspec:green:
|
|
91
|
+
` ${GREEN}/6aspec:green:implement${RESET} Execute tasks`,
|
|
56
92
|
];
|
|
93
|
+
}
|
|
57
94
|
|
|
58
|
-
|
|
59
|
-
|
|
95
|
+
function buildScreenLines(logoLines, rightLines) {
|
|
60
96
|
const lines = [];
|
|
61
97
|
lines.push('');
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
for (let i = 0; i < maxLines; i++) {
|
|
68
|
-
const l = i < logo.length ? logo[i] : ' ';
|
|
69
|
-
const r = i < totalRight.length ? totalRight[i] : '';
|
|
98
|
+
const len = Math.max(logoLines.length, rightLines.length);
|
|
99
|
+
for (let i = 0; i < len; i++) {
|
|
100
|
+
const l = i < logoLines.length ? logoLines[i] : ' ';
|
|
101
|
+
const r = i < rightLines.length ? rightLines[i] : '';
|
|
70
102
|
lines.push(` ${l} ${r}`);
|
|
71
103
|
}
|
|
72
|
-
|
|
73
104
|
lines.push('');
|
|
74
|
-
lines.push(` ${'
|
|
105
|
+
lines.push(` ${' '} ${DIM}Press Enter to select tools...${RESET}`);
|
|
75
106
|
lines.push('');
|
|
76
|
-
|
|
77
|
-
return lines.join('\n');
|
|
107
|
+
return lines;
|
|
78
108
|
}
|
|
79
109
|
|
|
80
|
-
// ───
|
|
110
|
+
// ─── Animated welcome: renders in-place until Enter is pressed ───────
|
|
81
111
|
|
|
82
|
-
function
|
|
112
|
+
function waitForEnterAnimated() {
|
|
83
113
|
return new Promise((resolve) => {
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
114
|
+
const rightLines = buildRightLines();
|
|
115
|
+
|
|
116
|
+
let ornIdx = 0;
|
|
117
|
+
let spinIdx = 0;
|
|
118
|
+
let screenLineCount = 0;
|
|
119
|
+
let firstRender = true;
|
|
120
|
+
|
|
121
|
+
function render() {
|
|
122
|
+
const logoLines = buildLogoLines(ornIdx, spinIdx);
|
|
123
|
+
const screenLines = buildScreenLines(logoLines, rightLines);
|
|
124
|
+
const output = screenLines.join('\n') + '\n';
|
|
125
|
+
|
|
126
|
+
if (firstRender) {
|
|
127
|
+
process.stdout.write(output);
|
|
128
|
+
screenLineCount = screenLines.length;
|
|
129
|
+
firstRender = false;
|
|
130
|
+
} else {
|
|
131
|
+
// Move cursor up to start of screen, overwrite in-place
|
|
132
|
+
process.stdout.write(`\x1b[${screenLineCount}A${output}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
render();
|
|
137
|
+
|
|
138
|
+
const interval = setInterval(() => {
|
|
139
|
+
ornIdx = (ornIdx + 1) % ORN_FRAMES.length;
|
|
140
|
+
spinIdx = (spinIdx + 1) % SPINNER_CHARS.length;
|
|
141
|
+
render();
|
|
142
|
+
}, 150);
|
|
143
|
+
|
|
144
|
+
const isRaw = process.stdin.isTTY;
|
|
145
|
+
if (isRaw) process.stdin.setRawMode(true);
|
|
146
|
+
process.stdin.resume();
|
|
147
|
+
process.stdin.setEncoding('utf8');
|
|
148
|
+
|
|
149
|
+
function onKey(key) {
|
|
150
|
+
if (key === '\r' || key === '\n' || key === ' ') {
|
|
151
|
+
clearInterval(interval);
|
|
152
|
+
process.stdin.removeListener('data', onKey);
|
|
153
|
+
if (isRaw) process.stdin.setRawMode(false);
|
|
154
|
+
process.stdin.pause();
|
|
155
|
+
// Clear welcome screen
|
|
156
|
+
process.stdout.write(`\x1b[${screenLineCount}A\x1b[J`);
|
|
157
|
+
resolve();
|
|
158
|
+
} else if (key === '\u0003') {
|
|
159
|
+
clearInterval(interval);
|
|
160
|
+
process.exit(0);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
process.stdin.on('data', onKey);
|
|
89
165
|
});
|
|
90
166
|
}
|
|
91
167
|
|
|
@@ -115,8 +191,13 @@ function selectTools(preSelected) {
|
|
|
115
191
|
TOOLS.forEach((tool, i) => {
|
|
116
192
|
const check = selected[i] ? `${GREEN}◉${RESET}` : `○`;
|
|
117
193
|
const pointer = i === cursor ? `${CYAN}❯${RESET}` : ' ';
|
|
118
|
-
|
|
119
|
-
|
|
194
|
+
let hint = '';
|
|
195
|
+
if (preSelected.includes(tool.id)) {
|
|
196
|
+
hint = selected[i]
|
|
197
|
+
? ` ${DIM}(installed)${RESET}`
|
|
198
|
+
: ` ${YELLOW}(will remove)${RESET}`;
|
|
199
|
+
}
|
|
200
|
+
console.log(` ${pointer} ${check} ${tool.name} ${DIM}- ${tool.desc}${RESET}${hint}`);
|
|
120
201
|
});
|
|
121
202
|
console.log('');
|
|
122
203
|
}
|
|
@@ -189,6 +270,43 @@ function writeConfig(targetDir, tools) {
|
|
|
189
270
|
return config;
|
|
190
271
|
}
|
|
191
272
|
|
|
273
|
+
// ─── Tool removal ───────────────────────────────────────────────────
|
|
274
|
+
|
|
275
|
+
function removeDirRecursive(dirPath) {
|
|
276
|
+
if (!fs.existsSync(dirPath)) return;
|
|
277
|
+
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
278
|
+
for (const entry of entries) {
|
|
279
|
+
const full = path.join(dirPath, entry.name);
|
|
280
|
+
if (entry.isDirectory()) removeDirRecursive(full);
|
|
281
|
+
else fs.unlinkSync(full);
|
|
282
|
+
}
|
|
283
|
+
fs.rmdirSync(dirPath);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function removeToolFiles(targetDir, tools) {
|
|
287
|
+
for (const tool of tools) {
|
|
288
|
+
const dirs = TOOL_DIRS[tool] || [];
|
|
289
|
+
for (const rel of dirs) {
|
|
290
|
+
const full = path.join(targetDir, rel);
|
|
291
|
+
if (fs.existsSync(full)) {
|
|
292
|
+
removeDirRecursive(full);
|
|
293
|
+
console.log(`${GREEN}[INFO]${RESET} 已删除 ${rel}`);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// Simple y/N prompt (readline, no raw mode needed)
|
|
300
|
+
function promptConfirm(question) {
|
|
301
|
+
return new Promise((resolve) => {
|
|
302
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
303
|
+
rl.question(`${question} ${DIM}[y/N]${RESET} `, (answer) => {
|
|
304
|
+
rl.close();
|
|
305
|
+
resolve(answer.trim().toLowerCase() === 'y');
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
|
|
192
310
|
// ─── Parse non-interactive --tool flag ──────────────────────────────
|
|
193
311
|
|
|
194
312
|
function parseToolFlag(args) {
|
|
@@ -221,8 +339,7 @@ async function init(args) {
|
|
|
221
339
|
console.log(`\n${GREEN}[INFO]${RESET} 非交互模式:初始化 ${selectedTools.join(', ')}`);
|
|
222
340
|
} else {
|
|
223
341
|
// Interactive mode
|
|
224
|
-
|
|
225
|
-
await waitForEnter();
|
|
342
|
+
await waitForEnterAnimated();
|
|
226
343
|
selectedTools = await selectTools(preSelected);
|
|
227
344
|
|
|
228
345
|
if (selectedTools.length === 0) {
|
|
@@ -266,10 +383,26 @@ async function init(args) {
|
|
|
266
383
|
}
|
|
267
384
|
}
|
|
268
385
|
|
|
386
|
+
// Handle deselected tools (were installed, now unchecked)
|
|
387
|
+
const removedTools = preSelected.filter((t) => !selectedTools.includes(t));
|
|
388
|
+
if (removedTools.length > 0) {
|
|
389
|
+
console.log(`\n${YELLOW}[WARN]${RESET} 以下工具已取消选择: ${removedTools.join(', ')}`);
|
|
390
|
+
for (const tool of removedTools) {
|
|
391
|
+
const dirs = TOOL_DIRS[tool] || [];
|
|
392
|
+
dirs.forEach((d) => console.log(` ${DIM}${d}${RESET}`));
|
|
393
|
+
}
|
|
394
|
+
const confirm = await promptConfirm(' 是否同时删除这些文件?');
|
|
395
|
+
if (confirm) {
|
|
396
|
+
removeToolFiles(targetDir, removedTools);
|
|
397
|
+
} else {
|
|
398
|
+
console.log(`${DIM} 已跳过文件删除,文件保留在磁盘上。${RESET}`);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
269
402
|
// Save config
|
|
270
403
|
const savedConfig = writeConfig(targetDir, selectedTools);
|
|
271
404
|
console.log(`\n${GREEN}[SUCCESS]${RESET} 初始化完成!配置已保存到 ${CONFIG_FILE}`);
|
|
272
|
-
console.log(`${DIM} 工具: ${selectedTools.join(', ')}${RESET}`);
|
|
405
|
+
console.log(`${DIM} 工具: ${selectedTools.length > 0 ? selectedTools.join(', ') : '(none)'}${RESET}`);
|
|
273
406
|
console.log(`${DIM} 版本: ${savedConfig.version}${RESET}\n`);
|
|
274
407
|
}
|
|
275
408
|
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
/package/.6aspec/rules/green/{6A_import_model_table_sop.md → green_import_model_table_sop.md}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|