Skip to content

Commit 04df2fe

Browse files
committed
refactor: Remove epic/adr types, simplify to tasks-only; fix pre-commit
- Remove task_type parameter from create_task (hardcode "task") - Remove Type display from /task show output - Remove epic/adr/contract/base schema references from docs - Add _get_cached_task_ids with mtime-based cache for tab completion - Fix simplify review issues: stale 'todo' fallback, duplicate session title, redundant find_task after create, hoisted store construction - Remove unused brainfile imports (Task, generateNextFileTaskId, listTasks, moveTaskFile, readTaskFile) - Fix isort import ordering and apply black formatting
1 parent 6a59bda commit 04df2fe

11 files changed

Lines changed: 225 additions & 125 deletions

File tree

cecli/brainfile/store.py

Lines changed: 61 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,18 @@
1818
from typing import Any, Dict, List, Optional
1919

2020
from brainfile import (
21-
Task,
2221
Subtask,
2322
addTaskFile,
2423
completeTaskFile,
2524
deleteTaskFile,
2625
ensureV2Dirs,
2726
findV2Task,
28-
generateNextFileTaskId,
2927
getV2Dirs,
30-
listTasks,
31-
moveTaskFile,
32-
readTaskFile,
3328
readTasksDir,
3429
writeTaskFile,
3530
)
3631
from brainfile.workspace import V2Dirs
3732

38-
3933
# ---------------------------------------------------------------------------
4034
# Constants
4135
# ---------------------------------------------------------------------------
@@ -137,20 +131,23 @@ def list_tasks(self, scope: str = "board") -> List[Dict[str, Any]]:
137131
subtasks = t.subtasks or []
138132
total = len(subtasks)
139133
done = sum(1 for s in subtasks if s.completed)
140-
tasks.append({
141-
"id": t.id,
142-
"title": t.title,
143-
"column": t.column or ("logs" if location == "logs" else "in-progress"),
144-
"location": location,
145-
"subtasks_total": total,
146-
"subtasks_done": done,
147-
"relpath": self.relpath(
148-
os.path.join(
149-
dirs.boardDir if location == "board" else dirs.logsDir,
150-
f"{t.id}.md",
151-
)
152-
),
153-
})
134+
tasks.append(
135+
{
136+
"id": t.id,
137+
"title": t.title,
138+
"column": t.column
139+
or ("logs" if location == "logs" else "in-progress"),
140+
"location": location,
141+
"subtasks_total": total,
142+
"subtasks_done": done,
143+
"relpath": self.relpath(
144+
os.path.join(
145+
dirs.boardDir if location == "board" else dirs.logsDir,
146+
f"{t.id}.md",
147+
)
148+
),
149+
}
150+
)
154151
return tasks
155152

