dsh-git-worktree 0.1.2 → 0.3.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 +93 -0
- package/LICENSE +21 -21
- package/README.md +187 -43
- package/README.zh.md +187 -41
- package/cordis.patch.yml +7 -7
- package/lib/adapters/lookup.d.ts +4 -2
- package/lib/adapters/lookup.js +31 -3
- package/lib/adapters/lookup.js.map +1 -1
- package/lib/adapters/registry.js +41 -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 +61 -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 +234 -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 +125 -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 +6902 -0
- package/lib/commands.d.ts +2 -4
- package/lib/commands.js +69 -28
- package/lib/commands.js.map +1 -1
- package/lib/console-contract.d.ts +253 -0
- package/lib/console-contract.js +86 -0
- package/lib/console-contract.js.map +1 -0
- package/lib/console-host/control-plane.d.ts +31 -0
- package/lib/console-host/control-plane.js +502 -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 +136 -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 +26 -0
- package/lib/console-host/service.js +143 -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 +105 -0
- package/lib/console-remote/descriptors.js.map +1 -0
- package/lib/console-remote/remote.d.ts +29 -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 +145 -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 +26 -8
- 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 +39 -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 +1098 -36
- 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 +6 -6
- package/lib/tools.js +107 -218
- 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 -69
- package/scripts/check-publish.mjs +193 -0
- package/scripts/clean-lib.mjs +7 -0
- package/scripts/dev-dsh-lib.mjs +509 -0
- package/scripts/dev-dsh.mjs +95 -0
- package/scripts/dsh-source-runner.mjs +14 -0
|
@@ -1,18 +1,17 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
1
2
|
import { basename, dirname, join } from 'node:path';
|
|
2
|
-
const DEFAULT_SESSION_TITLES = new Set(['新 Agent 会话', '新会话']);
|
|
3
3
|
const WINDOWS_INVALID_CHARACTERS = /[<>:"/\\|?*\u0000-\u001f]/g;
|
|
4
4
|
const WINDOWS_RESERVED_NAME = /^(?:CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i;
|
|
5
|
-
const DISPLAY_SUFFIX = /\s*\((?:worktree|fork)\)\s*$/i;
|
|
6
5
|
const REPEATED_DASHES = /-{2,}/g;
|
|
7
6
|
const MAX_LABEL_LENGTH = 40;
|
|
7
|
+
const DEFAULT_IDENTITY_LENGTH = 8;
|
|
8
8
|
function truncateCodePoints(value, maxLength) {
|
|
9
9
|
return Array.from(value).slice(0, maxLength).join('');
|
|
10
10
|
}
|
|
11
|
-
/**
|
|
12
|
-
export function sanitizeManagedWorktreeLabel(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
let cleaned = source
|
|
11
|
+
/** Convert a canonical repository basename into one safe, readable path segment. */
|
|
12
|
+
export function sanitizeManagedWorktreeLabel(rawName) {
|
|
13
|
+
let cleaned = (rawName ?? '')
|
|
14
|
+
.trim()
|
|
16
15
|
.normalize('NFC')
|
|
17
16
|
.replace(WINDOWS_INVALID_CHARACTERS, '-')
|
|
18
17
|
.replace(/\s+/g, '-')
|
|
@@ -21,33 +20,44 @@ export function sanitizeManagedWorktreeLabel(rawTitle) {
|
|
|
21
20
|
cleaned = truncateCodePoints(cleaned, MAX_LABEL_LENGTH)
|
|
22
21
|
.replace(/[.\s-]+$/g, '');
|
|
23
22
|
if (!cleaned)
|
|
24
|
-
return '
|
|
23
|
+
return 'repository';
|
|
25
24
|
return WINDOWS_RESERVED_NAME.test(cleaned) ? `_${cleaned}` : cleaned;
|
|
26
25
|
}
|
|
27
|
-
function
|
|
28
|
-
|
|
26
|
+
function checkoutIdentity(value, length) {
|
|
27
|
+
const normalized = value.replace(/[^a-zA-Z0-9]/g, '').toLowerCase();
|
|
28
|
+
if (!normalized)
|
|
29
|
+
return 'checkout';
|
|
30
|
+
return normalized.slice(0, Math.max(DEFAULT_IDENTITY_LENGTH, length));
|
|
29
31
|
}
|
|
32
|
+
/** Stable fallback partition that distinguishes repositories sharing one basename. */
|
|
33
|
+
export function createManagedWorktreeRepositoryKey(canonicalGitRoot) {
|
|
34
|
+
return createHash('sha256').update(canonicalGitRoot).digest('hex').slice(0, 12);
|
|
35
|
+
}
|
|
36
|
+
/** Physical basename: repository identity + trusted checkout identity only. */
|
|
30
37
|
export function createManagedWorktreeDirectoryName(input) {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
const checkoutIdentity = shortIdentity(input.checkoutId, 'checkout');
|
|
36
|
-
return `${sanitizeManagedWorktreeLabel(input.sessionTitle)}--${sessionIdentity}--i${input.iteration}--${checkoutIdentity}`;
|
|
38
|
+
const repositoryLabel = sanitizeManagedWorktreeLabel(input.repositoryName);
|
|
39
|
+
const identity = checkoutIdentity(input.checkoutId, input.identityLength ?? DEFAULT_IDENTITY_LENGTH);
|
|
40
|
+
return `${repositoryLabel}--${identity}--worktree`;
|
|
37
41
|
}
|
|
38
42
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
43
|
+
* Generate one collision-length candidate without touching the filesystem.
|
|
44
|
+
* The caller probes 8/12/full checkout identities and chooses the first path
|
|
45
|
+
* that does not already exist.
|
|
42
46
|
*/
|
|
43
47
|
export function createManagedWorktreePathCandidates(input) {
|
|
44
48
|
const repositoryLabel = sanitizeManagedWorktreeLabel(basename(input.localGitRoot));
|
|
45
|
-
const directoryName = createManagedWorktreeDirectoryName(
|
|
46
|
-
|
|
49
|
+
const directoryName = createManagedWorktreeDirectoryName({
|
|
50
|
+
repositoryName: repositoryLabel,
|
|
51
|
+
checkoutId: input.checkoutId,
|
|
52
|
+
...(input.identityLength === undefined ? {} : { identityLength: input.identityLength }),
|
|
53
|
+
});
|
|
54
|
+
const siblingContainer = join(dirname(input.localGitRoot), `${repositoryLabel}--worktrees`);
|
|
55
|
+
const fallbackContainer = join(input.managedCheckoutsRoot, 'worktrees', input.repositoryKey);
|
|
47
56
|
return {
|
|
48
57
|
siblingContainer,
|
|
49
58
|
siblingRoot: join(siblingContainer, directoryName),
|
|
50
|
-
|
|
59
|
+
fallbackContainer,
|
|
60
|
+
fallbackRoot: join(fallbackContainer, directoryName),
|
|
51
61
|
};
|
|
52
62
|
}
|
|
53
63
|
//# sourceMappingURL=managed-worktree-path.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"managed-worktree-path.js","sourceRoot":"","sources":["../src/managed-worktree-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"managed-worktree-path.js","sourceRoot":"","sources":["../src/managed-worktree-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEnD,MAAM,0BAA0B,GAAG,4BAA4B,CAAA;AAC/D,MAAM,qBAAqB,GAAG,0CAA0C,CAAA;AACxE,MAAM,eAAe,GAAG,QAAQ,CAAA;AAChC,MAAM,gBAAgB,GAAG,EAAE,CAAA;AAC3B,MAAM,uBAAuB,GAAG,CAAC,CAAA;AAEjC,SAAS,kBAAkB,CAAC,KAAa,EAAE,SAAiB;IAC1D,OAAO,KAAK,CAAC,IAAI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
88
88
|
}
|
|
89
89
|
export interface ManagedCheckoutMutationJournal extends ManagedCheckoutJournalBase {
|
|
90
|
-
operation: 'apply' | 'finish' | 'cleanup';
|
|
90
|
+
operation: 'apply' | 'preview' | 'rollback_preview' | 'finish' | 'finalize_preview' | 'cleanup';
|
|
91
91
|
step: 'planning' | 'artifacts_retained' | 'writing_local' | 'updating_ref' | 'replacing_index' | 'removing_worktree';
|
|
92
92
|
baseOid?: string;
|
|
93
93
|
planRevision?: string;
|
|
94
|
+
previewId?: string;
|
|
94
95
|
reviewId?: string;
|
|
95
96
|
localFingerprint?: string;
|
|
96
97
|
isolatedFingerprint?: string;
|
|
@@ -100,6 +101,8 @@ export interface ManagedCheckoutMutationJournal extends ManagedCheckoutJournalBa
|
|
|
100
101
|
isolatedHeadOid?: string;
|
|
101
102
|
commitOid?: string;
|
|
102
103
|
retention?: WorktreeRetentionMode;
|
|
104
|
+
/** rollback_preview crash recovery must preserve whether the review returns to working or ready_for_review. */
|
|
105
|
+
resumeRevision?: boolean;
|
|
103
106
|
changedFiles?: string[];
|
|
104
107
|
managedDirectoryIdentity?: DirectoryIdentity;
|
|
105
108
|
cleanupQuarantinePath?: string;
|
|
@@ -119,6 +122,26 @@ export interface ManagedWorktreeReviewRecord {
|
|
|
119
122
|
isolatedFingerprint: string;
|
|
120
123
|
isolatedHeadOid: string;
|
|
121
124
|
}
|
|
125
|
+
export interface ManagedPreviewReceipt {
|
|
126
|
+
previewId: string;
|
|
127
|
+
reviewId: string;
|
|
128
|
+
iteration: number;
|
|
129
|
+
previewedAt: number;
|
|
130
|
+
configuredBaseOid: string;
|
|
131
|
+
effectiveBaseOid: string;
|
|
132
|
+
baseStrategy: ApplyBaseStrategy;
|
|
133
|
+
localHeadOid: string;
|
|
134
|
+
localHeadRef: string | null;
|
|
135
|
+
localFingerprintBefore: string;
|
|
136
|
+
localFingerprintPreview: string;
|
|
137
|
+
localWorkingTreeOid: string;
|
|
138
|
+
localIndexTreeOid: string;
|
|
139
|
+
previewWorkingTreeOid: string;
|
|
140
|
+
isolatedHeadOid: string;
|
|
141
|
+
isolatedFingerprint: string;
|
|
142
|
+
isolatedSnapshotOid: string;
|
|
143
|
+
changedFiles: string[];
|
|
144
|
+
}
|
|
122
145
|
export interface ManagedDeliveryProof {
|
|
123
146
|
localBranch: string | null;
|
|
124
147
|
localHeadBefore: string;
|
|
@@ -131,6 +154,17 @@ export type ManagedCheckoutDelivery = {
|
|
|
131
154
|
} | {
|
|
132
155
|
state: 'ready_for_review';
|
|
133
156
|
review: ManagedWorktreeReviewRecord;
|
|
157
|
+
} | {
|
|
158
|
+
state: 'preview_active';
|
|
159
|
+
review: ManagedWorktreeReviewRecord;
|
|
160
|
+
preview: ManagedPreviewReceipt;
|
|
161
|
+
} | {
|
|
162
|
+
state: 'preview_detached';
|
|
163
|
+
review: ManagedWorktreeReviewRecord;
|
|
164
|
+
preview: ManagedPreviewReceipt;
|
|
165
|
+
detachedAt: number;
|
|
166
|
+
reason: 'stale_local' | 'preview_modified';
|
|
167
|
+
attemptedAction: 'rollback_preview' | 'finalize_preview' | 'discard';
|
|
134
168
|
} | {
|
|
135
169
|
state: 'finalized';
|
|
136
170
|
review: ManagedWorktreeReviewRecord;
|
|
@@ -162,9 +196,13 @@ export type ManagedCheckoutDelivery = {
|
|
|
162
196
|
};
|
|
163
197
|
export interface ManagedCheckoutRecord {
|
|
164
198
|
checkoutId: string;
|
|
199
|
+
/** Prior delivered checkout whose immutable Harness cwd path this iteration safely reuses. */
|
|
200
|
+
predecessorCheckoutId?: string;
|
|
165
201
|
projectId: string;
|
|
166
202
|
projectName: string;
|
|
167
203
|
ownerSessionId: string;
|
|
204
|
+
/** Local session that created this target; historical records may omit it. */
|
|
205
|
+
sourceSessionId?: string;
|
|
168
206
|
/** Canonical root of the project in the user's Local Checkout. */
|
|
169
207
|
localRoot: string;
|
|
170
208
|
/** Canonical root of the project in the managed worktree; also the lease cwd. */
|
|
@@ -64,6 +64,37 @@ export interface FinishSuccessResult {
|
|
|
64
64
|
nextBaseOid: string;
|
|
65
65
|
}
|
|
66
66
|
export type FinishResult = FinishSuccessResult | ApplyErrorResult;
|
|
67
|
+
export interface PreviewReceipt {
|
|
68
|
+
previewId: string;
|
|
69
|
+
reviewId: string;
|
|
70
|
+
iteration: number;
|
|
71
|
+
previewedAt: number;
|
|
72
|
+
configuredBaseOid: string;
|
|
73
|
+
effectiveBaseOid: string;
|
|
74
|
+
baseStrategy: ApplyBaseStrategy;
|
|
75
|
+
localHeadOid: string;
|
|
76
|
+
localHeadRef: string | null;
|
|
77
|
+
localFingerprintBefore: string;
|
|
78
|
+
localFingerprintPreview: string;
|
|
79
|
+
localWorkingTreeOid: string;
|
|
80
|
+
localIndexTreeOid: string;
|
|
81
|
+
previewWorkingTreeOid: string;
|
|
82
|
+
isolatedHeadOid: string;
|
|
83
|
+
isolatedFingerprint: string;
|
|
84
|
+
isolatedSnapshotOid: string;
|
|
85
|
+
changedFiles: string[];
|
|
86
|
+
}
|
|
87
|
+
export interface PreviewSuccessResult {
|
|
88
|
+
status: 'previewed';
|
|
89
|
+
receipt: PreviewReceipt;
|
|
90
|
+
changedFiles: string[];
|
|
91
|
+
}
|
|
92
|
+
export type PreviewResult = PreviewSuccessResult | ApplyErrorResult;
|
|
93
|
+
export interface RollbackSuccessResult {
|
|
94
|
+
status: 'preview_rolled_back';
|
|
95
|
+
changedFiles: string[];
|
|
96
|
+
}
|
|
97
|
+
export type RollbackResult = RollbackSuccessResult | ApplyErrorResult;
|
|
67
98
|
export interface InvalidInputApplyError {
|
|
68
99
|
code: 'invalid_input';
|
|
69
100
|
message: string;
|
|
@@ -92,7 +123,11 @@ export interface OperationNotAllowedApplyError {
|
|
|
92
123
|
code: 'operation_not_allowed';
|
|
93
124
|
message: string;
|
|
94
125
|
}
|
|
95
|
-
export
|
|
126
|
+
export interface PreviewModifiedApplyError {
|
|
127
|
+
code: 'preview_modified';
|
|
128
|
+
message: string;
|
|
129
|
+
}
|
|
130
|
+
export type ApplyError = InvalidInputApplyError | InvalidPlanApplyError | StaleLocalApplyError | StaleIsolatedApplyError | GitApplyError | CommitIsolationApplyError | OperationNotAllowedApplyError | PreviewModifiedApplyError;
|
|
96
131
|
export interface SessionCheckoutApplyEngine {
|
|
97
132
|
inspectReview(input: ApplyPlanInput): Promise<InspectReviewResult>;
|
|
98
133
|
/** 复用真实 Apply merge 计算,但不持久化可执行 plan,也不修改任一 checkout。 */
|
|
@@ -102,6 +137,24 @@ export interface SessionCheckoutApplyEngine {
|
|
|
102
137
|
finish(plan: ApplyPlan, options: {
|
|
103
138
|
commitMessage: string;
|
|
104
139
|
}): Promise<FinishResult>;
|
|
140
|
+
preview(plan: ApplyPlan, options: {
|
|
141
|
+
previewId: string;
|
|
142
|
+
reviewId: string;
|
|
143
|
+
iteration: number;
|
|
144
|
+
/** Local 写入前持久化 receipt artifacts/journal;失败时不得触碰 Local。 */
|
|
145
|
+
beforeWrite?(receipt: PreviewReceipt): Promise<void>;
|
|
146
|
+
}): Promise<PreviewResult>;
|
|
147
|
+
rollback(input: {
|
|
148
|
+
localPath: string;
|
|
149
|
+
receipt: PreviewReceipt;
|
|
150
|
+
}): Promise<RollbackResult>;
|
|
151
|
+
finalize(input: {
|
|
152
|
+
localPath: string;
|
|
153
|
+
receipt: PreviewReceipt;
|
|
154
|
+
commitMessage: string;
|
|
155
|
+
/** Commit object 已创建但 branch ref 尚未更新时持久化恢复信息。 */
|
|
156
|
+
beforeCommit?(commitOid: string): Promise<void>;
|
|
157
|
+
}): Promise<FinishResult>;
|
|
105
158
|
}
|
|
106
159
|
export interface SessionCheckoutApplyEngineOptions {
|
|
107
160
|
/** 测试/宿主 seam:在最后一次 Local fingerprint 校验前执行。 */
|