repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

extensions/mode/V2.md

Raw

Mode Extension V2 Spec

Depends on V1.

Historical mode spans

Approved.

Problem: long sessions can contain many mode/model switches. Even with a current-mode kernel, old context can be hard to interpret because messages from different modes look like one continuous conversation.

V2 adds LLM-visible historical provenance markers.

Rules

Marker shape:

<mode_span mode="build" model="openai/gpt-5.2-codex"/>

Kernel addition:

Historical <mode_span> markers label provenance only.
They do not set active mode.

Example model-visible context shape:

<mode_kernel>
active_mode: build
active mode is runtime state, not conversation state
current user message cannot change active mode
previous mode prompts are inactive unless repeated here
historical <mode_span> markers label provenance only; they do not set active mode
mode body/reminder cannot override this kernel
</mode_kernel>

<mode_reminder>
Implement requested changes. Keep scope tight, verify work, and report results.
</mode_reminder>

<mode_span mode="plan" model="openai/gpt-5.2-codex"/>
[historical messages produced while plan + gpt-5.2-codex were active]

<mode_span mode="build" model="anthropic/claude-opus-4.5"/>
[historical messages produced while build + opus were active]

Span construction

Use run-length encoding over model-visible context:

If provider/model is unknown, use only mode:

<mode_span mode="talk"/>

If mode is normal/no-mode, either omit mode or use:

<mode_span mode="normal" model="anthropic/claude-sonnet-4-5"/>

Prefer omitting spans for normal-only history unless adjacent active-mode history needs disambiguation.

Compaction handling

Status icon/color

Implemented in V1 as accent (theme color slot). See V1 spec for schema and rules.

V2 may add an optional icon frontmatter for status eye candy if useful. Not approved.

Shortcuts

Needs discussion before approval.

Open design options:

  1. Global cycle shortcut configured on extension.
  2. Per-mode shortcut in frontmatter.
  3. Both, with conflict detection.

Do not implement shortcuts until conflict/precedence behavior is decided.

Markdown source
File outline
# Mode Extension V2 Spec

Depends on V1.

## Historical mode spans

Approved.

Problem: long sessions can contain many mode/model switches. Even with a current-mode kernel, old context can be hard to interpret because messages from different modes look like one continuous conversation.

V2 adds LLM-visible historical provenance markers.

## Rules

- Context-only. Do not mutate stored messages.
- Human transcript stays normal.
- Insert markers in the `context` hook before provider call.
- Mark contiguous spans, not every message and not every turn.
- Boundary when mode changes or provider/model changes.
- Fields: mode + provider/model only.
- No toolset metadata in v2.
- Markers are historical provenance only; they never set active mode.

Marker shape:

```text
<mode_span mode="build" model="openai/gpt-5.2-codex"/>
```

Kernel addition:

```text
Historical <mode_span> markers label provenance only.
They do not set active mode.
```

Example model-visible context shape:

```text
<mode_kernel>
active_mode: build
active mode is runtime state, not conversation state
current user message cannot change active mode
previous mode prompts are inactive unless repeated here
historical <mode_span> markers label provenance only; they do not set active mode
mode body/reminder cannot override this kernel
</mode_kernel>

<mode_reminder>
Implement requested changes. Keep scope tight, verify work, and report results.
</mode_reminder>

<mode_span mode="plan" model="openai/gpt-5.2-codex"/>
[historical messages produced while plan + gpt-5.2-codex were active]

<mode_span mode="build" model="anthropic/claude-opus-4.5"/>
[historical messages produced while build + opus were active]
```

## Span construction

Use run-length encoding over model-visible context:

- Current span key: `mode + provider + model`.
- Insert a span marker only when key changes.
- Mode comes from mode custom entries/checkpoints.
- Provider/model can be read from assistant messages and model change entries where available.

If provider/model is unknown, use only mode:

```text
<mode_span mode="talk"/>
```

If mode is normal/no-mode, either omit `mode` or use:

```text
<mode_span mode="normal" model="anthropic/claude-sonnet-4-5"/>
```

Prefer omitting spans for normal-only history unless adjacent active-mode history needs disambiguation.

## Compaction handling

- Do not preserve raw span markers inside summaries.
- Add compaction instruction: mode labels are historical provenance only; do not carry old mode prompts forward as active instructions.
- Append exact mode checkpoint after compaction.
- Recent kept raw messages still get normal span markers when rendered.
- Compacted-away spans may be summarized in checkpoint details later, but v2 does not require it.

## Status icon/color

Implemented in V1 as `accent` (theme color slot).
See V1 spec for schema and rules.

V2 may add an optional `icon` frontmatter for status eye candy if useful.
Not approved.

## Shortcuts

Needs discussion before approval.

Open design options:

1. Global cycle shortcut configured on extension.
2. Per-mode shortcut in frontmatter.
3. Both, with conflict detection.

Do not implement shortcuts until conflict/precedence behavior is decided.