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,330 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# @file
|
|
3
|
+
# @brief Provides a bash wrapper for the standalone extension debug harness.
|
|
4
|
+
# @details Resolves repository-local execution paths, preserves the caller working directory as the default debug target, exposes convenience subcommands for registration inspection plus prompt and tool replay, resolves a repository-visible `tsx` runner, materializes a shared `node_modules` symlink for worktrees when required, converts tool `--args` text into `--params` JSON when requested, and delegates execution to `scripts/debug-extension.ts`. Runtime is O(n) in CLI argument count plus delegated harness cost. Side effects include spawning Node subprocesses and temporarily changing the wrapper subshell cwd to the repository root.
|
|
5
|
+
|
|
6
|
+
set -euo pipefail
|
|
7
|
+
|
|
8
|
+
# @brief Resolves the absolute directory containing `pi-usereq-debug.sh`.
|
|
9
|
+
# @details Uses `BASH_SOURCE[0]` so invocation through relative paths or symlinks still anchors repository-relative lookups. Runtime is O(p) in path length. No filesystem mutation occurs.
|
|
10
|
+
readonly SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
|
11
|
+
|
|
12
|
+
# @brief Resolves the repository root that owns the debug wrapper.
|
|
13
|
+
# @details Moves one level above `SCRIPT_DIR` so delegated Node execution can load the repository-local `tsx` dependency and extension entry. Runtime is O(p) in path length. No filesystem mutation occurs.
|
|
14
|
+
readonly REPO_ROOT="$(CDPATH= cd -- "${SCRIPT_DIR}/.." && pwd)"
|
|
15
|
+
|
|
16
|
+
# @brief Stores the default extension entry path used by the wrapper.
|
|
17
|
+
# @details Binds all convenience subcommands to the repository's `src/index.ts` entry unless the caller provides a later `--extension` override. Runtime is O(1). No filesystem mutation occurs.
|
|
18
|
+
readonly DEFAULT_EXTENSION="${REPO_ROOT}/src/index.ts"
|
|
19
|
+
|
|
20
|
+
# @brief Stores the caller working directory used as the default debug cwd.
|
|
21
|
+
# @details Captures the shell cwd before the wrapper enters the repository root so replayed commands and tools observe the caller-selected project context. Runtime is O(1). No filesystem mutation occurs.
|
|
22
|
+
readonly CALLER_CWD="${PWD}"
|
|
23
|
+
|
|
24
|
+
# @brief Resolves the `tsx` executable visible to the wrapper.
|
|
25
|
+
# @details Searches the active repository install first, then the shared git-common checkout used by worktrees, and finally the process `PATH`. When a shared checkout provides `node_modules`, the function links that directory into the worktree before returning the executable path. Runtime is O(1) plus one git subprocess. Side effects may include creating `REPO_ROOT/node_modules` as a symlink.
|
|
26
|
+
# @return {string} Absolute or PATH-resolved `tsx` executable path.
|
|
27
|
+
# @throws {shell-error} Returns non-zero when no usable `tsx` executable is available.
|
|
28
|
+
resolve_tsx_binary() {
|
|
29
|
+
local local_tsx="${REPO_ROOT}/node_modules/.bin/tsx"
|
|
30
|
+
if [[ -x "${local_tsx}" ]]; then
|
|
31
|
+
printf '%s\n' "${local_tsx}"
|
|
32
|
+
return 0
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
local git_common_dir=""
|
|
36
|
+
git_common_dir="$(git -C "${REPO_ROOT}" rev-parse --git-common-dir 2>/dev/null || true)"
|
|
37
|
+
if [[ -n "${git_common_dir}" ]]; then
|
|
38
|
+
local shared_root
|
|
39
|
+
local shared_tsx
|
|
40
|
+
shared_root="$(CDPATH= cd -- "${git_common_dir}/.." && pwd)"
|
|
41
|
+
shared_tsx="${shared_root}/node_modules/.bin/tsx"
|
|
42
|
+
if [[ -x "${shared_tsx}" ]]; then
|
|
43
|
+
if [[ ! -e "${REPO_ROOT}/node_modules" && ! -L "${REPO_ROOT}/node_modules" ]]; then
|
|
44
|
+
ln -s "${shared_root}/node_modules" "${REPO_ROOT}/node_modules"
|
|
45
|
+
fi
|
|
46
|
+
printf '%s\n' "${shared_tsx}"
|
|
47
|
+
return 0
|
|
48
|
+
fi
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
if command -v tsx >/dev/null 2>&1; then
|
|
52
|
+
command -v tsx
|
|
53
|
+
return 0
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
printf 'Error: tsx executable not found in repository or PATH.\n' >&2
|
|
57
|
+
return 1
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
# @brief Stores the resolved `tsx` executable path.
|
|
61
|
+
# @details Captures the executable once during wrapper startup so later dispatch paths do not repeat repository lookup logic. Runtime is dominated by `resolve_tsx_binary()`. Side effects may include creating a worktree-local `node_modules` symlink.
|
|
62
|
+
readonly TSX_BIN="$(resolve_tsx_binary)"
|
|
63
|
+
|
|
64
|
+
# @brief Prints the wrapper usage contract.
|
|
65
|
+
# @details Emits subcommand semantics, override rules, and concrete examples covering registrations, session replay, prompt replay, tool replay, and raw pass-through. Runtime is O(1). Side effect: writes to stdout.
|
|
66
|
+
# @return {void} No return value.
|
|
67
|
+
# @satisfies REQ-061, REQ-062, REQ-065
|
|
68
|
+
print_usage() {
|
|
69
|
+
cat <<EOF
|
|
70
|
+
Usage: ./scripts/pi-usereq-debug.sh <subcommand> [options]
|
|
71
|
+
|
|
72
|
+
Subcommands:
|
|
73
|
+
inspect [debug-extension options...]
|
|
74
|
+
Inspect command, tool, and event registrations.
|
|
75
|
+
session [debug-extension options...]
|
|
76
|
+
Replay session_start handlers via session-start.
|
|
77
|
+
command <name> [--args <text> | debug-extension options...]
|
|
78
|
+
Replay one registered command.
|
|
79
|
+
prompt <name> [--args <text> | debug-extension options...]
|
|
80
|
+
Replay one req-* prompt command; bare names are auto-prefixed.
|
|
81
|
+
tool <name> [--args <text> | --params <json> | debug-extension options...]
|
|
82
|
+
Replay one registered tool; defaults params to {}.
|
|
83
|
+
sdk [debug-extension options...]
|
|
84
|
+
Run sdk-smoke parity inspection.
|
|
85
|
+
raw <debug-extension arguments...>
|
|
86
|
+
Forward arguments directly to scripts/debug-extension.ts.
|
|
87
|
+
help
|
|
88
|
+
Show this usage text.
|
|
89
|
+
|
|
90
|
+
Default forwarding:
|
|
91
|
+
- Adds --cwd "${CALLER_CWD}" before forwarded arguments.
|
|
92
|
+
- Adds --extension "${DEFAULT_EXTENSION}" before forwarded arguments.
|
|
93
|
+
- Later --cwd or --extension arguments override the defaults.
|
|
94
|
+
|
|
95
|
+
Examples:
|
|
96
|
+
./scripts/pi-usereq-debug.sh inspect --format pretty
|
|
97
|
+
./scripts/pi-usereq-debug.sh session --format json
|
|
98
|
+
./scripts/pi-usereq-debug.sh prompt analyze --args "Inspect prompt rendering"
|
|
99
|
+
./scripts/pi-usereq-debug.sh tool files-find --args 'FUNCTION ^run src/index.ts --enable-line-numbers'
|
|
100
|
+
./scripts/pi-usereq-debug.sh raw command --name req-analyze --args "Review REQ-004"
|
|
101
|
+
EOF
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
# @brief Tests whether one exact option token is present in an argument list.
|
|
105
|
+
# @details Performs a linear scan over forwarded tokens and returns success when any token equals the requested option string. Runtime is O(n) in argument count. No external state is mutated.
|
|
106
|
+
# @param[in] needle {string} Exact option token to match.
|
|
107
|
+
# @param[in] ... {string[]} Forwarded CLI tokens.
|
|
108
|
+
# @return {int} Shell status `0` when the option exists; `1` otherwise.
|
|
109
|
+
contains_exact_option() {
|
|
110
|
+
local needle="$1"
|
|
111
|
+
shift
|
|
112
|
+
local token
|
|
113
|
+
for token in "$@"; do
|
|
114
|
+
if [[ "${token}" == "${needle}" ]]; then
|
|
115
|
+
return 0
|
|
116
|
+
fi
|
|
117
|
+
done
|
|
118
|
+
return 1
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
# @brief Tests whether an argument list already contains any long option token.
|
|
122
|
+
# @details Detects tokens beginning with `--` so the wrapper can avoid inferring positional payloads when the caller is already using the underlying debug-harness option grammar. Runtime is O(n) in argument count. No external state is mutated.
|
|
123
|
+
# @param[in] ... {string[]} Forwarded CLI tokens.
|
|
124
|
+
# @return {int} Shell status `0` when a long option exists; `1` otherwise.
|
|
125
|
+
contains_long_option() {
|
|
126
|
+
local token
|
|
127
|
+
for token in "$@"; do
|
|
128
|
+
if [[ "${token}" == --* ]]; then
|
|
129
|
+
return 0
|
|
130
|
+
fi
|
|
131
|
+
done
|
|
132
|
+
return 1
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
# @brief Normalizes prompt aliases to registered `req-*` command names.
|
|
136
|
+
# @details Returns the input unchanged when it already begins with `req-`; otherwise prepends the prefix required by extension registration. Runtime is O(p) in prompt-name length. No external state is mutated.
|
|
137
|
+
# @param[in] prompt_name {string} Prompt command alias supplied by the caller.
|
|
138
|
+
# @return {string} Registered prompt command name.
|
|
139
|
+
# @satisfies REQ-062
|
|
140
|
+
normalize_prompt_name() {
|
|
141
|
+
local prompt_name="$1"
|
|
142
|
+
if [[ "${prompt_name}" == req-* ]]; then
|
|
143
|
+
printf '%s\n' "${prompt_name}"
|
|
144
|
+
return 0
|
|
145
|
+
fi
|
|
146
|
+
printf 'req-%s\n' "${prompt_name}"
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
# @brief Executes `scripts/debug-extension.ts` with wrapper defaults.
|
|
150
|
+
# @details Enters the repository root so the resolved `tsx` dependency and shared `node_modules` tree remain visible, prepends default `--cwd` and `--extension` values, and forwards all remaining arguments unchanged so later overrides win. Runtime is dominated by the delegated Node process. Side effects include spawning one subprocess.
|
|
151
|
+
# @param[in] ... {string[]} Debug-harness CLI tokens beginning with the target subcommand.
|
|
152
|
+
# @return {int} Exit status produced by the delegated Node process.
|
|
153
|
+
# @satisfies REQ-060, REQ-062
|
|
154
|
+
run_debug_extension() {
|
|
155
|
+
(
|
|
156
|
+
cd -- "${REPO_ROOT}"
|
|
157
|
+
"${TSX_BIN}" ./scripts/debug-extension.ts --cwd "${CALLER_CWD}" --extension "${DEFAULT_EXTENSION}" "$@"
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
# @brief Converts wrapper tool `--args` text into a JSON `--params` payload.
|
|
162
|
+
# @details Executes the repository-local TypeScript converter so shell callers can reuse the same structured tool-parameter mapping as the debug interface without hand-writing JSON. Runtime is dominated by the helper subprocess. Side effects include spawning one subprocess.
|
|
163
|
+
# @param[in] tool_name {string} Registered tool name.
|
|
164
|
+
# @param[in] args_text {string} Raw wrapper `--args` payload.
|
|
165
|
+
# @return {string} JSON object serialized on stdout.
|
|
166
|
+
# @satisfies REQ-065
|
|
167
|
+
build_tool_params_json() {
|
|
168
|
+
local tool_name="$1"
|
|
169
|
+
local args_text="${2-}"
|
|
170
|
+
(
|
|
171
|
+
cd -- "${REPO_ROOT}"
|
|
172
|
+
"${TSX_BIN}" ./scripts/tool-args-to-params.ts --name "${tool_name}" --args "${args_text}"
|
|
173
|
+
)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
# @brief Replays one tool subcommand with wrapper-level `--args` normalization.
|
|
177
|
+
# @details Preserves direct `--params` passthrough, rewrites wrapper `--args` values into JSON `--params` payloads, forwards unrelated debug-harness options unchanged, and keeps the legacy single-positional-JSON shortcut. Runtime is O(n) in forwarded argument count plus delegated subprocess cost. Side effects include stdout/stderr writes and subprocess execution.
|
|
178
|
+
# @param[in] tool_name {string} Registered tool name.
|
|
179
|
+
# @param[in] ... {string[]} Forwarded wrapper tokens after the tool name.
|
|
180
|
+
# @return {int} Exit status propagated from the delegated harness or local validation.
|
|
181
|
+
# @satisfies REQ-060, REQ-062, REQ-065
|
|
182
|
+
forward_tool_subcommand() {
|
|
183
|
+
local tool_name="$1"
|
|
184
|
+
shift
|
|
185
|
+
local -a forwarded=()
|
|
186
|
+
local saw_args=0
|
|
187
|
+
local saw_params=0
|
|
188
|
+
local option_value=""
|
|
189
|
+
local tool_params_json=""
|
|
190
|
+
|
|
191
|
+
if [[ $# -eq 0 ]]; then
|
|
192
|
+
run_debug_extension tool --name "${tool_name}" --params '{}'
|
|
193
|
+
return 0
|
|
194
|
+
fi
|
|
195
|
+
|
|
196
|
+
while [[ $# -gt 0 ]]; do
|
|
197
|
+
case "$1" in
|
|
198
|
+
--args)
|
|
199
|
+
if [[ ${saw_params} -eq 1 ]]; then
|
|
200
|
+
printf 'Error: tool subcommand cannot combine --args with --params.\n' >&2
|
|
201
|
+
return 1
|
|
202
|
+
fi
|
|
203
|
+
saw_args=1
|
|
204
|
+
option_value="${2-}"
|
|
205
|
+
tool_params_json="$(build_tool_params_json "${tool_name}" "${option_value}")" || return 1
|
|
206
|
+
forwarded+=("--params" "${tool_params_json}")
|
|
207
|
+
if [[ $# -ge 2 ]]; then
|
|
208
|
+
shift 2
|
|
209
|
+
else
|
|
210
|
+
shift
|
|
211
|
+
fi
|
|
212
|
+
;;
|
|
213
|
+
--params)
|
|
214
|
+
if [[ ${saw_args} -eq 1 ]]; then
|
|
215
|
+
printf 'Error: tool subcommand cannot combine --args with --params.\n' >&2
|
|
216
|
+
return 1
|
|
217
|
+
fi
|
|
218
|
+
saw_params=1
|
|
219
|
+
forwarded+=("$1")
|
|
220
|
+
if [[ $# -ge 2 ]]; then
|
|
221
|
+
forwarded+=("$2")
|
|
222
|
+
shift 2
|
|
223
|
+
else
|
|
224
|
+
forwarded+=("")
|
|
225
|
+
shift
|
|
226
|
+
fi
|
|
227
|
+
;;
|
|
228
|
+
*)
|
|
229
|
+
forwarded+=("$1")
|
|
230
|
+
shift
|
|
231
|
+
;;
|
|
232
|
+
esac
|
|
233
|
+
done
|
|
234
|
+
|
|
235
|
+
if [[ ${saw_args} -eq 1 || ${saw_params} -eq 1 ]] || contains_long_option "${forwarded[@]}"; then
|
|
236
|
+
run_debug_extension tool --name "${tool_name}" "${forwarded[@]}"
|
|
237
|
+
elif [[ ${#forwarded[@]} -eq 1 ]]; then
|
|
238
|
+
run_debug_extension tool --name "${tool_name}" --params "${forwarded[0]}"
|
|
239
|
+
else
|
|
240
|
+
printf 'Error: tool JSON must be one shell argument or use --args/--params.\n' >&2
|
|
241
|
+
return 1
|
|
242
|
+
fi
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
# @brief Validates that one required subcommand operand is present.
|
|
246
|
+
# @details Emits a deterministic stderr error when the caller omits a required positional name such as a command or tool identifier. Runtime is O(1). Side effect: writes to stderr on failure.
|
|
247
|
+
# @param[in] label {string} Human-readable operand label.
|
|
248
|
+
# @param[in] value {string} Operand value.
|
|
249
|
+
# @return {int} Shell status `0` when the operand exists; `1` otherwise.
|
|
250
|
+
require_value() {
|
|
251
|
+
local label="$1"
|
|
252
|
+
local value="${2-}"
|
|
253
|
+
if [[ -n "${value}" ]]; then
|
|
254
|
+
return 0
|
|
255
|
+
fi
|
|
256
|
+
printf 'Error: missing %s.\n' "${label}" >&2
|
|
257
|
+
return 1
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
# @brief Dispatches wrapper subcommands to the standalone TypeScript harness.
|
|
261
|
+
# @details Implements the convenience grammar documented by `print_usage`, including session and SDK aliases, prompt-name normalization, tool `--args` to `--params` rewriting, default tool params, and raw pass-through mode. Runtime is O(n) in wrapper argument count plus delegated harness cost. Side effects include stdout/stderr writes and subprocess execution.
|
|
262
|
+
# @param[in] ... {string[]} Wrapper CLI arguments excluding the script path.
|
|
263
|
+
# @return {int} Exit status propagated from the delegated harness or local validation.
|
|
264
|
+
# @satisfies REQ-060, REQ-061, REQ-062, REQ-065
|
|
265
|
+
main() {
|
|
266
|
+
local subcommand="${1-}"
|
|
267
|
+
if [[ $# -eq 0 ]]; then
|
|
268
|
+
print_usage
|
|
269
|
+
return 0
|
|
270
|
+
fi
|
|
271
|
+
shift
|
|
272
|
+
|
|
273
|
+
case "${subcommand}" in
|
|
274
|
+
help|-h|--help)
|
|
275
|
+
print_usage
|
|
276
|
+
;;
|
|
277
|
+
inspect)
|
|
278
|
+
run_debug_extension inspect "$@"
|
|
279
|
+
;;
|
|
280
|
+
session)
|
|
281
|
+
run_debug_extension session-start "$@"
|
|
282
|
+
;;
|
|
283
|
+
command)
|
|
284
|
+
local command_name="${1-}"
|
|
285
|
+
require_value "command name" "${command_name}" || return 1
|
|
286
|
+
shift
|
|
287
|
+
if [[ $# -eq 0 ]]; then
|
|
288
|
+
run_debug_extension command --name "${command_name}"
|
|
289
|
+
elif contains_exact_option --args "$@" || contains_long_option "$@"; then
|
|
290
|
+
run_debug_extension command --name "${command_name}" "$@"
|
|
291
|
+
else
|
|
292
|
+
run_debug_extension command --name "${command_name}" --args "$*"
|
|
293
|
+
fi
|
|
294
|
+
;;
|
|
295
|
+
prompt)
|
|
296
|
+
local prompt_name="${1-}"
|
|
297
|
+
local normalized_prompt_name
|
|
298
|
+
require_value "prompt name" "${prompt_name}" || return 1
|
|
299
|
+
normalized_prompt_name="$(normalize_prompt_name "${prompt_name}")"
|
|
300
|
+
shift
|
|
301
|
+
if [[ $# -eq 0 ]]; then
|
|
302
|
+
run_debug_extension command --name "${normalized_prompt_name}"
|
|
303
|
+
elif contains_exact_option --args "$@" || contains_long_option "$@"; then
|
|
304
|
+
run_debug_extension command --name "${normalized_prompt_name}" "$@"
|
|
305
|
+
else
|
|
306
|
+
run_debug_extension command --name "${normalized_prompt_name}" --args "$*"
|
|
307
|
+
fi
|
|
308
|
+
;;
|
|
309
|
+
tool)
|
|
310
|
+
local tool_name="${1-}"
|
|
311
|
+
require_value "tool name" "${tool_name}" || return 1
|
|
312
|
+
shift
|
|
313
|
+
forward_tool_subcommand "${tool_name}" "$@"
|
|
314
|
+
;;
|
|
315
|
+
sdk)
|
|
316
|
+
run_debug_extension sdk-smoke "$@"
|
|
317
|
+
;;
|
|
318
|
+
raw)
|
|
319
|
+
require_value "raw subcommand" "${1-}" || return 1
|
|
320
|
+
run_debug_extension "$@"
|
|
321
|
+
;;
|
|
322
|
+
*)
|
|
323
|
+
printf 'Error: unknown pi-usereq-debug subcommand: %s\n' "${subcommand}" >&2
|
|
324
|
+
print_usage >&2
|
|
325
|
+
return 1
|
|
326
|
+
;;
|
|
327
|
+
esac
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
main "$@"
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* @brief Converts pi-usereq-debug tool `--args` text into the JSON object expected by `--params`.
|
|
4
|
+
* @details Parses the wrapper-only tool-argument grammar, tokenizes shell-style text without invoking a shell, validates the argument shape for the current registered tool set, and emits one compact JSON object for `scripts/pi-usereq-debug.sh`. Runtime is O(n) in argument length. Side effects are limited to stdout and stderr writes.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import process from "node:process";
|
|
8
|
+
import { ReqError } from "../src/core/errors.js";
|
|
9
|
+
import { shellSplit } from "../src/core/utils.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @brief Describes the normalized CLI request consumed by the tool-argument converter.
|
|
13
|
+
* @details Captures the target tool name, raw `--args` text, and help-mode state for the standalone converter entrypoint. The interface is compile-time only and introduces no runtime side effects.
|
|
14
|
+
*/
|
|
15
|
+
interface ParsedToolArgsCli {
|
|
16
|
+
toolName?: string;
|
|
17
|
+
argsText: string;
|
|
18
|
+
help: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @brief Stores the standalone converter usage text.
|
|
23
|
+
* @details Provides a deterministic help payload for invalid or incomplete invocations of `scripts/tool-args-to-params.ts`. Access complexity is O(1).
|
|
24
|
+
*/
|
|
25
|
+
const USAGE_TEXT = `Usage: node --import tsx ./scripts/tool-args-to-params.ts --name <tool> --args <text>
|
|
26
|
+
|
|
27
|
+
Options:
|
|
28
|
+
--name <tool> Registered tool name.
|
|
29
|
+
--args <text> Raw pi-usereq-debug tool argument text.
|
|
30
|
+
--help Show this help text.
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @brief Parses CLI flags for the standalone tool-argument converter.
|
|
35
|
+
* @details Performs one left-to-right scan, records the last `--name` and `--args` values, and ignores unrelated tokens so the wrapper can compose deterministic invocations. Runtime is O(n) in argument count. No external state is mutated.
|
|
36
|
+
* @param[in] argv {string[]} Raw CLI arguments excluding executable and script path.
|
|
37
|
+
* @return {ParsedToolArgsCli} Parsed converter request.
|
|
38
|
+
*/
|
|
39
|
+
function parseCliArgs(argv: string[]): ParsedToolArgsCli {
|
|
40
|
+
const parsed: ParsedToolArgsCli = {
|
|
41
|
+
argsText: "",
|
|
42
|
+
help: false,
|
|
43
|
+
};
|
|
44
|
+
let index = 0;
|
|
45
|
+
while (index < argv.length) {
|
|
46
|
+
const token = argv[index]!;
|
|
47
|
+
switch (token) {
|
|
48
|
+
case "--name":
|
|
49
|
+
parsed.toolName = argv[index + 1];
|
|
50
|
+
index += 2;
|
|
51
|
+
break;
|
|
52
|
+
case "--args":
|
|
53
|
+
parsed.argsText = argv[index + 1] ?? "";
|
|
54
|
+
index += 2;
|
|
55
|
+
break;
|
|
56
|
+
case "--help":
|
|
57
|
+
parsed.help = true;
|
|
58
|
+
index += 1;
|
|
59
|
+
break;
|
|
60
|
+
default:
|
|
61
|
+
index += 1;
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return parsed;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @brief Removes one boolean flag from a shell-token array.
|
|
70
|
+
* @details Preserves token order for all non-matching items and reports whether the requested flag appeared at least once. Runtime is O(n) in token count. No external state is mutated.
|
|
71
|
+
* @param[in] tokens {string[]} Tokenized `--args` payload.
|
|
72
|
+
* @param[in] flag {string} Flag token to remove.
|
|
73
|
+
* @return {{ tokens: string[]; present: boolean }} Remaining tokens plus presence marker.
|
|
74
|
+
*/
|
|
75
|
+
function takeBooleanFlag(tokens: string[], flag: string): { tokens: string[]; present: boolean } {
|
|
76
|
+
const remaining: string[] = [];
|
|
77
|
+
let present = false;
|
|
78
|
+
for (const token of tokens) {
|
|
79
|
+
if (token === flag) {
|
|
80
|
+
present = true;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
remaining.push(token);
|
|
84
|
+
}
|
|
85
|
+
return { tokens: remaining, present };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @brief Converts one pi-usereq-debug tool `--args` string into a tool-parameter object.
|
|
90
|
+
* @details Tokenizes shell-style text with `shellSplit`, applies tool-specific positional and flag mappings, and rejects unsupported or structurally incomplete argument layouts before wrapper forwarding. Runtime is O(n) in token count. No external state is mutated.
|
|
91
|
+
* @param[in] toolName {string} Registered tool name selected by `scripts/pi-usereq-debug.sh`.
|
|
92
|
+
* @param[in] argsText {string} Raw wrapper `--args` payload.
|
|
93
|
+
* @return {Record<string, unknown>} JSON-serializable tool-parameter object compatible with `--params`.
|
|
94
|
+
* @throws {ReqError} Throws when the selected tool has no supported `--args` mapping or when the token layout is invalid.
|
|
95
|
+
* @satisfies REQ-065
|
|
96
|
+
*/
|
|
97
|
+
export function buildToolParamsFromArgsText(toolName: string, argsText: string): Record<string, unknown> {
|
|
98
|
+
const tokens = shellSplit(argsText);
|
|
99
|
+
switch (toolName) {
|
|
100
|
+
case "git-path":
|
|
101
|
+
case "get-base-path":
|
|
102
|
+
case "references":
|
|
103
|
+
case "tokens":
|
|
104
|
+
case "static-check":
|
|
105
|
+
case "git-check":
|
|
106
|
+
case "docs-check":
|
|
107
|
+
case "git-wt-name":
|
|
108
|
+
if (tokens.length !== 0) {
|
|
109
|
+
throw new ReqError(`Error: tool ${toolName} does not accept --args values.`, 1);
|
|
110
|
+
}
|
|
111
|
+
return {};
|
|
112
|
+
case "files-tokens":
|
|
113
|
+
case "files-references":
|
|
114
|
+
case "files-static-check":
|
|
115
|
+
return { files: tokens };
|
|
116
|
+
case "files-compress": {
|
|
117
|
+
const { tokens: remaining, present } = takeBooleanFlag(tokens, "--enable-line-numbers");
|
|
118
|
+
return present ? { files: remaining, enableLineNumbers: true } : { files: remaining };
|
|
119
|
+
}
|
|
120
|
+
case "files-find": {
|
|
121
|
+
const { tokens: remaining, present } = takeBooleanFlag(tokens, "--enable-line-numbers");
|
|
122
|
+
if (remaining.length < 3) {
|
|
123
|
+
throw new ReqError("Error: tool files-find requires <tag> <pattern> <file...> in --args text.", 1);
|
|
124
|
+
}
|
|
125
|
+
const [tag, pattern, ...files] = remaining;
|
|
126
|
+
return present ? { tag, pattern, files, enableLineNumbers: true } : { tag, pattern, files };
|
|
127
|
+
}
|
|
128
|
+
case "compress": {
|
|
129
|
+
const { tokens: remaining, present } = takeBooleanFlag(tokens, "--enable-line-numbers");
|
|
130
|
+
if (remaining.length !== 0) {
|
|
131
|
+
throw new ReqError("Error: tool compress accepts only --enable-line-numbers in --args text.", 1);
|
|
132
|
+
}
|
|
133
|
+
return present ? { enableLineNumbers: true } : {};
|
|
134
|
+
}
|
|
135
|
+
case "find": {
|
|
136
|
+
const { tokens: remaining, present } = takeBooleanFlag(tokens, "--enable-line-numbers");
|
|
137
|
+
if (remaining.length !== 2) {
|
|
138
|
+
throw new ReqError("Error: tool find requires <tag> <pattern> in --args text.", 1);
|
|
139
|
+
}
|
|
140
|
+
const [tag, pattern] = remaining;
|
|
141
|
+
return present ? { tag, pattern, enableLineNumbers: true } : { tag, pattern };
|
|
142
|
+
}
|
|
143
|
+
case "git-wt-create":
|
|
144
|
+
case "git-wt-delete":
|
|
145
|
+
if (tokens.length !== 1) {
|
|
146
|
+
throw new ReqError(`Error: tool ${toolName} requires exactly one wtName value in --args text.`, 1);
|
|
147
|
+
}
|
|
148
|
+
return { wtName: tokens[0] };
|
|
149
|
+
default:
|
|
150
|
+
throw new ReqError(`Error: unsupported --args conversion for tool ${toolName}. Use --params with JSON.`, 1);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @brief Writes non-empty text to stdout.
|
|
156
|
+
* @details Skips zero-length payloads so callers can compose CLI output without duplicate blank writes. Runtime is O(n) in text length. Side effects are limited to stdout writes.
|
|
157
|
+
* @param[in] text {string} Text payload.
|
|
158
|
+
* @return {void} No return value.
|
|
159
|
+
*/
|
|
160
|
+
function writeStdout(text: string): void {
|
|
161
|
+
if (text.length > 0) {
|
|
162
|
+
process.stdout.write(text);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* @brief Writes non-empty text to stderr with a trailing newline.
|
|
168
|
+
* @details Appends a newline when absent and suppresses zero-length payloads. Runtime is O(n) in text length. Side effects are limited to stderr writes.
|
|
169
|
+
* @param[in] text {string} Text payload.
|
|
170
|
+
* @return {void} No return value.
|
|
171
|
+
*/
|
|
172
|
+
function writeStderr(text: string): void {
|
|
173
|
+
if (text.length === 0) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
process.stderr.write(text.endsWith("\n") ? text : `${text}\n`);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @brief Executes one standalone tool-argument conversion request.
|
|
181
|
+
* @details Parses converter CLI flags, validates the presence of `--name`, transforms wrapper `--args` text into a JSON object, and writes the serialized payload for shell consumption while converting `ReqError` failures into stderr plus exit codes. Runtime is O(n) in argument length. Side effects are limited to stdout and stderr writes.
|
|
182
|
+
* @param[in] argv {string[]} Raw CLI arguments. Defaults to `process.argv.slice(2)`.
|
|
183
|
+
* @return {Promise<number>} Process exit code.
|
|
184
|
+
* @throws {ReqError} Internally catches `ReqError` and returns its exit code.
|
|
185
|
+
* @satisfies REQ-065
|
|
186
|
+
*/
|
|
187
|
+
export async function main(argv = process.argv.slice(2)): Promise<number> {
|
|
188
|
+
try {
|
|
189
|
+
const args = parseCliArgs(argv);
|
|
190
|
+
if (args.help || !args.toolName) {
|
|
191
|
+
writeStdout(USAGE_TEXT);
|
|
192
|
+
return 0;
|
|
193
|
+
}
|
|
194
|
+
const params = buildToolParamsFromArgsText(args.toolName, args.argsText);
|
|
195
|
+
writeStdout(`${JSON.stringify(params)}\n`);
|
|
196
|
+
return 0;
|
|
197
|
+
} catch (error) {
|
|
198
|
+
const reqError = error as ReqError;
|
|
199
|
+
writeStderr(reqError.message ?? String(error));
|
|
200
|
+
return reqError.code ?? 1;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
205
|
+
void main().then((code) => {
|
|
206
|
+
process.exitCode = code;
|
|
207
|
+
});
|
|
208
|
+
}
|