rax-flow 0.1.7 → 0.1.8

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 (36) hide show
  1. package/dist/tui/App.d.ts.map +1 -1
  2. package/dist/tui/App.js +35 -3
  3. package/dist/tui/App.js.map +1 -1
  4. package/dist/tui/components/ChatPanel.d.ts +2 -1
  5. package/dist/tui/components/ChatPanel.d.ts.map +1 -1
  6. package/dist/tui/components/ChatPanel.js +3 -2
  7. package/dist/tui/components/ChatPanel.js.map +1 -1
  8. package/dist/tui/components/DAGPanel.d.ts +24 -0
  9. package/dist/tui/components/DAGPanel.d.ts.map +1 -0
  10. package/dist/tui/components/DAGPanel.js +30 -0
  11. package/dist/tui/components/DAGPanel.js.map +1 -0
  12. package/dist/tui/components/Header.d.ts +3 -1
  13. package/dist/tui/components/Header.d.ts.map +1 -1
  14. package/dist/tui/components/Header.js +11 -3
  15. package/dist/tui/components/Header.js.map +1 -1
  16. package/dist/tui/components/HelpOverlay.d.ts +6 -0
  17. package/dist/tui/components/HelpOverlay.d.ts.map +1 -0
  18. package/dist/tui/components/HelpOverlay.js +42 -0
  19. package/dist/tui/components/HelpOverlay.js.map +1 -0
  20. package/dist/tui/components/StatusPanel.d.ts +2 -1
  21. package/dist/tui/components/StatusPanel.d.ts.map +1 -1
  22. package/dist/tui/components/StatusPanel.js +7 -6
  23. package/dist/tui/components/StatusPanel.js.map +1 -1
  24. package/dist/tui/hooks/useAppState.d.ts +17 -0
  25. package/dist/tui/hooks/useAppState.d.ts.map +1 -1
  26. package/dist/tui/hooks/useAppState.js +91 -28
  27. package/dist/tui/hooks/useAppState.js.map +1 -1
  28. package/package.json +1 -1
  29. package/src/tui/App.tsx +71 -19
  30. package/src/tui/components/ChatPanel.tsx +8 -4
  31. package/src/tui/components/DAGPanel.tsx +116 -0
  32. package/src/tui/components/Header.tsx +42 -19
  33. package/src/tui/components/HelpOverlay.tsx +83 -0
  34. package/src/tui/components/StatusPanel.tsx +13 -8
  35. package/src/tui/hooks/useAppState.ts +124 -28
  36. package/tsconfig.tsbuildinfo +1 -1
@@ -21,6 +21,25 @@ interface Provider {
21
21
  latency: number;
22
22
  }
23
23
 
24
+ interface DAGNode {
25
+ id: string;
26
+ name: string;
27
+ status: "pending" | "running" | "done" | "error";
28
+ agent?: string;
29
+ }
30
+
31
+ interface DAGLevel {
32
+ name: string;
33
+ progress: number;
34
+ nodes: DAGNode[];
35
+ }
36
+
37
+ interface WorkflowState {
38
+ levels: DAGLevel[];
39
+ currentLevel: number;
40
+ totalProgress: number;
41
+ }
42
+
24
43
  interface AppState {
25
44
  projectName: string;
26
45
  agentCount: number;
@@ -33,6 +52,7 @@ interface AppState {
33
52
  currentWorkflow: string | null;
34
53
  suggestions: string[];
35
54
  isProcessing: boolean;
55
+ workflowState: WorkflowState;
36
56
  }
37
57
 
38
58
  const COMMAND_SUGGESTIONS = [
@@ -58,6 +78,38 @@ const DEFAULT_PROVIDERS: Provider[] = [
58
78
  { name: "Anthropic", status: "idle", latency: 0 },
59
79
  ];
60
80
 
81
+ const DEFAULT_WORKFLOW_STATE: WorkflowState = {
82
+ levels: [
83
+ {
84
+ name: "L1: SPEC",
85
+ progress: 0,
86
+ nodes: [
87
+ { id: "intent", name: "IntentClassifier", status: "pending", agent: "H" },
88
+ { id: "spec", name: "SpecAgent", status: "pending", agent: "H" },
89
+ { id: "arch", name: "ArchitectureAgent", status: "pending", agent: "H" },
90
+ ],
91
+ },
92
+ {
93
+ name: "L2: CODE",
94
+ progress: 0,
95
+ nodes: [
96
+ { id: "task", name: "TaskPlanner", status: "pending", agent: "H" },
97
+ { id: "codegen", name: "CodeGenerator", status: "pending", agent: "H" },
98
+ ],
99
+ },
100
+ {
101
+ name: "L3: TEST",
102
+ progress: 0,
103
+ nodes: [
104
+ { id: "test", name: "TestAgent", status: "pending", agent: "H" },
105
+ { id: "fix", name: "FixAgent", status: "pending", agent: "H" },
106
+ ],
107
+ },
108
+ ],
109
+ currentLevel: 0,
110
+ totalProgress: 0,
111
+ };
112
+
61
113
  function generateId(): string {
62
114
  return Math.random().toString(36).slice(2, 9);
63
115
  }
@@ -82,6 +134,7 @@ export function useAppState() {
82
134
  currentWorkflow: null,
83
135
  suggestions: COMMAND_SUGGESTIONS,
84
136
  isProcessing: false,
137
+ workflowState: DEFAULT_WORKFLOW_STATE,
85
138
  });
86
139
 
87
140
  const addMessage = useCallback((type: Message["type"], content: string, agent?: string) => {
@@ -94,6 +147,37 @@ export function useAppState() {
94
147
  }));
95
148
  }, []);
96
149
 
150
+ const updateWorkflowProgress = useCallback((level: number, nodeIndex: number, status: DAGNode["status"]) => {
151
+ setState((prev: AppState) => {
152
+ const newLevels = prev.workflowState.levels.map((l, i) => {
153
+ if (i !== level) return l;
154
+ const newNodes = l.nodes.map((n, j) =>
155
+ j === nodeIndex ? { ...n, status } : n
156
+ );
157
+ const doneCount = newNodes.filter((n) => n.status === "done").length;
158
+ return {
159
+ ...l,
160
+ nodes: newNodes,
161
+ progress: Math.round((doneCount / newNodes.length) * 100),
162
+ };
163
+ });
164
+
165
+ const totalDone = newLevels.reduce((acc, l) =>
166
+ acc + l.nodes.filter((n) => n.status === "done").length, 0
167
+ );
168
+ const totalNodes = newLevels.reduce((acc, l) => acc + l.nodes.length, 0);
169
+
170
+ return {
171
+ ...prev,
172
+ workflowState: {
173
+ levels: newLevels,
174
+ currentLevel: level,
175
+ totalProgress: Math.round((totalDone / totalNodes) * 100),
176
+ },
177
+ };
178
+ });
179
+ }, []);
180
+
97
181
  const processCommand = useCallback((input: string) => {
98
182
  if (input.startsWith("/")) {
99
183
  const cmd = input.slice(1).toLowerCase();
@@ -120,45 +204,57 @@ export function useAppState() {
120
204
  default:
121
205
  if (cmd.startsWith("run ")) {
122
206
  const prompt = cmd.slice(4);
123
- setState((prev: AppState) => ({ ...prev, status: "running", isProcessing: true }));
124
- addMessage("user", prompt);
125
- addMessage("agent", "Analyse de l'intent...", "IntentClassifier");
126
- setTimeout(() => {
127
- addMessage("agent", `Intent détecté: code_generation`, "IntentClassifier");
128
- addMessage("agent", "Décomposition en tâches...", "TaskPlanner");
129
- setState((prev: AppState) => ({
130
- ...prev,
131
- status: "ready",
132
- isProcessing: false,
133
- fitness: Math.min(prev.fitness + 0.02, 0.99),
134
- currentWorkflow: prompt,
135
- agents: prev.agents.map((a: Agent, i: number) => ({
136
- ...a,
137
- status: i === 0 ? "done" as const : i === 1 ? "running" as const : "idle" as const,
138
- })),
139
- }));
140
- }, 1500);
207
+ runWorkflow(prompt);
141
208
  } else {
142
209
  addMessage("error", `Commande inconnue: /${cmd}. Tapez /help pour l'aide.`);
143
210
  }
144
211
  }
145
212
  } else {
146
- setState((prev: AppState) => ({ ...prev, status: "running", isProcessing: true }));
147
- addMessage("user", input);
148
- addMessage("agent", "Analyse de l'intent...", "IntentClassifier");
149
- setTimeout(() => {
150
- addMessage("agent", `Intent détecté: code_generation`, "IntentClassifier");
151
- addMessage("agent", "Exécution du workflow...", "Orchestrator");
213
+ runWorkflow(input);
214
+ }
215
+ }, [state, addMessage]);
216
+
217
+ const runWorkflow = useCallback((prompt: string) => {
218
+ setState((prev: AppState) => ({ ...prev, status: "running", isProcessing: true }));
219
+ addMessage("user", prompt);
220
+
221
+ let step = 0;
222
+ const steps = [
223
+ { level: 0, node: 0, msg: "Analyse de l'intent...", agent: "IntentClassifier" },
224
+ { level: 0, node: 1, msg: "Génération des specs...", agent: "SpecAgent" },
225
+ { level: 0, node: 2, msg: "Design de l'architecture...", agent: "ArchitectureAgent" },
226
+ { level: 1, node: 0, msg: "Planification des tâches...", agent: "TaskPlanner" },
227
+ { level: 1, node: 1, msg: "Génération du code...", agent: "CodeGenerator" },
228
+ { level: 2, node: 0, msg: "Exécution des tests...", agent: "TestAgent" },
229
+ { level: 2, node: 1, msg: "Application des fixes...", agent: "FixAgent" },
230
+ ];
231
+
232
+ function executeStep() {
233
+ if (step >= steps.length) {
152
234
  setState((prev: AppState) => ({
153
235
  ...prev,
154
236
  status: "ready",
155
237
  isProcessing: false,
156
- fitness: Math.min(prev.fitness + 0.01, 0.99),
157
- currentWorkflow: input,
238
+ fitness: Math.min(prev.fitness + 0.05, 0.99),
239
+ currentWorkflow: prompt,
158
240
  }));
159
- }, 2000);
241
+ addMessage("success", `✓ Workflow terminé! Fitness: ${(state.fitness + 0.05).toFixed(2)}`);
242
+ return;
243
+ }
244
+
245
+ const s = steps[step];
246
+ updateWorkflowProgress(s.level, s.node, "running");
247
+ addMessage("agent", s.msg, s.agent);
248
+
249
+ setTimeout(() => {
250
+ updateWorkflowProgress(s.level, s.node, "done");
251
+ step++;
252
+ executeStep();
253
+ }, 500 + Math.random() * 500);
160
254
  }
161
- }, [state, addMessage]);
255
+
256
+ executeStep();
257
+ }, [addMessage, updateWorkflowProgress, state.fitness]);
162
258
 
163
259
  return {
164
260
  state,