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,319 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* @brief Finds named language constructs in explicit source-file lists and renders compact excerpts.
|
|
4
|
+
* @details Combines source analysis, tag filtering, regex name matching, optional Doxygen extraction, and comment-stripped code rendering. Runtime is O(F + S + M) where F is file count, S is analyzed source size, and M is candidate element count. Side effects are limited to filesystem reads and optional stderr logging.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import fs from "node:fs";
|
|
8
|
+
import { compressSource, detectLanguage } from "./compress.js";
|
|
9
|
+
import { formatDoxygenFieldsAsMarkdown, parseDoxygenComment } from "./doxygen-parser.js";
|
|
10
|
+
import { SourceAnalyzer, SourceElement, ElementType } from "./source-analyzer.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @brief Maps each supported language to the construct tags that can be queried.
|
|
14
|
+
* @details The table bounds user tag filters to constructs the analyzer can detect for each language. Membership checks are O(1) because each language entry stores a `Set<string>`.
|
|
15
|
+
*/
|
|
16
|
+
export const LANGUAGE_TAGS: Record<string, Set<string>> = {
|
|
17
|
+
python: new Set(["CLASS", "FUNCTION", "DECORATOR", "IMPORT", "VARIABLE"]),
|
|
18
|
+
c: new Set(["STRUCT", "UNION", "ENUM", "TYPEDEF", "MACRO", "FUNCTION", "IMPORT", "VARIABLE"]),
|
|
19
|
+
cpp: new Set(["CLASS", "STRUCT", "ENUM", "NAMESPACE", "FUNCTION", "MACRO", "IMPORT", "TYPE_ALIAS"]),
|
|
20
|
+
rust: new Set(["FUNCTION", "STRUCT", "ENUM", "TRAIT", "IMPL", "MODULE", "MACRO", "CONSTANT", "TYPE_ALIAS", "IMPORT", "DECORATOR"]),
|
|
21
|
+
javascript: new Set(["CLASS", "FUNCTION", "COMPONENT", "CONSTANT", "IMPORT", "MODULE"]),
|
|
22
|
+
typescript: new Set(["INTERFACE", "TYPE_ALIAS", "ENUM", "CLASS", "FUNCTION", "NAMESPACE", "MODULE", "IMPORT", "DECORATOR"]),
|
|
23
|
+
java: new Set(["CLASS", "INTERFACE", "ENUM", "FUNCTION", "IMPORT", "MODULE", "DECORATOR", "CONSTANT"]),
|
|
24
|
+
go: new Set(["FUNCTION", "METHOD", "STRUCT", "INTERFACE", "TYPE_ALIAS", "CONSTANT", "IMPORT", "MODULE"]),
|
|
25
|
+
ruby: new Set(["CLASS", "MODULE", "FUNCTION", "CONSTANT", "IMPORT", "DECORATOR"]),
|
|
26
|
+
php: new Set(["CLASS", "INTERFACE", "TRAIT", "FUNCTION", "NAMESPACE", "IMPORT", "CONSTANT"]),
|
|
27
|
+
swift: new Set(["CLASS", "STRUCT", "ENUM", "PROTOCOL", "EXTENSION", "FUNCTION", "IMPORT", "CONSTANT", "VARIABLE"]),
|
|
28
|
+
kotlin: new Set(["CLASS", "INTERFACE", "ENUM", "FUNCTION", "CONSTANT", "VARIABLE", "MODULE", "IMPORT", "DECORATOR"]),
|
|
29
|
+
scala: new Set(["CLASS", "TRAIT", "MODULE", "FUNCTION", "CONSTANT", "VARIABLE", "TYPE_ALIAS", "IMPORT"]),
|
|
30
|
+
lua: new Set(["FUNCTION", "VARIABLE"]),
|
|
31
|
+
shell: new Set(["FUNCTION", "VARIABLE", "IMPORT"]),
|
|
32
|
+
perl: new Set(["FUNCTION", "MODULE", "IMPORT", "CONSTANT"]),
|
|
33
|
+
haskell: new Set(["MODULE", "TYPE_ALIAS", "STRUCT", "CLASS", "FUNCTION", "IMPORT"]),
|
|
34
|
+
zig: new Set(["FUNCTION", "STRUCT", "ENUM", "UNION", "CONSTANT", "VARIABLE", "IMPORT"]),
|
|
35
|
+
elixir: new Set(["MODULE", "FUNCTION", "PROTOCOL", "IMPL", "STRUCT", "IMPORT"]),
|
|
36
|
+
csharp: new Set(["CLASS", "INTERFACE", "STRUCT", "ENUM", "NAMESPACE", "FUNCTION", "PROPERTY", "IMPORT", "DECORATOR", "CONSTANT"]),
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @brief Formats the supported tag matrix for user-facing error messages.
|
|
41
|
+
* @details Sorts languages alphabetically and emits one bullet per language containing its sorted construct tags. Runtime is O(l * t log t). No side effects occur.
|
|
42
|
+
* @return {string} Multiline markdown-like tag summary.
|
|
43
|
+
*/
|
|
44
|
+
export function formatAvailableTags(): string {
|
|
45
|
+
return Object.keys(LANGUAGE_TAGS)
|
|
46
|
+
.sort()
|
|
47
|
+
.map((language) => `- ${language.charAt(0).toUpperCase()}${language.slice(1)}: ${[...LANGUAGE_TAGS[language]!].sort().join(", ")}`)
|
|
48
|
+
.join("\n");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @brief Parses a pipe-delimited construct tag filter.
|
|
53
|
+
* @details Splits the raw filter on `|`, trims whitespace, uppercases entries, and removes empty tokens. Runtime is O(n) in input length. No side effects occur.
|
|
54
|
+
* @param[in] tagString {string} Raw pipe-delimited tag expression.
|
|
55
|
+
* @return {Set<string>} Normalized tag set.
|
|
56
|
+
*/
|
|
57
|
+
export function parseTagFilter(tagString: string): Set<string> {
|
|
58
|
+
return new Set(
|
|
59
|
+
tagString
|
|
60
|
+
.split("|")
|
|
61
|
+
.map((tag) => tag.trim().toUpperCase())
|
|
62
|
+
.filter(Boolean),
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @brief Tests whether a language supports at least one requested tag.
|
|
68
|
+
* @details Performs O(k) membership checks across the requested tag set against the language-specific supported-tag set. No external state is mutated.
|
|
69
|
+
* @param[in] language {string} Canonical analyzer language identifier.
|
|
70
|
+
* @param[in] tagSet {Set<string>} Requested construct tags.
|
|
71
|
+
* @return {boolean} `true` when at least one requested tag is supported for the language.
|
|
72
|
+
*/
|
|
73
|
+
export function languageSupportsTags(language: string, tagSet: Set<string>): boolean {
|
|
74
|
+
const supported = LANGUAGE_TAGS[language] ?? new Set<string>();
|
|
75
|
+
return [...tagSet].some((tag) => supported.has(tag));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @brief Tests whether one analyzed element satisfies tag and name filters.
|
|
80
|
+
* @details Rejects elements whose type label is outside the requested tag set or that do not expose a name, then applies the user regex to the name. Invalid regex patterns are treated as non-matches. Runtime is O(p) for regex evaluation plus constant filtering work.
|
|
81
|
+
* @param[in] element {SourceElement} Candidate source element.
|
|
82
|
+
* @param[in] tagSet {Set<string>} Requested construct tags.
|
|
83
|
+
* @param[in] pattern {string} User-provided regular expression applied to element names.
|
|
84
|
+
* @return {boolean} `true` when the element matches both tag and name criteria.
|
|
85
|
+
*/
|
|
86
|
+
export function constructMatches(element: SourceElement, tagSet: Set<string>, pattern: string): boolean {
|
|
87
|
+
if (!tagSet.has(element.typeLabel)) return false;
|
|
88
|
+
if (!element.name) return false;
|
|
89
|
+
try {
|
|
90
|
+
return new RegExp(pattern).test(element.name);
|
|
91
|
+
} catch {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @brief Merges parsed Doxygen field arrays into one accumulator.
|
|
98
|
+
* @details Appends values for matching tags without deduplication so comment order is preserved. Runtime is O(v) in merged value count. The function mutates `baseFields` in place.
|
|
99
|
+
* @param[in,out] baseFields {Record<string, string[]>} Mutable destination map.
|
|
100
|
+
* @param[in] extraFields {Record<string, string[]>} Source map to append.
|
|
101
|
+
* @return {Record<string, string[]>} The mutated destination map.
|
|
102
|
+
*/
|
|
103
|
+
function mergeDoxygenFields(baseFields: Record<string, string[]>, extraFields: Record<string, string[]>): Record<string, string[]> {
|
|
104
|
+
Object.entries(extraFields).forEach(([tag, values]) => {
|
|
105
|
+
baseFields[tag] ??= [];
|
|
106
|
+
baseFields[tag].push(...values);
|
|
107
|
+
});
|
|
108
|
+
return baseFields;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @brief Collects Doxygen fields associated with one construct.
|
|
113
|
+
* @details Starts with fields already attached to the element and extends them with nearby body comments from the first three lines of the body. Runtime is O(c) in inspected comment count. No external state is mutated.
|
|
114
|
+
* @param[in] element {SourceElement} Source element whose documentation should be aggregated.
|
|
115
|
+
* @return {Record<string, string[]>} Aggregated Doxygen field map.
|
|
116
|
+
*/
|
|
117
|
+
function extractConstructDoxygenFields(element: SourceElement): Record<string, string[]> {
|
|
118
|
+
const aggregate: Record<string, string[]> = {};
|
|
119
|
+
if (element.doxygenFields) mergeDoxygenFields(aggregate, element.doxygenFields);
|
|
120
|
+
element.bodyComments.forEach((bodyComment) => {
|
|
121
|
+
const [commentLineStart, , commentText] = bodyComment;
|
|
122
|
+
if (commentLineStart > element.lineStart + 3) return;
|
|
123
|
+
const parsed = parseDoxygenComment(commentText);
|
|
124
|
+
if (Object.keys(parsed).length > 0) mergeDoxygenFields(aggregate, parsed);
|
|
125
|
+
});
|
|
126
|
+
return aggregate;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @brief Extracts file-level Doxygen fields from analyzed elements.
|
|
131
|
+
* @details Scans non-inline comment elements for an `@file` tag and returns the first parsed Doxygen map encountered in source order. Runtime is O(n). No side effects occur.
|
|
132
|
+
* @param[in] elements {SourceElement[]} Analyzed source elements.
|
|
133
|
+
* @return {Record<string, string[]>} Parsed file-level Doxygen field map, or an empty map when absent.
|
|
134
|
+
*/
|
|
135
|
+
function extractFileLevelDoxygenFields(elements: SourceElement[]): Record<string, string[]> {
|
|
136
|
+
const fileTagPattern = /(?<!\w)(?:@|\\)file\b/;
|
|
137
|
+
const commentElements = elements
|
|
138
|
+
.filter((element) => element.typeLabel === "COMMENT" && element.name !== "inline")
|
|
139
|
+
.sort((a, b) => (a.lineStart - b.lineStart) || (a.lineEnd - b.lineEnd));
|
|
140
|
+
for (const comment of commentElements) {
|
|
141
|
+
const text = comment.commentSource || comment.extract;
|
|
142
|
+
if (!text || !fileTagPattern.test(text)) continue;
|
|
143
|
+
return parseDoxygenComment(text);
|
|
144
|
+
}
|
|
145
|
+
return {};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @brief Describes one stripped-code line extracted from a matched construct.
|
|
150
|
+
* @details Preserves output order, original source coordinates, normalized stripped text, and rendered display text so markdown and JSON renderers can share one canonical intermediate format. The interface is compile-time only and introduces no runtime cost.
|
|
151
|
+
*/
|
|
152
|
+
export interface StrippedConstructLineEntry {
|
|
153
|
+
output_line_number: number;
|
|
154
|
+
source_line_number: number;
|
|
155
|
+
text: string;
|
|
156
|
+
display_text: string;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @brief Removes comments from a construct excerpt and returns structured stripped-code lines.
|
|
161
|
+
* @details Reuses `compressSource` for comment stripping, translates local compressed line numbers back into absolute file coordinates, and emits both direct-access text fields and rendered display strings. Runtime is O(n) in excerpt length. No external state is mutated.
|
|
162
|
+
* @param[in] codeLines {string[]} Raw code lines belonging to the construct.
|
|
163
|
+
* @param[in] language {string} Canonical analyzer language identifier.
|
|
164
|
+
* @param[in] lineStart {number} Absolute starting line number of the construct.
|
|
165
|
+
* @param[in] includeLineNumbers {boolean} When `true`, `display_text` includes absolute source line prefixes.
|
|
166
|
+
* @return {StrippedConstructLineEntry[]} Structured stripped-code line entries.
|
|
167
|
+
*/
|
|
168
|
+
export function buildStrippedConstructLineEntries(
|
|
169
|
+
codeLines: string[],
|
|
170
|
+
language: string,
|
|
171
|
+
lineStart: number,
|
|
172
|
+
includeLineNumbers: boolean,
|
|
173
|
+
): StrippedConstructLineEntry[] {
|
|
174
|
+
const rawSource = codeLines.join("");
|
|
175
|
+
const strippedWithLocalNumbers = compressSource(rawSource, language, true);
|
|
176
|
+
return strippedWithLocalNumbers
|
|
177
|
+
.split(/\r?\n/)
|
|
178
|
+
.filter((line) => line.length > 0)
|
|
179
|
+
.map((line, outputIndex) => {
|
|
180
|
+
const match = /^(\d+):\s(.*)$/.exec(line);
|
|
181
|
+
if (!match) {
|
|
182
|
+
return {
|
|
183
|
+
output_line_number: outputIndex + 1,
|
|
184
|
+
source_line_number: lineStart + outputIndex,
|
|
185
|
+
text: line,
|
|
186
|
+
display_text: line,
|
|
187
|
+
} satisfies StrippedConstructLineEntry;
|
|
188
|
+
}
|
|
189
|
+
const localLine = Number.parseInt(match[1]!, 10);
|
|
190
|
+
const absoluteLine = lineStart + localLine - 1;
|
|
191
|
+
const strippedText = match[2]!;
|
|
192
|
+
return {
|
|
193
|
+
output_line_number: outputIndex + 1,
|
|
194
|
+
source_line_number: absoluteLine,
|
|
195
|
+
text: strippedText,
|
|
196
|
+
display_text: includeLineNumbers ? `${absoluteLine}: ${strippedText}` : strippedText,
|
|
197
|
+
} satisfies StrippedConstructLineEntry;
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* @brief Removes comments from a construct excerpt while preserving optional absolute line numbers.
|
|
203
|
+
* @details Delegates to `buildStrippedConstructLineEntries(...)` and joins the rendered display strings into one newline-delimited excerpt. Runtime is O(n) in excerpt length. No external state is mutated.
|
|
204
|
+
* @param[in] codeLines {string[]} Raw code lines belonging to the construct.
|
|
205
|
+
* @param[in] language {string} Canonical analyzer language identifier.
|
|
206
|
+
* @param[in] lineStart {number} Absolute starting line number of the construct.
|
|
207
|
+
* @param[in] includeLineNumbers {boolean} When `true`, emit absolute source line prefixes.
|
|
208
|
+
* @return {string} Comment-stripped construct excerpt.
|
|
209
|
+
*/
|
|
210
|
+
function stripConstructComments(codeLines: string[], language: string, lineStart: number, includeLineNumbers: boolean): string {
|
|
211
|
+
return buildStrippedConstructLineEntries(codeLines, language, lineStart, includeLineNumbers)
|
|
212
|
+
.map((line) => line.display_text)
|
|
213
|
+
.join("\n");
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* @brief Formats one matched construct as markdown.
|
|
218
|
+
* @details Emits construct metadata, attached Doxygen fields, and a fenced code block stripped of comments. Runtime is O(n) in construct span length plus attached documentation size. No side effects occur.
|
|
219
|
+
* @param[in] element {SourceElement} Matched source element.
|
|
220
|
+
* @param[in] sourceLines {string[]} Full source file split into line-preserving entries.
|
|
221
|
+
* @param[in] includeLineNumbers {boolean} When `true`, include absolute source line prefixes.
|
|
222
|
+
* @param[in] language {string} Canonical analyzer language identifier. Defaults to `python`.
|
|
223
|
+
* @return {string} Markdown section for the matched construct.
|
|
224
|
+
*/
|
|
225
|
+
export function formatConstruct(element: SourceElement, sourceLines: string[], includeLineNumbers: boolean, language = "python"): string {
|
|
226
|
+
const lines: string[] = [];
|
|
227
|
+
lines.push(`### ${element.typeLabel}: \`${element.name}\``);
|
|
228
|
+
if (element.signature) lines.push(`> Signature: \`${element.signature}\``);
|
|
229
|
+
lines.push(`> Lines: ${element.lineStart}-${element.lineEnd}`);
|
|
230
|
+
const doxygenFields = extractConstructDoxygenFields(element);
|
|
231
|
+
if (Object.keys(doxygenFields).length > 0) {
|
|
232
|
+
lines.push(...formatDoxygenFieldsAsMarkdown(doxygenFields));
|
|
233
|
+
}
|
|
234
|
+
const codeLines = sourceLines.slice(element.lineStart - 1, element.lineEnd);
|
|
235
|
+
const formatted = stripConstructComments(codeLines, language, element.lineStart, includeLineNumbers);
|
|
236
|
+
lines.push("```");
|
|
237
|
+
lines.push(formatted);
|
|
238
|
+
lines.push("```");
|
|
239
|
+
return lines.join("\n");
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* @brief Finds named constructs across explicit files and renders markdown excerpts.
|
|
244
|
+
* @details Validates files, infers languages, skips unsupported tag/language combinations, analyzes source elements, filters matches by tag and regex, and emits one markdown section per file containing matches. Runtime is O(F + S + M). Side effects are limited to filesystem reads and optional stderr logging.
|
|
245
|
+
* @param[in] filePaths {string[]} Explicit file paths to search.
|
|
246
|
+
* @param[in] tagFilter {string} Pipe-delimited requested construct tags.
|
|
247
|
+
* @param[in] pattern {string} Regular expression applied to construct names.
|
|
248
|
+
* @param[in] includeLineNumbers {boolean} When `true`, preserve absolute source line numbers in code excerpts.
|
|
249
|
+
* @param[in] verbose {boolean} When `true`, write progress and skip diagnostics to stderr.
|
|
250
|
+
* @return {string} Concatenated markdown output grouped by file.
|
|
251
|
+
* @throws {Error} Throws when no valid tags are provided or when no constructs match the request.
|
|
252
|
+
*/
|
|
253
|
+
export function findConstructsInFiles(
|
|
254
|
+
filePaths: string[],
|
|
255
|
+
tagFilter: string,
|
|
256
|
+
pattern: string,
|
|
257
|
+
includeLineNumbers = true,
|
|
258
|
+
verbose = false,
|
|
259
|
+
): string {
|
|
260
|
+
const tagSet = parseTagFilter(tagFilter);
|
|
261
|
+
if (tagSet.size === 0) {
|
|
262
|
+
throw new Error(`No valid tags specified in tag filter.\n\nAvailable tags by language:\n${formatAvailableTags()}`);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const parts: string[] = [];
|
|
266
|
+
let okCount = 0;
|
|
267
|
+
let skipCount = 0;
|
|
268
|
+
let failCount = 0;
|
|
269
|
+
let totalMatches = 0;
|
|
270
|
+
|
|
271
|
+
for (const filePath of filePaths) {
|
|
272
|
+
if (!fs.existsSync(filePath) || !fs.statSync(filePath).isFile()) {
|
|
273
|
+
if (verbose) console.error(` SKIP ${filePath} (not found)`);
|
|
274
|
+
skipCount += 1;
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
const language = detectLanguage(filePath);
|
|
278
|
+
if (!language) {
|
|
279
|
+
if (verbose) console.error(` SKIP ${filePath} (unsupported extension)`);
|
|
280
|
+
skipCount += 1;
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
if (!languageSupportsTags(language, tagSet)) {
|
|
284
|
+
if (verbose) console.error(` SKIP ${filePath} (language ${language} does not support any requested tags)`);
|
|
285
|
+
skipCount += 1;
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
try {
|
|
290
|
+
const sourceLines = fs.readFileSync(filePath, "utf8").split(/(?<=\n)/);
|
|
291
|
+
const analyzer = new SourceAnalyzer();
|
|
292
|
+
const elements = analyzer.analyze(filePath, language);
|
|
293
|
+
analyzer.enrich(elements, language, filePath);
|
|
294
|
+
const matches = elements.filter((element) => constructMatches(element, tagSet, pattern));
|
|
295
|
+
if (matches.length > 0) {
|
|
296
|
+
const header = `@@@ ${filePath} | ${language}`;
|
|
297
|
+
const fileLevelDoxygen = extractFileLevelDoxygenFields(elements);
|
|
298
|
+
const fileLevelLines = Object.keys(fileLevelDoxygen).length > 0 ? formatDoxygenFieldsAsMarkdown(fileLevelDoxygen) : [];
|
|
299
|
+
const constructsMarkdown = matches.map((element) => formatConstruct(element, sourceLines, includeLineNumbers, language)).join("\n\n");
|
|
300
|
+
parts.push(fileLevelLines.length > 0 ? `${header}\n${fileLevelLines.join("\n")}\n\n${constructsMarkdown}` : `${header}\n\n${constructsMarkdown}`);
|
|
301
|
+
totalMatches += matches.length;
|
|
302
|
+
okCount += 1;
|
|
303
|
+
if (verbose) console.error(` OK ${filePath} (${matches.length} matches)`);
|
|
304
|
+
} else {
|
|
305
|
+
if (verbose) console.error(` SKIP ${filePath} (no matches)`);
|
|
306
|
+
skipCount += 1;
|
|
307
|
+
}
|
|
308
|
+
} catch (error) {
|
|
309
|
+
failCount += 1;
|
|
310
|
+
if (verbose) console.error(` FAIL ${filePath} (${error instanceof Error ? error.message : String(error)})`);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (parts.length === 0) {
|
|
315
|
+
throw new Error(`No constructs found matching the specified criteria.\n\nAvailable tags by language:\n${formatAvailableTags()}`);
|
|
316
|
+
}
|
|
317
|
+
if (verbose) console.error(`\n Found: ${totalMatches} constructs in ${okCount} files (${skipCount} skipped, ${failCount} failed)`);
|
|
318
|
+
return parts.join("\n\n");
|
|
319
|
+
}
|