182 const repoList = document.getElementById('repoList');
183 const ignoredPatternsTextarea = document.getElementById('ignoredPatterns');
184 async function updateRepoList() {
185 const repos = await db.repositories.toArray();
186 repoList.innerHTML = repos.map(repo =>
211 });
212
213 function displayRepoData(repo) {
214 resultArea.value = repo.content;
215 updateStats(repo.content);
217 }
218
219 function updateStats(content) {
220 const bytes = new TextEncoder().encode(content).length;
221 const kb = bytes / 1024;
227 }
228
229 function updateTokenCounts(tokenCounts) {
230 tokenCountCl100k.textContent = tokenCounts.cl100k_base.toLocaleString();
231 tokenCountP50k.textContent = tokenCounts.p50k_base.toLocaleString();
234 }
235
236 // Add this new function to parse the patterns
237 function parseIgnoredPatterns() {
238 return ignoredPatternsTextarea.value
239 .split('\\n')
243
244
245 async function fetchFileTypes(repoUrl) {
246 const response = await fetch('/file-types', {
247 method: 'POST',
257 }
258
259 function displayFileTypeSelector(fileTypes, ignoredPatterns) {
260 const fileTypeSelectorDiv = document.getElementById('fileTypeSelector');
261 const fileTypeList = document.getElementById('fileTypeList');
528});
529
530function getTiktokenSegments(encoder, inputText) {
531 try {
532 const tokens = encoder.encode(inputText);
566}
567
568function getFileExtension(filename) {
569 const parts = filename.split('.');
570 return parts.length > 1 ? '.' + parts.pop().toLowerCase() : 'no-extension';
572
573
574function getFileType(path) {
575 // Handle directories
576 if (path.endsWith('/')) {
587}
588
589async function fetchRepositoryContent(owner, repo, specifiedBranch = null, ignoredPatterns, selectedTypes = null) {
590 // First, try to get the default branch or use the specified branch
591 const repoInfoUrl = `https://api.github.com/repos/${owner}/${repo}`;
661}
662
663async function fetchFileContent(owner, repo, path, branch) {
664 const apiUrl = `https://api.github.com/repos/${owner}/${repo}/contents/${path}`;
665 const response = await fetch(apiUrl, {
678}
679
680function getIgnoredPatterns() {
681 return [
682 // Folders
754}
755
756function shouldIgnoreFile(path, ignoredPatterns) {
757 // Special case for README.md
758 if (path.toLowerCase() === 'readme.md') {
763}
764
765async function countTokens(text) {
766 const encoders = {
767 cl100k_base: get_encoding("cl100k_base"),
780}
781
782async function getTokenizedText(text) {
783 const encoder = get_encoding("cl100k_base");
784 const tokens = encoder.encode(text);
819});
820
821// Add new function to get repository file types
822async function getRepositoryFileTypes(owner, repo, specifiedBranch = null) {
823 const repoInfoUrl = `https://api.github.com/repos/${owner}/${repo}`;
824 const repoInfoResponse = await fetch(repoInfoUrl, {