@plot-pm/board 0.25.0 → 0.27.0

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/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@plot-pm/board",
3
- "version": "0.25.0",
3
+ "version": "0.27.0",
4
4
  "description": "Local Kanban board for Plot — a glanceable view of plan phases from docs/plans, with sprint and story filters",
5
5
  "type": "module",
6
- "license": "MIT",
6
+ "license": "CC0-1.0",
7
7
  "author": "Max Albrecht",
8
8
  "homepage": "https://github.com/plot-pm/plot/tree/main/packages/board#readme",
9
9
  "repository": {
@@ -22,9 +22,7 @@
22
22
  },
23
23
  "files": [
24
24
  "dist/board-server.mjs",
25
- "plot-agent-monitor.sh",
26
25
  "plot-agent-manifest.sh",
27
- "plot-monitor-subject.sh",
28
26
  "plot-approve.sh",
29
27
  "plot-budget.sh",
30
28
  "plot-config.sh",
package/plot-desk-root.sh CHANGED
@@ -17,9 +17,36 @@
17
17
  # plot_repo_root → the MAIN checkout, from anywhere
18
18
  # plot_desk_root [repo [configured]] → the desk root; exit 3 when unaskable
19
19
  # plot_exclude_desk_root [repo] → keep it out of `git status`; never fails
20
+ # plot_given_common_dir dir [top] → the common git dir (or top level) from an
21
+ # exported answer, with no git process
20
22
  #
21
23
  # shellcheck shell=bash
22
24
 
25
+ # The common git dir of a directory from an exported answer — or, with `top`
26
+ # as the second argument, the directory's top level, which `--show-toplevel`
27
+ # prints. Non-zero and nothing printed when the answer is not this directory's,
28
+ # and the caller asks git.
29
+ #
30
+ # fleetd and the board pass `PLOT_REPO_ROOT` and `PLOT_GIT_COMMON_DIR` to the
31
+ # scripts they start (`git-dirs.ts`), and `plot-worker-state.sh` exports the
32
+ # second on sourcing. `givenGitDirs` in `git-dirs.ts` applies the same check to
33
+ # a node bundle.
34
+ #
35
+ # The candidate is `PLOT_GIT_COMMON_DIR`, else `$PLOT_REPO_ROOT/.git`. It holds
36
+ # only when the first `.git` above the directory is that dir itself (the main
37
+ # checkout) or a file whose `gitdir:` lies under its `worktrees/` (a desk).
38
+ # Every worktree of one repository shares the common dir, so an answer passes
39
+ # between desks; another repository's `.git` refuses it. Both answers are
40
+ # physical, as git prints them. Every caller runs it in a command
41
+ # substitution, so its variables need no `local`.
42
+ plot_given_common_dir() { # $1=directory [$2=top] → the physical common dir (or top level), or "" (non-zero)
43
+ c=$(cd -- "${PLOT_GIT_COMMON_DIR:-${PLOT_REPO_ROOT:-/nonexistent}/.git}" 2>/dev/null && pwd -P) && d=$(cd -- "$1" 2>/dev/null && pwd -P) || return 1
44
+ while [ ! -e "$d/.git" ] && [ -n "$d" ]; do d=${d%/*}; done
45
+ [ -d "$d/.git" ] && line="gitdir: $d/.git/worktrees/" || IFS= read -r line < "$d/.git" || return 1
46
+ [ "${line#"gitdir: $c/worktrees/"}" != "$line" ] || return 1
47
+ [ "${2:-}" = top ] && c=$d; printf '%s' "$c"
48
+ }
49
+
23
50
  # The MAIN checkout, from a desk as readily as from the checkout itself.
24
51
  #
25
52
  # `--show-toplevel` answers the DESK inside a linked worktree, so with
@@ -32,24 +59,25 @@
32
59
  # `--show-toplevel` is the fallback, since the common dir is also correct in a
33
60
  # non-worktree checkout: there `.git` is a real directory in the root.
34
61
  #
62
+ # AN EXPORTED ANSWER IS TAKEN WHEN IT IS THIS CHECKOUT'S (`plot_given_common_dir`),
63
+ # and git is asked otherwise.
64
+ #
35
65
  # PHYSICAL, through `pwd -P`: `git worktree list` and `--show-toplevel` print
36
66
  # resolved paths, and a desk root composed from a logical one (`/tmp` against
37
67
  # `/private/tmp` on macOS) is a prefix no worktree path ever starts with.
38
68
  plot_repo_root() {
39
- local common root=''
40
- common=$(git rev-parse --git-common-dir 2>/dev/null) && [ -n "$common" ] && {
41
- common=$(cd -- "$common" 2>/dev/null && pwd -P) || common=''
42
- [ -n "$common" ] && root=$(dirname -- "$common")
43
- }
44
- [ -n "$root" ] || root=$(git rev-parse --show-toplevel 2>/dev/null) || root=$(pwd)
69
+ local root
70
+ root=$(plot_given_common_dir "$PWD" || git rev-parse --path-format=absolute --git-common-dir 2>/dev/null) && root=$(cd -- "$root" 2>/dev/null && pwd -P) && root=$(dirname -- "$root") || root=$(git rev-parse --show-toplevel 2>/dev/null) || root=$(pwd)
45
71
  printf '%s\n' "$root"
46
72
  }
47
73
 
48
74
  # Resolved ONCE at source time, the way `plot-pr-merged.sh:105` resolves its
49
75
  # own bundle. Computing it inside a function reads `BASH_SOURCE[0]` at call
50
- # time, which is the caller's file once the function has been exported.
51
- _plot_desk_root_mjs="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/board/plot-desk-root.mjs"
52
- _plot_desk_root_config="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/plot-config.sh"
76
+ # time, which is the caller's file once the function has been exported. It
77
+ # starts no program: `plot-worker-state.sh` sources this file in every per-desk
78
+ # probe. A bare file name has no directory part, and the cwd holds it.
79
+ _plot_desk_root_mjs="$(cd -- "${BASH_SOURCE[0]%/*}" 2>/dev/null && pwd || pwd)/board/plot-desk-root.mjs"
80
+ _plot_desk_root_config="${_plot_desk_root_mjs%/board/*}/plot-config.sh"
53
81
 
54
82
  # The desk root for a repository, or exit 3 with the reason on stderr.
55
83
  #
@@ -111,9 +139,7 @@ plot_exclude_desk_root() {
111
139
  # Already ignored, by a `.gitignore` line /plot-init wrote or by an earlier
112
140
  # run. A second rule for a path already ignored is noise in a file people read.
113
141
  ( cd -- "$repo" 2>/dev/null && git check-ignore -q ".$line" ) && return 0
114
- common=$(cd -- "$repo" 2>/dev/null && git rev-parse --git-common-dir 2>/dev/null) || return 0
115
- [ -n "$common" ] || return 0
116
- case "$common" in /*) ;; *) common="$repo/$common" ;; esac
142
+ common=$(plot_given_common_dir "$repo" || git -C "$repo" rev-parse --path-format=absolute --git-common-dir 2>/dev/null) || return 0
117
143
  exclude="$common/info/exclude"
118
144
  if [ -f "$exclude" ] && grep -qxF "$line" "$exclude" 2>/dev/null; then return 0; fi
119
145
  mkdir -p "$common/info" 2>/dev/null || return 0