@output.ai/cli 0.0.3 → 0.0.5

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.
@@ -1,466 +1,260 @@
1
1
  ---
2
+ argument-hint: [workflow-description-and-additional-instructions]
2
3
  description: Workflow Planning Command for Output SDK
3
- version: 2.0
4
- encoding: UTF-8
4
+ version: 0.0.1
5
+ model: claude-opus-4-1
5
6
  ---
6
7
 
7
- # Plan Workflow Command
8
+ Your task is to generate a comprehensive Output.ai workflow implementation plan in markdown format.
9
+
10
+ The plan will be displayed to the user who can then decide what to do with it.
11
+
12
+ Please respond with only the final version of the plan.
13
+
14
+ Use the todo tool to track your progress through the plan creation process.
15
+
16
+ # Plan Creation Rules
8
17
 
9
18
  ## Overview
10
19
 
11
- Generate comprehensive workflow implementation plans following Output SDK patterns and best practices.
20
+ Generate detailed specifications for implementation of a new workflow.
12
21
 
13
22
  <pre_flight_check>
14
- EXECUTE: @{{projectPath}}/.outputai/instructions/meta/pre_flight.md
23
+ EXECUTE: @.outputai/instructions/meta/pre_flight.md
15
24
  </pre_flight_check>
16
25
 
17
26
  <process_flow>
18
27
 
19
- <step number="1" subagent="workflow_planner" name="requirements_analysis">
20
-
21
- ### Step 1: Requirements Analysis
22
-
23
- Use the workflow_planner subagent to analyze the workflow requirements and infer smart defaults.
24
-
25
- <smart_inference>
26
- <approach>Infer requirements from description and apply defaults</approach>
27
- <defaults>
28
- - retry_policy: 3 attempts with exponential backoff
29
- - timeout: 30s for activities, 5m for workflows
30
- - openai_model: gpt-4o unless specified
31
- - error_handling: ApplicationFailure patterns
32
- - performance: clarity over speed optimization
33
- </defaults>
34
- </smart_inference>
35
-
36
- <critical_questions>
37
- ASK ONLY if cannot be inferred:
38
- - Ambiguous input/output structures
39
- - Non-standard API integrations
40
- - Complex orchestration patterns
41
- - Unusual error handling requirements
42
- </critical_questions>
43
-
44
- <requirements_template>
45
- ## Requirements Analysis
46
-
47
- **Goal**: {{workflowGoal}}
48
- **Input**: {{inputDescription}}
49
- **Output**: {{outputDescription}}
50
- **External Services**: {{servicesList}}
51
- **Constraints**: {{constraintsList}}
52
- </requirements_template>
28
+ <step number="1" name="context_gathering">
29
+
30
+ ### Step 1: Context Gathering
31
+
32
+ Take the time to gather all the context you need to create a comprehensive plan.
33
+ 1. Read any given files or links
34
+ 2. Find any related workflows in the project
35
+ 3. Read the projects documentation files
53
36
 
54
37
  </step>
55
38
 
56
- <step number="2" name="pattern_analysis">
39
+ <step number="2" name="requirements_clarification">
57
40
 
58
- ### Step 2: Pattern Analysis
41
+ ### Step 2: Requirements Clarification
59
42
 
60
- <analysis_targets>
61
- - Check the repository for similar implementations
62
- - Identify reusable activities
63
- - Find applicable prompt templates in workflow directories
64
- - Locate relevant schemas and types
65
- </analysis_targets>
43
+ Clarify scope boundaries and technical considerations by asking numbered questions as needed to ensure clear requirements before proceeding.
66
44
 
67
- <pattern_collection>
68
- <existing_workflows>workflows with similar purpose or structure</existing_workflows>
69
- <reusable_activities>activities that can be leveraged</reusable_activities>
70
- <error_patterns>established error handling patterns</error_patterns>
71
- <retry_policies>common retry configurations</retry_policies>
72
- </pattern_collection>
45
+ <clarification_areas>
46
+ <scope>
47
+ - in_scope: what is included
48
+ - out_of_scope: what is excluded (optional)
49
+ </scope>
50
+ <technical>
51
+ - functionality specifics
52
+ - UI/UX requirements
53
+ - integration points
54
+ </technical>
55
+ </clarification_areas>
73
56
 
