@bastani/atomic 0.5.34-0 → 0.6.0-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 (94) hide show
  1. package/README.md +329 -50
  2. package/dist/commands/cli/session.d.ts +67 -0
  3. package/dist/commands/cli/session.d.ts.map +1 -0
  4. package/dist/commands/cli/workflow-status.d.ts +63 -0
  5. package/dist/commands/cli/workflow-status.d.ts.map +1 -0
  6. package/dist/sdk/commander.d.ts +74 -0
  7. package/dist/sdk/commander.d.ts.map +1 -0
  8. package/dist/sdk/components/workflow-picker-panel.d.ts +14 -17
  9. package/dist/sdk/components/workflow-picker-panel.d.ts.map +1 -1
  10. package/dist/sdk/define-workflow.d.ts +18 -9
  11. package/dist/sdk/define-workflow.d.ts.map +1 -1
  12. package/dist/sdk/index.d.ts +4 -3
  13. package/dist/sdk/index.d.ts.map +1 -1
  14. package/dist/sdk/management-commands.d.ts +42 -0
  15. package/dist/sdk/management-commands.d.ts.map +1 -0
  16. package/dist/sdk/registry.d.ts +27 -0
  17. package/dist/sdk/registry.d.ts.map +1 -0
  18. package/dist/sdk/runtime/attached-footer.d.ts +1 -1
  19. package/dist/sdk/runtime/executor-env.d.ts +20 -0
  20. package/dist/sdk/runtime/executor-env.d.ts.map +1 -0
  21. package/dist/sdk/runtime/executor.d.ts +61 -10
  22. package/dist/sdk/runtime/executor.d.ts.map +1 -1
  23. package/dist/sdk/types.d.ts +147 -4
  24. package/dist/sdk/types.d.ts.map +1 -1
  25. package/dist/sdk/worker-shared.d.ts +42 -0
  26. package/dist/sdk/worker-shared.d.ts.map +1 -0
  27. package/dist/sdk/workflow-cli.d.ts +103 -0
  28. package/dist/sdk/workflow-cli.d.ts.map +1 -0
  29. package/dist/sdk/workflows/builtin-registry.d.ts +113 -0
  30. package/dist/sdk/workflows/builtin-registry.d.ts.map +1 -0
  31. package/dist/sdk/workflows/index.d.ts +5 -5
  32. package/dist/sdk/workflows/index.d.ts.map +1 -1
  33. package/package.json +12 -8
  34. package/src/cli.ts +85 -144
  35. package/src/commands/cli/chat/index.ts +10 -0
  36. package/src/commands/cli/workflow-command.test.ts +279 -938
  37. package/src/commands/cli/workflow-inputs.test.ts +41 -11
  38. package/src/commands/cli/workflow-inputs.ts +47 -12
  39. package/src/commands/cli/workflow-list.test.ts +234 -0
  40. package/src/commands/cli/workflow-list.ts +0 -0
  41. package/src/commands/cli/workflow.ts +11 -798
  42. package/src/scripts/constants.ts +2 -1
  43. package/src/sdk/commander.ts +161 -0
  44. package/src/sdk/components/workflow-picker-panel.tsx +78 -258
  45. package/src/sdk/define-workflow.test.ts +104 -11
  46. package/src/sdk/define-workflow.ts +47 -11
  47. package/src/sdk/errors.test.ts +16 -0
  48. package/src/sdk/index.ts +8 -8
  49. package/src/sdk/management-commands.ts +151 -0
  50. package/src/sdk/registry.ts +132 -0
  51. package/src/sdk/runtime/attached-footer.ts +1 -1
  52. package/src/sdk/runtime/executor-env.ts +45 -0
  53. package/src/sdk/runtime/executor.test.ts +37 -0
  54. package/src/sdk/runtime/executor.ts +147 -68
  55. package/src/sdk/types.ts +169 -4
  56. package/src/sdk/worker-shared.test.ts +163 -0
  57. package/src/sdk/worker-shared.ts +155 -0
  58. package/src/sdk/workflow-cli.ts +409 -0
  59. package/src/sdk/workflows/builtin/deep-research-codebase/claude/index.ts +1 -1
  60. package/src/sdk/workflows/builtin/deep-research-codebase/copilot/index.ts +1 -1
  61. package/src/sdk/workflows/builtin/deep-research-codebase/opencode/index.ts +1 -1
  62. package/src/sdk/workflows/builtin/open-claude-design/claude/index.ts +1 -1
  63. package/src/sdk/workflows/builtin/open-claude-design/copilot/index.ts +1 -1
  64. package/src/sdk/workflows/builtin/open-claude-design/opencode/index.ts +1 -1
  65. package/src/sdk/workflows/builtin/ralph/claude/index.ts +1 -1
  66. package/src/sdk/workflows/builtin/ralph/copilot/index.ts +1 -1
  67. package/src/sdk/workflows/builtin/ralph/opencode/index.ts +1 -1
  68. package/src/sdk/workflows/builtin-registry.ts +23 -0
  69. package/src/sdk/workflows/index.ts +10 -20
  70. package/src/services/system/auth.test.ts +63 -1
  71. package/.agents/skills/workflow-creator/SKILL.md +0 -334
  72. package/.agents/skills/workflow-creator/references/agent-sessions.md +0 -888
  73. package/.agents/skills/workflow-creator/references/computation-and-validation.md +0 -201
  74. package/.agents/skills/workflow-creator/references/control-flow.md +0 -470
  75. package/.agents/skills/workflow-creator/references/discovery-and-verification.md +0 -232
  76. package/.agents/skills/workflow-creator/references/failure-modes.md +0 -903
  77. package/.agents/skills/workflow-creator/references/getting-started.md +0 -275
  78. package/.agents/skills/workflow-creator/references/running-workflows.md +0 -235
  79. package/.agents/skills/workflow-creator/references/session-config.md +0 -384
  80. package/.agents/skills/workflow-creator/references/state-and-data-flow.md +0 -357
  81. package/.agents/skills/workflow-creator/references/user-input.md +0 -234
  82. package/.agents/skills/workflow-creator/references/workflow-inputs.md +0 -272
  83. package/dist/sdk/runtime/discovery.d.ts +0 -132
  84. package/dist/sdk/runtime/discovery.d.ts.map +0 -1
  85. package/dist/sdk/runtime/executor-entry.d.ts +0 -11
  86. package/dist/sdk/runtime/executor-entry.d.ts.map +0 -1
  87. package/dist/sdk/runtime/loader.d.ts +0 -70
  88. package/dist/sdk/runtime/loader.d.ts.map +0 -1
  89. package/dist/version.d.ts +0 -2
  90. package/dist/version.d.ts.map +0 -1
  91. package/src/commands/cli/workflow.test.ts +0 -317
  92. package/src/sdk/runtime/discovery.ts +0 -368
  93. package/src/sdk/runtime/executor-entry.ts +0 -18
  94. package/src/sdk/runtime/loader.ts +0 -267
