@theholocron/cli 5.0.0-alpha.489 → 5.0.0-alpha.490

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.d.mts CHANGED
@@ -371,6 +371,144 @@ export declare function roleTeamProblem(layout: {
371
371
  * Lines go to `input.print` when it is given, and nowhere otherwise.
372
372
  */
373
373
  export declare function syncRoles(input: SyncRolesInput): Promise<SyncRolesResult>;
374
+ /** Why a pull request moves an item's status. */
375
+ type PullRequestStatusReason = "pull-request-open" | "checks-green" | "checks-failed";
376
+ /** The status change a pull request asks for. */
377
+ interface PullRequestStatusChange {
378
+ /** The item's `issues` key. */
379
+ key: string;
380
+ /** The item's title, for the printed line. */
381
+ title: string;
382
+ /** The status it holds now. */
383
+ from: string;
384
+ /** The template's status it is set to. */
385
+ to: string;
386
+ /** The category of `to`. */
387
+ category: Extract<BoardStatusCategory, "active" | "review">;
388
+ /** Which rule applies. */
389
+ reason: PullRequestStatusReason;
390
+ }
391
+ /** A rule applies, but the template has no status of the category to set. Reported, never guessed. */
392
+ interface PullRequestStatusUnresolved {
393
+ /** The item's `issues` key. */
394
+ key: string;
395
+ /** The item's title. */
396
+ title: string;
397
+ /** The category the rule wanted. */
398
+ category: PullRequestStatusChange["category"];
399
+ /** Which rule applies. */
400
+ reason: PullRequestStatusReason;
401
+ }
402
+ /** What {@link planPullRequestStatus} decided: a change or an unresolved rule (it returns `undefined` for nothing). */
403
+ type PullRequestStatusPlan = {
404
+ kind: "change";
405
+ change: PullRequestStatusChange;
406
+ } | {
407
+ kind: "unresolved";
408
+ unresolved: PullRequestStatusUnresolved;
409
+ };
410
+ /**
411
+ * Decide the status an item's linked pull requests ask for (spec `tech-board-status-automation`, #2388). Pure: it reads
412
+ * one item and the template and touches nothing; status only, never priority or any other field.
413
+ *
414
+ * - an open linked pull request (a draft counts) puts the item in `active`;
415
+ * - an open one whose aggregate check is `success` puts it in `review`;
416
+ * - when the item is in `review` and no open pull request is green, a `failure` moves it back to `active`, while
417
+ * `pending` and `none` leave it, so a re-run after a push does not flicker the board;
418
+ * - no open pull request: no change (closed and merged ones are `planReconcile()`'s, through the closed issue).
419
+ *
420
+ * Left to `planReconcile()`, which runs first: a closed item, an item with an open blocker or in `blocked`, and an
421
+ * item with no status (reported there, not set). An item in `done` is left alone. Where the template has no status of
422
+ * the wanted category the rule comes back as `unresolved` and nothing is guessed; where a category has several statuses
423
+ * the first in template order is used. Applying the change and planning again gives no change.
424
+ */
425
+ export declare function planPullRequestStatus(item: BoardItem, template: BoardTemplate): PullRequestStatusPlan | undefined;
426
+ /** Why an item's status is changed. */
427
+ type ReconcileReason = "blocked" | "unblocked" | "closed" | PullRequestStatusReason;
428
+ /** One status change `reconcile` makes. */
429
+ interface ReconcileChange {
430
+ /** The item's `issues` key. */
431
+ key: string;
432
+ /** The item's title, for the printed line. */
433
+ title: string;
434
+ /** The status it holds now, or undefined for none. */
435
+ from?: string;
436
+ /** The template's status it is set to. */
437
+ to: string;
438
+ /** The category of `to`. */
439
+ category: Extract<BoardStatusCategory, "blocked" | "planned" | "done" | "active" | "review">;
440
+ /** Which rule applies. */
441
+ reason: ReconcileReason;
442
+ }
443
+ /** An item a rule applies to, but whose template has no status of the category to set. Reported, never guessed. */
444
+ interface ReconcileUnresolved {
445
+ /** The item's `issues` key. */
446
+ key: string;
447
+ /** The item's title. */
448
+ title: string;
449
+ /** The category the rule wanted. */
450
+ category: ReconcileChange["category"];
451
+ /** Which rule applies. */
452
+ reason: ReconcileReason;
453
+ }
454
+ /** What {@link planReconcile} decided. */
455
+ interface ReconcilePlan {
456
+ /** The status changes to make, in the items' order. */
457
+ changes: ReconcileChange[];
458
+ /** Open items with no status: reported, not set, since they need a decision and not a rule. */
459
+ unset: BoardItem[];
460
+ /** Items a rule applies to whose template lacks a status of the category. */
461
+ unresolved: ReconcileUnresolved[];
462
+ }
463
+ /**
464
+ * Decide the status changes that keep a board true (spec `command-project`, "Keeping a board true"). Pure: it reads
465
+ * the items and the template and touches nothing. Status only, never priority or any other field.
466
+ *
467
+ * - closed or merged, not in a `done` status: set to `done` (whatever the blockers say);
468
+ * - open with no status: not changed, listed in `unset` (it needs a decision, not a rule; this holds even when it has a
469
+ * blocker);
470
+ * - open with an open blocker, not in a `blocked` status: set to `blocked`;
471
+ * - open, in a `blocked` status, with no open blocker: set to `planned` (the status it held before is unknown).
472
+ *
473
+ * Where a category has several statuses the first in template order is used; where it has none the item is listed in
474
+ * `unresolved` and nothing is guessed. An item's category is read from the template by its status name, falling back
475
+ * to the one the provider reports. Applying the changes and planning again gives no change.
476
+ */
477
+ export declare function planReconcile(items: readonly BoardItem[], template: BoardTemplate): ReconcilePlan;
478
+ /** One board a repo keeps: which template it follows and what it is called. */
479
+ interface BoardDeclaration {
480
+ /** The template's name, a built-in or a file in the templates directory. */
481
+ template: string;
482
+ /** The board's name, which is how it is found among the open boards. */
483
+ name: string;
484
+ }
485
+ /** The options of `providers.projects`, with their defaults filled in. */
486
+ interface ProjectOptions {
487
+ /** Whoever the boards belong to (a GitHub organization): the `org` option, else the config's `org`. */
488
+ owner: string;
489
+ /** The boards this repo keeps, template to name. Empty when the option is absent. */
490
+ boards: BoardDeclaration[];
491
+ /** The directory holding the repo's own template files, relative to the repo root. */
492
+ templatesDir: string;
493
+ }
494
+ /** What {@link resolveProjectOptions} made: the options, or every problem with them. */
495
+ type ResolveProjectOptionsResult = {
496
+ ok: true;
497
+ options: ProjectOptions;
498
+ } | {
499
+ ok: false;
500
+ problems: string[];
501
+ };
502
+ /** Where a repo's own template files live unless the `templates` option says otherwise. */
503
+ export declare const DEFAULT_TEMPLATES_DIR = ".holocron/projects";
504
+ /**
505
+ * Read the options of `providers.projects`: `org` (the owner, defaulting to `fallbackOwner`, the config's org), `boards`
506
+ * (a list of `{ template, name }`, nothing else about a board is written in the config) and `templates` (the directory
507
+ * of template files). Every problem is listed at once, and two boards with the same name are one.
508
+ */
509
+ export declare function resolveProjectOptions(options: Readonly<Record<string, unknown>>, fallbackOwner: string): ResolveProjectOptionsResult;
510
+ /** The templates that ship in `@theholocron/cli`, by name. A repo's own template with the same name replaces one. */
511
+ export declare const BUILTIN_TEMPLATES: Readonly<Record<string, BoardTemplate>>;
374
512
  /**
375
513
  * The labels every repository gets from `setup`, with their GitHub colours (hex, no `#`) and descriptions. A
376
514
  * plugin that makes labels of its own, such as Linear's setup, takes the colour of the one with the same name.
@@ -549,4 +687,4 @@ export declare const SHARED_AREAS: readonly ["org"];
549
687
  * is a `ConfigError` naming both (no merge, no precedence). With no area files the config is returned as it was.
550
688
  */
551
689
  export declare function placeAreas(areas: ConfigDirArea[], raw: HolocronConfig): HolocronConfig;
552
- export { AddedItem, type AgentName, type AgentOptions, Analytics, type AppConfig, Auth, AuthDescription, AuthError, AuthEvent, AuthEventType, type AuthExportOutKind, AuthIdentity, AuthUser, BoardField, BoardFieldType, BoardItem, BoardItemInput, BoardPullRequest, BoardPullRequestChecks, BoardRule, BoardState, BoardStatus, BoardStatusCategory, BoardSummary, BoardTemplate, BoardTemplateFile, BoardView, CARDINALITY, Cache, CacheTokenCheck, type Capability, type CapabilityConfigPackage, CapabilityImpls, CapabilityKey, Cardinality, CardinalityFor, type ChromaticProjectConfig, Ci, CiRun, CiRunFilter, CiRunStatus, type ComposedPreset, ConfigError, ConfigFileError, ConnectionStringOptions, Coverage, CoverageConfigComponent, CoverageConfigDocumentation, CoverageConfigInput, CoverageExpectations, CoverageNameDiff, CoverageRepoReport, CoverageStatusContext, CoverageStatusInput, CoverageTokenCheck, CoverageUploadFlagResult, CoverageUploadGroup, CoverageUploadInput, CoverageUploadResult, CreateAuthUserInput, Credentials, type CredentialsConfig, CredentialsInspection, DeployFunctionConfig, DeployFunctionResult, DeployScriptConfig, DeployScriptResult, Deployment, DeploymentProject, DeploymentProjectSettings, DeploymentRecord, DeploymentTarget, DeploymentTrigger, type DeriveProfileInput, type DevConfig, type DevServeConfig, DiscussionPatch, DiscussionPost, Dns, DnsRecord, DnsRecordRequest, DnsRecordType, type DocsConfig, type DoctorConfig, DuplicateDiscussion, ElevationRequiredError, EnsureDiscussionInput, EnsureRelayInput, EnsureRelayResult, EnsureReport, EnsureResult, EnsureWebhookResult, EnsuredDiscussion, EnsuredResource, EnsuredTunnel, type EnvConfig, Environment, EnvironmentEntry, type EnvironmentLayer, EnvironmentReviewer, Environments, Errors, ErrorsInspection, ErrorsOrgState, ErrorsProjectState, type EslintConfig, ExportInfo, type FeatureResolver, type FeatureResolverConfig, type GitHubAppConfig, type HolocronConfig, type HolocronProfile, IdeaRecord, Ideas, type IdeasConfig, ImportOptions, ImportResult, InspectErrorsInput, InspectRelayInput, Issue, IssueComment, IssueOrder, IssuePriority, IssueRecord, IssueSearchFilter, IssueSelector, Issues, KNOWN_STACK_DEPS, LabelDef, type LayerTokenExpectation, LifecycleResult, LifecycleSlot, type LinksFile, type LoadedConfig, type LogConfig, Logs, LogsDataset, type MemberLink, MissingTokenError, Monitoring, MonitoringAlertChannelInput, MonitoringAlertChannelResult, MonitoringAlertChannelState, MonitoringAlertSettings, MonitoringAssertion, MonitoringAssertionComparison, MonitoringAssertionSource, MonitoringCheck, MonitoringCheckInput, MonitoringDashboardInput, MonitoringDashboardState, MonitoringHeartbeatInput, MonitoringHeartbeatResult, MonitoringHeartbeatUnit, MonitoringHttpMethod, MonitoringStatusComponentInput, MonitoringStatusPageInput, MonitoringStatusPageResult, MonitoringStatusPageState, MoveReport, type MultiEntry, NormalizedAuthUser, Notifications, NotificationsAccess, NotificationsApplicationLayout, NotificationsChannelLayout, NotificationsDelivery, NotificationsEveryoneLayout, NotificationsForumTag, NotificationsLayout, NotificationsLinksLayout, NotificationsMember, NotificationsMonitoringFeed, NotificationsOnboardingLayout, NotificationsPicture, NotificationsPinnedLayout, NotificationsPrsFeed, NotificationsServerLayout, NotificationsSignIn, NotificationsSignedIn, NotificationsWelcomeLayout, type OrgConfig, OrganizationSecretScope, type PackageJsonLike, PagesConfig, ParseWebhookInput, type PermissionRule, type PluginProbes, type PluginToken, type Probe, type ProbeContext, type ProbeRow, Projects, type ProviderAction, type ProviderActionContext, type ProviderActions, ProviderApiError, ProviderIdentity, type ProviderOptions, type ProviderRow, PullRequest, REQUIRED_CAPABILITIES, type RawProviderEntry, type RawProvidersConfig, type ReadKeysLimitedInput, RelayState, type RepoConfig, type RepoProperties, type RepoProtection, RepoRef, type RepoSecrets, type RepoSecretsDeploy, type RepoSecretsSync, RepoSettings, type RepoValidationConfig, type RepoVariables, type RepoVariablesSync, type RequestOptions, type ResolveTokenConfig, type ResolveTokenInput, ResolvedCapability, type ResolvedHolocronConfig, type ResolvedProviderEntry, type ResolvedProvidersConfig, type ResolvedTuple, type RestClient, type RestClientConfig, Ruleset, SecretAccess, SecretScope, SecretVisibility, Secrets, ServerInspection, type SingleEntry, Source, SourceBranch, SourceFile, SourceRepoInfo, SourceRulesetDetail, SourceSecurity, SourceTeamMember, type StackName, StatusCategory, Storage, StorageBranch, type StorybookDeployProject, SyncResult, type SyncRolesInput, type SyncRolesResult, type TaskEntry, type TaskEntryConfig, TeamEntry, TeamPermission, type TelemetryConfig, type TokenExpectation, type TokenExpectationFilter, type TokenLifetime, type TokenResolver, type TokenRotation, Tooling, ToolingDoctorReport, ToolingExportInput, ToolingExportIssue, ToolingExportResult, ToolingOpenInput, ToolingOpenLaunch, ToolingOpenPlan, ToolingOpenWant, ToolingWorkspaceFile, ToolingWorkspaceInput, ToolingWorkspaceResult, ToolingWorkspaceSide, ToolingWorkspaceState, TrackerDoctorReport, TrackerUser, TunnelRoute, Tunnels, Vault, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, WebhookDashboardInfo, WebhookVerificationError, Wiki, WikiInspection, WikiInstanceState, WikiNavigationState, WikiOrganizationState, WikiProbe, WikiProvisionOpts, WikiProxyConfig, WikiPublishedState, WorkerDeploymentState, WorkerScriptState, Workers, type WorkflowWithConfig, compose, createRestClient, credentialsEnvironment, defineConfig, deriveCapabilities, deriveCompliance, deriveProfile, deriveStack, isMulti, loadConfig, missingCapabilities, readWorkspacePackageJsons, resolveConfig, resolveEntry, resolvePluginPackage, resolveValue };
690
+ export { AddedItem, type AgentName, type AgentOptions, Analytics, type AppConfig, Auth, AuthDescription, AuthError, AuthEvent, AuthEventType, type AuthExportOutKind, AuthIdentity, AuthUser, type BoardDeclaration, BoardField, BoardFieldType, BoardItem, BoardItemInput, BoardPullRequest, BoardPullRequestChecks, BoardRule, BoardState, BoardStatus, BoardStatusCategory, BoardSummary, BoardTemplate, BoardTemplateFile, BoardView, CARDINALITY, Cache, CacheTokenCheck, type Capability, type CapabilityConfigPackage, CapabilityImpls, CapabilityKey, Cardinality, CardinalityFor, type ChromaticProjectConfig, Ci, CiRun, CiRunFilter, CiRunStatus, type ComposedPreset, ConfigError, ConfigFileError, ConnectionStringOptions, Coverage, CoverageConfigComponent, CoverageConfigDocumentation, CoverageConfigInput, CoverageExpectations, CoverageNameDiff, CoverageRepoReport, CoverageStatusContext, CoverageStatusInput, CoverageTokenCheck, CoverageUploadFlagResult, CoverageUploadGroup, CoverageUploadInput, CoverageUploadResult, CreateAuthUserInput, Credentials, type CredentialsConfig, CredentialsInspection, DeployFunctionConfig, DeployFunctionResult, DeployScriptConfig, DeployScriptResult, Deployment, DeploymentProject, DeploymentProjectSettings, DeploymentRecord, DeploymentTarget, DeploymentTrigger, type DeriveProfileInput, type DevConfig, type DevServeConfig, DiscussionPatch, DiscussionPost, Dns, DnsRecord, DnsRecordRequest, DnsRecordType, type DocsConfig, type DoctorConfig, DuplicateDiscussion, ElevationRequiredError, EnsureDiscussionInput, EnsureRelayInput, EnsureRelayResult, EnsureReport, EnsureResult, EnsureWebhookResult, EnsuredDiscussion, EnsuredResource, EnsuredTunnel, type EnvConfig, Environment, EnvironmentEntry, type EnvironmentLayer, EnvironmentReviewer, Environments, Errors, ErrorsInspection, ErrorsOrgState, ErrorsProjectState, type EslintConfig, ExportInfo, type FeatureResolver, type FeatureResolverConfig, type GitHubAppConfig, type HolocronConfig, type HolocronProfile, IdeaRecord, Ideas, type IdeasConfig, ImportOptions, ImportResult, InspectErrorsInput, InspectRelayInput, Issue, IssueComment, IssueOrder, IssuePriority, IssueRecord, IssueSearchFilter, IssueSelector, Issues, KNOWN_STACK_DEPS, LabelDef, type LayerTokenExpectation, LifecycleResult, LifecycleSlot, type LinksFile, type LoadedConfig, type LogConfig, Logs, LogsDataset, type MemberLink, MissingTokenError, Monitoring, MonitoringAlertChannelInput, MonitoringAlertChannelResult, MonitoringAlertChannelState, MonitoringAlertSettings, MonitoringAssertion, MonitoringAssertionComparison, MonitoringAssertionSource, MonitoringCheck, MonitoringCheckInput, MonitoringDashboardInput, MonitoringDashboardState, MonitoringHeartbeatInput, MonitoringHeartbeatResult, MonitoringHeartbeatUnit, MonitoringHttpMethod, MonitoringStatusComponentInput, MonitoringStatusPageInput, MonitoringStatusPageResult, MonitoringStatusPageState, MoveReport, type MultiEntry, NormalizedAuthUser, Notifications, NotificationsAccess, NotificationsApplicationLayout, NotificationsChannelLayout, NotificationsDelivery, NotificationsEveryoneLayout, NotificationsForumTag, NotificationsLayout, NotificationsLinksLayout, NotificationsMember, NotificationsMonitoringFeed, NotificationsOnboardingLayout, NotificationsPicture, NotificationsPinnedLayout, NotificationsPrsFeed, NotificationsServerLayout, NotificationsSignIn, NotificationsSignedIn, NotificationsWelcomeLayout, type OrgConfig, OrganizationSecretScope, type PackageJsonLike, PagesConfig, ParseWebhookInput, type PermissionRule, type PluginProbes, type PluginToken, type Probe, type ProbeContext, type ProbeRow, type ProjectOptions, Projects, type ProviderAction, type ProviderActionContext, type ProviderActions, ProviderApiError, ProviderIdentity, type ProviderOptions, type ProviderRow, PullRequest, type PullRequestStatusChange, type PullRequestStatusPlan, type PullRequestStatusReason, type PullRequestStatusUnresolved, REQUIRED_CAPABILITIES, type RawProviderEntry, type RawProvidersConfig, type ReadKeysLimitedInput, type ReconcileChange, type ReconcilePlan, type ReconcileReason, type ReconcileUnresolved, RelayState, type RepoConfig, type RepoProperties, type RepoProtection, RepoRef, type RepoSecrets, type RepoSecretsDeploy, type RepoSecretsSync, RepoSettings, type RepoValidationConfig, type RepoVariables, type RepoVariablesSync, type RequestOptions, type ResolveProjectOptionsResult, type ResolveTokenConfig, type ResolveTokenInput, ResolvedCapability, type ResolvedHolocronConfig, type ResolvedProviderEntry, type ResolvedProvidersConfig, type ResolvedTuple, type RestClient, type RestClientConfig, Ruleset, SecretAccess, SecretScope, SecretVisibility, Secrets, ServerInspection, type SingleEntry, Source, SourceBranch, SourceFile, SourceRepoInfo, SourceRulesetDetail, SourceSecurity, SourceTeamMember, type StackName, StatusCategory, Storage, StorageBranch, type StorybookDeployProject, SyncResult, type SyncRolesInput, type SyncRolesResult, type TaskEntry, type TaskEntryConfig, TeamEntry, TeamPermission, type TelemetryConfig, type TokenExpectation, type TokenExpectationFilter, type TokenLifetime, type TokenResolver, type TokenRotation, Tooling, ToolingDoctorReport, ToolingExportInput, ToolingExportIssue, ToolingExportResult, ToolingOpenInput, ToolingOpenLaunch, ToolingOpenPlan, ToolingOpenWant, ToolingWorkspaceFile, ToolingWorkspaceInput, ToolingWorkspaceResult, ToolingWorkspaceSide, ToolingWorkspaceState, TrackerDoctorReport, TrackerUser, TunnelRoute, Tunnels, Vault, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, WebhookDashboardInfo, WebhookVerificationError, Wiki, WikiInspection, WikiInstanceState, WikiNavigationState, WikiOrganizationState, WikiProbe, WikiProvisionOpts, WikiProxyConfig, WikiPublishedState, WorkerDeploymentState, WorkerScriptState, Workers, type WorkflowWithConfig, compose, createRestClient, credentialsEnvironment, defineConfig, deriveCapabilities, deriveCompliance, deriveProfile, deriveStack, isMulti, loadConfig, missingCapabilities, readWorkspacePackageJsons, resolveConfig, resolveEntry, resolvePluginPackage, resolveValue };
package/dist/index.mjs CHANGED
@@ -371,6 +371,283 @@ async function readLinks(source, layout, org, provider) {
371
371
  throw new Error(`${repo}/${path}: ${errorMessage(err)}`, { cause: err });
372
372
  }
373
373
  }
374
+ // src/commands/project/plan-pull-request-status/plan-pull-request-status.ts
375
+ /**
376
+ * Decide the status an item's linked pull requests ask for (spec `tech-board-status-automation`, #2388). Pure: it reads
377
+ * one item and the template and touches nothing; status only, never priority or any other field.
378
+ *
379
+ * - an open linked pull request (a draft counts) puts the item in `active`;
380
+ * - an open one whose aggregate check is `success` puts it in `review`;
381
+ * - when the item is in `review` and no open pull request is green, a `failure` moves it back to `active`, while
382
+ * `pending` and `none` leave it, so a re-run after a push does not flicker the board;
383
+ * - no open pull request: no change (closed and merged ones are `planReconcile()`'s, through the closed issue).
384
+ *
385
+ * Left to `planReconcile()`, which runs first: a closed item, an item with an open blocker or in `blocked`, and an
386
+ * item with no status (reported there, not set). An item in `done` is left alone. Where the template has no status of
387
+ * the wanted category the rule comes back as `unresolved` and nothing is guessed; where a category has several statuses
388
+ * the first in template order is used. Applying the change and planning again gives no change.
389
+ */
390
+ function planPullRequestStatus(item, template) {
391
+ if (!item.open || item.status === void 0 || item.blockedBy.length > 0) return void 0;
392
+ const category = template.statuses.find((s) => s.name === item.status)?.category ?? item.category;
393
+ if (category === "blocked" || category === "done") return void 0;
394
+ const open = (item.pullRequests ?? []).filter((pr) => pr.state === "open");
395
+ if (open.length === 0) return void 0;
396
+ let want;
397
+ let reason;
398
+ if (open.some((pr) => pr.checks === "success")) {
399
+ if (category !== "review") [want, reason] = ["review", "checks-green"];
400
+ } else if (category === "review") {
401
+ if (open.some((pr) => pr.checks === "failure")) [want, reason] = ["active", "checks-failed"];
402
+ } else if (category !== "active") [want, reason] = ["active", "pull-request-open"];
403
+ if (want === void 0 || reason === void 0) return void 0;
404
+ const to = template.statuses.find((s) => s.category === want)?.name;
405
+ if (to === void 0) return {
406
+ kind: "unresolved",
407
+ unresolved: {
408
+ key: item.key,
409
+ title: item.title,
410
+ category: want,
411
+ reason
412
+ }
413
+ };
414
+ return {
415
+ kind: "change",
416
+ change: {
417
+ key: item.key,
418
+ title: item.title,
419
+ from: item.status,
420
+ to,
421
+ category: want,
422
+ reason
423
+ }
424
+ };
425
+ }
426
+ // src/commands/project/plan-reconcile/plan-reconcile.ts
427
+ /**
428
+ * Decide the status changes that keep a board true (spec `command-project`, "Keeping a board true"). Pure: it reads
429
+ * the items and the template and touches nothing. Status only, never priority or any other field.
430
+ *
431
+ * - closed or merged, not in a `done` status: set to `done` (whatever the blockers say);
432
+ * - open with no status: not changed, listed in `unset` (it needs a decision, not a rule; this holds even when it has a
433
+ * blocker);
434
+ * - open with an open blocker, not in a `blocked` status: set to `blocked`;
435
+ * - open, in a `blocked` status, with no open blocker: set to `planned` (the status it held before is unknown).
436
+ *
437
+ * Where a category has several statuses the first in template order is used; where it has none the item is listed in
438
+ * `unresolved` and nothing is guessed. An item's category is read from the template by its status name, falling back
439
+ * to the one the provider reports. Applying the changes and planning again gives no change.
440
+ */
441
+ function planReconcile(items, template) {
442
+ const target = (category) => template.statuses.find((s) => s.category === category)?.name;
443
+ const plan = {
444
+ changes: [],
445
+ unset: [],
446
+ unresolved: []
447
+ };
448
+ for (const item of items) {
449
+ const category = item.status === void 0 ? void 0 : template.statuses.find((s) => s.name === item.status)?.category ?? item.category;
450
+ let want;
451
+ let reason;
452
+ if (!item.open) {
453
+ if (category !== "done") [want, reason] = ["done", "closed"];
454
+ } else if (item.status === void 0) {
455
+ plan.unset.push(item);
456
+ continue;
457
+ } else if (item.blockedBy.length > 0) {
458
+ if (category !== "blocked") [want, reason] = ["blocked", "blocked"];
459
+ } else if (category === "blocked") [want, reason] = ["planned", "unblocked"];
460
+ if (want === void 0 || reason === void 0) continue;
461
+ const to = target(want);
462
+ if (to === void 0) {
463
+ plan.unresolved.push({
464
+ key: item.key,
465
+ title: item.title,
466
+ category: want,
467
+ reason
468
+ });
469
+ continue;
470
+ }
471
+ plan.changes.push({
472
+ key: item.key,
473
+ title: item.title,
474
+ ...item.status !== void 0 ? { from: item.status } : {},
475
+ to,
476
+ category: want,
477
+ reason
478
+ });
479
+ }
480
+ return plan;
481
+ }
482
+ // src/commands/project/project-options/project-options.ts
483
+ /** Where a repo's own template files live unless the `templates` option says otherwise. */
484
+ const DEFAULT_TEMPLATES_DIR = ".holocron/projects";
485
+ /**
486
+ * Read the options of `providers.projects`: `org` (the owner, defaulting to `fallbackOwner`, the config's org), `boards`
487
+ * (a list of `{ template, name }`, nothing else about a board is written in the config) and `templates` (the directory
488
+ * of template files). Every problem is listed at once, and two boards with the same name are one.
489
+ */
490
+ function resolveProjectOptions(options, fallbackOwner) {
491
+ const problems = [];
492
+ const org = options.org;
493
+ if (org !== void 0 && (typeof org !== "string" || org.trim() === "")) problems.push("org must be text");
494
+ const owner = typeof org === "string" && org.trim() !== "" ? org : fallbackOwner;
495
+ const dir = options.templates;
496
+ if (dir !== void 0 && (typeof dir !== "string" || dir.trim() === "")) problems.push("templates must be the path of a directory");
497
+ const boards = [];
498
+ if (options.boards !== void 0) {
499
+ if (!Array.isArray(options.boards)) problems.push("boards must be a list of { template, name }");
500
+ else {
501
+ const seen = /* @__PURE__ */ new Set();
502
+ options.boards.forEach((entry, i) => {
503
+ const where = `boards[${i}]`;
504
+ if (typeof entry !== "object" || entry === null || Array.isArray(entry)) {
505
+ problems.push(`${where} must be { template, name }`);
506
+ return;
507
+ }
508
+ const { template, name } = entry;
509
+ if (typeof template !== "string" || template.trim() === "") problems.push(`${where} needs a template`);
510
+ if (typeof name !== "string" || name.trim() === "") problems.push(`${where} needs a name`);
511
+ if (typeof template !== "string" || typeof name !== "string" || !template.trim() || !name.trim()) return;
512
+ if (seen.has(name)) problems.push(`${where}: the board name "${name}" is used twice`);
513
+ seen.add(name);
514
+ boards.push({
515
+ template,
516
+ name
517
+ });
518
+ });
519
+ }
520
+ }
521
+ if (problems.length > 0) return {
522
+ ok: false,
523
+ problems
524
+ };
525
+ return {
526
+ ok: true,
527
+ options: {
528
+ owner,
529
+ boards,
530
+ templatesDir: typeof dir === "string" ? dir : DEFAULT_TEMPLATES_DIR
531
+ }
532
+ };
533
+ }
534
+ // src/commands/project/templates/builtin-templates/builtin-templates.ts
535
+ /** The templates that ship in `@theholocron/cli`, by name. A repo's own template with the same name replaces one. */
536
+ const BUILTIN_TEMPLATES = {
537
+ roadmap: {
538
+ name: "roadmap",
539
+ statuses: [
540
+ {
541
+ name: "Someday",
542
+ category: "backlog",
543
+ color: "GRAY",
544
+ description: "Idea or future consideration, not yet planned"
545
+ },
546
+ {
547
+ name: "Todo",
548
+ category: "planned",
549
+ color: "BLUE",
550
+ description: "Planned and ready to be worked on"
551
+ },
552
+ {
553
+ name: "In Progress",
554
+ category: "active",
555
+ color: "YELLOW",
556
+ description: "Currently being worked on"
557
+ },
558
+ {
559
+ name: "In Review",
560
+ category: "review",
561
+ color: "ORANGE",
562
+ description: "Pull request is green and waiting on review"
563
+ },
564
+ {
565
+ name: "Blocked",
566
+ category: "blocked",
567
+ color: "RED",
568
+ description: "Waiting on another issue or an outside change"
569
+ },
570
+ {
571
+ name: "Done",
572
+ category: "done",
573
+ color: "GREEN",
574
+ description: "Completed"
575
+ }
576
+ ],
577
+ fields: [{
578
+ name: "Priority",
579
+ type: "single_select",
580
+ options: [
581
+ "1 · Now",
582
+ "2 · Next",
583
+ "3 · Process"
584
+ ]
585
+ }],
586
+ views: [
587
+ {
588
+ name: "Active",
589
+ layout: "board",
590
+ filter: "-status:Someday -status:Done",
591
+ default: true
592
+ },
593
+ {
594
+ name: "Backlog",
595
+ layout: "board",
596
+ filter: "status:Someday"
597
+ },
598
+ {
599
+ name: "Done",
600
+ layout: "table",
601
+ filter: "status:Done"
602
+ }
603
+ ],
604
+ rules: ["Auto-add sub-issues to project"]
605
+ },
606
+ sprint: {
607
+ name: "sprint",
608
+ statuses: [
609
+ {
610
+ name: "Todo",
611
+ category: "planned",
612
+ color: "BLUE"
613
+ },
614
+ {
615
+ name: "In Progress",
616
+ category: "active",
617
+ color: "YELLOW"
618
+ },
619
+ {
620
+ name: "In Review",
621
+ category: "review",
622
+ color: "ORANGE"
623
+ },
624
+ {
625
+ name: "Blocked",
626
+ category: "blocked",
627
+ color: "RED"
628
+ },
629
+ {
630
+ name: "Done",
631
+ category: "done",
632
+ color: "GREEN"
633
+ }
634
+ ],
635
+ fields: [{
636
+ name: "Sprint",
637
+ type: "text"
638
+ }],
639
+ views: [{
640
+ name: "Active",
641
+ layout: "table",
642
+ filter: "-status:Done",
643
+ default: true
644
+ }, {
645
+ name: "Done",
646
+ layout: "table",
647
+ filter: "status:Done"
648
+ }]
649
+ }
650
+ };
374
651
  // src/commands/setup/derived-properties/derived-properties.ts
375
652
  /**
376
653
  * Repo archetype, in priority order:
@@ -742,4 +1019,4 @@ function resolveCredentialsFile(base, file, makeDir = (dir) => void mkdirSync(di
742
1019
  isDefault: true
743
1020
  };
744
1021
  }
745
- export { AuthError, CANONICAL_LABELS, CARDINALITY, ConfigError, ConfigFileError, DEFAULT_TOKEN_ROTATION, ElevationRequiredError, HOLOCRON_AREAS, KNOWN_STACK_DEPS, MissingTokenError, PRIVATE_CREDENTIALS_FILE, ProviderApiError, REQUIRED_CAPABILITIES, SHARED_AREAS, WebhookVerificationError, compose, connectionProbe, coverageExpectations, createFeatureResolver, createResolveToken, createRestClient, credentialsEnvironment, defineConfig, deriveCapabilities, deriveCompliance, deriveProfile, deriveStack, ignoreAdvice, isMulti, keyring, loadConfig, missingCapabilities, orderKeys, pickByCreation, placeAreas, readKeysLimited, readLinks, readWorkspacePackageJsons, reportProgress, resolveConfig, resolveCredentialsFile, resolveEntry, resolveEnvironmentId, resolvePluginPackage, resolveValue, roleTeamProblem, sourceProblem, stdoutKind, syncRoles, tokenExpectations, tokenRotationRows };
1022
+ export { AuthError, BUILTIN_TEMPLATES, CANONICAL_LABELS, CARDINALITY, ConfigError, ConfigFileError, DEFAULT_TEMPLATES_DIR, DEFAULT_TOKEN_ROTATION, ElevationRequiredError, HOLOCRON_AREAS, KNOWN_STACK_DEPS, MissingTokenError, PRIVATE_CREDENTIALS_FILE, ProviderApiError, REQUIRED_CAPABILITIES, SHARED_AREAS, WebhookVerificationError, compose, connectionProbe, coverageExpectations, createFeatureResolver, createResolveToken, createRestClient, credentialsEnvironment, defineConfig, deriveCapabilities, deriveCompliance, deriveProfile, deriveStack, ignoreAdvice, isMulti, keyring, loadConfig, missingCapabilities, orderKeys, pickByCreation, placeAreas, planPullRequestStatus, planReconcile, readKeysLimited, readLinks, readWorkspacePackageJsons, reportProgress, resolveConfig, resolveCredentialsFile, resolveEntry, resolveEnvironmentId, resolvePluginPackage, resolveProjectOptions, resolveValue, roleTeamProblem, sourceProblem, stdoutKind, syncRoles, tokenExpectations, tokenRotationRows };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/cli",
3
- "version": "5.0.0-alpha.489",
3
+ "version": "5.0.0-alpha.490",
4
4
  "description": "The Holocron CLI - a pluggable, capability-based orchestrator for spinning up and operating software projects.",
5
5
  "keywords": [
6
6
  "cli",
@@ -59,17 +59,17 @@
59
59
  "posthog-node": "^5.74.0",
60
60
  "tsx": "4.23.15",
61
61
  "yargs": "^18.1.0",
62
- "@theholocron/dagobah": "5.0.0-alpha.489",
63
- "@theholocron/astromech": "5.0.0-alpha.489",
64
- "@theholocron/fs-utils": "^1.17.0-alpha.5",
65
- "@theholocron/datapad": "5.0.0-alpha.489",
62
+ "@theholocron/astromech": "5.0.0-alpha.490",
63
+ "@theholocron/dagobah": "5.0.0-alpha.490",
64
+ "@theholocron/datapad": "5.0.0-alpha.490",
66
65
  "@theholocron/env-utils": "^1.17.0-alpha.5",
67
- "@theholocron/git-utils": "^1.17.0-alpha.5",
68
66
  "@theholocron/github-client": "^1.58.0-alpha.42",
69
- "@theholocron/json-utils": "^1.17.0-alpha.5",
70
- "@theholocron/kyber": "5.0.0-alpha.489",
71
- "@theholocron/misc-utils": "^1.17.0-alpha.5",
72
67
  "@theholocron/http-client": "^1.58.0-alpha.42",
68
+ "@theholocron/kyber": "5.0.0-alpha.490",
69
+ "@theholocron/fs-utils": "^1.17.0-alpha.5",
70
+ "@theholocron/misc-utils": "^1.17.0-alpha.5",
71
+ "@theholocron/json-utils": "^1.17.0-alpha.5",
72
+ "@theholocron/git-utils": "^1.17.0-alpha.5",
73
73
  "@theholocron/observability": "^0.7.0-alpha.5",
74
74
  "@theholocron/pkg-utils": "^1.17.0-alpha.5"
75
75
  },
@@ -85,9 +85,9 @@
85
85
  "typescript": "^5.9.3",
86
86
  "vitest": "^5.1.0",
87
87
  "@theholocron/eslint-config": "^8.9.0-alpha.21",
88
- "@theholocron/rollup-plugin-transform-template": "^8.9.0-alpha.21",
88
+ "@theholocron/vitest-config": "^8.9.0-alpha.21",
89
89
  "@theholocron/tsconfig": "^8.9.0-alpha.21",
90
- "@theholocron/vitest-config": "^8.9.0-alpha.21"
90
+ "@theholocron/rollup-plugin-transform-template": "^8.9.0-alpha.21"
91
91
  },
92
92
  "engines": {
93
93
  "node": ">=22.0.0"