@agimon-ai/doompi-git 0.0.1-alpha.5 → 0.0.1-alpha.50

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 (180) hide show
  1. package/README.md +33 -1
  2. package/dist/apiContracts.cjs +387 -0
  3. package/dist/apiContracts.cjs.map +1 -0
  4. package/dist/apiContracts.d.mts +53 -0
  5. package/dist/apiContracts.d.mts.map +1 -0
  6. package/dist/apiContracts.mjs +382 -0
  7. package/dist/apiContracts.mjs.map +1 -0
  8. package/dist/extensions/pi.cjs +105 -1
  9. package/dist/extensions/pi.cjs.map +1 -0
  10. package/dist/extensions/pi.d.mts +6 -2
  11. package/dist/extensions/pi.d.mts.map +1 -0
  12. package/dist/extensions/pi.mjs +100 -1
  13. package/dist/extensions/pi.mjs.map +1 -0
  14. package/dist/extensions/server.cjs +1828 -0
  15. package/dist/extensions/server.cjs.map +1 -0
  16. package/dist/extensions/server.d.mts +5 -0
  17. package/dist/extensions/server.d.mts.map +1 -0
  18. package/dist/extensions/server.mjs +1820 -0
  19. package/dist/extensions/server.mjs.map +1 -0
  20. package/dist/extensions/web.mjs +2639 -0
  21. package/dist/extensions/web.mjs.map +1 -0
  22. package/dist/gitDependencies-CtVubYvU.mjs +22 -0
  23. package/dist/gitDependencies-CtVubYvU.mjs.map +1 -0
  24. package/dist/gitDependencies-Dqsz2HjK.cjs +33 -0
  25. package/dist/gitDependencies-Dqsz2HjK.cjs.map +1 -0
  26. package/dist/index-D79MSCee.d.mts +145 -0
  27. package/dist/index-D79MSCee.d.mts.map +1 -0
  28. package/dist/index.cjs +4 -1
  29. package/dist/index.d.mts +2 -5
  30. package/dist/index.mjs +2 -1
  31. package/dist/runWorktree-BE795LxL.cjs +374 -0
  32. package/dist/runWorktree-BE795LxL.cjs.map +1 -0
  33. package/dist/runWorktree-SPzJvIBt.mjs +303 -0
  34. package/dist/runWorktree-SPzJvIBt.mjs.map +1 -0
  35. package/dist/worktreeOperations-BYmVU0UV.cjs +1350 -0
  36. package/dist/worktreeOperations-BYmVU0UV.cjs.map +1 -0
  37. package/dist/worktreeOperations-BrWG2muV.mjs +1194 -0
  38. package/dist/worktreeOperations-BrWG2muV.mjs.map +1 -0
  39. package/llms.txt +4 -0
  40. package/package.json +59 -44
  41. package/src/prompts/doompi-use-git/SKILL.md +21 -1
  42. package/dist/_virtual/_rolldown/runtime.cjs +0 -1
  43. package/dist/adapters/channel/worktreeChannel.cjs +0 -2
  44. package/dist/adapters/channel/worktreeChannel.cjs.map +0 -1
  45. package/dist/adapters/channel/worktreeChannel.d.cts +0 -40
  46. package/dist/adapters/channel/worktreeChannel.d.cts.map +0 -1
  47. package/dist/adapters/channel/worktreeChannel.d.mts +0 -40
  48. package/dist/adapters/channel/worktreeChannel.d.mts.map +0 -1
  49. package/dist/adapters/channel/worktreeChannel.mjs +0 -2
  50. package/dist/adapters/channel/worktreeChannel.mjs.map +0 -1
  51. package/dist/adapters/filesystem/atomicJson.cjs +0 -2
  52. package/dist/adapters/filesystem/atomicJson.cjs.map +0 -1
  53. package/dist/adapters/filesystem/atomicJson.mjs +0 -2
  54. package/dist/adapters/filesystem/atomicJson.mjs.map +0 -1
  55. package/dist/adapters/filesystem/paths.cjs +0 -2
  56. package/dist/adapters/filesystem/paths.cjs.map +0 -1
  57. package/dist/adapters/filesystem/paths.mjs +0 -2
  58. package/dist/adapters/filesystem/paths.mjs.map +0 -1
  59. package/dist/adapters/hub/hubClient.cjs +0 -2
  60. package/dist/adapters/hub/hubClient.cjs.map +0 -1
  61. package/dist/adapters/hub/hubClient.d.cts +0 -1
  62. package/dist/adapters/hub/hubClient.d.mts +0 -1
  63. package/dist/adapters/hub/hubClient.mjs +0 -2
  64. package/dist/adapters/hub/hubClient.mjs.map +0 -1
  65. package/dist/adapters/pi/extension.cjs +0 -2
  66. package/dist/adapters/pi/extension.cjs.map +0 -1
  67. package/dist/adapters/pi/extension.d.cts +0 -9
  68. package/dist/adapters/pi/extension.d.cts.map +0 -1
  69. package/dist/adapters/pi/extension.d.mts +0 -9
  70. package/dist/adapters/pi/extension.d.mts.map +0 -1
  71. package/dist/adapters/pi/extension.mjs +0 -2
  72. package/dist/adapters/pi/extension.mjs.map +0 -1
  73. package/dist/adapters/pi/extensions/runWorktreeTool.cjs +0 -15
  74. package/dist/adapters/pi/extensions/runWorktreeTool.cjs.map +0 -1
  75. package/dist/adapters/pi/extensions/runWorktreeTool.mjs +0 -15
  76. package/dist/adapters/pi/extensions/runWorktreeTool.mjs.map +0 -1
  77. package/dist/adapters/web/worktreesChannel.cjs +0 -2
  78. package/dist/adapters/web/worktreesChannel.cjs.map +0 -1
  79. package/dist/adapters/web/worktreesChannel.d.cts +0 -21
  80. package/dist/adapters/web/worktreesChannel.d.cts.map +0 -1
  81. package/dist/adapters/web/worktreesChannel.d.mts +0 -21
  82. package/dist/adapters/web/worktreesChannel.d.mts.map +0 -1
  83. package/dist/adapters/web/worktreesChannel.mjs +0 -2
  84. package/dist/adapters/web/worktreesChannel.mjs.map +0 -1
  85. package/dist/adapters/worktree/compositionMirror.cjs +0 -2
  86. package/dist/adapters/worktree/compositionMirror.cjs.map +0 -1
  87. package/dist/adapters/worktree/compositionMirror.mjs +0 -2
  88. package/dist/adapters/worktree/compositionMirror.mjs.map +0 -1
  89. package/dist/adapters/worktree/gitCli.cjs +0 -4
  90. package/dist/adapters/worktree/gitCli.cjs.map +0 -1
  91. package/dist/adapters/worktree/gitCli.mjs +0 -4
  92. package/dist/adapters/worktree/gitCli.mjs.map +0 -1
  93. package/dist/adapters/worktree/repositoryIdentity.cjs +0 -2
  94. package/dist/adapters/worktree/repositoryIdentity.cjs.map +0 -1
  95. package/dist/adapters/worktree/repositoryIdentity.mjs +0 -2
  96. package/dist/adapters/worktree/repositoryIdentity.mjs.map +0 -1
  97. package/dist/adapters/worktree/worktreeOperations.cjs +0 -2
  98. package/dist/adapters/worktree/worktreeOperations.cjs.map +0 -1
  99. package/dist/adapters/worktree/worktreeOperations.d.cts +0 -38
  100. package/dist/adapters/worktree/worktreeOperations.d.cts.map +0 -1
  101. package/dist/adapters/worktree/worktreeOperations.d.mts +0 -38
  102. package/dist/adapters/worktree/worktreeOperations.d.mts.map +0 -1
  103. package/dist/adapters/worktree/worktreeOperations.mjs +0 -2
  104. package/dist/adapters/worktree/worktreeOperations.mjs.map +0 -1
  105. package/dist/adapters/worktree/worktreeRegistry.cjs +0 -2
  106. package/dist/adapters/worktree/worktreeRegistry.cjs.map +0 -1
  107. package/dist/adapters/worktree/worktreeRegistry.mjs +0 -2
  108. package/dist/adapters/worktree/worktreeRegistry.mjs.map +0 -1
  109. package/dist/commands/doomGitCommand.cjs +0 -2
  110. package/dist/commands/doomGitCommand.cjs.map +0 -1
  111. package/dist/commands/doomGitCommand.mjs +0 -2
  112. package/dist/commands/doomGitCommand.mjs.map +0 -1
  113. package/dist/container/index.cjs +0 -2
  114. package/dist/container/index.cjs.map +0 -1
  115. package/dist/container/index.d.cts +0 -6
  116. package/dist/container/index.d.cts.map +0 -1
  117. package/dist/container/index.d.mts +0 -6
  118. package/dist/container/index.d.mts.map +0 -1
  119. package/dist/container/index.mjs +0 -2
  120. package/dist/container/index.mjs.map +0 -1
  121. package/dist/extensions/pi.d.cts +0 -2
  122. package/dist/hubApi.cjs +0 -2
  123. package/dist/hubApi.cjs.map +0 -1
  124. package/dist/hubApi.d.cts +0 -6
  125. package/dist/hubApi.d.cts.map +0 -1
  126. package/dist/hubApi.d.mts +0 -6
  127. package/dist/hubApi.d.mts.map +0 -1
  128. package/dist/hubApi.mjs +0 -2
  129. package/dist/hubApi.mjs.map +0 -1
  130. package/dist/index.d.cts +0 -5
  131. package/dist/schemas/runWorktreeTool.cjs +0 -2
  132. package/dist/schemas/runWorktreeTool.cjs.map +0 -1
  133. package/dist/schemas/runWorktreeTool.mjs +0 -2
  134. package/dist/schemas/runWorktreeTool.mjs.map +0 -1
  135. package/dist/services/extensionService.cjs +0 -2
  136. package/dist/services/extensionService.cjs.map +0 -1
  137. package/dist/services/extensionService.d.cts +0 -8
  138. package/dist/services/extensionService.d.cts.map +0 -1
  139. package/dist/services/extensionService.d.mts +0 -8
  140. package/dist/services/extensionService.d.mts.map +0 -1
  141. package/dist/services/extensionService.mjs +0 -2
  142. package/dist/services/extensionService.mjs.map +0 -1
  143. package/dist/services/support/errors.cjs +0 -2
  144. package/dist/services/support/errors.cjs.map +0 -1
  145. package/dist/services/support/errors.mjs +0 -2
  146. package/dist/services/support/errors.mjs.map +0 -1
  147. package/dist/services/worktreeNaming.cjs +0 -2
  148. package/dist/services/worktreeNaming.cjs.map +0 -1
  149. package/dist/services/worktreeNaming.d.cts +0 -34
  150. package/dist/services/worktreeNaming.d.cts.map +0 -1
  151. package/dist/services/worktreeNaming.d.mts +0 -34
  152. package/dist/services/worktreeNaming.d.mts.map +0 -1
  153. package/dist/services/worktreeNaming.mjs +0 -2
  154. package/dist/services/worktreeNaming.mjs.map +0 -1
  155. package/dist/types/extension.d.cts +0 -17
  156. package/dist/types/extension.d.cts.map +0 -1
  157. package/dist/types/extension.d.mts +0 -17
  158. package/dist/types/extension.d.mts.map +0 -1
  159. package/dist/types/webWorktrees.cjs +0 -2
  160. package/dist/types/webWorktrees.cjs.map +0 -1
  161. package/dist/types/webWorktrees.mjs +0 -2
  162. package/dist/types/webWorktrees.mjs.map +0 -1
  163. package/dist/types/worktreeRegistry.d.cts +0 -41
  164. package/dist/types/worktreeRegistry.d.cts.map +0 -1
  165. package/dist/types/worktreeRegistry.d.mts +0 -41
  166. package/dist/types/worktreeRegistry.d.mts.map +0 -1
  167. package/dist/webHub.cjs +0 -1
  168. package/dist/webHub.d.cts +0 -2
  169. package/dist/webHub.d.mts +0 -2
  170. package/dist/webHub.mjs +0 -1
  171. package/src/exports/webClient.ts +0 -1
  172. package/src/types/webWorktrees.ts +0 -55
  173. package/src/types/worktreeRegistry.ts +0 -78
  174. package/src/web/components/RunWorktreeToolMessage.tsx +0 -45
  175. package/src/web/components/WorktreesActivitySection.tsx +0 -79
  176. package/src/web/components/WorktreesPanel.tsx +0 -174
  177. package/src/web/components/toolRenderers.ts +0 -7
  178. package/src/web/index.ts +0 -30
  179. package/src/web/stores/worktreesActivityStore.ts +0 -124
  180. package/src/web/tsconfig.json +0 -22
