social-light 0.0.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/.env.example ADDED
@@ -0,0 +1,7 @@
1
+ # OpenAI API key for AI features
2
+ OPENAI_API_KEY=your_openai_api_key
3
+
4
+ # Bluesky credentials
5
+ BLUESKY_HANDLE=your_handle.bsky.social
6
+ BLUESKY_APP_PASSWORD=your_bluesky_app_password
7
+ BLUESKY_SERVICE=https://bsky.social
@@ -0,0 +1,45 @@
1
+ # Social Light Project Checklist
2
+
3
+ ## Project Structure
4
+
5
+ - [x] Create basic project structure
6
+ - [x] Initialize package.json with dependencies
7
+ - [x] Create main entry point (index.mjs)
8
+
9
+ ## Core Utilities
10
+
11
+ - [x] Database utility (db.mjs)
12
+ - [x] Configuration utility (config.mjs)
13
+ - [x] AI utility (ai.mjs)
14
+ - [x] Social media API wrapper (base.mjs)
15
+ - [x] Twitter/X implementation (twitter.mjs)
16
+ - [x] Bluesky implementation (bluesky.mjs)
17
+ - [x] TikTok implementation (tiktok.mjs)
18
+
19
+ ## CLI Commands
20
+
21
+ - [x] Initialize command (init.mjs)
22
+ - [x] Create post command (create.mjs)
23
+ - [x] List unpublished posts command (unpublished.mjs)
24
+ - [x] List published posts command (published.mjs)
25
+ - [x] Edit post command (edit.mjs)
26
+ - [x] Publish posts command (publish.mjs)
27
+
28
+ ## Web Server
29
+
30
+ - [x] Express server setup
31
+ - [x] API endpoints
32
+ - [x] Basic web frontend
33
+
34
+ ## Social Media Integration
35
+
36
+ - [x] Twitter API integration
37
+ - [x] Bluesky API integration
38
+ - [x] TikTok API integration
39
+ - [x] Extensible platform API wrapper
40
+
41
+ ## Additional Features
42
+
43
+ - [x] Continuous publishing mode
44
+ - [x] Calendar visualization
45
+ - [ ] Post analytics
@@ -0,0 +1,182 @@
1
+ Here's a **Product Requirements Document (PRD)** for your CLI + Web hybrid AI-powered social scheduling tool, named **Social Light**.
2
+
3
+ ---
4
+
5
+ ## 📄 Product Requirements Document (PRD)
6
+
7
+ ### Product Name
8
+
9
+ **Social Light**
10
+
11
+ ### Overview
12
+
13
+ **Social Light** is a command-line tool and optional local web server that helps users manage and schedule social media posts. It leverages AI to assist with post generation, scheduling, and cross-platform publishing.
14
+
15
+ ---
16
+
17
+ ### Goals
18
+
19
+ - Provide a fast, scriptable, and extensible CLI for content creation and scheduling.
20
+ - Allow an optional local web interface for reviewing/editing posts and calendars.
21
+ - Support AI-powered assistance for titles, publish dates, and content suggestions.
22
+ - Manage state using a local SQLite database and a user-scoped JSON settings file.
23
+ - Support for scheduling and publishing to multiple platforms (e.g., Twitter, Bluesky, TikTok).
24
+
25
+ ---
26
+
27
+ ### Interfaces
28
+
29
+ #### CLI (Primary)
30
+
31
+ Command-line tool with subcommands (inspired by Git/Heroku-style commands).
32
+
33
+ #### Web UI (Optional)
34
+
35
+ Local web interface launched with `social-light server` to browse, create, and edit posts.
36
+
37
+ ---
38
+
39
+ ### Initial Setup
40
+
41
+ #### `social-light init`
42
+
43
+ - Creates a JSON config file at `$HOME/.social-light/config.json`
44
+ - Config includes:
45
+
46
+ ```json
47
+ {
48
+ "dbPath": "~/.social-light/social-light.db",
49
+ "defaultPlatforms": [],
50
+ "aiEnabled": true
51
+ }
52
+ ```
53
+
54
+ - Creates SQLite DB file and necessary tables (posts, logs, etc.)
55
+
56
+ ---
57
+
58
+ ### Post Data Model (SQLite)
59
+
60
+ | Field | Type | Description |
61
+ | ------------ | -------- | --------------------------------- |
62
+ | id | INTEGER | Primary key |
63
+ | title | TEXT | Title of the post |
64
+ | content | TEXT | Full post content |
65
+ | platforms | TEXT | Comma-separated list of platforms |
66
+ | publish_date | DATE | Scheduled publish date |
67
+ | published | BOOLEAN | Whether the post is published |
68
+ | created_at | DATETIME | Timestamp of creation |
69
+ | updated_at | DATETIME | Timestamp of last edit |
70
+
71
+ ---
72
+
73
+ ### CLI Commands
74
+
75
+ #### `social-light create`
76
+
77
+ Two modes:
78
+
79
+ 1. **Prompt-based (interactive)**
80
+
81
+ ```
82
+ > This is my first post!
83
+ enter a title? (leave blank for AI to figure it out)>
84
+ enter a publish date? (leave blank for AI to figure it out)>
85
+ where would you like to publish this post?
86
+ - [x] Twitter
87
+ - [ ] Bluesky
88
+ - [ ] TikTok
89
+ ```
90
+
91
+ 2. **File-based**
92
+
93
+ ```bash
94
+ social-light create --file my_post.txt
95
+ ```
96
+
97
+ AI will infer:
98
+
99
+ - Title (from content)
100
+ - Date (based on historical post frequency and current date)
101
+
102
+ #### `social-light unpublished`
103
+
104
+ Lists all unpublished posts:
105
+
106
+ ```
107
+ [index] [date] [title] [truncated content...]
108
+ ```
109
+
110
+ #### `social-light published`
111
+
112
+ Lists published posts:
113
+
114
+ ```
115
+ [index] [date] [title] [truncated content...]
116
+ ```
117
+
118
+ #### `social-light edit [index]`
119
+
120
+ - Edits a draft post by index
121
+ - Opens `$EDITOR` or prompts inline
122
+ - Title/content/platform/date editable
123
+
124
+ #### `social-light publish`
125
+
126
+ - Publishes all eligible posts (date <= today)
127
+ - Marks them as `published = true`
128
+
129
+ #### `social-light publish --continuous`
130
+
131
+ - Polls continuously (e.g., every 60s)
132
+ - Checks for publishable posts and posts them
133
+
134
+ #### `social-light server`
135
+
136
+ - Launches local web UI
137
+ - React frontend served via Express or Vite backend
138
+ - Allows post browsing, editing, calendar view, platform settings
139
+
140
+ ---
141
+
142
+ ### AI Integration
143
+
144
+ - **AI Title Inference:** Uses first lines + intent classification
145
+ - **AI Date Prediction:** Based on user's post cadence
146
+ - **Optional Caption Enhancement:** Suggestions on tone, hashtags, or trending topics
147
+
148
+ Uses the [`ai`](https://www.npmjs.com/package/ai) npm package (OpenAI wrapper).
149
+
150
+ ---
151
+
152
+ ### Tech Stack
153
+
154
+ - **CLI:** Node.js, `yargs`, `ora`, `inquirer`, `fs-extra`, `chalk`
155
+ - **AI:** [`ai`](https://www.npmjs.com/package/ai)
156
+ - **DB:** SQLite via `better-sqlite3` or `knex`
157
+ - **Config:** JSON in `$HOME/.social-light/config.json`
158
+ - **Server (optional):** Express + React (via Vite), Tailwind for UI
159
+ - **Scheduler:** Node cron jobs or `setInterval` for continuous mode
160
+
161
+ ---
162
+
163
+ ### Stretch Goals
164
+
165
+ - 🗓️ **Monthly Calendar Generator:** Visual calendar view with post slots
166
+ - ✍️ **Caption Generator:** Suggests captions per platform
167
+ - 🎨 **Image Generator:** AI-based content visuals from prompts
168
+ - 📹 **Video Stitcher:** Combine images/sound for TikTok/IG Reels
169
+
170
+ ---
171
+
172
+ ### Success Criteria
173
+
174
+ - Can create, edit, and publish posts via CLI
175
+ - AI assistance enhances workflow (for title/date at minimum)
176
+ - Local DB reliably stores and syncs post state
177
+ - Posts appear and update correctly in the optional web UI
178
+ - User can run `--continuous` publish mode reliably
179
+
180
+ ---
181
+
182
+ Would you like help scaffolding the CLI file structure or database schema next?
@@ -0,0 +1,122 @@
1
+ # Social Light Project Development Summary
2
+
3
+ ## Project Overview
4
+
5
+ We developed "Social Light," a Node.js CLI and web application for AI-powered social media post scheduling. The application allows users to create, schedule, and publish content to multiple social media platforms using a command-line interface or a web UI.
6
+
7
+ ## Key Features Implemented
8
+
9
+ - Command-line interface with multiple commands (init, create, edit, publish, etc.)
10
+ - Web interface using Express and vanilla JavaScript
11
+ - SQLite database for local data storage
12
+ - OpenAI-powered AI features for title generation and date suggestions
13
+ - Social media platform integrations for Twitter, Bluesky, and TikTok
14
+ - Continuous posting mode for scheduled content
15
+ - Calendar visualization
16
+
17
+ ## Project Architecture
18
+
19
+ ### Core Directory Structure
20
+
21
+ ```
22
+ social-light/
23
+ ├── src/
24
+ │ ├── commands/ # CLI command implementations
25
+ │ ├── utils/ # Utility modules
26
+ │ │ ├── social/ # Social media platform APIs
27
+ │ │ ├── ai.mjs # AI utilities
28
+ │ │ ├── config.mjs # Configuration utilities
29
+ │ │ └── db.mjs # Database utilities
30
+ │ ├── server/ # Web server and UI
31
+ │ │ ├── client/ # Client-side web interface
32
+ │ │ └── index.mjs # Express server
33
+ │ └── index.mjs # Main CLI entry point
34
+ └── package.json # Project configuration
35
+ ```
36
+
37
+ ### Technical Components
38
+
39
+ #### CLI Commands
40
+
41
+ - **init**: Initializes configuration and database
42
+ - **create**: Creates new posts with AI assistance
43
+ - **unpublished**: Lists unpublished posts
44
+ - **published**: Lists published posts
45
+ - **edit**: Edits existing posts
46
+ - **publish**: Publishes eligible posts, with continuous mode option
47
+ - **server**: Starts web interface
48
+
49
+ #### Database
50
+
51
+ - SQLite database for post storage
52
+ - Automatic table creation and initialization
53
+ - Functions for CRUD operations on posts
54
+
55
+ #### Social Media Integration
56
+
57
+ - Extensible platform API with a base class and factory pattern
58
+ - Twitter/X integration using their official API
59
+ - Bluesky integration using the AT Protocol
60
+ - TikTok integration using Content Posting API
61
+ - Graceful handling of unsupported platforms (Instagram, LinkedIn)
62
+
63
+ #### AI Features
64
+
65
+ - Title generation from post content
66
+ - Smart publish date suggestions based on posting history
67
+ - Content enhancement for platform optimization
68
+
69
+ ## Technical Challenges Addressed
70
+
71
+ 1. **Database Initialization**: Implemented auto-initialization of SQLite database to prevent "no such table" errors
72
+ 2. **Editor Issues**: Replaced external editor invocation with multiline terminal input
73
+ 3. **API Key Management**: Created extensive documentation for API setup and management
74
+ 4. **Platform Errors**: Fixed constant variable reassignment error in social API implementation
75
+ 5. **Unsupported Platforms**: Added graceful handling for platforms without implementation
76
+
77
+ ## Environment Variables Required
78
+
79
+ ```
80
+ # OpenAI API for AI features
81
+ OPENAI_API_KEY=your_openai_api_key
82
+
83
+ # Twitter/X credentials
84
+ TWITTER_API_KEY=your_twitter_api_key
85
+ TWITTER_API_SECRET=your_twitter_api_secret
86
+ TWITTER_ACCESS_TOKEN=your_twitter_access_token
87
+ TWITTER_ACCESS_TOKEN_SECRET=your_twitter_access_token_secret
88
+
89
+ # Bluesky credentials
90
+ BLUESKY_HANDLE=your_handle.bsky.social
91
+ BLUESKY_APP_PASSWORD=your_bluesky_app_password
92
+
93
+ # TikTok credentials
94
+ TIKTOK_CLIENT_KEY=your_tiktok_client_key
95
+ TIKTOK_CLIENT_SECRET=your_tiktok_client_secret
96
+ TIKTOK_ACCESS_TOKEN=your_tiktok_access_token
97
+ ```
98
+
99
+ ## Modern JavaScript Features Used
100
+
101
+ - ES Modules with dynamic imports
102
+ - Top-level await
103
+ - Destructuring assignments
104
+ - Async/await throughout codebase
105
+ - Template literals
106
+ - Arrow functions
107
+ - Optional chaining and nullish coalescing
108
+
109
+ ## Documentation Created
110
+
111
+ - README.md with usage instructions
112
+ - API_SETUP.md with detailed API integration instructions
113
+ - Inline JSDoc documentation for all functions
114
+
115
+ ## Future Expansion Possibilities
116
+
117
+ - Additional social platform integrations
118
+ - Enhanced analytics features
119
+ - Image and video generation capabilities
120
+ - Advanced scheduling algorithms
121
+
122
+ The application is designed with extensibility in mind, using modular architecture and factory patterns to make adding new features straightforward.
package/README.md ADDED
@@ -0,0 +1,196 @@
1
+ # Social Light
2
+
3
+ <img src="https://raw.githubusercontent.com/johnhenry/social-light/main/src/server/client/logo.jpg" alt="social light logo" style="height:256px">
4
+
5
+ An AI-powered social media scheduling tool for Bluesky with CLI and web interface. More platforms coming soon!
6
+
7
+ ## Features
8
+
9
+ - **CLI Interface**: Create, manage, and publish posts directly from your terminal
10
+ - **Web Interface**: Optional local web server for a visual post management experience
11
+ - **AI Assistance**: Automatic title generation, date suggestions, and content enhancement
12
+ - **Bluesky Integration**: Publish to Bluesky with ease
13
+ - **Scheduling**: Schedule posts ahead of time with smart AI date suggestions
14
+ - **Continuous Publishing**: Run in daemon mode to automatically publish scheduled posts
15
+
16
+ ## Prerequesites
17
+
18
+ ### Software
19
+
20
+ [Node.js/npm](https://nodejs.org) must be installed on your system
21
+
22
+ > [!WARNING]
23
+ > There's a know issues with the latest version of Node.js (v23) and 'better-sqlite3'. Please use Node.js v22 (LTS) or lower.
24
+
25
+ ## Accounts
26
+
27
+ You will need an account on [blue sky](https://bsky.app) and an [OpenAI](https://openai.com) account to use the AI features.
28
+
29
+ ## Installation
30
+
31
+ ### From NPM
32
+
33
+ ```bash
34
+ npm install -g social-light
35
+ ```
36
+
37
+ ### From Source
38
+
39
+ ```bash
40
+ # Clone the repository
41
+ git clone https://github.com/yourusername/social-light.git
42
+ cd social-light
43
+
44
+ # Install dependencies
45
+ npm install
46
+
47
+ # Make the CLI executable
48
+ chmod +x src/index.mjs
49
+ npm link
50
+ ```
51
+
52
+ ## CLI Usage
53
+
54
+ ### Initialize social-light
55
+
56
+ ```bash
57
+ social-light init
58
+ ```
59
+
60
+ This will:
61
+
62
+ - Create a configuration file at `~/.social-light/config.json`
63
+ - Initialize a SQLite database at `~/.social-light/social-light.db`
64
+ - Collect your Bluesky credentials
65
+ - Collect your Open AI credentials
66
+
67
+ ### Create a Post
68
+
69
+ ```bash
70
+ social-light create
71
+ ```
72
+
73
+ This will guide you through creating a new post with:
74
+
75
+ - Interactive content editor
76
+ - AI-powered title suggestions
77
+ - Smart publish date recommendations
78
+ - Platform selection
79
+
80
+ ### Manage Posts
81
+
82
+ ```bash
83
+ # List unpublished posts
84
+ social-light unpublished
85
+
86
+ # List published posts
87
+ social-light published
88
+
89
+ # Edit a post by index
90
+ social-light edit 1
91
+ ```
92
+
93
+ ### Publish Posts
94
+
95
+ ```bash
96
+ # Publish all eligible posts
97
+ social-light publish
98
+
99
+ # Run in continuous mode (daemon)
100
+ social-light publish --continuous
101
+ ```
102
+
103
+ ### Web Interface
104
+
105
+ Open the web interface to manage post visually
106
+
107
+ <img src="https://raw.githubusercontent.com/johnhenry/social-light/main/server.png" alt="server" style="height:256px">
108
+
109
+ ```bash
110
+ # Start the web server
111
+ social-light server
112
+
113
+ # Specify a custom port
114
+ social-light server --port 8080
115
+ ```
116
+
117
+ ## Web Interface
118
+
119
+ The web interface provides a visual way to:
120
+
121
+ - View all your scheduled and published posts
122
+ - Create and edit posts with a rich text editor
123
+ - See a calendar view of your posting schedule
124
+ - Manually publish posts with a single click
125
+
126
+ Access the web interface at `http://localhost:3000` (or your specified port) after starting the server.
127
+
128
+ ## Configuration
129
+
130
+ Configuration is stored in `~/.social-light/config.json` and can be modified directly or through the initialization process.
131
+
132
+ ### Example Config
133
+
134
+ ```json
135
+ {
136
+ "dbPath": "~/.social-light/social-light.db",
137
+ "defaultPlatforms": ["Bluesky"],
138
+ "aiEnabled": true
139
+ }
140
+ ```
141
+
142
+ ### Platform Setup
143
+
144
+ To publish to Bluesky, you'll need to set up your credentials:
145
+
146
+ #### Bluesky
147
+
148
+ ## AI Features
149
+
150
+ To use AI features, you need an OpenAI API key:
151
+
152
+ ```
153
+ OPENAI_API_KEY=your_openai_api_key
154
+ ```
155
+
156
+ AI features include:
157
+
158
+ - Title generation based on post content
159
+ - Smart publish date suggestions based on your posting history
160
+ - Content enhancement for platform-specific optimization
161
+
162
+ ## Development
163
+
164
+ ### Project Structure
165
+
166
+ ```
167
+ social-light/
168
+ ├── src/
169
+ │ ├── commands/ # CLI command implementations
170
+ │ ├── utils/ # Utility modules
171
+ │ │ ├── social/ # Social media platform APIs
172
+ │ │ ├── ai.mjs # AI utilities
173
+ │ │ ├── config.mjs # Configuration utilities
174
+ │ │ └── db.mjs # Database utilities
175
+ │ ├── server/ # Web server and UI
176
+ │ │ ├── client/ # Client-side web interface
177
+ │ │ └── index.mjs # Express server
178
+ │ └── index.mjs # Main CLI entry point
179
+ └── package.json # Project configuration
180
+ ```
181
+
182
+ ### Technologies Used
183
+
184
+ - **Node.js** with ES Modules
185
+ - **SQLite** for local database storage
186
+ - **Express** for the web server
187
+ - **OpenAI API** for AI-powered features
188
+ - **Bluesky AT Protocol** for social media integration
189
+
190
+ ## License
191
+
192
+ MIT
193
+
194
+ ## Contributing
195
+
196
+ Contributions are welcome! Please feel free to submit a Pull Request.
package/bin/socialite ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Get the directory of the script
4
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5
+
6
+ # Run the Node.js application
7
+ node "$DIR/../src/index.mjs" "$@"