Compare commits

..
2 Commits
Author SHA1 Message Date
thekhalidsha 8f3dbc880a Update repository URLs to git.openkhalix.com 2026-09-28 19:24:04 +05:30
thekhalidsha ec7802463a ci: mirror Gitea releases to GitHub via Actions (release event)
Mirror release to GitHub / mirror (release) Successful in 3s
2026-09-28 14:29:21 +05:30
4 changed files with 197 additions and 6 deletions

No files matched your search

+191
View File
@@ -0,0 +1,191 @@
name: Mirror release to GitHub
# Mirrors Gitea releases (title, body, prerelease flag, APK assets) to
# github.com/${{ github.repository }}. The Gitea push mirror only syncs git
# refs (branches/tags), never releases — this workflow closes that gap.
# Requires repo secret: GH_PAT (GitHub PAT with repo scope / contents:write).
on:
release:
workflow_dispatch:
inputs:
tag:
description: "Gitea tag to mirror (blank = latest Gitea release)"
required: false
jobs:
mirror:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Mirror release to GitHub
env:
GH_PAT: ${{ secrets.GH_PAT }}
EVENT_TAG: ${{ github.event.release.tag_name }}
INPUT_TAG: ${{ github.event.inputs.tag }}
GITEA_SERVER: ${{ github.server_url }}
GH_REPO: ${{ github.repository }}
run: |
cat > /tmp/mirror-release.cjs <<'SCRIPT_EOF'
const { spawnSync } = require("node:child_process");
const fs = require("node:fs");
const GH_PAT = process.env.GH_PAT || "";
const GITEA = (process.env.GITEA_SERVER || "https://git.openkhalix.com").replace(/\/+$/, "");
const REPO = process.env.GH_REPO || "thekhalidsha/stitch";
const TAG = ((process.env.EVENT_TAG || "") + "").trim() || ((process.env.INPUT_TAG || "") + "").trim();
function curlJson(url, opts = {}) {
const args = ["-sS", "-L", "-X", opts.method || "GET", "-w", "\n%{http_code}", url];
if (opts.token) args.push("-H", "Authorization: token " + opts.token);
args.push("-H", "Accept: application/json");
if (opts.body !== undefined) {
args.push("-H", "Content-Type: application/json");
args.push("--data", JSON.stringify(opts.body));
}
const r = spawnSync("curl", args, { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 });
if (r.error || r.status !== 0) throw new Error("curl failed for " + url + ": " + (r.stderr || r.error));
const out = r.stdout;
const nl = out.lastIndexOf("\n");
const code = parseInt(out.slice(nl + 1), 10);
const txt = out.slice(0, nl);
let body = null;
try { body = txt ? JSON.parse(txt) : null; } catch { body = txt; }
return { status: code, body };
}
function curlDownload(url, out, token) {
const args = ["-sS", "-L", "--fail", "--retry", "3", "-o", out, url];
if (token) args.splice(1, 0, "-H", "Authorization: token " + token);
const r = spawnSync("curl", args, { encoding: "utf8" });
if (r.error || r.status !== 0) throw new Error("download failed: " + (r.stderr || r.error));
}
function main() {
if (!GH_PAT) {
console.error("ERROR: GH_PAT secret is not set");
process.exit(1);
}
// 1. Resolve the tag to mirror (event -> input -> latest Gitea release)
let tag = TAG;
if (!tag) {
const latest = curlJson(`${GITEA}/api/v1/repos/${REPO}/releases?limit=1&page=1`);
if (latest.status !== 200 || !Array.isArray(latest.body) || latest.body.length === 0) {
console.error("ERROR: cannot list Gitea releases:", latest.status, latest.body);
process.exit(1);
}
tag = latest.body[0].tag_name;
console.log(`No tag given - using latest Gitea release: ${tag}`);
}
// 2. Fetch the Gitea release (source of truth)
const gr = curlJson(`${GITEA}/api/v1/repos/${REPO}/releases/tags/${encodeURIComponent(tag)}`);
if (gr.status === 404) {
console.log(`Release ${tag} not found on Gitea (deleted or draft) - nothing to mirror.`);
process.exit(0);
}
if (gr.status !== 200) {
console.error("ERROR: Gitea API error", gr.status, gr.body);
process.exit(1);
}
const g = gr.body;
console.log(`Gitea release: ${g.tag_name} "${g.name}" prerelease=${g.prerelease} assets=${(g.assets || []).length}`);
// 3. Upsert the GitHub release (title / body / prerelease flag)
const hr = curlJson(`https://api.github.com/repos/${REPO}/releases/tags/${encodeURIComponent(tag)}`, { token: GH_PAT });
const payload = {
tag_name: g.tag_name,
name: g.name || g.tag_name,
body: g.body || "",
prerelease: !!g.prerelease,
draft: false,
target_commitish: g.target_commitish || undefined,
};
let gh;
if (hr.status === 404) {
const created = curlJson(`https://api.github.com/repos/${REPO}/releases`, { token: GH_PAT, method: "POST", body: payload });
if (created.status !== 201 && created.status !== 200) {
console.error("ERROR: creating GitHub release failed:", created.status, created.body);
process.exit(1);
}
gh = created.body;
console.log(`Created GitHub release ${tag} (prerelease=${payload.prerelease})`);
} else if (hr.status === 200) {
gh = hr.body;
const differs =
(gh.name || "") !== payload.name ||
(gh.body || "") !== payload.body ||
!!gh.prerelease !== payload.prerelease;
if (differs) {
const upd = curlJson(`https://api.github.com/repos/${REPO}/releases/${gh.id}`, {
token: GH_PAT, method: "PATCH",
body: { name: payload.name, body: payload.body, prerelease: payload.prerelease },
});
if (upd.status === 200) {
gh = upd.body;
console.log("Updated existing GitHub release to match Gitea (title/body/prerelease)");
} else {
console.log("WARN: could not update release fields:", upd.status);
}
} else {
console.log(`GitHub release ${tag} already exists and matches - no field changes`);
}
} else {
console.error("ERROR: GitHub API error", hr.status, hr.body);
process.exit(1);
}
// 4. Mirror assets (download from Gitea, upload to GitHub, size-verified)
const gassets = g.assets || [];
for (const a of gassets) {
const existing = (gh.assets || []).find((x) => x.name === a.name);
if (existing && existing.size === a.size) {
console.log(`Asset ${a.name} already present (${a.size} B) - skip`);
continue;
}
if (existing) {
const d = curlJson(`https://api.github.com/repos/${REPO}/releases/assets/${existing.id}`, { token: GH_PAT, method: "DELETE" });
console.log(`Removed mismatched asset ${a.name} (HTTP ${d.status})`);
}
const tmp = "/tmp/" + a.name.replace(/[^\w.\-]/g, "_");
console.log(`Downloading ${a.name} (${a.size} B) from Gitea...`);
curlDownload(a.browser_download_url, tmp, process.env.GITEA_TOKEN || "");
const got = fs.statSync(tmp).size;
if (got !== a.size) {
console.error(`ERROR: download size mismatch ${got} != ${a.size}`);
process.exit(1);
}
const up = spawnSync("curl", [
"-sS", "--fail", "--retry", "3", "-X", "POST",
"-H", "Authorization: token " + GH_PAT,
"-H", "Content-Type: application/octet-stream",
"--data-binary", "@" + tmp,
`https://uploads.github.com/repos/${REPO}/releases/${gh.id}/assets?name=${encodeURIComponent(a.name)}`,
"-o", "/tmp/gh-upload.json",
], { encoding: "utf8" });
fs.unlinkSync(tmp);
if (up.error || up.status !== 0) {
console.error("ERROR: upload failed:", up.stderr, fs.existsSync("/tmp/gh-upload.json") ? fs.readFileSync("/tmp/gh-upload.json", "utf8") : "");
process.exit(1);
}
console.log(`Uploaded ${a.name} to GitHub`);
}
// 5. Final verification: refetch GitHub release, asset names + sizes must match
const verify = curlJson(`https://api.github.com/repos/${REPO}/releases/${gh.id}`, { token: GH_PAT });
let ok = verify.status === 200;
for (const a of gassets) {
const m = ((verify.body || {}).assets || []).find((x) => x.name === a.name);
if (!m || m.size !== a.size) {
ok = false;
console.error(`VERIFY FAIL: ${a.name} missing or size mismatch on GitHub`);
}
}
if (!ok) process.exit(2);
console.log(`DONE: ${tag} mirrored to GitHub - ${gassets.length} asset(s) verified, prerelease=${payload.prerelease}`);
}
main();
SCRIPT_EOF
node /tmp/mirror-release.cjs
+2 -2
View File
@@ -257,7 +257,7 @@ All times IST.
| 28 Sep, ~12:5x | Pre-publication check of every tracked file and the whole history. Found: possibly real contact names from the owner's bug reports ("Maria Daniya", "Rahul"), the build machine's Tailscale address, the owner's email on every commit, and a saved Bing results page (third-party content) as a test fixture. Owner chose to clean the history as well as the current files | | 28 Sep, ~12:5x | Pre-publication check of every tracked file and the whole history. Found: possibly real contact names from the owner's bug reports ("Maria Daniya", "Rahul"), the build machine's Tailscale address, the owner's email on every commit, and a saved Bing results page (third-party content) as a test fixture. Owner chose to clean the history as well as the current files |
| 28 Sep, ~13:0x | Added `LICENSE` (official Apache 2.0 text), `NOTICE` (owner's credit; Needle 2, LiteRT-LM and Thinai attributions), `LICENSES/Thinai-MIT.txt`, SPDX headers on 93 source files, `CONTRIBUTING.md`, `CODE_OF_CONDUCT.md` (Contributor Covenant 2.1), `SECURITY.md`, Gitea issue and pull-request templates. Contact names replaced with made-up ones ("Maria Daniya", "Rahul"), the Tailscale address with a placeholder, and the Bing and DuckDuckGo fixtures with made-up pages in the same structure. 125 tests pass | | 28 Sep, ~13:0x | Added `LICENSE` (official Apache 2.0 text), `NOTICE` (owner's credit; Needle 2, LiteRT-LM and Thinai attributions), `LICENSES/Thinai-MIT.txt`, SPDX headers on 93 source files, `CONTRIBUTING.md`, `CODE_OF_CONDUCT.md` (Contributor Covenant 2.1), `SECURITY.md`, Gitea issue and pull-request templates. Contact names replaced with made-up ones ("Maria Daniya", "Rahul"), the Tailscale address with a placeholder, and the Bing and DuckDuckGo fixtures with made-up pages in the same structure. 125 tests pass |
| 28 Sep, ~13:2x | New README with screenshots taken in the emulator against a demo AI (tools kept in scratch, not the repo); the old README's detail moved to `docs/USER_GUIDE.md`. Two small bugs found while taking them: B-43, B-44 | | 28 Sep, ~13:2x | New README with screenshots taken in the emulator against a demo AI (tools kept in scratch, not the repo); the old README's detail moved to `docs/USER_GUIDE.md`. Two small bugs found while taking them: B-43, B-44 |
| 28 Sep, ~13:4x | **History cleaned.** A full backup bundle was made first. `git filter-branch` rewrote all 23 commits on every branch and tag: the same name/address replacements and made-up fixtures applied to every old version of every file, and the owner's email replaced with `[email protected].mohammedkhalid.in`. The 17 annotated tags were recreated with that address, keeping their dates and messages. Every file in every commit then searched: nothing left (the only hits were the OAuth scope name `gmail.compose` in `docs/PLAN.md`). Force-pushed; all 36 branches and tags on Gitea checked identical to the local copy. The v0.3.5 release notes on Gitea were corrected too. This repository now commits with the no-reply address. The session paused once mid-way without saying so; nothing had been pushed at that point | | 28 Sep, ~13:4x | **History cleaned.** A full backup bundle was made first. `git filter-branch` rewrote all 23 commits on every branch and tag: the same name/address replacements and made-up fixtures applied to every old version of every file, and the owner's email replaced with `[email protected].openkhalix.com`. The 17 annotated tags were recreated with that address, keeping their dates and messages. Every file in every commit then searched: nothing left (the only hits were the OAuth scope name `gmail.compose` in `docs/PLAN.md`). Force-pushed; all 36 branches and tags on Gitea checked identical to the local copy. The v0.3.5 release notes on Gitea were corrected too. This repository now commits with the no-reply address. The session paused once mid-way without saying so; nothing had been pushed at that point |
| 28 Sep, ~13:5x | Branch protection on Gitea for `main`, `develop` and `release/*`: only the owner may push or merge, force pushes blocked. Description and topics set, wiki off. **Repository made public**; checked without logging in: the page opens, Gitea detects Apache-2.0, and the 0.4.4 APK downloads | | 28 Sep, ~13:5x | Branch protection on Gitea for `main`, `develop` and `release/*`: only the owner may push or merge, force pushes blocked. Description and topics set, wiki off. **Repository made public**; checked without logging in: the page opens, Gitea detects Apache-2.0, and the 0.4.4 APK downloads |
| 28 Sep, ~14:0x | Owner: the Releases tab showed 0.4.2 on top, not 0.4.4. Gitea orders releases by their **tag's date**, and the archive tags for 0.1.0–0.4.2 had all been created at 11:58 that day, after 0.4.4's tag. A first attempt, recreating the 0.4.3 and 0.4.4 release pages, changed nothing (C-16). Fix: the 15 archive tags re-created with each APK's real build date as the tag date and force-pushed (tags only; commits unchanged). The list now runs 0.4.4 (Latest) → 0.1.0, each dated when it was built, all 17 APKs still attached | | 28 Sep, ~14:0x | Owner: the Releases tab showed 0.4.2 on top, not 0.4.4. Gitea orders releases by their **tag's date**, and the archive tags for 0.1.0–0.4.2 had all been created at 11:58 that day, after 0.4.4's tag. A first attempt, recreating the 0.4.3 and 0.4.4 release pages, changed nothing (C-16). Fix: the 15 archive tags re-created with each APK's real build date as the tag date and force-pushed (tags only; commits unchanged). The list now runs 0.4.4 (Latest) → 0.1.0, each dated when it was built, all 17 APKs still attached |
| 28 Sep, ~14:3x | App icon added to the top of the README (`docs/images/icon.svg` from the icon's own vector shapes, plus a 512 px `icon.png` drawn from them, since no SVG converter is installed) and set as the Gitea repository's avatar | | 28 Sep, ~14:3x | App icon added to the top of the README (`docs/images/icon.svg` from the icon's own vector shapes, plus a 512 px `icon.png` drawn from them, since no SVG converter is installed) and set as the Gitea repository's avatar |
@@ -592,7 +592,7 @@ No system packages were installed. Nothing outside the home folder and the proje
| Native code | `needle_jni.cpp` + x86_64 stub | | Native code | `needle_jni.cpp` + x86_64 stub |
| Test files / tests | 18 / 125 on `develop` after 0.4.4 (0 failed, 1 live test skipped by default; 124 at 0.4.4, 87 at 0.4.3, 80 at 0.4.2, 53 at 0.4.1, 50 at 0.4.0) | | Test files / tests | 18 / 125 on `develop` after 0.4.4 (0 failed, 1 live test skipped by default; 124 at 0.4.4, 87 at 0.4.3, 80 at 0.4.2, 53 at 0.4.1, 50 at 0.4.0) |
| Needle eval (64 phrases, threshold 0.4) | tool 48 · tool+args 47 · on-device 24 · **wrong 0** (re-run 28 Sep at 0.4.4: identical) | | Needle eval (64 phrases, threshold 0.4) | tool 48 · tool+args 47 · on-device 24 · **wrong 0** (re-run 28 Sep at 0.4.4: identical) |
| Version control | git, since 25 Sep. Tags `v0.4.3` and `v0.4.4` (committed 28 Sep on `release/0.4.4`, merged into `main`, formerly `master`). `dist/` and build outputs excluded. **Online since 28 Sep, public since 28 Sep (Apache 2.0):** `thekhalidsha/stitch` on the owner's Gitea server (`git.mohammedkhalid.in`): `main` (default) and `develop`, a `release/<version>` branch and `v<version>` tag for **every version 0.1.0–0.4.4** (0.1.0–0.4.2 as archive entries: notes and APK fingerprint only, since their source was never kept), and a Gitea release per version with its APK attached, all 17 checked against `dist/` | | Version control | git, since 25 Sep. Tags `v0.4.3` and `v0.4.4` (committed 28 Sep on `release/0.4.4`, merged into `main`, formerly `master`). `dist/` and build outputs excluded. **Online since 28 Sep, public since 28 Sep (Apache 2.0):** `thekhalidsha/stitch` on the owner's Gitea server (`git.openkhalix.com`): `main` (default) and `develop`, a `release/<version>` branch and `v<version>` tag for **every version 0.1.0–0.4.4** (0.1.0–0.4.2 as archive entries: notes and APK fingerprint only, since their source was never kept), and a Gitea release per version with its APK attached, all 17 checked against `dist/` |
| On-phone model catalogue | 20 `.litertlm` models from litert-community (sizes from the Hugging Face API, 28 Sep); 8 use cases | | On-phone model catalogue | 20 `.litertlm` models from litert-community (sizes from the Hugging Face API, 28 Sep); 8 use cases |
| License | Apache 2.0 since 28 Sep 2026 (open source); `NOTICE` carries the credits | | License | Apache 2.0 since 28 Sep 2026 (open source); `NOTICE` carries the credits |
| Tools available to the AI | 70 | | Tools available to the AI | 70 |
+1 -1
View File
@@ -2,7 +2,7 @@ Stitch — an on-device Android agent
Copyright 2026 Mohammed Khalid Copyright 2026 Mohammed Khalid
This product is licensed under the Apache License, Version 2.0 (see LICENSE). This product is licensed under the Apache License, Version 2.0 (see LICENSE).
https://git.mohammedkhalid.in/thekhalidsha/stitch https://git.openkhalix.com/thekhalidsha/stitch
If you build on Stitch, a credit such as "Based on Stitch by Mohammed Khalid" in your app's If you build on Stitch, a credit such as "Based on Stitch by Mohammed Khalid" in your app's
About screen or README is warmly appreciated. It is not required beyond what the license asks: About screen or README is warmly appreciated. It is not required beyond what the license asks:
+3 -3
View File
@@ -14,7 +14,7 @@ using a tiny model on the phone for everyday commands and the AI of your choice
![Kotlin](https://img.shields.io/badge/Kotlin-Jetpack%20Compose-7F52FF.svg?logo=kotlin&logoColor=white) ![Kotlin](https://img.shields.io/badge/Kotlin-Jetpack%20Compose-7F52FF.svg?logo=kotlin&logoColor=white)
![Status](https://img.shields.io/badge/status-beta-orange.svg) ![Status](https://img.shields.io/badge/status-beta-orange.svg)
[**Download the APK**](https://git.mohammedkhalid.in/thekhalidsha/stitch/releases/latest) · [**Download the APK**](https://git.openkhalix.com/thekhalidsha/stitch/releases/latest) ·
[User guide](docs/USER_GUIDE.md) · [User guide](docs/USER_GUIDE.md) ·
[Contributing](CONTRIBUTING.md) · [Contributing](CONTRIBUTING.md) ·
[Development history](DEVELOPMENT_HISTORY.md) [Development history](DEVELOPMENT_HISTORY.md)
@@ -98,7 +98,7 @@ flowchart TD
## Get started ## Get started
1. **Download** the latest APK from [Releases](https://git.mohammedkhalid.in/thekhalidsha/stitch/releases/latest) 1. **Download** the latest APK from [Releases](https://git.openkhalix.com/thekhalidsha/stitch/releases/latest)
and open it on your phone. (Stitch is installed directly rather than from the Play Store, because it and open it on your phone. (Stitch is installed directly rather than from the Play Store, because it
uses permissions the Play Store restricts: SMS, call log and screen control.) uses permissions the Play Store restricts: SMS, call log and screen control.)
2. **Connect an AI** in ⚙ Settings → AI & provider, or pick *On this phone* and let the model guide 2. **Connect an AI** in ⚙ Settings → AI & provider, or pick *On this phone* and let the model guide
@@ -124,7 +124,7 @@ Requirements: JDK 17, Android SDK (platform 35, build-tools 35.0.0), **NDK 30.0.
Needle engine needs r30), CMake 3.22.1. The Gradle wrapper fetches Gradle itself. Needle engine needs r30), CMake 3.22.1. The Gradle wrapper fetches Gradle itself.
```sh ```sh
git clone https://git.mohammedkhalid.in/thekhalidsha/stitch.git && cd stitch git clone https://git.openkhalix.com/thekhalidsha/stitch.git && cd stitch
./scripts/fetch-needle.sh # prebuilt Needle 2 engine (already in the repo; this refreshes it) ./scripts/fetch-needle.sh # prebuilt Needle 2 engine (already in the repo; this refreshes it)
./gradlew testDebugUnitTest # unit tests ./gradlew testDebugUnitTest # unit tests
./gradlew assembleRelease # → app/build/outputs/apk/release/app-release.apk ./gradlew assembleRelease # → app/build/outputs/apk/release/app-release.apk