Skip to content

feat: project field write operations (create_project_field, add_project_field_option) #2

Description

@gastrodon

Summary

No tools exist to create or modify project fields or their options. Autonomous agents need this to set up project boards programmatically (e.g. adding a new Status column, creating a custom field).

Upstream gap identified in: github#2679

New Tools

create_project_field

Parameters:

  • owner_type (required): "user" or "org"
  • owner (required): login
  • project_number (required): int
  • name (required): field name
  • data_type (required): "TEXT" | "NUMBER" | "DATE" | "SINGLE_SELECT" | "ITERATION"
  • options (optional): array of option names for SINGLE_SELECT

add_project_field_option

Add a new option to an existing single-select field.

Parameters:

  • owner_type (required): "user" or "org"
  • owner (required): login
  • project_number (required): int
  • field_id (required): numeric field ID
  • option_name (required): name of the new option
  • color (optional): "BLUE" | "GREEN" | "RED" | "YELLOW" | "ORANGE" | "PINK" | "PURPLE" | "GRAY"

delete_project_field

Parameters:

  • owner_type, owner, project_number, field_id

Implementation

These require GraphQL mutations. Use the githubv4 / gqlClient pattern already present in the codebase.

GraphQL: add_project_field_option

mutation AddFieldOption($fieldId: ID!, $name: String!, $color: ProjectV2SingleSelectFieldOptionColor!) {
  addProjectV2SingleSelectFieldOption(input: {
    fieldId: $fieldId
    name: $name
    color: $color
  }) {
    projectV2SingleSelectField {
      id
      name
      options { id name color }
    }
  }
}

GraphQL: create_project_field

mutation CreateField($projectId: ID!, $name: String!, $dataType: ProjectV2CustomFieldType!) {
  createProjectV2Field(input: {
    projectId: $projectId
    name: $name
    dataType: $dataType
  }) {
    projectV2Field {
      ... on ProjectV2Field { id name dataType }
      ... on ProjectV2SingleSelectField { id name options { id name } }
    }
  }
}

Finding project/field node IDs

Project node_id: GET /users/{owner}/projectsV2/{project_number}node_id
Field node_id: use listProjectFieldsRaw (already in this fork) → match by numeric id, use node_id

GraphQL client pattern

Search for GetGQLClientFn or existing graphql usage in pkg/github/ to find the right pattern for mutations. If githubv4 typed client is awkward for mutations, use client.NewRequest POST to /graphql with a raw body.

Files to Modify

  • pkg/github/projects.go — implement three new tool functions
  • pkg/github/projects_test.go — unit tests with mocked responses
  • toolset registration — add to projects toolset

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions