prompt-language-shell 0.8.4 → 0.8.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 (41) hide show
  1. package/dist/configuration/io.js +85 -0
  2. package/dist/configuration/messages.js +30 -0
  3. package/dist/configuration/schema.js +167 -0
  4. package/dist/configuration/transformation.js +55 -0
  5. package/dist/configuration/types.js +30 -0
  6. package/dist/configuration/validation.js +52 -0
  7. package/dist/execution/handlers.js +135 -0
  8. package/dist/execution/processing.js +36 -0
  9. package/dist/execution/reducer.js +148 -0
  10. package/dist/execution/types.js +12 -0
  11. package/dist/execution/validation.js +12 -0
  12. package/dist/index.js +1 -1
  13. package/dist/services/anthropic.js +2 -1
  14. package/dist/services/colors.js +22 -12
  15. package/dist/services/components.js +35 -11
  16. package/dist/services/config-labels.js +15 -15
  17. package/dist/services/logger.js +2 -1
  18. package/dist/services/messages.js +53 -1
  19. package/dist/services/refinement.js +11 -6
  20. package/dist/services/router.js +92 -52
  21. package/dist/skills/execute.md +79 -9
  22. package/dist/skills/schedule.md +121 -29
  23. package/dist/tools/execute.tool.js +4 -0
  24. package/dist/types/schemas.js +1 -0
  25. package/dist/ui/Answer.js +36 -15
  26. package/dist/ui/Command.js +43 -23
  27. package/dist/ui/Component.js +147 -33
  28. package/dist/ui/Config.js +73 -79
  29. package/dist/ui/Confirm.js +34 -21
  30. package/dist/ui/Execute.js +129 -329
  31. package/dist/ui/Feedback.js +2 -1
  32. package/dist/ui/Introspect.js +51 -24
  33. package/dist/ui/Label.js +4 -3
  34. package/dist/ui/List.js +3 -2
  35. package/dist/ui/Main.js +5 -1
  36. package/dist/ui/Refinement.js +8 -1
  37. package/dist/ui/Schedule.js +89 -61
  38. package/dist/ui/Validate.js +75 -77
  39. package/dist/ui/Workflow.js +47 -123
  40. package/package.json +1 -1
  41. package/dist/services/configuration.js +0 -409
@@ -1,7 +1,10 @@
1
1
  import { asScheduledTasks } from '../types/guards.js';
2
2
  import { FeedbackType, TaskType } from '../types/types.js';
3
+ import { saveConfig } from '../configuration/io.js';
4
+ import { getConfigSchema } from '../configuration/schema.js';
5
+ import { unflattenConfig } from '../configuration/transformation.js';
6
+ import { saveConfigLabels } from './config-labels.js';
3
7
  import { createAnswerDefinition, createConfigDefinitionWithKeys, createConfirmDefinition, createExecuteDefinition, createFeedback, createIntrospectDefinition, createMessage, createScheduleDefinition, createValidateDefinition, } from './components.js';
4
- import { saveConfig, unflattenConfig } from './configuration.js';
5
8
  import { getCancellationMessage, getMixedTaskTypesError, getUnknownRequestMessage, } from './messages.js';
6
9
  import { validateExecuteTasks } from './validator.js';
7
10
  /**
@@ -20,7 +23,7 @@ export function getOperationName(tasks) {
20
23
  * Route tasks to appropriate components with Confirm flow
21
24
  * Handles the complete flow: Plan → Confirm → Execute/Answer/Introspect
22
25
  */
