@aigile/engine 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action-item-features.d.ts +33 -0
- package/dist/action-item-features.d.ts.map +1 -0
- package/dist/action-item-features.js +113 -0
- package/dist/action-item-features.js.map +1 -0
- package/dist/action-items.d.ts +234 -0
- package/dist/action-items.d.ts.map +1 -0
- package/dist/action-items.js +722 -0
- package/dist/action-items.js.map +1 -0
- package/dist/action-sources.d.ts +44 -0
- package/dist/action-sources.d.ts.map +1 -0
- package/dist/action-sources.js +141 -0
- package/dist/action-sources.js.map +1 -0
- package/dist/agent-roles.d.ts +9 -0
- package/dist/agent-roles.d.ts.map +1 -0
- package/dist/agent-roles.js +18 -0
- package/dist/agent-roles.js.map +1 -0
- package/dist/agent-tasks.d.ts +36 -0
- package/dist/agent-tasks.d.ts.map +1 -0
- package/dist/agent-tasks.js +151 -0
- package/dist/agent-tasks.js.map +1 -0
- package/dist/agents/orchestrator.d.ts +26 -6
- package/dist/agents/orchestrator.d.ts.map +1 -1
- package/dist/agents/orchestrator.js +95 -45
- package/dist/agents/orchestrator.js.map +1 -1
- package/dist/agents/spec-analyst.d.ts +81 -13
- package/dist/agents/spec-analyst.d.ts.map +1 -1
- package/dist/agents/spec-analyst.js +350 -89
- package/dist/agents/spec-analyst.js.map +1 -1
- package/dist/ai-service.d.ts +40 -0
- package/dist/ai-service.d.ts.map +1 -1
- package/dist/ai-service.js +94 -9
- package/dist/ai-service.js.map +1 -1
- package/dist/api-tokens.d.ts +67 -0
- package/dist/api-tokens.d.ts.map +1 -0
- package/dist/api-tokens.js +89 -0
- package/dist/api-tokens.js.map +1 -0
- package/dist/attachments/extract.d.ts +26 -0
- package/dist/attachments/extract.d.ts.map +1 -0
- package/dist/attachments/extract.js +160 -0
- package/dist/attachments/extract.js.map +1 -0
- package/dist/attachments/fixtures.d.ts +9 -0
- package/dist/attachments/fixtures.d.ts.map +1 -0
- package/dist/attachments/fixtures.js +58 -0
- package/dist/attachments/fixtures.js.map +1 -0
- package/dist/attachments/service.d.ts +71 -0
- package/dist/attachments/service.d.ts.map +1 -0
- package/dist/attachments/service.js +220 -0
- package/dist/attachments/service.js.map +1 -0
- package/dist/build-service.d.ts +1 -1
- package/dist/build-service.d.ts.map +1 -1
- package/dist/build-service.js +9 -4
- package/dist/build-service.js.map +1 -1
- package/dist/change-events.d.ts +110 -0
- package/dist/change-events.d.ts.map +1 -0
- package/dist/change-events.js +238 -0
- package/dist/change-events.js.map +1 -0
- package/dist/change-sets.d.ts +110 -0
- package/dist/change-sets.d.ts.map +1 -0
- package/dist/change-sets.js +188 -0
- package/dist/change-sets.js.map +1 -0
- package/dist/command-runner.d.ts.map +1 -1
- package/dist/command-runner.js +2 -1
- package/dist/command-runner.js.map +1 -1
- package/dist/conversations.d.ts +2 -1
- package/dist/conversations.d.ts.map +1 -1
- package/dist/conversations.js +1 -1
- package/dist/conversations.js.map +1 -1
- package/dist/data-access.d.ts +9 -2
- package/dist/data-access.d.ts.map +1 -1
- package/dist/data-access.js +38 -6
- package/dist/data-access.js.map +1 -1
- package/dist/decisions.d.ts +56 -0
- package/dist/decisions.d.ts.map +1 -0
- package/dist/decisions.js +76 -0
- package/dist/decisions.js.map +1 -0
- package/dist/deliverables.d.ts +96 -0
- package/dist/deliverables.d.ts.map +1 -0
- package/dist/deliverables.js +344 -0
- package/dist/deliverables.js.map +1 -0
- package/dist/designs.d.ts +30 -0
- package/dist/designs.d.ts.map +1 -0
- package/dist/designs.js +154 -0
- package/dist/designs.js.map +1 -0
- package/dist/git-host.d.ts +10 -0
- package/dist/git-host.d.ts.map +1 -1
- package/dist/git-host.js +30 -2
- package/dist/git-host.js.map +1 -1
- package/dist/grounding.d.ts +9 -0
- package/dist/grounding.d.ts.map +1 -0
- package/dist/grounding.js +12 -0
- package/dist/grounding.js.map +1 -0
- package/dist/index.d.ts +35 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -10
- package/dist/index.js.map +1 -1
- package/dist/jira-features.d.ts +142 -0
- package/dist/jira-features.d.ts.map +1 -0
- package/dist/jira-features.js +366 -0
- package/dist/jira-features.js.map +1 -0
- package/dist/milestones.js +1 -1
- package/dist/milestones.js.map +1 -1
- package/dist/pull-request-sync.d.ts.map +1 -1
- package/dist/pull-request-sync.js +10 -6
- package/dist/pull-request-sync.js.map +1 -1
- package/dist/questions.d.ts +100 -10
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +211 -22
- package/dist/questions.js.map +1 -1
- package/dist/related.d.ts +26 -0
- package/dist/related.d.ts.map +1 -0
- package/dist/related.js +64 -0
- package/dist/related.js.map +1 -0
- package/dist/release-gates.d.ts +16 -0
- package/dist/release-gates.d.ts.map +1 -0
- package/dist/release-gates.js +47 -0
- package/dist/release-gates.js.map +1 -0
- package/dist/reviews.d.ts.map +1 -1
- package/dist/reviews.js +4 -3
- package/dist/reviews.js.map +1 -1
- package/dist/router.d.ts +2 -2
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js.map +1 -1
- package/dist/scheduler.d.ts +41 -5
- package/dist/scheduler.d.ts.map +1 -1
- package/dist/scheduler.js +109 -7
- package/dist/scheduler.js.map +1 -1
- package/dist/services.d.ts +760 -15
- package/dist/services.d.ts.map +1 -1
- package/dist/services.js +402 -20
- package/dist/services.js.map +1 -1
- package/dist/source-sync.d.ts +136 -0
- package/dist/source-sync.d.ts.map +1 -0
- package/dist/source-sync.js +370 -0
- package/dist/source-sync.js.map +1 -0
- package/dist/sources/front-matter.d.ts +20 -0
- package/dist/sources/front-matter.d.ts.map +1 -0
- package/dist/sources/front-matter.js +57 -0
- package/dist/sources/front-matter.js.map +1 -0
- package/dist/sources/git.d.ts +80 -0
- package/dist/sources/git.d.ts.map +1 -0
- package/dist/sources/git.js +338 -0
- package/dist/sources/git.js.map +1 -0
- package/dist/sources/http.d.ts +54 -0
- package/dist/sources/http.d.ts.map +1 -0
- package/dist/sources/http.js +79 -0
- package/dist/sources/http.js.map +1 -0
- package/dist/spec-cache.d.ts +54 -0
- package/dist/spec-cache.d.ts.map +1 -0
- package/dist/spec-cache.js +133 -0
- package/dist/spec-cache.js.map +1 -0
- package/dist/spec-links.d.ts +68 -0
- package/dist/spec-links.d.ts.map +1 -0
- package/dist/spec-links.js +144 -0
- package/dist/spec-links.js.map +1 -0
- package/dist/spec-reader.d.ts +44 -0
- package/dist/spec-reader.d.ts.map +1 -0
- package/dist/spec-reader.js +81 -0
- package/dist/spec-reader.js.map +1 -0
- package/dist/spec-resolver.d.ts +13 -1
- package/dist/spec-resolver.d.ts.map +1 -1
- package/dist/spec-resolver.js +45 -8
- package/dist/spec-resolver.js.map +1 -1
- package/dist/spec-tools.d.ts +10 -0
- package/dist/spec-tools.d.ts.map +1 -0
- package/dist/spec-tools.js +103 -0
- package/dist/spec-tools.js.map +1 -0
- package/dist/task-scope.d.ts +11 -0
- package/dist/task-scope.d.ts.map +1 -0
- package/dist/task-scope.js +11 -0
- package/dist/task-scope.js.map +1 -0
- package/dist/telemetry.d.ts +34 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +72 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/template.d.ts +341 -0
- package/dist/template.d.ts.map +1 -0
- package/dist/template.js +142 -0
- package/dist/template.js.map +1 -0
- package/dist/tool-sandbox.d.ts.map +1 -1
- package/dist/tool-sandbox.js +2 -2
- package/dist/tool-sandbox.js.map +1 -1
- package/dist/tracks.d.ts +3 -3
- package/dist/tracks.js +1 -1
- package/dist/tracks.js.map +1 -1
- package/dist/verifier.d.ts.map +1 -1
- package/dist/verifier.js +8 -7
- package/dist/verifier.js.map +1 -1
- package/dist/vscode-connect.d.ts +48 -0
- package/dist/vscode-connect.d.ts.map +1 -0
- package/dist/vscode-connect.js +105 -0
- package/dist/vscode-connect.js.map +1 -0
- package/package.json +14 -3
- package/prompts/agent-task.contract.md +9 -0
- package/prompts/orchestrator.brief.md +17 -0
- package/prompts/orchestrator.contract.md +7 -0
- package/prompts/spec-analyst.brief.md +19 -0
- package/prompts/spec-analyst.contract.md +5 -0
- package/prompts/spec-analyst.sweep.md +2 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { AppConfig, Build, DataStore, Deliverable, Release, Spec, TicketGroup } from '@aigile/core';
|
|
2
|
+
/** A Jira ticket that belongs to a feature, and how it stands in Jira (as last mirrored). */
|
|
3
|
+
export interface FeatureTicket {
|
|
4
|
+
key: string;
|
|
5
|
+
title: string;
|
|
6
|
+
/** Its Jira status: as aigile last read it (`jiraStatus`), else as the spec source last mirrored it; empty when neither has. */
|
|
7
|
+
status: string;
|
|
8
|
+
/** Its status's category (To Do, In Progress, Done) when read from Jira; empty otherwise. */
|
|
9
|
+
category: string;
|
|
10
|
+
/** What the status means for the agents (`jira.ticketStates`). */
|
|
11
|
+
group: TicketGroup;
|
|
12
|
+
url: string | null;
|
|
13
|
+
/** `link`: in the feature's links; `spec`: a Jira-sourced spec the feature reads; `child`: under a linked issue (an epic's story). */
|
|
14
|
+
from: 'link' | 'spec' | 'child';
|
|
15
|
+
/** The spec it was mirrored into, if any. */
|
|
16
|
+
specId: string | null;
|
|
17
|
+
}
|
|
18
|
+
type TicketStates = AppConfig['jira']['ticketStates'];
|
|
19
|
+
/** The default ticket states (Final Draft's WF workflow), for callers without a config. */
|
|
20
|
+
export declare function defaultTicketStates(): TicketStates;
|
|
21
|
+
/** The Jira writes the feature sync makes (`JiraClient` in @aigile/source-jira). */
|
|
22
|
+
export interface JiraWriter {
|
|
23
|
+
comment(key: string, text: string): Promise<void>;
|
|
24
|
+
/** Through the transition with this name (the older mapping); `transitionTo` is used when there. */
|
|
25
|
+
transition(key: string, name: string): Promise<void>;
|
|
26
|
+
/** To the status with this name, through the transitions the issue has now; `unavailable`: none goes there, nothing written. */
|
|
27
|
+
transitionTo?(key: string, status: string): Promise<{
|
|
28
|
+
result: 'moved' | 'already' | 'unavailable';
|
|
29
|
+
available: string[];
|
|
30
|
+
}>;
|
|
31
|
+
/** Whether the account may comment and transition; a read-only account turns the sync's writes off. */
|
|
32
|
+
writeAccess?(): Promise<{
|
|
33
|
+
comment: boolean;
|
|
34
|
+
transition: boolean;
|
|
35
|
+
reason: string | null;
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A feature's Jira tickets (documentation/action-items.md "Jira"): the issues
|
|
40
|
+
* its links name (its epic), the Jira-sourced specs it reads (those it lists
|
|
41
|
+
* and those under them in the outline), and the Jira-sourced specs under a
|
|
42
|
+
* linked issue (the epic's stories), wherever they are attached.
|
|
43
|
+
*/
|
|
44
|
+
export declare function featureTickets(store: DataStore, d: Deliverable, specs?: readonly Spec[], states?: TicketStates): Promise<FeatureTicket[]>;
|
|
45
|
+
/** A feature's tickets by group, in their order. */
|
|
46
|
+
export declare function groupTickets(tickets: readonly FeatureTicket[]): Record<TicketGroup, FeatureTicket[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Why a build of the feature should not start: it has Jira tickets, every one of
|
|
49
|
+
* them read, and none is actionable (each is in flight with a person, or done).
|
|
50
|
+
* Null when it may build (no tickets, an actionable one, or one whose status is not known).
|
|
51
|
+
*/
|
|
52
|
+
export declare function noActionableTickets(tickets: readonly FeatureTicket[]): string | null;
|
|
53
|
+
/**
|
|
54
|
+
* The tickets as the Engineer's task reads them (documentation/action-items.md
|
|
55
|
+
* "Ticket states"): by group, with the rules for each. Empty when the feature has none.
|
|
56
|
+
*/
|
|
57
|
+
export declare function ticketsTaskText(tickets: readonly FeatureTicket[], word?: string): string;
|
|
58
|
+
/** Reading tickets' statuses from Jira (`JiraClient.issueStatuses` in @aigile/source-jira). */
|
|
59
|
+
export interface JiraReader {
|
|
60
|
+
issueStatuses(keys: readonly string[]): Promise<Record<string, {
|
|
61
|
+
name: string;
|
|
62
|
+
category: string;
|
|
63
|
+
summary: string;
|
|
64
|
+
}>>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Keeps each feature's tickets' statuses as Jira has them (documentation/action-items.md
|
|
68
|
+
* "Ticket states"): read each tick (every feature not done, one search per 50 keys) and
|
|
69
|
+
* when a build starts (that feature, when older than `ticketStates.maxAgeMinutes`),
|
|
70
|
+
* recorded on the feature (`jiraStatus`) with when. Reads only; nothing when the
|
|
71
|
+
* installation has no Jira connection with a token.
|
|
72
|
+
*/
|
|
73
|
+
export declare class JiraTicketStatus {
|
|
74
|
+
private readonly store;
|
|
75
|
+
private readonly reader;
|
|
76
|
+
private readonly states;
|
|
77
|
+
constructor(store: DataStore, reader: JiraReader | null, states?: TicketStates);
|
|
78
|
+
get enabled(): boolean;
|
|
79
|
+
/** The feature's tickets with their statuses, read again first when older than `maxAgeMs` (default: the configured age). */
|
|
80
|
+
fresh(d: Deliverable, maxAgeMs?: number): Promise<{
|
|
81
|
+
deliverable: Deliverable;
|
|
82
|
+
tickets: FeatureTicket[];
|
|
83
|
+
}>;
|
|
84
|
+
/** Every feature not done, read again; how many features were recorded. */
|
|
85
|
+
refreshAll(): Promise<{
|
|
86
|
+
features: number;
|
|
87
|
+
error: string | null;
|
|
88
|
+
}>;
|
|
89
|
+
/** One read for all the keys, recorded on each feature (its own keys only); a failed read is recorded as the error, the last statuses kept. */
|
|
90
|
+
private record;
|
|
91
|
+
}
|
|
92
|
+
interface FeatureEvent {
|
|
93
|
+
/** Recorded per ticket so each is written once. */
|
|
94
|
+
id: string;
|
|
95
|
+
transition?: 'started' | 'proposed' | 'approved' | 'merged' | 'done';
|
|
96
|
+
comment?: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Keeps a feature's Jira tickets following the feature (documentation/action-items.md
|
|
100
|
+
* "Jira"), each tick, when the installation switches it on:
|
|
101
|
+
* - **linked:** a comment on each ticket naming the aigile feature (and its link);
|
|
102
|
+
* - **started:** a build of the feature started: a comment and the `started` status (In Progress);
|
|
103
|
+
* - **proposed:** each build up for review (in aigile, or as a pull request): a comment, and the `proposed` status (Under Review);
|
|
104
|
+
* - **approved:** a person approved a build and its pull request waits to merge: a comment and the `approved` status (Pending Merge);
|
|
105
|
+
* - **merged:** a build merged: a comment and the `merged` status (QA);
|
|
106
|
+
* - **released:** a release with the feature's builds verified in an environment: a comment;
|
|
107
|
+
* - **done:** the feature is done: a comment (and the `done` status, when one is configured and it is not a done status).
|
|
108
|
+
* Each status is reached through the transitions the issue has now (matched by the
|
|
109
|
+
* target status's name); an issue with none to it is left where it is. Only tickets
|
|
110
|
+
* that are actionable, or that aigile took while they were, are written to: a ticket
|
|
111
|
+
* in flight with a person, or done, gets nothing (the events are recorded as skipped);
|
|
112
|
+
* one whose status is not read yet waits. aigile never moves a ticket to a done status
|
|
113
|
+
* (`ticketStates.done`): only a person does (the QA queue's "Mark complete"). Each event
|
|
114
|
+
* is written to each ticket once and recorded on the feature (`jiraSync`, and its
|
|
115
|
+
* history); a failed write is retried next tick and its error shown on the dashboard.
|
|
116
|
+
*/
|
|
117
|
+
export declare class JiraFeatureSync {
|
|
118
|
+
private readonly store;
|
|
119
|
+
private readonly writer;
|
|
120
|
+
private readonly config;
|
|
121
|
+
private readonly states;
|
|
122
|
+
private readonly data;
|
|
123
|
+
constructor(store: DataStore, writer: JiraWriter | null, config: AppConfig['jira']['featureSync'], states?: TicketStates);
|
|
124
|
+
get enabled(): boolean;
|
|
125
|
+
private link;
|
|
126
|
+
/** The events a feature has reached, in order. */
|
|
127
|
+
events(d: Deliverable, builds: readonly Build[], releases: readonly Release[]): FeatureEvent[];
|
|
128
|
+
/** The status an event moves a ticket to, or null: none configured, or a done status (only a person moves a ticket there). */
|
|
129
|
+
target(event: FeatureEvent['transition']): string | null;
|
|
130
|
+
/** Why the sync writes nothing although switched on (a read-only Jira account), from the last check. */
|
|
131
|
+
readOnly: string | null;
|
|
132
|
+
syncAll(): Promise<{
|
|
133
|
+
writes: number;
|
|
134
|
+
errors: number;
|
|
135
|
+
}>;
|
|
136
|
+
syncFeature(d: Deliverable, builds: readonly Build[], releases: readonly Release[], specs?: readonly Spec[]): Promise<{
|
|
137
|
+
writes: number;
|
|
138
|
+
errors: number;
|
|
139
|
+
}>;
|
|
140
|
+
}
|
|
141
|
+
export {};
|
|
142
|
+
//# sourceMappingURL=jira-features.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jira-features.d.ts","sourceRoot":"","sources":["../src/jira-features.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAKzG,6FAA6F;AAC7F,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,gIAAgI;IAChI,MAAM,EAAE,MAAM,CAAC;IACf,6FAA6F;IAC7F,QAAQ,EAAE,MAAM,CAAC;IACjB,kEAAkE;IAClE,KAAK,EAAE,WAAW,CAAC;IACnB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,sIAAsI;IACtI,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IAChC,6CAA6C;IAC7C,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,KAAK,YAAY,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,CAAC;AAEtD,2FAA2F;AAC3F,wBAAgB,mBAAmB,IAAI,YAAY,CAElD;AAED,oFAAoF;AACpF,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,oGAAoG;IACpG,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,gIAAgI;IAChI,YAAY,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAA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G,YAAY,EAAE;IAyB9F,8HAA8H;IAC9H,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,YAAY,CAAC,GAAG,MAAM,GAAG,IAAI;IAOxD,wGAAwG;IACxG,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAEzB,OAAO,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAsBtD,WAAW,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,OAAO,EAAE,EAAE,KAAK,CAAC,EAAE,SAAS,IAAI,EAAE,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAwDhK"}
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { COLLECTIONS, configSchema, deliverableSchema, nowIso, ticketGroup } from '@aigile/core';
|
|
2
|
+
import { DataAccess } from './data-access.js';
|
|
3
|
+
import { shortId } from '@aigile/core/id';
|
|
4
|
+
let defaultStates = null;
|
|
5
|
+
/** The default ticket states (Final Draft's WF workflow), for callers without a config. */
|
|
6
|
+
export function defaultTicketStates() {
|
|
7
|
+
return (defaultStates ??= configSchema.parse({}).jira.ticketStates);
|
|
8
|
+
}
|
|
9
|
+
const ISSUE_KEY = /^[A-Z][A-Z0-9_]+-\d+$/;
|
|
10
|
+
/**
|
|
11
|
+
* A feature's Jira tickets (documentation/action-items.md "Jira"): the issues
|
|
12
|
+
* its links name (its epic), the Jira-sourced specs it reads (those it lists
|
|
13
|
+
* and those under them in the outline), and the Jira-sourced specs under a
|
|
14
|
+
* linked issue (the epic's stories), wherever they are attached.
|
|
15
|
+
*/
|
|
16
|
+
export async function featureTickets(store, d, specs, states = defaultTicketStates()) {
|
|
17
|
+
const all = specs ?? (await new DataAccess(store).specs());
|
|
18
|
+
const byId = new Map(all.map((s) => [s.id, s]));
|
|
19
|
+
const children = new Map();
|
|
20
|
+
for (const s of all)
|
|
21
|
+
if (s.parentId)
|
|
22
|
+
children.set(s.parentId, [...(children.get(s.parentId) ?? []), s]);
|
|
23
|
+
const below = (roots) => {
|
|
24
|
+
const out = new Set();
|
|
25
|
+
const stack = [...roots];
|
|
26
|
+
while (stack.length) {
|
|
27
|
+
const id = stack.pop();
|
|
28
|
+
if (out.has(id))
|
|
29
|
+
continue;
|
|
30
|
+
out.add(id);
|
|
31
|
+
for (const c of children.get(id) ?? [])
|
|
32
|
+
stack.push(c.id);
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
};
|
|
36
|
+
const jiraKey = (s) => (s?.source?.kind === 'jira' && !s.source.removedAt ? s.source.externalId : null);
|
|
37
|
+
const out = new Map();
|
|
38
|
+
const add = (t) => {
|
|
39
|
+
if (!out.has(t.key))
|
|
40
|
+
out.set(t.key, t);
|
|
41
|
+
};
|
|
42
|
+
const linked = d.links.filter((l) => l.kind === 'jira' || ISSUE_KEY.test(l.key)).map((l) => l.key);
|
|
43
|
+
const mirrored = new Map(all.flatMap((s) => (jiraKey(s) ? [[jiraKey(s), s]] : [])));
|
|
44
|
+
// The status as aigile last read it wins over the spec source's mirror (which may be older, and has no category).
|
|
45
|
+
const withStatus = (t) => {
|
|
46
|
+
const read = d.jiraStatus.tickets[t.key];
|
|
47
|
+
const status = read?.name || t.status;
|
|
48
|
+
const category = read?.name ? read.category : '';
|
|
49
|
+
return { ...t, title: t.title === t.key && read?.summary ? read.summary : t.title, status, category, group: ticketGroup({ name: status, category }, states) };
|
|
50
|
+
};
|
|
51
|
+
const ticket = (s, from) => withStatus({ key: jiraKey(s), title: s.title.replace(/^[A-Z][A-Z0-9_]+-\d+:\s*/, ''), status: s.source?.meta.status ?? '', url: s.source?.url ?? null, from, specId: s.id });
|
|
52
|
+
for (const key of linked) {
|
|
53
|
+
const s = mirrored.get(key);
|
|
54
|
+
add(s ? ticket(s, 'link') : withStatus({ key, title: key, status: '', url: d.links.find((l) => l.key === key)?.url ?? null, from: 'link', specId: null }));
|
|
55
|
+
}
|
|
56
|
+
for (const id of below(d.specIds)) {
|
|
57
|
+
const s = byId.get(id);
|
|
58
|
+
if (jiraKey(s))
|
|
59
|
+
add(ticket(s, 'spec'));
|
|
60
|
+
}
|
|
61
|
+
for (const key of linked) {
|
|
62
|
+
const s = mirrored.get(key);
|
|
63
|
+
if (!s)
|
|
64
|
+
continue;
|
|
65
|
+
for (const id of below([s.id])) {
|
|
66
|
+
const c = byId.get(id);
|
|
67
|
+
if (jiraKey(c))
|
|
68
|
+
add(ticket(c, 'child'));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return [...out.values()];
|
|
72
|
+
}
|
|
73
|
+
/** A feature's tickets by group, in their order. */
|
|
74
|
+
export function groupTickets(tickets) {
|
|
75
|
+
const out = { actionable: [], inFlight: [], done: [], unknown: [] };
|
|
76
|
+
for (const t of tickets)
|
|
77
|
+
out[t.group].push(t);
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Why a build of the feature should not start: it has Jira tickets, every one of
|
|
82
|
+
* them read, and none is actionable (each is in flight with a person, or done).
|
|
83
|
+
* Null when it may build (no tickets, an actionable one, or one whose status is not known).
|
|
84
|
+
*/
|
|
85
|
+
export function noActionableTickets(tickets) {
|
|
86
|
+
if (tickets.length === 0)
|
|
87
|
+
return null;
|
|
88
|
+
const g = groupTickets(tickets);
|
|
89
|
+
if (g.actionable.length > 0 || g.unknown.length > 0)
|
|
90
|
+
return null;
|
|
91
|
+
const list = (ts) => ts.map((t) => `${t.key} (${t.status})`).join(', ');
|
|
92
|
+
return `None of its Jira tickets is actionable: ${[g.inFlight.length ? `in flight with a person: ${list(g.inFlight)}` : '', g.done.length ? `done: ${list(g.done)}` : ''].filter(Boolean).join('; ')}. Nothing was built. A person can build it anyway.`;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The tickets as the Engineer's task reads them (documentation/action-items.md
|
|
96
|
+
* "Ticket states"): by group, with the rules for each. Empty when the feature has none.
|
|
97
|
+
*/
|
|
98
|
+
export function ticketsTaskText(tickets, word = 'feature') {
|
|
99
|
+
if (tickets.length === 0)
|
|
100
|
+
return '';
|
|
101
|
+
const g = groupTickets(tickets);
|
|
102
|
+
const line = (t) => `- ${t.key}${t.title && t.title !== t.key ? `: ${t.title}` : ''} (${t.status || 'status not read'})${t.url ? ` ${t.url}` : ''}`;
|
|
103
|
+
// No status read for any of them (no Jira connection to read through): listed, without rules that would forbid everything.
|
|
104
|
+
if (g.unknown.length === tickets.length)
|
|
105
|
+
return `### Its Jira tickets\n\nTheir statuses were not read from Jira.\n${tickets.map(line).join('\n')}\n\nIn your report, name the ticket each change is for.`;
|
|
106
|
+
const parts = [
|
|
107
|
+
`### Its Jira tickets, by what you may do with them\n\nThe ${word}'s work is tracked in these Jira tickets. Their statuses decide what you may touch.`,
|
|
108
|
+
`**Actionable (${g.actionable.length}): work only on these.**${g.actionable.length ? `\n${g.actionable.map(line).join('\n')}` : `\n(none: a person asked for this build anyway. Build what the specs ask; the rules below for in-flight and done tickets still hold.)`}`,
|
|
109
|
+
...(g.inFlight.length ? [`**In flight (${g.inFlight.length}): a person owns these. Do not change code for them.** If your work would touch what they cover, leave it and name the conflict in your report.\n${g.inFlight.map(line).join('\n')}`] : []),
|
|
110
|
+
...(g.done.length ? [`**Done (${g.done.length}): you may check these for completeness, but never change them without a person's approval.** If one looks incomplete, say what and why in your report; do not fix it.\n${g.done.map(line).join('\n')}`] : []),
|
|
111
|
+
...(g.unknown.length ? [`**Status not known (${g.unknown.length}): treat these like in-flight tickets** (do not change code for them; say in your report what you would have done).\n${g.unknown.map(line).join('\n')}`] : []),
|
|
112
|
+
`In your report, name the ticket each change is for.`,
|
|
113
|
+
];
|
|
114
|
+
return parts.join('\n\n');
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Keeps each feature's tickets' statuses as Jira has them (documentation/action-items.md
|
|
118
|
+
* "Ticket states"): read each tick (every feature not done, one search per 50 keys) and
|
|
119
|
+
* when a build starts (that feature, when older than `ticketStates.maxAgeMinutes`),
|
|
120
|
+
* recorded on the feature (`jiraStatus`) with when. Reads only; nothing when the
|
|
121
|
+
* installation has no Jira connection with a token.
|
|
122
|
+
*/
|
|
123
|
+
export class JiraTicketStatus {
|
|
124
|
+
store;
|
|
125
|
+
reader;
|
|
126
|
+
states;
|
|
127
|
+
constructor(store, reader, states = defaultTicketStates()) {
|
|
128
|
+
this.store = store;
|
|
129
|
+
this.reader = reader;
|
|
130
|
+
this.states = states;
|
|
131
|
+
}
|
|
132
|
+
get enabled() {
|
|
133
|
+
return !!this.reader;
|
|
134
|
+
}
|
|
135
|
+
/** The feature's tickets with their statuses, read again first when older than `maxAgeMs` (default: the configured age). */
|
|
136
|
+
async fresh(d, maxAgeMs = this.states.maxAgeMinutes * 60_000) {
|
|
137
|
+
const specs = await new DataAccess(this.store).specs();
|
|
138
|
+
let current = d;
|
|
139
|
+
if (this.reader && (!d.jiraStatus.readAt || Date.now() - Date.parse(d.jiraStatus.readAt) >= maxAgeMs)) {
|
|
140
|
+
const keys = (await featureTickets(this.store, d, specs, this.states)).map((t) => t.key);
|
|
141
|
+
if (keys.length)
|
|
142
|
+
current = (await this.record([d], keys))[0] ?? d;
|
|
143
|
+
}
|
|
144
|
+
return { deliverable: current, tickets: await featureTickets(this.store, current, specs, this.states) };
|
|
145
|
+
}
|
|
146
|
+
/** Every feature not done, read again; how many features were recorded. */
|
|
147
|
+
async refreshAll() {
|
|
148
|
+
if (!this.reader)
|
|
149
|
+
return { features: 0, error: null };
|
|
150
|
+
const specs = await new DataAccess(this.store).specs();
|
|
151
|
+
const all = (await this.store.list(COLLECTIONS.deliverables)).flatMap((r) => {
|
|
152
|
+
const p = deliverableSchema.safeParse(r);
|
|
153
|
+
return p.success && p.data.status !== 'done' ? [p.data] : [];
|
|
154
|
+
});
|
|
155
|
+
const withKeys = [];
|
|
156
|
+
const keys = new Set();
|
|
157
|
+
for (const d of all) {
|
|
158
|
+
const ts = await featureTickets(this.store, d, specs, this.states);
|
|
159
|
+
if (!ts.length)
|
|
160
|
+
continue;
|
|
161
|
+
withKeys.push(d);
|
|
162
|
+
for (const t of ts)
|
|
163
|
+
keys.add(t.key);
|
|
164
|
+
}
|
|
165
|
+
if (!withKeys.length)
|
|
166
|
+
return { features: 0, error: null };
|
|
167
|
+
const saved = await this.record(withKeys, [...keys]);
|
|
168
|
+
return { features: saved.length, error: saved.find((d) => d.jiraStatus.error)?.jiraStatus.error ?? null };
|
|
169
|
+
}
|
|
170
|
+
/** One read for all the keys, recorded on each feature (its own keys only); a failed read is recorded as the error, the last statuses kept. */
|
|
171
|
+
async record(features, keys) {
|
|
172
|
+
let read = null;
|
|
173
|
+
let error = null;
|
|
174
|
+
try {
|
|
175
|
+
read = await this.reader.issueStatuses(keys);
|
|
176
|
+
}
|
|
177
|
+
catch (err) {
|
|
178
|
+
error = err instanceof Error ? err.message : String(err);
|
|
179
|
+
}
|
|
180
|
+
const specs = await new DataAccess(this.store).specs();
|
|
181
|
+
const out = [];
|
|
182
|
+
for (const d of features) {
|
|
183
|
+
const fresh = deliverableSchema.parse(await this.store.get(COLLECTIONS.deliverables, d.id));
|
|
184
|
+
const mine = (await featureTickets(this.store, fresh, specs, this.states)).map((t) => t.key);
|
|
185
|
+
const tickets = read ? Object.fromEntries(mine.filter((k) => read[k]).map((k) => [k, read[k]])) : fresh.jiraStatus.tickets;
|
|
186
|
+
const jiraStatus = { readAt: read ? nowIso() : fresh.jiraStatus.readAt, tickets, error };
|
|
187
|
+
const before = JSON.stringify({ ...fresh.jiraStatus, readAt: null });
|
|
188
|
+
const next = { ...fresh, jiraStatus };
|
|
189
|
+
// The read time moves every read; the record is written only when a status changed or a minute has passed, so a tick does not rewrite every feature.
|
|
190
|
+
const stale = !fresh.jiraStatus.readAt || Date.now() - Date.parse(fresh.jiraStatus.readAt) >= 60_000;
|
|
191
|
+
if (before !== JSON.stringify({ ...jiraStatus, readAt: null }) || stale) {
|
|
192
|
+
await this.store.put(COLLECTIONS.deliverables, d.id, next, { message: `Jira statuses: ${fresh.title}`, author: actor.author });
|
|
193
|
+
}
|
|
194
|
+
out.push(next);
|
|
195
|
+
}
|
|
196
|
+
return out;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const actor = { userId: 'agent:jira', author: { name: 'aigile', email: 'jira@aigile.local' } };
|
|
200
|
+
/**
|
|
201
|
+
* Keeps a feature's Jira tickets following the feature (documentation/action-items.md
|
|
202
|
+
* "Jira"), each tick, when the installation switches it on:
|
|
203
|
+
* - **linked:** a comment on each ticket naming the aigile feature (and its link);
|
|
204
|
+
* - **started:** a build of the feature started: a comment and the `started` status (In Progress);
|
|
205
|
+
* - **proposed:** each build up for review (in aigile, or as a pull request): a comment, and the `proposed` status (Under Review);
|
|
206
|
+
* - **approved:** a person approved a build and its pull request waits to merge: a comment and the `approved` status (Pending Merge);
|
|
207
|
+
* - **merged:** a build merged: a comment and the `merged` status (QA);
|
|
208
|
+
* - **released:** a release with the feature's builds verified in an environment: a comment;
|
|
209
|
+
* - **done:** the feature is done: a comment (and the `done` status, when one is configured and it is not a done status).
|
|
210
|
+
* Each status is reached through the transitions the issue has now (matched by the
|
|
211
|
+
* target status's name); an issue with none to it is left where it is. Only tickets
|
|
212
|
+
* that are actionable, or that aigile took while they were, are written to: a ticket
|
|
213
|
+
* in flight with a person, or done, gets nothing (the events are recorded as skipped);
|
|
214
|
+
* one whose status is not read yet waits. aigile never moves a ticket to a done status
|
|
215
|
+
* (`ticketStates.done`): only a person does (the QA queue's "Mark complete"). Each event
|
|
216
|
+
* is written to each ticket once and recorded on the feature (`jiraSync`, and its
|
|
217
|
+
* history); a failed write is retried next tick and its error shown on the dashboard.
|
|
218
|
+
*/
|
|
219
|
+
export class JiraFeatureSync {
|
|
220
|
+
store;
|
|
221
|
+
writer;
|
|
222
|
+
config;
|
|
223
|
+
states;
|
|
224
|
+
data;
|
|
225
|
+
constructor(store, writer, config, states = defaultTicketStates()) {
|
|
226
|
+
this.store = store;
|
|
227
|
+
this.writer = writer;
|
|
228
|
+
this.config = config;
|
|
229
|
+
this.states = states;
|
|
230
|
+
this.data = new DataAccess(store);
|
|
231
|
+
}
|
|
232
|
+
get enabled() {
|
|
233
|
+
return this.config.enabled && !!this.writer;
|
|
234
|
+
}
|
|
235
|
+
link(query) {
|
|
236
|
+
return this.config.publicUrl ? ` ${this.config.publicUrl.replace(/\/+$/, '')}/?w=${encodeURIComponent(query)}` : '';
|
|
237
|
+
}
|
|
238
|
+
/** The events a feature has reached, in order. */
|
|
239
|
+
events(d, builds, releases) {
|
|
240
|
+
// A build that stopped before it began (no actionable tickets) did not start anything.
|
|
241
|
+
const mine = builds.filter((b) => b.deliverableId === d.id && !b.stopReason && b.status !== 'planned').sort((a, b) => a.timestamp.localeCompare(b.timestamp));
|
|
242
|
+
const feature = this.link(`feature:${d.id}`);
|
|
243
|
+
const out = [{ id: 'linked', comment: `Tracked in aigile as the feature "${d.title}".${feature} aigile builds the feature's actionable tickets and keeps them up to date.` }];
|
|
244
|
+
const first = mine[0];
|
|
245
|
+
if (first)
|
|
246
|
+
out.push({ id: 'started', transition: 'started', comment: `aigile started building "${d.title}".${this.link(`approval:${first.id}`) || feature}` });
|
|
247
|
+
for (const b of mine.filter((x) => ['proposed', 'pushed', 'merged'].includes(x.status))) {
|
|
248
|
+
out.push({ id: `proposed:${b.id}`, transition: 'proposed', comment: `A build of "${d.title}" is up for review: ${b.pullRequest?.url ?? (this.link(`approval:${b.id}`).trim() || `build ${shortId(b.id)} in aigile`)}` });
|
|
249
|
+
}
|
|
250
|
+
for (const b of mine.filter((x) => x.status === 'pushed' || x.status === 'merged')) {
|
|
251
|
+
out.push({ id: `approved:${b.id}`, transition: 'approved', comment: `A person approved the build of "${d.title}"; ${b.pullRequest?.url ? `its pull request waits to merge: ${b.pullRequest.url}` : `it waits to merge.${this.link(`approval:${b.id}`)}`}` });
|
|
252
|
+
}
|
|
253
|
+
const merged = mine.filter((b) => b.status === 'merged');
|
|
254
|
+
if (merged.length)
|
|
255
|
+
out.push({ id: 'merged', transition: 'merged', comment: `Merged: ${merged.map((b) => b.pullRequest?.url ?? `build ${shortId(b.id)}`).join(', ')}. Ready for QA.` });
|
|
256
|
+
const ids = new Set(mine.map((b) => b.id));
|
|
257
|
+
for (const r of releases.filter((x) => x.buildIds.some((b) => ids.has(b)))) {
|
|
258
|
+
for (const p of r.phases.filter((x) => x.status === 'verified' && (this.config.environments.length === 0 || this.config.environments.includes(x.environment)))) {
|
|
259
|
+
out.push({ id: `released:${p.environment}`, comment: `Released to ${p.environment} in ${r.name}.` });
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
if (d.status === 'done')
|
|
263
|
+
out.push({ id: 'done', transition: 'done', comment: `The feature "${d.title}" is done in aigile.` });
|
|
264
|
+
return out;
|
|
265
|
+
}
|
|
266
|
+
/** The status an event moves a ticket to, or null: none configured, or a done status (only a person moves a ticket there). */
|
|
267
|
+
target(event) {
|
|
268
|
+
const name = event ? this.config.transitions[event] : undefined;
|
|
269
|
+
if (!name)
|
|
270
|
+
return null;
|
|
271
|
+
if (ticketGroup({ name }, this.states) === 'done')
|
|
272
|
+
return null;
|
|
273
|
+
return name;
|
|
274
|
+
}
|
|
275
|
+
/** Why the sync writes nothing although switched on (a read-only Jira account), from the last check. */
|
|
276
|
+
readOnly = null;
|
|
277
|
+
async syncAll() {
|
|
278
|
+
if (!this.enabled)
|
|
279
|
+
return { writes: 0, errors: 0 };
|
|
280
|
+
const access = await this.writer?.writeAccess?.().catch((err) => ({ comment: false, transition: false, reason: err instanceof Error ? err.message : String(err) }));
|
|
281
|
+
if (access && (!access.comment || !access.transition)) {
|
|
282
|
+
if (this.readOnly !== access.reason)
|
|
283
|
+
console.warn(`[aigile] Jira feature sync is on, but writes nothing: read only (${access.reason})`);
|
|
284
|
+
this.readOnly = access.reason;
|
|
285
|
+
return { writes: 0, errors: 0 };
|
|
286
|
+
}
|
|
287
|
+
this.readOnly = null;
|
|
288
|
+
const [raw, builds, releases, specs] = await Promise.all([this.store.list(COLLECTIONS.deliverables), this.data.builds(), this.data.releases(), this.data.specs()]);
|
|
289
|
+
let writes = 0;
|
|
290
|
+
let errors = 0;
|
|
291
|
+
for (const r of raw) {
|
|
292
|
+
const parsed = deliverableSchema.safeParse(r);
|
|
293
|
+
if (!parsed.success)
|
|
294
|
+
continue;
|
|
295
|
+
const result = await this.syncFeature(parsed.data, builds, releases, specs);
|
|
296
|
+
writes += result.writes;
|
|
297
|
+
errors += result.errors;
|
|
298
|
+
}
|
|
299
|
+
return { writes, errors };
|
|
300
|
+
}
|
|
301
|
+
async syncFeature(d, builds, releases, specs) {
|
|
302
|
+
if (!this.enabled || !this.writer)
|
|
303
|
+
return { writes: 0, errors: 0 };
|
|
304
|
+
const tickets = await featureTickets(this.store, d, specs, this.states);
|
|
305
|
+
if (tickets.length === 0)
|
|
306
|
+
return { writes: 0, errors: 0 };
|
|
307
|
+
const events = this.events(d, builds, releases);
|
|
308
|
+
const sync = structuredClone(d.jiraSync);
|
|
309
|
+
const notes = [];
|
|
310
|
+
let writes = 0;
|
|
311
|
+
let errors = 0;
|
|
312
|
+
for (const t of tickets) {
|
|
313
|
+
// Whose the ticket is: aigile's when actionable (it takes it) or taken before; a person's when in flight or done; not known until its status is read.
|
|
314
|
+
if (t.group === 'unknown' && !sync.tickets[t.key]?.owned)
|
|
315
|
+
continue;
|
|
316
|
+
const state = (sync.tickets[t.key] ??= { events: {}, error: null, skipped: {}, owned: false });
|
|
317
|
+
const mine = t.group === 'actionable' || state.owned;
|
|
318
|
+
for (const e of events) {
|
|
319
|
+
if (state.events[e.id] || state.skipped[e.id])
|
|
320
|
+
continue;
|
|
321
|
+
if (!mine) {
|
|
322
|
+
state.skipped[e.id] = nowIso();
|
|
323
|
+
notes.push(`${t.key}: ${e.id} skipped (${t.status}: ${t.group === 'done' ? 'done' : 'a person’s'})`);
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
326
|
+
try {
|
|
327
|
+
if (e.comment) {
|
|
328
|
+
await this.writer.comment(t.key, e.comment);
|
|
329
|
+
writes++;
|
|
330
|
+
}
|
|
331
|
+
const name = this.target(e.transition);
|
|
332
|
+
let moved = '';
|
|
333
|
+
if (name) {
|
|
334
|
+
if (this.writer.transitionTo) {
|
|
335
|
+
const r = await this.writer.transitionTo(t.key, name);
|
|
336
|
+
if (r.result === 'moved')
|
|
337
|
+
writes++;
|
|
338
|
+
moved = r.result === 'moved' ? ` → ${name}` : r.result === 'already' ? ` (already ${name})` : ` (no transition to ${name}; left as is)`;
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
await this.writer.transition(t.key, name);
|
|
342
|
+
writes++;
|
|
343
|
+
moved = ` → ${name}`;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
state.events[e.id] = nowIso();
|
|
347
|
+
state.owned = true;
|
|
348
|
+
state.error = null;
|
|
349
|
+
notes.push(`${t.key}: ${e.id}${moved}`);
|
|
350
|
+
}
|
|
351
|
+
catch (err) {
|
|
352
|
+
state.error = `${e.id}: ${err instanceof Error ? err.message : String(err)}`;
|
|
353
|
+
errors++;
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
if (JSON.stringify(sync) === JSON.stringify(d.jiraSync))
|
|
359
|
+
return { writes, errors };
|
|
360
|
+
const fresh = deliverableSchema.parse(await this.store.get(COLLECTIONS.deliverables, d.id));
|
|
361
|
+
const history = notes.length ? [...fresh.history, { at: nowIso(), byUserId: actor.userId, note: `Jira: ${notes.join('; ')}` }] : fresh.history;
|
|
362
|
+
await this.store.put(COLLECTIONS.deliverables, d.id, { ...fresh, jiraSync: sync, history }, { message: `Jira: ${d.title}${notes.length ? ` (${notes.length} written)` : ''}`, author: actor.author });
|
|
363
|
+
return { writes, errors };
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+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AC,CAAC;QAC5F,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;QAC/I,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,MAAM,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QACtM,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC5B,CAAC;CACF"}
|
package/dist/milestones.js
CHANGED
|
@@ -19,7 +19,7 @@ export class MilestoneService {
|
|
|
19
19
|
async post(input, actor) {
|
|
20
20
|
const ts = nowIso();
|
|
21
21
|
const milestone = milestoneSchema.parse({
|
|
22
|
-
id: newId(),
|
|
22
|
+
id: newId('milestone'),
|
|
23
23
|
kind: input.kind,
|
|
24
24
|
roleId: input.roleId ?? null,
|
|
25
25
|
agentKey: input.agentKey ?? null,
|
package/dist/milestones.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"milestones.js","sourceRoot":"","sources":["../src/milestones.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,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AC;QAC/K,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,mDAAmD;IACnD,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,EAAE,EAAE,KAAoC;QAC3D,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;QACzC,OAAO,GAAG;aACP,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC,CAAC;aAClF,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;aACtD,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull-request-sync.d.ts","sourceRoot":"","sources":["../src/pull-request-sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,SAAS,EAAE,MAAM,cAAc,CAAC;AAGrD,OAAO,
|
|
1
|
+
{"version":3,"file":"pull-request-sync.d.ts","sourceRoot":"","sources":["../src/pull-request-sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,SAAS,EAAE,MAAM,cAAc,CAAC;AAGrD,OAAO,EAAc,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAKlE,KAAK,WAAW,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAEnG;;;;;GAKG;AACH,qBAAa,eAAe;IAWxB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM;IAZzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;IACtC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAiB;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,OAAO,CAAgC;IAC/C,4EAA4E;IAC5E,UAAU,EAAE,MAAM,EAAE,CAAM;gBAGxB,KAAK,EAAE,SAAS,EACC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,EACrD,aAAa,SAAS,EACtB,MAAM,GAAE,WAGxB;IAOH,yFAAyF;IACnF,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;IAKxB,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;YASd,IAAI;YAyBJ,MAAM;CAIrB"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { BuildService } from './build-service.js';
|
|
2
2
|
import { DataAccess } from './data-access.js';
|
|
3
|
-
import {
|
|
3
|
+
import { gitHostFor } from './git-host.js';
|
|
4
4
|
import { ReviewService } from './reviews.js';
|
|
5
5
|
import { ProjectService } from './services.js';
|
|
6
|
+
import { shortId } from '@aigile/core/id';
|
|
6
7
|
/**
|
|
7
8
|
* What the host knows and aigile does not: whether a pushed build's pull
|
|
8
9
|
* request was merged or declined. Checked on reads (at most once per
|
|
@@ -20,7 +21,10 @@ export class PullRequestSync {
|
|
|
20
21
|
running = null;
|
|
21
22
|
/** The builds the last run saw merged, for the clock to schedule audits. */
|
|
22
23
|
lastMerged = [];
|
|
23
|
-
constructor(store, env = process.env, minIntervalMs = 60_000, lookup = (url, number, token) =>
|
|
24
|
+
constructor(store, env = process.env, minIntervalMs = 60_000, lookup = (url, number, token) => {
|
|
25
|
+
const found = gitHostFor(url);
|
|
26
|
+
return found.provider.pullRequestState(found.remote, number, token);
|
|
27
|
+
}) {
|
|
24
28
|
this.env = env;
|
|
25
29
|
this.minIntervalMs = minIntervalMs;
|
|
26
30
|
this.lookup = lookup;
|
|
@@ -49,9 +53,9 @@ export class PullRequestSync {
|
|
|
49
53
|
this.lastMerged = [];
|
|
50
54
|
for (const build of await this.pushed()) {
|
|
51
55
|
const project = await this.projects.get(build.projectId).catch(() => null);
|
|
52
|
-
const
|
|
53
|
-
const token =
|
|
54
|
-
if (!project?.gitUrl || !
|
|
56
|
+
const host = project?.gitUrl ? gitHostFor(project.gitUrl) : null;
|
|
57
|
+
const token = host ? this.env[host.provider.tokenEnv] : undefined;
|
|
58
|
+
if (!project?.gitUrl || !host || !token || !build.pullRequest || build.pullRequest.number === null)
|
|
55
59
|
continue;
|
|
56
60
|
let state;
|
|
57
61
|
try {
|
|
@@ -63,7 +67,7 @@ export class PullRequestSync {
|
|
|
63
67
|
}
|
|
64
68
|
if (state === 'open')
|
|
65
69
|
continue;
|
|
66
|
-
await this.builds.update(build.id, { status: state }, `Build ${build.id
|
|
70
|
+
await this.builds.update(build.id, { status: state }, `Build ${shortId(build.id)} ${state} on the host`);
|
|
67
71
|
await this.reviews.settleForBuild(build.id, state === 'merged' ? 'merged' : 'withdrawn', actor);
|
|
68
72
|
if (state === 'merged')
|
|
69
73
|
this.lastMerged.push(build.id);
|