Skip to content

Commit 316d8cd

Browse files
committed
docs: add AGENTS.md and modular documentation structure
Add AGENTS.md as a project guide with links to focused docs/ files: build.md, release.md, testing.md, code-conventions.md, ci.md, yaml-generation.md, and contributing.md. Merged getting-started.md and onboarding-new-task.md into the new files to eliminate duplication. Code was assisted by Cursor AI. Signed-off-by: Karel Simon <ksimon@redhat.com>
1 parent d59a65d commit 316d8cd

17 files changed

+507
-88
lines changed

.cursorrules

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Cursor AI Instructions
2+
3+
This project uses `AGENTS.md` for general AI agent guidelines that apply to all AI assistants.
4+
5+
**CRITICAL**: Before starting any work, you MUST:
6+
1. Read docs/ai-workflow.md - Required 2-step process: planning → approval → implementation
7+
2. Read AGENTS.md for project structure and guidelines
8+
9+
## Quick Reference
10+
11+
All project documentation is available in the `docs/` directory:
12+
- AI Workflow Rules: docs/ai-workflow.md - **REQUIRED: 2-step planning process**
13+
- Build & Dependencies: docs/build.md
14+
- YAML Generation: docs/yaml-generation.md - **NEVER hand-edit `release/` files**
15+
- Code Conventions: docs/code-conventions.md
16+
- Testing: docs/testing.md
17+
- CI / GitHub Actions: docs/ci.md
18+
- Release: docs/release.md
19+
- Contributing: docs/contributing.md
20+
21+
See AGENTS.md for the complete project guide.

.env.example

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Jira MCP Server Credentials
2+
# Copy this file to .env.jira and fill in your credentials
3+
4+
# Your Atlassian site name (e.g., "redhat" for redhat.atlassian.net)
5+
ATLASSIAN_SITE_NAME="redhat"
6+
7+
# Your Atlassian account email
8+
ATLASSIAN_USER_EMAIL="your.email@redhat.com"
9+
10+
# API token from https://id.atlassian.com/manage-profile/security/api-tokens
11+
ATLASSIAN_API_TOKEN="your-api-token-here"

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
ah
44
/manifests/
55
/test/test.test
6+
.env*
7+
!.env.example
8+
.mcp.json

AGENTS.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# KubeVirt Tekton Tasks - Project Guide
2+
3+
KubeVirt-specific Tekton tasks for CI/CD pipelines on Kubernetes. Provides tasks for creating/managing VMs, executing commands over SSH, manipulating disk images with libguestfs, and uploading disk images to container registries.
4+
5+
**IMPORTANT for AI Agents**: See [AI Workflow Rules](docs/ai-workflow.md) for the required 2-step planning and approval process before modifying any code.
6+
7+
## Documentation
8+
9+
| Document | Description |
10+
|----------|-------------|
11+
| [AI Workflow Rules](docs/ai-workflow.md) | **Required 2-step process for AI agents** (planning → approval → implementation) |
12+
| [Build & Dependencies](docs/build.md) | Build system, Go/container toolchain, supported environments |
13+
| [YAML Generation](docs/yaml-generation.md) | Ansible-driven task YAML generation pipeline (**never hand-edit `release/`**) |
14+
| [Code Conventions](docs/code-conventions.md) | Go module structure, testing patterns, error handling, formatting |
15+
| [Testing](docs/testing.md) | Unit tests, E2E tests, `DEV_MODE` for local images |
16+
| [CI / GitHub Actions](docs/ci.md) | Workflow descriptions, Dependabot, Renovate |
17+
| [Release](docs/release.md) | Release process, version bumping, artifacts |
18+
| [Contributing](docs/contributing.md) | PR requirements, code quality workflow, adding new tasks |
19+
| [Tasks RBAC Permissions](docs/tasks-rbac-permissions.md) | ServiceAccount, ClusterRole, RoleBinding setup |
20+
21+
## Project Structure
22+
23+
```
24+
cmd/ # One main.go per compiled task binary
25+
create-vm/
26+
execute-in-vm/
27+
generate-ssh-keys/
28+
modify-data-object/
29+
wait-for-vmi-status/
30+
disk-uploader/
31+
disk-virt-customize/
32+
disk-virt-sysprep/
33+
modules/ # Go libraries and per-task packages + tests
34+
shared/pkg/... # Shared utilities (env, log, output, zconstants, zerrors, zutils)
35+
sharedtest/... # Shared test helpers
36+
<task>/pkg/... # Per-task logic
37+
disk-virt/ # Shared by disk-virt-customize and disk-virt-sysprep
38+
build/ # Containerfiles and entrypoint scripts
39+
Containerfile # Multi-stage: CentOS Stream 10 builder + runtime
40+
Containerfile.DiskVirt # Builds disk-virt tasks on libguestfs-tools base
41+
configs/ # Per-task Ansible variable files
42+
templates/ # Ansible-driven Tekton task YAML generation
43+
<task>/manifests/ # Generated task manifests
44+
<task>/generate-task.yaml # Ansible playbook for YAML generation
45+
templates-pipelines/ # Pipeline YAML generation (Windows pipelines)
46+
release/ # Published task and pipeline YAML artifacts
47+
tasks/<task>/
48+
pipelines/<pipeline>/
49+
scripts/ # Shell automation for build, test, lint, deploy
50+
makefile-snippets/ # Included makefile fragments
51+
test/ # Ginkgo E2E integration tests and framework
52+
automation/ # E2E orchestration, resource deployment, CI helpers
53+
vendor/ # Vendored Go modules (GOFLAGS=-mod=vendor)
54+
docs/ # Developer and user documentation
55+
```
56+
57+
### Key relationships
58+
59+
- `cleanup-vm` is generated from `execute-in-vm` templates (with `is_cleanup: true`), not a separate binary.
60+
- `modify-windows-iso-file` exists as templates and release YAML only (no `cmd/` entry).
61+
- `disk-virt-customize` and `disk-virt-sysprep` share `modules/disk-virt/`.
62+
63+
## Common Commands
64+
65+
| Command | Description |
66+
|---------|-------------|
67+
| `make clean` | Clean build artifacts |
68+
| `make generate-yaml-tasks` | Generate task YAML from templates |
69+
| `make generate-pipelines` | Generate pipeline YAML |
70+
| `make test` | Run unit tests |
71+
| `make lint` / `make lint-fix` | Check / fix formatting |
72+
| `make test-yaml-consistency` | Verify YAML consistency |
73+
| `make cluster-sync` | Build, push, deploy to cluster |
74+
| `make cluster-test` | Run E2E tests on cluster |
75+
| `make cluster-clean` | Clean cluster resources |
76+
| `make e2e-tests` | Full E2E: deploy + test |
77+
| `make vendor` | Vendor Go dependencies |
78+
| `make release` | Full release pipeline |
79+
| `make deploy` / `make undeploy` | Deploy/remove tasks |

CLAUDE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Claude Code Instructions
2+
3+
This project uses `AGENTS.md` for general AI agent guidelines that apply to all AI assistants.
4+
5+
**CRITICAL**: Before starting any work, you MUST:
6+
1. Read [AI Workflow Rules](docs/ai-workflow.md) - Required 2-step process: planning → approval → implementation
7+
2. Read [AGENTS.md](AGENTS.md) for project structure and guidelines
8+
9+
## Quick Reference
10+
11+
All project documentation is available in the `docs/` directory:
12+
- [AI Workflow Rules](docs/ai-workflow.md) - **REQUIRED: 2-step planning process**
13+
- [Build & Dependencies](docs/build.md)
14+
- [YAML Generation](docs/yaml-generation.md) - **NEVER hand-edit `release/` files**
15+
- [Code Conventions](docs/code-conventions.md)
16+
- [Testing](docs/testing.md)
17+
- [CI / GitHub Actions](docs/ci.md)
18+
- [Release](docs/release.md)
19+
- [Contributing](docs/contributing.md)
20+
21+
See [AGENTS.md](AGENTS.md) for the complete project guide.

