Add execline skill documentation
💘 Generated with Crush
Assisted-by: MiniMax-M2.5 via Crush <crush@charm.land>
This commit is contained in:
parent
96deeeab7f
commit
c772e008cb
2 changed files with 27 additions and 10 deletions
|
|
@ -100,7 +100,7 @@ func (t *ExeclineTool) Parameters() map[string]any {
|
||||||
},
|
},
|
||||||
"env": map[string]any{
|
"env": map[string]any{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"description": "Additional environment variables to set for this command",
|
"description": "Additional environment variables to set for this command. Do not try to set PICOCLAW*, PATH, HOME, USER, LOGNAME, SHELL, LD_PRELOAD, or LD_LIBRARY_PATH",
|
||||||
"additionalProperties": map[string]any{
|
"additionalProperties": map[string]any{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
},
|
},
|
||||||
|
|
@ -174,7 +174,7 @@ func (t *ExeclineTool) Execute(ctx context.Context, args map[string]any) *ToolRe
|
||||||
"PICOCLAW_EXEC_TIME": time.Now().Format(time.RFC3339),
|
"PICOCLAW_EXEC_TIME": time.Now().Format(time.RFC3339),
|
||||||
"PICOCLAW_EXEC_TIMEOUT": t.timeout.String(),
|
"PICOCLAW_EXEC_TIMEOUT": t.timeout.String(),
|
||||||
}
|
}
|
||||||
execEnv = shell.MergeEnvVars(execEnv, execTimeEnv, nil)
|
execEnv := shell.MergeEnvVars(baseEnv, execTimeEnv, extraEnv)
|
||||||
|
|
||||||
// Use execlineb to execute
|
// Use execlineb to execute
|
||||||
// execlineb -c takes a command string and executes it
|
// execlineb -c takes a command string and executes it
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ cd $home
|
||||||
ls
|
ls
|
||||||
```
|
```
|
||||||
|
|
||||||
### backtick - Command output to variable
|
### backtick - Command output to variable (with -E flag!)
|
||||||
```bash
|
```bash
|
||||||
backtick DATE { date +%Y-%m-%d }
|
backtick DATE { date +%Y-%m-%d }
|
||||||
echo $DATE
|
echo $DATE
|
||||||
|
|
@ -76,6 +76,16 @@ echo $DATE
|
||||||
- Stores it in an environment variable
|
- Stores it in an environment variable
|
||||||
- Then execs into the next command
|
- Then execs into the next command
|
||||||
|
|
||||||
|
### backtick -E - Auto-import command substitution
|
||||||
|
The `-E` flag makes backtick automatically import the result as a variable, enabling true command substitution (like `$()` in bash):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
backtick -E DATE { date } echo $DATE
|
||||||
|
# Output: Sun Mar 22 08:08:58 PM GMT 2026
|
||||||
|
```
|
||||||
|
|
||||||
|
Without `-E`, you need `importas` to access the variable. With `-E`, it's auto-imported directly.
|
||||||
|
|
||||||
## Sequencing Commands
|
## Sequencing Commands
|
||||||
|
|
||||||
### foreground - Run and wait
|
### foreground - Run and wait
|
||||||
|
|
@ -194,8 +204,8 @@ wc -l
|
||||||
|---------|---------|----------|
|
|---------|---------|----------|
|
||||||
| $VAR expansion | Yes | Yes (via substitution) |
|
| $VAR expansion | Yes | Yes (via substitution) |
|
||||||
| ${VAR} expansion | Yes | Yes |
|
| ${VAR} expansion | Yes | Yes |
|
||||||
| $(cmd) substitution | Yes | **No** - use backtick |
|
| $(cmd) substitution | Yes | **Yes** - use `backtick -E VAR { cmd }` |
|
||||||
| `cmd` substitution | Yes | **No** |
|
| `cmd` substitution | Yes | **No** (use backtick) |
|
||||||
| &&, \|\| | Yes | **No** - use if/foreground |
|
| &&, \|\| | Yes | **No** - use if/foreground |
|
||||||
| ; | Yes | **No** - use foreground |
|
| ; | Yes | **No** - use foreground |
|
||||||
| Variable assignment | VAR=value | define VAR value |
|
| Variable assignment | VAR=value | define VAR value |
|
||||||
|
|
@ -205,10 +215,13 @@ wc -l
|
||||||
|
|
||||||
## Usage in picoclaw
|
## Usage in picoclaw
|
||||||
|
|
||||||
### Via ExeclineTool:
|
The picoclaw agent has a built-in `execline` tool that you can call directly:
|
||||||
|
|
||||||
```
|
```
|
||||||
Use the `execline` tool for commands that don't need shell features.
|
Tool: execline
|
||||||
|
ToolInput: { "command": "define FOO bar echo $FOO" }
|
||||||
```
|
```
|
||||||
|
→ Output: bar
|
||||||
|
|
||||||
The ExeclineTool validates:
|
The ExeclineTool validates:
|
||||||
- No `&&`, `||` (use `if`, `foreground` instead)
|
- No `&&`, `||` (use `if`, `foreground` instead)
|
||||||
|
|
@ -225,9 +238,13 @@ execlineb -c 'define FOO bar echo $FOO'
|
||||||
HOME=/tmp execlineb -c 'importas h HOME cd $h pwd'
|
HOME=/tmp execlineb -c 'importas h HOME cd $h pwd'
|
||||||
# Output: /tmp
|
# Output: /tmp
|
||||||
|
|
||||||
# Command substitution is LITERAL (not executed):
|
# backtick -E enables command substitution (like $()):
|
||||||
execlineb -c 'echo $(whoami)'
|
execlineb -c 'backtick -E DATE { date } echo $DATE'
|
||||||
# Output: $(whoami)
|
# Output: current date/time
|
||||||
|
|
||||||
|
# backtick without -E requires importas:
|
||||||
|
execlineb -c 'backtick DATE { date } importas D DATE echo $D'
|
||||||
|
# Output: current date/time
|
||||||
```
|
```
|
||||||
|
|
||||||
## Recommendations
|
## Recommendations
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue