gennady 0.8.2 → 0.8.4

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 (39) hide show
  1. package/README.md +212 -3
  2. package/ai/agents/agent-resolve-conflicts.xml +148 -3
  3. package/ai/agents/agent-review-verifier.xml +181 -3
  4. package/ai/directives/sdd/audit.directive.xml +22 -11
  5. package/ai/directives/sdd/critic-protocol.xml +3 -0
  6. package/ai/directives/sdd/critic.directive.xml +25 -3
  7. package/ai/skills/README.md +150 -0
  8. package/ai/skills/sdd-check/SKILL.md +19 -9
  9. package/ai/skills/sdd-execute/scripts/README.md +3 -0
  10. package/ai/skills/sdd-execute/scripts/_sdd-lib.sh +60 -0
  11. package/ai/skills/sdd-execute/scripts/check.sh +238 -0
  12. package/ai/skills/sdd-execute/scripts/sdd +12 -0
  13. package/ai/skills/sdd-hooks-install/SKILL.md +88 -0
  14. package/ai/skills/workspace-permission-setup/SKILL.md +193 -0
  15. package/cli/cmd/README.md +185 -0
  16. package/dist/ai/agents/agent-resolve-conflicts.xml +148 -3
  17. package/dist/ai/agents/agent-review-verifier.xml +181 -3
  18. package/dist/ai/directives/sdd/audit.directive.xml +22 -11
  19. package/dist/ai/directives/sdd/critic-protocol.xml +3 -0
  20. package/dist/ai/directives/sdd/critic.directive.xml +25 -3
  21. package/dist/ai/skills/README.md +150 -0
  22. package/dist/ai/skills/sdd-check/SKILL.md +19 -9
  23. package/dist/ai/skills/sdd-execute/scripts/README.md +3 -0
  24. package/dist/ai/skills/sdd-execute/scripts/_sdd-lib.sh +60 -0
  25. package/dist/ai/skills/sdd-execute/scripts/check.sh +238 -0
  26. package/dist/ai/skills/sdd-execute/scripts/sdd +12 -0
  27. package/dist/ai/skills/sdd-hooks-install/SKILL.md +88 -0
  28. package/dist/ai/skills/workspace-permission-setup/SKILL.md +193 -0
  29. package/dist/chunks/index-BHEP1kYv.js +164 -0
  30. package/dist/chunks/index-DqSFtXFv.js +813 -0
  31. package/dist/chunks/index-Ukr3nSKB.js +377 -0
  32. package/dist/cli/cmd/lint/checks/anchor-thin.check.d.ts +11 -0
  33. package/dist/cli/cmd/lint/lint.cmd.d.ts +1 -1
  34. package/dist/cli/cmd/lint/lint.types.d.ts +2 -0
  35. package/dist/gennady.js +4 -4
  36. package/package.json +1 -1
  37. package/dist/chunks/index-4fUNp3za.js +0 -156
  38. package/dist/chunks/index-C9UEDrqg.js +0 -754
  39. package/dist/chunks/index-jOIhIHdS.js +0 -369
@@ -9,6 +9,7 @@
9
9
  # sdd verify <file>... — comprehensive gate: typecheck + gennady lint + forbidden_grep
10
10
  # sdd check-blockers <ticket-file> — scan Execution Log for unresolved BLOCKER entries
11
11
  # sdd scan [project-root] — emit comprehensive project snapshot (single rich call)
12
+ # sdd check [root|--task TSK-NN|--files f...] — deterministic mechanical checks (task-id, tracker-sync, headers)
12
13
  # sdd help — print this help
13
14
  #
14
15
  # Why this wrapper exists:
@@ -44,6 +45,9 @@ case "$SUBCMD" in
44
45
  scan)
45
46
  exec "$SCRIPT_DIR/scan.sh" "$@"
46
47
  ;;
48
+ check)
49
+ exec "$SCRIPT_DIR/check.sh" "$@"
50
+ ;;
47
51
  help|--help|-h)
48
52
  cat <<'EOF'
49
53
  sdd — SDD command dispatcher
@@ -80,6 +84,14 @@ SUBCOMMANDS
80
84
  unparseable Meta.Status, broken spec links) are surfaced
81
85
  in [WARNINGS]. Defaults to current directory.
82
86
 
