aiwcli 0.9.8 → 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.
Files changed (116) hide show
  1. package/bin/run.js +5 -2
  2. package/dist/lib/claude-settings-types.d.ts +2 -0
  3. package/dist/templates/CLAUDE.md +3 -3
  4. package/dist/templates/_shared/.claude/settings.json +4 -0
  5. package/dist/templates/_shared/hooks/__pycache__/__init__.cpython-313.pyc +0 -0
  6. package/dist/templates/_shared/hooks/__pycache__/archive_plan.cpython-313.pyc +0 -0
  7. package/dist/templates/_shared/hooks/__pycache__/context_enforcer.cpython-313.pyc +0 -0
  8. package/dist/templates/_shared/hooks/__pycache__/context_monitor.cpython-313.pyc +0 -0
  9. package/dist/templates/_shared/hooks/__pycache__/file-suggestion.cpython-313.pyc +0 -0
  10. package/dist/templates/_shared/hooks/__pycache__/pre_compact.cpython-313.pyc +0 -0
  11. package/dist/templates/_shared/hooks/__pycache__/session_end.cpython-313.pyc +0 -0
  12. package/dist/templates/_shared/hooks/__pycache__/session_start.cpython-313.pyc +0 -0
  13. package/dist/templates/_shared/hooks/__pycache__/task_create_capture.cpython-313.pyc +0 -0
  14. package/dist/templates/_shared/hooks/__pycache__/task_update_capture.cpython-313.pyc +0 -0
  15. package/dist/templates/_shared/hooks/__pycache__/user_prompt_submit.cpython-313.pyc +0 -0
  16. package/dist/templates/_shared/hooks/archive_plan.py +87 -178
  17. package/dist/templates/_shared/hooks/context_monitor.py +104 -247
  18. package/dist/templates/_shared/hooks/file-suggestion.py +26 -23
  19. package/dist/templates/_shared/hooks/pre_compact.py +47 -32
  20. package/dist/templates/_shared/hooks/session_end.py +103 -60
  21. package/dist/templates/_shared/hooks/session_start.py +110 -81
  22. package/dist/templates/_shared/hooks/task_create_capture.py +26 -50
  23. package/dist/templates/_shared/hooks/task_update_capture.py +42 -115
  24. package/dist/templates/_shared/hooks/user_prompt_submit.py +61 -61
  25. package/dist/templates/_shared/lib/base/__init__.py +16 -0
  26. package/dist/templates/_shared/lib/base/__pycache__/__init__.cpython-313.pyc +0 -0
  27. package/dist/templates/_shared/lib/base/__pycache__/hook_utils.cpython-313.pyc +0 -0
  28. package/dist/templates/_shared/lib/base/__pycache__/inference.cpython-313.pyc +0 -0
  29. package/dist/templates/_shared/lib/base/__pycache__/logger.cpython-313.pyc +0 -0
  30. package/dist/templates/_shared/lib/base/__pycache__/utils.cpython-313.pyc +0 -0
  31. package/dist/templates/_shared/lib/base/hook_utils.py +199 -11
  32. package/dist/templates/_shared/lib/base/inference.py +121 -0
  33. package/dist/templates/_shared/lib/base/logger.py +291 -0
  34. package/dist/templates/_shared/lib/base/utils.py +42 -9
  35. package/dist/templates/_shared/lib/context/__init__.py +72 -80
  36. package/dist/templates/_shared/lib/context/__pycache__/__init__.cpython-313.pyc +0 -0
  37. package/dist/templates/_shared/lib/context/__pycache__/context_formatter.cpython-313.pyc +0 -0
  38. package/dist/templates/_shared/lib/context/__pycache__/context_manager.cpython-313.pyc +0 -0
  39. package/dist/templates/_shared/lib/context/__pycache__/context_selector.cpython-313.pyc +0 -0
  40. package/dist/templates/_shared/lib/context/__pycache__/context_store.cpython-313.pyc +0 -0
  41. package/dist/templates/_shared/lib/context/__pycache__/discovery.cpython-313.pyc +0 -0
  42. package/dist/templates/_shared/lib/context/__pycache__/plan_manager.cpython-313.pyc +0 -0
  43. package/dist/templates/_shared/lib/context/__pycache__/task_tracker.cpython-313.pyc +0 -0
  44. package/dist/templates/_shared/lib/context/context_formatter.py +316 -0
  45. package/dist/templates/_shared/lib/context/context_selector.py +491 -0
  46. package/dist/templates/_shared/lib/context/context_store.py +636 -0
  47. package/dist/templates/_shared/lib/context/plan_manager.py +204 -0
  48. package/dist/templates/_shared/lib/context/task_tracker.py +188 -0
  49. package/dist/templates/_shared/lib/handoff/__pycache__/__init__.cpython-313.pyc +0 -0
  50. package/dist/templates/_shared/lib/handoff/__pycache__/document_generator.cpython-313.pyc +0 -0
  51. package/dist/templates/_shared/lib/handoff/document_generator.py +14 -40
  52. package/dist/templates/_shared/lib/templates/README.md +5 -13
  53. package/dist/templates/_shared/lib/templates/__init__.py +2 -6
  54. package/dist/templates/_shared/lib/templates/__pycache__/__init__.cpython-313.pyc +0 -0
  55. package/dist/templates/_shared/lib/templates/__pycache__/formatters.cpython-313.pyc +0 -0
  56. package/dist/templates/_shared/lib/templates/__pycache__/plan_context.cpython-313.pyc +0 -0
  57. package/dist/templates/_shared/lib/templates/plan_context.py +1 -38
  58. package/dist/templates/_shared/scripts/__pycache__/save_handoff.cpython-313.pyc +0 -0
  59. package/dist/templates/_shared/scripts/__pycache__/status_line.cpython-313.pyc +0 -0
  60. package/dist/templates/_shared/scripts/save_handoff.py +39 -19
  61. package/dist/templates/_shared/scripts/status_line.py +701 -0
  62. package/dist/templates/_shared/workflows/handoff.md +9 -3
  63. package/dist/templates/cc-native/.claude/settings.json +41 -8
  64. package/dist/templates/cc-native/CC-NATIVE-README.md +25 -28
  65. package/dist/templates/cc-native/MIGRATION.md +1 -1
  66. package/dist/templates/cc-native/TEMPLATE-SCHEMA.md +14 -39
  67. package/dist/templates/cc-native/_cc-native/hooks/CLAUDE.md +49 -21
  68. package/dist/templates/cc-native/_cc-native/hooks/__pycache__/add_plan_context.cpython-313.pyc +0 -0
  69. package/dist/templates/cc-native/_cc-native/hooks/__pycache__/cc-native-plan-review.cpython-313.pyc +0 -0
  70. package/dist/templates/cc-native/_cc-native/hooks/__pycache__/mark_questions_asked.cpython-313.pyc +0 -0
  71. package/dist/templates/cc-native/_cc-native/hooks/__pycache__/plan_accepted.cpython-313.pyc +0 -0
  72. package/dist/templates/cc-native/_cc-native/hooks/__pycache__/plan_questions_early.cpython-313.pyc +0 -0
  73. package/dist/templates/cc-native/_cc-native/hooks/__pycache__/suggest-fresh-perspective.cpython-313.pyc +0 -0
  74. package/dist/templates/cc-native/_cc-native/hooks/add_plan_context.py +57 -55
  75. package/dist/templates/cc-native/_cc-native/hooks/cc-native-plan-review.py +163 -131
  76. package/dist/templates/cc-native/_cc-native/hooks/plan_accepted.py +127 -0
  77. package/dist/templates/cc-native/_cc-native/hooks/plan_questions_early.py +81 -0
  78. package/dist/templates/cc-native/_cc-native/hooks/suggest-fresh-perspective.py +26 -25
  79. package/dist/templates/cc-native/_cc-native/lib/CLAUDE.md +6 -4
  80. package/dist/templates/cc-native/_cc-native/lib/__pycache__/__init__.cpython-313.pyc +0 -0
  81. package/dist/templates/cc-native/_cc-native/lib/__pycache__/constants.cpython-313.pyc +0 -0
  82. package/dist/templates/cc-native/_cc-native/lib/__pycache__/debug.cpython-313.pyc +0 -0
  83. package/dist/templates/cc-native/_cc-native/lib/__pycache__/orchestrator.cpython-313.pyc +0 -0
  84. package/dist/templates/cc-native/_cc-native/lib/__pycache__/state.cpython-313.pyc +0 -0
  85. package/dist/templates/cc-native/_cc-native/lib/__pycache__/utils.cpython-313.pyc +0 -0
  86. package/dist/templates/cc-native/_cc-native/lib/debug.py +37 -22
  87. package/dist/templates/cc-native/_cc-native/lib/orchestrator.py +34 -29
  88. package/dist/templates/cc-native/_cc-native/lib/reviewers/__pycache__/__init__.cpython-313.pyc +0 -0
  89. package/dist/templates/cc-native/_cc-native/lib/reviewers/__pycache__/agent.cpython-313.pyc +0 -0
  90. package/dist/templates/cc-native/_cc-native/lib/reviewers/__pycache__/base.cpython-313.pyc +0 -0
  91. package/dist/templates/cc-native/_cc-native/lib/reviewers/__pycache__/codex.cpython-313.pyc +0 -0
  92. package/dist/templates/cc-native/_cc-native/lib/reviewers/__pycache__/gemini.cpython-313.pyc +0 -0
  93. package/dist/templates/cc-native/_cc-native/lib/reviewers/agent.py +26 -21
  94. package/dist/templates/cc-native/_cc-native/lib/reviewers/codex.py +12 -7
  95. package/dist/templates/cc-native/_cc-native/lib/reviewers/gemini.py +12 -7
  96. package/dist/templates/cc-native/_cc-native/lib/state.py +31 -16
  97. package/dist/templates/cc-native/_cc-native/lib/utils.py +207 -40
  98. package/dist/templates/cc-native/_cc-native/plan-review.config.json +1 -2
  99. package/oclif.manifest.json +1 -1
  100. package/package.json +1 -1
  101. package/dist/templates/_shared/hooks/context_enforcer.py +0 -625
  102. package/dist/templates/_shared/hooks/task_create_atomicity.py +0 -177
  103. package/dist/templates/_shared/lib/context/auto_state.py +0 -167
  104. package/dist/templates/_shared/lib/context/cache.py +0 -444
  105. package/dist/templates/_shared/lib/context/context_extractor.py +0 -115
  106. package/dist/templates/_shared/lib/context/context_manager.py +0 -1057
  107. package/dist/templates/_shared/lib/context/discovery.py +0 -554
  108. package/dist/templates/_shared/lib/context/event_log.py +0 -316
  109. package/dist/templates/_shared/lib/context/plan_archive.py +0 -101
  110. package/dist/templates/_shared/lib/context/task_sync.py +0 -407
  111. package/dist/templates/_shared/lib/templates/persona_questions.py +0 -113
  112. package/dist/templates/cc-native/_cc-native/hooks/__pycache__/archive_plan.cpython-313.pyc +0 -0
  113. package/dist/templates/cc-native/_cc-native/hooks/__pycache__/cc-native-agent-review.cpython-313.pyc +0 -0
  114. package/dist/templates/cc-native/_cc-native/hooks/__pycache__/test_permission_request.cpython-313.pyc +0 -0
  115. package/dist/templates/cc-native/_cc-native/lib/async_archive.py +0 -68
  116. package/dist/templates/cc-native/_cc-native/lib/atomic_write.py +0 -98
