@promethea-research/sundial 0.2.3 → 0.3.4

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,30 @@
1
+ PROPRIETARY SOFTWARE LICENSE — ALL RIGHTS RESERVED (UNLICENSED)
2
+
3
+ Copyright (c) 2026 Promethea Research LLC. All rights reserved.
4
+
5
+ Sundial (@promethea-research/sundial), Uchi, Uchi 1, and all included software,
6
+ object code, bundles, interfaces, documentation, and trademarks are the sole and
7
+ exclusive proprietary property and confidential trade secrets of Promethea Research LLC.
8
+
9
+ 1. LIMITED RIGHT OF USE
10
+ Subject to compliance with the Promethea Research Terms of Service
11
+ (https://sundial.promethearesearch.com/terms) and Privacy Policy
12
+ (https://sundial.promethearesearch.com/privacy), Promethea Research LLC grants you a
13
+ limited, revocable, non-exclusive, non-transferable, non-sublicensable license to
14
+ install and execute the unmodified @promethea-research/sundial CLI solely to access
15
+ authorized Sundial and Uchi 1 services.
16
+
17
+ 2. STRICT PROHIBITIONS
18
+ No open-source license or ownership interest is granted by implication, estoppel, or
19
+ otherwise. Except to the narrow extent expressly prohibited by non-waivable applicable
20
+ law, you shall NOT:
21
+ (a) copy, redistribute, sublicense, sell, lease, or host this software for third parties;
22
+ (b) reverse engineer, decompile, disassemble, decrypt, deobfuscate, translate, modify,
23
+ or create derivative works of any bundle, binary, protocol, or runtime component;
24
+ (c) systematically probe, extract, invert, scrape, or perform model distillation,
25
+ synthetic dataset generation, or competing model training/evaluation using Sundial
26
+ or Uchi 1 outputs.
27
+
28
+ 3. DISCLAIMER & GOVERNING LAW
29
+ THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. Governed by the laws of
30
+ the State of Delaware, USA, as set forth at https://sundial.promethearesearch.com/terms.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Sundial (`@promethea-research/sundial`)
2
2
 
3
- **Sundial** is an agentic terminal harness and cognitive co-processor created by [Promethea Research](https://promethearesearch.com), powered by **Uchi**—Promethea Research's flagship cognitive model (**99.8% zero-shot mean across 48 industry and Non-Invasive BCI benchmarks**).
3
+ **Sundial** is an agentic terminal harness and cognitive workspace created by [Promethea Research LLC](https://promethearesearch.com), powered by **Uchi 1**—Promethea Research's proprietary flagship cognitive model.
4
4
 
5
- Sundial runs directly in your terminal, shares the same account, conversations, billing, and **Knowledge Graphs** as the [Sundial Web Workspace](https://sundial.promethearesearch.com) and Desktop App, and executes verified code edits and shell commands across Linux (`bash`), macOS (`zsh`), and Windows (`PowerShell` / `CMD`).
5
+ Sundial runs directly in your terminal, uses your current working directory (`cwd`) as its default workspace context (with explicit approval gates before reading any external directory via `/dirs` or `--add-dir`), automatically checks for updates before launch and in the background, and shares the same account, conversations, billing, and **Two-Tier Knowledge Graphs** (`user_kg` and `org_kg`) as the [Sundial Web Workspace](https://sundial.promethearesearch.com) and Desktop App.
6
6
 
7
7
  ---
8
8
 
@@ -13,25 +13,24 @@ Sundial runs directly in your terminal, shares the same account, conversations,
13
13
  Requires **Node.js 20+**:
14
14
 
15
15
  ```bash
16
- npm i @promethea-research/sundial
17
- ```
18
- *(Or globally with `npm i -g @promethea-research/sundial` — both register the `sundial` command in your terminal `PATH` automatically.)*
16
+ # Install globally in your PATH
17
+ npm i -g @promethea-research/sundial
19
18
 
20
- ### 2. Launch & Sign In
19
+ # Or run directly with npx
20
+ npx @promethea-research/sundial@latest
21
+ ```
21
22
 
22
- Run `sundial` in your terminal:
23
+ ### 2. Sign In & Launch
23
24
 
24
25
  ```bash
25
- sundial
26
- ```
27
-
28
- Inside the interactive terminal prompt, sign in to your Promethea Research account (or start immediately as a guest):
26
+ # Authenticate with your Promethea Research account in the browser (or start immediately with 20 free guest messages)
27
+ sundial login
29
28
 
30
- ```text
31
- /login
29
+ # Launch Sundial in the current directory
30
+ sundial
32
31
  ```
33
32
 
34
- ### 3. Run Non-Interactive / Headless Tasks (`sundial exec`)
33
+ ### 3. Headless & CI Execution (`sundial exec`)
35
34
 
36
35
  Execute a single turn or autonomous coding loop directly from scripts or CI pipelines:
37
36
 
@@ -39,10 +38,16 @@ Execute a single turn or autonomous coding loop directly from scripts or CI pipe
39
38
  # Single non-interactive prompt (streams reply to stdout)
40
39
  sundial exec "summarize the authentication flow in this repository"
41
40
 
42
- # Autonomous coding agent loop (plan -> edit -> run tests until passing)
41
+ # Autonomous coding loop (inspect -> edit -> run tests -> verify)
43
42
  sundial exec --code --approvals full-auto "fix the failing unit tests in src/auth"
44
43
 
45
- # Multi-turn scripted run from a JSON array of prompts with structured JSON output
44
+ # Generate and auto-approve an architectural plan before editing
45
+ sundial exec --code --plan --yes "refactor the billing webhook handler"
46
+
47
+ # Approve an external directory for read-only reference context
48
+ sundial --add-dir ../shared-contracts
49
+
50
+ # Multi-turn batch execution with structured JSON output
46
51
  sundial exec --turns prompts.json --json --pace 10
47
52
  ```
48
53
 
@@ -53,86 +58,86 @@ sundial exec --turns prompts.json --json --pace 10
53
58
  ### Synopsis
54
59
 
55
60
  ```bash
56
- sundial [folder] [options]
57
- sundial exec "<prompt>" [folder] [options]
58
- sundial exec --turns <file.json> [folder] [options]
61
+ sundial [folder] # Launch the interactive terminal UI (TUI)
62
+ sundial --continue [folder] # Resume the most recent session in this folder
63
+ sundial --resume [id] [folder] # Resume a saved session by ID (or latest if omitted)
64
+ sundial exec [options] "<prompt>" [dir] # Run a single non-interactive turn and print to stdout
65
+ sundial exec --code "<task>" [dir] # Run Uchi 1's autonomous coding loop
66
+ sundial exec --turns <file.json> [dir] # Run multiple turns from a JSON array of prompts
67
+ sundial update # Check for and install the latest Sundial CLI release
68
+ sundial login # Sign in to your Promethea Research account in the browser
69
+ sundial logout # Sign out of Sundial on this machine
59
70
  ```
60
71
 
61
72
  ### Options & Flags
62
73
 
63
74
  | Flag | Values / Format | Description |
64
75
  | :--- | :--- | :--- |
65
- | `--model <id>` | `uchi` *(default)* | Select the model for the session (`uchi` is Promethea Research's flagship model). |
66
- | `--effort <tier>` | `low` \| `medium` \| `high` | Reasoning depth and compute allocation per turn. |
67
- | `--approvals <mode>` | `suggest` \| `auto-edit` \| `full-auto` | Approval gate policy for file edits and shell commands (`suggest` asks before edits/commands; `auto-edit` applies file edits automatically and asks before shell commands; `full-auto` runs edits and sandboxed commands autonomously). |
68
- | `--sandbox <mode>` | `read-only` \| `workspace-write` | File-system write boundary (`read-only` prevents any file modifications; `workspace-write` restricts writes to the active project directory). |
69
- | `--code` | *(boolean, `exec` mode)* | Run Uchi's multi-step coding agent on the workspace (plan, edit files, and run verification tests). |
70
- | `--turns <path>` | `file.json` *(`exec` mode)* | Execute multiple sequential turns from a JSON array of prompt strings (`["turn 1", "turn 2"]`). |
71
- | `--json` | *(boolean, `exec` mode)* | Emit a single structured JSON object `{"replies": [...], "errors": [...]}` on `stdout`. |
72
- | `--pace <N>` | Positive integer *(`exec` mode)* | Rate-limit scripted executions to at most `N` turns per minute. |
73
- | `--server <url>` | URL | Override the Sundial backend endpoint (defaults to `https://sundial.promethearesearch.com` or `$PROMETHEA_URL`). |
74
- | `--version` | *(boolean)* | Print the installed `@promethea-research/sundial` version and exit. |
76
+ | `-h, --help` | *(boolean)* | Print CLI usage, commands, flags, and environment variables, then exit. |
77
+ | `-v, --version` | *(boolean)* | Print the installed `@promethea-research/sundial` version and exit. |
78
+ | `-r, --resume [id]` | Session ID *(optional)* | Resume session `<id>` (or the most recent session if omitted). |
79
+ | `--continue` | *(boolean)* | Continue the most recent session in the current workspace. |
80
+ | `-c, --code` | *(boolean, `exec` mode)* | Run Uchi 1's multi-step coding loop on the workspace folder. |
81
+ | `--plan` | *(boolean, `exec` mode)* | Build a read-only step-by-step plan before making edits. |
82
+ | `--approve-plan`, `-y, --yes` | *(boolean, `exec` mode)* | Approve and execute the generated plan in headless `exec --plan` mode. |
83
+ | `-m, --model <id>` | `uchi` *(default)* | Select the active model (`uchi` is Uchi 1, the flagship). |
84
+ | `-e, --effort <tier>` | `low` \| `medium` \| `high` | Thinking depth (`1×` metering — `$0` deep reasoning surcharge across all tiers). |
85
+ | `-a, --approvals <mode>` | `suggest` \| `auto-edit` \| `full-auto` | Approval policy (`suggest` asks before edits/commands; `auto-edit` applies workspace edits automatically; `full-auto` runs edits and non-destructive commands autonomously). |
86
+ | `--full-auto` | *(boolean)* | Shortcut for `--approvals full-auto`. |
87
+ | `-s, --sandbox <mode>` | `workspace-write` \| `read-only` | File-system write boundary (`read-only` prevents all file modifications; `workspace-write` restricts writes strictly to the active workspace). |
88
+ | `-C, --cwd <dir>` | Path | Run as if Sundial was started in `<dir>`. |
89
+ | `--add-dir <dir>` | Path *(repeatable)* | Pre-approve an additional directory outside `cwd` for read-only context. |
90
+ | `--no-auto-update` | *(boolean)* | Skip pre-launch auto-update and background update listener for this run. |
91
+ | `--turns <path>` | `file.json` *(`exec` mode)* | Execute sequential turns from a JSON array of prompt strings. |
92
+ | `--json` | *(boolean, `exec` mode)* | Emit structured JSON `{"replies": [...], "errors": [...]}` on `stdout`. |
93
+ | `--pace <N>` | Positive integer *(`exec` mode)* | Rate-limit batch runs to at most `N` turns per minute. |
94
+ | `--server <url>` | URL | Override the Sundial server endpoint (defaults to `https://sundial.promethearesearch.com`). |
75
95
 
76
96
  ---
77
97
 
78
- ## Interactive Slash Commands & Shortcuts
98
+ ## Interactive Session Controls & Shortcuts
79
99
 
80
- Inside the `sundial` terminal UI, type `/` to open the interactive command autocomplete menu:
100
+ Speak to **Uchi 1** in plain natural language—no task-forcing slash commands required. Session controls and shortcuts:
81
101
 
82
- | Command | Description |
102
+ | Control / Command | Description |
83
103
  | :--- | :--- |
84
- | `/code <task>` | Run Uchi's autonomous coding agent on the current folder: plan, edit files, and run tests until they pass. |
85
- | `/plan <task>` | Formulate a step-by-step architectural plan without modifying any files until you approve. |
86
- | `/btw <question>` | Ask a side-channel question using active workspace/thread context without polluting main conversation history. |
87
- | `/skills` | List active skills (`.sundial/skills/<name>/SKILL.md`, `.promethea/skills/<name>/SKILL.md`) and loaded instruction files. |
88
- | `/obsidian [path]` | Sync an Obsidian Markdown vault (`.md` notes, `[[wikilinks]]`, `#tags`, frontmatter) directly into your Personal Knowledge Graph. |
89
- | `/remote` | Pair this terminal session for remote control from the Sundial web or mobile workspace. |
90
- | `/model` | Switch the active model (`Uchi` is the flagship model). |
91
- | `/effort` | Choose reasoning effort tier (`low`, `medium`, or `high`). |
92
- | `/approvals` | Set approval policy (`suggest`, `auto-edit`, or `full-auto`). |
93
- | `/sandbox` | Set sandbox boundary (`read-only` or `workspace-write`). |
94
- | `/diff` | Inspect unified diffs of all file changes made in the current thread. |
95
- | `/undo` | Revert the most recent file modification made by Sundial. |
96
- | `/compact [focus]` | Summarize earlier turns in the thread to free up context window space (optionally specifying what details to preserve). |
97
- | `/new` | Start a clean conversation thread. |
98
- | `/resume` | Browse and resume an earlier conversation thread from your account. |
99
- | `/knowledge` | Open your Personal, Organizational, and Public Knowledge Graphs in the browser. |
100
- | `/init` | Create a starter `PROMETHEA.md` project instruction file in the current workspace. |
101
- | `/status` | Display current account, active plan, token allowance meters, model, sandbox policy, and loaded instruction files. |
102
- | `/usage` | View session, weekly, and monthly token allowance windows and remaining credits. |
104
+ | `Shift+Tab` | Toggle `Auto` ↔ `Plan First` interactive `Plan → Approve → Execute` mode (or cycle approval modes). |
105
+ | `! <cmd>` | Execute a shell command directly in the current workspace. |
106
+ | `# <instruction>` | Append a persistent project rule directly to `./PROMETHEA.md`. |
107
+ | `@<path>` | Attach a local file, image, PDF, or Office workbook/deck (prompts for approval before reading outside `cwd`). |
108
+ | `Ctrl+V` / `Alt+V` | Paste an image from your system clipboard as an `@attachment`. |
109
+ | `Ctrl+B` | Toggle the Background Daemons logs & active port status pane. |
110
+ | `Ctrl+Y` / `/copy` | Copy the latest Uchi 1 reply to your system clipboard. |
111
+ | `/dirs [path]` | View approved external directories or approve a new external directory for read-only context (alias: `/add-dir`). |
112
+ | `/update` | Check for and install the latest `@promethea-research/sundial` release immediately. |
113
+ | `/clear` | Clear the transcript and start a fresh thread (aliases: `/new`, `/reset`). |
114
+ | `/resume` | Browse and resume an earlier session (aliases: `/continue`, `/threads`, `/history`). |
115
+ | `/compact [focus]` | Summarize earlier turns in the thread to free up context window space. |
116
+ | `/diff` | Show unified diffs of all workspace file changes made in this session. |
117
+ | `/undo` | Revert the latest workspace file modification made by Sundial. |
118
+ | `/status` / `/usage` | Show account, active plan, 5h/weekly/monthly usage meters, sandbox policy, and approved directories. |
119
+ | `/approvals` | Inspect or switch approval policy (`suggest` / `auto-edit` / `full-auto`). |
120
+ | `/sandbox` | Inspect or switch sandbox mode (`workspace-write` / `read-only`). |
121
+ | `/model` | Show or select the active model (`Uchi 1`). |
122
+ | `/effort [tier]` | Set thinking depth (`low`, `medium`, or `high`). |
123
+ | `/init` | Create a starter `PROMETHEA.md` project instructions file in the workspace. |
103
124
  | `/upgrade` | Open Sundial plans and billing in your browser. |
104
- | `/login` | Authenticate this machine with your Promethea Research account via browser device code. |
105
- | `/logout` | Remove local authentication credentials from this machine. |
106
- | `/help` | List all interactive commands and keyboard shortcuts. |
107
- | `/quit` / `/exit` | Exit Sundial. |
108
-
109
- ### Prompt Shortcuts & Keybindings
110
-
111
- - **`@path/to/file`** — Attach a local file directly into the prompt context.
112
- - **`# <instruction>`** — Append a persistent project rule directly to `./PROMETHEA.md` (e.g., `# always run vitest before finishing`).
113
- - **`Shift+Tab`** — Cycle approval modes on the fly (`suggest` → `auto-edit` → `full-auto`).
114
- - **`Tab`** — Autocomplete the highlighted `/command`.
115
- - **`Esc`** — Stop an in-progress generation or agent turn immediately.
116
- - **`Ctrl+C`** — Stop an active turn, or exit Sundial when idle.
125
+ | `/login` / `/logout` | Sign in or sign out of your Promethea Research account on this machine. |
126
+ | `/help` | Show terminal shortcuts and session controls. |
127
+ | `/quit` / `/exit` | Leave Sundial (or press `Ctrl+C` when idle / `Esc` to interrupt an active turn). |
117
128
 
118
129
  ---
119
130
 
120
- ## Project Instructions (`PROMETHEA.md` / `UCHI.md` / `CLAUDE.md`) & Skills
121
-
122
- Sundial automatically loads plain-Markdown instruction files and custom skills from your repository so Uchi follows your build commands, coding conventions, and architectural rules on every turn. Files are merged from general to specific:
123
-
124
- 1. `~/.config/promethea/PROMETHEA.md` and `~/.config/promethea/UCHI.md` — Your personal global instructions across all projects.
125
- 2. `SUNDIAL.md`, `PROMETHEA.md`, `UCHI.md`, `CLAUDE.md`, or `AGENTS.md` — Read from the Git repository root down to the current working directory.
126
- 3. `.promethea/PROMETHEA.md` and `.sundial/SUNDIAL.md` — Checked-in workspace instructions.
127
- 4. `.sundial/skills/<name>/SKILL.md` and `.promethea/skills/<name>/SKILL.md` — Modular skills loaded automatically into the session.
131
+ ## Automatic Updates & Workspace Directory Boundaries
128
132
 
129
- Run `/init` inside `sundial` to generate a `PROMETHEA.md` template in your current directory, or prefix any prompt with `# ` to append a rule automatically.
133
+ - **Always Up to Date:** Before launching the terminal UI, Sundial checks `npmjs.com` for a newer `@promethea-research/sundial` release, installs it automatically, and re-launches seamlessly—while also listening in the background during long sessions so `/update` or your next launch picks up new releases immediately. Set `PROMETHEA_NO_AUTO_UPDATE=1` (or `--no-auto-update`) to opt out.
134
+ - **Directory Context & Explicit External Read Approval:** Sundial defaults to the directory where you launch it (`process.cwd()`). Any attempt to read files or list directories outside your current workspace triggers an interactive `[y] Allow once / [a] Always allow directory / [n] Deny` prompt (or pre-approve paths via `/dirs <path>` or `--add-dir <path>`). Writes remain strictly confined to your active workspace.
130
135
 
131
136
  ---
132
137
 
133
- ## Model Context Protocol (MCP) Servers
138
+ ## Project Instructions (`PROMETHEA.md` / `UCHI.md`) & MCP Servers
134
139
 
135
- Sundial supports local **MCP (`2025-06-18`) stdio servers** out of the box. Configure MCP servers in either `.promethea/sundial.json` (project-scoped) or `~/.config/promethea/sundial.json` (user-scoped):
140
+ Sundial automatically merges plain-Markdown project instructions (`~/.config/promethea/PROMETHEA.md`, `SUNDIAL.md`, `PROMETHEA.md`, `UCHI.md`, `CLAUDE.md`, `AGENTS.md`, and `.sundial/skills/<name>/SKILL.md`) and supports local **MCP (`2025-06-18`) stdio servers** configured in `.promethea/sundial.json` or `~/.config/promethea/sundial.json`:
136
141
 
137
142
  ```json
138
143
  {
@@ -147,28 +152,6 @@ Sundial supports local **MCP (`2025-06-18`) stdio servers** out of the box. Conf
147
152
  }
148
153
  ```
149
154
 
150
- When Sundial starts, it initializes each configured MCP server over JSON-RPC stdio and exposes its tools to Uchi. By default, MCP tool calls require user confirmation unless `"autoApprove": true` is explicitly set for that server.
151
-
152
- ---
153
-
154
- ## Configuration & Environment Variables
155
-
156
- - **Config File Location:** `~/.config/promethea/sundial.json` (or `$XDG_CONFIG_HOME/promethea/sundial.json`, overridable via `$SUNDIAL_CONFIG_DIR`). Created with `0600` user-only permissions.
157
- - **`PROMETHEA_URL`:** Optional environment variable to override the default server URL (`https://sundial.promethearesearch.com`).
158
-
159
- ---
160
-
161
- ## Uchi Flagship Benchmark Highlights
162
-
163
- Uchi achieves a **99.8% zero-shot mean across 48 industry and Non-Invasive BCI benchmarks**:
164
-
165
- - **100.0%** SWE-bench Verified & GPQA Diamond
166
- - **100.0%** AIME & OSWorld
167
- - **99.95%** FrontierMath
168
- - **100.0%** Non-Invasive BCI Intent Decoding
169
-
170
- Explore the complete 48-benchmark breakdown at [sundial.promethearesearch.com/uchi](https://sundial.promethearesearch.com/uchi).
171
-
172
155
  ---
173
156
 
174
157
  ## Official Links & Support
@@ -176,14 +159,16 @@ Explore the complete 48-benchmark breakdown at [sundial.promethearesearch.com/uc
176
159
  - **Sundial Web Workspace:** [https://sundial.promethearesearch.com](https://sundial.promethearesearch.com)
177
160
  - **CLI Documentation:** [https://sundial.promethearesearch.com/docs/cli](https://sundial.promethearesearch.com/docs/cli)
178
161
  - **API Reference:** [https://sundial.promethearesearch.com/docs/api](https://sundial.promethearesearch.com/docs/api)
179
- - **Uchi Model & Benchmarks:** [https://sundial.promethearesearch.com/uchi](https://sundial.promethearesearch.com/uchi)
162
+ - **Uchi 1 Overview:** [https://sundial.promethearesearch.com/uchi](https://sundial.promethearesearch.com/uchi)
180
163
  - **Pricing & Plans:** [https://sundial.promethearesearch.com/pricing](https://sundial.promethearesearch.com/pricing)
181
164
  - **Promethea Research:** [https://promethearesearch.com](https://promethearesearch.com)
182
165
  - **Security & Privacy:** [https://sundial.promethearesearch.com/security](https://sundial.promethearesearch.com/security)
183
- - **Support:** [support@promethearesearch.com](mailto:support@promethearesearch.com)
166
+ - **Support:** [support@promethearesearch.com](mailto:support@promethearesearch.com) · **Feedback:** [feedback@promethearesearch.com](mailto:feedback@promethearesearch.com)
184
167
 
185
168
  ---
186
169
 
187
- ## License
170
+ ## License — All Rights Reserved (`UNLICENSED`)
171
+
172
+ Copyright © 2026 Promethea Research LLC. All rights reserved.
188
173
 
189
- Copyright © Promethea Research LLC. All rights reserved. Use of `@promethea-research/sundial` is governed by the Promethea Research [Terms of Service](https://sundial.promethearesearch.com/terms) and [Privacy Policy](https://sundial.promethearesearch.com/privacy).
174
+ `@promethea-research/sundial`, **Sundial**, **Uchi**, and **Uchi 1** are proprietary software and confidential trade secrets of **Promethea Research LLC** (see `LICENSE`). No open-source license is granted. Copying, redistribution, reverse engineering, decompilation, disassembly, decryption, systematic probing, or training/distillation on outputs is strictly prohibited. Governed by the [Terms of Service](https://sundial.promethearesearch.com/terms) and [Privacy Policy](https://sundial.promethearesearch.com/privacy).
@@ -1,84 +1,2 @@
1
1
  #!/usr/bin/env node
2
- // Ensures `sundial` is runnable directly in the terminal even after `npm i @promethea-research/sundial` (without -g).
3
- import fs from "node:fs";
4
- import os from "node:os";
5
- import path from "node:path";
6
- import { spawnSync } from "node:child_process";
7
- import { fileURLToPath } from "node:url";
8
-
9
- try {
10
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
11
- const entry = path.resolve(__dirname, "sundial.js");
12
- try { fs.chmodSync(entry, 0o755); } catch {}
13
-
14
- const home = os.homedir();
15
- const pathDirs = (process.env.PATH || "")
16
- .split(path.delimiter)
17
- .map((d) => d.trim())
18
- .filter((d) => d && !d.includes("node_modules"));
19
-
20
- if (process.platform === "win32") {
21
- const cmdScript = `@echo off\r\nnode "${entry}" %*\r\n`;
22
- const shScript = `#!/usr/bin/env sh\nexec node "${entry.replace(/\\/g, "/")}" "$@"\n`;
23
- const winCandidates = [
24
- process.env.APPDATA ? path.join(process.env.APPDATA, "npm") : "",
25
- process.env.LOCALAPPDATA ? path.join(process.env.LOCALAPPDATA, "Microsoft", "WindowsApps") : "",
26
- ...pathDirs,
27
- ].filter(Boolean);
28
- for (const dir of new Set(winCandidates)) {
29
- try {
30
- fs.mkdirSync(dir, { recursive: true });
31
- fs.writeFileSync(path.join(dir, "sundial.cmd"), cmdScript, "utf8");
32
- fs.writeFileSync(path.join(dir, "sundial"), shScript, { mode: 0o755 });
33
- } catch {}
34
- }
35
- } else {
36
- const shScript = `#!/usr/bin/env sh\nexec "${process.execPath}" "${entry}" "$@"\n`;
37
- const localBin = path.join(home, ".local", "bin");
38
- const localBinTarget = path.join(localBin, "sundial");
39
- try {
40
- fs.mkdirSync(localBin, { recursive: true });
41
- fs.writeFileSync(localBinTarget, shScript, { mode: 0o755 });
42
- fs.chmodSync(localBinTarget, 0o755);
43
- } catch {}
44
-
45
- const candidates = new Set([
46
- path.dirname(process.execPath),
47
- localBin,
48
- ...pathDirs,
49
- ]);
50
-
51
- let installedInPath = false;
52
- for (const dir of candidates) {
53
- if (!dir) continue;
54
- try {
55
- if (dir.startsWith(home)) {
56
- fs.mkdirSync(dir, { recursive: true });
57
- }
58
- const target = path.join(dir, "sundial");
59
- fs.writeFileSync(target, shScript, { mode: 0o755 });
60
- fs.chmodSync(target, 0o755);
61
- if (pathDirs.includes(dir)) installedInPath = true;
62
- } catch {}
63
- }
64
-
65
- if (!installedInPath && pathDirs.includes("/usr/local/bin") && fs.existsSync(localBinTarget)) {
66
- try {
67
- spawnSync("sudo", ["-n", "cp", "-f", localBinTarget, "/usr/local/bin/sundial"], { stdio: "ignore", timeout: 2000 });
68
- spawnSync("sudo", ["-n", "chmod", "0755", "/usr/local/bin/sundial"], { stdio: "ignore", timeout: 2000 });
69
- } catch {}
70
- }
71
-
72
- for (const rc of [".bashrc", ".zshrc", ".profile"]) {
73
- const rcPath = path.join(home, rc);
74
- try {
75
- if (fs.existsSync(rcPath)) {
76
- const content = fs.readFileSync(rcPath, "utf8");
77
- if (!content.includes(".local/bin")) {
78
- fs.appendFileSync(rcPath, '\nexport PATH="$HOME/.local/bin:$PATH"\n');
79
- }
80
- }
81
- } catch {}
82
- }
83
- }
84
- } catch {}
2
+ import m from"node:fs";import o from"node:path";import{fileURLToPath as t}from"node:url";try{const r=o.dirname(t(import.meta.url));m.chmodSync(o.resolve(r,"sundial.js"),493)}catch{}