Skip to content
Open
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
12 changes: 10 additions & 2 deletions .gemini/skills/initiative-start/reasearch-skill.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ Ensure all work begins with **documentation-first understanding**, **PRD validat
1. `/CONTRIBUTING.md`
2. `/README.md`
3. `/.github/skills/code-standards/SKILL.md`
4. `/docs/**`
5. Related module/code context if referenced
4. `/.github/skills/database-patterns/SKILL.md` — read when the feature touches the `Devices` table or requires audit/history logging
5. `/docs/**`
6. Related module/code context if referenced
Comment thread
jokob-sk marked this conversation as resolved.

* Extract:

Expand Down Expand Up @@ -69,6 +70,13 @@ If anything is unclear:
* Breaking assumptions
* Plugin or API mismatches

* **If the feature writes to the `Devices` table:**

* Load `/.github/skills/database-patterns/SKILL.md`
* Audit all write paths listed there — confirm which are affected
* Determine if a SQLite trigger or Python hook is the right approach
* Check if `*Source` fields already solve attribution requirements

* Clearly report inconsistencies before proceeding

---
Expand Down
90 changes: 80 additions & 10 deletions .gemini/skills/plugin-development/plugin-skill.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,86 @@
# Plugin development skill
---
name: netalertx-plugin-development
description: Create and run NetAlertX plugins. Use this when asked to create plugin, run plugin, test plugin, or develop plugin functionality.
---

1. Assess requirements
2. Read `docs/PLUGINS_DEV.md`
3. Confirm field mapping
4. Ask clarifying questions
5. code placed in `front/plugins/<new plugin name>`
# Plugin Development

## Expected Workflow

Plugin prefix:
1. Read this skill and `docs/PLUGINS_DEV.md` for full context.
2. Find or create the plugin in `front/plugins/<code_name>/`.
3. Read the plugin's `config.json` and `script.py` to understand its functionality.
4. Run: `python3 front/plugins/<code_name>/script.py`
5. Retrieve the result from `/tmp/log/plugins/last_result.<PREF>.log` quickly — the backend deletes it after processing.

- has to be uppercase letters only (no underscores)
- must be unique
- keep short but readable if possible
## Run a Plugin Manually

```bash
python3 front/plugins/<code_name>/script.py
```

Ensure `sys.path` includes `/app/front/plugins` and `/app/server` (as in the template).

## Plugin Structure

```text
front/plugins/<code_name>/
├── config.json # Manifest with settings
├── script.py # Main script
└── ...
```

## Plugin Prefix Rules

- Uppercase letters only (no underscores, no numbers)
- Must be unique across all plugins
- Short but readable (e.g., `ARPSCAN`, `MQTT`, `UNIFI`)

## Settings Pattern

- `<PREF>_RUN`: execution phase
- `<PREF>_RUN_SCHD`: cron-like schedule
- `<PREF>_CMD`: script path
- `<PREF>_RUN_TIMEOUT`: timeout in seconds
- `<PREF>_WATCH`: columns to watch for changes

## Data Contract

Scripts write to `/tmp/log/plugins/last_result.<PREF>.log` using `plugin_helper.py`:

```python
from plugin_helper import Plugin_Objects

plugin_objects = Plugin_Objects()
plugin_objects.add_object(...) # During processing
plugin_objects.write_result_file() # Exactly once at end
```

**Important:** The backend processes and deletes the result file almost immediately. Retrieve it quickly if inspecting output.

## Execution Phases

| Phase | Trigger |
|-------|---------|
| `once` | Once at startup |
| `schedule` | On cron schedule |
| `always_after_scan` | After every scan |
| `before_name_updates` | Before name resolution |
| `on_new_device` | When new device detected |
| `on_notification` | When notification triggered |

## Plugin Formats

| Format | Purpose | Phase |
|--------|---------|-------|
| publisher | Send notifications | `on_notification` |
| dev scanner | Create/manage devices | `schedule` |
| name discovery | Discover device names | `before_name_updates` |
| importer | Import from services | `schedule` |
| system | Core functionality | `schedule` |

## Starting Point

Copy from `front/plugins/__template` and customize. Read `docs/PLUGINS_DEV.md` for the full development guide.


59 changes: 51 additions & 8 deletions .gemini/skills/project-navigation/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,56 @@ name: project-navigation
description: Reference for the NetAlertX codebase structure, key file paths, and configuration locations. Use this when exploring the codebase or looking for specific components like the backend entry point, frontend files, or database location.
---

# Project Navigation & Structure
# Project Navigation

## Codebase Structure & Key Paths
## Key Paths

- **Source Code:** `/workspaces/NetAlertX` (mapped to `/app` in container via symlink).
- **Backend Entry:** `server/api_server/api_server_start.py` (Flask) and `server/__main__.py`.
- **Frontend:** `front/` (PHP/JS).
- **Plugins:** `front/plugins/`.
- **Config:** `/data/config/app.conf` (runtime) or `back/app.conf` (default).
- **Database:** `/data/db/app.db` (SQLite).
| Component | Path |
|-----------|------|
| Workspace root | `/workspaces/NetAlertX` |
| Backend entry | `server/__main__.py` |
| API server | `server/api_server/api_server_start.py` |
| Plugin system | `server/plugin.py` |
| Initialization | `server/initialise.py` |
| Frontend | `front/` |
| Frontend JS | `front/js/common.js` |
| Frontend PHP | `front/php/server/*.php` |
| Plugins | `front/plugins/` |
| Plugin template | `front/plugins/__template` |
| Database helpers | `server/db/db_helper.py` |
| Device model | `server/models/device_instance.py` |
| Messaging | `server/messaging/` |
| Workflows | `server/workflows/` |

## Architecture

NetAlertX uses a frontend–backend architecture: the frontend runs on **PHP + Nginx** (see `front/`), the backend is implemented in **Python** (see `server/`), and scheduled tasks are managed by a **supercronic** scheduler.

## Runtime Paths

| Data | Path |
|------|------|
| Config (runtime) | `/data/config/app.conf` |
| Config (default) | `back/app.conf` |
| Database | `/data/db/app.db` |
| API JSON cache | `/tmp/api/*.json` |
| Logs | `/tmp/log/` |
| Plugin logs | `/tmp/log/plugins/` |

## Environment Variables

Use these instead of hardcoding paths:
- `NETALERTX_DB`
- `NETALERTX_LOG`
- `NETALERTX_CONFIG`
- `NETALERTX_DATA`
- `NETALERTX_APP`

## Documentation

| Topic | Path |
|-------|------|
| Plugin development | `docs/PLUGINS_DEV.md` |
| System settings | `docs/SETTINGS_SYSTEM.md` |
| API docs | `docs/API_*.md` |
| Debug guides | `docs/DEBUG_*.md` |
Loading
Loading