diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-18 08:03:32 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-18 08:03:32 +0300 |
| commit | 6ff6493a58fa7dd203238dd1ace9f97c7afddbf2 (patch) | |
| tree | e201e8cd6ca532fb0a080a549b4ae049ba9a6a42 | |
| parent | fa558cbce505c8f4030e3a064d19671a6cbd35e3 (diff) | |
worktime: move uprecords collect/import into hidden worktime-repo script
Host-specific upload details now live in ~/git/worktime/.uprecords-sync.sh
(kept out of the public dotfiles repo). worktime::supersync calls it via
sh; f3s skill updated accordingly.
Amp-Thread-ID: https://ampcode.com/threads/T-019ed908-ca57-7251-8ff1-ce10c8c3a787
Co-authored-by: Amp <amp@ampcode.com>
| -rw-r--r-- | fish/conf.d/worktime.fish | 77 | ||||
| -rw-r--r-- | prompts/skills/f3s/references/goprecords-uptimed.md | 12 |
2 files changed, 12 insertions, 77 deletions
diff --git a/fish/conf.d/worktime.fish b/fish/conf.d/worktime.fish index 941a4a8..09c76ce 100644 --- a/fish/conf.d/worktime.fish +++ b/fish/conf.d/worktime.fish @@ -48,81 +48,14 @@ function worktime::supersync_sync cd - end -function worktime::uprecords::darwin::collect - if test (uname) != Darwin - return - end - - if not test -d $WORKTIME_DIR - return - end - - set -l uprecords_file - for candidate in /opt/homebrew/var/uptimed/records /usr/local/var/uptimed/records - if test -f $candidate - set uprecords_file $candidate - break - end - end - - if test -z "$uprecords_file" - return - end - - set -l target $WORKTIME_DIR/uprecords-(hostname).records - cp $uprecords_file $target - git -C $WORKTIME_DIR add $target - - if type -q uprecords - set -l txt_target $WORKTIME_DIR/uprecords-(hostname).txt - uprecords >$txt_target - git -C $WORKTIME_DIR add $txt_target - end -end - -function worktime::uprecords::darwin::import - if test (hostname) != earth - return - end - - if not test -d $WORKTIME_DIR - return - end - - set -l src_host MBDVXJ4XKH9C - set -l goprecords_host mega-m3-pro - set -l base_url https://goprecords.f3s.buetow.org - - set -l config_dir (test -n "$XDG_CONFIG_HOME"; and echo $XDG_CONFIG_HOME; or echo ~/.config) - set -l token_file $config_dir/goprecords-upload-$goprecords_host/token - if not test -r $token_file - echo "worktime::uprecords::darwin::import: cannot read $token_file (create the goprecords key for $goprecords_host)" >&2 - return 0 - end - set -l token (string trim <$token_file) - - # Map the file kind (extension) collected in the repo to the goprecords - # upload kind. - set -l records_file $WORKTIME_DIR/uprecords-$src_host.records - set -l txt_file $WORKTIME_DIR/uprecords-$src_host.txt - - for pair in records:$records_file txt:$txt_file - set -l kind (string split -m1 ':' $pair)[1] - set -l file (string split -m1 ':' $pair)[2] - if not test -f $file - continue - end - curl -fsS -X PUT --data-binary "@$file" \ - -H "Authorization: Bearer $token" \ - "$base_url/upload/$goprecords_host/$kind" - end -end - function worktime::supersync worktime::supersync_sync sync_quotes taskwarrior::invoke - worktime::uprecords::darwin::collect - worktime::uprecords::darwin::import + # uprecords collect/import live in the (private) worktime repo so that + # host-specific details stay out of the public dotfiles repo. The script + # guards internally (collect on Darwin, import on earth). + sh $WORKTIME_DIR/.uprecords-sync.sh collect + sh $WORKTIME_DIR/.uprecords-sync.sh import worktime::supersync_sync no_sync_quotes end diff --git a/prompts/skills/f3s/references/goprecords-uptimed.md b/prompts/skills/f3s/references/goprecords-uptimed.md index 4ae999a..ed7f81e 100644 --- a/prompts/skills/f3s/references/goprecords-uptimed.md +++ b/prompts/skills/f3s/references/goprecords-uptimed.md @@ -66,16 +66,18 @@ Copy to **`/usr/local/bin/`** (system) or **`~/.local/bin/`** (user), set **`GOP The Mac (Apple Silicon, **`Darwin`**) is **not** a direct upload client. Instead: -1. On the Mac, a fish function **`worktime::uprecords::darwin::collect`** copies the local **uptimed** records into the **worktime** git repo as - **`uprecords-MBDVXJ4XKH9C.records`** and **`uprecords-MBDVXJ4XKH9C.txt`**, and they get synced via `git` (part of **`worktime::supersync`**). -2. On **earth** (the only host that publishes), the fish function **`worktime::uprecords::darwin::import`** reads those repo files and **`PUT`**s them to goprecords, **re-labelling** the raw host `MBDVXJ4XKH9C` → **`mega-m3-pro`**: +The logic lives in a **hidden POSIX helper kept in the (private) worktime repo**, **`~/git/worktime/.uprecords-sync.sh`** (subcommands `collect` / `import`), so host-specific details stay out of the public dotfiles repo. The fish function **`worktime::supersync`** (in `dotfiles/fish/conf.d/worktime.fish`) just calls `sh $WORKTIME_DIR/.uprecords-sync.sh collect` then `… import`. + +1. On the Mac, **`.uprecords-sync.sh collect`** copies the local **uptimed** records into the **worktime** git repo as + **`uprecords-MBDVXJ4XKH9C.records`** and **`uprecords-MBDVXJ4XKH9C.txt`**, and they get synced via `git` (part of **`worktime::supersync`**). Guards on `uname = Darwin`. +2. On **earth** (the only host that publishes), **`.uprecords-sync.sh import`** reads those repo files and **`PUT`**s them to goprecords, **re-labelling** the raw host `MBDVXJ4XKH9C` → **`mega-m3-pro`**: - `PUT /upload/mega-m3-pro/records` and `PUT /upload/mega-m3-pro/txt` - token at **`~/.config/goprecords-upload-mega-m3-pro/token`** (`0600`). - - Both functions live in **`dotfiles/fish/conf.d/worktime.fish`**. + - Guards on `hostname = earth`; exits cleanly (warning) if the token is missing. 3. Automation: `goprecords-upload-earth.service` has a **second `ExecStart`** that runs the import hourly alongside earth's own upload: ```ini ExecStart=%h/.local/bin/goprecords-upload-earth.sh - ExecStart=/usr/local/sbin/fish -c worktime::uprecords::darwin::import + ExecStart=/bin/sh %h/git/worktime/.uprecords-sync.sh import ``` The import is a **no-op off earth** (guards on `hostname = earth`) and exits cleanly with a warning if the `mega-m3-pro` token is absent, so it never fails the service. |
