mirror of
https://github.com/openai/codex.git
synced 2026-12-02 00:31:03 +00:00
refactor(worktree): route interactive flow through app-server
This commit is contained in:
Generated
+1
@@ -1896,6 +1896,7 @@ dependencies = [
|
||||
"codex-utils-cli",
|
||||
"codex-utils-json-to-toml",
|
||||
"codex-utils-pty",
|
||||
"codex-worktree",
|
||||
"core_test_support",
|
||||
"flate2",
|
||||
"futures",
|
||||
|
||||
@@ -4564,6 +4564,97 @@
|
||||
"mode"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeCreateParams": {
|
||||
"description": "Create or reuse a managed worktree from the repository containing \\`cwd\\`.",
|
||||
"properties": {
|
||||
"baseRef": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"branch": {
|
||||
"type": "string"
|
||||
},
|
||||
"cwd": {
|
||||
"description": "Repository-relative workspace cwd to use as the source checkout.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"dirtyPolicy": {
|
||||
"$ref": "#/definitions/WorktreeDirtyPolicy"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"branch",
|
||||
"dirtyPolicy"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeDirtyPolicy": {
|
||||
"enum": [
|
||||
"fail",
|
||||
"ignore",
|
||||
"copyTracked",
|
||||
"copyAll",
|
||||
"moveTracked",
|
||||
"moveAll"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"WorktreeInspectSourceParams": {
|
||||
"description": "Inspect dirty state for the repository containing \\`cwd\\`.",
|
||||
"properties": {
|
||||
"cwd": {
|
||||
"description": "Repository-relative workspace cwd to inspect. Omitted uses app-server's effective cwd.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeListParams": {
|
||||
"description": "Request the managed worktrees associated with the repository containing \\`cwd\\`.",
|
||||
"properties": {
|
||||
"cwd": {
|
||||
"description": "Repository-relative workspace cwd to inspect. Omitted uses app-server's effective cwd.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeRemoveParams": {
|
||||
"description": "Remove a managed worktree in the repository containing \\`cwd\\`.",
|
||||
"properties": {
|
||||
"cwd": {
|
||||
"description": "Repository-relative workspace cwd to use when resolving \\`name_or_path\\`.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"deleteBranch": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"force": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"nameOrPath": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"nameOrPath"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"description": "Request from the client to the server.",
|
||||
@@ -5578,6 +5669,102 @@
|
||||
"title": "Fs/unwatchRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
"$ref": "#/definitions/RequestId"
|
||||
},
|
||||
"method": {
|
||||
"enum": [
|
||||
"worktree/list"
|
||||
],
|
||||
"title": "Worktree/listRequestMethod",
|
||||
"type": "string"
|
||||
},
|
||||
"params": {
|
||||
"$ref": "#/definitions/WorktreeListParams"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"title": "Worktree/listRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
"$ref": "#/definitions/RequestId"
|
||||
},
|
||||
"method": {
|
||||
"enum": [
|
||||
"worktree/inspectSource"
|
||||
],
|
||||
"title": "Worktree/inspectSourceRequestMethod",
|
||||
"type": "string"
|
||||
},
|
||||
"params": {
|
||||
"$ref": "#/definitions/WorktreeInspectSourceParams"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"title": "Worktree/inspectSourceRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
"$ref": "#/definitions/RequestId"
|
||||
},
|
||||
"method": {
|
||||
"enum": [
|
||||
"worktree/create"
|
||||
],
|
||||
"title": "Worktree/createRequestMethod",
|
||||
"type": "string"
|
||||
},
|
||||
"params": {
|
||||
"$ref": "#/definitions/WorktreeCreateParams"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"title": "Worktree/createRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
"$ref": "#/definitions/RequestId"
|
||||
},
|
||||
"method": {
|
||||
"enum": [
|
||||
"worktree/remove"
|
||||
],
|
||||
"title": "Worktree/removeRequestMethod",
|
||||
"type": "string"
|
||||
},
|
||||
"params": {
|
||||
"$ref": "#/definitions/WorktreeRemoveParams"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"title": "Worktree/removeRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
|
||||
+396
@@ -1194,6 +1194,102 @@
|
||||
"title": "Fs/unwatchRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
"$ref": "#/definitions/v2/RequestId"
|
||||
},
|
||||
"method": {
|
||||
"enum": [
|
||||
"worktree/list"
|
||||
],
|
||||
"title": "Worktree/listRequestMethod",
|
||||
"type": "string"
|
||||
},
|
||||
"params": {
|
||||
"$ref": "#/definitions/v2/WorktreeListParams"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"title": "Worktree/listRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
"$ref": "#/definitions/v2/RequestId"
|
||||
},
|
||||
"method": {
|
||||
"enum": [
|
||||
"worktree/inspectSource"
|
||||
],
|
||||
"title": "Worktree/inspectSourceRequestMethod",
|
||||
"type": "string"
|
||||
},
|
||||
"params": {
|
||||
"$ref": "#/definitions/v2/WorktreeInspectSourceParams"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"title": "Worktree/inspectSourceRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
"$ref": "#/definitions/v2/RequestId"
|
||||
},
|
||||
"method": {
|
||||
"enum": [
|
||||
"worktree/create"
|
||||
],
|
||||
"title": "Worktree/createRequestMethod",
|
||||
"type": "string"
|
||||
},
|
||||
"params": {
|
||||
"$ref": "#/definitions/v2/WorktreeCreateParams"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"title": "Worktree/createRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
"$ref": "#/definitions/v2/RequestId"
|
||||
},
|
||||
"method": {
|
||||
"enum": [
|
||||
"worktree/remove"
|
||||
],
|
||||
"title": "Worktree/removeRequestMethod",
|
||||
"type": "string"
|
||||
},
|
||||
"params": {
|
||||
"$ref": "#/definitions/v2/WorktreeRemoveParams"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"title": "Worktree/removeRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
@@ -18653,6 +18749,306 @@
|
||||
"title": "WindowsWorldWritableWarningNotification",
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeCreateParams": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "Create or reuse a managed worktree from the repository containing \\`cwd\\`.",
|
||||
"properties": {
|
||||
"baseRef": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"branch": {
|
||||
"type": "string"
|
||||
},
|
||||
"cwd": {
|
||||
"description": "Repository-relative workspace cwd to use as the source checkout.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"dirtyPolicy": {
|
||||
"$ref": "#/definitions/v2/WorktreeDirtyPolicy"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"branch",
|
||||
"dirtyPolicy"
|
||||
],
|
||||
"title": "WorktreeCreateParams",
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeCreateResponse": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "Result returned by \\`worktree/create\\`.",
|
||||
"properties": {
|
||||
"info": {
|
||||
"$ref": "#/definitions/v2/WorktreeInfo"
|
||||
},
|
||||
"reused": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"warnings": {
|
||||
"items": {
|
||||
"$ref": "#/definitions/v2/WorktreeWarning"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"info",
|
||||
"reused",
|
||||
"warnings"
|
||||
],
|
||||
"title": "WorktreeCreateResponse",
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeDirtyPolicy": {
|
||||
"enum": [
|
||||
"fail",
|
||||
"ignore",
|
||||
"copyTracked",
|
||||
"copyAll",
|
||||
"moveTracked",
|
||||
"moveAll"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"WorktreeDirtyState": {
|
||||
"properties": {
|
||||
"hasStagedChanges": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hasUnstagedChanges": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hasUntrackedFiles": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"hasStagedChanges",
|
||||
"hasUnstagedChanges",
|
||||
"hasUntrackedFiles"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeInfo": {
|
||||
"description": "Server-native representation of a managed worktree.",
|
||||
"properties": {
|
||||
"branch": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"commonGitDir": {
|
||||
"type": "string"
|
||||
},
|
||||
"dirty": {
|
||||
"$ref": "#/definitions/v2/WorktreeDirtyState"
|
||||
},
|
||||
"head": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"location": {
|
||||
"$ref": "#/definitions/v2/WorktreeLocation"
|
||||
},
|
||||
"metadataPath": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"originalRelativeCwd": {
|
||||
"type": "string"
|
||||
},
|
||||
"ownerThreadId": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"repoName": {
|
||||
"type": "string"
|
||||
},
|
||||
"repoRoot": {
|
||||
"type": "string"
|
||||
},
|
||||
"slug": {
|
||||
"type": "string"
|
||||
},
|
||||
"source": {
|
||||
"$ref": "#/definitions/v2/WorktreeSource"
|
||||
},
|
||||
"workspaceCwd": {
|
||||
"type": "string"
|
||||
},
|
||||
"worktreeGitRoot": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"commonGitDir",
|
||||
"dirty",
|
||||
"id",
|
||||
"location",
|
||||
"metadataPath",
|
||||
"name",
|
||||
"originalRelativeCwd",
|
||||
"repoName",
|
||||
"repoRoot",
|
||||
"slug",
|
||||
"source",
|
||||
"workspaceCwd",
|
||||
"worktreeGitRoot"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeInspectSourceParams": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "Inspect dirty state for the repository containing \\`cwd\\`.",
|
||||
"properties": {
|
||||
"cwd": {
|
||||
"description": "Repository-relative workspace cwd to inspect. Omitted uses app-server's effective cwd.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"title": "WorktreeInspectSourceParams",
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeInspectSourceResponse": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "Dirty-state response returned by \\`worktree/inspectSource\\`.",
|
||||
"properties": {
|
||||
"dirty": {
|
||||
"$ref": "#/definitions/v2/WorktreeDirtyState"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"dirty"
|
||||
],
|
||||
"title": "WorktreeInspectSourceResponse",
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeListParams": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "Request the managed worktrees associated with the repository containing \\`cwd\\`.",
|
||||
"properties": {
|
||||
"cwd": {
|
||||
"description": "Repository-relative workspace cwd to inspect. Omitted uses app-server's effective cwd.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"title": "WorktreeListParams",
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeListResponse": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "Managed worktrees returned by \\`worktree/list\\`.",
|
||||
"properties": {
|
||||
"data": {
|
||||
"items": {
|
||||
"$ref": "#/definitions/v2/WorktreeInfo"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"data"
|
||||
],
|
||||
"title": "WorktreeListResponse",
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeLocation": {
|
||||
"enum": [
|
||||
"sibling",
|
||||
"codexHome",
|
||||
"external"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"WorktreeRemoveParams": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "Remove a managed worktree in the repository containing \\`cwd\\`.",
|
||||
"properties": {
|
||||
"cwd": {
|
||||
"description": "Repository-relative workspace cwd to use when resolving \\`name_or_path\\`.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"deleteBranch": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"force": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"nameOrPath": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"nameOrPath"
|
||||
],
|
||||
"title": "WorktreeRemoveParams",
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeRemoveResponse": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "Result returned by \\`worktree/remove\\`.",
|
||||
"properties": {
|
||||
"deletedBranch": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"removedPath": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"removedPath"
|
||||
],
|
||||
"title": "WorktreeRemoveResponse",
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeSource": {
|
||||
"enum": [
|
||||
"cli",
|
||||
"app",
|
||||
"legacy",
|
||||
"git"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"WorktreeWarning": {
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"message"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"WriteStatus": {
|
||||
"enum": [
|
||||
"ok",
|
||||
|
||||
+396
@@ -1953,6 +1953,102 @@
|
||||
"title": "Fs/unwatchRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
"$ref": "#/definitions/RequestId"
|
||||
},
|
||||
"method": {
|
||||
"enum": [
|
||||
"worktree/list"
|
||||
],
|
||||
"title": "Worktree/listRequestMethod",
|
||||
"type": "string"
|
||||
},
|
||||
"params": {
|
||||
"$ref": "#/definitions/WorktreeListParams"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"title": "Worktree/listRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
"$ref": "#/definitions/RequestId"
|
||||
},
|
||||
"method": {
|
||||
"enum": [
|
||||
"worktree/inspectSource"
|
||||
],
|
||||
"title": "Worktree/inspectSourceRequestMethod",
|
||||
"type": "string"
|
||||
},
|
||||
"params": {
|
||||
"$ref": "#/definitions/WorktreeInspectSourceParams"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"title": "Worktree/inspectSourceRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
"$ref": "#/definitions/RequestId"
|
||||
},
|
||||
"method": {
|
||||
"enum": [
|
||||
"worktree/create"
|
||||
],
|
||||
"title": "Worktree/createRequestMethod",
|
||||
"type": "string"
|
||||
},
|
||||
"params": {
|
||||
"$ref": "#/definitions/WorktreeCreateParams"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"title": "Worktree/createRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
"$ref": "#/definitions/RequestId"
|
||||
},
|
||||
"method": {
|
||||
"enum": [
|
||||
"worktree/remove"
|
||||
],
|
||||
"title": "Worktree/removeRequestMethod",
|
||||
"type": "string"
|
||||
},
|
||||
"params": {
|
||||
"$ref": "#/definitions/WorktreeRemoveParams"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"title": "Worktree/removeRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
@@ -16539,6 +16635,306 @@
|
||||
"title": "WindowsWorldWritableWarningNotification",
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeCreateParams": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "Create or reuse a managed worktree from the repository containing \\`cwd\\`.",
|
||||
"properties": {
|
||||
"baseRef": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"branch": {
|
||||
"type": "string"
|
||||
},
|
||||
"cwd": {
|
||||
"description": "Repository-relative workspace cwd to use as the source checkout.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"dirtyPolicy": {
|
||||
"$ref": "#/definitions/WorktreeDirtyPolicy"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"branch",
|
||||
"dirtyPolicy"
|
||||
],
|
||||
"title": "WorktreeCreateParams",
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeCreateResponse": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "Result returned by \\`worktree/create\\`.",
|
||||
"properties": {
|
||||
"info": {
|
||||
"$ref": "#/definitions/WorktreeInfo"
|
||||
},
|
||||
"reused": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"warnings": {
|
||||
"items": {
|
||||
"$ref": "#/definitions/WorktreeWarning"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"info",
|
||||
"reused",
|
||||
"warnings"
|
||||
],
|
||||
"title": "WorktreeCreateResponse",
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeDirtyPolicy": {
|
||||
"enum": [
|
||||
"fail",
|
||||
"ignore",
|
||||
"copyTracked",
|
||||
"copyAll",
|
||||
"moveTracked",
|
||||
"moveAll"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"WorktreeDirtyState": {
|
||||
"properties": {
|
||||
"hasStagedChanges": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hasUnstagedChanges": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hasUntrackedFiles": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"hasStagedChanges",
|
||||
"hasUnstagedChanges",
|
||||
"hasUntrackedFiles"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeInfo": {
|
||||
"description": "Server-native representation of a managed worktree.",
|
||||
"properties": {
|
||||
"branch": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"commonGitDir": {
|
||||
"type": "string"
|
||||
},
|
||||
"dirty": {
|
||||
"$ref": "#/definitions/WorktreeDirtyState"
|
||||
},
|
||||
"head": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"location": {
|
||||
"$ref": "#/definitions/WorktreeLocation"
|
||||
},
|
||||
"metadataPath": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"originalRelativeCwd": {
|
||||
"type": "string"
|
||||
},
|
||||
"ownerThreadId": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"repoName": {
|
||||
"type": "string"
|
||||
},
|
||||
"repoRoot": {
|
||||
"type": "string"
|
||||
},
|
||||
"slug": {
|
||||
"type": "string"
|
||||
},
|
||||
"source": {
|
||||
"$ref": "#/definitions/WorktreeSource"
|
||||
},
|
||||
"workspaceCwd": {
|
||||
"type": "string"
|
||||
},
|
||||
"worktreeGitRoot": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"commonGitDir",
|
||||
"dirty",
|
||||
"id",
|
||||
"location",
|
||||
"metadataPath",
|
||||
"name",
|
||||
"originalRelativeCwd",
|
||||
"repoName",
|
||||
"repoRoot",
|
||||
"slug",
|
||||
"source",
|
||||
"workspaceCwd",
|
||||
"worktreeGitRoot"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeInspectSourceParams": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "Inspect dirty state for the repository containing \\`cwd\\`.",
|
||||
"properties": {
|
||||
"cwd": {
|
||||
"description": "Repository-relative workspace cwd to inspect. Omitted uses app-server's effective cwd.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"title": "WorktreeInspectSourceParams",
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeInspectSourceResponse": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "Dirty-state response returned by \\`worktree/inspectSource\\`.",
|
||||
"properties": {
|
||||
"dirty": {
|
||||
"$ref": "#/definitions/WorktreeDirtyState"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"dirty"
|
||||
],
|
||||
"title": "WorktreeInspectSourceResponse",
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeListParams": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "Request the managed worktrees associated with the repository containing \\`cwd\\`.",
|
||||
"properties": {
|
||||
"cwd": {
|
||||
"description": "Repository-relative workspace cwd to inspect. Omitted uses app-server's effective cwd.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"title": "WorktreeListParams",
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeListResponse": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "Managed worktrees returned by \\`worktree/list\\`.",
|
||||
"properties": {
|
||||
"data": {
|
||||
"items": {
|
||||
"$ref": "#/definitions/WorktreeInfo"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"data"
|
||||
],
|
||||
"title": "WorktreeListResponse",
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeLocation": {
|
||||
"enum": [
|
||||
"sibling",
|
||||
"codexHome",
|
||||
"external"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"WorktreeRemoveParams": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "Remove a managed worktree in the repository containing \\`cwd\\`.",
|
||||
"properties": {
|
||||
"cwd": {
|
||||
"description": "Repository-relative workspace cwd to use when resolving \\`name_or_path\\`.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"deleteBranch": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"force": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"nameOrPath": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"nameOrPath"
|
||||
],
|
||||
"title": "WorktreeRemoveParams",
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeRemoveResponse": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "Result returned by \\`worktree/remove\\`.",
|
||||
"properties": {
|
||||
"deletedBranch": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"removedPath": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"removedPath"
|
||||
],
|
||||
"title": "WorktreeRemoveResponse",
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeSource": {
|
||||
"enum": [
|
||||
"cli",
|
||||
"app",
|
||||
"legacy",
|
||||
"git"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"WorktreeWarning": {
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"message"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"WriteStatus": {
|
||||
"enum": [
|
||||
"ok",
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"definitions": {
|
||||
"WorktreeDirtyPolicy": {
|
||||
"enum": [
|
||||
"fail",
|
||||
"ignore",
|
||||
"copyTracked",
|
||||
"copyAll",
|
||||
"moveTracked",
|
||||
"moveAll"
|
||||
],
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"description": "Create or reuse a managed worktree from the repository containing \\`cwd\\`.",
|
||||
"properties": {
|
||||
"baseRef": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"branch": {
|
||||
"type": "string"
|
||||
},
|
||||
"cwd": {
|
||||
"description": "Repository-relative workspace cwd to use as the source checkout.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"dirtyPolicy": {
|
||||
"$ref": "#/definitions/WorktreeDirtyPolicy"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"branch",
|
||||
"dirtyPolicy"
|
||||
],
|
||||
"title": "WorktreeCreateParams",
|
||||
"type": "object"
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"definitions": {
|
||||
"WorktreeDirtyState": {
|
||||
"properties": {
|
||||
"hasStagedChanges": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hasUnstagedChanges": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hasUntrackedFiles": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"hasStagedChanges",
|
||||
"hasUnstagedChanges",
|
||||
"hasUntrackedFiles"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeInfo": {
|
||||
"description": "Server-native representation of a managed worktree.",
|
||||
"properties": {
|
||||
"branch": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"commonGitDir": {
|
||||
"type": "string"
|
||||
},
|
||||
"dirty": {
|
||||
"$ref": "#/definitions/WorktreeDirtyState"
|
||||
},
|
||||
"head": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"location": {
|
||||
"$ref": "#/definitions/WorktreeLocation"
|
||||
},
|
||||
"metadataPath": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"originalRelativeCwd": {
|
||||
"type": "string"
|
||||
},
|
||||
"ownerThreadId": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"repoName": {
|
||||
"type": "string"
|
||||
},
|
||||
"repoRoot": {
|
||||
"type": "string"
|
||||
},
|
||||
"slug": {
|
||||
"type": "string"
|
||||
},
|
||||
"source": {
|
||||
"$ref": "#/definitions/WorktreeSource"
|
||||
},
|
||||
"workspaceCwd": {
|
||||
"type": "string"
|
||||
},
|
||||
"worktreeGitRoot": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"commonGitDir",
|
||||
"dirty",
|
||||
"id",
|
||||
"location",
|
||||
"metadataPath",
|
||||
"name",
|
||||
"originalRelativeCwd",
|
||||
"repoName",
|
||||
"repoRoot",
|
||||
"slug",
|
||||
"source",
|
||||
"workspaceCwd",
|
||||
"worktreeGitRoot"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeLocation": {
|
||||
"enum": [
|
||||
"sibling",
|
||||
"codexHome",
|
||||
"external"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"WorktreeSource": {
|
||||
"enum": [
|
||||
"cli",
|
||||
"app",
|
||||
"legacy",
|
||||
"git"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"WorktreeWarning": {
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"message"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"description": "Result returned by \\`worktree/create\\`.",
|
||||
"properties": {
|
||||
"info": {
|
||||
"$ref": "#/definitions/WorktreeInfo"
|
||||
},
|
||||
"reused": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"warnings": {
|
||||
"items": {
|
||||
"$ref": "#/definitions/WorktreeWarning"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"info",
|
||||
"reused",
|
||||
"warnings"
|
||||
],
|
||||
"title": "WorktreeCreateResponse",
|
||||
"type": "object"
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "Inspect dirty state for the repository containing \\`cwd\\`.",
|
||||
"properties": {
|
||||
"cwd": {
|
||||
"description": "Repository-relative workspace cwd to inspect. Omitted uses app-server's effective cwd.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"title": "WorktreeInspectSourceParams",
|
||||
"type": "object"
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"definitions": {
|
||||
"WorktreeDirtyState": {
|
||||
"properties": {
|
||||
"hasStagedChanges": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hasUnstagedChanges": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hasUntrackedFiles": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"hasStagedChanges",
|
||||
"hasUnstagedChanges",
|
||||
"hasUntrackedFiles"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"description": "Dirty-state response returned by \\`worktree/inspectSource\\`.",
|
||||
"properties": {
|
||||
"dirty": {
|
||||
"$ref": "#/definitions/WorktreeDirtyState"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"dirty"
|
||||
],
|
||||
"title": "WorktreeInspectSourceResponse",
|
||||
"type": "object"
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "Request the managed worktrees associated with the repository containing \\`cwd\\`.",
|
||||
"properties": {
|
||||
"cwd": {
|
||||
"description": "Repository-relative workspace cwd to inspect. Omitted uses app-server's effective cwd.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"title": "WorktreeListParams",
|
||||
"type": "object"
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"definitions": {
|
||||
"WorktreeDirtyState": {
|
||||
"properties": {
|
||||
"hasStagedChanges": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hasUnstagedChanges": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hasUntrackedFiles": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"hasStagedChanges",
|
||||
"hasUnstagedChanges",
|
||||
"hasUntrackedFiles"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeInfo": {
|
||||
"description": "Server-native representation of a managed worktree.",
|
||||
"properties": {
|
||||
"branch": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"commonGitDir": {
|
||||
"type": "string"
|
||||
},
|
||||
"dirty": {
|
||||
"$ref": "#/definitions/WorktreeDirtyState"
|
||||
},
|
||||
"head": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"location": {
|
||||
"$ref": "#/definitions/WorktreeLocation"
|
||||
},
|
||||
"metadataPath": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"originalRelativeCwd": {
|
||||
"type": "string"
|
||||
},
|
||||
"ownerThreadId": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"repoName": {
|
||||
"type": "string"
|
||||
},
|
||||
"repoRoot": {
|
||||
"type": "string"
|
||||
},
|
||||
"slug": {
|
||||
"type": "string"
|
||||
},
|
||||
"source": {
|
||||
"$ref": "#/definitions/WorktreeSource"
|
||||
},
|
||||
"workspaceCwd": {
|
||||
"type": "string"
|
||||
},
|
||||
"worktreeGitRoot": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"commonGitDir",
|
||||
"dirty",
|
||||
"id",
|
||||
"location",
|
||||
"metadataPath",
|
||||
"name",
|
||||
"originalRelativeCwd",
|
||||
"repoName",
|
||||
"repoRoot",
|
||||
"slug",
|
||||
"source",
|
||||
"workspaceCwd",
|
||||
"worktreeGitRoot"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"WorktreeLocation": {
|
||||
"enum": [
|
||||
"sibling",
|
||||
"codexHome",
|
||||
"external"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"WorktreeSource": {
|
||||
"enum": [
|
||||
"cli",
|
||||
"app",
|
||||
"legacy",
|
||||
"git"
|
||||
],
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"description": "Managed worktrees returned by \\`worktree/list\\`.",
|
||||
"properties": {
|
||||
"data": {
|
||||
"items": {
|
||||
"$ref": "#/definitions/WorktreeInfo"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"data"
|
||||
],
|
||||
"title": "WorktreeListResponse",
|
||||
"type": "object"
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "Remove a managed worktree in the repository containing \\`cwd\\`.",
|
||||
"properties": {
|
||||
"cwd": {
|
||||
"description": "Repository-relative workspace cwd to use when resolving \\`name_or_path\\`.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"deleteBranch": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"force": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"nameOrPath": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"nameOrPath"
|
||||
],
|
||||
"title": "WorktreeRemoveParams",
|
||||
"type": "object"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "Result returned by \\`worktree/remove\\`.",
|
||||
"properties": {
|
||||
"deletedBranch": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"removedPath": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"removedPath"
|
||||
],
|
||||
"title": "WorktreeRemoveResponse",
|
||||
"type": "object"
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,13 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { WorktreeDirtyPolicy } from "./WorktreeDirtyPolicy";
|
||||
|
||||
/**
|
||||
* Create or reuse a managed worktree from the repository containing \`cwd\`.
|
||||
*/
|
||||
export type WorktreeCreateParams = {
|
||||
/**
|
||||
* Repository-relative workspace cwd to use as the source checkout.
|
||||
*/
|
||||
cwd?: string | null, branch: string, baseRef?: string | null, dirtyPolicy: WorktreeDirtyPolicy, };
|
||||
@@ -0,0 +1,10 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { WorktreeInfo } from "./WorktreeInfo";
|
||||
import type { WorktreeWarning } from "./WorktreeWarning";
|
||||
|
||||
/**
|
||||
* Result returned by \`worktree/create\`.
|
||||
*/
|
||||
export type WorktreeCreateResponse = { reused: boolean, info: WorktreeInfo, warnings: Array<WorktreeWarning>, };
|
||||
@@ -0,0 +1,5 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type WorktreeDirtyPolicy = "fail" | "ignore" | "copyTracked" | "copyAll" | "moveTracked" | "moveAll";
|
||||
@@ -0,0 +1,5 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type WorktreeDirtyState = { hasStagedChanges: boolean, hasUnstagedChanges: boolean, hasUntrackedFiles: boolean, };
|
||||
@@ -0,0 +1,11 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { WorktreeDirtyState } from "./WorktreeDirtyState";
|
||||
import type { WorktreeLocation } from "./WorktreeLocation";
|
||||
import type { WorktreeSource } from "./WorktreeSource";
|
||||
|
||||
/**
|
||||
* Server-native representation of a managed worktree.
|
||||
*/
|
||||
export type WorktreeInfo = { id: string, name: string, slug: string, source: WorktreeSource, location: WorktreeLocation, repoName: string, repoRoot: string, commonGitDir: string, worktreeGitRoot: string, workspaceCwd: string, originalRelativeCwd: string, branch: string | null, head: string | null, ownerThreadId: string | null, metadataPath: string, dirty: WorktreeDirtyState, };
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
/**
|
||||
* Inspect dirty state for the repository containing \`cwd\`.
|
||||
*/
|
||||
export type WorktreeInspectSourceParams = {
|
||||
/**
|
||||
* Repository-relative workspace cwd to inspect. Omitted uses app-server's effective cwd.
|
||||
*/
|
||||
cwd?: string | null, };
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { WorktreeDirtyState } from "./WorktreeDirtyState";
|
||||
|
||||
/**
|
||||
* Dirty-state response returned by \`worktree/inspectSource\`.
|
||||
*/
|
||||
export type WorktreeInspectSourceResponse = { dirty: WorktreeDirtyState, };
|
||||
@@ -0,0 +1,12 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
/**
|
||||
* Request the managed worktrees associated with the repository containing \`cwd\`.
|
||||
*/
|
||||
export type WorktreeListParams = {
|
||||
/**
|
||||
* Repository-relative workspace cwd to inspect. Omitted uses app-server's effective cwd.
|
||||
*/
|
||||
cwd?: string | null, };
|
||||
@@ -0,0 +1,9 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { WorktreeInfo } from "./WorktreeInfo";
|
||||
|
||||
/**
|
||||
* Managed worktrees returned by \`worktree/list\`.
|
||||
*/
|
||||
export type WorktreeListResponse = { data: Array<WorktreeInfo>, };
|
||||
@@ -0,0 +1,5 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type WorktreeLocation = "sibling" | "codexHome" | "external";
|
||||
@@ -0,0 +1,12 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
/**
|
||||
* Remove a managed worktree in the repository containing \`cwd\`.
|
||||
*/
|
||||
export type WorktreeRemoveParams = {
|
||||
/**
|
||||
* Repository-relative workspace cwd to use when resolving \`name_or_path\`.
|
||||
*/
|
||||
cwd?: string | null, nameOrPath: string, force?: boolean, deleteBranch?: boolean, };
|
||||
@@ -0,0 +1,8 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
/**
|
||||
* Result returned by \`worktree/remove\`.
|
||||
*/
|
||||
export type WorktreeRemoveResponse = { removedPath: string, deletedBranch: string | null, };
|
||||
@@ -0,0 +1,5 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type WorktreeSource = "cli" | "app" | "legacy" | "git";
|
||||
@@ -0,0 +1,5 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type WorktreeWarning = { message: string, };
|
||||
@@ -452,4 +452,18 @@ export type { WindowsSandboxSetupMode } from "./WindowsSandboxSetupMode";
|
||||
export type { WindowsSandboxSetupStartParams } from "./WindowsSandboxSetupStartParams";
|
||||
export type { WindowsSandboxSetupStartResponse } from "./WindowsSandboxSetupStartResponse";
|
||||
export type { WindowsWorldWritableWarningNotification } from "./WindowsWorldWritableWarningNotification";
|
||||
export type { WorktreeCreateParams } from "./WorktreeCreateParams";
|
||||
export type { WorktreeCreateResponse } from "./WorktreeCreateResponse";
|
||||
export type { WorktreeDirtyPolicy } from "./WorktreeDirtyPolicy";
|
||||
export type { WorktreeDirtyState } from "./WorktreeDirtyState";
|
||||
export type { WorktreeInfo } from "./WorktreeInfo";
|
||||
export type { WorktreeInspectSourceParams } from "./WorktreeInspectSourceParams";
|
||||
export type { WorktreeInspectSourceResponse } from "./WorktreeInspectSourceResponse";
|
||||
export type { WorktreeListParams } from "./WorktreeListParams";
|
||||
export type { WorktreeListResponse } from "./WorktreeListResponse";
|
||||
export type { WorktreeLocation } from "./WorktreeLocation";
|
||||
export type { WorktreeRemoveParams } from "./WorktreeRemoveParams";
|
||||
export type { WorktreeRemoveResponse } from "./WorktreeRemoveResponse";
|
||||
export type { WorktreeSource } from "./WorktreeSource";
|
||||
export type { WorktreeWarning } from "./WorktreeWarning";
|
||||
export type { WriteStatus } from "./WriteStatus";
|
||||
|
||||
@@ -710,6 +710,26 @@ client_request_definitions! {
|
||||
serialization: fs_watch_id(params.watch_id),
|
||||
response: v2::FsUnwatchResponse,
|
||||
},
|
||||
WorktreeList => "worktree/list" {
|
||||
params: v2::WorktreeListParams,
|
||||
serialization: None,
|
||||
response: v2::WorktreeListResponse,
|
||||
},
|
||||
WorktreeInspectSource => "worktree/inspectSource" {
|
||||
params: v2::WorktreeInspectSourceParams,
|
||||
serialization: None,
|
||||
response: v2::WorktreeInspectSourceResponse,
|
||||
},
|
||||
WorktreeCreate => "worktree/create" {
|
||||
params: v2::WorktreeCreateParams,
|
||||
serialization: global("worktree"),
|
||||
response: v2::WorktreeCreateResponse,
|
||||
},
|
||||
WorktreeRemove => "worktree/remove" {
|
||||
params: v2::WorktreeRemoveParams,
|
||||
serialization: global("worktree"),
|
||||
response: v2::WorktreeRemoveResponse,
|
||||
},
|
||||
SkillsConfigWrite => "skills/config/write" {
|
||||
params: v2::SkillsConfigWriteParams,
|
||||
serialization: global("config"),
|
||||
|
||||
@@ -23,6 +23,7 @@ mod thread;
|
||||
mod thread_data;
|
||||
mod turn;
|
||||
mod windows_sandbox;
|
||||
mod worktree;
|
||||
|
||||
pub use account::*;
|
||||
pub use apps::*;
|
||||
@@ -48,6 +49,7 @@ pub use thread::*;
|
||||
pub use thread_data::*;
|
||||
pub use turn::*;
|
||||
pub use windows_sandbox::*;
|
||||
pub use worktree::*;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use ts_rs::TS;
|
||||
|
||||
/// Request the managed worktrees associated with the repository containing \`cwd\`.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct WorktreeListParams {
|
||||
/// Repository-relative workspace cwd to inspect. Omitted uses app-server's effective cwd.
|
||||
#[ts(optional = nullable)]
|
||||
pub cwd: Option<String>,
|
||||
}
|
||||
|
||||
/// Managed worktrees returned by \`worktree/list\`.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct WorktreeListResponse {
|
||||
pub data: Vec<WorktreeInfo>,
|
||||
}
|
||||
|
||||
/// Inspect dirty state for the repository containing \`cwd\`.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct WorktreeInspectSourceParams {
|
||||
/// Repository-relative workspace cwd to inspect. Omitted uses app-server's effective cwd.
|
||||
#[ts(optional = nullable)]
|
||||
pub cwd: Option<String>,
|
||||
}
|
||||
|
||||
/// Dirty-state response returned by \`worktree/inspectSource\`.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct WorktreeInspectSourceResponse {
|
||||
pub dirty: WorktreeDirtyState,
|
||||
}
|
||||
|
||||
/// Create or reuse a managed worktree from the repository containing \`cwd\`.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct WorktreeCreateParams {
|
||||
/// Repository-relative workspace cwd to use as the source checkout.
|
||||
#[ts(optional = nullable)]
|
||||
pub cwd: Option<String>,
|
||||
pub branch: String,
|
||||
#[ts(optional = nullable)]
|
||||
pub base_ref: Option<String>,
|
||||
pub dirty_policy: WorktreeDirtyPolicy,
|
||||
}
|
||||
|
||||
/// Result returned by \`worktree/create\`.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct WorktreeCreateResponse {
|
||||
pub reused: bool,
|
||||
pub info: WorktreeInfo,
|
||||
pub warnings: Vec<WorktreeWarning>,
|
||||
}
|
||||
|
||||
/// Remove a managed worktree in the repository containing \`cwd\`.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct WorktreeRemoveParams {
|
||||
/// Repository-relative workspace cwd to use when resolving \`name_or_path\`.
|
||||
#[ts(optional = nullable)]
|
||||
pub cwd: Option<String>,
|
||||
pub name_or_path: String,
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
pub force: bool,
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
pub delete_branch: bool,
|
||||
}
|
||||
|
||||
/// Result returned by \`worktree/remove\`.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct WorktreeRemoveResponse {
|
||||
pub removed_path: String,
|
||||
pub deleted_branch: Option<String>,
|
||||
}
|
||||
|
||||
/// Server-native representation of a managed worktree.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct WorktreeInfo {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
pub slug: String,
|
||||
pub source: WorktreeSource,
|
||||
pub location: WorktreeLocation,
|
||||
pub repo_name: String,
|
||||
pub repo_root: String,
|
||||
pub common_git_dir: String,
|
||||
pub worktree_git_root: String,
|
||||
pub workspace_cwd: String,
|
||||
pub original_relative_cwd: String,
|
||||
pub branch: Option<String>,
|
||||
pub head: Option<String>,
|
||||
pub owner_thread_id: Option<String>,
|
||||
pub metadata_path: String,
|
||||
pub dirty: WorktreeDirtyState,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub enum WorktreeSource {
|
||||
Cli,
|
||||
App,
|
||||
Legacy,
|
||||
Git,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub enum WorktreeLocation {
|
||||
Sibling,
|
||||
CodexHome,
|
||||
External,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub enum WorktreeDirtyPolicy {
|
||||
Fail,
|
||||
Ignore,
|
||||
CopyTracked,
|
||||
CopyAll,
|
||||
MoveTracked,
|
||||
MoveAll,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct WorktreeDirtyState {
|
||||
pub has_staged_changes: bool,
|
||||
pub has_unstaged_changes: bool,
|
||||
pub has_untracked_files: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct WorktreeWarning {
|
||||
pub message: String,
|
||||
}
|
||||
@@ -67,6 +67,7 @@ codex-thread-store = { workspace = true }
|
||||
codex-tools = { workspace = true }
|
||||
codex-utils-absolute-path = { workspace = true }
|
||||
codex-utils-json-to-toml = { workspace = true }
|
||||
codex-worktree = { workspace = true }
|
||||
chrono = { workspace = true }
|
||||
clap = { workspace = true, features = ["derive"] }
|
||||
futures = { workspace = true }
|
||||
|
||||
@@ -1150,6 +1150,13 @@ All filesystem paths in this section must be absolute.
|
||||
{ "id": 45, "result": {} }
|
||||
```
|
||||
|
||||
### Worktrees
|
||||
|
||||
- `worktree/list` - list Codex-managed worktrees for the repository containing `cwd`; omitted `cwd` uses the app server's effective cwd.
|
||||
- `worktree/inspectSource` - inspect staged, unstaged, and untracked dirty state for the repository containing `cwd`.
|
||||
- `worktree/create` - create or reuse a managed worktree from `cwd`, returning the resolved worktree plus any transfer warnings.
|
||||
- `worktree/remove` - remove a managed worktree resolved from `cwd` and `nameOrPath`, with optional `force` and `deleteBranch` behavior.
|
||||
|
||||
## Events
|
||||
|
||||
Event notifications are the server-initiated event stream for thread lifecycles, turn lifecycles, and the items within them. After you start or resume a thread, keep reading stdout for `thread/started`, `thread/archived`, `thread/unarchived`, `thread/closed`, `turn/*`, and `item/*` notifications.
|
||||
|
||||
@@ -32,6 +32,7 @@ use crate::request_processors::ThreadGoalRequestProcessor;
|
||||
use crate::request_processors::ThreadRequestProcessor;
|
||||
use crate::request_processors::TurnRequestProcessor;
|
||||
use crate::request_processors::WindowsSandboxRequestProcessor;
|
||||
use crate::request_processors::WorktreeRequestProcessor;
|
||||
use crate::request_serialization::QueuedInitializedRequest;
|
||||
use crate::request_serialization::RequestSerializationQueueKey;
|
||||
use crate::request_serialization::RequestSerializationQueues;
|
||||
@@ -175,6 +176,7 @@ pub(crate) struct MessageProcessor {
|
||||
thread_processor: ThreadRequestProcessor,
|
||||
turn_processor: TurnRequestProcessor,
|
||||
windows_sandbox_processor: WindowsSandboxRequestProcessor,
|
||||
worktree_processor: WorktreeRequestProcessor,
|
||||
request_serialization_queues: RequestSerializationQueues,
|
||||
}
|
||||
|
||||
@@ -456,8 +458,9 @@ impl MessageProcessor {
|
||||
let windows_sandbox_processor = WindowsSandboxRequestProcessor::new(
|
||||
outgoing.clone(),
|
||||
Arc::clone(&config),
|
||||
config_manager,
|
||||
config_manager.clone(),
|
||||
);
|
||||
let worktree_processor = WorktreeRequestProcessor::new(config_manager);
|
||||
|
||||
Self {
|
||||
outgoing,
|
||||
@@ -481,6 +484,7 @@ impl MessageProcessor {
|
||||
thread_processor,
|
||||
turn_processor,
|
||||
windows_sandbox_processor,
|
||||
worktree_processor,
|
||||
request_serialization_queues: RequestSerializationQueues::default(),
|
||||
}
|
||||
}
|
||||
@@ -937,6 +941,26 @@ impl MessageProcessor {
|
||||
.unwatch(connection_id, params)
|
||||
.await
|
||||
.map(|response| Some(response.into())),
|
||||
ClientRequest::WorktreeList { params, .. } => self
|
||||
.worktree_processor
|
||||
.list(params)
|
||||
.await
|
||||
.map(|response| Some(response.into())),
|
||||
ClientRequest::WorktreeInspectSource { params, .. } => self
|
||||
.worktree_processor
|
||||
.inspect_source(params)
|
||||
.await
|
||||
.map(|response| Some(response.into())),
|
||||
ClientRequest::WorktreeCreate { params, .. } => self
|
||||
.worktree_processor
|
||||
.create(params)
|
||||
.await
|
||||
.map(|response| Some(response.into())),
|
||||
ClientRequest::WorktreeRemove { params, .. } => self
|
||||
.worktree_processor
|
||||
.remove(params)
|
||||
.await
|
||||
.map(|response| Some(response.into())),
|
||||
ClientRequest::ModelProviderCapabilitiesRead { params: _, .. } => self
|
||||
.config_processor
|
||||
.model_provider_capabilities_read()
|
||||
|
||||
@@ -241,6 +241,20 @@ use codex_app_server_protocol::WindowsSandboxSetupCompletedNotification;
|
||||
use codex_app_server_protocol::WindowsSandboxSetupMode;
|
||||
use codex_app_server_protocol::WindowsSandboxSetupStartParams;
|
||||
use codex_app_server_protocol::WindowsSandboxSetupStartResponse;
|
||||
use codex_app_server_protocol::WorktreeCreateParams;
|
||||
use codex_app_server_protocol::WorktreeCreateResponse;
|
||||
use codex_app_server_protocol::WorktreeDirtyPolicy as ApiWorktreeDirtyPolicy;
|
||||
use codex_app_server_protocol::WorktreeDirtyState as ApiWorktreeDirtyState;
|
||||
use codex_app_server_protocol::WorktreeInfo as ApiWorktreeInfo;
|
||||
use codex_app_server_protocol::WorktreeInspectSourceParams;
|
||||
use codex_app_server_protocol::WorktreeInspectSourceResponse;
|
||||
use codex_app_server_protocol::WorktreeListParams;
|
||||
use codex_app_server_protocol::WorktreeListResponse;
|
||||
use codex_app_server_protocol::WorktreeLocation as ApiWorktreeLocation;
|
||||
use codex_app_server_protocol::WorktreeRemoveParams;
|
||||
use codex_app_server_protocol::WorktreeRemoveResponse;
|
||||
use codex_app_server_protocol::WorktreeSource as ApiWorktreeSource;
|
||||
use codex_app_server_protocol::WorktreeWarning as ApiWorktreeWarning;
|
||||
use codex_arg0::Arg0DispatchPaths;
|
||||
use codex_backend_client::AddCreditsNudgeCreditType as BackendAddCreditsNudgeCreditType;
|
||||
use codex_backend_client::Client as BackendClient;
|
||||
@@ -446,6 +460,7 @@ mod thread_processor;
|
||||
mod token_usage_replay;
|
||||
mod turn_processor;
|
||||
mod windows_sandbox_processor;
|
||||
mod worktree_processor;
|
||||
|
||||
pub(crate) use account_processor::AccountRequestProcessor;
|
||||
pub(crate) use apps_processor::AppsRequestProcessor;
|
||||
@@ -467,6 +482,7 @@ pub(crate) use thread_goal_processor::ThreadGoalRequestProcessor;
|
||||
pub(crate) use thread_processor::ThreadRequestProcessor;
|
||||
pub(crate) use turn_processor::TurnRequestProcessor;
|
||||
pub(crate) use windows_sandbox_processor::WindowsSandboxRequestProcessor;
|
||||
pub(crate) use worktree_processor::WorktreeRequestProcessor;
|
||||
|
||||
use crate::error_code::internal_error;
|
||||
use crate::error_code::invalid_request;
|
||||
|
||||
@@ -1044,6 +1044,7 @@ impl ThreadRequestProcessor {
|
||||
.collect()
|
||||
};
|
||||
let core_dynamic_tool_count = core_dynamic_tools.len();
|
||||
let codex_home = config.codex_home.to_path_buf();
|
||||
|
||||
let NewThread {
|
||||
thread_id,
|
||||
@@ -1147,6 +1148,11 @@ impl ThreadRequestProcessor {
|
||||
);
|
||||
let active_permission_profile =
|
||||
thread_response_active_permission_profile(config_snapshot.active_permission_profile);
|
||||
bind_worktree_thread_best_effort(
|
||||
codex_home.as_path(),
|
||||
config_snapshot.cwd.as_path(),
|
||||
&thread.id,
|
||||
);
|
||||
|
||||
let response = ThreadStartResponse {
|
||||
thread: thread.clone(),
|
||||
@@ -2480,6 +2486,11 @@ impl ThreadRequestProcessor {
|
||||
let active_permission_profile = thread_response_active_permission_profile(
|
||||
config_snapshot.active_permission_profile,
|
||||
);
|
||||
bind_worktree_thread_best_effort(
|
||||
self.config.codex_home.as_path(),
|
||||
session_configured.cwd.as_path(),
|
||||
&thread.id,
|
||||
);
|
||||
|
||||
let response = ThreadResumeResponse {
|
||||
thread,
|
||||
@@ -3127,6 +3138,11 @@ impl ThreadRequestProcessor {
|
||||
);
|
||||
let active_permission_profile =
|
||||
thread_response_active_permission_profile(config_snapshot.active_permission_profile);
|
||||
bind_worktree_thread_best_effort(
|
||||
self.config.codex_home.as_path(),
|
||||
session_configured.cwd.as_path(),
|
||||
&thread.id,
|
||||
);
|
||||
|
||||
let response = ThreadForkResponse {
|
||||
thread: thread.clone(),
|
||||
@@ -3325,6 +3341,24 @@ impl ThreadRequestProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
fn bind_worktree_thread_best_effort(
|
||||
codex_home: &std::path::Path,
|
||||
cwd: &std::path::Path,
|
||||
thread_id: &str,
|
||||
) {
|
||||
match codex_worktree::resolve_worktree(codex_home, cwd) {
|
||||
Ok(Some(_)) => {
|
||||
if let Err(err) = codex_worktree::bind_thread(cwd, thread_id) {
|
||||
tracing::warn!(?err, "failed to bind managed worktree to thread");
|
||||
}
|
||||
}
|
||||
Ok(None) => {}
|
||||
Err(err) => {
|
||||
tracing::warn!(?err, "failed to resolve managed worktree metadata");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn xcode_26_4_mcp_elicitations_auto_deny(
|
||||
client_name: Option<&str>,
|
||||
client_version: Option<&str>,
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
use super::*;
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use codex_worktree::DirtyPolicy;
|
||||
use codex_worktree::DirtyState;
|
||||
use codex_worktree::WorktreeInfo;
|
||||
use codex_worktree::WorktreeListQuery;
|
||||
use codex_worktree::WorktreeLocation;
|
||||
use codex_worktree::WorktreeRemoveRequest;
|
||||
use codex_worktree::WorktreeRequest;
|
||||
use codex_worktree::WorktreeSource;
|
||||
use codex_worktree::WorktreeWarning;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct WorktreeRequestProcessor {
|
||||
config_manager: ConfigManager,
|
||||
}
|
||||
|
||||
impl WorktreeRequestProcessor {
|
||||
pub(crate) fn new(config_manager: ConfigManager) -> Self {
|
||||
Self { config_manager }
|
||||
}
|
||||
|
||||
pub(crate) async fn list(
|
||||
&self,
|
||||
params: WorktreeListParams,
|
||||
) -> Result<WorktreeListResponse, JSONRPCErrorError> {
|
||||
let cwd = self.resolve_cwd(params.cwd).await?;
|
||||
let data = codex_worktree::list_worktrees(WorktreeListQuery {
|
||||
codex_home: self.config_manager.codex_home().to_path_buf(),
|
||||
source_cwd: Some(cwd),
|
||||
include_all_repos: false,
|
||||
})
|
||||
.map_err(map_worktree_error)?
|
||||
.into_iter()
|
||||
.map(api_worktree_info)
|
||||
.collect();
|
||||
Ok(WorktreeListResponse { data })
|
||||
}
|
||||
|
||||
pub(crate) async fn inspect_source(
|
||||
&self,
|
||||
params: WorktreeInspectSourceParams,
|
||||
) -> Result<WorktreeInspectSourceResponse, JSONRPCErrorError> {
|
||||
let cwd = self.resolve_cwd(params.cwd).await?;
|
||||
let dirty = api_dirty_state(codex_worktree::dirty_state(&cwd).map_err(map_worktree_error)?);
|
||||
Ok(WorktreeInspectSourceResponse { dirty })
|
||||
}
|
||||
|
||||
pub(crate) async fn create(
|
||||
&self,
|
||||
params: WorktreeCreateParams,
|
||||
) -> Result<WorktreeCreateResponse, JSONRPCErrorError> {
|
||||
let cwd = self.resolve_cwd(params.cwd).await?;
|
||||
let resolution = codex_worktree::ensure_worktree(WorktreeRequest {
|
||||
codex_home: self.config_manager.codex_home().to_path_buf(),
|
||||
source_cwd: cwd,
|
||||
branch: params.branch,
|
||||
base_ref: params.base_ref,
|
||||
dirty_policy: dirty_policy_from_api(params.dirty_policy),
|
||||
})
|
||||
.map_err(map_worktree_error)?;
|
||||
Ok(WorktreeCreateResponse {
|
||||
reused: resolution.reused,
|
||||
info: api_worktree_info(resolution.info),
|
||||
warnings: resolution
|
||||
.warnings
|
||||
.into_iter()
|
||||
.map(api_worktree_warning)
|
||||
.collect(),
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) async fn remove(
|
||||
&self,
|
||||
params: WorktreeRemoveParams,
|
||||
) -> Result<WorktreeRemoveResponse, JSONRPCErrorError> {
|
||||
let cwd = self.resolve_cwd(params.cwd).await?;
|
||||
let result = codex_worktree::remove_worktree(WorktreeRemoveRequest {
|
||||
codex_home: self.config_manager.codex_home().to_path_buf(),
|
||||
source_cwd: Some(cwd),
|
||||
name_or_path: params.name_or_path,
|
||||
force: params.force,
|
||||
delete_branch: params.delete_branch,
|
||||
})
|
||||
.map_err(map_worktree_error)?;
|
||||
Ok(WorktreeRemoveResponse {
|
||||
removed_path: result.removed_path.to_string_lossy().to_string(),
|
||||
deleted_branch: result.deleted_branch,
|
||||
})
|
||||
}
|
||||
|
||||
async fn resolve_cwd(&self, cwd: Option<String>) -> Result<PathBuf, JSONRPCErrorError> {
|
||||
match cwd {
|
||||
Some(cwd) => Ok(PathBuf::from(cwd)),
|
||||
None => self
|
||||
.config_manager
|
||||
.load_latest_config(/*fallback_cwd*/ None)
|
||||
.await
|
||||
.map(|config| config.cwd.to_path_buf())
|
||||
.map_err(|err| internal_error(format!("failed to load worktree cwd: {err}"))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn map_worktree_error(err: anyhow::Error) -> JSONRPCErrorError {
|
||||
invalid_request(err.to_string())
|
||||
}
|
||||
|
||||
fn dirty_policy_from_api(value: ApiWorktreeDirtyPolicy) -> DirtyPolicy {
|
||||
match value {
|
||||
ApiWorktreeDirtyPolicy::Fail => DirtyPolicy::Fail,
|
||||
ApiWorktreeDirtyPolicy::Ignore => DirtyPolicy::Ignore,
|
||||
ApiWorktreeDirtyPolicy::CopyTracked => DirtyPolicy::CopyTracked,
|
||||
ApiWorktreeDirtyPolicy::CopyAll => DirtyPolicy::CopyAll,
|
||||
ApiWorktreeDirtyPolicy::MoveTracked => DirtyPolicy::MoveTracked,
|
||||
ApiWorktreeDirtyPolicy::MoveAll => DirtyPolicy::MoveAll,
|
||||
}
|
||||
}
|
||||
|
||||
fn api_dirty_state(value: DirtyState) -> ApiWorktreeDirtyState {
|
||||
ApiWorktreeDirtyState {
|
||||
has_staged_changes: value.has_staged_changes,
|
||||
has_unstaged_changes: value.has_unstaged_changes,
|
||||
has_untracked_files: value.has_untracked_files,
|
||||
}
|
||||
}
|
||||
|
||||
fn api_worktree_info(value: WorktreeInfo) -> ApiWorktreeInfo {
|
||||
ApiWorktreeInfo {
|
||||
id: value.id,
|
||||
name: value.name,
|
||||
slug: value.slug,
|
||||
source: api_worktree_source(value.source),
|
||||
location: api_worktree_location(value.location),
|
||||
repo_name: value.repo_name,
|
||||
repo_root: value.repo_root.to_string_lossy().to_string(),
|
||||
common_git_dir: value.common_git_dir.to_string_lossy().to_string(),
|
||||
worktree_git_root: value.worktree_git_root.to_string_lossy().to_string(),
|
||||
workspace_cwd: value.workspace_cwd.to_string_lossy().to_string(),
|
||||
original_relative_cwd: value.original_relative_cwd.to_string_lossy().to_string(),
|
||||
branch: value.branch,
|
||||
head: value.head,
|
||||
owner_thread_id: value.owner_thread_id,
|
||||
metadata_path: value.metadata_path.to_string_lossy().to_string(),
|
||||
dirty: api_dirty_state(value.dirty),
|
||||
}
|
||||
}
|
||||
|
||||
fn api_worktree_source(value: WorktreeSource) -> ApiWorktreeSource {
|
||||
match value {
|
||||
WorktreeSource::Cli => ApiWorktreeSource::Cli,
|
||||
WorktreeSource::App => ApiWorktreeSource::App,
|
||||
WorktreeSource::Legacy => ApiWorktreeSource::Legacy,
|
||||
WorktreeSource::Git => ApiWorktreeSource::Git,
|
||||
}
|
||||
}
|
||||
|
||||
fn api_worktree_location(value: WorktreeLocation) -> ApiWorktreeLocation {
|
||||
match value {
|
||||
WorktreeLocation::Sibling => ApiWorktreeLocation::Sibling,
|
||||
WorktreeLocation::CodexHome => ApiWorktreeLocation::CodexHome,
|
||||
WorktreeLocation::External => ApiWorktreeLocation::External,
|
||||
}
|
||||
}
|
||||
|
||||
fn api_worktree_warning(value: WorktreeWarning) -> ApiWorktreeWarning {
|
||||
ApiWorktreeWarning {
|
||||
message: value.message,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn dirty_policy_conversion_preserves_every_variant() {
|
||||
assert_eq!(
|
||||
[
|
||||
ApiWorktreeDirtyPolicy::Fail,
|
||||
ApiWorktreeDirtyPolicy::Ignore,
|
||||
ApiWorktreeDirtyPolicy::CopyTracked,
|
||||
ApiWorktreeDirtyPolicy::CopyAll,
|
||||
ApiWorktreeDirtyPolicy::MoveTracked,
|
||||
ApiWorktreeDirtyPolicy::MoveAll,
|
||||
]
|
||||
.map(dirty_policy_from_api),
|
||||
[
|
||||
DirtyPolicy::Fail,
|
||||
DirtyPolicy::Ignore,
|
||||
DirtyPolicy::CopyTracked,
|
||||
DirtyPolicy::CopyAll,
|
||||
DirtyPolicy::MoveTracked,
|
||||
DirtyPolicy::MoveAll,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -760,14 +760,6 @@ async fn run_debug_app_server_command(cmd: DebugAppServerCommand) -> anyhow::Res
|
||||
}
|
||||
}
|
||||
|
||||
fn resolve_worktree_options_for_tui(
|
||||
cli: &mut TuiCli,
|
||||
remote: Option<&str>,
|
||||
remote_auth_token_env: Option<&str>,
|
||||
) -> anyhow::Result<Option<WorktreeResolution>> {
|
||||
resolve_worktree_options_for_shared_cli(&mut cli.shared, remote, remote_auth_token_env)
|
||||
}
|
||||
|
||||
fn resolve_worktree_options_for_shared_cli(
|
||||
shared: &mut SharedCliOptions,
|
||||
remote: Option<&str>,
|
||||
@@ -1121,11 +1113,6 @@ async fn cli_main(arg0_paths: Arg0DispatchPaths) -> anyhow::Result<()> {
|
||||
&mut interactive.config_overrides,
|
||||
root_config_overrides.clone(),
|
||||
);
|
||||
resolve_worktree_options_for_tui(
|
||||
&mut interactive,
|
||||
root_remote.as_deref(),
|
||||
root_remote_auth_token_env.as_deref(),
|
||||
)?;
|
||||
let exit_info = run_interactive_tui(
|
||||
interactive,
|
||||
root_remote.clone(),
|
||||
@@ -1299,14 +1286,6 @@ async fn cli_main(arg0_paths: Arg0DispatchPaths) -> anyhow::Result<()> {
|
||||
include_non_interactive,
|
||||
config_overrides,
|
||||
);
|
||||
resolve_worktree_options_for_tui(
|
||||
&mut interactive,
|
||||
remote.remote.as_deref().or(root_remote.as_deref()),
|
||||
remote
|
||||
.remote_auth_token_env
|
||||
.as_deref()
|
||||
.or(root_remote_auth_token_env.as_deref()),
|
||||
)?;
|
||||
let exit_info = run_interactive_tui(
|
||||
interactive,
|
||||
remote.remote.or(root_remote.clone()),
|
||||
@@ -1333,14 +1312,6 @@ async fn cli_main(arg0_paths: Arg0DispatchPaths) -> anyhow::Result<()> {
|
||||
all,
|
||||
config_overrides,
|
||||
);
|
||||
resolve_worktree_options_for_tui(
|
||||
&mut interactive,
|
||||
remote.remote.as_deref().or(root_remote.as_deref()),
|
||||
remote
|
||||
.remote_auth_token_env
|
||||
.as_deref()
|
||||
.or(root_remote_auth_token_env.as_deref()),
|
||||
)?;
|
||||
let exit_info = run_interactive_tui(
|
||||
interactive,
|
||||
remote.remote.or(root_remote.clone()),
|
||||
|
||||
@@ -199,10 +199,6 @@ impl App {
|
||||
self.open_worktree_base_ref_prompt(branch);
|
||||
tui.frame_requester().schedule_frame();
|
||||
}
|
||||
AppEvent::WorktreesLoaded { cwd, result } => {
|
||||
self.on_worktrees_loaded(cwd, result);
|
||||
tui.frame_requester().schedule_frame();
|
||||
}
|
||||
AppEvent::CreateWorktreeAndSwitch {
|
||||
branch,
|
||||
base_ref,
|
||||
|
||||
+166
-120
@@ -1,17 +1,32 @@
|
||||
//! App-layer handlers for the worktree TUI flow.
|
||||
|
||||
use anyhow::Context;
|
||||
use codex_app_server_protocol::ClientRequest;
|
||||
use codex_app_server_protocol::RequestId;
|
||||
use codex_app_server_protocol::WorktreeCreateParams;
|
||||
use codex_app_server_protocol::WorktreeCreateResponse;
|
||||
use codex_app_server_protocol::WorktreeDirtyPolicy as ApiWorktreeDirtyPolicy;
|
||||
use codex_app_server_protocol::WorktreeDirtyState as ApiWorktreeDirtyState;
|
||||
use codex_app_server_protocol::WorktreeInfo as ApiWorktreeInfo;
|
||||
use codex_app_server_protocol::WorktreeInspectSourceParams;
|
||||
use codex_app_server_protocol::WorktreeInspectSourceResponse;
|
||||
use codex_app_server_protocol::WorktreeListParams;
|
||||
use codex_app_server_protocol::WorktreeListResponse;
|
||||
use codex_app_server_protocol::WorktreeLocation as ApiWorktreeLocation;
|
||||
use codex_app_server_protocol::WorktreeRemoveParams;
|
||||
use codex_app_server_protocol::WorktreeRemoveResponse;
|
||||
use codex_app_server_protocol::WorktreeSource as ApiWorktreeSource;
|
||||
use codex_protocol::ThreadId;
|
||||
use codex_worktree::DirtyPolicy;
|
||||
use codex_worktree::WorktreeInfo;
|
||||
use codex_worktree::WorktreeListQuery;
|
||||
use codex_worktree::WorktreeRemoveRequest;
|
||||
use codex_worktree::WorktreeLocation;
|
||||
use codex_worktree::WorktreeRequest;
|
||||
use codex_worktree::WorktreeResolution;
|
||||
use codex_worktree::WorktreeSource;
|
||||
use codex_worktree::WorktreeWarning;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::time::Duration;
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::*;
|
||||
use crate::bottom_pane::custom_prompt_view::CustomPromptView;
|
||||
@@ -50,15 +65,11 @@ impl App {
|
||||
tui.frame_requester(),
|
||||
self.config.animations,
|
||||
));
|
||||
if self.remote_app_server_url.is_some() {
|
||||
let result = self
|
||||
.list_current_repo_worktrees_remote(app_server)
|
||||
.await
|
||||
.map_err(|err| err.to_string());
|
||||
self.on_worktrees_loaded(self.session_workspace_cwd(app_server).to_path_buf(), result);
|
||||
} else {
|
||||
self.fetch_worktrees_for_picker();
|
||||
}
|
||||
let result = self
|
||||
.list_current_repo_worktrees_for_session(app_server)
|
||||
.await
|
||||
.map_err(|err| err.to_string());
|
||||
self.on_worktrees_loaded(self.session_workspace_cwd(app_server).to_path_buf(), result);
|
||||
}
|
||||
|
||||
pub(super) fn open_worktree_create_prompt(&mut self) {
|
||||
@@ -291,35 +302,12 @@ impl App {
|
||||
return;
|
||||
}
|
||||
|
||||
let result = if self.remote_app_server_url.is_some() {
|
||||
let Some(runner) = self.workspace_command_runner.clone() else {
|
||||
self.chat_widget.add_error_message(
|
||||
"Remote worktree removal is unavailable because the workspace command runner is missing."
|
||||
.to_string(),
|
||||
);
|
||||
return;
|
||||
};
|
||||
crate::remote_worktree::remove_worktree(
|
||||
&runner,
|
||||
&app_server.request_handle(),
|
||||
self.session_workspace_cwd(app_server),
|
||||
&target,
|
||||
force,
|
||||
delete_branch,
|
||||
)
|
||||
.await
|
||||
} else {
|
||||
codex_worktree::remove_worktree(WorktreeRemoveRequest {
|
||||
codex_home: self.config.codex_home.to_path_buf(),
|
||||
source_cwd: Some(self.session_workspace_cwd(app_server).to_path_buf()),
|
||||
name_or_path: target.clone(),
|
||||
force,
|
||||
delete_branch,
|
||||
})
|
||||
};
|
||||
let result = self
|
||||
.remove_worktree_via_app_server(app_server, target.clone(), force, delete_branch)
|
||||
.await;
|
||||
match result {
|
||||
Ok(result) => {
|
||||
let mut message = format!("Removed worktree {}", result.removed_path.display());
|
||||
let mut message = format!("Removed worktree {}", result.removed_path);
|
||||
if let Some(branch) = result.deleted_branch {
|
||||
message.push_str(&format!(" and deleted branch {branch}"));
|
||||
}
|
||||
@@ -332,58 +320,40 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
fn list_current_repo_worktrees(&self) -> anyhow::Result<Vec<WorktreeInfo>> {
|
||||
codex_worktree::list_worktrees(WorktreeListQuery {
|
||||
codex_home: self.config.codex_home.to_path_buf(),
|
||||
source_cwd: Some(self.config.cwd.to_path_buf()),
|
||||
include_all_repos: false,
|
||||
})
|
||||
}
|
||||
|
||||
async fn list_current_repo_worktrees_for_session(
|
||||
&self,
|
||||
app_server: &AppServerSession,
|
||||
) -> anyhow::Result<Vec<WorktreeInfo>> {
|
||||
if self.remote_app_server_url.is_some() {
|
||||
self.list_current_repo_worktrees_remote(app_server).await
|
||||
} else {
|
||||
self.list_current_repo_worktrees()
|
||||
}
|
||||
}
|
||||
|
||||
async fn list_current_repo_worktrees_remote(
|
||||
&self,
|
||||
app_server: &AppServerSession,
|
||||
) -> anyhow::Result<Vec<WorktreeInfo>> {
|
||||
let runner = self
|
||||
.workspace_command_runner
|
||||
.clone()
|
||||
.context("remote worktree operations require a workspace command runner")?;
|
||||
crate::remote_worktree::list_current_repo_worktrees(
|
||||
&runner,
|
||||
&app_server.request_handle(),
|
||||
self.session_workspace_cwd(app_server),
|
||||
)
|
||||
.await
|
||||
let response: WorktreeListResponse = app_server
|
||||
.request_handle()
|
||||
.request_typed(ClientRequest::WorktreeList {
|
||||
request_id: worktree_request_id("worktree-list"),
|
||||
params: WorktreeListParams {
|
||||
cwd: Some(self.session_workspace_cwd(app_server).display().to_string()),
|
||||
},
|
||||
})
|
||||
.await?;
|
||||
Ok(response
|
||||
.data
|
||||
.into_iter()
|
||||
.map(worktree_info_from_api)
|
||||
.collect())
|
||||
}
|
||||
|
||||
async fn source_worktree_dirty_state(
|
||||
&self,
|
||||
app_server: &AppServerSession,
|
||||
) -> anyhow::Result<codex_worktree::DirtyState> {
|
||||
if self.remote_app_server_url.is_some() {
|
||||
let runner = self
|
||||
.workspace_command_runner
|
||||
.clone()
|
||||
.context("remote worktree operations require a workspace command runner")?;
|
||||
crate::remote_worktree::source_dirty_state(
|
||||
&runner,
|
||||
self.session_workspace_cwd(app_server),
|
||||
)
|
||||
.await
|
||||
} else {
|
||||
codex_worktree::dirty_state(self.config.cwd.as_path())
|
||||
}
|
||||
let response: WorktreeInspectSourceResponse = app_server
|
||||
.request_handle()
|
||||
.request_typed(ClientRequest::WorktreeInspectSource {
|
||||
request_id: worktree_request_id("worktree-inspect-source"),
|
||||
params: WorktreeInspectSourceParams {
|
||||
cwd: Some(self.session_workspace_cwd(app_server).display().to_string()),
|
||||
},
|
||||
})
|
||||
.await?;
|
||||
Ok(dirty_state_from_api(response.dirty))
|
||||
}
|
||||
|
||||
fn session_workspace_cwd<'a>(&'a self, app_server: &'a AppServerSession) -> &'a Path {
|
||||
@@ -401,20 +371,6 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
fn fetch_worktrees_for_picker(&mut self) {
|
||||
let query = WorktreeListQuery {
|
||||
codex_home: self.config.codex_home.to_path_buf(),
|
||||
source_cwd: Some(self.config.cwd.to_path_buf()),
|
||||
include_all_repos: false,
|
||||
};
|
||||
let cwd = self.config.cwd.to_path_buf();
|
||||
let app_event_tx = self.app_event_tx.clone();
|
||||
tokio::task::spawn_blocking(move || {
|
||||
let result = codex_worktree::list_worktrees(query).map_err(|err| err.to_string());
|
||||
app_event_tx.send(AppEvent::WorktreesLoaded { cwd, result });
|
||||
});
|
||||
}
|
||||
|
||||
fn spawn_worktree_create_request(
|
||||
&self,
|
||||
app_server: &AppServerSession,
|
||||
@@ -422,31 +378,24 @@ impl App {
|
||||
) {
|
||||
let cwd = request.source_cwd.clone();
|
||||
let app_event_tx = self.app_event_tx.clone();
|
||||
if self.remote_app_server_url.is_some() {
|
||||
let Some(runner) = self.workspace_command_runner.clone() else {
|
||||
app_event_tx.send(AppEvent::WorktreeCreated {
|
||||
cwd,
|
||||
result: Err(
|
||||
"remote worktree operations require a workspace command runner".to_string(),
|
||||
),
|
||||
});
|
||||
return;
|
||||
};
|
||||
let request_handle = app_server.request_handle();
|
||||
tokio::spawn(async move {
|
||||
let result =
|
||||
crate::remote_worktree::ensure_worktree(&runner, &request_handle, request)
|
||||
.await
|
||||
.map_err(|err| err.to_string());
|
||||
app_event_tx.send(AppEvent::WorktreeCreated { cwd, result });
|
||||
});
|
||||
} else {
|
||||
tokio::task::spawn_blocking(move || {
|
||||
let result =
|
||||
codex_worktree::ensure_worktree(request).map_err(|err| err.to_string());
|
||||
app_event_tx.send(AppEvent::WorktreeCreated { cwd, result });
|
||||
});
|
||||
}
|
||||
let request_handle = app_server.request_handle();
|
||||
tokio::spawn(async move {
|
||||
let result: Result<WorktreeCreateResponse, _> = request_handle
|
||||
.request_typed(ClientRequest::WorktreeCreate {
|
||||
request_id: worktree_request_id("worktree-create"),
|
||||
params: WorktreeCreateParams {
|
||||
cwd: Some(request.source_cwd.display().to_string()),
|
||||
branch: request.branch,
|
||||
base_ref: request.base_ref,
|
||||
dirty_policy: dirty_policy_to_api(request.dirty_policy),
|
||||
},
|
||||
})
|
||||
.await;
|
||||
let result = result
|
||||
.map(worktree_resolution_from_api)
|
||||
.map_err(|err| err.to_string());
|
||||
app_event_tx.send(AppEvent::WorktreeCreated { cwd, result });
|
||||
});
|
||||
}
|
||||
|
||||
async fn switch_to_worktree_info(
|
||||
@@ -680,6 +629,103 @@ impl App {
|
||||
self.file_search
|
||||
.update_search_dir(self.config.cwd.to_path_buf());
|
||||
}
|
||||
|
||||
async fn remove_worktree_via_app_server(
|
||||
&self,
|
||||
app_server: &AppServerSession,
|
||||
target: String,
|
||||
force: bool,
|
||||
delete_branch: bool,
|
||||
) -> anyhow::Result<WorktreeRemoveResponse> {
|
||||
app_server
|
||||
.request_handle()
|
||||
.request_typed(ClientRequest::WorktreeRemove {
|
||||
request_id: worktree_request_id("worktree-remove"),
|
||||
params: WorktreeRemoveParams {
|
||||
cwd: Some(self.session_workspace_cwd(app_server).display().to_string()),
|
||||
name_or_path: target,
|
||||
force,
|
||||
delete_branch,
|
||||
},
|
||||
})
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
}
|
||||
}
|
||||
|
||||
fn worktree_request_id(prefix: &str) -> RequestId {
|
||||
RequestId::String(format!("{prefix}-{}", Uuid::new_v4()))
|
||||
}
|
||||
|
||||
fn dirty_policy_to_api(value: DirtyPolicy) -> ApiWorktreeDirtyPolicy {
|
||||
match value {
|
||||
DirtyPolicy::Fail => ApiWorktreeDirtyPolicy::Fail,
|
||||
DirtyPolicy::Ignore => ApiWorktreeDirtyPolicy::Ignore,
|
||||
DirtyPolicy::CopyTracked => ApiWorktreeDirtyPolicy::CopyTracked,
|
||||
DirtyPolicy::CopyAll => ApiWorktreeDirtyPolicy::CopyAll,
|
||||
DirtyPolicy::MoveTracked => ApiWorktreeDirtyPolicy::MoveTracked,
|
||||
DirtyPolicy::MoveAll => ApiWorktreeDirtyPolicy::MoveAll,
|
||||
}
|
||||
}
|
||||
|
||||
fn dirty_state_from_api(value: ApiWorktreeDirtyState) -> codex_worktree::DirtyState {
|
||||
codex_worktree::DirtyState {
|
||||
has_staged_changes: value.has_staged_changes,
|
||||
has_unstaged_changes: value.has_unstaged_changes,
|
||||
has_untracked_files: value.has_untracked_files,
|
||||
}
|
||||
}
|
||||
|
||||
fn worktree_info_from_api(value: ApiWorktreeInfo) -> WorktreeInfo {
|
||||
WorktreeInfo {
|
||||
id: value.id,
|
||||
name: value.name,
|
||||
slug: value.slug,
|
||||
source: worktree_source_from_api(value.source),
|
||||
location: worktree_location_from_api(value.location),
|
||||
repo_name: value.repo_name,
|
||||
repo_root: PathBuf::from(value.repo_root),
|
||||
common_git_dir: PathBuf::from(value.common_git_dir),
|
||||
worktree_git_root: PathBuf::from(value.worktree_git_root),
|
||||
workspace_cwd: PathBuf::from(value.workspace_cwd),
|
||||
original_relative_cwd: PathBuf::from(value.original_relative_cwd),
|
||||
branch: value.branch,
|
||||
head: value.head,
|
||||
owner_thread_id: value.owner_thread_id,
|
||||
metadata_path: PathBuf::from(value.metadata_path),
|
||||
dirty: dirty_state_from_api(value.dirty),
|
||||
}
|
||||
}
|
||||
|
||||
fn worktree_source_from_api(value: ApiWorktreeSource) -> WorktreeSource {
|
||||
match value {
|
||||
ApiWorktreeSource::Cli => WorktreeSource::Cli,
|
||||
ApiWorktreeSource::App => WorktreeSource::App,
|
||||
ApiWorktreeSource::Legacy => WorktreeSource::Legacy,
|
||||
ApiWorktreeSource::Git => WorktreeSource::Git,
|
||||
}
|
||||
}
|
||||
|
||||
fn worktree_location_from_api(value: ApiWorktreeLocation) -> WorktreeLocation {
|
||||
match value {
|
||||
ApiWorktreeLocation::Sibling => WorktreeLocation::Sibling,
|
||||
ApiWorktreeLocation::CodexHome => WorktreeLocation::CodexHome,
|
||||
ApiWorktreeLocation::External => WorktreeLocation::External,
|
||||
}
|
||||
}
|
||||
|
||||
fn worktree_resolution_from_api(value: WorktreeCreateResponse) -> WorktreeResolution {
|
||||
WorktreeResolution {
|
||||
reused: value.reused,
|
||||
info: worktree_info_from_api(value.info),
|
||||
warnings: value
|
||||
.warnings
|
||||
.into_iter()
|
||||
.map(|warning| WorktreeWarning {
|
||||
message: warning.message,
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
fn worktree_session_message(
|
||||
|
||||
@@ -205,12 +205,6 @@ pub(crate) enum AppEvent {
|
||||
branch: String,
|
||||
},
|
||||
|
||||
/// Result of loading worktrees for the managed worktree picker.
|
||||
WorktreesLoaded {
|
||||
cwd: PathBuf,
|
||||
result: Result<Vec<codex_worktree::WorktreeInfo>, String>,
|
||||
},
|
||||
|
||||
/// Create or reuse a managed worktree and switch the TUI into it.
|
||||
CreateWorktreeAndSwitch {
|
||||
branch: String,
|
||||
|
||||
@@ -117,7 +117,6 @@ use color_eyre::eyre::ContextCompat;
|
||||
use color_eyre::eyre::Result;
|
||||
use color_eyre::eyre::WrapErr;
|
||||
use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use uuid::Uuid;
|
||||
|
||||
@@ -1430,7 +1429,6 @@ async fn thread_session_state_from_thread_start_response(
|
||||
config: &Config,
|
||||
thread_params_mode: ThreadParamsMode,
|
||||
) -> Result<ThreadSessionState, String> {
|
||||
bind_worktree_thread_best_effort(config, response.cwd.as_path(), &response.thread.id);
|
||||
let permission_profile = permission_profile_from_thread_response(
|
||||
&response.sandbox,
|
||||
response.permission_profile.as_ref(),
|
||||
@@ -1463,7 +1461,6 @@ async fn thread_session_state_from_thread_resume_response(
|
||||
config: &Config,
|
||||
thread_params_mode: ThreadParamsMode,
|
||||
) -> Result<ThreadSessionState, String> {
|
||||
bind_worktree_thread_best_effort(config, response.cwd.as_path(), &response.thread.id);
|
||||
let permission_profile = permission_profile_from_thread_response(
|
||||
&response.sandbox,
|
||||
response.permission_profile.as_ref(),
|
||||
@@ -1496,7 +1493,6 @@ async fn thread_session_state_from_thread_fork_response(
|
||||
config: &Config,
|
||||
thread_params_mode: ThreadParamsMode,
|
||||
) -> Result<ThreadSessionState, String> {
|
||||
bind_worktree_thread_best_effort(config, response.cwd.as_path(), &response.thread.id);
|
||||
let permission_profile = permission_profile_from_thread_response(
|
||||
&response.sandbox,
|
||||
response.permission_profile.as_ref(),
|
||||
@@ -1524,20 +1520,6 @@ async fn thread_session_state_from_thread_fork_response(
|
||||
.await
|
||||
}
|
||||
|
||||
fn bind_worktree_thread_best_effort(config: &Config, cwd: &Path, thread_id: &str) {
|
||||
match codex_worktree::resolve_worktree(config.codex_home.as_path(), cwd) {
|
||||
Ok(Some(_)) => {
|
||||
if let Err(err) = codex_worktree::bind_thread(cwd, thread_id) {
|
||||
tracing::warn!(?err, "failed to bind managed worktree to thread");
|
||||
}
|
||||
}
|
||||
Ok(None) => {}
|
||||
Err(err) => {
|
||||
tracing::warn!(?err, "failed to resolve managed worktree metadata");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn permission_profile_from_thread_response(
|
||||
sandbox: &codex_app_server_protocol::SandboxPolicy,
|
||||
permission_profile: Option<&codex_app_server_protocol::PermissionProfile>,
|
||||
|
||||
+88
-5
@@ -28,12 +28,17 @@ use codex_app_server_client::RemoteAppServerConnectArgs;
|
||||
use codex_app_server_protocol::Account as AppServerAccount;
|
||||
use codex_app_server_protocol::AskForApproval;
|
||||
use codex_app_server_protocol::AuthMode as AppServerAuthMode;
|
||||
use codex_app_server_protocol::ClientRequest;
|
||||
use codex_app_server_protocol::ConfigWarningNotification;
|
||||
use codex_app_server_protocol::RequestId;
|
||||
use codex_app_server_protocol::Thread as AppServerThread;
|
||||
use codex_app_server_protocol::ThreadListCwdFilter;
|
||||
use codex_app_server_protocol::ThreadListParams;
|
||||
use codex_app_server_protocol::ThreadSortKey as AppServerThreadSortKey;
|
||||
use codex_app_server_protocol::ThreadSourceKind;
|
||||
use codex_app_server_protocol::WorktreeCreateParams;
|
||||
use codex_app_server_protocol::WorktreeCreateResponse;
|
||||
use codex_app_server_protocol::WorktreeDirtyPolicy;
|
||||
use codex_cloud_requirements::cloud_requirements_loader_for_storage;
|
||||
use codex_config::CloudRequirementsLoader;
|
||||
use codex_config::ConfigLoadError;
|
||||
@@ -55,6 +60,7 @@ use codex_state::log_db;
|
||||
use codex_terminal_detection::terminal_info;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use codex_utils_absolute_path::canonicalize_existing_preserving_symlinks;
|
||||
use codex_utils_cli::WorktreeDirtyCliArg;
|
||||
use codex_utils_oss::ensure_oss_provider_ready;
|
||||
use codex_utils_oss::get_default_model_for_oss_provider;
|
||||
use color_eyre::eyre::WrapErr;
|
||||
@@ -179,7 +185,6 @@ mod tui;
|
||||
mod ui_consts;
|
||||
pub(crate) mod update_action;
|
||||
pub use update_action::UpdateAction;
|
||||
mod remote_worktree;
|
||||
mod worktree;
|
||||
mod worktree_labels;
|
||||
#[cfg(not(debug_assertions))]
|
||||
@@ -698,6 +703,39 @@ fn latest_session_cwd_filter<'a>(
|
||||
}
|
||||
}
|
||||
|
||||
async fn create_startup_worktree(
|
||||
app_server: &AppServerSession,
|
||||
cwd: Option<&Path>,
|
||||
branch: String,
|
||||
base_ref: Option<String>,
|
||||
dirty_policy: WorktreeDirtyCliArg,
|
||||
) -> color_eyre::Result<WorktreeCreateResponse> {
|
||||
app_server
|
||||
.request_handle()
|
||||
.request_typed(ClientRequest::WorktreeCreate {
|
||||
request_id: RequestId::String(format!("startup-worktree-{}", Uuid::new_v4())),
|
||||
params: WorktreeCreateParams {
|
||||
cwd: cwd.map(|cwd| cwd.display().to_string()),
|
||||
branch,
|
||||
base_ref,
|
||||
dirty_policy: worktree_dirty_policy_from_cli(dirty_policy),
|
||||
},
|
||||
})
|
||||
.await
|
||||
.map_err(color_eyre::eyre::Report::msg)
|
||||
}
|
||||
|
||||
fn worktree_dirty_policy_from_cli(value: WorktreeDirtyCliArg) -> WorktreeDirtyPolicy {
|
||||
match value {
|
||||
WorktreeDirtyCliArg::Fail => WorktreeDirtyPolicy::Fail,
|
||||
WorktreeDirtyCliArg::Ignore => WorktreeDirtyPolicy::Ignore,
|
||||
WorktreeDirtyCliArg::CopyTracked => WorktreeDirtyPolicy::CopyTracked,
|
||||
WorktreeDirtyCliArg::CopyAll => WorktreeDirtyPolicy::CopyAll,
|
||||
WorktreeDirtyCliArg::MoveTracked => WorktreeDirtyPolicy::MoveTracked,
|
||||
WorktreeDirtyCliArg::MoveAll => WorktreeDirtyPolicy::MoveAll,
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn run_main(
|
||||
mut cli: Cli,
|
||||
arg0_paths: Arg0DispatchPaths,
|
||||
@@ -1089,11 +1127,11 @@ pub async fn run_main(
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn run_ratatui_app(
|
||||
cli: Cli,
|
||||
mut cli: Cli,
|
||||
arg0_paths: Arg0DispatchPaths,
|
||||
loader_overrides: LoaderOverrides,
|
||||
app_server_target: AppServerTarget,
|
||||
remote_cwd_override: Option<PathBuf>,
|
||||
mut remote_cwd_override: Option<PathBuf>,
|
||||
initial_config: Config,
|
||||
overrides: ConfigOverrides,
|
||||
cli_kv_overrides: Vec<(String, toml::Value)>,
|
||||
@@ -1175,6 +1213,51 @@ async fn run_ratatui_app(
|
||||
},
|
||||
);
|
||||
|
||||
let startup_worktree_requested = cli.worktree.is_some();
|
||||
let mut initial_config = initial_config;
|
||||
if let Some(branch) = cli.worktree.take() {
|
||||
let Some(startup_app_server) = app_server.as_mut() else {
|
||||
unreachable!("app server should exist while resolving startup worktree");
|
||||
};
|
||||
let response = match create_startup_worktree(
|
||||
startup_app_server,
|
||||
if remote_mode {
|
||||
remote_cwd_override.as_deref()
|
||||
} else {
|
||||
Some(initial_config.cwd.as_path())
|
||||
},
|
||||
branch,
|
||||
cli.worktree_base.take(),
|
||||
cli.worktree_dirty,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(response) => response,
|
||||
Err(err) => {
|
||||
shutdown_app_server_if_present(app_server.take()).await;
|
||||
terminal_restore_guard.restore_silently();
|
||||
session_log::log_session_end();
|
||||
return Err(err);
|
||||
}
|
||||
};
|
||||
let worktree_cwd = PathBuf::from(response.info.workspace_cwd.clone());
|
||||
if remote_mode {
|
||||
remote_cwd_override = Some(worktree_cwd.clone());
|
||||
startup_app_server.set_remote_cwd_override(Some(worktree_cwd));
|
||||
} else {
|
||||
initial_config = load_config_or_exit_with_fallback_cwd(
|
||||
cli_kv_overrides.clone(),
|
||||
overrides.clone(),
|
||||
cloud_requirements.clone(),
|
||||
Some(worktree_cwd),
|
||||
)
|
||||
.await;
|
||||
}
|
||||
initial_config
|
||||
.startup_warnings
|
||||
.extend(response.warnings.into_iter().map(|warning| warning.message));
|
||||
}
|
||||
|
||||
let should_show_trust_screen_flag = !remote_mode && should_show_trust_screen(&initial_config);
|
||||
let mut trust_decision_was_made = false;
|
||||
let login_status = if initial_config.model_provider.requires_openai_auth {
|
||||
@@ -1391,7 +1474,7 @@ async fn run_ratatui_app(
|
||||
};
|
||||
|
||||
let current_cwd = config.cwd.clone();
|
||||
let allow_prompt = !remote_mode && cli.cwd.is_none();
|
||||
let allow_prompt = !remote_mode && cli.cwd.is_none() && !startup_worktree_requested;
|
||||
let action_and_target_session_if_resume_or_fork = match &session_selection {
|
||||
resume_picker::SessionSelection::Resume(target_session) => {
|
||||
Some((CwdPromptAction::Resume, target_session))
|
||||
@@ -1403,7 +1486,7 @@ async fn run_ratatui_app(
|
||||
};
|
||||
let fallback_cwd = match action_and_target_session_if_resume_or_fork {
|
||||
Some((action, target_session)) => {
|
||||
if remote_mode {
|
||||
if startup_worktree_requested || remote_mode {
|
||||
Some(current_cwd.to_path_buf())
|
||||
} else {
|
||||
match resolve_cwd_for_resume_or_fork(
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user