-
-
Notifications
You must be signed in to change notification settings - Fork 117
Add GitHub Copilot/Claude instruction #583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,81 @@ | ||||||||||||||||||||
| # Home Assistant CLI | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## Project Overview | ||||||||||||||||||||
| This is the official Home Assistant CLI tool written in Go, providing command-line | ||||||||||||||||||||
| interface to interact with the Home Assistant Supervisor. The CLI enables users to | ||||||||||||||||||||
| manage add-ons, control the core system, handle audio/network settings, manage | ||||||||||||||||||||
| backups, and perform various system operations. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| The CLI is communicating with the Supervisor using the Supervisor's HTTP REST API. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## Repository Structure | ||||||||||||||||||||
| - **`main.go`** - Entry point of the application | ||||||||||||||||||||
| - **`cmd/`** - Contains all CLI command implementations using Cobra framework | ||||||||||||||||||||
| - **`client/`** - HTTP client functionality for API communication | ||||||||||||||||||||
| - **`spinner/`** - Progress spinner implementation | ||||||||||||||||||||
| - **Root files** - Configuration and documentation | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## Key Technologies | ||||||||||||||||||||
| - **Language**: Go (use modern syntax) | ||||||||||||||||||||
| - **CLI Framework**: Cobra (github.com/spf13/cobra) | ||||||||||||||||||||
| - **HTTP Client**: Resty (github.com/go-resty/resty/v2) | ||||||||||||||||||||
| - **Configuration**: Viper (github.com/spf13/viper) | ||||||||||||||||||||
| - **Logging**: Logrus (github.com/sirupsen/logrus) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## Available Commands | ||||||||||||||||||||
| The CLI provides the following main command categories: | ||||||||||||||||||||
| - `addons` - Install, update, remove and configure Home Assistant add-ons | ||||||||||||||||||||
| - `audio` - Audio plug-in management | ||||||||||||||||||||
| - `authentication` - Authentication for Home Assistant users | ||||||||||||||||||||
| - `cli` - CLI plug-in management | ||||||||||||||||||||
| - `core` - Home Assistant Core control | ||||||||||||||||||||
| - `dns` - DNS plug-in management | ||||||||||||||||||||
| - `docker` - Docker related configuration | ||||||||||||||||||||
| - `hardware` - System hardware information | ||||||||||||||||||||
| - `host` - Host OS control | ||||||||||||||||||||
| - `info` - General Home Assistant information | ||||||||||||||||||||
| - `multicast` - Multicast plug-in configuration | ||||||||||||||||||||
| - `network` - Network configuration and management | ||||||||||||||||||||
| - `observer` - Observer plug-in management | ||||||||||||||||||||
| - `os` - Home Assistant OS specific operations | ||||||||||||||||||||
| - `resolution` - Resolution center for issues and solutions | ||||||||||||||||||||
| - `backups` - Backup creation, restoration, and management | ||||||||||||||||||||
| - `supervisor` - Supervisor monitoring and control | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## Development Environment | ||||||||||||||||||||
| - **API Endpoint**: Configurable via `SUPERVISOR_ENDPOINT` environment variable | ||||||||||||||||||||
| - **Authentication**: Uses API tokens via `SUPERVISOR_API_TOKEN` environment variable | ||||||||||||||||||||
| - **Config File**: Optional config file support (default: `$HOME/.homeassistant.yaml`) | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
Comment on lines
+45
to
+49
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainAdd a brief security note for API tokens and verify default config path
Suggested doc tweak: - **Authentication**: Uses API tokens via `SUPERVISOR_API_TOKEN` environment variable
- **Config File**: Optional config file support (default: `$HOME/.homeassistant.yaml`)
+ - Security: Avoid exposing `SUPERVISOR_API_TOKEN` in shell history or logs; prefer `.env` files or a secrets manager.Verify config defaults: 🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n 'viper\.(SetConfig(Name|File)|AddConfigPath|SetDefault)' -A 2 -S || true
rg -n '\.homeassistant' -S || trueLength of output: 1273 Add security note for API token; default config path confirmed Verified that the default config file path ( - **Authentication**: Uses API tokens via `SUPERVISOR_API_TOKEN` environment variable
+ **Authentication**: Uses API tokens via `SUPERVISOR_API_TOKEN` environment variable
- Avoid exposing the token in shell history or logs; consider using `.env` files or a secrets manager.📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
| ## Build Commands | ||||||||||||||||||||
| - **Build**: `CGO_ENABLED=0 go build -ldflags="-s -w" -o "ha"` | ||||||||||||||||||||
| - **Test**: `go test ./...` | ||||||||||||||||||||
| - **Format**: `gofmt -s` | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
Comment on lines
+50
to
+54
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainFormatting command should write changes; consider standard ‘go fmt’ “gofmt -s” only prints to stdout. Use -w, or just “go fmt ./...” for module-aware formatting. -- **Format**: `gofmt -s`
+- **Format**: `gofmt -s -w .` (or `go fmt ./...`)Optionally verify if a Makefile or linting targets exist: 🏁 Script executed: #!/bin/bash
set -euo pipefail
fd -a '^Makefile$' || true
rg -n 'golangci-lint|gofumpt|go fmt|gofmt' -S || trueLength of output: 163 Apply formatting changes with The current command • File: - **Format**: `gofmt -s`
+ **Format**: `gofmt -s -w .` (or `go fmt ./...`)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
| ## File Organization Patterns | ||||||||||||||||||||
| - Command files follow naming pattern: `<component>_<action>.go` | ||||||||||||||||||||
| - Each command typically has its own file in the `cmd/` directory | ||||||||||||||||||||
| - Helper functions are in `client/helper.go` | ||||||||||||||||||||
| - Main client logic is in `client/client.go` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## Architecture Notes | ||||||||||||||||||||
| - Uses Cobra for command structure and flag parsing | ||||||||||||||||||||
| - Resty for HTTP API calls to Home Assistant Supervisor | ||||||||||||||||||||
| - Viper for configuration management | ||||||||||||||||||||
| - Logrus for structured logging | ||||||||||||||||||||
| - Custom spinner implementation for progress indication | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## Testing | ||||||||||||||||||||
| - Unit tests available in `client/helper_test.go` | ||||||||||||||||||||
| - Test command: `go test ./...` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## Contributing Guidelines | ||||||||||||||||||||
| 1. Create feature branch | ||||||||||||||||||||
| 2. Commit changes | ||||||||||||||||||||
| 3. Rebase against master | ||||||||||||||||||||
| 4. Run tests with `go test ./...` | ||||||||||||||||||||
| 5. Format code with `gofmt -s` | ||||||||||||||||||||
| 6. Create Pull Request | ||||||||||||||||||||
|
|
||||||||||||||||||||
| This CLI is designed to work with Home Assistant Supervisor API and is commonly used in | ||||||||||||||||||||
| Home Assistant Operating System environments, SSH add-ons, and development setups. | ||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| .github/copilot-instructions.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Optionally validate listed command categories against cobra definitions
To keep this list in sync, you can auto-check for top-level cobra “Use” strings.
🏁 Script executed:
Length of output: 1664
Ensure
hardwarecommand exists or update docsThe
.github/copilot-instructions.mdlists ahardwarecommand, but no corresponding cobra definition (Use: "hardware") was found:• Affected location:
.github/copilot-instructions.md(lines 26–43): the- hardware – System hardware informationentryNext steps:
Use: "hardware"(e.g. incmd/hardware.go)You can confirm with:
rg -n 'Use:\s*"hardware"' -S🤖 Prompt for AI Agents