feat(aiagents): detect package install in compound shell commands#89
Open
raysubham wants to merge 1 commit into
Open
feat(aiagents): detect package install in compound shell commands#89raysubham wants to merge 1 commit into
raysubham wants to merge 1 commit into
Conversation
The npm enricher classified a command by its first token only, so compound shells like `cd /repo && pnpm install && pnpm run build` were missed because `cd` is not a package manager. Split the command on unquoted shell separators (`&&`, `||`, `;`, `|`, `&`, newline) into segments, classify each, and pick the strongest detection (install > uninstall > publish > audit > exec > other). Quotes and backslash escapes are respected so operators inside string literals do not cause false splits.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cd /repo && pnpm install && pnpm run buildwere never flagged as a package install step (the first token iscd).Detectnow splits the command on unquoted shell separators (&&,||,;,|,&, newline) into segments, classifies each segment independently with the existing per-segment logic, and returns the strongest detection (install > uninstall > publish > audit > exec > other). Quotes and backslash escapes are respected so operators inside string literals do not cause false splits.npx/bunx/pnpm dlx— only the outer fetcher in a segment is emitted, no double-emission of the inner install.Notes
ShellEnrichment.WorkingDirectoryand thecwdpassed to enrichment continue to record the shell's origin directory, not any effective directory after acdsegment. That is intentional and out of scope here; lockfile / registry / npm-config evidence is still resolved against the origin cwd.Test plan
go test ./internal/aiagents/enrich/npm/...(existing single-segment cases plus new compound-command coverage).go build ./...gofmt -l internal/aiagents/enrich/npm/clean.cdandpnpm install.