@@ -31,8 +31,8 @@ SCRIPT_DIR = Path(__file__).resolve().parent
31
31
  SHARED_ROOT = SCRIPT_DIR.parent
32
32
  sys.path.insert(0, str(SHARED_ROOT))
33
33
 
34
- from lib.context.context_manager import get_context
35
- from lib.base.utils import eprint
34
+ from lib.context.context_store import get_context, save_state, update_mode
35
+ from lib.base.logger import log_info, log_warn, log_error
36
36
  from lib.base.atomic_write import atomic_write
37
37
  from lib.base.constants import get_handoff_folder_path
38
38
 
@@ -106,16 +106,14 @@ def get_git_status() -> str:
106
106
 
107
107
 
108
108
  def get_plan_path_from_context(context_id: str, project_root: Path) -> Optional[Path]:
109
- """Get the plan path from context.json if available."""
109
+ """Get the plan path from state.json if available."""
110
110
  context = get_context(context_id, project_root)
111
- if not context or not context.in_flight:
111
+ if not context or not context.plan_path:
112
112
  return None
113
113
 
114
- artifact_path = context.in_flight.artifact_path
115
- if artifact_path:
116
- plan_path = Path(artifact_path)
117
- if plan_path.exists():
118
- return plan_path
114
+ plan_path = Path(context.plan_path)
115
+ if plan_path.exists():
116
+ return plan_path
119
117
 
