@meistrari/tela-cli 0.7.58 → 0.8.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,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": "864146c6f6ef204590c4f444edb5109be08075343bd3115f1ba5bc29d70be177"
12
+ },
13
+ {
14
+ "slug": "api-reference",
15
+ "title": "API Reference",
16
+ "file": "api-reference.md",
17
+ "sha256": "bc52ff31a4fcf5b8c21cf0ddf2fc3f2ba2dcbc69b6b55302f26768fb5348b7bb"
18
+ },
19
+ {
20
+ "slug": "cli",
21
+ "title": "CLI",
22
+ "file": "cli.md",
23
+ "sha256": "321454c8359c0449261e625120e2af6960cc71460dcf9a0f929ffad58e8ab4bf"
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": "78212b3f1fa52c116e6fd9f5331edefecf1079e1073aa32673f719b44d019ce8"
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/sync/publish behavior, target selection rules, or JSON diagnostics. |
13
+ | [API Reference](/docs/api-reference) | You are authoring `workflow()`, `build()`, `input`, `llm`, `agent`, `code`, and references. |
14
+ | [Guides](/docs/guides) | You want repository layout, CI compile checks, and troubleshooting patterns. |
@@ -0,0 +1,122 @@
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, 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 review = agent({
81
+ name: 'Review outline',
82
+ input: {
83
+ maxRounds: 8,
84
+ prompt: ({ ref, paths }) => [
85
+ 'Review this outline for a new Tela user.',
86
+ `Bullets: ${ref(outline, paths(outline).bullets).formats().json}`,
87
+ `Bullet count: ${ref(countBullets, paths(countBullets).count).formats().json}`,
88
+ ].join('\n'),
89
+ },
90
+ })
91
+
92
+ export default build(workflow('first-workflow'), {
93
+ inputs: [topic],
94
+ nodes: [outline, countBullets, review],
95
+ })
96
+ ```
97
+
98
+ 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.
99
+
100
+ ### Compile
101
+
102
+ ```bash
103
+ tela workflow compile demo --json
104
+ ```
105
+
106
+ Use `compile` to validate source and inspect deterministic graph, compiler payload, hashes, and diagnostics.
107
+
108
+ ### Sync
109
+
110
+ ```bash
111
+ tela workflow sync demo --json
112
+ ```
113
+
114
+ 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.
115
+
116
+ ### Publish
117
+
118
+ ```bash
119
+ tela workflow publish demo --environment production --json
120
+ ```
121
+
122
+ 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.