Personal Telegram developer console for GitHub
fix/phase2-final-ux
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 | |
| 4 | let policy = {}; |
| 5 | try { |
| 6 | policy = await import('../src/core/workspace-policy.js'); |
| 7 | } catch { |
| 8 | policy = {}; |
| 9 | } |
| 10 | |
| 11 | const requireFn = name => { |
| 12 | assert.equal(typeof policy[name], 'function', `${name} must be implemented`); |
| 13 | return policy[name]; |
| 14 | }; |
| 15 | |
| 16 | test('editable file policy accepts bounded UTF-8 text', () => { |
| 17 | const validateEditableFile = requireFn('validateEditableFile'); |
| 18 | const result = validateEditableFile({ path: 'src/app.js', text: 'export const ok = true;\n' }); |
| 19 | assert.deepEqual(result, { |
| 20 | editable: true, |
| 21 | reason: '', |
| 22 | text: 'export const ok = true;\n', |
| 23 | charLength: 24, |
| 24 | byteLength: 24 |
| 25 | }); |
| 26 | }); |
| 27 | |
| 28 | test('editable file policy rejects sensitive paths binary markers LFS and both size ceilings', () => { |
| 29 | const validateEditableFile = requireFn('validateEditableFile'); |
| 30 | for (const path of ['.env', '.env.production', 'keys/id_rsa', 'id_ed25519', 'tls/cert.pem', 'tls/private.key', 'a.p12', 'a.pfx', 'credentials.json', 'service-account-prod.json']) { |
| 31 | const result = validateEditableFile({ path, text: 'safe-looking text' }); |
| 32 | assert.equal(result.editable, false, path); |
| 33 | assert.match(result.reason, /sensitive/i); |
| 34 | } |
| 35 | |
| 36 | const binary = validateEditableFile({ path: 'data.txt', text: 'abc\0def' }); |
| 37 | assert.equal(binary.editable, false); |
| 38 | assert.match(binary.reason, /binary/i); |
| 39 | |
| 40 | const lfs = validateEditableFile({ path: 'asset.txt', text: 'version https://git-lfs.github.com/spec/v1\noid sha256:abc\nsize 123\n' }); |
| 41 | assert.equal(lfs.editable, false); |
| 42 | assert.match(lfs.reason, /LFS/i); |
| 43 | |
| 44 | const tooManyChars = validateEditableFile({ path: 'large.txt', text: 'a'.repeat(20001) }); |
| 45 | assert.equal(tooManyChars.editable, false); |
| 46 | assert.match(tooManyChars.reason, /20,000|20000/); |
| 47 | |
| 48 | const explicitTooManyBytes = validateEditableFile({ path: 'large.txt', text: 'ok', byteLength: 65537 }); |
| 49 | assert.equal(explicitTooManyBytes.editable, false); |
| 50 | assert.match(explicitTooManyBytes.reason, /65,536|65536/); |
| 51 | }); |
| 52 | |
| 53 | test('editable file policy enforces multibyte UTF-8 byte boundary independently from character boundary', () => { |
| 54 | const validateEditableFile = requireFn('validateEditableFile'); |
| 55 | const exact = '😀'.repeat(16384); |
| 56 | const exactResult = validateEditableFile({ path: 'emoji.txt', text: exact }); |
| 57 | assert.equal(exactResult.charLength, 16384); |
| 58 | assert.equal(exactResult.byteLength, 65536); |
| 59 | assert.equal(exactResult.editable, true); |
| 60 | |
| 61 | const over = `${exact}a`; |
| 62 | const overResult = validateEditableFile({ path: 'emoji.txt', text: over }); |
| 63 | assert.equal(overResult.charLength, 16385); |
| 64 | assert.equal(overResult.byteLength, 65537); |
| 65 | assert.equal(overResult.editable, false); |
| 66 | assert.match(overResult.reason, /65,536|65536/); |
| 67 | }); |
| 68 | |
| 69 | test('commit message and target branch normalization fail closed on empty or unsafe values', () => { |
| 70 | const normalizeCommitMessage = requireFn('normalizeCommitMessage'); |
| 71 | const makeTargetBranch = requireFn('makeTargetBranch'); |
| 72 | |
| 73 | assert.equal(normalizeCommitMessage(' test: verify mobile editor '), 'test: verify mobile editor'); |
| 74 | assert.throws(() => normalizeCommitMessage(' '), /commit message/i); |
| 75 | assert.throws(() => normalizeCommitMessage('x'.repeat(121)), /120/); |
| 76 | |
| 77 | assert.equal(makeTargetBranch('Ab3_-xYz09'), 'nexa/edit-Ab3_-xYz09'); |
| 78 | assert.throws(() => makeTargetBranch('../bad'), /workspace/i); |
| 79 | assert.throws(() => makeTargetBranch('short'), /workspace/i); |
| 80 | }); |
| 81 | |
| 82 | test('unified diff reports exact additions deletions and marks bounded truncation without changing counts', () => { |
| 83 | const buildUnifiedDiff = requireFn('buildUnifiedDiff'); |
| 84 | const before = 'alpha\nbeta\ngamma\n'; |
| 85 | const after = 'alpha\nBETA\ngamma\ndelta\n'; |
| 86 | const full = buildUnifiedDiff({ path: 'src/app.js', before, after, maxChars: 2600 }); |
| 87 | assert.equal(full.additions, 2); |
| 88 | assert.equal(full.deletions, 1); |
| 89 | assert.equal(full.truncated, false); |
| 90 | assert.match(full.text, /--- a\/src\/app\.js/); |
| 91 | assert.match(full.text, /\+\+\+ b\/src\/app\.js/); |
| 92 | assert.match(full.text, /-beta/); |
| 93 | assert.match(full.text, /\+BETA/); |
| 94 | assert.match(full.text, /\+delta/); |
| 95 | |
| 96 | const bounded = buildUnifiedDiff({ |
| 97 | path: 'src/app.js', |
| 98 | before: Array.from({ length: 250 }, (_, i) => `old-${i}`).join('\n'), |
| 99 | after: Array.from({ length: 250 }, (_, i) => `new-${i}`).join('\n'), |
| 100 | maxChars: 120 |
| 101 | }); |
| 102 | assert.equal(bounded.additions, 250); |
| 103 | assert.equal(bounded.deletions, 250); |
| 104 | assert.equal(bounded.truncated, true); |
| 105 | assert.ok(bounded.text.length <= 120); |
| 106 | }); |
| 107 | |
| 108 | test('digestText is stable for identical content and changes with content', async () => { |
| 109 | const digestText = requireFn('digestText'); |
| 110 | const first = await digestText('hello'); |
| 111 | const second = await digestText('hello'); |
| 112 | const changed = await digestText('hello!'); |
| 113 | assert.match(first, /^[a-f0-9]{64}$/); |
| 114 | assert.equal(first, second); |
| 115 | assert.notEqual(first, changed); |
| 116 | }); |