50 Commits
Author SHA1 Message Date
Christian Rocha f32dcffc21 fix(shell): ensure canceling a command stops all child processes 2026-05-15 17:37:04 -04:00
c853a939ef fix(config): always resolve the data directory to an absolute path (#2883)
Co-authored-by: Charm Crush <crush@charm.land>
2026-05-12 10:37:49 -04:00
Christian Rocha 302f4ecf35 chore: modernize errors.As to errors.AsType 2026-05-09 21:40:25 -04:00
Christian Rocha 32410e29a4 fix(shell): fix build error post-refactor 2026-05-09 21:40:25 -04:00
Christian RochaandGitHub 09c83e839d Merge pull request #2730 from charmbracelet/hookshell
feat(hooks): use embedded shell by default
2026-05-09 20:53:46 -04:00
Kieran Klukas c9fd6be3e3 fix(shell): convert path to posix path in tests 2026-05-05 12:50:41 -04:00
Christian RochaandCharm Crush abacef9336 shell: switch config value expansion to lenient by default
Missing env vars in crush.json used to fail loudly. They now quietly
expand to an empty string, the same as bash. If you want the old
strict behavior for a specific value, write it as ${VAR:?message}
and Crush will still complain when the variable is not set.

Co-Authored-By: Charm Crush <crush@charm.land>
2026-05-03 17:02:26 -04:00
Christian Rocha 711d3a384f feat(shell): add ExpandValue for config value shell expansion
Groundwork for replacing the hand-rolled parser in internal/config/resolve.go.

Introduces shell.ExpandValue, a single-value expansion entry point built
on mvdan.cc/sh/v3's syntax + expand packages. Runs with nounset on and
globbing off, preserves internal whitespace, strips only trailing
newlines from command substitution output, and bounds/scrubs inner
stderr surfaced in errors. Shares the builtin/block/coreutils handler
chain with NewShell but uses the caller-provided env verbatim.
2026-05-02 15:47:57 -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 af002dca8e fix(shell): ctx-aware jq builtin
This in necessary so hook timeouts can now interrupt long-running
filters and large stdin reads for the builtin jq tool.
2026-04-27 11:06:40 -04:00
Christian Rocha 2e8e5365a2 feat(shell): shebang/binary/in-process dispatch handler 2026-04-27 11:06:34 -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
Bruno KrugelandGitHub e3df84efb4 refactor: modernize (#2548) 2026-04-02 10:24:28 -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
Sean PorterandGitHub 9ec46b8d43 feat(shell): add blocking wait option to job_output tool (#2189) 2026-03-02 17:22:53 -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
63e009898a fix: improving shutdown (#2175)
* test: use t.Context() and synctest

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* fix: passing down context to all shutdown funcs

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* perf(lsp): kill all clients on shutdown

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* fix: exit posthog earlier

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* test: fix dirs test

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* test: fix projects test

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* test: fix race

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* Update internal/lsp/manager.go

Co-authored-by: Andrey Nering <andreynering@users.noreply.github.com>

* fix: cleanup

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* test: race

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

---------

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Co-authored-by: Andrey Nering <andreynering@users.noreply.github.com>
2026-02-09 11:32:01 -03:00
M1xAandGitHub 3b3a3d78c8 fix: prevent goroutine orphaning in mcp.Close() and shell.KillAll() (#2159) 2026-02-09 09:40:35 -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
3fd9d97014 ci(sec): add more security jobs, improve build, enable race detector (#1849)
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-13 14:34:19 -03:00
Carlos Alexandro BeckerandGitHub 6f646c9151 perf: improve startup and shutdown speed (#1829)
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
2026-01-12 14:37:05 +01:00
Carlos Alexandro BeckerandGitHub e4400ad241 perf(shell): reduce allocations in updateShellFromRunner (#1817) 2026-01-09 17:58:37 -03:00
Andrey NeringandGitHub 7fcdf901a1 ci: skip two flacky tests depending on os (#1606) 2025-12-11 18:14:25 +00:00
Kujtim HoxhaandGitHub c38183438c fix: handle google reasoning (#1474) 2025-11-19 13:02:18 +01: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
Kujtim Hoxha 8fce31ead1 test: test all the tool calls 2025-10-01 18:51:15 +02:00
AmolithandGitHub feb184d802 chore: task fmt (#1098) 2025-09-22 09:29:01 -03:00
df2e64ead1 refactor(fsext): improve hierarchical ignore handling and consolidate file exclusion logic (#999)
* refactor(fsext): improve hierarchical ignore handling and consolidate file exclusion logic

- Refactor FastGlobWalker to use directoryLister for consistent ignore handling
- Add ShouldExcludeFile function for unified file exclusion checking
- Add WalkDirectories function for directory traversal with ignore support
- Improve directory pattern matching by checking both with and without trailing slash
- Add comprehensive tests for hierarchical ignore behavior and common patterns
- Remove direct dependency on go-gitignore in favor of existing directoryLister implementation

💖 Generated with Crush
Co-Authored-By: Crush <crush@charm.land>

* fix: improvements

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* chore: t.Context()

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* fix: tests

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

---------

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Co-authored-by: Crush <crush@charm.land>
2025-09-10 08:03:38 -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
Carlos Alexandro BeckerandGitHub 2a43184580 feat: grep should support gitignore/crushignore (#428)
* feat: support .crushignore as well as .gitignore
* docs: update
* refactor: simplify
* chore: fmt
* feat: grep should support gitignore/crushignore
* fix: small fixes
* fix: small fixes
* fix: ripgrep
* fix: rg
* fix: tst
* test: fixes
* refactor: organized code a bit
* fix: try
* fix: temp
* chore: lint

---------

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
2025-08-01 21:39:50 -04:00
Carlos Alexandro BeckerandGitHub 0506272332 test: improve tests (#315) 2025-07-28 10:55:42 -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 dafbdb74cd chore: remove logs 2025-07-05 16:46:47 +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