KI-Tasks

Erstellt: 2025-12-20 | Aktualisiert: 2025-12-20

Task-Management-System für Mensch-KI-Kollaboration.

Tool/tasks
Datenbankki_dev
Tabellentasks, task_assignments, task_results, task_comments

Web-UI (RESTful)

URLBeschreibung
/tasksTask-Liste mit Statistik und Filtern
/tasks/newNeuen Task erstellen
/tasks/{id}Task-Details anzeigen
/tasks/{id}/editTask bearbeiten

Dokumentation

ThemaBeschreibung
API-ReferenzREST-API Endpoints für Task-Management
CLI-BefehleKommandozeilen-Interface
Datenbank-SchemaTabellenstruktur und SQL
Hook-IntegrationAutomatische Task-Erstellung aus Prompts

Funktionen

Schnellstart

Task erstellen (API)

curl -X POST http://localhost/api/v1/tasks \
  -H "Content-Type: application/json" \
  -d '{"title": "Aufgabe", "type": "ai_task"}'

MCP-Tasks

# Tasks auflisten
tasks_list(status="pending")

# Task erstellen
tasks_create(title="Aufgabe", type="ai_task")

API-Referenz

Erstellt: 2025-12-20 | Aktualisiert: 2025-12-31

REST-API für das KI-Task-Management System.

Hinweis: Diese API ist die PHP Web-API, implementiert in Controller\Api\TaskController. Sie ist unabhängig vom MCP-Tasks Server (Python), der via Claude Code MCP-Protokoll angesprochen wird.
ImplementierungController\Api\TaskController
Base-URLhttps://dev.campus.systemische-tools.de/api/v1/tasks
FormatJSON
AuthentifizierungKeine (lokales Netzwerk)

Endpoints

Tasks

MethodeEndpointBeschreibung
GET/api/v1/tasksListe aller Tasks
GET/api/v1/tasks/{id}Task-Details
POST/api/v1/tasksTask erstellen
PUT/api/v1/tasks/{id}Task aktualisieren
DELETE/api/v1/tasks/{id}Task löschen
GET/api/v1/tasks/statisticsStatistiken

Zuweisungen & Ergebnisse

MethodeEndpointBeschreibung
POST/api/v1/tasks/{id}/assignTask zuweisen
PUT/api/v1/tasks/{id}/statusStatus ändern
GET/api/v1/tasks/{id}/resultsErgebnisse abrufen
POST/api/v1/tasks/{id}/resultsErgebnis speichern
POST/api/v1/tasks/{id}/executeKI-Ausführung

GET /api/v1/tasks

Listet alle Tasks mit optionalen Filtern.

Query-Parameter

ParameterTypBeschreibung
statusstringpending, in_progress, completed, failed, cancelled
typestringhuman_task, ai_task, mixed
searchstringSuche in Titel/Beschreibung
limitintMax. Anzahl (default: 50)
offsetintOffset für Paginierung

Beispiel

curl "https://dev.campus.systemische-tools.de/api/v1/tasks?status=pending&limit=10"

Response

{
  "success": true,
  "data": [
    {
      "id": 1,
      "uuid": "abc-123-...",
      "title": "Analyse durchführen",
      "type": "ai_task",
      "status": "pending",
      "created_by": "root",
      "created_at": "2025-12-20 10:00:00"
    }
  ],
  "meta": {
    "total": 42,
    "limit": 10,
    "offset": 0
  }
}

POST /api/v1/tasks

Erstellt einen neuen Task.

Request-Body

{
  "title": "Analyse durchführen",        // required
  "description": "Details...",           // optional
  "type": "ai_task",                     // optional: human_task, ai_task, mixed
  "created_by": "user",                  // optional
  "created_by_type": "human",            // optional: human, ai
  "due_date": "2025-12-31 23:59:59",    // optional
  "parent_task_id": 1,                   // optional
  "metadata": {"key": "value"}           // optional
}

Beispiel

curl -X POST https://dev.campus.systemische-tools.de/api/v1/tasks \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Daten analysieren",
    "type": "ai_task"
  }'

Response (201 Created)

{
  "success": true,
  "data": {
    "id": 2,
    "uuid": "def-456-...",
    "title": "Daten analysieren",
    "status": "pending",
    ...
  }
}

GET /api/v1/tasks/{id}

Gibt Task-Details inkl. Zuweisungen, Ergebnisse und Subtasks zurück.

Response

{
  "success": true,
  "data": {
    "task": { ... },
    "assignments": [ ... ],
    "results": [ ... ],
    "subtasks": [ ... ]
  }
}

POST /api/v1/tasks/{id}/assign

Weist einen Task einem Bearbeiter zu.

Request-Body

{
  "assignee": "ollama",                  // required
  "assignee_type": "ollama",             // required: human, ollama, claude, anthropic_api
  "model_name": "mistral",               // optional
  "assigned_by": "user",                 // optional
  "notes": "Bitte priorisieren"          // optional
}

PUT /api/v1/tasks/{id}/status

Ändert den Task-Status.

Request-Body

{
  "status": "in_progress",               // required
  "updated_by": "user",                  // optional
  "updated_by_type": "human"             // optional
}

Erlaubte Übergänge

VonNach
pendingin_progress, cancelled
in_progresscompleted, failed, cancelled
completed/failed/cancelled(keine)

POST /api/v1/tasks/{id}/execute

Führt einen Task mit KI aus.

Request-Body

{
  "executor_type": "ollama",             // optional: ollama, anthropic_api
  "model": "mistral",                    // optional
  "auto_complete": true,                 // optional: Task nach Erfolg abschließen
  "additional_context": "..."            // optional: Zusätzlicher Kontext
}

Response

{
  "success": true,
  "data": {
    "id": 1,
    "task_id": 2,
    "executor": "ollama",
    "model_name": "mistral",
    "response": "Die Analyse ergab...",
    "tokens_input": 150,
    "tokens_output": 420,
    "tokens_total": 570,
    "duration_ms": 12500,
    "status": "success"
  }
}

Error-Responses

// 400 Bad Request
{
  "success": false,
  "error": "Title is required"
}

// 404 Not Found
{
  "success": false,
  "error": "Task not found"
}

// 500 Internal Server Error
{
  "success": false,
  "error": "Database connection failed"
}

Vergleich: PHP API vs MCP-Tasks

AspektPHP Web-APIMCP-Tasks Server
ZugriffHTTP REST (curl, Browser)Claude Code MCP-Protokoll
ImplementierungPHP ControllerPython MCP Server
Pfad/api/v1/taskstasks_list(), tasks_create()
VerwendungWeb-Anwendungen, ScriptsClaude Code Sessions

Änderungshistorie

DatumÄnderung
2025-12-31Klarstellung: PHP Web-API vs MCP-Tasks Server, Host in Beispielen korrigiert
2025-12-20Initial erstellt

CLI-Befehle

Erstellt: 2025-12-20 | Aktualisiert: 2025-12-20

Kommandozeilen-Interface für das KI-Task-Management System.

Pfad/var/www/tools/ki-tasks/cli.php
Aufrufphp cli.php <command> [options]

Befehle

create

Erstellt einen neuen Task.

php cli.php create --title="Aufgabe" [options]

Optionen:
  --title="..."       Titel (required)
  --description="..." Beschreibung
  --type=...          human_task, ai_task, mixed (default: human_task)
  --created-by=...    Ersteller (default: $USER)

Beispiele

# Einfacher Task
php cli.php create --title="Code Review durchführen"

# KI-Task
php cli.php create --title="Analyse" --type=ai_task

# Task mit Beschreibung
php cli.php create \
  --title="Dokumentation aktualisieren" \
  --description="README.md mit neuen Features aktualisieren" \
  --type=human_task

list

Listet Tasks auf.

php cli.php list [options]

Optionen:
  --status=...   Filter nach Status
  --type=...     Filter nach Typ
  --limit=...    Max. Anzahl (default: 20)

Beispiele

# Alle Tasks
php cli.php list

# Nur offene Tasks
php cli.php list --status=pending

# KI-Tasks
php cli.php list --type=ai_task --limit=10

Ausgabe

ID    Titel                               Typ          Status       Erstellt
---------------------------------------------------------------------------------
1     Test-Task für KI-Analyse            ai_task      in_progress  2025-12-20 10:00
2     Code Review                         human_task   pending      2025-12-20 11:00

show

Zeigt Task-Details an.

php cli.php show <id>

Beispiel

php cli.php show 1

Task #1: Test-Task für KI-Analyse
============================================================
Status:      in_progress
Typ:         ai_task
Erstellt:    2025-12-20 10:00:00 von root

Beschreibung:
Dies ist ein Test-Task

Zuweisungen:
  - ollama (ollama) - completed

Ergebnisse:
  - ollama (mistral) - success - 686 tokens

assign

Weist einen Task zu.

php cli.php assign <id> --to=<name> --type=<type> [options]

Optionen:
  --to=...      Bearbeiter-Name (required)
  --type=...    human, ollama, claude, anthropic_api (required)
  --model=...   Model-Name (optional)

Beispiele

# An Ollama zuweisen
php cli.php assign 1 --to=ollama --type=ollama --model=mistral

# An Mensch zuweisen
php cli.php assign 2 --to=max --type=human

# An Anthropic API zuweisen
php cli.php assign 3 --to=anthropic --type=anthropic_api --model=claude-sonnet-4

execute

Führt einen Task mit KI aus.

php cli.php execute <id> [options]

Optionen:
  --executor=...      ollama, anthropic_api (default: ollama)
  --model=...         Model-Name (default: mistral)
  --auto-complete     Task nach Erfolg abschließen

Beispiele

# Mit Ollama (Mistral)
php cli.php execute 1 --executor=ollama --model=mistral

# Mit llama3.2
php cli.php execute 1 --model=llama3.2

# Mit Anthropic API
php cli.php execute 1 --executor=anthropic_api --model=claude-sonnet-4

# Mit Auto-Complete
php cli.php execute 1 --auto-complete

Ausgabe

ℹ Führe Task #1 mit ollama (mistral) aus...
✓ Erfolgreich ausgeführt!
Tokens: 686 | Dauer: 13043ms

Antwort:
----------------------------------------
Die Analyse ergab folgende Ergebnisse...

status

Ändert den Task-Status.

php cli.php status <id> <new_status>

Status-Werte:
  pending       Offen
  in_progress   In Arbeit
  completed     Abgeschlossen
  failed        Fehlgeschlagen
  cancelled     Abgebrochen

Beispiele

# Task starten
php cli.php status 1 in_progress

# Task abschließen
php cli.php status 1 completed

# Task abbrechen
php cli.php status 1 cancelled

complete

Schließt einen Task ab (Shortcut für status + result).

php cli.php complete <id> [options]

Optionen:
  --result="..."   Ergebnis-Text speichern

Beispiele

# Einfach abschließen
php cli.php complete 1

# Mit Ergebnis
php cli.php complete 1 --result="Alle Tests bestanden"

delete

Löscht einen Task.

php cli.php delete <id>

stats

Zeigt Statistiken an.

php cli.php stats

Ausgabe

Task-Statistiken
========================================
Gesamt:        42
Offen:         15
In Arbeit:     5
Abgeschlossen: 20
Fehlgeschlagen:1
Abgebrochen:   1

Nach Typ:
  Mensch:      10
  KI:          30
  Gemischt:    2

Token-Statistiken
========================================
Ergebnisse:    25
Tokens gesamt: 15420
Kosten (USD):  0.0350
Avg. Dauer:    8500ms

help

Zeigt die Hilfe an.

php cli.php help

Exit-Codes

CodeBedeutung
0Erfolgreich
1Fehler (z.B. Task nicht gefunden, ungültige Parameter)

Umgebungsvariablen

VariableVerwendung
$USERStandard-Wert für created_by und updated_by

Datenbank-Schema

Erstellt: 2025-12-20 | Aktualisiert: 2025-12-31

Tabellenstruktur des KI-Task-Management Systems in der Datenbank ki_dev.

Datenbankki_dev
Tabellen4 (tasks, task_assignments, task_results, task_comments)
EngineInnoDB
Charsetutf8mb4_unicode_ci

tasks

Haupttabelle für alle Tasks.

SpalteTypBeschreibung
idBIGINT UNSIGNEDPrimary Key, Auto-Increment
uuidVARCHAR(36)Unique Identifier
titleVARCHAR(255)Titel des Tasks
descriptionTEXTBeschreibung
typeENUM'human_task', 'ai_task', 'mixed'
statusENUM'pending', 'in_progress', 'completed', 'failed', 'cancelled'
created_byVARCHAR(100)Ersteller
created_by_typeENUM'human', 'ai'
parent_task_idBIGINT UNSIGNEDFK zu übergeordnetem Task
due_dateDATETIMEFälligkeitsdatum
created_atDATETIME(6)Erstellungszeitpunkt
updated_atDATETIME(6)Letzte Änderung
completed_atDATETIME(6)Abschlusszeitpunkt
metadataJSONZusätzliche Daten

