MCPcopy Index your code
hub / github.com/codeaashu/claude-code / extractShotCountFromMessages

Function extractShotCountFromMessages

src/utils/stats.ts:940–965  ·  view source on GitHub ↗

* Extract the shot count from PR attribution text in a `gh pr create` Bash call. * The attribution format is: "N-shotted by model-name" * Returns the shot count, or null if not found.

(
  messages: TranscriptMessage[],
)

Source from the content-addressed store, hash-verified

938 * Returns the shot count, or null if not found.
939 */
940function extractShotCountFromMessages(
941 messages: TranscriptMessage[],
942): number | null {
943 for (const m of messages) {
944 if (m.type !== 'assistant') continue
945 const content = m.message?.content
946 if (!Array.isArray(content)) continue
947 for (const block of content) {
948 if (
949 block.type !== 'tool_use' ||
950 !SHELL_TOOL_NAMES.includes(block.name) ||
951 typeof block.input !== 'object' ||
952 block.input === null ||
953 !('command' in block.input) ||
954 typeof block.input.command !== 'string'
955 ) {
956 continue
957 }
958 const match = SHOT_COUNT_REGEX.exec(block.input.command)
959 if (match) {
960 return parseInt(match[1]!, 10)
961 }
962 }
963 }
964 return null
965}
966
967// Transcript message types — must match isTranscriptMessage() in sessionStorage.ts.
968// The canonical dateKey (see processSessionFiles) reads mainMessages[0].timestamp,

Callers 1

processSessionFilesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected