Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
integration="claude-code",
user_agent="powercontext-claude-code-plugin/0.1.4",
component="powercontext.claude_code",
prompt_id_field="prompt_id",
diagnostics=DiagnosticThrottle(state_file="claude-code-diagnostics.json"),
bootstrap_state=BootstrapState(
directory_variable="POWERCONTEXT_CLAUDE_BOOTSTRAP_STATE_DIR",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
from urllib.parse import urlsplit, urlunsplit

from powercontext_lifecycle.client_config import load_client_settings, parse_boolean, resolve_allow_insecure_http
from powercontext_lifecycle.scope_binding import ScopeBindingSettings
from powercontext_lifecycle.user_prompt_submit import PromptSettings

# Kept in lockstep with powercontext.transport.LOOPBACK_HOSTS; the plugin ships
# isolated and cannot import powercontext.
Expand Down Expand Up @@ -176,6 +178,29 @@ def from_environment(cls, *, server_url: str | None = None) -> ClaudeCodePluginS
),
)

def scope_binding_settings(self) -> ScopeBindingSettings:
"""Return the values that the Scope client uses."""

return ScopeBindingSettings(
server_url=self.server_url,
authorization=self.authorization,
scope_id=self.scope_id,
request_timeout_seconds=self.request_timeout_seconds,
)

def prompt_settings(self) -> PromptSettings:
"""Return the values that the prompt flow uses."""

return PromptSettings(
scope_binding=self.scope_binding_settings(),
include_code=self.include_code,
context_assembly=self.context_assembly,
prompt_recall=True,
capture_prompts=self.capture_prompts,
flush_on_capture=self.flush_on_capture,
flush_max_calls=self.flush_max_calls,
)


def _first_environment(*names: str) -> str | None:
for name in names:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,17 @@
from typing import Any, cast

_PLUGIN_ROOT = Path(__file__).resolve().parents[1]
_SCRIPTS_ROOT = _PLUGIN_ROOT / "scripts"
sys.path.insert(0, str(_PLUGIN_ROOT))
sys.path.insert(0, str(_SCRIPTS_ROOT))

from claude_code_host import CLAUDE_CODE # noqa: E402
from claude_code_settings import ClaudeCodePluginSettings # noqa: E402
from powercontext_lifecycle.scope_binding import read_error_code, resolve_scope_id # noqa: E402
from powercontext_lifecycle.session_start import ( # noqa: E402
BootstrapConnection,
SessionStartEvent,
hook_event_id,
run_session_start,
)
from workspace_scope import read_error_code, resolve_scope_id # noqa: E402

_LIFECYCLES = frozenset({"startup", "resume", "clear", "compact", "fork"})

Expand Down Expand Up @@ -74,9 +72,10 @@ def _connect(event: SessionStartEvent, settings: ClaudeCodePluginSettings | None
max_bytes=loaded.bootstrap_max_bytes,
handoff=None if loaded.bootstrap_handoff is None else loaded.bootstrap_handoff.as_request(),
resolve_scope_id=lambda deadline: resolve_scope_id(
CLAUDE_CODE,
event.cwd,
session_id=event.session_id,
settings=loaded,
settings=loaded.scope_binding_settings(),
deadline=deadline,
),
read_error_code=read_error_code,
Expand Down
Loading
Loading