@selesai/code 0.10.2 → 0.11.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/CHANGELOG.md +13 -0
- package/dist/cli/credential-print.js +4 -4
- package/dist/cli.js +0 -0
- package/dist/core/compaction/branch-summarization.js +30 -30
- package/dist/core/compaction/compaction.js +81 -81
- package/dist/core/compaction/utils.js +2 -2
- package/dist/core/export-html/template.css +1066 -1066
- package/dist/core/export-html/template.html +55 -55
- package/dist/core/export-html/template.js +1864 -1864
- package/dist/core/export-html/vendor/highlight.min.js +1212 -1212
- package/dist/core/export-html/vendor/marked.min.js +78 -78
- package/dist/core/messages.js +7 -7
- package/dist/defaults/settings.json +0 -3
- package/dist/extensions/auto-session-name.test.ts +157 -0
- package/dist/extensions/auto-session-name.ts +96 -0
- package/dist/extensions/context-compaction-reminder.test.ts +82 -82
- package/dist/extensions/context-compaction-reminder.ts +28 -28
- package/dist/extensions/cost-reconcile.test.ts +76 -0
- package/dist/extensions/cost-reconcile.ts +278 -0
- package/dist/extensions/enable-readonly-tools.test.ts +11 -0
- package/dist/extensions/enable-readonly-tools.ts +7 -3
- package/dist/extensions/package.json +3 -0
- package/dist/extensions/pi-intercom/LICENSE +21 -21
- package/dist/extensions/pi-intercom/broker/client.test.ts +83 -83
- package/dist/extensions/pi-intercom/broker/framing.test.ts +114 -114
- package/dist/extensions/pi-intercom/broker/paths.ts +134 -134
- package/dist/extensions/pi-intercom/broker/runtime-claim.test.ts +34 -34
- package/dist/extensions/pi-intercom/broker/runtime-claim.ts +21 -21
- package/dist/extensions/pi-intercom/cwd.test.ts +40 -40
- package/dist/extensions/pi-intercom/cwd.ts +31 -31
- package/dist/extensions/pi-intercom/format-context.test.ts +31 -31
- package/dist/extensions/pi-intercom/format-context.ts +32 -32
- package/dist/extensions/pi-intercom/test/overlay-width.test.ts +66 -66
- package/dist/extensions/pi-intercom/ui/compose.ts +143 -143
- package/dist/extensions/pi-intercom/ui/session-list.ts +166 -166
- package/dist/extensions/pi-rewind-hook/README.md +245 -245
- package/dist/extensions/pi-rewind-hook/index.ts +1445 -1445
- package/dist/extensions/pi-rewind-hook/package.json +29 -29
- package/dist/extensions/pi-subagents/install.mjs +0 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/bun/cli.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/bun/register-bedrock.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/bun/restore-sandbox-env.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/args.d.ts +57 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/config-selector.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/file-processor.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/initial-message.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/list-models.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/project-trust.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/session-picker.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/startup-ui.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/config.d.ts +96 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/agent-session-runtime.d.ts +119 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/agent-session-services.d.ts +85 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/agent-session.d.ts +620 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/auth-guidance.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/auth-storage.d.ts +56 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/bash-executor.d.ts +32 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/cache-stats.d.ts +49 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/branch-summarization.d.ts +93 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/compaction.d.ts +128 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/index.d.ts +7 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/utils.d.ts +38 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/defaults.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/diagnostics.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/event-bus.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/exec.d.ts +29 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/experimental.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/export-html/index.d.ts +37 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/export-html/tool-renderer.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/index.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/loader.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/runner.d.ts +171 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/types.d.ts +1261 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/wrapper.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/footer-data-provider.d.ts +54 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/http-dispatcher.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/index.d.ts +13 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/keybindings.d.ts +358 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/messages.d.ts +77 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-config.d.ts +512 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-registry.d.ts +43 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-resolver.d.ts +121 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-runtime.d.ts +82 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/models-store.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/output-guard.d.ts +7 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/package-manager.d.ts +210 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/project-trust.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/prompt-templates.d.ts +54 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/provider-attribution.d.ts +4 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/provider-composer.d.ts +55 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/radius.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/remote-catalog-provider.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/resolve-config-value.d.ts +30 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/resource-loader.d.ts +206 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/runtime-credentials.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/sdk.d.ts +106 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/session-cwd.d.ts +19 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/session-manager.d.ts +356 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/settings-manager.d.ts +297 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/skills.d.ts +60 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/slash-commands.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/source-info.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/system-prompt.d.ts +28 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/telemetry.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/timings.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/bash.d.ts +68 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/edit-diff.d.ts +106 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/edit.d.ts +51 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/file-mutation-queue.d.ts +6 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/find.d.ts +35 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/grep.d.ts +37 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/index.d.ts +40 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/ls.d.ts +37 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/output-accumulator.d.ts +52 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/path-utils.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/read.d.ts +35 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/render-utils.d.ts +24 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/truncate.d.ts +70 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/write.d.ts +26 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/trust-manager.d.ts +36 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/usage-totals.d.ts +19 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/index.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/client.d.ts +61 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/huggingface.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/index.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/provider.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/ui.d.ts +42 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/index.d.ts +35 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/main.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/migrations.d.ts +33 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/index.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/armin.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/assistant-message.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/bash-execution.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/config-selector.d.ts +102 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/custom-editor.d.ts +21 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/custom-entry.d.ts +19 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/daxnuts.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/diff.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/earendil-announcement.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/extension-editor.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/extension-selector.d.ts +26 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/first-time-setup.d.ts +25 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/footer.d.ts +32 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/index.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/login-dialog.d.ts +52 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/model-selector.d.ts +54 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/oauth-selector.d.ts +33 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/scoped-models-selector.d.ts +42 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/session-selector.d.ts +95 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/settings-selector.d.ts +77 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/status-indicator.d.ts +28 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/tool-execution.d.ts +63 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/tree-selector.d.ts +94 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/trust-selector.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/user-message.d.ts +14 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/interactive-mode.d.ts +394 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/model-search.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/theme/theme-controller.d.ts +29 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/theme/theme.d.ts +120 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/print-mode.d.ts +28 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/jsonl.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/rpc-client.d.ts +246 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/rpc-types.d.ts +457 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/package-manager-cli.d.ts +8 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/rpc-entry.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/ansi.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/changelog.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/child-process.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/clipboard-image.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/clipboard-native.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/clipboard.d.ts +4 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/deprecation.d.ts +4 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/exif-orientation.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/frontmatter.d.ts +8 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/fs-watch.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/git.d.ts +26 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/html.d.ts +7 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-convert.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-process.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-resize-core.d.ts +30 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-resize-worker.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-resize.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/json.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/mime.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/open-browser.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/paths.d.ts +31 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/photon.d.ts +21 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/pi-user-agent.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/shell.d.ts +31 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/sleep.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/syntax-highlight.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/tools-manager.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/version-check.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/windows-self-update.d.ts +3 -0
- package/dist/extensions/pi-tool-display/CHANGELOG.md +329 -0
- package/dist/extensions/pi-tool-display/LICENSE +21 -0
- package/dist/extensions/pi-tool-display/README.md +417 -0
- package/dist/extensions/pi-tool-display/config/config.example.json +40 -0
- package/dist/extensions/pi-tool-display/index.ts +3 -0
- package/dist/extensions/pi-tool-display/package-lock.json +2555 -0
- package/dist/extensions/pi-tool-display/package.json +86 -0
- package/dist/extensions/pi-tool-display/src/agent-dir.ts +35 -0
- package/dist/extensions/pi-tool-display/src/ansi-utils.ts +116 -0
- package/dist/extensions/pi-tool-display/src/bash-display.ts +213 -0
- package/dist/extensions/pi-tool-display/src/capabilities.ts +88 -0
- package/dist/extensions/pi-tool-display/src/config-modal.ts +541 -0
- package/dist/extensions/pi-tool-display/src/config-store.ts +304 -0
- package/dist/extensions/pi-tool-display/src/debug-logger.ts +150 -0
- package/dist/extensions/pi-tool-display/src/diff-presentation.ts +72 -0
- package/dist/extensions/pi-tool-display/src/diff-renderer.ts +2517 -0
- package/dist/extensions/pi-tool-display/src/disposable.ts +34 -0
- package/dist/extensions/pi-tool-display/src/extension-lifecycle.ts +14 -0
- package/dist/extensions/pi-tool-display/src/index.ts +109 -0
- package/dist/extensions/pi-tool-display/src/line-width-safety.ts +93 -0
- package/dist/extensions/pi-tool-display/src/modal-icons.ts +57 -0
- package/dist/extensions/pi-tool-display/src/pending-diff-preview.ts +370 -0
- package/dist/extensions/pi-tool-display/src/presets.ts +117 -0
- package/dist/extensions/pi-tool-display/src/render-utils.ts +186 -0
- package/dist/extensions/pi-tool-display/src/settings-inspector-modal.ts +475 -0
- package/dist/extensions/pi-tool-display/src/thinking-label.ts +343 -0
- package/dist/extensions/pi-tool-display/src/tool-call-box.ts +181 -0
- package/dist/extensions/pi-tool-display/src/tool-metadata.ts +139 -0
- package/dist/extensions/pi-tool-display/src/tool-overrides.ts +2168 -0
- package/dist/extensions/pi-tool-display/src/types.ts +109 -0
- package/dist/extensions/pi-tool-display/src/user-message-box-markdown.ts +64 -0
- package/dist/extensions/pi-tool-display/src/user-message-box-native.ts +66 -0
- package/dist/extensions/pi-tool-display/src/user-message-box-patch.ts +72 -0
- package/dist/extensions/pi-tool-display/src/user-message-box-renderer.ts +419 -0
- package/dist/extensions/pi-tool-display/src/user-message-box-utils.ts +106 -0
- package/dist/extensions/pi-tool-display/src/write-display-utils.ts +31 -0
- package/dist/extensions/pi-tool-display/src/zellij-modal.ts +1027 -0
- package/dist/extensions/pi-tool-display/tests/active-backlog-red.test.ts +65 -0
- package/dist/extensions/pi-tool-display/tests/ansi-utils.test.ts +345 -0
- package/dist/extensions/pi-tool-display/tests/bash-display.test.ts +442 -0
- package/dist/extensions/pi-tool-display/tests/capabilities-edge.test.ts +360 -0
- package/dist/extensions/pi-tool-display/tests/capabilities.test.ts +54 -0
- package/dist/extensions/pi-tool-display/tests/config-modal.test.ts +360 -0
- package/dist/extensions/pi-tool-display/tests/config-store.test.ts +87 -0
- package/dist/extensions/pi-tool-display/tests/custom-tool-overrides.test.ts +415 -0
- package/dist/extensions/pi-tool-display/tests/debug-logger-edge.test.ts +630 -0
- package/dist/extensions/pi-tool-display/tests/debug-logger.test.ts +62 -0
- package/dist/extensions/pi-tool-display/tests/diff-renderer-ansi.test.ts +55 -0
- package/dist/extensions/pi-tool-display/tests/diff-renderer-edge.test.ts +886 -0
- package/dist/extensions/pi-tool-display/tests/diff-renderer-numbering.test.ts +135 -0
- package/dist/extensions/pi-tool-display/tests/diff-renderer-width.test.ts +454 -0
- package/dist/extensions/pi-tool-display/tests/diff-renderer-wrap.test.ts +169 -0
- package/dist/extensions/pi-tool-display/tests/index-integration.test.ts +354 -0
- package/dist/extensions/pi-tool-display/tests/pending-diff-preview.test.ts +79 -0
- package/dist/extensions/pi-tool-display/tests/presets-edge.test.ts +229 -0
- package/dist/extensions/pi-tool-display/tests/presets.test.ts +26 -0
- package/dist/extensions/pi-tool-display/tests/reload-behavior.test.ts +1241 -0
- package/dist/extensions/pi-tool-display/tests/render-utils.test.ts +710 -0
- package/dist/extensions/pi-tool-display/tests/settings-inspector.test.ts +450 -0
- package/dist/extensions/pi-tool-display/tests/thinking-label-edge.test.ts +904 -0
- package/dist/extensions/pi-tool-display/tests/thinking-label.test.ts +72 -0
- package/dist/extensions/pi-tool-display/tests/tool-call-box.test.ts +105 -0
- package/dist/extensions/pi-tool-display/tests/tool-overrides-config.test.ts +613 -0
- package/dist/extensions/pi-tool-display/tests/tool-overrides-mcp.test.ts +499 -0
- package/dist/extensions/pi-tool-display/tests/tool-overrides-registration.test.ts +315 -0
- package/dist/extensions/pi-tool-display/tests/tool-overrides-write-meta.test.ts +68 -0
- package/dist/extensions/pi-tool-display/tests/tool-ui-utils.test.ts +413 -0
- package/dist/extensions/pi-tool-display/tests/user-message-box-performance-red.test.ts +176 -0
- package/dist/extensions/pi-tool-display/tests/user-message-box.test.ts +908 -0
- package/dist/extensions/pi-tool-display/tests/zellij-modal.test.ts +848 -0
- package/dist/extensions/pi-tool-display/tool-display-api-consumer.d.ts +30 -0
- package/dist/extensions/pi-tool-display/tool-display-api-consumer.js +40 -0
- package/dist/extensions/pi-web-agent/package.json +31 -31
- package/dist/extensions/pi-web-agent/src/backends/config.ts +205 -205
- package/dist/extensions/pi-web-agent/src/backends/doctor.ts +136 -136
- package/dist/extensions/pi-web-agent/src/backends/factory.ts +152 -152
- package/dist/extensions/pi-web-agent/src/backends/settings-reader.ts +25 -25
- package/dist/extensions/pi-web-agent/src/cache/ttl-cache.ts +28 -28
- package/dist/extensions/pi-web-agent/src/changelog-notice.ts +136 -136
- package/dist/extensions/pi-web-agent/src/commands/web-agent-config.ts +946 -946
- package/dist/extensions/pi-web-agent/src/extension.ts +126 -126
- package/dist/extensions/pi-web-agent/src/extract/readability.ts +118 -118
- package/dist/extensions/pi-web-agent/src/fetch/browser-resolution.ts +199 -199
- package/dist/extensions/pi-web-agent/src/fetch/firecrawl-fetch.ts +100 -100
- package/dist/extensions/pi-web-agent/src/fetch/headless-fetch.ts +117 -117
- package/dist/extensions/pi-web-agent/src/fetch/http-fetch.ts +67 -67
- package/dist/extensions/pi-web-agent/src/orchestration/answer-synthesizer.ts +60 -60
- package/dist/extensions/pi-web-agent/src/orchestration/candidate-selector.ts +50 -50
- package/dist/extensions/pi-web-agent/src/orchestration/direct-url.ts +52 -52
- package/dist/extensions/pi-web-agent/src/orchestration/evidence-quality.ts +105 -105
- package/dist/extensions/pi-web-agent/src/orchestration/evidence-ranker.ts +45 -45
- package/dist/extensions/pi-web-agent/src/orchestration/index.ts +28 -28
- package/dist/extensions/pi-web-agent/src/orchestration/query-planner.ts +47 -47
- package/dist/extensions/pi-web-agent/src/orchestration/research-orchestrator.ts +376 -376
- package/dist/extensions/pi-web-agent/src/orchestration/research-types.ts +64 -64
- package/dist/extensions/pi-web-agent/src/orchestration/research-worker.ts +181 -181
- package/dist/extensions/pi-web-agent/src/orchestration/source-profile.ts +101 -101
- package/dist/extensions/pi-web-agent/src/orchestration/stop-decider.ts +81 -81
- package/dist/extensions/pi-web-agent/src/presentation/config-store.ts +210 -210
- package/dist/extensions/pi-web-agent/src/presentation/config.ts +75 -75
- package/dist/extensions/pi-web-agent/src/presentation/explore-presentation.ts +61 -61
- package/dist/extensions/pi-web-agent/src/presentation/fetch-presentation.ts +54 -54
- package/dist/extensions/pi-web-agent/src/presentation/search-presentation.ts +41 -41
- package/dist/extensions/pi-web-agent/src/presentation/select-view.ts +20 -20
- package/dist/extensions/pi-web-agent/src/presentation/types.ts +63 -63
- package/dist/extensions/pi-web-agent/src/search/brave.ts +114 -114
- package/dist/extensions/pi-web-agent/src/search/duckduckgo.ts +72 -72
- package/dist/extensions/pi-web-agent/src/search/searxng.ts +96 -96
- package/dist/extensions/pi-web-agent/src/tools/web-explore.ts +71 -71
- package/dist/extensions/pi-web-agent/src/tools/web-fetch-headless.ts +31 -31
- package/dist/extensions/pi-web-agent/src/tools/web-fetch.ts +31 -31
- package/dist/extensions/pi-web-agent/src/tools/web-search.ts +157 -157
- package/dist/extensions/pi-web-agent/src/types.ts +88 -88
- package/dist/extensions/pi-zentui/extensions/zentui/format.ts +46 -1
- package/dist/extensions/pi-zentui/extensions/zentui/index.ts +10 -0
- package/dist/extensions/pi-zentui/extensions/zentui/user-message-styles.ts +1 -1
- package/dist/extensions/pi-zentui/test/extension-compliance.test.ts +3 -3
- package/dist/extensions/pi-zentui/test/format.test.ts +50 -2
- package/dist/extensions/ponytail/package.json +8 -8
- package/dist/extensions/question/constants.ts +30 -30
- package/dist/extensions/question/helpers.ts +58 -58
- package/dist/extensions/question/navigation.ts +14 -14
- package/dist/extensions/question/package.json +19 -19
- package/dist/extensions/question/selection-mode.ts +46 -46
- package/dist/extensions/question/shortcuts.ts +44 -44
- package/dist/extensions/question/types.ts +132 -132
- package/dist/extensions/test-resolve-hook-impl.mjs +6 -6
- package/dist/extensions/test-resolve-hook.mjs +6 -6
- package/dist/extensions/web-agent-onboarding.ts +222 -222
- package/dist/modes/interactive/interactive-mode.js +17 -3
- package/dist/package-manager-cli.js +71 -71
- package/dist/rpc-entry.js +0 -0
- package/dist/skills/improve-codebase/REFERENCE.md +78 -78
- package/docs/compaction.md +396 -396
- package/docs/containerization.md +111 -111
- package/docs/development.md +71 -71
- package/docs/docs.json +164 -164
- package/docs/environment-variables.md +86 -86
- package/docs/index.md +83 -83
- package/docs/json.md +82 -82
- package/docs/models.md +502 -502
- package/docs/packages.md +227 -227
- package/docs/plans/subagent-delegation/phase-0-correctness.md +264 -264
- package/docs/plans/subagent-delegation/phase-1-behavioral-contract.md +485 -485
- package/docs/plans/subagent-delegation/phase-2-context-controls.md +281 -281
- package/docs/plans/subagent-delegation/phase-3-advisory-routing.md +361 -361
- package/docs/plans/subagent-delegation/phase-4-optional-enforcement.md +380 -380
- package/docs/prompt-templates.md +95 -95
- package/docs/providers.md +293 -293
- package/docs/security.md +59 -59
- package/docs/session-format.md +414 -414
- package/docs/sessions.md +145 -145
- package/docs/shared-host-extensions.md +109 -109
- package/docs/shell-aliases.md +13 -13
- package/docs/skills.md +231 -231
- package/docs/terminal-setup.md +142 -142
- package/docs/termux.md +127 -127
- package/docs/themes.md +295 -295
- package/docs/tmux.md +63 -63
- package/docs/tui.md +927 -927
- package/docs/windows.md +17 -17
- package/examples/README.md +25 -25
- package/examples/extensions/README.md +211 -211
- package/examples/extensions/auto-commit-on-exit.ts +49 -49
- package/examples/extensions/bash-spawn-hook.ts +30 -30
- package/examples/extensions/bookmark.ts +50 -50
- package/examples/extensions/border-status-editor.ts +150 -150
- package/examples/extensions/built-in-tool-renderer.ts +249 -249
- package/examples/extensions/claude-rules.ts +86 -86
- package/examples/extensions/commands.ts +72 -72
- package/examples/extensions/confirm-destructive.ts +59 -59
- package/examples/extensions/custom-compaction.ts +130 -130
- package/examples/extensions/custom-footer.ts +64 -64
- package/examples/extensions/custom-header.ts +73 -73
- package/examples/extensions/custom-provider-anthropic/index.ts +610 -610
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -24
- package/examples/extensions/custom-provider-anthropic/package.json +19 -19
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +404 -404
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -16
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -82
- package/examples/extensions/dirty-repo-guard.ts +56 -56
- package/examples/extensions/doom-overlay/README.md +46 -46
- package/examples/extensions/doom-overlay/doom/build/doom.js +21 -21
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +152 -152
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -72
- package/examples/extensions/doom-overlay/doom-component.ts +132 -132
- package/examples/extensions/doom-overlay/doom-engine.ts +173 -173
- package/examples/extensions/doom-overlay/doom-keys.ts +104 -104
- package/examples/extensions/doom-overlay/index.ts +74 -74
- package/examples/extensions/doom-overlay/wad-finder.ts +51 -51
- package/examples/extensions/dynamic-resources/SKILL.md +8 -8
- package/examples/extensions/dynamic-resources/dynamic.json +79 -79
- package/examples/extensions/dynamic-resources/dynamic.md +5 -5
- package/examples/extensions/dynamic-resources/index.ts +15 -15
- package/examples/extensions/dynamic-tools.ts +74 -74
- package/examples/extensions/event-bus.ts +43 -43
- package/examples/extensions/file-trigger.ts +41 -41
- package/examples/extensions/git-checkpoint.ts +53 -53
- package/examples/extensions/git-merge-and-resolve.ts +115 -115
- package/examples/extensions/github-issue-autocomplete.ts +185 -185
- package/examples/extensions/gondolin/index.ts +531 -531
- package/examples/extensions/gondolin/package-lock.json +185 -185
- package/examples/extensions/gondolin/package.json +19 -19
- package/examples/extensions/handoff.ts +199 -199
- package/examples/extensions/hello.ts +26 -26
- package/examples/extensions/hidden-thinking-label.ts +53 -53
- package/examples/extensions/inline-bash.ts +94 -94
- package/examples/extensions/input-transform-streaming.ts +39 -39
- package/examples/extensions/input-transform.ts +43 -43
- package/examples/extensions/interactive-shell.ts +196 -196
- package/examples/extensions/mac-system-theme.ts +47 -47
- package/examples/extensions/message-renderer.ts +59 -59
- package/examples/extensions/minimal-mode.ts +426 -426
- package/examples/extensions/modal-editor.ts +85 -85
- package/examples/extensions/model-status.ts +31 -31
- package/examples/extensions/notify.ts +55 -55
- package/examples/extensions/overlay-qa-tests.ts +1450 -1450
- package/examples/extensions/overlay-test.ts +153 -153
- package/examples/extensions/permission-gate.ts +34 -34
- package/examples/extensions/pirate.ts +47 -47
- package/examples/extensions/plan-mode/README.md +66 -66
- package/examples/extensions/plan-mode/index.ts +390 -390
- package/examples/extensions/plan-mode/utils.ts +168 -168
- package/examples/extensions/preset.ts +436 -436
- package/examples/extensions/project-trust.ts +64 -64
- package/examples/extensions/prompt-customizer.ts +97 -97
- package/examples/extensions/protected-paths.ts +30 -30
- package/examples/extensions/provider-payload.ts +18 -18
- package/examples/extensions/qna.ts +122 -122
- package/examples/extensions/question.ts +285 -285
- package/examples/extensions/questionnaire.ts +448 -448
- package/examples/extensions/rainbow-editor.ts +88 -88
- package/examples/extensions/reload-runtime.ts +37 -37
- package/examples/extensions/rpc-demo.ts +118 -118
- package/examples/extensions/sandbox/index.ts +321 -321
- package/examples/extensions/sandbox/package-lock.json +92 -92
- package/examples/extensions/sandbox/package.json +19 -19
- package/examples/extensions/send-user-message.ts +97 -97
- package/examples/extensions/session-name.ts +27 -27
- package/examples/extensions/shutdown-command.ts +63 -63
- package/examples/extensions/snake.ts +343 -343
- package/examples/extensions/space-invaders.ts +560 -560
- package/examples/extensions/ssh.ts +220 -220
- package/examples/extensions/status-line.ts +32 -32
- package/examples/extensions/structured-output.ts +65 -65
- package/examples/extensions/subagent/README.md +175 -175
- package/examples/extensions/subagent/agents/planner.md +37 -37
- package/examples/extensions/subagent/agents/reviewer.md +35 -35
- package/examples/extensions/subagent/agents/scout.md +50 -50
- package/examples/extensions/subagent/agents/worker.md +24 -24
- package/examples/extensions/subagent/agents.ts +126 -126
- package/examples/extensions/subagent/index.ts +1015 -1015
- package/examples/extensions/subagent/prompts/implement-and-review.md +10 -10
- package/examples/extensions/subagent/prompts/implement.md +10 -10
- package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -9
- package/examples/extensions/summarize.ts +209 -209
- package/examples/extensions/system-prompt-header.ts +17 -17
- package/examples/extensions/tic-tac-toe.ts +1008 -1008
- package/examples/extensions/timed-confirm.ts +70 -70
- package/examples/extensions/titlebar-spinner.ts +58 -58
- package/examples/extensions/todo.ts +297 -297
- package/examples/extensions/tool-override.ts +144 -144
- package/examples/extensions/tools.ts +146 -146
- package/examples/extensions/trigger-compact.ts +50 -50
- package/examples/extensions/truncated-tool.ts +195 -195
- package/examples/extensions/widget-placement.ts +9 -9
- package/examples/extensions/with-deps/index.ts +32 -32
- package/examples/extensions/with-deps/package-lock.json +31 -31
- package/examples/extensions/with-deps/package.json +22 -22
- package/examples/extensions/working-indicator.ts +123 -123
- package/examples/extensions/working-message-test.ts +25 -25
- package/examples/rpc-extension-ui.ts +632 -632
- package/examples/sdk/01-minimal.ts +26 -26
- package/examples/sdk/02-custom-model.ts +53 -53
- package/examples/sdk/03-custom-prompt.ts +75 -75
- package/examples/sdk/04-skills.ts +55 -55
- package/examples/sdk/05-tools.ts +48 -48
- package/examples/sdk/06-extensions.ts +99 -99
- package/examples/sdk/07-context-files.ts +47 -47
- package/examples/sdk/08-prompt-templates.ts +51 -51
- package/examples/sdk/09-api-keys-and-oauth.ts +52 -52
- package/examples/sdk/10-settings.ts +53 -53
- package/examples/sdk/11-sessions.ts +52 -52
- package/examples/sdk/12-full-control.ts +79 -79
- package/examples/sdk/13-session-runtime.ts +67 -67
- package/examples/sdk/README.md +144 -144
- package/package.json +3 -3
|
@@ -0,0 +1,630 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import {
|
|
3
|
+
existsSync,
|
|
4
|
+
mkdirSync,
|
|
5
|
+
mkdtempSync,
|
|
6
|
+
readFileSync,
|
|
7
|
+
rmSync,
|
|
8
|
+
statSync,
|
|
9
|
+
writeFileSync,
|
|
10
|
+
} from "node:fs";
|
|
11
|
+
import { tmpdir } from "node:os";
|
|
12
|
+
import { appendFile } from "node:fs/promises";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
import test from "node:test";
|
|
15
|
+
import {
|
|
16
|
+
createToolDisplayDebugLogger,
|
|
17
|
+
type ToolDisplayDebugLoggerOptions,
|
|
18
|
+
} from "../src/debug-logger.ts";
|
|
19
|
+
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
// Helpers
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
|
|
24
|
+
async function withTempRoot(
|
|
25
|
+
run: (root: string) => Promise<void> | void,
|
|
26
|
+
): Promise<void> {
|
|
27
|
+
const root = mkdtempSync(join(tmpdir(), "pi-tool-display-debug-edge-"));
|
|
28
|
+
try {
|
|
29
|
+
await run(root);
|
|
30
|
+
} finally {
|
|
31
|
+
rmSync(root, { recursive: true, force: true });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function loggerOpts(
|
|
36
|
+
root: string,
|
|
37
|
+
overrides: Partial<ToolDisplayDebugLoggerOptions> = {},
|
|
38
|
+
): ToolDisplayDebugLoggerOptions {
|
|
39
|
+
return {
|
|
40
|
+
configFile: join(root, "config.json"),
|
|
41
|
+
debugDir: join(root, "debug"),
|
|
42
|
+
debugLogFile: join(root, "debug", "debug.log"),
|
|
43
|
+
createDate: () => new Date("2026-01-01T00:00:00.000Z"),
|
|
44
|
+
now: () => 1000000,
|
|
45
|
+
...overrides,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function writeConfig(root: string, debug: boolean): void {
|
|
50
|
+
writeFileSync(join(root, "config.json"), JSON.stringify({ debug }), "utf-8");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function readLog(root: string): string {
|
|
54
|
+
const logFile = join(root, "debug", "debug.log");
|
|
55
|
+
assert.ok(existsSync(logFile), "debug.log should exist");
|
|
56
|
+
return readFileSync(logFile, "utf-8");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
// Concurrent Write Queue Behavior
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
|
|
63
|
+
test("concurrent writes are queued and flushed in order", async () => {
|
|
64
|
+
await withTempRoot(async (root) => {
|
|
65
|
+
writeConfig(root, true);
|
|
66
|
+
const logger = createToolDisplayDebugLogger(loggerOpts(root));
|
|
67
|
+
|
|
68
|
+
logger.log("first");
|
|
69
|
+
logger.log("second");
|
|
70
|
+
logger.log("third");
|
|
71
|
+
|
|
72
|
+
await logger.flush();
|
|
73
|
+
|
|
74
|
+
const content = readLog(root);
|
|
75
|
+
const lines = content.trim().split("\n");
|
|
76
|
+
assert.equal(lines.length, 3, "all three lines written");
|
|
77
|
+
assert.match(lines[0]!, /first/);
|
|
78
|
+
assert.match(lines[1]!, /second/);
|
|
79
|
+
assert.match(lines[2]!, /third/);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test("concurrent writes with simulated failures still complete", async () => {
|
|
84
|
+
await withTempRoot(async (root) => {
|
|
85
|
+
writeConfig(root, true);
|
|
86
|
+
let appendCallCount = 0;
|
|
87
|
+
const failingAppend = async (
|
|
88
|
+
_path: string,
|
|
89
|
+
_content: string,
|
|
90
|
+
_enc: string,
|
|
91
|
+
): Promise<void> => {
|
|
92
|
+
appendCallCount++;
|
|
93
|
+
if (appendCallCount === 2) {
|
|
94
|
+
throw new Error("simulated append failure");
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const logger = createToolDisplayDebugLogger(
|
|
99
|
+
loggerOpts(root, {
|
|
100
|
+
fileSystem: {
|
|
101
|
+
existsSync,
|
|
102
|
+
mkdirSync,
|
|
103
|
+
readFileSync,
|
|
104
|
+
statSync: ((p: string) => {
|
|
105
|
+
try {
|
|
106
|
+
return statSync(p);
|
|
107
|
+
} catch {
|
|
108
|
+
throw new Error("ENOENT");
|
|
109
|
+
}
|
|
110
|
+
}) as unknown as typeof statSync,
|
|
111
|
+
appendFile: failingAppend as unknown as typeof appendFile,
|
|
112
|
+
},
|
|
113
|
+
}),
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
logger.log("first ok");
|
|
117
|
+
logger.log("second fails");
|
|
118
|
+
logger.log("third ok");
|
|
119
|
+
|
|
120
|
+
await logger.flush();
|
|
121
|
+
assert.ok(true, "flush completed despite append failures");
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test("flush waits for all queued writes", async () => {
|
|
126
|
+
await withTempRoot(async (root) => {
|
|
127
|
+
writeConfig(root, true);
|
|
128
|
+
|
|
129
|
+
const order: string[] = [];
|
|
130
|
+
const trackingAppend = async (
|
|
131
|
+
_path: string,
|
|
132
|
+
content: string,
|
|
133
|
+
_enc: string,
|
|
134
|
+
): Promise<void> => {
|
|
135
|
+
if (content.includes("slow")) {
|
|
136
|
+
await new Promise((r) => setTimeout(r, 20));
|
|
137
|
+
}
|
|
138
|
+
order.push(content.trim());
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const logger = createToolDisplayDebugLogger(
|
|
142
|
+
loggerOpts(root, {
|
|
143
|
+
fileSystem: {
|
|
144
|
+
existsSync,
|
|
145
|
+
mkdirSync,
|
|
146
|
+
readFileSync,
|
|
147
|
+
statSync: ((p: string) => {
|
|
148
|
+
try {
|
|
149
|
+
return statSync(p);
|
|
150
|
+
} catch {
|
|
151
|
+
throw new Error("ENOENT");
|
|
152
|
+
}
|
|
153
|
+
}) as unknown as typeof statSync,
|
|
154
|
+
appendFile: trackingAppend as unknown as typeof appendFile,
|
|
155
|
+
},
|
|
156
|
+
}),
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
logger.log("fast");
|
|
160
|
+
logger.log("slow");
|
|
161
|
+
logger.log("fast2");
|
|
162
|
+
|
|
163
|
+
await logger.flush();
|
|
164
|
+
|
|
165
|
+
assert.ok(order.some((l) => l.includes("fast")), "fast logged");
|
|
166
|
+
assert.ok(order.some((l) => l.includes("slow")), "slow logged");
|
|
167
|
+
assert.ok(order.some((l) => l.includes("fast2")), "fast2 logged");
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// ---------------------------------------------------------------------------
|
|
172
|
+
// Redaction Patterns
|
|
173
|
+
// ---------------------------------------------------------------------------
|
|
174
|
+
|
|
175
|
+
test("redaction masks API-key-style tokens in messages", async () => {
|
|
176
|
+
await withTempRoot(async (root) => {
|
|
177
|
+
writeConfig(root, true);
|
|
178
|
+
const logger = createToolDisplayDebugLogger(loggerOpts(root));
|
|
179
|
+
|
|
180
|
+
// The SECRET_VALUE_PATTERN matches sk-[A-Za-z0-9_-]{12,}
|
|
181
|
+
// We need exactly the pattern threshold to trigger redaction.
|
|
182
|
+
logger.log("key sk-abcdefghijklmnop");
|
|
183
|
+
await logger.flush();
|
|
184
|
+
|
|
185
|
+
const content = readLog(root);
|
|
186
|
+
assert.doesNotMatch(content, /sk-abcdefghijklmnop/);
|
|
187
|
+
assert.match(content, /\[REDACTED\]/);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
test("redaction masks JWT-style token patterns in messages", async () => {
|
|
192
|
+
await withTempRoot(async (root) => {
|
|
193
|
+
writeConfig(root, true);
|
|
194
|
+
const logger = createToolDisplayDebugLogger(loggerOpts(root));
|
|
195
|
+
|
|
196
|
+
// Pattern matches groups of 24+ . 6+ . 12+ alphanum chars
|
|
197
|
+
logger.log("jwt TOKEN_STR=aabbccddeeffgghhiijjkkll.aabbcc.1234567890ab");
|
|
198
|
+
await logger.flush();
|
|
199
|
+
|
|
200
|
+
const content = readLog(root);
|
|
201
|
+
assert.doesNotMatch(
|
|
202
|
+
content,
|
|
203
|
+
/aabbccddeeffgghhiijjkkll\.aabbcc\.1234567890ab/,
|
|
204
|
+
);
|
|
205
|
+
assert.match(content, /\[REDACTED\]/);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
test("redaction does not match non-secret IDs that lack secret patterns", async () => {
|
|
210
|
+
await withTempRoot(async (root) => {
|
|
211
|
+
writeConfig(root, true);
|
|
212
|
+
const logger = createToolDisplayDebugLogger(loggerOpts(root));
|
|
213
|
+
|
|
214
|
+
// Short sk- pattern (< 12 chars after prefix) should NOT be redacted
|
|
215
|
+
// Hex commit hashes without sk- prefix should NOT be redacted
|
|
216
|
+
// Session IDs should NOT be redacted
|
|
217
|
+
logger.log("session: abc-123 def-456");
|
|
218
|
+
logger.log("hash: a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0");
|
|
219
|
+
logger.log("short-key: sk-short");
|
|
220
|
+
await logger.flush();
|
|
221
|
+
|
|
222
|
+
const content = readLog(root);
|
|
223
|
+
assert.match(content, /abc-123 def-456/);
|
|
224
|
+
assert.match(content, /a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0/);
|
|
225
|
+
assert.match(content, /short-key: sk-short/);
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
test("redaction handles tokens with hyphens and underscores in body", async () => {
|
|
230
|
+
await withTempRoot(async (root) => {
|
|
231
|
+
writeConfig(root, true);
|
|
232
|
+
const logger = createToolDisplayDebugLogger(loggerOpts(root));
|
|
233
|
+
|
|
234
|
+
// JWT body with hyphen/underscore should still match [A-Za-z0-9_-]
|
|
235
|
+
logger.log("token: aabbccddeeffgghhiijjkkll.abc-def_ghi.1234567890ab");
|
|
236
|
+
await logger.flush();
|
|
237
|
+
|
|
238
|
+
const content = readLog(root);
|
|
239
|
+
assert.doesNotMatch(content, /abc-def_ghi\.1234567890ab/);
|
|
240
|
+
assert.match(content, /\[REDACTED\]/);
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
// ---------------------------------------------------------------------------
|
|
245
|
+
// Config File Fingerprint Caching
|
|
246
|
+
// ---------------------------------------------------------------------------
|
|
247
|
+
|
|
248
|
+
test("fingerprint cache avoids re-reading config within TTL", async () => {
|
|
249
|
+
await withTempRoot(async (root) => {
|
|
250
|
+
let readCount = 0;
|
|
251
|
+
const trackingReadFileSync = (path: string, enc: string): string => {
|
|
252
|
+
readCount++;
|
|
253
|
+
return readFileSync(path, enc as BufferEncoding);
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
writeConfig(root, true);
|
|
257
|
+
|
|
258
|
+
const logger = createToolDisplayDebugLogger(
|
|
259
|
+
loggerOpts(root, {
|
|
260
|
+
now: () => 1000000,
|
|
261
|
+
fileSystem: {
|
|
262
|
+
existsSync,
|
|
263
|
+
mkdirSync,
|
|
264
|
+
readFileSync: trackingReadFileSync as unknown as typeof readFileSync,
|
|
265
|
+
statSync: ((p: string) => {
|
|
266
|
+
try {
|
|
267
|
+
return statSync(p);
|
|
268
|
+
} catch {
|
|
269
|
+
throw new Error("ENOENT");
|
|
270
|
+
}
|
|
271
|
+
}) as unknown as typeof statSync,
|
|
272
|
+
appendFile: async () => {},
|
|
273
|
+
},
|
|
274
|
+
}),
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
logger.log("first");
|
|
278
|
+
const readsAfterFirst = readCount;
|
|
279
|
+
assert.equal(readsAfterFirst >= 1, true, "config read at least once on first log");
|
|
280
|
+
|
|
281
|
+
logger.log("second");
|
|
282
|
+
assert.equal(readCount, readsAfterFirst, "no additional read within TTL");
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
test("fingerprint cache re-reads config for a newly created logger after file change", async () => {
|
|
287
|
+
await withTempRoot(async (root) => {
|
|
288
|
+
// Use a real-time logger to verify config change detection
|
|
289
|
+
writeConfig(root, false);
|
|
290
|
+
|
|
291
|
+
const logger = createToolDisplayDebugLogger(
|
|
292
|
+
loggerOpts(root, { cacheTtlMs: 30, now: () => Date.now() }),
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
logger.log("first-msg");
|
|
296
|
+
await logger.flush();
|
|
297
|
+
|
|
298
|
+
// No log file should exist while debug is disabled
|
|
299
|
+
assert.equal(
|
|
300
|
+
existsSync(join(root, "debug", "debug.log")),
|
|
301
|
+
false,
|
|
302
|
+
"no log while disabled",
|
|
303
|
+
);
|
|
304
|
+
|
|
305
|
+
// Enable debug and wait for TTL to pass
|
|
306
|
+
writeFileSync(
|
|
307
|
+
join(root, "config.json"),
|
|
308
|
+
JSON.stringify({ debug: true }),
|
|
309
|
+
"utf-8",
|
|
310
|
+
);
|
|
311
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
312
|
+
|
|
313
|
+
logger.log("after-enable");
|
|
314
|
+
await logger.flush();
|
|
315
|
+
|
|
316
|
+
assert.ok(
|
|
317
|
+
existsSync(join(root, "debug", "debug.log")),
|
|
318
|
+
"log created after enabling",
|
|
319
|
+
);
|
|
320
|
+
const content = readLog(root);
|
|
321
|
+
assert.match(content, /after-enable/, "after-enable message appears");
|
|
322
|
+
assert.doesNotMatch(content, /first-msg/, "first message not logged when disabled");
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
// ---------------------------------------------------------------------------
|
|
327
|
+
// Debug Directory Creation Timing
|
|
328
|
+
// ---------------------------------------------------------------------------
|
|
329
|
+
|
|
330
|
+
test("debug directory is created only on first enabled write", async () => {
|
|
331
|
+
await withTempRoot(async (root) => {
|
|
332
|
+
writeConfig(root, true);
|
|
333
|
+
|
|
334
|
+
const logger = createToolDisplayDebugLogger(
|
|
335
|
+
loggerOpts(root, { now: () => 1000000 }),
|
|
336
|
+
);
|
|
337
|
+
|
|
338
|
+
assert.equal(
|
|
339
|
+
existsSync(join(root, "debug")),
|
|
340
|
+
false,
|
|
341
|
+
"dir not yet created before first write",
|
|
342
|
+
);
|
|
343
|
+
logger.log("first enabled write");
|
|
344
|
+
await logger.flush();
|
|
345
|
+
|
|
346
|
+
assert.ok(existsSync(join(root, "debug")), "debug dir created on write");
|
|
347
|
+
assert.ok(existsSync(join(root, "debug", "debug.log")), "debug.log created");
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
test("disabled logger does not create debug directory", async () => {
|
|
352
|
+
await withTempRoot(async (root) => {
|
|
353
|
+
writeConfig(root, false);
|
|
354
|
+
|
|
355
|
+
const logger = createToolDisplayDebugLogger(
|
|
356
|
+
loggerOpts(root, { now: () => 1000000 }),
|
|
357
|
+
);
|
|
358
|
+
|
|
359
|
+
logger.log("disabled message");
|
|
360
|
+
await logger.flush();
|
|
361
|
+
|
|
362
|
+
assert.equal(
|
|
363
|
+
existsSync(join(root, "debug")),
|
|
364
|
+
false,
|
|
365
|
+
"no debug dir when disabled",
|
|
366
|
+
);
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
// ---------------------------------------------------------------------------
|
|
371
|
+
// Swallowed Logging Errors
|
|
372
|
+
// ---------------------------------------------------------------------------
|
|
373
|
+
|
|
374
|
+
test("logger swallows errors when config file is unreadable", async () => {
|
|
375
|
+
await withTempRoot(async (root) => {
|
|
376
|
+
writeFileSync(join(root, "config.json"), "not-valid-json", "utf-8");
|
|
377
|
+
|
|
378
|
+
const logger = createToolDisplayDebugLogger(
|
|
379
|
+
loggerOpts(root, { now: () => 1000000 }),
|
|
380
|
+
);
|
|
381
|
+
|
|
382
|
+
assert.doesNotThrow(() => logger.log("after bad config"));
|
|
383
|
+
await assert.doesNotReject(() => logger.flush());
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
test("logger swallows errors when config file is missing", async () => {
|
|
388
|
+
await withTempRoot(async (root) => {
|
|
389
|
+
const logger = createToolDisplayDebugLogger(
|
|
390
|
+
loggerOpts(root, { now: () => 1000000 }),
|
|
391
|
+
);
|
|
392
|
+
|
|
393
|
+
assert.doesNotThrow(() => logger.log("no config file"));
|
|
394
|
+
await assert.doesNotReject(() => logger.flush());
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
test("logger swallows directory creation errors", async () => {
|
|
399
|
+
await withTempRoot(async (root) => {
|
|
400
|
+
writeConfig(root, true);
|
|
401
|
+
|
|
402
|
+
// Block the debug directory with a regular file
|
|
403
|
+
writeFileSync(join(root, "debug"), "blocking file", "utf-8");
|
|
404
|
+
|
|
405
|
+
const logger = createToolDisplayDebugLogger(
|
|
406
|
+
loggerOpts(root, { now: () => 1000000 }),
|
|
407
|
+
);
|
|
408
|
+
|
|
409
|
+
assert.doesNotThrow(() => logger.log("after blocked mkdir"));
|
|
410
|
+
await assert.doesNotReject(() => logger.flush());
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
test("logger swallows individual append failures without crashing", async () => {
|
|
415
|
+
await withTempRoot(async (root) => {
|
|
416
|
+
writeConfig(root, true);
|
|
417
|
+
|
|
418
|
+
let failNext = false;
|
|
419
|
+
const flakyAppend = async (
|
|
420
|
+
_path: string,
|
|
421
|
+
_content: string,
|
|
422
|
+
_enc: string,
|
|
423
|
+
): Promise<void> => {
|
|
424
|
+
if (failNext) {
|
|
425
|
+
failNext = false;
|
|
426
|
+
throw new Error("flaky error");
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
const logger = createToolDisplayDebugLogger(
|
|
431
|
+
loggerOpts(root, {
|
|
432
|
+
now: () => 1000000,
|
|
433
|
+
fileSystem: {
|
|
434
|
+
existsSync,
|
|
435
|
+
mkdirSync,
|
|
436
|
+
readFileSync,
|
|
437
|
+
statSync: ((p: string) => {
|
|
438
|
+
try {
|
|
439
|
+
return statSync(p);
|
|
440
|
+
} catch {
|
|
441
|
+
throw new Error("ENOENT");
|
|
442
|
+
}
|
|
443
|
+
}) as unknown as typeof statSync,
|
|
444
|
+
appendFile: flakyAppend as unknown as typeof appendFile,
|
|
445
|
+
},
|
|
446
|
+
}),
|
|
447
|
+
);
|
|
448
|
+
|
|
449
|
+
failNext = true;
|
|
450
|
+
logger.log("this will fail");
|
|
451
|
+
await logger.flush();
|
|
452
|
+
|
|
453
|
+
logger.log("this should succeed");
|
|
454
|
+
await logger.flush();
|
|
455
|
+
|
|
456
|
+
assert.ok(true, "logging errors swallowed without crashing logger");
|
|
457
|
+
});
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
// ---------------------------------------------------------------------------
|
|
461
|
+
// Log File Append Behavior
|
|
462
|
+
// ---------------------------------------------------------------------------
|
|
463
|
+
|
|
464
|
+
test("multiple writes append to the same log file", async () => {
|
|
465
|
+
await withTempRoot(async (root) => {
|
|
466
|
+
writeConfig(root, true);
|
|
467
|
+
const logger = createToolDisplayDebugLogger(
|
|
468
|
+
loggerOpts(root, { now: () => 1000000 }),
|
|
469
|
+
);
|
|
470
|
+
|
|
471
|
+
logger.log("entry-a");
|
|
472
|
+
logger.log("entry-b");
|
|
473
|
+
logger.log("entry-c");
|
|
474
|
+
await logger.flush();
|
|
475
|
+
|
|
476
|
+
const content = readLog(root);
|
|
477
|
+
const lines = content.trim().split("\n");
|
|
478
|
+
assert.equal(lines.length, 3, "three entries appended");
|
|
479
|
+
assert.match(lines[0]!, /entry-a/);
|
|
480
|
+
assert.match(lines[1]!, /entry-b/);
|
|
481
|
+
assert.match(lines[2]!, /entry-c/);
|
|
482
|
+
});
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
test("log lines include ISO timestamp prefix", async () => {
|
|
486
|
+
await withTempRoot(async (root) => {
|
|
487
|
+
writeConfig(root, true);
|
|
488
|
+
const logger = createToolDisplayDebugLogger(loggerOpts(root));
|
|
489
|
+
|
|
490
|
+
logger.log("timed entry");
|
|
491
|
+
await logger.flush();
|
|
492
|
+
|
|
493
|
+
const content = readLog(root);
|
|
494
|
+
assert.match(
|
|
495
|
+
content,
|
|
496
|
+
/^2026-01-01T00:00:00\.000Z /,
|
|
497
|
+
"line starts with ISO timestamp",
|
|
498
|
+
);
|
|
499
|
+
});
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
test("log lines include error details after the message", async () => {
|
|
503
|
+
await withTempRoot(async (root) => {
|
|
504
|
+
writeConfig(root, true);
|
|
505
|
+
const logger = createToolDisplayDebugLogger(loggerOpts(root));
|
|
506
|
+
|
|
507
|
+
logger.log("operation", new Error("something broke"));
|
|
508
|
+
await logger.flush();
|
|
509
|
+
|
|
510
|
+
const content = readLog(root);
|
|
511
|
+
assert.match(content, /operation/);
|
|
512
|
+
assert.match(content, /Error: something broke/);
|
|
513
|
+
});
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
// ---------------------------------------------------------------------------
|
|
517
|
+
// Config Change After Logger Creation
|
|
518
|
+
// ---------------------------------------------------------------------------
|
|
519
|
+
|
|
520
|
+
test("logger picks up config from disabled to enabled after cache expiry", async () => {
|
|
521
|
+
await withTempRoot(async (root) => {
|
|
522
|
+
writeConfig(root, false);
|
|
523
|
+
|
|
524
|
+
const ttlMs = 40;
|
|
525
|
+
const logger = createToolDisplayDebugLogger(
|
|
526
|
+
loggerOpts(root, {
|
|
527
|
+
cacheTtlMs: ttlMs,
|
|
528
|
+
now: () => Date.now(),
|
|
529
|
+
}),
|
|
530
|
+
);
|
|
531
|
+
|
|
532
|
+
logger.log("disabled-message");
|
|
533
|
+
await logger.flush();
|
|
534
|
+
assert.equal(
|
|
535
|
+
existsSync(join(root, "debug")),
|
|
536
|
+
false,
|
|
537
|
+
"no debug dir while disabled",
|
|
538
|
+
);
|
|
539
|
+
|
|
540
|
+
// Switch to enabled
|
|
541
|
+
writeFileSync(join(root, "config.json"), JSON.stringify({ debug: true }), "utf-8");
|
|
542
|
+
|
|
543
|
+
// Wait for cache TTL and file system settle
|
|
544
|
+
await new Promise((r) => setTimeout(r, ttlMs * 2 + 50));
|
|
545
|
+
|
|
546
|
+
logger.log("enabled-message");
|
|
547
|
+
await logger.flush();
|
|
548
|
+
|
|
549
|
+
assert.ok(
|
|
550
|
+
existsSync(join(root, "debug", "debug.log")),
|
|
551
|
+
"log file created after enabling",
|
|
552
|
+
);
|
|
553
|
+
const content = readLog(root);
|
|
554
|
+
assert.match(content, /enabled-message/, "enabled message appears");
|
|
555
|
+
assert.doesNotMatch(content, /disabled-message/, "disabled message not in log");
|
|
556
|
+
});
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
test("logger picks up config from enabled to disabled", async () => {
|
|
560
|
+
await withTempRoot(async (root) => {
|
|
561
|
+
writeConfig(root, true);
|
|
562
|
+
|
|
563
|
+
const ttlMs = 40;
|
|
564
|
+
const logger = createToolDisplayDebugLogger(
|
|
565
|
+
loggerOpts(root, {
|
|
566
|
+
cacheTtlMs: ttlMs,
|
|
567
|
+
now: () => Date.now(),
|
|
568
|
+
}),
|
|
569
|
+
);
|
|
570
|
+
|
|
571
|
+
logger.log("before-disable");
|
|
572
|
+
await logger.flush();
|
|
573
|
+
assert.ok(
|
|
574
|
+
existsSync(join(root, "debug", "debug.log")),
|
|
575
|
+
"log exists while enabled",
|
|
576
|
+
);
|
|
577
|
+
|
|
578
|
+
writeFileSync(join(root, "config.json"), JSON.stringify({ debug: false }), "utf-8");
|
|
579
|
+
|
|
580
|
+
await new Promise((r) => setTimeout(r, ttlMs * 2 + 50));
|
|
581
|
+
|
|
582
|
+
logger.log("after-disable");
|
|
583
|
+
await logger.flush();
|
|
584
|
+
|
|
585
|
+
const content = readLog(root);
|
|
586
|
+
assert.match(content, /before-disable/, "before-disable message present");
|
|
587
|
+
assert.doesNotMatch(
|
|
588
|
+
content,
|
|
589
|
+
/after-disable/,
|
|
590
|
+
"after-disable message not logged",
|
|
591
|
+
);
|
|
592
|
+
});
|
|
593
|
+
});
|
|
594
|
+
|
|
595
|
+
// ---------------------------------------------------------------------------
|
|
596
|
+
// Error Redaction in Error Objects
|
|
597
|
+
// ---------------------------------------------------------------------------
|
|
598
|
+
|
|
599
|
+
test("error messages containing secrets are redacted", async () => {
|
|
600
|
+
await withTempRoot(async (root) => {
|
|
601
|
+
writeConfig(root, true);
|
|
602
|
+
const logger = createToolDisplayDebugLogger(loggerOpts(root));
|
|
603
|
+
|
|
604
|
+
// The secret value pattern matches sk-[A-Za-z0-9_-]{12,}
|
|
605
|
+
const secretKey = "sk-" + "a".repeat(14) + "b".repeat(8);
|
|
606
|
+
logger.log("auth failed", new Error("invalid key " + secretKey));
|
|
607
|
+
await logger.flush();
|
|
608
|
+
|
|
609
|
+
const content = readLog(root);
|
|
610
|
+
assert.doesNotMatch(content, new RegExp(secretKey.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")));
|
|
611
|
+
assert.match(content, /\[REDACTED\]/);
|
|
612
|
+
});
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
test("non-Error error arguments are converted to string", async () => {
|
|
616
|
+
await withTempRoot(async (root) => {
|
|
617
|
+
writeConfig(root, true);
|
|
618
|
+
const logger = createToolDisplayDebugLogger(loggerOpts(root));
|
|
619
|
+
|
|
620
|
+
logger.log("string error", "just a string");
|
|
621
|
+
logger.log("number error", 42);
|
|
622
|
+
logger.log("object error", { code: 500 });
|
|
623
|
+
await logger.flush();
|
|
624
|
+
|
|
625
|
+
const content = readLog(root);
|
|
626
|
+
assert.match(content, /just a string/);
|
|
627
|
+
assert.match(content, /42/);
|
|
628
|
+
assert.match(content, /\[object Object\]/);
|
|
629
|
+
});
|
|
630
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import test from "node:test";
|
|
6
|
+
import { createToolDisplayDebugLogger } from "../src/debug-logger.ts";
|
|
7
|
+
|
|
8
|
+
async function withTempRoot(run: (root: string) => Promise<void> | void): Promise<void> {
|
|
9
|
+
const root = mkdtempSync(join(tmpdir(), "pi-tool-display-debug-"));
|
|
10
|
+
try {
|
|
11
|
+
await run(root);
|
|
12
|
+
} finally {
|
|
13
|
+
rmSync(root, { recursive: true, force: true });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function createLogger(root: string) {
|
|
18
|
+
return createToolDisplayDebugLogger({
|
|
19
|
+
configFile: join(root, "config.json"),
|
|
20
|
+
debugDir: join(root, "debug"),
|
|
21
|
+
debugLogFile: join(root, "debug", "debug.log"),
|
|
22
|
+
createDate: () => new Date("2026-01-01T00:00:00.000Z"),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
test("disabled debug logger is a no-op and does not create debug artifacts", async () => {
|
|
27
|
+
await withTempRoot(async (root) => {
|
|
28
|
+
writeFileSync(join(root, "config.json"), JSON.stringify({ debug: false }), "utf-8");
|
|
29
|
+
const logger = createLogger(root);
|
|
30
|
+
|
|
31
|
+
assert.equal(logger.log("disabled sk-abcdefghijkl", new Error("hidden sk-bcdefghijklm")), undefined);
|
|
32
|
+
await logger.flush();
|
|
33
|
+
|
|
34
|
+
assert.equal(existsSync(join(root, "debug")), false);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test("enabled debug logger writes on flush and redacts secret values", async () => {
|
|
39
|
+
await withTempRoot(async (root) => {
|
|
40
|
+
writeFileSync(join(root, "config.json"), JSON.stringify({ debug: true }), "utf-8");
|
|
41
|
+
const logger = createLogger(root);
|
|
42
|
+
|
|
43
|
+
assert.equal(logger.log("request sk-abcdefghijkl", new Error("failed sk-bcdefghijklm")), undefined);
|
|
44
|
+
await logger.flush();
|
|
45
|
+
|
|
46
|
+
const logContent = readFileSync(join(root, "debug", "debug.log"), "utf-8");
|
|
47
|
+
assert.match(logContent, /^2026-01-01T00:00:00\.000Z request \[REDACTED\] Error: failed \[REDACTED\]/);
|
|
48
|
+
assert.doesNotMatch(logContent, /sk-abcdefghijkl|sk-bcdefghijklm/);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("debug logger swallows append failures", async () => {
|
|
53
|
+
await withTempRoot(async (root) => {
|
|
54
|
+
writeFileSync(join(root, "config.json"), JSON.stringify({ debug: true }), "utf-8");
|
|
55
|
+
mkdirSync(join(root, "debug"), { recursive: true });
|
|
56
|
+
mkdirSync(join(root, "debug", "debug.log"));
|
|
57
|
+
const logger = createLogger(root);
|
|
58
|
+
|
|
59
|
+
assert.doesNotThrow(() => logger.log("write-fails"));
|
|
60
|
+
await assert.doesNotReject(() => logger.flush());
|
|
61
|
+
});
|
|
62
|
+
});
|