@@ -1,18 +0,0 @@
1
- /**
2
- * Orchestrator entry point — invoked inside a tmux pane by the launcher script.
3
- *
4
- * Separated from executor.ts to avoid the dual-module-identity problem:
5
- * Bun evaluates a file twice when it is both the entry point (`bun run`)
6
- * and reached through package.json `exports` self-referencing. Keeping
7
- * the side-effectful `--run` guard here ensures executor.ts stays a pure
8
- * library module that can be safely re-exported from the SDK barrel.
9
- */
10
-
11
- import { runOrchestrator, applyContainerEnvDefaults } from "./executor.ts";
12
-
13
- applyContainerEnvDefaults();
14
-
15
- runOrchestrator().catch((err) => {
16
- console.error("Fatal:", err);
17
- process.exitCode = 1;
18
- });
@@ -1,267 +0,0 @@
1
- /**
2
- * Workflow Loader — multi-stage pipeline for resolving and loading workflows.
3
- *
4
- * Pipeline: Discover → Resolve → Validate → Load
5
- *
6
- * Each stage returns a typed discriminated result so callers get structured
7
- * error information without try/catch guesswork.
8
- *
9
- * Discovery (finding workflow files on disk) remains in `discovery.ts`.
10
- * This module handles everything after a workflow is discovered.
11
- */
12
-
13
- import type { WorkflowDefinition, AgentType } from "../types.ts";
14
- import type { DiscoveredWorkflow } from "./discovery.ts";
15
- import {
16
- errorMessage,
17
- WorkflowNotCompiledError,
18
- InvalidWorkflowError,
19
- IncompatibleSDKError,
20
- } from "../errors.ts";
21
- import { validateCopilotWorkflow } from "../providers/copilot.ts";
22
- import { validateOpenCodeWorkflow } from "../providers/opencode.ts";
23
- import { validateClaudeWorkflow } from "../providers/claude.ts";
24
- import { satisfiesMinVersion } from "./version-compat.ts";
25
- import { VERSION } from "../../version.ts";
26
-
27
- export namespace WorkflowLoader {
28
- // ---------------------------------------------------------------------------
29
- // Result types
30
- // ---------------------------------------------------------------------------
31
-
32
- /** Successful pipeline result. */
33
- export type Ok<T> = { ok: true; value: T };
34
-
35
- /** Failed pipeline result with stage and error context. */
36
- export type StageError<S extends string> = {
37
- ok: false;
38
- stage: S;
39
- error: unknown;
40
- message: string;
41
- };
42
-
43
- export type StageResult<T, S extends string> = Ok<T> | StageError<S>;
44
-
45
- // ---------------------------------------------------------------------------
46
- // Stage data types
47
- // ---------------------------------------------------------------------------
48
-
49
- /** Input to the pipeline — a discovered workflow from disk. */
50
- export type Plan = DiscoveredWorkflow;
51
-
52
- /** Output of the resolve stage. */
53
- export type Resolved = Plan;
54
-
55
- /** Source validation warning — alias of the canonical type from types.ts. */
56
- export type ValidationWarning = import("../types.ts").ValidationWarning;
57
-
58
- /** Output of the validate stage. */
59
- export type Validated = Resolved & {
60
- warnings: ValidationWarning[];
61
- };
62
-
63
- /** Output of the load stage — the final result. */
64
- export type Loaded = Validated & {
65
- definition: WorkflowDefinition;
66
- };
67
-
68
- // ---------------------------------------------------------------------------
69
- // Report callbacks — callers provide these for logging/UI
70
- // ---------------------------------------------------------------------------
71
-
72
- export interface Report {
73
- /** Called when a stage begins. */
74
- start?: (stage: "resolve" | "validate" | "load") => void;
75
- /** Called when source validation produces warnings. */
76
- warn?: (warnings: ValidationWarning[]) => void;
77
- /** Called when a stage fails. */
78
- error?: (stage: "resolve" | "validate" | "load", error: unknown, message: string) => void;
79
- }
80
-
81
- // ---------------------------------------------------------------------------
82
- // Stage 1: Resolve
83
- // ---------------------------------------------------------------------------
84
-
85
- /** Verify the workflow file exists. */
86
- export async function resolve(
87
- plan: Plan,
88
- ): Promise<StageResult<Resolved, "resolve">> {
89
- try {
90
- const file = Bun.file(plan.path);
91
- if (!(await file.exists())) {
92
- return {
93
- ok: false,
94
- stage: "resolve",
95
- error: new Error(`Workflow file not found: ${plan.path}`),
96
- message: `Workflow file not found: ${plan.path}`,
97
- };
98
- }
99
- return { ok: true, value: plan };
100
- } catch (error) {
101
- return {
102
- ok: false,
103
- stage: "resolve",
104
- error,
105
- message: errorMessage(error),
106
- };
107
- }
108
- }
109
-
110
- // ---------------------------------------------------------------------------
111
- // Stage 2: Validate
112
- // ---------------------------------------------------------------------------
113
-
114
- /** Run agent-specific source validation. */
115
- function validateSource(source: string, agent: AgentType): ValidationWarning[] {
116
- switch (agent) {
117
- case "copilot":
118
- return validateCopilotWorkflow(source);
119
- case "opencode":
120
- return validateOpenCodeWorkflow(source);
121
- case "claude":
122
- return validateClaudeWorkflow(source);
123
- default: {
124
- const _exhaustive: never = agent;
125
- return _exhaustive;
126
- }
127
- }
128
- }
129
-
130
- /**
131
- * Read the workflow source and run agent-specific validation checks.
132
- * Validation warnings are non-fatal — the pipeline continues.
133
- */
134
- export async function validate(
135
- resolved: Resolved,
136
- ): Promise<StageResult<Validated, "validate">> {
137
- try {
138
- const source = await Bun.file(resolved.path).text();
139
- const warnings = validateSource(source, resolved.agent);
140
-
141
- return {
142
- ok: true,
143
- value: { ...resolved, warnings },
144
- };
145
- } catch (error) {
146
- return {
147
- ok: false,
148
- stage: "validate",
149
- error,
150
- message: errorMessage(error),
151
- };
152
- }
153
- }
154
-
155
- // ---------------------------------------------------------------------------
156
- // Stage 3: Load
157
- // ---------------------------------------------------------------------------
158
-
159
- /**
160
- * Import the workflow module and extract the WorkflowDefinition.
161
- * Checks for common authoring mistakes (missing `.compile()`, wrong export).
162
- */
163
- export async function load(
164
- validated: Validated,
165
- ): Promise<StageResult<Loaded, "load">> {
166
- try {
167
- const mod = await import(validated.path);
168
- const definition = mod.default ?? mod;
169
-
170
- if (!definition || definition.__brand !== "WorkflowDefinition") {
171
- if (definition && definition.__brand === "WorkflowBuilder") {
172
- const err = new WorkflowNotCompiledError(validated.path);
173
- return {
174
- ok: false,
175
- stage: "load",
176
- error: err,
177
- message: err.message,
178
- };
179
- }
180
-
181
- const err = new InvalidWorkflowError(validated.path);
182
- return {
183
- ok: false,
184
- stage: "load",
185
- error: err,
186
- message: err.message,
187
- };
188
- }
189
-
190
- const def = definition as WorkflowDefinition;
191
-
192
- // Refuse workflows whose declared minSDKVersion is newer than the
193
- // bundled CLI — the workflow author opted in to a version gate
194
- // exactly so the loader could surface a clear upgrade hint
195
- // instead of letting a shape-drift error bubble up at run time.
196
- if (!satisfiesMinVersion(VERSION, def.minSDKVersion)) {
197
- const err = new IncompatibleSDKError(
198
- validated.path,
199
- def.minSDKVersion ?? "",
200
- VERSION,
201
- );
202
- return {
203
- ok: false,
204
- stage: "load",
205
- error: err,
206
- message: err.message,
207
- };
208
- }
209
-
210
- return {
211
- ok: true,
212
- value: { ...validated, definition: def },
213
- };
214
- } catch (error) {
215
- return {
216
- ok: false,
217
- stage: "load",
218
- error,
219
- message: errorMessage(error),
220
- };
221
- }
222
- }
223
-
224
- // ---------------------------------------------------------------------------
225
- // Full pipeline
226
- // ---------------------------------------------------------------------------
227
-
228
- /**
229
- * Run the full pipeline: resolve → validate → load.
230
- *
231
- * Returns a structured result with the loaded WorkflowDefinition on success,
232
- * or a stage-specific error on failure.
233
- */
234
- export async function loadWorkflow(
235
- plan: Plan,
236
- report?: Report,
237
- ): Promise<StageResult<Loaded, "resolve" | "validate" | "load">> {
238
- // Stage 1: Resolve
239
- report?.start?.("resolve");
240
- const resolved = await resolve(plan);
241
- if (!resolved.ok) {
242
- report?.error?.("resolve", resolved.error, resolved.message);
243
- return resolved;
244
- }
245
-
246
- // Stage 2: Validate
247
- report?.start?.("validate");
248
- const validated = await validate(resolved.value);
249
- if (!validated.ok) {
250
- report?.error?.("validate", validated.error, validated.message);
251
- return validated;
252
- }
253
- if (validated.value.warnings.length > 0) {
254
- report?.warn?.(validated.value.warnings);
255
- }
256
-
257
- // Stage 3: Load
258
- report?.start?.("load");
259
- const loaded = await load(validated.value);
260
- if (!loaded.ok) {
261
- report?.error?.("load", loaded.error, loaded.message);
262
- return loaded;
263
- }
264
-
265
- return loaded;
266
- }
267
- }