@ghx-dev/core 0.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +212 -0
- package/dist/agent-interface/prompt/main-skill.d.ts +3 -0
- package/dist/agent-interface/prompt/main-skill.js +7 -0
- package/dist/agent-interface/prompt/main-skill.js.map +1 -0
- package/dist/agent-interface/tools/execute-tool.d.ts +16 -0
- package/dist/agent-interface/tools/execute-tool.js +7 -0
- package/dist/agent-interface/tools/execute-tool.js.map +1 -0
- package/dist/agent-interface/tools/explain-tool.d.ts +11 -0
- package/dist/agent-interface/tools/explain-tool.js +9 -0
- package/dist/agent-interface/tools/explain-tool.js.map +1 -0
- package/dist/agent-interface/tools/list-capabilities-tool.d.ts +7 -0
- package/dist/agent-interface/tools/list-capabilities-tool.js +9 -0
- package/dist/agent-interface/tools/list-capabilities-tool.js.map +1 -0
- package/dist/agent.d.ts +7 -0
- package/dist/agent.js +21 -0
- package/dist/agent.js.map +1 -0
- package/dist/chunk-2W4L5YCC.js +116 -0
- package/dist/chunk-2W4L5YCC.js.map +1 -0
- package/dist/chunk-3RAT5BCB.js +584 -0
- package/dist/chunk-3RAT5BCB.js.map +1 -0
- package/dist/chunk-3RJCF42N.js +16 -0
- package/dist/chunk-3RJCF42N.js.map +1 -0
- package/dist/chunk-573MDG3I.js +18 -0
- package/dist/chunk-573MDG3I.js.map +1 -0
- package/dist/chunk-5JRLVOF2.js +50 -0
- package/dist/chunk-5JRLVOF2.js.map +1 -0
- package/dist/chunk-B6RLMKS4.js +41 -0
- package/dist/chunk-B6RLMKS4.js.map +1 -0
- package/dist/chunk-BJHVAFTN.js +42 -0
- package/dist/chunk-BJHVAFTN.js.map +1 -0
- package/dist/chunk-D746VR3B.js +38 -0
- package/dist/chunk-D746VR3B.js.map +1 -0
- package/dist/chunk-DJIEG6K7.js +20 -0
- package/dist/chunk-DJIEG6K7.js.map +1 -0
- package/dist/chunk-DLKIQBK6.js +106 -0
- package/dist/chunk-DLKIQBK6.js.map +1 -0
- package/dist/chunk-EBRDO4Y6.js +31 -0
- package/dist/chunk-EBRDO4Y6.js.map +1 -0
- package/dist/chunk-FXN6IIT5.js +14 -0
- package/dist/chunk-FXN6IIT5.js.map +1 -0
- package/dist/chunk-GPU4P7UG.js +92 -0
- package/dist/chunk-GPU4P7UG.js.map +1 -0
- package/dist/chunk-MMG6CIKK.js +44 -0
- package/dist/chunk-MMG6CIKK.js.map +1 -0
- package/dist/chunk-MT4U5DYD.js +88 -0
- package/dist/chunk-MT4U5DYD.js.map +1 -0
- package/dist/chunk-NFF5VF4U.js +28 -0
- package/dist/chunk-NFF5VF4U.js.map +1 -0
- package/dist/chunk-Q4RTT3DV.js +209 -0
- package/dist/chunk-Q4RTT3DV.js.map +1 -0
- package/dist/chunk-QEAMC4IJ.js +34 -0
- package/dist/chunk-QEAMC4IJ.js.map +1 -0
- package/dist/chunk-QX34GTH6.js +30 -0
- package/dist/chunk-QX34GTH6.js.map +1 -0
- package/dist/chunk-QZZC53HF.js +38 -0
- package/dist/chunk-QZZC53HF.js.map +1 -0
- package/dist/chunk-RUQXGZ35.js +34 -0
- package/dist/chunk-RUQXGZ35.js.map +1 -0
- package/dist/chunk-TCLMLVUQ.js +38 -0
- package/dist/chunk-TCLMLVUQ.js.map +1 -0
- package/dist/chunk-TDTKOJKN.js +52 -0
- package/dist/chunk-TDTKOJKN.js.map +1 -0
- package/dist/chunk-UGWIZ3RI.js +7 -0
- package/dist/chunk-UGWIZ3RI.js.map +1 -0
- package/dist/chunk-UOJWOHRM.js +16 -0
- package/dist/chunk-UOJWOHRM.js.map +1 -0
- package/dist/chunk-VD5NXQP7.js +42 -0
- package/dist/chunk-VD5NXQP7.js.map +1 -0
- package/dist/chunk-W2TKG2UL.js +37 -0
- package/dist/chunk-W2TKG2UL.js.map +1 -0
- package/dist/chunk-W6ROKCY5.js +28 -0
- package/dist/chunk-W6ROKCY5.js.map +1 -0
- package/dist/chunk-WYSY75U7.js +156 -0
- package/dist/chunk-WYSY75U7.js.map +1 -0
- package/dist/chunk-YNNDBMNR.js +113 -0
- package/dist/chunk-YNNDBMNR.js.map +1 -0
- package/dist/chunk-YNQNHCRS.js +198 -0
- package/dist/chunk-YNQNHCRS.js.map +1 -0
- package/dist/chunk-YQDQX4BT.js +624 -0
- package/dist/chunk-YQDQX4BT.js.map +1 -0
- package/dist/cli/commands/capabilities-explain.d.ts +3 -0
- package/dist/cli/commands/capabilities-explain.js +10 -0
- package/dist/cli/commands/capabilities-explain.js.map +1 -0
- package/dist/cli/commands/capabilities-list.d.ts +3 -0
- package/dist/cli/commands/capabilities-list.js +10 -0
- package/dist/cli/commands/capabilities-list.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +3 -0
- package/dist/cli/commands/doctor.js +7 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/routes.d.ts +3 -0
- package/dist/cli/commands/routes.js +7 -0
- package/dist/cli/commands/routes.js.map +1 -0
- package/dist/cli/commands/run.d.ts +3 -0
- package/dist/cli/commands/run.js +31 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/commands/setup.d.ts +3 -0
- package/dist/cli/commands/setup.js +7 -0
- package/dist/cli/commands/setup.js.map +1 -0
- package/dist/cli/formatters/json.d.ts +3 -0
- package/dist/cli/formatters/json.js +8 -0
- package/dist/cli/formatters/json.js.map +1 -0
- package/dist/cli/formatters/table.d.ts +3 -0
- package/dist/cli/formatters/table.js +8 -0
- package/dist/cli/formatters/table.js.map +1 -0
- package/dist/cli/index.d.ts +4 -0
- package/dist/cli/index.js +118 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/contracts/envelope.d.ts +43 -0
- package/dist/core/contracts/envelope.js +1 -0
- package/dist/core/contracts/envelope.js.map +1 -0
- package/dist/core/contracts/task.d.ts +7 -0
- package/dist/core/contracts/task.js +1 -0
- package/dist/core/contracts/task.js.map +1 -0
- package/dist/core/contracts/tasks/check_run.annotations.list.d.ts +5 -0
- package/dist/core/contracts/tasks/check_run.annotations.list.js +8 -0
- package/dist/core/contracts/tasks/check_run.annotations.list.js.map +1 -0
- package/dist/core/contracts/tasks/issue.comments.list.d.ts +5 -0
- package/dist/core/contracts/tasks/issue.comments.list.js +8 -0
- package/dist/core/contracts/tasks/issue.comments.list.js.map +1 -0
- package/dist/core/contracts/tasks/issue.list.d.ts +5 -0
- package/dist/core/contracts/tasks/issue.list.js +8 -0
- package/dist/core/contracts/tasks/issue.list.js.map +1 -0
- package/dist/core/contracts/tasks/issue.view.d.ts +5 -0
- package/dist/core/contracts/tasks/issue.view.js +8 -0
- package/dist/core/contracts/tasks/issue.view.js.map +1 -0
- package/dist/core/contracts/tasks/pr.checks.get_failed.d.ts +5 -0
- package/dist/core/contracts/tasks/pr.checks.get_failed.js +8 -0
- package/dist/core/contracts/tasks/pr.checks.get_failed.js.map +1 -0
- package/dist/core/contracts/tasks/pr.comment.reply.d.ts +5 -0
- package/dist/core/contracts/tasks/pr.comment.reply.js +8 -0
- package/dist/core/contracts/tasks/pr.comment.reply.js.map +1 -0
- package/dist/core/contracts/tasks/pr.comment.resolve.d.ts +5 -0
- package/dist/core/contracts/tasks/pr.comment.resolve.js +8 -0
- package/dist/core/contracts/tasks/pr.comment.resolve.js.map +1 -0
- package/dist/core/contracts/tasks/pr.comment.unresolve.d.ts +5 -0
- package/dist/core/contracts/tasks/pr.comment.unresolve.js +8 -0
- package/dist/core/contracts/tasks/pr.comment.unresolve.js.map +1 -0
- package/dist/core/contracts/tasks/pr.comments.list.d.ts +5 -0
- package/dist/core/contracts/tasks/pr.comments.list.js +8 -0
- package/dist/core/contracts/tasks/pr.comments.list.js.map +1 -0
- package/dist/core/contracts/tasks/pr.diff.list_files.d.ts +5 -0
- package/dist/core/contracts/tasks/pr.diff.list_files.js +8 -0
- package/dist/core/contracts/tasks/pr.diff.list_files.js.map +1 -0
- package/dist/core/contracts/tasks/pr.list.d.ts +5 -0
- package/dist/core/contracts/tasks/pr.list.js +8 -0
- package/dist/core/contracts/tasks/pr.list.js.map +1 -0
- package/dist/core/contracts/tasks/pr.mergeability.view.d.ts +5 -0
- package/dist/core/contracts/tasks/pr.mergeability.view.js +8 -0
- package/dist/core/contracts/tasks/pr.mergeability.view.js.map +1 -0
- package/dist/core/contracts/tasks/pr.ready_for_review.set.d.ts +5 -0
- package/dist/core/contracts/tasks/pr.ready_for_review.set.js +8 -0
- package/dist/core/contracts/tasks/pr.ready_for_review.set.js.map +1 -0
- package/dist/core/contracts/tasks/pr.reviews.list.d.ts +5 -0
- package/dist/core/contracts/tasks/pr.reviews.list.js +8 -0
- package/dist/core/contracts/tasks/pr.reviews.list.js.map +1 -0
- package/dist/core/contracts/tasks/pr.status.checks.d.ts +5 -0
- package/dist/core/contracts/tasks/pr.status.checks.js +8 -0
- package/dist/core/contracts/tasks/pr.status.checks.js.map +1 -0
- package/dist/core/contracts/tasks/pr.view.d.ts +5 -0
- package/dist/core/contracts/tasks/pr.view.js +8 -0
- package/dist/core/contracts/tasks/pr.view.js.map +1 -0
- package/dist/core/contracts/tasks/repo.view.d.ts +5 -0
- package/dist/core/contracts/tasks/repo.view.js +8 -0
- package/dist/core/contracts/tasks/repo.view.js.map +1 -0
- package/dist/core/contracts/tasks/workflow_job.logs.analyze.d.ts +5 -0
- package/dist/core/contracts/tasks/workflow_job.logs.analyze.js +8 -0
- package/dist/core/contracts/tasks/workflow_job.logs.analyze.js.map +1 -0
- package/dist/core/contracts/tasks/workflow_job.logs.get.d.ts +5 -0
- package/dist/core/contracts/tasks/workflow_job.logs.get.js +8 -0
- package/dist/core/contracts/tasks/workflow_job.logs.get.js.map +1 -0
- package/dist/core/contracts/tasks/workflow_run.jobs.list.d.ts +5 -0
- package/dist/core/contracts/tasks/workflow_run.jobs.list.js +8 -0
- package/dist/core/contracts/tasks/workflow_run.jobs.list.js.map +1 -0
- package/dist/core/contracts/tasks/workflow_runs.list.d.ts +5 -0
- package/dist/core/contracts/tasks/workflow_runs.list.js +8 -0
- package/dist/core/contracts/tasks/workflow_runs.list.js.map +1 -0
- package/dist/core/errors/codes.d.ts +13 -0
- package/dist/core/errors/codes.js +7 -0
- package/dist/core/errors/codes.js.map +1 -0
- package/dist/core/errors/map-error.d.ts +5 -0
- package/dist/core/errors/map-error.js +8 -0
- package/dist/core/errors/map-error.js.map +1 -0
- package/dist/core/errors/retryability.d.ts +3 -0
- package/dist/core/errors/retryability.js +8 -0
- package/dist/core/errors/retryability.js.map +1 -0
- package/dist/core/execute/execute.d.ts +28 -0
- package/dist/core/execute/execute.js +11 -0
- package/dist/core/execute/execute.js.map +1 -0
- package/dist/core/execution/adapters/cli-adapter.d.ts +22 -0
- package/dist/core/execution/adapters/cli-adapter.js +69 -0
- package/dist/core/execution/adapters/cli-adapter.js.map +1 -0
- package/dist/core/execution/adapters/cli-capability-adapter.d.ts +16 -0
- package/dist/core/execution/adapters/cli-capability-adapter.js +11 -0
- package/dist/core/execution/adapters/cli-capability-adapter.js.map +1 -0
- package/dist/core/execution/adapters/graphql-adapter.d.ts +25 -0
- package/dist/core/execution/adapters/graphql-adapter.js +44 -0
- package/dist/core/execution/adapters/graphql-adapter.js.map +1 -0
- package/dist/core/execution/adapters/graphql-capability-adapter.d.ts +20 -0
- package/dist/core/execution/adapters/graphql-capability-adapter.js +11 -0
- package/dist/core/execution/adapters/graphql-capability-adapter.js.map +1 -0
- package/dist/core/execution/adapters/rest-adapter.d.ts +3 -0
- package/dist/core/execution/adapters/rest-adapter.js +8 -0
- package/dist/core/execution/adapters/rest-adapter.js.map +1 -0
- package/dist/core/execution/cli/safe-runner.d.ts +12 -0
- package/dist/core/execution/cli/safe-runner.js +7 -0
- package/dist/core/execution/cli/safe-runner.js.map +1 -0
- package/dist/core/execution/normalizer.d.ts +13 -0
- package/dist/core/execution/normalizer.js +9 -0
- package/dist/core/execution/normalizer.js.map +1 -0
- package/dist/core/execution/preflight.d.ts +24 -0
- package/dist/core/execution/preflight.js +8 -0
- package/dist/core/execution/preflight.js.map +1 -0
- package/dist/core/registry/cards/check_run.annotations.list.yaml +35 -0
- package/dist/core/registry/cards/issue.comments.list.yaml +48 -0
- package/dist/core/registry/cards/issue.list.yaml +48 -0
- package/dist/core/registry/cards/issue.view.yaml +32 -0
- package/dist/core/registry/cards/pr.checks.get_failed.yaml +42 -0
- package/dist/core/registry/cards/pr.comment.reply.yaml +23 -0
- package/dist/core/registry/cards/pr.comment.resolve.yaml +22 -0
- package/dist/core/registry/cards/pr.comment.unresolve.yaml +22 -0
- package/dist/core/registry/cards/pr.comments.list.yaml +98 -0
- package/dist/core/registry/cards/pr.diff.list_files.yaml +43 -0
- package/dist/core/registry/cards/pr.list.yaml +48 -0
- package/dist/core/registry/cards/pr.mergeability.view.yaml +27 -0
- package/dist/core/registry/cards/pr.ready_for_review.set.yaml +24 -0
- package/dist/core/registry/cards/pr.reviews.list.yaml +47 -0
- package/dist/core/registry/cards/pr.status.checks.yaml +42 -0
- package/dist/core/registry/cards/pr.view.yaml +32 -0
- package/dist/core/registry/cards/repo.view.yaml +34 -0
- package/dist/core/registry/cards/workflow_job.logs.analyze.yaml +33 -0
- package/dist/core/registry/cards/workflow_job.logs.get.yaml +24 -0
- package/dist/core/registry/cards/workflow_run.jobs.list.yaml +35 -0
- package/dist/core/registry/cards/workflow_runs.list.yaml +45 -0
- package/dist/core/registry/index.d.ts +15 -0
- package/dist/core/registry/index.js +12 -0
- package/dist/core/registry/index.js.map +1 -0
- package/dist/core/registry/operation-card-schema.d.ts +167 -0
- package/dist/core/registry/operation-card-schema.js +7 -0
- package/dist/core/registry/operation-card-schema.js.map +1 -0
- package/dist/core/registry/schema-validator.d.ts +16 -0
- package/dist/core/registry/schema-validator.js +9 -0
- package/dist/core/registry/schema-validator.js.map +1 -0
- package/dist/core/registry/types.d.ts +51 -0
- package/dist/core/registry/types.js +1 -0
- package/dist/core/registry/types.js.map +1 -0
- package/dist/core/routing/capability-registry.d.ts +8 -0
- package/dist/core/routing/capability-registry.js +15 -0
- package/dist/core/routing/capability-registry.js.map +1 -0
- package/dist/core/routing/engine.d.ts +32 -0
- package/dist/core/routing/engine.js +23 -0
- package/dist/core/routing/engine.js.map +1 -0
- package/dist/core/routing/policy.d.ts +3 -0
- package/dist/core/routing/policy.js +7 -0
- package/dist/core/routing/policy.js.map +1 -0
- package/dist/core/routing/reason-codes.d.ts +4 -0
- package/dist/core/routing/reason-codes.js +15 -0
- package/dist/core/routing/reason-codes.js.map +1 -0
- package/dist/core/telemetry/logger.d.ts +8 -0
- package/dist/core/telemetry/logger.js +9 -0
- package/dist/core/telemetry/logger.js.map +1 -0
- package/dist/core/telemetry/metrics.d.ts +7 -0
- package/dist/core/telemetry/metrics.js +1 -0
- package/dist/core/telemetry/metrics.js.map +1 -0
- package/dist/gql/client.d.ts +183 -0
- package/dist/gql/client.js +17 -0
- package/dist/gql/client.js.map +1 -0
- package/dist/gql/generated/common-types.d.ts +36 -0
- package/dist/gql/generated/common-types.js +1 -0
- package/dist/gql/generated/common-types.js.map +1 -0
- package/dist/gql/operations/issue-comments-list.generated.d.ts +59 -0
- package/dist/gql/operations/issue-comments-list.generated.js +9 -0
- package/dist/gql/operations/issue-comments-list.generated.js.map +1 -0
- package/dist/gql/operations/issue-list.generated.d.ts +40 -0
- package/dist/gql/operations/issue-list.generated.js +9 -0
- package/dist/gql/operations/issue-list.generated.js.map +1 -0
- package/dist/gql/operations/issue-view.generated.d.ts +31 -0
- package/dist/gql/operations/issue-view.generated.js +9 -0
- package/dist/gql/operations/issue-view.generated.js.map +1 -0
- package/dist/gql/operations/pr-comment-reply.generated.d.ts +26 -0
- package/dist/gql/operations/pr-comment-reply.generated.js +25 -0
- package/dist/gql/operations/pr-comment-reply.generated.js.map +1 -0
- package/dist/gql/operations/pr-comment-resolve.generated.d.ts +26 -0
- package/dist/gql/operations/pr-comment-resolve.generated.js +24 -0
- package/dist/gql/operations/pr-comment-resolve.generated.js.map +1 -0
- package/dist/gql/operations/pr-comment-unresolve.generated.d.ts +26 -0
- package/dist/gql/operations/pr-comment-unresolve.generated.js +24 -0
- package/dist/gql/operations/pr-comment-unresolve.generated.js.map +1 -0
- package/dist/gql/operations/pr-comments-list.generated.d.ts +84 -0
- package/dist/gql/operations/pr-comments-list.generated.js +58 -0
- package/dist/gql/operations/pr-comments-list.generated.js.map +1 -0
- package/dist/gql/operations/pr-diff-list-files.generated.d.ts +42 -0
- package/dist/gql/operations/pr-diff-list-files.generated.js +9 -0
- package/dist/gql/operations/pr-diff-list-files.generated.js.map +1 -0
- package/dist/gql/operations/pr-list.generated.d.ts +40 -0
- package/dist/gql/operations/pr-list.generated.js +9 -0
- package/dist/gql/operations/pr-list.generated.js.map +1 -0
- package/dist/gql/operations/pr-reviews-list.generated.d.ts +64 -0
- package/dist/gql/operations/pr-reviews-list.generated.js +9 -0
- package/dist/gql/operations/pr-reviews-list.generated.js.map +1 -0
- package/dist/gql/operations/pr-view.generated.d.ts +31 -0
- package/dist/gql/operations/pr-view.generated.js +9 -0
- package/dist/gql/operations/pr-view.generated.js.map +1 -0
- package/dist/gql/operations/repo-view.generated.d.ts +33 -0
- package/dist/gql/operations/repo-view.generated.js +9 -0
- package/dist/gql/operations/repo-view.generated.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/shared/constants.d.ts +3 -0
- package/dist/shared/constants.js +6 -0
- package/dist/shared/constants.js.map +1 -0
- package/dist/shared/types.d.ts +3 -0
- package/dist/shared/types.js +1 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/shared/utils.d.ts +3 -0
- package/dist/shared/utils.js +8 -0
- package/dist/shared/utils.js.map +1 -0
- package/package.json +79 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/commands/setup.ts"],"sourcesContent":["import { access, appendFile, mkdir, readFile, writeFile } from \"node:fs/promises\"\nimport { homedir } from \"node:os\"\nimport { dirname, join } from \"node:path\"\nimport readline from \"node:readline/promises\"\n\nimport Ajv from \"ajv\"\n\ntype SetupScope = \"user\" | \"project\"\n\ntype SetupOptions = {\n scope: SetupScope\n assumeYes: boolean\n dryRun: boolean\n verifyOnly: boolean\n track: boolean\n}\n\nconst ajv = new Ajv({ allErrors: true, strict: false })\n\nconst setupOptionsSchema = {\n type: \"object\",\n additionalProperties: false,\n required: [\"scope\", \"assumeYes\", \"dryRun\", \"verifyOnly\", \"track\"],\n properties: {\n scope: {\n type: \"string\",\n enum: [\"user\", \"project\"]\n },\n assumeYes: { type: \"boolean\" },\n dryRun: { type: \"boolean\" },\n verifyOnly: { type: \"boolean\" },\n track: { type: \"boolean\" }\n }\n} as const\n\nconst validateSetupOptions = ajv.compile(setupOptionsSchema)\n\nconst SKILL_CONTENT = `# ghx skill\n\nUse ghx capabilities to execute GitHub operations through a stable capability interface.\n\nQuick commands:\n- ghx capabilities list\n- ghx capabilities explain <capability_id>\n- ghx run <capability_id> --input '<json>'\n\nExample:\n- ghx run repo.view --input '{\"owner\":\"aryeko\",\"name\":\"ghx\"}'\n`\n\nfunction usage(): string {\n return \"Usage: ghx setup --scope <user|project> [--yes] [--dry-run] [--verify] [--track]\"\n}\n\nfunction parseScope(argv: string[]): SetupScope | undefined {\n const inline = argv.find((arg) => arg.startsWith(\"--scope=\"))\n if (inline) {\n const raw = inline.slice(\"--scope=\".length)\n if (raw === \"user\" || raw === \"project\") {\n return raw\n }\n return undefined\n }\n\n const scopeIndex = argv.findIndex((arg) => arg === \"--scope\")\n if (scopeIndex < 0) {\n return undefined\n }\n\n const value = argv[scopeIndex + 1]\n if (value === \"user\" || value === \"project\") {\n return value\n }\n\n return undefined\n}\n\nfunction parseArgs(argv: string[]): SetupOptions | null {\n const scope = parseScope(argv)\n if (!scope) {\n return null\n }\n\n const options: SetupOptions = {\n scope,\n assumeYes: argv.includes(\"--yes\"),\n dryRun: argv.includes(\"--dry-run\"),\n verifyOnly: argv.includes(\"--verify\"),\n track: argv.includes(\"--track\")\n }\n\n if (!validateSetupOptions(options)) {\n return null\n }\n\n return options\n}\n\nfunction resolveSkillPath(scope: SetupScope): string {\n const base = scope === \"user\" ? homedir() : process.cwd()\n return join(base, \".agents\", \"skill\", \"ghx\", \"SKILL.md\")\n}\n\nfunction resolveTrackingPath(): string {\n return join(homedir(), \".agents\", \"ghx\", \"setup-events.jsonl\")\n}\n\nasync function writeTrackingEvent(options: {\n track: boolean\n scope: SetupScope\n mode: \"apply\"\n success: boolean\n}): Promise<void> {\n if (!options.track) {\n return\n }\n\n const trackingPath = resolveTrackingPath()\n await mkdir(join(homedir(), \".agents\", \"ghx\"), { recursive: true })\n await appendFile(\n trackingPath,\n `${JSON.stringify({\n command: \"setup\",\n scope: options.scope,\n mode: options.mode,\n success: options.success,\n timestamp: new Date().toISOString()\n })}\\n`,\n \"utf8\"\n )\n}\n\nasync function confirmOverwrite(skillPath: string): Promise<boolean> {\n if (!process.stdin.isTTY || !process.stdout.isTTY) {\n return false\n }\n\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n })\n\n try {\n const answer = await rl.question(`Skill already exists at ${skillPath}. Overwrite? [y/N] `)\n const normalized = answer.trim().toLowerCase()\n return normalized === \"y\" || normalized === \"yes\"\n } finally {\n rl.close()\n }\n}\n\nasync function verifySkill(skillPath: string): Promise<boolean> {\n try {\n const content = await readFile(skillPath, \"utf8\")\n return content.includes(\"ghx capabilities\")\n } catch (error) {\n if (typeof error === \"object\" && error !== null && \"code\" in error) {\n if ((error as { code?: string }).code === \"ENOENT\") {\n return false\n }\n }\n\n throw error\n }\n}\n\nasync function skillFileExists(skillPath: string): Promise<boolean> {\n try {\n await access(skillPath)\n return true\n } catch (error) {\n if (typeof error === \"object\" && error !== null && \"code\" in error) {\n if ((error as { code?: string }).code === \"ENOENT\") {\n return false\n }\n }\n\n throw error\n }\n}\n\nexport async function setupCommand(argv: string[] = []): Promise<number> {\n const parsed = parseArgs(argv)\n if (!parsed) {\n process.stderr.write(`${usage()}\\n`)\n return 1\n }\n\n const skillPath = resolveSkillPath(parsed.scope)\n\n try {\n if (parsed.verifyOnly) {\n const ok = await verifySkill(skillPath)\n if (!ok) {\n process.stderr.write(`Verify failed: skill not installed at ${skillPath}\\n`)\n return 1\n }\n\n process.stdout.write(`Verify passed: skill installed at ${skillPath}\\n`)\n return 0\n }\n\n if (parsed.dryRun) {\n process.stdout.write(`Dry run: would write ${skillPath}\\n`)\n return 0\n }\n\n const alreadyExists = await skillFileExists(skillPath)\n if (alreadyExists && !parsed.assumeYes) {\n const approved = await confirmOverwrite(skillPath)\n if (!approved) {\n process.stderr.write(\n `Skill already exists at ${skillPath}. Re-run with --yes or confirm overwrite interactively.\\n`\n )\n await writeTrackingEvent({ track: parsed.track, scope: parsed.scope, mode: \"apply\", success: false })\n return 1\n }\n }\n\n await mkdir(dirname(skillPath), { recursive: true })\n await writeFile(skillPath, SKILL_CONTENT, \"utf8\")\n\n process.stdout.write(`Setup complete: wrote ${skillPath}\\n`)\n process.stdout.write(\"Try: ghx capabilities list\\n\")\n await writeTrackingEvent({ track: parsed.track, scope: parsed.scope, mode: \"apply\", success: true })\n return 0\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n process.stderr.write(`Setup failed: ${message}\\n`)\n return 1\n }\n}\n"],"mappings":";AAAA,SAAS,QAAQ,YAAY,OAAO,UAAU,iBAAiB;AAC/D,SAAS,eAAe;AACxB,SAAS,SAAS,YAAY;AAC9B,OAAO,cAAc;AAErB,OAAO,SAAS;AAYhB,IAAM,MAAM,IAAI,IAAI,EAAE,WAAW,MAAM,QAAQ,MAAM,CAAC;AAEtD,IAAM,qBAAqB;AAAA,EACzB,MAAM;AAAA,EACN,sBAAsB;AAAA,EACtB,UAAU,CAAC,SAAS,aAAa,UAAU,cAAc,OAAO;AAAA,EAChE,YAAY;AAAA,IACV,OAAO;AAAA,MACL,MAAM;AAAA,MACN,MAAM,CAAC,QAAQ,SAAS;AAAA,IAC1B;AAAA,IACA,WAAW,EAAE,MAAM,UAAU;AAAA,IAC7B,QAAQ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MAAM,yBAAyB,SAAS;AAAA,CAAI;AAC3D,YAAQ,OAAO,MAAM,8BAA8B;AACnD,UAAM,mBAAmB,EAAE,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,MAAM,SAAS,SAAS,KAAK,CAAC;AACnG,WAAO;AAAA,EACT,SAAS,OAAO;AACd,UAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,YAAQ,OAAO,MAAM,iBAAiB,OAAO;AAAA,CAAI;AACjD,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,624 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getSdk as getSdk7
|
|
3
|
+
} from "./chunk-NFF5VF4U.js";
|
|
4
|
+
import {
|
|
5
|
+
getSdk as getSdk8
|
|
6
|
+
} from "./chunk-EBRDO4Y6.js";
|
|
7
|
+
import {
|
|
8
|
+
getSdk as getSdk3
|
|
9
|
+
} from "./chunk-W6ROKCY5.js";
|
|
10
|
+
import {
|
|
11
|
+
getSdk as getSdk4
|
|
12
|
+
} from "./chunk-RUQXGZ35.js";
|
|
13
|
+
import {
|
|
14
|
+
getSdk as getSdk6
|
|
15
|
+
} from "./chunk-TCLMLVUQ.js";
|
|
16
|
+
import {
|
|
17
|
+
getSdk as getSdk5
|
|
18
|
+
} from "./chunk-VD5NXQP7.js";
|
|
19
|
+
import {
|
|
20
|
+
getSdk
|
|
21
|
+
} from "./chunk-QZZC53HF.js";
|
|
22
|
+
import {
|
|
23
|
+
getSdk as getSdk2
|
|
24
|
+
} from "./chunk-D746VR3B.js";
|
|
25
|
+
|
|
26
|
+
// src/gql/client.ts
|
|
27
|
+
import { print } from "graphql";
|
|
28
|
+
function assertRepoInput(input) {
|
|
29
|
+
if (input.owner.trim().length === 0 || input.name.trim().length === 0) {
|
|
30
|
+
throw new Error("Repository owner and name are required");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function assertIssueInput(input) {
|
|
34
|
+
if (input.owner.trim().length === 0 || input.name.trim().length === 0) {
|
|
35
|
+
throw new Error("Repository owner and name are required");
|
|
36
|
+
}
|
|
37
|
+
if (!Number.isInteger(input.issueNumber) || input.issueNumber <= 0) {
|
|
38
|
+
throw new Error("Issue number must be a positive integer");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function assertIssueListInput(input) {
|
|
42
|
+
if (input.owner.trim().length === 0 || input.name.trim().length === 0) {
|
|
43
|
+
throw new Error("Repository owner and name are required");
|
|
44
|
+
}
|
|
45
|
+
if (!Number.isInteger(input.first) || input.first <= 0) {
|
|
46
|
+
throw new Error("List page size must be a positive integer");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function assertIssueCommentsListInput(input) {
|
|
50
|
+
if (input.owner.trim().length === 0 || input.name.trim().length === 0) {
|
|
51
|
+
throw new Error("Repository owner and name are required");
|
|
52
|
+
}
|
|
53
|
+
if (!Number.isInteger(input.issueNumber) || input.issueNumber <= 0) {
|
|
54
|
+
throw new Error("Issue number must be a positive integer");
|
|
55
|
+
}
|
|
56
|
+
if (!Number.isInteger(input.first) || input.first <= 0) {
|
|
57
|
+
throw new Error("List page size must be a positive integer");
|
|
58
|
+
}
|
|
59
|
+
if (input.after !== void 0 && input.after !== null && typeof input.after !== "string") {
|
|
60
|
+
throw new Error("After cursor must be a string");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function assertPrInput(input) {
|
|
64
|
+
if (input.owner.trim().length === 0 || input.name.trim().length === 0) {
|
|
65
|
+
throw new Error("Repository owner and name are required");
|
|
66
|
+
}
|
|
67
|
+
if (!Number.isInteger(input.prNumber) || input.prNumber <= 0) {
|
|
68
|
+
throw new Error("PR number must be a positive integer");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function assertPrListInput(input) {
|
|
72
|
+
if (input.owner.trim().length === 0 || input.name.trim().length === 0) {
|
|
73
|
+
throw new Error("Repository owner and name are required");
|
|
74
|
+
}
|
|
75
|
+
if (!Number.isInteger(input.first) || input.first <= 0) {
|
|
76
|
+
throw new Error("List page size must be a positive integer");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function assertPrReviewsListInput(input) {
|
|
80
|
+
if (typeof input.owner !== "string" || typeof input.name !== "string" || input.owner.trim().length === 0 || input.name.trim().length === 0) {
|
|
81
|
+
throw new Error("Repository owner and name are required");
|
|
82
|
+
}
|
|
83
|
+
if (!Number.isInteger(input.prNumber) || input.prNumber <= 0) {
|
|
84
|
+
throw new Error("PR number must be a positive integer");
|
|
85
|
+
}
|
|
86
|
+
if (!Number.isInteger(input.first) || input.first <= 0) {
|
|
87
|
+
throw new Error("List page size must be a positive integer");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function assertPrDiffListFilesInput(input) {
|
|
91
|
+
if (typeof input.owner !== "string" || typeof input.name !== "string" || input.owner.trim().length === 0 || input.name.trim().length === 0) {
|
|
92
|
+
throw new Error("Repository owner and name are required");
|
|
93
|
+
}
|
|
94
|
+
if (!Number.isInteger(input.prNumber) || input.prNumber <= 0) {
|
|
95
|
+
throw new Error("PR number must be a positive integer");
|
|
96
|
+
}
|
|
97
|
+
if (!Number.isInteger(input.first) || input.first <= 0) {
|
|
98
|
+
throw new Error("List page size must be a positive integer");
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function assertPrCommentsListInput(input) {
|
|
102
|
+
if (typeof input.owner !== "string" || typeof input.name !== "string" || input.owner.trim().length === 0 || input.name.trim().length === 0) {
|
|
103
|
+
throw new Error("Repository owner and name are required");
|
|
104
|
+
}
|
|
105
|
+
if (!Number.isInteger(input.prNumber) || input.prNumber <= 0) {
|
|
106
|
+
throw new Error("PR number must be a positive integer");
|
|
107
|
+
}
|
|
108
|
+
if (!Number.isInteger(input.first) || input.first <= 0) {
|
|
109
|
+
throw new Error("List page size must be a positive integer");
|
|
110
|
+
}
|
|
111
|
+
if (input.unresolvedOnly !== void 0 && typeof input.unresolvedOnly !== "boolean") {
|
|
112
|
+
throw new Error("unresolvedOnly must be a boolean");
|
|
113
|
+
}
|
|
114
|
+
if (input.includeOutdated !== void 0 && typeof input.includeOutdated !== "boolean") {
|
|
115
|
+
throw new Error("includeOutdated must be a boolean");
|
|
116
|
+
}
|
|
117
|
+
if (input.after !== void 0 && input.after !== null && typeof input.after !== "string") {
|
|
118
|
+
throw new Error("After cursor must be a string");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
var PR_COMMENTS_LIST_QUERY = `
|
|
122
|
+
query PrCommentsList($owner: String!, $name: String!, $prNumber: Int!, $first: Int!, $after: String) {
|
|
123
|
+
repository(owner: $owner, name: $name) {
|
|
124
|
+
pullRequest(number: $prNumber) {
|
|
125
|
+
reviewThreads(first: $first, after: $after) {
|
|
126
|
+
edges {
|
|
127
|
+
cursor
|
|
128
|
+
node {
|
|
129
|
+
id
|
|
130
|
+
path
|
|
131
|
+
line
|
|
132
|
+
startLine
|
|
133
|
+
diffSide
|
|
134
|
+
subjectType
|
|
135
|
+
isResolved
|
|
136
|
+
isOutdated
|
|
137
|
+
viewerCanReply
|
|
138
|
+
viewerCanResolve
|
|
139
|
+
viewerCanUnresolve
|
|
140
|
+
resolvedBy {
|
|
141
|
+
login
|
|
142
|
+
}
|
|
143
|
+
comments(first: 20) {
|
|
144
|
+
nodes {
|
|
145
|
+
id
|
|
146
|
+
body
|
|
147
|
+
createdAt
|
|
148
|
+
url
|
|
149
|
+
author {
|
|
150
|
+
login
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
pageInfo {
|
|
157
|
+
endCursor
|
|
158
|
+
hasNextPage
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
`;
|
|
165
|
+
var PR_COMMENT_REPLY_MUTATION = `
|
|
166
|
+
mutation PrCommentReply($threadId: ID!, $body: String!) {
|
|
167
|
+
addPullRequestReviewThreadReply(input: { pullRequestReviewThreadId: $threadId, body: $body }) {
|
|
168
|
+
comment {
|
|
169
|
+
id
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
`;
|
|
174
|
+
var PR_COMMENT_RESOLVE_MUTATION = `
|
|
175
|
+
mutation PrCommentResolve($threadId: ID!) {
|
|
176
|
+
resolveReviewThread(input: { threadId: $threadId }) {
|
|
177
|
+
thread {
|
|
178
|
+
id
|
|
179
|
+
isResolved
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
`;
|
|
184
|
+
var PR_COMMENT_UNRESOLVE_MUTATION = `
|
|
185
|
+
mutation PrCommentUnresolve($threadId: ID!) {
|
|
186
|
+
unresolveReviewThread(input: { threadId: $threadId }) {
|
|
187
|
+
thread {
|
|
188
|
+
id
|
|
189
|
+
isResolved
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
`;
|
|
194
|
+
var REVIEW_THREAD_STATE_QUERY = `
|
|
195
|
+
query ReviewThreadState($threadId: ID!) {
|
|
196
|
+
node(id: $threadId) {
|
|
197
|
+
... on PullRequestReviewThread {
|
|
198
|
+
id
|
|
199
|
+
isResolved
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
`;
|
|
204
|
+
function createSdkClients(transport) {
|
|
205
|
+
const client = {
|
|
206
|
+
request(documentOrOptions, ...variablesAndRequestHeaders) {
|
|
207
|
+
const options = typeof documentOrOptions === "object" && documentOrOptions !== null && "document" in documentOrOptions ? documentOrOptions : {
|
|
208
|
+
document: documentOrOptions,
|
|
209
|
+
variables: variablesAndRequestHeaders[0]
|
|
210
|
+
};
|
|
211
|
+
const queryText = queryToString(options.document);
|
|
212
|
+
assertQuery(queryText);
|
|
213
|
+
return transport.execute(queryText, options.variables);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
const graphqlRequestClient = client;
|
|
217
|
+
return {
|
|
218
|
+
issueCommentsList: getSdk(graphqlRequestClient),
|
|
219
|
+
issueList: getSdk2(graphqlRequestClient),
|
|
220
|
+
issue: getSdk3(graphqlRequestClient),
|
|
221
|
+
prDiffListFiles: getSdk4(graphqlRequestClient),
|
|
222
|
+
prList: getSdk6(graphqlRequestClient),
|
|
223
|
+
prReviewsList: getSdk5(graphqlRequestClient),
|
|
224
|
+
pr: getSdk7(graphqlRequestClient),
|
|
225
|
+
repo: getSdk8(graphqlRequestClient)
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
async function runRepoView(sdk, input) {
|
|
229
|
+
assertRepoInput(input);
|
|
230
|
+
const result = await sdk.RepoView(input);
|
|
231
|
+
if (!result.repository) {
|
|
232
|
+
throw new Error("Repository not found");
|
|
233
|
+
}
|
|
234
|
+
return {
|
|
235
|
+
id: result.repository.id,
|
|
236
|
+
name: result.repository.name,
|
|
237
|
+
nameWithOwner: result.repository.nameWithOwner,
|
|
238
|
+
isPrivate: result.repository.isPrivate,
|
|
239
|
+
stargazerCount: result.repository.stargazerCount,
|
|
240
|
+
forkCount: result.repository.forkCount,
|
|
241
|
+
url: result.repository.url,
|
|
242
|
+
defaultBranch: result.repository.defaultBranchRef?.name ?? null
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
async function runIssueView(sdk, input) {
|
|
246
|
+
assertIssueInput(input);
|
|
247
|
+
const result = await sdk.IssueView(input);
|
|
248
|
+
const issue = result.repository?.issue;
|
|
249
|
+
if (!issue) {
|
|
250
|
+
throw new Error("Issue not found");
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
id: issue.id,
|
|
254
|
+
number: issue.number,
|
|
255
|
+
title: issue.title,
|
|
256
|
+
state: issue.state,
|
|
257
|
+
url: issue.url
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
async function runIssueList(sdk, input) {
|
|
261
|
+
assertIssueListInput(input);
|
|
262
|
+
const result = await sdk.IssueList(input);
|
|
263
|
+
const issues = result.repository?.issues;
|
|
264
|
+
if (!issues) {
|
|
265
|
+
throw new Error("Issues not found");
|
|
266
|
+
}
|
|
267
|
+
return {
|
|
268
|
+
items: (issues.nodes ?? []).flatMap(
|
|
269
|
+
(issue) => issue ? [
|
|
270
|
+
{
|
|
271
|
+
id: issue.id,
|
|
272
|
+
number: issue.number,
|
|
273
|
+
title: issue.title,
|
|
274
|
+
state: issue.state,
|
|
275
|
+
url: issue.url
|
|
276
|
+
}
|
|
277
|
+
] : []
|
|
278
|
+
),
|
|
279
|
+
pageInfo: {
|
|
280
|
+
endCursor: issues.pageInfo.endCursor ?? null,
|
|
281
|
+
hasNextPage: issues.pageInfo.hasNextPage
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
async function runIssueCommentsList(sdk, input) {
|
|
286
|
+
assertIssueCommentsListInput(input);
|
|
287
|
+
const result = await sdk.IssueCommentsList(input);
|
|
288
|
+
const comments = result.repository?.issue?.comments;
|
|
289
|
+
if (!comments) {
|
|
290
|
+
throw new Error("Issue comments not found");
|
|
291
|
+
}
|
|
292
|
+
return {
|
|
293
|
+
items: (comments.nodes ?? []).flatMap(
|
|
294
|
+
(comment) => comment ? [
|
|
295
|
+
{
|
|
296
|
+
id: comment.id,
|
|
297
|
+
body: comment.body,
|
|
298
|
+
authorLogin: comment.author?.login ?? null,
|
|
299
|
+
createdAt: comment.createdAt,
|
|
300
|
+
url: String(comment.url)
|
|
301
|
+
}
|
|
302
|
+
] : []
|
|
303
|
+
),
|
|
304
|
+
pageInfo: {
|
|
305
|
+
endCursor: comments.pageInfo.endCursor ?? null,
|
|
306
|
+
hasNextPage: comments.pageInfo.hasNextPage
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
async function runPrView(sdk, input) {
|
|
311
|
+
assertPrInput(input);
|
|
312
|
+
const result = await sdk.PrView(input);
|
|
313
|
+
const pr = result.repository?.pullRequest;
|
|
314
|
+
if (!pr) {
|
|
315
|
+
throw new Error("Pull request not found");
|
|
316
|
+
}
|
|
317
|
+
return {
|
|
318
|
+
id: pr.id,
|
|
319
|
+
number: pr.number,
|
|
320
|
+
title: pr.title,
|
|
321
|
+
state: pr.state,
|
|
322
|
+
url: pr.url
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
async function runPrList(sdk, input) {
|
|
326
|
+
assertPrListInput(input);
|
|
327
|
+
const result = await sdk.PrList(input);
|
|
328
|
+
const prs = result.repository?.pullRequests;
|
|
329
|
+
if (!prs) {
|
|
330
|
+
throw new Error("Pull requests not found");
|
|
331
|
+
}
|
|
332
|
+
return {
|
|
333
|
+
items: (prs.nodes ?? []).flatMap(
|
|
334
|
+
(pr) => pr ? [
|
|
335
|
+
{
|
|
336
|
+
id: pr.id,
|
|
337
|
+
number: pr.number,
|
|
338
|
+
title: pr.title,
|
|
339
|
+
state: pr.state,
|
|
340
|
+
url: pr.url
|
|
341
|
+
}
|
|
342
|
+
] : []
|
|
343
|
+
),
|
|
344
|
+
pageInfo: {
|
|
345
|
+
endCursor: prs.pageInfo.endCursor ?? null,
|
|
346
|
+
hasNextPage: prs.pageInfo.hasNextPage
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
async function runPrReviewsList(sdk, input) {
|
|
351
|
+
assertPrReviewsListInput(input);
|
|
352
|
+
const result = await sdk.PrReviewsList(input);
|
|
353
|
+
const reviews = result.repository?.pullRequest?.reviews;
|
|
354
|
+
if (!reviews) {
|
|
355
|
+
throw new Error("Pull request reviews not found");
|
|
356
|
+
}
|
|
357
|
+
return {
|
|
358
|
+
items: (reviews.nodes ?? []).flatMap(
|
|
359
|
+
(review) => review ? [{
|
|
360
|
+
id: review.id,
|
|
361
|
+
authorLogin: review.author?.login ?? null,
|
|
362
|
+
body: review.body,
|
|
363
|
+
state: review.state,
|
|
364
|
+
submittedAt: review.submittedAt ?? null,
|
|
365
|
+
url: review.url,
|
|
366
|
+
commitOid: review.commit?.oid ?? null
|
|
367
|
+
}] : []
|
|
368
|
+
),
|
|
369
|
+
pageInfo: {
|
|
370
|
+
endCursor: reviews.pageInfo.endCursor ?? null,
|
|
371
|
+
hasNextPage: reviews.pageInfo.hasNextPage
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
async function runPrDiffListFiles(sdk, input) {
|
|
376
|
+
assertPrDiffListFilesInput(input);
|
|
377
|
+
const result = await sdk.PrDiffListFiles(input);
|
|
378
|
+
const files = result.repository?.pullRequest?.files;
|
|
379
|
+
if (!files) {
|
|
380
|
+
throw new Error("Pull request files not found");
|
|
381
|
+
}
|
|
382
|
+
return {
|
|
383
|
+
items: (files.nodes ?? []).flatMap(
|
|
384
|
+
(file) => file ? [{
|
|
385
|
+
path: file.path,
|
|
386
|
+
additions: file.additions,
|
|
387
|
+
deletions: file.deletions
|
|
388
|
+
}] : []
|
|
389
|
+
),
|
|
390
|
+
pageInfo: {
|
|
391
|
+
endCursor: files.pageInfo.endCursor ?? null,
|
|
392
|
+
hasNextPage: files.pageInfo.hasNextPage
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
var MAX_PR_REVIEW_THREAD_SCAN_PAGES = 5;
|
|
397
|
+
function asRecord(value) {
|
|
398
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
399
|
+
}
|
|
400
|
+
function normalizePrReviewThreadComment(comment) {
|
|
401
|
+
const commentRecord = asRecord(comment);
|
|
402
|
+
if (!commentRecord || typeof commentRecord.id !== "string") {
|
|
403
|
+
return null;
|
|
404
|
+
}
|
|
405
|
+
const author = asRecord(commentRecord.author);
|
|
406
|
+
const url = commentRecord.url;
|
|
407
|
+
return {
|
|
408
|
+
id: commentRecord.id,
|
|
409
|
+
authorLogin: typeof author?.login === "string" ? author.login : null,
|
|
410
|
+
body: typeof commentRecord.body === "string" ? commentRecord.body : "",
|
|
411
|
+
createdAt: typeof commentRecord.createdAt === "string" ? commentRecord.createdAt : "",
|
|
412
|
+
url: typeof url === "string" ? url : String(url ?? "")
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
function normalizePrReviewThread(thread) {
|
|
416
|
+
const threadRecord = asRecord(thread);
|
|
417
|
+
if (!threadRecord || typeof threadRecord.id !== "string") {
|
|
418
|
+
return null;
|
|
419
|
+
}
|
|
420
|
+
const comments = asRecord(threadRecord.comments);
|
|
421
|
+
const commentNodes = Array.isArray(comments?.nodes) ? comments.nodes : [];
|
|
422
|
+
const resolvedBy = asRecord(threadRecord.resolvedBy);
|
|
423
|
+
return {
|
|
424
|
+
id: threadRecord.id,
|
|
425
|
+
path: typeof threadRecord.path === "string" ? threadRecord.path : null,
|
|
426
|
+
line: typeof threadRecord.line === "number" ? threadRecord.line : null,
|
|
427
|
+
startLine: typeof threadRecord.startLine === "number" ? threadRecord.startLine : null,
|
|
428
|
+
diffSide: typeof threadRecord.diffSide === "string" ? threadRecord.diffSide : null,
|
|
429
|
+
subjectType: typeof threadRecord.subjectType === "string" ? threadRecord.subjectType : null,
|
|
430
|
+
isResolved: Boolean(threadRecord.isResolved),
|
|
431
|
+
isOutdated: Boolean(threadRecord.isOutdated),
|
|
432
|
+
viewerCanReply: Boolean(threadRecord.viewerCanReply),
|
|
433
|
+
viewerCanResolve: Boolean(threadRecord.viewerCanResolve),
|
|
434
|
+
viewerCanUnresolve: Boolean(threadRecord.viewerCanUnresolve),
|
|
435
|
+
resolvedByLogin: typeof resolvedBy?.login === "string" ? resolvedBy.login : null,
|
|
436
|
+
comments: commentNodes.map((comment) => normalizePrReviewThreadComment(comment)).flatMap((comment) => comment ? [comment] : [])
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
async function runPrCommentsList(graphqlClient, input) {
|
|
440
|
+
assertPrCommentsListInput(input);
|
|
441
|
+
const unresolvedOnly = input.unresolvedOnly ?? false;
|
|
442
|
+
const includeOutdated = input.includeOutdated ?? true;
|
|
443
|
+
const filteredThreads = [];
|
|
444
|
+
let sourceEndCursor = input.after ?? null;
|
|
445
|
+
let sourceHasNextPage = false;
|
|
446
|
+
let pagesScanned = 0;
|
|
447
|
+
let sourceItemsScanned = 0;
|
|
448
|
+
while (pagesScanned < MAX_PR_REVIEW_THREAD_SCAN_PAGES && filteredThreads.length < input.first) {
|
|
449
|
+
const result = await graphqlClient.query(PR_COMMENTS_LIST_QUERY, {
|
|
450
|
+
owner: input.owner,
|
|
451
|
+
name: input.name,
|
|
452
|
+
prNumber: input.prNumber,
|
|
453
|
+
first: input.first,
|
|
454
|
+
after: sourceEndCursor
|
|
455
|
+
});
|
|
456
|
+
const repository = asRecord(asRecord(result)?.repository);
|
|
457
|
+
const pullRequest = asRecord(repository?.pullRequest);
|
|
458
|
+
const reviewThreads = asRecord(pullRequest?.reviewThreads);
|
|
459
|
+
if (!reviewThreads) {
|
|
460
|
+
throw new Error("Pull request review threads not found");
|
|
461
|
+
}
|
|
462
|
+
const pageInfo = asRecord(reviewThreads.pageInfo);
|
|
463
|
+
const threadEdges = Array.isArray(reviewThreads.edges) ? reviewThreads.edges.map((edge) => {
|
|
464
|
+
const edgeRecord = asRecord(edge);
|
|
465
|
+
if (!edgeRecord) {
|
|
466
|
+
return null;
|
|
467
|
+
}
|
|
468
|
+
return {
|
|
469
|
+
cursor: typeof edgeRecord.cursor === "string" ? edgeRecord.cursor : null,
|
|
470
|
+
node: edgeRecord.node
|
|
471
|
+
};
|
|
472
|
+
}).flatMap((edge) => edge ? [edge] : []) : [];
|
|
473
|
+
const threadNodes = threadEdges.length > 0 ? threadEdges : Array.isArray(reviewThreads.nodes) ? reviewThreads.nodes.map((node) => ({ cursor: null, node })) : [];
|
|
474
|
+
pagesScanned += 1;
|
|
475
|
+
sourceItemsScanned += threadNodes.length;
|
|
476
|
+
for (const threadNode of threadNodes) {
|
|
477
|
+
const normalized = normalizePrReviewThread(threadNode.node);
|
|
478
|
+
if (!normalized) {
|
|
479
|
+
continue;
|
|
480
|
+
}
|
|
481
|
+
if (unresolvedOnly && normalized.isResolved) {
|
|
482
|
+
continue;
|
|
483
|
+
}
|
|
484
|
+
if (unresolvedOnly && !includeOutdated && normalized.isOutdated) {
|
|
485
|
+
continue;
|
|
486
|
+
}
|
|
487
|
+
filteredThreads.push({ thread: normalized, cursor: threadNode.cursor });
|
|
488
|
+
}
|
|
489
|
+
sourceHasNextPage = Boolean(pageInfo?.hasNextPage);
|
|
490
|
+
sourceEndCursor = typeof pageInfo?.endCursor === "string" ? pageInfo.endCursor : null;
|
|
491
|
+
if (!sourceHasNextPage) {
|
|
492
|
+
break;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
const hasBufferedFilteredItems = filteredThreads.length > input.first;
|
|
496
|
+
const returnedThreads = filteredThreads.slice(0, input.first);
|
|
497
|
+
const endCursor = returnedThreads.length > 0 ? returnedThreads[returnedThreads.length - 1]?.cursor ?? sourceEndCursor : sourceEndCursor;
|
|
498
|
+
const scanTruncated = sourceHasNextPage && pagesScanned >= MAX_PR_REVIEW_THREAD_SCAN_PAGES;
|
|
499
|
+
return {
|
|
500
|
+
items: returnedThreads.map((entry) => entry.thread),
|
|
501
|
+
pageInfo: {
|
|
502
|
+
hasNextPage: hasBufferedFilteredItems || sourceHasNextPage,
|
|
503
|
+
endCursor: hasBufferedFilteredItems || sourceHasNextPage ? endCursor : null
|
|
504
|
+
},
|
|
505
|
+
filterApplied: {
|
|
506
|
+
unresolvedOnly,
|
|
507
|
+
includeOutdated
|
|
508
|
+
},
|
|
509
|
+
scan: {
|
|
510
|
+
pagesScanned,
|
|
511
|
+
sourceItemsScanned,
|
|
512
|
+
scanTruncated
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
function assertReviewThreadInput(input) {
|
|
517
|
+
if (typeof input.threadId !== "string" || input.threadId.trim().length === 0) {
|
|
518
|
+
throw new Error("Review thread id is required");
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
function assertReplyToReviewThreadInput(input) {
|
|
522
|
+
assertReviewThreadInput(input);
|
|
523
|
+
if (typeof input.body !== "string" || input.body.trim().length === 0) {
|
|
524
|
+
throw new Error("Reply body is required");
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
function parseReviewThreadMutationResult(result, mutationKey) {
|
|
528
|
+
const root = asRecord(result);
|
|
529
|
+
const mutation = asRecord(root?.[mutationKey]);
|
|
530
|
+
const thread = asRecord(mutation?.thread);
|
|
531
|
+
if (!thread || typeof thread.id !== "string") {
|
|
532
|
+
throw new Error("Review thread mutation failed");
|
|
533
|
+
}
|
|
534
|
+
return {
|
|
535
|
+
id: thread.id,
|
|
536
|
+
isResolved: Boolean(thread.isResolved)
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
async function runReplyToReviewThread(graphqlClient, input) {
|
|
540
|
+
assertReplyToReviewThreadInput(input);
|
|
541
|
+
const result = await graphqlClient.query(PR_COMMENT_REPLY_MUTATION, {
|
|
542
|
+
threadId: input.threadId,
|
|
543
|
+
body: input.body
|
|
544
|
+
});
|
|
545
|
+
const root = asRecord(result);
|
|
546
|
+
const mutation = asRecord(root?.addPullRequestReviewThreadReply);
|
|
547
|
+
const comment = asRecord(mutation?.comment);
|
|
548
|
+
if (!comment || typeof comment.id !== "string") {
|
|
549
|
+
throw new Error("Review thread mutation failed");
|
|
550
|
+
}
|
|
551
|
+
const threadStateResult = await graphqlClient.query(REVIEW_THREAD_STATE_QUERY, {
|
|
552
|
+
threadId: input.threadId
|
|
553
|
+
});
|
|
554
|
+
const threadNode = asRecord(asRecord(threadStateResult)?.node);
|
|
555
|
+
if (!threadNode || typeof threadNode.id !== "string") {
|
|
556
|
+
throw new Error("Review thread state lookup failed");
|
|
557
|
+
}
|
|
558
|
+
return {
|
|
559
|
+
id: input.threadId,
|
|
560
|
+
isResolved: Boolean(threadNode.isResolved)
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
async function runResolveReviewThread(graphqlClient, input) {
|
|
564
|
+
assertReviewThreadInput(input);
|
|
565
|
+
const result = await graphqlClient.query(PR_COMMENT_RESOLVE_MUTATION, {
|
|
566
|
+
threadId: input.threadId
|
|
567
|
+
});
|
|
568
|
+
return parseReviewThreadMutationResult(result, "resolveReviewThread");
|
|
569
|
+
}
|
|
570
|
+
async function runUnresolveReviewThread(graphqlClient, input) {
|
|
571
|
+
assertReviewThreadInput(input);
|
|
572
|
+
const result = await graphqlClient.query(PR_COMMENT_UNRESOLVE_MUTATION, {
|
|
573
|
+
threadId: input.threadId
|
|
574
|
+
});
|
|
575
|
+
return parseReviewThreadMutationResult(result, "unresolveReviewThread");
|
|
576
|
+
}
|
|
577
|
+
function queryToString(query) {
|
|
578
|
+
if (typeof query === "string") {
|
|
579
|
+
return query;
|
|
580
|
+
}
|
|
581
|
+
if (typeof query === "object" && query !== null && "kind" in query) {
|
|
582
|
+
return print(query);
|
|
583
|
+
}
|
|
584
|
+
return String(query);
|
|
585
|
+
}
|
|
586
|
+
function assertQuery(query) {
|
|
587
|
+
if (query.trim().length === 0) {
|
|
588
|
+
throw new Error("GraphQL query must be non-empty");
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
function createGraphqlClient(transport) {
|
|
592
|
+
return {
|
|
593
|
+
async query(query, variables) {
|
|
594
|
+
const queryText = queryToString(query);
|
|
595
|
+
assertQuery(queryText);
|
|
596
|
+
return transport.execute(queryText, variables);
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
function createGithubClient(transport) {
|
|
601
|
+
const graphqlClient = createGraphqlClient(transport);
|
|
602
|
+
const sdk = createSdkClients(transport);
|
|
603
|
+
return {
|
|
604
|
+
query: (query, variables) => graphqlClient.query(query, variables),
|
|
605
|
+
fetchRepoView: (input) => runRepoView(sdk.repo, input),
|
|
606
|
+
fetchIssueCommentsList: (input) => runIssueCommentsList(sdk.issueCommentsList, input),
|
|
607
|
+
fetchIssueList: (input) => runIssueList(sdk.issueList, input),
|
|
608
|
+
fetchIssueView: (input) => runIssueView(sdk.issue, input),
|
|
609
|
+
fetchPrList: (input) => runPrList(sdk.prList, input),
|
|
610
|
+
fetchPrView: (input) => runPrView(sdk.pr, input),
|
|
611
|
+
fetchPrCommentsList: (input) => runPrCommentsList(graphqlClient, input),
|
|
612
|
+
fetchPrReviewsList: (input) => runPrReviewsList(sdk.prReviewsList, input),
|
|
613
|
+
fetchPrDiffListFiles: (input) => runPrDiffListFiles(sdk.prDiffListFiles, input),
|
|
614
|
+
replyToReviewThread: (input) => runReplyToReviewThread(graphqlClient, input),
|
|
615
|
+
resolveReviewThread: (input) => runResolveReviewThread(graphqlClient, input),
|
|
616
|
+
unresolveReviewThread: (input) => runUnresolveReviewThread(graphqlClient, input)
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
export {
|
|
621
|
+
createGraphqlClient,
|
|
622
|
+
createGithubClient
|
|
623
|
+
};
|
|
624
|
+
//# sourceMappingURL=chunk-YQDQX4BT.js.map
|