Skip to content

skills/wiki-generator/src/extractors

Module summary

Module skills/wiki-generator/src/extractors

Exports

NameKindDefault
CURSOR_REGEXvariableno
ISSUES_QUERYvariableno
ISSUE_COMMENTS_QUERYvariableno
_formatJsDocfunctionno
classifyCommitfunctionno
extractAstfunctionno
extractAstAndJsDocfunctionno
extractChangelogfunctionno
extractConfigCommentsfunctionno
extractIssuesfunctionno
extractJsDocfunctionno
extractReadmesfunctionno
notifyParseFailurefunctionno
parseSourcefunctionno
readCursorfunctionno
validatePathfunctionno
writeCursorfunctionno

Detail

CURSOR_REGEX

CURSOR_REGEX

Params

None.

Returns

None.

Examples

None.

ISSUES_QUERY

ISSUES_QUERY

Params

None.

Returns

None.

Examples

None.

ISSUE_COMMENTS_QUERY

ISSUE_COMMENTS_QUERY

Params

None.

Returns

None.

Examples

None.

_formatJsDoc

_formatJsDoc(parsed)

Params

  • parsed

Returns

None.

Examples

None.

classifyCommit

classifyCommit(subject)

Pure: classify a single conventional-commit subject line.

Params

  • subject

Returns

None.

Examples

None.

extractAst

extractAst({ path, source })

Params

  • { path, source }

Returns

None.

Examples

None.

extractAstAndJsDoc

extractAstAndJsDoc({ path, source })

Params

  • { path, source }

Returns

None.

Examples

None.

extractChangelog

async extractChangelog({ since = '30.days.ago', repoDir = process.cwd() })

Run git log --since=<since> in repoDir and return classified commits.

Params

  • { since = '30.days.ago', repoDir = process.cwd() } = {}

Returns

None.

Examples

None.

extractConfigComments

async extractConfigComments(rootDir)

Extract inline-comment annotations from project config files.

Looked-up files (best-effort — missing files yield empty maps):

  • vitest.config.ts (or .js, .mts, .cts) — top-level keys inside the test: { ... } block.
  • package.json + sibling package.scripts.md — comment for each entry in scripts.
  • .env.example — comment for each KEY=... line.

Params

  • rootDir = process.cwd()

Returns

None.

Examples

None.

extractIssues

async extractIssues({
owner,
repo,
client,
cursorPath = DEFAULT_CURSOR_PATH,
pageSize = DEFAULT_PAGE_SIZE,
maxPages = DEFAULT_MAX_PAGES,
reset = false,
now = () => new Date(),
})

Paginated GraphQL extractor for issues. See file header for cursor invariants.

Cursor-invalidation fallback (must_fix_in_build): when the pagination loop is resuming mid-run (pageCursor !== null) and the GraphQL call throws an error matched by isCursorError (explicit “cursor” mention, or pagination-argument error referencing “after”/“before” with “invalid”), the loop resets pageCursor to null, restores sinceForRun to the original cursor.last_updated_at, and retries the call once. On retry success, it immediately persists a cleared end_cursor (writeCursor with end_cursor: null) so the stale cursor on disk cannot re-trigger the fallback on the next run. If the retry also throws, the error propagates. Non-cursor errors (auth, scope, rate-limit) bypass the retry and propagate immediately.

Per-issue comment pagination (#1391): each matched issue’s comments connection is walked via ISSUE_COMMENTS_QUERY until pageInfo.hasNextPage is false or MAX_COMMENTS_PAGES_PER_ISSUE is hit. Issues with <= 100 comments take the single-fetch path (no extra GraphQL calls). The commentsTruncated stat is true if ANY issue hit the per-issue page cap.

Params

  • { owner, repo, client, cursorPath = DEFAULT_CURSOR_PATH, pageSize = DEFAULT_PAGE_SIZE, maxPages = DEFAULT_MAX_PAGES, reset = false, now = () => new Date(), }

Returns

None.

Examples

None.

extractJsDoc

extractJsDoc({ path, source })

Params

  • { path, source }

Returns

None.

Examples

None.

extractReadmes

async extractReadmes(rootDir, opts)

Walk rootDir and collect every README.md in any subdirectory.

Params

  • rootDir
  • opts = {}

Returns

None.

Examples

None.

notifyParseFailure

notifyParseFailure({ path, message })

Params

  • { path, message }

Returns

None.

Examples

None.

parseSource

parseSource({ path, source })

Params

  • { path, source }

Returns

None.

Examples

None.

readCursor

readCursor(filePath)

Read the cursor file. Returns safe defaults on any failure path.

Validation rules:

  • Missing file, unreadable file, malformed JSON → defaults.
  • last_updated_at: must be a string, must parse via Date.parse, and must not be in the future. On any failure → coerce to null and warn.
  • end_cursor: must match CURSOR_REGEX. On failure → coerce to null.

Params

  • filePath

Returns

None.

Examples

None.

validatePath

validatePath(rawPath, root, kind)

Validate that rawPath resolves to a location inside root. On any failure, write a generic error to stderr and call process.exit(2).

Params

  • rawPath
  • root
  • kind

Returns

None.

Examples

None.

writeCursor

writeCursor(filePath, cursor)

Atomically persist the cursor. Always overwrites updated_at with the current ISO timestamp. Creates the parent directory if missing.

Params

  • filePath
  • cursor

Returns

None.

Examples

None.