@alterset/alterspec-client 0.4.2 → 0.4.5

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/README.md CHANGED
@@ -7,6 +7,10 @@ back. The client never edits the spec.
7
7
 
8
8
  It also carries the format of the export's `work.json` (`@alterset/alterspec-client/work`) for the dispatcher.
9
9
 
10
+ New to the dispatcher? Start with the step-by-step [developer guide](developer-guide.md) (`developer-guide.md` in
11
+ this package): the SSH key, setting a repository up, signing in, and a task from start to finish. This README is the
12
+ reference.
13
+
10
14
  ## What you need
11
15
 
12
16
  - Node.js 20 or later, git, and [Claude Code](https://code.claude.com).
@@ -58,7 +62,11 @@ npx @alterset/alterspec-client init --dispatcher https://<dispatcher> --export .
58
62
  It is safe to run again. Running it again also updates the client: it adds the skills of the new version, removes
59
63
  the ones it dropped, and keeps any skill you edited unless you pass `--force`. Commit everything it writes except
60
64
  `.claude/settings.local.json`, so task worktrees have it too. `worktree` writes the approval into each new task
61
- worktree itself.
65
+ worktree itself. If you keep the setup out of git instead, as top-level symlinks into another repository (`.claude`,
66
+ `.mcp.json`, `.alterspec-client`), git-ignored, `worktree` links each of them into the new worktree too. If such a link is committed with a relative target, so that
67
+ it would point nowhere from a worktree one folder deeper, `worktree` links the folder it misses in the worktrees'
68
+ folder to the one beside your checkout (`../<repo>-tasks/ops` → `../ops`), which all task worktrees share; git sees
69
+ no change.
62
70
 
63
71
  When `.claude` is a symlink to another repository, git can't tell whether the file is ignored there: `init` says so,
64
72
  and you add `.claude/settings.local.json` to that repository's `.gitignore`.
@@ -72,6 +80,10 @@ npx @alterset/alterspec-client key
72
80
 
73
81
  The dispatcher's tools appear in the next Claude Code session started in the repository.
74
82
 
83
+ `init` doesn't touch your `CLAUDE.md`. So that Claude knows where the export is and how to treat it outside the
84
+ skills too, copy the block in [`agent-instructions.md`](agent-instructions.md) (in this package) into your agent's
85
+ instructions, wherever you keep them.
86
+
75
87
  ## Working day
76
88
 
77
89
  You talk to Claude Code; the skills call the dispatcher and the CLI for you.
@@ -128,7 +140,7 @@ worktree, the configuration is read from the main checkout.
128
140
  | `key` | Print the public key and fingerprint you sign with. |
129
141
  | `open dispatcher` | Sign in and open the dispatcher's pages in the browser. The link works once, for a minute. |
130
142
  | `context <task> [--json]` | Print the task's brief from the export, starting with its checklist. |
131
- | `worktree <task> [--here]` | Create the branch `task/<chg>-<track>` from `origin/<main>` in its own worktree. `--here` uses this checkout instead. |
143
+ | `worktree <task> [--here]` | Create the branch `task/<chg>-<track>` from `origin/<main>` in its own worktree, with the checkout's git-ignored top-level symlinks linked in and its committed relative ones made to resolve. `--here` uses this checkout instead. |
132
144
  | `progress [task] [--json]` | Report the items your commits cover. Default: the task of the current branch. |
133
145
  | `merged <task>` | Print the commit on `origin/<main>` that brought the task in. |
134
146
  | `export-head [--latest <sha>]` | Pull the export clone and print the commit to send to the dispatcher. |
@@ -0,0 +1,32 @@
1
+ # Instructions for your coding agent
2
+
3
+ The client's skills tell Claude how to use the export while one of them runs. Outside a skill (ordinary coding in
4
+ the repository, a review, a session after its context was summarised) the agent knows only what your own instructions
5
+ say. Copy the block below into them: `CLAUDE.md`, a file under `.claude/`, `AGENTS.md` or wherever your team keeps
6
+ them. Replace `<export>` with the path of your export clone (`export` in `.alterspec-client.json`), and change the
7
+ wording to suit your team.
8
+
9
+ The export's own `README.md` explains how the export is laid out and how to read it; it is written by the same
10
+ alterspec version as the export, so it is always the right description of that export. This block only points there.
11
+
12
+ ```markdown
13
+ ## Product spec
14
+
15
+ The product spec is in `<export>/`, an alterspec export: the signed-off spec, in business terms only. Before you
16
+ work from it, read its `README.md` (at least "How to read the spec" and "For coding agents").
17
+
18
+ - Treat it as the requirements. Build what it says, nothing it doesn't say. Technology, architecture, data storage
19
+ and APIs are ours to decide; the spec never decides them.
20
+ - Never edit, commit or switch branches in `<export>/`; the alterspec client pulls it.
21
+ - Look objects up by ID: the file names are the IDs (`modules/*/capabilities/CAP-….md`, `entities/ENT-….md`), and
22
+ `export.json` lists every object with its file. Read only the part you need: `_shards/` holds every document cut
23
+ by section and every collection by item.
24
+ - Reference spec IDs (CAP-…, RULE-…, CAP-…-AC-NN) in test names and comments where code implements them. Write one
25
+ test per acceptance criterion, named by its ID.
26
+ - Take rule messages, labels and states word for word from the spec and the screens' experience contracts.
27
+ - The mockups in `experience/*/mockups/` are the agreed look and behaviour; don't copy their code.
28
+ - If the spec is silent, ambiguous or contradicts itself or the code, stop and ask, naming the IDs involved. Never
29
+ fill a gap with an invented business rule.
30
+ - Work on a task goes through the alterspec skills (`/alterspec-task-context`); every commit of a task carries the
31
+ trailers they describe.
32
+ ```
@@ -0,0 +1,231 @@
1
+ # Taking tasks from the alterspec dispatcher: developer guide
2
+
3
+ Your team's work is handed out by the **alterspec dispatcher**. It reads the signed-off product spec (the **export**
4
+ repository), splits every change into tasks and gives them to you through Claude Code. It records who works on what,
5
+ how far along each task is and when it is done. You don't track any of this by hand.
6
+
7
+ You connect to it with the **alterspec client** (`@alterset/alterspec-client`, public on npm). Setting up takes about
8
+ 15 minutes, once per machine and repository. Follow the steps in order.
9
+
10
+ ## How it works, in six lines
11
+
12
+ - A **change** is one signed-off piece of the spec, e.g. `CHG-023`.
13
+ - A **track** is a stream of build work, usually built in one repository. `BE` is the backend (APIs included); every
14
+ other track is a UI design, named by its channel code (`WEB`, `MOB`, …).
15
+ - A **task** is one change on one track, written `CHG-023/BE`. A UI task opens only once the `BE` task of the same
16
+ change is done.
17
+ - A task's **checklist** lists what it must deliver: acceptance criteria (`CAP-CAT-001-AC-03`), screen actions
18
+ (`SCR-PRC-01.A02`), experience states (`UX-SCR-PRC-01-WEB#error`). Progress counts the items your commits cover;
19
+ nobody types percentages.
20
+ - When you take a task it is yours until you report it **done** or **release** it; nobody else can.
21
+ - A task is **done** when its work is merged into the track's main branch on the remote.
22
+
23
+ ## Before you start
24
+
25
+ You need:
26
+
27
+ - macOS or Linux, `git`, **Node 20 or later** (`node -v`) and **Claude Code**.
28
+ - From your admin (the person who runs the dispatcher):
29
+ - the **dispatcher URL**, e.g. `https://dispatcher.example.com`;
30
+ - the **export repository** to clone;
31
+ - your **track(s)** and the code repository each is built in;
32
+ - the track's **main branch** (`main`, `master`, …) if it isn't the remote's default.
33
+ - Read access to the export repository and access to your code repository.
34
+
35
+ In the steps below, replace `<dispatcher-url>`, `<export-repo>`, `<code-repo>`, `<TRACK>` and `<branch>` with these
36
+ values.
37
+
38
+ ## Step 1: An Ed25519 SSH key
39
+
40
+ The dispatcher has no passwords: you sign in with an SSH key that your admin adds for you. It must be **Ed25519**;
41
+ RSA keys (`id_rsa`) are not accepted. Check whether you have one:
42
+
43
+ ```bash
44
+ ls ~/.ssh/id_ed25519.pub
45
+ ```
46
+
47
+ If it says "No such file", create one (press Enter for the default location; a passphrase is recommended):
48
+
49
+ ```bash
50
+ ssh-keygen -t ed25519 -C "you@example.com"
51
+ ```
52
+
53
+ If the key has a passphrase, add it to ssh-agent so the client can sign without asking. On macOS:
54
+
55
+ ```bash
56
+ ssh-add --apple-use-keychain ~/.ssh/id_ed25519
57
+ ```
58
+
59
+ On Linux:
60
+
61
+ ```bash
62
+ ssh-add ~/.ssh/id_ed25519
63
+ ```
64
+
65
+ ## Step 2: Send your admin your public key
66
+
67
+ Print it with its fingerprint:
68
+
69
+ ```bash
70
+ cat ~/.ssh/id_ed25519.pub
71
+ ```
72
+
73
+ ```bash
74
+ ssh-keygen -lf ~/.ssh/id_ed25519.pub
75
+ ```
76
+
77
+ Send your admin:
78
+
79
+ 1. your name and email,
80
+ 2. the whole line starting with `ssh-ed25519 AAAA…`,
81
+ 3. the fingerprint (`SHA256:…`), so they can check it arrived intact,
82
+ 4. your track(s).
83
+
84
+ Send only the `.pub` line. **Never send `~/.ssh/id_ed25519`** (the file without `.pub`): that is your private key, and
85
+ it never leaves your machine.
86
+
87
+ Continue with steps 3 and 4 while you wait. Step 5 needs your admin's confirmation.
88
+
89
+ ## Step 3: Clone the repositories side by side
90
+
91
+ Put your code repository and the export next to each other in one folder:
92
+
93
+ ```bash
94
+ mkdir -p ~/Projects/<product> && cd ~/Projects/<product>
95
+ git clone <export-repo> <product>-export
96
+ git clone <code-repo>
97
+ ```
98
+
99
+ The export is **read-only**: never edit, commit or switch branches in it. The client pulls it for you.
100
+
101
+ Task worktrees (step 6, "Several tasks at once") are created next to your code repository, in `<code-repo>-tasks/`.
102
+
103
+ ## Step 4: Set the client up in your code repository
104
+
105
+ In the root of your code repository:
106
+
107
+ ```bash
108
+ cd ~/Projects/<product>/<code-repo>
109
+ npx @alterset/alterspec-client init --dispatcher <dispatcher-url> --export ../<product>-export --track <TRACK> --branch <branch>
110
+ ```
111
+
112
+ Answer `y` if npx asks to install the package. Leave out `--branch` when the track's main branch is the remote's
113
+ default. A repository that builds several tracks takes them all: `--track BE WEB`. If you sign with another key than
114
+ `~/.ssh/id_ed25519`, add `--key <path-to-.pub>`.
115
+
116
+ `init` writes:
117
+
118
+ | File | What it is | Commit it? |
119
+ | ----------------------------- | -------------------------------------------------------------------------- | -------------------------------------- |
120
+ | `.alterspec-client.json` | the dispatcher URL, the export path, your tracks, the main branch | if the whole team shares these values |
121
+ | `.mcp.json` | the `dispatcher` MCP server for Claude Code | yes |
122
+ | `.claude/settings.json` | a hook that reports progress after each `git commit` | yes |
123
+ | `.claude/skills/alterspec-*` | the skills | yes |
124
+ | `.alterspec-client/prompts/` | the instructions behind the skills | yes |
125
+ | `.claude/settings.local.json` | your approval of the `dispatcher` server; `init` adds it to `.gitignore` | **never** |
126
+
127
+ It ends by printing your public key and fingerprint: the same ones as in step 2. It is safe to run again, and running
128
+ it again with a newer client updates the skills.
129
+
130
+ If a teammate has already committed the setup, run `init` anyway: it reports the shared files as unchanged and writes
131
+ your approval.
132
+
133
+ ### If your team keeps the Claude Code setup in another repository
134
+
135
+ Some teams don't commit `.claude`, `.mcp.json` or `.alterspec-client` in the code repository, but keep them in a
136
+ shared repository next to it and link them in with symlinks. That works:
137
+
138
+ - Keep the links out of git on your machine: add each one to `.git/info/exclude` (never committed), e.g.
139
+ `echo "/.mcp.json" >> .git/info/exclude`. `git status` should not list them.
140
+ - Run `init` as above. Because `.claude` is a link, it may say it can't tell whether `.claude/settings.local.json` is
141
+ ignored: make sure the shared repository ignores that file.
142
+ - If `init` reports skills or `.claude/settings.json` as created or updated, the shared repository is behind the
143
+ client: tell whoever maintains it rather than committing there yourself.
144
+
145
+ Task worktrees get these links too: git-ignored links are linked into each new worktree, and a link committed with a
146
+ relative target is made to resolve there. This needs client 0.4.4 or later.
147
+
148
+ ## Step 5: Check that you can sign in
149
+
150
+ Once your admin confirms your key is added:
151
+
152
+ ```bash
153
+ npx @alterset/alterspec-client open dispatcher
154
+ ```
155
+
156
+ It opens the dispatcher in your browser, signed in as you: the dashboard, the changes and tasks, the graph of what
157
+ waits for what. If it says the dispatcher refused your SSH key, send your admin the two lines it prints.
158
+
159
+ ## Step 6: Working with Claude Code
160
+
161
+ **Start a new Claude Code session** in your code repository: a session that was already open doesn't see the new
162
+ server. Then talk to it in plain words; the skills do the rest.
163
+
164
+ | You say or type | What happens |
165
+ | ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
166
+ | "give me work" / `/alterspec-task-next` | takes the next available task on your track, creates its branch `task/chg-023-be` from `origin/<branch>` here, and shows the brief |
167
+ | "let's work on my task" / `/alterspec-task-context` | the task's brief from the spec: why, the checklist, the objects it changes (before and after), rules, acceptance criteria; for a UI track also the screens, their contracts, mockups and design system |
168
+ | "what am I on?" / `/alterspec-task-status` | your tasks with progress and ETA, what's available on your tracks, what is blocked and by what |
169
+ | "what does RULE-… say?" / `/alterspec-spec-ask` | answers about the product from the spec, citing IDs; reads only |
170
+ | `/alterspec-task-done CHG-023/BE` | after your branch is merged: reports the task done with the commit that brought it in; refused while the work isn't merged |
171
+ | `/alterspec-task-release CHG-023/BE <reason>` | gives the task back so someone else can take it; its branch stays |
172
+ | `/alterspec-task-eta CHG-023/BE <YYYY-MM-DD> <reason>` | sets your own date when the computed ETA is wrong; `clear` instead of the date removes it |
173
+
174
+ **done**, **release** and **eta** happen only when you type them; Claude never does them on its own.
175
+
176
+ ### A task, start to finish
177
+
178
+ 1. "Give me work." Claude takes a task, creates its branch and shows the brief and its checklist.
179
+ 2. Build it with Claude in your own technology. The spec says what, never how; a mockup shows the agreed look and
180
+ behaviour, it is not code to copy. When the spec is silent or disagrees with the code, Claude asks you.
181
+ 3. Claude ends every commit of the task with a trailer:
182
+
183
+ ```
184
+ Alterspec-Task: CHG-023/BE
185
+ Alterspec-Covers: CAP-CAT-001-AC-03, CAP-CAT-002
186
+ ```
187
+
188
+ `Alterspec-Covers` names the checklist items whose tests pass with that commit, never items that aren't tested yet.
189
+ After each commit a hook reports them in the background, and the task's progress on the dashboard moves.
190
+
191
+ 4. Push the branch, open a pull request into the main branch as usual, get it reviewed and merged.
192
+ 5. Type `/alterspec-task-done CHG-023/BE`.
193
+
194
+ ### Several tasks at once
195
+
196
+ Ask for more than one: `/alterspec-task-next BE 2`. The client creates a worktree and branch for each task in
197
+ `../<code-repo>-tasks/` and lists their folders. Start a separate Claude Code session in each folder and type
198
+ `/alterspec-task-context <task>` there. The dispatcher never gives you two tasks on the same track that change the same
199
+ objects, so the worktrees don't conflict.
200
+
201
+ ### Good to know
202
+
203
+ - **Start from a clean checkout.** Taking a single task switches this checkout to its branch, which is refused while you
204
+ have uncommitted changes to tracked files; commit or stash them first.
205
+ - **A UI task waits for its `BE` task.** "Nothing available" on a UI track usually means the backend part isn't done
206
+ yet; `/alterspec-task-status` says what blocks what.
207
+ - **The scope is the spec's.** If the brief and the code disagree, or something in the spec looks wrong, ask whoever
208
+ owns the spec; don't widen or narrow the task yourself.
209
+ - **Only you move your task on.** Going away for a while? Release it. An admin can force a release only when you are
210
+ gone, and that is logged.
211
+ - **Keep the client current.** Run `init` again now and then (or when your admin says so); it updates the skills.
212
+ - **Tell Claude about the spec outside the skills too.** The skills explain the export only while they run. Copy the
213
+ block in [`agent-instructions.md`](agent-instructions.md) (in this package) into your `CLAUDE.md` or wherever you
214
+ keep your agent's instructions, with your export clone's path.
215
+
216
+ ## When something goes wrong
217
+
218
+ | You see | Do |
219
+ | ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
220
+ | "The dispatcher refused your SSH key" | your key isn't added yet, or you sign with another key: send your admin the two lines it prints (or `npx @alterset/alterspec-client key`) |
221
+ | "That is not a public key the dispatcher accepts" | you used an RSA key: make an Ed25519 key (step 1) and send it |
222
+ | "No SSH key to sign with" | create `~/.ssh/id_ed25519` (step 1), or point `--key` at your key and run `init` again |
223
+ | "ssh-agent doesn't hold the key" | `ssh-add` your key (step 1) |
224
+ | `E401` or `E404` running `npx @alterset/...` | npm is set to a private registry that doesn't have the client. The client is on the public registry: add `registry=https://registry.npmjs.org/` to the repository's `.npmrc`, or fix your registry login |
225
+ | Claude has no `dispatcher` tools | run `init` again (it approves the server), make sure git doesn't track `.claude/settings.local.json`, and start a new session. In a terminal `claude` session, `/mcp` shows and approves the server too |
226
+ | "No .alterspec-client.json here" | run `init` in this repository (step 4) |
227
+ | "The export is N commits behind the dispatcher" | your export clone couldn't be pulled: `git -C ../<product>-export pull`, and check its remote if it keeps happening |
228
+ | an item reported as unknown | a commit's `Alterspec-Covers` named something the checklist lacks. A pushed commit can't be corrected; name the right item on a later commit |
229
+ | `task-done` refused: not merged | merge the pull request into the main branch first, then run it again |
230
+ | a worktree link "points nowhere", or `worktree` refuses | a symlink in your repository doesn't resolve from the task worktree; the message says which and what to do. Update the client to 0.4.4 or later first |
231
+ | anything else | send your admin the message exactly as it appears |
package/dist/cli.js CHANGED
@@ -964,8 +964,8 @@ function renderContext(c) {
964
964
 
965
965
  // src/git.ts
966
966
  import { execFileSync as execFileSync3 } from "child_process";
967
- import { existsSync as existsSync4, realpathSync } from "fs";
968
- import { join as join4, resolve as resolve2 } from "path";
967
+ import { existsSync as existsSync4, lstatSync, readdirSync as readdirSync2, readlinkSync, realpathSync, symlinkSync } from "fs";
968
+ import { dirname as dirname2, isAbsolute as isAbsolute2, join as join4, relative, resolve as resolve2 } from "path";
969
969
 
970
970
  // src/task.ts
971
971
  var TRAILER = "Alterspec-Task";
@@ -1041,27 +1041,94 @@ function taskWorktree(repo, task, opts) {
1041
1041
  tryGit(repo, ["fetch", "--quiet", "origin", opts.main]);
1042
1042
  const base = `origin/${opts.main}`;
1043
1043
  if (opts.here) {
1044
- const top = git2(repo, ["rev-parse", "--show-toplevel"]);
1044
+ const top2 = git2(repo, ["rev-parse", "--show-toplevel"]);
1045
1045
  if (tryGit(repo, ["symbolic-ref", "--short", "HEAD"]) === branch)
1046
- return { path: top, branch, created: false };
1046
+ return { path: top2, branch, created: false };
1047
1047
  if (git2(repo, ["status", "--porcelain", "--untracked-files=no"]))
1048
1048
  throw new GitError(
1049
1049
  `This checkout has uncommitted work: commit or stash it before switching to ${branch}.`
1050
1050
  );
1051
1051
  if (branchExists(repo, branch)) {
1052
1052
  git2(repo, ["switch", "--quiet", branch]);
1053
- return { path: top, branch, created: false };
1053
+ return { path: top2, branch, created: false };
1054
1054
  }
1055
1055
  git2(repo, ["switch", "--quiet", "--no-track", "-c", branch, base]);
1056
- return { path: top, branch, created: true };
1056
+ return { path: top2, branch, created: true };
1057
1057
  }
1058
1058
  const path = resolve2(opts.worktreesDir, folderOf(task));
1059
1059
  const listed = git2(repo, ["worktree", "list", "--porcelain"]).split("\n").filter((l) => l.startsWith("worktree ")).map((l) => real(l.slice("worktree ".length)));
1060
- if (listed.includes(real(path))) return { path, branch, created: false };
1060
+ const top = git2(repo, ["rev-parse", "--show-toplevel"]);
1061
+ if (listed.includes(real(path))) {
1062
+ const bridges = bridgeTrackedLinks(top, path);
1063
+ return { path, branch, created: false, bridges, dangling: danglingLinks(path) };
1064
+ }
1061
1065
  if (branchExists(repo, branch)) git2(repo, ["worktree", "add", "--quiet", path, branch]);
1062
1066
  else git2(repo, ["worktree", "add", "--quiet", "--no-track", "-b", branch, path, base]);
1063
- return { path, branch, created: true };
1067
+ return {
1068
+ path,
1069
+ branch,
1070
+ created: true,
1071
+ links: mirrorIgnoredLinks(top, path),
1072
+ bridges: bridgeTrackedLinks(top, path),
1073
+ dangling: danglingLinks(path)
1074
+ };
1075
+ }
1076
+ var danglingLinks = (worktree) => readdirSync2(worktree, { withFileTypes: true }).filter((e) => e.isSymbolicLink() && !existsSync4(join4(worktree, e.name))).map((e) => e.name);
1077
+ function mirrorIgnoredLinks(top, worktree) {
1078
+ const links = readdirSync2(top, { withFileTypes: true }).filter((e) => e.isSymbolicLink()).map((e) => e.name);
1079
+ if (!links.length) return [];
1080
+ const ignored = new Set((tryGit(top, ["check-ignore", "--", ...links]) ?? "").split("\n").filter(Boolean));
1081
+ const at = real(worktree);
1082
+ return links.filter((name) => {
1083
+ if (!ignored.has(name) || present(join4(at, name))) return false;
1084
+ const target = readlinkSync(join4(top, name));
1085
+ symlinkSync(isAbsolute2(target) ? target : relative(at, resolve2(top, target)), join4(at, name));
1086
+ return true;
1087
+ });
1064
1088
  }
1089
+ function bridgeTrackedLinks(top, worktree) {
1090
+ const at = real(worktree);
1091
+ const bridges = [];
1092
+ for (const entry of readdirSync2(at, { withFileTypes: true })) {
1093
+ const link = join4(at, entry.name);
1094
+ if (!entry.isSymbolicLink() || existsSync4(link)) continue;
1095
+ const target = readlinkSync(link);
1096
+ const source = resolve2(top, target);
1097
+ if (isAbsolute2(target) || !existsSync4(source)) continue;
1098
+ let missing = resolve2(at, target);
1099
+ let from = source;
1100
+ while (!present(dirname2(missing))) {
1101
+ missing = dirname2(missing);
1102
+ from = dirname2(from);
1103
+ }
1104
+ const inside = (dir) => !relative(dir, missing).startsWith("..");
1105
+ const refuse = (why, fix) => new GitError(
1106
+ `${entry.name} in ${at} points to ${target}, which resolves from the checkout but not from the worktree, and ${why}: ${fix}.`
1107
+ );
1108
+ const untrack = "keep the link out of git (ignored, not committed), so the client links it into each worktree";
1109
+ if (inside(at) || inside(top))
1110
+ throw refuse(`the folder it misses, ${missing}, lies inside a checkout`, untrack);
1111
+ const parent = dirname2(missing);
1112
+ if (present(missing) || !existsSync4(parent) || realpathSync(parent) !== parent) {
1113
+ const blocking = present(missing) ? missing : parent;
1114
+ throw refuse(
1115
+ `${blocking} is in the way`,
1116
+ `remove it, or make it lead to ${present(missing) ? from : parent}`
1117
+ );
1118
+ }
1119
+ symlinkSync(relative(parent, from), missing);
1120
+ bridges.push(missing);
1121
+ }
1122
+ return bridges;
1123
+ }
1124
+ var present = (path) => {
1125
+ try {
1126
+ lstatSync(path);
1127
+ return true;
1128
+ } catch {
1129
+ return false;
1130
+ }
1131
+ };
1065
1132
  var real = (path) => existsSync4(path) ? realpathSync(path) : resolve2(path);
1066
1133
  var escape = (s) => s.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
1067
1134
  function mergedCommit(repo, task, main) {
@@ -1091,13 +1158,13 @@ function mergedCommit(repo, task, main) {
1091
1158
 
1092
1159
  // src/install.ts
1093
1160
  import { spawnSync } from "child_process";
1094
- import { existsSync as existsSync6, mkdirSync as mkdirSync2, readFileSync as readFileSync5, readdirSync as readdirSync3, statSync, writeFileSync as writeFileSync4 } from "fs";
1095
- import { join as join6, relative } from "path";
1161
+ import { existsSync as existsSync6, mkdirSync as mkdirSync2, readFileSync as readFileSync5, readdirSync as readdirSync4, statSync, writeFileSync as writeFileSync4 } from "fs";
1162
+ import { join as join6, relative as relative2 } from "path";
1096
1163
  import { fileURLToPath } from "url";
1097
1164
 
1098
1165
  // ../src/install/installer.ts
1099
- import { existsSync as existsSync5, mkdirSync, readFileSync as readFileSync4, readdirSync as readdirSync2, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "fs";
1100
- import { dirname as dirname2, join as join5 } from "path";
1166
+ import { existsSync as existsSync5, mkdirSync, readFileSync as readFileSync4, readdirSync as readdirSync3, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "fs";
1167
+ import { dirname as dirname3, join as join5 } from "path";
1101
1168
 
1102
1169
  // ../src/install/hash.ts
1103
1170
  import { createHash as createHash2 } from "crypto";
@@ -1116,7 +1183,7 @@ function readManifest(root, path = MANIFEST_PATH) {
1116
1183
  }
1117
1184
  function write(root, path, content) {
1118
1185
  const full = join5(root, path);
1119
- mkdirSync(dirname2(full), { recursive: true });
1186
+ mkdirSync(dirname3(full), { recursive: true });
1120
1187
  writeFileSync3(full, content);
1121
1188
  }
1122
1189
  function install(root, plan, opts) {
@@ -1176,8 +1243,8 @@ function install(root, plan, opts) {
1176
1243
  if (sha256(readFileSync4(full, "utf8")) === hash) {
1177
1244
  rmSync2(full);
1178
1245
  result.removed.push(path);
1179
- const folder = dirname2(full);
1180
- if (emptiedFolder.test(folder) && readdirSync2(folder).length === 0)
1246
+ const folder = dirname3(full);
1247
+ if (emptiedFolder.test(folder) && readdirSync3(folder).length === 0)
1181
1248
  rmSync2(folder, { recursive: true });
1182
1249
  } else {
1183
1250
  result.conflicts.push(path);
@@ -1197,10 +1264,10 @@ var MCP_JSON = ".mcp.json";
1197
1264
  var MCP_SERVER = "dispatcher";
1198
1265
  var MCP_ENTRY = { command: "npx", args: ["@alterset/alterspec-client", "mcp"] };
1199
1266
  function walk(dir) {
1200
- return readdirSync3(dir).sort().flatMap((n) => statSync(join6(dir, n)).isDirectory() ? walk(join6(dir, n)) : [join6(dir, n)]);
1267
+ return readdirSync4(dir).sort().flatMap((n) => statSync(join6(dir, n)).isDirectory() ? walk(join6(dir, n)) : [join6(dir, n)]);
1201
1268
  }
1202
1269
  var assetFiles = (sub) => walk(join6(ASSETS_DIR, sub)).map((f) => ({
1203
- rel: relative(join6(ASSETS_DIR, sub), f).split("\\").join("/"),
1270
+ rel: relative2(join6(ASSETS_DIR, sub), f).split("\\").join("/"),
1204
1271
  content: readFileSync5(f, "utf8")
1205
1272
  }));
1206
1273
  function buildClientPlan(version) {
@@ -1736,7 +1803,12 @@ program.command("worktree").description("create the task\u2019s branch task/<chg
1736
1803
  worktreesDir: worktreesDir(loaded),
1737
1804
  here: opts.here
1738
1805
  });
1739
- if (!opts.here) writeLocalSettings(wt.path);
1806
+ if (wt.dangling?.length)
1807
+ process.stderr.write(
1808
+ `In ${wt.path}, ${wt.dangling.join(", ")} ${wt.dangling.length === 1 ? "points" : "point"} nowhere. A symlink git tracks is checked out as it is, so a relative target made for the checkout doesn't resolve from the worktree: keep such links out of git (ignored, not committed) and the client links them into each worktree, or fix them there.
1809
+ `
1810
+ );
1811
+ if (!opts.here && !wt.dangling?.includes(".claude")) writeLocalSettings(wt.path);
1740
1812
  process.stdout.write(JSON.stringify(wt, null, 2) + "\n");
1741
1813
  })
1742
1814
  );