In /Users/user_c042661f/Documents/reigh-workspace/vibecomfy, read docs/python_composition_dsl_plan.md and assess how it could be adjusted to address this weakness: the doc is architecture-heavy and not quite 'beautiful API first'. It needs a north-star API section near the top showing the intended user experience for Python orchestration with multiple Comfy graph executions, typed handles, graph -> Python -> graph, and escape hatches. Please propose concrete doc edits: where to insert, what sections to add/change, and any text/code examples. Keep it concise and do not edit files.
Assistant
I’ll inspect the plan doc and nearby docs enough to understand its current structure, then I’ll propose targeted edits without changing files.
Assistant
The doc already has the ingredients, but its first concrete user-facing API appears after architecture and layer taxonomy. I’m checking line numbers now so the edit proposal can point to exact insertion points.
Assistant
Yes. The fix is to move the reader from “architecture plan” into “this is what authoring feels like” before the architecture diagram.
Proposed edits for docs/python_composition_dsl_plan.md:
Insert After Goals
Add a new section after line 36, before ## Non-Goals / Constraints:
md
## North-Star API
The public API should first read like ordinary Python that happens to execute Comfy graphs. Authors should be able to compose graph fragments, run a graph, inspect typed artifacts, use Python to transform or decide, and feed the result into another graph without dropping into API dictionaries.
```python
from vibecomfy import VibeFlow, Workflow
from vibecomfy.blocks import flux, image_io
from vibecomfy.types import ImageArtifact, ImageHandle, LatentHandle
flow = VibeFlow(name="prompt_refine_upscale")
@flow.graph
def txt2img(wf: Workflow, prompt: str) -> ImageHandle:
ckpt, clip, vae = flux.load_checkpoint(wf, "flux1-dev-fp8.safetensors")
latent: LatentHandle = flux.empty_latent(wf, width=1024, height=1024)
cond = flux.encode_prompt(wf, clip=clip, text=prompt)
samples = flux.sample(wf, model=ckpt, positive=cond, latent=latent, steps=24)
image: ImageHandle = flux.decode(wf, samples=samples, vae=vae)
return image_io.save(wf, image, prefix="draft").image
@flow.python
def crop_for_upscale(draft: ImageArtifact) -> ImageArtifact:
return draft.open().center_crop_square().save_temp("crop.png")
@flow.graph
def upscale(wf: Workflow, crop: ImageArtifact) -> ImageHandle:
image = image_io.load(wf, crop)
upscaled = flux.upscale(wf, image=image, scale=2)
return image_io.save(wf, upscaled, prefix="final").image
result = flow.run(
txt2img(prompt="editorial portrait, rain on glass"),
crop_for_upscale(),
upscale(),
)
final_image = result.stage("upscale").output
This is the target shape, not a P1 guarantee. The important properties are:
graph authoring returns typed graph handles such as ImageHandle and LatentHandle;
graph execution returns Python-side artifacts such as ImageArtifact;
ordinary Python stages operate on artifacts, files, metadata, and decisions;
later graph stages can consume artifacts from earlier Python stages;
every layer still exposes escape hatches for raw nodes, raw refs, raw API JSON, and runtime configuration.
code
**Add a Smaller Escape-Hatch Example In Same Section**
Immediately after the north-star example, add:
```md
Escape hatches should be local and explicit:
```python
# Unknown or not-yet-typed node class.
node = wf.node("SomeCustomNode", image=image, widget_3=0.75)
out = node.out(0)
# Existing string refs still work.
wf.node("SaveImage", images="42.0", filename_prefix="legacy")
# Full lower-layer access remains available.
api_workflow = wf.compile("api")
raw_workflow = template.workflow
code
**Change Architecture Intro**
At line 84, replace the current paragraph with something that points back to the API instead of introducing the first user-facing intent:
```md
The north-star API above is the product shape. The architecture below exists to preserve that experience while keeping `VibeWorkflow` canonical, HiddenSwitch as the execution boundary, and lower-layer escape hatches available.
Trim Duplication Later
The existing ## Typed Handles section at line 99 and ## Multi-Stage Orchestration at line 116 are good, but they should become “mechanics behind the north star,” not the first API reveal.
Suggested small edits:
In ## Typed Handles, replace “New code should prefer:” with “The north-star API depends on this small primitive:”.
In ## Multi-Stage Orchestration, add one sentence at the top: “This section explains the execution semantics behind the north-star VibeFlow example.”
Rename One Section
Rename ## Layer Definitions at line 86 to:
md
## API Concepts
That makes the document feel less like an internal architecture taxonomy.
Optional Tightening
Move ## Architecture below the renamed ## API Concepts section. Current order is:
Goals
Constraints
Architecture
Layer Definitions
Better order:
Goals
North-Star API
Constraints
API Concepts
Architecture
That gives the reader the user experience first, the vocabulary second, and the architecture third.