2 Commits
Author SHA1 Message Date
baizhu945 1c03a59376 feat(pi): inject permission mode into agent process env (#1637)
* feat(pi): inject permission mode into agent process env

The pi permission-gate extension runs inside the pi CLI and has no way
to learn cc-connect's permission mode. When a user switches to yolo
(auto-approve) mode in Feishu, the engine restarts the session, but the
new pi process is still spawned without any mode hint, so the extension
keeps emitting permission cards.

Inject CC_PERMISSION_MODE=<mode> into the spawned pi process environment
in StartSession. The extension reads it and auto-approves all tool calls
in yolo mode. Mode switches already recreate the session (pi does not
implement LiveModeSwitcher), so the new process picks up the new value.

* test(pi): check Close error in StartSession test to satisfy errcheck

* refactor(pi): move permission-mode env injection into core helper

Extract the hardcoded CC_PERMISSION_MODE append into core.InjectedAgentEnv
so the env var becomes a documented, reusable part of cc-connect's CC_*
extension contract instead of a one-off string in the pi agent. Other
agents can opt into the same convention.

Add TestAgent_StartSession_UserOverrideWins to lock in that the
engine-injected value is appended after config/session env, so a
user-supplied CC_PERMISSION_MODE keeps priority (getenv returns the first
match).
2026-08-14 08:31:08 +08:00
baizhu945 d743b147b8 fix(pi): fall back to models-store.json when enabledModels is unset (#1636)
* fix(pi): fall back to models-store.json when enabledModels is unset

AvailableModels only read enabledModels from settings.json, which is
empty by default. /model in Feishu then renders an empty select with
only the current model, making model switching impossible.

Fall back to pi's own model catalog (~/.pi/agent/models-store.json),
which pi maintains as providers are added, when enabledModels is not
configured.

* test(pi): cover models-store.json fallback in readModelsStore

Add TestReadModelsStore mirroring TestReadSettingsModels: missing file,
valid file sorted provider-qualified, empty-id skip, and malformed JSON.
Add TestAgent_AvailableModels_FallsBackToStore for the enabledModels-empty
→ catalog fallback path.

Clarify in loadModelsContextWindows that models.json (context windows) is
distinct from models-store.json (the /model catalog).
2026-08-14 08:30:51 +08:00