@schnick371/devsteps-shared 0.8.5 → 1.0.0-next.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.
Files changed (148) hide show
  1. package/README.md +8 -3
  2. package/dist/constants/index.d.ts +26 -0
  3. package/dist/constants/index.d.ts.map +1 -1
  4. package/dist/constants/index.js +26 -0
  5. package/dist/constants/index.js.map +1 -1
  6. package/dist/core/add.d.ts +7 -0
  7. package/dist/core/add.d.ts.map +1 -1
  8. package/dist/core/add.js +9 -2
  9. package/dist/core/add.js.map +1 -1
  10. package/dist/core/archive.d.ts +7 -0
  11. package/dist/core/archive.d.ts.map +1 -1
  12. package/dist/core/archive.js +30 -20
  13. package/dist/core/archive.js.map +1 -1
  14. package/dist/core/auto-migrate-detect.d.ts +61 -0
  15. package/dist/core/auto-migrate-detect.d.ts.map +1 -0
  16. package/dist/core/auto-migrate-detect.js +68 -0
  17. package/dist/core/auto-migrate-detect.js.map +1 -0
  18. package/dist/core/auto-migrate-impl.d.ts +32 -0
  19. package/dist/core/auto-migrate-impl.d.ts.map +1 -0
  20. package/dist/core/auto-migrate-impl.js +120 -0
  21. package/dist/core/auto-migrate-impl.js.map +1 -0
  22. package/dist/core/auto-migrate.d.ts +16 -131
  23. package/dist/core/auto-migrate.d.ts.map +1 -1
  24. package/dist/core/auto-migrate.js +25 -318
  25. package/dist/core/auto-migrate.js.map +1 -1
  26. package/dist/core/auto-migrate.test.js +11 -7
  27. package/dist/core/auto-migrate.test.js.map +1 -1
  28. package/dist/core/bulk-update.d.ts +7 -0
  29. package/dist/core/bulk-update.d.ts.map +1 -1
  30. package/dist/core/bulk-update.js +8 -1
  31. package/dist/core/bulk-update.js.map +1 -1
  32. package/dist/core/config.d.ts +7 -0
  33. package/dist/core/config.d.ts.map +1 -1
  34. package/dist/core/config.js +7 -0
  35. package/dist/core/config.js.map +1 -1
  36. package/dist/core/context.d.ts +9 -0
  37. package/dist/core/context.d.ts.map +1 -1
  38. package/dist/core/context.js +9 -0
  39. package/dist/core/context.js.map +1 -1
  40. package/dist/core/get.d.ts +7 -0
  41. package/dist/core/get.d.ts.map +1 -1
  42. package/dist/core/get.js +8 -1
  43. package/dist/core/get.js.map +1 -1
  44. package/dist/core/index-rebuild.d.ts +3 -0
  45. package/dist/core/index-rebuild.d.ts.map +1 -1
  46. package/dist/core/index-rebuild.js +11 -8
  47. package/dist/core/index-rebuild.js.map +1 -1
  48. package/dist/core/index-rebuild.test.js +6 -15
  49. package/dist/core/index-rebuild.test.js.map +1 -1
  50. package/dist/core/index-refs-core.d.ts +114 -0
  51. package/dist/core/index-refs-core.d.ts.map +1 -0
  52. package/dist/core/index-refs-core.js +306 -0
  53. package/dist/core/index-refs-core.js.map +1 -0
  54. package/dist/core/index-refs.d.ts +9 -124
  55. package/dist/core/index-refs.d.ts.map +1 -1
  56. package/dist/core/index-refs.js +19 -345
  57. package/dist/core/index-refs.js.map +1 -1
  58. package/dist/core/index-refs.test.js +3 -3
  59. package/dist/core/index-refs.test.js.map +1 -1
  60. package/dist/core/index.d.ts +19 -10
  61. package/dist/core/index.d.ts.map +1 -1
  62. package/dist/core/index.js +19 -10
  63. package/dist/core/index.js.map +1 -1
  64. package/dist/core/link.d.ts +33 -0
  65. package/dist/core/link.d.ts.map +1 -0
  66. package/dist/core/link.js +102 -0
  67. package/dist/core/link.js.map +1 -0
  68. package/dist/core/list.d.ts +8 -0
  69. package/dist/core/list.d.ts.map +1 -1
  70. package/dist/core/list.js +82 -5
  71. package/dist/core/list.js.map +1 -1
  72. package/dist/core/unlink.d.ts +26 -0
  73. package/dist/core/unlink.d.ts.map +1 -0
  74. package/dist/core/unlink.js +78 -0
  75. package/dist/core/unlink.js.map +1 -0
  76. package/dist/core/update.d.ts +7 -0
  77. package/dist/core/update.d.ts.map +1 -1
  78. package/dist/core/update.js +16 -8
  79. package/dist/core/update.js.map +1 -1
  80. package/dist/core/validation.d.ts +26 -1
  81. package/dist/core/validation.d.ts.map +1 -1
  82. package/dist/core/validation.js +65 -4
  83. package/dist/core/validation.js.map +1 -1
  84. package/dist/index.d.ts +11 -4
  85. package/dist/index.d.ts.map +1 -1
  86. package/dist/index.js +11 -4
  87. package/dist/index.js.map +1 -1
  88. package/dist/schemas/analysis.d.ts +206 -0
  89. package/dist/schemas/analysis.d.ts.map +1 -0
  90. package/dist/schemas/analysis.js +138 -0
  91. package/dist/schemas/analysis.js.map +1 -0
  92. package/dist/schemas/cbp-loops.d.ts +154 -0
  93. package/dist/schemas/cbp-loops.d.ts.map +1 -0
  94. package/dist/schemas/cbp-loops.js +160 -0
  95. package/dist/schemas/cbp-loops.js.map +1 -0
  96. package/dist/schemas/cbp-loops.test.d.ts +10 -0
  97. package/dist/schemas/cbp-loops.test.d.ts.map +1 -0
  98. package/dist/schemas/cbp-loops.test.js +268 -0
  99. package/dist/schemas/cbp-loops.test.js.map +1 -0
  100. package/dist/schemas/cbp-mandate.d.ts +107 -0
  101. package/dist/schemas/cbp-mandate.d.ts.map +1 -0
  102. package/dist/schemas/cbp-mandate.js +107 -0
  103. package/dist/schemas/cbp-mandate.js.map +1 -0
  104. package/dist/schemas/cbp-mandate.test.d.ts +10 -0
  105. package/dist/schemas/cbp-mandate.test.d.ts.map +1 -0
  106. package/dist/schemas/cbp-mandate.test.js +188 -0
  107. package/dist/schemas/cbp-mandate.test.js.map +1 -0
  108. package/dist/schemas/index-refs.schema.d.ts +4 -1
  109. package/dist/schemas/index-refs.schema.d.ts.map +1 -1
  110. package/dist/schemas/index-refs.schema.js +24 -3
  111. package/dist/schemas/index-refs.schema.js.map +1 -1
  112. package/dist/schemas/index.d.ts +17 -7
  113. package/dist/schemas/index.d.ts.map +1 -1
  114. package/dist/schemas/index.js +14 -1
  115. package/dist/schemas/index.js.map +1 -1
  116. package/dist/schemas/project.d.ts +7 -0
  117. package/dist/schemas/project.d.ts.map +1 -1
  118. package/dist/schemas/project.js +7 -0
  119. package/dist/schemas/project.js.map +1 -1
  120. package/dist/schemas/relationships.d.ts +3 -0
  121. package/dist/schemas/relationships.d.ts.map +1 -1
  122. package/dist/schemas/relationships.js +3 -0
  123. package/dist/schemas/relationships.js.map +1 -1
  124. package/dist/types/commands.d.ts +7 -0
  125. package/dist/types/commands.d.ts.map +1 -1
  126. package/dist/types/commands.js +7 -0
  127. package/dist/types/commands.js.map +1 -1
  128. package/dist/types/index-refs.types.d.ts +3 -0
  129. package/dist/types/index-refs.types.d.ts.map +1 -1
  130. package/dist/types/index-refs.types.js +3 -0
  131. package/dist/types/index-refs.types.js.map +1 -1
  132. package/dist/types/index.d.ts +9 -1
  133. package/dist/types/index.d.ts.map +1 -1
  134. package/dist/types/index.js +7 -0
  135. package/dist/types/index.js.map +1 -1
  136. package/dist/utils/cache.d.ts +7 -0
  137. package/dist/utils/cache.d.ts.map +1 -1
  138. package/dist/utils/cache.js +7 -0
  139. package/dist/utils/cache.js.map +1 -1
  140. package/dist/utils/index.d.ts +9 -1
  141. package/dist/utils/index.d.ts.map +1 -1
  142. package/dist/utils/index.js +26 -3
  143. package/dist/utils/index.js.map +1 -1
  144. package/dist/utils/init-helpers.d.ts +30 -0
  145. package/dist/utils/init-helpers.d.ts.map +1 -0
  146. package/dist/utils/init-helpers.js +134 -0
  147. package/dist/utils/init-helpers.js.map +1 -0
  148. package/package.json +1 -1
