Skip to content

refactor(account): use cli-core's shared CRM account remove and sign-in guard - #159

Merged
leemour merged 1 commit into
mainfrom
refactor/shared-account-remove
Nov 23, 2026
Merged

leemour merged 1 commit into
mainfrom
refactor/shared-account-remove

Conversation

@leemour

@leemour leemour commented Nov 23, 2026

Copy link
Copy Markdown
Member

Task

Use cli-core's shared CRM account remove and sign-in guard, and drop b24's hand-written copy (owner decision NEED-2796 A, 2026-11-23; cli-core PR WireCatLabs/cli-core#3212, released in 0.722.0).

Why

bitrix24-cli, amo-cli and hubspot-cli each kept about 110 lines of the same code: the removal for accountRemoveCommand, a guard that refuses --delete-data while another profile reads the same copy, and a refusal of a second sign-in to the same account and user. cli-core now ships one, so a fix lands once for every CRM CLI.

What

  • src/commands/account.ts now holds only B24_ACCOUNT, the CrmAccountOptions passed to addCrmCommands({ account }):
    • held reads the portal host and webhook user from the saved webhook. When that read fails or nothing is saved, it uses the <host>:<userId> that session start remembered.
    • When the saved webhook cannot be read and nothing was remembered, held throws. cli-core then refuses --delete-data with account-remove.account-unknown. It never returns "no account" for a profile that holds one, so it cannot delete another profile's copy.
    • signedOut keeps b24's words about the webhook or application staying in Bitrix24.
  • session start (webhook) and setup apply call refuseTakenCrmAccount instead of the local refuseDuplicate.
  • program.ts no longer mounts its own account. src/reasons.ts drops session.duplicate and account-remove.portal-shared, which now come from cli-core.
  • @wirecat/cli-core 0.710.0 → 0.722.0, @wirecat/cli-base 0.124.0 → 0.127.0. Regenerated the command pages, contracts/wirecat.json, the help snapshot and the test matrix. account remove now sits after search all, and cli-core's "Works with" list gains linear.

For users (the changelog fragment is changes/refactor-shared-account-remove.md):

  • account-remove.portal-shared (detail portal) is now account-remove.account-shared (detail account).
  • --delete-data --dry-run warns instead of failing.
  • session.duplicate keeps its reason. Its detail portal is now account, and the message points to b24 <profile> session end.
  • A webhook sign-in to a profile named files or foreign-contacts is refused with profile.reserved.

Not changed: the local-application sign-in (session start --portal) still runs no duplicate or reserved-name check, as before.

Testing

  • New tests through the command, using memoryKeyring() and temp folders, with nothing on the network:
    • a dry run with a second profile on the same portal warns;
    • when the other profile's saved webhook is unreadable, the refusal still holds, from what session start remembered;
    • when nothing tells which portal another profile holds, the run is refused with account-remove.account-unknown, and --keep-data still works.
  • Local runs:
    • vitest run: all pass.
    • Exit code 0 for: standards:check, lint, typecheck, lint:commands, audit:commands, contracts:check, contracts:upgrade, docs:check, generate:check, version:check, security:no-leak, package:check, test:matrix:check.

🤖 Generated with Claude Code

…in guard

Bitrix24's hand-written `account remove`, its --delete-data guard and the
duplicate-webhook refusal at `session start` are replaced by cli-core's shared
CRM ones (cli-core 0.722.0, NEED-2796 A). b24 keeps only what it must say
itself: `held`, which reads the portal host and webhook user from the saved
webhook and falls back to what `session start` remembered, and the sign-out
words.

`held` never swallows its own read failure: when the saved webhook cannot be
read and nothing was remembered, it throws, and cli-core refuses
--delete-data with `account-remove.account-unknown` instead of deleting a
copy another profile still reads.

For users:
- `account-remove.portal-shared` (detail `portal`) is now
  `account-remove.account-shared` (detail `account`).
- `--delete-data --dry-run` warns instead of failing.
- `session.duplicate` carries `account` instead of `portal` and points to
  `session end`.
- a webhook sign-in to a profile named `files` or `foreign-contacts` is
  refused with `profile.reserved`.

Also bumps @wirecat/cli-core 0.710.0 -> 0.722.0 and @wirecat/cli-base
0.124.0 -> 0.127.0, and regenerates the command pages, the manifest, the
help snapshot and the test matrix (account remove moves after search all).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​wirecat/​cli-base@​0.124.0 ⏵ 0.127.098 +1100100 +19670
Updated@​wirecat/​cli-core@​0.710.0 ⏵ 0.722.098 +1100100 +19670

View full report

@leemour
leemour merged commit 15de1b4 into main Nov 23, 2026
16 checks passed
@leemour
leemour deleted the refactor/shared-account-remove branch November 23, 2026 04:40
leemour added a commit that referenced this pull request Nov 24, 2026
…les were set opens its task

The regression test runs the stage-tasks rules through the command against the fake portal, with the move in the same
second the rules were set, as bin/b24-live does. The 0.27.0 section now also carries the shared account remove (#159).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leemour leemour mentioned this pull request Nov 24, 2026
leemour added a commit that referenced this pull request Nov 24, 2026
* chore(release): 0.27.0

Raises the version to 0.27.0, a minor because the section has Added (client
files, #154). The changes/ fragment is collected under the dated section.

bin/b24-live --write now also puts a small PDF in the test deal's first file
field, lists the deal's files and downloads that one, checking the saved bytes
and the extracted text; then creates a test contact and company, lists their
files and deletes them, and asks the portal that none is left.

DESIGN.md and usage.md record what the live run showed: a file field's shape
with original names, downloads from the portal host with no redirect, and
documents listed with the crm scope alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(files): files permissions hold on api call; MCP names file text as data

The fresh audit of 0.27.0 found that api call of the methods files reads
through (crm.documentgenerator.document.list/get, crm.timeline.comment.*,
disk.file.get) checked only its own api.* key, so files: deny could be got
round. Each now also checks files.list or files.download (WC-PERM-22), with a
regression row per method. The MCP server's list of untrusted text now names
file names and downloaded file text (WC-MCP-11).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(crm): cli-core 0.739.0, so a move in the second the stage-task rules were set opens its task

The regression test runs the stage-tasks rules through the command against the fake portal, with the move in the same
second the rules were set, as bin/b24-live does. The 0.27.0 section now also carries the shared account remove (#159).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(release): record the live check of 0.27.0

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(mcp): b24's MCP server offers schedule run, not schedule exec, as cli-core 0.739.0 does

cli-core #3258 stopped offering `schedule exec` over MCP and limits it to the tool's own schedules folder; the pin in
src/mcp.test.ts and docs/security.md still named it. The 0.27.0 changelog says so under "may break callers".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant