@llblab/pi-telegram 0.46.0 → 0.47.0

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.
Files changed (199) hide show
  1. package/BACKLOG.md +0 -1
  2. package/CHANGELOG.md +8 -0
  3. package/README.md +2 -2
  4. package/dist/api/activity.d.ts +6 -0
  5. package/dist/api/activity.js +6 -0
  6. package/dist/api/commands.d.ts +6 -0
  7. package/dist/api/commands.js +6 -0
  8. package/dist/api/delivery.d.ts +6 -0
  9. package/dist/api/delivery.js +6 -0
  10. package/dist/api/inbound.d.ts +6 -0
  11. package/dist/api/inbound.js +6 -0
  12. package/dist/api/keyboard.d.ts +6 -0
  13. package/dist/api/keyboard.js +6 -0
  14. package/dist/api/outbound.d.ts +6 -0
  15. package/dist/api/outbound.js +6 -0
  16. package/dist/api/sections.d.ts +7 -0
  17. package/dist/api/sections.js +6 -0
  18. package/dist/api/status.d.ts +6 -0
  19. package/dist/api/status.js +6 -0
  20. package/dist/api/updates.d.ts +6 -0
  21. package/dist/api/updates.js +6 -0
  22. package/dist/api/voice.d.ts +6 -0
  23. package/dist/api/voice.js +6 -0
  24. package/dist/index.d.ts +6 -0
  25. package/dist/index.js +6 -0
  26. package/dist/lib/activity-verbosity.d.ts +52 -0
  27. package/dist/lib/activity-verbosity.js +596 -0
  28. package/dist/lib/activity.d.ts +220 -0
  29. package/dist/lib/activity.js +574 -0
  30. package/dist/lib/agent-messages.d.ts +28 -0
  31. package/dist/lib/agent-messages.js +86 -0
  32. package/dist/lib/bindings.d.ts +250 -0
  33. package/dist/lib/bindings.js +936 -0
  34. package/dist/lib/bus-api.d.ts +18 -0
  35. package/dist/lib/bus-api.js +254 -0
  36. package/dist/lib/bus-follower.d.ts +464 -0
  37. package/dist/lib/bus-follower.js +1686 -0
  38. package/dist/lib/bus-leader.d.ts +292 -0
  39. package/dist/lib/bus-leader.js +2242 -0
  40. package/dist/lib/bus-transport.d.ts +64 -0
  41. package/dist/lib/bus-transport.js +140 -0
  42. package/dist/lib/bus.d.ts +518 -0
  43. package/dist/lib/bus.js +2055 -0
  44. package/dist/lib/channel-posts.d.ts +170 -0
  45. package/dist/lib/channel-posts.js +611 -0
  46. package/dist/lib/command-templates.d.ts +70 -0
  47. package/dist/lib/command-templates.js +744 -0
  48. package/dist/lib/commands.d.ts +541 -0
  49. package/dist/lib/commands.js +1155 -0
  50. package/dist/lib/config.d.ts +252 -0
  51. package/dist/lib/config.js +889 -0
  52. package/dist/lib/delivery.d.ts +163 -0
  53. package/dist/lib/delivery.js +542 -0
  54. package/dist/lib/extension.d.ts +7 -0
  55. package/dist/lib/extension.js +1608 -0
  56. package/dist/lib/generative-app-worker.mjs +104 -0
  57. package/dist/lib/generative-apps.d.ts +212 -0
  58. package/dist/lib/generative-apps.js +1006 -0
  59. package/dist/lib/inbound.d.ts +91 -0
  60. package/dist/lib/inbound.js +502 -0
  61. package/dist/lib/journal.d.ts +665 -0
  62. package/dist/lib/journal.js +3701 -0
  63. package/dist/lib/keyboard.d.ts +23 -0
  64. package/dist/lib/keyboard.js +37 -0
  65. package/dist/lib/lifecycle.d.ts +157 -0
  66. package/dist/lib/lifecycle.js +395 -0
  67. package/dist/lib/locks.d.ts +164 -0
  68. package/dist/lib/locks.js +1208 -0
  69. package/dist/lib/logging.d.ts +50 -0
  70. package/dist/lib/logging.js +274 -0
  71. package/dist/lib/media.d.ts +181 -0
  72. package/dist/lib/media.js +602 -0
  73. package/dist/lib/menu-model.d.ts +217 -0
  74. package/dist/lib/menu-model.js +663 -0
  75. package/dist/lib/menu-queue.d.ts +37 -0
  76. package/dist/lib/menu-queue.js +408 -0
  77. package/dist/lib/menu-settings.d.ts +116 -0
  78. package/dist/lib/menu-settings.js +595 -0
  79. package/dist/lib/menu-status.d.ts +32 -0
  80. package/dist/lib/menu-status.js +112 -0
  81. package/dist/lib/menu-thinking.d.ts +29 -0
  82. package/dist/lib/menu-thinking.js +82 -0
  83. package/dist/lib/menu.d.ts +171 -0
  84. package/dist/lib/menu.js +323 -0
  85. package/dist/lib/model.d.ts +127 -0
  86. package/dist/lib/model.js +409 -0
  87. package/dist/lib/outbound-attachments.d.ts +241 -0
  88. package/dist/lib/outbound-attachments.js +639 -0
  89. package/dist/lib/outbound-buttons.d.ts +69 -0
  90. package/dist/lib/outbound-buttons.js +248 -0
  91. package/dist/lib/outbound-markup.d.ts +42 -0
  92. package/dist/lib/outbound-markup.js +678 -0
  93. package/dist/lib/outbound-voice.d.ts +55 -0
  94. package/dist/lib/outbound-voice.js +152 -0
  95. package/dist/lib/outbound.d.ts +185 -0
  96. package/dist/lib/outbound.js +516 -0
  97. package/dist/lib/ownership.d.ts +77 -0
  98. package/dist/lib/ownership.js +174 -0
  99. package/dist/lib/paths.d.ts +40 -0
  100. package/dist/lib/paths.js +94 -0
  101. package/dist/lib/pi.d.ts +72 -0
  102. package/dist/lib/pi.js +121 -0
  103. package/dist/lib/polling.d.ts +351 -0
  104. package/dist/lib/polling.js +1196 -0
  105. package/dist/lib/preview.d.ts +192 -0
  106. package/dist/lib/preview.js +614 -0
  107. package/dist/lib/prompt-templates.d.ts +24 -0
  108. package/dist/lib/prompt-templates.js +118 -0
  109. package/dist/lib/prompts.d.ts +57 -0
  110. package/dist/lib/prompts.js +167 -0
  111. package/dist/lib/queue.d.ts +766 -0
  112. package/dist/lib/queue.js +1965 -0
  113. package/dist/lib/recovery.d.ts +86 -0
  114. package/dist/lib/recovery.js +285 -0
  115. package/dist/lib/rendering.d.ts +20 -0
  116. package/dist/lib/rendering.js +983 -0
  117. package/dist/lib/replies.d.ts +214 -0
  118. package/dist/lib/replies.js +737 -0
  119. package/dist/lib/routing.d.ts +207 -0
  120. package/dist/lib/routing.js +2282 -0
  121. package/dist/lib/runtime.d.ts +172 -0
  122. package/dist/lib/runtime.js +402 -0
  123. package/dist/lib/sections.d.ts +165 -0
  124. package/dist/lib/sections.js +327 -0
  125. package/dist/lib/setup.d.ts +82 -0
  126. package/dist/lib/setup.js +150 -0
  127. package/dist/lib/skills.d.ts +8 -0
  128. package/dist/lib/skills.js +12 -0
  129. package/dist/lib/status.d.ts +442 -0
  130. package/dist/lib/status.js +1006 -0
  131. package/dist/lib/sync.d.ts +179 -0
  132. package/dist/lib/sync.js +782 -0
  133. package/dist/lib/target.d.ts +20 -0
  134. package/dist/lib/target.js +27 -0
  135. package/dist/lib/telegram-api.d.ts +541 -0
  136. package/dist/lib/telegram-api.js +1159 -0
  137. package/dist/lib/text-groups.d.ts +89 -0
  138. package/dist/lib/text-groups.js +317 -0
  139. package/dist/lib/thread-cleanup-manager.d.ts +288 -0
  140. package/dist/lib/thread-cleanup-manager.js +560 -0
  141. package/dist/lib/thread-display.d.ts +46 -0
  142. package/dist/lib/thread-display.js +257 -0
  143. package/dist/lib/thread-naming.d.ts +46 -0
  144. package/dist/lib/thread-naming.js +78 -0
  145. package/dist/lib/thread-reconciler.d.ts +239 -0
  146. package/dist/lib/thread-reconciler.js +644 -0
  147. package/dist/lib/threads.d.ts +621 -0
  148. package/dist/lib/threads.js +3679 -0
  149. package/dist/lib/time-injection.d.ts +15 -0
  150. package/dist/lib/time-injection.js +56 -0
  151. package/dist/lib/turns.d.ts +109 -0
  152. package/dist/lib/turns.js +500 -0
  153. package/dist/lib/updates.d.ts +1290 -0
  154. package/dist/lib/updates.js +3634 -0
  155. package/dist/lib/voice.d.ts +117 -0
  156. package/dist/lib/voice.js +174 -0
  157. package/dist/lib/workspace-admission.d.ts +264 -0
  158. package/dist/lib/workspace-admission.js +1136 -0
  159. package/dist/lib/workspace-retirement.d.ts +219 -0
  160. package/dist/lib/workspace-retirement.js +587 -0
  161. package/dist/lib/workspace-slots.d.ts +30 -0
  162. package/dist/lib/workspace-slots.js +54 -0
  163. package/dist/package.json +126 -0
  164. package/dist/pi-telegram/index.js +1 -0
  165. package/dist/skills/generated-control-surface/SKILL.md +107 -0
  166. package/dist/skills/generated-control-surface/references/capability-adapters.md +27 -0
  167. package/dist/skills/generated-control-surface/references/layout-and-state.md +37 -0
  168. package/dist/skills/generative-apps/SKILL.md +115 -0
  169. package/dist/skills/show-me/SKILL.md +166 -0
  170. package/dist/skills/show-me/references/telegram-surfaces.md +43 -0
  171. package/dist/skills/telegram-bridge/SKILL.md +129 -0
  172. package/dist/skills/telegram-bridge/references/configuration.md +15 -0
  173. package/dist/skills/telegram-bridge/references/delivery-and-threads.md +27 -0
  174. package/dist/skills/telegram-bridge/references/diagnosis.md +18 -0
  175. package/docs/architecture.md +1 -1
  176. package/docs/compact-matrix-literal.md +10 -3
  177. package/docs/generative-apps.md +15 -13
  178. package/docs/multi-instance-bus.md +4 -2
  179. package/docs/outbound.md +1 -1
  180. package/docs/public-api.md +2 -2
  181. package/lib/bindings.ts +89 -6
  182. package/lib/bus-follower.ts +7 -3
  183. package/lib/bus-leader.ts +44 -19
  184. package/lib/bus.ts +4 -1
  185. package/lib/commands.ts +2 -2
  186. package/lib/config.ts +14 -7
  187. package/lib/delivery.ts +38 -6
  188. package/lib/extension.ts +19 -0
  189. package/lib/generative-apps.ts +379 -13
  190. package/lib/menu-settings.ts +21 -5
  191. package/lib/outbound-markup.ts +16 -7
  192. package/lib/telegram-api.ts +12 -1
  193. package/lib/thread-display.ts +96 -18
  194. package/package.json +56 -13
  195. package/scripts/build-dist.mjs +44 -0
  196. package/scripts/measure-bus.mjs +8 -1
  197. package/scripts/measure-workspace.mjs +8 -1
  198. package/skills/generative-apps/SKILL.md +1 -1
  199. package/skills/telegram-bridge/SKILL.md +1 -1
