aibridge-context 1.5.1 → 1.5.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/core/init.js CHANGED
@@ -48,14 +48,28 @@ async function initProject(projectRoot, options) {
48
48
  let enableGitSync = false;
49
49
  const bootstrapState = createDefaultState(projectRoot);
50
50
  const bootstrapAnalysis = bootstrapProjectAnalysis(projectRoot);
51
+ const mergedArchitecturePatterns =
52
+ Array.isArray(bootstrapAnalysis.architecturePatterns) &&
53
+ bootstrapAnalysis.architecturePatterns.length > 0
54
+ ? bootstrapAnalysis.architecturePatterns
55
+ : Array.isArray(existingState && existingState.architecture_patterns)
56
+ ? existingState.architecture_patterns
57
+ : [];
58
+ const mergedImplementationDetails =
59
+ Array.isArray(bootstrapAnalysis.implementationDetails) &&
60
+ bootstrapAnalysis.implementationDetails.length > 0
61
+ ? bootstrapAnalysis.implementationDetails
62
+ : Array.isArray(existingState && existingState.implementation_details)
63
+ ? existingState.implementation_details
64
+ : [];
51
65
 
52
66
  const initialState = Object.assign({}, templateState, existingState || bootstrapState, {
53
67
  project: metadata.project,
54
68
  version: metadata.version,
55
69
  ai_summary: bootstrapState.ai_summary,
56
70
  tech_stack: bootstrapAnalysis.techStack,
57
- architecture_patterns: bootstrapAnalysis.architecturePatterns,
58
- implementation_details: bootstrapAnalysis.implementationDetails,
71
+ architecture_patterns: mergedArchitecturePatterns,
72
+ implementation_details: mergedImplementationDetails,
59
73
  current_stage: bootstrapState.current_stage,
60
74
  key_features: bootstrapState.key_features,
61
75
  known_issues: bootstrapState.known_issues,
@@ -416,6 +416,54 @@ function createDefaultState(projectRoot) {
416
416
  return state;
417
417
  }
418
418
 
419
+ function mergePreferredArray(preferredValue, fallbackValue) {
420
+ if (Array.isArray(preferredValue) && preferredValue.length > 0) {
421
+ return preferredValue;
422
+ }
423
+
424
+ if (Array.isArray(fallbackValue) && fallbackValue.length > 0) {
425
+ return fallbackValue;
426
+ }
427
+
428
+ return [];
429
+ }
430
+
431
+ function mergePreferredObject(preferredValue, fallbackValue) {
432
+ const preferredObject = isObject(preferredValue) ? preferredValue : {};
433
+ const fallbackObject = isObject(fallbackValue) ? fallbackValue : {};
434
+
435
+ return Object.assign({}, fallbackObject, preferredObject);
436
+ }
437
+
438
+ function composeStateFromAnalysis(existingState, metadata, bootstrap, overrides) {
439
+ const baseState = isObject(existingState) ? existingState : {};
440
+ const nextState = Object.assign(
441
+ {
442
+ project: metadata.project,
443
+ version: metadata.version,
444
+ last_updated: baseState.last_updated || new Date(0).toISOString(),
445
+ ai_summary: '',
446
+ tech_stack: mergePreferredObject(bootstrap.techStack, baseState.tech_stack),
447
+ architecture_patterns: mergePreferredArray(
448
+ bootstrap.architecturePatterns,
449
+ baseState.architecture_patterns
450
+ ),
451
+ implementation_details: mergePreferredArray(
452
+ bootstrap.implementationDetails,
453
+ baseState.implementation_details
454
+ ),
455
+ current_stage: '',
456
+ recent_updates: Array.isArray(baseState.recent_updates) ? baseState.recent_updates : [],
457
+ key_features: mergePreferredArray(bootstrap.keyFeatures, baseState.key_features),
458
+ known_issues: [],
459
+ next_steps: []
460
+ },
461
+ overrides || {}
462
+ );
463
+
464
+ return nextState;
465
+ }
466
+
419
467
  function bootstrapProjectAnalysis(projectRoot) {
420
468
  const resolvedRoot = resolveProjectRoot(projectRoot);
421
469
  const metadata = detectProjectMetadata(resolvedRoot);
@@ -825,20 +873,33 @@ async function updateProjectState(projectRoot, changeEvent, options) {
825
873
  ? dedupeRecentUpdates(groupedUpdates.map(toStateUpdate).concat(normalizeStoredUpdates(existingState.recent_updates)))
826
874
  .slice(0, MAX_RECENT_UPDATES)
827
875
  : normalizeStoredUpdates(existingState.recent_updates).slice(0, MAX_RECENT_UPDATES);
828
- const nextState = {
829
- project: metadata.project,
830
- version: metadata.version,
876
+ const mergedArchitecturePatterns = mergePreferredArray(
877
+ bootstrap.architecturePatterns,
878
+ existingState.architecture_patterns
879
+ );
880
+ const mergedImplementationDetails = mergePreferredArray(
881
+ bootstrap.implementationDetails,
882
+ existingState.implementation_details
883
+ );
884
+ const nextState = composeStateFromAnalysis(existingState, metadata, bootstrap, {
831
885
  last_updated: timestamp,
832
- ai_summary: '',
833
- tech_stack: bootstrap.techStack,
834
- architecture_patterns: bootstrap.architecturePatterns,
835
- implementation_details: bootstrap.implementationDetails,
836
- current_stage: determineCurrentStage(keyFeatures, historyEntries, bootstrap.implementationDetails),
886
+ tech_stack: mergePreferredObject(bootstrap.techStack, existingState.tech_stack),
887
+ architecture_patterns: mergedArchitecturePatterns,
888
+ implementation_details: mergedImplementationDetails,
889
+ current_stage: determineCurrentStage(
890
+ keyFeatures,
891
+ historyEntries,
892
+ mergedImplementationDetails
893
+ ),
837
894
  recent_updates: recentUpdates,
838
895
  key_features: keyFeatures,
839
- known_issues: deriveKnownIssues(resolvedRoot, bootstrap),
896
+ known_issues: deriveKnownIssues(resolvedRoot, Object.assign({}, bootstrap, {
897
+ architecturePatterns: mergedArchitecturePatterns,
898
+ implementationDetails: mergedImplementationDetails,
899
+ keyFeatures
900
+ })),
840
901
  next_steps: []
841
- };
902
+ });
842
903
 
843
904
  nextState.ai_summary = generateAiSummary(nextState, bootstrap);
844
905
  nextState.next_steps = generateNextSteps(nextState, bootstrap, historyEntries);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aibridge-context",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "description": "Zero-config CLI and library for generating AI-readable project context, serving it locally, and syncing it with git.",
5
5
  "main": "./index.js",
6
6
  "bin": {