Skip to content

AlfredChaos/TaskFlow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TaskFlow

终端原生的项目管理工具 — CLI 版 Linear

TaskFlow 是一个基于 Golang 构建的终端项目管理工具,复刻 Linear 的核心体验。支持交互式 TUI 界面和 CLI 命令行双模式,数据存储基于本地 SQLite,零配置、单二进制、完全离线运行。

特性

  • 三层任务结构:Project → Issue → Sub-issue,支持 Epic 拆子任务模式
  • 状态机驱动backlog → todo → in_progress → done,带合法性校验,防止跳跃式状态变更
  • 双视图 TUI:水平分栏看板(Kanban)+ 按状态分组列表,终端内完成所有操作
  • CLI 子命令:完整的命令行接口,支持 JSON/Table/Quiet 三种输出格式
  • Agent 友好--json 输出 + 短 ID(TF-42),天然适配 AI Agent 调用
  • 本地 SQLite:单文件数据库,零配置,数据完全在本地
  • 纯 Go 实现:无 CGO 依赖,单二进制跨平台部署

快速开始

安装

# 从源码构建
git clone https://github.com/AlfredChaos/TaskFlow.git
cd TaskFlow
make build

# 二进制文件在 bin/taskflow
./bin/taskflow --help

启动 TUI

# 直接运行进入交互式界面
taskflow

CLI 快速体验

# 创建项目
taskflow project create --name "My Sprint" --desc "Sprint 1"

# 创建 Issue
taskflow issue create --project "My Sprint" --title "实现登录功能" --priority high --assignee me

# 拆子任务
taskflow issue create --project "My Sprint" --title "设计数据库 Schema" --parent TF-1
taskflow issue create --project "My Sprint" --title "实现 JWT 鉴权" --parent TF-1

# 状态流转
taskflow issue move TF-1 --status todo
taskflow issue move TF-1 --status in_progress

# 添加评论
taskflow comment add --issue TF-1 --body "已开始开发"

# 添加标签
taskflow label create --name "feature" --color "#3B82F6"
taskflow label add --issue TF-1 --name "feature"

# 查看详情
taskflow issue show TF-1

架构

技术栈

组件 选型 说明
语言 Go 1.22+ 纯 Go,无 CGO 依赖
TUI 框架 Bubble Tea Elm 架构,Model-View-Update
样式渲染 Lip Gloss 终端样式库
CLI 框架 Cobra 命令行解析
数据库 modernc.org/sqlite 纯 Go SQLite 驱动
表格输出 tablewriter 终端表格渲染

项目结构

taskflow/
├── cmd/taskflow/main.go          # 程序入口
├── internal/
│   ├── model/                    # 数据模型层
│   │   ├── project.go            # Project 结构体
│   │   ├── issue.go              # Issue 结构体 + 状态机 + 优先级
│   │   ├── comment.go            # Comment 结构体
│   │   ├── label.go              # Label 结构体
│   │   └── relation.go           # IssueRelation 结构体
│   ├── store/                    # SQLite 存储层
│   │   ├── store.go              # DB 初始化 + 迁移 + 序号管理
│   │   ├── project.go            # Project CRUD
│   │   ├── issue.go              # Issue CRUD + 状态流转 + 短ID
│   │   ├── comment.go            # Comment 增查
│   │   ├── label.go              # Label CRUD + Issue 关联
│   │   └── relation.go           # Relation 增删查
│   ├── cli/                      # Cobra CLI 命令层
│   │   ├── root.go               # 根命令 + 全局 flags
│   │   ├── project.go            # project 子命令组
│   │   ├── issue.go              # issue 子命令组
│   │   ├── comment.go            # comment 子命令组
│   │   ├── label.go              # label 子命令组
│   │   ├── relation.go           # relation 子命令组
│   │   └── output.go             # JSON/Table/Quiet 输出格式化
│   └── tui/                      # Bubble Tea TUI 层
│       ├── app.go                # 主 Model(视图路由/键盘处理)
│       ├── styles.go             # Lip Gloss 全局样式
│       ├── projects.go           # Projects 列表视图
│       ├── board.go              # Board 看板视图(5列)
│       ├── list.go               # List 列表视图(按状态分组)
│       ├── detail.go             # Issue 详情视图
│       └── editor.go             # 编辑器占位
├── .claude/skills/taskflow/      # Agent 操作技能
├── Makefile
├── go.mod
└── go.sum

分层架构

┌─────────────────────────────────────┐
│           cmd/taskflow/main.go       │  入口:CLI 或 TUI
├──────────┬──────────────────────────┤
│  cli/    │         tui/             │  展示层
│  Cobra   │      Bubble Tea          │
├──────────┴──────────────────────────┤
│              store/                  │  存储层(SQLite CRUD)
├─────────────────────────────────────┤
│              model/                  │  数据模型(纯结构体+逻辑)
└─────────────────────────────────────┘

数据模型

三层结构

Project
  └── Issue (parent_id = NULL)
       └── Sub-issue (parent_id = Issue.id)

Sub-issue 复用 Issue 表,通过 parent_id 区分层级。

Issue 状态机

              ┌──────────┐
      ┌──────►│ backlog  │◄──────┐
      │       └────┬─────┘       │
      │            │              │
      │            ▼              │
      │       ┌──────────┐       │
      │  ┌───►│   todo   │◄──┐   │
      │  │    └────┬─────┘   │   │
      │  │         │         │   │
      │  │         ▼         │   │
      │  │    ┌──────────┐   │   │
      │  │    │in_progress│───┘   │
      │  │    └────┬─────┘       │
      │  │         │              │
      │  │         ▼              │
      │  │    ┌──────────┐       │
      │  └────│   done   │       │
      │       └──────────┘       │
      │                           │
      └─── canceled 可从任意状态进入 ┘
           canceled → backlog (恢复)