@@ -0,0 +1,126 @@
1
+ {
2
+ "name": "@llblab/pi-telegram",
3
+ "version": "0.47.0",
4
+ "private": false,
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "description": "Telegram runtime adapter for Pi",
9
+ "keywords": [
10
+ "pi-package",
11
+ "pi",
12
+ "telegram",
13
+ "bot",
14
+ "extension"
15
+ ],
16
+ "type": "module",
17
+ "license": "MIT",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/llblab/pi-telegram.git"
21
+ },
22
+ "homepage": "https://github.com/llblab/pi-telegram",
23
+ "bugs": {
24
+ "url": "https://github.com/llblab/pi-telegram/issues"
25
+ },
26
+ "engines": {
27
+ "node": ">=22.19.0"
28
+ },
29
+ "scripts": {
30
+ "test": "node --experimental-strip-types --test --test-concurrency=4 --test-reporter=dot tests/*.test.ts",
31
+ "test:verbose": "node --experimental-strip-types --test --test-reporter=spec tests/*.test.ts",
32
+ "typecheck": "tsc --noEmit",
33
+ "build": "node scripts/build-dist.mjs",
34
+ "prepack": "npm run build",
35
+ "check": "node -e \"await import('./dist/pi-telegram/index.js'); console.log('pi-telegram: extension import ok')\"",
36
+ "audit": "npm audit --omit=peer",
37
+ "audit:host": "npm audit",
38
+ "pack:check": "npm pack --dry-run",
39
+ "validate": "npm run build && npm run typecheck && npm test && npm run audit && npm run check && npm run pack:check"
40
+ },
41
+ "files": [
42
+ "index.ts",
43
+ "api/",
44
+ "lib/",
45
+ "dist/",
46
+ "README.md",
47
+ "AGENTS.md",
48
+ "BACKLOG.md",
49
+ "CHANGELOG.md",
50
+ "docs/",
51
+ "scripts/",
52
+ "skills/",
53
+ "screenshot.png"
54
+ ],
55
+ "exports": {
56
+ ".": {
57
+ "types": "./dist/index.d.ts",
58
+ "default": "./dist/index.js"
59
+ },
60
+ "./inbound": {
61
+ "types": "./dist/api/inbound.d.ts",
62
+ "default": "./dist/api/inbound.js"
63
+ },
64
+ "./outbound": {
65
+ "types": "./dist/api/outbound.d.ts",
66
+ "default": "./dist/api/outbound.js"
67
+ },
68
+ "./delivery": {
69
+ "types": "./dist/api/delivery.d.ts",
70
+ "default": "./dist/api/delivery.js"
71
+ },
72
+ "./activity": {
73
+ "types": "./dist/api/activity.d.ts",
74
+ "default": "./dist/api/activity.js"
75
+ },
76
+ "./updates": {
77
+ "types": "./dist/api/updates.d.ts",
78
+ "default": "./dist/api/updates.js"
79
+ },
80
+ "./commands": {
81
+ "types": "./dist/api/commands.d.ts",
82
+ "default": "./dist/api/commands.js"
83
+ },
84
+ "./sections": {
85
+ "types": "./dist/api/sections.d.ts",
86
+ "default": "./dist/api/sections.js"
87
+ },
88
+ "./status": {
89
+ "types": "./dist/api/status.d.ts",
90
+ "default": "./dist/api/status.js"
91
+ },
92
+ "./voice": {
93
+ "types": "./dist/api/voice.d.ts",
94
+ "default": "./dist/api/voice.js"
95
+ },
96
+ "./keyboard": {
97
+ "types": "./dist/api/keyboard.d.ts",
98
+ "default": "./dist/api/keyboard.js"
99
+ }
100
+ },
101
+ "pi": {
102
+ "extensions": [
103
+ "./dist/pi-telegram/index.js"
104
+ ],
105
+ "sourceExtensions": [
106
+ "./index.ts"
107
+ ],
108
+ "skills": [
109
+ "./dist/skills"
110
+ ],
111
+ "sourceSkills": [
112
+ "./skills"
113
+ ],
114
+ "image": "https://raw.githubusercontent.com/llblab/pi-telegram/main/screenshot.png"
115
+ },
116
+ "peerDependencies": {
117
+ "@earendil-works/pi-agent-core": ">=0.84.4",
118
+ "@earendil-works/pi-ai": ">=0.84.4",
119
+ "@earendil-works/pi-coding-agent": ">=0.84.4",
120
+ "@sinclair/typebox": "*"
121
+ },
122
+ "devDependencies": {
123
+ "@types/node": "latest",
124
+ "typescript": "latest"
125
+ }
126
+ }
@@ -0,0 +1 @@
1
+ export { default } from "../index.js";
@@ -0,0 +1,107 @@
1
+ ---
2
+ name: generated-control-surface
3
+ description: Proactively generate truthful prompt-button controls; every active surface emits useful buttons with semantic emoji labels, while stable deterministic loops route to Generative Apps.
4
+ ---
5
+
6
+ # Generated Control Surface
7
+
8
+ Compile a temporary interface from current evidence, available capabilities, and user intent:
9
+
10
+ ```text
11
+ state + capabilities + intent → projection + likely next actions
12
+ ```
13
+
14
+ The surface projects reality; it does not own domain state, grant authority, or create a shadow application.
15
+
16
+ ## Admission
17
+
18
+ Proactively use controls whenever a tap can reduce response effort, ambiguity, turnaround time, or supervision cost. On a prompt-button transport, every response produced under this Skill must include at least one useful button; never finish with prose alone. A bounded confirmation or choice should expose 2–6 safe concrete actions.
19
+
20
+ At workflow handoff, offer a small high-confidence next-action set when the completed step clearly unlocks it. Preserve free-form reply when choices are not exhaustive. When no domain mutation qualifies, offer the most useful truthful continuation—such as inspect details, refine scope, refresh mutable evidence, navigate back, or continue the parent workflow—rather than a decorative control or generic “What next?”.
21
+
22
+ Every button must advance, inspect, clarify, recover, navigate, or supervise the current intent. Never duplicate visible prose, represent unclear consequences, or repeat a command that introduces no new decision.
23
+
24
+ ## Ownership And Truth
25
+
26
+ Identify one controlled object, target, and capability owner. Build from one declared truth mode when ambiguity matters:
27
+
28
+ - **Live:** Freshly inspected mutable state.
29
+ - **Contract:** Stable documented capability.
30
+ - **Conversation:** Choices established in the dialogue.
31
+ - **Adapted:** A labeled subset or transformation.
32
+
33
+ Never present remembered or inferred state as live. Preserve material identity, ordering, values, warnings, failures, authority, and completeness. Label filtering, truncation, pagination, and unavailable evidence. Refresh affected state after mutation before claiming success or rendering dependent controls.
34
+
35
+ Use the real capability owner—tool, API, repository, Actor runtime, filesystem, media system, workflow, or conversation. Do not invent parallel state, lifecycle, navigation, or callbacks.
36
+
37
+ ## Surface Contract
38
+
39
+ A surface is an ordered ragged sequence of rows. Each button carries:
40
+
41
+ - A short, distinct label.
42
+ - The smallest self-contained next-request prompt.
43
+ - Optional presentation state supported by the transport, including disabled controls when their visible unavailability helps explain current state.
44
+
45
+ A disabled control is not an action: it needs no prompt or selected style and must not enqueue a prompt or invoke a bound method. Prefer a meaningful label; omit it only for an intentional blank cell in a spatial layout, never as decorative padding. Preserve its label and position when that makes a changing surface easier to understand; otherwise omit irrelevant controls. Explain non-obvious unavailability without relying on color alone. Retain at least one useful enabled action, such as refresh or navigation. Derive disabled state from the same evidence as the view; an old enabled control still requires current domain validation. Use the transport owner's disabled encoding rather than a dummy prompt or no-op callback.
46
+
47
+ Prompts must name any target, operation, constraint, or freshness identity whose omission could change the action. Reuse visible context only when it remains unambiguous under delayed or reordered clicks. Never encode volatile output that should be freshly inspected.
48
+
49
+ Every generated human-readable action label must use `emoji + space + text`; emoji-free text labels are invalid. Choose the emoji by action semantics, keep its meaning consistent, and never rely on emoji or color alone. Coordinates, established symbolic controls, and intentionally spatial glyphs already satisfy the marker role through their domain grammar. If prompt buttons are unavailable, preserve the same choices as a numbered list.
50
+
51
+ ## Layout Kernel
52
+
53
+ - Use one full-width row for an independent, primary, long, or consequential action.
54
+ - Use two columns only for unmistakably short textual peers.
55
+ - Reserve three through eight columns for compact position-bearing glyphs or codes.
56
+ - Preserve hierarchy and reading order; never pad, duplicate, or shorten necessary wording for symmetry.
57
+ - Use Back/Up only for real hierarchy and Refresh only for mutable projections.
58
+ - Prefer 2–6 decision controls. Paginate or group larger non-spatial collections.
59
+
60
+ For complex grids, navigation collections, or stateful repeated clicks, read [`references/layout-and-state.md`](./references/layout-and-state.md).
61
+
62
+ Place a control group beside the section it governs when the transport supports in-body blocks; use a footer for whole-answer actions. Placement must not change the matrix or action semantics. Serialize the resulting rows with the active transport contract. This Skill owns admission and composition, not transport syntax.
63
+
64
+ ## Safety
65
+
66
+ A click is an ordinary user request under the same authority and validation rules as typed text. Never infer permission from the existence of a button.
67
+
68
+ Classify actions as read-only, ordinary mutation, privileged, destructive, secret-bearing, external, or irreversible. High-impact actions use two stages:
69
+
70
+ 1. Open a confirmation surface naming exact target, effect, and recovery boundary.
71
+ 2. Offer a distinct request for the exact operation.
72
+
73
+ Re-check mutable targets immediately before execution. Never expose secrets, credentials, hidden reasoning, private keys, tokens, cookies, wallet material, or sensitive content in labels, prompts, or projections. Access denial never authorizes privilege escalation.
74
+
75
+ ## Reuse Boundary
76
+
77
+ Keep one-off, interpretive, changing, and context-heavy interaction here. When state and transitions become stable, repeated, bounded, and deterministic, follow `generative-apps` and compile only the deterministic loop. Existing transport menus, runtime callbacks, and installed apps remain with their owners.
78
+
79
+ For capability-specific composition guidance, read only the applicable reference:
80
+
81
+ - Console, filesystem, workflows, Actor Runs, and design choices: [`references/capability-adapters.md`](./references/capability-adapters.md)
82
+
83
+ ## Procedure
84
+
85
+ 1. Identify intent, controlled object, owner, and truth mode.
86
+ 2. Inspect only the evidence needed for a truthful projection.
87
+ 3. Admit only high-leverage actions and classify their impact.
88
+ 4. Arrange semantic rows, then serialize through the transport owner.
89
+ 5. Treat the click as a new request, validate authority, act, and refresh reality.
90
+
91
+ ## Failure And Empty States
92
+
93
+ Show concise failure evidence and emit valid recovery controls such as diagnose, retry, refresh, back, or narrower scope. If a target disappears, return to its nearest valid owner or parent. Empty collections retain the safest useful navigation, inspection, or refinement control rather than degrading to prose-only output.
94
+
95
+ ## Final Check
96
+
97
+ Before sending:
98
+
99
+ - At least one useful button is present whenever the transport supports prompt buttons.
100
+ - Every human-readable button label begins with a semantic emoji and one ASCII space.
101
+ - State, actions, owner, and target agree.
102
+ - Live claims are fresh; adaptation and incompleteness are explicit.
103
+ - Every prompt is sufficient and every label follows its semantic emoji rule.
104
+ - Row grouping reflects real hierarchy or peer relationships.
105
+ - High-impact actions require confirmation.
106
+ - No secret or hidden reasoning appears.
107
+ - The surface remains readable on a phone and free-form feedback remains possible.
@@ -0,0 +1,27 @@
1
+ # Capability Adapters
2
+
3
+ Read only the section matching the current controlled capability.
4
+
5
+ ## Console And System
6
+
7
+ Use the real console program as capability owner. Check exit status and stderr before rendering success. Preserve complete output when reasonably sized; otherwise label pagination, filtering, ranking, or head/tail adaptation. Process, service, package, permission, shutdown, disk, and deletion mutations retain required confirmation.
8
+
9
+ ## Filesystem
10
+
11
+ A prompt that is exactly a plausible filesystem path, including `/`, may request a generated filesystem surface. Resolve and freshly inspect it before display.
12
+
13
+ 1. Pin `⬆️ Up` first whenever the path is not root; its prompt is the exact parent path.
14
+ 2. If paginated, place available `⬅️ Previous` and `➡️ Next` together after Up. Re-inspect on traversal and use a stable 10-entry page.
15
+ 3. Sort visible directories, hidden directories, visible files, then hidden files; alphabetize within each category.
16
+ 4. Render at most 10 entries as full-width rows. Labels use the exact entry name plus semantic folder/file emoji; prompts may be exact paths because path-only prompts mean navigation here.
17
+ 5. Show compact Path and Entries metadata. Do not duplicate entries as a text inventory or add Refresh when resubmitting the path already refreshes.
18
+
19
+ Preserve the same ordering and pagination in a numbered fallback. Show a plain directory listing only when explicitly requested or established preference requires it. Never preview credential stores, keys, browser profiles, cookies, tokens, wallets, or secret-bearing files, and never raise privileges merely to enumerate a path.
20
+
21
+ ## Workflows And Actor Runs
22
+
23
+ Keep exact workflow, Recipe, Run, artifact, or task identity visible. Inspect, pause, continue, redirect, retry, or stop only through the owning runtime contract. Never simulate lifecycle state, bypass Control semantics, or treat a button as execution authority.
24
+
25
+ ## Decisions And Design
26
+
27
+ Controls may represent conversational alternatives without live inspection. State the decision and material trade-offs in visible text. Each prompt records the selected intent; it does not silently execute downstream consequences.
@@ -0,0 +1,37 @@
1
+ # Complex Layout And Interaction State
2
+
3
+ Read this reference only for complex grids, navigation collections, or repeated stateful clicks.
4
+
5
+ ## Semantic Rows
6
+
7
+ Model the surface as ordered ragged rows, not a rectangle to fill. Infer independent, peer, ordered, hierarchical, and spatial relationships before choosing row boundaries.
8
+
9
+ - Non-spatial controls default to one full-width row each.
10
+ - A horizontal pair is earned only by genuine peers with unmistakably compact labels and no plausible wrapping or truncation.
11
+ - Three through five columns are for short symbols, coordinates, glyphs, or codes whose position carries meaning.
12
+ - Six through eight columns require single-glyph or similarly minimal position-bearing labels. Never exceed eight columns on a phone surface.
13
+ - Vary row width intentionally; never pad for symmetry with empty, duplicate, or no-op controls. A blank disabled cell is appropriate only when it represents a real unavailable position in a spatial grid.
14
+ - Preserve reading order: orientation/navigation, primary content or choices, secondary controls, then separated destructive actions.
15
+ - Rectangular grids require genuine spatial or coordinate correspondence. Vertical continuity may justify many rows; non-spatial button walls should paginate or group.
16
+
17
+ Useful shapes include `1`, `2`, `1 → 2`, `2 → 1`, `1 → 2 → N×1`, repeated `2`, and true `R×C`. Treat these as vocabulary, never templates to impose.
18
+
19
+ ## Metadata And Collections
20
+
21
+ Use compact stacked key-value rows for path-like, numeric, identifier, or machine state, for example `- **Path:** /...` and `- **Entries:** 1–10 of 52`. Do not join unrelated metadata with decorative separators or duplicate button labels as a plain inventory.
22
+
23
+ When a Markdown grid has no semantic column headings, use its first data row as the syntactic header and render remaining rows once. Never invent blank, dash-only, or duplicate headings that add false topology.
24
+
25
+ Navigation collections may expose up to 12 scannable entries; paginate or categorize larger sets. Keep stable ordering and coordinates across regeneration.
26
+
27
+ ## Interaction State
28
+
29
+ Encode the smallest sufficient action delta when visible context establishes one unambiguous state. Add stable target or state identity when delivery may be delayed, reordered, routed elsewhere, or detached from the projection.
30
+
31
+ Keep trivial state in conversation. Persist a small human-auditable artifact when state becomes too large or long-lived for reliable reconstruction. Use a deterministic state-transition owner when rules become correctness-sensitive.
32
+
33
+ Evaluate repeated clicks against current state, not stale button appearance. Preserve tap-ahead when the transport queues each click independently. In source-then-destination interaction, retain the source selection without duplicating the whole surface; regenerate after a completed transition, invalid input, or evidence that the transport cannot preserve the intermediate view.
34
+
35
+ Omit unavailable controls when layout does not matter. Preserve occupied or selected cells when spatial topology depends on stable coordinates, using the transport's disabled state without a fabricated prompt. Keep a useful enabled navigation or inspection action.
36
+
37
+ Place each control group beside the content it governs when in-body blocks are supported; keep global navigation and whole-view actions in the footer. Do not duplicate one action in both positions merely for visibility. Row topology and current-state validation stay the same across compact and named representations and across placements; renderer limits and selection feedback belong to the transport.
@@ -0,0 +1,115 @@
1
+ ---
2
+ name: generative-apps
3
+ description: Design, author, review, install, replace, invoke, or debug reusable Generative Apps that combine generated button interfaces, deterministic bound methods, and optional model-mediated prompts. Use for standalone applications and bounded view/controller adapters rendered through pi-telegram; prefer Generated Control Surface when no reusable deterministic program is earned.
4
+ ---
5
+
6
+ # Generative Apps
7
+
8
+ ## Concept
9
+
10
+ A Generative App is a reusable application authored by the model for a concrete task. It combines persistent state, named methods, textual output, and a generated button interface. The model acts primarily as author/compiler; the installed program then renders evolving views and executes routine transitions without requiring inference on every click.
11
+
12
+ ```text
13
+ intent → model authors app → reusable state + methods + generated views
14
+ ```
15
+
16
+ One surface may deliberately mix two action planes:
17
+
18
+ ```text
19
+ bound method → deterministic local transition
20
+ ordinary prompt → model interpretation, explanation, teaching, or adaptation
21
+ ```
22
+
23
+ This is broader than one Telegram implementation. Telegram is the first renderer; a future TUI or web renderer may reuse the concept once a second implementation proves the common contract. Keep renderer-specific wire and lifecycle details with the owning runtime.
24
+
25
+ Generative Apps complement `generated-control-surface`:
26
+
27
+ ```text
28
+ Generated Control Surface → current context → model → one ephemeral surface
29
+ Generative App → model → reusable program → many evolving surfaces
30
+ ```
31
+
32
+ Both Skills use the same logical button matrix and `label + prompt` interaction model. An app may place groups beside their related content using the transport's in-body button blocks or keep whole-view controls in the footer; placement does not change binding, disabled state, or method authority. The Telegram runtime owns its full JSON/CML notation and callback routing; this Skill owns reusable program judgment, while `generated-control-surface` owns ephemeral agent-authored composition. Shared rendering needs no third button Skill and does not collapse those responsibilities.
33
+
34
+ An app may mix deterministic `app::method` controls and ordinary prompts in one view, including one control group. Compact and named cells may coexist under the shared transport grammar; neither representation nor placement creates another action plane. Compile only the stable transitions that benefit from inference bypass; keep explanation, interpretation, teaching, and adaptation on the model-mediated plane. When no reusable state or deterministic loop earns a script, load and use `generated-control-surface` instead.
35
+
36
+ The `generated` / `generative` distinction is intentional. Do not rename `generated-control-surface` to a competing generative term.
37
+
38
+ ## Ownership
39
+
40
+ This Skill owns agent operating judgment:
41
+
42
+ - Whether a Generative App is warranted.
43
+ - Standalone versus adapter selection.
44
+ - Authoring and capability review.
45
+ - Install, replace, invoke, and validation workflow.
46
+ - Safety boundaries and stop decisions.
47
+
48
+ This Skill also owns the transport-independent concept, vocabulary, application shapes, hybrid action model, and relationship to Generated Control Surface.
49
+
50
+ [`../../docs/generative-apps.md`](../../docs/generative-apps.md) owns only the concrete `pi-telegram` runtime reference: Telegram wire syntax, managed layout, executable ABI, state timeline, generation/revision fencing, worker execution, locking, installation transactions, callback routing, lifecycle behavior, and current limitations. Do not duplicate those implementation details here.
51
+
52
+ ## When To Use
53
+
54
+ Use a Generative App when:
55
+
56
+ - Interaction repeats or contains several stable transitions.
57
+ - State and valid actions fit a small auditable contract.
58
+ - Direct methods materially improve latency, cost, reliability, or UX.
59
+ - Model judgment remains optional rather than required for every action.
60
+ - One clear owner exists for application or external domain state.
61
+
62
+ Prefer `generated-control-surface` for one-shot, interpretive, rapidly changing, or wholly model-mediated interaction. Do not create decorative apps, generic remote terminals, arbitrary command runners, or deterministic facades over ambiguous high-impact decisions.
63
+
64
+ ## Choose The Shape
65
+
66
+ ### Standalone deterministic application
67
+
68
+ The app owns a closed state machine such as a game, form, selector, simulation, or compact workflow. Its state must reconstruct the current view and explain the previous transition.
69
+
70
+ ### View/controller adapter
71
+
72
+ Another capability remains the authoritative real owner. The app stores validated adapter configuration and a last-observed projection only. Re-read the owner before mutation or explicit status; never promote cached view state into domain authority.
73
+
74
+ ## Authoring Workflow
75
+
76
+ 1. Identify the repeated feedback loop, real state owner, and actions that are truly deterministic.
77
+ 2. Choose one stable lowercase app and one self-contained `<app>.mjs` source outside the managed installation directory.
78
+ 3. Keep `init` and every exported method small, named, bounded, shell-free, and capability-specific.
79
+ 4. Render one complete next view after each action. Derive disabled controls from current state using the shared transport contract; visible disabled controls neither invoke methods nor enqueue prompts. Revalidate domain preconditions when an enabled control is invoked, because previously rendered views may be stale.
80
+ 5. Mix action planes intentionally:
81
+
82
+ ```text
83
+ app::method(argument) → bounded method without a model turn
84
+ ordinary prompt → model-mediated interpretation or explanation
85
+ ```
86
+
87
+ 6. Review state fields, arguments, process calls, rendered values, secrets, destructive effects, and failure paths.
88
+ 7. Install with `telegram_bind({ app, script, argument })`.
89
+ 8. Replace the same logical app only with explicit `replace: true`; never create `-v2` identities merely to reload code.
90
+ 9. Invoke read-only diagnostics with `telegram_bind({ app, method, argument, display: false })` when agent-side evidence is needed.
91
+ 10. Keep the maintained source with its capability owner; managed `genapps/` state is runtime installation, not source ownership.
92
+
93
+ ## Safety Rules
94
+
95
+ - A direct click authorizes only its exact installed method and validated JSON argument.
96
+ - Use exact executable plus argv through the bounded process port; never expose generic `exec` or shell text.
97
+ - Keep credentials and unrelated private state out of source, state, output, and diagnostics.
98
+ - Route consequences requiring contextual judgment through an ordinary model prompt.
99
+ - Fail closed on unavailable owners, stale actions, malformed state, absent methods, process failures, or uncertain effects.
100
+ - Treat `refreshAfterMs` validation, output-only `refresh`, scheduling after a successful hinted explicit `telegram_bind` delivery, same-handle rescheduling after a current-surface bound action, Delivery edit-failure classification, known unavailable-message invalidation with bounded classified diagnostics, session/runtime live-surface cancellation, and exact direct classic/leader/authenticated-follower target retention as implemented. The Bot API has no ordinary private-message deletion update; `deleted_business_messages` is limited to connected business accounts. Do not claim removal, voice output, proactive deletion-update invalidation, or other behavior still marked incomplete in the runtime document.
101
+
102
+ ## Validation
103
+
104
+ Before presenting an app as working:
105
+
106
+ - Confirm app, source stem, installed identity, and bound prompts agree.
107
+ - Inspect the installed initial view and persisted bounded state.
108
+ - Exercise at least one real bound action and prove it bypasses Pi queue/model admission.
109
+ - Exercise at least one ordinary prompt when the app intentionally uses the model plane.
110
+ - Verify the placements actually used by the app and prove disabled cells invoke nothing. A successful ordinary prompt-button smoke is not evidence of app-method dispatch or stale-revision rejection.
111
+ - Verify replacement rejects stale buttons and failed initialization preserves the prior app.
112
+ - For adapters, prove fresh external status and terminal mutation evidence.
113
+ - Confirm failures are bounded, redacted, and do not silently render success.
114
+
115
+ Stop and return to ordinary model interaction when the workflow cannot be represented safely as reviewed bounded methods plus explicit model prompts.
@@ -0,0 +1,166 @@
1
+ ---
2
+ name: show-me
3
+ description: Explain completed work, proposed changes, system structure, or ideas through truthful contextual Markdown, concise diagrams, code-shape sketches, and focused HTML artifacts. Use when the user asks to show what happened, what changed, or how something works, especially on a phone-width Telegram surface.
4
+ ---
5
+
6
+ Help the user understand the current topic. Skip the preamble and keep prose brief. Pick the smallest view that makes the key point clear without making the underlying claim less true.
7
+
8
+ ### Output Selection
9
+
10
+ - Infer the subject from the conversation and honor an explicitly requested format. With plain `show me`, choose the form that best explains the subject.
11
+ - Markdown in the reply is a complete output format for both chat and terminal surfaces. Use headings, emphasis, lists, and focused code blocks to explain outcomes, comparisons, and reasoning; add a diagram when relationships need one.
12
+ - `Show me markdown` requests a rendered Markdown reply. Create a Markdown file only when the user asks for a saved document or file artifact.
13
+ - `Show me html` requests a focused HTML file. Prefer an accessible, art-directed interactive infographic when timelines, comparisons, layers, or progressive disclosure clarify the subject; otherwise stay static. Preserve truthful labels and reduced motion. Save and deliver the artifact through the active environment; open it locally when requested.
14
+
15
+ ### Surface Routing
16
+
17
+ - Infer whether the active surface is Telegram, a terminal, or another client. Keep the explanation portable and use surface-specific delivery only when the context or user request authorizes it.
18
+ - For Telegram output, read [`references/telegram-surfaces.md`](./references/telegram-surfaces.md) before selecting Markdown or HTML. Keep the immediate reply useful even when an attached artifact is the deeper view.
19
+ - When asked what changed or happened in current work, inspect the retained diff, status, and validation evidence when available. Separate this task from pre-existing changes and distinguish repository state from released or live behavior.
20
+
21
+ ### Truth And State
22
+
23
+ - Label material claims as `live`, `released`, `locally implemented`, `proposed`, or `unverified` when the distinction affects interpretation. Omit redundant labels when the state is already unambiguous.
24
+ - Preserve the exact mechanism, owner, and boundary when simplifying technical behavior. A friendly label may supplement the implementation term but must not replace it when that would merge distinct timers, states, stages, or authorities.
25
+ - Make a visual diff correspond to the actual changed symbol or contract. Show unchanged neighboring behavior when omission could imply that it changed too.
26
+ - Do not infer that an affordance is clickable, interactive, rendered, or client-visible from source or markup shape alone. Distinguish designed or expected behavior from behavior verified through the relevant renderer, transport, runtime, and client.
27
+ - Treat a mockup, diagram, or rendered artifact as explanatory evidence, not runtime proof. State the unverified boundary when the user could reasonably mistake one for the other.
28
+
29
+ A compact state line is enough when provenance matters:
30
+
31
+ ```text
32
+ State: locally implemented · validated · not released · not live
33
+ ```
34
+
35
+ ### Visual Forms
36
+
37
+ - Show logic or an algorithm as pseudocode:
38
+
39
+ ```text
40
+ on(save)
41
+ if content is unchanged
42
+ return cached result
43
+ write new content
44
+ return fresh result
45
+ ```
46
+
47
+ - Show runtime control flow as a call tree:
48
+
49
+ ```text
50
+ submitForm
51
+ createSession
52
+ persistPrompt
53
+ launchAgent
54
+ navigateToSession
55
+ ```
56
+
57
+ - Show UI structure as a component tree, including state and module boundaries that matter:
58
+
59
+ ```tsx
60
+ <SessionPage> (apps/example/src/routes/session.tsx)
61
+ useSessionEvents()
62
+ <SessionToolbar>
63
+ <RunSkillButton> (packages/ui)
64
+ ```
65
+
66
+ - Show file responsibility or a broad refactor as a shallow file tree:
67
+
68
+ ```text
69
+ src/
70
+ ├─ commands/
71
+ │ └─ parses user actions
72
+ ├─ sessions/
73
+ │ └─ owns session state
74
+ └─ transport/
75
+ └─ sends API requests
76
+ ```
77
+
78
+ - Show component interaction, control flow, or data flow with Mermaid:
79
+
80
+ ```mermaid
81
+ sequenceDiagram
82
+ participant User
83
+ participant UI
84
+ participant Daemon
85
+ User->>UI: choose command
86
+ UI->>Daemon: send expanded prompt
87
+ Daemon-->>UI: stream result
88
+ ```
89
+
90
+ - Use `diff` when the point is what changes and the surrounding shape already exists. Match the diff shape to the topic.
91
+
92
+ For a component change:
93
+
94
+ ```diff
95
+ <SessionPage>
96
+ useSessionEvents()
97
+ <SessionToolbar>
98
+ + <RunSkillButton />
99
+ <SessionTimeline>
100
+ + <SkillResultCard />
101
+ ```
102
+
103
+ For a file-layout change:
104
+
105
+ ```diff
106
+ src/
107
+ ├─ commands/
108
+ +│ └─ show-me.ts
109
+ +│ └─ expands the slash command
110
+ ├─ sessions/
111
+ -└─ transport.ts
112
+ +└─ transport/
113
+ + ├─ client.ts
114
+ + └─ stream.ts
115
+ ```
116
+
117
+ For a call-tree or call-stack change:
118
+
119
+ ```diff
120
+ submitForm
121
+ createSession
122
+ persistPrompt
123
+ + expandSkillMention
124
+ launchAgent
125
+ - navigateToSession
126
+ + navigateToSession
127
+ + subscribeToEvents
128
+ ```
129
+
130
+ For a state or control-flow change:
131
+
132
+ ```diff
133
+ on(save)
134
+ - write content
135
+ + if content is unchanged
136
+ + return cached result
137
+ + write new content
138
+ + invalidate cache
139
+ ```
140
+
141
+ - Show the whole block when most of it is new, when omitted context would hide ownership or order, or when the user needs a copyable target shape:
142
+
143
+ ```ts
144
+ function expandSkill(command: string): string {
145
+ const skillName = command.slice(1)
146
+ return `use the ${skillName} skill`
147
+ }
148
+ ```
149
+
150
+ - For a visual UI, layout, state comparison, or concept too dense for Mermaid, use a focused HTML artifact — a diagram, an infographic, or a short slide deck, whichever fits the point. Match the product's colors, type, spacing, and components; use real labels and data; support desktop and mobile. When practical, render representative narrow and wide viewports and report what was actually inspected.
151
+
152
+ ### Text Rendering
153
+
154
+ - Adapt the view to the available width in both terminal and chat surfaces. Use shallow trees with `├─`, `└─`, and `│`, a space before labels, and a three-column nesting step for file hierarchy; use indentation for call trees and pseudocode.
155
+ - Keep labels concise and in the user's language. Express status with words; use text glyphs with predictable monospace width for aligned diagram structure.
156
+ - For changes, use a compact fenced `diff` block in Telegram or the terminal. Show the changed lines and only the surrounding context needed to understand them.
157
+ - In trees, place comments and explanations as child nodes one level below the item they describe. Keep the item's own line for its label.
158
+ - Use prose lists for independent statuses and split larger views into meaningful sections.
159
+
160
+ ### Guidance
161
+
162
+ Place each visual next to the short text it supports. Keep only the calls, files, props, states, and boundaries needed to answer the user's current question or the options to resolve the current discussion point. Prefer one primary visual and a few decision-relevant takeaways; add another form only when it explains a different necessary relationship.
163
+
164
+ Use source paths, symbol names, or validation evidence when they materially anchor a claim, not as decoration. Report the strongest state the evidence supports and no stronger.
165
+
166
+ You may use one of these, you may use several, it is unlikely you will use all of them. Use your judgement and don't overwhelm the user.
@@ -0,0 +1,43 @@
1
+ # Telegram Explanation Surfaces
2
+
3
+ Use this reference only when Show Me is responding through Telegram or preparing an artifact for Telegram delivery.
4
+
5
+ ## Selection
6
+
7
+ - With plain `show me`, prefer a native Markdown reply when one phone-width view can explain the point.
8
+ - Use HTML when spatial comparison, dense state, a timeline, or a visual hierarchy would become harder to understand in narrow Markdown.
9
+ - `Show me markdown` means rendered Markdown in the current reply, not a `.md` attachment, unless the user explicitly asks for a file.
10
+ - `Show me html` means one focused, self-contained `.html` artifact delivered through the active Telegram file path. The surrounding reply should say what the artifact explains and disclose its evidence state.
11
+ - Do not create both formats by habit. The second format must answer a need the first cannot.
12
+
13
+ ## Telegram Markdown
14
+
15
+ - Design for a phone before a desktop: one governing question, one primary visual, short labels, shallow nesting, and prose that wraps naturally.
16
+ - Prefer compact semantic diffs, call trees, timelines, or state transitions over raw repository diffs. A remote user needs to understand impact before file-level detail.
17
+ - Avoid wide tables, deep trees, side-by-side layouts, and Mermaid when the current Telegram renderer would expose only source text. Move genuinely spatial material to HTML.
18
+ - Put material state near the top: what changed, whether it is local or live, what was validated, and what remains unresolved.
19
+ - Keep source paths and symbol names below the explanation unless they are the explanation.
20
+ - Keep intended Telegram bot-command tokens as plain text rather than inline code. Format Pi/TUI or shell commands as code according to the host contract. Plain source shape does not prove native clickability; claim it only after the active entity-detection and client path is verified.
21
+ - Use explicit Markdown links when a destination matters rather than assuming plain URL auto-detection.
22
+
23
+ ## Telegram HTML
24
+
25
+ - Produce a single self-contained file with UTF-8 metadata and a viewport declaration. Avoid external assets, scripts, fonts, trackers, or network requirements unless the user explicitly requested them.
26
+ - Build mobile-first for roughly phone-width reading, then let the same document expand cleanly in a system or desktop browser. Text must wrap; diagrams must scroll or reflow without clipping.
27
+ - Use semantic headings, sufficient contrast, non-color status meaning, comfortable touch targets, and no hover-only information.
28
+ - Preserve real labels, values, ordering, and uncertainty. An attractive reconstruction must not invent runtime state or imply that a proposed interaction exists.
29
+ - Include a compact provenance line when state matters, such as `Local patch · validated · not released · not live`.
30
+ - When rendering tools are available, inspect at least one narrow viewport and one wider viewport. Report what was inspected; static source review is not visual proof.
31
+ - Deliver the file through the active Telegram attachment mechanism. Do not expose local paths as if the user could open them remotely.
32
+
33
+ ## Current-Work Evidence
34
+
35
+ Before explaining “what we did” or “what happened,” use the narrowest available evidence that can support the answer:
36
+
37
+ 1. Inspect retained repository status and diff for the relevant task.
38
+ 2. Identify pre-existing or unrelated changes and exclude them from the claimed task result.
39
+ 3. Name the actual changed mechanism or contract, not a friendlier neighboring concept.
40
+ 4. Separate implementation evidence from validation, release, deployment, runtime, transport, and client evidence.
41
+ 5. State unresolved causes or missing live checks instead of filling them with a cleaner story.
42
+
43
+ A visual is successful when the user can understand the outcome away from a computer without being given a stronger claim than the evidence supports.