Indizes

PRIMARY KEY (id)
UNIQUE KEY uk_uuid (uuid)
KEY idx_status (status)
KEY idx_created_by (created_by)
KEY idx_type (type)
KEY idx_parent_task (parent_task_id)
KEY idx_created_at (created_at)
KEY idx_status_created (status, created_at)

task_assignments

Zuweisungen von Tasks an Bearbeiter.

SpalteTypBeschreibung
idBIGINT UNSIGNEDPrimary Key
task_idBIGINT UNSIGNEDFK zu tasks
assigneeVARCHAR(100)Bearbeiter-Name
assignee_typeENUM'human', 'ollama', 'claude', 'anthropic_api'
model_nameVARCHAR(100)KI-Model (z.B. mistral)
assigned_byVARCHAR(100)Zuweisender
assigned_by_typeENUM'human', 'ai'
statusENUM'pending', 'accepted', 'rejected', 'in_progress', 'completed'
assigned_atDATETIME(6)Zuweisungszeitpunkt
accepted_atDATETIME(6)Annahmezeitpunkt
completed_atDATETIME(6)Abschlusszeitpunkt
notesTEXTAnmerkungen zur Zuweisung

task_results

Ergebnisse von Task-Ausführungen mit Token-Tracking.

SpalteTypBeschreibung
idBIGINT UNSIGNEDPrimary Key
task_idBIGINT UNSIGNEDFK zu tasks
assignment_idBIGINT UNSIGNEDFK zu task_assignments
executorVARCHAR(100)Ausführender
executor_typeENUM'human', 'ollama', 'claude', 'anthropic_api'
model_nameVARCHAR(100)Verwendetes KI-Model
requestTEXTAnfrage/Prompt
responseLONGTEXTAntwort/Ergebnis
request_timestampDATETIME(6)Anfragezeitpunkt
response_timestampDATETIME(6)Antwortzeitpunkt
duration_msINT UNSIGNEDDauer in Millisekunden
tokens_inputINT UNSIGNEDInput-Tokens
tokens_outputINT UNSIGNEDOutput-Tokens
tokens_totalINT UNSIGNEDGesamt-Tokens
cost_usdDECIMAL(10,6)Kosten in USD
statusENUM'success', 'error', 'partial'
error_messageTEXTFehlermeldung bei Fehler
created_atDATETIME(6)Erstellungszeitpunkt

task_comments

Kommentare und Protokoll-Einträge zu Tasks.

SpalteTypBeschreibung
idBIGINT UNSIGNEDPrimary Key
task_idBIGINT UNSIGNEDFK zu tasks
authorVARCHAR(100)Autor
author_typeENUM'human', 'ai', 'system'
comment_typeENUM'comment', 'status_change', 'assignment', 'result', 'note'
contentTEXTInhalt
metadataJSONZusätzliche Daten
created_atDATETIME(6)Erstellungszeitpunkt

Abfragen

Letzte 10 Tasks

SELECT id, title, status, created_at
FROM tasks
ORDER BY id DESC
LIMIT 10;

Tasks nach Status

SELECT status, COUNT(*) as count
FROM tasks
GROUP BY status;

Token-Verbrauch pro Model

SELECT model_name,
       SUM(tokens_total) as total_tokens,
       SUM(cost_usd) as total_cost,
       COUNT(*) as executions
FROM task_results
WHERE model_name IS NOT NULL
GROUP BY model_name
ORDER BY total_tokens DESC;

Änderungshistorie

DatumÄnderung
2025-12-31Fehlende Felder ergänzt: task_assignments (assigned_at, accepted_at, completed_at, notes), task_results (10 Felder), task_comments (metadata, created_at)
2025-12-20Initial erstellt

Hook-Integration

Erstellt: 2025-12-20 | Aktualisiert: 2025-12-31

Automatische Task-Erstellung aus Claude Code Prompts via Hook-System.

Status: Der task_hook.py ist derzeit nicht aktiv. Er ist nicht in der Hook-Konfiguration registriert. Diese Dokumentation beschreibt die geplante Funktionalität.
Hook-Script/var/www/tools/ki-protokoll/claude-hook/task_hook.py
TriggerUserPromptSubmit (nicht aktiv)
StatusNicht aktiviert

