sillyspec 3.20.2 → 3.20.4

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.
Files changed (133) hide show
  1. package/.claude/skills/sillyspec-archive/SKILL.md +21 -21
  2. package/.claude/skills/sillyspec-auto/SKILL.md +83 -83
  3. package/.claude/skills/sillyspec-brainstorm/SKILL.md +44 -44
  4. package/.claude/skills/sillyspec-commit/SKILL.md +106 -106
  5. package/.claude/skills/sillyspec-continue/SKILL.md +45 -45
  6. package/.claude/skills/sillyspec-doctor/SKILL.md +31 -31
  7. package/.claude/skills/sillyspec-execute/SKILL.md +30 -30
  8. package/.claude/skills/sillyspec-explore/SKILL.md +109 -109
  9. package/.claude/skills/sillyspec-knowledge/SKILL.md +269 -269
  10. package/.claude/skills/sillyspec-plan/SKILL.md +21 -21
  11. package/.claude/skills/sillyspec-propose/SKILL.md +21 -21
  12. package/.claude/skills/sillyspec-quick/SKILL.md +21 -21
  13. package/.claude/skills/sillyspec-resume/SKILL.md +68 -68
  14. package/.claude/skills/sillyspec-scan/SKILL.md +21 -21
  15. package/.claude/skills/sillyspec-state/SKILL.md +54 -54
  16. package/.claude/skills/sillyspec-status/SKILL.md +21 -21
  17. package/.claude/skills/sillyspec-verify/SKILL.md +21 -21
  18. package/.claude/skills/sillyspec-workspace/SKILL.md +157 -157
  19. package/.husky/pre-push +13 -13
  20. package/CLAUDE.md +18 -18
  21. package/README.md +198 -188
  22. package/SKILL.md +90 -91
  23. package/bin/sillyspec.js +2 -2
  24. package/docs/brainstorm-plan-contract.md +64 -64
  25. package/docs/plan-execute-contract.md +123 -123
  26. package/docs/platform-scan-protocol.md +298 -298
  27. package/docs/revision-mode.md +115 -115
  28. package/docs/sillyspec/file-lifecycle/known-implementation-gaps.md +99 -99
  29. package/docs/sillyspec/file-lifecycle/platform-workflows-sync.md +218 -218
  30. package/docs/sillyspec/file-lifecycle/stage-artifacts.md +167 -167
  31. package/docs/sillyspec/file-lifecycle/storage-and-state.md +148 -148
  32. package/docs/sillyspec/file-lifecycle/worktree-and-guard.md +211 -193
  33. package/docs/sillyspec/file-lifecycle.md +125 -125
  34. package/docs/workflow-contract-regression.md +106 -106
  35. package/docs/worktree-isolation.md +252 -252
  36. package/package.json +40 -40
  37. package/packages/dashboard/dist/assets/index-Bq_Z2hne.js +7446 -7446
  38. package/packages/dashboard/dist/assets/index-O2W5RV4z.css +1 -1
  39. package/packages/dashboard/dist/index.html +16 -16
  40. package/packages/dashboard/index.html +15 -15
  41. package/packages/dashboard/package-lock.json +2384 -2384
  42. package/packages/dashboard/package.json +25 -25
  43. package/packages/dashboard/server/executor.js +86 -86
  44. package/packages/dashboard/server/index.js +588 -588
  45. package/packages/dashboard/server/parser.js +526 -526
  46. package/packages/dashboard/server/watcher.js +344 -344
  47. package/packages/dashboard/src/App.vue +558 -558
  48. package/packages/dashboard/src/components/ActionBar.vue +93 -93
  49. package/packages/dashboard/src/components/CommandPalette.vue +96 -96
  50. package/packages/dashboard/src/components/DetailPanel.vue +137 -137
  51. package/packages/dashboard/src/components/LogStream.vue +65 -65
  52. package/packages/dashboard/src/components/PipelineStage.vue +95 -95
  53. package/packages/dashboard/src/components/PipelineView.vue +156 -156
  54. package/packages/dashboard/src/components/ProjectList.vue +210 -210
  55. package/packages/dashboard/src/components/StageBadge.vue +67 -67
  56. package/packages/dashboard/src/components/StepCard.vue +94 -94
  57. package/packages/dashboard/src/components/detail/DocsDetail.vue +48 -48
  58. package/packages/dashboard/src/components/detail/GitDetail.vue +61 -61
  59. package/packages/dashboard/src/components/detail/TechDetail.vue +43 -43
  60. package/packages/dashboard/src/composables/useDashboard.js +170 -170
  61. package/packages/dashboard/src/composables/useKeyboard.js +119 -119
  62. package/packages/dashboard/src/composables/useWebSocket.js +129 -129
  63. package/packages/dashboard/src/main.js +8 -8
  64. package/packages/dashboard/src/style.css +132 -132
  65. package/packages/dashboard/vite.config.js +18 -18
  66. package/src/brainstorm-postcheck.js +158 -158
  67. package/src/change-list.js +52 -52
  68. package/src/change-risk-profile.js +352 -352
  69. package/src/classify-change.js +73 -73
  70. package/src/constants.js +70 -70
  71. package/src/contract-matrix.js +278 -278
  72. package/src/db.js +201 -201
  73. package/src/endpoint-extractor.js +315 -315
  74. package/src/hooks/claude-pre-tool-use.cjs +125 -125
  75. package/src/hooks/worktree-guard.js +653 -653
  76. package/src/index.js +922 -900
  77. package/src/init.js +431 -431
  78. package/src/knowledge-match.js +130 -130
  79. package/src/migrate.js +117 -117
  80. package/src/modules.js +482 -482
  81. package/src/progress.js +1734 -1734
  82. package/src/run.js +3465 -3358
  83. package/src/scan-postcheck.js +387 -383
  84. package/src/setup.js +398 -398
  85. package/src/stage-contract.js +700 -700
  86. package/src/stages/archive.js +160 -160
  87. package/src/stages/brainstorm-auto.js +229 -229
  88. package/src/stages/brainstorm.js +645 -645
  89. package/src/stages/doctor.js +365 -365
  90. package/src/stages/execute.js +625 -625
  91. package/src/stages/explore.js +34 -34
  92. package/src/stages/index.js +29 -29
  93. package/src/stages/knowledge.js +498 -498
  94. package/src/stages/plan-postcheck.js +511 -513
  95. package/src/stages/plan.js +582 -582
  96. package/src/stages/propose.js +174 -174
  97. package/src/stages/quick.js +82 -82
  98. package/src/stages/scan.js +558 -558
  99. package/src/stages/status.js +65 -65
  100. package/src/stages/verify.js +322 -322
  101. package/src/sync.js +497 -497
  102. package/src/task-review.js +346 -346
  103. package/src/workflow.js +785 -785
  104. package/src/worktree-apply.js +549 -549
  105. package/src/worktree-deps.js +185 -0
  106. package/src/worktree.js +982 -932
  107. package/templates/workflows/archive-impact.yaml +79 -79
  108. package/templates/workflows/scan-docs.yaml +132 -132
  109. package/test/brainstorm-plan-contract.test.mjs +273 -273
  110. package/test/check-syntax.mjs +26 -26
  111. package/test/contract-artifacts.test.mjs +323 -323
  112. package/test/decision-supersede.test.mjs +277 -277
  113. package/test/knowledge-match.test.mjs +231 -231
  114. package/test/plan-execute-contract.test.mjs +330 -330
  115. package/test/plan-optimization.test.mjs +572 -572
  116. package/test/platform-artifacts.test.mjs +166 -166
  117. package/test/platform-failure-samples.test.mjs +199 -199
  118. package/test/platform-recovery-chain.test.mjs +167 -167
  119. package/test/platform-recovery.test.mjs +136 -136
  120. package/test/platform-scan-p0.test.mjs +168 -168
  121. package/test/revision-v1.test.mjs +1145 -1145
  122. package/test/run-scan-project-parse.test.mjs +200 -200
  123. package/test/run-tests.mjs +48 -48
  124. package/test/scan-knowledge.test.mjs +175 -175
  125. package/test/scan-paths.test.mjs +68 -68
  126. package/test/scan-postcheck.test.mjs +197 -197
  127. package/test/spec-dir.test.mjs +206 -206
  128. package/test/stage-contract.test.mjs +299 -299
  129. package/test/stage-definitions.test.mjs +39 -39
  130. package/test/wait-gates.test.mjs +496 -496
  131. package/test/worktree-deps-provision.test.mjs +148 -0
  132. package/test/worktree-guard.test.mjs +71 -71
  133. package/test/worktree-native-overlay.test.mjs +188 -188
