@bastani/atomic 0.8.24-alpha.1 โ 0.8.24-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 +17 -0
- package/README.md +2 -1
- package/dist/builtin/intercom/CHANGELOG.md +12 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/CHANGELOG.md +12 -0
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +16 -0
- package/dist/builtin/subagents/README.md +132 -21
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/prompts/parallel-context-build.md +4 -2
- package/dist/builtin/subagents/prompts/parallel-handoff-plan.md +3 -1
- package/dist/builtin/subagents/skills/subagent/SKILL.md +49 -11
- package/dist/builtin/subagents/src/agents/agent-management.ts +79 -16
- package/dist/builtin/subagents/src/agents/agents.ts +47 -16
- package/dist/builtin/subagents/src/agents/chain-serializer.ts +114 -0
- package/dist/builtin/subagents/src/extension/schemas.ts +139 -3
- package/dist/builtin/subagents/src/runs/background/async-execution.ts +92 -6
- package/dist/builtin/subagents/src/runs/background/async-status.ts +11 -1
- package/dist/builtin/subagents/src/runs/background/run-status.ts +4 -1
- package/dist/builtin/subagents/src/runs/background/subagent-runner.ts +529 -32
- package/dist/builtin/subagents/src/runs/foreground/chain-execution.ts +361 -118
- package/dist/builtin/subagents/src/runs/foreground/execution.ts +75 -7
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +33 -0
- package/dist/builtin/subagents/src/runs/shared/acceptance.ts +611 -0
- package/dist/builtin/subagents/src/runs/shared/chain-outputs.ts +101 -0
- package/dist/builtin/subagents/src/runs/shared/dynamic-fanout.ts +293 -0
- package/dist/builtin/subagents/src/runs/shared/parallel-utils.ts +29 -1
- package/dist/builtin/subagents/src/runs/shared/pi-args.ts +11 -0
- package/dist/builtin/subagents/src/runs/shared/structured-output.ts +79 -0
- package/dist/builtin/subagents/src/runs/shared/subagent-prompt-runtime.ts +52 -2
- package/dist/builtin/subagents/src/runs/shared/workflow-graph.ts +206 -0
- package/dist/builtin/subagents/src/shared/formatters.ts +2 -2
- package/dist/builtin/subagents/src/shared/settings.ts +53 -4
- package/dist/builtin/subagents/src/shared/types.ts +226 -0
- package/dist/builtin/subagents/src/shared/utils.ts +2 -1
- package/dist/builtin/subagents/src/slash/slash-commands.ts +41 -3
- package/dist/builtin/subagents/src/tui/render.ts +152 -34
- package/dist/builtin/web-access/CHANGELOG.md +12 -0
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +16 -0
- package/dist/builtin/workflows/ambient.d.ts +36 -0
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/skills/create-spec/SKILL.md +1 -1
- package/dist/builtin/workflows/src/authoring.d.ts +197 -0
- package/dist/builtin/workflows/src/runs/shared/model-fallback.ts +11 -1
- package/dist/builtin/workflows/src/shared/authoring-contract.d.ts +523 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +0 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +1 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +4 -3
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +1 -1
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/docs/packages.md +2 -2
- package/docs/usage.md +1 -0
- package/docs/workflows.md +198 -2
- package/package.json +20 -1
- package/dist/builtin/workflows/src/authoring.ts +0 -410
- package/dist/builtin/workflows/src/shared/authoring-contract.ts +0 -660
package/docs/packages.md
CHANGED
|
@@ -166,7 +166,7 @@ If no app manifest (`atomic`, or legacy `pi`) is present, Atomic auto-discovers
|
|
|
166
166
|
- `skills/` recursively finds `SKILL.md` folders and loads top-level `.md` files as skills
|
|
167
167
|
- `prompts/` loads `.md` files
|
|
168
168
|
- `themes/` loads `.json` files
|
|
169
|
-
- `workflows/` loads workflow SDK files (`.ts`, `.js`, `.mjs`, `.cjs`); `workflow/` is also accepted as a singular alias. Workflow files should `import { defineWorkflow, Type } from "@bastani/workflows"` and export `defineWorkflow(...).compile()` output. TypeScript package authors do not need a
|
|
169
|
+
- `workflows/` loads workflow SDK files (`.ts`, `.js`, `.mjs`, `.cjs`); `workflow/` is also accepted as a singular alias. Workflow files should `import { defineWorkflow, Type } from "@bastani/workflows"` and export `defineWorkflow(...).compile()` output. TypeScript package authors do not need a hand-authored `.d.ts`, a `declare module` shim, or a `tsconfig` `paths` alias for the SDK import โ the SDK types ship with `@bastani/atomic`. A package that also imports `@bastani/atomic` picks them up automatically; a pure workflow-only package adds one opt-in line (`compilerOptions.types: ["@bastani/atomic/workflows/ambient"]` or a `/// <reference types="@bastani/atomic/workflows/ambient" />` directive). See the workflow SDK typing guidance under Programmatic Usage in the workflows guide.
|
|
170
170
|
|
|
171
171
|
When a package manifest exists, declared resource arrays normally define what loads. Workflows are the exception: if `atomic.workflows` / legacy `pi.workflows` is omitted, Atomic still checks conventional `workflows/` and `workflow/` directories.
|
|
172
172
|
|
|
@@ -176,7 +176,7 @@ Third-party runtime dependencies belong in `dependencies` in `package.json`. Dep
|
|
|
176
176
|
|
|
177
177
|
Atomic bundles core packages for extensions and skills. If you import any of these, list them in `peerDependencies` with a `"*"` range and do not bundle them: `@earendil-works/pi-ai`, `@earendil-works/pi-agent-core`, `@bastani/atomic`, `@earendil-works/pi-tui`, `typebox`.
|
|
178
178
|
|
|
179
|
-
Workflow packages should author workflow files with `import { defineWorkflow, Type } from "@bastani/workflows"` and export definitions produced by `defineWorkflow(...).compile()`. Do not use the removed `runWorkflow` object-form API, and do not hand-roll objects with `__piWorkflow: true`; discovery accepts only compiled definitions.
|
|
179
|
+
Workflow packages should author workflow files with `import { defineWorkflow, Type } from "@bastani/workflows"` and export definitions produced by `defineWorkflow(...).compile()`. Do not use the removed `runWorkflow` object-form API, and do not hand-roll objects with `__piWorkflow: true`; discovery accepts only compiled definitions. `@bastani/workflows` is not a separate npm package: its types resolve through `@bastani/atomic`, so list `@bastani/atomic` and `typebox` in `peerDependencies` (the workflow SDK's emitted types reference `typebox`). A pure workflow-only package also adds the one-line ambient opt-in noted above; a package that imports `@bastani/atomic` elsewhere picks the types up automatically.
|
|
180
180
|
|
|
181
181
|
Other Atomic packages must be bundled in your tarball. Add them to `dependencies` and `bundledDependencies`, then reference their resources through `node_modules/` paths. Atomic loads packages with separate module roots, so separate installs do not collide or share modules.
|
|
182
182
|
|
package/docs/usage.md
CHANGED
|
@@ -55,6 +55,7 @@ Type `/` in the editor to open command completion. Extensions can register custo
|
|
|
55
55
|
| `/reload` | Reload keybindings, extensions, skills, prompts, and context files |
|
|
56
56
|
| `/hotkeys` | Show all keyboard shortcuts |
|
|
57
57
|
| `/changelog` | Display version history |
|
|
58
|
+
| `/exit` | Exit Atomic |
|
|
58
59
|
| `/quit` | Quit Atomic |
|
|
59
60
|
|
|
60
61
|
## Message Queue
|
package/docs/workflows.md
CHANGED
|
@@ -30,6 +30,7 @@ Use a workflow when a task should be repeatable, inspectable, resumable, or spli
|
|
|
30
30
|
- [Quick Start](#quick-start)
|
|
31
31
|
- [Built-in Workflows](#built-in-workflows)
|
|
32
32
|
- [When to Use Workflows](#when-to-use-workflows)
|
|
33
|
+
- [Workflow Starter Patterns](#workflow-starter-patterns)
|
|
33
34
|
- [Atomic vs Claude Code Dynamic Workflows](#atomic-vs-claude-code-dynamic-workflows)
|
|
34
35
|
- [Workflow Locations](#workflow-locations)
|
|
35
36
|
- [Workflow Configuration](#workflow-configuration)
|
|
@@ -382,6 +383,177 @@ If the task is only deterministic TypeScript with no LLM/session stage, use a sc
|
|
|
382
383
|
| Track one-off work without saving a workflow file | direct `workflow({ task })`, `workflow({ tasks })`, or `workflow({ chain })` calls |
|
|
383
384
|
| Make a workflow robust | design the stage graph, context handoffs, artifacts, validation gates, model fallbacks, and human approval points before coding |
|
|
384
385
|
|
|
386
|
+
## Workflow Starter Patterns
|
|
387
|
+
|
|
388
|
+
When a workflow is larger than a single tracked task, start by choosing a small control-flow pattern before writing prompts. Naming the pattern keeps the stage graph understandable, makes validation gates explicit, and helps reviewers see why work is split across model sessions.
|
|
389
|
+
|
|
390
|
+
These patterns are composable. For example, a migration workflow might use **fan-out-and-synthesize** to fix many call sites, then **adversarial verification** to review each patch, and finally **loop until done** while tests still fail.
|
|
391
|
+
|
|
392
|
+
| Pattern | Use it when | Atomic shape |
|
|
393
|
+
|---|---|---|
|
|
394
|
+
| **Classify-and-act** | Inputs arrive in different categories and each category needs a different path, model, tool set, or output format. | `ctx.task("classify")` โ deterministic branch โ category-specific `ctx.task`, `ctx.chain`, `ctx.parallel`, or child `ctx.workflow(...)`. |
|
|
395
|
+
| **Fan-out-and-synthesize** | The task can be split into many independent slices that benefit from clean context windows. | `ctx.parallel([...])` with separate artifacts โ synthesis barrier that reads the artifacts and merges the answer. |
|
|
396
|
+
| **Adversarial verification** | Outputs need independent checking against a rubric, security rule, factual source, or acceptance contract. | Worker stage(s) โ fresh-context verifier stage(s) โ reducer that accepts, rejects, or asks for repair. |
|
|
397
|
+
| **Generate-and-filter** | You need many candidate ideas, plans, names, fixes, or hypotheses before selecting the best few. | Generator fan-out โ dedupe/filter stage โ optional verifier/judge โ final shortlist. |
|
|
398
|
+
| **Tournament** | The whole task is subjective or approach-sensitive, and comparative judgment is more reliable than absolute scoring. | Several agents attempt the same task โ pairwise judges compare results โ bracket reducer returns winners. |
|
|
399
|
+
| **Loop until done** | The amount of work is unknown up front, such as finding all failures, mining repeated issues, or iterating until checks pass. | Bounded loop with an explicit stop condition, progress ledger, per-iteration artifacts, and a max-iteration escape hatch. |
|
|
400
|
+
|
|
401
|
+
### Pattern diagrams
|
|
402
|
+
|
|
403
|
+
#### 1. Classify-and-act
|
|
404
|
+
|
|
405
|
+
```text
|
|
406
|
+
โโ 1 Classify-and-act โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
407
|
+
โ โ
|
|
408
|
+
โ โโโโโโโโโ โ
|
|
409
|
+
โ โญโโโธโagent Aโ โ
|
|
410
|
+
โ โ โโโโโโโโโ โ
|
|
411
|
+
โ โโโโโโ โโโโโโโโโโโโ โ โโโโโโโโโ โ
|
|
412
|
+
โ โtaskโโโธโclassifierโโโโโผโโโธโagent Bโ โ chosen โ
|
|
413
|
+
โ โโโโโโ โโโโโโโโโโโโ โ โโโโโโโโโ โ
|
|
414
|
+
โ โ โโโโโโโโโ โ
|
|
415
|
+
โ โฐโโโธโagent Cโ โ
|
|
416
|
+
โ โโโโโโโโโ โ
|
|
417
|
+
โ โ
|
|
418
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
Best practices:
|
|
422
|
+
- Make the classifier return a structured category and confidence, not free-form prose.
|
|
423
|
+
- Keep each action branch isolated with the minimum tools and context it needs.
|
|
424
|
+
- Add a fallback or human-input branch for low-confidence classifications.
|
|
425
|
+
|
|
426
|
+
#### 2. Fan-out-and-synthesize
|
|
427
|
+
|
|
428
|
+
```text
|
|
429
|
+
โโ 2 Fan-out-and-synthesize โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
430
|
+
โ โ
|
|
431
|
+
โ โโโโโโโโโ โ
|
|
432
|
+
โ โญโธโagent 1โโโโฎ โ
|
|
433
|
+
โ โ โโโโโโโโโ โ โ
|
|
434
|
+
โ โ โโโโโโโโโ โ โ
|
|
435
|
+
โ โโธโagent 2โโโโค โ
|
|
436
|
+
โ โโโโโโ โ โโโโโโโโโ โ โโโโโโโโโ โโโโโโโโโโโโ โ
|
|
437
|
+
โ โtaskโโโโค โโโโโโโโโ โโธโbarrierโโโธโsynthesizeโ โ
|
|
438
|
+
โ โโโโโโ โโธโagent 3โโโโค โโโโโโโโโ โโโโโโโโโโโโ โ
|
|
439
|
+
โ โ โโโโโโโโโ โ โ
|
|
440
|
+
โ โ โโโโโโโโโ โ โ
|
|
441
|
+
โ โฐโธโagent 4โโโโฏ โ
|
|
442
|
+
โ โโโโโโโโโ โ
|
|
443
|
+
โ โ
|
|
444
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
Best practices:
|
|
448
|
+
- Partition by files, sources, claims, candidates, or work items that can be evaluated independently.
|
|
449
|
+
- Save each branch to a separate artifact and pass paths with `reads` instead of inlining all branch output.
|
|
450
|
+
- Treat synthesis as a barrier: it waits for every branch, deduplicates, resolves conflicts, and cites evidence.
|
|
451
|
+
|
|
452
|
+
#### 3. Adversarial verification
|
|
453
|
+
|
|
454
|
+
```text
|
|
455
|
+
โโ 3 Adversarial verification โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
456
|
+
โ โ
|
|
457
|
+
โ โ
|
|
458
|
+
โ โโโโโโโโโโโโ โ
|
|
459
|
+
โ โโโโโโโโโโโโโโโโโโธโverifier Aโ โ
|
|
460
|
+
โ โ โโโโโโโโโโโโ โ
|
|
461
|
+
โ โโโโโโโโ โ โโโโโโโโโโโโ โ
|
|
462
|
+
โ โworkerโโโโโโโผโโโโโโโโโโโโโโโโโธโverifier Bโ โ
|
|
463
|
+
โ โโโโโโโโ โ โโโโโโโโโโโโ โ
|
|
464
|
+
โ โ โโโโโโโโโโโโ โ
|
|
465
|
+
โ โโโโโโโโโโโโโโโโโโธโverifier Cโ โ
|
|
466
|
+
โ โโโโโโโโโโโโ โ
|
|
467
|
+
โ โ
|
|
468
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
Best practices:
|
|
472
|
+
- Give verifiers fresh context and a concrete rubric with pass/fail evidence requirements.
|
|
473
|
+
- Separate production from judgment to reduce self-preferential bias.
|
|
474
|
+
- Ask verifiers to find blockers, not to rewrite the candidate unless repair is explicitly their role.
|
|
475
|
+
|
|
476
|
+
#### 4. Generate-and-filter
|
|
477
|
+
|
|
478
|
+
```text
|
|
479
|
+
โโ 4 Generate-and-filter โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
480
|
+
โ โ
|
|
481
|
+
โ โ
|
|
482
|
+
โ โโโโโโโ โโโโโโ โโโโโโ โ
|
|
483
|
+
โ โgen Aโโโโธโideaโโโโโฎ โญโโโธโbestโ โ
|
|
484
|
+
โ โโโโโโโ โโโโโโ โ โ โโโโโโ โ
|
|
485
|
+
โ โโโโโโโ โโโโโโ โ โโโโโโโโ โ โโโโโโ โ
|
|
486
|
+
โ โgen Bโโโโธโideaโโโโโผโโธโfilterโโโโโโผโโโธโbestโ โ
|
|
487
|
+
โ โโโโโโโ โโโโโโ โ โโโโโโโโ โ โโโโโโ โ
|
|
488
|
+
โ โโโโโโโ โโโโโโ โ โ โโโโโโโโโโโ โ
|
|
489
|
+
โ โgen Cโโโโธโideaโโโโโฏ โฐโโโธโdiscardedโ โ
|
|
490
|
+
โ โโโโโโโ โโโโโโ โโโโโโโโโโโ โ
|
|
491
|
+
โ โ
|
|
492
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
Best practices:
|
|
496
|
+
- Generate more candidates than you need, then filter hard by an explicit rubric.
|
|
497
|
+
- Dedupe before judging so near-identical candidates do not dominate the shortlist.
|
|
498
|
+
- Use this for exploration, naming, design options, hypotheses, and lightweight eval ideas.
|
|
499
|
+
|
|
500
|
+
#### 5. Tournament
|
|
501
|
+
|
|
502
|
+
```text
|
|
503
|
+
โโ 5 Tournament โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
504
|
+
โ โ
|
|
505
|
+
โ โโโโโโโโโโโ โ
|
|
506
|
+
โ โattempt Aโโโโฎ โโโโโโโโโ โ
|
|
507
|
+
โ โโโโโโโโโโโ โโโธโjudge 1โโโโโฎ โ
|
|
508
|
+
โ โโโโโโโโโโโ โ โโโโโโโโโ โ โ
|
|
509
|
+
โ โattempt Bโโโโฏ โ โโโโโโโ โโโโโโโโ โ
|
|
510
|
+
โ โโโโโโโโโโโ โโโโธโfinalโโโธโwinnerโ โ
|
|
511
|
+
โ โโโโโโโโโโโ โ โโโโโโโ โโโโโโโโ โ
|
|
512
|
+
โ โattempt Cโโโโฎ โโโโโโโโโ โ โ
|
|
513
|
+
โ โโโโโโโโโโโ โโโธโjudge 2โโโโโฏ โ
|
|
514
|
+
โ โโโโโโโโโโโ โ โโโโโโโโโ โ
|
|
515
|
+
โ โattempt Dโโโโฏ โ
|
|
516
|
+
โ โโโโโโโโโโโ โ
|
|
517
|
+
โ โ
|
|
518
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
Best practices:
|
|
522
|
+
- Use pairwise comparison when absolute scores are noisy or subjective.
|
|
523
|
+
- Randomize or balance presentation order where possible to reduce order bias.
|
|
524
|
+
- Keep the judge rubric short and require rationale tied to observable criteria.
|
|
525
|
+
|
|
526
|
+
#### 6. Loop until done
|
|
527
|
+
|
|
528
|
+
```text
|
|
529
|
+
โโ 6 Loop until done โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
530
|
+
โ โ
|
|
531
|
+
โ yes, spawn another โ
|
|
532
|
+
โ โญโโโโโโโโโโโโโโโโโฎ โ
|
|
533
|
+
โ โพ โ โ
|
|
534
|
+
โ โโโโโโโ โโโโโโโโโโโโโโโ no โโโโโโ โ
|
|
535
|
+
โ โagentโโโโโโโธโnew findings?โโโโโโโโธโdoneโ โ
|
|
536
|
+
โ โโโโโโโ โโโโโโโโโโโโโโโ โโโโโโ โ
|
|
537
|
+
โ โ
|
|
538
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
Best practices:
|
|
542
|
+
- Define both success and escape conditions before the loop starts.
|
|
543
|
+
- Keep a durable ledger of attempted work, findings, failures, and validation evidence.
|
|
544
|
+
- Bound loops by iterations, budget, or convergence criteria so they fail inspectably instead of drifting.
|
|
545
|
+
|
|
546
|
+
### Choosing a starter pattern
|
|
547
|
+
|
|
548
|
+
- Pick **classify-and-act** when routing correctness matters more than breadth.
|
|
549
|
+
- Pick **fan-out-and-synthesize** when the work divides cleanly into independent slices.
|
|
550
|
+
- Pick **adversarial verification** when the main risk is a plausible but wrong answer.
|
|
551
|
+
- Pick **generate-and-filter** when the output quality depends on exploring a large option space.
|
|
552
|
+
- Pick **tournament** when multiple whole-solution strategies should compete under one rubric.
|
|
553
|
+
- Pick **loop until done** when the workflow should continue until evidence says it is finished, not until a preselected number of stages completes.
|
|
554
|
+
|
|
555
|
+
Record the selected pattern in your spec or workflow README, then adapt the diagram to the actual stage graph. If the final design does not resemble any starter pattern, explain why in the workflow's design notes.
|
|
556
|
+
|
|
385
557
|
## Atomic vs Claude Code Dynamic Workflows
|
|
386
558
|
|
|
387
559
|
Claude Code Dynamic Workflows and Atomic are trying to solve a similar class of problem: important software engineering work is too large for one agent pass, so the system should split the job into stages, run agents in parallel, verify the result, and keep enough state to finish long-running work.
|
|
@@ -845,7 +1017,7 @@ Author workflows to create at least one tracked stage by calling `ctx.task()`, `
|
|
|
845
1017
|
|
|
846
1018
|
### Inputs
|
|
847
1019
|
|
|
848
|
-
Inputs are declared with TypeBox `Type.*` schemas passed to `.input(key, schema)`. `Type` is re-exported from `@bastani/workflows` (along with the `Static` and `TSchema` type helpers), so you
|
|
1020
|
+
Inputs are declared with TypeBox `Type.*` schemas passed to `.input(key, schema)`. `Type` is re-exported from `@bastani/workflows` (along with the `Static` and `TSchema` type helpers), so you do not import from `typebox` directly in workflow files. Workflow packages still declare `typebox` as a peer dependency so the SDK's shipped types resolve under `tsc` โ see [Programmatic Usage](#programmatic-usage). Common input schemas map to picker kinds and accepted runtime values:
|
|
849
1021
|
|
|
850
1022
|
| TypeBox schema | Picker kind | Accepted runtime value |
|
|
851
1023
|
|---|---|---|
|
|
@@ -1241,7 +1413,7 @@ This applies everywhere a stage accepts a model: direct `ctx.task`/`ctx.chain`/`
|
|
|
1241
1413
|
- the `workflow` tool for agent-initiated orchestration and direct one-off runs
|
|
1242
1414
|
Workflow definition files must export definitions produced by `defineWorkflow(...).compile()`. The former imperative object-form runner is not part of the public SDK, and authored workflow files cannot import `runWorkflow` from `@bastani/workflows`.
|
|
1243
1415
|
|
|
1244
|
-
Standalone TypeScript workflow packages
|
|
1416
|
+
Standalone TypeScript workflow packages type-check the SDK import with no hand-authored `.d.ts`, no `declare module` shim, and no `tsconfig` `paths` alias. The SDK types ship with `@bastani/atomic`, so a workflow package depends only on `@bastani/atomic` (plus a `typebox` peer):
|
|
1245
1417
|
|
|
1246
1418
|
```ts
|
|
1247
1419
|
import { defineWorkflow, Type } from "@bastani/workflows";
|
|
@@ -1255,6 +1427,29 @@ export default defineWorkflow("map-workflow-sdk")
|
|
|
1255
1427
|
.compile();
|
|
1256
1428
|
```
|
|
1257
1429
|
|
|
1430
|
+
How those types resolve depends on what else the package imports:
|
|
1431
|
+
|
|
1432
|
+
- A package that imports `@bastani/atomic` anywhere (for example, an extension shipped in the same package) picks the workflow SDK types up automatically. `@bastani/atomic`'s root declarations reference the ambient bridge, so no extra configuration is needed.
|
|
1433
|
+
- A pure workflow-only package โ one that imports nothing but `@bastani/workflows` โ adds a single opt-in so TypeScript loads the ambient bridge. Set it once for the project in `tsconfig.json`:
|
|
1434
|
+
|
|
1435
|
+
```jsonc
|
|
1436
|
+
{
|
|
1437
|
+
"compilerOptions": {
|
|
1438
|
+
"module": "NodeNext",
|
|
1439
|
+
"moduleResolution": "NodeNext",
|
|
1440
|
+
"types": ["@bastani/atomic/workflows/ambient"]
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
```
|
|
1444
|
+
|
|
1445
|
+
or add a single reference directive at the top of one workflow file:
|
|
1446
|
+
|
|
1447
|
+
```ts
|
|
1448
|
+
/// <reference types="@bastani/atomic/workflows/ambient" />
|
|
1449
|
+
```
|
|
1450
|
+
|
|
1451
|
+
Either form makes `import { defineWorkflow, Type } from "@bastani/workflows"` and the `@bastani/workflows/builtin/*` composition imports resolve under `tsc` (`moduleResolution: NodeNext`) with no hand-authored `.d.ts`, no `declare module` shim, and no `paths` alias. `@bastani/workflows` is not a separate npm package โ its types ship with `@bastani/atomic` โ so list both `@bastani/atomic` and `typebox` (the SDK's emitted types reference TypeBox) in `peerDependencies`. Runtime discovery and loading via `atomic.workflows` are unchanged: Atomic's loader still supplies the SDK when workflow files execute.
|
|
1452
|
+
|
|
1258
1453
|
The `workflow` tool still supports direct one-off `task`, `tasks`, and `chain` modes. Direct chains support `chainName` for status/artifact grouping and `chainDir` as a shared directory for relative reads, outputs, and worktree diffs.
|
|
1259
1454
|
|
|
1260
1455
|
Use `createRegistry()` when code needs to group definitions explicitly:
|
|
@@ -1415,6 +1610,7 @@ Before implementing or shipping a non-trivial workflow, answer these questions:
|
|
|
1415
1610
|
|
|
1416
1611
|
- **Purpose and fit:** What concrete outcome should the workflow produce? Is the task naturally multi-stage, parallel, resumable, or reusable? What is out of scope?
|
|
1417
1612
|
- **Inputs:** Which values should be declared as inputs? What is the narrowest schema type? Which defaults are safe?
|
|
1613
|
+
- **Starter pattern:** Which [workflow starter pattern](#workflow-starter-patterns) best matches the task, and where does the actual design intentionally diverge?
|
|
1418
1614
|
- **Stage decomposition:** For each stage, what question does it answer, what context does it need, what output should it return, and what model/tool/MCP requirements does it have?
|
|
1419
1615
|
- **Information flow:** For every edge between stages, is `previous` enough, or should the handoff use structured returns, files, `reads`, `output`, or `outputMode`?
|
|
1420
1616
|
- **Output contract:** Which outputs should be declared with `.output(...)`, which stage/task/child results should `.run()` return for those keys, and what runtime type must each value have? If another workflow may call this workflow as a child, which non-default outputs should the parent rely on?
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bastani/atomic",
|
|
3
|
-
"version": "0.8.24-alpha.
|
|
3
|
+
"version": "0.8.24-alpha.3",
|
|
4
4
|
"description": "Atomic coding agent CLI with read, bash, edit, write tools and session management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"atomicConfig": {
|
|
@@ -26,6 +26,24 @@
|
|
|
26
26
|
"./hooks": {
|
|
27
27
|
"types": "./dist/core/hooks/index.d.ts",
|
|
28
28
|
"import": "./dist/core/hooks/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./workflows": {
|
|
31
|
+
"types": "./dist/builtin/workflows/src/authoring.d.ts",
|
|
32
|
+
"import": "./dist/builtin/workflows/src/index.ts",
|
|
33
|
+
"default": "./dist/builtin/workflows/src/index.ts"
|
|
34
|
+
},
|
|
35
|
+
"./workflows/ambient": {
|
|
36
|
+
"types": "./dist/builtin/workflows/ambient.d.ts"
|
|
37
|
+
},
|
|
38
|
+
"./workflows/builtin": {
|
|
39
|
+
"types": "./dist/builtin/workflows/builtin/index.d.ts",
|
|
40
|
+
"import": "./dist/builtin/workflows/builtin/index.ts",
|
|
41
|
+
"default": "./dist/builtin/workflows/builtin/index.ts"
|
|
42
|
+
},
|
|
43
|
+
"./workflows/builtin/*": {
|
|
44
|
+
"types": "./dist/builtin/workflows/builtin/*.d.ts",
|
|
45
|
+
"import": "./dist/builtin/workflows/builtin/*.ts",
|
|
46
|
+
"default": "./dist/builtin/workflows/builtin/*.ts"
|
|
29
47
|
}
|
|
30
48
|
},
|
|
31
49
|
"files": [
|
|
@@ -44,6 +62,7 @@
|
|
|
44
62
|
"copy-builtin-packages": "bun run scripts/copy-builtin-packages.ts",
|
|
45
63
|
"copy-builtin-workflows": "bun run copy-builtin-packages",
|
|
46
64
|
"docs:check": "bun run scripts/validate-docs-links.ts",
|
|
65
|
+
"verify:workflow-types": "bun run scripts/verify-workflow-sdk-types.ts",
|
|
47
66
|
"test": "vitest --run",
|
|
48
67
|
"prepublishOnly": "bun run clean && bun run build"
|
|
49
68
|
},
|