MCPcopy Index your code
hub / github.com/simstudioai/sim / treeItemToStub

Function treeItemToStub

apps/sim/connectors/github/github.ts:162–184  ·  view source on GitHub ↗

* Creates a lightweight stub ExternalDocument from a tree item. * Uses the Git blob SHA as contentHash for change detection, avoiding * the need to fetch blob content for every file during listing. * Content is deferred and only fetched for new/changed documents.

(
  owner: string,
  repo: string,
  branch: string,
  item: TreeItem
)

Source from the content-addressed store, hash-verified

160 * Content is deferred and only fetched for new/changed documents.
161 */
162function treeItemToStub(
163 owner: string,
164 repo: string,
165 branch: string,
166 item: TreeItem
167): ExternalDocument {
168 return {
169 externalId: item.path,
170 title: item.path.split('/').pop() || item.path,
171 content: '',
172 contentDeferred: true,
173 mimeType: 'text/plain',
174 sourceUrl: `https://github.com/${owner}/${repo}/blob/${branch.split('/').map(encodeURIComponent).join('/')}/${item.path.split('/').map(encodeURIComponent).join('/')}`,
175 contentHash: `${GIT_SHA_PREFIX}${item.sha}`,
176 metadata: {
177 path: item.path,
178 sha: item.sha,
179 size: item.size,
180 branch,
181 repository: `${owner}/${repo}`,
182 },
183 }
184}
185
186export const githubConnector: ConnectorConfig = {
187 ...githubConnectorMeta,

Callers 1

github.tsFile · 0.85

Calls 1

joinMethod · 0.80

Tested by

no test coverage detected