notion-nilo 0.3.0__tar.gz

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 (241) hide show
  1. notion_nilo-0.3.0/.gitignore +44 -0
  2. notion_nilo-0.3.0/CONTRIBUTING.md +38 -0
  3. notion_nilo-0.3.0/Docs/Developer/API.md +32 -0
  4. notion_nilo-0.3.0/Docs/Developer/api/cli.md +204 -0
  5. notion_nilo-0.3.0/Docs/Developer/api/core.md +95 -0
  6. notion_nilo-0.3.0/Docs/Developer/architecture/overview.md +101 -0
  7. notion_nilo-0.3.0/Docs/Developer/mcp_tools/README.md +86 -0
  8. notion_nilo-0.3.0/Docs/Developer/mcp_tools/auth.md +11 -0
  9. notion_nilo-0.3.0/Docs/Developer/mcp_tools/blocks.md +18 -0
  10. notion_nilo-0.3.0/Docs/Developer/mcp_tools/comments.md +13 -0
  11. notion_nilo-0.3.0/Docs/Developer/mcp_tools/config.md +11 -0
  12. notion_nilo-0.3.0/Docs/Developer/mcp_tools/custom_emojis.md +9 -0
  13. notion_nilo-0.3.0/Docs/Developer/mcp_tools/data_sources.md +40 -0
  14. notion_nilo-0.3.0/Docs/Developer/mcp_tools/databases.md +44 -0
  15. notion_nilo-0.3.0/Docs/Developer/mcp_tools/file_uploads.md +21 -0
  16. notion_nilo-0.3.0/Docs/Developer/mcp_tools/pages.md +22 -0
  17. notion_nilo-0.3.0/Docs/Developer/mcp_tools/raw_api.md +10 -0
  18. notion_nilo-0.3.0/Docs/Developer/mcp_tools/search.md +7 -0
  19. notion_nilo-0.3.0/Docs/Developer/mcp_tools/users.md +12 -0
  20. notion_nilo-0.3.0/Docs/Developer/mcp_tools/views.md +21 -0
  21. notion_nilo-0.3.0/Docs/Developer/packaging.md +145 -0
  22. notion_nilo-0.3.0/Docs/Developer/testing/cli.md +43 -0
  23. notion_nilo-0.3.0/Docs/Developer/testing/core.md +33 -0
  24. notion_nilo-0.3.0/Docs/Developer/testing/live.md +60 -0
  25. notion_nilo-0.3.0/Docs/Developer/testing/mcp.md +33 -0
  26. notion_nilo-0.3.0/Docs/Developer/testing/scenarios.md +49 -0
  27. notion_nilo-0.3.0/Docs/Developer/testing/strategy.md +41 -0
  28. notion_nilo-0.3.0/Docs/User/Cli/Auth_And_User.md +23 -0
  29. notion_nilo-0.3.0/Docs/User/Cli/Block.md +24 -0
  30. notion_nilo-0.3.0/Docs/User/Cli/Comments.md +19 -0
  31. notion_nilo-0.3.0/Docs/User/Cli/Database_DataSource.md +77 -0
  32. notion_nilo-0.3.0/Docs/User/Cli/File_Uploads.md +23 -0
  33. notion_nilo-0.3.0/Docs/User/Cli/MCP_Server.md +62 -0
  34. notion_nilo-0.3.0/Docs/User/Cli/Overview.md +27 -0
  35. notion_nilo-0.3.0/Docs/User/Cli/Page.md +39 -0
  36. notion_nilo-0.3.0/Docs/User/Cli/Project_Config.md +29 -0
  37. notion_nilo-0.3.0/Docs/User/Cli/Raw_API.md +17 -0
  38. notion_nilo-0.3.0/Docs/User/Cli/Search_And_Custom_Emoji.md +19 -0
  39. notion_nilo-0.3.0/Docs/User/Cli/Views.md +23 -0
  40. notion_nilo-0.3.0/Docs/User/Cli.md +37 -0
  41. notion_nilo-0.3.0/Docs/User/Configuration.md +253 -0
  42. notion_nilo-0.3.0/Docs/User/Guide.md +108 -0
  43. notion_nilo-0.3.0/Docs/User/Installation.md +127 -0
  44. notion_nilo-0.3.0/Docs/User/MCP_Clients.md +304 -0
  45. notion_nilo-0.3.0/Docs/User/Troubleshooting.md +65 -0
  46. notion_nilo-0.3.0/Docs/User/Uninstallation.md +160 -0
  47. notion_nilo-0.3.0/Docs/skills/CHANGELOG.md +9 -0
  48. notion_nilo-0.3.0/Docs/skills/README.md +46 -0
  49. notion_nilo-0.3.0/Docs/skills/claude/SKILL.md +31 -0
  50. notion_nilo-0.3.0/Docs/skills/codex/SKILL.md +38 -0
  51. notion_nilo-0.3.0/Docs/skills/references/full.md +147 -0
  52. notion_nilo-0.3.0/Docs/skills/references/normal.md +58 -0
  53. notion_nilo-0.3.0/Docs/skills/references/quick.md +31 -0
  54. notion_nilo-0.3.0/Docs/skills/third_party/SKILL.md +32 -0
  55. notion_nilo-0.3.0/LICENSE +201 -0
  56. notion_nilo-0.3.0/PKG-INFO +124 -0
  57. notion_nilo-0.3.0/README.md +89 -0
  58. notion_nilo-0.3.0/SECURITY.md +41 -0
  59. notion_nilo-0.3.0/env.example +19 -0
  60. notion_nilo-0.3.0/pyproject.toml +150 -0
  61. notion_nilo-0.3.0/requirements.txt +10 -0
  62. notion_nilo-0.3.0/src/nilo/README.md +33 -0
  63. notion_nilo-0.3.0/src/nilo/__init__.py +26 -0
  64. notion_nilo-0.3.0/src/nilo/cli/__init__.py +11 -0
  65. notion_nilo-0.3.0/src/nilo/cli/app.py +75 -0
  66. notion_nilo-0.3.0/src/nilo/cli/commands/__init__.py +18 -0
  67. notion_nilo-0.3.0/src/nilo/cli/commands/auth.py +71 -0
  68. notion_nilo-0.3.0/src/nilo/cli/commands/blocks.py +247 -0
  69. notion_nilo-0.3.0/src/nilo/cli/commands/comments.py +89 -0
  70. notion_nilo-0.3.0/src/nilo/cli/commands/config.py +422 -0
  71. notion_nilo-0.3.0/src/nilo/cli/commands/custom_emojis.py +54 -0
  72. notion_nilo-0.3.0/src/nilo/cli/commands/data_sources.py +180 -0
  73. notion_nilo-0.3.0/src/nilo/cli/commands/databases.py +656 -0
  74. notion_nilo-0.3.0/src/nilo/cli/commands/file_uploads.py +104 -0
  75. notion_nilo-0.3.0/src/nilo/cli/commands/init.py +28 -0
  76. notion_nilo-0.3.0/src/nilo/cli/commands/pages.py +712 -0
  77. notion_nilo-0.3.0/src/nilo/cli/commands/project.py +191 -0
  78. notion_nilo-0.3.0/src/nilo/cli/commands/raw_api.py +47 -0
  79. notion_nilo-0.3.0/src/nilo/cli/commands/search.py +36 -0
  80. notion_nilo-0.3.0/src/nilo/cli/commands/server.py +248 -0
  81. notion_nilo-0.3.0/src/nilo/cli/commands/status.py +87 -0
  82. notion_nilo-0.3.0/src/nilo/cli/commands/users.py +63 -0
  83. notion_nilo-0.3.0/src/nilo/cli/commands/version.py +69 -0
  84. notion_nilo-0.3.0/src/nilo/cli/commands/views.py +99 -0
  85. notion_nilo-0.3.0/src/nilo/cli/core_services.py +169 -0
  86. notion_nilo-0.3.0/src/nilo/cli/formatting.py +64 -0
  87. notion_nilo-0.3.0/src/nilo/config.py +96 -0
  88. notion_nilo-0.3.0/src/nilo/core/__init__.py +12 -0
  89. notion_nilo-0.3.0/src/nilo/core/attachments/__init__.py +26 -0
  90. notion_nilo-0.3.0/src/nilo/core/attachments/attachment_store.py +159 -0
  91. notion_nilo-0.3.0/src/nilo/core/attachments/context_resolver.py +63 -0
  92. notion_nilo-0.3.0/src/nilo/core/attachments/database_attachment.py +274 -0
  93. notion_nilo-0.3.0/src/nilo/core/attachments/page_attachment.py +211 -0
  94. notion_nilo-0.3.0/src/nilo/core/audit.py +90 -0
  95. notion_nilo-0.3.0/src/nilo/core/auth.py +82 -0
  96. notion_nilo-0.3.0/src/nilo/core/client.py +75 -0
  97. notion_nilo-0.3.0/src/nilo/core/config.py +242 -0
  98. notion_nilo-0.3.0/src/nilo/core/errors.py +302 -0
  99. notion_nilo-0.3.0/src/nilo/core/identifiers.py +69 -0
  100. notion_nilo-0.3.0/src/nilo/core/models.py +31 -0
  101. notion_nilo-0.3.0/src/nilo/core/project/__init__.py +20 -0
  102. notion_nilo-0.3.0/src/nilo/core/project/project_config.py +224 -0
  103. notion_nilo-0.3.0/src/nilo/core/project/project_paths.py +134 -0
  104. notion_nilo-0.3.0/src/nilo/core/project/project_resolver.py +108 -0
  105. notion_nilo-0.3.0/src/nilo/core/services/__init__.py +21 -0
  106. notion_nilo-0.3.0/src/nilo/core/services/base.py +47 -0
  107. notion_nilo-0.3.0/src/nilo/core/services/blocks.py +90 -0
  108. notion_nilo-0.3.0/src/nilo/core/services/comments.py +54 -0
  109. notion_nilo-0.3.0/src/nilo/core/services/custom_emojis.py +60 -0
  110. notion_nilo-0.3.0/src/nilo/core/services/data_sources.py +115 -0
  111. notion_nilo-0.3.0/src/nilo/core/services/databases.py +95 -0
  112. notion_nilo-0.3.0/src/nilo/core/services/file_uploads.py +84 -0
  113. notion_nilo-0.3.0/src/nilo/core/services/pages.py +215 -0
  114. notion_nilo-0.3.0/src/nilo/core/services/raw_api.py +121 -0
  115. notion_nilo-0.3.0/src/nilo/core/services/search.py +26 -0
  116. notion_nilo-0.3.0/src/nilo/core/services/users.py +48 -0
  117. notion_nilo-0.3.0/src/nilo/core/services/views.py +95 -0
  118. notion_nilo-0.3.0/src/nilo/dependencies.py +44 -0
  119. notion_nilo-0.3.0/src/nilo/mcp_server/__init__.py +11 -0
  120. notion_nilo-0.3.0/src/nilo/mcp_server/process_manager.py +460 -0
  121. notion_nilo-0.3.0/src/nilo/mcp_server/runner.py +46 -0
  122. notion_nilo-0.3.0/src/nilo/mcp_server/server.py +174 -0
  123. notion_nilo-0.3.0/src/nilo/mcp_server/tools/__init__.py +23 -0
  124. notion_nilo-0.3.0/src/nilo/mcp_server/tools/auth.py +59 -0
  125. notion_nilo-0.3.0/src/nilo/mcp_server/tools/blocks.py +118 -0
  126. notion_nilo-0.3.0/src/nilo/mcp_server/tools/comments.py +62 -0
  127. notion_nilo-0.3.0/src/nilo/mcp_server/tools/config.py +67 -0
  128. notion_nilo-0.3.0/src/nilo/mcp_server/tools/custom_emojis.py +51 -0
  129. notion_nilo-0.3.0/src/nilo/mcp_server/tools/data_sources.py +123 -0
  130. notion_nilo-0.3.0/src/nilo/mcp_server/tools/databases.py +147 -0
  131. notion_nilo-0.3.0/src/nilo/mcp_server/tools/file_uploads.py +96 -0
  132. notion_nilo-0.3.0/src/nilo/mcp_server/tools/pages.py +118 -0
  133. notion_nilo-0.3.0/src/nilo/mcp_server/tools/raw_api.py +41 -0
  134. notion_nilo-0.3.0/src/nilo/mcp_server/tools/search.py +35 -0
  135. notion_nilo-0.3.0/src/nilo/mcp_server/tools/shared.py +182 -0
  136. notion_nilo-0.3.0/src/nilo/mcp_server/tools/users.py +62 -0
  137. notion_nilo-0.3.0/src/nilo/mcp_server/tools/views.py +83 -0
  138. notion_nilo-0.3.0/src/nilo/models/__init__.py +5 -0
  139. notion_nilo-0.3.0/src/nilo/models/config_model.py +21 -0
  140. notion_nilo-0.3.0/src/nilo/routes/__init__.py +8 -0
  141. notion_nilo-0.3.0/src/nilo/routes/blocks.py +65 -0
  142. notion_nilo-0.3.0/src/nilo/routes/databases.py +95 -0
  143. notion_nilo-0.3.0/src/nilo/routes/pages.py +75 -0
  144. notion_nilo-0.3.0/src/nilo/server.py +37 -0
  145. notion_nilo-0.3.0/tests/__init__.py +1 -0
  146. notion_nilo-0.3.0/tests/conftest.py +12 -0
  147. notion_nilo-0.3.0/tests/live/__init__.py +1 -0
  148. notion_nilo-0.3.0/tests/live/test_live_auth_validate.py +25 -0
  149. notion_nilo-0.3.0/tests/live/test_live_content_consistency_e2e.py +475 -0
  150. notion_nilo-0.3.0/tests/live/test_live_mcp_server_http_e2e.py +640 -0
  151. notion_nilo-0.3.0/tests/test_cli.py +42 -0
  152. notion_nilo-0.3.0/tests/test_config.py +44 -0
  153. notion_nilo-0.3.0/tests/test_server_blocks.py +58 -0
  154. notion_nilo-0.3.0/tests/test_server_databases.py +59 -0
  155. notion_nilo-0.3.0/tests/test_server_pages.py +63 -0
  156. notion_nilo-0.3.0/tests/v2/__init__.py +1 -0
  157. notion_nilo-0.3.0/tests/v2/cli/__init__.py +1 -0
  158. notion_nilo-0.3.0/tests/v2/cli/helpers.py +8 -0
  159. notion_nilo-0.3.0/tests/v2/cli/test_config_commands.py +100 -0
  160. notion_nilo-0.3.0/tests/v2/cli/test_data_source_namespace.py +91 -0
  161. notion_nilo-0.3.0/tests/v2/cli/test_database_container.py +75 -0
  162. notion_nilo-0.3.0/tests/v2/cli/test_database_shortcut_commands.py +116 -0
  163. notion_nilo-0.3.0/tests/v2/cli/test_dry_run.py +53 -0
  164. notion_nilo-0.3.0/tests/v2/cli/test_english_output_text.py +19 -0
  165. notion_nilo-0.3.0/tests/v2/cli/test_help_text.py +74 -0
  166. notion_nilo-0.3.0/tests/v2/cli/test_init.py +54 -0
  167. notion_nilo-0.3.0/tests/v2/cli/test_legacy_database_query_raw_api.py +38 -0
  168. notion_nilo-0.3.0/tests/v2/cli/test_raw_api_positioning.py +53 -0
  169. notion_nilo-0.3.0/tests/v2/cli/test_resource_commands.py +85 -0
  170. notion_nilo-0.3.0/tests/v2/cli/test_stage8_extended_resource_commands.py +141 -0
  171. notion_nilo-0.3.0/tests/v2/cli/test_stage8_status_capabilities.py +11 -0
  172. notion_nilo-0.3.0/tests/v2/cli/test_status.py +50 -0
  173. notion_nilo-0.3.0/tests/v2/core/__init__.py +1 -0
  174. notion_nilo-0.3.0/tests/v2/core/test_audit.py +27 -0
  175. notion_nilo-0.3.0/tests/v2/core/test_auth.py +53 -0
  176. notion_nilo-0.3.0/tests/v2/core/test_client.py +47 -0
  177. notion_nilo-0.3.0/tests/v2/core/test_config.py +105 -0
  178. notion_nilo-0.3.0/tests/v2/core/test_database_data_source_services.py +116 -0
  179. notion_nilo-0.3.0/tests/v2/core/test_database_service_container_only.py +5 -0
  180. notion_nilo-0.3.0/tests/v2/core/test_errors.py +30 -0
  181. notion_nilo-0.3.0/tests/v2/core/test_notion_version_policy.py +60 -0
  182. notion_nilo-0.3.0/tests/v2/core/test_packaging_metadata.py +39 -0
  183. notion_nilo-0.3.0/tests/v2/core/test_packaging_metadata_v2.py +41 -0
  184. notion_nilo-0.3.0/tests/v2/core/test_services_and_raw_api.py +173 -0
  185. notion_nilo-0.3.0/tests/v2/core/test_stage5_services_extended.py +188 -0
  186. notion_nilo-0.3.0/tests/v2/fixtures/__init__.py +1 -0
  187. notion_nilo-0.3.0/tests/v2/fixtures/fake_notion.py +36 -0
  188. notion_nilo-0.3.0/tests/v2/mcp_server/__init__.py +1 -0
  189. notion_nilo-0.3.0/tests/v2/mcp_server/test_dangerous_tools.py +30 -0
  190. notion_nilo-0.3.0/tests/v2/mcp_server/test_server_lifecycle.py +22 -0
  191. notion_nilo-0.3.0/tests/v2/mcp_server/test_stage5_tool_coverage.py +66 -0
  192. notion_nilo-0.3.0/tests/v2/mcp_server/test_tool_calls.py +65 -0
  193. notion_nilo-0.3.0/tests/v2/mcp_server/test_tool_inventory.py +54 -0
  194. notion_nilo-0.3.0/tests/v2/mcp_tools/__init__.py +1 -0
  195. notion_nilo-0.3.0/tests/v2/mcp_tools/test_database_data_source_tools.py +140 -0
  196. notion_nilo-0.3.0/tests/v2/mcp_tools/test_legacy_database_query_raw_api.py +89 -0
  197. notion_nilo-0.3.0/tests/v2/scenarios/__init__.py +1 -0
  198. notion_nilo-0.3.0/tests/v2/scenarios/test_cli_documentation_inventory.py +99 -0
  199. notion_nilo-0.3.0/tests/v2/scenarios/test_cli_to_core_to_fake_notion.py +34 -0
  200. notion_nilo-0.3.0/tests/v2/scenarios/test_documentation_reader_boundary.py +37 -0
  201. notion_nilo-0.3.0/tests/v2/scenarios/test_existing_rest_smoke.py +28 -0
  202. notion_nilo-0.3.0/tests/v2/scenarios/test_full_local_config_flow.py +35 -0
  203. notion_nilo-0.3.0/tests/v2/scenarios/test_install_and_run.py +29 -0
  204. notion_nilo-0.3.0/tests/v2/scenarios/test_isolated_install.py +41 -0
  205. notion_nilo-0.3.0/tests/v2/scenarios/test_mcp_client_flow.py +20 -0
  206. notion_nilo-0.3.0/tests/v2/scenarios/test_mcp_to_core_to_fake_notion.py +26 -0
  207. notion_nilo-0.3.0/tests/v2/scenarios/test_page_content_edit_workflow.py +97 -0
  208. notion_nilo-0.3.0/tests/v2/scenarios/test_stage1_documentation_alignment.py +63 -0
  209. notion_nilo-0.3.0/tests/v2/scenarios/test_stage7_documentation_completeness.py +64 -0
  210. notion_nilo-0.3.0/tests/v2/scenarios/test_stage8_release_readiness.py +48 -0
  211. notion_nilo-0.3.0/tests/v3/__init__.py +1 -0
  212. notion_nilo-0.3.0/tests/v3/cli/__init__.py +1 -0
  213. notion_nilo-0.3.0/tests/v3/cli/test_database_attach.py +103 -0
  214. notion_nilo-0.3.0/tests/v3/cli/test_database_context_resolution.py +132 -0
  215. notion_nilo-0.3.0/tests/v3/cli/test_database_detach.py +37 -0
  216. notion_nilo-0.3.0/tests/v3/cli/test_database_status.py +49 -0
  217. notion_nilo-0.3.0/tests/v3/cli/test_page_attach.py +89 -0
  218. notion_nilo-0.3.0/tests/v3/cli/test_page_block_edit_attach.py +120 -0
  219. notion_nilo-0.3.0/tests/v3/cli/test_page_content_attach.py +86 -0
  220. notion_nilo-0.3.0/tests/v3/cli/test_page_context_resolution.py +45 -0
  221. notion_nilo-0.3.0/tests/v3/cli/test_page_detach.py +57 -0
  222. notion_nilo-0.3.0/tests/v3/cli/test_page_insert.py +65 -0
  223. notion_nilo-0.3.0/tests/v3/cli/test_page_status.py +93 -0
  224. notion_nilo-0.3.0/tests/v3/cli/test_page_url_inputs.py +112 -0
  225. notion_nilo-0.3.0/tests/v3/cli/test_project_init.py +88 -0
  226. notion_nilo-0.3.0/tests/v3/cli/test_project_status.py +82 -0
  227. notion_nilo-0.3.0/tests/v3/cli/test_public_command_surface_revision.py +147 -0
  228. notion_nilo-0.3.0/tests/v3/core/__init__.py +1 -0
  229. notion_nilo-0.3.0/tests/v3/core/test_database_attachment_store.py +58 -0
  230. notion_nilo-0.3.0/tests/v3/core/test_identifier_parsing.py +21 -0
  231. notion_nilo-0.3.0/tests/v3/core/test_page_attachment_store.py +71 -0
  232. notion_nilo-0.3.0/tests/v3/core/test_page_content_service.py +129 -0
  233. notion_nilo-0.3.0/tests/v3/core/test_project_resolver.py +67 -0
  234. notion_nilo-0.3.0/tests/v3/scenarios/__init__.py +1 -0
  235. notion_nilo-0.3.0/tests/v3/scenarios/test_attach_database_workflow.py +115 -0
  236. notion_nilo-0.3.0/tests/v3/scenarios/test_attach_page_workflow.py +62 -0
  237. notion_nilo-0.3.0/tests/v3/scenarios/test_project_context_discovery.py +57 -0
  238. notion_nilo-0.3.0/tests/v4/cli/test_server_commands.py +106 -0
  239. notion_nilo-0.3.0/tests/v4/mcp_server/test_http_tool_output_contract.py +13 -0
  240. notion_nilo-0.3.0/tests/v4/mcp_server/test_process_manager.py +93 -0
  241. notion_nilo-0.3.0/tomllib.py +74 -0
