[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M77MN5NQ2YW16TEXM64ZJ776":3,"skill-same:01M77MN5NQ2YW16TEXM64ZJ776":45},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":26,"repositoryHtmlUrl":27,"repositoryHomepageUrl":28,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M77MN5NQ2YW16TEXM64ZJ776","gh-cli-issue-reporting",null,"Load this skill when writing code that creates GitHub issues via the `gh` CLI, when implementing auth-detection logic before a `gh` invocation, when scrubbing secrets from a body that will be submitted to a public GitHub repository, or when designing a local-file fallback for offline \u002F unauthenticated environments. Triggers: any file named *report-framework-bug*, *gh-report*, *file-issue*, or any code calling `spawnSync('gh', ...)` \u002F `execSync('gh issue create ...')`.","HexingBot\u002Fhivemind","HexingBot","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F296674764?v=4","01M77MMXMW5SWSXKHB0VA4N1FF","01M77MMXNV3PZA3795D6PYX5C9",1,"MIT","https:\u002F\u002Fgithub.com\u002FHexingBot\u002Fhivemind\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fgh-cli-issue-reporting\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: gh-cli-issue-reporting\ndescription: >\n  Load this skill when writing code that creates GitHub issues via the `gh` CLI,\n  when implementing auth-detection logic before a `gh` invocation, when scrubbing\n  secrets from a body that will be submitted to a public GitHub repository, or when\n  designing a local-file fallback for offline \u002F unauthenticated environments.\n  Triggers: any file named *report-framework-bug*, *gh-report*, *file-issue*,\n  or any code calling `spawnSync('gh', ...)` \u002F `execSync('gh issue create ...')`.\n---\n\n# gh CLI Issue Reporting — Team Skill\n\n## When to Use This Skill\n\nUse when implementing the `\u002Fhivemind:report-framework-bug` command or any\nfuture feature that files GitHub issues from within a Claude Code plugin. Core topics:\nauth detection, non-interactive issue creation, secret scrubbing before upload,\nand the local-file durable fallback.\n\n## Core Workflows\n\n### 1. Detect whether gh is available and authenticated\n\nRun two cheap checks in sequence. Either failure means fall back to the local file.\n\n```js\nimport { spawnSync } from 'node:child_process';\n\n\u002F**\n * @param {function} runner  injectable for tests: (cmd, args) => {status, stdout, stderr}\n * @returns {{ available: boolean, authenticated: boolean }}\n *\u002F\nexport function detectGh(runner = defaultRunner) {\n  \u002F\u002F Step 1 — is the binary present?\n  const ver = runner('gh', ['--version']);\n  if (ver.status !== 0) return { available: false, authenticated: false };\n\n  \u002F\u002F Step 2 — is at least one account authenticated?\n  \u002F\u002F gh auth status exits 0 when any account is logged in, 1 otherwise.\n  \u002F\u002F KNOWN CAVEAT: gh \u003C= 2.42.1 always exits 0 from `auth status`.\n  \u002F\u002F Mitigation: also check stderr for \"not logged into any GitHub hosts\".\n  const auth = runner('gh', ['auth', 'status']);\n  const authOk =\n    auth.status === 0 &&\n    !auth.stderr.includes('not logged into any GitHub hosts');\n  return { available: true, authenticated: authOk };\n}\n\nfunction defaultRunner(cmd, args) {\n  return spawnSync(cmd, args, { encoding: 'utf8', timeout: 8_000 });\n}\n```\n\n**Pitfall — `gh auth status` exit-code bug.** Versions of gh up to 2.42.1 return\nexit code 0 even when not authenticated. Always combine the exit-code check with the\nstderr string check above so the guard works on those versions.\n\n**Pitfall — 8-second timeout.** Claude Code desktop has had issues where\n`gh auth status` blocks for ~5 s on flaky network. Use `timeout: 8_000` to avoid\nhanging the command.\n\n### 2. Create an issue non-interactively\n\n```js\n\u002F**\n * @param {{ title: string, body: string, repo: string }} opts\n * @param {function} runner  injectable\n * @returns {{ url: string }}   the new issue URL, e.g. https:\u002F\u002Fgithub.com\u002Fowner\u002Frepo\u002Fissues\u002F42\n *\u002F\nexport function ghIssueCreate({ title, body, repo }, runner = defaultRunner) {\n  const result = runner('gh', [\n    'issue', 'create',\n    '--repo', repo,        \u002F\u002F e.g. 'HexingBot\u002Fhivemind'\n    '--title', title,\n    '--body', body,        \u002F\u002F pass body as a single arg; gh handles newlines fine\n  ]);\n\n  if (result.status !== 0) {\n    throw new Error(`gh issue create failed (exit ${result.status}): ${result.stderr}`);\n  }\n\n  \u002F\u002F gh prints the new issue URL as the last non-empty stdout line, e.g.\n  \u002F\u002F   https:\u002F\u002Fgithub.com\u002FHexingBot\u002Fhivemind\u002Fissues\u002F42\n  const url = result.stdout.trim().split('\\n').filter(Boolean).at(-1);\n  if (!url || !url.startsWith('https:\u002F\u002F')) {\n    throw new Error(`gh issue create returned unexpected output: ${result.stdout}`);\n  }\n  return { url };\n}\n```\n\n**Using `--body-file -` (stdin) instead of `--body`:** preferred when the body\nmay contain characters that shell-escape is fragile for. Pipe via `input` option\nof `spawnSync`:\n\n```js\nconst result = spawnSync('gh', ['issue', 'create', '--repo', repo,\n  '--title', title, '--body-file', '-'],\n  { input: body, encoding: 'utf8', timeout: 30_000 });\n```\n\nBoth forms work; the `--body` flag is simpler for short bodies with an injectable\nrunner. Use `--body-file -` when body exceeds ~2 KB or contains backticks\u002Fquotes.\n\n### 3. Secret-scrub the body before submission\n\nAll content that goes to GitHub MUST pass through `scrubSecrets` first.\n\n```js\nconst REDACT = '[REDACTED]';\n\n\u002F** Ordered list of {pattern, label} substitutions applied left-to-right. *\u002F\nconst SECRET_PATTERNS = [\n  \u002F\u002F GitHub tokens (classic PAT and fine-grained PAT)\n  { re: \u002Fghp_[A-Za-z0-9]{36}\u002Fg,          label: 'ghp_token' },\n  { re: \u002Fgho_[A-Za-z0-9]{36}\u002Fg,          label: 'gho_token' },\n  { re: \u002Fghs_[A-Za-z0-9]{36}\u002Fg,          label: 'ghs_token' },\n  { re: \u002Fghu_[A-Za-z0-9]{36}\u002Fg,          label: 'ghu_token' },\n  { re: \u002Fghr_[A-Za-z0-9]{36}\u002Fg,          label: 'ghr_token' },\n  { re: \u002Fgithub_pat_[A-Za-z0-9_]{82}\u002Fg,  label: 'github_pat' },\n  \u002F\u002F Anthropic API keys\n  { re: \u002Fsk-ant-[A-Za-z0-9\\-_]{40,}\u002Fg,   label: 'sk_ant_key' },\n  \u002F\u002F Generic sk- keys (OpenAI etc.)\n  { re: \u002Fsk-[A-Za-z0-9]{20,}\u002Fg,          label: 'sk_key' },\n  \u002F\u002F AWS access key IDs\n  { re: \u002F(?:AKIA|ASIA)[A-Z0-9]{16}\u002Fg,    label: 'aws_akid' },\n  \u002F\u002F AWS secret access keys (heuristic: 40 base64 chars after = or space)\n  { re: \u002F(?\u003C=AWS_SECRET_ACCESS_KEY[=:\\s][\"']?)[A-Za-z0-9+\u002F]{40}\u002Fg, label: 'aws_secret' },\n  \u002F\u002F URI-userinfo credentials: scheme:\u002F\u002Fuser:pass@host (e.g. a connection\n  \u002F\u002F string like bolt:\u002F\u002Fneo4j:hunter2@db:7687). Username is `*` (not `+`) —\n  \u002F\u002F RFC 3986 userinfo allows an empty username, e.g. redis:\u002F\u002F:password@host.\n  \u002F\u002F Only the credential portion is replaced — the captured scheme keeps\n  \u002F\u002F scheme+host readable.\n  { re: \u002F(\\w+:\\\u002F\\\u002F)[^\u002F\\s:@]*:[^\u002F\\s@]+@\u002Fgi,\n    label: 'uri_userinfo',\n    replace: (_m, scheme) => `${scheme}[REDACTED:uri_userinfo]@` },\n  \u002F\u002F Bearer \u002F Authorization header values\n  { re: \u002F(?\u003C=(?:Authorization|Bearer)[:\\s]+)[A-Za-z0-9\\-._~+\u002F]+=*\u002Fgi, label: 'bearer_token' },\n  \u002F\u002F Env-var assignment patterns: FOO_TOKEN=value, BAR_SECRET=\"value\", BAZ_KEY=value,\n  \u002F\u002F FOO_AUTH=value, and bare PASSWORD=value (e.g. NEO4J_AUTH=neo4j\u002Fhunter2)\n  { re: \u002F\\b(?:\\w+_TOKEN|\\w+_SECRET|\\w+_KEY|\\w+_PASSWORD|\\w+_CREDENTIAL|\\w*_AUTH|PASSWORD)\\s*=\\s*[\"']?[^\\s\"']{8,}[\"']?\u002Fgi,\n    label: 'env_secret' },\n];\n\n\u002F**\n * Replace known secret patterns with [REDACTED:\u003Clabel>].\n * Returns the scrubbed string. Never mutates the input.\n *\n * @param {string} text\n * @returns {string}\n *\u002F\nexport function scrubSecrets(text) {\n  let out = text;\n  for (const { re, label, replace } of SECRET_PATTERNS) {\n    \u002F\u002F A pattern may supply its own `replace` function to keep a captured\n    \u002F\u002F group (e.g. the URI scheme) legible instead of replacing the whole match.\n    out = out.replace(re, replace ?? `[REDACTED:${label}]`);\n  }\n  return out;\n}\n```\n\n**Known false-negative cases** the Developer must document in tests:\n- Long hex strings that are NOT tokens (e.g. git commit SHAs): not matched by the\n  prefix-anchored patterns above, so they pass through correctly.\n- Tokens stored in `.claude\u002Fsettings.json` keys: the settings file itself is NEVER\n  read by the collector — the context block only reads known safe fields\n  (plugin version, OS, project name, active session\u002Ftask key). Do not add a settings\n  reader; absence is the defense.\n- Custom prefixes the user's project uses (e.g. `myapp_secret_XYZ`): the `env_secret`\n  regex only covers `_TOKEN`, `_SECRET`, `_KEY`, `_PASSWORD`, `_CREDENTIAL`, `_AUTH`\n  suffixes and bare `PASSWORD=`. Document this limitation in the command's output\n  so users know to review before submitting.\n- Multiline values split across lines: most patterns are single-line. For env\n  assignments that wrap, only the first line is redacted.\n\n### 4. Collect safe context (no secrets)\n\n```js\nimport { platform, release } from 'node:os';\nimport { readFileSync, existsSync } from 'node:fs';\nimport { join } from 'node:path';\n\n\u002F**\n * Collect a safe, secret-free context block for the bug report.\n *\n * @param {{ pluginRoot: string, projectDir: string }} opts\n * @returns {string}  a markdown fenced block\n *\u002F\nexport function collectContext({ pluginRoot, projectDir }) {\n  \u002F\u002F Plugin version from plugin.json (safe metadata, no secrets)\n  let pluginVersion = 'unknown';\n  try {\n    const manifest = JSON.parse(\n      readFileSync(join(pluginRoot, '.claude-plugin', 'plugin.json'), 'utf8'));\n    pluginVersion = manifest.version ?? 'unknown';\n  } catch { \u002F* ignore *\u002F }\n\n  \u002F\u002F Project name from PROJECT.md frontmatter (first --- block, name field)\n  let projectName = 'unknown';\n  const projectMdPath = join(projectDir, 'PROJECT.md');\n  if (existsSync(projectMdPath)) {\n    const raw = readFileSync(projectMdPath, 'utf8');\n    const m = raw.match(\u002F^---[\\s\\S]*?project_name:\\s*(.+?)[\\s\\S]*?---\u002Fm);\n    if (m) projectName = m[1].trim();\n  }\n\n  \u002F\u002F Active session \u002F task from state\u002Fsession.json (key only, no body)\n  let activeSession = 'none';\n  let activeTask = 'none';\n  const sessionPtrPath = join(projectDir, 'state', 'session.json');\n  if (existsSync(sessionPtrPath)) {\n    try {\n      const ptr = JSON.parse(readFileSync(sessionPtrPath, 'utf8'));\n      if (ptr.active_session_id) {\n        activeSession = ptr.active_session_id;\n        const bundlePath = join(projectDir, 'state', 'sessions',\n          ptr.active_session_id, 'session.json');\n        if (existsSync(bundlePath)) {\n          const bundle = JSON.parse(readFileSync(bundlePath, 'utf8'));\n          activeTask = bundle.active_task ?? 'none';\n        }\n      }\n    } catch { \u002F* ignore *\u002F }\n  }\n\n  return [\n    '```',\n    `plugin_version: ${pluginVersion}`,\n    `os: ${platform()} ${release()}`,\n    `project: ${projectName}`,\n    `active_session: ${activeSession}`,\n    `active_task: ${activeTask}`,\n    '```',\n  ].join('\\n');\n}\n```\n\n### 5. Build the full issue body\n\n```js\n\u002F**\n * Compose and scrub the complete issue body.\n *\n * @param {{ title: string, repro: string, expected: string, actual: string,\n *            severity: string, evidence?: string, context: string }} opts\n * @returns {string}\n *\u002F\nexport function buildIssueBody({ title, repro, expected, actual,\n                                  severity, evidence, context }) {\n  const parts = [\n    `## What happened\\n${actual}`,\n    `## What was expected\\n${expected}`,\n    `## Steps to reproduce\\n${repro}`,\n    `## Severity\\n${severity}`,\n  ];\n  if (evidence) parts.push(`## Evidence\\n\\`\\`\\`\\n${evidence}\\n\\`\\`\\``);\n  parts.push(`## Auto-collected context\\n${context}`);\n\n  const raw = parts.join('\\n\\n');\n  return scrubSecrets(raw);  \u002F\u002F ALWAYS scrub before returning\n}\n```\n\n### 6. Top-level orchestrator: fileFrameworkBug\n\n```js\n\u002F**\n * The single entry point the command markdown invokes.\n * Injectable runner and fallbackWriter make it fully testable without disk\u002Fnetwork.\n *\n * @param {object} opts\n * @param {string} opts.title\n * @param {string} opts.body          pre-built, pre-scrubbed issue body\n * @param {string} opts.pluginRoot    CLAUDE_PLUGIN_ROOT\n * @param {string} opts.projectDir    CLAUDE_PROJECT_DIR\n * @param {string} [opts.repo]        default DEFAULT_REPO ('HexingBot\u002Fhivemind')\n * @param {function} [opts.runner]    spawnSync-compatible injectable\n * @param {function} [opts.fallbackWriter]  (path, content) => void, default fs.writeFileSync\n * @returns {{ filed: 'github'|'local', url?: string, path?: string, reason?: string }}\n *\u002F\nexport async function fileFrameworkBug({\n  title, body, pluginRoot, projectDir,\n  repo = DEFAULT_REPO,\n  runner,\n  fallbackWriter,\n}) {\n  \u002F\u002F `reason` names the ACTUAL cause of a fallback — gh can be present and\n  \u002F\u002F authenticated and still fail `gh issue create` (wrong repo, disabled\n  \u002F\u002F issues, etc.), so \"not available\" \u002F \"not authenticated\" must not be used\n  \u002F\u002F as a blanket explanation for every fallback.\n  let reason;\n  const { available, authenticated } = detectGh(runner);\n\n  if (!available) {\n    reason = 'gh CLI not found';\n  } else if (!authenticated) {\n    reason = 'gh not authenticated';\n  } else {\n    try {\n      const { url } = ghIssueCreate({ title, body, repo }, runner);\n      return { filed: 'github', url };\n    } catch (err) {\n      reason = err.message;\n    }\n  }\n\n  \u002F\u002F Fallback: write to a local file in the project's .claude\u002F directory\n  const fallbackDir = join(projectDir, '.claude', 'framework-bug-reports');\n  const ts = new Date().toISOString().replace(\u002F[:.]\u002Fg, '-');\n  const filePath = join(fallbackDir, `bug-report-${ts}.md`);\n  const content = `# ${title}\\n\\n${body}\\n`;\n\n  const writer = fallbackWriter ?? ((p, c) => {\n    mkdirSync(dirname(p), { recursive: true });\n    writeFileSync(p, c, 'utf8');\n  });\n  writer(filePath, content);\n\n  return { filed: 'local', path: filePath, reason };\n}\n```\n\n## Best Practices\n\n- **Do** inject the runner in every function that calls `gh`. It makes unit tests\n  instant and avoids real network calls.\n- **Do** scrub secrets (`scrubSecrets`) before building the body, not after.\n  Once the body is assembled it should already be clean.\n- **Do** check BOTH `gh --version` exit code AND `gh auth status` stderr for the\n  \"not logged into any GitHub hosts\" string (exit-code-always-0 bug).\n- **Do** use `--body-file -` (stdin) if the body may contain shell-unfriendly\n  characters (backticks, quotes, `$`).\n- **Do not** read `.claude\u002Fsettings.json` in the context collector — absence is the\n  defense against leaking project secrets via settings values.\n- **Do not** include the full session bundle body in the context block — only the\n  session ID and active task KEY (not its JSON).\n- **Do not** attempt to assign, label, or add the issue to a project in the initial\n  creation — those operations require extra OAuth scopes that downstream users may\n  not have.\n\n## Viability note: non-collaborator issue creation (CRITICAL)\n\nAny authenticated GitHub user with read access to a public repository CAN create\nissues on it via `gh issue create`. The GitHub REST API endpoint POST\n`\u002Frepos\u002F{owner}\u002F{repo}\u002Fissues` requires only a valid OAuth token with `repo` or\n`public_repo` scope — no collaborator status. This is confirmed by the official\ndocs: \"Any user with pull access to a repository can create an issue.\"\n\n**Therefore the feature IS viable for arbitrary downstream users of the plugin,\nnot only the maintainer.** The only cases where creation fails are:\n\n1. The repository owner has enabled interaction limits (collaborators-only or\n   existing-users-only modes) — very rare on open-source repos.\n2. The user's gh token lacks the `public_repo` scope — possible for fine-grained\n   PATs with restricted scopes.\n3. Issues are disabled on the repository.\n\nThe fallback to a local file handles all three cases gracefully.\n\n## Common Pitfalls\n\n- **gh auth status always exits 0 (gh \u003C= 2.42.1):** check stderr too (see Workflow 1).\n- **`gh issue create` prompts interactively when title or body is missing:** always\n  pass both `--title` and `--body` (or `--body-file`); omitting either drops into\n  an editor session that hangs non-interactive callers.\n- **`--body` with newlines on Windows PowerShell:** prefer `--body-file -` with stdin\n  piping if the body contains `\\n`. The `--body` flag works reliably on bash; on\n  PowerShell, newlines may be mangled by the shell before gh sees them.\n- **Issue URL parsing:** gh prints the URL as the LAST non-blank stdout line. Earlier\n  lines may include deprecation notices or config warnings. Always split on `\\n` and\n  take the last non-empty token.\n- **Rate limits:** GitHub allows 5000 requests per hour per authenticated user. Filing\n  one bug report consumes 1 request. No throttling logic needed.\n- **`env_secret` regex false positives:** env-var names like `DEBUG_LEVEL=verbose`\n  will not match (no `_TOKEN`\u002F`_SECRET`\u002Fetc. suffix); but `SOME_KEY=foo` WILL match\n  and be redacted. This is intentional — false positives are safe, false negatives\n  are not.\n\n## Verification\n\nAfter implementing `src\u002Fframework-bug-report.js`:\n\n1. Fast unit tests (pure logic, no disk): `npm test` — covers `scrubSecrets`,\n   `collectContext` with mock fs, `buildIssueBody`, `detectGh` with injected runner,\n   `ghIssueCreate` with injected runner (success + failure paths),\n   `fileFrameworkBug` with gh available\u002Fauth OK, gh unavailable, gh not authenticated.\n2. E2E \u002F integration (optional): spawn a real `gh --version` and `gh auth status`\n   in CI where GH_TOKEN is set. Skip if GH_TOKEN is absent.\n3. Dist parity: after adding the new entrypoint to `build-plugin.mjs`, run\n   `npm run build:plugin` and verify `dist\u002Freport-framework-bug.cjs` exists, then\n   run `npm run test:all` so `dist-parity.spec.js` validates the bundle.\n\n## References\n\n- [`references\u002Fgh-issue-create-flags.md`](references\u002Fgh-issue-create-flags.md) — full flag reference for `gh issue create`.\n- [`references\u002Fsecret-patterns.md`](references\u002Fsecret-patterns.md) — extended regex catalog for more token types.\n\n## Provenance\n\n- **Authored by:** Researcher subagent on behalf of TASK-010.\n- **Primary sources:**\n  - https:\u002F\u002Fcli.github.com\u002Fmanual\u002Fgh_issue_create\n  - https:\u002F\u002Fdocs.github.com\u002Fen\u002Frest\u002Fissues\u002Fissues#create-an-issue\n  - https:\u002F\u002Fcli.github.com\u002Fmanual\u002Fgh_auth_status\n  - https:\u002F\u002Fgithub.com\u002Fcli\u002Fcli\u002Fissues\u002F8845 (exit-code bug)\n- **Last verified:** 2026-06-23.\n","# gh CLI Issue Reporting — Team Skill\n\n## When to Use This Skill\n\nUse when implementing the `\u002Fhivemind:report-framework-bug` command or any\nfuture feature that files GitHub issues from within a Claude Code plugin. Core topics:\nauth detection, non-interactive issue creation, secret scrubbing before upload,\nand the local-file durable fallback.\n\n## Core Workflows\n\n### 1. Detect whether gh is available and authenticated\n\nRun two cheap checks in sequence. Either failure means fall back to the local file.\n\n```js\nimport { spawnSync } from 'node:child_process';\n\n\u002F**\n * @param {function} runner  injectable for tests: (cmd, args) => {status, stdout, stderr}\n * @returns {{ available: boolean, authenticated: boolean }}\n *\u002F\nexport function detectGh(runner = defaultRunner) {\n  \u002F\u002F Step 1 — is the binary present?\n  const ver = runner('gh', ['--version']);\n  if (ver.status !== 0) return { available: false, authenticated: false };\n\n  \u002F\u002F Step 2 — is at least one account authenticated?\n  \u002F\u002F gh auth status exits 0 when any account is logged in, 1 otherwise.\n  \u002F\u002F KNOWN CAVEAT: gh \u003C= 2.42.1 always exits 0 from `auth status`.\n  \u002F\u002F Mitigation: also check stderr for \"not logged into any GitHub hosts\".\n  const auth = runner('gh', ['auth', 'status']);\n  const authOk =\n    auth.status === 0 &&\n    !auth.stderr.includes('not logged into any GitHub hosts');\n  return { available: true, authenticated: authOk };\n}\n\nfunction defaultRunner(cmd, args) {\n  return spawnSync(cmd, args, { encoding: 'utf8', timeout: 8_000 });\n}\n```\n\n**Pitfall — `gh auth status` exit-code bug.** Versions of gh up to 2.42.1 return\nexit code 0 even when not authenticated. Always combine the exit-code check with the\nstderr string check above so the guard works on those versions.\n\n**Pitfall — 8-second timeout.** Claude Code desktop has had issues where\n`gh auth status` blocks for ~5 s on flaky network. Use `timeout: 8_000` to avoid\nhanging the command.\n\n### 2. Create an issue non-interactively\n\n```js\n\u002F**\n * @param {{ title: string, body: string, repo: string }} opts\n * @param {function} runner  injectable\n * @returns {{ url: string }}   the new issue URL, e.g. https:\u002F\u002Fgithub.com\u002Fowner\u002Frepo\u002Fissues\u002F42\n *\u002F\nexport function ghIssueCreate({ title, body, repo }, runner = defaultRunner) {\n  const result = runner('gh', [\n    'issue', 'create',\n    '--repo', repo,        \u002F\u002F e.g. 'HexingBot\u002Fhivemind'\n    '--title', title,\n    '--body', body,        \u002F\u002F pass body as a single arg; gh handles newlines fine\n  ]);\n\n  if (result.status !== 0) {\n    throw new Error(`gh issue create failed (exit ${result.status}): ${result.stderr}`);\n  }\n\n  \u002F\u002F gh prints the new issue URL as the last non-empty stdout line, e.g.\n  \u002F\u002F   https:\u002F\u002Fgithub.com\u002FHexingBot\u002Fhivemind\u002Fissues\u002F42\n  const url = result.stdout.trim().split('\\n').filter(Boolean).at(-1);\n  if (!url || !url.startsWith('https:\u002F\u002F')) {\n    throw new Error(`gh issue create returned unexpected output: ${result.stdout}`);\n  }\n  return { url };\n}\n```\n\n**Using `--body-file -` (stdin) instead of `--body`:** preferred when the body\nmay contain characters that shell-escape is fragile for. Pipe via `input` option\nof `spawnSync`:\n\n```js\nconst result = spawnSync('gh', ['issue', 'create', '--repo', repo,\n  '--title', title, '--body-file', '-'],\n  { input: body, encoding: 'utf8', timeout: 30_000 });\n```\n\nBoth forms work; the `--body` flag is simpler for short bodies with an injectable\nrunner. Use `--body-file -` when body exceeds ~2 KB or contains backticks\u002Fquotes.\n\n### 3. Secret-scrub the body before submission\n\nAll content that goes to GitHub MUST pass through `scrubSecrets` first.\n\n```js\nconst REDACT = '[REDACTED]';\n\n\u002F** Ordered list of {pattern, label} substitutions applied left-to-right. *\u002F\nconst SECRET_PATTERNS = [\n  \u002F\u002F GitHub tokens (classic PAT and fine-grained PAT)\n  { re: \u002Fghp_[A-Za-z0-9]{36}\u002Fg,          label: 'ghp_token' },\n  { re: \u002Fgho_[A-Za-z0-9]{36}\u002Fg,          label: 'gho_token' },\n  { re: \u002Fghs_[A-Za-z0-9]{36}\u002Fg,          label: 'ghs_token' },\n  { re: \u002Fghu_[A-Za-z0-9]{36}\u002Fg,          label: 'ghu_token' },\n  { re: \u002Fghr_[A-Za-z0-9]{36}\u002Fg,          label: 'ghr_token' },\n  { re: \u002Fgithub_pat_[A-Za-z0-9_]{82}\u002Fg,  label: 'github_pat' },\n  \u002F\u002F Anthropic API keys\n  { re: \u002Fsk-ant-[A-Za-z0-9\\-_]{40,}\u002Fg,   label: 'sk_ant_key' },\n  \u002F\u002F Generic sk- keys (OpenAI etc.)\n  { re: \u002Fsk-[A-Za-z0-9]{20,}\u002Fg,          label: 'sk_key' },\n  \u002F\u002F AWS access key IDs\n  { re: \u002F(?:AKIA|ASIA)[A-Z0-9]{16}\u002Fg,    label: 'aws_akid' },\n  \u002F\u002F AWS secret access keys (heuristic: 40 base64 chars after = or space)\n  { re: \u002F(?\u003C=AWS_SECRET_ACCESS_KEY[=:\\s][\"']?)[A-Za-z0-9+\u002F]{40}\u002Fg, label: 'aws_secret' },\n  \u002F\u002F URI-userinfo credentials: scheme:\u002F\u002Fuser:pass@host (e.g. a connection\n  \u002F\u002F string like bolt:\u002F\u002Fneo4j:hunter2@db:7687). Username is `*` (not `+`) —\n  \u002F\u002F RFC 3986 userinfo allows an empty username, e.g. redis:\u002F\u002F:password@host.\n  \u002F\u002F Only the credential portion is replaced — the captured scheme keeps\n  \u002F\u002F scheme+host readable.\n  { re: \u002F(\\w+:\\\u002F\\\u002F)[^\u002F\\s:@]*:[^\u002F\\s@]+@\u002Fgi,\n    label: 'uri_userinfo',\n    replace: (_m, scheme) => `${scheme}[REDACTED:uri_userinfo]@` },\n  \u002F\u002F Bearer \u002F Authorization header values\n  { re: \u002F(?\u003C=(?:Authorization|Bearer)[:\\s]+)[A-Za-z0-9\\-._~+\u002F]+=*\u002Fgi, label: 'bearer_token' },\n  \u002F\u002F Env-var assignment patterns: FOO_TOKEN=value, BAR_SECRET=\"value\", BAZ_KEY=value,\n  \u002F\u002F FOO_AUTH=value, and bare PASSWORD=value (e.g. NEO4J_AUTH=neo4j\u002Fhunter2)\n  { re: \u002F\\b(?:\\w+_TOKEN|\\w+_SECRET|\\w+_KEY|\\w+_PASSWORD|\\w+_CREDENTIAL|\\w*_AUTH|PASSWORD)\\s*=\\s*[\"']?[^\\s\"']{8,}[\"']?\u002Fgi,\n    label: 'env_secret' },\n];\n\n\u002F**\n * Replace known secret patterns with [REDACTED:\u003Clabel>].\n * Returns the scrubbed string. Never mutates the input.\n *\n * @param {string} text\n * @returns {string}\n *\u002F\nexport function scrubSecrets(text) {\n  let out = text;\n  for (const { re, label, replace } of SECRET_PATTERNS) {\n    \u002F\u002F A pattern may supply its own `replace` function to keep a captured\n    \u002F\u002F group (e.g. the URI scheme) legible instead of replacing the whole match.\n    out = out.replace(re, replace ?? `[REDACTED:${label}]`);\n  }\n  return out;\n}\n```\n\n**Known false-negative cases** the Developer must document in tests:\n- Long hex strings that are NOT tokens (e.g. git commit SHAs): not matched by the\n  prefix-anchored patterns above, so they pass through correctly.\n- Tokens stored in `.claude\u002Fsettings.json` keys: the settings file itself is NEVER\n  read by the collector — the context block only reads known safe fields\n  (plugin version, OS, project name, active session\u002Ftask key). Do not add a settings\n  reader; absence is the defense.\n- Custom prefixes the user's project uses (e.g. `myapp_secret_XYZ`): the `env_secret`\n  regex only covers `_TOKEN`, `_SECRET`, `_KEY`, `_PASSWORD`, `_CREDENTIAL`, `_AUTH`\n  suffixes and bare `PASSWORD=`. Document this limitation in the command's output\n  so users know to review before submitting.\n- Multiline values split across lines: most patterns are single-line. For env\n  assignments that wrap, only the first line is redacted.\n\n### 4. Collect safe context (no secrets)\n\n```js\nimport { platform, release } from 'node:os';\nimport { readFileSync, existsSync } from 'node:fs';\nimport { join } from 'node:path';\n\n\u002F**\n * Collect a safe, secret-free context block for the bug report.\n *\n * @param {{ pluginRoot: string, projectDir: string }} opts\n * @returns {string}  a markdown fenced block\n *\u002F\nexport function collectContext({ pluginRoot, projectDir }) {\n  \u002F\u002F Plugin version from plugin.json (safe metadata, no secrets)\n  let pluginVersion = 'unknown';\n  try {\n    const manifest = JSON.parse(\n      readFileSync(join(pluginRoot, '.claude-plugin', 'plugin.json'), 'utf8'));\n    pluginVersion = manifest.version ?? 'unknown';\n  } catch { \u002F* ignore *\u002F }\n\n  \u002F\u002F Project name from PROJECT.md frontmatter (first --- block, name field)\n  let projectName = 'unknown';\n  const projectMdPath = join(projectDir, 'PROJECT.md');\n  if (existsSync(projectMdPath)) {\n    const raw = readFileSync(projectMdPath, 'utf8');\n    const m = raw.match(\u002F^---[\\s\\S]*?project_name:\\s*(.+?)[\\s\\S]*?---\u002Fm);\n    if (m) projectName = m[1].trim();\n  }\n\n  \u002F\u002F Active session \u002F task from state\u002Fsession.json (key only, no body)\n  let activeSession = 'none';\n  let activeTask = 'none';\n  const sessionPtrPath = join(projectDir, 'state', 'session.json');\n  if (existsSync(sessionPtrPath)) {\n    try {\n      const ptr = JSON.parse(readFileSync(sessionPtrPath, 'utf8'));\n      if (ptr.active_session_id) {\n        activeSession = ptr.active_session_id;\n        const bundlePath = join(projectDir, 'state', 'sessions',\n          ptr.active_session_id, 'session.json');\n        if (existsSync(bundlePath)) {\n          const bundle = JSON.parse(readFileSync(bundlePath, 'utf8'));\n          activeTask = bundle.active_task ?? 'none';\n        }\n      }\n    } catch { \u002F* ignore *\u002F }\n  }\n\n  return [\n    '```',\n    `plugin_version: ${pluginVersion}`,\n    `os: ${platform()} ${release()}`,\n    `project: ${projectName}`,\n    `active_session: ${activeSession}`,\n    `active_task: ${activeTask}`,\n    '```',\n  ].join('\\n');\n}\n```\n\n### 5. Build the full issue body\n\n```js\n\u002F**\n * Compose and scrub the complete issue body.\n *\n * @param {{ title: string, repro: string, expected: string, actual: string,\n *            severity: string, evidence?: string, context: string }} opts\n * @returns {string}\n *\u002F\nexport function buildIssueBody({ title, repro, expected, actual,\n                                  severity, evidence, context }) {\n  const parts = [\n    `## What happened\\n${actual}`,\n    `## What was expected\\n${expected}`,\n    `## Steps to reproduce\\n${repro}`,\n    `## Severity\\n${severity}`,\n  ];\n  if (evidence) parts.push(`## Evidence\\n\\`\\`\\`\\n${evidence}\\n\\`\\`\\``);\n  parts.push(`## Auto-collected context\\n${context}`);\n\n  const raw = parts.join('\\n\\n');\n  return scrubSecrets(raw);  \u002F\u002F ALWAYS scrub before returning\n}\n```\n\n### 6. Top-level orchestrator: fileFrameworkBug\n\n```js\n\u002F**\n * The single entry point the command markdown invokes.\n * Injectable runner and fallbackWriter make it fully testable without disk\u002Fnetwork.\n *\n * @param {object} opts\n * @param {string} opts.title\n * @param {string} opts.body          pre-built, pre-scrubbed issue body\n * @param {string} opts.pluginRoot    CLAUDE_PLUGIN_ROOT\n * @param {string} opts.projectDir    CLAUDE_PROJECT_DIR\n * @param {string} [opts.repo]        default DEFAULT_REPO ('HexingBot\u002Fhivemind')\n * @param {function} [opts.runner]    spawnSync-compatible injectable\n * @param {function} [opts.fallbackWriter]  (path, content) => void, default fs.writeFileSync\n * @returns {{ filed: 'github'|'local', url?: string, path?: string, reason?: string }}\n *\u002F\nexport async function fileFrameworkBug({\n  title, body, pluginRoot, projectDir,\n  repo = DEFAULT_REPO,\n  runner,\n  fallbackWriter,\n}) {\n  \u002F\u002F `reason` names the ACTUAL cause of a fallback — gh can be present and\n  \u002F\u002F authenticated and still fail `gh issue create` (wrong repo, disabled\n  \u002F\u002F issues, etc.), so \"not available\" \u002F \"not authenticated\" must not be used\n  \u002F\u002F as a blanket explanation for every fallback.\n  let reason;\n  const { available, authenticated } = detectGh(runner);\n\n  if (!available) {\n    reason = 'gh CLI not found';\n  } else if (!authenticated) {\n    reason = 'gh not authenticated';\n  } else {\n    try {\n      const { url } = ghIssueCreate({ title, body, repo }, runner);\n      return { filed: 'github', url };\n    } catch (err) {\n      reason = err.message;\n    }\n  }\n\n  \u002F\u002F Fallback: write to a local file in the project's .claude\u002F directory\n  const fallbackDir = join(projectDir, '.claude', 'framework-bug-reports');\n  const ts = new Date().toISOString().replace(\u002F[:.]\u002Fg, '-');\n  const filePath = join(fallbackDir, `bug-report-${ts}.md`);\n  const content = `# ${title}\\n\\n${body}\\n`;\n\n  const writer = fallbackWriter ?? ((p, c) => {\n    mkdirSync(dirname(p), { recursive: true });\n    writeFileSync(p, c, 'utf8');\n  });\n  writer(filePath, content);\n\n  return { filed: 'local', path: filePath, reason };\n}\n```\n\n## Best Practices\n\n- **Do** inject the runner in every function that calls `gh`. It makes unit tests\n  instant and avoids real network calls.\n- **Do** scrub secrets (`scrubSecrets`) before building the body, not after.\n  Once the body is assembled it should already be clean.\n- **Do** check BOTH `gh --version` exit code AND `gh auth status` stderr for the\n  \"not logged into any GitHub hosts\" string (exit-code-always-0 bug).\n- **Do** use `--body-file -` (stdin) if the body may contain shell-unfriendly\n  characters (backticks, quotes, `$`).\n- **Do not** read `.claude\u002Fsettings.json` in the context collector — absence is the\n  defense against leaking project secrets via settings values.\n- **Do not** include the full session bundle body in the context block — only the\n  session ID and active task KEY (not its JSON).\n- **Do not** attempt to assign, label, or add the issue to a project in the initial\n  creation — those operations require extra OAuth scopes that downstream users may\n  not have.\n\n## Viability note: non-collaborator issue creation (CRITICAL)\n\nAny authenticated GitHub user with read access to a public repository CAN create\nissues on it via `gh issue create`. The GitHub REST API endpoint POST\n`\u002Frepos\u002F{owner}\u002F{repo}\u002Fissues` requires only a valid OAuth token with `repo` or\n`public_repo` scope — no collaborator status. This is confirmed by the official\ndocs: \"Any user with pull access to a repository can create an issue.\"\n\n**Therefore the feature IS viable for arbitrary downstream users of the plugin,\nnot only the maintainer.** The only cases where creation fails are:\n\n1. The repository owner has enabled interaction limits (collaborators-only or\n   existing-users-only modes) — very rare on open-source repos.\n2. The user's gh token lacks the `public_repo` scope — possible for fine-grained\n   PATs with restricted scopes.\n3. Issues are disabled on the repository.\n\nThe fallback to a local file handles all three cases gracefully.\n\n## Common Pitfalls\n\n- **gh auth status always exits 0 (gh \u003C= 2.42.1):** check stderr too (see Workflow 1).\n- **`gh issue create` prompts interactively when title or body is missing:** always\n  pass both `--title` and `--body` (or `--body-file`); omitting either drops into\n  an editor session that hangs non-interactive callers.\n- **`--body` with newlines on Windows PowerShell:** prefer `--body-file -` with stdin\n  piping if the body contains `\\n`. The `--body` flag works reliably on bash; on\n  PowerShell, newlines may be mangled by the shell before gh sees them.\n- **Issue URL parsing:** gh prints the URL as the LAST non-blank stdout line. Earlier\n  lines may include deprecation notices or config warnings. Always split on `\\n` and\n  take the last non-empty token.\n- **Rate limits:** GitHub allows 5000 requests per hour per authenticated user. Filing\n  one bug report consumes 1 request. No throttling logic needed.\n- **`env_secret` regex false positives:** env-var names like `DEBUG_LEVEL=verbose`\n  will not match (no `_TOKEN`\u002F`_SECRET`\u002Fetc. suffix); but `SOME_KEY=foo` WILL match\n  and be redacted. This is intentional — false positives are safe, false negatives\n  are not.\n\n## Verification\n\nAfter implementing `src\u002Fframework-bug-report.js`:\n\n1. Fast unit tests (pure logic, no disk): `npm test` — covers `scrubSecrets`,\n   `collectContext` with mock fs, `buildIssueBody`, `detectGh` with injected runner,\n   `ghIssueCreate` with injected runner (success + failure paths),\n   `fileFrameworkBug` with gh available\u002Fauth OK, gh unavailable, gh not authenticated.\n2. E2E \u002F integration (optional): spawn a real `gh --version` and `gh auth status`\n   in CI where GH_TOKEN is set. Skip if GH_TOKEN is absent.\n3. Dist parity: after adding the new entrypoint to `build-plugin.mjs`, run\n   `npm run build:plugin` and verify `dist\u002Freport-framework-bug.cjs` exists, then\n   run `npm run test:all` so `dist-parity.spec.js` validates the bundle.\n\n## References\n\n- [`references\u002Fgh-issue-create-flags.md`](references\u002Fgh-issue-create-flags.md) — full flag reference for `gh issue create`.\n- [`references\u002Fsecret-patterns.md`](references\u002Fsecret-patterns.md) — extended regex catalog for more token types.\n\n## Provenance\n\n- **Authored by:** Researcher subagent on behalf of TASK-010.\n- **Primary sources:**\n  - https:\u002F\u002Fcli.github.com\u002Fmanual\u002Fgh_issue_create\n  - https:\u002F\u002Fdocs.github.com\u002Fen\u002Frest\u002Fissues\u002Fissues#create-an-issue\n  - https:\u002F\u002Fcli.github.com\u002Fmanual\u002Fgh_auth_status\n  - https:\u002F\u002Fgithub.com\u002Fcli\u002Fcli\u002Fissues\u002F8845 (exit-code bug)\n- **Last verified:** 2026-06-23.\n",{"name":5,"description":7},"main","c8856147b7a3246a1e54b66126d093183805d1f3",".claude\u002Fskills\u002Fgh-cli-issue-reporting",0,"https:\u002F\u002Fgithub.com\u002FHexingBot\u002Fhivemind","https:\u002F\u002Fhivemind-ef84a.web.app","https:\u002F\u002Fgithub.com\u002FHexingBot","2026-10-10 00:50:01",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add HexingBot\u002Fhivemind --skill gh-cli-issue-reporting",{"tool":37,"command":38},"bunx","bunx skills add HexingBot\u002Fhivemind --skill gh-cli-issue-reporting",{"tool":40,"command":41},"pnpm","pnpm dlx skills add HexingBot\u002Fhivemind --skill gh-cli-issue-reporting","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHexingBot\u002Fhivemind\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fgh-cli-issue-reporting\u002FSKILL.md",true,[],[46,53,62,70,77,85],{"skillNo":47,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":50,"categories":51,"keywords":52,"publishedAt":18},"01M77MWBWY2AK0GJ91MMKAPZ0M","unknown-skill","A demo skill with no license signal at all, used to exercise the \"unknown\" classification branch of the human license gate (TASK-135).","https:\u002F\u002Fgithub.com\u002FHexingBot\u002Fhivemind\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fskills\u002Funknown-skill\u002FSKILL.md",[],[],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":57,"licenseFileUrl":58,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":18},"01M77MW9H43Z0ATZ15421K8J7D","spoofed-license-skill","A demo skill used to test TASK-150's SPDX-header-vs-LICENSE-file conflict surfacing.","GPL-3.0","https:\u002F\u002Fgithub.com\u002FHexingBot\u002Fhivemind\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fskills\u002Fspoofed-license-skill\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHexingBot\u002Fhivemind\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fskills\u002Fspoofed-license-skill\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":66,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":18},"01M77MW7715ENRZN6F01FDM81J","permissive-skill","A demo skill used to test assimilation of a permissively-licensed third party skill.","https:\u002F\u002Fgithub.com\u002FHexingBot\u002Fhivemind\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fskills\u002Fpermissive-skill\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHexingBot\u002Fhivemind\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fskills\u002Fpermissive-skill\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":18},"01M77MW3CRAPWETDAZT7E08BVS","malicious-skill","A fixture skill deliberately carrying risky content patterns, used only to exercise src\u002Fskill-scan.js (TASK-122). Never assimilated for real.","https:\u002F\u002Fgithub.com\u002FHexingBot\u002Fhivemind\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fskills\u002Fmalicious-skill\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":57,"licenseFileUrl":81,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":18},"01M77MW1RSWW1MTQGM9TY3X37G","copyleft-skill","A demo skill used to test the human license gate for a copyleft third party skill.","https:\u002F\u002Fgithub.com\u002FHexingBot\u002Fhivemind\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fskills\u002Fcopyleft-skill\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHexingBot\u002Fhivemind\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fskills\u002Fcopyleft-skill\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":18},"01M77MVWT1EVEJ8ZYZTCG4CENE","watch","Watch a video (URL or local path). Downloads with yt-dlp, extracts auto-scaled frames with ffmpeg, pulls the transcript from captions (or Whisper API fallback), and hands the result to Claude so it can answer questions about what's in the video. (assimilated for Hivemind)","https:\u002F\u002Fgithub.com\u002FHexingBot\u002Fhivemind\u002Fblob\u002Fmain\u002Fskills\u002Fwatch\u002FSKILL.md",[],[]]