@output.ai/cli 0.3.0-dev.pr156.696d4dd → 0.3.0-dev.pr156.a0c12ed
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 +2 -28
- package/dist/api/generated/api.d.ts +15 -39
- package/dist/commands/workflow/debug.d.ts +1 -1
- package/dist/commands/workflow/debug.js +11 -9
- package/dist/commands/workflow/debug.spec.js +36 -0
- package/dist/commands/workflow/generate.js +3 -10
- package/dist/commands/workflow/generate.spec.js +6 -4
- package/dist/services/coding_agents.js +30 -0
- package/dist/services/coding_agents.spec.js +36 -61
- package/dist/services/messages.d.ts +1 -0
- package/dist/services/messages.js +65 -1
- package/dist/services/trace_reader.d.ts +7 -1
- package/dist/services/trace_reader.js +24 -8
- package/dist/services/{trace_reader.test.js → trace_reader.spec.js} +2 -1
- package/dist/services/workflow_generator.spec.d.ts +1 -0
- package/dist/services/workflow_generator.spec.js +77 -0
- package/dist/templates/agent_instructions/AGENTS.md.template +209 -19
- package/dist/templates/agent_instructions/agents/context_fetcher.md.template +82 -0
- package/dist/templates/agent_instructions/agents/prompt_writer.md.template +595 -0
- package/dist/templates/agent_instructions/agents/workflow_planner.md.template +13 -4
- package/dist/templates/agent_instructions/agents/workflow_quality.md.template +244 -0
- package/dist/templates/agent_instructions/commands/build_workflow.md.template +52 -9
- package/dist/templates/agent_instructions/commands/plan_workflow.md.template +4 -4
- package/dist/templates/project/package.json.template +2 -2
- package/dist/templates/project/src/simple/scenarios/question_ada_lovelace.json.template +3 -0
- package/dist/templates/workflow/scenarios/test_input.json.template +7 -0
- package/dist/types/trace.d.ts +161 -0
- package/dist/types/trace.js +18 -0
- package/dist/utils/date_formatter.d.ts +8 -0
- package/dist/utils/date_formatter.js +19 -0
- package/dist/utils/template.spec.js +6 -0
- package/dist/utils/trace_formatter.d.ts +3 -19
- package/dist/utils/trace_formatter.js +308 -371
- package/package.json +2 -2
- package/dist/commands/workflow/debug.test.js +0 -75
- /package/dist/commands/workflow/{debug.test.d.ts → debug.spec.d.ts} +0 -0
- /package/dist/services/{trace_reader.test.d.ts → trace_reader.spec.d.ts} +0 -0
- /package/dist/templates/workflow/{prompt@v1.prompt.template → prompts/prompt@v1.prompt.template} +0 -0
package/README.md
CHANGED
|
@@ -103,15 +103,6 @@ output workflow debug <workflowId>
|
|
|
103
103
|
|
|
104
104
|
# Display trace in JSON format
|
|
105
105
|
output workflow debug <workflowId> --format json
|
|
106
|
-
|
|
107
|
-
# Prefer remote (S3) trace over local
|
|
108
|
-
output workflow debug <workflowId> --remote
|
|
109
|
-
|
|
110
|
-
# Save trace to a custom directory
|
|
111
|
-
output workflow debug <workflowId> --download-dir ./my-traces
|
|
112
|
-
|
|
113
|
-
# Force re-download of remote traces (bypass cache)
|
|
114
|
-
output workflow debug <workflowId> --remote --force-download
|
|
115
106
|
```
|
|
116
107
|
|
|
117
108
|
#### What It Does
|
|
@@ -123,30 +114,13 @@ The `debug` command retrieves and displays detailed execution traces for debuggi
|
|
|
123
114
|
- Error details and stack traces
|
|
124
115
|
- Performance metrics and durations
|
|
125
116
|
|
|
126
|
-
#### Trace Sources
|
|
127
|
-
|
|
128
|
-
The command automatically handles both local and remote traces:
|
|
129
|
-
- **Local traces**: Stored on your machine when `TRACE_LOCAL_ON=true`
|
|
130
|
-
- **Remote traces**: Stored in S3 when `TRACE_REMOTE_ON=true` (requires AWS credentials)
|
|
131
|
-
|
|
132
|
-
By default, it tries local traces first for faster access, then falls back to remote if needed.
|
|
133
|
-
|
|
134
117
|
#### Command Options
|
|
135
118
|
|
|
136
119
|
- `--format, -f` - Output format: `text` (default, human-readable) or `json` (raw trace data)
|
|
137
|
-
- `--remote, -r` - Prefer remote S3 trace even if local exists
|
|
138
|
-
- `--download-dir, -d` - Directory for saving downloaded traces (default: `.output/traces`)
|
|
139
|
-
- `--open, -o` - Save trace to file for viewing in external JSON viewer
|
|
140
|
-
- `--force-download` - Force re-download from S3, bypassing local cache
|
|
141
120
|
|
|
142
|
-
####
|
|
121
|
+
#### Environment Variables
|
|
143
122
|
|
|
144
|
-
|
|
145
|
-
```bash
|
|
146
|
-
export AWS_ACCESS_KEY_ID=your-access-key
|
|
147
|
-
export AWS_SECRET_ACCESS_KEY=your-secret-key
|
|
148
|
-
export AWS_REGION=us-east-1 # or your region
|
|
149
|
-
```
|
|
123
|
+
- `HOST_TRACE_PATH` - When running in Docker, this maps the container's trace log path to the host filesystem path. Set this to your project's `logs` directory (e.g., `${PWD}/logs`). Required for trace files to be accessible from the CLI when workflows run in containers.
|
|
150
124
|
|
|
151
125
|
### Generate a Workflow
|
|
152
126
|
|
|
@@ -32,20 +32,10 @@ export interface Workflow {
|
|
|
32
32
|
inputSchema?: JSONSchema;
|
|
33
33
|
outputSchema?: JSONSchema;
|
|
34
34
|
}
|
|
35
|
-
export type PostWorkflowRunBody = {
|
|
36
|
-
/** The name of the workflow to execute */
|
|
37
|
-
workflowName: string;
|
|
38
|
-
/** The payload to send to the workflow */
|
|
39
|
-
input: unknown;
|
|
40
|
-
/** (Optional) The workflowId to use. Must be unique */
|
|
41
|
-
workflowId?: string;
|
|
42
|
-
/** The name of the task queue to send the workflow to */
|
|
43
|
-
taskQueue?: string;
|
|
44
|
-
};
|
|
45
35
|
/**
|
|
46
36
|
* File destinations for trace data
|
|
47
37
|
*/
|
|
48
|
-
export type
|
|
38
|
+
export type TraceInfoDestinations = {
|
|
49
39
|
/**
|
|
50
40
|
* Absolute path to local trace file, or null if not saved locally
|
|
51
41
|
* @nullable
|
|
@@ -60,17 +50,26 @@ export type PostWorkflowRun200TraceDestinations = {
|
|
|
60
50
|
/**
|
|
61
51
|
* An object with information about the trace generated by the execution
|
|
62
52
|
*/
|
|
63
|
-
export
|
|
53
|
+
export interface TraceInfo {
|
|
64
54
|
/** File destinations for trace data */
|
|
65
|
-
destinations?:
|
|
55
|
+
destinations?: TraceInfoDestinations;
|
|
56
|
+
}
|
|
57
|
+
export type PostWorkflowRunBody = {
|
|
58
|
+
/** The name of the workflow to execute */
|
|
59
|
+
workflowName: string;
|
|
60
|
+
/** The payload to send to the workflow */
|
|
61
|
+
input: unknown;
|
|
62
|
+
/** (Optional) The workflowId to use. Must be unique */
|
|
63
|
+
workflowId?: string;
|
|
64
|
+
/** The name of the task queue to send the workflow to */
|
|
65
|
+
taskQueue?: string;
|
|
66
66
|
};
|
|
67
67
|
export type PostWorkflowRun200 = {
|
|
68
68
|
/** The workflow execution id */
|
|
69
69
|
workflowId?: string;
|
|
70
70
|
/** The output of the workflow */
|
|
71
71
|
output?: unknown;
|
|
72
|
-
|
|
73
|
-
trace?: PostWorkflowRun200Trace;
|
|
72
|
+
trace?: TraceInfo;
|
|
74
73
|
};
|
|
75
74
|
export type PostWorkflowStartBody = {
|
|
76
75
|
/** The name of the workflow to execute */
|
|
@@ -110,35 +109,12 @@ export type GetWorkflowIdStatus200 = {
|
|
|
110
109
|
/** An epoch timestamp representing when the workflow ended */
|
|
111
110
|
completedAt?: number;
|
|
112
111
|
};
|
|
113
|
-
/**
|
|
114
|
-
* File destinations for trace data
|
|
115
|
-
*/
|
|
116
|
-
export type GetWorkflowIdOutput200TraceDestinations = {
|
|
117
|
-
/**
|
|
118
|
-
* Absolute path to local trace file, or null if not saved locally
|
|
119
|
-
* @nullable
|
|
120
|
-
*/
|
|
121
|
-
local: string | null;
|
|
122
|
-
/**
|
|
123
|
-
* Remote trace location (e.g., S3 URI), or null if not saved remotely
|
|
124
|
-
* @nullable
|
|
125
|
-
*/
|
|
126
|
-
remote: string | null;
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* An object with information about the trace generated by the execution
|
|
130
|
-
*/
|
|
131
|
-
export type GetWorkflowIdOutput200Trace = {
|
|
132
|
-
/** File destinations for trace data */
|
|
133
|
-
destinations?: GetWorkflowIdOutput200TraceDestinations;
|
|
134
|
-
};
|
|
135
112
|
export type GetWorkflowIdOutput200 = {
|
|
136
113
|
/** The workflow execution id */
|
|
137
114
|
workflowId?: string;
|
|
138
115
|
/** The output of workflow */
|
|
139
116
|
output?: unknown;
|
|
140
|
-
|
|
141
|
-
trace?: GetWorkflowIdOutput200Trace;
|
|
117
|
+
trace?: TraceInfo;
|
|
142
118
|
};
|
|
143
119
|
export type GetWorkflowCatalogId200 = {
|
|
144
120
|
/** Each workflow available in this catalog */
|
|
@@ -9,7 +9,7 @@ export default class WorkflowDebug extends Command {
|
|
|
9
9
|
format: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
10
|
};
|
|
11
11
|
run(): Promise<void>;
|
|
12
|
-
private getTrace;
|
|
13
12
|
private outputJson;
|
|
14
13
|
private displayTextTrace;
|
|
14
|
+
catch(error: Error): Promise<void>;
|
|
15
15
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Args, Command, Flags } from '@oclif/core';
|
|
2
2
|
import { OUTPUT_FORMAT } from '#utils/constants.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { displayDebugTree } from '#utils/trace_formatter.js';
|
|
4
|
+
import { getTrace } from '#services/trace_reader.js';
|
|
5
|
+
import { handleApiError } from '#utils/error_handler.js';
|
|
5
6
|
export default class WorkflowDebug extends Command {
|
|
6
7
|
static description = 'Get and display workflow execution trace for debugging';
|
|
7
8
|
static examples = [
|
|
@@ -29,7 +30,7 @@ export default class WorkflowDebug extends Command {
|
|
|
29
30
|
if (!isJsonFormat) {
|
|
30
31
|
this.log(`Fetching debug information for workflow: ${args.workflowId}...`);
|
|
31
32
|
}
|
|
32
|
-
const traceData = await
|
|
33
|
+
const traceData = await getTrace(args.workflowId);
|
|
33
34
|
// Output based on format
|
|
34
35
|
if (isJsonFormat) {
|
|
35
36
|
this.outputJson(traceData);
|
|
@@ -38,18 +39,19 @@ export default class WorkflowDebug extends Command {
|
|
|
38
39
|
// Display text format
|
|
39
40
|
this.displayTextTrace(traceData);
|
|
40
41
|
}
|
|
41
|
-
async getTrace(workflowId) {
|
|
42
|
-
const tracePath = await findTraceFile(workflowId);
|
|
43
|
-
return readTraceFile(tracePath);
|
|
44
|
-
}
|
|
45
42
|
outputJson(data) {
|
|
46
43
|
this.log(JSON.stringify(data, null, 2));
|
|
47
44
|
}
|
|
48
45
|
displayTextTrace(traceData) {
|
|
49
46
|
this.log('\nTrace Log:');
|
|
50
47
|
this.log('─'.repeat(80));
|
|
51
|
-
this.log(
|
|
48
|
+
this.log(displayDebugTree(traceData));
|
|
52
49
|
this.log('\n' + '─'.repeat(80));
|
|
53
|
-
this.log('Tip: Use --format json for
|
|
50
|
+
this.log('Tip: Use --format json for the full untruncated trace');
|
|
51
|
+
}
|
|
52
|
+
async catch(error) {
|
|
53
|
+
return handleApiError(error, (...args) => this.error(...args), {
|
|
54
|
+
404: 'Workflow not found or trace not available. Check the workflow ID.'
|
|
55
|
+
});
|
|
54
56
|
}
|
|
55
57
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
// Mock the TraceReader service
|
|
3
|
+
vi.mock('../../services/trace_reader.js', () => ({
|
|
4
|
+
findTraceFile: vi.fn(),
|
|
5
|
+
readTraceFile: vi.fn(),
|
|
6
|
+
getTrace: vi.fn()
|
|
7
|
+
}));
|
|
8
|
+
// Mock the utilities
|
|
9
|
+
vi.mock('../../utils/trace_formatter.js', () => ({
|
|
10
|
+
displayDebugTree: vi.fn()
|
|
11
|
+
}));
|
|
12
|
+
describe('workflow debug command', () => {
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
vi.clearAllMocks();
|
|
15
|
+
});
|
|
16
|
+
describe('command definition', () => {
|
|
17
|
+
it('should export a valid OCLIF command', async () => {
|
|
18
|
+
const WorkflowDebug = (await import('./debug.js')).default;
|
|
19
|
+
expect(WorkflowDebug).toBeDefined();
|
|
20
|
+
expect(WorkflowDebug.description).toContain('Get and display workflow execution trace for debugging');
|
|
21
|
+
expect(WorkflowDebug.args).toHaveProperty('workflowId');
|
|
22
|
+
expect(WorkflowDebug.flags).toHaveProperty('format');
|
|
23
|
+
});
|
|
24
|
+
it('should have correct flag configuration', async () => {
|
|
25
|
+
const WorkflowDebug = (await import('./debug.js')).default;
|
|
26
|
+
// Format flag
|
|
27
|
+
expect(WorkflowDebug.flags.format.options).toEqual(['json', 'text']);
|
|
28
|
+
expect(WorkflowDebug.flags.format.default).toBe('text');
|
|
29
|
+
});
|
|
30
|
+
it('should have correct examples', async () => {
|
|
31
|
+
const WorkflowDebug = (await import('./debug.js')).default;
|
|
32
|
+
expect(WorkflowDebug.examples).toBeDefined();
|
|
33
|
+
expect(WorkflowDebug.examples.length).toBeGreaterThan(0);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -2,6 +2,7 @@ import { Args, Command, Flags, ux } from '@oclif/core';
|
|
|
2
2
|
import { generateWorkflow } from '#services/workflow_generator.js';
|
|
3
3
|
import { buildWorkflow, buildWorkflowInteractiveLoop } from '#services/workflow_builder.js';
|
|
4
4
|
import { ensureOutputAIStructure } from '#services/coding_agents.js';
|
|
5
|
+
import { getWorkflowGenerateSuccessMessage } from '#services/messages.js';
|
|
5
6
|
import { DEFAULT_OUTPUT_DIRS } from '#utils/paths.js';
|
|
6
7
|
import path from 'node:path';
|
|
7
8
|
export default class Generate extends Command {
|
|
@@ -78,15 +79,7 @@ export default class Generate extends Command {
|
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
displaySuccess(result) {
|
|
81
|
-
|
|
82
|
-
this.log(
|
|
83
|
-
this.log('\n-- Next steps --');
|
|
84
|
-
this.log(` 1. cd ${result.targetDir}`);
|
|
85
|
-
this.log(' 2. Edit the workflow files to customize your implementation');
|
|
86
|
-
this.log(' 3. If using @output.ai/llm, configure your .env file with LLM provider credentials:');
|
|
87
|
-
this.log(' - ANTHROPIC_API_KEY for Claude');
|
|
88
|
-
this.log(' - OPENAI_API_KEY for OpenAI');
|
|
89
|
-
this.log(' 4. Build and run with the worker');
|
|
90
|
-
this.log('\nCheck the README.md for workflow-specific documentation.');
|
|
82
|
+
const message = getWorkflowGenerateSuccessMessage(result.workflowName, result.targetDir, result.filesCreated);
|
|
83
|
+
this.log(message);
|
|
91
84
|
}
|
|
92
85
|
}
|
|
@@ -46,7 +46,8 @@ describe('Generate Command', () => {
|
|
|
46
46
|
skeleton: true,
|
|
47
47
|
force: false
|
|
48
48
|
});
|
|
49
|
-
expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('
|
|
49
|
+
expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('SUCCESS!'));
|
|
50
|
+
expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('test-workflow'));
|
|
50
51
|
});
|
|
51
52
|
it('should require skeleton flag and reject without it', async () => {
|
|
52
53
|
const cmd = createCommand();
|
|
@@ -105,9 +106,10 @@ describe('Generate Command', () => {
|
|
|
105
106
|
filesCreated: ['index.ts', 'steps.ts', 'types.ts']
|
|
106
107
|
});
|
|
107
108
|
await cmd.run();
|
|
108
|
-
expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('
|
|
109
|
-
expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('
|
|
110
|
-
expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('
|
|
109
|
+
expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('SUCCESS!'));
|
|
110
|
+
expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('my-workflow'));
|
|
111
|
+
expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('/custom/path/my-workflow'));
|
|
112
|
+
expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('NEXT STEPS'));
|
|
111
113
|
});
|
|
112
114
|
});
|
|
113
115
|
});
|
|
@@ -29,6 +29,21 @@ export const AGENT_CONFIGS = {
|
|
|
29
29
|
from: 'agents/workflow_planner.md.template',
|
|
30
30
|
to: `${AGENT_CONFIG_DIR}/agents/workflow_planner.md`
|
|
31
31
|
},
|
|
32
|
+
{
|
|
33
|
+
type: 'template',
|
|
34
|
+
from: 'agents/workflow_quality.md.template',
|
|
35
|
+
to: `${AGENT_CONFIG_DIR}/agents/workflow_quality.md`
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
type: 'template',
|
|
39
|
+
from: 'agents/context_fetcher.md.template',
|
|
40
|
+
to: `${AGENT_CONFIG_DIR}/agents/context_fetcher.md`
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: 'template',
|
|
44
|
+
from: 'agents/prompt_writer.md.template',
|
|
45
|
+
to: `${AGENT_CONFIG_DIR}/agents/prompt_writer.md`
|
|
46
|
+
},
|
|
32
47
|
{
|
|
33
48
|
type: 'template',
|
|
34
49
|
from: 'commands/plan_workflow.md.template',
|
|
@@ -65,6 +80,21 @@ export const AGENT_CONFIGS = {
|
|
|
65
80
|
from: `${AGENT_CONFIG_DIR}/agents/workflow_planner.md`,
|
|
66
81
|
to: '.claude/agents/workflow_planner.md'
|
|
67
82
|
},
|
|
83
|
+
{
|
|
84
|
+
type: 'symlink',
|
|
85
|
+
from: `${AGENT_CONFIG_DIR}/agents/workflow_quality.md`,
|
|
86
|
+
to: '.claude/agents/workflow_quality.md'
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
type: 'symlink',
|
|
90
|
+
from: `${AGENT_CONFIG_DIR}/agents/context_fetcher.md`,
|
|
91
|
+
to: '.claude/agents/context_fetcher.md'
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
type: 'symlink',
|
|
95
|
+
from: `${AGENT_CONFIG_DIR}/agents/prompt_writer.md`,
|
|
96
|
+
to: '.claude/agents/prompt_writer.md'
|
|
97
|
+
},
|
|
68
98
|
{
|
|
69
99
|
type: 'symlink',
|
|
70
100
|
from: `${AGENT_CONFIG_DIR}/commands/plan_workflow.md`,
|
|
@@ -39,11 +39,11 @@ describe('coding_agents service', () => {
|
|
|
39
39
|
const expectedCount = AGENT_CONFIGS.outputai.mappings.length +
|
|
40
40
|
AGENT_CONFIGS['claude-code'].mappings.length;
|
|
41
41
|
expect(files.length).toBe(expectedCount);
|
|
42
|
-
expect(files.length).toBe(
|
|
42
|
+
expect(files.length).toBe(16);
|
|
43
43
|
});
|
|
44
44
|
it('should have outputai files with .outputai prefix', () => {
|
|
45
45
|
const files = getRequiredFiles();
|
|
46
|
-
const outputaiFiles = files.slice(0,
|
|
46
|
+
const outputaiFiles = files.slice(0, 9);
|
|
47
47
|
outputaiFiles.forEach(file => {
|
|
48
48
|
expect(file).toMatch(/^\.outputai\//);
|
|
49
49
|
});
|
|
@@ -77,12 +77,18 @@ describe('coding_agents service', () => {
|
|
|
77
77
|
missingFiles: [
|
|
78
78
|
'.outputai/AGENTS.md',
|
|
79
79
|
'.outputai/agents/workflow_planner.md',
|
|
80
|
+
'.outputai/agents/workflow_quality.md',
|
|
81
|
+
'.outputai/agents/context_fetcher.md',
|
|
82
|
+
'.outputai/agents/prompt_writer.md',
|
|
80
83
|
'.outputai/commands/plan_workflow.md',
|
|
81
84
|
'.outputai/commands/build_workflow.md',
|
|
82
85
|
'.outputai/meta/pre_flight.md',
|
|
83
86
|
'.outputai/meta/post_flight.md',
|
|
84
87
|
'CLAUDE.md',
|
|
85
88
|
'.claude/agents/workflow_planner.md',
|
|
89
|
+
'.claude/agents/workflow_quality.md',
|
|
90
|
+
'.claude/agents/context_fetcher.md',
|
|
91
|
+
'.claude/agents/prompt_writer.md',
|
|
86
92
|
'.claude/commands/plan_workflow.md',
|
|
87
93
|
'.claude/commands/build_workflow.md'
|
|
88
94
|
],
|
|
@@ -98,54 +104,21 @@ describe('coding_agents service', () => {
|
|
|
98
104
|
missingFiles: [],
|
|
99
105
|
isComplete: true
|
|
100
106
|
});
|
|
101
|
-
expect(access).toHaveBeenCalledTimes(
|
|
107
|
+
expect(access).toHaveBeenCalledTimes(17); // dir + 9 outputai + 7 claude-code
|
|
102
108
|
});
|
|
103
109
|
it('should return missing files when some files do not exist', async () => {
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
// Call 3: .outputai/agents/workflow_planner.md missing
|
|
117
|
-
if (callNum === 3) {
|
|
118
|
-
throw { code: 'ENOENT' };
|
|
119
|
-
}
|
|
120
|
-
// Call 4: .outputai/commands/plan_workflow.md exists
|
|
121
|
-
if (callNum === 4) {
|
|
122
|
-
return undefined;
|
|
123
|
-
}
|
|
124
|
-
// Call 5: .outputai/commands/build_workflow.md exists
|
|
125
|
-
if (callNum === 5) {
|
|
126
|
-
return undefined;
|
|
127
|
-
}
|
|
128
|
-
// Call 6: .outputai/meta/pre_flight.md exists
|
|
129
|
-
if (callNum === 6) {
|
|
130
|
-
return undefined;
|
|
131
|
-
}
|
|
132
|
-
// Call 7: .outputai/meta/post_flight.md exists
|
|
133
|
-
if (callNum === 7) {
|
|
134
|
-
return undefined;
|
|
135
|
-
}
|
|
136
|
-
// Call 8: CLAUDE.md exists
|
|
137
|
-
if (callNum === 8) {
|
|
138
|
-
return undefined;
|
|
139
|
-
}
|
|
140
|
-
// Call 9: .claude/agents/workflow_planner.md missing
|
|
141
|
-
if (callNum === 9) {
|
|
142
|
-
throw { code: 'ENOENT' };
|
|
143
|
-
}
|
|
144
|
-
// Call 10: .claude/commands/plan_workflow.md exists
|
|
145
|
-
if (callNum === 10) {
|
|
146
|
-
return undefined;
|
|
110
|
+
const missingFiles = new Set([
|
|
111
|
+
'.outputai/agents/workflow_planner.md',
|
|
112
|
+
'.claude/agents/workflow_planner.md'
|
|
113
|
+
]);
|
|
114
|
+
vi.mocked(access).mockImplementation(async (path) => {
|
|
115
|
+
const pathStr = path.toString();
|
|
116
|
+
// Check if this path ends with any of the missing files
|
|
117
|
+
for (const missing of missingFiles) {
|
|
118
|
+
if (pathStr.endsWith(missing)) {
|
|
119
|
+
throw { code: 'ENOENT' };
|
|
120
|
+
}
|
|
147
121
|
}
|
|
148
|
-
// Call 11: .claude/commands/build_workflow.md exists
|
|
149
122
|
return undefined;
|
|
150
123
|
});
|
|
151
124
|
const result = await checkAgentStructure('/test/project');
|
|
@@ -159,18 +132,20 @@ describe('coding_agents service', () => {
|
|
|
159
132
|
});
|
|
160
133
|
});
|
|
161
134
|
it('should check all required files even when directory exists', async () => {
|
|
162
|
-
|
|
163
|
-
.
|
|
164
|
-
.
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
135
|
+
const missingFiles = new Set([
|
|
136
|
+
'.outputai/agents/workflow_planner.md',
|
|
137
|
+
'.outputai/commands/plan_workflow.md',
|
|
138
|
+
'.claude/commands/plan_workflow.md'
|
|
139
|
+
]);
|
|
140
|
+
vi.mocked(access).mockImplementation(async (path) => {
|
|
141
|
+
const pathStr = path.toString();
|
|
142
|
+
for (const missing of missingFiles) {
|
|
143
|
+
if (pathStr.endsWith(missing)) {
|
|
144
|
+
throw { code: 'ENOENT' };
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return undefined;
|
|
148
|
+
});
|
|
174
149
|
const result = await checkAgentStructure('/test/project');
|
|
175
150
|
expect(result.dirExists).toBe(true);
|
|
176
151
|
expect(result.missingFiles).toEqual([
|
|
@@ -207,8 +182,8 @@ describe('coding_agents service', () => {
|
|
|
207
182
|
});
|
|
208
183
|
// Should create outputai files (6 templates)
|
|
209
184
|
expect(fs.writeFile).toHaveBeenCalledWith(expect.stringContaining('AGENTS.md'), expect.any(String), 'utf-8');
|
|
210
|
-
// Should create symlinks (
|
|
211
|
-
expect(fs.symlink).toHaveBeenCalledTimes(
|
|
185
|
+
// Should create symlinks (7 symlinks for claude-code)
|
|
186
|
+
expect(fs.symlink).toHaveBeenCalledTimes(7);
|
|
212
187
|
});
|
|
213
188
|
it('should skip existing files when force is false', async () => {
|
|
214
189
|
// Mock some files exist
|
|
@@ -3,3 +3,4 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare const getEjectSuccessMessage: (destPath: string, outputFile: string, binName: string) => string;
|
|
5
5
|
export declare const getProjectSuccessMessage: (folderName: string, installSuccess: boolean, envConfigured?: boolean) => string;
|
|
6
|
+
export declare const getWorkflowGenerateSuccessMessage: (workflowName: string, targetDir: string, filesCreated: string[]) => string;
|
|
@@ -176,7 +176,7 @@ export const getProjectSuccessMessage = (folderName, installSuccess, envConfigur
|
|
|
176
176
|
note: 'Launches Temporal, Redis, PostgreSQL, API, Worker, and UI'
|
|
177
177
|
}, {
|
|
178
178
|
step: 'Run example workflow',
|
|
179
|
-
command: 'output workflow run simple --input
|
|
179
|
+
command: 'output workflow run simple --input src/simple/scenarios/question_ada_lovelace.json',
|
|
180
180
|
note: 'Execute in a new terminal after services are running'
|
|
181
181
|
}, {
|
|
182
182
|
step: 'Monitor workflows',
|
|
@@ -231,3 +231,67 @@ ${ux.colorize('dim', ' with AI assistance.')}
|
|
|
231
231
|
${ux.colorize('green', ux.colorize('bold', 'Happy building with Output SDK! 🚀'))}
|
|
232
232
|
`;
|
|
233
233
|
};
|
|
234
|
+
export const getWorkflowGenerateSuccessMessage = (workflowName, targetDir, filesCreated) => {
|
|
235
|
+
const divider = ux.colorize('dim', '─'.repeat(80));
|
|
236
|
+
const bulletPoint = ux.colorize('green', '▸');
|
|
237
|
+
const formattedFiles = filesCreated.map(file => {
|
|
238
|
+
return ` ${bulletPoint} ${formatPath(file)}`;
|
|
239
|
+
}).join('\n');
|
|
240
|
+
const steps = [
|
|
241
|
+
{
|
|
242
|
+
step: 'Navigate to workflow directory',
|
|
243
|
+
command: `cd ${targetDir}`
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
step: 'Edit workflow files',
|
|
247
|
+
note: 'Customize workflow.ts, steps.ts, and prompts to match your requirements'
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
step: 'Configure environment',
|
|
251
|
+
command: 'Edit .env file',
|
|
252
|
+
note: 'Add your LLM provider credentials (ANTHROPIC_API_KEY or OPENAI_API_KEY)'
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
step: 'Test with example scenario',
|
|
256
|
+
command: `output workflow run ${workflowName} --input ${targetDir}/scenarios/test_input.json`,
|
|
257
|
+
note: 'Run after starting services with "output dev"'
|
|
258
|
+
}
|
|
259
|
+
];
|
|
260
|
+
const formattedSteps = steps.map((item, index) => {
|
|
261
|
+
const stepNumber = ux.colorize('dim', `${index + 1}.`);
|
|
262
|
+
const stepText = ux.colorize('white', item.step);
|
|
263
|
+
const command = item.command ? `\n ${bulletPoint} ${formatCommand(item.command)}` : '';
|
|
264
|
+
const note = item.note ? `\n ${ux.colorize('dim', ` ${item.note}`)}` : '';
|
|
265
|
+
return ` ${stepNumber} ${stepText}${command}${note}`;
|
|
266
|
+
}).join('\n\n');
|
|
267
|
+
return `
|
|
268
|
+
${divider}
|
|
269
|
+
|
|
270
|
+
${ux.colorize('bold', ux.colorize('green', '✅ SUCCESS!'))} ${ux.colorize('bold', `Workflow "${workflowName}" created`)}
|
|
271
|
+
|
|
272
|
+
${divider}
|
|
273
|
+
|
|
274
|
+
${createSectionHeader('WORKFLOW DETAILS', '📁')}
|
|
275
|
+
|
|
276
|
+
${bulletPoint} ${ux.colorize('white', 'Name:')} ${formatPath(workflowName)}
|
|
277
|
+
${bulletPoint} ${ux.colorize('white', 'Location:')} ${formatPath(targetDir)}
|
|
278
|
+
|
|
279
|
+
${divider}
|
|
280
|
+
|
|
281
|
+
${createSectionHeader('FILES CREATED', '📄')}
|
|
282
|
+
|
|
283
|
+
${formattedFiles}
|
|
284
|
+
|
|
285
|
+
${divider}
|
|
286
|
+
|
|
287
|
+
${createSectionHeader('NEXT STEPS', '🚀')}
|
|
288
|
+
|
|
289
|
+
${formattedSteps}
|
|
290
|
+
|
|
291
|
+
${divider}
|
|
292
|
+
|
|
293
|
+
${ux.colorize('dim', '💡 Tip: Check the README.md in your workflow directory for detailed documentation.')}
|
|
294
|
+
|
|
295
|
+
${ux.colorize('green', ux.colorize('bold', 'Happy building! 🛠️'))}
|
|
296
|
+
`;
|
|
297
|
+
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { TraceData } from '#types/trace.js';
|
|
2
|
+
export type { TraceData };
|
|
1
3
|
/**
|
|
2
4
|
* Find trace file from workflow metadata
|
|
3
5
|
*/
|
|
@@ -5,4 +7,8 @@ export declare function findTraceFile(workflowId: string): Promise<string>;
|
|
|
5
7
|
/**
|
|
6
8
|
* Read and parse trace file
|
|
7
9
|
*/
|
|
8
|
-
export declare function readTraceFile(path: string): Promise<
|
|
10
|
+
export declare function readTraceFile(path: string): Promise<TraceData>;
|
|
11
|
+
/**
|
|
12
|
+
* Get trace data from workflow ID
|
|
13
|
+
*/
|
|
14
|
+
export declare function getTrace(workflowId: string): Promise<TraceData>;
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import { readFile, stat } from 'node:fs/promises';
|
|
2
2
|
import { getWorkflowIdOutput } from '#api/generated/api.js';
|
|
3
|
+
import { getErrorCode } from '#utils/error_utils.js';
|
|
3
4
|
/**
|
|
4
|
-
* Check if a file exists
|
|
5
|
+
* Check if a file exists with detailed error information
|
|
5
6
|
*/
|
|
6
7
|
async function fileExists(path) {
|
|
7
8
|
try {
|
|
8
9
|
await stat(path);
|
|
9
|
-
return true;
|
|
10
|
+
return { exists: true };
|
|
10
11
|
}
|
|
11
|
-
catch {
|
|
12
|
-
|
|
12
|
+
catch (error) {
|
|
13
|
+
const code = getErrorCode(error);
|
|
14
|
+
if (code === 'ENOENT') {
|
|
15
|
+
return { exists: false };
|
|
16
|
+
}
|
|
17
|
+
if (code === 'EACCES') {
|
|
18
|
+
return { exists: false, error: `Permission denied: ${path}` };
|
|
19
|
+
}
|
|
20
|
+
return { exists: false, error: `Cannot access file: ${path}` };
|
|
13
21
|
}
|
|
14
22
|
}
|
|
15
23
|
/**
|
|
@@ -25,22 +33,23 @@ export async function findTraceFile(workflowId) {
|
|
|
25
33
|
if (!tracePath) {
|
|
26
34
|
throw new Error(`No trace file path found for workflow ${workflowId}`);
|
|
27
35
|
}
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
const fileCheck = await fileExists(tracePath);
|
|
37
|
+
if (!fileCheck.exists) {
|
|
38
|
+
const errorDetail = fileCheck.error || `Trace file not found at path: ${tracePath}`;
|
|
39
|
+
throw new Error(errorDetail);
|
|
30
40
|
}
|
|
31
41
|
return tracePath;
|
|
32
42
|
}
|
|
33
43
|
/**
|
|
34
44
|
* Read and parse trace file
|
|
35
45
|
*/
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
46
|
export async function readTraceFile(path) {
|
|
38
47
|
try {
|
|
39
48
|
const content = await readFile(path, 'utf-8');
|
|
40
49
|
return JSON.parse(content);
|
|
41
50
|
}
|
|
42
51
|
catch (error) {
|
|
43
|
-
if (error
|
|
52
|
+
if (getErrorCode(error) === 'ENOENT') {
|
|
44
53
|
throw new Error(`Trace file not found at path: ${path}`);
|
|
45
54
|
}
|
|
46
55
|
if (error instanceof SyntaxError) {
|
|
@@ -49,3 +58,10 @@ export async function readTraceFile(path) {
|
|
|
49
58
|
throw error;
|
|
50
59
|
}
|
|
51
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Get trace data from workflow ID
|
|
63
|
+
*/
|
|
64
|
+
export async function getTrace(workflowId) {
|
|
65
|
+
const tracePath = await findTraceFile(workflowId);
|
|
66
|
+
return readTraceFile(tracePath);
|
|
67
|
+
}
|
|
@@ -85,7 +85,8 @@ describe('TraceReader', () => {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
|
-
|
|
88
|
+
const enoentError = Object.assign(new Error('ENOENT: no such file or directory'), { code: 'ENOENT' });
|
|
89
|
+
mockStat.mockRejectedValue(enoentError);
|
|
89
90
|
await expect(findTraceFile(workflowId))
|
|
90
91
|
.rejects.toThrow(`Trace file not found at path: ${expectedPath}`);
|
|
91
92
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|