@trailstep/authoring 0.1.0 → 0.1.2

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.
Files changed (2) hide show
  1. package/README.md +146 -8
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -1,19 +1,157 @@
1
1
  # @trailstep/authoring
2
2
 
3
- `@trailstep/authoring` provides TypeScript helpers for writing TrailStep workflows.
3
+ `@trailstep/authoring` provides TypeScript helpers for writing TrailStep workflows. Most workflow authors should start here rather than using `@trailstep/core` directly.
4
4
 
5
5
  ## Install
6
6
 
7
7
  ```bash
8
- pnpm add @trailstep/authoring
8
+ npm install @trailstep/authoring @trailstep/core
9
9
  ```
10
10
 
11
- ## Public role
11
+ Use the equivalent command for your package manager if you use `pnpm`, `yarn`, or `bun`.
12
12
 
13
- Use this package to author workflows with:
13
+ ## What this package is for
14
14
 
15
- - `defineWorkflow({ start })` as the workflow definition boundary.
16
- - `step(...)` for continuation steps.
17
- - `done(...)` for successful completion.
15
+ Use this package to author continuation workflows with:
18
16
 
19
- Export workflows from a Node-readable module. Consumers can run direct refs such as `./workflows/sample.ts#sampleWorkflow`, register refs with `trailstep add`, or use bundle refs when a package exposes a TrailStep workflow manifest.
17
+ - `defineWorkflow({ start })` as the workflow boundary.
18
+ - `step(...)` for focused units of agent or local work.
19
+ - `.prompt(...).do(...)` for agent-backed steps with structured output.
20
+ - `done(...)` and `fail(...)` for terminal continuations.
21
+ - `shape(...)` or `jsonSchema(...)` for JSON-object validation.
22
+ - prompt helpers such as `promptSections`, `section`, `loadFragments`, and `promptTemplate`.
23
+
24
+ ## Basic pattern
25
+
26
+ Keep workflow entrypoints small and put step logic in separate files as workflows grow.
27
+
28
+ ```ts
29
+ // workflows/feature-summary.schema.ts
30
+ import { shape } from "@trailstep/authoring";
31
+
32
+ export type FeatureSummaryInput = {
33
+ readonly request: string;
34
+ };
35
+
36
+ export type FeatureSummaryOutput = {
37
+ readonly summary: string;
38
+ readonly nextStep: string;
39
+ };
40
+
41
+ export const featureSummaryInput = shape<FeatureSummaryInput>({
42
+ request: "string",
43
+ });
44
+
45
+ export const featureSummaryOutput = shape<FeatureSummaryOutput>({
46
+ summary: "string",
47
+ nextStep: "string",
48
+ });
49
+ ```
50
+
51
+ ```ts
52
+ // workflows/feature-summary.workflow.ts
53
+ import { defineWorkflow } from "@trailstep/authoring";
54
+ import {
55
+ type FeatureSummaryInput,
56
+ type FeatureSummaryOutput,
57
+ featureSummaryInput,
58
+ featureSummaryOutput,
59
+ } from "./feature-summary.schema.js";
60
+ import { summarizeRequestStep } from "./steps/summarize-request.step.js";
61
+
62
+ export const featureSummary = defineWorkflow<FeatureSummaryInput, FeatureSummaryOutput>({
63
+ id: "feature-summary",
64
+ description: "Summarize a feature request and suggest one next step.",
65
+ inputShape: featureSummaryInput,
66
+ outputShape: featureSummaryOutput,
67
+ agents: {
68
+ summarizer: {
69
+ size: "medium",
70
+ thinking: "medium",
71
+ description: "Summarizes feature requests for planning.",
72
+ },
73
+ },
74
+ start(input) {
75
+ return summarizeRequestStep(input);
76
+ },
77
+ });
78
+ ```
79
+
80
+ ```ts
81
+ // workflows/steps/summarize-request.step.ts
82
+ import { done, promptSections, section, step } from "@trailstep/authoring";
83
+ import {
84
+ type FeatureSummaryInput,
85
+ type FeatureSummaryOutput,
86
+ featureSummaryOutput,
87
+ } from "../feature-summary.schema.js";
88
+
89
+ function summarizeRequestPrompt({
90
+ input,
91
+ }: {
92
+ readonly input: FeatureSummaryInput;
93
+ }): string {
94
+ return promptSections(
95
+ section("Feature request", input.request),
96
+ section(
97
+ "Task",
98
+ "Summarize the request in two or three sentences, then recommend exactly one next step.",
99
+ ),
100
+ );
101
+ }
102
+
103
+ export const summarizeRequestStep = step({ id: "summarize-request" })
104
+ .prompt<FeatureSummaryInput, FeatureSummaryOutput>(summarizeRequestPrompt, {
105
+ agent: "summarizer",
106
+ output: featureSummaryOutput,
107
+ })
108
+ .do((output) => done(output));
109
+ ```
110
+
111
+ Run direct refs while developing:
112
+
113
+ ```bash
114
+ trailstep ./workflows/feature-summary.workflow.ts#featureSummary --input '{"request":"Add CSV export."}'
115
+ ```
116
+
117
+ Register stable refs when the workflow should be shared:
118
+
119
+ ```bash
120
+ trailstep add ./workflows/feature-summary.workflow.ts#featureSummary --scope project --name feature-summary --project-skill
121
+ trailstep project/feature-summary --input '{"request":"Add CSV export."}'
122
+ ```
123
+
124
+ ## Packaging prompt fragments
125
+
126
+ If a published workflow imports markdown prompt fragments, prefer bundling them into the workflow entrypoint so the installed package has no runtime file-path assumptions. With `tsup`, use raw imports plus the text loader:
127
+
128
+ ```ts
129
+ import methodology from "./methodology.md?raw";
130
+
131
+ const promptFragment = methodology.trimEnd();
132
+ ```
133
+
134
+ ```json
135
+ {
136
+ "scripts": {
137
+ "build": "tsup src/index.ts --format esm --dts --sourcemap --clean --loader .md=text"
138
+ }
139
+ }
140
+ ```
141
+
142
+ Add a declaration for TypeScript:
143
+
144
+ ```ts
145
+ declare module "*.md?raw" {
146
+ const content: string;
147
+ export default content;
148
+ }
149
+ ```
150
+
151
+ `loadFragments(import.meta.dirname, ...)` is useful for local source workflows or packages that deliberately ship copied asset files, but publishable bundled workflow packages must either inline those fragments or include copied assets in `files` at the exact runtime paths used by the built bundle.
152
+
153
+ ## More docs
154
+
155
+ - [Authoring workflows](../../docs/authoring-workflows.md)
156
+ - [Generated skills](../../docs/generated-skills.md)
157
+ - [CLI reference](../../docs/cli-reference.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trailstep/authoring",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "TypeScript authoring helpers for TrailStep workflows.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -29,14 +29,14 @@
29
29
  "LICENSE"
30
30
  ],
31
31
  "dependencies": {
32
- "@trailstep/core": "0.1.0"
32
+ "@trailstep/core": "0.1.1"
33
33
  },
34
34
  "peerDependencies": {
35
- "@trailstep/core": "^0.1.0"
35
+ "@trailstep/core": "^0.1.1"
36
36
  },
37
37
  "devDependencies": {
38
- "@biomejs/biome": "^2.1.1",
39
- "@types/node": "^26.1.1",
38
+ "@biomejs/biome": "^2.5.8",
39
+ "@types/node": "^26.2.0",
40
40
  "tsup": "^8.5.0",
41
41
  "typescript": "^5.8.3",
42
42
  "vitest": "^3.2.4"