Skip to content

Add shell command explainer - #75004

Merged
clawsweeper[bot] merged 5 commits into
mainfrom
feat/command-explainer-parser
May 3, 2026
Merged

clawsweeper[bot] merged 5 commits into
mainfrom
feat/command-explainer-parser

Conversation

@jesse-merhi

Copy link
Copy Markdown
Member

Summary

Adds an internal shell command explainer backed by web-tree-sitter and tree-sitter-bash.

The explainer can report:

  • top-level commands
  • nested commands in command/process substitutions
  • command shapes such as pipelines, chains, sequences, and conditionals
  • risk markers such as inline eval, shell wrappers, command carriers, dynamic executables, and eval

This PR intentionally does not hook the explainer into approval UI, allowlist, or allow-always decisions yet.

Testing

  • pnpm test src/infra/command-explainer/extract.test.ts
  • pnpm check:changed

@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Apr 30, 2026
@clawsweeper

clawsweeper Bot commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: passed.

Summary
The PR adds an internal Tree-sitter-backed shell command explainer under src/infra, parser runtime/tests, dependency/build-policy updates, an index export, and a changelog entry.

Reproducibility: not applicable. this is a feature PR rather than a bug report. For the prior PR blocker, source inspection shows byte-to-string span conversion and focused Unicode span coverage on the exact head.

Next step before merge
No repair job is needed; exact-head automerge and CI gates should handle the remaining merge decision.

Security
Cleared: The diff adds parser dependencies and build-policy entries, but no concrete secret, workflow-permission, publishing, or unintended lifecycle-script regression was found.

Review details

Best possible solution:

Land the internal explainer after the exact-head CI gate completes, leaving approval UI and allowlist integration for a later intentional PR.

Do we have a high-confidence way to reproduce the issue?

Not applicable; this is a feature PR rather than a bug report. For the prior PR blocker, source inspection shows byte-to-string span conversion and focused Unicode span coverage on the exact head.

Is this the best way to solve the issue?

Yes. The submitted approach keeps the parser isolated under src/infra, reuses existing wrapper and inline-eval helpers, and deliberately avoids changing approval decisions in this PR.

What I checked:

  • Exact PR head: GitHub API inspection showed the PR open, non-draft, mergeable, labeled maintainer and clawsweeper:automerge, at head 47577579e9043453c4df298ac7132c74b48c77b4 against current main e27b7c2d7446f869ee25993cf44f56d9ad0fe151. Current main has no command-explainer, explainShellCommand, web-tree-sitter, or tree-sitter-bash matches. (47577579e904)
  • Implementation surface: explainShellCommand parses bash source, walks the tree, returns top-level and nested commands, shapes, parse status, and risk records while deleting Tree-sitter trees after use. (src/infra/command-explainer/extract.ts:1170, 47577579e904)
  • Prior span blocker repaired: The exact head converts Tree-sitter byte offsets to JavaScript string indexes before exposing spans, including wrapper-payload span translation. (src/infra/command-explainer/extract.ts:180, 47577579e904)
  • Regression coverage: The added tests cover Unicode byte-index span conversion, escaped wrapper-payload spans, shell wrappers, command/process substitutions, dynamic executables, command carriers, syntax errors, and repeated parser use. (src/infra/command-explainer/extract.test.ts:210, 47577579e904)
  • Runtime hardening: The parser loader now clears cached rejections, resolves required wasm files with explainer-specific errors, limits source size, and distinguishes parse timeout from a generic null parse tree. (src/infra/command-explainer/tree-sitter-runtime.ts:64, 47577579e904)
  • Dependency contract: [email protected] types document Node.startIndex and Node.endIndex as byte indexes, matching the repaired conversion logic.

