aiwcli 0.9.7 → 0.10.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/bin/run.js +5 -2
- package/dist/lib/claude-settings-types.d.ts +2 -0
- package/dist/templates/CLAUDE.md +49 -18
- package/dist/templates/_shared/.claude/settings.json +4 -0
- package/dist/templates/_shared/hooks/__pycache__/__init__.cpython-313.pyc +0 -0
- package/dist/templates/_shared/hooks/__pycache__/archive_plan.cpython-313.pyc +0 -0
- package/dist/templates/_shared/hooks/__pycache__/context_enforcer.cpython-313.pyc +0 -0
- package/dist/templates/_shared/hooks/__pycache__/context_monitor.cpython-313.pyc +0 -0
- package/dist/templates/_shared/hooks/__pycache__/file-suggestion.cpython-313.pyc +0 -0
- package/dist/templates/_shared/hooks/__pycache__/pre_compact.cpython-313.pyc +0 -0
- package/dist/templates/_shared/hooks/__pycache__/session_end.cpython-313.pyc +0 -0
- package/dist/templates/_shared/hooks/__pycache__/session_start.cpython-313.pyc +0 -0
- package/dist/templates/_shared/hooks/__pycache__/task_create_atomicity.cpython-313.pyc +0 -0
- package/dist/templates/_shared/hooks/__pycache__/task_create_capture.cpython-313.pyc +0 -0
- package/dist/templates/_shared/hooks/__pycache__/task_update_capture.cpython-313.pyc +0 -0
- package/dist/templates/_shared/hooks/__pycache__/user_prompt_submit.cpython-313.pyc +0 -0
- package/dist/templates/_shared/hooks/archive_plan.py +87 -178
- package/dist/templates/_shared/hooks/context_monitor.py +128 -194
- package/dist/templates/_shared/hooks/file-suggestion.py +26 -23
- package/dist/templates/_shared/hooks/pre_compact.py +104 -0
- package/dist/templates/_shared/hooks/session_end.py +154 -0
- package/dist/templates/_shared/hooks/session_start.py +145 -59
- package/dist/templates/_shared/hooks/task_create_capture.py +26 -49
- package/dist/templates/_shared/hooks/task_update_capture.py +42 -100
- package/dist/templates/_shared/hooks/user_prompt_submit.py +63 -77
- package/dist/templates/_shared/lib/base/__init__.py +16 -0
- package/dist/templates/_shared/lib/base/__pycache__/__init__.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/base/__pycache__/constants.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/base/__pycache__/hook_utils.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/base/__pycache__/inference.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/base/__pycache__/logger.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/base/__pycache__/utils.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/base/constants.py +18 -4
- package/dist/templates/_shared/lib/base/hook_utils.py +199 -11
- package/dist/templates/_shared/lib/base/inference.py +121 -0
- package/dist/templates/_shared/lib/base/logger.py +291 -0
- package/dist/templates/_shared/lib/base/utils.py +49 -11
- package/dist/templates/_shared/lib/context/__init__.py +72 -80
- package/dist/templates/_shared/lib/context/__pycache__/__init__.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/__pycache__/context_formatter.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/__pycache__/context_manager.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/__pycache__/context_selector.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/__pycache__/context_store.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/__pycache__/discovery.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/__pycache__/plan_manager.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/__pycache__/task_tracker.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/context_formatter.py +316 -0
- package/dist/templates/_shared/lib/context/context_selector.py +491 -0
- package/dist/templates/_shared/lib/context/context_store.py +636 -0
- package/dist/templates/_shared/lib/context/plan_manager.py +204 -0
- package/dist/templates/_shared/lib/context/task_tracker.py +188 -0
- package/dist/templates/_shared/lib/handoff/__pycache__/__init__.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/handoff/__pycache__/document_generator.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/handoff/document_generator.py +14 -40
- package/dist/templates/_shared/lib/templates/README.md +5 -13
- package/dist/templates/_shared/lib/templates/__init__.py +2 -6
- package/dist/templates/_shared/lib/templates/__pycache__/__init__.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/templates/__pycache__/formatters.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/templates/__pycache__/plan_context.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/templates/plan_context.py +25 -79
- package/dist/templates/_shared/scripts/__pycache__/save_handoff.cpython-313.pyc +0 -0
- package/dist/templates/_shared/scripts/__pycache__/status_line.cpython-313.pyc +0 -0
- package/dist/templates/_shared/scripts/save_handoff.py +39 -19
- package/dist/templates/_shared/scripts/status_line.py +701 -0
- package/dist/templates/_shared/workflows/handoff.md +9 -3
- package/dist/templates/cc-native/.claude/settings.json +64 -9
- package/dist/templates/cc-native/CC-NATIVE-README.md +25 -28
- package/dist/templates/cc-native/MIGRATION.md +1 -1
- package/dist/templates/cc-native/TEMPLATE-SCHEMA.md +14 -39
- package/dist/templates/cc-native/_cc-native/agents/CLAUDE.md +1 -1
- package/dist/templates/cc-native/_cc-native/hooks/CLAUDE.md +57 -22
- package/dist/templates/cc-native/_cc-native/hooks/__pycache__/add_plan_context.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/hooks/__pycache__/cc-native-plan-review.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/hooks/__pycache__/mark_questions_asked.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/hooks/__pycache__/plan_accepted.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/hooks/__pycache__/plan_questions_early.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/hooks/__pycache__/suggest-fresh-perspective.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/hooks/add_plan_context.py +57 -57
- package/dist/templates/cc-native/_cc-native/hooks/cc-native-plan-review.py +208 -158
- package/dist/templates/cc-native/_cc-native/hooks/plan_accepted.py +127 -0
- package/dist/templates/cc-native/_cc-native/hooks/plan_questions_early.py +81 -0
- package/dist/templates/cc-native/_cc-native/hooks/suggest-fresh-perspective.py +26 -25
- package/dist/templates/cc-native/_cc-native/lib/CLAUDE.md +35 -10
- package/dist/templates/cc-native/_cc-native/lib/__pycache__/__init__.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/__pycache__/constants.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/__pycache__/debug.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/__pycache__/orchestrator.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/__pycache__/state.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/__pycache__/utils.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/debug.py +37 -22
- package/dist/templates/cc-native/_cc-native/lib/orchestrator.py +103 -42
- package/dist/templates/cc-native/_cc-native/lib/reviewers/__pycache__/__init__.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/reviewers/__pycache__/agent.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/reviewers/__pycache__/base.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/reviewers/__pycache__/codex.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/reviewers/__pycache__/gemini.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/reviewers/agent.py +26 -21
- package/dist/templates/cc-native/_cc-native/lib/reviewers/codex.py +12 -7
- package/dist/templates/cc-native/_cc-native/lib/reviewers/gemini.py +12 -7
- package/dist/templates/cc-native/_cc-native/lib/state.py +31 -16
- package/dist/templates/cc-native/_cc-native/lib/utils.py +210 -43
- package/dist/templates/cc-native/_cc-native/plan-review.config.json +1 -2
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/dist/templates/_shared/hooks/context_enforcer.py +0 -625
- package/dist/templates/_shared/hooks/task_create_atomicity.py +0 -205
- package/dist/templates/_shared/lib/context/cache.py +0 -444
- package/dist/templates/_shared/lib/context/context_extractor.py +0 -115
- package/dist/templates/_shared/lib/context/context_manager.py +0 -1054
- package/dist/templates/_shared/lib/context/discovery.py +0 -444
- package/dist/templates/_shared/lib/context/event_log.py +0 -308
- package/dist/templates/_shared/lib/context/plan_archive.py +0 -101
- package/dist/templates/_shared/lib/context/task_sync.py +0 -290
- package/dist/templates/_shared/lib/templates/persona_questions.py +0 -113
- package/dist/templates/cc-native/_cc-native/hooks/__pycache__/archive_plan.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/hooks/__pycache__/cc-native-agent-review.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/hooks/__pycache__/test_permission_request.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/async_archive.py +0 -68
- package/dist/templates/cc-native/_cc-native/lib/atomic_write.py +0 -98
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"""Context ID extraction from hook payloads.
|
|
2
|
-
|
|
3
|
-
Centralizes the logic for determining which context a hook operation
|
|
4
|
-
belongs to, using multiple fallback strategies.
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
from pathlib import Path
|
|
8
|
-
from typing import Any, Dict, Optional
|
|
9
|
-
|
|
10
|
-
from .context_manager import get_context_by_session_id, get_all_contexts
|
|
11
|
-
from ..base.utils import eprint
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def extract_context_id(
|
|
15
|
-
tool_input: Dict[str, Any],
|
|
16
|
-
project_root: Path,
|
|
17
|
-
session_id: Optional[str] = None,
|
|
18
|
-
hook_name: str = "hook",
|
|
19
|
-
check_persistent_id: bool = False
|
|
20
|
-
) -> Optional[str]:
|
|
21
|
-
"""
|
|
22
|
-
Extract context ID from tool input with multiple fallback strategies.
|
|
23
|
-
|
|
24
|
-
Order of precedence:
|
|
25
|
-
1. metadata.context field (explicit context specification)
|
|
26
|
-
2. Session ID lookup (session bound to context)
|
|
27
|
-
3. persistent_id parsing (if check_persistent_id=True, for TaskCreate)
|
|
28
|
-
4. Single active context fallback
|
|
29
|
-
|
|
30
|
-
Args:
|
|
31
|
-
tool_input: Tool input dict from hook payload
|
|
32
|
-
project_root: Project root directory
|
|
33
|
-
session_id: Optional session ID from hook payload
|
|
34
|
-
hook_name: Name of calling hook for log messages
|
|
35
|
-
check_persistent_id: Whether to check persistent_id for context hint
|
|
36
|
-
(used by task_create_capture for ID format parsing)
|
|
37
|
-
|
|
38
|
-
Returns:
|
|
39
|
-
Context ID string, or None if context cannot be determined
|
|
40
|
-
"""
|
|
41
|
-
# 1. Check metadata.context field (explicit)
|
|
42
|
-
metadata = tool_input.get("metadata", {})
|
|
43
|
-
if isinstance(metadata, dict):
|
|
44
|
-
context = metadata.get("context")
|
|
45
|
-
if context:
|
|
46
|
-
return context
|
|
47
|
-
|
|
48
|
-
# 2. Check session ID (session may be bound to a context)
|
|
49
|
-
if session_id:
|
|
50
|
-
try:
|
|
51
|
-
session_context = get_context_by_session_id(session_id, project_root)
|
|
52
|
-
if session_context:
|
|
53
|
-
eprint(f"[{hook_name}] Found context via session_id: {session_context.id}")
|
|
54
|
-
return session_context.id
|
|
55
|
-
except Exception as e:
|
|
56
|
-
eprint(f"[{hook_name}] Failed to lookup context by session: {e}")
|
|
57
|
-
|
|
58
|
-
# 3. Check persistent_id for context hint (task_create only)
|
|
59
|
-
# Format: "context-id-task-N" or similar
|
|
60
|
-
if check_persistent_id and isinstance(metadata, dict):
|
|
61
|
-
persistent_id = metadata.get("persistent_id", "")
|
|
62
|
-
if persistent_id and "-" in persistent_id:
|
|
63
|
-
parts = persistent_id.split("-")
|
|
64
|
-
if len(parts) >= 2:
|
|
65
|
-
# Reconstruct context ID (everything before last two parts)
|
|
66
|
-
context_parts = parts[:-2] if len(parts) > 2 else parts[:1]
|
|
67
|
-
potential_id = "-".join(context_parts)
|
|
68
|
-
if potential_id:
|
|
69
|
-
return potential_id
|
|
70
|
-
|
|
71
|
-
# 4. Check for single active context (fallback)
|
|
72
|
-
try:
|
|
73
|
-
contexts = get_all_contexts(status="active", project_root=project_root)
|
|
74
|
-
if len(contexts) == 1:
|
|
75
|
-
return contexts[0].id
|
|
76
|
-
except Exception as e:
|
|
77
|
-
eprint(f"[{hook_name}] Failed to get active contexts: {e}")
|
|
78
|
-
|
|
79
|
-
return None
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
def extract_context_id_for_session(
|
|
83
|
-
session_id: str,
|
|
84
|
-
project_root: Path,
|
|
85
|
-
hook_name: str = "hook"
|
|
86
|
-
) -> Optional[str]:
|
|
87
|
-
"""
|
|
88
|
-
Find context that matches this session_id.
|
|
89
|
-
|
|
90
|
-
Simpler variant for hooks that only need session-based lookup.
|
|
91
|
-
|
|
92
|
-
Args:
|
|
93
|
-
session_id: Session ID to match
|
|
94
|
-
project_root: Project root directory
|
|
95
|
-
hook_name: Name of calling hook for log messages
|
|
96
|
-
|
|
97
|
-
Returns:
|
|
98
|
-
Context ID or None if not found
|
|
99
|
-
"""
|
|
100
|
-
contexts = get_all_contexts(status="active", project_root=project_root)
|
|
101
|
-
|
|
102
|
-
# Primary strategy: Find context with matching session_id
|
|
103
|
-
for ctx in contexts:
|
|
104
|
-
if ctx.in_flight and ctx.in_flight.session_ids and session_id in ctx.in_flight.session_ids:
|
|
105
|
-
eprint(f"[{hook_name}] Found context by session: {ctx.id}")
|
|
106
|
-
return ctx.id
|
|
107
|
-
|
|
108
|
-
# Fallback: If only one context is planning, assume it's the one
|
|
109
|
-
planning_contexts = [c for c in contexts if c.in_flight and c.in_flight.mode == "planning"]
|
|
110
|
-
if len(planning_contexts) == 1:
|
|
111
|
-
eprint(f"[{hook_name}] Fallback: Single planning context: {planning_contexts[0].id}")
|
|
112
|
-
return planning_contexts[0].id
|
|
113
|
-
|
|
114
|
-
eprint(f"[{hook_name}] Could not find context for session {session_id}")
|
|
115
|
-
return None
|