pi-odd-worktree 0.0.0-stage → 0.1.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.
Files changed (60) hide show
  1. package/README.md +223 -2
  2. package/extensions/odd-worktree-tools.ts +7593 -0
  3. package/lib/checkout-facts.js +598 -0
  4. package/lib/clipboard.js +226 -0
  5. package/lib/gh-issues.js +1555 -0
  6. package/lib/issue-preview.js +273 -0
  7. package/lib/issues-view.js +2274 -0
  8. package/lib/odd-docs.js +505 -0
  9. package/lib/odd-markdown.js +413 -0
  10. package/lib/odd-view.js +990 -0
  11. package/lib/open-external.js +106 -0
  12. package/lib/preview-scroll-keys.js +192 -0
  13. package/lib/session-auto-name.js +292 -0
  14. package/lib/session-worktree-register.js +62 -0
  15. package/lib/tui-paint.js +273 -0
  16. package/lib/view-layout.js +368 -0
  17. package/lib/warp-create-panel.js +722 -0
  18. package/lib/warp-create-picker.js +906 -0
  19. package/lib/warp-delete-confirm.js +465 -0
  20. package/lib/warp-selector-view.js +1265 -0
  21. package/lib/worktree-card.js +1117 -0
  22. package/lib/worktree-changes.js +1395 -0
  23. package/lib/worktree-close-herdr.js +73 -0
  24. package/lib/worktree-git.js +1048 -0
  25. package/lib/worktree-hooks.js +738 -0
  26. package/lib/worktree-model-result.js +291 -0
  27. package/lib/worktree-registry.js +886 -0
  28. package/lib/worktree-session-guard.js +595 -0
  29. package/lib/worktree-symlinks.js +336 -0
  30. package/lib/worktree-warp-sessions.js +566 -0
  31. package/package.json +36 -4
  32. package/tools/commands.test.js +176 -0
  33. package/tools/fixtures/gh-api-user.json +1 -0
  34. package/tools/fixtures/gh-issue-list.json +1 -0
  35. package/tools/fixtures/gh-issue-view.json +1 -0
  36. package/tools/fixtures/gh-label-list.json +1 -0
  37. package/tools/fixtures/gh-repo-view.json +1 -0
  38. package/tools/fixtures/load-extension.js +66 -0
  39. package/tools/gh-issues-feedback.test.js +359 -0
  40. package/tools/gh-issues.test.js +1502 -0
  41. package/tools/issue-preview.test.js +216 -0
  42. package/tools/issues-command.test.js +1217 -0
  43. package/tools/issues-view.test.js +4401 -0
  44. package/tools/odd-docs.test.js +803 -0
  45. package/tools/odd-markdown.test.js +236 -0
  46. package/tools/odd-view.test.js +2328 -0
  47. package/tools/package-surface.test.js +138 -0
  48. package/tools/t5-session-identity.test.js +306 -0
  49. package/tools/warp-create-panel.test.js +185 -0
  50. package/tools/warp-create-picker.test.js +1357 -0
  51. package/tools/warp-delete-confirm.test.js +616 -0
  52. package/tools/warp-selector-view.test.js +1463 -0
  53. package/tools/worktree-changes.test.js +951 -0
  54. package/tools/worktree-close-herdr-async.test.js +204 -0
  55. package/tools/worktree-odd-migration.test.js +224 -0
  56. package/tools/worktree-registry-cache.test.js +163 -0
  57. package/tools/worktree-registry-odd.test.js +231 -0
  58. package/tools/worktree-registry.test.js +244 -0
  59. package/tools/worktree-session-guard.test.js +507 -0
  60. package/tools/worktree-tools.test.js +434 -0
@@ -0,0 +1,73 @@
1
+ 'use strict';
2
+ // S6: the checkout removal for `worktree_close` — git, and only git.
3
+ //
4
+ // History worth knowing, because the file keeps its name: this module used to
5
+ // reconcile Herdr workspaces around a close (closing every workspace of the
6
+ // checkout's group, then opening a fresh one at the principal, because Herdr
7
+ // has no path move) and could hand the removal to Herdr instead. Both are gone.
8
+ // A deletion performed by this package never closes, opens or retires a Herdr
9
+ // panel, and it never asks Herdr to remove a checkout — Herdr cannot be asked
10
+ // to delete a worktree without retiring the workspace behind the human's back.
11
+ //
12
+ // What remains is one fixed argv: `git worktree remove <absolute path>`, with
13
+ // `--force` only when the caller asked for it. It never deletes the branch and
14
+ // never passes `--trust-repository`.
15
+ //
16
+ // No static package imports (node builtins only), so the extension's
17
+ // copy-to-.mjs test loaders keep working.
18
+
19
+ const path = require('node:path');
20
+
21
+ // Interactive removals can be slow on a large checkout; same bound the close
22
+ // has always used for its remover child.
23
+ const REMOVE_TIMEOUT_MS = 120000;
24
+
25
+ // The removal argv. The target must already be the absolute, verified path —
26
+ // the caller derives it from the registry entry and never from a process cwd.
27
+ // A relative target is refused here rather than resolved against whatever
28
+ // directory the child happens to run in.
29
+ function gitRemovalArgv(resolvedTarget, force) {
30
+ if (typeof resolvedTarget !== 'string' || !path.isAbsolute(resolvedTarget)) {
31
+ throw new TypeError('gitRemovalArgv requires an absolute checkout path');
32
+ }
33
+ const argv = ['worktree', 'remove'];
34
+ if (force === true) argv.push('--force');
35
+ argv.push(resolvedTarget);
36
+ return argv;
37
+ }
38
+
39
+ // Ask git to remove the checkout. `runAsync(bin, argv, options)` is the
40
+ // caller's awaited child runner (lib/worktree-git.js `runArgvAsync`), which
41
+ // spawns synchronously and returns `{status, stdout, stderr, error}`. Resolves;
42
+ // never rejects: every failure is `{removed: false, error}` and the backend's
43
+ // own first-line reason is preserved for the human.
44
+ async function removeCheckout({ runAsync, repoRoot, resolvedTarget, force }) {
45
+ if (typeof runAsync !== 'function') {
46
+ return { removed: false, error: 'the git runner is unavailable, so no checkout was removed' };
47
+ }
48
+ let argv;
49
+ try {
50
+ argv = gitRemovalArgv(resolvedTarget, force === true);
51
+ } catch (err) {
52
+ return { removed: false, error: (err && err.message) || String(err) };
53
+ }
54
+ let out;
55
+ try {
56
+ out = await runAsync('git', argv, { cwd: repoRoot, timeoutMs: REMOVE_TIMEOUT_MS });
57
+ } catch (err) {
58
+ return { removed: false, error: (err && err.message) || String(err) };
59
+ }
60
+ if (!out || out.status !== 0) {
61
+ const text = out && typeof out.stderr === 'string' && out.stderr.trim().length > 0
62
+ ? out.stderr
63
+ : (out && typeof out.error === 'string' ? out.error : '');
64
+ return { removed: false, error: text.trim() || 'git worktree removal failed' };
65
+ }
66
+ return { removed: true, removedBy: 'git' };
67
+ }
68
+
69
+ module.exports = {
70
+ REMOVE_TIMEOUT_MS,
71
+ gitRemovalArgv,
72
+ removeCheckout,
73
+ };