Spaces:
Sleeping
Sleeping
Ming Wang commited on
Commit Β·
5f4d28e
1
Parent(s): bf28b11
Phase 4: Copilot governance layer
Browse files- .github/agents/network-dashboard-implementer.md +55 -0
- .github/copilot-instructions.md +122 -0
- .github/prompts/add-chart-widget.prompt.md +68 -0
- .github/prompts/add-kpi-widget.prompt.md +44 -0
- .github/prompts/add-new-component.prompt.md +60 -0
- .github/skills/dashboard-widget.md +42 -0
- README.md +20 -0
- docs/ai-working-rules.md +72 -0
.github/agents/network-dashboard-implementer.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: network-dashboard-implementer
|
| 3 |
+
description: "Specialized agent for implementing features in the PulseFabric Monitor dashboard. Follows strict implementation order and validates all 20 production code rules."
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
# Network Dashboard Implementer
|
| 7 |
+
|
| 8 |
+
You are an expert Angular developer building features for **PulseFabric Monitor**, an enterprise infrastructure monitoring dashboard.
|
| 9 |
+
|
| 10 |
+
## Planning
|
| 11 |
+
|
| 12 |
+
Before writing any code, create a brief plan:
|
| 13 |
+
|
| 14 |
+
1. Identify which phase of the implementation order applies: **db.json β model β service β UI**.
|
| 15 |
+
2. List the files that will be created or modified.
|
| 16 |
+
3. If more than 3 existing files must change, **stop and ask for confirmation**.
|
| 17 |
+
|
| 18 |
+
## Implementation Rules
|
| 19 |
+
|
| 20 |
+
You MUST comply with all 20 rules in `.github/copilot-instructions.md`. The critical ones are:
|
| 21 |
+
|
| 22 |
+
- **No `any` type** β use typed interfaces from `core/models/api.models.ts`.
|
| 23 |
+
- **No hardcoded data** β all data flows from `backend/db.json` through the API service.
|
| 24 |
+
- **No magic numbers** β use constants, enums, or design tokens.
|
| 25 |
+
- **CSS tokens only** β use `--mat-sys-*`, `--pf-*`, or SCSS variables. No raw hex/px/rem.
|
| 26 |
+
- **Separate files** β TS, HTML, SCSS must be in separate files.
|
| 27 |
+
- **Standalone components** β no NgModules.
|
| 28 |
+
- **Reuse before creating** β check existing components before making new ones.
|
| 29 |
+
- **No console.log** β remove all logging before completing.
|
| 30 |
+
- **No dead code** β no commented-out blocks.
|
| 31 |
+
|
| 32 |
+
## Repo Compliance
|
| 33 |
+
|
| 34 |
+
Before completing any task, verify:
|
| 35 |
+
|
| 36 |
+
- [ ] Implementation follows db.json β model β service β UI order
|
| 37 |
+
- [ ] All interfaces defined in `api.models.ts`
|
| 38 |
+
- [ ] All HTTP calls go through `DashboardApi` service
|
| 39 |
+
- [ ] No component fetches data directly
|
| 40 |
+
- [ ] All design tokens used correctly
|
| 41 |
+
- [ ] SCSS nesting β€ 3 levels
|
| 42 |
+
- [ ] `ng build` passes
|
| 43 |
+
|
| 44 |
+
## Validation
|
| 45 |
+
|
| 46 |
+
After implementation, run `ng build` from the `frontend/` directory. The build must pass with zero errors. Budget warnings for echarts are acceptable.
|
| 47 |
+
|
| 48 |
+
## Stop Behavior
|
| 49 |
+
|
| 50 |
+
**Stop and ask the user** when:
|
| 51 |
+
|
| 52 |
+
- The task requires modifying more than 3 existing files.
|
| 53 |
+
- The task conflicts with any of the 20 rules.
|
| 54 |
+
- The data shape in `db.json` is ambiguous or incomplete.
|
| 55 |
+
- You are unsure whether to create a new component or extend an existing one.
|
.github/copilot-instructions.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# PulseFabric Monitor β Copilot Instructions
|
| 2 |
+
|
| 3 |
+
## Project Overview
|
| 4 |
+
|
| 5 |
+
PulseFabric Monitor is an enterprise infrastructure monitoring dashboard built with Angular 21, Angular Material (Material 3), and a json-server fake backend. The codebase lives under `/frontend` (Angular app) and `/backend` (db.json).
|
| 6 |
+
|
| 7 |
+
## Feature Implementation Order
|
| 8 |
+
|
| 9 |
+
When adding any new feature, **always** follow this sequence:
|
| 10 |
+
|
| 11 |
+
1. **db.json** β Add or update the data shape in `backend/db.json`
|
| 12 |
+
2. **Typed model** β Add or update the DTO interface in `frontend/src/app/core/models/api.models.ts`
|
| 13 |
+
3. **Service** β Add a method to `frontend/src/app/core/services/dashboard-api.service.ts`
|
| 14 |
+
4. **UI** β Build or extend the component, consuming data via the service
|
| 15 |
+
|
| 16 |
+
Never skip steps. Never put data fetching logic directly in a component.
|
| 17 |
+
|
| 18 |
+
## All Decisions Must Be Documented
|
| 19 |
+
|
| 20 |
+
Before making any change, write a brief rationale in the commit message or PR description. If a decision involves trade-offs, document it explicitly.
|
| 21 |
+
|
| 22 |
+
---
|
| 23 |
+
|
| 24 |
+
## Twenty Production Code Rules
|
| 25 |
+
|
| 26 |
+
Every line of code generated or modified **must** comply with all twenty rules below. Violations are not acceptable.
|
| 27 |
+
|
| 28 |
+
### 1. Separation of Concerns
|
| 29 |
+
TS, HTML, and SCSS must be in separate files. Frontend and backend are separate directories.
|
| 30 |
+
|
| 31 |
+
### 2. No Hardcoded Data
|
| 32 |
+
All data must come from mock files or API services. Never embed data literals in templates or component classes.
|
| 33 |
+
|
| 34 |
+
### 3. Typed Interfaces for All Data
|
| 35 |
+
Every data structure must have a TypeScript interface. The `any` type is **strictly forbidden** everywhereβfunction parameters, return types, variables, generics.
|
| 36 |
+
|
| 37 |
+
### 4. Component-Driven Architecture
|
| 38 |
+
All UI must be composed of reusable, standalone Angular components. No logic in `app.html` beyond a single root component tag.
|
| 39 |
+
|
| 40 |
+
### 5. No Magic Numbers or Strings
|
| 41 |
+
All values must be stored in named constants, enums, or configuration objects. No unexplained literals in code.
|
| 42 |
+
|
| 43 |
+
### 6. CSS Token System
|
| 44 |
+
All colors, spacing, border-radius, and typography must use Material 3 system variables (`--mat-sys-*`), project tokens (`--pf-*`), or SCSS variables. Never write raw hex, px, or rem values directly in component SCSS.
|
| 45 |
+
|
| 46 |
+
### 7. Material 3 Compliance
|
| 47 |
+
Follow Angular Material / Material 3 guidelines for spacing, typography, color, and component usage. Use `mat-card`, `mat-icon`, etc. from `@angular/material`.
|
| 48 |
+
|
| 49 |
+
### 8. Concise, Idiomatic Angular
|
| 50 |
+
Use signals, `input()`, `inject()`, pipes, and directives. Avoid verbose boilerplate. Prefer declarative patterns over imperative ones.
|
| 51 |
+
|
| 52 |
+
### 9. No Over-Engineering
|
| 53 |
+
Do not add state management libraries, unit test frameworks, authentication, or logging infrastructure unless explicitly requested. Keep it minimal.
|
| 54 |
+
|
| 55 |
+
### 10. Reuse Before Creating
|
| 56 |
+
Before creating any new component, service, or utility, audit existing code for reusable pieces. If an existing component can be extended via inputs, prefer that over creating a new one.
|
| 57 |
+
|
| 58 |
+
### 11. Generic Component Design
|
| 59 |
+
Components like KPI cards, chart widgets, and alert items must be input-driven. Adding a new instance of the same type should require only a single template reference with different inputsβno new component file.
|
| 60 |
+
|
| 61 |
+
### 12. Minimal Change Principle
|
| 62 |
+
If adding a feature requires modifying more than 3 existing files, **stop and explain** the scope before proceeding. Get confirmation before making broad changes.
|
| 63 |
+
|
| 64 |
+
### 13. Flat HTML Structure
|
| 65 |
+
No unnecessary DOM wrappers. Keep HTML structure as flat and semantic as possible. Every element must serve a layout or semantic purpose.
|
| 66 |
+
|
| 67 |
+
### 14. No console.log
|
| 68 |
+
Remove all `console.log`, `console.warn`, `console.error` statements before committing. Use proper error handling patterns instead.
|
| 69 |
+
|
| 70 |
+
### 15. No Dead Code
|
| 71 |
+
No commented-out code blocks. If code is not needed, delete it. Version control preserves history.
|
| 72 |
+
|
| 73 |
+
### 16. Clean Imports
|
| 74 |
+
Every import must be used. No orphan imports. Organize imports logically (Angular core β Angular Material β third-party β project).
|
| 75 |
+
|
| 76 |
+
### 17. Consistent Naming Conventions
|
| 77 |
+
- Files: `kebab-case` (e.g., `kpi-card.ts`)
|
| 78 |
+
- Variables/functions: `camelCase`
|
| 79 |
+
- Classes/interfaces: `PascalCase`
|
| 80 |
+
- CSS classes: `kebab-case`
|
| 81 |
+
|
| 82 |
+
### 18. Single Responsibility per File
|
| 83 |
+
Each file does exactly one thing. One component per file, one service per file, one model group per file.
|
| 84 |
+
|
| 85 |
+
### 19. No `any` Type (Reinforced)
|
| 86 |
+
This rule is critical enough to state twice. `any` is forbidden in all positions: parameters, return types, generics, type assertions. Use `unknown` with type guards if needed.
|
| 87 |
+
|
| 88 |
+
### 20. SCSS Nesting β€ 3 Levels
|
| 89 |
+
SCSS selectors must not nest deeper than 3 levels. Refactor into separate classes if nesting would exceed this limit.
|
| 90 |
+
|
| 91 |
+
---
|
| 92 |
+
|
| 93 |
+
## Project Structure Reference
|
| 94 |
+
|
| 95 |
+
```
|
| 96 |
+
backend/
|
| 97 |
+
db.json β json-server database
|
| 98 |
+
|
| 99 |
+
frontend/src/app/
|
| 100 |
+
core/
|
| 101 |
+
models/api.models.ts β All typed DTOs
|
| 102 |
+
services/dashboard-api.service.ts β API abstraction layer
|
| 103 |
+
mocks/ β Legacy mock files (being phased out)
|
| 104 |
+
dashboard/
|
| 105 |
+
dashboard.ts / .html / .scss β Main dashboard page
|
| 106 |
+
kpi-card/ β Generic KPI card (input-driven)
|
| 107 |
+
chart-widget/ β Generic chart widget (input-driven)
|
| 108 |
+
alert-list/ β Alert list component
|
| 109 |
+
chart-config.factory.ts β Pure functions generating ECharts options
|
| 110 |
+
shared/styles/
|
| 111 |
+
_tokens.scss β Design tokens (spacing, radius, etc.)
|
| 112 |
+
environments/
|
| 113 |
+
environment.ts β Dev config (apiBaseUrl)
|
| 114 |
+
environment.prod.ts β Prod config
|
| 115 |
+
```
|
| 116 |
+
|
| 117 |
+
## Key Patterns
|
| 118 |
+
|
| 119 |
+
- **Chart addition**: Add factory function in `chart-config.factory.ts` β reference `<app-chart-widget>` in template with `[options]`
|
| 120 |
+
- **KPI addition**: Add entry to `db.json` kpis array β `<app-kpi-card>` renders automatically via `@for`
|
| 121 |
+
- **Alert addition**: Add entry to `db.json` alerts array β renders automatically
|
| 122 |
+
- **API base URL**: Managed via `environment.ts` + Angular dev proxy (`proxy.conf.json`)
|
.github/prompts/add-chart-widget.prompt.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
mode: agent
|
| 3 |
+
description: "Add a new chart widget to the PulseFabric Monitor dashboard"
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
# Demo: Add a Chart to AI Drop Zone
|
| 7 |
+
|
| 8 |
+
Use this prompt during live demo. Copy and paste the sentence below into Copilot Chat:
|
| 9 |
+
|
| 10 |
+
> Add a CPU Load by Device bar chart to the AI Widget Drop Zone at the bottom of the dashboard. Show 5 devices with fake CPU percentage data. Add the data to db.json first, then create the chart. Follow all repo rules in copilot-instructions.md.
|
| 11 |
+
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
## Task: Add a New Chart Widget
|
| 15 |
+
|
| 16 |
+
Follow the strict implementation order. Do not skip any step.
|
| 17 |
+
|
| 18 |
+
### Step 1 β db.json
|
| 19 |
+
Open `backend/db.json` and add a new top-level collection for the chart data. Example:
|
| 20 |
+
```json
|
| 21 |
+
"myNewData": [
|
| 22 |
+
{ "label": "A", "value": 10 },
|
| 23 |
+
{ "label": "B", "value": 20 }
|
| 24 |
+
]
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
### Step 2 β Typed Model
|
| 28 |
+
Add the DTO interface to `frontend/src/app/core/models/api.models.ts`:
|
| 29 |
+
```ts
|
| 30 |
+
export interface MyNewDto {
|
| 31 |
+
label: string;
|
| 32 |
+
value: number;
|
| 33 |
+
}
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
### Step 3 β Service Method
|
| 37 |
+
Add a method to `frontend/src/app/core/services/dashboard-api.service.ts`:
|
| 38 |
+
```ts
|
| 39 |
+
getMyNewData(): Observable<MyNewDto[]> {
|
| 40 |
+
return this.http.get<MyNewDto[]>(`${this.base}/myNewData`);
|
| 41 |
+
}
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
### Step 4 β Chart Factory Function
|
| 45 |
+
Add a pure function in `frontend/src/app/dashboard/chart-config.factory.ts`:
|
| 46 |
+
```ts
|
| 47 |
+
export function buildMyNewChartOption(data: MyNewDto[]): EChartsOption {
|
| 48 |
+
// Use PALETTE constants for colors.
|
| 49 |
+
// Return a complete EChartsOption object.
|
| 50 |
+
}
|
| 51 |
+
```
|
| 52 |
+
Colors MUST come from the `PALETTE` constant β no raw hex in the function.
|
| 53 |
+
|
| 54 |
+
### Step 5 β Dashboard Integration
|
| 55 |
+
In `frontend/src/app/dashboard/dashboard.ts`:
|
| 56 |
+
- Import the new factory function and DTO.
|
| 57 |
+
- Add a signal for the chart options.
|
| 58 |
+
- Call the new service method inside the existing `forkJoin` block.
|
| 59 |
+
|
| 60 |
+
In `frontend/src/app/dashboard/dashboard.html`:
|
| 61 |
+
- Add a `<app-chart-widget>` reference with `[title]` and `[options]`.
|
| 62 |
+
|
| 63 |
+
**Do NOT create a new component.** Use the existing `ChartWidget` with different inputs.
|
| 64 |
+
|
| 65 |
+
### Validation
|
| 66 |
+
- Run `ng build` β must pass.
|
| 67 |
+
- Confirm the chart renders in the browser.
|
| 68 |
+
- Confirm no `console.log`, no `any`, no magic numbers, SCSS β€ 3 levels.
|
.github/prompts/add-kpi-widget.prompt.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
mode: agent
|
| 3 |
+
description: "Add a new KPI widget to the PulseFabric Monitor dashboard"
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
# Demo: Add a KPI Card
|
| 7 |
+
|
| 8 |
+
Use this prompt during live demo. Copy and paste the sentence below into Copilot Chat:
|
| 9 |
+
|
| 10 |
+
> Add a new KPI card called Active Sessions showing the number 14,200 with a trending up indicator. Put it next to the existing KPI cards. Follow all repo rules in copilot-instructions.md.
|
| 11 |
+
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
## Task: Add a New KPI Widget
|
| 15 |
+
|
| 16 |
+
Follow the strict implementation order below. Do not skip any step.
|
| 17 |
+
|
| 18 |
+
### Step 1 β db.json
|
| 19 |
+
Open `backend/db.json` and add a new entry to the `kpis` array:
|
| 20 |
+
```json
|
| 21 |
+
{
|
| 22 |
+
"id": "<kebab-case-id>",
|
| 23 |
+
"title": "<Display Title>",
|
| 24 |
+
"value": "<string value>",
|
| 25 |
+
"unit": "<optional unit>",
|
| 26 |
+
"trend": "up | down | stable",
|
| 27 |
+
"trendLabel": "<human-readable trend>",
|
| 28 |
+
"icon": "<Material Icon name>"
|
| 29 |
+
}
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
### Step 2 β Verify Typed Model
|
| 33 |
+
Ensure `KpiDto` in `frontend/src/app/core/models/api.models.ts` already covers the shape. If new fields are needed, add them to the interface.
|
| 34 |
+
|
| 35 |
+
### Step 3 β Verify Service
|
| 36 |
+
Confirm `DashboardApi.getKpis()` in `frontend/src/app/core/services/dashboard-api.service.ts` already returns `Observable<KpiDto[]>`. No change should be needed.
|
| 37 |
+
|
| 38 |
+
### Step 4 β UI (Automatic)
|
| 39 |
+
Because the dashboard template uses `@for (kpi of kpis(); track kpi.title)` with `<app-kpi-card>`, the new KPI renders automatically. **No component code changes required.**
|
| 40 |
+
|
| 41 |
+
### Validation
|
| 42 |
+
- Run `ng build` β must pass with no errors.
|
| 43 |
+
- Confirm the new KPI card appears in the browser.
|
| 44 |
+
- Confirm no `console.log`, no `any` type, no hardcoded values.
|
.github/prompts/add-new-component.prompt.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
mode: agent
|
| 3 |
+
description: "Add a new standalone component to the PulseFabric Monitor dashboard"
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
# Demo: Add a Brand New Widget
|
| 7 |
+
|
| 8 |
+
Use this prompt during live demo. Copy and paste the sentence below into Copilot Chat:
|
| 9 |
+
|
| 10 |
+
> Add a new AI Security Recommendations widget to the dashboard. It should show 3 recommendations, each with a priority level (High, Medium, Low) and a short description. Add the data to db.json first, then build the component. Follow all repo rules in copilot-instructions.md.
|
| 11 |
+
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
## Task: Add a New Component
|
| 15 |
+
|
| 16 |
+
Before creating anything, answer these questions:
|
| 17 |
+
|
| 18 |
+
1. **Can an existing component handle this?** Check `kpi-card`, `chart-widget`, and `alert-list` first. If the new feature fits one of these patterns, extend via inputs β do not create a new component.
|
| 19 |
+
2. **Will this modify more than 3 existing files?** If yes, stop and explain the scope before proceeding.
|
| 20 |
+
|
| 21 |
+
If a new component is genuinely needed, follow the steps below.
|
| 22 |
+
|
| 23 |
+
### Step 1 β db.json
|
| 24 |
+
Add the backing data to `backend/db.json` as a new collection.
|
| 25 |
+
|
| 26 |
+
### Step 2 β Typed Model
|
| 27 |
+
Add the DTO interface to `frontend/src/app/core/models/api.models.ts`.
|
| 28 |
+
|
| 29 |
+
### Step 3 β Service Method
|
| 30 |
+
Add a method to `frontend/src/app/core/services/dashboard-api.service.ts` returning `Observable<YourDto[]>`.
|
| 31 |
+
|
| 32 |
+
### Step 4 β Create Component
|
| 33 |
+
Create under `frontend/src/app/dashboard/<component-name>/`:
|
| 34 |
+
```
|
| 35 |
+
<component-name>.ts
|
| 36 |
+
<component-name>.html
|
| 37 |
+
<component-name>.scss
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
Requirements:
|
| 41 |
+
- **Standalone component** β no NgModule.
|
| 42 |
+
- **TS / HTML / SCSS in separate files** β no inline templates or styles.
|
| 43 |
+
- **Input-driven** β accept data via `input()` signals, not internal fetching.
|
| 44 |
+
- **Use Material 3 tokens** β `--mat-sys-*` and `--pf-*` for all visual values.
|
| 45 |
+
- **Flat HTML** β no unnecessary `<div>` wrappers.
|
| 46 |
+
- **SCSS nesting β€ 3 levels**.
|
| 47 |
+
- **No `any` type anywhere**.
|
| 48 |
+
|
| 49 |
+
### Step 5 β Wire into Dashboard
|
| 50 |
+
In `dashboard.ts`:
|
| 51 |
+
- Import the new component, add to `imports` array.
|
| 52 |
+
- Fetch data via the service; store in a signal.
|
| 53 |
+
|
| 54 |
+
In `dashboard.html`:
|
| 55 |
+
- Add the component tag with `[input]` bindings.
|
| 56 |
+
|
| 57 |
+
### Step 6 β Validation
|
| 58 |
+
- `ng build` must pass.
|
| 59 |
+
- No `console.log`, no dead code, no unused imports.
|
| 60 |
+
- Naming: file = `kebab-case`, class = `PascalCase`, variables = `camelCase`.
|
.github/skills/dashboard-widget.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: dashboard-widget
|
| 3 |
+
description: "(Optional) Skill for scaffolding dashboard widgets following PulseFabric conventions"
|
| 4 |
+
optional: true
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
# Dashboard Widget Skill
|
| 8 |
+
|
| 9 |
+
This skill provides step-by-step scaffolding for adding widgets to the PulseFabric Monitor dashboard.
|
| 10 |
+
|
| 11 |
+
## When to Use
|
| 12 |
+
|
| 13 |
+
Use this skill when:
|
| 14 |
+
- Adding a new KPI card (data-only change in `db.json`)
|
| 15 |
+
- Adding a new chart widget (factory function + template reference)
|
| 16 |
+
- Adding a new list or table widget (new component if no existing one fits)
|
| 17 |
+
|
| 18 |
+
## Widget Types
|
| 19 |
+
|
| 20 |
+
### KPI Card (no new component needed)
|
| 21 |
+
1. Add entry to `kpis` array in `backend/db.json`
|
| 22 |
+
2. Verify `KpiDto` interface covers the shape
|
| 23 |
+
3. Card renders automatically via `@for` loop
|
| 24 |
+
|
| 25 |
+
### Chart Widget (no new component needed)
|
| 26 |
+
1. Add data collection to `backend/db.json`
|
| 27 |
+
2. Add DTO to `api.models.ts`
|
| 28 |
+
3. Add service method to `dashboard-api.service.ts`
|
| 29 |
+
4. Add factory function to `chart-config.factory.ts`
|
| 30 |
+
5. Add `<app-chart-widget>` in `dashboard.html` with `[title]` and `[options]`
|
| 31 |
+
|
| 32 |
+
### Custom Widget (new component)
|
| 33 |
+
1. Follow the full db.json β model β service β UI flow
|
| 34 |
+
2. Create standalone component under `frontend/src/app/dashboard/`
|
| 35 |
+
3. Must be input-driven, use Material 3 tokens, separate files
|
| 36 |
+
|
| 37 |
+
## Conventions
|
| 38 |
+
|
| 39 |
+
- Chart colors: use `PALETTE` from `chart-config.factory.ts`
|
| 40 |
+
- Icons: use Material Icons (e.g., `speed`, `warning`, `cloud`)
|
| 41 |
+
- Spacing: use `--pf-space-*` tokens
|
| 42 |
+
- Border radius: use `--pf-radius-*` tokens
|
README.md
CHANGED
|
@@ -16,3 +16,23 @@ This project rearchitects the B2B Design-to-Code workflow, eliminating complex l
|
|
| 16 |
3. Click **Create codespace on main**.
|
| 17 |
4. Wait for the Dev Container to build β Node.js 20, Angular CLI, and all VS Code extensions will be installed automatically.
|
| 18 |
5. Once the terminal is ready, you're good to go.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
3. Click **Create codespace on main**.
|
| 17 |
4. Wait for the Dev Container to build β Node.js 20, Angular CLI, and all VS Code extensions will be installed automatically.
|
| 18 |
5. Once the terminal is ready, you're good to go.
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
Use cases AI prompts
|
| 22 |
+
# Demo: Add a KPI Card
|
| 23 |
+
|
| 24 |
+
Use this prompt during live demo. Copy and paste the sentence below into Copilot Chat:
|
| 25 |
+
|
| 26 |
+
"Add a new KPI card called Active Sessions showing the number 14,200 with a trending up indicator. Put it next to the existing KPI cards. Follow all repo rules in copilot-instructions.md."
|
| 27 |
+
|
| 28 |
+
# Demo: Add a Chart to AI Drop Zone
|
| 29 |
+
|
| 30 |
+
Use this prompt during live demo. Copy and paste the sentence below into Copilot Chat:
|
| 31 |
+
|
| 32 |
+
"Add a CPU Load by Device bar chart to the AI Widget Drop Zone at the bottom of the dashboard. Show 5 devices with fake CPU percentage data. Add the data to db.json first, then create the chart. Follow all repo rules in copilot-instructions.md."
|
| 33 |
+
|
| 34 |
+
# Demo: Add a Brand New Widget
|
| 35 |
+
|
| 36 |
+
Use this prompt during live demo. Copy and paste the sentence below into Copilot Chat:
|
| 37 |
+
|
| 38 |
+
"Add a new AI Security Recommendations widget to the dashboard. It should show 3 recommendations, each with a priority level (High, Medium, Low) and a short description. Add the data to db.json first, then build the component. Follow all repo rules in copilot-instructions.md."
|
docs/ai-working-rules.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AI Working Rules β PulseFabric Monitor
|
| 2 |
+
|
| 3 |
+
This document defines the rules and conventions that AI assistants (GitHub Copilot, agents, etc.) must follow when working on this project.
|
| 4 |
+
|
| 5 |
+
## Feature Implementation Order
|
| 6 |
+
|
| 7 |
+
All features must be implemented in this strict sequence:
|
| 8 |
+
|
| 9 |
+
1. **db.json** β Add or update data in `backend/db.json`
|
| 10 |
+
2. **Typed model** β Add or update the DTO interface in `frontend/src/app/core/models/api.models.ts`
|
| 11 |
+
3. **Service** β Add a method to `frontend/src/app/core/services/dashboard-api.service.ts`
|
| 12 |
+
4. **UI** β Build or extend the component, consuming data via the service
|
| 13 |
+
|
| 14 |
+
Never skip steps. Never put data fetching logic directly in a component.
|
| 15 |
+
|
| 16 |
+
## 20 Production Code Rules
|
| 17 |
+
|
| 18 |
+
| # | Rule | Summary |
|
| 19 |
+
|---|------|---------|
|
| 20 |
+
| 1 | Separation of Concerns | TS, HTML, SCSS in separate files |
|
| 21 |
+
| 2 | No Hardcoded Data | All data from API or mock files |
|
| 22 |
+
| 3 | Typed Interfaces | Every data structure has a TS interface; `any` is forbidden |
|
| 23 |
+
| 4 | Component-Driven | Reusable standalone Angular components |
|
| 24 |
+
| 5 | No Magic Numbers | Named constants, enums, or config objects only |
|
| 25 |
+
| 6 | CSS Token System | Use `--mat-sys-*`, `--pf-*`, or SCSS variables |
|
| 26 |
+
| 7 | Material 3 Compliance | Follow M3 guidelines for all UI |
|
| 27 |
+
| 8 | Concise Angular | Signals, `input()`, `inject()`, pipes, directives |
|
| 28 |
+
| 9 | No Over-Engineering | No unnecessary libraries or infrastructure |
|
| 29 |
+
| 10 | Reuse Before Creating | Audit existing code first |
|
| 30 |
+
| 11 | Generic Component Design | Input-driven; new instance = new inputs, not new file |
|
| 31 |
+
| 12 | Minimal Change Principle | >3 files changed β stop and explain |
|
| 32 |
+
| 13 | Flat HTML Structure | No unnecessary DOM wrappers |
|
| 33 |
+
| 14 | No console.log | Remove all logging before committing |
|
| 34 |
+
| 15 | No Dead Code | No commented-out blocks |
|
| 35 |
+
| 16 | Clean Imports | Every import must be used |
|
| 36 |
+
| 17 | Consistent Naming | kebab-case files, camelCase vars, PascalCase classes |
|
| 37 |
+
| 18 | Single Responsibility | One component/service/model group per file |
|
| 38 |
+
| 19 | No `any` (Reinforced) | Forbidden in all positions |
|
| 39 |
+
| 20 | SCSS Nesting β€ 3 Levels | Refactor into separate classes if exceeded |
|
| 40 |
+
|
| 41 |
+
## Governance Files
|
| 42 |
+
|
| 43 |
+
| File | Purpose |
|
| 44 |
+
|------|---------|
|
| 45 |
+
| `.github/copilot-instructions.md` | Full rule set loaded into every Copilot session |
|
| 46 |
+
| `.github/prompts/add-kpi-widget.prompt.md` | Step-by-step prompt for adding a KPI card |
|
| 47 |
+
| `.github/prompts/add-chart-widget.prompt.md` | Step-by-step prompt for adding a chart widget |
|
| 48 |
+
| `.github/prompts/add-new-component.prompt.md` | Step-by-step prompt for creating a new component |
|
| 49 |
+
| `.github/agents/network-dashboard-implementer.md` | Agent profile with planning, compliance, and stop behavior |
|
| 50 |
+
| `.github/skills/dashboard-widget.md` | Optional skill for widget scaffolding |
|
| 51 |
+
|
| 52 |
+
## Stop Conditions
|
| 53 |
+
|
| 54 |
+
The AI must stop and ask the user when:
|
| 55 |
+
|
| 56 |
+
- A task requires modifying more than 3 existing files
|
| 57 |
+
- A task conflicts with any of the 20 rules
|
| 58 |
+
- The data shape is ambiguous or incomplete
|
| 59 |
+
- It is unclear whether to create or reuse a component
|
| 60 |
+
|
| 61 |
+
## Validation Checklist
|
| 62 |
+
|
| 63 |
+
Before completing any task, verify:
|
| 64 |
+
|
| 65 |
+
- [ ] `ng build` passes from `frontend/`
|
| 66 |
+
- [ ] No `any` types introduced
|
| 67 |
+
- [ ] No `console.log` statements
|
| 68 |
+
- [ ] No dead or commented-out code
|
| 69 |
+
- [ ] All imports are used
|
| 70 |
+
- [ ] SCSS nesting β€ 3 levels
|
| 71 |
+
- [ ] CSS tokens used (no raw hex/px/rem)
|
| 72 |
+
- [ ] Implementation follows db.json β model β service β UI order
|