@output.ai/cli 0.0.1 → 0.0.3
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.
- package/README.md +44 -12
- package/dist/api/generated/api.d.ts +13 -13
- package/dist/api/generated/api.js +1 -1
- package/dist/commands/agents/init.d.ts +18 -0
- package/dist/commands/agents/init.js +175 -0
- package/dist/commands/agents/init.spec.d.ts +1 -0
- package/dist/commands/agents/init.spec.js +227 -0
- package/dist/commands/workflow/generate.js +1 -2
- package/dist/commands/workflow/generate.spec.js +0 -6
- package/dist/commands/workflow/list.d.ts +1 -1
- package/dist/commands/workflow/list.js +26 -42
- package/dist/commands/workflow/output.d.ts +13 -0
- package/dist/commands/workflow/output.js +49 -0
- package/dist/commands/workflow/output.test.d.ts +1 -0
- package/dist/commands/workflow/output.test.js +23 -0
- package/dist/commands/workflow/run.d.ts +15 -0
- package/dist/commands/workflow/run.js +66 -0
- package/dist/commands/workflow/run.test.d.ts +1 -0
- package/dist/commands/workflow/run.test.js +26 -0
- package/dist/commands/workflow/start.d.ts +14 -0
- package/dist/commands/workflow/start.js +57 -0
- package/dist/commands/workflow/start.test.d.ts +1 -0
- package/dist/commands/workflow/start.test.js +23 -0
- package/dist/commands/workflow/status.d.ts +13 -0
- package/dist/commands/workflow/status.js +56 -0
- package/dist/commands/workflow/status.test.d.ts +1 -0
- package/dist/commands/workflow/status.test.js +33 -0
- package/dist/commands/workflow/stop.d.ts +10 -0
- package/dist/commands/workflow/stop.js +31 -0
- package/dist/commands/workflow/stop.test.d.ts +1 -0
- package/dist/commands/workflow/stop.test.js +17 -0
- package/dist/templates/agent_instructions/AGENTS.md.template +30 -0
- package/dist/templates/agent_instructions/agents/workflow_planner.md.template +104 -0
- package/dist/templates/agent_instructions/commands/plan_workflow.md.template +466 -0
- package/dist/templates/agent_instructions/meta/post_flight.md.template +94 -0
- package/dist/templates/agent_instructions/meta/pre_flight.md.template +60 -0
- package/dist/templates/workflow/README.md.template +5 -5
- package/dist/utils/constants.d.ts +5 -0
- package/dist/utils/constants.js +4 -0
- package/dist/utils/error_handler.d.ts +8 -0
- package/dist/utils/error_handler.js +25 -0
- package/dist/utils/input_parser.d.ts +1 -0
- package/dist/utils/input_parser.js +19 -0
- package/dist/utils/output_formatter.d.ts +2 -0
- package/dist/utils/output_formatter.js +11 -0
- package/dist/utils/paths.d.ts +5 -0
- package/dist/utils/paths.js +8 -1
- package/package.json +28 -30
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Pre-Flight Checks for Output SDK Workflow Operations
|
|
3
|
+
version: 1.0
|
|
4
|
+
encoding: UTF-8
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Pre-Flight Rules for Output SDK Workflows
|
|
8
|
+
|
|
9
|
+
## Execution Requirements
|
|
10
|
+
|
|
11
|
+
- **CRITICAL**: For any step that specifies a subagent in the `subagent=""` XML attribute, you MUST use the specified subagent to perform the instructions for that step
|
|
12
|
+
- Process all XML blocks sequentially and completely
|
|
13
|
+
- Execute every numbered step in the process_flow EXACTLY as specified
|
|
14
|
+
|
|
15
|
+
## Output SDK Conventions Check
|
|
16
|
+
|
|
17
|
+
Before proceeding with any workflow operation, verify:
|
|
18
|
+
|
|
19
|
+
- **ES Modules**: All imports MUST use `.js` extension for ESM modules
|
|
20
|
+
- **HTTP Client**: NEVER use axios directly - always use @output.ai/http wrapper
|
|
21
|
+
- **LLM Client**: NEVER use a direct llm call - always use @output.ai/llm wrapper
|
|
22
|
+
- **Worker Restarts**: Remember to restart worker after creating workflows: `overmind restart worker`
|
|
23
|
+
- **Documentation**: Run `yarn g:workflow-doc` after modifications
|
|
24
|
+
|
|
25
|
+
## Requirements Gathering Strategy
|
|
26
|
+
|
|
27
|
+
### Smart Defaults Application
|
|
28
|
+
When information is not explicitly provided, apply these defaults:
|
|
29
|
+
- **Retry Policies**: 3 attempts with exponential backoff (1s initial, 10s max)
|
|
30
|
+
- **OpenAI Models**: Use `gpt-4o` unless specified otherwise
|
|
31
|
+
- **Error Handling**: ApplicationFailure patterns with appropriate error types
|
|
32
|
+
- **Performance**: Optimize for clarity and maintainability over raw speed
|
|
33
|
+
- **Timeouts**: 30 seconds for activities, 5 minutes for workflows
|
|
34
|
+
|
|
35
|
+
### Critical Information Requirements
|
|
36
|
+
Only stop to ask for clarification on:
|
|
37
|
+
- Ambiguous input/output structures that cannot be inferred from context
|
|
38
|
+
- Specific API keys or services not commonly used in the project
|
|
39
|
+
- Non-standard error handling or recovery requirements
|
|
40
|
+
- Complex orchestration patterns requiring specific sequencing
|
|
41
|
+
- External dependencies not already in the project
|
|
42
|
+
|
|
43
|
+
## Template Processing Rules
|
|
44
|
+
|
|
45
|
+
- Use exact templates as provided in each step
|
|
46
|
+
- Replace all template variables with actual values:
|
|
47
|
+
- `{{workflowName}}` - The workflow being planned
|
|
48
|
+
- `{{projectPath}}` - Root project directory path
|
|
49
|
+
- `{{requirements}}` - User-provided requirements
|
|
50
|
+
- `{{currentDate}}` - Current date in YYYY-MM-DD format
|
|
51
|
+
- `{{sdkVersion}}` - Current Output SDK version
|
|
52
|
+
|
|
53
|
+
## Quality Gates
|
|
54
|
+
|
|
55
|
+
Before proceeding past pre-flight:
|
|
56
|
+
1. Confirm all required context is available
|
|
57
|
+
2. Verify understanding of the workflow's purpose
|
|
58
|
+
3. Check for existing similar workflows to use as patterns
|
|
59
|
+
4. Ensure Output SDK conventions are understood
|
|
60
|
+
5. Validate that necessary subagents are available
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
This workflow was generated using the
|
|
7
|
+
This workflow was generated using the Output SDK CLI. It provides a starting point for building Temporal-based workflows with LLM integration.
|
|
8
8
|
|
|
9
9
|
## Files
|
|
10
10
|
|
|
@@ -63,7 +63,7 @@ Example:
|
|
|
63
63
|
|
|
64
64
|
### Workflow Structure
|
|
65
65
|
|
|
66
|
-
The workflow follows the new
|
|
66
|
+
The workflow follows the new Output SDK conventions:
|
|
67
67
|
|
|
68
68
|
```typescript
|
|
69
69
|
import { workflow } from '@output.ai/core';
|
|
@@ -192,8 +192,8 @@ Please provide a helpful response.
|
|
|
192
192
|
To test your workflow:
|
|
193
193
|
|
|
194
194
|
1. Build the parent project containing this workflow
|
|
195
|
-
2. Start the
|
|
196
|
-
3. Execute the workflow using the
|
|
195
|
+
2. Start the Output worker
|
|
196
|
+
3. Execute the workflow using the Output SDK API
|
|
197
197
|
|
|
198
198
|
Example execution:
|
|
199
199
|
```bash
|
|
@@ -210,6 +210,6 @@ curl -X POST http://localhost:3001/workflow \
|
|
|
210
210
|
|
|
211
211
|
## Resources
|
|
212
212
|
|
|
213
|
-
- [
|
|
213
|
+
- [Output SDK Documentation](https://github.com/growthxai/output-sdk)
|
|
214
214
|
- [Temporal Documentation](https://docs.temporal.io)
|
|
215
215
|
- [AI SDK Documentation](https://sdk.vercel.ai/docs)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type ErrorOverrides = {
|
|
2
|
+
[statusCode: number]: string;
|
|
3
|
+
ECONNREFUSED?: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function handleApiError(error: unknown, errorFn: (...args: [message: string, options: {
|
|
6
|
+
exit: number;
|
|
7
|
+
}]) => never, overrides?: ErrorOverrides): never;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { config } from '../config.js';
|
|
2
|
+
const DEFAULT_MESSAGES = {
|
|
3
|
+
ECONNREFUSED: `Connection refused to ${config.apiUrl}. Is the API server running?`,
|
|
4
|
+
401: 'Authentication failed. Check your API_AUTH_TOKEN.',
|
|
5
|
+
404: 'Resource not found.',
|
|
6
|
+
UNKNOWN: 'An unknown error occurred.'
|
|
7
|
+
};
|
|
8
|
+
export function handleApiError(error, errorFn, overrides = {}) {
|
|
9
|
+
const apiError = error;
|
|
10
|
+
const errorMessages = { ...DEFAULT_MESSAGES, ...overrides };
|
|
11
|
+
if (apiError.code === 'ECONNREFUSED') {
|
|
12
|
+
return errorFn(errorMessages.ECONNREFUSED, { exit: 1 });
|
|
13
|
+
}
|
|
14
|
+
if (apiError.response?.status) {
|
|
15
|
+
const status = apiError.response.status;
|
|
16
|
+
const message = errorMessages[status];
|
|
17
|
+
if (message) {
|
|
18
|
+
return errorFn(message, { exit: 1 });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (apiError.message) {
|
|
22
|
+
return errorFn(apiError.message, { exit: 1 });
|
|
23
|
+
}
|
|
24
|
+
return errorFn(errorMessages.UNKNOWN, { exit: 1 });
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function parseInputFlag(input: string): unknown;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
export function parseInputFlag(input) {
|
|
3
|
+
try {
|
|
4
|
+
return JSON.parse(input);
|
|
5
|
+
}
|
|
6
|
+
catch {
|
|
7
|
+
try {
|
|
8
|
+
const fileContent = readFileSync(input, 'utf-8');
|
|
9
|
+
return JSON.parse(fileContent);
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
const err = error;
|
|
13
|
+
if (err.code === 'ENOENT') {
|
|
14
|
+
throw new Error(`Input file not found: ${input}`);
|
|
15
|
+
}
|
|
16
|
+
throw new Error(`Invalid JSON input: ${err.message}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OUTPUT_FORMAT } from './constants.js';
|
|
2
|
+
export function formatOutput(result, format, textFormatter = result => JSON.stringify(result, null, 2)) {
|
|
3
|
+
switch (format) {
|
|
4
|
+
case OUTPUT_FORMAT.JSON:
|
|
5
|
+
return JSON.stringify(result, null, 2);
|
|
6
|
+
case OUTPUT_FORMAT.TEXT:
|
|
7
|
+
return textFormatter(result);
|
|
8
|
+
default:
|
|
9
|
+
return textFormatter(result);
|
|
10
|
+
}
|
|
11
|
+
}
|
package/dist/utils/paths.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare const TEMPLATE_DIRS: {
|
|
5
5
|
readonly workflow: string;
|
|
6
|
+
readonly agent_instructions: string;
|
|
6
7
|
};
|
|
7
8
|
/**
|
|
8
9
|
* Default output directories
|
|
@@ -22,3 +23,7 @@ export declare function createTargetDir(outputDir: string, workflowName: string)
|
|
|
22
23
|
* Get the template directory for a specific template type
|
|
23
24
|
*/
|
|
24
25
|
export declare function getTemplateDir(templateType: keyof typeof TEMPLATE_DIRS): string;
|
|
26
|
+
/**
|
|
27
|
+
* Get the agent instruction directory for a specific category
|
|
28
|
+
*/
|
|
29
|
+
export declare function getAgentInstructionDir(category: 'agents' | 'commands'): string;
|
package/dist/utils/paths.js
CHANGED
|
@@ -6,7 +6,8 @@ const __dirname = path.dirname(__filename);
|
|
|
6
6
|
* Template directory paths
|
|
7
7
|
*/
|
|
8
8
|
export const TEMPLATE_DIRS = {
|
|
9
|
-
workflow: path.join(__dirname, '..', 'templates', 'workflow')
|
|
9
|
+
workflow: path.join(__dirname, '..', 'templates', 'workflow'),
|
|
10
|
+
agent_instructions: path.join(__dirname, '..', 'templates', 'agent_instructions')
|
|
10
11
|
};
|
|
11
12
|
/**
|
|
12
13
|
* Default output directories
|
|
@@ -33,3 +34,9 @@ export function createTargetDir(outputDir, workflowName) {
|
|
|
33
34
|
export function getTemplateDir(templateType) {
|
|
34
35
|
return TEMPLATE_DIRS[templateType];
|
|
35
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Get the agent instruction directory for a specific category
|
|
39
|
+
*/
|
|
40
|
+
export function getAgentInstructionDir(category) {
|
|
41
|
+
return path.join(TEMPLATE_DIRS.agent_instructions, category);
|
|
42
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@output.ai/cli",
|
|
3
|
+
"version": "0.0.3",
|
|
3
4
|
"description": "CLI for Output.ai workflow generation",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"./bin",
|
|
10
|
+
"./dist",
|
|
11
|
+
"./oclif.manifest.json"
|
|
12
|
+
],
|
|
6
13
|
"bin": {
|
|
7
|
-
"output
|
|
14
|
+
"output": "./bin/run.js"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "rm -rf ./dist && tsc && copyfiles -u 1 './src/templates/**/*.template' './src/templates/**/.env.template' './src/templates/**/*.prompt.template' dist",
|
|
18
|
+
"test": "vitest run",
|
|
19
|
+
"generate:api": "orval --config ./orval.config.ts",
|
|
20
|
+
"prebuild": "npm run generate:api"
|
|
8
21
|
},
|
|
9
|
-
"bugs": "https://github.com/growthxai/flow-sdk/issues",
|
|
10
22
|
"dependencies": {
|
|
11
23
|
"@oclif/core": "^4",
|
|
12
24
|
"@oclif/plugin-help": "^6",
|
|
@@ -26,24 +38,10 @@
|
|
|
26
38
|
"orval": "^7.13.0",
|
|
27
39
|
"slash": "^5.1.0"
|
|
28
40
|
},
|
|
29
|
-
"
|
|
30
|
-
"node": ">=18.0.0"
|
|
31
|
-
},
|
|
32
|
-
"files": [
|
|
33
|
-
"./bin",
|
|
34
|
-
"./dist",
|
|
35
|
-
"./oclif.manifest.json"
|
|
36
|
-
],
|
|
37
|
-
"homepage": "https://github.com/growthxai/flow-sdk",
|
|
38
|
-
"keywords": [
|
|
39
|
-
"oclif"
|
|
40
|
-
],
|
|
41
|
-
"license": "MIT",
|
|
42
|
-
"main": "dist/index.js",
|
|
43
|
-
"type": "module",
|
|
41
|
+
"license": "UNLICENSED",
|
|
44
42
|
"oclif": {
|
|
45
|
-
"bin": "output
|
|
46
|
-
"dirname": "output
|
|
43
|
+
"bin": "output",
|
|
44
|
+
"dirname": "output",
|
|
47
45
|
"commands": "./dist/commands",
|
|
48
46
|
"plugins": [
|
|
49
47
|
"@oclif/plugin-help",
|
|
@@ -53,15 +51,15 @@
|
|
|
53
51
|
"topics": {
|
|
54
52
|
"workflow": {
|
|
55
53
|
"description": "Manage Output.ai workflows"
|
|
54
|
+
},
|
|
55
|
+
"config": {
|
|
56
|
+
"description": "Configure Output.ai CLI",
|
|
57
|
+
"subtopics": {
|
|
58
|
+
"agents": {
|
|
59
|
+
"description": "Manage AI agent configurations"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
56
62
|
}
|
|
57
63
|
}
|
|
58
|
-
}
|
|
59
|
-
"repository": "sdk/cli",
|
|
60
|
-
"scripts": {
|
|
61
|
-
"build": "rm -rf ./dist && tsc && copyfiles -u 1 './src/templates/**/*.template' './src/templates/**/.env.template' './src/templates/**/*.prompt.template' dist",
|
|
62
|
-
"test": "vitest run",
|
|
63
|
-
"generate:api": "orval --config ./orval.config.ts",
|
|
64
|
-
"prebuild": "npm run generate:api"
|
|
65
|
-
},
|
|
66
|
-
"types": "dist/index.d.ts"
|
|
64
|
+
}
|
|
67
65
|
}
|