dotscope 0.1.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 (160) hide show
  1. dotscope-0.1.0/.claude/hooks/pre-commit-check.sh +41 -0
  2. dotscope-0.1.0/.claude/settings.json +15 -0
  3. dotscope-0.1.0/.claude/settings.local.json +35 -0
  4. dotscope-0.1.0/.gitignore +10 -0
  5. dotscope-0.1.0/.mcp.json +9 -0
  6. dotscope-0.1.0/.scopes +28 -0
  7. dotscope-0.1.0/LICENSE +21 -0
  8. dotscope-0.1.0/PKG-INFO +50 -0
  9. dotscope-0.1.0/README.md +18 -0
  10. dotscope-0.1.0/docs/architecture.md +72 -0
  11. dotscope-0.1.0/docs/cli-reference.md +67 -0
  12. dotscope-0.1.0/docs/how-it-works.md +86 -0
  13. dotscope-0.1.0/docs/mcp-setup.md +255 -0
  14. dotscope-0.1.0/docs/scope-file.md +257 -0
  15. dotscope-0.1.0/dotscope/.scope +63 -0
  16. dotscope-0.1.0/dotscope/__init__.py +3 -0
  17. dotscope-0.1.0/dotscope/absorber.py +390 -0
  18. dotscope-0.1.0/dotscope/assertions.py +128 -0
  19. dotscope-0.1.0/dotscope/ast_analyzer.py +2 -0
  20. dotscope-0.1.0/dotscope/backtest.py +2 -0
  21. dotscope-0.1.0/dotscope/bench.py +141 -0
  22. dotscope-0.1.0/dotscope/budget.py +3 -0
  23. dotscope-0.1.0/dotscope/cache.py +2 -0
  24. dotscope-0.1.0/dotscope/check/__init__.py +1 -0
  25. dotscope-0.1.0/dotscope/check/acknowledge.py +2 -0
  26. dotscope-0.1.0/dotscope/check/checker.py +3 -0
  27. dotscope-0.1.0/dotscope/check/checks/__init__.py +1 -0
  28. dotscope-0.1.0/dotscope/check/checks/antipattern.py +2 -0
  29. dotscope-0.1.0/dotscope/check/checks/boundary.py +2 -0
  30. dotscope-0.1.0/dotscope/check/checks/contracts.py +3 -0
  31. dotscope-0.1.0/dotscope/check/checks/direction.py +2 -0
  32. dotscope-0.1.0/dotscope/check/checks/intent.py +2 -0
  33. dotscope-0.1.0/dotscope/check/checks/stability.py +2 -0
  34. dotscope-0.1.0/dotscope/check/constraints.py +2 -0
  35. dotscope-0.1.0/dotscope/check/models.py +15 -0
  36. dotscope-0.1.0/dotscope/cli.py +1447 -0
  37. dotscope-0.1.0/dotscope/composer.py +147 -0
  38. dotscope-0.1.0/dotscope/constants.py +45 -0
  39. dotscope-0.1.0/dotscope/context.py +60 -0
  40. dotscope-0.1.0/dotscope/counterfactual.py +180 -0
  41. dotscope-0.1.0/dotscope/debug.py +220 -0
  42. dotscope-0.1.0/dotscope/discovery.py +104 -0
  43. dotscope-0.1.0/dotscope/formatter.py +157 -0
  44. dotscope-0.1.0/dotscope/graph.py +3 -0
  45. dotscope-0.1.0/dotscope/health.py +212 -0
  46. dotscope-0.1.0/dotscope/help.py +204 -0
  47. dotscope-0.1.0/dotscope/history.py +6 -0
  48. dotscope-0.1.0/dotscope/hooks.py +2 -0
  49. dotscope-0.1.0/dotscope/ingest.py +858 -0
  50. dotscope-0.1.0/dotscope/intent.py +618 -0
  51. dotscope-0.1.0/dotscope/lessons.py +223 -0
  52. dotscope-0.1.0/dotscope/matcher.py +104 -0
  53. dotscope-0.1.0/dotscope/mcp_server.py +1081 -0
  54. dotscope-0.1.0/dotscope/models/.scope +45 -0
  55. dotscope-0.1.0/dotscope/models/__init__.py +7 -0
  56. dotscope-0.1.0/dotscope/models/core.py +288 -0
  57. dotscope-0.1.0/dotscope/models/history.py +73 -0
  58. dotscope-0.1.0/dotscope/models/intent.py +213 -0
  59. dotscope-0.1.0/dotscope/models/passes.py +58 -0
  60. dotscope-0.1.0/dotscope/models/state.py +250 -0
  61. dotscope-0.1.0/dotscope/models.py +9 -0
  62. dotscope-0.1.0/dotscope/near_miss.py +3 -0
  63. dotscope-0.1.0/dotscope/onboarding.py +2 -0
  64. dotscope-0.1.0/dotscope/parser.py +387 -0
  65. dotscope-0.1.0/dotscope/passes/.scope +105 -0
  66. dotscope-0.1.0/dotscope/passes/__init__.py +1 -0
  67. dotscope-0.1.0/dotscope/passes/ast_analyzer.py +508 -0
  68. dotscope-0.1.0/dotscope/passes/backtest.py +198 -0
  69. dotscope-0.1.0/dotscope/passes/budget_allocator.py +164 -0
  70. dotscope-0.1.0/dotscope/passes/convention_compliance.py +40 -0
  71. dotscope-0.1.0/dotscope/passes/convention_discovery.py +247 -0
  72. dotscope-0.1.0/dotscope/passes/convention_parser.py +223 -0
  73. dotscope-0.1.0/dotscope/passes/graph_builder.py +299 -0
  74. dotscope-0.1.0/dotscope/passes/history_miner.py +336 -0
  75. dotscope-0.1.0/dotscope/passes/incremental.py +149 -0
  76. dotscope-0.1.0/dotscope/passes/lang/__init__.py +38 -0
  77. dotscope-0.1.0/dotscope/passes/lang/_base.py +20 -0
  78. dotscope-0.1.0/dotscope/passes/lang/_treesitter.py +93 -0
  79. dotscope-0.1.0/dotscope/passes/lang/go.py +333 -0
  80. dotscope-0.1.0/dotscope/passes/lang/javascript.py +348 -0
  81. dotscope-0.1.0/dotscope/passes/lazy.py +152 -0
  82. dotscope-0.1.0/dotscope/passes/semantic_diff.py +160 -0
  83. dotscope-0.1.0/dotscope/passes/sentinel/__init__.py +1 -0
  84. dotscope-0.1.0/dotscope/passes/sentinel/acknowledge.py +222 -0
  85. dotscope-0.1.0/dotscope/passes/sentinel/checker.py +383 -0
  86. dotscope-0.1.0/dotscope/passes/sentinel/checks/__init__.py +1 -0
  87. dotscope-0.1.0/dotscope/passes/sentinel/checks/antipattern.py +84 -0
  88. dotscope-0.1.0/dotscope/passes/sentinel/checks/boundary.py +46 -0
  89. dotscope-0.1.0/dotscope/passes/sentinel/checks/contracts.py +148 -0
  90. dotscope-0.1.0/dotscope/passes/sentinel/checks/convention.py +54 -0
  91. dotscope-0.1.0/dotscope/passes/sentinel/checks/direction.py +71 -0
  92. dotscope-0.1.0/dotscope/passes/sentinel/checks/intent.py +207 -0
  93. dotscope-0.1.0/dotscope/passes/sentinel/checks/stability.py +66 -0
  94. dotscope-0.1.0/dotscope/passes/sentinel/checks/voice.py +108 -0
  95. dotscope-0.1.0/dotscope/passes/sentinel/constraints.py +472 -0
  96. dotscope-0.1.0/dotscope/passes/sentinel/line_filter.py +88 -0
  97. dotscope-0.1.0/dotscope/passes/sentinel/models.py +15 -0
  98. dotscope-0.1.0/dotscope/passes/virtual.py +239 -0
  99. dotscope-0.1.0/dotscope/passes/voice.py +162 -0
  100. dotscope-0.1.0/dotscope/passes/voice_defaults.py +28 -0
  101. dotscope-0.1.0/dotscope/passes/voice_discovery.py +245 -0
  102. dotscope-0.1.0/dotscope/paths.py +32 -0
  103. dotscope-0.1.0/dotscope/progress.py +44 -0
  104. dotscope-0.1.0/dotscope/regression.py +147 -0
  105. dotscope-0.1.0/dotscope/resolver.py +203 -0
  106. dotscope-0.1.0/dotscope/scanner.py +246 -0
  107. dotscope-0.1.0/dotscope/sessions.py +2 -0
  108. dotscope-0.1.0/dotscope/storage/.scope +64 -0
  109. dotscope-0.1.0/dotscope/storage/__init__.py +1 -0
  110. dotscope-0.1.0/dotscope/storage/cache.py +114 -0
  111. dotscope-0.1.0/dotscope/storage/claude_hooks.py +119 -0
  112. dotscope-0.1.0/dotscope/storage/git_hooks.py +277 -0
  113. dotscope-0.1.0/dotscope/storage/incremental_state.py +61 -0
  114. dotscope-0.1.0/dotscope/storage/mcp_config.py +98 -0
  115. dotscope-0.1.0/dotscope/storage/near_miss.py +183 -0
  116. dotscope-0.1.0/dotscope/storage/onboarding.py +150 -0
  117. dotscope-0.1.0/dotscope/storage/session_manager.py +195 -0
  118. dotscope-0.1.0/dotscope/storage/timing.py +84 -0
  119. dotscope-0.1.0/dotscope/timing.py +2 -0
  120. dotscope-0.1.0/dotscope/tokens.py +53 -0
  121. dotscope-0.1.0/dotscope/utility.py +123 -0
  122. dotscope-0.1.0/dotscope/virtual.py +3 -0
  123. dotscope-0.1.0/dotscope/visibility.py +664 -0
  124. dotscope-0.1.0/logo.png +0 -0
  125. dotscope-0.1.0/pyproject.toml +44 -0
  126. dotscope-0.1.0/tests/.scope +29 -0
  127. dotscope-0.1.0/tests/__init__.py +0 -0
  128. dotscope-0.1.0/tests/conftest.py +152 -0
  129. dotscope-0.1.0/tests/test_absorber.py +91 -0
  130. dotscope-0.1.0/tests/test_ast_analyzer.py +168 -0
  131. dotscope-0.1.0/tests/test_backtest.py +114 -0
  132. dotscope-0.1.0/tests/test_budget.py +62 -0
  133. dotscope-0.1.0/tests/test_canonical_snippet.py +70 -0
  134. dotscope-0.1.0/tests/test_cli.py +105 -0
  135. dotscope-0.1.0/tests/test_composer.py +65 -0
  136. dotscope-0.1.0/tests/test_context.py +52 -0
  137. dotscope-0.1.0/tests/test_enforcement.py +423 -0
  138. dotscope-0.1.0/tests/test_experience.py +237 -0
  139. dotscope-0.1.0/tests/test_graph.py +78 -0
  140. dotscope-0.1.0/tests/test_health.py +74 -0
  141. dotscope-0.1.0/tests/test_history.py +71 -0
  142. dotscope-0.1.0/tests/test_ingest.py +215 -0
  143. dotscope-0.1.0/tests/test_lessons.py +91 -0
  144. dotscope-0.1.0/tests/test_line_filter.py +67 -0
  145. dotscope-0.1.0/tests/test_loop.py +384 -0
  146. dotscope-0.1.0/tests/test_matcher.py +47 -0
  147. dotscope-0.1.0/tests/test_near_miss.py +161 -0
  148. dotscope-0.1.0/tests/test_parser.py +119 -0
  149. dotscope-0.1.0/tests/test_resolver.py +100 -0
  150. dotscope-0.1.0/tests/test_rigor.py +223 -0
  151. dotscope-0.1.0/tests/test_routing.py +207 -0
  152. dotscope-0.1.0/tests/test_scanner.py +54 -0
  153. dotscope-0.1.0/tests/test_sessions.py +122 -0
  154. dotscope-0.1.0/tests/test_treesitter.py +359 -0
  155. dotscope-0.1.0/tests/test_utility.py +48 -0
  156. dotscope-0.1.0/tests/test_virtual.py +71 -0
  157. dotscope-0.1.0/tests/test_visibility.py +338 -0
  158. dotscope-0.1.0/tests/test_voice_check.py +111 -0
  159. dotscope-0.1.0/tests/test_voice_discovery.py +129 -0
  160. dotscope-0.1.0/uv.lock +2375 -0
