Skip to content

Commit 38ffc2e

Browse files
committed
feat: introduce TaskFlow CLI package with commands, models, storage, and tests, alongside an updated .gitignore.
1 parent 8d3533c commit 38ffc2e

41 files changed

Lines changed: 10245 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/cli.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: TaskFlow CLI CI
2+
3+
on:
4+
push:
5+
branches: [main, 001-cli-core]
6+
paths:
7+
- 'packages/cli/**'
8+
- '.github/workflows/cli.yml'
9+
pull_request:
10+
branches: [main]
11+
paths:
12+
- 'packages/cli/**'
13+
14+
defaults:
15+
run:
16+
working-directory: packages/cli
17+
18+
jobs:
19+
test:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v4
26+
27+
- name: Set up Python 3.13
28+
run: uv python install 3.13
29+
30+
- name: Install dependencies
31+
run: uv sync
32+
33+
- name: Run tests with coverage
34+
run: uv run pytest --cov=src/taskflow --cov-report=xml --cov-fail-under=80
35+
36+
- name: Upload coverage
37+
uses: codecov/codecov-action@v4
38+
with:
39+
file: packages/cli/coverage.xml
40+
continue-on-error: true
41+
42+
lint:
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
- name: Install uv
48+
uses: astral-sh/setup-uv@v4
49+
50+
- name: Set up Python 3.13
51+
run: uv python install 3.13
52+
53+
- name: Install dependencies
54+
run: uv sync
55+
56+
- name: Lint with ruff
57+
run: uv run ruff check .
58+
59+
- name: Format check
60+
run: uv run ruff format --check .
61+
62+
demo:
63+
runs-on: ubuntu-latest
64+
needs: test
65+
steps:
66+
- uses: actions/checkout@v4
67+
68+
- name: Install uv
69+
uses: astral-sh/setup-uv@v4
70+
71+
- name: Set up Python 3.13
72+
run: uv python install 3.13
73+
74+
- name: Install dependencies
75+
run: uv sync
76+
77+
- name: Run demo (must complete <90s)
78+
run: timeout 90 uv run taskflow demo || echo "Demo not yet implemented"

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,15 @@ build/
3737
*.egg-info/
3838
.pytest_cache/
3939
.coverage
40+
coverage.xml
4041
htmlcov/
4142
.mypy_cache/
4243
.ruff_cache/
4344

45+
# TaskFlow CLI
46+
.taskflow/
47+
packages/cli/.venv/
48+
packages/cli/uv.lock
49+
4450
robolearn-interface/
4551
feedback/

packages/cli/.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13

packages/cli/README.md

Whitespace-only changes.

packages/cli/pyproject.toml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[project]
2+
name = "taskflow"
3+
version = "0.1.0"
4+
description = "CLI for TaskFlow - Human-Agent Task Management with Parity"
5+
readme = "README.md"
6+
authors = [
7+
{ name = "mjunaidca", email = "mr.junaidshaukat@gmail.com" }
8+
]
9+
requires-python = ">=3.13"
10+
dependencies = [
11+
"typer>=0.15.0",
12+
"pydantic>=2.10.0",
13+
"rich>=13.9.0",
14+
"prompt-toolkit>=3.0.52",
15+
]
16+
17+
[project.scripts]
18+
taskflow = "taskflow.main:app"
19+
20+
[build-system]
21+
requires = ["hatchling"]
22+
build-backend = "hatchling.build"
23+
24+
[tool.hatch.build.targets.wheel]
25+
packages = ["src/taskflow"]
26+
27+
[tool.uv]
28+
dev-dependencies = [
29+
"pytest>=8.3.0",
30+
"pytest-cov>=6.0.0",
31+
"ruff>=0.8.0",
32+
]
33+
34+
[tool.ruff]
35+
target-version = "py313"
36+
line-length = 100
37+
38+
[tool.ruff.lint]
39+
select = ["E", "F", "I", "UP"]
40+
41+
[tool.pytest.ini_options]
42+
testpaths = ["tests"]
43+
pythonpath = ["src"]
44+
addopts = "-v --tb=short"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""TaskFlow CLI - Human-Agent Task Management with Parity.
2+
3+
A command-line interface for task management that treats human and AI agent
4+
workers identically, proving human-agent parity in task workflows.
5+
"""
6+
7+
__version__ = "0.1.0"
8+
__author__ = "mjunaidca"

packages/cli/src/taskflow/audit.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
"""TaskFlow audit infrastructure for tracking all actions.
2+
3+
Provides functions to:
4+
- Detect actor type (human vs agent)
5+
- Log actions with full context
6+
- Maintain audit trail for accountability
7+
"""
8+
9+
from datetime import datetime
10+
from typing import Any, Literal
11+
12+
from taskflow.models import AuditLog
13+
from taskflow.storage import Storage
14+
15+
16+
def get_actor_type(actor_id: str, storage: Storage) -> Literal["human", "agent"]:
17+
"""Determine if an actor is human or agent.
18+
19+
Args:
20+
actor_id: Worker ID (e.g., @sarah, @claude-code)
21+
storage: Storage instance to look up worker
22+
23+
Returns:
24+
"human" or "agent"
25+
"""
26+
worker = storage.get_worker(actor_id)
27+
if worker is None:
28+
# Default to human if worker not found
29+
return "human"
30+
return worker.type
31+
32+
33+
def log_action(
34+
storage: Storage,
35+
action: str,
36+
actor_id: str,
37+
task_id: int | None = None,
38+
project_slug: str | None = None,
39+
context: dict[str, Any] | None = None,
40+
) -> AuditLog:
41+
"""Log an action to the audit trail.
42+
43+
Creates an audit log entry and persists it to storage.
44+
Automatically determines actor type and generates unique ID.
45+
46+
Args:
47+
storage: Storage instance
48+
action: Action performed (e.g., "created", "started", "completed")
49+
actor_id: Worker ID who performed the action
50+
task_id: Optional task ID if action relates to a task
51+
project_slug: Optional project slug if action relates to a project
52+
context: Optional additional context (e.g., progress %, notes)
53+
54+
Returns:
55+
Created AuditLog entry
56+
"""
57+
# Determine actor type
58+
actor_type = get_actor_type(actor_id, storage)
59+
60+
# Generate next ID
61+
existing_logs = storage.get_audit_logs()
62+
next_id = len(existing_logs) + 1
63+
64+
# Create audit log entry
65+
log = AuditLog(
66+
id=next_id,
67+
task_id=task_id,
68+
project_slug=project_slug,
69+
actor_id=actor_id,
70+
actor_type=actor_type,
71+
action=action,
72+
context=context or {},
73+
timestamp=datetime.now(),
74+
)
75+
76+
# Persist to storage
77+
storage.add_audit_log(log)
78+
79+
return log
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""TaskFlow CLI command modules."""

0 commit comments

Comments
 (0)