mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-02 08:33:36 +00:00
feat: Introduce @automaker/prompts package for AI prompt templates
Changes: - Added a new package, @automaker/prompts, containing AI prompt templates for enhancing user-written task descriptions. - Implemented four enhancement modes: improve, technical, simplify, and acceptance, each with corresponding system prompts and examples. - Updated relevant packages to utilize the new prompts package, ensuring backward compatibility with existing imports. - Enhanced documentation to include usage examples and integration details for the new prompts. Benefits: ✅ Streamlined AI prompt management across the codebase ✅ Improved clarity and usability for AI-powered features ✅ Comprehensive documentation for developers All tests passing.
This commit is contained in:
@@ -108,3 +108,27 @@ export function getUserFriendlyErrorMessage(error: unknown): string {
|
||||
|
||||
return info.message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract error message from an unknown error value
|
||||
*
|
||||
* Simple utility for getting a string error message from any error type.
|
||||
* Returns the error's message property if it's an Error, otherwise
|
||||
* converts to string. Used throughout the codebase for consistent
|
||||
* error message extraction.
|
||||
*
|
||||
* @param error - The error value (Error object, string, or unknown)
|
||||
* @returns Error message string
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* try {
|
||||
* throw new Error("Something went wrong");
|
||||
* } catch (error) {
|
||||
* const message = getErrorMessage(error); // "Something went wrong"
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export function getErrorMessage(error: unknown): string {
|
||||
return error instanceof Error ? error.message : "Unknown error";
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ export {
|
||||
isAuthenticationError,
|
||||
classifyError,
|
||||
getUserFriendlyErrorMessage,
|
||||
getErrorMessage,
|
||||
} from './error-handler.js';
|
||||
|
||||
// Conversation utilities
|
||||
@@ -48,3 +49,9 @@ export {
|
||||
mkdirSafe,
|
||||
existsSafe,
|
||||
} from './fs-utils.js';
|
||||
|
||||
// Path utilities
|
||||
export {
|
||||
normalizePath,
|
||||
pathsEqual,
|
||||
} from './path-utils.js';
|
||||
|
||||
54
libs/utils/src/path-utils.ts
Normal file
54
libs/utils/src/path-utils.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Path Utilities - Cross-platform path manipulation helpers
|
||||
*
|
||||
* Provides functions for normalizing and comparing file system paths
|
||||
* across different operating systems (Windows, macOS, Linux).
|
||||
*/
|
||||
|
||||
/**
|
||||
* Normalize a path by converting backslashes to forward slashes
|
||||
*
|
||||
* This ensures consistent path representation across platforms:
|
||||
* - Windows: C:\Users\foo\bar -> C:/Users/foo/bar
|
||||
* - Unix: /home/foo/bar -> /home/foo/bar (unchanged)
|
||||
*
|
||||
* @param p - Path string to normalize
|
||||
* @returns Normalized path with forward slashes
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* normalizePath("C:\\Users\\foo\\bar"); // "C:/Users/foo/bar"
|
||||
* normalizePath("/home/foo/bar"); // "/home/foo/bar"
|
||||
* ```
|
||||
*/
|
||||
export function normalizePath(p: string): string {
|
||||
return p.replace(/\\/g, "/");
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two paths for equality after normalization
|
||||
*
|
||||
* Handles null/undefined values and normalizes paths before comparison.
|
||||
* Useful for checking if two paths refer to the same location regardless
|
||||
* of platform-specific path separators.
|
||||
*
|
||||
* @param p1 - First path to compare (or null/undefined)
|
||||
* @param p2 - Second path to compare (or null/undefined)
|
||||
* @returns true if paths are equal (or both null/undefined), false otherwise
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* pathsEqual("C:\\foo\\bar", "C:/foo/bar"); // true
|
||||
* pathsEqual("/home/user", "/home/user"); // true
|
||||
* pathsEqual("/home/user", "/home/other"); // false
|
||||
* pathsEqual(null, undefined); // false
|
||||
* pathsEqual(null, null); // true
|
||||
* ```
|
||||
*/
|
||||
export function pathsEqual(
|
||||
p1: string | undefined | null,
|
||||
p2: string | undefined | null
|
||||
): boolean {
|
||||
if (!p1 || !p2) return p1 === p2;
|
||||
return normalizePath(p1) === normalizePath(p2);
|
||||
}
|
||||
Reference in New Issue
Block a user