Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
5014c36
add AI coding agent instructions to AGENTS.md
Dec 5, 2025
470c7db
chore: initialize SpecKit framework for Spec-Driven Development
Dec 5, 2025
12e34b3
chore: add SpecKit agent definitions for VS Code Copilot
Dec 5, 2025
2d85fab
docs: add GitHub Copilot plugin research and specification
Dec 5, 2025
585a17d
Add comprehensive GitHub Copilot API research and implementation stra…
Dec 5, 2025
60798d1
feat: add comprehensive specification and quality checklist for GitHu…
Dec 5, 2025
a849964
feat: update Phase 1 spec for Adoption metrics only
Dec 5, 2025
f4d44ac
Merge updated Phase 1 spec
Dec 5, 2025
f80fd49
refactor: explicitly include engaged users in Adoption Dashboard requ…
Dec 9, 2025
f2b1052
refactor: remove team-level metrics from Phase 1 scope
Dec 9, 2025
7be0b3e
refactor: specify raw username storage for seat assignments
Dec 9, 2025
7439621
refactor: remove PR summary usage from Phase 1 scope
Dec 9, 2025
2af4f7e
Refactor code structure for improved readability and maintainability
Dec 11, 2025
06276a2
refactor: add complete API response schemas to research summary
Dec 11, 2025
d4dcddf
feat: implement GitHub Copilot Adoption Plugin with comprehensive dat…
Dec 11, 2025
41712f1
Merge branch 'worktree-2025-12-11T18-21-24' into 001-copilot-metrics-…
Dec 11, 2025
3a4bd1b
feat: enhance GitHub Copilot plugin plan with detailed API surface an…
Dec 11, 2025
d6add91
Merge branch 'apache:main' into main
ewega Dec 11, 2025
05d20aa
feat: scaffold copilot plugin foundation
Dec 11, 2025
a5fbd1a
copilot: add connection & scope APIs
Dec 16, 2025
c1a76b4
copilot: ingest Copilot metrics and seats
Dec 16, 2025
9619fef
spec: update Copilot plugin task checklist
Dec 16, 2025
308bb87
grafana: add Copilot adoption dashboard
Dec 16, 2025
430c00c
docs: document Copilot adoption dashboard
Dec 16, 2025
8f271e3
feat(copilot): implement DataSourcePipelinePlan for blueprint v2.0.0 …
Dec 23, 2025
79094de
copilot: set auth header for API client
Jan 2, 2026
bd9b64a
copilot: clamp metrics date range to API window
Jan 2, 2026
b025ff1
copilot: accept seat API response shapes
Jan 2, 2026
e8aef8b
copilot: add RawDataOrigin to tool models
Jan 5, 2026
00e1b5d
copilot: extract seats and sync seat totals
Jan 5, 2026
00d5aaa
copilot: update e2e fixtures for seats and language metrics
Jan 5, 2026
97b147e
grafana: fix Copilot dashboard seat axis and editor pie
Jan 5, 2026
1b3d4fe
Merge branch 'main' into 001-copilot-metrics-plugin
ewega Jan 5, 2026
839ac67
chore: polish Copilot Phase 7 docs
Jan 5, 2026
f82540a
Merge branch '001-copilot-metrics-plugin' of https://github.com/ewega…
Jan 5, 2026
8e246e1
Merge branch 'main' into 001-copilot-metrics-plugin
ewega Jan 6, 2026
9eac64d
fix(grafana): disable folder structure creation for dashboards
Jan 9, 2026
ca2cd8b
Initial plan
Copilot Jan 12, 2026
b1aabd8
Fix e2e test CSV timestamp formats to match MySQL output
Copilot Jan 12, 2026
31010a8
Complete T029 - End to End tests validation
Copilot Jan 12, 2026
6e2fcd8
Merge pull request #12 from ewega/copilot/add-end-to-end-tests
ewega Jan 12, 2026
58b9fb8
speckit: add tasks to enhance adoption metrics with new Stat panels a…
Jan 13, 2026
3f2313e
Merge branch '001-copilot-metrics-plugin' of https://github.com/ewega…
Jan 13, 2026
6d86043
Change folder to gh-copilot
Jan 13, 2026
8296fad
Clean Up Speckit
Jan 13, 2026
6802a0c
Merge branch 'main' into 001-copilot-metrics-plugin
ewega Jan 13, 2026
8797b10
Initial plan
Copilot Jan 14, 2026
353144b
Update all import paths and plugin name from copilot to gh-copilot
Copilot Jan 14, 2026
6f4fee4
Rename Copilot types to GhCopilot following DevLake naming conventions
Copilot Jan 15, 2026
9bdcba2
Fix error messages to reference GhCopilotTaskData instead of CopilotT…
Copilot Jan 15, 2026
d465096
Merge branch 'main' of https://github.com/ewega/incubator-devlake
Jan 15, 2026
dc39060
feat: update .gitignore to include speckit and GitHub agent files
Jan 15, 2026
0007762
Merge pull request #17 from ewega/copilot/rename-plugin-identifier-to…
ewega Jan 15, 2026
8e4b0c7
Initial plan
Copilot Jan 15, 2026
29c0d37
feat: add gh-copilot config-ui icon
Copilot Jan 15, 2026
c9e7311
docs: add gh-copilot doc link
Copilot Jan 15, 2026
1101936
Fix Copilot plugin ordering and icon fallback
Jan 16, 2026
1ccbfc8
Merge pull request #18 from ewega/copilot/update-github-copilot-icon
ewega Jan 16, 2026
51ed4f4
Add run-debug skill guidance and UI plugin id fix
Jan 16, 2026
e5e3ec1
feat: add name and fullName fields to GhCopilotScope and migration sc…
Jan 16, 2026
4286ac3
Merge branch 'main' into 001-copilot-metrics-plugin
ewega Jan 16, 2026
a2b9ac8
Merge branch 'main' into 001-copilot-metrics-plugin
ewega Jan 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,20 @@
config-ui/
grafana/
releases/