23
- export function routeTasksWithConfirm(tasks, message, service, userRequest, queueHandlers, workflowHandlers, errorHandlers, hasDefineTask = false) {
26
+ export function routeTasksWithConfirm(tasks, message, service, userRequest, lifecycleHandlers, workflowHandlers, requestHandlers, hasDefineTask = false) {
24
27
  if (tasks.length === 0)
25
28
  return;
26
29
  // Filter out ignore and discard tasks early
@@ -28,7 +31,7 @@ export function routeTasksWithConfirm(tasks, message, service, userRequest, queu
28
31
  // Check if no valid tasks remain after filtering
29
32
  if (validTasks.length === 0) {
30
33
  const message = createMessage(getUnknownRequestMessage());
31
- queueHandlers.addToQueue(message);
34
+ workflowHandlers.addToQueue(message);
32
35
  return;
33
36
  }
34
37
  const operation = getOperationName(validTasks);
@@ -36,7 +39,7 @@ export function routeTasksWithConfirm(tasks, message, service, userRequest, queu
36
39
  // Has DEFINE tasks - add Schedule to queue for user selection
37
40
  // Refinement flow will call this function again with refined tasks
38
41
  const scheduleDefinition = createScheduleDefinition(message, validTasks);
39
- queueHandlers.addToQueue(scheduleDefinition);
42
+ workflowHandlers.addToQueue(scheduleDefinition);
40
43
  }
41
44
  else {
42
45
  // No DEFINE tasks - Schedule auto-completes and adds Confirm to queue
@@ -47,17 +50,17 @@ export function routeTasksWithConfirm(tasks, message, service, userRequest, queu
47
50
  // Schedule completed - add Confirm to queue
48
51
  const confirmDefinition = createConfirmDefinition(() => {
49
52
  // User confirmed - complete both Confirm and Schedule, then route to appropriate component
50
- workflowHandlers.completeActiveAndPending();
51
- executeTasksAfterConfirm(validTasks, service, userRequest, queueHandlers, errorHandlers);
53
+ lifecycleHandlers.completeActiveAndPending();
54
+ executeTasksAfterConfirm(validTasks, service, userRequest, workflowHandlers, requestHandlers);
52
55
  }, () => {
53
56
  // User cancelled - complete both Confirm and Schedule, then show cancellation
54
- workflowHandlers.completeActiveAndPending();
57
+ lifecycleHandlers.completeActiveAndPending();
55
58
  const message = getCancellationMessage(operation);
56
- queueHandlers.addToQueue(createFeedback(FeedbackType.Aborted, message));
59
+ workflowHandlers.addToQueue(createFeedback(FeedbackType.Aborted, message));
57
60
  });
58
- queueHandlers.addToQueue(confirmDefinition);
61
+ workflowHandlers.addToQueue(confirmDefinition);
59
62
  });
60
- queueHandlers.addToQueue(scheduleDefinition);
63
+ workflowHandlers.addToQueue(scheduleDefinition);
61
64
  }
62
65
  }
63
66
  /**
@@ -88,16 +91,70 @@ function validateTaskTypes(tasks) {
88
91
  * Validates task types and routes each type appropriately
89
92
  * Supports mixed types at top level with Groups
90
93
  */
91
- function executeTasksAfterConfirm(tasks, service, userRequest, queueHandlers, errorHandlers) {
94
+ function executeTasksAfterConfirm(tasks, service, userRequest, workflowHandlers, requestHandlers) {
92
95
  // Validate task types (Groups must have uniform subtasks)
93
96
  try {
94
97
  validateTaskTypes(tasks);
95
98
  }
96
99
  catch (error) {
97
- errorHandlers.onError(error instanceof Error ? error.message : String(error));
100
+ requestHandlers.onError(error instanceof Error ? error.message : String(error));
98
101
  return;
99
102
  }
100
103
  const scheduledTasks = asScheduledTasks(tasks);
104
+ // Collect ALL Execute tasks (standalone and from groups) for upfront validation
105
+ const allExecuteTasks = [];
106
+ for (const task of scheduledTasks) {
107
+ if (task.type === TaskType.Execute) {
108
+ allExecuteTasks.push(task);
109
+ }
110
+ else if (task.type === TaskType.Group && task.subtasks) {
111
+ const subtasks = task.subtasks;
112
+ if (subtasks.length > 0 && subtasks[0].type === TaskType.Execute) {
113
+ allExecuteTasks.push(...subtasks);
114
+ }
115
+ }
116
+ }
117
+ // Validate ALL Execute tasks together to collect ALL missing config upfront
118
+ if (allExecuteTasks.length > 0) {
119
+ try {
120
+ const validation = validateExecuteTasks(allExecuteTasks);
121
+ if (validation.validationErrors.length > 0) {
122
+ // Show error feedback for invalid skills
123
+ const errorMessages = validation.validationErrors.map((error) => {
124
+ const issuesList = error.issues
125
+ .map((issue) => ` - ${issue}`)
126
+ .join('\n');
127
+ return `Invalid skill definition "${error.skill}":\n\n${issuesList}`;
128
+ });
129
+ workflowHandlers.addToQueue(createFeedback(FeedbackType.Failed, errorMessages.join('\n\n')));
130
+ return;
131
+ }
132
+ else if (validation.missingConfig.length > 0) {
133
+ // Missing config detected - create ONE Validate component for ALL missing config
134
+ workflowHandlers.addToQueue(createValidateDefinition(validation.missingConfig, userRequest, service, (error) => {
135
+ requestHandlers.onError(error);
136
+ }, () => {
137
+ // After config is complete, resume task routing
138
+ routeTasksAfterConfig(scheduledTasks, service, userRequest, workflowHandlers, requestHandlers);
139
+ }, (operation) => {
140
+ requestHandlers.onAborted(operation);
141
+ }));
142
+ return;
143
+ }
144
+ }
145
+ catch (error) {
146
+ requestHandlers.onError(error instanceof Error ? error.message : String(error));
147
+ return;
148
+ }
149
+ }
150
+ // No missing config - proceed with normal routing
151
+ routeTasksAfterConfig(scheduledTasks, service, userRequest, workflowHandlers, requestHandlers);
152
+ }
153
+ /**
154
+ * Route tasks after config is complete (or when no config is needed)
155
+ * Processes tasks in order, grouping by type
156
+ */
157
+ function routeTasksAfterConfig(scheduledTasks, service, userRequest, workflowHandlers, requestHandlers) {
101
158
  // Process tasks in order, preserving Group boundaries
102
159
  // Track consecutive standalone tasks to group them by type
103
160
  let consecutiveStandaloneTasks = [];
@@ -117,7 +174,7 @@ function executeTasksAfterConfirm(tasks, service, userRequest, queueHandlers, er
117
174
  const taskType = type;
118
175
  if (typeTasks.length === 0)
119
176
  continue;
120
- routeTasksByType(taskType, typeTasks, service, userRequest, queueHandlers, errorHandlers);
177
+ routeTasksByType(taskType, typeTasks, service, userRequest, workflowHandlers, requestHandlers);
121
178
  }
122
179
  consecutiveStandaloneTasks = [];
123
180
  };
@@ -130,7 +187,7 @@ function executeTasksAfterConfirm(tasks, service, userRequest, queueHandlers, er
130
187
  if (task.subtasks.length > 0) {
131
188
  const subtasks = task.subtasks;
132
189
  const taskType = subtasks[0].type;
133
- routeTasksByType(taskType, subtasks, service, userRequest, queueHandlers, errorHandlers);
190
+ routeTasksByType(taskType, subtasks, service, userRequest, workflowHandlers, requestHandlers);
134
191
  }
135
192
  }
136
193
  else {
@@ -145,22 +202,35 @@ function executeTasksAfterConfirm(tasks, service, userRequest, queueHandlers, er
145
202
  * Route tasks by type to appropriate components
146
203
  * Extracted to allow reuse for both Groups and standalone tasks
147
204
  */
148
- function routeTasksByType(taskType, typeTasks, service, userRequest, queueHandlers, errorHandlers) {
205
+ function routeTasksByType(taskType, typeTasks, service, userRequest, workflowHandlers, requestHandlers) {
149
206
  if (taskType === TaskType.Answer) {
150
207
  // Create separate Answer component for each question
151
208
  for (const task of typeTasks) {
152
- queueHandlers.addToQueue(createAnswerDefinition(task.action, service));
209
+ workflowHandlers.addToQueue(createAnswerDefinition(task.action, service));
153
210
  }
154
211
  }
155
212
  else if (taskType === TaskType.Introspect) {
156
- queueHandlers.addToQueue(createIntrospectDefinition(typeTasks, service));
213
+ workflowHandlers.addToQueue(createIntrospectDefinition(typeTasks, service));
157
214
  }
158
215
  else if (taskType === TaskType.Config) {
159
- // Route to Config flow - extract keys from task params
216
+ // Route to Config flow - extract keys and descriptions from task params
160
217
  const configKeys = typeTasks
161
218
  .map((task) => task.params?.key)
162
219
  .filter((key) => key !== undefined);
163
- queueHandlers.addToQueue(createConfigDefinitionWithKeys(configKeys, (config) => {
220
+ // Extract and cache labels from task descriptions
221
+ // Only cache labels for dynamically discovered keys (not in schema)
222
+ const schema = getConfigSchema();
223
+ const labels = {};
224
+ for (const task of typeTasks) {
225
+ const key = task.params?.key;
226
+ if (key && task.action && !(key in schema)) {
227
+ labels[key] = task.action;
228
+ }
229
+ }
230
+ if (Object.keys(labels).length > 0) {
231
+ saveConfigLabels(labels);
232
+ }
233
+ workflowHandlers.addToQueue(createConfigDefinitionWithKeys(configKeys, (config) => {
164
234
  // Save config - Config component will handle completion and feedback
165
235
  try {
166
236
  // Convert flat dotted keys to nested structure grouped by section
@@ -177,41 +247,11 @@ function routeTasksByType(taskType, typeTasks, service, userRequest, queueHandle
177
247
  throw new Error(errorMessage);
178
248
  }
179
249
  }, (operation) => {
180
- errorHandlers.onAborted(operation);
250
+ requestHandlers.onAborted(operation);
181
251
  }));
182
252
  }
183
253
  else if (taskType === TaskType.Execute) {
184
- // Execute tasks with validation
185
- try {
186
- const validation = validateExecuteTasks(typeTasks);
187
- if (validation.validationErrors.length > 0) {
188
- // Show error feedback for invalid skills
189
- const errorMessages = validation.validationErrors.map((error) => {
190
- const issuesList = error.issues
191
- .map((issue) => ` - ${issue}`)
192
- .join('\n');
193
- return `Invalid skill definition "${error.skill}":\n\n${issuesList}`;
194
- });
195
- queueHandlers.addToQueue(createFeedback(FeedbackType.Failed, errorMessages.join('\n\n')));
196
- }
197
- else if (validation.missingConfig.length > 0) {
198
- queueHandlers.addToQueue(createValidateDefinition(validation.missingConfig, userRequest, service, (error) => {
199
- errorHandlers.onError(error);
200
- }, () => {
201
- queueHandlers.addToQueue(createExecuteDefinition(typeTasks, service));
202
- }, (operation) => {
203
- errorHandlers.onAborted(operation);
204
- }));
205
- }
206
- else {
207
- queueHandlers.addToQueue(createExecuteDefinition(typeTasks, service));
208
- }
209
- }
210
- catch (error) {
211
- // Handle skill reference errors (e.g., unknown skills)
212
- const errorMessage = error instanceof Error ? error.message : String(error);
213
- const message = createMessage(errorMessage);
214
- queueHandlers.addToQueue(message);
215
- }
254
+ // Execute tasks (validation already happened upfront in executeTasksAfterConfirm)
255
+ workflowHandlers.addToQueue(createExecuteDefinition(typeTasks, service));
216
256
  }
217
257
  }
@@ -26,9 +26,63 @@ You will receive:
26
26
 
27
27
  ## Skill-Based Command Generation
28
28
 
29
+ **CRITICAL**: The "Available Skills" section in the prompt defines the ONLY
30
+ skills you can execute. This is an EXHAUSTIVE and COMPLETE list. Do NOT
31
+ assume skills exist based on examples in these instructions.
32
+
29
33
  **CRITICAL**: When tasks originate from a user-defined skill, you MUST use
30
34
  the skill's **Execution** section to generate commands, NOT invent your own.
31
35
 
36
+ **CRITICAL VALIDATION**: Before generating ANY commands for skill-based
37
+ tasks, perform these checks in order:
38
+
39
+ 1. **Verify "Available Skills" section exists**: If there is no
40
+ "Available Skills" section in the prompt, STOP immediately and return
41
+ an error response.
42
+
43
+ 2. **Verify skill exists**: Check if the skill named in params.skill
44
+ actually exists in the "Available Skills" section below.
45
+
46
+ 3. **Verify skill has Steps section**: Check if the skill definition
47
+ includes a "### Steps" section with step descriptions.
48
+
49
+ 4. **Verify skill has Execution section**: Check if the skill definition
50
+ includes a "### Execution" section with actual commands.
51
+
52
+ 5. **If ANY check fails**: STOP immediately and return an error response.
53
+ DO NOT generate commands. DO NOT invent commands. DO NOT make
54
+ assumptions about what commands should be run.
55
+
56
+ **Error Response Formats** (keep error messages concise):
57
+
58
+ No Available Skills section:
59
+ ```
60
+ message: "Cannot execute:"
61
+ summary: "No skills available"
62
+ commands: []
63
+ error: "No skills available"
64
+ ```
65
+
66
+ Skill not found:
67
+ ```
68
+ message: "Cannot execute:"
69
+ summary: "Skill not found"
70
+ commands: []
71
+ error: "Skill '[skill name]' not found"
72
+ ```
73
+
74
+ Skill missing Steps or Execution:
75
+ ```
76
+ message: "Cannot execute:"
77
+ summary: "Incomplete skill"
78
+ commands: []
79
+ error: "Skill '[skill name]' is incomplete"
80
+ ```
81
+
82
+ **IMPORTANT**: Error messages must be concise (under 50 characters). Avoid
83
+ technical jargon or detailed explanations. The error will be shown to the
84
+ user in a natural, conversational format.
85
+
32
86
  ### Understanding Skill Structure
33
87
 
34
88
  User-defined skills have two key sections:
@@ -42,7 +96,7 @@ position.
42
96
 
43
97
  1. **Identify skill tasks**: Check if tasks have params.skill
44
98
  2. **Find the skill**: Look up the skill in "Available Skills" section
45
- below
99
+ below (REQUIRED - must exist)
46
100
  3. **Match tasks to Execution**: Each task action came from a Steps line;
47
101
  use the corresponding Execution line for the command
48
102
  4. **Substitute parameters**: Replace {PARAM} placeholders with actual
@@ -304,9 +358,13 @@ For complex multi-step operations:
304
358
  ❌ Setting unrealistic timeouts for long operations
305
359
  ❌ Running destructive commands without safeguards
306
360
  ❌ Ignoring task parameters when generating commands
307
- ❌ Inventing commands instead of using skill's Execution section
308
- ❌ Ignoring params.skill and making up your own commands
361
+ **CRITICAL: Inventing commands instead of using skill's Execution
362
+ section**
363
+ ❌ **CRITICAL: Ignoring params.skill and making up your own commands**
364
+ ❌ **CRITICAL: Generating commands when the skill doesn't exist in
365
+ Available Skills**
309
366
  ❌ Not substituting parameter placeholders in skill commands
367
+ ❌ **CRITICAL: Assuming what commands to run when skill is missing**
310
368
 
311
369
  ✅ Match commands precisely to task descriptions
312
370
  ✅ Use task params to fill in specific values
@@ -314,6 +372,10 @@ For complex multi-step operations:
314
372
  ✅ Set appropriate timeouts for each operation type
315
373
  ✅ Include safety checks for destructive operations
316
374
  ✅ Generate portable commands when possible
375
+ ✅ **CRITICAL: Verify skill exists in Available Skills before generating
376
+ commands**
377
+ ✅ **CRITICAL: Return error response if skill not found, never invent
378
+ commands**
317
379
  ✅ Always use skill's Execution section when params.skill is present
318
380
  ✅ Replace all {PARAM} placeholders with values from task params
319
381
 
@@ -321,9 +383,17 @@ For complex multi-step operations:
321
383
 
322
384
  Before returning commands:
323
385
 
324
- 1. Verify each command matches its task description
325
- 2. Check that all task params are incorporated
326
- 3. Ensure paths are properly quoted
327
- 4. Confirm timeouts are reasonable for each operation
328
- 5. Validate that critical flags are set appropriately
329
- 6. Review for any safety concerns
386
+ 1. **CRITICAL: If tasks have params.skill, verify Available Skills
387
+ section exists**
388
+ 2. **CRITICAL: If tasks have params.skill, verify the skill exists in
389
+ Available Skills section**
390
+ 3. **CRITICAL: If tasks have params.skill, verify the skill has both
391
+ Steps and Execution sections**
392
+ 4. **CRITICAL: If any validation fails, return error response with empty
393
+ commands array**
394
+ 5. Verify each command matches its task description
395
+ 6. Check that all task params are incorporated
396
+ 7. Ensure paths are properly quoted
397
+ 8. Confirm timeouts are reasonable for each operation
398
+ 9. Validate that critical flags are set appropriately
399
+ 10. Review for any safety concerns
@@ -4,6 +4,21 @@ You are the scheduling component of "pls" (please), a command-line
4
4
  concierge. Your role is to organize user requests into hierarchical
5
5
  task structures with high-level tasks and their subtasks.
6
6
 
7
+ **CRITICAL - Skill Matching Foundation**:
8
+
9
+ The ONLY skills you can execute are those explicitly listed in the
10
+ "Available Skills" section of the system prompt. This section may be
11
+ present with skills, present but empty, or missing entirely. Your
12
+ behavior must adapt accordingly:
13
+
14
+ - **Skills present**: Match user requests ONLY against listed skills
15
+ - **Empty or missing**: Create "ignore" tasks for ALL action verbs
16
+
17
+ All examples in these instructions (e.g., "build", "deploy", "process")
18
+ are for illustration only. They do NOT represent actual available
19
+ skills unless they appear in the "Available Skills" section of the
20
+ system prompt.
21
+
7
22
  ## Response Format
8
23
 
9
24
  Every response MUST include a brief message (single sentence, max 64
@@ -53,21 +68,38 @@ Every task MUST have a type field. Use the appropriate type:
53
68
  - `answer` - Answering questions, explaining concepts
54
69
  - `introspect` - Listing capabilities when user asks what you can do
55
70
  - `report` - Generating summaries, displaying results
56
- - `define` - Presenting options when request is ambiguous
71
+ - `define` - Presenting options when a matching skill needs variant
72
+ selection
57
73
  - `ignore` - Request has NO matching skill OR is too vague to execute
58
74
 
59
- **CRITICAL**: Use `ignore` type for ANY action verb that does NOT have
60
- a matching skill in the "Available Skills" section. DO NOT create
61
- `execute` tasks without a corresponding skill.
75
+ **CRITICAL SKILL MATCHING RULES**:
76
+
77
+ 1. **ONLY match against skills in "Available Skills" section**: The
78
+ ONLY skills you can execute are those explicitly listed in the
79
+ "Available Skills" section of the prompt. Do NOT assume, infer, or
80
+ create skills based on examples in these instructions.
81
+
82
+ 2. **Examples are illustrative only**: All examples in these
83
+ instructions (including "build", "deploy", etc.) are for
84
+ illustration purposes. They do NOT represent actual available
85
+ skills unless they appear in the "Available Skills" section.
62
86
 
63
- **Define task params**: When creating a `define` type task, include:
87
+ 3. **No Available Skills = No Execute Tasks**: If the "Available
88
+ Skills" section is missing or empty, ALL action verbs must result
89
+ in `ignore` type tasks. You cannot execute ANY commands without
90
+ explicitly defined skills.
91
+
92
+ 4. **Define vs Ignore**:
93
+ - Use `define` ONLY when a skill EXISTS in "Available Skills" but
94
+ needs variant selection
95
+ - Use `ignore` when NO matching skill exists in "Available Skills"
96
+
97
+ **Define task params** (ONLY when skill exists): When creating a
98
+ `define` type task for a skill that EXISTS in "Available Skills",
99
+ include:
64
100
  - `skill`: the skill name that needs variant selection (REQUIRED)
65
101
  - `options`: array of option strings describing each variant (REQUIRED)
66
102
 
67
- Example: User "build" without variant → Task with type "define",
68
- params { skill: "Build Project", options: ["Build project Alpha, the
69
- main variant", "Build project Beta, the experimental variant"] }
70
-
71
103
  ## Configuration Requests
72
104
 
73
105
  When user wants to configure or change settings (e.g., "config",
@@ -93,15 +125,22 @@ Before creating tasks, evaluate the request type:
93
125
  "search"
94
126
  - Example: "explain docker" → answer type
95
127
 
96
- 3. **Action requests** (commands) - Must match available skills:
97
- - Action verbs like "compile", "deploy", "process", "validate"
98
- - If verb matches a skill extract skill steps as subtasks
99
- - If verb does NOT match any skill → ignore type with action
100
- "Ignore unknown 'X' request" where X is the verb/phrase
101
- - Example: "compile" with no skill → action "Ignore unknown
102
- 'compile' request"
103
- - Example: "validate" with no skill action "Ignore unknown
104
- 'validate' request"
128
+ 3. **Action requests** (commands) - Must match skills in "Available
129
+ Skills" section:
130
+ - Check if action verb matches ANY skill in "Available Skills"
131
+ section
132
+ - If verb matches a skill examine the skill's Execution section
133
+ to determine structure:
134
+ - Multiple execution steps → create ONLY a group task with those
135
+ steps as subtasks (never create a flat execute task)
136
+ - Single execution step → can use a leaf execute task
137
+ - If verb does NOT match any skill in "Available Skills" → ignore
138
+ type with action "Ignore unknown 'X' request" where X is the
139
+ verb/phrase
140
+ - Example: "compile" with no matching skill in "Available Skills"
141
+ → action "Ignore unknown 'compile' request"
142
+ - Example: "build" with no matching skill in "Available Skills" →
143
+ action "Ignore unknown 'build' request"
105
144
 
106
145
  4. **Vague/ambiguous requests** without clear verb:
107
146
  - Phrases like "do something", "handle it" → ignore type
@@ -128,6 +167,22 @@ components (e.g., {project.VARIANT.path}, {env.TYPE.config},
128
167
  - Example: "build alpha" → variant is "alpha"
129
168
  - Example: "deploy to staging" → variant is "staging"
130
169
  - Example: "process experimental" → variant is "experimental"
170
+ - **CRITICAL**: If the variant CANNOT be identified from the user's
171
+ request, you MUST create a DEFINE task instead (see step 1a below)
172
+
173
+ 1a. **When variant is unclear** - Create a DEFINE task:
174
+ - **NEVER use placeholder values** like `<UNKNOWN>`, `UNKNOWN`, or any
175
+ other placeholder
176
+ - **NEVER leave variant unresolved** or use temporary values
177
+ - **ALWAYS create a DEFINE task** with type "define" that includes:
178
+ - params.skill: the skill name requiring variant selection
179
+ - params.options: array of descriptive options for each available
180
+ variant
181
+ - Example: User says "deploy" without specifying environment → Create
182
+ DEFINE task with options like "Deploy to staging environment" and
183
+ "Deploy to production environment"
184
+ - The define task will prompt the user to select the variant before
185
+ execution continues
131
186
 
132
187
  2. **Normalize to lowercase**: Convert variant name to lowercase
133
188
  - "Alpha" → "alpha"
@@ -160,6 +215,19 @@ components (e.g., {project.VARIANT.path}, {env.TYPE.config},
160
215
  {project.beta.config}` should include config:
161
216
  ["project.beta.repo", "project.beta.config"]
162
217
 
218
+ 6. **Multi-step skills MUST use group structure**:
219
+ - **CRITICAL**: When a skill has multiple execution steps, it MUST
220
+ be represented as a group task with those steps as subtasks
221
+ - **NEVER use a flat execute task** for multi-step skills
222
+ - Single execution step: Can be represented as a leaf execute task
223
+ - Multiple execution steps: ALWAYS use group structure, never flat
224
+ - Note: The same skill can appear multiple times if the user
225
+ requests it in sequence (e.g., "deploy alpha, test, deploy beta")
226
+ - Each occurrence must still use group structure
227
+ - Example: "deploy alpha" → "Deploy Alpha" (group) with subtasks
228
+ - Example: "deploy alpha, test, deploy alpha" → "Deploy Alpha"
229
+ (group), "Run tests" (execute), "Deploy Alpha" (group)
230
+
163
231
  **Examples**:
164
232
 
165
233
  User request with variant placeholder
@@ -188,6 +256,10 @@ User request with multiple config expressions
188
256
  - Multiple config expressions from the same task's commands
189
257
 
190
258
  **Critical Rules**:
259
+ - **NEVER use placeholder values** like `<UNKNOWN>`, `UNKNOWN`, or
260
+ leave variant unresolved
261
+ - **If variant cannot be determined** from user request, create a
262
+ DEFINE task with options
191
263
  - NEVER leave uppercase placeholder components unresolved
192
264
  - The uppercase word can be ANY name (VARIANT, TARGET, TYPE,
193
265
  PRODUCT, etc.)
@@ -269,20 +341,40 @@ even if they use the same action verb.
269
341
 
270
342
  ## Strict Skill Matching
271
343
 
272
- Skills define the ONLY operations you can execute. If skills are
273
- provided in the "Available Skills" section:
344
+ **CRITICAL - Examples Are NOT Real Skills:**
345
+
346
+ - **All examples in these instructions are for illustration ONLY**:
347
+ Examples like "build", "deploy", "process" are NOT real skills
348
+ - **ONLY the Available Skills section contains real skills**: The
349
+ Available Skills section in the system prompt is the ONLY source of
350
+ truth
351
+ - **Never use example skills**: Do NOT create tasks based on skills
352
+ mentioned in examples unless they appear in Available Skills
353
+ - **When no Available Skills section exists**: ALL action verbs must
354
+ result in "ignore" type tasks
355
+
356
+ **CRITICAL**: Skills in the "Available Skills" section define the ONLY
357
+ operations you can execute. This is an EXHAUSTIVE and COMPLETE list.
274
358
 
275
359
  **EXHAUSTIVE and EXCLUSIVE rules:**
276
360
 
277
- - The list of available skills is COMPLETE
278
- - If an action verb does NOT have a matching skill, it CANNOT be
279
- executed
280
- - You MUST create an "ignore" type task for ANY verb without a matching
281
- skill
282
- - There are NO implicit or assumed operations
283
- - **DO NOT infer follow-up actions based on context**
284
- - **DO NOT assume operations even if they seem logically related to a
285
- matched skill**
361
+ - **ONLY skills in "Available Skills" section exist**: The skills
362
+ listed in the "Available Skills" section are the ONLY skills
363
+ available. Do NOT assume skills exist based on examples in these
364
+ instructions.
365
+ - **Empty or missing "Available Skills" = NO execute tasks**: If there
366
+ is no "Available Skills" section, or if it's empty, you CANNOT
367
+ create ANY execute tasks. ALL action verbs must result in "ignore"
368
+ type tasks.
369
+ - **The list is COMPLETE**: The "Available Skills" list is exhaustive.
370
+ There are no hidden or implicit skills.
371
+ - **No matching skill = ignore task**: If an action verb does NOT have
372
+ a matching skill in "Available Skills", you MUST create an "ignore"
373
+ type task
374
+ - **NO assumptions**: There are NO implicit or assumed operations
375
+ - **NO inference**: DO NOT infer follow-up actions based on context
376
+ - **NO related operations**: DO NOT assume operations even if they
377
+ seem logically related to a matched skill
286
378
 
287
379
  **Common verbs that need skills:**
288
380
 
@@ -42,6 +42,10 @@ export const executeTool = {
42
42
  required: ['description', 'command'],
43
43
  },
44
44
  },
45
+ error: {
46
+ type: 'string',
47
+ description: 'Error message when execution cannot proceed. Only include this field when returning an empty commands array due to validation failure (e.g., skill not found, missing Steps/Execution sections). Describes what went wrong.',
48
+ },
45
49
  },
46
50
  required: ['message', 'summary', 'commands'],
47
51
  },
@@ -90,6 +90,7 @@ export const CommandResultSchema = z.object({
90
90
  tasks: z.array(ScheduledTaskSchema),
91
91
  answer: z.string().optional(),
92
92
  commands: z.array(ExecuteCommandSchema).optional(),
93
+ error: z.string().optional(),
93
94
  debug: z.array(ComponentDefinitionSchema).optional(),
94
95
  });
95
96
  /**