dsh-git-worktree 0.1.1 → 0.2.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.
- package/CHANGELOG.md +59 -0
- package/LICENSE +21 -21
- package/README.md +115 -37
- package/README.zh.md +115 -37
- package/cordis.patch.yml +7 -7
- package/lib/adapters/registry.js +40 -0
- package/lib/adapters/registry.js.map +1 -1
- package/lib/adapters/safe-file.js +34 -4
- package/lib/adapters/safe-file.js.map +1 -1
- package/lib/client/WorktreeCreateRow.d.ts +7 -0
- package/lib/client/WorktreeCreateRow.js +26 -0
- package/lib/client/WorktreeCreateRow.js.map +1 -0
- package/lib/client/WorktreeReviewRow.d.ts +11 -0
- package/lib/client/WorktreeReviewRow.js +67 -0
- package/lib/client/WorktreeReviewRow.js.map +1 -0
- package/lib/client/actions.d.ts +86 -0
- package/lib/client/actions.js +35 -0
- package/lib/client/actions.js.map +1 -0
- package/lib/client/console-remote/adapter.d.ts +3 -0
- package/lib/client/console-remote/adapter.js +59 -0
- package/lib/client/console-remote/adapter.js.map +1 -0
- package/lib/client/console-remote/index.d.ts +18 -0
- package/lib/client/console-remote/index.js +17 -0
- package/lib/client/console-remote/index.js.map +1 -0
- package/lib/client/index.d.ts +17 -0
- package/lib/client/index.js +44 -0
- package/lib/client/index.js.map +1 -0
- package/lib/client/model.d.ts +68 -0
- package/lib/client/model.js +127 -0
- package/lib/client/model.js.map +1 -0
- package/lib/client/pre-session/PreSessionWorktreeToggle.d.ts +16 -0
- package/lib/client/pre-session/PreSessionWorktreeToggle.js +128 -0
- package/lib/client/pre-session/PreSessionWorktreeToggle.js.map +1 -0
- package/lib/client/pre-session/controller.d.ts +42 -0
- package/lib/client/pre-session/controller.js +149 -0
- package/lib/client/pre-session/controller.js.map +1 -0
- package/lib/client/pre-session/index.d.ts +15 -0
- package/lib/client/pre-session/index.js +16 -0
- package/lib/client/pre-session/index.js.map +1 -0
- package/lib/client/review-console/ReviewActions.d.ts +15 -0
- package/lib/client/review-console/ReviewActions.js +219 -0
- package/lib/client/review-console/ReviewActions.js.map +1 -0
- package/lib/client/review-console/WorktreeReviewPanel.d.ts +20 -0
- package/lib/client/review-console/WorktreeReviewPanel.js +75 -0
- package/lib/client/review-console/WorktreeReviewPanel.js.map +1 -0
- package/lib/client/review-console/index.d.ts +8 -0
- package/lib/client/review-console/index.js +22 -0
- package/lib/client/review-console/index.js.map +1 -0
- package/lib/client/review-console/review-console.styles.d.ts +1 -0
- package/lib/client/review-console/review-console.styles.js +81 -0
- package/lib/client/review-console/review-console.styles.js.map +1 -0
- package/lib/client/review-console/status-events.d.ts +3 -0
- package/lib/client/review-console/status-events.js +6 -0
- package/lib/client/review-console/status-events.js.map +1 -0
- package/lib/client/styles.d.ts +1 -0
- package/lib/client/styles.js +78 -0
- package/lib/client/styles.js.map +1 -0
- package/lib/client/target-console/TargetStatusAction.d.ts +7 -0
- package/lib/client/target-console/TargetStatusAction.js +46 -0
- package/lib/client/target-console/TargetStatusAction.js.map +1 -0
- package/lib/client/target-console/WorktreeConsoleView.d.ts +9 -0
- package/lib/client/target-console/WorktreeConsoleView.js +362 -0
- package/lib/client/target-console/WorktreeConsoleView.js.map +1 -0
- package/lib/client/target-console/WorktreeReviewStatus.d.ts +9 -0
- package/lib/client/target-console/WorktreeReviewStatus.js +91 -0
- package/lib/client/target-console/WorktreeReviewStatus.js.map +1 -0
- package/lib/client/target-console/index.d.ts +14 -0
- package/lib/client/target-console/index.js +23 -0
- package/lib/client/target-console/index.js.map +1 -0
- package/lib/client/target-console/target-console.styles.d.ts +1 -0
- package/lib/client/target-console/target-console.styles.js +130 -0
- package/lib/client/target-console/target-console.styles.js.map +1 -0
- package/lib/client.js +6813 -0
- package/lib/commands.d.ts +2 -4
- package/lib/commands.js +54 -28
- package/lib/commands.js.map +1 -1
- package/lib/console-contract.d.ts +236 -0
- package/lib/console-contract.js +86 -0
- package/lib/console-contract.js.map +1 -0
- package/lib/console-host/control-plane.d.ts +29 -0
- package/lib/console-host/control-plane.js +443 -0
- package/lib/console-host/control-plane.js.map +1 -0
- package/lib/console-host/errors.d.ts +6 -0
- package/lib/console-host/errors.js +31 -0
- package/lib/console-host/errors.js.map +1 -0
- package/lib/console-host/projection.d.ts +12 -0
- package/lib/console-host/projection.js +131 -0
- package/lib/console-host/projection.js.map +1 -0
- package/lib/console-host/review-diff.d.ts +18 -0
- package/lib/console-host/review-diff.js +176 -0
- package/lib/console-host/review-diff.js.map +1 -0
- package/lib/console-host/service.d.ts +24 -0
- package/lib/console-host/service.js +131 -0
- package/lib/console-host/service.js.map +1 -0
- package/lib/console-remote/descriptors.d.ts +3 -0
- package/lib/console-remote/descriptors.js +96 -0
- package/lib/console-remote/descriptors.js.map +1 -0
- package/lib/console-remote/remote.d.ts +27 -0
- package/lib/console-remote/remote.js +4 -0
- package/lib/console-remote/remote.js.map +1 -0
- package/lib/console-remote/schemas.d.ts +29 -0
- package/lib/console-remote/schemas.js +143 -0
- package/lib/console-remote/schemas.js.map +1 -0
- package/lib/console-remote/typert.d.ts +3 -0
- package/lib/console-remote/typert.js +14 -0
- package/lib/console-remote/typert.js.map +1 -0
- package/lib/index.d.ts +22 -6
- package/lib/index.js +28 -10
- package/lib/index.js.map +1 -1
- package/lib/managed-worktree-path.d.ts +14 -13
- package/lib/managed-worktree-path.js +32 -22
- package/lib/managed-worktree-path.js.map +1 -1
- package/lib/ports.d.ts +37 -1
- package/lib/session-checkout-apply.d.ts +54 -1
- package/lib/session-checkout-apply.js +318 -28
- package/lib/session-checkout-apply.js.map +1 -1
- package/lib/session-checkout-module.js +853 -33
- package/lib/session-checkout-module.js.map +1 -1
- package/lib/session-target-context.d.ts +6 -0
- package/lib/session-target-context.js +16 -0
- package/lib/session-target-context.js.map +1 -0
- package/lib/tools.d.ts +5 -6
- package/lib/tools.js +43 -233
- package/lib/tools.js.map +1 -1
- package/lib/types.d.ts +57 -11
- package/lib/types.js +6 -6
- package/lib/types.js.map +1 -1
- package/package.json +116 -67
- package/scripts/check-publish.mjs +193 -0
- package/scripts/clean-lib.mjs +7 -0
- package/scripts/dev-dsh-lib.mjs +453 -0
- package/scripts/dev-dsh.mjs +89 -0
- package/scripts/dsh-source-runner.mjs +14 -0
package/lib/commands.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `/worktree` human command surface
|
|
3
|
-
*
|
|
4
|
-
* but are user-initiated, so destructive verbs carry their own confirmation
|
|
5
|
-
* semantics (dirty discard is the user's own command).
|
|
2
|
+
* `/worktree` human command surface. Destructive verbs are intentionally
|
|
3
|
+
* user-initiated; model tools stop at Ready for Review.
|
|
6
4
|
* @module dsh-git-worktree/commands
|
|
7
5
|
*/
|
|
8
6
|
import type { Context } from '@deepseek-ai/cordis';
|
package/lib/commands.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `/worktree` human command surface
|
|
3
|
-
*
|
|
4
|
-
* but are user-initiated, so destructive verbs carry their own confirmation
|
|
5
|
-
* semantics (dirty discard is the user's own command).
|
|
2
|
+
* `/worktree` human command surface. Destructive verbs are intentionally
|
|
3
|
+
* user-initiated; model tools stop at Ready for Review.
|
|
6
4
|
* @module dsh-git-worktree/commands
|
|
7
5
|
*/
|
|
8
6
|
import '@deepseek-ai/dsh-commands';
|
|
@@ -22,46 +20,71 @@ function sessionIdOf(agent) {
|
|
|
22
20
|
throw new Error('`/worktree` 只能在 DSH Agent 会话中使用');
|
|
23
21
|
return session.id;
|
|
24
22
|
}
|
|
25
|
-
const
|
|
23
|
+
const RETENTIONS = new Set(['cleanup', 'retain_24h', 'retain_3d', 'retain_manual']);
|
|
24
|
+
const USAGE = 'Usage: /worktree status | list | finalize [<reviewId> <revision>] [cleanup|retain_24h|retain_3d|retain_manual] | finish <message> | discard | remove <checkoutId>';
|
|
25
|
+
function finishedText(result) {
|
|
26
|
+
return `Finished: committed ${result.changedFiles.length} file(s) as ${result.commitOid?.slice(0, 7) ?? 'no-op'} (cleanup: ${result.cleanup}).`;
|
|
27
|
+
}
|
|
26
28
|
/** Register the `/worktree` command. */
|
|
27
29
|
export function registerWorktreeCommand(ctx, module) {
|
|
28
30
|
ctx.commands.register({
|
|
29
31
|
name: 'worktree',
|
|
30
|
-
description: '
|
|
31
|
-
input: { hint: '
|
|
32
|
+
description: 'inspect and explicitly accept managed worktree delivery',
|
|
33
|
+
input: { hint: 'status | list | finalize [retention] | finish <message> | discard | remove <checkoutId>' },
|
|
32
34
|
handler: async (invocation) => {
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
+
const rawInput = invocation.rawInput.trim();
|
|
36
|
+
const tokens = rawInput.split(/\s+/u).filter(Boolean);
|
|
37
|
+
const verb = tokens[0] ?? 'status';
|
|
35
38
|
const sessionId = sessionIdOf(invocation.agent);
|
|
36
39
|
try {
|
|
37
40
|
switch (verb) {
|
|
38
|
-
case '
|
|
39
|
-
|
|
40
|
-
return { kind: 'success', text: `Worktree created:\n${targetText(target)}\n打开新会话并选择该工作区以在其中工作。` };
|
|
41
|
+
case 'status': {
|
|
42
|
+
return { kind: 'success', text: targetText(await module.inspect(sessionId)) };
|
|
41
43
|
}
|
|
42
44
|
case 'list': {
|
|
43
|
-
const summaries = await module.
|
|
45
|
+
const summaries = await module.listManagedWorktreesForSession(sessionId);
|
|
44
46
|
if (summaries.length === 0)
|
|
45
|
-
return { kind: 'success', text: 'No managed worktrees.' };
|
|
47
|
+
return { kind: 'success', text: 'No managed worktrees visible to this Session.' };
|
|
46
48
|
return {
|
|
47
49
|
kind: 'success',
|
|
48
50
|
text: summaries.map((summary) => (`${summary.checkoutId} ${summary.project.name} i${summary.iteration} ${summary.state}/${summary.phase} dirty=${summary.dirty}`)).join('\n'),
|
|
49
51
|
};
|
|
50
52
|
}
|
|
51
|
-
case '
|
|
53
|
+
case 'finalize': {
|
|
54
|
+
const hasReviewIdentity = tokens[1] !== undefined && !RETENTIONS.has(tokens[1]);
|
|
55
|
+
const expectedReviewId = hasReviewIdentity ? tokens[1] : undefined;
|
|
56
|
+
const parsedRevision = hasReviewIdentity ? Number(tokens[2]) : undefined;
|
|
57
|
+
const retention = (hasReviewIdentity ? tokens[3] : tokens[1] ?? 'cleanup');
|
|
58
|
+
if (!RETENTIONS.has(retention) || (hasReviewIdentity && (!expectedReviewId || !Number.isSafeInteger(parsedRevision)))) {
|
|
59
|
+
return { kind: 'error', text: USAGE };
|
|
60
|
+
}
|
|
52
61
|
const target = await module.inspect(sessionId);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
62
|
+
if (target.delivery?.state !== 'ready_for_review') {
|
|
63
|
+
return { kind: 'error', text: '当前 Worktree 尚未 Ready for Review,不能 finalize。' };
|
|
64
|
+
}
|
|
65
|
+
if (expectedReviewId && (target.delivery.review.reviewId !== expectedReviewId
|
|
66
|
+
|| target.revision !== parsedRevision)) {
|
|
67
|
+
return { kind: 'error', text: '该验收卡已过期;请确认会话中的最新 Ready for Review 卡片。' };
|
|
68
|
+
}
|
|
69
|
+
const result = await module.operate({
|
|
70
|
+
action: 'finish',
|
|
71
|
+
sessionId,
|
|
72
|
+
expectedRevision: parsedRevision ?? target.revision,
|
|
73
|
+
commitMessage: target.delivery.review.suggestedCommitMessage,
|
|
74
|
+
retention,
|
|
75
|
+
...(expectedReviewId ? { expectedReviewId } : {}),
|
|
76
|
+
});
|
|
77
|
+
if (result.status === 'finished')
|
|
78
|
+
return { kind: 'success', text: finishedText(result) };
|
|
56
79
|
if (result.status === 'conflict') {
|
|
57
|
-
return { kind: 'error', text: `Conflict: ${result.conflictingFiles.join('、')}\nLocal HEAD: ${result.localHeadOid.slice(0, 7)} — 在
|
|
80
|
+
return { kind: 'error', text: `Conflict: ${result.conflictingFiles.join('、')}\nLocal HEAD: ${result.localHeadOid.slice(0, 7)} — 在 Worktree 内同步并解决后重新 Ready。` };
|
|
58
81
|
}
|
|
59
82
|
if (result.status === 'error')
|
|
60
83
|
return { kind: 'error', text: `${result.code}: ${result.message}` };
|
|
61
|
-
return { kind: 'error', text: '
|
|
84
|
+
return { kind: 'error', text: 'Finalize 未返回预期结果' };
|
|
62
85
|
}
|
|
63
86
|
case 'finish': {
|
|
64
|
-
const commitMessage =
|
|
87
|
+
const commitMessage = rawInput.slice(verb.length).trim();
|
|
65
88
|
if (!commitMessage)
|
|
66
89
|
return { kind: 'error', text: USAGE };
|
|
67
90
|
const target = await module.inspect(sessionId);
|
|
@@ -71,9 +94,10 @@ export function registerWorktreeCommand(ctx, module) {
|
|
|
71
94
|
expectedRevision: target.revision,
|
|
72
95
|
commitMessage,
|
|
73
96
|
});
|
|
74
|
-
if (result.status === 'finished')
|
|
75
|
-
return { kind: 'success', text:
|
|
76
|
-
|
|
97
|
+
if (result.status === 'finished')
|
|
98
|
+
return { kind: 'success', text: finishedText(result) };
|
|
99
|
+
if (result.status === 'conflict')
|
|
100
|
+
return { kind: 'error', text: `Conflict: ${result.conflictingFiles.join('、')}` };
|
|
77
101
|
if (result.status === 'error')
|
|
78
102
|
return { kind: 'error', text: `${result.code}: ${result.message}` };
|
|
79
103
|
return { kind: 'error', text: 'Finish 未返回预期结果' };
|
|
@@ -85,9 +109,10 @@ export function registerWorktreeCommand(ctx, module) {
|
|
|
85
109
|
sessionId,
|
|
86
110
|
expectedRevision: target.revision,
|
|
87
111
|
confirmDirty: true,
|
|
112
|
+
...(target.delivery?.state === 'preview_active' ? { rollbackPreview: true } : {}),
|
|
88
113
|
});
|
|
89
114
|
return result.status === 'discarded'
|
|
90
|
-
? { kind: 'success', text: 'Worktree discarded.' }
|
|
115
|
+
? { kind: 'success', text: 'Worktree discarded. This Session target is no longer available.' }
|
|
91
116
|
: result.status === 'error'
|
|
92
117
|
? { kind: 'error', text: `${result.code}: ${result.message}` }
|
|
93
118
|
: { kind: 'error', text: 'Discard 未返回预期结果' };
|
|
@@ -96,15 +121,16 @@ export function registerWorktreeCommand(ctx, module) {
|
|
|
96
121
|
const checkoutId = tokens[1];
|
|
97
122
|
if (!checkoutId)
|
|
98
123
|
return { kind: 'error', text: USAGE };
|
|
99
|
-
const summaries = await module.
|
|
124
|
+
const summaries = await module.listManagedWorktreesForSession(sessionId, { checkoutId });
|
|
100
125
|
const summary = summaries[0];
|
|
101
126
|
if (!summary)
|
|
102
|
-
return { kind: 'error', text: `No managed worktree ${checkoutId}.` };
|
|
103
|
-
await module.
|
|
127
|
+
return { kind: 'error', text: `No managed worktree ${checkoutId} visible to this Session.` };
|
|
128
|
+
await module.manageManagedWorktreeForSession(sessionId, {
|
|
104
129
|
checkoutId,
|
|
105
130
|
expectedRevision: summary.revision,
|
|
106
131
|
action: 'discard',
|
|
107
132
|
confirmDirty: true,
|
|
133
|
+
...(summary.state === 'preview_active' ? { rollbackPreview: true } : {}),
|
|
108
134
|
});
|
|
109
135
|
return { kind: 'success', text: `Removed worktree ${checkoutId}.` };
|
|
110
136
|
}
|
package/lib/commands.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,2BAA2B,CAAA;AAIlC,SAAS,UAAU,CAAC,MAAyB;IAC3C,MAAM,KAAK,GAAG;QACZ,aAAa,MAAM,CAAC,QAAQ,CAAC,KAAK,KAAK,MAAM,CAAC,QAAQ,CAAC,IAAI,WAAW,MAAM,CAAC,QAAQ,CAAC,KAAK,GAAG;QAC9F,UAAU,MAAM,CAAC,KAAK,EAAE;QACxB,YAAY,MAAM,CAAC,OAAO,CAAC,MAAM,IAAI,UAAU,MAAM,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;KACtF,CAAA;IACD,IAAI,MAAM,CAAC,QAAQ;QAAE,KAAK,CAAC,IAAI,CAAC,aAAa,MAAM,CAAC,QAAQ,CAAC,KAAK,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AAC,EAAE,CAAA;YACxF,CAAC;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-only shared contract for the future Harness-native Worktree Console.
|
|
3
|
+
*
|
|
4
|
+
* This module deliberately contains no Cordis, React, Remote or filesystem
|
|
5
|
+
* implementation. Host and Client tracks share these DTOs while preserving one
|
|
6
|
+
* authority rule: every Host operation resolves an exact caller Session and
|
|
7
|
+
* re-validates project, owner, cwd, revision and review identity at execution.
|
|
8
|
+
* @module dsh-git-worktree/console-contract
|
|
9
|
+
*/
|
|
10
|
+
import { type SessionCheckoutErrorCode, type SessionCheckoutPhase, type WorktreeRetentionMode, type WorktreeApplyPreflightView, type WorktreeValidationItem, type WorktreeValidationStatus } from './types.js';
|
|
11
|
+
export declare const WORKTREE_CONSOLE_TARGET_STATES: readonly ["local", "creating", "working", "ready_for_review", "preview_active", "preview_detached", "retained", "cleanup_pending", "recovery_required", "delivered"];
|
|
12
|
+
export type WorktreeConsoleTargetState = typeof WORKTREE_CONSOLE_TARGET_STATES[number];
|
|
13
|
+
export type WorktreeConsoleDeliveryState = 'working' | 'ready_for_review' | 'preview_active' | 'preview_detached' | 'finalized' | 'retained' | 'delivered';
|
|
14
|
+
/** Minimal domain facts required to project a stable, UI-facing state. */
|
|
15
|
+
export interface WorktreeConsoleProjectionSource {
|
|
16
|
+
kind: 'local' | 'isolated';
|
|
17
|
+
phase: SessionCheckoutPhase;
|
|
18
|
+
deliveryState?: WorktreeConsoleDeliveryState;
|
|
19
|
+
}
|
|
20
|
+
/** Recovery and mutation phases take precedence over a stale delivery label. */
|
|
21
|
+
export declare function consoleStateFromDomain(source: WorktreeConsoleProjectionSource): WorktreeConsoleTargetState;
|
|
22
|
+
export interface WorktreeConsoleProject {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
}
|
|
26
|
+
export interface WorktreeConsoleCapabilities {
|
|
27
|
+
create: boolean;
|
|
28
|
+
open: boolean;
|
|
29
|
+
inspect: boolean;
|
|
30
|
+
discard: boolean;
|
|
31
|
+
preflight: boolean;
|
|
32
|
+
preview: boolean;
|
|
33
|
+
rollbackPreview: boolean;
|
|
34
|
+
/** Direct Ready → Commit path that skips Local Preview. */
|
|
35
|
+
finalize: boolean;
|
|
36
|
+
finalizePreview: boolean;
|
|
37
|
+
setRetention: boolean;
|
|
38
|
+
retryCleanup: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface WorktreeConsolePreviewRecovery {
|
|
41
|
+
reason: 'stale_local' | 'preview_modified';
|
|
42
|
+
attemptedAction: 'rollback_preview' | 'finalize_preview' | 'discard';
|
|
43
|
+
}
|
|
44
|
+
export interface WorktreeConsoleReviewSummary {
|
|
45
|
+
reviewId: string;
|
|
46
|
+
revision: number;
|
|
47
|
+
iteration: number;
|
|
48
|
+
preparedAt: number;
|
|
49
|
+
summary: string;
|
|
50
|
+
validationStatus: WorktreeValidationStatus;
|
|
51
|
+
validationSummary?: string;
|
|
52
|
+
tests: WorktreeValidationItem[];
|
|
53
|
+
changedFiles: string[];
|
|
54
|
+
suggestedCommitMessage: string;
|
|
55
|
+
}
|
|
56
|
+
/** Path-free row safe for project lists and header status chips. */
|
|
57
|
+
export interface WorktreeConsoleTargetSummary {
|
|
58
|
+
project: WorktreeConsoleProject;
|
|
59
|
+
checkoutId: string | null;
|
|
60
|
+
sourceSessionId: string;
|
|
61
|
+
ownerSessionId: string;
|
|
62
|
+
targetSessionId: string | null;
|
|
63
|
+
iteration: number;
|
|
64
|
+
revision: number;
|
|
65
|
+
state: WorktreeConsoleTargetState;
|
|
66
|
+
phase: SessionCheckoutPhase | 'local';
|
|
67
|
+
dirty: boolean;
|
|
68
|
+
currentOid: string;
|
|
69
|
+
commitOid: string | null;
|
|
70
|
+
retention?: Exclude<WorktreeRetentionMode, 'cleanup'>;
|
|
71
|
+
retainedAt?: number;
|
|
72
|
+
expiresAt?: number | null;
|
|
73
|
+
cleanupMessage?: string;
|
|
74
|
+
review?: WorktreeConsoleReviewSummary;
|
|
75
|
+
reviewSlot?: 'available' | 'waiting';
|
|
76
|
+
reviewSlotOwnerSessionId?: string;
|
|
77
|
+
previewRecovery?: WorktreeConsolePreviewRecovery;
|
|
78
|
+
capabilities: WorktreeConsoleCapabilities;
|
|
79
|
+
}
|
|
80
|
+
/** Identity-validated detail used only when the caller may open this target. */
|
|
81
|
+
export interface WorktreeConsoleTargetDetails extends WorktreeConsoleTargetSummary {
|
|
82
|
+
managedRoot: string | null;
|
|
83
|
+
sourceOid: string;
|
|
84
|
+
currentBranch: string | null;
|
|
85
|
+
}
|
|
86
|
+
export interface WorktreeConsoleCurrentRequest {
|
|
87
|
+
sessionId: string;
|
|
88
|
+
}
|
|
89
|
+
export interface WorktreeConsoleCurrentResponse {
|
|
90
|
+
target: WorktreeConsoleTargetDetails;
|
|
91
|
+
}
|
|
92
|
+
export interface WorktreeConsoleListRequest {
|
|
93
|
+
sessionId: string;
|
|
94
|
+
needsAttention?: boolean;
|
|
95
|
+
includeDelivered?: boolean;
|
|
96
|
+
}
|
|
97
|
+
export interface WorktreeConsoleListResponse {
|
|
98
|
+
project: WorktreeConsoleProject;
|
|
99
|
+
worktrees: WorktreeConsoleTargetSummary[];
|
|
100
|
+
}
|
|
101
|
+
/** targetSessionId is allocated on the Host; the browser never chooses ownership identity. */
|
|
102
|
+
export interface WorktreeConsoleCreateRequest {
|
|
103
|
+
sourceSessionId: string;
|
|
104
|
+
}
|
|
105
|
+
export interface WorktreeConsoleCreateResponse {
|
|
106
|
+
target: WorktreeConsoleTargetDetails;
|
|
107
|
+
targetSessionId: string;
|
|
108
|
+
managedRoot: string;
|
|
109
|
+
}
|
|
110
|
+
export interface WorktreeConsoleInspectRequest {
|
|
111
|
+
sessionId: string;
|
|
112
|
+
checkoutId: string;
|
|
113
|
+
}
|
|
114
|
+
export interface WorktreeConsoleInspectResponse {
|
|
115
|
+
target: WorktreeConsoleTargetDetails;
|
|
116
|
+
}
|
|
117
|
+
export interface WorktreeConsoleDiscardRequest {
|
|
118
|
+
sessionId: string;
|
|
119
|
+
checkoutId: string;
|
|
120
|
+
expectedRevision: number;
|
|
121
|
+
confirmDirty: boolean;
|
|
122
|
+
rollbackPreview?: boolean;
|
|
123
|
+
}
|
|
124
|
+
export interface WorktreeConsolePreflightRequest {
|
|
125
|
+
sessionId: string;
|
|
126
|
+
checkoutId: string;
|
|
127
|
+
expectedRevision: number;
|
|
128
|
+
expectedReviewId: string;
|
|
129
|
+
}
|
|
130
|
+
export interface WorktreeConsolePreflightResponse {
|
|
131
|
+
preflight: WorktreeApplyPreflightView;
|
|
132
|
+
}
|
|
133
|
+
export interface WorktreeConsolePreviewRequest {
|
|
134
|
+
sessionId: string;
|
|
135
|
+
checkoutId: string;
|
|
136
|
+
expectedRevision: number;
|
|
137
|
+
expectedReviewId: string;
|
|
138
|
+
}
|
|
139
|
+
export interface WorktreeConsoleRollbackPreviewRequest {
|
|
140
|
+
sessionId: string;
|
|
141
|
+
checkoutId: string;
|
|
142
|
+
expectedRevision: number;
|
|
143
|
+
resumeRevision?: boolean;
|
|
144
|
+
}
|
|
145
|
+
export interface WorktreeConsoleFinalizeRequest {
|
|
146
|
+
sessionId: string;
|
|
147
|
+
checkoutId: string;
|
|
148
|
+
expectedRevision: number;
|
|
149
|
+
expectedReviewId: string;
|
|
150
|
+
/** Explicit user-confirmed message; Host revalidates the bounded value. */
|
|
151
|
+
commitMessage: string;
|
|
152
|
+
retention: WorktreeRetentionMode;
|
|
153
|
+
}
|
|
154
|
+
export interface WorktreeConsoleFinalizePreviewRequest {
|
|
155
|
+
sessionId: string;
|
|
156
|
+
checkoutId: string;
|
|
157
|
+
expectedRevision: number;
|
|
158
|
+
expectedReviewId: string;
|
|
159
|
+
commitMessage: string;
|
|
160
|
+
retention: WorktreeRetentionMode;
|
|
161
|
+
}
|
|
162
|
+
export interface WorktreeConsoleSetRetentionRequest {
|
|
163
|
+
sessionId: string;
|
|
164
|
+
checkoutId: string;
|
|
165
|
+
expectedRevision: number;
|
|
166
|
+
retention: Exclude<WorktreeRetentionMode, 'cleanup'>;
|
|
167
|
+
}
|
|
168
|
+
export interface WorktreeConsoleRetryCleanupRequest {
|
|
169
|
+
sessionId: string;
|
|
170
|
+
checkoutId: string;
|
|
171
|
+
expectedRevision: number;
|
|
172
|
+
}
|
|
173
|
+
export interface WorktreeConsoleMutationResponse {
|
|
174
|
+
target: WorktreeConsoleTargetSummary;
|
|
175
|
+
changedFiles?: string[];
|
|
176
|
+
commitOid?: string | null;
|
|
177
|
+
}
|
|
178
|
+
export type WorktreeConsoleFileStatus = 'added' | 'modified' | 'deleted' | 'renamed' | 'binary';
|
|
179
|
+
export interface WorktreeConsoleDiffFile {
|
|
180
|
+
path: string;
|
|
181
|
+
previousPath?: string;
|
|
182
|
+
status: WorktreeConsoleFileStatus;
|
|
183
|
+
patch: string | null;
|
|
184
|
+
truncated: boolean;
|
|
185
|
+
}
|
|
186
|
+
/** Review reads are bound to the same immutable identity required by Finalize. */
|
|
187
|
+
export interface WorktreeConsoleReviewDiffRequest {
|
|
188
|
+
sessionId: string;
|
|
189
|
+
checkoutId: string;
|
|
190
|
+
expectedRevision: number;
|
|
191
|
+
expectedReviewId: string;
|
|
192
|
+
}
|
|
193
|
+
export interface WorktreeConsoleReviewDiffResponse {
|
|
194
|
+
reviewId: string;
|
|
195
|
+
revision: number;
|
|
196
|
+
files: WorktreeConsoleDiffFile[];
|
|
197
|
+
truncated: boolean;
|
|
198
|
+
}
|
|
199
|
+
export declare const WORKTREE_CONSOLE_ERROR_CODES: readonly ["session_not_found", "project_not_found", "project_root_missing", "not_git_repository", "target_unselected", "target_already_bound", "project_mismatch", "checkout_missing", "checkout_mismatch", "recovery_required", "registry_corrupt", "git_operation_failed", "not_owner", "stale_target", "dirty_confirmation_required", "apply_conflict", "apply_failed", "invalid_input", "invalid_plan", "stale_local", "stale_isolated", "git_error", "commit_isolation_conflict", "checkout_limit_reached", "project_acceptance_busy", "operation_not_allowed", "preview_not_active", "preview_modified", "recovery_unsafe", "transport_unavailable", "malformed_response"];
|
|
200
|
+
export type WorktreeConsoleErrorCode = SessionCheckoutErrorCode | 'transport_unavailable' | 'malformed_response';
|
|
201
|
+
export type WorktreeConsoleErrorCategory = 'permission' | 'stale' | 'confirmation' | 'recovery' | 'conflict' | 'unavailable' | 'invalid' | 'internal';
|
|
202
|
+
export type WorktreeConsoleRecovery = 'none' | 'refresh' | 'confirm_dirty' | 'open_recovery' | 'retry';
|
|
203
|
+
export interface WorktreeConsoleError {
|
|
204
|
+
code: WorktreeConsoleErrorCode;
|
|
205
|
+
message: string;
|
|
206
|
+
details?: Record<string, string | number | boolean | null>;
|
|
207
|
+
}
|
|
208
|
+
export type WorktreeConsoleOutcome<T> = {
|
|
209
|
+
ok: true;
|
|
210
|
+
value: T;
|
|
211
|
+
} | {
|
|
212
|
+
ok: false;
|
|
213
|
+
error: WorktreeConsoleError;
|
|
214
|
+
};
|
|
215
|
+
export interface WorktreeConsoleErrorMeta {
|
|
216
|
+
category: WorktreeConsoleErrorCategory;
|
|
217
|
+
recovery: WorktreeConsoleRecovery;
|
|
218
|
+
retryable: boolean;
|
|
219
|
+
}
|
|
220
|
+
export declare function worktreeConsoleErrorMeta(code: WorktreeConsoleErrorCode): WorktreeConsoleErrorMeta;
|
|
221
|
+
/** Normalized Client seam; Remote transport details stay behind one adapter. */
|
|
222
|
+
export interface WorktreeConsoleAdapter {
|
|
223
|
+
current(request: WorktreeConsoleCurrentRequest): Promise<WorktreeConsoleOutcome<WorktreeConsoleCurrentResponse>>;
|
|
224
|
+
list(request: WorktreeConsoleListRequest): Promise<WorktreeConsoleOutcome<WorktreeConsoleListResponse>>;
|
|
225
|
+
create(request: WorktreeConsoleCreateRequest): Promise<WorktreeConsoleOutcome<WorktreeConsoleCreateResponse>>;
|
|
226
|
+
inspect(request: WorktreeConsoleInspectRequest): Promise<WorktreeConsoleOutcome<WorktreeConsoleInspectResponse>>;
|
|
227
|
+
reviewDiff(request: WorktreeConsoleReviewDiffRequest): Promise<WorktreeConsoleOutcome<WorktreeConsoleReviewDiffResponse>>;
|
|
228
|
+
preflight(request: WorktreeConsolePreflightRequest): Promise<WorktreeConsoleOutcome<WorktreeConsolePreflightResponse>>;
|
|
229
|
+
preview(request: WorktreeConsolePreviewRequest): Promise<WorktreeConsoleOutcome<WorktreeConsoleMutationResponse>>;
|
|
230
|
+
rollbackPreview(request: WorktreeConsoleRollbackPreviewRequest): Promise<WorktreeConsoleOutcome<WorktreeConsoleMutationResponse>>;
|
|
231
|
+
discard(request: WorktreeConsoleDiscardRequest): Promise<WorktreeConsoleOutcome<WorktreeConsoleMutationResponse>>;
|
|
232
|
+
finalize(request: WorktreeConsoleFinalizeRequest): Promise<WorktreeConsoleOutcome<WorktreeConsoleMutationResponse>>;
|
|
233
|
+
finalizePreview(request: WorktreeConsoleFinalizePreviewRequest): Promise<WorktreeConsoleOutcome<WorktreeConsoleMutationResponse>>;
|
|
234
|
+
setRetention(request: WorktreeConsoleSetRetentionRequest): Promise<WorktreeConsoleOutcome<WorktreeConsoleMutationResponse>>;
|
|
235
|
+
retryCleanup(request: WorktreeConsoleRetryCleanupRequest): Promise<WorktreeConsoleOutcome<WorktreeConsoleMutationResponse>>;
|
|
236
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-only shared contract for the future Harness-native Worktree Console.
|
|
3
|
+
*
|
|
4
|
+
* This module deliberately contains no Cordis, React, Remote or filesystem
|
|
5
|
+
* implementation. Host and Client tracks share these DTOs while preserving one
|
|
6
|
+
* authority rule: every Host operation resolves an exact caller Session and
|
|
7
|
+
* re-validates project, owner, cwd, revision and review identity at execution.
|
|
8
|
+
* @module dsh-git-worktree/console-contract
|
|
9
|
+
*/
|
|
10
|
+
import { SESSION_CHECKOUT_ERROR_CODES, } from './types.js';
|
|
11
|
+
export const WORKTREE_CONSOLE_TARGET_STATES = [
|
|
12
|
+
'local',
|
|
13
|
+
'creating',
|
|
14
|
+
'working',
|
|
15
|
+
'ready_for_review',
|
|
16
|
+
'preview_active',
|
|
17
|
+
'preview_detached',
|
|
18
|
+
'retained',
|
|
19
|
+
'cleanup_pending',
|
|
20
|
+
'recovery_required',
|
|
21
|
+
'delivered',
|
|
22
|
+
];
|
|
23
|
+
/** Recovery and mutation phases take precedence over a stale delivery label. */
|
|
24
|
+
export function consoleStateFromDomain(source) {
|
|
25
|
+
if (source.kind === 'local')
|
|
26
|
+
return 'local';
|
|
27
|
+
if (source.phase === 'recovery_required')
|
|
28
|
+
return 'recovery_required';
|
|
29
|
+
if (source.phase === 'preparing')
|
|
30
|
+
return 'creating';
|
|
31
|
+
if (source.deliveryState === 'retained' || source.phase === 'retained')
|
|
32
|
+
return 'retained';
|
|
33
|
+
if (source.deliveryState === 'finalized' || source.phase === 'finalized')
|
|
34
|
+
return 'cleanup_pending';
|
|
35
|
+
if (source.deliveryState === 'delivered' || source.phase === 'discarded')
|
|
36
|
+
return 'delivered';
|
|
37
|
+
if (source.deliveryState === 'preview_detached')
|
|
38
|
+
return 'preview_detached';
|
|
39
|
+
if (source.deliveryState === 'preview_active')
|
|
40
|
+
return 'preview_active';
|
|
41
|
+
if (source.deliveryState === 'ready_for_review')
|
|
42
|
+
return 'ready_for_review';
|
|
43
|
+
return 'working';
|
|
44
|
+
}
|
|
45
|
+
export const WORKTREE_CONSOLE_ERROR_CODES = [
|
|
46
|
+
...SESSION_CHECKOUT_ERROR_CODES,
|
|
47
|
+
'transport_unavailable',
|
|
48
|
+
'malformed_response',
|
|
49
|
+
];
|
|
50
|
+
const ERROR_META = {
|
|
51
|
+
session_not_found: { category: 'unavailable', recovery: 'refresh', retryable: true },
|
|
52
|
+
project_not_found: { category: 'unavailable', recovery: 'refresh', retryable: true },
|
|
53
|
+
project_root_missing: { category: 'unavailable', recovery: 'open_recovery', retryable: false },
|
|
54
|
+
not_git_repository: { category: 'invalid', recovery: 'none', retryable: false },
|
|
55
|
+
target_unselected: { category: 'unavailable', recovery: 'refresh', retryable: true },
|
|
56
|
+
target_already_bound: { category: 'invalid', recovery: 'refresh', retryable: true },
|
|
57
|
+
project_mismatch: { category: 'permission', recovery: 'none', retryable: false },
|
|
58
|
+
checkout_missing: { category: 'unavailable', recovery: 'refresh', retryable: true },
|
|
59
|
+
checkout_mismatch: { category: 'permission', recovery: 'open_recovery', retryable: false },
|
|
60
|
+
recovery_required: { category: 'recovery', recovery: 'open_recovery', retryable: false },
|
|
61
|
+
registry_corrupt: { category: 'recovery', recovery: 'open_recovery', retryable: false },
|
|
62
|
+
git_operation_failed: { category: 'internal', recovery: 'retry', retryable: true },
|
|
63
|
+
not_owner: { category: 'permission', recovery: 'none', retryable: false },
|
|
64
|
+
stale_target: { category: 'stale', recovery: 'refresh', retryable: true },
|
|
65
|
+
dirty_confirmation_required: { category: 'confirmation', recovery: 'confirm_dirty', retryable: true },
|
|
66
|
+
apply_conflict: { category: 'conflict', recovery: 'open_recovery', retryable: false },
|
|
67
|
+
apply_failed: { category: 'internal', recovery: 'retry', retryable: true },
|
|
68
|
+
invalid_input: { category: 'invalid', recovery: 'none', retryable: false },
|
|
69
|
+
invalid_plan: { category: 'invalid', recovery: 'refresh', retryable: true },
|
|
70
|
+
stale_local: { category: 'stale', recovery: 'refresh', retryable: true },
|
|
71
|
+
stale_isolated: { category: 'stale', recovery: 'refresh', retryable: true },
|
|
72
|
+
git_error: { category: 'internal', recovery: 'retry', retryable: true },
|
|
73
|
+
commit_isolation_conflict: { category: 'conflict', recovery: 'open_recovery', retryable: false },
|
|
74
|
+
checkout_limit_reached: { category: 'invalid', recovery: 'none', retryable: false },
|
|
75
|
+
project_acceptance_busy: { category: 'conflict', recovery: 'retry', retryable: true },
|
|
76
|
+
operation_not_allowed: { category: 'invalid', recovery: 'refresh', retryable: true },
|
|
77
|
+
preview_not_active: { category: 'invalid', recovery: 'refresh', retryable: true },
|
|
78
|
+
preview_modified: { category: 'stale', recovery: 'open_recovery', retryable: false },
|
|
79
|
+
recovery_unsafe: { category: 'recovery', recovery: 'open_recovery', retryable: false },
|
|
80
|
+
transport_unavailable: { category: 'unavailable', recovery: 'retry', retryable: true },
|
|
81
|
+
malformed_response: { category: 'internal', recovery: 'none', retryable: false },
|
|
82
|
+
};
|
|
83
|
+
export function worktreeConsoleErrorMeta(code) {
|
|
84
|
+
return ERROR_META[code];
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=console-contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console-contract.js","sourceRoot":"","sources":["../src/console-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,4BAA4B,GAO7B,MAAM,YAAY,CAAA;AAEnB,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,OAAO;IACP,UAAU;IACV,SAAS;IACT,kBAAkB;IAClB,gBAAgB;IAChB,kBAAkB;IAClB,UAAU;IACV,iBAAiB;IACjB,mBAAmB;IACnB,WAAW;CACH,CAAA;AAoBV,gFAAgF;AAChF,MAAM,UAAU,sBAAsB,CAAC,MAAuC;IAC5E,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,OAAO,CAAA;IAC3C,IAAI,MAAM,CAAC,KAAK,KAAK,mBAAmB;QAAE,OAAO,mBAAmB,CAAA;IACpE,IAAI,MAAM,CAAC,KAAK,KAAK,WAAW;QAAE,OAAO,UAAU,CAAA;IACnD,IAAI,MAAM,CAAC,aAAa,KAAK,UAAU,IAAI,MAAM,CAAC,KAAK,KAAK,UAAU;QAAE,OAAO,UAAU,CAAA;IACzF,IAAI,MAAM,CAAC,aAAa,KAAK,WAAW,IAAI,MAAM,CAAC,KAAK,KAAK,WAAW;QAAE,OAAO,iBAAiB,CAAA;IAClG,IAAI,MAAM,CAAC,aAAa,KAAK,WAAW,IAAI,MAAM,CAAC,KAAK,KAAK,WAAW;QAAE,OAAO,WAAW,CAAA;IAC5F,IAAI,MAAM,CAAC,aAAa,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viewRequest, WorktreeConsoleFinalizeRequest, WorktreeConsoleInspectResponse, WorktreeConsoleListRequest, WorktreeConsoleListResponse, WorktreeConsoleMutationResponse, WorktreeConsoleOutcome, WorktreeConsolePreflightRequest, WorktreeConsolePreflightResponse, WorktreeConsolePreviewRequest, WorktreeConsoleRollbackPreviewRequest, WorktreeConsoleRetryCleanupRequest, WorktreeConsoleReviewDiffRequest, WorktreeConsoleReviewDiffResponse, WorktreeConsoleSetRetentionRequest } from '../console-contract.js';
|
|
2
|
+
import type { SessionCheckoutFilesPort, SessionCheckoutGitPort, SessionCheckoutLookupPort, SessionCheckoutRegistryPort } from '../ports.js';
|
|
3
|
+
import type { SessionCheckoutModule } from '../index.js';
|
|
4
|
+
import { type WorktreeReviewDiffReader } from './review-diff.js';
|
|
5
|
+
export interface WorktreeConsoleControlPlaneOptions {
|
|
6
|
+
module: SessionCheckoutModule;
|
|
7
|
+
lookup: SessionCheckoutLookupPort;
|
|
8
|
+
files: SessionCheckoutFilesPort;
|
|
9
|
+
registry: SessionCheckoutRegistryPort;
|
|
10
|
+
git: SessionCheckoutGitPort;
|
|
11
|
+
reviewDiff: WorktreeReviewDiffReader;
|
|
12
|
+
createTargetSessionId?: () => string;
|
|
13
|
+
}
|
|
14
|
+
export interface WorktreeConsoleControlPlane {
|
|
15
|
+
current(sessionId: string): Promise<WorktreeConsoleOutcome<WorktreeConsoleCurrentResponse>>;
|
|
16
|
+
list(request: WorktreeConsoleListRequest): Promise<WorktreeConsoleOutcome<WorktreeConsoleListResponse>>;
|
|
17
|
+
create(sourceSessionId: string): Promise<WorktreeConsoleOutcome<WorktreeConsoleCreateResponse>>;
|
|
18
|
+
inspect(sessionId: string, checkoutId: string): Promise<WorktreeConsoleOutcome<WorktreeConsoleInspectResponse>>;
|
|
19
|
+
reviewDiff(request: WorktreeConsoleReviewDiffRequest): Promise<WorktreeConsoleOutcome<WorktreeConsoleReviewDiffResponse>>;
|
|
20
|
+
preflight(request: WorktreeConsolePreflightRequest): Promise<WorktreeConsoleOutcome<WorktreeConsolePreflightResponse>>;
|
|
21
|
+
preview(request: WorktreeConsolePreviewRequest): Promise<WorktreeConsoleOutcome<WorktreeConsoleMutationResponse>>;
|
|
22
|
+
rollbackPreview(request: WorktreeConsoleRollbackPreviewRequest): Promise<WorktreeConsoleOutcome<WorktreeConsoleMutationResponse>>;
|
|
23
|
+
discard(request: WorktreeConsoleDiscardRequest): Promise<WorktreeConsoleOutcome<WorktreeConsoleMutationResponse>>;
|
|
24
|
+
finalize(request: WorktreeConsoleFinalizeRequest): Promise<WorktreeConsoleOutcome<WorktreeConsoleMutationResponse>>;
|
|
25
|
+
finalizePreview(request: WorktreeConsoleFinalizePreviewRequest): Promise<WorktreeConsoleOutcome<WorktreeConsoleMutationResponse>>;
|
|
26
|
+
setRetention(request: WorktreeConsoleSetRetentionRequest): Promise<WorktreeConsoleOutcome<WorktreeConsoleMutationResponse>>;
|
|
27
|
+
retryCleanup(request: WorktreeConsoleRetryCleanupRequest): Promise<WorktreeConsoleOutcome<WorktreeConsoleMutationResponse>>;
|
|
28
|
+
}
|
|
29
|
+
export declare function createWorktreeConsoleControlPlane(options: WorktreeConsoleControlPlaneOptions): WorktreeConsoleControlPlane;
|