Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions emdx/commands/briefing.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,19 +432,19 @@ def _briefing_save(hours: int, model: str | None) -> None:
)

if tasks:
done = [t for t in tasks if t["status"] == "done"]
active_tasks = [t for t in tasks if t["status"] == "active"]
blocked = [t for t in tasks if t["status"] == "blocked"]
done = [t for t in tasks if t.status == "done"]
active_tasks = [t for t in tasks if t.status == "active"]
blocked = [t for t in tasks if t.status == "blocked"]
task_lines = []
if done:
task_lines.append("## Completed Tasks")
task_lines.extend(f"- {t['title']}" for t in done[:10])
task_lines.extend(f"- {t.title}" for t in done[:10])
if active_tasks:
task_lines.append("## In-Progress Tasks")
task_lines.extend(f"- {t['title']}" for t in active_tasks[:5])
task_lines.extend(f"- {t.title}" for t in active_tasks[:5])
if blocked:
task_lines.append("## Blocked Tasks")
task_lines.extend(f"- {t['title']}" for t in blocked[:5])
task_lines.extend(f"- {t.title}" for t in blocked[:5])
if task_lines:
sections.append("\n".join(task_lines))

Expand Down
12 changes: 6 additions & 6 deletions emdx/commands/categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ def list_cmd() -> None:

for c in cats:
table.add_row(
c["key"],
c["name"],
str(c["open_count"]),
str(c["done_count"]),
str(c["epic_count"]),
str(c["total_count"]),
c.key,
c.name,
str(c.open_count),
str(c.done_count),
str(c.epic_count),
str(c.total_count),
)

