dunsocial 0.15.0 → 0.16.1
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/README.md +21 -0
- package/dist/index.js +163 -76
- package/package.json +6 -1
- package/skills/dunsocial/SKILL.md +37 -1
package/README.md
CHANGED
|
@@ -77,6 +77,8 @@ dun posts publish \
|
|
|
77
77
|
|
|
78
78
|
Personal LinkedIn and Company Pages (`linkedin-business`) support **images** (up to 20) **or exactly one video** (MP4/MOV, ≤512MB). Do not mix video and images. No `--meta` needed.
|
|
79
79
|
|
|
80
|
+
Facebook Pages (limited beta) are **text, one link, or photos** — images-only, no `--meta`. Connect the Page in the dashboard, then `dun accounts list --platform facebook`.
|
|
81
|
+
|
|
80
82
|
```bash
|
|
81
83
|
# 1. Find your personal LinkedIn account id
|
|
82
84
|
dun accounts list --platform linkedin --json
|
|
@@ -156,6 +158,23 @@ Also useful: `dun reddit requirements <subreddit> --json`.
|
|
|
156
158
|
|
|
157
159
|
---
|
|
158
160
|
|
|
161
|
+
## Instagram and TikTok
|
|
162
|
+
|
|
163
|
+
These commands build the platform options for you, so you don't need `--meta`.
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
# Instagram: --format feed_image | carousel | reel | story
|
|
167
|
+
dun media upload ./clip.mp4 --json
|
|
168
|
+
dun instagram schedule --account ACCOUNT_ID --format reel --media ASSET_ID --caption "Launch day" --in 2h
|
|
169
|
+
|
|
170
|
+
# TikTok: one video, --privacy public | friends | followers | private
|
|
171
|
+
dun tiktok publish --account ACCOUNT_ID --media ASSET_ID --privacy public --title "Behind the scenes" --wait
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Run `dun instagram --help` or `dun tiktok --help` for every option.
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
159
178
|
## Automated posting (CI)
|
|
160
179
|
|
|
161
180
|
1. In DunSocial, open **Settings → CLI**
|
|
@@ -182,7 +201,9 @@ dun posts schedule \
|
|
|
182
201
|
dun --help
|
|
183
202
|
dun auth status
|
|
184
203
|
dun posts list
|
|
204
|
+
dun posts list --status scheduled --from 2026-12-08 --to 2026-12-15 --sort scheduled_asc
|
|
185
205
|
dun media upload ./photo.png
|
|
206
|
+
dun media alt ASSET_ID --text "Team photo at the launch"
|
|
186
207
|
dun reddit flairs some-subreddit
|
|
187
208
|
dun posts validate --accounts ACCOUNT_ID --text "Hello" --json
|
|
188
209
|
dun drafts create --text "Idea for later"
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{readFileSync as
|
|
3
|
-
`,"utf8");try{await
|
|
2
|
+
import{readFileSync as bt}from"node:fs";import{mkdir as yt,readFile as It,writeFile as At,chmod as St,unlink as Tt}from"node:fs/promises";import{dirname as Ct,join as Q}from"node:path";import{homedir as Ut}from"node:os";var c={OK:0,USAGE:1,AUTH:2,FORBIDDEN:3,VALIDATION:4,NOT_FOUND:5,RATE_LIMITED:6,NETWORK:7,PAYMENT:8};class d extends Error{code;details;constructor(e,n=c.USAGE,t){super(e);this.name="CliError",this.code=n,this.details=t}}function Ae(e){if(e===401)return c.AUTH;if(e===402)return c.PAYMENT;if(e===403)return c.FORBIDDEN;if(e===404)return c.NOT_FOUND;if(e===429)return c.RATE_LIMITED;if(e>=400&&e<500)return c.VALIDATION;return c.NETWORK}var vt="https://api.dunsocial.com",Se="0.16.1";function Et(){if(!Se.includes("@@"))return Se;try{let e=JSON.parse(bt(Q(import.meta.dir,"..","package.json"),"utf8"));if(typeof e.version==="string"&&e.version.length>0)return e.version}catch{}return"0.0.0"}var U=Et();function W(){if(process.env.DUN_CONFIG)return process.env.DUN_CONFIG;let e=process.env.XDG_CONFIG_HOME,n=e?e:Q(Ut(),".config");return Q(n,"dunsocial","config.json")}function P(){return W()}async function ee(){let e=W();try{let n=await It(e,"utf8");return JSON.parse(n)}catch(n){if(n.code==="ENOENT")return{};throw new d(`Failed to read config at ${e}: ${n.message}`,c.USAGE)}}async function D(e){let n=W();await yt(Ct(n),{recursive:!0});let t={...e,updatedAt:new Date().toISOString()};await At(n,`${JSON.stringify(t,null,2)}
|
|
3
|
+
`,"utf8");try{await St(n,384)}catch{}}async function Te(){let e=W();try{await Tt(e)}catch(n){if(n.code!=="ENOENT")throw new d(`Failed to clear config: ${n.message}`,c.USAGE)}}async function Ce(e){let n=await ee(),t=(e.apiUrl||process.env.DUN_API_URL||n.apiUrl||vt).replace(/\/$/,""),r=e.token||process.env.DUN_TOKEN||n.token,a=e.workspace||process.env.DUN_WORKSPACE_ID||n.defaultWorkspaceId||void 0,i=process.env.DUN_JSON==="0",o=!process.stdout.isTTY,s=i?!1:e.json===!0||process.env.DUN_JSON==="1"||process.env.CI==="true"||process.env.CI==="1"||o;return{apiUrl:t,token:r,workspaceId:a,json:s,debug:e.debug===!0||process.env.DUN_DEBUG==="1",quiet:e.quiet===!0,yes:e.yes===!0||process.env.CI==="true"||process.env.CI==="1",config:n}}function y(e){if(!e.token)throw new d("Not authenticated. Run `dun auth login` (or `dun auth login --token <token>` / set DUN_TOKEN).",c.AUTH);return e.token}function I(e){if(!e.workspaceId)throw new d("No workspace selected. Run `dun workspace use <id|slug>` or pass --workspace / DUN_WORKSPACE_ID.",c.VALIDATION);return e.workspaceId}function te(e){let n={},t=[],r=0,a=!0;while(r<e.length){let u=e[r];if(a&&u==="--"){a=!1,r+=1;continue}if(a&&u.startsWith("--")){let m=u.indexOf("=");if(m!==-1){n[u.slice(2,m)]=u.slice(m+1),r+=1;continue}let g=u.slice(2),h=e[r+1];if(h!==void 0&&!h.startsWith("-"))n[g]=h,r+=2;else n[g]=!0,r+=1;continue}if(a&&u.startsWith("-")&&u.length>1&&u!=="-"){let m=u.slice(1);if(m.length>1&&!m.includes("=")){for(let k of m)n[k]=!0;r+=1;continue}let g=m,h=e[r+1];if(h!==void 0&&!h.startsWith("-"))n[g]=h,r+=2;else n[g]=!0,r+=1;continue}t.push(u),r+=1}let i=t[0],o,s,l=1;if(i==="memory"&&(t[1]==="collections"||t[1]==="collection"))s="collections",o=t[2],l=o?3:2;else o=t[1],l=o?2:1;return{group:i,action:o,nest:s,flags:n,positionals:t.slice(l)}}function f(e,...n){for(let t of n){let r=e[t];if(typeof r==="string"&&r.length>0)return r}return}function w(e,...n){for(let t of n){let r=e[t];if(r===!0)return!0;if(typeof r==="string"){let a=r.toLowerCase();if(a==="1"||a==="true"||a==="yes")return!0}}return!1}function S(e,...n){let t=f(e,...n);if(t===void 0)return;let r=Number(t);if(!Number.isFinite(r))throw Error(`Invalid number for --${n[0]}: ${t}`);return r}function v(e,...n){let t=f(e,...n);if(t===void 0)return;return t.split(",").map((r)=>r.trim()).filter(Boolean)}function ne(e){return w(e,"help","h")}function ie(e){return w(e,"version","v","V")}function p(e,n){if(n.quiet&&!n.json)return;if(n.json||!process.stdout.isTTY){process.stdout.write(`${JSON.stringify({ok:!0,data:e},null,2)}
|
|
4
4
|
`);return}if(e===void 0||e===null){process.stdout.write(`ok
|
|
5
5
|
`);return}if(typeof e==="string"){process.stdout.write(`${e}
|
|
6
|
-
`);return}process.stdout.write(`${
|
|
7
|
-
`)}function
|
|
6
|
+
`);return}process.stdout.write(`${Ot(e,n.emptyMessage)}
|
|
7
|
+
`)}function ve(e,n){let{message:t,code:r,details:a}=Rt(e);if(n.json||!process.stdout.isTTY)process.stdout.write(`${JSON.stringify({ok:!1,error:{code:xt(r),message:t,details:a??null}},null,2)}
|
|
8
8
|
`);else{process.stderr.write(`error: ${t}
|
|
9
|
-
`);let
|
|
9
|
+
`);let i=Nt(a);if(r===c.PAYMENT&&i)process.stderr.write(`Subscribe: ${i}
|
|
10
10
|
`);else if(a!==void 0&&process.env.DUN_DEBUG==="1")process.stderr.write(`${JSON.stringify(a,null,2)}
|
|
11
|
-
`)}return
|
|
12
|
-
`)}if(e&&typeof e==="object"){let t=e;if(Array.isArray(t.items)){if(t.items.length===0&&n)return n;let
|
|
13
|
-
${a}`:a}return Object.entries(t).map(([
|
|
14
|
-
`)}return String(e)}function
|
|
15
|
-
`);return`${
|
|
16
|
-
${l}`}function
|
|
11
|
+
`)}return r}function xt(e){switch(e){case c.AUTH:return"auth";case c.FORBIDDEN:return"forbidden";case c.VALIDATION:return"validation";case c.NOT_FOUND:return"not_found";case c.RATE_LIMITED:return"rate_limited";case c.NETWORK:return"network";case c.PAYMENT:return"payment_required";default:return"usage"}}function Nt(e){if(!e||typeof e!=="object")return;let n=e;if(typeof n.billingUrl==="string")return n.billingUrl;let t=n.body;if(t&&typeof t==="object"&&typeof t.billingUrl==="string")return t.billingUrl;return}function Rt(e){if(e instanceof d)return{message:e.message,code:e.code,details:e.details};if(e instanceof Error)return{message:e.message,code:c.USAGE};return{message:String(e),code:c.USAGE}}function Ot(e,n){if(Array.isArray(e)){if(e.length===0)return n??"(empty)";if(e.every((t)=>t&&typeof t==="object"))return Ue(e,n);return e.map((t)=>`- ${re(t)}`).join(`
|
|
12
|
+
`)}if(e&&typeof e==="object"){let t=e;if(Array.isArray(t.items)){if(t.items.length===0&&n)return n;let r=typeof t.total==="number"?`total=${t.total} showing=${t.items.length}`:void 0,a=Ue(t.items,n);return r?`${r}
|
|
13
|
+
${a}`:a}return Object.entries(t).map(([r,a])=>`${r}: ${re(a)}`).join(`
|
|
14
|
+
`)}return String(e)}function Ue(e,n){if(e.length===0)return n??"(empty)";let t=["id","name","slug","status","providerName","username","displayName","role","scheduledAt","content","text","originalFilename","score","collectionId"],r=new Set;for(let u of e)for(let m of Object.keys(u))r.add(m);let a=[...t.filter((u)=>r.has(u)),...[...r].filter((u)=>!t.includes(u)).slice(0,6)].slice(0,8),i=e.map((u)=>a.map((m)=>Lt(re(u[m]),m==="content"||m==="text"?48:28))),o=a.map((u,m)=>Math.max(u.length,...i.map((g)=>g[m]?.length??0))),s=a.map((u,m)=>u.padEnd(o[m])).join(" "),l=i.map((u)=>u.map((m,g)=>m.padEnd(o[g])).join(" ")).join(`
|
|
15
|
+
`);return`${s}
|
|
16
|
+
${l}`}function re(e){if(e===null||e===void 0)return"";if(typeof e==="string")return e.replace(/\s+/g," ").trim();if(typeof e==="number"||typeof e==="boolean")return String(e);if(e instanceof Date)return e.toISOString();if(typeof e==="object"){let n=e;if(typeof n.id==="string"&&typeof n.name==="string")return`${n.name} (${n.id})`;if(typeof n.status==="string")return n.status;return JSON.stringify(e)}return String(e)}function Lt(e,n){if(e.length<=n)return e;return`${e.slice(0,Math.max(0,n-1))}...`}function R(e,n,t){if(!e)return;if(t!==void 0){process.stderr.write(`[debug] ${n} ${JSON.stringify(t)}
|
|
17
17
|
`);return}process.stderr.write(`[debug] ${n}
|
|
18
|
-
`)}function
|
|
19
|
-
${
|
|
18
|
+
`)}function A(e,n){let t=`${e} ${n}`,r="-".repeat(Math.max(12,t.length+4));return`${t}
|
|
19
|
+
${r}`}var oe=`dun - schedule & publish social posts
|
|
20
20
|
|
|
21
21
|
Usage:
|
|
22
22
|
dun <command> [flags]
|
|
23
23
|
|
|
24
|
-
${
|
|
24
|
+
${A("\uD83D\uDD10","Auth")}
|
|
25
25
|
dun auth login # device-code browser flow
|
|
26
26
|
dun auth login --token <token> # CI / headless
|
|
27
27
|
dun auth login --no-browser
|
|
@@ -29,36 +29,52 @@ ${C("\uD83D\uDD10","Auth")}
|
|
|
29
29
|
dun auth whoami
|
|
30
30
|
dun auth status
|
|
31
31
|
|
|
32
|
-
${
|
|
32
|
+
${A("\uD83D\uDCC1","Workspaces")}
|
|
33
33
|
dun workspace list
|
|
34
34
|
dun workspace use <id|slug>
|
|
35
35
|
dun workspace current
|
|
36
36
|
|
|
37
|
-
${
|
|
38
|
-
dun accounts list [--platform x|reddit|...]
|
|
37
|
+
${A("\uD83D\uDD17","Accounts")}
|
|
38
|
+
dun accounts list [--platform x|reddit|facebook|...]
|
|
39
39
|
|
|
40
|
-
${
|
|
40
|
+
${A("\uD83D\uDFE0","Reddit")}
|
|
41
41
|
dun reddit flairs <subreddit> # template id + text + textEditable
|
|
42
42
|
dun reddit requirements <subreddit> # live post rules (flair required, ...)
|
|
43
43
|
# alias: dun accounts reddit flairs <subreddit>
|
|
44
44
|
|
|
45
|
-
${
|
|
45
|
+
${A("\uD83D\uDCCC","Pinterest")}
|
|
46
46
|
dun pinterest boards # live boards for the connected account
|
|
47
47
|
dun pinterest create-board --name "..." [--private]
|
|
48
48
|
# alias: dun accounts pinterest boards
|
|
49
49
|
|
|
50
|
-
${
|
|
50
|
+
${A("\uD83D\uDCAC","Discord")}
|
|
51
51
|
dun discord channels [--account <id>] # text and announcement channels
|
|
52
52
|
# alias: dun accounts discord channels
|
|
53
53
|
# then: --meta '{"discord":{"channelId":"..."}}'
|
|
54
54
|
|
|
55
|
-
${
|
|
55
|
+
${A("\uD83D\uDCAC","Slack")}
|
|
56
|
+
dun slack channels [--account <id>] # public and private channels
|
|
57
|
+
# alias: dun accounts slack channels
|
|
58
|
+
# then: --meta '{"slack":{"channelId":"..."}}'
|
|
59
|
+
|
|
60
|
+
${A("\uD83D\uDCF8","Instagram")}
|
|
61
|
+
dun instagram schedule --account <id> --format reel --media <asset> --caption "..." (--at ISO | --in 2h)
|
|
62
|
+
dun instagram publish --account <id> --format feed_image --media <asset> [--alt "..."] [--wait]
|
|
63
|
+
# formats: feed_image, carousel, reel, story
|
|
64
|
+
|
|
65
|
+
${A("\uD83C\uDFB5","TikTok")}
|
|
66
|
+
dun tiktok schedule --account <id> --media <video> --privacy public --title "..." (--at ISO | --in 2h)
|
|
67
|
+
dun tiktok publish --account <id> --media <video> --privacy private [--wait]
|
|
68
|
+
|
|
69
|
+
${A("\uD83D\uDCDD","Posts")}
|
|
56
70
|
dun posts list [--status scheduled|published|failed|draft|cancelled]
|
|
71
|
+
dun posts list --status scheduled --from 2026-12-08 --to 2026-12-15 --sort scheduled_asc
|
|
57
72
|
dun posts get <id>
|
|
58
73
|
dun posts validate --accounts <id> --text "..." [--media id] [--meta '{...}']
|
|
59
74
|
dun posts schedule --text "..." --accounts <id,id> (--at ISO | --in 2h) [--media id,id] [--meta '{...}']
|
|
60
75
|
dun posts publish --text "..." --accounts <id,id> [--media id,id] [--meta '{...}'] [--natural] [--wait]
|
|
61
76
|
dun posts reschedule <id> --at ISO|--in 2h [--text "..."] [--media id] [--meta '{...}']
|
|
77
|
+
dun posts update <id> [--text "..."] [--media id] [--meta '{...}'] # edit, keep the time
|
|
62
78
|
dun posts cancel <id>
|
|
63
79
|
dun posts delete <id> [--yes]
|
|
64
80
|
dun posts x-cap
|
|
@@ -71,22 +87,25 @@ ${C("\uD83D\uDCDD","Posts")}
|
|
|
71
87
|
# kinds: self | link | image | video
|
|
72
88
|
# LinkedIn video (no --meta): upload one mp4/mov, then --media ASSET on a LinkedIn or Company Page account
|
|
73
89
|
# Do not mix video + images on LinkedIn.
|
|
90
|
+
# Facebook Pages: text / one link / photos. Images-only. No --meta. Connect in the app.
|
|
91
|
+
|
|
74
92
|
# publish queues async work; without --wait, status scheduled means queued
|
|
75
93
|
|
|
76
|
-
${
|
|
77
|
-
dun drafts list
|
|
94
|
+
${A("\uD83D\uDCC4","Drafts")}
|
|
95
|
+
dun drafts list [--team] # --team: every member's drafts
|
|
78
96
|
dun drafts get <id>
|
|
79
97
|
dun drafts create --text "..." [--platforms x,linkedin] [--accounts id,id]
|
|
80
98
|
dun drafts update <id> --text "..."
|
|
81
99
|
dun drafts delete <id> [--yes]
|
|
82
100
|
|
|
83
|
-
${
|
|
101
|
+
${A("\uD83D\uDDBC️","Media")}
|
|
84
102
|
dun media list
|
|
85
103
|
dun media get <id>
|
|
86
104
|
dun media upload <file> [--alt "..."] # local preflight: images <=8MB, video <=16GB
|
|
105
|
+
dun media alt <id> --text "..." | --clear # set or clear alt text
|
|
87
106
|
dun media delete <id> [--yes]
|
|
88
107
|
|
|
89
|
-
${
|
|
108
|
+
${A("\uD83E\uDDE0","Memory")}
|
|
90
109
|
dun memory collections list
|
|
91
110
|
dun memory collections create --name "..." [--color blue] [--private]
|
|
92
111
|
dun memory collections get <id>
|
|
@@ -97,7 +116,10 @@ ${C("\uD83E\uDDE0","Memory")}
|
|
|
97
116
|
dun memory search --prompt "..." --collections <id,id> [--top-k 5]
|
|
98
117
|
dun memory delete <id> --collection <id> [--yes]
|
|
99
118
|
|
|
100
|
-
${
|
|
119
|
+
${A("\uD83D\uDCC8","Analytics")}
|
|
120
|
+
dun analytics [--days 30] # totals, followers, top posts (PAT scope posts:read)
|
|
121
|
+
|
|
122
|
+
${A("\uD83C\uDF99️","Personalization")}
|
|
101
123
|
# workspace AI voice
|
|
102
124
|
dun personalization get
|
|
103
125
|
dun personalization set --description "..."
|
|
@@ -105,14 +127,14 @@ ${C("\uD83C\uDF99️","Personalization")}
|
|
|
105
127
|
dun personalization set --clear
|
|
106
128
|
# requires PAT scope workspace:write for set (owner/admin)
|
|
107
129
|
|
|
108
|
-
${
|
|
130
|
+
${A("\uD83E\uDDE9","Agent skills")}
|
|
109
131
|
dun skill install <agent|all>
|
|
110
132
|
dun skill list
|
|
111
133
|
dun skill path
|
|
112
134
|
# agents: claude codex cursor pi opencode agents copilot windsurf
|
|
113
135
|
# goose gemini amp grok continue antigravity
|
|
114
136
|
|
|
115
|
-
${
|
|
137
|
+
${A("⬆️","Update")}
|
|
116
138
|
dun update # upgrade to latest from npm
|
|
117
139
|
dun update --check # report only
|
|
118
140
|
dun update --force # reinstall latest even if current
|
|
@@ -122,7 +144,7 @@ ${C("⬆️","Update")}
|
|
|
122
144
|
# disable: --no-update or DUN_UPDATE=0
|
|
123
145
|
# major bumps print: dun update --yes
|
|
124
146
|
|
|
125
|
-
${
|
|
147
|
+
${A("⚙️","Global flags")}
|
|
126
148
|
--json Machine-readable output (default when non-TTY / CI)
|
|
127
149
|
--workspace <id> Override workspace for this command
|
|
128
150
|
--api-url <url> Override API base (default https://api.dunsocial.com)
|
|
@@ -134,14 +156,14 @@ ${C("⚙️","Global flags")}
|
|
|
134
156
|
--help, -h Show help
|
|
135
157
|
--version, -v Show version
|
|
136
158
|
|
|
137
|
-
${
|
|
159
|
+
${A("\uD83C\uDF31","Env")}
|
|
138
160
|
DUN_TOKEN DUN_WORKSPACE_ID DUN_API_URL DUN_CONFIG DUN_JSON=1 DUN_DEBUG=1 DUN_UPDATE=0
|
|
139
161
|
|
|
140
|
-
${
|
|
162
|
+
${A("\uD83D\uDEAA","Exit codes")}
|
|
141
163
|
0 ok | 1 usage | 2 auth | 3 forbidden | 4 validation | 5 not found | 6 rate limit | 7 network | 8 payment
|
|
142
164
|
|
|
143
165
|
Docs: https://dunsocial.com/docs/cli
|
|
144
|
-
`;function
|
|
166
|
+
`;function se(e){return{auth:`dun auth
|
|
145
167
|
|
|
146
168
|
login [--token] Device-code browser login (default) or --token for CI
|
|
147
169
|
logout Clear local config
|
|
@@ -156,6 +178,7 @@ Docs: https://dunsocial.com/docs/cli
|
|
|
156
178
|
dun accounts reddit flairs <subreddit> # alias of dun reddit flairs
|
|
157
179
|
dun accounts pinterest boards # alias of dun pinterest boards
|
|
158
180
|
dun accounts discord channels # alias of dun discord channels
|
|
181
|
+
dun accounts slack channels # alias of dun slack channels
|
|
159
182
|
`,discord:`dun discord
|
|
160
183
|
|
|
161
184
|
channels [--account <id>] List text and announcement channels for the connected Discord server
|
|
@@ -167,6 +190,48 @@ dun posts publish --meta '{"discord":{"channelId":"..."}}'
|
|
|
167
190
|
Example:
|
|
168
191
|
dun discord channels --json
|
|
169
192
|
dun discord channels --account <id> --json
|
|
193
|
+
`,instagram:`dun instagram schedule|publish (alias: dun ig)
|
|
194
|
+
|
|
195
|
+
--account <id> Instagram account (dun accounts list --platform instagram)
|
|
196
|
+
--format <f> feed_image | carousel | reel | story (required)
|
|
197
|
+
--media <id,id> Gallery asset ids (upload with dun media upload)
|
|
198
|
+
--caption "..." Caption
|
|
199
|
+
--alt "..." Alt text (images)
|
|
200
|
+
--collaborators a,b Collaborator usernames
|
|
201
|
+
--cover <assetId> Reel cover image --thumb-offset <ms> Reel cover frame
|
|
202
|
+
--audio-name "..." Name the Reel's original audio
|
|
203
|
+
--no-feed Reel: don't share to the main feed
|
|
204
|
+
schedule: --at ISO | --in 2h publish: [--wait] [--wait-timeout 120]
|
|
205
|
+
|
|
206
|
+
Builds metadata.instagram for you, then runs dun posts schedule|publish.
|
|
207
|
+
|
|
208
|
+
Example:
|
|
209
|
+
dun ig publish --account acc_ig --format reel --media <asset> --caption "Launch day" --wait --json
|
|
210
|
+
`,ig:"Alias of instagram",tiktok:`dun tiktok schedule|publish
|
|
211
|
+
|
|
212
|
+
--account <id> TikTok account
|
|
213
|
+
--media <id> One video asset
|
|
214
|
+
--privacy <p> public | friends | followers | private (required)
|
|
215
|
+
--title "..." Video caption/title
|
|
216
|
+
--no-comments --no-duet --no-stitch
|
|
217
|
+
--cover-ms <n> Cover frame timestamp in ms
|
|
218
|
+
schedule: --at ISO | --in 2h publish: [--wait] [--wait-timeout 120]
|
|
219
|
+
|
|
220
|
+
Builds metadata.tiktok for you, then runs dun posts schedule|publish.
|
|
221
|
+
|
|
222
|
+
Example:
|
|
223
|
+
dun tiktok schedule --account acc_tt --media <asset> --privacy public --title "Behind the scenes" --in 2h --json
|
|
224
|
+
`,slack:`dun slack
|
|
225
|
+
|
|
226
|
+
channels [--account <id>] List public and private channels for the connected Slack team
|
|
227
|
+
|
|
228
|
+
Output fields: id, name, type (public | private)
|
|
229
|
+
Use channel id in
|
|
230
|
+
dun posts publish --meta '{"slack":{"channelId":"..."}}'
|
|
231
|
+
|
|
232
|
+
Example:
|
|
233
|
+
dun slack channels --json
|
|
234
|
+
dun slack channels --account <id> --json
|
|
170
235
|
`,pinterest:`dun pinterest
|
|
171
236
|
|
|
172
237
|
boards List boards for the connected Pinterest account
|
|
@@ -192,12 +257,13 @@ Example:
|
|
|
192
257
|
dun reddit flairs tamilyapping --json
|
|
193
258
|
`,posts:`dun posts
|
|
194
259
|
|
|
195
|
-
list [--status] [--account] [--limit] [--offset]
|
|
260
|
+
list [--status] [--account] [--from ISO] [--to ISO] [--sort created_desc|scheduled_asc|scheduled_desc] [--limit] [--offset]
|
|
196
261
|
get <id>
|
|
197
262
|
validate --accounts --text [--media] [--meta] Dry-run schedule checks (no writes)
|
|
198
263
|
schedule --text --accounts (--at|--in) [--media] [--meta]
|
|
199
264
|
publish --text --accounts [--media] [--meta] [--natural] [--wait] [--wait-timeout 120]
|
|
200
265
|
reschedule <id> (--at|--in) [--text] [--media] [--meta]
|
|
266
|
+
update <id> [--text] [--media] [--meta] edit a scheduled post, keep its time
|
|
201
267
|
cancel <id>
|
|
202
268
|
delete <id> [--yes]
|
|
203
269
|
x-cap
|
|
@@ -214,6 +280,10 @@ Platform metadata (--meta / --metadata / --meta-json):
|
|
|
214
280
|
{"discord":{"channelId":"SNOWFLAKE"}}
|
|
215
281
|
Optional discord fields: channelName
|
|
216
282
|
Discover channel ids with: dun discord channels --json
|
|
283
|
+
Slack (required when publishing to a Slack account):
|
|
284
|
+
{"slack":{"channelId":"C01234567"}}
|
|
285
|
+
Optional slack fields: channelName
|
|
286
|
+
Discover channel ids with: dun slack channels --json
|
|
217
287
|
|
|
218
288
|
Reddit happy path:
|
|
219
289
|
1. dun media upload ./video.mp4 --json # rejects >16GB locally
|
|
@@ -231,13 +301,22 @@ YouTube Shorts only:
|
|
|
231
301
|
Vertical or square video, 3 minutes or less. The uploaded asset must include width, height, and duration
|
|
232
302
|
or publish is rejected (landscape/unknown dimensions will not post as a regular YouTube video).
|
|
233
303
|
|
|
304
|
+
Facebook Pages (limited beta, no --meta):
|
|
305
|
+
1. Connect the Page in the DunSocial dashboard
|
|
306
|
+
2. dun accounts list --platform facebook --json
|
|
307
|
+
3. dun posts publish --accounts ID --text "..." [--media ASSET] --wait --json
|
|
308
|
+
Images only. Text, one link, or photos.
|
|
309
|
+
|
|
234
310
|
Notes:
|
|
235
311
|
- publish without --wait returns status scheduled (queued). Poll get or use --wait.
|
|
236
312
|
- Prefer flairId alone. flairText without flairId always fails.
|
|
237
|
-
`,drafts
|
|
313
|
+
`,drafts:`dun drafts list|get|create|update|delete
|
|
238
314
|
|
|
239
|
-
list
|
|
315
|
+
list [--team] --team lists every member's drafts (author shown); only the author can update or delete`,media:`dun media
|
|
316
|
+
|
|
317
|
+
list|get|upload|alt|delete
|
|
240
318
|
upload <file> [--alt] [--mime]
|
|
319
|
+
alt <id> --text "..." | --clear set or clear alt text
|
|
241
320
|
|
|
242
321
|
Local preflight before upload-url:
|
|
243
322
|
images <= 8MB (jpeg/png/gif/webp)
|
|
@@ -259,7 +338,13 @@ collections delete <id> [--yes]
|
|
|
259
338
|
|
|
260
339
|
Workspace-scoped (not per-user). set requires owner/admin + PAT scope workspace:write.
|
|
261
340
|
Alias: dun voice ...
|
|
262
|
-
`,
|
|
341
|
+
`,analytics:`dun analytics [--days 30]
|
|
342
|
+
|
|
343
|
+
Per-account totals (impressions, likes, comments, shares, clicks, saves),
|
|
344
|
+
followers and the top 10 posts: the same numbers as the dashboard.
|
|
345
|
+
Platforms without analytics show support.supported=false and a reason.
|
|
346
|
+
Requires PAT scope posts:read. Alias: dun stats
|
|
347
|
+
`,stats:"Alias of analytics",voice:"Alias of personalization",skill:`dun skill install <claude|codex|cursor|pi|opencode|agents|copilot|windsurf|goose|gemini|amp|grok|continue|antigravity|all>
|
|
263
348
|
dun skill list
|
|
264
349
|
dun skill path`,update:`dun update
|
|
265
350
|
|
|
@@ -273,53 +358,55 @@ after a successful command. Agents, CI, --json, and npx never auto-update.
|
|
|
273
358
|
Disable with --no-update or DUN_UPDATE=0.
|
|
274
359
|
|
|
275
360
|
Aliases: dun upgrade, dun self-update
|
|
276
|
-
`,upgrade:"Alias of update","self-update":"Alias of update"}[e]??
|
|
277
|
-
`),
|
|
278
|
-
`).map((n)=>n.length))}function
|
|
279
|
-
CLI v${
|
|
280
|
-
`)}import{spawn as
|
|
281
|
-
Next: dun workspace list && dun workspace use <id|slug>`}async function
|
|
282
|
-
${
|
|
361
|
+
`,upgrade:"Alias of update","self-update":"Alias of update"}[e]??oe}var $t=["DunSocial","---------"].join(`
|
|
362
|
+
`),Ee="DunSocial";var zn=xe($t),Jn=xe(Ee);function xe(e){return Math.max(...e.split(`
|
|
363
|
+
`).map((n)=>n.length))}function N(e=process.stderr){if(!e.isTTY)return!1;if(process.env.CI==="true"||process.env.CI==="1")return!1;if(process.env.GITHUB_ACTIONS||process.env.TF_BUILD||process.env.GITLAB_CI)return!1;if(process.env.DUN_JSON==="1")return!1;return!0}function Ne(){return`DunSocial CLI v${U}`}function Re(){return`${Ee}
|
|
364
|
+
CLI v${U}`}var Pt="https://dunsocial.com/docs/cli";function Dt(e){if(!e.token)return"signed_out";if(!e.workspaceId)return"needs_workspace";return"ready"}function Oe(e){let n=Dt(e),t=[`DunSocial CLI v${U}`,""];if(n==="signed_out")t.push("Not signed in.",""," Next: dun auth login");else if(n==="needs_workspace")t.push("Signed in — pick a workspace.",""," Next: dun workspace list"," dun workspace use <slug>");else{let r=e.config.defaultWorkspaceSlug||e.config.defaultWorkspaceName||e.workspaceId||"workspace";t.push(`Ready | workspace: ${r}`,""," Tip: dun accounts list"," dun posts list")}return t.push(""," dun --help all commands",` Docs ${Pt}`,""),t.join(`
|
|
365
|
+
`)}import{spawn as Mt}from"node:child_process";class Le{ctx;constructor(e){this.ctx=e}async request(e){let n=e.method??"GET",t=new URL(e.path.startsWith("http")?e.path:`${this.ctx.apiUrl}${e.path}`);if(e.query)for(let[l,u]of Object.entries(e.query)){if(u===void 0||u===null||u==="")continue;t.searchParams.set(l,String(u))}let r={Accept:"application/json","User-Agent":`dunsocial-cli/${U}`,...e.headers??{}};if(e.auth!==!1)r.Authorization=`Bearer ${y(this.ctx)}`;if(e.workspace)r["X-Workspace-Id"]=I(this.ctx);let a;if(e.body!==void 0)r["Content-Type"]="application/json",a=JSON.stringify(e.body);R(this.ctx.debug,`${n} ${t.toString()}`);let i;try{i=await fetch(t,{method:n,headers:r,body:a})}catch(l){throw new d(`Network error: ${l.message}`,c.NETWORK,{cause:String(l)})}let o=await i.text(),s=null;if(o)try{s=JSON.parse(o)}catch{s=null}if(R(this.ctx.debug,`<- ${i.status}`,{ok:i.ok,bodyPreview:o.slice(0,300)}),!i.ok){let l=s?.error||s?.message||(o?o.slice(0,300):`HTTP ${i.status}`);throw new d(l,Ae(i.status),_t(i.status,s,o))}if(s&&typeof s==="object"&&"success"in s){if(s.success===!1)throw new d(s.error||s.message||"Request failed",c.VALIDATION,s);return s.data}return s??void 0}get(e,n){return this.request({...n,method:"GET",path:e})}post(e,n,t){return this.request({...t,method:"POST",path:e,body:n})}patch(e,n,t){return this.request({...t,method:"PATCH",path:e,body:n})}delete(e,n,t){return this.request({...t,method:"DELETE",path:e,body:n})}}function b(e){return new Le(e)}function _t(e,n,t){if(e===402&&n&&typeof n==="object"){let r=n;return{billingUrl:typeof r.billingUrl==="string"?r.billingUrl:void 0,subscriptionStatus:typeof r.subscriptionStatus==="string"?r.subscriptionStatus:void 0,workspaceSlug:typeof r.workspaceSlug==="string"?r.workspaceSlug:void 0}}return{status:e,body:n??t}}async function $e(e,n,t,r){switch(n){case"login":return jt(e,t);case"logout":return Vt(e);case"whoami":return Bt(e);case"status":return Gt(e);default:throw new d(`Unknown auth command "${n??""}". Try: login, logout, whoami, status`,c.USAGE)}}async function jt(e,n){let t=f(n,"token")||process.env.DUN_TOKEN;if(t)return qt(e,t);return Wt(e,n)}function V(e){if(e)return"Logged in.";return`Logged in.
|
|
366
|
+
Next: dun workspace list && dun workspace use <id|slug>`}async function qt(e,n){let t={...e,token:n},a=await b(t).get("/api/user/profile");if(await D({...e.config,apiUrl:e.apiUrl,token:n,defaultWorkspaceId:e.config.defaultWorkspaceId,defaultWorkspaceSlug:e.config.defaultWorkspaceSlug,defaultWorkspaceName:e.config.defaultWorkspaceName}),!e.json&&N(process.stdout)){p(V(Boolean(e.config.defaultWorkspaceId)),e);return}p({user:{id:a.id,name:a.name,email:a.email},configPath:P(),method:"token",message:V(Boolean(e.config.defaultWorkspaceId))},e)}async function Wt(e,n){let t=b({...e,token:void 0}),r=await t.post("/api/cli/auth/start",{clientName:"dun-cli"},{auth:!1}),a=!w(n,"no-browser");if(!e.json){if(N(process.stderr))process.stderr.write(`
|
|
367
|
+
${Re()}
|
|
283
368
|
|
|
284
369
|
`);else process.stderr.write(`
|
|
285
370
|
DunSocial CLI login
|
|
286
371
|
`),process.stderr.write(`───────────────────
|
|
287
372
|
`);process.stderr.write(`In your browser, open:
|
|
288
|
-
${
|
|
373
|
+
${r.verificationUrlComplete}
|
|
289
374
|
|
|
290
|
-
`),process.stderr.write(`Or go to ${
|
|
291
|
-
`),process.stderr.write(` ${
|
|
375
|
+
`),process.stderr.write(`Or go to ${r.verificationUrl} and enter code:
|
|
376
|
+
`),process.stderr.write(` ${r.userCode}
|
|
292
377
|
|
|
293
378
|
`),process.stderr.write(`Waiting for approval...
|
|
294
|
-
`)}else process.stderr.write(JSON.stringify({ok:!0,phase:"waiting",userCode:
|
|
295
|
-
`);if(a&&process.stdout.isTTY)try{await
|
|
296
|
-
Subscribe: ${t}`:n}function
|
|
379
|
+
`)}else process.stderr.write(JSON.stringify({ok:!0,phase:"waiting",userCode:r.userCode,verificationUrlComplete:r.verificationUrlComplete})+`
|
|
380
|
+
`);if(a&&process.stdout.isTTY)try{await Kt(r.verificationUrlComplete)}catch{}let i=Math.max(3,r.interval||5)*1000,o=Date.now()+(r.expiresIn||900)*1000;while(Date.now()<o){await Ft(i);let s=await t.post("/api/cli/auth/poll",{deviceCode:r.deviceCode},{auth:!1});if(s.status==="pending")continue;if(s.status==="expired")throw new d("Login expired. Run dun auth login again.",c.AUTH);if(s.status==="denied")throw new d("Login was denied in the browser.",c.AUTH);if(s.status==="approved"){let l=s.token,u={...e,token:l},m=b(u),g=await m.get("/api/user/profile"),h={...e.config,apiUrl:e.apiUrl,token:l,defaultWorkspaceId:s.workspaceId||e.config.defaultWorkspaceId,defaultWorkspaceSlug:e.config.defaultWorkspaceSlug,defaultWorkspaceName:e.config.defaultWorkspaceName};if(s.workspaceId)try{let E=(await m.get("/api/workspaces")).find((kt)=>kt.id===s.workspaceId);if(E)h.defaultWorkspaceId=E.id,h.defaultWorkspaceSlug=E.slug,h.defaultWorkspaceName=E.name}catch{}await D(h);let k=Boolean(h.defaultWorkspaceId);if(!e.json&&N(process.stdout)){p(V(k),e);return}p({user:{id:g.id,name:g.name,email:g.email},workspaceId:h.defaultWorkspaceId??null,configPath:P(),method:"device",message:V(k)},e);return}}throw new d("Login timed out. Run dun auth login again.",c.AUTH)}async function Vt(e){if(await Te(),!e.json&&N(process.stdout)){p("Logged out. Config cleared.",e);return}p({message:"Logged out. Config cleared.",configPath:P()},e)}async function Bt(e){y(e);let t=await b(e).get("/api/user/profile");p({id:t.id,name:t.name,email:t.email,image:t.image??null,apiUrl:e.apiUrl,workspaceId:e.workspaceId??null},e)}async function Gt(e){let n=Boolean(e.token),t=null,r=null;if(n)try{t=await b(e).get("/api/user/profile")}catch(a){r=a instanceof Error?a.message:String(a)}p({authenticated:Boolean(t),tokenPresent:n,apiUrl:e.apiUrl,workspaceId:e.workspaceId??null,workspaceSlug:e.config.defaultWorkspaceSlug??null,workspaceName:e.config.defaultWorkspaceName??null,configPath:P(),user:t?{id:t.id,name:t.name,email:t.email}:null,error:r},e)}function Ft(e){return new Promise((n)=>setTimeout(n,e))}async function Kt(e){let n=process.platform,t=n==="darwin"?["open",e]:n==="win32"?["cmd","/c","start","",e]:["xdg-open",e];await new Promise((r,a)=>{let i=Mt(t[0],t.slice(1),{stdio:"ignore",windowsHide:!0});i.on("error",a),i.on("close",()=>r())})}function Pe(e){return{id:e.id,name:e.name,slug:e.slug,role:e.role,timezone:e.timezone,plan:e.subscription?.planName??null,status:e.subscription?.status??null,hasAccess:e.subscription?.hasAccess??null,accessMessage:e.subscription?.accessMessage??null,billingUrl:e.subscription?.billingUrl??null,cancelAtPeriodEnd:e.subscription?.cancelAtPeriodEnd??null,currentPeriodEnd:e.subscription?.currentPeriodEnd??null}}function Ht(e){return e?.hasAccess===!1}function zt(e){if(!Ht(e.subscription))return null;let n=e.subscription?.accessMessage??`Workspace "${e.name}" is not on a paid plan.`,t=e.subscription?.billingUrl;return t?`${n}
|
|
381
|
+
Subscribe: ${t}`:n}function Jt(){return"Every workspace is unpaid. Open a billing URL above — posts and drafts stay locked until you subscribe."}function L(e,n){if(n.json||!process.stdout.isTTY)return;let t=e.map((r)=>zt(r)).filter((r)=>Boolean(r));if(t.length===0)return;if(process.stdout.write(`${t.join(`
|
|
297
382
|
`)}
|
|
298
|
-
`),t.length===e.length&&e.length>0)process.stdout.write(`${
|
|
299
|
-
`)}async function Le(e,n,t,i){y(e);let a=b(e);switch(n){case"list":case"ls":{let r=await a.get("/api/workspaces");p(r.map(Re),{...e,emptyMessage:"No workspaces yet."}),L(r,e);return}case"use":{let r=i[0];if(!r)throw new d("Usage: dun workspace use <id|slug>",c.USAGE);let o=(await a.get("/api/workspaces")).find((l)=>l.id===r||l.slug===r);if(!o)throw new d(`Workspace not found: ${r}. Run dun workspace list`,c.NOT_FOUND);await P({...e.config,apiUrl:e.apiUrl,token:e.token,defaultWorkspaceId:o.id,defaultWorkspaceSlug:o.slug,defaultWorkspaceName:o.name}),p({id:o.id,name:o.name,slug:o.slug,role:o.role,hasAccess:o.subscription?.hasAccess??null,accessMessage:o.subscription?.accessMessage??null,billingUrl:o.subscription?.billingUrl??null,message:`Default workspace set to ${o.name}`},e),L([o],e);return}case"current":{if(!e.workspaceId&&!e.config.defaultWorkspaceId)throw new d("No workspace selected. Run dun workspace use <id|slug>",c.VALIDATION);let r=e.workspaceId||e.config.defaultWorkspaceId;try{let o=(await a.get("/api/workspaces")).find((l)=>l.id===r||l.slug===r);if(o){p({id:o.id,name:o.name,slug:o.slug,role:o.role,timezone:o.timezone,hasAccess:o.subscription?.hasAccess??null,accessMessage:o.subscription?.accessMessage??null,billingUrl:o.subscription?.billingUrl??null},e),L([o],e);return}}catch{}p({id:r,name:e.config.defaultWorkspaceName??null,slug:e.config.defaultWorkspaceSlug??null},e);return}default:throw new d(`Unknown workspace command "${n??""}". Try: list, use, current`,c.USAGE)}}async function $e(e,n,t,i){y(e),I(e);let a=b(e);switch(n){case void 0:case"list":case"ls":{let r=await a.get("/api/social-accounts",{workspace:!0}),s=f(t,"platform","p")?.toLowerCase(),o=s?r.filter((l)=>{let u=(l.providerName||"").toLowerCase();return({x:["x","twitter"],twitter:["x","twitter"],linkedin:["linkedin"],"linkedin-business":["linkedin business","linkedin-business","linkedin_business"],bluesky:["bluesky"],threads:["threads"],reddit:["reddit"],pinterest:["pinterest"],instagram:["instagram"],youtube:["youtube"],tiktok:["tiktok"],discord:["discord"]}[s]??[s]).some((w)=>u.includes(w))}):r;p(o.map((l)=>({id:l.id,providerName:l.providerName,username:l.username??null,displayName:l.displayName??null,isConnected:l.isConnected,expiresAt:l.expiresAt??null})),{...e,emptyMessage:s?`No ${s} accounts connected. Connect one in the DunSocial dashboard.`:"No accounts connected. Connect one in the DunSocial dashboard."});try{let l=await a.get(`/api/workspaces/${I(e)}`,{workspace:!0});L([l],e)}catch{}return}default:throw new d(`Unknown accounts command "${n}". Try: list (or: dun accounts reddit flairs <subreddit>)`,c.USAGE)}}import{readFileSync as Ht}from"node:fs";var Ft=/^(\d+)\s*(s|sec|secs|second|seconds|m|min|mins|minute|minutes|h|hr|hrs|hour|hours|d|day|days|w|week|weeks)$/i;function oe(e,n=new Date){let t=e.trim();if(!t)throw new d("Empty time value",c.VALIDATION);let i=t.match(Ft);if(i){let s=Number(i[1]),o=i[2].toLowerCase(),l=Kt(o)*s;return new Date(n.getTime()+l)}let a=t.match(/^in\s+(.+)$/i);if(a)return oe(a[1],n);let r=new Date(t);if(Number.isNaN(r.getTime()))throw new d(`Invalid time "${e}". Use ISO-8601 (2026-06-01T09:00:00Z) or relative (2h, 30m, 1d).`,c.VALIDATION);return r}function Kt(e){switch(e){case"s":case"sec":case"secs":case"second":case"seconds":return 1000;case"m":case"min":case"mins":case"minute":case"minutes":return 60000;case"h":case"hr":case"hrs":case"hour":case"hours":return 3600000;case"d":case"day":case"days":return 86400000;case"w":case"week":case"weeks":return 604800000;default:throw new d(`Unknown time unit: ${e}`,c.VALIDATION)}}function V(e){if(e.at&&e.in)throw new d("Pass only one of --at or --in",c.VALIDATION);if(e.at)return oe(e.at).toISOString();if(e.in)return oe(e.in).toISOString();throw new d("Schedule time required. Pass --at <iso> or --in <duration> (e.g. 2h).",c.VALIDATION)}function De(e){if(!e)return[];return e.split(",").map((n)=>n.trim()).filter(Boolean)}function se(e,n){let t=f(e,"text","content","c","t");if(t)return t;let i=n?.reddit;if(i&&typeof i==="object"&&!Array.isArray(i)&&typeof i.title==="string"&&i.title.trim())return i.title.trim();throw new d("Missing --text",c.VALIDATION)}function B(e){let n=E(e,"accounts","account","a")??De(f(e,"accounts","account","a"));if(!n||n.length===0)throw new d("Missing --accounts <id,id>",c.VALIDATION);return n}function G(e){return E(e,"media","media-urls")??De(f(e,"media","media-urls"))}function zt(e,n){if(e?.reddit)return!0;return n.some((t)=>t.toLowerCase().includes("reddit"))}function Jt(e){let n=e.existing.metadata&&typeof e.existing.metadata==="object"&&!Array.isArray(e.existing.metadata)?e.existing.metadata:{};return{scheduledAt:e.scheduledAt,content:e.text??e.existing.content,mediaUrls:e.media&&e.media.length>0?e.media:e.existing.mediaUrls,metadata:e.meta?{...n,...e.meta}:n}}function O(e){let n=f(e,"meta","metadata","meta-json");if(!n)return;try{let t=JSON.parse(n);if(!t||typeof t!=="object"||Array.isArray(t))throw Error("metadata must be a JSON object");return t}catch(t){throw new d(`Invalid --meta JSON: ${t.message}`,c.VALIDATION)}}var Yt=new Set(["published","failed","cancelled"]);async function Xt(e){await new Promise((n)=>setTimeout(n,e))}async function Zt(e,n,t,i){let a=Date.now()+i*1000,r=new Map,s=1500;while(r.size<t.length){if(Date.now()>a){let u=t.filter((m)=>!r.has(m.id)).map((m)=>m.id);throw new d(`Timed out waiting for publish after ${i}s. Still pending: ${u.join(", ")}. Poll with: dun posts get <id> --json`,c.NETWORK,{pending:u})}for(let u of t){if(r.has(u.id))continue;let m=await e.get(`/api/posts/${u.id}`,{workspace:!0});if(R(n.debug,`wait status ${u.id}=${m.status}`),Yt.has(m.status))r.set(u.id,m)}if(r.size>=t.length)break;await Xt(s),s=Math.min(s*1.4,8000)}let o=t.map((u)=>r.get(u.id)),l=o.filter((u)=>u.status==="failed");if(l.length>0){let u=l.map((m)=>`${m.id}: ${m.error||"publish failed"}`).join("; ");throw new d(`Publish failed — ${u}`,c.VALIDATION,{posts:o})}return o}async function Oe(e,n,t){if(t.meta?.reddit){await ae(e,{accounts:n,text:t.text,media:t.media,meta:t.meta});return}let i=await e.get("/api/social-accounts",{workspace:!0}),a=n.map((r)=>i.find((o)=>o.id===r)?.providerName||"");if(!zt(t.meta,a))return;await ae(e,{accounts:n,text:t.text,media:t.media,meta:t.meta})}async function ae(e,n){let t=[],i=n.meta?.reddit??null;if(!i||typeof i!=="object")throw new d("Reddit accounts require --meta with a reddit object, e.g. "+`--meta '{"reddit":{"subreddit":"…","kind":"self","title":"…","flairId":"…"}}'`,c.VALIDATION);let a=(i.subreddit??"").trim().replace(/^\/?r\//i,""),r=(i.title??"").trim(),s=(i.kind??"").trim(),o=(i.flairId??"").trim(),l=(i.flairText??"").trim();if(!a)throw new d("metadata.reddit.subreddit is required",c.VALIDATION);if(!r)throw new d("metadata.reddit.title is required",c.VALIDATION);if(r.length>300)throw new d(`Reddit title exceeds 300 characters: ${r.length}/300`,c.VALIDATION);if(!["self","link","image","video"].includes(s))throw new d("metadata.reddit.kind must be one of: self, link, image, video",c.VALIDATION);if(t.push(`kind=${s}`),t.push(`titleLength=${r.length}`),l&&!o)throw new d(`Can't set flairText without flairId for r/${a}. Run: dun reddit flairs ${a} --json`,c.VALIDATION);if(s==="link"){if(!i.url?.trim())throw new d("Reddit link posts require metadata.reddit.url",c.VALIDATION);try{new URL(i.url)}catch{throw new d("metadata.reddit.url is invalid",c.VALIDATION)}if(n.media.length>0)throw new d("Reddit link posts do not accept --media",c.VALIDATION)}else if(s==="image"||s==="video"){if(n.media.length!==1)throw new d(`Reddit ${s} posts require exactly one --media asset id`,c.VALIDATION)}else if(n.media.length>0)throw new d("Reddit self posts do not accept --media. Use kind image or video.",c.VALIDATION);let u=await e.get("/api/social-accounts/reddit/post-requirements",{workspace:!0,query:{subreddit:a}});if(t.push("fetched post-requirements"),u?.is_flair_required&&!o)throw new d(`r/${a} requires post flair. Discover ids with: dun reddit flairs ${a} --json`,c.VALIDATION);let m=u?.title_text_max_length??300;if(r.length>m)throw new d(`Reddit title too long for r/${a}: ${r.length}/${m}`,c.VALIDATION);if(u?.title_text_min_length&&r.length<u.title_text_min_length)throw new d(`Reddit title must be at least ${u.title_text_min_length} characters`,c.VALIDATION);if(o){let g=await e.get("/api/social-accounts/reddit/flair-options",{workspace:!0,query:{subreddit:a}});t.push(`fetched ${g.choices?.length??0} flairs`);let w=(g.choices??[]).find((k)=>k.id===o);if(!w)throw new d(`Unknown flairId "${o}" for r/${a}. Run: dun reddit flairs ${a} --json`,c.VALIDATION);if(w.textEditable===!1&&l&&l!==w.text)throw new d(`Customization not allowed for this flair template. Use flairId "${w.id}" alone`+(w.text?` (template text: "${w.text}")`:""),c.VALIDATION);t.push(`flairId=${w.id}`)}return{ok:!0,checks:t,reddit:{subreddit:a,kind:s,title:r,flairId:o||null,accounts:n.accounts,media:n.media,textPreview:n.text?.slice(0,120)??null,requirements:{is_flair_required:u?.is_flair_required??!1,title_text_max_length:m}}}}async function Pe(e,n,t,i){y(e),I(e);let a=b(e);switch(n){case"list":case"ls":{let r=await a.get("/api/posts",{workspace:!0,query:{status:f(t,"status","s"),socialAccountId:f(t,"account","social-account"),groupId:f(t,"group"),limit:U(t,"limit")??50,offset:U(t,"offset")??0}});p(r,{...e,emptyMessage:"No posts yet. Schedule one with dun posts schedule."});return}case"get":{let r=i[0];if(!r)throw new d("Usage: dun posts get <id>",c.USAGE);let s=await a.get(`/api/posts/${r}`,{workspace:!0});p(s,e);return}case"validate":{let r=B(t),s=G(t),o=O(t)??{},l=se(t,o),u=await a.post("/api/posts/validate",{content:l,socialAccountIds:r,mediaUrls:s,metadata:o},{workspace:!0});if(!u.valid){let w=u.issues.map((k)=>k.next?`${k.message} ${k.next}`:k.message).join("; ");throw new d(w||"Post validation failed",c.VALIDATION,u)}let m=Boolean(o.reddit),g=m;if(!m){let w=await a.get("/api/social-accounts",{workspace:!0});g=r.some((k)=>(w.find((N)=>N.id===k)?.providerName||"").toLowerCase().includes("reddit"))}if(g){let w=await ae(a,{accounts:r,text:l,media:s,meta:o});p({ok:!0,...u,reddit:w},e);return}p({ok:!0,...u},e);return}case"schedule":{let r=O(t)??{},s=se(t,r),o=B(t),l=G(t);await Oe(a,o,{text:s,media:l,meta:r});let u=V({at:f(t,"at"),in:f(t,"in")}),m=await a.post("/api/posts/schedule",{content:s,socialAccountIds:o,scheduledAt:u,mediaUrls:l,metadata:r},{workspace:!0});p(m,e);return}case"publish":case"publish-now":{let r=O(t)??{},s=se(t,r),o=B(t),l=G(t);await Oe(a,o,{text:s,media:l,meta:r});let u=await a.post("/api/posts/publish-now",{content:s,socialAccountIds:o,mediaUrls:l,metadata:r,naturalPosting:h(t,"natural","natural-posting")},{workspace:!0});if(!h(t,"wait")){p(u,e);return}let g=Array.isArray(u)?u:[];if(g.length===0||!g.every((v)=>typeof v?.id==="string"))throw new d("publish --wait expected an array of created posts with ids",c.NETWORK,{data:u});let w=U(t,"wait-timeout","timeout")??120,k=await Zt(a,e,g,w);p({queued:g,posts:k,status:k.every((v)=>v.status==="published")?"published":k[0]?.status},e);return}case"reschedule":{let r=i[0];if(!r)throw new d("Usage: dun posts reschedule <id> --at|--in",c.USAGE);let s=V({at:f(t,"at"),in:f(t,"in")}),o=await a.get(`/api/posts/${r}`,{workspace:!0}),l=Jt({scheduledAt:s,text:f(t,"text","content","c","t"),media:G(t),meta:O(t),existing:o}),u=await a.post(`/api/posts/${r}/reschedule`,l,{workspace:!0});p(u,e);return}case"cancel":{let r=i[0];if(!r)throw new d("Usage: dun posts cancel <id>",c.USAGE);let s=await a.post(`/api/posts/${r}/cancel`,void 0,{workspace:!0});p(s??{id:r,status:"cancelled"},e);return}case"delete":case"rm":{let r=i[0];if(!r)throw new d("Usage: dun posts delete <id> [--yes]",c.USAGE);if(!e.yes&&!h(t,"yes","y"))throw new d("Refusing to delete without --yes (or CI/yes mode)",c.VALIDATION);let s=await a.delete(`/api/posts/${r}`,void 0,{workspace:!0});p(s??{id:r,deleted:!0},e);return}case"x-cap":case"xcap":{let r=await a.get("/api/posts/x-cap-usage",{workspace:!0});p(r,e);return}case"schedule-thread":case"publish-thread":case"publish-thread-now":{let r=f(t,"file","f"),s=f(t,"account","accounts","a")??B(t)[0];if(!s)throw new d("Missing --account <xAccountId>",c.VALIDATION);let o;if(r){let u;try{u=Ht(r,"utf8")}catch(g){throw new d(`Could not read file: ${g.message}`,c.VALIDATION)}let m=JSON.parse(u);if(Array.isArray(m))o=m;else if(m&&typeof m==="object"&&Array.isArray(m.tweets))o=m.tweets;else throw new d("Thread file must be an array of tweets or { tweets: [] }",c.VALIDATION)}else{let u=f(t,"text","content");if(!u)throw new d('Provide --file thread.json (array of {content}) or --text "tweet1||tweet2"',c.VALIDATION);o=u.split("||").map((m)=>({content:m.trim()})).filter((m)=>m.content)}if(o.length<2)throw new d("Threads require at least 2 tweets",c.VALIDATION);if(n==="schedule-thread"){let u=V({at:f(t,"at"),in:f(t,"in")}),m=await a.post("/api/posts/schedule-thread",{socialAccountId:s,tweets:o,scheduledAt:u,metadata:O(t)??{}},{workspace:!0});p(m,e);return}let l=await a.post("/api/posts/publish-thread-now",{socialAccountId:s,tweets:o,metadata:O(t)??{}},{workspace:!0});p(l,e);return}default:throw new d(`Unknown posts command "${n??""}". Try: list, get, validate, schedule, publish, reschedule, cancel, delete, x-cap, schedule-thread, publish-thread`,c.USAGE)}}async function _e(e,n,t,i){y(e),I(e);let a=b(e);switch(n){case"list":case"ls":{let r=await a.get("/api/drafts",{workspace:!0,query:{limit:U(t,"limit")??50,offset:U(t,"offset")??0}});p(r,{...e,emptyMessage:'No drafts yet. Create one with dun drafts create --text "..."'});return}case"get":{let r=i[0];if(!r)throw new d("Usage: dun drafts get <id>",c.USAGE);let s=await a.get(`/api/drafts/${r}`,{workspace:!0});p(s,e);return}case"create":{let r=f(t,"text","content","c","t");if(!r)throw new d("Missing --text",c.VALIDATION);let s=await a.post("/api/drafts",{content:r,name:f(t,"name","n"),socialAccountIds:E(t,"accounts","account","a")??[],selectedPlatforms:E(t,"platforms","platform","p")??[],mediaUrls:E(t,"media")??[]},{workspace:!0});p(s,e);return}case"update":{let r=i[0];if(!r)throw new d("Usage: dun drafts update <id> --text ...",c.USAGE);let s={id:r},o=f(t,"text","content","c","t");if(o)s.content=o;let l=f(t,"name","n");if(l!==void 0)s.name=l;let u=E(t,"accounts","account","a");if(u)s.socialAccountIds=u;let m=E(t,"platforms","platform","p");if(m)s.selectedPlatforms=m;let g=E(t,"media");if(g)s.mediaUrls=g;let w=await a.patch(`/api/drafts/${r}`,s,{workspace:!0});p(w,e);return}case"delete":case"rm":{let r=i[0];if(!r)throw new d("Usage: dun drafts delete <id> [--yes]",c.USAGE);if(!e.yes&&!h(t,"yes","y"))throw new d("Refusing to delete without --yes",c.VALIDATION);let s=await a.delete(`/api/drafts/${r}`,void 0,{workspace:!0});p(s??{id:r,deleted:!0},e);return}default:throw new d(`Unknown drafts command "${n??""}". Try: list, get, create, update, delete`,c.USAGE)}}import{readFileSync as Qt,existsSync as en,statSync as tn}from"node:fs";import{basename as nn}from"node:path";var je=["image/jpeg","image/png","image/gif","image/webp"],Me=["video/mp4","video/quicktime","video/webm"];function ce(e){if(e<1024)return`${e}B`;if(e<1048576)return`${(e/1024).toFixed(1)}KB`;if(e<1073741824)return`${(e/1048576).toFixed(1)}MB`;let n=e/1073741824;return Number.isInteger(n)?`${n}GB`:`${n.toFixed(1)}GB`}function We(e){let{mimeType:n,fileSize:t}=e,i=je.includes(n),a=Me.includes(n);if(!i&&!a)return{ok:!1,message:`Unsupported MIME type "${n}". Allowed images: ${je.join(", ")}; videos: ${Me.join(", ")}`};if(a&&t>17179869184)return{ok:!1,message:`Video files must be less than ${ce(17179869184)} (got ${ce(t)}). Compress first, e.g.:
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
Example: dun
|
|
303
|
-
Example: dun
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
383
|
+
`),t.length===e.length&&e.length>0)process.stdout.write(`${Jt()}
|
|
384
|
+
`)}async function De(e,n,t,r){y(e);let a=b(e);switch(n){case"list":case"ls":{let i=await a.get("/api/workspaces");p(i.map(Pe),{...e,emptyMessage:"No workspaces yet."}),L(i,e);return}case"use":{let i=r[0];if(!i)throw new d("Usage: dun workspace use <id|slug>",c.USAGE);let s=(await a.get("/api/workspaces")).find((l)=>l.id===i||l.slug===i);if(!s)throw new d(`Workspace not found: ${i}. Run dun workspace list`,c.NOT_FOUND);await D({...e.config,apiUrl:e.apiUrl,token:e.token,defaultWorkspaceId:s.id,defaultWorkspaceSlug:s.slug,defaultWorkspaceName:s.name}),p({id:s.id,name:s.name,slug:s.slug,role:s.role,hasAccess:s.subscription?.hasAccess??null,accessMessage:s.subscription?.accessMessage??null,billingUrl:s.subscription?.billingUrl??null,message:`Default workspace set to ${s.name}`},e),L([s],e);return}case"current":{if(!e.workspaceId&&!e.config.defaultWorkspaceId)throw new d("No workspace selected. Run dun workspace use <id|slug>",c.VALIDATION);let i=e.workspaceId||e.config.defaultWorkspaceId;try{let s=(await a.get("/api/workspaces")).find((l)=>l.id===i||l.slug===i);if(s){p({id:s.id,name:s.name,slug:s.slug,role:s.role,timezone:s.timezone,hasAccess:s.subscription?.hasAccess??null,accessMessage:s.subscription?.accessMessage??null,billingUrl:s.subscription?.billingUrl??null},e),L([s],e);return}}catch{}p({id:i,name:e.config.defaultWorkspaceName??null,slug:e.config.defaultWorkspaceSlug??null},e);return}default:throw new d(`Unknown workspace command "${n??""}". Try: list, use, current`,c.USAGE)}}async function _e(e,n,t,r){y(e),I(e);let a=b(e);switch(n){case void 0:case"list":case"ls":{let i=await a.get("/api/social-accounts",{workspace:!0}),o=f(t,"platform","p")?.toLowerCase(),s=o?i.filter((l)=>{let u=(l.providerName||"").toLowerCase();return({x:["x","twitter"],twitter:["x","twitter"],linkedin:["linkedin"],"linkedin-business":["linkedin business","linkedin-business","linkedin_business"],bluesky:["bluesky"],threads:["threads"],reddit:["reddit"],pinterest:["pinterest"],instagram:["instagram"],youtube:["youtube"],tiktok:["tiktok"],discord:["discord"],slack:["slack"],facebook:["facebook"],fb:["facebook"],"facebook-page":["facebook"]}[o]??[o]).some((h)=>u.includes(h))}):i;p(s.map((l)=>({id:l.id,providerName:l.providerName,username:l.username??null,displayName:l.displayName??null,isConnected:l.isConnected,needsReconnect:l.needsReconnect??!1,expiresAt:l.expiresAt??null})),{...e,emptyMessage:o?`No ${o} accounts connected. Connect one in the DunSocial dashboard.`:"No accounts connected. Connect one in the DunSocial dashboard."});try{let l=await a.get(`/api/workspaces/${I(e)}`,{workspace:!0});L([l],e)}catch{}return}default:throw new d(`Unknown accounts command "${n}". Try: list (or: dun accounts reddit flairs <subreddit>)`,c.USAGE)}}import{readFileSync as Zt}from"node:fs";var Yt=/^(\d+)\s*(s|sec|secs|second|seconds|m|min|mins|minute|minutes|h|hr|hrs|hour|hours|d|day|days|w|week|weeks)$/i;function ae(e,n=new Date){let t=e.trim();if(!t)throw new d("Empty time value",c.VALIDATION);let r=t.match(Yt);if(r){let o=Number(r[1]),s=r[2].toLowerCase(),l=Xt(s)*o;return new Date(n.getTime()+l)}let a=t.match(/^in\s+(.+)$/i);if(a)return ae(a[1],n);let i=new Date(t);if(Number.isNaN(i.getTime()))throw new d(`Invalid time "${e}". Use ISO-8601 (2026-06-01T09:00:00Z) or relative (2h, 30m, 1d).`,c.VALIDATION);return i}function Xt(e){switch(e){case"s":case"sec":case"secs":case"second":case"seconds":return 1000;case"m":case"min":case"mins":case"minute":case"minutes":return 60000;case"h":case"hr":case"hrs":case"hour":case"hours":return 3600000;case"d":case"day":case"days":return 86400000;case"w":case"week":case"weeks":return 604800000;default:throw new d(`Unknown time unit: ${e}`,c.VALIDATION)}}function B(e){if(e.at&&e.in)throw new d("Pass only one of --at or --in",c.VALIDATION);if(e.at)return ae(e.at).toISOString();if(e.in)return ae(e.in).toISOString();throw new d("Schedule time required. Pass --at <iso> or --in <duration> (e.g. 2h).",c.VALIDATION)}function je(e){if(!e)return[];return e.split(",").map((n)=>n.trim()).filter(Boolean)}function ce(e,n){let t=f(e,"text","content","c","t");if(t)return t;let r=n?.reddit;if(r&&typeof r==="object"&&!Array.isArray(r)&&typeof r.title==="string"&&r.title.trim())return r.title.trim();throw new d("Missing --text",c.VALIDATION)}function G(e){let n=v(e,"accounts","account","a")??je(f(e,"accounts","account","a"));if(!n||n.length===0)throw new d("Missing --accounts <id,id>",c.VALIDATION);return n}function _(e){return v(e,"media","media-urls")??je(f(e,"media","media-urls"))}function Qt(e,n){if(e?.reddit)return!0;return n.some((t)=>t.toLowerCase().includes("reddit"))}function en(e){let n=e.existing.metadata&&typeof e.existing.metadata==="object"&&!Array.isArray(e.existing.metadata)?e.existing.metadata:{};return{scheduledAt:e.scheduledAt,content:e.text??e.existing.content,mediaUrls:e.media&&e.media.length>0?e.media:e.existing.mediaUrls,metadata:e.meta?{...n,...e.meta}:n}}function tn(e){let n={id:e.id};if(e.text!==void 0)n.content=e.text;if(e.media&&e.media.length>0)n.mediaUrls=e.media;if(e.meta){let t=e.existingMetadata&&typeof e.existingMetadata==="object"&&!Array.isArray(e.existingMetadata)?e.existingMetadata:{};n.metadata={...t,...e.meta}}return n}function O(e){let n=f(e,"meta","metadata","meta-json");if(!n)return;try{let t=JSON.parse(n);if(!t||typeof t!=="object"||Array.isArray(t))throw Error("metadata must be a JSON object");return t}catch(t){throw new d(`Invalid --meta JSON: ${t.message}`,c.VALIDATION)}}var nn=new Set(["published","failed","cancelled"]);async function rn(e){await new Promise((n)=>setTimeout(n,e))}async function on(e,n,t,r){let a=Date.now()+r*1000,i=new Map,o=1500;while(i.size<t.length){if(Date.now()>a){let u=t.filter((m)=>!i.has(m.id)).map((m)=>m.id);throw new d(`Timed out waiting for publish after ${r}s. Still pending: ${u.join(", ")}. Poll with: dun posts get <id> --json`,c.NETWORK,{pending:u})}for(let u of t){if(i.has(u.id))continue;let m=await e.get(`/api/posts/${u.id}`,{workspace:!0});if(R(n.debug,`wait status ${u.id}=${m.status}`),nn.has(m.status))i.set(u.id,m)}if(i.size>=t.length)break;await rn(o),o=Math.min(o*1.4,8000)}let s=t.map((u)=>i.get(u.id)),l=s.filter((u)=>u.status==="failed");if(l.length>0){let u=l.map((m)=>`${m.id}: ${m.error||"publish failed"}`).join("; ");throw new d(`Publish failed — ${u}`,c.VALIDATION,{posts:s})}return s}async function Me(e,n,t){if(t.meta?.reddit){await de(e,{accounts:n,text:t.text,media:t.media,meta:t.meta});return}let r=await e.get("/api/social-accounts",{workspace:!0}),a=n.map((i)=>r.find((s)=>s.id===i)?.providerName||"");if(!Qt(t.meta,a))return;await de(e,{accounts:n,text:t.text,media:t.media,meta:t.meta})}async function de(e,n){let t=[],r=n.meta?.reddit??null;if(!r||typeof r!=="object")throw new d("Reddit accounts require --meta with a reddit object, e.g. "+`--meta '{"reddit":{"subreddit":"…","kind":"self","title":"…","flairId":"…"}}'`,c.VALIDATION);let a=(r.subreddit??"").trim().replace(/^\/?r\//i,""),i=(r.title??"").trim(),o=(r.kind??"").trim(),s=(r.flairId??"").trim(),l=(r.flairText??"").trim();if(!a)throw new d("metadata.reddit.subreddit is required",c.VALIDATION);if(!i)throw new d("metadata.reddit.title is required",c.VALIDATION);if(i.length>300)throw new d(`Reddit title exceeds 300 characters: ${i.length}/300`,c.VALIDATION);if(!["self","link","image","video"].includes(o))throw new d("metadata.reddit.kind must be one of: self, link, image, video",c.VALIDATION);if(t.push(`kind=${o}`),t.push(`titleLength=${i.length}`),l&&!s)throw new d(`Can't set flairText without flairId for r/${a}. Run: dun reddit flairs ${a} --json`,c.VALIDATION);if(o==="link"){if(!r.url?.trim())throw new d("Reddit link posts require metadata.reddit.url",c.VALIDATION);try{new URL(r.url)}catch{throw new d("metadata.reddit.url is invalid",c.VALIDATION)}if(n.media.length>0)throw new d("Reddit link posts do not accept --media",c.VALIDATION)}else if(o==="image"||o==="video"){if(n.media.length!==1)throw new d(`Reddit ${o} posts require exactly one --media asset id`,c.VALIDATION)}else if(n.media.length>0)throw new d("Reddit self posts do not accept --media. Use kind image or video.",c.VALIDATION);let u=await e.get("/api/social-accounts/reddit/post-requirements",{workspace:!0,query:{subreddit:a}});if(t.push("fetched post-requirements"),u?.is_flair_required&&!s)throw new d(`r/${a} requires post flair. Discover ids with: dun reddit flairs ${a} --json`,c.VALIDATION);let m=u?.title_text_max_length??300;if(i.length>m)throw new d(`Reddit title too long for r/${a}: ${i.length}/${m}`,c.VALIDATION);if(u?.title_text_min_length&&i.length<u.title_text_min_length)throw new d(`Reddit title must be at least ${u.title_text_min_length} characters`,c.VALIDATION);if(s){let g=await e.get("/api/social-accounts/reddit/flair-options",{workspace:!0,query:{subreddit:a}});t.push(`fetched ${g.choices?.length??0} flairs`);let h=(g.choices??[]).find((k)=>k.id===s);if(!h)throw new d(`Unknown flairId "${s}" for r/${a}. Run: dun reddit flairs ${a} --json`,c.VALIDATION);if(h.textEditable===!1&&l&&l!==h.text)throw new d(`Customization not allowed for this flair template. Use flairId "${h.id}" alone`+(h.text?` (template text: "${h.text}")`:""),c.VALIDATION);t.push(`flairId=${h.id}`)}return{ok:!0,checks:t,reddit:{subreddit:a,kind:o,title:i,flairId:s||null,accounts:n.accounts,media:n.media,textPreview:n.text?.slice(0,120)??null,requirements:{is_flair_required:u?.is_flair_required??!1,title_text_max_length:m}}}}async function F(e,n,t,r){y(e),I(e);let a=b(e);switch(n){case"list":case"ls":{let i=await a.get("/api/posts",{workspace:!0,query:{status:f(t,"status","s"),socialAccountId:f(t,"account","social-account"),groupId:f(t,"group"),from:f(t,"from"),to:f(t,"to"),sort:f(t,"sort"),limit:S(t,"limit")??50,offset:S(t,"offset")??0}});p(i,{...e,emptyMessage:"No posts yet. Schedule one with dun posts schedule."});return}case"get":{let i=r[0];if(!i)throw new d("Usage: dun posts get <id>",c.USAGE);let o=await a.get(`/api/posts/${i}`,{workspace:!0});p(o,e);return}case"validate":{let i=G(t),o=_(t),s=O(t)??{},l=ce(t,s),u=await a.post("/api/posts/validate",{content:l,socialAccountIds:i,mediaUrls:o,metadata:s},{workspace:!0});if(!u.valid){let h=u.issues.map((k)=>k.next?`${k.message} ${k.next}`:k.message).join("; ");throw new d(h||"Post validation failed",c.VALIDATION,u)}let m=Boolean(s.reddit),g=m;if(!m){let h=await a.get("/api/social-accounts",{workspace:!0});g=i.some((k)=>(h.find((E)=>E.id===k)?.providerName||"").toLowerCase().includes("reddit"))}if(g){let h=await de(a,{accounts:i,text:l,media:o,meta:s});p({ok:!0,...u,reddit:h},e);return}p({ok:!0,...u},e);return}case"schedule":{let i=O(t)??{},o=ce(t,i),s=G(t),l=_(t);await Me(a,s,{text:o,media:l,meta:i});let u=B({at:f(t,"at"),in:f(t,"in")}),m=await a.post("/api/posts/schedule",{content:o,socialAccountIds:s,scheduledAt:u,mediaUrls:l,metadata:i},{workspace:!0});p(m,e);return}case"publish":case"publish-now":{let i=O(t)??{},o=ce(t,i),s=G(t),l=_(t);await Me(a,s,{text:o,media:l,meta:i});let u=await a.post("/api/posts/publish-now",{content:o,socialAccountIds:s,mediaUrls:l,metadata:i,naturalPosting:w(t,"natural","natural-posting")},{workspace:!0});if(!w(t,"wait")){p(u,e);return}let g=Array.isArray(u)?u:[];if(g.length===0||!g.every((x)=>typeof x?.id==="string"))throw new d("publish --wait expected an array of created posts with ids",c.NETWORK,{data:u});let h=S(t,"wait-timeout","timeout")??120,k=await on(a,e,g,h);p({queued:g,posts:k,status:k.every((x)=>x.status==="published")?"published":k[0]?.status},e);return}case"reschedule":{let i=r[0];if(!i)throw new d("Usage: dun posts reschedule <id> --at|--in",c.USAGE);let o=B({at:f(t,"at"),in:f(t,"in")}),s=await a.get(`/api/posts/${i}`,{workspace:!0}),l=en({scheduledAt:o,text:f(t,"text","content","c","t"),media:_(t),meta:O(t),existing:s}),u=await a.post(`/api/posts/${i}/reschedule`,l,{workspace:!0});p(u,e);return}case"update":case"edit":{let i=r[0];if(!i)throw new d(`Usage: dun posts update <id> [--text "..."] [--media id] [--meta '{...}']`,c.USAGE);let o=f(t,"text","content","c","t"),s=_(t),l=O(t);if(o===void 0&&s.length===0&&!l)throw new d("Nothing to update: pass --text, --media or --meta",c.USAGE);let u=l?await a.get(`/api/posts/${i}`,{workspace:!0}):void 0,m=tn({id:i,text:o,media:s,meta:l,existingMetadata:u?.metadata}),g=await a.patch(`/api/posts/${i}`,m,{workspace:!0});p(g,e);return}case"cancel":{let i=r[0];if(!i)throw new d("Usage: dun posts cancel <id>",c.USAGE);let o=await a.post(`/api/posts/${i}/cancel`,void 0,{workspace:!0});p(o??{id:i,status:"cancelled"},e);return}case"delete":case"rm":{let i=r[0];if(!i)throw new d("Usage: dun posts delete <id> [--yes]",c.USAGE);if(!e.yes&&!w(t,"yes","y"))throw new d("Refusing to delete without --yes (or CI/yes mode)",c.VALIDATION);let o=await a.delete(`/api/posts/${i}`,void 0,{workspace:!0});p(o??{id:i,deleted:!0},e);return}case"x-cap":case"xcap":{let i=await a.get("/api/posts/x-cap-usage",{workspace:!0});p(i,e);return}case"schedule-thread":case"publish-thread":case"publish-thread-now":{let i=f(t,"file","f"),o=f(t,"account","accounts","a")??G(t)[0];if(!o)throw new d("Missing --account <xAccountId>",c.VALIDATION);let s;if(i){let u;try{u=Zt(i,"utf8")}catch(g){throw new d(`Could not read file: ${g.message}`,c.VALIDATION)}let m=JSON.parse(u);if(Array.isArray(m))s=m;else if(m&&typeof m==="object"&&Array.isArray(m.tweets))s=m.tweets;else throw new d("Thread file must be an array of tweets or { tweets: [] }",c.VALIDATION)}else{let u=f(t,"text","content");if(!u)throw new d('Provide --file thread.json (array of {content}) or --text "tweet1||tweet2"',c.VALIDATION);s=u.split("||").map((m)=>({content:m.trim()})).filter((m)=>m.content)}if(s.length<2)throw new d("Threads require at least 2 tweets",c.VALIDATION);if(n==="schedule-thread"){let u=B({at:f(t,"at"),in:f(t,"in")}),m=await a.post("/api/posts/schedule-thread",{socialAccountId:o,tweets:s,scheduledAt:u,metadata:O(t)??{}},{workspace:!0});p(m,e);return}let l=await a.post("/api/posts/publish-thread-now",{socialAccountId:o,tweets:s,metadata:O(t)??{}},{workspace:!0});p(l,e);return}default:throw new d(`Unknown posts command "${n??""}". Try: list, get, validate, schedule, publish, reschedule, update, cancel, delete, x-cap, schedule-thread, publish-thread`,c.USAGE)}}async function qe(e,n,t,r){y(e),I(e);let a=b(e);switch(n){case"list":case"ls":{let i=await a.get("/api/drafts",{workspace:!0,query:{scope:w(t,"team")?"workspace":void 0,limit:S(t,"limit")??50,offset:S(t,"offset")??0}});p(i,{...e,emptyMessage:'No drafts yet. Create one with dun drafts create --text "..."'});return}case"get":{let i=r[0];if(!i)throw new d("Usage: dun drafts get <id>",c.USAGE);let o=await a.get(`/api/drafts/${i}`,{workspace:!0});p(o,e);return}case"create":{let i=f(t,"text","content","c","t");if(!i)throw new d("Missing --text",c.VALIDATION);let o=await a.post("/api/drafts",{content:i,name:f(t,"name","n"),socialAccountIds:v(t,"accounts","account","a")??[],selectedPlatforms:v(t,"platforms","platform","p")??[],mediaUrls:v(t,"media")??[]},{workspace:!0});p(o,e);return}case"update":{let i=r[0];if(!i)throw new d("Usage: dun drafts update <id> --text ...",c.USAGE);let o={id:i},s=f(t,"text","content","c","t");if(s)o.content=s;let l=f(t,"name","n");if(l!==void 0)o.name=l;let u=v(t,"accounts","account","a");if(u)o.socialAccountIds=u;let m=v(t,"platforms","platform","p");if(m)o.selectedPlatforms=m;let g=v(t,"media");if(g)o.mediaUrls=g;let h=await a.patch(`/api/drafts/${i}`,o,{workspace:!0});p(h,e);return}case"delete":case"rm":{let i=r[0];if(!i)throw new d("Usage: dun drafts delete <id> [--yes]",c.USAGE);if(!e.yes&&!w(t,"yes","y"))throw new d("Refusing to delete without --yes",c.VALIDATION);let o=await a.delete(`/api/drafts/${i}`,void 0,{workspace:!0});p(o??{id:i,deleted:!0},e);return}default:throw new d(`Unknown drafts command "${n??""}". Try: list, get, create, update, delete`,c.USAGE)}}var We=["feed_image","carousel","reel","story"],K={public:"PUBLIC_TO_EVERYONE",friends:"MUTUAL_FOLLOW_FRIENDS",followers:"FOLLOWER_OF_CREATOR",private:"SELF_ONLY"};function sn(e){let n=f(e,"format","f");if(!n||!We.includes(n))throw new d(`Missing or invalid --format. Use one of: ${We.join(", ")}`,c.VALIDATION);let t=f(e,"caption","text","t")??"",r={format:n,caption:t,shareToFeed:!w(e,"no-feed"),collaborators:v(e,"collaborators","collaborator")??[]},a=f(e,"alt","alt-text");if(a)r.altText=a;let i=f(e,"cover");if(i)r.coverMediaAssetId=i;let o=S(e,"thumb-offset");if(o!==void 0)r.thumbOffset=o;let s=f(e,"audio-name");if(s)r.audioName=s;return{content:t||"Instagram media post",meta:{instagram:r}}}function an(e){let n=f(e,"privacy","p"),t=n&&n in K?K[n]:Object.values(K).find((o)=>o===n);if(!t)throw new d(`Missing or invalid --privacy. Use one of: ${Object.keys(K).join(", ")}`,c.VALIDATION);let r=f(e,"title","text","t")??"",a={title:r,privacyLevel:t,disableComment:w(e,"no-comments"),disableDuet:w(e,"no-duet"),disableStitch:w(e,"no-stitch")},i=S(e,"cover-ms");if(i!==void 0)a.videoCoverTimestampMs=i;return{content:r||"TikTok video",meta:{tiktok:a}}}async function le(e,n,t,r,a){if(t!=="schedule"&&t!=="publish"&&t!=="publish-now")throw new d(`Unknown ${e} command "${t??""}". Try: schedule, publish
|
|
385
|
+
Run: dun ${e} --help`,c.USAGE);if(f(r,"meta","metadata","meta-json"))throw new d(`dun ${e} builds --meta for you. Use dun posts ${t} --meta for raw JSON.`,c.USAGE);let{content:i,meta:o}=e==="instagram"?sn(r):an(r);await F(n,t,{...r,text:i,meta:JSON.stringify(o)},a)}import{readFileSync as cn,existsSync as dn,statSync as ln}from"node:fs";import{basename as un}from"node:path";var Ve=["image/jpeg","image/png","image/gif","image/webp"],Be=["video/mp4","video/quicktime","video/webm"];function ue(e){if(e<1024)return`${e}B`;if(e<1048576)return`${(e/1024).toFixed(1)}KB`;if(e<1073741824)return`${(e/1048576).toFixed(1)}MB`;let n=e/1073741824;return Number.isInteger(n)?`${n}GB`:`${n.toFixed(1)}GB`}function Ge(e){let{mimeType:n,fileSize:t}=e,r=Ve.includes(n),a=Be.includes(n);if(!r&&!a)return{ok:!1,message:`Unsupported MIME type "${n}". Allowed images: ${Ve.join(", ")}; videos: ${Be.join(", ")}`};if(a&&t>17179869184)return{ok:!1,message:`Video files must be less than ${ue(17179869184)} (got ${ue(t)}). Compress first, e.g.:
|
|
386
|
+
ffmpeg -i input.mp4 -vf scale=-2:1080 -c:v libx264 -crf 23 -c:a aac output.mp4`};if(r&&t>8388608)return{ok:!1,message:`Image files must be less than 8MB (got ${ue(t)}).`};return{ok:!0}}function pn(e){let n=e.split(".").pop()?.toLowerCase()??"";return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",mp4:"video/mp4",mov:"video/quicktime",webm:"video/webm"}[n]??"application/octet-stream"}async function Fe(e,n,t,r){y(e),I(e);let a=b(e);switch(n){case"list":case"ls":{let i=await a.get("/api/media",{workspace:!0,query:{limit:S(t,"limit")??50,offset:S(t,"offset")??0}});p(i,{...e,emptyMessage:"No media yet. Upload with dun media upload <file>."});return}case"get":{let i=r[0];if(!i)throw new d("Usage: dun media get <id>",c.USAGE);let o=await a.get(`/api/media/${i}`,{workspace:!0});p(o,e);return}case"upload":{let i=r[0]||f(t,"file","f");if(!i)throw new d('Usage: dun media upload <file> [--alt "..."]',c.USAGE);if(!dn(i))throw new d(`File not found: ${i}`,c.VALIDATION);let o=un(i),s=ln(i).size,l=f(t,"mime","type","content-type")||pn(o),u=f(t,"alt","alt-text"),m=Ge({mimeType:l,fileSize:s});if(!m.ok)throw new d(m.message,c.VALIDATION);let g=await a.post("/api/media/upload-url",{filename:o,mimeType:l,fileSize:s},{workspace:!0});R(e.debug,`PUT ${g.uploadUrl}`,{storageKey:g.storageKey,fileSize:s});let h=cn(i),k;try{k=await fetch(g.uploadUrl,{method:"PUT",headers:{"Content-Type":l,"Content-Length":String(s)},body:h})}catch(E){throw new d(`Upload PUT failed: ${E.message}`,c.NETWORK)}if(!k.ok){let E=await k.text().catch(()=>"");throw new d(`Upload PUT failed with HTTP ${k.status}${E?`: ${E.slice(0,200)}`:""}`,c.NETWORK)}let x=await a.post("/api/media/complete",{storageKey:g.storageKey,originalFilename:o,mimeType:l,fileSize:s,altText:u},{workspace:!0});p(x,e);return}case"alt":{let i=r[0],o=w(t,"clear")?"":f(t,"text","alt","t");if(!i||o===void 0)throw new d('Usage: dun media alt <id> --text "..." | --clear',c.USAGE);await a.patch(`/api/media/${i}/alt-text`,{altText:o.trim()},{workspace:!0}),p({id:i,altText:o.trim()},e);return}case"delete":case"rm":{let i=r[0];if(!i)throw new d("Usage: dun media delete <id> [--yes]",c.USAGE);if(!e.yes&&!w(t,"yes","y"))throw new d("Refusing to delete without --yes",c.VALIDATION);let o=await a.delete(`/api/media/${i}`,void 0,{workspace:!0});p(o??{id:i,deleted:!0},e);return}default:throw new d(`Unknown media command "${n??""}". Try: list, get, upload, alt, delete`,c.USAGE)}}async function Ke(e,n,t,r){if(y(e),I(e),n!==void 0&&n!=="show"&&n!=="get")throw new d(`Unknown analytics command "${n}". Try: dun analytics [--days 30]`,c.USAGE);let a=S(t,"days","d")??30;if(!Number.isInteger(a)||a<1||a>90)throw new d("--days must be a whole number from 1 to 90",c.USAGE);let o=await b(e).get(`/api/analytics?days=${a}`,{workspace:!0});p(o,e)}async function He(e,n,t,r){y(e),I(e);let a=b(e),i=n[0];if(i==="collections"||i==="collection"){let o=n[1]||"list";switch(o){case"list":case"ls":{let s=await a.get("/api/memory/collections",{workspace:!0});p(s,{...e,emptyMessage:'No memory collections yet. Create one with dun memory collections create --name "..."'});return}case"create":{let s=f(t,"name","n");if(!s)throw new d("Missing --name",c.VALIDATION);let l=await a.post("/api/memory/collections",{name:s,color:f(t,"color")??"blue",isPrivate:w(t,"private")},{workspace:!0});p(l,e);return}case"get":{let s=n[2]||r[0];if(!s)throw new d("Usage: dun memory collections get <id>",c.USAGE);let l=await a.get(`/api/memory/collections/${s}`,{workspace:!0});p(l,e);return}case"update":{let s=n[2]||r[0];if(!s)throw new d("Usage: dun memory collections update <id> [--name] [--color] [--private|--public]",c.USAGE);let l=f(t,"name","n"),u=f(t,"color"),m=w(t,"private"),g=w(t,"public");if(m&&g)throw new d("Use either --private or --public, not both",c.VALIDATION);let h={};if(l)h.name=l;if(u)h.color=u;if(m)h.isPrivate=!0;if(g)h.isPrivate=!1;if(Object.keys(h).length===0)throw new d("Provide at least one of --name, --color, --private, or --public",c.VALIDATION);let k=await a.patch(`/api/memory/collections/${s}`,h,{workspace:!0});p(k,e);return}case"delete":case"rm":{let s=n[2]||r[0];if(!s)throw new d("Usage: dun memory collections delete <id> [--yes]",c.USAGE);if(!e.yes&&!w(t,"yes","y"))throw new d("Refusing to delete without --yes",c.VALIDATION);let l=await a.delete(`/api/memory/collections/${s}`,void 0,{workspace:!0});p(l??{id:s,deleted:!0},e);return}default:throw new d(`Unknown memory collections command "${o}". Try: list, create, get, update, delete`,c.USAGE)}}switch(i){case"list":case"ls":{let o=f(t,"collection","collection-id","c");if(!o)throw new d("Missing --collection <id>",c.VALIDATION);let s=await a.get("/api/memory",{workspace:!0,query:{collectionId:o,limit:S(t,"limit")??100}});p(s,{...e,emptyMessage:"No memories in this collection."});return}case"save":case"add":{let o=f(t,"collection","collection-id","c"),s=f(t,"text","t");if(!o)throw new d("Missing --collection <id>",c.VALIDATION);if(!s)throw new d("Missing --text",c.VALIDATION);let l=await a.post("/api/memory",{collectionId:o,text:s},{workspace:!0});p(l,e);return}case"search":{let o=f(t,"prompt","q","query","text"),s=v(t,"collections","collection","collection-ids","c")??[];if(!o)throw new d("Missing --prompt",c.VALIDATION);if(s.length===0)throw new d("Missing --collections <id,id>",c.VALIDATION);let l=await a.post("/api/memory/search",{prompt:o,collectionIds:s,topK:S(t,"top-k","topk","k")??5},{workspace:!0});p(l,e);return}case"delete":case"rm":{let o=n[1]||r[0],s=f(t,"collection","collection-id","c");if(!o)throw new d("Usage: dun memory delete <id> --collection <id>",c.USAGE);if(!s)throw new d("Missing --collection <id>",c.VALIDATION);if(!e.yes&&!w(t,"yes","y"))throw new d("Refusing to delete without --yes",c.VALIDATION);let l=await a.delete(`/api/memory/${o}`,{collectionId:s,memoryId:o},{workspace:!0});p(l??{id:o,deleted:!0},e);return}default:throw new d(`Unknown memory command "${i??""}". Try: collections, list, save, search, delete`,c.USAGE)}}import{readFileSync as mn}from"node:fs";async function ze(e,n,t,r){y(e);let a=I(e),i=b(e),o=`/api/workspaces/${a}/ai-voice-settings`;switch(n){case"get":case"show":case void 0:{let s=await i.get(o,{workspace:!0});p(s??{personalization:null,hint:'No personalization set. Use dun personalization set --description "..."'},e);return}case"set":case"update":{let s=w(t,"clear"),l=f(t,"description","d"),u=f(t,"file","f");if([s,Boolean(l),Boolean(u)].filter(Boolean).length!==1)throw new d("Use exactly one of --description, --file, or --clear",c.VALIDATION);let g;if(s)g=null;else if(u){let k;try{k=mn(u,"utf8").trim()}catch(x){throw new d(`Could not read file: ${x.message}`,c.VALIDATION)}if(!k)throw new d("File is empty",c.VALIDATION);g={description:k}}else{let k=l.trim();if(!k)throw new d("--description cannot be empty",c.VALIDATION);g={description:k}}let h=await i.patch(o,g,{workspace:!0});p(h,e);return}default:throw new d(`Unknown personalization command "${n}". Try: get, set`,c.USAGE)}}function Je(e){return e.trim().replace(/^\/?r\//i,"").replace(/^@/,"")}async function pe(e,n,t,r){y(e),I(e);let a=b(e);switch(n){case"flairs":case"flair":case"flair-options":{let i=r[0]||f(t,"subreddit","sub","r");if(!i)throw new d(`Usage: dun reddit flairs <subreddit>
|
|
387
|
+
Example: dun reddit flairs tamilyapping --json`,c.USAGE);let o=Je(i),l=((await a.get("/api/social-accounts/reddit/flair-options",{workspace:!0,query:{subreddit:o}})).choices??[]).map((u)=>({id:u.id,text:u.text,textEditable:u.textEditable!==!1}));p({subreddit:o,choices:l},{...e,emptyMessage:`No flairs returned for r/${o}. The subreddit may not use post flair.`});return}case"requirements":case"post-requirements":{let i=r[0]||f(t,"subreddit","sub","r");if(!i)throw new d("Usage: dun reddit requirements <subreddit>",c.USAGE);let o=Je(i),s=await a.get("/api/social-accounts/reddit/post-requirements",{workspace:!0,query:{subreddit:o}});p({subreddit:o,requirements:s},e);return}default:throw new d(`Unknown reddit command "${n??""}". Try: flairs, requirements`,c.USAGE)}}async function me(e,n,t,r){y(e),I(e);let a=b(e);switch(n){case"boards":case"list":case"list-boards":{let i=await a.get("/api/social-accounts/pinterest/boards",{workspace:!0});p({boards:i.boards??[]},{...e,emptyMessage:'No Pinterest boards on this account. Create one with dun pinterest create-board --name "..."'});return}case"create-board":case"board-create":case"create":{let i=f(t,"name","n")||r[0]||"";if(!i.trim())throw new d(`Usage: dun pinterest create-board --name "Brand assets" [--private]
|
|
388
|
+
Example: dun pinterest create-board --name "Landing page" --json`,c.USAGE);let o=await a.post("/api/social-accounts/pinterest/boards",{name:i.trim(),privacy:w(t,"private")?"SECRET":"PUBLIC"},{workspace:!0});p(o,e);return}default:throw new d(`Unknown pinterest command "${n??""}". Try: boards, create-board`,c.USAGE)}}async function fe(e,n,t,r){y(e),I(e);let a=b(e);switch(n){case"channels":case"list":case"list-channels":{let i=f(t,"account","a"),o=i?{socialAccountId:i}:void 0,s=await a.get("/api/social-accounts/discord/channels",{workspace:!0,query:o});p({channels:s.channels??[],guildId:s.guildId,source:s.source},{...e,emptyMessage:"No text or announcement channels. Reconnect Discord and pick a server the bot can post in."});return}default:throw new d(`Unknown discord command "${n??""}". Try: channels
|
|
389
|
+
Example: dun discord channels --account <id>`,c.USAGE)}}async function ge(e,n,t,r){y(e),I(e);let a=b(e);switch(n){case"channels":case"list":case"list-channels":{let i=f(t,"account","a"),o=i?{socialAccountId:i}:void 0,s=await a.get("/api/social-accounts/slack/channels",{workspace:!0,query:o});p({channels:s.channels??[],teamId:s.teamId,source:s.source},{...e,emptyMessage:"No Slack channels. Reconnect Slack and invite the DunSocial app to the channels you want to post in."});return}default:throw new d(`Unknown slack command "${n??""}". Try: channels
|
|
390
|
+
Example: dun slack channels --account <id>`,c.USAGE)}}import{existsSync as Ze}from"node:fs";import{mkdir as Qe,writeFile as et,readFile as ke}from"node:fs/promises";import{dirname as be,join as T}from"node:path";import{homedir as H}from"node:os";import{fileURLToPath as fn}from"node:url";var M=[{id:"claude",label:"Claude Code",aliases:["claude-code"],dest:(e)=>T(e,".claude","skills","dunsocial","SKILL.md")},{id:"codex",label:"Codex",dest:(e)=>T(e,".codex","skills","dunsocial","SKILL.md"),afterInstall:async(e)=>({agentsPath:await hn(e)})},{id:"cursor",label:"Cursor",dest:(e)=>T(e,".cursor","skills","dunsocial","SKILL.md")},{id:"pi",label:"Pi",dest:(e)=>T(e,".pi","agent","skills","dunsocial","SKILL.md")},{id:"opencode",label:"OpenCode",dest:(e)=>T(e,".config","opencode","skills","dunsocial","SKILL.md")},{id:"agents",label:"Universal (.agents)",aliases:["universal"],dest:(e)=>T(e,".agents","skills","dunsocial","SKILL.md")},{id:"copilot",label:"GitHub Copilot",aliases:["github-copilot","github"],dest:(e)=>T(e,".copilot","skills","dunsocial","SKILL.md")},{id:"windsurf",label:"Windsurf",dest:(e)=>T(e,".codeium","windsurf","skills","dunsocial","SKILL.md")},{id:"goose",label:"Goose",dest:(e)=>T(e,".config","goose","skills","dunsocial","SKILL.md")},{id:"gemini",label:"Gemini CLI",aliases:["gemini-cli"],dest:(e)=>T(e,".gemini","skills","dunsocial","SKILL.md")},{id:"amp",label:"Amp",dest:(e)=>T(e,".config","agents","skills","dunsocial","SKILL.md")},{id:"grok",label:"Grok Build",dest:(e)=>T(e,".grok","skills","dunsocial","SKILL.md")},{id:"continue",label:"Continue",dest:(e)=>T(e,".continue","skills","dunsocial","SKILL.md")},{id:"antigravity",label:"Antigravity",dest:(e)=>T(e,".gemini","antigravity","skills","dunsocial","SKILL.md")}],he=new Map;for(let e of M){he.set(e.id,e);for(let n of e.aliases??[])he.set(n,e)}var Ye=`Usage: dun skill install <${M.map((e)=>e.id).join("|")}|all>`;function we(){let e=be(fn(import.meta.url)),n=T("skills","dunsocial","SKILL.md"),t=[T(e,"..",n),T(e,"..","..",n)];return t.find(Ze)??t[0]}function gn(){let e=H();return M.map((n)=>({id:n.id,label:n.label,path:n.dest(e),aliases:n.aliases??[]}))}async function tt(){try{return await ke(we(),"utf8")}catch{throw new d(`Bundled skill not found at ${we()}. Reinstall dunsocial.`,c.USAGE)}}async function nt(e,n){await Qe(be(e),{recursive:!0}),await et(e,n,"utf8")}async function hn(e){let n=T(H(),".codex","AGENTS.md");await Qe(be(n),{recursive:!0});let t="";try{t=await ke(n,"utf8")}catch{t=""}let r=["<!-- BEGIN DUNSOCIAL CLI SKILL -->","## DunSocial CLI","","Use the `dun` CLI for DunSocial scheduling from the shell. Prefer `--json` output.",`Skill details: ${e}`,"","Common flow:","1. `dun auth status --json`","2. `dun workspace list --json` / `dun workspace use <id>`","3. `dun accounts list --json`",'4. `dun posts schedule --text "..." --accounts <id> --in 1h --json`',"<!-- END DUNSOCIAL CLI SKILL -->"].join(`
|
|
391
|
+
`),a="<!-- BEGIN DUNSOCIAL CLI SKILL -->",i="<!-- END DUNSOCIAL CLI SKILL -->",o,s=t.indexOf(a),l=t.indexOf(i);if(s!==-1&&l!==-1&&l>s)o=t.slice(0,s)+r+t.slice(l+i.length);else if(t.trim())o=`${t.trimEnd()}
|
|
392
|
+
|
|
393
|
+
${r}
|
|
394
|
+
`;else o=`${r}
|
|
395
|
+
`;return await et(n,o,"utf8"),n}async function z(e){let n=e?.home??H(),t=e?.markdown;if(t===void 0)try{t=await tt()}catch{return[]}let r=[];for(let a of M){let i=a.dest(n);if(!Ze(i))continue;let o="";try{o=await ke(i,"utf8")}catch{continue}if(o===t){r.push({target:a.id,path:i,updated:!1});continue}if(await nt(i,t),a.afterInstall)try{await a.afterInstall(i)}catch{}r.push({target:a.id,path:i,updated:!0})}return r}async function Xe(e,n){let t=e.dest(H());await nt(t,n);let r=e.afterInstall?await e.afterInstall(t):{};return{target:e.id,path:t,message:`Installed DunSocial skill for ${e.label}. Restart or open a new session if needed.`,...r}}async function it(e,n,t,r){switch(n){case"path":{p({path:we()},e);return}case"list":{p({targets:gn(),hint:"Install with: dun skill install <target|all>"},e);return}case"install":{let a=(r[0]||"").toLowerCase();if(!a)throw new d(Ye,c.USAGE);let i=await tt();if(a==="all"){let l=[];for(let u of M){let m=await Xe(u,i);l.push({target:m.target,path:m.path})}p({target:"all",count:l.length,installed:l,message:`Installed DunSocial skill for ${l.length} agents.`},e);return}let o=he.get(a);if(!o)throw new d(`Unknown agent "${a}". ${Ye}
|
|
396
|
+
Try: dun skill list`,c.USAGE);let s=await Xe(o,i);p(s,e);return}default:throw new d(`Unknown skill command "${n??""}". Try: install, list, path`,c.USAGE)}}import{spawn as wn}from"node:child_process";import{realpathSync as kn}from"node:fs";var C="dunsocial",bn=`https://registry.npmjs.org/${C}/latest`,yn=400;function j(e=process.argv[1]??""){let n=e.replaceAll("\\","/");try{n=kn(e).replaceAll("\\","/")}catch{}if(n.includes("/.npm/_npx")||n.includes("/npm/_npx")||n.includes("/_npx/"))return{packageManager:"npx",manual:`npm install -g ${C}@latest`};if(n.includes("/.pnpm/")||n.includes("/pnpm/"))return{packageManager:"pnpm",command:"pnpm",args:["add","-g",`${C}@latest`],manual:`pnpm add -g ${C}@latest`};if(n.includes("/.yarn/")||n.includes("/yarn/global"))return{packageManager:"yarn",command:"yarn",args:["global","add",`${C}@latest`],manual:`yarn global add ${C}@latest`};if(n.includes("/.bun/")||n.includes("/bun/install/global"))return{packageManager:"bun",command:"bun",args:["add","-g",`${C}@latest`],manual:`bun add -g ${C}@latest`};if(n.includes(`/node_modules/${C}/`))return{packageManager:"npm",command:"npm",args:["install","-g",`${C}@latest`],manual:`npm install -g ${C}@latest`};return{packageManager:"unknown",manual:`npm install -g ${C}@latest`}}function q(e,n){let t=e.replace(/^v/,"").split(".").map((i)=>Number.parseInt(i,10)||0),r=n.replace(/^v/,"").split(".").map((i)=>Number.parseInt(i,10)||0),a=Math.max(t.length,r.length);for(let i=0;i<a;i++){let o=t[i]??0,s=r[i]??0;if(o>s)return 1;if(o<s)return-1}return 0}function rt(e){return Number.parseInt(e.replace(/^v/,"").split(".")[0]??"0",10)||0}function ot(e,n){return rt(n)>rt(e)}async function J(e=fetch,n){let t=await e(bn,{headers:{Accept:"application/json"},...n});if(!t.ok)throw new d(`Could not check npm for updates (HTTP ${t.status}). Try: npm install -g ${C}@latest`,c.NETWORK);let r=await t.json();if(!r.version)throw new d("npm registry response missing version",c.NETWORK);return r.version}async function ye(e=yn,n=fetch){let t=new AbortController,r=setTimeout(()=>t.abort(),e);try{return await J(n,{signal:t.signal})}catch{return}finally{clearTimeout(r)}}function Y(e,n,t){let r=t?.stdio??"inherit";return new Promise((a,i)=>{let o=wn(e,n,{stdio:r,env:process.env,windowsHide:!0,shell:process.platform==="win32"});o.on("error",(s)=>{i(new d(`Failed to run ${e}: ${s.message}. Try manually: ${e} ${n.join(" ")}`,c.NETWORK))}),o.on("close",(s)=>a(s??1))})}async function st(e,n,t){let r=w(t,"check"),a=w(t,"force"),i=U,o=j(),s;try{s=await J()}catch(g){if(g instanceof d)throw g;throw new d(`Could not check npm for updates: ${g.message}`,c.NETWORK)}let l=q(s,i)>0,u={current:i,latest:s,upToDate:!l,packageManager:o.packageManager,command:o.manual};if(!l&&!a){p(e.json?u:`Already on the latest version (${i}).`,e);return}if(r){p(e.json?{...u,updateAvailable:l}:`Update available: ${i} → ${s}
|
|
310
397
|
Run: dun update
|
|
311
|
-
Or: ${
|
|
312
|
-
Cannot auto-update this install (${
|
|
313
|
-
Run: ${
|
|
314
|
-
`);let m=await
|
|
315
|
-
`,"utf8"),e}async function
|
|
316
|
-
`);return{applied:!1,reason:"major",latest:
|
|
317
|
-
`);return{applied:!0,reason:"applied",latest:
|
|
318
|
-
`);return{applied:!1,reason:"apply-failed",latest:
|
|
319
|
-
|
|
320
|
-
`);process.stdout.write(`${
|
|
321
|
-
`)}async function
|
|
322
|
-
`)}async function
|
|
323
|
-
`),c.OK;if(t==="help"||!t&&
|
|
324
|
-
`);else
|
|
325
|
-
`),c.OK;let
|
|
398
|
+
Or: ${o.manual}`,e);return}if(!o.command||!o.args){p(e.json?{...u,applied:!1,hint:o.manual}:`Update available: ${i} → ${s}
|
|
399
|
+
Cannot auto-update this install (${o.packageManager}).
|
|
400
|
+
Run: ${o.manual}`,e);return}if(!e.json&&!e.quiet)process.stderr.write(`Updating ${C}: ${i} → ${s} via ${o.packageManager}...
|
|
401
|
+
`);let m=await Y(o.command,o.args);if(m!==0)throw new d(`Update command failed (exit ${m}). Try: ${o.manual}`,c.NETWORK);try{await z()}catch{}p(e.json?{...u,applied:!0}:`Updated via ${o.packageManager}. Run dun --version to confirm.`,e)}import{mkdir as In,readFile as An,writeFile as Sn}from"node:fs/promises";import{dirname as Tn,join as at}from"node:path";import{homedir as Cn}from"node:os";var ct=86400000,Un=new Set(["update","upgrade","self-update"]);function Z(e=process.env){if(e.DUN_UPDATE_CACHE)return e.DUN_UPDATE_CACHE;let n=e.XDG_CACHE_HOME,t=n?n:at(Cn(),".cache");return at(t,"dunsocial","update.json")}function vn(e){let n=(e??"").trim().toLowerCase();return n==="0"||n==="never"||n==="off"||n==="false"||n==="no"}function En(e=process.env){return e.CI==="true"||e.CI==="1"||Boolean(e.GITHUB_ACTIONS)||Boolean(e.TF_BUILD)||Boolean(e.GITLAB_CI)||Boolean(e.CIRCLECI)||Boolean(e.BUILDKITE)}function xn(e){return Boolean(e&&Un.has(e))}function Nn(e){return Boolean(e.command&&e.args)}function dt(e){let n=e.env??process.env;if(w(e.flags,"no-update"))return!1;if(w(e.flags,"json","j"))return!1;if(xn(e.group))return!1;if(!e.stdoutIsTty)return!1;if(n.DUN_JSON==="1")return!1;if(En(n))return!1;if(vn(n.DUN_UPDATE))return!1;return!0}function lt(e,n=Date.now(),t=ct){if(!e.lastCheckedAt||!e.latest)return!1;let r=Date.parse(e.lastCheckedAt);if(!Number.isFinite(r))return!1;return n-r<t}function Rn(e,n,t=Date.now(),r=ct){if(e.lastFailedVersion!==n||!e.lastFailedAt)return!0;let a=Date.parse(e.lastFailedAt);if(!Number.isFinite(a))return!0;return t-a>=r}async function ut(e=Z()){try{let n=await An(e,"utf8");return JSON.parse(n)}catch{return{}}}async function X(e,n=Z()){return await In(Tn(n),{recursive:!0}),await Sn(n,`${JSON.stringify(e,null,2)}
|
|
402
|
+
`,"utf8"),e}async function pt(e){let n=e?.cachePath??Z(),t=e?.now??Date.now(),r=await ut(n);if(lt(r,t))return r;let a=await(e?.fetchLatest??ye)();if(!a)return r;return X({...r,lastCheckedAt:new Date(t).toISOString(),latest:a},n)}async function On(e){let n=e.write??((s)=>process.stderr.write(s)),t=e.cachePath??Z(),r=e.now??Date.now(),a=e.install??j();if(!Nn(a))return{applied:!1,reason:"no-install-command"};let i=await e.checkPromise??await ut(t),o=i.latest;if(!o||!lt(i,r)){let s=await(e.fetchLatest??ye)();if(s)i=await X({...i,lastCheckedAt:new Date(r).toISOString(),latest:s},t),o=s}if(!o)return{applied:!1,reason:"no-latest"};if(q(o,e.current)<=0)return{applied:!1,reason:"up-to-date",latest:o};if(ot(e.current,o)){if(!e.quiet)n(`Major update available: ${e.current} -> ${o}. Run: dun update --yes
|
|
403
|
+
`);return{applied:!1,reason:"major",latest:o}}if(!Rn(i,o,r))return{applied:!1,reason:"failed-backoff",latest:o};try{let s=await(e.spawn??Y)(a.command,a.args,{stdio:"ignore"});if(s!==0)throw Error(`exit ${s}`);if(await X({...i,latest:o,lastAppliedAt:new Date(r).toISOString(),lastFailedAt:void 0,lastFailedVersion:void 0},t),!e.quiet)n(`Updated ${C} ${e.current} → ${o}
|
|
404
|
+
`);return{applied:!0,reason:"applied",latest:o}}catch{if(await X({...i,latest:o,lastFailedAt:new Date(r).toISOString(),lastFailedVersion:o},t),!e.quiet)n(`Auto-update failed. Try: ${a.manual}
|
|
405
|
+
`);return{applied:!1,reason:"apply-failed",latest:o}}}async function mt(e){try{await e.refreshSkills();let t=await(e.apply??On)({current:e.current,checkPromise:e.checkPromise,quiet:e.quiet,install:e.install,cachePath:e.cachePath,now:e.now,fetchLatest:e.fetchLatest,spawn:e.spawn,write:e.write});if(t.applied)await e.refreshSkills();return t}catch{return}}function ft(){if(N(process.stdout))process.stdout.write(`${Ne()}
|
|
406
|
+
|
|
407
|
+
`);process.stdout.write(`${oe}
|
|
408
|
+
`)}async function Ln(){let e=await ee(),n=process.env.DUN_TOKEN||e.token,t=process.env.DUN_WORKSPACE_ID||e.defaultWorkspaceId;process.stdout.write(`${Oe({token:n,workspaceId:t,config:e})}
|
|
409
|
+
`)}async function $n(e){let n=te(e),{group:t,action:r,nest:a,flags:i,positionals:o}=n;if(ie(i)&&!t)return process.stdout.write(`${U}
|
|
410
|
+
`),c.OK;if(t==="help"||!t&&ne(i)){let l=t==="help"?r||o[0]:void 0;if(l)process.stdout.write(`${se(l)}
|
|
411
|
+
`);else ft();return c.OK}if(!t){if(N(process.stdout))await Ln();else ft();return c.OK}if(ne(i))return process.stdout.write(`${se(t)}
|
|
412
|
+
`),c.OK;let s=await Ce({apiUrl:f(i,"api-url","apiUrl"),token:f(i,"token"),workspace:f(i,"workspace","w"),json:w(i,"json","j")?!0:void 0,debug:w(i,"debug"),quiet:w(i,"quiet","q"),yes:w(i,"yes","y")});if(ie(i))return p({version:U},s),c.OK;try{switch(t){case"auth":await $e(s,r,i,o);break;case"workspace":case"workspaces":await De(s,r,i,o);break;case"account":case"accounts":if(r==="reddit"){await pe(s,o[0],i,o.slice(1));break}if(r==="pinterest"){await me(s,o[0],i,o.slice(1));break}if(r==="discord"){await fe(s,o[0],i,o.slice(1));break}if(r==="slack"){await ge(s,o[0],i,o.slice(1));break}await _e(s,r??"list",i,o);break;case"reddit":await pe(s,r,i,o);break;case"pinterest":await me(s,r,i,o);break;case"discord":await fe(s,r,i,o);break;case"slack":await ge(s,r,i,o);break;case"instagram":case"ig":await le("instagram",s,r,i,o);break;case"tiktok":await le("tiktok",s,r,i,o);break;case"post":case"posts":await F(s,r,i,o);break;case"draft":case"drafts":await qe(s,r,i,o);break;case"media":await Fe(s,r,i,o);break;case"memory":{let l=a?[a,r].filter(Boolean):r?[r]:[];await He(s,l,i,o);break}case"analytics":case"stats":await Ke(s,r,i,o);break;case"personalization":case"voice":await ze(s,r,i,o);break;case"skill":case"skills":await it(s,r,i,o);break;case"update":case"upgrade":case"self-update":await st(s,r,i);break;case"version":p({version:U},s);break;default:throw new d(`Unknown command "${t}". Run dun --help`,c.USAGE)}return c.OK}catch(l){return ve(l,s)}}var gt=process.argv.slice(2),Ie=te(gt),ht=dt({flags:Ie.flags,group:Ie.group,stdoutIsTty:Boolean(process.stdout.isTTY),env:process.env}),Pn=ht?pt():Promise.resolve(void 0),wt=await $n(gt);if(wt===c.OK&&ht)await mt({current:U,checkPromise:Pn,quiet:w(Ie.flags,"quiet","q"),refreshSkills:z});process.exit(wt);
|
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dunsocial",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"description": "DunSocial agent-first CLI — schedule and publish social posts from the terminal, CI, and coding agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://www.dunsocial.com/cli",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/thisuxhq/dunsocialapp.git",
|
|
11
|
+
"directory": "apps/cli"
|
|
12
|
+
},
|
|
8
13
|
"keywords": [
|
|
9
14
|
"dunsocial",
|
|
10
15
|
"cli",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: dunsocial
|
|
3
|
-
description: Schedule, publish, and manage DunSocial posts, drafts, media, memory, and workspace personalization (AI voice) from the shell via the dun CLI (npm package dunsocial). Use when the user wants to post or schedule to X/LinkedIn/Bluesky/Threads/Reddit/Pinterest/Instagram/YouTube/Discord through DunSocial, manage drafts or media uploads, search workspace memory, get/set AI voice personalization, or wire social publishing into CI/agent workflows.
|
|
3
|
+
description: Schedule, publish, and manage DunSocial posts, drafts, media, memory, and workspace personalization (AI voice) from the shell via the dun CLI (npm package dunsocial). Use when the user wants to post or schedule to X/LinkedIn/Bluesky/Threads/Reddit/Pinterest/Instagram/TikTok/YouTube/Discord/Slack/Facebook Pages through DunSocial, manage drafts or media uploads, search workspace memory, get/set AI voice personalization, or wire social publishing into CI/agent workflows.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# DunSocial CLI skill
|
|
@@ -85,6 +85,8 @@ dun posts publish --text "Hello" --accounts acc_x --wait --json
|
|
|
85
85
|
```bash
|
|
86
86
|
dun media upload ./shot.png --alt "Product screenshot" --json
|
|
87
87
|
dun posts schedule --text "…" --accounts acc_x --media <assetId> --in 30m --json
|
|
88
|
+
# fix alt text later (or --clear)
|
|
89
|
+
dun media alt <assetId> --text "Product screenshot, dark mode" --json
|
|
88
90
|
```
|
|
89
91
|
|
|
90
92
|
Local preflight rejects images > 8MB and video > 16GB **before** upload-url. X publish then re-checks the connected account (default 20 min / 8 GB; Premium and Premium+ 125 min / 16 GB). Compress video first if needed:
|
|
@@ -97,6 +99,40 @@ ffmpeg -i input.mp4 -vf scale=-2:1080 -c:v libx264 -crf 23 -c:a aac output.mp4
|
|
|
97
99
|
|
|
98
100
|
No `--meta`. Upload one MP4/MOV, attach with `--media`, target a personal LinkedIn or Company Page account (`dun accounts list --platform linkedin` or `--platform linkedin-business`). Rules: **exactly one video** or images — never mix.
|
|
99
101
|
|
|
102
|
+
## Instagram
|
|
103
|
+
|
|
104
|
+
`dun instagram` (alias `dun ig`) builds `metadata.instagram` for you. `--format` is required: `feed_image`, `carousel`, `reel` or `story`.
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
dun media upload ./clip.mp4 --json
|
|
108
|
+
dun ig schedule --account acc_ig --format reel --media <assetId> --caption "Launch day" --in 2h --json
|
|
109
|
+
dun ig publish --account acc_ig --format feed_image --media <assetId> --alt "Product shot" --wait --json
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Optional: `--collaborators a,b`, `--cover <assetId>`, `--thumb-offset <ms>`, `--audio-name "..."`, `--no-feed`.
|
|
113
|
+
|
|
114
|
+
## TikTok
|
|
115
|
+
|
|
116
|
+
`dun tiktok` builds `metadata.tiktok`. One video, and `--privacy` is required: `public`, `friends`, `followers` or `private`.
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
dun tiktok schedule --account acc_tt --media <videoAssetId> --privacy public --title "Behind the scenes" --in 2h --json
|
|
120
|
+
dun tiktok publish --account acc_tt --media <videoAssetId> --privacy private --wait --json
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Optional: `--no-comments`, `--no-duet`, `--no-stitch`, `--cover-ms <n>`.
|
|
124
|
+
|
|
125
|
+
## Facebook Pages
|
|
126
|
+
|
|
127
|
+
Limited beta. Connect the Page in the DunSocial dashboard (not the CLI). Text, one link, or photos — **images only**, no `--meta`.
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
dun accounts list --platform facebook --json
|
|
131
|
+
dun posts validate --accounts PAGE_ACCOUNT_ID --text "Hello from the Page" --json
|
|
132
|
+
dun posts schedule --accounts PAGE_ACCOUNT_ID --text "Hello from the Page" --at 2026-09-01T15:00:00.000Z --json
|
|
133
|
+
dun drafts create --text "WIP" --platforms facebook --json
|
|
134
|
+
```
|
|
135
|
+
|
|
100
136
|
```bash
|
|
101
137
|
dun accounts list --platform linkedin --json
|
|
102
138
|
dun media upload ./clip.mp4 --json
|