@narumitw/pi-inspect 0.0.0-stage → 0.2.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 (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +110 -2
  3. package/dist/app.css +1 -0
  4. package/dist/app.js +128 -0
  5. package/dist/index.html +1 -0
  6. package/docs/REVIEW.md +189 -0
  7. package/docs/VERIFICATION.md +186 -0
  8. package/docs/viewer.md +74 -0
  9. package/package.json +67 -4
  10. package/src/ancestry.ts +32 -0
  11. package/src/collector.ts +143 -0
  12. package/src/context.ts +115 -0
  13. package/src/correlation.ts +27 -0
  14. package/src/entry-index.ts +17 -0
  15. package/src/entry-summary.ts +34 -0
  16. package/src/extension.ts +259 -0
  17. package/src/feed.ts +145 -0
  18. package/src/identity.ts +112 -0
  19. package/src/index.ts +1 -0
  20. package/src/model.ts +117 -0
  21. package/src/native-projection.ts +28 -0
  22. package/src/privacy.ts +136 -0
  23. package/src/projection.ts +374 -0
  24. package/src/server.ts +202 -0
  25. package/src/system-message.ts +117 -0
  26. package/src/web/api.ts +137 -0
  27. package/src/web/app.tsx +570 -0
  28. package/src/web/captured-executions.tsx +177 -0
  29. package/src/web/components.css +261 -0
  30. package/src/web/components.tsx +241 -0
  31. package/src/web/composition.css +554 -0
  32. package/src/web/context-composition.tsx +329 -0
  33. package/src/web/context-inventory.tsx +65 -0
  34. package/src/web/entry-calls.ts +14 -0
  35. package/src/web/format.ts +94 -0
  36. package/src/web/hierarchy.ts +117 -0
  37. package/src/web/history.ts +56 -0
  38. package/src/web/inline-entry.tsx +124 -0
  39. package/src/web/inspector.tsx +386 -0
  40. package/src/web/json-tree.tsx +74 -0
  41. package/src/web/overview.tsx +67 -0
  42. package/src/web/panels.css +267 -0
  43. package/src/web/panes.tsx +123 -0
  44. package/src/web/recorded-content.tsx +49 -0
  45. package/src/web/search.ts +16 -0
  46. package/src/web/session-filters.tsx +100 -0
  47. package/src/web/session.css +114 -0
  48. package/src/web/style.css +332 -0
  49. package/src/web/styles.d.ts +1 -0
  50. package/src/web/timeline.tsx +33 -0
  51. package/src/web/timing.ts +26 -0
  52. package/src/web/trace.css +411 -0
  53. package/src/web/trace.tsx +313 -0
  54. package/src/web/virtual-context.ts +138 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 narumiruna
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,111 @@
1
- # Temporary Holding Version
1
+ # 🔎 pi-inspect — Pi session inspector
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm version](https://img.shields.io/npm/v/@narumitw/pi-inspect)](https://www.npmjs.com/package/@narumitw/pi-inspect)
4
+ [![Pi extension](https://img.shields.io/badge/Pi-extension-blue)](https://pi.dev)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)
6
+
7
+ A read-only browser view of the current Pi session, with consent-gated live context and tool-call observation.
8
+
9
+ > Opening the viewer exposes session prompts, code, paths, and tool output to your browser. Structured credential fields and Bearer tokens are redacted, but arbitrary secrets in prose cannot be reliably removed. Open the URL privately; do not share it, record it, or load the viewer in an untrusted browser profile. Nothing is uploaded, and detailed traces are kept only in memory after consent.
10
+
11
+ ## ✨ Features
12
+
13
+ - Explore ordered context messages and blocks with search, filters, a minimap and expandable details.
14
+ - Read branch-scoped Session history with conversation groups, direct search matches, and an explicit internal-events view.
15
+ - Inspect actual branches, historical prompts, tools, skills and codemode evidence through content-first Details without changing Pi's active leaf.
16
+ - Follow bounded live tool calls, including observed nested calls, with explicit provenance and unavailable-data labels.
17
+ - Use light/dark and responsive browser layouts with keyboard navigation.
18
+
19
+ ## 📦 Install
20
+
21
+ This package has not been published yet. From a repository checkout:
22
+
23
+ ```bash
24
+ npm install
25
+ npm --workspace @narumitw/pi-inspect run build
26
+ pi install ./packages/pi-inspect
27
+ ```
28
+
29
+ For one invocation without saving an installation:
30
+
31
+ ```bash
32
+ pi -e ./packages/pi-inspect
33
+ ```
34
+
35
+ Extensions run with Pi's permissions; review the source before installing. Root `npm install` builds browser assets during prepare, including Pi's production-only Git installation path. Rebuild after frontend changes. Packaged browser assets require no development server; frontend/build dependencies remain production dependencies so asset-free Git checkouts can build with dev dependencies omitted. Factory loading does not start the server or read those assets.
36
+
37
+ The old project-local extension is removed. Replace explicit `.pi/extensions/inspect/index.ts` references with `packages/pi-inspect/src/index.ts`, or load the package directory. Reload an existing session after updating its installation.
38
+
39
+ ## 🚀 Quick start
40
+
41
+ In Pi's interactive TUI, run `/inspect` and accept the sensitive-data warning. The command opens your default browser; if opening fails, Pi shows a private URL instead.
42
+
43
+ Context shows the last observed model input, or an explicitly labeled session-derived fallback. Switch to Session for History, Branch view, or Captured executions; selecting a record opens Details. **View branch context** opens an explicit historical projection, not a captured request. Current runtime inventories and independent provider observations remain separate from historical evidence.
44
+
45
+ Use `/inspect stop` when finished. Closing the browser tab alone does not stop the server or collection.
46
+
47
+ ## 💬 Commands
48
+
49
+ | Command | TUI | RPC | JSON / print |
50
+ | --- | --- | --- | --- |
51
+ | `/inspect` | Confirm, start, open/reopen viewer | Observable notification rejecting opening | Extension command error reported by Pi |
52
+ | `/inspect stop` | Stop and notify | Stop and notify | Stop; no ad hoc protocol output |
53
+ | Unknown or trailing arguments | Usage warning | Usage warning | Extension command error reported by Pi |
54
+
55
+ `/session-inspector` and `/session-inspector stop` remain compatibility aliases with identical consent, mode checks and lifecycle behavior.
56
+
57
+ The default command is a frequent single action, not a manager menu. There are no saved settings, extension environment variables, model tools, or browser-controlled agent actions.
58
+
59
+ ## 🔒 Security and privacy
60
+
61
+ The server binds only `127.0.0.1` on a random port. Data and SSE requests require a per-session token and generation; Host, Origin and method checks reject unrelated requests. The data-free shell and bundled JS/CSS are publicly readable on that loopback port. Do not expose the port remotely: tokens do not defend against a malicious process running as your local user.
62
+
63
+ CSP blocks remote content. Text and Markdown remain literal; only small validated raster images can render. No filesystem attachment is opened automatically. Capture and display are bounded, and Raw/Copy reveal only bounded captured data, not omitted content.
64
+
65
+ Stop, reload, session replacement and shutdown clear collection, close connections and revoke the URL. Revocation cannot erase data already received by a browser; close the tab to release that view. Pending requests, streams, timers, browser-launch tasks and session resources are cancelled at their owning boundary. Browser storage is optional: valid private URLs still work when it is blocked, but a fragment-free reload without saved credentials requires reopening the viewer from Pi.
66
+
67
+ See the bundled [viewer reference](./docs/viewer.md) for detailed bounds, connection behavior and security controls.
68
+
69
+ ## 🚧 Limitations
70
+
71
+ The observed Pi-stage context and provider-payload copies are not guaranteed final transport inputs. Historical projections follow native Pi semantics; missing checkpoints, uncaptured results, segment token sizes and unavailable timings are labeled rather than inferred. Session ancestry and live execution parentage remain separate.
72
+
73
+ The [viewer reference](./docs/viewer.md) documents every view, supported interaction, provenance distinction and capture limit.
74
+
75
+ ## Development verification
76
+
77
+ Run from the repository root:
78
+
79
+ ```bash
80
+ npm --workspace @narumitw/pi-inspect run build
81
+ npm --workspace @narumitw/pi-inspect run typecheck
82
+ npm --workspace @narumitw/pi-inspect test
83
+ npm exec --workspace @narumitw/pi-inspect -- playwright install chromium
84
+ npm --workspace @narumitw/pi-inspect run test:browser
85
+ npm --workspace @narumitw/pi-inspect run smoke
86
+ npm --workspace @narumitw/pi-inspect run smoke:git-install
87
+ npm run package:pack -- inspect
88
+ npm run check
89
+ npm test
90
+ ```
91
+
92
+ Root checks build and typecheck this workspace; root tests include its deterministic tests. Browser tests run separately. The smoke exercises package-directory loading, trusted source discovery, command-mode rejection, reload, replacement and orderly shutdown without a paid provider request. The production Git-install smoke starts with an asset-free source checkout, runs Pi's production npm install flags, and verifies generated assets, loopback serving and Pi loading. Browser bundles preserve third-party license comments.
93
+
94
+ [Historical verification](./docs/VERIFICATION.md) and [review evidence](./docs/REVIEW.md) retain earlier implementation audits; their old project-local paths describe that earlier revision.
95
+
96
+ ## 🗂️ Package layout
97
+
98
+ - `src/index.ts`: thin Pi entrypoint forwarding to `src/extension.ts`.
99
+ - `src/`: session ownership, bounded collection, projection, privacy and loopback server.
100
+ - `src/web/`: React/Radix browser viewer and styles.
101
+ - `dist/`: generated browser assets, built before packing and included in the package.
102
+ - `docs/`: bundled viewer reference and historical review/verification evidence.
103
+ - `scripts/`, `test/`: repository build/smoke helpers and deterministic/browser tests; not published.
104
+
105
+ ## 🔎 Keywords
106
+
107
+ Pi, session inspector, context composition, tool calls, codemode, read-only browser viewer, privacy.
108
+
109
+ ## 📄 License
110
+
111
+ [MIT](./LICENSE).