pi-usereq 0.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/.g.conf +20 -0
- package/.github/workflows/release-npm.yml +131 -0
- package/.gitignore +270 -0
- package/CHANGELOG.md +221 -0
- package/LICENSE +674 -0
- package/README.md +260 -0
- package/TODO.md +20 -0
- package/docs/pi.dev/agent-document-manifest.json +6399 -0
- package/docs/pi.dev/coding-agent-docs/compaction.md +394 -0
- package/docs/pi.dev/coding-agent-docs/custom-provider.md +596 -0
- package/docs/pi.dev/coding-agent-docs/development.md +71 -0
- package/docs/pi.dev/coding-agent-docs/extensions.md +2262 -0
- package/docs/pi.dev/coding-agent-docs/images/doom-extension.png +0 -0
- package/docs/pi.dev/coding-agent-docs/images/exy.png +0 -0
- package/docs/pi.dev/coding-agent-docs/images/interactive-mode.png +0 -0
- package/docs/pi.dev/coding-agent-docs/images/tree-view.png +0 -0
- package/docs/pi.dev/coding-agent-docs/json.md +82 -0
- package/docs/pi.dev/coding-agent-docs/keybindings.md +175 -0
- package/docs/pi.dev/coding-agent-docs/models.md +392 -0
- package/docs/pi.dev/coding-agent-docs/packages.md +218 -0
- package/docs/pi.dev/coding-agent-docs/prompt-templates.md +67 -0
- package/docs/pi.dev/coding-agent-docs/providers.md +195 -0
- package/docs/pi.dev/coding-agent-docs/rpc.md +1377 -0
- package/docs/pi.dev/coding-agent-docs/sdk.md +1124 -0
- package/docs/pi.dev/coding-agent-docs/session.md +412 -0
- package/docs/pi.dev/coding-agent-docs/settings.md +247 -0
- package/docs/pi.dev/coding-agent-docs/shell-aliases.md +13 -0
- package/docs/pi.dev/coding-agent-docs/skills.md +232 -0
- package/docs/pi.dev/coding-agent-docs/terminal-setup.md +106 -0
- package/docs/pi.dev/coding-agent-docs/termux.md +127 -0
- package/docs/pi.dev/coding-agent-docs/themes.md +295 -0
- package/docs/pi.dev/coding-agent-docs/tmux.md +61 -0
- package/docs/pi.dev/coding-agent-docs/tree.md +231 -0
- package/docs/pi.dev/coding-agent-docs/tui.md +887 -0
- package/docs/pi.dev/coding-agent-docs/windows.md +17 -0
- package/docs/pi.dev/mom-docs/artifacts-server.md +475 -0
- package/docs/pi.dev/mom-docs/events.md +307 -0
- package/docs/pi.dev/mom-docs/new.md +970 -0
- package/docs/pi.dev/mom-docs/sandbox.md +153 -0
- package/docs/pi.dev/mom-docs/slack-bot-minimal-guide.md +399 -0
- package/docs/pi.dev/mom-docs/v86.md +319 -0
- package/docs/pi.dev/pods-docs/gml-4.5.md +189 -0
- package/docs/pi.dev/pods-docs/gpt-oss.md +233 -0
- package/docs/pi.dev/pods-docs/implementation-plan.md +183 -0
- package/docs/pi.dev/pods-docs/kimi-k2.md +197 -0
- package/docs/pi.dev/pods-docs/models.md +116 -0
- package/docs/pi.dev/pods-docs/plan.md +166 -0
- package/docs/pi.dev/pods-docs/qwen3-coder.md +132 -0
- package/images/flowchart-bw.png +0 -0
- package/images/flowchart-bw.svg +102 -0
- package/images/flowchart.md +100 -0
- package/images/flowchart.png +0 -0
- package/images/flowchart.svg +3 -0
- package/package.json +46 -0
- package/req/docs/REFERENCES.md +4554 -0
- package/req/docs/REQUIREMENTS.md +475 -0
- package/req/docs/WORKFLOW.md +1059 -0
- package/scripts/debug-extension.ts +497 -0
- package/scripts/lib/extension-debug-harness.ts +450 -0
- package/scripts/lib/recording-extension-api.ts +786 -0
- package/scripts/lib/sdk-smoke.ts +503 -0
- package/scripts/pi-usereq-debug.sh +330 -0
- package/scripts/tool-args-to-params.ts +208 -0
- package/src/cli.ts +349 -0
- package/src/core/agent-tool-json.ts +621 -0
- package/src/core/compress-files.ts +72 -0
- package/src/core/compress-payload.ts +648 -0
- package/src/core/compress.ts +464 -0
- package/src/core/config.ts +272 -0
- package/src/core/doxygen-parser.ts +318 -0
- package/src/core/errors.ts +31 -0
- package/src/core/extension-status.ts +660 -0
- package/src/core/find-constructs.ts +319 -0
- package/src/core/find-payload.ts +915 -0
- package/src/core/generate-markdown.ts +120 -0
- package/src/core/path-context.ts +196 -0
- package/src/core/pi-notify.ts +430 -0
- package/src/core/pi-usereq-tools.ts +140 -0
- package/src/core/prompts.ts +184 -0
- package/src/core/reference-payload.ts +818 -0
- package/src/core/resources.ts +63 -0
- package/src/core/runtime-project-paths.ts +99 -0
- package/src/core/settings-menu.ts +233 -0
- package/src/core/source-analyzer.ts +1721 -0
- package/src/core/static-check.ts +674 -0
- package/src/core/token-counter.ts +729 -0
- package/src/core/tool-runner.ts +717 -0
- package/src/core/utils.ts +185 -0
- package/src/index.ts +2209 -0
- package/src/resources/guidelines/Google_C++_Style_Guide.md +3711 -0
- package/src/resources/guidelines/Google_Python_Style_Guide.md +3709 -0
- package/src/resources/prompts/analyze.md +130 -0
- package/src/resources/prompts/change.md +227 -0
- package/src/resources/prompts/check.md +139 -0
- package/src/resources/prompts/cover.md +219 -0
- package/src/resources/prompts/create.md +104 -0
- package/src/resources/prompts/fix.md +221 -0
- package/src/resources/prompts/flowchart.md +220 -0
- package/src/resources/prompts/implement.md +163 -0
- package/src/resources/prompts/new.md +226 -0
- package/src/resources/prompts/readme.md +182 -0
- package/src/resources/prompts/recreate.md +213 -0
- package/src/resources/prompts/refactor.md +213 -0
- package/src/resources/prompts/references.md +100 -0
- package/src/resources/prompts/renumber.md +119 -0
- package/src/resources/prompts/workflow.md +202 -0
- package/src/resources/prompts/write.md +99 -0
- package/src/resources/sounds/Machine-alert-beep-sound-effect.mp3 +0 -0
- package/src/resources/sounds/Soft-high-tech-notification-sound-effect.mp3 +0 -0
- package/src/resources/templates/Document_Source_Code_in_Doxygen_Style.md +130 -0
- package/src/resources/templates/HDT_Test_Authoring_Guide.md +318 -0
- package/src/resources/templates/Requirements_Template.md +78 -0
- package/tests/attended-results-scenarios.ts +758 -0
- package/tests/attended-results.test.ts +39 -0
- package/tests/cli-command-option-parity.test.ts +815 -0
- package/tests/debug-extension-harness.test.ts +463 -0
- package/tests/extension-registration.test.ts +2006 -0
- package/tests/fixtures/fixture_c.c +361 -0
- package/tests/fixtures/fixture_cpp.cpp +407 -0
- package/tests/fixtures/fixture_csharp.cs +411 -0
- package/tests/fixtures/fixture_elixir.ex +409 -0
- package/tests/fixtures/fixture_go.go +341 -0
- package/tests/fixtures/fixture_haskell.hs +250 -0
- package/tests/fixtures/fixture_java.java +430 -0
- package/tests/fixtures/fixture_javascript.js +383 -0
- package/tests/fixtures/fixture_kotlin.kt +451 -0
- package/tests/fixtures/fixture_lua.lua +276 -0
- package/tests/fixtures/fixture_perl.pl +310 -0
- package/tests/fixtures/fixture_php.php +433 -0
- package/tests/fixtures/fixture_python.py +502 -0
- package/tests/fixtures/fixture_ruby.rb +345 -0
- package/tests/fixtures/fixture_rust.rs +380 -0
- package/tests/fixtures/fixture_scala.scala +398 -0
- package/tests/fixtures/fixture_shell.sh +276 -0
- package/tests/fixtures/fixture_swift.swift +397 -0
- package/tests/fixtures/fixture_typescript.ts +434 -0
- package/tests/fixtures/fixture_zig.zig +295 -0
- package/tests/fixtures_attended_results/project/compress-line-numbers.json +5 -0
- package/tests/fixtures_attended_results/project/compress.json +5 -0
- package/tests/fixtures_attended_results/project/enable-static-check-invalid-command.json +5 -0
- package/tests/fixtures_attended_results/project/enable-static-check-valid.json +5 -0
- package/tests/fixtures_attended_results/project/files-static-check.json +5 -0
- package/tests/fixtures_attended_results/project/find-line-numbers.json +5 -0
- package/tests/fixtures_attended_results/project/find.json +5 -0
- package/tests/fixtures_attended_results/project/get-base-path.json +5 -0
- package/tests/fixtures_attended_results/project/git-check-clean.json +5 -0
- package/tests/fixtures_attended_results/project/git-check-dirty.json +5 -0
- package/tests/fixtures_attended_results/project/git-path.json +5 -0
- package/tests/fixtures_attended_results/project/git-wt-create-invalid.json +5 -0
- package/tests/fixtures_attended_results/project/git-wt-create-valid.json +5 -0
- package/tests/fixtures_attended_results/project/git-wt-delete-nonexistent.json +5 -0
- package/tests/fixtures_attended_results/project/git-wt-delete-valid.json +5 -0
- package/tests/fixtures_attended_results/project/git-wt-name.json +5 -0
- package/tests/fixtures_attended_results/project/references.json +5 -0
- package/tests/fixtures_attended_results/project/static-check.json +5 -0
- package/tests/fixtures_attended_results/project/tokens.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_c.c.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_cpp.cpp.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_csharp.cs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_elixir.ex.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_go.go.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_haskell.hs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_java.java.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_javascript.js.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_kotlin.kt.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_lua.lua.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_perl.pl.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_php.php.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_python.py.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_ruby.rb.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_rust.rs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_scala.scala.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_shell.sh.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_swift.swift.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_typescript.ts.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_zig.zig.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_c.c.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_cpp.cpp.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_csharp.cs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_elixir.ex.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_go.go.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_haskell.hs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_java.java.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_javascript.js.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_kotlin.kt.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_lua.lua.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_perl.pl.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_php.php.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_python.py.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_ruby.rb.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_rust.rs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_scala.scala.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_shell.sh.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_swift.swift.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_typescript.ts.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_zig.zig.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_c.c.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_cpp.cpp.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_csharp.cs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_elixir.ex.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_go.go.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_haskell.hs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_java.java.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_javascript.js.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_kotlin.kt.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_lua.lua.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_perl.pl.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_php.php.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_python.py.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_ruby.rb.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_rust.rs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_scala.scala.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_shell.sh.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_swift.swift.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_typescript.ts.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_zig.zig.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_c.c.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_cpp.cpp.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_csharp.cs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_elixir.ex.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_go.go.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_haskell.hs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_java.java.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_javascript.js.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_kotlin.kt.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_lua.lua.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_perl.pl.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_php.php.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_python.py.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_ruby.rb.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_rust.rs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_scala.scala.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_shell.sh.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_swift.swift.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_typescript.ts.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_zig.zig.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_c.c.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_cpp.cpp.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_csharp.cs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_elixir.ex.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_go.go.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_haskell.hs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_java.java.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_javascript.js.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_kotlin.kt.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_lua.lua.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_perl.pl.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_php.php.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_python.py.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_ruby.rb.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_rust.rs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_scala.scala.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_shell.sh.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_swift.swift.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_typescript.ts.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_zig.zig.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_c.c.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_cpp.cpp.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_csharp.cs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_elixir.ex.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_go.go.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_haskell.hs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_java.java.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_javascript.js.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_kotlin.kt.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_lua.lua.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_perl.pl.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_php.php.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_python.py.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_ruby.rb.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_rust.rs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_scala.scala.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_shell.sh.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_swift.swift.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_typescript.ts.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_zig.zig.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_c.c.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_cpp.cpp.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_csharp.cs.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_elixir.ex.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_go.go.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_haskell.hs.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_java.java.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_javascript.js.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_kotlin.kt.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_lua.lua.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_perl.pl.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_php.php.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_python.py.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_ruby.rb.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_rust.rs.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_scala.scala.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_shell.sh.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_swift.swift.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_typescript.ts.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_zig.zig.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_c.c.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_cpp.cpp.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_csharp.cs.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_elixir.ex.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_go.go.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_haskell.hs.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_java.java.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_javascript.js.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_kotlin.kt.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_lua.lua.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_perl.pl.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_php.php.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_python.py.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_ruby.rb.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_rust.rs.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_scala.scala.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_shell.sh.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_swift.swift.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_typescript.ts.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_zig.zig.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_c.c.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_cpp.cpp.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_csharp.cs.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_elixir.ex.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_go.go.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_haskell.hs.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_java.java.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_javascript.js.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_kotlin.kt.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_lua.lua.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_perl.pl.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_php.php.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_python.py.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_ruby.rb.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_rust.rs.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_scala.scala.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_shell.sh.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_swift.swift.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_typescript.ts.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_zig.zig.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_c.c.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_cpp.cpp.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_csharp.cs.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_elixir.ex.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_go.go.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_haskell.hs.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_java.java.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_javascript.js.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_kotlin.kt.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_lua.lua.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_perl.pl.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_php.php.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_python.py.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_ruby.rb.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_rust.rs.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_scala.scala.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_shell.sh.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_swift.swift.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_typescript.ts.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_zig.zig.json +5 -0
- package/tests/helpers.ts +204 -0
- package/tests/oracle-project.test.ts +63 -0
- package/tests/oracle-standalone.test.ts +48 -0
- package/tests/prompt-rendering.test.ts +66 -0
- package/tests/release-workflow.test.ts +133 -0
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* @brief Implements the standalone extension debug harness CLI.
|
|
4
|
+
* @details Parses debug-harness subcommands, dispatches offline inspection and replay operations, formats reports as JSON or human-readable markdown, and converts `ReqError` instances into process-style stderr plus exit codes. Runtime is dominated by the selected harness subcommand. Side effects include stdout/stderr writes and any extension-owned behavior triggered by delegated replay operations.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import process from "node:process";
|
|
8
|
+
import { ReqError } from "../src/core/errors.js";
|
|
9
|
+
import {
|
|
10
|
+
inspectExtension,
|
|
11
|
+
replayCommand,
|
|
12
|
+
replaySessionStart,
|
|
13
|
+
replayTool,
|
|
14
|
+
type CommandReplayReport,
|
|
15
|
+
type InspectReport,
|
|
16
|
+
type OfflineContractSnapshot,
|
|
17
|
+
type SessionStartReport,
|
|
18
|
+
type ToolReplayReport,
|
|
19
|
+
} from "./lib/extension-debug-harness.js";
|
|
20
|
+
import { runSdkSmoke, type ParityMismatch, type SdkSmokeReport } from "./lib/sdk-smoke.js";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @brief Enumerates the supported harness output formats.
|
|
24
|
+
* @details Keeps the CLI formatter selection constrained to deterministic JSON output or human-readable markdown output. The alias is compile-time only and introduces no runtime cost.
|
|
25
|
+
*/
|
|
26
|
+
type OutputFormat = "json" | "pretty";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @brief Describes the parsed debug-harness CLI arguments.
|
|
30
|
+
* @details Captures the selected subcommand plus all recognized option values in the normalized shape consumed by `main`. The interface is compile-time only and introduces no runtime cost.
|
|
31
|
+
*/
|
|
32
|
+
interface ParsedHarnessArgs {
|
|
33
|
+
subcommand?: string;
|
|
34
|
+
cwd?: string;
|
|
35
|
+
extensionPath?: string;
|
|
36
|
+
format: OutputFormat;
|
|
37
|
+
name?: string;
|
|
38
|
+
commandArgs: string;
|
|
39
|
+
params?: string;
|
|
40
|
+
eventPayload?: string;
|
|
41
|
+
selects: string[];
|
|
42
|
+
inputs: string[];
|
|
43
|
+
help: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @brief Stores the standalone harness usage text.
|
|
48
|
+
* @details Provides a deterministic help payload for invalid or incomplete invocations. Access complexity is O(1).
|
|
49
|
+
*/
|
|
50
|
+
const USAGE_TEXT = `Usage: node --import tsx ./scripts/debug-extension.ts <subcommand> [options]
|
|
51
|
+
|
|
52
|
+
Subcommands:
|
|
53
|
+
inspect
|
|
54
|
+
session-start
|
|
55
|
+
command
|
|
56
|
+
tool
|
|
57
|
+
sdk-smoke
|
|
58
|
+
|
|
59
|
+
Options:
|
|
60
|
+
--cwd <path> Working directory exposed as ctx.cwd and process.cwd().
|
|
61
|
+
--extension <path> Extension entry path. Defaults to ./src/index.ts.
|
|
62
|
+
--format <pretty|json> Output format. Defaults to pretty.
|
|
63
|
+
--name <value> Command or tool name for replay subcommands.
|
|
64
|
+
--args <text> Raw argument string for the command subcommand.
|
|
65
|
+
--params <json> JSON object passed to the tool subcommand.
|
|
66
|
+
--event-payload <json> JSON object passed to session-start.
|
|
67
|
+
--select <value> Scripted ctx.ui.select response. Repeatable.
|
|
68
|
+
--input <value> Scripted ctx.ui.input response. Repeatable.
|
|
69
|
+
--help Show this help text.
|
|
70
|
+
`;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @brief Parses raw CLI arguments into a normalized harness command object.
|
|
74
|
+
* @details Performs a single left-to-right scan, records the first positional token as the subcommand, supports repeatable `--select` and `--input` options, and defaults the output format to `pretty`. Runtime is O(n) in argument count. No external state is mutated.
|
|
75
|
+
* @param[in] argv {string[]} Raw CLI arguments excluding executable and script path.
|
|
76
|
+
* @return {ParsedHarnessArgs} Parsed harness arguments.
|
|
77
|
+
*/
|
|
78
|
+
function parseArgs(argv: string[]): ParsedHarnessArgs {
|
|
79
|
+
const parsed: ParsedHarnessArgs = {
|
|
80
|
+
format: "pretty",
|
|
81
|
+
commandArgs: "",
|
|
82
|
+
selects: [],
|
|
83
|
+
inputs: [],
|
|
84
|
+
help: false,
|
|
85
|
+
};
|
|
86
|
+
let index = 0;
|
|
87
|
+
while (index < argv.length) {
|
|
88
|
+
const token = argv[index]!;
|
|
89
|
+
if (!token.startsWith("--") && !parsed.subcommand) {
|
|
90
|
+
parsed.subcommand = token;
|
|
91
|
+
index += 1;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
switch (token) {
|
|
95
|
+
case "--cwd":
|
|
96
|
+
parsed.cwd = argv[index + 1];
|
|
97
|
+
index += 2;
|
|
98
|
+
break;
|
|
99
|
+
case "--extension":
|
|
100
|
+
parsed.extensionPath = argv[index + 1];
|
|
101
|
+
index += 2;
|
|
102
|
+
break;
|
|
103
|
+
case "--format":
|
|
104
|
+
parsed.format = argv[index + 1] === "json" ? "json" : "pretty";
|
|
105
|
+
index += 2;
|
|
106
|
+
break;
|
|
107
|
+
case "--name":
|
|
108
|
+
parsed.name = argv[index + 1];
|
|
109
|
+
index += 2;
|
|
110
|
+
break;
|
|
111
|
+
case "--args":
|
|
112
|
+
parsed.commandArgs = argv[index + 1] ?? "";
|
|
113
|
+
index += 2;
|
|
114
|
+
break;
|
|
115
|
+
case "--params":
|
|
116
|
+
parsed.params = argv[index + 1];
|
|
117
|
+
index += 2;
|
|
118
|
+
break;
|
|
119
|
+
case "--event-payload":
|
|
120
|
+
parsed.eventPayload = argv[index + 1];
|
|
121
|
+
index += 2;
|
|
122
|
+
break;
|
|
123
|
+
case "--select":
|
|
124
|
+
parsed.selects.push(argv[index + 1] ?? "");
|
|
125
|
+
index += 2;
|
|
126
|
+
break;
|
|
127
|
+
case "--input":
|
|
128
|
+
parsed.inputs.push(argv[index + 1] ?? "");
|
|
129
|
+
index += 2;
|
|
130
|
+
break;
|
|
131
|
+
case "--help":
|
|
132
|
+
parsed.help = true;
|
|
133
|
+
index += 1;
|
|
134
|
+
break;
|
|
135
|
+
default:
|
|
136
|
+
index += 1;
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return parsed;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @brief Parses a JSON object option from the CLI.
|
|
145
|
+
* @details Accepts an omitted value as the supplied fallback, requires object payloads for present values, and wraps parse failures in `ReqError` for deterministic CLI error reporting. Runtime is O(n) in input size. No external state is mutated.
|
|
146
|
+
* @param[in] text {string | undefined} Raw JSON option value.
|
|
147
|
+
* @param[in] label {string} Human-readable option label.
|
|
148
|
+
* @param[in] fallback {Record<string, unknown>} Fallback object when the option is omitted.
|
|
149
|
+
* @return {Record<string, unknown>} Parsed JSON object.
|
|
150
|
+
* @throws {ReqError} Throws when the option is present but not valid JSON object syntax.
|
|
151
|
+
*/
|
|
152
|
+
function parseJsonObject(text: string | undefined, label: string, fallback: Record<string, unknown>): Record<string, unknown> {
|
|
153
|
+
if (text === undefined) {
|
|
154
|
+
return fallback;
|
|
155
|
+
}
|
|
156
|
+
try {
|
|
157
|
+
const parsed = JSON.parse(text) as unknown;
|
|
158
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
159
|
+
throw new ReqError(`Error: ${label} must be a JSON object.`, 1);
|
|
160
|
+
}
|
|
161
|
+
return parsed as Record<string, unknown>;
|
|
162
|
+
} catch (error) {
|
|
163
|
+
if (error instanceof ReqError) {
|
|
164
|
+
throw error;
|
|
165
|
+
}
|
|
166
|
+
throw new ReqError(`Error: failed to parse ${label}: ${error instanceof Error ? error.message : String(error)}`, 1);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* @brief Writes non-empty text to stdout.
|
|
172
|
+
* @details Skips zero-length writes so callers can compose output safely. Runtime is O(n) in text length. Side effects are limited to stdout writes.
|
|
173
|
+
* @param[in] text {string} Text payload.
|
|
174
|
+
* @return {void} No return value.
|
|
175
|
+
*/
|
|
176
|
+
function writeStdout(text: string): void {
|
|
177
|
+
if (text.length > 0) {
|
|
178
|
+
process.stdout.write(text);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* @brief Writes non-empty text to stderr with a trailing newline.
|
|
184
|
+
* @details Appends a newline when needed and skips empty payloads. Runtime is O(n) in text length. Side effects are limited to stderr writes.
|
|
185
|
+
* @param[in] text {string} Text payload.
|
|
186
|
+
* @return {void} No return value.
|
|
187
|
+
*/
|
|
188
|
+
function writeStderr(text: string): void {
|
|
189
|
+
if (text.length === 0) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
process.stderr.write(text.endsWith("\n") ? text : `${text}\n`);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* @brief Serializes one arbitrary report as pretty-printed JSON.
|
|
197
|
+
* @details Uses two-space indentation and appends a trailing newline for stable automation-friendly output. Runtime is O(n) in report size. No external state is mutated.
|
|
198
|
+
* @param[in] value {unknown} Report payload.
|
|
199
|
+
* @return {string} JSON document.
|
|
200
|
+
*/
|
|
201
|
+
function formatJson(value: unknown): string {
|
|
202
|
+
return `${JSON.stringify(value, null, 2)}\n`;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* @brief Formats the common snapshot header for human-readable output.
|
|
207
|
+
* @details Renders normalized path metadata, registration counts, and event names shared by all offline reports. Runtime is O(n) in inventory size. No external state is mutated.
|
|
208
|
+
* @param[in] snapshot {OfflineContractSnapshot} Snapshot payload.
|
|
209
|
+
* @return {string[]} Markdown lines.
|
|
210
|
+
*/
|
|
211
|
+
function formatSnapshotHeader(snapshot: OfflineContractSnapshot): string[] {
|
|
212
|
+
return [
|
|
213
|
+
`- Extension: \`${snapshot.extensionPath}\``,
|
|
214
|
+
`- Requested cwd: \`${snapshot.requestedCwd}\``,
|
|
215
|
+
`- Effective ctx.cwd: \`${snapshot.effectiveCtxCwd}\``,
|
|
216
|
+
`- Effective process.cwd(): \`${snapshot.effectiveProcessCwd}\``,
|
|
217
|
+
`- Commands: ${snapshot.commands.length}`,
|
|
218
|
+
`- Tools: ${snapshot.tools.length}`,
|
|
219
|
+
`- Event handlers: ${snapshot.eventHandlers.join(", ") || "(none)"}`,
|
|
220
|
+
`- Active tools: ${snapshot.activeTools.join(", ") || "(none)"}`,
|
|
221
|
+
];
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* @brief Formats one offline inspection report for human-readable output.
|
|
226
|
+
* @details Emits sections for inventory counts, commands, tools, sent user messages, and the generated usage manual. Runtime is O(n) in report size. No external state is mutated.
|
|
227
|
+
* @param[in] report {InspectReport} Inspection report.
|
|
228
|
+
* @return {string} Markdown document.
|
|
229
|
+
*/
|
|
230
|
+
function formatInspectReport(report: InspectReport): string {
|
|
231
|
+
const lines = ["# Offline extension inspection", "", ...formatSnapshotHeader(report), "", "## Commands"];
|
|
232
|
+
for (const command of report.commands) {
|
|
233
|
+
lines.push(`- ${command.name}: ${command.description ?? "(no description)"}`);
|
|
234
|
+
}
|
|
235
|
+
lines.push("", "## Tools");
|
|
236
|
+
for (const tool of report.tools) {
|
|
237
|
+
lines.push(`- ${tool.name}: ${tool.description ?? "(no description)"} | parameters: ${tool.hasParameters ? "present" : "absent"}`);
|
|
238
|
+
}
|
|
239
|
+
lines.push("", "## Sent user messages");
|
|
240
|
+
if (report.sentUserMessages.length === 0) {
|
|
241
|
+
lines.push("- (none)");
|
|
242
|
+
} else {
|
|
243
|
+
for (const [index, message] of report.sentUserMessages.entries()) {
|
|
244
|
+
lines.push(`- [${index}] ${JSON.stringify(message.content)}`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
lines.push("", report.manual.trimEnd());
|
|
248
|
+
return `${lines.join("\n")}\n`;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* @brief Formats one recorded UI state snapshot for human-readable output.
|
|
253
|
+
* @details Emits statuses, notifications, editor text, and scripted interaction traces used by session-start and command/tool replay reports. Runtime is O(n) in interaction count. No external state is mutated.
|
|
254
|
+
* @param[in] ui {SessionStartReport["ui"]} UI-state snapshot.
|
|
255
|
+
* @return {string[]} Markdown lines.
|
|
256
|
+
*/
|
|
257
|
+
function formatUiState(ui: SessionStartReport["ui"]): string[] {
|
|
258
|
+
const lines = ["## UI side effects"];
|
|
259
|
+
const statusEntries = Object.entries(ui.statuses);
|
|
260
|
+
lines.push(`- Status slots: ${statusEntries.length === 0 ? "(none)" : statusEntries.map(([key, value]) => `${key}=${value}`).join(", ")}`);
|
|
261
|
+
lines.push(`- Notifications: ${ui.notifications.length === 0 ? "(none)" : ui.notifications.map((entry) => `${entry.level}:${entry.message}`).join(" | ")}`);
|
|
262
|
+
lines.push(`- Editor text length: ${ui.editorText.length}`);
|
|
263
|
+
lines.push(`- Remaining scripted selects: ${ui.remainingSelects.length}`);
|
|
264
|
+
lines.push(`- Remaining scripted inputs: ${ui.remainingInputs.length}`);
|
|
265
|
+
if (ui.editorText.length > 0) {
|
|
266
|
+
lines.push("", "### Editor text", "```text", ui.editorText.trimEnd(), "```");
|
|
267
|
+
}
|
|
268
|
+
if (ui.selectCalls.length > 0) {
|
|
269
|
+
lines.push("", "### select() calls");
|
|
270
|
+
for (const call of ui.selectCalls) {
|
|
271
|
+
lines.push(`- ${call.title} -> ${call.response ?? "(undefined)"}`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
if (ui.inputCalls.length > 0) {
|
|
275
|
+
lines.push("", "### input() calls");
|
|
276
|
+
for (const call of ui.inputCalls) {
|
|
277
|
+
lines.push(`- ${call.title} -> ${call.response ?? "(undefined)"}`);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return lines;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @brief Formats one session-start replay report for human-readable output.
|
|
285
|
+
* @details Emits common snapshot metadata plus the recorded event payload and UI side effects. Runtime is O(n) in report size. No external state is mutated.
|
|
286
|
+
* @param[in] report {SessionStartReport} Session-start replay report.
|
|
287
|
+
* @return {string} Markdown document.
|
|
288
|
+
*/
|
|
289
|
+
function formatSessionStartReport(report: SessionStartReport): string {
|
|
290
|
+
const lines = [
|
|
291
|
+
"# Offline session_start replay",
|
|
292
|
+
"",
|
|
293
|
+
...formatSnapshotHeader(report),
|
|
294
|
+
"",
|
|
295
|
+
`- Event payload: \`${JSON.stringify(report.eventPayload)}\``,
|
|
296
|
+
"",
|
|
297
|
+
...formatUiState(report.ui),
|
|
298
|
+
];
|
|
299
|
+
return `${lines.join("\n")}\n`;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* @brief Formats one command replay report for human-readable output.
|
|
304
|
+
* @details Emits common snapshot metadata, command identity, sent user messages, and UI side effects. Runtime is O(n) in report size. No external state is mutated.
|
|
305
|
+
* @param[in] report {CommandReplayReport} Command replay report.
|
|
306
|
+
* @return {string} Markdown document.
|
|
307
|
+
*/
|
|
308
|
+
function formatCommandReplayReport(report: CommandReplayReport): string {
|
|
309
|
+
const lines = [
|
|
310
|
+
`# Offline command replay: ${report.commandName}`,
|
|
311
|
+
"",
|
|
312
|
+
...formatSnapshotHeader(report),
|
|
313
|
+
"",
|
|
314
|
+
`- Raw args: \`${report.commandArgs}\``,
|
|
315
|
+
`- Sent user messages: ${report.sentUserMessages.length}`,
|
|
316
|
+
];
|
|
317
|
+
if (report.sentUserMessages.length > 0) {
|
|
318
|
+
lines.push("", "## Sent user messages");
|
|
319
|
+
for (const [index, message] of report.sentUserMessages.entries()) {
|
|
320
|
+
lines.push(`- [${index}] ${JSON.stringify(message.content)}`);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
lines.push("", ...formatUiState(report.ui));
|
|
324
|
+
return `${lines.join("\n")}\n`;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* @brief Formats one tool replay report for human-readable output.
|
|
329
|
+
* @details Emits common snapshot metadata, tool identity, input parameters, streamed updates, final result payload, and UI side effects. Runtime is O(n) in report size. No external state is mutated.
|
|
330
|
+
* @param[in] report {ToolReplayReport} Tool replay report.
|
|
331
|
+
* @return {string} Markdown document.
|
|
332
|
+
*/
|
|
333
|
+
function formatToolReplayReport(report: ToolReplayReport): string {
|
|
334
|
+
const lines = [
|
|
335
|
+
`# Offline tool replay: ${report.toolName}`,
|
|
336
|
+
"",
|
|
337
|
+
...formatSnapshotHeader(report),
|
|
338
|
+
"",
|
|
339
|
+
`- Params: \`${JSON.stringify(report.toolParams)}\``,
|
|
340
|
+
`- Stream updates: ${report.toolUpdates.length}`,
|
|
341
|
+
"",
|
|
342
|
+
"## Tool result",
|
|
343
|
+
"```json",
|
|
344
|
+
JSON.stringify(report.toolResult, null, 2),
|
|
345
|
+
"```",
|
|
346
|
+
];
|
|
347
|
+
if (report.toolUpdates.length > 0) {
|
|
348
|
+
lines.push("", "## Tool updates", "```json", JSON.stringify(report.toolUpdates, null, 2), "```");
|
|
349
|
+
}
|
|
350
|
+
lines.push("", ...formatUiState(report.ui));
|
|
351
|
+
return `${lines.join("\n")}\n`;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* @brief Formats one parity mismatch for human-readable output.
|
|
356
|
+
* @details Emits the category, subject, detail, and normalized offline versus SDK payloads for deterministic troubleshooting. Runtime is O(n) in payload size. No external state is mutated.
|
|
357
|
+
* @param[in] mismatch {ParityMismatch} Mismatch payload.
|
|
358
|
+
* @return {string[]} Markdown lines.
|
|
359
|
+
*/
|
|
360
|
+
function formatMismatch(mismatch: ParityMismatch): string[] {
|
|
361
|
+
return [
|
|
362
|
+
`- ${mismatch.category} :: ${mismatch.subject}`,
|
|
363
|
+
` - detail: ${mismatch.detail}`,
|
|
364
|
+
` - offline: ${JSON.stringify(mismatch.offline ?? null)}`,
|
|
365
|
+
` - sdk: ${JSON.stringify(mismatch.sdk ?? null)}`,
|
|
366
|
+
];
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* @brief Formats one SDK smoke report for human-readable output.
|
|
371
|
+
* @details Emits parity status, offline versus SDK inventory counts, runtime-shape metadata, and detailed mismatch entries when parity fails. Runtime is O(n) in report size. No external state is mutated.
|
|
372
|
+
* @param[in] report {SdkSmokeReport} SDK smoke report.
|
|
373
|
+
* @return {string} Markdown document.
|
|
374
|
+
*/
|
|
375
|
+
function formatSdkSmokeReport(report: SdkSmokeReport): string {
|
|
376
|
+
const lines = [
|
|
377
|
+
"# SDK parity smoke",
|
|
378
|
+
"",
|
|
379
|
+
`- Parity: ${report.ok ? "OK" : "FAIL"}`,
|
|
380
|
+
`- SDK runtime shape: ${report.sdk.runtimeShape}`,
|
|
381
|
+
`- Offline commands/tools: ${report.offline.commands.length}/${report.offline.tools.length}`,
|
|
382
|
+
`- SDK commands/tools: ${report.sdk.commands.length}/${report.sdk.tools.length}`,
|
|
383
|
+
`- Offline active tools: ${report.offline.activeTools.join(", ") || "(none)"}`,
|
|
384
|
+
`- SDK active tools: ${report.sdk.activeTools.join(", ") || "(none)"}`,
|
|
385
|
+
];
|
|
386
|
+
if (report.mismatches.length === 0) {
|
|
387
|
+
lines.push("", "No mismatches detected.");
|
|
388
|
+
} else {
|
|
389
|
+
lines.push("", "## Mismatches");
|
|
390
|
+
for (const mismatch of report.mismatches) {
|
|
391
|
+
lines.push(...formatMismatch(mismatch));
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return `${lines.join("\n")}\n`;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* @brief Formats the selected report according to the requested output mode.
|
|
399
|
+
* @details Uses JSON for automation-friendly output and markdown for human review. Runtime is O(n) in report size. No external state is mutated.
|
|
400
|
+
* @param[in] format {OutputFormat} Requested output format.
|
|
401
|
+
* @param[in] subcommand {string} Executed harness subcommand.
|
|
402
|
+
* @param[in] report {InspectReport | SessionStartReport | CommandReplayReport | ToolReplayReport | SdkSmokeReport} Report payload.
|
|
403
|
+
* @return {string} Final stdout payload.
|
|
404
|
+
*/
|
|
405
|
+
function formatReport(
|
|
406
|
+
format: OutputFormat,
|
|
407
|
+
subcommand: string,
|
|
408
|
+
report: InspectReport | SessionStartReport | CommandReplayReport | ToolReplayReport | SdkSmokeReport,
|
|
409
|
+
): string {
|
|
410
|
+
if (format === "json") {
|
|
411
|
+
return formatJson(report);
|
|
412
|
+
}
|
|
413
|
+
switch (subcommand) {
|
|
414
|
+
case "inspect":
|
|
415
|
+
return formatInspectReport(report as InspectReport);
|
|
416
|
+
case "session-start":
|
|
417
|
+
return formatSessionStartReport(report as SessionStartReport);
|
|
418
|
+
case "command":
|
|
419
|
+
return formatCommandReplayReport(report as CommandReplayReport);
|
|
420
|
+
case "tool":
|
|
421
|
+
return formatToolReplayReport(report as ToolReplayReport);
|
|
422
|
+
case "sdk-smoke":
|
|
423
|
+
return formatSdkSmokeReport(report as SdkSmokeReport);
|
|
424
|
+
default:
|
|
425
|
+
return `${USAGE_TEXT}\n`;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* @brief Executes one standalone debug-harness invocation.
|
|
431
|
+
* @details Parses CLI arguments, validates subcommand-specific requirements, dispatches the selected harness workflow, and formats the result for stdout while converting `ReqError` failures into stderr plus exit codes. Runtime is dominated by the selected subcommand. Side effects include stdout/stderr writes and delegated extension replay behavior.
|
|
432
|
+
* @param[in] argv {string[]} Raw CLI arguments. Defaults to `process.argv.slice(2)`.
|
|
433
|
+
* @return {Promise<number>} Process exit code.
|
|
434
|
+
* @throws {ReqError} Internally catches `ReqError` and returns its exit code.
|
|
435
|
+
*/
|
|
436
|
+
export async function main(argv = process.argv.slice(2)): Promise<number> {
|
|
437
|
+
try {
|
|
438
|
+
const args = parseArgs(argv);
|
|
439
|
+
if (args.help || !args.subcommand) {
|
|
440
|
+
writeStdout(USAGE_TEXT);
|
|
441
|
+
return 0;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
const uiPlan = { selects: args.selects, inputs: args.inputs };
|
|
445
|
+
let report: InspectReport | SessionStartReport | CommandReplayReport | ToolReplayReport | SdkSmokeReport;
|
|
446
|
+
|
|
447
|
+
switch (args.subcommand) {
|
|
448
|
+
case "inspect":
|
|
449
|
+
report = await inspectExtension(args.cwd, args.extensionPath);
|
|
450
|
+
break;
|
|
451
|
+
case "session-start":
|
|
452
|
+
report = await replaySessionStart(
|
|
453
|
+
args.cwd,
|
|
454
|
+
args.extensionPath,
|
|
455
|
+
parseJsonObject(args.eventPayload, "event payload", { reason: "startup" }),
|
|
456
|
+
uiPlan,
|
|
457
|
+
);
|
|
458
|
+
break;
|
|
459
|
+
case "command":
|
|
460
|
+
if (!args.name) {
|
|
461
|
+
throw new ReqError("Error: --name is required for the command subcommand.", 1);
|
|
462
|
+
}
|
|
463
|
+
report = await replayCommand(args.name, args.commandArgs, args.cwd, args.extensionPath, uiPlan);
|
|
464
|
+
break;
|
|
465
|
+
case "tool":
|
|
466
|
+
if (!args.name) {
|
|
467
|
+
throw new ReqError("Error: --name is required for the tool subcommand.", 1);
|
|
468
|
+
}
|
|
469
|
+
report = await replayTool(
|
|
470
|
+
args.name,
|
|
471
|
+
parseJsonObject(args.params, "tool params", {}),
|
|
472
|
+
args.cwd,
|
|
473
|
+
args.extensionPath,
|
|
474
|
+
uiPlan,
|
|
475
|
+
);
|
|
476
|
+
break;
|
|
477
|
+
case "sdk-smoke":
|
|
478
|
+
report = await runSdkSmoke(args.cwd, args.extensionPath);
|
|
479
|
+
break;
|
|
480
|
+
default:
|
|
481
|
+
throw new ReqError(`Error: unknown subcommand: ${args.subcommand}`, 1);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
writeStdout(formatReport(args.format, args.subcommand, report));
|
|
485
|
+
return 0;
|
|
486
|
+
} catch (error) {
|
|
487
|
+
const reqError = error as ReqError;
|
|
488
|
+
writeStderr(reqError.message ?? String(error));
|
|
489
|
+
return reqError.code ?? 1;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
494
|
+
void main().then((code) => {
|
|
495
|
+
process.exitCode = code;
|
|
496
|
+
});
|
|
497
|
+
}
|