Skip to content
This repository was archived by the owner on Aug 3, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .agents/plugins/marketplace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "superself",
"interface": {
"displayName": "Superself"
},
"plugins": [
{
"name": "superself",
"source": {
"source": "local",
"path": "./"
},
"policy": {
"installation": "AVAILABLE",
"authentication": "ON_INSTALL"
},
"category": "Productivity"
}
]
}
4 changes: 2 additions & 2 deletions .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "superself",
"version": "0.1.3",
"description": "Superself shared context, token-savings discipline, and usage collection for Claude Code"
"version": "0.2.0",
"description": "Superself shared context, working discipline, and usage collection"
}
44 changes: 44 additions & 0 deletions .codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "superself",
"version": "0.2.0",
"description": "Carry project context across Codex, ChatGPT, Claude, and other MCP clients.",
"author": {
"name": "Superfunction",
"email": "hello@fxy.global",
"url": "https://superselfs.com"
},
"homepage": "https://superselfs.com/install",
"repository": "https://github.com/spfn/plugin",
"keywords": [
"mcp",
"shared context",
"knowledge",
"usage"
],
"mcpServers": {
"superself": {
"type": "http",
"url": "https://superself-dev.us.spfn.app/mcp"
}
},
"interface": {
"displayName": "Superself",
"shortDescription": "Shared context across AI sessions",
"longDescription": "Open Superself sessions from Codex, recall project knowledge, preserve decisions, and collect token usage without uploading conversation content.",
"developerName": "Superfunction",
"category": "Productivity",
"capabilities": [
"Read",
"Write"
],
"websiteURL": "https://superselfs.com",
"privacyPolicyURL": "https://superselfs.com/privacy",
"termsOfServiceURL": "https://superselfs.com/terms",
"defaultPrompt": [
"Open a Superself session and load this project's context.",
"Find the relevant decision in Superself knowledge.",
"Save this decision to Superself shared context."
],
"brandColor": "#277A5A"
}
}
70 changes: 44 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,57 @@
# Superself plugin

A Claude Code plugin that connects your agent to Superself: shared project
context carried across sessions, a token-savings discipline nudged at session
start, and lightweight usage collection so you can see what your sessions
cost. Install by pointing your agent at our install guide —
**https://superselfs.com/install** — and it will walk itself through the
marketplace add, plugin install, and OAuth connection steps.
Superself connects Claude Code, Codex, ChatGPT, and other MCP clients to the
same project context. The plugin bundles the MCP connection, a session-start
working discipline, and host-specific usage collectors.

## What the hooks send
## Install

This plugin ships two hooks:
Follow the dev guide at **https://superself-dev.us.spfn.app/install**.

- `superself-transcript-upload.sh` (Stop/SessionEnd) — uploads the raw local session transcript
(jsonl), but **only** for sessions you explicitly opened with the Superself
MCP tool `session_open` (a marker file records the upload target for that
session). If you never open a Superself session, this hook is a no-op.
- `superself-usage-collect.mjs` (SessionEnd) — reports token count deltas only (input/output/
cache read/cache creation, aggregated per model) for every session, once
you've registered a collector token via the `collector_register` MCP tool.
It never sends conversation content — just numbers.
Claude Code:

Both hooks fail silently (non-blocking) and never interrupt your session.
```sh
claude plugin marketplace add https://superselfs.com/marketplace.json
claude plugin install superself@superself
```

## Updating
Codex:

The session-start prompt is fetched from the Superself server on each session
(with the bundled copy as offline fallback), so prompt changes reach you
without a plugin update. Plugin updates are only needed when the hook scripts
themselves change — which is rare.
```sh
codex plugin marketplace add spfn/plugin --ref dev
codex plugin add superself@superself
codex mcp login superself
```

Claude Code doesn't auto-update third-party marketplaces by default. To pull
the latest version:
For ChatGPT developer mode, create an app whose MCP server URL is
`https://superself-dev.us.spfn.app/mcp`. The same endpoint can be used as a remote MCP
tool from the OpenAI Responses API when the caller supplies a Superself OAuth
access token.

