start-command 0.7.4 → 0.7.6
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/CHANGELOG.md +25 -0
- package/README.md +23 -0
- package/docs/PIPES.md +243 -0
- package/docs/USAGE.md +194 -0
- package/docs/case-studies/issue-25/README.md +25 -18
- package/docs/case-studies/issue-28/README.md +405 -0
- package/docs/case-studies/issue-28/issue-data.json +105 -0
- package/docs/case-studies/issue-28/raw-issue-data.md +92 -0
- package/experiments/screen-output-test.js +265 -0
- package/package.json +1 -1
- package/src/bin/cli.js +10 -0
- package/src/lib/isolation.js +15 -43
- package/test/isolation.test.js +27 -0
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
# Case Study: Issue #28 - Shell Quoting with Pipe Operator
|
|
2
|
+
|
|
3
|
+
## Issue Summary
|
|
4
|
+
|
|
5
|
+
**Issue URL:** https://github.com/link-foundation/start/issues/28
|
|
6
|
+
**Date Reported:** 2025-12-24
|
|
7
|
+
**Reporter:** @konard
|
|
8
|
+
**Labels:** bug, documentation, enhancement, question
|
|
9
|
+
**Status:** Under Analysis
|
|
10
|
+
|
|
11
|
+
### Problem Statement
|
|
12
|
+
|
|
13
|
+
When using the `$` command (start-command) with pipe operators (`|`) and double quotes (`"`) in the command, users need to wrap the entire command in single quotes to get the expected behavior. Without the quotes, the shell parses the pipe operator **before** passing arguments to the `$` command.
|
|
14
|
+
|
|
15
|
+
**Example - Undesired behavior:**
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
$ echo "hi" | agent
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The shell interprets this as: "Run `$ echo "hi"` and pipe its output to `agent`"
|
|
22
|
+
|
|
23
|
+
**Example - Desired behavior (requires single quotes):**
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
$ 'echo "hi" | agent'
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The shell interprets this as: "Run `$` with the argument `echo "hi" | agent`"
|
|
30
|
+
|
|
31
|
+
### Environment
|
|
32
|
+
|
|
33
|
+
- **Platform:** macOS (darwin)
|
|
34
|
+
- **Package:** start-command (version assumed latest)
|
|
35
|
+
- **Shell:** /bin/zsh
|
|
36
|
+
- **Bun Version:** 1.2.20
|
|
37
|
+
- **Working Directory:** /Users/konard
|
|
38
|
+
|
|
39
|
+
## Timeline of Events
|
|
40
|
+
|
|
41
|
+
Based on the terminal logs provided in the issue:
|
|
42
|
+
|
|
43
|
+
### Timestamp 1: 15:07:08.894 - Unquoted Command
|
|
44
|
+
|
|
45
|
+
1. **User input:** `$ echo "hi" | agent`
|
|
46
|
+
2. **Shell parsing:** The shell parsed this as TWO separate commands:
|
|
47
|
+
- Command 1: `$ echo "hi"` (run `$` with argument `echo "hi"`)
|
|
48
|
+
- Pipe: `|` (pipe stdout of command 1 to stdin of command 2)
|
|
49
|
+
- Command 2: `agent` (run `agent` with stdin from pipe)
|
|
50
|
+
3. **Result:** The `$` command executed `echo "hi"` and logged it, showing:
|
|
51
|
+
```
|
|
52
|
+
Command: echo hi
|
|
53
|
+
Exit Code: 0
|
|
54
|
+
```
|
|
55
|
+
4. **What agent received:** The `agent` received the JSON output from the `$` command (status messages, tool use messages, etc.) via the pipe - NOT the original command.
|
|
56
|
+
5. **Agent's response:** The agent saw the log file and responded about the `echo hi` execution, not the "hi" message itself.
|
|
57
|
+
|
|
58
|
+
### Timestamp 2: 15:07:33.420 - Quoted Command
|
|
59
|
+
|
|
60
|
+
1. **User input:** `$ 'echo "hi" | agent'`
|
|
61
|
+
2. **Shell parsing:** The shell parsed this as ONE command:
|
|
62
|
+
- Command: `$` with a single argument: `echo "hi" | agent`
|
|
63
|
+
3. **Result:** The `$` command received the entire string and executed it as a pipeline
|
|
64
|
+
4. **What agent received:** The output of `echo "hi"` which is `hi`
|
|
65
|
+
5. **Agent's response:** "Hello! How can I help you today?" (responding to "hi" as input)
|
|
66
|
+
|
|
67
|
+
## Sequence Diagrams
|
|
68
|
+
|
|
69
|
+
### Scenario 1: Without Quotes (Problematic)
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
User Input: $ echo "hi" | agent
|
|
73
|
+
└───┬────┘ └──┬──┘
|
|
74
|
+
│ │
|
|
75
|
+
┌────────────┴───────────┴────────────┐
|
|
76
|
+
│ Shell (zsh/bash) │
|
|
77
|
+
│ Tokenizes command line into: │
|
|
78
|
+
│ Command 1: ['$', 'echo', '"hi"'] │
|
|
79
|
+
│ Operator: | │
|
|
80
|
+
│ Command 2: ['agent'] │
|
|
81
|
+
└────────────────────────────────────┘
|
|
82
|
+
│ │
|
|
83
|
+
┌────────────┴───┐ ┌───┴────────────┐
|
|
84
|
+
│ $ (start-cmd) │ │ agent │
|
|
85
|
+
│ executes: │──→│ receives: │
|
|
86
|
+
│ "echo hi" │ │ JSON output │
|
|
87
|
+
│ │ │ from $ cmd │
|
|
88
|
+
└────────────────┘ └────────────────┘
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Scenario 2: With Quotes (Desired)
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
User Input: $ 'echo "hi" | agent'
|
|
95
|
+
└─────────┬──────────┘
|
|
96
|
+
│
|
|
97
|
+
┌──────────────────┴──────────────────┐
|
|
98
|
+
│ Shell (zsh/bash) │
|
|
99
|
+
│ Tokenizes command line into: │
|
|
100
|
+
│ Command: ['$', 'echo "hi" | agent']
|
|
101
|
+
│ Single quotes prevent parsing │
|
|
102
|
+
└──────────────────────────────────────┘
|
|
103
|
+
│
|
|
104
|
+
┌──────────────────┴──────────────────┐
|
|
105
|
+
│ $ (start-command) │
|
|
106
|
+
│ Receives: "echo \"hi\" | agent" │
|
|
107
|
+
│ Spawns shell with: │
|
|
108
|
+
│ /bin/zsh -c 'echo "hi" | agent' │
|
|
109
|
+
│ │
|
|
110
|
+
│ ┌──────────┐ ┌─────────┐ │
|
|
111
|
+
│ │ echo "hi"│─────→│ agent │ │
|
|
112
|
+
│ │ stdout: │ │ stdin: │ │
|
|
113
|
+
│ │ "hi" │ │ "hi" │ │
|
|
114
|
+
│ └──────────┘ └─────────┘ │
|
|
115
|
+
└──────────────────────────────────────┘
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Root Cause Analysis
|
|
119
|
+
|
|
120
|
+
### PRIMARY ROOT CAUSE: Shell Grammar and Operator Precedence
|
|
121
|
+
|
|
122
|
+
The root cause is **not a bug in start-command** but rather a fundamental aspect of how POSIX shells parse command lines.
|
|
123
|
+
|
|
124
|
+
According to the [Bash Reference Manual - Pipelines](https://www.gnu.org/software/bash/manual/html_node/Pipelines.html):
|
|
125
|
+
|
|
126
|
+
> "A pipeline is a sequence of one or more commands separated by one of the control operators `|` or `|&`."
|
|
127
|
+
|
|
128
|
+
The shell's parsing order is:
|
|
129
|
+
|
|
130
|
+
1. **Tokenization:** The command line is split into tokens
|
|
131
|
+
2. **Operator Recognition:** Pipe (`|`), redirections (`>`, `<`), and logical operators (`&&`, `||`) are identified
|
|
132
|
+
3. **Command Grouping:** Commands are grouped based on operators
|
|
133
|
+
4. **Quote Processing:** Quotes affect tokenization but don't change operator recognition
|
|
134
|
+
|
|
135
|
+
### Why This Happens
|
|
136
|
+
|
|
137
|
+
When you type:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
$ echo "hi" | agent
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
The shell sees:
|
|
144
|
+
|
|
145
|
+
- `$` - a command (the start-command binary)
|
|
146
|
+
- `echo` - an argument to `$`
|
|
147
|
+
- `"hi"` - another argument to `$` (quotes are stripped by shell)
|
|
148
|
+
- `|` - **pipe operator** (this is a metacharacter, not an argument)
|
|
149
|
+
- `agent` - a separate command that receives piped input
|
|
150
|
+
|
|
151
|
+
The pipe operator has special meaning to the shell and is **never** passed as an argument to commands unless quoted or escaped.
|
|
152
|
+
|
|
153
|
+
### Single Quotes Behavior
|
|
154
|
+
|
|
155
|
+
From the [GNU Bash Reference - Quoting](https://www.gnu.org/software/bash/manual/html_node/Quoting.html):
|
|
156
|
+
|
|
157
|
+
> "Enclosing characters in single quotes (`'`) preserves the literal value of each character within the quotes."
|
|
158
|
+
|
|
159
|
+
This means:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
$ 'echo "hi" | agent'
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
The shell sees:
|
|
166
|
+
|
|
167
|
+
- `$` - a command
|
|
168
|
+
- `echo "hi" | agent` - a single string argument (the `|` inside is literal, not a pipe operator)
|
|
169
|
+
|
|
170
|
+
### Operator Precedence Summary
|
|
171
|
+
|
|
172
|
+
From [Shell Grammar Rules](https://bargenqua.st/posts/bash-pipes/):
|
|
173
|
+
|
|
174
|
+
1. Redirections (`<`, `>`, `>>`) - highest precedence
|
|
175
|
+
2. Pipes (`|`) - next highest
|
|
176
|
+
3. Command separators (`;`, `&`, `&&`, `||`) - lower precedence
|
|
177
|
+
|
|
178
|
+
## Impact Assessment
|
|
179
|
+
|
|
180
|
+
### Who Is Affected
|
|
181
|
+
|
|
182
|
+
Users who want to:
|
|
183
|
+
|
|
184
|
+
1. Pipe content **through** the `$` command to another command
|
|
185
|
+
2. Use the `$` command to execute complex pipelines
|
|
186
|
+
3. Use `$` as part of a larger shell pipeline
|
|
187
|
+
|
|
188
|
+
### Severity
|
|
189
|
+
|
|
190
|
+
**Low-Medium**: The current behavior is technically correct - it follows POSIX shell semantics. However, it may be unintuitive for users who expect the entire command line to be passed to the `$` command.
|
|
191
|
+
|
|
192
|
+
## Proposed Solutions
|
|
193
|
+
|
|
194
|
+
### Solution 1: Pipe TO `$` (Recommended - Preferred Approach)
|
|
195
|
+
|
|
196
|
+
Instead of quoting, put `$` on the **receiving** command in the pipeline:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
# Preferred - pipe TO the $-wrapped command
|
|
200
|
+
echo "hi" | $ agent
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
This works because:
|
|
204
|
+
|
|
205
|
+
1. The shell creates a pipeline: `echo "hi"` piped to `$ agent`
|
|
206
|
+
2. `$ agent` receives "hi" on stdin
|
|
207
|
+
3. The `$` command wraps `agent`, which processes the input correctly
|
|
208
|
+
|
|
209
|
+
**Pros:**
|
|
210
|
+
|
|
211
|
+
- No quoting needed
|
|
212
|
+
- Simple and intuitive
|
|
213
|
+
- Works naturally with shell pipelines
|
|
214
|
+
|
|
215
|
+
**Cons:**
|
|
216
|
+
|
|
217
|
+
- Only works when piping TO a command (not for entire pipelines)
|
|
218
|
+
|
|
219
|
+
### Solution 2: Documentation Enhancement (Also Recommended)
|
|
220
|
+
|
|
221
|
+
Add clear documentation explaining:
|
|
222
|
+
|
|
223
|
+
1. How shell parsing affects the `$` command
|
|
224
|
+
2. When to use quotes around complex commands
|
|
225
|
+
3. Examples of common use cases
|
|
226
|
+
|
|
227
|
+
**Pros:**
|
|
228
|
+
|
|
229
|
+
- No code changes required
|
|
230
|
+
- Educates users about shell behavior
|
|
231
|
+
- Maintains POSIX compliance
|
|
232
|
+
|
|
233
|
+
**Cons:**
|
|
234
|
+
|
|
235
|
+
- Requires users to learn quoting rules
|
|
236
|
+
- May still feel unintuitive
|
|
237
|
+
|
|
238
|
+
### Solution 3: Use a Multi-Character Command Name
|
|
239
|
+
|
|
240
|
+
Instead of `$`, use a multi-character name like `start` or `run`:
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
start 'echo "hi" | agent' # Still needs quotes
|
|
244
|
+
start echo "hi" | agent # Same issue
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
**Pros:**
|
|
248
|
+
|
|
249
|
+
- Less visual confusion with shell's `$` variable syntax
|
|
250
|
+
- Easier to google and document
|
|
251
|
+
|
|
252
|
+
**Cons:**
|
|
253
|
+
|
|
254
|
+
- Doesn't solve the fundamental issue
|
|
255
|
+
- Breaks backward compatibility
|
|
256
|
+
|
|
257
|
+
### Solution 4: Wrapper Script with Here-Document
|
|
258
|
+
|
|
259
|
+
Create an alternative invocation method:
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
$$ <<'CMD'
|
|
263
|
+
echo "hi" | agent
|
|
264
|
+
CMD
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
**Pros:**
|
|
268
|
+
|
|
269
|
+
- No quoting issues
|
|
270
|
+
- Can handle multi-line commands
|
|
271
|
+
- Clear visual separation
|
|
272
|
+
|
|
273
|
+
**Cons:**
|
|
274
|
+
|
|
275
|
+
- Requires new syntax
|
|
276
|
+
- More verbose for simple commands
|
|
277
|
+
|
|
278
|
+
### Solution 5: Shell Function Alternative
|
|
279
|
+
|
|
280
|
+
Provide a shell function that users can source:
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
# In ~/.zshrc or ~/.bashrc
|
|
284
|
+
run() {
|
|
285
|
+
$ "$*"
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
# Usage:
|
|
289
|
+
run echo "hi" | agent # Still has the same issue!
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
**Pros:**
|
|
293
|
+
|
|
294
|
+
- More conventional naming
|
|
295
|
+
|
|
296
|
+
**Cons:**
|
|
297
|
+
|
|
298
|
+
- **Does not solve the problem** - shell parsing happens before function call
|
|
299
|
+
|
|
300
|
+
### Solution 6: Interactive Mode Detection
|
|
301
|
+
|
|
302
|
+
When `$` detects it's being piped to/from, emit a warning:
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
$ echo "hi" | agent
|
|
306
|
+
# Warning: $ stdout is being piped. Did you mean: $ 'echo "hi" | agent'?
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
**Pros:**
|
|
310
|
+
|
|
311
|
+
- Helps users understand what's happening
|
|
312
|
+
- Non-breaking change
|
|
313
|
+
|
|
314
|
+
**Cons:**
|
|
315
|
+
|
|
316
|
+
- Adds noise to output
|
|
317
|
+
- May interfere with legitimate piping use cases
|
|
318
|
+
|
|
319
|
+
### Solution 7: ZSH Global Alias (ZSH Only)
|
|
320
|
+
|
|
321
|
+
ZSH supports [global aliases](https://vonheikemen.github.io/devlog/tools/zsh-global-aliases/) that expand anywhere in the command:
|
|
322
|
+
|
|
323
|
+
```zsh
|
|
324
|
+
# In ~/.zshrc
|
|
325
|
+
alias -g '|$'='| $' # Not helpful
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
**Analysis:** This doesn't solve the problem because the issue is with the **input** to `$`, not its output.
|
|
329
|
+
|
|
330
|
+
## Recommended Approach
|
|
331
|
+
|
|
332
|
+
After careful analysis, the **recommended approach is Solution 1: Pipe TO `$`** combined with documentation enhancement:
|
|
333
|
+
|
|
334
|
+
1. **Preferred syntax**: `echo "hi" | $ agent` - pipe TO the `$`-wrapped command
|
|
335
|
+
2. **Alternative**: `$ 'echo "hi" | agent'` - quote the entire pipeline when needed
|
|
336
|
+
3. **Documentation**: Clear docs explaining both approaches
|
|
337
|
+
|
|
338
|
+
### Implementation Plan
|
|
339
|
+
|
|
340
|
+
1. **Documentation (docs/PIPES.md)** - New file:
|
|
341
|
+
- Detailed explanation of pipe usage
|
|
342
|
+
- Preferred approach: piping TO `$`
|
|
343
|
+
- Alternative approach: quoting
|
|
344
|
+
- Examples and troubleshooting
|
|
345
|
+
|
|
346
|
+
2. **Documentation (docs/USAGE.md)**:
|
|
347
|
+
- Brief section on pipes with link to PIPES.md
|
|
348
|
+
- Updated examples showing preferred syntax
|
|
349
|
+
|
|
350
|
+
3. **README.md Update**:
|
|
351
|
+
- Add piping examples showing preferred syntax
|
|
352
|
+
- Link to detailed documentation
|
|
353
|
+
|
|
354
|
+
4. **CLI Help Update** (Future Enhancement):
|
|
355
|
+
- Add a note about piping in `$ --help`
|
|
356
|
+
|
|
357
|
+
5. **Optional Warning** (Future Enhancement):
|
|
358
|
+
- Detect if stdout is a pipe
|
|
359
|
+
- Detect if command doesn't contain pipe-like patterns
|
|
360
|
+
- Emit helpful warning
|
|
361
|
+
|
|
362
|
+
## Key Learnings
|
|
363
|
+
|
|
364
|
+
1. **Shell parsing is fundamental**: Metacharacters like `|`, `&`, `;` are processed by the shell before commands receive arguments. This is not something applications can change.
|
|
365
|
+
|
|
366
|
+
2. **Single quotes are your friend**: When you want literal characters, use single quotes. When you want variable expansion inside, use double quotes with escaped special characters.
|
|
367
|
+
|
|
368
|
+
3. **The `$` symbol is contextual**: In shells, `$` typically introduces variable expansion (`$HOME`, `$PATH`). Using it as a command name, while valid, can be visually confusing.
|
|
369
|
+
|
|
370
|
+
4. **Education over code changes**: Some issues are best solved by educating users rather than adding complex workarounds that might introduce new problems.
|
|
371
|
+
|
|
372
|
+
5. **POSIX compliance matters**: Shell behavior is standardized. Fighting against it often creates more problems than it solves.
|
|
373
|
+
|
|
374
|
+
## Related Research
|
|
375
|
+
|
|
376
|
+
### Shell Quoting Resources
|
|
377
|
+
|
|
378
|
+
- [GNU Bash Reference Manual - Quoting](https://www.gnu.org/software/bash/manual/html_node/Quoting.html)
|
|
379
|
+
- [GNU Bash Reference Manual - Pipelines](https://www.gnu.org/software/bash/manual/html_node/Pipelines.html)
|
|
380
|
+
- [Advanced Quoting in Shell Scripts](https://scriptingosx.com/2020/04/advanced-quoting-in-shell-scripts/)
|
|
381
|
+
- [ZSH Global Aliases](https://vonheikemen.github.io/devlog/tools/zsh-global-aliases/)
|
|
382
|
+
|
|
383
|
+
### Shell Parsing Order
|
|
384
|
+
|
|
385
|
+
1. Tokenization (splitting into words)
|
|
386
|
+
2. Command identification
|
|
387
|
+
3. Alias expansion (if applicable)
|
|
388
|
+
4. Brace expansion
|
|
389
|
+
5. Tilde expansion
|
|
390
|
+
6. Parameter/variable expansion
|
|
391
|
+
7. Command substitution
|
|
392
|
+
8. Arithmetic expansion
|
|
393
|
+
9. Word splitting
|
|
394
|
+
10. Filename expansion (globbing)
|
|
395
|
+
11. Quote removal
|
|
396
|
+
|
|
397
|
+
The pipe operator (`|`) is recognized during **step 1 (tokenization)**, before any command receives its arguments.
|
|
398
|
+
|
|
399
|
+
## References
|
|
400
|
+
|
|
401
|
+
- [Bash Reference Manual](https://www.gnu.org/software/bash/manual/bash.html)
|
|
402
|
+
- [ZSH Expansion and Substitution](https://zsh.sourceforge.io/Doc/Release/Expansion.html)
|
|
403
|
+
- [POSIX Shell Command Language](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html)
|
|
404
|
+
- [Issue #25 Case Study](../issue-25/README.md) - Related shell quoting issues
|
|
405
|
+
- [Baeldung - Special Dollar Sign Variables](https://www.baeldung.com/linux/shell-special-dollar-sign-variables)
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"issue": {
|
|
3
|
+
"number": 28,
|
|
4
|
+
"title": "Can we somehow overcome the need of `'` quotes with `|` and `\"` in a sequence?",
|
|
5
|
+
"url": "https://github.com/link-foundation/start/issues/28",
|
|
6
|
+
"state": "open",
|
|
7
|
+
"labels": ["bug", "documentation", "enhancement", "question"],
|
|
8
|
+
"author": "konard",
|
|
9
|
+
"created_at": "2025-12-24"
|
|
10
|
+
},
|
|
11
|
+
"environment": {
|
|
12
|
+
"platform": "darwin",
|
|
13
|
+
"shell": "/bin/zsh",
|
|
14
|
+
"bun_version": "1.2.20",
|
|
15
|
+
"working_directory": "/Users/konard"
|
|
16
|
+
},
|
|
17
|
+
"scenarios": [
|
|
18
|
+
{
|
|
19
|
+
"name": "unquoted_command",
|
|
20
|
+
"input": "$ echo \"hi\" | agent",
|
|
21
|
+
"timestamp": "2025-12-24 15:07:08.894",
|
|
22
|
+
"shell_interpretation": {
|
|
23
|
+
"command_1": "$ echo \"hi\"",
|
|
24
|
+
"operator": "|",
|
|
25
|
+
"command_2": "agent"
|
|
26
|
+
},
|
|
27
|
+
"actual_execution": {
|
|
28
|
+
"start_command_received": "echo \"hi\"",
|
|
29
|
+
"start_command_output": "hi",
|
|
30
|
+
"agent_received": "JSON output from start-command stdout"
|
|
31
|
+
},
|
|
32
|
+
"user_expectation": "agent should receive 'hi' from echo",
|
|
33
|
+
"actual_result": "agent received start-command JSON output",
|
|
34
|
+
"exit_code": 0
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "quoted_command",
|
|
38
|
+
"input": "$ 'echo \"hi\" | agent'",
|
|
39
|
+
"timestamp": "2025-12-24 15:07:33.420",
|
|
40
|
+
"shell_interpretation": {
|
|
41
|
+
"command": "$",
|
|
42
|
+
"argument": "echo \"hi\" | agent"
|
|
43
|
+
},
|
|
44
|
+
"actual_execution": {
|
|
45
|
+
"start_command_received": "echo \"hi\" | agent",
|
|
46
|
+
"pipeline_executed": true,
|
|
47
|
+
"echo_output": "hi",
|
|
48
|
+
"agent_received": "hi"
|
|
49
|
+
},
|
|
50
|
+
"user_expectation": "agent should receive 'hi' from echo",
|
|
51
|
+
"actual_result": "agent received 'hi' from echo",
|
|
52
|
+
"exit_code": 0
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
"root_cause": {
|
|
56
|
+
"category": "shell_parsing_behavior",
|
|
57
|
+
"is_bug": false,
|
|
58
|
+
"description": "The pipe operator (|) is a shell metacharacter that is parsed by the shell before command arguments are passed. This is standard POSIX shell behavior, not a bug in start-command.",
|
|
59
|
+
"affected_shells": ["bash", "zsh", "sh", "dash", "ksh"],
|
|
60
|
+
"shell_parsing_order": [
|
|
61
|
+
"1. Tokenization - command line split into tokens",
|
|
62
|
+
"2. Operator recognition - | && || ; & recognized as metacharacters",
|
|
63
|
+
"3. Command grouping - commands grouped based on operators",
|
|
64
|
+
"4. Quote processing - quoted strings preserved",
|
|
65
|
+
"5. Expansion - variables, commands, etc. expanded"
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
"solutions": {
|
|
69
|
+
"recommended": "documentation_enhancement",
|
|
70
|
+
"options": [
|
|
71
|
+
{
|
|
72
|
+
"id": "documentation_enhancement",
|
|
73
|
+
"name": "Documentation Enhancement",
|
|
74
|
+
"description": "Add clear documentation about quoting requirements",
|
|
75
|
+
"pros": ["No code changes", "Educates users", "POSIX compliant"],
|
|
76
|
+
"cons": ["Requires users to learn quoting rules"],
|
|
77
|
+
"complexity": "low"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"id": "warning_detection",
|
|
81
|
+
"name": "Optional Warning Detection",
|
|
82
|
+
"description": "Detect when stdout is piped and emit helpful warning",
|
|
83
|
+
"pros": ["Helps users understand behavior", "Non-breaking"],
|
|
84
|
+
"cons": ["May add noise to output"],
|
|
85
|
+
"complexity": "medium"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"id": "here_document",
|
|
89
|
+
"name": "Here-Document Wrapper",
|
|
90
|
+
"description": "Support $$ <<'CMD' syntax for multi-line commands",
|
|
91
|
+
"pros": ["No quoting issues", "Clear syntax"],
|
|
92
|
+
"cons": ["More verbose", "New syntax to learn"],
|
|
93
|
+
"complexity": "high"
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
"references": {
|
|
98
|
+
"bash_manual": "https://www.gnu.org/software/bash/manual/bash.html",
|
|
99
|
+
"pipelines_doc": "https://www.gnu.org/software/bash/manual/html_node/Pipelines.html",
|
|
100
|
+
"quoting_doc": "https://www.gnu.org/software/bash/manual/html_node/Quoting.html",
|
|
101
|
+
"posix_shell": "https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html"
|
|
102
|
+
},
|
|
103
|
+
"analysis_date": "2025-12-24",
|
|
104
|
+
"analyst": "AI Issue Solver"
|
|
105
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Issue #28 Raw Data
|
|
2
|
+
|
|
3
|
+
## Issue Title
|
|
4
|
+
|
|
5
|
+
Can we somehow overcome the need of `'` quotes with `|` and `"` in a sequence?
|
|
6
|
+
|
|
7
|
+
## Issue State
|
|
8
|
+
|
|
9
|
+
OPEN
|
|
10
|
+
|
|
11
|
+
## Issue Labels
|
|
12
|
+
|
|
13
|
+
bug, documentation, enhancement, question
|
|
14
|
+
|
|
15
|
+
## Issue Author
|
|
16
|
+
|
|
17
|
+
konard
|
|
18
|
+
|
|
19
|
+
## Issue Content
|
|
20
|
+
|
|
21
|
+
The issue shows two terminal sessions demonstrating different behaviors:
|
|
22
|
+
|
|
23
|
+
### Session 1: Without quoting the entire command
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
konard@MacBook-Pro-Konstantin ~ % $ echo "hi" | agent
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Result:** The `echo "hi"` command ran directly in the shell, and only its OUTPUT was piped to `agent`. The agent then processed the log file that was created by the `$` command (start-command), not the original command input.
|
|
30
|
+
|
|
31
|
+
The agent received the OUTPUT of `$ echo "hi"` which was captured in a log file, and then read that log file.
|
|
32
|
+
|
|
33
|
+
### Session 2: With quoting the entire command
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
konard@MacBook-Pro-Konstantin ~ % $ 'echo "hi" | agent'
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Result:** The entire string `echo "hi" | agent` was passed TO the `$` command (start-command). The start-command then executed this complete pipeline, which resulted in the `echo "hi"` output being piped to `agent` correctly.
|
|
40
|
+
|
|
41
|
+
## Terminal Logs
|
|
42
|
+
|
|
43
|
+
### Session 1 Output (problematic behavior)
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"type": "status",
|
|
48
|
+
"mode": "stdin-stream",
|
|
49
|
+
"message": "Agent CLI in continuous listening mode. Accepts JSON and plain text input.",
|
|
50
|
+
"hint": "Press CTRL+C to exit. Use --help for options.",
|
|
51
|
+
"acceptedFormats": ["JSON object with \"message\" field", "Plain text"],
|
|
52
|
+
"options": {
|
|
53
|
+
"interactive": true,
|
|
54
|
+
"autoMergeQueuedMessages": true,
|
|
55
|
+
"alwaysAcceptStdin": true,
|
|
56
|
+
"compactJson": false
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The agent then read a log file:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
=== Start Command Log ===
|
|
65
|
+
Timestamp: 2025-12-24 15:07:08.894
|
|
66
|
+
Command: echo hi
|
|
67
|
+
Shell: /bin/zsh
|
|
68
|
+
Platform: darwin
|
|
69
|
+
Bun Version: 1.2.20
|
|
70
|
+
Working Directory: /Users/konard
|
|
71
|
+
==================================================
|
|
72
|
+
|
|
73
|
+
hi
|
|
74
|
+
|
|
75
|
+
==================================================
|
|
76
|
+
Finished: 2025-12-24 15:07:08.906
|
|
77
|
+
Exit Code: 0
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
And responded:
|
|
81
|
+
|
|
82
|
+
> "It looks like you executed the command `echo hi`, which successfully output \"hi\" with exit code 0..."
|
|
83
|
+
|
|
84
|
+
### Session 2 Output (desired behavior)
|
|
85
|
+
|
|
86
|
+
The agent received "hi" directly as input and responded:
|
|
87
|
+
|
|
88
|
+
> "Hello! How can I help you today?"
|
|
89
|
+
|
|
90
|
+
## User Request
|
|
91
|
+
|
|
92
|
+
> Please download all logs and data related about the issue to this repository, make sure we compile that data to `./docs/case-studies/issue-{id}` folder, and use it to do deep case study analysis (also make sure to search online for additional facts and data), in which we will reconstruct timeline/sequence of events, find root causes of the problem, and propose possible solutions.
|