@hiai-gg/hiai-docs 0.0.1

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.
Files changed (216) hide show
  1. package/.all-contributorsrc +18 -0
  2. package/.claude/settings.local.json +61 -0
  3. package/.dockerignore +113 -0
  4. package/.env.example +68 -0
  5. package/.github/FUNDING.yml +5 -0
  6. package/.github/ISSUE_TEMPLATE/bug_report.md +74 -0
  7. package/.github/ISSUE_TEMPLATE/feature_request.md +78 -0
  8. package/.github/dependabot.yml +136 -0
  9. package/.github/pull_request_template.md +96 -0
  10. package/.github/workflows/ci.yml +283 -0
  11. package/AGENTS.md +237 -0
  12. package/CODE_OF_CONDUCT.md +134 -0
  13. package/CONTRIBUTING.md +77 -0
  14. package/Caddyfile +50 -0
  15. package/Dockerfile.backend +60 -0
  16. package/LICENSE +21 -0
  17. package/README.md +284 -0
  18. package/RELEASE_CHECKLIST.md +34 -0
  19. package/SECURITY.md +60 -0
  20. package/backend/package.json +43 -0
  21. package/backend/src/__tests__/auth-helpers.test.ts +51 -0
  22. package/backend/src/__tests__/chunker.test.ts +65 -0
  23. package/backend/src/__tests__/config.test.ts +91 -0
  24. package/backend/src/__tests__/csrf.test.ts +91 -0
  25. package/backend/src/__tests__/embedding.test.ts +48 -0
  26. package/backend/src/__tests__/rate-limit.test.ts +46 -0
  27. package/backend/src/__tests__/routes.test.ts +38 -0
  28. package/backend/src/__tests__/schema.test.ts +31 -0
  29. package/backend/src/__tests__/validation.test.ts +556 -0
  30. package/backend/src/api/middleware/auth.ts +56 -0
  31. package/backend/src/api/middleware/csrf.ts +91 -0
  32. package/backend/src/api/middleware/rate-limit.ts +77 -0
  33. package/backend/src/api/middleware/webhook-verify.ts +22 -0
  34. package/backend/src/api/routes/attachments.ts +280 -0
  35. package/backend/src/api/routes/auth.ts +52 -0
  36. package/backend/src/api/routes/collaboration.ts +121 -0
  37. package/backend/src/api/routes/documents.ts +664 -0
  38. package/backend/src/api/routes/folders.ts +226 -0
  39. package/backend/src/api/routes/search.ts +354 -0
  40. package/backend/src/api/routes/share.ts +512 -0
  41. package/backend/src/api/routes/tags.ts +247 -0
  42. package/backend/src/api/routes/versions.ts +99 -0
  43. package/backend/src/api/routes/webhooks.ts +43 -0
  44. package/backend/src/embedding/chunker.ts +74 -0
  45. package/backend/src/embedding/index.ts +117 -0
  46. package/backend/src/embedding/providers/ollama.ts +63 -0
  47. package/backend/src/embedding/providers/openrouter.ts +71 -0
  48. package/backend/src/embedding/utils.ts +13 -0
  49. package/backend/src/embedding/worker.ts +89 -0
  50. package/backend/src/index.ts +147 -0
  51. package/backend/src/lib/auth-helpers.ts +27 -0
  52. package/backend/src/lib/auth.ts +35 -0
  53. package/backend/src/lib/config.ts +73 -0
  54. package/backend/src/lib/db.ts +7 -0
  55. package/backend/src/lib/embedding-queue.ts +12 -0
  56. package/backend/src/lib/logger.ts +18 -0
  57. package/backend/src/lib/markdown-to-doc.ts +45 -0
  58. package/backend/src/lib/minio.ts +46 -0
  59. package/backend/src/lib/redis.ts +19 -0
  60. package/backend/src/lib/yjs-provider.ts +182 -0
  61. package/backend/tests/integration/_harness.ts +754 -0
  62. package/backend/tests/integration/auth.test.ts +296 -0
  63. package/backend/tests/integration/routes.documents.test.ts +459 -0
  64. package/backend/tests/integration/routes.folders.test.ts +337 -0
  65. package/backend/tests/integration/routes.search.test.ts +322 -0
  66. package/backend/tests/integration/routes.share.test.ts +773 -0
  67. package/backend/tests/integration/routes.tags.test.ts +425 -0
  68. package/backend/tests/integration/routes.versions.test.ts +233 -0
  69. package/backend/tsconfig.json +18 -0
  70. package/docker-compose.yml +218 -0
  71. package/docs/API.md +328 -0
  72. package/docs/ARCHITECTURE.md +75 -0
  73. package/docs/DEPLOYMENT.md +113 -0
  74. package/docs/PRODUCTION_STATUS.md +61 -0
  75. package/docs/openapi.json +385 -0
  76. package/frontend/.svelte-kit.old/ambient.d.ts +230 -0
  77. package/frontend/.svelte-kit.old/env.d.ts +1 -0
  78. package/frontend/.svelte-kit.old/generated/client/app.js +46 -0
  79. package/frontend/.svelte-kit.old/generated/client/matchers.js +1 -0
  80. package/frontend/.svelte-kit.old/generated/client/nodes/0.js +3 -0
  81. package/frontend/.svelte-kit.old/generated/client/nodes/1.js +1 -0
  82. package/frontend/.svelte-kit.old/generated/client/nodes/10.js +3 -0
  83. package/frontend/.svelte-kit.old/generated/client/nodes/2.js +1 -0
  84. package/frontend/.svelte-kit.old/generated/client/nodes/3.js +1 -0
  85. package/frontend/.svelte-kit.old/generated/client/nodes/4.js +1 -0
  86. package/frontend/.svelte-kit.old/generated/client/nodes/5.js +3 -0
  87. package/frontend/.svelte-kit.old/generated/client/nodes/6.js +1 -0
  88. package/frontend/.svelte-kit.old/generated/client/nodes/7.js +3 -0
  89. package/frontend/.svelte-kit.old/generated/client/nodes/8.js +1 -0
  90. package/frontend/.svelte-kit.old/generated/client/nodes/9.js +3 -0
  91. package/frontend/.svelte-kit.old/generated/root.js +3 -0
  92. package/frontend/.svelte-kit.old/generated/root.svelte +80 -0
  93. package/frontend/.svelte-kit.old/generated/server/internal.js +55 -0
  94. package/frontend/.svelte-kit.old/non-ambient.d.ts +59 -0
  95. package/frontend/.svelte-kit.old/tsconfig.json +59 -0
  96. package/frontend/.svelte-kit.old/types/route_meta_data.json +40 -0
  97. package/frontend/.svelte-kit.old/types/src/routes/$types.d.ts +21 -0
  98. package/frontend/.svelte-kit.old/types/src/routes/(app)/$types.d.ts +30 -0
  99. package/frontend/.svelte-kit.old/types/src/routes/(app)/docs/[id]/$types.d.ts +27 -0
  100. package/frontend/.svelte-kit.old/types/src/routes/(app)/docs/[id]/proxy+page.ts +25 -0
  101. package/frontend/.svelte-kit.old/types/src/routes/api/[...path]/$types.d.ts +10 -0
  102. package/frontend/.svelte-kit.old/types/src/routes/folders/[id]/$types.d.ts +27 -0
  103. package/frontend/.svelte-kit.old/types/src/routes/folders/[id]/proxy+page.ts +15 -0
  104. package/frontend/.svelte-kit.old/types/src/routes/login/$types.d.ts +17 -0
  105. package/frontend/.svelte-kit.old/types/src/routes/register/$types.d.ts +17 -0
  106. package/frontend/.svelte-kit.old/types/src/routes/s/[token]/$types.d.ts +20 -0
  107. package/frontend/.svelte-kit.old/types/src/routes/s/[token]/proxy+page.ts +6 -0
  108. package/frontend/.svelte-kit.old/types/src/routes/search/$types.d.ts +19 -0
  109. package/frontend/.svelte-kit.old/types/src/routes/search/proxy+page.ts +26 -0
  110. package/frontend/.svelte-kit.old/types/src/routes/settings/$types.d.ts +17 -0
  111. package/frontend/Dockerfile +44 -0
  112. package/frontend/biome.json +40 -0
  113. package/frontend/components.json +18 -0
  114. package/frontend/messages/en.json +434 -0
  115. package/frontend/package.json +70 -0
  116. package/frontend/project.inlang/settings.json +12 -0
  117. package/frontend/src/app.css +6 -0
  118. package/frontend/src/app.d.ts +13 -0
  119. package/frontend/src/app.html +30 -0
  120. package/frontend/src/hooks.server.ts +10 -0
  121. package/frontend/src/hooks.ts +10 -0
  122. package/frontend/src/lib/api/attachments.ts +45 -0
  123. package/frontend/src/lib/api/client.test.ts +15 -0
  124. package/frontend/src/lib/api/client.ts +57 -0
  125. package/frontend/src/lib/api/documents.ts +83 -0
  126. package/frontend/src/lib/api/folders.ts +180 -0
  127. package/frontend/src/lib/api/search.test.ts +52 -0
  128. package/frontend/src/lib/api/search.ts +128 -0
  129. package/frontend/src/lib/api/settings.ts +95 -0
  130. package/frontend/src/lib/api/share.ts +71 -0
  131. package/frontend/src/lib/api/tags.test.ts +91 -0
  132. package/frontend/src/lib/api/tags.ts +87 -0
  133. package/frontend/src/lib/auth-client.ts +10 -0
  134. package/frontend/src/lib/collaboration.ts +63 -0
  135. package/frontend/src/lib/components/AttachmentUpload.svelte +110 -0
  136. package/frontend/src/lib/components/DatePicker.svelte +322 -0
  137. package/frontend/src/lib/components/DocumentCard.svelte +166 -0
  138. package/frontend/src/lib/components/EmptyState.svelte +49 -0
  139. package/frontend/src/lib/components/FolderCard.svelte +93 -0
  140. package/frontend/src/lib/components/ScrollToTop.svelte +72 -0
  141. package/frontend/src/lib/components/SearchBar.svelte +47 -0
  142. package/frontend/src/lib/components/SearchResult.svelte +115 -0
  143. package/frontend/src/lib/components/SettingsDialog.svelte +271 -0
  144. package/frontend/src/lib/components/ShareDialog.svelte +158 -0
  145. package/frontend/src/lib/components/ShareLink.svelte +98 -0
  146. package/frontend/src/lib/components/TagCreateDialog.svelte +284 -0
  147. package/frontend/src/lib/components/VersionDiff.svelte +55 -0
  148. package/frontend/src/lib/components/VersionHistory.svelte +96 -0
  149. package/frontend/src/lib/components/editor/DocumentTitle.svelte +87 -0
  150. package/frontend/src/lib/components/editor/EditorToolbar.svelte +1367 -0
  151. package/frontend/src/lib/components/editor/HiAiEditor.svelte +531 -0
  152. package/frontend/src/lib/components/editor/LinkDialog.svelte +134 -0
  153. package/frontend/src/lib/components/editor/MarkdownToggle.svelte +88 -0
  154. package/frontend/src/lib/components/editor/editorExtensions.ts +53 -0
  155. package/frontend/src/lib/components/editor/markdown.ts +38 -0
  156. package/frontend/src/lib/components/sidebar/FolderTree.svelte +731 -0
  157. package/frontend/src/lib/components/sidebar/RecentDocs.svelte +311 -0
  158. package/frontend/src/lib/components/sidebar/Sidebar.svelte +156 -0
  159. package/frontend/src/lib/components/sidebar/TagList.svelte +200 -0
  160. package/frontend/src/lib/components/ui/confirm-dialog/ConfirmDialog.svelte +76 -0
  161. package/frontend/src/lib/components/ui/confirm-dialog/index.ts +1 -0
  162. package/frontend/src/lib/stores/tag-store.svelte.ts +56 -0
  163. package/frontend/src/lib/stores/theme.svelte.ts +97 -0
  164. package/frontend/src/lib/svelte.d.ts +6 -0
  165. package/frontend/src/lib/types.ts +44 -0
  166. package/frontend/src/lib/utils/clipboard.ts +17 -0
  167. package/frontend/src/lib/utils/strip-markdown.ts +59 -0
  168. package/frontend/src/lib/utils.ts +33 -0
  169. package/frontend/src/routes/(app)/+layout.svelte +17 -0
  170. package/frontend/src/routes/(app)/+page.server.ts +10 -0
  171. package/frontend/src/routes/(app)/+page.svelte +303 -0
  172. package/frontend/src/routes/(app)/docs/[id]/+page.server.ts +10 -0
  173. package/frontend/src/routes/(app)/docs/[id]/+page.svelte +1108 -0
  174. package/frontend/src/routes/(app)/docs/[id]/+page.ts +24 -0
  175. package/frontend/src/routes/(app)/search/+page.svelte +593 -0
  176. package/frontend/src/routes/(app)/search/+page.ts +25 -0
  177. package/frontend/src/routes/+error.svelte +12 -0
  178. package/frontend/src/routes/+layout.svelte +18 -0
  179. package/frontend/src/routes/+layout.ts +2 -0
  180. package/frontend/src/routes/api/[...path]/+server.ts +111 -0
  181. package/frontend/src/routes/folders/[id]/+page.server.ts +10 -0
  182. package/frontend/src/routes/folders/[id]/+page.svelte +319 -0
  183. package/frontend/src/routes/folders/[id]/+page.ts +14 -0
  184. package/frontend/src/routes/login/+page.svelte +90 -0
  185. package/frontend/src/routes/register/+page.svelte +97 -0
  186. package/frontend/src/routes/s/[token]/+page.svelte +496 -0
  187. package/frontend/src/routes/s/[token]/+page.ts +5 -0
  188. package/frontend/src/routes/settings/+page.svelte +175 -0
  189. package/frontend/static/favicon.png +0 -0
  190. package/frontend/static/logo.png +0 -0
  191. package/frontend/svelte.config.js +15 -0
  192. package/frontend/tsconfig.json +15 -0
  193. package/frontend/vite.config.ts +25 -0
  194. package/init.sql +9 -0
  195. package/logo.png +0 -0
  196. package/package.json +39 -0
  197. package/package.public.json +39 -0
  198. package/packages/db/drizzle.config.ts +10 -0
  199. package/packages/db/package.json +30 -0
  200. package/packages/db/src/client.ts +9 -0
  201. package/packages/db/src/index.ts +2 -0
  202. package/packages/db/src/migrations/0000_nice_bedlam.sql +165 -0
  203. package/packages/db/src/migrations/0001_w2_3_test.sql +5 -0
  204. package/packages/db/src/migrations/0002_rename_content_json.sql +2 -0
  205. package/packages/db/src/migrations/meta/0000_snapshot.json +1331 -0
  206. package/packages/db/src/migrations/meta/0001_snapshot.json +1399 -0
  207. package/packages/db/src/migrations/meta/0002_snapshot.json +1399 -0
  208. package/packages/db/src/migrations/meta/_journal.json +27 -0
  209. package/packages/db/src/schema.ts +378 -0
  210. package/packages/db/tsconfig.json +17 -0
  211. package/scripts/export-openapi.ts +37 -0
  212. package/scripts/health-check.sh +75 -0
  213. package/scripts/migrate.sh +135 -0
  214. package/scripts/prework_backup.sh +25 -0
  215. package/scripts/release.sh +83 -0
  216. package/tsconfig.json +25 -0
