@mrclrchtr/supi-debug 1.3.0 → 1.4.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @mrclrchtr/supi-debug
2
2
 
3
- Session-local debug event inspection for the [pi coding agent](https://github.com/earendil-works/pi).
3
+ Adds shared debug-event capture and inspection for SuPi extensions in the [pi coding agent](https://github.com/earendil-works/pi).
4
4
 
5
5
  ## Install
6
6
 
@@ -8,50 +8,85 @@ Session-local debug event inspection for the [pi coding agent](https://github.co
8
8
  pi install npm:@mrclrchtr/supi-debug
9
9
  ```
10
10
 
11
- ## What it adds
11
+ For local development:
12
12
 
13
- This extension provides three surfaces for inspecting recent SuPi debug events:
13
+ ```bash
14
+ pi install ./packages/supi-debug
15
+ ```
16
+
17
+ After editing the source, run `/reload`.
18
+
19
+ ## What you get
20
+
21
+ After install, this package wires the shared debug registry into three user-facing surfaces:
22
+
23
+ - `/supi-debug` — show recent debug events in a readable TUI report
24
+ - `supi_debug` — let the model query recent debug events during troubleshooting
25
+ - `/supi-settings` integration — configure whether events are captured and how much data is exposed
26
+
27
+ It also registers a **Debug** provider section for `/supi-context`.
28
+
29
+ ## Event behavior
14
30
 
15
- - `supi_debug` tool — agent-callable query API
16
- - `/supi-debug` command TUI report for humans
17
- - shared settings integration enable/disable, access level, max events, notify level when your install surface includes `/supi-settings` (for example via `@mrclrchtr/supi`)
31
+ - events are session-local
32
+ - the event buffer is cleared on `session_start`
33
+ - if debug capture is disabled, no events are retained
34
+ - agent-facing access is blocked, sanitized, or raw depending on settings
18
35
 
19
- By default the agent sees sanitized event data. Raw event access requires explicit opt-in.
36
+ Rendered events include:
20
37
 
21
- ## Query filters
38
+ - timestamp
39
+ - level
40
+ - `source/category`
41
+ - message
42
+ - optional `cwd`
43
+ - optional `data`
44
+ - optional `rawData`
22
45
 
23
- Both the command and the tool support filtering by:
46
+ ## Filters
47
+
48
+ Both `/supi-debug` and `supi_debug` support the same basic filters:
24
49
 
25
50
  - `source`
26
51
  - `level`
27
52
  - `category`
28
53
  - `limit`
29
54
 
30
- ## Architecture
55
+ The tool also accepts:
31
56
 
32
- ```text
33
- src/
34
- ├── debug.ts extension wiring, settings, tool, and command registration
35
- ├── format.ts event formatting and serialization
36
- ├── renderer.ts custom message renderer for debug reports
37
- └── index.ts package entrypoint
38
- ```
57
+ - `includeRaw` — request raw event data when settings allow it
39
58
 
40
- ## Requirements
59
+ ## Settings
41
60
 
42
- - `@earendil-works/pi-coding-agent`
43
- - `@earendil-works/pi-tui`
44
- - `typebox`
45
- - `@mrclrchtr/supi-core`
61
+ This package registers a **Debug** section in `/supi-settings`.
46
62
 
47
- ## Development
63
+ Available settings:
48
64
 
49
- ```bash
50
- pnpm vitest run packages/supi-debug/
51
- pnpm exec tsc --noEmit -p packages/supi-debug/tsconfig.json
52
- pnpm exec biome check packages/supi-debug/
65
+ - `enabled` — turn session-local event capture on or off
66
+ - `agentAccess` `off`, `sanitized`, or `raw`
67
+ - `maxEvents` maximum retained events in memory
68
+ - `notifyLevel` minimum severity that may notify the user: `off`, `warning`, or `error`
69
+
70
+ Defaults come from the shared debug registry:
71
+
72
+ ```json
73
+ {
74
+ "debug": {
75
+ "enabled": false,
76
+ "agentAccess": "sanitized",
77
+ "maxEvents": 100,
78
+ "notifyLevel": "off"
79
+ }
80
+ }
53
81
  ```
54
82
 
55
- ## License
83
+ ## Extra status logging
84
+
85
+ If `SUPI_LOG_STATUS` is enabled in the environment, the package emits a SuPi load-status marker to stderr on `session_start` and appends the same payload as a session entry.
86
+
87
+ ## Source
56
88
 
57
- MIT
89
+ - `src/debug.ts` — settings, command, tool, and registry wiring
90
+ - `src/renderer.ts` — custom report renderer
91
+ - `src/format.ts` — debug payload formatting
92
+ - `src/status-log.ts` — optional load-status logging
@@ -1,65 +1,78 @@
1
1
  # @mrclrchtr/supi-core
2
2
 
3
- Shared infrastructure for SuPi packages.
3
+ Shared infrastructure for SuPi extensions.
4
+
5
+ This package is mainly for extension authors. It gives you a common config system, settings plumbing, context helpers, registries, and a small extension surface that registers `/supi-settings`.
4
6
 
5
7
  ## Install
6
8
 
7
- Use it as a dependency in another extension package:
9
+ ### As a dependency for another extension
8
10
 
9
11
  ```bash
10
12
  pnpm add @mrclrchtr/supi-core
11
13
  ```
12
14
 
13
- ## Package role
14
-
15
- `@mrclrchtr/supi-core` now has two explicit surfaces:
15
+ ### As a pi package
16
16
 
17
- - `@mrclrchtr/supi-core/api` — shared library helpers for other SuPi packages
18
- - `@mrclrchtr/supi-core/extension` — a minimal pi extension that registers `/supi-settings`
19
-
20
- `pi.extensions` still points at the real file path `./src/extension.ts` inside the package. The `/api` and `/extension` paths are consumer-facing package exports, not manifest aliases.
17
+ ```bash
18
+ pi install npm:@mrclrchtr/supi-core
19
+ ```
21
20
 
22
- ## What it provides
21
+ Installing it as a pi package adds the minimal `/supi-settings` extension surface.
23
22
 
24
- Current exports cover:
23
+ ## Package surfaces
25
24
 
26
- - shared config loading, scoped reads, writes, and key removal
27
- - config-backed settings registration helpers for `/supi-settings`
28
- - the shared settings registry, overlay UI, and `registerSettingsCommand()` helper
29
- - XML `<extension-context>` wrapping plus context-message utilities
30
- - context-provider and debug-event registries reused across SuPi packages
31
- - project root and path helpers reused by packages such as `supi-lsp`
25
+ - `@mrclrchtr/supi-core/api` reusable helpers for other packages and extensions
26
+ - `@mrclrchtr/supi-core/extension` minimal pi extension that registers `/supi-settings`
32
27
 
33
- ## Config system
28
+ ## What you get from the API
34
29
 
35
- Config resolution order:
30
+ ### Config helpers
36
31
 
37
- ```text
38
- defaults <- global <- project
39
- ```
32
+ - `loadSupiConfig()` — merged config with resolution order `defaults <- global <- project`
33
+ - `loadSupiConfigForScope()` load one scope at a time for settings UIs
34
+ - `writeSupiConfig()` — persist values
35
+ - `removeSupiConfigKey()` — remove a key or override
40
36
 
41
37
  Config file locations:
42
38
 
43
39
  - global: `~/.pi/agent/supi/config.json`
44
40
  - project: `.pi/supi/config.json`
45
41
 
46
- Main helpers:
42
+ ### Settings helpers
43
+
44
+ - `registerSettings()` — register an arbitrary settings section
45
+ - `registerConfigSettings()` — register a config-backed settings section with scoped persistence helpers
46
+ - `registerSettingsCommand()` — register `/supi-settings`
47
+ - `openSettingsOverlay()` — open the shared settings UI directly
48
+ - `createInputSubmenu()` — helper for simple text-entry submenus
49
+
50
+ The built-in settings UI supports:
47
51
 
48
- - `loadSupiConfig()` — effective merged config (`defaults <- global <- project`)
49
- - `loadSupiConfigForScope()` raw single-scope config for settings UIs (`defaults <- selected scope`)
50
- - `writeSupiConfig()`
51
- - `removeSupiConfigKey()`
52
- - `registerConfigSettings()`
52
+ - project/global scope toggle
53
+ - grouped extension sections
54
+ - searchable setting lists
53
55
 
54
- ## Context and settings helpers
56
+ ### Context helpers
55
57
 
56
- - `wrapExtensionContext()`
58
+ - `wrapExtensionContext()` — wrap injected text in SuPi's `<extension-context>` tag
57
59
  - `findLastUserMessageIndex()`
58
60
  - `getContextToken()`
61
+ - `getPromptContent()`
59
62
  - `pruneAndReorderContextMessages()`
60
- - `registerSettings()`
61
- - `registerSettingsCommand()`
62
- - `openSettingsOverlay()`
63
+ - `restorePromptContent()`
64
+
65
+ ### Shared registries
66
+
67
+ - context-provider registry for `/supi-context`
68
+ - debug-event registry for producers that want shared debug capture
69
+ - settings registry used by `/supi-settings`
70
+
71
+ ### Project and session helpers
72
+
73
+ - project-root detection and directory walking helpers such as `findProjectRoot()` and `walkProject()`
74
+ - active-branch session helper: `getActiveBranchEntries()`
75
+ - terminal helpers such as `formatTitle()`, `signalWaiting()`, and `signalDone()`
63
76
 
64
77
  ## Example
65
78
 
@@ -80,17 +93,15 @@ registerConfigSettings({
80
93
  });
81
94
 
82
95
  const message = wrapExtensionContext("my-extension", "hello", {
83
- turn: 1,
84
96
  file: "CLAUDE.md",
97
+ turn: 1,
85
98
  });
86
99
  ```
87
100
 
88
- ## Requirements
89
-
90
- - `@earendil-works/pi-coding-agent`
91
- - `@earendil-works/pi-tui`
92
-
93
101
  ## Source
94
102
 
95
- - Library surface: `src/api.ts`
96
- - Extension surface: `src/extension.ts`
103
+ - `src/api.ts` — exported library surface
104
+ - `src/extension.ts` — minimal `/supi-settings` entrypoint
105
+ - `src/config.ts` — shared config loading and writing
106
+ - `src/config-settings.ts` — config-backed settings registration helper
107
+ - `src/settings-ui.ts` — shared settings overlay
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-core",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "SuPi core — shared infrastructure for SuPi extensions (XML context tags, config system)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -2,30 +2,30 @@
2
2
  // Provides XML context tag wrapping, unified config system, context-message utilities,
3
3
  // and settings registry for supi-wide TUI settings.
4
4
 
5
- export type { SupiConfigLocation, SupiConfigOptions } from "./config.ts";
5
+ export type { SupiConfigLocation, SupiConfigOptions } from "./config/config.ts";
6
6
  export {
7
7
  loadSupiConfig,
8
8
  loadSupiConfigForScope,
9
9
  removeSupiConfigKey,
10
10
  writeSupiConfig,
11
- } from "./config.ts";
12
- export type { ConfigSettingsHelpers, ConfigSettingsOptions } from "./config-settings.ts";
13
- export { registerConfigSettings } from "./config-settings.ts";
14
- export type { ContextMessageLike } from "./context-messages.ts";
11
+ } from "./config/config.ts";
12
+ export type { ConfigSettingsHelpers, ConfigSettingsOptions } from "./config/config-settings.ts";
13
+ export { registerConfigSettings } from "./config/config-settings.ts";
14
+ export type { ContextMessageLike } from "./context/context-messages.ts";
15
15
  export {
16
16
  findLastUserMessageIndex,
17
17
  getContextToken,
18
18
  getPromptContent,
19
19
  pruneAndReorderContextMessages,
20
20
  restorePromptContent,
21
- } from "./context-messages.ts";
22
- export type { ContextProvider } from "./context-provider-registry.ts";
21
+ } from "./context/context-messages.ts";
22
+ export type { ContextProvider } from "./context/context-provider-registry.ts";
23
23
  export {
24
24
  clearRegisteredContextProviders,
25
25
  getRegisteredContextProviders,
26
26
  registerContextProvider,
27
- } from "./context-provider-registry.ts";
28
- export { wrapExtensionContext } from "./context-tag.ts";
27
+ } from "./context/context-provider-registry.ts";
28
+ export { wrapExtensionContext } from "./context/context-tag.ts";
29
29
  export type {
30
30
  DebugAgentAccess,
31
31
  DebugEvent,
@@ -64,14 +64,14 @@ export {
64
64
  walkProject,
65
65
  } from "./project-roots.ts";
66
66
  export { getActiveBranchEntries } from "./session-utils.ts";
67
- export { registerSettingsCommand } from "./settings-command.ts";
68
- export type { SettingsScope, SettingsSection } from "./settings-registry.ts";
67
+ export { registerSettingsCommand } from "./settings/settings-command.ts";
68
+ export type { SettingsScope, SettingsSection } from "./settings/settings-registry.ts";
69
69
  export {
70
70
  clearRegisteredSettings,
71
71
  getRegisteredSettings,
72
72
  registerSettings,
73
- } from "./settings-registry.ts";
74
- export { createInputSubmenu, openSettingsOverlay } from "./settings-ui.ts";
73
+ } from "./settings/settings-registry.ts";
74
+ export { createInputSubmenu, openSettingsOverlay } from "./settings/settings-ui.ts";
75
75
  export type { TitleTarget } from "./terminal.ts";
76
76
  export {
77
77
  DONE_SYMBOL,
@@ -2,9 +2,9 @@
2
2
  // Wraps registerSettings() and centralizes selected-scope loading + scoped persistence.
3
3
 
4
4
  import type { SettingItem } from "@earendil-works/pi-tui";
5
+ import type { SettingsScope } from "../settings/settings-registry.ts";
6
+ import { registerSettings } from "../settings/settings-registry.ts";
5
7
  import { loadSupiConfigForScope, removeSupiConfigKey, writeSupiConfig } from "./config.ts";
6
- import type { SettingsScope } from "./settings-registry.ts";
7
- import { registerSettings } from "./settings-registry.ts";
8
8
 
9
9
  export interface ConfigSettingsHelpers {
10
10
  /** Write a key to the selected scope's config section. */
@@ -3,7 +3,7 @@
3
3
  // Extensions declare context data providers via `registerContextProvider()` during their
4
4
  // factory function. The `/supi-context` command reads them via `getRegisteredContextProviders()`.
5
5
 
6
- import { createRegistry } from "./registry-utils.ts";
6
+ import { createRegistry } from "../registry-utils.ts";
7
7
 
8
8
  export interface ContextProvider {
9
9
  /** Unique identifier — e.g. "rtk" */
@@ -1 +1 @@
1
- export { registerSettingsCommand as default } from "./settings-command.ts";
1
+ export { registerSettingsCommand as default } from "./settings/settings-command.ts";
@@ -2,30 +2,30 @@
2
2
  // Provides XML context tag wrapping, unified config system, context-message utilities,
3
3
  // and settings registry for supi-wide TUI settings.
4
4
 
5
- export type { SupiConfigLocation, SupiConfigOptions } from "./config.ts";
5
+ export type { SupiConfigLocation, SupiConfigOptions } from "./config/config.ts";
6
6
  export {
7
7
  loadSupiConfig,
8
8
  loadSupiConfigForScope,
9
9
  removeSupiConfigKey,
10
10
  writeSupiConfig,
11
- } from "./config.ts";
12
- export type { ConfigSettingsHelpers, ConfigSettingsOptions } from "./config-settings.ts";
13
- export { registerConfigSettings } from "./config-settings.ts";
14
- export type { ContextMessageLike } from "./context-messages.ts";
11
+ } from "./config/config.ts";
12
+ export type { ConfigSettingsHelpers, ConfigSettingsOptions } from "./config/config-settings.ts";
13
+ export { registerConfigSettings } from "./config/config-settings.ts";
14
+ export type { ContextMessageLike } from "./context/context-messages.ts";
15
15
  export {
16
16
  findLastUserMessageIndex,
17
17
  getContextToken,
18
18
  getPromptContent,
19
19
  pruneAndReorderContextMessages,
20
20
  restorePromptContent,
21
- } from "./context-messages.ts";
22
- export type { ContextProvider } from "./context-provider-registry.ts";
21
+ } from "./context/context-messages.ts";
22
+ export type { ContextProvider } from "./context/context-provider-registry.ts";
23
23
  export {
24
24
  clearRegisteredContextProviders,
25
25
  getRegisteredContextProviders,
26
26
  registerContextProvider,
27
- } from "./context-provider-registry.ts";
28
- export { wrapExtensionContext } from "./context-tag.ts";
27
+ } from "./context/context-provider-registry.ts";
28
+ export { wrapExtensionContext } from "./context/context-tag.ts";
29
29
  export type {
30
30
  DebugAgentAccess,
31
31
  DebugEvent,
@@ -64,14 +64,14 @@ export {
64
64
  walkProject,
65
65
  } from "./project-roots.ts";
66
66
  export { getActiveBranchEntries } from "./session-utils.ts";
67
- export { registerSettingsCommand } from "./settings-command.ts";
68
- export type { SettingsScope, SettingsSection } from "./settings-registry.ts";
67
+ export { registerSettingsCommand } from "./settings/settings-command.ts";
68
+ export type { SettingsScope, SettingsSection } from "./settings/settings-registry.ts";
69
69
  export {
70
70
  clearRegisteredSettings,
71
71
  getRegisteredSettings,
72
72
  registerSettings,
73
- } from "./settings-registry.ts";
74
- export { createInputSubmenu, openSettingsOverlay } from "./settings-ui.ts";
73
+ } from "./settings/settings-registry.ts";
74
+ export { createInputSubmenu, openSettingsOverlay } from "./settings/settings-ui.ts";
75
75
  export type { TitleTarget } from "./terminal.ts";
76
76
  export {
77
77
  DONE_SYMBOL,
@@ -4,7 +4,7 @@
4
4
  // factory function. The generic settings UI reads them via `getRegisteredSettings()`.
5
5
 
6
6
  import type { SettingItem } from "@earendil-works/pi-tui";
7
- import { createRegistry } from "./registry-utils.ts";
7
+ import { createRegistry } from "../registry-utils.ts";
8
8
 
9
9
  export type SettingsScope = "project" | "global";
10
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-debug",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "SuPi Debug extension — shared debug event inspection for SuPi extensions",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -20,7 +20,7 @@
20
20
  "README.md"
21
21
  ],
22
22
  "dependencies": {
23
- "@mrclrchtr/supi-core": "1.3.0"
23
+ "@mrclrchtr/supi-core": "1.4.0"
24
24
  },
25
25
  "bundledDependencies": [
26
26
  "@mrclrchtr/supi-core"
@@ -43,7 +43,8 @@
43
43
  },
44
44
  "pi": {
45
45
  "extensions": [
46
- "./src/extension.ts"
46
+ "./src/extension.ts",
47
+ "node_modules/@mrclrchtr/supi-core/src/extension.ts"
47
48
  ]
48
49
  },
49
50
  "main": "src/api.ts",
package/src/debug.ts CHANGED
@@ -18,6 +18,7 @@ import { Type } from "typebox";
18
18
  import { formatDataLines } from "./format.ts";
19
19
  import { registerDebugMessageRenderer } from "./renderer.ts";
20
20
  import { maybeLogLoadStatus } from "./status-log.ts";
21
+ import { promptGuidelines, promptSnippet, toolDescription } from "./tool/guidance.ts";
21
22
 
22
23
  const DEBUG_SECTION = "debug";
23
24
  const DEBUG_REPORT_TYPE = "supi-debug-report";
@@ -319,13 +320,9 @@ export default function debugExtension(pi: ExtensionAPI) {
319
320
  pi.registerTool({
320
321
  name: "supi_debug",
321
322
  label: "SuPi Debug",
322
- description: "Fetch recent session-local SuPi extension debug events for troubleshooting.",
323
- promptSnippet:
324
- "Fetch recent SuPi extension debug events when troubleshooting extension behavior.",
325
- promptGuidelines: [
326
- "Use supi_debug when the user asks to inspect SuPi extension failures, fallback reasons, or recent debug events.",
327
- "supi_debug returns sanitized events by default; request raw data only when the user explicitly wants raw diagnostics and settings allow it.",
328
- ],
323
+ description: toolDescription,
324
+ promptSnippet,
325
+ promptGuidelines,
329
326
  parameters: Type.Object({
330
327
  source: Type.Optional(Type.String({ description: "Filter by extension source, e.g. rtk" })),
331
328
  level: Type.Optional(
@@ -0,0 +1,12 @@
1
+ // Prompt guidance and tool description for the supi_debug tool.
2
+
3
+ export const toolDescription =
4
+ "Fetch recent session-local SuPi extension debug events for troubleshooting, with optional source/level/category filters and optional raw event data when allowed.";
5
+
6
+ export const promptSnippet =
7
+ "supi_debug — fetch recent SuPi extension debug events for troubleshooting";
8
+
9
+ export const promptGuidelines = [
10
+ "Use supi_debug when the user asks to inspect SuPi extension failures, fallback reasons, or recent debug events in the current session.",
11
+ "Use supi_debug's default sanitized output unless the user explicitly asks for raw diagnostics and the configured access level allows raw supi_debug data.",
12
+ ];