@nightloom/isy 1.0.1 → 1.0.3

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 (152) hide show
  1. package/README.md +1 -1
  2. package/dist/agents/claude.js +18 -7
  3. package/dist/agents/claude.js.map +1 -1
  4. package/dist/agents/codex-records.js +16 -2
  5. package/dist/agents/codex-records.js.map +1 -1
  6. package/dist/agents/index.d.ts +16 -5
  7. package/dist/agents/index.js +21 -6
  8. package/dist/agents/index.js.map +1 -1
  9. package/dist/agents/kimi-cli-wire.d.ts +17 -0
  10. package/dist/agents/kimi-cli-wire.js +312 -0
  11. package/dist/agents/kimi-cli-wire.js.map +1 -0
  12. package/dist/agents/kimi-config.d.ts +29 -0
  13. package/dist/agents/kimi-config.js +193 -0
  14. package/dist/agents/kimi-config.js.map +1 -0
  15. package/dist/agents/kimi-records.d.ts +0 -6
  16. package/dist/agents/kimi-records.js +51 -31
  17. package/dist/agents/kimi-records.js.map +1 -1
  18. package/dist/agents/kimi-tools.d.ts +30 -0
  19. package/dist/agents/kimi-tools.js +100 -0
  20. package/dist/agents/kimi-tools.js.map +1 -0
  21. package/dist/agents/kimi-wire.d.ts +8 -0
  22. package/dist/agents/kimi-wire.js +245 -80
  23. package/dist/agents/kimi-wire.js.map +1 -1
  24. package/dist/agents/kimi.d.ts +13 -2
  25. package/dist/agents/kimi.js +633 -114
  26. package/dist/agents/kimi.js.map +1 -1
  27. package/dist/agents/timeline.d.ts +36 -0
  28. package/dist/agents/timeline.js +61 -0
  29. package/dist/agents/timeline.js.map +1 -0
  30. package/dist/agents/types.d.ts +12 -0
  31. package/dist/api.d.ts +3 -0
  32. package/dist/api.js +1 -1
  33. package/dist/api.js.map +1 -1
  34. package/dist/commands/analyze.d.ts +2 -0
  35. package/dist/commands/analyze.js +63 -6
  36. package/dist/commands/analyze.js.map +1 -1
  37. package/dist/commands/check.js +11 -0
  38. package/dist/commands/check.js.map +1 -1
  39. package/dist/commands/health.js +2 -2
  40. package/dist/commands/health.js.map +1 -1
  41. package/dist/commands/init.js +25 -2
  42. package/dist/commands/init.js.map +1 -1
  43. package/dist/commands/upload.d.ts +2 -0
  44. package/dist/commands/upload.js +38 -7
  45. package/dist/commands/upload.js.map +1 -1
  46. package/dist/detectors.js +40 -5
  47. package/dist/detectors.js.map +1 -1
  48. package/dist/hook.d.ts +12 -5
  49. package/dist/hook.js +73 -17
  50. package/dist/hook.js.map +1 -1
  51. package/dist/lines.d.ts +8 -0
  52. package/dist/lines.js +32 -0
  53. package/dist/lines.js.map +1 -0
  54. package/dist/mask-paths.js +31 -15
  55. package/dist/mask-paths.js.map +1 -1
  56. package/dist/parser.d.ts +41 -0
  57. package/dist/parser.js +345 -36
  58. package/dist/parser.js.map +1 -1
  59. package/dist/paths.d.ts +4 -0
  60. package/dist/paths.js +39 -39
  61. package/dist/paths.js.map +1 -1
  62. package/dist/plan.d.ts +3 -1
  63. package/dist/plan.js +5 -1
  64. package/dist/plan.js.map +1 -1
  65. package/dist/queue.d.ts +14 -2
  66. package/dist/queue.js +25 -3
  67. package/dist/queue.js.map +1 -1
  68. package/dist/redact.d.ts +17 -0
  69. package/dist/redact.js +202 -12
  70. package/dist/redact.js.map +1 -1
  71. package/dist/state.d.ts +15 -6
  72. package/dist/state.js +25 -9
  73. package/dist/state.js.map +1 -1
  74. package/dist/subagents.d.ts +53 -0
  75. package/dist/subagents.js +243 -0
  76. package/dist/subagents.js.map +1 -0
  77. package/dist/test/check.test.js +25 -3
  78. package/dist/test/check.test.js.map +1 -1
  79. package/dist/test/codex.test.js +21 -0
  80. package/dist/test/codex.test.js.map +1 -1
  81. package/dist/test/commit.test.js +9 -1
  82. package/dist/test/commit.test.js.map +1 -1
  83. package/dist/test/hook.test.js +66 -2
  84. package/dist/test/hook.test.js.map +1 -1
  85. package/dist/test/init.test.d.ts +1 -0
  86. package/dist/test/init.test.js +102 -0
  87. package/dist/test/init.test.js.map +1 -0
  88. package/dist/test/kimi-cli.test.d.ts +1 -0
  89. package/dist/test/kimi-cli.test.js +231 -0
  90. package/dist/test/kimi-cli.test.js.map +1 -0
  91. package/dist/test/kimi-code.test.d.ts +1 -0
  92. package/dist/test/kimi-code.test.js +302 -0
  93. package/dist/test/kimi-code.test.js.map +1 -0
  94. package/dist/test/kimi-config.test.d.ts +1 -0
  95. package/dist/test/kimi-config.test.js +224 -0
  96. package/dist/test/kimi-config.test.js.map +1 -0
  97. package/dist/test/kimi-hook.test.d.ts +1 -0
  98. package/dist/test/kimi-hook.test.js +163 -0
  99. package/dist/test/kimi-hook.test.js.map +1 -0
  100. package/dist/test/kimi-listing.test.d.ts +1 -0
  101. package/dist/test/kimi-listing.test.js +193 -0
  102. package/dist/test/kimi-listing.test.js.map +1 -0
  103. package/dist/test/kimi.test.js +52 -7
  104. package/dist/test/kimi.test.js.map +1 -1
  105. package/dist/test/mask-paths.test.js +31 -0
  106. package/dist/test/mask-paths.test.js.map +1 -1
  107. package/dist/test/parser.test.js +208 -5
  108. package/dist/test/parser.test.js.map +1 -1
  109. package/dist/test/plan.test.js +7 -6
  110. package/dist/test/plan.test.js.map +1 -1
  111. package/dist/test/redact.test.js +245 -8
  112. package/dist/test/redact.test.js.map +1 -1
  113. package/dist/test/stage0.test.js +49 -0
  114. package/dist/test/stage0.test.js.map +1 -1
  115. package/dist/test/subagents.test.d.ts +1 -0
  116. package/dist/test/subagents.test.js +290 -0
  117. package/dist/test/subagents.test.js.map +1 -0
  118. package/dist/test/sweep.test.js +25 -0
  119. package/dist/test/sweep.test.js.map +1 -1
  120. package/dist/test/upload.test.js +68 -6
  121. package/dist/test/upload.test.js.map +1 -1
  122. package/dist/types.d.ts +16 -0
  123. package/package.json +5 -3
  124. package/src/agents/claude.ts +17 -7
  125. package/src/agents/codex-records.ts +17 -2
  126. package/src/agents/index.ts +21 -6
  127. package/src/agents/kimi-cli-wire.ts +350 -0
  128. package/src/agents/kimi-config.ts +210 -0
  129. package/src/agents/kimi-records.ts +52 -29
  130. package/src/agents/kimi-tools.ts +128 -0
  131. package/src/agents/kimi-wire.ts +270 -82
  132. package/src/agents/kimi.ts +653 -113
  133. package/src/agents/timeline.ts +68 -0
  134. package/src/agents/types.ts +12 -0
  135. package/src/api.ts +5 -2
  136. package/src/commands/analyze.ts +62 -6
  137. package/src/commands/check.ts +11 -0
  138. package/src/commands/health.ts +2 -2
  139. package/src/commands/init.ts +26 -2
  140. package/src/commands/upload.ts +46 -7
  141. package/src/detectors.ts +39 -5
  142. package/src/hook.ts +81 -24
  143. package/src/lines.ts +31 -0
  144. package/src/mask-paths.ts +31 -14
  145. package/src/parser.ts +356 -35
  146. package/src/paths.ts +36 -33
  147. package/src/plan.ts +4 -1
  148. package/src/queue.ts +30 -4
  149. package/src/redact.ts +218 -15
  150. package/src/state.ts +34 -9
  151. package/src/subagents.ts +292 -0
  152. package/src/types.ts +16 -0
