Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -646,11 +646,19 @@ class CharacterCardManager private constructor(private val context: Context) {
append("\n\n")
}

attachedTags.forEach { tag ->
if (tag.promptContent.isNotBlank()) {
append(tag.promptContent)
append("\n\n")
val activeTagsWithContent = attachedTags.filter { it.promptContent.isNotBlank() }
if (activeTagsWithContent.isNotEmpty()) {
append("<tag_prompts priority=\"P1\">\n")
activeTagsWithContent.forEach { tag ->
val resolvedContent =
EngineeringPromptDefaults.resolvePromptContent(context, tag)
if (resolvedContent.isNotBlank()) {
append(" <tag_prompt name=\"${tag.name}\">\n")
append(resolvedContent.trim().prependIndent(" "))
append("\n </tag_prompt>\n")
}
}
append("</tag_prompts>\n\n")
}

if (characterCard.advancedCustomPrompt.isNotBlank()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package com.ai.assistance.operit.data.preferences

import android.content.Context
import com.ai.assistance.operit.R
import com.ai.assistance.operit.data.model.PromptTag
import java.util.Locale

object EngineeringPromptDefaults {
const val CLAUDE_CODE_CORE_ENGLISH = """# Engineering Guidelines (Claude Code)
1. Anti-Overengineering:
- Do not make changes beyond what was requested. A bug fix does not need surrounding code refactored. A simple feature does not need extra configurability.
- Do not add docstrings, comments, or type annotations to code you did not change. Only add comments explaining non-obvious "WHY", never "WHAT".
- Trust internal framework guarantees; only validate at external system boundaries.
- Do not create helpers or premature abstractions for one-time operations. Three similar lines of code is better than a premature abstraction.
- Avoid backwards-compatibility shims like dead aliases or `// removed` comments. If something is unused, delete it cleanly.
2. Faithful Reporting:
- Report verification outcomes faithfully. If checks fail or were skipped, say so explicitly. Never manufacture fake green results.
- When confirmed complete, state it plainly without unnecessary hedging.
3. Reversibility & Blast Radius:
- Freely take safe, reversible actions (reading, small edits, testing). Always confirm before destructive operations (e.g. deleting files, git reset --hard).
- Investigate root causes instead of bypassing safety checks.
4. Diagnostic Discipline:
- When an approach fails, diagnose root causes from error outputs before changing tactics. Never blindly repeat failed actions."""

const val CODEX_CORE_ENGLISH = """# Engineering Guidelines (CodeX)
1. Ground in Environment First:
- Explore before asking. Discover facts by inspecting files, configs, and entrypoints; do not ask questions that can be answered from the environment.
- Only ask clarifying questions after reasonable exploration fails to resolve obvious ambiguities.
2. Respect Existing Worktree:
- Never revert or discard existing changes you did not make; treat them as user work-in-progress.
- If you notice unexpected external changes while working, stop immediately and ask the user how to proceed.
- Never use destructive commands like `git reset --hard` unless specifically requested.
3. Decision-Complete Planning:
- For complex tasks, make a concrete plan leaving no ambiguous decisions for implementation.
- Keep planning strictly non-mutating (read, search, dry-run only; no file writes).
4. Concise Delivery & Next Steps:
- State the solution clearly without dumping entire files. Do not instruct the user to "save/copy this file".
- When suggesting logical next steps, use numbered lists (1. 2. 3.) for quick replies."""

private val SUPPORTED_LOCALES = listOf(
Locale.CHINA,
Locale.ENGLISH,
Locale.KOREAN,
Locale("es"),
Locale("pt", "BR"),
Locale("id"),
Locale("ms"),
Locale("ro")
)

private fun getLocalizedDefaults(context: Context, resId: Int): Set<String> {
val result = mutableSetOf<String>()
result.add(context.getString(resId).trim())
for (locale in SUPPORTED_LOCALES) {
try {
val config = android.content.res.Configuration(context.resources.configuration)
config.setLocale(locale)
val localizedContext = context.createConfigurationContext(config)
result.add(localizedContext.getString(resId).trim())
} catch (_: Exception) {}
}
return result
}

fun isClaudeCodePreset(name: String): Boolean {
return name.contains("ClaudeCode", ignoreCase = true)
}

fun isCodeXPreset(name: String): Boolean {
return name.contains("CodeX", ignoreCase = true) || name.contains("Codex", ignoreCase = true)
}

fun resolvePromptContent(context: Context, tag: PromptTag): String {
val rawContent = tag.promptContent.trim()
if (rawContent.isBlank()) return ""

if (isClaudeCodePreset(tag.name)) {
val defaults = getLocalizedDefaults(context, R.string.tag_claudecode_content)
if (rawContent in defaults || rawContent == CLAUDE_CODE_CORE_ENGLISH.trim()) {
return CLAUDE_CODE_CORE_ENGLISH
}
return tag.promptContent
}

if (isCodeXPreset(tag.name)) {
val defaults = getLocalizedDefaults(context, R.string.tag_codex_content)
if (rawContent in defaults || rawContent == CODEX_CORE_ENGLISH.trim()) {
return CODEX_CORE_ENGLISH
}
return tag.promptContent
}

return tag.promptContent
}
}
Original file line number Diff line number Diff line change
@@ -1,59 +1,68 @@
package com.ai.assistance.operit.ui.features.settings.screens

import android.content.Context
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.Label
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.Book
import androidx.compose.material.icons.filled.Check
import androidx.compose.material.icons.filled.Code
import androidx.compose.material.icons.filled.Favorite
import androidx.compose.material.icons.filled.Label
import androidx.compose.material.icons.filled.Psychology
import androidx.compose.material.icons.filled.Security
import androidx.compose.material.icons.filled.Shield
import androidx.compose.material.icons.filled.Terminal
import com.ai.assistance.operit.R
import com.ai.assistance.operit.data.model.TagType
import java.util.Locale

/**
* Bilingual data model for PresetTag
*/
data class PresetTagBilingual(
val nameZh: String,
val nameEn: String,
val descriptionZh: String,
val descriptionEn: String,
val promptContentZh: String,
val promptContentEn: String,
val nameZh: String = "",
val nameEn: String = "",
val descriptionZh: String = "",
val descriptionEn: String = "",
val promptContentZh: String = "",
val promptContentEn: String = "",
val tagType: TagType,
val categoryZh: String,
val categoryEn: String,
val icon: androidx.compose.ui.graphics.vector.ImageVector
val categoryZh: String = "",
val categoryEn: String = "",
val icon: androidx.compose.ui.graphics.vector.ImageVector,
val nameResId: Int? = null,
val descriptionResId: Int? = null,
val promptContentResId: Int? = null,
val categoryResId: Int? = null,
) {
/**
* Get localized name based on current locale
*/
fun getLocalizedName(context: Context): String {
if (nameResId != null) return context.getString(nameResId)
return if (isChineseLocale(context)) nameZh else nameEn
}

/**
* Get localized description based on current locale
*/
fun getLocalizedDescription(context: Context): String {
if (descriptionResId != null) return context.getString(descriptionResId)
return if (isChineseLocale(context)) descriptionZh else descriptionEn
}

/**
* Get localized prompt content based on current locale
*/
fun getLocalizedPromptContent(context: Context): String {
if (promptContentResId != null) return context.getString(promptContentResId)
return if (isChineseLocale(context)) promptContentZh else promptContentEn
}

/**
* Get localized category based on current locale
*/
fun getLocalizedCategory(context: Context): String {
if (categoryResId != null) return context.getString(categoryResId)
return if (isChineseLocale(context)) categoryZh else categoryEn
}

Expand Down Expand Up @@ -419,5 +428,38 @@ He found himself in a cyberpunk metropolis ruled by neon lights and flying vehic
categoryZh = "创意写作",
categoryEn = "Creative Writing",
icon = Icons.Default.Book
),
// Engineering Preset Tags
PresetTagBilingual(
nameZh = "ClaudeCode预设提示词",
nameEn = "ClaudeCode Preset Prompt",
descriptionZh = "极简、自律与诚实的代码行动规范,严禁过度设计与测试造假",
descriptionEn = "Minimalist, disciplined, and honest coding guidelines against overengineering and fake verification",
promptContentZh = "",
promptContentEn = "",
tagType = TagType.FUNCTION,
categoryZh = "工程开发",
categoryEn = "Engineering",
icon = Icons.Default.Code,
nameResId = R.string.tag_claudecode_name,
descriptionResId = R.string.tag_claudecode_desc,
promptContentResId = R.string.tag_claudecode_content,
categoryResId = R.string.tag_category_engineering
),
PresetTagBilingual(
nameZh = "CodeX预设提示词",
nameEn = "CodeX Preset Prompt",
descriptionZh = "环境探查优先、工作区保护与决策闭环交付规范",
descriptionEn = "Environment grounding, worktree preservation, and decision-complete delivery guidelines",
promptContentZh = "",
promptContentEn = "",
tagType = TagType.FUNCTION,
categoryZh = "工程开发",
categoryEn = "Engineering",
icon = Icons.Default.Terminal,
nameResId = R.string.tag_codex_name,
descriptionResId = R.string.tag_codex_desc,
promptContentResId = R.string.tag_codex_content,
categoryResId = R.string.tag_category_engineering
)
)
8 changes: 8 additions & 0 deletions app/src/main/res/values-en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8325,4 +8325,12 @@
<string name="market_version_too_low_message">Current client version %1$s is lower than the minimum required version %2$s for this resource. Please update the client before downloading.</string>
<string name="market_version_too_high_message">Current client version %1$s is higher than the maximum supported version %2$s for this resource. Please use a supported client version.</string>
<string name="thinking_config_invalid_json">Invalid Thinking Configuration</string>
<!-- Engineering Preset Tags -->
<string name="tag_category_engineering">Engineering</string>
<string name="tag_claudecode_name">ClaudeCode Preset Prompt</string>
<string name="tag_claudecode_desc">Minimalist, disciplined, and honest coding guidelines against overengineering and fake verification</string>
<string name="tag_claudecode_content"># Engineering Guidelines (Claude Code)\n\n1. Anti-Overengineering:\n- Do not make changes beyond what was requested. A bug fix does not need surrounding code refactored. A simple feature does not need extra configurability.\n- Do not add docstrings, comments, or type annotations to code you did not change.\n- Do not add defensive error handling or fallbacks for impossible scenarios. Trust internal framework guarantees; only validate at system boundaries.\n- Do not create helpers or premature abstractions for one-time operations. Three similar lines of code is better than a premature abstraction.\n- Write comments explaining non-obvious \"WHY\", never self-evident \"WHAT\".\n- Clean up dead code completely without backwards-compatibility shims.\n\n2. Faithful Reporting:\n- Report verification outcomes faithfully. If checks fail or were skipped, say so explicitly. Never manufacture fake green results.\n- State confirmed outcomes plainly without unnecessary hedging.\n\n3. Reversibility &amp; Blast Radius:\n- Freely take safe, reversible actions. Always confirm before destructive operations (e.g. deleting files, git reset --hard).\n- Investigate root causes instead of bypassing safety checks.\n\n4. Diagnostic Discipline:\n- Diagnose root causes from errors before switching tactics. Never blindly repeat failed actions.</string>
<string name="tag_codex_name">CodeX Preset Prompt</string>
<string name="tag_codex_desc">Environment grounding, worktree preservation, and decision-complete delivery guidelines</string>
<string name="tag_codex_content"># Engineering Guidelines (CodeX)\n\n1. Ground in Environment First:\n- Explore before asking. Discover facts by reading files, configs, and code; do not ask questions that can be answered from the environment.\n- Only ask clarifying questions after exploration fails to resolve obvious ambiguities.\n\n2. Respect Existing Worktree:\n- Never revert or discard existing changes you did not make; treat them as user work-in-progress.\n- If you notice unexpected external changes, stop immediately and ask the user.\n- Never use destructive commands unless specifically requested.\n\n3. Decision-Complete Planning:\n- For complex tasks, make a concrete plan leaving no ambiguous decisions for implementation.\n- Keep planning strictly non-mutating (read and search only).\n\n4. Concise Delivery &amp; Next Steps:\n- Explain the solution clearly without dumping entire files. Do not tell the user to save files.\n- Suggest logical next steps using numbered lists for quick replies.</string>
</resources>
8 changes: 8 additions & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7782,4 +7782,12 @@ Ahora puede usar el modo AutoGLM en la interfaz de conversación.</string>
<string name="token_stats_trends">Análisis de tendencias</string>
<string name="token_stats_settings">Configuración de estadísticas</string>
<string name="token_stats_custom_range_confirm">Aceptar</string>
<!-- Etiquetas de desarrollo de ingeniería -->
<string name="tag_category_engineering">Ingeniería</string>
<string name="tag_claudecode_name">Prompt preestablecido ClaudeCode</string>
<string name="tag_claudecode_desc">Pautas de codificación minimalistas, disciplinadas y honestas contra el exceso de ingeniería y verificaciones falsas</string>
<string name="tag_claudecode_content"># Pautas de ingeniería minimalista\n\n1. Anti-sobreingeniería:\n- No realice cambios más allá de lo solicitado. La corrección de un error no necesita refactorización del código circundante.\n- No agregue comentarios ni anotaciones de tipos al código no modificado.\n- Confíe en las garantías del framework; valide solo en los límites del sistema.\n- No cree abstracciones prematuras para operaciones únicas. Tres líneas de código similares son mejores que una abstracción prematura.\n- Escriba comentarios que expliquen el \"POR QUÉ\", nunca el \"QUÉ\".\n- Elimine el código muerto por completo sin parches falsos.\n\n2. Informe fiel y honesto:\n- Reporte los resultados de verificación con fidelidad. Si fallan o no se ejecutaron, indíquelo explícitamente. Nunca fabrique resultados verdes falsos.\n\n3. Reversibilidad y seguridad:\n- Confirme siempre antes de operaciones destructivas (eliminar archivos, git reset --hard).\n- Resuelva las causas fundamentales en lugar de eludir comprobaciones.\n\n4. Disciplina de diagnóstico:\n- Diagnostique el origen del error antes de cambiar de táctica. No repita acciones fallidas a ciegas.</string>
<string name="tag_codex_name">Prompt preestablecido CodeX</string>
<string name="tag_codex_desc">Pautas de exploración del entorno, protección del área de trabajo y planes con decisiones completas</string>
<string name="tag_codex_content"># Pautas de exploración, planificación y entrega\n\n1. Explorar antes de preguntar:\n- Descubra hechos inspeccionando archivos y código. No haga preguntas que el entorno ya responda.\n- Pregunte solo cuando la exploración no logre resolver ambigüedades clave.\n\n2. Respetar el área de trabajo:\n- Nunca revierta cambios existentes que no haya realizado; trátelos como trabajo en curso del usuario.\n- Si detecta cambios externos inesperados, deténgase y consulte al usuario.\n\n3. Planificación con decisiones completas:\n- Para tareas complejas, asegure un plan concreto que no deje dudas para la implementación.\n- Mantenga la planificación en modo no modificador (solo lectura y búsqueda).\n\n4. Entrega concisa y pasos siguientes:\n- Explique la solución claramente sin volcar archivos enteros en el chat.\n- Sugiera los siguientes pasos lógicos en una lista numerada para respuestas rápidas.</string>
</resources>
8 changes: 8 additions & 0 deletions app/src/main/res/values-id/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7633,4 +7633,12 @@ Sekarang Anda dapat menggunakan mode AutoGLM di antarmuka percakapan.</string>
<string name="token_activity_chart_tap_hint">Ketuk grafik untuk melihat data detail</string>
<string name="token_activity_total_tokens">Total Token</string>
<string name="token_activity_peak_tokens">Token puncak</string>
<!-- Tag rekayasa -->
<string name="tag_category_engineering">Rekayasa</string>
<string name="tag_claudecode_name">Prompt Preset ClaudeCode</string>
<string name="tag_claudecode_desc">Pedoman pengkodean minimalis, disiplin, dan jujur terhadap over-engineering dan verifikasi palsu</string>
<string name="tag_claudecode_content"># Pedoman Rekayasa Minimalis\n\n1. Anti-Overengineering:\n- Jangan membuat perubahan melebihi yang diminta. Perbaikan bug tidak memerlukan refaktor kode sekitar.\n- Jangan menambahkan komentar atau anotasi tipe pada kode yang tidak diubah.\n- Percayai jaminan framework; validasi hanya pada batas sistem.\n- Tiga baris kode serupa lebih baik daripada abstraksi prematur.\n- Tulis komentar untuk menjelaskan \"MENGAPA\", bukan \"APA\".\n- Hapus kode mati sepenuhnya.\n\n2. Laporan Jujur:\n- Laporkan hasil verifikasi apa adanya. Jika gagal atau tidak dijalankan, katakan dengan jelas.\n\n3. Keamanan &amp; Reversibilitas:\n- Selalu konfirmasi sebelum tindakan destruktif (menghapus file, git reset --hard).\n- Selesaikan akar masalah daripada melewati pemeriksaan.\n\n4. Disiplin Diagnostik:\n- Diagnosis penyebab kesalahan sebelum beralih taktik. Jangan ulangi tindakan gagal secara membabi buta.</string>
<string name="tag_codex_name">Prompt Preset CodeX</string>
<string name="tag_codex_desc">Pedoman eksplorasi lingkungan, perlindungan worktree, dan rencana keputusan lengkap</string>
<string name="tag_codex_content"># Pedoman Eksplorasi dan Perencanaan\n\n1. Eksplorasi Sebelum Bertanya:\n- Temukan fakta dengan memeriksa file dan kode. Jangan tanyakan hal yang dapat dijawab oleh lingkungan.\n- Bertanyalah hanya jika eksplorasi gagal menyelesaikan ambiguitas.\n\n2. Hormati Worktree yang Ada:\n- Jangan pernah membatalkan perubahan yang bukan Anda buat; anggap sebagai pekerjaan yang sedang berlangsung.\n- Jika melihat perubahan tak terduga, segera berhenti dan tanyakan kepada pengguna.\n\n3. Rencana Keputusan Lengkap:\n- Buat rencana konkret tanpa menyisakan keputusan ambigu untuk implementasi.\n- Jaga perencanaan tetap tanpa modifikasi file.\n\n4. Pengiriman Ringkas:\n- Jelaskan solusi dengan jelas tanpa mencetak seluruh file.\n- Sarankan langkah berikutnya dengan daftar bernomor untuk balasan cepat.</string>
</resources>
Loading