Initial public push: docs cosmos v4 + AI module + framework groundwork

This is the snapshot the production landing site (nibiru-framework.com) is
deployed from. Brings together the recent splash + docs migration to the v4
"Cosmos" design system, the new in-framework AI module, and the framework
groundwork that backs the framework-reference extraction.

What lands:
- docs/: Astro + Starlight site with the v4 dark cosmic palette, GalaxyHero
  canvas constellation, Mission Control chat (wired to /api/oracle →
  api.neuronetz.ai via providers.mjs Ollama), 5-panel MMVC stage
  (Model · AI · Module · Controller · View), translated EN/DE/JA/ES/FR
  content, PWA + sitemap + llms.txt + Umami analytics.
- docs/design-system/: canonical mockup bundle (source/index-v2.html for
  splash, source/docs-system.html + preview/ for docs, SPEC.md, tokens).
- docs/scripts/extraction/framework-reference-v2.md: deep framework
  reference (~1.6k lines, file:line citations, every public factory and
  idiom — basis for the LoRA training corpus.
- application/module/ai/: AI module with chat / embed / RAG / agent
  plugins, plus pdoQuery / httpGet / fileRead tools and Modelfile +
  smoke-test in training/.
- application/module/users/: user / ACL / form-factory traits used as the
  reference plugin pattern for the framework docs.
- application/settings/config/database/: schema + seed migrations
  including the AI module tables (200–203).
- Form factory + autogenerator changes the framework-reference-v2 covers.

Production secrets stay out: docs/.env, settings.production.ini and
ai.production.ini are all gitignored (.example files are in tree).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
stephan
2026-05-08 15:22:18 +02:00
parent a60ce90643
commit 48c839d927
662 changed files with 172811 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
create table if not exists acl
(
acl_id int auto_increment
primary key,
acl_role varchar(255) null
) engine = InnoDB;

View File

@@ -0,0 +1,7 @@
create table if not exists account
(
account_id int auto_increment
primary key,
account_name varchar(255) null,
account_active tinyint(1) default 1 null
) engine = InnoDB;

View File

@@ -0,0 +1,8 @@
create table if not exists api_registry
(
api_registry_id int auto_increment
primary key,
api_name varchar(255) null,
api_registered tinyint default 0 null
) engine = InnoDB;

View File

@@ -0,0 +1,7 @@
create table if not exists timeanddate
(
timeanddate_id int auto_increment
primary key,
timeanddate_date date default current_timestamp() not null,
timeanddate_time timestamp default current_timestamp() not null
) engine = InnoDB;

View File

@@ -0,0 +1,11 @@
create table if not exists user
(
user_id int auto_increment
primary key,
user_firstname varchar(255) null,
user_lastname varchar(255) null,
user_pass varbinary(50) null,
user_login varchar(255) null,
user_account_active tinyint(1) default 0 not null
) engine = InnoDB;

View File

@@ -0,0 +1,10 @@
SET foreign_key_checks = 0;
CREATE TABLE user_to_account (
account_id int(11) DEFAULT NULL,
user_id int(11) DEFAULT NULL,
KEY user_to_account_account_account_id_fk (account_id),
KEY user_to_account_user_user_id_fk (user_id),
CONSTRAINT user_to_account_account_account_id_fk FOREIGN KEY (account_id) REFERENCES account (account_id),
CONSTRAINT user_to_account_user_user_id_fk FOREIGN KEY (user_id) REFERENCES user (user_id)
) engine = InnoDB;
SET foreign_key_checks = 1;

View File

@@ -0,0 +1,10 @@
SET foreign_key_checks = 0;
CREATE TABLE timeanddate_to_account (
account_id int(11) DEFAULT NULL,
timeanddate_id int(11) DEFAULT NULL,
KEY account_to_timeanddate_account_account_id_fk (account_id),
KEY account_to_timeanddate_timeanddate_timeanddate_id_fk (timeanddate_id),
CONSTRAINT account_to_timeanddate_account_account_id_fk FOREIGN KEY (account_id) REFERENCES account (account_id),
CONSTRAINT account_to_timeanddate_timeanddate_timeanddate_id_fk FOREIGN KEY (timeanddate_id) REFERENCES timeanddate (timeanddate_id)
) engine = InnoDB;
SET foreign_key_checks = 1;

View File

@@ -0,0 +1,10 @@
SET foreign_key_checks = 0;
CREATE TABLE user_to_acl (
user_id int(11) NOT NULL,
acl_id int(11) NOT NULL,
KEY user_to_acl_user_user_id_fk (user_id),
KEY user_to_acl_acl_acl_id_fk (acl_id),
CONSTRAINT user_to_acl_acl_acl_id_fk FOREIGN KEY (acl_id) REFERENCES acl (acl_id),
CONSTRAINT user_to_acl_user_user_id_fk FOREIGN KEY (user_id) REFERENCES user (user_id) ON DELETE CASCADE
) engine = InnoDB;
SET foreign_key_checks = 1;

View File

@@ -0,0 +1,10 @@
SET foreign_key_checks = 0;
CREATE TABLE account_to_api_registry (
account_id int(11) NOT NULL,
api_registry_id int(11) DEFAULT NULL,
PRIMARY KEY (account_id),
KEY account_to_api_registry_api_registry_api_registry_id_fk (api_registry_id),
CONSTRAINT account_to_api_registry_account_account_id_fk FOREIGN KEY (account_id) REFERENCES account (account_id),
CONSTRAINT account_to_api_registry_api_registry_api_registry_id_fk FOREIGN KEY (api_registry_id) REFERENCES api_registry (api_registry_id)
) engine = InnoDB;
SET foreign_key_checks = 1;

View File

@@ -0,0 +1,10 @@
SET foreign_key_checks = 0;
CREATE TABLE timeanddate_to_user (
timeanddate_id int(11) NOT NULL,
user_id int(11) NOT NULL,
KEY timeanddate_to_user_timeanddate_timeanddate_id_fk (timeanddate_id),
KEY timeanddate_to_user_user_user_id_fk (user_id),
CONSTRAINT timeanddate_to_user_timeanddate_timeanddate_id_fk FOREIGN KEY (timeanddate_id) REFERENCES timeanddate (timeanddate_id),
CONSTRAINT timeanddate_to_user_user_user_id_fk FOREIGN KEY (user_id) REFERENCES user (user_id)
) engine = InnoDB;
SET foreign_key_checks = 1;

View File

@@ -0,0 +1,4 @@
INSERT INTO acl VALUES
(1,'superuser'),
(2,'moderator'),
(3,'user');

View File

@@ -0,0 +1 @@
ALTER TABLE warehouse_loach.user ADD UNIQUE KEY user_pk (user_login);

View File

@@ -0,0 +1 @@
ALTER TABLE warehouse_loach.account ADD COLUMN account_email VARCHAR(255);

View File

@@ -0,0 +1,20 @@
-- =============================================================================
-- ai_rag_collection
--
-- A named RAG knowledge base. Each collection is a logical grouping of
-- text chunks + their embeddings. The Nibiru AI module's `Rag` plugin
-- reads / writes this table via the auto-generated model in
-- application/model/ai_rag_collection.php.
-- =============================================================================
CREATE TABLE IF NOT EXISTS ai_rag_collection (
ai_rag_collection_id INT(11) NOT NULL AUTO_INCREMENT,
ai_rag_collection_name VARCHAR(64) NOT NULL,
ai_rag_collection_embed_model VARCHAR(128) NOT NULL,
ai_rag_collection_embed_dim INT(11) NOT NULL,
ai_rag_collection_chunk_count INT(11) NOT NULL DEFAULT 0,
ai_rag_collection_created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
ai_rag_collection_updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (ai_rag_collection_id),
UNIQUE KEY ai_rag_collection_name_uk (ai_rag_collection_name)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;

View File

@@ -0,0 +1,28 @@
-- =============================================================================
-- ai_rag_chunk
--
-- One row per text chunk in a RAG collection. The embedding column stores
-- the vector as a base64-packed Float32Array (4 bytes/dim). Cosine search
-- is done in PHP after fetching all chunks for the collection — fine up
-- to ~10k chunks per collection. For larger sets, drop in a vector index
-- extension (pgvector, MySQL HeatWave LakeHouse vector) and update
-- Rag::search() accordingly.
-- =============================================================================
CREATE TABLE IF NOT EXISTS ai_rag_chunk (
ai_rag_chunk_id INT(11) NOT NULL AUTO_INCREMENT,
ai_rag_chunk_collection_id INT(11) NOT NULL,
ai_rag_chunk_text MEDIUMTEXT NOT NULL,
ai_rag_chunk_metadata JSON NULL,
ai_rag_chunk_embedding LONGTEXT NOT NULL, -- base64-packed Float32Array
ai_rag_chunk_token_count INT(11) NOT NULL DEFAULT 0,
ai_rag_chunk_source VARCHAR(512) NULL, -- denormalised from metadata for indexing
ai_rag_chunk_created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (ai_rag_chunk_id),
KEY ai_rag_chunk_collection_idx (ai_rag_chunk_collection_id),
KEY ai_rag_chunk_source_idx (ai_rag_chunk_source),
CONSTRAINT ai_rag_chunk_collection_fk
FOREIGN KEY (ai_rag_chunk_collection_id)
REFERENCES ai_rag_collection (ai_rag_collection_id)
ON DELETE CASCADE
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;

View File

@@ -0,0 +1,18 @@
-- =============================================================================
-- ai_conversation
--
-- A persistent chat conversation. Lets you build apps where the user's
-- chat history with the AI module survives page reloads / sessions.
-- Optional — Chat plugin is happy in-memory if you don't need persistence.
-- =============================================================================
CREATE TABLE IF NOT EXISTS ai_conversation (
ai_conversation_id INT(11) NOT NULL AUTO_INCREMENT,
ai_conversation_user_id INT(11) NULL, -- FK user.user_id, nullable for anonymous
ai_conversation_title VARCHAR(255) NULL,
ai_conversation_model VARCHAR(128) NOT NULL,
ai_conversation_created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
ai_conversation_updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (ai_conversation_id),
KEY ai_conversation_user_idx (ai_conversation_user_id)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;

View File

@@ -0,0 +1,23 @@
-- =============================================================================
-- ai_message
--
-- One row per turn in an ai_conversation. Role is one of: system, user,
-- assistant, tool. token_count is best-effort (filled in by the plugin
-- when the model returns usage info; 0 otherwise).
-- =============================================================================
CREATE TABLE IF NOT EXISTS ai_message (
ai_message_id INT(11) NOT NULL AUTO_INCREMENT,
ai_message_conversation_id INT(11) NOT NULL,
ai_message_role ENUM('system','user','assistant','tool') NOT NULL,
ai_message_content MEDIUMTEXT NOT NULL,
ai_message_tool_name VARCHAR(64) NULL,
ai_message_token_count INT(11) NOT NULL DEFAULT 0,
ai_message_created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (ai_message_id),
KEY ai_message_conversation_idx (ai_message_conversation_id),
CONSTRAINT ai_message_conversation_fk
FOREIGN KEY (ai_message_conversation_id)
REFERENCES ai_conversation (ai_conversation_id)
ON DELETE CASCADE
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;

View File

@@ -11,8 +11,11 @@ caching = true
[AUTOLOADER]
iface.pos[] = "users"
iface.pos[] = "ai"
trait.pos[] = "users"
trait.pos[] = "ai"
class.pos[] = "users"
class.pos[] = "ai"
class.plugin.pos[] = ""
[EMAIL]

View File

@@ -0,0 +1,68 @@
; =====================================================================
; Main application settings — production environment.
;
; Copy to settings.production.ini on the production host and fill in
; real values. settings.production.ini SHOULD be gitignored — add it
; to .gitignore before deploying.
;
; Mirror the structure of settings.development.ini and override only
; the values that differ in production.
; =====================================================================
[ENGINE]
cache = "/../../application/view/cache/"
templates = "/../../application/view/templates/"
templates_c = "/../../application/view/templates_c/"
config_dir = "/../../application/view/configs/"
debug_template = "/../../application/view/templates/shared/debug.tpl"
error_template = "/../../application/view/templates/shared/error.tpl"
error_controller = "error"
debugbar = false ; OFF in production
caching = true
[AUTOLOADER]
iface.pos[] = "users"
iface.pos[] = "ai"
trait.pos[] = "users"
trait.pos[] = "ai"
class.pos[] = "users"
class.pos[] = "ai"
class.plugin.pos[] = ""
[SETTINGS]
pageurl = "https://your-app.example.com"
navigation = "/../../application/settings/config/navigation.json"
modulespath = "/../../application/module/"
entriesperpage = 25
timezone = "Europe/Vienna"
smarty.css[] = "/public/css/app.min.css"
smarty.js[] = "/public/js/app.min.js"
[DATABASE]
driver = "pdo"
hostname = "your-prod-db-host"
port = 3306
username = "REPLACE_ME"
password = "REPLACE_ME"
basename = "your_prod_db_name"
encoding = "utf8mb4"
is.active = true
[GENERATOR]
; In production: don't regenerate models on every request. Generate once
; locally, commit the resulting application/model/*.php files, ship.
database = false
database.overwrite = false
[SECURITY]
password_hash = "REPLACE_WITH_A_LONG_RANDOM_SALT"
[EMAIL]
register.smtp = 1
register.smtp[host] = "smtp.your-host.example"
register.smtp[port] = "587"
register.smtp[username] = "REPLACE_ME"
register.smtp[password] = "REPLACE_ME"
register.from = "no-reply@your-app.example.com"
register.sender = "Your App"
register.subject = "Welcome"