@delfos-ai/cli 1.0.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/README.md +93 -0
- package/dist/api/delfos-api.client.d.ts +32 -0
- package/dist/api/delfos-api.client.d.ts.map +1 -0
- package/dist/api/delfos-api.client.js +43 -0
- package/dist/api/delfos-api.client.js.map +1 -0
- package/dist/commands/login.command.d.ts +15 -0
- package/dist/commands/login.command.d.ts.map +1 -0
- package/dist/commands/login.command.js +164 -0
- package/dist/commands/login.command.js.map +1 -0
- package/dist/commands/logout.command.d.ts +8 -0
- package/dist/commands/logout.command.d.ts.map +1 -0
- package/dist/commands/logout.command.js +46 -0
- package/dist/commands/logout.command.js.map +1 -0
- package/dist/commands/mcp/mcp-memory.command.d.ts +11 -0
- package/dist/commands/mcp/mcp-memory.command.d.ts.map +1 -0
- package/dist/commands/mcp/mcp-memory.command.js +22 -0
- package/dist/commands/mcp/mcp-memory.command.js.map +1 -0
- package/dist/commands/memory/index.d.ts +3 -0
- package/dist/commands/memory/index.d.ts.map +1 -0
- package/dist/commands/memory/index.js +14 -0
- package/dist/commands/memory/index.js.map +1 -0
- package/dist/commands/memory/memory-index.command.d.ts +3 -0
- package/dist/commands/memory/memory-index.command.d.ts.map +1 -0
- package/dist/commands/memory/memory-index.command.js +57 -0
- package/dist/commands/memory/memory-index.command.js.map +1 -0
- package/dist/commands/memory/memory-init.command.d.ts +3 -0
- package/dist/commands/memory/memory-init.command.d.ts.map +1 -0
- package/dist/commands/memory/memory-init.command.js +72 -0
- package/dist/commands/memory/memory-init.command.js.map +1 -0
- package/dist/commands/memory/memory-read.command.d.ts +3 -0
- package/dist/commands/memory/memory-read.command.d.ts.map +1 -0
- package/dist/commands/memory/memory-read.command.js +52 -0
- package/dist/commands/memory/memory-read.command.js.map +1 -0
- package/dist/commands/memory/memory-status.command.d.ts +7 -0
- package/dist/commands/memory/memory-status.command.d.ts.map +1 -0
- package/dist/commands/memory/memory-status.command.js +43 -0
- package/dist/commands/memory/memory-status.command.js.map +1 -0
- package/dist/commands/memory/memory-write.command.d.ts +3 -0
- package/dist/commands/memory/memory-write.command.d.ts.map +1 -0
- package/dist/commands/memory/memory-write.command.js +66 -0
- package/dist/commands/memory/memory-write.command.js.map +1 -0
- package/dist/config/cli-config.d.ts +13 -0
- package/dist/config/cli-config.d.ts.map +1 -0
- package/dist/config/cli-config.js +31 -0
- package/dist/config/cli-config.js.map +1 -0
- package/dist/config/memory.config.d.ts +61 -0
- package/dist/config/memory.config.d.ts.map +1 -0
- package/dist/config/memory.config.js +22 -0
- package/dist/config/memory.config.js.map +1 -0
- package/dist/features/memory-index/index.d.ts +5 -0
- package/dist/features/memory-index/index.d.ts.map +1 -0
- package/dist/features/memory-index/index.js +3 -0
- package/dist/features/memory-index/index.js.map +1 -0
- package/dist/features/memory-index/memory-index.schema.d.ts +96 -0
- package/dist/features/memory-index/memory-index.schema.d.ts.map +1 -0
- package/dist/features/memory-index/memory-index.schema.js +14 -0
- package/dist/features/memory-index/memory-index.schema.js.map +1 -0
- package/dist/features/memory-index/vault-indexer.d.ts +17 -0
- package/dist/features/memory-index/vault-indexer.d.ts.map +1 -0
- package/dist/features/memory-index/vault-indexer.js +140 -0
- package/dist/features/memory-index/vault-indexer.js.map +1 -0
- package/dist/features/memory-init/vault-scaffolder.d.ts +20 -0
- package/dist/features/memory-init/vault-scaffolder.d.ts.map +1 -0
- package/dist/features/memory-init/vault-scaffolder.js +109 -0
- package/dist/features/memory-init/vault-scaffolder.js.map +1 -0
- package/dist/features/memory-read/index.d.ts +4 -0
- package/dist/features/memory-read/index.d.ts.map +1 -0
- package/dist/features/memory-read/index.js +3 -0
- package/dist/features/memory-read/index.js.map +1 -0
- package/dist/features/memory-read/memory-read.schema.d.ts +79 -0
- package/dist/features/memory-read/memory-read.schema.d.ts.map +1 -0
- package/dist/features/memory-read/memory-read.schema.js +25 -0
- package/dist/features/memory-read/memory-read.schema.js.map +1 -0
- package/dist/features/memory-read/rag-reader.d.ts +8 -0
- package/dist/features/memory-read/rag-reader.d.ts.map +1 -0
- package/dist/features/memory-read/rag-reader.js +79 -0
- package/dist/features/memory-read/rag-reader.js.map +1 -0
- package/dist/features/memory-server/config-loader.d.ts +6 -0
- package/dist/features/memory-server/config-loader.d.ts.map +1 -0
- package/dist/features/memory-server/config-loader.js +39 -0
- package/dist/features/memory-server/config-loader.js.map +1 -0
- package/dist/features/memory-server/index.d.ts +5 -0
- package/dist/features/memory-server/index.d.ts.map +1 -0
- package/dist/features/memory-server/index.js +4 -0
- package/dist/features/memory-server/index.js.map +1 -0
- package/dist/features/memory-server/memory-server.d.ts +6 -0
- package/dist/features/memory-server/memory-server.d.ts.map +1 -0
- package/dist/features/memory-server/memory-server.js +197 -0
- package/dist/features/memory-server/memory-server.js.map +1 -0
- package/dist/features/memory-server/memory-server.schema.d.ts +194 -0
- package/dist/features/memory-server/memory-server.schema.d.ts.map +1 -0
- package/dist/features/memory-server/memory-server.schema.js +58 -0
- package/dist/features/memory-server/memory-server.schema.js.map +1 -0
- package/dist/features/memory-server/tools/memory-index.handler.d.ts +10 -0
- package/dist/features/memory-server/tools/memory-index.handler.d.ts.map +1 -0
- package/dist/features/memory-server/tools/memory-index.handler.js +27 -0
- package/dist/features/memory-server/tools/memory-index.handler.js.map +1 -0
- package/dist/features/memory-server/tools/memory-read.handler.d.ts +10 -0
- package/dist/features/memory-server/tools/memory-read.handler.d.ts.map +1 -0
- package/dist/features/memory-server/tools/memory-read.handler.js +33 -0
- package/dist/features/memory-server/tools/memory-read.handler.js.map +1 -0
- package/dist/features/memory-server/tools/memory-status.handler.d.ts +9 -0
- package/dist/features/memory-server/tools/memory-status.handler.d.ts.map +1 -0
- package/dist/features/memory-server/tools/memory-status.handler.js +35 -0
- package/dist/features/memory-server/tools/memory-status.handler.js.map +1 -0
- package/dist/features/memory-server/tools/memory-write.handler.d.ts +8 -0
- package/dist/features/memory-server/tools/memory-write.handler.d.ts.map +1 -0
- package/dist/features/memory-server/tools/memory-write.handler.js +42 -0
- package/dist/features/memory-server/tools/memory-write.handler.js.map +1 -0
- package/dist/features/memory-shared/chunker.d.ts +16 -0
- package/dist/features/memory-shared/chunker.d.ts.map +1 -0
- package/dist/features/memory-shared/chunker.js +93 -0
- package/dist/features/memory-shared/chunker.js.map +1 -0
- package/dist/features/memory-shared/markdown-parser.d.ts +7 -0
- package/dist/features/memory-shared/markdown-parser.d.ts.map +1 -0
- package/dist/features/memory-shared/markdown-parser.js +24 -0
- package/dist/features/memory-shared/markdown-parser.js.map +1 -0
- package/dist/features/memory-shared/vault-path-validator.d.ts +14 -0
- package/dist/features/memory-shared/vault-path-validator.d.ts.map +1 -0
- package/dist/features/memory-shared/vault-path-validator.js +56 -0
- package/dist/features/memory-shared/vault-path-validator.js.map +1 -0
- package/dist/features/memory-shared/vault-scanner.d.ts +8 -0
- package/dist/features/memory-shared/vault-scanner.d.ts.map +1 -0
- package/dist/features/memory-shared/vault-scanner.js +35 -0
- package/dist/features/memory-shared/vault-scanner.js.map +1 -0
- package/dist/features/memory-shared/vault-slug.d.ts +9 -0
- package/dist/features/memory-shared/vault-slug.d.ts.map +1 -0
- package/dist/features/memory-shared/vault-slug.js +17 -0
- package/dist/features/memory-shared/vault-slug.js.map +1 -0
- package/dist/features/memory-write/index.d.ts +6 -0
- package/dist/features/memory-write/index.d.ts.map +1 -0
- package/dist/features/memory-write/index.js +4 -0
- package/dist/features/memory-write/index.js.map +1 -0
- package/dist/features/memory-write/memory-write.schema.d.ts +36 -0
- package/dist/features/memory-write/memory-write.schema.d.ts.map +1 -0
- package/dist/features/memory-write/memory-write.schema.js +14 -0
- package/dist/features/memory-write/memory-write.schema.js.map +1 -0
- package/dist/features/memory-write/note-formatter.d.ts +11 -0
- package/dist/features/memory-write/note-formatter.d.ts.map +1 -0
- package/dist/features/memory-write/note-formatter.js +38 -0
- package/dist/features/memory-write/note-formatter.js.map +1 -0
- package/dist/features/memory-write/vault-writer.d.ts +6 -0
- package/dist/features/memory-write/vault-writer.d.ts.map +1 -0
- package/dist/features/memory-write/vault-writer.js +61 -0
- package/dist/features/memory-write/vault-writer.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/embeddings/embedding-provider.d.ts +9 -0
- package/dist/infrastructure/embeddings/embedding-provider.d.ts.map +1 -0
- package/dist/infrastructure/embeddings/embedding-provider.js +5 -0
- package/dist/infrastructure/embeddings/embedding-provider.js.map +1 -0
- package/dist/infrastructure/embeddings/local-embedding.provider.d.ts +18 -0
- package/dist/infrastructure/embeddings/local-embedding.provider.d.ts.map +1 -0
- package/dist/infrastructure/embeddings/local-embedding.provider.js +38 -0
- package/dist/infrastructure/embeddings/local-embedding.provider.js.map +1 -0
- package/dist/infrastructure/logger/index.d.ts +21 -0
- package/dist/infrastructure/logger/index.d.ts.map +1 -0
- package/dist/infrastructure/logger/index.js +116 -0
- package/dist/infrastructure/logger/index.js.map +1 -0
- package/dist/infrastructure/vector-db/chroma.adapter.d.ts +76 -0
- package/dist/infrastructure/vector-db/chroma.adapter.d.ts.map +1 -0
- package/dist/infrastructure/vector-db/chroma.adapter.js +137 -0
- package/dist/infrastructure/vector-db/chroma.adapter.js.map +1 -0
- package/dist/utils/config.d.ts +13 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +13 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/pkce.d.ts +17 -0
- package/dist/utils/pkce.d.ts.map +1 -0
- package/dist/utils/pkce.js +28 -0
- package/dist/utils/pkce.js.map +1 -0
- package/dist/utils/port.d.ts +7 -0
- package/dist/utils/port.d.ts.map +1 -0
- package/dist/utils/port.js +33 -0
- package/dist/utils/port.js.map +1 -0
- package/package.json +59 -0
- package/templates/.gitkeep +0 -0
- package/templates/obsidian-vault/AI-Context/global-rules.md +129 -0
- package/templates/obsidian-vault/AI-Context/tool-preferences.md +128 -0
- package/templates/obsidian-vault/Patterns/architecture-patterns.md +147 -0
- package/templates/obsidian-vault/Patterns/coding-standards.md +90 -0
- package/templates/obsidian-vault/Projects/example-project/Decisions/example-decision.md +51 -0
- package/templates/obsidian-vault/Projects/example-project/Migrations/example-migration.md +85 -0
- package/templates/obsidian-vault/Projects/example-project/Overview.md +43 -0
- package/templates/obsidian-vault/Projects/example-project/Sessions/session-1.md +66 -0
- package/templates/obsidian-vault/Templates/decision.md +57 -0
- package/templates/obsidian-vault/Templates/migration.md +86 -0
- package/templates/obsidian-vault/Templates/session.md +87 -0
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@delfos-ai/cli",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "Delfos CLI — AI Layer tools for the terminal",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"private": false,
|
|
7
|
+
"type": "module",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=22.0.0"
|
|
10
|
+
},
|
|
11
|
+
"files": ["dist", "templates", "README.md"],
|
|
12
|
+
"bin": {
|
|
13
|
+
"delfos": "dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"dev": "tsx watch src/index.ts",
|
|
20
|
+
"build": "tsc --project tsconfig.build.json",
|
|
21
|
+
"test": "jest",
|
|
22
|
+
"lint": "eslint src --ext .ts",
|
|
23
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
24
|
+
"test:coverage": "jest --coverage",
|
|
25
|
+
"typecheck": "tsc --noEmit --project tsconfig.build.json"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@huggingface/transformers": "^4.2.0",
|
|
29
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
30
|
+
"chalk": "^5.6.2",
|
|
31
|
+
"chromadb": "^3.4.3",
|
|
32
|
+
"cli-table3": "^0.6.5",
|
|
33
|
+
"commander": "^14.0.3",
|
|
34
|
+
"dotenv": "^17.4.2",
|
|
35
|
+
"gray-matter": "^4.0.3",
|
|
36
|
+
"inquirer": "^13.4.2",
|
|
37
|
+
"open": "^10.1.0",
|
|
38
|
+
"pino": "^10.0.0",
|
|
39
|
+
"zod": "^3.23.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/inquirer": "^9.0.0",
|
|
43
|
+
"@types/jest": "^29.5.0",
|
|
44
|
+
"@types/node": "^22.0.0",
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
46
|
+
"@typescript-eslint/parser": "^7.18.0",
|
|
47
|
+
"eslint": "^8.57.0",
|
|
48
|
+
"eslint-config-prettier": "^9.1.0",
|
|
49
|
+
"eslint-plugin-prettier": "^5.2.0",
|
|
50
|
+
"jest": "^29.7.0",
|
|
51
|
+
"prettier": "^3.3.0",
|
|
52
|
+
"ts-jest": "^29.1.4",
|
|
53
|
+
"ts-jest-mock-import-meta": "^1.3.2",
|
|
54
|
+
"ts-node": "^10.9.2",
|
|
55
|
+
"tsx": "^4.7.0",
|
|
56
|
+
"typescript": "^5.4.0",
|
|
57
|
+
"vitest": "^4.1.6"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Global Rules for AI Agents
|
|
3
|
+
tags:
|
|
4
|
+
- ai-context
|
|
5
|
+
- rules
|
|
6
|
+
created: {{date}}
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Global Rules for AI Agents
|
|
10
|
+
|
|
11
|
+
## Repository Context
|
|
12
|
+
|
|
13
|
+
This is the **Delfos AI Layers Backend** — a Node.js + Express.js + BullMQ API that serves as the centralized intelligence layer for autonomous and semi-autonomous development workflows.
|
|
14
|
+
|
|
15
|
+
## Tech Stack
|
|
16
|
+
|
|
17
|
+
- **Runtime**: Node.js 24+ LTS
|
|
18
|
+
- **Framework**: Express.js 5.x
|
|
19
|
+
- **Language**: TypeScript (strict mode, ESNext target)
|
|
20
|
+
- **Job Queue**: BullMQ 5.x with Redis
|
|
21
|
+
- **Validation**: Zod 3.x
|
|
22
|
+
- **CMS**: Directus 11.17 (REST API)
|
|
23
|
+
- **Cache**: Redis 7+
|
|
24
|
+
- **Testing**: Jest + Supertest
|
|
25
|
+
|
|
26
|
+
## Architecture Principles
|
|
27
|
+
|
|
28
|
+
### Vertical Slice Architecture (VSA)
|
|
29
|
+
|
|
30
|
+
All feature code MUST be in `features/<slice>/`. Global controllers or services are forbidden.
|
|
31
|
+
|
|
32
|
+
### Feature Slice Structure
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
features/<slice>/
|
|
36
|
+
<slice>.route.ts # Express router
|
|
37
|
+
<slice>.producer.ts # BullMQ job enqueuer
|
|
38
|
+
<slice>.worker.ts # Worker processor
|
|
39
|
+
<slice>.handler.ts # Business logic
|
|
40
|
+
<slice>.schema.ts # Zod validation schemas
|
|
41
|
+
index.ts # Re-exports
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Forbidden Patterns
|
|
45
|
+
|
|
46
|
+
- ❌ `src/controllers/` directory
|
|
47
|
+
- ❌ `src/services/` directory
|
|
48
|
+
- ❌ `console.log()` anywhere
|
|
49
|
+
- ❌ `import { logger }` inside features
|
|
50
|
+
- ❌ Installing AI SDKs (use native `fetch`)
|
|
51
|
+
|
|
52
|
+
## Code Style
|
|
53
|
+
|
|
54
|
+
| Element | Convention | Example |
|
|
55
|
+
|---|---|---|
|
|
56
|
+
| Files | kebab-case | `vault-scaffolder.ts` |
|
|
57
|
+
| Classes/Interfaces | PascalCase | `ScaffoldResult` |
|
|
58
|
+
| Functions/Variables | camelCase | `scaffoldVault` |
|
|
59
|
+
| Constants | UPPER_SNAKE_CASE | `MAX_RETRIES` |
|
|
60
|
+
| Feature dirs | lowercase-kebab | `memory-init/` |
|
|
61
|
+
|
|
62
|
+
## TypeScript Rules
|
|
63
|
+
|
|
64
|
+
- **No `any` types** - use explicit interfaces or Zod inference
|
|
65
|
+
- **ESNext target** - never ES2022 or older
|
|
66
|
+
- **`import type`** for type-only imports
|
|
67
|
+
- **Zod-inferred types** for job payloads
|
|
68
|
+
|
|
69
|
+
## Logging Rules
|
|
70
|
+
|
|
71
|
+
1. **L1 — Redaction**: Never log sensitive fields (API keys, tokens, passwords)
|
|
72
|
+
2. **L2 — Slice child**: Use `createSliceLogger('slice-name')` in features
|
|
73
|
+
3. **L3 — Job child**: Use `createJobLogger(job, sliceLogger)` in workers
|
|
74
|
+
4. **L4 — Transport**: JSON in production, pino-pretty in dev
|
|
75
|
+
5. **L5 — Fatal handlers**: Register first in `main.ts`
|
|
76
|
+
|
|
77
|
+
## BullMQ Rules
|
|
78
|
+
|
|
79
|
+
- Use `bullConnection` for BullMQ primitives (db: 1)
|
|
80
|
+
- Use `cacheConnection` for cache (db: 0)
|
|
81
|
+
- `maxRetriesPerRequest: null` is mandatory for BullMQ
|
|
82
|
+
- Every worker must have DLQ handler
|
|
83
|
+
- QueueEvents requires `bullConnection.duplicate()`
|
|
84
|
+
|
|
85
|
+
## Directus Integration
|
|
86
|
+
|
|
87
|
+
- Include `Authorization: Bearer ${DIRECTUS_SERVICE_TOKEN}` on every request
|
|
88
|
+
- Never prefix with `NEXT_PUBLIC_` (backend-only)
|
|
89
|
+
- Filter `is_active` server-side
|
|
90
|
+
|
|
91
|
+
## Security Rules
|
|
92
|
+
|
|
93
|
+
- BYOK keys must be encrypted, never logged
|
|
94
|
+
- Use native `fetch` for BYOK bridge (no AI SDKs)
|
|
95
|
+
- Validate all inputs with Zod
|
|
96
|
+
- Check for path traversal before file operations
|
|
97
|
+
|
|
98
|
+
## Validation Commands
|
|
99
|
+
|
|
100
|
+
Run after every implementation phase:
|
|
101
|
+
```bash
|
|
102
|
+
npm run build # TypeScript compilation
|
|
103
|
+
npm run lint # ESLint
|
|
104
|
+
npm test # Jest tests
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Branch Rules
|
|
108
|
+
|
|
109
|
+
- Working branch: `feat/<epic>-<story>`
|
|
110
|
+
- Never commit or push to `main`
|
|
111
|
+
|
|
112
|
+
## Commit Convention
|
|
113
|
+
|
|
114
|
+
Follow Conventional Commits:
|
|
115
|
+
```
|
|
116
|
+
feat(backend): add migration worker
|
|
117
|
+
fix(backend): resolve BullMQ timeout
|
|
118
|
+
refactor(operations): extract validation
|
|
119
|
+
chore(deps): update bullmq to 5.x
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Memory Integration Context
|
|
123
|
+
|
|
124
|
+
This vault is integrated with Delfos AI Layer for memory context. AI agents can reference:
|
|
125
|
+
- Technical decisions in `Decisions/`
|
|
126
|
+
- Migration notes in `Migrations/`
|
|
127
|
+
- Session summaries in `Sessions/`
|
|
128
|
+
- Coding standards in `Patterns/coding-standards.md`
|
|
129
|
+
- Architecture patterns in `Patterns/architecture-patterns.md`
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Tool Preferences for AI Agents
|
|
3
|
+
tags:
|
|
4
|
+
- ai-context
|
|
5
|
+
- preferences
|
|
6
|
+
created: {{date}}
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Tool Preferences for AI Agents
|
|
10
|
+
|
|
11
|
+
## Claude Code (Anthropic)
|
|
12
|
+
|
|
13
|
+
### When to Use
|
|
14
|
+
|
|
15
|
+
- Complex refactoring tasks requiring deep code understanding
|
|
16
|
+
- Architecture decisions and design discussions
|
|
17
|
+
- Code reviews with detailed explanations
|
|
18
|
+
|
|
19
|
+
### Preferences
|
|
20
|
+
|
|
21
|
+
- Use vertical slice architecture patterns
|
|
22
|
+
- Follow the coding standards in `Patterns/coding-standards.md`
|
|
23
|
+
- Always use `createSliceLogger` for logging
|
|
24
|
+
- Validate with Zod schemas
|
|
25
|
+
- Write tests following TDD principles
|
|
26
|
+
|
|
27
|
+
### Commands
|
|
28
|
+
|
|
29
|
+
- `/implement` - Execute backend user stories
|
|
30
|
+
- `/review` - Production readiness review
|
|
31
|
+
- `/fix` - Fix validation issues
|
|
32
|
+
|
|
33
|
+
## Windsurf
|
|
34
|
+
|
|
35
|
+
### When to Use
|
|
36
|
+
|
|
37
|
+
- Rapid prototyping and feature development
|
|
38
|
+
- Interactive coding sessions
|
|
39
|
+
- Real-time collaboration
|
|
40
|
+
|
|
41
|
+
### Preferences
|
|
42
|
+
|
|
43
|
+
- Maintain VSA structure
|
|
44
|
+
- Use TypeScript strict mode
|
|
45
|
+
- Follow the established patterns
|
|
46
|
+
- Run validation after changes
|
|
47
|
+
|
|
48
|
+
### Integration
|
|
49
|
+
|
|
50
|
+
- Use the Delfos MCP server for memory context
|
|
51
|
+
- Reference decisions in `Decisions/`
|
|
52
|
+
- Update session notes in `Sessions/`
|
|
53
|
+
|
|
54
|
+
## Cursor
|
|
55
|
+
|
|
56
|
+
### When to Use
|
|
57
|
+
|
|
58
|
+
- Quick code fixes and small edits
|
|
59
|
+
- Navigating large codebases
|
|
60
|
+
- Understanding existing code
|
|
61
|
+
|
|
62
|
+
### Preferences
|
|
63
|
+
|
|
64
|
+
- Don't modify architecture without approval
|
|
65
|
+
- Follow existing patterns
|
|
66
|
+
- Ask before making breaking changes
|
|
67
|
+
|
|
68
|
+
## Common Patterns Across All Tools
|
|
69
|
+
|
|
70
|
+
### File Organization
|
|
71
|
+
|
|
72
|
+
- Feature code in `features/<slice>/`
|
|
73
|
+
- Infrastructure in `infrastructure/`
|
|
74
|
+
- Shared utilities in `shared/`
|
|
75
|
+
- Configuration in `config/`
|
|
76
|
+
|
|
77
|
+
### Testing
|
|
78
|
+
|
|
79
|
+
- Unit tests: mock I/O, test in isolation
|
|
80
|
+
- Integration tests: real Redis/Directus
|
|
81
|
+
- Functional tests: Supertest against `createApp()`
|
|
82
|
+
|
|
83
|
+
### Validation
|
|
84
|
+
|
|
85
|
+
Always run after changes:
|
|
86
|
+
```bash
|
|
87
|
+
npm run typecheck
|
|
88
|
+
npm test
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Logging
|
|
92
|
+
|
|
93
|
+
Never use `console.log()`. Always use:
|
|
94
|
+
```typescript
|
|
95
|
+
const logger = createSliceLogger('slice-name');
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## MCP Server Integration
|
|
99
|
+
|
|
100
|
+
The Delfos MCP server provides:
|
|
101
|
+
- Memory context from this vault
|
|
102
|
+
- Technical decisions reference
|
|
103
|
+
- Coding standards lookup
|
|
104
|
+
- Architecture patterns reference
|
|
105
|
+
|
|
106
|
+
Configure in your IDE's MCP settings to enable AI agents to access this knowledge base.
|
|
107
|
+
|
|
108
|
+
## Tool-Specific Notes
|
|
109
|
+
|
|
110
|
+
### Claude Code
|
|
111
|
+
|
|
112
|
+
- Best for architecture decisions and complex refactoring
|
|
113
|
+
- Strong at understanding code context
|
|
114
|
+
- Good at explaining trade-offs
|
|
115
|
+
|
|
116
|
+
### Windsurf
|
|
117
|
+
|
|
118
|
+
- Best for rapid development
|
|
119
|
+
- Good for interactive sessions
|
|
120
|
+
- Strong real-time collaboration
|
|
121
|
+
|
|
122
|
+
### Cursor
|
|
123
|
+
|
|
124
|
+
- Best for quick fixes
|
|
125
|
+
- Good at code navigation
|
|
126
|
+
- Fast code understanding
|
|
127
|
+
|
|
128
|
+
Choose the right tool for the task at hand, but always maintain consistency with the established patterns and standards.
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Architecture Patterns
|
|
3
|
+
tags:
|
|
4
|
+
- patterns
|
|
5
|
+
- architecture
|
|
6
|
+
created: {{date}}
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Architecture Patterns
|
|
10
|
+
|
|
11
|
+
## Vertical Slice Architecture (VSA)
|
|
12
|
+
|
|
13
|
+
### Concept
|
|
14
|
+
|
|
15
|
+
Organize code by feature/business capability rather than technical layer. Each slice contains all code needed for that feature.
|
|
16
|
+
|
|
17
|
+
### Benefits
|
|
18
|
+
|
|
19
|
+
- High cohesion within features
|
|
20
|
+
- Low coupling between features
|
|
21
|
+
- Easier to delete or replace features
|
|
22
|
+
- Clear ownership boundaries
|
|
23
|
+
|
|
24
|
+
### Example Structure
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
src/features/memory-init/
|
|
28
|
+
vault-scaffolder.ts # Business logic
|
|
29
|
+
memory-init.command.ts # CLI entry point
|
|
30
|
+
__tests__/
|
|
31
|
+
vault-scaffolder.test.ts
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Repository Pattern
|
|
35
|
+
|
|
36
|
+
### Concept
|
|
37
|
+
|
|
38
|
+
Data access encapsulated in repository objects that abstract the underlying storage.
|
|
39
|
+
|
|
40
|
+
### Implementation
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
export const ObsidianConnectionsRepository = {
|
|
44
|
+
upsertConnection,
|
|
45
|
+
getByVaultPath,
|
|
46
|
+
updateLastSync,
|
|
47
|
+
};
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Benefits
|
|
51
|
+
|
|
52
|
+
- Single place for Directus API calls
|
|
53
|
+
- Easy to mock in tests
|
|
54
|
+
- Consistent error handling
|
|
55
|
+
|
|
56
|
+
## Worker Pattern
|
|
57
|
+
|
|
58
|
+
### Concept
|
|
59
|
+
|
|
60
|
+
Long-running tasks processed asynchronously by BullMQ workers.
|
|
61
|
+
|
|
62
|
+
### Standard Worker Configuration
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
{
|
|
66
|
+
connection: bullConnection,
|
|
67
|
+
concurrency: 10,
|
|
68
|
+
lockDuration: 60_000,
|
|
69
|
+
stalledInterval: 30_000,
|
|
70
|
+
limiter: { max: 10, duration: 60_000, groupKey: 'byokKeyId' },
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### DLQ Handler (Mandatory)
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
worker.on('failed', (job, err) => {
|
|
78
|
+
sliceLogger.error(
|
|
79
|
+
{ jobId: job?.id, userId: job?.data?.userId, err },
|
|
80
|
+
'[slice-name] failed permanently — DLQ',
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Logger Hierarchy
|
|
86
|
+
|
|
87
|
+
### Pattern
|
|
88
|
+
|
|
89
|
+
1. **Base logger**: Infrastructure-level (`src/infrastructure/logger/`)
|
|
90
|
+
2. **Slice logger**: Feature-level (`createSliceLogger('slice-name')`)
|
|
91
|
+
3. **Job logger**: Worker-level (`createJobLogger(job, sliceLogger)`)
|
|
92
|
+
|
|
93
|
+
### Benefits
|
|
94
|
+
|
|
95
|
+
- Automatic context propagation
|
|
96
|
+
- Redaction of sensitive fields
|
|
97
|
+
- Structured logging with consistent fields
|
|
98
|
+
|
|
99
|
+
## Configuration Pattern
|
|
100
|
+
|
|
101
|
+
### Concept
|
|
102
|
+
|
|
103
|
+
Environment-based configuration validated with Zod.
|
|
104
|
+
|
|
105
|
+
### Implementation
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
export const MemoryConfigSchema = z.object({
|
|
109
|
+
enabled: z.boolean().default(true),
|
|
110
|
+
vault_path: z.string().min(1),
|
|
111
|
+
// ...
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
export type MemoryConfig = z.infer<typeof MemoryConfigSchema>;
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Benefits
|
|
118
|
+
|
|
119
|
+
- Type-safe configuration
|
|
120
|
+
- Runtime validation
|
|
121
|
+
- Single source of truth
|
|
122
|
+
|
|
123
|
+
## Dependency Injection
|
|
124
|
+
|
|
125
|
+
### Concept
|
|
126
|
+
|
|
127
|
+
Pass dependencies as parameters rather than importing directly.
|
|
128
|
+
|
|
129
|
+
### Example
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
// Good
|
|
133
|
+
export async function scaffoldVault(
|
|
134
|
+
vaultPath: string,
|
|
135
|
+
templateDir: string,
|
|
136
|
+
): Promise<ScaffoldResult>
|
|
137
|
+
|
|
138
|
+
// Avoid
|
|
139
|
+
import { TEMPLATE_DIR } from '../config';
|
|
140
|
+
export async function scaffoldVault(vaultPath: string)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Benefits
|
|
144
|
+
|
|
145
|
+
- Easier testing (can inject mocks)
|
|
146
|
+
- Clear dependencies
|
|
147
|
+
- Flexible configuration
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Coding Standards
|
|
3
|
+
tags:
|
|
4
|
+
- patterns
|
|
5
|
+
- standards
|
|
6
|
+
created: {{date}}
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Coding Standards
|
|
10
|
+
|
|
11
|
+
## TypeScript
|
|
12
|
+
|
|
13
|
+
- Use **strict mode** - no `any` types allowed
|
|
14
|
+
- Use **Zod** for runtime validation with type inference
|
|
15
|
+
- Use `import type` for type-only imports
|
|
16
|
+
- Follow **ESNext** target (not ES2022 or older)
|
|
17
|
+
|
|
18
|
+
## File Naming
|
|
19
|
+
|
|
20
|
+
- **Files**: kebab-case (e.g., `vault-scaffolder.ts`)
|
|
21
|
+
- **Classes/Interfaces**: PascalCase
|
|
22
|
+
- **Functions/Variables**: camelCase
|
|
23
|
+
- **Constants**: UPPER_SNAKE_CASE
|
|
24
|
+
- **Feature directories**: lowercase-kebab (e.g., `memory-init/`)
|
|
25
|
+
|
|
26
|
+
## Architecture
|
|
27
|
+
|
|
28
|
+
### Vertical Slice Architecture (VSA)
|
|
29
|
+
|
|
30
|
+
All feature code lives in `features/<slice>/`:
|
|
31
|
+
```
|
|
32
|
+
features/<slice>/
|
|
33
|
+
<slice>.route.ts # Express router
|
|
34
|
+
<slice>.producer.ts # BullMQ job enqueuer
|
|
35
|
+
<slice>.worker.ts # Worker processor
|
|
36
|
+
<slice>.handler.ts # Business logic
|
|
37
|
+
<slice>.schema.ts # Zod validation schemas
|
|
38
|
+
index.ts # Re-exports
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Forbidden Patterns
|
|
42
|
+
|
|
43
|
+
- ❌ `src/controllers/` - violates VSA
|
|
44
|
+
- ❌ `src/services/` - violates VSA
|
|
45
|
+
- ❌ `console.log()` - always use Pino logger
|
|
46
|
+
- ❌ Global services - keep in feature slices
|
|
47
|
+
|
|
48
|
+
## Logging
|
|
49
|
+
|
|
50
|
+
Use `createSliceLogger('slice-name')` in every feature file:
|
|
51
|
+
```typescript
|
|
52
|
+
import { createSliceLogger } from '../../infrastructure/logger';
|
|
53
|
+
|
|
54
|
+
const logger = createSliceLogger('memory-init');
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
For workers, use `createJobLogger` as first call:
|
|
58
|
+
```typescript
|
|
59
|
+
const log = createJobLogger(job, sliceLogger);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Error Handling
|
|
63
|
+
|
|
64
|
+
- **Operational errors**: Log and handle gracefully
|
|
65
|
+
- **Programmer errors**: Log fatal and exit
|
|
66
|
+
- Always use structured logging with context
|
|
67
|
+
|
|
68
|
+
## Testing
|
|
69
|
+
|
|
70
|
+
- **Unit tests**: Mock all I/O, test in isolation
|
|
71
|
+
- **Integration tests**: Use real Redis/Directus
|
|
72
|
+
- **Functional tests**: Use Supertest against `createApp()`
|
|
73
|
+
- Test files: `<slice>.test.ts` or in `__tests__/` folder
|
|
74
|
+
|
|
75
|
+
## Security
|
|
76
|
+
|
|
77
|
+
- Never log sensitive data (API keys, tokens, passwords)
|
|
78
|
+
- Use environment variables for secrets
|
|
79
|
+
- Validate all inputs with Zod schemas
|
|
80
|
+
- Check for path traversal before file operations
|
|
81
|
+
|
|
82
|
+
## Git Conventions
|
|
83
|
+
|
|
84
|
+
Follow Conventional Commits:
|
|
85
|
+
```
|
|
86
|
+
feat(backend): add memory init command
|
|
87
|
+
fix(backend): resolve vault path validation issue
|
|
88
|
+
refactor(memory): extract scaffolding logic
|
|
89
|
+
chore(deps): update bullmq to 5.x
|
|
90
|
+
```
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Example Technical Decision
|
|
3
|
+
tags:
|
|
4
|
+
- decision
|
|
5
|
+
- architecture
|
|
6
|
+
created: {{date}}
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Technical Decision: Use BullMQ for Job Queueing
|
|
10
|
+
|
|
11
|
+
## Context
|
|
12
|
+
|
|
13
|
+
The application requires a reliable job queue for processing long-running tasks such as workspace migrations and AI layer generation. We evaluated several options including RabbitMQ, Kafka, and BullMQ.
|
|
14
|
+
|
|
15
|
+
## Decision
|
|
16
|
+
|
|
17
|
+
We selected **BullMQ** for the following reasons:
|
|
18
|
+
|
|
19
|
+
1. **Redis-backed**: Leverages our existing Redis infrastructure
|
|
20
|
+
2. **TypeScript-first**: Excellent TypeScript support with typed job payloads
|
|
21
|
+
3. **Flows support**: Built-in flow producer for complex job dependencies
|
|
22
|
+
4. **Monitoring**: Bull Board provides a built-in dashboard for monitoring
|
|
23
|
+
5. **Performance**: Efficient job processing with configurable concurrency
|
|
24
|
+
|
|
25
|
+
## Trade-offs
|
|
26
|
+
|
|
27
|
+
**Pros:**
|
|
28
|
+
- Simple to set up with existing Redis instance
|
|
29
|
+
- Good TypeScript integration
|
|
30
|
+
- Active community and maintenance
|
|
31
|
+
|
|
32
|
+
**Cons:**
|
|
33
|
+
- Requires Redis persistence configuration for durability
|
|
34
|
+
- Less mature than RabbitMQ for very high throughput scenarios
|
|
35
|
+
|
|
36
|
+
## Implementation Details
|
|
37
|
+
|
|
38
|
+
- Queue configuration in `src/infrastructure/bullmq/`
|
|
39
|
+
- Worker options: `concurrency: 10`, `lockDuration: 60_000`
|
|
40
|
+
- Retry policy: 5 attempts with exponential backoff
|
|
41
|
+
- DLQ handler on every worker for failed jobs
|
|
42
|
+
|
|
43
|
+
## Alternatives Considered
|
|
44
|
+
|
|
45
|
+
- **RabbitMQ**: More mature but adds infrastructure complexity
|
|
46
|
+
- **Kafka**: Overkill for our use case, higher operational overhead
|
|
47
|
+
- **PostgreSQL-based queues**: Limited performance compared to Redis
|
|
48
|
+
|
|
49
|
+
## Status
|
|
50
|
+
|
|
51
|
+
**Implemented** - {{date}}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Example Migration Note
|
|
3
|
+
tags:
|
|
4
|
+
- migration
|
|
5
|
+
- upgrade
|
|
6
|
+
created: {{date}}
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Migration: Upgrade to BullMQ 5.x
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
Upgrading the job queue system from BullMQ 4.x to 5.x to leverage new features and performance improvements.
|
|
14
|
+
|
|
15
|
+
## Version
|
|
16
|
+
|
|
17
|
+
- **From**: BullMQ 4.12.0
|
|
18
|
+
- **To**: BullMQ 5.1.0
|
|
19
|
+
|
|
20
|
+
## Breaking Changes
|
|
21
|
+
|
|
22
|
+
1. **Connection options**: `maxRetriesPerRequest: null` is now mandatory for BullMQ connections
|
|
23
|
+
2. **QueueEvents**: Requires dedicated connection via `bullConnection.duplicate()`
|
|
24
|
+
3. **Flow API**: Minor changes to flow producer configuration
|
|
25
|
+
|
|
26
|
+
## Migration Steps
|
|
27
|
+
|
|
28
|
+
### 1. Update Dependencies
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install bullmq@5.1.0
|
|
32
|
+
npm install @bull-board/express@5.0.0
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 2. Update Redis Configuration
|
|
36
|
+
|
|
37
|
+
Updated `src/infrastructure/redis/index.ts`:
|
|
38
|
+
```typescript
|
|
39
|
+
export const bullConnection = new Redis({
|
|
40
|
+
host: env.REDIS_HOST,
|
|
41
|
+
port: env.REDIS_PORT,
|
|
42
|
+
password: env.REDIS_PASSWORD,
|
|
43
|
+
db: 1,
|
|
44
|
+
maxRetriesPerRequest: null, // Required for BullMQ 5.x
|
|
45
|
+
enableReadyCheck: false,
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 3. Update QueueEvents
|
|
50
|
+
|
|
51
|
+
Updated queue events to use duplicate connection:
|
|
52
|
+
```typescript
|
|
53
|
+
const queueEvents = new QueueEvents('queue-name', {
|
|
54
|
+
connection: bullConnection.duplicate(),
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 4. Update Worker Configuration
|
|
59
|
+
|
|
60
|
+
No changes required for worker options, but verified:
|
|
61
|
+
```typescript
|
|
62
|
+
{
|
|
63
|
+
connection: bullConnection,
|
|
64
|
+
concurrency: 10,
|
|
65
|
+
lockDuration: 60_000,
|
|
66
|
+
stalledInterval: 30_000,
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Testing
|
|
71
|
+
|
|
72
|
+
- Ran existing test suite: all tests passing
|
|
73
|
+
- Manual verification of job processing: working correctly
|
|
74
|
+
- Bull Board dashboard: accessible and showing jobs
|
|
75
|
+
|
|
76
|
+
## Rollback Plan
|
|
77
|
+
|
|
78
|
+
If issues arise, rollback steps:
|
|
79
|
+
1. Revert package.json to BullMQ 4.12.0
|
|
80
|
+
2. Remove `maxRetriesPerRequest: null` from Redis config
|
|
81
|
+
3. Use original QueueEvents configuration
|
|
82
|
+
|
|
83
|
+
## Status
|
|
84
|
+
|
|
85
|
+
**Completed** - {{date}}
|