@acryldev/workspace 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +61 -2
- package/cordis.patch.yml +3 -0
- package/lib/agents/argument-text.d.ts +9 -0
- package/lib/agents/catalog.d.ts +32 -0
- package/lib/agents/contract.d.ts +50 -0
- package/lib/agents/definition.d.ts +38 -0
- package/lib/agents/file-store.d.ts +7 -0
- package/lib/agents/known-agents.d.ts +52 -0
- package/lib/agents/launch.d.ts +26 -0
- package/lib/agents/preferences.d.ts +40 -0
- package/lib/agents/route.d.ts +10 -0
- package/lib/agents/settings.d.ts +28 -0
- package/lib/agents/status/agent-status.d.ts +38 -0
- package/lib/agents/status/claude-hooks.d.ts +18 -0
- package/lib/agents/status/route.d.ts +10 -0
- package/lib/capabilities/contract.d.ts +17 -0
- package/lib/capabilities/route.d.ts +8 -0
- package/lib/client.js +91109 -0
- package/lib/client.js.map +1 -0
- package/lib/files/contract.d.ts +74 -0
- package/lib/files/route.d.ts +9 -0
- package/lib/files/service.d.ts +48 -0
- package/lib/folder-picker/contract.d.ts +9 -0
- package/lib/folder-picker/picker.d.ts +23 -0
- package/lib/folder-picker/route.d.ts +5 -0
- package/lib/git/changes.d.ts +29 -0
- package/lib/git/checks.d.ts +8 -0
- package/lib/git/commits.d.ts +14 -0
- package/lib/git/contract.d.ts +136 -0
- package/lib/git/errors.d.ts +9 -0
- package/lib/git/guards.d.ts +9 -0
- package/lib/git/ignored.d.ts +9 -0
- package/lib/git/parsing.d.ts +13 -0
- package/lib/git/route.d.ts +9 -0
- package/lib/git/runner.d.ts +29 -0
- package/lib/git/search.d.ts +14 -0
- package/lib/git/service.d.ts +52 -0
- package/lib/git/worktrees.d.ts +26 -0
- package/lib/index.d.ts +39 -0
- package/lib/index.js +3799 -0
- package/lib/index.js.map +1 -0
- package/lib/private-route.d.ts +15 -0
- package/lib/projects/contract.d.ts +82 -0
- package/lib/projects/registry.d.ts +73 -0
- package/lib/projects/route.d.ts +16 -0
- package/lib/projects/tools.d.ts +24 -0
- package/lib/pty/contract.d.ts +52 -0
- package/lib/pty/node-pty-spawn.d.ts +3 -0
- package/lib/pty/route.d.ts +9 -0
- package/lib/pty/screen-model.d.ts +25 -0
- package/lib/pty/scrollback.d.ts +26 -0
- package/lib/pty/service.d.ts +156 -0
- package/lib/pty/stream.d.ts +19 -0
- package/lib/shared-context/chat.d.ts +34 -0
- package/lib/shared-context/launch.d.ts +24 -0
- package/lib/shared-context/render.d.ts +29 -0
- package/lib/shared-context/route.d.ts +13 -0
- package/lib/shared-context/service.d.ts +65 -0
- package/lib/shared-context/tool.d.ts +20 -0
- package/lib/types/agents/argument-text.d.ts +9 -0
- package/lib/types/agents/contract.d.ts +50 -0
- package/lib/types/agents/definition.d.ts +38 -0
- package/lib/types/agents/known-agents.d.ts +52 -0
- package/lib/types/agents/launch.d.ts +26 -0
- package/lib/types/agents/preferences.d.ts +40 -0
- package/lib/types/agents/status/agent-status.d.ts +38 -0
- package/lib/types/capabilities/contract.d.ts +17 -0
- package/lib/types/client/agents/AddAgentForm.d.ts +10 -0
- package/lib/types/client/agents/AgentRow.d.ts +11 -0
- package/lib/types/client/agents/AgentsSection.d.ts +14 -0
- package/lib/types/client/agents/acryl-logo-data.d.ts +3 -0
- package/lib/types/client/agents/agent-draft.d.ts +24 -0
- package/lib/types/client/agents/agents-api.d.ts +18 -0
- package/lib/types/client/agents/agents-section-model.d.ts +45 -0
- package/lib/types/client/agents/agents-settings-plugin.d.ts +8 -0
- package/lib/types/client/agents/agents-state.d.ts +26 -0
- package/lib/types/client/agents/controls.d.ts +40 -0
- package/lib/types/client/board/NoteColumn.d.ts +17 -0
- package/lib/types/client/board/SessionBoardPane.d.ts +16 -0
- package/lib/types/client/board/board-model.d.ts +36 -0
- package/lib/types/client/browser/BrowserPane.d.ts +28 -0
- package/lib/types/client/canvas/SplitDivider.d.ts +9 -0
- package/lib/types/client/canvas/WorkspaceCanvas.d.ts +78 -0
- package/lib/types/client/canvas/groups.d.ts +47 -0
- package/lib/types/client/canvas/persist.d.ts +17 -0
- package/lib/types/client/canvas/persistence.d.ts +78 -0
- package/lib/types/client/canvas/shell-requests.d.ts +16 -0
- package/lib/types/client/canvas/split-ratio.d.ts +12 -0
- package/lib/types/client/canvas/state.d.ts +181 -0
- package/lib/types/client/canvas/tab-title.d.ts +7 -0
- package/lib/types/client/capabilities/capabilities-api.d.ts +8 -0
- package/lib/types/client/changes/ChangesBody.d.ts +14 -0
- package/lib/types/client/changes/changes-tab.d.ts +20 -0
- package/lib/types/client/chat/chat-selection.d.ts +70 -0
- package/lib/types/client/chat/composer-focus.d.ts +16 -0
- package/lib/types/client/checks/ChecksBody.d.ts +9 -0
- package/lib/types/client/checks/checks-tab.d.ts +12 -0
- package/lib/types/client/chrome/StatusLine.d.ts +11 -0
- package/lib/types/client/chrome/panel-icons.d.ts +16 -0
- package/lib/types/client/chrome/status-line.d.ts +19 -0
- package/lib/types/client/chrome/worktree-agents.d.ts +13 -0
- package/lib/types/client/comments/CommentsBody.d.ts +24 -0
- package/lib/types/client/comments/comment-store.d.ts +38 -0
- package/lib/types/client/comments/comments-tab.d.ts +14 -0
- package/lib/types/client/comments/editor-comments.d.ts +6 -0
- package/lib/types/client/comments/terminal-targets.d.ts +35 -0
- package/lib/types/client/comments/use-comments.d.ts +27 -0
- package/lib/types/client/connection/session-banner.d.ts +51 -0
- package/lib/types/client/diff/GitDiffPane.d.ts +27 -0
- package/lib/types/client/diff/TextDiffPane.d.ts +6 -0
- package/lib/types/client/diff/comment-message.d.ts +29 -0
- package/lib/types/client/diff/diff-layout.d.ts +4 -0
- package/lib/types/client/diff/line-diff.d.ts +14 -0
- package/lib/types/client/diff/unified-diff.d.ts +31 -0
- package/lib/types/client/dock/DockButtons.d.ts +19 -0
- package/lib/types/client/dock/DockColumns.d.ts +21 -0
- package/lib/types/client/dock/DockDivider.d.ts +13 -0
- package/lib/types/client/dock/TerminalDockPanel.d.ts +13 -0
- package/lib/types/client/dock/dock-controller.d.ts +55 -0
- package/lib/types/client/dock/dock-hooks.d.ts +6 -0
- package/lib/types/client/dock/dock-host.d.ts +14 -0
- package/lib/types/client/dock/dock-icons.d.ts +10 -0
- package/lib/types/client/dock/dock-model.d.ts +35 -0
- package/lib/types/client/dock/dock-tabs.d.ts +72 -0
- package/lib/types/client/dock/terminal-stack.d.ts +19 -0
- package/lib/types/client/docs/DocFilePane.d.ts +12 -0
- package/lib/types/client/docs/DocPane.d.ts +6 -0
- package/lib/types/client/docs/DocView.d.ts +5 -0
- package/lib/types/client/docs/doc-format.d.ts +46 -0
- package/lib/types/client/dom/find-by-name.d.ts +18 -0
- package/lib/types/client/files/CodeEditor.d.ts +19 -0
- package/lib/types/client/files/FileBreadcrumbs.d.ts +15 -0
- package/lib/types/client/files/FileEditorPane.d.ts +12 -0
- package/lib/types/client/files/FileTree.d.ts +25 -0
- package/lib/types/client/files/FilesBody.d.ts +14 -0
- package/lib/types/client/files/ScratchFilePane.d.ts +6 -0
- package/lib/types/client/files/breadcrumbs.d.ts +18 -0
- package/lib/types/client/files/file-edit.d.ts +20 -0
- package/lib/types/client/files/file-icons.d.ts +17 -0
- package/lib/types/client/files/files-api.d.ts +26 -0
- package/lib/types/client/files/files-tab.d.ts +25 -0
- package/lib/types/client/files/line-comment.d.ts +26 -0
- package/lib/types/client/files/line-comments.d.ts +48 -0
- package/lib/types/client/files/tree-model.d.ts +60 -0
- package/lib/types/client/git/git-api.d.ts +35 -0
- package/lib/types/client/index.d.ts +28 -0
- package/lib/types/client/models/ModelConnect.d.ts +13 -0
- package/lib/types/client/models/model-connect.d.ts +145 -0
- package/lib/types/client/notifications/Toasts.d.ts +6 -0
- package/lib/types/client/notifications/system-notice.d.ts +19 -0
- package/lib/types/client/notifications/toast-state.d.ts +29 -0
- package/lib/types/client/palette/CommandPalette.d.ts +9 -0
- package/lib/types/client/palette/PalettePanel.d.ts +10 -0
- package/lib/types/client/palette/file-search.d.ts +9 -0
- package/lib/types/client/palette/fuzzy.d.ts +15 -0
- package/lib/types/client/palette/palette-commands.d.ts +64 -0
- package/lib/types/client/palette/palette-config.d.ts +21 -0
- package/lib/types/client/palette/palette-items.d.ts +40 -0
- package/lib/types/client/palette/palette-settings-plugin.d.ts +8 -0
- package/lib/types/client/palette/palette-shortcut.d.ts +10 -0
- package/lib/types/client/palette/palette-state.d.ts +68 -0
- package/lib/types/client/palette/use-workspace-palette.d.ts +39 -0
- package/lib/types/client/projects/NewWorkspaceDialog.d.ts +21 -0
- package/lib/types/client/projects/ProjectsSidebar.d.ts +39 -0
- package/lib/types/client/projects/RepoSection.d.ts +29 -0
- package/lib/types/client/projects/WorkspaceStrip.d.ts +14 -0
- package/lib/types/client/projects/projects-control.d.ts +119 -0
- package/lib/types/client/projects/registry-api.d.ts +22 -0
- package/lib/types/client/projects/registry-state.d.ts +67 -0
- package/lib/types/client/projects/shown-workspace.d.ts +19 -0
- package/lib/types/client/projects/sidebar-model.d.ts +113 -0
- package/lib/types/client/projects/upstream-panels.d.ts +54 -0
- package/lib/types/client/projects/web-folder-picker.d.ts +13 -0
- package/lib/types/client/review/ReviewBody.d.ts +9 -0
- package/lib/types/client/review/review-store.d.ts +46 -0
- package/lib/types/client/review/review-tab.d.ts +15 -0
- package/lib/types/client/sessions/agent-bridge.d.ts +20 -0
- package/lib/types/client/sessions/main-session.d.ts +24 -0
- package/lib/types/client/sessions/running-agents.d.ts +9 -0
- package/lib/types/client/sessions/session-client.d.ts +22 -0
- package/lib/types/client/sessions/session-navigation.d.ts +63 -0
- package/lib/types/client/sessions/session-pick.d.ts +15 -0
- package/lib/types/client/settings/locales.d.ts +5 -0
- package/lib/types/client/settings/open-settings.d.ts +37 -0
- package/lib/types/client/settings/section-plugin.d.ts +39 -0
- package/lib/types/client/settings/styles.d.ts +3 -0
- package/lib/types/client/shared-context/BriefTab.d.ts +21 -0
- package/lib/types/client/shared-context/brief-api.d.ts +9 -0
- package/lib/types/client/status/agent-status-api.d.ts +10 -0
- package/lib/types/client/status/agent-status-state.d.ts +27 -0
- package/lib/types/client/status/attention-model.d.ts +20 -0
- package/lib/types/client/styles.d.ts +2 -0
- package/lib/types/client/tabs/AgentIcon.d.ts +12 -0
- package/lib/types/client/tabs/NewTabMenu.d.ts +42 -0
- package/lib/types/client/tabs/TabActivity.d.ts +7 -0
- package/lib/types/client/tabs/TabStrip.d.ts +53 -0
- package/lib/types/client/tabs/TabsPanel.d.ts +14 -0
- package/lib/types/client/tabs/agent-marks.d.ts +9 -0
- package/lib/types/client/tabs/agent-visibility.d.ts +11 -0
- package/lib/types/client/tabs/last-tab.d.ts +15 -0
- package/lib/types/client/tabs/registry/CustomTabPane.d.ts +13 -0
- package/lib/types/client/tabs/registry/provide.d.ts +11 -0
- package/lib/types/client/tabs/registry/tab-registry.d.ts +52 -0
- package/lib/types/client/tabs/tab-close.d.ts +4 -0
- package/lib/types/client/tabs/tab-scroll.d.ts +19 -0
- package/lib/types/client/tabs/tab-types-state.d.ts +24 -0
- package/lib/types/client/tabs/tabs-settings-plugin.d.ts +9 -0
- package/lib/types/client/terminal/PtyPane.d.ts +8 -0
- package/lib/types/client/terminal/TerminalSearchBar.d.ts +7 -0
- package/lib/types/client/terminal/agent-commands.d.ts +15 -0
- package/lib/types/client/terminal/gpu-renderer.d.ts +10 -0
- package/lib/types/client/terminal/pty-api.d.ts +21 -0
- package/lib/types/client/terminal/pty-stream.d.ts +46 -0
- package/lib/types/client/terminal/terminal-links.d.ts +9 -0
- package/lib/types/client/terminal/terminal-search.d.ts +18 -0
- package/lib/types/client/terminal/terminal-session.d.ts +105 -0
- package/lib/types/client/terminal/terminal-size.d.ts +7 -0
- package/lib/types/client/ui.d.ts +18 -0
- package/lib/types/client/worktrees/shell-polling.d.ts +10 -0
- package/lib/types/client/worktrees/shell-state.d.ts +200 -0
- package/lib/types/files/contract.d.ts +74 -0
- package/lib/types/folder-picker/contract.d.ts +9 -0
- package/lib/types/git/contract.d.ts +136 -0
- package/lib/types/projects/contract.d.ts +82 -0
- package/lib/types/pty/contract.d.ts +52 -0
- package/lib/ui.js +12735 -0
- package/lib/ui.js.map +1 -0
- package/package.json +145 -3
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/** Loopback routes and JSON shapes for browsing, reading and saving files inside a git worktree. */
|
|
2
|
+
export declare const WORKSPACE_FILES_TREE_PATH = "/api/acryl-workspace/files/tree";
|
|
3
|
+
export declare const WORKSPACE_FILES_READ_PATH = "/api/acryl-workspace/files/read";
|
|
4
|
+
export declare const WORKSPACE_FILES_WRITE_PATH = "/api/acryl-workspace/files/write";
|
|
5
|
+
export declare const WORKSPACE_FILES_ENTRY_PATH = "/api/acryl-workspace/files/entry";
|
|
6
|
+
/** The largest file the editor opens or saves. */
|
|
7
|
+
export declare const MAX_EDITABLE_BYTES: number;
|
|
8
|
+
export type FileEntryKind = 'file' | 'dir';
|
|
9
|
+
export interface FileEntry {
|
|
10
|
+
/** Base name, without any directory part. */
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly kind: FileEntryKind;
|
|
13
|
+
/** Git ignores it (build output, dependencies, local settings); the tree shows it dimmed. */
|
|
14
|
+
readonly ignored?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** One directory of a worktree. */
|
|
17
|
+
export interface FilesTreeView {
|
|
18
|
+
/** Absolute worktree path. */
|
|
19
|
+
readonly path: string;
|
|
20
|
+
/** Directory relative to the worktree, `''` for its root. */
|
|
21
|
+
readonly dir: string;
|
|
22
|
+
/** Directories first, then files, each alphabetical. */
|
|
23
|
+
readonly entries: readonly FileEntry[];
|
|
24
|
+
/** True when the directory had more entries than the cap. */
|
|
25
|
+
readonly truncated: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface FileContentView {
|
|
28
|
+
readonly path: string;
|
|
29
|
+
readonly file: string;
|
|
30
|
+
/** UTF-8 text; empty when `binary`. */
|
|
31
|
+
readonly content: string;
|
|
32
|
+
readonly binary: boolean;
|
|
33
|
+
readonly size: number;
|
|
34
|
+
/** Modification time on disk, sent back when saving to detect an outside change. */
|
|
35
|
+
readonly mtimeMs: number;
|
|
36
|
+
}
|
|
37
|
+
export interface FileSavedView {
|
|
38
|
+
readonly path: string;
|
|
39
|
+
readonly file: string;
|
|
40
|
+
readonly size: number;
|
|
41
|
+
readonly mtimeMs: number;
|
|
42
|
+
}
|
|
43
|
+
/** @param value - unknown JSON from the tree route. */
|
|
44
|
+
export declare function parseFilesTreeView(value: unknown): FilesTreeView;
|
|
45
|
+
/** @param value - unknown JSON from the read route. */
|
|
46
|
+
export declare function parseFileContentView(value: unknown): FileContentView;
|
|
47
|
+
/** @param value - unknown JSON from the write route. */
|
|
48
|
+
export declare function parseFileSavedView(value: unknown): FileSavedView;
|
|
49
|
+
/**
|
|
50
|
+
* One structural change to a worktree's files. Deliberately small: create a file or an empty folder,
|
|
51
|
+
* rename or move an entry, delete a file or an empty folder. Nothing overwrites, nothing recurses.
|
|
52
|
+
*/
|
|
53
|
+
export type FileEntryChange = {
|
|
54
|
+
readonly op: 'create';
|
|
55
|
+
readonly kind: FileEntryKind;
|
|
56
|
+
readonly file: string;
|
|
57
|
+
} | {
|
|
58
|
+
readonly op: 'rename';
|
|
59
|
+
readonly file: string;
|
|
60
|
+
readonly to: string;
|
|
61
|
+
} | {
|
|
62
|
+
readonly op: 'delete';
|
|
63
|
+
readonly file: string;
|
|
64
|
+
};
|
|
65
|
+
/** The result of a structural change: what now exists (null after a delete). */
|
|
66
|
+
export interface FileEntryChangedView {
|
|
67
|
+
readonly path: string;
|
|
68
|
+
readonly op: FileEntryChange['op'];
|
|
69
|
+
readonly file: string | null;
|
|
70
|
+
}
|
|
71
|
+
/** @param value - unknown JSON from the entry route. */
|
|
72
|
+
export declare function parseFileEntryChangedView(value: unknown): FileEntryChangedView;
|
|
73
|
+
/** Validate an untrusted request body into a change, or null when it is not one. */
|
|
74
|
+
export declare function parseFileEntryChange(value: unknown): FileEntryChange | null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The worktree file routes: two reads and two changes, for the app's own page only. */
|
|
2
|
+
import { Acryl } from '@acryldev/blends';
|
|
3
|
+
import { type ReportError } from '../private-route.ts';
|
|
4
|
+
import { type WorkspaceFiles } from './service.ts';
|
|
5
|
+
/**
|
|
6
|
+
* GET `tree?path=<worktree>&dir=<relative, empty for the root>` and `read?path=&file=`; POST `write` `{ path, file, content, expectedMtimeMs }`
|
|
7
|
+
* to replace an existing file's text and `entry` `{ path, op: 'create' | 'rename' | 'delete', file, kind?, to? }` for one structural change.
|
|
8
|
+
*/
|
|
9
|
+
export declare function filesRoutes(files: WorkspaceFiles, reportError: ReportError): Acryl;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browsing, reading and saving files inside one git worktree.
|
|
3
|
+
*
|
|
4
|
+
* This is the only part of the package that writes user files, so every path is confined: the worktree
|
|
5
|
+
* must be the root of a git worktree (checked by the injected resolver), a file path is relative and
|
|
6
|
+
* free of `..` and `.git` segments, and the real path (after symlinks) must stay inside the worktree.
|
|
7
|
+
* Saves are atomic (temp file then rename) and refuse to overwrite a file that changed on disk since it
|
|
8
|
+
* was read.
|
|
9
|
+
*/
|
|
10
|
+
import { type FileContentView, type FileEntryChange, type FileEntryChangedView, type FileSavedView, type FilesTreeView } from './contract.ts';
|
|
11
|
+
export type WorkspaceFilesErrorKind = 'invalid' | 'not-found' | 'conflict' | 'too-large' | 'failed';
|
|
12
|
+
export declare class WorkspaceFilesError extends Error {
|
|
13
|
+
readonly kind: WorkspaceFilesErrorKind;
|
|
14
|
+
constructor(message: string, kind: WorkspaceFilesErrorKind);
|
|
15
|
+
}
|
|
16
|
+
export interface WorkspaceFilesOptions {
|
|
17
|
+
/** Validates that a path is the root of a git worktree and returns its real path. */
|
|
18
|
+
readonly resolveWorktree: (path: string) => Promise<string>;
|
|
19
|
+
/** Which of the given root-relative paths git ignores (a directory ends in `/`); without it nothing is marked. */
|
|
20
|
+
readonly ignored?: (root: string, paths: readonly string[]) => Promise<ReadonlySet<string>>;
|
|
21
|
+
}
|
|
22
|
+
export declare class WorkspaceFiles {
|
|
23
|
+
private readonly options;
|
|
24
|
+
constructor(options: WorkspaceFilesOptions);
|
|
25
|
+
tree(worktree: string, dir: string): Promise<FilesTreeView>;
|
|
26
|
+
read(worktree: string, file: string): Promise<FileContentView>;
|
|
27
|
+
/**
|
|
28
|
+
* Replace an existing file's text.
|
|
29
|
+
* @param expectedMtimeMs - the `mtimeMs` from the read this edit is based on.
|
|
30
|
+
* @throws WorkspaceFilesError `conflict` when the file changed on disk since that read.
|
|
31
|
+
*/
|
|
32
|
+
write(worktree: string, file: string, content: string, expectedMtimeMs: number): Promise<FileSavedView>;
|
|
33
|
+
/**
|
|
34
|
+
* Create, rename or delete one entry. Never overwrites, never recurses: a delete removes a file or an
|
|
35
|
+
* empty folder only, and a create or rename refuses a name that is already taken.
|
|
36
|
+
*/
|
|
37
|
+
change(worktree: string, change: FileEntryChange): Promise<FileEntryChangedView>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Turn a worktree-relative path into a real path that is guaranteed to be inside `root`.
|
|
41
|
+
* Rejects absolute paths, NUL, `..` and `.git` segments, and symlinks that leave the worktree.
|
|
42
|
+
*/
|
|
43
|
+
export declare function confine(root: string, relative: string): Promise<string>;
|
|
44
|
+
/**
|
|
45
|
+
* The real path of an entry that will be created: its folder must exist inside the worktree and the name
|
|
46
|
+
* must be free (a dangling symlink counts as taken).
|
|
47
|
+
*/
|
|
48
|
+
export declare function confineNew(root: string, relative: string): Promise<string>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Same-origin route that opens the operating system's own folder chooser on the machine running the Host. */
|
|
2
|
+
export declare const WORKSPACE_PICK_FOLDER_PATH = "/api/acryl-workspace/pick-folder";
|
|
3
|
+
/** What the chooser answered: the picked absolute path, or null when it was cancelled. */
|
|
4
|
+
export interface PickFolderView {
|
|
5
|
+
readonly path: string | null;
|
|
6
|
+
}
|
|
7
|
+
/** HTTP status the route uses when this machine has no native chooser (a headless Linux box, say). */
|
|
8
|
+
export declare const PICK_FOLDER_UNAVAILABLE_STATUS = 501;
|
|
9
|
+
export declare function parsePickFolderView(value: unknown): PickFolderView;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opens the operating system's own folder chooser and reports the folder picked. The Host serves a
|
|
3
|
+
* loopback-only Web server (`@acryldev/workspace` refuses to start otherwise), so a dialog raised here is on
|
|
4
|
+
* the same machine as the person using the page - the reason this is safe to offer at all, unlike a
|
|
5
|
+
* chooser on a remote server nobody is sitting at.
|
|
6
|
+
*/
|
|
7
|
+
/** Runs a program and resolves its stdout; rejects with `code` set to the exit code or 'ENOENT'. */
|
|
8
|
+
export type RunProgram = (file: string, args: readonly string[]) => Promise<string>;
|
|
9
|
+
/** No native chooser exists on this machine (no dialog program installed). */
|
|
10
|
+
export declare class FolderPickerUnavailableError extends Error {
|
|
11
|
+
constructor();
|
|
12
|
+
}
|
|
13
|
+
/** A trailing separator is dropped (the chooser adds one), except for a filesystem root. */
|
|
14
|
+
export declare function normalizePickedPath(raw: string): string | null;
|
|
15
|
+
/**
|
|
16
|
+
* @param platform - `process.platform`.
|
|
17
|
+
* @param run - process runner; injected so the tests never open a dialog.
|
|
18
|
+
* @returns the absolute path picked, or null when the chooser was cancelled.
|
|
19
|
+
* @throws FolderPickerUnavailableError when this machine has no chooser program.
|
|
20
|
+
*/
|
|
21
|
+
export declare function pickFolderNatively(platform: NodeJS.Platform, run?: RunProgram): Promise<string | null>;
|
|
22
|
+
/** One chooser at a time: a second request while one is open waits for that answer instead of stacking dialogs. */
|
|
23
|
+
export declare function singleFlight<T>(task: () => Promise<T>): () => Promise<T>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** The native folder chooser, for the app's own page only. */
|
|
2
|
+
import { Acryl } from '@acryldev/blends';
|
|
3
|
+
import { type ReportError } from '../private-route.ts';
|
|
4
|
+
/** POST: open the OS's chooser and answer the folder, or `null` when it was cancelled. */
|
|
5
|
+
export declare function pickFolderRoutes(pick: () => Promise<string | null>, reportError: ReportError): Acryl;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** What changed in a worktree: the status list, one file's diff, and staging. Nothing here commits. */
|
|
2
|
+
import type { GitDiffView, GitStatusView } from './contract.ts';
|
|
3
|
+
import { type GitRunner } from './runner.ts';
|
|
4
|
+
export declare class WorkspaceChanges {
|
|
5
|
+
private readonly git;
|
|
6
|
+
private readonly maxChanges;
|
|
7
|
+
constructor(git: GitRunner, maxChanges: number);
|
|
8
|
+
/**
|
|
9
|
+
* Changed files in one worktree, versus HEAD.
|
|
10
|
+
* @param path - absolute worktree directory.
|
|
11
|
+
*/
|
|
12
|
+
status(path: string): Promise<GitStatusView>;
|
|
13
|
+
/**
|
|
14
|
+
* Unified diff of one file against HEAD (untracked files diff against nothing).
|
|
15
|
+
* @param path - absolute worktree directory.
|
|
16
|
+
* @param file - path relative to that worktree.
|
|
17
|
+
*/
|
|
18
|
+
diff(path: string, file: string): Promise<GitDiffView>;
|
|
19
|
+
/**
|
|
20
|
+
* Stage files (`git add`), then report the worktree's status.
|
|
21
|
+
* @param path - absolute worktree directory.
|
|
22
|
+
* @param files - paths relative to that worktree.
|
|
23
|
+
*/
|
|
24
|
+
stage(path: string, files: readonly string[]): Promise<GitStatusView>;
|
|
25
|
+
/**
|
|
26
|
+
* Unstage files, keeping their working-tree changes, then report the status. Works before the first commit too.
|
|
27
|
+
*/
|
|
28
|
+
unstage(path: string, files: readonly string[]): Promise<GitStatusView>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Read-only discovery of the checks a worktree can run: its package.json scripts and package manager. */
|
|
2
|
+
import type { CheckManager, CheckScript, GitChecksView } from './contract.ts';
|
|
3
|
+
/** The manager the project itself uses: its lockfile, else null (the caller then runs plain `npm`). */
|
|
4
|
+
export declare function detectManager(dir: string): Promise<CheckManager | null>;
|
|
5
|
+
/** Parse `package.json` scripts; a missing, oversized or malformed file simply means "no scripts". */
|
|
6
|
+
export declare function parseScripts(text: string): CheckScript[];
|
|
7
|
+
/** @param dir - an already validated absolute worktree directory. */
|
|
8
|
+
export declare function readWorktreeChecks(dir: string): Promise<GitChecksView>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Committing what is staged. It never pushes and never bypasses hooks. */
|
|
2
|
+
import type { GitCommitView } from './contract.ts';
|
|
3
|
+
import type { WorkspaceChanges } from './changes.ts';
|
|
4
|
+
import type { GitRunner } from './runner.ts';
|
|
5
|
+
export declare class WorkspaceCommits {
|
|
6
|
+
private readonly git;
|
|
7
|
+
private readonly changes;
|
|
8
|
+
constructor(git: GitRunner, changes: WorkspaceChanges);
|
|
9
|
+
/**
|
|
10
|
+
* Commit what is staged. Refuses an empty message, nothing staged, or a missing git identity with a reason the
|
|
11
|
+
* user can act on; never pushes, and never bypasses hooks.
|
|
12
|
+
*/
|
|
13
|
+
commit(path: string, message: string): Promise<GitCommitView>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/** Read-only git routes and view types shared by the ACRYL Workspace Host and Client. */
|
|
2
|
+
export declare const WORKSPACE_GIT_REPO_PATH = "/api/acryl-workspace/git/repo";
|
|
3
|
+
export declare const WORKSPACE_GIT_STATUS_PATH = "/api/acryl-workspace/git/status";
|
|
4
|
+
export declare const WORKSPACE_GIT_DIFF_PATH = "/api/acryl-workspace/git/diff";
|
|
5
|
+
export declare const WORKSPACE_GIT_WORKTREE_PATH = "/api/acryl-workspace/git/worktree";
|
|
6
|
+
export declare const WORKSPACE_GIT_CHECKS_PATH = "/api/acryl-workspace/git/checks";
|
|
7
|
+
export declare const WORKSPACE_GIT_SEARCH_PATH = "/api/acryl-workspace/git/search";
|
|
8
|
+
export declare const WORKSPACE_GIT_STAGE_PATH = "/api/acryl-workspace/git/stage";
|
|
9
|
+
export declare const WORKSPACE_GIT_UNSTAGE_PATH = "/api/acryl-workspace/git/unstage";
|
|
10
|
+
export declare const WORKSPACE_GIT_COMMIT_PATH = "/api/acryl-workspace/git/commit";
|
|
11
|
+
/** The most hits one search returns. */
|
|
12
|
+
export declare const MAX_SEARCH_RESULTS = 200;
|
|
13
|
+
/** The longest query the search route accepts. */
|
|
14
|
+
export declare const MAX_SEARCH_QUERY = 200;
|
|
15
|
+
/** The most files one stage or unstage request may name. */
|
|
16
|
+
export declare const MAX_STAGE_FILES = 1000;
|
|
17
|
+
/** The longest commit message the commit route accepts. */
|
|
18
|
+
export declare const MAX_COMMIT_MESSAGE = 5000;
|
|
19
|
+
/** One worktree of a repository, as `git worktree list` reports it. */
|
|
20
|
+
export interface GitWorktree {
|
|
21
|
+
/** Absolute path of the worktree directory. */
|
|
22
|
+
readonly path: string;
|
|
23
|
+
/** Checked-out branch name, or null when HEAD is detached or bare. */
|
|
24
|
+
readonly branch: string | null;
|
|
25
|
+
/** Full commit id HEAD points at. */
|
|
26
|
+
readonly head: string;
|
|
27
|
+
/** True for the repository's main worktree (git always lists it first). */
|
|
28
|
+
readonly main: boolean;
|
|
29
|
+
}
|
|
30
|
+
/** A repository and every worktree attached to it. */
|
|
31
|
+
export interface GitRepoView {
|
|
32
|
+
/** Display name: the main worktree's directory name. */
|
|
33
|
+
readonly name: string;
|
|
34
|
+
/** Absolute path of the main worktree. */
|
|
35
|
+
readonly root: string;
|
|
36
|
+
/** Path of the worktree that contains the directory the request named. */
|
|
37
|
+
readonly current: string;
|
|
38
|
+
readonly worktrees: readonly GitWorktree[];
|
|
39
|
+
}
|
|
40
|
+
/** Status letters shown next to a changed file. `?` is untracked, `U` is unmerged. */
|
|
41
|
+
export type GitChangeCode = 'M' | 'A' | 'D' | 'R' | 'U' | '?';
|
|
42
|
+
export interface GitChange {
|
|
43
|
+
/** Path relative to the worktree root, forward slashes. */
|
|
44
|
+
readonly path: string;
|
|
45
|
+
readonly code: GitChangeCode;
|
|
46
|
+
/** True when the index already holds a change for this path. */
|
|
47
|
+
readonly staged: boolean;
|
|
48
|
+
/** Lines added versus HEAD, or null for binary and untracked files. */
|
|
49
|
+
readonly added: number | null;
|
|
50
|
+
/** Lines removed versus HEAD, or null for binary and untracked files. */
|
|
51
|
+
readonly removed: number | null;
|
|
52
|
+
/** Previous path for a rename. */
|
|
53
|
+
readonly oldPath?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface GitStatusView {
|
|
56
|
+
/** Worktree path this status describes. */
|
|
57
|
+
readonly path: string;
|
|
58
|
+
/** Current branch, or null when detached. */
|
|
59
|
+
readonly branch: string | null;
|
|
60
|
+
readonly changes: readonly GitChange[];
|
|
61
|
+
/** True when the change list was cut at the entry cap. */
|
|
62
|
+
readonly truncated: boolean;
|
|
63
|
+
}
|
|
64
|
+
export interface GitDiffView {
|
|
65
|
+
readonly path: string;
|
|
66
|
+
readonly file: string;
|
|
67
|
+
/** Unified diff text against HEAD; empty for binary files. */
|
|
68
|
+
readonly text: string;
|
|
69
|
+
readonly binary: boolean;
|
|
70
|
+
/** True when the diff exceeded the output cap and was cut. */
|
|
71
|
+
readonly truncated: boolean;
|
|
72
|
+
}
|
|
73
|
+
/** The result of creating a branch and its worktree. */
|
|
74
|
+
export interface GitWorktreeCreatedView {
|
|
75
|
+
/** Absolute path of the new worktree. */
|
|
76
|
+
readonly path: string;
|
|
77
|
+
readonly branch: string;
|
|
78
|
+
/** The repository after the change, so the caller does not need a second request. */
|
|
79
|
+
readonly repo: GitRepoView;
|
|
80
|
+
}
|
|
81
|
+
export type CheckManager = 'pnpm' | 'npm' | 'yarn' | 'bun';
|
|
82
|
+
export interface CheckScript {
|
|
83
|
+
/** A plain script name (letters, digits and `:_.-`), safe to type into a shell. */
|
|
84
|
+
readonly name: string;
|
|
85
|
+
/** The script's command line, for display only. */
|
|
86
|
+
readonly command: string;
|
|
87
|
+
/** True for check-like names (check, test, lint, typecheck, build, format, ...). */
|
|
88
|
+
readonly primary: boolean;
|
|
89
|
+
}
|
|
90
|
+
/** What a worktree can run: its package scripts and the package manager its lockfile names. */
|
|
91
|
+
export interface GitChecksView {
|
|
92
|
+
readonly path: string;
|
|
93
|
+
/** The project's own manager, or null when no lockfile says (then `npm` is the neutral default). */
|
|
94
|
+
readonly manager: CheckManager | null;
|
|
95
|
+
readonly scripts: readonly CheckScript[];
|
|
96
|
+
}
|
|
97
|
+
export type GitSearchMode = 'name' | 'content';
|
|
98
|
+
/** One search hit: a file, and for a content search the line and its text. */
|
|
99
|
+
export interface GitSearchHit {
|
|
100
|
+
readonly file: string;
|
|
101
|
+
readonly line?: number;
|
|
102
|
+
readonly text?: string;
|
|
103
|
+
}
|
|
104
|
+
/** Search results over the tracked and untracked (not ignored) files of a worktree. */
|
|
105
|
+
export interface GitSearchView {
|
|
106
|
+
readonly path: string;
|
|
107
|
+
readonly query: string;
|
|
108
|
+
readonly mode: GitSearchMode;
|
|
109
|
+
readonly hits: readonly GitSearchHit[];
|
|
110
|
+
/** True when there were more matches than the cap. */
|
|
111
|
+
readonly truncated: boolean;
|
|
112
|
+
}
|
|
113
|
+
/** The result of a commit: the new commit and the worktree's status afterwards. */
|
|
114
|
+
export interface GitCommitView {
|
|
115
|
+
/** Abbreviated hash of the new commit. */
|
|
116
|
+
readonly hash: string;
|
|
117
|
+
/** First line of its message. */
|
|
118
|
+
readonly subject: string;
|
|
119
|
+
readonly status: GitStatusView;
|
|
120
|
+
}
|
|
121
|
+
/** @param value - unknown JSON from the repo route. */
|
|
122
|
+
export declare function parseGitRepoView(value: unknown): GitRepoView;
|
|
123
|
+
/** @param value - unknown JSON from the status route. */
|
|
124
|
+
export declare function parseGitStatusView(value: unknown): GitStatusView;
|
|
125
|
+
/** @param value - unknown JSON from the diff route. */
|
|
126
|
+
export declare function parseGitDiffView(value: unknown): GitDiffView;
|
|
127
|
+
/** @param value - unknown JSON from the worktree route. */
|
|
128
|
+
export declare function parseGitWorktreeCreatedView(value: unknown): GitWorktreeCreatedView;
|
|
129
|
+
/** @param value - unknown JSON from the checks route. */
|
|
130
|
+
export declare function parseGitChecksView(value: unknown): GitChecksView;
|
|
131
|
+
/** The command line to type for one script, using the project's own package manager. */
|
|
132
|
+
export declare function checkCommandLine(manager: CheckManager | null, script: string): string;
|
|
133
|
+
/** @param value - unknown JSON from the commit route. */
|
|
134
|
+
export declare function parseGitCommitView(value: unknown): GitCommitView;
|
|
135
|
+
/** @param value - unknown JSON from the search route. */
|
|
136
|
+
export declare function parseGitSearchView(value: unknown): GitSearchView;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Errors of the Workspace git modules. */
|
|
2
|
+
/**
|
|
3
|
+
* A request the caller got wrong (400), a directory that is not a repository (404), something that
|
|
4
|
+
* already exists (409), or a git failure (500).
|
|
5
|
+
*/
|
|
6
|
+
export declare class WorkspaceGitError extends Error {
|
|
7
|
+
readonly kind: 'invalid' | 'not-repo' | 'conflict' | 'failed';
|
|
8
|
+
constructor(message: string, kind: 'invalid' | 'not-repo' | 'conflict' | 'failed');
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Checks on what a caller may hand to git, before git sees it. */
|
|
2
|
+
/**
|
|
3
|
+
* A conservative first filter, before git's own check: letters, digits, `.`, `_`, `-` and `/`
|
|
4
|
+
* separators, starting with a letter, digit or underscore. It keeps the branch usable as one folder
|
|
5
|
+
* name and can never look like an option or a path escape.
|
|
6
|
+
*/
|
|
7
|
+
export declare function assertBranchName(branch: string): void;
|
|
8
|
+
export declare function assertFileList(files: readonly string[]): void;
|
|
9
|
+
export declare function assertRelativeFile(file: string): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Which entries of one directory git ignores, for the file tree to show them dimmed. */
|
|
2
|
+
import type { GitRunner } from './runner.ts';
|
|
3
|
+
/**
|
|
4
|
+
* @param git - the runner.
|
|
5
|
+
* @param root - absolute worktree root (its real path).
|
|
6
|
+
* @param paths - entries relative to the root, `/`-separated; a directory ends in `/`, so directory-only patterns (`build/`) apply.
|
|
7
|
+
* @returns the given paths git ignores; none when git cannot answer (the tree then shows everything undimmed).
|
|
8
|
+
*/
|
|
9
|
+
export declare function ignoredPaths(git: GitRunner, root: string, paths: readonly string[]): Promise<ReadonlySet<string>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Parsers for the machine-readable output of `git worktree`, `git diff --numstat` and `git status`. */
|
|
2
|
+
import type { GitChange, GitWorktree } from './contract.ts';
|
|
3
|
+
/** Parse `git worktree list --porcelain`. Git always lists the main worktree first. Git writes `C:/repo` on Windows; paths are returned in the host's own form (`C:\repo`). */
|
|
4
|
+
export declare function parseWorktrees(text: string): GitWorktree[];
|
|
5
|
+
interface LineCount {
|
|
6
|
+
readonly added: number | null;
|
|
7
|
+
readonly removed: number | null;
|
|
8
|
+
}
|
|
9
|
+
/** Parse `git diff --numstat -z`. Binary files report `-` and map to null counts. */
|
|
10
|
+
export declare function parseNumstat(text: string): Map<string, LineCount>;
|
|
11
|
+
/** Parse `git status --porcelain=v1 -z`, attaching line counts where git reported them. */
|
|
12
|
+
export declare function parsePorcelain(text: string, counts: ReadonlyMap<string, LineCount>): GitChange[];
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The workspace git routes: five reads, and the writes the Changes panel makes (worktree, stage, unstage, commit), for the app's own page only. */
|
|
2
|
+
import { Acryl } from '@acryldev/blends';
|
|
3
|
+
import { type ReportError } from '../private-route.ts';
|
|
4
|
+
import { type WorkspaceGit } from './service.ts';
|
|
5
|
+
/**
|
|
6
|
+
* GET `repo?cwd=`, `status?path=`, `checks?path=`, `search?path=&q=&mode=name|content` and `diff?path=&file=`; POST `worktree` `{ cwd, branch }`
|
|
7
|
+
* (create a branch and its worktree), `stage` and `unstage` `{ path, files }`, and `commit` `{ path, message }` (never pushes).
|
|
8
|
+
*/
|
|
9
|
+
export declare function gitRoutes(git: WorkspaceGit, reportError: ReportError): Acryl;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The confined way to run git: an argument array (never a shell), a timeout, an output cap, and a record
|
|
3
|
+
* of every in-flight process so disposal can abort and reap them. Set `GIT_OPTIONAL_LOCKS=0` so a status
|
|
4
|
+
* poll never takes the index lock an agent's own `git` call may need.
|
|
5
|
+
*/
|
|
6
|
+
export interface GitRunnerOptions {
|
|
7
|
+
/** Executable to run. Defaults to `git`. */
|
|
8
|
+
readonly gitPath?: string;
|
|
9
|
+
/** Output cap per command; longer output is cut and flagged. */
|
|
10
|
+
readonly maxOutputBytes?: number;
|
|
11
|
+
readonly timeoutMs?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface RunResult {
|
|
14
|
+
readonly stdout: string;
|
|
15
|
+
readonly truncated: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function emptyResult(): RunResult;
|
|
18
|
+
export declare class GitRunner {
|
|
19
|
+
private readonly gitPath;
|
|
20
|
+
private readonly maxOutputBytes;
|
|
21
|
+
private readonly timeoutMs;
|
|
22
|
+
private readonly inflight;
|
|
23
|
+
private disposed;
|
|
24
|
+
constructor(options?: GitRunnerOptions);
|
|
25
|
+
/** Abort every in-flight `git` process and wait for each to exit. Later calls reject. */
|
|
26
|
+
dispose(): Promise<void>;
|
|
27
|
+
resolveDirectory(path: string): Promise<string>;
|
|
28
|
+
run(args: readonly string[], cwd: string, acceptExit?: number, timeoutMs?: number): Promise<RunResult>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Repo-wide search over the files git tracks or would track: by name or by content. */
|
|
2
|
+
import type { GitSearchMode, GitSearchView } from './contract.ts';
|
|
3
|
+
import type { GitRunner } from './runner.ts';
|
|
4
|
+
export declare class WorkspaceSearch {
|
|
5
|
+
private readonly git;
|
|
6
|
+
constructor(git: GitRunner);
|
|
7
|
+
/**
|
|
8
|
+
* Find files by name, or lines by content, among the tracked and untracked files git does not ignore.
|
|
9
|
+
* Case-insensitive and literal (the query is never a pattern), so it cannot be a regular-expression trap.
|
|
10
|
+
* @param path - absolute worktree directory.
|
|
11
|
+
* @param query - what to look for.
|
|
12
|
+
*/
|
|
13
|
+
search(path: string, query: string, mode: GitSearchMode): Promise<GitSearchView>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Workspace's git access, as one facade over focused modules.
|
|
3
|
+
*
|
|
4
|
+
* Each use case lives in its own module and reaches git only through the confined {@link GitRunner}
|
|
5
|
+
* (argument arrays, timeouts, output caps, no shell):
|
|
6
|
+
* - `worktrees.ts` repositories and worktrees
|
|
7
|
+
* - `changes.ts` status, diff, stage, unstage
|
|
8
|
+
* - `commits.ts` commit (never pushes)
|
|
9
|
+
* - `search.ts` repo-wide search
|
|
10
|
+
* - `checks.ts` package scripts a worktree can run
|
|
11
|
+
* The facade exists so the routes and the file routes keep one collaborator to depend on.
|
|
12
|
+
*/
|
|
13
|
+
import type { GitChecksView, GitCommitView, GitDiffView, GitRepoView, GitSearchMode, GitSearchView, GitStatusView, GitWorktreeCreatedView } from './contract.ts';
|
|
14
|
+
import { type GitRunnerOptions } from './runner.ts';
|
|
15
|
+
export { WorkspaceGitError } from './errors.ts';
|
|
16
|
+
export { parseNumstat, parsePorcelain, parseWorktrees } from './parsing.ts';
|
|
17
|
+
export interface WorkspaceGitOptions extends GitRunnerOptions {
|
|
18
|
+
/** Cap on entries returned by `status`. */
|
|
19
|
+
readonly maxChanges?: number;
|
|
20
|
+
}
|
|
21
|
+
export declare class WorkspaceGit {
|
|
22
|
+
private readonly runner;
|
|
23
|
+
private readonly worktrees;
|
|
24
|
+
private readonly changes;
|
|
25
|
+
private readonly commits;
|
|
26
|
+
private readonly searcher;
|
|
27
|
+
constructor(options?: WorkspaceGitOptions);
|
|
28
|
+
/** The repository containing `cwd`, or null when it is not inside a git repository. */
|
|
29
|
+
repo(cwd: string): Promise<GitRepoView | null>;
|
|
30
|
+
/** Confirm `path` is the root of a git worktree and return its real path. */
|
|
31
|
+
worktreeRoot(path: string): Promise<string>;
|
|
32
|
+
/** Create a branch and a worktree for it in the repository's sibling `<repo>.worktrees/` folder. */
|
|
33
|
+
createWorktree(cwd: string, branch: string): Promise<GitWorktreeCreatedView>;
|
|
34
|
+
/** Changed files in one worktree, versus HEAD. */
|
|
35
|
+
status(path: string): Promise<GitStatusView>;
|
|
36
|
+
/** Unified diff of one file against HEAD (untracked files diff against nothing). */
|
|
37
|
+
diff(path: string, file: string): Promise<GitDiffView>;
|
|
38
|
+
/** Stage files, then report the worktree's status. */
|
|
39
|
+
stage(path: string, files: readonly string[]): Promise<GitStatusView>;
|
|
40
|
+
/** Unstage files, keeping their working-tree changes, then report the status. */
|
|
41
|
+
unstage(path: string, files: readonly string[]): Promise<GitStatusView>;
|
|
42
|
+
/** Commit what is staged; never pushes. */
|
|
43
|
+
commit(path: string, message: string): Promise<GitCommitView>;
|
|
44
|
+
/** Find files by name, or lines by content, literally and case-insensitively. */
|
|
45
|
+
search(path: string, query: string, mode: GitSearchMode): Promise<GitSearchView>;
|
|
46
|
+
/** Which of the given worktree-relative paths git ignores (a directory ends in `/`); none when git cannot say. */
|
|
47
|
+
ignored(root: string, paths: readonly string[]): Promise<ReadonlySet<string>>;
|
|
48
|
+
/** The scripts a worktree can run as checks, and its package manager. */
|
|
49
|
+
checks(path: string): Promise<GitChecksView>;
|
|
50
|
+
/** Abort every in-flight `git` process and wait for each to exit. Later calls reject. */
|
|
51
|
+
dispose(): Promise<void>;
|
|
52
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Repositories and their worktrees: listing them, confirming a path is one, and creating one. */
|
|
2
|
+
import type { GitRepoView, GitWorktreeCreatedView } from './contract.ts';
|
|
3
|
+
import type { GitRunner } from './runner.ts';
|
|
4
|
+
export declare class WorkspaceWorktrees {
|
|
5
|
+
private readonly git;
|
|
6
|
+
constructor(git: GitRunner);
|
|
7
|
+
/**
|
|
8
|
+
* List the repository's worktrees.
|
|
9
|
+
* @param cwd - any directory inside the repository.
|
|
10
|
+
* @returns the repository view, or null when `cwd` is not inside a git repository.
|
|
11
|
+
*/
|
|
12
|
+
repo(cwd: string): Promise<GitRepoView | null>;
|
|
13
|
+
/**
|
|
14
|
+
* Confirm `path` is the root of a git worktree and return its real path. The file routes use this so
|
|
15
|
+
* they only ever touch a checkout, never an arbitrary directory.
|
|
16
|
+
* @throws WorkspaceGitError `invalid` when the path is not a worktree root.
|
|
17
|
+
*/
|
|
18
|
+
worktreeRoot(path: string): Promise<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Create a branch and a worktree for it in the repository's sibling `<repo>.worktrees/` folder,
|
|
21
|
+
* which never dirties the repository. The branch starts at the main worktree's current commit.
|
|
22
|
+
* @param cwd - any directory inside the repository.
|
|
23
|
+
* @param branch - the new branch name.
|
|
24
|
+
*/
|
|
25
|
+
createWorktree(cwd: string, branch: string): Promise<GitWorktreeCreatedView>;
|
|
26
|
+
}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** Cordis Host plugin: ACRYL Workspace PTY table and loopback routes. */
|
|
2
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
+
/** Stable Cordis plugin name. */
|
|
4
|
+
export declare const name = "acryl-workspace";
|
|
5
|
+
/**
|
|
6
|
+
* The part of the runtime's `appInstance` service ACRYL plugins read (a separated interface: plugins do not import the runtime). Every plugin declares
|
|
7
|
+
* exactly this shape, so the Context augmentations agree in any program that loads several of them.
|
|
8
|
+
*/
|
|
9
|
+
interface AppInstanceService {
|
|
10
|
+
readonly home: string;
|
|
11
|
+
readonly dshHome: string;
|
|
12
|
+
}
|
|
13
|
+
declare module '@deepseek-ai/cordis' {
|
|
14
|
+
interface Context {
|
|
15
|
+
appInstance: AppInstanceService;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The row's config, written by the generated overlay when the frame hosts an app: where the app's own page is served (`/app`). The page opens it in a
|
|
20
|
+
* browser tile on first run, so the person starts at the app they are building rather than an empty canvas.
|
|
21
|
+
*/
|
|
22
|
+
export interface WorkspaceConfig {
|
|
23
|
+
readonly appPage?: string;
|
|
24
|
+
/** A folder to open on: added to the projects shown at start (`acryl ade` passes the folder it was started in). Not a folder: ignored. */
|
|
25
|
+
readonly openFolder?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The routes, the terminal's WebSocket among them, are served by the router (`router`, `routerHttp`) under {@link WORKSPACE_API_PREFIX}. The
|
|
29
|
+
* loopback Web server is still needed for its address (agent hooks report to it). The app instance says where this app keeps its data.
|
|
30
|
+
*/
|
|
31
|
+
export declare const inject: string[];
|
|
32
|
+
/**
|
|
33
|
+
* Activate the workspace's Host half: its services and their routes. Disabling the Loader row unmounts the routes and kills leftover PTY sessions.
|
|
34
|
+
* @param ctx - Host context for this generation.
|
|
35
|
+
*/
|
|
36
|
+
export declare function apply(ctx: Context, config?: WorkspaceConfig): void;
|
|
37
|
+
/** The agent's workspace tools, exported so the runtime can check their schemas against DSH's own compiler. */
|
|
38
|
+
export { registerWorkspaceTools } from './projects/tools.ts';
|
|
39
|
+
export { registerContextTool } from './shared-context/tool.ts';
|