superclawd 0.1.0

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.
package/LICENSE ADDED
@@ -0,0 +1,72 @@
1
+ SuperClawd CLI — End User License Agreement
2
+
3
+ Copyright (c) 2026 SharpComputing LLC. All rights reserved.
4
+
5
+ This License Agreement ("Agreement") governs your use of the "superclawd"
6
+ command-line interface and its accompanying files (the "Software"), published
7
+ by SharpComputing LLC ("Licensor"). "SuperClawd" is a product of SharpComputing
8
+ LLC. By installing, copying, or otherwise using the
9
+ Software, you agree to be bound by this Agreement. If you do not agree, do not
10
+ install or use the Software.
11
+
12
+ 1. License Grant
13
+ Subject to your compliance with this Agreement and the SuperClawd Terms of
14
+ Service (https://superclawd.com), Licensor grants you a personal,
15
+ non-exclusive, non-transferable, non-sublicensable, revocable license to
16
+ install and run the Software solely to access and use the SuperClawd service
17
+ with your own account and credentials.
18
+
19
+ 2. Restrictions
20
+ You may not, in whole or in part:
21
+ (a) copy, distribute, publish, sublicense, sell, rent, lease, or otherwise
22
+ make the Software available to any third party;
23
+ (b) modify, adapt, translate, or create derivative works of the Software;
24
+ (c) reverse engineer, decompile, disassemble, or otherwise attempt to derive
25
+ the source code or underlying ideas of the Software, except to the extent
26
+ this restriction is prohibited by applicable law;
27
+ (d) remove, alter, or obscure any proprietary notices (including copyright,
28
+ trademark, or this Agreement) in or on the Software;
29
+ (e) use the Software to build or assist in building a competing product or
30
+ service, or in any manner that violates applicable law or the SuperClawd
31
+ Terms of Service.
32
+
33
+ 3. Ownership
34
+ The Software is licensed, not sold. Licensor and its licensors retain all
35
+ right, title, and interest in and to the Software, including all intellectual
36
+ property rights. No rights are granted to you other than as expressly set
37
+ forth in this Agreement.
38
+
39
+ 4. Service and Fees
40
+ The Software is a client for the SuperClawd service. Access to that service
41
+ may require an account and the payment of fees, and is subject to the
42
+ SuperClawd Terms of Service and Privacy Policy. Licensor may modify, suspend,
43
+ or discontinue the service or the Software at any time.
44
+
45
+ 5. Termination
46
+ This Agreement is effective until terminated. It terminates automatically if
47
+ you breach any of its terms. Upon termination, you must cease all use of the
48
+ Software and destroy all copies in your possession or control. Sections 2
49
+ through 8 survive termination.
50
+
51
+ 6. Disclaimer of Warranty
52
+ THE SOFTWARE IS PROVIDED "AS IS" AND "AS AVAILABLE", WITHOUT WARRANTY OF ANY
53
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
54
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND
55
+ NON-INFRINGEMENT. YOU USE THE SOFTWARE AT YOUR OWN RISK.
56
+
57
+ 7. Limitation of Liability
58
+ TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT WILL LICENSOR BE LIABLE
59
+ FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES, OR
60
+ ANY LOSS OF PROFITS, REVENUE, DATA, OR GOODWILL, ARISING OUT OF OR RELATED TO
61
+ YOUR USE OF OR INABILITY TO USE THE SOFTWARE, WHETHER BASED ON WARRANTY,
62
+ CONTRACT, TORT, OR ANY OTHER LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY
63
+ OF SUCH DAMAGES.
64
+
65
+ 8. General
66
+ This Agreement constitutes the entire agreement between you and Licensor
67
+ regarding the Software and supersedes all prior or contemporaneous
68
+ understandings. If any provision is held unenforceable, the remaining
69
+ provisions will remain in full force and effect. Licensor's failure to
70
+ enforce any right or provision is not a waiver of that right or provision.
71
+
72
+ For licensing inquiries, contact support@superclawd.com.
package/README.md ADDED
@@ -0,0 +1,139 @@
1
+ # SuperClawd
2
+
3
+ **Give your Claude Code superpowers.** SuperClawd launches [Claude Code](https://claude.com/code) with your team's coding standards, skills, agents, commands, and workflows already loaded — so every session follows your rules automatically, no copy‑pasting context, no reminding the AI how your team works.
4
+
5
+ One command. Your standards, every session.
6
+
7
+ ```bash
8
+ npm install -g superclawd
9
+ superclawd configure # connect your workspace (one time)
10
+ superclawd # launch Claude Code, supercharged
11
+ ```
12
+
13
+ ---
14
+
15
+ ## What you get
16
+
17
+ - 🧠 **Your skills, on tap** — workspace skills and instructions load into every session and apply automatically when they're relevant.
18
+ - 🤖 **Your agents** — the specialized agents you've defined are available as Claude Code subagents.
19
+ - ⚡ **Commands & workflows** — your reusable commands and processes, ready to run.
20
+ - 📏 **Always‑on rules** — your foundational standards stay in effect for the whole session, even after `/clear` or a compaction.
21
+ - 🔔 **Notifications** — get pinged the moment Claude needs your input or finishes a task, so you can step away and come back at the right time.
22
+
23
+ You manage all of it from your dashboard at **[superclawd.com](https://superclawd.com)** — update a skill once and every teammate's next session picks it up.
24
+
25
+ ---
26
+
27
+ ## Requirements
28
+
29
+ - **[Claude Code](https://claude.com/code)** installed and available on your `PATH`
30
+ - **Node.js 20+**
31
+ - A **SuperClawd account and workspace** — sign up at **[superclawd.com](https://superclawd.com)**
32
+
33
+ ## Install
34
+
35
+ ```bash
36
+ npm install -g superclawd
37
+ ```
38
+
39
+ ## Set up (one time)
40
+
41
+ Grab your credentials from the dashboard under **Settings → Credentials** (a key ID, a secret, and your workspace slug), then run:
42
+
43
+ ```bash
44
+ superclawd configure
45
+ ```
46
+
47
+ It walks you through connecting your workspace and saves your credentials securely on your machine, so you only do this once.
48
+
49
+ ```bash
50
+ superclawd configure --show # show your current configuration
51
+ superclawd configure --reset # clear it and start over
52
+ ```
53
+
54
+ ## Use it
55
+
56
+ From any project directory, run:
57
+
58
+ ```bash
59
+ superclawd
60
+ ```
61
+
62
+ That launches Claude Code with your workspace's skills, agents, commands, workflows, and standards already loaded. Work as you normally would — SuperClawd applies the right context behind the scenes.
63
+
64
+ > Prefer plain Claude Code for a one‑off? Just run `claude` directly. `superclawd` is the supercharged way in.
65
+
66
+ ## Your default workspace
67
+
68
+ On more than one team or project? A single set of credentials works across **all** your workspaces. `superclawd switch` sets your **default workspace** — the one each `superclawd` launch boots into:
69
+
70
+ ```bash
71
+ superclawd switch
72
+ ```
73
+
74
+ Pick from your workspaces and you're set; your next `superclawd` launch uses it. No need to reconfigure.
75
+
76
+ Prefer to choose per launch? Turn on **Choose workspace at startup** in `superclawd config` — then every `superclawd` shows the picker first and boots into whatever you pick (just for that session; your default stays put).
77
+
78
+ ---
79
+
80
+ ## Options — `superclawd config`
81
+
82
+ Run `superclawd config` for an interactive menu (↑/↓ to move, **Space/Enter** to toggle, **Esc** to exit):
83
+
84
+ - **Notifications** — your default for new sessions: get pinged when Claude needs you or finishes.
85
+ - **Dangerously skip permissions** — launch Claude Code without approval prompts. Off by default; turn it on only if you understand the trade‑off.
86
+ - **Choose workspace at startup** — show the workspace picker each time you run `superclawd` and boot into the one you choose (per session; doesn't change your default). Off by default.
87
+
88
+ ### Notifications
89
+
90
+ Your default lives in `superclawd config`. Inside a session you can flip notifications for **just that session** without changing your default:
91
+
92
+ ```
93
+ /superclawd:notifications # flips on/off for this session
94
+ ```
95
+
96
+ ## Handy in‑session commands
97
+
98
+ Once Claude Code is running, these slash commands are always available:
99
+
100
+ | Command | What it does |
101
+ | --- | --- |
102
+ | `/superclawd:notifications` | Toggle notifications for the current session |
103
+ | `/superclawd:status` | Show service status, your workspace, and credit balance |
104
+ | `/superclawd:audit-work` | Check the work so far against your active standards |
105
+ | `/superclawd:ultrathink` | Apply maximum extended thinking to the task at hand |
106
+
107
+ ## Keep it up to date
108
+
109
+ ```bash
110
+ superclawd update
111
+ ```
112
+
113
+ ---
114
+
115
+ ## Command reference
116
+
117
+ | Command | Description |
118
+ | --- | --- |
119
+ | `superclawd` | Launch Claude Code with your workspace loaded |
120
+ | `superclawd configure` | Connect your workspace (interactive); `--show`, `--reset` |
121
+ | `superclawd switch` | Set your default workspace (pick from yours) |
122
+ | `superclawd config` | Toggle notifications + launch options |
123
+ | `superclawd update` | Update to the latest version |
124
+ | `superclawd version` | Print the installed version |
125
+ | `superclawd help` | Show help |
126
+
127
+ ---
128
+
129
+ ## Questions & feedback
130
+
131
+ Have a question, idea, or run into something? Join the conversation in **[GitHub Discussions](https://github.com/superclawd-ai/superclawd/discussions)** — we read every post.
132
+
133
+ - 📚 **Docs:** [docs.superclawd.com](https://docs.superclawd.com)
134
+ - 🌐 **Website:** [superclawd.com](https://superclawd.com)
135
+ - 💬 **Dashboard:** [app.superclawd.com](https://app.superclawd.com)
136
+
137
+ ## License
138
+
139
+ SEE LICENSE IN [LICENSE](./LICENSE)
@@ -0,0 +1,15 @@
1
+ import { createRequire as __cr } from 'module'; const require = __cr(import.meta.url);
2
+ import{readFileSync as m,writeFileSync as $,existsSync as F}from"node:fs";import{basename as Y}from"node:path";import{randomUUID as B}from"node:crypto";import{spawn as b}from"node:child_process";var R=`SUPERCLAWD \u2014 operating manual (always in effect):
3
+ - The ALWAYS rules below are ALREADY LOADED and active for this entire session.
4
+ Apply them directly to all work. Do NOT call any tool to fetch them \u2014 you
5
+ already have them in full.
6
+ - Separately, you have on-demand SuperClawd **skills** (each is a skill file
7
+ whose body carries a skillId). When one of those activates for the task, call
8
+ the \`get_directives\` tool with that file's skillId (a UUID) BEFORE acting,
9
+ and apply what it returns. Those skill files are pointers, not the rules.
10
+ - Only call \`get_directives\` with a UUID skillId taken from an activated skill
11
+ file. Never call it for the ALWAYS rules, and never pass a skill name.`;function D(t){let e=R,n=(t||"").trim();return n&&(e+=`
12
+
13
+ ALWAYS \u2014 foundational rules (already loaded & active for this whole session; apply directly, never fetch):
14
+ ${n}`),e}function k(t,e){return JSON.stringify({hookSpecificOutput:{hookEventName:t,additionalContext:D(e)}})}import{homedir as I}from"node:os";import{join as f}from"node:path";import{readFileSync as P,writeFileSync as re,mkdirSync as ie,chmodSync as ce,existsSync as ae}from"node:fs";var fe=(process.env.SUPERCLAWD_BACKEND||"real").toLowerCase();var pe=process.env.SUPERCLAWD_MCP_API_URL||"https://mcp-api.superclawd.com",_=process.env.SUPERCLAWD_HOME||f(I(),".superclawd"),W=f(_,"sessions"),L=f(_,"config.json");function T(t){if(!t||typeof t!="object")return{};let e=t,n=e.credentials??{...typeof e.keyId=="string"?{keyId:e.keyId}:{},...typeof e.secret=="string"?{secret:e.secret}:{},...typeof e.workspace=="string"?{workspace:e.workspace}:{}},o=e.preferences??{...typeof e.skipPermissions=="boolean"?{skipPermissions:e.skipPermissions}:{},...typeof e.notifications=="boolean"?{notifications:e.notifications}:{},...typeof e.chooseWorkspaceAtStartup=="boolean"?{chooseWorkspaceAtStartup:e.chooseWorkspaceAtStartup}:{}},s={};return Object.keys(n).length&&(s.credentials=n),Object.keys(o).length&&(s.preferences=o),s}function U(){try{return T(JSON.parse(P(L,"utf8")))}catch{return null}}function M(){return U()?.preferences?.notifications===!0}function j(t){return f(W,t)}function K(t){return f(t,"config.json")}function J(t){try{return JSON.parse(P(K(t),"utf8"))}catch{return null}}function d(t){let e=t?J(j(t)):null;return e&&typeof e.notifications=="boolean"?e.notifications:M()}var ue=1e3*60*60*24*3;var y=process.env.SUPERCLAWD_MCP_API_URL||"https://mcp-api.superclawd.com",S=(process.env.SUPERCLAWD_BACKEND||"real").toLowerCase(),p=process.env.MCP_KEY_ID||"",u=process.env.MCP_SECRET||"",l=process.env.MCP_WORKSPACE||"";function v(){return{"content-type":"application/json","x-mcp-key-id":p,"x-mcp-secret":u,"x-workspace-slug":l,"x-request-id":B()}}async function O(t,e){let n=new AbortController,o=setTimeout(()=>n.abort(),e);try{return await fetch(t,{headers:v(),signal:n.signal})}finally{clearTimeout(o)}}async function q(t,e="SessionStart"){let n="";if(t)try{n=m(t,"utf8")}catch{}if(S!=="mock"&&p&&u&&l)try{let o=await O(`${y}/api/prompt/foundational`,3e3);if(o.ok){let s=await o.json();typeof s.text=="string"&&(n=s.text)}}catch{}process.stdout.write(k(e,n))}async function G(){let t=()=>process.stdout.write(JSON.stringify({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"allow"}})),e=()=>process.stdout.write(JSON.stringify({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:"SuperClawd: out of credits. Top up at app.superclawd.com to load directives."}}));if(S==="mock"||!p||!u||!l)return void t();try{let n=await O(`${y}/api/prompt/balance`,2e3);if(!n.ok)return void t();let s=(await n.json()).content,r=(Array.isArray(s)?s.map(i=>i.text??"").join(""):"").match(/<current_balance>([\d.]+)<\/current_balance>/);return r&&Number(r[1])<=0?void e():void t()}catch{return void t()}}function g(){return new Promise(t=>{let e="";try{process.stdin.setEncoding("utf8"),process.stdin.on("data",n=>e+=n),process.stdin.on("end",()=>t(e)),process.stdin.on("error",()=>t(e)),setTimeout(()=>t(e),1500)}catch{t(e)}})}function H(t){if(!t||!F(t))return"";try{let e=m(t,"utf8").trim().split(`
15
+ `).filter(Boolean);for(let n=e.length-1;n>=0;n--){let o=JSON.parse(e[n]),s=o.message??o;if((s.role??o.type)==="assistant"){let r=s.content,i=Array.isArray(r)?r.map(c=>c.text??"").join(" "):typeof r=="string"?r:"";if(i.trim())return i.trim().slice(0,300)}}}catch{}return""}function z(t,e,n){if(!(!d(e??"")||S==="mock"||!p||!u||!l))try{let o=process.argv[1];if(!o)return;let s=Buffer.from(n,"utf8").toString("base64");b(process.execPath,[o,"notify-bg",t,e??"",s],{detached:!0,stdio:"ignore"}).unref()}catch{}}async function V(t,e,n){if(!d(e??"")||S==="mock"||!p||!u||!l)return;let o={};try{o=JSON.parse(n)}catch{}let s=Y(process.cwd()),a=t==="attention",r=a?o.message||"Claude needs your input":H(o.transcript_path)||"Session finished",i=`[${s}] ${r}`.slice(0,500),c=e||process.env.SUPERCLAWD_SESSION_ID||"",N={type:a?"attention_needed":"completion",summary:i,sms_summary:i.slice(0,110),x_session_request_id:c},w=()=>x(`${y}/api/prompt/notify-checkpoint`,4e3,{method:"POST",headers:{...v(),"x-session-request-id":c},body:JSON.stringify(N)});try{let h=await w();h.status===404&&c&&(await x(`${y}/api/prompt/inspector`,4e3,{method:"POST",headers:{...v(),"x-session-request-id":c},body:JSON.stringify({ide:!0,platform:"claude-code",llm_model:"claude",x_session_request_id:c,notify_on_checkpoint:!0,enable_session_files:!1})}).catch(()=>{}),h=await w())}catch{}}async function x(t,e,n){let o=new AbortController,s=setTimeout(()=>o.abort(),e);try{return await fetch(t,{...n,signal:o.signal})}finally{clearTimeout(s)}}function E(t,e,n){try{b(t,e,{detached:!0,stdio:"ignore",env:n??process.env}).unref()}catch{}}function A(t,e,n){if(process.platform==="darwin"){let o=n?`display notification m with title ${C(t)} subtitle ${C(n)} sound name "Glass"`:`display notification m with title ${C(t)} sound name "Glass"`;E("osascript",["-e","on run {m}","-e",o,"-e","end run",e]);return}process.platform!=="win32"&&E("notify-send",[t,e])}function C(t){return`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function X(t,e,n){if(d(n??"")){if(t==="attention"){let o="";try{o=JSON.parse(e).message??""}catch{}if(o.includes("waiting for your input"))return;A("Claude Code",o||"Claude needs you","Needs you");return}A("Claude Code","Done \u2014 your turn.")}}function Q(t,e){let n=Number(process.env.SUPERCLAWD_REMIND_EVERY??8);if(!Number.isFinite(n)||n<=0||!t||!e)return;let o=0;try{o=parseInt(m(e,"utf8").trim(),10)||0}catch{}o+=1;try{$(e,String(o))}catch{}if(o%n!==0)return;let s="";try{s=m(t,"utf8")}catch{return}s&&process.stdout.write(JSON.stringify({hookSpecificOutput:{hookEventName:"PostToolUse",additionalContext:s}}))}async function Z(){let t=process.argv[2];if(t==="gate")return await g(),G();if(t==="notify"){let e=process.argv[3],n=process.argv[4],o=await g();z(e,n,o);return}if(t==="notify-bg"){let e=process.argv[3],n=process.argv[4]||void 0,o=Buffer.from(process.argv[5]||"","base64").toString("utf8");return V(e,n,o)}if(t==="notify-local"){let e=process.argv[3],n=process.argv[4]||void 0,o=await g();X(e,o,n);return}if(t==="remind"){Q(process.argv[3],process.argv[4]);return}return await g(),q(process.argv[3],process.argv[4]||"SessionStart")}var ee=new Set(["gate","notify","notify-bg","notify-local","remind"]);Z().catch(()=>{let t=process.argv[2];ee.has(t)||process.stdout.write(k(process.argv[4]||"SessionStart",""))});
package/dist/index.js ADDED
@@ -0,0 +1,236 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __cr } from 'module'; const require = __cr(import.meta.url);
3
+ import{spawn as pt,spawnSync as mo}from"node:child_process";import{fileURLToPath as dt}from"node:url";import{existsSync as ft}from"node:fs";import{homedir as kt}from"node:os";import{join as j}from"node:path";import{readFileSync as Ct,writeFileSync as pe,mkdirSync as fe,chmodSync as yt,existsSync as me}from"node:fs";var Q=(process.env.SUPERCLAWD_BACKEND||"real").toLowerCase(),g=Q==="mock",P=process.env.SUPERCLAWD_MCP_API_URL||"https://mcp-api.superclawd.com",Z=process.env.SUPERCLAWD_HOME||j(kt(),".superclawd"),B=j(Z,"sessions"),W=j(Z,"config.json");function St(e){if(!e||typeof e!="object")return{};let t=e,o=t.credentials??{...typeof t.keyId=="string"?{keyId:t.keyId}:{},...typeof t.secret=="string"?{secret:t.secret}:{},...typeof t.workspace=="string"?{workspace:t.workspace}:{}},n=t.preferences??{...typeof t.skipPermissions=="boolean"?{skipPermissions:t.skipPermissions}:{},...typeof t.notifications=="boolean"?{notifications:t.notifications}:{},...typeof t.chooseWorkspaceAtStartup=="boolean"?{chooseWorkspaceAtStartup:t.chooseWorkspaceAtStartup}:{}},r={};return Object.keys(o).length&&(r.credentials=o),Object.keys(n).length&&(r.preferences=n),r}function x(){try{return St(JSON.parse(Ct(W,"utf8")))}catch{return null}}function I(e){fe(Z,{recursive:!0}),pe(W,`${JSON.stringify(e,null,2)}
4
+ `,{mode:384});try{yt(W,384)}catch{}}function ge(){return x()?.preferences?.skipPermissions===!0}function $t(){return x()?.preferences?.notifications===!0}function he(){return x()?.preferences?.chooseWorkspaceAtStartup===!0}function we(e){return j(e,"config.json")}function _t(e,t){try{fe(e,{recursive:!0}),pe(we(e),`${JSON.stringify(t,null,2)}
5
+ `)}catch{}}function ke(e,t){me(we(e))||_t(e,{notifications:$t(),...t?{workspace:t}:{}})}function Ce(){me(W)||I({credentials:{keyId:"",secret:"",workspace:""},preferences:{notifications:!1,skipPermissions:!1,chooseWorkspaceAtStartup:!1}})}var ye=1e3*60*60*24*3;function Se(){if(g)return{ok:!0,session:{keyId:process.env.MCP_KEY_ID||"mock-key",secret:process.env.MCP_SECRET||"mock-secret",workspace:process.env.MCP_WORKSPACE||"mock-workspace",apiUrl:P}};let e=x()?.credentials??{},t=process.env.MCP_KEY_ID||e.keyId,o=process.env.MCP_SECRET||e.secret,n=process.env.MCP_WORKSPACE||e.workspace;return!t||!o||!n?{ok:!1,error:"No SuperClawd credentials found. Run `superclawd configure`, or set MCP_KEY_ID / MCP_SECRET / MCP_WORKSPACE in your environment."}:{ok:!0,session:{keyId:t,secret:o,workspace:n,apiUrl:P}}}import{randomUUID as $e}from"node:crypto";function _e(e){return{"content-type":"application/json","x-mcp-key-id":e.keyId,"x-mcp-secret":e.secret,"x-workspace-slug":e.workspace,"x-request-id":$e()}}async function H(e,t){let o=await fetch(`${e.apiUrl}${t}`,{headers:_e(e)}),n=await o.json().catch(()=>null);return{status:o.status,ok:o.ok,body:n}}async function Y(e,t,o){try{let n=await fetch(`${e}/api/prompt/workspaces`,{headers:{"content-type":"application/json","x-mcp-key-id":t,"x-mcp-secret":o,"x-request-id":$e()}}),r=await n.json().catch(()=>null);return{ok:n.ok,status:n.status,workspaces:r?.workspaces??[]}}catch{return{ok:!1,status:0,workspaces:[]}}}async function ve(e,t,o,n={}){let r=await fetch(`${e.apiUrl}${t}`,{method:"POST",headers:{..._e(e),...n},body:JSON.stringify(o)}),s=await r.json().catch(()=>null);return{status:r.status,ok:r.ok,body:s}}async function Me(e,t){e.message("Loading your workspaces\u2026");let o=await Y(P,t.keyId,t.secret);if(!o.ok||o.workspaces.length===0)return{};let n=await e.selectWorkspace(o.workspaces,t.workspace);return n===null?{cancelled:!0}:{workspace:n}}async function U(e){if(g)return{ok:!0};try{let t=await H(e,"/api/prompt/catalog");return t.ok?{ok:!0}:t.status===401?{ok:!1,error:"Invalid MCP key or secret."}:t.status===404?{ok:!1,error:"Workspace not found \u2014 check MCP_WORKSPACE."}:t.status===403?{ok:!1,error:"You are not a member of this workspace."}:t.status===502||t.status===503||t.status===504?{ok:!1,error:`SuperClawd backend is unreachable or starting up (HTTP ${t.status}). Try again in a moment.`}:{ok:!1,error:`Auth check failed (HTTP ${t.status}).`}}catch(t){return{ok:!1,error:`Cannot reach SuperClawd backend (${String(t)}).`}}}var ee=[{id:"skill-backend-001",name:"backend-api-conventions",action:"code",executionMode:"auto",description:"writing, creating, modifying, or reviewing backend API code \u2014 HTTP endpoints, routes, controllers, request handlers, or server-side validation and security",categories:[{name:"endpoint-design",instructions:["Name routes with plural nouns and kebab-case (e.g. /user-profiles).","Return RFC-7807 problem+json on errors, never bare strings.","Validate and sanitize every request body against a schema before use."]},{name:"security",instructions:["Use parameterized queries only; never string-concatenate SQL.","Rate-limit auth endpoints to 5 requests/minute per IP."]}]},{id:"skill-testing-001",name:"testing-standards",action:"test",executionMode:"auto",description:"writing or updating automated tests \u2014 unit tests, integration tests, test files, assertions, mocks, or test coverage",categories:[{name:"unit",instructions:["One behavioral assertion per test; name tests as should_<expectation>.","Mock only at process boundaries (network, fs, clock)."]}]},{id:"skill-always-001",name:"repo-foundations",action:"behave",executionMode:"always",description:"foundational rules that always apply in this repository",categories:[{name:"house-rules",instructions:["Every source file must start with a one-line header comment describing its purpose.","Prefer clarity over cleverness; match the surrounding code's style."]}]}];var xe=[{id:"agent-reviewer-001",name:"code-reviewer",description:"Reviews a diff for correctness and security issues. Use after writing code.",vendor:"anthropic",model:"claude-sonnet-4-6",temperature:.2,prompt:"You are a meticulous senior code reviewer. Examine the change for correctness, security, and clarity. Report concrete findings with file:line; do not rewrite the code unless asked.",mode:"subagent",tools:{read:"allow",glob:"allow",grep:"allow",edit:"deny",write:"deny",bash:"deny",webfetch:"deny",task:"deny"},steps:null,inheritWorkspaceContext:!1},{id:"agent-orchestrator-001",name:"orchestrator",description:"Coordinates multi-step coding tasks and delegates focused work. Use when a task spans several files or steps.",vendor:"anthropic",model:"claude-sonnet-4-6",temperature:.3,prompt:"You are an orchestrator. Break the request into concrete steps, perform the edits directly, and keep changes minimal and focused on what was asked.",mode:"subagent",tools:{read:"allow",glob:"allow",grep:"allow",edit:"allow",write:"allow",bash:"deny",webfetch:"deny",task:"allow"},steps:null,inheritWorkspaceContext:!0}],be=[{name:"ship-checklist",description:"Run this team's pre-merge checklist.",arguments:[{name:"scope",description:"what is being shipped",required:!1}],content:`Pre-merge checklist for $ARGUMENTS:
6
+ 1. Tests pass and cover new behavior.
7
+ 2. No secrets or debug logging left in.
8
+ 3. Public APIs documented.
9
+ 4. Changelog updated.`}],Pe=[{name:"error-codes",description:"Canonical list of this platform's error codes.",content:`E1001 invalid_input
10
+ E1002 unauthorized
11
+ E1003 rate_limited
12
+ E2001 upstream_unavailable`}];var Ee=[{id:"workflow-deploy-001",name:"production-deploy",description:"deploying to production, cutting a release, or shipping to prod",itemCount:6,content:`Production deploy workflow:
13
+ 1. Confirm CI is green on main.
14
+ 2. Bump version + update changelog.
15
+ 3. Tag the release.
16
+ 4. Run db migrations.
17
+ 5. Deploy and watch error rate for 10m.
18
+ 6. Announce in #releases.`}];function vt(){let e=ee.filter(o=>o.executionMode==="auto").map(o=>({id:o.id,name:o.name,action:o.action,executionMode:o.executionMode,description:o.description})),t=ee.filter(o=>o.executionMode==="always").flatMap(o=>o.categories.flatMap(n=>n.instructions)).map((o,n)=>`${n+1}. ${o}`).join(`
19
+ `);return{skills:e,agents:xe,commands:be.map(({name:o,description:n,arguments:r})=>({name:o,description:n,arguments:r})),resources:Pe.map(({name:o,description:n})=>({name:o,description:n})),workflows:Ee.map(({id:o,name:n,description:r})=>({id:o,name:n,description:r})),foundational:{text:t}}}async function Re(e){if(g)return vt();let t=await H(e,"/api/prompt/catalog");if(!t.ok||!t.body)throw new Error(`Failed to fetch catalog (HTTP ${t.status}).`);return{skills:(t.body.skills??[]).filter(n=>n.executionMode==="auto"),agents:t.body.agents??[],commands:t.body.commands??[],resources:t.body.resources??[],workflows:t.body.workflows??[],foundational:{text:t.body.foundational?.text??""}}}async function Ae(e,t){if(g)return!0;try{return(await ve(e,"/api/prompt/inspector",{ide:!0,platform:"claude-code",llm_model:"claude",x_session_request_id:t,notify_on_checkpoint:!0,enable_session_files:!1},{"x-session-request-id":t})).ok}catch{return!1}}import{mkdirSync as jt,writeFileSync as Bt,chmodSync as Ht}from"node:fs";import{dirname as Fe,join as Ge}from"node:path";function v(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64)||"skill"}function Mt(e){return`${(e.description??e.name).trim().replace(/\.$/,"")}. SuperClawd-managed "${e.name}" guidance for ${e.action} tasks.`}function xt(e){return`# ${e.name} (SuperClawd-managed)
20
+
21
+ The authoritative instructions for this skill are managed in SuperClawd and
22
+ are **not** included here. You must fetch them before acting.
23
+
24
+ **REQUIRED \u2014 before doing anything else for this task:**
25
+
26
+ 1. Call the \`get_directives\` tool (SuperClawd MCP server) with:
27
+ - \`skillId\`: \`${e.id}\`
28
+ - \`action\`: \`${e.action}\`
29
+ 2. Apply every returned instruction exactly.
30
+
31
+ Do not proceed using only this description \u2014 it is a pointer, not the rules.
32
+ If \`get_directives\` returns an error, tell the user and stop.
33
+ `}function bt(e){let t=Mt(e).replace(/"/g,'\\"');return`---
34
+ name: ${v(e.name)}
35
+ description: "${t}"
36
+ user-invocable: false
37
+ ---
38
+
39
+ `}function Ie(e){let t=new Set,o=[];for(let n of e){let r=v(n.name),s=2;for(;t.has(r);)r=`${v(n.name)}-${s++}`;t.add(r),o.push({relPath:`skills/${r}/SKILL.md`,content:bt(n)+xt(n)})}return o}var Pt=`SUPERCLAWD \u2014 operating manual (always in effect):
40
+ - The ALWAYS rules below are ALREADY LOADED and active for this entire session.
41
+ Apply them directly to all work. Do NOT call any tool to fetch them \u2014 you
42
+ already have them in full.
43
+ - Separately, you have on-demand SuperClawd **skills** (each is a skill file
44
+ whose body carries a skillId). When one of those activates for the task, call
45
+ the \`get_directives\` tool with that file's skillId (a UUID) BEFORE acting,
46
+ and apply what it returns. Those skill files are pointers, not the rules.
47
+ - Only call \`get_directives\` with a UUID skillId taken from an activated skill
48
+ file. Never call it for the ALWAYS rules, and never pass a skill name.`;function te(e){let t=Pt,o=(e||"").trim();return o&&(t+=`
49
+
50
+ ALWAYS \u2014 foundational rules (already loaded & active for this whole session; apply directly, never fetch):
51
+ ${o}`),t}function Et(e){return e.inheritWorkspaceContext!==!1}function Rt(e){return te(e).trim()}function Oe(e,t){if(!Et(e))return e.prompt;let o=Rt(t);return o?`${o}
52
+
53
+ ---
54
+
55
+ ${e.prompt}`:e.prompt}var Te={read:"Read",glob:"Glob",grep:"Grep",edit:"Edit",write:"Write",bash:"Bash",webfetch:"WebFetch",task:"Task"};function At(e){return e==="allow"||e==="ask"||e===!0}function It(e){let t=e.tools??{};return Object.keys(Te).filter(o=>At(t[o])).map(o=>Te[o])}function Ot(e){let t=[`name: ${v(e.name)}`,`description: "${(e.description??e.name).replace(/"/g,'\\"')}"`];e.vendor==="anthropic"&&e.model&&e.model!=="default"&&t.push(`model: ${JSON.stringify(e.model)}`);let o=It(e);return o.length&&t.push(`tools: ${o.join(", ")}`),`---
56
+ ${t.join(`
57
+ `)}
58
+ ---
59
+
60
+ `}function De(e,t={}){let o=t.foundationalText??"",n=new Set,r=[];for(let s of e){let i=v(s.name),d=2;for(;n.has(i);)i=`${v(s.name)}-${d++}`;n.add(i),r.push({relPath:`agents/${i}.md`,content:Ot(s)+Oe(s,o)})}return r}function Tt(e){return e.arguments.length?e.arguments.map(t=>t.required?`<${t.name}>`:`[${t.name}]`).join(" "):""}function Dt(e){let t=[`description: "${e.description.replace(/"/g,'\\"')}"`],o=Tt(e);return o&&t.push(`argument-hint: ${o}`),`---
61
+ ${t.join(`
62
+ `)}
63
+ ---
64
+
65
+ `}function Lt(e){return`This is the SuperClawd command **${e.name}**. Its content is managed in
66
+ SuperClawd and fetched on use.
67
+
68
+ **REQUIRED \u2014 do this now:**
69
+
70
+ 1. Call the \`get_command\` tool (SuperClawd MCP server) with \`name\`: \`${e.name}\`.
71
+ 2. Execute the returned command content, substituting these arguments: $ARGUMENTS
72
+
73
+ Do not improvise the command from this description.
74
+ `}function Le(e){let t=new Set,o=[];for(let n of e){let r=v(n.name),s=2;for(;t.has(r);)r=`${v(n.name)}-${s++}`;t.add(r),o.push({relPath:`commands/${r}.md`,content:Dt(n)+Lt(n)})}return o}function Wt(e,t){let n=`${(e.description??e.name).trim().replace(/\.$/,"")}. Runs the '${e.name}' SuperClawd workflow.`.replace(/"/g,'\\"'),r=`# ${e.name} (SuperClawd workflow)
75
+
76
+ This is a managed multi-step workflow. Fetch its steps before starting.
77
+
78
+ **REQUIRED \u2014 before doing anything else:**
79
+
80
+ 1. Call the \`get_workflow\` tool with \`workflowId\`: \`${e.id}\`.
81
+ 2. Follow the returned steps **in order**.
82
+
83
+ Do not improvise the process from this description.
84
+ `;return{relPath:`skills/${t}/SKILL.md`,content:`---
85
+ name: ${t}
86
+ description: "${n}"
87
+ user-invocable: false
88
+ ---
89
+
90
+ ${r}`}}function Ut(e,t){let o=`Run the SuperClawd workflow **${e.name}**:
91
+
92
+ 1. Call the \`get_workflow\` tool with \`workflowId\`: \`${e.id}\`.
93
+ 2. Follow the returned steps in order, using any arguments: $ARGUMENTS
94
+ `,n=`Run the '${e.name}' workflow.`.replace(/"/g,'\\"');return{relPath:`commands/${t}.md`,content:`---
95
+ description: "${n}"
96
+ ---
97
+
98
+ ${o}`}}function We(e){let t=new Set,o=[];for(let n of e){let r=v(n.name),s=2;for(;t.has(r);)r=`${v(n.name)}-${s++}`;t.add(r),o.push(Wt(n,r)),o.push(Ut(n,r))}return o}var Nt=`---
99
+ description: Audit this session against your active SuperClawd directives.
100
+ ---
101
+
102
+ Audit the work done so far in this session against your active SuperClawd directives:
103
+
104
+ 1. The foundational/always-on directives loaded at session start \u2014 did you keep following them?
105
+ 2. For each skill relevant to the tasks performed, did you fetch its directives (via \`get_directives\`) and apply them?
106
+ 3. For any task that matched an SuperClawd workflow, did you fetch it (via \`get_workflow\`) and follow its steps in order?
107
+ 4. Flag anything relevant you may have skipped \u2014 and if so, fetch and apply/run it now.
108
+
109
+ Be concise; this is a compliance check, not a code review.
110
+ `,Ft=`---
111
+ description: Show SuperClawd service status, workspace info, and credit balance.
112
+ ---
113
+
114
+ Give me a concise SuperClawd status overview. Call these tools and summarize the results in a short list:
115
+
116
+ 1. \`service_status\` \u2014 is the service operational?
117
+ 2. \`workspace_info\` \u2014 workspace name, tier, and counts.
118
+ 3. \`check_balance\` \u2014 current credit balance.
119
+
120
+ Present it as a tidy summary; do not take any other action.
121
+ `,Gt=`---
122
+ description: Toggle SuperClawd notifications for this session.
123
+ ---
124
+
125
+ The user wants to flip SuperClawd notifications for this session.
126
+
127
+ Call the \`notifications\` tool (no arguments \u2014 it toggles the current on/off state), then report the resulting state in one short line. Do not take any other action.
128
+ `,Kt=`---
129
+ description: Apply maximum extended thinking (ultrathink) to the work at hand.
130
+ argument-hint: "[task or question]"
131
+ ---
132
+
133
+ To perform this work, please ultrathink \u2014 reason as deeply and carefully as you can before acting. Surface edge cases, weigh alternatives, and check your assumptions.
134
+
135
+ $ARGUMENTS
136
+ `;function Ue(){return[{relPath:"commands/audit-work.md",content:Nt},{relPath:"commands/status.md",content:Ft},{relPath:"commands/notifications.md",content:Gt},{relPath:"commands/ultrathink.md",content:Kt}]}function Ne(e){let t="hooks/foundational-fallback.txt",o=`${e.pluginDir}/${t}`,n=`${e.pluginDir}/hooks/reminder-context.txt`,r=`${e.pluginDir}/stepcount`,s=l=>({type:"command",command:`node "${e.helperPath}" ${l}`}),i=l=>({...s(l),async:!0}),d={SessionStart:[{hooks:[s(`foundational "${o}" SessionStart`)]}],Notification:[{matcher:"permission_prompt|elicitation_dialog|elicitation_complete|elicitation_response|auth_success",hooks:[i(`notify-local attention "${e.launchId}"`),i(`notify attention "${e.launchId}"`)]}],Stop:[{hooks:[i(`notify-local stop "${e.launchId}"`)]}],SessionEnd:[{hooks:[i(`notify completion "${e.launchId}"`)]}]},p=[{relPath:t,content:e.foundational.text??""}],u=Number(process.env.SUPERCLAWD_REMIND_EVERY??8),a=(e.foundational.text??"").trim();return u>0&&a&&(d.PostToolUse=[{matcher:"*",hooks:[s(`remind "${n}" "${r}"`)]}],p.push({relPath:"hooks/reminder-context.txt",content:`REMINDER \u2014 these SuperClawd always-rules remain in effect:
137
+ ${a}`})),e.gate&&(d.PreToolUse=[{matcher:"mcp__plugin_superclawd_superclawd__.*",hooks:[s("gate")]}]),p.push({relPath:"hooks/hooks.json",content:JSON.stringify({hooks:d},null,2)}),p}function Yt(e,t,o,n){let r={SUPERCLAWD_BACKEND:Q,SUPERCLAWD_MCP_API_URL:P,SUPERCLAWD_SESSION_ID:o};return g||(r.MCP_KEY_ID=e.keyId,r.MCP_SECRET=e.secret,r.MCP_WORKSPACE=e.workspace),process.env.NODE_EXTRA_CA_CERTS&&(r.NODE_EXTRA_CA_CERTS=process.env.NODE_EXTRA_CA_CERTS),process.env.SUPERCLAWD_HOME&&(r.SUPERCLAWD_HOME=process.env.SUPERCLAWD_HOME),process.env.SUPERCLAWD_LOG_FILE&&(r.SUPERCLAWD_LOG_FILE=process.env.SUPERCLAWD_LOG_FILE),process.env.SUPERCLAWD_DEBUG&&(r.SUPERCLAWD_DEBUG=process.env.SUPERCLAWD_DEBUG),process.env.SUPERCLAWD_MOCK_TIER&&(r.SUPERCLAWD_MOCK_TIER=process.env.SUPERCLAWD_MOCK_TIER),process.env.SUPERCLAWD_MOCK_BALANCE&&(r.SUPERCLAWD_MOCK_BALANCE=process.env.SUPERCLAWD_MOCK_BALANCE),n.length&&(r.SUPERCLAWD_RESOURCES=JSON.stringify(n.map(i=>({name:i.name,description:i.description})))),{relPath:".claude-plugin/plugin.json",content:JSON.stringify({name:"superclawd",description:"SuperClawd skills + live, metered directives for Claude Code.",mcpServers:{superclawd:{command:"node",args:[t],env:r}}},null,2)}}function Ke(e){let{pluginDir:t,session:o,catalog:n,serverPath:r,launchId:s}=e,i=Ge(Fe(r),"hook-helper.mjs"),d=process.env.SUPERCLAWD_GATE==="1",p=[Yt(o,r,s,n.resources),...Ie(n.skills),...De(n.agents,{foundationalText:n.foundational.text}),...Le(n.commands),...We(n.workflows),...Ue(),...Ne({foundational:n.foundational,helperPath:i,pluginDir:t,launchId:s,gate:d})],u=[];for(let a of p){let l=Ge(t,a.relPath);jt(Fe(l),{recursive:!0}),Bt(l,a.content),a.executable&&Ht(l,493),u.push(a.relPath)}return{pluginDir:t,skillCount:n.skills.length,agentCount:n.agents.length,commandCount:n.commands.length,workflowCount:n.workflows.length,files:u}}import{mkdirSync as qt,rmSync as je,readdirSync as Jt,statSync as Vt}from"node:fs";import{join as oe}from"node:path";import{randomBytes as zt}from"node:crypto";function Be(){let e=`${Date.now().toString(36)}-${zt(4).toString("hex")}`,t=oe(B,e),o=oe(t,"plugin");return qt(o,{recursive:!0}),{id:e,dir:t,pluginDir:o}}function He(e){try{je(e.dir,{recursive:!0,force:!0})}catch{}}function Ye(e=Date.now()){let t=0,o=[];try{o=Jt(B)}catch{return 0}for(let n of o){let r=oe(B,n);try{e-Vt(r).mtimeMs>ye&&(je(r,{recursive:!0,force:!0}),t++)}catch{}}return t}import{createInterface as Xt}from"node:readline";import{rmSync as Qt}from"node:fs";var $="\x1B",qe=2e3,Zt=e=>new Promise(t=>setTimeout(t,e));function Je(e){return e?e.length<=6?"\u2022\u2022\u2022\u2022":`${e.slice(0,4)}\u2026${e.slice(-2)}`:""}function ne(e,t=!1){return new Promise(o=>{let n=Xt({input:process.stdin,output:process.stdout}),r=n,s=!1;t&&(r._writeToOutput=i=>{s?(i===`
138
+ `||i==="\r"||i===`\r
139
+ `)&&r.output.write(i):r.output.write(i)}),n.on("SIGINT",()=>{n.close(),process.stdout.write(`
140
+ `),o(null)}),n.question(e,i=>{n.close(),t&&process.stdout.write(`
141
+ `),o(i.trim())}),t&&(s=!0)})}function eo(e,t){return new Promise(o=>{let n=process.stdin;if(!n.isTTY){o(e[0]?.slug??null);return}let r=t?e.findIndex(u=>u.slug===t):-1,s=Math.max(0,r>=0?r:e.findIndex(u=>u.role==="owner")),i=u=>{u||process.stdout.write(`${$}[${e.length}A`);for(let a=0;a<e.length;a++){let l=e[a],E=a===s?`${$}[38;5;208m\u276F `:" ";process.stdout.write(`${$}[2K${E}${l.name} ${$}[2m${l.slug} \xB7 ${l.role}${$}[0m
142
+ `)}};process.stdout.write(`Select your default workspace (\u2191/\u2193 \xB7 Enter \xB7 Esc cancels):
143
+ ${$}[?25l`),i(!0),n.setRawMode(!0),n.resume();let d=()=>{n.off("data",p);try{n.setRawMode(!1)}catch{}n.pause(),process.stdout.write(`${$}[?25h`)},p=u=>{let a=u.toString();a===""||a===$?(d(),process.stdout.write(`
144
+ `),o(null)):a==="\r"||a===`
145
+ `?(d(),o(e[s].slug)):a===`${$}[A`||a==="k"?(s=(s-1+e.length)%e.length,i(!1)):(a===`${$}[B`||a==="j")&&(s=(s+1)%e.length,i(!1))};n.on("data",p)})}async function Ve(e,t,o){let n=await Y(P,e,t);if(n.status===401)return{error:"Invalid MCP key or secret."};if(n.ok&&n.workspaces.length>0){if(n.workspaces.length===1){let i=n.workspaces[0];return process.stdout.write(`Using workspace "${i.slug}" (your only workspace).
146
+ `),{workspace:i.slug}}let s=await eo(n.workspaces,o);return s?{workspace:s}:{cancelled:!0}}n.ok&&process.stdout.write(`No workspaces found for this account \u2014 enter a slug manually.
147
+ `);let r=await ne(`Workspace slug${o?` [${o}]`:""}: `);return r===null?{cancelled:!0}:{workspace:r||o||""}}async function ze(e,t,o){let n=await U({keyId:e,secret:t,workspace:o,apiUrl:P});return n.ok?(I({...x()??{},credentials:{keyId:e,secret:t,workspace:o}}),{ok:!0}):{ok:!1,error:n.error??"Validation failed."}}async function Xe(e={}){if(g)return process.stdout.write(`Mock mode \u2014 no credentials needed.
148
+ `),{ok:!0};let t=x()??{},o=t.credentials??{};e.firstRun??!(o.keyId&&o.workspace)?(process.stdout.write(`
149
+ Welcome to SuperClawd. Let's connect your workspace.
150
+ `),process.stdout.write(`Grab your MCP credentials from https://app.superclawd.com (Settings \u2192 MCP Keys).
151
+ `),process.stdout.write(`${$}[2mPress Ctrl-C anytime to cancel.${$}[0m
152
+
153
+ `)):(process.stdout.write(`
154
+ Configure SuperClawd credentials (press Enter to keep an existing value).
155
+ `),process.stdout.write(`${$}[2mPress Ctrl-C anytime to cancel.${$}[0m
156
+
157
+ `));let r=await ne(`MCP Key ID${o.keyId?` [${Je(o.keyId)}]`:""}: `);if(r===null)return{ok:!0,cancelled:!0};let s=r||o.keyId||"",i=await ne(`MCP Secret${o.secret?" [keep current]":""}: `,!0);if(i===null)return{ok:!0,cancelled:!0};let d=i||o.secret||"";if(!s||!d)return{ok:!1,error:"MCP Key ID and Secret are required."};let p=await Ve(s,d,o.workspace??"");if(p.cancelled)return{ok:!0,cancelled:!0};if(p.error)return{ok:!1,error:p.error};let u=p.workspace??"";if(!u)return{ok:!1,error:"A workspace is required."};process.stdout.write(`
158
+ Validating credentials\u2026
159
+ `);let a={keyId:s,secret:d,workspace:u,apiUrl:P},l=Date.now(),E=await U(a),D=Date.now()-l;return D<qe&&await Zt(qe-D),E.ok?(I({...t,credentials:{keyId:s,secret:d,workspace:u}}),process.stdout.write(`\u2713 Connected to workspace "${u}".
160
+
161
+ `),{ok:!0}):{ok:!1,error:E.error??"Validation failed."}}async function Qe(){if(g)return process.stdout.write(`Mock mode \u2014 workspace switching is not used.
162
+ `),{ok:!0};let e=x()??{},t=e.credentials??{};if(!t.keyId||!t.secret)return{ok:!1,error:"No credentials yet. Run `superclawd configure` first."};let o=await Ve(t.keyId,t.secret,t.workspace??"");if(o.cancelled)return{ok:!0,cancelled:!0};if(o.error)return{ok:!1,error:o.error};let n=o.workspace??"";return n?n===t.workspace?(process.stdout.write(`
163
+ Default workspace is already "${n}".
164
+
165
+ `),{ok:!0}):(I({...e,credentials:{...t,workspace:n}}),process.stdout.write(`
166
+ \u2713 Default workspace set to "${n}".
167
+
168
+ `),{ok:!0}):{ok:!1,error:"A workspace is required."}}function Ze(){if(g){process.stdout.write(`Mock mode \u2014 credentials are not used.
169
+ `);return}let e=x()?.credentials??{},t=(o,n,r,s=!1)=>{let i=process.env[n],d=i||r,p=i?"env":r?"config file":"\u2014",u=d?s?Je(d):d:"(not set)";process.stdout.write(` ${o.padEnd(12)} ${u.padEnd(28)} (${p})
170
+ `)};process.stdout.write(`SuperClawd configuration:
171
+ `),t("Key ID","MCP_KEY_ID",e.keyId,!0),t("Secret","MCP_SECRET",e.secret,!0),t("Workspace","MCP_WORKSPACE",e.workspace),process.stdout.write(`
172
+ Env vars override the config file.
173
+ `)}function et(){try{Qt(W),process.stdout.write(`Cleared your SuperClawd configuration.
174
+ `)}catch{process.stdout.write(`No stored configuration to remove.
175
+ `)}}var h="\x1B",q=[{key:"notifications",label:"Notifications",description:"Default for new sessions \u2014 ping when Claude needs you or finishes",defaultOn:!1},{key:"skipPermissions",label:"Dangerously skip permissions",description:"Launch Claude Code with --dangerously-skip-permissions (no approval prompts)",defaultOn:!1},{key:"chooseWorkspaceAtStartup",label:"Choose workspace at startup",description:"Pick the workspace to boot into each time you run superclawd",defaultOn:!1}].sort((e,t)=>e.label.localeCompare(t.label)),re=(e,t)=>e.preferences?.[t.key]??t.defaultOn;async function tt(){let e=x()??{},t=process.stdin;if(!t.isTTY){process.stdout.write(`SuperClawd options:
176
+ `);for(let o of q)process.stdout.write(` ${re(e,o)?"on ":"off"} ${o.label}
177
+ `);return}await new Promise(o=>{let n=q.length,r=n+2,s=0,i=u=>{u||process.stdout.write(`${h}[${r}A`);for(let a=0;a<n;a++){let l=q[a],E=a===s?`${h}[38;5;208m\u276F `:" ",D=re(e,l)?`${h}[38;5;208m[\u2713]${h}[0m`:"[ ]";process.stdout.write(`${h}[2K${E}${D} ${l.label}${h}[0m ${h}[2m${l.description}${h}[0m
178
+ `)}process.stdout.write(`${h}[2K
179
+ `),process.stdout.write(`${h}[2K${h}[2mPress Esc (or Ctrl-C) to exit${h}[0m
180
+ `)};process.stdout.write(`
181
+ SuperClawd options ${h}[2m(\u2191/\u2193 move \xB7 Space/Enter to toggle)${h}[0m
182
+ ${h}[?25l`),i(!0),t.setRawMode(!0),t.resume();let d=()=>{t.off("data",p);try{t.setRawMode(!1)}catch{}t.pause(),process.stdout.write(`${h}[?25h
183
+ `)},p=u=>{let a=u.toString();if(a===""||a===h)d(),o();else if(a==="\r"||a===`
184
+ `||a===" "){let l=q[s];e.preferences={...e.preferences,[l.key]:!re(e,l)},I(e),i(!1)}else a===`${h}[A`||a==="k"?(s=(s-1+n)%n,i(!1)):(a===`${h}[B`||a==="j")&&(s=(s+1)%n,i(!1))};t.on("data",p)})}import{execSync as it}from"node:child_process";var m="\x1B",A=`${m}[38;5;208m`,T=`${m}[2m`,ae=`${m}[31m`,w=`${m}[0m`,to=`${m}[?1049h`,ot=`${m}[?1049l`,oo=`${m}[?25l`,se=`${m}[?25h`,no=`${m}[?1007l`,nt=`${m}[?1007h`,ro=`${m}[?1000l${m}[?1002l${m}[?1003l${m}[?1004l${m}[?1006l${m}[?1015l`,ie=`${m}[2J${m}[H`,J=[" _ _"," ____ _ _ __ ___ _ _ __| |__ ___ __ ____| |","(_-< || | '_ \\/ -_) '_/ _| / _` \\ V V / _` |","/__/\\_,_| .__/\\___|_| \\__|_\\__,_|\\_/\\_/\\__,_|"," |_|"],rt=45,N=36,so=140,io=350,M=e=>void process.stdout.write(e),ao=e=>new Promise(t=>setTimeout(t,e)),O=e=>e>0?" ".repeat(e):"",at=process.platform!=="win32";function co(){if(!at)return null;try{return it("stty -g </dev/tty",{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim()}catch{return null}}function st(e){if(at)try{it(`stty ${e} </dev/tty`,{stdio:"ignore"})}catch{}}var V=null;function ct(e){V?.(),V=null,process.stderr.write(`${ae}\u2717 ${e}${w}
185
+ `)}function lo(e,t){return M(`${A}${J.join(`
186
+ `)}${w} ${T}v${t}${w}
187
+
188
+ `),{async phase(o,n){M(`${T} \xB7 ${n}${w}
189
+ `)},message(o){M(`${T} \xB7 ${o}${w}
190
+ `)},async selectWorkspace(o,n){return n??o[0]?.slug??null},async ready(o){M(`${A} \u2713 ${o}${w}
191
+ `)},fail(o){M(`${ae} \u2717 ${o}${w}
192
+ `)},note(o){M(` ${o}
193
+ `)},handoff(){},finish(){}}}function uo(e,t){let o=co(),n=0,r=!0,s=!1,i=c=>{c.includes(3)&&a()},d=()=>{let c=process.stdin;if(c.isTTY){try{c.setRawMode(!0)}catch{}c.resume(),c.on("data",i),s=!0}},p=()=>{if(!s)return;let c=process.stdin;c.off("data",i);try{c.setRawMode(!1)}catch{}c.pause(),s=!1},u=()=>{p();try{process.stdin.isTTY&&process.stdin.setRawMode(!1)}catch{}M(se+nt+ot),o&&st(o)},a=()=>{r&&u(),r=!1,process.exit(130)},l=()=>{p(),r&&M(se+nt+ot)},E=()=>{process.off("SIGINT",a),process.off("SIGTERM",a),process.off("exit",l),V=null};st("-echo"),M(to+oo+no+ro),d(),process.on("SIGINT",a),process.on("SIGTERM",a),process.on("exit",l),V=u;let D=(c,y)=>{let k=process.stdout.columns||80,_=process.stdout.rows||24,f=Math.floor(c*N/e);f<0&&(f=0),f>N&&(f=N);let R="\u2588".repeat(f)+"\u2591".repeat(N-f),b=Math.floor(c*100/e),S=N+6,F=Math.max(0,Math.floor((_-9)/2)),C=ie+`
194
+ `.repeat(F),L=Math.max(0,Math.floor((k-rt)/2));for(let wt of J)C+=`${O(L)}${A}${wt}${w}
195
+ `;C+=`
196
+ `;let G=Math.max(0,Math.floor((k-y.length)/2));C+=`${O(G)}${T}${y}${w}
197
+
198
+ `;let X=Math.max(0,Math.floor((k-S)/2));C+=`${O(X)}${A}${R}${w} ${String(b).padStart(3)}%
199
+ `;let K=`v${t}`,gt=Math.max(1,_-1),ht=Math.max(1,k-K.length-1);C+=`${m}[${gt};${ht}H${A}${K}${w}`,M(C)},ue=async(c,y,k)=>{let _=k-(Date.now()-n);_>0&&await ao(_),D(c,y),n=Date.now()},de=c=>{let y=process.stdout.columns||80,k=process.stdout.rows||24,_=Math.max(0,Math.floor((k-(J.length+1+c.length))/2)),f=ie+`
200
+ `.repeat(_),R=Math.max(0,Math.floor((y-rt)/2));for(let S of J)f+=`${O(R)}${A}${S}${w}
201
+ `;f+=`
202
+ `;for(let S of c)f+=`${S}
203
+ `;let b=`v${t}`;f+=`${m}[${Math.max(1,k-1)};${Math.max(1,y-b.length-1)}H${A}${b}${w}`,M(f)},z=(c,y)=>{let k=process.stdout.columns||80,_="Select your workspace \u2191/\u2193 \xB7 Enter \xB7 Esc cancels",f=Math.max(0,Math.floor((k-_.length)/2)),R=C=>` ${C.name} ${C.slug} \xB7 ${C.role}`,b=Math.max(...c.map(C=>R(C).length)),S=Math.max(0,Math.floor((k-b)/2)),F=[`${O(f)}${T}${_}${w}`,""];for(let C=0;C<c.length;C++){let L=c[C],G=C===y,X=G?`${A}\u276F `:" ",K=G?`${A}${L.name}${w}`:L.name;F.push(`${O(S)}${X}${K} ${T}${L.slug} \xB7 ${L.role}${w}`)}de(F)};return{phase:(c,y)=>ue(c-1,y,so),ready:c=>ue(e,c,io),message(c){let y=process.stdout.columns||80,k=Math.max(0,Math.floor((y-c.length)/2));de([`${O(k)}${T}${c}${w}`]),n=Date.now()},selectWorkspace(c,y){return new Promise(k=>{let _=y?c.findIndex(b=>b.slug===y):-1,f=_>=0?_:0;s&&process.stdin.off("data",i),z(c,f);let R=b=>{let S=b.toString();S===""||S===m?(process.stdin.off("data",R),k(null)):S==="\r"||S===`
204
+ `?(process.stdin.off("data",R),process.stdin.on("data",i),k(c[f].slug)):S===`${m}[A`||S==="k"?(f=(f-1+c.length)%c.length,z(c,f)):(S===`${m}[B`||S==="j")&&(f=(f+1)%c.length,z(c,f))};process.stdin.on("data",R)})},fail(c){r&&u(),r=!1,E(),process.stderr.write(`${ae}\u2717 ${c}${w}
205
+ `)},note(){},handoff(){s&&(process.stdin.off("data",i),process.stdin.pause(),s=!1),M(ie+se),process.off("SIGINT",a),process.off("SIGTERM",a)},finish(){r&&u(),r=!1,E()}}}function po(){return process.platform!=="win32"?!0:!!(process.env.WT_SESSION||process.env.TERM_PROGRAM||process.env.TERM)}function lt(e){let t=process.stdout.isTTY===!0,o=e.version??"";return e.plain||!t||!po()?lo(e.total,o):uo(e.total,o)}var ut={name:"superclawd",version:"0.1.0",description:"Claude Code, supercharged \u2014 your team's standards, every session. The superclawd CLI loads your workspace's skills, agents, commands, workflows, and live directives into Claude Code as a plugin.",author:"SuperClawd <support@superclawd.com>",license:"SEE LICENSE IN LICENSE",homepage:"https://superclawd.com",repository:{type:"git",url:"https://github.com/superclawd-ai/superclawd"},bugs:{url:"https://github.com/superclawd-ai/superclawd/issues"},keywords:["superclawd","claude-code","claude","plugin","skills","agents","mcp","ai-assistant","coding-standards","model-context-protocol"],engines:{node:">=20"},type:"module",main:"dist/index.js",bin:{superclawd:"dist/index.js"},files:["dist","README.md","LICENSE"],scripts:{build:"node build.mjs",dev:"node build.mjs && tsx src/index.ts",typecheck:"tsc --noEmit",lint:"eslint 'src/**/*.{ts,tsx}'","lint:fix":"eslint 'src/**/*.{ts,tsx}' --fix",format:"prettier --check 'src/**/*.{ts,tsx}'","format:fix":"prettier --write 'src/**/*.{ts,tsx}'",selftest:"tsx test/mcp-selftest.ts",test:"node build.mjs && tsx test/mcp-selftest.ts",prepublishOnly:"npm run build","publish:npm":"npm publish","version:bump":"npm version patch --no-git-tag-version"},dependencies:{"@modelcontextprotocol/sdk":"^1.7.0",zod:"^3.24.2"},devDependencies:{"@eslint/js":"^9.39.1","@types/node":"^22.10.0","@typescript-eslint/eslint-plugin":"^8.44.1","@typescript-eslint/parser":"^8.44.1",esbuild:"^0.24.0",eslint:"^9.36.0","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.4",prettier:"^3.6.2",tsx:"^4.19.0",typescript:"^5.7.0"}};var mt=ut.version,ce=process.env.SUPERCLAWD_DRY_RUN==="1"||process.argv.includes("--dry-run");function go(){if(process.env.SUPERCLAWD_MCP_SERVER_PATH)return process.env.SUPERCLAWD_MCP_SERVER_PATH;let e=dt(new URL("./mcp-server.mjs",import.meta.url));return ft(e)?e:dt(new URL("../dist/mcp-server.mjs",import.meta.url))}function ho(){return`superclawd \u2014 Claude Code, supercharged with your SuperClawd workspace.
206
+
207
+ Usage:
208
+ superclawd Launch Claude with your skills/agents/directives loaded
209
+ superclawd configure Set up your credentials (interactive); --show, --reset
210
+ superclawd switch Set your default workspace (pick from yours)
211
+ superclawd config Toggle launch options + default notifications preference
212
+ superclawd update Update to the latest version (npm i -g superclawd)
213
+ superclawd version
214
+ superclawd help
215
+
216
+ No credentials yet? Run \`superclawd configure\` first.
217
+
218
+ Env (override the stored config):
219
+ MCP_KEY_ID, MCP_SECRET, MCP_WORKSPACE credentials
220
+ `}function wo(){try{return!mo("claude",["--version"],{stdio:"ignore"}).error}catch{return!1}}function ko(e){let t=["--plugin-dir",e.pluginDir];return t.push("--allowedTools","mcp__plugin_superclawd_superclawd__*"),ge()&&t.push("--dangerously-skip-permissions"),new Promise(o=>{let n=pt("claude",t,{stdio:"inherit"});n.on("error",r=>o({code:127,error:`Could not launch claude: ${r.message}. Is Claude Code installed and on PATH?`})),n.on("close",r=>o({code:r??0}))})}function Co(){return process.stdout.write(`Updating superclawd (npm i -g superclawd@latest)\u2026
221
+ `),new Promise(e=>{let t=pt("npm install -g superclawd@latest",{stdio:"inherit",shell:!0});t.on("error",o=>{process.stderr.write(`\u2717 Could not run npm: ${o.message}. Is npm on your PATH?
222
+ `),e(127)}),t.on("close",o=>{o===0?process.stdout.write("\u2713 Updated. Run `superclawd version` to confirm.\n"):process.stderr.write(`\u2717 Update failed (npm exited ${o}).
223
+ `),e(o??1)})})}async function yo(){if(!ce&&!wo())return process.stderr.write(`\u2717 Claude Code isn't installed (or isn't on your PATH).
224
+
225
+ SuperClawd supercharges Claude Code, so you'll need it first:
226
+ \u2192 https://claude.com/code
227
+
228
+ Once it's installed, run \`superclawd\` again.
229
+ `),1;g||Ce();let e=Se();if(!e.ok&&!g)return process.stderr.write(`${e.error??"Could not resolve credentials."}
230
+ `),1;let t=e.session,o=lt({total:5,plain:ce,version:mt});if(!g&&he()&&process.stdin.isTTY){let l=await Me(o,t);if(l.cancelled)return o.finish(),130;l.workspace&&(t={...t,workspace:l.workspace})}await o.phase(1,"Resolving credentials\u2026"),await o.phase(2,"Authenticating\u2026");let n=await U(t);if(!n.ok)return o.fail(n.error??"Authentication failed."),1;await o.phase(3,g?"Loading mock catalog\u2026":"Fetching your workspace\u2026");let r;try{r=await Re(t)}catch(l){return o.fail(`Catalog fetch failed: ${String(l)}`),1}await o.phase(4,"Establishing session\u2026"),Ye();let s=Be();ke(s.dir,t.workspace);let i=go();if(!ft(i))return o.fail(`Bundled MCP server not found at ${i}. Run \`npm run build\` first.`),1;await Ae(t,s.id),await o.phase(5,"Generating plugin\u2026");let d=Ke({pluginDir:s.pluginDir,session:t,catalog:r,serverPath:i,launchId:s.id}),p=g?"mock":t.workspace;if(await o.ready(`${p} \xB7 ${d.skillCount} skills \xB7 ${d.commandCount} commands \xB7 ${d.workflowCount} workflows`),ce){o.note("Dry run \u2014 not launching Claude. Generated files:");for(let l of d.files)o.note(` ${l}`);return 0}o.handoff();let{code:u,error:a}=await ko(s);return o.finish(),He(s),a&&process.stderr.write(`${a}
231
+ `),a?127:u}function le(e){let t=process.argv.indexOf(`--${e}`);return t>=0?process.argv[t+1]:void 0}async function So(){if(process.argv.includes("--show"))return Ze(),0;if(process.argv.includes("--reset"))return et(),0;let e=le("key"),t=le("secret"),o=le("workspace"),n=e&&t&&o?await ze(e,t,o):await Xe();return n.cancelled?(process.stdout.write(`Cancelled.
232
+ `),0):n.ok?(e&&t&&o&&process.stdout.write(`\u2713 Credentials saved.
233
+ `),0):(process.stderr.write(`\u2717 ${n.error??"Configuration failed."}
234
+ `),1)}async function $o(){let e=await Qe();return e.cancelled?(process.stdout.write(`Cancelled.
235
+ `),0):e.ok?0:(process.stderr.write(`\u2717 ${e.error??"Workspace switch failed."}
236
+ `),1)}async function _o(){let[e]=process.argv.slice(2).filter(t=>t!=="--dry-run");switch(e){case"configure":process.exit(await So());return;case"switch":process.exit(await $o());return;case"config":await tt(),process.exit(0);return;case"update":process.exit(await Co());return;case"version":case"--version":case"-v":console.log(mt);return;case"help":case"--help":case"-h":console.log(ho());return;default:process.exit(await yo())}}_o().catch(e=>{ct(String(e)),process.exit(1)});