@@ -1,174 +0,0 @@
1
- /**
2
- * The '# git' group's tab: this session's worktrees, and the form that makes one.
3
- *
4
- * DESIGN PATTERNS:
5
- * - Lives in the activity dock, opened by the group's name. A worktree is work
6
- * in progress belonging to the session that started it, so it sits beside
7
- * agents, runners and workflows rather than in a settings screen.
8
- * - Header, form, then cards, the same rhythm the runners and workflows panels
9
- * use. A worktree row is a card because it carries three facts and two
10
- * actions, which a single line cannot hold without becoming a puzzle.
11
- * - Local form state is never reset by a data refresh. The hub republishes this
12
- * list on a timer, and a half-typed branch name must survive that.
13
- * - Acts through the plugin's own hub channel, so a worktree made here and one
14
- * made by the tool take exactly the same path.
15
- * - Creating waits on the cockpit starting a session, so the hub reports each
16
- * phase on that channel and the header shows it turning. A button that looks
17
- * idle for two minutes reads as broken.
18
- *
19
- * AVOID:
20
- * - Deriving form state from props or store data. That is what wiped the
21
- * fields on every poll.
22
- * - Colour classes outside the token set. `doom-error`, `doom-line` and
23
- * `doom-bright` are not tokens: they compile to nothing and the row silently
24
- * loses its border.
25
- */
26
- import { Button, Dot, EmptyState, Input, Spinner, StatusBadge } from '@agimon-ai/doompi-web-components';
27
- import type { TransientTab, WebPluginSlotProps } from '@agimon-ai/doompi-web-contracts';
28
- import { useStore } from '@tanstack/react-store';
29
- import { useState } from 'react';
30
- import type { WorktreeView } from '../../types/webWorktrees.ts';
31
- import { requestWorktreeClose, requestWorktreeCreate, worktreeActivity } from '../stores/worktreesActivityStore.ts';
32
-
33
- const WORKTREES_TAB_ID = 'git-worktrees';
34
-
35
- export function worktreesTab(): TransientTab {
36
- return { id: WORKTREES_TAB_ID, label: 'worktrees', panel: WorktreesPanel };
37
- }
38
-
39
- export function WorktreesPanel({ sessionId }: WebPluginSlotProps) {
40
- const session = useStore(worktreeActivity.store, (state) => worktreeActivity.select(state, sessionId));
41
- const [branch, setBranch] = useState('');
42
- const [baseRef, setBaseRef] = useState('');
43
-
44
- const busy = session.pending !== undefined;
45
- const canCreate = sessionId !== null && branch.trim() !== '' && !busy;
46
-
47
- const create = (): void => {
48
- if (sessionId === null || !canCreate) return;
49
- requestWorktreeCreate(sessionId, branch, baseRef);
50
- setBranch('');
51
- setBaseRef('');
52
- };
53
-
54
- return (
55
- <div data-testid="git-worktrees-panel" className="flex min-h-0 flex-1 flex-col overflow-auto">
56
- <div className="flex min-h-11 shrink-0 items-center gap-2.5 border-b border-doom-border-soft px-3 sm:px-[26px]">
57
- <span className="text-sm font-bold text-doom-hi">worktrees</span>
58
- <span data-testid="git-worktrees-count" className="text-xs text-doom-faint">
59
- {session.worktrees.length === 0 ? 'none yet' : `${String(session.worktrees.length)} open`}
60
- </span>
61
- <span className="min-w-0 flex-1" />
62
- {session.pending === undefined ? null : (
63
- <span data-testid="git-worktree-pending" className="flex min-w-0 items-center gap-1.5">
64
- <Spinner className="h-3 w-3 shrink-0 text-doom-faint" label={session.pending} />
65
- <span className="min-w-0 truncate text-xs text-doom-dim">{session.pending}</span>
66
- </span>
67
- )}
68
- </div>
69
-
70
- <div className="flex shrink-0 flex-col gap-1.5 border-b border-doom-border-soft px-3 py-2.5 sm:px-[26px]">
71
- <div className="flex items-center gap-2">
72
- <Input
73
- data-testid="git-worktree-branch"
74
- aria-label="Branch"
75
- size="sm"
76
- className="min-w-0 flex-1"
77
- placeholder="wt/fix-auth"
78
- value={branch}
79
- onChange={(event) => setBranch(event.target.value)}
80
- onKeyDown={(event) => {
81
- if (event.key === 'Enter') create();
82
- }}
83
- />
84
- <Input
85
- data-testid="git-worktree-base"
86
- aria-label="Base ref"
87
- size="sm"
88
- placeholder="base (current)"
89
- value={baseRef}
90
- onChange={(event) => setBaseRef(event.target.value)}
91
- className="w-32 shrink-0"
92
- />
93
- <Button data-testid="git-worktree-create" size="sm" disabled={!canCreate} onClick={create}>
94
- Create
95
- </Button>
96
- </div>
97
- {session.error === undefined ? (
98
- <p className="text-2xs text-doom-faint">
99
- Creates the worktree outside the repository and starts a session nested under this one.
100
- </p>
101
- ) : (
102
- <p data-testid="git-worktree-error" className="text-2xs text-doom-red">
103
- {session.error}
104
- </p>
105
- )}
106
- </div>
107
-
108
- {session.worktrees.length === 0 ? (
109
- <EmptyState
110
- data-testid="git-worktrees-empty"
111
- className="px-4 py-8"
112
- title="no worktrees yet"
113
- description="a worktree is its own checkout on its own branch, with its own session nested under this one."
114
- />
115
- ) : (
116
- <ul data-testid="git-worktrees-list" className="flex flex-col gap-2.5 px-3 py-3 sm:px-[26px]">
117
- {session.worktrees.map((worktree: WorktreeView) => (
118
- <WorktreeCard key={worktree.id} worktree={worktree} sessionId={sessionId} busy={busy} />
119
- ))}
120
- </ul>
121
- )}
122
- </div>
123
- );
124
- }
125
-
126
- /** One worktree: what it is, where it is, and the one thing you can do to it. */
127
- function WorktreeCard({
128
- worktree,
129
- sessionId,
130
- busy,
131
- }: {
132
- worktree: WorktreeView;
133
- busy: boolean;
134
- } & Pick<WebPluginSlotProps, 'sessionId'>) {
135
- return (
136
- <li
137
- data-testid={`git-worktree-${worktree.id}`}
138
- className="flex min-w-0 flex-col gap-1.5 rounded-md border border-doom-border-soft bg-doom-panel p-2.5"
139
- >
140
- <div className="flex min-w-0 items-center gap-1.5">
141
- <Dot tone={worktree.orphaned ? 'red' : worktree.sessionId === null ? 'muted' : 'blue'} />
142
- <span className="min-w-0 flex-1 truncate text-sm font-bold text-doom-hi">{worktree.branch}</span>
143
- {worktree.orphaned ? (
144
- <StatusBadge tone="error" size="xs">
145
- orphaned
146
- </StatusBadge>
147
- ) : null}
148
- {worktree.unowned ? (
149
- <StatusBadge tone="info" size="xs">
150
- unowned
151
- </StatusBadge>
152
- ) : null}
153
- </div>
154
-
155
- <span className="min-w-0 truncate text-2xs text-doom-faint">{worktree.path}</span>
156
-
157
- <div className="flex items-center gap-1.5 pt-0.5">
158
- <span className="min-w-0 flex-1" />
159
- {sessionId === null ? null : (
160
- <Button
161
- variant="danger-outline"
162
- size="xs"
163
- disabled={busy}
164
- data-testid={`git-worktree-close-${worktree.id}`}
165
- className="px-2 text-2xs font-bold"
166
- onClick={() => requestWorktreeClose(sessionId, worktree.id)}
167
- >
168
- close
169
- </Button>
170
- )}
171
- </div>
172
- </li>
173
- );
174
- }
@@ -1,7 +0,0 @@
1
- import type { ToolRendererContribution } from '@agimon-ai/doompi-web-contracts';
2
- import { RunWorktreeToolMessage } from './RunWorktreeToolMessage.tsx';
3
-
4
- /** The timeline items for this package's tools. */
5
- export const gitToolRenderers: ToolRendererContribution[] = [
6
- { tools: ['run_worktree'], message: RunWorktreeToolMessage },
7
- ];
package/src/web/index.ts DELETED
@@ -1,30 +0,0 @@
1
- import { defineWebPlugin } from '@agimon-ai/doompi-web-contracts';
2
- import { gitToolRenderers } from './components/toolRenderers.ts';
3
- import { WorktreesActivitySection } from './components/WorktreesActivitySection.tsx';
4
- import { worktreesTab } from './components/WorktreesPanel.tsx';
5
- import { startWorktreeRuntime, worktreeActivitySource, worktreesChannel } from './stores/worktreesActivityStore.ts';
6
-
7
- /** The named export the generated plugin registry imports. */
8
- export const webPlugin = defineWebPlugin({
9
- id: 'git',
10
- channels: [worktreesChannel],
11
- // The panel commands the hub over its own channel, which needs the page's
12
- // hub socket rather than the per-session frame sender the slots carry.
13
- start: startWorktreeRuntime,
14
- activityGroups: [
15
- {
16
- name: 'git',
17
- keys: 'g w',
18
- // The source keeps the group present while idle, which is exactly when
19
- // its launcher matters: a repository with no worktrees is where someone
20
- // wants to make the first one.
21
- activeSource: worktreeActivitySource,
22
- // A standing worktree is not background work in progress; it is state.
23
- marksBackgroundWork: false,
24
- transientTab: worktreesTab,
25
- order: 30,
26
- },
27
- ],
28
- activitySections: [{ id: 'git', component: WorktreesActivitySection }],
29
- toolRenderers: gitToolRenderers,
30
- });
@@ -1,124 +0,0 @@
1
- /**
2
- * The dock's view of this session's worktrees, and the commands it sends.
3
- *
4
- * DESIGN PATTERNS:
5
- * - Session-scoped store fed by one hub channel. The hub is authoritative; the
6
- * page never reads a registry and never guesses.
7
- * - Actions are channel frames, not prompts. The hub half owns the tool's
8
- * operations, so the panel names the work and the hub performs it; a
9
- * worktree made from the dock is the same object the tool makes, without
10
- * spending a turn of the conversation to ask for it.
11
- * - The sender lives in a store rather than a module variable, because a web
12
- * plugin keeps no mutable module state and the page may reconnect.
13
- *
14
- * AVOID:
15
- * - Calling the hub package API from here. A dock slot gets no sealed request
16
- * transport, and raw fetch breaks the remote cockpit.
17
- * - `sendSessionFrame` for a command. It envelopes the frame as a session
18
- * command bound for the agent, which never reaches a channel's `receive`.
19
- */
20
- import { defineGlobalStore, defineSessionStore, type WebPluginRuntime } from '@agimon-ai/doompi-web-contracts';
21
- import { GIT_WORKTREES_TYPE, type GitWorktreesCommand, type WorktreeView } from '../../types/webWorktrees.ts';
22
-
23
- export interface WorktreesSession {
24
- /** The worktrees the hub last reported for this session's repository. */
25
- worktrees: WorktreeView[];
26
- /** Label of the operation the hub is running for this session. */
27
- pending: string | undefined;
28
- /** The last failure the hub reported, shown until the next command. */
29
- error: string | undefined;
30
- }
31
-
32
- export const worktreeActivity = defineSessionStore<WorktreesSession>({
33
- worktrees: [],
34
- pending: undefined,
35
- error: undefined,
36
- });
37
-
38
- /**
39
- * The page's hub socket sender, held for as long as the plugin runs.
40
- *
41
- * Undefined before `startWorktreeRuntime` and after it disposes; a command
42
- * sent in that window is dropped rather than queued, because a queue would
43
- * replay a worktree create against a socket that has since changed sessions.
44
- */
45
- const worktreeSender = defineGlobalStore<WebPluginRuntime['sendHubFrame'] | undefined>(undefined);
46
-
47
- /** Binds the page's hub socket. The plugin host calls this once per page. */
48
- export function startWorktreeRuntime(runtime: WebPluginRuntime): () => void {
49
- // Wrapped rather than referenced: an unbound method would lose the runtime
50
- // it belongs to the moment the store hands it back.
51
- const send = (frame: Record<string, unknown>): void => {
52
- runtime.sendHubFrame(frame);
53
- };
54
- worktreeSender.update(() => send);
55
- return () => {
56
- worktreeSender.update((current) => (current === send ? undefined : current));
57
- };
58
- }
59
-
60
- /**
61
- * Whether this session has worktree work in flight.
62
- *
63
- * A standing worktree is state, not work: it sits there until someone closes
64
- * it, so counting it would leave the session reading as busy forever, with a
65
- * "background work is still running" notice under a conversation where
66
- * nothing is running. Only a create or close actually in progress counts.
67
- *
68
- * The group stays visible either way. Declaring an active source at all is
69
- * what keeps it in the dock; this answers how it is drawn, not whether it is
70
- * there.
71
- */
72
- export const worktreeActivitySource = {
73
- subscribe(listener: () => void) {
74
- const subscription = worktreeActivity.store.subscribe(listener);
75
- return () => subscription.unsubscribe();
76
- },
77
- isActive(sessionId: string | null) {
78
- return worktreeActivity.select(worktreeActivity.store.state, sessionId).pending !== undefined;
79
- },
80
- };
81
-
82
- function isRecord(value: unknown): value is Record<string, unknown> {
83
- return typeof value === 'object' && value !== null && !Array.isArray(value);
84
- }
85
-
86
- function optionalText(value: unknown): string | undefined {
87
- return typeof value === 'string' && value !== '' ? value : undefined;
88
- }
89
-
90
- /** The plugin's session data channel: 'git_worktrees' payloads into the store. */
91
- export const worktreesChannel = worktreeActivity.channel<WorktreesSession>({
92
- channel: GIT_WORKTREES_TYPE,
93
- parse(input) {
94
- if (!isRecord(input) || !Array.isArray(input.worktrees)) return null;
95
- return {
96
- worktrees: input.worktrees.filter(isRecord) as unknown as WorktreeView[],
97
- pending: optionalText(input.pending),
98
- error: optionalText(input.error),
99
- };
100
- },
101
- reduce(_current, next) {
102
- return next;
103
- },
104
- });
105
-
106
- /** Sends one command to the session's worktrees channel. */
107
- function command(sessionId: string, payload: GitWorktreesCommand): void {
108
- worktreeSender.store.state?.({ type: GIT_WORKTREES_TYPE, sessionId, payload });
109
- }
110
-
111
- /** Asks the hub for a worktree. The hub answers on the same channel. */
112
- export function requestWorktreeCreate(sessionId: string, branch: string, baseRef: string): void {
113
- const trimmedBase = baseRef.trim();
114
- command(sessionId, {
115
- action: 'create',
116
- branch: branch.trim(),
117
- ...(trimmedBase === '' ? {} : { baseRef: trimmedBase }),
118
- });
119
- }
120
-
121
- /** Asks the hub to close one worktree. Refusal on a dirty tree stays the hub's call. */
122
- export function requestWorktreeClose(sessionId: string, id: string): void {
123
- command(sessionId, { action: 'close', id });
124
- }
@@ -1,22 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "lib": ["ES2023", "DOM", "DOM.Iterable"],
5
- "module": "ESNext",
6
- "moduleResolution": "Bundler",
7
- "jsx": "react-jsx",
8
- "strict": true,
9
- "noImplicitAny": true,
10
- "noUnusedLocals": true,
11
- "noUnusedParameters": true,
12
- "noImplicitReturns": true,
13
- "noFallthroughCasesInSwitch": true,
14
- "noEmit": true,
15
- "resolveJsonModule": true,
16
- "esModuleInterop": true,
17
- "skipLibCheck": true,
18
- "allowImportingTsExtensions": true,
19
- "forceConsistentCasingInFileNames": true
20
- },
21
- "include": [".", "../types/worktreeRegistry.ts", "../types/webWorktrees.ts", "../exports/webClient.ts"]
22
- }