@theholocron/cli 5.0.0-alpha.18 → 5.0.0-alpha.181

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/dist/index.mjs CHANGED
@@ -1,14 +1,16 @@
1
1
  import { CARDINALITY, ProviderApiError, REQUIRED_CAPABILITIES, WebhookVerificationError, isMulti } from "./plugin/capabilities.mjs";
2
2
  import { AuthError, createResolveToken as createResolveToken$1, createRestClient } from "@theholocron/http-client";
3
- import { createEnvLookup } from "@theholocron/env-utils";
3
+ import { createEnvLookup, withEnvPrefix } from "@theholocron/env-utils";
4
4
  import { Entry, findCredentials } from "@napi-rs/keyring";
5
- import { readFile } from "node:fs/promises";
6
5
  import { basename, dirname, join } from "node:path";
7
- import { execFile } from "node:child_process";
8
- import { promisify } from "node:util";
6
+ import { readPackageJson } from "@theholocron/pkg-utils";
9
7
  import { loadTasksConfig } from "@theholocron/astromech/config";
10
8
  import { ConfigFileError, ConfigFileError as ConfigFileError$1, loadConfigFile } from "@theholocron/datapad";
11
- createEnvLookup();
9
+ import { readGitRemote } from "@theholocron/git-utils";
10
+ //#region src/env/env.ts
11
+ /** Singleton env for simple global lookups throughout the CLI. */
12
+ const env = createEnvLookup();
13
+ withEnvPrefix(env, "HOLOCRON");
12
14
  /**
13
15
  * Create an injectable env for commands that accept a fake env in tests.
14
16
  * Pass `input.env` when available, falls back to `process.env`.
@@ -17,7 +19,7 @@ function makeEnv(source) {
17
19
  return createEnvLookup(source);
18
20
  }
19
21
  //#endregion
20
- //#region src/auth/keyring.ts
22
+ //#region src/auth/keyring/keyring.ts
21
23
  /**
22
24
  * Keyring-backed bootstrap credential store.
23
25
  *
@@ -87,7 +89,7 @@ function listStoredProviders() {
87
89
  }
88
90
  }
89
91
  //#endregion
90
- //#region src/auth/auth-resolver.ts
92
+ //#region src/auth/auth-resolver/auth-resolver.ts
91
93
  /** Wraps `createResolveToken` from `@theholocron/http` and injects the
92
94
  * system keyring so plugins stay at a one-liner call site. */
93
95
  function createResolveToken(config) {
@@ -113,7 +115,7 @@ function createFeatureResolver(config) {
113
115
  };
114
116
  }
115
117
  //#endregion
116
- //#region src/commands/setup/derived-properties.ts
118
+ //#region src/commands/setup/derived-properties/derived-properties.ts
117
119
  /**
118
120
  * Repo archetype, in priority order:
119
121
  * 1. `*-template` repo name → `template` (independent of package shape).
@@ -184,7 +186,7 @@ function deriveCapabilities(providers) {
184
186
  return Object.keys(providers ?? {}).sort();
185
187
  }
186
188
  /**
187
- * `source` + `ci` are the minimal baseline every repo `holocron setup`
189
+ * `source` + `ci` are the minimal baseline every repo `holocron repo setup`
188
190
  * touches wires — every `holocron.config.ts` in this org already satisfies
189
191
  * this, so `non-compliant` here means drift (a provider manually removed
190
192
  * after setup), not an unmet aspirational policy. Deliberately not a richer
@@ -196,6 +198,15 @@ function deriveCompliance(capabilities) {
196
198
  return REQUIRED_BASELINE.every((key) => capabilities.includes(key)) ? "compliant" : "non-compliant";
197
199
  }
198
200
  /**
201
+ * The Phase B refinement `deriveCompliance()`'s own doc comment names —
202
+ * *why* a repo is non-compliant, not just that it is. `[]` when compliant.
203
+ * Same `REQUIRED_BASELINE` `deriveCompliance()` checks against — one
204
+ * table, not two independently-maintained baselines.
205
+ */
206
+ function missingCapabilities(capabilities) {
207
+ return REQUIRED_BASELINE.filter((key) => !capabilities.includes(key));
208
+ }
209
+ /**
199
210
  * Reads each workspace package's actual `package.json` content (not just
200
211
  * `readWorkspacePackages()`'s `{ slug, name, dir }` — `deriveProfile()`'s
201
212
  * `platform` detection needs `bin`, which that helper doesn't carry).
@@ -204,14 +215,14 @@ function deriveCompliance(capabilities) {
204
215
  */
