Personal Telegram developer console for GitHub
docs/phase2-acceptance-closeout
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
| 1 | import test from 'node:test'; |
| 2 | import assert from 'node:assert/strict'; |
| 3 | import { createWorkspaceController } from '../src/plugins/github/workspace.js'; |
| 4 | |
| 5 | const ws = { id:'W000000001', repoId:1, repoFullName:'o/r', baseBranch:'main', baseHeadSha:'a'.repeat(40), baseTreeSha:'b'.repeat(40), state:'DRAFT', path:'README.md', originalText:'one', draftText:'two', commitMessage:'msg', files:[{path:'README.md',blobSha:'c'.repeat(40),originalText:'one',draftText:'two',draftDigest:'1'.repeat(64)},{path:'src/a.js',blobSha:'d'.repeat(40),originalText:'a',draftText:'b',draftDigest:'2'.repeat(64)}] }; |
| 6 | |
| 7 | test('workspace view lists every change-set file and exposes add control', async()=>{ |
| 8 | const workspaces={async getWorkspace(){return structuredClone(ws)},async createNavigationRefs({refs}){return refs.map((_,i)=>({refId:`R00000000${i}`}))}}; |
| 9 | const c=createWorkspaceController({github:{},workspaces,editorUrl:'https://example.com/editor'}); |
| 10 | const v=await c.resolveCallback('ws:W000000001',{ownerId:'42'}).execute(); |
| 11 | assert.match(v.text,/README\.md/); assert.match(v.text,/src\/a\.js/); assert.match(v.text,/2 فایل/); |
| 12 | assert.ok(v.reply_markup.inline_keyboard.flat().some(b=>b.callback_data==='wfiles:W000000001:1')); |
| 13 | }); |
| 14 | |
| 15 | test('adding a file reads pinned source then upserts durable workspace only', async()=>{ |
| 16 | const calls=[]; |
| 17 | const workspaces={async resolveNavigationRef(){return {repoId:1,path:'src/b.js',type:'workspace-add',workspaceId:'W000000001'}},async getWorkspace(){return structuredClone(ws)},async upsertWorkspaceFile(x){calls.push(['upsert',x]);return {...ws,files:[...ws.files,x.file]}},async createNavigationRefs({refs}){return refs.map((_,i)=>({refId:`R00000000${i}`}))}}; |
| 18 | const github={async getRepository(){return {fullName:'o/r',defaultBranch:'main'}},async getBranchSnapshot(){return {headSha:ws.baseHeadSha,treeSha:ws.baseTreeSha}},async getFileAtRef(_r,path){calls.push(['read',path]);return {path,sha:'e'.repeat(40),content:'safe',size:4}}}; |
| 19 | const c=createWorkspaceController({github,workspaces}); |
| 20 | const v=await c.resolveCallback('wadd:R000000001',{ownerId:'42'}).execute(); |
| 21 | assert.equal(calls[0][0],'read'); assert.equal(calls[1][0],'upsert'); assert.match(v.text,/اضافه|added/i); |
| 22 | }); |
| 23 | |
| 24 | test('removing a change-set file uses opaque ref and durable remove', async()=>{ |
| 25 | let removed=''; |
| 26 | const workspaces={async resolveNavigationRef(){return {workspaceId:'W000000001',path:'src/a.js',type:'workspace-file'}},async removeWorkspaceFile({path}){removed=path;return {...ws,files:[ws.files[0]]}},async createNavigationRefs({refs}){return refs.map((_,i)=>({refId:`R00000000${i}`}))}}; |
| 27 | const c=createWorkspaceController({github:{},workspaces}); |
| 28 | const v=await c.resolveCallback('wremove:R000000001',{ownerId:'42'}).execute(); |
| 29 | assert.equal(removed,'src/a.js'); assert.match(v.text,/README\.md/); |
| 30 | }); |
| 31 | |
| 32 | |
| 33 | test('add-file callback actions are declared READ in the GitHub manifest', async()=>{ |
| 34 | const { githubPluginManifest } = await import('../src/plugins/github/manifest.js'); |
| 35 | for (const action of ['github.workspace.file.pick','github.workspace.file.add','github.workspace.file.remove']) { |
| 36 | assert.equal(githubPluginManifest.actions[action]?.risk, 'READ', action + ' must be routed as owner-only READ'); |
| 37 | } |
| 38 | }); |
| 39 | |
| 40 | |
| 41 | test('file picker rejects a repo id that is not bound to the workspace', async()=>{ |
| 42 | const workspaces={async getWorkspace(){return structuredClone(ws)}}; |
| 43 | const c=createWorkspaceController({github:{async listFiles(){throw new Error('must not read mismatched repo')}},workspaces}); |
| 44 | await assert.rejects(()=>c.resolveCallback('wfiles:W000000001:2',{ownerId:'42'}).execute(),/repository mismatch/i); |
| 45 | }); |
| 46 | |
| 47 | test('file picker lists candidates from the exact workspace base snapshot', async()=>{ |
| 48 | let seen; |
| 49 | const workspaces={async getWorkspace(){return structuredClone(ws)},async createNavigationRefs({refs}){return refs.map((_,i)=>({refId:'R'+String(i).padStart(9,'0')}))}}; |
| 50 | const github={async listFiles(repoId,path,options){seen={repoId,path,options};return [{type:'file',path:'src/new.js',sha:'e'.repeat(40)}]}}; |
| 51 | const c=createWorkspaceController({github,workspaces}); |
| 52 | await c.resolveCallback('wfiles:W000000001:1',{ownerId:'42'}).execute(); |
| 53 | assert.deepEqual(seen,{repoId:1,path:'',options:{ref:ws.baseHeadSha}}); |
| 54 | }); |
| 55 | |
| 56 | test('multi-file workspace exposes a direct editor button for every file', async()=>{ |
| 57 | const workspaces={async getWorkspace(){return structuredClone(ws)},async createNavigationRefs({refs}){return refs.map((_,i)=>({refId:'R'+String(i).padStart(9,'0')}))}}; |
| 58 | const c=createWorkspaceController({github:{},workspaces,editorUrl:'https://example.com/workspace/editor'}); |
| 59 | const v=await c.resolveCallback('ws:W000000001',{ownerId:'42'}).execute(); |
| 60 | const editors=v.reply_markup.inline_keyboard.flat().filter(button=>button.web_app?.url); |
| 61 | assert.equal(editors.length,2); |
| 62 | assert.equal(editors[0].web_app.url,'https://example.com/workspace/editor?workspaceId=W000000001&path=README.md'); |
| 63 | assert.equal(editors[1].web_app.url,'https://example.com/workspace/editor?workspaceId=W000000001&path=src%2Fa.js'); |
| 64 | assert.match(editors[1].text,/src\/a\.js/); |
| 65 | }); |
| 66 | |
| 67 | test('ready view lists every changed file in the sealed change set', async()=>{ |
| 68 | const workspaces={async getWorkspace(){return structuredClone(ws)},async sealIntent({intent}){return {id:'INTENT01',...intent}}}; |
| 69 | const c=createWorkspaceController({github:{},workspaces}); |
| 70 | const v=await c.resolveCallback('wready:W000000001',{ownerId:'42'}).execute(); |
| 71 | assert.match(v.text,/README\.md/); |
| 72 | assert.match(v.text,/src\/a\.js/); |
| 73 | assert.match(v.text,/2/); |
| 74 | }); |