dsh-git-worktree 0.1.2 → 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 -43
- package/README.zh.md +115 -41
- 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 -69
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptors.js","sourceRoot":"","sources":["../../src/console-remote/descriptors.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,aAAa,EACb,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,EACf,wBAAwB,EACxB,cAAc,EACd,cAAc,EACd,eAAe,GAChB,MAAM,cAAc,CAAA;AAErB,MAAM,OAAO,GAAG,kBAAkB,CAAA;AAClC,MAAM,OAAO,GAAG,aAAa,CAAA;AAC7B,MAAM,eAAe,GAAG,0CAA0C,CAAA;AAElE,MAAM,cAAc,GAAkC;IACpD,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,OAAO;IACf,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,eAAe,EAAE;CAChF,CAAA;AAED,SAAS,IAAI,CAAC,IAAY,EAAE,MAA0C,EAAE,UAAkB,EAAE,gBAAgB,GAAG,KAAK;IAClH,OAAO;QACL,IAAI;QACJ,IAAI,EAAE,IAAI;QACV,MAAM,EAAE,MAAM;QACd,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,IAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAChE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE;KAC9C,CAAA;AACH,CAAC;AAED,SAAS,UAAU,CACjB,MAAc,EACd,U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,EAAE,GAAG,OAAO,uEAAuE,CAAC;QAC3H,IAAI,CAAC,WAAW,EAAE,kBAAkB,EAAE,GAAG,OAAO,gEAAgE,CAAC;KAClH,EAAE,aAAa,CAAC,sBAAsB,CAAC,EAAE,yDAAyD,CAAC;IACpG,UAAU,CAAC,cAAc,EAAE;QACzB,IAAI,CAAC,YAAY,EAAE,gBAAgB,EAAE,GAAG,OAAO,iEAAiE,CAAC;QACjH,IAAI,CAAC,kBAAkB,EAAE,cAAc,EAAE,GAAG,OAAO,uEAAuE,CAAC;KAC5H,EAAE,aAAa,CAAC,sBAAsB,CAAC,EAAE,yDAAyD,CAAC;CACrG,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAA6B,MAAM,CAAC,MAAM,CAAC;IAC7E,OAAO,EAAE,OAAO;IAChB,WAAW,EAAE,4BAA4B;CAC1C,CAAC,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { RemoteResult, TypertRemoteNamespace } from '@deepseek-ai/dsh-typert-protocol';
|
|
2
|
+
import type { WorktreeConsoleCreateResponse, WorktreeConsoleCurrentResponse, WorktreeConsoleInspectResponse, WorktreeConsoleListResponse, WorktreeConsoleMutationResponse, WorktreeConsoleOutcome, WorktreeConsolePreflightResponse, WorktreeConsoleReviewDiffResponse } from '../console-contract.js';
|
|
3
|
+
import type { WorktreeRetentionMode } from '../types.js';
|
|
4
|
+
import { WORKTREE_CONSOLE_REMOTE } from './descriptors.js';
|
|
5
|
+
export type GitWorktreeRemote = TypertRemoteNamespace<'gitWorktree'>;
|
|
6
|
+
export default WORKTREE_CONSOLE_REMOTE;
|
|
7
|
+
export { WORKTREE_CONSOLE_DESCRIPTORS, WORKTREE_CONSOLE_REMOTE } from './descriptors.js';
|
|
8
|
+
declare module '@deepseek-ai/dsh-typert-protocol' {
|
|
9
|
+
interface TypertRemoteMap {
|
|
10
|
+
'gitWorktree/current': (agentId: string) => Promise<RemoteResult<WorktreeConsoleOutcome<WorktreeConsoleCurrentResponse>>>;
|
|
11
|
+
'gitWorktree/list': (agentId: string, needsAttention?: boolean, includeDelivered?: boolean) => Promise<RemoteResult<WorktreeConsoleOutcome<WorktreeConsoleListResponse>>>;
|
|
12
|
+
'gitWorktree/create': (agentId: string) => Promise<RemoteResult<WorktreeConsoleOutcome<WorktreeConsoleCreateResponse>>>;
|
|
13
|
+
'gitWorktree/inspect': (agentId: string, checkoutId: string) => Promise<RemoteResult<WorktreeConsoleOutcome<WorktreeConsoleInspectResponse>>>;
|
|
14
|
+
'gitWorktree/reviewDiff': (agentId: string, checkoutId: string, expectedRevision: number, expectedReviewId: string) => Promise<RemoteResult<WorktreeConsoleOutcome<WorktreeConsoleReviewDiffResponse>>>;
|
|
15
|
+
'gitWorktree/preflight': (agentId: string, checkoutId: string, expectedRevision: number, expectedReviewId: string) => Promise<RemoteResult<WorktreeConsoleOutcome<WorktreeConsolePreflightResponse>>>;
|
|
16
|
+
'gitWorktree/preview': (agentId: string, checkoutId: string, expectedRevision: number, expectedReviewId: string) => Promise<RemoteResult<WorktreeConsoleOutcome<WorktreeConsoleMutationResponse>>>;
|
|
17
|
+
'gitWorktree/rollbackPreview': (agentId: string, checkoutId: string, expectedRevision: number, resumeRevision?: boolean) => Promise<RemoteResult<WorktreeConsoleOutcome<WorktreeConsoleMutationResponse>>>;
|
|
18
|
+
'gitWorktree/discard': (agentId: string, checkoutId: string, expectedRevision: number, confirmDirty: boolean, rollbackPreview?: boolean) => Promise<RemoteResult<WorktreeConsoleOutcome<WorktreeConsoleMutationResponse>>>;
|
|
19
|
+
'gitWorktree/finalize': (agentId: string, checkoutId: string, expectedRevision: number, expectedReviewId: string, commitMessage: string, retention: WorktreeRetentionMode) => Promise<RemoteResult<WorktreeConsoleOutcome<WorktreeConsoleMutationResponse>>>;
|
|
20
|
+
'gitWorktree/finalizePreview': (agentId: string, checkoutId: string, expectedRevision: number, expectedReviewId: string, commitMessage: string, retention: WorktreeRetentionMode) => Promise<RemoteResult<WorktreeConsoleOutcome<WorktreeConsoleMutationResponse>>>;
|
|
21
|
+
'gitWorktree/setRetention': (agentId: string, checkoutId: string, expectedRevision: number, retention: Exclude<WorktreeRetentionMode, 'cleanup'>) => Promise<RemoteResult<WorktreeConsoleOutcome<WorktreeConsoleMutationResponse>>>;
|
|
22
|
+
'gitWorktree/retryCleanup': (agentId: string, checkoutId: string, expectedRevision: number) => Promise<RemoteResult<WorktreeConsoleOutcome<WorktreeConsoleMutationResponse>>>;
|
|
23
|
+
}
|
|
24
|
+
interface TypertRemoteNamespaceMap {
|
|
25
|
+
gitWorktree: TypertRemoteNamespace<'gitWorktree'>;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.js","sourceRoot":"","sources":["../../src/console-remote/remote.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAI1D,eAAe,uBAAuB,CAAA;AACtC,OAAO,EAAE,4BAA4B,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type WorktreeConsoleCreateResponse, type WorktreeConsoleCurrentResponse, type WorktreeConsoleInspectResponse, type WorktreeConsoleListResponse, type WorktreeConsoleMutationResponse, type WorktreeConsoleOutcome, type WorktreeConsolePreflightResponse, type WorktreeConsoleReviewDiffResponse } from '../console-contract.js';
|
|
3
|
+
export declare const sessionIdSchema: z.ZodString;
|
|
4
|
+
export declare const checkoutIdSchema: z.ZodString;
|
|
5
|
+
export declare const reviewIdSchema: z.ZodString;
|
|
6
|
+
export declare const commitMessageSchema: z.ZodString;
|
|
7
|
+
export declare const revisionSchema: z.ZodNumber;
|
|
8
|
+
export declare const oidSchema: z.ZodUnion<readonly [z.ZodLiteral<"unversioned">, z.ZodString]>;
|
|
9
|
+
export declare const booleanSchema: z.ZodBoolean;
|
|
10
|
+
export declare const optionalBooleanSchema: z.ZodUnion<readonly [z.ZodBoolean, z.ZodUndefined]>;
|
|
11
|
+
export declare const retentionSchema: z.ZodEnum<{
|
|
12
|
+
cleanup: "cleanup";
|
|
13
|
+
retain_24h: "retain_24h";
|
|
14
|
+
retain_3d: "retain_3d";
|
|
15
|
+
retain_manual: "retain_manual";
|
|
16
|
+
}>;
|
|
17
|
+
export declare const retainedModeSchema: z.ZodEnum<{
|
|
18
|
+
retain_24h: "retain_24h";
|
|
19
|
+
retain_3d: "retain_3d";
|
|
20
|
+
retain_manual: "retain_manual";
|
|
21
|
+
}>;
|
|
22
|
+
export declare function outcomeSchema<T>(value: z.ZodType<T>): z.ZodType<WorktreeConsoleOutcome<T>>;
|
|
23
|
+
export declare const currentResponseSchema: z.ZodType<WorktreeConsoleCurrentResponse>;
|
|
24
|
+
export declare const createResponseSchema: z.ZodType<WorktreeConsoleCreateResponse>;
|
|
25
|
+
export declare const inspectResponseSchema: z.ZodType<WorktreeConsoleInspectResponse>;
|
|
26
|
+
export declare const listResponseSchema: z.ZodType<WorktreeConsoleListResponse>;
|
|
27
|
+
export declare const mutationResponseSchema: z.ZodType<WorktreeConsoleMutationResponse>;
|
|
28
|
+
export declare const preflightResponseSchema: z.ZodType<WorktreeConsolePreflightResponse>;
|
|
29
|
+
export declare const reviewDiffResponseSchema: z.ZodType<WorktreeConsoleReviewDiffResponse>;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { WORKTREE_CONSOLE_ERROR_CODES, WORKTREE_CONSOLE_TARGET_STATES, } from '../console-contract.js';
|
|
3
|
+
const strict = (shape) => z.object(shape).strict();
|
|
4
|
+
export const sessionIdSchema = z.string().min(1);
|
|
5
|
+
export const checkoutIdSchema = z.string().min(1).refine(value => !value.includes('..') && !/[\\/\0]/u.test(value), 'unsafe checkout id');
|
|
6
|
+
export const reviewIdSchema = z.string().min(1);
|
|
7
|
+
export const commitMessageSchema = z.string().trim().min(1).max(500);
|
|
8
|
+
export const revisionSchema = z.number().int().nonnegative();
|
|
9
|
+
export const oidSchema = z.union([
|
|
10
|
+
z.literal('unversioned'),
|
|
11
|
+
z.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/iu),
|
|
12
|
+
]);
|
|
13
|
+
export const booleanSchema = z.boolean();
|
|
14
|
+
export const optionalBooleanSchema = z.union([booleanSchema, z.undefined()]);
|
|
15
|
+
export const retentionSchema = z.enum(['cleanup', 'retain_24h', 'retain_3d', 'retain_manual']);
|
|
16
|
+
export const retainedModeSchema = z.enum(['retain_24h', 'retain_3d', 'retain_manual']);
|
|
17
|
+
const projectSchema = strict({ id: z.string().min(1), name: z.string().min(1) });
|
|
18
|
+
const validationItemSchema = strict({
|
|
19
|
+
command: z.string(),
|
|
20
|
+
status: z.enum(['passed', 'failed', 'not_run']),
|
|
21
|
+
summary: z.string().optional(),
|
|
22
|
+
});
|
|
23
|
+
const reviewSchema = strict({
|
|
24
|
+
reviewId: reviewIdSchema,
|
|
25
|
+
revision: revisionSchema,
|
|
26
|
+
iteration: z.number().int().nonnegative(),
|
|
27
|
+
preparedAt: z.number().finite(),
|
|
28
|
+
summary: z.string(),
|
|
29
|
+
validationStatus: z.enum(['passed', 'failed', 'partial', 'not_run']),
|
|
30
|
+
validationSummary: z.string().optional(),
|
|
31
|
+
tests: z.array(validationItemSchema),
|
|
32
|
+
changedFiles: z.array(z.string()),
|
|
33
|
+
suggestedCommitMessage: z.string().min(1),
|
|
34
|
+
});
|
|
35
|
+
const capabilitiesSchema = strict({
|
|
36
|
+
create: z.boolean(),
|
|
37
|
+
open: z.boolean(),
|
|
38
|
+
inspect: z.boolean(),
|
|
39
|
+
discard: z.boolean(),
|
|
40
|
+
preflight: z.boolean(),
|
|
41
|
+
preview: z.boolean(),
|
|
42
|
+
rollbackPreview: z.boolean(),
|
|
43
|
+
finalize: z.boolean(),
|
|
44
|
+
finalizePreview: z.boolean(),
|
|
45
|
+
setRetention: z.boolean(),
|
|
46
|
+
retryCleanup: z.boolean(),
|
|
47
|
+
});
|
|
48
|
+
const targetSummarySchema = strict({
|
|
49
|
+
project: projectSchema,
|
|
50
|
+
checkoutId: checkoutIdSchema.nullable(),
|
|
51
|
+
sourceSessionId: sessionIdSchema,
|
|
52
|
+
ownerSessionId: sessionIdSchema,
|
|
53
|
+
targetSessionId: sessionIdSchema.nullable(),
|
|
54
|
+
iteration: z.number().int().nonnegative(),
|
|
55
|
+
revision: revisionSchema,
|
|
56
|
+
state: z.enum(WORKTREE_CONSOLE_TARGET_STATES),
|
|
57
|
+
phase: z.enum(['local', 'preparing', 'ready', 'applying', 'mutating', 'recovery_required', 'finalized', 'retained', 'discarded']),
|
|
58
|
+
dirty: z.boolean(),
|
|
59
|
+
currentOid: oidSchema,
|
|
60
|
+
commitOid: oidSchema.nullable(),
|
|
61
|
+
retention: retainedModeSchema.optional(),
|
|
62
|
+
retainedAt: z.number().finite().optional(),
|
|
63
|
+
expiresAt: z.number().finite().nullable().optional(),
|
|
64
|
+
cleanupMessage: z.string().optional(),
|
|
65
|
+
review: reviewSchema.optional(),
|
|
66
|
+
reviewSlot: z.enum(['available', 'waiting']).optional(),
|
|
67
|
+
reviewSlotOwnerSessionId: sessionIdSchema.optional(),
|
|
68
|
+
previewRecovery: strict({
|
|
69
|
+
reason: z.enum(['stale_local', 'preview_modified']),
|
|
70
|
+
attemptedAction: z.enum(['rollback_preview', 'finalize_preview', 'discard']),
|
|
71
|
+
}).optional(),
|
|
72
|
+
capabilities: capabilitiesSchema,
|
|
73
|
+
});
|
|
74
|
+
const targetDetailsSchema = targetSummarySchema.extend({
|
|
75
|
+
managedRoot: z.string().min(1).nullable(),
|
|
76
|
+
sourceOid: oidSchema,
|
|
77
|
+
currentBranch: z.string().nullable(),
|
|
78
|
+
}).strict();
|
|
79
|
+
const consoleErrorSchema = strict({
|
|
80
|
+
code: z.enum(WORKTREE_CONSOLE_ERROR_CODES),
|
|
81
|
+
message: z.string(),
|
|
82
|
+
details: z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.null()])).optional(),
|
|
83
|
+
});
|
|
84
|
+
export function outcomeSchema(value) {
|
|
85
|
+
return z.discriminatedUnion('ok', [
|
|
86
|
+
strict({ ok: z.literal(true), value }),
|
|
87
|
+
strict({ ok: z.literal(false), error: consoleErrorSchema }),
|
|
88
|
+
]);
|
|
89
|
+
}
|
|
90
|
+
export const currentResponseSchema = strict({ target: targetDetailsSchema });
|
|
91
|
+
export const createResponseSchema = strict({
|
|
92
|
+
target: targetDetailsSchema,
|
|
93
|
+
targetSessionId: sessionIdSchema,
|
|
94
|
+
managedRoot: z.string().min(1),
|
|
95
|
+
});
|
|
96
|
+
export const inspectResponseSchema = strict({ target: targetDetailsSchema });
|
|
97
|
+
export const listResponseSchema = strict({ project: projectSchema, worktrees: z.array(targetSummarySchema) });
|
|
98
|
+
export const mutationResponseSchema = strict({
|
|
99
|
+
target: targetSummarySchema,
|
|
100
|
+
changedFiles: z.array(z.string()).optional(),
|
|
101
|
+
commitOid: oidSchema.nullable().optional(),
|
|
102
|
+
});
|
|
103
|
+
const diffFileSchema = strict({
|
|
104
|
+
path: z.string(),
|
|
105
|
+
previousPath: z.string().optional(),
|
|
106
|
+
status: z.enum(['added', 'modified', 'deleted', 'renamed', 'binary']),
|
|
107
|
+
patch: z.string().nullable(),
|
|
108
|
+
truncated: z.boolean(),
|
|
109
|
+
});
|
|
110
|
+
const preflightFactsSchema = {
|
|
111
|
+
localModified: z.literal(false),
|
|
112
|
+
checkoutId: checkoutIdSchema,
|
|
113
|
+
reviewId: reviewIdSchema,
|
|
114
|
+
revision: revisionSchema,
|
|
115
|
+
configuredBaseOid: oidSchema,
|
|
116
|
+
effectiveBaseOid: oidSchema,
|
|
117
|
+
baseStrategy: z.enum(['recorded_base', 'isolated_contains_local_head', 'local_contains_isolated_head']),
|
|
118
|
+
localBranch: z.string().nullable(),
|
|
119
|
+
localHeadOid: oidSchema,
|
|
120
|
+
isolatedHeadOid: oidSchema,
|
|
121
|
+
changedFiles: z.array(z.string()),
|
|
122
|
+
};
|
|
123
|
+
const preflightSchema = z.union([
|
|
124
|
+
strict({ status: z.enum(['ready', 'local_advanced', 'already_in_local']), ...preflightFactsSchema }),
|
|
125
|
+
strict({ status: z.literal('conflict'), ...preflightFactsSchema, conflictingFiles: z.array(z.string()) }),
|
|
126
|
+
strict({
|
|
127
|
+
status: z.literal('blocked'),
|
|
128
|
+
localModified: z.literal(false),
|
|
129
|
+
checkoutId: z.string(),
|
|
130
|
+
reviewId: reviewIdSchema.nullable(),
|
|
131
|
+
revision: revisionSchema,
|
|
132
|
+
reason: z.enum(['not_owner', 'not_ready_for_review', 'stale_target', 'stale_isolated', 'project_acceptance_busy', 'checkout_unavailable', 'git_error']),
|
|
133
|
+
message: z.string(),
|
|
134
|
+
}),
|
|
135
|
+
]);
|
|
136
|
+
export const preflightResponseSchema = strict({ preflight: preflightSchema });
|
|
137
|
+
export const reviewDiffResponseSchema = strict({
|
|
138
|
+
reviewId: reviewIdSchema,
|
|
139
|
+
revision: revisionSchema,
|
|
140
|
+
files: z.array(diffFileSchema).max(200),
|
|
141
|
+
truncated: z.boolean(),
|
|
142
|
+
});
|
|
143
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/console-remote/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,GAS/B,MAAM,wBAAwB,CAAA;AAE/B,MAAM,MAAM,GAAG,CAAkC,KAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAA;AAEtF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AAChD,MAAM,CAAC,MAAM,gBAA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CAAC;QAC/B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;QACtB,QAAQ,EAAE,cAAc,CAAC,QAAQ,EAAE;QACnC,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,sBAAsB,EAAE,cAAc,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,WAAW,CAAC,CAAC;QACvJ,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;KACpB,CAAC;CACH,CAAC,CAAA;AACF,MAAM,CAAC,MAAM,uBAAuB,GAAgD,MAAM,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAA;AAE1H,MAAM,CAAC,MAAM,wBAAwB,GAAiD,MAAM,CAAC;IAC3F,QAAQ,EAAE,cAAc;IACxB,QAAQ,EAAE,cAAc;IACxB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IACvC,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE;CACvB,CAAC,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { WORKTREE_CONSOLE_DESCRIPTORS } from './descriptors.js';
|
|
2
|
+
/** Manual strict Host contribution discovered by the official Typert Loader through `./typert`. */
|
|
3
|
+
export const TYPERT = Object.freeze({
|
|
4
|
+
package: 'dsh-git-worktree',
|
|
5
|
+
face: 'host',
|
|
6
|
+
schemas: [],
|
|
7
|
+
model: {
|
|
8
|
+
services: [],
|
|
9
|
+
events: [],
|
|
10
|
+
objects: [],
|
|
11
|
+
},
|
|
12
|
+
invocations: WORKTREE_CONSOLE_DESCRIPTORS,
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=typert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typert.js","sourceRoot":"","sources":["../../src/console-remote/typert.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAA;AAE/D,mGAAmG;AACnG,MAAM,CAAC,MAAM,MAAM,GAAuB,MAAM,CAAC,MAAM,CAAC;IACtD,OAAO,EAAE,kBAAkB;IAC3B,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,EAAE;IACX,KAAK,EAAE;QACL,QAAQ,EAAE,EAAE;QACZ,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,EAAE;KACZ;IACD,WAAW,EAAE,4BAA4B;CAC1C,CAAC,CAAA"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dsh-git-worktree plugin entry. The session-checkout domain (state machine,
|
|
3
3
|
* apply engine, ports) is Domi-ported and host-agnostic; this file is the DSH
|
|
4
|
-
* plugin face: exports the domain error type and
|
|
5
|
-
*
|
|
6
|
-
* `/worktree`
|
|
4
|
+
* plugin face: exports the domain error type and module contract, builds the
|
|
5
|
+
* DSH adapters, mounts the state machine, and registers safe model tools,
|
|
6
|
+
* human `/worktree` acceptance commands, and Session Target runtime context.
|
|
7
7
|
* @module dsh-git-worktree
|
|
8
8
|
*/
|
|
9
9
|
import type { Context } from '@deepseek-ai/cordis';
|
|
@@ -29,6 +29,7 @@ export interface ManageManagedWorktreeInput {
|
|
|
29
29
|
action: 'cleanup_retained' | 'retry_cleanup' | 'set_retention' | 'discard';
|
|
30
30
|
retention?: Exclude<WorktreeRetentionMode, 'cleanup'>;
|
|
31
31
|
confirmDirty?: boolean;
|
|
32
|
+
rollbackPreview?: boolean;
|
|
32
33
|
}
|
|
33
34
|
export interface ListManagedWorktreesInput {
|
|
34
35
|
projectId?: string;
|
|
@@ -44,19 +45,33 @@ export interface MarkReadyForReviewInput {
|
|
|
44
45
|
tests: WorktreeValidationItem[];
|
|
45
46
|
suggestedCommitMessage: string;
|
|
46
47
|
}
|
|
48
|
+
/** Handoff data used by the client to create the authoritative isolated Workspace/Session. */
|
|
49
|
+
export interface IsolatedTargetLaunch {
|
|
50
|
+
targetSessionId: string;
|
|
51
|
+
managedRoot: string;
|
|
52
|
+
target: SessionTargetView;
|
|
53
|
+
}
|
|
47
54
|
/** Complete core interface the session-checkout module exposes to business callers. */
|
|
48
55
|
export interface SessionCheckoutModule {
|
|
49
56
|
inspect(sessionId: string): Promise<SessionTargetView>;
|
|
57
|
+
/** Synchronous registry snapshot for replay-stable model runtime context. */
|
|
58
|
+
runtimeContext(sessionId: string): string;
|
|
50
59
|
/** Read-only sync preflight; modifies no Local, worktree, registry, review state, or Git refs. */
|
|
51
60
|
preflight?(sessionId: string, expectedRevision: number): Promise<WorktreeApplyPreflightView>;
|
|
52
61
|
/** Cross-module mutation under the same exclusive lock as bind/apply/discard/cleanup. */
|
|
53
62
|
runExclusiveSessionMutation<T>(sessionId: string, operation: (target: SessionTargetView) => Promise<T>): Promise<T>;
|
|
54
63
|
bind(sessionId: string, choice: SessionTargetBindChoice): Promise<SessionTargetView>;
|
|
64
|
+
/** Reserve a distinct owner session and checkout without changing the source session cwd/identity. */
|
|
65
|
+
createIsolatedTarget(sourceSessionId: string, targetSessionId: string): Promise<IsolatedTargetLaunch>;
|
|
55
66
|
/** Lazily create the next isolated checkout when a delivered owner session needs code changes. */
|
|
56
67
|
beginNextIteration(sessionId: string): Promise<SessionTargetView>;
|
|
57
68
|
markReadyForReview(sessionId: string, input: MarkReadyForReviewInput): Promise<SessionTargetView>;
|
|
58
69
|
operate(input: SessionCheckoutOperation): Promise<SessionCheckoutOperationResult>;
|
|
59
70
|
listManagedWorktrees(input?: ListManagedWorktreesInput): Promise<ManagedWorktreeSummaryView[]>;
|
|
71
|
+
/** Caller-scoped list for model and human session surfaces. */
|
|
72
|
+
listManagedWorktreesForSession(sessionId: string, input?: Omit<ListManagedWorktreesInput, 'projectId'>): Promise<ManagedWorktreeSummaryView[]>;
|
|
73
|
+
/** Caller-scoped management; never treats persisted owner ids as authorization. */
|
|
74
|
+
manageManagedWorktreeForSession(sessionId: string, input: ManageManagedWorktreeInput): Promise<ManagedWorktreeSummaryView>;
|
|
60
75
|
/** Main-owned read-only cleanup inspection; writes no registry, refs, or directories. */
|
|
61
76
|
inspectManagedWorktreeCleanup(input?: ListManagedWorktreesInput): Promise<ManagedWorktreeSummaryView[]>;
|
|
62
77
|
bulkCleanupManagedWorktrees(candidates: BulkCleanupManagedWorktreeCandidate[]): Promise<BulkCleanupManagedWorktreesResult>;
|
|
@@ -66,11 +81,12 @@ export interface SessionCheckoutModule {
|
|
|
66
81
|
cleanupExpiredRetained(now?: number): Promise<string[]>;
|
|
67
82
|
reconcile(): Promise<SessionCheckoutReconcileSummary>;
|
|
68
83
|
}
|
|
84
|
+
export * from './console-contract.js';
|
|
69
85
|
export declare const inject: string[];
|
|
70
86
|
/**
|
|
71
|
-
* Mount the plugin: DSH adapters, the session-checkout module,
|
|
72
|
-
*
|
|
73
|
-
*
|
|
87
|
+
* Mount the plugin: DSH adapters, the session-checkout module, safe worktree
|
|
88
|
+
* tools, human acceptance command, dynamic target context, startup recovery,
|
|
89
|
+
* and the retention-expiry timer.
|
|
74
90
|
*/
|
|
75
91
|
export declare function apply(ctx: Context, config?: {
|
|
76
92
|
stateDir?: string;
|
package/lib/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dsh-git-worktree plugin entry. The session-checkout domain (state machine,
|
|
3
3
|
* apply engine, ports) is Domi-ported and host-agnostic; this file is the DSH
|
|
4
|
-
* plugin face: exports the domain error type and
|
|
5
|
-
*
|
|
6
|
-
* `/worktree`
|
|
4
|
+
* plugin face: exports the domain error type and module contract, builds the
|
|
5
|
+
* DSH adapters, mounts the state machine, and registers safe model tools,
|
|
6
|
+
* human `/worktree` acceptance commands, and Session Target runtime context.
|
|
7
7
|
* @module dsh-git-worktree
|
|
8
8
|
*/
|
|
9
9
|
/** Stable domain failure raised by the session-checkout state machine and its adapters. */
|
|
@@ -32,6 +32,11 @@ import { createSessionCheckoutApplyEngine } from './session-checkout-apply.js';
|
|
|
32
32
|
import { createSessionCheckoutModule } from './session-checkout-module.js';
|
|
33
33
|
import { registerTools } from './tools.js';
|
|
34
34
|
import { registerWorktreeCommand } from './commands.js';
|
|
35
|
+
import { registerSessionTargetContext } from './session-target-context.js';
|
|
36
|
+
import { createWorktreeConsoleControlPlane } from './console-host/control-plane.js';
|
|
37
|
+
import { createGitWorktreeReviewDiffReader } from './console-host/review-diff.js';
|
|
38
|
+
import { WorktreeConsoleService } from './console-host/service.js';
|
|
39
|
+
export * from './console-contract.js';
|
|
35
40
|
const name = 'git-worktree';
|
|
36
41
|
// Named export: the loader reads inject/apply named exports as plugin
|
|
37
42
|
// metadata. A bare function export mounts with no injection list, and the
|
|
@@ -54,26 +59,39 @@ function resolveStateDir(config) {
|
|
|
54
59
|
}
|
|
55
60
|
const RETENTION_MAINTENANCE_INTERVAL_MS = 15 * 60 * 1000;
|
|
56
61
|
/**
|
|
57
|
-
* Mount the plugin: DSH adapters, the session-checkout module,
|
|
58
|
-
*
|
|
59
|
-
*
|
|
62
|
+
* Mount the plugin: DSH adapters, the session-checkout module, safe worktree
|
|
63
|
+
* tools, human acceptance command, dynamic target context, startup recovery,
|
|
64
|
+
* and the retention-expiry timer.
|
|
60
65
|
*/
|
|
61
66
|
export function apply(ctx, config = {}) {
|
|
62
67
|
const stateDir = resolveStateDir(config);
|
|
63
68
|
mkdirSync(stateDir, { recursive: true });
|
|
64
69
|
const hooksPath = join(stateDir, 'disabled-git-hooks');
|
|
65
70
|
mkdirSync(hooksPath, { recursive: true });
|
|
71
|
+
const lookup = createDshLookupPort(ctx);
|
|
72
|
+
const git = createDshGitPort(ctx, { hooksPath });
|
|
73
|
+
const files = createNodeFilesPort();
|
|
74
|
+
const registry = new AtomicJsonCheckoutRegistry(join(stateDir, 'managed-checkouts.json'));
|
|
66
75
|
const module = createSessionCheckoutModule({
|
|
67
|
-
lookup
|
|
68
|
-
git
|
|
69
|
-
files
|
|
70
|
-
registry
|
|
76
|
+
lookup,
|
|
77
|
+
git,
|
|
78
|
+
files,
|
|
79
|
+
registry,
|
|
71
80
|
applyEngine: createSessionCheckoutApplyEngine(),
|
|
72
81
|
managedCheckoutsRoot: stateDir,
|
|
73
82
|
createCheckoutId: randomUUID,
|
|
74
83
|
});
|
|
84
|
+
new WorktreeConsoleService(ctx, createWorktreeConsoleControlPlane({
|
|
85
|
+
module,
|
|
86
|
+
lookup,
|
|
87
|
+
files,
|
|
88
|
+
registry,
|
|
89
|
+
git,
|
|
90
|
+
reviewDiff: createGitWorktreeReviewDiffReader(),
|
|
91
|
+
}));
|
|
75
92
|
registerTools(ctx, module);
|
|
76
93
|
registerWorktreeCommand(ctx, module);
|
|
94
|
+
registerSessionTargetContext(ctx, module);
|
|
77
95
|
// Startup recovery plus periodic expiry of retained worktrees. cordis's
|
|
78
96
|
// typed Events map omits the runtime 'ready' event; the events service's
|
|
79
97
|
// loose runtime signature covers it.
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAkBH,2FAA2F;AAC3F,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACpC,IAAI,CAA0B;IAEvC;;;OAGG;IACH,YAAY,IAA8B,EAAE,OAAe;QACzD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAA;QAClC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;CACF;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAkBH,2FAA2F;AAC3F,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACpC,IAAI,CAA0B;IAEvC;;;OAGG;IACH,YAAY,IAA8B,EAAE,OAAe;QACzD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,sBAA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A;IAEF,IAAI,sBAAsB,CAAC,GAAG,EAAE,iCAAiC,CAAC;QAChE,MAAM;QACN,MAAM;QACN,KAAK;QACL,QAAQ;QACR,GAAG;QACH,UAAU,EAAE,iCAAiC,EAAE;KAChD,CAAC,CAAC,CAAA;IAEH,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IAC1B,uBAAuB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IACpC,4BAA4B,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IAEzC,wEAAwE;IACxE,yEAAyE;IACzE,qCAAqC;IACrC,MAAM,gBAAgB,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;QACnD,KAAK,MAAM,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACtC,OAAO,CAAC,IAAI,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAA;QAC7D,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IACF,MAAM,cAAc,GAAG,WAAW,CAAC,GAAG,EAAE;QACtC,KAAK,MAAM,CAAC,sBAAsB,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACnD,OAAO,CAAC,IAAI,CAAC,0DAA0D,EAAE,KAAK,CAAC,CAAA;QACjF,CAAC,CAAC,CAAA;IACJ,CAAC,EAAE,iCAAiC,CAAC,CAAA;IACrC,cAAc,CAAC,KAAK,EAAE,EAAE,CAAA;IACxB,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE;QACpB,gBAAgB,EAAE,CAAA;QAClB,aAAa,CAAC,cAAc,CAAC,CAAA;IAC/B,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
export declare function sanitizeManagedWorktreeLabel(
|
|
1
|
+
/** Convert a canonical repository basename into one safe, readable path segment. */
|
|
2
|
+
export declare function sanitizeManagedWorktreeLabel(rawName: string | undefined): string;
|
|
3
|
+
/** Stable fallback partition that distinguishes repositories sharing one basename. */
|
|
4
|
+
export declare function createManagedWorktreeRepositoryKey(canonicalGitRoot: string): string;
|
|
5
|
+
/** Physical basename: repository identity + trusted checkout identity only. */
|
|
3
6
|
export declare function createManagedWorktreeDirectoryName(input: {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
iteration?: number;
|
|
7
|
+
repositoryName: string;
|
|
8
|
+
checkoutId: string;
|
|
9
|
+
identityLength?: number;
|
|
8
10
|
}): string;
|
|
9
11
|
export interface ManagedWorktreePathCandidates {
|
|
10
12
|
siblingContainer: string;
|
|
11
13
|
siblingRoot: string;
|
|
14
|
+
fallbackContainer: string;
|
|
12
15
|
fallbackRoot: string;
|
|
13
16
|
}
|
|
14
17
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
+
* Generate one collision-length candidate without touching the filesystem.
|
|
19
|
+
* The caller probes 8/12/full checkout identities and chooses the first path
|
|
20
|
+
* that does not already exist.
|
|
18
21
|
*/
|
|
19
22
|
export declare function createManagedWorktreePathCandidates(input: {
|
|
20
23
|
localGitRoot: string;
|
|
21
24
|
managedCheckoutsRoot: string;
|
|
22
25
|
repositoryKey: string;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
checkoutId?: string;
|
|
26
|
-
iteration?: number;
|
|
26
|
+
checkoutId: string;
|
|
27
|
+
identityLength?: number;
|
|
27
28
|
}): ManagedWorktreePathCandidates;
|
|
@@ -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,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACvD,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,4BAA4B,CAAC,OAA2B;IACtE,IAAI,OAAO,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;SAC1B,IAAI,EAAE;SACN,SAAS,CAAC,KAAK,CAAC;SAChB,OAAO,CAAC,0BAA0B,EAAE,GAAG,CAAC;SACxC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC;SAC7B,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAA;IAEpC,OAAO,GAAG,kBAAkB,CAAC,OAAO,E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