Erkannte Patterns (geplant)

Bei Aktivierung würde der Hook folgende Patterns in User-Prompts erkennen und automatisch Tasks erstellen:

PatternBeispielTask-Titel
TODO: <text>TODO: Tests schreibenTests schreiben
TASK: <text>TASK: API dokumentierenAPI dokumentieren
@task <text>@task RefactoringRefactoring
#task <text>#task Bug fixenBug fixen

Funktionsweise (bei Aktivierung)

User-Prompt: "Bitte TODO: Logging implementieren und den Code reviewen"
                    ↓
            Hook erkennt Pattern
                    ↓
        Task erstellt: "Logging implementieren"
                    ↓
            type: ai_task
            status: pending
            created_by: $USER
            created_by_type: ai

Aktivierung

Um den Hook zu aktivieren, muss er in der Hook-Konfiguration registriert werden:

Datei: /root/.claude/settings.json oder .claude/settings.local.json

{
  "hooks": {
    "UserPromptSubmit": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "/var/www/tools/ki-protokoll/claude-hook/log_to_db.py",
            "timeout": 5
          },
          {
            "type": "command",
            "command": "/var/www/tools/ki-protokoll/claude-hook/task_hook.py",
            "timeout": 5
          }
        ]
      }
    ]
  }
}

Aktive Hooks (aktueller Stand)

Derzeit sind folgende Hooks für UserPromptSubmit aktiv:

HookFunktion
log_to_db.pyProtokolliert Prompts in Datenbank

Hook-Script

Konfiguration

# Datenbankverbindung - verwendet Umgebungsvariablen
DB_CONFIG = {
    'host': os.environ.get('CLAUDE_DB_HOST', 'localhost'),
    'port': int(os.environ.get('CLAUDE_DB_PORT', '3306')),
    'user': os.environ.get('CLAUDE_DB_USER', 'claude_code'),
    'password': os.environ.get('CLAUDE_DB_PASSWORD'),
    'database': os.environ.get('CLAUDE_DB_NAME', 'ki_dev'),
    'charset': 'utf8mb4'
}

# Erkennungsmuster
TASK_PATTERNS = [
    (r'TODO:\s*(.+?)(?:\n|$)', 'todo'),
    (r'TASK:\s*(.+?)(?:\n|$)', 'task'),
    (r'@task\s+(.+?)(?:\n|$)', 'mention'),
    (r'#task\s+(.+?)(?:\n|$)', 'hashtag'),
]

Erstellte Task-Eigenschaften

EigenschaftWert
typeai_task
statuspending
created_by$USER oder 'claude-code-hook'
created_by_typeai

Installation (falls gewünscht)

1. Hook ausführbar machen

chmod +x /var/www/tools/ki-protokoll/claude-hook/task_hook.py

2. Python-Abhängigkeiten

pip3 install pymysql

3. Hook in settings.json registrieren

# Füge den task_hook.py zu den UserPromptSubmit Hooks hinzu (siehe oben)

4. Testen

# In Claude Code eingeben:
"TODO: Test-Task erstellen"

# Prüfen ob Task erstellt wurde

Fehlerbehandlung

Der Hook ist non-blocking. Fehler werden zu stderr geloggt, aber der Claude Code Workflow wird nicht unterbrochen.

# Immer zurückgegeben:
{"continue": true}

Debugging

# Hook manuell testen
echo '{"hook_event_name":"UserPromptSubmit","prompt":"TODO: Test"}' | python3 /var/www/tools/ki-protokoll/claude-hook/task_hook.py

# Logs prüfen (stderr)
# Task #123 created: Test...

Zusammenspiel mit anderen Hooks

HookFunktionEventStatus
log_to_db.pyProtokolliert alle EventsAlleAktiv
block_direct_db.pyBlockiert mysql/mariadb CLIPreToolUse:BashAktiv
file_backup_hook.pyBackup vor DateiänderungenPreToolUse:Edit|WriteAktiv
task_hook.pyTasks aus Prompts erstellenUserPromptSubmitNicht aktiv

Änderungshistorie

DatumÄnderung
2025-12-31Klarstellung: Hook ist nicht aktiv, Aktivierungsanleitung hinzugefügt
2025-12-20Initial erstellt