chore: migrate from opencode to trellis 0.5.0-rc.6
- Remove legacy .opencode/ directory and configuration - Update .trellis/ to v0.5.0-rc.6 structure - Refactor scripts: modularize common/, remove multi_agent/ - Add new common modules: git.py, io.py, log.py, types.py, etc. - Update workflow.md and AGENTS.md - Archive completed migration tasks
This commit is contained in:
@@ -12,23 +12,32 @@ Provides:
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from .paths import (
|
||||
FILE_TASK_JSON,
|
||||
get_repo_root,
|
||||
get_developer,
|
||||
get_tasks_dir,
|
||||
)
|
||||
from .tasks import iter_active_tasks
|
||||
|
||||
|
||||
def _read_json_file(path: Path) -> dict | None:
|
||||
"""Read and parse a JSON file."""
|
||||
try:
|
||||
return json.loads(path.read_text(encoding="utf-8"))
|
||||
except (FileNotFoundError, json.JSONDecodeError, OSError):
|
||||
return None
|
||||
# =============================================================================
|
||||
# Internal helper
|
||||
# =============================================================================
|
||||
|
||||
def _task_to_dict(t) -> dict:
|
||||
"""Convert TaskInfo to the dict format callers expect."""
|
||||
return {
|
||||
"priority": t.priority,
|
||||
"id": t.raw.get("id", ""),
|
||||
"title": t.title,
|
||||
"status": t.status,
|
||||
"assignee": t.assignee or "-",
|
||||
"dir": t.dir_name,
|
||||
"children": list(t.children),
|
||||
"parent": t.parent,
|
||||
}
|
||||
|
||||
|
||||
# =============================================================================
|
||||
@@ -54,41 +63,10 @@ def list_tasks_by_status(
|
||||
tasks_dir = get_tasks_dir(repo_root)
|
||||
results = []
|
||||
|
||||
if not tasks_dir.is_dir():
|
||||
return results
|
||||
|
||||
for d in tasks_dir.iterdir():
|
||||
if not d.is_dir() or d.name == "archive":
|
||||
for t in iter_active_tasks(tasks_dir):
|
||||
if filter_status and t.status != filter_status:
|
||||
continue
|
||||
|
||||
task_json = d / FILE_TASK_JSON
|
||||
if not task_json.is_file():
|
||||
continue
|
||||
|
||||
data = _read_json_file(task_json)
|
||||
if not data:
|
||||
continue
|
||||
|
||||
task_id = data.get("id", "")
|
||||
title = data.get("title") or data.get("name", "")
|
||||
priority = data.get("priority", "P2")
|
||||
status = data.get("status", "planning")
|
||||
assignee = data.get("assignee", "-")
|
||||
|
||||
# Apply filter
|
||||
if filter_status and status != filter_status:
|
||||
continue
|
||||
|
||||
results.append({
|
||||
"priority": priority,
|
||||
"id": task_id,
|
||||
"title": title,
|
||||
"status": status,
|
||||
"assignee": assignee,
|
||||
"dir": d.name,
|
||||
"children": data.get("children", []),
|
||||
"parent": data.get("parent"),
|
||||
})
|
||||
results.append(_task_to_dict(t))
|
||||
|
||||
return results
|
||||
|
||||
@@ -126,46 +104,12 @@ def list_tasks_by_assignee(
|
||||
tasks_dir = get_tasks_dir(repo_root)
|
||||
results = []
|
||||
|
||||
if not tasks_dir.is_dir():
|
||||
return results
|
||||
|
||||
for d in tasks_dir.iterdir():
|
||||
if not d.is_dir() or d.name == "archive":
|
||||
for t in iter_active_tasks(tasks_dir):
|
||||
if (t.assignee or "-") != assignee:
|
||||
continue
|
||||
|
||||
task_json = d / FILE_TASK_JSON
|
||||
if not task_json.is_file():
|
||||
if filter_status and t.status != filter_status:
|
||||
continue
|
||||
|
||||
data = _read_json_file(task_json)
|
||||
if not data:
|
||||
continue
|
||||
|
||||
task_assignee = data.get("assignee", "-")
|
||||
|
||||
# Apply assignee filter
|
||||
if task_assignee != assignee:
|
||||
continue
|
||||
|
||||
task_id = data.get("id", "")
|
||||
title = data.get("title") or data.get("name", "")
|
||||
priority = data.get("priority", "P2")
|
||||
status = data.get("status", "planning")
|
||||
|
||||
# Apply status filter
|
||||
if filter_status and status != filter_status:
|
||||
continue
|
||||
|
||||
results.append({
|
||||
"priority": priority,
|
||||
"id": task_id,
|
||||
"title": title,
|
||||
"status": status,
|
||||
"assignee": task_assignee,
|
||||
"dir": d.name,
|
||||
"children": data.get("children", []),
|
||||
"parent": data.get("parent"),
|
||||
})
|
||||
results.append(_task_to_dict(t))
|
||||
|
||||
return results
|
||||
|
||||
@@ -211,24 +155,9 @@ def get_task_stats(repo_root: Path | None = None) -> dict[str, int]:
|
||||
tasks_dir = get_tasks_dir(repo_root)
|
||||
stats = {"P0": 0, "P1": 0, "P2": 0, "P3": 0, "Total": 0}
|
||||
|
||||
if not tasks_dir.is_dir():
|
||||
return stats
|
||||
|
||||
for d in tasks_dir.iterdir():
|
||||
if not d.is_dir() or d.name == "archive":
|
||||
continue
|
||||
|
||||
task_json = d / FILE_TASK_JSON
|
||||
if not task_json.is_file():
|
||||
continue
|
||||
|
||||
data = _read_json_file(task_json)
|
||||
if not data:
|
||||
continue
|
||||
|
||||
priority = data.get("priority", "P2")
|
||||
if priority in stats:
|
||||
stats[priority] += 1
|
||||
for t in iter_active_tasks(tasks_dir):
|
||||
if t.priority in stats:
|
||||
stats[t.priority] += 1
|
||||
stats["Total"] += 1
|
||||
|
||||
return stats
|
||||
|
||||
Reference in New Issue
Block a user