@@ -0,0 +1,44 @@
1
+ __pycache__/
2
+ # BEGIN git-guard managed ignore rules
3
+ .*
4
+ !.gitignore
5
+ !.gitmodules
6
+ !.github/
7
+ .github/**
8
+ !.github/workflows/
9
+ !.github/workflows/*.yml
10
+ !.github/workflows/*.yaml
11
+ !.github/actions/
12
+ !.github/actions/**
13
+ !.github/ISSUE_TEMPLATE/
14
+ !.github/ISSUE_TEMPLATE/**
15
+ !.github/PULL_REQUEST_TEMPLATE.md
16
+ !.github/pull_request_template.md
17
+ !.github/PULL_REQUEST_TEMPLATE/
18
+ !.github/PULL_REQUEST_TEMPLATE/**
19
+ !.github/DISCUSSION_TEMPLATE/
20
+ !.github/DISCUSSION_TEMPLATE/**
21
+ !.github/dependabot.yml
22
+ !.github/CODEOWNERS
23
+ !.github/FUNDING.yml
24
+ !.github/SECURITY.md
25
+ !.github/CODE_OF_CONDUCT.md
26
+ !.github/CONTRIBUTING.md
27
+ !.github/SUPPORT.md
28
+ AGENTS.md
29
+ # END git-guard managed ignore rules
30
+ *.py[cod]
31
+ *.pyo
32
+ .pytest_cache/
33
+ .ruff_cache/
34
+ .mypy_cache/
35
+ .venv/
36
+ uv.lock
37
+ build/
38
+ dist/
39
+ *.egg-info/
40
+ .DS_Store
41
+ .dev_docs/
42
+ .private_docs/
43
+ tests/v5/
44
+ Docs/skills/test_copies/
@@ -0,0 +1,38 @@
1
+ # Contributing
2
+
3
+ Pull requests are welcome.
4
+
5
+ ## Before Opening a Pull Request
6
+
7
+ Use a small, focused change. Keep unrelated refactors, formatting churn, and
8
+ generated files out of the PR.
9
+
10
+ Run the local checks when they apply:
11
+
12
+ ```bash
13
+ uv run pytest -q -p no:cacheprovider
14
+ uv run ruff check .
15
+ uv run mypy src
16
+ ```
17
+
18
+ Live Notion tests require explicit opt-in and real credentials. Do not run or
19
+ document live results unless the test command, required environment variables,
20
+ and data-safety scope are clear.
21
+
22
+ ## Documentation
23
+
24
+ Update user or developer documentation when a change affects CLI commands,
25
+ MCP tools, configuration, installation, security behavior, or public package
26
+ metadata.
27
+
28
+ ## Security
29
+
30
+ Do not include real Notion tokens, private workspace content, local config files,
31
+ or unredacted logs in issues, pull requests, tests, or documentation.
32
+
33
+ Report sensitive security issues through the process in [SECURITY.md](SECURITY.md).
34
+
35
+ ## License
36
+
37
+ By contributing to this repository, you agree that your contribution is licensed
38
+ under the Apache License 2.0.
@@ -0,0 +1,32 @@
1
+ # 开发者接口索引
2
+
3
+ 本文档面向开发者,说明当前仓库的接口文档入口。当前项目已经从 REST 原型补全为本地 Notion MCP 服务器。
4
+
5
+ ## 当前接口状态
6
+
7
+ - `src/nilo/core/`:唯一业务逻辑层,供 CLI、MCP Tool 和兼容代码复用。
8
+ - `src/nilo/server.py` 与 `src/nilo/routes/`:内部 REST 原型兼容代码,不是公开 server CLI 入口,也不是最终 MCP Tool 接口。
9
+ - `src/nilo/cli/`:git-like CLI,人类入口,调用 Core。
10
+ - `src/nilo/mcp_server/`:MCP server 和 MCP tools,Agent/LLM 结构化入口,调用 Core。
11
+
12
+ ## 文档入口
13
+
14
+ - Core API:`Docs/Developer/api/core.md`
15
+ - CLI API:`Docs/Developer/api/cli.md`
16
+ - Core 测试:`Docs/Developer/testing/core.md`
17
+ - CLI 测试:`Docs/Developer/testing/cli.md`
18
+ - MCP 测试:`Docs/Developer/testing/mcp.md`
19
+ - Live 测试:`Docs/Developer/testing/live.md`
20
+ - 场景测试:`Docs/Developer/testing/scenarios.md`
21
+ - MCP Tool contract:`Docs/Developer/mcp_tools/README.md`
22
+
23
+ ## 调用边界
24
+
25
+ 目标调用关系必须保持为:
26
+
27
+ ```text
28
+ Human -> CLI -> Core
29
+ Agent / LLM -> MCP Tool -> Core
30
+ ```
31
+
32
+ 禁止 MCP Tool 通过 CLI 字符串调用,也禁止 CLI 和 MCP Tool 各自复制业务逻辑。
@@ -0,0 +1,204 @@
1
+ # CLI API
2
+
3
+ 本文档面向开发者,记录当前 `nilo` CLI 的公开命令面、隐藏兼容入口和 Core 调用边界。CLI 负责终端使用体验,业务能力必须来自 Core service。
4
+
5
+ ## 入口
6
+
7
+ - package:`nilo.cli`
8
+ - console script:`nilo = nilo.cli:app`
9
+ - root app:`src/nilo/cli/app.py`
10
+ - help options:`--help` and `-h`
11
+
12
+ ## 核心边界
13
+
14
+ ```text
15
+ CLI -> Core -> Notion SDK/API
16
+ MCP Tool -> Core -> Notion SDK/API
17
+ ```
18
+
19
+ CLI 不应直接调用 Notion SDK。新增命令时,应先确认对应 Core service 能力;如果 Core 缺失,应先补 Core,再接 CLI。
20
+
21
+ ## 公开 Root 命令
22
+
23
+ - `nilo init`
24
+ - 初始化当前目录的项目级 `.notion_mcp/`。
25
+ - 不写入 token,不要求 user id。
26
+ - `nilo pwd`
27
+ - 从当前目录向上解析项目根目录。
28
+ - `nilo version`
29
+ - 输出 MCP package version 和配置的 Notion API version。
30
+ - `nilo config --global --show`
31
+ - 输出全局配置摘要,不暴露 token。
32
+ - `nilo config --global user.token <token>`
33
+ - 更新全局 token。
34
+ - `nilo config --global user.name <name>`
35
+ - 更新全局用户显示名称。
36
+ - `nilo config --local --show`
37
+ - 输出当前项目级配置摘要。
38
+
39
+ `project`、`local`、root `status`、`config global/local` 和 `config set/get/unset/list` 只保留为隐藏兼容入口,不属于公开命令面。
40
+
41
+ ## Project Context
42
+
43
+ 项目上下文由 Core 提供:
44
+
45
+ ```text
46
+ ProjectResolver
47
+ ProjectConfigStore
48
+ AttachmentStore
49
+ ContextResolver
50
+ ```
51
+
52
+ 解析规则:
53
+
54
+ ```text
55
+ explicit id > attached state > error
56
+ ```
57
+
58
+ 项目级配置:
59
+
60
+ ```text
61
+ .notion_mcp/config.json
62
+ ```
63
+
64
+ Attach state:
65
+
66
+ ```text
67
+ .notion_mcp/state/page.attach.json
68
+ .notion_mcp/state/database.attach.json
69
+ ```
70
+
71
+ 项目级配置和 attach state 不得保存 token。
72
+
73
+ ## Page CLI
74
+
75
+ 公开命令:
76
+
77
+ Page id inputs are normalized through `src/nilo/core/identifiers.py`. Public `<page_id>` arguments accept raw page ids, copied Notion URLs, and Markdown links that contain Notion URLs.
78
+
79
+ - `nilo page attach <page_id>`
80
+ - 绑定当前项目默认 page。
81
+ - `attach` 语义是 project context binding,不是 file attachment。
82
+ - `nilo page status`
83
+ - 显示当前绑定 page。
84
+ - `nilo page refresh`
85
+ - 重新读取绑定 page 的标题、URL 和状态,只刷新本地 state,不修改 Notion 远端。
86
+ - `nilo page detach`
87
+ - 删除本地 page attach state,不修改 Notion 远端。
88
+ - `nilo page retrieve [page_id]`
89
+ - 读取 page 元信息。
90
+ - 无参数时使用 attached page。
91
+ - `nilo page blocks [page_id]`
92
+ - 读取 page 内容块摘要。
93
+ - 无参数时使用 attached page。
94
+ - `nilo page create`
95
+ - 创建 page。
96
+ - payload 没有 parent 且存在 attached page 时,默认使用 attached page 作为 parent。
97
+ - `nilo page create --parent-page <page_id>`
98
+ - 在指定 parent page 下创建 child page。
99
+ - `nilo page update <page_id>`
100
+ - 更新普通 page 或 data source entry page properties。
101
+ - `nilo page trash <page_id>`
102
+ - 将 page 移入 trash。
103
+
104
+ 隐藏兼容入口保留给旧的 page content/current/deattach aliases、旧 page-scoped block group 和旧 page insert group。它们不得作为公开用户命令记录。
105
+
106
+ ## Block CLI
107
+
108
+ 公开命令:
109
+
110
+ - `nilo block children <block_id>`
111
+ - 列出 child blocks。
112
+ - `nilo block append <block_id>`
113
+ - 追加 child blocks。
114
+ - `nilo block insert-after <block_id>`
115
+ - 在目标 block 后插入 sibling blocks。
116
+ - `nilo block update <block_id>`
117
+ - 更新 block。
118
+ - `nilo block trash <block_id>`
119
+ - 将 block 移入 trash。
120
+
121
+ `insert-before` 不作为稳定公开命令。`block remove` 只作为隐藏兼容别名,行为等同 trash。
122
+
123
+ ## Database 和 DataSource
124
+
125
+ 语义边界:
126
+
127
+ ```text
128
+ database = container
129
+ data_source = table under database
130
+ page = page or data source entry
131
+ block = page content node
132
+ ```
133
+
134
+ 容器级能力使用 `database`。表级 schema/query/templates/page-entry 能力使用 `data-source`。只有使用当前绑定 database 的 active data source 时,才允许 `database` 快捷命令。
135
+
136
+ ### Database 容器命令
137
+
138
+ - `nilo database attach <database_id>`
139
+ - `nilo database attach <database_id> --data-source <id_or_name>`
140
+ - `nilo database status`
141
+ - `nilo database refresh`
142
+ - `nilo database detach`
143
+ - `nilo database retrieve [database_id]`
144
+ - `nilo database sources [database_id]`
145
+ - `nilo database create`
146
+ - `nilo database create --parent-page <page_id>`
147
+ - `nilo database update <database_id>`
148
+ - `nilo database rename <database_id> <new_name>`
149
+
150
+ `database create` 创建 database 容器,并创建 initial data source。`database update` 只允许容器级更新,不用于修改 data source schema。
151
+
152
+ ### Database 快捷命令
153
+
154
+ 这些命令只作用于 attached database 的 active data source:
155
+
156
+ - `nilo database query --payload <json>`
157
+ - `nilo database page create --properties <json>`
158
+ - `nilo database property rename <property> <new_name>`
159
+
160
+ 公开 CLI 不提供 `database query --data-source`、`database page create <data_source_id>`、`database page update <page_id>` 或三参数 `database property rename`。显式 data source 操作必须使用 `data-source`;page property 更新使用 `page update`。
161
+
162
+ ### DataSource 命令
163
+
164
+ - `nilo data-source retrieve <data_source_id>`
165
+ - `nilo data-source query <data_source_id>`
166
+ - `nilo data-source create`
167
+ - `nilo data-source create <database_id>`
168
+ - `nilo data-source update <data_source_id>`
169
+ - `nilo data-source templates <data_source_id>`
170
+ - `nilo data-source property rename <data_source_id> <property> <new_name>`
171
+ - `nilo data-source page create <data_source_id>`
172
+
173
+ ## 其他对象域
174
+
175
+ - `nilo auth validate`
176
+ - `nilo auth whoami`
177
+ - `nilo user me/list/retrieve`
178
+ - `nilo comment list/create/reply`
179
+ - `nilo view retrieve/list/query/create/update`
180
+ - `nilo file-upload retrieve/list/create/send/complete`
181
+ - `nilo search query`
182
+ - `nilo custom-emoji list/retrieve`
183
+ - `nilo raw-api operations`
184
+ - `nilo raw-api invoke <operation>`
185
+ - `nilo server run`
186
+ - `nilo server status`
187
+ - `nilo server stop`
188
+ - `nilo server logs`
189
+ - `nilo server remove`
190
+ - `nilo server stdio`
191
+
192
+ Raw API 是高级兜底入口,不应作为普通 page/database 编辑路径。
193
+
194
+ ## 移除的旧入口
195
+
196
+ 以下旧 root 命令不再作为公开 CLI 入口:
197
+
198
+ - `nilo set-token`
199
+ - `nilo set-user`
200
+ - `nilo show`
201
+ - `nilo run`
202
+ - `nilo mcp serve`
203
+
204
+ 配置使用 `nilo config --global ...`;MCP server 使用 `nilo server ...`。
@@ -0,0 +1,95 @@
1
+ # Core API
2
+
3
+ 本文档面向开发者,记录 `src/nilo/core/` 当前已经实现的 Core 能力。Core 是唯一业务逻辑层,CLI 和 MCP Tool 都应调用 Core,而不是直接调用 Notion SDK。
4
+
5
+ ## 配置
6
+
7
+ 模块:`src/nilo/core/config.py`
8
+
9
+ - `CoreConfig`
10
+ - 保存 `notion_token`、`user_name`、`user_id`、`notion_version`、`timeout_ms`、`retry`、`default_transport` 和 `audit_enabled`。
11
+ - `user_id` 必须是 UUID。
12
+ - 默认 `notion_version` 为 `2026-03-11`。
13
+ - `init_core_config(...)`
14
+ - 初始化配置并写入本地配置文件。
15
+ - 配置文件权限写为 `0600`。
16
+ - `load_core_config(...)`
17
+ - 读取配置文件并返回严格校验后的 `CoreConfig`。
18
+ - `update_core_config(...)`
19
+ - 只更新传入字段,不清空未传入字段。
20
+ - `redacted_config(...)`
21
+ - 返回状态输出使用的脱敏配置,不泄露 token。
22
+
23
+ ## 错误模型
24
+
25
+ 模块:`src/nilo/core/errors.py`
26
+
27
+ - `CoreError`
28
+ - 所有 Core 错误的基类。
29
+ - `to_dict()` 返回 `type`、`code`、`message`、`details`。
30
+ - `ConfigNotFoundError`
31
+ - `ConfigValidationError`
32
+ - `NotionAuthError`
33
+ - `NotionOperationError`
34
+
35
+ CLI JSON 输出和 MCP tool 响应应复用这些错误结构。
36
+
37
+ ## Notion SDK Client
38
+
39
+ 模块:`src/nilo/core/client.py`
40
+
41
+ - `NotionClientFactory`
42
+ - 从 `CoreConfig` 创建 Notion SDK client。
43
+ - 注入 `auth`、`notion_version`、`timeout_ms` 和 `retry`。
44
+ - 支持 `client_cls` 和 `fake_client`,用于测试和后续 MCP 场景测试。
45
+ - `create_notion_client(...)`
46
+ - 默认 client factory 入口。
47
+
48
+ ## 认证
49
+
50
+ 模块:`src/nilo/core/auth.py`
51
+
52
+ - `AuthService.validate(...)`
53
+ - 调用 `client.users.me()` 校验 token。
54
+ - 可传入 `expected_user_id`,用于校验配置中的 Notion 用户 UUID 是否匹配当前 token。
55
+ - 返回 `AuthValidationResult`。
56
+
57
+ ## 审计
58
+
59
+ 模块:`src/nilo/core/audit.py`
60
+
61
+ - `AuditRecorder.record(...)`
62
+ - 写入 JSONL 审计记录。
63
+ - 字段包含 `timestamp`、`configured_user_id`、`operation`、`target`、`dry_run` 和 `metadata`。
64
+ - 会移除 `notion_token`、`token`、`auth`、`authorization`、`bearer` 等敏感字段。
65
+
66
+ ## Notion 对象域服务
67
+
68
+ 目录:`src/nilo/core/services/`
69
+
70
+ 当前已按对象域建立服务模块:
71
+
72
+ - `blocks.py`
73
+ - `pages.py`
74
+ - `databases.py`
75
+ - `data_sources.py`
76
+ - `users.py`
77
+ - `comments.py`
78
+ - `views.py`
79
+ - `file_uploads.py`
80
+ - `search.py`
81
+ - `custom_emojis.py`
82
+ - `raw_api.py`
83
+
84
+ 这些服务只依赖 Core 和 Notion SDK-compatible client,不导入 CLI 或 MCP 层。
85
+
86
+ ## Raw API
87
+
88
+ 模块:`src/nilo/core/services/raw_api.py`
89
+
90
+ - `registered_operations()`
91
+ - 返回允许 pass-through 的 Notion SDK 操作名。
92
+ - `RawNotionService.invoke(operation, arguments)`
93
+ - 只允许调用登记表内的操作。
94
+ - 禁止未登记操作和私有属性。
95
+ - 用于补足 “支持 Notion SDK/API 公开能力” 的扩展入口。
@@ -0,0 +1,101 @@
1
+ # Architecture Overview
2
+
3
+ 本文档面向开发者,说明当前仓库的架构边界。
4
+
5
+ ## 当前目标
6
+
7
+ 本仓库提供本地运行的 Notion MCP server。当前实现围绕以下三层展开:
8
+
9
+ - Core:唯一业务逻辑层。
10
+ - CLI:面向人类的 git-like 本地命令入口。
11
+ - MCP Tool:面向 Agent/LLM 的结构化工具入口。
12
+
13
+ 使用者安装、Notion connection 配置和命令用法放在 `Docs/User/`;本目录只记录开发者需要维护的实现边界。
14
+
15
+ ## 目标结构
16
+
17
+ ```text
18
+ Human -> CLI -> Core
19
+ Agent / LLM -> MCP Tool -> Core
20
+ ```
21
+
22
+ 必须保持:
23
+
24
+ ```text
25
+ CLI -> Core
26
+ MCP Tool -> Core
27
+ ```
28
+
29
+ 禁止:
30
+
31
+ ```text
32
+ MCP Tool 通过 CLI 字符串绕行
33
+ CLI -> Notion SDK
34
+ MCP Tool -> Notion SDK
35
+ ```
36
+
37
+ ## Core
38
+
39
+ Core 是唯一业务逻辑层,负责:
40
+
41
+ - 全局配置读写、项目级上下文解析和 token 脱敏。
42
+ - 集中管理 Notion API version、timeout 和 retry。
43
+ - 统一创建 Notion SDK-compatible client。
44
+ - auth validate 和 user/bot 信息读取。
45
+ - 按对象域封装 Notion 服务:
46
+ - pages
47
+ - blocks
48
+ - databases
49
+ - data sources
50
+ - users
51
+ - comments
52
+ - views
53
+ - file uploads
54
+ - search
55
+ - custom emojis
56
+ - raw API 登记表和高级兜底调用。
57
+ - 本地审计和统一错误模型。
58
+
59
+ ## CLI
60
+
61
+ CLI 是人类入口,负责:
62
+
63
+ - git-like 命令结构。
64
+ - 普通文本输出。
65
+ - `--json` 输出。
66
+ - `--dry-run`。
67
+ - 启动和管理 MCP server。
68
+
69
+ 公开 server 命令包括:
70
+
71
+ ```text
72
+ nilo server run
73
+ nilo server status
74
+ nilo server stop
75
+ nilo server logs
76
+ nilo server remove
77
+ nilo server stdio
78
+ ```
79
+
80
+ CLI resource command 通过 Core service 调用 Notion 能力。
81
+
82
+ 项目级 `.notion_mcp/` 目录只保存项目上下文和 attach state,不保存 token。全局配置继续保存 token、用户显示名和 Notion API version。
83
+
84
+ ## MCP Tool
85
+
86
+ MCP Tool 是 Agent/LLM 入口,负责:
87
+
88
+ - tool inventory。
89
+ - input schema。
90
+ - tool annotations。
91
+ - 结构化错误。
92
+ - 危险操作确认。
93
+
94
+ MCP Tool 直接调用 Core service,不拼 CLI 字符串。
95
+
96
+ ## 非功能边界
97
+
98
+ - token 默认不得在普通输出或 MCP config status 中明文泄露。
99
+ - CLI 和 MCP 写操作应支持 dry-run 或危险操作确认。
100
+ - live 测试默认跳过,只能在明确的测试 page/workspace 中运行。
101
+ - Notion-Version 由 Core 配置集中管理,不在 CLI、MCP tool 或单个服务里散落硬编码。
@@ -0,0 +1,86 @@
1
+ # MCP Tools 开发者文档
2
+
3
+ 本文档是 MCP tool 文档入口。当前仓库已实现 `src/nilo/mcp_server/`,使用 MCP Python SDK 的 `FastMCP` 暴露本地工具。
4
+
5
+ ## Server
6
+
7
+ - server factory:`src/nilo/mcp_server/server.py`
8
+ - package entry:`nilo.mcp_server:create_mcp_server`
9
+ - CLI stdio entry:`nilo server stdio`
10
+ - CLI background HTTP entry:`nilo server run --host 127.0.0.1 --port 8000`
11
+ - 支持 transport:`stdio`、`streamable-http`
12
+
13
+ ## 工具域文档
14
+
15
+ - `config.md`
16
+ - `auth.md`
17
+ - `pages.md`
18
+ - `blocks.md`
19
+ - `databases.md`
20
+ - `data_sources.md`
21
+ - `users.md`
22
+ - `comments.md`
23
+ - `views.md`
24
+ - `file_uploads.md`
25
+ - `search.md`
26
+ - `custom_emojis.md`
27
+ - `raw_api.md`
28
+
29
+ ## Tool Inventory
30
+
31
+ 当前 server 可枚举 46 个 tools:
32
+
33
+ - `auth_validate`
34
+ - `auth_whoami`
35
+ - `block_append`
36
+ - `block_children_list`
37
+ - `block_trash`
38
+ - `block_update`
39
+ - `comment_create`
40
+ - `comment_list`
41
+ - `comment_reply`
42
+ - `config_get`
43
+ - `config_status`
44
+ - `custom_emoji_list`
45
+ - `custom_emoji_retrieve`
46
+ - `data_source_create`
47
+ - `data_source_property_rename`
48
+ - `data_source_query`
49
+ - `data_source_retrieve`
50
+ - `data_source_templates`
51
+ - `data_source_update`
52
+ - `database_create`
53
+ - `database_query`
54
+ - `database_rename`
55
+ - `database_retrieve`
56
+ - `database_sources`
57
+ - `database_update`
58
+ - `file_upload_complete`
59
+ - `file_upload_create`
60
+ - `file_upload_list`
61
+ - `file_upload_retrieve`
62
+ - `file_upload_send`
63
+ - `page_create`
64
+ - `page_property_retrieve`
65
+ - `page_retrieve`
66
+ - `page_trash`
67
+ - `page_update`
68
+ - `raw_api_invoke`
69
+ - `raw_api_registered_operations`
70
+ - `search`
71
+ - `user_list`
72
+ - `user_me`
73
+ - `user_retrieve`
74
+ - `view_create`
75
+ - `view_list`
76
+ - `view_query`
77
+ - `view_retrieve`
78
+ - `view_update`
79
+
80
+ ## 公共规则
81
+
82
+ - MCP Tool 只能调用 Core,不能调用 CLI。
83
+ - 工具错误应返回结构化 `{"ok": false, "error": ...}`。
84
+ - token 默认必须脱敏。
85
+ - 删除、归档、trash 类危险工具必须带 `destructiveHint`,并要求 `confirm=true`。
86
+ - live Notion 权限、付费计划或真实 workspace 才能验证的能力,必须在测试和进度文档中标记。
@@ -0,0 +1,11 @@
1
+ # Auth Tools
2
+
3
+ - `auth_validate`
4
+ - 说明:通过 Core auth service 调用 `users.me()` 校验当前 token。
5
+ - 必选参数:无。
6
+ - 返回:`valid`、`user_id`、`name`、`raw`。
7
+ - live 限制:需要真实 Notion token。
8
+ - `auth_whoami`
9
+ - 说明:返回当前 token 对应的 Notion 用户信息。
10
+ - 必选参数:无。
11
+ - live 限制:需要真实 Notion token。
@@ -0,0 +1,18 @@
1
+ # Block Tools
2
+
3
+ - `block_children_list`
4
+ - 说明:列出区块子元素。
5
+ - 必选参数:`block_id`。
6
+ - `block_append`
7
+ - 说明:追加子区块,使用 Notion 2026 `position` 合约。
8
+ - 必选参数:`block_id`、`children`。
9
+ - 可选参数:`position`、`dry_run`。
10
+ - `block_update`
11
+ - 说明:更新区块。
12
+ - 必选参数:`block_id`、`payload`。
13
+ - 可选参数:`dry_run`。
14
+ - `block_trash`
15
+ - 说明:删除或 trash 区块。
16
+ - 必选参数:`block_id`、`confirm`。
17
+ - 可选参数:`dry_run`。
18
+ - 危险性:`destructiveHint=true`,缺少 `confirm=true` 会返回 `confirmation_required`。
@@ -0,0 +1,13 @@
1
+ # Comment Tools
2
+
3
+ - `comment_list`
4
+ - 说明:按 raw Notion comment query 参数列出 comments。
5
+ - 必选参数:`params`。
6
+ - `comment_create`
7
+ - 说明:创建 comment。
8
+ - 必选参数:`payload`。
9
+ - 可选参数:`dry_run`。
10
+ - `comment_reply`
11
+ - 说明:回复 discussion。
12
+ - 必选参数:`discussion_id`、`rich_text`。
13
+ - 可选参数:`dry_run`。
@@ -0,0 +1,11 @@
1
+ # Config Tools
2
+
3
+ - `config_status`
4
+ - 说明:返回本地配置状态、脱敏配置和能力标记。
5
+ - 必选参数:无。
6
+ - 返回:`configured`、`config`、`capabilities`。
7
+ - `config_get`
8
+ - 说明:读取一个配置字段。
9
+ - 必选参数:`key`。
10
+ - 可选参数:`show_secret`,默认 `false`。
11
+ - 安全:`notion_token` 默认返回 `********`。
@@ -0,0 +1,9 @@
1
+ # Custom Emoji Tools
2
+
3
+ - `custom_emoji_list`
4
+ - 说明:列出 integration 可访问的 custom emojis。
5
+ - 可选参数:`page_size`、`start_cursor`。
6
+ - `custom_emoji_retrieve`
7
+ - 说明:读取指定 custom emoji。
8
+ - 必选参数:`custom_emoji_id`。
9
+ - live 限制:取决于 workspace 是否有 custom emojis 和 API 权限。