@zyro-sec/schema 1.0.1 → 1.0.3
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/AGENTS.md +95 -95
- package/package.json +5 -1
- package/script/build.ts +9 -9
- package/script/config-schema.ts +86 -86
- package/script/config-v1.json +1311 -1311
- package/script/pack.ts +5 -5
- package/src/agent.ts +68 -68
- package/src/artifact.ts +81 -81
- package/src/automation.ts +224 -224
- package/src/blob-store.ts +25 -25
- package/src/command.ts +18 -18
- package/src/config/agent.ts +26 -26
- package/src/config/command.ts +14 -14
- package/src/config/compaction.ts +27 -27
- package/src/config/experimental.ts +72 -72
- package/src/config/flag.ts +39 -39
- package/src/config/formatter.ts +13 -13
- package/src/config/lsp.ts +19 -19
- package/src/config/mcp.ts +22 -22
- package/src/config/media.ts +15 -15
- package/src/config/model.ts +37 -37
- package/src/config/plugin.ts +14 -14
- package/src/config/policy.ts +57 -57
- package/src/config/provider.ts +122 -122
- package/src/config/reference.ts +23 -23
- package/src/config/shell.ts +10 -10
- package/src/config/tool-output.ts +9 -9
- package/src/config/warming.ts +21 -21
- package/src/config/watcher.ts +8 -8
- package/src/config/websearch.ts +17 -17
- package/src/config/worktree.ts +10 -10
- package/src/config.ts +149 -149
- package/src/connection.ts +38 -38
- package/src/credential-legacy.ts +29 -29
- package/src/credential.ts +78 -78
- package/src/durable-event-manifest.ts +7 -7
- package/src/event-log.ts +21 -21
- package/src/event-manifest.ts +108 -108
- package/src/event.ts +205 -205
- package/src/file-diff.ts +25 -25
- package/src/filesystem-v1.ts +1 -1
- package/src/filesystem.ts +48 -48
- package/src/form.ts +177 -177
- package/src/generate.ts +292 -292
- package/src/goal.ts +46 -46
- package/src/identifier.ts +32 -32
- package/src/index.ts +51 -51
- package/src/installation-event.ts +20 -20
- package/src/instruction-entry.ts +40 -40
- package/src/instruction.ts +25 -25
- package/src/integration-id.ts +13 -13
- package/src/integration.ts +129 -129
- package/src/job.ts +79 -79
- package/src/legacy-event.ts +1 -1
- package/src/llm.ts +6 -6
- package/src/location-event.ts +8 -8
- package/src/location.ts +36 -36
- package/src/lsp-event.ts +7 -7
- package/src/mcp-event.ts +63 -63
- package/src/mcp.ts +171 -171
- package/src/model-compatibility.ts +55 -55
- package/src/model.ts +176 -176
- package/src/models-dev.ts +9 -9
- package/src/money.ts +18 -18
- package/src/permission-saved.ts +25 -25
- package/src/permission-v1.ts +1 -1
- package/src/permission.ts +67 -67
- package/src/persistent-pty.ts +73 -73
- package/src/plugin.ts +62 -62
- package/src/project-id.ts +9 -9
- package/src/project.ts +62 -62
- package/src/prompt-input.ts +33 -33
- package/src/prompt.ts +117 -117
- package/src/provider.ts +136 -136
- package/src/pty-ticket.ts +10 -10
- package/src/pty.ts +61 -61
- package/src/push.ts +86 -86
- package/src/question.ts +22 -22
- package/src/reference.ts +40 -40
- package/src/rpc.ts +167 -167
- package/src/schema.ts +41 -41
- package/src/server-event.ts +8 -8
- package/src/session-error.ts +14 -14
- package/src/session-event.ts +739 -739
- package/src/session-fork.ts +10 -10
- package/src/session-id.ts +12 -12
- package/src/session-inbox.ts +102 -102
- package/src/session-legacy.ts +117 -117
- package/src/session-message.ts +352 -352
- package/src/session-metadata.ts +11 -11
- package/src/session-revert.ts +86 -86
- package/src/session-stats.ts +68 -68
- package/src/session-status-event.ts +53 -53
- package/src/session-transfer.ts +11 -11
- package/src/session-v1.ts +1 -1
- package/src/session.ts +147 -147
- package/src/shell.ts +90 -90
- package/src/skill.ts +68 -68
- package/src/snapshot.ts +6 -6
- package/src/token-usage.ts +18 -18
- package/src/tool.ts +143 -143
- package/src/tui-event.ts +59 -59
- package/src/usage-limits.ts +76 -76
- package/src/v1/filesystem.ts +11 -11
- package/src/v1/legacy-event.ts +18 -18
- package/src/v1/permission.ts +66 -66
- package/src/v1/session.ts +667 -667
- package/src/vcs-event.ts +14 -14
- package/src/vcs.ts +41 -41
- package/src/websearch.ts +44 -44
- package/src/workspace-event.ts +32 -32
- package/src/workspace-id.ts +19 -19
- package/src/workspace.ts +20 -20
- package/src/worktree-event.ts +22 -22
- package/src/worktree.ts +109 -109
- package/tsconfig.build.json +11 -11
- package/tsconfig.json +14 -14
- package/test/agent.test.ts +0 -10
- package/test/automation.test.ts +0 -48
- package/test/compatibility.test.ts +0 -10
- package/test/config.test.ts +0 -194
- package/test/contract-hygiene.test.ts +0 -352
- package/test/credential-legacy.test.ts +0 -55
- package/test/event-manifest.test.ts +0 -228
- package/test/event.test.ts +0 -52
- package/test/legacy-event.test.ts +0 -46
- package/test/mcp.test.ts +0 -37
- package/test/model.test.ts +0 -104
- package/test/session-cursor.test.ts +0 -16
- package/test/session-error.test.ts +0 -51
- package/test/session-legacy.test.ts +0 -178
- package/test/session-terminal.test.ts +0 -50
- package/test/token-usage.test.ts +0 -18
- package/test/v1-isolation.test.ts +0 -26
- package/test/vcs.test.ts +0 -23
- package/test/worktree.test.ts +0 -45
package/src/vcs-event.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export * as VcsEvent from "./vcs-event.js"
|
|
2
|
-
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { optional } from "./schema.js"
|
|
5
|
-
import { Event } from "./event.js"
|
|
6
|
-
|
|
7
|
-
export const BranchUpdated = Event.ephemeral({
|
|
8
|
-
type: "vcs.branch.updated",
|
|
9
|
-
schema: {
|
|
10
|
-
branch: optional(Schema.String),
|
|
11
|
-
},
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
export const Definitions = Event.inventory(BranchUpdated)
|
|
1
|
+
export * as VcsEvent from "./vcs-event.js"
|
|
2
|
+
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { optional } from "./schema.js"
|
|
5
|
+
import { Event } from "./event.js"
|
|
6
|
+
|
|
7
|
+
export const BranchUpdated = Event.ephemeral({
|
|
8
|
+
type: "vcs.branch.updated",
|
|
9
|
+
schema: {
|
|
10
|
+
branch: optional(Schema.String),
|
|
11
|
+
},
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
export const Definitions = Event.inventory(BranchUpdated)
|
package/src/vcs.ts
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
export * as Vcs from "./vcs.js"
|
|
2
|
-
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { NonNegativeInt, optional } from "./schema.js"
|
|
5
|
-
|
|
6
|
-
export const Branch = Schema.Struct({
|
|
7
|
-
current: optional(Schema.String),
|
|
8
|
-
default: optional(Schema.String),
|
|
9
|
-
}).annotate({ identifier: "Vcs.Branch" })
|
|
10
|
-
export interface Branch extends Schema.Schema.Type<typeof Branch> {}
|
|
11
|
-
|
|
12
|
-
export const Info = Schema.Struct({
|
|
13
|
-
provider: optional(Schema.String),
|
|
14
|
-
branch: Branch,
|
|
15
|
-
}).annotate({ identifier: "Vcs.Info" })
|
|
16
|
-
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
|
17
|
-
|
|
18
|
-
export const BranchList = Schema.Array(Schema.String).annotate({ identifier: "Vcs.BranchList" })
|
|
19
|
-
export type BranchList = typeof BranchList.Type
|
|
20
|
-
|
|
21
|
-
export const Base = Schema.Struct({
|
|
22
|
-
name: Schema.String,
|
|
23
|
-
ref: Schema.String,
|
|
24
|
-
source: Schema.Literals(["reflog", "default"]),
|
|
25
|
-
}).annotate({ identifier: "Vcs.Base" })
|
|
26
|
-
export interface Base extends Schema.Schema.Type<typeof Base> {}
|
|
27
|
-
|
|
28
|
-
export const Mode = Schema.Literals(["working", "branch", "committed"]).annotate({ identifier: "Vcs.Mode" })
|
|
29
|
-
export type Mode = typeof Mode.Type
|
|
30
|
-
|
|
31
|
-
/** How a diff lists untracked files: one by one, or each untracked folder as one `dir/` entry. */
|
|
32
|
-
export const Untracked = Schema.Literals(["files", "folders"]).annotate({ identifier: "Vcs.Untracked" })
|
|
33
|
-
export type Untracked = typeof Untracked.Type
|
|
34
|
-
|
|
35
|
-
export const FileStatus = Schema.Struct({
|
|
36
|
-
file: Schema.String,
|
|
37
|
-
additions: NonNegativeInt,
|
|
38
|
-
deletions: NonNegativeInt,
|
|
39
|
-
status: Schema.Literals(["added", "deleted", "modified"]),
|
|
40
|
-
}).annotate({ identifier: "Vcs.FileStatus" })
|
|
41
|
-
export interface FileStatus extends Schema.Schema.Type<typeof FileStatus> {}
|
|
1
|
+
export * as Vcs from "./vcs.js"
|
|
2
|
+
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { NonNegativeInt, optional } from "./schema.js"
|
|
5
|
+
|
|
6
|
+
export const Branch = Schema.Struct({
|
|
7
|
+
current: optional(Schema.String),
|
|
8
|
+
default: optional(Schema.String),
|
|
9
|
+
}).annotate({ identifier: "Vcs.Branch" })
|
|
10
|
+
export interface Branch extends Schema.Schema.Type<typeof Branch> {}
|
|
11
|
+
|
|
12
|
+
export const Info = Schema.Struct({
|
|
13
|
+
provider: optional(Schema.String),
|
|
14
|
+
branch: Branch,
|
|
15
|
+
}).annotate({ identifier: "Vcs.Info" })
|
|
16
|
+
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
|
17
|
+
|
|
18
|
+
export const BranchList = Schema.Array(Schema.String).annotate({ identifier: "Vcs.BranchList" })
|
|
19
|
+
export type BranchList = typeof BranchList.Type
|
|
20
|
+
|
|
21
|
+
export const Base = Schema.Struct({
|
|
22
|
+
name: Schema.String,
|
|
23
|
+
ref: Schema.String,
|
|
24
|
+
source: Schema.Literals(["reflog", "default"]),
|
|
25
|
+
}).annotate({ identifier: "Vcs.Base" })
|
|
26
|
+
export interface Base extends Schema.Schema.Type<typeof Base> {}
|
|
27
|
+
|
|
28
|
+
export const Mode = Schema.Literals(["working", "branch", "committed"]).annotate({ identifier: "Vcs.Mode" })
|
|
29
|
+
export type Mode = typeof Mode.Type
|
|
30
|
+
|
|
31
|
+
/** How a diff lists untracked files: one by one, or each untracked folder as one `dir/` entry. */
|
|
32
|
+
export const Untracked = Schema.Literals(["files", "folders"]).annotate({ identifier: "Vcs.Untracked" })
|
|
33
|
+
export type Untracked = typeof Untracked.Type
|
|
34
|
+
|
|
35
|
+
export const FileStatus = Schema.Struct({
|
|
36
|
+
file: Schema.String,
|
|
37
|
+
additions: NonNegativeInt,
|
|
38
|
+
deletions: NonNegativeInt,
|
|
39
|
+
status: Schema.Literals(["added", "deleted", "modified"]),
|
|
40
|
+
}).annotate({ identifier: "Vcs.FileStatus" })
|
|
41
|
+
export interface FileStatus extends Schema.Schema.Type<typeof FileStatus> {}
|
package/src/websearch.ts
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
export * as WebSearch from "./websearch.js"
|
|
2
|
-
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { ephemeral, inventory } from "./event.js"
|
|
5
|
-
import { optional } from "./schema.js"
|
|
6
|
-
|
|
7
|
-
export const ID = Schema.String.pipe(Schema.brand("WebSearch.ID"), Schema.annotate({ identifier: "WebSearch.ID" }))
|
|
8
|
-
export type ID = typeof ID.Type
|
|
9
|
-
|
|
10
|
-
export interface Provider extends Schema.Schema.Type<typeof Provider> {}
|
|
11
|
-
export const Provider = Schema.Struct({
|
|
12
|
-
id: ID,
|
|
13
|
-
name: Schema.String,
|
|
14
|
-
}).annotate({ identifier: "WebSearch.Provider" })
|
|
15
|
-
|
|
16
|
-
export interface Input extends Schema.Schema.Type<typeof Input> {}
|
|
17
|
-
export const Input = Schema.Struct({
|
|
18
|
-
query: Schema.String,
|
|
19
|
-
providerID: ID.pipe(optional),
|
|
20
|
-
}).annotate({ identifier: "WebSearch.Input" })
|
|
21
|
-
export type ProviderInput = Pick<Input, "query">
|
|
22
|
-
|
|
23
|
-
export interface Result extends Schema.Schema.Type<typeof Result> {}
|
|
24
|
-
export const Result = Schema.Struct({
|
|
25
|
-
url: Schema.String,
|
|
26
|
-
title: Schema.String.pipe(optional),
|
|
27
|
-
content: Schema.String.pipe(optional),
|
|
28
|
-
time: Schema.Struct({
|
|
29
|
-
published: Schema.Finite.pipe(optional).annotate({
|
|
30
|
-
description: "Publication time in milliseconds since the Unix epoch",
|
|
31
|
-
}),
|
|
32
|
-
}),
|
|
33
|
-
}).annotate({ identifier: "WebSearch.Result" })
|
|
34
|
-
|
|
35
|
-
export class Response extends Schema.Class<Response>("WebSearch.Response")({
|
|
36
|
-
providerID: ID,
|
|
37
|
-
results: Schema.Array(Result),
|
|
38
|
-
}) {}
|
|
39
|
-
|
|
40
|
-
const Updated = ephemeral({
|
|
41
|
-
type: "websearch.updated",
|
|
42
|
-
schema: {},
|
|
43
|
-
})
|
|
44
|
-
export const Event = { Updated, Definitions: inventory(Updated) }
|
|
1
|
+
export * as WebSearch from "./websearch.js"
|
|
2
|
+
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { ephemeral, inventory } from "./event.js"
|
|
5
|
+
import { optional } from "./schema.js"
|
|
6
|
+
|
|
7
|
+
export const ID = Schema.String.pipe(Schema.brand("WebSearch.ID"), Schema.annotate({ identifier: "WebSearch.ID" }))
|
|
8
|
+
export type ID = typeof ID.Type
|
|
9
|
+
|
|
10
|
+
export interface Provider extends Schema.Schema.Type<typeof Provider> {}
|
|
11
|
+
export const Provider = Schema.Struct({
|
|
12
|
+
id: ID,
|
|
13
|
+
name: Schema.String,
|
|
14
|
+
}).annotate({ identifier: "WebSearch.Provider" })
|
|
15
|
+
|
|
16
|
+
export interface Input extends Schema.Schema.Type<typeof Input> {}
|
|
17
|
+
export const Input = Schema.Struct({
|
|
18
|
+
query: Schema.String,
|
|
19
|
+
providerID: ID.pipe(optional),
|
|
20
|
+
}).annotate({ identifier: "WebSearch.Input" })
|
|
21
|
+
export type ProviderInput = Pick<Input, "query">
|
|
22
|
+
|
|
23
|
+
export interface Result extends Schema.Schema.Type<typeof Result> {}
|
|
24
|
+
export const Result = Schema.Struct({
|
|
25
|
+
url: Schema.String,
|
|
26
|
+
title: Schema.String.pipe(optional),
|
|
27
|
+
content: Schema.String.pipe(optional),
|
|
28
|
+
time: Schema.Struct({
|
|
29
|
+
published: Schema.Finite.pipe(optional).annotate({
|
|
30
|
+
description: "Publication time in milliseconds since the Unix epoch",
|
|
31
|
+
}),
|
|
32
|
+
}),
|
|
33
|
+
}).annotate({ identifier: "WebSearch.Result" })
|
|
34
|
+
|
|
35
|
+
export class Response extends Schema.Class<Response>("WebSearch.Response")({
|
|
36
|
+
providerID: ID,
|
|
37
|
+
results: Schema.Array(Result),
|
|
38
|
+
}) {}
|
|
39
|
+
|
|
40
|
+
const Updated = ephemeral({
|
|
41
|
+
type: "websearch.updated",
|
|
42
|
+
schema: {},
|
|
43
|
+
})
|
|
44
|
+
export const Event = { Updated, Definitions: inventory(Updated) }
|
package/src/workspace-event.ts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
export * as WorkspaceEvent from "./workspace-event.js"
|
|
2
|
-
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { Event } from "./event.js"
|
|
5
|
-
import { WorkspaceID } from "./workspace-id.js"
|
|
6
|
-
|
|
7
|
-
export const ConnectionStatus = Schema.Struct({
|
|
8
|
-
workspaceID: WorkspaceID,
|
|
9
|
-
status: Schema.Literals(["connected", "connecting", "disconnected", "error"]),
|
|
10
|
-
}).annotate({ identifier: "WorkspaceEvent.ConnectionStatus" })
|
|
11
|
-
export interface ConnectionStatus extends Schema.Schema.Type<typeof ConnectionStatus> {}
|
|
12
|
-
|
|
13
|
-
export const Ready = Event.ephemeral({
|
|
14
|
-
type: "workspace.ready",
|
|
15
|
-
schema: {
|
|
16
|
-
name: Schema.String,
|
|
17
|
-
},
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
export const Failed = Event.ephemeral({
|
|
21
|
-
type: "workspace.failed",
|
|
22
|
-
schema: {
|
|
23
|
-
message: Schema.String,
|
|
24
|
-
},
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
export const Status = Event.ephemeral({
|
|
28
|
-
type: "workspace.status",
|
|
29
|
-
schema: ConnectionStatus.fields,
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
export const Definitions = Event.inventory(Ready, Failed, Status)
|
|
1
|
+
export * as WorkspaceEvent from "./workspace-event.js"
|
|
2
|
+
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { Event } from "./event.js"
|
|
5
|
+
import { WorkspaceID } from "./workspace-id.js"
|
|
6
|
+
|
|
7
|
+
export const ConnectionStatus = Schema.Struct({
|
|
8
|
+
workspaceID: WorkspaceID,
|
|
9
|
+
status: Schema.Literals(["connected", "connecting", "disconnected", "error"]),
|
|
10
|
+
}).annotate({ identifier: "WorkspaceEvent.ConnectionStatus" })
|
|
11
|
+
export interface ConnectionStatus extends Schema.Schema.Type<typeof ConnectionStatus> {}
|
|
12
|
+
|
|
13
|
+
export const Ready = Event.ephemeral({
|
|
14
|
+
type: "workspace.ready",
|
|
15
|
+
schema: {
|
|
16
|
+
name: Schema.String,
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
export const Failed = Event.ephemeral({
|
|
21
|
+
type: "workspace.failed",
|
|
22
|
+
schema: {
|
|
23
|
+
message: Schema.String,
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
export const Status = Event.ephemeral({
|
|
28
|
+
type: "workspace.status",
|
|
29
|
+
schema: ConnectionStatus.fields,
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
export const Definitions = Event.inventory(Ready, Failed, Status)
|
package/src/workspace-id.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { Schema } from "effect"
|
|
2
|
-
import { ascending } from "./identifier.js"
|
|
3
|
-
import { statics } from "./schema.js"
|
|
4
|
-
|
|
5
|
-
export const WorkspaceID = Schema.String.check(Schema.isStartingWith("wrk")).pipe(
|
|
6
|
-
Schema.brand("Workspace.ID"),
|
|
7
|
-
Schema.annotate({ identifier: "Workspace.ID" }),
|
|
8
|
-
statics((schema) => {
|
|
9
|
-
const create = () => schema.make("wrk_" + ascending())
|
|
10
|
-
return {
|
|
11
|
-
ascending: (id?: string) => {
|
|
12
|
-
if (!id) return create()
|
|
13
|
-
return schema.make(id)
|
|
14
|
-
},
|
|
15
|
-
create,
|
|
16
|
-
}
|
|
17
|
-
}),
|
|
18
|
-
)
|
|
19
|
-
export type WorkspaceID = typeof WorkspaceID.Type
|
|
1
|
+
import { Schema } from "effect"
|
|
2
|
+
import { ascending } from "./identifier.js"
|
|
3
|
+
import { statics } from "./schema.js"
|
|
4
|
+
|
|
5
|
+
export const WorkspaceID = Schema.String.check(Schema.isStartingWith("wrk")).pipe(
|
|
6
|
+
Schema.brand("Workspace.ID"),
|
|
7
|
+
Schema.annotate({ identifier: "Workspace.ID" }),
|
|
8
|
+
statics((schema) => {
|
|
9
|
+
const create = () => schema.make("wrk_" + ascending())
|
|
10
|
+
return {
|
|
11
|
+
ascending: (id?: string) => {
|
|
12
|
+
if (!id) return create()
|
|
13
|
+
return schema.make(id)
|
|
14
|
+
},
|
|
15
|
+
create,
|
|
16
|
+
}
|
|
17
|
+
}),
|
|
18
|
+
)
|
|
19
|
+
export type WorkspaceID = typeof WorkspaceID.Type
|
package/src/workspace.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export * as Workspace from "./workspace.js"
|
|
2
|
-
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { WorkspaceEvent } from "./workspace-event.js"
|
|
5
|
-
import { WorkspaceID } from "./workspace-id.js"
|
|
6
|
-
|
|
7
|
-
export const ID = WorkspaceID
|
|
8
|
-
export type ID = WorkspaceID
|
|
9
|
-
|
|
10
|
-
export const DestroyResult = Schema.Struct({
|
|
11
|
-
destroyed: Schema.Boolean.annotate({
|
|
12
|
-
description: "True when this request transitioned the workspace from existing to destroyed.",
|
|
13
|
-
}),
|
|
14
|
-
}).annotate({
|
|
15
|
-
identifier: "WorkspaceDestroyResult",
|
|
16
|
-
description: "Reports whether this request destroyed an existing workspace.",
|
|
17
|
-
})
|
|
18
|
-
export interface DestroyResult extends Schema.Schema.Type<typeof DestroyResult> {}
|
|
19
|
-
|
|
20
|
-
export const Event = WorkspaceEvent
|
|
1
|
+
export * as Workspace from "./workspace.js"
|
|
2
|
+
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { WorkspaceEvent } from "./workspace-event.js"
|
|
5
|
+
import { WorkspaceID } from "./workspace-id.js"
|
|
6
|
+
|
|
7
|
+
export const ID = WorkspaceID
|
|
8
|
+
export type ID = WorkspaceID
|
|
9
|
+
|
|
10
|
+
export const DestroyResult = Schema.Struct({
|
|
11
|
+
destroyed: Schema.Boolean.annotate({
|
|
12
|
+
description: "True when this request transitioned the workspace from existing to destroyed.",
|
|
13
|
+
}),
|
|
14
|
+
}).annotate({
|
|
15
|
+
identifier: "WorkspaceDestroyResult",
|
|
16
|
+
description: "Reports whether this request destroyed an existing workspace.",
|
|
17
|
+
})
|
|
18
|
+
export interface DestroyResult extends Schema.Schema.Type<typeof DestroyResult> {}
|
|
19
|
+
|
|
20
|
+
export const Event = WorkspaceEvent
|
package/src/worktree-event.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
export * as WorktreeEvent from "./worktree-event.js"
|
|
2
|
-
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { optional } from "./schema.js"
|
|
5
|
-
import { Event } from "./event.js"
|
|
6
|
-
|
|
7
|
-
export const Ready = Event.ephemeral({
|
|
8
|
-
type: "worktree.ready",
|
|
9
|
-
schema: {
|
|
10
|
-
name: Schema.String,
|
|
11
|
-
branch: optional(Schema.String),
|
|
12
|
-
},
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
export const Failed = Event.ephemeral({
|
|
16
|
-
type: "worktree.failed",
|
|
17
|
-
schema: {
|
|
18
|
-
message: Schema.String,
|
|
19
|
-
},
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
export const Definitions = Event.inventory(Ready, Failed)
|
|
1
|
+
export * as WorktreeEvent from "./worktree-event.js"
|
|
2
|
+
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { optional } from "./schema.js"
|
|
5
|
+
import { Event } from "./event.js"
|
|
6
|
+
|
|
7
|
+
export const Ready = Event.ephemeral({
|
|
8
|
+
type: "worktree.ready",
|
|
9
|
+
schema: {
|
|
10
|
+
name: Schema.String,
|
|
11
|
+
branch: optional(Schema.String),
|
|
12
|
+
},
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
export const Failed = Event.ephemeral({
|
|
16
|
+
type: "worktree.failed",
|
|
17
|
+
schema: {
|
|
18
|
+
message: Schema.String,
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
export const Definitions = Event.inventory(Ready, Failed)
|
package/src/worktree.ts
CHANGED
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
export * as Worktree from "./worktree.js"
|
|
2
|
-
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { durable, ephemeral, inventory } from "./event.js"
|
|
5
|
-
import { AbsolutePath, optional } from "./schema.js"
|
|
6
|
-
import { Project } from "./project.js"
|
|
7
|
-
|
|
8
|
-
export const StrategyID = Schema.Trim.pipe(Schema.check(Schema.isNonEmpty()), Schema.brand("Worktree.StrategyID"))
|
|
9
|
-
export type StrategyID = typeof StrategyID.Type
|
|
10
|
-
|
|
11
|
-
export const CreateInput = Schema.Struct({
|
|
12
|
-
projectID: Project.ID,
|
|
13
|
-
from: optional(AbsolutePath),
|
|
14
|
-
branch: optional(Schema.Trim.pipe(Schema.check(Schema.isNonEmpty()))),
|
|
15
|
-
directory: optional(AbsolutePath).annotate({
|
|
16
|
-
description:
|
|
17
|
-
"Parent directory for the new worktree. Uses the project's canonical configuration, then defaults to the server's data directory under worktree/<first six project ID characters>.",
|
|
18
|
-
}),
|
|
19
|
-
name: optional(Schema.String),
|
|
20
|
-
}).annotate({ identifier: "Worktree.CreateInput" })
|
|
21
|
-
export interface CreateInput extends Schema.Schema.Type<typeof CreateInput> {}
|
|
22
|
-
|
|
23
|
-
export const RemoveInput = Schema.Struct({
|
|
24
|
-
projectID: Project.ID,
|
|
25
|
-
directory: AbsolutePath,
|
|
26
|
-
force: Schema.Boolean,
|
|
27
|
-
}).annotate({ identifier: "Worktree.RemoveInput" })
|
|
28
|
-
export interface RemoveInput extends Schema.Schema.Type<typeof RemoveInput> {}
|
|
29
|
-
|
|
30
|
-
export const Info = Schema.Struct({
|
|
31
|
-
directory: AbsolutePath,
|
|
32
|
-
}).annotate({ identifier: "Worktree.Info" })
|
|
33
|
-
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
|
34
|
-
|
|
35
|
-
export const Directory = Schema.Struct({
|
|
36
|
-
directory: AbsolutePath,
|
|
37
|
-
strategy: optional(Schema.String),
|
|
38
|
-
}).annotate({ identifier: "Worktree.Directory" })
|
|
39
|
-
export interface Directory extends Schema.Schema.Type<typeof Directory> {}
|
|
40
|
-
|
|
41
|
-
export const ListEntry = Schema.Struct({
|
|
42
|
-
directory: AbsolutePath,
|
|
43
|
-
type: Schema.Literals(["root", "worktree"]),
|
|
44
|
-
}).annotate({ identifier: "Worktree.ListEntry" })
|
|
45
|
-
export interface ListEntry extends Schema.Schema.Type<typeof ListEntry> {}
|
|
46
|
-
|
|
47
|
-
export class OperationError extends Schema.TaggedError<OperationError>()("Worktree.OperationError", {
|
|
48
|
-
message: Schema.String,
|
|
49
|
-
forceRequired: optional(Schema.Boolean),
|
|
50
|
-
}) {}
|
|
51
|
-
|
|
52
|
-
export const List = Schema.Array(Directory).annotate({ identifier: "Worktree.List" })
|
|
53
|
-
export type List = typeof List.Type
|
|
54
|
-
|
|
55
|
-
const Updated = ephemeral({
|
|
56
|
-
type: "worktree.updated",
|
|
57
|
-
schema: { projectID: Project.ID },
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
const Resolved = durable({
|
|
61
|
-
type: "worktree.resolved",
|
|
62
|
-
durable: { aggregate: "projectID", version: 1 },
|
|
63
|
-
schema: {
|
|
64
|
-
projectID: Project.ID,
|
|
65
|
-
directory: AbsolutePath,
|
|
66
|
-
previous: Project.ID,
|
|
67
|
-
adopted: optional(Schema.Array(Project.ID)),
|
|
68
|
-
},
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
export const Event = { Updated, Resolved, Definitions: inventory(Updated, Resolved) }
|
|
72
|
-
|
|
73
|
-
export function adopt(
|
|
74
|
-
session: { readonly projectID: string; readonly directory: string; readonly workspaceID?: string },
|
|
75
|
-
event: {
|
|
76
|
-
readonly projectID: string
|
|
77
|
-
readonly directory: string
|
|
78
|
-
readonly previous: string
|
|
79
|
-
readonly adopted?: ReadonlyArray<string>
|
|
80
|
-
},
|
|
81
|
-
) {
|
|
82
|
-
if (session.workspaceID) return
|
|
83
|
-
if (
|
|
84
|
-
session.projectID !== event.previous &&
|
|
85
|
-
session.projectID !== Project.ID.global &&
|
|
86
|
-
!event.adopted?.includes(session.projectID)
|
|
87
|
-
)
|
|
88
|
-
return
|
|
89
|
-
if (session.projectID === event.projectID) return
|
|
90
|
-
const normalize = (value: string) =>
|
|
91
|
-
value
|
|
92
|
-
.replaceAll("\\", "/")
|
|
93
|
-
.split("/")
|
|
94
|
-
.reduce((result, segment) => {
|
|
95
|
-
if (!segment || segment === ".") return result
|
|
96
|
-
if (segment === "..") return result.slice(0, result.lastIndexOf("/"))
|
|
97
|
-
return `${result}/${segment}`
|
|
98
|
-
}, "")
|
|
99
|
-
const directory = normalize(session.directory)
|
|
100
|
-
const root = normalize(event.directory)
|
|
101
|
-
const windows = /^\/[a-z]:/i.test(root)
|
|
102
|
-
const key = windows ? directory.toLowerCase() : directory
|
|
103
|
-
const parent = windows ? root.toLowerCase() : root
|
|
104
|
-
if (key !== parent && !key.startsWith(parent + "/")) return
|
|
105
|
-
return {
|
|
106
|
-
projectID: event.projectID,
|
|
107
|
-
subpath: key === parent ? undefined : directory.slice(root.length + 1),
|
|
108
|
-
}
|
|
109
|
-
}
|
|
1
|
+
export * as Worktree from "./worktree.js"
|
|
2
|
+
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { durable, ephemeral, inventory } from "./event.js"
|
|
5
|
+
import { AbsolutePath, optional } from "./schema.js"
|
|
6
|
+
import { Project } from "./project.js"
|
|
7
|
+
|
|
8
|
+
export const StrategyID = Schema.Trim.pipe(Schema.check(Schema.isNonEmpty()), Schema.brand("Worktree.StrategyID"))
|
|
9
|
+
export type StrategyID = typeof StrategyID.Type
|
|
10
|
+
|
|
11
|
+
export const CreateInput = Schema.Struct({
|
|
12
|
+
projectID: Project.ID,
|
|
13
|
+
from: optional(AbsolutePath),
|
|
14
|
+
branch: optional(Schema.Trim.pipe(Schema.check(Schema.isNonEmpty()))),
|
|
15
|
+
directory: optional(AbsolutePath).annotate({
|
|
16
|
+
description:
|
|
17
|
+
"Parent directory for the new worktree. Uses the project's canonical configuration, then defaults to the server's data directory under worktree/<first six project ID characters>.",
|
|
18
|
+
}),
|
|
19
|
+
name: optional(Schema.String),
|
|
20
|
+
}).annotate({ identifier: "Worktree.CreateInput" })
|
|
21
|
+
export interface CreateInput extends Schema.Schema.Type<typeof CreateInput> {}
|
|
22
|
+
|
|
23
|
+
export const RemoveInput = Schema.Struct({
|
|
24
|
+
projectID: Project.ID,
|
|
25
|
+
directory: AbsolutePath,
|
|
26
|
+
force: Schema.Boolean,
|
|
27
|
+
}).annotate({ identifier: "Worktree.RemoveInput" })
|
|
28
|
+
export interface RemoveInput extends Schema.Schema.Type<typeof RemoveInput> {}
|
|
29
|
+
|
|
30
|
+
export const Info = Schema.Struct({
|
|
31
|
+
directory: AbsolutePath,
|
|
32
|
+
}).annotate({ identifier: "Worktree.Info" })
|
|
33
|
+
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
|
34
|
+
|
|
35
|
+
export const Directory = Schema.Struct({
|
|
36
|
+
directory: AbsolutePath,
|
|
37
|
+
strategy: optional(Schema.String),
|
|
38
|
+
}).annotate({ identifier: "Worktree.Directory" })
|
|
39
|
+
export interface Directory extends Schema.Schema.Type<typeof Directory> {}
|
|
40
|
+
|
|
41
|
+
export const ListEntry = Schema.Struct({
|
|
42
|
+
directory: AbsolutePath,
|
|
43
|
+
type: Schema.Literals(["root", "worktree"]),
|
|
44
|
+
}).annotate({ identifier: "Worktree.ListEntry" })
|
|
45
|
+
export interface ListEntry extends Schema.Schema.Type<typeof ListEntry> {}
|
|
46
|
+
|
|
47
|
+
export class OperationError extends Schema.TaggedError<OperationError>()("Worktree.OperationError", {
|
|
48
|
+
message: Schema.String,
|
|
49
|
+
forceRequired: optional(Schema.Boolean),
|
|
50
|
+
}) {}
|
|
51
|
+
|
|
52
|
+
export const List = Schema.Array(Directory).annotate({ identifier: "Worktree.List" })
|
|
53
|
+
export type List = typeof List.Type
|
|
54
|
+
|
|
55
|
+
const Updated = ephemeral({
|
|
56
|
+
type: "worktree.updated",
|
|
57
|
+
schema: { projectID: Project.ID },
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
const Resolved = durable({
|
|
61
|
+
type: "worktree.resolved",
|
|
62
|
+
durable: { aggregate: "projectID", version: 1 },
|
|
63
|
+
schema: {
|
|
64
|
+
projectID: Project.ID,
|
|
65
|
+
directory: AbsolutePath,
|
|
66
|
+
previous: Project.ID,
|
|
67
|
+
adopted: optional(Schema.Array(Project.ID)),
|
|
68
|
+
},
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
export const Event = { Updated, Resolved, Definitions: inventory(Updated, Resolved) }
|
|
72
|
+
|
|
73
|
+
export function adopt(
|
|
74
|
+
session: { readonly projectID: string; readonly directory: string; readonly workspaceID?: string },
|
|
75
|
+
event: {
|
|
76
|
+
readonly projectID: string
|
|
77
|
+
readonly directory: string
|
|
78
|
+
readonly previous: string
|
|
79
|
+
readonly adopted?: ReadonlyArray<string>
|
|
80
|
+
},
|
|
81
|
+
) {
|
|
82
|
+
if (session.workspaceID) return
|
|
83
|
+
if (
|
|
84
|
+
session.projectID !== event.previous &&
|
|
85
|
+
session.projectID !== Project.ID.global &&
|
|
86
|
+
!event.adopted?.includes(session.projectID)
|
|
87
|
+
)
|
|
88
|
+
return
|
|
89
|
+
if (session.projectID === event.projectID) return
|
|
90
|
+
const normalize = (value: string) =>
|
|
91
|
+
value
|
|
92
|
+
.replaceAll("\\", "/")
|
|
93
|
+
.split("/")
|
|
94
|
+
.reduce((result, segment) => {
|
|
95
|
+
if (!segment || segment === ".") return result
|
|
96
|
+
if (segment === "..") return result.slice(0, result.lastIndexOf("/"))
|
|
97
|
+
return `${result}/${segment}`
|
|
98
|
+
}, "")
|
|
99
|
+
const directory = normalize(session.directory)
|
|
100
|
+
const root = normalize(event.directory)
|
|
101
|
+
const windows = /^\/[a-z]:/i.test(root)
|
|
102
|
+
const key = windows ? directory.toLowerCase() : directory
|
|
103
|
+
const parent = windows ? root.toLowerCase() : root
|
|
104
|
+
if (key !== parent && !key.startsWith(parent + "/")) return
|
|
105
|
+
return {
|
|
106
|
+
projectID: event.projectID,
|
|
107
|
+
subpath: key === parent ? undefined : directory.slice(root.length + 1),
|
|
108
|
+
}
|
|
109
|
+
}
|
package/tsconfig.build.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
-
"extends": "./tsconfig.json",
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"rootDir": "src",
|
|
6
|
-
"outDir": "dist",
|
|
7
|
-
"noEmit": false,
|
|
8
|
-
"declaration": true
|
|
9
|
-
},
|
|
10
|
-
"include": ["src"]
|
|
11
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"extends": "./tsconfig.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"rootDir": "src",
|
|
6
|
+
"outDir": "dist",
|
|
7
|
+
"noEmit": false,
|
|
8
|
+
"declaration": true
|
|
9
|
+
},
|
|
10
|
+
"include": ["src"]
|
|
11
|
+
}
|