Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
run: npm run validate
- name: Versions, hooks, MCP wiring, docs, line endings
run: npm run check
- name: Synced skills match the pinned coreflux-skills tag
run: npm run skills:check

unit:
name: Unit tests (${{ matrix.os }}, Node ${{ matrix.node }})
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@ All notable changes to the Coreflux plugin for Cursor are documented here. The f
(`coreflux.vscode-lot-notebooks`) through the Cursor CLI when it is missing, so `.lotnb`
files open as notebooks.
- Plugin logo.
- `coreflux-cursor-tools` skill: maps the broker tool names used by the shared skills to this
plugin's MCP tools.
- `lot_deploy` / `lotnb_deploy` deploy `DEFINE AGENT` (`-addAgent`, after routes) and
`DEFINE THING` (every Thing block, templates included, as one `-addThing`, last, as the broker loads projects);
`lot_remove` takes `AGENT` and `THING`.

### Changed

- The LoT and broker skills are now a pinned copy of
[coreflux-skills](https://github.com/CorefluxCommunity/coreflux-skills) (tag `2.21.16-rc.186`),
generated from the broker: `broker-tools`, `lot-actions`, `lot-models`, `lot-routes`,
`lot-rules`, `lot-agents`, `lot-things`, `lot-panels`, `lot-themes`, `python-scripts`.
`npm run skills:sync` updates the copy and `npm run skills:check` (in CI) fails on drift.

### Removed

- The hand-written `lot-authoring`, `broker-commands`, `broker-observability`,
`broker-security` and `lot-projects` skills, replaced by the synced set above.

## [0.1.0] - 2026-09-13

Expand Down
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ npm run e2e # deploys throw-away entities, drives them, removes them

### Writing skills and rules

- The LoT/broker skills under `plugins/coreflux/skills/` (every one listed in `skills.json`) are
synced from [coreflux-skills](https://github.com/CorefluxCommunity/coreflux-skills), which is
generated from the broker. Do not edit them here; `npm run skills:check` fails on any drift.
Fix the skill in the broker (`src/CorefluxCentral/Agents/Skills/*.md`, `audience: [broker, external]`),
then, once a broker release has tagged coreflux-skills, run `npm run skills:sync -- --ref <tag>`.
- Plugin-only guidance (this plugin's MCP tools, hooks, profiles) goes in
`skills/coreflux-cursor-tools`, a rule, an agent or a command.
- Keep examples copy-pastable. Prefer realistic names (`PackagingLine`, `PLC_Modbus`) over
`foo`/`test`.
- Action, model, route and rule names are bare identifiers; panel and theme names are quoted.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ themes on a Coreflux broker.

| Plugin | What it gives the agent |
|--------|-------------------------|
| [`plugins/coreflux`](plugins/coreflux) | The full broker command surface over MQTT (`$SYS/Coreflux/Command`), live topic publish/subscribe, LoT lint + ordered deployment of `.lot`/`.lotnb` files, project upload/export, route templates, action tracing, docs search, five LoT/broker skills, two agents, six slash-commands and safety hooks for destructive operations. |
| [`plugins/coreflux`](plugins/coreflux) | The full broker command surface over MQTT (`$SYS/Coreflux/Command`), live topic publish/subscribe, LoT lint + ordered deployment of `.lot`/`.lotnb` files, project upload/export, route templates, action tracing, docs search, the Coreflux LoT/broker skills (synced from coreflux-skills), two agents, six slash-commands and safety hooks for destructive operations. |

## Install

Expand Down Expand Up @@ -76,7 +76,7 @@ Node 20 and 22, and the end-to-end suite against `coreflux/coreflux-mqtt-broker:
## Contributing

Issues and PRs welcome — see [CONTRIBUTING.md](CONTRIBUTING.md) for the checks to run, how to
write skills that stay true to the broker parser, and the release process.
update the synced skills, and the release process.
[SECURITY.md](SECURITY.md) covers vulnerability reports. Changes are tracked in
[CHANGELOG.md](CHANGELOG.md).

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
"scripts": {
"validate": "node scripts/validate-template.mjs",
"check": "node scripts/check-sources.mjs",
"skills:sync": "node scripts/sync-skills.mjs",
"skills:check": "node scripts/sync-skills.mjs --check",
"test": "node scripts/run-tests.mjs",
"smoke": "node plugins/coreflux/scripts/smoke-test.mjs",
"e2e": "node plugins/coreflux/scripts/e2e-test.mjs",
"ci": "npm run validate && npm run check && npm test"
"ci": "npm run validate && npm run check && npm run skills:check && npm test"
}
}
21 changes: 14 additions & 7 deletions plugins/coreflux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,20 @@ workspace file `active` → user file `active` → `default` → `workspace` →

### Skills (`skills/`)

| Skill | Use |
|-------|-----|
| `lot-authoring` | LoT syntax, decision guide, anti-patterns; references for actions, models, routes |
| `broker-commands` | Every broker command, payload rules, envelope shape, sequences |
| `broker-observability` | `$SYS/Coreflux` topic map, status/trace JSON, triage playbook |
| `lot-projects` | `.lotnb` format, project layout, load order, `-addProject` / git commands |
| `broker-security` | RBAC rules, flags, groups, which flag each command needs, anti-lockout |
The LoT and broker skills are a pinned copy of
[CorefluxCommunity/coreflux-skills](https://github.com/CorefluxCommunity/coreflux-skills), which is
generated from the broker and tagged per broker release; the tag in use is `brokerVersion` in
`skills/skills.json`. Do not edit them here — fix the broker's skill and move the pin with
`npm run skills:sync -- --ref <tag>`. CI fails when the bundle drifts from the pinned tag.

| Skill | Source | Use |
|-------|--------|-----|
| `broker-tools` | coreflux-skills | The broker's tool surfaces, registry commands, safe deploy workflow |
| `lot-actions` / `lot-models` / `lot-routes` / `lot-rules` | coreflux-skills | LoT syntax per entity kind |
| `lot-agents` / `lot-things` | coreflux-skills | `DEFINE AGENT`, `DEFINE THING` |
| `lot-panels` / `lot-themes` | coreflux-skills | LoTV dashboards |
| `python-scripts` | coreflux-skills | Python scripts and `CALL PYTHON` |
| `coreflux-cursor-tools` | this plugin | Maps the broker tool names in those skills to this plugin's MCP tools; envelopes; deploying files and projects |

### Rules (`rules/`)

Expand Down
5 changes: 3 additions & 2 deletions plugins/coreflux/agents/broker-operator.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ state: every statement about the broker is backed by an envelope or a topic you

## Diagnosing

Follow the `broker-observability` skill playbook:
Use `broker-tools` for what the broker can tell you and `coreflux-cursor-tools` for the tool
to call here:
- Actions: `broker_action_trace { action, payload }`, then `$SYS/Coreflux/Actions/<name>/Error`.
- Routes: status JSON (`errors.consecutive`, `health`), `-checkRouteConnection`, the route
source on `$SYS/Coreflux/Routes/<name>`, env/secret names via `-listEnv` / `-listSecrets`.
- Data flow: `mqtt_subscribe` on the exact topic for a bounded time; OT values are on
`<SOURCE_TOPIC>/<Tag>`.
- Permissions: `Permission denied` → `broker-security` skill; identify the missing flag.
- Permissions: `Permission denied` → `lot-rules` skill; identify the scope and rule that denied.

## Changing things

Expand Down
3 changes: 2 additions & 1 deletion plugins/coreflux/agents/lot-reviewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ the broker parser and runtime will. Be concrete: file, cell, line, wrong text, c

1. Run `lot_lint` on every changed `.lot` / `.lotnb` (path mode) and on any inline LoT.
Report every `error`; treat `warning`s as findings to explain.
2. Read the code with the `lot-authoring` skill open and check what the linter cannot:
2. Read the code with the skill for each kind open (`lot-actions`, `lot-models`, `lot-routes`,
`lot-rules`, `lot-panels`, `python-scripts`, …) and check what the linter cannot:
- Wildcards and `TOPIC POSITION` indexes match the real topic shape (1-based).
- `IF` conditions compare compatible types (`PAYLOAD AS DOUBLE` before `> 85`).
- `GET JSON` paths exist in the payload the action really receives.
Expand Down
4 changes: 2 additions & 2 deletions plugins/coreflux/commands/coreflux-new-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ description: Scaffold a Coreflux LoT project folder with numbered .lotnb noteboo
Ask for: project name (kebab-case), what it should do (devices/sources, outputs), and which
broker it targets (an existing profile from `broker_list`, or a new URL).

1. Create the layout described in the `lot-projects` skill:
1. Create the layout (numbered so alphabetical order matches load order):
`README.md`, `01-models.lotnb`, `02-actions.lotnb`, `03-routes.lotnb`, `04-rules.lotnb`,
`05-dashboard.lotnb` (skip files that would be empty). For the broker, write
`.coreflux/brokers.json` with `broker_save { scope: "workspace", name, url, username,
passwordEnv, activate: true }` — the password goes in an environment variable or in the
user-scope profile of the same name, never in the project.
2. Each notebook starts with a markdown cell (purpose, topics in/out, how to test) followed by
`lot` cells written with the `lot-authoring` skill. Use realistic names from the user's
`lot` cells written with the skill for each kind (`lot-models`, `lot-actions`, …). Use realistic names from the user's
domain, never `foo`/`test`.
3. README lists: what the project does, required `-setEnv` / `-setSecret` names, how to deploy
(`project_upload` or `-addProject`), how to verify.
Expand Down
2 changes: 1 addition & 1 deletion plugins/coreflux/commands/coreflux-new-route.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ and out (topics), polling interval for OT routes.
1. `broker_route_template { type }` → use `fields` to know every setting, its type, regex and
whether it should come from env (`env: true`). Start from `skeleton` (the `ADD METADATA`
block is already removed).
2. Fill the skeleton following `lot-authoring` → `lot-routes.md`:
2. Fill the skeleton following the `lot-routes` skill:
- hosts/users → `GET ENV "NAME"`; passwords/keys → `GET SECRET "NAME"`;
- OT routes: `ADD MAPPING` with `SOURCE_TOPIC` + `EVERY`, tags indented 8 spaces; values
will appear on `<SOURCE_TOPIC>/<Tag>`;
Expand Down
4 changes: 2 additions & 2 deletions plugins/coreflux/commands/coreflux-secure.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ description: Audit a Coreflux broker's access control — users, permission flag

# Secure the broker

Use the `broker-security` skill throughout.
Use the `lot-rules` skill throughout (scopes, priority bands, which scopes a user rule can
change at all).

1. `broker_connection` — which user you are; note if it is `root`.
2. Inventory: `mqtt_read_retained $SYS/Coreflux/Rules/#` (deployed rules),
Expand All @@ -19,7 +20,6 @@ Use the `broker-security` skill throughout.
6. Propose, in order and with the exact LoT / `-command`:
- per-device or per-group publish/subscribe rules (priority 100–999 999, allow-list style);
- `FOR Connect` admission if devices have a client-id pattern;
- `SubscribeSys` carve-outs for dashboard users instead of `AllowedSystemConfiguration`;
- moving secrets from env to `-setSecret`;
- password rotation via `-changeUserPassword` (values supplied by the user, never echoed).
7. For each rule, state which users/clients it affects and confirm `root`/admin stay allowed.
Expand Down
5 changes: 4 additions & 1 deletion plugins/coreflux/rules/coreflux-conventions.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ alwaysApply: true
# Coreflux conventions

- **LoT is the only configuration language** for actions, models, routes, rules, panels and
themes. Never propose JSON/YAML for these. Read the `lot-authoring` skill before writing LoT.
themes. Never propose JSON/YAML for these. Before writing LoT read the skill for that kind
(`lot-actions`, `lot-models`, `lot-routes`, `lot-rules`, `lot-agents`, `lot-things`,
`lot-panels`, `lot-themes`, `python-scripts`). Those skills come from the broker; where they
name a broker MCP tool, `coreflux-cursor-tools` gives the tool to call here.
- **Talk to the broker through the `coreflux-broker` MCP tools**, not ad-hoc shell MQTT
clients: `broker_command`, `broker_overview`, `lot_lint`, `lot_deploy`, `lotnb_deploy`,
`mqtt_publish`, `mqtt_subscribe`, `mqtt_read_retained`, `broker_action_trace`,
Expand Down
5 changes: 3 additions & 2 deletions plugins/coreflux/rules/lot-files.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ alwaysApply: false
`{braces}`, credentials via `GET ENV` / `GET SECRET`.
- After every edit run `lot_lint { path }` on the file. Before claiming a notebook is done run
`lotnb_deploy { path, dryRun: true }` to confirm the plan (order: models → actions → routes →
rules → python → themes → panels), then deploy for real if a broker is configured.
agents → rules → python → themes → panels → things), then deploy for real if a broker is configured.
- Do not "fix" a notebook by deleting cells whose meaning you do not understand; ask.
- Follow the `lot-authoring` and `lot-projects` skills for syntax and layout.
- Follow the skill for each kind (`lot-actions`, `lot-models`, `lot-routes`, …) for syntax and
`coreflux-cursor-tools` for deploying files and projects.
2 changes: 1 addition & 1 deletion plugins/coreflux/scripts/hooks/session-context.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function countNotebooks(dir, depth = 0, acc = { lotnb: 0, lot: 0 }) {

const counts = countNotebooks(root);
if (counts.lotnb || counts.lot) {
lines.push(`Workspace contains ${counts.lotnb} .lotnb notebook(s) and ${counts.lot} .lot file(s): treat it as a Coreflux LoT project (skills: lot-authoring, lot-projects).`);
lines.push(`Workspace contains ${counts.lotnb} .lotnb notebook(s) and ${counts.lot} .lot file(s): treat it as a Coreflux LoT project (skills: coreflux-cursor-tools, then lot-actions, lot-models, lot-routes, … per kind).`);
}

respond({ additional_context: `Coreflux plugin: ${lines.join(" ")}` });
14 changes: 7 additions & 7 deletions plugins/coreflux/scripts/mcp/coreflux-mqtt-mcp.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import path from "node:path";
import { randomUUID } from "node:crypto";
import { createInterface } from "node:readline";
import { MqttClient, topicMatches } from "./lib/mqtt-client.mjs";
import { deployCommand, lintLot, loadLotFile, sortForDeploy, splitLotEntities, ENTITY_COMMANDS } from "./lib/lot.mjs";
import { deployCommand, deployUnits, lintLot, loadLotFile, splitLotEntities, ENTITY_COMMANDS } from "./lib/lot.mjs";
import { zipDirectory } from "./lib/zip.mjs";
import { describeProfiles, loadProfiles, removeProfile, resolveSettings as resolveProfileSettings, saveProfile, setActiveProfile } from "./lib/brokers.mjs";

Expand Down Expand Up @@ -260,7 +260,7 @@ function summarizeEnvelope(envelope) {
// ---------------------------------------------------------------------------------------------

async function deployEntities(entities, { dryRun = false, stopOnError = true, lint = true, timeoutMs = DEFAULT_TIMEOUT_MS }) {
const plan = sortForDeploy(entities).map((entity) => ({
const plan = deployUnits(entities).map((entity) => ({
kind: entity.kind,
name: entity.name,
source: entity.source,
Expand All @@ -282,7 +282,7 @@ async function deployEntities(entities, { dryRun = false, stopOnError = true, li
}

const results = [];
for (const entity of sortForDeploy(entities)) {
for (const entity of deployUnits(entities)) {
let outcome;
try {
const envelope = await session.command(deployCommand(entity), { timeoutMs });
Expand Down Expand Up @@ -590,7 +590,7 @@ const tools = [
{
name: "lot_lint",
description:
"Statically check LoT source for the mistakes that break the broker parser (indentation, indented triggers, missing DO/WITH/THEN, MESSAGE keyword, 0-based TOPIC POSITION, quoted action/model/route/rule names, ADD METADATA, hardcoded passwords, PAYLOAD on timers, models without AS TRIGGER…). Pass either code or a path to a .lot/.lotnb file. Run before deploying.",
"Statically check LoT source for the mistakes that break the broker parser (indentation, indented triggers, missing DO/WITH/THEN, MESSAGE keyword, 0-based TOPIC POSITION, quoted action/model/route/agent/rule names, ADD METADATA, hardcoded passwords, PAYLOAD on timers, models without AS TRIGGER (skipped when the model inherits via FROM)…). Pass either code or a path to a .lot/.lotnb file. Run before deploying.",
inputSchema: {
type: "object",
properties: {
Expand All @@ -615,7 +615,7 @@ const tools = [
{
name: "lot_deploy",
description:
"Deploy LoT source (one or more DEFINE blocks, or a Python script with a # Script Name header) to the broker. Splits entities, lints them, deploys in broker order (models → actions → routes → rules → python → themes → panels) and returns each envelope. Use dryRun=true to see the plan first.",
"Deploy LoT source (one or more DEFINE blocks, or a Python script with a # Script Name header) to the broker. Splits entities, lints them, deploys in broker order (models → actions → routes → agents → rules → python → themes → panels → things; all Things go as one -addThing) and returns each envelope. Use dryRun=true to see the plan first.",
inputSchema: {
type: "object",
properties: {
Expand Down Expand Up @@ -668,11 +668,11 @@ const tools = [
},
{
name: "lot_remove",
description: "Remove a single LoT entity from the broker (-removeAction / -removeModel / -removeRoute / -removeRule / -removePython / -removeTheme / -removePanel).",
description: "Remove a single LoT entity from the broker (-removeAction / -removeModel / -removeRoute / -removeRule / -removeAgent / -removeThing / -removePython / -removeTheme / -removePanel). Change a Thing's child through its Thing, never directly.",
inputSchema: {
type: "object",
properties: {
kind: { type: "string", enum: ["ACTION", "MODEL", "ROUTE", "RULE", "PYTHON", "THEME", "PANEL"] },
kind: { type: "string", enum: ["ACTION", "MODEL", "ROUTE", "RULE", "AGENT", "THING", "PYTHON", "THEME", "PANEL"] },
name: { type: "string" },
},
required: ["kind", "name"],
Expand Down
Loading
Loading