Skip to content

Commit 8298307

Browse files
SamMorrowDrumsJoão Doria de SouzaCopilot
committed
feat: add create_project and create_iteration_field methods to projects_write
Adds two new methods to the consolidated projects_write tool: - create_project: creates a new GitHub ProjectsV2 for a user or org - create_iteration_field: adds an iteration field to an existing project Changes addressing review feedback: - Validate owner_type is exactly 'user' or 'org' in create_project - Use resolveProjectNodeID (GraphQL) instead of getProjectNodeID (REST) to avoid HTTP response body leaks - Add omitempty to Iterations JSON tag - Rename iterations item field startDate to start_date for consistency - Validate iteration elements instead of silently skipping invalid ones - Use explicit response structs with snake_case JSON tags - Add test for auto-detected owner_type in create_iteration_field - Use stubExporters() in test deps for nil-safety Co-authored-by: João Doria de Souza <jdoria@github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 95726ad commit 8298307

File tree

5 files changed

+816
-22
lines changed

5 files changed

+816
-22
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,22 +1014,26 @@ The following sets of tools are available:
10141014
- `project_number`: The project's number. Required for 'list_project_fields', 'list_project_items', and 'list_project_status_updates' methods. (number, optional)
10151015
- `query`: Filter/query string. For list_projects: filter by title text and state (e.g. "roadmap is:open"). For list_project_items: advanced filtering using GitHub's project filtering syntax. (string, optional)
10161016

1017-
- **projects_write** - Modify GitHub Project items
1017+
- **projects_write** - Manage GitHub Projects
10181018
- **Required OAuth Scopes**: `project`
10191019
- `body`: The body of the status update (markdown). Used for 'create_project_status_update' method. (string, optional)
1020+
- `duration`: Duration in days for each iteration (e.g. 7 for weekly, 14 for bi-weekly). Required for 'create_iteration_field' method. (number, optional)
1021+
- `field_name`: The name of the iteration field (e.g. 'Sprint'). Required for 'create_iteration_field' method. (string, optional)
10201022
- `issue_number`: The issue number (use when item_type is 'issue' for 'add_project_item' method). Provide either issue_number or pull_request_number. (number, optional)
10211023
- `item_id`: The project item ID. Required for 'update_project_item' and 'delete_project_item' methods. (number, optional)
10221024
- `item_owner`: The owner (user or organization) of the repository containing the issue or pull request. Required for 'add_project_item' method. (string, optional)
10231025
- `item_repo`: The name of the repository containing the issue or pull request. Required for 'add_project_item' method. (string, optional)
10241026
- `item_type`: The item's type, either issue or pull_request. Required for 'add_project_item' method. (string, optional)
1027+
- `iterations`: Optional array of iteration definitions for 'create_iteration_field' method. Each entry defines a named iteration with a start date and duration. If omitted, the field is created with default iteration settings. (object[], optional)
10251028
- `method`: The method to execute (string, required)
10261029
- `owner`: The project owner (user or organization login). The name is not case sensitive. (string, required)
1027-
- `owner_type`: Owner type (user or org). If not provided, will be automatically detected. (string, optional)
1028-
- `project_number`: The project's number. (number, required)
1030+
- `owner_type`: Owner type (user or org). Required for 'create_project' method. If not provided for other methods, will be automatically detected. (string, optional)
1031+
- `project_number`: The project's number. Required for all methods except 'create_project'. (number, optional)
10291032
- `pull_request_number`: The pull request number (use when item_type is 'pull_request' for 'add_project_item' method). Provide either issue_number or pull_request_number. (number, optional)
1030-
- `start_date`: The start date of the status update in YYYY-MM-DD format. Used for 'create_project_status_update' method. (string, optional)
1033+
- `start_date`: Start date in YYYY-MM-DD format. Used for 'create_project_status_update' and 'create_iteration_field' methods. (string, optional)
10311034
- `status`: The status of the project. Used for 'create_project_status_update' method. (string, optional)
10321035
- `target_date`: The target date of the status update in YYYY-MM-DD format. Used for 'create_project_status_update' method. (string, optional)
1036+
- `title`: The project title. Required for 'create_project' method. (string, optional)
10331037
- `updated_field`: Object consisting of the ID of the project field to update and the new value for the field. To clear the field, set value to null. Example: {"id": 123456, "value": "New Value"}. Required for 'update_project_item' method. (object, optional)
10341038

