@tdsoft-tech/aikit 0.1.5 → 0.1.6
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/CHANGELOG.md +13 -0
- package/dist/cli.js +291 -86
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +4 -6
- package/dist/index.js +88 -58
- package/dist/index.js.map +1 -1
- package/dist/mcp-server.js +72 -41
- package/dist/mcp-server.js.map +1 -1
- package/package.json +1 -1
package/dist/mcp-server.js
CHANGED
|
@@ -169,7 +169,7 @@ __export(figma_mcp_exports, {
|
|
|
169
169
|
FigmaMcpClient: () => FigmaMcpClient
|
|
170
170
|
});
|
|
171
171
|
import { writeFile as writeFile3, mkdir as mkdir3 } from "fs/promises";
|
|
172
|
-
import { join as
|
|
172
|
+
import { join as join6 } from "path";
|
|
173
173
|
import { existsSync as existsSync2 } from "fs";
|
|
174
174
|
var FigmaMcpClient;
|
|
175
175
|
var init_figma_mcp = __esm({
|
|
@@ -528,7 +528,7 @@ ${text}`);
|
|
|
528
528
|
}, "Figma images listing");
|
|
529
529
|
const imageData = await response.json();
|
|
530
530
|
const images = imageData.images;
|
|
531
|
-
const fullAssetsDir = assetsDir.startsWith("/") ? assetsDir :
|
|
531
|
+
const fullAssetsDir = assetsDir.startsWith("/") ? assetsDir : join6(process.cwd(), assetsDir);
|
|
532
532
|
if (!existsSync2(fullAssetsDir)) {
|
|
533
533
|
await mkdir3(fullAssetsDir, { recursive: true });
|
|
534
534
|
}
|
|
@@ -549,7 +549,7 @@ ${text}`);
|
|
|
549
549
|
const safeName = node.name.replace(/[^a-z0-9]/gi, "_").toLowerCase().substring(0, 50);
|
|
550
550
|
const extension = "png";
|
|
551
551
|
const filename = `${safeName}_${node.id.substring(0, 8)}.${extension}`;
|
|
552
|
-
const filePath =
|
|
552
|
+
const filePath = join6(fullAssetsDir, filename);
|
|
553
553
|
await writeFile3(filePath, Buffer.from(imageBuffer));
|
|
554
554
|
downloadedAssets.push({
|
|
555
555
|
nodeId: node.id,
|
|
@@ -590,7 +590,7 @@ __export(figma_screen_developer_exports, {
|
|
|
590
590
|
compareCodeWithFigma: () => compareCodeWithFigma
|
|
591
591
|
});
|
|
592
592
|
import { readFile as readFile4, readdir as readdir3 } from "fs/promises";
|
|
593
|
-
import { join as
|
|
593
|
+
import { join as join7 } from "path";
|
|
594
594
|
import { existsSync as existsSync3 } from "fs";
|
|
595
595
|
async function checkCurrentCodeStatus(projectPath = process.cwd()) {
|
|
596
596
|
const status = {
|
|
@@ -604,13 +604,13 @@ async function checkCurrentCodeStatus(projectPath = process.cwd()) {
|
|
|
604
604
|
};
|
|
605
605
|
try {
|
|
606
606
|
const htmlFiles = ["index.html", "index.htm", "main.html"].filter(
|
|
607
|
-
(file) => existsSync3(
|
|
607
|
+
(file) => existsSync3(join7(projectPath, file))
|
|
608
608
|
);
|
|
609
609
|
if (htmlFiles.length > 0) {
|
|
610
610
|
status.hasHTML = true;
|
|
611
611
|
status.htmlFile = htmlFiles[0];
|
|
612
612
|
try {
|
|
613
|
-
const htmlContent = await readFile4(
|
|
613
|
+
const htmlContent = await readFile4(join7(projectPath, htmlFiles[0]), "utf-8");
|
|
614
614
|
const sectionMatches = htmlContent.match(/<(section|div|header|footer|main|article|aside)[^>]*(?:id|class)=["']([^"']+)["']/gi);
|
|
615
615
|
if (sectionMatches) {
|
|
616
616
|
status.sections = sectionMatches.map((match) => {
|
|
@@ -622,19 +622,19 @@ async function checkCurrentCodeStatus(projectPath = process.cwd()) {
|
|
|
622
622
|
} catch (e) {
|
|
623
623
|
}
|
|
624
624
|
}
|
|
625
|
-
const stylesDir =
|
|
625
|
+
const stylesDir = join7(projectPath, "styles");
|
|
626
626
|
if (existsSync3(stylesDir)) {
|
|
627
627
|
try {
|
|
628
628
|
const files = await readdir3(stylesDir);
|
|
629
629
|
const cssFiles = files.filter((f) => f.endsWith(".css"));
|
|
630
630
|
if (cssFiles.length > 0) {
|
|
631
631
|
status.hasCSS = true;
|
|
632
|
-
status.cssFiles = cssFiles.map((f) =>
|
|
632
|
+
status.cssFiles = cssFiles.map((f) => join7(stylesDir, f));
|
|
633
633
|
}
|
|
634
634
|
} catch (e) {
|
|
635
635
|
}
|
|
636
636
|
}
|
|
637
|
-
const assetsDir =
|
|
637
|
+
const assetsDir = join7(projectPath, "assets", "images");
|
|
638
638
|
if (existsSync3(assetsDir)) {
|
|
639
639
|
try {
|
|
640
640
|
const files = await readdir3(assetsDir);
|
|
@@ -713,7 +713,7 @@ __export(memory_exports, {
|
|
|
713
713
|
MemoryManager: () => MemoryManager
|
|
714
714
|
});
|
|
715
715
|
import { readFile as readFile5, writeFile as writeFile4, mkdir as mkdir4, access as access2, constants as constants2 } from "fs/promises";
|
|
716
|
-
import { join as
|
|
716
|
+
import { join as join8 } from "path";
|
|
717
717
|
var MemoryManager;
|
|
718
718
|
var init_memory = __esm({
|
|
719
719
|
"src/core/memory.ts"() {
|
|
@@ -733,13 +733,13 @@ var init_memory = __esm({
|
|
|
733
733
|
const memoryPath = paths.memory(this.config.configPath);
|
|
734
734
|
const subDirs = ["observations", "handoffs", "research"];
|
|
735
735
|
for (const subDir of subDirs) {
|
|
736
|
-
const dirPath =
|
|
736
|
+
const dirPath = join8(memoryPath, subDir);
|
|
737
737
|
try {
|
|
738
738
|
const { readdir: readdir5 } = await import("fs/promises");
|
|
739
739
|
const files = await readdir5(dirPath);
|
|
740
740
|
for (const file of files) {
|
|
741
741
|
if (!file.endsWith(".md")) continue;
|
|
742
|
-
const content = await readFile5(
|
|
742
|
+
const content = await readFile5(join8(dirPath, file), "utf-8");
|
|
743
743
|
const summary = this.extractSummary(content);
|
|
744
744
|
memories.push({
|
|
745
745
|
key: `${subDir}/${file.replace(".md", "")}`,
|
|
@@ -763,11 +763,11 @@ var init_memory = __esm({
|
|
|
763
763
|
const memoryPath = paths.memory(this.config.configPath);
|
|
764
764
|
let filePath;
|
|
765
765
|
if (key.includes("/")) {
|
|
766
|
-
filePath =
|
|
766
|
+
filePath = join8(memoryPath, `${key}.md`);
|
|
767
767
|
} else {
|
|
768
768
|
const subDirs = ["observations", "handoffs", "research", "_templates"];
|
|
769
769
|
for (const subDir of subDirs) {
|
|
770
|
-
const testPath =
|
|
770
|
+
const testPath = join8(memoryPath, subDir, `${key}.md`);
|
|
771
771
|
try {
|
|
772
772
|
await access2(testPath, constants2.R_OK);
|
|
773
773
|
filePath = testPath;
|
|
@@ -776,7 +776,7 @@ var init_memory = __esm({
|
|
|
776
776
|
continue;
|
|
777
777
|
}
|
|
778
778
|
}
|
|
779
|
-
filePath = filePath ||
|
|
779
|
+
filePath = filePath || join8(memoryPath, `${key}.md`);
|
|
780
780
|
}
|
|
781
781
|
try {
|
|
782
782
|
return await readFile5(filePath, "utf-8");
|
|
@@ -792,13 +792,13 @@ var init_memory = __esm({
|
|
|
792
792
|
const type = options?.type || "custom";
|
|
793
793
|
let filePath;
|
|
794
794
|
if (key.includes("/")) {
|
|
795
|
-
filePath =
|
|
795
|
+
filePath = join8(memoryPath, `${key}.md`);
|
|
796
796
|
} else {
|
|
797
797
|
const subDir = type === "observation" ? "observations" : type === "handoff" ? "handoffs" : type === "research" ? "research" : "";
|
|
798
|
-
filePath =
|
|
798
|
+
filePath = join8(memoryPath, subDir, `${key}.md`);
|
|
799
799
|
}
|
|
800
|
-
const { dirname } = await import("path");
|
|
801
|
-
await mkdir4(
|
|
800
|
+
const { dirname: dirname2 } = await import("path");
|
|
801
|
+
await mkdir4(dirname2(filePath), { recursive: true });
|
|
802
802
|
if (options?.append) {
|
|
803
803
|
try {
|
|
804
804
|
const existing = await readFile5(filePath, "utf-8");
|
|
@@ -936,8 +936,28 @@ import {
|
|
|
936
936
|
init_esm_shims();
|
|
937
937
|
init_paths();
|
|
938
938
|
import { readFile, access, constants } from "fs/promises";
|
|
939
|
-
import { join as
|
|
939
|
+
import { join as join3 } from "path";
|
|
940
940
|
import { z } from "zod";
|
|
941
|
+
|
|
942
|
+
// src/utils/version.ts
|
|
943
|
+
init_esm_shims();
|
|
944
|
+
import { readFileSync } from "fs";
|
|
945
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
946
|
+
import { dirname, join as join2 } from "path";
|
|
947
|
+
function getVersion() {
|
|
948
|
+
try {
|
|
949
|
+
const __filename2 = fileURLToPath2(import.meta.url);
|
|
950
|
+
const __dirname2 = dirname(__filename2);
|
|
951
|
+
const packageJsonPath = join2(__dirname2, "..", "package.json");
|
|
952
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
953
|
+
return packageJson.version;
|
|
954
|
+
} catch (error) {
|
|
955
|
+
console.warn("Warning: Could not read version from package.json, using fallback");
|
|
956
|
+
return "0.0.0";
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
// src/core/config.ts
|
|
941
961
|
var ConfigSchema = z.object({
|
|
942
962
|
version: z.string(),
|
|
943
963
|
skills: z.object({
|
|
@@ -1029,23 +1049,23 @@ async function loadConfig(projectPath) {
|
|
|
1029
1049
|
let configPath;
|
|
1030
1050
|
let configData = {};
|
|
1031
1051
|
try {
|
|
1032
|
-
await access(
|
|
1033
|
-
const globalContent = await readFile(
|
|
1052
|
+
await access(join3(globalConfigPath, "aikit.json"), constants.R_OK);
|
|
1053
|
+
const globalContent = await readFile(join3(globalConfigPath, "aikit.json"), "utf-8");
|
|
1034
1054
|
configData = JSON.parse(globalContent);
|
|
1035
1055
|
configPath = globalConfigPath;
|
|
1036
1056
|
} catch {
|
|
1037
1057
|
configPath = projectConfigPath;
|
|
1038
1058
|
}
|
|
1039
1059
|
try {
|
|
1040
|
-
await access(
|
|
1041
|
-
const projectContent = await readFile(
|
|
1060
|
+
await access(join3(projectConfigPath, "aikit.json"), constants.R_OK);
|
|
1061
|
+
const projectContent = await readFile(join3(projectConfigPath, "aikit.json"), "utf-8");
|
|
1042
1062
|
const projectData = JSON.parse(projectContent);
|
|
1043
1063
|
configData = deepMerge(configData, projectData);
|
|
1044
1064
|
configPath = projectConfigPath;
|
|
1045
1065
|
} catch {
|
|
1046
1066
|
}
|
|
1047
1067
|
if (!configData.version) {
|
|
1048
|
-
configData.version =
|
|
1068
|
+
configData.version = getVersion();
|
|
1049
1069
|
}
|
|
1050
1070
|
const parsed = ConfigSchema.parse(configData);
|
|
1051
1071
|
return new Config({
|
|
@@ -1074,8 +1094,9 @@ function deepMerge(base, override) {
|
|
|
1074
1094
|
// src/core/skills.ts
|
|
1075
1095
|
init_esm_shims();
|
|
1076
1096
|
init_paths();
|
|
1097
|
+
init_logger();
|
|
1077
1098
|
import { readFile as readFile2, readdir, writeFile, mkdir } from "fs/promises";
|
|
1078
|
-
import { join as
|
|
1099
|
+
import { join as join4, basename, extname } from "path";
|
|
1079
1100
|
import matter from "gray-matter";
|
|
1080
1101
|
var SkillEngine = class {
|
|
1081
1102
|
config;
|
|
@@ -1146,7 +1167,7 @@ var SkillEngine = class {
|
|
|
1146
1167
|
const skillsDir = paths.skills(configPath);
|
|
1147
1168
|
await mkdir(skillsDir, { recursive: true });
|
|
1148
1169
|
const fileName = `${name.replace(/\s+/g, "-").toLowerCase()}.md`;
|
|
1149
|
-
const filePath =
|
|
1170
|
+
const filePath = join4(skillsDir, fileName);
|
|
1150
1171
|
const frontmatter = {
|
|
1151
1172
|
name,
|
|
1152
1173
|
description: options?.description || `Use when you need to ${name}`,
|
|
@@ -1207,12 +1228,22 @@ Describe what this skill does.
|
|
|
1207
1228
|
if (globalSkillsPath === projectSkillsPath) {
|
|
1208
1229
|
return { count: 0, synced: [] };
|
|
1209
1230
|
}
|
|
1210
|
-
|
|
1231
|
+
let globalSkills = [];
|
|
1232
|
+
try {
|
|
1233
|
+
globalSkills = await this.loadSkillsFromDir(globalSkillsPath);
|
|
1234
|
+
} catch (error) {
|
|
1235
|
+
logger.warn("Global skills directory not found. Skipping sync.");
|
|
1236
|
+
return { count: 0, synced: [] };
|
|
1237
|
+
}
|
|
1238
|
+
if (globalSkills.length === 0) {
|
|
1239
|
+
logger.info("No global skills to sync.");
|
|
1240
|
+
return { count: 0, synced: [] };
|
|
1241
|
+
}
|
|
1211
1242
|
await mkdir(projectSkillsPath, { recursive: true });
|
|
1212
1243
|
const synced = [];
|
|
1213
1244
|
for (const skill of globalSkills) {
|
|
1214
1245
|
const fileName = `${skill.name.replace(/\s+/g, "-").toLowerCase()}.md`;
|
|
1215
|
-
const destPath =
|
|
1246
|
+
const destPath = join4(projectSkillsPath, fileName);
|
|
1216
1247
|
const srcContent = await readFile2(skill.filePath, "utf-8");
|
|
1217
1248
|
await writeFile(destPath, srcContent);
|
|
1218
1249
|
synced.push(skill.name);
|
|
@@ -1246,7 +1277,7 @@ ${skill.content}
|
|
|
1246
1277
|
const skills = [];
|
|
1247
1278
|
for (const file of files) {
|
|
1248
1279
|
if (extname(file) !== ".md") continue;
|
|
1249
|
-
const filePath =
|
|
1280
|
+
const filePath = join4(dir, file);
|
|
1250
1281
|
const content = await readFile2(filePath, "utf-8");
|
|
1251
1282
|
const { data, content: body } = matter(content);
|
|
1252
1283
|
const frontmatter = data;
|
|
@@ -1586,7 +1617,7 @@ ${agent.delegatesTo.map((a) => `- @${a}`).join("\n")}` : ""}
|
|
|
1586
1617
|
init_esm_shims();
|
|
1587
1618
|
init_paths();
|
|
1588
1619
|
import { readFile as readFile3, readdir as readdir2, writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
1589
|
-
import { join as
|
|
1620
|
+
import { join as join5, basename as basename2, extname as extname2 } from "path";
|
|
1590
1621
|
import matter2 from "gray-matter";
|
|
1591
1622
|
var DEFAULT_COMMANDS = [
|
|
1592
1623
|
// Core Workflow Commands (Beads integration)
|
|
@@ -2278,10 +2309,10 @@ var CommandRunner = class {
|
|
|
2278
2309
|
async createCommand(name, options) {
|
|
2279
2310
|
const configPath = options?.global ? paths.globalConfig() : this.config.configPath;
|
|
2280
2311
|
const category = options?.category || "utility";
|
|
2281
|
-
const commandsDir =
|
|
2312
|
+
const commandsDir = join5(paths.commands(configPath), category);
|
|
2282
2313
|
await mkdir2(commandsDir, { recursive: true });
|
|
2283
2314
|
const fileName = `${name}.md`;
|
|
2284
|
-
const filePath =
|
|
2315
|
+
const filePath = join5(commandsDir, fileName);
|
|
2285
2316
|
const frontmatter = {
|
|
2286
2317
|
name,
|
|
2287
2318
|
description: options?.description || `Custom command: ${name}`,
|
|
@@ -2340,7 +2371,7 @@ ${command.content}
|
|
|
2340
2371
|
try {
|
|
2341
2372
|
const entries = await readdir2(currentDir, { withFileTypes: true });
|
|
2342
2373
|
for (const entry of entries) {
|
|
2343
|
-
const fullPath =
|
|
2374
|
+
const fullPath = join5(currentDir, entry.name);
|
|
2344
2375
|
if (entry.isDirectory()) {
|
|
2345
2376
|
await processDir(fullPath, entry.name);
|
|
2346
2377
|
} else if (extname2(entry.name) === ".md") {
|
|
@@ -2373,7 +2404,7 @@ init_esm_shims();
|
|
|
2373
2404
|
init_paths();
|
|
2374
2405
|
init_logger();
|
|
2375
2406
|
import { readdir as readdir4, writeFile as writeFile5, mkdir as mkdir5 } from "fs/promises";
|
|
2376
|
-
import { join as
|
|
2407
|
+
import { join as join9, extname as extname3 } from "path";
|
|
2377
2408
|
import { z as z2 } from "zod";
|
|
2378
2409
|
var ToolArgSchema = z2.object({
|
|
2379
2410
|
type: z2.enum(["string", "number", "boolean", "array", "object"]),
|
|
@@ -2835,7 +2866,7 @@ ${tokens.screens?.map((s, i) => `${i + 1}. ${s.name} (ID: ${s.id})`).join("\n")
|
|
|
2835
2866
|
try {
|
|
2836
2867
|
const fileData = await client.getFileData(figmaUrl);
|
|
2837
2868
|
const projectPath = process.cwd();
|
|
2838
|
-
const assetsDir =
|
|
2869
|
+
const assetsDir = join9(projectPath, "assets", "images");
|
|
2839
2870
|
const assets = await client.downloadAssets(fileKey, fileData.document, assetsDir, selectedScreen.id);
|
|
2840
2871
|
downloadedAssets = assets || [];
|
|
2841
2872
|
logger.info(`Downloaded ${downloadedAssets.length} assets for screen ${selectedScreen.name}`);
|
|
@@ -3081,7 +3112,7 @@ var ToolRegistry = class {
|
|
|
3081
3112
|
const toolsDir = paths.tools(configPath);
|
|
3082
3113
|
await mkdir5(toolsDir, { recursive: true });
|
|
3083
3114
|
const fileName = `${name}.ts`;
|
|
3084
|
-
const filePath =
|
|
3115
|
+
const filePath = join9(toolsDir, fileName);
|
|
3085
3116
|
const argsSchema = Object.entries(options.args).map(([argName, arg]) => ` ${argName}: {
|
|
3086
3117
|
type: '${arg.type}',
|
|
3087
3118
|
description: '${arg.description}',
|
|
@@ -3135,7 +3166,7 @@ ${argsDesc}
|
|
|
3135
3166
|
}
|
|
3136
3167
|
for (const file of files) {
|
|
3137
3168
|
if (extname3(file) !== ".ts" && extname3(file) !== ".js") continue;
|
|
3138
|
-
const filePath =
|
|
3169
|
+
const filePath = join9(dir, file);
|
|
3139
3170
|
try {
|
|
3140
3171
|
const toolModule = await import(`file://${filePath}`);
|
|
3141
3172
|
const tool = toolModule.default;
|
|
@@ -3153,7 +3184,7 @@ ${argsDesc}
|
|
|
3153
3184
|
// src/core/tool-config.ts
|
|
3154
3185
|
init_esm_shims();
|
|
3155
3186
|
import { readFile as readFile6, writeFile as writeFile6, mkdir as mkdir6, access as access3, constants as constants3 } from "fs/promises";
|
|
3156
|
-
import { join as
|
|
3187
|
+
import { join as join10 } from "path";
|
|
3157
3188
|
import { z as z3 } from "zod";
|
|
3158
3189
|
var ToolConfigSchema = z3.object({
|
|
3159
3190
|
name: z3.string(),
|
|
@@ -3176,7 +3207,7 @@ var ToolConfigManager = class {
|
|
|
3176
3207
|
toolsConfigPath;
|
|
3177
3208
|
constructor(config) {
|
|
3178
3209
|
this.config = config;
|
|
3179
|
-
this.toolsConfigPath =
|
|
3210
|
+
this.toolsConfigPath = join10(this.config.configPath, "config", "tools.json");
|
|
3180
3211
|
}
|
|
3181
3212
|
/**
|
|
3182
3213
|
* Get all registered tools with their current status
|
|
@@ -3270,7 +3301,7 @@ var ToolConfigManager = class {
|
|
|
3270
3301
|
* Save configurations
|
|
3271
3302
|
*/
|
|
3272
3303
|
async saveConfigs(configs) {
|
|
3273
|
-
const configDir =
|
|
3304
|
+
const configDir = join10(this.config.configPath, "config");
|
|
3274
3305
|
await mkdir6(configDir, { recursive: true });
|
|
3275
3306
|
await writeFile6(this.toolsConfigPath, JSON.stringify(configs, null, 2));
|
|
3276
3307
|
}
|