@meistrari/tela-cli 0.7.58 → 1.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.
@@ -0,0 +1,210 @@
1
+ ## CLI
2
+
3
+ The workflow command group documents implemented `init`, `compile`, `docs`, `codegen`, `sync`, and `publish` workflows. Current MVP behavior is local-first until you run explicit remote lifecycle commands such as `sync` or `publish`.
4
+
5
+ ### Command surface
6
+
7
+ | Command | Status | Remote mutation | Purpose |
8
+ | --- | --- | --- | --- |
9
+ | `init [--directory <path>] [--config <path>] [--workflow <key>...] [--yes] [--init-git\|--no-init-git] [--install-deps\|--no-install-deps] [--package-manager bun\|pnpm\|npm\|yarn] [--json]` | Implemented | No | Create local Workflow Code scaffold. |
10
+ | `compile [target] [--config <path>] [--env <path>] [--json]` | Implemented | No | Compile selected source into Workflow V3 output. |
11
+ | `docs [page] [--json]` | Implemented | No | Read the version-matched Workflow Code documentation bundled with the installed CLI. |
12
+ | `codegen [--json]` | Implemented | No | Refresh or reuse the active-context remote catalog and generate remote() TypeScript metadata. |
13
+ | `sync [target] [--config <path>] [--env <path>] [--yes] [--json]` | Implemented | Yes | Synchronize local compiled workflow(s) with configured Tela prompt(s). |
14
+ | `publish [target] [--environment <name>] [--create-environment-if-missing] [--config <path>] [--env <path>] [--yes] [--json]` | Implemented | Yes | Publish local-matching workflow version(s) to the selected workflow environment. |
15
+
16
+ ### Target selection
17
+
18
+ The positional target is the key inside `workflow-code.config.ts` `workflows`. If `compile` sees exactly one configured workflow, the target may be omitted. If multiple workflows exist, `compile` requires a target. `sync` and `publish` use the same target key; when the target is omitted, they run every configured workflow. For publish, `--environment <name>` selects the workflow publication environment and is independent from the active Tela Local context. `--env <path>` remains a dotenv loader.
19
+
20
+ ```bash
21
+ tela workflow compile
22
+ tela workflow compile invoice-processing
23
+ tela workflow compile invoice-processing --env .env.staging --json
24
+ tela workflow docs cli
25
+ tela workflow codegen --json
26
+ tela workflow sync
27
+ tela workflow sync invoice-processing --env .env.staging --json
28
+ tela workflow publish
29
+ tela workflow publish invoice-processing --environment staging --json
30
+ ```
31
+
32
+ ### init
33
+
34
+ **Description.** `tela workflow init` scaffolds a local Workflow Code project. It is local-only: it does not contact Tela APIs, create remote resources, write lockfiles, emit generated artifacts, or print environment values.
35
+
36
+ Init creates the target directory when needed, then writes a safe starter project:
37
+
38
+ - `workflow-code.config.ts` with `tsconfig: './tsconfig.json'`, `outDir: '.tela/workflows'`, and a `workflows` map.
39
+ - `src/workflows/<key>.workflow.ts` for each workflow key passed with `--workflow <key>` or entered interactively.
40
+ - `.env.example` with placeholder project and prompt variables for generated workflow targets.
41
+ - `tsconfig.json` when missing.
42
+ - `package.json` updates for `@meistrari/workflow-code` and missing `workflow:*` scripts.
43
+ - `.gitignore` entry for `.tela/workflows/*/contexts/dev/lock.json`.
44
+
45
+ Existing files and package scripts are preserved by default. Conflicts become diagnostics and `--json` reports written paths, skipped paths, skipped scripts, and setup actions.
46
+
47
+ Interactive init prompts in this order: target directory, workflow keys, git initialization, dependency installation, then package manager when installation is enabled. Defaults are safe: current directory, no workflow keys, no git init, no dependency install, and Bun when a package manager is needed. `--yes` answers non-interactive prompts with those safe defaults while still honoring explicit flags such as `--workflow`, `--directory`, or `--install-deps`.
48
+
49
+ | Prop | Type | Required | Description |
50
+ |---|---|---:|---|
51
+ | `--directory <path>` | Flag | No | Target directory to initialize. Defaults to `.` and is created when missing. |
52
+ | `--config <path>` | Flag | No | Config file path to create inside the target directory. Defaults to `workflow-code.config.ts`. |
53
+ | `--workflow <key>` | Flag | No | Add a workflow target and source file. Repeat for multiple workflows. Keys must be safe file names. |
54
+ | `--yes` | Flag | No | Disable prompts and use safe defaults for unspecified choices. |
55
+ | `--init-git` / `--no-init-git` | Flag | No | Create or skip a git repository when the target directory is not already inside one. |
56
+ | `--install-deps` / `--no-install-deps` | Flag | No | Install Workflow Code dependencies. If `package.json` is missing, init runs the selected package manager's non-interactive init first. |
57
+ | `--package-manager bun|pnpm|npm|yarn` | Flag | No | Package manager for dependency installation. Defaults to Bun. |
58
+ | `--json` | Flag | No | Emit the result envelope, diagnostics, scaffold paths, skipped scripts, and setup actions as JSON. |
59
+
60
+ **Examples.**
61
+
62
+ ```bash
63
+ tela workflow init
64
+ tela workflow init --directory ./workflow-app --workflow invoice-processing --workflow review
65
+ tela workflow init --install-deps --package-manager pnpm --yes
66
+ tela workflow init --workflow invoice-processing --yes --json
67
+ ```
68
+
69
+
70
+
71
+ ### compile
72
+
73
+ **Description.** `tela workflow compile` loads config, loads dotenv files, evaluates the TypeScript entrypoint, validates declarations, and returns deterministic Workflow V3 graph, payload, hashes, and diagnostics. It does not require or validate remote `projectId`/`promptId`, write lockfiles, sync remote content, or publish.
74
+
75
+ | Prop | Type | Required | Description |
76
+ |---|---|---:|---|
77
+ | `target` | Positional | No | Config `workflows` key to compile. Required when more than one workflow is configured. |
78
+ | `--config <path>` | Flag | No | Load a custom config file instead of `workflow-code.config.ts`. |
79
+ | `--env <path>` | Flag | No | Load a custom dotenv file before evaluating config. |
80
+ | `--json` | Flag | No | Emit compiled graph, payload, hashes, and diagnostics as JSON. |
81
+
82
+ **Examples.**
83
+
84
+ ```bash
85
+ tela workflow compile
86
+ tela workflow compile invoice-processing
87
+ tela workflow compile invoice-processing --env .env.staging --json
88
+ tela workflow compile --config ./workflow-code.config.ts
89
+ ```
90
+
91
+ ### docs
92
+
93
+ **Description.** `tela workflow docs` reads the official Workflow Code documentation bundled with the installed CLI. It is local-only, performs no network requests, and reports the Workflow Code package version represented by the bundle.
94
+
95
+ Omit the page to list the available documentation. Pass a page slug to print its Markdown content. JSON output includes the package version, source package, and either the page catalog or selected page content.
96
+
97
+ | Prop | Type | Required | Description |
98
+ |---|---|---:|---|
99
+ | `page` | Positional | No | Bundled documentation page such as `cli`, `config`, or `api-reference`. |
100
+ | `--json` | Flag | No | Emit bundle provenance, package version, and page metadata or content as JSON. |
101
+
102
+ **Examples.**
103
+
104
+ ```bash
105
+ tela workflow docs
106
+ tela workflow docs cli
107
+ tela workflow docs api-reference --json
108
+ ```
109
+
110
+ ### codegen
111
+
112
+ `codegen [--json]`
113
+
114
+ **Description.** `tela workflow codegen` resolves the active Tela Local context and workspace, refreshes the authenticated remote catalog, and writes TypeScript metadata for inert `remote()` authoring. It writes the generated augmentation at `.tela/workflow-code/generated/workflow-code.generated.d.ts` and the complete context/workspace snapshot at `.tela/workflow-code/catalogs/<workspaceId>/remote-catalog.snapshot.json`. The catalog includes canvases, workflows, templates, published agents, and models; only canvases, workflows, published agents, and models are projected by `remote()`.
115
+
116
+ Codegen fetches a fresh snapshot when possible. If refresh fails, it may reuse only a complete cached snapshot for the same active context and workspace, reports warning diagnostics, and repairs or skips artifacts deterministically. If neither refresh nor a matching snapshot is available, it fails without inventing catalog bindings. Generated files are non-secret typechecking and orchestration metadata; include the generated declaration path in TypeScript's `include` configuration when needed.
117
+
118
+ `compile` remains offline and preserves symbolic remote refs. `sync` refreshes and validates catalog references and locks before resolved lowering and remote mutation.
119
+
120
+ | Prop | Type | Required | Description |
121
+ |---|---|---:|---|
122
+ | `--json` | Flag | No | Emit command, active context/workspace, metadata source/hash/timestamps, written paths, skipped paths, and diagnostics as JSON. |
123
+
124
+ **Examples.**
125
+
126
+ ```bash
127
+ tela workflow codegen
128
+ tela workflow codegen --json
129
+ ```
130
+
131
+ ### sync
132
+
133
+ **Description.** `tela workflow sync` compiles local source, resolves the active Tela Local context, selects the matching `projectId` and `promptId`, verifies remote content, and writes per-context lockfile state under `.tela/workflows/<workflowKey>/contexts/<context>/lock.json`.
134
+
135
+ Sync uses a consolidated version strategy. The compiled workflow becomes the complete source of truth for the next remote version: source files, hashes, lifecycle payload, package metadata, and binding metadata are consolidated into one prompt version snapshot. When compiled content changed, sync creates a new non-draft version. The only exception is a verified no-op: if local hashes already match the active-context lockfile and fresh remote content confirms the same version, sync returns without creating a version.
136
+
137
+ Consolidated versions make sync safe to repeat. A sync never edits an existing version in place, never mutates a draft, and never changes the previous consolidated version. If the workflow is currently pointing at a draft version, sync leaves that draft untouched and creates a new consolidated non-draft version for the compiled workflow instead.
138
+
139
+ | Prop | Type | Required | Description |
140
+ |---|---|---:|---|
141
+ | `target` | Positional | No | Config `workflows` key to sync. Omit to sync every configured workflow. |
142
+ | `--config <path>` | Flag | No | Load a custom config file instead of `workflow-code.config.ts`. |
143
+ | `--env <path>` | Flag | No | Load a custom dotenv file before evaluating config. |
144
+ | `--yes` | Flag | No | Continue non-interactively when remote content changed since the last successful sync. |
145
+ | `--json` | Flag | No | Emit selected workflows, sync status, remote version ids, lockfile paths, compiled payloads, and diagnostics as JSON. |
146
+
147
+ **Examples.**
148
+
149
+ ```bash
150
+ tela workflow sync
151
+ tela workflow sync invoice-processing
152
+ tela workflow sync invoice-processing --env .env.staging --yes --json
153
+ ```
154
+
155
+ **Example: local source changes after review.** You update `src/invoice.workflow.ts`, run `compile`, review the payload, then run `tela workflow sync invoice-processing`. Sync creates a new non-draft consolidated version that contains the compiled workflow and updates the active-context lockfile to that version.
156
+
157
+ **Example: active remote workflow is a draft.** A teammate is experimenting in Tela and the current workflow points at a draft version. Running `tela workflow sync invoice-processing` does not overwrite or publish that draft. Sync creates a new consolidated non-draft version from local source and records that new version in the lockfile; the former draft version remains available as it was.
158
+
159
+ **Example: no local changes.** CI runs `tela workflow sync --yes --json` after a previous successful sync. If local hashes match the lockfile and the remote snapshot still matches, sync returns a no-op and does not create another version.
160
+
161
+
162
+
163
+ ### publish
164
+
165
+ **Description.** `tela workflow publish` releases only remote versions proven to match local compiled source. It uses shared Tela CLI authentication and the active Tela Local context to resolve each workflow's configured `projectId` and `promptId`. If the current remote version cannot be proven to match the local hashes and synced lineage, publish runs sync internally for that workflow before continuing. A matching draft is consolidated before publication; publish does not create an unrelated workflow version.
166
+
167
+ `--environment <name>` selects the workflow publication environment for every selected workflow and defaults to `production`. Before changing any workflow version, publish resolves that environment and its current remote version for every selected workflow. If a custom environment is missing in an interactive terminal, publish shows its exact name and affected workflows, then asks once whether to create it; the default answer is no. In `--json` or another non-interactive execution, pass `--create-environment-if-missing` to authorize creation explicitly. `--yes` remains limited to remote-divergence handling during the sync lifecycle. These flags do not change the Tela Local context, API endpoint, workspace, or credentials. `--env <path>` only loads dotenv values used by config and workflow source.
168
+
169
+ Publish does not store publication state in the Workflow Code lockfile; Tela's environment state remains authoritative. The lockfile changes only when publish needs to run sync internally first.
170
+
171
+ | Prop | Type | Required | Description |
172
+ |---|---|---:|---|
173
+ | `target` | Positional | No | Config `workflows` key to publish. Omit to publish every configured workflow. |
174
+ | `--environment <name>` | Flag | No | Workflow publication environment. Defaults to `production`. |
175
+ | `--create-environment-if-missing` | Flag | No | Create the selected custom environment when absent. Required for non-interactive creation. |
176
+ | `--config <path>` | Flag | No | Load a custom config file instead of `workflow-code.config.ts`. |
177
+ | `--env <path>` | Flag | No | Load a custom dotenv file before evaluating config. |
178
+ | `--yes` | Flag | No | Continue non-interactively if the sync performed by publish detects remote divergence. |
179
+ | `--json` | Flag | No | Emit selected workflow, context, and environment identities, version ids, hashes, diagnostics, and written paths as JSON. |
180
+
181
+ **Examples.**
182
+
183
+ ```bash
184
+ tela workflow publish
185
+ tela workflow publish invoice-processing
186
+ tela workflow publish invoice-processing --environment staging
187
+ tela workflow publish invoice-processing --environment dev --create-environment-if-missing --json
188
+ tela workflow publish --environment production --yes --json
189
+ ```
190
+
191
+
192
+
193
+ ### JSON diagnostics
194
+
195
+ ```ts
196
+ type Diagnostic = Readonly<{
197
+ code: string
198
+ severity: 'error' | 'warning' | 'info'
199
+ message: string
200
+ hint?: string
201
+ location?: {
202
+ file: string
203
+ line?: number
204
+ column?: number
205
+ offset?: number
206
+ endOffset?: number
207
+ }
208
+ stack?: string
209
+ }>
210
+ ```
@@ -0,0 +1,69 @@
1
+ ## Config
2
+
3
+ `workflow-code.config.ts` selects workflow targets, TypeScript entrypoints used by `compile`, and remote prompt bindings used by `sync`. The config is evaluated after dotenv loading, so `process.env` is available.
4
+
5
+ ### Basic shape
6
+
7
+ ```ts
8
+ import type { WorkflowCodeConfig } from '@meistrari/workflow-code'
9
+
10
+ export default {
11
+ version: 1,
12
+ workflows: {
13
+ demo: {
14
+ entry: './src/workflows/demo.workflow.ts',
15
+ projectId: process.env.TELA_PROJECT_ID,
16
+ promptId: process.env.TELA_WORKFLOW_PROMPT_ID,
17
+ workflowKey: 'first-workflow',
18
+ contexts: {
19
+ development: {
20
+ projectId: process.env.TELA_DEV_PROJECT_ID ?? process.env.TELA_PROJECT_ID!,
21
+ promptId: process.env.TELA_DEV_PROMPT_ID,
22
+ },
23
+ },
24
+ },
25
+ },
26
+ } satisfies WorkflowCodeConfig
27
+ ```
28
+
29
+ ### Config properties
30
+
31
+ | Property | Required | Purpose |
32
+ | --- | --- | --- |
33
+ | `version` | Yes | Must be `1`. |
34
+ | `workflows` | Yes | Map from CLI target name to workflow target. |
35
+ | `tsconfig` | No | Optional TypeScript config path for source evaluation. |
36
+ | `outDir` | No | Output directory for generated workflow artifacts. |
37
+
38
+ ### Workflow target properties
39
+
40
+ | Property | Required | Purpose |
41
+ | --- | --- | --- |
42
+ | `entry` | Yes | Path to the workflow TypeScript entrypoint. |
43
+ | `projectId` | No | Default Tela project id for remote lifecycle commands; not required by compile. |
44
+ | `promptId` | No | Existing Tela prompt or workflow id for remote lifecycle commands; not required by compile. |
45
+ | `workflowKey` | No | Expected source workflow key; compile reports an error if it disagrees with `workflow(...)`. |
46
+ | `title` | No | Human title used by compiler metadata. |
47
+ | `contexts` | No | Map of context name to `projectId` and `promptId` overrides for remote lifecycle commands. |
48
+
49
+ ### Environment variables
50
+
51
+ Use `.env` files for ids that differ by workspace or deployment.
52
+
53
+ ```bash
54
+ TELA_PROJECT_ID=proj_default
55
+ TELA_WORKFLOW_PROMPT_ID=prompt_default
56
+ TELA_DEV_PROJECT_ID=proj_development
57
+ TELA_DEV_PROMPT_ID=prompt_development
58
+ ```
59
+
60
+ Use `tela workflow compile --env .env.staging --json` to validate local workflow source. `compile` does not require or validate `projectId`/`promptId`; use `tela workflow sync demo --env .env.staging --json` when remote bindings are available. Do not print secrets or store credentials in workflow source.
61
+
62
+ ### Contexts
63
+
64
+ Contexts can mirror Tela Dock contexts for environment-specific ids. `compile` remains local validation. `sync` resolves the active Tela Local context, chooses the matching `contexts[...]` binding, requires both `projectId` and `promptId`, and writes state under `.tela/workflows/<workflowKey>/contexts/<context>/lock.json`.
65
+
66
+ ```bash
67
+ tela context current --json
68
+ tela context list --json
69
+ ```
@@ -0,0 +1,56 @@
1
+ ## Guides
2
+
3
+ These guides collect practical conventions for source layout, CI validation, and diagnostic workflows.
4
+
5
+ ### Suggested scaffold
6
+
7
+ Start with a small source tree that separates workflow declarations, prompt text, and shared utilities.
8
+
9
+
10
+
11
+ ```bash
12
+ workflow-code.config.ts
13
+ .env.example
14
+ src/workflows/demo.workflow.ts
15
+ src/workflows/prompts.ts
16
+ src/workflows/shared.ts
17
+ ```
18
+
19
+
20
+
21
+ | Path | Purpose |
22
+ | --- | --- |
23
+ | `workflow-code.config.ts` | Typed workflow targets and context bindings. |
24
+ | `.env.example` | Document required project and prompt ids. |
25
+ | `src/workflows/demo.workflow.ts` | Default-exported `build(workflow(...))` declaration. |
26
+ | `src/workflows/prompts.ts` | Prompt strings and small prompt helpers. |
27
+ | `src/workflows/shared.ts` | Pure utilities reused by declarations or code handlers. |
28
+
29
+ ### CI compile check
30
+
31
+ Use `compile --json` in CI to validate source and fail on error diagnostics before any remote lifecycle command runs.
32
+
33
+ ```bash
34
+ set -euo pipefail
35
+ pnpm install --frozen-lockfile
36
+ pnpm exec tela workflow compile demo --env .env.ci --json > .tela/compile-result.json
37
+ node -e "const r=require('./.tela/compile-result.json'); if (r.diagnostics?.some(d => d.severity === 'error')) process.exit(1)"
38
+ ```
39
+
40
+ For trusted release jobs with Tela credentials, run sync after compile:
41
+
42
+ ```bash
43
+ pnpm exec tela workflow sync --env .env.ci --yes --json > .tela/sync-result.json
44
+ node -e "const r=require('./.tela/sync-result.json'); if (r.diagnostics?.some(d => d.severity === 'error')) process.exit(1)"
45
+ ```
46
+
47
+ Commit stable context lockfiles such as `.tela/workflows/*/contexts/*/lock.json` when they represent reviewed remote sync state.
48
+
49
+ ### Troubleshooting diagnostics
50
+
51
+ When `compile` or `sync` fails, read diagnostic `code` and `hint` first. Most failures point to config shape, missing env files, unresolved entry paths, invalid references, `workflowKey` mismatches, unsupported `code()` extraction patterns, missing `promptId`, active-context binding mismatches, or remote divergence.
52
+
53
+ - Use `tela workflow compile --json` for declaration and graph diagnostics.
54
+ - Use `tela context current --json` when `sync` selects an unexpected context binding.
55
+ - Pass `--yes` only in trusted non-interactive jobs where consolidating a newer remote version is expected.
56
+ - Keep code handlers source-visible and avoid dynamic imports, runtime-created closure values, and reserved generated names.
@@ -0,0 +1,33 @@
1
+ ## Installation
2
+
3
+ Workflow Code uses the `tela workflow` command group from `@meistrari/tela-cli` and the authoring/compiler package `@meistrari/workflow-code` in the repository that owns workflow source.
4
+
5
+ ### CLI through Tela Dock
6
+
7
+ Tela Dock is the recommended source for CLI setup. It manages account login, workspace or environment context, updates, and shared local configuration used by workflow commands.
8
+
9
+ ```bash
10
+ tela whoami --pretty
11
+ tela workflow help
12
+ ```
13
+
14
+ Use Dock for login and context switching instead of workflow-specific token files. Dock and CLI share local context metadata through `@meistrari/tela-local-config`; credential material remains in the OS keychain (macOS Keychain, or the Linux freedesktop Secret Service via `secret-tool`) or environment credential adapters.
15
+
16
+ ### Repository package
17
+
18
+ Install the authoring and compiler package where workflow source lives.
19
+
20
+ ```bash
21
+ pnpm add -D @meistrari/workflow-code @meistrari/tela-cli
22
+ ```
23
+
24
+ Use package scripts or `pnpm exec` to invoke `tela workflow` from CI. The public workflow source imports only `@meistrari/workflow-code`.
25
+
26
+ ### Verification
27
+
28
+ Run these checks before writing workflow source:
29
+
30
+ - `tela whoami --pretty` confirms the authenticated account.
31
+ - `tela context current --json` confirms the active local context.
32
+ - `tela workflow help` confirms the workflow command group is routed.
33
+ - `pnpm list @meistrari/workflow-code` confirms the authoring package is installed in the repository.
@@ -0,0 +1,50 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "packageName": "@meistrari/workflow-code",
4
+ "packageVersion": "0.0.0",
5
+ "sourcePackage": "@meistrari/workflow-code-page",
6
+ "pages": [
7
+ {
8
+ "slug": "overview",
9
+ "title": "Documentation overview",
10
+ "file": "overview.md",
11
+ "sha256": "88c838262048260cee280cdd8d16e9987847bcf06b857ca6d2cf0b707c4b15fe"
12
+ },
13
+ {
14
+ "slug": "api-reference",
15
+ "title": "API Reference",
16
+ "file": "api-reference.md",
17
+ "sha256": "2306f6a21d23b4e3457262c3105e65e0292af5a59154aa15cf24188409db07f8"
18
+ },
19
+ {
20
+ "slug": "cli",
21
+ "title": "CLI",
22
+ "file": "cli.md",
23
+ "sha256": "759db330fd7b06859e55404f01feb0625a43bb579324fe011bc34cd92d517239"
24
+ },
25
+ {
26
+ "slug": "config",
27
+ "title": "Config",
28
+ "file": "config.md",
29
+ "sha256": "b07b91f46b4ab9a3850df58a0dec388c670771be6de0a5cf3bafd989135fe306"
30
+ },
31
+ {
32
+ "slug": "guides",
33
+ "title": "Guides",
34
+ "file": "guides.md",
35
+ "sha256": "b3f2ff1ac03f3829b6c5614ecc61229e181179dd2506684fae073075748359cb"
36
+ },
37
+ {
38
+ "slug": "installation",
39
+ "title": "Installation",
40
+ "file": "installation.md",
41
+ "sha256": "e20f15e52c519580a8260748195a3ec8f149ac15d8beb79d06bb401a5f639500"
42
+ },
43
+ {
44
+ "slug": "quick-start",
45
+ "title": "Quick start",
46
+ "file": "quick-start.md",
47
+ "sha256": "15f4b45bd6292c4dd3f3ff5fc58f46e5e83e55f3a5e4ed9fee0df37fd12b2305"
48
+ }
49
+ ]
50
+ }
@@ -0,0 +1,14 @@
1
+ ## Documentation overview
2
+
3
+ Workflow Code documentation is organized as a set of focused pages. Read the pages in order when adopting the package for the first time, or use the sidebar when you need a specific reference.
4
+
5
+ ### Recommended path
6
+
7
+ | Page | Use it when |
8
+ | --- | --- |
9
+ | [Quick start](/docs/quick-start) | You want the shortest path from `tela workflow init` to local compile and explicit sync. |
10
+ | [Installation](/docs/installation) | You need to verify Tela Dock, the `tela` CLI, or the `@meistrari/workflow-code` package. |
11
+ | [Config](/docs/config) | You are defining `workflow-code.config.ts`, dotenv files, target ids, or context-specific bindings. |
12
+ | [CLI](/docs/cli) | You need implemented init/compile/docs/codegen/sync/publish behavior, target selection rules, generated catalog refresh, or JSON diagnostics. |
13
+ | [API Reference](/docs/api-reference) | You are authoring `workflow()`, `build()`, `input`, `llm`, `agent`, `code`, references, remote catalogs, and executable remote refs. |
14
+ | [Guides](/docs/guides) | You want repository layout, CI compile checks, and troubleshooting patterns. |
@@ -0,0 +1,124 @@
1
+ ## Quick start
2
+
3
+ This page assumes Tela Dock already installed and authenticated the `tela` CLI. Use [Installation](/docs/installation) only when the command is unavailable or the account context is not configured.
4
+
5
+ ### Verify the CLI
6
+
7
+ ```bash
8
+ tela whoami --pretty
9
+ tela workflow help
10
+ ```
11
+
12
+ `compile` is a local validation step. It does not create, sync, publish, or run remote workflows. `sync` writes compiled versions to configured Tela prompts, while `publish` releases a local-matching version to a workflow publication environment.
13
+
14
+ ### Initialize local scaffold
15
+
16
+ ```bash
17
+ tela workflow init
18
+ ```
19
+
20
+ `init` creates safe starter files and package scripts, reports skipped existing files, and does not call Tela APIs.
21
+
22
+ ### Add a minimal config
23
+
24
+ ```ts
25
+ import type { WorkflowCodeConfig } from '@meistrari/workflow-code'
26
+
27
+ export default {
28
+ version: 1,
29
+ workflows: {
30
+ demo: {
31
+ entry: './src/workflows/demo.workflow.ts',
32
+ projectId: process.env.TELA_PROJECT_ID,
33
+ promptId: process.env.TELA_WORKFLOW_PROMPT_ID,
34
+ contexts: {
35
+ development: {
36
+ projectId: process.env.TELA_DEV_PROJECT_ID ?? process.env.TELA_PROJECT_ID!,
37
+ promptId: process.env.TELA_DEV_PROMPT_ID,
38
+ },
39
+ },
40
+ },
41
+ },
42
+ } satisfies WorkflowCodeConfig
43
+ ```
44
+
45
+ Keep the first config small: one target, one entrypoint, and environment-backed ids. Context-specific ids can override defaults when Tela Dock switches contexts.
46
+
47
+ ### Author a workflow
48
+
49
+ ```ts
50
+ import { agent, build, code, input, llm, remote, workflow } from '@meistrari/workflow-code'
51
+
52
+ const topic = input.text({
53
+ name: 'topic',
54
+ required: true,
55
+ description: 'Topic the workflow should explain.',
56
+ })
57
+
58
+ const outline = llm({
59
+ name: 'Draft outline',
60
+ input: {
61
+ temperature: 0.2,
62
+ prompt: ({ ref }) => `Create a concise outline about ${ref(topic).formats().raw}.`,
63
+ },
64
+ schema: {
65
+ bullets: { type: 'array', items: { type: 'string' } },
66
+ },
67
+ })
68
+
69
+ const countBullets = code({
70
+ name: 'Count bullets',
71
+ handler: ({ ref, paths }) => {
72
+ const bullets = ref(outline, paths(outline).bullets) as string[]
73
+ return {
74
+ count: bullets.length,
75
+ firstBullet: bullets[0] ?? null,
76
+ }
77
+ },
78
+ })
79
+
80
+ const reviewer = remote().agent().byId('published-agent-id')
81
+
82
+ const review = agent(reviewer, {
83
+ name: 'Review outline',
84
+ input: {
85
+ message: ({ ref, paths }) => [
86
+ 'Review this outline for a new Tela user.',
87
+ `Bullets: ${ref(outline, paths(outline).bullets).formats().json}`,
88
+ `Bullet count: ${ref(countBullets, paths(countBullets).count).formats().json}`,
89
+ ].join('\n'),
90
+ inputs: {},
91
+ },
92
+ })
93
+
94
+ export default build(workflow('first-workflow'), {
95
+ inputs: [topic],
96
+ nodes: [outline, countBullets, review],
97
+ })
98
+ ```
99
+
100
+ Workflow source is an inert TypeScript declaration. `build(workflow(...), { inputs, nodes })` is the default export read by `compile`. The `code()` handler is not run during compile; compile extracts supported source and lowers it into sandbox code for Workflow runtime execution.
101
+
102
+ ### Compile
103
+
104
+ ```bash
105
+ tela workflow compile demo --json
106
+ ```
107
+
108
+ Use `compile` to validate source and inspect deterministic graph, compiler payload, hashes, and diagnostics.
109
+
110
+ ### Sync
111
+
112
+ ```bash
113
+ tela workflow sync demo --json
114
+ ```
115
+
116
+ Use `sync` after review to write the compiled workflow to the configured Tela prompt for the active Tela context. Omit `demo` to sync every configured workflow. If remote content changed since the last successful sync, the CLI asks before consolidating a new version; pass `--yes` for non-interactive CI.
117
+
118
+ ### Publish
119
+
120
+ ```bash
121
+ tela workflow publish demo --environment production --json
122
+ ```
123
+
124
+ Use `publish` to release the exact version proven to match local compiled source. `production` is the default. When a selected custom environment does not exist, interactive publish asks whether to create it and defaults to no; non-interactive commands must add `--create-environment-if-missing`. The `--environment` flag selects the workflow publication environment; Tela authentication, workspace, and context still come from shared Tela Local state. Publish can perform its own sync when required, but keeping sync explicit in this quick-start flow preserves a clear review boundary before release.