10351039
</details>

pkg/github/__toolsnaps__/projects_write.snap

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
{
22
"annotations": {
33
"destructiveHint": true,
4-
"title": "Modify GitHub Project items"
4+
"title": "Manage GitHub Projects"
55
},
6-
"description": "Add, update, or delete project items, or create status updates in a GitHub Project.",
6+
"description": "Create and manage GitHub Projects: create projects, add/update/delete items, create status updates, and add iteration fields.",
77
"inputSchema": {
88
"properties": {
99
"body": {
1010
"description": "The body of the status update (markdown). Used for 'create_project_status_update' method.",
1111
"type": "string"
1212
},
13+
"duration": {
14+
"description": "Duration in days for each iteration (e.g. 7 for weekly, 14 for bi-weekly). Required for 'create_iteration_field' method.",
15+
"type": "number"
16+
},
17+
"field_name": {
18+
"description": "The name of the iteration field (e.g. 'Sprint'). Required for 'create_iteration_field' method.",
19+
"type": "string"
20+
},
1321
"issue_number": {
1422
"description": "The issue number (use when item_type is 'issue' for 'add_project_item' method). Provide either issue_number or pull_request_number.",
1523
"type": "number"
@@ -34,13 +42,41 @@
3442
],
3543
"type": "string"
3644
},
45+
"iterations": {
46+
"description": "Optional array of iteration definitions for 'create_iteration_field' method. Each entry defines a named iteration with a start date and duration. If omitted, the field is created with default iteration settings.",
47+
"items": {
48+
"properties": {
49+
"duration": {
50+
"description": "Duration in days",
51+
"type": "number"
52+
},
53+
"start_date": {
54+
"description": "Start date in YYYY-MM-DD format",
55+
"type": "string"
56+
},
57+
"title": {
58+
"description": "Iteration title (e.g. 'Sprint 1')",
59+
"type": "string"
60+
}
61+
},
62+
"required": [
63+
"title",
64+
"start_date",
65+
"duration"
66+
],
67+
"type": "object"
68+
},
69+
"type": "array"
70+
},
3771
"method": {
3872
"description": "The method to execute",
3973
"enum": [
4074
"add_project_item",
4175
"update_project_item",
4276
"delete_project_item",
43-
"create_project_status_update"
77+
"create_project_status_update",
78+
"create_project",
79+
"create_iteration_field"
4480
],
4581
"type": "string"
4682
},
@@ -49,23 +85,23 @@
4985
"type": "string"
5086
},
5187
"owner_type": {
52-
"description": "Owner type (user or org). If not provided, will be automatically detected.",
88+
"description": "Owner type (user or org). Required for 'create_project' method. If not provided for other methods, will be automatically detected.",
5389
"enum": [
5490
"user",
5591
"org"
5692
],
5793
"type": "string"
5894
},
5995
"project_number": {
60-
"description": "The project's number.",
96+
"description": "The project's number. Required for all methods except 'create_project'.",
6197
"type": "number"
6298
},
6399
"pull_request_number": {
64100
"description": "The pull request number (use when item_type is 'pull_request' for 'add_project_item' method). Provide either issue_number or pull_request_number.",
65101
"type": "number"
66102
},
67103
"start_date": {
68-
"description": "The start date of the status update in YYYY-MM-DD format. Used for 'create_project_status_update' method.",
104+
"description": "Start date in YYYY-MM-DD format. Used for 'create_project_status_update' and 'create_iteration_field' methods.",
69105
"type": "string"
70106
},
71107
"status": {
@@ -83,15 +119,18 @@
83119
"description": "The target date of the status update in YYYY-MM-DD format. Used for 'create_project_status_update' method.",
84120
"type": "string"
85121
},
122+
"title": {
123+
"description": "The project title. Required for 'create_project' method.",
124+
"type": "string"
125+
},
86126
"updated_field": {
87127
"description": "Object consisting of the ID of the project field to update and the new value for the field. To clear the field, set value to null. Example: {\"id\": 123456, \"value\": \"New Value\"}. Required for 'update_project_item' method.",
88128
"type": "object"
89129
}
90130
},
91131
"required": [
92132
"method",
93-
"owner",
94-
"project_number"
133+
"owner"
95134
],
96135
"type": "object"
97136
},

0 commit comments

Comments
 (0)