From fb6deee34e6ed707a721dae23ad89e8d788abf29 Mon Sep 17 00:00:00 2001 From: sendbird-client-release Date: Thu, 15 Oct 2026 13:15:04 +0000 Subject: [PATCH] release 0.1.48 --- .claude-plugin/marketplace.json | 2 +- README.md | 6 +- .../.claude-plugin/plugin.json | 2 +- .../sendbird-client/.codex-plugin/plugin.json | 2 +- plugins/sendbird-client/README.md | 2 +- .../sendbird-client/config/plugin-config.json | 2 +- .../sendbird-client/docs/AGENT_CONTRACT.md | 2 +- .../sendbird-client/hooks/credential-guard.sh | 2 +- .../hooks/destructive-command-guard.sh | 11 +- .../hooks/final-answer-gate.sh | 63 +++------- .../sendbird-client/hooks/lib/hook-helpers.sh | 114 +++++++++++++++++- .../sendbird-client/hooks/run-summary-gate.sh | 4 +- .../hooks/source-claim-guard.sh | 50 ++------ plugins/sendbird-client/hooks/welcome.sh | 12 +- .../skills/calls-incoming/SKILL.md | 2 +- .../skills/diagnose-channel/SKILL.md | 2 +- .../sendbird-client/skills/fix-build/SKILL.md | 2 +- .../skills/permissions-setup/SKILL.md | 2 +- .../skills/start-chat/SKILL.md | 2 +- .../ios/swiftui/calls/CallsSession.swift | 2 +- .../ios/uikit/calls/SetupCalls.swift | 2 +- .../ios/uikit/uikit/SetupUIKit.swift | 2 +- .../templates/js/react-native/calls/setup.ts | 2 +- .../templates/js/react/calls/setup.ts | 2 +- .../common/detect-existing-integration.sh | 36 ++++++ .../tools/detection/common/detect-products.sh | 35 ++++-- .../tools/detection/lib/detect-helpers.sh | 44 +++++++ .../tools/local-sdk/read-surface.sh | 13 +- 28 files changed, 290 insertions(+), 132 deletions(-) diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index da3bc2d..9dd1026 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -12,7 +12,7 @@ "source": "git-subdir", "url": "https://github.com/sendbird/sendbird-client-plugin.git", "path": "plugins/sendbird-client", - "ref": "v0.1.47" + "ref": "v0.1.48" }, "description": "Sendbird integration helper for Chat (incl. auth/session) and UIKit across iOS, Android, and JS. Includes hooks that run local shell scripts; see README \"What runs on your machine\"." } diff --git a/README.md b/README.md index fb64745..3ad8bc6 100644 --- a/README.md +++ b/README.md @@ -90,14 +90,16 @@ This plugin runs inside Claude Code with your user account's permissions. Three | Session start | `hooks/welcome.sh` | plugin files | adds the plugin's rules to the model's context | none | | Before a file write or shell command | `hooks/credential-guard.sh` | the content or command about to run | blocks it if it contains a credential | none | | Before a shell command | `hooks/destructive-command-guard.sh` | the command about to run | asks you to approve a Sendbird CLI `delete`, `revoke`, or `deactivate` run with `--yes`; in a `-p` run it is denied | none | -| Before a file write, or a shell command that writes a source file | `hooks/source-claim-guard.sh` | the content about to be written, local files it cites | blocks Sendbird API code without a verifiable source | fetches the cited page if it is on `sendbird.com/docs` or `github.com/sendbird` | +| Before a file write, or a shell command that writes a source file | `hooks/source-claim-guard.sh` | the content about to be written, local files it cites | blocks Sendbird API code without a verifiable source: a plugin file, an installed SDK file (`node_modules/@sendbird`, `Pods`, `.build`, Xcode `SourcePackages` or `DerivedData`, the Gradle cache), or a public page; a file the model wrote in your project does not count | fetches the cited page if it is on `sendbird.com/docs` or is a file in a `github.com/sendbird` repository (a `/blob/` or `/raw/` link); issues, discussions, and pull requests are not fetched | | After an agent finishes | `hooks/unsourced-claim-warn.sh` | the agent's reply | adds a warning when an API claim has no source; in Codex, sends the agent back once to add sources | none | | When the answer ends | `hooks/final-answer-gate.sh` | the final answer (passed by Claude Code; older versions: the session transcript after your last prompt) | asks the model to revise an unsourced answer | same as `source-claim-guard.sh` | -| When the answer ends, only when `SENDBIRD_NONINTERACTIVE` is set | `hooks/run-summary-gate.sh` | the final answer and the plugin's run summary schema | asks the model to fix a run summary that does not match the schema | none | +| When the answer ends, only when `SENDBIRD_NONINTERACTIVE` is `1`, `true`, or `yes` | `hooks/run-summary-gate.sh` | the final answer and the plugin's run summary schema | asks the model to fix a run summary that does not match the schema | none | | Before and after an agent runs | `hooks/telemetry-start.sh`, `hooks/telemetry-end.sh` | agent name, duration, outcome | nothing; writes a local log only if you opted in | none | The two fetching hooks send a plain request for the cited public page (8-second timeout); nothing from your project or conversation is sent. +The hooks read their input with `jq`. When `jq` is not on your `PATH`, the credential, source, and destructive-command guards cannot check a call, so instead of blocking or allowing it they ask you to approve every file write and shell command, and the session start says that `jq` is missing. The other hooks then do nothing. Install `jq` to turn the checks back on. + **Scripts the agent runs** through Claude Code's Bash tool, under your Claude Code permission settings: project detection (reads manifests such as `package.json`, `Podfile`, `Package.swift`, `build.gradle`) and the installed-SDK reader (reads `node_modules/@sendbird/*`, `Pods/`, `.build/`, this project's Xcode `DerivedData`, and the Gradle cache). **Instructions** — skills and agents that tell Claude how to work. They change what Claude does in your session. diff --git a/plugins/sendbird-client/.claude-plugin/plugin.json b/plugins/sendbird-client/.claude-plugin/plugin.json index 3900ccc..08830fb 100644 --- a/plugins/sendbird-client/.claude-plugin/plugin.json +++ b/plugins/sendbird-client/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "sendbird-client", "displayName": "Sendbird Client", - "version": "0.1.47", + "version": "0.1.48", "description": "Sendbird integration helper for Chat (incl. auth/session) and UIKit across iOS, Android, and JS", "author": { "name": "Sendbird", diff --git a/plugins/sendbird-client/.codex-plugin/plugin.json b/plugins/sendbird-client/.codex-plugin/plugin.json index 8d6e20b..a4a896e 100644 --- a/plugins/sendbird-client/.codex-plugin/plugin.json +++ b/plugins/sendbird-client/.codex-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "sendbird-client", - "version": "0.1.47", + "version": "0.1.48", "description": "Sendbird integration helper for Chat (incl. auth/session) and UIKit across iOS, Android, and JS", "author": { "name": "Sendbird", diff --git a/plugins/sendbird-client/README.md b/plugins/sendbird-client/README.md index 99cb79c..48b05f3 100644 --- a/plugins/sendbird-client/README.md +++ b/plugins/sendbird-client/README.md @@ -3,7 +3,7 @@ > Generated by `tools/editions/build.sh` from the repository root. Do not edit this folder; > change the root and rerun the build. -`sendbird-client` v0.1.47 — Sendbird integration helper for Chat (incl. auth/session) and UIKit across iOS, Android, and JS. +`sendbird-client` v0.1.48 — Sendbird integration helper for Chat (incl. auth/session) and UIKit across iOS, Android, and JS. ## Products diff --git a/plugins/sendbird-client/config/plugin-config.json b/plugins/sendbird-client/config/plugin-config.json index 439b149..db26d6f 100644 --- a/plugins/sendbird-client/config/plugin-config.json +++ b/plugins/sendbird-client/config/plugin-config.json @@ -1,5 +1,5 @@ { - "schemaVersion": "0.1.47", + "schemaVersion": "0.1.48", "knowledge": { "mode": "runtime-fetch", "_modes": [ diff --git a/plugins/sendbird-client/docs/AGENT_CONTRACT.md b/plugins/sendbird-client/docs/AGENT_CONTRACT.md index 075d169..77ae8fb 100644 --- a/plugins/sendbird-client/docs/AGENT_CONTRACT.md +++ b/plugins/sendbird-client/docs/AGENT_CONTRACT.md @@ -94,7 +94,7 @@ Return: ## 7. Non-interactive runs -When `SENDBIRD_NONINTERACTIVE` is set (for example `SENDBIRD_NONINTERACTIVE=1 claude -p ...` in CI or a script), nobody can answer a question during the run. +When `SENDBIRD_NONINTERACTIVE` is `1`, `true`, or `yes` in any case (for example `SENDBIRD_NONINTERACTIVE=1 claude -p ...` in CI or a script), nobody can answer a question during the run. Any other value, including an empty one, `0`, `false`, or `no`, keeps the run interactive. - Never ask the user a question, and never end the answer with one. - For a value you would otherwise ask for, use the environment (`SENDBIRD_APP_ID`, `SENDBIRD_PRODUCTS`, `SENDBIRD_REGION`, `SENDBIRD_PLAN`) or the project's `profile.json` when they have it. diff --git a/plugins/sendbird-client/hooks/credential-guard.sh b/plugins/sendbird-client/hooks/credential-guard.sh index d27466a..82bf25f 100755 --- a/plugins/sendbird-client/hooks/credential-guard.sh +++ b/plugins/sendbird-client/hooks/credential-guard.sh @@ -10,7 +10,7 @@ set -uo pipefail HERE="$(cd "$(dirname "$0")" && pwd)" source "$HERE/lib/hook-helpers.sh" -read_stdin_json +read_stdin_json guard tool="$(jget .tool_name)" case "$tool" in diff --git a/plugins/sendbird-client/hooks/destructive-command-guard.sh b/plugins/sendbird-client/hooks/destructive-command-guard.sh index 6d4e1a4..9943479 100755 --- a/plugins/sendbird-client/hooks/destructive-command-guard.sh +++ b/plugins/sendbird-client/hooks/destructive-command-guard.sh @@ -11,13 +11,18 @@ set -uo pipefail HERE="$(cd "$(dirname "$0")" && pwd)" # shellcheck source=lib/hook-helpers.sh source "$HERE/lib/hook-helpers.sh" -read_stdin_json +read_stdin_json guard [ "$(jget .tool_name)" = "Bash" ] || exit 0 cmd="$(jget .tool_input.command)" [ -n "$cmd" ] || exit 0 -# Look at each simple command (split on ; && || | and newlines) on its own. +# Normalize before matching: quotes, backticks, and command substitution become spaces, so a +# command wrapped as bash -c "sendbird ...", sh -c'...', zsh -c, eval "...", $(...), or with a +# quoted program name reads as plain words. Then look at each simple command (split on +# ; && || | and newlines) on its own. An env or sudo prefix needs nothing: the CLI name is +# matched anywhere after a space. +norm="$(printf '%s\n' "$cmd" | tr "\"'\`()" ' ')" hit="" while IFS= read -r part; do # the CLI: sendbird, sendbird-cli, or npx/pnpm dlx/bunx @sendbird/cli @@ -25,7 +30,7 @@ while IFS= read -r part; do printf '%s' "$part" | grep -Eq '(^|[[:space:]])(delete|revoke|deactivate)([[:space:]]|$)' || continue printf '%s' "$part" | grep -Eq '(^|[[:space:]])(--yes|-y)([[:space:]=]|$)' || continue hit="$part"; break -done < <(printf '%s\n' "$cmd" | sed -E 's/(&&|\|\||;|\|)/\n/g') +done < <(printf '%s\n' "$norm" | sed -E 's/(&&|\|\||;|\|)/\n/g') [ -n "$hit" ] || exit 0 jq -n --arg c "$(printf '%s' "$hit" | sed -E 's/^[[:space:]]+//' | cut -c1-200)" '{ diff --git a/plugins/sendbird-client/hooks/final-answer-gate.sh b/plugins/sendbird-client/hooks/final-answer-gate.sh index 9e41057..a5bbedf 100755 --- a/plugins/sendbird-client/hooks/final-answer-gate.sh +++ b/plugins/sendbird-client/hooks/final-answer-gate.sh @@ -2,7 +2,8 @@ # Stop hook: citation gate for the FINAL answer of a turn (closes the gap where the # main loop names Sendbird APIs without any skill/agent involved — dogfood round 2). # -# Behavior: if the final answer contains Sendbird-specific API identifiers AND code, +# Behavior: if the final answer contains Sendbird-specific API identifiers AND code (or, in +# prose, a Sendbird error code or a dotted Sendbird symbol), # but no citation marker, block ONCE with a reason (Claude continues and adds sources # or corrects). The documented `stop_hook_active` guard makes the second pass exit 0, # so this can never loop or trap the session. Fail-open on any parsing problem. @@ -22,9 +23,15 @@ text="$(final_answer_text)" # line; otherwise PR numbers, dates and IDs would gate unrelated answers. code_ctx='(error|Error|ERROR|code|Code|에러|오류|코드)[^0-9]{0,24}[0-9]{6}([^0-9]|$)' -# Only gate Sendbird-flavored answers that include code-shaped content. +# A Sendbird type followed by a member (GroupChannel.createChannel) names an API even in prose. +dotted_symbol='(SendbirdChat|SendBirdCall|SendbirdCalls|AIAgentMessenger|SendbirdUIKit|SendbirdLive|SendbirdDesk|SendBirdDesk|MessengerLauncher|GroupChannel|BaseMessage|SBU[A-Z][A-Za-z0-9_]*|SBA[A-Z][A-Za-z0-9_]*|SBDSK[A-Za-z0-9_]*)\.[A-Za-z_]' + +# Gate Sendbird-flavored answers that include code-shaped content, and prose answers that name +# a Sendbird error code or a dotted Sendbird symbol ("Error code 400302 means ..." has no code +# block but states a fact that needs a source). A bare type name in prose is not checked. printf '%s' "$text" | grep -Eq "SendbirdChat|SendBirdCall|SendbirdCalls|AIAgentMessenger|SendbirdUIKit|SendbirdLive|SendbirdDesk|SendBirdDesk|MessengerLauncher|GroupChannel|BaseMessage|@sendbird/|\bSBU[A-Z]|\bSBA[A-Z]|\bSBDSK|$code_ctx" || exit 0 -printf '%s' "$text" | grep -Eq '```|[A-Za-z]\([A-Za-z]*:' || exit 0 +printf '%s' "$text" | grep -Eq '```|[A-Za-z]\([A-Za-z]*:' \ + || printf '%s' "$text" | grep -Eq "$code_ctx|$dotted_symbol" || exit 0 # Pass only when a concrete source marker resolves to a shipped local file or an # allowed public URL. Vague words such as "verified" are not citations. @@ -35,51 +42,11 @@ error_codes="$(printf '%s' "$text" | grep -Eo "$code_ctx" | grep -Eo '[0-9]{6}' symbols="$(printf '%s\n%s\n%s\n' "$symbols" "$instance_methods" "$error_codes" | sed '/^$/d' | sort -u)" # Nothing checkable (for example a bare package name in prose): let it pass. [ -n "$symbols" ] || exit 0 -source_supports_symbol() { - local file="$1" symbol="$2" method - [ -s "$file" ] || return 1 - grep -Fq -- "$symbol" "$file" && return 0 - method="${symbol#*.}" - grep -Eq -- "(^|[^A-Za-z0-9_])${method}([^A-Za-z0-9_]|$)" "$file" -} -cwd="$(jget '.cwd')" -resolved_sources=() -tmp_sources=() -while IFS= read -r source; do - [ -n "$source" ] || continue - case "$source" in - https://sendbird.com/docs/*|https://github.com/sendbird/*) - tmp_source="$(mktemp)" - if curl -fsSL --max-time 8 "$source" -o "$tmp_source" 2>/dev/null; then - resolved_sources+=("$tmp_source") - tmp_sources+=("$tmp_source") - else - rm -f "$tmp_source" - fi - ;; - knowledge/curated/*) - root="${CLAUDE_PLUGIN_ROOT:-.}" - resolved_sources+=("$root/$source") - ;; - .sendbird-client/cache/*) - project_root="${cwd:-$(pwd)}" - resolved_sources+=("$project_root/$source") - ;; - *.swiftinterface|*.d.ts) resolved_sources+=("$source") ;; - esac -done <<< "$sources" - -valid=1 -while IFS= read -r symbol; do - supported=0 - for source_file in ${resolved_sources[@]+"${resolved_sources[@]}"}; do - if source_supports_symbol "$source_file" "$symbol"; then supported=1; break; fi - done - [ "$supported" -eq 1 ] || { valid=0; break; } -done <<< "$symbols" -for tmp_source in ${tmp_sources[@]+"${tmp_sources[@]}"}; do rm -f "$tmp_source"; done -[ "$valid" -eq 1 ] && exit 0 +# Plugin files, the plugin's SDK cache, installed SDK interfaces, and public Sendbird pages +# (hooks/lib/hook-helpers.sh resolve_cited_sources); a file the model wrote in the app does not count. +resolve_cited_sources "$(jget '.cwd')" <<< "$sources" +all_symbols_sourced "$symbols" && exit 0 jq -n '{decision: "block", - reason: "Final-answer citation gate (Sendbird plugin): this answer names Sendbird APIs/code but cites no source. Re-emit it citing a verifiable source per symbol — knowledge/curated//... , the customer-local SDK surface, a public sendbird/* repo, or a version-matched sendbird.com/docs page — or state: I do not know, and list what you checked. Do not invent symbols."}' + reason: "Final-answer citation gate (Sendbird plugin): this answer names Sendbird APIs/code but cites no source. Re-emit it citing a verifiable source per symbol — knowledge/curated//... , the customer-local SDK surface or installed SDK files, a file in a public sendbird/* repo (a /blob/ or /raw/ link, not an issue or discussion), or a version-matched sendbird.com/docs page — or state: I do not know, and list what you checked. Do not invent symbols."}' exit 0 diff --git a/plugins/sendbird-client/hooks/lib/hook-helpers.sh b/plugins/sendbird-client/hooks/lib/hook-helpers.sh index c7eeb9f..38f2274 100644 --- a/plugins/sendbird-client/hooks/lib/hook-helpers.sh +++ b/plugins/sendbird-client/hooks/lib/hook-helpers.sh @@ -1,12 +1,39 @@ #!/usr/bin/env bash # Shared helpers for hook scripts. Source this file. Reads stdin JSON once. -# read_stdin_json : caches the stdin payload into $HOOK_JSON (empty if none/not json) +# JQ_MISSING_REASON : what a guard tells the user when jq is missing (welcome.sh says it too) +JQ_MISSING_REASON='The Sendbird plugin safety checks (credential, source citation, and destructive-command guards) need jq, which is not on PATH, so this call was not checked. Approve it only if you trust it, and install jq to turn the checks back on.' + +# ask_without_jq : the PreToolUse "ask" decision, built with printf because jq is absent +ask_without_jq() { + printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"ask","permissionDecisionReason":"%s"}}\n' "$JQ_MISSING_REASON" +} + +# read_stdin_json [guard] : caches the stdin payload into $HOOK_JSON (empty if none/not json). +# Every hook reads its input with jq. Without jq on PATH no check can run, so the hook stops +# here instead of reading '{}' and letting everything through: a PreToolUse guard (called with +# "guard") asks the user to approve the call, and any other hook exits 0 without blocking. read_stdin_json() { + if ! command -v jq >/dev/null 2>&1; then + cat >/dev/null 2>&1 || true + [ "${1:-}" = guard ] && ask_without_jq + exit 0 + fi HOOK_JSON="$(cat 2>/dev/null || true)" if ! printf '%s' "$HOOK_JSON" | jq -e . >/dev/null 2>&1; then HOOK_JSON='{}'; fi } +# is_noninteractive : 0 when SENDBIRD_NONINTERACTIVE turns on a non-interactive run (1, true, or +# yes in any case). Empty, 0, false, no, and any other value keep the run interactive. welcome.sh +# and run-summary-gate.sh both use this, so the model is told about the run summary exactly when +# the gate checks it. (tr, not ${v,,}: stock macOS bash 3.2.) +is_noninteractive() { + case "$(printf '%s' "${SENDBIRD_NONINTERACTIVE:-}" | tr '[:upper:]' '[:lower:]')" in + 1|true|yes) return 0 ;; + *) return 1 ;; + esac +} + # jget : echo a string field from $HOOK_JSON ('' if absent) jget() { printf '%s' "$HOOK_JSON" | jq -r "$1 // empty" 2>/dev/null; } @@ -34,6 +61,91 @@ final_answer_text() { printf '%s' "$text" } +# --- Cited sources (source-claim-guard.sh, final-answer-gate.sh) --------------------------- +# A cited source counts only when the model cannot have written it in this session. + +# public_source_url : 0 for a page Sendbird controls: sendbird.com/docs, or a file at a +# ref in a sendbird GitHub repository (/blob/ or /raw/, or raw.githubusercontent.com). Issues, +# discussions, pull requests, and other GitHub pages are written by anyone, so they do not count. +public_source_url() { + printf '%s' "$1" | grep -Eq '^https://sendbird\.com/docs/|^https://github\.com/sendbird/[A-Za-z0-9._-]+/(blob|raw)/[^[:space:]]+|^https://raw\.githubusercontent\.com/sendbird/[A-Za-z0-9._-]+/[^[:space:]]+' +} + +# sdk_source_path : prints the real path of a local .d.ts or .swiftinterface when it +# is inside an installed SDK (node_modules/@sendbird or node_modules/sendbird-*, Pods, .build, +# SourcePackages, DerivedData, the Gradle cache) or the plugin's own knowledge/ or templates/; +# prints nothing for any other file, such as one the model just wrote in the app's folders. +# A relative path resolves from ; ".." is resolved before the check. +sdk_source_path() { + local p="$1" cwd="$2" d real root + case "$p" in /*) ;; *) p="${cwd:-$(pwd)}/$p" ;; esac + [ -f "$p" ] || return 0 + d="$(cd "$(dirname "$p")" 2>/dev/null && pwd -P)" || return 0 + real="$d/$(basename "$p")" + root="$(cd "${CLAUDE_PLUGIN_ROOT:-$(dirname "${BASH_SOURCE[0]}")/../..}" 2>/dev/null && pwd -P)" + case "$real" in + "$root"/knowledge/*|"$root"/templates/*) printf '%s' "$real" ;; + */node_modules/@sendbird/*|*/node_modules/sendbird-*|*/Pods/*|*/.build/*|*/SourcePackages/*|*/DerivedData/*|*/.gradle/caches/*) + printf '%s' "$real" ;; + esac +} + +# resolve_cited_sources : reads cited source tokens on stdin, one per line, and fills +# RESOLVED_SOURCES with the files to search for a symbol: plugin files (knowledge/, templates/), +# the plugin's cache of the customer's installed SDK, installed SDK interfaces, and fetched +# copies of public pages. Fetched copies are also in TMP_SOURCES; remove them when done. +resolve_cited_sources() { + local cwd="$1" source tmp_source local_path root="${CLAUDE_PLUGIN_ROOT:-.}" + RESOLVED_SOURCES=(); TMP_SOURCES=() + while IFS= read -r source; do + [ -n "$source" ] || continue + case "$source" in *..*) continue ;; esac + case "$source" in + knowledge/*|templates/*) + RESOLVED_SOURCES+=("$root/$source") ;; + .sendbird-client/cache/*) + RESOLVED_SOURCES+=("${cwd:-$(pwd)}/$source") ;; + *.swiftinterface|*.d.ts) + local_path="$(sdk_source_path "$source" "$cwd")" + [ -z "$local_path" ] || RESOLVED_SOURCES+=("$local_path") ;; + https://*) + public_source_url "$source" || continue + tmp_source="$(mktemp)" + if curl -fsSL --max-time 8 "$source" -o "$tmp_source" 2>/dev/null; then + RESOLVED_SOURCES+=("$tmp_source"); TMP_SOURCES+=("$tmp_source") + else + rm -f "$tmp_source" + fi ;; + esac + done +} + +# source_supports_symbol : 0 when the file names the symbol, or for Type.member +# the member as a whole word +source_supports_symbol() { + local file="$1" symbol="$2" method + [ -s "$file" ] || return 1 + grep -Fq -- "$symbol" "$file" && return 0 + method="${symbol#*.}" + grep -Eq -- "(^|[^A-Za-z0-9_])${method}([^A-Za-z0-9_]|$)" "$file" +} + +# all_symbols_sourced : 0 when every symbol (one per line) is in one of +# RESOLVED_SOURCES. Removes the fetched copies either way. +all_symbols_sourced() { + local symbol supported source_file valid=1 + while IFS= read -r symbol; do + [ -n "$symbol" ] || continue + supported=0 + for source_file in ${RESOLVED_SOURCES[@]+"${RESOLVED_SOURCES[@]}"}; do + if source_supports_symbol "$source_file" "$symbol"; then supported=1; break; fi + done + [ "$supported" -eq 1 ] || { valid=0; break; } + done <<< "$1" + for source_file in ${TMP_SOURCES[@]+"${TMP_SOURCES[@]}"}; do rm -f "$source_file"; done + [ "$valid" -eq 1 ] +} + # emit_warning : warn-only output (exit 0 in caller). Never blocks. emit_warning() { jq -n --arg m "$1" '{systemMessage: $m}'; } diff --git a/plugins/sendbird-client/hooks/run-summary-gate.sh b/plugins/sendbird-client/hooks/run-summary-gate.sh index ed62ec1..9325673 100755 --- a/plugins/sendbird-client/hooks/run-summary-gate.sh +++ b/plugins/sendbird-client/hooks/run-summary-gate.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Stop hook for non-interactive runs (SENDBIRD_NONINTERACTIVE set): the caller, a CLI or a +# Stop hook for non-interactive runs (SENDBIRD_NONINTERACTIVE=1, true, or yes): the caller, a CLI or a # script, decides what to do next from the run summary the answer ends with, so its shape is # checked before the run ends. A follow-up request sent with --resume does not get the # session-start instructions again, and such a run once ended with "status": "ok" and no @@ -12,7 +12,7 @@ HERE="$(cd "$(dirname "$0")" && pwd)" source "$HERE/lib/hook-helpers.sh" read_stdin_json -[ -n "${SENDBIRD_NONINTERACTIVE:-}" ] || exit 0 +is_noninteractive || exit 0 [ "$(jget '.stop_hook_active')" = "true" ] && exit 0 SCHEMA="${CLAUDE_PLUGIN_ROOT:-$HERE/..}/core/schemas/run-summary.schema.json" [ -r "$SCHEMA" ] || exit 0 diff --git a/plugins/sendbird-client/hooks/source-claim-guard.sh b/plugins/sendbird-client/hooks/source-claim-guard.sh index 6f6ca7e..6fea992 100755 --- a/plugins/sendbird-client/hooks/source-claim-guard.sh +++ b/plugins/sendbird-client/hooks/source-claim-guard.sh @@ -5,23 +5,14 @@ set -uo pipefail HERE="$(cd "$(dirname "$0")" && pwd)" # shellcheck source=lib/hook-helpers.sh source "$HERE/lib/hook-helpers.sh" -read_stdin_json +read_stdin_json guard cwd="$(jget '.cwd')" -source_supports_symbol() { - local file="$1" symbol="$2" method - [ -s "$file" ] || return 1 - grep -Fq -- "$symbol" "$file" && return 0 - method="${symbol#*.}" - grep -Eq -- "(^|[^A-Za-z0-9_])${method}([^A-Za-z0-9_]|$)" "$file" -} - # body_is_sourced : 0 when every Sendbird symbol in is found in a # source that or the existing file cites. body_is_sourced() { -local body="$1" existing="$2" context symbols instance_methods sources source tmp_source symbol supported source_file valid -local -a resolved_sources=() tmp_sources=() +local body="$1" existing="$2" context symbols instance_methods sources context="${existing}${existing:+$'\n'}${body}" symbols="$(printf '%s' "$body" | grep -Eo '(SendbirdChat|SendBirdCall|SendbirdCalls|AIAgentMessenger|SendbirdUIKit|SendbirdLive|SendbirdDesk|SendBirdDesk|MessengerLauncher|GroupChannel|BaseMessage|SBU[A-Z][A-Za-z0-9_]*|SBA[A-Z][A-Za-z0-9_]*|SBDSK[A-Za-z0-9_]*)(\.[A-Za-z_][A-Za-z0-9_]*)?' | sort -u || true)" if printf '%s' "$context" | grep -Eq '@sendbird/|sendbird-(calls|desk)|Sendbird(Chat|UIKit|Calls|Live|Desk)|AIAgentMessenger'; then @@ -31,37 +22,10 @@ fi [ -n "$symbols" ] || return 0 sources="$(printf '%s' "$context" | grep -Eo 'source:[[:space:]]*[^)`[:space:]]+' | sed -E 's/^source:[[:space:]]*//' | sort -u || true)" -while IFS= read -r source; do - [ -n "$source" ] || continue - case "$source" in - knowledge/curated/*) - resolved_sources+=("${CLAUDE_PLUGIN_ROOT:-.}/$source") ;; - .sendbird-client/cache/*) - resolved_sources+=("${cwd:-$(pwd)}/$source") ;; - *.swiftinterface|*.d.ts) - resolved_sources+=("$source") ;; - https://sendbird.com/docs/*|https://github.com/sendbird/*) - tmp_source="$(mktemp)" - if curl -fsSL --max-time 8 "$source" -o "$tmp_source" 2>/dev/null; then - resolved_sources+=("$tmp_source") - tmp_sources+=("$tmp_source") - else - rm -f "$tmp_source" - fi - ;; - esac -done <<< "$sources" - -valid=1 -while IFS= read -r symbol; do - supported=0 - for source_file in ${resolved_sources[@]+"${resolved_sources[@]}"}; do - if source_supports_symbol "$source_file" "$symbol"; then supported=1; break; fi - done - [ "$supported" -eq 1 ] || { valid=0; break; } -done <<< "$symbols" -for tmp_source in ${tmp_sources[@]+"${tmp_sources[@]}"}; do rm -f "$tmp_source"; done -[ "$valid" -eq 1 ] +# Plugin files, the plugin's SDK cache, installed SDK interfaces, and public Sendbird pages +# (hooks/lib/hook-helpers.sh resolve_cited_sources); a file the model wrote in the app does not count. +resolve_cited_sources "$cwd" <<< "$sources" +all_symbols_sourced "$symbols" } # existing_text : the file's current content; a relative path resolves from the session cwd @@ -76,7 +40,7 @@ deny() { jq -n '{hookSpecificOutput:{ hookEventName:"PreToolUse", permissionDecision:"deny", - permissionDecisionReason:"Sendbird API code requires a concrete source comment whose file or public URL contains the emitted symbol. Preserve the template source comment or cite knowledge/curated, the customer SDK cache, a version-matched public source, or stop if unverifiable." + permissionDecisionReason:"Sendbird API code requires a concrete source comment whose file or public URL contains the emitted symbol. Preserve the template source comment or cite knowledge/curated, the customer SDK cache or installed SDK files (node_modules/@sendbird, Pods, .build, SourcePackages, DerivedData), a version-matched sendbird.com/docs page or a file in a public sendbird/* repo (a /blob/ or /raw/ link, not an issue or discussion), or stop if unverifiable." }}' exit 0 } diff --git a/plugins/sendbird-client/hooks/welcome.sh b/plugins/sendbird-client/hooks/welcome.sh index 43c105b..96c6510 100755 --- a/plugins/sendbird-client/hooks/welcome.sh +++ b/plugins/sendbird-client/hooks/welcome.sh @@ -3,6 +3,10 @@ # it is the plugin's ALWAYS-ON policy, active even when no skill is invoked. set -euo pipefail ROOT="${CLAUDE_PLUGIN_ROOT:-$(cd "$(dirname "$0")/.." && pwd)}" +# shellcheck source=lib/hook-helpers.sh +source "$(cd "$(dirname "$0")" && pwd)/lib/hook-helpers.sh" +# Without jq the guards cannot read their input and ask the user about every call instead. +command -v jq >/dev/null 2>&1 || echo "WARNING: jq is not installed, so the Sendbird plugin safety checks cannot run and will ask for confirmation before every file write and shell command. Install jq to turn them back on." # Products this release does not support yet (config .productScope.notYetSupported). The rule is # built from the config so that removing a product there is the whole change that turns it back on. CONFIG="$ROOT/config/plugin-config.json" @@ -38,11 +42,10 @@ ALWAYS-ON rules for ANY Sendbird answer (even without a skill): - Never state pricing/quota figures or "latest" version numbers from memory; tokens are secrets — never hard-code or log them. EOF # Non-interactive runs (claude -p, CI, scripts): the caller cannot answer a question mid-run. -case "${SENDBIRD_NONINTERACTIVE:-}" in - 1|true|TRUE|yes) +if is_noninteractive; then cat < code` before delegating. Resolve the active product scope with `bash "${CLAUDE_PLUGIN_ROOT}/tools/detection/resolve-products.sh" ` and run `resolve-products.sh --check calls` before anything else. If it reports `product not supported yet: calls`, tell the customer that Sendbird Calls is not supported yet in this plugin, change nothing, and stop; in a non-interactive run, end with status `declined` and that reason. If Calls is outside the configured scope, say so and stop. diff --git a/plugins/sendbird-client/skills/diagnose-channel/SKILL.md b/plugins/sendbird-client/skills/diagnose-channel/SKILL.md index ae97400..1849fa9 100644 --- a/plugins/sendbird-client/skills/diagnose-channel/SKILL.md +++ b/plugins/sendbird-client/skills/diagnose-channel/SKILL.md @@ -7,7 +7,7 @@ allowed-tools: Read, Bash, Grep, Glob, WebFetch, Agent # /sendbird-client:diagnose-channel -Resolve every plugin-owned path below from `${CLAUDE_PLUGIN_ROOT}`. +Resolve every plugin-owned path below from `${CLAUDE_PLUGIN_ROOT}`. Where that variable is empty (Codex does not set it for shell commands), the plugin root is the folder two levels above this SKILL.md. Resolve the platform agent with `bash "${CLAUDE_PLUGIN_ROOT}/tools/routing/route-agent.sh" code` before delegating a fix. Read-first diagnosis. The skill finds the cause in the customer's code; it changes code only after the customer confirms, through the platform agent. diff --git a/plugins/sendbird-client/skills/fix-build/SKILL.md b/plugins/sendbird-client/skills/fix-build/SKILL.md index a514655..59eeb46 100644 --- a/plugins/sendbird-client/skills/fix-build/SKILL.md +++ b/plugins/sendbird-client/skills/fix-build/SKILL.md @@ -7,7 +7,7 @@ allowed-tools: Read, Edit, Bash, Grep, Glob, WebFetch, Agent # /sendbird-client:fix-build -Resolve every plugin-owned path below from `${CLAUDE_PLUGIN_ROOT}`. +Resolve every plugin-owned path below from `${CLAUDE_PLUGIN_ROOT}`. Where that variable is empty (Codex does not set it for shell commands), the plugin root is the folder two levels above this SKILL.md. Resolve the platform agent with `bash "${CLAUDE_PLUGIN_ROOT}/tools/routing/route-agent.sh" code` before delegating a fix. Works from the error text the customer pasted (or a log file they point to). It does not run a build unless the customer explicitly asks for one in this request. diff --git a/plugins/sendbird-client/skills/permissions-setup/SKILL.md b/plugins/sendbird-client/skills/permissions-setup/SKILL.md index 19187ba..bfaeea0 100644 --- a/plugins/sendbird-client/skills/permissions-setup/SKILL.md +++ b/plugins/sendbird-client/skills/permissions-setup/SKILL.md @@ -7,7 +7,7 @@ allowed-tools: Read, Edit, Write, Bash, Grep, Glob, WebFetch, Agent # /sendbird-client:permissions-setup -Resolve every plugin-owned path below from `${CLAUDE_PLUGIN_ROOT}`. +Resolve every plugin-owned path below from `${CLAUDE_PLUGIN_ROOT}`. Where that variable is empty (Codex does not set it for shell commands), the plugin root is the folder two levels above this SKILL.md. Resolve the platform agent with `bash "${CLAUDE_PLUGIN_ROOT}/tools/routing/route-agent.sh" code` before delegating. Resolve the active product scope with `bash "${CLAUDE_PLUGIN_ROOT}/tools/detection/resolve-products.sh" ` and decline out-of-scope products. diff --git a/plugins/sendbird-client/skills/start-chat/SKILL.md b/plugins/sendbird-client/skills/start-chat/SKILL.md index f184e92..2e14257 100644 --- a/plugins/sendbird-client/skills/start-chat/SKILL.md +++ b/plugins/sendbird-client/skills/start-chat/SKILL.md @@ -7,7 +7,7 @@ allowed-tools: Read, Edit, Write, Bash, Grep, Glob, WebFetch, Agent # /sendbird-client:start-chat -Resolve every plugin-owned path below from `${CLAUDE_PLUGIN_ROOT}`. +Resolve every plugin-owned path below from `${CLAUDE_PLUGIN_ROOT}`. Where that variable is empty (Codex does not set it for shell commands), the plugin root is the folder two levels above this SKILL.md. Resolve the platform agent with `bash "${CLAUDE_PLUGIN_ROOT}/tools/routing/route-agent.sh" code` before delegating. Resolve the active product scope with `bash "${CLAUDE_PLUGIN_ROOT}/tools/detection/resolve-products.sh" ` and decline out-of-scope products. This skill needs Chat and UIKit. diff --git a/plugins/sendbird-client/templates/ios/swiftui/calls/CallsSession.swift b/plugins/sendbird-client/templates/ios/swiftui/calls/CallsSession.swift index a60e214..e5bd384 100644 --- a/plugins/sendbird-client/templates/ios/swiftui/calls/CallsSession.swift +++ b/plugins/sendbird-client/templates/ios/swiftui/calls/CallsSession.swift @@ -1,4 +1,4 @@ -// source: https://github.com/sendbird/sendbird-calls-ios (README "Receive a call", "Make a call", and +// source: https://github.com/sendbird/sendbird-calls-ios/blob/1.12.3/README.md (README "Receive a call", "Make a call", and // "Callback and delegate thread handling", verified 2026-09-30) // + SendBirdCalls.swiftinterface 1.12.3 (verified 2026-09-30): SendBirdCall.configure(appId:) line 858, // addDelegate(_:identifier:) line 863, authenticate(with:completionHandler:) line 877, diff --git a/plugins/sendbird-client/templates/ios/uikit/calls/SetupCalls.swift b/plugins/sendbird-client/templates/ios/uikit/calls/SetupCalls.swift index b30bc0b..c3c07fe 100644 --- a/plugins/sendbird-client/templates/ios/uikit/calls/SetupCalls.swift +++ b/plugins/sendbird-client/templates/ios/uikit/calls/SetupCalls.swift @@ -1,4 +1,4 @@ -// source: https://github.com/sendbird/sendbird-calls-ios (README implementation guide, verified 2026-06-09) +// source: https://github.com/sendbird/sendbird-calls-ios/blob/1.12.3/README.md (README implementation guide, verified 2026-06-09) // Build-verified: SendBirdCall.configure / AuthenticateParams / authenticate / DialParams / // CallOptions / dial compile + link against SendBirdCalls (xcodebuild BUILD SUCCEEDED for // generic/platform=iOS, 2026-06-09; the binary framework's simulator slice has an arch limit diff --git a/plugins/sendbird-client/templates/ios/uikit/uikit/SetupUIKit.swift b/plugins/sendbird-client/templates/ios/uikit/uikit/SetupUIKit.swift index 1656b96..a4b3163 100644 --- a/plugins/sendbird-client/templates/ios/uikit/uikit/SetupUIKit.swift +++ b/plugins/sendbird-client/templates/ios/uikit/uikit/SetupUIKit.swift @@ -1,4 +1,4 @@ -// source: https://github.com/sendbird/sendbird-uikit-ios (README quickstart, verified 2026-06-09) +// source: https://github.com/sendbird/sendbird-uikit-ios/blob/3.36.2/README.md (README quickstart, verified 2026-06-09) // source: https://github.com/sendbird/sendbird-uikit-ios/blob/3.36.1/Sources/SBUGlobals.swift#L22-L26 (accessToken, currentUser) // source: https://github.com/sendbird/sendbird-uikit-ios/blob/3.36.1/Sources/Theme/SBUTheme.swift#L252 (channelTheme) // Build-verified: SendbirdUI.initialize / SBUGlobals.currentUser / SBUUser / diff --git a/plugins/sendbird-client/templates/js/react-native/calls/setup.ts b/plugins/sendbird-client/templates/js/react-native/calls/setup.ts index 1847bc9..7ef04d2 100644 --- a/plugins/sendbird-client/templates/js/react-native/calls/setup.ts +++ b/plugins/sendbird-client/templates/js/react-native/calls/setup.ts @@ -1,4 +1,4 @@ -// source: https://github.com/sendbird/sendbird-calls-sdk-react-native (README, verified 2026-06-09) +// source: https://github.com/sendbird/sendbird-calls-sdk-react-native/blob/v1.2.0/README.md (README, verified 2026-06-09) // Symbols quoted from the RN quickstart; full RN tsc not run in-repo (needs a react-native env). // App ID/user from env; tokens are secrets. diff --git a/plugins/sendbird-client/templates/js/react/calls/setup.ts b/plugins/sendbird-client/templates/js/react/calls/setup.ts index 80c736c..497a499 100644 --- a/plugins/sendbird-client/templates/js/react/calls/setup.ts +++ b/plugins/sendbird-client/templates/js/react/calls/setup.ts @@ -1,4 +1,4 @@ -// source: https://github.com/sendbird/sendbird-calls-javascript (README implementation guide, verified 2026-06-09) +// source: https://github.com/sendbird/sendbird-calls-javascript/blob/1.10.21/README.md (README implementation guide, verified 2026-06-09) // Type-checked against sendbird-calls (tsc --noEmit clean). App ID/user from env; tokens are secrets. // Needs esModuleInterop=true for the default import (else: import * as SendBirdCall from 'sendbird-calls'). diff --git a/plugins/sendbird-client/tools/detection/common/detect-existing-integration.sh b/plugins/sendbird-client/tools/detection/common/detect-existing-integration.sh index 3b1804b..c35e6a8 100644 --- a/plugins/sendbird-client/tools/detection/common/detect-existing-integration.sh +++ b/plugins/sendbird-client/tools/detection/common/detect-existing-integration.sh @@ -1,8 +1,13 @@ #!/usr/bin/env bash # Detect an existing Sendbird integration + resolved version. # Prints: present= version= +# Looks at, in order: SwiftPM Package.resolved, Podfile.lock, package-lock.json, yarn.lock +# (v1 and berry), pnpm-lock.yaml, then Gradle build files and the version catalog. set -euo pipefail dir="${1:?usage}" +HERE="$(cd "$(dirname "$0")" && pwd)" +# shellcheck source=../lib/detect-helpers.sh +source "$HERE/../lib/detect-helpers.sh" ver="unknown"; present="false" res="$(find "$dir" -name Package.resolved -not -path '*/.git/*' 2>/dev/null | head -1)" if [ -n "$res" ]; then @@ -20,4 +25,35 @@ if [ "$present" = "false" ] && [ -f "$dir/package-lock.json" ]; then v="$(jq -r '[(.packages // {}) | to_entries[] | select(.key | test("@sendbird/")) | .value.version] | map(select(.!=null)) | .[0] // empty' "$dir/package-lock.json" 2>/dev/null)" [ -n "$v" ] && { present="true"; ver="$v"; } fi +# yarn.lock: an entry header names the package ("@sendbird/chat@^4.9.0": in v1, +# "@sendbird/chat@npm:^4.9.0": in berry) and its indented block has the resolved version +# (`version "4.9.2"` in v1, `version: 4.9.2` in berry). +if [ "$present" = "false" ] && [ -f "$dir/yarn.lock" ]; then + v="$(awk ' + /^[^[:space:]#]/ { in_pkg = (index($0, "@sendbird/") > 0); next } + in_pkg && /^[[:space:]]+version:?[[:space:]]/ { + v = $0; sub(/^[[:space:]]+version:?[[:space:]]+/, "", v); gsub(/"/, "", v) + if (v ~ /^[0-9]+\.[0-9]+\.[0-9]+/) { print v; exit } + }' "$dir/yarn.lock" 2>/dev/null || true)" + [ -n "$v" ] && { present="true"; ver="$v"; } +fi +# pnpm-lock.yaml: package keys carry the resolved version: /@sendbird/chat@4.9.2: (v6), +# /@sendbird/chat/4.9.2: (v5), '@sendbird/chat@4.9.2': (v9), with an optional peer suffix. +if [ "$present" = "false" ] && [ -f "$dir/pnpm-lock.yaml" ]; then + v="$(grep -oE '@sendbird/[A-Za-z0-9._-]+[@/][0-9]+\.[0-9]+\.[0-9]+' "$dir/pnpm-lock.yaml" 2>/dev/null \ + | head -1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+$' || true)" + [ -n "$v" ] && { present="true"; ver="$v"; } +fi +# Gradle: a declared com.sendbird.sdk dependency means the integration is present, even when +# its version is dynamic (3.+) or a variable; the version is reported only when it is exact. +# Prefer the Chat SDK's version, then the first exact one. +if [ "$present" = "false" ]; then + deps="$(gradle_sendbird_deps "$dir")" + if [ -n "$deps" ]; then + present="true" + v="$(printf '%s\n' "$deps" | awk '$1 == "sendbird-chat" && $2 != "unknown" { print $2; exit }')" + [ -n "$v" ] || v="$(printf '%s\n' "$deps" | awk '$2 != "unknown" { print $2; exit }')" + [ -n "$v" ] && ver="$v" + fi +fi echo "present=$present version=$ver" diff --git a/plugins/sendbird-client/tools/detection/common/detect-products.sh b/plugins/sendbird-client/tools/detection/common/detect-products.sh index fdbe52b..b3febcd 100644 --- a/plugins/sendbird-client/tools/detection/common/detect-products.sh +++ b/plugins/sendbird-client/tools/detection/common/detect-products.sh @@ -6,8 +6,10 @@ dir="${1:?usage}" HERE="$(cd "$(dirname "$0")" && pwd)" # shellcheck source=../lib/detect-helpers.sh source "$HERE/../lib/detect-helpers.sh" -declare -A found -mark() { found["$1"]=1; } +# Bash 3.2 (stock macOS /bin/bash) has no associative arrays: collect the names in a +# space-separated string and remove duplicates with sort -u at the end. +found="" +mark() { found="$found $1"; } if [ -f "$dir/package.json" ]; then pkgjson_has_dep "$dir" "@sendbird/chat" && mark chat { pkgjson_has_dep "$dir" "@sendbird/uikit-react" || pkgjson_has_dep "$dir" "@sendbird/uikit-react-native"; } && mark uikit @@ -19,14 +21,31 @@ if [ -f "$dir/package.json" ]; then fi file_contains "$dir" "*.swift" 'import[[:space:]]+SendbirdChatSDK' && mark chat file_contains "$dir" "*.swift" 'import[[:space:]]+(SendbirdUIKit|SendbirdSwiftUI)' && mark uikit -file_contains "$dir" "*.swift" 'import[[:space:]]+SendbirdCalls' && mark calls +# Calls and Desk modules spell the brand with a capital B (knowledge/curated/ios/products/calls.md, +# desk.md); accept both spellings. +file_contains "$dir" "*.swift" 'import[[:space:]]+Send[Bb]irdCalls' && mark calls file_contains "$dir" "*.swift" 'import[[:space:]]+SendbirdAIAgent' && mark ai-agent -file_contains "$dir" "*.swift" 'import[[:space:]]+SendbirdDesk' && mark desk +file_contains "$dir" "*.swift" 'import[[:space:]]+Send[Bb]irdDesk' && mark desk file_contains "$dir" "*.swift" 'import[[:space:]]+SendbirdLive' && mark live { has_glob "$dir" "Podfile" && file_contains "$dir" "Podfile" "pod[[:space:]]+'SendbirdUIKit'"; } && mark uikit { has_glob "$dir" "Podfile" && file_contains "$dir" "Podfile" "pod[[:space:]]+'SendbirdChat"; } && mark chat -file_contains "$dir" "*.gradle*" 'com\.sendbird\.sdk:uikit|com\.sendbird:uikit' && mark uikit -file_contains "$dir" "*.kt" 'com\.sendbird\.android' && mark chat -file_contains "$dir" "*.kt" 'com\.sendbird\.calls' && mark calls -out="$(printf '%s\n' "${!found[@]}" | sort | paste -sd, -)" +# Android: Gradle build files and the version catalog (gradle/libs.versions.toml), in the +# "com.sendbird.sdk:" form or as group = "com.sendbird.sdk", name = "". +# Artifacts from knowledge/curated/android/setup.md "Packaging (Gradle)" and hosts/compose.md. +while IFS= read -r artifact; do + case "$artifact" in + sendbird-chat) mark chat;; uikit|uikit-compose) mark uikit;; ai-agent-messenger) mark ai-agent;; + sendbird-calls) mark calls;; sendbird-desk-android-sdk) mark desk;; sendbird-live) mark live;; + esac +done < <(gradle_sendbird_artifacts "$dir") +file_contains "$dir" "*.gradle*" 'com\.sendbird:uikit' && mark uikit +# Kotlin and Java sources: package names from the imports in knowledge/curated/android. +for src in "*.kt" "*.java"; do + file_contains "$dir" "$src" 'com\.sendbird\.android' && mark chat + file_contains "$dir" "$src" 'com\.sendbird\.uikit' && mark uikit + file_contains "$dir" "$src" 'com\.sendbird\.sdk\.aiagent' && mark ai-agent + file_contains "$dir" "$src" 'com\.sendbird\.calls' && mark calls + file_contains "$dir" "$src" 'com\.sendbird\.live' && mark live +done +out="$(printf '%s\n' $found | sort -u | paste -sd, -)" [ -n "$out" ] && echo "$out" || echo "unknown" diff --git a/plugins/sendbird-client/tools/detection/lib/detect-helpers.sh b/plugins/sendbird-client/tools/detection/lib/detect-helpers.sh index 11c226b..c57b309 100644 --- a/plugins/sendbird-client/tools/detection/lib/detect-helpers.sh +++ b/plugins/sendbird-client/tools/detection/lib/detect-helpers.sh @@ -27,5 +27,49 @@ pkgjson_has_dep() { jq -e --arg d "$dep" '((.dependencies // {}) + (.devDependencies // {})) | has($d)' "$pj" >/dev/null 2>&1 } +# gradle_files : Gradle build scripts and version catalogs (gradle/libs.versions.toml) +gradle_files() { + find "$1" -type f \( -name '*.gradle' -o -name '*.gradle.kts' -o -name '*.versions.toml' \) \ + -not -path '*/node_modules/*' -not -path '*/.git/*' -not -path '*/build/*' 2>/dev/null +} + +# gradle_sendbird_deps : every com.sendbird.sdk dependency in the Gradle files, one per line +# as " ". Handles "com.sendbird.sdk:[:]" and +# group = "com.sendbird.sdk", name = "". The version is the literal x.y.z, or in a +# version catalog the [versions] entry that version.ref names; anything else (3.+, a Gradle +# variable) is "unknown". +gradle_sendbird_deps() { + gradle_files "$1" | while IFS= read -r f; do + awk ' + /^[[:space:]]*\[/ { sect = $0; gsub(/[][[:space:]]/, "", sect) } + sect == "versions" && /=/ { + k = $0; sub(/[[:space:]]*=.*/, "", k); gsub(/[[:space:]"]/, "", k) + v = $0; sub(/^[^=]*=[[:space:]]*/, "", v); gsub(/[[:space:]"]/, "", v); vers[k] = v + } + { lines[++n] = $0 } + END { + for (i = 1; i <= n; i++) { + l = lines[i]; a = ""; v = "" + if (match(l, /com\.sendbird\.sdk:[A-Za-z0-9._-]+(:[A-Za-z0-9.+_-]+)?/)) { + c = substr(l, RSTART + 17, RLENGTH - 17); p = index(c, ":") + if (p) { a = substr(c, 1, p - 1); v = substr(c, p + 1) } else a = c + } else if (l ~ /group[[:space:]]*=[[:space:]]*"com\.sendbird\.sdk"/ && match(l, /name[[:space:]]*=[[:space:]]*"[^"]+"/)) { + a = substr(l, RSTART, RLENGTH); sub(/^name[[:space:]]*=[[:space:]]*"/, "", a); sub(/"$/, "", a) + } else continue + if (v == "" && match(l, /version\.ref[[:space:]]*=[[:space:]]*"[^"]+"/)) { + r = substr(l, RSTART, RLENGTH); sub(/^version\.ref[[:space:]]*=[[:space:]]*"/, "", r); sub(/"$/, "", r); v = vers[r] + } else if (v == "" && match(l, /version[[:space:]]*=[[:space:]]*"[^"]+"/)) { + v = substr(l, RSTART, RLENGTH); sub(/^version[[:space:]]*=[[:space:]]*"/, "", v); sub(/"$/, "", v) + } + if (v !~ /^[0-9]+\.[0-9]+\.[0-9]+$/) v = "unknown" + print a, v + } + }' "$f" + done +} + +# gradle_sendbird_artifacts : the artifact names gradle_sendbird_deps finds +gradle_sendbird_artifacts() { gradle_sendbird_deps "$1" | cut -d' ' -f1 | sort -u; } + # json_escape : escape for embedding in JSON value json_escape() { printf '%s' "$1" | jq -Rs .; } diff --git a/plugins/sendbird-client/tools/local-sdk/read-surface.sh b/plugins/sendbird-client/tools/local-sdk/read-surface.sh index e3517d6..dcb383b 100755 --- a/plugins/sendbird-client/tools/local-sdk/read-surface.sh +++ b/plugins/sendbird-client/tools/local-sdk/read-surface.sh @@ -42,9 +42,16 @@ case "$plat" in # Module names verified in the public SPM packages (sendbird-chat-sdk-ios, # sendbird-uikit-ios-spm, sendbird-live-sdk-ios). Match on `.swiftmodule/`, # never on the whole path: a project folder named `uikit-demo` must not turn the - # Chat interface into a UIKit candidate. + # Chat interface into a UIKit candidate. AI Agent, Desk, and Calls names come from the + # curated install sections (knowledge/curated/ios/products/ai-agent.md and desk.md + # "Install (SPM)", calls.md "Install (SPM only)"). Since 1.23.0 the AI Agent Messenger + # module is built from source and its public API ships in the SendbirdAIAgentCore binary, + # so either name counts; `|` separates names. case "$product" in - chat) module="SendbirdChatSDK";; uikit) module="SendbirdUIKit";; live) module="SendbirdLiveSDK";; *) module="";; + chat) module="SendbirdChatSDK";; uikit) module="SendbirdUIKit";; live) module="SendbirdLiveSDK";; + ai-agent) module="SendbirdAIAgentCore|SendbirdAIAgentMessenger";; + desk) module="SendBirdDesk";; calls) module="SendBirdCalls";; + *) module="";; esac # Where an installed xcframework lives: CocoaPods (Pods/), SwiftPM CLI # (.build/artifacts), and Xcode's SPM cache (DerivedData/-/ @@ -77,7 +84,7 @@ case "$plat" in n = split($2, parts, "/"); sm = "" for (k = n; k >= 1; k--) if (parts[k] ~ /\.swiftmodule$/) { sm = parts[k]; break } sub(/\.swiftmodule$/, "", sm) - if (mod != "" ? sm != mod : index(tolower(sm), tolower(prod)) == 0) next + if (mod != "" ? index("|" mod "|", "|" sm "|") == 0 : index(tolower(sm), tolower(prod)) == 0) next r = 4 if ($2 ~ /\/ios-arm64\/.*\/arm64-apple-ios\.swiftinterface$/) r = 0 else if ($2 ~ /-apple-ios\.swiftinterface$/) r = 1