doubled-graph 1.0.2__tar.gz → 1.0.4__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.
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/PKG-INFO +44 -4
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/README.md +43 -3
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/docs/HOOKS.md +1 -1
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/docs/METHODOLOGY_README.md +1 -1
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/methodology/README.md +1 -1
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/methodology/runtime-adapters/claude-code.md +1 -1
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/methodology/runtime-adapters/codex.md +1 -1
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/methodology/runtime-adapters/continue.md +1 -1
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/methodology/runtime-adapters/cursor.md +1 -1
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/methodology/runtime-adapters/local-llm.md +1 -1
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/methodology/runtime-adapters/windsurf.md +1 -1
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/methodology/tools.md +1 -1
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/pyproject.toml +1 -1
- doubled_graph-1.0.4/src/doubled_graph/integrations/grace_cli.py +334 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/src/doubled_graph/setup.py +75 -24
- doubled_graph-1.0.2/src/doubled_graph/integrations/grace_cli.py +0 -147
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/.gitignore +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/LICENSE +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/docs/CHANGELOG.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/docs/SPEC.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/docs/TOOLS.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/for-ai-existing-project/README.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/for-ai-maintenance/README.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/for-ai-new-project/README.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/methodology/approval-checkpoints.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/methodology/artifacts.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/methodology/auto-scaling.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/methodology/drift-and-priority.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/methodology/language-adapters/_template.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/methodology/language-adapters/csharp.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/methodology/language-adapters/go.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/methodology/language-adapters/java.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/methodology/language-adapters/python.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/methodology/language-adapters/rust.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/methodology/language-adapters/swift.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/methodology/language-adapters/typescript.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/methodology/principles.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/methodology/roles.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/methodology/runtime-adapters/_template.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/methodology/workflow.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/prompts/maintenance/on-after-edit.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/prompts/maintenance/on-before-edit.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/prompts/maintenance/on-drift-detected.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/prompts/maintenance/on-user-manual-edit.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/prompts/migrate-existing-project/00-entry-prompt.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/prompts/migrate-existing-project/01-discover.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/prompts/migrate-existing-project/02-reconstruct-intent.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/prompts/migrate-existing-project/03-draft-plan.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/prompts/migrate-existing-project/04-markup-codebase.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/prompts/migrate-existing-project/05-verification-and-logs.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/prompts/migrate-existing-project/06-validation-gates.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/prompts/new-project/00-entry-prompt.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/prompts/new-project/01-intent-interview.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/prompts/new-project/02-requirements.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/prompts/new-project/03-technology.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/prompts/new-project/04-development-plan.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/prompts/new-project/05-verification-plan.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/prompts/new-project/06-generate.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/prompts/new-project/07-post-init-sync.md +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/src/doubled_graph/__init__.py +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/src/doubled_graph/__main__.py +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/src/doubled_graph/cli.py +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/src/doubled_graph/config.py +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/src/doubled_graph/graphs/__init__.py +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/src/doubled_graph/graphs/crossref.py +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/src/doubled_graph/graphs/declared.py +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/src/doubled_graph/hooks_installer.py +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/src/doubled_graph/integrations/__init__.py +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/src/doubled_graph/integrations/cgc.py +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/src/doubled_graph/policy/__init__.py +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/src/doubled_graph/policy/phase.py +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/src/doubled_graph/server.py +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/src/doubled_graph/storage/__init__.py +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/src/doubled_graph/storage/paths.py +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/src/doubled_graph/tools/__init__.py +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/src/doubled_graph/tools/_meta.py +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/src/doubled_graph/tools/analyze.py +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/src/doubled_graph/tools/context.py +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/src/doubled_graph/tools/detect_changes.py +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/src/doubled_graph/tools/impact.py +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/tests/__init__.py +0 -0
- {doubled_graph-1.0.2 → doubled_graph-1.0.4}/tests/test_smoke.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: doubled-graph
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.4
|
|
4
4
|
Summary: MCP facade over CodeGraphContext + grace-marketplace: impact, context, drift-detect for LLM-driven codebases.
|
|
5
5
|
Project-URL: Homepage, https://github.com/rour/doubled-graph-mcp
|
|
6
6
|
Project-URL: Repository, https://github.com/rour/doubled-graph-mcp
|
|
@@ -54,12 +54,34 @@ MCP-сервер для LLM-агентов, работающих с больши
|
|
|
54
54
|
|
|
55
55
|
## Установка
|
|
56
56
|
|
|
57
|
-
**Требования:** Python 3.11+, Bun/
|
|
57
|
+
**Требования:** Python 3.11+, Bun/Node (для grace-cli), [pipx](https://pipx.pypa.io/).
|
|
58
|
+
|
|
59
|
+
`doubled-graph` — CLI-утилита. Рекомендуемый способ — `pipx`: он ставит её в изолированный venv и кладёт бинарь в PATH. Это также обходит PEP 668 (`externally-managed-environment`) на современных Homebrew/Debian/Ubuntu.
|
|
60
|
+
|
|
61
|
+
### 1. Установить pipx
|
|
62
|
+
|
|
63
|
+
| OS | Команда |
|
|
64
|
+
|---|---|
|
|
65
|
+
| macOS | `brew install pipx` |
|
|
66
|
+
| Debian / Ubuntu | `sudo apt install pipx` |
|
|
67
|
+
| Fedora | `sudo dnf install pipx` |
|
|
68
|
+
| Arch | `sudo pacman -S python-pipx` |
|
|
69
|
+
| Windows / прочее | `python3 -m pip install --user pipx` |
|
|
70
|
+
|
|
71
|
+
После установки один раз добавьте pipx-папку в PATH и перезапустите терминал:
|
|
58
72
|
|
|
59
73
|
```bash
|
|
60
|
-
|
|
74
|
+
pipx ensurepath
|
|
61
75
|
```
|
|
62
76
|
|
|
77
|
+
### 2. Установить doubled-graph
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pipx install doubled-graph
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
> Уже работаете в своём venv или conda-окружении? Тогда подойдёт обычная установка: `python3 -m pip install doubled-graph`.
|
|
84
|
+
|
|
63
85
|
---
|
|
64
86
|
|
|
65
87
|
## Первые шаги
|
|
@@ -72,7 +94,7 @@ doubled-graph setup
|
|
|
72
94
|
```
|
|
73
95
|
|
|
74
96
|
Одна команда:
|
|
75
|
-
- установит `@osovv/grace-cli` через `bun
|
|
97
|
+
- установит `@osovv/grace-cli` через первый найденный JS-менеджер (`bun` → `npm` → `yarn` → `pnpm`)
|
|
76
98
|
- скопирует `prompts/` и `methodology/` в репозиторий
|
|
77
99
|
- зарегистрирует MCP-сервер в вашей IDE (Claude Code / Cursor / Continue)
|
|
78
100
|
- установит `git post-commit` хук для автообновления графа
|
|
@@ -132,6 +154,24 @@ doubled-graph phase set post_migration --reason "migration complete"
|
|
|
132
154
|
|
|
133
155
|
---
|
|
134
156
|
|
|
157
|
+
## Удаление
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
pipx uninstall doubled-graph
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
(или `python3 -m pip uninstall doubled-graph`, если ставили в venv).
|
|
164
|
+
|
|
165
|
+
Это снимает сам CLI и Python-зависимости. Артефакты, которые `doubled-graph setup` создал в вашем репозитории, нужно удалить вручную:
|
|
166
|
+
|
|
167
|
+
- запись `doubled-graph` в `.mcp.json` (Claude Code) / `.cursor/mcp.json` / `.continue/config.json`
|
|
168
|
+
- скопированные `prompts/` и `methodology/` — если они больше не нужны
|
|
169
|
+
- git-хук `.git/hooks/post-commit` (проверьте содержимое — там может быть ваша логика поверх нашей)
|
|
170
|
+
- локальный кеш графа: `rm -rf .doubled-graph`
|
|
171
|
+
- grace-cli (отдельный Bun/Node-пакет) — через тот менеджер, которым ставился: `bun remove -g @osovv/grace-cli` или `npm uninstall -g @osovv/grace-cli`
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
135
175
|
## Документация
|
|
136
176
|
|
|
137
177
|
- [SPEC.md](docs/SPEC.md) — архитектура, хранилище `.doubled-graph/`
|
|
@@ -20,12 +20,34 @@ MCP-сервер для LLM-агентов, работающих с больши
|
|
|
20
20
|
|
|
21
21
|
## Установка
|
|
22
22
|
|
|
23
|
-
**Требования:** Python 3.11+, Bun/
|
|
23
|
+
**Требования:** Python 3.11+, Bun/Node (для grace-cli), [pipx](https://pipx.pypa.io/).
|
|
24
|
+
|
|
25
|
+
`doubled-graph` — CLI-утилита. Рекомендуемый способ — `pipx`: он ставит её в изолированный venv и кладёт бинарь в PATH. Это также обходит PEP 668 (`externally-managed-environment`) на современных Homebrew/Debian/Ubuntu.
|
|
26
|
+
|
|
27
|
+
### 1. Установить pipx
|
|
28
|
+
|
|
29
|
+
| OS | Команда |
|
|
30
|
+
|---|---|
|
|
31
|
+
| macOS | `brew install pipx` |
|
|
32
|
+
| Debian / Ubuntu | `sudo apt install pipx` |
|
|
33
|
+
| Fedora | `sudo dnf install pipx` |
|
|
34
|
+
| Arch | `sudo pacman -S python-pipx` |
|
|
35
|
+
| Windows / прочее | `python3 -m pip install --user pipx` |
|
|
36
|
+
|
|
37
|
+
После установки один раз добавьте pipx-папку в PATH и перезапустите терминал:
|
|
24
38
|
|
|
25
39
|
```bash
|
|
26
|
-
|
|
40
|
+
pipx ensurepath
|
|
27
41
|
```
|
|
28
42
|
|
|
43
|
+
### 2. Установить doubled-graph
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pipx install doubled-graph
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
> Уже работаете в своём venv или conda-окружении? Тогда подойдёт обычная установка: `python3 -m pip install doubled-graph`.
|
|
50
|
+
|
|
29
51
|
---
|
|
30
52
|
|
|
31
53
|
## Первые шаги
|
|
@@ -38,7 +60,7 @@ doubled-graph setup
|
|
|
38
60
|
```
|
|
39
61
|
|
|
40
62
|
Одна команда:
|
|
41
|
-
- установит `@osovv/grace-cli` через `bun
|
|
63
|
+
- установит `@osovv/grace-cli` через первый найденный JS-менеджер (`bun` → `npm` → `yarn` → `pnpm`)
|
|
42
64
|
- скопирует `prompts/` и `methodology/` в репозиторий
|
|
43
65
|
- зарегистрирует MCP-сервер в вашей IDE (Claude Code / Cursor / Continue)
|
|
44
66
|
- установит `git post-commit` хук для автообновления графа
|
|
@@ -98,6 +120,24 @@ doubled-graph phase set post_migration --reason "migration complete"
|
|
|
98
120
|
|
|
99
121
|
---
|
|
100
122
|
|
|
123
|
+
## Удаление
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
pipx uninstall doubled-graph
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
(или `python3 -m pip uninstall doubled-graph`, если ставили в venv).
|
|
130
|
+
|
|
131
|
+
Это снимает сам CLI и Python-зависимости. Артефакты, которые `doubled-graph setup` создал в вашем репозитории, нужно удалить вручную:
|
|
132
|
+
|
|
133
|
+
- запись `doubled-graph` в `.mcp.json` (Claude Code) / `.cursor/mcp.json` / `.continue/config.json`
|
|
134
|
+
- скопированные `prompts/` и `methodology/` — если они больше не нужны
|
|
135
|
+
- git-хук `.git/hooks/post-commit` (проверьте содержимое — там может быть ваша логика поверх нашей)
|
|
136
|
+
- локальный кеш графа: `rm -rf .doubled-graph`
|
|
137
|
+
- grace-cli (отдельный Bun/Node-пакет) — через тот менеджер, которым ставился: `bun remove -g @osovv/grace-cli` или `npm uninstall -g @osovv/grace-cli`
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
101
141
|
## Документация
|
|
102
142
|
|
|
103
143
|
- [SPEC.md](docs/SPEC.md) — архитектура, хранилище `.doubled-graph/`
|
|
@@ -172,7 +172,7 @@ doubled-graph init-hooks --prepare-commit-msg # явно просит пост
|
|
|
172
172
|
```
|
|
173
173
|
1. checkout
|
|
174
174
|
2. setup Python + Bun
|
|
175
|
-
3.
|
|
175
|
+
3. pipx install doubled-graph ; bun add -g @osovv/grace-cli
|
|
176
176
|
4. doubled-graph analyze --mode full ← CI стартует с чистого листа
|
|
177
177
|
5. doubled-graph detect_changes --scope compare --base-ref ${{ github.base_ref }}
|
|
178
178
|
6. grace lint
|
|
@@ -41,7 +41,7 @@ doubled-graph — методология разработки программн
|
|
|
41
41
|
Методология **не работает** без стека:
|
|
42
42
|
|
|
43
43
|
- `grace-marketplace` (skills + CLI `grace`, Bun) — `bun add -g @osovv/grace-cli`.
|
|
44
|
-
- `doubled-graph` (MCP facade, Python, этот репозиторий) — `
|
|
44
|
+
- `doubled-graph` (MCP facade, Python, этот репозиторий) — `pipx install doubled-graph`.
|
|
45
45
|
- IDE с поддержкой **tools + MCP**. Без них промпты `../prompts/**` нельзя исполнить.
|
|
46
46
|
|
|
47
47
|
Это — осознанный компромисс (см. `tools.md §1`). Методология отказывается от tool-agnostic-риторики в пользу робастности: автоматизация через инструменты даёт одинаковый результат вне зависимости от опыта пользователя.
|
|
@@ -45,7 +45,7 @@ Codex имеет approval mode (suggest / auto-edit / full-auto):
|
|
|
45
45
|
## 6. Установка за 60 секунд
|
|
46
46
|
|
|
47
47
|
```bash
|
|
48
|
-
|
|
48
|
+
pipx install doubled-graph
|
|
49
49
|
bun add -g @osovv/grace-cli
|
|
50
50
|
doubled-graph init-hooks --post-commit
|
|
51
51
|
# создать .codex/mcp.json (§2)
|
|
@@ -55,7 +55,7 @@ Continue имеет tool approval UI (accept/deny per tool call). Настрой
|
|
|
55
55
|
## 7. Установка за 90 секунд
|
|
56
56
|
|
|
57
57
|
```bash
|
|
58
|
-
|
|
58
|
+
pipx install doubled-graph
|
|
59
59
|
bun add -g @osovv/grace-cli
|
|
60
60
|
doubled-graph init-hooks --post-commit
|
|
61
61
|
# создать .continue/config.json (§2)
|
|
@@ -105,7 +105,7 @@ curl -fsSL https://ollama.com/install.sh | sh
|
|
|
105
105
|
ollama pull qwen3-coder:30b-q4
|
|
106
106
|
|
|
107
107
|
# 2. doubled-graph tooling
|
|
108
|
-
|
|
108
|
+
pipx install doubled-graph
|
|
109
109
|
bun add -g @osovv/grace-cli
|
|
110
110
|
doubled-graph init-hooks --post-commit
|
|
111
111
|
|
|
@@ -43,7 +43,7 @@ Windsurf имеет auto-accept и per-command approval. Аналогично Cu
|
|
|
43
43
|
## 6. Установка за 90 секунд
|
|
44
44
|
|
|
45
45
|
```bash
|
|
46
|
-
|
|
46
|
+
pipx install doubled-graph
|
|
47
47
|
bun add -g @osovv/grace-cli
|
|
48
48
|
doubled-graph init-hooks --post-commit
|
|
49
49
|
# Отредактировать ~/.codeium/windsurf/mcp_config.json (§2)
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "doubled-graph"
|
|
7
|
-
version = "1.0.
|
|
7
|
+
version = "1.0.4"
|
|
8
8
|
description = "MCP facade over CodeGraphContext + grace-marketplace: impact, context, drift-detect for LLM-driven codebases."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { text = "MIT" }
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
"""grace-cli (Bun binary) integration — subprocess wrapper."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import shutil
|
|
7
|
+
import subprocess
|
|
8
|
+
import sys
|
|
9
|
+
from dataclasses import dataclass
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class GraceCLIMissing(RuntimeError):
|
|
15
|
+
"""Raised when `grace` executable is not in $PATH."""
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
_PACKAGE = "@osovv/grace-cli"
|
|
19
|
+
|
|
20
|
+
# Ordered preference of JS package managers for installing grace-cli.
|
|
21
|
+
# Bun is upstream's default; npm/yarn/pnpm are accepted fallbacks so users
|
|
22
|
+
# without Bun (e.g. typical Node installs) don't hit a dead end.
|
|
23
|
+
INSTALLERS: list[tuple[str, list[str]]] = [
|
|
24
|
+
("bun", ["bun", "add", "-g", _PACKAGE]),
|
|
25
|
+
("npm", ["npm", "install", "-g", _PACKAGE]),
|
|
26
|
+
("yarn", ["yarn", "global", "add", _PACKAGE]),
|
|
27
|
+
("pnpm", ["pnpm", "add", "-g", _PACKAGE]),
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# Per-package-manager commands — keep classification hints portable across bun/npm/yarn/pnpm.
|
|
32
|
+
_INSTALL_CMD = {
|
|
33
|
+
"bun": f"bun add -g {_PACKAGE}",
|
|
34
|
+
"npm": f"npm install -g {_PACKAGE}",
|
|
35
|
+
"yarn": f"yarn global add {_PACKAGE}",
|
|
36
|
+
"pnpm": f"pnpm add -g {_PACKAGE}",
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
_UNINSTALL_CMD = {
|
|
40
|
+
"bun": f"bun remove -g {_PACKAGE}",
|
|
41
|
+
"npm": f"npm uninstall -g {_PACKAGE}",
|
|
42
|
+
"yarn": f"yarn global remove {_PACKAGE}",
|
|
43
|
+
"pnpm": f"pnpm remove -g {_PACKAGE}",
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
_PROXY_HINT = {
|
|
47
|
+
"bun": "Bun reads `HTTP_PROXY` / `HTTPS_PROXY` env vars and `~/.bunfig.toml`.",
|
|
48
|
+
"npm": "For npm: `npm config set proxy <url>` and `npm config set https-proxy <url>`.",
|
|
49
|
+
"yarn": "For yarn: `yarn config set proxy <url>` and `yarn config set https-proxy <url>`.",
|
|
50
|
+
"pnpm": "For pnpm: `pnpm config set proxy <url>` and `pnpm config set https-proxy <url>`.",
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
_PERMISSION_HINT = {
|
|
54
|
+
"bun": (
|
|
55
|
+
"Global install was denied. Ensure `~/.bun/bin` is writable and on PATH; "
|
|
56
|
+
"don't run Bun with sudo (it installs into the invoking user's home)."
|
|
57
|
+
),
|
|
58
|
+
"npm": (
|
|
59
|
+
"Global install was denied by the OS. Don't run with sudo; instead point npm "
|
|
60
|
+
"at a user-writable prefix: `npm config set prefix ~/.npm-global` and add "
|
|
61
|
+
"`~/.npm-global/bin` to PATH."
|
|
62
|
+
),
|
|
63
|
+
"yarn": (
|
|
64
|
+
"Global install was denied. Check write access to `yarn global dir` — run as "
|
|
65
|
+
"the owning user, not sudo."
|
|
66
|
+
),
|
|
67
|
+
"pnpm": (
|
|
68
|
+
"Global install was denied. Set `PNPM_HOME` to a user-writable directory and "
|
|
69
|
+
"ensure it is on PATH (`pnpm setup` configures this for you)."
|
|
70
|
+
),
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _classify_install_error(pm: str, output: str) -> tuple[str, str]:
|
|
75
|
+
"""Best-effort: map package-manager output to (error_type, actionable hint).
|
|
76
|
+
|
|
77
|
+
The tokens we look for span bun/npm/yarn/pnpm phrasings — Node-style errno
|
|
78
|
+
codes (ETIMEDOUT, EACCES, …) which appear in npm/yarn/pnpm, plus the plain-
|
|
79
|
+
English variants that bun emits. The hint is then formatted per `pm` so we
|
|
80
|
+
never tell a bun user to run an npm command.
|
|
81
|
+
|
|
82
|
+
The raw output stays in `stderr` for bug reports; this just surfaces the
|
|
83
|
+
actionable bit so the user doesn't have to parse a 2000-char log.
|
|
84
|
+
"""
|
|
85
|
+
out = output.lower()
|
|
86
|
+
install_cmd = _INSTALL_CMD.get(pm, _INSTALL_CMD["npm"])
|
|
87
|
+
uninstall_cmd = _UNINSTALL_CMD.get(pm, _UNINSTALL_CMD["npm"])
|
|
88
|
+
proxy_hint = _PROXY_HINT.get(pm, _PROXY_HINT["npm"])
|
|
89
|
+
|
|
90
|
+
if any(t in out for t in ("etimedout", "esockettimedout", "econnreset", "timed out", " timeout")):
|
|
91
|
+
return (
|
|
92
|
+
"network_timeout",
|
|
93
|
+
f"Registry request timed out. Check network/VPN and retry. {proxy_hint}",
|
|
94
|
+
)
|
|
95
|
+
if any(
|
|
96
|
+
t in out
|
|
97
|
+
for t in (
|
|
98
|
+
"enotfound", "getaddrinfo", "econnrefused", "connection refused",
|
|
99
|
+
"failed to resolve", "unable to resolve host", "could not resolve host",
|
|
100
|
+
)
|
|
101
|
+
):
|
|
102
|
+
return (
|
|
103
|
+
"network_unreachable",
|
|
104
|
+
f"DNS/connection to the registry failed. Check network/VPN/proxy, then retry. {proxy_hint}",
|
|
105
|
+
)
|
|
106
|
+
if "eacces" in out or "eperm" in out or "permission denied" in out:
|
|
107
|
+
return ("permission_denied", _PERMISSION_HINT.get(pm, _PERMISSION_HINT["npm"]))
|
|
108
|
+
if any(
|
|
109
|
+
t in out
|
|
110
|
+
for t in (
|
|
111
|
+
"e404", "404 not found", "not in this registry", "not found in registry",
|
|
112
|
+
"no matching version", "package not found", "package \"" + _PACKAGE,
|
|
113
|
+
)
|
|
114
|
+
):
|
|
115
|
+
return (
|
|
116
|
+
"package_not_found",
|
|
117
|
+
f"The package {_PACKAGE} could not be resolved. Check your registry is "
|
|
118
|
+
f"reachable and the package name is correct. Manual retry: `{install_cmd}`.",
|
|
119
|
+
)
|
|
120
|
+
if "eexist" in out or "already exists" in out:
|
|
121
|
+
return (
|
|
122
|
+
"conflict",
|
|
123
|
+
f"A conflicting install exists. Try `{uninstall_cmd}` and rerun.",
|
|
124
|
+
)
|
|
125
|
+
return (
|
|
126
|
+
"install_failed",
|
|
127
|
+
f"Install command failed. See `stderr` below or rerun manually: `{install_cmd}`.",
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def _run_installer(cmd: list[str], tee_to_stderr: bool) -> tuple[int, str]:
|
|
132
|
+
"""Run an install command, optionally streaming its output live to stderr.
|
|
133
|
+
|
|
134
|
+
Always returns (exit_code, merged_output) — even when streaming, so failures
|
|
135
|
+
can still be classified and reported with structured fields. Streams stdout
|
|
136
|
+
and stderr together so progress bars from npm/bun show up in real time.
|
|
137
|
+
"""
|
|
138
|
+
if not tee_to_stderr:
|
|
139
|
+
p = subprocess.run(cmd, capture_output=True, text=True, check=False)
|
|
140
|
+
merged = ((p.stdout or "") + (p.stderr or "")).strip()
|
|
141
|
+
return p.returncode, merged
|
|
142
|
+
|
|
143
|
+
proc = subprocess.Popen(
|
|
144
|
+
cmd,
|
|
145
|
+
stdout=subprocess.PIPE,
|
|
146
|
+
stderr=subprocess.STDOUT,
|
|
147
|
+
text=True,
|
|
148
|
+
bufsize=1,
|
|
149
|
+
)
|
|
150
|
+
assert proc.stdout is not None
|
|
151
|
+
lines: list[str] = []
|
|
152
|
+
for line in proc.stdout:
|
|
153
|
+
sys.stderr.write(line)
|
|
154
|
+
sys.stderr.flush()
|
|
155
|
+
lines.append(line)
|
|
156
|
+
proc.wait()
|
|
157
|
+
return proc.returncode, "".join(lines).strip()
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def try_install_grace_cli(
|
|
161
|
+
dry_run: bool = False,
|
|
162
|
+
grace_cmd: str = "grace",
|
|
163
|
+
log_to_stderr: bool = False,
|
|
164
|
+
) -> dict[str, Any]:
|
|
165
|
+
"""Install `@osovv/grace-cli` via the first available JS package manager.
|
|
166
|
+
|
|
167
|
+
Shared by `doubled-graph setup` and the lazy-install path in `GraceCLI._check`,
|
|
168
|
+
so both paths have identical fallback behavior (bun → npm → yarn → pnpm).
|
|
169
|
+
|
|
170
|
+
Return a structured dict the CLI can dump as JSON. Keys vary by status:
|
|
171
|
+
- already_installed: {"status", "command"?}
|
|
172
|
+
- dry_run: {"status", "via", "command"}
|
|
173
|
+
- installed: {"status", "via", "command"}
|
|
174
|
+
- failed: {"status", "via", "command", "exit_code",
|
|
175
|
+
"error_type", "hint", "stderr"}
|
|
176
|
+
- no_package_manager:{"status", "hint"}
|
|
177
|
+
"""
|
|
178
|
+
if shutil.which(grace_cmd) is not None:
|
|
179
|
+
return {"status": "already_installed"}
|
|
180
|
+
|
|
181
|
+
for pm, cmd in INSTALLERS:
|
|
182
|
+
if shutil.which(pm) is None:
|
|
183
|
+
continue
|
|
184
|
+
command_str = " ".join(cmd)
|
|
185
|
+
if dry_run:
|
|
186
|
+
return {"status": "dry_run", "via": pm, "command": command_str}
|
|
187
|
+
if log_to_stderr:
|
|
188
|
+
print(
|
|
189
|
+
f"`{grace_cmd}` not found — installing via {pm}: {command_str}",
|
|
190
|
+
file=sys.stderr,
|
|
191
|
+
flush=True,
|
|
192
|
+
)
|
|
193
|
+
exit_code, output = _run_installer(cmd, tee_to_stderr=log_to_stderr)
|
|
194
|
+
if exit_code == 0 and shutil.which(grace_cmd) is not None:
|
|
195
|
+
return {"status": "installed", "via": pm, "command": command_str}
|
|
196
|
+
error_type, hint = _classify_install_error(pm, output)
|
|
197
|
+
# Last ~1500 chars — plenty for bug reports without bloating the JSON.
|
|
198
|
+
stderr_tail = output[-1500:] if output else ""
|
|
199
|
+
return {
|
|
200
|
+
"status": "failed",
|
|
201
|
+
"via": pm,
|
|
202
|
+
"command": command_str,
|
|
203
|
+
"exit_code": exit_code,
|
|
204
|
+
"error_type": error_type,
|
|
205
|
+
"hint": hint,
|
|
206
|
+
"stderr": stderr_tail,
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return {
|
|
210
|
+
"status": "no_package_manager",
|
|
211
|
+
"hint": (
|
|
212
|
+
"No JS package manager found. Install one of: Bun (https://bun.sh/), "
|
|
213
|
+
"Node.js+npm, yarn, or pnpm, then rerun `doubled-graph setup`."
|
|
214
|
+
),
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
@dataclass
|
|
219
|
+
class ModuleRecord:
|
|
220
|
+
id: str
|
|
221
|
+
purpose: str = ""
|
|
222
|
+
exports: list[str] | None = None
|
|
223
|
+
crosslinks: list[str] | None = None
|
|
224
|
+
raw: dict | None = None
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
@dataclass
|
|
228
|
+
class FileRecord:
|
|
229
|
+
path: str
|
|
230
|
+
module_contract: str | None = None
|
|
231
|
+
module_map: list[str] | None = None
|
|
232
|
+
contracts: list[dict] | None = None
|
|
233
|
+
blocks: list[dict] | None = None
|
|
234
|
+
change_summary: list[dict] | None = None
|
|
235
|
+
raw: dict | None = None
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
class GraceCLI:
|
|
239
|
+
"""Thin subprocess wrapper around the upstream `grace` CLI (Bun, MIT).
|
|
240
|
+
|
|
241
|
+
Why this class: grace CLI is the only lightweight way to query grace
|
|
242
|
+
artifacts (`docs/*.xml`, module records, file-level anchors) without
|
|
243
|
+
re-implementing the parser. Everywhere in doubled-graph where we need
|
|
244
|
+
those, we go through this wrapper — never shell out inline — so that:
|
|
245
|
+
|
|
246
|
+
1. If `grace` CLI is missing, we fail with one consistent error
|
|
247
|
+
(`GraceCLIMissing`) instead of cryptic FileNotFoundError.
|
|
248
|
+
2. When upstream changes its flag names / stdout format, the fix is
|
|
249
|
+
localized here (not in every caller).
|
|
250
|
+
3. Our gateway commands (`doubled-graph lint|module|file`) have a
|
|
251
|
+
predictable boundary to subprocess.
|
|
252
|
+
"""
|
|
253
|
+
|
|
254
|
+
def __init__(self, repo_path: Path, command: str = "grace"):
|
|
255
|
+
self.repo_path = repo_path
|
|
256
|
+
self.command = command
|
|
257
|
+
|
|
258
|
+
def _check(self) -> None:
|
|
259
|
+
"""Verify the grace binary is on PATH, auto-installing if a JS runtime is available."""
|
|
260
|
+
result = try_install_grace_cli(grace_cmd=self.command, log_to_stderr=True)
|
|
261
|
+
status = result["status"]
|
|
262
|
+
if status in ("already_installed", "installed"):
|
|
263
|
+
return
|
|
264
|
+
raise GraceCLIMissing(
|
|
265
|
+
f"`{self.command}` is not on $PATH and could not be installed automatically "
|
|
266
|
+
f"(status={status}). "
|
|
267
|
+
"Run manually: `npm install -g @osovv/grace-cli` (requires bun/npm/yarn/pnpm)."
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
def _run(self, args: list[str]) -> str:
|
|
271
|
+
"""Run `grace <args>` synchronously, capture stdout, raise on non-zero exit.
|
|
272
|
+
|
|
273
|
+
Intentionally plain: no streaming, no async, no retries. Callers that
|
|
274
|
+
need richer handling should wrap this, not fork it.
|
|
275
|
+
"""
|
|
276
|
+
self._check()
|
|
277
|
+
proc = subprocess.run(
|
|
278
|
+
[self.command, *args],
|
|
279
|
+
cwd=str(self.repo_path),
|
|
280
|
+
capture_output=True,
|
|
281
|
+
text=True,
|
|
282
|
+
check=False,
|
|
283
|
+
)
|
|
284
|
+
if proc.returncode != 0:
|
|
285
|
+
raise RuntimeError(
|
|
286
|
+
f"grace {' '.join(args)} failed (rc={proc.returncode}): {proc.stderr.strip()}"
|
|
287
|
+
)
|
|
288
|
+
return proc.stdout
|
|
289
|
+
|
|
290
|
+
def lint(self, verbose: bool = False) -> dict:
|
|
291
|
+
"""Run `grace lint` — the upstream validator of anchors and references.
|
|
292
|
+
|
|
293
|
+
Why we expose this: `grace lint` is a methodology gate (pre-commit and
|
|
294
|
+
pre-merge). Exposing it through `doubled-graph lint` keeps CI configs
|
|
295
|
+
tool-name-consistent (one binary in the scripts).
|
|
296
|
+
"""
|
|
297
|
+
# TODO[integration]: confirm `grace lint --json` availability; else parse textual output.
|
|
298
|
+
args = ["lint", "--path", str(self.repo_path)]
|
|
299
|
+
if verbose:
|
|
300
|
+
args.append("--verbose")
|
|
301
|
+
out = self._run(args)
|
|
302
|
+
try:
|
|
303
|
+
return json.loads(out)
|
|
304
|
+
except json.JSONDecodeError:
|
|
305
|
+
return {"raw": out}
|
|
306
|
+
|
|
307
|
+
def module_show(self, id_or_path: str, with_verification: bool = False) -> ModuleRecord:
|
|
308
|
+
"""Fetch module record: contract + exports + deps + (opt.) V-M-* list.
|
|
309
|
+
|
|
310
|
+
Called from `on-before-edit` and `grace-fix`-style flows when the agent
|
|
311
|
+
needs to read the contract BEFORE opening the code — saves context
|
|
312
|
+
window, which matters a lot for local models.
|
|
313
|
+
"""
|
|
314
|
+
args = ["module", "show", id_or_path, "--path", str(self.repo_path)]
|
|
315
|
+
if with_verification:
|
|
316
|
+
args += ["--with", "verification"]
|
|
317
|
+
# TODO[integration]: confirm stdout schema. MVP stub: return raw.
|
|
318
|
+
out = self._run(args)
|
|
319
|
+
return ModuleRecord(id=id_or_path, raw={"stdout": out})
|
|
320
|
+
|
|
321
|
+
def file_show(self, path: str, contracts: bool = True, blocks: bool = True) -> FileRecord:
|
|
322
|
+
"""Extract only anchor-framed sections of a file (not full content).
|
|
323
|
+
|
|
324
|
+
The cornerstone of RAG-over-anchors: instead of dumping a 2000-line
|
|
325
|
+
file into the LLM prompt, we fetch just CONTRACT + BLOCK_* the model
|
|
326
|
+
needs. Without this, long files blow out local-model context budgets.
|
|
327
|
+
"""
|
|
328
|
+
args = ["file", "show", path, "--path", str(self.repo_path)]
|
|
329
|
+
if contracts:
|
|
330
|
+
args.append("--contracts")
|
|
331
|
+
if blocks:
|
|
332
|
+
args.append("--blocks")
|
|
333
|
+
out = self._run(args)
|
|
334
|
+
return FileRecord(path=path, raw={"stdout": out})
|
|
@@ -25,7 +25,7 @@ from __future__ import annotations
|
|
|
25
25
|
import json
|
|
26
26
|
import os
|
|
27
27
|
import shutil
|
|
28
|
-
import
|
|
28
|
+
import sys
|
|
29
29
|
from importlib import resources
|
|
30
30
|
from pathlib import Path
|
|
31
31
|
from typing import Any
|
|
@@ -35,6 +35,51 @@ def _have(cmd: str) -> bool:
|
|
|
35
35
|
return shutil.which(cmd) is not None
|
|
36
36
|
|
|
37
37
|
|
|
38
|
+
def _log(msg: str) -> None:
|
|
39
|
+
"""Emit a progress line on stderr so it doesn't mix with the JSON report on stdout."""
|
|
40
|
+
print(msg, file=sys.stderr, flush=True)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _summary(result: dict[str, Any]) -> str:
|
|
44
|
+
"""Short human-readable one-liner for a step result.
|
|
45
|
+
|
|
46
|
+
For failures, prefer the classified `error_type` + `hint` over raw stderr —
|
|
47
|
+
the full stderr tail is still in the JSON report for bug reports.
|
|
48
|
+
"""
|
|
49
|
+
status = result.get("status", "?")
|
|
50
|
+
if status == "installed":
|
|
51
|
+
via = result.get("via")
|
|
52
|
+
return f"done (installed via {via})" if via else "done (installed)"
|
|
53
|
+
if status == "already_installed":
|
|
54
|
+
return "done (already installed)"
|
|
55
|
+
if status == "dry_run":
|
|
56
|
+
command = result.get("command") or result.get("cmd")
|
|
57
|
+
return f"dry-run ({command})" if command else "dry-run"
|
|
58
|
+
if status == "no_package_manager":
|
|
59
|
+
return "skipped — no JS package manager (bun/npm/yarn/pnpm) found"
|
|
60
|
+
if status == "failed":
|
|
61
|
+
via = result.get("via", "?")
|
|
62
|
+
error_type = result.get("error_type")
|
|
63
|
+
hint = result.get("hint")
|
|
64
|
+
if error_type and hint:
|
|
65
|
+
return f"failed via {via} ({error_type}): {hint}"
|
|
66
|
+
err = (result.get("stderr") or result.get("detail") or "")[:160]
|
|
67
|
+
return f"failed via {via}: {err}" if err else f"failed via {via}"
|
|
68
|
+
if status == "skipped":
|
|
69
|
+
return "skipped"
|
|
70
|
+
if status == "ok":
|
|
71
|
+
return "done"
|
|
72
|
+
if status == "manual":
|
|
73
|
+
return "manual step required — see JSON report"
|
|
74
|
+
if status == "registered":
|
|
75
|
+
return f"done (wrote {result.get('path','')})"
|
|
76
|
+
if status == "already_registered":
|
|
77
|
+
return f"done (already present in {result.get('path','')})"
|
|
78
|
+
if status == "not_a_git_repo":
|
|
79
|
+
return "skipped (not a git repo)"
|
|
80
|
+
return status
|
|
81
|
+
|
|
82
|
+
|
|
38
83
|
def _detect_ide(repo: Path) -> str:
|
|
39
84
|
"""Best-effort IDE detection.
|
|
40
85
|
|
|
@@ -105,24 +150,14 @@ def _copy_bundle(subdir: str, dest: Path, dry_run: bool) -> dict[str, Any]:
|
|
|
105
150
|
|
|
106
151
|
|
|
107
152
|
def _install_grace_cli(dry_run: bool) -> dict[str, Any]:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return {"status": "dry_run", "cmd": "bun add -g @osovv/grace-cli"}
|
|
117
|
-
out = subprocess.run(
|
|
118
|
-
["bun", "add", "-g", "@osovv/grace-cli"],
|
|
119
|
-
capture_output=True,
|
|
120
|
-
text=True,
|
|
121
|
-
check=False,
|
|
122
|
-
)
|
|
123
|
-
if out.returncode != 0:
|
|
124
|
-
return {"status": "failed", "stderr": out.stderr.strip()[:400]}
|
|
125
|
-
return {"status": "installed"}
|
|
153
|
+
"""Delegate to the shared installer so setup and lazy-install stay in sync.
|
|
154
|
+
|
|
155
|
+
`log_to_stderr=True` surfaces "installing via npm…" on stderr — without it the
|
|
156
|
+
user stares at a blank terminal for 10–30s while the package manager works.
|
|
157
|
+
"""
|
|
158
|
+
from doubled_graph.integrations.grace_cli import try_install_grace_cli
|
|
159
|
+
|
|
160
|
+
return try_install_grace_cli(dry_run=dry_run, log_to_stderr=True)
|
|
126
161
|
|
|
127
162
|
|
|
128
163
|
# ---------------------------------------------------------------------------
|
|
@@ -225,28 +260,43 @@ def run_setup(
|
|
|
225
260
|
dry_run: bool = False,
|
|
226
261
|
) -> dict[str, Any]:
|
|
227
262
|
report: dict[str, Any] = {"repo": str(repo_path), "dry_run": dry_run}
|
|
263
|
+
total = 5
|
|
264
|
+
prefix = "[dry-run] " if dry_run else ""
|
|
228
265
|
|
|
229
|
-
# 1. Grace CLI
|
|
266
|
+
# 1. Grace CLI — slow: subprocess to a JS package manager can take 10–30s.
|
|
267
|
+
_log(f"{prefix}[1/{total}] Installing @osovv/grace-cli (may take 10–30s)…")
|
|
230
268
|
report["grace_cli"] = (
|
|
231
269
|
{"status": "skipped"} if skip_grace_cli else _install_grace_cli(dry_run)
|
|
232
270
|
)
|
|
271
|
+
_log(f" {_summary(report['grace_cli'])}")
|
|
233
272
|
|
|
234
|
-
# 2. Bundled prompts + methodology
|
|
273
|
+
# 2. Bundled prompts + methodology — fast.
|
|
274
|
+
_log(f"{prefix}[2/{total}] Copying bundled prompts/ and methodology/ into the repo…")
|
|
235
275
|
report["prompts"] = _copy_bundle("prompts", repo_path / "prompts", dry_run)
|
|
236
276
|
report["methodology"] = _copy_bundle("methodology", repo_path / "methodology", dry_run)
|
|
277
|
+
_log(
|
|
278
|
+
f" prompts: {_summary(report['prompts'])}; "
|
|
279
|
+
f"methodology: {_summary(report['methodology'])}"
|
|
280
|
+
)
|
|
237
281
|
|
|
238
|
-
# 3. IDE MCP registration
|
|
282
|
+
# 3. IDE MCP registration — fast.
|
|
239
283
|
resolved_ide = ide if ide != "auto" else _detect_ide(repo_path)
|
|
240
284
|
report["ide_detected"] = resolved_ide
|
|
285
|
+
_log(f"{prefix}[3/{total}] Registering MCP server (IDE: {resolved_ide})…")
|
|
241
286
|
report["mcp_register"] = _register_mcp(repo_path, resolved_ide, dry_run)
|
|
287
|
+
_log(f" {_summary(report['mcp_register'])}")
|
|
242
288
|
|
|
243
|
-
# 4. Hooks
|
|
289
|
+
# 4. Hooks — fast.
|
|
290
|
+
_log(f"{prefix}[4/{total}] Installing git post-commit hook…")
|
|
244
291
|
report["hooks"] = {"status": "skipped"} if skip_hooks else _install_hooks(repo_path, dry_run)
|
|
292
|
+
_log(f" {_summary(report['hooks'])}")
|
|
245
293
|
|
|
246
|
-
# 5. First analyze
|
|
294
|
+
# 5. First analyze — slow: AST scan of the whole repo, size-dependent.
|
|
295
|
+
_log(f"{prefix}[5/{total}] Running first full analyze (slow on large repos)…")
|
|
247
296
|
report["analyze"] = (
|
|
248
297
|
{"status": "skipped"} if skip_analyze else _first_analyze(repo_path, dry_run)
|
|
249
298
|
)
|
|
299
|
+
_log(f" {_summary(report['analyze'])}")
|
|
250
300
|
|
|
251
301
|
# Overall ok: MCP registered (or manual hint returned) + hooks installed (or skipped).
|
|
252
302
|
mcp_ok = report["mcp_register"]["status"] in (
|
|
@@ -254,4 +304,5 @@ def run_setup(
|
|
|
254
304
|
)
|
|
255
305
|
hooks_ok = report["hooks"]["status"] in ("ok", "skipped")
|
|
256
306
|
report["ok"] = mcp_ok and hooks_ok
|
|
307
|
+
_log("Setup complete." if report["ok"] else "Setup finished with errors — see JSON report.")
|
|
257
308
|
return report
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"""grace-cli (Bun binary) integration — subprocess wrapper."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
import json
|
|
6
|
-
import shutil
|
|
7
|
-
import subprocess
|
|
8
|
-
from dataclasses import dataclass
|
|
9
|
-
from pathlib import Path
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class GraceCLIMissing(RuntimeError):
|
|
13
|
-
"""Raised when `grace` executable is not in $PATH."""
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
@dataclass
|
|
17
|
-
class ModuleRecord:
|
|
18
|
-
id: str
|
|
19
|
-
purpose: str = ""
|
|
20
|
-
exports: list[str] | None = None
|
|
21
|
-
crosslinks: list[str] | None = None
|
|
22
|
-
raw: dict | None = None
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
@dataclass
|
|
26
|
-
class FileRecord:
|
|
27
|
-
path: str
|
|
28
|
-
module_contract: str | None = None
|
|
29
|
-
module_map: list[str] | None = None
|
|
30
|
-
contracts: list[dict] | None = None
|
|
31
|
-
blocks: list[dict] | None = None
|
|
32
|
-
change_summary: list[dict] | None = None
|
|
33
|
-
raw: dict | None = None
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
class GraceCLI:
|
|
37
|
-
"""Thin subprocess wrapper around the upstream `grace` CLI (Bun, MIT).
|
|
38
|
-
|
|
39
|
-
Why this class: grace CLI is the only lightweight way to query grace
|
|
40
|
-
artifacts (`docs/*.xml`, module records, file-level anchors) without
|
|
41
|
-
re-implementing the parser. Everywhere in doubled-graph where we need
|
|
42
|
-
those, we go through this wrapper — never shell out inline — so that:
|
|
43
|
-
|
|
44
|
-
1. If `grace` CLI is missing, we fail with one consistent error
|
|
45
|
-
(`GraceCLIMissing`) instead of cryptic FileNotFoundError.
|
|
46
|
-
2. When upstream changes its flag names / stdout format, the fix is
|
|
47
|
-
localized here (not in every caller).
|
|
48
|
-
3. Our gateway commands (`doubled-graph lint|module|file`) have a
|
|
49
|
-
predictable boundary to subprocess.
|
|
50
|
-
"""
|
|
51
|
-
|
|
52
|
-
def __init__(self, repo_path: Path, command: str = "grace"):
|
|
53
|
-
self.repo_path = repo_path
|
|
54
|
-
self.command = command
|
|
55
|
-
|
|
56
|
-
def _check(self) -> None:
|
|
57
|
-
"""Verify the grace binary is on PATH, auto-installing if a JS runtime is available."""
|
|
58
|
-
if shutil.which(self.command) is not None:
|
|
59
|
-
return
|
|
60
|
-
|
|
61
|
-
_PACKAGE = "@osovv/grace-cli"
|
|
62
|
-
_INSTALLERS = [
|
|
63
|
-
["bun", "add", "-g", _PACKAGE],
|
|
64
|
-
["npm", "install", "-g", _PACKAGE],
|
|
65
|
-
["yarn", "global", "add", _PACKAGE],
|
|
66
|
-
["pnpm", "add", "-g", _PACKAGE],
|
|
67
|
-
]
|
|
68
|
-
for cmd in _INSTALLERS:
|
|
69
|
-
if shutil.which(cmd[0]) is None:
|
|
70
|
-
continue
|
|
71
|
-
import sys
|
|
72
|
-
print(f"`grace` not found — installing via {cmd[0]}…", file=sys.stderr)
|
|
73
|
-
result = subprocess.run(cmd, capture_output=False)
|
|
74
|
-
if result.returncode == 0 and shutil.which(self.command) is not None:
|
|
75
|
-
return
|
|
76
|
-
break # installer found but failed — fall through to error
|
|
77
|
-
|
|
78
|
-
raise GraceCLIMissing(
|
|
79
|
-
f"`{self.command}` is not on $PATH and could not be installed automatically. "
|
|
80
|
-
"Run manually: `npm install -g @osovv/grace-cli` (requires bun/npm/yarn/pnpm)."
|
|
81
|
-
)
|
|
82
|
-
|
|
83
|
-
def _run(self, args: list[str]) -> str:
|
|
84
|
-
"""Run `grace <args>` synchronously, capture stdout, raise on non-zero exit.
|
|
85
|
-
|
|
86
|
-
Intentionally plain: no streaming, no async, no retries. Callers that
|
|
87
|
-
need richer handling should wrap this, not fork it.
|
|
88
|
-
"""
|
|
89
|
-
self._check()
|
|
90
|
-
proc = subprocess.run(
|
|
91
|
-
[self.command, *args],
|
|
92
|
-
cwd=str(self.repo_path),
|
|
93
|
-
capture_output=True,
|
|
94
|
-
text=True,
|
|
95
|
-
check=False,
|
|
96
|
-
)
|
|
97
|
-
if proc.returncode != 0:
|
|
98
|
-
raise RuntimeError(
|
|
99
|
-
f"grace {' '.join(args)} failed (rc={proc.returncode}): {proc.stderr.strip()}"
|
|
100
|
-
)
|
|
101
|
-
return proc.stdout
|
|
102
|
-
|
|
103
|
-
def lint(self, verbose: bool = False) -> dict:
|
|
104
|
-
"""Run `grace lint` — the upstream validator of anchors and references.
|
|
105
|
-
|
|
106
|
-
Why we expose this: `grace lint` is a methodology gate (pre-commit and
|
|
107
|
-
pre-merge). Exposing it through `doubled-graph lint` keeps CI configs
|
|
108
|
-
tool-name-consistent (one binary in the scripts).
|
|
109
|
-
"""
|
|
110
|
-
# TODO[integration]: confirm `grace lint --json` availability; else parse textual output.
|
|
111
|
-
args = ["lint", "--path", str(self.repo_path)]
|
|
112
|
-
if verbose:
|
|
113
|
-
args.append("--verbose")
|
|
114
|
-
out = self._run(args)
|
|
115
|
-
try:
|
|
116
|
-
return json.loads(out)
|
|
117
|
-
except json.JSONDecodeError:
|
|
118
|
-
return {"raw": out}
|
|
119
|
-
|
|
120
|
-
def module_show(self, id_or_path: str, with_verification: bool = False) -> ModuleRecord:
|
|
121
|
-
"""Fetch module record: contract + exports + deps + (opt.) V-M-* list.
|
|
122
|
-
|
|
123
|
-
Called from `on-before-edit` and `grace-fix`-style flows when the agent
|
|
124
|
-
needs to read the contract BEFORE opening the code — saves context
|
|
125
|
-
window, which matters a lot for local models.
|
|
126
|
-
"""
|
|
127
|
-
args = ["module", "show", id_or_path, "--path", str(self.repo_path)]
|
|
128
|
-
if with_verification:
|
|
129
|
-
args += ["--with", "verification"]
|
|
130
|
-
# TODO[integration]: confirm stdout schema. MVP stub: return raw.
|
|
131
|
-
out = self._run(args)
|
|
132
|
-
return ModuleRecord(id=id_or_path, raw={"stdout": out})
|
|
133
|
-
|
|
134
|
-
def file_show(self, path: str, contracts: bool = True, blocks: bool = True) -> FileRecord:
|
|
135
|
-
"""Extract only anchor-framed sections of a file (not full content).
|
|
136
|
-
|
|
137
|
-
The cornerstone of RAG-over-anchors: instead of dumping a 2000-line
|
|
138
|
-
file into the LLM prompt, we fetch just CONTRACT + BLOCK_* the model
|
|
139
|
-
needs. Without this, long files blow out local-model context budgets.
|
|
140
|
-
"""
|
|
141
|
-
args = ["file", "show", path, "--path", str(self.repo_path)]
|
|
142
|
-
if contracts:
|
|
143
|
-
args.append("--contracts")
|
|
144
|
-
if blocks:
|
|
145
|
-
args.append("--blocks")
|
|
146
|
-
out = self._run(args)
|
|
147
|
-
return FileRecord(path=path, raw={"stdout": out})
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{doubled_graph-1.0.2 → doubled_graph-1.0.4}/prompts/migrate-existing-project/00-entry-prompt.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{doubled_graph-1.0.2 → doubled_graph-1.0.4}/prompts/migrate-existing-project/03-draft-plan.md
RENAMED
|
File without changes
|
{doubled_graph-1.0.2 → doubled_graph-1.0.4}/prompts/migrate-existing-project/04-markup-codebase.md
RENAMED
|
File without changes
|
|
File without changes
|
{doubled_graph-1.0.2 → doubled_graph-1.0.4}/prompts/migrate-existing-project/06-validation-gates.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|