@opencode-ai/schema
Advanced tools
+22
-0
@@ -130,2 +130,7 @@ export * as Worktree from "./worktree.js"; | ||
| }; | ||
| readonly adopted: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.brand<Schema.String, "Project.ID"> & { | ||
| global: string & import("effect/Brand").Brand<"Project.ID">; | ||
| }>>>, Schema.optionalKey<Schema.$Array<Schema.brand<Schema.String, "Project.ID"> & { | ||
| global: string & import("effect/Brand").Brand<"Project.ID">; | ||
| }>>, never, never>; | ||
| }>; | ||
@@ -147,2 +152,7 @@ }> & { | ||
| }; | ||
| readonly adopted: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.brand<Schema.String, "Project.ID"> & { | ||
| global: string & import("effect/Brand").Brand<"Project.ID">; | ||
| }>>>, Schema.optionalKey<Schema.$Array<Schema.brand<Schema.String, "Project.ID"> & { | ||
| global: string & import("effect/Brand").Brand<"Project.ID">; | ||
| }>>, never, never>; | ||
| }>; | ||
@@ -229,2 +239,7 @@ }; | ||
| }; | ||
| readonly adopted: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.brand<Schema.String, "Project.ID"> & { | ||
| global: string & import("effect/Brand").Brand<"Project.ID">; | ||
| }>>>, Schema.optionalKey<Schema.$Array<Schema.brand<Schema.String, "Project.ID"> & { | ||
| global: string & import("effect/Brand").Brand<"Project.ID">; | ||
| }>>, never, never>; | ||
| }>; | ||
@@ -246,2 +261,7 @@ }> & { | ||
| }; | ||
| readonly adopted: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.brand<Schema.String, "Project.ID"> & { | ||
| global: string & import("effect/Brand").Brand<"Project.ID">; | ||
| }>>>, Schema.optionalKey<Schema.$Array<Schema.brand<Schema.String, "Project.ID"> & { | ||
| global: string & import("effect/Brand").Brand<"Project.ID">; | ||
| }>>, never, never>; | ||
| }>; | ||
@@ -253,2 +273,3 @@ }]; | ||
| readonly directory: string; | ||
| readonly workspaceID?: string; | ||
| }, event: { | ||
@@ -258,2 +279,3 @@ readonly projectID: string; | ||
| readonly previous: string; | ||
| readonly adopted?: ReadonlyArray<string>; | ||
| }): { | ||
@@ -260,0 +282,0 @@ projectID: string; |
+23
-8
@@ -43,2 +43,3 @@ export * as Worktree from "./worktree.js"; | ||
| previous: Project.ID, | ||
| adopted: optional(Schema.Array(Project.ID)), | ||
| }, | ||
@@ -48,17 +49,31 @@ }); | ||
| export function adopt(session, event) { | ||
| if (session.projectID !== event.previous && session.projectID !== Project.ID.global) | ||
| if (session.workspaceID) | ||
| return; | ||
| if (session.projectID !== event.previous && | ||
| session.projectID !== Project.ID.global && | ||
| !event.adopted?.includes(session.projectID)) | ||
| return; | ||
| if (session.projectID === event.projectID) | ||
| return; | ||
| const inside = session.directory === event.directory || | ||
| session.directory.startsWith(event.directory + "/") || | ||
| session.directory.startsWith(event.directory + "\\"); | ||
| if (!inside) | ||
| const normalize = (value) => value | ||
| .replaceAll("\\", "/") | ||
| .split("/") | ||
| .reduce((result, segment) => { | ||
| if (!segment || segment === ".") | ||
| return result; | ||
| if (segment === "..") | ||
| return result.slice(0, result.lastIndexOf("/")); | ||
| return `${result}/${segment}`; | ||
| }, ""); | ||
| const directory = normalize(session.directory); | ||
| const root = normalize(event.directory); | ||
| const windows = /^\/[a-z]:/i.test(root); | ||
| const key = windows ? directory.toLowerCase() : directory; | ||
| const parent = windows ? root.toLowerCase() : root; | ||
| if (key !== parent && !key.startsWith(parent + "/")) | ||
| return; | ||
| return { | ||
| projectID: event.projectID, | ||
| subpath: session.directory === event.directory | ||
| ? undefined | ||
| : session.directory.slice(event.directory.length + 1).replaceAll("\\", "/"), | ||
| subpath: key === parent ? undefined : directory.slice(root.length + 1), | ||
| }; | ||
| } |
+1
-1
| { | ||
| "$schema": "https://json.schemastore.org/package.json", | ||
| "name": "@opencode-ai/schema", | ||
| "version": "0.0.0-dev-18263", | ||
| "version": "0.0.0-dev-18266", | ||
| "type": "module", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
Sorry, the diff of this file is too big to display
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
3589300
0.11%57015
0.1%