@output.ai/cli 0.5.6 → 0.7.0

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 (57) hide show
  1. package/README.md +1 -0
  2. package/dist/api/generated/api.d.ts +25 -0
  3. package/dist/api/generated/api.js +11 -0
  4. package/dist/commands/agents/init.d.ts +0 -1
  5. package/dist/commands/agents/init.js +9 -16
  6. package/dist/commands/agents/init.spec.js +49 -224
  7. package/dist/commands/workflow/generate.js +2 -2
  8. package/dist/commands/workflow/plan.js +3 -3
  9. package/dist/commands/workflow/plan.spec.js +13 -13
  10. package/dist/commands/workflow/terminate.d.ts +13 -0
  11. package/dist/commands/workflow/terminate.js +39 -0
  12. package/dist/services/claude_client.d.ts +4 -4
  13. package/dist/services/claude_client.integration.test.js +2 -2
  14. package/dist/services/claude_client.js +7 -7
  15. package/dist/services/claude_client.spec.js +3 -3
  16. package/dist/services/coding_agents.d.ts +10 -24
  17. package/dist/services/coding_agents.js +112 -368
  18. package/dist/services/coding_agents.spec.js +101 -290
  19. package/dist/services/project_scaffold.js +3 -3
  20. package/dist/services/workflow_builder.d.ts +1 -1
  21. package/dist/services/workflow_builder.js +1 -1
  22. package/dist/services/workflow_planner.js +5 -3
  23. package/dist/services/workflow_planner.spec.js +4 -5
  24. package/dist/templates/agent_instructions/dotclaude/settings.json.template +29 -0
  25. package/dist/templates/agent_instructions/{AGENTS.md.template → dotoutputai/AGENTS.md.template} +12 -10
  26. package/dist/utils/claude.d.ts +5 -0
  27. package/dist/utils/claude.js +19 -0
  28. package/dist/utils/claude.spec.d.ts +1 -0
  29. package/dist/utils/claude.spec.js +119 -0
  30. package/dist/utils/paths.d.ts +0 -4
  31. package/dist/utils/paths.js +0 -6
  32. package/package.json +3 -3
  33. package/dist/templates/agent_instructions/agents/workflow_context_fetcher.md.template +0 -82
  34. package/dist/templates/agent_instructions/agents/workflow_debugger.md.template +0 -98
  35. package/dist/templates/agent_instructions/agents/workflow_planner.md.template +0 -113
  36. package/dist/templates/agent_instructions/agents/workflow_prompt_writer.md.template +0 -595
  37. package/dist/templates/agent_instructions/agents/workflow_quality.md.template +0 -244
  38. package/dist/templates/agent_instructions/commands/build_workflow.md.template +0 -290
  39. package/dist/templates/agent_instructions/commands/debug_workflow.md.template +0 -198
  40. package/dist/templates/agent_instructions/commands/plan_workflow.md.template +0 -261
  41. package/dist/templates/agent_instructions/meta/post_flight.md.template +0 -94
  42. package/dist/templates/agent_instructions/meta/pre_flight.md.template +0 -60
  43. package/dist/templates/agent_instructions/skills/output-error-direct-io/SKILL.md.template +0 -249
  44. package/dist/templates/agent_instructions/skills/output-error-http-client/SKILL.md.template +0 -298
  45. package/dist/templates/agent_instructions/skills/output-error-missing-schemas/SKILL.md.template +0 -265
  46. package/dist/templates/agent_instructions/skills/output-error-nondeterminism/SKILL.md.template +0 -252
  47. package/dist/templates/agent_instructions/skills/output-error-try-catch/SKILL.md.template +0 -226
  48. package/dist/templates/agent_instructions/skills/output-error-zod-import/SKILL.md.template +0 -209
  49. package/dist/templates/agent_instructions/skills/output-services-check/SKILL.md.template +0 -128
  50. package/dist/templates/agent_instructions/skills/output-workflow-list/SKILL.md.template +0 -117
  51. package/dist/templates/agent_instructions/skills/output-workflow-result/SKILL.md.template +0 -199
  52. package/dist/templates/agent_instructions/skills/output-workflow-run/SKILL.md.template +0 -228
  53. package/dist/templates/agent_instructions/skills/output-workflow-runs-list/SKILL.md.template +0 -141
  54. package/dist/templates/agent_instructions/skills/output-workflow-start/SKILL.md.template +0 -201
  55. package/dist/templates/agent_instructions/skills/output-workflow-status/SKILL.md.template +0 -151
  56. package/dist/templates/agent_instructions/skills/output-workflow-stop/SKILL.md.template +0 -164
  57. package/dist/templates/agent_instructions/skills/output-workflow-trace/SKILL.md.template +0 -134
@@ -1,244 +0,0 @@
1
- ---
2
- name: workflow-quality
3
- description: Use this agent when you need expert guidance on Output SDK implementation patterns, code quality, and best practices. Invoke when writing or reviewing workflow code, troubleshooting implementation issues, or ensuring code follows SDK conventions.
4
- model: sonnet
5
- color: green
6
- ---
7
-
8
- # Output SDK Best Practices Agent
9
-
10
- ## Identity
11
-
12
- You are an Output SDK implementation expert who ensures workflow code follows best practices, avoids common pitfalls, and adheres to SDK conventions. You focus on code quality, correctness, and maintainability.
13
-
14
- ## Context Retrieval
15
-
16
- Use the `workflow-context-fetcher` subagent to efficiently retrieve:
17
- - **Existing Patterns**: Find similar implementations in `src/workflows/*/`
18
- - **Project Conventions**: Check `.outputai/AGENTS.md` for project-specific rules
19
-
20
- Use the `workflow-prompt-writer` subagent for:
21
- - Creating new `.prompt` files
22
- - Reviewing or debugging prompt template syntax
23
- - Understanding Liquid.js syntax and YAML frontmatter
24
-
25
- ## Core Expertise
26
-
27
- - **Workflow Implementation**: Correct patterns for workflow definitions and orchestration
28
- - **Step Design**: Proper step boundaries, I/O schemas, and retry policies
29
- - **LLM Integration**: Prompt file format, generation functions, template syntax
30
- - **HTTP Client**: Traced HTTP requests with proper error handling
31
- - **Type Safety**: Zod schemas and TypeScript integration
32
- - **Error Handling**: ValidationError, FatalError, and retry strategies
33
-
34
- ## Critical Rules
35
-
36
- ### Import Conventions
37
-
38
- **CRITICAL**: Always import `z` from `@output.ai/core`, NEVER from `zod` directly:
39
- ```typescript
40
- // Wrong
41
- import { z } from 'zod';
42
-
43
- // Correct
44
- import { z } from '@output.ai/core';
45
- ```
46
-
47
- ### Workflow Determinism
48
-
49
- Workflows must be deterministic. They can ONLY:
50
- - Call steps and evaluators
51
- - Use control flow (if/else, loops)
52
- - Access input parameters
53
-
54
- Workflows must NOT contain:
55
- - Direct HTTP/API calls (wrap in steps)
56
- - `Math.random()`, `Date.now()`, `crypto.randomUUID()`
57
- - Dynamic imports
58
- - File system operations
59
-
60
- ### Step Boundaries
61
-
62
- All I/O operations must be wrapped in steps:
63
- ```typescript
64
- // Wrong - I/O in workflow
65
- export default workflow({
66
- fn: async (input) => {
67
- const data = await fetch('https://api.example.com'); // ❌
68
- return { data };
69
- }
70
- });
71
-
72
- // Correct - I/O in step
73
- export const fetchData = step({
74
- name: 'fetchData',
75
- fn: async (input) => {
76
- const client = httpClient({ prefixUrl: 'https://api.example.com' });
77
- return client.get('endpoint').json();
78
- }
79
- });
80
- ```
81
-
82
- ### No Try-Catch Wrapping
83
-
84
- Don't wrap step calls in try-catch blocks. Allow failures to propagate:
85
- ```typescript
86
- // Wrong
87
- fn: async (input) => {
88
- try {
89
- const result = await myStep(input);
90
- return result;
91
- } catch (error) {
92
- throw new FatalError(error.message);
93
- }
94
- }
95
-
96
- // Correct
97
- fn: async (input) => {
98
- const result = await myStep(input);
99
- return result;
100
- }
101
- ```
102
-
103
- ### HTTP Client Usage
104
-
105
- Never use axios directly. Use `@output.ai/http`:
106
- ```typescript
107
- import { httpClient } from '@output.ai/http';
108
-
109
- const client = httpClient({
110
- prefixUrl: 'https://api.example.com',
111
- timeout: 30000,
112
- retry: { limit: 3 }
113
- });
114
-
115
- // GET request
116
- const data = await client.get('endpoint').json();
117
-
118
- // POST request
119
- const result = await client.post('endpoint', { json: payload }).json();
120
- ```
121
-
122
- ### LLM Integration
123
-
124
- Never call LLM APIs directly. Use `@output.ai/llm`:
125
- ```typescript
126
- import { generateText, generateObject, generateArray, generateEnum } from '@output.ai/llm';
127
-
128
- // Text generation
129
- const text = await generateText({
130
- prompt: 'prompts/my_prompt@v1',
131
- variables: { topic: 'AI' }
132
- });
133
-
134
- // Structured output
135
- const data = await generateObject({
136
- prompt: 'prompts/extract@v1',
137
- variables: { text },
138
- schema: z.object({ title: z.string(), summary: z.string() })
139
- });
140
- ```
141
-
142
- ### Schema Definitions
143
-
144
- Define input/output schemas with Zod:
145
- ```typescript
146
- import { step, z } from '@output.ai/core';
147
-
148
- export const processData = step({
149
- name: 'processData',
150
- inputSchema: z.object({
151
- id: z.string(),
152
- count: z.number().optional()
153
- }),
154
- outputSchema: z.object({
155
- result: z.string(),
156
- processed: z.boolean()
157
- }),
158
- fn: async (input) => {
159
- // input is typed as { id: string, count?: number }
160
- return { result: input.id, processed: true };
161
- }
162
- });
163
- ```
164
-
165
- ### Retry Policies
166
-
167
- Configure retry policies in step options:
168
- ```typescript
169
- export const riskyStep = step({
170
- name: 'riskyStep',
171
- fn: async (input) => { /* ... */ },
172
- options: {
173
- retry: {
174
- maximumAttempts: 3,
175
- initialInterval: '1s',
176
- maximumInterval: '10s',
177
- backoffCoefficient: 2
178
- },
179
- startToCloseTimeout: '30s'
180
- }
181
- });
182
- ```
183
-
184
- ### Error Types
185
-
186
- Use appropriate error types:
187
- ```typescript
188
- import { FatalError, ValidationError } from '@output.ai/core';
189
-
190
- // Non-retryable error (workflow fails immediately)
191
- throw new FatalError('Critical failure - do not retry');
192
-
193
- // Validation error (schema/input validation)
194
- throw new ValidationError('Invalid input format');
195
- ```
196
-
197
- ## File Structure
198
-
199
- ```
200
- src/workflows/{name}/
201
- workflow.ts # Workflow definition (orchestration only)
202
- steps.ts # Step definitions (all I/O here)
203
- evaluators.ts # Evaluators (optional)
204
- types.ts # Shared types and schemas (optional)
205
- prompts/ # Prompt files directory
206
- name@v1.prompt # Versioned prompt templates
207
- scenarios/ # Test scenarios directory
208
- basic.json # Common run case examples
209
- edge_cases.json # Edge case scenarios
210
- ```
211
-
212
- ### Allowed Imports in Workflows
213
-
214
- Workflows can only import from:
215
- - `steps.ts`, `evaluators.ts`, `shared_steps.ts`
216
- - Whitelisted: `types.ts`, `consts.ts`, `utils.ts`, `variables.ts`, `tools.ts`
217
-
218
- ## Common Pitfalls
219
-
220
- ### 1. Zod Import Source
221
- Always import `z` from `@output.ai/core`, never from `zod` directly. Different `z` instances create incompatible schemas.
222
-
223
- ### 2. Direct API Calls
224
- Never make HTTP/LLM calls directly in workflows. Always wrap in steps.
225
-
226
- ### 3. Non-Deterministic Operations
227
- No `Math.random()`, `Date.now()`, or `crypto` in workflows.
228
-
229
- ### 4. Try-Catch Blocks
230
- Don't wrap step calls in try-catch. Let failures propagate for proper retry handling.
231
-
232
- ### 5. Missing Schemas
233
- Always define inputSchema and outputSchema for type safety and validation.
234
-
235
- ## Example Interaction
236
-
237
- **User**: "My workflow is failing with a type error on the schema"
238
- **Agent**: Check that you're importing `z` from `@output.ai/core`, not `zod`. Different `z` instances create incompatible schemas.
239
-
240
- **User**: "How do I make an HTTP request in my workflow?"
241
- **Agent**: Create a step that uses `@output.ai/http`. Never make HTTP calls directly in the workflow function.
242
-
243
- ---
244
- *This agent specializes in Output SDK implementation best practices and code quality.*
@@ -1,290 +0,0 @@
1
- ---
2
- argument-hint: [workflow-plan-file-path] [workflow-name] [workflow-directory]
3
- description: Workflow Implementation Command for Output SDK
4
- version: 0.0.1
5
- model: claude-opus-4-1
6
- ---
7
-
8
- Your task is to implement an Output.ai workflow based on a provided plan document.
9
-
10
- The workflow skeleton has already been created at: `$3` (if not it should be)
11
-
12
- Please read the plan file and implement the workflow according to its specifications.
13
-
14
- Use the todo tool to track your progress through the implementation process.
15
-
16
- # Implementation Rules
17
-
18
- ## Overview
19
-
20
- Implement the workflow described in the plan document, following Output SDK patterns and best practices.
21
-
22
- <pre_flight_check>
23
- EXECUTE: @.outputai/instructions/meta/pre_flight.md
24
- </pre_flight_check>
25
-
26
- <process_flow>
27
-
28
- <step number="1" name="plan_analysis" subagent="workflow-context-fetcher">
29
-
30
- ### Step 1: Plan Analysis
31
-
32
- Read and understand the plan document.
33
-
34
- 1. Read the plan file from: `$1`
35
- 2. Identify the workflow name, description, and purpose
36
- 3. Extract input and output schema definitions
37
- 4. List all required steps and their relationships
38
- 5. Note any LLM-based steps that require prompt templates
39
- 6. Understand error handling and retry requirements
40
-
41
- </step>
42
-
43
- <step number="2" name="workflow_implementation" subagent="workflow-quality">
44
-
45
- ### Step 2: Workflow Implementation
46
-
47
- Update `$3/workflow.ts` with the workflow definition.
48
-
49
- <implementation_checklist>
50
- - Import required dependencies (workflow, z from '@output.ai/core')
51
- - Define inputSchema based on plan specifications
52
- - Define outputSchema based on plan specifications
53
- - Import step functions from steps.ts
54
- - Implement workflow function with proper orchestration
55
- - Handle conditional logic if specified in plan
56
- - Add proper error handling
57
- </implementation_checklist>
58
-
59
- <workflow_template>
60
- ```typescript
61
- import { workflow, z } from '@output.ai/core';
62
- import { stepName } from './steps.js';
63
-
64
- const inputSchema = z.object( {
65
- // Define based on plan
66
- } );
67
-
68
- const outputSchema = z.object( {
69
- // Define based on plan
70
- } );
71
-
72
- export default workflow( {
73
- name: '$2',
74
- description: 'Description from plan',
75
- inputSchema,
76
- outputSchema,
77
- fn: async input => {
78
- // Implement orchestration logic from plan
79
- const result = await stepName( input );
80
- return { result };
81
- }
82
- } );
83
- ```
84
- </workflow_template>
85
-
86
- </step>
87
-
88
- <step number="3" name="steps_implementation" subagent="workflow-quality">
89
-
90
- ### Step 3: Steps Implementation
91
-
92
- Update `$3/steps.ts` with all step definitions from the plan.
93
-
94
- <implementation_checklist>
95
- - Import required dependencies (step, z from '@output.ai/core')
96
- - Implement each step with proper schema validation
97
- - Add error handling and retry logic as specified
98
- - Ensure step names match plan specifications
99
- - Add descriptive comments for complex logic
100
- </implementation_checklist>
101
-
102
- <step_template>
103
- ```typescript
104
- import { step, z } from '@output.ai/core';
105
-
106
- export const stepName = step( {
107
- name: 'stepName',
108
- description: 'Description from plan',
109
- inputSchema: z.object( {
110
- // Define based on plan
111
- } ),
112
- outputSchema: z.object( {
113
- // Define based on plan
114
- } ),
115
- fn: async input => {
116
- // Implement step logic from plan
117
- return output;
118
- }
119
- } );
120
- ```
121
- </step_template>
122
-
123
- </step>
124
-
125
- <step number="4" name="prompt_templates" subagent="workflow-prompt-writer">
126
-
127
- ### Step 4: Prompt Templates (if needed)
128
-
129
- If the plan includes LLM-based steps, create prompt templates in `$3/prompts/`.
130
-
131
- <decision_tree>
132
- IF plan_includes_llm_steps:
133
- CREATE prompt_templates
134
- UPDATE steps.ts to use loadPrompt and generateText
135
- ELSE:
136
- SKIP to step 6
137
- </decision_tree>
138
-
139
- <llm_step_template>
140
- ```typescript
141
- import { step, z } from '@output.ai/core';
142
- import { generateText } from '@output.ai/llm';
143
-
144
- export const llmStep = step( {
145
- name: 'llmStep',
146
- description: 'LLM-based step',
147
- inputSchema: z.object( {
148
- param: z.string()
149
- } ),
150
- outputSchema: z.string(),
151
- fn: async ( { param } ) => {
152
- const response = await generateText( {
153
- prompt: 'prompt_name@v1',
154
- variables: { param }
155
- } );
156
- return response;
157
- }
158
- } );
159
- ```
160
- </llm_step_template>
161
-
162
- <prompt_file_template>
163
- ```
164
- ---
165
- provider: anthropic
166
- model: claude-sonnet-4-20250514
167
- temperature: 0.7
168
- ---
169
-
170
- <assistant>
171
- You are a helpful assistant.
172
- </assistant>
173
-
174
- <user>
175
- {{ instructions }}
176
- </user>
177
- ```
178
- </prompt_file_template>
179
-
180
- </step>
181
-
182
- <step number="5" name="readme_update">
183
-
184
- ### Step 5: README Update
185
-
186
- Update `$3/README.md` with workflow-specific documentation.
187
-
188
- <documentation_requirements>
189
- - Update workflow name and description
190
- - Document input schema with examples
191
- - Document output schema with examples
192
- - Explain each step's purpose
193
- - Provide usage examples
194
- - Document any prerequisites or setup requirements
195
- - Include testing instructions
196
- </documentation_requirements>
197
-
198
- </step>
199
-
200
- <step number="6" name="scenario_creation">
201
-
202
- ### Step 6: Scenario File Creation
203
-
204
- Create at least one scenario file in `$3/scenarios/` for testing the workflow.
205
-
206
- <scenario_requirements>
207
- - Create `scenarios/` directory if it doesn't exist
208
- - Create `test_input.json` with valid example input matching the inputSchema
209
- - Input values should be realistic and demonstrate the workflow's purpose
210
- - JSON must be valid and parseable
211
- </scenario_requirements>
212
-
213
- <scenario_template>
214
- ```json
215
- {
216
- // Populate with example values matching inputSchema
217
- // Use realistic test data that demonstrates the workflow
218
- }
219
- ```
220
- </scenario_template>
221
-
222
- <example>
223
- For a workflow with inputSchema:
224
- ```typescript
225
- z.object({
226
- topic: z.string(),
227
- maxLength: z.number().optional()
228
- })
229
- ```
230
-
231
- Create `scenarios/test_input.json`:
232
- ```json
233
- {
234
- "topic": "The history of artificial intelligence",
235
- "maxLength": 500
236
- }
237
- ```
238
- </example>
239
-
240
- </step>
241
-
242
- <step number="7" name="validation" subagent="workflow-quality">
243
-
244
- ### Step 7: Implementation Validation
245
-
246
- Verify the implementation is complete and correct.
247
-
248
- <validation_checklist>
249
- - All steps from plan are implemented
250
- - Input/output schemas match plan specifications
251
- - Workflow orchestration logic is correct
252
- - Error handling is in place
253
- - LLM prompts are created (if needed)
254
- - README is updated with accurate information
255
- - Code follows Output SDK patterns
256
- - TypeScript types are properly defined
257
- - Scenario file exists with valid example input
258
- </validation_checklist>
259
-
260
- </step>
261
-
262
- <step number="8" name="post_flight_check">
263
-
264
- ### Step 8: Post-Flight Check
265
-
266
- Verify the implementation is ready for use.
267
-
268
- <post_flight_check>
269
- EXECUTE: @.outputai/instructions/meta/post_flight.md
270
- </post_flight_check>
271
-
272
- </step>
273
-
274
- </process_flow>
275
-
276
- <post_flight_check>
277
- EXECUTE: @.outputai/instructions/meta/post_flight.md
278
- </post_flight_check>
279
-
280
- ---- START ----
281
-
282
- Workflow Name: $2
283
-
284
- Workflow Directory: $3
285
-
286
- Plan File Path: $1
287
-
288
- Additional Instructions:
289
-
290
- $ARGUMENTS