@@ -65,6 +65,18 @@ async function fetchIssuesBatch(github, repoConfig) {
6565 }
6666}
6767
68+ /**
69+ * Returns the number of open issues currently assigned to `username` in the
70+ * given repository. Pull requests are excluded because they do not consume
71+ * assignment capacity. Returns null on API failure so callers can fail open.
72+ *
73+ * @param {object } params
74+ * @param {import('@actions/github').GitHub } params.github
75+ * @param {string } params.owner - Repo owner.
76+ * @param {string } params.repo - Repo name.
77+ * @param {string } params.username - GitHub login of the contributor.
78+ * @returns {Promise<number|null> } Count of open issue assignments, or null on failure.
79+ */
6880async function getOpenAssignments ( { github, owner, repo, username } ) {
6981 try {
7082 const issues = await github . paginate ( github . rest . issues . listForRepo , {
@@ -94,6 +106,14 @@ async function getOpenAssignments({ github, owner, repo, username }) {
94106 * Counts closed issues carrying `label` (in the given repo) assigned to
95107 * `username`. Returns null (rather than throwing) on unsafe input or API
96108 * error so callers can choose to fail open.
109+ *
110+ * @param {object } params
111+ * @param {import('@actions/github').GitHub } params.github
112+ * @param {string } params.owner - Repo owner.
113+ * @param {string } params.repo - Repo name.
114+ * @param {string } params.username - GitHub login of the contributor.
115+ * @param {string } params.label - Label string to filter by.
116+ * @returns {Promise<number|null> } Issue count, or null on invalid input or API failure.
97117 */
98118async function countCompletedIssuesWithLabel ( { github, owner, repo, username, label } ) {
99119 if ( ! isValidSearchToken ( owner ) || ! isValidSearchToken ( repo ) || ! isValidSearchToken ( username ) ) {
@@ -133,12 +153,18 @@ async function countCompletedIssuesWithLabel({ github, owner, repo, username, la
133153}
134154
135155/**
136-
137156 * Determines whether a user has repository collaborator access.
138157 *
139158 * Repository owners are always considered collaborators.
140159 * GitHub returns 204 when the user is a collaborator and 404 otherwise.
141160 * Unexpected API failures are treated as non-collaborator access.
161+ *
162+ * @param {object } params
163+ * @param {import('@actions/github').GitHub } params.github
164+ * @param {string } params.owner - Repo owner.
165+ * @param {string } params.repo - Repo name.
166+ * @param {string } params.username - GitHub login to check.
167+ * @returns {Promise<boolean> } True if the user is a collaborator, false otherwise.
142168 */
143169async function isRepoCollaborator ( { github, owner, repo, username } ) {
144170 if ( username === owner ) {
@@ -176,16 +202,46 @@ async function isRepoCollaborator({ github, owner, repo, username }) {
176202 }
177203}
178204
205+ /**
206+ * Posts a comment on an issue or pull request via the GitHub REST API.
207+ * When `logLabel` is provided, logs the outcome to the console; when omitted,
208+ * stays silent so the caller owns all logging. Re-throws any API error either
209+ * way so callers can handle or propagate failures themselves.
210+ *
211+ * @param {object } params
212+ * @param {import('@actions/github').GitHub } params.github
213+ * @param {string } params.owner - Repo owner.
214+ * @param {string } params.repo - Repo name.
215+ * @param {number } params.issueNumber - Issue or PR number to comment on.
216+ * @param {string } params.body - Markdown body of the comment.
217+ * @param {string } [logLabel] - Optional human-readable label used in console output.
218+ * @returns {Promise<void> }
219+ * @throws {Error } Re-throws the Octokit error on API failure.
220+ */
179221async function postIssueComment ( { github, owner, repo, issueNumber, body } , logLabel ) {
180222 try {
181223 await github . rest . issues . createComment ( { owner, repo, issue_number : issueNumber , body } ) ;
182- console . log ( `[github-api] Posted comment: ${ logLabel } ` ) ;
224+ if ( logLabel ) {
225+ console . log ( `[github-api] Posted comment: ${ logLabel } ` ) ;
226+ }
183227 } catch ( error ) {
184- console . error ( `[github-api] Failed to post comment (${ logLabel } ):` , { message : error . message } ) ;
228+ if ( logLabel ) {
229+ console . error ( `[github-api] Failed to post comment (${ logLabel } ):` , { message : error . message } ) ;
230+ }
185231 throw error ;
186232 }
187233}
188234
235+ /**
236+ * Fetches all comments on an issue or pull request, paginating automatically.
237+ *
238+ * @param {object } params
239+ * @param {import('@actions/github').GitHub } params.github
240+ * @param {string } params.owner - Repo owner.
241+ * @param {string } params.repo - Repo name.
242+ * @param {number } params.issueNumber - Issue or PR number.
243+ * @returns {Promise<Array<object>> } Array of comment objects from the GitHub API.
244+ */
189245async function fetchAllComments ( { github, owner, repo, issueNumber } ) {
190246 return github . paginate ( github . rest . issues . listComments , {
191247 owner,
@@ -195,6 +251,17 @@ async function fetchAllComments({ github, owner, repo, issueNumber }) {
195251 } ) ;
196252}
197253
254+ /**
255+ * Assigns a contributor to an issue.
256+ *
257+ * @param {object } params
258+ * @param {import('@actions/github').GitHub } params.github
259+ * @param {string } params.owner - Repo owner.
260+ * @param {string } params.repo - Repo name.
261+ * @param {number } params.issueNumber - Issue number to assign.
262+ * @param {string } params.username - GitHub login of the contributor to assign.
263+ * @returns {Promise<void> }
264+ */
198265async function assignIssue ( {
199266 github,
200267 owner,
0 commit comments