@e0ipso/ai-task-manager 1.0.1

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.
@@ -0,0 +1,210 @@
1
+ /**
2
+ * Helper Functions for File Operations
3
+ *
4
+ * This file contains utility functions for file system operations,
5
+ * path manipulation, and other common tasks used by the CLI
6
+ */
7
+ import { Assistant, TemplateFormat } from './types';
8
+ /**
9
+ * Create a directory recursively if it doesn't exist
10
+ * @param dirPath - The directory path to create
11
+ * @throws FileSystemError if directory creation fails
12
+ */
13
+ export declare function ensureDir(dirPath: string): Promise<void>;
14
+ /**
15
+ * Check if a directory exists
16
+ * @param dirPath - The directory path to check
17
+ * @returns Promise<boolean> - True if directory exists, false otherwise
18
+ */
19
+ export declare function directoryExists(dirPath: string): Promise<boolean>;
20
+ /**
21
+ * Check if a file exists
22
+ * @param filePath - The file path to check
23
+ * @returns Promise<boolean> - True if file exists, false otherwise
24
+ */
25
+ export declare function fileExists(filePath: string): Promise<boolean>;
26
+ /**
27
+ * Check if a file or directory exists (generic)
28
+ * @param filepath - The path to check
29
+ * @returns Promise<boolean> - True if path exists, false otherwise
30
+ */
31
+ export declare function exists(filepath: string): Promise<boolean>;
32
+ /**
33
+ * Copy a file or directory from source to destination
34
+ * @param src - Source path (file or directory)
35
+ * @param dest - Destination path
36
+ * @param options - Copy options
37
+ * @throws FileSystemError if copy operation fails
38
+ */
39
+ export declare function copyTemplate(src: string, dest: string, options?: {
40
+ overwrite?: boolean;
41
+ }): Promise<void>;
42
+ /**
43
+ * Write JSON data to a file with proper formatting
44
+ * @param filePath - The file path to write to
45
+ * @param data - The data to write as JSON
46
+ * @throws FileSystemError if write operation fails
47
+ */
48
+ export declare function writeJsonFile(filePath: string, data: unknown): Promise<void>;
49
+ /**
50
+ * Read and parse a JSON file
51
+ * @param filePath - The file path to read from
52
+ * @returns The parsed JSON data
53
+ * @throws FileSystemError if read operation fails
54
+ */
55
+ export declare function readJsonFile<T = unknown>(filePath: string): Promise<T>;
56
+ /**
57
+ * Parse comma-separated assistant values into an array
58
+ * @param value - Comma-separated string of assistant names
59
+ * @returns Array of assistant names
60
+ * @throws Error if invalid assistant names are provided
61
+ */
62
+ export declare function parseAssistants(value: string): Assistant[];
63
+ /**
64
+ * Validate that all assistants are supported
65
+ * @param assistants - Array of assistants to validate
66
+ * @throws Error if any assistant is invalid or array is empty
67
+ */
68
+ export declare function validateAssistants(assistants: Assistant[]): void;
69
+ /**
70
+ * Get the absolute path for a given path, resolving it relative to the current working directory
71
+ * @param inputPath - The input path (can be relative or absolute)
72
+ * @returns The absolute path
73
+ */
74
+ export declare function getAbsolutePath(inputPath: string): string;
75
+ /**
76
+ * Get the relative path from one path to another
77
+ * @param from - The source path
78
+ * @param to - The target path
79
+ * @returns The relative path
80
+ */
81
+ export declare function getRelativePath(from: string, to: string): string;
82
+ /**
83
+ * Join multiple path segments into a single path
84
+ * @param segments - Path segments to join
85
+ * @returns The joined path
86
+ */
87
+ export declare function joinPath(...segments: string[]): string;
88
+ /**
89
+ * Get the directory name from a file path
90
+ * @param filePath - The file path
91
+ * @returns The directory name
92
+ */
93
+ export declare function getDirName(filePath: string): string;
94
+ /**
95
+ * Get the base name (filename) from a file path
96
+ * @param filePath - The file path
97
+ * @param ext - Optional extension to remove
98
+ * @returns The base name
99
+ */
100
+ export declare function getBaseName(filePath: string, ext?: string): string;
101
+ /**
102
+ * Get the file extension from a file path
103
+ * @param filePath - The file path
104
+ * @returns The file extension (including the dot)
105
+ */
106
+ export declare function getExtension(filePath: string): string;
107
+ /**
108
+ * Get the template format for a specific assistant
109
+ * @param assistant - The assistant type
110
+ * @returns The template format to use ('md' for Claude, 'toml' for Gemini)
111
+ */
112
+ export declare function getTemplateFormat(assistant: Assistant): TemplateFormat;
113
+ /**
114
+ * Get the absolute path to a template file
115
+ * @param templateFile - The template filename
116
+ * @returns The absolute path to the template
117
+ */
118
+ export declare function getTemplatePath(templateFile: string): string;
119
+ /**
120
+ * Get list of directories that will be created for given assistants
121
+ * @param assistants - Array of assistants
122
+ * @param baseDir - Base directory to resolve paths against (defaults to current directory)
123
+ * @returns Array of directory paths to create
124
+ */
125
+ export declare function getCreatedDirectories(assistants: Assistant[], baseDir?: string): string[];
126
+ /**
127
+ * Ensure a directory path ends with a path separator
128
+ * @param dirPath - The directory path
129
+ * @returns The directory path with trailing separator
130
+ */
131
+ export declare function ensureTrailingSlash(dirPath: string): string;
132
+ /**
133
+ * Create a safe filename by removing or replacing invalid characters
134
+ * @param filename - The input filename
135
+ * @returns A safe filename for the current platform
136
+ */
137
+ export declare function sanitizeFilename(filename: string): string;
138
+ /**
139
+ * Get the home directory path
140
+ * @returns The user's home directory path
141
+ */
142
+ export declare function getHomeDirectory(): string;
143
+ /**
144
+ * Remove a file or directory recursively
145
+ * @param targetPath - The path to remove
146
+ * @throws FileSystemError if removal fails
147
+ */
148
+ export declare function remove(targetPath: string): Promise<void>;
149
+ /**
150
+ * Move a file or directory from source to destination
151
+ * @param src - Source path
152
+ * @param dest - Destination path
153
+ * @throws FileSystemError if move operation fails
154
+ */
155
+ export declare function move(src: string, dest: string): Promise<void>;
156
+ /**
157
+ * Resolve path segments relative to a base directory with cross-platform compatibility
158
+ * @param baseDir - The base directory (defaults to '.' if not provided, null, or undefined)
159
+ * @param segments - Additional path segments to resolve
160
+ * @returns The resolved absolute path
161
+ */
162
+ export declare function resolvePath(baseDir: string | undefined, ...segments: string[]): string;
163
+ /**
164
+ * Interface for parsed markdown frontmatter
165
+ */
166
+ export interface MarkdownFrontmatter {
167
+ [key: string]: unknown;
168
+ }
169
+ /**
170
+ * Parse YAML frontmatter from markdown content
171
+ * @param content - The markdown content with frontmatter
172
+ * @returns Object containing frontmatter and body content
173
+ */
174
+ export declare function parseFrontmatter(content: string): {
175
+ frontmatter: MarkdownFrontmatter;
176
+ body: string;
177
+ };
178
+ /**
179
+ * Escape a string for TOML format
180
+ * @param str - The string to escape
181
+ * @returns The escaped string suitable for TOML
182
+ */
183
+ export declare function escapeTomlString(str: string): string;
184
+ /**
185
+ * Convert markdown template content to TOML format for Gemini
186
+ * @param mdContent - The markdown template content
187
+ * @returns The converted TOML content
188
+ */
189
+ export declare function convertMdToToml(mdContent: string): string;
190
+ /**
191
+ * Read a markdown template file and optionally convert to TOML
192
+ * @param templatePath - Path to the markdown template
193
+ * @param targetFormat - Target format ('md' or 'toml')
194
+ * @returns The template content in the requested format
195
+ */
196
+ export declare function readAndProcessTemplate(templatePath: string, targetFormat: TemplateFormat): Promise<string>;
197
+ /**
198
+ * Write processed template content to destination
199
+ * @param content - The template content to write
200
+ * @param destPath - Destination file path
201
+ */
202
+ export declare function writeProcessedTemplate(content: string, destPath: string): Promise<void>;
203
+ /**
204
+ * Get the names of all markdown template files in a given subdirectory of templates.
205
+ * @param templateSubdir - The subdirectory within templates (e.g., 'commands/tasks')
206
+ * @returns An array of template names (filenames without .md extension)
207
+ * @throws FileSystemError if the directory cannot be read
208
+ */
209
+ export declare function getMarkdownTemplateNames(templateSubdir: string): Promise<string[]>;
210
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAmB,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAErE;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAU9D;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQvE;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQnE;AAED;;;;GAIG;AACH,wBAAsB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAO/D;AAED;;;;;;GAMG;AAC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