120
118
  return None
121
119
 
@@ -206,7 +204,7 @@ def write_section_file(folder: Path, filename: str, title: str, content: str) ->
206
204
  file_path = folder / filename
207
205
  success, error = atomic_write(file_path, '\n'.join(lines))
208
206
  if not success:
209
- eprint(f"[save_handoff] Warning: Failed to write {filename}: {error}")
207
+ log_warn("save_handoff", f"Failed to write {filename}: {error}")
210
208
  return False
211
209
  return True
212
210
 
@@ -224,7 +222,7 @@ def main():
224
222
  # Read content from stdin
225
223
  content = sys.stdin.read()
226
224
  if not content.strip():
227
- print("Error: No content provided via stdin", file=sys.stderr)
225
+ log_error("save_handoff", "No content provided via stdin")
228
226
  sys.exit(1)
229
227
 
230
228
  # Project root is the parent of .aiwcli
@@ -233,19 +231,19 @@ def main():
233
231
  # Verify context exists
234
232
  context = get_context(context_id, project_root)
235
233
  if not context:
236
- print(f"Error: Context not found: {context_id}", file=sys.stderr)
234
+ log_error("save_handoff", f"Context not found: {context_id}")
237
235
  sys.exit(1)
238
236
 
239
237
  # Parse frontmatter and sections
