@trailstep/authoring 0.1.0 → 0.1.1
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/README.md +100 -8
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,19 +1,111 @@
|
|
|
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
|
-
|
|
8
|
+
npm install @trailstep/authoring @trailstep/core
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Use the equivalent command for your package manager if you use `pnpm`, `yarn`, or `bun`.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
## What this package is for
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
- `step(...)` for continuation steps.
|
|
17
|
-
- `done(...)` for successful completion.
|
|
15
|
+
Use this package to author continuation workflows with:
|
|
18
16
|
|
|
19
|
-
|
|
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.workflow.ts
|
|
30
|
+
import { defineWorkflow, shape } from "@trailstep/authoring";
|
|
31
|
+
import { summarizeRequestStep } from "./steps/summarize-request.step.js";
|
|
32
|
+
|
|
33
|
+
type FeatureSummaryInput = { request: string };
|
|
34
|
+
type FeatureSummaryOutput = { summary: string; nextStep: string };
|
|
35
|
+
|
|
36
|
+
export const featureSummary = defineWorkflow<FeatureSummaryInput, FeatureSummaryOutput>({
|
|
37
|
+
id: "feature-summary",
|
|
38
|
+
description: "Summarize a feature request and suggest one next step.",
|
|
39
|
+
inputShape: shape<FeatureSummaryInput>({ request: "string" }),
|
|
40
|
+
outputShape: shape<FeatureSummaryOutput>({ summary: "string", nextStep: "string" }),
|
|
41
|
+
start(input) {
|
|
42
|
+
return summarizeRequestStep(input);
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
// workflows/steps/summarize-request.step.ts
|
|
49
|
+
import { done, shape, step } from "@trailstep/authoring";
|
|
50
|
+
|
|
51
|
+
type FeatureSummaryInput = { request: string };
|
|
52
|
+
type FeatureSummaryOutput = { summary: string; nextStep: string };
|
|
53
|
+
|
|
54
|
+
export function summarizeRequestStep(input: FeatureSummaryInput) {
|
|
55
|
+
return step({ id: "summarize-request" })
|
|
56
|
+
.prompt<FeatureSummaryInput, FeatureSummaryOutput>(
|
|
57
|
+
({ input: stepInput }) =>
|
|
58
|
+
`Summarize this feature request and recommend one next step:\n\n${stepInput.request}`,
|
|
59
|
+
{ output: shape<FeatureSummaryOutput>({ summary: "string", nextStep: "string" }) },
|
|
60
|
+
)
|
|
61
|
+
.do((output) => done(output))(input);
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Run direct refs while developing:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
trailstep ./workflows/feature-summary.workflow.ts#featureSummary --input '{"request":"Add CSV export."}'
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Register stable refs when the workflow should be shared:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
trailstep add ./workflows/feature-summary.workflow.ts#featureSummary --scope project --name feature-summary --project-skill
|
|
75
|
+
trailstep project/feature-summary --input '{"request":"Add CSV export."}'
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Packaging prompt fragments
|
|
79
|
+
|
|
80
|
+
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:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import methodology from "./methodology.md?raw";
|
|
84
|
+
|
|
85
|
+
const promptFragment = methodology.trimEnd();
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
{
|
|
90
|
+
"scripts": {
|
|
91
|
+
"build": "tsup src/index.ts --format esm --dts --sourcemap --clean --loader .md=text"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Add a declaration for TypeScript:
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
declare module "*.md?raw" {
|
|
100
|
+
const content: string;
|
|
101
|
+
export default content;
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
`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.
|
|
106
|
+
|
|
107
|
+
## More docs
|
|
108
|
+
|
|
109
|
+
- [Authoring workflows](../../docs/authoring-workflows.md)
|
|
110
|
+
- [Generated skills](../../docs/generated-skills.md)
|
|
111
|
+
- [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.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "TypeScript authoring helpers for TrailStep workflows.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"LICENSE"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@trailstep/core": "0.1.
|
|
32
|
+
"@trailstep/core": "0.1.1"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@trailstep/core": "^0.1.
|
|
35
|
+
"@trailstep/core": "^0.1.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@biomejs/biome": "^2.1.1",
|