@llblab/pi-state-flow 0.11.0 → 0.11.1

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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## 0.11.1: Telegram inspection hierarchy
8
+
9
+ - `Telegram inspection`: `👁 Show state` now follows Start/Stop, and its Back, 🌐 Global, 📂 CWD, 💬 Session, and 🧬 Effective controls form one vertical composition axis. A selected scope opens with a fixed emoji-bearing heading followed directly by the four top-level collapsible semantic fields, removing the redundant outer disclosure.
10
+
7
11
  ## 0.11.0: Telegram state inspection
8
12
 
9
13
  - `Telegram inspection`: The State Flow submenu now offers `👁 Show state` with Global, CWD, Session, and Effective choices. Selecting one scope sends exactly that projected materialized slice as a standalone Telegram Native Rich Message whose semantic fields use collapsible `details` and JSON `pre` blocks; inspection is read-only and the optional adapter remains fail-open without a compatible pi-telegram membrane.
package/README.md CHANGED
@@ -53,7 +53,7 @@ Continue working normally. The agent receives the state protocol and uses `patch
53
53
 
54
54
  State Flow is **opt-in**. Starting in an existing conversation keeps its active context for one migration run. To enable genuinely new sessions automatically, set `"autoStart": true` in the optional [configuration](docs/usage.md#configuration).
55
55
 
56
- With a compatible `pi-telegram` installed, its main menu also exposes the same Start/Stop controls and a `👁 Show state` chooser for Global, CWD, Session, or Effective memory. Selecting one scope sends exactly that materialized slice as a standalone native Rich Message with collapsible semantic fields; inspection is read-only and does not create a State Flow transition.
56
+ With a compatible `pi-telegram` installed, its main menu exposes the same Start/Stop controls followed by `👁 Show state`. The chooser presents Back, 🌐 Global, 📂 CWD, 💬 Session, and 🧬 Effective as one vertical composition axis. Selecting a scope sends exactly that materialized slice as a standalone native Rich Message with a fixed scope heading and four top-level collapsible semantic fields; inspection is read-only and does not create a State Flow transition.
57
57
 
58
58
  ## What carries forward
59
59
 
package/lib/telegram.ts CHANGED
@@ -26,6 +26,7 @@ export interface StateFlowTelegramState {
26
26
  }
27
27
 
28
28
  export type StateFlowTelegramRichBlock =
29
+ | { type: "heading"; text: string; size: 2 }
29
30
  | { type: "pre"; text: string; language?: string }
30
31
  | { type: "details"; summary: string | { type: "bold" | "code"; text: string }; blocks: StateFlowTelegramRichBlock[]; is_open?: true };
31
32
 
@@ -124,19 +125,28 @@ export function buildStateFlowSectionView(
124
125
  text: [formatStateFlowSectionHeader(snapshot), "", STATE_FLOW_SECTION_HELP].join("\n"),
125
126
  parseMode: "html",
126
127
  replyMarkup: { inline_keyboard: [
127
- [{ text: "👁 Show state", callback_data: callbackData("show-state") }],
128
128
  [action],
129
+ [{ text: "👁 Show state", callback_data: callbackData("show-state") }],
129
130
  ] },
130
131
  };
131
132
  }
132
133
 
134
+ const STATE_FLOW_SCOPE_LABELS: Record<StateFlowTelegramScope, string> = {
135
+ global: "🌐 Global",
136
+ cwd: "📂 CWD",
137
+ session: "💬 Session",
138
+ effective: "🧬 Effective",
139
+ };
140
+
133
141
  export function buildStateFlowScopeChooser(callbackData: (action: string, payload?: string) => string): StateFlowTelegramView {
134
142
  return {
135
143
  text: "<b>👁 Show state:</b>",
136
144
  parseMode: "html",
137
145
  replyMarkup: { inline_keyboard: [
138
- ["global", "cwd"].map((scope) => ({ text: scope === "global" ? "Global" : "CWD", callback_data: callbackData("inspect", scope) })),
139
- ["session", "effective"].map((scope) => ({ text: scope === "session" ? "Session" : "Effective", callback_data: callbackData("inspect", scope) })),
146
+ [{ text: "⬅️ Back", callback_data: callbackData("back") }],
147
+ ...(["global", "cwd", "session", "effective"] as const).map((scope) => [
148
+ { text: STATE_FLOW_SCOPE_LABELS[scope], callback_data: callbackData("inspect", scope) },
149
+ ]),
140
150
  ] },
141
151
  };
142
152
  }
@@ -169,18 +179,16 @@ function renderStateFlowTelegramField(value: unknown): string {
169
179
  }
170
180
 
171
181
  export function renderStateFlowRichState(scope: StateFlowTelegramScope, state: StateFlowTelegramState): StateFlowTelegramRichMessage {
172
- const title = scope === "cwd" ? "CWD" : `${scope[0].toUpperCase()}${scope.slice(1)}`;
173
182
  const fields = ["artifacts", "contract", "working", "response"] as const;
174
183
  return {
175
- blocks: [{
176
- type: "details",
177
- summary: { type: "bold", text: title },
178
- blocks: fields.map((field) => ({
179
- type: "details",
180
- summary: { type: "code", text: field },
181
- blocks: [{ type: "pre", language: "json", text: renderStateFlowTelegramField(state[field]) }],
184
+ blocks: [
185
+ { type: "heading", text: STATE_FLOW_SCOPE_LABELS[scope], size: 2 },
186
+ ...fields.map((field) => ({
187
+ type: "details" as const,
188
+ summary: { type: "code" as const, text: field },
189
+ blocks: [{ type: "pre" as const, language: "json", text: renderStateFlowTelegramField(state[field]) }],
182
190
  })),
183
- }],
191
+ ],
184
192
  skip_entity_detection: true,
185
193
  };
186
194
  }
@@ -198,7 +206,7 @@ function buildStateFlowTelegramSection(port: StateFlowTelegramPort) {
198
206
  buildStateFlowSectionView(port.snapshot(), (action) => ctx.callbackData(action)),
199
207
  handleCallback: async (ctx: StateFlowTelegramCallbackContext) => {
200
208
  // cancel/refresh remain routable for keyboards sent by earlier versions.
201
- if (ctx.action !== "start" && ctx.action !== "stop" && ctx.action !== "cancel" && ctx.action !== "refresh" && ctx.action !== "show-state" && ctx.action !== "inspect") return "pass" as const;
209
+ if (ctx.action !== "start" && ctx.action !== "stop" && ctx.action !== "cancel" && ctx.action !== "refresh" && ctx.action !== "show-state" && ctx.action !== "inspect" && ctx.action !== "back") return "pass" as const;
202
210
  let notice: string | undefined;
203
211
  try {
204
212
  if (ctx.action === "show-state") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llblab/pi-state-flow",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "private": false,
5
5
  "description": "Incremental scoped state/context compiler for Pi, inspired by SKILL.state",
6
6
  "keywords": [