@@ -0,0 +1,18 @@
1
+ {
2
+ "projectName": "hiai-docs",
3
+ "projectOwner": "hiai-gg",
4
+ "repoType": "github",
5
+ "repoHost": "https://github.com",
6
+ "files": ["README.md"],
7
+ "commitConvention": "angular",
8
+ "contributors": [
9
+ {
10
+ "login": "vgalibov",
11
+ "name": "vgalibov",
12
+ "avatar_url": "https://github.com/vgalibov.png",
13
+ "profile": "https://github.com/vgalibov",
14
+ "contributions": ["code", "doc", "infra", "review", "maintenance"]
15
+ }
16
+ ],
17
+ "contributorsPerLine": 7
18
+ }
@@ -0,0 +1,61 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(git mv *)",
5
+ "Bash(echo \"rm exit: $?\")",
6
+ "Bash(sudo rm -rf .svelte-kit/types)",
7
+ "Bash(echo \"exit $?\")",
8
+ "Bash(docker exec *)",
9
+ "Bash(curl -fsS -o /dev/null -w \"frontend:%{http_code}\\\\n\" http://localhost:50701/)",
10
+ "Bash(curl -fsS -o /dev/null -w \"api-health:%{http_code}\\\\n\" http://localhost:50700/api/health)",
11
+ "Bash(bunx @biomejs/biome check --max-diagnostics=none 'frontend/src/routes/\\(app\\)/+page.svelte' 'frontend/src/routes/\\(app\\)/docs/[id]/+page.svelte' frontend/src/lib/components/sidebar/TagList.svelte frontend/src/lib/components/sidebar/RecentDocs.svelte frontend/src/lib/stores/tag-store.svelte.ts frontend/src/lib/components/editor/EditorToolbar.svelte frontend/src/lib/components/editor/LinkDialog.svelte frontend/src/lib/api/settings.ts backend/src/api/routes/attachments.ts backend/src/api/routes/documents.ts)",
12
+ "mcp__plugin_playwright_playwright__browser_navigate",
13
+ "Bash(timeout 300 bunx playwright install chromium)",
14
+ "Bash(timeout 300 bunx playwright install chrome)",
15
+ "Bash(curl -s -o /dev/null -w \"GET /api/health -> %{http_code}\\\\n\" http://localhost:50700/api/health)",
16
+ "Bash(curl -s -o /dev/null -w \"GET /api/auth/get-session -> %{http_code}\\\\n\" http://localhost:50700/api/auth/get-session)",
17
+ "Bash(curl -s -o /dev/null -w \"GET /api/attachments/00000000-0000-0000-0000-000000000000/raw -> %{http_code} \\(404=route exists, no such id\\)\\\\n\" http://localhost:50700/api/attachments/00000000-0000-0000-0000-000000000000/raw)",
18
+ "Bash(curl -s -o /dev/null -w \"GET /api/documents \\(no auth\\) -> %{http_code} \\(401 expected\\)\\\\n\" http://localhost:50700/api/documents)",
19
+ "Bash(timeout 180 bun add --cwd frontend @tiptap/extension-table@^3.26.1)",
20
+ "Bash(timeout 180 bun add --cwd frontend @tiptap/extension-table@3.26.1)",
21
+ "Bash(curl -s -o /dev/null -w \"/register -> %{http_code}\\\\n\" http://localhost:50701/register)",
22
+ "Bash(curl -s -o /dev/null -w \"/docs/probe -> %{http_code}\\\\n\" http://localhost:50701/docs/00000000-0000-0000-0000-000000000000)",
23
+ "Bash(rm -f cj.txt img.png got_proxy.bin got_direct.bin)",
24
+ "Bash(curl -s -c cj.txt -b cj.txt -X POST http://localhost:50701/api/auth/sign-up/email -H 'Content-Type: application/json' -d '{\"name\":\"Img Test\",\"email\":\"__TRACKED_VAR__\",\"password\":\"password12345\"}' -w '\\\\nHTTP %{http_code}\\\\n')",
25
+ "Bash(curl -s -o /dev/null -w \"/search -> %{http_code}\\\\n\" \"http://localhost:50701/search?q=test\")",
26
+ "Bash(curl -s -o /dev/null -w \"/ \\(dash\\) -> %{http_code}\\\\n\" http://localhost:50701/)",
27
+ "Bash(curl -s -o /dev/null -w \"/ -> %{http_code}\\\\n\" http://localhost:50701/)",
28
+ "Bash(curl -s -o /dev/null -w \"/login -> %{http_code}\\\\n\" http://localhost:50701/login)",
29
+ "Bash(curl -s \"http://localhost:50701/api/share/PnWzf7hNeAZA_Aqdntkl3\")",
30
+ "Bash(python3 -c ' *)",
31
+ "Bash(git checkout *)",
32
+ "Bash(grep -n '>Import<\\\\|Import$\\\\|>All<\\\\|All$\\\\|<Upload' \"frontend/src/routes/\\(app\\)/+page.svelte\")",
33
+ "Bash(git --no-pager diff stash@{0} -- \"frontend/src/routes/\\(app\\)/docs/[id]/+page.svelte\")",
34
+ "Bash(git --no-pager diff \"stash@{0}\" -- \":\\(literal\\)frontend/src/routes/\\(app\\)/docs/[id]/+page.svelte\")",
35
+ "Bash(git --no-pager diff \"stash@{0}\" -- backend/src/api/routes/documents.ts)",
36
+ "Bash(git --no-pager diff \"stash@{0}\" -- frontend/package.json)",
37
+ "Bash(git --no-pager diff \"stash@{0}\" -- backend/src/lib/auth.ts)",
38
+ "Bash(git --no-pager diff \"stash@{0}\" -- backend/src/lib/config.ts)",
39
+ "Bash(git --no-pager diff \"stash@{0}\" -- frontend/src/routes/+layout.svelte)",
40
+ "Bash(git --no-pager diff \"stash@{0}\" -- frontend/src/routes/settings/+page.svelte)",
41
+ "Bash(grep -iE \"\\\\.env|secret|credential|\\\\.pem|\\\\.key$|id_rsa\")",
42
+ "Bash(git rm *)",
43
+ "Bash(awk '{print $NF}')",
44
+ "Bash(grep -ivE \"change-me|process\\\\.env|envSchema|z\\\\.string|placeholder|example|//|\\\\*|_SECRET=|_KEY=|_PASSWORD=|aipassword|minioadmin|description:|api-key-user|API_KEY=$|SECRET=change\")",
45
+ "Bash(grep -iE \"\\\\.env$|secret|\\\\.pem|\\\\.key$|credential\")",
46
+ "Bash(curl -s -o /dev/null -w \"/docs test -> %{http_code}\\\\n\" \"http://localhost:50701/docs/test\")",
47
+ "Bash(grep -n \"^## \\\\|^---$\" README.md)"
48
+ ]
49
+ },
50
+ "enabledMcpjsonServers": [
51
+ "playwright",
52
+ "stitch",
53
+ "sequential-thinking",
54
+ "firecrawl",
55
+ "rag",
56
+ "context7",
57
+ "mempalace",
58
+ "websearch",
59
+ "grep_app"
60
+ ]
61
+ }
package/.dockerignore ADDED
@@ -0,0 +1,113 @@
1
+ # ============================================
2
+ # hiai-docs .dockerignore
3
+ # Mirrors .gitignore with extra hardening for
4
+ # image builds (no secrets, no VCS metadata,
5
+ # no host volumes, no test artifacts).
6
+ # ============================================
7
+
8
+ # --- VCS ---
9
+ .git
10
+ .gitignore
11
+ .gitattributes
12
+ .github
13
+
14
+ # --- Dependencies (re-installed inside image) ---
15
+ node_modules
16
+ **/node_modules
17
+ # bun.lock is intentionally NOT ignored — required for `bun install --frozen-lockfile` reproducibility
18
+
19
+ # --- Build outputs (regenerated inside image) ---
20
+ dist
21
+ build
22
+ .svelte-kit
23
+ .next
24
+ .output
25
+ **/.svelte-kit
26
+ **/.next
27
+ **/.output
28
+ **/dist
29
+ **/build
30
+ packages/db/.drizzle
31
+
32
+ # --- Paraglide generated (rebuilt in image) ---
33
+ frontend/src/lib/paraglide
34
+
35
+ # --- Secrets and local env (NEVER ship into image) ---
36
+ .env
37
+ .env.local
38
+ .env.*.local
39
+ **/.env
40
+ **/.env.local
41
+ !**/.env.example
42
+
43
+ # --- Docker dev override (not needed in image) ---
44
+ docker-compose.dev.yml
45
+
46
+ # --- Local data volumes (host-only) ---
47
+ minio_data
48
+ ollama_data
49
+ backup
50
+ docker-data
51
+
52
+ # --- Logs and runtime artifacts ---
53
+ *.log
54
+ logs
55
+ **/*.log
56
+
57
+ # --- Test artifacts ---
58
+ coverage
59
+ **/coverage
60
+ **/*.test.ts
61
+ **/*.test.tsx
62
+ **/*.test.js
63
+ **/*.spec.ts
64
+ **/*.spec.tsx
65
+ **/*.spec.js
66
+ tests
67
+ **/tests
68
+ __tests__
69
+ **/__tests__
70
+ qa
71
+ **/qa
72
+ pytest.ini
73
+ pytest-qa.ini
74
+
75
+ # --- IDE / editor metadata ---
76
+ .vscode
77
+ .idea
78
+ *.swp
79
+ *.swo
80
+ *~
81
+ .DS_Store
82
+ Thumbs.db
83
+
84
+ # --- OpenCode workspace metadata ---
85
+ .opencode
86
+ .bob
87
+
88
+ # --- Docs (only README.md ships into the image per Wave 0 spec) ---
89
+ # Exclude all *.md, but make an exception for README.md (per W0.5 spec: "*.md (except README)")
90
+ *.md
91
+ !README.md
92
+ docs
93
+
94
+ # --- ML / dataset scratch ---
95
+ mlops
96
+ dataset
97
+ models
98
+ artifacts
99
+ cache
100
+
101
+ # --- Python envs (legacy) ---
102
+ .venv
103
+ **/.venv
104
+ __pycache__
105
+ **/__pycache__
106
+ *.pyc
107
+ *.pyo
108
+
109
+ # --- Backup / archive ---
110
+ *.tar
111
+ *.tar.gz
112
+ *.tgz
113
+ *.zip
package/.env.example ADDED
@@ -0,0 +1,68 @@
1
+ # ============================================
2
+ # hiai-docs Environment Configuration
3
+ # Copy to .env and fill in your values
4
+ # ============================================
5
+ #
6
+ # Wave 0 (W0.1) — Generate new random secrets before deployment.
7
+ # Use: openssl rand -hex 32
8
+ # IMPORTANT: Each domain MUST use its own secret. Do NOT reuse
9
+ # BETTER_AUTH_SECRET for CSRF or MINIO_SECRET_KEY for webhooks.
10
+ # ============================================
11
+
12
+ # --- Database (shared ai-core infra) ---
13
+ DB_USER=aiuser
14
+ DB_PASSWORD=aipassword
15
+ DB_NAME=hiai_docs
16
+ DB_HOST=localhost
17
+ DB_PORT=5433
18
+
19
+ # --- Auth ---
20
+ # Generate with: openssl rand -hex 32
21
+ BETTER_AUTH_SECRET=change-me-to-random-32-chars
22
+ BETTER_AUTH_URL=http://localhost:50700
23
+
24
+ # --- CSRF ---
25
+ # Dedicated signing key for CSRF tokens. Must differ from BETTER_AUTH_SECRET.
26
+ # Generate with: openssl rand -hex 32
27
+ CSRF_SECRET=change-me-to-random-32-chars
28
+
29
+ # --- MinIO (shared ai-core infra) ---
30
+ MINIO_ENDPOINT=localhost
31
+ MINIO_PORT=9010
32
+ MINIO_ACCESS_KEY=minioadmin
33
+ # Generate with: openssl rand -hex 32
34
+ MINIO_SECRET_KEY=change-me-to-random-32-chars
35
+ MINIO_BUCKET=hiai-docs
36
+ MINIO_USE_SSL=false
37
+
38
+ # --- Webhooks ---
39
+ # Dedicated HMAC key for inbound webhooks. Must differ from MINIO_SECRET_KEY.
40
+ # Generate with: openssl rand -hex 32
41
+ WEBHOOK_SECRET=change-me-to-random-32-chars
42
+
43
+ # --- Redis (shared ai-core infra) ---
44
+ REDIS_URL=redis://localhost:6380
45
+
46
+ # --- Embeddings (shared ai-core Ollama) ---
47
+ EMBEDDING_PROVIDER=ollama
48
+ EMBEDDING_MODEL=mxbai-embed-large # 1024-dim
49
+ EMBEDDING_OLLAMA_URL=http://localhost:11434
50
+ EMBEDDING_FALLBACK_PROVIDER=openrouter
51
+ EMBEDDING_FALLBACK_MODEL=openai/text-embedding-3-large
52
+
53
+ # --- OpenRouter (fallback for embeddings) ---
54
+ # Get a key from https://openrouter.ai/keys
55
+ OPENROUTER_API_KEY=
56
+
57
+ # --- API Key Auth (for bots / programmatic access) ---
58
+ # If set, requests with `Authorization: Bearer <key>` bypass Better Auth sessions.
59
+ # Must be a unique random value (do NOT reuse BETTER_AUTH_SECRET).
60
+ HIAI_DOCS_API_KEY=
61
+ # The user ID assigned to API key-authenticated requests. Defaults to "api-key-user".
62
+ OWNER_ID=api-key-user
63
+
64
+ # --- App ---
65
+ API_PORT=50700
66
+ WEB_PORT=50701
67
+ NODE_ENV=development
68
+ LOG_LEVEL=info
@@ -0,0 +1,5 @@
1
+ # Funding configuration for hiai-docs
2
+ # https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/displaying-a-sponsor-button-in-your-repository
3
+
4
+ # These settings support the `hiai-dev` GitHub Sponsors account.
5
+ github: [hiai-dev]
@@ -0,0 +1,74 @@
1
+ ---
2
+ name: Bug Report
3
+ about: Report a bug in hiai-docs to help us improve
4
+ title: "[BUG] "
5
+ labels: ["bug", "needs-triage"]
6
+ assignees: []
7
+ ---
8
+
9
+ ## Bug Description
10
+
11
+ <!-- A clear, concise description of what the bug is. -->
12
+
13
+ ## Steps to Reproduce
14
+
15
+ 1. Go to '...'
16
+ 2. Click on '...'
17
+ 3. Run command '...'
18
+ 4. See error
19
+
20
+ ## Expected Behavior
21
+
22
+ <!-- What you expected to happen. -->
23
+
24
+ ## Actual Behavior
25
+
26
+ <!-- What actually happened. Include screenshots, error messages, or stack traces if applicable. -->
27
+
28
+ ## Environment
29
+
30
+ | Field | Value |
31
+ |-------|-------|
32
+ | hiai-docs version | <!-- e.g. v0.1.0, commit SHA, or `main` --> |
33
+ | Deployment | <!-- Docker / local dev / other --> |
34
+ | Backend (Elysia) | <!-- version or commit --> |
35
+ | Frontend (SvelteKit) | <!-- version or commit --> |
36
+ | Database | <!-- PostgreSQL 18 + pgvector --> |
37
+ | OS | <!-- e.g. Ubuntu 22.04, macOS 14 --> |
38
+ | Browser | <!-- e.g. Chrome 120, Firefox 121 --> |
39
+ | Bun version | <!-- `bun --version` output --> |
40
+
41
+ ## Configuration
42
+
43
+ <!-- Relevant environment variables from `.env` (redact secrets). -->
44
+
45
+ ```bash
46
+ EMBEDDING_PROVIDER=
47
+ EMBEDDING_MODEL=
48
+ DATABASE_URL=postgresql://***:***@***:**/hiai_docs
49
+ ```
50
+
51
+ ## Logs
52
+
53
+ <!-- Paste relevant logs from `api`, `web`, or `docker compose logs`. Wrap in ```blocks```. Use [pastebin](https://pastebin.com) or similar for very long logs. -->
54
+
55
+ ```text
56
+ [Paste logs here]
57
+ ```
58
+
59
+ ## Severity
60
+
61
+ <!-- How badly does this affect you? -->
62
+
63
+ - [ ] Critical — data loss, security issue, or complete outage
64
+ - [ ] High — major feature broken
65
+ - [ ] Medium — feature degraded but workaround exists
66
+ - [ ] Low — minor cosmetic or edge case
67
+
68
+ ## Possible Cause
69
+
70
+ <!-- Optional: your hypothesis on what might be causing the bug. -->
71
+
72
+ ## Additional Context
73
+
74
+ <!-- Any other context, related issues, or PRs. -->
@@ -0,0 +1,78 @@
1
+ ---
2
+ name: Feature Request
3
+ about: Suggest a new feature or enhancement for hiai-docs
4
+ title: "[FEATURE] "
5
+ labels: ["enhancement", "needs-triage"]
6
+ assignees: []
7
+ ---
8
+
9
+ ## Summary
10
+
11
+ <!-- One-sentence description of the feature. -->
12
+
13
+ ## Problem / Use Case
14
+
15
+ <!-- What problem does this solve? Who benefits? Describe the workflow or scenario. -->
16
+
17
+ > As a [type of user], I want to [action] so that [outcome / value].
18
+
19
+ ## Proposed Solution
20
+
21
+ <!-- Describe the desired behavior, API, or UI in detail. Mockups, ASCII diagrams, or links to references are welcome. -->
22
+
23
+ ### Example API / UI
24
+
25
+ ```http
26
+ POST /api/documents/:id/duplicate
27
+ Authorization: Bearer <token>
28
+ ```
29
+
30
+ ```svelte
31
+ <Button on:click={duplicate}>Duplicate</Button>
32
+ ```
33
+
34
+ ### Database / Schema Changes (if any)
35
+
36
+ <!-- Describe any new tables, columns, or migrations. -->
37
+
38
+ ## Alternatives Considered
39
+
40
+ <!-- What other approaches did you consider, and why is this one better? -->
41
+
42
+ ## Out of Scope
43
+
44
+ <!-- What this feature should NOT do. Be explicit to keep scope tight. -->
45
+
46
+ ## Acceptance Criteria
47
+
48
+ <!-- A clear checklist we can use to know the feature is done. -->
49
+
50
+ - [ ] Criterion 1
51
+ - [ ] Criterion 2
52
+ - [ ] Documentation updated (`docs/` and `README.md` if needed)
53
+ - [ ] Tests added (unit + integration)
54
+ - [ ] No breaking changes (or migration path documented)
55
+
56
+ ## Affected Areas
57
+
58
+ <!-- Check all that apply. -->
59
+
60
+ - [ ] Backend API (`backend/src/api/`)
61
+ - [ ] Database schema (`packages/db/`)
62
+ - [ ] Embedding pipeline (`backend/src/embedding/`)
63
+ - [ ] Frontend pages (`frontend/src/routes/`)
64
+ - [ ] Frontend components (`frontend/src/lib/`)
65
+ - [ ] Docker / deployment
66
+ - [ ] Documentation
67
+
68
+ ## Priority
69
+
70
+ <!-- Your estimate of priority. Maintainers will adjust. -->
71
+
72
+ - [ ] High — blocks current workflow for many users
73
+ - [ ] Medium — valuable but not blocking
74
+ - [ ] Low — nice-to-have
75
+
76
+ ## Additional Context
77
+
78
+ <!-- Links, screenshots, references to similar features in Outline / Docmost / Notion, etc. -->
@@ -0,0 +1,136 @@
1
+ # Dependabot configuration for hiai-docs
2
+ # https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
3
+
4
+ version: 2
5
+
6
+ # Update Bun lockfiles weekly (root + per-workspace)
7
+ updates:
8
+ # ---------------------------------------------------------------------------
9
+ # Backend — Elysia REST API (Bun)
10
+ # ---------------------------------------------------------------------------
11
+ - package-ecosystem: "npm"
12
+ directory: "/backend"
13
+ schedule:
14
+ interval: "weekly"
15
+ day: "monday"
16
+ time: "09:00"
17
+ timezone: "Europe/Lisbon"
18
+ open-pull-requests-limit: 5
19
+ labels:
20
+ - "dependencies"
21
+ - "backend"
22
+ groups:
23
+ production-dependencies:
24
+ dependency-type: "production"
25
+ development-dependencies:
26
+ dependency-type: "development"
27
+ commit-message:
28
+ prefix: "deps(backend)"
29
+ prefix-development: "deps(dev/backend)"
30
+ include: "scope"
31
+ # Elysia + Drizzle are sensitive to major bumps — only patch + minor
32
+ versioning-strategy: "increase"
33
+ ignore:
34
+ - dependency-name: "elysia"
35
+ update-types: ["version-update:semver-major"]
36
+ - dependency-name: "drizzle-orm"
37
+ update-types: ["version-update:semver-major"]
38
+
39
+ # ---------------------------------------------------------------------------
40
+ # Frontend — SvelteKit + Svelte 5 (Bun)
41
+ # ---------------------------------------------------------------------------
42
+ - package-ecosystem: "npm"
43
+ directory: "/frontend"
44
+ schedule:
45
+ interval: "weekly"
46
+ day: "monday"
47
+ time: "09:00"
48
+ timezone: "Europe/Lisbon"
49
+ open-pull-requests-limit: 5
50
+ labels:
51
+ - "dependencies"
52
+ - "frontend"
53
+ groups:
54
+ production-dependencies:
55
+ dependency-type: "production"
56
+ development-dependencies:
57
+ dependency-type: "development"
58
+ commit-message:
59
+ prefix: "deps(frontend)"
60
+ prefix-development: "deps(dev/frontend)"
61
+ include: "scope"
62
+ versioning-strategy: "increase"
63
+ ignore:
64
+ - dependency-name: "svelte"
65
+ update-types: ["version-update:semver-major"]
66
+ - dependency-name: "@sveltejs/kit"
67
+ update-types: ["version-update:semver-major"]
68
+
69
+ # ---------------------------------------------------------------------------
70
+ # Database package — Drizzle schema + migrations
71
+ # ---------------------------------------------------------------------------
72
+ - package-ecosystem: "npm"
73
+ directory: "/packages/db"
74
+ schedule:
75
+ interval: "weekly"
76
+ day: "monday"
77
+ time: "09:00"
78
+ timezone: "Europe/Lisbon"
79
+ open-pull-requests-limit: 5
80
+ labels:
81
+ - "dependencies"
82
+ - "db"
83
+ commit-message:
84
+ prefix: "deps(db)"
85
+ include: "scope"
86
+
87
+ # ---------------------------------------------------------------------------
88
+ # Docker base image updates (weekly digest bumps)
89
+ # ---------------------------------------------------------------------------
90
+ - package-ecosystem: "docker"
91
+ directory: "/backend"
92
+ schedule:
93
+ interval: "weekly"
94
+ day: "monday"
95
+ time: "09:00"
96
+ timezone: "Europe/Lisbon"
97
+ open-pull-requests-limit: 3
98
+ labels:
99
+ - "dependencies"
100
+ - "docker"
101
+ commit-message:
102
+ prefix: "docker(backend)"
103
+
104
+ - package-ecosystem: "docker"
105
+ directory: "/frontend"
106
+ schedule:
107
+ interval: "weekly"
108
+ day: "monday"
109
+ time: "09:00"
110
+ timezone: "Europe/Lisbon"
111
+ open-pull-requests-limit: 3
112
+ labels:
113
+ - "dependencies"
114
+ - "docker"
115
+ commit-message:
116
+ prefix: "docker(frontend)"
117
+
118
+ # ---------------------------------------------------------------------------
119
+ # GitHub Actions — pin to digest for supply-chain hygiene
120
+ # ---------------------------------------------------------------------------
121
+ - package-ecosystem: "github-actions"
122
+ directory: "/"
123
+ schedule:
124
+ interval: "weekly"
125
+ day: "monday"
126
+ time: "09:00"
127
+ timezone: "Europe/Lisbon"
128
+ open-pull-requests-limit: 5
129
+ labels:
130
+ - "dependencies"
131
+ - "ci"
132
+ commit-message:
133
+ prefix: "ci"
134
+ groups:
135
+ actions:
136
+ patterns: ["*"]
@@ -0,0 +1,96 @@
1
+ # Pull Request
2
+
3
+ ## Description
4
+
5
+ <!-- Briefly describe what this PR does and why. Link the related issue with `Closes #123` or `Fixes #123`. -->
6
+
7
+ Closes #
8
+
9
+ ## Type of Change
10
+
11
+ <!-- Check all that apply. -->
12
+
13
+ - [ ] Bug fix (non-breaking change that fixes an issue)
14
+ - [ ] New feature (non-breaking change that adds functionality)
15
+ - [ ] Breaking change (fix or feature that would cause existing functionality to change)
16
+ - [ ] Documentation update
17
+ - [ ] Refactor (no functional change)
18
+ - [ ] Performance improvement
19
+ - [ ] Test addition / improvement
20
+ - [ ] CI / build / tooling change
21
+
22
+ ## Summary of Changes
23
+
24
+ <!-- Bullet list of the meaningful changes. -->
25
+
26
+ -
27
+ -
28
+ -
29
+
30
+ ## Affected Areas
31
+
32
+ <!-- Check all that apply. -->
33
+
34
+ - [ ] Backend (`backend/`)
35
+ - [ ] Frontend (`frontend/`)
36
+ - [ ] Database schema (`packages/db/`)
37
+ - [ ] Docker / deployment
38
+ - [ ] Documentation
39
+ - [ ] CI workflows
40
+
41
+ ## Database Changes
42
+
43
+ <!-- If you modified Drizzle schema or migrations, describe them. -->
44
+
45
+ - [ ] No schema changes
46
+ - [ ] Schema change — `bun run db:generate` produced new migration(s)
47
+ - [ ] Migration applied locally and tested
48
+
49
+ ## Testing
50
+
51
+ <!-- Describe how you tested this change. Include commands you ran. -->
52
+
53
+ ### Local Verification
54
+
55
+ ```bash
56
+ # Commands run locally
57
+ bun install
58
+ bun run lint
59
+ bun run typecheck
60
+ bun test
61
+ ```
62
+
63
+ ### Manual / E2E
64
+
65
+ - [ ] Verified in `bun run dev:all` (backend + frontend)
66
+ - [ ] Verified in `docker compose up -d`
67
+ - [ ] Browser-tested with `agent-browser` (no Playwright)
68
+
69
+ ## Checklist
70
+
71
+ <!-- Author self-review before requesting review. -->
72
+
73
+ - [ ] Code follows the project's style and conventions (`AGENTS.md`)
74
+ - [ ] Bun-native — no npm/yarn, no Node-only assumptions
75
+ - [ ] ESM-only — no CommonJS
76
+ - [ ] TypeScript strict — no `any` introduced, Zod validation on inputs
77
+ - [ ] No hardcoded secrets, paths, or keys (all via `.env`)
78
+ - [ ] `bun run lint` passes
79
+ - [ ] `bun run typecheck` passes
80
+ - [ ] `bun test` passes
81
+ - [ ] New tests added for new functionality
82
+ - [ ] Documentation updated (`docs/`, `README.md`, or inline JSDoc)
83
+ - [ ] Self-reviewed the diff — no debug code, console.logs, or commented-out blocks
84
+ - [ ] PR title follows Conventional Commits (`feat:`, `fix:`, `chore:`, `docs:`, `refactor:`, `test:`)
85
+
86
+ ## Screenshots / Recordings
87
+
88
+ <!-- If UI changes, attach before/after screenshots or a short recording. -->
89
+
90
+ ## Breaking Changes & Migration
91
+
92
+ <!-- If this is a breaking change, describe the migration path. -->
93
+
94
+ ## Additional Notes
95
+
96
+ <!-- Anything reviewers should pay special attention to. -->