prompt-language-shell 0.9.2 → 0.9.6

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 (67) hide show
  1. package/dist/{ui/Main.js → Main.js} +12 -12
  2. package/dist/{ui → components}/Component.js +28 -26
  3. package/dist/{ui → components}/Workflow.js +14 -4
  4. package/dist/{ui → components/controllers}/Answer.js +18 -17
  5. package/dist/{ui → components/controllers}/Command.js +11 -18
  6. package/dist/{ui → components/controllers}/Config.js +8 -116
  7. package/dist/components/controllers/Confirm.js +42 -0
  8. package/dist/{ui → components/controllers}/Execute.js +75 -144
  9. package/dist/{ui → components/controllers}/Introspect.js +12 -28
  10. package/dist/components/controllers/Refinement.js +18 -0
  11. package/dist/components/controllers/Schedule.js +134 -0
  12. package/dist/{ui → components/controllers}/Validate.js +14 -32
  13. package/dist/components/views/Answer.js +28 -0
  14. package/dist/components/views/Command.js +11 -0
  15. package/dist/components/views/Config.js +115 -0
  16. package/dist/components/views/Confirm.js +24 -0
  17. package/dist/components/views/Debug.js +12 -0
  18. package/dist/components/views/Execute.js +60 -0
  19. package/dist/components/views/Feedback.js +8 -0
  20. package/dist/components/views/Introspect.js +17 -0
  21. package/dist/{ui → components/views}/Label.js +3 -3
  22. package/dist/{ui → components/views}/List.js +1 -1
  23. package/dist/{ui → components/views}/Output.js +2 -2
  24. package/dist/components/views/Refinement.js +9 -0
  25. package/dist/{ui → components/views}/Report.js +1 -1
  26. package/dist/components/views/Schedule.js +121 -0
  27. package/dist/{ui → components/views}/Separator.js +1 -1
  28. package/dist/{ui → components/views}/Spinner.js +1 -1
  29. package/dist/{ui → components/views}/Subtask.js +4 -4
  30. package/dist/components/views/Table.js +15 -0
  31. package/dist/components/views/Task.js +18 -0
  32. package/dist/components/views/Upcoming.js +30 -0
  33. package/dist/{ui → components/views}/UserQuery.js +1 -1
  34. package/dist/components/views/Validate.js +17 -0
  35. package/dist/{ui → components/views}/Welcome.js +1 -1
  36. package/dist/configuration/steps.js +1 -1
  37. package/dist/execution/handlers.js +19 -53
  38. package/dist/execution/reducer.js +26 -38
  39. package/dist/execution/runner.js +43 -25
  40. package/dist/execution/types.js +3 -4
  41. package/dist/execution/utils.js +1 -1
  42. package/dist/index.js +1 -1
  43. package/dist/services/anthropic.js +27 -31
  44. package/dist/services/colors.js +2 -1
  45. package/dist/services/logger.js +126 -13
  46. package/dist/services/messages.js +19 -0
  47. package/dist/services/parser.js +13 -5
  48. package/dist/services/refinement.js +8 -2
  49. package/dist/services/router.js +184 -89
  50. package/dist/services/shell.js +26 -6
  51. package/dist/services/skills.js +35 -7
  52. package/dist/services/timing.js +1 -0
  53. package/dist/skills/execute.md +15 -7
  54. package/dist/skills/schedule.md +155 -0
  55. package/dist/tools/execute.tool.js +0 -4
  56. package/dist/tools/schedule.tool.js +1 -1
  57. package/dist/types/schemas.js +0 -1
  58. package/package.json +4 -4
  59. package/dist/execution/hooks.js +0 -291
  60. package/dist/ui/Confirm.js +0 -62
  61. package/dist/ui/Debug.js +0 -7
  62. package/dist/ui/Feedback.js +0 -19
  63. package/dist/ui/Refinement.js +0 -23
  64. package/dist/ui/Schedule.js +0 -257
  65. package/dist/ui/Task.js +0 -11
  66. /package/dist/{ui → components/views}/Message.js +0 -0
  67. /package/dist/{ui → components/views}/Panel.js +0 -0
