sugarcraft / candy-codetime
Privacy-first coding-time tracker — design antecedent Rtarun3606k/TakaTime, native PHP on the SugarCraft stack.
Package info
github.com/sugarcraft/candy-codetime
Type:project
pkg:composer/sugarcraft/candy-codetime
Requires
- php: ^8.3
- sugarcraft/sugar-async: dev-master
- sugarcraft/sugar-charts: dev-master
- sugarcraft/sugar-core: dev-master
- sugarcraft/sugar-style: dev-master
Requires (Dev)
- phpunit/phpunit: ^10.0
Suggests
- ext-sqlite3: Enables the optional --backend=sqlite storage backend (the default file backend needs no extension)
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-20 01:03:57 UTC
README
CandyCodetime
Formerly published as
sugarcraft/sugar-tick(renamed 2026-10). Namespace changed:SugarCraft\Tick\→SugarCraft\CodeTime\.
candy-codetime — a privacy-first coding-time tracker. Requires PHP 8.3+.
It does not watch you. A heartbeat is one activity sample — I was working
on this file, in this language, for this many seconds — and candy-codetime
records only what it is explicitly told (a beat is the same heartbeat, shortened): a hand-typed push, a save hook, a
cron entry, or an editor keybinding calling the CLI. No editor plugins ship;
the binding is one command line. Storage is local by default: one append-only
JSONL file per day, with an optional embedded-SQLite backend
(--backend=sqlite) for milestone tracking and time-indexed range queries.
Nothing leaves your machine — no cloud, no daemon, and no database server
(SQLite is an in-process library reading a file you own). The dashboard is a
SugarCraft TUI that reads whichever backend you selected.
Install
composer global require sugarcraft/candy-codetime # the global bin dir varies by composer version and platform; ask composer: BIN="$(composer global config bin-dir --absolute)" export PATH="$BIN:$PATH" # keep this line in your shell profile "$BIN/candy-codetime" push myproj php src/Main.php 120
Or from a clone: composer install && php bin/candy-codetime.
A signed single-file build ships with every candy-codetime/v* release:
download candy-codetime.phar with its candy-codetime.phar.sha256 digest
(and the .sha256.sig / .minisig minisig sidecars), verify it, and run
php candy-codetime.phar on stock PHP. The ini default phar.readonly=On is
the right runtime setting — the app never rewrites its own archive, and there
is deliberately no self-update channel: upgrading means downloading the new
file. Inside an archive, --version prints the release build stamp, because
the frozen vendor/ would otherwise make Composer report the build root's dev
guess; the release workflow pins SOURCE_DATE_EPOCH, so rebuilds of a tag
agree byte-wise on that stamp. tools/build-phar.php documents the build.
Quick start
You need PHP 8.3 or newer; the SQLite backend additionally needs the sqlite3
extension, and the dashboard needs a terminal. The commands below assume the
export PATH line from Install is in effect.
candy-codetime push myproj php src/Main.php 120 # │ │ │ └ seconds of work covered (optional; default 60) # │ │ └ the file you were working on # │ └ its language # └ project to report under candy-codetime # open the dashboard candy-codetime export csv 30 # headless (plain text, no TUI) dump of 30 days
Project and language may be omitted when the file argument makes them
inferable (see push below).
Three replies are worth knowing by heart, because they answer the first hour of questions:
$ candy-codetime gaps # before anything was recorded
gaps: no tracked data for that period
$ candy-codetime gaps # once there is time, and no untracked stretch
No gaps found.
$ candy-codetime dashboard < /dev/null # the dashboard, without a terminal
candy-codetime: the dashboard needs an interactive terminal (stdin and stdout are not both TTYs). For headless output use: candy-codetime export <csv|json|ics>
(The first line answers “did I record anything today?”, the second “is my tracking honest?”, the third points a non-terminal session at the headless commands.)
php examples/dashboard.php seeds a throwaway data directory with a pretend
week and opens the dashboard, so you can see the TUI before recording
anything real. Like the dashboard command, it refuses (exit 1) when
standard input or output is not a terminal, so piping it into a capture
cannot dump an alt-screen into the log.
Automating collection
No editor plugins ship with candy-codetime — the tracker is passive by design, so capturing your day is something you wire up once, and this section is the whole how-to. Three doors exist, pick one:
- The editor hook (recommended):
examples/plugin-heartbeat.example.shis a worked ~35-line POSIX sh script. Call it from a save hook with the saved path and one heartbeat lands per save. It prefers the CLI'spush --stdin door (ignore patterns, clamps and the advisory lock all apply), and falls back to a raw append underflockwhen no binary is onPATH. - A direct
pushtyped (or scripted) by you:candy-codetime push <file> [duration]— a path-shaped first slot names the project from the nearest repository root and the language from the extension — or spell both out (candy-codetime push <project> <language> <file> [duration]) to override detection. Backdate any form with--time=<unix>. - A raw
printf … >> YYYY-MM-DD.jsonlfrom cron — the exact line shape is in Data layout below, but see the two caveats there before choosing this door: raw lines are unstamped unless you writetimeinto them, and they land in the file backend only (a--backend=sqlitedashboard never sees them).
A cron recipe for the raw door, five-minute cadence (it still needs time
inline — see the contract in Data layout):
*/5 * * * * umask 077; D=${CANDY_CODETIME_DIR:-$HOME/.local/share/candy-codetime}; mkdir -p "$D" && printf '{"time": %s, "project": "myproj", "language": "php", "file": "/home/me/myproj/src/Main.php", "duration": 300, "tags": []}\n' "$(date +\%s)" >> "$D/$(date +\%F).jsonl"
(% is escaped for cron; the day file is named with the machine's local
calendar date, matching the store layout.)
Keys (dashboard)
| Key | Action |
|---|---|
← / h |
Move the window back one day |
→ / l |
Move it forward one day |
g |
Jump the window end back to today |
+ |
Widen the window (7/14/30/90 days) |
- |
Narrow the window back down |
t |
Toggle the lower pane between languages and tags |
r |
Reload from disk |
q / Esc |
Quit |
Ctrl+C |
Quit |
Letter commands answer unmodified keys only: Ctrl+q does not quit and
Ctrl+r does not reload (the two bare-metal exits, Esc and Ctrl+C, stay
guarded by their own shapes). h/l exist because arrow keys are the only
other way to walk the window, and not every keyboard has them.
The two ranking panes render side by side from 62 columns up (two 30-cell
frames plus a gap) and stack vertically below that. Every dashboard line is
clipped to the terminal width and never wraps: the timeline frame fills the
width, while the ranking panes keep the 62-column budget described above, and days
that cannot be drawn are counted
("+N earlier") rather than silently dropped. When CANDY_CODETIME_GOAL is set the header gains a today 2h01 / 1h00 cell and days that reach the goal render as shaded blocks in the band.
Accessibility
The dashboard is a deliberately visual artifact; the supported assistive
path is the plain-text commands: export csv|json and gaps write their
whole answer to stdout as ordinary lines, so a screen reader gets the same
data as the terminal does. The TUI adds nothing that those commands lack.
Font requirement: the frame draws rounded box glyphs, the timeline draws block-character bars, and the help row uses arrow glyphs. There is no ASCII fallback, so on a terminal whose font lacks those characters they degrade to replacement symbols — labels and numbers stay legible, borders get ugly.
Colour is decorative only. The palette ships dark-terminal hexes, applied
solely when the terminal declares 256-colour or TrueColor capability (and
never under NO_COLOR); the information survives without it — bars are
height-encoded (minutes, not hue), every coloured value carries its word
label (total:, spelled-out project and language names), and the milestone
mark is * text rather than a colour change.
The interface is static by design: the dashboard subscribes to nothing — no timers, no animation, no moving cells. Each screen is a snapshot that redraws only when a key changes it, which is also the reduced-motion answer: nothing ever moves on its own.
Commands
| Command | Arguments | What it does |
|---|---|---|
dashboard |
[days] |
Open the TUI (reads the selected backend), showing a [days]-day window ending today (default 7). Inside the TUI, +/- step the window through 7, 14, 30, 90 days. Without an interactive terminal it exits with an error naming export as the headless way out, instead of hanging. |
push |
[<project> <language>] <file> [duration] [tags] | -- |
Record heartbeats. duration is whole seconds, 0 and up (default 60); anything else, negatives included, is refused with exit 1 and never silently read as 0; durations above one year are clamped to 31,536,000 s. --time=<unix> files a single beat at a past (or future) instant instead of now — a malformed value is refused, never coerced. push -- reads a batch: one JSON heartbeat per line on stdin, each with its own time; a malformed line is named with its line number on STDERR and the run exits 1 after the well-formed rows still land. tags is a comma-list (work,review) stored with the beat and carried by every export format; blank members are dropped. When project and language are omitted (the first slot contains a path separator or a known extension), they are detected: project is the nearest .git ancestor's name (else the first path segment relative to the working directory, else unknown), language is the extension map (php, js, ts, python, …, else unknown). Typed slots always win. Both forms pass the same allow/deny door and the same clamps. |
milestone |
add <name> [description] | list |
Manage milestones. name is required; description is optional. Milestones live only in SQLite, so this command uses the sqlite backend regardless of --backend (a milestone add into a file-only data dir says so on stderr before it creates the database); the sqlite dashboard marks the milestone days with * under the weekday row. |
export |
<csv|json|ics> [days] | from [to] |
Dump heartbeats for the last N days (default 7, clamped to [1, 3660]; a non-numeric count is refused with a one-line error and exit 1), or for an explicit dated window: from/to are YYYY-MM or YYYY-MM-DD — export json 2025-06 2025-06 is June 2025, a lone from runs through today. A window wider than 3660 days is refused like any oversized range. --project=<name> / --tag=<label> keep only the rows they match (same filter on both backends). Output goes to STDOUT — redirect it to a file to save it. |
gaps |
[days] | from [to] | --min=<secs> |
List untracked stretches in the last N days or the dated window named by from [to] (same doors, filters, and clamps as export). Stretches count from 300 seconds up; --min=<secs> raises or lowers that threshold. |
summary |
[days | from [to] | --format=text|md] |
Print a per-project and per-language digest of tracked time to STDOUT — same window doors and filters as export/gaps. --format=md answers in Markdown for badges and README updates; it replaces upstream's third report binary, deliberately without a GitHub Action. |
forget |
--project=<name> [--file-prefix=<path>] [--apply] |
Remove stored beats matching the filter from both stores — day files and the SQLite database, regardless of the selected backend. Dry run by default: it counts the matches and changes nothing. --apply rewrites the day files (temp-file rewrite; non-matching lines stay byte-identical, a fully emptied day is unlinked) and runs a parameterized DELETE on the database. Lines that fail to parse are never removed — only provably matching beats go. Run backup first: the archive is the undo path. |
backup |
— | Archive day files (*.jsonl) older than 30 days into <dir>-backups/ — copies only, nothing is ever deleted or pruned. |
help, --help, -h |
— | Print usage. |
--version, -v |
— | Print the version. |
Any command word not listed above prints a one-line error followed by the full usage on stderr and exits 1.
Two details sit behind the backup row:
- Archives are named after the source directory and the file's logical day, so a backfilled day refreshes its existing archive instead of minting a second diverging copy, and two same-basename roots can never overwrite one another. Overlapping runs refuse on a lock file rather than interleaving.
- Plain
backuprefuses the live SQLite database — a byte copy would be a torn snapshot. The--sqliteoption (below) runs the crash-safeVACUUM INTOsnapshot, and the Data layout section states the retention law: nothing, archive or database, is ever pruned, so theforgetdoor is the only trim.
Options (accepted before or after the command):
| Option / env | Effect |
|---|---|
--backend=file|sqlite |
Storage for push/export/gaps/dashboard. Both forms work: --backend=sqlite and --backend sqlite. The sqlite backend needs the sqlite3 PHP extension; without it the CLI exits with a clear message instead of crashing. With neither the flag nor CANDY_CODETIME_BACKEND set, the CLI auto-selects sqlite when the database holds records and the JSONL store does not — the store is re-decided per invocation, never persisted. |
CANDY_CODETIME_BACKEND=<name> |
Default backend (file or sqlite) for every invocation, so an sqlite user need not repeat the flag. An explicit --backend on the command line outranks it; a junk value is refused like a junk flag. The dashboard header badges the store it actually reads ([file]/[sqlite]), and when the other store also holds records the CLI prints a one-line pointer on STDERR. |
CANDY_CODETIME_GOAL=<seconds> |
Daily goal for the dashboard: the header gains a today 2h01 / 1h00 cell and every day that reaches the goal shows as a shaded block in the activity band. A whole number of seconds, or a whole number of hours like 6h; junk is refused like a junk flag. Presentation only — recording nothing, gating nothing. |
--theme=<name> |
Dashboard palette: default, light, dracula, solarized, gruvbox, high-contrast. default is the shipped palette and paints byte-identically to every documented frame; light answers the pastel-on-white complaint (the candy tones wash out on a white terminal). Junk is refused with a one-line error naming the choices. Tints paint only where the terminal answers 256-colour or truecolour — the frames themselves are identical everywhere else. |
--project=<name> |
export/gaps: keep only heartbeats recorded for this project. |
--tag=<label> |
export/gaps: keep only heartbeats carrying this tag. |
--min=<secs> |
gaps: report only untracked stretches of at least this many seconds (default 300; the library ships the same 300 s as its constructor default). |
CANDY_CODETIME_THEME=<name> |
The same palette choice as an environment variable; --theme outranks it. |
--sqlite (with backup) |
Archive the SQLite database itself: VACUUM INTO writes a consistent standalone snapshot named candy-codetime-<timestamp>.db under <dir>-backups/, owner-private like every other archived payload. The live database is untouched — this is archive-only, no prune, no in-place vacuum. |
CANDY_CODETIME_DIR=<path> |
Data directory (default $XDG_DATA_HOME/candy-codetime, falling back to ~/.local/share/candy-codetime). With CANDY_CODETIME_DIR, XDG_DATA_HOME and HOME all unset the CLI refuses rather than resolving next to the working directory — set CANDY_CODETIME_DIR for such runs. |
A storage failure ends any command with a one-line message on stderr and exit status 1 — never a bare PHP fatal.
Compatibility with the tool's earlier names — the banner at the top of this file covers the package and namespace rename, and the same tool simply kept its old file and environment names:
- Legacy
SUGARTICK_*environment variables are still imported on every launch, each with a deprecation notice on stderr. - The old default data directory is migrated once on first launch — not when
CANDY_CODETIME_DIRis set, because then you have chosen the destination. If both the old and the new directory already exist, nothing is merged (the tool never fuses two histories on its own) and every launch prints one stderr notice naming both paths — merge the day files by hand if you want the old records in the live tree.
CLI messages and dashboard chrome follow LC_ALL/LC_MESSAGES/LANG
across the 16 shipped locales. Date and weekday names (Jun 7, Sat) render
in English in every locale: the locale catalogue carries the PHP format
characters, not month tables.
Export formats
| Format | Shape |
|---|---|
csv |
Six columns — time,project,language,file,duration,tags — one row per heartbeat; tags is a comma-joined cell (empty when a beat has none), and every free-text cell passes the formula-injection guard. |
json |
An array of objects mirroring the JSONL day-file rows: the same six keys, time and duration in whole seconds. |
ics |
One VEVENT per heartbeat. SUMMARY carries the full stored file path, DTSTART/DTEND are UTC (Z) stamps whose difference is the beat's duration, and the UID mixes duration and row order so retried beats do not collapse into a single event on import (see Privacy below for what the paths imply). |
Ignoring files
A .sugartrackignore in the current directory — or, failing that, in the
tracked file's own directory (the first found wins) — holds glob patterns one
per line; a push whose file matches is reported as skipped and never
stored. (The dotfile keeps the pre-rename name — same tool, same patterns.)
Patterns match in three ways:
- a bare pattern (
secret.log) matches by file name at any depth; - a pattern naming the whole tracked path matches it exactly;
- a path pattern (
vendor/*) matches below anyvendordirectory, whether the tracked path is relative or absolute.
An ignore file larger than 1 MiB is refused outright:
push reports it with a one-line error and exits 1 rather than parsing a
deliberately hostile file. An ignore file that exists but cannot be read is refused the
same way — tracking with the opt-out in an unknown state is exactly the
failure the file was written to prevent, so push never proceeds as if the
file were empty.
The sibling .sugartrackallow file reverses the deny file: a path matched
by one of its patterns is tracked and the ignore file is never consulted
for it — first-match precedence goes to the allow side. It is looked for in
the same candidates, in the same order (current directory first, then the
tracked file's own directory), and the same parsing law applies: over 1 MiB
is refused, and an unreadable allow file aborts the push with a one-line
error just like an unreadable ignore file. Since a repository can ship one,
that means a checked-out repo can re-enable tracking of paths a deny file
elsewhere would have skipped — remove or narrow the allow file it planted
to undo that.
Trust boundary: ignore files usually live inside tracked repositories, so
their patterns are untrusted input to the tracking tool. A wildcard-only
pattern (a bare *) matches every file name and silently zeroes that
project's entire recorded time — and so does anything behaviourally equal
to it (?* matches every real, non-empty path while failing a pure-shape
test), so such patterns are caught by probe-matching, not just by shape.
When the loaded file carries such a pattern,
the skip is no longer a quiet stdout line: push reports it on stderr
with the ignore file's path, its pattern count, and the affected project —
then still exits 0, because the opt-out is honoured, not refused. To undo a
file supplied by the repository, delete or narrow the file the notice names;
to override a directory-level ignore file instead, run push from a working
directory whose own .sugartrackignore (checked first) carries only the
patterns you chose.
Data layout
$CANDY_CODETIME_DIR/
2026-10-23.jsonl One line appended per heartbeat.
candy-codetime.db Created by --backend=sqlite, and by `milestone` (which always uses SQLite).
candy-codetime.db-wal WAL sidecar: recent commits live here until checkpointed.
candy-codetime.db-shm WAL index header (shared memory).
<dir>-backups/ Created by `backup` (day files) and `backup --sqlite` (database snapshots).
The SQLite backend tunes the database on every open:
journal_mode=WAL— dashboard reads never block behind a committing appender, nor does the reverse hold: the stated model is editor plugin + CLI + cron appending to one file.busy_timeout(5 seconds) — concurrent writers wait out each other's locks instead of failing with "database is locked".synchronous=NORMAL— WAL's companion setting: a power cut can cost the last transaction of heartbeat telemetry — one sample, never the file.cache_size=-64000— a 64,000 KiB (62.5 MiB) page cache that keeps theidx_heartbeats_timerange scans in memory. The schema is declared in SQLite'suser_versionpragma (version1): a file stamped with a version this build does not know is refused on open rather than silently no-op'ed against a layout it cannot read, and pre-versioning databases are stamped once after their tables are verified. The-wal/-shmsidecars are swept to0600with the database itself (Privacy below) — one more reason a byte copy cannot cover SQLite;backup --sqlitesnapshots the database crash-safely withVACUUM INTO. Nothing is ever pruned: neither the live.dbnor the archives under<dir>-backups/are trimmed — retention is yours to manage (delete day files, or archive-and-remove by hand).
Each line of a day file is one JSON object:
{"time": <unix seconds>, "project": <string>, "language": <string>, "file": <path as supplied>, "duration": <seconds>, "tags": <array>}. The CLI never
sets tags; a plugin-written tag is honoured on read and export. Readers should
ignore unknown keys — editor is exactly such a key: upstream TakaTime heartbeats carry it, this schema deliberately omits it, so a plugin-written editor value survives the JSONL round-trip untouched but nothing here reads it (no per-editor view exists). Timestamps are part of the payload, not the envelope: a
line fed through the push -- stdin door without time gets stamped at
the moment it is read in, so a batch pushed after the fact files every beat
under batch-time. A raw line placed in a day file with no time is a corrupt
record: readers drop it (counted on the day-file warning lane) rather than
invent a live beat at read time. If you are
backfilling, carry the real instant on each line — or feed the batch through
push --time=<unix> (one beat) / push -- (stdin JSON-lines), which run the
same ignore door, clamps and locking as an interactive push.
Day files are keyed by the calendar date in PHP's effective timezone.
Since PHP 8.3 the TZ environment variable no longer steers that zone, so a
cron or wrapper that sets only TZ files under whatever date.timezone
resolves to (usually UTC) — set date.timezone in php.ini to choose the
filing zone. The readers then part company after a zone change: the dashboard
timeline re-buckets heartbeats by their timestamps in the current zone,
export, summary and forget walk day files under the keys their writers
used, and gaps works from the raw stamps — so the same store can show a
beat in a different day column than the file that holds it. Nothing is lost
or corrupted; it is only "which day was this" resolving three ways. Nothing
is ever deleted: heartbeats accumulate until you remove them by hand or
archive them with backup (which copies and never trims).
Fixing a bad entry
There is no edit command, and that is deliberate — the store is plain files.
With the file backend, fix or drop the offending JSON line in the day file,
then press r in the dashboard to reload it (or q and reopen). With the
SQLite backend, open the database with sqlite3 and fix the row in
heartbeats.
To remove rather than fix, there is a supported door: forget --project=<name> [--file-prefix=<path>] counts the matches as a dry run,
and --apply removes them from both stores. Lines that fail to parse are
never touched, so a corrupt line still only goes by hand. Run backup
before --apply — the archive is the undo path (day-file archives name the
logical day; the database needs backup --sqlite).
Privacy
The data directory and every file in it are owner-private, per surface:
- Directories are
0700, created under a narrowed umask, so they never exist world-readable. - Day files, the database, and its
-wal/-shmsidecars are0600. Regular files are created-then-tightened — mode0600is settled before any payload is written, and until then the file is empty and shielded by the0700directory. The WAL sidecars are the exception to that timing: SQLite creates them mid-transaction, so on a fresh database the first beats can land on a-walmicroseconds before the constructor's sweep tightens it — there, the0700directory is the protection window. The sweep tightens every sidecar visible at open and re-asserts on every subsequent open. - Legacy and plugin-made files cannot stay loose: the contract is a
launch invariant, not a write-path favor. A directory or file left
world-readable — by an older version, a plugin direct-appending with
>>(which runs none of this code), or the pre-rename migration moving a legacy tree — is swept tight on the next CLI run, any command, reads included; if that fails, the run aborts rather than printing over data that is still out in the open. Until that next run, a raw-echoed file sits at the shell's umask, so plugin and cron writers should run underumask 077. - Stored names are swept before they paint, per surface. The dashboard
runs every name through a one-line sweep: escape sequences, C0 and C1
control classes, and DEL are dropped, TAB/CR/LF go with them (a name is
one row of the frame), and zero-width/bidi "Trojan Source" characters are
made visible as
<U+XXXX>markers instead of painted. CLI echoes use the byte-oriented sweep of the same family — escapes and control classes dropped, line breaks preserved so multi-line output stays readable. A doctored store cannot inject escape sequences into either surface. - The
backuparchive under<dir>-backups/is held to the same contract: it is created0700and every copied day file is tightened to0600, because an archive of those files is the same path map one directory over. - The
csv,jsonandicsexports carry every stored path verbatim. Redirecting an export somewhere shared — or importing anicsinto a hosted calendar — hands the whole directory map to whoever receives it. Export only where you would leave the data directory itself.
Heartbeats carry file paths exactly as supplied (editor plugins typically send absolute ones) and project names; treat the directory accordingly.
Colour is driven by the detected ColorProfile for the terminal: a profile
below 256-colour (which NO_COLOR=1, CLICOLOR=0 and TERM=dumb all land
on) renders the dashboard without any tints. Detection runs once at startup
(and without a detected profile the fallback honours a set, non-empty
NO_COLOR, treating 0 and false as not suppressing); a resize relayouts
the frame under the stored profile.
Architecture
| File | Role |
|---|---|
Heartbeat |
Value object — one activity sample (project, language, file, duration, tags). |
Store |
JSONL-backed reader/appender; implements HeartbeatReader; enforces the private modes above. |
Storage\SqliteBackend |
Optional storage whose only index is on the heartbeat time column (idx_heartbeats_time) for range queries; implements HeartbeatReader; also owns milestones. |
Storage\HeartbeatReader |
The read contract (loadRange/invalidate) both storages satisfy — what lets every subcommand honour --backend uniformly. |
Stats |
Pure fold — totals per project / language + per-day timeline buckets. |
Dashboard |
SugarCraft Model — window shifts one day per press (←/→), reload (r), quit; reads through a HeartbeatReader. |
Renderer |
View — header + ranking panes + Sparkline timeline (SugarCharts); colour-ladder aware (honours the detected ColorProfile). |
Report\GapsReport |
Pure gap detection over sorted heartbeats (threshold 300 s). |
Backup\AutoBackup |
Copy-only archiver; temp-file-plus-rename copies under a run lock; throws loudly on any failure. |
Ignore\SugarTrackIgnore |
.sugartrackignore matcher used by push. |
Milestone |
Value object for SQLite markers. |
Export\CsvExporter / JsonExporter / IcalExporter |
export formats behind ExporterInterface (the tabular pair shares TabularExporterInterface). |
Support\Version |
Single-source version constant. |
Lang |
i18n facade (16 locales under lang/). |
The Store is intentionally append-only at the file level, so editor hooks can
append a JSON line with >> without coordinating with the dashboard (no
plugins ship — see Automating collection for the worked example) — the
trade-off is stated plainly: raw >> redirection does not take the advisory lock
push uses, so a hand-echoed line could theoretically interleave, and it runs
none of the privacy-mode doors — the next CLI launch sweeps such files to
0600, but write under umask 077 meanwhile; plugin integrations should
flock or just call push. The dashboard re-reads on
launch and on r; it has no clock subscription, so an open panel never
refreshes by itself. Reads degrade loudly too: a day file that exists but
cannot be opened is named in a one-line stderr warning and counted as an
empty day, never skipped in silence.
Shared foundations
candy-codetime uses sugar-async
for cooperative cancellation: Store::append() polls an optional
CancellationToken immediately before writing (PHP cannot interrupt a blocking
write mid-flight). The CLI never arms a token; the seam exists for embedding
hosts that want abortable writers.
Test
composer install vendor/bin/phpunit
Parity vs TakaTime
Position against the design antecedent, Rtarun3606k/TakaTime:
- Ported: the heartbeat model, project/language/file tracking, the dashboard, an ignore file.
- Replaced: the always-on daemon became an explicit
push(nothing watches you); MongoDB became JSONL day files plus an optional embedded-SQLite backend;:TakaInitsetup ceremony became zero-config storage. - Redone: the upstream dashboard theme picker became named palettes (
--theme); its tags became a stored field with attoggle and a--tagfilter. - Not ported: the
.takatrackallowlist (the.sugartrackallowrescue file plays that role), the separatetaka-reportbinary (thesummarycommand folds instead), and the heartbeat'seditorfield (see Data layout above).
Credits & inspiration
Design antecedent: Rtarun3606k/TakaTime; SugarCraft is developed as a native PHP project.
