Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
38 changes: 38 additions & 0 deletions .devcontainer/devcontainer-local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "Copilot Token Tracker Extension (Local with Mounts)",
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-22-bookworm",
"features": {
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/powershell:1": {}
},
"customizations": {
"vscode": {
"extensions": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"ms-vscode.extension-test-runner",
"amodio.tsc-problem-matcher",
"github.copilot",
"github.copilot-chat"
],
"settings": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"eslint.enable": true,
"typescript.tsdk": "node_modules/typescript/lib",
"chat.tools.autoApprove": true
}
}
},
"initializeCommand": "powershell -ExecutionPolicy Bypass -File .devcontainer/init-mounts.ps1",
"mounts": [
"source=${localEnv:APPDATA}/Code/User,target=/home/node/.config/Code/User,type=bind,readonly=true",
"source=${localEnv:APPDATA}/Code - Insiders/User,target=/home/node/.config/Code - Insiders/User,type=bind,readonly=true",
"source=github-copilot-token-usage-nodemodules,target=/workspaces/github-copilot-token-usage/node_modules,type=volume"
],
"containerEnv": {
"NODE_OPTIONS": "--max-old-space-size=4096"
},
"updateContentCommand": "npm ci",
"remoteUser": "node"
}
8 changes: 1 addition & 7 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,9 @@
}
}
},
"initializeCommand": "powershell -ExecutionPolicy Bypass -File .devcontainer/init-mounts.ps1",
"mounts": [
"source=${localEnv:APPDATA}/Code/User,target=/home/node/.config/Code/User,type=bind,readonly=true",
"source=${localEnv:APPDATA}/Code - Insiders/User,target=/home/node/.config/Code - Insiders/User,type=bind,readonly=true",
"source=github-copilot-token-usage-nodemodules,target=/workspaces/github-copilot-token-usage/node_modules,type=volume"
],
"containerEnv": {
"NODE_OPTIONS": "--max-old-space-size=4096"
},
"postCreateCommand": "npm ci",
"updateContentCommand": "npm ci",
"remoteUser": "node"
}
35 changes: 34 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Thank you for your interest in contributing to the Copilot Token Tracker extensi
- [Development Environment Setup](#development-environment-setup)
- [Using the DevContainer (Recommended)](#using-the-devcontainer-recommended)
- [Why Use a DevContainer for AI-Assisted Development?](#why-use-a-devcontainer-for-ai-assisted-development)
- [DevContainer Configuration Notes](#devcontainer-configuration-notes)
- [Manual Local Setup](#manual-local-setup)
- [Development Workflow](#development-workflow)
- [Available Scripts](#available-scripts)
Expand Down Expand Up @@ -115,7 +116,7 @@ The devcontainer allows you to confidently let AI assistants:
- **Zero Configuration:** AI can start working immediately without environment setup
- **Pre-installed Tools:** All required dependencies are ready to go
- **Known State:** AI agents can make more accurate suggestions knowing the exact environment
- **Automatic Setup:** The `postCreateCommand` ensures dependencies are always up-to-date
- **Automatic Setup:** The `updateContentCommand` ensures dependencies are installed after content updates

### 💡 Real-World Scenario

Expand All @@ -134,6 +135,38 @@ Without a devcontainer, you'd need to:
- Risk system-level changes
- Potentially need to uninstall packages or revert changes

### DevContainer Configuration Notes

The repository provides two devcontainer configurations:

1. **`.devcontainer/devcontainer.json`** (default) - Optimized for **GitHub Codespaces** and cloud environments
2. **`.devcontainer/devcontainer-local.json`** - Optimized for **local Windows development** with host mounts

#### Default Configuration (Codespaces)

The default `devcontainer.json` is designed to work reliably in GitHub Codespaces and other cloud environments:

- Uses `updateContentCommand` instead of `postCreateCommand` for dependency installation (more reliable timing)
- No host mounts (not available in cloud environments)
- Includes memory optimization (`NODE_OPTIONS: --max-old-space-size=4096`)

**Why `updateContentCommand`?** This lifecycle hook runs after workspace content is updated (including initial clone), making it more reliable than `postCreateCommand` which runs once during container creation and can timeout with large dependency trees.

#### Local Configuration (Windows with Mounts)

The `devcontainer-local.json` configuration adds features for local development:

- **Host Mounts:** Binds your VS Code session data (including Copilot logs) into the container so the extension can track your actual usage
- **PowerShell Init:** Runs `.devcontainer/init-mounts.ps1` to ensure mount directories exist on Windows
- **Volume for node_modules:** Uses a Docker volume for faster dependency installation

**To use the local configuration:**
1. Open the repository in VS Code
2. Press `F1` and select "Dev Containers: Reopen in Container"
3. Choose "Copilot Token Tracker Extension (Local with Mounts)"

**Note:** The local configuration with mounts is **Windows-only** due to the use of `%APPDATA%` environment variables and PowerShell. For local development on Linux/macOS, use the default configuration.

## Manual Local Setup

If you prefer not to use the devcontainer, you can set up the extension locally:
Expand Down