Skip to content

Commit 5d47ccc

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 c0dca1f commit 5d47ccc

6 files changed

Lines changed: 832 additions & 22 deletions

File tree

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,22 +1028,26 @@ The following sets of tools are available:
10281028
- `project_number`: The project's number. Required for 'list_project_fields', 'list_project_items', and 'list_project_status_updates' methods. (number, optional)
10291029
- `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)
10301030

1031-
- **projects_write** - Modify GitHub Project items
1031+
- **projects_write** - Manage GitHub Projects
10321032
- **Required OAuth Scopes**: `project`
10331033
- `body`: The body of the status update (markdown). Used for 'create_project_status_update' method. (string, optional)
1034+
- `field_name`: The name of the iteration field (e.g. 'Sprint'). Required for 'create_iteration_field' method. (string, optional)
10341035
- `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)
10351036
- `item_id`: The project item ID. Required for 'update_project_item' and 'delete_project_item' methods. (number, optional)
10361037
- `item_owner`: The owner (user or organization) of the repository containing the issue or pull request. Required for 'add_project_item' method. (string, optional)
10371038
- `item_repo`: The name of the repository containing the issue or pull request. Required for 'add_project_item' method. (string, optional)
10381039
- `item_type`: The item's type, either issue or pull_request. Required for 'add_project_item' method. (string, optional)
1040+
- `iteration_duration`: Duration in days for iterations of the field (e.g. 7 for weekly, 14 for bi-weekly). Required for 'create_iteration_field' method. (number, optional)
1041+
- `iterations`: Custom iterations for 'create_iteration_field' method. Only set this when you need iterations with varying durations, breaks between them, or specific titles. Otherwise omit it: GitHub auto-creates three iterations of 'iteration_duration' days starting on 'start_date', which is the right choice for most cases. (object[], optional)
10391042
- `method`: The method to execute (string, required)
10401043
- `owner`: The project owner (user or organization login). The name is not case sensitive. (string, required)
1041-
- `owner_type`: Owner type (user or org). If not provided, will be automatically detected. (string, optional)
1042-
- `project_number`: The project's number. (number, required)
1044+
- `owner_type`: Owner type (user or org). Required for 'create_project' method. If not provided for other methods, will be automatically detected. (string, optional)
1045+
- `project_number`: The project's number. Required for all methods except 'create_project'. (number, optional)
10431046
- `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)
1044-
- `start_date`: The start date of the status update in YYYY-MM-DD format. Used for 'create_project_status_update' method. (string, optional)
1047+
- `start_date`: Start date in YYYY-MM-DD format. Used for 'create_project_status_update' and 'create_iteration_field' methods. (string, optional)
10451048
- `status`: The status of the project. Used for 'create_project_status_update' method. (string, optional)
10461049
- `target_date`: The target date of the status update in YYYY-MM-DD format. Used for 'create_project_status_update' method. (string, optional)
1050+
- `title`: The project title. Required for 'create_project' method. (string, optional)
10471051
- `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)
10481052

10491053
</details>

pkg/github/__toolsnaps__/projects_write.snap

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
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+
"field_name": {
14+
"description": "The name of the iteration field (e.g. 'Sprint'). Required for 'create_iteration_field' method.",
15+
"type": "string"
16+
},
1317
"issue_number": {
1418
"description": "The issue number (use when item_type is 'issue' for 'add_project_item' method). Provide either issue_number or pull_request_number.",
1519
"type": "number"
@@ -34,13 +38,46 @@
3438
],
3539
"type": "string"
3640
},
41+
"iteration_duration": {
42+
"description": "Duration in days for iterations of the field (e.g. 7 for weekly, 14 for bi-weekly). Required for 'create_iteration_field' method.",
43+
"type": "number"
44+
},
45+
"iterations": {
46+
"description": "Custom iterations for 'create_iteration_field' method. Only set this when you need iterations with varying durations, breaks between them, or specific titles. Otherwise omit it: GitHub auto-creates three iterations of 'iteration_duration' days starting on 'start_date', which is the right choice for most cases.",
47+
"items": {
48+
"additionalProperties": false,
49+
"properties": {
50+
"duration": {
51+
"description": "Duration in days",
52+
"type": "number"
53+
},
54+
"start_date": {
55+
"description": "Start date in YYYY-MM-DD format",
56+
"type": "string"
57+
},
58+
"title": {
59+
"description": "Iteration title (e.g. 'Sprint 1')",
60+
"type": "string"
61+
}
62+
},
63+
"required": [
64+
"title",
65+
"start_date",
66+
"duration"
67+
],
68+
"type": "object"
69+
},
70+
"type": "array"
71+
},
3772
"method": {
3873
"description": "The method to execute",
3974
"enum": [
4075
"add_project_item",
4176
"update_project_item",
4277
"delete_project_item",
43-
"create_project_status_update"
78+
"create_project_status_update",
79+
"create_project",
80+
"create_iteration_field"
4481
],
4582
"type": "string"
4683
},
@@ -49,23 +86,23 @@
4986
"type": "string"
5087
},
5188
"owner_type": {
52-
"description": "Owner type (user or org). If not provided, will be automatically detected.",
89+
"description": "Owner type (user or org). Required for 'create_project' method. If not provided for other methods, will be automatically detected.",
5390
"enum": [
5491
"user",
5592
"org"
5693
],
5794
"type": "string"
5895
},
5996
"project_number": {
60-
"description": "The project's number.",
97+
"description": "The project's number. Required for all methods except 'create_project'.",
6198
"type": "number"
6299
},
63100
"pull_request_number": {
64101
"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.",
65102
"type": "number"
66103
},
67104
"start_date": {
68-
"description": "The start date of the status update in YYYY-MM-DD format. Used for 'create_project_status_update' method.",
105+
"description": "Start date in YYYY-MM-DD format. Used for 'create_project_status_update' and 'create_iteration_field' methods.",
69106
"type": "string"
70107
},
71108
"status": {
@@ -83,15 +120,18 @@
83120
"description": "The target date of the status update in YYYY-MM-DD format. Used for 'create_project_status_update' method.",
84121
"type": "string"
85122
},
123+
"title": {
124+
"description": "The project title. Required for 'create_project' method.",
125+
"type": "string"
126+
},
86127
"updated_field": {
87128
"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.",
88129
"type": "object"
89130
}
90131
},
91132
"required": [
92133
"method",
93-
"owner",
94-
"project_number"
134+
"owner"
95135
],
96136
"type": "object"
97137
},

0 commit comments

Comments
 (0)