|
| 1 | +GitHub Copilot Chat Assistant — Preparé un paquete (parches) con la estructura completa y el scaffold Android + workflow CI. Copia y ejecuta el siguiente script en tu máquina para generar el ZIP listo para subir o aplicar en un repo. El script crea la estructura, los ficheros principales, el scaffold Android, el workflow de Actions (assembleDebug) y un Makefile básico. |
| 2 | + |
| 3 | +Instrucciones rápidas |
| 4 | +1. Crea un fichero llamado prepare_tokyo_patch.sh y pega el contenido que sigue. |
| 5 | +2. Hazlo ejecutable: chmod +x prepare_tokyo_patch.sh |
| 6 | +3. Ejecútalo: ./prepare_tokyo_patch.sh |
| 7 | +4. Obtendrás tokyo-predictor.zip en la carpeta actual. Descomprímelo o súbelo a GitHub y haz push desde tu máquina. |
| 8 | + |
| 9 | +prepare_tokyo_patch.sh |
| 10 | +#!/usr/bin/env bash |
| 11 | +set -euo pipefail |
| 12 | + |
| 13 | +OUTDIR="tokyo-predictor" |
| 14 | +ZIPFILE="${OUTDIR}.zip" |
| 15 | +MODULE="github.com/modelcontextprotocol/tokyo-predictor" |
| 16 | +YEAR="2025" |
| 17 | +AUTHOR="Melampe001" |
| 18 | + |
| 19 | +rm -rf "${OUTDIR}" "${ZIPFILE}" |
| 20 | +mkdir -p "${OUTDIR}" |
| 21 | + |
| 22 | +cd "${OUTDIR}" |
| 23 | + |
| 24 | +# Directories |
| 25 | +mkdir -p cmd internal lib admin config docs proto ruby testing .github .github/instructions |
| 26 | +mkdir -p android/app/src/main/java/com/example/tokyopredictor |
| 27 | +mkdir -p android/app/src/main/res |
| 28 | +mkdir -p .github/workflows |
| 29 | + |
| 30 | +# README |
| 31 | +cat > README.md <<'EOF' |
| 32 | +tokyo-predictor |
| 33 | + |
| 34 | +Initial scaffold for the Tokyo Predictor repository. |
| 35 | +EOF |
| 36 | + |
| 37 | +# .gitignore (Go) |
| 38 | +cat > .gitignore <<'EOF' |
| 39 | +# Binaries for programs and plugins |
| 40 | +bin/ |
| 41 | +# Test binary, build outputs |
| 42 | +*.test |
| 43 | +# Go workspace file |
| 44 | +go.work |
| 45 | +# IDE/editor files |
| 46 | +.vscode/ |
| 47 | +.idea/ |
| 48 | +# Android builds |
| 49 | +android/app/build/ |
| 50 | +android/.gradle/ |
| 51 | +EOF |
| 52 | + |
| 53 | +# LICENSE (MIT) |
| 54 | +cat > LICENSE <<EOF |
| 55 | +MIT License |
| 56 | + |
| 57 | +Copyright (c) ${YEAR} ${AUTHOR} |
| 58 | + |
| 59 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
| 60 | +of this software and associated documentation files (the "Software"), to deal |
| 61 | +in the Software without restriction, including without limitation the rights |
| 62 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 63 | +copies of the Software, and to permit persons to whom the Software is |
| 64 | +furnished to do so, subject to the following conditions: |
| 65 | +[...standard MIT text...] |
| 66 | +EOF |
| 67 | + |
| 68 | +# CONTRIBUTING.md (uses your Code Standards) |
| 69 | +cat > .github/CONTRIBUTING.md <<'EOF' |
| 70 | +This repository is primarily a Go service with a Ruby client for some API endpoints. It is responsible for ingesting metered usage and recording that usage. Please follow these guidelines when contributing. |
| 71 | + |
| 72 | +Required before each commit |
| 73 | +- Run: make fmt — runs gofmt on all Go files. |
| 74 | +- Ensure tests pass locally: make test. |
| 75 | +- Add tests for new logic. |
| 76 | + |
| 77 | +Development flow |
| 78 | +- Build: make build |
| 79 | +- Test: make test |
| 80 | +- Full CI: make ci (includes build, fmt, lint, test) |
| 81 | + |
| 82 | +If you modify proto/ or ruby/ |
| 83 | +- proto/: run `make proto` after changes. |
| 84 | +- ruby/: increment ruby/lib/billing-platform/version.rb using semantic versioning. |
| 85 | + |
| 86 | +Repository structure |
| 87 | +- cmd/: Main service entry points and executables |
| 88 | +- internal/: Logic related to interactions with other GitHub services |
| 89 | +- lib/: Core Go packages for billing logic |
| 90 | +- admin/: Admin interface components |
| 91 | +- config/: Configuration files and templates |
| 92 | +- docs/: Documentation |
| 93 | +- proto/: Protocol buffer definitions (run `make proto` after updates) |
| 94 | +- ruby/: Ruby implementation components (bump version file when updated) |
| 95 | +- testing/: Test helpers and fixtures |
| 96 | + |
| 97 | +Key guidelines |
| 98 | +1. Follow idiomatic Go practices. |
| 99 | +2. Preserve existing structure. |
| 100 | +3. Use dependency injection patterns where appropriate. |
| 101 | +4. Write unit tests (prefer table-driven). |
| 102 | +5. Document public APIs and complex logic. |
| 103 | + |
| 104 | +How to open a PR |
| 105 | +- Create a descriptive branch (feature/..., fix/...). |
| 106 | +- Ensure you ran: make fmt, make build, make test, make ci, make proto (if relevant), update ruby version file if modifying ruby/. |
| 107 | +- PR description should include what it changes, how to test locally, API impacts and versioning needs. |
| 108 | + |
| 109 | +PR checklist |
| 110 | +- [ ] make fmt passed |
| 111 | +- [ ] make build passed |
| 112 | +- [ ] make test passed |
| 113 | +- [ ] make ci passed |
| 114 | +- [ ] Docs updated if applicable |
| 115 | +- [ ] proto/ or ruby/ changes handled |
| 116 | +- [ ] Tests added for new functionality |
| 117 | +EOF |
| 118 | + |
| 119 | +# Makefile (basic targets matching your Code Standards) |
| 120 | +cat > Makefile <<'EOF' |
| 121 | +.PHONY: fmt build test ci proto |
| 122 | + |
| 123 | +fmt: |
| 124 | +\t@gofmt -w . |
| 125 | + |
| 126 | +build: |
| 127 | +\t@go build ./... |
| 128 | + |
| 129 | +test: |
| 130 | +\t@go test ./... |
| 131 | + |
| 132 | +ci: fmt test |
| 133 | + |
| 134 | +proto: |
| 135 | +\t@echo "Run codegen for proto files (not implemented)." |
| 136 | +EOF |
| 137 | + |
| 138 | +# Placeholder go.mod |
| 139 | +cat > go.mod <<EOF |
| 140 | +module ${MODULE} |
| 141 | + |
| 142 | +go 1.20 |
| 143 | +EOF |
| 144 | + |
| 145 | +# keep dirs visible |
| 146 | +touch cmd/.gitkeep internal/.gitkeep lib/.gitkeep admin/.gitkeep config/.gitkeep docs/.gitkeep proto/.gitkeep ruby/.gitkeep testing/.gitkeep |
| 147 | + |
| 148 | +# Android scaffold (Kotlin) |
| 149 | +cat > android/settings.gradle <<'EOF' |
| 150 | +rootProject.name = "TokyoPredictor" |
| 151 | +include ':app' |
| 152 | +EOF |
| 153 | + |
| 154 | +cat > android/build.gradle <<'EOF' |
| 155 | +buildscript { |
| 156 | + repositories { |
| 157 | + google() |
| 158 | + mavenCentral() |
| 159 | + } |
| 160 | + dependencies { |
| 161 | + classpath "com.android.tools.build:gradle:7.4.2" |
| 162 | + } |
| 163 | +} |
| 164 | + |
| 165 | +allprojects { |
| 166 | + repositories { |
| 167 | + google() |
| 168 | + mavenCentral() |
| 169 | + } |
| 170 | +} |
| 171 | +EOF |
| 172 | + |
| 173 | +cat > android/gradle.properties <<'EOF' |
| 174 | +org.gradle.jvmargs=-Xmx1536m |
| 175 | +android.useAndroidX=true |
| 176 | +android.enableJetifier=true |
| 177 | +EOF |
| 178 | + |
| 179 | +cat > android/app/build.gradle <<'EOF' |
| 180 | +plugins { |
| 181 | + id 'com.android.application' |
| 182 | + id 'kotlin-android' |
| 183 | +} |
| 184 | + |
| 185 | +android { |
| 186 | + compileSdk 33 |
| 187 | + |
| 188 | + defaultConfig { |
| 189 | + applicationId "com.example.tokyopredictor" |
| 190 | + minSdk 21 |
| 191 | + targetSdk 33 |
| 192 | + versionCode 1 |
| 193 | + versionName "0.1" |
| 194 | + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
| 195 | + } |
| 196 | + |
| 197 | + buildTypes { |
| 198 | + release { |
| 199 | + minifyEnabled false |
| 200 | + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
| 201 | + } |
| 202 | + } |
| 203 | + |
| 204 | + compileOptions { |
| 205 | + sourceCompatibility JavaVersion.VERSION_11 |
| 206 | + targetCompatibility JavaVersion.VERSION_11 |
| 207 | + } |
| 208 | + kotlinOptions { |
| 209 | + jvmTarget = "11" |
| 210 | + } |
| 211 | +} |
| 212 | + |
| 213 | +dependencies { |
| 214 | + implementation "org.jetbrains.kotlin:kotlin-stdlib:1.9.0" |
| 215 | + implementation 'androidx.core:core-ktx:1.9.0' |
| 216 | + implementation 'androidx.appcompat:appcompat:1.6.1' |
| 217 | + implementation 'com.google.android.material:material:1.8.0' |
| 218 | + |
| 219 | + testImplementation 'junit:junit:4.13.2' |
| 220 | + androidTestImplementation 'androidx.test.ext:junit:1.1.5' |
| 221 | + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' |
| 222 | +} |
| 223 | +EOF |
| 224 | + |
| 225 | +cat > android/app/src/main/AndroidManifest.xml <<'EOF' |
| 226 | +<manifest package="com.example.tokyopredictor" |
| 227 | + xmlns:android="http://schemas.android.com/apk/res/android"> |
| 228 | + |
| 229 | + <application |
| 230 | + android:label="TokyoPredictor" |
| 231 | + android:icon="@mipmap/ic_launcher"> |
| 232 | + <activity android:name=".MainActivity"> |
| 233 | + <intent-filter> |
| 234 | + <action android:name="android.intent.action.MAIN" /> |
| 235 | + <category android:name="android.intent.category.LAUNCHER" /> |
| 236 | + </intent-filter> |
| 237 | + </activity> |
| 238 | + </application> |
| 239 | + |
| 240 | +</manifest> |
| 241 | +EOF |
| 242 | + |
| 243 | +cat > android/app/src/main/java/com/example/tokyopredictor/MainActivity.kt <<'EOF' |
| 244 | +package com.example.tokyopredictor |
| 245 | + |
| 246 | +import android.os.Bundle |
| 247 | +import androidx.appcompat.app.AppCompatActivity |
| 248 | +import android.widget.TextView |
| 249 | + |
| 250 | +class MainActivity : AppCompatActivity() { |
| 251 | + override fun onCreate(savedInstanceState: Bundle?) { |
| 252 | + super.onCreate(savedInstanceState) |
| 253 | + |
| 254 | + val tv = TextView(this) |
| 255 | + tv.text = "Tokyo Predictor - App Scaffold" |
| 256 | + tv.textSize = 20f |
| 257 | + setContentView(tv) |
| 258 | + } |
| 259 | +} |
| 260 | +EOF |
| 261 | + |
| 262 | +cat > android/app/proguard-rules.pro <<'EOF' |
| 263 | +# Keep default rules (empty stub for now) |
| 264 | +EOF |
| 265 | + |
| 266 | +# GitHub Actions workflow for Android build (assembleDebug) |
| 267 | +cat > .github/workflows/android-build.yml <<'EOF' |
| 268 | +name: Android Build (assembleDebug) |
| 269 | + |
| 270 | +on: |
| 271 | + push: |
| 272 | + branches: |
| 273 | + - ci/android-build |
| 274 | + pull_request: |
| 275 | + branches: |
| 276 | + - main |
| 277 | + |
| 278 | +jobs: |
| 279 | + build: |
| 280 | + runs-on: ubuntu-latest |
| 281 | + env: |
| 282 | + ANDROID_SDK_ROOT: ${{ runner.temp }}/android-sdk |
| 283 | + |
| 284 | + steps: |
| 285 | + - uses: actions/checkout@v4 |
| 286 | + |
| 287 | + - name: Set up JDK 11 |
| 288 | + uses: actions/setup-java@v4 |
| 289 | + with: |
| 290 | + distribution: temurin |
| 291 | + java-version: '11' |
| 292 | + |
| 293 | + - name: Install Android SDK command-line tools & platforms |
| 294 | + run: | |
| 295 | + sudo apt-get update |
| 296 | + sudo apt-get install -y wget unzip |
| 297 | + mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools" |
| 298 | + wget -q -O /tmp/cmdline-tools.zip "https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip" |
| 299 | + unzip -q /tmp/cmdline-tools.zip -d "$ANDROID_SDK_ROOT/cmdline-tools" |
| 300 | + mv "$ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools" "$ANDROID_SDK_ROOT/cmdline-tools/latest" || true |
| 301 | + yes | "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" --sdk_root="$ANDROID_SDK_ROOT" "platform-tools" "platforms;android-33" "build-tools;33.0.2" |
| 302 | + |
| 303 | + - name: Make gradlew executable |
| 304 | + run: | |
| 305 | + if [ -f ./android/gradlew ]; then chmod +x ./android/gradlew; fi |
| 306 | + |
| 307 | + - name: Build debug APK |
| 308 | + working-directory: android |
| 309 | + run: | |
| 310 | + if [ -f ./gradlew ]; then ./gradlew assembleDebug --stacktrace; else gradle assembleDebug --no-daemon --stacktrace; fi |
| 311 | + |
| 312 | + - name: Upload APK artifact |
| 313 | + uses: actions/upload-artifact@v4 |
| 314 | + with: |
| 315 | + name: tokyopredictor-debug-apk |
| 316 | + path: android/app/build/outputs/apk/debug/*.apk |
| 317 | +EOF |
| 318 | + |
| 319 | +# optional: add a simple repo-level CI workflow (Go) - basic check |
| 320 | +cat > .github/workflows/go-ci.yml <<'EOF' |
| 321 | +name: Go CI |
| 322 | + |
| 323 | +on: |
| 324 | + push: |
| 325 | + branches: |
| 326 | + - main |
| 327 | + pull_request: |
| 328 | + branches: |
| 329 | + - main |
| 330 | + |
| 331 | +jobs: |
| 332 | + test: |
| 333 | + runs-on: ubuntu-latest |
| 334 | + steps: |
| 335 | + - uses: actions/checkout@v4 |
| 336 | + - name: Set up Go |
| 337 | + uses: actions/setup-go@v4 |
| 338 | + with: |
| 339 | + go-version: '1.20' |
| 340 | + - name: Run fmt |
| 341 | + run: make fmt || true |
| 342 | + - name: Run tests |
| 343 | + run: make test |
| 344 | +EOF |
| 345 | + |
| 346 | +# Add .github/instructions placeholder and original Fiel if needed |
| 347 | +cat > .github/instructions/Fiel <<'EOF' |
| 348 | +# Original instructions placeholder (migrated to CONTRIBUTING.md) |
| 349 | +EOF |
| 350 | + |
| 351 | +# finalize |
| 352 | +git init -b main >/dev/null 2>&1 || true |
| 353 | +git add -A >/dev/null 2>&1 || true |
| 354 | +git commit -m "chore: prepare patch scaffold (initial files + Android scaffold + CI workflows)" >/dev/null 2>&1 || true |
| 355 | +cd .. |
| 356 | + |
| 357 | +zip -r "${ZIPFILE}" "${OUTDIR}" >/dev/null |
| 358 | + |
| 359 | +echo "Created ${ZIPFILE} with the scaffold." |
| 360 | + |
| 361 | +Fin. |
| 362 | + |
| 363 | +Qué contiene el ZIP |
| 364 | +- README.md, LICENSE, .gitignore |
| 365 | +- .github/CONTRIBUTING.md (con tus Code Standards) |
| 366 | +- Makefile con targets: fmt, build, test, ci, proto |
| 367 | +- Estructura de carpetas: cmd/, internal/, lib/, admin/, config/, docs/, proto/, ruby/, testing/ |
| 368 | +- Scaffold Android completo dentro de android/ (app module, manifest, MainActivity.kt) |
| 369 | +- Workflow CI: .github/workflows/android-build.yml (genera APK debug y sube artifact) |
| 370 | +- Workflow Go CI básico: .github/workflows/go-ci.yml |
| 371 | + |
| 372 | +Pasos sugeridos para aplicar el contenido como repo |
| 373 | +1. Descomprime tokyo-predictor.zip |
| 374 | +2. Revisa archivos y ajusta cualquier valor (module name, applicationId) si lo deseas. |
| 375 | +3. Crea el repo y sube: |
| 376 | + - cd tokyo-predictor |
| 377 | + - git remote add origin git@github.com:MODEL/REPO.git (reemplaza MODEL/REPO) |
| 378 | + - git push -u origin main |
| 379 | + - o usa: gh repo create modelcontextprotocol/tokyo-predictor --public --source=. --remote=origin --push |
| 380 | + |
| 381 | +Cambios opcionales que recomiendo después de aplicar |
| 382 | +- Añadir Gradle Wrapper al directorio android/ (en una máquina con gradle: cd android && gradle wrapper) y subir gradlew/gradlew.bat + gradle/wrapper/* |
| 383 | +- Si vas a firmar releases en CI, añade secretos y ajusta workflow para assembleRelease + signing (te puedo generar el workflow si confirmas los nombres de los secrets). |
| 384 | +- Ajustar go.mod module si tu organización tiene otro path. |
| 385 | +- Habilitar branch protection y permisos en la org. |
| 386 | + |
| 387 | +¿Quieres que además: |
| 388 | +- Genere un PR template / ISSUE template? (sí/no) |
| 389 | +- Genere el workflow de release firmado para Android (requiere que indiques nombres de secrets)? (sí/no) |
| 390 | + |
| 391 | +Si quieres que suba el ZIP aquí para descargar, dime y lo preparo como contenido listo (te mostraré el comando curl/gh to upload); no puedo adjuntar archivos binarios directamente, pero te puedo devolver un patch (git diff) si prefieres aplicar con git apply. |
0 commit comments