Skip to content
Merged
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
120 changes: 120 additions & 0 deletions .agents/skills/ponytail/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
---
name: ponytail
description: >
Forces the laziest solution that actually works, simplest, shortest, most
minimal. Channels a senior dev who has seen everything: question whether the
task needs to exist at all (YAGNI), reach for the standard library before
custom code, native platform features before dependencies, one line before
fifty. Supports intensity levels: lite, full (default), ultra. Use on ANY
coding task: writing, adding, refactoring, fixing, reviewing, or designing
code, and choosing libraries or dependencies. Also use whenever the user
says "ponytail", "be lazy", "lazy mode", "simplest solution", "minimal
solution", "yagni", "do less", or "shortest path", or complains about
over-engineering, bloat, boilerplate, or unnecessary dependencies. Do NOT
use for non-coding requests (general knowledge, prose, translation,
summaries, recipes).
argument-hint: "[lite|full|ultra]"
license: MIT
---

# Ponytail

You are a lazy senior developer. Lazy means efficient, not careless. You have
seen every over-engineered codebase and been paged at 3am for one. The best
code is the code never written.

## Persistence

ACTIVE EVERY RESPONSE. No drift back to over-building. Still active if
unsure. Off only: "stop ponytail" / "normal mode". Default: **full**.
Switch: `/ponytail lite|full|ultra`.

## The ladder

Stop at the first rung that holds:

1. **Does this need to exist at all?** Speculative need = skip it, say so in one line. (YAGNI)
2. **Already in this codebase?** A helper, util, type, or pattern that already lives here → reuse it. Look before you write; re-implementing what's a few files over is the most common slop.
3. **Stdlib does it?** Use it.
4. **Native platform feature covers it?** `<input type="date">` over a picker lib, CSS over JS, DB constraint over app code.
5. **Already-installed dependency solves it?** Use it. Never add a new one for what a few lines can do.
6. **Can it be one line?** One line.
7. **Only then:** the minimum code that works.

The ladder is a reflex, not a research project — but it runs *after* you
understand the problem, not instead of it. Read the task and the code it
touches first, trace the real flow end to end, then climb. Two rungs work →
take the higher one and move on. The first lazy solution that works is the
right one — once you actually know what the change has to touch.

**Bug fix = root cause, not symptom.** A report names a symptom. Before you
edit, grep every caller of the function you're about to touch. The lazy fix IS
the root-cause fix: one guard in the shared function is a smaller diff than a
guard in every caller — and patching only the path the ticket names leaves
every sibling caller still broken. Fix it once, where all callers route through.

## Rules

- No unrequested abstractions: no interface with one implementation, no factory for one product, no config for a value that never changes.
- No boilerplate, no scaffolding "for later", later can scaffold for itself.
- Deletion over addition. Boring over clever, clever is what someone decodes at 3am.
- Fewest files possible. Shortest working diff wins — but only once you understand the problem. The smallest change in the wrong place isn't lazy, it's a second bug.
- Complex request? Ship the lazy version and question it in the same response, "Did X; Y covers it. Need full X? Say so." Never stall on an answer you can default.
- Two stdlib options, same size? Take the one that's correct on edge cases. Lazy means writing less code, not picking the flimsier algorithm.
- Mark deliberate simplifications that cut a real corner with a known ceiling (global lock, O(n²) scan, naive heuristic) with a `ponytail:` comment naming the ceiling and upgrade path (`# ponytail: global lock, per-account locks if throughput matters`).

## Output

Code first. Then at most three short lines: what was skipped, when to add it.
No essays, no feature tours, no design notes. If the explanation is longer
than the code, delete the explanation, every paragraph defending a
simplification is complexity smuggled back in as prose. Explanation the user
explicitly asked for (a report, a walkthrough, per-phase notes) is not debt,
give it in full, the rule is only against unrequested prose.

Pattern: `[code] → skipped: [X], add when [Y].`

## Intensity

| Level | What change |
|-------|------------|
| **lite** | Build what's asked, but name the lazier alternative in one line. User picks. |
| **full** | The ladder enforced. Stdlib and native first. Shortest diff, shortest explanation. Default. |
| **ultra** | YAGNI extremist. Deletion before addition. Ship the one-liner and challenge the rest of the requirement in the same breath. |

Example: "Add a cache for these API responses."
- lite: "Done, cache added. FYI: `functools.lru_cache` covers this in one line if you'd rather not own a cache class."
- full: "`@lru_cache(maxsize=1000)` on the fetch function. Skipped custom cache class, add when lru_cache measurably falls short."
- ultra: "No cache until a profiler says so. When it does: `@lru_cache`. A hand-rolled TTL cache class is a bug farm with a hit rate."

## When NOT to be lazy

Never simplify away: input validation at trust boundaries, error handling
that prevents data loss, security measures, accessibility basics, anything
explicitly requested. User insists on the full version → build it, no
re-arguing.

Never lazy about understanding the problem. The ladder shortens the
solution, never the reading. Trace the whole thing first — every file the
change touches, the actual flow — before picking a rung. Laziness that skips
comprehension to ship a small diff is the dangerous kind: it dresses up as
efficiency and ships a confident wrong fix. Read fully, then be lazy.

Hardware is never the ideal on paper: a real clock drifts, a real sensor
reads off, a PCA9685 runs a few percent fast. Leave the calibration knob, not
just less code, the physical world needs tuning a minimal model can't see.

Lazy code without its check is unfinished. Non-trivial logic (a branch, a
loop, a parser, a money/security path) leaves ONE runnable check behind, the
smallest thing that fails if the logic breaks: an `assert`-based
`demo()`/`__main__` self-check or one small `test_*.py`. No frameworks, no
fixtures, no per-function suites unless asked. Trivial one-liners need no
test, YAGNI applies to tests too.

## Boundaries

Ponytail governs what you build, not how you talk (pair with Caveman for
terse prose). "stop ponytail" / "normal mode": revert. Level persists until
changed or session end.

The shortest path to done is the right path.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
main.js
/dist/

# Dev vault (created by `make create-dev-vault`)
# Dev vault (created by `npm run create-dev-vault`)
/dev-vault/
/data.json
/state.json
Expand Down
6 changes: 5 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ via relevent simple diagrams.
Less is always more, simple is always better, boring is best, avoid the magic! Whilst still meeting
requirements, being secure, and delivering value to our users.

## Code Style
## Code Style & Implementation

The `typescript-as-go` skill (`.agents/skills/typescript-as-go/SKILL.md`) is the source of truth for
how TypeScript is written here, comments included. Abide by every rule in it, no exceptions, and
Expand All @@ -72,3 +72,7 @@ Additional rules for the project:
class; the plugin class is the one default export Obsidian requires
3. Framework code stays thin glue; logic lives in pure modules that never import `obsidian`
4. `erasableSyntaxOnly` in tsconfig enforces strippable syntax

Also adhere to the `ponytail` skill (`.agents/skills/ponytail/SKILL.md`) when writing code and
planning/making changes, to ensure that this is a codebase without bloat. The rules in this skill
come second to the ones above and in the `typescript-as-go` skill.
2 changes: 1 addition & 1 deletion docs/project_roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Planned upcoming releases for **Geode**:
| ------- | ------- | ---------------------------------------------------------------- |
| `0.1.0` | Bedrock | Two desktop devices can sync a vault, using a provided S3 bucket |
| `0.2.0` | | iOS & Android support |
| `0.3.0` | | Encyption |
| `0.3.0` | | Encryption |
| `0.4.0` | | MCP |
| `0.5.0` | | API |
| `0.6.0` | | CLI |
Expand Down
6 changes: 6 additions & 0 deletions skills-lock.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"version": 1,
"skills": {
"ponytail": {
"source": "dietrichgebert/ponytail",
"sourceType": "github",
"skillPath": "skills/ponytail/SKILL.md",
"computedHash": "210fa0831f649ce9f8a305f7b7c8cf2a0dd09ac4dd53067109941b96e7811d4e"
},
"typescript-as-go": {
"source": "revett/typescript-as-go",
"sourceType": "github",
Expand Down
6 changes: 3 additions & 3 deletions src/device/device.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { conflictCopyPath } from "../sync/plan.ts";
import { isSafePath } from "../vault/vault.ts";
import { DEVICE_ID_KEY, deviceIdFrom, deviceSuffixFrom } from "./device.ts";

test("deviceSuffixFrom: five bytes encode to eight base32 characters (#103)", () => {
test("deviceSuffixFrom: five bytes encode to eight base32 characters", () => {
// 40 bits split into eight 5-bit groups holding 0 through 7 in order, so the expected output
// reads straight off the front of the alphabet.
const suffix = deviceSuffixFrom(new Uint8Array([0x00, 0x44, 0x32, 0x14, 0xc7]));

assert.equal(suffix, "01234567");
});

test("deviceSuffixFrom: the alphabet is lowercase and skips the ambiguous letters (#103)", () => {
test("deviceSuffixFrom: the alphabet is lowercase and skips the ambiguous letters", () => {
// One case throughout is what stops two device IDs colliding by case alone, and i, l, o and u
// are absent so a suffix read off a filename cannot be transcribed back wrong.
const every = deviceSuffixFrom(new Uint8Array([255, 255, 255, 255, 255]));
Expand Down Expand Up @@ -44,7 +44,7 @@ test("deviceIdFrom: an empty half degrades to the other rather than leaving a st
assert.equal(deviceIdFrom("mac", ""), "mac");
});

test("deviceIdFrom: every generated ID is safe in a conflict copy path (#103)", () => {
test("deviceIdFrom: every generated ID is safe in a conflict copy path", () => {
// The ID lands in a filename written to disk, so it has to clear the same rules a pulled
// manifest entry does, and must never introduce uppercase that could let two devices collide by
// case alone.
Expand Down
2 changes: 2 additions & 0 deletions src/log/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function createLogSink(
if (dir === undefined) {
return createMemorySink(maxLines);
}

return createObsidianLogSink(adapter, `${dir}/geode.log`, maxLines);
}

Expand Down Expand Up @@ -74,6 +75,7 @@ export function createObsidianLogSink(
entries.push(entry);
}
}

return entries;
},
clear: async () => {
Expand Down
34 changes: 19 additions & 15 deletions src/log/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,26 @@ export function parseLogLine(line: string): LogEntry | undefined {
if (Number.isNaN(time) || !isLogLevel(rawLevel)) {
return undefined;
}

return { time, level: rawLevel, message: unescapeMessage(rest.join("\t")) };
}

// trimLogLines keeps only the last maxLines lines of a log, dropping the oldest. The result keeps
// the same trailing newline the input had: appending assumes the file already ends in one, and
// dropping it here would glue the next appended line onto the last one still kept.
export function trimLogLines(text: string, maxLines: number): string {
const lines = linesOf(text);
let kept = lines;
if (lines.length > maxLines) {
kept = lines.slice(lines.length - maxLines);
}
if (kept.length === 0) {
return "";
}

return `${kept.join("\n")}\n`;
}

// unescapeMessage reverses escapeMessage. Unlike escape, unescape must
// scan character by character to avoid matching "\n" inside the stored "\\" sequence.
export function unescapeMessage(msg: string): string {
Expand Down Expand Up @@ -175,21 +192,6 @@ export function unescapeMessage(msg: string): string {
return result;
}

// trimLogLines keeps only the last maxLines lines of a log, dropping the oldest. The result keeps
// the same trailing newline the input had: appending assumes the file already ends in one, and
// dropping it here would glue the next appended line onto the last one still kept.
export function trimLogLines(text: string, maxLines: number): string {
const lines = linesOf(text);
let kept = lines;
if (lines.length > maxLines) {
kept = lines.slice(lines.length - maxLines);
}
if (kept.length === 0) {
return "";
}
return `${kept.join("\n")}\n`;
}

// consoleFor returns the console method matching level, so console and persisted output agree on
// severity.
function consoleFor(level: LogLevel): (message: string) => void {
Expand All @@ -199,6 +201,7 @@ function consoleFor(level: LogLevel): (message: string) => void {
if (level === "error") {
return (message) => console.error(message);
}

return (message) => console.log(message);
}

Expand All @@ -217,6 +220,7 @@ function linesOf(text: string): string[] {
if (parts[parts.length - 1] === "") {
return parts.slice(0, -1);
}

return parts;
}

Expand Down
48 changes: 26 additions & 22 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { App } from "obsidian";
import { Platform, Plugin, setIcon, setTooltip } from "obsidian";
import { DEVICE_ID_KEY, deviceIdFrom, deviceSuffixFrom } from "./device/device";
import { createLogSink } from "./log/adapter";
import { createLogBus, createLogger, type LogBus, type Logger, type LogSink } from "./log/log";
import { GeodeLogView, LOG_VIEW_TYPE } from "./log/view";
import { DEFAULT_PASS, type Pass, toastFor } from "./notify/notify";
import { createToaster, type Toaster } from "./notify/obsidian";
import { type Actions, GeodeOnboardingModal } from "./onboarding/modal";
import { type RemoteRead, readRemote, type SyncReport } from "./onboarding/onboarding";
import { DEVICE_ID_KEY, deviceIdFrom, deviceSuffixFrom } from "./device/device.ts";
import { createLogSink } from "./log/adapter.ts";
import { createLogBus, createLogger, type LogBus, type Logger, type LogSink } from "./log/log.ts";
import { GeodeLogView, LOG_VIEW_TYPE } from "./log/view.ts";
import { DEFAULT_PASS, type Pass, toastFor } from "./notify/notify.ts";
import { createToaster, type Toaster } from "./notify/obsidian.ts";
import { type Actions, GeodeOnboardingModal } from "./onboarding/modal.ts";
import { type RemoteRead, readRemote, type SyncReport } from "./onboarding/onboarding.ts";
import {
armed,
DEFAULT_STATE,
Expand All @@ -23,15 +23,15 @@ import {
type State,
TICK_MS,
type Trigger,
} from "./schedule/schedule";
} from "./schedule/schedule.ts";
import {
DEFAULT_SETTINGS,
type GeodeSettings,
hasConnectionConfig,
normalizeSettings,
prefixError,
} from "./settings/settings";
import { GeodeSettingTab } from "./settings/tab";
} from "./settings/settings.ts";
import { GeodeSettingTab } from "./settings/tab.ts";
import {
DEFAULT_STATUS,
type Kind,
Expand All @@ -43,18 +43,22 @@ import {
noteUnsynced,
type Status,
view,
} from "./status/status";
import { obsidianTransport } from "./storage/obsidian";
import { createS3Client, probeConditionalWrites } from "./storage/storage";
import type { MassChange } from "./sync/guard";
import { GeodeMassChangeModal } from "./sync/modal";
import { type SyncFault, syncOnce } from "./sync/sync";
} from "./status/status.ts";
import { obsidianTransport } from "./storage/obsidian.ts";
import { createS3Client, probeConditionalWrites } from "./storage/storage.ts";
import type { MassChange } from "./sync/guard.ts";
import { GeodeMassChangeModal } from "./sync/modal.ts";
import { type SyncFault, syncOnce } from "./sync/sync.ts";
import {
createObsidianLocalWriter,
createObsidianReader,
createObsidianStore,
flushOpenEditors,
} from "./vault/obsidian";
} from "./vault/obsidian.ts";

// DEVICE_SUFFIX_BYTES is how much randomness separates two devices carrying the same platform
// label. Five bytes encode to exactly eight base32 characters with nothing left over.
const DEVICE_SUFFIX_BYTES = 5;

// LOG_MIN_LEVEL is fixed rather than user configurable: there's no meaningful "quiet" mode to
// offer today, so a verbosity setting would be a toggle with no observable effect.
Expand All @@ -64,10 +68,6 @@ const LOG_MIN_LEVEL = "debug";
// grow it unbounded.
const MAX_LOG_LINES = 500;

// DEVICE_SUFFIX_BYTES is how much randomness separates two devices carrying the same platform
// label. Five bytes encode to exactly eight base32 characters with nothing left over.
const DEVICE_SUFFIX_BYTES = 5;

// AppWithSetting adds Obsidian's internal, undocumented settings-window API (there is no public
// equivalent) so the Settings command can jump straight to Geode's tab, and opening the log view
// can close the settings modal out from under itself.
Expand Down Expand Up @@ -206,6 +206,7 @@ export default class GeodePlugin extends Plugin {
if (!checking) {
this.offerOnboarding();
}

return true;
},
});
Expand All @@ -221,6 +222,7 @@ export default class GeodePlugin extends Plugin {
if (!checking) {
this.setPaused(true);
}

return true;
},
});
Expand All @@ -234,6 +236,7 @@ export default class GeodePlugin extends Plugin {
if (!checking) {
this.setPaused(false);
}

return true;
},
});
Expand Down Expand Up @@ -342,6 +345,7 @@ export default class GeodePlugin extends Plugin {
for (const file of files) {
paths.push(file.path);
}

return paths;
},
openLogs: () => void this.openLogView(),
Expand Down
Loading