CONTRIBUTING.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ Any help is highly appreciated.
3131
relevant flows should be covered via unit tests and functional tests. So when
3232
thinking about a contribution, also think about testability. All tests can be
3333
run local without the need of CI. Have a look at the
34-
[Testing](docs/getting-started.md#testing)
35-
section in the [Developer Guide](docs/getting-started.md).
34+
[Testing](docs/testing.md) documentation.
3635

3736
### Contributor compliance with Developer Certificate Of Origin (DCO)
3837
We require every contributor to certify that they are legally permitted to contribute to our project. A contributor expresses this by consciously signing their commits, and by this act expressing that they comply with the Developer Certificate Of Origin
@@ -47,5 +46,5 @@ This can be done by adding --signoff to your git command line.
4746
Before your PR can be merged it must meet the following criteria:
4847

4948
- README.md has been updated if new task is added or functionality of existing tasks is affected.
50-
- [Onboarding a New Task](docs/onboarding-new-task.md) has been taken into account when introducing a new task
49+
- [Adding a New Task](docs/contributing.md#adding-a-new-task) process has been followed when introducing a new task
5150
- Functionality must be fully tested.

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,5 @@ Then, a VM is created from such image.
100100

101101
## Development Guide
102102

103-
See [Getting Started](docs/getting-started.md) for the environment setup and development workflow.
103+
- See [AGENTS.md](AGENTS.md) for project structure, documentation index, and common commands
104+
- See [Getting Started](docs/getting-started.md) for environment setup and development workflow

docs/ai-workflow.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# AI Agent Workflow Rules
2+
3+
Whenever you are given a task to modify, refactor, or create code, you MUST strictly follow this 2-step process. Do not skip steps.
4+
5+
## STEP 1: Planning and Documentation
6+
7+
1. Before writing or modifying any project code, create or update a file named `change.md` in the root directory.
8+
2. In `change.md`, clearly outline:
9+
- The goal of the task.
10+
- The files that will be modified or created.
11+
- A step-by-step technical plan of the exact changes you intend to make.
12+
3. **CRITICAL INSTRUCTION:** Once you have saved `change.md`, you must **STOP**. Do not write any code. Ask the user: *"I have outlined the plan in change.md. Please review it. Reply with 'APPROVED' to proceed, or let me know what needs to be changed."*
13+
4. Wait for the user's explicit approval.
14+
15+
## STEP 2: Implementation
16+
17+
1. ONLY after the user explicitly types "APPROVED" (or a clear affirmative), you may begin implementing the steps exactly as outlined in `change.md`.
18+
2. Do not deviate from the approved plan without asking for permission first.
19+
3. **Before completing implementation, follow the Review Checklist below**.
20+
21+
### Review Checklist
22+
23+
**IMPORTANT**: This checklist MUST be followed:
24+
- When implementing changes (after coding, before committing)
25+
- When performing standalone code reviews (when asked to review code without implementing)
26+
27+
#### Documentation Review
28+
29+
Check if changes require updates to `docs/` files:
30+
- New features, tasks, or commands
31+
- Modified behavior or configuration
32+
- New dependencies or build requirements
33+
- Changed workflows or processes
34+
- Update relevant documentation files before proceeding
35+
- If unsure whether docs need updating, ask the user
36+
37+
#### Manifest Regeneration Review
38+
39+
Check if changes require regenerating YAML manifests:
40+
- **NEVER hand-edit files in `release/`** (see [YAML Generation](yaml-generation.md))
41+
- Run `make generate-yaml-tasks` if changes affect:
42+
- Files in `templates/` directory
43+
- Files in `configs/` (Ansible variable files)
44+
- Task parameters or behavior
45+
- RBAC requirements in task definitions
46+
- Run `make generate-pipelines` if changes affect:
47+
- Files in `templates-pipelines/` directory
48+
- Pipeline definitions or structure
49+
- Run `make test-yaml-consistency` to verify YAML is in sync
50+
- Commit any regenerated YAML files along with code changes
51+
52+
#### Code Quality Review
53+
54+
Verify code meets project standards:
55+
- Run `make lint` to check code formatting and style
56+
- Fix any linter issues with `make lint-fix`
57+
- Ensure all linter checks pass before committing
58+
- Run `make test` to verify unit tests still pass
59+
- Address any test failures before proceeding
60+
61+
### After Implementation
62+
63+
Once implementation and the review checklist are complete, **ask the user** if they would like to proceed with committing and pushing the changes to GitHub (STEP 3). Do not automatically proceed to STEP 3 without user confirmation.
64+
65+
## STEP 3: Git Workflow
66+
67+
After successfully implementing the changes:
68+
69+
1. **Create a new branch** with a descriptive name:
70+
```bash
71+
git checkout -b feature/descriptive-name
72+
# or
73+
git checkout -b fix/issue-description
74+
```
75+
76+
2. **Commit changes** following the commit message guidelines:
77+
- **Format**: `type(scope): description`
78+
- **Types**: `feat`, `fix`, `docs`, `test`, `build`, `refactor`
79+
- **Subject line**: Imperative mood, max 72 chars, capitalized, no period
80+
- **Body**: Wrap at 72 chars, explain what and why
81+
- **DCO**: Always use `--signoff`
82+
83+
Example:
84+
```bash
85+
git add <files>
86+
git commit --signoff -m "feat(execute-in-vm): Add support for custom SSH timeout
87+
88+
Implements configurable SSH timeout parameter to handle slow VM boots.
89+
Default timeout remains 5 minutes for backwards compatibility."
90+
```
91+
92+
3. **Push to origin**:
93+
```bash
94+
git push origin feature/descriptive-name
95+
```
96+
97+
4. **Inform the user** that the branch has been pushed and provide the branch name for PR creation.
98+
99+
## Why This Process?
100+
101+
- **Prevents mistakes**: Plan is reviewed before implementation
102+
- **Saves time**: Avoids implementing wrong solutions
103+
- **Builds trust**: User has full visibility and control
104+
- **Improves quality**: Thoughtful planning leads to better code
105+
106+
## Example Workflow
107+
108+
```
109+
User: "Add a new Tekton task for disk snapshot"
110+
111+
AI: [Creates change.md with detailed plan]
112+
AI: "I have outlined the plan in change.md. Please review it.
113+
Reply with 'APPROVED' to proceed, or let me know what needs
114+
to be changed."
115+
116+
User: [Reviews change.md, suggests modifications]
117+
118+
AI: [Updates change.md based on feedback]
119+
120+
User: "APPROVED"
121+
122+
AI: [Implements the plan step by step]
123+
AI: [Creates branch, commits with DCO sign-off, pushes to origin]
124+
AI: "Changes have been pushed to branch 'feature/disk-snapshot-task'.
125+
You can now create a PR on GitHub."
126+
```

docs/build.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Build & Dependencies
2+
3+
## Build system
4+
5+
- Root build: `makefile` (lowercase), not `Makefile`.
6+
- **All Go builds use vendored deps**: `GOFLAGS=-mod=vendor`.
7+
- After any dependency change: **ALWAYS** run `make vendor` (runs `go mod tidy` + `go mod vendor`).
8+
- Go version: defined in `go.mod` (check the `go` directive). Pinned Kubernetes/OpenShift/CDI versions via `replace` directives in `go.mod`.
9+
- **Do NOT bump the Go version without confirmation.** Before upgrading, verify which Go version the midstream is using — the upstream version must stay compatible. On **release branches**, never bump the Go version as it would break midstream builds.
10+
11+
## Build commands
12+
13+
```bash
14+
# Generate task YAML from Ansible templates (only when templates change)
15+
make generate-yaml-tasks
16+
17+
# Generate pipeline YAML
18+
make generate-pipelines
19+
20+
# Build and push images to cluster registry, deploy tasks
21+
make cluster-sync
22+
23+
# Sync a single task
24+
./scripts/cluster-sync.sh execute-in-vm
25+
26+
# Build multi-arch release images (podman, linux/amd64+arm64+s390x)
27+
make build-release-images
28+
29+
# Full release: generate YAML + build + push images
30+
make release
31+
```
32+
33+
## Container images
34+
35+
- Built with **Podman** (not Docker). Multi-arch: `linux/amd64`, `linux/arm64`, `linux/s390x`.
36+
- `build/Containerfile`: CentOS Stream 10 builder (Go 1.24.9) + runtime with xorriso, ssh, nbdkit, qemu-img.
37+
- `build/Containerfile.DiskVirt`: Builds disk-virt tasks on `quay.io/kubevirt/libguestfs-tools:v1.6.0`.
38+
- Images pushed to `quay.io/kubevirt/tekton-tasks` and `quay.io/kubevirt/tekton-tasks-disk-virt`.
39+
40+
## Supported environments
41+
42+
- **OKD** (OpenShift Kubernetes Distribution)
43+
- **OCP** (OpenShift Container Platform)
44+
45+
## Troubleshooting
46+
47+
- Build fails with module errors: run `make vendor` first.
48+
- Cluster sync issues: verify cluster registry is accessible and permissions are set.

docs/ci.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# CI / GitHub Actions
2+
3+
## Workflows
4+
5+
- **`test-yaml-consistency.yaml`**: PRs to `main` - runs `scripts/test-yaml-consistency.sh`.
6+
- **`validate-no-offensive-lang.yml`**: PRs to `main` - language validation.
7+
- **`release.yaml`**: On release published - builds multi-arch images, pushes to Quay, uploads manifest asset.
8+
9+
## Dependency management
10+
11+
- **Dependabot**: Watches Go modules and GitHub Actions (ignores Ginkgo/Gomega).
12+
- **Renovate**: Vulnerability/OSV alerts enabled; ignores `vendor/`.

0 commit comments

Comments
 (0)