MCPcopy
hub / github.com/21st-dev/1code / assertRegisteredWorktree

Function assertRegisteredWorktree

src/main/lib/git/security/path-validation.ts:62–91  ·  view source on GitHub ↗
(workspacePath: string)

Source from the content-addressed store, hash-verified

60 * @throws PathValidationError if path is not registered
61 */
62export function assertRegisteredWorktree(workspacePath: string): void {
63 const db = getDatabase();
64
65 // Check chats.worktreePath first (most common case)
66 const chatExists = db
67 .select()
68 .from(chats)
69 .where(eq(chats.worktreePath, workspacePath))
70 .get();
71
72 if (chatExists) {
73 return;
74 }
75
76 // Check projects.path for direct project access
77 const projectExists = db
78 .select()
79 .from(projects)
80 .where(eq(projects.path, workspacePath))
81 .get();
82
83 if (projectExists) {
84 return;
85 }
86
87 throw new PathValidationError(
88 "Workspace path not registered in database",
89 "UNREGISTERED_WORKTREE",
90 );
91}
92
93/**
94 * Gets the chat record if registered. Returns record for updates.

Callers 15

createStatusRouterFunction · 0.90
createFileContentsRouterFunction · 0.90
createBranchesRouterFunction · 0.90
gitSwitchBranchFunction · 0.90
gitCheckoutFileFunction · 0.90
gitCheckoutFilesFunction · 0.90
gitStageFileFunction · 0.90
gitStageAllFunction · 0.90
gitStageFilesFunction · 0.90
gitUnstageFileFunction · 0.90
gitUnstageAllFunction · 0.90

Calls 2

getDatabaseFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected