@medicine-wheel/app 0.2.3

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.
package/Dockerfile ADDED
@@ -0,0 +1,69 @@
1
+ # =============================================================================
2
+ # Medicine Wheel — Docker Image
3
+ # jgwill/medicine-wheel:app
4
+ #
5
+ # Usage (via mwsrv CLI):
6
+ # mwsrv --docker -D /path/to/project
7
+ #
8
+ # Manual usage:
9
+ # docker run --rm -p 3940:3940 \
10
+ # -v /path/to/project/.mw/store:/data/store \
11
+ # -e MW_DATA_DIR=/data/store \
12
+ # jgwill/medicine-wheel:app
13
+ # =============================================================================
14
+
15
+ # ---- Build stage ----
16
+ FROM node:22-alpine AS builder
17
+
18
+ WORKDIR /app
19
+
20
+ # Copy package manifests and workspace source first (layer cache)
21
+ COPY package.json package-lock.json ./
22
+ COPY src/ ./src/
23
+ COPY mcp/ ./mcp/
24
+
25
+ # Install all dependencies (workspace packages resolved as file: refs)
26
+ RUN npm ci --legacy-peer-deps --ignore-scripts
27
+
28
+ # Copy Next.js application source
29
+ COPY app/ ./app/
30
+ COPY components/ ./components/
31
+ COPY hooks/ ./hooks/
32
+ COPY lib/ ./lib/
33
+ COPY public/ ./public/
34
+ COPY next.config.mjs postcss.config.mjs tsconfig.json next-env.d.ts ./
35
+
36
+ # Build workspace packages then Next.js
37
+ RUN npm run build:packages && npm run build
38
+
39
+ # ---- Runner stage ----
40
+ FROM node:22-alpine AS runner
41
+
42
+ WORKDIR /app
43
+
44
+ ENV NODE_ENV=production
45
+ ENV PORT=3940
46
+ ENV MW_STORAGE_PROVIDER=jsonl
47
+ ENV MW_DATA_DIR=/data/store
48
+
49
+ # Copy manifests and full node_modules from builder
50
+ COPY --from=builder /app/package.json ./
51
+ COPY --from=builder /app/node_modules ./node_modules
52
+ COPY --from=builder /app/src ./src
53
+ COPY --from=builder /app/mcp ./mcp
54
+
55
+ # Copy pre-built Next.js output and static assets
56
+ COPY --from=builder /app/.next ./.next
57
+ COPY --from=builder /app/public ./public
58
+ COPY --from=builder /app/next.config.mjs ./next.config.mjs
59
+
60
+ # Entrypoint
61
+ COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
62
+ RUN chmod +x /usr/local/bin/docker-entrypoint.sh
63
+
64
+ # Volume for persistent data
65
+ VOLUME ["/data/store"]
66
+
67
+ EXPOSE 3940
68
+
69
+ ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
package/LICENSE ADDED
@@ -0,0 +1,205 @@
1
+ MIT License and IKSL
2
+
3
+ -----
4
+ BELLOW is the IKSL which governs as best as I can what is of Indigenous Epistemologies in what I am doing. What is not is governed by MIT
5
+ -----
6
+
7
+
8
+ # LICENSE-IKSL.md
9
+ by Guillaume D.Isabelle, 2025a,
10
+ http://simp.ly/publish/9vWq1Y https://app.simplenote.com/publish/9vWq1Y https://app.simplenote.com/p/CdgR71
11
+
12
+
13
+ ## Indigenous Knowledge Stewardship License (IKSL) v1.0
14
+
15
+ This repository contains knowledge protected under the Indigenous Knowledge Stewardship License, which recognizes that knowledge belongs to the relationships, land, and communities that created it, not to individuals or corporations.
16
+
17
+ ### Active License: IKSL-Bridge v1.0
18
+
19
+ This work serves as a bridge between Indigenous and Western knowledge systems.
20
+
21
+ #### Immediate Terms:
22
+
23
+ 1. **Attribution Required**: This work builds upon Indigenous knowledge systems, particularly those of the Lakota and Mani-Utenam peoples, as well as the contributions of Guillaume D-Isabelle and the Spiral Agent Protocol collective.
24
+
25
+ 1. **Dual Framework**:
26
+ - **Code/Technical Implementation**: Licensed under Creative Commons BY-SA 4.0
27
+ - **Stories/Frameworks/Methodologies**: Protected under IKSL-Ceremonial (see below)
28
+ - **Documentation/Educational Materials**: Licensed under IKSL-Community
29
+ 1. **Reciprocal Obligation**: By using this knowledge, you agree to:
30
+ - Contribute improvements back to the originating community
31
+ - Respect the ceremonial nature of the teaching methodologies
32
+ - Acknowledge that this knowledge is held in trust, not owned
33
+ 1. **Commercial Restrictions**:
34
+ - Technical code may be used commercially under CC BY-SA terms
35
+ - Stories, analogies, and Indigenous methodologies may NOT be commercialized
36
+ - Educational use is encouraged with proper attribution
37
+
38
+ #### Sacred Elements (IKSL-Ceremonial):
39
+
40
+ The following elements require special ceremonial protocols and may not be used without explicit permission from knowledge keepers:
41
+
42
+ - Ceremony research methodologies
43
+ - Sacred narrative frameworks
44
+ - Indigenous teaching stories and analogies
45
+ - Spiral methodology implementations
46
+ - Firekeeper protocols
47
+
48
+ #### Legal Bridge:
49
+
50
+ This license operates simultaneously within Western legal frameworks (through Creative Commons) and Indigenous sovereignty principles. In cases of conflict, Indigenous protocols take precedence for protected elements.
51
+
52
+ ### How to Apply This License:
53
+
54
+ 1. Include this LICENSE-IKSL.md in your repository
55
+ 1. Add the following header to protected files:
56
+
57
+ ```
58
+ /**
59
+ * Protected under Indigenous Knowledge Stewardship License v1.0
60
+ * This knowledge belongs to the relationships and land that created it.
61
+ * See LICENSE-IKSL.md for full terms.
62
+ *
63
+ * Attribution: [Your addition] builds upon [Previous contributors]
64
+ * Origin Community: [Name]
65
+ * Transmission Path: [Origin] → [Previous] → [You]
66
+ */
67
+ ```
68
+
69
+ ### Metadata Structure:
70
+
71
+ Create an `iksl-metadata.json` file:
72
+
73
+ ```json
74
+ {
75
+ "license_version": "IKSL-Bridge-v1.0",
76
+ "origin_community": "Lakota and Mani-Utenam peoples",
77
+ "primary_steward": "Guillaume D-Isabelle",
78
+ "knowledge_keepers": [
79
+ "To be designated by community"
80
+ ],
81
+ "transmission_path": [
82
+ {
83
+ "from": "Indigenous Knowledge Systems",
84
+ "to": "Guillaume D-Isabelle",
85
+ "date": "2024-2025",
86
+ "context": "Ceremony research and Two-Eyed Seeing methodology"
87
+ }
88
+ ],
89
+ "reciprocal_contributions": [
90
+ "Document your contributions here"
91
+ ],
92
+ "sacred_elements": [
93
+ "ceremony_research_methodology",
94
+ "spiral_framework",
95
+ "firekeeper_protocols"
96
+ ],
97
+ "technical_elements_cc_licensed": [
98
+ "List technical implementations under CC BY-SA"
99
+ ]
100
+ }
101
+ ```
102
+
103
+ ### Enforcement and Accountability:
104
+
105
+ 1. **Violations** of ceremonial protocols result in:
106
+ - Immediate revocation of license
107
+ - Requirement for restorative process
108
+ - Community-determined consequences
109
+ 1. **Restorative Process**:
110
+ - Acknowledgment of harm
111
+ - Dialogue with knowledge keepers
112
+ - Contribution to community healing
113
+ - Demonstration of renewed understanding
114
+ 1. **Questions and Permissions**:
115
+ - Contact: [Community contact to be established]
116
+ - For ceremonial elements: Requires knowledge keeper approval
117
+ - For technical elements: Standard CC BY-SA applies
118
+
119
+ ### Statement of Understanding:
120
+
121
+ By using this repository, you acknowledge:
122
+
123
+ > “I understand that this knowledge emerges from and returns to the relationships that created it. I commit to honoring the ceremonial nature of these teachings, contributing reciprocally to the community, and respecting that ultimate authority over this knowledge rests with Indigenous sovereignty, not Western legal systems.”
124
+
125
+ ### Living Document:
126
+
127
+ This license is itself a living document, meant to evolve through community consensus and relationship. Updates will be made through proper ceremonial protocols and community agreement.
128
+
129
+ -----
130
+
131
+ ## Quick Reference Card
132
+
133
+ ### Can I use this for…
134
+
135
+ |Use Case |Technical Code |Stories/Methods |Documentation |
136
+ |-------------------|------------------|-------------------|------------------|
137
+ |Personal Learning |✅ Yes |✅ With respect |✅ Yes |
138
+ |Teaching/Education |✅ Yes |✅ With attribution |✅ Yes |
139
+ |Open Source Project|✅ CC BY-SA |❌ Permission needed|✅ With attribution|
140
+ |Commercial Product |✅ CC BY-SA |❌ No |⚠️ Case by case |
141
+ |AI Training |⚠️ With reciprocity|❌ No |⚠️ With agreement |
142
+
143
+ ### Attribution Template:
144
+
145
+ ```
146
+ This work incorporates Indigenous Knowledge Stewardship practices
147
+ originated by the Lakota and Mani-Utenam peoples,
148
+ stewarded by Guillaume D-Isabelle,
149
+ and transmitted through the Spiral Agent Protocol.
150
+
151
+ [Your specific use/modification]
152
+
153
+ In the spirit of reciprocity, [describe your contribution back].
154
+ ```
155
+
156
+ -----
157
+
158
+ ## Frequently Asked Questions
159
+
160
+ **Q: How is this different from Creative Commons?**
161
+ A: Creative Commons assumes individual ownership that can be given away. IKSL recognizes knowledge as belonging to relationships and land, with communities as stewards rather than owners.
162
+
163
+ **Q: Can I fork this repository?**
164
+ A: Technical elements can be forked under CC BY-SA. Sacred elements require permission and proper protocols.
165
+
166
+ **Q: How do I contribute back?**
167
+ A: Document your contributions in the metadata, share improvements with the community, and consider how your work serves the seven generations to come.
168
+
169
+ **Q: What if I violate the license accidentally?**
170
+ A: Reach out immediately. This license emphasizes restoration over punishment. Honest mistakes can become learning opportunities.
171
+
172
+ -----
173
+
174
+ *Version 1.0 - October 2025*
175
+ *A Living Document in Service of Knowledge Sovereignty*
176
+
177
+
178
+ https://claude.ai/public/artifacts/7d283f81-b49c-4181-8839-8b4f5a20c900
179
+
180
+
181
+
182
+
183
+
184
+ ----
185
+ ORIGINAL MIT License
186
+ ----
187
+ Copyright (c) 2026 Guillaume Descoteaux-Isabelle
188
+
189
+ Permission is hereby granted, free of charge, to any person obtaining a copy
190
+ of this software and associated documentation files (the "Software"), to deal
191
+ in the Software without restriction, including without limitation the rights
192
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
193
+ copies of the Software, and to permit persons to whom the Software is
194
+ furnished to do so, subject to the following conditions:
195
+
196
+ The above copyright notice and this permission notice shall be included in all
197
+ copies or substantial portions of the Software.
198
+
199
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
200
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
201
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
202
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
203
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
204
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
205
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,201 @@
1
+ # Medicine Wheel
2
+
3
+ > A first experimental TypeScript framework for relational healing, ceremonial inquiry, and Indigenous-aligned software development — grounded in the Four Directions, Wilson's three R's (Respect, Reciprocity, Responsibility), and OCAP® data sovereignty principles.
4
+
5
+ ## NEWS
6
+
7
+ * Full postgres (neon) data provider !
8
+
9
+
10
+ ## Architecture
11
+
12
+ ```
13
+ medicine-wheel-ontology-core ← Foundation (types, schemas, RDF vocabulary)
14
+ ├── medicine-wheel-ceremony-protocol ← Ceremony state & governance
15
+ ├── medicine-wheel-fire-keeper ← Ceremony coordination agent
16
+ ├── medicine-wheel-community-review ← Elder review & consensus
17
+ ├── medicine-wheel-consent-lifecycle ← Relational consent lifecycle
18
+ ├── medicine-wheel-narrative-engine ← Beat sequencing & arc validation
19
+ ├── medicine-wheel-importance-unit ← Relational unit of knowledge
20
+ ├── medicine-wheel-relational-index ← Four-source epistemic indexing
21
+ ├── medicine-wheel-transformation-tracker ← Wilson validity tracking
22
+ ├── medicine-wheel-graph-viz ← Circular layout & visualization
23
+ ├── medicine-wheel-relational-query ← Query, traversal & audit
24
+ ├── medicine-wheel-prompt-decomposition ← Intent extraction & PDE
25
+ ├── medicine-wheel-ui-components ← React components
26
+ ├── medicine-wheel-data-store ← Shared Redis data access
27
+ └── medicine-wheel-session-reader ← Session event data reader
28
+ ```
29
+
30
+ ## Methodology: RISE Framework
31
+
32
+ This project utilizes the **RISE** methodology:
33
+ - **Reverse Engineering**: Deconstructing existing patterns to find relational roots.
34
+ - **Intent**: Establishing ceremonial purpose before action.
35
+ - **Specifications**: Explicit relational obligations as system requirements.
36
+ - **Exportation**: Sharing wisdom back to the community.
37
+
38
+ ## Packages
39
+
40
+ ### [@medicine-wheel/ontology-core](src/ontology-core)
41
+ Core ontology layer — 50+ TypeScript types, Zod validation schemas, RDF vocabulary (6 custom namespaces), canonical constants (Ojibwe names, seasons, direction colors), and semantic query helpers (Wilson alignment, OCAP® compliance, relational traversal).
42
+
43
+ - **Version:** 0.2.0
44
+ - **Dependencies:** `zod` ^3.23.0
45
+
46
+ ### [@medicine-wheel/ceremony-protocol](src/ceremony-protocol)
47
+ Ceremony lifecycle protocol — manages ceremony state, four-phase transitions (opening → council → integration → closure), governance enforcement for protected paths, and ceremony-required change detection.
48
+
49
+ - **Version:** 0.2.0
50
+ - **Dependencies:** `medicine-wheel-ontology-core`
51
+
52
+ ### [@medicine-wheel/fire-keeper](src/fire-keeper)
53
+ Fire Keeper coordination agent — tends the ceremony fire, ensures relational integrity through gating conditions, permission tier escalation, and maintains Wilson alignment as an active agent that evaluates, gates, routes, and escalates.
54
+
55
+ - **Version:** 0.2.0
56
+ - **Dependencies:** `medicine-wheel-ontology-core`, `medicine-wheel-ceremony-protocol`
57
+
58
+ ### [@medicine-wheel/community-review](src/community-review)
59
+ Community-based ceremonial review protocol — implements Wilson's validation through Elder review circles, consensus-seeking, talking circle protocol, and relational accountability assessment.
60
+
61
+ - **Version:** 0.2.0
62
+ - **Dependencies:** `medicine-wheel-ontology-core`, `medicine-wheel-ceremony-protocol`, `zod`
63
+
64
+ ### [@medicine-wheel/consent-lifecycle](src/consent-lifecycle)
65
+ Ongoing relational consent lifecycle — consent as a living relational obligation with lifecycle tracking, renewal, renegotiation, withdrawal cascades, and community-level consent protocols.
66
+
67
+ - **Version:** 0.2.0
68
+ - **Dependencies:** `medicine-wheel-ontology-core`, `medicine-wheel-ceremony-protocol`, `zod`
69
+
70
+ ### [@medicine-wheel/narrative-engine](src/narrative-engine)
71
+ Beat sequencing, cadence validation, arc completeness scoring, timeline building, cycle orchestration, and RSIS narrative generators. Tracks four-directional balance and ceremony coverage.
72
+
73
+ - **Version:** 0.2.0
74
+ - **Dependencies:** `medicine-wheel-ontology-core`
75
+
76
+ ### [@medicine-wheel/importance-unit](src/importance-unit)
77
+ ImportanceUnit — the relational unit of knowledge in Wilson's epistemology. Carries epistemic weight, source dimensions (Land/Dream/Code/Vision), circle depth tracking, and accountability links. Dream-state knowledge starts at 0.85+ weight; rational-filtered inputs start lower.
78
+
79
+ - **Version:** 0.2.0
80
+ - **Dependencies:** `medicine-wheel-ontology-core`, `zod`
81
+
82
+ ### [@medicine-wheel/relational-index](src/relational-index)
83
+ Four-source epistemic dimensional indexing — Land, Dream, Code, Vision traversal with cross-dimensional mapping, convergence/tension detection, and spiral depth metrics.
84
+
85
+ - **Version:** 0.2.0
86
+ - **Dependencies:** `medicine-wheel-ontology-core`
87
+
88
+ ### [@medicine-wheel/transformation-tracker](src/transformation-tracker)
89
+ Research transformation tracking — Wilson validity criterion: "If research doesn't change you, you haven't done it right." Tracks researcher growth, community impact, relational shifts, reciprocity balance, and seven-generation sustainability.
90
+
91
+ - **Version:** 0.2.0
92
+ - **Dependencies:** `medicine-wheel-ontology-core`, `medicine-wheel-ceremony-protocol`, `zod`
93
+
94
+ ### [@medicine-wheel/graph-viz](src/graph-viz)
95
+ Medicine Wheel circular graph visualization — four-direction node positioning, ceremony-aware edges, OCAP® indicators, SVG path generation, data converters, and RSIS visualization utilities (kinship graphs, reciprocity flows, Mermaid export).
96
+
97
+ - **Version:** 0.2.0
98
+ - **Dependencies:** `medicine-wheel-ontology-core`
99
+ - **Peer:** `react` >=18.0.0
100
+
101
+ ### [@medicine-wheel/relational-query](src/relational-query)
102
+ Query builder for relational webs — node/edge filtering, ceremony-bounded BFS traversal, OCAP®-compliant path walking, accountability auditing, shortest path, neighborhood discovery, and KuzuDB Cypher query builders.
103
+
104
+ - **Version:** 0.2.0
105
+ - **Dependencies:** `medicine-wheel-ontology-core`
106
+
107
+ ### [@medicine-wheel/prompt-decomposition](src/prompt-decomposition)
108
+ Ontology-enriched prompt decomposition — Four Directions classification, implicit intent extraction from hedging language, dependency mapping, ceremony guidance, action stacking, and narrative beat generation.
109
+
110
+ - **Version:** 0.2.0
111
+ - **Dependencies:** `medicine-wheel-ontology-core`
112
+
113
+ ### [@medicine-wheel/ui-components](src/ui-components)
114
+ React UI component library — `DirectionCard`, `BeatTimeline`, `NodeInspector`, `OcapBadge`, `WilsonMeter`. All components use ontology-core types for type-safe, culturally grounded interfaces.
115
+
116
+ - **Version:** 0.2.0
117
+ - **Dependencies:** `medicine-wheel-ontology-core`
118
+ - **Peer:** `react` ^18.0.0 || ^19.0.0
119
+
120
+ ### [@medicine-wheel/data-store](src/data-store)
121
+ Shared Redis data-access layer — connection management (Upstash, Vercel KV, local), Node/Edge/Ceremony/Accountability CRUD, session-ceremony linking, and generic Redis helpers.
122
+
123
+ - **Version:** 0.2.0
124
+ - **Dependencies:** `medicine-wheel-ontology-core`, `redis`
125
+
126
+ ### [@medicine-wheel/session-reader](src/session-reader)
127
+ Session event reader — JSONL parsing, session summaries, analytics extraction, and search across agent session data. Zero external dependencies.
128
+
129
+ - **Version:** 0.2.0
130
+ - **Dependencies:** None (Node.js built-ins only)
131
+
132
+ ## Specifications
133
+
134
+ RISE framework specifications for all 15 packages are in [`rispecs/`](rispecs/). Start with [`medicine-wheel.spec.md`](rispecs/medicine-wheel.spec.md) for the system overview.
135
+
136
+ | Package | Spec |
137
+ |---------|------|
138
+ | System Overview | [medicine-wheel.spec.md](rispecs/medicine-wheel.spec.md) |
139
+ | ontology-core | [ontology-core.spec.md](rispecs/ontology-core.spec.md) |
140
+ | ceremony-protocol | [ceremony-protocol.spec.md](rispecs/ceremony-protocol.spec.md) |
141
+ | fire-keeper | [fire-keeper.spec.md](rispecs/fire-keeper.spec.md) |
142
+ | community-review | [community-review.spec.md](rispecs/community-review.spec.md) |
143
+ | consent-lifecycle | [consent-lifecycle.spec.md](rispecs/consent-lifecycle.spec.md) |
144
+ | narrative-engine | [narrative-engine.spec.md](rispecs/narrative-engine.spec.md) |
145
+ | importance-unit | [importance-unit.spec.md](rispecs/importance-unit.spec.md) |
146
+ | relational-index | [relational-index.spec.md](rispecs/relational-index.spec.md) |
147
+ | transformation-tracker | [transformation-tracker.spec.md](rispecs/transformation-tracker.spec.md) |
148
+ | graph-viz | [graph-viz.spec.md](rispecs/graph-viz.spec.md) |
149
+ | relational-query | [relational-query.spec.md](rispecs/relational-query.spec.md) |
150
+ | prompt-decomposition | [prompt-decomposition.spec.md](rispecs/prompt-decomposition.spec.md) |
151
+ | ui-components | [ui-components.spec.md](rispecs/ui-components.spec.md) |
152
+ | data-store | [data-store.spec.md](rispecs/data-store.spec.md) |
153
+ | session-reader | [session-reader.spec.md](rispecs/session-reader.spec.md) |
154
+
155
+ ## LLM Integration
156
+
157
+ - [`llms.txt`](llms.txt) — Quick navigation for LLMs
158
+ - [`llms-full.txt`](llms-full.txt) — Exhaustive reference with code samples
159
+
160
+ ## Getting Started
161
+
162
+ ### Development
163
+ This is a monorepo using npm workspaces.
164
+
165
+ ```bash
166
+ # Build all packages
167
+ npm run build:packages
168
+
169
+ # Start development server (Next.js)
170
+ npm run dev
171
+ ```
172
+
173
+ ### Installation
174
+ ```bash
175
+ # Install individual packages (from registry when published)
176
+ npm install @medicine-wheel/ontology-core
177
+ npm install @medicine-wheel/narrative-engine
178
+ ```
179
+
180
+ ### App package CLI
181
+ ```bash
182
+ # Install the published app package
183
+ npm install -g @medicine-wheel/app
184
+
185
+ # Start the server against the current directory's .mw/store
186
+ mwsrv -D ./
187
+
188
+ # Start the server in Docker with the published image
189
+ mwsrv --docker -D /src/myapp
190
+
191
+ # Talk to the running server
192
+ mw status
193
+ mw directions
194
+ mw node list
195
+ ```
196
+
197
+ ## License
198
+
199
+ MIT see [LICENSE](LICENSE)
200
+
201
+
@@ -0,0 +1,95 @@
1
+ "use client";
2
+
3
+ import { useEffect, useState } from "react";
4
+
5
+ interface Resource {
6
+ id: string;
7
+ name: string;
8
+ description: string;
9
+ content: Record<string, string>;
10
+ }
11
+
12
+ export default function AccountabilityPage() {
13
+ const [resources, setResources] = useState<Resource[]>([]);
14
+ const [nodes, setNodes] = useState<any[]>([]);
15
+ const [edges, setEdges] = useState<any[]>([]);
16
+ const [ceremonies, setCeremonies] = useState<any[]>([]);
17
+ const [beats, setBeats] = useState<any[]>([]);
18
+ const [expandedRes, setExpandedRes] = useState<string | null>(null);
19
+
20
+ useEffect(() => {
21
+ Promise.all([
22
+ fetch("/api/resources").then((r) => r.json()),
23
+ fetch("/api/nodes").then((r) => r.json()),
24
+ fetch("/api/edges").then((r) => r.json()),
25
+ fetch("/api/ceremonies").then((r) => r.json()),
26
+ fetch("/api/narrative/beats").then((r) => r.json()),
27
+ ]).then(([res, n, e, c, b]) => {
28
+ setResources(Array.isArray(res) ? res : []);
29
+ setNodes(Array.isArray(n) ? n : []);
30
+ setEdges(Array.isArray(e) ? e : []);
31
+ setCeremonies(Array.isArray(c) ? c : []);
32
+ setBeats(Array.isArray(b) ? b : []);
33
+ }).catch(() => {});
34
+ }, []);
35
+
36
+ const ceremoniedCount = edges.filter((e: any) => e.ceremony_honored).length;
37
+
38
+ return (
39
+ <div className="p-6 max-w-5xl mx-auto">
40
+ <h1 className="text-2xl font-bold mb-2">Accountability & Frameworks</h1>
41
+ <p className="text-sm text-muted-foreground mb-6">Relational accountability metrics and Indigenous research frameworks</p>
42
+
43
+ {/* Metric Cards */}
44
+ <div className="grid grid-cols-2 md:grid-cols-4 gap-4 mb-8">
45
+ <div className="p-4 rounded-lg border bg-card text-center">
46
+ <p className="text-3xl font-bold">{nodes.length}</p>
47
+ <p className="text-sm text-muted-foreground">Relations Mapped</p>
48
+ <p className="text-xs text-muted-foreground">{nodes.length} nodes · {edges.length} edges</p>
49
+ </div>
50
+ <div className="p-4 rounded-lg border bg-card text-center">
51
+ <p className="text-3xl font-bold">{ceremonies.length}</p>
52
+ <p className="text-sm text-muted-foreground">Ceremonies Logged</p>
53
+ </div>
54
+ <div className="p-4 rounded-lg border bg-card text-center">
55
+ <p className="text-3xl font-bold">{beats.length}</p>
56
+ <p className="text-sm text-muted-foreground">Narrative Beats</p>
57
+ </div>
58
+ <div className="p-4 rounded-lg border bg-card text-center">
59
+ <p className="text-3xl font-bold text-green-500">{ceremoniedCount > 0 ? "✓" : "○"}</p>
60
+ <p className="text-sm text-muted-foreground">Relations Ceremonied</p>
61
+ <p className="text-xs text-muted-foreground">{ceremoniedCount}/{edges.length} edges ceremonied</p>
62
+ </div>
63
+ </div>
64
+
65
+ {/* Frameworks */}
66
+ <h2 className="text-lg font-semibold mb-4">Indigenous Research Frameworks</h2>
67
+ <div className="space-y-3">
68
+ {resources.map((res) => (
69
+ <div key={res.id} className="border rounded-lg bg-card overflow-hidden cursor-pointer hover:border-ring/50"
70
+ onClick={() => setExpandedRes(expandedRes === res.id ? null : res.id)}>
71
+ <div className="p-4 flex items-center justify-between">
72
+ <div>
73
+ <h3 className="font-medium">{res.name}</h3>
74
+ <p className="text-sm text-muted-foreground">{res.description}</p>
75
+ </div>
76
+ <span className="text-muted-foreground">{expandedRes === res.id ? "▲" : "▼"}</span>
77
+ </div>
78
+ {expandedRes === res.id && (
79
+ <div className="px-4 pb-4 border-t pt-3">
80
+ <div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
81
+ {Object.entries(res.content).map(([key, value]) => (
82
+ <div key={key} className="p-3 rounded-md bg-secondary/30">
83
+ <p className="text-xs font-medium text-muted-foreground uppercase mb-1">{key}</p>
84
+ <p className="text-sm">{value}</p>
85
+ </div>
86
+ ))}
87
+ </div>
88
+ </div>
89
+ )}
90
+ </div>
91
+ ))}
92
+ </div>
93
+ </div>
94
+ );
95
+ }
@@ -0,0 +1,52 @@
1
+ import { NextResponse } from "next/server";
2
+ import { createProvider, detectProvider } from "@medicine-wheel/storage-provider";
3
+
4
+ export async function GET(request: Request) {
5
+ try {
6
+ const { searchParams } = new URL(request.url);
7
+ const direction = searchParams.get("direction");
8
+ const type = searchParams.get("type");
9
+
10
+ const store = await createProvider();
11
+ let ceremonies = await store.getAllCeremonies();
12
+
13
+ if (direction) {
14
+ ceremonies = ceremonies.filter((c) => c.direction === direction);
15
+ } else if (type) {
16
+ ceremonies = ceremonies.filter((c) => c.type === type);
17
+ }
18
+
19
+ return NextResponse.json({
20
+ ceremonies,
21
+ provider: detectProvider(),
22
+ count: ceremonies.length
23
+ });
24
+ } catch (error: unknown) {
25
+ const message = error instanceof Error ? error.message : String(error);
26
+ return NextResponse.json({ error: message }, { status: 500 });
27
+ }
28
+ }
29
+
30
+ export async function POST(request: Request) {
31
+ try {
32
+ const store = await createProvider();
33
+ const body = await request.json();
34
+
35
+ const ceremony = {
36
+ id: body.id || crypto.randomUUID(),
37
+ type: body.type,
38
+ direction: body.direction,
39
+ participants: body.participants ?? [],
40
+ medicines_used: body.medicines_used ?? [],
41
+ intentions: body.intentions ?? [],
42
+ timestamp: new Date().toISOString(),
43
+ research_context: body.research_context,
44
+ };
45
+
46
+ await store.logCeremony(ceremony);
47
+ return NextResponse.json({ success: true, ceremony, provider: detectProvider() }, { status: 201 });
48
+ } catch (error: unknown) {
49
+ const message = error instanceof Error ? error.message : String(error);
50
+ return NextResponse.json({ error: message }, { status: 500 });
51
+ }
52
+ }
@@ -0,0 +1,6 @@
1
+ import { NextResponse } from "next/server";
2
+ import { DIRECTIONS } from "@/lib/types";
3
+
4
+ export async function GET() {
5
+ return NextResponse.json(DIRECTIONS);
6
+ }
@@ -0,0 +1,27 @@
1
+ import { NextResponse } from "next/server";
2
+ import { getAllEdges, createEdge } from "@/lib/store";
3
+
4
+ export async function GET() {
5
+ try {
6
+ return NextResponse.json(getAllEdges());
7
+ } catch (error: any) {
8
+ return NextResponse.json({ error: error.message }, { status: 500 });
9
+ }
10
+ }
11
+
12
+ export async function POST(request: Request) {
13
+ try {
14
+ const body = await request.json();
15
+ const edge = createEdge({
16
+ from_id: body.from_id,
17
+ to_id: body.to_id,
18
+ relationship_type: body.relationship_type,
19
+ strength: body.strength ?? 0.5,
20
+ ceremony_honored: body.ceremony_honored ?? false,
21
+ obligations: body.obligations ?? [],
22
+ });
23
+ return NextResponse.json(edge, { status: 201 });
24
+ } catch (error: any) {
25
+ return NextResponse.json({ error: error.message }, { status: 500 });
26
+ }
27
+ }