@@ -1,93 +1,93 @@
1
- <template>
2
- <div class="h-12 flex items-center justify-between px-5 relative" style="background: rgba(17,17,19,0.9); backdrop-filter: blur(20px); border-top: 1px solid #F0F0F3;">
3
- <!-- Ambient top glow -->
4
- <div class="absolute inset-x-0 top-0 h-px" style="background: linear-gradient(90deg, transparent, rgba(251,191,36,0.1), transparent);"></div>
5
-
6
- <!-- Left: Status -->
7
- <div class="flex items-center gap-3">
8
- <div v-if="project" class="flex items-center gap-2">
9
- <span class="text-[11px] font-[JetBrains_Mono,monospace]" style="color: #6B7280;">{{ project.name }}</span>
10
- <span style="color: #F0F0F3;">|</span>
11
- <StageBadge v-if="project.state?.currentStage" :status="getProjectStatus()" :label="stageLabel()" />
12
- </div>
13
- <div v-else class="text-[10px] font-[JetBrains_Mono,monospace]" style="color: #D1D1D6;">
14
- 未选择项目
15
- </div>
16
- </div>
17
-
18
- <!-- Center: Execution -->
19
- <div class="flex items-center gap-2">
20
- <div v-if="isExecuting" class="flex items-center gap-2">
21
- <div class="w-1 h-1 rounded-full animate-pulse-dot" style="background: #D97706;" />
22
- <span class="text-[10px] font-[JetBrains_Mono,monospace]" style="color: #D97706;">执行中...</span>
23
- </div>
24
- <div v-else-if="executionResult" class="flex items-center gap-1.5">
25
- <span class="text-[10px] font-[JetBrains_Mono,monospace]" :style="{ color: executionResult.exitCode === 0 ? '#16A34A' : '#DC2626' }">
26
- {{ executionResult.exitCode === 0 ? '● 完成' : `● 失败 (${executionResult.exitCode})` }}
27
- </span>
28
- </div>
29
- </div>
30
-
31
- <!-- Right: Actions -->
32
- <div class="flex items-center gap-1">
33
- <n-button quaternary size="tiny" @click="$emit('toggle-panel')" title="切换详情面板">
34
- <template #icon>
35
- <svg :class="['w-3.5 h-3.5 transition-transform duration-200', { 'rotate-180': !isPanelOpen }]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
36
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
37
- </svg>
38
- </template>
39
- </n-button>
40
-
41
- <n-button v-if="isExecuting" size="tiny" type="error" @click="$emit('kill')">
42
- 停止
43
- </n-button>
44
-
45
- <n-button quaternary size="tiny" @click="$emit('open-palette')" title="命令面板 (⌘K)">
46
- <template #icon>
47
- <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
48
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
49
- </svg>
50
- </template>
51
- </n-button>
52
- </div>
53
- </div>
54
- </template>
55
-
56
- <script setup>
57
- import StageBadge from './StageBadge.vue'
58
-
59
- const props = defineProps({
60
- project: { type: Object, default: null },
61
- isExecuting: { type: Boolean, default: false },
62
- executionResult: { type: Object, default: null },
63
- isPanelOpen: { type: Boolean, default: true }
64
- })
65
-
66
- const emit = defineEmits(['execute', 'kill', 'toggle-panel', 'open-palette'])
67
-
68
- function getProjectStatus() {
69
- if (!props.project?.state) return 'pending'
70
- const stage = props.project.state.currentStage
71
- const steps = props.project.state.progress?.stages?.[stage]?.steps || []
72
- if (steps.some(s => s.status === 'failed')) return 'failed'
73
- if (steps.some(s => s.status === 'blocked')) return 'blocked'
74
- if (steps.some(s => s.status === 'in-progress')) return 'in-progress'
75
- if (steps.every(s => s.status === 'completed')) return 'completed'
76
- return 'pending'
77
- }
78
-
79
- function stageLabel() {
80
- const stage = props.project?.state?.currentStage
81
- const labels = {
82
- scan: '代码扫描',
83
- brainstorm: '头脑风暴',
84
- plan: '规划',
85
- execute: '执行',
86
- verify: '验证',
87
- archive: '归档',
88
- quick: '快速任务',
89
- explore: '自由探索'
90
- }
91
- return labels[stage] || stage || '未知'
92
- }
93
- </script>
1
+ <template>
2
+ <div class="h-12 flex items-center justify-between px-5 relative" style="background: rgba(17,17,19,0.9); backdrop-filter: blur(20px); border-top: 1px solid #F0F0F3;">
3
+ <!-- Ambient top glow -->
4
+ <div class="absolute inset-x-0 top-0 h-px" style="background: linear-gradient(90deg, transparent, rgba(251,191,36,0.1), transparent);"></div>
5
+
6
+ <!-- Left: Status -->
7
+ <div class="flex items-center gap-3">
8
+ <div v-if="project" class="flex items-center gap-2">
9
+ <span class="text-[11px] font-[JetBrains_Mono,monospace]" style="color: #6B7280;">{{ project.name }}</span>
10
+ <span style="color: #F0F0F3;">|</span>
11
+ <StageBadge v-if="project.state?.currentStage" :status="getProjectStatus()" :label="stageLabel()" />
12
+ </div>
13
+ <div v-else class="text-[10px] font-[JetBrains_Mono,monospace]" style="color: #D1D1D6;">
14
+ 未选择项目
15
+ </div>
16
+ </div>
17
+
18
+ <!-- Center: Execution -->
19
+ <div class="flex items-center gap-2">
20
+ <div v-if="isExecuting" class="flex items-center gap-2">
21
+ <div class="w-1 h-1 rounded-full animate-pulse-dot" style="background: #D97706;" />
22
+ <span class="text-[10px] font-[JetBrains_Mono,monospace]" style="color: #D97706;">执行中...</span>
23
+ </div>
24
+ <div v-else-if="executionResult" class="flex items-center gap-1.5">
25
+ <span class="text-[10px] font-[JetBrains_Mono,monospace]" :style="{ color: executionResult.exitCode === 0 ? '#16A34A' : '#DC2626' }">
26
+ {{ executionResult.exitCode === 0 ? '● 完成' : `● 失败 (${executionResult.exitCode})` }}
27
+ </span>
28
+ </div>
29
+ </div>
30
+
31
+ <!-- Right: Actions -->
32
+ <div class="flex items-center gap-1">
33
+ <n-button quaternary size="tiny" @click="$emit('toggle-panel')" title="切换详情面板">
34
+ <template #icon>
35
+ <svg :class="['w-3.5 h-3.5 transition-transform duration-200', { 'rotate-180': !isPanelOpen }]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
36
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
37
+ </svg>
38
+ </template>
39
+ </n-button>
40
+
41
+ <n-button v-if="isExecuting" size="tiny" type="error" @click="$emit('kill')">
42
+ 停止
43
+ </n-button>
44
+
45
+ <n-button quaternary size="tiny" @click="$emit('open-palette')" title="命令面板 (⌘K)">
46
+ <template #icon>
47
+ <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
48
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
49
+ </svg>
50
+ </template>
51
+ </n-button>
52
+ </div>
53
+ </div>
54
+ </template>
55
+
56
+ <script setup>
57
+ import StageBadge from './StageBadge.vue'
58
+
59
+ const props = defineProps({
60
+ project: { type: Object, default: null },
61
+ isExecuting: { type: Boolean, default: false },
62
+ executionResult: { type: Object, default: null },
63
+ isPanelOpen: { type: Boolean, default: true }
64
+ })
65
+
66
+ const emit = defineEmits(['execute', 'kill', 'toggle-panel', 'open-palette'])
67
+
68
+ function getProjectStatus() {
69
+ if (!props.project?.state) return 'pending'
70
+ const stage = props.project.state.currentStage
71
+ const steps = props.project.state.progress?.stages?.[stage]?.steps || []
72
+ if (steps.some(s => s.status === 'failed')) return 'failed'
73
+ if (steps.some(s => s.status === 'blocked')) return 'blocked'
74
+ if (steps.some(s => s.status === 'in-progress')) return 'in-progress'
75
+ if (steps.every(s => s.status === 'completed')) return 'completed'
76
+ return 'pending'
77
+ }
78
+
79
+ function stageLabel() {
80
+ const stage = props.project?.state?.currentStage
81
+ const labels = {
82
+ scan: '代码扫描',
83
+ brainstorm: '头脑风暴',
84
+ plan: '规划',
85
+ execute: '执行',
86
+ verify: '验证',
87
+ archive: '归档',
88
+ quick: '快速任务',
89
+ explore: '自由探索'
90
+ }
91
+ return labels[stage] || stage || '未知'
92
+ }
93
+ </script>
@@ -1,96 +1,96 @@
1
- <template>
2
- <n-modal :show="isOpen" @update:show="$emit('close')" :mask-closable="true" transform-origin="center" style="max-width: 480px;">
3
- <div class="overflow-hidden rounded-md" style="background: #FFFFFF; border: 1px solid #E5E5EA; box-shadow: 0 25px 60px rgba(0,0,0,0.1);">
4
- <!-- Search -->
5
- <div class="px-4 py-3" style="border-bottom: 1px solid #F0F0F3;">
6
- <n-input v-model:value="searchQuery" placeholder="搜索项目或命令..." ref="searchInput" @keydown="handleKeydown" size="small">
7
- <template #prefix>
8
- <svg class="w-3.5 h-3.5" style="color: #6B7280;" fill="none" stroke="currentColor" viewBox="0 0 24 24">
9
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
10
- </svg>
11
- </template>
12
- </n-input>
13
- </div>
14
-
15
- <!-- Results -->
16
- <div class="max-h-72 overflow-y-auto">
17
- <n-empty v-if="filteredItems.length === 0" description="无结果" style="padding: 40px 0;" />
18
- <div v-else class="py-0.5">
19
- <div
20
- v-for="(item, index) in filteredItems"
21
- :key="item.id"
22
- :class="['px-4 py-2.5 cursor-pointer transition-colors duration-100 flex items-center gap-3']"
23
- :style="{ background: selectedIndex === index ? 'rgba(217,119,6,0.06)' : 'transparent' }"
24
- @click="selectItem(item)"
25
- @mouseenter="selectedIndex = index"
26
- >
27
- <div class="w-6 h-6 rounded-sm flex items-center justify-center text-[10px] font-[JetBrains_Mono,monospace] flex-shrink-0" style="background: #F0F0F3; border: 1px solid #F0F0F3; color: #6B7280;">
28
- {{ item.type === 'project' ? '□' : '◇' }}
29
- </div>
30
- <div class="flex-1 min-w-0">
31
- <div class="text-[12px] font-medium truncate font-[JetBrains_Mono,monospace]" style="color: #1C1C1E;">{{ item.title }}</div>
32
- <div class="text-[10px] truncate" style="color: #6B7280;">{{ item.subtitle }}</div>
33
- </div>
34
- <StageBadge v-if="item.status" :status="item.status" size="sm" />
35
- </div>
36
- </div>
37
- </div>
38
-
39
- <!-- Footer -->
40
- <div class="px-4 py-2 flex items-center gap-4 text-[9px] font-mono-log" style="border-top: 1px solid #F0F0F3; color: #D1D1D6;">
41
- <span><kbd class="px-1 rounded-sm" style="background: #F0F0F3; border: 1px solid #F0F0F3;">↑↓</kbd> 导航</span>
42
- <span><kbd class="px-1 rounded-sm" style="background: #F0F0F3; border: 1px solid #F0F0F3;">↵</kbd> 打开</span>
43
- <span><kbd class="px-1 rounded-sm" style="background: #F0F0F3; border: 1px solid #F0F0F3;">esc</kbd> 关闭</span>
44
- </div>
45
- </div>
46
- </n-modal>
47
- </template>
48
-
49
- <script setup>
50
- import { ref, computed, watch, nextTick } from 'vue'
51
- import StageBadge from './StageBadge.vue'
52
-
53
- const props = defineProps({ isOpen: { type: Boolean, default: false }, projects: { type: Array, default: () => [] } })
54
- const emit = defineEmits(['close', 'select-project', 'select-stage'])
55
-
56
- const searchQuery = ref('')
57
- const searchInput = ref(null)
58
- const selectedIndex = ref(0)
59
-
60
- const stageNames = [
61
- { id: 'scan', name: '代码扫描' },
62
- { id: 'brainstorm', name: '头脑风暴' },
63
- { id: 'plan', name: '规划' },
64
- { id: 'execute', name: '执行' },
65
- { id: 'verify', name: '验证' },
66
- { id: 'archive', name: '归档' },
67
- { id: 'quick', name: '快速任务' },
68
- { id: 'explore', name: '自由探索' }
69
- ]
70
-
71
- const filteredItems = computed(() => {
72
- const items = []
73
- for (const project of props.projects) {
74
- const pm = !searchQuery.value || project.name.toLowerCase().includes(searchQuery.value.toLowerCase()) || project.path.toLowerCase().includes(searchQuery.value.toLowerCase())
75
- if (pm) items.push({ id: `project-${project.name}`, type: 'project', title: project.name, subtitle: project.path, data: project, status: getProjectStatus(project) })
76
- for (const stage of stageNames) {
77
- const sm = !searchQuery.value || stage.name.toLowerCase().includes(searchQuery.value.toLowerCase()) || stage.id.toLowerCase().includes(searchQuery.value.toLowerCase())
78
- if (sm || pm) items.push({ id: `stage-${project.name}-${stage.id}`, type: 'stage', title: `${project.name} / ${stage.name}`, subtitle: `Jump to ${stage.name}`, data: { project, stage: stage.id }, status: getStageStatus(project, stage.id) })
79
- }
80
- }
81
- return items
82
- })
83
-
84
- function getProjectStatus(p) { const s = p.state?.progress?.stages?.[p.state?.currentStage]?.steps || []; if (s.some(x => x.status === 'failed')) return 'failed'; if (s.some(x => x.status === 'in-progress')) return 'in-progress'; if (s.every(x => x.status === 'completed')) return 'completed'; return 'pending' }
85
- function getStageStatus(p, id) { const s = p.state?.progress?.stages?.[id]?.steps || []; if (!s.length) return 'pending'; if (s.some(x => x.status === 'failed')) return 'failed'; if (s.some(x => x.status === 'in-progress')) return 'in-progress'; if (s.every(x => x.status === 'completed')) return 'completed'; return 'pending' }
86
- function close() { searchQuery.value = ''; selectedIndex.value = 0; emit('close') }
87
- function selectItem(item) { if (item.type === 'project') emit('select-project', item.data); else emit('select-stage', item.data); close() }
88
- function handleKeydown(e) {
89
- if (e.key === 'ArrowDown') { e.preventDefault(); selectedIndex.value = Math.min(selectedIndex.value + 1, filteredItems.value.length - 1) }
90
- else if (e.key === 'ArrowUp') { e.preventDefault(); selectedIndex.value = Math.max(selectedIndex.value - 1, 0) }
91
- else if (e.key === 'Enter') { e.preventDefault(); if (filteredItems.value[selectedIndex.value]) selectItem(filteredItems.value[selectedIndex.value]) }
92
- else if (e.key === 'Escape') { e.preventDefault(); close() }
93
- }
94
- watch(filteredItems, () => { selectedIndex.value = 0 })
95
- watch(() => props.isOpen, (v) => { if (v) { nextTick(() => { searchInput.value?.focus() }) } })
96
- </script>
1
+ <template>
2
+ <n-modal :show="isOpen" @update:show="$emit('close')" :mask-closable="true" transform-origin="center" style="max-width: 480px;">
3
+ <div class="overflow-hidden rounded-md" style="background: #FFFFFF; border: 1px solid #E5E5EA; box-shadow: 0 25px 60px rgba(0,0,0,0.1);">
4
+ <!-- Search -->
5
+ <div class="px-4 py-3" style="border-bottom: 1px solid #F0F0F3;">
6
+ <n-input v-model:value="searchQuery" placeholder="搜索项目或命令..." ref="searchInput" @keydown="handleKeydown" size="small">
7
+ <template #prefix>
8
+ <svg class="w-3.5 h-3.5" style="color: #6B7280;" fill="none" stroke="currentColor" viewBox="0 0 24 24">
9
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
10
+ </svg>
11
+ </template>
12
+ </n-input>
13
+ </div>
14
+
15
+ <!-- Results -->
16
+ <div class="max-h-72 overflow-y-auto">
17
+ <n-empty v-if="filteredItems.length === 0" description="无结果" style="padding: 40px 0;" />
18
+ <div v-else class="py-0.5">
19
+ <div
20
+ v-for="(item, index) in filteredItems"
21
+ :key="item.id"
22
+ :class="['px-4 py-2.5 cursor-pointer transition-colors duration-100 flex items-center gap-3']"
23
+ :style="{ background: selectedIndex === index ? 'rgba(217,119,6,0.06)' : 'transparent' }"
24
+ @click="selectItem(item)"
25
+ @mouseenter="selectedIndex = index"
26
+ >
27
+ <div class="w-6 h-6 rounded-sm flex items-center justify-center text-[10px] font-[JetBrains_Mono,monospace] flex-shrink-0" style="background: #F0F0F3; border: 1px solid #F0F0F3; color: #6B7280;">
28
+ {{ item.type === 'project' ? '□' : '◇' }}
29
+ </div>
30
+ <div class="flex-1 min-w-0">
31
+ <div class="text-[12px] font-medium truncate font-[JetBrains_Mono,monospace]" style="color: #1C1C1E;">{{ item.title }}</div>
32
+ <div class="text-[10px] truncate" style="color: #6B7280;">{{ item.subtitle }}</div>
33
+ </div>
34
+ <StageBadge v-if="item.status" :status="item.status" size="sm" />
35
+ </div>
36
+ </div>
37
+ </div>
38
+
39
+ <!-- Footer -->
40
+ <div class="px-4 py-2 flex items-center gap-4 text-[9px] font-mono-log" style="border-top: 1px solid #F0F0F3; color: #D1D1D6;">
41
+ <span><kbd class="px-1 rounded-sm" style="background: #F0F0F3; border: 1px solid #F0F0F3;">↑↓</kbd> 导航</span>
42
+ <span><kbd class="px-1 rounded-sm" style="background: #F0F0F3; border: 1px solid #F0F0F3;">↵</kbd> 打开</span>
43
+ <span><kbd class="px-1 rounded-sm" style="background: #F0F0F3; border: 1px solid #F0F0F3;">esc</kbd> 关闭</span>
44
+ </div>
45
+ </div>
46
+ </n-modal>
47
+ </template>
48
+
49
+ <script setup>
50
+ import { ref, computed, watch, nextTick } from 'vue'
51
+ import StageBadge from './StageBadge.vue'
52
+
53
+ const props = defineProps({ isOpen: { type: Boolean, default: false }, projects: { type: Array, default: () => [] } })
54
+ const emit = defineEmits(['close', 'select-project', 'select-stage'])
55
+
56
+ const searchQuery = ref('')
57
+ const searchInput = ref(null)
58
+ const selectedIndex = ref(0)
59
+
60
+ const stageNames = [
61
+ { id: 'scan', name: '代码扫描' },
62
+ { id: 'brainstorm', name: '头脑风暴' },
63
+ { id: 'plan', name: '规划' },
64
+ { id: 'execute', name: '执行' },
65
+ { id: 'verify', name: '验证' },
66
+ { id: 'archive', name: '归档' },
67
+ { id: 'quick', name: '快速任务' },
68
+ { id: 'explore', name: '自由探索' }
69
+ ]
70
+
71
+ const filteredItems = computed(() => {
72
+ const items = []
73
+ for (const project of props.projects) {
74
+ const pm = !searchQuery.value || project.name.toLowerCase().includes(searchQuery.value.toLowerCase()) || project.path.toLowerCase().includes(searchQuery.value.toLowerCase())
75
+ if (pm) items.push({ id: `project-${project.name}`, type: 'project', title: project.name, subtitle: project.path, data: project, status: getProjectStatus(project) })
76
+ for (const stage of stageNames) {
77
+ const sm = !searchQuery.value || stage.name.toLowerCase().includes(searchQuery.value.toLowerCase()) || stage.id.toLowerCase().includes(searchQuery.value.toLowerCase())
78
+ if (sm || pm) items.push({ id: `stage-${project.name}-${stage.id}`, type: 'stage', title: `${project.name} / ${stage.name}`, subtitle: `Jump to ${stage.name}`, data: { project, stage: stage.id }, status: getStageStatus(project, stage.id) })
79
+ }
80
+ }
81
+ return items
82
+ })
83
+
84
+ function getProjectStatus(p) { const s = p.state?.progress?.stages?.[p.state?.currentStage]?.steps || []; if (s.some(x => x.status === 'failed')) return 'failed'; if (s.some(x => x.status === 'in-progress')) return 'in-progress'; if (s.every(x => x.status === 'completed')) return 'completed'; return 'pending' }
85
+ function getStageStatus(p, id) { const s = p.state?.progress?.stages?.[id]?.steps || []; if (!s.length) return 'pending'; if (s.some(x => x.status === 'failed')) return 'failed'; if (s.some(x => x.status === 'in-progress')) return 'in-progress'; if (s.every(x => x.status === 'completed')) return 'completed'; return 'pending' }
86
+ function close() { searchQuery.value = ''; selectedIndex.value = 0; emit('close') }
87
+ function selectItem(item) { if (item.type === 'project') emit('select-project', item.data); else emit('select-stage', item.data); close() }
88
+ function handleKeydown(e) {
89
+ if (e.key === 'ArrowDown') { e.preventDefault(); selectedIndex.value = Math.min(selectedIndex.value + 1, filteredItems.value.length - 1) }
90
+ else if (e.key === 'ArrowUp') { e.preventDefault(); selectedIndex.value = Math.max(selectedIndex.value - 1, 0) }
91
+ else if (e.key === 'Enter') { e.preventDefault(); if (filteredItems.value[selectedIndex.value]) selectItem(filteredItems.value[selectedIndex.value]) }
92
+ else if (e.key === 'Escape') { e.preventDefault(); close() }
93
+ }
94
+ watch(filteredItems, () => { selectedIndex.value = 0 })
95
+ watch(() => props.isOpen, (v) => { if (v) { nextTick(() => { searchInput.value?.focus() }) } })
96
+ </script>