package/README.md CHANGED
@@ -46,10 +46,15 @@ const items = await listItems('/path/to/.devsteps');
46
46
  - `getItem()` - Retrieve work item by ID
47
47
  - `updateItem()` - Update existing work item
48
48
  - `deleteItem()` - Delete work item
49
- - `listItems()` - List all work items with filters
49
+ - `listItems()` - List all work items with filters (supports `archived: true` for archive scan)
50
50
  - `searchItems()` - Full-text search across items
51
- - `linkItems()` - Create relationships between items
52
- - `archiveItem()` - Archive completed items
51
+ - `linkItems()` - Create bidirectional relationship between items
52
+ - `unlinkItem()` - Remove a bidirectional relationship (idempotent — no-op if not present)
53
+ - `archiveItem()` - Archive a single completed item
54
+ - `purgeItems()` - Bulk archive items matching status/type filters
55
+ - `bulkUpdateItems()` - Update status/assignee/category/priority on multiple items
56
+ - `bulkAddTags()` - Add tags to multiple items at once
57
+ - `bulkRemoveTags()` - Remove tags from multiple items at once
53
58
 
54
59
  ### Types
55
60
  - `ItemType` - Epic, Story, Task, Bug, etc.
@@ -1,4 +1,7 @@
1
1
  /**
2
+ * Copyright © 2025 Thomas Hertel (the@devsteps.dev)
3
+ * Licensed under the Apache License, Version 2.0
4
+ *
2
5
  * Centralized constants for type-safe comparisons.
3
6
  * Use these instead of string literals to get autocomplete + compile-time safety.
4
7
  *
@@ -72,6 +75,29 @@ export declare const HIERARCHY_TYPE: {
72
75
  */
73
76
  export type ItemTypeValue = (typeof ITEM_TYPE)[keyof typeof ITEM_TYPE];
74
77
  export type StatusValue = (typeof STATUS)[keyof typeof STATUS];
78
+ /**
79
+ * Context Budget Protocol — Loop iteration bounds
80
+ *
81
+ * Hard limits enforced at handler level (not just schema).
82
+ * These values define the maximum number of iterations per loop type.
83
+ * Changing these requires updating all Tier-2 agent files that reference them.
84
+ *
85
+ * @see EPIC-028 N-Tier Agent Hierarchy
86
+ */
87
+ export declare const CBP_LOOP: {
88
+ /** Max Review-Fix iterations before escalation (Tier-2 quality gate) */
89
+ readonly MAX_REVIEW_FIX_ITERATIONS: 3;
90
+ /** Max TDD loop iterations (Tier-3 test-driven impl) */
91
+ readonly MAX_TDD_ITERATIONS: 3;
92
+ /** Max clarification rounds in Tier-2 research analyst */
93
+ readonly MAX_CLARIFICATION_ROUNDS: 2;
94
+ /** Max conflict-resolution rounds within a Tier-2 REDUCE phase */
95
+ readonly MAX_CONFLICT_RESOLUTION_ROUNDS: 2;
96
+ /** Max Tier-2 parallel T3 dispatches per turn */
97
+ readonly MAX_PARALLEL_T3_DISPATCHES: 10;
98
+ /** Max tokens for MandateResult findings field (~800 tokens) */
99
+ readonly MAX_MANDATE_FINDINGS_CHARS: 6000;
100
+ };
75
101
  export type RelationshipTypeValue = (typeof RELATIONSHIP_TYPE)[keyof typeof RELATIONSHIP_TYPE];
76
102
  export type MethodologyValue = (typeof METHODOLOGY)[keyof typeof METHODOLOGY];
77
103
  export type HierarchyTypeValue = (typeof HIERARCHY_TYPE)[keyof typeof HIERARCHY_TYPE];
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;;CASZ,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,MAAM;;;;;;;;;CAST,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;CAYpB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,WAAW;;;;CAId,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,cAAc;;;;CAIjB,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;AACvE,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,OAAO,MAAM,CAAC,CAAC;AAC/D,MAAM,MAAM,qBAAqB,GAChC,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAC5D,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAC9E,MAAM,MAAM,kBAAkB,GAC7B,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;;CASZ,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,MAAM;;;;;;;;;CAST,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;CAYpB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,WAAW;;;;CAId,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,cAAc;;;;CAIjB,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;AACvE,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,OAAO,MAAM,CAAC,CAAC;AAE/D;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ;IACnB,wEAAwE;;IAExE,wDAAwD;;IAExD,0DAA0D;;IAE1D,kEAAkE;;IAElE,iDAAiD;;IAEjD,gEAAgE;;CAExD,CAAC;AACX,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAC/F,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAC9E,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC"}
@@ -1,4 +1,7 @@
1
1
  /**
2
+ * Copyright © 2025 Thomas Hertel (the@devsteps.dev)
3
+ * Licensed under the Apache License, Version 2.0
4
+ *
2
5
  * Centralized constants for type-safe comparisons.
3
6
  * Use these instead of string literals to get autocomplete + compile-time safety.
4
7
  *
@@ -67,4 +70,27 @@ export const HIERARCHY_TYPE = {
67
70
  WATERFALL: 'waterfall',
68
71
  BOTH: 'both',
69
72
  };
73
+ /**
74
+ * Context Budget Protocol — Loop iteration bounds
75
+ *
76
+ * Hard limits enforced at handler level (not just schema).
77
+ * These values define the maximum number of iterations per loop type.
78
+ * Changing these requires updating all Tier-2 agent files that reference them.
79
+ *
80
+ * @see EPIC-028 N-Tier Agent Hierarchy
81
+ */
82
+ export const CBP_LOOP = {
83
+ /** Max Review-Fix iterations before escalation (Tier-2 quality gate) */
84
+ MAX_REVIEW_FIX_ITERATIONS: 3,
85
+ /** Max TDD loop iterations (Tier-3 test-driven impl) */
86
+ MAX_TDD_ITERATIONS: 3,
87
+ /** Max clarification rounds in Tier-2 research analyst */
88
+ MAX_CLARIFICATION_ROUNDS: 2,
89
+ /** Max conflict-resolution rounds within a Tier-2 REDUCE phase */
90
+ MAX_CONFLICT_RESOLUTION_ROUNDS: 2,
91
+ /** Max Tier-2 parallel T3 dispatches per turn */
92
+ MAX_PARALLEL_T3_DISPATCHES: 10,
93
+ /** Max tokens for MandateResult findings field (~800 tokens) */
94
+ MAX_MANDATE_FINDINGS_CHARS: 6000,
95
+ };
70
96
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACxB,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,aAAa;IAC1B,OAAO,EAAE,SAAS;IAClB,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;CACH,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IACrB,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,aAAa;IAC1B,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,SAAS,EAAE,WAAW;IACtB,QAAQ,EAAE,UAAU;CACX,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAChC,UAAU,EAAE,YAAY;IACxB,cAAc,EAAE,gBAAgB;IAChC,MAAM,EAAE,QAAQ;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EAAE,WAAW;IACtB,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,YAAY;IACxB,UAAU,EAAE,YAAY;IACxB,WAAW,EAAE,aAAa;IAC1B,UAAU,EAAE,YAAY;IACxB,aAAa,EAAE,eAAe;CACtB,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,KAAK,EAAE,OAAO;IACd,SAAS,EAAE,WAAW;IACtB,MAAM,EAAE,QAAQ;CACR,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,KAAK,EAAE,OAAO;IACd,SAAS,EAAE,WAAW;IACtB,IAAI,EAAE,MAAM;CACJ,CAAC;AAQX;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,wEAAwE;IACxE,yBAAyB,EAAE,CAAC;IAC5B,wDAAwD;IACxD,kBAAkB,EAAE,CAAC;IACrB,0DAA0D;IAC1D,wBAAwB,EAAE,CAAC;IAC3B,kEAAkE;IAClE,8BAA8B,EAAE,CAAC;IACjC,iDAAiD;IACjD,0BAA0B,EAAE,EAAE;IAC9B,gEAAgE;IAChE,0BAA0B,EAAE,IAAI;CACxB,CAAC"}
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Copyright © 2025 Thomas Hertel (the@devsteps.dev)
3
+ * Licensed under the Apache License, Version 2.0
4
+ *
5
+ * Core add-item operation
6
+ * Creates metadata JSON, description Markdown, and updates distributed index.
7
+ */
1
8
  import type { DevStepsConfig, EisenhowerQuadrant, ItemMetadata, ItemType } from '../schemas/index.js';
