rheaarchived
- 40 commits
- 1 branch
- 0 tags
- updated
feat: udpate mirror and archive repo
SignedGitea couldn't verify the signature.
Showing 6 changed files with 82 additions and 369 deletions.
.gitea/workflows/ci.ymldeleted
+0 −34
@@ -1,34 +0,0 @@1# name: CI23# on:4# push:5# pull_request:67# jobs:8# build-and-test:9# runs-on: macos10# steps:11# - name: Checkout12# uses: actions/checkout@v41314# - name: Generate Xcode project15# run: xcodegen generate1617# - name: Build and test18# run: |19# rm -rf TestResults.xcresult20# xcodebuild build test \21# -project Rhea.xcodeproj \22# -scheme Rhea \23# -destination 'platform=macOS' \24# -resultBundlePath TestResults.xcresult2526# - name: Upload result bundle27# if: always()28# # Gitea's built-in artifact backend only implements the v329# # upload-artifact/download-artifact protocol; v4+ (the30# # @actions/artifact v2 client) errors with GHESNotSupportedError.31# uses: actions/upload-artifact@v332# with:33# name: test-results34# path: TestResults.xcresult
.gitea/workflows/mirror.yamladded
+59 −0
@@ -0,0 +1,59 @@1name: mirror2on:3 push:4 branches: [main]5 workflow_dispatch:67env:8 TANGLED_SSH_PORT: "2222"9 TANGLED_REMOTE: "ssh://git@knot.danieldaum.net:2222/danieldaum.net/rhea"1011jobs:12 mirror:13 runs-on: ubuntu-latest14 steps:15 - name: Checkout16 uses: actions/checkout@v417 with:18 fetch-depth: 01920 - name: Push to GitHub21 run: |22 git remote add github https://x-access-token:${{ secrets.GH_MIRROR_TOKEN }}@github.com/daniel-daum/rhea.git23 git push github main --force24 git push github --tags --force2526 - name: Set up SSH for Tangled27 env:28 TANGLED_SSH_KEY: ${{ secrets.TANGLED_SSH_KEY }}29 # Public half of the deploy key registered on Tangled as "gitea-ci-mirror".30 EXPECTED_PUBKEY: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDNl8WEwlLHsqWi15NNoZCqkDG2/GjiGgthdIYVm8kNM31 run: |32 mkdir -p ~/.ssh && chmod 700 ~/.ssh33 if [ -z "$TANGLED_SSH_KEY" ]; then34 echo "::error::secret TANGLED_SSH_KEY is empty or not visible to this workflow"35 exit 136 fi37 # Strip CRs (pasted from Windows/clipboard) and guarantee a trailing newline.38 printf '%s\n' "$TANGLED_SSH_KEY" | tr -d '\r' > ~/.ssh/tangled_ci39 chmod 600 ~/.ssh/tangled_ci40 echo "key file: $(wc -l < ~/.ssh/tangled_ci) lines, first line: $(head -n1 ~/.ssh/tangled_ci)"41 # Derive the public key; this fails loudly if the private key is malformed.42 if ! actual=$(ssh-keygen -y -f ~/.ssh/tangled_ci); then43 echo "::error::TANGLED_SSH_KEY is not a valid private key (check it is the PRIVATE key, all lines intact)"44 exit 145 fi46 echo "derived pubkey: $actual"47 if [ "$(echo "$actual" | cut -d' ' -f1,2)" != "$EXPECTED_PUBKEY" ]; then48 echo "::error::TANGLED_SSH_KEY does not match the gitea-ci-mirror key registered on Tangled"49 exit 150 fi51 ssh-keyscan -t ed25519 -p "$TANGLED_SSH_PORT" knot.danieldaum.net >> ~/.ssh/known_hosts5253 - name: Push to Tangled54 env:55 GIT_SSH_COMMAND: ssh -i ~/.ssh/tangled_ci -o IdentitiesOnly=yes -o UserKnownHostsFile=~/.ssh/known_hosts56 run: |57 git remote add tangled "$TANGLED_REMOTE"58 git push tangled main --force59 git push tangled --tags --force
.gitea/workflows/release.ymldeleted
+0 −287
@@ -1,287 +0,0 @@1# name: Release23# on:4# push:5# tags:6# - "v*"78# jobs:9# release:10# runs-on: macos11# steps:12# - name: Checkout13# uses: actions/checkout@v414# with:15# fetch-depth: 01617# - name: Generate Xcode project18# run: xcodegen generate1920# - name: Derive version from tag21# id: version22# run: |23# TAG="${GITHUB_REF#refs/tags/}"24# echo "tag=$TAG" >> "$GITHUB_OUTPUT"25# echo "marketing_version=${TAG#v}" >> "$GITHUB_OUTPUT"2627# - name: Import Developer ID certificate into temporary keychain28# env:29# MACOS_CERTIFICATE_P12: ${{ secrets.MACOS_CERTIFICATE_P12 }}30# MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}31# MACOS_CI_KEYCHAIN_PASSWORD: ${{ secrets.MACOS_CI_KEYCHAIN_PASSWORD }}32# run: |33# KEYCHAIN_PATH="$RUNNER_TEMP/release-signing.keychain-db"34# CERT_PATH="$RUNNER_TEMP/developer_id.p12"3536# echo -n "$MACOS_CERTIFICATE_P12" | base64 --decode -o "$CERT_PATH"3738# security create-keychain -p "$MACOS_CI_KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"39# security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH"40# security unlock-keychain -p "$MACOS_CI_KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"41# security import "$CERT_PATH" -k "$KEYCHAIN_PATH" -P "$MACOS_CERTIFICATE_PASSWORD" -T /usr/bin/codesign -T /usr/bin/security42# security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$MACOS_CI_KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"43# security list-keychain -d user -s "$KEYCHAIN_PATH" login.keychain4445# rm -f "$CERT_PATH"46# echo "keychain_path=$KEYCHAIN_PATH" >> "$GITHUB_ENV"4748# - name: Build Release49# run: |50# # Notarization requirements a plain (non-archive) xcodebuild doesn't meet51# # by default: sign with a secure timestamp (Xcode passes --timestamp=none52# # outside of Archive) and don't inject the get-task-allow debug53# # entitlement (CODE_SIGN_INJECT_BASE_ENTITLEMENTS). Apple rejects the54# # submission as Invalid on both counts otherwise.55# xcodebuild clean build \56# -project Rhea.xcodeproj \57# -scheme Rhea \58# -configuration Release \59# -destination 'platform=macOS' \60# -derivedDataPath build \61# MARKETING_VERSION="${{ steps.version.outputs.marketing_version }}" \62# CODE_SIGN_INJECT_BASE_ENTITLEMENTS=NO \63# OTHER_CODE_SIGN_FLAGS="--keychain $keychain_path --timestamp"6465# - name: Re-sign Sparkle's embedded helpers for notarization66# run: |67# # Sparkle's SPM package ships prebuilt XPC services/helper apps (Autoupdate,68# # Updater.app, Downloader.xpc, Installer.xpc) that keep their own upstream69# # signature after Xcode embeds them, instead of being re-signed with our70# # Developer ID identity — notarization rejects those as "not signed with a71# # valid Developer ID certificate" / "signature does not include a secure72# # timestamp". `--deep` re-signs the app and everything nested inside it73# # (including Sparkle's helpers) with one consistent identity/timestamp/74# # hardened-runtime, which is also why this has to happen after Build Release75# # and before the app gets verified/packaged.76# codesign --force --deep --options runtime --timestamp \77# --sign "Developer ID Application" --keychain "$keychain_path" \78# "build/Build/Products/Release/Rhea.app"7980# - name: Verify code signature81# run: |82# APP_PATH="build/Build/Products/Release/Rhea.app"83# codesign --verify --deep --strict --verbose=2 "$APP_PATH"84# codesign --display --verbose=4 "$APP_PATH"8586# - name: Package into dmg87# run: |88# APP_PATH="build/Build/Products/Release/Rhea.app"89# DMG_NAME="Rhea-${{ steps.version.outputs.tag }}.dmg"90# STAGING_DIR="$RUNNER_TEMP/dmg-staging"91# mkdir -p "$STAGING_DIR"92# cp -R "$APP_PATH" "$STAGING_DIR/"93# ln -s /Applications "$STAGING_DIR/Applications"94# hdiutil create -volname "Rhea" -srcfolder "$STAGING_DIR" -ov -format UDZO "$DMG_NAME"95# # Gatekeeper assesses the disk image's own signature, not just the app96# # inside it — an unsigned dmg is rejected with "no usable signature"97# # even when its contents are signed and notarized.98# codesign --sign "Developer ID Application" --timestamp \99# --keychain "$keychain_path" "$DMG_NAME"100# echo "dmg_path=$DMG_NAME" >> "$GITHUB_ENV"101102# - name: Notarize dmg103# env:104# APPLE_API_KEY_P8: ${{ secrets.APPLE_API_KEY_P8 }}105# APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}106# APPLE_API_ISSUER_ID: ${{ secrets.APPLE_API_ISSUER_ID }}107# run: |108# KEY_PATH="$RUNNER_TEMP/AuthKey_${APPLE_API_KEY_ID}.p8"109# echo -n "$APPLE_API_KEY_P8" | base64 --decode -o "$KEY_PATH"110111# # notarytool exits 0 whenever processing completes, even when the verdict112# # is Invalid — parse the status and fetch the rejection log ourselves.113# SUBMIT_JSON=$(xcrun notarytool submit "$dmg_path" \114# --key "$KEY_PATH" \115# --key-id "$APPLE_API_KEY_ID" \116# --issuer "$APPLE_API_ISSUER_ID" \117# --wait --output-format json)118# echo "$SUBMIT_JSON"119# STATUS=$(echo "$SUBMIT_JSON" | python3 -c 'import json,sys; print(json.load(sys.stdin)["status"])')120# SUBMISSION_ID=$(echo "$SUBMIT_JSON" | python3 -c 'import json,sys; print(json.load(sys.stdin)["id"])')121122# if [ "$STATUS" != "Accepted" ]; then123# echo "Notarization verdict: $STATUS — fetching log:"124# xcrun notarytool log "$SUBMISSION_ID" \125# --key "$KEY_PATH" \126# --key-id "$APPLE_API_KEY_ID" \127# --issuer "$APPLE_API_ISSUER_ID"128# rm -f "$KEY_PATH"129# exit 1130# fi131132# rm -f "$KEY_PATH"133134# - name: Staple notarization ticket135# run: |136# # notarytool --wait reports success as soon as Apple's notary service137# # finishes, but the ticket can take a little longer to propagate through138# # Apple's CloudKit-backed distribution — stapling immediately after can139# # transiently fail with "CloudKit query ... Record not found". Retry with140# # backoff rather than failing the whole release on a race condition.141# for attempt in 1 2 3 4 5; do142# if xcrun stapler staple "$dmg_path"; then143# exit 0144# fi145# echo "staple attempt $attempt failed, retrying in 30s..."146# sleep 30147# done148# echo "stapling failed after all retries"149# exit 1150151# - name: Verify Gatekeeper acceptance152# run: |153# spctl -a -t open --context context:primary-signature -v "$dmg_path"154# spctl -a -vv "build/Build/Products/Release/Rhea.app"155156# - name: Clean up temporary keychain157# if: always()158# run: |159# if [ -n "$keychain_path" ] && [ -f "$keychain_path" ]; then160# security delete-keychain "$keychain_path" || true161# fi162163# - name: Extract changelog section164# id: changelog165# run: |166# NOTES=$(python3 Packaging/scripts/extract_changelog.py \167# "${{ steps.version.outputs.marketing_version }}" CHANGELOG.md)168# {169# echo "log<<EOF"170# echo "$NOTES"171# echo "EOF"172# } >> "$GITHUB_OUTPUT"173174# - name: Create Gitea release175# id: create_release176# env:177# GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}178# run: |179# # Idempotent re-runs: a re-pushed tag (e.g. after a failed run) may180# # already have a release — delete it so the create below starts clean.181# EXISTING_ID=$(curl -s \182# -H "Authorization: token $GITEA_TOKEN" \183# "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/tags/${{ steps.version.outputs.tag }}" \184# | python3 -c 'import json,sys; print(json.load(sys.stdin).get("id",""))' 2>/dev/null || true)185# if [ -n "$EXISTING_ID" ]; then186# echo "deleting existing release $EXISTING_ID for tag ${{ steps.version.outputs.tag }}"187# curl -s -X DELETE \188# -H "Authorization: token $GITEA_TOKEN" \189# "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/$EXISTING_ID"190# fi191192# BODY=$(python3 -c "import json,sys; print(json.dumps(sys.stdin.read()))" <<< "${{ steps.changelog.outputs.log }}")193# RESPONSE=$(curl -s -X POST \194# -H "Authorization: token $GITEA_TOKEN" \195# -H "Content-Type: application/json" \196# -d "{\"tag_name\":\"${{ steps.version.outputs.tag }}\",\"name\":\"${{ steps.version.outputs.tag }}\",\"body\":$BODY,\"draft\":false,\"prerelease\":false}" \197# "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases")198# echo "$RESPONSE"199# echo "release_id=$(echo "$RESPONSE" | python3 -c 'import json,sys; print(json.load(sys.stdin)["id"])')" >> "$GITHUB_OUTPUT"200201# - name: Upload dmg to release202# env:203# GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}204# run: |205# curl -s -X POST \206# -H "Authorization: token $GITEA_TOKEN" \207# -F "attachment=@${dmg_path}" \208# "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/${{ steps.create_release.outputs.release_id }}/assets?name=${dmg_path}"209210# - name: Fetch Sparkle release tools211# run: |212# curl -sL "https://github.com/sparkle-project/Sparkle/releases/download/2.6.4/Sparkle-2.6.4.tar.xz" -o sparkle.tar.xz213# mkdir -p sparkle-tools214# tar -xf sparkle.tar.xz -C sparkle-tools bin/sign_update215# chmod +x sparkle-tools/bin/sign_update216217# - name: Sign and publish appcast218# env:219# SPARKLE_ED_PRIVATE_KEY: ${{ secrets.SPARKLE_ED_PRIVATE_KEY }}220# GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}221# run: |222# DOWNLOAD_URL="${{ github.server_url }}/${{ github.repository }}/releases/download/${{ steps.version.outputs.tag }}/${dmg_path}"223# # sign_update opens its key file with Foundation APIs that can't read224# # bash process-substitution fd paths (/dev/fd/N) — use a real temp file.225# # Its output is already formatted as enclosure attributes:226# # sparkle:edSignature="..." length="..."227# SPARKLE_KEY_FILE="$RUNNER_TEMP/sparkle_ed_key"228# printf '%s' "$SPARKLE_ED_PRIVATE_KEY" > "$SPARKLE_KEY_FILE"229# SIGNATURE_ATTRS=$(sparkle-tools/bin/sign_update "$dmg_path" -f "$SPARKLE_KEY_FILE")230# rm -f "$SPARKLE_KEY_FILE"231# PUB_DATE=$(date -u +"%a, %d %b %Y %H:%M:%S +0000")232233# # This release-side appcast only lists the current release — see the234# # "Publish appcast to stable feed branch" step below for why a single-item feed235# # is sufficient and how it's exposed at one stable URL for the app's SUFeedURL.236# cat > appcast.xml <<XMLEOF237# <?xml version="1.0" encoding="utf-8"?>238# <rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle">239# <channel>240# <title>Rhea</title>241# <item>242# <title>${{ steps.version.outputs.tag }}</title>243# <pubDate>$PUB_DATE</pubDate>244# <sparkle:version>${{ steps.version.outputs.marketing_version }}</sparkle:version>245# <sparkle:shortVersionString>${{ steps.version.outputs.marketing_version }}</sparkle:shortVersionString>246# <sparkle:minimumSystemVersion>14.0</sparkle:minimumSystemVersion>247# <enclosure248# url="$DOWNLOAD_URL"249# type="application/octet-stream"250# $SIGNATURE_ATTRS />251# </item>252# </channel>253# </rss>254# XMLEOF255256# curl -s -X POST \257# -H "Authorization: token $GITEA_TOKEN" \258# -F "attachment=@appcast.xml" \259# "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/${{ steps.create_release.outputs.release_id }}/assets?name=appcast.xml"260261# - name: Publish appcast to stable feed branch262# env:263# GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}264# run: |265# # The per-release appcast.xml uploaded above lives at a URL that changes every266# # release; Sparkle's SUFeedURL needs one URL that never changes. Gitea has no267# # GitHub-style "latest release asset" redirect (confirmed: /releases/latest/download/268# # 404s), so instead force-push the same appcast.xml to a dedicated orphan branch and269# # serve it via Gitea's raw-file endpoint, which is stable by construction. Only the270# # current release needs to be advertised — Sparkle just compares the feed's newest271# # sparkle:version against the running app, so a single-item feed with no history is272# # sufficient and the branch is simply overwritten each run.273# cp appcast.xml "$RUNNER_TEMP/appcast.xml"274# git config user.name "gitea-actions"275# git config user.email "actions@git.danieldaum.net"276# SERVER_HOST=$(echo "${{ github.server_url }}" | sed -e 's#^https://##')277# AUTH_URL="https://x-access-token:${GITEA_TOKEN}@${SERVER_HOST}/${{ github.repository }}.git"278# git checkout --orphan appcast-feed279# git rm -rf . > /dev/null 2>&1 || true280# cp "$RUNNER_TEMP/appcast.xml" appcast.xml281# git add appcast.xml282# # This runner's user account has commit/tag signing enabled (via Secretive), which283# # only works interactively — it isn't a human-authored commit, just a mechanism to284# # publish a generated file at a stable URL, so skip signing for it specifically285# # rather than disabling signing globally.286# git commit --no-gpg-sign -m "chore: publish appcast.xml for ${{ steps.version.outputs.tag }}"287# git push "$AUTH_URL" HEAD:appcast-feed --force
.tangled/workflows/mirror.ymldeleted
+0 −36
@@ -1,36 +0,0 @@1# .tangled/workflows/mirror-to-github.yml23when:4 - event: ["push", "manual"]5 branch: ["main"]67engine: "nixery"89clone:10 depth: 01112dependencies:13 nixpkgs:14 - git1516steps:17 - name: "Mirror to GitHub"18 command: |19 git fetch --unshallow origin || true20 git fetch origin refs/heads/main:refs/heads/main21 git remote add github https://x-access-token:${GITHUB_PAT}@github.com/${GITHUB_USERNAME}/${GITHUB_REPO_NAME}.git22 git push github refs/heads/main:refs/heads/main --force23 environment:24 GITHUB_USERNAME: "daniel-daum"25 GITHUB_REPO_NAME: "rhea"2627 - name: "Mirror to Gitea"28 command: |29 git fetch --unshallow origin || true30 git fetch origin refs/heads/main:refs/heads/main31 git remote add gitea https://${GITEA_USERNAME}:${GITEA_TOKEN}@${GITEA_HOST}/${GITEA_USERNAME}/${GITEA_REPO_NAME}.git32 git push gitea refs/heads/main:refs/heads/main --force33 environment:34 GITEA_USERNAME: "daniel-daum"35 GITEA_REPO_NAME: "rhea"36 GITEA_HOST: "git.danieldaum.net"
AGENTS.md
+13 −8
@@ -4,6 +4,11 @@ Reference doc for any coding agent or new contributor working in this repo. For44Claude-Code-specific working conventions (things learned the hard way, kept as55guardrails), see `CLAUDE.md` — read both before making non-trivial changes.667> **Archived.** Rhea was a deliberate experiment in AI-assisted software development.8> It was designed, specified, and written primarily through conversation with Claude.9> The code is functional but rough — it's a case study, not a product.10> No further development is planned.11712## What this is813914Rhea is a native macOS SwiftUI app for turning scanned grocery-receipt PDFs into@@ -89,10 +94,10 @@ Rhea/8994- `Receipt`: `id` (UUID), `sourceURL` (in-vault copy), `pageImage` (Data?), `status`9095 (`queued`/`inProgress`/`done`/`failed`), `extracted` (`ExtractedReceipt?`),9196 `confirmed` (Bool), `errorMessage`, and `submittedAt`/`startedAt`/`finishedAt`.92 - `publicID` = `rhea_receipt_id_<uuid, no dashes>`.93 - `naturalKey` = `chain_storeNumber_date_receiptNumber` (slugified); falls back to94 a UUID-derived `generatedReceiptNumber` when the model can't read one, then to95 `publicID` if chain + one other part are still missing. Used as the DB key.97 - `publicID` = `rhea_receipt_id_<uuid, no dashes>`.98 - `naturalKey` = `chain_storeNumber_date_receiptNumber` (slugified); falls back to99 a UUID-derived `generatedReceiptNumber` when the model can't read one, then to100 `publicID` if chain + one other part are still missing. Used as the DB key.96101- `ExtractedReceipt`: `merchant`, `chain?`, `storeNumber?`, `storeAddress?`, `date`97102 (ISO-8601), `receiptNumber?`, `total`, `tax?`, `paymentMethod?`, `lineItems`,98103 `overallConfidence?` (0–1, the model's confidence in the whole extraction).@@ -100,10 +105,10 @@ Rhea/100105 read-only), `userCommonName?` (user's own normalized name, editable), `category?`,101106 `barcode?`, `quantity?`, `unitPrice?`, `weightLbs?`, `pricePerLb?`, `listPrice?`,102107 `pricePaid?`, `lineTotal?`, `confidence?` (0–1, per-line model confidence).103 - `stableKey(receiptKey:index:)` = `barcode_<barcode>` when present, else104 `<receiptKey>_itemNN`.105 - The model emits `commonName` in its JSON; decoding maps that (and legacy saved106 records) into `aiCommonName`.108 - `stableKey(receiptKey:index:)` = `barcode_<barcode>` when present, else109 `<receiptKey>_itemNN`.110 - The model emits `commonName` in its JSON; decoding maps that (and legacy saved111 records) into `aiCommonName`.107112108113All model decoding goes through `LenientDecoding` helpers because local vision109114models drift on types (numeric fields as strings, quoted decimals, nulls in
README.md
+10 −4
@@ -3,22 +3,28 @@33</p>4455<h1 align="center">Rhea</h1>6<p align="center">Turn a folder of scanned grocery receipts into a clean, queryable dataset.</p>6<p align="center">A study in AI-assisted development — a receipt-scanning app built entirely through conversation with Claude.</p>7788<p align="center">9 macOS 14+ · runs fully local9 macOS 14+ · runs fully local · archived1010</p>11111212---131314> **In development.** Rhea is a personal tool under active development and has known15> bugs. An attempt at building something using LLMs. Code generated by claude, expect rough edges, and don't rely on it as your only copy of receipt data.14> **Archived.** Rhea was a deliberate experiment in AI-assisted software development.15> It was designed, specified, and written primarily through conversation with Claude.16> The code is functional but rough — it's a case study, not a product.17> Don't rely on it as your only copy of receipt data.16181719Drop in receipt PDFs, review each extraction next to the original scan, confirm it,1820and export to CSV or Postgres. Extraction runs against your own local vision model1921(LM Studio, oMLX, or anything else that speaks the OpenAI chat-completions API) —2022nothing leaves your machine.212324This project demonstrates what's possible when a developer iterates closely with an25AI coding assistant over the course of a project — from architecture decisions to26bug fixes to feature additions, all through conversation.272228## Build from source23292430Rhea is a native Xcode macOS App project generated by [XcodeGen](https://github.com/yonaskolb/XcodeGen)