dkit 0.3.3 → 0.4.1

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -0
  3. data/README.md +8 -3
  4. data/bin/dkit +51 -2
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0b4a5d2779f046a28fd08f82a5564621b5856617507e5e9a7891981818318ff
4
- data.tar.gz: e5f0e728e94bc3b45a80f7834dfc3cdc76458689eda7b5000e6851d1e6ed31a8
3
+ metadata.gz: a3a9a92ddb91d679c5e3829e29555e41e350f28e21d5b23068c9f47aed0bfb71
4
+ data.tar.gz: 7cfdcde91b707f91065824ebd500b7d98ece0775a69cd0d859592c65200924f0
5
5
  SHA512:
6
- metadata.gz: 7236faaaad611849ad0446036ab189bfd16fd54f39f7f032569658859a21c64236fc103b9516ca90369ae454ed5616f681ee1ce912a2729e5a2d321d7d86f1de
7
- data.tar.gz: b0d487ab8e2df9f522bc7d6a9fd58a697492020f1dc8bd71ec8946e25f152b3a686d1489b7986e42fd128fa5a7cddb2f2f0a69550f2ce30089344e3839ddfb08
6
+ metadata.gz: f545daeb77092ee428d0ec2405e1cea0f9f83685bc918ba4900acfa0dd9e1355858bab85a2326ed8f0a944720b1a01d6dd635ee574a39ca9985efd4f118fdcb2
7
+ data.tar.gz: 83ff15a0ebf7e693aff3a40ce59c9deab9373aea4be9afbc45da082a970886c6c35e3344485827f7b9ed8486d29c54837b300e936f66e6c017a36508344669c4
data/CHANGELOG.md CHANGED
@@ -5,6 +5,27 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.4.1] - 2026-04-13
9
+
10
+ ### Fixed
11
+ - `dkit shell` now runs as a subprocess (`system`) instead of replacing the current process (`exec`), so `exit` returns to the host shell instead of closing the terminal
12
+
13
+ ### Changed
14
+ - README: added zsh as explicit requirement, documented glob/wildcard intercept patterns, clarified zsh-specific hook mechanisms
15
+
16
+ ## [0.4.0] - 2026-04-13
17
+
18
+ ### Added
19
+ - Glob/wildcard patterns in intercept file: `bin/*` intercepts all executables under `bin/` (e.g. `bin/rails`, `bin/rspec`)
20
+ - New zsh helpers `_dkit_expand_glob` and `_dkit_refresh_globs` for dynamic function creation from glob patterns
21
+ - `precmd` hook automatically picks up new executables and cleans up deleted ones between prompts
22
+ - Help text documents glob usage with quoting example
23
+
24
+ ### Notes
25
+ - Glob patterns must be quoted to prevent shell expansion: `dkit intercept add 'bin/*'`
26
+ - Only executable files are matched (non-executable files like READMEs are skipped)
27
+ - Requires `exec zsh` after gem update to reload the shell hook
28
+
8
29
  ## [0.3.3] - 2026-04-13
9
30
 
10
31
  ### Changed
data/README.md CHANGED
@@ -10,6 +10,7 @@ When you `cd` into a project, dkit intercepts configured commands (e.g. `rails`,
10
10
  ## Requirements
11
11
 
12
12
  - macOS or Linux
13
+ - zsh (bash and other shells are not supported)
13
14
  - Ruby >= 2.7
14
15
  - Docker with Compose v2 (`docker compose`)
15
16
  - A project with `.devcontainer/devcontainer.json` using `dockerComposeFile` + `service`
@@ -56,10 +57,13 @@ git commit -m "chore: add dkit intercept config"
56
57
  ```sh
57
58
  dkit intercept list # show active commands for this project
58
59
  dkit intercept add terraform # add a command
60
+ dkit intercept add 'bin/*' # add a glob pattern (quote to prevent shell expansion)
59
61
  dkit intercept remove terraform # remove a command
60
62
  exec zsh # reload shell to apply changes
61
63
  ```
62
64
 
65
+ Glob patterns like `bin/*` intercept all matching executables at once (e.g. `bin/rails`, `bin/rspec`). New files are picked up automatically at each prompt.
66
+
63
67
  ### Verbose routing messages
64
68
 
65
69
  By default, dkit prints a line to stderr whenever it intercepts a command:
@@ -100,17 +104,18 @@ dkit down [flags] docker compose down
100
104
  dkit logs [service] docker compose logs -f
101
105
 
102
106
  dkit init Create .devcontainer/dkit-intercept
103
- dkit intercept list|add|remove <cmd>
107
+ dkit intercept list|add|remove <cmd|pattern>
104
108
  dkit hook Emit shell hook for ~/.zshrc
105
109
  dkit version
106
110
  ```
107
111
 
108
112
  ## How it works
109
113
 
110
- 1. On `cd`, the shell hook calls `dkit root` to find the nearest `.devcontainer/devcontainer.json`.
111
- 2. It reads `.devcontainer/dkit-intercept` and defines a shell function for each listed command.
114
+ 1. On `cd`, the zsh `chpwd` hook calls `dkit root` to find the nearest `.devcontainer/devcontainer.json`.
115
+ 2. It reads `.devcontainer/dkit-intercept` and defines a zsh function for each listed command. Glob patterns (e.g. `bin/*`) are expanded to matching executables.
112
116
  3. Each function calls `dkit status --quiet` to check if the container is running. If yes, it delegates to `dkit run <cmd>`; otherwise it calls the host binary.
113
117
  4. `dkit run` resolves the container name from the devcontainer config (via compose YAML, docker labels, or `docker compose ps`) and execs into it at the mirrored working directory.
118
+ 5. A `precmd` hook re-expands glob patterns before each prompt, picking up new files and cleaning up deleted ones.
114
119
 
115
120
  ## devcontainer.json requirements
116
121
 
data/bin/dkit CHANGED
@@ -16,7 +16,7 @@ require 'pathname'
16
16
  require 'shellwords'
17
17
  require 'fileutils'
18
18
 
19
- VERSION = "0.3.3"
19
+ VERSION = "0.4.1"
20
20
  DC_CONFIG = ".devcontainer/devcontainer.json"
21
21
  DC_INTERCEPT = ".devcontainer/dkit-intercept"
22
22
 
@@ -228,6 +228,8 @@ def cmd_hook
228
228
 
229
229
  _DKIT_ROOT=""
230
230
  _DKIT_ACTIVE_CMDS=()
231
+ _DKIT_GLOB_PATTERNS=()
232
+ _DKIT_GLOB_CMDS=()
231
233
 
232
234
  _dkit_reset() {
233
235
  local cmd
@@ -235,6 +237,8 @@ def cmd_hook
235
237
  unfunction "$cmd" 2>/dev/null
236
238
  done
237
239
  _DKIT_ACTIVE_CMDS=()
240
+ _DKIT_GLOB_PATTERNS=()
241
+ _DKIT_GLOB_CMDS=()
238
242
  }
239
243
 
240
244
  _dkit_verbose_fallback() {
@@ -244,6 +248,43 @@ def cmd_hook
244
248
  printf '\033[31m[dkit] %s → host (fallback)\033[0m\n' "$1" >&2
245
249
  }
246
250
 
251
+ _dkit_expand_glob() {
252
+ local root="$1" pattern="$2"
253
+ local full_pattern="$root/$pattern"
254
+ local matches=( ${~full_pattern}(N*) )
255
+ local m rel
256
+ for m in "${matches[@]}"; do
257
+ rel="${m#$root/}"
258
+ (( ${_DKIT_ACTIVE_CMDS[(Ie)$rel]} )) && continue
259
+ eval "function ${rel}() {
260
+ if dkit status --quiet 2>/dev/null; then
261
+ dkit run ${rel} \"\$@\"
262
+ else
263
+ _dkit_verbose_fallback \"${rel}\"
264
+ command ${rel} \"\$@\"
265
+ fi
266
+ }"
267
+ _DKIT_ACTIVE_CMDS+=("${rel}")
268
+ _DKIT_GLOB_CMDS+=("${rel}")
269
+ done
270
+ }
271
+
272
+ _dkit_refresh_globs() {
273
+ [[ -z "$_DKIT_ROOT" || ${#_DKIT_GLOB_PATTERNS[@]} -eq 0 ]] && return
274
+ local cmd
275
+ for cmd in "${_DKIT_GLOB_CMDS[@]}"; do
276
+ if [[ ! -e "$_DKIT_ROOT/$cmd" ]]; then
277
+ unfunction "$cmd" 2>/dev/null
278
+ _DKIT_ACTIVE_CMDS=("${(@)_DKIT_ACTIVE_CMDS:#$cmd}")
279
+ fi
280
+ done
281
+ _DKIT_GLOB_CMDS=()
282
+ local pat
283
+ for pat in "${_DKIT_GLOB_PATTERNS[@]}"; do
284
+ _dkit_expand_glob "$_DKIT_ROOT" "$pat"
285
+ done
286
+ }
287
+
247
288
  _dkit_load() {
248
289
  local root="$1"
249
290
  local intercept="$root/.devcontainer/dkit-intercept"
@@ -255,6 +296,12 @@ def cmd_hook
255
296
  cmd="${cmd## }"
256
297
  cmd="${cmd%% }"
257
298
  [[ -z "$cmd" ]] && continue
299
+ # Glob pattern: expand matching executables
300
+ if [[ "$cmd" == *[\*\?\[]* ]]; then
301
+ _DKIT_GLOB_PATTERNS+=("${cmd}")
302
+ _dkit_expand_glob "$root" "$cmd"
303
+ continue
304
+ fi
258
305
  eval "function ${cmd}() {
259
306
  if dkit status --quiet 2>/dev/null; then
260
307
  dkit run ${cmd} \"\$@\"
@@ -301,6 +348,7 @@ def cmd_hook
301
348
 
302
349
  autoload -U add-zsh-hook
303
350
  add-zsh-hook chpwd _dkit_chpwd
351
+ add-zsh-hook precmd _dkit_refresh_globs
304
352
  _dkit_chpwd
305
353
  ZSH
306
354
  end
@@ -319,7 +367,7 @@ def cmd_run(ctx, args)
319
367
  end
320
368
 
321
369
  def cmd_shell(ctx)
322
- exec("docker", "exec", "-it", "--user", ctx.user, "--workdir", ctx.cwd, ctx.container, "zsh", "-l")
370
+ system("docker", "exec", "-it", "--user", ctx.user, "--workdir", ctx.cwd, ctx.container, "zsh", "-l")
323
371
  end
324
372
 
325
373
  def cmd_claude(ctx, args)
@@ -393,6 +441,7 @@ def cmd_help
393
441
  dkit init Create .devcontainer/dkit-intercept with auto-detected defaults
394
442
  dkit intercept list List intercepted commands for current project
395
443
  dkit intercept add <cmd> Add command to current project's intercept list
444
+ dkit intercept add 'bin/*' Add glob pattern (quote to prevent shell expansion)
396
445
  dkit intercept remove <cmd> Remove command from current project's intercept list
397
446
 
398
447
  Verbose routing messages (on by default):
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Augusto Stroligo