@theholocron/holocron-plugin-github 5.0.0-alpha.51 → 5.0.0-alpha.511

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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # `@theholocron/holocron-plugin-github`
2
2
 
3
- GitHub plugin for [Holocron](../cli). Implements five capabilities
4
- against the GitHub REST API:
3
+ GitHub plugin for [Holocron](../cli). Implements six capabilities
4
+ against the GitHub REST and GraphQL APIs:
5
5
 
6
6
  | Capability | What this plugin does |
7
7
  | -------------- | ---------------------------------------------------------------- |
@@ -10,6 +10,7 @@ against the GitHub REST API:
10
10
  | `secrets` | GH Actions secrets (repo + environment + organization) |
11
11
  | `environments` | Named deployment environments (reviewers, wait timers) |
12
12
  | `issues` | GitHub Issues as a tracker (with lifecycle slots) |
13
+ | `projects` | GitHub Projects v2 boards (GraphQL) |
13
14
 
14
15
  ## Install
15
16
 
@@ -34,18 +35,19 @@ Each capability resolves its own fine-grained token so a compromised credential
34
35
  | `HOLOCRON_SYNC_TOKEN` | `github.sync` | `sync-github` command |
35
36
  | `HOLOCRON_RELEASE_TOKEN` | `github.release` | semantic-release, GitHub releases |
36
37
  | `HOLOCRON_ADMIN_TOKEN` | `github.admin` | `source`, `secrets`, `environments` |
38
+ | `HOLOCRON_ORG_TOKEN` | `github.org` | `projects` |
37
39
 
38
40
  Store tokens once via the keyring so they are picked up automatically:
39
41
 
40
42
  ```sh
41
- holocron auth set github.read ghp_xxx # clone + CI run listing
42
- holocron auth set github.issues ghp_xxx # issue management
43
- holocron auth set github.sync ghp_xxx # sync-github workflow templates
44
- holocron auth set github.release ghp_xxx # semantic-release
45
- holocron auth set github.admin ghp_xxx # setup, secrets, environments
43
+ holocron new token github.read ghp_xxx # clone + CI run listing
44
+ holocron new token github.issues ghp_xxx # issue management
45
+ holocron new token github.sync ghp_xxx # sync-github workflow templates
46
+ holocron new token github.release ghp_xxx # semantic-release
47
+ holocron new token github.admin ghp_xxx # setup, secrets, environments
46
48
  ```
47
49
 
