specweave 0.29.0 → 0.29.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/package.json +3 -1
- package/plugins/specweave-github/hooks/.specweave/logs/hooks-debug.log +18 -0
- package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +27 -0
- package/dist/plugins/specweave-github/lib/enhanced-github-sync.d.ts +0 -26
- package/dist/plugins/specweave-github/lib/enhanced-github-sync.d.ts.map +0 -1
- package/dist/plugins/specweave-github/lib/enhanced-github-sync.js +0 -249
- package/dist/plugins/specweave-github/lib/enhanced-github-sync.js.map +0 -1
- package/dist/plugins/specweave-jira/lib/enhanced-jira-sync.d.ts +0 -28
- package/dist/plugins/specweave-jira/lib/enhanced-jira-sync.d.ts.map +0 -1
- package/dist/plugins/specweave-jira/lib/enhanced-jira-sync.js +0 -156
- package/dist/plugins/specweave-jira/lib/enhanced-jira-sync.js.map +0 -1
- package/dist/src/core/sync/bidirectional-engine.d.ts +0 -119
- package/dist/src/core/sync/bidirectional-engine.d.ts.map +0 -1
- package/dist/src/core/sync/bidirectional-engine.js +0 -359
- package/dist/src/core/sync/bidirectional-engine.js.map +0 -1
- package/dist/src/core/sync/conflict-resolver.d.ts +0 -66
- package/dist/src/core/sync/conflict-resolver.d.ts.map +0 -1
- package/dist/src/core/sync/conflict-resolver.js +0 -108
- package/dist/src/core/sync/conflict-resolver.js.map +0 -1
- package/dist/src/core/sync/enhanced-content-builder.d.ts +0 -55
- package/dist/src/core/sync/enhanced-content-builder.d.ts.map +0 -1
- package/dist/src/core/sync/enhanced-content-builder.js +0 -203
- package/dist/src/core/sync/enhanced-content-builder.js.map +0 -1
- package/dist/src/core/sync/folder-mapper.d.ts +0 -71
- package/dist/src/core/sync/folder-mapper.d.ts.map +0 -1
- package/dist/src/core/sync/folder-mapper.js +0 -203
- package/dist/src/core/sync/folder-mapper.js.map +0 -1
- package/dist/src/core/sync/label-detector.d.ts +0 -66
- package/dist/src/core/sync/label-detector.d.ts.map +0 -1
- package/dist/src/core/sync/label-detector.js +0 -224
- package/dist/src/core/sync/label-detector.js.map +0 -1
- package/dist/src/core/sync/performance-optimizer.d.ts +0 -153
- package/dist/src/core/sync/performance-optimizer.d.ts.map +0 -1
- package/dist/src/core/sync/performance-optimizer.js +0 -220
- package/dist/src/core/sync/performance-optimizer.js.map +0 -1
- package/dist/src/core/sync/profile-selector.d.ts +0 -52
- package/dist/src/core/sync/profile-selector.d.ts.map +0 -1
- package/dist/src/core/sync/profile-selector.js +0 -179
- package/dist/src/core/sync/profile-selector.js.map +0 -1
- package/dist/src/core/sync/profile-validator.d.ts +0 -52
- package/dist/src/core/sync/profile-validator.d.ts.map +0 -1
- package/dist/src/core/sync/profile-validator.js +0 -170
- package/dist/src/core/sync/profile-validator.js.map +0 -1
- package/dist/src/core/sync/rate-limiter.d.ts +0 -116
- package/dist/src/core/sync/rate-limiter.d.ts.map +0 -1
- package/dist/src/core/sync/rate-limiter.js +0 -308
- package/dist/src/core/sync/rate-limiter.js.map +0 -1
- package/dist/src/core/sync/retry-handler.d.ts +0 -98
- package/dist/src/core/sync/retry-handler.d.ts.map +0 -1
- package/dist/src/core/sync/retry-handler.js +0 -196
- package/dist/src/core/sync/retry-handler.js.map +0 -1
- package/dist/src/core/sync/retry-logic.d.ts +0 -64
- package/dist/src/core/sync/retry-logic.d.ts.map +0 -1
- package/dist/src/core/sync/retry-logic.js +0 -165
- package/dist/src/core/sync/retry-logic.js.map +0 -1
- package/dist/src/core/sync/status-cache.d.ts +0 -91
- package/dist/src/core/sync/status-cache.d.ts.map +0 -1
- package/dist/src/core/sync/status-cache.js +0 -140
- package/dist/src/core/sync/status-cache.js.map +0 -1
- package/dist/src/core/sync/status-mapper.d.ts +0 -69
- package/dist/src/core/sync/status-mapper.d.ts.map +0 -1
- package/dist/src/core/sync/status-mapper.js +0 -90
- package/dist/src/core/sync/status-mapper.js.map +0 -1
- package/dist/src/core/sync/status-sync-engine.d.ts +0 -162
- package/dist/src/core/sync/status-sync-engine.d.ts.map +0 -1
- package/dist/src/core/sync/status-sync-engine.js +0 -347
- package/dist/src/core/sync/status-sync-engine.js.map +0 -1
- package/dist/src/core/sync/sync-event-logger.d.ts +0 -113
- package/dist/src/core/sync/sync-event-logger.d.ts.map +0 -1
- package/dist/src/core/sync/sync-event-logger.js +0 -141
- package/dist/src/core/sync/sync-event-logger.js.map +0 -1
- package/dist/src/core/sync/time-range-selector.d.ts +0 -48
- package/dist/src/core/sync/time-range-selector.d.ts.map +0 -1
- package/dist/src/core/sync/time-range-selector.js +0 -224
- package/dist/src/core/sync/time-range-selector.js.map +0 -1
- package/dist/src/core/sync/types.d.ts +0 -52
- package/dist/src/core/sync/types.d.ts.map +0 -1
- package/dist/src/core/sync/types.js +0 -5
- package/dist/src/core/sync/types.js.map +0 -1
- package/dist/src/core/sync/workflow-detector.d.ts +0 -95
- package/dist/src/core/sync/workflow-detector.d.ts.map +0 -1
- package/dist/src/core/sync/workflow-detector.js +0 -175
- package/dist/src/core/sync/workflow-detector.js.map +0 -1
- package/plugins/specweave-github/lib/enhanced-github-sync.js +0 -220
- package/plugins/specweave-github/lib/enhanced-github-sync.ts +0 -322
- package/plugins/specweave-jira/lib/enhanced-jira-sync.js +0 -134
- package/plugins/specweave-jira/lib/enhanced-jira-sync.ts +0 -196
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bidirectional Sync Engine
|
|
3
|
-
*
|
|
4
|
-
* @deprecated This module is deprecated as of v0.24.0 (Three-Permission Architecture).
|
|
5
|
-
* The "bidirectional" and "three-permission sync" terminology has been replaced with granular permission controls:
|
|
6
|
-
* - canUpsertInternalItems: CREATE + UPDATE internal items
|
|
7
|
-
* - canUpdateExternalItems: UPDATE external items (full content)
|
|
8
|
-
* - canUpdateStatus: UPDATE status (both types)
|
|
9
|
-
*
|
|
10
|
-
* This file is kept for backward compatibility but is no longer actively maintained.
|
|
11
|
-
* See: .specweave/increments/0047-us-task-linkage/reports/THREE-PERMISSION-ARCHITECTURE-CHANGES.md
|
|
12
|
-
*
|
|
13
|
-
* Handles synchronization between SpecWeave increments and external systems
|
|
14
|
-
* (GitHub, Jira, ADO) in both directions with conflict detection and resolution.
|
|
15
|
-
*
|
|
16
|
-
* Features:
|
|
17
|
-
* - Three-permission sync (to-external, from-external, both)
|
|
18
|
-
* - Conflict detection (field-level granularity)
|
|
19
|
-
* - Interactive conflict resolution
|
|
20
|
-
* - Change tracking (detect what changed since last sync)
|
|
21
|
-
* - Reorganization detection (moved issues, split/merged stories)
|
|
22
|
-
*/
|
|
23
|
-
import { SyncProvider } from '../types/sync-profile.js';
|
|
24
|
-
export type SyncDirection = 'to-external' | 'from-external' | 'bidirectional';
|
|
25
|
-
export type ConflictResolution = 'prefer-local' | 'prefer-external' | 'manual' | 'prompt';
|
|
26
|
-
export interface SyncState {
|
|
27
|
-
/** Increment metadata */
|
|
28
|
-
incrementId: string;
|
|
29
|
-
title: string;
|
|
30
|
-
status: string;
|
|
31
|
-
/** External metadata */
|
|
32
|
-
externalId?: string;
|
|
33
|
-
externalKey?: string;
|
|
34
|
-
externalUrl?: string;
|
|
35
|
-
/** Sync state */
|
|
36
|
-
lastSyncAt?: string;
|
|
37
|
-
lastLocalChange?: string;
|
|
38
|
-
lastExternalChange?: string;
|
|
39
|
-
/** Content hashes (for change detection) */
|
|
40
|
-
localHash?: string;
|
|
41
|
-
externalHash?: string;
|
|
42
|
-
/** Linked items (user stories, tasks, etc.) */
|
|
43
|
-
linkedItems?: Record<string, string>;
|
|
44
|
-
}
|
|
45
|
-
export interface FieldChange {
|
|
46
|
-
field: string;
|
|
47
|
-
localValue: any;
|
|
48
|
-
externalValue: any;
|
|
49
|
-
lastSyncValue?: any;
|
|
50
|
-
}
|
|
51
|
-
export interface Conflict extends FieldChange {
|
|
52
|
-
resolution?: 'local' | 'external' | 'merged';
|
|
53
|
-
mergedValue?: any;
|
|
54
|
-
}
|
|
55
|
-
export interface ChangeSet {
|
|
56
|
-
/** Changes to sync to external */
|
|
57
|
-
toExternal: FieldChange[];
|
|
58
|
-
/** Changes to sync from external */
|
|
59
|
-
fromExternal: FieldChange[];
|
|
60
|
-
/** Conflicts (both sides changed) */
|
|
61
|
-
conflicts: Conflict[];
|
|
62
|
-
}
|
|
63
|
-
export interface SyncResult {
|
|
64
|
-
success: boolean;
|
|
65
|
-
direction: SyncDirection;
|
|
66
|
-
changes: ChangeSet;
|
|
67
|
-
conflictsResolved: number;
|
|
68
|
-
errors: string[];
|
|
69
|
-
}
|
|
70
|
-
export declare class BidirectionalSyncEngine {
|
|
71
|
-
private provider;
|
|
72
|
-
private projectRoot;
|
|
73
|
-
constructor(provider: SyncProvider, projectRoot?: string);
|
|
74
|
-
/**
|
|
75
|
-
* Main sync orchestrator
|
|
76
|
-
*/
|
|
77
|
-
sync(incrementId: string, direction: SyncDirection, conflictResolution?: ConflictResolution): Promise<SyncResult>;
|
|
78
|
-
/**
|
|
79
|
-
* Detect changes in both local and external state
|
|
80
|
-
*/
|
|
81
|
-
private detectChanges;
|
|
82
|
-
/**
|
|
83
|
-
* Fetch local state from increment files
|
|
84
|
-
*/
|
|
85
|
-
private fetchLocalState;
|
|
86
|
-
/**
|
|
87
|
-
* Fetch external state from Jira/GitHub/ADO
|
|
88
|
-
*/
|
|
89
|
-
private fetchExternalState;
|
|
90
|
-
/**
|
|
91
|
-
* Resolve conflicts interactively or automatically
|
|
92
|
-
*/
|
|
93
|
-
private resolveConflicts;
|
|
94
|
-
/**
|
|
95
|
-
* Interactive conflict resolution prompt
|
|
96
|
-
*/
|
|
97
|
-
private promptConflictResolution;
|
|
98
|
-
/**
|
|
99
|
-
* Apply changes to external system
|
|
100
|
-
*/
|
|
101
|
-
private applyToExternal;
|
|
102
|
-
/**
|
|
103
|
-
* Apply changes to local increment
|
|
104
|
-
*/
|
|
105
|
-
private applyToLocal;
|
|
106
|
-
/**
|
|
107
|
-
* Load sync state from metadata
|
|
108
|
-
*/
|
|
109
|
-
private loadSyncState;
|
|
110
|
-
/**
|
|
111
|
-
* Update sync state in metadata
|
|
112
|
-
*/
|
|
113
|
-
private updateSyncState;
|
|
114
|
-
/**
|
|
115
|
-
* Print sync summary
|
|
116
|
-
*/
|
|
117
|
-
private printSyncSummary;
|
|
118
|
-
}
|
|
119
|
-
//# sourceMappingURL=bidirectional-engine.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bidirectional-engine.d.ts","sourceRoot":"","sources":["../../../../src/core/sync/bidirectional-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAMxD,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG,eAAe,GAAG,eAAe,CAAC;AAE9E,MAAM,MAAM,kBAAkB,GAAG,cAAc,GAAG,iBAAiB,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE1F,MAAM,WAAW,SAAS;IACxB,yBAAyB;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IAEf,wBAAwB;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,iBAAiB;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,GAAG,CAAC;IAChB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precated This module is deprecated as of v0.24.0 (Three-Permission Architecture).
|
|
5
|
-
* The "bidirectional" and "three-permission sync" terminology has been replaced with granular permission controls:
|
|
6
|
-
* - canUpsertInternalItems: CREATE + UPDATE internal items
|
|
7
|
-
* - canUpdateExternalItems: UPDATE external items (full content)
|
|
8
|
-
* - canUpdateStatus: UPDATE status (both types)
|
|
9
|
-
*
|
|
10
|
-
* This file is kept for backward compatibility but is no longer actively maintained.
|
|
11
|
-
* See: .specweave/increments/0047-us-task-linkage/reports/THREE-PERMISSION-ARCHITECTURE-CHANGES.md
|
|
12
|
-
*
|
|
13
|
-
* Handles synchronization between SpecWeave increments and external systems
|
|
14
|
-
* (GitHub, Jira, ADO) in both directions with conflict detection and resolution.
|
|
15
|
-
*
|
|
16
|
-
* Features:
|
|
17
|
-
* - Three-permission sync (to-external, from-external, both)
|
|
18
|
-
* - Conflict detection (field-level granularity)
|
|
19
|
-
* - Interactive conflict resolution
|
|
20
|
-
* - Change tracking (detect what changed since last sync)
|
|
21
|
-
* - Reorganization detection (moved issues, split/merged stories)
|
|
22
|
-
*/
|
|
23
|
-
import * as fs from '../../utils/fs-native.js';
|
|
24
|
-
import * as path from 'path';
|
|
25
|
-
import { select, input } from '@inquirer/prompts';
|
|
26
|
-
// ============================================================================
|
|
27
|
-
// Bidirectional Sync Engine
|
|
28
|
-
// ============================================================================
|
|
29
|
-
export class BidirectionalSyncEngine {
|
|
30
|
-
constructor(provider, projectRoot = process.cwd()) {
|
|
31
|
-
this.provider = provider;
|
|
32
|
-
this.projectRoot = projectRoot;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Main sync orchestrator
|
|
36
|
-
*/
|
|
37
|
-
async sync(incrementId, direction, conflictResolution = 'prompt') {
|
|
38
|
-
console.log(`\n🔄 Starting ${direction} sync for increment ${incrementId}...\n`);
|
|
39
|
-
const result = {
|
|
40
|
-
success: false,
|
|
41
|
-
direction,
|
|
42
|
-
changes: { toExternal: [], fromExternal: [], conflicts: [] },
|
|
43
|
-
conflictsResolved: 0,
|
|
44
|
-
errors: [],
|
|
45
|
-
};
|
|
46
|
-
try {
|
|
47
|
-
// Step 1: Load current state
|
|
48
|
-
const currentState = await this.loadSyncState(incrementId);
|
|
49
|
-
// Step 2: Detect changes
|
|
50
|
-
const changes = await this.detectChanges(incrementId, currentState);
|
|
51
|
-
result.changes = changes;
|
|
52
|
-
// Step 3: Handle conflicts (if bidirectional)
|
|
53
|
-
if (direction === 'bidirectional' && changes.conflicts.length > 0) {
|
|
54
|
-
console.log(`\n⚠️ Detected ${changes.conflicts.length} conflicts\n`);
|
|
55
|
-
const resolved = await this.resolveConflicts(changes.conflicts, conflictResolution);
|
|
56
|
-
result.conflictsResolved = resolved.length;
|
|
57
|
-
// Apply resolutions
|
|
58
|
-
for (const conflict of resolved) {
|
|
59
|
-
if (conflict.resolution === 'local') {
|
|
60
|
-
changes.toExternal.push(conflict);
|
|
61
|
-
}
|
|
62
|
-
else if (conflict.resolution === 'external') {
|
|
63
|
-
changes.fromExternal.push(conflict);
|
|
64
|
-
}
|
|
65
|
-
else if (conflict.resolution === 'merged' && conflict.mergedValue !== undefined) {
|
|
66
|
-
// Apply merged value to both sides
|
|
67
|
-
changes.toExternal.push({
|
|
68
|
-
...conflict,
|
|
69
|
-
localValue: conflict.mergedValue,
|
|
70
|
-
});
|
|
71
|
-
changes.fromExternal.push({
|
|
72
|
-
...conflict,
|
|
73
|
-
externalValue: conflict.mergedValue,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
// Step 4: Apply changes based on direction
|
|
79
|
-
if (direction === 'to-external' || direction === 'bidirectional') {
|
|
80
|
-
if (changes.toExternal.length > 0) {
|
|
81
|
-
console.log(`\n📤 Syncing ${changes.toExternal.length} changes to ${this.provider}...`);
|
|
82
|
-
await this.applyToExternal(incrementId, changes.toExternal);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
if (direction === 'from-external' || direction === 'bidirectional') {
|
|
86
|
-
if (changes.fromExternal.length > 0) {
|
|
87
|
-
console.log(`\n📥 Syncing ${changes.fromExternal.length} changes from ${this.provider}...`);
|
|
88
|
-
await this.applyToLocal(incrementId, changes.fromExternal);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
// Step 5: Update sync state
|
|
92
|
-
await this.updateSyncState(incrementId, {
|
|
93
|
-
...currentState,
|
|
94
|
-
lastSyncAt: new Date().toISOString(),
|
|
95
|
-
lastLocalChange: new Date().toISOString(),
|
|
96
|
-
lastExternalChange: new Date().toISOString(),
|
|
97
|
-
});
|
|
98
|
-
result.success = true;
|
|
99
|
-
console.log(`\n✅ Sync complete!\n`);
|
|
100
|
-
this.printSyncSummary(result);
|
|
101
|
-
return result;
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
result.success = false;
|
|
105
|
-
result.errors.push(error.message);
|
|
106
|
-
console.error(`\n❌ Sync failed:`, error.message);
|
|
107
|
-
return result;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
// ==========================================================================
|
|
111
|
-
// Change Detection
|
|
112
|
-
// ==========================================================================
|
|
113
|
-
/**
|
|
114
|
-
* Detect changes in both local and external state
|
|
115
|
-
*/
|
|
116
|
-
async detectChanges(incrementId, currentState) {
|
|
117
|
-
const localState = await this.fetchLocalState(incrementId);
|
|
118
|
-
const externalState = await this.fetchExternalState(incrementId, currentState);
|
|
119
|
-
const toExternal = [];
|
|
120
|
-
const fromExternal = [];
|
|
121
|
-
const conflicts = [];
|
|
122
|
-
// Compare common fields
|
|
123
|
-
const fields = ['title', 'description', 'status', 'priority', 'assignee'];
|
|
124
|
-
for (const field of fields) {
|
|
125
|
-
const localValue = localState[field];
|
|
126
|
-
const externalValue = externalState[field];
|
|
127
|
-
const lastSyncValue = currentState.lastSyncAt
|
|
128
|
-
? currentState[field]
|
|
129
|
-
: undefined;
|
|
130
|
-
// Detect changes
|
|
131
|
-
const localChanged = localValue !== lastSyncValue;
|
|
132
|
-
const externalChanged = externalValue !== lastSyncValue;
|
|
133
|
-
if (localChanged && externalChanged && localValue !== externalValue) {
|
|
134
|
-
// CONFLICT: Both changed to different values
|
|
135
|
-
conflicts.push({
|
|
136
|
-
field,
|
|
137
|
-
localValue,
|
|
138
|
-
externalValue,
|
|
139
|
-
lastSyncValue,
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
else if (localChanged) {
|
|
143
|
-
// Local changed, external didn't
|
|
144
|
-
toExternal.push({
|
|
145
|
-
field,
|
|
146
|
-
localValue,
|
|
147
|
-
externalValue,
|
|
148
|
-
lastSyncValue,
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
else if (externalChanged) {
|
|
152
|
-
// External changed, local didn't
|
|
153
|
-
fromExternal.push({
|
|
154
|
-
field,
|
|
155
|
-
localValue,
|
|
156
|
-
externalValue,
|
|
157
|
-
lastSyncValue,
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
return { toExternal, fromExternal, conflicts };
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Fetch local state from increment files
|
|
165
|
-
*/
|
|
166
|
-
async fetchLocalState(incrementId) {
|
|
167
|
-
const incrementPath = path.join(this.projectRoot, '.specweave', 'increments', incrementId);
|
|
168
|
-
// Read spec.md
|
|
169
|
-
const specPath = path.join(incrementPath, 'spec.md');
|
|
170
|
-
const specContent = await fs.readFile(specPath, 'utf-8');
|
|
171
|
-
// Parse frontmatter and content
|
|
172
|
-
const titleMatch = specContent.match(/^#\s+(.+)$/m);
|
|
173
|
-
const statusMatch = specContent.match(/Status:\s*(.+)$/m);
|
|
174
|
-
const priorityMatch = specContent.match(/Priority:\s*(.+)$/m);
|
|
175
|
-
return {
|
|
176
|
-
title: titleMatch ? titleMatch[1] : '',
|
|
177
|
-
description: specContent.substring(0, 500), // First 500 chars
|
|
178
|
-
status: statusMatch ? statusMatch[1].trim() : 'in-progress',
|
|
179
|
-
priority: priorityMatch ? priorityMatch[1].trim() : 'medium',
|
|
180
|
-
assignee: null,
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Fetch external state from Jira/GitHub/ADO
|
|
185
|
-
*/
|
|
186
|
-
async fetchExternalState(incrementId, currentState) {
|
|
187
|
-
if (!currentState.externalKey) {
|
|
188
|
-
return {}; // No external issue yet
|
|
189
|
-
}
|
|
190
|
-
// This will be implemented by provider-specific adapters
|
|
191
|
-
// For now, return placeholder
|
|
192
|
-
return {
|
|
193
|
-
title: '',
|
|
194
|
-
description: '',
|
|
195
|
-
status: '',
|
|
196
|
-
priority: '',
|
|
197
|
-
assignee: null,
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
// ==========================================================================
|
|
201
|
-
// Conflict Resolution
|
|
202
|
-
// ==========================================================================
|
|
203
|
-
/**
|
|
204
|
-
* Resolve conflicts interactively or automatically
|
|
205
|
-
*/
|
|
206
|
-
async resolveConflicts(conflicts, strategy) {
|
|
207
|
-
const resolved = [];
|
|
208
|
-
for (const conflict of conflicts) {
|
|
209
|
-
if (strategy === 'prefer-local') {
|
|
210
|
-
conflict.resolution = 'local';
|
|
211
|
-
}
|
|
212
|
-
else if (strategy === 'prefer-external') {
|
|
213
|
-
conflict.resolution = 'external';
|
|
214
|
-
}
|
|
215
|
-
else if (strategy === 'manual' || strategy === 'prompt') {
|
|
216
|
-
await this.promptConflictResolution(conflict);
|
|
217
|
-
}
|
|
218
|
-
resolved.push(conflict);
|
|
219
|
-
}
|
|
220
|
-
return resolved;
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Interactive conflict resolution prompt
|
|
224
|
-
*/
|
|
225
|
-
async promptConflictResolution(conflict) {
|
|
226
|
-
console.log(`\n⚠️ Conflict in field: ${conflict.field}`);
|
|
227
|
-
console.log(` Local value: ${conflict.localValue}`);
|
|
228
|
-
console.log(` ${this.provider} value: ${conflict.externalValue}`);
|
|
229
|
-
console.log(` Last sync value: ${conflict.lastSyncValue || '(unknown)'}\n`);
|
|
230
|
-
const resolution = await select({
|
|
231
|
-
message: `How should this conflict be resolved?`,
|
|
232
|
-
choices: [
|
|
233
|
-
{
|
|
234
|
-
name: `Use local value: "${conflict.localValue}"`,
|
|
235
|
-
value: 'local',
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
name: `Use ${this.provider} value: "${conflict.externalValue}"`,
|
|
239
|
-
value: 'external',
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
name: 'Enter custom value (merge)',
|
|
243
|
-
value: 'merge',
|
|
244
|
-
},
|
|
245
|
-
],
|
|
246
|
-
});
|
|
247
|
-
if (resolution === 'merge') {
|
|
248
|
-
const mergedValue = await input({
|
|
249
|
-
message: `Enter merged value for ${conflict.field}:`,
|
|
250
|
-
default: conflict.localValue,
|
|
251
|
-
});
|
|
252
|
-
conflict.resolution = 'merged';
|
|
253
|
-
conflict.mergedValue = mergedValue;
|
|
254
|
-
}
|
|
255
|
-
else {
|
|
256
|
-
conflict.resolution = resolution;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
// ==========================================================================
|
|
260
|
-
// Apply Changes
|
|
261
|
-
// ==========================================================================
|
|
262
|
-
/**
|
|
263
|
-
* Apply changes to external system
|
|
264
|
-
*/
|
|
265
|
-
async applyToExternal(incrementId, changes) {
|
|
266
|
-
// Implementation will be provider-specific
|
|
267
|
-
// This is a placeholder
|
|
268
|
-
for (const change of changes) {
|
|
269
|
-
console.log(` ✓ ${change.field}: ${change.localValue}`);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Apply changes to local increment
|
|
274
|
-
*/
|
|
275
|
-
async applyToLocal(incrementId, changes) {
|
|
276
|
-
const incrementPath = path.join(this.projectRoot, '.specweave', 'increments', incrementId);
|
|
277
|
-
const specPath = path.join(incrementPath, 'spec.md');
|
|
278
|
-
let specContent = await fs.readFile(specPath, 'utf-8');
|
|
279
|
-
// Apply changes to spec.md
|
|
280
|
-
for (const change of changes) {
|
|
281
|
-
if (change.field === 'title') {
|
|
282
|
-
specContent = specContent.replace(/^#\s+.+$/m, `# ${change.externalValue}`);
|
|
283
|
-
}
|
|
284
|
-
else if (change.field === 'status') {
|
|
285
|
-
specContent = specContent.replace(/Status:\s*.+$/m, `Status: ${change.externalValue}`);
|
|
286
|
-
}
|
|
287
|
-
else if (change.field === 'priority') {
|
|
288
|
-
specContent = specContent.replace(/Priority:\s*.+$/m, `Priority: ${change.externalValue}`);
|
|
289
|
-
}
|
|
290
|
-
console.log(` ✓ ${change.field}: ${change.externalValue}`);
|
|
291
|
-
}
|
|
292
|
-
await fs.writeFile(specPath, specContent, 'utf-8');
|
|
293
|
-
}
|
|
294
|
-
// ==========================================================================
|
|
295
|
-
// Sync State Management
|
|
296
|
-
// ==========================================================================
|
|
297
|
-
/**
|
|
298
|
-
* Load sync state from metadata
|
|
299
|
-
*/
|
|
300
|
-
async loadSyncState(incrementId) {
|
|
301
|
-
const metadataPath = path.join(this.projectRoot, '.specweave', 'increments', incrementId, 'metadata.json');
|
|
302
|
-
if (!fs.existsSync(metadataPath)) {
|
|
303
|
-
return { incrementId, title: '', status: '' };
|
|
304
|
-
}
|
|
305
|
-
const metadata = await fs.readJSON(metadataPath);
|
|
306
|
-
return {
|
|
307
|
-
incrementId,
|
|
308
|
-
title: metadata.title || '',
|
|
309
|
-
status: metadata.status || '',
|
|
310
|
-
externalId: metadata.sync?.externalId,
|
|
311
|
-
externalKey: metadata.sync?.externalKey,
|
|
312
|
-
externalUrl: metadata.sync?.externalUrl,
|
|
313
|
-
lastSyncAt: metadata.sync?.lastSyncAt,
|
|
314
|
-
lastLocalChange: metadata.sync?.lastLocalChange,
|
|
315
|
-
lastExternalChange: metadata.sync?.lastExternalChange,
|
|
316
|
-
linkedItems: metadata.sync?.linkedItems || {},
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Update sync state in metadata
|
|
321
|
-
*/
|
|
322
|
-
async updateSyncState(incrementId, state) {
|
|
323
|
-
const metadataPath = path.join(this.projectRoot, '.specweave', 'increments', incrementId, 'metadata.json');
|
|
324
|
-
let metadata = {};
|
|
325
|
-
if (fs.existsSync(metadataPath)) {
|
|
326
|
-
metadata = await fs.readJSON(metadataPath);
|
|
327
|
-
}
|
|
328
|
-
metadata.sync = {
|
|
329
|
-
...metadata.sync,
|
|
330
|
-
externalId: state.externalId,
|
|
331
|
-
externalKey: state.externalKey,
|
|
332
|
-
externalUrl: state.externalUrl,
|
|
333
|
-
lastSyncAt: state.lastSyncAt,
|
|
334
|
-
lastLocalChange: state.lastLocalChange,
|
|
335
|
-
lastExternalChange: state.lastExternalChange,
|
|
336
|
-
linkedItems: state.linkedItems,
|
|
337
|
-
};
|
|
338
|
-
await fs.writeJSON(metadataPath, metadata, { spaces: 2 });
|
|
339
|
-
}
|
|
340
|
-
// ==========================================================================
|
|
341
|
-
// Helpers
|
|
342
|
-
// ==========================================================================
|
|
343
|
-
/**
|
|
344
|
-
* Print sync summary
|
|
345
|
-
*/
|
|
346
|
-
printSyncSummary(result) {
|
|
347
|
-
console.log('📊 Sync Summary:\n');
|
|
348
|
-
// Display user-friendly direction label
|
|
349
|
-
const directionLabel = result.direction === 'bidirectional' ? 'Two-way' : result.direction;
|
|
350
|
-
console.log(` Direction: ${directionLabel}`);
|
|
351
|
-
console.log(` Changes to external: ${result.changes.toExternal.length}`);
|
|
352
|
-
console.log(` Changes from external: ${result.changes.fromExternal.length}`);
|
|
353
|
-
console.log(` Conflicts detected: ${result.changes.conflicts.length}`);
|
|
354
|
-
console.log(` Conflicts resolved: ${result.conflictsResolved}`);
|
|
355
|
-
console.log(` Errors: ${result.errors.length}`);
|
|
356
|
-
console.log('');
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
//# sourceMappingURL=bidirectional-engine.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bidirectional-engine.js","sourceRoot":"","sources":["../../../../src/core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-
/**
|
|
2
|
-
* Conflict Resolver
|
|
3
|
-
*
|
|
4
|
-
* Detects and resolves status conflicts between SpecWeave increments
|
|
5
|
-
* and external tools (GitHub, JIRA, Azure DevOps).
|
|
6
|
-
*
|
|
7
|
-
* Supports four resolution strategies:
|
|
8
|
-
* - prompt: Requires user interaction (UI)
|
|
9
|
-
* - last-write-wins: Uses most recent timestamp
|
|
10
|
-
* - specweave-wins: Always uses local SpecWeave status
|
|
11
|
-
* - external-wins: Always uses external tool status
|
|
12
|
-
*/
|
|
13
|
-
export type ConflictResolutionStrategy = 'prompt' | 'last-write-wins' | 'specweave-wins' | 'external-wins';
|
|
14
|
-
export interface StatusConflict {
|
|
15
|
-
incrementId: string;
|
|
16
|
-
tool: string;
|
|
17
|
-
localStatus: string;
|
|
18
|
-
remoteStatus: string;
|
|
19
|
-
localTimestamp: string;
|
|
20
|
-
remoteTimestamp: string;
|
|
21
|
-
}
|
|
22
|
-
export interface ConflictResolution {
|
|
23
|
-
action: 'use-local' | 'use-remote';
|
|
24
|
-
resolvedStatus: string;
|
|
25
|
-
}
|
|
26
|
-
export interface ConflictDetectionInput {
|
|
27
|
-
incrementId: string;
|
|
28
|
-
local: string;
|
|
29
|
-
remote: string;
|
|
30
|
-
tool: string;
|
|
31
|
-
localTimestamp: string;
|
|
32
|
-
remoteTimestamp: string;
|
|
33
|
-
}
|
|
34
|
-
export declare class ConflictResolver {
|
|
35
|
-
/**
|
|
36
|
-
* Detect status conflicts between local and remote
|
|
37
|
-
*
|
|
38
|
-
* @param input - Detection input with local/remote statuses and timestamps
|
|
39
|
-
* @returns StatusConflict if conflict exists, null if statuses match
|
|
40
|
-
*/
|
|
41
|
-
detect(input: ConflictDetectionInput): Promise<StatusConflict | null>;
|
|
42
|
-
/**
|
|
43
|
-
* Resolve status conflict using specified strategy
|
|
44
|
-
*
|
|
45
|
-
* @param conflict - The status conflict to resolve
|
|
46
|
-
* @param strategy - Resolution strategy to use
|
|
47
|
-
* @returns Resolution with action and resolved status
|
|
48
|
-
* @throws Error if strategy is unknown or requires user interaction
|
|
49
|
-
*/
|
|
50
|
-
resolve(conflict: StatusConflict, strategy: ConflictResolutionStrategy): Promise<ConflictResolution>;
|
|
51
|
-
/**
|
|
52
|
-
* Resolve conflict by comparing timestamps (last-write-wins)
|
|
53
|
-
*
|
|
54
|
-
* @param conflict - The status conflict to resolve
|
|
55
|
-
* @returns Resolution based on most recent timestamp
|
|
56
|
-
*/
|
|
57
|
-
private resolveByTimestamp;
|
|
58
|
-
/**
|
|
59
|
-
* Format conflict details for display to user
|
|
60
|
-
*
|
|
61
|
-
* @param conflict - The status conflict to format
|
|
62
|
-
* @returns Human-readable conflict message
|
|
63
|
-
*/
|
|
64
|
-
formatConflictMessage(conflict: StatusConflict): string;
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=conflict-resolver.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conflict-resolver.d.ts","sourceRoot":"","sources":["../../../../src/core/sync/conflict-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,MAAM,0BAA0B,GAClC,QAAQ,GACR,iBAAiB,GACjB,gBAAgB,GAChB,eAAe,CAAC;AAEpB,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,WAAW,GAAG,YAAY,CAAC;IACnC,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,gBAAgB;IAC3B;;;;;OAKG;IACU,MAAM,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAiBlF;;;;;;;OAOG;IACU,OAAO,CAClB,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,0BAA0B,GACnC,OAAO,CAAC,kBAAkB,CAAC;IAyB9B;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAkB1B;;;;;OAKG;IACI,qBAAqB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM;CAiB/D"}
|