@synity/bitrix-skills 1.3.1 → 1.3.2

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.
@@ -0,0 +1,173 @@
1
+ ---
2
+ name: bitrix-sync-install
3
+ description: |
4
+ Install Bitrix Task Sync vào brownfield project (existing repo).
5
+ Wraps `npx @synity/bitrix-task-sync` với interactive TASK_ID setup,
6
+ webhook env var detection, và live verify smoke test.
7
+
8
+ Use when:
9
+ - User says "install bitrix sync", "setup task tracking", "thêm bitrix sync vào dự án"
10
+ - User asks how to enable AI session sync to Bitrix24 task chat
11
+ - Brownfield project not scaffolded by `create-bitrix-app`
12
+ tools: [Bash, Read, Edit, AskUserQuestion]
13
+ ---
14
+
15
+ # /bitrix-sync-install — Install Bitrix Task Sync (interactive)
16
+
17
+ Orchestrate installation of [@synity/bitrix-task-sync](https://www.npmjs.com/package/@synity/bitrix-task-sync) into the current project. **Skill = thin wrapper** — all file copy / settings merge / githook setup is delegated to the npm CLI. Skill only handles interactive bits CLI cannot do (CLAUDE.md edit, env var detection, user confirmation gates).
18
+
19
+ ## Workflow (7 steps with user confirmation)
20
+
21
+ ### Step 1 — Detect project state
22
+
23
+ Run via Bash to inspect current dir:
24
+
25
+ ```bash
26
+ pwd && ls -la .claude .githooks docs CLAUDE.md 2>/dev/null
27
+ ```
28
+
29
+ Show user what already exists. **Decision:**
30
+ - If `.claude/scripts/bitrix-*.sh` already exists → skip to Step 7 (verify only)
31
+ - Else → proceed Step 2
32
+
33
+ ### Step 2 — Preflight check
34
+
35
+ Confirm bash deps present:
36
+
37
+ ```bash
38
+ command -v jq && command -v curl && command -v awk && echo "OK"
39
+ ```
40
+
41
+ If any missing → abort, instruct user to install (`brew install jq` on macOS).
42
+
43
+ ### Step 3 — Dry-run install
44
+
45
+ ```bash
46
+ npx -y @synity/bitrix-skills install --dry-run
47
+ ```
48
+
49
+ Show planned actions. **Always pin exact version** (never `@latest`).
50
+
51
+ ### Step 4 — Confirm + install
52
+
53
+ Use `AskUserQuestion`:
54
+
55
+ ```
56
+ Question: "Proceed with install? (review the dry-run plan above)"
57
+ Options:
58
+ - "Yes, install" — runs `npx ... install`
59
+ - "No, abort" — exit skill
60
+ ```
61
+
62
+ If yes:
63
+
64
+ ```bash
65
+ npx -y @synity/bitrix-skills install
66
+ ```
67
+
68
+ ### Step 5 — TASK_ID setup
69
+
70
+ Read `CLAUDE.md` (project root). Search for `TASK_ID:` pattern.
71
+
72
+ **Missing case:**
73
+ 1. `AskUserQuestion` for `PORTAL` URL (e.g. `https://yourname.bitrix24.com`)
74
+ 2. `AskUserQuestion` for `TASK_ID` (numeric task ID from Bitrix24 task URL)
75
+ 3. Validate `TASK_ID` is numeric (reject `1234abc`)
76
+ 4. Use `Edit` to insert at end of CLAUDE.md:
77
+
78
+ ```markdown
79
+
80
+ ## Bitrix Task
81
+
82
+ PORTAL: {portal_url}
83
+ TASK_ID: {task_id}
84
+
85
+ <!-- AI session activity auto-syncs to this task via .claude/scripts/bitrix-*.sh hooks -->
86
+ <!-- See docs/bitrix-task-sync.md for setup details -->
87
+ ```
88
+
89
+ **Present case:** display existing TASK_ID + ask user to confirm or update.
90
+
91
+ ### Step 6 — Webhook env var
92
+
93
+ Check current shell env:
94
+
95
+ ```bash
96
+ [ -n "$BITRIX_WEBHOOK_URL" ] && echo SET || echo UNSET
97
+ ```
98
+
99
+ If `UNSET`, `AskUserQuestion`:
100
+
101
+ ```
102
+ Question: "Where to add BITRIX_WEBHOOK_URL?"
103
+ Options:
104
+ - ".envrc (direnv)"
105
+ - "~/.zshrc"
106
+ - "~/.bashrc"
107
+ - "Skip — I'll do it manually"
108
+ ```
109
+
110
+ Print the exact `export` command. Wait for user to confirm they ran `source <file>` (or restarted shell). **NEVER auto-edit shell rc files** — could conflict with user's setup.
111
+
112
+ Example output:
113
+ ```
114
+ Add this line to ~/.zshrc:
115
+ export BITRIX_WEBHOOK_URL="https://yourname.bitrix24.com/rest/USER_ID/TOKEN/"
116
+ Then run: source ~/.zshrc
117
+
118
+ (Press confirm when done)
119
+ ```
120
+
121
+ ### Step 7 — Verify
122
+
123
+ ```bash
124
+ npx -y @synity/bitrix-skills verify
125
+ ```
126
+
127
+ Interpret exit codes:
128
+
129
+ | Code | Meaning | User Action |
130
+ |------|---------|-------------|
131
+ | 0 | Success — comment posted | Done. |
132
+ | 1 | TASK_ID missing in CLAUDE.md | Re-run Step 5 |
133
+ | 2 | BITRIX_WEBHOOK_URL not set | Re-run Step 6 |
134
+ | 3 | Webhook call failed (network/token error) | Verify webhook URL is correct + has perms |
135
+ | 4 | Manifest drift detected | Run `npx @synity/bitrix-task-sync update` to repair |
136
+
137
+ ## Final summary
138
+
139
+ On success, print:
140
+
141
+ ```
142
+ ✓ Bitrix Task Sync installed and verified
143
+
144
+ Next: every commit must include [B24:{TASK_ID}] tag, e.g.:
145
+ feat: implement deal sync [B24:{task_id}]
146
+
147
+ AI activity (skills) auto-syncs to: {portal_url}/company/personal/user/USER/tasks/task/view/{task_id}/
148
+ ```
149
+
150
+ ## Failure modes
151
+
152
+ | Symptom | Likely cause | Fix |
153
+ |---------|--------------|-----|
154
+ | `command not found: jq` | macOS without homebrew | `brew install jq curl` |
155
+ | `npx: not found` | Node not installed | Install Node 20+ from nodejs.org |
156
+ | `git: not a repository` | Not in git repo | `git init` first |
157
+ | Webhook returns 401 | Bad token | Regenerate webhook in Bitrix24 → Apps → Webhooks |
158
+ | `TASK_ID: 1234abc` rejected | Non-numeric value | Use ID from task URL, e.g. `12345` |
159
+
160
+ ## Re-run behavior
161
+
162
+ Re-running on already-installed project:
163
+ - Step 1 detects existing `.claude/scripts/bitrix-*.sh`
164
+ - Skips to Step 7 (verify only)
165
+ - If verify passes → "Already installed and working"
166
+ - If verify fails → suggests `update` command
167
+
168
+ ## Notes
169
+
170
+ - **Pin version**: every `npx` example uses `@0.1.0` exact pin. Never `@latest`. User must explicitly bump after reading CHANGELOG.
171
+ - **Project-scope only**: skill operates on current cwd's git root. Does NOT touch other projects.
172
+ - **Idempotent**: re-run = no-op if state is good.
173
+ - **No secrets logged**: skill never echoes `BITRIX_WEBHOOK_URL` value, only its set/unset status.