Skip to content

Commit 2487a83

Browse files
author
catlog22
committed
feat: 更新分析会话 API,支持分页和并发处理
1 parent a94c790 commit 2487a83

6 files changed

Lines changed: 196 additions & 95 deletions

File tree

.claude/skills/team-lifecycle-v3/SKILL.md

Lines changed: 102 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,22 @@ Parse `$ARGUMENTS` to extract `--role`. If absent → Orchestration Mode (auto r
4343

4444
### Role Registry
4545

46-
| Role | File | Task Prefix | Type |
47-
|------|------|-------------|------|
48-
| coordinator | roles/coordinator/role.md | (none) | orchestrator |
49-
| analyst | roles/analyst/role.md | RESEARCH-* | pipeline |
50-
| writer | roles/writer/role.md | DRAFT-* | pipeline |
51-
| discussant | roles/discussant/role.md | DISCUSS-* | pipeline |
52-
| planner | roles/planner/role.md | PLAN-* | pipeline |
53-
| executor | roles/executor/role.md | IMPL-* | pipeline |
54-
| tester | roles/tester/role.md | TEST-* | pipeline |
55-
| reviewer | roles/reviewer/role.md | REVIEW-* + QUALITY-* | pipeline |
56-
| explorer | roles/explorer/role.md | EXPLORE-* | service (on-demand) |
57-
| architect | roles/architect/role.md | ARCH-* | consulting (on-demand) |
58-
| fe-developer | roles/fe-developer/role.md | DEV-FE-* | frontend pipeline |
59-
| fe-qa | roles/fe-qa/role.md | QA-FE-* | frontend pipeline |
46+
| Role | File | Task Prefix | Type | Compact |
47+
|------|------|-------------|------|---------|
48+
| coordinator | [roles/coordinator/role.md](roles/coordinator/role.md) | (none) | orchestrator | **⚠️ 压缩后必须重读** |
49+
| analyst | [roles/analyst/role.md](roles/analyst/role.md) | RESEARCH-* | pipeline | 压缩后必须重读 |
50+
| writer | [roles/writer/role.md](roles/writer/role.md) | DRAFT-* | pipeline | 压缩后必须重读 |
51+
| discussant | [roles/discussant/role.md](roles/discussant/role.md) | DISCUSS-* | pipeline | 压缩后必须重读 |
52+
| planner | [roles/planner/role.md](roles/planner/role.md) | PLAN-* | pipeline | 压缩后必须重读 |
53+
| executor | [roles/executor/role.md](roles/executor/role.md) | IMPL-* | pipeline | 压缩后必须重读 |
54+
| tester | [roles/tester/role.md](roles/tester/role.md) | TEST-* | pipeline | 压缩后必须重读 |
55+
| reviewer | [roles/reviewer/role.md](roles/reviewer/role.md) | REVIEW-* + QUALITY-* | pipeline | 压缩后必须重读 |
56+
| explorer | [roles/explorer/role.md](roles/explorer/role.md) | EXPLORE-* | service (on-demand) | 压缩后必须重读 |
57+
| architect | [roles/architect/role.md](roles/architect/role.md) | ARCH-* | consulting (on-demand) | 压缩后必须重读 |
58+
| fe-developer | [roles/fe-developer/role.md](roles/fe-developer/role.md) | DEV-FE-* | frontend pipeline | 压缩后必须重读 |
59+
| fe-qa | [roles/fe-qa/role.md](roles/fe-qa/role.md) | QA-FE-* | frontend pipeline | 压缩后必须重读 |
60+
61+
> **⚠️ COMPACT PROTECTION**: 角色文件是执行文档,不是参考资料。当 context compression 发生后,角色指令仅剩摘要时,**必须立即 `Read` 对应 role.md 重新加载后再继续执行**。不得基于摘要执行任何 Phase。
6062
6163
### Dispatch
6264

@@ -179,6 +181,86 @@ Fullstack: PLAN-001 → IMPL-001 ∥ DEV-FE-001 → TEST-001 ∥ QA-FE-001
179181
Full + FE: [Spec pipeline] → PLAN-001 → IMPL-001 ∥ DEV-FE-001 → TEST-001 ∥ QA-FE-001 → REVIEW-001
180182
```
181183

184+
### Cadence Control
185+
186+
**节拍模型**: 事件驱动,每个 beat = coordinator 唤醒 → 处理 → spawn → STOP。
187+
188+
```
189+
Beat Cycle (单次节拍)
190+
═══════════════════════════════════════════════════════════
191+
Event Coordinator Workers
192+
───────────────────────────────────────────────────────────
193+
callback/resume ──→ ┌─ handleCallback ─┐
194+
│ mark completed │
195+
│ check pipeline │
196+
├─ handleSpawnNext ─┤
197+
│ find ready tasks │
198+
│ spawn workers ───┼──→ [Worker A] Phase 1-5
199+
│ (parallel OK) ──┼──→ [Worker B] Phase 1-5
200+
└─ STOP (idle) ─────┘ │
201+
202+
callback ←─────────────────────────────────────────┘
203+
(next beat) SendMessage + TaskUpdate(completed)
204+
═══════════════════════════════════════════════════════════
205+
```
206+
207+
**Pipeline 节拍视图**:
208+
209+
```
210+
Spec-only (12 beats, 严格串行)
211+
──────────────────────────────────────────────────────────
212+
Beat 1 2 3 4 5 6 7 8 9 10 11 12
213+
│ │ │ │ │ │ │ │ │ │ │ │
214+
R1 → D1 → W1 → D2 → W2 → D3 → W3 → D4 → W4 → D5 → Q1 → D6
215+
▲ ▲
216+
pipeline sign-off
217+
start pause
218+
219+
R=RESEARCH D=DISCUSS W=DRAFT(writer) Q=QUALITY
220+
221+
Impl-only (3 beats, 含并行窗口)
222+
──────────────────────────────────────────────────────────
223+
Beat 1 2 3
224+
│ │ ┌────┴────┐
225+
PLAN → IMPL ──→ TEST ∥ REVIEW ← 并行窗口
226+
└────┬────┘
227+
pipeline
228+
done
229+
230+
Full-lifecycle (15 beats, spec→impl 过渡含检查点)
231+
──────────────────────────────────────────────────────────
232+
Beat 1-12: [Spec pipeline 同上]
233+
234+
Beat 12 (D6 完成): ⏸ CHECKPOINT ── 用户确认后 resume
235+
236+
Beat 13 14 15
237+
PLAN → IMPL → TEST ∥ REVIEW
238+
239+
Fullstack (含双并行窗口)
240+
──────────────────────────────────────────────────────────
241+
Beat 1 2 3 4
242+
│ ┌────┴────┐ ┌────┴────┐ │
243+
PLAN → IMPL ∥ DEV-FE → TEST ∥ QA-FE → REVIEW
244+
▲ ▲ ▲
245+
并行窗口 1 并行窗口 2 同步屏障
246+
```
247+
248+
**检查点 (Checkpoint)**:
249+
250+
| 触发条件 | 位置 | 行为 |
251+
|----------|------|------|
252+
| Spec→Impl 过渡 | DISCUSS-006 完成后 | ⏸ 暂停,等待用户 `resume` 确认 |
253+
| GC 循环上限 | QA-FE max 2 rounds | 超出轮次 → 停止迭代,报告当前状态 |
254+
| Pipeline 停滞 | 无 ready + 无 running | 检查缺失任务,报告用户 |
255+
256+
**Stall 检测** (coordinator `handleCheck` 时执行):
257+
258+
| 检查项 | 条件 | 处理 |
259+
|--------|------|------|
260+
| Worker 无响应 | in_progress 任务无回调 | 报告等待中的任务列表,建议用户 `resume` |
261+
| Pipeline 死锁 | 无 ready + 无 running + 有 pending | 检查 blockedBy 依赖链,报告卡点 |
262+
| GC 循环超限 | DEV-FE / QA-FE 迭代 > max_rounds | 终止循环,输出最新 QA 报告 |
263+
182264
### Task Metadata Registry
183265

184266
| Task ID | Role | Phase | Dependencies | Description |
@@ -282,12 +364,12 @@ Coordinator supports `--resume` / `--continue` for interrupted sessions:
282364

283365
| Resource | Path | Usage |
284366
|----------|------|-------|
285-
| Document Standards | specs/document-standards.md | YAML frontmatter, naming, structure |
286-
| Quality Gates | specs/quality-gates.md | Per-phase quality gates |
287-
| Product Brief Template | templates/product-brief.md | DRAFT-001 |
288-
| Requirements Template | templates/requirements-prd.md | DRAFT-002 |
289-
| Architecture Template | templates/architecture-doc.md | DRAFT-003 |
290-
| Epics Template | templates/epics-template.md | DRAFT-004 |
367+
| Document Standards | [specs/document-standards.md](specs/document-standards.md) | YAML frontmatter, naming, structure |
368+
| Quality Gates | [specs/quality-gates.md](specs/quality-gates.md) | Per-phase quality gates |
369+
| Product Brief Template | [templates/product-brief.md](templates/product-brief.md) | DRAFT-001 |
370+
| Requirements Template | [templates/requirements-prd.md](templates/requirements-prd.md) | DRAFT-002 |
371+
| Architecture Template | [templates/architecture-doc.md](templates/architecture-doc.md) | DRAFT-003 |
372+
| Epics Template | [templates/epics-template.md](templates/epics-template.md) | DRAFT-004 |
291373

292374
## Error Handling
293375

.claude/skills/workflow-lite-plan/SKILL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,6 @@ Plan mode and execute mode are triggered by skill name routing (see Mode Detecti
189189
| Phase | Document | Purpose | Compact |
190190
|-------|----------|---------|---------|
191191
| 1 | [phases/01-lite-plan.md](phases/01-lite-plan.md) | Complete planning pipeline: exploration, clarification, planning, confirmation, handoff | Phase 1 完成后可压缩 |
192-
| 2 | [phases/02-lite-execute.md](phases/02-lite-execute.md) | Complete execution engine: input modes, task grouping, batch execution, code review | **⚠️ 执行期间禁止压缩,压缩后必须重读** |
192+
| 2 | [phases/02-lite-execute.md](phases/02-lite-execute.md) | Complete execution engine: input modes, task grouping, batch execution, code review | **⚠️ 压缩时必须完整保留,若仅剩摘要须重读** |
193193

194-
**Phase 2 Compact Rule**: Phase 2 是执行引擎,包含 Step 1-6 的完整执行协议。如果 compact 发生且 Phase 2 内容仅剩摘要**必须立即 `Read("phases/02-lite-execute.md")` 重新加载后再继续执行**。不得基于摘要执行任何 Step。
194+
**Phase 2 Compact Rule**: Phase 2 是执行引擎,包含 Step 1-6 的完整执行协议。compact 压缩时必须完整保留 Phase 2 内容。若 compact Phase 2 仅剩摘要**必须立即 `Read("phases/02-lite-execute.md")` 重新加载后再继续执行**。不得基于摘要执行任何 Step。

.claude/skills/workflow-skill-designer/SKILL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ Multi-phase workflows span long conversations. Context compression (compact) may
174174
| Phase | Document | Purpose | Compact |
175175
|-------|----------|---------|---------|
176176
| 1 | phases/01-xxx.md | Planning pipeline | Phase 1 完成后可压缩 |
177-
| 2 | phases/02-xxx.md | Execution engine | **⚠️ 执行期间禁止压缩,压缩后必须重读** |
177+
| 2 | phases/02-xxx.md | Execution engine | **⚠️ 压缩时必须完整保留,若仅剩摘要须重读** |
178178

179-
**Phase N Compact Rule**: Phase N 是执行引擎,包含 Step 1-M 的完整执行协议。如果 compact 发生且 Phase N 内容仅剩摘要**必须立即 `Read("phases/0N-xxx.md")` 重新加载后再继续执行**。不得基于摘要执行任何 Step。
179+
**Phase N Compact Rule**: Phase N 是执行引擎,包含 Step 1-M 的完整执行协议。compact 压缩时必须完整保留 Phase N 内容。若 compact 后仅剩摘要**必须立即 `Read("phases/0N-xxx.md")` 重新加载后再继续执行**。不得基于摘要执行任何 Step。
180180
```
181181

182182
**Phase 文件顶部** — Compact Protection directive:

ccw/frontend/src/lib/api.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7141,11 +7141,19 @@ import type { AnalysisSessionSummary, AnalysisSessionDetail } from '../types/ana
71417141
* Fetch list of analysis sessions
71427142
*/
71437143
export async function fetchAnalysisSessions(
7144-
projectPath?: string
7144+
projectPath?: string,
7145+
options?: { limit?: number; offset?: number }
71457146
): Promise<AnalysisSessionSummary[]> {
7146-
const data = await fetchApi<{ success: boolean; data: AnalysisSessionSummary[]; error?: string }>(
7147-
withPath('/api/analysis', projectPath)
7148-
);
7147+
const params = new URLSearchParams();
7148+
if (options?.limit) params.set('limit', String(options.limit));
7149+
if (options?.offset) params.set('offset', String(options.offset));
7150+
7151+
const queryString = params.toString();
7152+
const path = queryString
7153+
? `${withPath('/api/analysis', projectPath)}&${queryString}`
7154+
: withPath('/api/analysis', projectPath);
7155+
7156+
const data = await fetchApi<{ success: boolean; data: AnalysisSessionSummary[]; error?: string }>(path);
71497157
if (!data.success) {
71507158
throw new Error(data.error || 'Failed to fetch analysis sessions');
71517159
}

ccw/frontend/src/pages/AnalysisPage.tsx

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ import { Card } from '@/components/ui/Card';
2424
import { Input } from '@/components/ui/Input';
2525
import { Badge } from '@/components/ui/Badge';
2626
import { Button } from '@/components/ui/Button';
27-
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/Tabs';
27+
import { TabsNavigation } from '@/components/ui/TabsNavigation';
2828
import { fetchAnalysisSessions, fetchAnalysisDetail } from '@/lib/api';
2929
import { MessageRenderer } from '@/components/shared/CliStreamMonitor/MessageRenderer';
3030
import { JsonCardView } from '@/components/shared/JsonCardView';
31+
import { cn } from '@/lib/utils';
3132
import type { AnalysisSessionSummary } from '@/types/analysis';
3233

3334
// ========== Session Card Component ==========
@@ -41,23 +42,22 @@ interface SessionCardProps {
4142
function SessionCard({ session, onClick, isSelected }: SessionCardProps) {
4243
return (
4344
<Card
44-
className={`p-4 cursor-pointer transition-colors ${
45-
isSelected ? 'ring-2 ring-primary bg-accent/50' : 'hover:bg-accent/50'
46-
}`}
45+
className={cn(
46+
'p-4 cursor-pointer transition-all hover:shadow-md',
47+
isSelected && 'ring-2 ring-primary'
48+
)}
4749
onClick={onClick}
4850
>
49-
<div className="flex items-start justify-between">
50-
<div className="flex-1 min-w-0">
51-
<div className="flex items-center gap-2 mb-1">
52-
<FileSearch className="w-4 h-4 text-muted-foreground" />
53-
<span className="font-medium truncate">{session.topic}</span>
54-
</div>
55-
<p className="text-sm text-muted-foreground truncate">{session.id}</p>
51+
<div className="flex items-start justify-between mb-3">
52+
<div className="flex items-center gap-2 flex-1 min-w-0">
53+
<FileSearch className="w-5 h-5 text-primary flex-shrink-0" />
54+
<h3 className="font-medium text-foreground truncate">{session.topic}</h3>
5655
</div>
5756
<ChevronRight className="w-4 h-4 text-muted-foreground flex-shrink-0" />
5857
</div>
59-
<div className="flex items-center gap-3 mt-3">
60-
<Badge variant={session.status === 'completed' ? 'default' : 'secondary'}>
58+
<p className="text-sm text-muted-foreground truncate mb-3">{session.id}</p>
59+
<div className="flex items-center gap-3">
60+
<Badge variant={session.status === 'completed' ? 'success' : 'warning'}>
6161
{session.status === 'completed' ? (
6262
<><CheckCircle className="w-3 h-3 mr-1" />完成</>
6363
) : (
@@ -82,6 +82,8 @@ interface DetailPanelProps {
8282
}
8383

8484
function DetailPanel({ sessionId, projectPath, onClose }: DetailPanelProps) {
85+
const [activeTab, setActiveTab] = useState('discussion');
86+
8587
const { data: detail, isLoading, error } = useQuery({
8688
queryKey: ['analysis-detail', sessionId, projectPath],
8789
queryFn: () => fetchAnalysisDetail(sessionId, projectPath),
@@ -110,13 +112,20 @@ function DetailPanel({ sessionId, projectPath, onClose }: DetailPanelProps) {
110112

111113
// Build available tabs based on content
112114
const tabs = [
113-
{ id: 'discussion', label: '讨论记录', icon: MessageSquare, content: detail.discussion },
114-
{ id: 'conclusions', label: '结论', icon: CheckCircle, content: detail.conclusions },
115-
{ id: 'explorations', label: '代码探索', icon: Code, content: detail.explorations },
116-
{ id: 'perspectives', label: '视角分析', icon: FileText, content: detail.perspectives },
117-
].filter(tab => tab.content);
115+
{ value: 'discussion', label: '讨论记录', icon: <MessageSquare className="w-4 h-4" /> },
116+
{ value: 'conclusions', label: '结论', icon: <CheckCircle className="w-4 h-4" /> },
117+
{ value: 'explorations', label: '代码探索', icon: <Code className="w-4 h-4" /> },
118+
{ value: 'perspectives', label: '视角分析', icon: <FileText className="w-4 h-4" /> },
119+
].filter(tab => {
120+
const key = tab.value as keyof typeof detail;
121+
return detail[key];
122+
});
118123

119-
const defaultTab = tabs[0]?.id || 'discussion';
124+
// Ensure activeTab is valid
125+
const validTab = tabs.find(t => t.value === activeTab);
126+
if (!validTab && tabs.length > 0) {
127+
setActiveTab(tabs[0].value);
128+
}
120129

121130
return (
122131
<div className="h-full flex flex-col">
@@ -138,46 +147,35 @@ function DetailPanel({ sessionId, projectPath, onClose }: DetailPanelProps) {
138147

139148
{/* Tabs Content */}
140149
{tabs.length > 0 ? (
141-
<Tabs defaultValue={defaultTab} className="flex-1 flex flex-col min-h-0">
142-
<TabsList className="mx-4 mt-4 shrink-0 w-fit">
143-
{tabs.map(tab => (
144-
<TabsTrigger key={tab.id} value={tab.id} className="gap-1.5">
145-
<tab.icon className="w-3.5 h-3.5" />
146-
{tab.label}
147-
</TabsTrigger>
148-
))}
149-
</TabsList>
150-
150+
<>
151+
<TabsNavigation
152+
value={activeTab}
153+
onValueChange={setActiveTab}
154+
tabs={tabs}
155+
className="px-4"
156+
/>
151157
<div className="flex-1 overflow-auto min-h-0 p-4">
152158
{/* Discussion Tab */}
153-
<TabsContent value="discussion" className="mt-0 h-full">
154-
{detail.discussion && (
155-
<MessageRenderer content={detail.discussion} format="markdown" />
156-
)}
157-
</TabsContent>
159+
{activeTab === 'discussion' && detail.discussion && (
160+
<MessageRenderer content={detail.discussion} format="markdown" />
161+
)}
158162

159163
{/* Conclusions Tab */}
160-
<TabsContent value="conclusions" className="mt-0 h-full">
161-
{detail.conclusions && (
162-
<JsonCardView data={detail.conclusions} />
163-
)}
164-
</TabsContent>
164+
{activeTab === 'conclusions' && detail.conclusions && (
165+
<JsonCardView data={detail.conclusions} />
166+
)}
165167

166168
{/* Explorations Tab */}
167-
<TabsContent value="explorations" className="mt-0 h-full">
168-
{detail.explorations && (
169-
<JsonCardView data={detail.explorations} />
170-
)}
171-
</TabsContent>
169+
{activeTab === 'explorations' && detail.explorations && (
170+
<JsonCardView data={detail.explorations} />
171+
)}
172172

173173
{/* Perspectives Tab */}
174-
<TabsContent value="perspectives" className="mt-0 h-full">
175-
{detail.perspectives && (
176-
<JsonCardView data={detail.perspectives} />
177-
)}
178-
</TabsContent>
174+
{activeTab === 'perspectives' && detail.perspectives && (
175+
<JsonCardView data={detail.perspectives} />
176+
)}
179177
</div>
180-
</Tabs>
178+
</>
181179
) : (
182180
<div className="flex-1 flex items-center justify-center text-muted-foreground">
183181
暂无分析内容
@@ -210,14 +208,16 @@ export function AnalysisPage() {
210208
{/* Left Panel - List */}
211209
<div className={`p-6 space-y-6 overflow-auto ${selectedSession ? 'w-[400px] shrink-0' : 'flex-1'}`}>
212210
{/* Header */}
213-
<div>
214-
<h1 className="text-2xl font-bold flex items-center gap-2">
215-
<FileSearch className="w-6 h-6" />
216-
Analysis Viewer
217-
</h1>
218-
<p className="text-muted-foreground mt-1">
219-
查看 /workflow:analyze-with-file 命令的分析结果
220-
</p>
211+
<div className="flex items-center gap-2">
212+
<FileSearch className="w-6 h-6 text-primary" />
213+
<div>
214+
<h1 className="text-2xl font-semibold text-foreground">
215+
Analysis Viewer
216+
</h1>
217+
<p className="text-sm text-muted-foreground mt-1">
218+
查看 /workflow:analyze-with-file 命令的分析结果
219+
</p>
220+
</div>
221221
</div>
222222

223223
{/* Search */}

0 commit comments

Comments
 (0)