tasktree-manager 2.16.1__tar.gz → 2.17.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/CHANGELOG.md +6 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/PKG-INFO +1 -1
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/README.md +12 -2
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/docs/user-guide.md +16 -1
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/pyproject.toml +1 -1
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tasktree_manager/_version.py +2 -2
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tasktree_manager/cli.py +183 -2
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tasktree_manager/services/claude_sessions.py +82 -9
- tasktree_manager-2.17.0/tasktree_manager/services/epic_log.py +105 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tasktree_manager/services/task_manager.py +188 -2
- tasktree_manager-2.17.0/tests/test_epic_log.py +438 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/.claude/skills/textual-tui/SKILL.md +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/.claude/skills/textual-tui/assets/README.md +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/.claude/skills/textual-tui/assets/dashboard_app.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/.claude/skills/textual-tui/assets/data_viewer.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/.claude/skills/textual-tui/assets/todo_app.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/.claude/skills/textual-tui/assets/worker_demo.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/.claude/skills/textual-tui/references/layouts.md +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/.claude/skills/textual-tui/references/official-guides-index.md +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/.claude/skills/textual-tui/references/styling.md +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/.claude/skills/textual-tui/references/widgets.md +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/.github/templates/CHANGELOG.md.j2 +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/.github/workflows/ci.yml +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/.github/workflows/release.yml +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/.gitignore +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/CONTRIBUTING.md +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/LICENSE +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/ROADMAP.md +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/docs/claude-code-integration-spec.md +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/docs/configuration.md +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/docs/installation.md +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/docs/troubleshooting.md +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/mise.toml +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/scripts/bump_version.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tasktree_manager/__init__.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tasktree_manager/app.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tasktree_manager/commands.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tasktree_manager/services/__init__.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tasktree_manager/services/agent_sessions.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tasktree_manager/services/claude_hooks.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tasktree_manager/services/config.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tasktree_manager/services/forge.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tasktree_manager/services/git_ops.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tasktree_manager/services/models.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tasktree_manager/themes.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tasktree_manager/widgets/__init__.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tasktree_manager/widgets/app_header.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tasktree_manager/widgets/create_modal.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tasktree_manager/widgets/messages_panel.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tasktree_manager/widgets/setup_modal.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tasktree_manager/widgets/status_panel.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tasktree_manager/widgets/task_list.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tasktree_manager/widgets/worktree_list.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/__init__.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/conftest.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_agent_sessions.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_agent_sessions_decode.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_app.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_app_review_fixes.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_bump_version.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_claude_hooks.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_claude_sessions.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_cli.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_commands.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_config.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_epic_claude_md.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_epic_tui.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_epics.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_forge.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_git_ops.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_integration_git.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_list_selection.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_medium_fixes.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_memory.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_messages_panel.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_modals.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_safety_fixes.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_setup_modal.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_status_panel.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_task_manager.py +0 -0
- {tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tests/test_worktree_badges.py +0 -0
|
@@ -15,6 +15,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
15
15
|
- Git hooks support
|
|
16
16
|
- Custom task metadata
|
|
17
17
|
|
|
18
|
+
## [2.17.0] - 2026-10-20
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
- **epic**: Add an epic log for notes shared across task sessions (#13)
|
|
22
|
+
|
|
23
|
+
|
|
18
24
|
## [2.16.1] - 2026-10-19
|
|
19
25
|
|
|
20
26
|
### Fixed
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
- 🛰️ **Agent Dashboard** - Live Claude Code session state per worktree (from `claude agents`), plus one-key background-agent dispatch — the multi-repo agent view Claude Code lacks natively
|
|
23
23
|
- ✻ **Session Recap** - The Info panel shows each task's latest Claude Code session: title, last turn duration, and Claude's own idle recap of what was done and what comes next — read straight from the transcript, no CLI call
|
|
24
24
|
- 🔀 **Forge-Aware Safety** - MR/PR and CI state via `glab`/`gh`; squash- and rebase-merged branches count as merged instead of blocking deletion forever
|
|
25
|
-
- 🗂️ **Epics** - Group related tasks under an epic: a foldable row with rolled-up dirty and Claude state, `E` to attach tasks
|
|
25
|
+
- 🗂️ **Epics** - Group related tasks under an epic: a foldable row with rolled-up dirty and Claude state, `E` to attach tasks, and an epic log where the Claude sessions of one epic share notes
|
|
26
26
|
- 📦 **Finish Flow with Archives** - Ending a task saves its combined diff (committed-but-unmerged + uncommitted) and the task-folder files outside the worktrees (plans, ADRs, notes) to an archive before deleting
|
|
27
27
|
|
|
28
28
|
## 📊 Status Indicators
|
|
@@ -100,10 +100,20 @@ tasktree-manager epic add DIC-2466-pcaps-epic DIC-2862-pcaps-s3 # attach or mov
|
|
|
100
100
|
tasktree-manager epic remove DIC-2862-pcaps-s3 # detach
|
|
101
101
|
tasktree-manager epic mark DIC-2466-pcaps-epic # turn an existing task into an epic; unmark reverts
|
|
102
102
|
tasktree-manager epic list # epics and their tasks; also --json
|
|
103
|
+
tasktree-manager epic note "chose layout A for the S3 keys" # add a note to this task's file in the epic log
|
|
104
|
+
tasktree-manager epic log # notes and latest session recap of every task in the epic
|
|
105
|
+
tasktree-manager epic log DIC-2862-pcaps-s3 --json # one task (or a whole epic by its name), as JSON
|
|
106
|
+
tasktree-manager epic sync # refresh the CLAUDE.md epic block after an upgrade
|
|
103
107
|
```
|
|
104
108
|
|
|
105
109
|
Each task's `CLAUDE.md` gets a managed block naming its epic and how to find sibling
|
|
106
|
-
tasks; it follows every epic change and leaves the rest of the file alone.
|
|
110
|
+
tasks; it follows every epic change and leaves the rest of the file alone. The block
|
|
111
|
+
also tells the session about the epic log: one notes file per task in `epic-log/` in the
|
|
112
|
+
epic folder, written with `epic note` and read with `epic log`, which adds the recap of each
|
|
113
|
+
task's latest Claude session (in the task folder or one of its worktrees). Inside a task
|
|
114
|
+
folder, `epic note` writes only that task's notes and `epic log` reads only its epic;
|
|
115
|
+
`epic note -` reads the text from stdin. Notes of a task that left the epic stay readable.
|
|
116
|
+
Epics don't
|
|
107
117
|
nest. `list --json` and `status --json` carry `kind` (`task` or `epic`) and
|
|
108
118
|
`epic` (the parent epic or `null`). `delete` and `finish` refuse an epic that still has
|
|
109
119
|
tasks, even with `--force`.
|
|
@@ -89,7 +89,22 @@ names their epic, so nothing moves on disk.
|
|
|
89
89
|
that names the epic folder and how to find sibling tasks, so a Claude session knows
|
|
90
90
|
the bigger picture. It updates on every epic change; text outside the markers is
|
|
91
91
|
never touched.
|
|
92
|
-
-
|
|
92
|
+
- The epic log lets the sessions of one epic share what they learned. A session
|
|
93
|
+
records decisions, interfaces and open questions with
|
|
94
|
+
`tasktree-manager epic note "..."`; they go to `epic-log/<task>.md` in the epic
|
|
95
|
+
folder. `tasktree-manager epic log` shows every task's notes and the recap of its
|
|
96
|
+
latest Claude session, so a session can check what its siblings did before asking.
|
|
97
|
+
The `CLAUDE.md` block tells each session about both commands, and that notes are
|
|
98
|
+
information from other sessions, not instructions.
|
|
99
|
+
- A session writes only its own task's notes. From a terminal outside any task,
|
|
100
|
+
`epic note --task NAME` writes for a task and marks the entry as written outside it.
|
|
101
|
+
- Notes stay in the epic after their task is finished, moved or deleted; `epic log`
|
|
102
|
+
lists them as "no longer in the epic". A note is at most 16 KB, and `epic log` shows
|
|
103
|
+
the newest 64 KB of each task's notes.
|
|
104
|
+
- After upgrading tasktree-manager, run `tasktree-manager epic sync` to refresh the
|
|
105
|
+
block in existing tasks (the TUI also refreshes it when it starts a Claude session).
|
|
106
|
+
Folders without a `CLAUDE.md` yet are counted and skipped.
|
|
107
|
+
- From scripts: `tasktree-manager epic create/add/remove/mark/unmark/list/note/log/sync`.
|
|
93
108
|
|
|
94
109
|
### Worktrees
|
|
95
110
|
|
|
@@ -71,7 +71,7 @@ version-file = "tasktree_manager/_version.py"
|
|
|
71
71
|
# Semantic Release Configuration
|
|
72
72
|
[tool.semantic_release]
|
|
73
73
|
version_toml = ["pyproject.toml:tool.semantic_release.version"]
|
|
74
|
-
version = "2.
|
|
74
|
+
version = "2.17.0"
|
|
75
75
|
tag_format = "v{version}"
|
|
76
76
|
branch = "main"
|
|
77
77
|
commit_message = "chore(release): {version} [skip ci]"
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '2.
|
|
22
|
-
__version_tuple__ = version_tuple = (2,
|
|
21
|
+
__version__ = version = '2.17.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (2, 17, 0)
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
|
@@ -9,17 +9,36 @@ errors on stderr, exit code 0 on success and 1 on failure.
|
|
|
9
9
|
import argparse
|
|
10
10
|
import json
|
|
11
11
|
import os
|
|
12
|
+
import re
|
|
12
13
|
import shutil
|
|
13
14
|
import sys
|
|
15
|
+
from datetime import timezone
|
|
14
16
|
from pathlib import Path
|
|
15
17
|
|
|
16
18
|
from . import __version__
|
|
17
19
|
from .services import forge
|
|
18
20
|
from .services.config import Config, ConfigError
|
|
21
|
+
from .services.epic_log import (
|
|
22
|
+
EPIC_ROLE,
|
|
23
|
+
FORMER_ROLE,
|
|
24
|
+
EpicLogEntry,
|
|
25
|
+
read_epic_log,
|
|
26
|
+
resolve_log_target,
|
|
27
|
+
)
|
|
19
28
|
from .services.git_ops import GitOps
|
|
20
|
-
from .services.models import
|
|
29
|
+
from .services.models import (
|
|
30
|
+
EPIC_KIND,
|
|
31
|
+
TASK_KIND,
|
|
32
|
+
ArchiveResult,
|
|
33
|
+
Task,
|
|
34
|
+
parent_epic_name,
|
|
35
|
+
same_folder,
|
|
36
|
+
)
|
|
21
37
|
from .services.task_manager import ARCHIVE_NOTES_SHOWN, ArchiveIncompleteError, TaskManager
|
|
22
38
|
|
|
39
|
+
# C0/C1 controls except tab; notes are split on newlines before this runs
|
|
40
|
+
_CONTROL_CHARS = re.compile(r"[\x00-\x08\x0a-\x1f\x7f-\x9f]")
|
|
41
|
+
|
|
23
42
|
|
|
24
43
|
def build_parser() -> argparse.ArgumentParser:
|
|
25
44
|
"""Build the argument parser for the headless CLI."""
|
|
@@ -79,6 +98,31 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
79
98
|
epic_list.add_argument("--json", action="store_true", dest="as_json", help="Output JSON")
|
|
80
99
|
epic_list.set_defaults(func=cmd_epic_list)
|
|
81
100
|
|
|
101
|
+
epic_note = epic_sub.add_parser("note", help="Add a note to this task's file in the epic log")
|
|
102
|
+
epic_note.add_argument("text", help='Note text ("-" reads it from stdin)')
|
|
103
|
+
epic_note.add_argument(
|
|
104
|
+
"--task", default=None, help="Task that writes the note (default: inferred from $PWD)"
|
|
105
|
+
)
|
|
106
|
+
epic_note.set_defaults(func=cmd_epic_note)
|
|
107
|
+
|
|
108
|
+
epic_log = epic_sub.add_parser(
|
|
109
|
+
"log", help="Show the notes and latest session recap of tasks in an epic"
|
|
110
|
+
)
|
|
111
|
+
epic_log.add_argument(
|
|
112
|
+
"task",
|
|
113
|
+
nargs="?",
|
|
114
|
+
default=None,
|
|
115
|
+
help="One task of the epic (default: the epic of $PWD and all its tasks)",
|
|
116
|
+
)
|
|
117
|
+
epic_log.add_argument("--json", action="store_true", dest="as_json", help="Output JSON")
|
|
118
|
+
epic_log.set_defaults(func=cmd_epic_log)
|
|
119
|
+
|
|
120
|
+
epic_sync = epic_sub.add_parser(
|
|
121
|
+
"sync", help="Refresh the epic block in the CLAUDE.md of epics and their tasks"
|
|
122
|
+
)
|
|
123
|
+
epic_sync.add_argument("name", nargs="?", default=None, help="Epic name (default: all)")
|
|
124
|
+
epic_sync.set_defaults(func=cmd_epic_sync)
|
|
125
|
+
|
|
82
126
|
list_parser = sub.add_parser("list", help="List tasks with their repos and dirty state")
|
|
83
127
|
list_parser.add_argument("--json", action="store_true", dest="as_json", help="Output JSON")
|
|
84
128
|
list_parser.set_defaults(func=cmd_list)
|
|
@@ -335,6 +379,142 @@ def cmd_epic_list(manager: TaskManager, config: Config, args: argparse.Namespace
|
|
|
335
379
|
return 0
|
|
336
380
|
|
|
337
381
|
|
|
382
|
+
def cmd_epic_note(manager: TaskManager, config: Config, args: argparse.Namespace) -> int:
|
|
383
|
+
"""Append a note to the task's file in its epic log.
|
|
384
|
+
|
|
385
|
+
Inside a task folder a session writes only its own notes; from outside
|
|
386
|
+
any task, `--task` writes and the heading records that.
|
|
387
|
+
"""
|
|
388
|
+
caller = _find_task_by_cwd(manager)
|
|
389
|
+
source = None
|
|
390
|
+
if args.task:
|
|
391
|
+
task = manager.get_task(args.task)
|
|
392
|
+
if task is None:
|
|
393
|
+
return _error(f"no such task: {args.task}")
|
|
394
|
+
if caller is None:
|
|
395
|
+
source = "written outside the task folder"
|
|
396
|
+
elif not same_folder(caller.path, task.path):
|
|
397
|
+
return _error(f"inside task {caller.name}: notes go to its own file, not {task.name}")
|
|
398
|
+
elif caller is None:
|
|
399
|
+
return _error("not inside a task directory; pass --task")
|
|
400
|
+
else:
|
|
401
|
+
task = caller
|
|
402
|
+
text = sys.stdin.read() if args.text == "-" else args.text
|
|
403
|
+
path = manager.append_epic_note(task, text, source=source)
|
|
404
|
+
print(f"Noted in {path}")
|
|
405
|
+
return 0
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
def cmd_epic_log(manager: TaskManager, config: Config, args: argparse.Namespace) -> int:
|
|
409
|
+
"""Show notes and the latest session recap of one task or a whole epic."""
|
|
410
|
+
epic, only = resolve_log_target(manager, _find_task_by_cwd(manager), args.task)
|
|
411
|
+
entries = read_epic_log(manager, epic, only)
|
|
412
|
+
for entry in entries:
|
|
413
|
+
if entry.problem:
|
|
414
|
+
print(f"warning: {entry.task}: {entry.problem}", file=sys.stderr)
|
|
415
|
+
if args.as_json:
|
|
416
|
+
print(json.dumps([_epic_log_json(entry) for entry in entries], indent=2))
|
|
417
|
+
return 0
|
|
418
|
+
for index, entry in enumerate(entries):
|
|
419
|
+
if index:
|
|
420
|
+
print()
|
|
421
|
+
_print_epic_log_entry(entry)
|
|
422
|
+
return 0
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
def _epic_log_json(entry: EpicLogEntry) -> dict:
|
|
426
|
+
session = None
|
|
427
|
+
if entry.session is not None:
|
|
428
|
+
recap = entry.recap
|
|
429
|
+
session = {
|
|
430
|
+
"id": entry.session.session_id,
|
|
431
|
+
"cwd": str(entry.session.cwd),
|
|
432
|
+
"title": recap.title if recap else None,
|
|
433
|
+
"finished_at": recap.finished_at.isoformat() if recap and recap.finished_at else None,
|
|
434
|
+
"summary": recap.summary if recap else None,
|
|
435
|
+
# The typed prompt only stands in for a missing recap, as in the TUI
|
|
436
|
+
"last_prompt": recap.last_prompt if recap and not recap.summary else None,
|
|
437
|
+
}
|
|
438
|
+
return {
|
|
439
|
+
"task": entry.task,
|
|
440
|
+
"role": entry.role,
|
|
441
|
+
"notes_path": str(entry.notes_path),
|
|
442
|
+
"notes": entry.notes,
|
|
443
|
+
"notes_truncated": entry.notes_truncated,
|
|
444
|
+
"session": session,
|
|
445
|
+
"problem": entry.problem,
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
def _print_epic_log_entry(entry: EpicLogEntry) -> None:
|
|
450
|
+
role = {EPIC_ROLE: " (epic)", FORMER_ROLE: " (no longer in the epic)"}.get(entry.role, "")
|
|
451
|
+
print(f"== {entry.task}{role} ==")
|
|
452
|
+
recap = entry.recap
|
|
453
|
+
if entry.role == FORMER_ROLE:
|
|
454
|
+
pass
|
|
455
|
+
elif recap is None:
|
|
456
|
+
print("Last session: none recorded")
|
|
457
|
+
else:
|
|
458
|
+
when = "time unknown"
|
|
459
|
+
if recap.finished_at:
|
|
460
|
+
when = recap.finished_at.astimezone(timezone.utc).strftime("%Y-%m-%d %H:%M UTC")
|
|
461
|
+
print(f"Last session: {recap.title} ({when})")
|
|
462
|
+
if recap.summary:
|
|
463
|
+
print(f" Recap: {recap.summary}")
|
|
464
|
+
elif recap.last_prompt:
|
|
465
|
+
print(f" Last prompt: {recap.last_prompt}")
|
|
466
|
+
if not entry.notes:
|
|
467
|
+
print("Notes: none yet")
|
|
468
|
+
return
|
|
469
|
+
cut = ", older notes cut" if entry.notes_truncated else ""
|
|
470
|
+
print(f"Notes ({entry.notes_path}{cut}):")
|
|
471
|
+
# Indented, so a note cannot forge a "== task ==" line; controls dropped
|
|
472
|
+
for line in _safe_lines(entry.notes.rstrip()):
|
|
473
|
+
print(f" {line}" if line else "")
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
def _safe_lines(text: str) -> list[str]:
|
|
477
|
+
return [_CONTROL_CHARS.sub("", line) for line in text.split("\n")]
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
def cmd_epic_sync(manager: TaskManager, config: Config, args: argparse.Namespace) -> int:
|
|
481
|
+
"""Refresh the CLAUDE.md epic block of epics and their tasks."""
|
|
482
|
+
if args.name:
|
|
483
|
+
epic = manager.get_task(args.name)
|
|
484
|
+
if epic is None:
|
|
485
|
+
return _error(f"no such epic: {args.name}")
|
|
486
|
+
if manager.epic_of(epic) != epic.name:
|
|
487
|
+
return _error(f"{epic.name} is not an epic")
|
|
488
|
+
epics = [epic.name]
|
|
489
|
+
else:
|
|
490
|
+
epics = [task.name for task in manager.list_tasks() if manager.epic_of(task) == task.name]
|
|
491
|
+
synced = missing = failed = 0
|
|
492
|
+
for name in epics:
|
|
493
|
+
for member in [name, *manager.epic_child_names(name)]:
|
|
494
|
+
try:
|
|
495
|
+
task = manager.get_task(member)
|
|
496
|
+
except (OSError, ValueError) as e:
|
|
497
|
+
print(f"warning: {member}: {e}", file=sys.stderr)
|
|
498
|
+
failed += 1
|
|
499
|
+
continue
|
|
500
|
+
if task is None:
|
|
501
|
+
continue
|
|
502
|
+
if not (task.path / "CLAUDE.md").is_file():
|
|
503
|
+
missing += 1
|
|
504
|
+
continue
|
|
505
|
+
problem = manager.sync_epic_block(task)
|
|
506
|
+
if problem:
|
|
507
|
+
print(f"warning: {problem}", file=sys.stderr)
|
|
508
|
+
failed += 1
|
|
509
|
+
else:
|
|
510
|
+
synced += 1
|
|
511
|
+
print(
|
|
512
|
+
f"Synced {synced} folder(s); {missing} without CLAUDE.md "
|
|
513
|
+
f"(written when a Claude session starts there from the TUI); {failed} failed"
|
|
514
|
+
)
|
|
515
|
+
return 1 if failed else 0
|
|
516
|
+
|
|
517
|
+
|
|
338
518
|
def _refuse_epic_with_children(manager: TaskManager, task: Task, verb: str) -> bool:
|
|
339
519
|
"""Print an error and return True if `task` is an epic that still has tasks.
|
|
340
520
|
|
|
@@ -545,7 +725,8 @@ def cmd_add_repo(manager: TaskManager, config: Config, args: argparse.Namespace)
|
|
|
545
725
|
def _find_task_by_cwd(manager: TaskManager) -> Task | None:
|
|
546
726
|
"""Find the task whose directory contains the current working directory."""
|
|
547
727
|
cwd = Path.cwd().resolve()
|
|
548
|
-
|
|
728
|
+
# A symlink alias resolves to the same folder: the real folder wins
|
|
729
|
+
for task in sorted(manager.list_tasks(), key=lambda task: task.path.is_symlink()):
|
|
549
730
|
task_path = task.path.resolve()
|
|
550
731
|
if cwd == task_path or cwd.is_relative_to(task_path):
|
|
551
732
|
return task
|
{tasktree_manager-2.16.1 → tasktree_manager-2.17.0}/tasktree_manager/services/claude_sessions.py
RENAMED
|
@@ -14,6 +14,7 @@ costs one bounded read regardless of its length.
|
|
|
14
14
|
import json
|
|
15
15
|
import os
|
|
16
16
|
import re
|
|
17
|
+
from collections.abc import Iterable
|
|
17
18
|
from dataclasses import dataclass
|
|
18
19
|
from datetime import datetime, tzinfo
|
|
19
20
|
from pathlib import Path
|
|
@@ -23,6 +24,8 @@ from .claude_hooks import project_dir_candidates
|
|
|
23
24
|
RECAP_SUFFIX = "(disable recaps in /config)"
|
|
24
25
|
TAIL_WINDOW = 1 << 20
|
|
25
26
|
TAIL_WINDOW_RETRY = 4 << 20
|
|
27
|
+
# Most a session-folder lookup reads from the start of a transcript
|
|
28
|
+
HEAD_BUDGET = 16 << 20
|
|
26
29
|
# Turns that span a laptop sleep report days of "duration"; anything above
|
|
27
30
|
# an hour is noise rather than work time
|
|
28
31
|
DURATION_CAP_MS = 3_600_000
|
|
@@ -56,13 +59,22 @@ class ClaudeRecap:
|
|
|
56
59
|
last_prompt: str | None
|
|
57
60
|
|
|
58
61
|
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
@dataclass(frozen=True)
|
|
63
|
+
class SessionRef:
|
|
64
|
+
"""A transcript and the folder its session was started in."""
|
|
61
65
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
path: Path
|
|
67
|
+
cwd: Path
|
|
68
|
+
mtime_ns: int
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
def session_id(self) -> str:
|
|
72
|
+
return self.path.stem
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _transcripts(folder: Path) -> list[tuple[int, int, Path]]:
|
|
76
|
+
"""``(mtime_ns, size, path)`` of every transcript in a folder's project dirs."""
|
|
77
|
+
found = []
|
|
66
78
|
for project_dir in project_dir_candidates(folder):
|
|
67
79
|
try:
|
|
68
80
|
entries = list(os.scandir(project_dir))
|
|
@@ -77,15 +89,76 @@ def transcript_key(folder: Path) -> tuple[Path, int, int] | None:
|
|
|
77
89
|
# Claude prunes old transcripts at startup; one can vanish
|
|
78
90
|
# between the scandir and the stat
|
|
79
91
|
continue
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
92
|
+
found.append((stat.st_mtime_ns, stat.st_size, Path(entry.path)))
|
|
93
|
+
return found
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def transcript_key(folder: Path) -> tuple[Path, int, int] | None:
|
|
97
|
+
"""Return ``(path, mtime_ns, size)`` of the newest transcript for a folder.
|
|
98
|
+
|
|
99
|
+
One ``scandir`` per candidate project dir and no file reads, so callers
|
|
100
|
+
can poll it to detect changes cheaply.
|
|
101
|
+
"""
|
|
102
|
+
newest = max(_transcripts(folder), key=lambda found: found[0], default=None)
|
|
83
103
|
if newest is None:
|
|
84
104
|
return None
|
|
85
105
|
mtime_ns, size, path = newest
|
|
86
106
|
return path, mtime_ns, size
|
|
87
107
|
|
|
88
108
|
|
|
109
|
+
def transcript_cwd(path: Path) -> Path | None:
|
|
110
|
+
"""The folder a session started in: the first ``cwd`` in its transcript.
|
|
111
|
+
|
|
112
|
+
Whole records are read, since ``cwd`` follows the message body; a first
|
|
113
|
+
prompt bigger than HEAD_BUDGET leaves the cwd unknown.
|
|
114
|
+
"""
|
|
115
|
+
try:
|
|
116
|
+
with open(path, "rb") as f:
|
|
117
|
+
budget = HEAD_BUDGET
|
|
118
|
+
while budget > 0:
|
|
119
|
+
line = f.readline(budget)
|
|
120
|
+
if not line:
|
|
121
|
+
return None
|
|
122
|
+
budget -= len(line)
|
|
123
|
+
if b'"cwd"' not in line:
|
|
124
|
+
continue
|
|
125
|
+
try:
|
|
126
|
+
record = json.loads(line)
|
|
127
|
+
except ValueError:
|
|
128
|
+
continue
|
|
129
|
+
cwd = record.get("cwd") if isinstance(record, dict) else None
|
|
130
|
+
if isinstance(cwd, str) and cwd:
|
|
131
|
+
return Path(cwd)
|
|
132
|
+
except OSError:
|
|
133
|
+
return None
|
|
134
|
+
return None
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def latest_session(folders: Iterable[Path]) -> SessionRef | None:
|
|
138
|
+
"""The newest session started in one of `folders` (a task and its worktrees).
|
|
139
|
+
|
|
140
|
+
Project dir names fold every non-alphanumeric character, so `X/1` and `X-1`
|
|
141
|
+
share one dir; a transcript counts only when its recorded cwd is the folder.
|
|
142
|
+
"""
|
|
143
|
+
candidates = [
|
|
144
|
+
(mtime_ns, str(path), path, folder)
|
|
145
|
+
for folder in folders
|
|
146
|
+
for mtime_ns, _size, path in _transcripts(folder)
|
|
147
|
+
]
|
|
148
|
+
for mtime_ns, _key, path, folder in sorted(candidates, reverse=True):
|
|
149
|
+
cwd = transcript_cwd(path)
|
|
150
|
+
if cwd is not None and _same_dir(cwd, folder):
|
|
151
|
+
return SessionRef(path=path, cwd=folder, mtime_ns=mtime_ns)
|
|
152
|
+
return None
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def _same_dir(a: Path, b: Path) -> bool:
|
|
156
|
+
try:
|
|
157
|
+
return os.path.samefile(a, b)
|
|
158
|
+
except OSError:
|
|
159
|
+
return os.path.realpath(a) == os.path.realpath(b)
|
|
160
|
+
|
|
161
|
+
|
|
89
162
|
def read_claude_recap(path: Path) -> ClaudeRecap | None:
|
|
90
163
|
"""Read the recap from one transcript (see ``transcript_key`` to pick it)."""
|
|
91
164
|
try:
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"""The epic log: each task's notes plus the recap of its latest Claude session.
|
|
2
|
+
|
|
3
|
+
Sessions of one epic read it to learn what the other tasks decided. The scope
|
|
4
|
+
rule lives here so every reader applies it the same way: from inside a task of
|
|
5
|
+
an epic, only that epic can be read.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from dataclasses import dataclass
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
from .claude_sessions import ClaudeRecap, SessionRef, latest_session, read_claude_recap
|
|
12
|
+
from .models import Task
|
|
13
|
+
from .task_manager import TaskManager
|
|
14
|
+
|
|
15
|
+
EPIC_ROLE = "epic"
|
|
16
|
+
MEMBER_ROLE = "task"
|
|
17
|
+
# A notes file left by a task that is no longer in the epic (finished, moved)
|
|
18
|
+
FORMER_ROLE = "former"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@dataclass(frozen=True)
|
|
22
|
+
class EpicLogEntry:
|
|
23
|
+
"""One task's part of the epic log."""
|
|
24
|
+
|
|
25
|
+
task: str
|
|
26
|
+
role: str
|
|
27
|
+
notes_path: Path
|
|
28
|
+
notes: str | None
|
|
29
|
+
notes_truncated: bool
|
|
30
|
+
session: SessionRef | None
|
|
31
|
+
recap: ClaudeRecap | None
|
|
32
|
+
problem: str | None = None # why the task's sessions could not be read
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def caller_epic(manager: TaskManager, caller: Task | None) -> str | None:
|
|
36
|
+
"""The epic of the task the command runs in, or None outside an epic."""
|
|
37
|
+
return manager.epic_of(caller) if caller is not None else None
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def resolve_log_target(
|
|
41
|
+
manager: TaskManager, caller: Task | None, name: str | None
|
|
42
|
+
) -> tuple[str, str | None]:
|
|
43
|
+
"""``(epic, task)`` to read: `task` None means the whole epic.
|
|
44
|
+
|
|
45
|
+
Raises ValueError for a task outside any epic, or outside the caller's.
|
|
46
|
+
"""
|
|
47
|
+
scope = caller_epic(manager, caller)
|
|
48
|
+
if name is None:
|
|
49
|
+
if scope is None:
|
|
50
|
+
raise ValueError("not inside a task of an epic; pass a task name")
|
|
51
|
+
return scope, None
|
|
52
|
+
target = manager.get_task(name)
|
|
53
|
+
if target is None:
|
|
54
|
+
# Notes outlive their task: read them by name from inside the epic
|
|
55
|
+
if scope is not None and name in manager.epic_note_names(scope):
|
|
56
|
+
return scope, name
|
|
57
|
+
raise ValueError(f"no such task: {name}")
|
|
58
|
+
epic = manager.epic_of(target)
|
|
59
|
+
if scope is not None and epic != scope and target.name in manager.epic_note_names(scope):
|
|
60
|
+
# It left the caller's epic: its notes there are still readable
|
|
61
|
+
return scope, target.name
|
|
62
|
+
if epic is None:
|
|
63
|
+
raise ValueError(f"task {target.name} is not in an epic")
|
|
64
|
+
if scope is not None and epic != scope:
|
|
65
|
+
raise ValueError(f"task {target.name} is in epic {epic}, not in {scope}")
|
|
66
|
+
return epic, None if target.is_epic else target.name
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def task_session(task: Task) -> SessionRef | None:
|
|
70
|
+
"""The newest session of a task, run in its folder or one of its worktrees."""
|
|
71
|
+
return latest_session([task.path, *(wt.path for wt in task.worktrees)])
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def read_epic_log(manager: TaskManager, epic: str, only: str | None = None) -> list[EpicLogEntry]:
|
|
75
|
+
"""The log of the whole epic, or of the one task `only`."""
|
|
76
|
+
members = [epic, *manager.epic_child_names(epic)]
|
|
77
|
+
roles = {name: MEMBER_ROLE for name in members}
|
|
78
|
+
roles[epic] = EPIC_ROLE
|
|
79
|
+
for name in manager.epic_note_names(epic):
|
|
80
|
+
roles.setdefault(name, FORMER_ROLE)
|
|
81
|
+
names = [only] if only is not None else [*members, *sorted(set(roles) - set(members))]
|
|
82
|
+
return [_entry(manager, epic, name, roles.get(name, FORMER_ROLE)) for name in names]
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _entry(manager: TaskManager, epic: str, name: str, role: str) -> EpicLogEntry:
|
|
86
|
+
session = recap = problem = None
|
|
87
|
+
if role != FORMER_ROLE:
|
|
88
|
+
try:
|
|
89
|
+
task = manager.get_task(name)
|
|
90
|
+
except (OSError, ValueError) as e:
|
|
91
|
+
task, problem = None, str(e)
|
|
92
|
+
if task is not None:
|
|
93
|
+
session = task_session(task)
|
|
94
|
+
recap = read_claude_recap(session.path) if session else None
|
|
95
|
+
notes = manager.read_epic_note(epic, name)
|
|
96
|
+
return EpicLogEntry(
|
|
97
|
+
task=name,
|
|
98
|
+
role=role,
|
|
99
|
+
notes_path=manager.epic_note_path(epic, name),
|
|
100
|
+
notes=notes[0] if notes else None,
|
|
101
|
+
notes_truncated=bool(notes and notes[1]),
|
|
102
|
+
session=session,
|
|
103
|
+
recap=recap,
|
|
104
|
+
problem=problem,
|
|
105
|
+
)
|