Skip to content

Commit 4eff3e0

Browse files
committed
Update Project
1 parent 9e32652 commit 4eff3e0

8 files changed

Lines changed: 175 additions & 8 deletions

File tree

.github/agents/flet-ui.agent.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
description: "Flet UI specialist. Use when: building Flet views, fixing Flet controls, navigation/routing, theming, layout issues, ft.Icon usage, ft.Page lifecycle, Flet desktop packaging with flet build."
3+
tools: [read, edit, search, execute]
4+
---
5+
You are a Flet UI engineer building desktop applications with **Flet** (Flutter renderer for Python). Your job is to create, fix, and improve Flet views and controls following project conventions.
6+
7+
## Knowledge
8+
9+
- **Flet ≥ 0.80**: Use `ft.run(main)``ft.app()` is deprecated.
10+
- `ft.Icon` takes the icon as the **first positional argument**: `ft.Icon(ft.Icons.HOME)`, never `ft.Icon(name=...)`.
11+
- Views extend `ft.Column` or `ft.Container` and receive `page: ft.Page` in `__init__`.
12+
- Navigation index → view mapping lives in `app.py`; views do not contain routing logic.
13+
- `page.update()` must be called after mutating controls for changes to render.
14+
- Theme: use `ft.Theme(color_scheme_seed=...)` and `ft.ThemeMode.DARK` / `LIGHT`.
15+
- Icons: reference via `ft.Icons.CONSTANT_NAME` (e.g., `ft.Icons.CLOUD`, `ft.Icons.SETTINGS`).
16+
- Colors: reference via `ft.Colors.CONSTANT_NAME` (e.g., `ft.Colors.BLUE_200`).
17+
- Packaging: `flet build <target> --yes src/` for desktop binaries.
18+
19+
## Constraints
20+
21+
- DO NOT use `ft.app()` — it is deprecated. Always use `ft.run()`.
22+
- DO NOT use `name=` keyword for `ft.Icon` — pass the icon as the first positional arg.
23+
- DO NOT import `kubernetes` or business logic directly in UI files — UI only talks to `core/`.
24+
- DO NOT embed routing logic inside individual views.
25+
- ONLY create views under `src/kubeidea/ui/views/`.
26+
27+
## Approach
28+
29+
1. Read the existing view and `app.py` to understand current navigation wiring.
30+
2. Create or modify Flet controls using the correct API for the installed Flet version.
31+
3. Verify the control hierarchy: `page``Row``NavigationRail` + content area.
32+
4. Run the app with `poetry run flet run src/kubeidea/app.py` to verify visually if possible.
33+
5. Report what was changed and any layout considerations.
34+
35+
## Output Format
36+
37+
- Code changes applied directly to files.
38+
- Brief description of the visual result the user should expect.
39+
- If a new view is created, confirm it was wired into the navigation index in `app.py`.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
description: "Python + Poetry specialist. Use when: writing Python modules, fixing imports, managing pyproject.toml dependencies, running pytest, configuring ruff/mypy, debugging Poetry virtualenvs, creating type-annotated code."
3+
tools: [read, edit, search, execute]
4+
---
5+
You are a senior Python engineer specializing in modern Python (≥ 3.11) projects managed with **Poetry**. Your job is to write, review, and fix Python code following strict quality standards.
6+
7+
## Knowledge
8+
9+
- Python 3.11+ features: `match`, `StrEnum`, `ExceptionGroup`, `type` aliases, `Self`, `override`.
10+
- Poetry workflows: `poetry add`, `poetry lock`, `poetry install`, `poetry run`, groups, extras.
11+
- `pyproject.toml` configuration for ruff, mypy, pytest, and build systems.
12+
- Type annotations: use `mypy --strict` conventions — `disallow_untyped_defs`, generic collections (`list[str]` not `List[str]`), `from __future__ import annotations` when needed.
13+
- Testing with `pytest` and `pytest-asyncio`; fixtures, parametrize, coverage.
14+
15+
## Constraints
16+
17+
- DO NOT edit `poetry.lock` manually — always use `poetry add` / `poetry lock`.
18+
- DO NOT use deprecated typing imports (`typing.List`, `typing.Dict`, `typing.Optional`) — use built-in generics and `X | None`.
19+
- DO NOT disable ruff or mypy rules without an inline comment explaining why.
20+
- DO NOT add dependencies without confirming they are needed for the current task.
21+
- ONLY write code that passes `ruff check` and `mypy --strict`.
22+
23+
## Approach
24+
25+
1. Read the relevant source files and understand the existing patterns.
26+
2. Write or fix code with full type annotations and idiomatic Python.
27+
3. Run `poetry run ruff check` and `poetry run mypy` to validate changes.
28+
4. Run `poetry run pytest` if tests are affected.
29+
5. Report what changed and any remaining warnings.
30+
31+
## Output Format
32+
33+
- Code changes applied directly to files.
34+
- After edits, run linter/type-checker and report results.
35+
- If a dependency change is needed, show the `poetry add` command and ask before running.

.github/copilot-instructions.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Kube-IDEA — Copilot Instructions
2+
3+
## Stack
4+
5+
- **Language**: Python ≥ 3.11 with full type annotations (`mypy --strict`).
6+
- **UI**: [Flet](https://flet.dev) (Flutter renderer). Use `ft.run()``ft.app()` is deprecated since 0.80.
7+
- **Dependencies**: managed with Poetry (`pyproject.toml` + `poetry.lock`). Do not edit `poetry.lock` manually.
8+
- **Linter / formatter**: `ruff` (rules E, F, I, N, W, UP). Never disable rules without a comment explaining why.
9+
- **Testing**: `pytest` under `tests/`. Async tests use `pytest-asyncio`. Target coverage ≥ 80 %.
10+
11+
## Project layout
12+
13+
```
14+
src/kubeidea/
15+
app.py # Flet bootstrap — ft.run(main)
16+
ui/ # All Flet views and navigation
17+
core/ # AppContext, business logic, use-cases
18+
kube/ # kubernetes-python API wrappers
19+
metrics/ # metrics-server / Prometheus adapters
20+
plugins/ # Plugin host and entry-point discovery
21+
security/ # RBAC inspector, SubjectAccessReview
22+
config/ # Settings persistence
23+
utils/ # Logging, telemetry helpers
24+
tests/ # Mirrors src/kubeidea/ structure
25+
```
26+
27+
See [docs/architecture.md](docs/architecture.md) for component boundaries.
28+
29+
## Coding conventions
30+
31+
- Views extend `ft.Column` or `ft.Container`; receive `page: ft.Page` in `__init__`.
32+
- Navigation index → view mapping lives in `app.py`; do not embed routing logic inside views.
33+
- `ft.Icon` takes the icon **as the first positional argument**, not `name=`.
34+
- All Kubernetes calls go through `kube/client.py` — never import `kubernetes` directly in UI code.
35+
- Secrets are never stored to disk; use the OS keyring (`keyring` lib) where persistence is required.
36+
- Telemetry is opt-in only; never collect data unless the user has explicitly enabled it in settings.
37+
38+
## CI / build
39+
40+
- `poetry run pytest` — must pass before any PR merge.
41+
- `poetry run ruff check src/ tests/` — zero warnings.
42+
- `poetry run mypy src/kubeidea/` — zero errors.
43+
- Desktop binaries are built with `flet build <target>` via the release workflow on `v*` tags.
44+
- Docs are deployed to `gh-pages` branch with `mkdocs gh-deploy --force`.
45+
46+
## Security (DevSecOps)
47+
48+
- All cluster actions must respect the user's RBAC via `SubjectAccessReview` — see `security/rbac.py`.
49+
- Never log kubeconfig tokens, credentials, or secret values.
50+
- Dependencies must stay pinned in `poetry.lock`; raise a PR to update them explicitly.

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
[![CI](https://github.com/Ops-Talks/kubeidea/actions/workflows/ci.yml/badge.svg)](https://github.com/Ops-Talks/kubeidea/actions/workflows/ci.yml)
44
[![Docs](https://github.com/Ops-Talks/kubeidea/actions/workflows/docs.yml/badge.svg)](https://ops-talks.github.io/kubeidea/)
5+
[![Release](https://github.com/Ops-Talks/kubeidea/actions/workflows/release.yml/badge.svg)](https://github.com/Ops-Talks/kubeidea/actions/workflows/release.yml)
6+
[![Python](https://img.shields.io/badge/python-%3E%3D3.11-blue?logo=python&logoColor=white)](https://www.python.org/)
7+
[![Flet](https://img.shields.io/badge/flet-UI-purple?logo=flutter&logoColor=white)](https://flet.dev)
8+
[![License](https://img.shields.io/github/license/Ops-Talks/kubeidea)](LICENSE)
9+
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
510

611
> **Kubernetes desktop IDE built with Python (Flet + Poetry).**
712

src/kubeidea/app.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from kubeidea.ui.navigation import build_navigation
66
from kubeidea.ui.theme import apply_theme
77
from kubeidea.ui.views.home import HomeView
8+
from kubeidea.ui.views.placeholder import PlaceholderView
89

910

1011
def main(page: ft.Page) -> None:
@@ -15,16 +16,33 @@ def main(page: ft.Page) -> None:
1516

1617
apply_theme(page)
1718

18-
navigation = build_navigation(page)
19-
home_view = HomeView(page)
19+
views: list[ft.Control] = [
20+
HomeView(page),
21+
PlaceholderView("Clusters", ft.Icons.CLOUD),
22+
PlaceholderView("Logs", ft.Icons.TERMINAL),
23+
PlaceholderView("Metrics", ft.Icons.MONITOR_HEART),
24+
PlaceholderView("YAML Editor", ft.Icons.CODE),
25+
PlaceholderView("RBAC Inspector", ft.Icons.SECURITY),
26+
PlaceholderView("Plugins", ft.Icons.EXTENSION),
27+
PlaceholderView("Settings", ft.Icons.SETTINGS),
28+
]
29+
30+
content_area = ft.Column(controls=[views[0]], expand=True)
31+
32+
def on_nav_change(index: int) -> None:
33+
content_area.controls.clear()
34+
content_area.controls.append(views[index])
35+
page.update()
36+
37+
navigation = build_navigation(page, on_nav_change)
2038

2139
page.add(
2240
ft.Row(
23-
controls=[navigation, home_view],
41+
controls=[navigation, content_area],
2442
expand=True,
2543
)
2644
)
2745

2846

2947
if __name__ == "__main__":
30-
ft.app(target=main)
48+
ft.run(main)

src/kubeidea/ui/navigation.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,25 @@
22

33
from __future__ import annotations
44

5+
from collections.abc import Callable
56
from typing import Any
67

78
import flet as ft
89

910

10-
def build_navigation(page: ft.Page) -> ft.NavigationRail:
11+
def build_navigation(page: ft.Page, on_change: Callable[[int], None]) -> ft.NavigationRail:
1112
"""Build the main navigation rail.
1213
1314
Args:
1415
page: The Flet page instance.
16+
on_change: Callback invoked with the selected destination index.
1517
1618
Returns:
1719
A configured NavigationRail control.
1820
"""
1921

2022
def _on_destination_change(e: Any) -> None:
21-
_ = e
22-
page.update()
23+
on_change(e.control.selected_index)
2324

2425
rail = ft.NavigationRail(
2526
selected_index=0,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""Generic placeholder view for sections not yet implemented."""
2+
3+
import flet as ft
4+
5+
6+
class PlaceholderView(ft.Column):
7+
"""Temporary placeholder shown for features under development."""
8+
9+
def __init__(self, section: str, icon: str) -> None:
10+
super().__init__(
11+
expand=True,
12+
alignment=ft.MainAxisAlignment.CENTER,
13+
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
14+
controls=[
15+
ft.Icon(icon, size=64, color=ft.Colors.BLUE_200),
16+
ft.Text(section, size=22, weight=ft.FontWeight.BOLD),
17+
ft.Text("This section is under development.", size=13, color=ft.Colors.GREY_500),
18+
],
19+
)

src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
from kubeidea.app import main
66

7-
ft.app(target=main)
7+
ft.run(main)

0 commit comments

Comments
 (0)