# Common ignores
.DS_Store
Thumbs.db
*.log
.env
.env.*

# Editor/IDE
.vscode/
.idea/

# Dependency & build outputs
**/node_modules/
**/dist/
**/build/
**/coverage/
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ local.js
/.nova
*.sublime*

# Agent skills (local-only)
.github/skills/


# OS metadata
.DS_Store
Expand Down Expand Up @@ -165,4 +168,10 @@ venv
/backend/plugins/gitextractor/parser/output*
/backend/plugins/gitextractor/parser/demo_repo/

__debug_bin*
__debug_bin*

# speckit
.specify
specs/
.github/agents/
.github/prompts/
6 changes: 5 additions & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ FROM builder as build

WORKDIR /app
COPY . /app
RUN find /app/scripts -type f -name "*.sh" -exec sed -i 's/\r$//' {} + && \
find /app/scripts -type f -name "*.sh" -exec chmod +x {} +
ENV GOBIN=/app/bin

ARG TARGETPLATFORM
Expand Down Expand Up @@ -143,7 +145,9 @@ RUN mkdir logs
VOLUME /app/logs

# Setup Python
COPY python/ /app/python/
COPY --chown=devlake:devlake python/ /app/python/
RUN find /app/python -type f -name "*.sh" -exec sed -i 's/\r$//' {} + && \
find /app/python -type f -name "*.sh" -exec chmod +x {} +
RUN python3 -m pip install --no-cache --upgrade pip setuptools && \
python3 -m pip install --no-cache -r python/requirements.txt && \
python3 -m pip install --upgrade pip
Expand Down
108 changes: 108 additions & 0 deletions backend/plugins/gh-copilot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# GitHub Copilot Plugin (Adoption Metrics)

This plugin ingests GitHub Copilot **organization-level adoption metrics** (daily usage and seat assignments) and provides a Grafana dashboard for adoption trends.

It follows the same structure/patterns as other DevLake data-source plugins (notably `backend/plugins/q_dev`).

## What it collects

**Phase 1 endpoints** (GitHub Copilot REST API):

- `GET /orgs/{org}/copilot/billing`
- `GET /orgs/{org}/copilot/billing/seats`
- `GET /orgs/{org}/copilot/metrics`

**Stored data (tool layer)**:

- `_tool_copilot_org_metrics` (daily aggregates)
- `_tool_copilot_language_metrics` (editor/language breakdown)
- `_tool_copilot_seats` (seat assignments)

## Data flow (high level)

```mermaid
flowchart LR
GH[GitHub Copilot REST API]
RAW[(Raw tables\n_raw_copilot_*)]
TOOL[(Tool tables\n_tool_copilot_*)]
GRAF[Grafana Dashboard\nGitHub Copilot Adoption]

GH --> RAW --> TOOL --> GRAF
```

## Repository layout

- `api/` – REST layer for connections/scopes
- `impl/` – plugin meta, options, connection helpers
- `models/` – tool-layer models + migrations
- `tasks/` – collectors/extractors and pipeline registration
- `e2e/` – E2E fixtures and golden CSV assertions
- `docs/` – documentation assets

## Setup

### Prerequisites

- GitHub Copilot Business or Enterprise enabled for the target organization
- A token that can access GitHub Copilot billing/metrics (classic PAT with `manage_billing:copilot` works)

### 1) Create a connection

1. DevLake UI → **Data Integrations → Add Connection → GitHub Copilot**
2. Fill in:
- **Name**: e.g. `GitHub Copilot Octodemo`
- **Endpoint**: defaults to `https://api.github.com`
- **Organization**: GitHub org slug
- **Token**: PAT with required scope
3. Click **Test Connection** (calls `GET /orgs/{org}/copilot/billing`).
4. Save the connection.

### 2) Create a scope

Add an organization scope for that connection. For Phase 1, `implementationDate` is optional.

### 3) Create a blueprint (recipe)

Use a blueprint plan like:

```json
[
[
{
"plugin": "gh-copilot",
"options": {
"connectionId": 1,
"scopeId": "octodemo"
}
}
]
]
```

Run the blueprint daily to keep metrics up to date.

## Dashboard

The Grafana dashboard JSON is in `grafana/dashboards/copilot/adoption.json`.

Link: `grafana/dashboards/copilot/adoption.json`

## Error handling guidance

- **403 Forbidden** → token missing required billing/metrics scope, or org lacks GitHub Copilot access
- **404 Not Found** → incorrect org slug, or GitHub Copilot endpoints unavailable for the org
- **422 Unprocessable Entity** → GitHub Copilot metrics disabled in GitHub org settings

- **429 Too Many Requests** → respect `Retry-After`; collectors implement backoff/retry

Tokens are sanitized before persisting. When patching an existing connection, omit the token to retain the encrypted value already stored in DevLake.

## Limitations (Phase 1)

- Metrics endpoint is limited to a rolling **100-day** window (GitHub API constraint)
- GitHub enforces a privacy threshold (often **≥ 5 engaged users**) and may omit daily data
- Enterprise download endpoints and per-user metrics (JSONL exports) are intentionally deferred to Phase 2+

## More docs

- Spec quickstart: `specs/001-copilot-metrics-plugin/quickstart.md`
87 changes: 87 additions & 0 deletions backend/plugins/gh-copilot/api/blueprint_v200.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package api

import (
"github.com/apache/incubator-devlake/core/errors"
coreModels "github.com/apache/incubator-devlake/core/models"
"github.com/apache/incubator-devlake/core/plugin"
helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
"github.com/apache/incubator-devlake/helpers/srvhelper"
"github.com/apache/incubator-devlake/plugins/gh-copilot/models"
"github.com/apache/incubator-devlake/plugins/gh-copilot/tasks"
)

