MCPcopy Create free account
hub / github.com/scopecraft/command / parseTaskPath

Method parseTaskPath

src/core/project-config.ts:253–289  ·  view source on GitHub ↗

* Parse task path to extract phase and subdirectory * @deprecated Use directory-utils.parseTaskPath instead

(filePath: string)

Source from the content-addressed store, hash-verified

251 * @deprecated Use directory-utils.parseTaskPath instead
252 */
253 parseTaskPath(filePath: string): { phase?: string; subdirectory?: string } {
254 const tasksRoot = this.paths.tasksRoot;
255
256 // Ensure we're working with absolute paths
257 const absoluteFilePath = path.resolve(filePath);
258 const absoluteTasksRoot = path.resolve(tasksRoot);
259
260 // Check if the file is actually under the tasks root
261 if (!absoluteFilePath.startsWith(absoluteTasksRoot)) {
262 return {};
263 }
264
265 // Get the relative path from tasks root
266 const relativePath = path.relative(absoluteTasksRoot, absoluteFilePath);
267 const parts = relativePath.split(path.sep);
268
269 // Skip dot-prefix directories (system dirs)
270 if (parts.length > 0 && parts[0].startsWith('.')) {
271 return {};
272 }
273
274 if (parts.length === 1) {
275 // Only filename, no phase or subdirectory
276 return {};
277 }
278
279 if (parts.length === 2) {
280 // phase/filename - has phase but no subdirectory
281 return { phase: parts[0] };
282 }
283
284 // Has both phase and subdirectory (or more levels)
285 const phase = parts[0];
286 // Combine all middle directories as the subdirectory path
287 const subdirectory = parts.slice(1, -1).join(path.sep);
288 return { phase, subdirectory };
289 }
290}
291
292// Export a singleton instance (for backward compatibility)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected