shutong-backend 0.0.1__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 (92) hide show
  1. shutong_backend-0.0.1/.gitignore +163 -0
  2. shutong_backend-0.0.1/PKG-INFO +88 -0
  3. shutong_backend-0.0.1/README.md +62 -0
  4. shutong_backend-0.0.1/pyproject.toml +42 -0
  5. shutong_backend-0.0.1/server.json +36 -0
  6. shutong_backend-0.0.1/shutong_backend/__init__.py +5 -0
  7. shutong_backend-0.0.1/shutong_backend/agents/__init__.py +44 -0
  8. shutong_backend-0.0.1/shutong_backend/agents/chat.py +604 -0
  9. shutong_backend-0.0.1/shutong_backend/agents/claim_extraction.py +213 -0
  10. shutong_backend-0.0.1/shutong_backend/agents/clarification.py +131 -0
  11. shutong_backend-0.0.1/shutong_backend/agents/code_subagent.py +239 -0
  12. shutong_backend-0.0.1/shutong_backend/agents/compact.py +178 -0
  13. shutong_backend-0.0.1/shutong_backend/agents/contradiction.py +5 -0
  14. shutong_backend-0.0.1/shutong_backend/agents/coordinator.py +5 -0
  15. shutong_backend-0.0.1/shutong_backend/agents/corpus_loader.py +183 -0
  16. shutong_backend-0.0.1/shutong_backend/agents/depth.py +115 -0
  17. shutong_backend-0.0.1/shutong_backend/agents/devils_advocate.py +210 -0
  18. shutong_backend-0.0.1/shutong_backend/agents/gap_identification.py +5 -0
  19. shutong_backend-0.0.1/shutong_backend/agents/generation.py +370 -0
  20. shutong_backend-0.0.1/shutong_backend/agents/hierarchy_classification.py +5 -0
  21. shutong_backend-0.0.1/shutong_backend/agents/indexing.py +199 -0
  22. shutong_backend-0.0.1/shutong_backend/agents/ingest.py +5 -0
  23. shutong_backend-0.0.1/shutong_backend/agents/integrity.py +189 -0
  24. shutong_backend-0.0.1/shutong_backend/agents/librarian.py +5 -0
  25. shutong_backend-0.0.1/shutong_backend/agents/literature_review.py +5 -0
  26. shutong_backend-0.0.1/shutong_backend/agents/memory.py +121 -0
  27. shutong_backend-0.0.1/shutong_backend/agents/models.py +267 -0
  28. shutong_backend-0.0.1/shutong_backend/agents/pageindex_retrieval.py +378 -0
  29. shutong_backend-0.0.1/shutong_backend/agents/pipeline.py +307 -0
  30. shutong_backend-0.0.1/shutong_backend/agents/quality_gate.py +270 -0
  31. shutong_backend-0.0.1/shutong_backend/agents/query_planner.py +206 -0
  32. shutong_backend-0.0.1/shutong_backend/agents/retrieval.py +354 -0
  33. shutong_backend-0.0.1/shutong_backend/agents/review/__init__.py +205 -0
  34. shutong_backend-0.0.1/shutong_backend/agents/structure.py +5 -0
  35. shutong_backend-0.0.1/shutong_backend/agents/v12_runtime.py +948 -0
  36. shutong_backend-0.0.1/shutong_backend/agents/writing/__init__.py +15 -0
  37. shutong_backend-0.0.1/shutong_backend/agents/writing/draft.py +190 -0
  38. shutong_backend-0.0.1/shutong_backend/agents/writing/outline.py +183 -0
  39. shutong_backend-0.0.1/shutong_backend/agents/writing/pipeline.py +288 -0
  40. shutong_backend-0.0.1/shutong_backend/agents/writing/quality.py +132 -0
  41. shutong_backend-0.0.1/shutong_backend/agents/writing/style.py +232 -0
  42. shutong_backend-0.0.1/shutong_backend/analysis.py +305 -0
  43. shutong_backend-0.0.1/shutong_backend/cli.py +151 -0
  44. shutong_backend-0.0.1/shutong_backend/diary.py +114 -0
  45. shutong_backend-0.0.1/shutong_backend/doctor.py +181 -0
  46. shutong_backend-0.0.1/shutong_backend/graph.py +103 -0
  47. shutong_backend-0.0.1/shutong_backend/ingestion/__init__.py +13 -0
  48. shutong_backend-0.0.1/shutong_backend/ingestion/deterministic.py +65 -0
  49. shutong_backend-0.0.1/shutong_backend/llm/__init__.py +9 -0
  50. shutong_backend-0.0.1/shutong_backend/llm/provider.py +301 -0
  51. shutong_backend-0.0.1/shutong_backend/llm/registry.py +81 -0
  52. shutong_backend-0.0.1/shutong_backend/mcp_server.py +915 -0
  53. shutong_backend-0.0.1/shutong_backend/papers.py +566 -0
  54. shutong_backend-0.0.1/shutong_backend/passport.py +123 -0
  55. shutong_backend-0.0.1/shutong_backend/permissions.py +195 -0
  56. shutong_backend-0.0.1/shutong_backend/rpc_server.py +736 -0
  57. shutong_backend-0.0.1/shutong_backend/server.py +352 -0
  58. shutong_backend-0.0.1/shutong_backend/state.py +133 -0
  59. shutong_backend-0.0.1/shutong_backend/templates/AGENTS.md.j2 +63 -0
  60. shutong_backend-0.0.1/shutong_backend/templates/commands/ingest.md +8 -0
  61. shutong_backend-0.0.1/shutong_backend/templates/commands/research.md +8 -0
  62. shutong_backend-0.0.1/shutong_backend/templates/commands/verify.md +8 -0
  63. shutong_backend-0.0.1/shutong_backend/templates/global-agents.md +20 -0
  64. shutong_backend-0.0.1/shutong_backend/templates/global-shutong.json +26 -0
  65. shutong_backend-0.0.1/shutong_backend/templates/glossary/theology-en-zh.json +50 -0
  66. shutong_backend-0.0.1/shutong_backend/templates/shutong.json +54 -0
  67. shutong_backend-0.0.1/shutong_backend/templates/skills/analysis-plan/SKILL.md +12 -0
  68. shutong_backend-0.0.1/shutong_backend/templates/skills/citation-check/SKILL.md +12 -0
  69. shutong_backend-0.0.1/shutong_backend/templates/skills/cite-research/SKILL.md +13 -0
  70. shutong_backend-0.0.1/shutong_backend/templates/skills/evidence-synthesis/SKILL.md +10 -0
  71. shutong_backend-0.0.1/shutong_backend/templates/skills/ingest-source/SKILL.md +12 -0
  72. shutong_backend-0.0.1/shutong_backend/templates/skills/text-analysis/SKILL.md +18 -0
  73. shutong_backend-0.0.1/shutong_backend/templates/skills/translate-academic/SKILL.md +16 -0
  74. shutong_backend-0.0.1/shutong_backend/templates/skills/verify-corpus/SKILL.md +12 -0
  75. shutong_backend-0.0.1/shutong_backend/templates/skills/workspace-planner/SKILL.md +12 -0
  76. shutong_backend-0.0.1/shutong_backend/templates.py +94 -0
  77. shutong_backend-0.0.1/shutong_backend/tools/__init__.py +1 -0
  78. shutong_backend-0.0.1/shutong_backend/tools/bibliography.py +141 -0
  79. shutong_backend-0.0.1/shutong_backend/tools/code.py +296 -0
  80. shutong_backend-0.0.1/shutong_backend/tools/corpus.py +92 -0
  81. shutong_backend-0.0.1/shutong_backend/tools/errors.py +25 -0
  82. shutong_backend-0.0.1/shutong_backend/tools/glossary.py +24 -0
  83. shutong_backend-0.0.1/shutong_backend/tools/ingest.py +156 -0
  84. shutong_backend-0.0.1/shutong_backend/tools/memory.py +39 -0
  85. shutong_backend-0.0.1/shutong_backend/tools/research.py +73 -0
  86. shutong_backend-0.0.1/shutong_backend/tools/translate.py +29 -0
  87. shutong_backend-0.0.1/shutong_backend/tools/verify.py +185 -0
  88. shutong_backend-0.0.1/shutong_backend/translation/__init__.py +11 -0
  89. shutong_backend-0.0.1/shutong_backend/translation/glossary.py +97 -0
  90. shutong_backend-0.0.1/shutong_backend/translation/pipeline.py +419 -0
  91. shutong_backend-0.0.1/shutong_backend/workspaces.py +128 -0
  92. shutong_backend-0.0.1/uv.lock +7990 -0
@@ -0,0 +1,163 @@
1
+ # OS files
2
+ .DS_Store
3
+ Thumbs.db
4
+
5
+ # Database files
6
+ *.db
7
+ *.sqlite
8
+ *.sqlite3
9
+
10
+ # Bun / Node
11
+ node_modules/
12
+ bun.lock
13
+ bun.lockb
14
+ .bun/
15
+ .bunx/
16
+ .npm/
17
+ .pnpm-store/
18
+ .yarn/
19
+ .pnp.*
20
+ .turbo/
21
+ npm-debug.log*
22
+ yarn-debug.log*
23
+ yarn-error.log*
24
+ bun-debug.log*
25
+
26
+ # Python
27
+ __pycache__/
28
+ *.py[cod]
29
+ *$py.class
30
+ *.so
31
+ .Python
32
+ build/
33
+ develop-eggs/
34
+ dist/
35
+ downloads/
36
+ eggs/
37
+ .eggs/
38
+ lib/
39
+ lib64/
40
+ parts/
41
+ sdist/
42
+ var/
43
+ wheels/
44
+ share/python-wheels/
45
+ *.egg-info/
46
+ .installed.cfg
47
+ *.egg
48
+ MANIFEST
49
+ .venv/
50
+ venv/
51
+ ENV/
52
+ env/
53
+ .pytest_cache/
54
+ .tox/
55
+ .nox/
56
+ .coverage
57
+ .coverage.*
58
+ .mypy_cache/
59
+ .ruff_cache/
60
+ .pyre/
61
+ .pytype/
62
+ .ipynb_checkpoints/
63
+ __pypackages__/
64
+ .uv/
65
+ pip-wheel-metadata/
66
+ htmlcov/
67
+ .cache
68
+ nosetests.xml
69
+ coverage.xml
70
+ *.cover
71
+ .hypothesis/
72
+ .python-version
73
+
74
+ # Rust
75
+ target/
76
+ Cargo.lock
77
+ *.rs.bk
78
+ *.pdb
79
+
80
+ # ── Secrets & Credentials ──
81
+ .env
82
+ .env.*
83
+ !.env.example
84
+ *.pem
85
+ *.key
86
+ *.p12
87
+ *.pfx
88
+ *.jks
89
+ *.kdbx
90
+ *.der
91
+ *.agekey
92
+ *.token
93
+ *.tokens
94
+ *.secret
95
+ *.secrets
96
+ id_rsa*
97
+ id_ed25519*
98
+ id_ecdsa*
99
+ credentials.json
100
+ service-account*.json
101
+ .netrc
102
+ .npmrc
103
+ .pypirc
104
+ .authinfo
105
+ .pgpass
106
+ .aws/
107
+ .config/gcloud/
108
+ .kube/
109
+ .secrets
110
+ .secrets.*
111
+
112
+ # ── Security scan artifacts ──
113
+ .gitleaks-report.json
114
+
115
+ # Project specific
116
+ test_output/
117
+ corpus/
118
+ library/
119
+ papers/
120
+ projects/
121
+ research/
122
+ private/
123
+ exports/
124
+ uploads/
125
+ downloads/
126
+ source-cache/
127
+ tmp/
128
+ temp/
129
+ # Local model downloads and their logs
130
+ *.gguf
131
+ mmproj_download.log
132
+ tests/**/*
133
+ example/
134
+ shutong/dist/
135
+ shutong/python-backend/
136
+ .omc/
137
+ .opencode/
138
+ .swarm/
139
+ .agent/
140
+ .agents/
141
+ .claude/
142
+ .codex/
143
+ .mcp.json
144
+ opencode.json
145
+ opencode.jsonc
146
+ .code-review-graph/
147
+ .omx/
148
+ .shutong/
149
+ .ropeproject/
150
+
151
+ # IDEs
152
+ .vscode/
153
+ .idea/
154
+ *.swp
155
+ *.swo
156
+ *~
157
+
158
+ # MemPalace per-project files (issue #185)
159
+ mempalace.yaml
160
+ entities.json
161
+ # CocoIndex Code (ccc)
162
+ /.cocoindex_code/
163
+
@@ -0,0 +1,88 @@
1
+ Metadata-Version: 2.5
2
+ Name: shutong-backend
3
+ Version: 0.0.1
4
+ Summary: Citation-verified scholarly research over a local corpus (MCP server)
5
+ License-Expression: MIT
6
+ Requires-Python: >=3.12
7
+ Requires-Dist: citeindex==0.13.2
8
+ Requires-Dist: citeproc-py>=0.7.0
9
+ Requires-Dist: click>=8.0
10
+ Requires-Dist: dspy-ai<3
11
+ Requires-Dist: dspy<3
12
+ Requires-Dist: jinja2>=3.1
13
+ Requires-Dist: jsonschema>=4.20.0
14
+ Requires-Dist: lxml>=4.9.0
15
+ Requires-Dist: mcp<2,>=1.27
16
+ Requires-Dist: pymupdf[mupdf-third]>=1.26.3
17
+ Requires-Dist: pypdf2>=3.0.1
18
+ Requires-Dist: python-dateutil>=2.8.0
19
+ Requires-Dist: python-dotenv>=1.1.0
20
+ Requires-Dist: pyyaml>=6.0.0
21
+ Requires-Dist: requests>=2.31.0
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
24
+ Requires-Dist: pytest>=8.0; extra == 'dev'
25
+ Description-Content-Type: text/markdown
26
+
27
+ # Shutong backend
28
+
29
+ <!-- mcp-name: io.github.Areopaguaworkshop/shutong -->
30
+
31
+ MCP server and scholarly backend for Shutong. Citation-verified research over a
32
+ local corpus: search, Merkle verification, bibliography checkpoints, notes,
33
+ claims, audits, and DOCX export.
34
+
35
+ ## Run the MCP server
36
+
37
+ ```bash
38
+ uvx shutong-backend-mcp
39
+ ```
40
+
41
+ The server speaks stdio. Configure a corpus path with `SHUTONG_CORPUS_ROOT`.
42
+
43
+ ## Prerequisites
44
+
45
+ - Python 3.12 or newer. `uvx` downloads it when missing.
46
+ - `citeindex` is a separate project that Shutong depends on. It brings
47
+ paddlepaddle, mineru, whisperx, pyannote and playwright, so the first install
48
+ is about 13 GB and needs a network connection. Shutong does not vendor or fork
49
+ it.
50
+ - For ingestion you also need the models citeindex downloads on first use.
51
+
52
+ ## Host configuration
53
+
54
+ Claude Desktop:
55
+
56
+ ```json
57
+ { "mcpServers": { "shutong": { "command": "uvx", "args": ["shutong-backend-mcp"],
58
+ "env": { "SHUTONG_CORPUS_ROOT": "/abs/path/to/corpus" } } } }
59
+ ```
60
+
61
+ OpenCode V2 (`opencode.json`):
62
+
63
+ ```json
64
+ { "mcp": { "servers": { "shutong": { "type": "local",
65
+ "command": ["uvx", "shutong-backend-mcp"],
66
+ "environment": { "SHUTONG_CORPUS_ROOT": "/abs/path/to/corpus" } } } } }
67
+ ```
68
+
69
+ Codex (`~/.codex/config.toml`):
70
+
71
+ ```toml
72
+ [mcp_servers.shutong]
73
+ command = "uvx"
74
+ args = ["shutong-backend-mcp"]
75
+ env = { SHUTONG_CORPUS_ROOT = "/abs/path/to/corpus" }
76
+ ```
77
+
78
+ ## Setup and diagnostics
79
+
80
+ ```bash
81
+ shutong-backend init # scaffold AGENTS.md, corpus/, library/
82
+ shutong-backend doctor # Ollama, citeindex, GROBID, corpus
83
+ shutong-backend doctor --surface # MCP tools, skill pack, no agent layer
84
+ ```
85
+
86
+ ## License
87
+
88
+ MIT.
@@ -0,0 +1,62 @@
1
+ # Shutong backend
2
+
3
+ <!-- mcp-name: io.github.Areopaguaworkshop/shutong -->
4
+
5
+ MCP server and scholarly backend for Shutong. Citation-verified research over a
6
+ local corpus: search, Merkle verification, bibliography checkpoints, notes,
7
+ claims, audits, and DOCX export.
8
+
9
+ ## Run the MCP server
10
+
11
+ ```bash
12
+ uvx shutong-backend-mcp
13
+ ```
14
+
15
+ The server speaks stdio. Configure a corpus path with `SHUTONG_CORPUS_ROOT`.
16
+
17
+ ## Prerequisites
18
+
19
+ - Python 3.12 or newer. `uvx` downloads it when missing.
20
+ - `citeindex` is a separate project that Shutong depends on. It brings
21
+ paddlepaddle, mineru, whisperx, pyannote and playwright, so the first install
22
+ is about 13 GB and needs a network connection. Shutong does not vendor or fork
23
+ it.
24
+ - For ingestion you also need the models citeindex downloads on first use.
25
+
26
+ ## Host configuration
27
+
28
+ Claude Desktop:
29
+
30
+ ```json
31
+ { "mcpServers": { "shutong": { "command": "uvx", "args": ["shutong-backend-mcp"],
32
+ "env": { "SHUTONG_CORPUS_ROOT": "/abs/path/to/corpus" } } } }
33
+ ```
34
+
35
+ OpenCode V2 (`opencode.json`):
36
+
37
+ ```json
38
+ { "mcp": { "servers": { "shutong": { "type": "local",
39
+ "command": ["uvx", "shutong-backend-mcp"],
40
+ "environment": { "SHUTONG_CORPUS_ROOT": "/abs/path/to/corpus" } } } } }
41
+ ```
42
+
43
+ Codex (`~/.codex/config.toml`):
44
+
45
+ ```toml
46
+ [mcp_servers.shutong]
47
+ command = "uvx"
48
+ args = ["shutong-backend-mcp"]
49
+ env = { SHUTONG_CORPUS_ROOT = "/abs/path/to/corpus" }
50
+ ```
51
+
52
+ ## Setup and diagnostics
53
+
54
+ ```bash
55
+ shutong-backend init # scaffold AGENTS.md, corpus/, library/
56
+ shutong-backend doctor # Ollama, citeindex, GROBID, corpus
57
+ shutong-backend doctor --surface # MCP tools, skill pack, no agent layer
58
+ ```
59
+
60
+ ## License
61
+
62
+ MIT.
@@ -0,0 +1,42 @@
1
+ [project]
2
+ name = "shutong-backend"
3
+ version = "0.0.1"
4
+ description = "Citation-verified scholarly research over a local corpus (MCP server)"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ requires-python = ">=3.12"
8
+ dependencies = [
9
+ "citeindex==0.13.2",
10
+ "dspy<3",
11
+ "dspy-ai<3",
12
+ "mcp>=1.27,<2",
13
+ "click>=8.0",
14
+ "jinja2>=3.1",
15
+ "requests>=2.31.0",
16
+ "python-dateutil>=2.8.0",
17
+ "lxml>=4.9.0",
18
+ "pymupdf[mupdf-third]>=1.26.3",
19
+ "pyyaml>=6.0.0",
20
+ "jsonschema>=4.20.0",
21
+ "python-dotenv>=1.1.0",
22
+ "PyPDF2>=3.0.1",
23
+ "citeproc-py>=0.7.0",
24
+ ]
25
+
26
+ [project.scripts]
27
+ "shutong-backend" = "shutong_backend.cli:main"
28
+ "shutong-backend-mcp" = "shutong_backend.mcp_server:main"
29
+ "shutong-backend-server" = "shutong_backend.server:main"
30
+
31
+ [build-system]
32
+ requires = ["hatchling"]
33
+ build-backend = "hatchling.build"
34
+
35
+ [tool.hatch.build.targets.wheel]
36
+ packages = ["shutong_backend"]
37
+
38
+ [project.optional-dependencies]
39
+ dev = [
40
+ "pytest>=8.0",
41
+ "pytest-asyncio>=0.23",
42
+ ]
@@ -0,0 +1,36 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.Areopaguaworkshop/shutong",
4
+ "title": "Shutong",
5
+ "description": "Citation-verified scholarly research over a local corpus",
6
+ "repository": {
7
+ "url": "https://github.com/Areopaguaworkshop/shutong",
8
+ "source": "github"
9
+ },
10
+ "version": "0.0.1",
11
+ "packages": [
12
+ {
13
+ "registryType": "pypi",
14
+ "identifier": "shutong-backend",
15
+ "version": "0.0.1",
16
+ "runtimeHint": "uvx",
17
+ "transport": {
18
+ "type": "stdio"
19
+ },
20
+ "environmentVariables": [
21
+ {
22
+ "name": "SHUTONG_CORPUS_ROOT",
23
+ "description": "Absolute path to the corpus root",
24
+ "format": "string",
25
+ "isRequired": false
26
+ },
27
+ {
28
+ "name": "SHUTONG_LIBRARY_ROOT",
29
+ "description": "Absolute path to the library root",
30
+ "format": "string",
31
+ "isRequired": false
32
+ }
33
+ ]
34
+ }
35
+ ]
36
+ }
@@ -0,0 +1,5 @@
1
+ """Shutong Backend — scholar research backend for the Shutong Bun frontend."""
2
+
3
+ __all__ = ["__version__"]
4
+
5
+ __version__ = "0.0.1"
@@ -0,0 +1,44 @@
1
+ """CiteIndex Agent & Retrieval Layer (Tier 2).
2
+
3
+ Deterministic 7-agent pipeline: indexing → query planning → retrieval →
4
+ clarification → generation → integrity verification.
5
+ """
6
+
7
+ __all__ = [
8
+ "CorpusLoader",
9
+ "IndexingAgent",
10
+ "QueryPlanner",
11
+ "RetrievalAgent",
12
+ "ClarificationAgent",
13
+ "GenerationAgent",
14
+ "IntegrityVerifier",
15
+ "ChatPipeline",
16
+ ]
17
+
18
+
19
+ def __getattr__(name):
20
+ if name == "CorpusLoader":
21
+ from .corpus_loader import CorpusLoader
22
+ return CorpusLoader
23
+ if name == "IndexingAgent":
24
+ from .indexing import IndexingAgent
25
+ return IndexingAgent
26
+ if name == "QueryPlanner":
27
+ from .query_planner import QueryPlanner
28
+ return QueryPlanner
29
+ if name == "RetrievalAgent":
30
+ from .retrieval import RetrievalAgent
31
+ return RetrievalAgent
32
+ if name == "ClarificationAgent":
33
+ from .clarification import ClarificationAgent
34
+ return ClarificationAgent
35
+ if name == "GenerationAgent":
36
+ from .generation import GenerationAgent
37
+ return GenerationAgent
38
+ if name == "IntegrityVerifier":
39
+ from .integrity import IntegrityVerifier
40
+ return IntegrityVerifier
41
+ if name == "ChatPipeline":
42
+ from .chat import ChatPipeline
43
+ return ChatPipeline
44
+ raise AttributeError(f"module 'citeindex.agents' has no attribute {name!r}")