ClaudeMods
☰
ZH-CN
● 0 人在线 · 浏览 0 次
赞助提交作品
GitHub 仓库 · 发布者 NotTahaAli

sessclone

将 token、模型和花费使用量报告给 SessClone 部署的 Claude Code 插件,提供状态栏、斜杠命令和可选择启用的转录上传。

NotTahaAli@NotTahaAli

NotTahaAli/sessclone/tree/main/packages/plugin

已翻译

关于这个 mod

SessClone Collector 会将 Claude Code 的使用情况(token、模型、成本输入和耗时)报告给 SessClone 部署,让个人和组织能够按人员、Project、Device 和 Session 查看花费。它包含 hooks(SessionStart、Stop、StopFailure、SessionEnd)、状态栏行,以及 /sessclone-status 和 /sessclone-sync 命令;mod 还提供 /sessclone:status 和 /sessclone:sync 作为后备。每轮只通过 HTTPS 发送带 bearer key 的元数据;除非启用可选择的转录上传,否则不会发送提示、回复或文件内容。需要 Node 22.18+(或 23.6+、24)。采用 MIT 授权。

安装

请先查看作者 README 确认 marketplace 和插件名称;命令可能随仓库结构改变。

claude plugin marketplace add NotTahaAli/sessclone
claude plugin install sessclone
原文 / README

sessclone

The SessClone Collector. It reports your Claude Code usage (tokens, models, cost inputs, timings) to a SessClone deployment, so you and your Org can see spend per person, Project, Device and Session on the dashboard.

Install

/plugin marketplace add NotTahaAli/sessclone
/plugin install sessclone@sessclone

Claude Code asks for two things, both optional:

  • API key: create one in the dashboard under Keys. It is shown once and kept in Claude Code's secure credential store, not in settings.json. Leave it empty in a Claude Code cloud environment whose SessClone API credential adds it.
  • Deployment URL: leave it empty for the hosted service at https://sessclone.com. Self-hosted deployments enter their own address.

Restart Claude Code. The next session says whether it connected, and which Org it reports to. Turns from before the install are backfilled from the transcripts Claude Code still keeps.

Requires Node 22.18 or newer (or 23.6+, or 24).

Commands and the status bar

  • /sessclone-status shows what the last session start found: the deployment, the key's first three characters and length, whether it was accepted and for which Org, plus this Device, how many of this session's Turns are not sent yet, what is waiting to send and the last push.
  • /sessclone-sync sends everything waiting now, without a Claude turn, and says what it sent.
  • A line above the prompt shows whether the key is connected, whether this session is synced or how many Turns it is behind, what is queued, and ↗, which opens this session in the dashboard.

These are the plugin's mod (hooks/register.tsx), which needs Claude Code 2.1.287 or newer. Where mods cannot load, /sessclone:status and /sessclone:sync do the same, except that status leaves out this session's unsent Turns, and sync is carried out by the hook that ends that turn.

What it sends, and where

Everything goes over HTTPS to the deployment URL above, with your key as a bearer token, except the opt-in transcript upload described last.

  • Session start (SessionStart): GET /api/ingest to ask whether the key is accepted and for which Org. If it is not, the plugin says so and sends nothing else until a session starts with a key that is. Then it re-sends what an earlier session could not (POST /api/ingest).
  • Every turn (Stop): POST /api/ingest with, per Turn, the token counts by kind, the model, timings, the Session, Project and Device it belongs to, the working directory, the git branch, and the git remote reduced to a Project key. No prompt, no reply, no file contents.
  • Session events (StopFailure, SessionEnd): POST /api/ingest saying that a turn ended on an API error, or that a session ended.
  • Transcripts, only if you opt in: the raw session transcript, which does contain prompts and code, is uploaded only when your Member settings on the deployment turn transcript upload on. It is off by default. The plugin asks the deployment for an upload URL (POST /api/logs/presign), uploads the compressed transcript to that URL, which is the deployment's object storage (Supabase Storage for the hosted service), and confirms it (POST /api/logs/confirm). Your Org's retention removes it.

What it reads and runs locally

  • Claude Code's own transcripts under ~/.claude/projects/ (or CLAUDE_CONFIG_DIR), from a cursor, so each turn costs a few hundred bytes.
  • git in the session's working directory, to read the branch and remote.
  • A state directory for cursors, the retry queue, and the last key check (~/.local/state/sessclone, ~/Library/Application Support/sessclone, or %LOCALAPPDATA%\sessclone).
  • When HTTPS_PROXY is set, each hook restarts itself once under Node's own proxy support so its requests go through that proxy.

The API key is read only from the plugin's setup prompt, never from your shell environment, and never written to a log, a file or a transcript.

Settings

| Setting | Where | Default | | ------------------- | ----------------------------- | ------------------------ | | API key | setup prompt (api_key) | none, optional in cloud | | Deployment URL | setup prompt, SESSCLONE_URL | https://sessclone.com | | State directory | SESSCLONE_STATE_DIR | per platform, see above | | Device name | SESSCLONE_DEVICE | derived from the machine | | Print hook failures | SESSCLONE_DEBUG=1 | off |

To change an answer, run /plugin configure sessclone and start a new session.

Source and license

Readable source, no build step: the hooks in hooks/ run as node <file>.mjs and import the modules in src/. MIT licensed, see LICENSE. Project home and issues: https://github.com/NotTahaAli/sessclone

更多类似作品