28 Commits
Author SHA1 Message Date
Christian Rocha 302f4ecf35 chore: modernize errors.As to errors.AsType 2026-05-09 21:40:25 -04:00
Christian Rocha 3b3f992f05 feat(hooks): propagate CRUSH/AGENT env vars to builtin shell
Share CRUSH=1/AGENT=crush/AI_AGENT=crush between the bash tool's Shell
and the hook runner so the two surfaces can't drift.
2026-04-27 11:08:02 -04:00
Christian Rocha f6ef43e9de refactor(shell): extract stateless run entrypoint
This is necessary for sharing the builtin shell with hooks.
2026-04-27 11:05:49 -04:00
Christian RochaandAndrey Nering 3773b23cb4 feat(shell): add jq as a bash builtin + a jq skill for it
Also, two local skills now exist for Crush development:

* builtin-skills, for adding new builtin skills
* shell-builtins, for adding new shell builtins
2026-04-16 17:41:30 -03:00
Andrey NeringandGitHub 0f5df9bec2 feat(bash): set CRUSH=1, AGENT=crush and AI_AGENT=crush (#2484)
These ENVs can be used by tools to detect if they are being executed
by Crush, via the Bash tool.
2026-03-25 13:08:13 -03:00
Andrey NeringandGitHub baedc28232 fix: address potential panic on shell command execution (#2200)
This panic happen once in a while on CI on Windows specifically.
I personally never saw it happening myself, but I think it's possible
to happen for the end user on Windows as well.

Looks like a potential bug on the interpreter, but in the meantime let's
at least recover from the panic and gracefully handle it.

    panic: ended up with a non-nil exitStatus.err but a zero exitStatus.code

    goroutine 61 [running]:
    mvdan.cc/sh/v3/interp.(*Runner).Run(0xc000220848, {0x1415220e0, 0xc00021a1e0}, {0x14151e088, 0xc00025a600})
    	C:/Users/runneradmin/go/pkg/mod/mvdan.cc/sh/v3@v3.12.1-0.20250902163504-3cf4fd5717a5/interp/api.go:929 +0x6b2
    github.com/charmbracelet/crush/internal/shell.(*Shell).execCommon(0xc000256360, {0x1415220e0, 0xc00021a1e0}, {0x14135a250, 0x9}, {0x14151baa0, 0xc00025a540}, {0x14151baa0, 0xc00025a580})
    	D:/a/crush/crush/internal/shell/shell.go:273 +0x285
    github.com/charmbracelet/crush/internal/shell.(*Shell).execStream(...)
    	D:/a/crush/crush/internal/shell/shell.go:288
    github.com/charmbracelet/crush/internal/shell.(*Shell).ExecStream(0xc000256360, {0x1415220e0, 0xc00021a1e0}, {0x14135a250, 0x9}, {0x14151baa0, 0xc00025a540}, {0x14151baa0, 0xc00025a580})
    	D:/a/crush/crush/internal/shell/shell.go:111 +0x139
    github.com/charmbracelet/crush/internal/shell.(*BackgroundShellManager).Start.func1()
    	D:/a/crush/crush/internal/shell/background.go:122 +0x15f
    created by github.com/charmbracelet/crush/internal/shell.(*BackgroundShellManager).Start in goroutine 28
    	D:/a/crush/crush/internal/shell/background.go:119 +0x72a
2026-02-11 17:19:51 -03:00
Andrey Nering 5e23ecdb4d chore: run modernize 2026-02-10 15:26:04 -03:00
b66676c52a fix(sec): do not output resolved command (#1934)
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Co-authored-by: Andrey Nering <andreynering@users.noreply.github.com>
2026-01-21 15:52:17 -03:00
Carlos Alexandro BeckerandGitHub e4400ad241 perf(shell): reduce allocations in updateShellFromRunner (#1817) 2026-01-09 17:58:37 -03:00
4401d5b37f feat: background jobs & remove persistent shell (#1328)
Co-authored-by: Christian Rocha <christian@rocha.is>
Co-authored-by: Raphael Amorim <rapha850@gmail.com>
Co-authored-by: Andrey Nering <andreynering@users.noreply.github.com>
2025-11-07 13:11:14 +01:00
Andrey Nering b9e41f8cb9 refactor(shell): some small code adjustments 2025-10-30 16:43:54 -03:00
Andrey Nering 569044c5a0 fix: only enable built-in core utils by default on windows
Or we risk making them failing on other platforms due to
incompatibilities.

Fixes #1341
2025-10-30 16:43:54 -03:00
AmolithandGitHub feb184d802 chore: task fmt (#1098) 2025-09-22 09:29:01 -03:00
Andrey NeringandGitHub a2e89c82fb chore: IsSubset was moved to x/exp/slice (#923) 2025-08-29 12:12:11 -03:00
Andrey Nering b4492299c1 fix(shell): block go test -exec and ensure it works using equals 2025-08-18 16:50:35 -03:00
Andrey Nering cbdd2e5220 fix(shell): refactor arguments blocker to check for flags in any position 2025-08-18 16:50:35 -03:00
Andrey Nering 2d2ee7f5ab refactor: have shorter argument name 2025-08-18 16:50:35 -03:00
Andrey Nering 9eb207f3cf refactor: migrate bool to empty struct for lower memory usage 2025-08-18 16:50:35 -03:00
Andrey NeringandGitHub a32c16cb87 refactor: use core utils middleware from mvdan/sh (#323)
* https://github.com/mvdan/sh/pull/1179
* https://github.com/mvdan/sh/pull/1186
2025-08-07 19:14:06 -03:00
Andrey Nering 60e7d043fc chore: fix lint issue 2025-07-28 10:30:06 -03:00
Andrey NeringandChristian Rocha ec7894ff9f feat(shell): use coreutils from u-root 2025-07-23 11:01:20 -04:00
Andrey Nering 08d5a47c7d chore: run modernize 2025-07-21 10:51:45 -03:00
Andrey Nering 436aa017e4 fix(windows): use mvdan/sh + general fixes 2025-07-15 10:02:29 -03:00
Kujtim Hoxha 0a52748401 chore: small change 2025-07-11 18:02:42 +02:00
Kujtim Hoxha 2fdbcac029 chore: better naming 2025-07-11 17:55:01 +02:00
Kujtim Hoxha f99f50427a refactor: improve command blocking system and fix test isolation
- Simplify command blocking logic by using utility functions instead of complex closures
- Add sudo to banned commands list
- Move command blocking from bash tool to shell layer for better separation of concerns
- Add comprehensive tests for command blocking functionality
- Fix test isolation by using temporary directories to prevent npm package files from polluting source tree
- Remove redundant command validation logic from bash tool
2025-07-11 00:21:19 +02:00
Kujtim Hoxha 8d4f80d607 chore: lint fixes 2025-06-28 13:37:17 +02:00
Kujtim Hoxha baad28ac90 chore: move shell to its own package 2025-06-28 13:35:50 +02:00