Personal Telegram developer console for GitHub

hardening/ci-zero-test-telegram-token
audit/commit-drilldown audit/finalize-workspace-menu-security audit/ops-actionability audit/pr-menu-consolidation audit/status-menu-consolidation audit/telegram-menu-e2e audit/telegram-menu-e2e-wave2 chore/actions-node24-runtime cleanup/remove-diag design/cloudflare-ops-read docs/control-plane-2-7-design docs/guide-v2-1-sync docs/menu-audit-final-sync docs/phase2-acceptance-closeout docs/phase2-multifile-design feat/bootstrap-worker feat/cloudflare-ops-read feat/cp2-multifile-final feat/cp2-multifile-workspace feat/cp3-github-write-final feat/cp4-cloudflare-ops-final feat/cp5-cicd-control-plane feat/cp6-incident-manager feat/cp7-automation-engine feat/deep-file-browser feat/final-delivery-16-20 feat/github-advanced-read feat/in-app-guide-v2 feat/navigation-recovery-ux-v2 feat/ops-console-v2-1 feat/persistent-menu-code-input feat/phase2-multifile-workspace feat/phase2-multifile-workspace-v2 feat/plugin-foundation-v1 feat/safe-github-ops feat/self-register-webhook feat/studio-g0-foundation feat/telegram-main-inline-menu feat/telegram-pr-merge feat/ux-platform-8-12 feat/v3a-readonly-copilot feat/workspace-file-upload feature/mobile-repo-browser feature/multi-file-change-set fix/approval-expiry-feedback fix/callback-resilience-and-docs fix/ci-actions-pagination fix/cloudflare-fetch-binding fix/editor-request-body-cap fix/editor-safe-file-options fix/issues-permission-release-empty-ux fix/main-menu-callback-fallback fix/phase2-file-editor-selection fix/phase2-final-ux fix/phase2-workspace-ref-persistence fix/production-auto-deploy fix/provider-write-error-feedback fix/repository-id-navigation-fallback fix/repository-pr-navigation fix/telegram-callback-updates fix/telegram-runtime-diagnostics fix/workspace-editor-flow-v2 fix/workspace-recovery-validation hardening/ci-zero-test-telegram-token hardening/pr1-destructive-totp hardening/pr2-kill-switch main multifile-workspace nexa/edit-BwJEIIY3PW nexa/edit-IPHT8irO7b nexa/edit-b4Od3BIMYd p2-multifile phase2-20261005 phase2-20261005-a phase2-20261005-b phase2-20261005-c phase2-20261005-d phase2-20261005-e phase2-20261005-f phase2-20261005-g phase2-20261005-h phase2-20261005-i phase2-20261005-j phase2-20261005-k phase2-20261005-l phase2-20261005-m phase2-20261005-n phase2-20261005-o phase2-20261005-p phase2-20261005-q phase2-20261005-r phase2-20261005-s phase2-20261005-t phase2-20261005-u phase2-20261005-v phase2-20261005-w phase2-20261005-x phase2-20261005-y phase2-20261005-z phase2-acceptance-closeout phase2-add-file-hotfix phase2-change-set phase2-design-20261005 phase2-design-final phase2-implementation phase2-multifile-implementation phase2-multifile-spec phase2-spec-final phase2-workspace phase2/multifile-workspace plan/nexa-studio-v2-reviewed security/remove-telegram-setup spec/repository-workspace-editor v3a/multifile work/multifile
md 242 lines 12.6 KB
Rendered Raw
1 # PROJECT_MEMORY.md
2
3 ## Project Identity
4 - Name: Nexa Dev Bot
5 - Repository: `davoodmehraban89/nexa-dev-bot`
6 - Canonical branch: `main`
7 - Visibility: private
8 - Purpose: personal, owner-only Telegram developer console for GitHub repository visibility and controlled developer operations.
9 - This file is the Single Source of Truth for AI continuity. Repository/runtime evidence overrides stale text here.
10
11 ## AI HANDOFF PROTOCOL
12 1. Read this file completely before making changes.
13 2. Verify the real repository head, recent commits, CI, source and runtime evidence.
14 3. Prefer repository/runtime evidence over previous chat claims or stale memory.
15 4. If this file is stale, repair it before implementation.
16 5. Continue from `Current Work / Last Checkpoint`.
17 6. After each durable checkpoint, update this file with evidence and remaining work.
18 7. Never store passwords, tokens, API secrets, webhook secrets or private keys here.
19
20 ## Product Vision
21 Build a secure, professional, mobile-first Telegram control surface for GitHub projects with hierarchical navigation, minimal chat clutter, trustworthy live data, auditability and later developer automation.
22
23 ## Repository / Workspace
24 - Repository: `davoodmehraban89/nexa-dev-bot`
25 - Default branch: `main`
26 - Connected GitHub integration has repository read/write access.
27 - The former branch `feat/telegram-main-inline-menu` is stale and is not the implementation baseline.
28 - Current implementation baseline is `main`.
29
30 ## Architecture
31 Current source layout:
32 - `src/index.js` — Cloudflare Worker HTTP boundary, webhook authentication and owner authorization.
33 - `src/bot.js` — Telegram update router and callback handling.
34 - `src/telegram.js` — Telegram Bot API client with explicit error propagation.
35 - `src/github.js` — authenticated GitHub REST reader; fails explicitly instead of returning fabricated fallback data.
36 - `src/menu.js` — hierarchical inline-menu renderer and callback router.
37 - `src/config.js` — minimal non-secret static configuration.
38 - `.github/workflows/ci.yml` — Node.js CI.
39 - `test/` — security, navigation, bot, menu, worker, GitHub and Telegram client regression tests.
40
41 ## Technology Stack
42 - JavaScript ES modules
43 - Node.js 22 test runner
44 - Telegram Bot API
45 - GitHub REST API
46 - Cloudflare Workers / Wrangler
47 - GitHub Actions
48
49 ## Environments & Integrations
50 Repository-verified:
51 - Cloudflare Worker configuration exists in `wrangler.jsonc` with `src/index.js` as entrypoint.
52 - Telegram Bot API integration exists.
53 - GitHub API integration exists.
54 - CI workflow exists.
55 Runtime configuration names required by the code:
56 - `TELEGRAM_BOT_TOKEN`
57 - `TELEGRAM_WEBHOOK_SECRET`
58 - `OWNER_TELEGRAM_ID`
59 - `GITHUB_TOKEN`
60 - optional `GITHUB_OWNER`
61 Secret values must never be committed to this file or the repository.
62
63 ## Current Production State
64 - Source and automated CI state are verified as described below.
65 - Live Cloudflare deployment contents after the latest security/quality repair: **NOT YET VERIFIED IN THIS CHECKPOINT**.
66 - Live Telegram mobile behavior after the latest repair: **NOT YET VERIFIED IN THIS CHECKPOINT**.
67
68 ## Completed Work — Verified
69 ### Telegram UX
70 - Hierarchical Inline Keyboard navigation exists.
71 - `/start` creates the initial menu message.
72 - Callback navigation uses `editMessageText` on the same message.
73 - Main menu sections: Repositories, Status, Tools, Settings, Security.
74 - Repository submenu: Files, Pull Requests, Commits, Status/Tests, Back.
75 - Explicit Back navigation is present.
76 - Breadcrumb-style path text is present.
77
78 ### Security boundary
79 Implemented and test-verified in `src/index.js`:
80 - Telegram webhook processing is restricted to `POST /telegram/webhook`.
81 - Missing `TELEGRAM_WEBHOOK_SECRET` fails closed with 503.
82 - Wrong `X-Telegram-Bot-Api-Secret-Token` is rejected with 403.
83 - Missing `OWNER_TELEGRAM_ID` fails closed.
84 - Message and callback senders must match `OWNER_TELEGRAM_ID`.
85 - Unauthorized senders are ignored without Telegram/GitHub network calls.
86 - Temporary `/telegram/setup` route remains disabled.
87 - Temporary diagnostic behavior does not expose Telegram ID/authorization details.
88
89 ### Data trust
90 - `src/github.js` no longer returns sample/default operational data when GitHub fails.
91 - Missing `GITHUB_TOKEN` is an explicit error.
92 - GitHub HTTP failures are surfaced as errors.
93 - Repository discovery uses the authenticated `/user/repos` endpoint so private accessible repositories can be returned.
94 - Repository detail uses live repository metadata.
95 - PRs, commits, files and GitHub Actions status are source-backed.
96 - Hard-coded service health, `100% SLA`, fixed latency and fake security/token status claims were removed.
97 - GitHub-derived menu content is HTML-escaped before Telegram HTML rendering.
98
99 ### Telegram API correctness
100 - `TelegramClient` now throws for network errors, HTTP-level Telegram API failures and Telegram `{ok:false}` responses.
101 - `message is not modified` can therefore be handled deliberately by the bot callback layer rather than silently treated as success.
102
103 ### CI
104 - Test discovery corrected from the wrong `tests/*.test.js` path to `test/*.test.js`.
105 - TDD RED evidence was captured after enabling the real suite and during Telegram error-propagation work.
106 - Fresh GREEN evidence: GitHub Actions run `37050047446`, commit `40e31294950ba6e3d85744728476e81cc239fbe9`.
107 - Exact result: `26` tests, `26` passed, `0` failed, `0` skipped/cancelled.
108
109 ## Current Work / Last Checkpoint
110 WHERE WE WERE:
111 - A modular menu redesign had been uploaded to `main`, but CI ran zero tests, webhook/owner security had regressed, GitHub failures could silently turn into fake data, and status screens contained fabricated operational claims.
112
113 WHAT CHANGED:
114 - Real CI test discovery restored.
115 - Fail-closed webhook authentication and owner-only authorization restored.
116 - GitHub fallback/sample operational data removed.
117 - Status/security/tool screens made non-fabricated.
118 - Navigation tests rewritten for the current one-message architecture.
119 - Telegram API failures now propagate correctly.
120 - Full automated suite is green: run `37050047446`, 26/26 passing.
121
122 WHERE WE ARE NOW:
123 - Repository-level security, data-trust and navigation regression gates are green.
124 - The source implements the requested one-message hierarchical Inline Keyboard flow.
125 - Live deployment and real-phone Telegram smoke after this latest repair remain the final verification gap.
126
127 WHAT REMAINS:
128 1. Verify the live Cloudflare root/health endpoint is serving the latest application version.
129 2. Verify `/telegram/setup` remains unavailable in live runtime.
130 3. On the real Telegram bot/mobile client, smoke-test: `/start → Repositories → repository → Files/Commits/PR/Status → Back → Main`.
131 4. Confirm callback navigation edits the same menu message and does not create message spam.
132 5. Decide separately whether to keep Inline Keyboard as the final UX or add a persistent Reply Keyboard shell; this is not required for the current in-place navigation implementation.
133
134 ## Master Roadmap
135 Phase 1 — Secure Telegram navigation core: **IMPLEMENTED + AUTOMATED-VERIFIED; LIVE MOBILE VERIFICATION PENDING**.
136 Phase 2 — Trustworthy GitHub repository browsing/status: **IMPLEMENTED + AUTOMATED-VERIFIED; LIVE TOKEN/RUNTIME SMOKE PENDING**.
137 Phase 3 — Developer tools and controlled write operations: planned.
138 Phase 4 — Security hardening, auditability and observability: ongoing after live verification.
139 Phase 5 — Mobile QA, release validation and documentation: current next checkpoint.
140
141 ## Requirements
142 - Owner-only personal bot.
143 - Fail closed if webhook authentication/owner configuration is absent or wrong.
144 - No secret values committed to repository.
145 - No fabricated operational success/status.
146 - Minimal chat spam.
147 - Hierarchical navigation with reliable Back behavior.
148 - Preserve GitHub Reader functionality.
149 - Mobile-first Telegram usability.
150 - Completion claims require implemented + tested + re-verified evidence.
151
152 ## User Decisions
153 - Nexa Dev Bot is independent from Finora / Factor-easy application development; do not mix project state or Supabase requirements from those projects into this repository.
154 - Canonical repository: `davoodmehraban89/nexa-dev-bot`.
155 - Professional layered menus are desired.
156 - User prefers execution over explanatory chat.
157 - Before saying a task is complete, verify from three perspectives: Execution, Architecture/Quality, QA/User.
158
159 ## Architecture Decisions
160 - `PROJECT_MEMORY.md` is the canonical continuity file.
161 - Keep the modular source architecture; do not revert to the old monolithic Worker implementation.
162 - Security enforcement belongs at the Worker/update boundary.
163 - External integration failures must be explicit rather than replaced with plausible mock data.
164 - Callback navigation edits the current Telegram message rather than sending a new message.
165 - Initial command entry (`/start`, `/repos`, `/status`) may create an entry message; callback navigation must remain in-place.
166
167 ## Data Model
168 No persistent application database is required or verified for the current read-only GitHub/menu scope.
169
170 ## Security Rules
171 - Never commit Telegram token, GitHub token, webhook secret or private keys.
172 - Validate webhook secret before processing Telegram updates.
173 - Enforce `OWNER_TELEGRAM_ID` for messages and callbacks.
174 - Unauthorized callers must not receive private repository data.
175 - Do not reintroduce temporary diagnostic/setup endpoints without a bounded need and explicit cleanup.
176 - Do not display secret values or infer that a token is valid from static configuration text.
177
178 ## Testing & Acceptance Criteria
179 A checkpoint is complete only after:
180 `IMPLEMENTED → VERIFIED → FIXED IF NEEDED → RE-VERIFIED`
181 Automated minimum gates:
182 - CI executes a non-zero test count.
183 - Security tests pass.
184 - Navigation/bot/menu/index tests pass.
185 - GitHub fail-closed/data-trust tests pass.
186 - Telegram API error propagation tests pass.
187 Current automated evidence: run `37050047446` = 26 pass / 0 fail.
188 Final release gate still required:
189 - live Cloudflare smoke;
190 - real Telegram mobile smoke of complete menu/back flow.
191
192 ## Known Issues / Remaining Gaps
193 - Live Cloudflare deployment after the latest repair is not yet verified in this checkpoint.
194 - Real Telegram mobile smoke after the latest repair is not yet verified.
195 - The current files view is a source-backed listing but does not yet provide full deep folder/file browsing buttons in the new modular UI.
196 - Service Status intentionally avoids claiming external uptime/latency without measured telemetry.
197
198 ## Risks
199 - If Cloudflare has not deployed current `main`, runtime may temporarily differ from repository state.
200 - A runtime secret/configuration mismatch can make the secure webhook fail closed; this is preferable to unauthorized access.
201 - Future GitHub write operations require explicit permission scoping and stronger audit/confirmation rules than current read-only flows.
202
203 ## Technical Debt
204 - Add measured deployment/runtime telemetry if desired rather than static service claims.
205 - Add deeper interactive folder navigation to the modular files view if required.
206 - Consider a durable navigation/session store only if future flows require cross-message/session state; current callback data is sufficient for the existing hierarchy.
207 - Track GitHub Actions deprecation warning for older action runtimes and upgrade actions when appropriate.
208
209 ## Deployment / Release State
210 - GitHub Actions: green on verified code checkpoint `40e31294950ba6e3d85744728476e81cc239fbe9`, run `37050047446`, 26/26 tests passing.
211 - Cloudflare live deployment: pending direct runtime verification after this memory update.
212 - Telegram live/mobile: pending owner smoke test after runtime verification.
213
214 ## Important File Paths
215 - `PROJECT_MEMORY.md`
216 - `src/index.js`
217 - `src/bot.js`
218 - `src/menu.js`
219 - `src/telegram.js`
220 - `src/github.js`
221 - `src/config.js`
222 - `test/security.test.js`
223 - `test/navigation.test.js`
224 - `test/bot.test.js`
225 - `test/menu.test.js`
226 - `test/index.test.js`
227 - `test/github.test.js`
228 - `test/telegram.test.js`
229 - `.github/workflows/ci.yml`
230 - `wrangler.jsonc`
231
232 ## Reference Assets
233 No canonical Nexa Dev UI image asset is currently stored under `docs/project-memory/assets/`.
234 Status: Missing Asset.
235
236 ## Change Log
237 - 2026-10-02: Initial continuity memory created.
238 - 2026-10-02: Reconciled memory after modular menu redesign upload and recorded false-green CI/security/data-trust regressions.
239 - 2026-10-02: Repaired real test discovery, webhook/owner security, GitHub fail-closed behavior, non-fabricated UI status, current navigation coverage and Telegram API failure handling. Automated verification reached 26/26 green in run `37050047446`.
240
241 ## Next Executable Action
242 Verify the live Cloudflare deployment against current `main`, then run the final owner-device Telegram smoke flow without changing architecture unless that live test exposes a defect.