// MakeDataSourcePipelinePlanV200 generates the pipeline plan for blueprint v2.0.0.
func MakeDataSourcePipelinePlanV200(
subtaskMetas []plugin.SubTaskMeta,
connectionId uint64,
bpScopes []*coreModels.BlueprintScope,
) (coreModels.PipelinePlan, []plugin.Scope, errors.Error) {
// load connection and scopes from the db
_, err := dsHelper.ConnSrv.FindByPk(connectionId)
if err != nil {
return nil, nil, err
}
// map blueprint scopes (scopeId/scopeConfigId) to concrete stored scopes
scopeDetails, err := dsHelper.ScopeSrv.MapScopeDetails(connectionId, bpScopes)
if err != nil {
return nil, nil, err
}

plan, err := makeDataSourcePipelinePlanV200(subtaskMetas, scopeDetails)
if err != nil {
return nil, nil, err
}

// Copilot metrics are org-level and currently don't map to a standard domain-layer top-level entity.
// Return an empty scope list to avoid adding meaningless project mappings.
return plan, nil, nil
}

func makeDataSourcePipelinePlanV200(
subtaskMetas []plugin.SubTaskMeta,
scopeDetails []*srvhelper.ScopeDetail[models.GhCopilotScope, srvhelper.NoScopeConfig],
) (coreModels.PipelinePlan, errors.Error) {
plan := make(coreModels.PipelinePlan, len(scopeDetails))
for i, scopeDetail := range scopeDetails {
stage := plan[i]
if stage == nil {
stage = coreModels.PipelineStage{}
}

scope := scopeDetail.Scope
task, err := helper.MakePipelinePlanTask(
"gh-copilot",
subtaskMetas,
nil,
tasks.GhCopilotOptions{
ConnectionId: scope.ConnectionId,
ScopeId: scope.Id,
},
)
if err != nil {
return nil, err
}

stage = append(stage, task)
plan[i] = stage
}

return plan, nil
}
106 changes: 106 additions & 0 deletions backend/plugins/gh-copilot/api/connection.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package api

import (
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/plugin"
helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
"github.com/apache/incubator-devlake/plugins/gh-copilot/models"
)

// PostConnections creates a new Copilot connection.
func PostConnections(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) {
connection := &models.GhCopilotConnection{}
if err := helper.Decode(input.Body, connection, vld); err != nil {
return nil, err
}

connection.Normalize()
if err := validateConnection(connection); err != nil {
return nil, err
}

if err := connectionHelper.Create(connection, input); err != nil {
return nil, err
}
return &plugin.ApiResourceOutput{Body: connection.Sanitize()}, nil
}

func PatchConnection(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) {
connection := &models.GhCopilotConnection{}
if err := connectionHelper.First(connection, input.Params); err != nil {
return nil, err
}
if err := (&models.GhCopilotConnection{}).MergeFromRequest(connection, input.Body); err != nil {
return nil, errors.Convert(err)
}
connection.Normalize()
if err := validateConnection(connection); err != nil {
return nil, err
}
if err := connectionHelper.SaveWithCreateOrUpdate(connection); err != nil {
return nil, err
}
return &plugin.ApiResourceOutput{Body: connection.Sanitize()}, nil
}

func DeleteConnection(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) {
conn := &models.GhCopilotConnection{}
output, err := connectionHelper.Delete(conn, input)
if err != nil {
return output, err
}
output.Body = conn.Sanitize()
return output, nil
}

func ListConnections(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) {
var connections []models.GhCopilotConnection
if err := connectionHelper.List(&connections); err != nil {
return nil, err
}
for i := range connections {
connections[i] = connections[i].Sanitize()
}
return &plugin.ApiResourceOutput{Body: connections}, nil
}

func GetConnection(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) {
connection := &models.GhCopilotConnection{}
if err := connectionHelper.First(connection, input.Params); err != nil {
return nil, err
}
return &plugin.ApiResourceOutput{Body: connection.Sanitize()}, nil
}

func validateConnection(connection *models.GhCopilotConnection) errors.Error {
if connection == nil {
return errors.BadInput.New("connection is required")
}
if connection.Organization == "" {
return errors.BadInput.New("organization is required")
}
if connection.Token == "" {
return errors.BadInput.New("token is required")
}
if connection.RateLimitPerHour < 0 {
return errors.BadInput.New("rateLimitPerHour must be non-negative")
}
return nil
}
Loading
Loading