@xbzbing/dsh-git-panel 0.1.0 → 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/README.md +7 -5
- package/README_EN.md +7 -5
- package/cordis.patch.yml +1 -1
- package/lib/client.js +37 -27
- package/lib/host/actions.d.ts +2 -3
- package/lib/host/core.d.ts +20 -1
- package/lib/host/git.d.ts +2 -0
- package/lib/host/index.js +319 -139
- package/lib/host/parser.d.ts +8 -1
- package/lib/host/types.d.ts +24 -4
- package/lib/host/validate.d.ts +10 -0
- package/lib/host/version.d.ts +6 -4
- package/package.json +4 -3
package/lib/host/actions.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SnapshotDeps, GitPanelConfig } from './core.ts';
|
|
2
|
+
import { isSafePath } from './validate.ts';
|
|
2
3
|
import type { GitAction, GitActionRequest, GitActionResult, GitErrorCode } from './types.ts';
|
|
3
|
-
|
|
4
|
-
export declare function isSafePath(path: string): boolean;
|
|
4
|
+
export { isSafePath };
|
|
5
5
|
interface CommandPlan {
|
|
6
6
|
readonly argv: readonly (readonly string[])[];
|
|
7
7
|
}
|
|
@@ -13,4 +13,3 @@ type PlanResult = CommandPlan | {
|
|
|
13
13
|
export declare function planAction(action: GitAction, unborn: boolean): PlanResult;
|
|
14
14
|
/** Execute a management action, returning the fresh snapshot on success. */
|
|
15
15
|
export declare function runAction(deps: SnapshotDeps, config: GitPanelConfig, request: GitActionRequest): Promise<GitActionResult>;
|
|
16
|
-
export {};
|
package/lib/host/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GitRunner } from './git.ts';
|
|
2
|
-
import type { GitChange, GitSnapshotResult } from './types.ts';
|
|
2
|
+
import type { GitChange, GitErrorCode, GitSnapshotResult } from './types.ts';
|
|
3
3
|
export interface GitPanelConfig {
|
|
4
4
|
readonly timeoutMs: number;
|
|
5
5
|
/** Per-command stdout cap; also the per-side image-diff payload cap. */
|
|
@@ -45,6 +45,13 @@ export interface SnapshotDeps {
|
|
|
45
45
|
* distinct cwd (a session's cwd is effectively stable).
|
|
46
46
|
*/
|
|
47
47
|
readonly rootCache?: Map<string, string>;
|
|
48
|
+
/**
|
|
49
|
+
* Optional negative cache (cwd → expiry epoch ms) for non-repo cwds, so a
|
|
50
|
+
* session whose directory is not a git repo does not spawn `rev-parse` on
|
|
51
|
+
* every 30s poll. Short-lived (see NEG_CACHE_MS) so a repo created under the
|
|
52
|
+
* cwd is picked up soon after.
|
|
53
|
+
*/
|
|
54
|
+
readonly rootNegCache?: Map<string, number>;
|
|
48
55
|
}
|
|
49
56
|
export type WorkspaceResolution = {
|
|
50
57
|
readonly ok: true;
|
|
@@ -63,6 +70,18 @@ export declare function runCommand(runner: GitRunner, argv: readonly string[], c
|
|
|
63
70
|
} | {
|
|
64
71
|
failure: unknown;
|
|
65
72
|
}>;
|
|
73
|
+
/**
|
|
74
|
+
* Collapse a workspace-resolution failure into the `{ code, message }` shape
|
|
75
|
+
* the run/query endpoints return. `GitFailure` already carries only endpoint
|
|
76
|
+
* codes, so no membership test is needed (the previous per-endpoint ternary
|
|
77
|
+
* that re-listed every code was always true — dead). `detail` becomes message.
|
|
78
|
+
*/
|
|
79
|
+
export declare function mapWorkspaceFailure(failure: GitSnapshotResult & {
|
|
80
|
+
ok: false;
|
|
81
|
+
}): {
|
|
82
|
+
code: GitErrorCode;
|
|
83
|
+
message?: string;
|
|
84
|
+
};
|
|
66
85
|
/** Produce a full snapshot for a session. */
|
|
67
86
|
export declare function snapshotForSession(deps: SnapshotDeps, config: GitPanelConfig, sessionId: string): Promise<GitSnapshotResult>;
|
|
68
87
|
/** Max mtime among changed files (epoch ms), capped for large sets. */
|
package/lib/host/git.d.ts
CHANGED
|
@@ -45,6 +45,8 @@ export interface GitRunResult {
|
|
|
45
45
|
readonly stdout: string;
|
|
46
46
|
readonly stderr: string;
|
|
47
47
|
readonly timedOut: boolean;
|
|
48
|
+
/** The caller's own signal aborted the run (navigation/reset), not our timeout. */
|
|
49
|
+
readonly cancelled: boolean;
|
|
48
50
|
readonly stdoutLossy: boolean;
|
|
49
51
|
}
|
|
50
52
|
export interface GitRunner {
|