session-planner 1.0.0 → 1.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/README.md CHANGED
@@ -4,6 +4,8 @@
4
4
  [![npm](https://img.shields.io/npm/v/session-planner)](https://www.npmjs.com/package/session-planner)
5
5
 
6
6
  > Schedule "Hello!" Claude Code sessions at times you choose — opening Claude **N hours before** each target time. Works as a terminal CLI, an `npx` one-liner, or a Claude Code plugin.
7
+ >
8
+ > 📦 **Available on npm:** [session-planner](https://www.npmjs.com/package/session-planner)
7
9
 
8
10
  ---
9
11
 
@@ -13,21 +15,21 @@ This tool helps maximize your Claude Code session duration by opening sessions a
13
15
 
14
16
  ### The "Session Hack" Explained
15
17
 
16
- ![Hacking Time Illustration](file:///Users/mahmoud.maghrabia/.gemini/antigravity/brain/4caf6a88-8f79-4afb-a4ff-4f4b38b32272/session_planner_hack_illustration_1775342703939.png)
18
+ ![Hacking Time Illustration](file:///Users/mahmoud.maghrabia/.gemini/antigravity/brain/4caf6a88-8f79-4afb-a4ff-4f4b38b32272/session_planner_hack_final_illustration_1775343574461.png)
17
19
 
18
20
  ```mermaid
19
21
  graph TD
20
- subgraph "Standard Way"
22
+ subgraph Standard_Way [Standard Way]
21
23
  A1[Start Work at 1 PM] --> B1{Hit Limit?}
22
- B1 -- Yes --> C1[Wait 4-8 Hours]
23
- C1 --> D1[Resume at 9 PM 😫]
24
+ B1 -- Yes --> C1["'Limit will reset at 9:00 PM'"]
25
+ C1 --> D1[Wait 5 Hours 😫]
24
26
  end
25
27
 
26
- subgraph "The Hack (Session Planner)"
28
+ subgraph The_Hack [The Hack]
27
29
  A2[Auto-Open at 9 AM] --> B2[Start Work at 1 PM]
28
30
  B2 --> C2{Hit Limit?}
29
- C2 -- Yes --> D2[Reset is NEAR]
30
- D2 --> E2[Resume Immediately 😎]
31
+ C2 -- Yes --> D2["'Limit will reset... in 5 mins'"]
32
+ D2 --> E2[NO MORE WAITING 😎]
31
33
  end
32
34
 
33
35
  style A2 fill:#4CAF50,stroke:#2E7D32,color:#fff
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "session-planner",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Schedule Hello! Claude Code sessions at specific times. Opens a session N hours before your chosen time.",
5
5
  "keywords": ["claude", "claude-code", "scheduler", "cli", "cron"],
6
6
  "author": "MahmoudMabrok",
@@ -14,7 +14,7 @@
14
14
  "url": "https://github.com/MahmoudMabrok/SessionPlanner/issues"
15
15
  },
16
16
  "bin": {
17
- "session-planner": "./bin/session-planner.js"
17
+ "session-planner": "./session-planner.js"
18
18
  },
19
19
  "engines": {
20
20
  "node": ">=14.0.0"
@@ -0,0 +1,159 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ /**
5
+ * session-planner CLI
6
+ *
7
+ * Wraps hello-scheduler.sh so it can be run directly from the terminal
8
+ * or via npx without going through Claude Code at all.
9
+ *
10
+ * Usage:
11
+ * npx session-planner hello 1am
12
+ * npx session-planner hello 9am 2pm --offset 2h
13
+ * npx session-planner list
14
+ * npx session-planner remove 2pm
15
+ * npx session-planner remove --all
16
+ * npx session-planner help
17
+ */
18
+
19
+ const { spawnSync } = require('child_process');
20
+ const path = require('path');
21
+ const fs = require('fs');
22
+ const os = require('os');
23
+
24
+ // ── colours ───────────────────────────────────────────────────────────────────
25
+ const isTTY = process.stdout.isTTY;
26
+ const c = {
27
+ bold: s => isTTY ? `\x1b[1m${s}\x1b[0m` : s,
28
+ green: s => isTTY ? `\x1b[32m${s}\x1b[0m` : s,
29
+ yellow: s => isTTY ? `\x1b[33m${s}\x1b[0m` : s,
30
+ cyan: s => isTTY ? `\x1b[36m${s}\x1b[0m` : s,
31
+ red: s => isTTY ? `\x1b[31m${s}\x1b[0m` : s,
32
+ dim: s => isTTY ? `\x1b[2m${s}\x1b[0m` : s,
33
+ };
34
+
35
+ // ── resolve the shell script ──────────────────────────────────────────────────
36
+ // Priority:
37
+ // 1. Alongside this file (when run from the repo / npx)
38
+ // 2. Installed as a Claude Code plugin ~/.claude/plugins/session-planner/scripts/
39
+ function findScript() {
40
+ const candidates = [
41
+ path.join(__dirname, 'hello-scheduler.sh'),
42
+ path.join(os.homedir(), '.claude', 'plugins', 'session-planner', 'scripts', 'hello-scheduler.sh'),
43
+ ];
44
+ for (const p of candidates) {
45
+ if (fs.existsSync(p)) return p;
46
+ }
47
+ return null;
48
+ }
49
+
50
+ // ── help ──────────────────────────────────────────────────────────────────────
51
+ function printHelp() {
52
+ console.log(`
53
+ ${c.bold('session-planner')} — Schedule Hello! Claude Code sessions
54
+
55
+ ${c.bold('USAGE')}
56
+ npx session-planner <command> [args]
57
+
58
+ ${c.bold('COMMANDS')}
59
+ ${c.cyan('hello')} <time> [time2 ...] [--offset Nh]
60
+ Schedule one or more Hello! sessions.
61
+ Claude opens N hours before each chosen time (default: 4h).
62
+
63
+ ${c.cyan('list')}
64
+ Show all scheduled Hello! jobs.
65
+
66
+ ${c.cyan('remove')} <time>
67
+ Remove the job for a specific target time.
68
+
69
+ ${c.cyan('remove')} --all
70
+ Cancel all scheduled Hello! jobs.
71
+
72
+ ${c.cyan('help')}
73
+ Show this help message.
74
+
75
+ ${c.bold('TIME FORMATS')}
76
+ 1am 2pm 12:00 9:30am 14:30
77
+
78
+ ${c.bold('EXAMPLES')}
79
+ npx session-planner hello 1am
80
+ npx session-planner hello 9am 2pm 6pm
81
+ npx session-planner hello 14:00 --offset 2h
82
+ npx session-planner list
83
+ npx session-planner remove 2pm
84
+ npx session-planner remove --all
85
+
86
+ ${c.dim('Logs → ~/.claude/session-planner.log')}
87
+ `);
88
+ }
89
+
90
+ // ── run the shell script ──────────────────────────────────────────────────────
91
+ function runScript(scriptArgs) {
92
+ const script = findScript();
93
+ if (!script) {
94
+ console.error(c.red('ERROR:') + ' hello-scheduler.sh not found.\n');
95
+ console.error(' Expected it next to this package, or at:');
96
+ console.error(' ~/.claude/plugins/session-planner/scripts/hello-scheduler.sh\n');
97
+ console.error(' Clone the repo and run from inside it, or install the Claude Code plugin first.');
98
+ process.exit(1);
99
+ }
100
+
101
+ // Ensure the script is executable
102
+ try { fs.chmodSync(script, 0o755); } catch (_) {}
103
+
104
+ const result = spawnSync('bash', [script, ...scriptArgs], {
105
+ stdio: 'inherit',
106
+ env: { ...process.env },
107
+ });
108
+
109
+ if (result.error) {
110
+ console.error(c.red('ERROR:') + ' Failed to run bash: ' + result.error.message);
111
+ process.exit(1);
112
+ }
113
+
114
+ process.exit(result.status ?? 0);
115
+ }
116
+
117
+ // ── parse top-level command ───────────────────────────────────────────────────
118
+ const args = process.argv.slice(2);
119
+
120
+ if (args.length === 0 || args[0] === 'help' || args[0] === '--help' || args[0] === '-h') {
121
+ printHelp();
122
+ process.exit(0);
123
+ }
124
+
125
+ const [command, ...rest] = args;
126
+
127
+ switch (command) {
128
+ case 'hello':
129
+ if (rest.length === 0) {
130
+ console.error(c.red('ERROR:') + ' Please provide at least one time.\n');
131
+ console.error(' Example: ' + c.cyan('npx session-planner hello 1am'));
132
+ process.exit(1);
133
+ }
134
+ runScript(rest);
135
+ break;
136
+
137
+ case 'list':
138
+ runScript(['--list']);
139
+ break;
140
+
141
+ case 'remove':
142
+ if (rest.length === 0) {
143
+ console.error(c.red('ERROR:') + ' Please provide a time or --all.\n');
144
+ console.error(' Example: ' + c.cyan('npx session-planner remove 2pm'));
145
+ console.error(' Example: ' + c.cyan('npx session-planner remove --all'));
146
+ process.exit(1);
147
+ }
148
+ if (rest[0] === '--all' || rest[0] === 'all') {
149
+ runScript(['--remove-all']);
150
+ } else {
151
+ runScript(['--remove', ...rest]);
152
+ }
153
+ break;
154
+
155
+ default:
156
+ console.error(c.red('ERROR:') + ` Unknown command: ${c.bold(command)}\n`);
157
+ console.error(' Run ' + c.cyan('npx session-planner help') + ' to see available commands.');
158
+ process.exit(1);
159
+ }