205
216
  async function readWorkspacePackageJsons(repoRoot, workspacePackages) {
206
217
  const results = [];
207
- for (const { slug, dir = "packages" } of workspacePackages) try {
208
- const raw = await readFile(join(repoRoot, dir, slug, "package.json"), "utf8");
209
- results.push(JSON.parse(raw));
210
- } catch {}
218
+ for (const { slug, dir = "packages" } of workspacePackages) {
219
+ const pkg = await readPackageJson(join(repoRoot, dir, slug));
220
+ if (pkg) results.push(pkg);
221
+ }
211
222
  return results;
212
223
  }
213
224
  //#endregion
214
- //#region src/config/config.ts
225
+ //#region src/config/config/config.ts
215
226
  var ConfigError = class extends Error {
216
227
  name = "ConfigError";
217
228
  };
@@ -315,11 +326,12 @@ function resolveConfig(raw) {
315
326
  docs,
316
327
  env: raw.env,
317
328
  log: raw.log,
318
- telemetry: raw.telemetry
329
+ telemetry: raw.telemetry,
330
+ eslint: raw.eslint
319
331
  };
320
332
  }
321
333
  //#endregion
322
- //#region src/config/compose.ts
334
+ //#region src/config/compose/compose.ts
323
335
  function taskName(e) {
324
336
  return typeof e === "string" ? e : e.name;
325
337
  }
@@ -407,12 +419,12 @@ function compose(...args) {
407
419
  };
408
420
  }
409
421
  //#endregion
410
- //#region src/config/define-config.ts
422
+ //#region src/config/define-config/define-config.ts
411
423
  function defineConfig(config) {
412
424
  return config;
413
425
  }
414
426
  //#endregion
415
- //#region src/config/load-config.ts
427
+ //#region src/config/load-config/load-config.ts
416
428
  /**
417
429
  * `holocron.config.{ts,js,mjs,cjs,json}` loader.
418
430
  *
@@ -424,34 +436,39 @@ function defineConfig(config) {
424
436
  * Probe order is TS-first (`.ts` → `.js` → `.mjs` → `.cjs` → `.json`) —
425
437
  * see ADR-0010 / issue #75 / #81.
426
438
  */
427
- const execFileAsync = promisify(execFile);
428
439
  /**
429
- * Read + parse + resolve `holocron.config.*` from the given directory.
440
+ * Read + parse + resolve `holocron.config.*` starting from the given
441
+ * directory, walking up through ancestors to the nearest `.git` boundary
442
+ * when `cwd` itself has no match — every command is usable from any
443
+ * subdirectory of a repo, not only its exact root (see
444
+ * `@theholocron/datapad`'s own doc comment for the stop conditions).
430
445
  * Throws {@link ConfigFileError} when nothing is found or a file cannot
431
- * be loaded, or `ConfigError` when the config is invalid.
446
+ * be loaded, or `ConfigError` when the config fails schema checks.
432
447
  */
433
448
  async function loadConfig(cwd) {
434
449
  const found = await loadConfigFile({
435
450
  cwd,
436
- name: "holocron"
451
+ name: "holocron",
452
+ walkUp: true
437
453
  });
438
454
  if (!found) throw new ConfigFileError$1(`no holocron.config.{ts,js,mjs,cjs,json} found in ${cwd}. Create one — see the README for the schema.`);
439
455
  return {
440
- resolved: resolveConfig(await deriveDefaults(dirname(found.filepath), found.config)),
456
+ resolved: resolveConfig(await deriveDefaults(found)),
441
457
  filepath: found.filepath
442
458
  };
443
459
  }
