@agimon-ai/doompi-git 0.0.1-alpha.1 → 0.0.1-alpha.11
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 +2 -0
- package/package.json +48 -35
- package/src/prompts/doompi-use-git/SKILL.md +5 -2
- package/dist/_virtual/_rolldown/runtime.cjs +0 -1
- package/dist/adapters/channel/worktreeChannel.cjs +0 -2
- package/dist/adapters/channel/worktreeChannel.cjs.map +0 -1
- package/dist/adapters/channel/worktreeChannel.d.cts +0 -40
- package/dist/adapters/channel/worktreeChannel.d.cts.map +0 -1
- package/dist/adapters/channel/worktreeChannel.d.mts +0 -40
- package/dist/adapters/channel/worktreeChannel.d.mts.map +0 -1
- package/dist/adapters/channel/worktreeChannel.mjs +0 -2
- package/dist/adapters/channel/worktreeChannel.mjs.map +0 -1
- package/dist/adapters/filesystem/atomicJson.cjs +0 -2
- package/dist/adapters/filesystem/atomicJson.cjs.map +0 -1
- package/dist/adapters/filesystem/atomicJson.mjs +0 -2
- package/dist/adapters/filesystem/atomicJson.mjs.map +0 -1
- package/dist/adapters/filesystem/paths.cjs +0 -2
- package/dist/adapters/filesystem/paths.cjs.map +0 -1
- package/dist/adapters/filesystem/paths.mjs +0 -2
- package/dist/adapters/filesystem/paths.mjs.map +0 -1
- package/dist/adapters/hub/hubClient.cjs +0 -2
- package/dist/adapters/hub/hubClient.cjs.map +0 -1
- package/dist/adapters/hub/hubClient.d.cts +0 -1
- package/dist/adapters/hub/hubClient.d.mts +0 -1
- package/dist/adapters/hub/hubClient.mjs +0 -2
- package/dist/adapters/hub/hubClient.mjs.map +0 -1
- package/dist/adapters/pi/extension.cjs +0 -2
- package/dist/adapters/pi/extension.cjs.map +0 -1
- package/dist/adapters/pi/extension.d.cts +0 -9
- package/dist/adapters/pi/extension.d.cts.map +0 -1
- package/dist/adapters/pi/extension.d.mts +0 -9
- package/dist/adapters/pi/extension.d.mts.map +0 -1
- package/dist/adapters/pi/extension.mjs +0 -2
- package/dist/adapters/pi/extension.mjs.map +0 -1
- package/dist/adapters/pi/extensions/runWorktreeTool.cjs +0 -15
- package/dist/adapters/pi/extensions/runWorktreeTool.cjs.map +0 -1
- package/dist/adapters/pi/extensions/runWorktreeTool.mjs +0 -15
- package/dist/adapters/pi/extensions/runWorktreeTool.mjs.map +0 -1
- package/dist/adapters/web/worktreesChannel.cjs +0 -2
- package/dist/adapters/web/worktreesChannel.cjs.map +0 -1
- package/dist/adapters/web/worktreesChannel.d.cts +0 -21
- package/dist/adapters/web/worktreesChannel.d.cts.map +0 -1
- package/dist/adapters/web/worktreesChannel.d.mts +0 -21
- package/dist/adapters/web/worktreesChannel.d.mts.map +0 -1
- package/dist/adapters/web/worktreesChannel.mjs +0 -2
- package/dist/adapters/web/worktreesChannel.mjs.map +0 -1
- package/dist/adapters/worktree/dependencyInstall.cjs +0 -2
- package/dist/adapters/worktree/dependencyInstall.cjs.map +0 -1
- package/dist/adapters/worktree/dependencyInstall.mjs +0 -2
- package/dist/adapters/worktree/dependencyInstall.mjs.map +0 -1
- package/dist/adapters/worktree/gitCli.cjs +0 -4
- package/dist/adapters/worktree/gitCli.cjs.map +0 -1
- package/dist/adapters/worktree/gitCli.mjs +0 -4
- package/dist/adapters/worktree/gitCli.mjs.map +0 -1
- package/dist/adapters/worktree/repositoryIdentity.cjs +0 -2
- package/dist/adapters/worktree/repositoryIdentity.cjs.map +0 -1
- package/dist/adapters/worktree/repositoryIdentity.mjs +0 -2
- package/dist/adapters/worktree/repositoryIdentity.mjs.map +0 -1
- package/dist/adapters/worktree/worktreeOperations.cjs +0 -2
- package/dist/adapters/worktree/worktreeOperations.cjs.map +0 -1
- package/dist/adapters/worktree/worktreeOperations.d.cts +0 -32
- package/dist/adapters/worktree/worktreeOperations.d.cts.map +0 -1
- package/dist/adapters/worktree/worktreeOperations.d.mts +0 -32
- package/dist/adapters/worktree/worktreeOperations.d.mts.map +0 -1
- package/dist/adapters/worktree/worktreeOperations.mjs +0 -2
- package/dist/adapters/worktree/worktreeOperations.mjs.map +0 -1
- package/dist/adapters/worktree/worktreeRegistry.cjs +0 -2
- package/dist/adapters/worktree/worktreeRegistry.cjs.map +0 -1
- package/dist/adapters/worktree/worktreeRegistry.mjs +0 -2
- package/dist/adapters/worktree/worktreeRegistry.mjs.map +0 -1
- package/dist/commands/doomGitCommand.cjs +0 -2
- package/dist/commands/doomGitCommand.cjs.map +0 -1
- package/dist/commands/doomGitCommand.mjs +0 -2
- package/dist/commands/doomGitCommand.mjs.map +0 -1
- package/dist/container/index.cjs +0 -2
- package/dist/container/index.cjs.map +0 -1
- package/dist/container/index.d.cts +0 -6
- package/dist/container/index.d.cts.map +0 -1
- package/dist/container/index.d.mts +0 -6
- package/dist/container/index.d.mts.map +0 -1
- package/dist/container/index.mjs +0 -2
- package/dist/container/index.mjs.map +0 -1
- package/dist/extensions/pi.cjs +0 -1
- package/dist/extensions/pi.d.cts +0 -2
- package/dist/extensions/pi.d.mts +0 -2
- package/dist/extensions/pi.mjs +0 -1
- package/dist/hubApi.cjs +0 -2
- package/dist/hubApi.cjs.map +0 -1
- package/dist/hubApi.d.cts +0 -6
- package/dist/hubApi.d.cts.map +0 -1
- package/dist/hubApi.d.mts +0 -6
- package/dist/hubApi.d.mts.map +0 -1
- package/dist/hubApi.mjs +0 -2
- package/dist/hubApi.mjs.map +0 -1
- package/dist/index.cjs +0 -1
- package/dist/index.d.cts +0 -5
- package/dist/index.d.mts +0 -5
- package/dist/index.mjs +0 -1
- package/dist/schemas/runWorktreeTool.cjs +0 -2
- package/dist/schemas/runWorktreeTool.cjs.map +0 -1
- package/dist/schemas/runWorktreeTool.mjs +0 -2
- package/dist/schemas/runWorktreeTool.mjs.map +0 -1
- package/dist/services/extensionService.cjs +0 -2
- package/dist/services/extensionService.cjs.map +0 -1
- package/dist/services/extensionService.d.cts +0 -8
- package/dist/services/extensionService.d.cts.map +0 -1
- package/dist/services/extensionService.d.mts +0 -8
- package/dist/services/extensionService.d.mts.map +0 -1
- package/dist/services/extensionService.mjs +0 -2
- package/dist/services/extensionService.mjs.map +0 -1
- package/dist/services/support/errors.cjs +0 -2
- package/dist/services/support/errors.cjs.map +0 -1
- package/dist/services/support/errors.mjs +0 -2
- package/dist/services/support/errors.mjs.map +0 -1
- package/dist/services/worktreeNaming.cjs +0 -2
- package/dist/services/worktreeNaming.cjs.map +0 -1
- package/dist/services/worktreeNaming.d.cts +0 -27
- package/dist/services/worktreeNaming.d.cts.map +0 -1
- package/dist/services/worktreeNaming.d.mts +0 -27
- package/dist/services/worktreeNaming.d.mts.map +0 -1
- package/dist/services/worktreeNaming.mjs +0 -2
- package/dist/services/worktreeNaming.mjs.map +0 -1
- package/dist/types/extension.d.cts +0 -17
- package/dist/types/extension.d.cts.map +0 -1
- package/dist/types/extension.d.mts +0 -17
- package/dist/types/extension.d.mts.map +0 -1
- package/dist/types/webWorktrees.cjs +0 -2
- package/dist/types/webWorktrees.cjs.map +0 -1
- package/dist/types/webWorktrees.mjs +0 -2
- package/dist/types/webWorktrees.mjs.map +0 -1
- package/dist/types/worktreeRegistry.d.cts +0 -41
- package/dist/types/worktreeRegistry.d.cts.map +0 -1
- package/dist/types/worktreeRegistry.d.mts +0 -41
- package/dist/types/worktreeRegistry.d.mts.map +0 -1
- package/dist/webHub.cjs +0 -1
- package/dist/webHub.d.cts +0 -2
- package/dist/webHub.d.mts +0 -2
- package/dist/webHub.mjs +0 -1
- package/src/exports/webClient.ts +0 -1
- package/src/types/webWorktrees.ts +0 -55
- package/src/types/worktreeRegistry.ts +0 -69
- package/src/web/components/RunWorktreeToolMessage.tsx +0 -37
- package/src/web/components/WorktreesActivitySection.tsx +0 -64
- package/src/web/components/WorktreesPanel.tsx +0 -125
- package/src/web/components/toolRenderers.ts +0 -7
- package/src/web/index.ts +0 -30
- package/src/web/stores/worktreesActivityStore.ts +0 -124
- package/src/web/tsconfig.json +0 -22
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The cockpit's view of this session's worktrees.
|
|
3
|
-
*
|
|
4
|
-
* DESIGN PATTERNS:
|
|
5
|
-
* - Declarations only. The channel frame type is a constant so the hub and the
|
|
6
|
-
* page cannot drift apart on a string.
|
|
7
|
-
* - A view is the subset of a record the dock needs, not the record. The
|
|
8
|
-
* registry may hold paths and provenance the page has no business rendering.
|
|
9
|
-
*
|
|
10
|
-
* AVOID:
|
|
11
|
-
* - Adding behaviour here. This file is imported by browser code, so it must
|
|
12
|
-
* stay free of node builtins.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/** The data channel carrying one session's worktrees to the page. */
|
|
16
|
-
export const GIT_WORKTREES_TYPE = 'git_worktrees';
|
|
17
|
-
|
|
18
|
-
/** One worktree, as the activity dock and its panel render it. */
|
|
19
|
-
export interface WorktreeView {
|
|
20
|
-
id: string;
|
|
21
|
-
branch: string;
|
|
22
|
-
path: string;
|
|
23
|
-
/** The session the hub started for this worktree, when it is still live. */
|
|
24
|
-
sessionId: string | null;
|
|
25
|
-
/** True once the directory the record names has gone missing. */
|
|
26
|
-
orphaned: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* True when the session that asked for this worktree is gone.
|
|
29
|
-
*
|
|
30
|
-
* An owned worktree is only ever shown to its own session. This flag marks
|
|
31
|
-
* the exception: once the parent is dead nobody would see the worktree at
|
|
32
|
-
* all, so every session in the repository does, and may close it.
|
|
33
|
-
*/
|
|
34
|
-
unowned: boolean;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* What the panel asks the hub channel to do.
|
|
39
|
-
*
|
|
40
|
-
* The dock acts through its own channel rather than through the agent: a
|
|
41
|
-
* worktree made from the panel and one made by the tool take the same
|
|
42
|
-
* `worktreeOperations` path, but the panel no longer has to spend a turn of
|
|
43
|
-
* the conversation to get there.
|
|
44
|
-
*/
|
|
45
|
-
export type GitWorktreesCommand =
|
|
46
|
-
| { action: 'create'; branch: string; baseRef?: string }
|
|
47
|
-
| { action: 'close'; id: string; force?: boolean };
|
|
48
|
-
|
|
49
|
-
export interface GitWorktreesPayload {
|
|
50
|
-
worktrees: WorktreeView[];
|
|
51
|
-
/** Label of the operation in flight, absent when the session is idle. */
|
|
52
|
-
pending?: string;
|
|
53
|
-
/** The last failure, cleared when the next command starts. */
|
|
54
|
-
error?: string;
|
|
55
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The worktree registry: what this package knows about the worktrees it made.
|
|
3
|
-
*
|
|
4
|
-
* It deliberately does not mirror `git worktree list`. Git knows which
|
|
5
|
-
* worktrees exist; only this registry knows which of them this package created,
|
|
6
|
-
* which session runs in each, and which process to signal. Reconciling the two
|
|
7
|
-
* is how orphans are found, so the two views are kept separate on purpose.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* A worktree's lifecycle as this package sees it.
|
|
12
|
-
*
|
|
13
|
-
* `orphaned` is a finding, not a cleanup: the session process is gone or the
|
|
14
|
-
* directory has vanished, but the worktree may still hold uncommitted work, so
|
|
15
|
-
* the record is kept until someone decides what to do with it.
|
|
16
|
-
*/
|
|
17
|
-
export type WorktreeStatus = 'spawning' | 'running' | 'closing' | 'orphaned';
|
|
18
|
-
|
|
19
|
-
export const WORKTREE_RECORD_VERSION = 1;
|
|
20
|
-
|
|
21
|
-
export interface WorktreeRecord {
|
|
22
|
-
version: typeof WORKTREE_RECORD_VERSION;
|
|
23
|
-
/** This registry's own id, distinct from the session id, and stable across restarts. */
|
|
24
|
-
id: string;
|
|
25
|
-
/** The branch checked out in the worktree. */
|
|
26
|
-
branch: string;
|
|
27
|
-
/** The ref the branch was created from, kept so a merge can name its base. */
|
|
28
|
-
baseRef: string;
|
|
29
|
-
/** Absolute path to the worktree directory. */
|
|
30
|
-
path: string;
|
|
31
|
-
/** Absolute path to the repository the worktree belongs to. */
|
|
32
|
-
repositoryRoot: string;
|
|
33
|
-
/** The session spawned into the worktree. */
|
|
34
|
-
sessionId: string;
|
|
35
|
-
/** The session that asked for the worktree; the rail nests one under the other. */
|
|
36
|
-
parentSessionId: string;
|
|
37
|
-
status: WorktreeStatus;
|
|
38
|
-
/** ISO 8601. */
|
|
39
|
-
createdAt: string;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface WorktreeRegistryFile {
|
|
43
|
-
version: typeof WORKTREE_RECORD_VERSION;
|
|
44
|
-
entries: readonly WorktreeRecord[];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/** Reads the registry back, treating anything unusable as an empty registry. */
|
|
48
|
-
export interface WorktreeRegistryStore {
|
|
49
|
-
list(): WorktreeRecord[];
|
|
50
|
-
/** Replaces the whole file. One writer per repository, so no merge is attempted. */
|
|
51
|
-
replace(entries: readonly WorktreeRecord[]): void;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** The git operations this package needs, named in its own vocabulary. */
|
|
55
|
-
export interface WorktreeGit {
|
|
56
|
-
addWorktree(input: { repositoryRoot: string; path: string; branch: string; baseRef: string }): Promise<void>;
|
|
57
|
-
removeWorktree(input: { repositoryRoot: string; path: string; force: boolean }): Promise<void>;
|
|
58
|
-
pruneWorktrees(repositoryRoot: string): Promise<void>;
|
|
59
|
-
/** Paths git currently lists for the repository, used to find orphans. */
|
|
60
|
-
listWorktreePaths(repositoryRoot: string): Promise<string[]>;
|
|
61
|
-
/** Files with uncommitted changes, empty when the tree is clean. */
|
|
62
|
-
dirtyFiles(path: string): Promise<string[]>;
|
|
63
|
-
/** The repository root for a directory, or undefined when it is not a repository. */
|
|
64
|
-
repositoryRoot(cwd: string): Promise<string | undefined>;
|
|
65
|
-
/** The branch currently checked out, used as the default base ref. */
|
|
66
|
-
currentBranch(cwd: string): Promise<string | undefined>;
|
|
67
|
-
/** Merges a worktree's branch into whatever the given root has checked out. */
|
|
68
|
-
mergeBranch(input: { repositoryRoot: string; branch: string; message?: string }): Promise<void>;
|
|
69
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { ToolMessageRenderProps } from '@agimon-ai/doompi-web-contracts';
|
|
2
|
-
|
|
3
|
-
const ACTION_LABEL: Readonly<Record<string, string>> = {
|
|
4
|
-
spawn_worktree: 'Create worktree',
|
|
5
|
-
close_worktree: 'Close worktree',
|
|
6
|
-
list: 'List worktrees',
|
|
7
|
-
status: 'Worktree status',
|
|
8
|
-
merge: 'Merge worktree',
|
|
9
|
-
prune: 'Prune worktrees',
|
|
10
|
-
send: 'Message worktree',
|
|
11
|
-
messages: 'Read worktree messages',
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The timeline item for `run_worktree`.
|
|
16
|
-
*
|
|
17
|
-
* The action and its subject go in the heading because that is what a reader
|
|
18
|
-
* scanning a transcript needs: "close_worktree a1b2c3d4" answers the question
|
|
19
|
-
* the raw JSON arguments make them decode.
|
|
20
|
-
*/
|
|
21
|
-
export function RunWorktreeToolMessage({ args, output, running, isError }: ToolMessageRenderProps) {
|
|
22
|
-
const action = typeof args.action === 'string' ? args.action : '';
|
|
23
|
-
const subject = typeof args.branch === 'string' ? args.branch : typeof args.id === 'string' ? args.id : '';
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<div className="flex flex-col gap-0.5">
|
|
27
|
-
<span className="text-[11px] font-bold text-doom-hi">
|
|
28
|
-
{ACTION_LABEL[action] ?? 'Worktree'}
|
|
29
|
-
{subject === '' ? '' : ` ${subject}`}
|
|
30
|
-
{running ? ' …' : ''}
|
|
31
|
-
</span>
|
|
32
|
-
{output !== '' && (
|
|
33
|
-
<pre className={`whitespace-pre-wrap text-[10px] ${isError ? 'text-doom-red' : 'text-doom-dim'}`}>{output}</pre>
|
|
34
|
-
)}
|
|
35
|
-
</div>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The '# git' group's body in the activity dock.
|
|
3
|
-
*
|
|
4
|
-
* DESIGN PATTERNS:
|
|
5
|
-
* - One line per worktree, the same rule the runners rail follows: enough to
|
|
6
|
-
* notice it, not enough to work with it. The group's own name opens the tab
|
|
7
|
-
* that has room.
|
|
8
|
-
* - Idle still shows the launcher. A repository with no worktrees is the state
|
|
9
|
-
* where someone most wants to make one.
|
|
10
|
-
*
|
|
11
|
-
* AVOID:
|
|
12
|
-
* - Doing work here. This section reports and launches; the panel and the tool
|
|
13
|
-
* own everything else.
|
|
14
|
-
*/
|
|
15
|
-
import { Button } from '@agimon-ai/doompi-web-components';
|
|
16
|
-
import type { WebPluginSlotProps } from '@agimon-ai/doompi-web-contracts';
|
|
17
|
-
import { useStore } from '@tanstack/react-store';
|
|
18
|
-
import type { WorktreeView } from '../../types/webWorktrees.ts';
|
|
19
|
-
import { worktreeActivity } from '../stores/worktreesActivityStore.ts';
|
|
20
|
-
import { worktreesTab } from './WorktreesPanel.tsx';
|
|
21
|
-
|
|
22
|
-
export function WorktreesActivitySection({ sessionId, openTransientTab }: WebPluginSlotProps) {
|
|
23
|
-
const session = useStore(worktreeActivity.store, (state) => worktreeActivity.select(state, sessionId));
|
|
24
|
-
|
|
25
|
-
if (session.worktrees.length === 0 && session.pending === undefined) {
|
|
26
|
-
return (
|
|
27
|
-
<div className="flex items-center gap-2 px-1">
|
|
28
|
-
<p data-testid="activity-summary-git" className="px-1 text-[10px] text-doom-faint">
|
|
29
|
-
idle
|
|
30
|
-
</p>
|
|
31
|
-
{sessionId === null ? null : (
|
|
32
|
-
<Button
|
|
33
|
-
variant="link"
|
|
34
|
-
size="xs"
|
|
35
|
-
data-testid="activity-git-create"
|
|
36
|
-
className="px-0"
|
|
37
|
-
onClick={() => openTransientTab(worktreesTab())}
|
|
38
|
-
>
|
|
39
|
-
create a worktree
|
|
40
|
-
</Button>
|
|
41
|
-
)}
|
|
42
|
-
</div>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<div data-testid="activity-git-worktrees" className="flex flex-col gap-0.5">
|
|
48
|
-
{session.pending === undefined ? null : <p className="px-1 text-[10px] text-doom-dim">{session.pending}</p>}
|
|
49
|
-
{session.worktrees.map((worktree: WorktreeView) => (
|
|
50
|
-
<button
|
|
51
|
-
key={worktree.id}
|
|
52
|
-
type="button"
|
|
53
|
-
data-testid={`activity-git-worktree-${worktree.id}`}
|
|
54
|
-
className="flex items-center gap-2 px-1 text-left text-[11px] text-doom-dim hover:text-doom-bright"
|
|
55
|
-
onClick={() => openTransientTab(worktreesTab())}
|
|
56
|
-
>
|
|
57
|
-
<span className="truncate">{worktree.branch}</span>
|
|
58
|
-
{worktree.orphaned ? <span className="text-[10px] text-doom-faint">orphaned</span> : null}
|
|
59
|
-
{worktree.unowned ? <span className="text-[10px] text-doom-faint">unowned</span> : null}
|
|
60
|
-
</button>
|
|
61
|
-
))}
|
|
62
|
-
</div>
|
|
63
|
-
);
|
|
64
|
-
}
|
|
@@ -1,125 +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
|
-
* - Local form state is never reset by a data refresh. The hub republishes this
|
|
9
|
-
* list on a timer, and a half-typed branch name must survive that.
|
|
10
|
-
* - Acts through the plugin's own hub channel, so a worktree made here and one
|
|
11
|
-
* made by the tool take exactly the same path.
|
|
12
|
-
* - Creating takes minutes, so the hub reports progress and failure on that
|
|
13
|
-
* channel and this panel renders both. A button that looks idle for two
|
|
14
|
-
* minutes reads as broken.
|
|
15
|
-
*
|
|
16
|
-
* AVOID:
|
|
17
|
-
* - Deriving form state from props or store data. That is what wiped the
|
|
18
|
-
* fields on every poll.
|
|
19
|
-
*/
|
|
20
|
-
import { Button, Input } from '@agimon-ai/doompi-web-components';
|
|
21
|
-
import type { TransientTab, WebPluginSlotProps } from '@agimon-ai/doompi-web-contracts';
|
|
22
|
-
import { useStore } from '@tanstack/react-store';
|
|
23
|
-
import { useState } from 'react';
|
|
24
|
-
import type { WorktreeView } from '../../types/webWorktrees.ts';
|
|
25
|
-
import { requestWorktreeClose, requestWorktreeCreate, worktreeActivity } from '../stores/worktreesActivityStore.ts';
|
|
26
|
-
|
|
27
|
-
const WORKTREES_TAB_ID = 'git-worktrees';
|
|
28
|
-
|
|
29
|
-
export function worktreesTab(): TransientTab {
|
|
30
|
-
return { id: WORKTREES_TAB_ID, label: 'worktrees', panel: WorktreesPanel };
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function WorktreesPanel({ sessionId }: WebPluginSlotProps) {
|
|
34
|
-
const session = useStore(worktreeActivity.store, (state) => worktreeActivity.select(state, sessionId));
|
|
35
|
-
const [branch, setBranch] = useState('');
|
|
36
|
-
const [baseRef, setBaseRef] = useState('');
|
|
37
|
-
|
|
38
|
-
const busy = session.pending !== undefined;
|
|
39
|
-
const canCreate = sessionId !== null && branch.trim() !== '' && !busy;
|
|
40
|
-
|
|
41
|
-
const create = (): void => {
|
|
42
|
-
if (sessionId === null || !canCreate) return;
|
|
43
|
-
requestWorktreeCreate(sessionId, branch, baseRef);
|
|
44
|
-
setBranch('');
|
|
45
|
-
setBaseRef('');
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<div className="flex flex-col gap-3 p-3" data-testid="git-worktrees-panel">
|
|
50
|
-
<div className="flex flex-col gap-1">
|
|
51
|
-
<div className="flex items-center gap-2">
|
|
52
|
-
<Input
|
|
53
|
-
data-testid="git-worktree-branch"
|
|
54
|
-
aria-label="Branch"
|
|
55
|
-
placeholder="wt/fix-auth"
|
|
56
|
-
value={branch}
|
|
57
|
-
onChange={(event) => setBranch(event.target.value)}
|
|
58
|
-
onKeyDown={(event) => {
|
|
59
|
-
if (event.key === 'Enter') create();
|
|
60
|
-
}}
|
|
61
|
-
/>
|
|
62
|
-
<Input
|
|
63
|
-
data-testid="git-worktree-base"
|
|
64
|
-
aria-label="Base ref"
|
|
65
|
-
placeholder="base (current)"
|
|
66
|
-
value={baseRef}
|
|
67
|
-
onChange={(event) => setBaseRef(event.target.value)}
|
|
68
|
-
className="w-40"
|
|
69
|
-
/>
|
|
70
|
-
<Button data-testid="git-worktree-create" size="xs" disabled={!canCreate} onClick={create}>
|
|
71
|
-
Create
|
|
72
|
-
</Button>
|
|
73
|
-
</div>
|
|
74
|
-
<p className="text-[10px] text-doom-faint">
|
|
75
|
-
Creates the worktree outside the repository, installs its dependencies, then starts a session nested under
|
|
76
|
-
this one. The install is what makes the wait; a warm store is under a minute.
|
|
77
|
-
</p>
|
|
78
|
-
{session.pending === undefined ? null : (
|
|
79
|
-
<p data-testid="git-worktree-pending" className="text-[10px] text-doom-dim">
|
|
80
|
-
{session.pending}
|
|
81
|
-
</p>
|
|
82
|
-
)}
|
|
83
|
-
{session.error === undefined ? null : (
|
|
84
|
-
<p data-testid="git-worktree-error" className="text-[10px] text-doom-error">
|
|
85
|
-
{session.error}
|
|
86
|
-
</p>
|
|
87
|
-
)}
|
|
88
|
-
</div>
|
|
89
|
-
|
|
90
|
-
{session.worktrees.length === 0 ? (
|
|
91
|
-
<p className="text-[11px] text-doom-faint">No worktrees yet.</p>
|
|
92
|
-
) : (
|
|
93
|
-
<ul className="flex flex-col gap-1">
|
|
94
|
-
{session.worktrees.map((worktree: WorktreeView) => (
|
|
95
|
-
<li
|
|
96
|
-
key={worktree.id}
|
|
97
|
-
data-testid={`git-worktree-${worktree.id}`}
|
|
98
|
-
className="flex items-center justify-between gap-2 border border-doom-line px-2 py-1"
|
|
99
|
-
>
|
|
100
|
-
<div className="flex min-w-0 flex-col">
|
|
101
|
-
<span className="truncate text-[11px] text-doom-bright">{worktree.branch}</span>
|
|
102
|
-
<span className="truncate text-[10px] text-doom-faint">{worktree.path}</span>
|
|
103
|
-
</div>
|
|
104
|
-
<div className="flex items-center gap-2">
|
|
105
|
-
{worktree.orphaned ? <span className="text-[10px] text-doom-faint">orphaned</span> : null}
|
|
106
|
-
{worktree.unowned ? <span className="text-[10px] text-doom-faint">unowned</span> : null}
|
|
107
|
-
{sessionId === null ? null : (
|
|
108
|
-
<Button
|
|
109
|
-
variant="link"
|
|
110
|
-
size="xs"
|
|
111
|
-
disabled={busy}
|
|
112
|
-
data-testid={`git-worktree-close-${worktree.id}`}
|
|
113
|
-
onClick={() => requestWorktreeClose(sessionId, worktree.id)}
|
|
114
|
-
>
|
|
115
|
-
close
|
|
116
|
-
</Button>
|
|
117
|
-
)}
|
|
118
|
-
</div>
|
|
119
|
-
</li>
|
|
120
|
-
))}
|
|
121
|
-
</ul>
|
|
122
|
-
)}
|
|
123
|
-
</div>
|
|
124
|
-
);
|
|
125
|
-
}
|
|
@@ -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
|
-
}
|
package/src/web/tsconfig.json
DELETED
|
@@ -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
|
-
}
|