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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
import { useState, useEffect } from "react";
import type { AutonomyLevel, RepositoryHistoryEntry } from "../../lib/api";
import { getRepositorySuggestions } from "../../lib/api";
interface CreateDirectiveModalProps {
onSubmit: (goal: string, repositoryUrl: string | undefined, autonomyLevel: AutonomyLevel) => void;
onCancel: () => void;
}
export function CreateDirectiveModal({ onSubmit, onCancel }: CreateDirectiveModalProps) {
const [goal, setGoal] = useState("");
const [repositoryUrl, setRepositoryUrl] = useState("");
const [autonomyLevel, setAutonomyLevel] = useState<AutonomyLevel>("guardrails");
const [suggestions, setSuggestions] = useState<RepositoryHistoryEntry[]>([]);
const [showSuggestions, setShowSuggestions] = useState(false);
// Load suggestions
useEffect(() => {
getRepositorySuggestions("remote", undefined, 5)
.then((res) => {
setSuggestions(res.entries);
})
.catch(() => {
setSuggestions([]);
});
}, []);
const handleSubmit = () => {
if (goal.trim()) {
onSubmit(goal.trim(), repositoryUrl.trim() || undefined, autonomyLevel);
}
};
return (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4">
<div className="w-full max-w-lg p-6 bg-[#0a1628] border border-[rgba(117,170,252,0.3)] max-h-[90vh] overflow-y-auto">
<h3 className="font-mono text-sm text-[#75aafc] uppercase mb-4">
Create Directive
</h3>
<div className="space-y-4">
{/* Goal */}
<div>
<label className="block font-mono text-xs text-[#8b949e] uppercase mb-1">
Goal *
</label>
<textarea
value={goal}
onChange={(e) => setGoal(e.target.value)}
placeholder="Describe what you want to accomplish..."
rows={3}
className="w-full px-3 py-2 bg-[#0d1b2d] border border-[#3f6fb3] text-[#dbe7ff] font-mono text-sm focus:outline-none focus:border-[#75aafc] resize-none"
autoFocus
/>
</div>
{/* Repository URL */}
<div>
<label className="block font-mono text-xs text-[#8b949e] uppercase mb-1">
Repository URL (optional)
</label>
<div className="relative">
<input
type="text"
value={repositoryUrl}
onChange={(e) => setRepositoryUrl(e.target.value)}
onFocus={() => suggestions.length > 0 && setShowSuggestions(true)}
onBlur={() => setTimeout(() => setShowSuggestions(false), 200)}
placeholder="https://github.com/owner/repo"
className="w-full px-3 py-2 bg-[#0d1b2d] border border-[#3f6fb3] text-[#dbe7ff] font-mono text-sm focus:outline-none focus:border-[#75aafc]"
/>
{showSuggestions && suggestions.length > 0 && (
<div className="absolute top-full left-0 right-0 mt-1 border border-[rgba(117,170,252,0.2)] bg-[#0a1525] max-h-32 overflow-y-auto z-10">
{suggestions.map((s) => (
<button
key={s.id}
type="button"
onClick={() => {
setRepositoryUrl(s.repositoryUrl || "");
setShowSuggestions(false);
}}
className="w-full text-left px-3 py-2 font-mono text-xs hover:bg-[rgba(117,170,252,0.1)] border-b border-[rgba(117,170,252,0.1)] last:border-b-0"
>
<div className="text-[#9bc3ff] truncate">{s.name}</div>
<div className="text-[10px] text-[#556677] truncate">{s.repositoryUrl}</div>
</button>
))}
</div>
)}
</div>
</div>
{/* Autonomy Level */}
<div>
<label className="block font-mono text-xs text-[#8b949e] uppercase mb-2">
Autonomy Level
</label>
<div className="flex gap-2">
{(["full_auto", "guardrails", "manual"] as const).map((level) => (
<button
key={level}
type="button"
onClick={() => setAutonomyLevel(level)}
className={`flex-1 px-3 py-2 font-mono text-xs uppercase ${
autonomyLevel === level
? "text-[#dbe7ff] bg-[#0f3c78] border border-[#3f6fb3]"
: "text-[#556677] border border-[rgba(117,170,252,0.2)] hover:border-[#3f6fb3]"
}`}
>
{level.replace("_", " ")}
</button>
))}
</div>
<p className="font-mono text-[10px] text-[#556677] mt-1">
{autonomyLevel === "full_auto" && "Automatic progression without approval gates"}
{autonomyLevel === "guardrails" && "Request approval for yellow/red confidence scores"}
{autonomyLevel === "manual" && "Request approval for all step completions"}
</p>
</div>
<p className="font-mono text-xs text-[#8b949e]">
A directive is a top-level goal that generates a chain of steps. Each step spawns
contracts that are verified before progression.
</p>
{/* Actions */}
<div className="flex gap-2 justify-end pt-2">
<button
onClick={onCancel}
className="px-4 py-2 font-mono text-xs text-[#9bc3ff] hover:text-[#dbe7ff] transition-colors"
>
Cancel
</button>
<button
onClick={handleSubmit}
disabled={!goal.trim()}
className="px-4 py-2 font-mono text-xs text-[#dbe7ff] bg-[#0f3c78] border border-[#3f6fb3] hover:bg-[#153667] transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
>
Create
</button>
</div>
</div>
</div>
</div>
);
}
|