package/src/hook.ts CHANGED
@@ -4,7 +4,7 @@ import type { AgentHook } from "./agents/types.js";
4
4
  import { claudeConfigDir, claudeSettingsPath } from "./paths.js";
5
5
 
6
6
  export const HOOK_EVENT = "SessionEnd";
7
- export const HOOK_COMMAND = "npx @nightloom/isy upload --hook";
7
+ export const HOOK_COMMAND = "exec 3<&0; nohup npx @nightloom/isy upload --hook <&3 >/dev/null 2>&1 &";
8
8
  export const START_HOOK_EVENT = "SessionStart";
9
9
  export const START_HOOK_COMMAND = "npx @nightloom/isy check --hook";
10
10
 
@@ -18,11 +18,29 @@ export const START_HOOK_COMMAND = "npx @nightloom/isy check --hook";
18
18
  * installing over it rewrites that line in place instead of leaving two hooks
19
19
  * to fire.
20
20
  */
21
- export const ISY_HOOKS: { event: string; command: string; superseded: string[] }[] = [
21
+ export const ISY_HOOKS: (AgentHook & { superseded: string[] })[] = [
22
22
  {
23
23
  event: HOOK_EVENT,
24
+ // Detached, the way Kimi CLI's and Codex's are. Claude Code 2.1 cancels a
25
+ // SessionEnd hook after 1.5 seconds unless it asks for more — before `npx`
26
+ // has even started node, so every upload at the end of a session was
27
+ // killed — and it waits out whatever a hook asks for on `/clear` and
28
+ // `/resume` too, so a hook given the upload's own thirty seconds froze
29
+ // both for as long as the upload took. The shell returns at once and the
30
+ // upload outlives it. A background job's stdin is /dev/null, so the
31
+ // payload is handed over on fd 3 first: without it the upload took the
32
+ // newest session in the cwd, the wrong one whenever two share a directory.
33
+ // Its line is parked for the next session start (`claude.ts:deliver`).
34
+ //
35
+ // ponytail: POSIX `&`. Claude Code runs hooks through bash (Git Bash on
36
+ // Windows), so this holds wherever it does; a hook shell without `nohup`
37
+ // loses the upload to the sweep at the next session start.
24
38
  command: HOOK_COMMAND,
25
- superseded: ["npx isy upload --silent", "npx isy upload --hook"],
39
+ superseded: [
40
+ "npx isy upload --silent",
41
+ "npx isy upload --hook",
42
+ "npx @nightloom/isy upload --hook",
43
+ ],
26
44
  },
27
45
  { event: START_HOOK_EVENT, command: START_HOOK_COMMAND, superseded: ["npx isy check --hook"] },
28
46
  ];
@@ -93,16 +111,20 @@ function matchers(settings: Record<string, unknown>, event: string): HookMatcher
93
111
  return Array.isArray(entries) ? (entries.filter(isObject) as HookMatcher[]) : [];
94
112
  }