240
238
  frontmatter, body = parse_frontmatter(content)
241
239
  sections = parse_handoff_sections(body)
242
240
 
243
- eprint(f"[save_handoff] Parsed {len(sections)} sections: {list(sections.keys())}")
241
+ log_info("save_handoff", f"Parsed {len(sections)} sections: {list(sections.keys())}")
244
242
 
245
243
  # Create handoff folder
246
244
  handoff_folder = get_handoff_folder_path(context_id, project_root)
247
245
  handoff_folder.mkdir(parents=True, exist_ok=True)
248
- eprint(f"[save_handoff] Created folder: {handoff_folder}")
246
+ log_info("save_handoff", f"Created folder: {handoff_folder}")
249
247
 
250
248
  # Get git status
251
249
  git_status = get_git_status()
@@ -261,18 +259,18 @@ def main():
261
259
  plan_dest = handoff_folder / "plan.md"
262
260
  success, error = atomic_write(plan_dest, plan_content)
263
261
  if success:
264
- eprint(f"[save_handoff] Copied plan from {plan_path}")
262
+ log_info("save_handoff", f"Copied plan from {plan_path}")
265
263
  else:
266
- eprint(f"[save_handoff] Warning: Failed to copy plan: {error}")
264
+ log_warn("save_handoff", f"Failed to copy plan: {error}")
267
265
  except Exception as e:
268
- eprint(f"[save_handoff] Warning: Failed to read plan: {e}")
266
+ log_warn("save_handoff", f"Failed to read plan: {e}")
269
267
 
270
268
  # Write index.md
271
269
  index_content = generate_index(frontmatter, sections, git_status, has_plan)
272
270
  index_path = handoff_folder / "index.md"
273
271
  success, error = atomic_write(index_path, index_content)
274
272
  if not success:
275
- print(f"Error: Failed to write index.md: {error}", file=sys.stderr)
273
+ log_error("save_handoff", f"Failed to write index.md: {error}")
276
274
  sys.exit(1)
277
275
 
278
276
  # Write section files
@@ -313,7 +311,7 @@ def main():
313
311
  full_content = '\n'.join(content_parts) + '\n'
314
312
  success, error = atomic_write(file_path, full_content)
315
313
  if not success:
316
- eprint(f"[save_handoff] Warning: Failed to write {filename}: {error}")
314
+ log_warn("save_handoff", f"Failed to write {filename}: {error}")
317
315
 
318
316
  # Ensure all expected files exist (even if empty)
319
317
  expected_files = ['completed-work.md', 'dead-ends.md', 'decisions.md', 'pending.md', 'context.md']
@@ -330,6 +328,28 @@ def main():
330
328
  if not file_path.exists():
331
329
  write_section_file(handoff_folder, filename, titles[filename], "")
332
330
 
331
+ # Set handoff_path so next session auto-detects it
332
+ try:
333
+ index_path_str = str(handoff_folder / "index.md")
334
+ state = get_context(context_id, project_root)
335
+ if state:
336
+ state.handoff_path = index_path_str
337
+ save_state(state, project_root)
338
+ log_info("save_handoff", f"Set handoff_path: {index_path_str}")
339
+ else:
340
+ log_warn("save_handoff", f"Could not load context state for {context_id}")
341
+ except Exception as e:
342
+ log_warn("save_handoff", f"Handoff saved but auto-resume won't work (context update failed): {e}")
343
+
344
+ # Transition context to idle — handoff is saved, no longer "active work"
345
+ # This prevents auto-selection in new sessions while keeping the context
346
+ # accessible via explicit caret commands (^, ^N)
347
+ try:
348
+ update_mode(context_id, "idle", project_root=project_root)
349
+ log_info("save_handoff", f"Set mode to 'idle' (dormant) for context: {context_id}")
350
+ except Exception as e:
351
+ log_warn("save_handoff", f"Failed to set dormant mode: {e}")
352
+
333
353
  # Output success message (ASCII-safe for Windows)
334
354
  print(f"[OK] Created handoff folder: {handoff_folder}")
335
355
  print(f" - index.md (entry point with navigation)")