Likely related people:

  • steipete: Recent current-main history around shell-wrapper traversal, exec infra exports, and package/build policy is concentrated in Peter Steinberger commits that this explainer reuses. (role: recent maintainer and adjacent owner; confidence: high; commits: 0f1a938a3eec, 536e4f49bc39, 45dee50c2860; files: src/infra/shell-wrapper-resolution.ts, src/infra/exec-wrapper-resolution.ts, src/infra/dispatch-wrapper-resolution.ts)
  • vincentkoc: Recent current-main commits added dispatch-wrapper unwrapping behavior that the explainer calls for wrapper-through-carrier and inline-eval classification. (role: adjacent exec-wrapper maintainer; confidence: medium; commits: 730ba4076383, 9023a0436c3e; files: src/infra/dispatch-wrapper-resolution.ts, src/infra/shell-wrapper-resolution.ts)

Remaining risk / open question:

  • One exact-head CI check, check-additional-boundaries, was still in progress during this read-only review; final automerge should wait for the required check gate.

Codex review notes: model gpt-5.5, reasoning high; reviewed against e27b7c2d7446.

@jesse-merhi
jesse-merhi force-pushed the feat/command-explainer-parser branch from 0b309e4 to f4b4e1b Compare April 30, 2026 10:39
@jesse-merhi jesse-merhi self-assigned this Apr 30, 2026
@jesse-merhi
jesse-merhi force-pushed the feat/command-explainer-parser branch from f4b4e1b to d50b21c Compare April 30, 2026 17:26
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: L and removed size: M labels Apr 30, 2026
@jesse-merhi
jesse-merhi force-pushed the feat/command-explainer-parser branch from d50b21c to 5d15fed Compare May 2, 2026 00:51
@openclaw-barnacle openclaw-barnacle Bot removed the cli CLI command changes label May 2, 2026
@jesse-merhi
jesse-merhi force-pushed the feat/command-explainer-parser branch 3 times, most recently from 23da7d7 to d4b623d Compare May 3, 2026 01:50
@jesse-merhi
jesse-merhi force-pushed the feat/command-explainer-parser branch 2 times, most recently from 96befae to f523be0 Compare May 3, 2026 01:52
@jesse-merhi
jesse-merhi force-pushed the feat/command-explainer-parser branch 4 times, most recently from 14948e3 to 2a05b5b Compare May 3, 2026 03:28
@jesse-merhi
jesse-merhi marked this pull request as ready for review May 3, 2026 03:31
Copilot AI review requested due to automatic review settings May 3, 2026 03:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an internal shell command explainer module (tree-sitter-backed) to parse Bash-like command strings and extract command steps, structural “shapes”, and risk markers for future approval/command-review surfaces.

Changes:

  • Introduce src/infra/command-explainer with types, parser runtime (web-tree-sitter + tree-sitter-bash), and extraction/walk logic.
  • Add a comprehensive Vitest suite covering pipelines, substitutions, wrappers, carriers, dynamic tokens, redirects, and syntax errors.
  • Add dependencies (web-tree-sitter, tree-sitter-bash), pnpm build ignore config, and a changelog entry.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/infra/command-explainer/types.ts Defines public explanation output types (steps, shapes, risks, spans).
src/infra/command-explainer/tree-sitter-runtime.ts Loads/initializes the tree-sitter parser + wasm language and exposes parse helpers.
src/infra/command-explainer/index.ts Exports the explainer API and types as a module entry point.
src/infra/command-explainer/extract.ts Implements AST walk, argv extraction, span translation, and risk detection.
src/infra/command-explainer/extract.test.ts Adds functional coverage for parsing and risk/shape extraction, plus a perf-style test.
package.json Adds dependencies + pnpm ignoredBuiltDependencies entry for tree-sitter-bash.
pnpm-workspace.yaml Adds tree-sitter-bash to ignoredBuiltDependencies.
pnpm-lock.yaml Locks new dependencies and their transitive additions.
CHANGELOG.md Documents the new internal shell command explainer.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread src/infra/command-explainer/extract.ts Resolved
Comment thread src/infra/command-explainer/extract.ts Resolved
@jesse-merhi jesse-merhi closed this May 3, 2026
@jesse-merhi jesse-merhi reopened this May 3, 2026
@clawsweeper
clawsweeper Bot force-pushed the feat/command-explainer-parser branch from 940aa21 to 4757757 Compare May 3, 2026 06:01
@clawsweeper
clawsweeper Bot merged commit 207aa18 into main May 3, 2026
86 of 87 checks passed
@clawsweeper
clawsweeper Bot deleted the feat/command-explainer-parser branch May 3, 2026 06:05
lxe pushed a commit to lxe/openclaw that referenced this pull request May 6, 2026
Summary:
- The PR adds an internal Tree-sitter-backed shell command explainer under `src/infra`, parser runtime/tests, dependency/build-policy updates, an index export, and a changelog entry.
- Reproducibility: not applicable. this is a feature PR rather than a bug report. For the prior PR blocker, source inspection shows byte-to-string span conversion and focused Unicode span coverage on the exact head.

