add cmd lexicon

This commit is contained in:
2026-01-18 12:15:43 +09:00
parent 28eb463b74
commit 5f017d30cb
16 changed files with 1589 additions and 50 deletions

View File

@@ -152,13 +152,20 @@ curl "https://syu.is/xrpc/com.atproto.repo.listRecords?repo=did:plc:xxx&collecti
### Local (Static File)
```
public/records/ai.syui.log.post/3xxx.json
content/
└── did:plc:xxx/
├── describe.json # describeRepo (special)
├── app.bsky.actor.profile/
│ └── self.json # {collection}/{rkey}.json
└── ai.syui.log.post/
└── 3xxx.json # {collection}/{rkey}.json
```
```json
// content/did:plc:xxx/ai.syui.log.post/3xxx.json
{
"uri": "at://did:plc:xxx/ai.syui.log.post/3xxx",
"cid": "local",
"cid": "bafyrei...",
"value": {
"title": "Hello World",
"content": "# Hello\n\nThis is my post.",
@@ -167,13 +174,23 @@ public/records/ai.syui.log.post/3xxx.json
}
```
### ATProto API Reference
| API | Path | Description |
|-----|------|-------------|
| getRecord | `/xrpc/com.atproto.repo.getRecord` | Get single record |
| listRecords | `/xrpc/com.atproto.repo.listRecords` | List records in collection |
| describeRepo | `/xrpc/com.atproto.repo.describeRepo` | Get repo info + collections list |
See: [com.atproto.repo.describeRepo](https://docs.bsky.app/docs/api/com-atproto-repo-describe-repo)
### Resolution Strategy
```
at-browser
├── admin (config.json user)
│ ├── 1. Check local: /records/{collection}/{rkey}.json
│ ├── 1. Check local: /content/{did}/{collection}/{rkey}.json
│ └── 2. Fallback to remote: PDS API
└── user (/@handle)
@@ -202,11 +219,87 @@ at-browser
## Tech Stack
- **CLI**: Rust (ailog)
- **Frontend**: Vite + TypeScript
- **ATProto**: @atproto/api
- **OAuth**: @atproto/oauth-client-browser
- **Markdown**: marked + highlight.js
## CLI (ailog)
### Install
```bash
cargo build --release
cp target/release/ailog ~/.local/bin/
```
### Commands
```bash
# Login to ATProto PDS
ailog login <handle> -p <password> [-s <server>]
# Post a record
ailog post <file.json> -c <collection> [-r <rkey>]
# Get records from collection
ailog get -c <collection> [-l <limit>]
# Delete a record
ailog delete -c <collection> -r <rkey>
# Sync PDS data to local content directory
ailog sync [-o <output>]
# Generate lexicon Rust code from ATProto lexicons
ailog gen [-i <input>] [-o <output>]
```
### Example
```bash
# Login
ailog login syui.syui.ai -p "app-password" -s syu.is
# Post
echo '{"title":"Hello","content":"World","createdAt":"2025-01-01T00:00:00Z"}' > post.json
ailog post post.json -c ai.syui.log.post
# Sync to local
ailog sync -o content
```
### Project Structure
```
src/
├── main.rs
├── commands/
│ ├── mod.rs
│ ├── auth.rs # login, refresh session
│ ├── token.rs # token management
│ ├── post.rs # post, get, delete, sync
│ └── gen.rs # lexicon code generation
└── lexicons/
└── mod.rs # auto-generated from ATProto lexicons
```
### Lexicon Generation
Generate Rust endpoint definitions from ATProto lexicon JSON files:
```bash
# Clone atproto repo (if not exists)
git clone https://github.com/bluesky-social/atproto repos/atproto
# Generate lexicons
ailog gen -i ./repos/atproto/lexicons -o ./src/lexicons
# Rebuild
cargo build
```
## Collection Schema
### ai.syui.log.post