Aaronontheweb / Aaronontheweb/ShellSyntaxTree

Support structured control flow (loops) in Bash and PowerShell grammars

オープン
#71 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

enhancement
主要言語
C#
スター
15
フォーク
0
平均マージ
9分
マージ済み PR(30日)
7

説明

Problem

SPEC.md section 4 states v0.1 does not support control-flow keywords. for, while, do, done, then, fi, case, and esac set IsUnparseable = true.

The grammar is flat:

command := clause (compound_op clause)*

This is load-bearing for real consumers. NetClaw's shell approval gate walks parsed clauses to decide authorization. Commands that hit IsUnparseable fail closed to an approval prompt.

Why it matters

LLM agents emit loops and heredocs constantly. A production corpus of 45 approval-prompted shell commands showed 8 (18%) were for loops, heredocs, or process substitution. All tripped IsUnparseable.

Loops are static constructs. for f in *.txt; do rm "$f"; done does not hide a path behind $(). The approval risk is the body clause (rm). The existing clause model already evaluates that.

Request

Support structured control flow in both grammars:

  • Bash: for / while / until / if / case with do / done / then / else / fi / esac
  • PowerShell: foreach / for / while / do / if / switch

Design intent: parse the loop header and expose body clauses as child clauses in the AST. The loop keyword adds no authorization scope. Consumers (approval gates) can walk body clauses with the same logic they use for && chains.

Priority

Corpus-based order for Bash: for loops first, then heredocs, then while / if. Also consider arithmetic expansion $(( ... )), which the same spec line excludes.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

SPEC.md のセクション 4 と、Bash および PowerShell の既存のフラットなコマンド/句文法から始めます。IsUnparseable がどのように設定されるか、また AST が句をどのように公開するかを追跡し、そのうえで、一覧にある構造化構文が、approval-gate コンシューマーが IsUnparseable を発生させずに走査できる子の body 句を生成することを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
bash, csharp, powershell
領域
compilers
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。