156153
def find_task(self, task_id: str) -> Optional[Dict[str, Any]]:
@@ -178,7 +175,6 @@ def create_task(
178175
self,
179176
title: str,
180177
column: str = "in-progress",
181-
task_type: str = "task",
182178
description: Optional[str] = None,
183179
subtasks: Optional[List[str]] = None,
184180
) -> Dict[str, Any]:
@@ -188,7 +184,7 @@ def create_task(
188184
{
189185
"title": title,
190186
"column": column,
191-
"type": task_type,
187+
"type": "task",
192188
"description": description or "",
193189
"subtasks": subtasks or [],
194190
},
@@ -202,10 +198,10 @@ def create_task(
202198
"id": task.id,
203199
"title": task.title,
204200
"column": task.column,
205-
"type": task.type or "task",
206201
"location": "board",
207202
"path": Path(result["filePath"]),
208203
"relpath": self.relpath(result["filePath"]),
204+
"task": task,
209205
}
210206

211207
def update_task(
@@ -233,6 +229,7 @@ def update_task(
233229

234230
if changed:
235231
from datetime import datetime
232+
236233
updates["updated_at"] = datetime.now().isoformat()
237234
updated_task = task.model_copy(update=updates)
238235
writeTaskFile(str(found["path"]), updated_task, found["body"])
@@ -351,13 +348,10 @@ def get_or_create_session_task(self, coder) -> dict:
351348
task_id = best["id"]
352349
else:
353350
# Create a new task
354-
from datetime import date
355-
356-
title = f"Session {date.today().isoformat()}"
351+
title = self.auto_title(None)
357352
created = self.create_task(title=title, column="in-progress")
358353
task_id = created["id"]
359-
found = self.find_task(task_id)
360-
task = found["task"]
354+
task = created["task"]
361355

362356
# Set active_task_id + update TUI — but do NOT add the file to
363357
# coder context so the agent never sees raw YAML.
@@ -433,11 +427,13 @@ def update_task_subtasks(
433427
title = str(item.get("task", "")).strip()
434428
if not title:
435429
continue
436-
parsed.append({
437-
"title": title,
438-
"completed": bool(item.get("done", False)),
439-
"current": bool(item.get("current", False)),
440-
})
430+
parsed.append(
431+
{
432+
"title": title,
433+
"completed": bool(item.get("done", False)),
434+
"current": bool(item.get("current", False)),
435+
}
436+
)
441437

442438
if not append:
443439
# Reorder: current first, then remaining, then done
@@ -462,20 +458,25 @@ def update_task_subtasks(
462458

463459
for sub in ordered:
464460
max_idx += 1
465-
new_subtasks.append(Subtask(
466-
id=f"{task.id}-{max_idx}",
467-
title=sub["title"],
468-
completed=sub["completed"],
469-
))
461+
new_subtasks.append(
462+
Subtask(
463+
id=f"{task.id}-{max_idx}",
464+
title=sub["title"],
465+
completed=sub["completed"],
466+
)
467+
)
470468

471469
new_column = "in-progress"
472470

473471
from datetime import datetime
474-
updated_task = task.model_copy(update={
475-
"subtasks": new_subtasks,
476-
"column": new_column,
477-
"updated_at": datetime.now().isoformat(),
478-
})
472+
473+
updated_task = task.model_copy(
474+
update={
475+
"subtasks": new_subtasks,
476+
"column": new_column,
477+
"updated_at": datetime.now().isoformat(),
478+
}
479+
)
479480

480481
path = found["path"]
481482
writeTaskFile(str(path), updated_task, found["body"])
@@ -514,7 +515,9 @@ def open_task_in_context(
514515
coder.abs_fnames.add(abs_path)
515516
coder.check_added_files()
516517
if explicit:
517-
coder.io.tool_output(f"Opened task '{found['id']}' as editable: {relpath}")
518+
coder.io.tool_output(
519+
f"Opened task '{found['id']}' as editable: {relpath}"
520+
)
518521
else:
519522
if abs_path in coder.abs_fnames:
520523
coder.abs_fnames.remove(abs_path)
@@ -524,7 +527,9 @@ def open_task_in_context(
524527
raise ValueError(f"Unable to read task file: {relpath}")
525528
coder.abs_read_only_fnames.add(abs_path)
526529
if explicit:
527-
coder.io.tool_output(f"Opened task '{found['id']}' as read-only: {relpath}")
530+
coder.io.tool_output(
531+
f"Opened task '{found['id']}' as read-only: {relpath}"
532+
)
528533

529534
if hasattr(coder, "use_enhanced_context") and coder.use_enhanced_context:
530535
if hasattr(coder, "_calculate_context_block_tokens"):
@@ -569,9 +574,13 @@ def clear_active_task(self, coder) -> None:
569574
set_active_task = getattr(io, "set_active_task", None)
570575
if callable(set_active_task):
571576
set_active_task(
572-
task_id="", title="", column="",
573-
subtasks_done=0, subtasks_total=0,
574-
mode="", location="",
577+
task_id="",
578+
title="",
579+
column="",
580+
subtasks_done=0,
581+
subtasks_total=0,
582+
mode="",
583+
location="",
575584
)
576585

577586
def drop_task_from_context(
@@ -580,7 +589,9 @@ def drop_task_from_context(
580589
task_id: Optional[str] = None,
581590
clear_active: bool = True,
582591
) -> Dict[str, Any]:
583-
target = _normalize_task_id(task_id or getattr(coder, "active_task_id", "") or "")
592+
target = _normalize_task_id(
593+
task_id or getattr(coder, "active_task_id", "") or ""
594+
)
584595
if not target:
585596
raise ValueError("No active task to drop. Use /task drop <task-id>.")
586597

@@ -662,6 +673,6 @@ def render_task_todo_block(self, task_id: str) -> Optional[str]:
662673

663674
total = len(done_tasks) + len(remaining_tasks)
664675
done = len(done_tasks)
665-
result += f"\nActive: {task.title} | {task.column or 'todo'} | {done}/{total}\n"
676+
result += f"\nActive: {task.title} | {task.column or 'in-progress'} | {done}/{total}\n"
666677
result += "</context>"
667678
return result

cecli/coders/agent_coder.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,30 +1193,23 @@ def get_todo_list(self):
11931193
already exists (to avoid creating one before the agent has done anything).
11941194
"""
11951195
try:
1196+
from cecli.brainfile import CecliTaskStore
1197+
1198+
store = CecliTaskStore(self.root)
11961199
active_task_id = getattr(self, "active_task_id", None)
11971200

11981201
# Auto-resume: pick up an incomplete board task if one exists
1199-
if not active_task_id:
1202+
if not active_task_id and store.board_exists():
12001203
try:
1201-
from cecli.brainfile import CecliTaskStore
1202-
1203-
store = CecliTaskStore(self.root)
1204-
if store.board_exists():
1205-
opened = store.get_or_create_session_task(self)
1206-
active_task_id = opened["id"]
1204+
opened = store.get_or_create_session_task(self)
1205+
active_task_id = opened["id"]
12071206
except Exception:
12081207
pass
12091208

12101209
if active_task_id:
1211-
try:
1212-
from cecli.brainfile import CecliTaskStore
1213-
1214-
store = CecliTaskStore(self.root)
1215-
block = store.render_task_todo_block(active_task_id)
1216-
if block:
1217-
return block
1218-
except Exception:
1219-
pass
1210+
block = store.render_task_todo_block(active_task_id)
1211+
if block:
1212+
return block
12201213

12211214
return (
12221215
'<context name="todo_list" from="agent">\n'

cecli/commands/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
from .save import SaveCommand
5656
from .save_session import SaveSessionCommand
5757
from .settings import SettingsCommand
58-
from .terminal_setup import TerminalSetupCommand
5958
from .task import TaskCommand
59+
from .terminal_setup import TerminalSetupCommand
6060
from .test import TestCommand
6161
from .think_tokens import ThinkTokensCommand
6262
from .tokens import TokensCommand

0 commit comments

Comments
 (0)