@sudosandwich/limps 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +190 -0
  3. package/dist/agent-parser.d.ts +146 -0
  4. package/dist/agent-parser.d.ts.map +1 -0
  5. package/dist/agent-parser.js +448 -0
  6. package/dist/agent-parser.js.map +1 -0
  7. package/dist/config.d.ts +54 -0
  8. package/dist/config.d.ts.map +1 -0
  9. package/dist/config.js +146 -0
  10. package/dist/config.js.map +1 -0
  11. package/dist/coordination.d.ts +102 -0
  12. package/dist/coordination.d.ts.map +1 -0
  13. package/dist/coordination.js +157 -0
  14. package/dist/coordination.js.map +1 -0
  15. package/dist/index.d.ts +3 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +256 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/indexer.d.ts +83 -0
  20. package/dist/indexer.d.ts.map +1 -0
  21. package/dist/indexer.js +467 -0
  22. package/dist/indexer.js.map +1 -0
  23. package/dist/resources/agents-status.d.ts +32 -0
  24. package/dist/resources/agents-status.d.ts.map +1 -0
  25. package/dist/resources/agents-status.js +73 -0
  26. package/dist/resources/agents-status.js.map +1 -0
  27. package/dist/resources/decisions-log.d.ts +21 -0
  28. package/dist/resources/decisions-log.d.ts.map +1 -0
  29. package/dist/resources/decisions-log.js +146 -0
  30. package/dist/resources/decisions-log.js.map +1 -0
  31. package/dist/resources/index.d.ts +10 -0
  32. package/dist/resources/index.d.ts.map +1 -0
  33. package/dist/resources/index.js +74 -0
  34. package/dist/resources/index.js.map +1 -0
  35. package/dist/resources/plans-full.d.ts +11 -0
  36. package/dist/resources/plans-full.d.ts.map +1 -0
  37. package/dist/resources/plans-full.js +71 -0
  38. package/dist/resources/plans-full.js.map +1 -0
  39. package/dist/resources/plans-index.d.ts +30 -0
  40. package/dist/resources/plans-index.d.ts.map +1 -0
  41. package/dist/resources/plans-index.js +177 -0
  42. package/dist/resources/plans-index.js.map +1 -0
  43. package/dist/resources/plans-summary.d.ts +33 -0
  44. package/dist/resources/plans-summary.d.ts.map +1 -0
  45. package/dist/resources/plans-summary.js +238 -0
  46. package/dist/resources/plans-summary.js.map +1 -0
  47. package/dist/rlm/extractors.d.ts +39 -0
  48. package/dist/rlm/extractors.d.ts.map +1 -0
  49. package/dist/rlm/extractors.js +291 -0
  50. package/dist/rlm/extractors.js.map +1 -0
  51. package/dist/rlm/helpers-inject.d.ts +13 -0
  52. package/dist/rlm/helpers-inject.d.ts.map +1 -0
  53. package/dist/rlm/helpers-inject.js +586 -0
  54. package/dist/rlm/helpers-inject.js.map +1 -0
  55. package/dist/rlm/helpers.d.ts +124 -0
  56. package/dist/rlm/helpers.d.ts.map +1 -0
  57. package/dist/rlm/helpers.js +381 -0
  58. package/dist/rlm/helpers.js.map +1 -0
  59. package/dist/rlm/index.d.ts +12 -0
  60. package/dist/rlm/index.d.ts.map +1 -0
  61. package/dist/rlm/index.js +19 -0
  62. package/dist/rlm/index.js.map +1 -0
  63. package/dist/rlm/parallel.d.ts +45 -0
  64. package/dist/rlm/parallel.d.ts.map +1 -0
  65. package/dist/rlm/parallel.js +76 -0
  66. package/dist/rlm/parallel.js.map +1 -0
  67. package/dist/rlm/recursion.d.ts +96 -0
  68. package/dist/rlm/recursion.d.ts.map +1 -0
  69. package/dist/rlm/recursion.js +113 -0
  70. package/dist/rlm/recursion.js.map +1 -0
  71. package/dist/rlm/sampling.d.ts +100 -0
  72. package/dist/rlm/sampling.d.ts.map +1 -0
  73. package/dist/rlm/sampling.js +96 -0
  74. package/dist/rlm/sampling.js.map +1 -0
  75. package/dist/rlm/sandbox.d.ts +73 -0
  76. package/dist/rlm/sandbox.d.ts.map +1 -0
  77. package/dist/rlm/sandbox.js +160 -0
  78. package/dist/rlm/sandbox.js.map +1 -0
  79. package/dist/rlm/security.d.ts +28 -0
  80. package/dist/rlm/security.d.ts.map +1 -0
  81. package/dist/rlm/security.js +154 -0
  82. package/dist/rlm/security.js.map +1 -0
  83. package/dist/server.d.ts +21 -0
  84. package/dist/server.d.ts.map +1 -0
  85. package/dist/server.js +107 -0
  86. package/dist/server.js.map +1 -0
  87. package/dist/task-parser.d.ts +47 -0
  88. package/dist/task-parser.d.ts.map +1 -0
  89. package/dist/task-parser.js +112 -0
  90. package/dist/task-parser.js.map +1 -0
  91. package/dist/test-setup.d.ts +6 -0
  92. package/dist/test-setup.d.ts.map +1 -0
  93. package/dist/test-setup.js +37 -0
  94. package/dist/test-setup.js.map +1 -0
  95. package/dist/tools/claim-task.d.ts +28 -0
  96. package/dist/tools/claim-task.d.ts.map +1 -0
  97. package/dist/tools/claim-task.js +288 -0
  98. package/dist/tools/claim-task.js.map +1 -0
  99. package/dist/tools/create-doc.d.ts +47 -0
  100. package/dist/tools/create-doc.d.ts.map +1 -0
  101. package/dist/tools/create-doc.js +137 -0
  102. package/dist/tools/create-doc.js.map +1 -0
  103. package/dist/tools/create-plan.d.ts +25 -0
  104. package/dist/tools/create-plan.d.ts.map +1 -0
  105. package/dist/tools/create-plan.js +179 -0
  106. package/dist/tools/create-plan.js.map +1 -0
  107. package/dist/tools/delete-doc.d.ts +51 -0
  108. package/dist/tools/delete-doc.d.ts.map +1 -0
  109. package/dist/tools/delete-doc.js +194 -0
  110. package/dist/tools/delete-doc.js.map +1 -0
  111. package/dist/tools/get-next-task.d.ts +49 -0
  112. package/dist/tools/get-next-task.d.ts.map +1 -0
  113. package/dist/tools/get-next-task.js +204 -0
  114. package/dist/tools/get-next-task.js.map +1 -0
  115. package/dist/tools/index.d.ts +10 -0
  116. package/dist/tools/index.d.ts.map +1 -0
  117. package/dist/tools/index.js +122 -0
  118. package/dist/tools/index.js.map +1 -0
  119. package/dist/tools/list-docs.d.ts +53 -0
  120. package/dist/tools/list-docs.d.ts.map +1 -0
  121. package/dist/tools/list-docs.js +236 -0
  122. package/dist/tools/list-docs.js.map +1 -0
  123. package/dist/tools/open-document-in-cursor.d.ts +62 -0
  124. package/dist/tools/open-document-in-cursor.d.ts.map +1 -0
  125. package/dist/tools/open-document-in-cursor.js +211 -0
  126. package/dist/tools/open-document-in-cursor.js.map +1 -0
  127. package/dist/tools/read-doc.d.ts +44 -0
  128. package/dist/tools/read-doc.d.ts.map +1 -0
  129. package/dist/tools/read-doc.js +174 -0
  130. package/dist/tools/read-doc.js.map +1 -0
  131. package/dist/tools/release-task.d.ts +28 -0
  132. package/dist/tools/release-task.d.ts.map +1 -0
  133. package/dist/tools/release-task.js +154 -0
  134. package/dist/tools/release-task.js.map +1 -0
  135. package/dist/tools/rlm-multi-query.d.ts +110 -0
  136. package/dist/tools/rlm-multi-query.d.ts.map +1 -0
  137. package/dist/tools/rlm-multi-query.js +348 -0
  138. package/dist/tools/rlm-multi-query.js.map +1 -0
  139. package/dist/tools/rlm-query.d.ts +56 -0
  140. package/dist/tools/rlm-query.d.ts.map +1 -0
  141. package/dist/tools/rlm-query.js +228 -0
  142. package/dist/tools/rlm-query.js.map +1 -0
  143. package/dist/tools/search-docs.d.ts +34 -0
  144. package/dist/tools/search-docs.d.ts.map +1 -0
  145. package/dist/tools/search-docs.js +292 -0
  146. package/dist/tools/search-docs.js.map +1 -0
  147. package/dist/tools/update-doc.d.ts +149 -0
  148. package/dist/tools/update-doc.d.ts.map +1 -0
  149. package/dist/tools/update-doc.js +195 -0
  150. package/dist/tools/update-doc.js.map +1 -0
  151. package/dist/tools/update-task-status.d.ts +31 -0
  152. package/dist/tools/update-task-status.d.ts.map +1 -0
  153. package/dist/tools/update-task-status.js +303 -0
  154. package/dist/tools/update-task-status.js.map +1 -0
  155. package/dist/types.d.ts +50 -0
  156. package/dist/types.d.ts.map +1 -0
  157. package/dist/types.js +2 -0
  158. package/dist/types.js.map +1 -0
  159. package/dist/utils/backup.d.ts +76 -0
  160. package/dist/utils/backup.d.ts.map +1 -0
  161. package/dist/utils/backup.js +172 -0
  162. package/dist/utils/backup.js.map +1 -0
  163. package/dist/utils/errors.d.ts +93 -0
  164. package/dist/utils/errors.d.ts.map +1 -0
  165. package/dist/utils/errors.js +125 -0
  166. package/dist/utils/errors.js.map +1 -0
  167. package/dist/utils/index.d.ts +8 -0
  168. package/dist/utils/index.d.ts.map +1 -0
  169. package/dist/utils/index.js +9 -0
  170. package/dist/utils/index.js.map +1 -0
  171. package/dist/utils/os-paths.d.ts +45 -0
  172. package/dist/utils/os-paths.d.ts.map +1 -0
  173. package/dist/utils/os-paths.js +81 -0
  174. package/dist/utils/os-paths.js.map +1 -0
  175. package/dist/utils/paths.d.ts +71 -0
  176. package/dist/utils/paths.d.ts.map +1 -0
  177. package/dist/utils/paths.js +165 -0
  178. package/dist/utils/paths.js.map +1 -0
  179. package/dist/watcher.d.ts +19 -0
  180. package/dist/watcher.d.ts.map +1 -0
  181. package/dist/watcher.js +109 -0
  182. package/dist/watcher.js.map +1 -0
  183. package/package.json +85 -0
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Task handoff contract for sequential review workflows.
3
+ */
4
+ export interface TaskHandoff {
5
+ fromAgent: string;
6
+ toPersona: 'reviewer' | 'pm' | 'customer';
7
+ task: {
8
+ id: string;
9
+ filesModified: string[];
10
+ summary: string;
11
+ testsAdded: number;
12
+ };
13
+ reviewCriteria: {
14
+ type: 'code_quality' | 'security' | 'ux' | 'requirements';
15
+ required: boolean;
16
+ }[];
17
+ iterationCount: number;
18
+ maxIterations: number;
19
+ }
20
+ /**
21
+ * Coordination state for multi-agent orchestration.
22
+ */
23
+ export interface CoordinationState {
24
+ version: number;
25
+ agents: Record<string, AgentState>;
26
+ tasks: Record<string, TaskState>;
27
+ fileLocks: Record<string, string>;
28
+ handoffs?: Record<string, TaskHandoff>;
29
+ }
30
+ /**
31
+ * Agent state tracking.
32
+ */
33
+ export interface AgentState {
34
+ status: 'idle' | 'WIP';
35
+ persona: 'coder' | 'reviewer' | 'pm' | 'customer';
36
+ taskId?: string;
37
+ filesLocked: string[];
38
+ heartbeat: string;
39
+ }
40
+ /**
41
+ * Task state tracking.
42
+ */
43
+ export interface TaskState {
44
+ status: 'GAP' | 'WIP' | 'PASS' | 'BLOCKED';
45
+ claimedBy?: string;
46
+ dependencies: string[];
47
+ }
48
+ /**
49
+ * Read coordination state from file.
50
+ * Creates default state if file doesn't exist.
51
+ *
52
+ * @param path - Path to coordination.json file
53
+ * @returns Coordination state
54
+ */
55
+ export declare function readCoordination(path: string): Promise<CoordinationState>;
56
+ /**
57
+ * Write coordination state to file with optimistic concurrency control.
58
+ * Uses atomic write (temp file + rename) to prevent corruption.
59
+ *
60
+ * @param path - Path to coordination.json file
61
+ * @param state - Coordination state to write
62
+ * @param expectedVersion - Expected version number (for optimistic concurrency)
63
+ * @throws Error if expectedVersion doesn't match current version
64
+ */
65
+ export declare function writeCoordination(path: string, state: CoordinationState, expectedVersion: number): Promise<void>;
66
+ /**
67
+ * Create a task handoff contract.
68
+ *
69
+ * @param fromAgent - Agent ID creating the handoff
70
+ * @param toPersona - Target persona type
71
+ * @param task - Task information
72
+ * @param criteria - Review criteria
73
+ * @param maxIterations - Maximum iterations before escalation (typically from config.maxHandoffIterations)
74
+ * @returns Task handoff contract
75
+ */
76
+ export declare function createHandoff(fromAgent: string, toPersona: string, task: TaskHandoff['task'], criteria: TaskHandoff['reviewCriteria'], maxIterations?: number): TaskHandoff;
77
+ /**
78
+ * Accept a handoff and store it in coordination state.
79
+ * Updates coordination state to link handoff to task.
80
+ * Note: Interface shows void return, but implementation returns updated state
81
+ * for functional/immutable pattern. Caller should write coordination state.
82
+ *
83
+ * @param coordination - Coordination state to update
84
+ * @param handoff - Handoff to accept
85
+ * @param _agentId - Agent ID accepting the handoff
86
+ * @returns Updated coordination state (caller should write to file)
87
+ */
88
+ export declare function acceptHandoff(coordination: CoordinationState, handoff: TaskHandoff, _agentId: string): CoordinationState;
89
+ /**
90
+ * Reject a handoff with feedback and determine escalation.
91
+ * Increments iteration count and checks if escalation is needed.
92
+ *
93
+ * @param handoff - Handoff to reject
94
+ * @param _feedback - Rejection feedback (for future use - could be stored in handoff or separate store)
95
+ * @returns Escalation decision and new status (includes updatedHandoff for convenience)
96
+ */
97
+ export declare function rejectHandoff(handoff: TaskHandoff, _feedback: string): {
98
+ shouldEscalate: boolean;
99
+ newStatus: 'WIP' | 'BLOCKED';
100
+ updatedHandoff: TaskHandoff;
101
+ };
102
+ //# sourceMappingURL=coordination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordination.d.ts","sourceRoot":"","sources":["../src/coordination.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,UAAU,GAAG,IAAI,GAAG,UAAU,CAAC;IAC1C,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,aAAa,EAAE,MAAM,EAAE,CAAC;QACxB,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,cAAc,EAAE;QACd,IAAI,EAAE,cAAc,GAAG,UAAU,GAAG,IAAI,GAAG,cAAc,CAAC;QAC1D,QAAQ,EAAE,OAAO,CAAC;KACnB,EAAE,CAAC;IACJ,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC;IACvB,OAAO,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,GAAG,UAAU,CAAC;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAiD/E;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,iBAAiB,EACxB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,IAAI,CAAC,CAyBf;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,EACzB,QAAQ,EAAE,WAAW,CAAC,gBAAgB,CAAC,EACvC,aAAa,SAAI,GAChB,WAAW,CAcb;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC3B,YAAY,EAAE,iBAAiB,EAC/B,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,MAAM,GACf,iBAAiB,CAUnB;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,MAAM,GAChB;IAAE,cAAc,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,KAAK,GAAG,SAAS,CAAC;IAAC,cAAc,EAAE,WAAW,CAAA;CAAE,CAiBxF"}
@@ -0,0 +1,157 @@
1
+ import { readFileSync, writeFileSync, existsSync, renameSync, mkdirSync, unlinkSync } from 'fs';
2
+ import { dirname } from 'path';
3
+ /**
4
+ * Read coordination state from file.
5
+ * Creates default state if file doesn't exist.
6
+ *
7
+ * @param path - Path to coordination.json file
8
+ * @returns Coordination state
9
+ */
10
+ export async function readCoordination(path) {
11
+ if (!existsSync(path)) {
12
+ const defaultState = {
13
+ version: 1,
14
+ agents: {},
15
+ tasks: {},
16
+ fileLocks: {},
17
+ handoffs: {},
18
+ };
19
+ // Ensure directory exists
20
+ mkdirSync(dirname(path), { recursive: true });
21
+ writeFileSync(path, JSON.stringify(defaultState, null, 2), 'utf-8');
22
+ return defaultState;
23
+ }
24
+ try {
25
+ const content = readFileSync(path, 'utf-8');
26
+ const state = JSON.parse(content);
27
+ // Validate structure
28
+ if (typeof state.version !== 'number' || !state.agents || !state.tasks || !state.fileLocks) {
29
+ // Return default state if structure is invalid
30
+ const defaultState = {
31
+ version: 1,
32
+ agents: {},
33
+ tasks: {},
34
+ fileLocks: {},
35
+ handoffs: {},
36
+ };
37
+ return defaultState;
38
+ }
39
+ // Ensure handoffs exists (for backward compatibility)
40
+ if (!state.handoffs) {
41
+ state.handoffs = {};
42
+ }
43
+ return state;
44
+ }
45
+ catch (_error) {
46
+ // Handle malformed JSON gracefully
47
+ const defaultState = {
48
+ version: 1,
49
+ agents: {},
50
+ tasks: {},
51
+ fileLocks: {},
52
+ handoffs: {},
53
+ };
54
+ return defaultState;
55
+ }
56
+ }
57
+ /**
58
+ * Write coordination state to file with optimistic concurrency control.
59
+ * Uses atomic write (temp file + rename) to prevent corruption.
60
+ *
61
+ * @param path - Path to coordination.json file
62
+ * @param state - Coordination state to write
63
+ * @param expectedVersion - Expected version number (for optimistic concurrency)
64
+ * @throws Error if expectedVersion doesn't match current version
65
+ */
66
+ export async function writeCoordination(path, state, expectedVersion) {
67
+ // Ensure directory exists
68
+ mkdirSync(dirname(path), { recursive: true });
69
+ // Read current state to check version
70
+ const currentState = await readCoordination(path);
71
+ if (currentState.version !== expectedVersion) {
72
+ throw new Error(`Version mismatch: expected ${expectedVersion}, got ${currentState.version}`);
73
+ }
74
+ // Atomic write: write to temp file, then rename
75
+ const tempPath = `${path}.tmp`;
76
+ try {
77
+ writeFileSync(tempPath, JSON.stringify(state, null, 2), 'utf-8');
78
+ // Rename is atomic on most filesystems
79
+ renameSync(tempPath, path);
80
+ }
81
+ catch (error) {
82
+ // Clean up temp file on error
83
+ if (existsSync(tempPath)) {
84
+ unlinkSync(tempPath);
85
+ }
86
+ throw error;
87
+ }
88
+ }
89
+ /**
90
+ * Create a task handoff contract.
91
+ *
92
+ * @param fromAgent - Agent ID creating the handoff
93
+ * @param toPersona - Target persona type
94
+ * @param task - Task information
95
+ * @param criteria - Review criteria
96
+ * @param maxIterations - Maximum iterations before escalation (typically from config.maxHandoffIterations)
97
+ * @returns Task handoff contract
98
+ */
99
+ export function createHandoff(fromAgent, toPersona, task, criteria, maxIterations = 3) {
100
+ // Validate toPersona matches expected type
101
+ if (!['reviewer', 'pm', 'customer'].includes(toPersona)) {
102
+ throw new Error(`Invalid toPersona: ${toPersona}. Must be 'reviewer', 'pm', or 'customer'`);
103
+ }
104
+ return {
105
+ fromAgent,
106
+ toPersona: toPersona,
107
+ task,
108
+ reviewCriteria: criteria,
109
+ iterationCount: 0,
110
+ maxIterations,
111
+ };
112
+ }
113
+ /**
114
+ * Accept a handoff and store it in coordination state.
115
+ * Updates coordination state to link handoff to task.
116
+ * Note: Interface shows void return, but implementation returns updated state
117
+ * for functional/immutable pattern. Caller should write coordination state.
118
+ *
119
+ * @param coordination - Coordination state to update
120
+ * @param handoff - Handoff to accept
121
+ * @param _agentId - Agent ID accepting the handoff
122
+ * @returns Updated coordination state (caller should write to file)
123
+ */
124
+ export function acceptHandoff(coordination, handoff, _agentId) {
125
+ const handoffs = coordination.handoffs || {};
126
+ return {
127
+ ...coordination,
128
+ handoffs: {
129
+ ...handoffs,
130
+ [handoff.task.id]: handoff,
131
+ },
132
+ };
133
+ }
134
+ /**
135
+ * Reject a handoff with feedback and determine escalation.
136
+ * Increments iteration count and checks if escalation is needed.
137
+ *
138
+ * @param handoff - Handoff to reject
139
+ * @param _feedback - Rejection feedback (for future use - could be stored in handoff or separate store)
140
+ * @returns Escalation decision and new status (includes updatedHandoff for convenience)
141
+ */
142
+ export function rejectHandoff(handoff, _feedback) {
143
+ const newIterationCount = handoff.iterationCount + 1;
144
+ const shouldEscalate = newIterationCount >= handoff.maxIterations;
145
+ const updatedHandoff = {
146
+ ...handoff,
147
+ iterationCount: newIterationCount,
148
+ };
149
+ // Store feedback in handoff (extend interface if needed, or use a separate feedback store)
150
+ // For now, we'll return the decision and let the caller handle feedback storage
151
+ return {
152
+ shouldEscalate,
153
+ newStatus: shouldEscalate ? 'BLOCKED' : 'WIP',
154
+ updatedHandoff,
155
+ };
156
+ }
157
+ //# sourceMappingURL=coordination.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordination.js","sourceRoot":"","sources":["../src/coordination.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChG,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAqD/B;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAAY;IACjD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,MAAM,YAAY,GAAsB;YACtC,OAAO,EAAE,CAAC;YACV,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,EAAE;YACT,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,EAAE;SACb,CAAC;QACF,0BAA0B;QAC1B,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9C,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QACpE,OAAO,YAAY,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L,GAAG,YAAY;QACf,QAAQ,EAAE;YACR,GAAG,QAAQ;YACX,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,OAAO;SAC3B;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAC3B,OAAoB,EACpB,SAAiB;IAEjB,MAAM,iBAAiB,GAAG,OAAO,CAAC,cAAc,GAAG,CAAC,CAAC;IACrD,MAAM,cAAc,GAAG,iBAAiB,IAAI,OAAO,CAAC,aAAa,CAAC;IAElE,MAAM,cAAc,GAAgB;QAClC,GAAG,OAAO;QACV,cAAc,EAAE,iBAAiB;KAClC,CAAC;IAEF,2FAA2F;IAC3F,gFAAgF;IAEhF,OAAO;QACL,cAAc;QACd,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK;QAC7C,cAAc;KACf,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,256 @@
1
+ #!/usr/bin/env node
2
+ import { loadConfig, getAllDocsPaths, getFileExtensions } from './config.js';
3
+ import { createServer, startServer } from './server.js';
4
+ import { resolve, dirname } from 'path';
5
+ import { fileURLToPath } from 'url';
6
+ import { mkdirSync, existsSync, writeFileSync } from 'fs';
7
+ import { homedir } from 'os';
8
+ import which from 'which';
9
+ /**
10
+ * Expand tilde in path to full home directory path.
11
+ */
12
+ function expandTilde(path) {
13
+ if (path.startsWith('~/')) {
14
+ return resolve(homedir(), path.slice(2));
15
+ }
16
+ return resolve(path);
17
+ }
18
+ import { initializeDatabase, createSchema, indexAllPaths, indexDocument, removeDocument, } from './indexer.js';
19
+ import { startWatcher, stopWatcher } from './watcher.js';
20
+ import { readCoordination } from './coordination.js';
21
+ import { getOSConfigPath, getOSBasePath, getOSDataPath, getOSCoordinationPath, } from './utils/os-paths.js';
22
+ // Global references for graceful shutdown
23
+ let watcher = null;
24
+ let db = null;
25
+ /**
26
+ * Parse command line arguments.
27
+ *
28
+ * Supports:
29
+ * - limps (start server with default config)
30
+ * - limps --config <path> (start server with custom config)
31
+ * - limps init <project-name> [--docs-path <path>] (initialize new project)
32
+ *
33
+ * @returns Parsed arguments
34
+ */
35
+ function parseArgs() {
36
+ const args = process.argv.slice(2);
37
+ // Check for init command
38
+ if (args[0] === 'init') {
39
+ const projectName = args[1];
40
+ const docsPathIndex = args.indexOf('--docs-path');
41
+ const docsPath = docsPathIndex !== -1 ? args[docsPathIndex + 1] : undefined;
42
+ return { command: 'init', projectName, docsPath };
43
+ }
44
+ // Check for --config flag
45
+ const configIndex = args.indexOf('--config');
46
+ if (configIndex !== -1 && args[configIndex + 1]) {
47
+ return { configPath: args[configIndex + 1] };
48
+ }
49
+ return {};
50
+ }
51
+ /**
52
+ * Get the full path to the limps executable.
53
+ * Falls back to 'limps' if not found in PATH.
54
+ */
55
+ function getLocalPlannerPath() {
56
+ try {
57
+ return which.sync('limps');
58
+ }
59
+ catch {
60
+ // Fallback to command name if not in PATH
61
+ return 'limps';
62
+ }
63
+ }
64
+ /**
65
+ * Initialize a new project configuration.
66
+ *
67
+ * @param projectName - Name of the project (e.g., "runi-planning")
68
+ * @param docsPath - Optional path to documentation directory
69
+ */
70
+ function initProject(projectName, docsPath) {
71
+ const basePath = getOSBasePath(projectName);
72
+ const configPath = getOSConfigPath(projectName);
73
+ const dataPath = getOSDataPath(projectName);
74
+ const coordinationPath = getOSCoordinationPath(projectName);
75
+ // Expand tilde in docsPath if provided
76
+ const resolvedDocsPath = docsPath ? expandTilde(docsPath) : null;
77
+ const defaultDocsPath = resolve(homedir(), 'Documents', projectName);
78
+ // Create directory
79
+ mkdirSync(basePath, { recursive: true });
80
+ // Check if config already exists
81
+ if (existsSync(configPath)) {
82
+ console.log(`Config already exists at: ${configPath}`);
83
+ console.log('To reconfigure, delete the existing config file first.');
84
+ process.exit(1);
85
+ }
86
+ // Create default config with absolute paths
87
+ const config = {
88
+ plansPath: resolvedDocsPath ? resolve(resolvedDocsPath, 'plans') : resolve(defaultDocsPath, 'plans'),
89
+ docsPaths: [resolvedDocsPath || defaultDocsPath],
90
+ fileExtensions: ['.md'],
91
+ dataPath: dataPath,
92
+ coordinationPath: coordinationPath,
93
+ heartbeatTimeout: 300000,
94
+ debounceDelay: 200,
95
+ maxHandoffIterations: 3,
96
+ };
97
+ writeFileSync(configPath, JSON.stringify(config, null, 2));
98
+ // Get the full path to limps executable
99
+ const localPlannerPath = getLocalPlannerPath();
100
+ console.log(`\n✓ Created ${projectName} configuration\n`);
101
+ console.log(`Config: ${configPath}`);
102
+ console.log(`Data: ${dataPath}`);
103
+ console.log('');
104
+ // Output Cursor settings snippet
105
+ console.log('Add this to your Cursor settings (Cmd+Shift+P → "Preferences: Open User Settings (JSON)"):\n');
106
+ console.log(JSON.stringify({
107
+ 'mcp.servers': {
108
+ [projectName]: {
109
+ command: localPlannerPath,
110
+ args: ['--config', configPath],
111
+ },
112
+ },
113
+ }, null, 2));
114
+ console.log('');
115
+ // Output Claude Desktop config snippet
116
+ console.log('For Claude Desktop, add this to ~/Library/Application Support/Claude/claude_desktop_config.json:\n');
117
+ console.log(JSON.stringify({
118
+ mcpServers: {
119
+ [projectName]: {
120
+ command: localPlannerPath,
121
+ args: ['--config', configPath],
122
+ },
123
+ },
124
+ }, null, 2));
125
+ console.log('');
126
+ // Test command
127
+ console.log('To test the server:');
128
+ console.log(` ${localPlannerPath} --config "${configPath}"`);
129
+ }
130
+ /**
131
+ * Resolve configuration file path with priority:
132
+ * 1. CLI argument --config
133
+ * 2. Environment variable MCP_PLANNING_CONFIG
134
+ * 3. OS-specific default path
135
+ *
136
+ * Falls back to repo-local config.json if no config exists at determined path.
137
+ *
138
+ * @param cliConfigPath - Config path from CLI argument (if provided)
139
+ * @returns Resolved absolute path to config file
140
+ */
141
+ function resolveConfigPath(cliConfigPath) {
142
+ // Priority 1: CLI argument
143
+ if (cliConfigPath) {
144
+ return resolve(cliConfigPath);
145
+ }
146
+ // Priority 2: Environment variable
147
+ const envConfigPath = process.env.MCP_PLANNING_CONFIG;
148
+ if (envConfigPath) {
149
+ return resolve(envConfigPath);
150
+ }
151
+ // Priority 3: OS-specific default
152
+ const osConfigPath = getOSConfigPath();
153
+ if (existsSync(osConfigPath)) {
154
+ return osConfigPath;
155
+ }
156
+ // Fallback: repo-local config.json (for development/backwards compatibility)
157
+ const currentFile = fileURLToPath(import.meta.url);
158
+ const currentDir = dirname(currentFile);
159
+ const srcDir = dirname(currentDir);
160
+ const repoRoot = dirname(srcDir);
161
+ const repoConfigPath = resolve(repoRoot, 'config.json');
162
+ // If neither OS config nor repo config exists, use OS path (will be created)
163
+ if (existsSync(repoConfigPath)) {
164
+ return repoConfigPath;
165
+ }
166
+ return osConfigPath;
167
+ }
168
+ /**
169
+ * Entry point for the MCP Planning Server.
170
+ * Loads configuration and starts the server.
171
+ */
172
+ async function main() {
173
+ try {
174
+ // Parse CLI arguments
175
+ const args = parseArgs();
176
+ // Handle init command
177
+ if (args.command === 'init') {
178
+ if (!args.projectName) {
179
+ console.error('Usage: limps init <project-name> [--docs-path <path>]');
180
+ console.error('');
181
+ console.error('Example:');
182
+ console.error(' limps init my-project --docs-path ~/Documents/my-project');
183
+ process.exit(1);
184
+ }
185
+ initProject(args.projectName, args.docsPath);
186
+ return;
187
+ }
188
+ // Resolve config path for server mode
189
+ const configPath = resolveConfigPath(args.configPath);
190
+ // Load configuration
191
+ const config = loadConfig(configPath);
192
+ // Ensure data directory exists
193
+ mkdirSync(config.dataPath, { recursive: true });
194
+ // Initialize database
195
+ const dbPath = resolve(config.dataPath, 'documents.sqlite');
196
+ db = initializeDatabase(dbPath);
197
+ createSchema(db);
198
+ console.error(`Database initialized at ${dbPath}`);
199
+ // Load coordination state
200
+ const coordination = await readCoordination(config.coordinationPath);
201
+ console.error(`Coordination state loaded from ${config.coordinationPath}`);
202
+ // Get all paths and extensions to index
203
+ const docsPaths = getAllDocsPaths(config);
204
+ const fileExtensions = getFileExtensions(config);
205
+ const ignorePatterns = ['.git', 'node_modules', '.tmp'];
206
+ // Initial indexing (#19)
207
+ const result = await indexAllPaths(db, docsPaths, fileExtensions, ignorePatterns);
208
+ console.error(`Indexed ${result.indexed} documents (${result.updated} updated, ${result.skipped} skipped)`);
209
+ console.error(`Paths: ${docsPaths.join(', ')}`);
210
+ console.error(`Extensions: ${fileExtensions.join(', ')}`);
211
+ if (result.errors.length > 0) {
212
+ console.error(`Indexing errors: ${result.errors.length}`);
213
+ for (const err of result.errors) {
214
+ console.error(` - ${err.path}: ${err.error}`);
215
+ }
216
+ }
217
+ // Capture db reference for watcher callback
218
+ const dbRef = db;
219
+ // Start file watcher (#4)
220
+ watcher = startWatcher(docsPaths, async (path, event) => {
221
+ if (event === 'unlink') {
222
+ await removeDocument(dbRef, path);
223
+ console.error(`Removed document: ${path}`);
224
+ }
225
+ else {
226
+ await indexDocument(dbRef, path);
227
+ console.error(`Indexed document: ${path} (${event})`);
228
+ }
229
+ }, fileExtensions, ignorePatterns, config.debounceDelay);
230
+ console.error(`File watcher started for ${docsPaths.length} path(s)`);
231
+ // Create and start server (pass db and coordination for tools)
232
+ const server = createServer(config, db, coordination);
233
+ await startServer(server, async () => {
234
+ // Graceful shutdown callback
235
+ if (watcher) {
236
+ await stopWatcher(watcher);
237
+ console.error('File watcher stopped');
238
+ watcher = null;
239
+ }
240
+ if (db) {
241
+ db.close();
242
+ console.error('Database connection closed');
243
+ db = null;
244
+ }
245
+ });
246
+ }
247
+ catch (error) {
248
+ console.error('Fatal error in main():', error);
249
+ process.exit(1);
250
+ }
251
+ }
252
+ main().catch((error) => {
253
+ console.error('Unhandled error in main():', error);
254
+ process.exit(1);
255
+ });
256
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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ACtC,OAAO,GAAG,IAAI,CAAC;YACjB,CAAC;YACD,IAAI,EAAE,EAAE,CAAC;gBACP,EAAE,CAAC,KAAK,EAAE,CAAC;gBACX,OAAO,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;gBAC5C,EAAE,GAAG,IAAI,CAAC;YACZ,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;IACnD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,83 @@
1
+ import { type Database as DatabaseType } from 'better-sqlite3';
2
+ /**
3
+ * Document metadata interface.
4
+ */
5
+ export interface DocumentMetadata {
6
+ path: string;
7
+ title: string;
8
+ content: string;
9
+ summary?: string;
10
+ status?: 'GAP' | 'WIP' | 'PASS' | 'BLOCKED' | 'MISSING';
11
+ dependencies?: string[];
12
+ modifiedAt: number;
13
+ hash: string;
14
+ }
15
+ /**
16
+ * Indexing result interface for batch operations.
17
+ */
18
+ export interface IndexingResult {
19
+ indexed: number;
20
+ updated: number;
21
+ skipped: number;
22
+ errors: {
23
+ path: string;
24
+ error: string;
25
+ }[];
26
+ }
27
+ /**
28
+ * Initialize a SQLite database at the given path.
29
+ * Creates the database file if it doesn't exist.
30
+ *
31
+ * @param dbPath - Path to the SQLite database file
32
+ * @returns Database instance
33
+ */
34
+ export declare function initializeDatabase(dbPath: string): DatabaseType;
35
+ /**
36
+ * Create the database schema including documents table and FTS5 virtual table.
37
+ * Must be called after initializeDatabase.
38
+ *
39
+ * @param db - Database instance
40
+ */
41
+ export declare function createSchema(db: DatabaseType): void;
42
+ /**
43
+ * Index a single document into the database.
44
+ *
45
+ * @param db - Database instance
46
+ * @param filePath - Path to the markdown file
47
+ * @returns Document metadata
48
+ */
49
+ export declare function indexDocument(db: DatabaseType, filePath: string): Promise<DocumentMetadata>;
50
+ /**
51
+ * Update document index in database and FTS5.
52
+ *
53
+ * @param db - Database instance
54
+ * @param metadata - Document metadata
55
+ */
56
+ export declare function updateDocumentIndex(db: DatabaseType, metadata: DocumentMetadata): Promise<void>;
57
+ /**
58
+ * Remove document from database and FTS5 index.
59
+ *
60
+ * @param db - Database instance
61
+ * @param filePath - Path to the document
62
+ */
63
+ export declare function removeDocument(db: DatabaseType, filePath: string): Promise<void>;
64
+ /**
65
+ * Index all documents in a directory.
66
+ *
67
+ * @param db - Database instance
68
+ * @param plansPath - Path to the plans directory
69
+ * @param ignorePatterns - Patterns to ignore (e.g., ['node_modules', '.git'])
70
+ * @returns Indexing result
71
+ */
72
+ export declare function indexAllDocuments(db: DatabaseType, plansPath: string, ignorePatterns?: string[]): Promise<IndexingResult>;
73
+ /**
74
+ * Index all documents from multiple paths with configurable file extensions.
75
+ *
76
+ * @param db - Database instance
77
+ * @param paths - Array of paths to index
78
+ * @param extensions - File extensions to index (e.g., ['.md', '.jsx', '.tsx'])
79
+ * @param ignorePatterns - Patterns to ignore (e.g., ['node_modules', '.git'])
80
+ * @returns Combined indexing result
81
+ */
82
+ export declare function indexAllPaths(db: DatabaseType, paths: string[], extensions?: string[], ignorePatterns?: string[]): Promise<IndexingResult>;
83
+ //# sourceMappingURL=indexer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexer.d.ts","sourceRoot":"","sources":["../src/indexer.ts"],"names":[],"mappings":"AAAA,OAAiB,EAAE,KAAK,QAAQ,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAKzE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,C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