1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
import type { ContractPhase, ContractWithRelations } from "../../lib/api";
interface PhaseHintProps {
contract: ContractWithRelations;
onAdvancePhase: (phase: ContractPhase) => void;
}
const phaseOrder: ContractPhase[] = ["research", "specify", "plan", "execute", "review"];
interface HintConfig {
condition: (contract: ContractWithRelations) => boolean;
message: (contract: ContractWithRelations) => string;
nextPhase: ContractPhase;
}
const phaseHints: Record<ContractPhase, HintConfig | null> = {
research: {
condition: (c) => c.files.length >= 1,
message: (c) =>
`You have ${c.files.length} file${c.files.length === 1 ? "" : "s"}. Ready to specify requirements?`,
nextPhase: "specify",
},
specify: {
condition: (c) => c.files.length >= 2,
message: () => "Spec files ready. Create implementation plan?",
nextPhase: "plan",
},
plan: {
condition: (c) => c.files.length >= 1 && c.repositories.length >= 1,
message: () => "Plan documented. Ready to create tasks?",
nextPhase: "execute",
},
execute: {
condition: (c) => {
// Show hint only when all tasks are complete
const doneTasks = c.tasks.filter(
(t) => t.status === "done" || t.status === "merged"
);
return c.tasks.length > 0 && doneTasks.length === c.tasks.length;
},
message: (c) => {
const doneTasks = c.tasks.filter(
(t) => t.status === "done" || t.status === "merged"
);
return `All ${doneTasks.length} task${doneTasks.length === 1 ? "" : "s"} complete. Ready for review?`;
},
nextPhase: "review",
},
review: null, // No hint for review phase - it's the final phase
};
export function PhaseHint({ contract, onAdvancePhase }: PhaseHintProps) {
const hintConfig = phaseHints[contract.phase];
// No hint for this phase
if (!hintConfig) return null;
// Condition not met
if (!hintConfig.condition(contract)) return null;
return (
<div className="flex items-center gap-3 p-3 bg-[rgba(117,170,252,0.05)] border border-[rgba(117,170,252,0.2)]">
<span className="font-mono text-xs text-[#9bc3ff]">
{hintConfig.message(contract)}
</span>
<button
onClick={() => onAdvancePhase(hintConfig.nextPhase)}
className="px-3 py-1 font-mono text-xs text-[#dbe7ff] bg-[#0f3c78] border border-[#3f6fb3] hover:bg-[#153667] transition-colors uppercase whitespace-nowrap"
>
Advance to {hintConfig.nextPhase}
</button>
</div>
);
}
export function getNextPhase(currentPhase: ContractPhase): ContractPhase | null {
const currentIndex = phaseOrder.indexOf(currentPhase);
if (currentIndex === -1 || currentIndex === phaseOrder.length - 1) {
return null;
}
return phaseOrder[currentIndex + 1];
}
export function getPreviousPhase(currentPhase: ContractPhase): ContractPhase | null {
const currentIndex = phaseOrder.indexOf(currentPhase);
if (currentIndex <= 0) {
return null;
}
return phaseOrder[currentIndex - 1];
}
|