okstra 0.232.0 → 0.233.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 +19 -283
- package/dist/cli-registry.mjs +8 -1
- package/dist/cli-registry.mjs.map +1 -1
- package/dist/commands/execute/render-bundle.d.mts +6 -1
- package/dist/commands/execute/render-bundle.mjs +139 -32
- package/dist/commands/execute/render-bundle.mjs.map +1 -1
- package/dist/commands/lifecycle/config.mjs +6 -74
- package/dist/commands/lifecycle/config.mjs.map +1 -1
- package/dist/commands/trace/capacity.d.mts +12 -0
- package/dist/commands/trace/capacity.mjs +21 -0
- package/dist/commands/trace/capacity.mjs.map +1 -0
- package/dist/commands/trace/model.d.mts +89 -0
- package/dist/commands/trace/model.mjs +251 -0
- package/dist/commands/trace/model.mjs.map +1 -0
- package/dist/commands/trace/progression.d.mts +11 -0
- package/dist/commands/trace/progression.mjs +194 -0
- package/dist/commands/trace/progression.mjs.map +1 -0
- package/dist/commands/trace/review.d.mts +7 -0
- package/dist/commands/trace/review.mjs +51 -0
- package/dist/commands/trace/review.mjs.map +1 -0
- package/dist/commands/trace/task-link.d.mts +18 -0
- package/dist/commands/trace/task-link.mjs +72 -0
- package/dist/commands/trace/task-link.mjs.map +1 -0
- package/dist/commands/trace/trace.d.mts +1 -0
- package/dist/commands/trace/trace.mjs +293 -0
- package/dist/commands/trace/trace.mjs.map +1 -0
- package/dist/lib/bounded-file.d.mts +1 -0
- package/dist/lib/bounded-file.mjs +36 -0
- package/dist/lib/bounded-file.mjs.map +1 -0
- package/dist/lib/config-store.d.mts +34 -0
- package/dist/lib/config-store.mjs +70 -0
- package/dist/lib/config-store.mjs.map +1 -0
- package/dist/lib/file-lock.mjs +4 -5
- package/dist/lib/file-lock.mjs.map +1 -1
- package/dist/lib/input-limit.d.mts +4 -0
- package/dist/lib/input-limit.mjs +8 -0
- package/dist/lib/input-limit.mjs.map +1 -0
- package/dist/lib/memory-auto-register.mjs +2 -17
- package/dist/lib/memory-auto-register.mjs.map +1 -1
- package/dist/lib/report-language-tag.d.mts +1 -0
- package/dist/lib/report-language-tag.mjs +4 -0
- package/dist/lib/report-language-tag.mjs.map +1 -0
- package/dist/lib/report-language.d.mts +1 -0
- package/dist/lib/report-language.mjs +50 -0
- package/dist/lib/report-language.mjs.map +1 -0
- package/dist/lib/skill-catalog.mjs +3 -0
- package/dist/lib/skill-catalog.mjs.map +1 -1
- package/docs/architecture/storage-model.md +36 -5
- package/docs/architecture.md +10 -4
- package/docs/cli.md +279 -2
- package/docs/contributor-change-matrix.md +1 -2
- package/docs/project-structure-overview.md +31 -41
- package/package.json +1 -1
- package/runtime/BUILD.json +2 -2
- package/runtime/agents/operations/trace-interface-review.json +6 -0
- package/runtime/agents/operations/trace-scope-review.json +6 -0
- package/runtime/prompts/coding-preflight/authoring-checks.md +1 -1
- package/runtime/prompts/coding-preflight/clean-code.md +18 -20
- package/runtime/prompts/coding-preflight/overview.md +1 -1
- package/runtime/prompts/duties/code-reviewer.json +1 -1
- package/runtime/prompts/duties/interface-reviewer.json +32 -0
- package/runtime/prompts/host-orchestration/README.md +18 -9
- package/runtime/prompts/launch.template.md +3 -2
- package/runtime/prompts/lead/context-loader.md +2 -0
- package/runtime/prompts/lead/okstra-lead-contract.md +7 -7
- package/runtime/prompts/lead/report-writer.md +6 -6
- package/runtime/prompts/profiles/_coding-conventions-preflight.md +2 -2
- package/runtime/prompts/profiles/_common-contract.md +1 -1
- package/runtime/python/okstra_ctl/agent/invocation.py +1 -0
- package/runtime/python/okstra_ctl/agent/prompt_cli/cli.py +66 -26
- package/runtime/python/okstra_ctl/agent/prompt_cli/corrections.py +23 -8
- package/runtime/python/okstra_ctl/agent/prompt_cli/materialize.py +28 -10
- package/runtime/python/okstra_ctl/agent/prompt_cli/results.py +8 -11
- package/runtime/python/okstra_ctl/agent/standalone.py +12 -0
- package/runtime/python/okstra_ctl/analysis_packet.py +22 -11
- package/runtime/python/okstra_ctl/code_review_census.py +93 -2
- package/runtime/python/okstra_ctl/code_review_prepare.py +381 -0
- package/runtime/python/okstra_ctl/code_review_run.py +384 -0
- package/runtime/python/okstra_ctl/code_review_scope.py +13 -0
- package/runtime/python/okstra_ctl/code_review_supervisor.py +41 -0
- package/runtime/python/okstra_ctl/code_review_target.py +140 -15
- package/runtime/python/okstra_ctl/coverage_census.py +11 -2
- package/runtime/python/okstra_ctl/design_snapshot.py +16 -9
- package/runtime/python/okstra_ctl/direct_work.py +45 -3
- package/runtime/python/okstra_ctl/dispatch_core.py +31 -15
- package/runtime/python/okstra_ctl/dispatch_state.py +9 -2
- package/runtime/python/okstra_ctl/domain/role.py +1 -0
- package/runtime/python/okstra_ctl/doyouknow/sources/manager.py +48 -9
- package/runtime/python/okstra_ctl/final_report_schema.py +37 -34
- package/runtime/python/okstra_ctl/incremental_carry.py +6 -7
- package/runtime/python/okstra_ctl/initial_prompt_materialization.py +9 -2
- package/runtime/python/okstra_ctl/json_boundary.py +33 -6
- package/runtime/python/okstra_ctl/manager_cli.py +122 -1
- package/runtime/python/okstra_ctl/manager_journal.py +126 -0
- package/runtime/python/okstra_ctl/manager_launch.py +3 -3
- package/runtime/python/okstra_ctl/manager_log.py +221 -0
- package/runtime/python/okstra_ctl/manager_paths.py +8 -0
- package/runtime/python/okstra_ctl/manager_resume.py +59 -0
- package/runtime/python/okstra_ctl/manager_split.py +2 -2
- package/runtime/python/okstra_ctl/manager_store.py +116 -17
- package/runtime/python/okstra_ctl/manager_sync.py +42 -3
- package/runtime/python/okstra_ctl/manager_view.py +35 -2
- package/runtime/python/okstra_ctl/material.py +2 -0
- package/runtime/python/okstra_ctl/model_cli.py +64 -14
- package/runtime/python/okstra_ctl/model_defaults.py +22 -0
- package/runtime/python/okstra_ctl/model_io/renderers.py +3 -0
- package/runtime/python/okstra_ctl/operation_invocation.py +207 -28
- package/runtime/python/okstra_ctl/path_hints.py +14 -3
- package/runtime/python/okstra_ctl/paths.py +6 -1
- package/runtime/python/okstra_ctl/phases/catalog.py +24 -7
- package/runtime/python/okstra_ctl/phases/implementation/host-rules.md +3 -3
- package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-diff-review.md +8 -6
- package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-self-check.md +1 -1
- package/runtime/python/okstra_ctl/phases/implementation_option_selection/profile.md +1 -1
- package/runtime/python/okstra_ctl/phases/implementation_option_selection/votes.py +11 -11
- package/runtime/python/okstra_ctl/phases/implementation_planning/authoring.py +12 -9
- package/runtime/python/okstra_ctl/phases/implementation_planning/host-rules.md +3 -6
- package/runtime/python/okstra_ctl/phases/implementation_planning/instructions/plan-body-verification.md +12 -10
- package/runtime/python/okstra_ctl/phases/implementation_planning/profile.md +5 -5
- package/runtime/python/okstra_ctl/phases/improvement_discovery/lenses.py +12 -0
- package/runtime/python/okstra_ctl/phases/improvement_discovery/profile.md +7 -6
- package/runtime/python/okstra_ctl/phases/improvement_discovery/resolved_census.py +159 -0
- package/runtime/python/okstra_ctl/phases/improvement_discovery/spec.md +5 -2
- package/runtime/python/okstra_ctl/phases/improvement_discovery/validation.py +21 -7
- package/runtime/python/okstra_ctl/phases/release_handoff/boundary.json +1 -1
- package/runtime/python/okstra_ctl/phases/release_handoff/profile.md +4 -1
- package/runtime/python/okstra_ctl/plan_verify_cli.py +6 -4
- package/runtime/python/okstra_ctl/render.py +28 -2
- package/runtime/python/okstra_ctl/report_assembly.py +38 -11
- package/runtime/python/okstra_ctl/report_contract.py +26 -0
- package/runtime/python/okstra_ctl/report_corrections.py +36 -20
- package/runtime/python/okstra_ctl/report_inputs.py +1 -0
- package/runtime/python/okstra_ctl/report_language.py +4 -1
- package/runtime/python/okstra_ctl/report_narrative.py +179 -7
- package/runtime/python/okstra_ctl/report_projections.py +64 -18
- package/runtime/python/okstra_ctl/report_synthesis_packet.py +86 -36
- package/runtime/python/okstra_ctl/run.py +43 -35
- package/runtime/python/okstra_ctl/run_context.py +10 -1
- package/runtime/python/okstra_ctl/set_work_status.py +4 -15
- package/runtime/python/okstra_ctl/task_list_cli.py +34 -8
- package/runtime/python/okstra_ctl/task_query.py +239 -0
- package/runtime/python/okstra_ctl/trace_review.py +264 -0
- package/runtime/python/okstra_ctl/trace_tasks.py +197 -0
- package/runtime/python/okstra_ctl/user_authorization.py +14 -0
- package/runtime/python/okstra_ctl/wizard/confirmation.py +7 -3
- package/runtime/python/okstra_ctl/wizard/launch.py +52 -0
- package/runtime/python/okstra_ctl/wizard/launch_cli.py +39 -0
- package/runtime/python/okstra_ctl/wizard/outcome.py +17 -16
- package/runtime/python/okstra_ctl/wizard/registry.py +1 -1
- package/runtime/python/okstra_ctl/wizard/render.py +8 -0
- package/runtime/python/okstra_ctl/wizard/state.py +2 -1
- package/runtime/python/okstra_project/state.py +20 -0
- package/runtime/python/okstra_token_usage/blocks.py +74 -0
- package/runtime/python/okstra_token_usage/cli.py +23 -10
- package/runtime/python/okstra_token_usage/collect.py +25 -22
- package/runtime/python/okstra_token_usage/policy.py +193 -0
- package/runtime/schemas/report-synthesis-packet-v1.0.schema.json +1 -1
- package/runtime/skills/_fragments/wizard-confirm-step.md +1 -1
- package/runtime/skills/_fragments/wizard-preflight.md +1 -1
- package/runtime/skills/_fragments/wizard-prompt-loop.md +3 -5
- package/runtime/skills/_fragments/wizard-relay-protocol.md +1 -1
- package/runtime/skills/_fragments/wizard-render-bundle.md +15 -29
- package/runtime/skills/okstra-brief-gen/SKILL.md +7 -7
- package/runtime/skills/okstra-brief-gen/references/tracker-recursion.md +1 -1
- package/runtime/skills/okstra-code-review/SKILL.md +58 -50
- package/runtime/skills/okstra-code-review/references/census-rules.md +6 -6
- package/runtime/skills/okstra-code-review/references/review-calibration.md +8 -12
- package/runtime/skills/okstra-discussion/SKILL.md +22 -38
- package/runtime/skills/okstra-explain-flow/SKILL.md +6 -2
- package/runtime/skills/okstra-manager/SKILL.md +24 -0
- package/runtime/skills/okstra-memory/SKILL.md +1 -1
- package/runtime/skills/okstra-pr-gen/SKILL.md +1 -1
- package/runtime/skills/okstra-run/SKILL.md +55 -183
- package/runtime/skills/okstra-schedule-gen/SKILL.md +9 -13
- package/runtime/skills/okstra-setup/SKILL.md +3 -2
- package/runtime/skills/okstra-setup/references/project-config.md +2 -4
- package/runtime/skills/okstra-tdd/SKILL.md +187 -0
- package/runtime/skills/okstra-user-response/SKILL.md +4 -2
- package/runtime/templates/manager/view.template.html +4 -0
- package/runtime/templates/report-writer-prompt-preamble.md +15 -3
- package/runtime/templates/trace/trace.template.md +42 -0
- package/runtime/validators/checks/fixtures-02.py +25 -33
- package/runtime/validators/validate-run.py +93 -36
|
@@ -4,7 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
import shlex
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
|
|
7
|
-
from okstra_ctl.jsonl import
|
|
7
|
+
from okstra_ctl.jsonl import read_jsonl
|
|
8
8
|
from okstra_ctl.phases.discussion.followup import RECOMMENDED_PHASE as DISCUSSION_FOLLOW_UP_PHASE
|
|
9
9
|
from okstra_ctl.phases.discussion.followup import brief_revision_ref
|
|
10
10
|
from okstra_ctl.phases.discussion.store import same_task
|
|
@@ -19,7 +19,7 @@ from .manager_paths import (
|
|
|
19
19
|
snapshots_json_path,
|
|
20
20
|
task_manifest_path,
|
|
21
21
|
)
|
|
22
|
-
from .manager_store import ManagerError, _now_iso, _read_json, _read_json_default, _write_json
|
|
22
|
+
from .manager_store import ManagerError, _now_iso, _read_json, _read_json_default, _write_json, record_event
|
|
23
23
|
from .manager_sync import _snapshot_child, summary_bucket
|
|
24
24
|
|
|
25
25
|
|
|
@@ -205,7 +205,7 @@ def _record_launch_prepared(
|
|
|
205
205
|
)
|
|
206
206
|
child["launch"] = launch
|
|
207
207
|
_write_json(children_json_path(home, manager_id, task_group, task_id), children)
|
|
208
|
-
|
|
208
|
+
record_event(
|
|
209
209
|
events_jsonl_path(home, manager_id, task_group, task_id),
|
|
210
210
|
{
|
|
211
211
|
"event": "child-launch-prepared",
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"""Merge manager activity files for `okstra manager log`."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from collections.abc import Iterator
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from datetime import datetime, timezone
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import TypedDict
|
|
9
|
+
|
|
10
|
+
from .manager_journal import JOURNAL_ORIGIN, is_open_followup, open_followups_oldest_first, resolved_entry_ids
|
|
11
|
+
from .manager_paths import directives_jsonl_path, events_jsonl_path, journal_jsonl_path, manager_events_jsonl_path
|
|
12
|
+
from .manager_store import ManagerError, _read_json, _task_manifest_paths, load_manager, read_jsonl_rows, task_selection
|
|
13
|
+
|
|
14
|
+
DEFAULT_LIMIT = 50
|
|
15
|
+
MAX_LIMIT = 1000
|
|
16
|
+
MANAGER_EVENT = "manager-event"
|
|
17
|
+
TASK_EVENT = "task-event"
|
|
18
|
+
DIRECTIVE = "directive"
|
|
19
|
+
JOURNAL = JOURNAL_ORIGIN
|
|
20
|
+
_NO_TASK = ("", "")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class ActivityEntry(TypedDict):
|
|
24
|
+
origin: str
|
|
25
|
+
kind: str
|
|
26
|
+
createdAt: str
|
|
27
|
+
taskGroup: str
|
|
28
|
+
taskId: str
|
|
29
|
+
row: dict
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _since_floor(value: str) -> str:
|
|
33
|
+
try:
|
|
34
|
+
parsed = datetime.fromisoformat(value.strip().replace("Z", "+00:00"))
|
|
35
|
+
if parsed.tzinfo is None:
|
|
36
|
+
parsed = parsed.replace(tzinfo=timezone.utc)
|
|
37
|
+
return parsed.astimezone(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
38
|
+
except (ValueError, OverflowError) as exc:
|
|
39
|
+
raise ManagerError(f"--since must be an ISO date or time: {value!r}") from exc
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _task_identities(home: Path, manager_id: str) -> list[tuple[str, str]]:
|
|
43
|
+
"""Read (task group, task id) from manifests only, so other task files cannot stop the log."""
|
|
44
|
+
load_manager(home, manager_id)
|
|
45
|
+
identities = []
|
|
46
|
+
for path in _task_manifest_paths(home, manager_id):
|
|
47
|
+
manifest = _read_json(path)
|
|
48
|
+
identities.append((str(manifest.get("taskGroup") or ""), str(manifest.get("taskId") or "")))
|
|
49
|
+
return sorted(identities)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _sources(home: Path, manager_id: str) -> list[tuple[str, Path, tuple[str, str]]]:
|
|
53
|
+
sources = [(MANAGER_EVENT, manager_events_jsonl_path(home, manager_id), _NO_TASK)]
|
|
54
|
+
for group, task_id in _task_identities(home, manager_id):
|
|
55
|
+
sources.append((TASK_EVENT, events_jsonl_path(home, manager_id, group, task_id), (group, task_id)))
|
|
56
|
+
sources.append((DIRECTIVE, directives_jsonl_path(home, manager_id, group, task_id), (group, task_id)))
|
|
57
|
+
sources.append((JOURNAL, journal_jsonl_path(home, manager_id), _NO_TASK))
|
|
58
|
+
return sources
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _matches_task(identity: tuple[str, str], row: dict, task: tuple[str, str] | None) -> bool:
|
|
62
|
+
"""Whether a row belongs to the `--task-group` / `--task-id` selection.
|
|
63
|
+
|
|
64
|
+
Task files belong to their own task. Manager-level rows (manager events and journal
|
|
65
|
+
entries) belong to a task they name, which includes removals and unlinks recorded
|
|
66
|
+
after the task's own files are gone.
|
|
67
|
+
"""
|
|
68
|
+
if task is None:
|
|
69
|
+
return True
|
|
70
|
+
if identity != _NO_TASK:
|
|
71
|
+
return identity == task
|
|
72
|
+
group, task_id = task
|
|
73
|
+
if (row.get("taskGroup"), row.get("taskId")) == task:
|
|
74
|
+
return True
|
|
75
|
+
event = row.get("event")
|
|
76
|
+
if event == "task-group-removed":
|
|
77
|
+
return row.get("taskGroup") == group and task_id in (row.get("taskIds") or [])
|
|
78
|
+
if event == "project-unlinked":
|
|
79
|
+
named = row.get("tasks") or []
|
|
80
|
+
return any(isinstance(item, dict) and (item.get("taskGroup"), item.get("taskId")) == task for item in named)
|
|
81
|
+
return False
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _reads_file(identity: tuple[str, str], task: tuple[str, str] | None) -> bool:
|
|
85
|
+
"""Manager-level files are always read; a task's own files only for that task."""
|
|
86
|
+
return identity == _NO_TASK or _matches_task(identity, {}, task)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def _kind(origin: str, row: dict) -> str:
|
|
90
|
+
if origin == DIRECTIVE:
|
|
91
|
+
return DIRECTIVE
|
|
92
|
+
if origin == JOURNAL:
|
|
93
|
+
return str(row.get("kind") or "")
|
|
94
|
+
return str(row.get("event") or "")
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def _entry(origin: str, identity: tuple[str, str], row: dict) -> ActivityEntry:
|
|
98
|
+
group, task_id = identity
|
|
99
|
+
return {
|
|
100
|
+
"origin": origin,
|
|
101
|
+
"kind": _kind(origin, row),
|
|
102
|
+
"createdAt": str(row.get("createdAt") or ""),
|
|
103
|
+
"taskGroup": group or str(row.get("taskGroup") or ""),
|
|
104
|
+
"taskId": task_id or str(row.get("taskId") or ""),
|
|
105
|
+
"row": row,
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def _string_values(value: object) -> Iterator[str]:
|
|
110
|
+
if isinstance(value, str):
|
|
111
|
+
yield value
|
|
112
|
+
elif isinstance(value, dict):
|
|
113
|
+
for child in value.values():
|
|
114
|
+
yield from _string_values(child)
|
|
115
|
+
elif isinstance(value, list):
|
|
116
|
+
for child in value:
|
|
117
|
+
yield from _string_values(child)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def _search_text(entry: ActivityEntry) -> str:
|
|
121
|
+
if entry["origin"] in (DIRECTIVE, JOURNAL):
|
|
122
|
+
return str(entry["row"].get("body") or "")
|
|
123
|
+
return "\n".join(_string_values(entry["row"]))
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def _matches_filters(entry: ActivityEntry, kind: str | None, since_utc: str, grep_casefolded: str) -> bool:
|
|
127
|
+
if kind is not None and entry["kind"] != kind:
|
|
128
|
+
return False
|
|
129
|
+
if since_utc and entry["createdAt"] < since_utc:
|
|
130
|
+
return False
|
|
131
|
+
return not grep_casefolded or grep_casefolded in _search_text(entry).casefold()
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def _newest_first(entries: list[ActivityEntry]) -> list[ActivityEntry]:
|
|
135
|
+
"""Sort by createdAt, newest first.
|
|
136
|
+
|
|
137
|
+
createdAt has one-second resolution. Entries with the same createdAt come in reverse
|
|
138
|
+
read order: a later line of one file comes first, and so does a file read later.
|
|
139
|
+
Files are read manager events first, then each task's events and directives in
|
|
140
|
+
(task group, task id) order, then the journal, so across files a tie does not follow
|
|
141
|
+
write order.
|
|
142
|
+
"""
|
|
143
|
+
indexed = sorted(enumerate(entries), key=lambda item: (item[1]["createdAt"], item[0]), reverse=True)
|
|
144
|
+
return [entry for _, entry in indexed]
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
@dataclass(frozen=True)
|
|
148
|
+
class Activity:
|
|
149
|
+
entries: list[ActivityEntry]
|
|
150
|
+
damaged: list[dict]
|
|
151
|
+
resolved: set[str]
|
|
152
|
+
|
|
153
|
+
def open_followups_oldest_first(self) -> list[ActivityEntry]:
|
|
154
|
+
return open_followups_oldest_first(self.entries, self.resolved)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def merge_activity(
|
|
158
|
+
home: Path,
|
|
159
|
+
manager_id: str,
|
|
160
|
+
*,
|
|
161
|
+
task: tuple[str, str] | None = None,
|
|
162
|
+
kind: str | None = None,
|
|
163
|
+
since_utc: str = "",
|
|
164
|
+
grep_casefolded: str = "",
|
|
165
|
+
) -> Activity:
|
|
166
|
+
"""Every matching entry newest first, unpaged, with damaged lines per file and resolved journal ids.
|
|
167
|
+
|
|
168
|
+
`since_utc` must already be normalised by `_since_floor` and `grep_casefolded` must be
|
|
169
|
+
casefolded. `resolved` comes from the whole journal, whatever the filters keep.
|
|
170
|
+
"""
|
|
171
|
+
entries: list[ActivityEntry] = []
|
|
172
|
+
damaged: list[dict] = []
|
|
173
|
+
resolved: set[str] = set()
|
|
174
|
+
for origin, path, identity in _sources(home, manager_id):
|
|
175
|
+
if not _reads_file(identity, task):
|
|
176
|
+
continue
|
|
177
|
+
rows, invalid_lines = read_jsonl_rows(path)
|
|
178
|
+
if invalid_lines:
|
|
179
|
+
damaged.append({"path": str(path), "lines": invalid_lines})
|
|
180
|
+
if origin == JOURNAL:
|
|
181
|
+
resolved = resolved_entry_ids(rows)
|
|
182
|
+
for row in rows:
|
|
183
|
+
entry = _entry(origin, identity, row)
|
|
184
|
+
if _matches_task(identity, row, task) and _matches_filters(entry, kind, since_utc, grep_casefolded):
|
|
185
|
+
entries.append(entry)
|
|
186
|
+
return Activity(_newest_first(entries), damaged, resolved)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def read_activity_page(
|
|
190
|
+
home: Path,
|
|
191
|
+
manager_id: str,
|
|
192
|
+
*,
|
|
193
|
+
task_group: str | None = None,
|
|
194
|
+
task_id: str | None = None,
|
|
195
|
+
kind: str | None = None,
|
|
196
|
+
since: str | None = None,
|
|
197
|
+
grep: str | None = None,
|
|
198
|
+
open_followups: bool = False,
|
|
199
|
+
limit: int = DEFAULT_LIMIT,
|
|
200
|
+
) -> dict:
|
|
201
|
+
"""One page (`limit` entries) of manager events, task events, directives and journal entries, newest first.
|
|
202
|
+
|
|
203
|
+
`open_followups` keeps only followup journal entries that no journal row resolves.
|
|
204
|
+
|
|
205
|
+
Each entry names the file it came from as `origin` and keeps the stored JSONL
|
|
206
|
+
object under `row`; stored directive and task-split rows have their own `source`.
|
|
207
|
+
"""
|
|
208
|
+
task = task_selection(task_group, task_id)
|
|
209
|
+
check_limit(limit, "--limit")
|
|
210
|
+
activity = merge_activity(home, manager_id, task=task, kind=kind,
|
|
211
|
+
since_utc=_since_floor(since) if since else "", grep_casefolded=(grep or "").casefold())
|
|
212
|
+
entries = activity.entries
|
|
213
|
+
if open_followups:
|
|
214
|
+
entries = [entry for entry in entries if is_open_followup(entry, activity.resolved)]
|
|
215
|
+
return {"managerId": manager_id, "matchedCount": len(entries), "entries": entries[:limit],
|
|
216
|
+
"damaged": activity.damaged}
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
def check_limit(value: int, flag: str) -> None:
|
|
220
|
+
if not 1 <= value <= MAX_LIMIT:
|
|
221
|
+
raise ManagerError(f"{flag} must be between 1 and {MAX_LIMIT}")
|
|
@@ -79,6 +79,14 @@ def projects_json_path(home: Path, manager_id: str) -> Path:
|
|
|
79
79
|
return manager_root(home, manager_id) / "projects.json"
|
|
80
80
|
|
|
81
81
|
|
|
82
|
+
def manager_events_jsonl_path(home: Path, manager_id: str) -> Path:
|
|
83
|
+
return manager_root(home, manager_id) / "events.jsonl"
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def journal_jsonl_path(home: Path, manager_id: str) -> Path:
|
|
87
|
+
return manager_root(home, manager_id) / "journal.jsonl"
|
|
88
|
+
|
|
89
|
+
|
|
82
90
|
def task_manifest_path(home: Path, manager_id: str, task_group: str, task_id: str) -> Path:
|
|
83
91
|
return task_root(home, manager_id, task_group, task_id) / "manifest.json"
|
|
84
92
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""Session start summary for `okstra manager resume`."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from .manager_journal import DECISION, SESSION_SUMMARY, is_journal_kind
|
|
7
|
+
from .manager_log import ActivityEntry, _task_identities, check_limit, merge_activity
|
|
8
|
+
from .manager_store import ManagerError
|
|
9
|
+
from .manager_sync import status_task
|
|
10
|
+
|
|
11
|
+
DEFAULT_RECENT = 10
|
|
12
|
+
RECENT_DECISION_COUNT = 5
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _last_summary_index(entries: list[ActivityEntry]) -> int | None:
|
|
16
|
+
return next((index for index, entry in enumerate(entries) if is_journal_kind(entry, SESSION_SUMMARY)), None)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _task_overview(home: Path, manager_id: str, task_group: str, task_id: str, now: str | None) -> dict:
|
|
20
|
+
"""One task's sync state, or its `error` when its files cannot be read, so other tasks still report."""
|
|
21
|
+
try:
|
|
22
|
+
status = status_task(home, manager_id, task_group, task_id, now=now)
|
|
23
|
+
except ManagerError as exc:
|
|
24
|
+
return {"taskGroup": task_group, "taskId": task_id, "error": str(exc)}
|
|
25
|
+
overview = {
|
|
26
|
+
"taskGroup": task_group,
|
|
27
|
+
"taskId": task_id,
|
|
28
|
+
"syncedAt": status["syncedAt"],
|
|
29
|
+
"changedSinceSyncCount": status["changedSinceSyncCount"],
|
|
30
|
+
"unlinkedChildCount": sum(1 for child in status["children"] if not child["projectLinked"]),
|
|
31
|
+
}
|
|
32
|
+
if "syncAgeSeconds" in status:
|
|
33
|
+
overview["syncAgeSeconds"] = status["syncAgeSeconds"]
|
|
34
|
+
return overview
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def resume_manager(home: Path, manager_id: str, *, recent: int = DEFAULT_RECENT, now: str | None = None) -> dict:
|
|
38
|
+
"""What the previous sessions left: last summary, activity after it, open follow-ups and task status.
|
|
39
|
+
|
|
40
|
+
`unsummarizedCount` counts the entries listed before the last session summary in
|
|
41
|
+
the newest-first order of `log`, so it follows the same tie rule.
|
|
42
|
+
"""
|
|
43
|
+
check_limit(recent, "--recent")
|
|
44
|
+
activity = merge_activity(home, manager_id)
|
|
45
|
+
entries = activity.entries
|
|
46
|
+
summary_index = _last_summary_index(entries)
|
|
47
|
+
summary = entries[summary_index] if summary_index is not None else None
|
|
48
|
+
return {
|
|
49
|
+
"managerId": manager_id,
|
|
50
|
+
"lastSummary": summary,
|
|
51
|
+
"unsummarizedCount": summary_index if summary_index is not None else len(entries),
|
|
52
|
+
"unsummarizedSince": summary["createdAt"] if summary is not None else "",
|
|
53
|
+
"openFollowups": activity.open_followups_oldest_first(),
|
|
54
|
+
"recentDecisions": [entry for entry in entries if is_journal_kind(entry, DECISION)][:RECENT_DECISION_COUNT],
|
|
55
|
+
"recentEntries": entries[:recent],
|
|
56
|
+
"tasks": [_task_overview(home, manager_id, group, task_id, now)
|
|
57
|
+
for group, task_id in _task_identities(home, manager_id)],
|
|
58
|
+
"damaged": activity.damaged,
|
|
59
|
+
}
|
|
@@ -19,7 +19,6 @@ from types import ModuleType
|
|
|
19
19
|
from typing import Any, TypedDict
|
|
20
20
|
|
|
21
21
|
from okstra_ctl.json_boundary import JsonBoundaryError, load_owned_object
|
|
22
|
-
from okstra_ctl.jsonl import append_jsonl
|
|
23
22
|
|
|
24
23
|
from .analysis_packet import _fence_mask, project_relative_ref
|
|
25
24
|
from .brief_sources import (
|
|
@@ -35,6 +34,7 @@ from .manager_store import (
|
|
|
35
34
|
_read_json,
|
|
36
35
|
_write_json,
|
|
37
36
|
create_task,
|
|
37
|
+
record_event,
|
|
38
38
|
list_projects,
|
|
39
39
|
load_manager,
|
|
40
40
|
)
|
|
@@ -746,7 +746,7 @@ def split_task(
|
|
|
746
746
|
_write_json(split_plan_path(home, manager_id, task_group, task_id), plan)
|
|
747
747
|
briefs = [{"taskKey": item["taskKey"], "projectId": item["projectId"], "ticketId": item["issue"]["ticketId"],
|
|
748
748
|
"briefPath": str(item["briefPath"]), "briefStatus": item["briefStatus"]} for item in items]
|
|
749
|
-
|
|
749
|
+
record_event(events_jsonl_path(home, manager_id, task_group, task_id),
|
|
750
750
|
{"event": "task-split", "createdAt": when, "source": source["ref"],
|
|
751
751
|
"taskKeys": [brief["taskKey"] for brief in briefs]})
|
|
752
752
|
return {"managerId": manager_id, "taskGroup": task_group, "taskId": task_id, "briefs": briefs}
|
|
@@ -4,12 +4,13 @@ from __future__ import annotations
|
|
|
4
4
|
import json
|
|
5
5
|
import os
|
|
6
6
|
import shutil
|
|
7
|
+
import sys
|
|
7
8
|
from datetime import datetime, timezone
|
|
8
9
|
from pathlib import Path
|
|
9
10
|
|
|
10
11
|
from okstra_project import project_json_path, upsert_project_json
|
|
11
12
|
|
|
12
|
-
from okstra_ctl.jsonl import append_jsonl
|
|
13
|
+
from okstra_ctl.jsonl import append_jsonl, parse_jsonl_snapshot
|
|
13
14
|
from okstra_ctl.json_boundary import (
|
|
14
15
|
JsonBoundaryError,
|
|
15
16
|
load_owned_object,
|
|
@@ -23,6 +24,7 @@ from .manager_paths import (
|
|
|
23
24
|
children_json_path,
|
|
24
25
|
directives_jsonl_path,
|
|
25
26
|
events_jsonl_path,
|
|
27
|
+
manager_events_jsonl_path,
|
|
26
28
|
manager_json_path,
|
|
27
29
|
manager_root,
|
|
28
30
|
projects_json_path,
|
|
@@ -46,6 +48,28 @@ def _write_json(path: Path, payload: dict) -> None:
|
|
|
46
48
|
write_owned_object_atomic(path, payload, artifact="manager state")
|
|
47
49
|
|
|
48
50
|
|
|
51
|
+
def record_event(path: Path, row: dict) -> None:
|
|
52
|
+
"""Append one activity row after the state change it describes has been saved.
|
|
53
|
+
|
|
54
|
+
An `OSError` is not raised: it becomes one stderr warning and the caller continues,
|
|
55
|
+
so a failed append never turns a saved state change into a failed command.
|
|
56
|
+
"""
|
|
57
|
+
try:
|
|
58
|
+
append_jsonl(path, row)
|
|
59
|
+
except OSError as exc:
|
|
60
|
+
# The state change already succeeded. Reporting failure would make the user repeat it.
|
|
61
|
+
print(f"okstra manager: activity log write failed: {path}: {exc.strerror or exc}", file=sys.stderr)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _field_changes(current: dict, requested: dict) -> dict:
|
|
65
|
+
"""`{field: {"from", "to"}}` for each requested value that differs from the current one."""
|
|
66
|
+
return {
|
|
67
|
+
key: {"from": current.get(key), "to": value}
|
|
68
|
+
for key, value in requested.items()
|
|
69
|
+
if current.get(key) != value
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
49
73
|
def _read_json(path: Path) -> dict:
|
|
50
74
|
if not path.is_file():
|
|
51
75
|
raise ManagerError(f"manager file not found: {path}")
|
|
@@ -58,6 +82,28 @@ def _read_json(path: Path) -> dict:
|
|
|
58
82
|
return data
|
|
59
83
|
|
|
60
84
|
|
|
85
|
+
def read_jsonl_rows(path: Path) -> tuple[list[dict], list[int]]:
|
|
86
|
+
"""Parsed rows and the line numbers of damaged lines; a missing file has neither."""
|
|
87
|
+
if not path.is_file():
|
|
88
|
+
return [], []
|
|
89
|
+
try:
|
|
90
|
+
text = path.read_text(encoding="utf-8")
|
|
91
|
+
except (OSError, UnicodeDecodeError) as exc:
|
|
92
|
+
raise ManagerError(f"failed to read {path}: {exc}") from exc
|
|
93
|
+
return parse_jsonl_snapshot(text)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def task_selection(task_group: str | None, task_id: str | None) -> tuple[str, str] | None:
|
|
97
|
+
"""`--task-group` / `--task-id` as one pair, or None when neither is given."""
|
|
98
|
+
if (task_group is None) != (task_id is None):
|
|
99
|
+
raise ManagerError("--task-group and --task-id must be given together")
|
|
100
|
+
if task_group is None or task_id is None:
|
|
101
|
+
return None
|
|
102
|
+
if not task_group.strip() or not task_id.strip():
|
|
103
|
+
raise ManagerError("--task-group and --task-id must not be empty")
|
|
104
|
+
return task_group, task_id
|
|
105
|
+
|
|
106
|
+
|
|
61
107
|
def _read_json_default(path: Path, default: dict) -> dict:
|
|
62
108
|
if not path.is_file():
|
|
63
109
|
return default
|
|
@@ -91,6 +137,10 @@ def init_manager(home: Path, manager_id: str, *, now: str | None = None) -> dict
|
|
|
91
137
|
}
|
|
92
138
|
root.mkdir(parents=True, exist_ok=True)
|
|
93
139
|
_write_json(path, payload)
|
|
140
|
+
record_event(
|
|
141
|
+
manager_events_jsonl_path(home, canonical_id),
|
|
142
|
+
{"event": "manager-initialized", "createdAt": payload["createdAt"]},
|
|
143
|
+
)
|
|
94
144
|
return payload
|
|
95
145
|
|
|
96
146
|
|
|
@@ -214,29 +264,49 @@ def link_project(
|
|
|
214
264
|
raise ManagerError(str(exc)) from exc
|
|
215
265
|
payload = _load_projects(home, manager_id)
|
|
216
266
|
entry = _project_entry(payload, project_id)
|
|
267
|
+
when = now or _now_iso()
|
|
217
268
|
next_entry = {
|
|
218
269
|
"projectId": project_id,
|
|
219
270
|
"projectRoot": str(root),
|
|
220
271
|
"role": role,
|
|
221
272
|
"tags": list(tags),
|
|
222
|
-
"linkedAt":
|
|
273
|
+
"linkedAt": when,
|
|
223
274
|
}
|
|
275
|
+
changes = {}
|
|
224
276
|
if entry is None:
|
|
225
277
|
payload["projects"].append(next_entry)
|
|
226
278
|
else:
|
|
279
|
+
changes = _field_changes(entry, {key: next_entry[key] for key in ("projectRoot", "role", "tags")})
|
|
227
280
|
entry.update(next_entry)
|
|
228
281
|
payload["projects"].sort(key=lambda item: item.get("projectId", ""))
|
|
229
282
|
_write_json(projects_json_path(home, manager_id), payload)
|
|
283
|
+
if entry is None or changes:
|
|
284
|
+
record_event(manager_events_jsonl_path(home, manager_id), _project_linked_event(next_entry, changes))
|
|
230
285
|
return payload
|
|
231
286
|
|
|
232
287
|
|
|
288
|
+
def _project_linked_event(linked: dict, changes: dict) -> dict:
|
|
289
|
+
row = {"event": "project-linked", "createdAt": linked["linkedAt"]}
|
|
290
|
+
row.update({key: linked[key] for key in ("projectId", "projectRoot", "role", "tags")})
|
|
291
|
+
if changes:
|
|
292
|
+
row["changes"] = changes
|
|
293
|
+
return row
|
|
294
|
+
|
|
295
|
+
|
|
233
296
|
def _ensure_group_meta(home: Path, manager_id: str, task_group: str, when: str) -> dict:
|
|
234
297
|
"""그룹 폴더와 `group.json` 을 만든다. 이미 있으면 처음 기록을 그대로 둔다."""
|
|
235
298
|
path = task_group_meta_path(home, manager_id, task_group)
|
|
236
299
|
if path.is_file():
|
|
237
300
|
return _read_json(path)
|
|
301
|
+
# A group directory without group.json predates group.json, so the group is not new.
|
|
302
|
+
group_is_new = not path.parent.is_dir()
|
|
238
303
|
meta = {"taskGroup": task_group, "createdAt": when}
|
|
239
304
|
_write_json(path, meta)
|
|
305
|
+
if group_is_new:
|
|
306
|
+
record_event(
|
|
307
|
+
manager_events_jsonl_path(home, manager_id),
|
|
308
|
+
{"event": "task-group-created", "createdAt": when, "taskGroup": task_group},
|
|
309
|
+
)
|
|
240
310
|
return meta
|
|
241
311
|
|
|
242
312
|
|
|
@@ -331,7 +401,7 @@ def create_task(
|
|
|
331
401
|
_ensure_group_meta(home, manager_id, task_group, when)
|
|
332
402
|
_write_json(manifest_path, manifest)
|
|
333
403
|
_write_json(children_json_path(home, manager_id, task_group, task_id), children)
|
|
334
|
-
|
|
404
|
+
record_event(
|
|
335
405
|
events_jsonl_path(home, manager_id, task_group, task_id),
|
|
336
406
|
{
|
|
337
407
|
"event": "task-children-added" if existing else "task-created",
|
|
@@ -398,14 +468,21 @@ def assign_child(
|
|
|
398
468
|
tags: list[str],
|
|
399
469
|
assignment: str,
|
|
400
470
|
child_task_id: str | None = None,
|
|
471
|
+
now: str | None = None,
|
|
401
472
|
) -> dict:
|
|
402
473
|
_read_json(task_manifest_path(home, manager_id, task_group, task_id))
|
|
403
474
|
payload = _load_children(home, manager_id, task_group, task_id)
|
|
404
475
|
child = _select_child_for_assignment(payload["children"], project_id, task_group, child_task_id)
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
child
|
|
476
|
+
requested = {"role": role, "tags": list(tags), "assignment": assignment}
|
|
477
|
+
changes = _field_changes(child, requested)
|
|
478
|
+
child.update(requested)
|
|
408
479
|
_write_json(children_json_path(home, manager_id, task_group, task_id), payload)
|
|
480
|
+
if changes:
|
|
481
|
+
record_event(
|
|
482
|
+
events_jsonl_path(home, manager_id, task_group, task_id),
|
|
483
|
+
{"event": "task-assigned", "createdAt": now or _now_iso(),
|
|
484
|
+
"taskKey": str(child.get("taskKey") or ""), "changes": changes},
|
|
485
|
+
)
|
|
409
486
|
return payload
|
|
410
487
|
|
|
411
488
|
|
|
@@ -510,10 +587,18 @@ def unlink_project(
|
|
|
510
587
|
_write_json(projects_json_path(home, manager_id), payload)
|
|
511
588
|
when = now or _now_iso()
|
|
512
589
|
for manifest, keys in affected:
|
|
513
|
-
|
|
590
|
+
record_event(
|
|
514
591
|
events_jsonl_path(home, manager_id, str(manifest["taskGroup"]), str(manifest["taskId"])),
|
|
515
592
|
{"event": "project-unlinked", "createdAt": when, "projectId": project_id, "taskKeys": keys},
|
|
516
593
|
)
|
|
594
|
+
# Task-level rows disappear with `remove task`; this copy keeps the unlink visible afterwards.
|
|
595
|
+
record_event(
|
|
596
|
+
manager_events_jsonl_path(home, manager_id),
|
|
597
|
+
{"event": "project-unlinked", "createdAt": when, "projectId": project_id,
|
|
598
|
+
"taskKeys": result["keptChildren"],
|
|
599
|
+
"tasks": [{"taskGroup": str(manifest["taskGroup"]), "taskId": str(manifest["taskId"])}
|
|
600
|
+
for manifest, _ in affected]},
|
|
601
|
+
)
|
|
517
602
|
return result
|
|
518
603
|
|
|
519
604
|
|
|
@@ -550,7 +635,7 @@ def remove_child(
|
|
|
550
635
|
child_context_path(
|
|
551
636
|
home, manager_id, task_group, task_id, project_id, str(child.get("taskId") or task_id)
|
|
552
637
|
).unlink(missing_ok=True)
|
|
553
|
-
|
|
638
|
+
record_event(
|
|
554
639
|
events_jsonl_path(home, manager_id, task_group, task_id),
|
|
555
640
|
{"event": "task-child-removed", "createdAt": now or _now_iso(), "taskKey": task_key},
|
|
556
641
|
)
|
|
@@ -577,16 +662,12 @@ def update_task(
|
|
|
577
662
|
raise ManagerError("task update needs at least one of --objective, --common-brief, --progress-mode")
|
|
578
663
|
if requested.get("progressMode") not in (None, "manual", "auto"):
|
|
579
664
|
raise ManagerError("progress-mode must be manual or auto")
|
|
580
|
-
changes =
|
|
581
|
-
key: {"from": manifest.get(key), "to": value}
|
|
582
|
-
for key, value in requested.items()
|
|
583
|
-
if manifest.get(key) != value
|
|
584
|
-
}
|
|
665
|
+
changes = _field_changes(manifest, requested)
|
|
585
666
|
for key, change in changes.items():
|
|
586
667
|
manifest[key] = change["to"]
|
|
587
668
|
if changes:
|
|
588
669
|
_write_json(manifest_path, manifest)
|
|
589
|
-
|
|
670
|
+
record_event(
|
|
590
671
|
events_jsonl_path(home, manager_id, task_group, task_id),
|
|
591
672
|
{"event": "task-updated", "createdAt": now or _now_iso(), "changes": changes},
|
|
592
673
|
)
|
|
@@ -594,7 +675,7 @@ def update_task(
|
|
|
594
675
|
|
|
595
676
|
|
|
596
677
|
def remove_task(
|
|
597
|
-
home: Path, manager_id: str, task_group: str, task_id: str, *, confirm: bool
|
|
678
|
+
home: Path, manager_id: str, task_group: str, task_id: str, *, confirm: bool, now: str | None = None
|
|
598
679
|
) -> dict:
|
|
599
680
|
"""manager task 폴더를 지운다. 하위 프로젝트의 태스크와 브리프는 남는다."""
|
|
600
681
|
manifest = _read_json(task_manifest_path(home, manager_id, task_group, task_id))
|
|
@@ -610,16 +691,29 @@ def remove_task(
|
|
|
610
691
|
}
|
|
611
692
|
if confirm:
|
|
612
693
|
shutil.rmtree(root)
|
|
694
|
+
record_event(
|
|
695
|
+
manager_events_jsonl_path(home, manager_id),
|
|
696
|
+
{"event": "task-removed", "createdAt": now or _now_iso(), "taskGroup": result["taskGroup"],
|
|
697
|
+
"taskId": result["taskId"],
|
|
698
|
+
"taskKeys": [str(child.get("taskKey") or "") for child in children if isinstance(child, dict)]},
|
|
699
|
+
)
|
|
613
700
|
return result
|
|
614
701
|
|
|
615
702
|
|
|
616
|
-
def remove_task_group(
|
|
703
|
+
def remove_task_group(
|
|
704
|
+
home: Path, manager_id: str, task_group: str, *, confirm: bool, now: str | None = None
|
|
705
|
+
) -> dict:
|
|
617
706
|
"""그룹 폴더와 그 안의 manager task 전부를 지운다."""
|
|
618
707
|
load_manager(home, manager_id)
|
|
619
708
|
root = task_group_root(home, manager_id, task_group)
|
|
620
709
|
if not root.is_dir():
|
|
621
710
|
raise ManagerError(f"unknown task group: {task_group}")
|
|
622
|
-
|
|
711
|
+
manifests = [(path, _read_json(path)) for path in sorted(root.glob("*/manifest.json"))]
|
|
712
|
+
task_ids = [str(manifest.get("taskId") or path.parent.name) for path, manifest in manifests]
|
|
713
|
+
meta_path = root / "group.json"
|
|
714
|
+
stored_name = str(_read_json(meta_path).get("taskGroup") or "") if meta_path.is_file() else ""
|
|
715
|
+
if not stored_name and manifests:
|
|
716
|
+
stored_name = str(manifests[0][1].get("taskGroup") or "")
|
|
623
717
|
result = {
|
|
624
718
|
"managerId": manager_id,
|
|
625
719
|
"taskGroup": task_group,
|
|
@@ -629,4 +723,9 @@ def remove_task_group(home: Path, manager_id: str, task_group: str, *, confirm:
|
|
|
629
723
|
}
|
|
630
724
|
if confirm:
|
|
631
725
|
shutil.rmtree(root)
|
|
726
|
+
record_event(
|
|
727
|
+
manager_events_jsonl_path(home, manager_id),
|
|
728
|
+
{"event": "task-group-removed", "createdAt": now or _now_iso(),
|
|
729
|
+
"taskGroup": stored_name or task_group, "taskIds": task_ids},
|
|
730
|
+
)
|
|
632
731
|
return result
|