@evref-bl/dev-nexus 0.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/README.md +677 -0
  2. package/dist/browserOpener.d.ts +9 -0
  3. package/dist/browserOpener.js +47 -0
  4. package/dist/cli.d.ts +18 -0
  5. package/dist/cli.js +2374 -0
  6. package/dist/gitWorktreeService.d.ts +57 -0
  7. package/dist/gitWorktreeService.js +157 -0
  8. package/dist/index.d.ts +47 -0
  9. package/dist/index.js +47 -0
  10. package/dist/nexusAgentMcpConfig.d.ts +30 -0
  11. package/dist/nexusAgentMcpConfig.js +228 -0
  12. package/dist/nexusAutomation.d.ts +103 -0
  13. package/dist/nexusAutomation.js +390 -0
  14. package/dist/nexusAutomationAgentLaunch.d.ts +148 -0
  15. package/dist/nexusAutomationAgentLaunch.js +855 -0
  16. package/dist/nexusAutomationAgentProfile.d.ts +39 -0
  17. package/dist/nexusAutomationAgentProfile.js +103 -0
  18. package/dist/nexusAutomationAgentSurface.d.ts +62 -0
  19. package/dist/nexusAutomationAgentSurface.js +90 -0
  20. package/dist/nexusAutomationCommandExecutor.d.ts +29 -0
  21. package/dist/nexusAutomationCommandExecutor.js +251 -0
  22. package/dist/nexusAutomationConfig.d.ts +114 -0
  23. package/dist/nexusAutomationConfig.js +547 -0
  24. package/dist/nexusAutomationEnqueue.d.ts +37 -0
  25. package/dist/nexusAutomationEnqueue.js +128 -0
  26. package/dist/nexusAutomationRunOnce.d.ts +91 -0
  27. package/dist/nexusAutomationRunOnce.js +586 -0
  28. package/dist/nexusAutomationScheduler.d.ts +50 -0
  29. package/dist/nexusAutomationScheduler.js +196 -0
  30. package/dist/nexusAutomationStatus.d.ts +55 -0
  31. package/dist/nexusAutomationStatus.js +462 -0
  32. package/dist/nexusAutomationTarget.d.ts +19 -0
  33. package/dist/nexusAutomationTarget.js +33 -0
  34. package/dist/nexusAutomationTargetCycle.d.ts +90 -0
  35. package/dist/nexusAutomationTargetCycle.js +282 -0
  36. package/dist/nexusAutomationTargetReport.d.ts +136 -0
  37. package/dist/nexusAutomationTargetReport.js +504 -0
  38. package/dist/nexusAutomationWorktreeSetup.d.ts +89 -0
  39. package/dist/nexusAutomationWorktreeSetup.js +661 -0
  40. package/dist/nexusCoordination.d.ts +198 -0
  41. package/dist/nexusCoordination.js +1018 -0
  42. package/dist/nexusExtension.d.ts +31 -0
  43. package/dist/nexusExtension.js +1 -0
  44. package/dist/nexusHomeConfig.d.ts +38 -0
  45. package/dist/nexusHomeConfig.js +133 -0
  46. package/dist/nexusMcpServer.d.ts +31 -0
  47. package/dist/nexusMcpServer.js +1036 -0
  48. package/dist/nexusPluginCapabilities.d.ts +197 -0
  49. package/dist/nexusPluginCapabilities.js +201 -0
  50. package/dist/nexusProjectConfig.d.ts +95 -0
  51. package/dist/nexusProjectConfig.js +880 -0
  52. package/dist/nexusProjectHomeService.d.ts +121 -0
  53. package/dist/nexusProjectHomeService.js +171 -0
  54. package/dist/nexusProjectLifecycle.d.ts +62 -0
  55. package/dist/nexusProjectLifecycle.js +205 -0
  56. package/dist/nexusProjectOperations.d.ts +101 -0
  57. package/dist/nexusProjectOperations.js +296 -0
  58. package/dist/nexusProjectRegistry.d.ts +42 -0
  59. package/dist/nexusProjectRegistry.js +91 -0
  60. package/dist/nexusProjectScaffold.d.ts +25 -0
  61. package/dist/nexusProjectScaffold.js +61 -0
  62. package/dist/nexusProjectTemplate.d.ts +34 -0
  63. package/dist/nexusProjectTemplate.js +354 -0
  64. package/dist/nexusSkills.d.ts +134 -0
  65. package/dist/nexusSkills.js +647 -0
  66. package/dist/nexusWorkerContextBundle.d.ts +142 -0
  67. package/dist/nexusWorkerContextBundle.js +375 -0
  68. package/dist/processSupervisor.d.ts +89 -0
  69. package/dist/processSupervisor.js +440 -0
  70. package/dist/vibeKanbanApi.d.ts +11 -0
  71. package/dist/vibeKanbanApi.js +14 -0
  72. package/dist/vibeKanbanAuth.d.ts +25 -0
  73. package/dist/vibeKanbanAuth.js +101 -0
  74. package/dist/vibeKanbanBoardAdapter.d.ts +36 -0
  75. package/dist/vibeKanbanBoardAdapter.js +196 -0
  76. package/dist/vibeKanbanMcpConfig.d.ts +36 -0
  77. package/dist/vibeKanbanMcpConfig.js +191 -0
  78. package/dist/vibeKanbanProjectAdapter.d.ts +39 -0
  79. package/dist/vibeKanbanProjectAdapter.js +113 -0
  80. package/dist/vibeKanbanWorkspaceSetup.d.ts +1 -0
  81. package/dist/vibeKanbanWorkspaceSetup.js +96 -0
  82. package/dist/workItemService.d.ts +60 -0
  83. package/dist/workItemService.js +163 -0
  84. package/dist/workTrackingGitHubProvider.d.ts +71 -0
  85. package/dist/workTrackingGitHubProvider.js +663 -0
  86. package/dist/workTrackingGitLabProvider.d.ts +62 -0
  87. package/dist/workTrackingGitLabProvider.js +523 -0
  88. package/dist/workTrackingJiraProvider.d.ts +67 -0
  89. package/dist/workTrackingJiraProvider.js +652 -0
  90. package/dist/workTrackingLocalProvider.d.ts +49 -0
  91. package/dist/workTrackingLocalProvider.js +463 -0
  92. package/dist/workTrackingProviderService.d.ts +21 -0
  93. package/dist/workTrackingProviderService.js +117 -0
  94. package/dist/workTrackingTypes.d.ts +202 -0
  95. package/dist/workTrackingTypes.js +1 -0
  96. package/dist/workTrackingVibeProvider.d.ts +35 -0
  97. package/dist/workTrackingVibeProvider.js +119 -0
  98. package/dist/worktreeExecutionMetadata.d.ts +76 -0
  99. package/dist/worktreeExecutionMetadata.js +239 -0
  100. package/package.json +37 -0
@@ -0,0 +1,196 @@
1
+ import path from "node:path";
2
+ import { runNexusAutomationOnce, } from "./nexusAutomationRunOnce.js";
3
+ import { runNexusAutomationAgentLaunchOnce, } from "./nexusAutomationAgentLaunch.js";
4
+ import { getNexusAutomationStatus, } from "./nexusAutomationStatus.js";
5
+ export class NexusAutomationSchedulerError extends Error {
6
+ constructor(message) {
7
+ super(message);
8
+ this.name = "NexusAutomationSchedulerError";
9
+ }
10
+ }
11
+ export async function runNexusAutomationScheduler(options) {
12
+ const projectRoot = path.resolve(requiredNonEmptyString(options.projectRoot, "projectRoot"));
13
+ const intervalOverride = optionalPositiveInteger(options.intervalMs, "intervalMs");
14
+ const maxTicks = optionalPositiveInteger(options.maxTicks, "maxTicks");
15
+ const maxRuns = optionalPositiveInteger(options.maxRuns, "maxRuns");
16
+ const sleep = options.sleep ?? defaultSleep;
17
+ const startedAt = currentIso(options.now);
18
+ const ticks = [];
19
+ const runs = [];
20
+ let stoppedReason = "stopped";
21
+ while (true) {
22
+ if (options.shouldStop?.()) {
23
+ stoppedReason = "stopped";
24
+ break;
25
+ }
26
+ const tickStartedAt = currentIso(options.now);
27
+ const status = await getNexusAutomationStatus({
28
+ projectRoot,
29
+ provider: options.provider,
30
+ providerFactory: options.providerFactory,
31
+ providerOptions: options.providerOptions,
32
+ now: options.now,
33
+ });
34
+ const intervalMs = intervalOverride ?? status.automationConfig?.schedule.intervalMs;
35
+ if (!status.automationConfig?.schedule.enabled || !intervalMs) {
36
+ const tick = schedulerTick({
37
+ index: ticks.length + 1,
38
+ startedAt: tickStartedAt,
39
+ finishedAt: currentIso(options.now),
40
+ status,
41
+ action: "stopped",
42
+ waitMs: null,
43
+ run: null,
44
+ });
45
+ ticks.push(tick);
46
+ await options.onTick?.(tick);
47
+ stoppedReason = "disabled";
48
+ break;
49
+ }
50
+ let action = "waited";
51
+ let waitMs = nextNexusAutomationSchedulerDelayMs(status, intervalMs, tickStartedAt);
52
+ let run = null;
53
+ if (status.status === "ready") {
54
+ const runId = schedulerRunId(options.runIdPrefix, ticks.length + 1, tickStartedAt);
55
+ if (status.automationConfig?.mode === "agent_launch") {
56
+ if (!options.agentLauncher) {
57
+ throw new NexusAutomationSchedulerError("agentLauncher is required when automation.mode is agent_launch");
58
+ }
59
+ run = await runNexusAutomationAgentLaunchOnce({
60
+ projectRoot,
61
+ provider: options.provider,
62
+ providerFactory: options.providerFactory,
63
+ providerOptions: options.providerOptions,
64
+ now: options.now,
65
+ owner: options.owner ?? "scheduler",
66
+ runId,
67
+ launcher: options.agentLauncher,
68
+ });
69
+ waitMs = status.automationConfig.agent.relaunch.whileEligible &&
70
+ maxRuns !== undefined
71
+ ? 0
72
+ : intervalMs;
73
+ }
74
+ else {
75
+ if (!options.executor) {
76
+ throw new NexusAutomationSchedulerError("executor is required when automation.mode is run_once");
77
+ }
78
+ run = await runNexusAutomationOnce({
79
+ projectRoot,
80
+ provider: options.provider,
81
+ providerFactory: options.providerFactory,
82
+ providerOptions: options.providerOptions,
83
+ gitRunner: options.gitRunner,
84
+ now: options.now,
85
+ owner: options.owner ?? "scheduler",
86
+ baseRef: options.baseRef,
87
+ runId,
88
+ executor: options.executor,
89
+ });
90
+ }
91
+ runs.push(run);
92
+ action = "ran";
93
+ }
94
+ const tick = schedulerTick({
95
+ index: ticks.length + 1,
96
+ startedAt: tickStartedAt,
97
+ finishedAt: currentIso(options.now),
98
+ status,
99
+ action,
100
+ waitMs,
101
+ run,
102
+ });
103
+ ticks.push(tick);
104
+ await options.onTick?.(tick);
105
+ if (maxRuns !== undefined && runs.length >= maxRuns) {
106
+ stoppedReason = "max_runs";
107
+ break;
108
+ }
109
+ if (maxTicks !== undefined && ticks.length >= maxTicks) {
110
+ stoppedReason = "max_ticks";
111
+ break;
112
+ }
113
+ if (options.shouldStop?.()) {
114
+ stoppedReason = "stopped";
115
+ break;
116
+ }
117
+ await sleep(waitMs);
118
+ }
119
+ return {
120
+ projectRoot,
121
+ startedAt,
122
+ finishedAt: currentIso(options.now),
123
+ ticks,
124
+ runs,
125
+ stoppedReason,
126
+ };
127
+ }
128
+ export function nextNexusAutomationSchedulerDelayMs(status, intervalMs, now = new Date()) {
129
+ const normalizedInterval = optionalPositiveInteger(intervalMs, "intervalMs");
130
+ if (normalizedInterval === undefined) {
131
+ throw new NexusAutomationSchedulerError("intervalMs is required");
132
+ }
133
+ if (status.status === "backoff" && status.backoff?.retryAfter) {
134
+ return delayUntil(status.backoff.retryAfter, now);
135
+ }
136
+ if (status.status === "locked" && status.lock?.expiresAt) {
137
+ return delayUntil(status.lock.expiresAt, now);
138
+ }
139
+ return normalizedInterval;
140
+ }
141
+ function schedulerTick(tick) {
142
+ return tick;
143
+ }
144
+ function schedulerRunId(prefix, tickIndex, timestamp) {
145
+ return [
146
+ safeRunIdPrefix(prefix ?? "scheduled"),
147
+ timestamp.replaceAll("-", "").replaceAll(":", "").replace(".", "-"),
148
+ tickIndex.toString(),
149
+ ].join("-");
150
+ }
151
+ function safeRunIdPrefix(value) {
152
+ const normalized = value
153
+ .trim()
154
+ .replace(/[^A-Za-z0-9._-]+/g, "-")
155
+ .replace(/^-+|-+$/g, "");
156
+ if (!normalized) {
157
+ throw new NexusAutomationSchedulerError("runIdPrefix must contain at least one safe character");
158
+ }
159
+ return normalized;
160
+ }
161
+ function delayUntil(target, now) {
162
+ const targetDate = dateFrom(target, "target");
163
+ const nowDate = dateFrom(now, "now");
164
+ return Math.max(0, targetDate.getTime() - nowDate.getTime());
165
+ }
166
+ function currentIso(now) {
167
+ const value = now ? now() : new Date();
168
+ return dateFrom(value, "now").toISOString();
169
+ }
170
+ function dateFrom(value, name) {
171
+ const date = value instanceof Date ? value : new Date(value);
172
+ if (Number.isNaN(date.getTime())) {
173
+ throw new NexusAutomationSchedulerError(`${name} must be a valid date`);
174
+ }
175
+ return date;
176
+ }
177
+ async function defaultSleep(ms) {
178
+ await new Promise((resolve) => {
179
+ setTimeout(resolve, ms);
180
+ });
181
+ }
182
+ function optionalPositiveInteger(value, name) {
183
+ if (value === undefined) {
184
+ return undefined;
185
+ }
186
+ if (!Number.isInteger(value) || value <= 0) {
187
+ throw new NexusAutomationSchedulerError(`${name} must be a positive integer`);
188
+ }
189
+ return value;
190
+ }
191
+ function requiredNonEmptyString(value, name) {
192
+ if (typeof value !== "string" || value.trim().length === 0) {
193
+ throw new NexusAutomationSchedulerError(`${name} must be a non-empty string`);
194
+ }
195
+ return value.trim();
196
+ }
@@ -0,0 +1,55 @@
1
+ import { type NexusAutomationBackoffDecision, type NexusAutomationRunLedger } from "./nexusAutomation.js";
2
+ import type { NexusAutomationConfig } from "./nexusAutomationConfig.js";
3
+ import { type NexusAutomationComponentEligibleWorkItems } from "./nexusAutomationAgentLaunch.js";
4
+ import { type NexusAutomationAgentPolicy } from "./nexusAutomationAgentProfile.js";
5
+ import { type NexusProjectConfig } from "./nexusProjectConfig.js";
6
+ import { type NexusAutomationTargetContext } from "./nexusAutomationTarget.js";
7
+ import { type NexusAutomationTargetCycleSummary } from "./nexusAutomationTargetCycle.js";
8
+ import { type ResolvedNexusProjectComponent } from "./nexusProjectLifecycle.js";
9
+ import { type NexusAutomationPreflightCheck, type NexusAutomationWorkTrackerProviderFactory } from "./nexusAutomationRunOnce.js";
10
+ import { type CreateWorkTrackerProviderOptions } from "./workTrackingProviderService.js";
11
+ import type { WorkItem, WorkItemQuery, WorkTrackerProvider } from "./workTrackingTypes.js";
12
+ export type NexusAutomationStatusKind = "disabled" | "locked" | "backoff" | "blocked" | "idle" | "ready";
13
+ export type NexusAutomationLockStatusKind = "none" | "active" | "stale" | "invalid";
14
+ export interface NexusAutomationStatusLock {
15
+ path: string;
16
+ status: NexusAutomationLockStatusKind;
17
+ runId: string | null;
18
+ owner: string | null;
19
+ acquiredAt: string | null;
20
+ expiresAt: string | null;
21
+ message: string;
22
+ }
23
+ export interface GetNexusAutomationStatusOptions {
24
+ projectRoot: string;
25
+ provider?: WorkTrackerProvider;
26
+ providerFactory?: NexusAutomationWorkTrackerProviderFactory;
27
+ providerOptions?: CreateWorkTrackerProviderOptions;
28
+ now?: () => Date | string;
29
+ }
30
+ export interface NexusAutomationStatus {
31
+ projectRoot: string;
32
+ sourceRoot: string | null;
33
+ components: ResolvedNexusProjectComponent[];
34
+ projectConfig: NexusProjectConfig;
35
+ automationConfig: NexusAutomationConfig | null;
36
+ status: NexusAutomationStatusKind;
37
+ summary: string;
38
+ lock: NexusAutomationStatusLock | null;
39
+ ledger: NexusAutomationRunLedger | null;
40
+ backoff: NexusAutomationBackoffDecision | null;
41
+ preflight: NexusAutomationPreflightCheck[];
42
+ target: NexusAutomationTargetContext | null;
43
+ targetCycles: NexusAutomationTargetCycleSummary | null;
44
+ agent: NexusAutomationAgentPolicy | null;
45
+ selectorQuery: WorkItemQuery | null;
46
+ candidateCount: number | null;
47
+ eligibleWorkItems: WorkItem[] | null;
48
+ componentEligibleWorkItems: NexusAutomationComponentEligibleWorkItems[] | null;
49
+ selectedWorkItem: WorkItem | null;
50
+ }
51
+ export declare class NexusAutomationStatusError extends Error {
52
+ constructor(message: string);
53
+ }
54
+ export declare function getNexusAutomationStatus(options: GetNexusAutomationStatusOptions): Promise<NexusAutomationStatus>;
55
+ export declare function readNexusAutomationStatusLock(projectRoot: string, config: NexusAutomationConfig, now?: Date | string): NexusAutomationStatusLock;