Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bin/
obj/
*.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 cemheren

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>QuickSheetMoon</RootNamespace>
<AssemblyName>MoonExtension</AssemblyName>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
using System.Globalization;
using System.Text.Json;

// QuickSheet moon extension — ambient lunar-phase widget for your desktop grid.
//
// Cell usage examples:
// moon: → today's phase: emoji, name, illumination %, moon age
// moon: today → same as bare "moon:"
// moon: 2026-12-25 → phase on a specific date (YYYY-MM-DD)
// moon: next full → date of the next full moon from today
// moon: next new → date of the next new moon from today
//
// Everything is computed locally from a standard synodic-month approximation
// anchored to a known new moon (2000-01-06 18:14 UTC). No network, no API key,
// no state — perfect as an always-on wallpaper cell that never flickers offline.

const double SynodicMonth = 29.530588853; // mean length of a lunar cycle, days
const double KnownNewMoonJd = 2451550.1; // 2000-01-06 18:14 UTC, a reference new moon

Console.OutputEncoding = System.Text.Encoding.UTF8;
Console.WriteLine(JsonSerializer.Serialize(new
{
type = "register",
prefix = "moon",
name = "Lunar Phase",
version = "1.0.0",
}));
Console.Out.Flush();

string? line;
while ((line = Console.ReadLine()) != null)
{
if (string.IsNullOrWhiteSpace(line)) continue;
try
{
using var doc = JsonDocument.Parse(line);
if (!doc.RootElement.TryGetProperty("type", out var t)) continue;
if (t.GetString() != "activate") continue;
HandleActivate(doc.RootElement);
}
catch { /* swallow malformed input lines */ }
}

void HandleActivate(JsonElement root)
{
string id = root.TryGetProperty("id", out var idEl) ? idEl.GetString() ?? "" : "";

string spec = "";
if (root.TryGetProperty("params", out var p) && p.ValueKind == JsonValueKind.Array)
{
var en = p.EnumerateArray();
if (en.MoveNext()) spec = en.Current.GetString() ?? "";
}
spec = spec.Trim();

if (spec.Length == 0 || spec.Equals("today", StringComparison.OrdinalIgnoreCase))
{
Emit(id, DescribePhase(DateTime.UtcNow));
return;
}

if (spec.StartsWith("next", StringComparison.OrdinalIgnoreCase))
{
string which = spec[4..].Trim().ToLowerInvariant();
if (which is "full")
{
var d = NextPhase(DateTime.UtcNow, 0.5);
Emit(id, $"🌕 next full moon: {d:yyyy-MM-dd} ({(d - DateTime.UtcNow).Days}d away)");
return;
}
if (which is "new" or "")
{
var d = NextPhase(DateTime.UtcNow, 0.0);
Emit(id, $"🌑 next new moon: {d:yyyy-MM-dd} ({(d - DateTime.UtcNow).Days}d away)");
return;
}
Emit(id, "moon: next full | next new");
return;
}

if (DateTime.TryParse(spec, CultureInfo.InvariantCulture,
DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal, out var when))
{
Emit(id, DescribePhase(when));
return;
}

Emit(id, "moon: [today | YYYY-MM-DD | next full | next new]");
}

string DescribePhase(DateTime utc)
{
double age = MoonAgeDays(utc); // 0..SynodicMonth
double frac = age / SynodicMonth; // 0..1 through the cycle
double illum = (1 - Math.Cos(2 * Math.PI * frac)) / 2.0; // 0=new, 1=full
var (emoji, name) = PhaseLabel(frac);
return $"{emoji} {name} · {illum * 100:0}% lit · age {age:0.0}d";
}

(string emoji, string name) PhaseLabel(double frac)
{
// Eight principal phases, each a 1/8 slice of the cycle centred on its phase point.
double f = ((frac % 1) + 1) % 1;
int slice = (int)Math.Floor(f * 8 + 0.5) % 8;
return slice switch
{
0 => ("🌑", "New Moon"),
1 => ("🌒", "Waxing Crescent"),
2 => ("🌓", "First Quarter"),
3 => ("🌔", "Waxing Gibbous"),
4 => ("🌕", "Full Moon"),
5 => ("🌖", "Waning Gibbous"),
6 => ("🌗", "Last Quarter"),
_ => ("🌘", "Waning Crescent"),
};
}

double MoonAgeDays(DateTime utc)
{
double jd = ToJulianDate(utc);
double age = (jd - KnownNewMoonJd) % SynodicMonth;
if (age < 0) age += SynodicMonth;
return age;
}

// Find the next datetime (after `from`) at which the cycle fraction equals `targetFrac`
// (0.0 = new moon, 0.5 = full moon).
DateTime NextPhase(DateTime from, double targetFrac)
{
double age = MoonAgeDays(from);
double curFrac = age / SynodicMonth;
double delta = targetFrac - curFrac;
if (delta <= 0) delta += 1.0;
double daysAhead = delta * SynodicMonth;
return from.AddDays(daysAhead);
}

static double ToJulianDate(DateTime utc)
{
int year = utc.Year, month = utc.Month;
double day = utc.Day + (utc.Hour + utc.Minute / 60.0 + utc.Second / 3600.0) / 24.0;
if (month <= 2) { year -= 1; month += 12; }
int a = year / 100;
int b = 2 - a + a / 4;
return Math.Floor(365.25 * (year + 4716))
+ Math.Floor(30.6001 * (month + 1))
+ day + b - 1524.5;
}

void Emit(string id, string text)
{
var cells = new[] { new { r = 0, c = 0, v = text } };
Console.WriteLine(JsonSerializer.Serialize(new { type = "write", id, cells }));
Console.Out.Flush();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# quicksheet-moon-ext

A [QuickSheet](https://github.com/cemheren/QuickSheet) extension that turns a cell
into a live lunar-phase widget — phase emoji, name, illumination %, and the moon's
age in days. Great as an ambient cell on your desktop-wallpaper grid.

It is **fully offline and deterministic**: the phase is computed locally from a
standard synodic-month approximation anchored to a known new moon. No network, no
API key, no rate limits — so it never flickers or goes blank when you're offline,
which matters for a cell that lives on your wallpaper 24/7.

## Install

```
ext: github:Deskworks/quicksheet-moon-ext
```

## Usage

```
moon: → today's phase: emoji, name, illumination %, age in days
moon: today → same as bare moon:
moon: 2026-12-25 → phase on a specific date (YYYY-MM-DD)
moon: next full → date of the next full moon
moon: next new → date of the next new moon
```

### Example output

| Cell | Result |
|-----------------|-------------------------------------------------|
| `moon:` | `🌓 First Quarter · 37% lit · age 6.2d` |
| `moon: 2026-12-25` | `🌕 Full Moon · 99% lit · age 15.7d` |
| `moon: next full` | `🌕 next full moon: 2026-06-29 (8d away)` |
| `moon: next new` | `🌑 next new moon: 2026-07-14 (23d away)` |

The eight principal phases each map to the matching Unicode moon glyph
(🌑 🌒 🌓 🌔 🌕 🌖 🌗 🌘), so a column of dates renders as a little phase strip.

> _Screenshot placeholder — drop a `--desktop` capture of a moon: cell here._

## Why

- **Ricers / `r/unixporn`** — an always-on moon glyph that tracks the real sky is a
clean, low-noise wallpaper widget that needs zero setup.
- **Photographers & gardeners** — quick "is it near full?" / "when's the next new
moon?" lookups without opening an app.
- **Anyone who just likes the moon** — `=moon:` is a one-keystroke sky check.

## Accuracy

Uses the mean synodic month (29.530589 days) from a reference new moon
(2000-01-06 18:14 UTC). Phase name and illumination are accurate to well within a
day for any modern date — plenty for an ambient widget. It does not model the
small libration/perigee perturbations an ephemeris would.

## Protocol

Speaks QuickSheet's JSON-lines extension protocol: emits a `register` message on
startup, then responds to each `activate` with a `write`. See the
[extension protocol spec](https://github.com/cemheren/QuickSheet/blob/main/docs/extension-protocol.md).

## Build

```
dotnet build MoonExtension.csproj
```

Zero NuGet dependencies. .NET 9.

## License

MIT — see [LICENSE](LICENSE).
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "moon",
"version": "1.0.0",
"prefix": "moon",
"description": "Live lunar phase widget for QuickSheet — phase name, illumination %, emoji, next new/full moon. Zero network, zero auth, fully deterministic.",
"entry": "dotnet run --project MoonExtension.csproj",
"minProtocolVersion": 1
}
7 changes: 7 additions & 0 deletions .claude/skills/grow-quicksheet/log.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 2026-06-19 (no-op #35 — saturation hold, 100 open PRs)

- Stars: 0 (Δ 0). Full sweep: main repo has 8 open issues (#374, #372, #321, #320, #319, #318, #158, #3); every one already has 1–3 duplicate addressing PRs open. Ext repos (50+ `quicksheet-*`): 0 open issues. Open PR count on main = **100**, last merge ~3 weeks ago — backlog is fully merge-gated on the user. Every distribution asset that doesn't touch the PR pile (social drafts for HN/Reddit/Lobsters/Twitter/Mastodon/dev.to, awesome-list submissions, persona research, launch-venue briefs) already exists under `drafts/` + `research/`. Producing a 101st PR or a duplicate draft = manufactured filler, which Boundaries forbid. Genuine bottleneck is user merge/post throughput, which the skill cannot do.
- Bucket: none (no-op).
- Outcome: skill-only log entry. No project code, no new PR, no new draft.
- Follow-up: keep no-op'ing until PR backlog drains or a fresh real-user issue/PR appears. Next actionable signal = (a) user merges a batch of PRs, or (b) a new issue with no existing PR lands on main or an ext repo.

## 2026-05-19 (no-op #31 — #139 still open, hold)

- Stars: 0 (Δ 0). PR #139 still open, no other action items. Hold.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ tls: github.com, 1, 4
| `caniuse:` | Browser compat lookup via caniuse-db — `caniuse: css-grid` · `caniuse: flexbox` · `caniuse: webassembly`. Shows support across Chrome/Firefox/Safari/Edge + usage %. No API key. | `ext: github:Deskworks/quicksheet-caniuse` |
| `gem:` | Ruby gem lookup via rubygems.org — version, total downloads, authors, license, homepage, description. `gem: rails` (detail) · `gem: search json parser` (top 5). No API key. | `ext: github:Deskworks/quicksheet-rubygems` |
| `hackage:` | Haskell package lookup from Hackage — `hackage: aeson` (version, synopsis, author, category, license, homepage) · `hackage: search json` (top results). No API key. | `ext: github:Deskworks/quicksheet-hackage` |
| `moon:` | Live lunar phase — emoji, name, illumination %, moon age. `moon:` (today) · `moon: 2026-12-25` · `moon: next full` · `moon: next new`. Fully offline, zero API key, deterministic. | `ext: github:Deskworks/quicksheet-moon-ext` |

See [docs/extensions.md](docs/extensions.md) for the full directory with descriptions and protocol docs.

Expand Down
1 change: 1 addition & 0 deletions docs/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ A live index of QuickSheet extensions. Each one is an independent repo that regi
| `caniuse` | Browser Compat | Can I Use browser compatibility lookup via caniuse-db. Shows support status for CSS/HTML/JS features across Chrome, Firefox, Safari, Edge, Opera, Samsung, iOS Safari. Usage: `caniuse: css-grid` · `caniuse: flexbox` · `caniuse: webassembly`. Usage %, spec link, notes. 1h cache, no API key. | [`quicksheet-caniuse`](https://github.com/Deskworks/quicksheet-caniuse) |
| `gem` | Ruby Gem Lookup | Ruby gem info and search via rubygems.org. Version, total downloads, authors, license, Ruby requirement, homepage, description. `gem: rails` (detail), `gem: search json parser` (top 5). No API key, 30-min cache, zero NuGet. | [`quicksheet-rubygems`](https://github.com/Deskworks/quicksheet-rubygems) |
| `hackage` | Haskell Packages | Haskell package lookup from Hackage. `hackage: aeson` shows latest version, synopsis, author, category, license, and homepage. `hackage: search json` lists top matching packages. No API key, 30-min cache, zero NuGet. | [`quicksheet-hackage`](https://github.com/Deskworks/quicksheet-hackage) |
| `moon` | Lunar Phase | Live lunar phase widget — fully offline, deterministic, no API key. `moon:` (today's phase emoji, name, illumination %, age), `moon: 2026-12-25` (phase on a date), `moon: next full`, `moon: next new`. Computed from the synodic month; great as an ambient wallpaper cell. | [`quicksheet-moon-ext`](https://github.com/Deskworks/quicksheet-moon-ext) |

## Install

Expand Down
1 change: 1 addition & 0 deletions docs/tour.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Currently public:
- [`quicksheet-qtr`](https://github.com/Deskworks/quicksheet-qtr) — IRS quarterly tax deadline countdown.
- [`quicksheet-fx`](https://github.com/Deskworks/quicksheet-fx) — live currency conversion (200+ currencies, ECB rates).
- [`quicksheet-rate`](https://github.com/Deskworks/quicksheet-rate) — freelance hourly rate calculator (taxes, benefits, billable time).
- [`quicksheet-moon-ext`](https://github.com/Deskworks/quicksheet-moon-ext) — live lunar phase widget (offline, deterministic).

[Write your own](../README.md#build-your-own) in whatever language you want — the protocol is two message types.

Expand Down