95
113
 
114
+ /** An entry running one of `commands`, and — when one is asked for — with that timeout. */
115
+ function runs(entry: unknown, commands: readonly string[], timeout?: number): boolean {
116
+ if (!isObject(entry) || typeof entry.command !== "string" || !commands.includes(entry.command)) return false;
117
+ return timeout === undefined || entry.timeout === timeout;
118
+ }
119
+
96
120
  function hasHook(
97
121
  settings: Record<string, unknown>,
98
122
  event: string,
99
123
  commands: readonly string[],
124
+ timeout?: number,
100
125
  ): boolean {
101
126
  return matchers(settings, event).some((matcher) =>
102
- Array.isArray(matcher.hooks) &&
103
- matcher.hooks.some(
104
- (entry) => isObject(entry) && typeof entry.command === "string" && commands.includes(entry.command),
105
- ),
127
+ Array.isArray(matcher.hooks) && matcher.hooks.some((entry) => runs(entry, commands, timeout)),
106
128
  );
107
129
  }
108
130
 
@@ -131,23 +153,20 @@ function stripHook(
131
153
  }
132
154
 
133
155
  /**
134
- * Swap the first superseded command for its replacement at the same group and
135
- * position, dropping any further copies, so no group's index moves.
156
+ * Swap the first entry running one of `commands` for the hook as it should be
157
+ * written, at the same group and position, dropping any further copies, so no
158
+ * group's index moves. The same swap brings an older command up to date and
159
+ * gives the current one a timeout it was written without.
136
160
  */
