maddex
v0.2.2
Published
Maddex CLI fetches remote Caspian-ready Python UI components from the Maddex registry and writes them into your project. It also bootstraps a few project defaults and keeps Maddex metadata in sync for both human and AI-assisted workflows.
Downloads
1,118
Readme
Maddex CLI
Maddex CLI fetches remote Caspian-ready Python UI components from the Maddex registry and writes them into your project. It also bootstraps a few project defaults and keeps Maddex metadata in sync for both human and AI-assisted workflows.
What the CLI does
- Installs one or more remote components with
maddex add <name...>. - Supports both multi-file components and legacy single-file component payloads.
- Prompts interactively when you run
maddex addwithout component names. - Installs the full remote catalogue with
maddex add --all. - Refreshes already installed Python components with
maddex update. - Bootstraps default icons, Tailwind CSS, and the
tw-animate-csspackage when needed. - Writes a Maddex manifest into
maddex.json, refreshes the managed AI context block in.github/instructions/maddex.instructions.md, and keeps.github/copilot-instructions.mdavailable as a stable top-level pointer file.
Supported commands
The CLI currently supports only two commands:
maddex add [--all] [--force] [components...]
maddex updateExamples:
maddex add Button
maddex add Button Card
maddex add
maddex add --all
maddex add --force Button
maddex updateNotes:
addwith no component names opens an interactive text prompt.--allis only meaningful withadd.--forceis only parsed foradd.updatealways refreshes installed components with overwrite behavior.
First-run and housekeeping behavior
On every CLI run, Maddex first verifies that the current working directory is a Caspian project by checking for caspian.config.json in the project root. After that check passes, it loads maddex.json and creates it if it does not exist.
During normal execution, the CLI also performs these housekeeping steps:
- If
iconsInstalledisfalse, it installsppiconsglobally and runsnpx ppicons add ...for a default icon set. - It ensures
tw-animate-cssexists in the current project's dependencies or devDependencies. - It copies the bundled
globals.cssintosrc/app/globals.css. - After a successful install or refresh flow, it writes Maddex manifest data back into
maddex.json, updates the managed instruction block in.github/instructions/maddex.instructions.md, and creates.github/copilot-instructions.mdwhen missing without rewriting existing manual content there.
On the first add run, if you are not using --all, Maddex prepends these core components before your requested names:
SlotPortalutils
Overwrite behavior is also different on first run:
- First run: bundled
globals.cssis copied with overwrite enabled. - Later runs:
globals.cssis copied only when missing. - Component files are overwritten only when
--forceis passed toadd, or whenupdateis used.
Generated files
By default, Maddex writes Python components into:
src/lib/maddexComponent payloads can contain one file or several files. For example:
src/lib/maddex/
Button.py
Button.htmlMaddex may also create or update these files:
maddex.jsonsrc/app/globals.css.github/instructions/maddex.instructions.md.github/copilot-instructions.md
Important details:
updatediscovers installed components by scanning only.pyfiles inoutputDir.__init__.pyis ignored during update scans.- Sidecar files such as
.htmlfiles are written during component generation, but they are not used to discover installed components. - Manual content outside the Maddex-managed block in
.github/instructions/maddex.instructions.mdis preserved. .github/copilot-instructions.mdis kept as a stable top-level file and is not used as the Maddex-managed block target.
First-party CRUD pattern
For Maddex and Caspian CRUD screens, the default composition pattern is:
- Let
index.pyandindex.htmlown the list shell, search, pagination, lookup data, and dialog state. - Use one
CreateUpdateDialogcomposition component for both create and update flows, built with MaddexDialogprimitives. - Drive create versus update from
selectedItemorselectedItem.id, and map that value into local form state when the dialog opens. - Keep create and update mutations in one
save_*RPC next to that dialog component. - After a successful save, update the parent
itemscollection in place and close the dialog before falling back to a full refetch. - Use a dedicated
DeleteDialogconfirmation component built with MaddexAlertDialogprimitives for deletes. - Keep the delete mutation in a
delete_*RPC next to the delete dialog and remove the deleted record from the parentitemscollection after confirmation. - Pass
openDialog,setOpenDialog,selectedItem,items, andsetItemsas composition props instead of introducing ad-hoc global state for simple CRUD flows. - Treat this as the first pattern AI should reach for when generating Maddex CRUD screens unless the host repo already has a stronger local convention.
Configuration
When maddex.json does not exist, Maddex creates it with this default shape:
{
"style": "default",
"force": false,
"outputDir": "src/lib/maddex",
"iconsInstalled": false,
"tailwind": {
"css": "src/app/globals.css",
"baseColor": "neutral",
"cssVariables": true,
"prefix": ""
},
"pythonPath": "src/lib/maddex",
"iconLibrary": "ppicons"
}After a successful Maddex refresh, the CLI also writes a manifest object into maddex.json that records:
- installed component inventory
- component directory
- Python module path hints
- registry API metadata
- Tailwind CSS metadata
- icon library metadata
What the current runtime actually uses
The current implementation actively uses these config values:
| Field | Current behavior |
| ---------------- | ---------------------------------------------------------------------------------------------- |
| outputDir | Controls where component files are written and where update scans for installed .py files. |
| iconsInstalled | Controls whether the icon bootstrap runs again. |
| pythonPath | Used when building manifest and AI context metadata. |
| iconLibrary | Recorded in the generated manifest and managed AI context content. |
| tailwind.css | Recorded in generated metadata. |
Fields that are currently persisted but do not directly change CLI runtime behavior:
styleforcetailwind.baseColortailwind.cssVariablestailwind.prefix
Current implementation note:
- The bundled CSS copy step always writes to
src/app/globals.css, even iftailwind.cssinmaddex.jsonpoints somewhere else. - The CLI overwrite switch for component files is the
--forcecommand-line flag, not the persistedforcefield inmaddex.json.
Remote registry API
Maddex fetches components from:
GET https://maddex.tsnc.tech/cli?component=allGET https://maddex.tsnc.tech/cli?component=<component-name>
The component=all endpoint returns a JSON array of component names.
Single-component responses can use either of these shapes.
Multi-file payload:
{
"name": "Button",
"files": [
{
"name": "Button.py",
"content": "class Button:\n ...generated Python source..."
},
{
"name": "Button.html",
"content": "<button>...generated template...</button>"
}
]
}Legacy single-file payload:
{
"name": "Button",
"content": "...generated Python source..."
}If the API returns an error status or no usable files or content, Maddex fails the current install for that component.
Installation and local development
This repository currently exposes the executable name maddex through the package bin field.
To work with the CLI from this repository checkout:
npm install
npm run build
node dist/index.js add ButtonIf you want the maddex command available globally while developing locally:
npm install
npm run build
npm link
maddex add ButtonIf you publish this package under your own npm package name, install that package and invoke the maddex executable it exposes.
Requirements
- Node.js 18 or newer is recommended.
npmmust be available because the CLI installs missing packages and the icon bootstrap depends onnpx.- The target project must be a Caspian project root and include
caspian.config.json. - The target project should contain
package.jsonif you want Maddex to auto-installtw-animate-css. - The environment must allow
npm install -g ppiconsthe first time icon bootstrap runs.
Contributor workflow
Useful commands in this repository:
npm test
npm run buildThe build step compiles TypeScript, copies bundled CSS assets into dist, and minifies the final output.
Troubleshooting
No components found to update.means the configuredoutputDirdoes not currently contain any installable.pycomponent files.- If icon bootstrap fails, verify that global npm installs are allowed and that
npx ppiconscan run in your environment. - If a component is skipped during
add, check whether the file already exists and rerun with--forceif overwrite is intended. - If your project uses a Tailwind CSS file outside
src/app/globals.css, note that the current bootstrap copier still targetssrc/app/globals.css.
License
MIT
Author
Jefferson Abraham Omier [email protected]
Homepage: https://maddex.tsnc.tech/ Repository: https://github.com/TheSteelNinjaCode/maddex.git
