konfetti-spider 1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- konfetti_spider-1.2/LICENSE +21 -0
- konfetti_spider-1.2/PKG-INFO +234 -0
- konfetti_spider-1.2/README.md +208 -0
- konfetti_spider-1.2/__init__.py +2 -0
- konfetti_spider-1.2/config.py +94 -0
- konfetti_spider-1.2/db/__init__.py +2 -0
- konfetti_spider-1.2/db/database.py +396 -0
- konfetti_spider-1.2/db/models.py +160 -0
- konfetti_spider-1.2/db/seed.py +392 -0
- konfetti_spider-1.2/init.py +267 -0
- konfetti_spider-1.2/konfetti_spider.egg-info/PKG-INFO +234 -0
- konfetti_spider-1.2/konfetti_spider.egg-info/SOURCES.txt +61 -0
- konfetti_spider-1.2/konfetti_spider.egg-info/dependency_links.txt +1 -0
- konfetti_spider-1.2/konfetti_spider.egg-info/entry_points.txt +2 -0
- konfetti_spider-1.2/konfetti_spider.egg-info/requires.txt +11 -0
- konfetti_spider-1.2/konfetti_spider.egg-info/top_level.txt +1 -0
- konfetti_spider-1.2/launch.py +54 -0
- konfetti_spider-1.2/mcp_server.py +150 -0
- konfetti_spider-1.2/pyproject.toml +58 -0
- konfetti_spider-1.2/server/__init__.py +2 -0
- konfetti_spider-1.2/server/api.py +316 -0
- konfetti_spider-1.2/server/main.py +52 -0
- konfetti_spider-1.2/server/schemas.py +150 -0
- konfetti_spider-1.2/setup.cfg +4 -0
- konfetti_spider-1.2/templates/AGENTS.md +236 -0
- konfetti_spider-1.2/templates/commands/spider-execute.md +31 -0
- konfetti_spider-1.2/templates/commands/spider-plan.md +28 -0
- konfetti_spider-1.2/templates/work_agent.md +27 -0
- konfetti_spider-1.2/test_poc.py +117 -0
- konfetti_spider-1.2/tests/test_api.py +88 -0
- konfetti_spider-1.2/tests/test_db.py +134 -0
- konfetti_spider-1.2/tools/__init__.py +2 -0
- konfetti_spider-1.2/tools/agent_tools.py +377 -0
- konfetti_spider-1.2/tools/local_tools.py +266 -0
- konfetti_spider-1.2/tools/tool_schemas.py +340 -0
- konfetti_spider-1.2/visualization/__init__.py +2 -0
- konfetti_spider-1.2/visualization/serve.py +83 -0
- konfetti_spider-1.2/visualization/tree.html +547 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 David Natzkin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: konfetti-spider
|
|
3
|
+
Version: 1.2
|
|
4
|
+
Summary: POC-Framework zur Nachvollziehbarkeit von AI-Agent-Entscheidungen (Planungsbaum + Audit-Log).
|
|
5
|
+
Author-email: David Natzkin <david.natzkin+spider@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/KonFetti11/spider
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: fastapi>=0.110.0
|
|
17
|
+
Requires-Dist: uvicorn[standard]>=0.29.0
|
|
18
|
+
Requires-Dist: pydantic>=2.0.0
|
|
19
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
20
|
+
Provides-Extra: mcp
|
|
21
|
+
Requires-Dist: mcp>=1.2.0; extra == "mcp"
|
|
22
|
+
Provides-Extra: test
|
|
23
|
+
Requires-Dist: pytest>=8.0; extra == "test"
|
|
24
|
+
Requires-Dist: httpx>=0.27; extra == "test"
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
# 🕷 Spider – AI Traceability Framework
|
|
28
|
+
|
|
29
|
+
**POC-Framework zur Nachvollziehbarkeit von AI-Agent-Entscheidungen.**
|
|
30
|
+
|
|
31
|
+
Spider zwingt Coding-Agents dazu, jeden Entscheidungsschritt als Knoten in einem
|
|
32
|
+
persistenten Baumgraphen zu dokumentieren. Das Ergebnis ist ein vollständig
|
|
33
|
+
nachvollziehbarer Planungsbaum, der für menschliche Reviewer transparent und
|
|
34
|
+
interaktiv visualisierbar ist.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Kernkonzept
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
Root-Knoten (reifegrad = 0.0 → 1.0)
|
|
42
|
+
├── Planungsbereich A
|
|
43
|
+
│ ├── ✓ Option 1 (akzeptiert) → reifegrad = 1.0
|
|
44
|
+
│ └── ✗ Option 2 (abgelehnt) → reifegrad = 1.0
|
|
45
|
+
└── Planungsbereich B
|
|
46
|
+
└── ? Option X (offen) → reifegrad = 0.0
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- **reifegrad = 1.0** am Root = Alle Entscheidungen getroffen → Planungsphase abgeschlossen
|
|
50
|
+
- Jede Entscheidung (accept/reject) wird mit Begründung dokumentiert
|
|
51
|
+
- Alle Änderungen erzeugen automatisch einen unveränderlichen **Audit-Log (Actions)**
|
|
52
|
+
- Optional lässt sich an jedem Knoten die zugehörige Aufgabenstellung verlinken
|
|
53
|
+
(`taskRef` – Pfad/Link) oder direkt einbetten (`taskMarkdown` – Markdown-Inhalt)
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Schnellstart
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# 1. Installieren (editable, inkl. optionalem MCP-Server)
|
|
61
|
+
pip install -e ".[mcp]"
|
|
62
|
+
|
|
63
|
+
# 2. Demo-Daten laden (in ./.spider/spider.db)
|
|
64
|
+
python -m spider.db.seed
|
|
65
|
+
|
|
66
|
+
# 3. Visualisierung starten (wählt freien Port, gibt die URL aus)
|
|
67
|
+
python -m spider.launch
|
|
68
|
+
|
|
69
|
+
# Optional: HTTP-API – nur für Netzwerk-/Remote-Zugriff (Port 8765, Docs unter /docs)
|
|
70
|
+
python -m spider.server.main
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
> Für die Einbindung in **eigene** Projekte nicht den obigen Demo-Flow nutzen, sondern
|
|
74
|
+
> `spider-init` – siehe [Einbindung in ein neues Projekt](#einbindung-in-ein-neues-projekt).
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Projektstruktur
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
spider/
|
|
82
|
+
├── db/
|
|
83
|
+
│ ├── models.py # Dataclasses: Node, Action
|
|
84
|
+
│ ├── database.py # SQLite CRUD + reifegrad/confidence-Berechnung
|
|
85
|
+
│ └── seed.py # Demo-Testdaten
|
|
86
|
+
├── server/
|
|
87
|
+
│ ├── schemas.py # Pydantic Request/Response-Modelle
|
|
88
|
+
│ ├── api.py # FastAPI REST-Endpunkte
|
|
89
|
+
│ └── main.py # Uvicorn-Einstiegspunkt (Port 8765)
|
|
90
|
+
├── tools/
|
|
91
|
+
│ ├── agent_tools.py # SpiderTools-Klasse für AI-Agents
|
|
92
|
+
│ └── tool_schemas.py# JSON-Schemas für function-calling
|
|
93
|
+
├── visualization/
|
|
94
|
+
│ ├── serve.py # Visualisierungsserver (Port 8766)
|
|
95
|
+
│ └── tree.html # Interaktiver D3.js-Baum
|
|
96
|
+
├── templates/
|
|
97
|
+
│ └── AGENTS.md # Nutzungsvorlage für Zielprojekte
|
|
98
|
+
├── data/
|
|
99
|
+
│ └── spider.db # SQLite-Datenbank (auto-erstellt)
|
|
100
|
+
├── AGENTS.md # Bauanleitung für Coding-Agents
|
|
101
|
+
└── .env.example # Konfigurationsvorlage
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## API-Endpunkte
|
|
107
|
+
|
|
108
|
+
| Method | Endpunkt | Beschreibung |
|
|
109
|
+
|--------|---------------------------|--------------------------------------|
|
|
110
|
+
| GET | `/nodes` | Alle Nodes (flach) |
|
|
111
|
+
| GET | `/nodes/{id}` | Einzelner Node |
|
|
112
|
+
| GET | `/nodes/{id}/children` | Direktkinder eines Nodes |
|
|
113
|
+
| POST | `/nodes` | Neuen Node erstellen |
|
|
114
|
+
| PATCH | `/nodes/{id}` | Node aktualisieren |
|
|
115
|
+
| POST | `/nodes/{id}/reject` | Node ablehnen |
|
|
116
|
+
| POST | `/nodes/{id}/accept` | Node akzeptieren |
|
|
117
|
+
| GET | `/tree` | Kompletter Baum (flach) |
|
|
118
|
+
| GET | `/tree/nested` | Baum verschachtelt |
|
|
119
|
+
| GET | `/tree/stats` | Fortschrittsstatistiken |
|
|
120
|
+
| GET | `/actions` | Alle Audit-Log-Einträge |
|
|
121
|
+
| POST | `/actions` | Manuellen Audit-Eintrag erstellen |
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Einbindung in ein neues Projekt
|
|
126
|
+
|
|
127
|
+
### Schritt 1: Spider einmalig installieren
|
|
128
|
+
```bash
|
|
129
|
+
# Lokal (Entwicklung), aus dem Spider-Repo – inkl. MCP-Server:
|
|
130
|
+
pip install -e ".[mcp]"
|
|
131
|
+
|
|
132
|
+
# Später, nach GitHub-Publish:
|
|
133
|
+
pip install "spider[mcp] @ git+https://github.com/<user>/spider.git"
|
|
134
|
+
```
|
|
135
|
+
Installiere in das Python, das deine Projekte nutzen (System-Python, oder das venv des Projekts).
|
|
136
|
+
`[mcp]` ist optional – nur für den nativen MCP-Server nötig.
|
|
137
|
+
|
|
138
|
+
### Schritt 2: Projekt initialisieren
|
|
139
|
+
Ein Befehl macht ein beliebiges Projekt Spider-fähig:
|
|
140
|
+
```bash
|
|
141
|
+
spider-init /pfad/zum/projekt # oder: python -m spider.init /pfad/zum/projekt
|
|
142
|
+
```
|
|
143
|
+
Das legt im Zielprojekt an:
|
|
144
|
+
- `.spider/.env` – zentrale Konfiguration (`SPIDER_DB_PATH`, optional `SPIDER_BASE_URL`),
|
|
145
|
+
- `.spider/spider.db` – die projekteigene Datenbank (lazy, isoliert pro Projekt),
|
|
146
|
+
- `.spider/work_agent.md` – System-Prompt für read-only Subagents,
|
|
147
|
+
- `AGENTS.md` – Agent-Anweisungen (neu) bzw. ein angehängter, markierter Block,
|
|
148
|
+
- `spider_tools.py` – Tool-Shim (exportiert `spider` und read-only `spider_ro`),
|
|
149
|
+
- `.mcp.json` – MCP-Server-Konfiguration für Claude Code & Co.,
|
|
150
|
+
- `.claude/commands/spider-plan.md` + `spider-execute.md` – Slash-Commands,
|
|
151
|
+
- `spider-viz.ps1` / `spider-viz.sh` – Start-Helper für die Visualisierung.
|
|
152
|
+
|
|
153
|
+
### Schritt 3: Tools nutzen
|
|
154
|
+
|
|
155
|
+
**a) Native MCP-Tools (empfohlen, z.B. Claude Code):** Beim Öffnen des Projekts findet der Client
|
|
156
|
+
`.mcp.json` und startet `python -m spider.mcp_server` (Direkt-DB, kein Server). Verfügbare Tools:
|
|
157
|
+
`spider_create_node`, `spider_get_tree`, `spider_get_tree_stats`, `spider_accept_node`,
|
|
158
|
+
`spider_reject_node`, `spider_update_node`, `spider_add_action`, `spider_get_node`,
|
|
159
|
+
`spider_get_children`, `spider_get_actions`. (Projekt-MCP-Server einmalig bestätigen.)
|
|
160
|
+
|
|
161
|
+
**b) Per Python (kein Server nötig):**
|
|
162
|
+
```python
|
|
163
|
+
from spider_tools import spider # voller Zugriff
|
|
164
|
+
spider.get_tree_stats()
|
|
165
|
+
from spider_tools import spider_ro # read-only (für Subagents; Schreib-Methoden werfen)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**Netzwerk-/Remote-Zugriff** (z.B. Claude Code vom Handy): in `.spider/.env`
|
|
169
|
+
`SPIDER_BASE_URL=http://<host>:8765` setzen und `python -m spider.server.main` starten –
|
|
170
|
+
Shim/MCP nutzen dann HTTP, gleiche DB darunter, keine Migration.
|
|
171
|
+
|
|
172
|
+
### Schritt 4: Zwei-Phasen-Workflow (Slash-Commands)
|
|
173
|
+
- **`/spider-plan`** – Planungsphase: baut den Entscheidungsbaum auf, bis `root.reifegrad == 1.0`.
|
|
174
|
+
- **`/spider-execute`** – Ausführungsphase: Orchestrator mit exklusivem Schreibzugriff startet
|
|
175
|
+
read-only Subagents (siehe `.spider/work_agent.md`), die Ergebnisse zurückmelden; nur der
|
|
176
|
+
Orchestrator schreibt sie nach Spider.
|
|
177
|
+
|
|
178
|
+
### Schritt 5: Visualisierung öffnen
|
|
179
|
+
```bash
|
|
180
|
+
./spider-viz.ps1 # Windows (bzw. ./spider-viz.sh unter Linux/macOS)
|
|
181
|
+
# wählt automatisch einen freien Port und gibt die URL aus
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Bestehendes Projekt upgraden
|
|
185
|
+
Nach einem Spider-Update die generierten Dateien im Projekt aktualisieren – Nutzerdaten
|
|
186
|
+
(`.spider/.env`, `.spider/spider.db`) bleiben unangetastet:
|
|
187
|
+
```bash
|
|
188
|
+
spider-init /pfad/zum/projekt --force
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## reifegrad-Logik
|
|
194
|
+
|
|
195
|
+
| Knotentyp | reifegrad |
|
|
196
|
+
|------------------------------------|-----------|
|
|
197
|
+
| Blattknoten, akzeptiert | 1.0 |
|
|
198
|
+
| Blattknoten, abgelehnt | 1.0 |
|
|
199
|
+
| Blattknoten, offen | 0.0 |
|
|
200
|
+
| Interner Knoten | Ø(Children)|
|
|
201
|
+
| Root (Ziel) | **1.0** |
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Konfiguration (`.spider/.env`)
|
|
206
|
+
|
|
207
|
+
Pro Projekt liegt die Konfiguration in `.spider/.env` (von `spider-init` erzeugt, autoritativ
|
|
208
|
+
geladen via `spider/config.py`). Ein relativer `SPIDER_DB_PATH` wird relativ zur Projektwurzel
|
|
209
|
+
aufgelöst.
|
|
210
|
+
|
|
211
|
+
```env
|
|
212
|
+
SPIDER_DB_PATH=.spider/spider.db
|
|
213
|
+
# Optionaler Netzwerk-/Remote-Zugriff (Shim/MCP schalten dann auf HTTP):
|
|
214
|
+
# SPIDER_BASE_URL=http://127.0.0.1:8765
|
|
215
|
+
# Optionale feste Ports (sonst wählt der Viz-Start einen freien Port):
|
|
216
|
+
# SPIDER_HOST=127.0.0.1
|
|
217
|
+
# SPIDER_PORT=8765
|
|
218
|
+
# SPIDER_VIZ_HOST=127.0.0.1
|
|
219
|
+
# SPIDER_VIZ_PORT=8766
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## POC-Status & Nächste Schritte
|
|
225
|
+
|
|
226
|
+
Dieser POC validiert das Grundkonzept. Bei Erfolg geplant:
|
|
227
|
+
|
|
228
|
+
- [ ] Rückwirkende Integration für laufende Projekte
|
|
229
|
+
- [ ] API-Key-Authentifizierung für Multi-Agent-Setups
|
|
230
|
+
- [ ] PostgreSQL-Migration für Produktion
|
|
231
|
+
- [ ] PDF/Markdown-Export des Entscheidungsbaums
|
|
232
|
+
- [ ] Webhook-Benachrichtigungen bei Reifegrad-Schwellwerten
|
|
233
|
+
- [ ] pip-Package-Veröffentlichung
|
|
234
|
+
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# 🕷 Spider – AI Traceability Framework
|
|
2
|
+
|
|
3
|
+
**POC-Framework zur Nachvollziehbarkeit von AI-Agent-Entscheidungen.**
|
|
4
|
+
|
|
5
|
+
Spider zwingt Coding-Agents dazu, jeden Entscheidungsschritt als Knoten in einem
|
|
6
|
+
persistenten Baumgraphen zu dokumentieren. Das Ergebnis ist ein vollständig
|
|
7
|
+
nachvollziehbarer Planungsbaum, der für menschliche Reviewer transparent und
|
|
8
|
+
interaktiv visualisierbar ist.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Kernkonzept
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
Root-Knoten (reifegrad = 0.0 → 1.0)
|
|
16
|
+
├── Planungsbereich A
|
|
17
|
+
│ ├── ✓ Option 1 (akzeptiert) → reifegrad = 1.0
|
|
18
|
+
│ └── ✗ Option 2 (abgelehnt) → reifegrad = 1.0
|
|
19
|
+
└── Planungsbereich B
|
|
20
|
+
└── ? Option X (offen) → reifegrad = 0.0
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
- **reifegrad = 1.0** am Root = Alle Entscheidungen getroffen → Planungsphase abgeschlossen
|
|
24
|
+
- Jede Entscheidung (accept/reject) wird mit Begründung dokumentiert
|
|
25
|
+
- Alle Änderungen erzeugen automatisch einen unveränderlichen **Audit-Log (Actions)**
|
|
26
|
+
- Optional lässt sich an jedem Knoten die zugehörige Aufgabenstellung verlinken
|
|
27
|
+
(`taskRef` – Pfad/Link) oder direkt einbetten (`taskMarkdown` – Markdown-Inhalt)
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Schnellstart
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# 1. Installieren (editable, inkl. optionalem MCP-Server)
|
|
35
|
+
pip install -e ".[mcp]"
|
|
36
|
+
|
|
37
|
+
# 2. Demo-Daten laden (in ./.spider/spider.db)
|
|
38
|
+
python -m spider.db.seed
|
|
39
|
+
|
|
40
|
+
# 3. Visualisierung starten (wählt freien Port, gibt die URL aus)
|
|
41
|
+
python -m spider.launch
|
|
42
|
+
|
|
43
|
+
# Optional: HTTP-API – nur für Netzwerk-/Remote-Zugriff (Port 8765, Docs unter /docs)
|
|
44
|
+
python -m spider.server.main
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
> Für die Einbindung in **eigene** Projekte nicht den obigen Demo-Flow nutzen, sondern
|
|
48
|
+
> `spider-init` – siehe [Einbindung in ein neues Projekt](#einbindung-in-ein-neues-projekt).
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Projektstruktur
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
spider/
|
|
56
|
+
├── db/
|
|
57
|
+
│ ├── models.py # Dataclasses: Node, Action
|
|
58
|
+
│ ├── database.py # SQLite CRUD + reifegrad/confidence-Berechnung
|
|
59
|
+
│ └── seed.py # Demo-Testdaten
|
|
60
|
+
├── server/
|
|
61
|
+
│ ├── schemas.py # Pydantic Request/Response-Modelle
|
|
62
|
+
│ ├── api.py # FastAPI REST-Endpunkte
|
|
63
|
+
│ └── main.py # Uvicorn-Einstiegspunkt (Port 8765)
|
|
64
|
+
├── tools/
|
|
65
|
+
│ ├── agent_tools.py # SpiderTools-Klasse für AI-Agents
|
|
66
|
+
│ └── tool_schemas.py# JSON-Schemas für function-calling
|
|
67
|
+
├── visualization/
|
|
68
|
+
│ ├── serve.py # Visualisierungsserver (Port 8766)
|
|
69
|
+
│ └── tree.html # Interaktiver D3.js-Baum
|
|
70
|
+
├── templates/
|
|
71
|
+
│ └── AGENTS.md # Nutzungsvorlage für Zielprojekte
|
|
72
|
+
├── data/
|
|
73
|
+
│ └── spider.db # SQLite-Datenbank (auto-erstellt)
|
|
74
|
+
├── AGENTS.md # Bauanleitung für Coding-Agents
|
|
75
|
+
└── .env.example # Konfigurationsvorlage
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## API-Endpunkte
|
|
81
|
+
|
|
82
|
+
| Method | Endpunkt | Beschreibung |
|
|
83
|
+
|--------|---------------------------|--------------------------------------|
|
|
84
|
+
| GET | `/nodes` | Alle Nodes (flach) |
|
|
85
|
+
| GET | `/nodes/{id}` | Einzelner Node |
|
|
86
|
+
| GET | `/nodes/{id}/children` | Direktkinder eines Nodes |
|
|
87
|
+
| POST | `/nodes` | Neuen Node erstellen |
|
|
88
|
+
| PATCH | `/nodes/{id}` | Node aktualisieren |
|
|
89
|
+
| POST | `/nodes/{id}/reject` | Node ablehnen |
|
|
90
|
+
| POST | `/nodes/{id}/accept` | Node akzeptieren |
|
|
91
|
+
| GET | `/tree` | Kompletter Baum (flach) |
|
|
92
|
+
| GET | `/tree/nested` | Baum verschachtelt |
|
|
93
|
+
| GET | `/tree/stats` | Fortschrittsstatistiken |
|
|
94
|
+
| GET | `/actions` | Alle Audit-Log-Einträge |
|
|
95
|
+
| POST | `/actions` | Manuellen Audit-Eintrag erstellen |
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Einbindung in ein neues Projekt
|
|
100
|
+
|
|
101
|
+
### Schritt 1: Spider einmalig installieren
|
|
102
|
+
```bash
|
|
103
|
+
# Lokal (Entwicklung), aus dem Spider-Repo – inkl. MCP-Server:
|
|
104
|
+
pip install -e ".[mcp]"
|
|
105
|
+
|
|
106
|
+
# Später, nach GitHub-Publish:
|
|
107
|
+
pip install "spider[mcp] @ git+https://github.com/<user>/spider.git"
|
|
108
|
+
```
|
|
109
|
+
Installiere in das Python, das deine Projekte nutzen (System-Python, oder das venv des Projekts).
|
|
110
|
+
`[mcp]` ist optional – nur für den nativen MCP-Server nötig.
|
|
111
|
+
|
|
112
|
+
### Schritt 2: Projekt initialisieren
|
|
113
|
+
Ein Befehl macht ein beliebiges Projekt Spider-fähig:
|
|
114
|
+
```bash
|
|
115
|
+
spider-init /pfad/zum/projekt # oder: python -m spider.init /pfad/zum/projekt
|
|
116
|
+
```
|
|
117
|
+
Das legt im Zielprojekt an:
|
|
118
|
+
- `.spider/.env` – zentrale Konfiguration (`SPIDER_DB_PATH`, optional `SPIDER_BASE_URL`),
|
|
119
|
+
- `.spider/spider.db` – die projekteigene Datenbank (lazy, isoliert pro Projekt),
|
|
120
|
+
- `.spider/work_agent.md` – System-Prompt für read-only Subagents,
|
|
121
|
+
- `AGENTS.md` – Agent-Anweisungen (neu) bzw. ein angehängter, markierter Block,
|
|
122
|
+
- `spider_tools.py` – Tool-Shim (exportiert `spider` und read-only `spider_ro`),
|
|
123
|
+
- `.mcp.json` – MCP-Server-Konfiguration für Claude Code & Co.,
|
|
124
|
+
- `.claude/commands/spider-plan.md` + `spider-execute.md` – Slash-Commands,
|
|
125
|
+
- `spider-viz.ps1` / `spider-viz.sh` – Start-Helper für die Visualisierung.
|
|
126
|
+
|
|
127
|
+
### Schritt 3: Tools nutzen
|
|
128
|
+
|
|
129
|
+
**a) Native MCP-Tools (empfohlen, z.B. Claude Code):** Beim Öffnen des Projekts findet der Client
|
|
130
|
+
`.mcp.json` und startet `python -m spider.mcp_server` (Direkt-DB, kein Server). Verfügbare Tools:
|
|
131
|
+
`spider_create_node`, `spider_get_tree`, `spider_get_tree_stats`, `spider_accept_node`,
|
|
132
|
+
`spider_reject_node`, `spider_update_node`, `spider_add_action`, `spider_get_node`,
|
|
133
|
+
`spider_get_children`, `spider_get_actions`. (Projekt-MCP-Server einmalig bestätigen.)
|
|
134
|
+
|
|
135
|
+
**b) Per Python (kein Server nötig):**
|
|
136
|
+
```python
|
|
137
|
+
from spider_tools import spider # voller Zugriff
|
|
138
|
+
spider.get_tree_stats()
|
|
139
|
+
from spider_tools import spider_ro # read-only (für Subagents; Schreib-Methoden werfen)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Netzwerk-/Remote-Zugriff** (z.B. Claude Code vom Handy): in `.spider/.env`
|
|
143
|
+
`SPIDER_BASE_URL=http://<host>:8765` setzen und `python -m spider.server.main` starten –
|
|
144
|
+
Shim/MCP nutzen dann HTTP, gleiche DB darunter, keine Migration.
|
|
145
|
+
|
|
146
|
+
### Schritt 4: Zwei-Phasen-Workflow (Slash-Commands)
|
|
147
|
+
- **`/spider-plan`** – Planungsphase: baut den Entscheidungsbaum auf, bis `root.reifegrad == 1.0`.
|
|
148
|
+
- **`/spider-execute`** – Ausführungsphase: Orchestrator mit exklusivem Schreibzugriff startet
|
|
149
|
+
read-only Subagents (siehe `.spider/work_agent.md`), die Ergebnisse zurückmelden; nur der
|
|
150
|
+
Orchestrator schreibt sie nach Spider.
|
|
151
|
+
|
|
152
|
+
### Schritt 5: Visualisierung öffnen
|
|
153
|
+
```bash
|
|
154
|
+
./spider-viz.ps1 # Windows (bzw. ./spider-viz.sh unter Linux/macOS)
|
|
155
|
+
# wählt automatisch einen freien Port und gibt die URL aus
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Bestehendes Projekt upgraden
|
|
159
|
+
Nach einem Spider-Update die generierten Dateien im Projekt aktualisieren – Nutzerdaten
|
|
160
|
+
(`.spider/.env`, `.spider/spider.db`) bleiben unangetastet:
|
|
161
|
+
```bash
|
|
162
|
+
spider-init /pfad/zum/projekt --force
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## reifegrad-Logik
|
|
168
|
+
|
|
169
|
+
| Knotentyp | reifegrad |
|
|
170
|
+
|------------------------------------|-----------|
|
|
171
|
+
| Blattknoten, akzeptiert | 1.0 |
|
|
172
|
+
| Blattknoten, abgelehnt | 1.0 |
|
|
173
|
+
| Blattknoten, offen | 0.0 |
|
|
174
|
+
| Interner Knoten | Ø(Children)|
|
|
175
|
+
| Root (Ziel) | **1.0** |
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Konfiguration (`.spider/.env`)
|
|
180
|
+
|
|
181
|
+
Pro Projekt liegt die Konfiguration in `.spider/.env` (von `spider-init` erzeugt, autoritativ
|
|
182
|
+
geladen via `spider/config.py`). Ein relativer `SPIDER_DB_PATH` wird relativ zur Projektwurzel
|
|
183
|
+
aufgelöst.
|
|
184
|
+
|
|
185
|
+
```env
|
|
186
|
+
SPIDER_DB_PATH=.spider/spider.db
|
|
187
|
+
# Optionaler Netzwerk-/Remote-Zugriff (Shim/MCP schalten dann auf HTTP):
|
|
188
|
+
# SPIDER_BASE_URL=http://127.0.0.1:8765
|
|
189
|
+
# Optionale feste Ports (sonst wählt der Viz-Start einen freien Port):
|
|
190
|
+
# SPIDER_HOST=127.0.0.1
|
|
191
|
+
# SPIDER_PORT=8765
|
|
192
|
+
# SPIDER_VIZ_HOST=127.0.0.1
|
|
193
|
+
# SPIDER_VIZ_PORT=8766
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## POC-Status & Nächste Schritte
|
|
199
|
+
|
|
200
|
+
Dieser POC validiert das Grundkonzept. Bei Erfolg geplant:
|
|
201
|
+
|
|
202
|
+
- [ ] Rückwirkende Integration für laufende Projekte
|
|
203
|
+
- [ ] API-Key-Authentifizierung für Multi-Agent-Setups
|
|
204
|
+
- [ ] PostgreSQL-Migration für Produktion
|
|
205
|
+
- [ ] PDF/Markdown-Export des Entscheidungsbaums
|
|
206
|
+
- [ ] Webhook-Benachrichtigungen bei Reifegrad-Schwellwerten
|
|
207
|
+
- [ ] pip-Package-Veröffentlichung
|
|
208
|
+
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Spider Framework – zentrale Konfiguration / .env-Laden.
|
|
3
|
+
|
|
4
|
+
Sorgt dafür, dass alle SPIDER_*-Einstellungen (insbesondere SPIDER_DB_PATH)
|
|
5
|
+
**konsistent aus der Projekt-.env** kommen. Jeder Einstiegspunkt (Tool-Shim,
|
|
6
|
+
`launch.py`, `server.main`, `db.seed`, `db.database.get_db`) ruft `load_project_env()`
|
|
7
|
+
auf, bevor er Konfiguration liest.
|
|
8
|
+
|
|
9
|
+
Konventionen:
|
|
10
|
+
- Pro Projekt liegt die Konfiguration in `<projekt>/.spider/.env`
|
|
11
|
+
(isoliert von einer evtl. vorhandenen App-eigenen `.env` im Projektwurzelordner).
|
|
12
|
+
- Gesucht wird ab einem Startverzeichnis aufwärts: zuerst `.spider/.env`,
|
|
13
|
+
ersatzweise `.env` im selben Verzeichnis.
|
|
14
|
+
- Die `.env` ist **autoritativ** (`override=True`): ihre Werte gewinnen gegenüber
|
|
15
|
+
bereits gesetzten Prozess-Umgebungsvariablen. Damit kann keine global gesetzte
|
|
16
|
+
SPIDER_DB_PATH-Variable ein Projekt mehr „kapern". Schlüssel, die *nicht* in der
|
|
17
|
+
`.env` stehen (z.B. ein per Shell gesetztes SPIDER_BASE_URL), bleiben unberührt.
|
|
18
|
+
- Ein relativer SPIDER_DB_PATH wird relativ zur **Projektwurzel** (dem Verzeichnis,
|
|
19
|
+
das `.spider/` enthält) zu einem absoluten Pfad aufgelöst.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
import os
|
|
25
|
+
from pathlib import Path
|
|
26
|
+
from typing import Optional
|
|
27
|
+
|
|
28
|
+
_loaded = False
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def find_project_env(start: Optional[Path] = None) -> Optional[Path]:
|
|
32
|
+
"""Sucht ab `start` (default: CWD) aufwärts die nächste Projekt-.env."""
|
|
33
|
+
base = (Path(start) if start else Path.cwd()).resolve()
|
|
34
|
+
for d in [base, *base.parents]:
|
|
35
|
+
candidate = d / ".spider" / ".env"
|
|
36
|
+
if candidate.is_file():
|
|
37
|
+
return candidate
|
|
38
|
+
candidate = d / ".env"
|
|
39
|
+
if candidate.is_file():
|
|
40
|
+
return candidate
|
|
41
|
+
return None
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _parse_env(text: str) -> dict[str, str]:
|
|
45
|
+
"""Minimaler .env-Parser (KEY=VALUE, # Kommentare, optionale Quotes)."""
|
|
46
|
+
values: dict[str, str] = {}
|
|
47
|
+
for raw in text.splitlines():
|
|
48
|
+
line = raw.strip()
|
|
49
|
+
if not line or line.startswith("#"):
|
|
50
|
+
continue
|
|
51
|
+
if line.startswith("export "):
|
|
52
|
+
line = line[len("export "):]
|
|
53
|
+
if "=" not in line:
|
|
54
|
+
continue
|
|
55
|
+
key, _, val = line.partition("=")
|
|
56
|
+
key = key.strip()
|
|
57
|
+
val = val.strip().strip('"').strip("'")
|
|
58
|
+
if key:
|
|
59
|
+
values[key] = val
|
|
60
|
+
return values
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _project_root(env_path: Path) -> Path:
|
|
64
|
+
"""Projektwurzel = Verzeichnis, das `.spider/` enthält (bzw. .env-Verzeichnis)."""
|
|
65
|
+
if env_path.parent.name == ".spider":
|
|
66
|
+
return env_path.parent.parent
|
|
67
|
+
return env_path.parent
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def load_project_env(start: Optional[Path] = None, override: bool = True, force: bool = False) -> Optional[Path]:
|
|
71
|
+
"""
|
|
72
|
+
Lädt die Projekt-.env in os.environ. Idempotent (nur einmal pro Prozess, außer force=True).
|
|
73
|
+
Gibt den geladenen .env-Pfad zurück (oder None, wenn keine gefunden wurde).
|
|
74
|
+
"""
|
|
75
|
+
global _loaded
|
|
76
|
+
if _loaded and not force:
|
|
77
|
+
return None
|
|
78
|
+
_loaded = True
|
|
79
|
+
|
|
80
|
+
env_path = find_project_env(start)
|
|
81
|
+
if env_path is None:
|
|
82
|
+
return None
|
|
83
|
+
|
|
84
|
+
values = _parse_env(env_path.read_text(encoding="utf-8"))
|
|
85
|
+
for key, val in values.items():
|
|
86
|
+
if override or key not in os.environ:
|
|
87
|
+
os.environ[key] = val
|
|
88
|
+
|
|
89
|
+
# Relativen SPIDER_DB_PATH relativ zur Projektwurzel absolut machen (portabel).
|
|
90
|
+
db_path = os.environ.get("SPIDER_DB_PATH")
|
|
91
|
+
if db_path and not Path(db_path).is_absolute():
|
|
92
|
+
os.environ["SPIDER_DB_PATH"] = str((_project_root(env_path) / db_path).resolve())
|
|
93
|
+
|
|
94
|
+
return env_path
|