wave-agent-sdk 0.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.
- package/README.md +32 -0
- package/dist/agent.d.ts +96 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +286 -0
- package/dist/hooks/executor.d.ts +56 -0
- package/dist/hooks/executor.d.ts.map +1 -0
- package/dist/hooks/executor.js +312 -0
- package/dist/hooks/index.d.ts +17 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +14 -0
- package/dist/hooks/manager.d.ts +90 -0
- package/dist/hooks/manager.d.ts.map +1 -0
- package/dist/hooks/manager.js +395 -0
- package/dist/hooks/matcher.d.ts +49 -0
- package/dist/hooks/matcher.d.ts.map +1 -0
- package/dist/hooks/matcher.js +147 -0
- package/dist/hooks/settings.d.ts +46 -0
- package/dist/hooks/settings.d.ts.map +1 -0
- package/dist/hooks/settings.js +100 -0
- package/dist/hooks/types.d.ts +80 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +59 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/managers/aiManager.d.ts +61 -0
- package/dist/managers/aiManager.d.ts.map +1 -0
- package/dist/managers/aiManager.js +415 -0
- package/dist/managers/backgroundBashManager.d.ts +27 -0
- package/dist/managers/backgroundBashManager.d.ts.map +1 -0
- package/dist/managers/backgroundBashManager.js +166 -0
- package/dist/managers/bashManager.d.ts +20 -0
- package/dist/managers/bashManager.d.ts.map +1 -0
- package/dist/managers/bashManager.js +66 -0
- package/dist/managers/mcpManager.d.ts +63 -0
- package/dist/managers/mcpManager.d.ts.map +1 -0
- package/dist/managers/mcpManager.js +378 -0
- package/dist/managers/messageManager.d.ts +85 -0
- package/dist/managers/messageManager.d.ts.map +1 -0
- package/dist/managers/messageManager.js +265 -0
- package/dist/managers/skillManager.d.ts +59 -0
- package/dist/managers/skillManager.d.ts.map +1 -0
- package/dist/managers/skillManager.js +317 -0
- package/dist/managers/slashCommandManager.d.ts +77 -0
- package/dist/managers/slashCommandManager.d.ts.map +1 -0
- package/dist/managers/slashCommandManager.js +208 -0
- package/dist/managers/toolManager.d.ts +23 -0
- package/dist/managers/toolManager.d.ts.map +1 -0
- package/dist/managers/toolManager.js +79 -0
- package/dist/services/aiService.d.ts +28 -0
- package/dist/services/aiService.d.ts.map +1 -0
- package/dist/services/aiService.js +180 -0
- package/dist/services/memory.d.ts +8 -0
- package/dist/services/memory.d.ts.map +1 -0
- package/dist/services/memory.js +128 -0
- package/dist/services/session.d.ts +54 -0
- package/dist/services/session.d.ts.map +1 -0
- package/dist/services/session.js +196 -0
- package/dist/tools/bashTool.d.ts +14 -0
- package/dist/tools/bashTool.d.ts.map +1 -0
- package/dist/tools/bashTool.js +351 -0
- package/dist/tools/deleteFileTool.d.ts +6 -0
- package/dist/tools/deleteFileTool.d.ts.map +1 -0
- package/dist/tools/deleteFileTool.js +67 -0
- package/dist/tools/editTool.d.ts +6 -0
- package/dist/tools/editTool.d.ts.map +1 -0
- package/dist/tools/editTool.js +168 -0
- package/dist/tools/globTool.d.ts +6 -0
- package/dist/tools/globTool.d.ts.map +1 -0
- package/dist/tools/globTool.js +113 -0
- package/dist/tools/grepTool.d.ts +6 -0
- package/dist/tools/grepTool.d.ts.map +1 -0
- package/dist/tools/grepTool.js +268 -0
- package/dist/tools/lsTool.d.ts +6 -0
- package/dist/tools/lsTool.d.ts.map +1 -0
- package/dist/tools/lsTool.js +160 -0
- package/dist/tools/multiEditTool.d.ts +6 -0
- package/dist/tools/multiEditTool.d.ts.map +1 -0
- package/dist/tools/multiEditTool.js +222 -0
- package/dist/tools/readTool.d.ts +6 -0
- package/dist/tools/readTool.d.ts.map +1 -0
- package/dist/tools/readTool.js +136 -0
- package/dist/tools/types.d.ts +35 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +4 -0
- package/dist/tools/writeTool.d.ts +6 -0
- package/dist/tools/writeTool.d.ts.map +1 -0
- package/dist/tools/writeTool.js +138 -0
- package/dist/types.d.ts +212 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +13 -0
- package/dist/utils/bashHistory.d.ts +46 -0
- package/dist/utils/bashHistory.d.ts.map +1 -0
- package/dist/utils/bashHistory.js +236 -0
- package/dist/utils/commandArgumentParser.d.ts +34 -0
- package/dist/utils/commandArgumentParser.d.ts.map +1 -0
- package/dist/utils/commandArgumentParser.js +123 -0
- package/dist/utils/constants.d.ts +27 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +28 -0
- package/dist/utils/convertMessagesForAPI.d.ts +9 -0
- package/dist/utils/convertMessagesForAPI.d.ts.map +1 -0
- package/dist/utils/convertMessagesForAPI.js +189 -0
- package/dist/utils/customCommands.d.ts +14 -0
- package/dist/utils/customCommands.d.ts.map +1 -0
- package/dist/utils/customCommands.js +71 -0
- package/dist/utils/fileFilter.d.ts +26 -0
- package/dist/utils/fileFilter.d.ts.map +1 -0
- package/dist/utils/fileFilter.js +177 -0
- package/dist/utils/markdownParser.d.ts +27 -0
- package/dist/utils/markdownParser.d.ts.map +1 -0
- package/dist/utils/markdownParser.js +109 -0
- package/dist/utils/mcpUtils.d.ts +24 -0
- package/dist/utils/mcpUtils.d.ts.map +1 -0
- package/dist/utils/mcpUtils.js +51 -0
- package/dist/utils/messageOperations.d.ts +118 -0
- package/dist/utils/messageOperations.d.ts.map +1 -0
- package/dist/utils/messageOperations.js +334 -0
- package/dist/utils/path.d.ts +25 -0
- package/dist/utils/path.d.ts.map +1 -0
- package/dist/utils/path.js +109 -0
- package/dist/utils/skillParser.d.ts +18 -0
- package/dist/utils/skillParser.d.ts.map +1 -0
- package/dist/utils/skillParser.js +147 -0
- package/dist/utils/stringUtils.d.ts +13 -0
- package/dist/utils/stringUtils.d.ts.map +1 -0
- package/dist/utils/stringUtils.js +44 -0
- package/package.json +51 -0
- package/src/agent.ts +405 -0
- package/src/hooks/executor.ts +440 -0
- package/src/hooks/index.ts +52 -0
- package/src/hooks/manager.ts +618 -0
- package/src/hooks/matcher.ts +187 -0
- package/src/hooks/settings.ts +129 -0
- package/src/hooks/types.ts +169 -0
- package/src/index.ts +24 -0
- package/src/managers/aiManager.ts +573 -0
- package/src/managers/backgroundBashManager.ts +203 -0
- package/src/managers/bashManager.ts +97 -0
- package/src/managers/mcpManager.ts +493 -0
- package/src/managers/messageManager.ts +415 -0
- package/src/managers/skillManager.ts +404 -0
- package/src/managers/slashCommandManager.ts +293 -0
- package/src/managers/toolManager.ts +106 -0
- package/src/services/aiService.ts +252 -0
- package/src/services/memory.ts +149 -0
- package/src/services/session.ts +265 -0
- package/src/tools/bashTool.ts +402 -0
- package/src/tools/deleteFileTool.ts +81 -0
- package/src/tools/editTool.ts +192 -0
- package/src/tools/globTool.ts +135 -0
- package/src/tools/grepTool.ts +326 -0
- package/src/tools/lsTool.ts +187 -0
- package/src/tools/multiEditTool.ts +268 -0
- package/src/tools/readTool.ts +165 -0
- package/src/tools/types.ts +47 -0
- package/src/tools/writeTool.ts +163 -0
- package/src/types.ts +260 -0
- package/src/utils/bashHistory.ts +303 -0
- package/src/utils/commandArgumentParser.ts +153 -0
- package/src/utils/constants.ts +37 -0
- package/src/utils/convertMessagesForAPI.ts +236 -0
- package/src/utils/customCommands.ts +85 -0
- package/src/utils/fileFilter.ts +202 -0
- package/src/utils/markdownParser.ts +156 -0
- package/src/utils/mcpUtils.ts +81 -0
- package/src/utils/messageOperations.ts +506 -0
- package/src/utils/path.ts +118 -0
- package/src/utils/skillParser.ts +188 -0
- package/src/utils/stringUtils.ts +50 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { resolve } from "path";
|
|
2
|
+
import { homedir } from "os";
|
|
3
|
+
import { relative } from "path";
|
|
4
|
+
/**
|
|
5
|
+
* Handle paths, supporting ~ expansion
|
|
6
|
+
* @param filePath File path
|
|
7
|
+
* @param workdir Working directory
|
|
8
|
+
* @returns Resolved absolute path
|
|
9
|
+
*/
|
|
10
|
+
export function resolvePath(filePath, workdir) {
|
|
11
|
+
// If the path starts with ~, replace it with the user's home directory
|
|
12
|
+
if (filePath.startsWith("~/")) {
|
|
13
|
+
return resolve(homedir(), filePath.slice(2));
|
|
14
|
+
}
|
|
15
|
+
// If the path starts with ~ but has no slash, it means it's the home directory
|
|
16
|
+
if (filePath === "~") {
|
|
17
|
+
return homedir();
|
|
18
|
+
}
|
|
19
|
+
// For other paths, resolve using the specified working directory
|
|
20
|
+
return resolve(workdir, filePath);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Binary file extension list
|
|
24
|
+
*/
|
|
25
|
+
export const binaryExtensions = [
|
|
26
|
+
// Image files
|
|
27
|
+
"png",
|
|
28
|
+
"jpg",
|
|
29
|
+
"jpeg",
|
|
30
|
+
"gif",
|
|
31
|
+
"bmp",
|
|
32
|
+
"ico",
|
|
33
|
+
"webp",
|
|
34
|
+
"svg",
|
|
35
|
+
"sketch",
|
|
36
|
+
// Audio files
|
|
37
|
+
"mp3",
|
|
38
|
+
"wav",
|
|
39
|
+
"ogg",
|
|
40
|
+
"aac",
|
|
41
|
+
// Video files
|
|
42
|
+
"mp4",
|
|
43
|
+
"webm",
|
|
44
|
+
"avi",
|
|
45
|
+
"mov",
|
|
46
|
+
// Document files
|
|
47
|
+
"pdf",
|
|
48
|
+
"doc",
|
|
49
|
+
"docx",
|
|
50
|
+
"xls",
|
|
51
|
+
"xlsx",
|
|
52
|
+
"ppt",
|
|
53
|
+
"pptx",
|
|
54
|
+
// Compressed files
|
|
55
|
+
"zip",
|
|
56
|
+
"rar",
|
|
57
|
+
"7z",
|
|
58
|
+
"tar",
|
|
59
|
+
"gz",
|
|
60
|
+
// Font files
|
|
61
|
+
"ttf",
|
|
62
|
+
"otf",
|
|
63
|
+
"woff",
|
|
64
|
+
"woff2",
|
|
65
|
+
"eot",
|
|
66
|
+
// Other binary files
|
|
67
|
+
"exe",
|
|
68
|
+
"dll",
|
|
69
|
+
"so",
|
|
70
|
+
"dylib",
|
|
71
|
+
"bin",
|
|
72
|
+
];
|
|
73
|
+
/**
|
|
74
|
+
* Check if a file is a binary file
|
|
75
|
+
* @param filename File name
|
|
76
|
+
* @returns Whether it is a binary file
|
|
77
|
+
*/
|
|
78
|
+
export const isBinary = (filename) => {
|
|
79
|
+
const parts = filename.split(".");
|
|
80
|
+
const ext = parts.length > 1 ? parts.pop()?.toLowerCase() || "" : "";
|
|
81
|
+
return binaryExtensions.includes(ext);
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Get relative path for display, use relative path if shorter and not in parent directory
|
|
85
|
+
* @param filePath Absolute path
|
|
86
|
+
* @param workdir Working directory
|
|
87
|
+
* @returns Path for display (relative or absolute)
|
|
88
|
+
*/
|
|
89
|
+
export function getDisplayPath(filePath, workdir) {
|
|
90
|
+
if (!filePath) {
|
|
91
|
+
return filePath;
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
const relativePath = relative(workdir, filePath);
|
|
95
|
+
// If the relative path is empty (i.e., the paths are the same), return "."
|
|
96
|
+
if (relativePath === "") {
|
|
97
|
+
return ".";
|
|
98
|
+
}
|
|
99
|
+
// If the relative path is shorter than the absolute path and does not start with .. (not in parent directory), use the relative path
|
|
100
|
+
if (relativePath.length < filePath.length &&
|
|
101
|
+
!relativePath.startsWith("..")) {
|
|
102
|
+
return relativePath;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
// If calculating the relative path fails, keep the original path
|
|
107
|
+
}
|
|
108
|
+
return filePath;
|
|
109
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ParsedSkillFile, SkillParseOptions, SkillMetadata } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Parse a SKILL.md file and validate its contents
|
|
4
|
+
*/
|
|
5
|
+
export declare function parseSkillFile(filePath: string, options?: SkillParseOptions): ParsedSkillFile;
|
|
6
|
+
/**
|
|
7
|
+
* Validate skill metadata according to requirements
|
|
8
|
+
*/
|
|
9
|
+
export declare function validateSkillMetadata(metadata: SkillMetadata): string[];
|
|
10
|
+
/**
|
|
11
|
+
* Check if a skill name is valid format
|
|
12
|
+
*/
|
|
13
|
+
export declare function isValidSkillName(name: string): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Generate user-friendly error messages for skill validation
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatSkillError(skillPath: string, errors: string[]): string;
|
|
18
|
+
//# sourceMappingURL=skillParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skillParser.d.ts","sourceRoot":"","sources":["../../src/utils/skillParser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EAEjB,aAAa,EACd,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,iBAAsB,GAC9B,eAAe,CAiEjB;AAkCD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,EAAE,CAwCvE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAOtD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAa5E"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { readFileSync } from "fs";
|
|
2
|
+
import { dirname } from "path";
|
|
3
|
+
/**
|
|
4
|
+
* Parse a SKILL.md file and validate its contents
|
|
5
|
+
*/
|
|
6
|
+
export function parseSkillFile(filePath, options = {}) {
|
|
7
|
+
const { validateMetadata = true, basePath } = options;
|
|
8
|
+
const result = {
|
|
9
|
+
frontmatter: { name: "", description: "" },
|
|
10
|
+
content: "",
|
|
11
|
+
skillMetadata: {
|
|
12
|
+
name: "",
|
|
13
|
+
description: "",
|
|
14
|
+
type: "personal",
|
|
15
|
+
skillPath: "",
|
|
16
|
+
},
|
|
17
|
+
validationErrors: [],
|
|
18
|
+
isValid: false,
|
|
19
|
+
};
|
|
20
|
+
try {
|
|
21
|
+
// Read file content
|
|
22
|
+
const content = readFileSync(filePath, "utf-8");
|
|
23
|
+
result.content = content;
|
|
24
|
+
// Parse YAML frontmatter
|
|
25
|
+
const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---/);
|
|
26
|
+
if (!frontmatterMatch) {
|
|
27
|
+
result.validationErrors.push("Missing YAML frontmatter");
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
const yamlContent = frontmatterMatch[1];
|
|
31
|
+
result.frontmatter = parseYamlFrontmatter(yamlContent);
|
|
32
|
+
if (!result.frontmatter.name || !result.frontmatter.description) {
|
|
33
|
+
result.validationErrors.push("Missing required fields: name and description");
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
// Determine skill type and path
|
|
37
|
+
const skillPath = basePath || dirname(filePath);
|
|
38
|
+
const skillType = skillPath.includes("/.wave/skills")
|
|
39
|
+
? "project"
|
|
40
|
+
: "personal";
|
|
41
|
+
result.skillMetadata = {
|
|
42
|
+
name: result.frontmatter.name,
|
|
43
|
+
description: result.frontmatter.description,
|
|
44
|
+
type: skillType,
|
|
45
|
+
skillPath,
|
|
46
|
+
};
|
|
47
|
+
// Validate metadata if requested
|
|
48
|
+
if (validateMetadata) {
|
|
49
|
+
const validationErrors = validateSkillMetadata(result.skillMetadata);
|
|
50
|
+
result.validationErrors.push(...validationErrors);
|
|
51
|
+
}
|
|
52
|
+
result.isValid = result.validationErrors.length === 0;
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
result.validationErrors.push(`Failed to read skill file: ${error instanceof Error ? error.message : String(error)}`);
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Simple YAML frontmatter parser for skill files
|
|
62
|
+
*/
|
|
63
|
+
function parseYamlFrontmatter(yamlContent) {
|
|
64
|
+
const frontmatter = { name: "", description: "" };
|
|
65
|
+
try {
|
|
66
|
+
const lines = yamlContent.split("\n");
|
|
67
|
+
for (const line of lines) {
|
|
68
|
+
const trimmed = line.trim();
|
|
69
|
+
if (!trimmed || trimmed.startsWith("#"))
|
|
70
|
+
continue;
|
|
71
|
+
const colonIndex = trimmed.indexOf(":");
|
|
72
|
+
if (colonIndex === -1)
|
|
73
|
+
continue;
|
|
74
|
+
const key = trimmed.substring(0, colonIndex).trim();
|
|
75
|
+
const value = trimmed
|
|
76
|
+
.substring(colonIndex + 1)
|
|
77
|
+
.trim()
|
|
78
|
+
.replace(/^["']|["']$/g, "");
|
|
79
|
+
if (key && value) {
|
|
80
|
+
frontmatter[key] = value;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// Return empty frontmatter on parse error - validation will catch missing fields
|
|
86
|
+
}
|
|
87
|
+
return frontmatter;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Validate skill metadata according to requirements
|
|
91
|
+
*/
|
|
92
|
+
export function validateSkillMetadata(metadata) {
|
|
93
|
+
const errors = [];
|
|
94
|
+
// Import SKILL_DEFAULTS dynamically to avoid circular imports
|
|
95
|
+
const NAME_PATTERN = /^[a-z0-9-]+$/;
|
|
96
|
+
const MAX_NAME_LENGTH = 64;
|
|
97
|
+
const MAX_DESCRIPTION_LENGTH = 1024;
|
|
98
|
+
const MIN_DESCRIPTION_LENGTH = 1;
|
|
99
|
+
// Validate name
|
|
100
|
+
if (!metadata.name) {
|
|
101
|
+
errors.push("Skill name is required");
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
if (metadata.name.length > MAX_NAME_LENGTH) {
|
|
105
|
+
errors.push(`Skill name must be ${MAX_NAME_LENGTH} characters or less`);
|
|
106
|
+
}
|
|
107
|
+
if (!NAME_PATTERN.test(metadata.name)) {
|
|
108
|
+
errors.push("Skill name must contain only lowercase letters, numbers, and hyphens");
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// Validate description
|
|
112
|
+
if (!metadata.description) {
|
|
113
|
+
errors.push("Skill description is required");
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
if (metadata.description.length < MIN_DESCRIPTION_LENGTH) {
|
|
117
|
+
errors.push(`Skill description must be at least ${MIN_DESCRIPTION_LENGTH} character`);
|
|
118
|
+
}
|
|
119
|
+
if (metadata.description.length > MAX_DESCRIPTION_LENGTH) {
|
|
120
|
+
errors.push(`Skill description must be ${MAX_DESCRIPTION_LENGTH} characters or less`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return errors;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Check if a skill name is valid format
|
|
127
|
+
*/
|
|
128
|
+
export function isValidSkillName(name) {
|
|
129
|
+
const NAME_PATTERN = /^[a-z0-9-]+$/;
|
|
130
|
+
const MAX_NAME_LENGTH = 64;
|
|
131
|
+
return (name.length > 0 && name.length <= MAX_NAME_LENGTH && NAME_PATTERN.test(name));
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Generate user-friendly error messages for skill validation
|
|
135
|
+
*/
|
|
136
|
+
export function formatSkillError(skillPath, errors) {
|
|
137
|
+
const header = `Skill validation failed for ${skillPath}:`;
|
|
138
|
+
const errorList = errors.map((error) => ` • ${error}`).join("\n");
|
|
139
|
+
const suggestions = [
|
|
140
|
+
"To fix this skill:",
|
|
141
|
+
" 1. Ensure SKILL.md has valid YAML frontmatter (---...---)",
|
|
142
|
+
" 2. Include required fields: name and description",
|
|
143
|
+
" 3. Use lowercase letters, numbers, and hyphens only for name",
|
|
144
|
+
" 4. Keep name under 64 characters and description under 1024 characters",
|
|
145
|
+
].join("\n");
|
|
146
|
+
return `${header}\n${errorList}\n\n${suggestions}`;
|
|
147
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remove code block wrappers
|
|
3
|
+
* @param content Content that may contain code block wrappers
|
|
4
|
+
* @returns Content after removing wrappers
|
|
5
|
+
*/
|
|
6
|
+
export declare function removeCodeBlockWrappers(content: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Function to remove ANSI color codes
|
|
9
|
+
* @param text Text containing ANSI color codes
|
|
10
|
+
* @returns Plain text with color codes removed
|
|
11
|
+
*/
|
|
12
|
+
export declare const stripAnsiColors: (text: string) => string;
|
|
13
|
+
//# sourceMappingURL=stringUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringUtils.d.ts","sourceRoot":"","sources":["../../src/utils/stringUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAgC/D;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,MAK9C,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remove code block wrappers
|
|
3
|
+
* @param content Content that may contain code block wrappers
|
|
4
|
+
* @returns Content after removing wrappers
|
|
5
|
+
*/
|
|
6
|
+
export function removeCodeBlockWrappers(content) {
|
|
7
|
+
// Remove code block wrappers from beginning and end
|
|
8
|
+
// Supports the following formats:
|
|
9
|
+
// ```language
|
|
10
|
+
// code content
|
|
11
|
+
// ```
|
|
12
|
+
//
|
|
13
|
+
// ```
|
|
14
|
+
// code content
|
|
15
|
+
// ```
|
|
16
|
+
const lines = content.split("\n");
|
|
17
|
+
let startIndex = 0;
|
|
18
|
+
let endIndex = lines.length - 1;
|
|
19
|
+
// Check if there is a code block marker at the beginning
|
|
20
|
+
if (lines[startIndex]?.trim().startsWith("```")) {
|
|
21
|
+
startIndex = 1;
|
|
22
|
+
}
|
|
23
|
+
// Check if there is a code block marker at the end
|
|
24
|
+
if (lines[endIndex]?.trim() === "```") {
|
|
25
|
+
endIndex = endIndex - 1;
|
|
26
|
+
}
|
|
27
|
+
// If no complete code block wrapper is found, return original content
|
|
28
|
+
if (startIndex === 0 && endIndex === lines.length - 1) {
|
|
29
|
+
return content;
|
|
30
|
+
}
|
|
31
|
+
// Return content after removing wrappers
|
|
32
|
+
return lines.slice(startIndex, endIndex + 1).join("\n");
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Function to remove ANSI color codes
|
|
36
|
+
* @param text Text containing ANSI color codes
|
|
37
|
+
* @returns Plain text with color codes removed
|
|
38
|
+
*/
|
|
39
|
+
export const stripAnsiColors = (text) => {
|
|
40
|
+
// Create the escape character dynamically to avoid control character detection
|
|
41
|
+
const escapeChar = String.fromCharCode(27); // ESC character
|
|
42
|
+
const ansiEscapeRegex = new RegExp(`${escapeChar}\\[[0-9;]*[a-zA-Z]`, "g");
|
|
43
|
+
return text.replace(ansiEscapeRegex, "");
|
|
44
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "wave-agent-sdk",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "SDK for building AI-powered development tools and agents",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ai",
|
|
7
|
+
"sdk",
|
|
8
|
+
"agent",
|
|
9
|
+
"development-tools",
|
|
10
|
+
"typescript",
|
|
11
|
+
"mcp"
|
|
12
|
+
],
|
|
13
|
+
"main": "dist/index.js",
|
|
14
|
+
"types": "dist/index.d.ts",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"src",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "rimraf dist && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
23
|
+
"type-check": "tsc --noEmit --incremental",
|
|
24
|
+
"dev": "tsc -p tsconfig.build.json --watch & tsc-alias -p tsconfig.build.json --watch",
|
|
25
|
+
"test": "vitest run",
|
|
26
|
+
"lint": "eslint --cache",
|
|
27
|
+
"format": "prettier --write .",
|
|
28
|
+
"release:patch": "pnpm version patch && npm publish",
|
|
29
|
+
"release:minor": "pnpm version minor && npm publish",
|
|
30
|
+
"release:major": "pnpm version major && npm publish",
|
|
31
|
+
"prepublishOnly": "npm run build"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@modelcontextprotocol/sdk": "^1.18.2",
|
|
35
|
+
"@vscode/ripgrep": "^1.15.14",
|
|
36
|
+
"diff": "^8.0.2",
|
|
37
|
+
"glob": "^11.0.3",
|
|
38
|
+
"minimatch": "^10.0.3",
|
|
39
|
+
"openai": "^5.12.2"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"rimraf": "^6.0.1",
|
|
43
|
+
"tsc-alias": "^1.8.16",
|
|
44
|
+
"tsx": "^4.20.4",
|
|
45
|
+
"vitest": "^3.2.4"
|
|
46
|
+
},
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=16.0.0"
|
|
49
|
+
},
|
|
50
|
+
"license": "MIT"
|
|
51
|
+
}
|