Automerge notes:
- Ran the ClawSweeper repair loop before final review.
- Included post-review commit in the final squash: Repair shell command explainer automerge blockers
- Included post-review commit in the final squash: fix(clawsweeper): address review for automerge-openclaw-openclaw-7500…

Validation:
- ClawSweeper review passed for head 4757757.
- Required merge gates passed before the squash merge.

Prepared head SHA: 4757757
Review: openclaw#75004 (comment)

Co-authored-by: Jesse Merhi <[email protected]>
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
markfietje pushed a commit to markfietje/openclaw that referenced this pull request May 20, 2026
Summary:
- The PR adds an internal Tree-sitter-backed shell command explainer under `src/infra`, parser runtime/tests, dependency/build-policy updates, an index export, and a changelog entry.
- Reproducibility: not applicable. this is a feature PR rather than a bug report. For the prior PR blocker, source inspection shows byte-to-string span conversion and focused Unicode span coverage on the exact head.

Automerge notes:
- Ran the ClawSweeper repair loop before final review.
- Included post-review commit in the final squash: Repair shell command explainer automerge blockers
- Included post-review commit in the final squash: fix(clawsweeper): address review for automerge-openclaw-openclaw-7500…

Validation:
- ClawSweeper review passed for head 47577579e9043453c4df298ac7132c74b48c77b4.
- Required merge gates passed before the squash merge.

Prepared head SHA: 47577579e9043453c4df298ac7132c74b48c77b4
Review: openclaw/openclaw#75004 (comment)

Co-authored-by: Jesse Merhi <[email protected]>
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
markfietje pushed a commit to markfietje/openclaw that referenced this pull request May 20, 2026
Summary:
- The PR adds an internal Tree-sitter-backed shell command explainer under `src/infra`, parser runtime/tests, dependency/build-policy updates, an index export, and a changelog entry.
- Reproducibility: not applicable. this is a feature PR rather than a bug report. For the prior PR blocker, source inspection shows byte-to-string span conversion and focused Unicode span coverage on the exact head.

Automerge notes:
- Ran the ClawSweeper repair loop before final review.
- Included post-review commit in the final squash: Repair shell command explainer automerge blockers
- Included post-review commit in the final squash: fix(clawsweeper): address review for automerge-openclaw-openclaw-7500…

Validation:
- ClawSweeper review passed for head 47577579e9043453c4df298ac7132c74b48c77b4.
- Required merge gates passed before the squash merge.

Prepared head SHA: 47577579e9043453c4df298ac7132c74b48c77b4
Review: openclaw/openclaw#75004 (comment)

Co-authored-by: Jesse Merhi <[email protected]>
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
Summary:
- The PR adds an internal Tree-sitter-backed shell command explainer under `src/infra`, parser runtime/tests, dependency/build-policy updates, an index export, and a changelog entry.
- Reproducibility: not applicable. this is a feature PR rather than a bug report. For the prior PR blocker, source inspection shows byte-to-string span conversion and focused Unicode span coverage on the exact head.

Automerge notes:
- Ran the ClawSweeper repair loop before final review.
- Included post-review commit in the final squash: Repair shell command explainer automerge blockers
- Included post-review commit in the final squash: fix(clawsweeper): address review for automerge-openclaw-openclaw-7500…

Validation:
- ClawSweeper review passed for head 4757757.
- Required merge gates passed before the squash merge.