57
+ <decision_tree>
58
+ IF clarification_needed:
59
+ ASK numbered_questions
60
+ WAIT for_user_response
61
+ ELSE:
62
+ PROCEED schema_definition
63
+ </decision_tree>
74
64
  </step>
75
65
 
76
- <step number="3" subagent="workflow_planner" name="schema_definition">
66
+ <step number="3" name="workflow_design">
77
67
 
78
- ### Step 3: Schema Definition
68
+ ### Step 3: Workflow Design
79
69
 
80
- Use the workflow_planner subagent to define input/output schemas with Zod validation.
70
+ Design the workflow with clear single purpose steps and sound orchestration logic.
81
71
 
82
- <schema_requirements>
83
- - Use simple TypeScript interfaces for basic types
84
- - Use Zod schemas when validation is needed
85
- - Keep field types simple: string, number, boolean, object
86
- - Mark optional fields with ? in interfaces or .optional() in Zod
87
- - Export types for reuse across workflow files
88
- </schema_requirements>
72
+ <thought_process>
89
73
 
90
- <input_schema_template>
91
- ```typescript
92
- // For simple types (types.ts)
93
- export interface {{WorkflowName}}Input {
94
- {{requiredField}}: string;
95
- {{optionalField}}?: string;
96
- }
74
+ 1. Define the workflow name and description
75
+ 2. What is a valid output schema for the workflow?
76
+ 3. What is a valid input schema for the workflow?
77
+ 4. What needs to happen to transform the input into the output?
78
+ 5. What are the atomic steps that need to happen to transform the input into the output?
79
+ 6. How do these steps relate to each other?
80
+ 7. Are any of these steps conditional?
81
+ 8. Are any of these steps already defined in the project?
82
+ 9. How could these steps fail, and how should we handle them? (retry, backoff, etc.)
97
83
 
98
- // Or for validation with Zod
99
- import { z } from 'zod';
84
+ </thought_process>
100
85
 
101
- export const {{WorkflowName}}InputSchema = z.object({
102
- {{requiredField}}: z.string(),
103
- {{optionalField}}: z.string().optional()
104
- });
86
+ <workflow_template>
87
+ ```typescript
88
+ import { workflow, z } from 'output.ai/core';
89
+ import { sumValues } from './steps.js';
105
90
 
106
- export type {{WorkflowName}}Input = z.infer<typeof {{WorkflowName}}InputSchema>;
107
- ```
108
- </input_schema_template>
91
+ const inputSchema = z.object( {
92
+ values: z.array( z.number() )
93
+ } );
109
94
 
110
- <output_schema_template>
111
- ```typescript
112
- export interface {{WorkflowName}}Output {
113
- result: string;
114
- // Additional fields as needed
115
- {{additionalFields}}
95
+ const outputSchema = z.object( {
96
+ result: z.number()
97
+ } );
98
+
99
+ export default workflow( {
100
+ name: 'simple',
101
+ description: 'A simple workflow',
102
+ inputSchema,
103
+ outputSchema,
104
+ fn: async input => {
105
+ const result = await sumValues( input.values );
106
+ return { result };
116
107
  }
117
- ```
118
- </output_schema_template>
108
+ } );
109
+ ```
110
+ </workflow_template>
119
111
 
120
- </step>
112
+ <step number="4" name="step_design">
113
+ ### Step 4: Step Design
121
114
 
122
- <step number="4" subagent="workflow_planner" name="activity_design">
123
-
124
- ### Step 4: Activity Design
125
-
126
- Use the workflow_planner subagent to design workflow activities with clear boundaries.
127
-
128
- <activity_template>
129
- ### Step: `{{stepName}}`
130
-
131
- **Purpose**: {{stepPurpose}}
132
-
133
- **Implementation (steps.ts)**:
134
- ```typescript
135
- import { step } from '@output.ai/core';
136
- import { generateText, generateObject } from '@output.ai/llm';
137
- import { loadPrompt } from '@output.ai/prompt';
138
- import type { Prompt } from '@output.ai/llm';
139
-
140
- export const {{stepName}} = step({
141
- name: '{{stepName}}',
142
- description: '{{stepDescription}}',
143
- inputSchema: {
144
- type: 'object',
145
- required: [{{requiredFields}}],
146
- properties: {
147
- {{fieldName}}: { type: '{{fieldType}}' }
148
- // Add more fields as needed
149
- }
150
- },
151
- outputSchema: {
152
- type: '{{outputType}}'
153
- },
154
- fn: async (input) => {
155
- // Implementation logic
156
- {{implementationLogic}}
157
-
158
- // For LLM operations:
159
- // const prompt = loadPrompt('{{promptName}}', input);
160
- // const response = await generateText(prompt as Prompt);
161
-
162
- return {{returnValue}};
163
- }
164
- });
165
- ```
166
-
167
- **Error Handling**:
168
- - Use `FatalError` from '@output.ai/core' for non-retryable errors
169
- - Standard errors will be retried based on workflow configuration
170
- </activity_template>
115
+ Design the steps with clear boundaries.
171
116
 
172
- <decision_tree>
173
- IF step_uses_llm:
174
- USE generateText or generateObject from @output.ai/llm
175
- LOAD prompts with loadPrompt from @output.ai/prompt
176
- DEFINE error handling with FatalError
177
- ELSE IF step_uses_external_service:
178
- IMPORT required service libraries
179
- HANDLE errors appropriately
180
- ELSE:
181
- IMPLEMENT pure logic
182
- VALIDATE inputs/outputs
183
- </decision_tree>
117
+ <step_template>
118
+ ```typescript
119
+ import { step, z } from 'output.ai/core';
120
+
121
+ export const sumValues = step( {
122
+ name: 'sumValues',
123
+ description: 'Sum all values',
124
+ inputSchema: z.array( z.number() ),
125
+ outputSchema: z.number(),
126
+ fn: async numbers => numbers.reduce( ( v, n ) => v + n, 0 )
127
+ } );
128
+ ```
129
+ </step_template>
184
130
 
185
131
  </step>
186
132
 
187
- <step number="5" subagent="workflow_planner" name="prompt_engineering">
133
+ <step number="5" name="prompt_engineering">
188
134
 
189
- ### Step 5: Prompt Engineering (Conditional)
135
+ ### Step 5: Prompt Engineering
190
136
 
191
- Use the workflow_planner subagent to design LLM prompts if the workflow uses AI services.
137
+ If any of the steps use an LLM, design the prompts for the steps.
192
138
 
193
139
  <decision_tree>
194
- IF workflow_uses_llm:
195
- EXECUTE prompt_design
140
+ IF step_uses_llm:
141
+ USE prompt_step_template
196
142
  ELSE:
197
143
  SKIP to step 6
198
144
  </decision_tree>
199
145
 
200
- <prompt_template>
201
- **Prompt File ({{promptName}}@v1.prompt)**:
202
- ```yaml
203
- ---
204
- provider: {{provider}} # anthropic, openai, etc.
205
- model: {{model}} # e.g., claude-sonnet-4-20250514, gpt-4o
206
- temperature: {{temperature}} # e.g., 0.7
207
- ---
208
-
209
- <assistant>
210
- {{systemPrompt}}
211
- </assistant>
212
-
213
- <user>
214
- {{userPrompt}}
215
-
216
- Variables to include:
217
- {{ "{{ " }}{{variableName}}{{ " }}" }}
218
- </user>
219
- ```
220
- </prompt_template>
221
-
222
- <template_variables>
223
- **Template Variables**:
224
- - `{{ "{{ " }}{{variableName1}}{{ " }}" }}` - {{description1}}
225
- - `{{ "{{ " }}{{variableName2}}{{ " }}" }}` - {{description2}}
226
-
227
- **Loading in Step**:
228
- ```typescript
229
- const prompt = loadPrompt('{{promptName}}@v1', {
230
- {{variableName1}}: input.{{field1}},
231
- {{variableName2}}: input.{{field2}}
232
- });
233
- ```
234
- </template_variables>
235
-
236
- </step>
237
-
238
- <step number="6" subagent="workflow_planner" name="orchestration_planning">
239
-
240
- ### Step 6: Workflow Orchestration
241
-
242
- Use the workflow_planner subagent to define the workflow execution logic.
243
-
244
- <orchestration_template>
245
- ## Workflow Logic
246
-
247
- 1. **Input Validation**: `validateWorkflowInput(rawInput, {{WorkflowName}}InputSchema)`
248
- 2. **{{Step2Name}}**: {{step2Description}}
249
- 3. **{{Step3Name}}**: Call `{{activityName}}({{parameters}})`
250
- 4. **{{Step4Name}}**: {{step4Description}}
251
- 5. **Result Assembly**: Structure final output with metadata
252
- 6. **Return**: Complete {{WorkflowName}}Output object
253
-
254
- **Conditional Logic**:
255
- {{conditionalRules}}
256
- </orchestration_template>
257
-
258
- <workflow_code_template>
259
- **Workflow File (workflow.ts)**:
260
- ```typescript
261
- import { workflow } from '@output.ai/core';
262
- import { {{stepImports}} } from './steps.js';
263
- import type { {{WorkflowName}}Input, {{WorkflowName}}Output } from './types.js';
264
-
265
- export default workflow({
266
- name: '{{workflowName}}',
267
- description: '{{workflowDescription}}',
268
- inputSchema: {
269
- type: 'object',
270
- required: [{{requiredFields}}],
271
- properties: {
272
- {{fieldName}}: { type: '{{fieldType}}' }
273
- // Define all input fields
274
- }
275
- },
276
- outputSchema: {
277
- type: 'object',
278
- required: [{{outputRequiredFields}}],
279
- properties: {
280
- result: { type: 'string' }
281
- // Define output structure
282
- }
283
- },
284
- fn: async (input: {{WorkflowName}}Input): Promise<{{WorkflowName}}Output> => {
285
- // Workflow orchestration logic
286
- {{orchestrationSteps}}
287
-
288
- // Example step invocation:
289
- // const result = await {{stepName}}({ {{stepParams}} });
290
-
291
- return {
292
- result: {{resultValue}}
293
- };
294
- }
295
- });
296
- ```
297
- </workflow_code_template>
298
-
299
- </step>
300
-
301
- <step number="7" name="plan_document_creation">
302
-
303
- ### Step 7: Create Plan Document
304
-
305
- <plan_structure>
306
- # Workflow Plan: {{WorkflowName}}
146
+ <prompt_step_template>
147
+ ```typescript
148
+ import { step, z } from 'output.ai/core';
149
+ import { loadPrompt } from 'output.ai/prompt';
150
+ import { generateText } from 'output.ai/llm';
151
+
152
+ export const aiSdkPrompt = step( {
153
+ name: 'aiSdkPrompt',
154
+ description: 'Generates a prompt',
155
+ inputSchema: z.object( {
156
+ topic: z.string()
157
+ } ),
158
+ outputSchema: z.string(),
159
+ fn: async ( { topic } ) => {
160
+ const prompt = loadPrompt( 'prompt@v1', { topic } );
161
+ const response = await generateText( { prompt } );
162
+ return response;
163
+ }
164
+ } );
307
165
 
308
- ## Overview
309
- - **Purpose**: {{purpose}}
310
- - **Use Case**: {{useCase}}
311
- - **Key Features**: {{features}}
166
+ export const finalStep = step( {
167
+ name: 'finalStep',
168
+ outputSchema: z.boolean(),
169
+ fn: async () => true
170
+ } );
312
171
 
313
- ## Technical Specifications
314
- {{schemaDefinitions}}
172
+ ```
173
+ </prompt_step_template>
315
174
 
316
- ## Activity Specifications
317
- {{activityDefinitions}}
175
+ <prompt_template>
176
+ ```
177
+ ---
178
+ provider: anthropic
179
+ model: claude-sonnet-4-20250514
180
+ temperature: 0.7
181
+ ---
318
182
 
319
- ## Prompt Specifications (if applicable)
320
- {{promptDefinitions}}
183
+ <assistant>
184
+ You are a concise assistant.
185
+ </assistant>
321
186
 
322
- ## Workflow Orchestration
323
- {{orchestrationLogic}}
187
+ <user>
188
+ Explain about "{{ topic }}"
189
+ </user>
324
190
 
325
- ## Implementation Checklist
326
- - [ ] Create workflow directory structure
327
- - [ ] Implement input/output schemas
328
- - [ ] Create activity functions
329
- - [ ] Design prompt templates (if needed)
330
- - [ ] Implement workflow logic
331
- - [ ] Add to entrypoint.ts
332
- - [ ] Write unit tests
333
- - [ ] Test with flow-cli
334
- - [ ] Run integration tests
335
- - [ ] Update documentation
336
- </plan_structure>
191
+ ```
337
192
 
338
- <file_location>
339
- workflow_plans/{{workflowName}}-plan.md
340
- </file_location>
193
+ </prompt_template>
341
194
 
342
195
  </step>
343
196
 
344
- <step number="8" subagent="workflow_planner" name="testing_strategy">
345
-
346
- ### Step 8: Define Testing Strategy
347
-
348
- Use the workflow_planner subagent to create comprehensive testing requirements.
349
-
350
- <test_scenarios>
351
- ## Testing Plan
197
+ <step number="6" name="testing_strategy">
352
198
 
353
- ### Happy Path Tests
354
- 1. **Complete Input**: All fields provided, successful execution
355
- 2. **Minimal Input**: Required fields only
356
- 3. **Variations**: Different input combinations
199
+ ### Step 6: Testing Strategy
357
200
 
358
- ### Edge Cases
359
- 1. **Boundary Values**: Min/max values, empty strings
360
- 2. **Special Characters**: Unicode, punctuation
361
- 3. **Optional Fields**: With/without optional data
201
+ Design the testing strategy for the workflow.
202
+ <thought_process>
203
+ 1. What unit tests do we need to write?
204
+ 2. How can I run the workflow?
205
+ 3. What cases do we need to validate?
206
+ </thought_process>
362
207
 
363
- ### Error Scenarios
364
- 1. **Invalid Input**: Malformed data, wrong types
365
- 2. **Service Failures**: API errors, timeouts
366
- 3. **Schema Violations**: Invalid responses
367
-
368
- ### Performance Tests
369
- 1. **Response Time**: Must complete within {{timeout}}
370
- 2. **Concurrent Execution**: Multiple workflow instances
371
- 3. **Resource Usage**: Monitor memory and CPU
372
- </test_scenarios>
208
+ </step>
373
209
 
374
- <test_commands>
375
- ```bash
376
- # Build the workflow
377
- npm run build
210
+ <step number="7" name="generate_plan">
211
+ ### Step 7: Generate Plan
378
212
 
379
- # Start the worker (in one terminal)
380
- npm run start # or flow-worker
213
+ Generate the complete plan in markdown format.
381
214
 
382
- # Execute workflow (in another terminal or via API)
383
- # Via API endpoint if configured
384
- curl -X POST http://localhost:3000/workflows/{{workflowName}} \
385
- -H "Content-Type: application/json" \
386
- -d '{{testPayload}}'
215
+ Note that every implementation should start with running the cli command `output workflow generate --skeleton` to create the workflow directory structure.
387
216
 
388
- # Run validation
389
- ./run.sh validate
217
+ <file_template>
218
+ <header>
219
+ # Workflow Requirements Document
390
220
 
391
- # Development mode with Docker
392
- ./run.sh dev
393
- ```
394
- </test_commands>
221
+ > Workflow: [WORKFLOW_NAME]
222
+ > Created: [CURRENT_DATE]
223
+ </header>
224
+ <required_sections>
225
+ - Overview
226
+ - Spec Scope
227
+ - Out of Scope
228
+ - Workflow Design
229
+ - Step Design
230
+ - Testing Strategy
231
+ - Implementation Phases
232
+ </required_sections>
233
+ </file_template>
395
234
 
396
235
  </step>
397
236
 
398
- <step number="9" name="review_checkpoint">
399
-
400
- ### Step 9: Review and Approval
401
-
402
- Request user review of the workflow plan before proceeding to implementation.
237
+ <step_number="8" name="post_flight_check">
403
238
 
404
- <review_template>
405
- I've completed the workflow plan for {{workflowName}}:
406
239
 
407
- 📋 **Plan Document**: `workflow_plans/{{workflowName}}-plan.md`
240
+ ### Step 8: Post-Flight Check
408
241
 
409
- The plan includes:
410
- - Complete input/output schemas with Zod validation
411
- - {{activityCount}} activity specifications with error handling
412
- - Workflow orchestration logic
413
- - Comprehensive testing strategy
414
- - Implementation checklist
242
+ Verify the plan is complete and ready for implementation.
415
243
 
416
- Please review the plan and let me know if any modifications are needed.
417
- </review_template>
244
+ <post_flight_check>
245
+ EXECUTE: @.outputai/instructions/meta/post_flight.md
246
+ </post_flight_check>
418
247
 
419
248
  </step>
420
249
 
421
250
  </process_flow>
422
251
 
423
252
  <post_flight_check>
424
- EXECUTE: @{{projectPath}}/.outputai/instructions/meta/post_flight.md
253
+ EXECUTE: @.outputai/instructions/meta/post_flight.md
425
254
  </post_flight_check>
426
255
 
427
- ## Command Usage
428
-
429
- ### Basic Planning
430
- ```
431
- /plan-workflow "Process customer support tickets using AI categorization"
432
- ```
256
+ ---- START ----
433
257
 
434
- ### With Complexity Hints
435
- ```
436
- /plan-workflow "Multi-step data pipeline with validation" --complexity=complex --integrations=apis,llm
437
- ```
438
-
439
- ### Integration-Heavy Workflow
440
- ```
441
- /plan-workflow "E-commerce order fulfillment" --integrations=payment,inventory,shipping
442
- ```
258
+ Workflow Description and Additional Instructions:
443
259
 
444
- ## Quality Standards
445
-
446
- ### Plan Completeness
447
- - All schemas defined with exact types
448
- - Every activity specified with I/O and processing logic
449
- - External services identified with SDK references
450
- - Error handling complete for all scenarios
451
- - Testing scenarios documented with commands
452
-
453
- ### Output SDK Compliance
454
- - ES module imports with .js extensions
455
- - Use @output.ai/core for workflow and step functions
456
- - Use @output.ai/llm for AI operations
457
- - Use @output.ai/prompt for prompt loading
458
- - Use FatalError from @output.ai/core for non-retryable errors
459
- - Follow established workflow file structure (workflow.ts, steps.ts, types.ts, *.prompt)
460
-
461
- ### Implementation Readiness
462
- - Developer can implement without clarification
463
- - All code examples compile without modification
464
- - Testing approach is comprehensive
465
- - Performance requirements are measurable
466
- - Documentation is clear and actionable
260
+ $ARGUMENTS
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Mock for @anthropic-ai/claude-agent-sdk
3
+ */
4
+ export declare const mockClaudeAgentSDK: {
5
+ Agent: import("vitest").Mock<(...args: any[]) => any>;
6
+ };
7
+ /**
8
+ * Mock for @output.ai/llm
9
+ */
10
+ export declare const mockLLM: {
11
+ generateText: import("vitest").Mock<(...args: any[]) => any>;
12
+ };
13
+ /**
14
+ * Mock for child_process spawn (for agents init)
15
+ */
16
+ export declare const mockSpawn: import("vitest").Mock<(...args: any[]) => any>;
17
+ /**
18
+ * Mock for fs/promises
19
+ */
20
+ export declare const mockFS: {
21
+ access: import("vitest").Mock<(...args: any[]) => any>;
22
+ mkdir: import("vitest").Mock<(...args: any[]) => any>;
23
+ writeFile: import("vitest").Mock<(...args: any[]) => any>;
24
+ readFile: import("vitest").Mock<(...args: any[]) => any>;
25
+ stat: import("vitest").Mock<(...args: any[]) => any>;
26
+ };
27
+ /**
28
+ * Mock for @inquirer/prompts
29
+ */
30
+ export declare const mockInquirer: {
31
+ input: import("vitest").Mock<(...args: any[]) => any>;
32
+ confirm: import("vitest").Mock<(...args: any[]) => any>;
33
+ };
34
+ /**
35
+ * Reset all mocks
36
+ */
37
+ export declare function resetAllMocks(): void;