87
+ check [root] Deterministic mechanical checks — the single source of
88
+ check --task TSK-NN [root] mechanical truth shared by sdd-check (whole tree) and
89
+ check --files <f...> sdd-audit (scoped). Emits [TASKID] (collisions, orphan
90
+ @tasks refs), [TRACKER_SYNC] (ticket Meta.Status vs tracker
91
+ row), and — in --files mode — [HEADERS] (@file/@consumers/
92
+ @tasks presence on a caller-supplied in-scope file list).
93
+ Exit 0 clean, 3 findings, 2 structural, 4 bad invocation.
94
+
83
95
  check-blockers <ticket> Scan ticket Execution Log for unresolved BLOCKER entries.
84
96
  A BLOCKER is considered RESOLVED if a later Round contains
85
97
  a "✅ RESOLVED" entry referencing it. Returns list of
@@ -0,0 +1,88 @@
1
+ ---
2
+ name: sdd-hooks-install
3
+ description: Install Claude Code hooks for live SDD subagent progress streaming. Adds PreToolUse / PostToolUse / SubagentStop entries to project's .claude/settings.json (merging with existing config), ensures .claude/sdd-progress.ndjson is gitignored, prints the operator's tail command. Use once per project before running /sdd-execute or /sdd-execute-batch when live progress visibility is wanted. Idempotent — safe to re-run.
4
+ ---
5
+
6
+ <SDDHooksInstaller role="config-bootstrapper">
7
+ You install hooks into the CURRENT project to enable live SDD progress tailing. You do NOT install global hooks (those would fire on every project). Idempotent — re-running detects existing entries and skips duplicates.
8
+
9
+ <Protocol>
10
+ 1. **Verify project context:**
11
+ - cwd has `.git/` OR a `.claude/` directory OR an `.ai/` directory → proceed.
12
+ - Otherwise → halt: "Not a project root. Run from project's working directory."
13
+
14
+ 2. **Ensure `.claude/` exists:**
15
+ - `mkdir -p .claude`
16
+
17
+ 3. **Patch `.claude/settings.json`:**
18
+ - File missing → write a fresh one with the hooks block below.
19
+ - File exists → parse JSON. Merge: under `.hooks`, add `PreToolUse`, `PostToolUse`, `SubagentStop` entries. If a matcher with same `command` already exists, skip. Preserve existing hooks.
20
+ - Write back with 2-space indent.
21
+
22
+ Hooks block to add:
23
+ ```jsonc
24
+ {
25
+ "hooks": {
26
+ "PreToolUse": [
27
+ {
28
+ "matcher": "*",
29
+ "hooks": [
30
+ {
31
+ "type": "command",
32
+ "command": "jq -nc --arg ts \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\" --arg tool \"$CLAUDE_HOOK_TOOL_NAME\" --arg agent \"${CLAUDE_HOOK_PARENT_TOOL_USE_ID:-}\" '{ts:$ts, kind:\"pre\", tool:$tool, agent:$agent}' >> .claude/sdd-progress.ndjson"
33
+ }
34
+ ]
35
+ }
36
+ ],
37
+ "PostToolUse": [
38
+ {
39
+ "matcher": "*",
40
+ "hooks": [
41
+ {
42
+ "type": "command",
43
+ "command": "jq -nc --arg ts \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\" --arg tool \"$CLAUDE_HOOK_TOOL_NAME\" --arg agent \"${CLAUDE_HOOK_PARENT_TOOL_USE_ID:-}\" '{ts:$ts, kind:\"post\", tool:$tool, agent:$agent}' >> .claude/sdd-progress.ndjson"
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "SubagentStop": [
49
+ {
50
+ "hooks": [
51
+ {
52
+ "type": "command",
53
+ "command": "jq -nc --arg ts \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\" --arg sess \"${CLAUDE_HOOK_SESSION_ID:-}\" '{ts:$ts, kind:\"subagent_stop\", session:$sess}' >> .claude/sdd-progress.ndjson"
54
+ }
55
+ ]
56
+ }
57
+ ]
58
+ }
59
+ }
60
+ ```
61
+
62
+ 4. **Patch `.gitignore`:**
63
+ - Append `.claude/sdd-progress.ndjson` if not already listed.
64
+ - Create `.gitignore` with that single line if missing.
65
+
66
+ 5. **Verify `jq` is available** (Bash `command -v jq`). If missing → emit warning: "jq not found — install via `brew install jq` or `apt install jq` for hook scripts to work."
67
+
68
+ 6. **Print to operator** (final message):
69
+ ```
70
+ ✅ SDD hooks installed in <project-root>/.claude/settings.json
71
+ ✅ .gitignore updated to exclude sdd-progress.ndjson
72
+
73
+ To watch live progress in a second terminal:
74
+ tail -f .claude/sdd-progress.ndjson | jq -r '"\(.ts) | \(.kind) | \(.tool // .session) | agent=\(.agent // "-")"'
75
+
76
+ Now run /sdd-execute <TSK-NN> or /sdd-execute-batch in this terminal.
77
+
78
+ To uninstall: edit .claude/settings.json and remove the SDD entries.
79
+ ```
80
+ </Protocol>
81
+
82
+ <HardForbidden>
83
+ - Modifying global `~/.claude/settings.json` (this is per-project setup).
84
+ - Overwriting existing settings.json — must merge, preserving operator's other hooks.
85
+ - Adding the file outside .gitignore (would commit operator activity logs).
86
+ - Running the install if jq is unavailable without the warning (hooks would silently fail).
87
+ </HardForbidden>
88
+ </SDDHooksInstaller>
@@ -0,0 +1,193 @@
1
+ ---
2
+ name: workspace-permission-setup
3
+ description: Configure .claude/settings.json so the agent works autonomously inside the current repository while being auto-denied access to anything outside it (home directory, system paths, network, secrets). Use when the user wants to enable AI-first development with minimal permission prompts, scope the agent to a workspace, set up safe autonomy for a project, stop the agent from leaving the repo, reduce repetitive approval requests, or harden permissions for a codebase.
4
+ ---
5
+
6
+ # Workspace Permission Setup
7
+
8
+ Set up `.claude/settings.json` so the agent operates fully autonomously **inside** the current repository, and is **auto-denied** (not prompted) for anything **outside** it. Goal: enable AI-first development without sacrificing safety.
9
+
10
+ ## Core principle
11
+
12
+ - **Wide allow inside repo** — file edits, project tooling, git, common shell utilities.
13
+ - **Hard deny outside repo** — `~/`, `/etc`, `/var`, `.ssh`, `.aws`, network commands, `WebFetch`/`WebSearch`, secrets.
14
+ - `deny` always wins over `allow` — the agent gets a refusal, not a prompt, so the user is not interrupted.
15
+
16
+ ## Workflow
17
+
18
+ Always run all six steps in order. Never write to disk before Step 5 user approval.
19
+
20
+ ### Step 1 — Detect project context
21
+
22
+ Determine repo root and stack so allow-list is tailored, not generic.
23
+
24
+ ```bash
25
+ git rev-parse --show-toplevel 2>/dev/null || pwd
26
+ ls -la package.json pyproject.toml Cargo.toml go.mod Gemfile pom.xml build.gradle Makefile Dockerfile docker-compose.yml mise.toml .tool-versions 2>/dev/null
27
+ ls -la .claude/ 2>/dev/null
28
+ ```
29
+
30
+ Map detection → allow additions:
31
+
32
+ | Detected | Add to allow |
33
+ |---|---|
34
+ | `package.json` | `Bash(npm:*)`, `Bash(npx:*)`, `Bash(pnpm:*)`, `Bash(yarn:*)`, `Bash(node:*)` |
35
+ | `pyproject.toml` / `requirements.txt` | `Bash(python:*)`, `Bash(python3:*)`, `Bash(pip:*)`, `Bash(uv:*)`, `Bash(poetry:*)`, `Bash(pytest:*)` |
36
+ | `Cargo.toml` | `Bash(cargo:*)`, `Bash(rustc:*)` |
37
+ | `go.mod` | `Bash(go:*)`, `Bash(gofmt:*)` |
38
+ | `Gemfile` | `Bash(bundle:*)`, `Bash(rake:*)`, `Bash(rspec:*)` |
39
+ | `Makefile` | `Bash(make:*)` |
40
+ | `Dockerfile` / `docker-compose.yml` | (do **not** auto-allow `docker` — ask in Step 4) |
41
+ | `mise.toml` / `.tool-versions` | `Bash(mise:*)` |
42
+
43
+ Also read existing `.claude/settings.json` and `.claude/settings.local.json`. **Preserve** other sections — only the `permissions` block is replaced.
44
+
45
+ ### Step 2 — Harvest from transcript history
46
+
47
+ Invoke the `fewer-permission-prompts` skill via the Skill tool. It scans recent transcripts and extracts safe read-only commands the user has been approving repeatedly. Capture its proposal but **do not** let it write — we will merge into our config in Step 3.
48
+
49
+ If the skill is not available or returns nothing useful, skip — Steps 1 and 3 give a working baseline.
50
+
51
+ ### Step 3 — Build the proposed config
52
+
53
+ Three sources merged into one block:
54
+
55
+ 1. **Universal scoping** (deny + baseline allow — always present).
56
+ 2. **Project-specific allow** (from Step 1).
57
+ 3. **Transcript-derived allow** (from Step 2).
58
+
59
+ #### Universal scoping deny — always include
60
+
61
+ ```json
62
+ "deny": [
63
+ "WebFetch",
64
+ "WebSearch",
65
+
66
+ "Read(~/**)",
67
+ "Edit(~/**)",
68
+ "Write(~/**)",
69
+ "Read(/etc/**)",
70
+ "Read(/var/**)",
71
+ "Read(/private/**)",
72
+ "Read(/tmp/**)",
73
+
74
+ "Read(./.env*)",
75
+ "Read(./**/.env*)",
76
+ "Read(./.git/config)",
77
+
78
+ "Bash(curl:*)",
79
+ "Bash(wget:*)",
80
+ "Bash(ssh:*)",
81
+ "Bash(scp:*)",
82
+ "Bash(rsync:*)",
83
+ "Bash(nc:*)",
84
+ "Bash(cd ..*)",
85
+ "Bash(cd /*)",
86
+ "Bash(cd ~*)",
87
+ "Bash(rm -rf:*)",
88
+ "Bash(sudo:*)"
89
+ ]
90
+ ```
91
+
92
+ If sensitive directories exist on the machine (`~/.ssh`, `~/.aws`, `~/.gnupg`, `~/.config`, `~/Library`), add explicit absolute-path denies — `~` patterns may not always expand, so be belt-and-suspenders:
93
+
94
+ ```json
95
+ "Read(/Users/<user>/.ssh/**)",
96
+ "Read(/Users/<user>/.aws/**)",
97
+ "Read(/Users/<user>/.gnupg/**)",
98
+ "Read(/Users/<user>/.config/**)",
99
+ "Read(/Users/<user>/Library/**)"
100
+ ```
101
+
102
+ Use `$HOME` or detect actual user from `whoami` / `echo $HOME`.
103
+
104
+ #### Universal allow baseline — always include
105
+
106
+ ```json
107
+ "allow": [
108
+ "Read",
109
+ "Grep",
110
+ "Glob",
111
+ "Edit",
112
+ "Write",
113
+ "Bash(git:*)",
114
+ "Bash(ls:*)",
115
+ "Bash(cat:*)",
116
+ "Bash(head:*)",
117
+ "Bash(tail:*)",
118
+ "Bash(grep:*)",
119
+ "Bash(rg:*)",
120
+ "Bash(find . *)",
121
+ "Bash(sed:*)",
122
+ "Bash(awk:*)",
123
+ "Bash(jq:*)",
124
+ "Bash(diff:*)",
125
+ "Bash(wc:*)",
126
+ "Bash(echo:*)",
127
+ "Bash(pwd)",
128
+ "Bash(mkdir:*)",
129
+ "Bash(touch:*)",
130
+ "Bash(mv:*)",
131
+ "Bash(cp:*)"
132
+ ]
133
+ ```
134
+
135
+ #### Default mode
136
+
137
+ ```json
138
+ "defaultMode": "acceptEdits"
139
+ ```
140
+
141
+ File edits inside the repo no longer prompt.
142
+
143
+ ### Step 4 — Interactive review with the user
144
+
145
+ Present the **full proposed JSON** to the user, then ask 3–5 targeted questions tied to what was detected. Do not write yet.
146
+
147
+ Standard questions (skip those that don't apply):
148
+
149
+ 1. **`git push`** — allow autonomously, or keep asking? Default recommendation: **ask** (irreversible, affects remote).
150
+ 2. **Package install** (`npm install`, `pip install`, `cargo add`, etc.) — allow autonomously, or ask? Default recommendation: **ask** (mutates lockfile, pulls supply chain).
151
+ 3. **`docker:*`** (if Dockerfile detected) — allow, ask, or deny?
152
+ 4. **`WebFetch`** — currently denied. Need it for fetching external docs? Default recommendation: **keep denied**, agent should ask explicitly when needed.
153
+ 5. **Anything project-specific** — extra CLIs (`terraform`, `kubectl`, `aws`, `gcloud`, custom scripts in `./bin/`)?
154
+
155
+ Apply answers to the config and show the final version once more.
156
+
157
+ ### Step 5 — Write the config (only after explicit approval)
158
+
159
+ Wait for unambiguous user approval ("yes", "ok, write", "go").
160
+
161
+ Then merge with any existing `.claude/settings.json`:
162
+
163
+ - **Preserve** all top-level keys other than `permissions` (e.g., `env`, `hooks`, `model`, `statusLine`).
164
+ - **Replace** the `permissions` block with the new merged result.
165
+ - Use Edit (if file exists) or Write (if not) — never shell redirection.
166
+
167
+ **Do not touch `.claude/settings.local.json`** — that is the user's personal, gitignored layer.
168
+
169
+ ### Step 6 — Verify and explain
170
+
171
+ Show the final file content and explain in 4–5 lines:
172
+
173
+ 1. Default mode is `acceptEdits` → file edits in the repo run without prompting.
174
+ 2. Off-workspace paths (`~`, `/etc`, `.ssh`, etc.) are now **auto-denied** — the agent will not interrupt to ask.
175
+ 3. `WebFetch`/`WebSearch` are denied → agent won't try to leave the repo for info unless user explicitly relaxes the rule.
176
+ 4. Suggest one quick smoke test: ask the agent to read `~/.ssh/known_hosts`, confirm it gets denied without prompting.
177
+ 5. Mention `Shift+Tab` switches modes if user wants to temporarily relax for one task.
178
+
179
+ ## Honest limits
180
+
181
+ Bash cannot be perfectly sandboxed via deny patterns alone — an agent can use `bash -c "..."`, `eval`, command substitution, environment manipulation. The patterns block the obvious, common escape paths (`curl`, `cd ..`, `sudo`), which is enough for ~95% of real-world risk. For genuine sandbox guarantees, mention these as follow-ups (do not implement here):
182
+
183
+ - Run Claude Code inside a **devcontainer** (https://code.claude.com/docs/en/devcontainer).
184
+ - Add a **PreToolUse hook** that parses every Bash command and rejects cwd escapes.
185
+
186
+ ## Anti-patterns — never do these
187
+
188
+ - Do not overwrite `.claude/settings.json` — always merge other sections.
189
+ - Do not write before explicit user approval in Step 5.
190
+ - Do not allow-list `Bash(curl:*)`, `Bash(wget:*)`, broad `Bash(*)`, or `Bash(sudo:*)`.
191
+ - Do not put deny rules in `.claude/settings.local.json` — security policy belongs in the committed `settings.json` so the whole team inherits it.
192
+ - Do not delete the user's existing `settings.local.json` allow rules — they may have been hand-tuned for personal workflows.
193
+ - Do not skip Step 4 questions — the difference between "agent can `git push` at 3am" and "agent asks first" matters and is project-specific.
@@ -0,0 +1,185 @@
1
+ # cli/cmd — Команды CLI
2
+
3
+ 16 команд для AI-агентов: работа с git, генерация commit-сообщений, ревью, merge-конфликты, линтинг, навигация по коду, синхронизация, мониторинг.
4
+
5
+ ---
6
+
7
+ ## Типовые сценарии
8
+
9
+ ### 1. Сделать коммит
10
+
11
+ ```bash
12
+ # Сгенерировать commit message из staged-изменений
13
+ npx gennady commit
14
+
15
+ # One-line + сразу применить
16
+ npx gennady commit --mode=oneline --apply
17
+
18
+ # С указанием задачи
19
+ npx gennady commit --task=MAILCORE-123
20
+ ```
21
+
22
+ ### 2. Проверить качество кода
23
+
24
+ ```bash
25
+ # Линтинг директории
26
+ npx gennady lint ./src
27
+
28
+ # Только staged .ts файлы
29
+ npx gennady lint --staged
30
+
31
+ # Автофикс DbC-контрактов
32
+ npx gennady lint ./src --autofix
33
+ ```
34
+
35
+ ### 3. Навигация по проекту
36
+
37
+ ```bash
38
+ # Карта проекта (все файлы с аннотациями)
39
+ npx gennady orient
40
+
41
+ # Найти файлы по задаче
42
+ npx gennady orient --task=TSK-03
43
+
44
+ # Кто потребляет модуль
45
+ npx gennady orient --consumer=DbcTsLinter
46
+
47
+ # Граф зависимостей
48
+ npx gennady orient --graph
49
+
50
+ # Детальный просмотр файла
51
+ npx gennady orient --file=path/to/file.ts
52
+
53
+ # Встроить orient-инструкции в AGENTS.md
54
+ npx gennady agents-rules
55
+ ```
56
+
57
+ ### 4. Ревью MR/PR
58
+
59
+ ```bash
60
+ # Верификация MR по текущей ветке
61
+ npx gennady review-verify
62
+
63
+ # По URL
64
+ npx gennady review-verify --url="https://gitlab.com/group/repo/-/merge_requests/42"
65
+
66
+ # По ref
67
+ npx gennady review-verify group/repo!42
68
+
69
+ # Только XML issues
70
+ npx gennady review-issues --ref=group/repo!42
71
+
72
+ # Ответить на discussion-треды
73
+ echo '[{"discussionId":"abc","body":"Fixed"}]' | \
74
+ npx gennady vcs-reply --project=group/repo --iid=42
75
+ ```
76
+
77
+ ### 5. AI-ревью staged-изменений
78
+
79
+ ```bash
80
+ npx gennady review
81
+ npx gennady review --branch=develop
82
+ ```
83
+
84
+ ### 6. Разрешить merge-конфликты
85
+
86
+ ```bash
87
+ # После git merge с конфликтами
88
+ npx gennady resolve-conflicts
89
+ npx gennady resolve-conflicts --branch=main --incoming=feature/x
90
+ ```
91
+
92
+ ### 7. Собрать файлы для AI-контекста
93
+
94
+ ```bash
95
+ # XML (по умолчанию)
96
+ npx gennady cat "./src/**/*.ts"
97
+
98
+ # Markdown, без цвета
99
+ npx gennady cat "./src/**/*.ts" --output=md --plain | pbcopy
100
+
101
+ # Из удалённого MR
102
+ npx gennady cat --url="https://gitlab.com/.../-/merge_requests/123"
103
+ ```
104
+
105
+ ### 8. Синхронизировать директивы и навыки
106
+
107
+ ```bash
108
+ # Директивы
109
+ npx gennady sync
110
+ npx gennady sync --dry-run
111
+
112
+ # Навыки
113
+ npx gennady sync-skills
114
+ npx gennady sync-skills --dry-run
115
+ ```
116
+
117
+ ### 9. Мульти-модельный анализ
118
+
119
+ ```bash
120
+ # Мнение двух моделей с синтезом
121
+ npx gennady alt-opinion \
122
+ --model="llmproxy/kimi-k2.6" \
123
+ --model="llmproxy/glm-5.1" \
124
+ --synthModel="llmproxy/deepseek-v4-pro" \
125
+ --file="./spec.md"
126
+ ```
127
+
128
+ ### 10. Мониторинг AI-агентов
129
+
130
+ ```bash
131
+ # Live-дашборд
132
+ npx gennady agent-mon
133
+
134
+ # Одноразовый снапшот
135
+ npx gennady agent-mon --once
136
+ ```
137
+
138
+ ---
139
+
140
+ ## Все команды
141
+
142
+ | Команда | Назначение |
143
+ | ------------------- | ------------------------------------------------------- |
144
+ | `commit` | Генерация commit message из staged-изменений через AI |
145
+ | `cat` | Вывод файлов в XML/Markdown для AI-контекста |
146
+ | `review` | AI-ревью staged изменений |
147
+ | `review-verify` | Сборка промпта для верификации MR/PR discussions |
148
+ | `review-issues` | XML-артефакт issues из MR/PR |
149
+ | `vcs-reply` | Постинг ответов в GitLab MR discussions |
150
+ | `resolve-conflicts` | Промпт для AI-разрешения merge-конфликтов |
151
+ | `remote-console` | Зеркалирование браузерной консоли в stdout |
152
+ | `lint` | Валидация .ts файлов: headers, anchors, DbC, invariants |
153
+ | `alt-opinion` | Мульти-модельные мнения с синтезом |
154
+ | `sync` | Синхронизация `ai/directives/` из npm-пакета |
155
+ | `sync-skills` | Синхронизация SDD-навыков в `.claude/skills/` |
156
+ | `agent-mon` | Интерактивный дашборд мониторинга AI-агентов |
157
+ | `orient` | Навигация по file-header и DBC-контрактам |
158
+ | `agents-rules` | Инструкция по orient для AI-агентов |
159
+
160
+ ---
161
+
162
+ ## Структура команды
163
+
164
+ ```
165
+ cli/cmd/<name>/
166
+ ├── <name>.cmd.ts # Исполняемая логика команды
167
+ ├── index.ts # Точка входа для динамического импорта
168
+ ├── help.ts # help-вывод (опционально)
169
+ └── README.md # Документация (есть только у orient — канонический источник для agents-rules)
170
+ ```
171
+
172
+ При добавлении команды обновить: `cli/cmd/README.md` (этот файл), `cli/AGENTS.md`, `cli/gennady.ts`.
173
+
174
+ ---
175
+
176
+ ## Связанные спеки
177
+
178
+ - `specs/cli/cli.spec.md` — общая спека CLI
179
+ - `specs/cli/lint/lint.spec.md` — линтинг
180
+ - `specs/cli/alt-opinion/alt-opinion.spec.md` — alt-opinion
181
+ - `specs/cli/cat/cat.spec.md` — cat
182
+ - `specs/cli/sync/sync.spec.md` — sync
183
+ - `specs/cli/sync-skills/sync-skills.spec.md` — sync-skills
184
+ - `specs/cli/agents-rules/agents-rules.spec.md` — agents-rules
185
+ - `specs/cli/e2e/e2e.spec.md` — e2e-тестирование
@@ -1,3 +1,148 @@
1
- <Agent name="agent-resolve-conflicts" type="directive" ver="0.1">
2
- <Mission>Resolve merge conflicts with confidence scoring.</Mission>
3
- </Agent>
1
+ <!--
2
+ ENTRY POINT: Это не документ, а исполняемый манифест.
3
+ Ты — агент разрешения merge-конфликтов. Начинай немедленно.
4
+ -->
5
+ <Agent_Execution_Manifest id="ResolveConflicts_Master_v1" schema_version="2026.2">
6
+ <Configuration>
7
+ <Agent_Identity>
8
+ <Role>ResolveConflicts</Role>
9
+ <Mission>
10
+ Разрешить merge-конфликты так, чтобы сохранить намерения обеих веток.
11
+ При высокой уверенности — завершить задачу до готового staged-состояния.
12
+ При риске ошибки — остановиться и перейти в управляемый диалог с пользователем.
13
+ </Mission>
14
+ </Agent_Identity>
15
+ <Belief_State>
16
+ <Axiom id="AX_INTENT_OVER_MARKERS">
17
+ Конфликтные маркеры — это симптом. Решение должно опираться на цель изменений в обеих ветках.
18
+ </Axiom>
19
+ <Axiom id="AX_EVIDENCE_FIRST">
20
+ Любое решение обосновывается фактами: история коммитов, итоговые diff от merge-base, контекст использования кода.
21
+ </Axiom>
22
+ <Axiom id="AX_OPERATOR_LANGUAGE">
23
+ Все сообщения оператору (вопросы, план, отчёты, итоговые решения) формулируй на русском языке.
24
+ Английский допустим только для кода, команд, идентификаторов и технических терминов.
25
+ </Axiom>
26
+ <Axiom id="AX_CONFIDENCE_GATE">
27
+ Применяй изменения автоматически только при достаточной уверенности и отсутствии критичных сомнений.
28
+ </Axiom>
29
+ <Axiom id="AX_SAFE_VERIFY">
30
+ После автоматического разрешения обязательно проверь код: используй <!--ai:verify-axiom-hint-->.
31
+ </Axiom>
32
+ <Axiom id="AX_USER_DIALOG">
33
+ Если есть неоднозначность, влияние на архитектуру или риск регрессии — переходи в диалог и не форсируй auto-resolve.
34
+ </Axiom>
35
+ </Belief_State>
36
+ <Tool_Usage_Policy>
37
+ <Priority_Matrix>
38
+ <Primary_Tools>
39
+ Native IDE tools для чтения/редактирования/поиска — основной режим.
40
+ </Primary_Tools>
41
+ <Secondary_Tools>
42
+ Terminal для git-анализа и верификации: <!--ai:verify-tools-example-->.
43
+ </Secondary_Tools>
44
+ </Priority_Matrix>
45
+ </Tool_Usage_Policy>
46
+ </Configuration>
47
+ <Input_Data>
48
+ <!--Resolve_Conflicts_Artifact-->
49
+ </Input_Data>
50
+ <Execution_Plan>
51
+ <Step id="STEP_1_INGEST_CONTEXT">
52
+ <Goal>Понять merge-контекст и список конфликтов.</Goal>
53
+ <Action>
54
+ <!--ai:first-->
55
+ Прочитай `<Merge_Conflict_Context>`.
56
+ Зафиксируй:
57
+ - `current_branch`, `incoming_branch`, `merge_base`;
58
+ - список `<Conflict_Files><File ... />` и их `path`, `status`, `kind`, `conflictRegions`, `binary`.
59
+ Если `binary=true`, не пытайся редактировать бинарный файл автоматически: пометь как manual.
60
+ </Action>
61
+ </Step>
62
+ <Step id="STEP_2_BRANCH_INTENT_ANALYSIS">
63
+ <Goal>Построить понимание, зачем меняли каждый конфликтующий файл в обеих ветках.</Goal>
64
+ <Action>
65
+ Для каждого конфликтующего текстового файла:
66
+ 1. Найди unique commits incoming-ветки для файла: от `merge_base..incoming`.
67
+ 2. Найди unique commits current-ветки для файла: от `merge_base..current`.
68
+ 3. Для каждой стороны зафиксируй:
69
+ - краткий intent;
70
+ - критичность (low/medium/high/critical);
71
+ - масштаб (localized/global);
72
+ - ключевые изменения.
73
+ 4. Если commit history слишком большая, сначала возьми последние релевантные изменения, но не теряй критические правки (security/hotfix).
74
+ </Action>
75
+ </Step>
76
+ <Step id="STEP_3_CONFLICT_DECISION">
77
+ <Goal>Принять решение по каждому конфликтному региону.</Goal>
78
+ <Action>
79
+ Для каждого конфликтного региона выбери стратегию:
80
+ - `take-current`
81
+ - `take-incoming`
82
+ - `merge-both`
83
+ - `rewrite`
84
+
85
+ Для каждого региона сформируй:
86
+ - `analysis`: почему возник конфликт;
87
+ - `strategy`: выбранный подход;
88
+ - `resolvedCode`: итоговый код без маркеров;
89
+ - `confidence` (0-100);
90
+ - `riskFlags`: список рисков (архитектура, безопасность, API-совместимость, тестовый пробел).
91
+
92
+ Общие правила приоритета:
93
+ 1. Критичный hotfix/security не теряется.
94
+ 2. Рефакторинг не должен ломать исправления багов.
95
+ 3. Если изменения совместимы — объединяй, а не отбрасывай.
96
+ </Action>
97
+ </Step>
98
+ <Step id="STEP_4_CONFIDENCE_SWITCH">
99
+ <Goal>Выбрать режим: автоматическое применение или диалог с пользователем.</Goal>
100
+ <Action>
101
+ <Switch exclusive="true" purpose="Выбор режима по уровню уверенности и рискам">
102
+ <Case when="Для каждого конфликтного региона confidence >= 85 и нет riskFlags высокого уровня">
103
+ - Примени resolvedCode ко всем регионам.
104
+ - Удали конфликтные маркеры.
105
+ - Выполни `git add` только для файлов, полностью разрешённых без сомнений.
106
+ - Перейди к STEP_5.
107
+ </Case>
108
+ <Case when="Есть регионы с confidence 60-84 или есть значимые riskFlags">
109
+ - Не выполняй auto-apply для спорных регионов.
110
+ - Перейди в диалог с пользователем.
111
+ - Покажи 1-3 точечных вопроса по развилке и предложи рекомендуемый вариант.
112
+ - Для каждого спорного региона дай краткое сравнение вариантов (`current`, `incoming`, `merge`) и ожидаемые последствия.
113
+ - Остановись и жди ответа пользователя.
114
+ </Case>
115
+ <Case when="Есть регионы с confidence &lt; 60 или не хватает фактов для безопасного выбора">
116
+ - Не вноси автоматические изменения в спорные участки.
117
+ - Сформируй план ручного разрешения с приоритетами и рисками.
118
+ - Запроси решение пользователя по каждому блокирующему региону.
119
+ - Остановись и жди ответа пользователя.
120
+ </Case>
121
+ </Switch>
122
+ </Action>
123
+ </Step>
124
+ <Step id="STEP_5_VERIFY_AND_REPORT">
125
+ <Precondition>STEP_4 выбрал auto-apply для всех регионов или спорные регионы уже подтверждены пользователем.</Precondition>
126
+ <Goal>Проверить результат и отчитаться прозрачно.</Goal>
127
+ <Action>
128
+ 1. Verify: <!--ai:verify-step-commands-->
129
+ 2. Сформируй отчёт:
130
+ - какие файлы разрешены автоматически;
131
+ - какие стратегии применены;
132
+ - итоговый confidence по файлам;
133
+ - какие команды проверки выполнены и их результат.
134
+ 3. Если проверки упали — покажи причину и предложи дальнейшие шаги.
135
+ 4. Не выполняй `git commit` автоматически.
136
+ </Action>
137
+ </Step>
138
+ </Execution_Plan>
139
+ <Output_Contracts>
140
+ <Contract id="REPORT_FORMAT">
141
+ Итог должен содержать:
142
+ - `Resolved Automatically` (список файлов и стратегии),
143
+ - `Needs User Decision` (если есть),
144
+ - `Verification` (какие команды и статус),
145
+ - `Next Steps` (что сделать пользователю дальше).
146
+ </Contract>
147
+ </Output_Contracts>
148
+ </Agent_Execution_Manifest>