@bastani/atomic 0.5.34 → 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.
- package/README.md +329 -50
- package/dist/commands/cli/session.d.ts +67 -0
- package/dist/commands/cli/session.d.ts.map +1 -0
- package/dist/commands/cli/workflow-status.d.ts +63 -0
- package/dist/commands/cli/workflow-status.d.ts.map +1 -0
- package/dist/sdk/commander.d.ts +74 -0
- package/dist/sdk/commander.d.ts.map +1 -0
- package/dist/sdk/components/workflow-picker-panel.d.ts +14 -17
- package/dist/sdk/components/workflow-picker-panel.d.ts.map +1 -1
- package/dist/sdk/define-workflow.d.ts +18 -9
- package/dist/sdk/define-workflow.d.ts.map +1 -1
- package/dist/sdk/index.d.ts +4 -3
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/management-commands.d.ts +42 -0
- package/dist/sdk/management-commands.d.ts.map +1 -0
- package/dist/sdk/registry.d.ts +27 -0
- package/dist/sdk/registry.d.ts.map +1 -0
- package/dist/sdk/runtime/attached-footer.d.ts +1 -1
- package/dist/sdk/runtime/executor-env.d.ts +20 -0
- package/dist/sdk/runtime/executor-env.d.ts.map +1 -0
- package/dist/sdk/runtime/executor.d.ts +61 -10
- package/dist/sdk/runtime/executor.d.ts.map +1 -1
- package/dist/sdk/types.d.ts +147 -4
- package/dist/sdk/types.d.ts.map +1 -1
- package/dist/sdk/worker-shared.d.ts +42 -0
- package/dist/sdk/worker-shared.d.ts.map +1 -0
- package/dist/sdk/workflow-cli.d.ts +103 -0
- package/dist/sdk/workflow-cli.d.ts.map +1 -0
- package/dist/sdk/workflows/builtin-registry.d.ts +113 -0
- package/dist/sdk/workflows/builtin-registry.d.ts.map +1 -0
- package/dist/sdk/workflows/index.d.ts +5 -5
- package/dist/sdk/workflows/index.d.ts.map +1 -1
- package/package.json +12 -8
- package/src/cli.ts +85 -144
- package/src/commands/cli/chat/index.ts +10 -0
- package/src/commands/cli/workflow-command.test.ts +279 -938
- package/src/commands/cli/workflow-inputs.test.ts +41 -11
- package/src/commands/cli/workflow-inputs.ts +47 -12
- package/src/commands/cli/workflow-list.test.ts +234 -0
- package/src/commands/cli/workflow-list.ts +0 -0
- package/src/commands/cli/workflow.ts +11 -798
- package/src/scripts/constants.ts +2 -1
- package/src/sdk/commander.ts +161 -0
- package/src/sdk/components/workflow-picker-panel.tsx +78 -258
- package/src/sdk/define-workflow.test.ts +104 -11
- package/src/sdk/define-workflow.ts +47 -11
- package/src/sdk/errors.test.ts +16 -0
- package/src/sdk/index.ts +8 -8
- package/src/sdk/management-commands.ts +151 -0
- package/src/sdk/registry.ts +132 -0
- package/src/sdk/runtime/attached-footer.ts +1 -1
- package/src/sdk/runtime/executor-env.ts +45 -0
- package/src/sdk/runtime/executor.test.ts +37 -0
- package/src/sdk/runtime/executor.ts +147 -68
- package/src/sdk/types.ts +169 -4
- package/src/sdk/worker-shared.test.ts +163 -0
- package/src/sdk/worker-shared.ts +155 -0
- package/src/sdk/workflow-cli.ts +409 -0
- package/src/sdk/workflows/builtin/deep-research-codebase/claude/index.ts +1 -1
- package/src/sdk/workflows/builtin/deep-research-codebase/copilot/index.ts +1 -1
- package/src/sdk/workflows/builtin/deep-research-codebase/opencode/index.ts +1 -1
- package/src/sdk/workflows/builtin/open-claude-design/claude/index.ts +1 -1
- package/src/sdk/workflows/builtin/open-claude-design/copilot/index.ts +1 -1
- package/src/sdk/workflows/builtin/open-claude-design/opencode/index.ts +1 -1
- package/src/sdk/workflows/builtin/ralph/claude/index.ts +1 -1
- package/src/sdk/workflows/builtin/ralph/copilot/index.ts +1 -1
- package/src/sdk/workflows/builtin/ralph/opencode/index.ts +1 -1
- package/src/sdk/workflows/builtin-registry.ts +23 -0
- package/src/sdk/workflows/index.ts +10 -20
- package/src/services/system/auth.test.ts +63 -1
- package/.agents/skills/workflow-creator/SKILL.md +0 -334
- package/.agents/skills/workflow-creator/references/agent-sessions.md +0 -888
- package/.agents/skills/workflow-creator/references/computation-and-validation.md +0 -201
- package/.agents/skills/workflow-creator/references/control-flow.md +0 -470
- package/.agents/skills/workflow-creator/references/discovery-and-verification.md +0 -232
- package/.agents/skills/workflow-creator/references/failure-modes.md +0 -903
- package/.agents/skills/workflow-creator/references/getting-started.md +0 -275
- package/.agents/skills/workflow-creator/references/running-workflows.md +0 -235
- package/.agents/skills/workflow-creator/references/session-config.md +0 -384
- package/.agents/skills/workflow-creator/references/state-and-data-flow.md +0 -357
- package/.agents/skills/workflow-creator/references/user-input.md +0 -234
- package/.agents/skills/workflow-creator/references/workflow-inputs.md +0 -272
- package/dist/sdk/runtime/discovery.d.ts +0 -132
- package/dist/sdk/runtime/discovery.d.ts.map +0 -1
- package/dist/sdk/runtime/executor-entry.d.ts +0 -11
- package/dist/sdk/runtime/executor-entry.d.ts.map +0 -1
- package/dist/sdk/runtime/loader.d.ts +0 -70
- package/dist/sdk/runtime/loader.d.ts.map +0 -1
- package/dist/version.d.ts +0 -2
- package/dist/version.d.ts.map +0 -1
- package/src/commands/cli/workflow.test.ts +0 -317
- package/src/sdk/runtime/discovery.ts +0 -368
- package/src/sdk/runtime/executor-entry.ts +0 -18
- package/src/sdk/runtime/loader.ts +0 -267
package/src/scripts/constants.ts
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
* change propagates everywhere.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { AGENTS } from "../sdk/workflows/index.ts";
|
|
9
8
|
import type { AgentType } from "../sdk/workflows/index.ts";
|
|
10
9
|
|
|
10
|
+
const AGENTS: AgentType[] = ["copilot", "opencode", "claude"];
|
|
11
|
+
|
|
11
12
|
export {
|
|
12
13
|
SDK_PACKAGE_NAME,
|
|
13
14
|
VERSION_FILES,
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commander adapter for embedding a WorkflowCli under a parent Commander CLI.
|
|
3
|
+
*
|
|
4
|
+
* ```ts
|
|
5
|
+
* import { createWorkflowCli } from "@bastani/atomic/workflows";
|
|
6
|
+
* import { toCommand, runCli } from "@bastani/atomic/workflows/commander";
|
|
7
|
+
*
|
|
8
|
+
* const cli = createWorkflowCli(workflow);
|
|
9
|
+
* const program = new Command("my-app");
|
|
10
|
+
* program.addCommand(toCommand(cli, "workflow"));
|
|
11
|
+
*
|
|
12
|
+
* await runCli(cli, () => program.parseAsync());
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* `WorkflowCli` itself is framework-agnostic — this module is the only place
|
|
16
|
+
* that imports Commander on the adapter side of the API. A future
|
|
17
|
+
* yargs/citty adapter would be a sibling module with the same shape.
|
|
18
|
+
*
|
|
19
|
+
* `runCli` handles orchestrator re-entry transparently — parent CLIs never
|
|
20
|
+
* see env vars or guards. PyTorch-distributed style: the framework owns
|
|
21
|
+
* rank-zero dispatch; the developer writes one line.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import type { Command } from "@commander-js/extra-typings";
|
|
25
|
+
import type {
|
|
26
|
+
AgentType,
|
|
27
|
+
WorkflowCli,
|
|
28
|
+
WorkflowDefinition,
|
|
29
|
+
} from "./types.ts";
|
|
30
|
+
import {
|
|
31
|
+
buildCliCommand,
|
|
32
|
+
resolveAndStart,
|
|
33
|
+
runPicker,
|
|
34
|
+
} from "./workflow-cli.ts";
|
|
35
|
+
import { buildInputUnion } from "./worker-shared.ts";
|
|
36
|
+
import { runOrchestrator } from "./runtime/executor.ts";
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Build a Commander `Command` bound to a WorkflowCli for embedding under
|
|
40
|
+
* a parent CLI. The returned Command declares `-n/--name`, `-a/--agent`,
|
|
41
|
+
* `-d/--detach`, plus the per-input union across the registry. Picker
|
|
42
|
+
* behaviour (agent without name in a TTY) is preserved.
|
|
43
|
+
*
|
|
44
|
+
* @param cli - WorkflowCli returned by `createWorkflowCli()`.
|
|
45
|
+
* @param name - Mount name (default: `"workflow"`).
|
|
46
|
+
*/
|
|
47
|
+
export function toCommand<T extends Record<string, WorkflowDefinition>>(
|
|
48
|
+
cli: WorkflowCli<T>,
|
|
49
|
+
name?: string,
|
|
50
|
+
): Command {
|
|
51
|
+
const registry = cli.registry;
|
|
52
|
+
const entry = cli.entry;
|
|
53
|
+
const defaultInputs = cli.defaults;
|
|
54
|
+
|
|
55
|
+
const unionInputs = buildInputUnion(registry.list());
|
|
56
|
+
|
|
57
|
+
let cmd!: Command;
|
|
58
|
+
cmd = buildCliCommand(
|
|
59
|
+
registry,
|
|
60
|
+
unionInputs,
|
|
61
|
+
async (params) => {
|
|
62
|
+
const { name: parsedName, agent: parsedAgent, cliInputs, detach } = params;
|
|
63
|
+
|
|
64
|
+
// Interactive picker: agent given, name omitted, running in a TTY.
|
|
65
|
+
if (!parsedName && parsedAgent && process.stdout.isTTY) {
|
|
66
|
+
await runPicker(registry, parsedAgent, detach, entry, defaultInputs);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (!parsedName || !parsedAgent) {
|
|
71
|
+
// Commander's `help()` calls `process.exit()` and is typed `never`.
|
|
72
|
+
cmd.help();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
await resolveAndStart(
|
|
76
|
+
registry,
|
|
77
|
+
parsedName,
|
|
78
|
+
parsedAgent as AgentType,
|
|
79
|
+
{
|
|
80
|
+
cliInputs,
|
|
81
|
+
dispatcherInputs: defaultInputs,
|
|
82
|
+
detach,
|
|
83
|
+
entry,
|
|
84
|
+
},
|
|
85
|
+
);
|
|
86
|
+
},
|
|
87
|
+
name ?? "workflow",
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
return cmd;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// ─── runCli — embed bootstrap ──────────────────────────────────────────────
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Bootstrap an embedded Commander CLI. Use this in place of
|
|
97
|
+
* `program.parseAsync()` when you've mounted an atomic WorkflowCli under
|
|
98
|
+
* a parent program.
|
|
99
|
+
*
|
|
100
|
+
* Inspired by PyTorch's `init_process_group()`: the framework handles
|
|
101
|
+
* rank-zero dispatch (here: orchestrator vs CLI) transparently, so the
|
|
102
|
+
* developer writes the same code whether this process is a fresh CLI
|
|
103
|
+
* invocation or a tmux-spawned orchestrator re-exec.
|
|
104
|
+
*
|
|
105
|
+
* - On a fresh invocation, invokes `cliFn()` (your `program.parseAsync()`
|
|
106
|
+
* call, plus any bootstrap you want before it).
|
|
107
|
+
* - When the process is a detached orchestrator re-exec
|
|
108
|
+
* (`ATOMIC_ORCHESTRATOR_MODE=1` is set by the runtime), resolves the
|
|
109
|
+
* workflow identified by `ATOMIC_WF_KEY` against the supplied CLI
|
|
110
|
+
* (or the first match across CLIs) and drives it via
|
|
111
|
+
* `runOrchestrator`. `cliFn` is not called.
|
|
112
|
+
*
|
|
113
|
+
* Accepts a single WorkflowCli or an array — use an array when your
|
|
114
|
+
* parent CLI embeds multiple atomic WorkflowClis (rare, but supported).
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* const program = new Command("my-app");
|
|
119
|
+
* program.addCommand(toCommand(cli));
|
|
120
|
+
*
|
|
121
|
+
* await runCli(cli, () => program.parseAsync());
|
|
122
|
+
* ```
|
|
123
|
+
*
|
|
124
|
+
* @example With pre-parse bootstrap:
|
|
125
|
+
* ```ts
|
|
126
|
+
* await runCli(builtinCli, async () => {
|
|
127
|
+
* await ensureGlobalAtomicSettings();
|
|
128
|
+
* await autoSyncIfStale();
|
|
129
|
+
* await program.parseAsync();
|
|
130
|
+
* });
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
export async function runCli(
|
|
134
|
+
target: WorkflowCli | ReadonlyArray<WorkflowCli>,
|
|
135
|
+
cliFn: () => void | Promise<void>,
|
|
136
|
+
): Promise<void> {
|
|
137
|
+
if (process.env.ATOMIC_ORCHESTRATOR_MODE === "1") {
|
|
138
|
+
const key = process.env.ATOMIC_WF_KEY ?? "";
|
|
139
|
+
const slashIdx = key.indexOf("/");
|
|
140
|
+
if (slashIdx < 0) {
|
|
141
|
+
throw new Error(
|
|
142
|
+
`ATOMIC_ORCHESTRATOR_MODE=1 but ATOMIC_WF_KEY "${key}" is malformed — expected "<agent>/<name>"`,
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
const agent = key.slice(0, slashIdx) as AgentType;
|
|
146
|
+
const name = key.slice(slashIdx + 1);
|
|
147
|
+
|
|
148
|
+
const clis = Array.isArray(target) ? target : [target];
|
|
149
|
+
for (const cli of clis) {
|
|
150
|
+
const def = cli.registry.resolve(name, agent);
|
|
151
|
+
if (def) {
|
|
152
|
+
await runOrchestrator(def);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
throw new Error(`ATOMIC_WF_KEY "${key}" not found in any provided WorkflowCli`);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
await cliFn();
|
|
161
|
+
}
|