137
- function replaceSuperseded(
138
- groups: unknown[],
139
- commands: readonly string[],
140
- command: string,
141
- ): boolean {
161
+ function replaceSuperseded(groups: unknown[], commands: readonly string[], hook: AgentHook): boolean {
142
162
  let replaced = false;
143
163
  for (const group of groups) {
144
164
  if (!isObject(group) || !Array.isArray(group.hooks)) continue;
145
165
  group.hooks = (group.hooks as unknown[]).filter((entry: unknown) => {
146
- if (!isObject(entry) || typeof entry.command !== "string" || !commands.includes(entry.command)) {
147
- return true;
148
- }
166
+ if (!isObject(entry) || !runs(entry, commands)) return true;
149
167
  if (replaced) return false;
150
- entry.command = command;
168
+ entry.command = hook.command;
169
+ if (hook.timeout !== undefined) entry.timeout = hook.timeout;
151
170
  replaced = true;
152
171
  return true;
153
172
  });
@@ -155,16 +174,45 @@ function replaceSuperseded(
155
174
  return replaced;
156
175
  }
157
176
 
177
+ /**
178
+ * Bring the entries an older isy wrote up to date, in place, and add nothing:
179
+ * a hook that is not there at all stays away — that is the reader's call, and
180
+ * `isy check` names it. The SessionStart hook runs this, so an upgrade needs no
181
+ * `isy init`, which pairs the browser again, and on a plan with one key asks
182
+ * the reader to revoke the key in use first. Whether anything changed.
183
+ */
184
+ export async function repairHooksIn(file: HookFile): Promise<boolean> {
185
+ const settings = await readSettings(file);
186
+ const stale = file.hooks.filter(
187
+ (hook) =>
188
+ !hasHook(settings, hook.event, [hook.command], hook.timeout) &&
189
+ hasHook(settings, hook.event, [hook.command, ...(hook.superseded ?? [])]),
190
+ );
191
+ if (stale.length === 0) return false;
192
+
193
+ const hooks = isObject(settings.hooks) ? { ...settings.hooks } : {};
194
+ for (const hook of stale) {
195
+ const existing = [...(hooks[hook.event] as unknown[])];
196
+ replaceSuperseded(existing, [hook.command, ...(hook.superseded ?? [])], hook);
197
+ hooks[hook.event] = existing;
198
+ }
199
+
200
+ await writeSettings(file, { ...settings, hooks });
201
+ return true;
202
+ }
203
+
158
204
  export async function installedHooksIn(file: HookFile): Promise<string[]> {
159
205
  const settings = await readSettings(file);
160
- return file.hooks.filter((hook) => hasHook(settings, hook.event, [hook.command])).map(
206
+ return file.hooks.filter((hook) => hasHook(settings, hook.event, [hook.command], hook.timeout)).map(
161
207
  (hook) => hook.event,
162
208
  );
163
209
  }
164
210
 
165
211
  export async function installHookIn(file: HookFile): Promise<"installed" | "already-present"> {
166
212
  const settings = await readSettings(file);
167
- const missing = file.hooks.filter((hook) => !hasHook(settings, hook.event, [hook.command]));
213
+ const missing = file.hooks.filter(
214
+ (hook) => !hasHook(settings, hook.event, [hook.command], hook.timeout),
215
+ );
168
216
  if (missing.length === 0) return "already-present";
169
217
 
170
218
  const hooks = isObject(settings.hooks) ? { ...settings.hooks } : {};
@@ -179,9 +227,14 @@ export async function installHookIn(file: HookFile): Promise<"installed" | "alre
179
227
  // after it — and with them the positions Codex keys its approvals on, so
180
228
  // the user's hooks would lose their approval and ours would inherit one it
181
229
  // was never given.
182
- const replaced =
183
- hook.superseded !== undefined && replaceSuperseded(existing, hook.superseded, hook.command);
184
- if (!replaced) existing.push({ hooks: [{ type: "command", command: hook.command }] });
230
+ const replaced = replaceSuperseded(existing, [hook.command, ...(hook.superseded ?? [])], hook);
231
+ if (!replaced) {
232
+ existing.push({
233
+ hooks: [
234
+ { type: "command", command: hook.command, ...(hook.timeout !== undefined ? { timeout: hook.timeout } : {}) },
235
+ ],
236
+ });
237
+ }
185
238
 
186
239
  hooks[hook.event] = existing;
187
240
  }
@@ -213,7 +266,7 @@ export async function removeHookIn(file: HookFile): Promise<"removed" | "absent"
213
266
  export async function isHookInstalled(): Promise<boolean> {
214
267
  const file = claudeHookFile();
215
268
  const settings = await readSettings(file);
216
- return ISY_HOOKS.every((hook) => hasHook(settings, hook.event, [hook.command]));
269
+ return ISY_HOOKS.every((hook) => hasHook(settings, hook.event, [hook.command], hook.timeout));
217
270
  }
218
271
 
219
272
  export function installedHooks(): Promise<string[]> {
@@ -228,6 +281,10 @@ export function removeHook(): Promise<"removed" | "absent"> {
228
281
  return removeHookIn(claudeHookFile());
229
282
  }
230
283
 
284
+ export function repairHooks(): Promise<boolean> {
285
+ return repairHooksIn(claudeHookFile());
286
+ }
287
+
231
288
  export function settingsLocation(): string {
232
289
  return claudeSettingsPath();
233
290
  }
package/src/lines.ts ADDED
@@ -0,0 +1,31 @@
1
+ import { createReadStream } from "node:fs";
2
+
3
+ /**
4
+ * A file's lines, split on "\n" alone, a trailing "\r" dropped. `node:readline`
5
+ * also ends a line at U+2028 and U+2029, which `JSON.stringify` leaves
6
+ * unescaped inside strings: a JSONL record carrying one came apart into two
7
+ * fragments that neither parsed nor had their secrets redacted by key. Breaking
8
+ * out of the loop closes the file.
9
+ */
10
+ export async function* fileLines(path: string): AsyncGenerator<string> {
11
+ const input = createReadStream(path, { encoding: "utf8" });
12
+ let rest = "";
13
+ try {
14
+ for await (const chunk of input as AsyncIterable<string>) {
15
+ let from = 0;
16
+ for (let at = chunk.indexOf("\n"); at !== -1; at = chunk.indexOf("\n", from)) {
17
+ yield withoutCr(rest + chunk.slice(from, at));
18
+ rest = "";
19
+ from = at + 1;
20
+ }
21
+ rest += chunk.slice(from);
22
+ }
23
+ if (rest.length > 0) yield withoutCr(rest);
24
+ } finally {
25
+ input.destroy();
26
+ }
27
+ }
28
+
29
+ function withoutCr(line: string): string {
30
+ return line.endsWith("\r") ? line.slice(0, -1) : line;
31
+ }
package/src/mask-paths.ts CHANGED
@@ -110,9 +110,10 @@ const URL_LIKE = /[A-Za-z][A-Za-z0-9+.-]*:\/\/[^\s"'`<>]*/;
110
110
  * rather than an address on the network. Node, vitest and Next print
111
111
  * `imported from file:///home/alice/…` on an unresolved import, and that lands
112
112
  * in a tool result like any other line of stdout; an editor spells the same
113
- * path `vscode://file/home/alice/…`. The scheme is kept, the path masked.
113
+ * path `vscode://file/home/alice/…`, and some tools `file://localhost/home/…`.
114
+ * The scheme is kept, the path masked.
114
115
  */
115
- const LOCAL_URL = /^((?:file|vscode(?:-insiders)?):\/\/(?:file)?)(\/[^\s"'`<>]*)$/;
116
+ const LOCAL_URL = /^((?:file|vscode(?:-insiders)?):\/\/(?:file|localhost)?)(\/[^\s"'`<>]*)$/;
116
117
 
117
118
  /**
118
119
  * `\\host\share\…`. The lookbehind keeps a drive letter out: a transcript line
@@ -127,9 +128,19 @@ const UNC = new RegExp(
127
128
  `(?<![A-Za-z0-9:~\\\\])\\\\\\\\${SEG.source}+(?:[\\\\/]+${SEG.source}+)*[\\\\/]?`,
128
129
  );
129
130
 
131
+ /**
132
+ * What ends an escape rather than a word, so a path may open right after it:
133
+ * `\n`, `\u001b`, `\x22`, and a terminal's colour code (`ESC[2m`), raw or
134
+ * escaped — test runners colour the paths they print.
135
+ */
136
+ const ESCAPE_END = String.raw`(?:\\[A-Za-z0-9]|\\u[0-9A-Fa-f]{4}|\\x[0-9A-Fa-f]{2}|(?:\x1b|\\u001b|\\x1b|\\033|\\e)\[[0-9;]*m)`;
137
+
138
+ /** A letter or digit right before a path continues a word, unless it ends an escape. */
139
+ const NOT_A_WORD = `(?<![A-Za-z0-9](?<!${ESCAPE_END}))`;
140
+
130
141
  /** Separators repeat for the same reason: JSON doubles every backslash. */
131
142
  const WINDOWS = new RegExp(
132
- `(?<![A-Za-z0-9])[A-Za-z]:[\\\\/]+(?:${SEG.source}+[\\\\/]+)*${SEG.source}*`,
143
+ `${NOT_A_WORD}[A-Za-z]:[\\\\/]+(?:${SEG.source}+[\\\\/]+)*${SEG.source}*`,
133
144
  );
134
145
 
135
146
  /**
@@ -140,14 +151,17 @@ const WINDOWS = new RegExp(
140
151
  * `~` stays, and that is all idempotence needs: masking twice is masking once,
141
152
  * because `./dist/b.js` and `100%/x` are under no root and come back unchanged.
142
153
  *
143
- * The inner lookbehind is the one exception to the letter rule: a letter that
144
- * is itself behind a backslash ends an escape sequence rather than a word. Tool
145
- * output reaches a transcript JSON-encoded twice often enough for that to
146
- * matter — Prisma reports `invocation in\\n/home/alice/…`, and read as a word
147
- * `in\\n` carried the account name through untouched.
154
+ * The one exception to the letter rule is a letter that ends an escape rather
155
+ * than a word (`ESCAPE_END`). Tool output reaches a transcript JSON-encoded
156
+ * twice often enough for that to matter — Prisma reports
157
+ * `invocation in\\n/home/alice/…`, and read as a word `in\\n` carried the
158
+ * account name through untouched.
159
+ *
160
+ * A slash may come escaped, `\/home\/alice\/…`, as PHP and some loggers write
161
+ * JSON; that is still one path.
148
162
  */
149
163
  const POSIX = new RegExp(
150
- `(?<!~)(?<!(?<!\\\\)[A-Za-z0-9])\\/(?:${SEG.source}+\\/)*${SEG.source}+\\/?`,
164
+ `(?<!~)${NOT_A_WORD}\\\\?\\/(?:${SEG.source}+\\\\?\\/)*${SEG.source}+(?:\\\\?\\/)?`,
151
165
  );
152
166
 
153
167
  /**
@@ -180,7 +194,7 @@ const TRAILING = /[.,;:!?]+$/;
180
194
  * slug behind a newline is as much the account name as one behind a slash.
181
195
  */
182
196
  const PROJECT_SLUG =
183
- /(?<![A-Za-z0-9._-])-(?:home|root|users|[a-z]-users)-[A-Za-z0-9._-]*-[A-Za-z0-9._-]+(?![A-Za-z0-9._-])/gi;
197
+ /(?<![A-Za-z0-9._-])-(?:home|root|users|(?:mnt-|cygdrive-)?[a-z]-users)-[A-Za-z0-9._-]*-[A-Za-z0-9._-]+(?![A-Za-z0-9._-])/gi;
184
198
 
185
199
  /**
186
200
  * `-home-alice`: the slug of a session that ran in the home directory itself.
@@ -191,7 +205,7 @@ const PROJECT_SLUG =
191
205
  * known nothing here fires at all.
192
206
  */
193
207
  const HOME_SLUG =
194
- /(?<![A-Za-z0-9._-])-(?:home|root|users|[a-z]-users)-[A-Za-z0-9._]+(?![A-Za-z0-9._-])/gi;
208
+ /(?<![A-Za-z0-9._-])-(?:home|root|users|(?:mnt-|cygdrive-)?[a-z]-users)-[A-Za-z0-9._]+(?![A-Za-z0-9._-])/gi;
195
209
 
196
210
  function maskSlugs(value: string, home: readonly string[] | undefined): string {
197
211
  const masked = value.replace(PROJECT_SLUG, MASK_PROJECT);
@@ -221,7 +235,8 @@ const NOT_AN_ACCOUNT: ReadonlySet<string> = new Set(["shared", "public", "defaul
221
235
  * Which segment of a path would be the account name, or -1 when the path is
222
236
  * not shaped like a home at all. `/home/alice/…` and `/Users/alice/…` name it
223
237
  * second; `C:\Users\alice\…` and the Git Bash spelling `/c/Users/alice/…`
224
- * name it third.
238
+ * name it third, and WSL's `/mnt/c/Users/alice/…` and Cygwin's
239
+ * `/cygdrive/c/Users/alice/…` fourth.
225
240
  *
226
241
  * The spellings are exact because the near misses are ordinary text:
227
242
  * `/users/42/profile` is a URL and `/root/app` is a `WORKDIR`, and neither
@@ -231,7 +246,8 @@ const NOT_AN_ACCOUNT: ReadonlySet<string> = new Set(["shared", "public", "defaul
231
246
  function accountAt(parts: readonly string[]): number {
232
247
  const head = parts[0] ?? "";
233
248
  if (head === "home" || head === "Users") return 1;
234
- if (/^[a-z]:?$/i.test(head) && (parts[1] ?? "").toLowerCase() === "users") return 2;
249
+ const drive = head === "mnt" || head === "cygdrive" ? 1 : 0;
250
+ if (/^[a-z]:?$/i.test(parts[drive] ?? "") && (parts[drive + 1] ?? "").toLowerCase() === "users") return drive + 2;
235
251
  return -1;
236
252
  }
237
253
 
@@ -259,8 +275,9 @@ function genericHome(parts: readonly string[]): string[] | undefined {
259
275
  return parts.slice(account + 1);
260
276
  }
261
277
 
262
- /** `\` when the path was written the Windows way, so a `~` path keeps its shape. */
278
+ /** The separator the path was written with, so a `~` path keeps its shape. */
263
279
  function joiner(value: string): string {
280
+ if (value.includes("\\/")) return "\\/";
264
281
  return value.includes("\\") ? "\\" : "/";
265
282
  }
266
283