```
## What the hooks send

- `superself-transcript-upload.sh` uploads Claude Code transcripts only for a
Superself session that explicitly enabled transcript upload. Without the
local session marker it is a no-op.
- `superself-usage-collect.mjs` reports Claude Code token-count deltas by model.
- `superself-codex-usage-collect.mjs` reports Codex token-count deltas by model.

Usage collectors never send conversation content. They read the host's local
transcript only to extract token counters and fail without interrupting the
session. The collector runs after a completed turn once `collector_register`
has stored a local write-only token.

## Updating

Claude Code:

```text
/plugin marketplace update superself
```

See the install guide for enabling automatic updates.
Codex:

```sh
codex plugin marketplace upgrade superself
codex plugin add superself@superself
```
17 changes: 2 additions & 15 deletions hooks/hooks.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,8 @@
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/superself-transcript-upload.sh"
}
]
}
],
"SessionEnd": [
{
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/superself-transcript-upload.sh"
},
{
"type": "command",
"command": "node ${CLAUDE_PLUGIN_ROOT}/hooks/superself-usage-collect.mjs"
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/stop.sh",
"timeout": 35
}
]
}
Expand Down
15 changes: 13 additions & 2 deletions hooks/session-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,25 @@
# 내용은 서버(GET /discipline)가 소유한다 — 서버 배포만으로 모든 사용자에게
# 갱신되고, 플러그인은 업데이트할 일이 없다. 서버에 못 닿으면(오프라인·타임아웃)
# 번들 사본으로 fallback — 훅이 세션 시작을 막는 일은 없어야 한다.
BASE="${SUPERSELF_MCP_URL:-https://superselfs.com/mcp}"
if [ -n "${PLUGIN_ROOT:-}" ]
then
DEFAULT_MCP_URL="https://superself-dev.us.spfn.app/mcp"
else
DEFAULT_MCP_URL="https://superselfs.com/mcp"
fi
BASE="${SUPERSELF_MCP_URL:-$DEFAULT_MCP_URL}"
BASE="${BASE%/mcp}"
ROOT="${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-}}"
if [ -z "$ROOT" ]
then
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
fi

# 부분 응답이 새어 나가지 않게 버퍼링 후 성공했을 때만 출력한다.
PROMPT="$(curl -fsS --max-time 2 "${BASE}/discipline" 2>/dev/null)"
if [ -n "$PROMPT" ]
then
printf '%s\n' "$PROMPT"
else
cat "${CLAUDE_PLUGIN_ROOT}/hooks/superself-discipline.md"
cat "${ROOT}/hooks/superself-discipline.md"
fi
28 changes: 28 additions & 0 deletions hooks/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
# Shared Stop hook. Codex and Claude expose different transcript formats, so
# keep the host-specific collectors separate and emit one valid hook result.
set -u

INPUT=$(cat)
ROOT="${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-}}"
if [ -z "$ROOT" ]
then
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
fi

# Codex exports PLUGIN_ROOT (and a Claude-compatible alias); Claude exports only
# CLAUDE_PLUGIN_ROOT.
if [ -n "${PLUGIN_ROOT:-}" ]
then
export SUPERSELF_MCP_URL="${SUPERSELF_MCP_URL:-https://superself-dev.us.spfn.app/mcp}"
printf '%s' "$INPUT" | node "$ROOT/hooks/superself-codex-usage-collect.mjs" >/dev/null
else
printf '%s' "$INPUT" | "$ROOT/hooks/superself-transcript-upload.sh" >/dev/null &
UPLOAD_PID=$!
printf '%s' "$INPUT" | node "$ROOT/hooks/superself-usage-collect.mjs" >/dev/null &
USAGE_PID=$!
wait "$UPLOAD_PID" "$USAGE_PID"
fi

printf '{}\n'
exit 0
Loading