Skip to content

Conversation

@davewaring
Copy link
Contributor

Summary

Implements Phase 1 & 2 of the library-integration project - core filesystem primitives for accessing the BrainDrive Library.

Project: library-integration

Endpoints

Method Endpoint Auth Description
GET /api/v1/fs/config User Get Library configuration (path, exists)
GET /api/v1/fs/read?path=... User Read file content
POST /api/v1/fs/write User Create/replace file
POST /api/v1/fs/append User Append to file
GET /api/v1/fs/list?path=... User List directory contents
DELETE /api/v1/fs/delete?path=... Admin Delete file
POST /api/v1/fs/init User Initialize Library with starter content

Configuration

  • LIBRARY_PATH setting added to config.py
  • Default: ~/BrainDrive-Library
  • Supports .env override
  • Tilde expansion for home directory

Security

  • Path traversal prevention (blocks ..)
  • Restricted to text file extensions: .md, .txt, .json, .yaml, .yml
  • Delete requires admin authentication
  • All endpoints require user authentication

Files Changed

  • backend/app/api/v1/endpoints/fs.py - New filesystem API endpoints (773 lines)
  • backend/app/api/v1/api.py - Router registration
  • backend/app/core/config.py - LIBRARY_PATH configuration

Test Plan

  • Test read endpoint with valid path
  • Test read endpoint with path traversal (should 403)
  • Test write endpoint creates new file
  • Test write endpoint with invalid extension (should 400)
  • Test list endpoint returns directory contents
  • Test delete as non-admin (should 403)
  • Test delete as admin (should succeed)
  • Test init creates starter content

Related

  • Closes Phase 1 & 2 of library-integration
  • Chat UI integration (Phase 3) already complete in BrainDriveChat plugin v1.0.26

🤖 Generated with Claude Code

Implements Phase 1 & 2 of library-integration project:

Endpoints:
- GET /api/v1/fs/config - Get Library configuration (path, exists)
- GET /api/v1/fs/read - Read file content
- POST /api/v1/fs/write - Create/replace file
- POST /api/v1/fs/append - Append to file
- GET /api/v1/fs/list - List directory contents
- DELETE /api/v1/fs/delete - Delete file (admin only)
- POST /api/v1/fs/init - Initialize Library with starter content

Configuration:
- LIBRARY_PATH setting in config.py (default: ~/BrainDrive-Library)
- Supports .env override
- Tilde expansion for home directory

Security:
- Path traversal prevention
- Restricted to text file extensions (.md, .txt, .json, .yaml, .yml)
- Delete requires admin authentication
- All endpoints require user authentication

See: projects/active/library-integration/build-plan.md

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants