ai-sdlc 0.3.1-alpha.0-alpha.9 → 0.3.1-alpha.2

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.js CHANGED
File without changes
@@ -0,0 +1,25 @@
1
+ /**
2
+ * GitHub Projects v2 API client using gh CLI.
3
+ */
4
+ import { ProjectItem, GitHubProjectsConfig } from './types.js';
5
+ /**
6
+ * Check if gh CLI is available.
7
+ */
8
+ export declare function isGhAvailable(): boolean;
9
+ /**
10
+ * Get all items from a GitHub Project.
11
+ *
12
+ * @param config - GitHub Projects configuration
13
+ * @returns Array of project items
14
+ * @throws Error if gh CLI is not available or API call fails
15
+ */
16
+ export declare function getProjectItems(config: GitHubProjectsConfig): Promise<ProjectItem[]>;
17
+ /**
18
+ * Get priority for a specific issue from a GitHub Project.
19
+ *
20
+ * @param config - GitHub Projects configuration
21
+ * @param issueNumber - Issue number to look up
22
+ * @returns Normalized priority value, or null if issue not in project
23
+ */
24
+ export declare function getIssuePriorityFromProject(config: GitHubProjectsConfig, issueNumber: number): Promise<number | null>;
25
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/services/github-projects/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAI/D;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAOvC;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAwD1F;AAED;;;;;;GAMG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,oBAAoB,EAC5B,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAuBxB"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * GitHub Projects v2 API client using gh CLI.
3
+ */
4
+ import { execSync } from 'child_process';
5
+ import { buildProjectItemsQuery, extractPriorityValue } from './queries.js';
6
+ import { normalizePositionPriority, normalizeMappedPriority } from './priority-normalizer.js';
7
+ /**
8
+ * Check if gh CLI is available.
9
+ */
10
+ export function isGhAvailable() {
11
+ try {
12
+ execSync('gh --version', { stdio: 'ignore' });
13
+ return true;
14
+ }
15
+ catch {
16
+ return false;
17
+ }
18
+ }
19
+ /**
20
+ * Get all items from a GitHub Project.
21
+ *
22
+ * @param config - GitHub Projects configuration
23
+ * @returns Array of project items
24
+ * @throws Error if gh CLI is not available or API call fails
25
+ */
26
+ export async function getProjectItems(config) {
27
+ if (!isGhAvailable()) {
28
+ throw new Error('gh CLI is not available. Please install it: https://cli.github.com/');
29
+ }
30
+ const query = buildProjectItemsQuery(config.owner, config.projectNumber, config.priorityField);
31
+ try {
32
+ const result = execSync(`gh api graphql -f query='${query.replace(/'/g, "'\\''")}'`, {
33
+ encoding: 'utf-8',
34
+ maxBuffer: 10 * 1024 * 1024, // 10MB buffer for large projects
35
+ });
36
+ const data = JSON.parse(result);
37
+ // Try organization path first, then user path
38
+ const projectData = data.data?.org?.projectV2 || data.data?.user?.projectV2;
39
+ if (!projectData) {
40
+ throw new Error(`Project #${config.projectNumber} not found for owner "${config.owner}"`);
41
+ }
42
+ const items = [];
43
+ const nodes = projectData.items?.nodes || [];
44
+ for (let i = 0; i < nodes.length; i++) {
45
+ const node = nodes[i];
46
+ // Skip non-issue items (could be draft issues, pull requests, etc.)
47
+ if (!node.content?.number) {
48
+ continue;
49
+ }
50
+ const item = {
51
+ issueNumber: node.content.number,
52
+ position: i + 1, // 1-indexed position
53
+ };
54
+ // Extract priority field value if present
55
+ if (node.priorityValue) {
56
+ const priorityValue = extractPriorityValue(node.priorityValue);
57
+ if (priorityValue) {
58
+ item.priorityValue = priorityValue;
59
+ }
60
+ }
61
+ items.push(item);
62
+ }
63
+ return items;
64
+ }
65
+ catch (error) {
66
+ if (error instanceof Error) {
67
+ throw new Error(`Failed to fetch GitHub Project items: ${error.message}`);
68
+ }
69
+ throw error;
70
+ }
71
+ }
72
+ /**
73
+ * Get priority for a specific issue from a GitHub Project.
74
+ *
75
+ * @param config - GitHub Projects configuration
76
+ * @param issueNumber - Issue number to look up
77
+ * @returns Normalized priority value, or null if issue not in project
78
+ */
79
+ export async function getIssuePriorityFromProject(config, issueNumber) {
80
+ const items = await getProjectItems(config);
81
+ const item = items.find((i) => i.issueNumber === issueNumber);
82
+ if (!item) {
83
+ return null; // Issue not in project
84
+ }
85
+ // If priorityField is configured and item has a value, use mapping
86
+ if (config.priorityField && item.priorityValue && config.priorityMapping) {
87
+ const mappedPriority = normalizeMappedPriority(item.priorityValue, config.priorityMapping);
88
+ if (mappedPriority !== null) {
89
+ return mappedPriority;
90
+ }
91
+ // Fall through to position-based if mapping doesn't contain the value
92
+ }
93
+ // Use position-based priority as fallback
94
+ if (item.position) {
95
+ return normalizePositionPriority(item.position);
96
+ }
97
+ return null;
98
+ }
99
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/services/github-projects/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAE9F;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,IAAI,CAAC;QACH,QAAQ,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,MAA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C;QACD,sEAAsE;IACxE,CAAC;IAED,0CAA0C;IAC1C,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAClB,OAAO,yBAAyB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * GitHub Projects v2 integration for priority sync.
3
+ */
4
+ export * from './types.js';
5
+ export * from './client.js';
6
+ export * from './priority-normalizer.js';
7
+ export * from './queries.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/github-projects/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * GitHub Projects v2 integration for priority sync.
3
+ */
4
+ export * from './types.js';
5
+ export * from './client.js';
6
+ export * from './priority-normalizer.js';
7
+ export * from './queries.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/github-projects/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Utilities for normalizing priority values from GitHub Projects.
3
+ */
4
+ /**
5
+ * Normalize position-based priority.
6
+ * Converts project position (1, 2, 3, ...) to priority value (10, 20, 30, ...).
7
+ *
8
+ * @param position - Position in the project (1-indexed)
9
+ * @returns Normalized priority value (position * 10)
10
+ */
11
+ export declare function normalizePositionPriority(position: number): number;
12
+ /**
13
+ * Normalize priority using a field value mapping.
14
+ * Maps priority field values (e.g., 'P0', 'P1', 'High') to numeric priorities.
15
+ *
16
+ * @param value - Priority field value from GitHub Projects
17
+ * @param mapping - Mapping from field values to numeric priorities
18
+ * @returns Normalized priority value, or null if value not in mapping
19
+ */
20
+ export declare function normalizeMappedPriority(value: string, mapping: Record<string, number>): number | null;
21
+ //# sourceMappingURL=priority-normalizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"priority-normalizer.d.ts","sourceRoot":"","sources":["../../../src/services/github-projects/priority-normalizer.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKlE;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,MAAM,GAAG,IAAI,CAYf"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Utilities for normalizing priority values from GitHub Projects.
3
+ */
4
+ /**
5
+ * Normalize position-based priority.
6
+ * Converts project position (1, 2, 3, ...) to priority value (10, 20, 30, ...).
7
+ *
8
+ * @param position - Position in the project (1-indexed)
9
+ * @returns Normalized priority value (position * 10)
10
+ */
11
+ export function normalizePositionPriority(position) {
12
+ if (position <= 0) {
13
+ throw new Error(`Invalid position: ${position} (must be positive)`);
14
+ }
15
+ return position * 10;
16
+ }
17
+ /**
18
+ * Normalize priority using a field value mapping.
19
+ * Maps priority field values (e.g., 'P0', 'P1', 'High') to numeric priorities.
20
+ *
21
+ * @param value - Priority field value from GitHub Projects
22
+ * @param mapping - Mapping from field values to numeric priorities
23
+ * @returns Normalized priority value, or null if value not in mapping
24
+ */
25
+ export function normalizeMappedPriority(value, mapping) {
26
+ const priority = mapping[value];
27
+ if (priority === undefined) {
28
+ return null;
29
+ }
30
+ // Validate that the mapped value is a valid number
31
+ if (typeof priority !== 'number' || !Number.isFinite(priority) || priority <= 0) {
32
+ throw new Error(`Invalid priority mapping for "${value}": ${priority} (must be positive finite number)`);
33
+ }
34
+ return priority;
35
+ }
36
+ //# sourceMappingURL=priority-normalizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"priority-normalizer.js","sourceRoot":"","sources":["../../../src/services/github-projects/priority-normalizer.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CAAC,QAAgB;IACxD,IAAI,QAAQ,IAAI,CAAC,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,qBAAqB,QAAQ,qBAAqB,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,QAAQ,GAAG,EAAE,CAAC;AACvB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CACrC,KAAa,EACb,OAA+B;IAE/B,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAChC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,mDAAmD;IACnD,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,IAAI,CAAC,EAAE,CAAC;QAChF,MAAM,IAAI,KAAK,CAAC,iCAAiC,KAAK,MAAM,QAAQ,mCAAmC,CAAC,CAAC;IAC3G,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * GraphQL queries for GitHub Projects v2 API.
3
+ */
4
+ /**
5
+ * Query to fetch all items from a GitHub Project with priority field.
6
+ * This query is designed to work with both organization and user projects.
7
+ *
8
+ * @param owner - The owner login (organization or user)
9
+ * @param number - The project number
10
+ * @param priorityField - Optional name of the priority field to fetch
11
+ */
12
+ export declare function buildProjectItemsQuery(owner: string, number: number, priorityField?: string): string;
13
+ /**
14
+ * Extract priority value from a GraphQL field value node.
15
+ */
16
+ export declare function extractPriorityValue(fieldValue: any): string | undefined;
17
+ //# sourceMappingURL=queries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/services/github-projects/queries.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CA+CpG;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,GAAG,GAAG,MAAM,GAAG,SAAS,CAmBxE"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * GraphQL queries for GitHub Projects v2 API.
3
+ */
4
+ /**
5
+ * Query to fetch all items from a GitHub Project with priority field.
6
+ * This query is designed to work with both organization and user projects.
7
+ *
8
+ * @param owner - The owner login (organization or user)
9
+ * @param number - The project number
10
+ * @param priorityField - Optional name of the priority field to fetch
11
+ */
12
+ export function buildProjectItemsQuery(owner, number, priorityField) {
13
+ const priorityFieldFragment = priorityField
14
+ ? `
15
+ priorityValue: fieldValueByName(name: "${priorityField}") {
16
+ ... on ProjectV2ItemFieldSingleSelectValue {
17
+ name
18
+ }
19
+ ... on ProjectV2ItemFieldTextValue {
20
+ text
21
+ }
22
+ ... on ProjectV2ItemFieldNumberValue {
23
+ number
24
+ }
25
+ }`
26
+ : '';
27
+ // Try both organization and user paths
28
+ return `
29
+ query {
30
+ org: organization(login: "${owner}") {
31
+ projectV2(number: ${number}) {
32
+ items(first: 100) {
33
+ nodes {
34
+ content {
35
+ ... on Issue {
36
+ number
37
+ }
38
+ }${priorityFieldFragment}
39
+ }
40
+ }
41
+ }
42
+ }
43
+ user(login: "${owner}") {
44
+ projectV2(number: ${number}) {
45
+ items(first: 100) {
46
+ nodes {
47
+ content {
48
+ ... on Issue {
49
+ number
50
+ }
51
+ }${priorityFieldFragment}
52
+ }
53
+ }
54
+ }
55
+ }
56
+ }
57
+ `;
58
+ }
59
+ /**
60
+ * Extract priority value from a GraphQL field value node.
61
+ */
62
+ export function extractPriorityValue(fieldValue) {
63
+ if (!fieldValue)
64
+ return undefined;
65
+ // Single select field
66
+ if (fieldValue.name !== undefined) {
67
+ return fieldValue.name;
68
+ }
69
+ // Text field
70
+ if (fieldValue.text !== undefined) {
71
+ return fieldValue.text;
72
+ }
73
+ // Number field
74
+ if (fieldValue.number !== undefined) {
75
+ return String(fieldValue.number);
76
+ }
77
+ return undefined;
78
+ }
79
+ //# sourceMappingURL=queries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/services/github-projects/queries.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAa,EAAE,MAAc,EAAE,aAAsB;IAC1F,MAAM,qBAAqB,GAAG,aAAa;QACzC,CAAC,CAAC;qDAC+C,aAAa;;;;;;;;;;cAUpD;QACV,CAAC,CAAC,EAAE,CAAC;IAEP,uCAAuC;IACvC,OAAO;;kCAEyB,KAAK;4BACX,MAAM;;;;;;;iBAOjB,qBAAqB;;;;;qBAKjB,KAAK;4BACE,MAAM;;;;;;;iBAOjB,qBAAqB;;;;;;GAMnC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAe;IAClD,IAAI,CAAC,UAAU;QAAE,OAAO,SAAS,CAAC;IAElC,sBAAsB;IACtB,IAAI,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAClC,OAAO,UAAU,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,aAAa;IACb,IAAI,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAClC,OAAO,UAAU,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,eAAe;IACf,IAAI,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACpC,OAAO,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Types for GitHub Projects v2 integration.
3
+ */
4
+ /**
5
+ * Represents an item in a GitHub Project.
6
+ */
7
+ export interface ProjectItem {
8
+ /** Issue number */
9
+ issueNumber: number;
10
+ /** Priority field value (e.g., 'P0', 'P1', 'High', 'Medium') */
11
+ priorityValue?: string;
12
+ /** Position in the project view (1-indexed) */
13
+ position?: number;
14
+ }
15
+ /**
16
+ * Priority data extracted from a GitHub Project.
17
+ */
18
+ export interface ProjectPriorityData {
19
+ /** Normalized priority value (10, 20, 30, etc.) */
20
+ priority: number;
21
+ /** Source of the priority value */
22
+ source: PrioritySource;
23
+ }
24
+ /**
25
+ * Source of the priority value.
26
+ * - 'project-position': Priority derived from issue position in project board
27
+ * - 'project-field': Priority derived from explicit priority field value
28
+ * - 'local': Priority set locally, not synced from project
29
+ */
30
+ export type PrioritySource = 'project-position' | 'project-field' | 'local';
31
+ /**
32
+ * Configuration for GitHub Projects priority sync.
33
+ */
34
+ export interface GitHubProjectsConfig {
35
+ /** Owner of the repository (org or user) */
36
+ owner: string;
37
+ /** Repository name */
38
+ repo: string;
39
+ /** GitHub Projects v2 project number */
40
+ projectNumber: number;
41
+ /** Name of the priority field in the project (if using explicit field) */
42
+ priorityField?: string;
43
+ /** Mapping from priority field values to numeric priorities */
44
+ priorityMapping?: Record<string, number>;
45
+ }
46
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/github-projects/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,mBAAmB;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,mCAAmC;IACnC,MAAM,EAAE,cAAc,CAAC;CACxB;AAED;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG,eAAe,GAAG,OAAO,CAAC;AAE5E;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,0EAA0E;IAC1E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+DAA+D;IAC/D,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Types for GitHub Projects v2 integration.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/services/github-projects/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Service for syncing story priority from external ticketing systems.
3
+ */
4
+ import { Story } from '../types/index.js';
5
+ import { TicketProvider } from './ticket-provider/types.js';
6
+ /**
7
+ * Sync priority for a single story from its ticket provider.
8
+ * Updates the story's priority and priority_source fields if a priority is returned.
9
+ *
10
+ * @param story - Story to sync priority for
11
+ * @param provider - Ticket provider to use for syncing
12
+ * @returns Updated story if priority was synced, null if no sync needed
13
+ */
14
+ export declare function syncStoryPriority(story: Story, provider: TicketProvider): Promise<Story | null>;
15
+ /**
16
+ * Sync priority for multiple stories.
17
+ * Continues on individual failures to ensure all stories are attempted.
18
+ *
19
+ * @param stories - Stories to sync priority for
20
+ * @param provider - Ticket provider to use for syncing
21
+ * @param onProgress - Optional callback for progress updates
22
+ * @returns Number of successfully synced stories
23
+ */
24
+ export declare function syncAllStoriesPriority(stories: Story[], provider: TicketProvider, onProgress?: (current: number, total: number, story: Story) => void): Promise<number>;
25
+ //# sourceMappingURL=priority-sync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"priority-sync.d.ts","sourceRoot":"","sources":["../../src/services/priority-sync.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAG5D;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,cAAc,GACvB,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAoCvB;AAED;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,KAAK,EAAE,EAChB,QAAQ,EAAE,cAAc,EACxB,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,GAClE,OAAO,CAAC,MAAM,CAAC,CAiBjB"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Service for syncing story priority from external ticketing systems.
3
+ */
4
+ import { updateStoryField } from '../core/story.js';
5
+ /**
6
+ * Sync priority for a single story from its ticket provider.
7
+ * Updates the story's priority and priority_source fields if a priority is returned.
8
+ *
9
+ * @param story - Story to sync priority for
10
+ * @param provider - Ticket provider to use for syncing
11
+ * @returns Updated story if priority was synced, null if no sync needed
12
+ */
13
+ export async function syncStoryPriority(story, provider) {
14
+ // Only sync if story has a ticket ID and provider supports priority sync
15
+ if (!story.frontmatter.ticket_id || !provider.syncPriority) {
16
+ return null;
17
+ }
18
+ try {
19
+ const priority = await provider.syncPriority(story.frontmatter.ticket_id);
20
+ // If priority is null, the ticket is not in a project - keep local priority
21
+ if (priority === null) {
22
+ return null;
23
+ }
24
+ // Update priority if it changed
25
+ if (story.frontmatter.priority !== priority) {
26
+ await updateStoryField(story, 'priority', priority);
27
+ await updateStoryField(story, 'priority_source', 'github-project');
28
+ await updateStoryField(story, 'ticket_synced_at', new Date().toISOString());
29
+ return story;
30
+ }
31
+ // Priority unchanged, but update sync timestamp
32
+ if (story.frontmatter.priority_source !== 'github-project') {
33
+ await updateStoryField(story, 'priority_source', 'github-project');
34
+ }
35
+ await updateStoryField(story, 'ticket_synced_at', new Date().toISOString());
36
+ return story;
37
+ }
38
+ catch (error) {
39
+ // Log error but don't throw - gracefully continue with local priority
40
+ console.warn(`Failed to sync priority for story ${story.slug}: ${error instanceof Error ? error.message : String(error)}`);
41
+ return null;
42
+ }
43
+ }
44
+ /**
45
+ * Sync priority for multiple stories.
46
+ * Continues on individual failures to ensure all stories are attempted.
47
+ *
48
+ * @param stories - Stories to sync priority for
49
+ * @param provider - Ticket provider to use for syncing
50
+ * @param onProgress - Optional callback for progress updates
51
+ * @returns Number of successfully synced stories
52
+ */
53
+ export async function syncAllStoriesPriority(stories, provider, onProgress) {
54
+ let syncedCount = 0;
55
+ for (let i = 0; i < stories.length; i++) {
56
+ const story = stories[i];
57
+ if (onProgress) {
58
+ onProgress(i + 1, stories.length, story);
59
+ }
60
+ const updated = await syncStoryPriority(story, provider);
61
+ if (updated) {
62
+ syncedCount++;
63
+ }
64
+ }
65
+ return syncedCount;
66
+ }
67
+ //# sourceMappingURL=priority-sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"priority-sync.js","sourceRoot":"","sources":["../../src/services/priority-sync.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,KAAY,EACZ,QAAwB;IAExB,yEAAyE;IACzE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,IAAI,CAAC,QAAQ,C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AAC,KAAK,UAAU,sBAAsB,CAC1C,OAAgB,EAChB,QAAwB,EACxB,UAAmE;IAEnE,IAAI,WAAW,GAAG,CAAC,CAAC;IAEpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAEzB,IAAI,UAAU,EAAE,CAAC;YACf,UAAU,CAAC,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAC3C,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QACzD,IAAI,OAAO,EAAE,CAAC;YACZ,WAAW,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-sdlc",
3
- "version": "0.3.1-alpha.0-alpha.9",
3
+ "version": "0.3.1-alpha.2",
4
4
  "description": "Agent-first SDLC workflow manager using Claude Agent SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",