@@ -0,0 +1,41 @@
1
+ #!/bin/bash
2
+ # dotscope pre-commit enforcement for Claude Code
3
+ #
4
+ # Intercepts git commit commands and runs dotscope check on staged changes.
5
+ # Exit 2 blocks the commit and feeds the error back to the agent.
6
+ # Non-commit Bash commands pass through untouched.
7
+
8
+ set -e
9
+
10
+ INPUT=$(cat)
11
+ COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
12
+
13
+ # Only intercept git commit commands
14
+ case "$COMMAND" in
15
+ git\ commit*) ;;
16
+ *) exit 0 ;;
17
+ esac
18
+
19
+ # Run dotscope check on staged changes (30s timeout, fail open)
20
+ if command -v timeout >/dev/null 2>&1; then
21
+ OUTPUT=$(timeout 30 python3 -m dotscope.cli check 2>&1) || true
22
+ elif command -v gtimeout >/dev/null 2>&1; then
23
+ OUTPUT=$(gtimeout 30 python3 -m dotscope.cli check 2>&1) || true
24
+ else
25
+ OUTPUT=$(python3 -m dotscope.cli check 2>&1) || true
26
+ fi
27
+
28
+ # Only GUARDs block. NUDGEs and NOTEs pass through.
29
+ if echo "$OUTPUT" | grep -qE "GUARD|HOLD"; then
30
+ echo "$OUTPUT" >&2
31
+ echo "" >&2
32
+ echo "dotscope: commit blocked -- address guards before committing" >&2
33
+ exit 2
34
+ fi
35
+
36
+ # NUDGEs and NOTEs are guidance, not gates
37
+ if echo "$OUTPUT" | grep -qE "NUDGE|NOTE"; then
38
+ echo "$OUTPUT" >&2
39
+ fi
40
+
41
+ exit 0
@@ -0,0 +1,15 @@
1
+ {
2
+ "hooks": {
3
+ "PreToolUse": [
4
+ {
5
+ "matcher": "Bash",
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "command": ".claude/hooks/pre-commit-check.sh"
10
+ }
11
+ ]
12
+ }
13
+ ]
14
+ }
15
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(python3 -c \"from dotscope.mcp_server import create_server; create_server\\(\\)\")",
5
+ "Bash(python3 -c \"from dotscope.mcp_server import main\")",
6
+ "Bash(chmod +x /Users/nigel/Documents/dotscope/.claude/hooks/pre-commit-check.sh)",
7
+ "Bash(python3 -m pytest tests/ -x -q)",
8
+ "WebSearch",
9
+ "WebFetch(domain:support.claude.com)",
10
+ "Bash(python3 -m pytest tests/test_line_filter.py -x -q)",
11
+ "Bash(git add:*)",
12
+ "Bash(python3 -m dotscope.cli check --acknowledge contract_dotscope_visibility__tests_test_visibilit_f05a15 --reason \"Large feature commit — visibility changes are internal\")",
13
+ "Bash(python3 -m dotscope.cli check --acknowledge contract_dotscope_mcp_server__dotscope_models_py_556414 --reason \"Large feature commit — models.py not affected by these changes\")",
14
+ "Bash(python3 -m dotscope.cli check --acknowledge contract_dotscope_mcp_server__dotscope_budget_py_8639b0 --reason \"Large feature commit — budget.py not affected\")",
15
+ "Bash(python3 -m dotscope.cli check --acknowledge contract_dotscope_mcp_server__tests_test_visibilit_57f45e --reason \"Large feature commit — visibility tests not affected\")",
16
+ "Bash(python3 -m dotscope.cli check --acknowledge contract_dotscope_cli_py_dotscope_models_py_42c554 --reason \"Large feature commit — models.py not affected\")",
17
+ "mcp__dotscope__dotscope_acknowledge",
18
+ "Bash(git commit:*)",
19
+ "Bash(git pull:*)",
20
+ "Bash(git push:*)",
21
+ "Bash(ls /Users/nigel/Downloads/dotscope*)",
22
+ "Bash(ls -t /Users/nigel/Downloads/*.png /Users/nigel/Downloads/*.jpg /Users/nigel/Downloads/*.svg)",
23
+ "Bash(python3 -c \"from dotscope.passes.sentinel import *\")",
24
+ "Bash(grep -n \"write_text\\\\|path.write\\\\|json.dump\" /Users/nigel/Documents/dotscope/dotscope/storage/*.py)",
25
+ "Bash(grep -n \"/ \" /Users/nigel/Documents/dotscope/dotscope/passes/*.py)",
26
+ "Bash(grep -n \"\\\\.get\\(\" /Users/nigel/Documents/dotscope/dotscope/passes/sentinel/*.py)",
27
+ "Bash(wc -l /Users/nigel/Documents/dotscope/dotscope/*.py)",
28
+ "Bash(grep -n \"\\\\[\"\"\" /Users/nigel/Documents/dotscope/dotscope/passes/sentinel/checks/*.py)",
29
+ "Bash(python3 -m py_compile dotscope/passes/convention_discovery.py dotscope/passes/convention_parser.py dotscope/passes/convention_compliance.py dotscope/passes/semantic_diff.py dotscope/passes/voice_discovery.py dotscope/passes/voice_defaults.py dotscope/passes/voice.py dotscope/passes/lazy.py dotscope/passes/incremental.py dotscope/passes/graph_builder.py dotscope/passes/history_miner.py dotscope/passes/budget_allocator.py dotscope/passes/backtest.py dotscope/passes/ast_analyzer.py dotscope/passes/virtual.py)",
30
+ "Bash(grep -n \"sys.exit\\(1\\)\" dotscope/*.py)",
31
+ "Bash(grep -n \"$\\\\|echo\\\\|grep\" /Users/nigel/Documents/dotscope/dotscope/storage/git_hooks.py)",
32
+ "Bash(grep -n \"\\\\.get.*\\\\[0\\\\]\" dotscope/passes/*.py)"
33
+ ]
34
+ }
35
+ }
@@ -0,0 +1,10 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .venv/
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ .pytest_cache/
8
+ .ruff_cache/
9
+ .mypy_cache/
10
+ .dotscope/
@@ -0,0 +1,9 @@
1
+ {
2
+ "mcpServers": {
3
+ "dotscope": {
4
+ "command": "python3",
5
+ "args": ["-m", "dotscope.mcp_server"],
6
+ "env": {}
7
+ }
8
+ }
9
+ }
dotscope-0.1.0/.scopes ADDED
@@ -0,0 +1,28 @@
1
+ version: 1
2
+ total_repo_tokens: 42000
3
+
4
+ scopes:
5
+ models:
6
+ path: dotscope/models/.scope
7
+ keywords: [models, dataclasses, types, core, history, intent, state]
8
+ description: Data models — the single source of truth for all types
9
+ passes:
10
+ path: dotscope/passes/.scope
11
+ keywords: [analysis, ast, graph, budget, enforcement, sentinel, checks]
12
+ description: Analysis engine — the active verbs of the compiler
13
+ storage:
14
+ path: dotscope/storage/.scope
15
+ keywords: [storage, sessions, hooks, cache, onboarding, timing]
16
+ description: Infrastructure — disk I/O, hooks, caching, state persistence
17
+ dotscope:
18
+ path: dotscope/.scope
19
+ keywords: [cli, mcp, resolve, ingest, compose, parse, format, visibility]
20
+ description: Root interfaces and orchestrators
21
+ tests:
22
+ path: tests/.scope
23
+ keywords: [tests, pytest, enforcement, experience, rigor, e2e]
24
+ description: Test suite — 266 tests across all features
25
+
26
+ defaults:
27
+ max_tokens: 8000
28
+ include_related: false
dotscope-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Supremum
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,50 @@
1
+ Metadata-Version: 2.4
2
+ Name: dotscope
3
+ Version: 0.1.0
4
+ Summary: Directory-scoped context boundaries for AI coding agents
5
+ Author: Supremum
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Keywords: agents,ai,coding,context,mcp,scope
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Software Development :: Libraries
14
+ Requires-Python: >=3.10
15
+ Requires-Dist: tree-sitter-go>=0.23.0
16
+ Requires-Dist: tree-sitter-javascript>=0.23.0
17
+ Requires-Dist: tree-sitter-typescript>=0.23.0
18
+ Requires-Dist: tree-sitter>=0.23.0
19
+ Provides-Extra: all
20
+ Requires-Dist: mcp>=1.2.0; extra == 'all'
21
+ Requires-Dist: tiktoken; extra == 'all'
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest; extra == 'dev'
24
+ Requires-Dist: ruff; extra == 'dev'
25
+ Provides-Extra: embeddings
26
+ Requires-Dist: sentence-transformers; extra == 'embeddings'
27
+ Provides-Extra: mcp
28
+ Requires-Dist: mcp>=1.2.0; extra == 'mcp'
29
+ Provides-Extra: tokens
30
+ Requires-Dist: tiktoken; extra == 'tokens'
31
+ Description-Content-Type: text/markdown
32
+
33
+ <p align="center">
34
+ <img src="logo.png" alt="dotscope" width="400">
35
+ </p>
36
+
37
+ When agents write your code, no one remembers the architecture.
38
+ Which files depend on each other. Which patterns the last agent followed.
39
+ What breaks when you change something.
40
+
41
+ dotscope remembers. It reads your codebase, learns the rules, and
42
+ gives every agent the context it needs — before it writes a line.
43
+
44
+ Works on existing codebases and new projects. Point it at anything.
45
+
46
+ ```
47
+ pip install dotscope && dotscope init
48
+ ```
49
+
50
+ [How It Works](docs/how-it-works.md) · [Docs](docs/scope-file.md) · [MIT](LICENSE)
@@ -0,0 +1,18 @@
1
+ <p align="center">
2
+ <img src="logo.png" alt="dotscope" width="400">
3
+ </p>
4
+
5
+ When agents write your code, no one remembers the architecture.
6
+ Which files depend on each other. Which patterns the last agent followed.
7
+ What breaks when you change something.
8
+
9
+ dotscope remembers. It reads your codebase, learns the rules, and
10
+ gives every agent the context it needs — before it writes a line.
11
+
12
+ Works on existing codebases and new projects. Point it at anything.
13
+
14
+ ```
15
+ pip install dotscope && dotscope init
16
+ ```
17
+
18
+ [How It Works](docs/how-it-works.md) · [Docs](docs/scope-file.md) · [MIT](LICENSE)
@@ -0,0 +1,72 @@
1
+ # Architecture
2
+
3
+ dotscope is structured as an agentic compiler. Data definitions (Nouns), analysis operations (Verbs), and persistence (Memory).
4
+
5
+ ```
6
+ dotscope/
7
+ ├── models/ # What the compiler knows
8
+ │ ├── core.py # Static structure (AST, graph, scopes, conventions)
9
+ │ ├── history.py # Empirical behavior (contracts, stability)
10
+ │ ├── intent.py # Human rules (intents, conventions, assertions, checks)
11
+ │ ├── state.py # Persistent memory (sessions, observations)
12
+ │ └── passes.py # Transient outputs (ingest plans, semantic diffs)
13
+ ├── passes/ # What the compiler does
14
+ │ ├── graph_builder.py # Dependency analysis
15
+ │ ├── history_miner.py # Git history mining
16
+ │ ├── budget_allocator.py # Token budgeting with assertions
17
+ │ ├── convention_discovery.py # Discover conventions from structural patterns
18
+ │ ├── convention_parser.py # Match files to conventions, check rules
19
+ │ ├── convention_compliance.py # Compliance tracking + severity
20
+ │ ├── semantic_diff.py # Convention-level structural diff
21
+ │ ├── voice_discovery.py # Scan codebase for coding style patterns
22
+ │ ├── voice_defaults.py # Prescriptive defaults for new codebases
23
+ │ ├── voice.py # Voice injection into resolve responses
24
+ │ ├── lazy.py # On-demand single-module ingest
25
+ │ ├── incremental.py # Post-commit incremental scope updates
26
+ │ └── sentinel/ # Routing engine (8 checks, constraints, decay)
27
+ ├── storage/ # How the compiler remembers
28
+ │ ├── session_manager.py # Session + observation persistence
29
+ │ ├── cache.py # Cached analysis data
30
+ │ ├── git_hooks.py # Pre-commit routing + post-commit feedback
31
+ │ ├── claude_hooks.py # Claude Code PreToolUse hook
32
+ │ ├── mcp_config.py # Auto-detect IDE, write MCP config
33
+ │ ├── onboarding.py # Stage-aware milestone tracking
34
+ │ ├── timing.py # Operation instrumentation
35
+ │ ├── near_miss.py # Near-miss detection persistence
36
+ │ └── incremental_state.py # Continuous ingest drift tracking
37
+ ├── progress.py # Streaming progress emitter
38
+ ├── help.py # Hand-written help text
39
+ ├── cli.py # Human interface
40
+ └── mcp_server.py # Agent interface
41
+ ```
42
+
43
+ The Nouns live in `models/`. The Verbs live in `passes/`. The Memory lives in `storage/`. The Interfaces are at the root.
44
+
45
+ ## Design Principles
46
+
47
+ **Routing, not enforcement.** Constraints at resolve time are the bowling bumpers. Checks at commit time verify the bumpers worked. Only frozen modules and deprecated imports hard-block.
48
+
49
+ **Severity levels:** GUARD (blocks commit), NUDGE (prints guidance, passes through), NOTE (informational). Nudges that fire 3+ times auto-escalate to GUARD.
50
+
51
+ **Zero dependencies.** Python 3.9+ stdlib only. Cross-platform.
52
+
53
+ ## What's in `.dotscope/`
54
+
55
+ Runtime state. Gitignored. Fully rebuildable via `dotscope ingest .`.
56
+
57
+ ```
58
+ .dotscope/
59
+ history.json # Cached implicit contracts, stabilities, hotspots
60
+ graph_hubs.json # Cached cross-cutting hub analysis
61
+ invariants.json # Contracts, function co-changes, file stabilities
62
+ sessions/ # Per-session JSON files (predictions)
63
+ observations/ # Observation events from post-commit hooks
64
+ regressions/ # Frozen successful sessions (regression test cases)
65
+ near_misses.jsonl # Detected near-misses
66
+ utility_scores.json # Per-file utility scores
67
+ nudge_occurrences.jsonl # NUDGE escalation tracking
68
+ timings.jsonl # Operation timing data
69
+ acknowledgments.jsonl # Acknowledged guards with reasons
70
+ onboarding.json # Milestone tracking
71
+ last_session.json # Scopes resolved in most recent session
72
+ ```
@@ -0,0 +1,67 @@
1
+ # CLI Reference
2
+
3
+ ## Setup
4
+
5
+ ```bash
6
+ pip install dotscope
7
+ dotscope init
8
+ ```
9
+
10
+ `dotscope init` does everything: ingest, hook install, MCP config for detected IDEs. One command.
11
+
12
+ For manual setup or re-runs:
13
+
14
+ ```bash
15
+ dotscope ingest . # Full re-ingest
16
+ dotscope hook install # Re-install hooks
17
+ ```
18
+
19
+ ## Commands
20
+
21
+ ```bash
22
+ # Context
23
+ dotscope resolve auth --budget 4000
24
+ dotscope resolve auth+payments
25
+
26
+ # Routing verification
27
+ dotscope check
28
+ dotscope check --backtest
29
+ dotscope intent add freeze core/
30
+
31
+ # Conventions
32
+ dotscope conventions # List all conventions + compliance
33
+ dotscope conventions --discover # Discover patterns from codebase
34
+ dotscope diff --staged # Semantic diff against conventions
35
+
36
+ # Voice
37
+ dotscope voice # Show discovered voice config
38
+ dotscope voice --upgrade typing # Tighten enforcement as codebase improves
39
+
40
+ # Rigor
41
+ dotscope test-compiler
42
+ dotscope bench
43
+ dotscope debug --last
44
+
45
+ # Hooks
46
+ dotscope hook install # Pre-commit routing + post-commit feedback
47
+ dotscope hook claude # Claude Code pre-commit hook (defense-in-depth)
48
+ dotscope hook status # Check what's installed
49
+
50
+ # Maintenance
51
+ dotscope health
52
+ dotscope impact auth/tokens.py
53
+ ```
54
+
55
+ ## MCP Server
56
+
57
+ For agents, add the MCP server:
58
+
59
+ ```json
60
+ {
61
+ "mcpServers": {
62
+ "dotscope": { "command": "dotscope-mcp" }
63
+ }
64
+ }
65
+ ```
66
+
67
+ `dotscope init` configures this automatically for Claude Desktop, Claude Code, and Cursor.
@@ -0,0 +1,86 @@
1
+ # How It Works
2
+
3
+ You run `dotscope init`. It scans your codebase. From that point on, every agent that touches your code gets the full picture — what files matter, what patterns to follow, and what not to break.
4
+
5
+ ## What happens when you run `dotscope init`
6
+
7
+ dotscope reads every file in your project and learns three things:
8
+
9
+ **Which files are connected.** If `billing.py` and `webhook_handler.py` always change together in your git history, dotscope knows. When an agent changes one, it gets told to check the other.
10
+
11
+ **What patterns your code follows.** If every file in `api/routes/` uses the same decorator and never touches the database directly, dotscope recognizes that as a convention. New files in that folder will follow the same pattern automatically.
12
+
13
+ **How your code is written.** Type hints on most functions? Google-style docstrings? No bare `except:` blocks? dotscope measures the style of your existing code and teaches agents to match it.
14
+
15
+ After the scan, dotscope:
16
+ - Installs git hooks so it stays up to date on every commit
17
+ - Connects to your AI tool (Claude Desktop, Claude Code, or Cursor) automatically
18
+ - Shows you what it would have caught in your last 50 commits
19
+
20
+ ## What agents see
21
+
22
+ When an agent starts working on your code, it asks dotscope: "What do I need to know about this part of the project?"
23
+
24
+ dotscope responds with:
25
+ - **The right files** — not the whole repo, just the ones that matter for this task
26
+ - **The rules** — which files are connected, what patterns to follow, what imports are off-limits
27
+ - **The style** — how the existing code is written, so new code matches
28
+
29
+ The agent gets all of this before writing a single line. It writes code that fits in on the first try.
30
+
31
+ ## What happens when something goes wrong
32
+
33
+ Before every commit, dotscope checks the agent's work:
34
+
35
+ - **Blocks** (rare) — The agent tried to modify a frozen module or use deprecated code. The commit is stopped. The agent fixes it.
36
+ - **Nudges** (common) — The agent changed a file without updating its counterpart, or drifted from a convention. The agent sees the guidance and self-corrects.
37
+ - **Notes** (informational) — Something worth knowing but not worth blocking.
38
+
39
+ Most of the time, nothing fires. The routing is good enough that agents follow the rules without needing to be corrected.
40
+
41
+ ## It gets smarter over time
42
+
43
+ Every commit teaches dotscope something. Did the agent need a file that wasn't included? Next time, it will be. Did a convention hold up across 50 commits? Its enforcement gets stronger. Did a rule get overridden three times in a month? It gets quieter.
44
+
45
+ You don't need to configure any of this. It happens automatically through the git hooks installed during `dotscope init`.
46
+
47
+ ## What you can customize
48
+
49
+ dotscope works out of the box, but you can tune it:
50
+
51
+ **Freeze a module.** If you have stable code that agents shouldn't touch:
52
+ ```
53
+ dotscope intent add freeze core/
54
+ ```
55
+ Any change to `core/` will be blocked until acknowledged.
56
+
57
+ **Deprecate a file.** If you're migrating away from old code:
58
+ ```
59
+ dotscope intent add deprecate utils/legacy.py --replacement utils/helpers.py
60
+ ```
61
+ Agents that try to import from the old file get redirected.
62
+
63
+ **Edit conventions.** dotscope discovers conventions automatically, but you can add your own or adjust the ones it found. They live in `intent.yaml` at the root of your project.
64
+
65
+ ## What gets created
66
+
67
+ dotscope creates two kinds of files:
68
+
69
+ **`.scope` files** (one per folder) — These describe what an agent needs to know about that part of your code. Commit them. They're your project's memory.
70
+
71
+ **`.dotscope/` folder** — Machine state. Gitignored. Rebuilds automatically if deleted.
72
+
73
+ Both are plain text. You can read them, edit them, or ignore them entirely.
74
+
75
+ ## Languages supported
76
+
77
+ Python, JavaScript, TypeScript, and Go get full analysis — every function, every class, every import relationship mapped.
78
+
79
+ Other languages get basic import detection (enough for the dependency graph and git history analysis, but no convention or style discovery).
80
+
81
+ ## Further reading
82
+
83
+ - [The .scope File](scope-file.md) — what's inside a scope file and how to edit it
84
+ - [MCP Server Setup](mcp-setup.md) — manual setup for AI tools (usually not needed after `dotscope init`)
85
+ - [CLI Reference](cli-reference.md) — every command dotscope offers
86
+ - [Architecture](architecture.md) — how dotscope itself is built (for contributors)