@sleepy-ai/cli 0.0.0-main-202607032053

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 SleepyCode, Tahsin Arafat
4
+ Copyright (c) 2026 MiMo Code, Xiaomi Corporation
5
+ Copyright (c) 2025 opencode
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,148 @@
1
+ <h1 align="center">SleepyCode</h1>
2
+
3
+ <p align="center"><strong>Sleepy Code: Where Models and Agents Co-Evolve</strong></p>
4
+
5
+ <p align="center">
6
+ <a href="https://www.sleepyai.org">Website</a> | <a href="https://www.sleepyai.org/blog">Blog</a> | <a href="https://github.com/TahsinArafat/sleepy-ai">GitHub</a>
7
+ </p>
8
+
9
+ ---
10
+
11
+ SleepyCode is a terminal-native AI coding assistant. It can read and write code, run commands, manage Git, and use a persistent memory system to keep a deep understanding of your project across sessions while continuously improving itself.
12
+
13
+ Sleepy Auto is built in as a free-for-limited-time channel, so you can start with zero configuration. SleepyCode also supports connecting to any mainstream LLM provider API.
14
+
15
+ ---
16
+
17
+ ## Quick Start
18
+
19
+ ```bash
20
+ # One-line install
21
+ curl -fsSL https://www.sleepyai.org/install | bash
22
+
23
+ # Or install via npm
24
+ npm install -g @sleepy-ai/cli
25
+
26
+ # Run
27
+ sleepy
28
+ ```
29
+
30
+ The first launch guides you through configuration automatically. Supported options:
31
+ - **Sleepy Auto (free for a limited time)** — anonymous channel, zero configuration
32
+ - **Sleepy Platform** — OAuth login
33
+ - **Import from Claude Code** — migrate existing authentication in one step
34
+ - **Custom Provider** — add any OpenAI-compatible API in the TUI
35
+
36
+ <details>
37
+ <summary><strong>WSL: clipboard issues</strong></summary>
38
+
39
+ If you encounter garbled text when copying on WSL, install `xsel`:
40
+ ```bash
41
+ sudo apt install xsel
42
+ ```
43
+ </details>
44
+
45
+ ---
46
+
47
+ ## Core Features
48
+
49
+ ### Multiple Agents
50
+
51
+ | Agent | Description |
52
+ |--------|------|
53
+ | **build** | Default. Full tool permissions for development |
54
+ | **plan** | Read-only analysis mode for code exploration and solution design |
55
+ | **compose** | Orchestration mode for specs-driven development and skill-driven workflows |
56
+
57
+ Press `Tab` to switch between primary agents. Subagents are created by the system as needed.
58
+
59
+ ### Persistent Memory
60
+
61
+ Cross-session memory powered by SQLite FTS5 full-text search:
62
+
63
+ - **Project memory** (`MEMORY.md`) — persistent project knowledge, rules, and architecture decisions
64
+ - **Session checkpoint** (`checkpoint.md`) — structured state snapshots maintained automatically by the checkpoint-writer subagent
65
+ - **Scratch notes** (`notes.md`) — temporary note area for agents
66
+ - **Task progress** (`tasks/<id>/progress.md`) — per-task logs
67
+
68
+ Memory is injected automatically when a session resumes, so the agent does not need to relearn project context.
69
+
70
+ ### Intelligent Context Management
71
+
72
+ - **Automatic checkpoints** — decides when to save session state based on the model context window
73
+ - **Context reconstruction** — when context approaches the limit, rebuilds it from the latest checkpoint, project memory, task progress, and retained recent messages so the agent can continue the current task
74
+ - **Budgeted injection** — uses a token budget to control how much checkpoint, memory, and notes content enters context, with importance ranking
75
+
76
+ ### Task Tracking
77
+
78
+ A tree-shaped task system (`T1`, `T1.1`, `T1.2`, …) that integrates automatically with the checkpoint system, so task progress is preserved when sessions resume.
79
+
80
+ ### Subagent System
81
+
82
+ The primary agent can create subagents on demand. Subagents share the current session context and can work in parallel, with lifecycle tracking, cancellation, and background execution.
83
+
84
+ ### Goal / Stop Condition
85
+
86
+ The `/goal` command sets a stopping condition for a session. When the agent tries to stop, an independent judge model evaluates the conversation to decide whether the condition is truly satisfied — preventing premature "optimistic stops" during autonomous work.
87
+
88
+ ### Compose Mode
89
+
90
+ Compose mode provides a structured workflow for specs-driven development. It includes built-in skills for planning, execution, code review, TDD, debugging, verification, and merging — orchestrating the full lifecycle from spec to shipped code.
91
+
92
+ ### Voice Input
93
+
94
+ Real-time streaming voice input powered by TenVAD and Sleepy ASR. Activate with `/voice`, then speak — audio is segmented by pauses and transcribed incrementally into the input. Available for Sleepy logged-in users. Requires `sox` (`brew install sox` on macOS, other platforms similar).
95
+
96
+ <details>
97
+ <summary><strong>WSLg audio setup</strong></summary>
98
+
99
+ ```bash
100
+ sudo apt install -y sox pulseaudio libasound2-plugins
101
+ export PULSE_SERVER=unix:/mnt/wslg/PulseServer
102
+ ```
103
+ </details>
104
+
105
+ <details>
106
+ <summary><strong>SSH remote audio (Mac → remote host)</strong></summary>
107
+
108
+ ```bash
109
+ # Mac (local)
110
+ brew install pulseaudio
111
+ pulseaudio --load="module-native-protocol-tcp auth-ip-acl=127.0.0.1" --exit-idle-time=-1 --daemonize
112
+ # Add to ~/.ssh/config: RemoteForward 4713 127.0.0.1:4713
113
+
114
+ # Remote host
115
+ apt install -y pulseaudio pulseaudio-utils sox
116
+ export PULSE_SERVER=tcp:127.0.0.1:4713
117
+ # Verify: pactl info
118
+ ```
119
+ </details>
120
+
121
+ ### Dream & Distill
122
+
123
+ - **`/dream`** — scans recent session traces, extracts persistent knowledge into project memory, and removes outdated entries
124
+ - **`/distill`** — discovers repeated manual workflows in recent work and packages high-confidence candidates into reusable skills, subagents, or commands
125
+
126
+ ---
127
+
128
+ ## Configuration
129
+
130
+ SleepyCode is configured via `.sleepycode/sleepycode.json` in the project directory (or `~/.config/sleepycode/sleepycode.json` globally). Key options include:
131
+
132
+ - Provider and model selection
133
+ - Agent permissions and custom agents
134
+ - Checkpoint and memory behavior
135
+ - MCP server connections
136
+ - Keybindings and theme
137
+
138
+ Max Mode (parallel best-of-N reasoning with judge selection) can be enabled via `experimental.maxMode` in the config.
139
+
140
+ ---
141
+
142
+ ## License
143
+
144
+ Source code is licensed under the [MIT License](https://github.com/XiaomiSleepy/Sleepy-Code/blob/main/LICENSE).
145
+
146
+ Use of SleepyCode is also subject to the [Use Restrictions](https://github.com/XiaomiSleepy/Sleepy-Code/blob/main/USE_RESTRICTIONS.md).
147
+ Use of Sleepy-hosted services is subject to the [Sleepy Terms of Service](https://www.sleepyai.org/terms).
148
+ Use of the Sleepy name, logo, and trademarks is subject to the Sleepy Trademark Policy.
package/bin/sleepy ADDED
@@ -0,0 +1,180 @@
1
+ #!/usr/bin/env node
2
+
3
+ const childProcess = require("child_process")
4
+ const fs = require("fs")
5
+ const path = require("path")
6
+ const os = require("os")
7
+
8
+ function run(target) {
9
+ const result = childProcess.spawnSync(target, process.argv.slice(2), {
10
+ stdio: "inherit",
11
+ })
12
+ if (result.error) {
13
+ console.error(result.error.message)
14
+ process.exit(1)
15
+ }
16
+ const code = typeof result.status === "number" ? result.status : 0
17
+ process.exit(code)
18
+ }
19
+
20
+ const envPath = process.env.SLEEPYCODE_BIN_PATH
21
+ if (envPath) {
22
+ run(envPath)
23
+ }
24
+
25
+ const scriptPath = fs.realpathSync(__filename)
26
+ const scriptDir = path.dirname(scriptPath)
27
+
28
+ //
29
+ const cached = path.join(scriptDir, ".sleepycode")
30
+ if (fs.existsSync(cached)) {
31
+ run(cached)
32
+ }
33
+
34
+ const platformMap = {
35
+ darwin: "darwin",
36
+ linux: "linux",
37
+ win32: "windows",
38
+ }
39
+ const archMap = {
40
+ x64: "x64",
41
+ arm64: "arm64",
42
+ arm: "arm",
43
+ }
44
+
45
+ let platform = platformMap[os.platform()]
46
+ if (!platform) {
47
+ platform = os.platform()
48
+ }
49
+ let arch = archMap[os.arch()]
50
+ if (!arch) {
51
+ arch = os.arch()
52
+ }
53
+ const scope = "@sleepy-ai/"
54
+ const base = scope + "sleepycode-" + platform + "-" + arch
55
+ const binary = platform === "windows" ? "sleepy.exe" : "sleepy"
56
+
57
+ function supportsAvx2() {
58
+ if (arch !== "x64") return false
59
+
60
+ if (platform === "linux") {
61
+ try {
62
+ return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
63
+ } catch {
64
+ return false
65
+ }
66
+ }
67
+
68
+ if (platform === "darwin") {
69
+ try {
70
+ const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
71
+ encoding: "utf8",
72
+ timeout: 1500,
73
+ })
74
+ if (result.status !== 0) return false
75
+ return (result.stdout || "").trim() === "1"
76
+ } catch {
77
+ return false
78
+ }
79
+ }
80
+
81
+ if (platform === "windows") {
82
+ const cmd =
83
+ '(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
84
+
85
+ for (const exe of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
86
+ try {
87
+ const result = childProcess.spawnSync(exe, ["-NoProfile", "-NonInteractive", "-Command", cmd], {
88
+ encoding: "utf8",
89
+ timeout: 3000,
90
+ windowsHide: true,
91
+ })
92
+ if (result.status !== 0) continue
93
+ const out = (result.stdout || "").trim().toLowerCase()
94
+ if (out === "true" || out === "1") return true
95
+ if (out === "false" || out === "0") return false
96
+ } catch {
97
+ continue
98
+ }
99
+ }
100
+
101
+ return false
102
+ }
103
+
104
+ return false
105
+ }
106
+
107
+ const names = (() => {
108
+ const avx2 = supportsAvx2()
109
+ const baseline = arch === "x64" && !avx2
110
+
111
+ if (platform === "linux") {
112
+ const musl = (() => {
113
+ try {
114
+ if (fs.existsSync("/etc/alpine-release")) return true
115
+ } catch {
116
+ // ignore
117
+ }
118
+
119
+ try {
120
+ const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
121
+ const text = ((result.stdout || "") + (result.stderr || "")).toLowerCase()
122
+ if (text.includes("musl")) return true
123
+ } catch {
124
+ // ignore
125
+ }
126
+
127
+ return false
128
+ })()
129
+
130
+ if (musl) {
131
+ if (arch === "x64") {
132
+ if (baseline) return [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
133
+ return [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
134
+ }
135
+ return [`${base}-musl`, base]
136
+ }
137
+
138
+ if (arch === "x64") {
139
+ if (baseline) return [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
140
+ return [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
141
+ }
142
+ return [base, `${base}-musl`]
143
+ }
144
+
145
+ if (arch === "x64") {
146
+ if (baseline) return [`${base}-baseline`, base]
147
+ return [base, `${base}-baseline`]
148
+ }
149
+ return [base]
150
+ })()
151
+
152
+ function findBinary(startDir) {
153
+ let current = startDir
154
+ for (;;) {
155
+ const modules = path.join(current, "node_modules")
156
+ if (fs.existsSync(modules)) {
157
+ for (const name of names) {
158
+ const candidate = path.join(modules, name, "bin", binary)
159
+ if (fs.existsSync(candidate)) return candidate
160
+ }
161
+ }
162
+ const parent = path.dirname(current)
163
+ if (parent === current) {
164
+ return
165
+ }
166
+ current = parent
167
+ }
168
+ }
169
+
170
+ const resolved = findBinary(scriptDir)
171
+ if (!resolved) {
172
+ console.error(
173
+ "It seems that your package manager failed to install the right version of the sleepycode CLI for your platform. You can try manually installing " +
174
+ names.map((n) => `\"${n}\"`).join(" or ") +
175
+ " package",
176
+ )
177
+ process.exit(1)
178
+ }
179
+
180
+ run(resolved)
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@sleepy-ai/cli",
3
+ "version": "0.0.0-main-202607032053",
4
+ "description": "Sleepy Code: Where Models and Agents Co-Evolve",
5
+ "license": "MIT",
6
+ "author": "Sleepy AI",
7
+ "homepage": "https://www.sleepyai.org",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/TahsinArafat/sleepy-ai.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/TahsinArafat/sleepy-ai/issues"
14
+ },
15
+ "keywords": [
16
+ "ai",
17
+ "cli",
18
+ "code",
19
+ "sleepy",
20
+ "sleepycode"
21
+ ],
22
+ "bin": {
23
+ "sleepy": "./bin/sleepy"
24
+ },
25
+ "scripts": {
26
+ "postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
27
+ },
28
+ "optionalDependencies": {
29
+ "@sleepy-ai/sleepycode-linux-x64-musl": "0.0.0-main-202607032053",
30
+ "@sleepy-ai/sleepycode-linux-arm64-musl": "0.0.0-main-202607032053",
31
+ "@sleepy-ai/sleepycode-linux-x64-baseline": "0.0.0-main-202607032053",
32
+ "@sleepy-ai/sleepycode-darwin-arm64": "0.0.0-main-202607032053",
33
+ "@sleepy-ai/sleepycode-darwin-x64-baseline": "0.0.0-main-202607032053",
34
+ "@sleepy-ai/sleepycode-darwin-x64": "0.0.0-main-202607032053",
35
+ "@sleepy-ai/sleepycode-linux-x64-baseline-musl": "0.0.0-main-202607032053",
36
+ "@sleepy-ai/sleepycode-windows-x64": "0.0.0-main-202607032053",
37
+ "@sleepy-ai/sleepycode-linux-arm64": "0.0.0-main-202607032053",
38
+ "@sleepy-ai/sleepycode-windows-x64-baseline": "0.0.0-main-202607032053",
39
+ "@sleepy-ai/sleepycode-windows-arm64": "0.0.0-main-202607032053",
40
+ "@sleepy-ai/sleepycode-linux-x64": "0.0.0-main-202607032053"
41
+ }
42
+ }
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "fs"
4
+ import path from "path"
5
+ import os from "os"
6
+ import { fileURLToPath } from "url"
7
+ import { createRequire } from "module"
8
+
9
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
10
+ const require = createRequire(import.meta.url)
11
+
12
+ function detectPlatformAndArch() {
13
+ // Map platform names
14
+ let platform
15
+ switch (os.platform()) {
16
+ case "darwin":
17
+ platform = "darwin"
18
+ break
19
+ case "linux":
20
+ platform = "linux"
21
+ break
22
+ case "win32":
23
+ platform = "windows"
24
+ break
25
+ default:
26
+ platform = os.platform()
27
+ break
28
+ }
29
+
30
+ // Map architecture names
31
+ let arch
32
+ switch (os.arch()) {
33
+ case "x64":
34
+ arch = "x64"
35
+ break
36
+ case "arm64":
37
+ arch = "arm64"
38
+ break
39
+ case "arm":
40
+ arch = "arm"
41
+ break
42
+ default:
43
+ arch = os.arch()
44
+ break
45
+ }
46
+
47
+ return { platform, arch }
48
+ }
49
+
50
+ function findBinary() {
51
+ const { platform, arch } = detectPlatformAndArch()
52
+ const packageName = `@sleepy-ai/sleepycode-${platform}-${arch}`
53
+ const binaryName = platform === "windows" ? "sleepy.exe" : "sleepy"
54
+
55
+ try {
56
+ // Use require.resolve to find the package
57
+ const packageJsonPath = require.resolve(`${packageName}/package.json`)
58
+ const packageDir = path.dirname(packageJsonPath)
59
+ const binaryPath = path.join(packageDir, "bin", binaryName)
60
+
61
+ if (!fs.existsSync(binaryPath)) {
62
+ throw new Error(`Binary not found at ${binaryPath}`)
63
+ }
64
+
65
+ return { binaryPath, binaryName }
66
+ } catch (error) {
67
+ throw new Error(`Could not find package ${packageName}: ${error.message}`, { cause: error })
68
+ }
69
+ }
70
+
71
+ async function main() {
72
+ try {
73
+ if (os.platform() === "win32") {
74
+ // On Windows, the .exe is already included in the package and bin field points to it
75
+ // No postinstall setup needed
76
+ console.log("Windows detected: binary setup not needed (using packaged .exe)")
77
+ return
78
+ }
79
+
80
+ // On non-Windows platforms, just verify the binary package exists
81
+ // Don't replace the wrapper script - it handles binary execution
82
+ const { binaryPath } = findBinary()
83
+ const target = path.join(__dirname, "bin", ".sleepycode")
84
+ if (fs.existsSync(target)) fs.unlinkSync(target)
85
+ try {
86
+ fs.linkSync(binaryPath, target)
87
+ } catch {
88
+ fs.copyFileSync(binaryPath, target)
89
+ }
90
+ fs.chmodSync(target, 0o755)
91
+ } catch (error) {
92
+ console.error("Failed to setup sleepycode binary:", error.message)
93
+ process.exit(1)
94
+ }
95
+ }
96
+
97
+ try {
98
+ void main()
99
+ } catch (error) {
100
+ console.error("Postinstall script error:", error.message)
101
+ process.exit(0)
102
+ }