@bastani/atomic 0.9.0-alpha.1 → 0.9.0-alpha.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/CHANGELOG.md +29 -0
- package/dist/builtin/cursor/CHANGELOG.md +6 -0
- package/dist/builtin/cursor/package.json +2 -2
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/CHANGELOG.md +6 -0
- package/dist/builtin/mcp/package.json +3 -3
- package/dist/builtin/subagents/CHANGELOG.md +6 -0
- package/dist/builtin/subagents/package.json +4 -4
- package/dist/builtin/web-access/CHANGELOG.md +6 -0
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +19 -0
- package/dist/builtin/workflows/README.md +189 -122
- package/dist/builtin/workflows/builtin/deep-research-codebase.ts +30 -27
- package/dist/builtin/workflows/builtin/goal-ledger.ts +2 -0
- package/dist/builtin/workflows/builtin/goal-reports.ts +5 -0
- package/dist/builtin/workflows/builtin/goal-runner.ts +17 -20
- package/dist/builtin/workflows/builtin/goal-types.ts +2 -0
- package/dist/builtin/workflows/builtin/goal.d.ts +1 -0
- package/dist/builtin/workflows/builtin/goal.ts +40 -44
- package/dist/builtin/workflows/builtin/index.d.ts +1 -0
- package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +16 -17
- package/dist/builtin/workflows/builtin/open-claude-design.d.ts +1 -0
- package/dist/builtin/workflows/builtin/open-claude-design.ts +42 -50
- package/dist/builtin/workflows/builtin/prompt-refinement.ts +102 -0
- package/dist/builtin/workflows/builtin/ralph-core.ts +6 -4
- package/dist/builtin/workflows/builtin/ralph-runner.ts +22 -24
- package/dist/builtin/workflows/builtin/ralph.d.ts +2 -0
- package/dist/builtin/workflows/builtin/ralph.ts +46 -41
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/src/authoring/typebox-defaults.d.ts +41 -0
- package/dist/builtin/workflows/src/authoring/typebox-defaults.ts +217 -0
- package/dist/builtin/workflows/src/authoring/workflow.ts +184 -0
- package/dist/builtin/workflows/src/authoring.d.ts +14 -66
- package/dist/builtin/workflows/src/engine/graph-inference.ts +100 -0
- package/dist/builtin/workflows/src/engine/options.ts +40 -0
- package/dist/builtin/workflows/src/engine/primitives/chain.ts +29 -0
- package/dist/builtin/workflows/src/engine/primitives/exit.ts +2 -0
- package/dist/builtin/workflows/src/engine/primitives/parallel.ts +47 -0
- package/dist/builtin/workflows/src/engine/primitives/task.ts +108 -0
- package/dist/builtin/workflows/src/engine/primitives/ui.ts +41 -0
- package/dist/builtin/workflows/src/engine/primitives/workflow.ts +159 -0
- package/dist/builtin/workflows/src/engine/replay.ts +8 -0
- package/dist/builtin/workflows/src/engine/run.ts +356 -0
- package/dist/builtin/workflows/src/engine/runtime.ts +160 -0
- package/dist/builtin/workflows/src/extension/workflow-module-loader.ts +9 -3
- package/dist/builtin/workflows/src/extension/workflow-prompts.ts +3 -1
- package/dist/builtin/workflows/src/extension/workflow-schema.ts +0 -18
- package/dist/builtin/workflows/src/index.ts +0 -2
- package/dist/builtin/workflows/src/runs/background/runner.ts +6 -3
- package/dist/builtin/workflows/src/runs/foreground/executor-child-boundary.ts +3 -3
- package/dist/builtin/workflows/src/runs/foreground/executor-child-helpers.ts +4 -4
- package/dist/builtin/workflows/src/runs/foreground/executor-child-workflow.ts +1 -158
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-outputs.ts +2 -2
- package/dist/builtin/workflows/src/runs/foreground/executor-prompt-nodes.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-run.ts +1 -359
- package/dist/builtin/workflows/src/runs/foreground/executor-scheduler.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-call.ts +2 -5
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +12 -4
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-replay.ts +4 -3
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-types.ts +9 -2
- package/dist/builtin/workflows/src/runs/foreground/executor-task-context.ts +2 -132
- package/dist/builtin/workflows/src/runs/foreground/executor-types.ts +2 -2
- package/dist/builtin/workflows/src/runs/shared/graph-inference.ts +2 -100
- package/dist/builtin/workflows/src/sdk-surface.ts +6 -9
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +9 -3
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.ts +17 -3
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +3 -33
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.ts +9 -81
- package/dist/builtin/workflows/src/shared/types.ts +25 -8
- package/dist/builtin/workflows/src/shared/workflow-authoring-types.d.ts +49 -0
- package/dist/builtin/workflows/src/shared/workflow-authoring-types.ts +84 -0
- package/dist/builtin/workflows/src/workflows/registry.ts +7 -3
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +6 -1
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +0 -5
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +0 -2
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +0 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +0 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +0 -2
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +0 -2
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +0 -2
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +0 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/atomic-guide-command.d.ts.map +1 -1
- package/dist/core/atomic-guide-command.js +1 -1
- package/dist/core/atomic-guide-command.js.map +1 -1
- package/dist/core/extensions/loader-core.d.ts +1 -3
- package/dist/core/extensions/loader-core.d.ts.map +1 -1
- package/dist/core/extensions/loader-core.js +13 -6
- package/dist/core/extensions/loader-core.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts +7 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +34 -2
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +2 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +2 -1
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/index.d.ts +0 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +0 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/model-registry-builtins.d.ts.map +1 -1
- package/dist/core/model-registry-builtins.js +6 -0
- package/dist/core/model-registry-builtins.js.map +1 -1
- package/dist/core/model-registry-schemas.d.ts +65 -13
- package/dist/core/model-registry-schemas.d.ts.map +1 -1
- package/dist/core/model-registry-schemas.js +10 -0
- package/dist/core/model-registry-schemas.js.map +1 -1
- package/dist/core/resource-loader-core.d.ts +1 -0
- package/dist/core/resource-loader-core.d.ts.map +1 -1
- package/dist/core/resource-loader-core.js +2 -0
- package/dist/core/resource-loader-core.js.map +1 -1
- package/dist/core/resource-loader-extensions.d.ts.map +1 -1
- package/dist/core/resource-loader-extensions.js +3 -3
- package/dist/core/resource-loader-extensions.js.map +1 -1
- package/dist/core/resource-loader-internals.d.ts +1 -0
- package/dist/core/resource-loader-internals.d.ts.map +1 -1
- package/dist/core/resource-loader-internals.js.map +1 -1
- package/dist/core/resource-loader-reload.d.ts.map +1 -1
- package/dist/core/resource-loader-reload.js +6 -2
- package/dist/core/resource-loader-reload.js.map +1 -1
- package/dist/core/sdk-exports.d.ts +1 -1
- package/dist/core/sdk-exports.d.ts.map +1 -1
- package/dist/core/sdk-exports.js.map +1 -1
- package/dist/core/sdk-types.d.ts +0 -3
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +0 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-history.d.ts.map +1 -1
- package/dist/core/session-manager-history.js +2 -1
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +0 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +0 -5
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +10 -11
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff-preserve.d.ts +18 -0
- package/dist/core/tools/edit-diff-preserve.d.ts.map +1 -0
- package/dist/core/tools/edit-diff-preserve.js +85 -0
- package/dist/core/tools/edit-diff-preserve.js.map +1 -0
- package/dist/core/tools/edit-diff.d.ts +3 -2
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +15 -18
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/index.d.ts +0 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +0 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +2 -2
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/model-search.d.ts +5 -0
- package/dist/modes/interactive/model-search.d.ts.map +1 -1
- package/dist/modes/interactive/model-search.js +9 -0
- package/dist/modes/interactive/model-search.js.map +1 -1
- package/dist/utils/shell.d.ts +1 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +12 -5
- package/dist/utils/shell.js.map +1 -1
- package/docs/custom-provider.md +4 -3
- package/docs/models.md +3 -2
- package/docs/packages.md +2 -2
- package/docs/quickstart.md +1 -1
- package/docs/sdk.md +2 -40
- package/docs/security.md +1 -1
- package/docs/workflows.md +991 -176
- package/package.json +5 -5
- package/dist/builtin/workflows/src/workflows/define-workflow.ts +0 -277
- package/dist/core/tools/bash-policy-compile.d.ts +0 -5
- package/dist/core/tools/bash-policy-compile.d.ts.map +0 -1
- package/dist/core/tools/bash-policy-compile.js +0 -241
- package/dist/core/tools/bash-policy-compile.js.map +0 -1
- package/dist/core/tools/bash-policy-evaluate.d.ts +0 -3
- package/dist/core/tools/bash-policy-evaluate.d.ts.map +0 -1
- package/dist/core/tools/bash-policy-evaluate.js +0 -92
- package/dist/core/tools/bash-policy-evaluate.js.map +0 -1
- package/dist/core/tools/bash-policy-format.d.ts +0 -5
- package/dist/core/tools/bash-policy-format.d.ts.map +0 -1
- package/dist/core/tools/bash-policy-format.js +0 -49
- package/dist/core/tools/bash-policy-format.js.map +0 -1
- package/dist/core/tools/bash-policy-parser.d.ts +0 -4
- package/dist/core/tools/bash-policy-parser.d.ts.map +0 -1
- package/dist/core/tools/bash-policy-parser.js +0 -155
- package/dist/core/tools/bash-policy-parser.js.map +0 -1
- package/dist/core/tools/bash-policy-segment.d.ts +0 -3
- package/dist/core/tools/bash-policy-segment.d.ts.map +0 -1
- package/dist/core/tools/bash-policy-segment.js +0 -275
- package/dist/core/tools/bash-policy-segment.js.map +0 -1
- package/dist/core/tools/bash-policy-shell.d.ts +0 -11
- package/dist/core/tools/bash-policy-shell.d.ts.map +0 -1
- package/dist/core/tools/bash-policy-shell.js +0 -267
- package/dist/core/tools/bash-policy-shell.js.map +0 -1
- package/dist/core/tools/bash-policy-types.d.ts +0 -146
- package/dist/core/tools/bash-policy-types.d.ts.map +0 -1
- package/dist/core/tools/bash-policy-types.js +0 -2
- package/dist/core/tools/bash-policy-types.js.map +0 -1
- package/dist/core/tools/bash-policy.d.ts +0 -6
- package/dist/core/tools/bash-policy.d.ts.map +0 -1
- package/dist/core/tools/bash-policy.js +0 -5
- package/dist/core/tools/bash-policy.js.map +0 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
import type { WorkflowTaskResult } from "../src/shared/types.js";
|
|
2
|
+
import type { WorkflowParallelOptions, WorkflowTaskOptions, WorkflowTaskResult, WorkflowTaskStep } from "../src/shared/types.js";
|
|
3
3
|
import { reviewDecisionSchema } from "./goal-schemas.js";
|
|
4
4
|
import {
|
|
5
5
|
DEFAULT_BLOCKER_THRESHOLD,
|
|
6
6
|
DEFAULT_MAX_TURNS,
|
|
7
7
|
DEFAULT_REVIEW_QUORUM,
|
|
8
|
+
type GoalWorkflowInputs,
|
|
8
9
|
type GoalWorkflowOutputs,
|
|
9
10
|
type ReviewRecord,
|
|
10
11
|
} from "./goal-types.js";
|
|
@@ -28,6 +29,8 @@ import {
|
|
|
28
29
|
renderGoalContinuationPrompt,
|
|
29
30
|
renderReviewerPrompt,
|
|
30
31
|
} from "./goal-prompts.js";
|
|
32
|
+
import { promptEngineerModelConfig } from "./ralph-models.js";
|
|
33
|
+
import { runPromptRefinementStage } from "./prompt-refinement.js";
|
|
31
34
|
|
|
32
35
|
function positiveInteger(value: number | undefined, fallback: number): number {
|
|
33
36
|
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
|
|
@@ -63,32 +66,25 @@ function normalizeBranchInput(
|
|
|
63
66
|
);
|
|
64
67
|
return looksLikeSafeGitRef ? trimmed : fallback;
|
|
65
68
|
}
|
|
66
|
-
|
|
67
|
-
readonly inputs:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
readonly base_branch?: string;
|
|
71
|
-
};
|
|
72
|
-
task(name: string, options: object): Promise<WorkflowTaskResult>;
|
|
73
|
-
parallel(
|
|
74
|
-
steps: readonly object[],
|
|
75
|
-
options: { readonly task: string; readonly failFast: false },
|
|
76
|
-
): Promise<WorkflowTaskResult[]>;
|
|
69
|
+
type GoalRunnerContext = {
|
|
70
|
+
readonly inputs: GoalWorkflowInputs;
|
|
71
|
+
task(name: string, options: WorkflowTaskOptions): Promise<WorkflowTaskResult>;
|
|
72
|
+
parallel(steps: readonly WorkflowTaskStep[], options: WorkflowParallelOptions): Promise<WorkflowTaskResult[]>;
|
|
77
73
|
};
|
|
78
74
|
|
|
79
|
-
export async function runGoalWorkflow(ctx:
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
if (!objective) {
|
|
75
|
+
export async function runGoalWorkflow(ctx: GoalRunnerContext): Promise<GoalWorkflowOutputs> {
|
|
76
|
+
const inputs = ctx.inputs;
|
|
77
|
+
const rawObjective = inputs.objective.trim();
|
|
78
|
+
if (!rawObjective) {
|
|
84
79
|
throw new Error("goal requires an objective input.");
|
|
85
80
|
}
|
|
81
|
+
const objective = await runPromptRefinementStage(ctx, { request: rawObjective, workflowLabel: "Goal", modelConfig: promptEngineerModelConfig });
|
|
86
82
|
|
|
87
83
|
const maxTurns = positiveInteger(inputs.max_turns, DEFAULT_MAX_TURNS);
|
|
88
84
|
const reviewQuorum = DEFAULT_REVIEW_QUORUM;
|
|
89
85
|
const blockerThreshold = Math.min(DEFAULT_BLOCKER_THRESHOLD, maxTurns);
|
|
90
86
|
const comparisonBaseBranch = normalizeBranchInput(inputs.base_branch, "origin/main");
|
|
91
|
-
const { ledger, ledgerPath, artifactDir } = await createGoalLedger(objective);
|
|
87
|
+
const { ledger, ledgerPath, artifactDir } = await createGoalLedger(objective, rawObjective);
|
|
92
88
|
|
|
93
89
|
const workerModelConfig = {
|
|
94
90
|
model: "openai-codex/gpt-5.5:medium",
|
|
@@ -169,7 +165,7 @@ export async function runGoalWorkflow(ctx: unknown): Promise<GoalWorkflowOutputs
|
|
|
169
165
|
|
|
170
166
|
let worker: WorkflowTaskResult;
|
|
171
167
|
try {
|
|
172
|
-
worker = await
|
|
168
|
+
worker = await ctx.task(`work-turn-${turn}`, {
|
|
173
169
|
prompt: workerPrompt,
|
|
174
170
|
reads: [ledgerPath, ...latestReviewArtifactPaths],
|
|
175
171
|
output: workTurnPath,
|
|
@@ -249,7 +245,7 @@ export async function runGoalWorkflow(ctx: unknown): Promise<GoalWorkflowOutputs
|
|
|
249
245
|
|
|
250
246
|
let reviewResults: WorkflowTaskResult[];
|
|
251
247
|
try {
|
|
252
|
-
reviewResults = await
|
|
248
|
+
reviewResults = await ctx.parallel(reviewerSteps, {
|
|
253
249
|
task: objective,
|
|
254
250
|
failFast: false,
|
|
255
251
|
});
|
|
@@ -332,6 +328,7 @@ export async function runGoalWorkflow(ctx: unknown): Promise<GoalWorkflowOutputs
|
|
|
332
328
|
approved: ledger.status === "complete",
|
|
333
329
|
goal_id: ledger.goal_id,
|
|
334
330
|
objective: ledger.objective,
|
|
331
|
+
...(ledger.original_objective === undefined ? {} : { original_objective: ledger.original_objective }),
|
|
335
332
|
ledger_path: ledgerPath,
|
|
336
333
|
turns_completed: ledger.turns,
|
|
337
334
|
iterations_completed: ledger.turns,
|
|
@@ -93,6 +93,7 @@ export type GoalLifecycleEvent = {
|
|
|
93
93
|
export type GoalLedger = {
|
|
94
94
|
readonly goal_id: string;
|
|
95
95
|
readonly objective: string;
|
|
96
|
+
readonly original_objective?: string;
|
|
96
97
|
status: GoalStatus;
|
|
97
98
|
turns: number;
|
|
98
99
|
readonly created_at: string;
|
|
@@ -122,6 +123,7 @@ export type GoalWorkflowOutputs = {
|
|
|
122
123
|
readonly approved?: boolean;
|
|
123
124
|
readonly goal_id?: string;
|
|
124
125
|
readonly objective?: string;
|
|
126
|
+
readonly original_objective?: string;
|
|
125
127
|
readonly ledger_path?: string;
|
|
126
128
|
readonly turns_completed?: number;
|
|
127
129
|
readonly iterations_completed?: number;
|
|
@@ -27,6 +27,7 @@ export type GoalWorkflowOutputs = WorkflowOutputValues & {
|
|
|
27
27
|
readonly approved?: boolean;
|
|
28
28
|
readonly goal_id?: string;
|
|
29
29
|
readonly objective?: string;
|
|
30
|
+
readonly original_objective?: string;
|
|
30
31
|
readonly ledger_path?: string;
|
|
31
32
|
readonly turns_completed?: number;
|
|
32
33
|
readonly iterations_completed?: number;
|
|
@@ -7,50 +7,46 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { Type } from "typebox";
|
|
10
|
-
import {
|
|
10
|
+
import { workflow } from "../src/authoring/workflow.js";
|
|
11
11
|
import { runGoalWorkflow } from "./goal-runner.js";
|
|
12
12
|
import { DEFAULT_MAX_TURNS } from "./goal-types.js";
|
|
13
13
|
|
|
14
|
-
export default
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
Type.Optional(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
.output("review_report", Type.Optional(Type.String({ description: "Compact report pointing to the latest reviewer decision artifacts used by the reducer." })))
|
|
54
|
-
.output("review_report_path", Type.Optional(Type.String({ description: "JSON artifact path for the latest reviewer decision round." })))
|
|
55
|
-
.run(runGoalWorkflow)
|
|
56
|
-
.compile();
|
|
14
|
+
export default workflow({
|
|
15
|
+
name: "goal",
|
|
16
|
+
description: "Goal Runner workflow with bounded LM turns, ledger artifacts, parallel reviewers, and reducer-gated completion.",
|
|
17
|
+
inputs: {
|
|
18
|
+
objective: Type.String({ description: "The objective for the Goal Runner workflow." }),
|
|
19
|
+
max_turns: Type.Number({
|
|
20
|
+
default: DEFAULT_MAX_TURNS,
|
|
21
|
+
description: "Maximum worker/review turns before Goal Runner stops as needs_human.",
|
|
22
|
+
}),
|
|
23
|
+
base_branch: Type.String({
|
|
24
|
+
default: "origin/main",
|
|
25
|
+
description: "Optional branch reviewers compare the current code delta against (default origin/main).",
|
|
26
|
+
}),
|
|
27
|
+
},
|
|
28
|
+
outputs: {
|
|
29
|
+
result: Type.Optional(Type.String({ description: "Final report with objective, status, receipts, turns, and remaining work." })),
|
|
30
|
+
status: Type.Optional(Type.Union(
|
|
31
|
+
[Type.Literal("complete"), Type.Literal("blocked"), Type.Literal("needs_human"), Type.Literal("active")],
|
|
32
|
+
{ description: "Final reducer status: complete, blocked, needs_human, or active if externally interrupted." },
|
|
33
|
+
)),
|
|
34
|
+
approved: Type.Optional(Type.Boolean({ description: "Whether the reducer reached complete." })),
|
|
35
|
+
goal_id: Type.Optional(Type.String({ description: "Per-run goal identifier stored in the ledger." })),
|
|
36
|
+
objective: Type.Optional(Type.String({ description: "Normalized goal objective used by the run (refined by the prompt-refinement stage)." })),
|
|
37
|
+
original_objective: Type.Optional(Type.String({ description: "The raw user-provided objective exactly as given, before prompt refinement. Omitted when refinement left it unchanged." })),
|
|
38
|
+
ledger_path: Type.Optional(Type.String({ description: "OS-temp path to goal-ledger.json with receipts, reviewer decisions, blockers, and lifecycle events." })),
|
|
39
|
+
turns_completed: Type.Optional(Type.Number({ description: "Worker/review turns completed." })),
|
|
40
|
+
iterations_completed: Type.Optional(Type.Number({ description: "Worker/review turns completed, retained for status summaries." })),
|
|
41
|
+
receipts: Type.Optional(Type.Array(Type.Object({
|
|
42
|
+
turn: Type.Number(),
|
|
43
|
+
stage: Type.String(),
|
|
44
|
+
artifact_path: Type.String(),
|
|
45
|
+
summary: Type.String(),
|
|
46
|
+
}), { description: "Ledger receipt summaries and worker artifact paths." })),
|
|
47
|
+
remaining_work: Type.Optional(Type.String({ description: "Remaining gaps or blockers when incomplete, or none." })),
|
|
48
|
+
review_report: Type.Optional(Type.String({ description: "Compact report pointing to the latest reviewer decision artifacts used by the reducer." })),
|
|
49
|
+
review_report_path: Type.Optional(Type.String({ description: "JSON artifact path for the latest reviewer decision round." })),
|
|
50
|
+
},
|
|
51
|
+
run: async (ctx) => await runGoalWorkflow(ctx),
|
|
52
|
+
});
|
|
@@ -127,6 +127,7 @@ export type OpenClaudeDesignWorkflowOutputs = WorkflowOutputValues & {
|
|
|
127
127
|
readonly preview_file_url?: string;
|
|
128
128
|
readonly spec_path?: string;
|
|
129
129
|
readonly spec_file_url?: string;
|
|
130
|
+
readonly playwright_cli_status?: string;
|
|
130
131
|
};
|
|
131
132
|
export type OpenClaudeDesignWorkflowDefinition = WorkflowDefinition<
|
|
132
133
|
OpenClaudeDesignWorkflowInputs,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WorkflowTaskResult, WorkflowTaskStep } from "../src/shared/types.js";
|
|
1
|
+
import type { WorkflowParallelOptions, WorkflowTaskOptions, WorkflowTaskResult, WorkflowTaskStep } from "../src/shared/types.js";
|
|
2
2
|
import {
|
|
3
3
|
ANTI_SLOP_RULES,
|
|
4
4
|
DEFAULT_MAX_REFINEMENTS,
|
|
@@ -18,24 +18,22 @@ import {
|
|
|
18
18
|
} from "./open-claude-design-utils.js";
|
|
19
19
|
import { exportOpenClaudeDesign, refineOpenClaudeDesign } from "./open-claude-design-phases.js";
|
|
20
20
|
|
|
21
|
+
type OpenClaudeDesignOutputs = {
|
|
22
|
+
readonly output_type?: string; readonly design_system?: string; readonly artifact?: string; readonly handoff?: string;
|
|
23
|
+
readonly approved_for_export?: boolean; readonly refinements_completed?: number; readonly import_context?: string; readonly run_id?: string;
|
|
24
|
+
readonly artifact_dir?: string; readonly preview_path?: string; readonly preview_file_url?: string; readonly spec_path?: string; readonly spec_file_url?: string;
|
|
25
|
+
readonly playwright_cli_status?: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
21
28
|
type OpenClaudeDesignContext = {
|
|
22
|
-
readonly cwd
|
|
23
|
-
readonly inputs: {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
readonly output_type?: string;
|
|
27
|
-
readonly design_system?: string;
|
|
28
|
-
readonly max_refinements?: number;
|
|
29
|
-
};
|
|
30
|
-
task(name: string, options: object): Promise<WorkflowTaskResult>;
|
|
31
|
-
parallel(
|
|
32
|
-
steps: readonly WorkflowTaskStep[],
|
|
33
|
-
options: { readonly task: string },
|
|
34
|
-
): Promise<WorkflowTaskResult[]>;
|
|
29
|
+
readonly cwd?: string;
|
|
30
|
+
readonly inputs: { readonly prompt: string; readonly reference?: string; readonly output_type?: string; readonly design_system?: string; readonly max_refinements?: number };
|
|
31
|
+
task(name: string, options: WorkflowTaskOptions): Promise<WorkflowTaskResult>;
|
|
32
|
+
parallel(steps: readonly WorkflowTaskStep[], options: WorkflowParallelOptions): Promise<WorkflowTaskResult[]>;
|
|
35
33
|
};
|
|
36
34
|
|
|
37
|
-
export async function runOpenClaudeDesignWorkflow(ctx:
|
|
38
|
-
const designContext = ctx
|
|
35
|
+
export async function runOpenClaudeDesignWorkflow(ctx: OpenClaudeDesignContext): Promise<OpenClaudeDesignOutputs> {
|
|
36
|
+
const designContext = ctx;
|
|
39
37
|
|
|
40
38
|
// Initial deterministic setup step (no LLM): ensure the playwright-cli skill's
|
|
41
39
|
// `playwright-cli` command is installed before any design stage runs. Best-effort —
|
|
@@ -55,8 +53,9 @@ export async function runOpenClaudeDesignWorkflow(ctx: unknown): Promise<object>
|
|
|
55
53
|
DEFAULT_MAX_REFINEMENTS,
|
|
56
54
|
);
|
|
57
55
|
|
|
56
|
+
const workflowCwd = designContext.cwd ?? process.cwd();
|
|
58
57
|
const { runId, artifactDir, previewPath, specPath } = prepareArtifactDir(
|
|
59
|
-
|
|
58
|
+
workflowCwd,
|
|
60
59
|
);
|
|
61
60
|
const previewFileUrl = `file://${previewPath}`;
|
|
62
61
|
const specFileUrl = `file://${specPath}`;
|
|
@@ -32,6 +32,7 @@ export type OpenClaudeDesignWorkflowOutputs = WorkflowOutputValues & {
|
|
|
32
32
|
readonly preview_file_url?: string;
|
|
33
33
|
readonly spec_path?: string;
|
|
34
34
|
readonly spec_file_url?: string;
|
|
35
|
+
readonly playwright_cli_status?: string;
|
|
35
36
|
};
|
|
36
37
|
|
|
37
38
|
export type OpenClaudeDesignWorkflowDefinition = WorkflowDefinition<
|
|
@@ -18,21 +18,10 @@
|
|
|
18
18
|
* pre-export → impeccable `audit`
|
|
19
19
|
* forced-fix → impeccable `harden`
|
|
20
20
|
* exporter → impeccable `document` (rich HTML spec)
|
|
21
|
-
*
|
|
22
|
-
* The refinement loop has been re-shaped so that the artifact under review is
|
|
23
|
-
* a real HTML page on disk (`preview.html`). The workflow attempts to open it
|
|
24
|
-
* through the `playwright-cli` skill so the user can interactively review;
|
|
25
|
-
* when browser automation is unavailable, the file path is surfaced so the user
|
|
26
|
-
* can open it manually. Before any stage runs, an initial deterministic setup
|
|
27
|
-
* step ensures the playwright-cli skill's `playwright-cli` command is available
|
|
28
|
-
* (`npx --no-install playwright-cli --version`, then
|
|
29
|
-
* `npm install -g @playwright/cli@latest` when missing); it is best-effort and
|
|
30
|
-
* never blocks the run. The final exporter produces a rich `spec.html` that
|
|
31
|
-
* embeds the agreed-upon design alongside the implementation handoff.
|
|
32
21
|
*/
|
|
33
22
|
|
|
34
|
-
import { defineWorkflow } from "../src/workflows/define-workflow.js";
|
|
35
23
|
import { Type } from "typebox";
|
|
24
|
+
import { workflow } from "../src/authoring/workflow.js";
|
|
36
25
|
import { runOpenClaudeDesignWorkflow } from "./open-claude-design-runner.js";
|
|
37
26
|
import {
|
|
38
27
|
DEFAULT_MAX_REFINEMENTS,
|
|
@@ -40,41 +29,44 @@ import {
|
|
|
40
29
|
OUTPUT_TYPES,
|
|
41
30
|
} from "./open-claude-design-utils.js";
|
|
42
31
|
|
|
43
|
-
export default
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
32
|
+
export default workflow({
|
|
33
|
+
name: "open-claude-design",
|
|
34
|
+
description: "AI-powered design workflow: design-system onboarding → reference import → HTML generation → impeccable-driven refinement → quality gate → rich HTML handoff. Each stage delegates to a specific impeccable sub-skill; the user can iteratively review the generated HTML through the playwright-cli skill.",
|
|
35
|
+
inputs: {
|
|
36
|
+
prompt: Type.String({
|
|
37
|
+
description: "What to design (for example, a dashboard, page, component, or prototype).",
|
|
38
|
+
}),
|
|
39
|
+
reference: Type.Optional(Type.String({
|
|
40
|
+
description: "URL, file path, screenshot path, or design doc to import as a reference.",
|
|
41
|
+
})),
|
|
42
|
+
output_type: Type.Union(
|
|
43
|
+
[...OUTPUT_TYPES].map((value) => Type.Literal(value)),
|
|
44
|
+
{ default: DEFAULT_OUTPUT_TYPE, description: "Kind of design artifact to produce." },
|
|
45
|
+
),
|
|
46
|
+
design_system: Type.Optional(Type.String({
|
|
47
|
+
description:
|
|
48
|
+
"Path(s) or description of an existing design system (DESIGN.md, PRODUCT.md, etc.); skips onboarding when provided.",
|
|
49
|
+
})),
|
|
50
|
+
max_refinements: Type.Number({
|
|
51
|
+
default: DEFAULT_MAX_REFINEMENTS,
|
|
52
|
+
description: `Maximum critique/apply refinement iterations (default ${DEFAULT_MAX_REFINEMENTS}).`,
|
|
53
|
+
}),
|
|
54
|
+
},
|
|
55
|
+
outputs: {
|
|
56
|
+
output_type: Type.Optional(Type.String({ description: "Kind of design artifact produced." })),
|
|
57
|
+
design_system: Type.Optional(Type.String({ description: "Design system source used for generation: supplied input or project-derived design system." })),
|
|
58
|
+
artifact: Type.Optional(Type.String({ description: "Latest final design summary from the approved preview artifact." })),
|
|
59
|
+
handoff: Type.Optional(Type.String({ description: "Final rich HTML spec and implementation handoff summary." })),
|
|
60
|
+
approved_for_export: Type.Optional(Type.Boolean({ description: "Whether refinement completed before the final export gate." })),
|
|
61
|
+
refinements_completed: Type.Optional(Type.Number({ description: "Number of refinement iterations completed." })),
|
|
62
|
+
import_context: Type.Optional(Type.String({ description: "Reference-import context used during generation." })),
|
|
63
|
+
run_id: Type.Optional(Type.String({ description: "Per-run design workflow artifact identifier." })),
|
|
64
|
+
artifact_dir: Type.Optional(Type.String({ description: "Directory containing preview and spec artifacts." })),
|
|
65
|
+
preview_path: Type.Optional(Type.String({ description: "Absolute path to the generated preview.html file." })),
|
|
66
|
+
preview_file_url: Type.Optional(Type.String({ description: "file:// URL for the generated preview.html file." })),
|
|
67
|
+
spec_path: Type.Optional(Type.String({ description: "Absolute path to the generated spec.html file." })),
|
|
68
|
+
spec_file_url: Type.Optional(Type.String({ description: "file:// URL for the generated spec.html file." })),
|
|
69
|
+
playwright_cli_status: Type.Optional(Type.String({ description: "Outcome of the initial deterministic step that ensures the playwright-cli skill's `playwright-cli` command is installed." })),
|
|
70
|
+
},
|
|
71
|
+
run: async (ctx) => await runOpenClaudeDesignWorkflow(ctx),
|
|
72
|
+
});
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared prompt-refinement stage used by the ralph and goal workflows.
|
|
3
|
+
*
|
|
4
|
+
* Before the main work loop begins, both workflows run this single
|
|
5
|
+
* `prompt-refinement` stage. It invokes the prompt-engineer skill
|
|
6
|
+
* (`/skill:prompt-engineer`) to sharpen the raw user request into a clearer,
|
|
7
|
+
* more actionable objective using the Workflow Best Practices prompt anatomy
|
|
8
|
+
* documented in `packages/coding-agent/docs/workflows.md`. The refined request
|
|
9
|
+
* replaces the original as the operative objective downstream; the original is
|
|
10
|
+
* preserved by each workflow for reporting.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { WorkflowModelValue, WorkflowTaskOptions, WorkflowTaskResult } from "../src/shared/types.js";
|
|
14
|
+
|
|
15
|
+
export type PromptSection = readonly [tag: string, content: string];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Clarity rubric mirrored from the "## Workflow Best Practices" section of
|
|
19
|
+
* `docs/workflows.md` (the user-facing docs under packages/coding-agent/docs).
|
|
20
|
+
* The refinement stage makes each element explicit where it can be reasonably
|
|
21
|
+
* inferred from the raw request.
|
|
22
|
+
*/
|
|
23
|
+
export const PROMPT_REFINEMENT_CRITERIA = [
|
|
24
|
+
"Apply the workflow best practices documented in the `## Workflow Best Practices` section of `docs/workflows.md`. Treat that section as the authoritative prompt-anatomy rubric: use its Objective, Context, Scope, Non-goals, Done criteria, Validation command, Reporting requirements, and Stop conditions when refining the request.",
|
|
25
|
+
"Objective — state what should be true when the work is complete.",
|
|
26
|
+
"Context — note why it matters and where the relevant code or area likely lives.",
|
|
27
|
+
"Scope — state what is allowed to change (the smallest correct change).",
|
|
28
|
+
"Non-goals — state what to avoid (unrelated refactors, redesigns, or behavior changes outside this case).",
|
|
29
|
+
"Done criteria — list verifiable completion signals: new behavior works, existing behavior is unchanged, and the validation command passes.",
|
|
30
|
+
"Validation command — name the targeted check that proves the result.",
|
|
31
|
+
"Reporting requirements — changed files, validation results, and remaining risks must be reported.",
|
|
32
|
+
"Stop conditions — name the cases where the agent should stop and ask first (public API, security, data migration, etc.).",
|
|
33
|
+
].join("\n");
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Build the prompt sent to the prompt-refinement stage. The refined request is
|
|
37
|
+
* returned verbatim (no fences or preamble) so it can replace the original
|
|
38
|
+
* request as the operative objective for the rest of the workflow.
|
|
39
|
+
*/
|
|
40
|
+
export function renderPromptRefinementPrompt(args: {
|
|
41
|
+
readonly request: string;
|
|
42
|
+
readonly workflowLabel: string;
|
|
43
|
+
readonly workflowCwdContext?: PromptSection;
|
|
44
|
+
}): string {
|
|
45
|
+
const sections: readonly string[] = [
|
|
46
|
+
`/skill:prompt-engineer Refine the following user request into a clearer, more actionable objective for the ${args.workflowLabel} workflow. Improve clarity and completeness using the rubric below without changing the user's intent, expanding scope, or inventing requirements that cannot be reasonably inferred from the request.`,
|
|
47
|
+
`<original_request>\n${args.request}\n</original_request>`,
|
|
48
|
+
`<clarity_rubric>\nApply the Workflow Best Practices prompt anatomy. Make each of the following explicit where it can be reasonably inferred from the original request:\n${PROMPT_REFINEMENT_CRITERIA}\n</clarity_rubric>`,
|
|
49
|
+
[
|
|
50
|
+
"<refinement_rules>",
|
|
51
|
+
"- Preserve the user's original intent and scope; do not add unrelated work.",
|
|
52
|
+
"- If the original request is already clear and complete, return it essentially unchanged with only clarity improvements.",
|
|
53
|
+
"- Where a criterion cannot be reasonably inferred, state it as a concise assumption or a 'to confirm' note rather than fabricating specifics.",
|
|
54
|
+
"- Do not implement anything, run commands, or edit files. This stage only produces the refined request text.",
|
|
55
|
+
"</refinement_rules>",
|
|
56
|
+
].join("\n"),
|
|
57
|
+
`<output_format>\nReturn ONLY the refined request. No preamble, no explanation, and no Markdown fences. The returned text replaces the original request as the operative objective for the rest of the workflow, so it must be a single self-contained request.\n</output_format>`,
|
|
58
|
+
];
|
|
59
|
+
const tail = args.workflowCwdContext === undefined
|
|
60
|
+
? []
|
|
61
|
+
: [`<${args.workflowCwdContext[0]}>\n${args.workflowCwdContext[1].trim()}\n</${args.workflowCwdContext[0]}>`];
|
|
62
|
+
return [...sections, ...tail].join("\n\n");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Minimal context surface required to run a tracked refinement stage. */
|
|
66
|
+
type PromptRefinementContext = {
|
|
67
|
+
task(name: string, options: WorkflowTaskOptions): Promise<WorkflowTaskResult>;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/** Model-chain + tool gating forwarded to the refinement stage session. */
|
|
71
|
+
export type PromptRefinementModelConfig = {
|
|
72
|
+
readonly model?: WorkflowModelValue;
|
|
73
|
+
readonly fallbackModels?: readonly string[];
|
|
74
|
+
readonly noTools?: "all" | "builtin";
|
|
75
|
+
readonly excludedTools?: readonly string[];
|
|
76
|
+
readonly tools?: readonly string[];
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Run the shared `prompt-refinement` stage once and return the refined request.
|
|
81
|
+
* Falls back to the original request when the stage produces no usable text.
|
|
82
|
+
*/
|
|
83
|
+
export async function runPromptRefinementStage(
|
|
84
|
+
ctx: PromptRefinementContext,
|
|
85
|
+
options: {
|
|
86
|
+
readonly request: string;
|
|
87
|
+
readonly workflowLabel: string;
|
|
88
|
+
readonly workflowCwdContext?: PromptSection;
|
|
89
|
+
readonly modelConfig: PromptRefinementModelConfig;
|
|
90
|
+
},
|
|
91
|
+
): Promise<string> {
|
|
92
|
+
const result = await ctx.task("prompt-refinement", {
|
|
93
|
+
prompt: renderPromptRefinementPrompt({
|
|
94
|
+
request: options.request,
|
|
95
|
+
workflowLabel: options.workflowLabel,
|
|
96
|
+
...(options.workflowCwdContext === undefined ? {} : { workflowCwdContext: options.workflowCwdContext }),
|
|
97
|
+
}),
|
|
98
|
+
...options.modelConfig,
|
|
99
|
+
});
|
|
100
|
+
const refined = (result.text ?? "").trim();
|
|
101
|
+
return refined.length > 0 ? refined : options.request;
|
|
102
|
+
}
|
|
@@ -258,18 +258,18 @@ export function forkContinuationOptions(
|
|
|
258
258
|
: { context: "fork", forkFromSessionFile: sessionFile };
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
export function
|
|
261
|
+
export function renderResearchPromptRefinementPrompt(args: {
|
|
262
262
|
readonly iteration: number;
|
|
263
263
|
readonly maxLoops: number;
|
|
264
|
-
readonly
|
|
264
|
+
readonly request: string;
|
|
265
265
|
readonly workflowCwdContext: PromptSection;
|
|
266
266
|
readonly latestReviewReportPath: string | undefined;
|
|
267
267
|
}): string {
|
|
268
|
-
const basePrompt = `/skill:prompt-engineer Transform the following user
|
|
268
|
+
const basePrompt = `/skill:prompt-engineer Transform the following refined user request into a codebase and online research question which can be thoroughly explored: ${args.request}`;
|
|
269
269
|
return [
|
|
270
270
|
basePrompt,
|
|
271
271
|
taggedPrompt([
|
|
272
|
-
["iteration", `
|
|
272
|
+
["iteration", `Research prompt refinement iteration ${args.iteration}/${args.maxLoops}.`],
|
|
273
273
|
args.workflowCwdContext,
|
|
274
274
|
[
|
|
275
275
|
"review_findings",
|
|
@@ -404,5 +404,7 @@ export type RalphWorkflowResult = {
|
|
|
404
404
|
readonly iterations_completed: number;
|
|
405
405
|
readonly review_report: string;
|
|
406
406
|
readonly review_report_path?: string;
|
|
407
|
+
readonly original_prompt: string;
|
|
408
|
+
readonly refined_prompt: string;
|
|
407
409
|
};
|
|
408
410
|
|