48
- See [docs/tokens.md](../../docs/tokens.md) for full scope requirements and CI setup.
50
+ See the [token reference](https://docs.theholocron.dev/holocron/tokens/) for full scope requirements and CI setup.
49
51
 
50
52
  ## Config
51
53
 
@@ -64,6 +66,29 @@ See [docs/tokens.md](../../docs/tokens.md) for full scope requirements and CI se
64
66
 
65
67
  ```
66
68
 
69
+ ## `projects` capability
70
+
71
+ GitHub Projects v2 boards over GraphQL, for `list projects`, `new project`, `setup project` (SPEC-0020, #1744). It uses the org token
72
+ (`HOLOCRON_ORG_TOKEN`, keyring `github.org`) with the **Projects** organization permission. Items are keyed `#N` in the
73
+ configured `repo` and `owner/repo#N` elsewhere.
74
+
75
+ | Method | What it does |
76
+ | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
77
+ | `list` | Every project of the organization, open and closed. `find` is the exact name among the open ones. |
78
+ | `create` | Copies the board `template.source` names (fields, options, views, automation rules, no items), or creates a project and applies the template. |
79
+ | `close` | `updateProjectV2` with `closed: true`. Reversible. |
80
+ | `read` | Statuses, other fields, board and table views and automation rules. |
81
+ | `ensure` | Adds what the template lists and the board lacks (options, fields, views, filters). Never deletes. Rules and view grouping the API cannot set come back as `todos`. |
82
+ | `items` | Each issue or pull request with its status, category, whether it is open and its open blockers. |
83
+ | `setStatus` | Sets an item's status. Idempotent: `transitioned: false` when it is already there. |
84
+ | `move` | Puts open items on another board with status and priority (only where the target has none); closed and merged ones stay and are set to done when theirs is not a done one. |
85
+ | `whoami` | How many boards the token sees, for `holocron doctor`. |
86
+
87
+ `ensure` is safe on a field that has items. `updateProjectV2Field` replaces a single select field's whole option list,
88
+ and an option sent without its `id` blanks the field on every item, so `ensure` reads the field first, sends every
89
+ existing option with its `id` in the template's order (new ones without), and stops when the field cannot be read. It
90
+ also keeps the item values in memory and, if a re-read shows any gone, writes them back by option name and fails.
91
+
67
92
  ## Status
68
93
 
69
94
  **`v2.0.0-alpha.0`** — published on npm under the `alpha` dist-tag.
package/dist/index.d.mts CHANGED
@@ -1,47 +1,85 @@
1
- import { GitHubClient, GitHubClientOptions, createGitHubClient } from "@theholocron/github-client";
2
- import { Auth, AuthError, Ci, CiRun, CiRunFilter, Environment, Environments, Issue, IssueSearchFilter, Issues, LabelDef, LifecycleResult, LifecycleSlot, PagesConfig, PullRequest, RepoRef, RepoSettings, ResolveTokenInput, Ruleset, SecretScope, Secrets, Source, TeamEntry, TeamEntry as TeamEntry$1, TeamPermission, TrackerDoctorReport, TrackerUser, createFeatureResolver } from "@theholocron/cli";
3
- //#region src/auth.d.ts
4
- declare const resolveReadToken: (input?: ResolveTokenInput) => string;
5
- declare const resolveIssuesToken: (input?: ResolveTokenInput) => string;
6
- declare const resolveSyncToken: (input?: ResolveTokenInput) => string;
7
- declare const resolveReleaseToken: (input?: ResolveTokenInput) => string;
8
- declare const resolveAdminToken: (input?: ResolveTokenInput) => string;
9
- declare const resolveDeployToken: (input?: ResolveTokenInput) => string;
10
- declare const resolveOrgToken: (input?: ResolveTokenInput) => string;
11
- //#endregion
12
- //#region src/capabilities/ci.d.ts
1
+ /**
2
+ * `@theholocron/holocron-plugin-github` — entrypoint.
3
+ *
4
+ * Holocron loads a plugin by resolving its package and reading the
5
+ * default export, which is a `Plugin` object declaring which
6
+ * capabilities it implements. The factory for each capability
7
+ * receives plugin-level options from `holocron.config.json` and
8
+ * returns the bound implementation.
9
+ */
10
+ import { AddedItem, Auth, AuthError, BoardItem, BoardItemInput, BoardState, BoardSummary, BoardTemplate, Ci, CiRun, CiRunFilter, EnsureReport, Environment, Environments, ExportInfo, ImportOptions, ImportResult, Issue, IssueCreateInput, IssuePatch, IssueRecord, IssueSearchFilter, IssueSelector, IssueUpdateResult, Issues, LabelDef, LifecycleResult, LifecycleSlot, MoveReport, PagesConfig, PluginToken, Projects, PullRequest, PullRequestChecks, PullRequestInput, PullRequestPatch, PullRequestResult, RepoRef, RepoSettings, ResolveTokenInput, Ruleset, SecretAccess, SecretScope, Secrets, Source, SourceBranch, SourceFile, SourceRepoInfo, SourceRulesetDetail, SourceSecurity, SourceTeamMember, SyncResult, TeamEntry, TeamEntry as TeamEntry$1, TeamPermission, TeamPermission as TeamPermission$1, TrackerDoctorReport, TrackerUser, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess, createFeatureResolver } from "@theholocron/cli";
11
+ import { GitHubClient, GitHubClientOptions, GraphQLClient, createGitHubClient } from "@theholocron/github-client";
12
+ /** Resolves the token for read-only GitHub access (`HOLOCRON_READ_TOKEN`, keyring key `github.read`). */
13
+ export declare const resolveReadToken: import("@theholocron/cli").FeatureResolver;
14
+ /** Resolves the token for issue operations (`HOLOCRON_ISSUES_TOKEN`, keyring key `github.issues`). */
15
+ export declare const resolveIssuesToken: import("@theholocron/cli").FeatureResolver;
16
+ /** Resolves the token for syncing repo files and settings (`HOLOCRON_SYNC_TOKEN`, keyring key `github.sync`). */
17
+ export declare const resolveSyncToken: import("@theholocron/cli").FeatureResolver;
18
+ /** Resolves the token for release operations (`HOLOCRON_RELEASE_TOKEN`, keyring key `github.release`). */
19
+ export declare const resolveReleaseToken: import("@theholocron/cli").FeatureResolver;
20
+ /** Resolves the repo-scoped admin token (`HOLOCRON_ADMIN_TOKEN`, keyring key `github.admin`). */
21
+ export declare const resolveAdminToken: import("@theholocron/cli").FeatureResolver;
22
+ /** Resolves the org-level secrets token (`HOLOCRON_SECRETS_TOKEN`, keyring key `github.secrets`). */
23
+ export declare const resolveSecretsToken: import("@theholocron/cli").FeatureResolver;
24
+ /** Resolves the token for deployment operations (`HOLOCRON_DEPLOY_TOKEN`, keyring key `github.deploy`). */
25
+ export declare const resolveDeployToken: import("@theholocron/cli").FeatureResolver;
26
+ /**
27
+ * Resolves the token for the user-sync files in the org's private config repo (`HOLOCRON_USER_SYNC_TOKEN`, keyring
28
+ * key `github.user-sync`).
29
+ */
30
+ export declare const resolveUserSyncToken: import("@theholocron/cli").FeatureResolver;
31
+ /** Resolves the org-level token (`HOLOCRON_ORG_TOKEN`, keyring key `github.org`). */
32
+ export declare const resolveOrgToken: import("@theholocron/cli").FeatureResolver;
33
+ /** `repo.labels`, which the loader hands the plugin: the area map, the kind tables and the repositories. */
34
+ interface LabelsConfig {
35
+ areas?: Record<string, string[]>;
36
+ scopes?: Record<string, string>;
37
+ /** Main kind label to Type (default `bug` Bug, `enhancement` Feature, `chore` Task). */
38
+ kinds?: Record<string, string>;
39
+ /** Kind labels used only when none of `kinds` is on the issue (default the six of #2494, each Task). */
40
+ fallbackKinds?: Record<string, string>;
41
+ /** The repositories to run on when `--repo` is not given. */
42
+ repos?: string[];
43
+ }
13
44
  interface CiOptions {
14
45
  repo: string;
15
46
  }
16
- declare class GitHubCi implements Ci {
47
+ /** The GitHub implementation of the `ci` capability, backed by GitHub Actions workflow runs. */
48
+ export declare class GitHubCi implements Ci {
17
49
  private readonly client;
18
50
  private readonly opts;
51
+ /** Capability key, always `"ci"`. */
19
52
  readonly key: "ci";
53
+ /** Provider name, always `"github"`. */
20
54
  readonly providerName = "github";
21
55
  constructor(client: GitHubClient, opts: CiOptions);
56
+ /** Lists workflow runs for the repo, optionally filtered by branch, status and limit. */
22
57
  listRuns(filter?: CiRunFilter): Promise<CiRun[]>;
58
+ /** Fetches one workflow run by id. */
23
59
  getRun(id: string | number): Promise<CiRun>;
24
60
  private mapRun;
25
61
  private mapConclusion;
26
62
  }
27
- //#endregion
28
- //#region src/capabilities/environments.d.ts
29
63
  interface EnvironmentsOptions {
30
64
  repo: string;
31
65
  }
32
- declare class GitHubEnvironments implements Environments {
66
+ /** The GitHub implementation of the `environments` capability, managing a repo's deployment environments. */
67
+ export declare class GitHubEnvironments implements Environments {
33
68
  private readonly client;
34
69
  private readonly opts;
70
+ /** Capability key, always `"environments"`. */
35
71
  readonly key: "environments";
72
+ /** Provider name, always `"github"`. */
36
73
  readonly providerName = "github";
37
74
  constructor(client: GitHubClient, opts: EnvironmentsOptions);
75
+ /** Lists the repo's environments with their wait timer, self-review rule and required reviewers. */
38
76
  listEnvironments(): Promise<Environment[]>;
77
+ /** Creates or updates an environment, sending only the settings the given environment defines. */
39
78
  upsertEnvironment(env: Environment): Promise<void>;
79
+ /** Deletes the named environment. */
40
80
  deleteEnvironment(name: string): Promise<void>;
41
81
  private flattenReviewers;
42
82
  }
43
- //#endregion
44
- //#region src/capabilities/issues.d.ts
45
83
  interface IssuesOptions {
46
84
  repo: string;
47
85
  /**
@@ -55,9 +93,12 @@ interface IssuesOptions {
55
93
  inReview: string;
56
94
  };
57
95
  }
58
- declare class GitHubIssues implements Issues {
96
+ /** The GitHub implementation of the `issues` capability, backed by GitHub Issues and status labels. */
97
+ export declare class GitHubIssues implements Issues {
59
98
  private readonly client;
99
+ /** Capability key, always `"issues"`. */
60
100
  readonly key: "issues";
101
+ /** Provider name, always `"github"`. */
61
102
  readonly providerName = "github";
62
103
  private readonly owner;
63
104
  private readonly repoName;
@@ -65,28 +106,56 @@ declare class GitHubIssues implements Issues {
65
106
  private readonly labels;
66
107
  constructor(client: GitHubClient, opts: IssuesOptions);
67
108
  getMyself(): Promise<TrackerUser>;
109
+ /**
110
+ * Searches the repo's issues, newest update first, leaving out pull requests.
111
+ *
112
+ * With `filter.text`, the issues are paged (newest update first, 100 a page, at most 20 pages) and compared
113
+ * client-side, without regard to case, until `limit` matches are found or the issues run out. GitHub's issue
114
+ * search (`GET /search/issues`) is deliberately not used: it indexes the words of a body, so punctuation and an
115
+ * HTML comment such as `<!-- holocron:idea notes/a.md -->` cannot be relied on to match, it is limited to 30
116
+ * requests a minute and it is eventually consistent (an issue made a moment ago may be missing). Paging has none
117
+ * of those limits, at the cost of reading up to 20 pages of a very large repository.
118
+ */
68
119
  search(filter: IssueSearchFilter): Promise<Issue[]>;
120
+ private searchText;
121
+ /** Fetches one issue by its key. */
69
122
  get(key: string): Promise<Issue>;
70
- create(input: {
71
- summary: string;
72
- body?: string;
73
- labels?: string[];
74
- milestone?: string;
75
- }): Promise<{
123
+ /**
124
+ * Creates an issue and returns its key as `#<number>`; the milestone is resolved from its title. Type, Priority,
125
+ * Effort, the dates, the parent and the blockers are set after the issue exists; what GitHub refuses of them comes
126
+ * back in `dropped`, never as a failure, because the issue is made by then and its key must not be lost.
127
+ */
128
+ create(input: IssueCreateInput): Promise<{
76
129
  key: string;
130
+ dropped?: string[];
77
131
  }>;
132
+ /** Changes an issue; see {@link updateGitHubIssue}. */
133
+ update(key: string, patch: IssuePatch): Promise<IssueUpdateResult>;
78
134
  transition(key: string, slot: LifecycleSlot): Promise<LifecycleResult>;
135
+ /** Adds a comment to the issue with the given key. */
79
136
  comment(key: string, body: string): Promise<void>;
137
+ /** Checks the authenticated user, the repo and the label-backed lifecycle slots, and reports what resolves. */
80
138
  doctor(): Promise<TrackerDoctorReport>;
139
+ /** Reads issues with their comments, priority label, parent and blockers, for `holocron migrate`. */
140
+ export(selector: IssueSelector, info?: ExportInfo): Promise<IssueRecord[]>;
141
+ /** Makes the records as issues; one already made by an earlier run is skipped. */
142
+ import(records: IssueRecord[], options?: ImportOptions): Promise<ImportResult[]>;
143
+ /** Like `import`, and it also updates what an earlier import or sync made, for `holocron sync issues`. */
144
+ sync(records: IssueRecord[], options?: ImportOptions): Promise<SyncResult[]>;
145
+ private fieldSetter;
146
+ /** What the field writers need; the setter is shared so the organization's field list is read once. */
147
+ private fieldContext;
81
148
  private resolveMilestone;
82
149
  private removeStatusLabels;
83
150
  private mapIssue;
84
151
  }
85
- //#endregion
86
- //#region src/capabilities/labels.d.ts
152
+ /** A label the repo is expected to have. */
87
153
  interface CanonicalLabel {
154
+ /** The label's name. */
88
155
  readonly name: string;
156
+ /** The label's color, as a hex string. */
89
157
  readonly color: string;
158
+ /** The label's description. */
90
159
  readonly description: string;
91
160
  }
92
161
  /**
@@ -97,36 +166,138 @@ interface CanonicalLabel {
97
166
  * - DELETEs labels listed in `stale`.
98
167
  * - Leaves unrecognised labels that aren't in `stale` untouched.
99
168
  */
100
- declare function syncLabels(client: GitHubClient, repo: string, canonical: ReadonlyArray<CanonicalLabel>, stale: ReadonlyArray<string>): Promise<string>;
101
- //#endregion
102
- //#region src/capabilities/secrets.d.ts
169
+ export declare function syncLabels(client: GitHubClient, repo: string, canonical: ReadonlyArray<CanonicalLabel>, stale: ReadonlyArray<string>): Promise<string>;
170
+ /** Options of the GitHub `projects` capability. */
171
+ interface ProjectsOptions {
172
+ /** The repository the provider is configured for, as `owner/name`; its items get the short key `#N`. */
173
+ repo: string;
174
+ }
175
+ /** The GitHub implementation of the `projects` capability, backed by Projects v2. */
176
+ export declare class GitHubProjects implements Projects {
177
+ private readonly graphql;
178
+ /** Capability key, always `"projects"`. */
179
+ readonly key: "projects";
180
+ /** Provider name, always `"github"`. */
181
+ readonly providerName = "github";
182
+ private readonly repo;
183
+ constructor(graphql: GraphQLClient, opts: ProjectsOptions);
184
+ /** Every board of the organization, open and closed. */
185
+ list(owner: string): Promise<BoardSummary[]>;
186
+ /** The open board with exactly this name. */
187
+ find(owner: string, name: string): Promise<BoardSummary | undefined>;
188
+ /**
189
+ * Makes a board. With `template.source` naming an open board it is copied (fields, options, views and automation
190
+ * rules, no items); otherwise the board is created and brought in line with the template.
191
+ */
192
+ create(owner: string, name: string, template: BoardTemplate): Promise<BoardSummary>;
193
+ /** Closes the board; `updateProjectV2` with `closed: true` is the only way, and reversible. */
194
+ close(_owner: string, board: BoardSummary): Promise<void>;
195
+ /** The live board: statuses, other fields, views and automation rules. */
196
+ read(_owner: string, board: BoardSummary): Promise<BoardState>;
197
+ /**
198
+ * Brings the board in line with the template. Never deletes a field, option or view, and never sends an option
199
+ * list without ids. Stops (throws) when the status field cannot be read.
200
+ */
201
+ ensure(_owner: string, board: BoardSummary, template: BoardTemplate): Promise<EnsureReport>;
202
+ /**
203
+ * Makes a single select field hold the wanted options in order, every existing one sent with its id. Options the
204
+ * template does not mention stay, after the wanted ones. Returns what changed (`Blocked added`, `order set`).
205
+ */
206
+ private ensureOptions;
207
+ private createField;
208
+ private createView;
209
+ private updateView;
210
+ /**
211
+ * The board's issues and pull requests with their status, whether they are open and their open blockers. A second step
212
+ * then reads, one small query per issue, the pull requests that close each open issue a rule could still move (it has a
213
+ * status that is not `done` or `blocked` and no open blocker), each with the aggregate `ci / Required checks` state of
214
+ * its head commit. An issue whose read fails keeps no `pullRequests` and carries `pullRequestsProblem` instead.
215
+ */
216
+ items(_owner: string, board: BoardSummary, template: BoardTemplate): Promise<BoardItem[]>;
217
+ /** Puts an item in a status; `transitioned` is false when it already is there. */
218
+ setStatus(_owner: string, board: BoardSummary, key: string, status: string): Promise<LifecycleResult>;
219
+ /**
220
+ * Puts the open items of `from` on `to` with their status and priority, only where the target has no value;
221
+ * closed and merged ones stay, and are set to the template's done status when theirs is not a done one.
222
+ */
223
+ move(_owner: string, from: BoardSummary, to: BoardSummary, template: BoardTemplate): Promise<MoveReport>;
224
+ /**
225
+ * Puts issues on the board (`addProjectV2ItemById`, the content id the issue's node id) and sets Status and Priority
226
+ * through the single select update, only where the item has no value yet. A status or priority with no option on
227
+ * the board is reported in `dropped`; no option is ever created, so no value is cleared.
228
+ */
229
+ addItems(_owner: string, board: BoardSummary, items: BoardItemInput[], template: BoardTemplate): Promise<AddedItem[]>;
230
+ /** The board's own status for an input: the option named like its status, else the template's status of its category. */
231
+ private statusFor;
232
+ /** The node id of an issue, which `addProjectV2ItemById` takes as the content id. */
233
+ private nodeId;
234
+ /** A `holocron doctor` smoke check: how many boards the token sees in the configured repository's organization. */
235
+ whoami(): Promise<{
236
+ ok: boolean;
237
+ boards: number;
238
+ }>;
239
+ /** Sets a single select value by option name; a field or option the board lacks is skipped. */
240
+ private setOption;
241
+ private ownerId;
242
+ private readRaw;
243
+ private fetchItems;
244
+ private keyOf;
245
+ private parseKey;
246
+ }
103
247
  interface SecretsOptions {
104
248
  repo: string;
105
249
  }
106
- declare class GitHubSecrets implements Secrets {
250
+ /** The GitHub implementation of the `secrets` capability, covering repository, environment and organization secrets. */
251
+ export declare class GitHubSecrets implements Secrets {
107
252
  private readonly client;
108
253
  private readonly opts;
254
+ private readonly orgClient?;
255
+ /** Capability key, always `"secrets"`. */
109
256
  readonly key: "secrets";
257
+ /** Provider name, always `"github"`. */
110
258
  readonly providerName = "github";
111
- constructor(client: GitHubClient, opts: SecretsOptions);
259
+ /**
260
+ * `client` handles repo and environment scopes; `orgClient`, when given, handles
261
+ * the organization scope. They differ when a dedicated org-only token exists:
262
+ * it can write org secrets but not repo ones, and `github.admin` is the reverse.
263
+ */
264
+ constructor(client: GitHubClient, opts: SecretsOptions, orgClient?: GitHubClient | undefined);
265
+ /** Repository name to numeric id, so one run asks GitHub once per repository however many secrets name it. */
266
+ private readonly repoIds;
267
+ private clientFor;
112
268
  listSecrets(scope: SecretScope): Promise<string[]>;
113
269
  setSecret(scope: SecretScope, name: string, value: string): Promise<void>;
270
+ /**
271
+ * Who can read each organization secret, by name (never a value): `selected` ones come with the names of their
272
+ * repositories. Any other scope has no visibility and gives `{}`.
273
+ */
274
+ listSecretAccess(scope: SecretScope): Promise<Record<string, SecretAccess>>;
275
+ /** The `visibility` (and repository ids) of an organization write. No `visibility` keeps the older default, `all`. */
276
+ private readers;
277
+ private repoId;
278
+ /** Deletes the named secret in the given scope. */
114
279
  deleteSecret(scope: SecretScope, name: string): Promise<void>;
115
280
  }
116
- //#endregion
117
- //#region src/capabilities/source.d.ts
118
281
  interface SourceOptions {
119
282
  repo: string;
120
283
  repoRoot: string;
121
284
  /** Secondary client authenticated with HOLOCRON_ORG_TOKEN for org-scoped operations (teams, custom properties). */
122
285
  orgClient?: GitHubClient;
286
+ /** Client for the files that link GitHub accounts to other services (HOLOCRON_USER_SYNC_TOKEN); falls back to the org client. */
287
+ userSyncClient?: GitHubClient;
123
288
  /** Forwarded to a secondary client created for Pages calls (HOLOCRON_DEPLOY_TOKEN). */
124
289
  baseUrl?: string;
125
290
  fetch?: typeof fetch;
126
291
  }
127
- declare class GitHubSource implements Source {
292
+ /**
293
+ * The GitHub implementation of the `source` capability: repo settings, rulesets, branch protection, security
294
+ * features and local workflow files.
295
+ */
296
+ export declare class GitHubSource implements Source {
128
297
  private readonly client;
298
+ /** Capability key, always `"source"`. */
129
299
  readonly key: "source";
300
+ /** Provider name, always `"github"`. */
130
301
  readonly providerName = "github";
131
302
  private readonly owner;
132
303
  private readonly name;
@@ -134,83 +305,131 @@ declare class GitHubSource implements Source {
134
305
  private readonly repoRoot;
135
306
  private readonly workflowDir;
136
307
  private readonly orgClient?;
308
+ private readonly userSyncClient?;
137
309
  private readonly baseUrl?;
138
310
  private readonly fetchImpl?;
139
311
  constructor(client: GitHubClient, opts: SourceOptions);
140
312
  whoami(): Promise<{
141
313
  login: string;
142
314
  }>;
315
+ /** Returns the repo's owner, name and default branch. */
143
316
  getRepo(): Promise<RepoRef>;
317
+ /** Lists the repo's rulesets. */
144
318
  listRulesets(): Promise<Ruleset[]>;
319
+ /** Creates a ruleset from the given payload. */
145
320
  createRuleset(payload: Record<string, unknown>): Promise<Ruleset>;
321
+ /** Updates the ruleset with the given id from the payload. */
146
322
  updateRuleset(id: number, payload: Record<string, unknown>): Promise<Ruleset>;
323
+ /** Updates the repo's settings. */
147
324
  updateRepoSettings(settings: RepoSettings): Promise<void>;
148
325
  protectBranch(branch: string, payload: Record<string, unknown>): Promise<void>;
326
+ /** Enables Dependabot vulnerability alerts. */
149
327
  enableVulnerabilityAlerts(): Promise<void>;
328
+ /** Enables Dependabot automated security fixes. */
150
329
  enableAutomatedSecurityFixes(): Promise<void>;
330
+ /** Enables secret scanning. */
151
331
  enableSecretScanning(): Promise<void>;
152
332
  enableCodeScanning(): Promise<string>;
153
333
  disableDefaultCodeScanning(): Promise<void>;
154
334
  enableDependencyGraph(): Promise<void>;
335
+ /** Enables private vulnerability reporting. */
155
336
  enablePrivateVulnerabilityReporting(): Promise<void>;
337
+ /** Lists the `.yml` and `.yaml` files in `.github/workflows`, sorted by name; empty when the folder is missing. */
156
338
  listWorkflowFiles(): Promise<string[]>;
339
+ /** Reads a workflow file's text, or `null` when it does not exist. */
157
340
  readWorkflowFile(name: string): Promise<string | null>;
341
+ /** Writes a workflow file, creating `.github/workflows` first when needed. */
158
342
  writeWorkflowFile(name: string, contents: string): Promise<void>;
343
+ /** Removes a workflow file; a file that is already gone is not an error. */
159
344
  removeWorkflowFile(name: string): Promise<void>;
160
345
  writeRepoFile(path: string, contents: string): Promise<void>;
161
346
  syncLabels(canonical: ReadonlyArray<LabelDef>, stale: ReadonlyArray<string>): Promise<string>;
347
+ ensureLabels(labels: ReadonlyArray<LabelDef>): Promise<string>;
162
348
  syncProperties(values: Record<string, string | string[]>): Promise<string>;
349
+ getOrgPropertyValues(name: string): Promise<string[] | undefined>;
350
+ addOrgPropertyValues(name: string, values: string[]): Promise<string[]>;
351
+ checkPropertyValues(values: Record<string, string | string[]>): Promise<string[] | undefined>;
163
352
  syncTeams(teams: TeamEntry$1[]): Promise<string>;
353
+ teamMembers(teamSlug: string, org?: string): Promise<SourceTeamMember[]>;
354
+ readFile(path: string, repo?: string): Promise<SourceFile | null>;
355
+ writeFile(path: string, content: string, opts: {
356
+ message: string;
357
+ version?: string;
358
+ repo?: string;
359
+ }): Promise<void>;
164
360
  syncTopics(topics: string[]): Promise<string>;
361
+ syncVariables(variables: Record<string, string>, opts?: {
362
+ prune?: boolean;
363
+ dryRun?: boolean;
364
+ }): Promise<string>;
365
+ syncOrgVariables(org: string, variables: Record<string, {
366
+ value: string;
367
+ visibility: "all" | "private";
368
+ }>, opts?: {
369
+ prune?: boolean;
370
+ dryRun?: boolean;
371
+ }): Promise<string>;
372
+ listVariables(): Promise<Record<string, string>>;
373
+ listOrgVariables(org: string): Promise<Record<string, {
374
+ value: string;
375
+ visibility: "all" | "private" | "selected";
376
+ }>>;
377
+ getRepoInfo(): Promise<SourceRepoInfo>;
378
+ getProperties(): Promise<Record<string, string | string[]>>;
379
+ listLabels(): Promise<LabelDef[]>;
380
+ listTeamAccess(): Promise<Array<{
381
+ slug: string;
382
+ permission: TeamPermission$1;
383
+ }>>;
384
+ getRulesetDetail(id: number): Promise<SourceRulesetDetail>;
385
+ getSecurity(): Promise<SourceSecurity>;
165
386
  syncDescription(description: string): Promise<string>;
166
387
  syncHomepage(homepage: string): Promise<string>;
167
388
  getPullRequest(number: number, repo?: string): Promise<PullRequest>;
389
+ listPullRequests(state: "open" | "closed", repo?: string): Promise<PullRequest[]>;
390
+ listBranches(repo?: string): Promise<SourceBranch[]>;
391
+ deleteBranch(name: string, repo?: string): Promise<void>;
392
+ listPullRequestCommits(number: number, repo?: string): Promise<string[]>;
393
+ listPullRequestFiles(number: number, repo?: string): Promise<string[]>;
394
+ createPullRequest(input: PullRequestInput, repo?: string): Promise<PullRequestResult>;
395
+ updatePullRequest(number: number, patch: PullRequestPatch, repo?: string): Promise<PullRequestResult>;
396
+ markReady(number: number, repo?: string): Promise<boolean>;
397
+ getPullRequestChecks(number: number, repo?: string): Promise<PullRequestChecks>;
168
398
  configurePages(config: PagesConfig, token: string): Promise<void>;
169
399
  }
170
- //#endregion
171
- //#region src/capabilities/teams.d.ts
400
+ /** A team entry with the permission spelled out. */
172
401
  interface NormalizedTeamEntry {
402
+ /** The team's slug. */
173
403
  slug: string;
404
+ /** The permission the team gets on the repo. */
174
405
  permission: TeamPermission;
175
406
  }
176
- declare function normalizeTeamEntry(entry: TeamEntry): NormalizedTeamEntry;
177
- declare function syncTeams(client: GitHubClient, repo: string, teams: TeamEntry[]): Promise<string>;
178
- //#endregion
179
- //#region src/sodium.d.ts
407
+ /** Turns a team entry into slug and permission form; a bare slug gets `push`. */
408
+ export declare function normalizeTeamEntry(entry: TeamEntry): NormalizedTeamEntry;
409
+ /** Grants each team access to the repo and reports the outcome; throws when every team fails. */
410
+ export declare function syncTeams(client: GitHubClient, repo: string, teams: TeamEntry[]): Promise<string>;
180
411
  /**
181
412
  * Encrypt `value` for the given GitHub-provided base64 public key.
182
413
  * Returns the base64 ciphertext to send as `encrypted_value`.
183
414
  */
184
- declare function encryptSecret(publicKeyBase64: string, value: string): Promise<string>;
185
- //#endregion
186
- //#region src/verify-token.d.ts
415
+ export declare function encryptSecret(publicKeyBase64: string, value: string): Promise<string>;
187
416
  /**
188
- * `verifyToken` — plugin-level export used by `holocron auth set` +
189
- * `holocron auth check`. Hits `GET /user` and translates the response
190
- * into the normalized `VerifyTokenResult` shape.
191
- *
192
- * Kept as a standalone function (not a capability method) so the auth
193
- * command can call it without initializing the full plugin — plugin
194
- * construction requires an already-resolved token, which is exactly
195
- * what we don't have yet at bootstrap time.
417
+ * Every token this plugin takes, for `holocron doctor tokens`, with what each layer's token must and must not be able
418
+ * to do. The release token is `optional`: only CI's release workflow reads it (from the org secret), so a development
419
+ * environment has no reason to hold it.
196
420
  */
197
- interface VerifyTokenSuccess {
198
- ok: true;
199
- subject: string;
200
- }
201
- interface VerifyTokenFailure {
202
- ok: false;
203
- message: string;
204
- }
205
- type VerifyTokenResult = VerifyTokenSuccess | VerifyTokenFailure;
421
+ export declare const tokens: PluginToken[];
422
+ /** Options for `verifyToken`. */
206
423
  interface VerifyTokenOptions {
424
+ /** Overrides the API base URL, for tests. */
207
425
  baseUrl?: string;
426
+ /** Overrides `fetch`, for tests. */
208
427
  fetch?: typeof fetch;
209
428
  }
210
- declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult>;
211
- //#endregion
212
- //#region src/index.d.ts
213
- interface GitHubPluginOptions extends ResolveTokenInput {
429
+ /** Checks a token against `GET /user` and returns who it belongs to, or why it failed. */
430
+ export declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult$1>;
431
+ /** Options for the GitHub plugin. */
432
+ export interface GitHubPluginOptions extends ResolveTokenInput {
214
433
  /** "owner/name" — e.g., "theholocron/holocron". Required. */
215
434
  repo: string;
216
435
  /** Absolute path to the working repo root. Used by `source`'s
@@ -218,39 +437,61 @@ interface GitHubPluginOptions extends ResolveTokenInput {
218
437
  repoRoot?: string;
219
438
  /** Lifecycle slot → label name. Used by the `issues` capability. */
220
439
  labels?: {
440
+ /** Label that marks an issue as in progress. */
221
441
  inProgress: string;
442
+ /** Label that marks an issue as in review. */
222
443
  inReview: string;
223
444
  };
445
+ /** `repo.labels` (the area map), handed in by the loader for the `issue-types` probe. */
446
+ areaLabels?: LabelsConfig;
224
447
  /** Override base URL for tests. Defaults to https://api.github.com. */
225
448
  baseUrl?: string;
226
449
  /** Override `fetch` for tests. Defaults to global `fetch`. */
227
450
  fetch?: typeof fetch;
228
451
  }
229
- interface PluginContext {
452
+ /** What the capability factories receive: the plugin options, a client, the repo and its root. */
453
+ export interface PluginContext {
454
+ /** The plugin options. */
230
455
  options: GitHubPluginOptions;
456
+ /** The GitHub client the capability uses. */
231
457
  client: GitHubClient;
458
+ /** The repo as `owner/name`. */
232
459
  repo: string;
460
+ /** Absolute path to the working repo root. */
233
461
  repoRoot: string;
234
462
  }
235
- declare function source(ctx: PluginContext, orgClient?: GitHubClient): Source;
236
- declare function secrets(ctx: PluginContext): Secrets;
237
- declare function environments(ctx: PluginContext): Environments;
238
- declare function ci(ctx: PluginContext): Ci;
239
- declare function issues(ctx: PluginContext): Issues;
240
- declare function createPlugin(options: GitHubPluginOptions): {
463
+ /** Builds the `source` capability; the optional clients cover org-level and user-sync access. */
464
+ export declare function source(ctx: PluginContext, orgClient?: GitHubClient, userSyncClient?: GitHubClient): Source;
465
+ /** Builds the `secrets` capability; the optional client handles organization secrets. */
466
+ export declare function secrets(ctx: PluginContext, orgClient?: GitHubClient): Secrets;
467
+ /** Builds the `environments` capability. */
468
+ export declare function environments(ctx: PluginContext): Environments;
469
+ /** Builds the `ci` capability. */
470
+ export declare function ci(ctx: PluginContext): Ci;
471
+ /** Builds the `issues` capability, passing the lifecycle labels when configured. */
472
+ export declare function issues(ctx: PluginContext): Issues;
473
+ /** Builds the `projects` capability: GitHub Projects v2 over GraphQL, with items keyed relative to the configured repo. */
474
+ export declare function projects(ctx: PluginContext): Projects;
475
+ /** Creates the plugin, resolving a token per capability when it is first used. */
476
+ export declare function createPlugin(options: GitHubPluginOptions): {
241
477
  name: string;
478
+ probes: {
479
+ token: import("@theholocron/cli").Probe;
480
+ "issue-types": import("@theholocron/cli").Probe;
481
+ connection: import("@theholocron/cli").Probe;
482
+ };
242
483
  capabilities: {
243
484
  source: () => Source;
244
485
  ci: () => Ci;
245
486
  secrets: () => Secrets;
246
487
  environments: () => Environments;
247
488
  issues: () => Issues;
489
+ projects: () => Projects;
248
490
  };
249
491
  };
250
492
  /**
251
- * One-line hint printed by `holocron auth set github` when no token
493
+ * One-line hint printed by `holocron new token github` when no token
252
494
  * is supplied or the supplied token is rejected.
253
495
  */
254
- declare const AUTH_HINT: string;
255
- //#endregion
256
- export { AUTH_HINT, type Auth, AuthError, type CanonicalLabel, GitHubCi, type GitHubClientOptions, GitHubEnvironments, GitHubIssues, GitHubPluginOptions, GitHubSecrets, GitHubSource, type NormalizedTeamEntry, PluginContext, type ResolveTokenInput, type TeamEntry, type TeamPermission, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, ci, createFeatureResolver, createGitHubClient, createPlugin, encryptSecret, environments, issues, normalizeTeamEntry, resolveAdminToken, resolveDeployToken, resolveIssuesToken, resolveOrgToken, resolveReadToken, resolveReleaseToken, resolveSyncToken, secrets, source, syncLabels, syncTeams, verifyToken };
496
+ export declare const AUTH_HINT: string;
497
+ export { type Auth, AuthError, type CanonicalLabel, type GitHubClientOptions, type NormalizedTeamEntry, type ProjectsOptions, type ResolveTokenInput, type TeamEntry, type TeamPermission, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createFeatureResolver, createGitHubClient };