2026-03-31 05:38:29 -07:00
|
|
|
"""Python porting workspace for the Claude Code rewrite effort."""
|
|
|
|
|
|
|
|
|
|
from .commands import PORTED_COMMANDS, build_command_backlog
|
|
|
|
|
from .parity_audit import ParityAuditResult, run_parity_audit
|
|
|
|
|
from .port_manifest import PortManifest, build_port_manifest
|
2026-03-31 08:03:46 -07:00
|
|
|
from .query_engine import QueryEnginePort, TurnResult
|
|
|
|
|
from .runtime import PortRuntime, RuntimeSession
|
feat(#160): wire claw list-sessions and delete-session CLI commands
Closes the last #160 gap: claws can now manage session lifecycle entirely
through the CLI without filesystem hacks.
New commands:
- claw list-sessions [--directory DIR] [--output-format text|json]
Enumerates stored session IDs. JSON mode emits {sessions, count}.
Missing/empty directories return empty list (exit 0), not an error.
- claw delete-session SESSION_ID [--directory DIR] [--output-format text|json]
Idempotent: not-found is exit 0 with status='not_found' (no raise).
Partial-failure: exit 1 with typed JSON error envelope:
{session_id, deleted: false, error: {kind, message, retryable}}
The 'session_delete_failed' kind is retryable=true so orchestrators
know to retry vs escalate.
Public API surface extended in src/__init__.py:
- list_sessions, session_exists, delete_session
- SessionNotFoundError, SessionDeleteError
Tests added (tests/test_porting_workspace.py):
- test_list_sessions_cli_runs: text + json modes against tempdir
- test_delete_session_cli_idempotent: first call deleted=true,
second call deleted=false (exit 0, status=not_found)
- test_delete_session_cli_partial_failure_exit_1: permission error
surfaces as exit 1 + typed JSON error with retryable=true
All 43 tests pass. The session storage abstraction chapter is closed:
- storage layer decoupled from claw code (#160 initial impl)
- delete contract hardened + caller-audited (#160 hardening pass)
- CLI wired with idempotency preserved at exit-code boundary (this commit)
2026-04-22 17:16:53 +09:00
|
|
|
from .session_store import (
|
|
|
|
|
SessionDeleteError,
|
|
|
|
|
SessionNotFoundError,
|
|
|
|
|
StoredSession,
|
|
|
|
|
delete_session,
|
|
|
|
|
list_sessions,
|
|
|
|
|
load_session,
|
|
|
|
|
save_session,
|
|
|
|
|
session_exists,
|
|
|
|
|
)
|
2026-03-31 08:03:46 -07:00
|
|
|
from .system_init import build_system_init_message
|
2026-03-31 05:38:29 -07:00
|
|
|
from .tools import PORTED_TOOLS, build_tool_backlog
|
|
|
|
|
|
|
|
|
|
__all__ = [
|
|
|
|
|
'ParityAuditResult',
|
|
|
|
|
'PortManifest',
|
2026-03-31 08:03:46 -07:00
|
|
|
'PortRuntime',
|
2026-03-31 05:38:29 -07:00
|
|
|
'QueryEnginePort',
|
2026-03-31 08:03:46 -07:00
|
|
|
'RuntimeSession',
|
feat(#160): wire claw list-sessions and delete-session CLI commands
Closes the last #160 gap: claws can now manage session lifecycle entirely
through the CLI without filesystem hacks.
New commands:
- claw list-sessions [--directory DIR] [--output-format text|json]
Enumerates stored session IDs. JSON mode emits {sessions, count}.
Missing/empty directories return empty list (exit 0), not an error.
- claw delete-session SESSION_ID [--directory DIR] [--output-format text|json]
Idempotent: not-found is exit 0 with status='not_found' (no raise).
Partial-failure: exit 1 with typed JSON error envelope:
{session_id, deleted: false, error: {kind, message, retryable}}
The 'session_delete_failed' kind is retryable=true so orchestrators
know to retry vs escalate.
Public API surface extended in src/__init__.py:
- list_sessions, session_exists, delete_session
- SessionNotFoundError, SessionDeleteError
Tests added (tests/test_porting_workspace.py):
- test_list_sessions_cli_runs: text + json modes against tempdir
- test_delete_session_cli_idempotent: first call deleted=true,
second call deleted=false (exit 0, status=not_found)
- test_delete_session_cli_partial_failure_exit_1: permission error
surfaces as exit 1 + typed JSON error with retryable=true
All 43 tests pass. The session storage abstraction chapter is closed:
- storage layer decoupled from claw code (#160 initial impl)
- delete contract hardened + caller-audited (#160 hardening pass)
- CLI wired with idempotency preserved at exit-code boundary (this commit)
2026-04-22 17:16:53 +09:00
|
|
|
'SessionDeleteError',
|
|
|
|
|
'SessionNotFoundError',
|
2026-03-31 08:03:46 -07:00
|
|
|
'StoredSession',
|
|
|
|
|
'TurnResult',
|
2026-03-31 05:38:29 -07:00
|
|
|
'PORTED_COMMANDS',
|
|
|
|
|
'PORTED_TOOLS',
|
|
|
|
|
'build_command_backlog',
|
|
|
|
|
'build_port_manifest',
|
2026-03-31 08:03:46 -07:00
|
|
|
'build_system_init_message',
|
2026-03-31 05:38:29 -07:00
|
|
|
'build_tool_backlog',
|
feat(#160): wire claw list-sessions and delete-session CLI commands
Closes the last #160 gap: claws can now manage session lifecycle entirely
through the CLI without filesystem hacks.
New commands:
- claw list-sessions [--directory DIR] [--output-format text|json]
Enumerates stored session IDs. JSON mode emits {sessions, count}.
Missing/empty directories return empty list (exit 0), not an error.
- claw delete-session SESSION_ID [--directory DIR] [--output-format text|json]
Idempotent: not-found is exit 0 with status='not_found' (no raise).
Partial-failure: exit 1 with typed JSON error envelope:
{session_id, deleted: false, error: {kind, message, retryable}}
The 'session_delete_failed' kind is retryable=true so orchestrators
know to retry vs escalate.
Public API surface extended in src/__init__.py:
- list_sessions, session_exists, delete_session
- SessionNotFoundError, SessionDeleteError
Tests added (tests/test_porting_workspace.py):
- test_list_sessions_cli_runs: text + json modes against tempdir
- test_delete_session_cli_idempotent: first call deleted=true,
second call deleted=false (exit 0, status=not_found)
- test_delete_session_cli_partial_failure_exit_1: permission error
surfaces as exit 1 + typed JSON error with retryable=true
All 43 tests pass. The session storage abstraction chapter is closed:
- storage layer decoupled from claw code (#160 initial impl)
- delete contract hardened + caller-audited (#160 hardening pass)
- CLI wired with idempotency preserved at exit-code boundary (this commit)
2026-04-22 17:16:53 +09:00
|
|
|
'delete_session',
|
|
|
|
|
'list_sessions',
|
2026-03-31 08:03:46 -07:00
|
|
|
'load_session',
|
2026-03-31 05:38:29 -07:00
|
|
|
'run_parity_audit',
|
2026-03-31 08:03:46 -07:00
|
|
|
'save_session',
|
feat(#160): wire claw list-sessions and delete-session CLI commands
Closes the last #160 gap: claws can now manage session lifecycle entirely
through the CLI without filesystem hacks.
New commands:
- claw list-sessions [--directory DIR] [--output-format text|json]
Enumerates stored session IDs. JSON mode emits {sessions, count}.
Missing/empty directories return empty list (exit 0), not an error.
- claw delete-session SESSION_ID [--directory DIR] [--output-format text|json]
Idempotent: not-found is exit 0 with status='not_found' (no raise).
Partial-failure: exit 1 with typed JSON error envelope:
{session_id, deleted: false, error: {kind, message, retryable}}
The 'session_delete_failed' kind is retryable=true so orchestrators
know to retry vs escalate.
Public API surface extended in src/__init__.py:
- list_sessions, session_exists, delete_session
- SessionNotFoundError, SessionDeleteError
Tests added (tests/test_porting_workspace.py):
- test_list_sessions_cli_runs: text + json modes against tempdir
- test_delete_session_cli_idempotent: first call deleted=true,
second call deleted=false (exit 0, status=not_found)
- test_delete_session_cli_partial_failure_exit_1: permission error
surfaces as exit 1 + typed JSON error with retryable=true
All 43 tests pass. The session storage abstraction chapter is closed:
- storage layer decoupled from claw code (#160 initial impl)
- delete contract hardened + caller-audited (#160 hardening pass)
- CLI wired with idempotency preserved at exit-code boundary (this commit)
2026-04-22 17:16:53 +09:00
|
|
|
'session_exists',
|
2026-03-31 05:38:29 -07:00
|
|
|
]
|