Spaces:
Running
Running
bigwolfe
commited on
Commit
·
c30798d
1
Parent(s):
31b3b17
init
Browse files
GEMINI.md
CHANGED
|
@@ -3,6 +3,8 @@
|
|
| 3 |
Auto-generated from all feature plans. Last updated: 2025-11-25
|
| 4 |
|
| 5 |
## Active Technologies
|
|
|
|
|
|
|
| 6 |
|
| 7 |
- Python 3.11+ (Backend), TypeScript/React 18 (Frontend) + `react-force-graph-2d` (New), `FastAPI`, `sqlite3` (002-add-graph-view)
|
| 8 |
|
|
@@ -22,6 +24,7 @@ cd src [ONLY COMMANDS FOR ACTIVE TECHNOLOGIES][ONLY COMMANDS FOR ACTIVE TECHNOLO
|
|
| 22 |
Python 3.11+ (Backend), TypeScript/React 18 (Frontend): Follow standard conventions
|
| 23 |
|
| 24 |
## Recent Changes
|
|
|
|
| 25 |
|
| 26 |
- 002-add-graph-view: Added Python 3.11+ (Backend), TypeScript/React 18 (Frontend) + `react-force-graph-2d` (New), `FastAPI`, `sqlite3`
|
| 27 |
|
|
|
|
| 3 |
Auto-generated from all feature plans. Last updated: 2025-11-25
|
| 4 |
|
| 5 |
## Active Technologies
|
| 6 |
+
- Python 3.11+, TypeScript/React 18 + `fastmcp`, `fastapi`, `vite` (003-chatgpt-app-integration)
|
| 7 |
+
- No schema changes; relies on existing vault. (003-chatgpt-app-integration)
|
| 8 |
|
| 9 |
- Python 3.11+ (Backend), TypeScript/React 18 (Frontend) + `react-force-graph-2d` (New), `FastAPI`, `sqlite3` (002-add-graph-view)
|
| 10 |
|
|
|
|
| 24 |
Python 3.11+ (Backend), TypeScript/React 18 (Frontend): Follow standard conventions
|
| 25 |
|
| 26 |
## Recent Changes
|
| 27 |
+
- 003-chatgpt-app-integration: Added Python 3.11+, TypeScript/React 18 + `fastmcp`, `fastapi`, `vite`
|
| 28 |
|
| 29 |
- 002-add-graph-view: Added Python 3.11+ (Backend), TypeScript/React 18 (Frontend) + `react-force-graph-2d` (New), `FastAPI`, `sqlite3`
|
| 30 |
|
specs/003-chatgpt-app-integration/plan.md
CHANGED
|
@@ -1,104 +1,76 @@
|
|
| 1 |
-
# Implementation Plan:
|
| 2 |
|
| 3 |
-
**Branch**: `
|
| 4 |
-
**Input**: Feature specification from `/specs/
|
| 5 |
|
| 6 |
**Note**: This template is filled in by the `/speckit.plan` command. See `.specify/templates/commands/plan.md` for the execution workflow.
|
| 7 |
|
| 8 |
## Summary
|
| 9 |
|
| 10 |
-
|
| 11 |
|
| 12 |
## Technical Context
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
**
|
| 21 |
-
**
|
| 22 |
-
**
|
| 23 |
-
**Testing**: [e.g., pytest, XCTest, cargo test or NEEDS CLARIFICATION]
|
| 24 |
-
**Target Platform**: [e.g., Linux server, iOS 15+, WASM or NEEDS CLARIFICATION]
|
| 25 |
-
**Project Type**: [single/web/mobile - determines source structure]
|
| 26 |
-
**Performance Goals**: [domain-specific, e.g., 1000 req/s, 10k lines/sec, 60 fps or NEEDS CLARIFICATION]
|
| 27 |
-
**Constraints**: [domain-specific, e.g., <200ms p95, <100MB memory, offline-capable or NEEDS CLARIFICATION]
|
| 28 |
-
**Scale/Scope**: [domain-specific, e.g., 10k users, 1M LOC, 50 screens or NEEDS CLARIFICATION]
|
| 29 |
|
| 30 |
## Constitution Check
|
| 31 |
|
| 32 |
*GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.*
|
| 33 |
|
| 34 |
-
|
|
|
|
|
|
|
| 35 |
|
| 36 |
## Project Structure
|
| 37 |
|
| 38 |
### Documentation (this feature)
|
| 39 |
|
| 40 |
```text
|
| 41 |
-
specs/
|
| 42 |
-
├── plan.md # This file
|
| 43 |
-
├── research.md # Phase 0 output
|
| 44 |
-
├── data-model.md # Phase 1 output
|
| 45 |
-
├── quickstart.md # Phase 1 output
|
| 46 |
-
|
| 47 |
-
└── tasks.md # Phase 2 output (/speckit.tasks command - NOT created by /speckit.plan)
|
| 48 |
```
|
| 49 |
|
| 50 |
### Source Code (repository root)
|
| 51 |
-
<!--
|
| 52 |
-
ACTION REQUIRED: Replace the placeholder tree below with the concrete layout
|
| 53 |
-
for this feature. Delete unused options and expand the chosen structure with
|
| 54 |
-
real paths (e.g., apps/admin, packages/something). The delivered plan must
|
| 55 |
-
not include Option labels.
|
| 56 |
-
-->
|
| 57 |
|
| 58 |
```text
|
| 59 |
-
# [REMOVE IF UNUSED] Option 1: Single project (DEFAULT)
|
| 60 |
-
src/
|
| 61 |
-
├── models/
|
| 62 |
-
├── services/
|
| 63 |
-
├── cli/
|
| 64 |
-
└── lib/
|
| 65 |
-
|
| 66 |
-
tests/
|
| 67 |
-
├── contract/
|
| 68 |
-
├── integration/
|
| 69 |
-
└── unit/
|
| 70 |
-
|
| 71 |
-
# [REMOVE IF UNUSED] Option 2: Web application (when "frontend" + "backend" detected)
|
| 72 |
backend/
|
| 73 |
├── src/
|
| 74 |
-
│ ├──
|
|
|
|
|
|
|
|
|
|
| 75 |
│ ├── services/
|
| 76 |
-
│
|
|
|
|
|
|
|
|
|
|
| 77 |
└── tests/
|
|
|
|
|
|
|
| 78 |
|
| 79 |
frontend/
|
| 80 |
-
├──
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
└── tests/
|
| 85 |
-
|
| 86 |
-
# [REMOVE IF UNUSED] Option 3: Mobile + API (when "iOS/Android" detected)
|
| 87 |
-
api/
|
| 88 |
-
└── [same as backend above]
|
| 89 |
-
|
| 90 |
-
ios/ or android/
|
| 91 |
-
└── [platform-specific structure: feature modules, UI flows, platform tests]
|
| 92 |
```
|
| 93 |
|
| 94 |
-
**Structure Decision**:
|
| 95 |
-
directories captured above]
|
| 96 |
|
| 97 |
## Complexity Tracking
|
| 98 |
|
| 99 |
-
> **Fill ONLY if Constitution Check has violations that must be justified**
|
| 100 |
-
|
| 101 |
| Violation | Why Needed | Simpler Alternative Rejected Because |
|
| 102 |
|-----------|------------|-------------------------------------|
|
| 103 |
-
|
|
| 104 |
-
| [e.g., Repository pattern] | [specific problem] | [why direct DB access insufficient] |
|
|
|
|
| 1 |
+
# Implementation Plan: ChatGPT App Integration
|
| 2 |
|
| 3 |
+
**Branch**: `003-chatgpt-app-integration` | **Date**: 2025-11-26 | **Spec**: [spec.md](spec.md)
|
| 4 |
+
**Input**: Feature specification from `/specs/003-chatgpt-app-integration/spec.md`
|
| 5 |
|
| 6 |
**Note**: This template is filled in by the `/speckit.plan` command. See `.specify/templates/commands/plan.md` for the execution workflow.
|
| 7 |
|
| 8 |
## Summary
|
| 9 |
|
| 10 |
+
Adapt the backend to support ChatGPT Apps SDK by adding a static service token auth strategy, configuring CORS for ChatGPT, and updating MCP tools to return metadata for widget rendering. Create a standalone `widget.html` entry point in the frontend.
|
| 11 |
|
| 12 |
## Technical Context
|
| 13 |
|
| 14 |
+
**Language/Version**: Python 3.11+, TypeScript/React 18
|
| 15 |
+
**Primary Dependencies**: `fastmcp`, `fastapi`, `vite`
|
| 16 |
+
**Storage**: No schema changes; relies on existing vault.
|
| 17 |
+
**Testing**: `pytest` for auth/tools; manual verification for widgets.
|
| 18 |
+
**Target Platform**: Hugging Face Spaces (Docker) + ChatGPT UI.
|
| 19 |
+
**Project Type**: Full Stack (Backend API + Frontend Widget).
|
| 20 |
+
**Performance Goals**: Widget load < 500ms.
|
| 21 |
+
**Constraints**: Must work alongside existing "local dev" and "HF OAuth" modes.
|
| 22 |
+
**Scale/Scope**: Demo scale (single tenant impersonation via service token).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
## Constitution Check
|
| 25 |
|
| 26 |
*GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.*
|
| 27 |
|
| 28 |
+
- **Brownfield Integration**: Respects existing auth structure (adding a strategy, not rewriting). Reuses `NoteViewer` component.
|
| 29 |
+
- **Test-Backed**: New auth strategy will be unit tested.
|
| 30 |
+
- **Simplicity**: Using static token instead of full OIDC.
|
| 31 |
|
| 32 |
## Project Structure
|
| 33 |
|
| 34 |
### Documentation (this feature)
|
| 35 |
|
| 36 |
```text
|
| 37 |
+
specs/003-chatgpt-app-integration/
|
| 38 |
+
├── plan.md # This file
|
| 39 |
+
├── research.md # Phase 0 output
|
| 40 |
+
├── data-model.md # Phase 1 output
|
| 41 |
+
├── quickstart.md # Phase 1 output
|
| 42 |
+
└── tasks.md # Phase 2 output
|
|
|
|
| 43 |
```
|
| 44 |
|
| 45 |
### Source Code (repository root)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
```text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
backend/
|
| 49 |
├── src/
|
| 50 |
+
│ ├── api/
|
| 51 |
+
│ │ ├── main.py # Update: CORS, widget route
|
| 52 |
+
│ │ └── middleware/
|
| 53 |
+
│ │ └── auth_middleware.py # Update: Strategy usage
|
| 54 |
│ ├── services/
|
| 55 |
+
│ │ ├── auth.py # Update: Refactor to Strategy pattern
|
| 56 |
+
│ │ └── config.py # Update: New config fields
|
| 57 |
+
│ └── mcp/
|
| 58 |
+
│ └── server.py # Update: Tool return types
|
| 59 |
└── tests/
|
| 60 |
+
└── unit/
|
| 61 |
+
└── test_auth_strategy.py # New test
|
| 62 |
|
| 63 |
frontend/
|
| 64 |
+
├── vite.config.ts # Update: Multi-page build
|
| 65 |
+
├── widget.html # New: Widget entry point
|
| 66 |
+
└── src/
|
| 67 |
+
└── widget.tsx # New: Widget root component
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
```
|
| 69 |
|
| 70 |
+
**Structure Decision**: Multi-page build for Frontend; Strategy pattern for Backend Auth.
|
|
|
|
| 71 |
|
| 72 |
## Complexity Tracking
|
| 73 |
|
|
|
|
|
|
|
| 74 |
| Violation | Why Needed | Simpler Alternative Rejected Because |
|
| 75 |
|-----------|------------|-------------------------------------|
|
| 76 |
+
| Multi-page Vite | To isolate widget styles/scripts from main app | Iframing the full app is too heavy and leaky for ChatGPT widgets. |
|
|
|
specs/003-chatgpt-app-integration/quickstart.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Quickstart: ChatGPT App Integration
|
| 2 |
+
|
| 3 |
+
## Prerequisites
|
| 4 |
+
- Existing backend running.
|
| 5 |
+
- `CHATGPT_SERVICE_TOKEN` set in environment.
|
| 6 |
+
|
| 7 |
+
## Testing the Integration
|
| 8 |
+
|
| 9 |
+
### 1. Authentication
|
| 10 |
+
```bash
|
| 11 |
+
# Test service token access
|
| 12 |
+
curl -H "Authorization: Bearer <your-service-token>" http://localhost:8000/api/notes
|
| 13 |
+
```
|
| 14 |
+
|
| 15 |
+
### 2. Widget Serving
|
| 16 |
+
```bash
|
| 17 |
+
# Test widget endpoint
|
| 18 |
+
curl -v http://localhost:8000/widget/note
|
| 19 |
+
# Expect: Content-Type: text/html+skybridge (or similar)
|
| 20 |
+
```
|
| 21 |
+
|
| 22 |
+
### 3. Tool Metadata
|
| 23 |
+
```bash
|
| 24 |
+
# Test tool call via /mcp endpoint
|
| 25 |
+
curl -X POST http://localhost:8000/mcp \
|
| 26 |
+
-H "Content-Type: application/json" \
|
| 27 |
+
-d '{
|
| 28 |
+
"jsonrpc": "2.0",
|
| 29 |
+
"method": "tools/call",
|
| 30 |
+
"params": {
|
| 31 |
+
"name": "read_note",
|
| 32 |
+
"arguments": {"note_path": "Welcome.md"}
|
| 33 |
+
},
|
| 34 |
+
"id": 1
|
| 35 |
+
}'
|
| 36 |
+
# Expect response to contain _meta.openai.outputTemplate
|
| 37 |
+
```
|
| 38 |
+
|
specs/003-chatgpt-app-integration/tasks.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Tasks: ChatGPT App Integration
|
| 2 |
+
|
| 3 |
+
**Feature**: 003-chatgpt-app-integration
|
| 4 |
+
**Status**: Pending
|
| 5 |
+
**Spec**: [spec.md](spec.md)
|
| 6 |
+
|
| 7 |
+
## Phase 1: Setup (Project Initialization)
|
| 8 |
+
|
| 9 |
+
*Goal: Configure build pipelines and backend settings to support the new widget and auth modes.*
|
| 10 |
+
|
| 11 |
+
- [ ] T001 Update `backend/src/services/config.py` to include `chatgpt_service_token` and `chatgpt_cors_origin` fields
|
| 12 |
+
- [ ] T002 Update `frontend/vite.config.ts` to support multi-page build (`index.html` and `widget.html`)
|
| 13 |
+
- [ ] T003 Create `frontend/widget.html` as the entry point for the ChatGPT widget
|
| 14 |
+
- [ ] T004 Create `frontend/src/widget.tsx` as the root React component for the widget
|
| 15 |
+
|
| 16 |
+
## Phase 2: Foundational Tasks
|
| 17 |
+
|
| 18 |
+
*Goal: Establish authentication and infrastructure required for the integration.*
|
| 19 |
+
|
| 20 |
+
- [ ] T005 Refactor `backend/src/services/auth.py` to implement Strategy pattern (`JWTValidator` and `StaticTokenValidator`)
|
| 21 |
+
- [ ] T006 [P] Create unit tests for new Auth Strategy in `backend/tests/unit/test_auth_strategy.py`
|
| 22 |
+
- [ ] T007 Update `backend/src/api/middleware/auth_middleware.py` to use the new Auth Service strategies
|
| 23 |
+
- [ ] T008 Update `backend/src/api/main.py` to configure CORS for `https://chatgpt.com`
|
| 24 |
+
- [ ] T009 [P] Update `backend/src/api/main.py` to serve `widget.html` on `/widget` route with `text/html+skybridge` MIME type
|
| 25 |
+
|
| 26 |
+
## Phase 3: User Story 1 - The Recall Loop
|
| 27 |
+
|
| 28 |
+
*Goal: Enable searching and viewing notes within ChatGPT.*
|
| 29 |
+
|
| 30 |
+
- [ ] T010 [US1] Extract `NoteViewer` component logic into a reusable pure component (if not already) in `frontend/src/components/NoteViewer.tsx`
|
| 31 |
+
- [ ] T011 [P] [US1] Create `SearchWidget` component in `frontend/src/components/SearchWidget.tsx` for the widget view
|
| 32 |
+
- [ ] T012 [US1] Implement `WidgetApp` component in `frontend/src/widget.tsx` to handle routing between Note and Search views based on props/URL
|
| 33 |
+
- [ ] T013 [US1] Update `backend/src/mcp/server.py` `read_note` tool to return `CallToolResult` with `_meta.openai.outputTemplate`
|
| 34 |
+
- [ ] T014 [US1] Update `backend/src/mcp/server.py` `search_notes` tool to return `CallToolResult` with `_meta.openai.outputTemplate`
|
| 35 |
+
|
| 36 |
+
## Phase 4: User Story 2 - In-Context Editing
|
| 37 |
+
|
| 38 |
+
*Goal: Enable editing notes from ChatGPT interactions.*
|
| 39 |
+
|
| 40 |
+
- [ ] T015 [US2] Verify `write_note` tool functionality with Service Token auth (no code change expected if T007 is correct, but validation needed)
|
| 41 |
+
- [ ] T016 [US2] Implement auto-refresh or status indication in `WidgetApp` when a note is updated externally (by ChatGPT)
|
| 42 |
+
|
| 43 |
+
## Final Phase: Polish
|
| 44 |
+
|
| 45 |
+
*Goal: Ensure seamless experience and robustness.*
|
| 46 |
+
|
| 47 |
+
- [ ] T017 Verify widget load performance and optimize bundle size if needed
|
| 48 |
+
- [ ] T018 Add error boundary to `WidgetApp` to handle load failures gracefully inside the iframe
|
| 49 |
+
|
| 50 |
+
## Dependencies
|
| 51 |
+
|
| 52 |
+
1. **Setup (T001-T004)**: Must be done first to enable widget development.
|
| 53 |
+
2. **Foundational (T005-T009)**: Auth and serving infrastructure required before widgets can be loaded by ChatGPT.
|
| 54 |
+
3. **US1 (T010-T014)**: Depends on Foundational. T013/T014 depend on T009 (widget serving).
|
| 55 |
+
4. **US2 (T015-T016)**: Depends on US1.
|
| 56 |
+
|
| 57 |
+
## Parallel Execution Strategy
|
| 58 |
+
|
| 59 |
+
- **Frontend vs Backend**: T002-T004 (Frontend Setup) can run parallel to T001 & T005-T008 (Backend Auth).
|
| 60 |
+
- **Within US1**: T011 (Search Widget UI) and T013/T014 (MCP Tool Updates) can be done in parallel.
|
| 61 |
+
|
| 62 |
+
## Implementation Strategy
|
| 63 |
+
|
| 64 |
+
1. **Infrastructure First**: Get the backend serving the widget HTML and accepting the service token.
|
| 65 |
+
2. **Widget Shell**: Build the minimal widget shell that can display *something*.
|
| 66 |
+
3. **Tool Connection**: Wire up the MCP tools to point to the widget.
|
| 67 |
+
4. **Features**: Flesh out the Viewer and Search capabilities.
|