@framers/agentos-ext-github 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +96 -21
- package/dist/GitHubRepoIndexer.d.ts +88 -0
- package/dist/GitHubRepoIndexer.d.ts.map +1 -0
- package/dist/GitHubRepoIndexer.js +252 -0
- package/dist/GitHubRepoIndexer.js.map +1 -0
- package/dist/GitHubService.d.ts +58 -1
- package/dist/GitHubService.d.ts.map +1 -1
- package/dist/GitHubService.js +83 -1
- package/dist/GitHubService.js.map +1 -1
- package/dist/__tests__/fileAndBranchTools.test.d.ts +6 -0
- package/dist/__tests__/fileAndBranchTools.test.d.ts.map +1 -0
- package/dist/__tests__/fileAndBranchTools.test.js +310 -0
- package/dist/__tests__/fileAndBranchTools.test.js.map +1 -0
- package/dist/__tests__/indexer.test.d.ts +6 -0
- package/dist/__tests__/indexer.test.d.ts.map +1 -0
- package/dist/__tests__/indexer.test.js +239 -0
- package/dist/__tests__/indexer.test.js.map +1 -0
- package/dist/__tests__/issueTools.test.d.ts +5 -0
- package/dist/__tests__/issueTools.test.d.ts.map +1 -0
- package/dist/__tests__/issueTools.test.js +183 -0
- package/dist/__tests__/issueTools.test.js.map +1 -0
- package/dist/__tests__/prTools.test.d.ts +5 -0
- package/dist/__tests__/prTools.test.d.ts.map +1 -0
- package/dist/__tests__/prTools.test.js +318 -0
- package/dist/__tests__/prTools.test.js.map +1 -0
- package/dist/__tests__/releaseAndActionsTools.test.d.ts +6 -0
- package/dist/__tests__/releaseAndActionsTools.test.d.ts.map +1 -0
- package/dist/__tests__/releaseAndActionsTools.test.js +315 -0
- package/dist/__tests__/releaseAndActionsTools.test.js.map +1 -0
- package/dist/__tests__/repoTools.test.d.ts +6 -0
- package/dist/__tests__/repoTools.test.d.ts.map +1 -0
- package/dist/__tests__/repoTools.test.js +308 -0
- package/dist/__tests__/repoTools.test.js.map +1 -0
- package/dist/__tests__/service.test.d.ts +6 -0
- package/dist/__tests__/service.test.d.ts.map +1 -0
- package/dist/__tests__/service.test.js +173 -0
- package/dist/__tests__/service.test.js.map +1 -0
- package/dist/index.d.ts +41 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +60 -1
- package/dist/index.js.map +1 -1
- package/dist/tools/actionsList.d.ts +48 -0
- package/dist/tools/actionsList.d.ts.map +1 -0
- package/dist/tools/actionsList.js +71 -0
- package/dist/tools/actionsList.js.map +1 -0
- package/dist/tools/actionsTrigger.d.ts +56 -0
- package/dist/tools/actionsTrigger.d.ts.map +1 -0
- package/dist/tools/actionsTrigger.js +62 -0
- package/dist/tools/actionsTrigger.js.map +1 -0
- package/dist/tools/branchCreate.d.ts +47 -0
- package/dist/tools/branchCreate.d.ts.map +1 -0
- package/dist/tools/branchCreate.js +68 -0
- package/dist/tools/branchCreate.js.map +1 -0
- package/dist/tools/branchList.d.ts +45 -0
- package/dist/tools/branchList.d.ts.map +1 -0
- package/dist/tools/branchList.js +47 -0
- package/dist/tools/branchList.js.map +1 -0
- package/dist/tools/commentList.d.ts +48 -0
- package/dist/tools/commentList.d.ts.map +1 -0
- package/dist/tools/commentList.js +52 -0
- package/dist/tools/commentList.js.map +1 -0
- package/dist/tools/commitList.d.ts +65 -0
- package/dist/tools/commitList.d.ts.map +1 -0
- package/dist/tools/commitList.js +58 -0
- package/dist/tools/commitList.js.map +1 -0
- package/dist/tools/fileRead.d.ts.map +1 -1
- package/dist/tools/fileRead.js +1 -0
- package/dist/tools/fileRead.js.map +1 -1
- package/dist/tools/fileWrite.d.ts +61 -0
- package/dist/tools/fileWrite.d.ts.map +1 -0
- package/dist/tools/fileWrite.js +56 -0
- package/dist/tools/fileWrite.js.map +1 -0
- package/dist/tools/gistCreate.d.ts.map +1 -1
- package/dist/tools/gistCreate.js +1 -0
- package/dist/tools/gistCreate.js.map +1 -1
- package/dist/tools/issueCreate.d.ts.map +1 -1
- package/dist/tools/issueCreate.js +1 -0
- package/dist/tools/issueCreate.js.map +1 -1
- package/dist/tools/issueList.d.ts.map +1 -1
- package/dist/tools/issueList.js +1 -0
- package/dist/tools/issueList.js.map +1 -1
- package/dist/tools/issueUpdate.d.ts +75 -0
- package/dist/tools/issueUpdate.d.ts.map +1 -0
- package/dist/tools/issueUpdate.js +80 -0
- package/dist/tools/issueUpdate.js.map +1 -0
- package/dist/tools/prCommentCreate.d.ts +48 -0
- package/dist/tools/prCommentCreate.d.ts.map +1 -0
- package/dist/tools/prCommentCreate.js +50 -0
- package/dist/tools/prCommentCreate.js.map +1 -0
- package/dist/tools/prCommentList.d.ts +48 -0
- package/dist/tools/prCommentList.d.ts.map +1 -0
- package/dist/tools/prCommentList.js +53 -0
- package/dist/tools/prCommentList.js.map +1 -0
- package/dist/tools/prCreate.d.ts.map +1 -1
- package/dist/tools/prCreate.js +1 -0
- package/dist/tools/prCreate.js.map +1 -1
- package/dist/tools/prDiff.d.ts +48 -0
- package/dist/tools/prDiff.d.ts.map +1 -0
- package/dist/tools/prDiff.js +75 -0
- package/dist/tools/prDiff.js.map +1 -0
- package/dist/tools/prList.d.ts.map +1 -1
- package/dist/tools/prList.js +1 -0
- package/dist/tools/prList.js.map +1 -1
- package/dist/tools/prMerge.d.ts +59 -0
- package/dist/tools/prMerge.d.ts.map +1 -0
- package/dist/tools/prMerge.js +58 -0
- package/dist/tools/prMerge.js.map +1 -0
- package/dist/tools/prReview.d.ts +81 -0
- package/dist/tools/prReview.d.ts.map +1 -0
- package/dist/tools/prReview.js +70 -0
- package/dist/tools/prReview.js.map +1 -0
- package/dist/tools/releaseCreate.d.ts +73 -0
- package/dist/tools/releaseCreate.d.ts.map +1 -0
- package/dist/tools/releaseCreate.js +69 -0
- package/dist/tools/releaseCreate.js.map +1 -0
- package/dist/tools/releaseList.d.ts +42 -0
- package/dist/tools/releaseList.d.ts.map +1 -0
- package/dist/tools/releaseList.js +50 -0
- package/dist/tools/releaseList.js.map +1 -0
- package/dist/tools/repoCreate.d.ts +55 -0
- package/dist/tools/repoCreate.d.ts.map +1 -0
- package/dist/tools/repoCreate.js +54 -0
- package/dist/tools/repoCreate.js.map +1 -0
- package/dist/tools/repoIndex.d.ts +47 -0
- package/dist/tools/repoIndex.d.ts.map +1 -0
- package/dist/tools/repoIndex.js +127 -0
- package/dist/tools/repoIndex.js.map +1 -0
- package/dist/tools/repoInfo.d.ts +35 -0
- package/dist/tools/repoInfo.d.ts.map +1 -0
- package/dist/tools/repoInfo.js +60 -0
- package/dist/tools/repoInfo.js.map +1 -0
- package/dist/tools/repoList.d.ts +47 -0
- package/dist/tools/repoList.d.ts.map +1 -0
- package/dist/tools/repoList.js +74 -0
- package/dist/tools/repoList.js.map +1 -0
- package/dist/tools/search.d.ts.map +1 -1
- package/dist/tools/search.js +1 -0
- package/dist/tools/search.js.map +1 -1
- package/manifest.json +30 -6
- package/package.json +10 -6
package/LICENSE
CHANGED
|
@@ -1,23 +1,98 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
10
|
+
|
|
11
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
12
|
+
|
|
13
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
14
|
+
|
|
15
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
16
|
+
|
|
17
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
18
|
+
|
|
19
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
20
|
+
|
|
21
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
22
|
+
|
|
23
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
24
|
+
|
|
25
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
26
|
+
|
|
27
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
28
|
+
|
|
29
|
+
2. Grant of Copyright License.
|
|
30
|
+
|
|
31
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
32
|
+
|
|
33
|
+
3. Grant of Patent License.
|
|
34
|
+
|
|
35
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
36
|
+
|
|
37
|
+
4. Redistribution.
|
|
38
|
+
|
|
39
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
40
|
+
|
|
41
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
42
|
+
|
|
43
|
+
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
44
|
+
|
|
45
|
+
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
46
|
+
|
|
47
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
48
|
+
|
|
49
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
50
|
+
|
|
51
|
+
5. Submission of Contributions.
|
|
52
|
+
|
|
53
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
54
|
+
|
|
55
|
+
6. Trademarks.
|
|
56
|
+
|
|
57
|
+
This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
58
|
+
|
|
59
|
+
7. Disclaimer of Warranty.
|
|
60
|
+
|
|
61
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
62
|
+
|
|
63
|
+
8. Limitation of Liability.
|
|
64
|
+
|
|
65
|
+
In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
66
|
+
|
|
67
|
+
9. Accepting Warranty or Additional Liability.
|
|
68
|
+
|
|
69
|
+
While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
70
|
+
|
|
71
|
+
END OF TERMS AND CONDITIONS
|
|
72
|
+
|
|
73
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
74
|
+
|
|
75
|
+
To apply the Apache License to your work, attach the following
|
|
76
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
77
|
+
replaced with your own identifying information. (Don't include
|
|
78
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
79
|
+
comment syntax for the file format. We also recommend that a
|
|
80
|
+
file or class name and description of purpose be included on the
|
|
81
|
+
same "printed page" as the copyright notice for easier
|
|
82
|
+
identification within third-party archives.
|
|
83
|
+
|
|
84
|
+
Copyright (c) 2025 Framers
|
|
85
|
+
|
|
86
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
87
|
+
you may not use this file except in compliance with the License.
|
|
88
|
+
You may obtain a copy of the License at
|
|
89
|
+
|
|
90
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
91
|
+
|
|
92
|
+
Unless required by applicable law or agreed to in writing, software
|
|
93
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
94
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
95
|
+
See the License for the specific language governing permissions and
|
|
96
|
+
limitations under the License.
|
|
22
97
|
|
|
23
98
|
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Background codebase indexer that produces chunks from GitHub repos
|
|
3
|
+
* for RAG embedding. Walks repo trees, extracts documentation files, splits them
|
|
4
|
+
* by markdown headings, and returns structured IndexedChunk arrays suitable for
|
|
5
|
+
* vector-store ingestion.
|
|
6
|
+
*/
|
|
7
|
+
import type { GitHubService } from './GitHubService.js';
|
|
8
|
+
/** A single indexable text chunk extracted from a GitHub repository. */
|
|
9
|
+
export interface IndexedChunk {
|
|
10
|
+
/** Human-readable heading identifying this chunk (e.g. `github:owner/repo:metadata`). */
|
|
11
|
+
heading: string;
|
|
12
|
+
/** The chunk text content, ready for embedding. */
|
|
13
|
+
content: string;
|
|
14
|
+
/** Source path within the repo (or a virtual path like `:metadata`). */
|
|
15
|
+
sourcePath: string;
|
|
16
|
+
}
|
|
17
|
+
/** Summary result returned after indexing a single repository. */
|
|
18
|
+
export interface IndexResult {
|
|
19
|
+
/** Full `owner/repo` slug. */
|
|
20
|
+
repo: string;
|
|
21
|
+
/** All chunks extracted from the repository. */
|
|
22
|
+
chunks: IndexedChunk[];
|
|
23
|
+
/** Number of individual files whose content was fetched. */
|
|
24
|
+
filesScanned: number;
|
|
25
|
+
/** Total number of entries in the repo tree (before filtering). */
|
|
26
|
+
treeSize: number;
|
|
27
|
+
/** Wall-clock duration of the indexing run in milliseconds. */
|
|
28
|
+
durationMs: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Default ecosystem repos to index when `indexEcosystem()` is called
|
|
32
|
+
* without arguments.
|
|
33
|
+
*/
|
|
34
|
+
export declare const ECOSYSTEM_REPOS: readonly {
|
|
35
|
+
owner: string;
|
|
36
|
+
repo: string;
|
|
37
|
+
}[];
|
|
38
|
+
/**
|
|
39
|
+
* Directories to skip when walking the repo tree.
|
|
40
|
+
* These are typically build artifacts, caches, or vendored dependencies.
|
|
41
|
+
*/
|
|
42
|
+
export declare const SKIP_DIRS: ReadonlySet<string>;
|
|
43
|
+
/**
|
|
44
|
+
* Regex matching file paths that should be treated as indexable documentation.
|
|
45
|
+
* Matches README.md, CONTRIBUTING.md, CHANGELOG.md, any .md file under docs/,
|
|
46
|
+
* and any nested README.md.
|
|
47
|
+
*/
|
|
48
|
+
export declare const DOC_PATTERN: RegExp;
|
|
49
|
+
/**
|
|
50
|
+
* Indexes GitHub repositories into structured text chunks for RAG embedding.
|
|
51
|
+
*
|
|
52
|
+
* The indexer produces four kinds of chunks per repo:
|
|
53
|
+
* 1. **Metadata** — repo description, stars, language, topics, etc.
|
|
54
|
+
* 2. **Directory tree** — filtered file listing (skipping SKIP_DIRS).
|
|
55
|
+
* 3. **Documentation chunks** — README, CONTRIBUTING, CHANGELOG, docs/*.md
|
|
56
|
+
* split by h1-h3 headings.
|
|
57
|
+
* 4. **package.json** — name, version, description, dependencies, scripts.
|
|
58
|
+
*/
|
|
59
|
+
export declare class GitHubRepoIndexer {
|
|
60
|
+
private readonly service;
|
|
61
|
+
constructor(service: GitHubService);
|
|
62
|
+
/**
|
|
63
|
+
* Index all six default ecosystem repos.
|
|
64
|
+
* Errors on individual repos are caught so one failure doesn't abort the batch.
|
|
65
|
+
*
|
|
66
|
+
* @returns An IndexResult for every repo (failed repos have zero chunks).
|
|
67
|
+
*/
|
|
68
|
+
indexEcosystem(): Promise<IndexResult[]>;
|
|
69
|
+
/**
|
|
70
|
+
* Index a single GitHub repository.
|
|
71
|
+
*
|
|
72
|
+
* @param owner - Repository owner (user or org).
|
|
73
|
+
* @param repo - Repository name.
|
|
74
|
+
* @param branch - Optional branch/tag/SHA (defaults to the repo's default branch).
|
|
75
|
+
* @returns An IndexResult containing all extracted chunks.
|
|
76
|
+
*/
|
|
77
|
+
indexRepo(owner: string, repo: string, branch?: string): Promise<IndexResult>;
|
|
78
|
+
/**
|
|
79
|
+
* Split markdown content by h1-h3 headings (`#`, `##`, `###`).
|
|
80
|
+
* Each returned string includes the heading line that starts it.
|
|
81
|
+
* Content before the first heading (if any) is returned as the first element.
|
|
82
|
+
*
|
|
83
|
+
* @param content - Raw markdown text.
|
|
84
|
+
* @returns Array of sections, each starting at a heading boundary.
|
|
85
|
+
*/
|
|
86
|
+
splitByHeadings(content: string): string[];
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=GitHubRepoIndexer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitHubRepoIndexer.d.ts","sourceRoot":"","sources":["../src/GitH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0,0 +1,252 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Background codebase indexer that produces chunks from GitHub repos
|
|
4
|
+
* for RAG embedding. Walks repo trees, extracts documentation files, splits them
|
|
5
|
+
* by markdown headings, and returns structured IndexedChunk arrays suitable for
|
|
6
|
+
* vector-store ingestion.
|
|
7
|
+
*/
|
|
8
|
+
/* ------------------------------------------------------------------ */
|
|
9
|
+
/* Constants */
|
|
10
|
+
/* ------------------------------------------------------------------ */
|
|
11
|
+
/**
|
|
12
|
+
* Default ecosystem repos to index when `indexEcosystem()` is called
|
|
13
|
+
* without arguments.
|
|
14
|
+
*/
|
|
15
|
+
export const ECOSYSTEM_REPOS = [
|
|
16
|
+
{ owner: 'framerslab', repo: 'agentos' },
|
|
17
|
+
{ owner: 'jddunn', repo: 'wunderland' },
|
|
18
|
+
{ owner: 'framerslab', repo: 'agentos-live-docs' },
|
|
19
|
+
{ owner: 'jddunn', repo: 'wunderland-live-docs' },
|
|
20
|
+
{ owner: 'framerslab', repo: 'agentos-skills-registry' },
|
|
21
|
+
{ owner: 'framerslab', repo: 'agentos-extensions' },
|
|
22
|
+
];
|
|
23
|
+
/**
|
|
24
|
+
* Directories to skip when walking the repo tree.
|
|
25
|
+
* These are typically build artifacts, caches, or vendored dependencies.
|
|
26
|
+
*/
|
|
27
|
+
export const SKIP_DIRS = new Set([
|
|
28
|
+
'node_modules',
|
|
29
|
+
'dist',
|
|
30
|
+
'build',
|
|
31
|
+
'.git',
|
|
32
|
+
'.next',
|
|
33
|
+
'coverage',
|
|
34
|
+
'__pycache__',
|
|
35
|
+
'.turbo',
|
|
36
|
+
]);
|
|
37
|
+
/**
|
|
38
|
+
* Regex matching file paths that should be treated as indexable documentation.
|
|
39
|
+
* Matches README.md, CONTRIBUTING.md, CHANGELOG.md, any .md file under docs/,
|
|
40
|
+
* and any nested README.md.
|
|
41
|
+
*/
|
|
42
|
+
export const DOC_PATTERN = /(?:^|\/)(?:README\.md|CONTRIBUTING\.md|CHANGELOG\.md)$|(?:^|\/)docs\/[^/]+\.md$|(?:^\/?)[\w.-]+\/README\.md$/i;
|
|
43
|
+
/* ------------------------------------------------------------------ */
|
|
44
|
+
/* Limits */
|
|
45
|
+
/* ------------------------------------------------------------------ */
|
|
46
|
+
/** Maximum number of doc files to fetch per repo. */
|
|
47
|
+
const MAX_DOC_FILES = 20;
|
|
48
|
+
/** Maximum number of heading-delimited sections to keep per doc file. */
|
|
49
|
+
const MAX_SECTIONS_PER_FILE = 5;
|
|
50
|
+
/** Maximum character length for any single chunk's content. */
|
|
51
|
+
const MAX_CHUNK_CHARS = 6_000;
|
|
52
|
+
/* ------------------------------------------------------------------ */
|
|
53
|
+
/* GitHubRepoIndexer */
|
|
54
|
+
/* ------------------------------------------------------------------ */
|
|
55
|
+
/**
|
|
56
|
+
* Indexes GitHub repositories into structured text chunks for RAG embedding.
|
|
57
|
+
*
|
|
58
|
+
* The indexer produces four kinds of chunks per repo:
|
|
59
|
+
* 1. **Metadata** — repo description, stars, language, topics, etc.
|
|
60
|
+
* 2. **Directory tree** — filtered file listing (skipping SKIP_DIRS).
|
|
61
|
+
* 3. **Documentation chunks** — README, CONTRIBUTING, CHANGELOG, docs/*.md
|
|
62
|
+
* split by h1-h3 headings.
|
|
63
|
+
* 4. **package.json** — name, version, description, dependencies, scripts.
|
|
64
|
+
*/
|
|
65
|
+
export class GitHubRepoIndexer {
|
|
66
|
+
service;
|
|
67
|
+
constructor(service) {
|
|
68
|
+
this.service = service;
|
|
69
|
+
}
|
|
70
|
+
/* ---------------------------------------------------------------- */
|
|
71
|
+
/* Public API */
|
|
72
|
+
/* ---------------------------------------------------------------- */
|
|
73
|
+
/**
|
|
74
|
+
* Index all six default ecosystem repos.
|
|
75
|
+
* Errors on individual repos are caught so one failure doesn't abort the batch.
|
|
76
|
+
*
|
|
77
|
+
* @returns An IndexResult for every repo (failed repos have zero chunks).
|
|
78
|
+
*/
|
|
79
|
+
async indexEcosystem() {
|
|
80
|
+
const results = [];
|
|
81
|
+
for (const { owner, repo } of ECOSYSTEM_REPOS) {
|
|
82
|
+
try {
|
|
83
|
+
const result = await this.indexRepo(owner, repo);
|
|
84
|
+
results.push(result);
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
results.push({
|
|
88
|
+
repo: `${owner}/${repo}`,
|
|
89
|
+
chunks: [],
|
|
90
|
+
filesScanned: 0,
|
|
91
|
+
treeSize: 0,
|
|
92
|
+
durationMs: 0,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return results;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Index a single GitHub repository.
|
|
100
|
+
*
|
|
101
|
+
* @param owner - Repository owner (user or org).
|
|
102
|
+
* @param repo - Repository name.
|
|
103
|
+
* @param branch - Optional branch/tag/SHA (defaults to the repo's default branch).
|
|
104
|
+
* @returns An IndexResult containing all extracted chunks.
|
|
105
|
+
*/
|
|
106
|
+
async indexRepo(owner, repo, branch) {
|
|
107
|
+
const t0 = Date.now();
|
|
108
|
+
const slug = `${owner}/${repo}`;
|
|
109
|
+
const chunks = [];
|
|
110
|
+
let filesScanned = 0;
|
|
111
|
+
const octokit = this.service.getOctokit();
|
|
112
|
+
/* 1 — Metadata chunk ------------------------------------------- */
|
|
113
|
+
const { data: meta } = await octokit.rest.repos.get({ owner, repo });
|
|
114
|
+
const metaLines = [
|
|
115
|
+
`Repository: ${meta.full_name}`,
|
|
116
|
+
meta.description ? `Description: ${meta.description}` : '',
|
|
117
|
+
`Language: ${meta.language ?? 'N/A'}`,
|
|
118
|
+
`Stars: ${meta.stargazers_count} Forks: ${meta.forks_count}`,
|
|
119
|
+
`Default branch: ${meta.default_branch}`,
|
|
120
|
+
`License: ${meta.license?.spdx_id ?? 'N/A'}`,
|
|
121
|
+
meta.topics && meta.topics.length > 0 ? `Topics: ${meta.topics.join(', ')}` : '',
|
|
122
|
+
`URL: ${meta.html_url}`,
|
|
123
|
+
].filter(Boolean);
|
|
124
|
+
chunks.push({
|
|
125
|
+
heading: `github:${slug}:metadata`,
|
|
126
|
+
content: metaLines.join('\n'),
|
|
127
|
+
sourcePath: ':metadata',
|
|
128
|
+
});
|
|
129
|
+
/* Determine ref to use for tree/file fetches -------------------- */
|
|
130
|
+
const ref = branch ?? meta.default_branch;
|
|
131
|
+
/* 2 — Directory tree chunk -------------------------------------- */
|
|
132
|
+
const { data: treeData } = await octokit.rest.git.getTree({
|
|
133
|
+
owner,
|
|
134
|
+
repo,
|
|
135
|
+
tree_sha: ref,
|
|
136
|
+
recursive: 'true',
|
|
137
|
+
});
|
|
138
|
+
const treeEntries = treeData.tree;
|
|
139
|
+
const treeSize = treeEntries.length;
|
|
140
|
+
const filteredPaths = treeEntries
|
|
141
|
+
.filter((entry) => {
|
|
142
|
+
const parts = (entry.path ?? '').split('/');
|
|
143
|
+
return !parts.some((part) => SKIP_DIRS.has(part));
|
|
144
|
+
})
|
|
145
|
+
.map((entry) => entry.path ?? '');
|
|
146
|
+
const treeListing = filteredPaths.join('\n').slice(0, MAX_CHUNK_CHARS);
|
|
147
|
+
chunks.push({
|
|
148
|
+
heading: `github:${slug}:tree`,
|
|
149
|
+
content: treeListing,
|
|
150
|
+
sourcePath: ':tree',
|
|
151
|
+
});
|
|
152
|
+
/* 3 — Documentation file chunks --------------------------------- */
|
|
153
|
+
const docPaths = filteredPaths
|
|
154
|
+
.filter((p) => DOC_PATTERN.test(p))
|
|
155
|
+
.slice(0, MAX_DOC_FILES);
|
|
156
|
+
for (const docPath of docPaths) {
|
|
157
|
+
try {
|
|
158
|
+
const { data: fileData } = await octokit.rest.repos.getContent({
|
|
159
|
+
owner,
|
|
160
|
+
repo,
|
|
161
|
+
path: docPath,
|
|
162
|
+
ref,
|
|
163
|
+
});
|
|
164
|
+
if (Array.isArray(fileData) || fileData.type !== 'file' || !('content' in fileData)) {
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
const content = Buffer.from(fileData.content, 'base64').toString('utf8');
|
|
168
|
+
filesScanned++;
|
|
169
|
+
const sections = this.splitByHeadings(content).slice(0, MAX_SECTIONS_PER_FILE);
|
|
170
|
+
for (const section of sections) {
|
|
171
|
+
chunks.push({
|
|
172
|
+
heading: `github:${slug}:${docPath}`,
|
|
173
|
+
content: section.slice(0, MAX_CHUNK_CHARS),
|
|
174
|
+
sourcePath: docPath,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
// File may have been deleted or is inaccessible — skip silently.
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/* 4 — package.json chunk ---------------------------------------- */
|
|
183
|
+
try {
|
|
184
|
+
const { data: pkgData } = await octokit.rest.repos.getContent({
|
|
185
|
+
owner,
|
|
186
|
+
repo,
|
|
187
|
+
path: 'package.json',
|
|
188
|
+
ref,
|
|
189
|
+
});
|
|
190
|
+
if (!Array.isArray(pkgData) && pkgData.type === 'file' && 'content' in pkgData) {
|
|
191
|
+
const raw = Buffer.from(pkgData.content, 'base64').toString('utf8');
|
|
192
|
+
filesScanned++;
|
|
193
|
+
const pkg = JSON.parse(raw);
|
|
194
|
+
const pkgLines = [
|
|
195
|
+
pkg.name ? `name: ${pkg.name}` : '',
|
|
196
|
+
pkg.version ? `version: ${pkg.version}` : '',
|
|
197
|
+
pkg.description ? `description: ${pkg.description}` : '',
|
|
198
|
+
pkg.dependencies
|
|
199
|
+
? `dependencies: ${Object.keys(pkg.dependencies).join(', ')}`
|
|
200
|
+
: '',
|
|
201
|
+
pkg.scripts
|
|
202
|
+
? `scripts: ${Object.keys(pkg.scripts).join(', ')}`
|
|
203
|
+
: '',
|
|
204
|
+
].filter(Boolean);
|
|
205
|
+
chunks.push({
|
|
206
|
+
heading: `github:${slug}:package.json`,
|
|
207
|
+
content: pkgLines.join('\n').slice(0, MAX_CHUNK_CHARS),
|
|
208
|
+
sourcePath: 'package.json',
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
catch {
|
|
213
|
+
// No package.json in repo — that's fine.
|
|
214
|
+
}
|
|
215
|
+
return {
|
|
216
|
+
repo: slug,
|
|
217
|
+
chunks,
|
|
218
|
+
filesScanned,
|
|
219
|
+
treeSize,
|
|
220
|
+
durationMs: Date.now() - t0,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
/* ---------------------------------------------------------------- */
|
|
224
|
+
/* Private helpers */
|
|
225
|
+
/* ---------------------------------------------------------------- */
|
|
226
|
+
/**
|
|
227
|
+
* Split markdown content by h1-h3 headings (`#`, `##`, `###`).
|
|
228
|
+
* Each returned string includes the heading line that starts it.
|
|
229
|
+
* Content before the first heading (if any) is returned as the first element.
|
|
230
|
+
*
|
|
231
|
+
* @param content - Raw markdown text.
|
|
232
|
+
* @returns Array of sections, each starting at a heading boundary.
|
|
233
|
+
*/
|
|
234
|
+
splitByHeadings(content) {
|
|
235
|
+
const headingRe = /^#{1,3}\s/m;
|
|
236
|
+
const lines = content.split('\n');
|
|
237
|
+
const sections = [];
|
|
238
|
+
let current = [];
|
|
239
|
+
for (const line of lines) {
|
|
240
|
+
if (headingRe.test(line) && current.length > 0) {
|
|
241
|
+
sections.push(current.join('\n'));
|
|
242
|
+
current = [];
|
|
243
|
+
}
|
|
244
|
+
current.push(line);
|
|
245
|
+
}
|
|
246
|
+
if (current.length > 0) {
|
|
247
|
+
sections.push(current.join('\n'));
|
|
248
|
+
}
|
|
249
|
+
return sections;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
//# sourceMappingURL=GitHubRepoIndexer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitHubRepoIndexer.js","sourceRoot":"","sources":["../src/GitHubRepoIndexer.ts"],"names":[],"mappings":"AAAA,cAAc;AACd;;;;;GAKG;AAgCH,wEAAwE;AACxE,yEAAyE;AACzE,wEAAwE;AAExE;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GA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AI,CAAC,CAAC;QACrB,CAAC;QAED,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACpC,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
|
package/dist/GitHubService.d.ts
CHANGED
|
@@ -1,8 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Octokit wrapper for the GitHub extension.
|
|
3
|
-
* Manages token-based authentication and provides the Octokit client
|
|
3
|
+
* Manages token-based authentication and provides the Octokit client
|
|
4
|
+
* along with convenience methods for common GitHub API operations.
|
|
4
5
|
*/
|
|
5
6
|
import { Octokit } from '@octokit/rest';
|
|
7
|
+
/** A single entry from a Git tree (file, directory, or submodule). */
|
|
8
|
+
export interface TreeEntry {
|
|
9
|
+
path: string;
|
|
10
|
+
type: string;
|
|
11
|
+
size?: number;
|
|
12
|
+
}
|
|
13
|
+
/** Rate-limit snapshot returned by {@link GitHubService.getRateLimit}. */
|
|
14
|
+
export interface RateLimitInfo {
|
|
15
|
+
remaining: number;
|
|
16
|
+
limit: number;
|
|
17
|
+
resetsAt: string;
|
|
18
|
+
}
|
|
19
|
+
/** High-level repository metadata returned by {@link GitHubService.getRepoMetadata}. */
|
|
20
|
+
export interface RepoMetadata {
|
|
21
|
+
name: string;
|
|
22
|
+
fullName: string;
|
|
23
|
+
description: string | null;
|
|
24
|
+
language: string | null;
|
|
25
|
+
stars: number;
|
|
26
|
+
forks: number;
|
|
27
|
+
topics: string[];
|
|
28
|
+
defaultBranch: string;
|
|
29
|
+
visibility: string;
|
|
30
|
+
license: string | null;
|
|
31
|
+
pushedAt: string | null;
|
|
32
|
+
htmlUrl: string;
|
|
33
|
+
}
|
|
6
34
|
export declare class GitHubService {
|
|
7
35
|
private octokit;
|
|
8
36
|
private readonly token;
|
|
@@ -11,5 +39,34 @@ export declare class GitHubService {
|
|
|
11
39
|
initialize(): Promise<void>;
|
|
12
40
|
getOctokit(): Octokit;
|
|
13
41
|
getUsername(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Retrieve the full recursive tree for a repo at a given ref.
|
|
44
|
+
* @param owner - Repository owner (user or org).
|
|
45
|
+
* @param repo - Repository name.
|
|
46
|
+
* @param sha - Branch name, tag, or commit SHA (default: 'HEAD').
|
|
47
|
+
* @returns Flat array of tree entries with path, type, and optional size.
|
|
48
|
+
*/
|
|
49
|
+
getRepoTree(owner: string, repo: string, sha?: string): Promise<TreeEntry[]>;
|
|
50
|
+
/**
|
|
51
|
+
* Read and decode a single file from a repository.
|
|
52
|
+
* @param owner - Repository owner.
|
|
53
|
+
* @param repo - Repository name.
|
|
54
|
+
* @param path - File path within the repo.
|
|
55
|
+
* @param ref - Optional branch, tag, or SHA.
|
|
56
|
+
* @returns Decoded UTF-8 file content as a string.
|
|
57
|
+
*/
|
|
58
|
+
getFileContent(owner: string, repo: string, path: string, ref?: string): Promise<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Return current API rate-limit status for the authenticated token.
|
|
61
|
+
* @returns Object with remaining calls, total limit, and UTC reset timestamp.
|
|
62
|
+
*/
|
|
63
|
+
getRateLimit(): Promise<RateLimitInfo>;
|
|
64
|
+
/**
|
|
65
|
+
* Fetch high-level metadata for a repository.
|
|
66
|
+
* @param owner - Repository owner.
|
|
67
|
+
* @param repo - Repository name.
|
|
68
|
+
* @returns Normalized metadata object.
|
|
69
|
+
*/
|
|
70
|
+
getRepoMetadata(owner: string, repo: string): Promise<RepoMetadata>;
|
|
14
71
|
}
|
|
15
72
|
//# sourceMappingURL=GitHubService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GitHubService.d.ts","sourceRoot":"","sources":["../src/GitHubService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GitHubService.d.ts","sourceRoot":"","sources":["../src/GitHubService.ts"],"names":[],"mappings":"AACA;;;;GAIG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AAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAgB9F;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,aAAa,CAAC;IAW5C;;;;;OAKG;IACG,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;CAkB1E"}
|
package/dist/GitHubService.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
/**
|
|
2
3
|
* @fileoverview Octokit wrapper for the GitHub extension.
|
|
3
|
-
* Manages token-based authentication and provides the Octokit client
|
|
4
|
+
* Manages token-based authentication and provides the Octokit client
|
|
5
|
+
* along with convenience methods for common GitHub API operations.
|
|
4
6
|
*/
|
|
5
7
|
import { Octokit } from '@octokit/rest';
|
|
6
8
|
export class GitHubService {
|
|
@@ -24,5 +26,85 @@ export class GitHubService {
|
|
|
24
26
|
getUsername() {
|
|
25
27
|
return this.username;
|
|
26
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Retrieve the full recursive tree for a repo at a given ref.
|
|
31
|
+
* @param owner - Repository owner (user or org).
|
|
32
|
+
* @param repo - Repository name.
|
|
33
|
+
* @param sha - Branch name, tag, or commit SHA (default: 'HEAD').
|
|
34
|
+
* @returns Flat array of tree entries with path, type, and optional size.
|
|
35
|
+
*/
|
|
36
|
+
async getRepoTree(owner, repo, sha = 'HEAD') {
|
|
37
|
+
const octokit = this.getOctokit();
|
|
38
|
+
const { data } = await octokit.rest.git.getTree({
|
|
39
|
+
owner,
|
|
40
|
+
repo,
|
|
41
|
+
tree_sha: sha,
|
|
42
|
+
recursive: 'true',
|
|
43
|
+
});
|
|
44
|
+
return data.tree.map((entry) => ({
|
|
45
|
+
path: entry.path,
|
|
46
|
+
type: entry.type,
|
|
47
|
+
...(entry.size != null ? { size: entry.size } : {}),
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Read and decode a single file from a repository.
|
|
52
|
+
* @param owner - Repository owner.
|
|
53
|
+
* @param repo - Repository name.
|
|
54
|
+
* @param path - File path within the repo.
|
|
55
|
+
* @param ref - Optional branch, tag, or SHA.
|
|
56
|
+
* @returns Decoded UTF-8 file content as a string.
|
|
57
|
+
*/
|
|
58
|
+
async getFileContent(owner, repo, path, ref) {
|
|
59
|
+
const octokit = this.getOctokit();
|
|
60
|
+
const { data } = await octokit.rest.repos.getContent({
|
|
61
|
+
owner,
|
|
62
|
+
repo,
|
|
63
|
+
path,
|
|
64
|
+
...(ref ? { ref } : {}),
|
|
65
|
+
});
|
|
66
|
+
if (Array.isArray(data) || data.type !== 'file' || !('content' in data)) {
|
|
67
|
+
throw new Error(`Path "${path}" is not a file`);
|
|
68
|
+
}
|
|
69
|
+
return Buffer.from(data.content, 'base64').toString('utf8');
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Return current API rate-limit status for the authenticated token.
|
|
73
|
+
* @returns Object with remaining calls, total limit, and UTC reset timestamp.
|
|
74
|
+
*/
|
|
75
|
+
async getRateLimit() {
|
|
76
|
+
const octokit = this.getOctokit();
|
|
77
|
+
const { data } = await octokit.rest.rateLimit.get();
|
|
78
|
+
const core = data.resources.core;
|
|
79
|
+
return {
|
|
80
|
+
remaining: core.remaining,
|
|
81
|
+
limit: core.limit,
|
|
82
|
+
resetsAt: new Date(core.reset * 1000).toISOString(),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Fetch high-level metadata for a repository.
|
|
87
|
+
* @param owner - Repository owner.
|
|
88
|
+
* @param repo - Repository name.
|
|
89
|
+
* @returns Normalized metadata object.
|
|
90
|
+
*/
|
|
91
|
+
async getRepoMetadata(owner, repo) {
|
|
92
|
+
const octokit = this.getOctokit();
|
|
93
|
+
const { data } = await octokit.rest.repos.get({ owner, repo });
|
|
94
|
+
return {
|
|
95
|
+
name: data.name,
|
|
96
|
+
fullName: data.full_name,
|
|
97
|
+
description: data.description,
|
|
98
|
+
language: data.language,
|
|
99
|
+
stars: data.stargazers_count,
|
|
100
|
+
forks: data.forks_count,
|
|
101
|
+
topics: data.topics ?? [],
|
|
102
|
+
defaultBranch: data.default_branch,
|
|
103
|
+
visibility: data.visibility ?? 'public',
|
|
104
|
+
license: data.license?.spdx_id ?? null,
|
|
105
|
+
pushedAt: data.pushed_at,
|
|
106
|
+
htmlUrl: data.html_url,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
27
109
|
}
|
|
28
110
|
//# sourceMappingURL=GitHubService.js.map
|