444
- async function deriveDefaults(configDir, raw) {
445
- const result = { ...raw };
460
+ async function deriveDefaults(found) {
461
+ const configDir = dirname(found.filepath);
462
+ const result = { ...found.config };
446
463
  if (!result.name) result.name = await readPackageJsonName(configDir) ?? basename(configDir);
447
464
  if (result.repo && !result.repo.name) {
448
- const repoName = await readGitRemote(configDir);
449
- if (repoName) result.repo = {
465
+ const remote = await readGitRemote(configDir);
466
+ if (remote?.host === "github.com") result.repo = {
450
467
  ...result.repo,
451
- name: repoName
468
+ name: remote.slug
452
469
  };
453
470
  }
454
- const manifest = await loadTasksConfig(configDir);
471
+ const manifest = await loadTasksConfig(configDir, { holocron: found });
455
472
  if (manifest.tasks) result.tasks = manifest.tasks;
456
473
  if (manifest.syncScripts !== void 0) result.syncScripts = manifest.syncScripts;
457
474
  if (manifest.holocronScript !== void 0) result.holocronScript = manifest.holocronScript;
@@ -460,31 +477,8 @@ async function deriveDefaults(configDir, raw) {
460
477
  return result;
461
478
  }
462
479
  async function readPackageJsonName(dir) {
463
- try {
464
- const content = await readFile(join(dir, "package.json"), "utf8");
465
- const pkg = JSON.parse(content);
466
- return typeof pkg.name === "string" ? pkg.name.replace(/^@[^/]+\//, "") : void 0;
467
- } catch {
468
- return;
469
- }
470
- }
471
- async function readGitRemote(dir) {
472
- try {
473
- const { stdout } = await execFileAsync("git", [
474
- "remote",
475
- "get-url",
476
- "origin"
477
- ], { cwd: dir });
478
- return parseGitRemoteUrl(stdout.trim());
479
- } catch {
480
- return;
481
- }
482
- }
483
- function parseGitRemoteUrl(url) {
484
- const httpsMatch = url.match(/github\.com\/([^/]+\/[^/]+?)(?:\.git)?$/);
485
- if (httpsMatch) return httpsMatch[1];
486
- const sshMatch = url.match(/github\.com:([^/]+\/[^/]+?)(?:\.git)?$/);
487
- if (sshMatch) return sshMatch[1];
480
+ const name = (await readPackageJson(dir))?.name;
481
+ return name === void 0 ? void 0 : name.replace(/^@[^/]+\//, "");
488
482
  }
489
483
  //#endregion
490
- export { AuthError, CARDINALITY, ConfigError, ConfigFileError, ProviderApiError, REQUIRED_CAPABILITIES, WebhookVerificationError, compose, createFeatureResolver, createResolveToken, createRestClient, defineConfig, deleteToken, deriveCapabilities, deriveCompliance, deriveProfile, deriveStack, getToken, isMulti, listStoredProviders, loadConfig, readWorkspacePackageJsons, resolveConfig, resolveEntry, resolvePluginPackage, setToken };
484
+ export { AuthError, CARDINALITY, ConfigError, ConfigFileError, ProviderApiError, REQUIRED_CAPABILITIES, WebhookVerificationError, compose, createFeatureResolver, createResolveToken, createRestClient, defineConfig, deleteToken, deriveCapabilities, deriveCompliance, deriveProfile, deriveStack, getToken, isMulti, listStoredProviders, loadConfig, missingCapabilities, readWorkspacePackageJsons, resolveConfig, resolveEntry, resolvePluginPackage, setToken };
@@ -1,5 +1,5 @@
1
1
  import { ProviderApiError } from "@theholocron/http-client";
2
- //#region src/plugin/capabilities.d.ts
2
+ //#region src/plugin/capabilities/capabilities.type.d.ts
3
3
  /**
4
4
  * Capability interfaces — the contracts that providers implement.
5
5
  *
@@ -12,33 +12,8 @@ import { ProviderApiError } from "@theholocron/http-client";
12
12
  * See `docs/wiki/specifications/tech-architecture.spec.md` for the design narrative
13
13
  * (issue: #74).
14
14
  */
15
- type CapabilityKey = "source" | "ci" | "secrets" | "environments" | "issues" | "deployment" | "storage" | "auth" | "vault" | "dns" | "tooling" | "notifications" | "analytics" | "errors" | "logs" | "wiki" | "workers";
15
+ type CapabilityKey = "source" | "ci" | "secrets" | "environments" | "issues" | "deployment" | "storage" | "auth" | "vault" | "dns" | "tooling" | "notifications" | "analytics" | "errors" | "logs" | "monitoring" | "wiki" | "workers";
16
16
  type Cardinality = "single" | "many";
17
- declare const CARDINALITY: {
18
- readonly source: "single";
19
- readonly ci: "single";
20
- readonly secrets: "single";
21
- readonly environments: "single";
22
- readonly issues: "single";
23
- readonly deployment: "single";
24
- readonly storage: "single";
25
- readonly auth: "single";
26
- readonly vault: "single";
27
- readonly dns: "single";
28
- readonly tooling: "many";
29
- readonly notifications: "many";
30
- readonly analytics: "many";
31
- readonly errors: "single";
32
- readonly logs: "single";
33
- readonly wiki: "single";
34
- readonly workers: "single";
35
- };
36
- /**
37
- * No capabilities are strictly required — repos without secrets (e.g. org
38
- * community health repos) legitimately omit vault. Plugins validate their
39
- * own requirements at call time.
40
- */
41
- declare const REQUIRED_CAPABILITIES: readonly CapabilityKey[];
42
17
  interface ProviderIdentity {
43
18
  readonly key: CapabilityKey;
44
19
  readonly providerName: string;
@@ -364,9 +339,35 @@ interface DeploymentRecord {
364
339
  target?: DeploymentTrigger;
365
340
  status: "queued" | "building" | "ready" | "error" | "cancelled";
366
341
  createdAt?: string;
342
+ /** The provider's own reason when `status` is `"error"` (e.g. Vercel's `Command "npm install" exited with 1`). */
343
+ errorMessage?: string;
344
+ }
345
+ /** Config for `Deployment.deployFunction()` — source files, not a Git ref. */
346
+ interface DeployFunctionConfig {
347
+ /**
348
+ * Files to deploy, keyed by path relative to the project root (e.g.
349
+ * `"api/webhook.js"`, `"package.json"`). Content is plain text — the
350
+ * provider handles any wire-format encoding.
351
+ */
352
+ files: Record<string, string>;
353
+ /**
354
+ * Named deployment target. Omit for a preview deployment — same
355
+ * semantics as `triggerDeployment`'s `target`.
356
+ */
357
+ target?: DeploymentTrigger;
358
+ }
359
+ interface DeployFunctionResult {
360
+ deploymentId: string;
361
+ url: string;
367
362
  }
368
363
  interface Deployment extends ProviderIdentity {
369
364
  readonly key: "deployment";
365
+ /**
366
+ * Custom domain declared in the deployment provider's configuration.
367
+ * `holocron repo setup` attaches it to the configured project and hands any
368
+ * returned verification record to the `dns` capability.
369
+ */
370
+ readonly domain?: string;
370
371
  listProjects(): Promise<DeploymentProject[]>;
371
372
  /** Create if missing, otherwise return existing. Idempotent. */
372
373
  ensureProject(input: {
@@ -390,6 +391,16 @@ interface Deployment extends ProviderIdentity {
390
391
  target?: DeploymentTrigger;
391
392
  }): Promise<DeploymentRecord>;
392
393
  getDeployment(deploymentId: string): Promise<DeploymentRecord>;
394
+ /**
395
+ * Deploy (or update) a project directly from source files, bypassing
396
+ * Git entirely — the non-git counterpart to `triggerDeployment`, for a
397
+ * consumer with no repo to link (a webhook receiver shipped as an npm
398
+ * package, for instance, rather than deployed from its own Git
399
+ * history). `projectId` may be a project name for providers that
400
+ * accept either. Optional — providers without a files-based deploy API
401
+ * omit this (e.g. Cloudflare Pages, git-source only today).
402
+ */
403
+ deployFunction?(projectId: string, config: DeployFunctionConfig): Promise<DeployFunctionResult>;
393
404
  /**
394
405
  * List preview deployments for a specific branch alias (e.g. "repo-pr-42").
395
406
  * Optional — providers that don't support listing by branch omit this.
@@ -402,10 +413,18 @@ interface Deployment extends ProviderIdentity {
402
413
  deletePreviewDeployments?(projectId: string, deploymentIds: string[]): Promise<number>;
403
414
  /**
404
415
  * Add a custom domain (or wildcard) to the project. Idempotent — no-op
405
- * when the domain is already present. Optional: providers without a custom
406
- * domain API omit this (e.g. Vercel manages domains separately).
416
+ * when the domain is already present. Optional: providers without a
417
+ * custom domain API omit this.
418
+ *
419
+ * Returns the DNS record needed to finish verification — `null` when
420
+ * the domain is already verified, or when the provider's API doesn't
421
+ * surface DNS-challenge details at all (e.g. Cloudflare Pages, whose
422
+ * custom-domain flow doesn't expose the same per-request verification
423
+ * handshake Vercel's does). Callers hand a non-null result straight
424
+ * to `dns.upsertRecord(result.zone, result.record)` — the exact
425
+ * pattern `setup` already uses for `Wiki.dnsRecord()`.
407
426
  */
408
- ensureCustomDomain?(projectId: string, hostname: string): Promise<void>;
427
+ ensureCustomDomain?(projectId: string, hostname: string): Promise<DnsRecordRequest | null>;
409
428
  }
410
429
  interface StorageBranch {
411
430
  id: string;
@@ -517,9 +536,6 @@ interface ParseWebhookInput {
517
536
  /** The signing secret the auth provider issued for this webhook endpoint. */
518
537
  signingSecret: string;
519
538
  }
520
- declare class WebhookVerificationError extends Error {
521
- name: string;
522
- }
523
539
  interface EnsureResult {
524
540
  /** True when the resource already existed (idempotent no-op). */
525
541
  alreadyExists: boolean;
@@ -573,11 +589,31 @@ interface DnsRecord {
573
589
  priority?: number;
574
590
  proxied?: boolean;
575
591
  }
592
+ /**
593
+ * A DNS record a capability wants created, plus which zone it belongs
594
+ * to — the shape `Wiki.dnsRecord()` and `Deployment.ensureCustomDomain()`
595
+ * both hand off to `Dns.upsertRecord()`. Not tied to either capability;
596
+ * any provider that needs "here's a record, go create it" returns this.
597
+ */
598
+ interface DnsRecordRequest {
599
+ /** Zone apex passed as the first argument to `dns.upsertRecord`. */
600
+ zone: string;
601
+ record: DnsRecord;
602
+ }
576
603
  interface Dns extends ProviderIdentity {
577
604
  readonly key: "dns";
578
605
  listRecords(domain: string): Promise<DnsRecord[]>;
579
606
  upsertRecord(domain: string, record: DnsRecord): Promise<DnsRecord>;
580
607
  deleteRecord(domain: string, id: string): Promise<void>;
608
+ /**
609
+ * A `holocron doctor` smoke check with no specific domain to ask about —
610
+ * `listRecords` needs one, but doctor doesn't have one on hand. Verifies
611
+ * the token and reports how many zones it can see.
612
+ */
613
+ whoami?(): Promise<{
614
+ ok: boolean;
615
+ zones: number;
616
+ }>;
581
617
  }
582
618
  interface Errors extends ProviderIdentity {
583
619
  readonly key: "errors";
@@ -586,9 +622,17 @@ interface Errors extends ProviderIdentity {
586
622
  provider: string;
587
623
  envKeys: string[];
588
624
  }>;
625
+ /**
626
+ * Reachability probe. `null` means the check genuinely can't run right
627
+ * now on an otherwise-valid configuration (e.g. Sentry's optional `org`
628
+ * setting is unset — error ingestion still works from the DSN alone,
629
+ * `org` is only needed for the management-API calls `whoami` makes) —
630
+ * callers should fall back to `describe()`, not treat it as a failure.
631
+ * Still throws for a genuine failure (bad token, network error, etc.).
632
+ */
589
633
  whoami?(): Promise<{
590
634
  org: string;
591
- }>;
635
+ } | null>;
592
636
  ensureProject?(input: {
593
637
  name: string;
594
638
  platform?: string;
@@ -614,6 +658,74 @@ interface Logs extends ProviderIdentity {
614
658
  alreadyExists: boolean;
615
659
  }>;
616
660
  }
661
+ type MonitoringAssertionSource = "status_code" | "response_time" | "body" | "header";
662
+ type MonitoringAssertionComparison = "equals" | "not_equals" | "contains" | "not_contains" | "greater_than" | "less_than";
663
+ interface MonitoringAssertion {
664
+ source: MonitoringAssertionSource;
665
+ comparison: MonitoringAssertionComparison;
666
+ /** Header name / JSON path — required when `source` needs one (e.g. `"header"`). */
667
+ property?: string;
668
+ target?: string;
669
+ }
670
+ type MonitoringHttpMethod = "GET" | "POST" | "PUT" | "HEAD" | "DELETE" | "PATCH";
671
+ interface MonitoringCheckInput {
672
+ /** Also the idempotency key — `ensureCheck` finds-or-creates by this name. */
673
+ name: string;
674
+ url: string;
675
+ method?: MonitoringHttpMethod;
676
+ /** Minutes between runs. Adapters round to their own supported values. */
677
+ frequency?: number;
678
+ assertions?: MonitoringAssertion[];
679
+ activated?: boolean;
680
+ /**
681
+ * Provider-specific region/datacenter ids to run the check from (e.g.
682
+ * Checkly's `"us-east-1"`). Required by some providers — there's no
683
+ * universal default; an account with none configured rejects a check
684
+ * that omits this entirely.
685
+ */
686
+ locations?: string[];
687
+ /**
688
+ * Inverts pass/fail: set this when the check's expected-healthy
689
+ * response is itself an HTTP error status (e.g. asserting a 404/405
690
+ * on an endpoint that should reject certain requests). Without it,
691
+ * most providers classify any 4xx/5xx response as a failure at the
692
+ * platform level *before* evaluating `assertions` at all — a custom
693
+ * assertion that matches the "expected" error status does not
694
+ * override that baseline classification on its own.
695
+ */
696
+ shouldFail?: boolean;
697
+ /**
698
+ * Raw request body to send with the check — e.g. simulating a webhook
699
+ * delivery to verify signature/auth checking is wired correctly
700
+ * end-to-end, rather than just confirming the endpoint is reachable.
701
+ * Omitted entirely by default (no body sent).
702
+ */
703
+ body?: string;
704
+ }
705
+ interface MonitoringCheck {
706
+ id: string;
707
+ name: string;
708
+ }
709
+ interface Monitoring extends ProviderIdentity {
710
+ readonly key: "monitoring";
711
+ /**
712
+ * Checks this provider is configured to ensure exist — populated from
713
+ * the provider's own config (`holocron.config.ts`'s provider tuple),
714
+ * the same place `Deployment.domain` comes from. `holocron repo setup`
715
+ * loops this list and calls `ensureCheck` for each; empty when none
716
+ * are configured.
717
+ */
718
+ readonly checks: readonly MonitoringCheckInput[];
719
+ /** Auth sanity-check. Throws ProviderApiError on auth failure. */
720
+ whoami?(): Promise<{
721
+ ok: boolean;
722
+ }>;
723
+ /** Idempotent find-or-create-or-update by `input.name`. */
724
+ ensureCheck(input: MonitoringCheckInput): Promise<{
725
+ check: MonitoringCheck;
726
+ alreadyExists: boolean;
727
+ }>;
728
+ }
617
729
  interface ToolingDoctorReport {
618
730
  ok: boolean;
619
731
  message: string;
@@ -624,6 +736,46 @@ interface Tooling extends ProviderIdentity {
624
736
  sync(): Promise<void>;
625
737
  doctor(): Promise<ToolingDoctorReport>;
626
738
  }
739
+ /** What an `ensure*` call found or made. `created: false` means it already existed. */
740
+ interface EnsuredResource {
741
+ id: string;
742
+ created: boolean;
743
+ }
744
+ /** A webhook (or equivalent inbound URL) for a channel. */
745
+ interface EnsureWebhookResult {
746
+ created: boolean;
747
+ /**
748
+ * The posting URL — a credential. Absent when the webhook already existed and
749
+ * the provider will not reveal it again (Discord returns the token only to
750
+ * the application that created the webhook, and only on creation).
751
+ */
752
+ url?: string;
753
+ }
754
+ /** One channel in a {@link NotificationsLayout}. */
755
+ interface NotificationsChannelLayout {
756
+ name: string;
757
+ topic?: string;
758
+ /**
759
+ * Create an inbound webhook for the channel and store its URL in a secret.
760
+ * `true` uses the defaults; the object form overrides the webhook's display
761
+ * name and the secret's name.
762
+ */
763
+ webhook?: boolean | {
764
+ name?: string;
765
+ secret?: string;
766
+ };
767
+ }
768
+ /** A declared server layout, applied idempotently by `holocron notifications setup`. */
769
+ interface NotificationsLayout {
770
+ categories?: Array<{
771
+ name: string;
772
+ channels?: NotificationsChannelLayout[];
773
+ }>;
774
+ roles?: Array<{
775
+ name: string;
776
+ mentionable?: boolean;
777
+ }>;
778
+ }
627
779
  interface Notifications extends ProviderIdentity {
628
780
  readonly key: "notifications";
629
781
  /**
@@ -631,6 +783,31 @@ interface Notifications extends ProviderIdentity {
631
783
  * Discord webhook url-name, etc.); adapters resolve from config.
632
784
  */
633
785
  send(channel: string, message: string): Promise<void>;
786
+ /**
787
+ * The server layout the owner declared for this provider, if any. Read by
788
+ * `holocron notifications setup`; the provider just carries it from its options.
789
+ */
790
+ readonly layout?: NotificationsLayout;
791
+ /**
792
+ * Provisioning. All optional, all idempotent (look up by name, create only
793
+ * what is missing), and all need provider credentials beyond the posting
794
+ * URL — so a provider that only posts simply omits them.
795
+ */
796
+ ensureCategory?(name: string): Promise<EnsuredResource>;
797
+ ensureChannel?(input: {
798
+ name: string;
799
+ category?: string;
800
+ topic?: string;
801
+ }): Promise<EnsuredResource>;
802
+ ensureWebhook?(input: {
803
+ channel: string;
804
+ name: string;
805
+ category?: string;
806
+ }): Promise<EnsureWebhookResult>;
807
+ ensureRole?(input: {
808
+ name: string;
809
+ mentionable?: boolean;
810
+ }): Promise<EnsuredResource>;
634
811
  }
635
812
  interface Analytics extends ProviderIdentity {
636
813
  readonly key: "analytics";
@@ -651,18 +828,6 @@ interface WikiProvisionOpts {
651
828
  /** Project display name used in the wiki title (e.g. "Holocron"). */
652
829
  name?: string;
653
830
  }
654
- /**
655
- * DNS record that `setup` should create for a wiki custom domain.
656
- * Returned by `Wiki.dnsRecord()` when a custom domain is configured.
657
- */
658
- interface WikiDnsRecord {
659
- /** Zone apex passed as the first argument to `dns.upsertRecord`. */
660
- zone: string;
661
- /** Full hostname for the CNAME (e.g. "wiki.theholocron.dev"). */
662
- cname: string;
663
- /** CNAME target (e.g. "holocron.docs.buildwithfern.com"). */
664
- target: string;
665
- }
666
831
  /**
667
832
  * Reverse-proxy configuration returned by `Wiki.proxyConfig()`.
668
833
  * Used by `setup` to deploy a Worker that forwards traffic to the wiki
@@ -691,7 +856,7 @@ interface Wiki extends ProviderIdentity {
691
856
  * Returns null when no custom domain is set.
692
857
  * Called by `setup` to provision the CNAME via the `dns` capability.
693
858
  */
694
- dnsRecord?(): WikiDnsRecord | null;
859
+ dnsRecord?(): DnsRecordRequest | null;
695
860
  /**
696
861
  * Reverse-proxy config when the wiki provider requires a Worker-level
697
862
  * proxy in addition to the CNAME. Returns null when no proxy is needed.
@@ -699,12 +864,34 @@ interface Wiki extends ProviderIdentity {
699
864
  */
700
865
  proxyConfig?(): WikiProxyConfig | null;
701
866
  }
867
+ /** Config for `Workers.deployScript()` — an arbitrary Worker, not a generated reverse-proxy. */
868
+ interface DeployScriptConfig {
869
+ /** The full Worker script source — a single ES module (`export default { fetch(...) {...} }`). */
870
+ code: string;
871
+ /**
872
+ * Secret bindings — `env.<name>` in the deployed Worker. Values are
873
+ * write-only; the provider never echoes them back, here or anywhere else.
874
+ */
875
+ secrets?: Record<string, string>;
876
+ /**
877
+ * Route pattern(s) this Worker should serve (e.g.
878
+ * `"sentinel.theholocron.dev/*"`). Omit for a Worker reached only via
879
+ * its `*.workers.dev` URL.
880
+ */
881
+ routes?: string[];
882
+ }
883
+ interface DeployScriptResult {
884
+ /** The deployed script's name at the provider. */
885
+ scriptName: string;
886
+ }
702
887
  /**
703
- * Edge Worker / reverse-proxy management capability.
888
+ * Edge Worker management capability.
704
889
  *
705
- * Deploys and manages Worker scripts that proxy traffic to a configured
706
- * target. Used by `setup` to wire wiki custom-domain proxies when the
707
- * wiki provider requires a Worker in addition to the CNAME.
890
+ * Deploys and manages Worker scripts. `upsertProxy` is the existing,
891
+ * narrower case `setup` uses to wire wiki custom-domain reverse-proxies;
892
+ * `deployScript` is the general case — any Worker, any code, its own
893
+ * secrets — for a consumer that isn't a reverse-proxy (a webhook
894
+ * receiver, for instance).
708
895
  */
709
896
  interface Workers extends ProviderIdentity {
710
897
  readonly key: "workers";
@@ -714,6 +901,17 @@ interface Workers extends ProviderIdentity {
714
901
  * `config.headers` on each request.
715
902
  */
716
903
  upsertProxy(hostname: string, config: WikiProxyConfig): Promise<void>;
904
+ /** Deploy (or update) an arbitrary Worker script, optionally with secrets and routes. */
905
+ deployScript(name: string, config: DeployScriptConfig): Promise<DeployScriptResult>;
906
+ /**
907
+ * A `holocron doctor` smoke check — every other method either mutates or
908
+ * needs a specific script/zone doctor has no way to supply up front.
909
+ * Reports how many Worker scripts the token can see.
910
+ */
911
+ whoami?(): Promise<{
912
+ ok: boolean;
913
+ scripts: number;
914
+ }>;
717
915
  }
718
916
  interface CapabilityImpls {
719
917
  source: Source;
@@ -731,12 +929,44 @@ interface CapabilityImpls {
731
929
  analytics: Analytics;
732
930
  errors: Errors;
733
931
  logs: Logs;
932
+ monitoring: Monitoring;
734
933
  wiki: Wiki;
735
934
  workers: Workers;
736
935
  }
737
936
  type CardinalityFor<K extends CapabilityKey> = (typeof CARDINALITY)[K];
738
937
  /** Resolved runtime shape: single → one impl; many → array. */
739
938
  type ResolvedCapability<K extends CapabilityKey> = CardinalityFor<K> extends "many" ? CapabilityImpls[K][] : CapabilityImpls[K];
939
+ //#endregion
940
+ //#region src/plugin/capabilities/capabilities.d.ts
941
+ declare const CARDINALITY: {
942
+ readonly source: "single";
943
+ readonly ci: "single";
944
+ readonly secrets: "single";
945
+ readonly environments: "single";
946
+ readonly issues: "single";
947
+ readonly deployment: "single";
948
+ readonly storage: "single";
949
+ readonly auth: "single";
950
+ readonly vault: "single";
951
+ readonly dns: "single";
952
+ readonly tooling: "many";
953
+ readonly notifications: "many";
954
+ readonly analytics: "many";
955
+ readonly errors: "single";
956
+ readonly logs: "single";
957
+ readonly monitoring: "single";
958
+ readonly wiki: "single";
959
+ readonly workers: "single";
960
+ };
961
+ /**
962
+ * No capabilities are strictly required — repos without secrets (e.g. org
963
+ * community health repos) legitimately omit vault. Plugins validate their
964
+ * own requirements at call time.
965
+ */
966
+ declare const REQUIRED_CAPABILITIES: readonly CapabilityKey[];
967
+ declare class WebhookVerificationError extends Error {
968
+ name: string;
969
+ }
740
970
  declare function isMulti<K extends CapabilityKey>(key: K): CardinalityFor<K> extends "many" ? true : false;
741
971
  //#endregion
742
- export { Analytics, Auth, AuthDescription, AuthEvent, AuthEventType, AuthIdentity, AuthUser, CARDINALITY, CapabilityImpls, CapabilityKey, Cardinality, CardinalityFor, Ci, CiRun, CiRunFilter, CiRunStatus, ConnectionStringOptions, CreateAuthUserInput, Deployment, DeploymentProject, DeploymentProjectSettings, DeploymentRecord, DeploymentTarget, DeploymentTrigger, Dns, DnsRecord, DnsRecordType, EnsureResult, Environment, EnvironmentReviewer, Environments, Errors, Issue, IssueSearchFilter, Issues, LabelDef, LifecycleResult, LifecycleSlot, Logs, NormalizedAuthUser, Notifications, PagesConfig, ParseWebhookInput, ProviderApiError, ProviderIdentity, PullRequest, REQUIRED_CAPABILITIES, RepoRef, RepoSettings, ResolvedCapability, Ruleset, SecretScope, Secrets, Source, StatusCategory, Storage, StorageBranch, TeamEntry, TeamPermission, Tooling, ToolingDoctorReport, TrackerDoctorReport, TrackerUser, Vault, WebhookDashboardInfo, WebhookVerificationError, Wiki, WikiDnsRecord, WikiProvisionOpts, WikiProxyConfig, Workers, isMulti };
972
+ export { Analytics, Auth, AuthDescription, AuthEvent, AuthEventType, AuthIdentity, AuthUser, CARDINALITY, CapabilityImpls, CapabilityKey, Cardinality, CardinalityFor, Ci, CiRun, CiRunFilter, CiRunStatus, ConnectionStringOptions, CreateAuthUserInput, DeployFunctionConfig, DeployFunctionResult, DeployScriptConfig, DeployScriptResult, Deployment, DeploymentProject, DeploymentProjectSettings, DeploymentRecord, DeploymentTarget, DeploymentTrigger, Dns, DnsRecord, DnsRecordRequest, DnsRecordType, EnsureResult, EnsureWebhookResult, EnsuredResource, Environment, EnvironmentReviewer, Environments, Errors, Issue, IssueSearchFilter, Issues, LabelDef, LifecycleResult, LifecycleSlot, Logs, Monitoring, MonitoringAssertion, MonitoringAssertionComparison, MonitoringAssertionSource, MonitoringCheck, MonitoringCheckInput, MonitoringHttpMethod, NormalizedAuthUser, Notifications, NotificationsChannelLayout, NotificationsLayout, PagesConfig, ParseWebhookInput, ProviderApiError, ProviderIdentity, PullRequest, REQUIRED_CAPABILITIES, RepoRef, RepoSettings, ResolvedCapability, Ruleset, SecretScope, Secrets, Source, StatusCategory, Storage, StorageBranch, TeamEntry, TeamPermission, Tooling, ToolingDoctorReport, TrackerDoctorReport, TrackerUser, Vault, WebhookDashboardInfo, WebhookVerificationError, Wiki, WikiProvisionOpts, WikiProxyConfig, Workers, isMulti };
@@ -1,5 +1,5 @@
1
1
  import { ProviderApiError } from "@theholocron/http-client";
2
- //#region src/plugin/capabilities.ts
2
+ //#region src/plugin/capabilities/capabilities.ts
3
3
  const CARDINALITY = {
4
4
  source: "single",
5
5
  ci: "single",
@@ -16,6 +16,7 @@ const CARDINALITY = {
16
16
  analytics: "many",
17
17
  errors: "single",
18
18
  logs: "single",
19
+ monitoring: "single",
19
20
  wiki: "single",
20
21
  workers: "single"
21
22
  };