trak_flow 0.1.3
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.
- checksums.yaml +7 -0
- data/.envrc +3 -0
- data/CHANGELOG.md +69 -0
- data/COMMITS.md +196 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +281 -0
- data/README.md +479 -0
- data/Rakefile +16 -0
- data/bin/tf +6 -0
- data/bin/tf_mcp +81 -0
- data/docs/.keep +0 -0
- data/docs/api/database.md +434 -0
- data/docs/api/ruby-library.md +349 -0
- data/docs/api/task-model.md +341 -0
- data/docs/assets/stylesheets/extra.css +53 -0
- data/docs/assets/trak_flow.jpg +0 -0
- data/docs/cli/admin-commands.md +369 -0
- data/docs/cli/dependency-commands.md +321 -0
- data/docs/cli/label-commands.md +222 -0
- data/docs/cli/overview.md +163 -0
- data/docs/cli/plan-commands.md +344 -0
- data/docs/cli/task-commands.md +333 -0
- data/docs/core-concepts/dependencies.md +232 -0
- data/docs/core-concepts/labels.md +217 -0
- data/docs/core-concepts/overview.md +178 -0
- data/docs/core-concepts/plans-workflows.md +264 -0
- data/docs/core-concepts/tasks.md +205 -0
- data/docs/getting-started/configuration.md +120 -0
- data/docs/getting-started/installation.md +79 -0
- data/docs/getting-started/quick-start.md +245 -0
- data/docs/index.md +169 -0
- data/docs/mcp/integration.md +302 -0
- data/docs/mcp/overview.md +206 -0
- data/docs/mcp/resources.md +284 -0
- data/docs/mcp/tools.md +457 -0
- data/examples/basic_usage.rb +365 -0
- data/examples/cli_demo.sh +314 -0
- data/examples/mcp/Gemfile +9 -0
- data/examples/mcp/Gemfile.lock +226 -0
- data/examples/mcp/http_demo.rb +232 -0
- data/examples/mcp/stdio_demo.rb +146 -0
- data/lib/trak_flow/cli/admin_commands.rb +136 -0
- data/lib/trak_flow/cli/config_commands.rb +260 -0
- data/lib/trak_flow/cli/dep_commands.rb +71 -0
- data/lib/trak_flow/cli/label_commands.rb +76 -0
- data/lib/trak_flow/cli/main_commands.rb +386 -0
- data/lib/trak_flow/cli/plan_commands.rb +185 -0
- data/lib/trak_flow/cli/workflow_commands.rb +133 -0
- data/lib/trak_flow/cli.rb +110 -0
- data/lib/trak_flow/config/defaults.yml +114 -0
- data/lib/trak_flow/config/section.rb +74 -0
- data/lib/trak_flow/config.rb +276 -0
- data/lib/trak_flow/graph/dependency_graph.rb +288 -0
- data/lib/trak_flow/id_generator.rb +52 -0
- data/lib/trak_flow/mcp/resources/base_resource.rb +25 -0
- data/lib/trak_flow/mcp/resources/dependency_graph.rb +31 -0
- data/lib/trak_flow/mcp/resources/label_list.rb +21 -0
- data/lib/trak_flow/mcp/resources/plan_by_id.rb +27 -0
- data/lib/trak_flow/mcp/resources/plan_list.rb +21 -0
- data/lib/trak_flow/mcp/resources/task_by_id.rb +31 -0
- data/lib/trak_flow/mcp/resources/task_list.rb +21 -0
- data/lib/trak_flow/mcp/resources/task_next.rb +30 -0
- data/lib/trak_flow/mcp/resources/workflow_by_id.rb +27 -0
- data/lib/trak_flow/mcp/resources/workflow_list.rb +21 -0
- data/lib/trak_flow/mcp/server.rb +140 -0
- data/lib/trak_flow/mcp/tools/base_tool.rb +29 -0
- data/lib/trak_flow/mcp/tools/comment_add.rb +33 -0
- data/lib/trak_flow/mcp/tools/dep_add.rb +34 -0
- data/lib/trak_flow/mcp/tools/dep_remove.rb +25 -0
- data/lib/trak_flow/mcp/tools/label_add.rb +28 -0
- data/lib/trak_flow/mcp/tools/label_remove.rb +25 -0
- data/lib/trak_flow/mcp/tools/plan_add_step.rb +35 -0
- data/lib/trak_flow/mcp/tools/plan_create.rb +33 -0
- data/lib/trak_flow/mcp/tools/plan_run.rb +58 -0
- data/lib/trak_flow/mcp/tools/plan_start.rb +58 -0
- data/lib/trak_flow/mcp/tools/task_block.rb +27 -0
- data/lib/trak_flow/mcp/tools/task_close.rb +26 -0
- data/lib/trak_flow/mcp/tools/task_create.rb +51 -0
- data/lib/trak_flow/mcp/tools/task_defer.rb +27 -0
- data/lib/trak_flow/mcp/tools/task_start.rb +25 -0
- data/lib/trak_flow/mcp/tools/task_update.rb +36 -0
- data/lib/trak_flow/mcp/tools/workflow_discard.rb +28 -0
- data/lib/trak_flow/mcp/tools/workflow_summarize.rb +34 -0
- data/lib/trak_flow/mcp.rb +38 -0
- data/lib/trak_flow/models/comment.rb +71 -0
- data/lib/trak_flow/models/dependency.rb +96 -0
- data/lib/trak_flow/models/label.rb +90 -0
- data/lib/trak_flow/models/task.rb +188 -0
- data/lib/trak_flow/storage/database.rb +638 -0
- data/lib/trak_flow/storage/jsonl.rb +259 -0
- data/lib/trak_flow/time_parser.rb +15 -0
- data/lib/trak_flow/version.rb +5 -0
- data/lib/trak_flow.rb +100 -0
- data/mkdocs.yml +143 -0
- metadata +392 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
# Labels
|
|
2
|
+
|
|
3
|
+
Labels provide flexible categorization for tasks.
|
|
4
|
+
|
|
5
|
+
## Adding Labels
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
tf label add TASK_ID LABEL
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Examples
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
tf label add tf-abc123 "frontend"
|
|
15
|
+
tf label add tf-abc123 "urgent"
|
|
16
|
+
tf label add tf-abc123 "v2.0"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Removing Labels
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
tf label remove TASK_ID LABEL
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Examples
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
tf label remove tf-abc123 "urgent"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Viewing Labels
|
|
32
|
+
|
|
33
|
+
### Labels on a Task
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
tf label list TASK_ID
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Output:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
Labels for tf-abc123:
|
|
43
|
+
- frontend
|
|
44
|
+
- urgent
|
|
45
|
+
- v2.0
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### All Labels in Project
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
tf label list-all
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Output:
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
All labels:
|
|
58
|
+
- backend (3 tasks)
|
|
59
|
+
- frontend (5 tasks)
|
|
60
|
+
- urgent (2 tasks)
|
|
61
|
+
- v2.0 (8 tasks)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Filtering by Label
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
tf list --label frontend
|
|
68
|
+
tf list -l urgent
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Multiple Labels
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
tf list --label frontend --label urgent
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
This shows tasks with BOTH labels.
|
|
78
|
+
|
|
79
|
+
## Label Naming
|
|
80
|
+
|
|
81
|
+
### Conventions
|
|
82
|
+
|
|
83
|
+
Labels are case-sensitive strings. Common conventions:
|
|
84
|
+
|
|
85
|
+
| Category | Examples |
|
|
86
|
+
|----------|----------|
|
|
87
|
+
| Components | `frontend`, `backend`, `api`, `database` |
|
|
88
|
+
| Priority | `urgent`, `quick-win`, `stretch-goal` |
|
|
89
|
+
| Version | `v1.0`, `v2.0`, `next-release` |
|
|
90
|
+
| Team | `team-a`, `team-b`, `platform` |
|
|
91
|
+
| Status | `needs-review`, `blocked-external`, `ready-for-qa` |
|
|
92
|
+
| Type | `tech-debt`, `documentation`, `security` |
|
|
93
|
+
|
|
94
|
+
### Best Practices
|
|
95
|
+
|
|
96
|
+
1. **Use lowercase** - `frontend` not `Frontend`
|
|
97
|
+
2. **Use hyphens** - `needs-review` not `needs_review`
|
|
98
|
+
3. **Be consistent** - Agree on conventions with your team
|
|
99
|
+
4. **Keep it simple** - Fewer labels = easier to manage
|
|
100
|
+
|
|
101
|
+
## Use Cases
|
|
102
|
+
|
|
103
|
+
### Component Tracking
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
tf label add tf-abc123 "frontend"
|
|
107
|
+
tf label add tf-def456 "backend"
|
|
108
|
+
tf label add tf-ghi789 "api"
|
|
109
|
+
|
|
110
|
+
# Find all frontend tasks
|
|
111
|
+
tf list --label frontend
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Sprint Planning
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
tf label add tf-abc123 "sprint-42"
|
|
118
|
+
tf label add tf-def456 "sprint-42"
|
|
119
|
+
|
|
120
|
+
# Sprint backlog
|
|
121
|
+
tf list --label sprint-42 --status open
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Release Management
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
tf label add tf-abc123 "v2.0"
|
|
128
|
+
tf label add tf-def456 "v2.0"
|
|
129
|
+
|
|
130
|
+
# What's in v2.0?
|
|
131
|
+
tf list --label v2.0
|
|
132
|
+
|
|
133
|
+
# What's not done for v2.0?
|
|
134
|
+
tf list --label v2.0 --status open
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Priority Escalation
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
# Mark as urgent
|
|
141
|
+
tf label add tf-abc123 "urgent"
|
|
142
|
+
|
|
143
|
+
# Find all urgent tasks
|
|
144
|
+
tf list --label urgent
|
|
145
|
+
|
|
146
|
+
# De-escalate
|
|
147
|
+
tf label remove tf-abc123 "urgent"
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Workflow States
|
|
151
|
+
|
|
152
|
+
Labels can track custom workflow states:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
tf label add tf-abc123 "needs-review"
|
|
156
|
+
tf label add tf-abc123 "in-qa"
|
|
157
|
+
tf label add tf-abc123 "approved"
|
|
158
|
+
|
|
159
|
+
# Find tasks needing review
|
|
160
|
+
tf list --label needs-review
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Labels vs Dependencies
|
|
164
|
+
|
|
165
|
+
| Use | Labels | Dependencies |
|
|
166
|
+
|-----|--------|--------------|
|
|
167
|
+
| Grouping | Yes | No |
|
|
168
|
+
| Blocking work | No | Yes |
|
|
169
|
+
| Filtering | Yes | Limited |
|
|
170
|
+
| Order/sequence | No | Yes |
|
|
171
|
+
| Multiple per task | Yes | Yes |
|
|
172
|
+
|
|
173
|
+
### When to Use Labels
|
|
174
|
+
|
|
175
|
+
- Categorization without blocking
|
|
176
|
+
- Cross-cutting concerns
|
|
177
|
+
- Temporary states
|
|
178
|
+
- Filtering/search
|
|
179
|
+
|
|
180
|
+
### When to Use Dependencies
|
|
181
|
+
|
|
182
|
+
- Task A must complete before Task B
|
|
183
|
+
- Sequential workflows
|
|
184
|
+
- Blocking relationships
|
|
185
|
+
|
|
186
|
+
## JSON Representation
|
|
187
|
+
|
|
188
|
+
Labels are stored as a separate entity with task associations:
|
|
189
|
+
|
|
190
|
+
```json
|
|
191
|
+
{
|
|
192
|
+
"id": "lbl-123",
|
|
193
|
+
"task_id": "tf-abc123",
|
|
194
|
+
"name": "frontend",
|
|
195
|
+
"created_at": "2024-01-15T10:00:00Z"
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Bulk Operations
|
|
200
|
+
|
|
201
|
+
### Add Label to Multiple Tasks
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
# Using shell loop
|
|
205
|
+
for id in tf-abc123 tf-def456 tf-ghi789; do
|
|
206
|
+
tf label add $id "sprint-42"
|
|
207
|
+
done
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Remove Label from All Tasks
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
# Find all tasks with label and remove
|
|
214
|
+
tf list --label old-label --json | \
|
|
215
|
+
jq -r '.[].id' | \
|
|
216
|
+
xargs -I {} tf label remove {} "old-label"
|
|
217
|
+
```
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# Core Concepts Overview
|
|
2
|
+
|
|
3
|
+
TrakFlow is built around a few key concepts that work together to provide flexible task management.
|
|
4
|
+
|
|
5
|
+
## The Task Model
|
|
6
|
+
|
|
7
|
+
Everything in TrakFlow is a **Task**. Tasks serve multiple roles depending on their flags:
|
|
8
|
+
|
|
9
|
+
```mermaid
|
|
10
|
+
graph TD
|
|
11
|
+
A[Task] --> B{plan?}
|
|
12
|
+
B -->|true| C[Plan Blueprint]
|
|
13
|
+
B -->|false| D{source_plan_id?}
|
|
14
|
+
D -->|set| E[Workflow Instance]
|
|
15
|
+
D -->|not set| F[Regular Task]
|
|
16
|
+
|
|
17
|
+
C --> G[Contains Steps]
|
|
18
|
+
E --> H[Contains Work Items]
|
|
19
|
+
F --> I[Standalone Task]
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
| Role | Identification | Description |
|
|
23
|
+
|------|----------------|-------------|
|
|
24
|
+
| **Task** | Default | A unit of work to be completed |
|
|
25
|
+
| **Plan** | `task.plan? == true` | A reusable workflow blueprint |
|
|
26
|
+
| **Step** | Child of a Plan | A task definition within a Plan |
|
|
27
|
+
| **Workflow** | `task.source_plan_id` set | A running instance of a Plan |
|
|
28
|
+
| **Work Item** | Child of a Workflow | A task within a running Workflow |
|
|
29
|
+
|
|
30
|
+
## Task Lifecycle
|
|
31
|
+
|
|
32
|
+
```mermaid
|
|
33
|
+
stateDiagram-v2
|
|
34
|
+
[*] --> open: Create
|
|
35
|
+
open --> in_progress: Start
|
|
36
|
+
open --> blocked: Block
|
|
37
|
+
open --> deferred: Defer
|
|
38
|
+
in_progress --> blocked: Block
|
|
39
|
+
in_progress --> closed: Close
|
|
40
|
+
blocked --> open: Unblock
|
|
41
|
+
blocked --> in_progress: Unblock & Start
|
|
42
|
+
deferred --> open: Reopen
|
|
43
|
+
closed --> open: Reopen
|
|
44
|
+
closed --> tombstone: Archive
|
|
45
|
+
tombstone --> [*]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Statuses
|
|
49
|
+
|
|
50
|
+
| Status | Description |
|
|
51
|
+
|--------|-------------|
|
|
52
|
+
| `open` | Ready to work on |
|
|
53
|
+
| `in_progress` | Currently being worked on |
|
|
54
|
+
| `blocked` | Waiting on something |
|
|
55
|
+
| `deferred` | Postponed for later |
|
|
56
|
+
| `closed` | Completed |
|
|
57
|
+
| `tombstone` | Archived (permanent) |
|
|
58
|
+
| `pinned` | Highlighted for visibility |
|
|
59
|
+
|
|
60
|
+
## Dependency Graph
|
|
61
|
+
|
|
62
|
+
Tasks can depend on other tasks. TrakFlow maintains a dependency graph to:
|
|
63
|
+
|
|
64
|
+
1. **Track blockers** - Know what's preventing work
|
|
65
|
+
2. **Find ready work** - Identify tasks with no open blockers
|
|
66
|
+
3. **Visualize relationships** - Understand task connections
|
|
67
|
+
|
|
68
|
+
```mermaid
|
|
69
|
+
graph LR
|
|
70
|
+
A[Design API] -->|blocks| B[Implement API]
|
|
71
|
+
B -->|blocks| C[Write Tests]
|
|
72
|
+
B -->|blocks| D[Update Docs]
|
|
73
|
+
C -->|blocks| E[Deploy]
|
|
74
|
+
D -->|blocks| E
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Dependency Types
|
|
78
|
+
|
|
79
|
+
| Type | Description |
|
|
80
|
+
|------|-------------|
|
|
81
|
+
| `blocks` | Hard dependency (default) |
|
|
82
|
+
| `related` | Soft link for reference |
|
|
83
|
+
| `parent-child` | Hierarchical relationship |
|
|
84
|
+
| `discovered-from` | Traceability link |
|
|
85
|
+
|
|
86
|
+
## Plans and Workflows
|
|
87
|
+
|
|
88
|
+
Plans are reusable workflow templates. When executed, they create Workflows.
|
|
89
|
+
|
|
90
|
+
```mermaid
|
|
91
|
+
graph TB
|
|
92
|
+
subgraph Plan [Plan: Deploy Checklist]
|
|
93
|
+
P1[Run Tests]
|
|
94
|
+
P2[Build Artifacts]
|
|
95
|
+
P3[Deploy Staging]
|
|
96
|
+
P4[Deploy Production]
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
subgraph Workflow [Workflow: Deploy v1.2]
|
|
100
|
+
W1[Run Tests ✓]
|
|
101
|
+
W2[Build Artifacts ✓]
|
|
102
|
+
W3[Deploy Staging ~]
|
|
103
|
+
W4[Deploy Production]
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
Plan -->|start| Workflow
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Workflow Types
|
|
110
|
+
|
|
111
|
+
| Type | Created By | Lifecycle | JSONL Export |
|
|
112
|
+
|------|------------|-----------|--------------|
|
|
113
|
+
| **Persistent** | `tf plan start` | Kept forever | Yes |
|
|
114
|
+
| **Ephemeral** | `tf plan execute` | Auto-cleaned | No |
|
|
115
|
+
|
|
116
|
+
## Labels
|
|
117
|
+
|
|
118
|
+
Labels provide flexible categorization:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
tf label add tf-abc123 "frontend"
|
|
122
|
+
tf label add tf-abc123 "urgent"
|
|
123
|
+
tf label add tf-abc123 "v2.0"
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Labels can represent:
|
|
127
|
+
- **Components**: `frontend`, `backend`, `api`
|
|
128
|
+
- **Priority markers**: `urgent`, `quick-win`
|
|
129
|
+
- **Versions**: `v1.0`, `v2.0`
|
|
130
|
+
- **States**: `needs-review`, `blocked-external`
|
|
131
|
+
|
|
132
|
+
## Data Storage
|
|
133
|
+
|
|
134
|
+
TrakFlow uses a dual-storage approach:
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
.trak_flow/
|
|
138
|
+
├── issues.jsonl # Source of truth (git-tracked)
|
|
139
|
+
├── trak_flow.db # Fast cache (gitignored)
|
|
140
|
+
└── config.json # Settings (git-tracked)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### JSONL Format
|
|
144
|
+
|
|
145
|
+
Human-readable, one task per line:
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{"id":"tf-abc123","title":"Fix bug","status":"open","priority":1}
|
|
149
|
+
{"id":"tf-def456","title":"Add feature","status":"in_progress","priority":2}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### SQLite Cache
|
|
153
|
+
|
|
154
|
+
Provides:
|
|
155
|
+
- **Fast queries** - Millisecond response times
|
|
156
|
+
- **Indexing** - By status, priority, labels
|
|
157
|
+
- **Full-text search** - Search task content
|
|
158
|
+
|
|
159
|
+
The cache is rebuilt automatically from JSONL on each session.
|
|
160
|
+
|
|
161
|
+
## Hash-Based IDs
|
|
162
|
+
|
|
163
|
+
TrakFlow generates IDs using content hashes:
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
tf-a1b2c3d4
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Benefits:
|
|
170
|
+
- **No collisions** - Multiple agents can create tasks simultaneously
|
|
171
|
+
- **Merge-friendly** - Git merges work without conflicts
|
|
172
|
+
- **Deterministic** - Same content = same ID (for deduplication)
|
|
173
|
+
|
|
174
|
+
## Next Steps
|
|
175
|
+
|
|
176
|
+
- [Tasks](tasks.md) - Deep dive into task properties
|
|
177
|
+
- [Plans & Workflows](plans-workflows.md) - Workflow automation
|
|
178
|
+
- [Dependencies](dependencies.md) - Managing task relationships
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# Plans & Workflows
|
|
2
|
+
|
|
3
|
+
Plans and Workflows enable reusable, automated task sequences.
|
|
4
|
+
|
|
5
|
+
## Concept Overview
|
|
6
|
+
|
|
7
|
+
```mermaid
|
|
8
|
+
graph TB
|
|
9
|
+
subgraph Definition
|
|
10
|
+
Plan[Plan Blueprint]
|
|
11
|
+
Step1[Step 1]
|
|
12
|
+
Step2[Step 2]
|
|
13
|
+
Step3[Step 3]
|
|
14
|
+
Plan --> Step1
|
|
15
|
+
Plan --> Step2
|
|
16
|
+
Plan --> Step3
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
subgraph Execution
|
|
20
|
+
Plan -->|start| PW[Persistent Workflow]
|
|
21
|
+
Plan -->|execute| EW[Ephemeral Workflow]
|
|
22
|
+
PW --> T1[Task 1]
|
|
23
|
+
PW --> T2[Task 2]
|
|
24
|
+
PW --> T3[Task 3]
|
|
25
|
+
end
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
| Concept | Description |
|
|
29
|
+
|---------|-------------|
|
|
30
|
+
| **Plan** | A reusable template defining a sequence of tasks |
|
|
31
|
+
| **Step** | A task definition within a Plan |
|
|
32
|
+
| **Workflow** | A running instance created from a Plan |
|
|
33
|
+
| **Work Item** | A task within a Workflow |
|
|
34
|
+
|
|
35
|
+
## Creating Plans
|
|
36
|
+
|
|
37
|
+
### Create an Empty Plan
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
tf plan create "Deploy to Production"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Add Steps
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
tf plan add tf-plan1 "Run test suite"
|
|
47
|
+
tf plan add tf-plan1 "Build Docker image"
|
|
48
|
+
tf plan add tf-plan1 "Deploy to staging"
|
|
49
|
+
tf plan add tf-plan1 "Run smoke tests"
|
|
50
|
+
tf plan add tf-plan1 "Deploy to production"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### View Plan
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
tf plan show tf-plan1
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Output:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
Plan: Deploy to Production [tf-plan1]
|
|
63
|
+
Status: open (blueprint)
|
|
64
|
+
Steps: 5
|
|
65
|
+
|
|
66
|
+
[ ] Run test suite
|
|
67
|
+
[ ] Build Docker image
|
|
68
|
+
[ ] Deploy to staging
|
|
69
|
+
[ ] Run smoke tests
|
|
70
|
+
[ ] Deploy to production
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Convert Existing Task to Plan
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
tf plan convert tf-existing-task
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Executing Workflows
|
|
80
|
+
|
|
81
|
+
### Persistent Workflow
|
|
82
|
+
|
|
83
|
+
Creates a workflow that is kept in history:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
tf plan start tf-plan1
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
- Exported to JSONL
|
|
90
|
+
- Appears in `tf workflow list`
|
|
91
|
+
- Kept after completion
|
|
92
|
+
|
|
93
|
+
### Ephemeral Workflow
|
|
94
|
+
|
|
95
|
+
Creates a one-shot workflow:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
tf plan execute tf-plan1
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
- NOT exported to JSONL
|
|
102
|
+
- Auto-cleaned after completion
|
|
103
|
+
- Use for temporary operations
|
|
104
|
+
|
|
105
|
+
## Managing Workflows
|
|
106
|
+
|
|
107
|
+
### List Workflows
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
# All workflows
|
|
111
|
+
tf workflow list
|
|
112
|
+
|
|
113
|
+
# Only ephemeral
|
|
114
|
+
tf workflow list --ephemeral
|
|
115
|
+
tf workflow list -e
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### View Workflow
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
tf workflow show tf-wf1
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Output:
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
Workflow: Deploy to Production [tf-wf1]
|
|
128
|
+
Source Plan: tf-plan1
|
|
129
|
+
Type: Persistent
|
|
130
|
+
Status: in_progress
|
|
131
|
+
|
|
132
|
+
[x] Run test suite
|
|
133
|
+
[x] Build Docker image
|
|
134
|
+
[~] Deploy to staging
|
|
135
|
+
[ ] Run smoke tests
|
|
136
|
+
[ ] Deploy to production
|
|
137
|
+
|
|
138
|
+
Progress: 2/5 completed
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Work on Tasks
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# Start a task
|
|
145
|
+
tf start tf-task1
|
|
146
|
+
|
|
147
|
+
# Complete a task
|
|
148
|
+
tf close tf-task1
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Summarize and Close
|
|
152
|
+
|
|
153
|
+
When all tasks are done:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
tf workflow summarize tf-wf1 --summary "Deployed v1.2.0 successfully"
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
This:
|
|
160
|
+
1. Adds the summary to workflow notes
|
|
161
|
+
2. Closes the workflow
|
|
162
|
+
3. Records completion timestamp
|
|
163
|
+
|
|
164
|
+
### Discard Ephemeral Workflow
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
tf workflow discard tf-wf1
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Only ephemeral workflows can be discarded.
|
|
171
|
+
|
|
172
|
+
## Garbage Collection
|
|
173
|
+
|
|
174
|
+
Clean up old ephemeral workflows:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
tf workflow gc
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
This removes ephemeral workflows that are:
|
|
181
|
+
- Closed
|
|
182
|
+
- Older than the retention period
|
|
183
|
+
|
|
184
|
+
## Plan vs Workflow Properties
|
|
185
|
+
|
|
186
|
+
| Property | Plan | Workflow |
|
|
187
|
+
|----------|------|----------|
|
|
188
|
+
| `plan` | `true` | `false` |
|
|
189
|
+
| `source_plan_id` | `null` | Set to Plan ID |
|
|
190
|
+
| `ephemeral` | Always `false` | `true` or `false` |
|
|
191
|
+
| `status` | Always `open` | Can change |
|
|
192
|
+
| Contains | Steps (templates) | Work items (tasks) |
|
|
193
|
+
| JSONL export | Yes | Persistent only |
|
|
194
|
+
|
|
195
|
+
## Use Cases
|
|
196
|
+
|
|
197
|
+
### Release Checklist
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
tf plan create "Release Checklist"
|
|
201
|
+
tf plan add tf-plan1 "Update version number"
|
|
202
|
+
tf plan add tf-plan1 "Update CHANGELOG"
|
|
203
|
+
tf plan add tf-plan1 "Run full test suite"
|
|
204
|
+
tf plan add tf-plan1 "Create release branch"
|
|
205
|
+
tf plan add tf-plan1 "Build release artifacts"
|
|
206
|
+
tf plan add tf-plan1 "Deploy to staging"
|
|
207
|
+
tf plan add tf-plan1 "QA verification"
|
|
208
|
+
tf plan add tf-plan1 "Deploy to production"
|
|
209
|
+
tf plan add tf-plan1 "Create GitHub release"
|
|
210
|
+
tf plan add tf-plan1 "Announce release"
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Code Review Process
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
tf plan create "Code Review"
|
|
217
|
+
tf plan add tf-plan1 "Check code style"
|
|
218
|
+
tf plan add tf-plan1 "Review logic"
|
|
219
|
+
tf plan add tf-plan1 "Check test coverage"
|
|
220
|
+
tf plan add tf-plan1 "Security review"
|
|
221
|
+
tf plan add tf-plan1 "Performance review"
|
|
222
|
+
tf plan add tf-plan1 "Approve or request changes"
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Onboarding Workflow
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
tf plan create "New Team Member Onboarding"
|
|
229
|
+
tf plan add tf-plan1 "Create accounts"
|
|
230
|
+
tf plan add tf-plan1 "Grant repository access"
|
|
231
|
+
tf plan add tf-plan1 "Add to Slack channels"
|
|
232
|
+
tf plan add tf-plan1 "Schedule intro meetings"
|
|
233
|
+
tf plan add tf-plan1 "Assign onboarding buddy"
|
|
234
|
+
tf plan add tf-plan1 "First task assignment"
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Best Practices
|
|
238
|
+
|
|
239
|
+
### Plan Design
|
|
240
|
+
|
|
241
|
+
1. **Keep steps atomic** - Each step should be completable independently
|
|
242
|
+
2. **Use clear names** - Steps should be self-explanatory
|
|
243
|
+
3. **Order logically** - Steps should follow a natural sequence
|
|
244
|
+
4. **Consider dependencies** - Add explicit dependencies if needed
|
|
245
|
+
|
|
246
|
+
### Workflow Execution
|
|
247
|
+
|
|
248
|
+
1. **Use persistent for auditing** - When you need a record
|
|
249
|
+
2. **Use ephemeral for routine** - For repeatable, disposable operations
|
|
250
|
+
3. **Summarize on completion** - Document what happened
|
|
251
|
+
4. **Clean up regularly** - Run `tf workflow gc` periodically
|
|
252
|
+
|
|
253
|
+
### Error Handling
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
# If a step fails, mark it blocked
|
|
257
|
+
tf block tf-step3
|
|
258
|
+
|
|
259
|
+
# Add notes about the issue
|
|
260
|
+
tf update tf-step3 --notes "Staging deployment failed, investigating"
|
|
261
|
+
|
|
262
|
+
# Once resolved, restart
|
|
263
|
+
tf start tf-step3
|
|
264
|
+
```
|