@@ -1,257 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useEffect, useState } from 'react';
3
- import { Box } from 'ink';
4
- import { ComponentStatus, } from '../types/components.js';
5
- import { TaskType } from '../types/types.js';
6
- import { getTaskColors, getTaskTypeLabel, Palette, } from '../services/colors.js';
7
- import { DebugLevel } from '../configuration/types.js';
8
- import { useInput } from '../services/keyboard.js';
9
- import { Label } from './Label.js';
10
- import { List } from './List.js';
11
- export function taskToListItem(task, highlightedChildIndex = null, isDefineTaskWithoutSelection = false, status = ComponentStatus.Done, debug = DebugLevel.None) {
12
- const taskColors = getTaskColors(task.type, status);
13
- // Determine description color based on status
14
- let descriptionColor = taskColors.description;
15
- if (status === ComponentStatus.Pending) {
16
- descriptionColor = Palette.SoftWhite;
17
- }
18
- const item = {
19
- description: {
20
- text: task.action,
21
- color: descriptionColor,
22
- },
23
- type: { text: getTaskTypeLabel(task.type, debug), color: taskColors.type },
24
- children: [],
25
- };
26
- // Mark define tasks with right arrow when no selection has been made
27
- if (isDefineTaskWithoutSelection) {
28
- item.marker = ' → ';
29
- item.markerColor = getTaskColors(TaskType.Schedule, status).type;
30
- }
31
- // Add children for Define tasks with options
32
- if (task.type === TaskType.Define && Array.isArray(task.params?.options)) {
33
- item.children = task.params.options.map((option, index) => {
34
- // Determine the type based on selection state
35
- let childType = TaskType.Select;
36
- if (highlightedChildIndex !== null) {
37
- // A selection was made - mark others as discarded
38
- childType =
39
- index === highlightedChildIndex ? TaskType.Execute : TaskType.Discard;
40
- }
41
- const colors = getTaskColors(childType, status);
42
- const planColors = getTaskColors(TaskType.Schedule, status);
43
- return {
44
- description: {
45
- text: option,
46
- color: colors.description,
47
- highlightedColor: planColors.description,
48
- },
49
- type: {
50
- text: getTaskTypeLabel(childType, debug),
51
- color: colors.type,
52
- highlightedColor: planColors.type,
53
- },
54
- };
55
- });
56
- }
57
- // Add children for Group tasks with subtasks
58
- const scheduledTask = task;
59
- if (task.type === TaskType.Group &&
60
- scheduledTask.subtasks &&
61
- Array.isArray(scheduledTask.subtasks) &&
62
- scheduledTask.subtasks.length > 0) {
63
- item.children = scheduledTask.subtasks.map((subtask) => {
64
- const subtaskColors = getTaskColors(subtask.type, status);
65
- return {
66
- description: {
67
- text: subtask.action,
68
- color: Palette.AshGray,
69
- },
70
- type: {
71
- text: getTaskTypeLabel(subtask.type, debug),
72
- color: subtaskColors.type,
73
- },
74
- };
75
- });
76
- }
77
- return item;
78
- }
79
- export const ScheduleView = ({ message, tasks, state, status, debug = DebugLevel.None, }) => {
80
- const isActive = status === ComponentStatus.Active;
81
- const { highlightedIndex, currentDefineGroupIndex, completedSelections } = state;
82
- // Use compact mode when all tasks are Config type
83
- const isCompact = tasks.every((task) => task.type === TaskType.Config);
84
- // Find all Define tasks
85
- const defineTaskIndices = tasks
86
- .map((t, idx) => (t.type === TaskType.Define ? idx : -1))
87
- .filter((idx) => idx !== -1);
88
- // Get the current active define task
89
- const currentDefineTaskIndex = defineTaskIndices[currentDefineGroupIndex] ?? -1;
90
- const listItems = tasks.map((task, idx) => {
91
- // Find which define group this task belongs to (if any)
92
- const defineGroupIndex = defineTaskIndices.indexOf(idx);
93
- const isDefineTask = defineGroupIndex !== -1;
94
- // Determine child selection state
95
- let childIndex = null;
96
- if (isDefineTask) {
97
- if (defineGroupIndex < currentDefineGroupIndex) {
98
- // Previously completed group - show the selection
99
- childIndex = completedSelections[defineGroupIndex] ?? null;
100
- }
101
- else if (defineGroupIndex === currentDefineGroupIndex) {
102
- // Current active group - show live navigation unless not active
103
- if (!isActive) {
104
- // If not active, show the completed selection for this group too
105
- childIndex = completedSelections[defineGroupIndex] ?? null;
106
- }
107
- else {
108
- childIndex = null;
109
- }
110
- }
111
- }
112
- // Show arrow on current active define task when no child is highlighted and is active
113
- const isDefineWithoutSelection = isDefineTask &&
114
- defineGroupIndex === currentDefineGroupIndex &&
115
- highlightedIndex === null &&
116
- isActive;
117
- return taskToListItem(task, childIndex, isDefineWithoutSelection, status, debug);
118
- });
119
- return (_jsxs(Box, { flexDirection: "column", children: [message && (_jsx(Box, { marginBottom: 1, marginLeft: 1, children: _jsx(Label, { description: message, taskType: TaskType.Schedule, showType: debug !== DebugLevel.None, status: status, debug: debug }) })), _jsx(Box, { marginLeft: 1, children: _jsx(List, { items: listItems, highlightedIndex: currentDefineTaskIndex >= 0 ? highlightedIndex : null, highlightedParentIndex: currentDefineTaskIndex, showType: debug !== DebugLevel.None, compact: isCompact }) })] }));
120
- };
121
- /**
122
- * Schedule controller: Manages task selection and navigation
123
- */
124
- export function Schedule({ message, tasks, status, debug = DebugLevel.None, requestHandlers, lifecycleHandlers, onSelectionConfirmed, }) {
125
- const isActive = status === ComponentStatus.Active;
126
- const [highlightedIndex, setHighlightedIndex] = useState(null);
127
- const [currentDefineGroupIndex, setCurrentDefineGroupIndex] = useState(0);
128
- const [completedSelections, setCompletedSelections] = useState([]);
129
- // Find all Define tasks
130
- const defineTaskIndices = tasks
131
- .map((t, idx) => (t.type === TaskType.Define ? idx : -1))
132
- .filter((idx) => idx !== -1);
133
- // Get the current active define task
134
- const currentDefineTaskIndex = defineTaskIndices[currentDefineGroupIndex] ?? -1;
135
- const defineTask = currentDefineTaskIndex >= 0 ? tasks[currentDefineTaskIndex] : null;
136
- const optionsCount = Array.isArray(defineTask?.params?.options)
137
- ? defineTask.params.options.length
138
- : 0;
139
- const hasMoreGroups = currentDefineGroupIndex < defineTaskIndices.length - 1;
140
- // If no DEFINE tasks, immediately confirm with all tasks
141
- useEffect(() => {
142
- if (isActive && defineTaskIndices.length === 0 && onSelectionConfirmed) {
143
- // No selection needed - all tasks are concrete
144
- const concreteTasks = tasks.filter((task) => task.type !== TaskType.Ignore && task.type !== TaskType.Discard);
145
- // Expose final state
146
- const finalState = {
147
- highlightedIndex,
148
- currentDefineGroupIndex,
149
- completedSelections,
150
- };
151
- requestHandlers.onCompleted(finalState);
152
- // Complete the selection phase - it goes to timeline
153
- // Callback will create a new Plan showing refined tasks (pending) + Confirm (active)
154
- lifecycleHandlers.completeActive();
155
- void onSelectionConfirmed(concreteTasks);
156
- }
157
- }, [
158
- isActive,
159
- defineTaskIndices.length,
160
- tasks,
161
- onSelectionConfirmed,
162
- lifecycleHandlers,
163
- highlightedIndex,
164
- currentDefineGroupIndex,
165
- completedSelections,
166
- requestHandlers,
167
- ]);
168
- useInput((input, key) => {
169
- // Don't handle input if not active or no define task
170
- if (!isActive || !defineTask) {
171
- return;
172
- }
173
- if (key.escape) {
174
- requestHandlers.onAborted('task selection');
175
- return;
176
- }
177
- if (key.downArrow) {
178
- setHighlightedIndex((prev) => {
179
- if (prev === null) {
180
- return 0; // Select first
181
- }
182
- return (prev + 1) % optionsCount; // Wrap around
183
- });
184
- }
185
- else if (key.upArrow) {
186
- setHighlightedIndex((prev) => {
187
- if (prev === null) {
188
- return optionsCount - 1; // Select last
189
- }
190
- return (prev - 1 + optionsCount) % optionsCount; // Wrap around
191
- });
192
- }
193
- else if (key.return && highlightedIndex !== null) {
194
- // Record the selection for this group
195
- const newCompletedSelections = [...completedSelections];
196
- newCompletedSelections[currentDefineGroupIndex] = highlightedIndex;
197
- setCompletedSelections(newCompletedSelections);
198
- if (hasMoreGroups) {
199
- // Advance to next group
200
- const newGroupIndex = currentDefineGroupIndex + 1;
201
- setCurrentDefineGroupIndex(newGroupIndex);
202
- setHighlightedIndex(null);
203
- }
204
- else {
205
- // Clear highlight to show Execute color
206
- setHighlightedIndex(null);
207
- // Build refined task list with only selected options (no discarded or ignored ones)
208
- const refinedTasks = [];
209
- tasks.forEach((task, idx) => {
210
- const defineGroupIndex = defineTaskIndices.indexOf(idx);
211
- if (defineGroupIndex !== -1 &&
212
- Array.isArray(task.params?.options)) {
213
- // This is a Define task - only include the selected option
214
- const options = task.params.options;
215
- const selectedIndex = newCompletedSelections[defineGroupIndex];
216
- const selectedOption = options[selectedIndex];
217
- // Use Execute as default - LLM will properly classify during refinement
218
- refinedTasks.push({
219
- action: selectedOption,
220
- type: TaskType.Execute,
221
- config: [],
222
- });
223
- }
224
- else if (task.type !== TaskType.Ignore &&
225
- task.type !== TaskType.Discard) {
226
- // Regular task - keep as is, but skip Ignore and Discard tasks
227
- refinedTasks.push(task);
228
- }
229
- });
230
- // Expose final state
231
- const finalState = {
232
- highlightedIndex: null,
233
- currentDefineGroupIndex,
234
- completedSelections: newCompletedSelections,
235
- };
236
- requestHandlers.onCompleted(finalState);
237
- if (onSelectionConfirmed) {
238
- // Complete the selection phase - it goes to timeline
239
- // Callback will create a new Plan showing refined tasks (pending) + Confirm (active)
240
- lifecycleHandlers.completeActive();
241
- void onSelectionConfirmed(refinedTasks);
242
- }
243
- else {
244
- // No selection callback, just complete normally
245
- lifecycleHandlers.completeActive();
246
- }
247
- }
248
- }
249
- }, { isActive: isActive && defineTask !== null });
250
- // Controller always renders View, passing current state
251
- const state = {
252
- highlightedIndex,
253
- currentDefineGroupIndex,
254
- completedSelections,
255
- };
256
- return (_jsx(ScheduleView, { message: message, tasks: tasks, state: state, status: status, debug: debug }));
257
- }
package/dist/ui/Task.js DELETED
@@ -1,11 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Box } from 'ink';
3
- import { Output } from './Output.js';
4
- import { SubtaskView } from './Subtask.js';
5
- /**
6
- * Pure display component for a task.
7
- * Combines SubtaskView (label/command/status) with Output (stdout/stderr).
8
- */
9
- export function TaskView({ label, command, status, elapsed, stdout, stderr, isFinished, }) {
10
- return (_jsxs(Box, { flexDirection: "column", children: [_jsx(SubtaskView, { label: label, command: command, status: status, elapsed: elapsed }), _jsx(Output, { stdout: stdout, stderr: stderr, isFinished: isFinished, status: status }, `${stdout.length}-${stderr.length}`)] }));
11
- }
File without changes
File without changes