合法流转:

  • 前进:backlog → todo → in_progress → done
  • 退回:in_progress → todo
  • 重开:done → todo
  • 取消:任意状态 → canceled
  • 恢复:canceled → backlog
  • 禁止跳跃前进(如 backlog → done

优先级

名称 说明
0 None 未设置
1 Urgent 紧急
2 High 高优
3 Normal 普通(默认)
4 Low 低优

Issue ID

对外使用短 ID 格式:TF-{序号}(如 TF-42),全局自增。CLI 命令中 <id> 参数同时支持短 ID 和 UUID。

CLI 命令

两种模式

模式 命令 说明
TUI 交互模式 taskflow 启动终端 UI
CLI 命令模式 taskflow <command> 执行单次命令

输出格式

Flag 说明 适用场景
(默认) 终端表格 人类阅读
--json JSON 格式 Agent/脚本解析
--quiet 仅输出 ID 管道组合

完整命令列表

# 项目管理
taskflow project list [--status active|archived]
taskflow project create --name "Name" [--desc "Desc"]
taskflow project show <id|name>
taskflow project update <id> [--name X] [--desc X] [--status X]
taskflow project delete <id>

# Issue 管理
taskflow issue list [--project X] [--status X] [--assignee X] [--priority X] [--label X]
taskflow issue create --project X --title "X" [--desc X] [--priority X] [--assignee X] [--parent X] [--due YYYY-MM-DD] [--estimate N]
taskflow issue show <TF-N|uuid>
taskflow issue update <TF-N> [--title X] [--desc X] [--priority X] [--assignee X] [--due X] [--estimate N]
taskflow issue move <TF-N> --status <target>
taskflow issue delete <TF-N>

# 评论
taskflow comment add --issue <TF-N> --body "text" [--author me]
taskflow comment list --issue <TF-N>

# 标签
taskflow label create --name "name" [--color "#hex"]
taskflow label list
taskflow label add --issue <TF-N> --name "name"
taskflow label remove --issue <TF-N> --name "name"

# 关联
taskflow relation add --source <TF-N> --target <TF-N> --type <blocks|related|duplicate>
taskflow relation list --issue <TF-N>
taskflow relation remove <relation-id>

TUI 界面

主界面布局

┌─ TaskFlow ──────────────────────────────────────────┐
│ [1]Projects  [2]Board  [3]List  [4]Detail  [q]Quit  │
├──────────────────────────────────────────────────────┤
│                                                      │
│  (当前视图内容区)                                    │
│                                                      │
├──────────────────────────────────────────────────────┤
│ ↑↓ Navigate │ Enter:Open │ /:Search │ c:Create │ ?:Help│
└──────────────────────────────────────────────────────┘

视图说明

视图 快捷键 说明
Projects 1 项目列表,显示名称和状态
Board 2 水平分栏看板,5 列按状态分组
List 3 按状态分组的紧凑列表
Detail 4 Issue 完整详情(子任务/评论/标签)

快捷键

功能
1-4 切换视图
↑/↓k/j 上下导航
←/→h/l 看板中切换列
Enter 打开详情 / 进入项目
s 切换 Issue 状态
q / Ctrl+C 退出

看板视图

┌─ backlog ──┐┌─── todo ───┐┌─ in_progress ┐┌─── done ───┐┌─ canceled ──┐
│ ● TF-1 登录 ││ TF-3 API   ││ ● TF-5 鉴权   ││ TF-7 文档   ││ TF-8 旧版   │
│ TF-2 注册   ││ TF-4 测试   ││ TF-6 部署     ││             ││              │
└─────────────┘└─────────────┘└───────────────┘└─────────────┘└──────────────┘

数据存储

  • 默认路径~/.taskflow/taskflow.db
  • 环境变量覆盖TASKFLOW_DB_PATH
  • CLI 参数覆盖--db <path>
  • 首次运行自动建表
  • 文件权限 0600

Agent 集成

TaskFlow 天然支持 AI Agent 调用。推荐配合 .claude/skills/taskflow/ 中的技能文件使用:

# Agent 通过 JSON 输出解析结果
taskflow issue list --project "Sprint 1" --json | jq '.[].title'

# 创建并获取新 Issue ID
taskflow issue create --project "Sprint 1" --title "New task" --json --quiet

# 批量状态查询(Agent 日报)
for s in backlog todo in_progress done; do
  echo "$s: $(taskflow issue list --project "Sprint 1" --status $s --json | jq length)"
done

taskflow-skill 文件

.claude/skills/taskflow/
├── skill.md        # 技能入口(触发条件、能力说明、快速参考)
├── commands.md     # 完整命令参考(参数、输出示例)
└── workflows.md    # 常见工作流(Sprint/Bug/Feature/日报)

开发

前置条件

  • Go 1.22+
  • Make

常用命令

# 构建
make build

# 运行
make run

# 测试
make test

# 清理
make clean

测试

# 运行所有测试
go test -v -race ./...

# 仅运行 model 测试
go test -v ./internal/model/...

# 仅运行 store 测试
go test -v ./internal/store/...

代码统计

模块 文件数 代码行数 说明
model 5 + 1 test ~320 数据模型 + 状态机
store 6 + 5 tests ~1050 SQLite CRUD
cli 7 ~1140 Cobra 命令
tui 7 ~830 Bubble Tea 视图
合计 33 ~3700

许可证

MIT

作者

AlfredChaos

About

A terminal-native project management tool built with Go — a CLI clone of Linear featuring interactive TUI (Bubble Tea), SQLite storage, state-machine-driven issue workflow, and AI agent-friendly JSON output. Zero config, single binary, fully offline.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors