@synity/bitrix-skills 1.3.0 → 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.
Files changed (31) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/bin/bitrix-skills.js +0 -0
  3. package/dist/cli.js +80 -31
  4. package/dist/features/task-sync/index.js +0 -0
  5. package/package.json +20 -16
  6. package/src/features/bx/feature.json +5 -3
  7. package/src/features/bx-calendar/feature.json +7 -3
  8. package/src/features/bx-crm/assets/SKILL.md +73 -36
  9. package/src/features/bx-crm/assets/commerce.md +56 -27
  10. package/src/features/bx-crm/assets/convert.md +70 -0
  11. package/src/features/bx-crm/assets/document.md +103 -0
  12. package/src/features/bx-crm/assets/flows.md +144 -0
  13. package/src/features/bx-crm/assets/onboard.md +91 -73
  14. package/src/features/bx-crm/assets/report.md +64 -33
  15. package/src/features/bx-crm/assets/research.md +62 -24
  16. package/src/features/bx-crm/assets/vn-norms.md +50 -0
  17. package/src/features/bx-crm/feature.json +7 -3
  18. package/src/features/bx-task/assets/lib/bx-api.sh +0 -0
  19. package/src/features/bx-task/assets/lib/bx-resolve-task.sh +0 -0
  20. package/src/features/bx-task/feature.json +6 -3
  21. package/src/features/task-sync/assets/githooks/commit-msg +0 -0
  22. package/src/features/task-sync/assets/githooks/install.sh +0 -0
  23. package/src/features/task-sync/assets/scripts/bitrix-attach-files.sh +0 -0
  24. package/src/features/task-sync/assets/scripts/bitrix-lib.sh +0 -0
  25. package/src/features/task-sync/assets/scripts/bitrix-render-digest.sh +0 -0
  26. package/src/features/task-sync/assets/scripts/bitrix-session-check.sh +0 -0
  27. package/src/features/task-sync/assets/scripts/bitrix-session-sync.sh +0 -0
  28. package/src/features/task-sync/assets/scripts/bitrix-skill-end.sh +0 -0
  29. package/src/features/task-sync/assets/scripts/bitrix-skill-start.sh +0 -0
  30. package/src/features/task-sync/assets/skill/SKILL.md +173 -0
  31. package/src/features/task-sync/feature.json +9 -4
@@ -1,13 +1,13 @@
1
1
  # bx:crm — Research (Analysis Protocol)
2
2
 
3
- Covers: customer360, contactSignals, dealSignals, customerJourney, chatHistory.
3
+ Covers: customer360, contactSignals, dealSignals, customerJourney, chatHistory, nextAction, behaviorWindow.
4
4
 
5
5
  ---
6
6
 
7
7
  ## Helper Selection
8
8
 
9
9
  | Need | Helper | Returns |
10
- |------|--------|---------|
10
+ |---|---|---|
11
11
  | Full customer overview | `customer360` | profile + deals + comms + invoices |
12
12
  | Quick risk signals | `contactSignals` | 8 sections raw context |
13
13
  | Deal health check | `dealSignals` | pipeline + activities + AR |
@@ -20,31 +20,47 @@ Covers: customer360, contactSignals, dealSignals, customerJourney, chatHistory.
20
20
 
21
21
  ## Output Protocol — customer360
22
22
 
23
- Always present in this order:
24
-
25
- 1. **Profile** — name, company, lifecycle stage, assigned rep
26
- 2. **Deals** — active deals (stage, value, days in stage)
27
- 3. **Last contact** — channel + date + 1-line content summary
28
- 4. **Pending actions** — overdue activities, unpaid invoices
29
- 5. **Recommendation** — next action in 1 concrete sentence
23
+ 1. **Profile** name, company, lifecycle stage, assigned rep.
24
+ 2. **Deals** — active deals (stage, value, days in stage).
25
+ 3. **Last contact** — channel + date + 1-line summary.
26
+ 4. **Pending actions** — overdue activities, unpaid invoices.
27
+ 5. **Recommendation** — next action in 1 concrete sentence.
30
28
 
31
29
  ---
32
30
 
33
31
  ## Output Protocol — contactSignals / dealSignals
34
32
 
35
- 1. **Risk level** — `HIGH` / `MEDIUM` / `LOW` + 1-line reason
36
- 2. **Top 3 signals** — bulleted, most critical first
37
- 3. **Next action** — specific, with suggested deadline
38
- 4. **Reference** — contactId / dealId for traceability
33
+ 1. **Risk level** — `HIGH` / `MEDIUM` / `LOW` + 1-line reason.
34
+ 2. **Top 3 signals** — most critical first.
35
+ 3. **Next action** — specific, with suggested deadline.
36
+ 4. **Reference** — contactId / dealId for traceability.
39
37
 
40
38
  ---
41
39
 
42
40
  ## Output Protocol — customerJourney
43
41
 
44
- 1. **Timeline** — chronological: stage changes + key communications
45
- 2. **Turning points** — when did deal get stuck or advance?
46
- 3. **Sentiment trend** — Positive / Neutral / Negative
47
- 4. **Gap analysis** — longest silence period (in days)
42
+ 1. **Timeline** — stage changes + key communications.
43
+ 2. **Turning points** — when deal got stuck or advanced.
44
+ 3. **Sentiment trend** — Positive / Neutral / Negative.
45
+ 4. **Gap analysis** — longest silence period in days.
46
+
47
+ ---
48
+
49
+ ## Output Protocol — nextAction
50
+
51
+ 1. **Action** — one imperative sentence.
52
+ 2. **Reasoning** — 1-2 bullets explaining why now.
53
+ 3. **Deadline** — exact date/time when possible.
54
+ 4. **Reference** — source contactId/dealId.
55
+
56
+ ---
57
+
58
+ ## Output Protocol — behaviorWindow
59
+
60
+ 1. **Window** — date range and interaction count.
61
+ 2. **Trend** — Increasing / Stable / Declining.
62
+ 3. **Last 3 events** — date + channel + 1-line summary.
63
+ 4. **Recommendation** — next action tied to the trend.
48
64
 
49
65
  ---
50
66
 
@@ -52,20 +68,42 @@ Always present in this order:
52
68
 
53
69
  ```js
54
70
  chatHistory({
55
- entityType: "contact", // or "deal"
71
+ entityType: "contact",
56
72
  entityId: 123,
57
- channels: ["chat", "zalo", "email"], // optional filter
73
+ channels: ["chat", "zalo", "email"],
58
74
  limit: 50
59
75
  })
60
76
  ```
61
77
 
62
- Present as: `[date] [channel]: <1-line summary>` per message block.
78
+ Present as: `[date] [channel]: <1-line summary>`.
79
+
80
+ ---
81
+
82
+ ## Example Dialog — customer360
83
+
84
+ User: "phân tích contact #123 trước cuộc họp 2pm"
85
+
86
+ LLM behavior: call `customer360({ contactId: 123 })`, then follow the customer360 output protocol.
87
+
88
+ Sample output:
89
+ ```text
90
+ Profile: Nguyen Van A, ABC Training, assigned to Linh.
91
+ Deals: 2 active; main deal 80M VND stuck 18 days.
92
+ Last contact: Zalo 2026-05-14, asked for contract terms.
93
+ Pending actions: proposal follow-up overdue 1 day.
94
+ Recommendation: Call before 14:00 and confirm decision timeline.
95
+ ```
63
96
 
64
97
  ---
65
98
 
66
99
  ## Pre-Research Checklist
67
100
 
68
- Before calling any intelligence helper:
69
- - [ ] Have contactId or dealId ready
70
- - [ ] Know the goal (overview / risk check / history / next action)
71
- - [ ] Use `codemode.search({ intent: "read" })` if unsure which helper fits
101
+ - [ ] Have contactId or dealId ready.
102
+ - [ ] Know the goal: overview, risk check, history, next action, or behavior.
103
+ - [ ] Use `codemode.search({ intent: "read" })` if unsure which helper fits.
104
+
105
+ ## Verify Checklist
106
+
107
+ - [ ] Output cites source contactId/dealId.
108
+ - [ ] Recommendations are based on returned signals, not invented context.
109
+ - [ ] PII is summarized only as needed for the user's stated purpose.
@@ -0,0 +1,50 @@
1
+ # bx:crm — VN Normalization Reference
2
+
3
+ Vietnam-specific normalization for phone, honorific, address, and MST.
4
+
5
+ ---
6
+
7
+ ## Phone Normalization
8
+
9
+ `upsertContact` auto-normalizes. Pass raw user input.
10
+
11
+ | Input | Stored as |
12
+ |---|---|
13
+ | `0977680550` | `+84977680550` |
14
+ | `0977 68 0550` | `+84977680550` |
15
+ | `84977680550` | `+84977680550` |
16
+ | `+84977680550` | `+84977680550` |
17
+ | `+6591234567` | `+6591234567` |
18
+
19
+ Rules: strip spaces/dashes; VN leading `0` becomes `+84`; existing country code stays; non-VN numbers stay unchanged.
20
+
21
+ ---
22
+
23
+ ## HONORIFIC
24
+
25
+ | Input | Value |
26
+ |---|---|
27
+ | Anh / Mr | `Anh` |
28
+ | Chị / Ms / Mrs | `Chị` |
29
+ | Em | `Em` |
30
+ | Cô | `Cô` |
31
+ | Chú | `Chú` |
32
+ | Bác | `Bác` |
33
+ | Ông (senior male) | `Ông` |
34
+ | Bà (senior female) | `Bà` |
35
+ | Unknown | omit field |
36
+
37
+ ---
38
+
39
+ ## Address + MST
40
+
41
+ VN legal address should preserve: street, ward, district, province/city, country. Do not invent missing parts. Prefer GDT/VietQR registry data from `upsertCompanyByTaxCode`.
42
+
43
+ - Company MST: usually 10 digits.
44
+ - Branch MST: 13 digits, often `10-digit-parent-3-digit-branch`.
45
+ - Store in Bitrix requisites as `RQ_INN` and `RQ_VAT_ID`.
46
+
47
+ ## Verify Checklist
48
+
49
+ - [ ] Raw phone was passed to helper, not preformatted.
50
+ - [ ] Missing address/MST parts were not invented.
@@ -4,7 +4,11 @@
4
4
  "version": "2.0.0",
5
5
  "target": "global",
6
6
  "description": "Claude Code skill for Bitrix24 CRM: contacts, companies, deals, leads, estimates, invoices, customer analysis, pipeline reports",
7
+ "status": "planned",
7
8
  "requires": {
8
- "mcp": ["bitrix-synity-mcp"]
9
- }
10
- }
9
+ "mcp": [
10
+ "bitrix-synity-mcp"
11
+ ]
12
+ },
13
+ "tier": 0
14
+ }
File without changes
@@ -5,6 +5,9 @@
5
5
  "target": "global",
6
6
  "description": "Claude Code skill for Bitrix24 task management",
7
7
  "requires": {
8
- "mcp": ["bitrix-synity-mcp"]
9
- }
10
- }
8
+ "mcp": [
9
+ "bitrix-synity-mcp"
10
+ ]
11
+ },
12
+ "tier": 0
13
+ }
File without changes
File without changes
@@ -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.
@@ -4,9 +4,14 @@
4
4
  "version": "0.3.0-pre",
5
5
  "target": "project",
6
6
  "description": "AI session sync to Bitrix task chat via hooks",
7
- "needs": ["bash-lib"],
7
+ "needs": [
8
+ "bash-lib"
9
+ ],
8
10
  "requires": {
9
- "env": ["BITRIX_WEBHOOK_URL"],
11
+ "env": [
12
+ "BITRIX_WEBHOOK_URL"
13
+ ],
10
14
  "task_id": true
11
- }
12
- }
15
+ },
16
+ "tier": 0
17
+ }