@leocm/flowcraft 2.2.0 → 2.3.0
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.
- package/README.md +7 -2
- package/bin/cli.js +108 -108
- package/flowcraft.yaml +30 -30
- package/install.sh +24 -24
- package/lib/args.js +38 -38
- package/lib/config.js +20 -20
- package/lib/copy.js +131 -131
- package/lib/fix.js +110 -110
- package/lib/fsutil.js +104 -104
- package/lib/global.js +229 -229
- package/lib/init.js +43 -43
- package/lib/runtime.js +84 -84
- package/lib/version.js +55 -55
- package/lib/wizard.js +125 -125
- package/package.json +33 -33
- package/presets/backend.yaml +20 -20
- package/presets/default.yaml +15 -15
- package/presets/frontend.yaml +20 -20
- package/presets/quick-fix.yaml +15 -15
- package/setup/.claude/hooks/check-phase-test.py +152 -152
- package/setup/.claude/hooks/check-phase-write.py +235 -235
- package/setup/.claude/hooks/dispatch.py +67 -67
- package/setup/.claude/hooks/file-suggestion.py +45 -45
- package/setup/.claude/hooks/flowcraft_env.py +162 -162
- package/setup/.claude/hooks/permission-request.py +132 -132
- package/setup/.claude/hooks/post-tool-failure.py +36 -36
- package/setup/.claude/hooks/pre-compact.py +66 -66
- package/setup/.claude/hooks/review-runner.py +846 -846
- package/setup/.claude/hooks/setup-keys.py +282 -282
- package/setup/.claude/hooks/statusline.py +63 -63
- package/setup/.claude/hooks/stop-check.py +186 -186
- package/setup/.claude/hooks/subagent-start.py +50 -50
- package/setup/.claude/hooks/subagent-stop.py +63 -63
- package/setup/.claude/hooks/task-completed.py +57 -57
- package/setup/.claude/hooks/task_manager.py +592 -592
- package/setup/.claude/hooks/user-prompt-submit.py +91 -91
- package/setup/.claude/settings.json +233 -233
- package/setup/.claude/skills/Pstatus/SKILL.md +68 -68
- package/setup/.claude/skills/archive/SKILL.md +195 -195
- package/setup/.claude/skills/brainstorming/SKILL.md +5 -5
- package/setup/.claude/skills/brainstorming/scripts/server.cjs +723 -723
- package/setup/.claude/skills/brainstorming/scripts/start-server.py +245 -245
- package/setup/.claude/skills/brainstorming/scripts/stop-server.py +178 -178
- package/setup/.claude/skills/brainstorming/visual-companion.md +298 -298
- package/setup/.claude/skills/chrome-integration/SKILL.md +66 -66
- package/setup/.claude/skills/code-review/SKILL.md +264 -264
- package/setup/.claude/skills/executing-plans/SKILL.md +1 -1
- package/setup/.claude/skills/gitnexus/gitnexus-cli/SKILL.md +67 -67
- package/setup/.claude/skills/gitnexus/gitnexus-debugging/SKILL.md +1 -1
- package/setup/.claude/skills/gitnexus/gitnexus-exploring/SKILL.md +1 -1
- package/setup/.claude/skills/gitnexus/gitnexus-guide/SKILL.md +1 -1
- package/setup/.claude/skills/gitnexus/gitnexus-impact-analysis/SKILL.md +1 -1
- package/setup/.claude/skills/gitnexus/gitnexus-refactoring/SKILL.md +1 -1
- package/setup/.claude/skills/methodology/SKILL.md +124 -0
- package/setup/.claude/skills/phase/SKILL.md +62 -62
- package/setup/.claude/skills/playwright/SKILL.md +85 -85
- package/setup/.claude/skills/review/SKILL.md +97 -97
- package/setup/.claude/skills/task/SKILL.md +26 -26
- package/setup/.claude/skills/test-driven-development/SKILL.md +1 -1
- package/setup/.claude/skills/ui-ux-pro-max/SKILL.md +1 -1
- package/setup/.claude/skills/verification-before-completion/SKILL.md +1 -1
- package/setup/.claude/skills/writing-plans/SKILL.md +1 -1
- package/setup/.codex/.agents/skills/archive/SKILL.md +195 -195
- package/setup/.codex/.agents/skills/brainstorming/SKILL.md +5 -5
- package/setup/.codex/.agents/skills/brainstorming/scripts/server.cjs +723 -723
- package/setup/.codex/.agents/skills/brainstorming/scripts/start-server.py +245 -245
- package/setup/.codex/.agents/skills/brainstorming/scripts/stop-server.py +178 -178
- package/setup/.codex/.agents/skills/brainstorming/visual-companion.md +298 -298
- package/setup/.codex/.agents/skills/chrome-integration/SKILL.md +66 -66
- package/setup/.codex/.agents/skills/code-review/SKILL.md +264 -264
- package/setup/.codex/.agents/skills/executing-plans/SKILL.md +1 -1
- package/setup/.codex/.agents/skills/gitnexus/gitnexus-cli/SKILL.md +67 -67
- package/setup/.codex/.agents/skills/gitnexus/gitnexus-debugging/SKILL.md +1 -1
- package/setup/.codex/.agents/skills/gitnexus/gitnexus-exploring/SKILL.md +1 -1
- package/setup/.codex/.agents/skills/gitnexus/gitnexus-guide/SKILL.md +1 -1
- package/setup/.codex/.agents/skills/gitnexus/gitnexus-impact-analysis/SKILL.md +1 -1
- package/setup/.codex/.agents/skills/gitnexus/gitnexus-refactoring/SKILL.md +1 -1
- package/setup/.codex/.agents/skills/methodology/SKILL.md +124 -0
- package/setup/.codex/.agents/skills/phase/SKILL.md +62 -62
- package/setup/.codex/.agents/skills/playwright/SKILL.md +85 -85
- package/setup/.codex/.agents/skills/review/SKILL.md +97 -97
- package/setup/.codex/.agents/skills/task/SKILL.md +27 -27
- package/setup/.codex/.agents/skills/test-driven-development/SKILL.md +1 -1
- package/setup/.codex/.agents/skills/ui-ux-pro-max/SKILL.md +1 -1
- package/setup/.codex/.agents/skills/verification-before-completion/SKILL.md +1 -1
- package/setup/.codex/.agents/skills/writing-plans/SKILL.md +1 -1
- package/setup/.codex/hooks/review-runner.py +851 -851
- package/setup/.codex/hooks/setup-keys.py +287 -287
- package/setup/AGENTS.md +11 -1
- package/setup/CLAUDE.md +11 -1
- package/setup/install.sh +24 -24
- package/setup/tests/test_decision_timeout.py +241 -241
- package/setup/tests/test_hook_guards.py +357 -357
- package/setup/tests/test_sdlc_bootstrap.py +167 -167
- package/setup/tests/test_sessionlog_switch.py +199 -199
- package/setup/tests/test_task_manager.py +148 -148
|
@@ -1,148 +1,148 @@
|
|
|
1
|
-
"""Unit tests for task_manager multi-task resolution (PRD R1-R5, Issue 5)."""
|
|
2
|
-
import json
|
|
3
|
-
import sys
|
|
4
|
-
from pathlib import Path
|
|
5
|
-
|
|
6
|
-
import pytest
|
|
7
|
-
|
|
8
|
-
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / ".claude" / "hooks"))
|
|
9
|
-
|
|
10
|
-
import task_manager as tm
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
@pytest.fixture
|
|
14
|
-
def root(tmp_path, monkeypatch):
|
|
15
|
-
"""Isolated project root: clean env, single-task state file with inline [] lists."""
|
|
16
|
-
monkeypatch.delenv(tm.ENV_TASK_ID, raising=False)
|
|
17
|
-
monkeypatch.delenv(tm.ENV_SESSION_ID, raising=False)
|
|
18
|
-
monkeypatch.setenv("CLAUDE_PROJECT_DIR", str(tmp_path))
|
|
19
|
-
(tmp_path / ".claude").mkdir()
|
|
20
|
-
(tmp_path / ".claude" / "project-state.md").write_text(
|
|
21
|
-
"active_tasks: []\ncompleted_tasks: []\n", encoding="utf-8"
|
|
22
|
-
)
|
|
23
|
-
return tmp_path
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def _make_tasks(root):
|
|
27
|
-
"""Create the tasks dir and return its path."""
|
|
28
|
-
tasks = root / ".claude" / "tasks"
|
|
29
|
-
tasks.mkdir(exist_ok=True)
|
|
30
|
-
return tasks
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def test_single_task_fallback_without_tasks(root):
|
|
34
|
-
"""AC5: no tasks dir and no binding -> project-state.md (backward compatible)."""
|
|
35
|
-
assert tm.get_task_state_path(root) == root / ".claude" / "project-state.md"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def test_dir_default_routes_to_task_file(root, monkeypatch):
|
|
39
|
-
"""AC1: tasks/{dirname}.md exists -> directory default."""
|
|
40
|
-
tasks = _make_tasks(root)
|
|
41
|
-
(tasks / f"{root.name}.md").write_text("task_id: x", encoding="utf-8")
|
|
42
|
-
monkeypatch.setenv(tm.ENV_SESSION_ID, "sid-unbound")
|
|
43
|
-
assert tm.get_task_state_path(root) == tasks / f"{root.name}.md"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def test_session_binding_isolates_two_sessions(root, monkeypatch):
|
|
47
|
-
"""AC2: two sessions bound to different tasks resolve independently."""
|
|
48
|
-
tasks = _make_tasks(root)
|
|
49
|
-
tm.create_task("task-a", "A", root)
|
|
50
|
-
tm.create_task("task-b", "B", root)
|
|
51
|
-
tm.bind_session(root, "sid-a", "task-a")
|
|
52
|
-
tm.bind_session(root, "sid-b", "task-b")
|
|
53
|
-
monkeypatch.setenv(tm.ENV_SESSION_ID, "sid-a")
|
|
54
|
-
assert tm.get_task_state_path(root) == tasks / "task-a.md"
|
|
55
|
-
monkeypatch.setenv(tm.ENV_SESSION_ID, "sid-b")
|
|
56
|
-
assert tm.get_task_state_path(root) == tasks / "task-b.md"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def test_env_overrides_session_binding(root, monkeypatch):
|
|
60
|
-
"""AC4/R3: FLOWCRAFT_TASK_ID beats session binding."""
|
|
61
|
-
tasks = _make_tasks(root)
|
|
62
|
-
tm.create_task("task-a", "A", root)
|
|
63
|
-
tm.create_task("task-env", "E", root)
|
|
64
|
-
tm.bind_session(root, "sid-a", "task-a")
|
|
65
|
-
monkeypatch.setenv(tm.ENV_SESSION_ID, "sid-a")
|
|
66
|
-
monkeypatch.setenv(tm.ENV_TASK_ID, "task-env")
|
|
67
|
-
assert tm.get_task_state_path(root) == tasks / "task-env.md"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
def test_explicit_task_id_wins(root):
|
|
71
|
-
"""Explicit task_id argument has the highest priority."""
|
|
72
|
-
tasks = _make_tasks(root)
|
|
73
|
-
tm.create_task("task-x", "X", root)
|
|
74
|
-
assert tm.get_task_state_path(root, "task-x") == tasks / "task-x.md"
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
def test_safe_task_id_rejects_traversal(root):
|
|
78
|
-
"""Error path: traversal/unsafe IDs rejected (OWASP path defense)."""
|
|
79
|
-
for bad in ("../evil", "bad/../id", "x/y", ".hidden", "a" * 101, "c:d", ""):
|
|
80
|
-
assert tm._safe_task_id(bad) == ""
|
|
81
|
-
with pytest.raises(ValueError):
|
|
82
|
-
tm.create_task(bad, "d", root)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
def test_corrupt_bindings_fallback(root, monkeypatch):
|
|
86
|
-
"""Error path: corrupt bindings.json -> empty mapping, graceful fallback."""
|
|
87
|
-
tasks = _make_tasks(root)
|
|
88
|
-
(tasks / tm.BINDINGS_FILE).write_text("{not json", encoding="utf-8")
|
|
89
|
-
monkeypatch.setenv(tm.ENV_SESSION_ID, "sid-x")
|
|
90
|
-
assert tm._read_bindings(root) == {}
|
|
91
|
-
assert tm.get_task_state_path(root) == root / ".claude" / "project-state.md"
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
def test_atomic_write_creates_valid_file(root):
|
|
95
|
-
"""AC3: atomic write produces the file and leaves no temp files."""
|
|
96
|
-
target = _make_tasks(root) / "f.json"
|
|
97
|
-
tm._atomic_write_text(target, '{"a": 1}')
|
|
98
|
-
assert json.loads(target.read_text(encoding="utf-8")) == {"a": 1}
|
|
99
|
-
assert list(target.parent.glob("*.tmp")) == []
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
def test_register_inline_empty_and_block_lists(root):
|
|
103
|
-
"""Issue 5: create/archive registration works for inline [] lists."""
|
|
104
|
-
tm.create_task("t1", "d", root)
|
|
105
|
-
content = (root / ".claude" / "project-state.md").read_text(encoding="utf-8")
|
|
106
|
-
assert 'task_id: "t1"' in content
|
|
107
|
-
tm.archive_task("t1", root)
|
|
108
|
-
content = (root / ".claude" / "project-state.md").read_text(encoding="utf-8")
|
|
109
|
-
assert "completed_at" in content
|
|
110
|
-
assert 'task_id: "t1"' not in content
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
def test_register_block_format(root):
|
|
114
|
-
"""Issue 5 regression: block-list YAML format still works."""
|
|
115
|
-
(root / ".claude" / "project-state.md").write_text(
|
|
116
|
-
"active_tasks:\ncompleted_tasks:\n", encoding="utf-8"
|
|
117
|
-
)
|
|
118
|
-
tm.create_task("t2", "d", root)
|
|
119
|
-
content = (root / ".claude" / "project-state.md").read_text(encoding="utf-8")
|
|
120
|
-
assert 'task_id: "t2"' in content
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
def test_ensure_session_binding_no_overwrite(root):
|
|
124
|
-
"""R2: ensure_session_binding keeps an existing binding."""
|
|
125
|
-
tm.create_task("t1", "d", root)
|
|
126
|
-
tm.create_task("t2", "d", root)
|
|
127
|
-
tm.bind_session(root, "sid-1", "t1")
|
|
128
|
-
tm.ensure_session_binding(root, "sid-1", "t2")
|
|
129
|
-
assert tm._read_bindings(root)["sid-1"] == "t1"
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
def test_get_task_state_contract(root, monkeypatch):
|
|
133
|
-
"""AC7: get_task_state routes to the same file as the resolution chain."""
|
|
134
|
-
tasks = _make_tasks(root)
|
|
135
|
-
tm.create_task("task-c", "C", root)
|
|
136
|
-
tm.bind_session(root, "sid-c", "task-c")
|
|
137
|
-
monkeypatch.setenv(tm.ENV_SESSION_ID, "sid-c")
|
|
138
|
-
assert tm.get_task_state(str(root / "hook.py")) == tasks / "task-c.md"
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
def test_cli_list_use_and_guard(root, capsys):
|
|
142
|
-
"""AC6: CLI list/use work; invalid task-id rejected with exit code 1."""
|
|
143
|
-
tm.create_task("t-cli", "d", root)
|
|
144
|
-
assert tm._cli(["list"]) == 0
|
|
145
|
-
assert "t-cli" in capsys.readouterr().out
|
|
146
|
-
assert tm._cli(["use", "t-cli", "sid-cli"]) == 0
|
|
147
|
-
assert tm._read_bindings(root)["sid-cli"] == "t-cli"
|
|
148
|
-
assert tm._cli(["use", "bad/../id", "s"]) == 1
|
|
1
|
+
"""Unit tests for task_manager multi-task resolution (PRD R1-R5, Issue 5)."""
|
|
2
|
+
import json
|
|
3
|
+
import sys
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
import pytest
|
|
7
|
+
|
|
8
|
+
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / ".claude" / "hooks"))
|
|
9
|
+
|
|
10
|
+
import task_manager as tm
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@pytest.fixture
|
|
14
|
+
def root(tmp_path, monkeypatch):
|
|
15
|
+
"""Isolated project root: clean env, single-task state file with inline [] lists."""
|
|
16
|
+
monkeypatch.delenv(tm.ENV_TASK_ID, raising=False)
|
|
17
|
+
monkeypatch.delenv(tm.ENV_SESSION_ID, raising=False)
|
|
18
|
+
monkeypatch.setenv("CLAUDE_PROJECT_DIR", str(tmp_path))
|
|
19
|
+
(tmp_path / ".claude").mkdir()
|
|
20
|
+
(tmp_path / ".claude" / "project-state.md").write_text(
|
|
21
|
+
"active_tasks: []\ncompleted_tasks: []\n", encoding="utf-8"
|
|
22
|
+
)
|
|
23
|
+
return tmp_path
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _make_tasks(root):
|
|
27
|
+
"""Create the tasks dir and return its path."""
|
|
28
|
+
tasks = root / ".claude" / "tasks"
|
|
29
|
+
tasks.mkdir(exist_ok=True)
|
|
30
|
+
return tasks
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def test_single_task_fallback_without_tasks(root):
|
|
34
|
+
"""AC5: no tasks dir and no binding -> project-state.md (backward compatible)."""
|
|
35
|
+
assert tm.get_task_state_path(root) == root / ".claude" / "project-state.md"
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def test_dir_default_routes_to_task_file(root, monkeypatch):
|
|
39
|
+
"""AC1: tasks/{dirname}.md exists -> directory default."""
|
|
40
|
+
tasks = _make_tasks(root)
|
|
41
|
+
(tasks / f"{root.name}.md").write_text("task_id: x", encoding="utf-8")
|
|
42
|
+
monkeypatch.setenv(tm.ENV_SESSION_ID, "sid-unbound")
|
|
43
|
+
assert tm.get_task_state_path(root) == tasks / f"{root.name}.md"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def test_session_binding_isolates_two_sessions(root, monkeypatch):
|
|
47
|
+
"""AC2: two sessions bound to different tasks resolve independently."""
|
|
48
|
+
tasks = _make_tasks(root)
|
|
49
|
+
tm.create_task("task-a", "A", root)
|
|
50
|
+
tm.create_task("task-b", "B", root)
|
|
51
|
+
tm.bind_session(root, "sid-a", "task-a")
|
|
52
|
+
tm.bind_session(root, "sid-b", "task-b")
|
|
53
|
+
monkeypatch.setenv(tm.ENV_SESSION_ID, "sid-a")
|
|
54
|
+
assert tm.get_task_state_path(root) == tasks / "task-a.md"
|
|
55
|
+
monkeypatch.setenv(tm.ENV_SESSION_ID, "sid-b")
|
|
56
|
+
assert tm.get_task_state_path(root) == tasks / "task-b.md"
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def test_env_overrides_session_binding(root, monkeypatch):
|
|
60
|
+
"""AC4/R3: FLOWCRAFT_TASK_ID beats session binding."""
|
|
61
|
+
tasks = _make_tasks(root)
|
|
62
|
+
tm.create_task("task-a", "A", root)
|
|
63
|
+
tm.create_task("task-env", "E", root)
|
|
64
|
+
tm.bind_session(root, "sid-a", "task-a")
|
|
65
|
+
monkeypatch.setenv(tm.ENV_SESSION_ID, "sid-a")
|
|
66
|
+
monkeypatch.setenv(tm.ENV_TASK_ID, "task-env")
|
|
67
|
+
assert tm.get_task_state_path(root) == tasks / "task-env.md"
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def test_explicit_task_id_wins(root):
|
|
71
|
+
"""Explicit task_id argument has the highest priority."""
|
|
72
|
+
tasks = _make_tasks(root)
|
|
73
|
+
tm.create_task("task-x", "X", root)
|
|
74
|
+
assert tm.get_task_state_path(root, "task-x") == tasks / "task-x.md"
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def test_safe_task_id_rejects_traversal(root):
|
|
78
|
+
"""Error path: traversal/unsafe IDs rejected (OWASP path defense)."""
|
|
79
|
+
for bad in ("../evil", "bad/../id", "x/y", ".hidden", "a" * 101, "c:d", ""):
|
|
80
|
+
assert tm._safe_task_id(bad) == ""
|
|
81
|
+
with pytest.raises(ValueError):
|
|
82
|
+
tm.create_task(bad, "d", root)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def test_corrupt_bindings_fallback(root, monkeypatch):
|
|
86
|
+
"""Error path: corrupt bindings.json -> empty mapping, graceful fallback."""
|
|
87
|
+
tasks = _make_tasks(root)
|
|
88
|
+
(tasks / tm.BINDINGS_FILE).write_text("{not json", encoding="utf-8")
|
|
89
|
+
monkeypatch.setenv(tm.ENV_SESSION_ID, "sid-x")
|
|
90
|
+
assert tm._read_bindings(root) == {}
|
|
91
|
+
assert tm.get_task_state_path(root) == root / ".claude" / "project-state.md"
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def test_atomic_write_creates_valid_file(root):
|
|
95
|
+
"""AC3: atomic write produces the file and leaves no temp files."""
|
|
96
|
+
target = _make_tasks(root) / "f.json"
|
|
97
|
+
tm._atomic_write_text(target, '{"a": 1}')
|
|
98
|
+
assert json.loads(target.read_text(encoding="utf-8")) == {"a": 1}
|
|
99
|
+
assert list(target.parent.glob("*.tmp")) == []
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def test_register_inline_empty_and_block_lists(root):
|
|
103
|
+
"""Issue 5: create/archive registration works for inline [] lists."""
|
|
104
|
+
tm.create_task("t1", "d", root)
|
|
105
|
+
content = (root / ".claude" / "project-state.md").read_text(encoding="utf-8")
|
|
106
|
+
assert 'task_id: "t1"' in content
|
|
107
|
+
tm.archive_task("t1", root)
|
|
108
|
+
content = (root / ".claude" / "project-state.md").read_text(encoding="utf-8")
|
|
109
|
+
assert "completed_at" in content
|
|
110
|
+
assert 'task_id: "t1"' not in content
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def test_register_block_format(root):
|
|
114
|
+
"""Issue 5 regression: block-list YAML format still works."""
|
|
115
|
+
(root / ".claude" / "project-state.md").write_text(
|
|
116
|
+
"active_tasks:\ncompleted_tasks:\n", encoding="utf-8"
|
|
117
|
+
)
|
|
118
|
+
tm.create_task("t2", "d", root)
|
|
119
|
+
content = (root / ".claude" / "project-state.md").read_text(encoding="utf-8")
|
|
120
|
+
assert 'task_id: "t2"' in content
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def test_ensure_session_binding_no_overwrite(root):
|
|
124
|
+
"""R2: ensure_session_binding keeps an existing binding."""
|
|
125
|
+
tm.create_task("t1", "d", root)
|
|
126
|
+
tm.create_task("t2", "d", root)
|
|
127
|
+
tm.bind_session(root, "sid-1", "t1")
|
|
128
|
+
tm.ensure_session_binding(root, "sid-1", "t2")
|
|
129
|
+
assert tm._read_bindings(root)["sid-1"] == "t1"
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def test_get_task_state_contract(root, monkeypatch):
|
|
133
|
+
"""AC7: get_task_state routes to the same file as the resolution chain."""
|
|
134
|
+
tasks = _make_tasks(root)
|
|
135
|
+
tm.create_task("task-c", "C", root)
|
|
136
|
+
tm.bind_session(root, "sid-c", "task-c")
|
|
137
|
+
monkeypatch.setenv(tm.ENV_SESSION_ID, "sid-c")
|
|
138
|
+
assert tm.get_task_state(str(root / "hook.py")) == tasks / "task-c.md"
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def test_cli_list_use_and_guard(root, capsys):
|
|
142
|
+
"""AC6: CLI list/use work; invalid task-id rejected with exit code 1."""
|
|
143
|
+
tm.create_task("t-cli", "d", root)
|
|
144
|
+
assert tm._cli(["list"]) == 0
|
|
145
|
+
assert "t-cli" in capsys.readouterr().out
|
|
146
|
+
assert tm._cli(["use", "t-cli", "sid-cli"]) == 0
|
|
147
|
+
assert tm._read_bindings(root)["sid-cli"] == "t-cli"
|
|
148
|
+
assert tm._cli(["use", "bad/../id", "s"]) == 1
|