Prepared head SHA: 4757757
Review: openclaw#75004 (comment)

Co-authored-by: Jesse Merhi <[email protected]>
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
Summary:
- The PR adds an internal Tree-sitter-backed shell command explainer under `src/infra`, parser runtime/tests, dependency/build-policy updates, an index export, and a changelog entry.
- Reproducibility: not applicable. this is a feature PR rather than a bug report. For the prior PR blocker, source inspection shows byte-to-string span conversion and focused Unicode span coverage on the exact head.

Automerge notes:
- Ran the ClawSweeper repair loop before final review.
- Included post-review commit in the final squash: Repair shell command explainer automerge blockers
- Included post-review commit in the final squash: fix(clawsweeper): address review for automerge-openclaw-openclaw-7500…

Validation:
- ClawSweeper review passed for head 4757757.
- Required merge gates passed before the squash merge.

Prepared head SHA: 4757757
Review: openclaw#75004 (comment)

Co-authored-by: Jesse Merhi <[email protected]>
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
Summary:
- The PR adds an internal Tree-sitter-backed shell command explainer under `src/infra`, parser runtime/tests, dependency/build-policy updates, an index export, and a changelog entry.
- Reproducibility: not applicable. this is a feature PR rather than a bug report. For the prior PR blocker, source inspection shows byte-to-string span conversion and focused Unicode span coverage on the exact head.

Automerge notes:
- Ran the ClawSweeper repair loop before final review.
- Included post-review commit in the final squash: Repair shell command explainer automerge blockers
- Included post-review commit in the final squash: fix(clawsweeper): address review for automerge-openclaw-openclaw-7500…

Validation:
- ClawSweeper review passed for head 4757757.
- Required merge gates passed before the squash merge.

Prepared head SHA: 4757757
Review: openclaw#75004 (comment)

Co-authored-by: Jesse Merhi <[email protected]>
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
zeekay pushed a commit to hanzoai/bot that referenced this pull request Sep 11, 2026
Summary:
- The PR adds an internal Tree-sitter-backed shell command explainer under `src/infra`, parser runtime/tests, dependency/build-policy updates, an index export, and a changelog entry.
- Reproducibility: not applicable. this is a feature PR rather than a bug report. For the prior PR blocker, source inspection shows byte-to-string span conversion and focused Unicode span coverage on the exact head.

Automerge notes:
- Ran the ClawSweeper repair loop before final review.
- Included post-review commit in the final squash: Repair shell command explainer automerge blockers
- Included post-review commit in the final squash: fix(clawsweeper): address review for automerge-openclaw-openclaw-7500…

Validation:
- ClawSweeper review passed for head 47577579e9043453c4df298ac7132c74b48c77b4.
- Required merge gates passed before the squash merge.

Prepared head SHA: 47577579e9043453c4df298ac7132c74b48c77b4
Review: openclaw/openclaw#75004 (comment)

Co-authored-by: Jesse Merhi <[email protected]>
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
zeekay pushed a commit to hanzoai/bot that referenced this pull request Sep 11, 2026
Summary:
- The PR adds an internal Tree-sitter-backed shell command explainer under `src/infra`, parser runtime/tests, dependency/build-policy updates, an index export, and a changelog entry.
- Reproducibility: not applicable. this is a feature PR rather than a bug report. For the prior PR blocker, source inspection shows byte-to-string span conversion and focused Unicode span coverage on the exact head.

Automerge notes:
- Ran the ClawSweeper repair loop before final review.
- Included post-review commit in the final squash: Repair shell command explainer automerge blockers
- Included post-review commit in the final squash: fix(clawsweeper): address review for automerge-openclaw-openclaw-7500…

Validation:
- ClawSweeper review passed for head 47577579e9043453c4df298ac7132c74b48c77b4.
- Required merge gates passed before the squash merge.

Prepared head SHA: 47577579e9043453c4df298ac7132c74b48c77b4
Review: openclaw/openclaw#75004 (comment)

Co-authored-by: Jesse Merhi <[email protected]>
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants