Open source under Apache 2.0, with a new README

- LICENSE (Apache 2.0), NOTICE with credits (Needle 2, LiteRT-LM, Thinai),
  LICENSES/Thinai-MIT.txt, SPDX headers on every source file
- CONTRIBUTING (fork, branch from develop, PR into develop, maintainer
  merges), CODE_OF_CONDUCT (Contributor Covenant 2.1), SECURITY, Gitea
  issue and pull-request templates
- README rewritten with screenshots; the detailed guide moved to
  docs/USER_GUIDE.md
- Personal details removed: made-up contact names in examples and tests,
  a placeholder for the Tailscale address, made-up web-search fixtures
  in place of saved third-party pages
- B-43: the emulator reports Needle as unavailable instead of "init failed"
- B-44: chat previews show plain text, not Markdown symbols
This commit is contained in:
thekhalidsha committed 2026-09-28 12:40:28 +05:30
1 parent 0bd9888335
commit 917d4632c2
109 files changed
+1080 -179

No files matched your search

+3
View File
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
// JNI bridge to the Needle 2 C API (needle.h). Needle keeps one process-global conversation,
// so the Kotlin side calls these from a single thread only.
// Strings cross JNI as UTF-8 byte arrays: JNI's own string functions use "modified UTF-8",
+3
View File
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
// Stand-in for CPU types Needle has no prebuilt engine for (x86_64 emulators): every call reports failure,
// so the app runs normally with the on-device command model shown as unavailable.
#include "needle.h"
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch
import android.Manifest
+3
View File
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch
import android.content.Context
+3
View File
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch
/**
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch
import android.app.Application
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch
import android.content.ActivityNotFoundException
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.agent
import android.content.Context
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.agent
import android.content.Context
@@ -130,7 +133,8 @@ object ChatStore {
title = title,
updated = turn.at,
count = list.size,
preview = turn.text.replace(Regex("\\s+"), " ").take(90),
// Plain text: the panel shows one line, and "**Subject:**" should read as "Subject:".
preview = app.stitch.core.MarkdownParser.toPlainText(turn.text).replace(Regex("\\s+"), " ").take(90),
)
prefs(c).edit().putString(key(id), encode(list)).putString(INDEX, encodeIndex(idx)).apply()
changed()
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.agent
/**
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.agent
import app.stitch.core.TimeParser
@@ -1,3 +1,7 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-FileCopyrightText: 2026 Abhinivesh (adapted from Thinai, MIT: see LICENSES/Thinai-MIT.txt)
// SPDX-License-Identifier: Apache-2.0 AND MIT
package app.stitch.agent
import java.security.SecureRandom
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.ai
import app.stitch.tools.Tool
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.ai
import app.stitch.tools.Tool
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.ai
import android.content.Context
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.ai
import android.content.Context
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.ai
import android.app.DownloadManager
@@ -1,3 +1,7 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-FileCopyrightText: 2026 Abhinivesh (adapted from Thinai, MIT: see LICENSES/Thinai-MIT.txt)
// SPDX-License-Identifier: Apache-2.0 AND MIT
package app.stitch.ai
import android.app.ActivityManager
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.ai
import app.stitch.tools.Tool
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.ai
import app.stitch.tools.Tool
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.ai
import org.json.JSONObject
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.automation
import android.accessibilityservice.AccessibilityService
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.automation
import android.content.Context
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.automation
import android.content.Context
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.automation
import android.content.Intent
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.automation
import android.graphics.Rect
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.automation
import android.accessibilityservice.AccessibilityService
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.core
import android.app.AlarmManager
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.core
import android.content.Context
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.core
import android.Manifest
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.core
import android.content.Context
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.core
/** The Markdown blocks AI replies use, parsed without any library so the chat can draw them natively. */
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.core
import android.content.Context
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.core
import android.content.Context
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.core
import android.app.AlarmManager
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.core
import android.content.Context
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.core
import java.time.LocalDateTime
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.needle
import android.content.Context
@@ -73,8 +76,13 @@ class NeedleEngine(private val context: Context, private val toolsJson: String)
var status: String = "Not loaded yet"
private set
/**
* Whether the real Needle engine was installed. x86_64 emulators also list ARM in SUPPORTED_ABIS (they
* translate ARM code), but an emulator build installs the x86_64 stand-in, which always fails — so
* look at which native library folder Android actually picked.
*/
val isSupportedDevice: Boolean
get() = Build.SUPPORTED_ABIS.any { it == "arm64-v8a" || it == "armeabi-v7a" }
get() = context.applicationInfo.nativeLibraryDir.substringAfterLast('/').startsWith("arm")
suspend fun warmUp(system: String) = withContext(thread) { ensureReady(system) }
@@ -113,7 +121,7 @@ class NeedleEngine(private val context: Context, private val toolsJson: String)
private fun load(): Boolean {
if (!isSupportedDevice) {
status = "Not available on this CPU (${Build.SUPPORTED_ABIS.firstOrNull()})"
status = "Not available on this CPU (${context.applicationInfo.nativeLibraryDir.substringAfterLast('/')})"
return false
}
return try {
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.notifications
import android.app.Notification
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.tools
import android.Manifest
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.tools
import android.Manifest
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.tools
import android.content.Context
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.tools
import android.Manifest
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.tools
import android.Manifest
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.tools
import android.Manifest
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.tools
import android.app.SearchManager
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.tools
import android.Manifest
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.tools
import android.Manifest
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.tools
import android.content.Intent
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.tools
import android.Manifest
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.tools
import android.content.Context
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.tools
import org.json.JSONArray
@@ -1,3 +1,7 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-FileCopyrightText: 2026 Abhinivesh (adapted from Thinai, MIT: see LICENSES/Thinai-MIT.txt)
// SPDX-License-Identifier: Apache-2.0 AND MIT
package app.stitch.tools
import app.stitch.ai.Http
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.ui
import androidx.compose.foundation.background
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.ui
import android.net.Uri
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.ui
import android.text.format.DateUtils
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.ui
import androidx.compose.foundation.background
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.ui
import androidx.compose.foundation.layout.fillMaxWidth
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.ui
import android.Manifest
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.ui
import androidx.compose.foundation.border
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.ui
import androidx.compose.foundation.layout.Arrangement
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.ui
import android.net.Uri
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.ui
import android.content.Intent
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.ui
import android.os.Build
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.voice
import kotlin.math.PI
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.voice
import android.Manifest
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.voice
import android.content.Context
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.voice
import android.content.Intent
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch.voice
import android.annotation.SuppressLint
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch
import app.stitch.core.Backup
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch
import android.content.Context
@@ -119,6 +122,13 @@ class ChatStoreTest {
assertEquals("line 99", (conv.last() as ConvItem.Assistant).text)
}
@Test
fun `the panel preview is plain text, not Markdown`() {
val id = ChatStore.currentId(c)
say(id, "draft an email", "Here's a draft:\n\n**Subject:** Leave on _Friday_")
assertEquals("Here's a draft: Subject: Leave on Friday", ChatStore.list(c).single().preview)
}
@Test
fun `long titles are shortened at a word`() {
val t = ChatStore.titleFrom("Please summarize the last five calls from yesterday and tell me who needs a callback")
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch
import app.stitch.automation.ClockScreen
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch
import app.stitch.agent.Agent
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch
import app.stitch.voice.Fingerprint
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch
import app.stitch.agent.Grounding
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch
import app.stitch.core.MarkdownParser
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch
import app.stitch.ai.ModelGuide
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch
import app.stitch.tools.Contacts
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch
import app.stitch.ai.AnthropicProvider
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch
import app.stitch.ai.ConvItem
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch
import android.content.Context
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch
import app.stitch.agent.QuickCommands
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch
import app.stitch.core.MarkdownParser
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch
import app.stitch.core.TimeParser
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch
import app.stitch.agent.Untrusted
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch
import app.stitch.voice.Fingerprint
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2026 Mohammed Khalid
// SPDX-License-Identifier: Apache-2.0
package app.stitch
import app.stitch.tools.WebSearch
@@ -71,7 +74,7 @@ class WebSearchTest {
}
@Test
fun `a real Bing page is read, with its tracking links decoded`() {
fun `a Bing results page is read, with its tracking links decoded`() {
val r = WebSearch.parseHeadingResults(fixture("bing_nvidia_ceo.html"))
assertTrue("got ${r.size}", r.size >= 5)
assertEquals("https://en.wikipedia.org/wiki/Jensen_Huang", r[0].url)