2
9
  export interface AddItemArgs {
3
10
  type: ItemType;
@@ -1 +1 @@
1
- {"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/core/add.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,cAAc,EAEd,kBAAkB,EAClB,YAAY,EACZ,QAAQ,EACT,MAAM,qBAAqB,CAAC;AAgB7B,MAAM,WAAW,WAAW;IAC1B,IAAI,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AW,GAAG,OAAO,CAAC,aAAa,CAAC,CA2E5F"}
package/dist/core/add.js CHANGED
@@ -1,8 +1,15 @@
1
+ /**
2
+ * Copyright © 2025 Thomas Hertel (the@devsteps.dev)
3
+ * Licensed under the Apache License, Version 2.0
4
+ *
5
+ * Core add-item operation
6
+ * Creates metadata JSON, description Markdown, and updates distributed index.
7
+ */
1
8
  import { existsSync, writeFileSync } from 'node:fs';
2
9
  import { join } from 'node:path';
3
- import { TYPE_TO_DIRECTORY, generateItemId, getCurrentTimestamp, getTypePrefix, } from '../utils/index.js';
4
- import { loadCounters, updateCounters, addItemToIndex, } from './index-refs.js';
10
+ import { generateItemId, getCurrentTimestamp, getTypePrefix, TYPE_TO_DIRECTORY, } from '../utils/index.js';
5
11
  import { getConfig } from './config.js';
12
+ import { addItemToIndex, loadCounters, updateCounters } from './index-refs.js';
6
13
  /**
7
14
  * Core business logic for adding a new item to devsteps
8
15
  * Pure function that handles all file I/O and validation
@@ -1 +1 @@
1
- {"version":3,"file":"add.js","sourceRoot":"","sources":["../../src/core/add.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAgB,aAAa,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAQjC,OAAO,EACN,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,aAAa,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,YAAY,EACZ,cAAc,EACd,cAAc,GAEf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAmBxC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,WAAmB,EAAE,IAAiB;IAClE,uBAAuB;IACvB,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IAED,wBAAwB;IACxB,MAAM,MA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,CAAC;AACJ,CAAC"}
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Copyright © 2025 Thomas Hertel (the@devsteps.dev)
3
+ * Licensed under the Apache License, Version 2.0
4
+ *
5
+ * Core archive and purge operations
6
+ * Moves items to .devsteps/archive/ and updates the distributed index.
7
+ */
1
8
  import type { ItemStatus } from '../schemas/index.js';
2
9
  export interface ArchiveItemResult {
3
10
  itemId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"archive.d.ts","sourceRoot":"","sources":["../../src/core/archive.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAiB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGrE,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,UAAU,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAqDjG;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,IAAI,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,wBAAsB,UAAU,CAC9B,WAAW,EAAE,MAAM,EACnB,IAAI,GAAE,cAAmB,GACxB,OAAO,CAAC,gBAAgB,CAAC,CA6C3B"}
1
+ {"version":3,"file":"archive.d.ts","sourceRoot":"","sources":["../../src/core/archive.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAY,MAAM,qBAAqB,CAAC;AAKhE,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,UAAU,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA+CjG;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,IAAI,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,wBAAsB,UAAU,CAC9B,WAAW,EAAE,MAAM,EACnB,IAAI,GAAE,cAAmB,GACxB,OAAO,CAAC,gBAAgB,CAAC,CA8C3B"}
@@ -1,8 +1,16 @@
1
- import { existsSync, mkdirSync, readFileSync, renameSync } from 'node:fs';
1
+ /**
2
+ * Copyright © 2025 Thomas Hertel (the@devsteps.dev)
3
+ * Licensed under the Apache License, Version 2.0
4
+ *
5
+ * Core archive and purge operations
6
+ * Moves items to .devsteps/archive/ and updates the distributed index.
7
+ */
8
+ import { existsSync, mkdirSync, renameSync } from 'node:fs';
2
9
  import { join } from 'node:path';
3
- import { TYPE_TO_DIRECTORY, getCurrentTimestamp, parseItemId } from '../utils/index.js';
4
- import { removeItemFromIndex } from './index-refs.js';
10
+ import { getCurrentTimestamp, parseItemId, TYPE_TO_DIRECTORY } from '../utils/index.js';
5
11
  import { getItem } from './get.js';
12
+ import { removeItemFromIndex } from './index-refs.js';
13
+ import { listItems } from './list.js';
6
14
  /**
7
15
  * Core business logic for archiving a single item
8
16
  */
@@ -51,25 +59,27 @@ export async function purgeItems(devstepsDir, args = {}) {
51
59
  if (!existsSync(devstepsDir)) {
52
60
  throw new Error('Project not initialized. Run devsteps-init first.');
53
61
  }
54
- const indexPath = join(devstepsDir, 'index.json');
55
- const index = JSON.parse(readFileSync(indexPath, 'utf-8'));
56
- // Find items to archive
57
- let itemsToArchive = [...index.items];
58
- // Filter by status (default: done, cancelled)
59
- const statusFilter = args.status || ['done', 'cancelled'];
60
- itemsToArchive = itemsToArchive.filter((i) => statusFilter.includes(i.status));
61
- // Filter by type
62
- if (args.type) {
63
- itemsToArchive = itemsToArchive.filter((i) => i.type === args.type);
64
- }
65
- // Filter by date
66
- if (args.olderThan) {
67
- const cutoffDate = args.olderThan;
68
- itemsToArchive = itemsToArchive.filter((i) => {
69
- const updated = new Date(i.updated);
70
- return updated < cutoffDate;
62
+ // Collect candidate items using the refs-style index (via listItems).
63
+ // listItems() handles both legacy index.json and the current directory-based index.
64
+ const statusFilter = args.status ?? ['done', 'cancelled'];
65
+ const seen = new Set();
66
+ const candidates = [];
67
+ for (const status of statusFilter) {
68
+ const result = await listItems(devstepsDir, {
69
+ status,
70
+ type: args.type ? args.type : undefined,
71
71
  });
72
+ for (const item of result.items) {
73
+ if (!seen.has(item.id)) {
74
+ seen.add(item.id);
75
+ candidates.push({ id: item.id, updated: item.updated });
76
+ }
77
+ }
72
78
  }
79
+ // Apply optional date filter
80
+ const itemsToArchive = args.olderThan != null
81
+ ? candidates.filter((i) => new Date(i.updated) < args.olderThan)
82
+ : candidates;
73
83
  // Archive each item
74
84
  const archivedIds = [];
75
85
  for (const item of itemsToArchive) {
@@ -1 +1 @@
1
- {"version":3,"file":"archive.js","sourceRoot":"","sources":["../../src/core/archive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAiB,MAAM,SAAS,CAAC;AACzF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAAA,OAAO,EAAqB,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACjK,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAA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,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;gBACvB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAClB,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC;IACH,CAAC;IAED,6BAA6B;IAC7B,MAAM,cAAc,GAClB,IAAI,CAAC,SAAS,IAAI,IAAI;QACpB,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,GAAI,IAAI,CAAC,SAAkB,CAAC;QAC1E,CAAC,CAAC,UAAU,CAAC;IAEjB,oBAAoB;IACpB,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;QAClC,IAAI,CAAC;YACH,MAAM,WAAW,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;YACxC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,mCAAmC;YACnC,OAAO,CAAC,KAAK,CAAC,qBAAqB,IAAI,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK,EAAE,WAAW,CAAC,MAAM;QACzB,WAAW;KACZ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Copyright © 2025 Thomas Hertel (the@devsteps.dev)
3
+ * Licensed under the Apache License, Version 2.0
4
+ *
5
+ * Auto-Migration Detection
6
+ *
7
+ * Pure analysis/detection functions — no side effects, no I/O mutations.
8
+ * These functions only read state and return status information.
9
+ *
10
+ * @see STORY-073 External Project Migration Auto-Detection
11
+ */
12
+ /**
13
+ * Migration check result
14
+ */
15
+ export interface MigrationCheckResult {
16
+ /** Whether migration is needed */
17
+ needed: boolean;
18
+ /** Whether legacy index exists */
19
+ hasLegacy: boolean;
20
+ /** Whether refs-style index exists */
21
+ hasRefs: boolean;
22
+ /** Number of items in legacy index (if exists) */
23
+ itemCount?: number;
24
+ /** Human-readable status message */
25
+ message: string;
26
+ }
27
+ /**
28
+ * Auto-migration options
29
+ */
30
+ export interface AutoMigrationOptions {
31
+ /** Skip backup creation (advanced users only) */
32
+ skipBackup?: boolean;
33
+ /** Silent mode - suppress console output */
34
+ silent?: boolean;
35
+ /** Dry-run mode - check only, don't migrate */
36
+ dryRun?: boolean;
37
+ }
38
+ /**
39
+ * Migration statistics
40
+ */
41
+ export interface MigrationStats {
42
+ totalItems: number;
43
+ byType: Record<string, number>;
44
+ byStatus: Record<string, number>;
45
+ byPriority: Record<string, number>;
46
+ backupPath?: string;
47
+ archivePath?: string;
48
+ }
49
+ /**
50
+ * Check if index migration is needed (legacy → refs-style)
51
+ */
52
+ export declare function checkMigrationNeeded(devstepsDir: string): MigrationCheckResult;
53
+ /**
54
+ * Get user-friendly migration status message
55
+ */
56
+ export declare function getMigrationStatusMessage(devstepsDir: string): string;
57
+ /**
58
+ * Check if items/ directory migration is needed (flat → nested structure)
59
+ */
60
+ export declare function needsItemsDirectoryMigration(devstepsDir: string): boolean;
61
+ //# sourceMappingURL=auto-migrate-detect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-migrate-detect.d.ts","sourceRoot":"","sources":["../../src/core/auto-migrate-detect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,kCAAkC;IAClC,MAAM,EAAE,OAAO,CAAC;IAChB,kCAAkC;IAClC,SAAS,EAAE,OAAO,CAAC;IACnB,sCAAsC;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,iDAAiD;IACjD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,+CAA+C;IAC/C,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,oBAAoB,CA6B9E;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAQrE;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAOzE"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Copyright © 2025 Thomas Hertel (the@devsteps.dev)
3
+ * Licensed under the Apache License, Version 2.0
4
+ *
5
+ * Auto-Migration Detection
6
+ *
7
+ * Pure analysis/detection functions — no side effects, no I/O mutations.
8
+ * These functions only read state and return status information.
9
+ *
10
+ * @see STORY-073 External Project Migration Auto-Detection
11
+ */
12
+ import { existsSync } from 'node:fs';
13
+ import { join } from 'node:path';
14
+ import { hasLegacyIndex, hasRefsStyleIndex, loadLegacyIndex } from './index-refs.js';
15
+ /**
16
+ * Check if index migration is needed (legacy → refs-style)
17
+ */
18
+ export function checkMigrationNeeded(devstepsDir) {
19
+ if (!existsSync(devstepsDir)) {
20
+ return { needed: false, hasLegacy: false, hasRefs: false, message: 'Not a DevSteps project (no .devsteps directory)' };
21
+ }
22
+ const hasLegacy = hasLegacyIndex(devstepsDir);
23
+ const hasRefs = hasRefsStyleIndex(devstepsDir);
24
+ if (!hasLegacy && hasRefs) {
25
+ return { needed: false, hasLegacy: false, hasRefs: true, message: 'Project already using refs-style index ✓' };
26
+ }
27
+ if (hasLegacy && hasRefs) {
28
+ return { needed: false, hasLegacy: true, hasRefs: true, message: 'Both index formats exist - manual intervention required' };
29
+ }
30
+ if (!hasLegacy && !hasRefs) {
31
+ return { needed: false, hasLegacy: false, hasRefs: false, message: 'No index found - new project or not initialized' };
32
+ }
33
+ let itemCount;
34
+ try {
35
+ const legacy = loadLegacyIndex(devstepsDir);
36
+ itemCount = legacy.items.length;
37
+ }
38
+ catch (_error) {
39
+ // Ignore - legacy index might be corrupted
40
+ }
41
+ return { needed: true, hasLegacy: true, hasRefs: false, itemCount, message: `Migration needed: ${itemCount ?? 'unknown'} items to migrate` };
42
+ }
43
+ /**
44
+ * Get user-friendly migration status message
45
+ */
46
+ export function getMigrationStatusMessage(devstepsDir) {
47
+ const result = checkMigrationNeeded(devstepsDir);
48
+ if (!existsSync(devstepsDir))
49
+ return '❌ Not a DevSteps project';
50
+ if (result.needed)
51
+ return `🔄 Migration available: ${result.itemCount ?? 'unknown'} items can be migrated to refs-style index`;
52
+ if (result.hasRefs)
53
+ return '✅ Project using refs-style index';
54
+ if (result.hasLegacy && result.hasRefs)
55
+ return '⚠️ Both index formats detected - manual cleanup needed';
56
+ return '📦 DevSteps project (no index yet)';
57
+ }
58
+ /**
59
+ * Check if items/ directory migration is needed (flat → nested structure)
60
+ */
61
+ export function needsItemsDirectoryMigration(devstepsDir) {
62
+ const hasOldStructure = existsSync(join(devstepsDir, 'epics')) ||
63
+ existsSync(join(devstepsDir, 'stories')) ||
64
+ existsSync(join(devstepsDir, 'tasks'));
65
+ const hasNewStructure = existsSync(join(devstepsDir, 'items'));
66
+ return hasOldStructure && !hasNewStructure;
67
+ }
68
+ //# sourceMappingURL=auto-migrate-detect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-migrate-detect.js","sourceRoot":"","sources":["../../src/core/auto-migrate-detect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AA0CrF;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,WAAmB;IACtD,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,iDAAiD,EAAE,CAAC;IACzH,CAAC;IAED,MAAM,SAAS,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAE/C,IAAI,CAAC,SAAS,IAAI,OAAO,EAAE,CAAC;QAC1B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,0CAA0C,EAAE,CAAC;IACjH,CAAC;IAED,IAAI,SAAS,IAAI,OAAO,EAAE,CAAC;QACzB,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,yDAAyD,EAAE,CAAC;IAC/H,CAAC;IAED,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,EAAE,CAAC;QAC3B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS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CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;IAC/D,OAAO,eAAe,IAAI,CAAC,eAAe,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Copyright © 2025 Thomas Hertel (the@devsteps.dev)
3
+ * Licensed under the Apache License, Version 2.0
4
+ *
5
+ * Auto-Migration Implementation
6
+ *
7
+ * Stateful migration operations: performs actual index and directory migrations.
8
+ * Contains all I/O-heavy transformation logic.
9
+ *
10
+ * @see STORY-073 External Project Migration Auto-Detection
11
+ */
12
+ import type { AutoMigrationOptions, MigrationStats } from './auto-migrate-detect.js';
13
+ /**
14
+ * Perform core index migration: legacy index.json → refs-style distributed index
15
+ *
16
+ * @param devstepsDir Path to .devsteps directory
17
+ * @param options Migration options
18
+ * @returns Migration statistics
19
+ * @throws Error if migration fails or preconditions not met
20
+ * @internal
21
+ */
22
+ export declare function performMigration(devstepsDir: string, options?: AutoMigrationOptions): Promise<MigrationStats>;
23
+ /**
24
+ * Migrate from flat directory structure to items/ subdirectory
25
+ *
26
+ * Moves: `.devsteps/epics/…` → `.devsteps/items/epics/…`
27
+ */
28
+ export declare function migrateItemsDirectory(devstepsDir: string, options?: AutoMigrationOptions): {
29
+ moved: number;
30
+ types: Record<string, number>;
31
+ };
32
+ //# sourceMappingURL=auto-migrate-impl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-migrate-impl.d.ts","sourceRoot":"","sources":["../../src/core/auto-migrate-impl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAsBH,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAErF;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,cAAc,CAAC,CA6DzB;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,oBAAyB,GACjC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CA2BlD"}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Copyright © 2025 Thomas Hertel (the@devsteps.dev)
3
+ * Licensed under the Apache License, Version 2.0
4
+ *
5
+ * Auto-Migration Implementation
6
+ *
7
+ * Stateful migration operations: performs actual index and directory migrations.
8
+ * Contains all I/O-heavy transformation logic.
9
+ *
10
+ * @see STORY-073 External Project Migration Auto-Detection
11
+ */
12
+ import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmdirSync, writeFileSync, } from 'node:fs';
13
+ import { join } from 'node:path';
14
+ import { TYPE_TO_DIRECTORY } from '../utils/index.js';
15
+ import { addItemToIndex, getIndexPaths, hasLegacyIndex, hasRefsStyleIndex, initializeRefsStyleIndex, loadAllIndexes, } from './index-refs.js';
16
+ /**
17
+ * Perform core index migration: legacy index.json → refs-style distributed index
18
+ *
19
+ * @param devstepsDir Path to .devsteps directory
20
+ * @param options Migration options
21
+ * @returns Migration statistics
22
+ * @throws Error if migration fails or preconditions not met
23
+ * @internal
24
+ */
25
+ export async function performMigration(devstepsDir, options = {}) {
26
+ const { skipBackup = false } = options;
27
+ const paths = getIndexPaths(devstepsDir);
28
+ if (!existsSync(devstepsDir))
29
+ throw new Error('.devsteps directory not found. Is this a DevSteps project?');
30
+ if (!hasLegacyIndex(devstepsDir))
31
+ throw new Error('No index.json found. Nothing to migrate.');
32
+ if (hasRefsStyleIndex(devstepsDir))
33
+ throw new Error('Refs-style index already exists. Aborting to prevent data loss.');
34
+ const stats = { totalItems: 0, byType: {}, byStatus: {}, byPriority: {} };
35
+ // Backup old index
36
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
37
+ if (!skipBackup) {
38
+ const backupPath = `${paths.legacy}.backup-${timestamp}`;
39
+ writeFileSync(backupPath, readFileSync(paths.legacy, 'utf-8'));
40
+ stats.backupPath = backupPath;
41
+ }
42
+ // Load legacy index + initialize new structure
43
+ const legacyIndex = JSON.parse(readFileSync(paths.legacy, 'utf-8'));
44
+ initializeRefsStyleIndex(devstepsDir, legacyIndex.counters || {});
45
+ // Migrate each item into new index
46
+ for (const item of legacyIndex.items) {
47
+ const typeFolder = TYPE_TO_DIRECTORY[item.type];
48
+ const metadataPath = join(devstepsDir, typeFolder, `${item.id}.json`);
49
+ if (!existsSync(metadataPath))
50
+ continue;
51
+ const metadata = JSON.parse(readFileSync(metadataPath, 'utf-8'));
52
+ if (!metadata.eisenhower)
53
+ metadata.eisenhower = 'not-urgent-important'; // Default Q2
54
+ addItemToIndex(devstepsDir, metadata);
55
+ stats.totalItems++;
56
+ stats.byType[item.type] = (stats.byType[item.type] || 0) + 1;
57
+ stats.byStatus[item.status] = (stats.byStatus[item.status] || 0) + 1;
58
+ stats.byPriority[metadata.eisenhower] = (stats.byPriority[metadata.eisenhower] || 0) + 1;
59
+ }
60
+ // Verify migration: count + deduplicate
61
+ const newIndexes = loadAllIndexes(devstepsDir);
62
+ let newItemCount = 0;
63
+ for (const items of newIndexes.byType.values()) {
64
+ newItemCount += items.length;
65
+ }
66
+ if (newItemCount !== stats.totalItems) {
67
+ throw new Error(`Item count mismatch! Migrated: ${stats.totalItems}, Verified: ${newItemCount}`);
68
+ }
69
+ const allIds = new Set();
70
+ for (const items of newIndexes.byType.values()) {
71
+ for (const id of items) {
72
+ if (allIds.has(id))
73
+ throw new Error(`Duplicate item detected: ${id}`);
74
+ allIds.add(id);
75
+ }
76
+ }
77
+ // Archive old index and return stats
78
+ const archivePath = `${paths.legacy}.archived-${timestamp}`;
79
+ renameSync(paths.legacy, archivePath);
80
+ stats.archivePath = archivePath;
81
+ return stats;
82
+ }
83
+ /**
84
+ * Migrate from flat directory structure to items/ subdirectory
85
+ *
86
+ * Moves: `.devsteps/epics/…` → `.devsteps/items/epics/…`
87
+ */
88
+ export function migrateItemsDirectory(devstepsDir, options = {}) {
89
+ const { silent = false } = options;
90
+ if (!silent)
91
+ console.log('📂 Migrating to items/ directory structure...');
92
+ const oldDirs = ['epics', 'stories', 'tasks', 'bugs', 'spikes', 'tests', 'requirements', 'features'];
93
+ const stats = { moved: 0, types: {} };
94
+ const itemsDir = join(devstepsDir, 'items');
95
+ if (!existsSync(itemsDir))
96
+ mkdirSync(itemsDir, { recursive: true });
97
+ for (const dirName of oldDirs) {
98
+ const oldPath = join(devstepsDir, dirName);
99
+ const newPath = join(itemsDir, dirName);
100
+ if (!existsSync(oldPath))
101
+ continue;
102
+ mkdirSync(newPath, { recursive: true });
103
+ const files = readdirSync(oldPath);
104
+ let count = 0;
105
+ for (const file of files) {
106
+ renameSync(join(oldPath, file), join(newPath, file));
107
+ count++;
108
+ }
109
+ stats.types[dirName] = count;
110
+ stats.moved += count;
111
+ try {
112
+ rmdirSync(oldPath);
113
+ }
114
+ catch { /* ignore — not empty or other error */ }
115
+ }
116
+ if (!silent)
117
+ console.log(` ✅ Moved ${stats.moved} files to items/ subdirectories`);
118
+ return stats;
119
+ }
120
+ //# sourceMappingURL=auto-migrate-impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-migrate-impl.js","sourceRoot":"","sources":["../../src/core/auto-migrate-impl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,UAAU,EACV,SAAS,EACT,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EACL,cAAc,EACd,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,wBAAwB,EACxB,cAAc,GACf,MAAM,iBAAiB,CAAC;AAGzB;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,WAAmB,EACnB,UAAgC,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