console.print(table)
Expand Down
18 changes: 5 additions & 13 deletions emdx/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,11 +649,7 @@ def _find_list_all(
if json_output:
json_docs = []
for doc in docs:
d: dict[str, Any] = dict(doc)
if d["created_at"]:
d["created_at"] = d["created_at"].isoformat()
if d.get("accessed_at"):
d["accessed_at"] = d["accessed_at"].isoformat()
d = doc.to_dict()
json_docs.append(d)
print(json.dumps(json_docs, indent=2))
return
Expand Down Expand Up @@ -705,11 +701,7 @@ def _find_recent(
if json_output:
json_docs = []
for doc in docs:
d: dict[str, Any] = dict(doc)
if d.get("created_at"):
d["created_at"] = d["created_at"].isoformat()
if d.get("accessed_at"):
d["accessed_at"] = d["accessed_at"].isoformat()
d = doc.to_dict()
json_docs.append(d)
print(json.dumps(json_docs, indent=2))
return
Expand Down Expand Up @@ -884,7 +876,7 @@ def _find_keyword_search(

# Combine: only show documents that match both criteria
results: list[dict[str, Any]] = [
dict(doc) for doc in search_results if doc.id in tag_doc_ids
doc.to_dict() for doc in search_results if doc.id in tag_doc_ids
][:limit]

if not results:
Expand Down Expand Up @@ -918,7 +910,7 @@ def _find_keyword_search(
effective_query = search_query if search_query else "*"

results = [
dict(r)
r.to_dict()
for r in search_documents(
effective_query,
project=project,
Expand Down Expand Up @@ -1675,7 +1667,7 @@ def delete(
if failed:
console.print(f"\n[red]Failed to delete {len(failed)} document(s):[/red]")
for doc in failed:
console.print(f" [dim]• #{doc['id']}: {doc['title']}[/dim]")
console.print(f" [dim]• #{doc.id}: {doc.title}[/dim]")

except typer.Abort:
console.print("[yellow]Deletion cancelled[/yellow]")
Expand Down
48 changes: 23 additions & 25 deletions emdx/commands/epics.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def create(
try:
epic_id = tasks.create_epic(name, cat, description or "")
epic = tasks.get_task(epic_id)
seq = epic["epic_seq"] if epic else None
seq = epic.epic_seq if epic else None
key_label = f"{cat.upper()}-{seq}" if seq else f"#{epic_id}"
id_suffix = f" (#{epic_id})" if seq else ""
console.print(f"[green]Created epic {key_label}{id_suffix}: {name}[/green]")
Expand Down Expand Up @@ -83,16 +83,16 @@ def list_cmd(
table.add_column("Total", justify="right", width=6)

for e in epics:
epic_key = e.get("epic_key") or ""
epic_seq = e.get("epic_seq")
key_label = f"{epic_key}-{epic_seq}" if epic_key and epic_seq else str(e["id"])
epic_key = e.epic_key or ""
epic_seq = e.epic_seq
key_label = f"{epic_key}-{epic_seq}" if epic_key and epic_seq else str(e.id)
table.add_row(
key_label,
e["title"][:40],
e["status"],
str(e["children_open"]),
str(e["children_done"]),
str(e["child_count"]),
e.title[:40],
e.status,
str(e.children_open),
str(e.children_done),
str(e.child_count),
)

console.print(table)
Expand All @@ -114,23 +114,21 @@ def view(
console.print(f"[red]Epic #{epic_id} not found[/red]")
raise typer.Exit(1)

cat_label = f" ({epic['epic_key']})" if epic.get("epic_key") else ""
console.print(
f"\n[bold]Epic #{epic['id']}: {epic['title']}{cat_label}[/bold] — {epic['status']}"
)
if epic.get("description"):
console.print(f"[dim]{epic['description']}[/dim]")
console.print(f"[dim]Created: {epic.get('created_at', 'unknown')}[/dim]\n")
cat_label = f" ({epic.epic_key})" if epic.epic_key else ""
console.print(f"\n[bold]Epic #{epic.id}: {epic.title}{cat_label}[/bold] — {epic.status}")
if epic.description:
console.print(f"[dim]{epic.description}[/dim]")
console.print(f"[dim]Created: {epic.created_at or 'unknown'}[/dim]\n")

children = epic.get("children", [])
children = epic.children
if children:
console.print("[bold]Tasks:[/bold]")
done_count = 0
for c in children:
icon = ICONS.get(c["status"], "?")
seq_label = f"{c['epic_key']}-{c['epic_seq']}" if c.get("epic_seq") else f"#{c['id']}"
console.print(f" {icon} {seq_label} {c['title']}")
if c["status"] == "done":
icon = ICONS.get(c.status, "?")
seq_label = f"{c.epic_key}-{c.epic_seq}" if c.epic_seq else f"#{c.id}"
console.print(f" {icon} {seq_label} {c.title}")
if c.status == "done":
done_count += 1
console.print(f"\n[dim]Progress: {done_count}/{len(children)} done[/dim]")
else:
Expand Down Expand Up @@ -181,7 +179,7 @@ def done(
raise typer.Exit(1)

tasks.update_task(epic_id, status="done")
console.print(f"[green]✓ Done:[/green] Epic #{epic_id} {epic['title']}")
console.print(f"[green]✓ Done:[/green] Epic #{epic_id} {epic.title}")


@app.command()
Expand All @@ -201,7 +199,7 @@ def active(
raise typer.Exit(1)

tasks.update_task(epic_id, status="active")
console.print(f"[green]● Active:[/green] Epic #{epic_id} {epic['title']}")
console.print(f"[green]● Active:[/green] Epic #{epic_id} {epic.title}")


TASK_ID_HELP = "Task ID (e.g. 42 or TOOL-12)"
Expand Down Expand Up @@ -239,7 +237,7 @@ def attach(

epic_task = tasks.get_task(epic_id)
epic_label = f"#{epic_id}"
if epic_task and epic_task.get("epic_key") and epic_task.get("epic_seq"):
epic_label = f"{epic_task['epic_key']}-{epic_task['epic_seq']}"
if epic_task and epic_task.epic_key and epic_task.epic_seq:
epic_label = f"{epic_task.epic_key}-{epic_task.epic_seq}"

console.print(f"[green]✅ Attached {count} task(s) to epic {epic_label}[/green]")
12 changes: 6 additions & 6 deletions emdx/commands/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ def _serialize(obj: Any) -> Any:
def _find_recent(params: dict[str, Any]) -> list[dict[str, Any]]:
limit = params.get("limit", 20)
rows = get_recent_documents(limit=limit)
return [dict(r) for r in rows]
return [r.to_dict() for r in rows]


def _find_search(params: dict[str, Any]) -> list[dict[str, Any]]:
query = params["query"]
limit = params.get("limit", 10)
rows = search_documents(query, limit=limit)
return [dict(r) for r in rows]
return [r.to_dict() for r in rows]


def _find_by_tags(params: dict[str, Any]) -> list[dict[str, Any]]:
Expand All @@ -80,7 +80,7 @@ def _view_document(params: dict[str, Any]) -> dict[str, Any] | None:
row = get_document(doc_id)
if row is None:
return None
result = dict(row)
result = row.to_dict()
# Get tags for the document
from emdx.models.tags import get_document_tags

Expand Down Expand Up @@ -127,14 +127,14 @@ def _task_list(params: dict[str, Any]) -> list[dict[str, Any]]:
limit = params.get("limit", 200)
status_list = [status] if status else None
rows = list_tasks(status=status_list, epic_key=epic_key, limit=limit)
return [dict(r) for r in rows]
return [r.to_dict() for r in rows]


def _task_log(params: dict[str, Any]) -> list[dict[str, Any]]:
task_id = params["id"]
limit = params.get("limit", 50)
rows = get_task_log(task_id, limit=limit)
return [dict(r) for r in rows]
return [r.to_dict() for r in rows]


def _task_update(params: dict[str, Any]) -> dict[str, Any]:
Expand All @@ -155,7 +155,7 @@ def _task_log_progress(params: dict[str, Any]) -> dict[str, Any]:
def _status(params: dict[str, Any]) -> dict[str, Any]:
tasks = list_tasks(limit=20)
return {
"tasks": [dict(t) for t in tasks],
"tasks": [t.to_dict() for t in tasks],
}


Expand Down
Loading
Loading