@h-ai/cli 0.1.0-alpha.37 → 0.1.0-alpha.38
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/dist/{chunk-5IGMJVV5.js → chunk-WUYLYCW2.js} +17 -8
- package/dist/chunk-WUYLYCW2.js.map +1 -0
- package/dist/{cli-skill-templates-JMSV2SVW.js → cli-skill-templates-ZIWYMS4Y.js} +3 -3
- package/dist/{cli-skill-templates-JMSV2SVW.js.map → cli-skill-templates-ZIWYMS4Y.js.map} +1 -1
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/Cargo.toml.hbs +7 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/tauri.conf.json.hbs +7 -2
- package/templates/base/package.json.hbs +1 -1
- package/templates/skills/bridges/fullstack/{AGENTS.md → AGENTS.md.hbs} +10 -10
- package/templates/skills/bridges/fullstack/{CLAUDE.md → CLAUDE.md.hbs} +1 -1
- package/templates/skills/bridges/fullstack/{copilot-instructions.md → copilot-instructions.md.hbs} +5 -5
- package/dist/chunk-5IGMJVV5.js.map +0 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import fse from 'fs-extra';
|
|
5
|
+
import Handlebars from 'handlebars';
|
|
5
6
|
|
|
6
7
|
var MODULE_SKILL_MAP = {
|
|
7
8
|
"db": "hai-reldb",
|
|
@@ -129,10 +130,10 @@ async function copySkills(templatesDir, skillNames, projectPath, targetDirs = SK
|
|
|
129
130
|
}
|
|
130
131
|
return copiedFiles;
|
|
131
132
|
}
|
|
132
|
-
async function copyBridgeFiles(templatesDir, projectPath, overwrite = true, appType) {
|
|
133
|
+
async function copyBridgeFiles(templatesDir, projectPath, overwrite = true, appType, projectName) {
|
|
133
134
|
const copiedFiles = [];
|
|
134
135
|
for (const file of BRIDGE_FILES) {
|
|
135
|
-
const src = await resolveBridgeSource(templatesDir, file.source, appType);
|
|
136
|
+
const src = await resolveBridgeSource(templatesDir, file.source, appType, projectName !== void 0);
|
|
136
137
|
const dest = path.join(projectPath, file.destination);
|
|
137
138
|
if (!src) {
|
|
138
139
|
continue;
|
|
@@ -140,14 +141,22 @@ async function copyBridgeFiles(templatesDir, projectPath, overwrite = true, appT
|
|
|
140
141
|
if (!overwrite && await fse.pathExists(dest)) {
|
|
141
142
|
continue;
|
|
142
143
|
}
|
|
143
|
-
await fse.
|
|
144
|
+
await fse.ensureDir(path.dirname(dest));
|
|
145
|
+
if (src.endsWith(".hbs")) {
|
|
146
|
+
const template = await fse.readFile(src, "utf8");
|
|
147
|
+
const rendered = Handlebars.compile(template, { noEscape: true })({ projectName });
|
|
148
|
+
await fse.writeFile(dest, rendered, "utf8");
|
|
149
|
+
} else {
|
|
150
|
+
await fse.copy(src, dest, { overwrite });
|
|
151
|
+
}
|
|
144
152
|
copiedFiles.push(file.destination);
|
|
145
153
|
}
|
|
146
154
|
return copiedFiles;
|
|
147
155
|
}
|
|
148
|
-
async function resolveBridgeSource(templatesDir, source, appType) {
|
|
156
|
+
async function resolveBridgeSource(templatesDir, source, appType, allowTemplate = false) {
|
|
149
157
|
const profile = appType && BRIDGE_PROFILE_REGEX.test(appType) ? appType : "generic";
|
|
150
158
|
const candidates = [
|
|
159
|
+
...allowTemplate ? [path.join(templatesDir, "bridges", profile, `${source}.hbs`)] : [],
|
|
151
160
|
path.join(templatesDir, "bridges", profile, source),
|
|
152
161
|
path.join(templatesDir, "bridges", "generic", source),
|
|
153
162
|
path.join(templatesDir, source)
|
|
@@ -159,7 +168,7 @@ async function resolveBridgeSource(templatesDir, source, appType) {
|
|
|
159
168
|
}
|
|
160
169
|
return null;
|
|
161
170
|
}
|
|
162
|
-
async function generateSkillFiles(projectPath, _features, appType) {
|
|
171
|
+
async function generateSkillFiles(projectPath, _features, appType, projectName) {
|
|
163
172
|
const templatesDir = getSkillTemplatesDir();
|
|
164
173
|
if (!await fse.pathExists(templatesDir)) {
|
|
165
174
|
return [];
|
|
@@ -168,7 +177,7 @@ async function generateSkillFiles(projectPath, _features, appType) {
|
|
|
168
177
|
const templateSkillNames = await listTemplateSkillNames(templatesDir);
|
|
169
178
|
const compatibleSkillNames = resolveCompatibleSkillNames(templateSkillNames, appType);
|
|
170
179
|
copiedFiles.push(...await copySkills(templatesDir, compatibleSkillNames, projectPath));
|
|
171
|
-
copiedFiles.push(...await copyBridgeFiles(templatesDir, projectPath, true, appType));
|
|
180
|
+
copiedFiles.push(...await copyBridgeFiles(templatesDir, projectPath, true, appType, projectName));
|
|
172
181
|
return copiedFiles;
|
|
173
182
|
}
|
|
174
183
|
async function generateModuleSkillFile(projectPath, moduleId) {
|
|
@@ -224,5 +233,5 @@ async function generateProjectAiSupport(projectPath, skillNames, options = {}) {
|
|
|
224
233
|
}
|
|
225
234
|
|
|
226
235
|
export { generateModuleSkillFile, generateProjectAiSupport, generateSkillFiles, resolveCompatibleSkillNames, resolveSkillNamesForPackages };
|
|
227
|
-
//# sourceMappingURL=chunk-
|
|
228
|
-
//# sourceMappingURL=chunk-
|
|
236
|
+
//# sourceMappingURL=chunk-WUYLYCW2.js.map
|
|
237
|
+
//# sourceMappingURL=chunk-WUYLYCW2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/cli-skill-templates.ts"],"names":[],"mappings":";;;;;;AAgBA,IAAM,gBAAA,GAA2C;AAAA,EAC/C,IAAA,EAAM,WAAA;AAAA,EACN,OAAA,EAAS,WAAA;AAAA,EACT,OAAA,EAAS,WAAA;AAAA,EACT,KAAA,EAAO,SAAA;AAAA,EACP,SAAA,EAAW,aAAA;AAAA,EACX,IAAA,EAAM,QAAA;AAAA,EACN,QAAA,EAAU,YAAA;AAAA,EACV,SAAA,EAAW,aAAA;AAAA,EACX,OAAA,EAAS,WAAA;AAAA,EACT,UAAA,EAAY,cAAA;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Y,CAAA,EAAI;AACzC,IAAA,OAAO,EAAC;AAAA,EACV;AAEA,EAAA,MAAM;AAAA,IACJ,eAAA,GAAkB,IAAA;AAAA,IAClB,oBAAA,GAAuB;AAAA,GACzB,GAAI,OAAA;AAEJ,EAAA,MAAM,cAAwB,EAAC;AAC/B,EAAA,WAAA,CAAY,IAAA,CAAK,GAAG,MAAM,UAAA,CAAW,cAAc,UAAA,EAAY,WAAA,EAAa,iBAAA,EAAmB,eAAe,CAAC,CAAA;AAC/G,EAAA,WAAA,CAAY,IAAA,CAAK,GAAG,MAAM,eAAA,CAAgB,cAAc,WAAA,EAAa,oBAAA,EAAsB,OAAA,CAAQ,OAAO,CAAC,CAAA;AAE3G,EAAA,OAAO,WAAA;AACT","file":"chunk-WUYLYCW2.js","sourcesContent":["/**\n * @h-ai/cli — Skill 模板生成\n *\n * 将 Skill 模板文件复制到用户项目中,供 AI 编程助手使用。\n * @module cli-skill-templates\n */\n\nimport type { AppType } from '../cli-types.js'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport fse from 'fs-extra'\nimport Handlebars from 'handlebars'\n\n/**\n * 模块名到 Skill 目录名的映射\n */\nconst MODULE_SKILL_MAP: Record<string, string> = {\n 'db': 'hai-reldb',\n 'reldb': 'hai-reldb',\n 'cache': 'hai-cache',\n 'iam': 'hai-iam',\n 'storage': 'hai-storage',\n 'ai': 'hai-ai',\n 'crypto': 'hai-crypto',\n 'payment': 'hai-payment',\n 'vecdb': 'hai-vecdb',\n 'datapipe': 'hai-datapipe',\n 'reach': 'hai-reach',\n 'scheduler': 'hai-scheduler',\n 'audit': 'hai-audit',\n 'deploy': 'hai-deploy',\n 'kit': 'hai-kit',\n 'ui': 'hai-ui',\n 'api-client': 'hai-api-client',\n 'capacitor': 'hai-capacitor',\n}\n\n/**\n * 各 appType 互斥的 Skill。\n *\n * 生成样板工程时,默认复制 templates/skills 下所有 hai-* Skill,\n * 仅排除与当前样板技术栈明显冲突的少数 Skill。\n */\nconst SKILL_EXCLUSIONS_BY_APP_TYPE: Partial<Record<AppType, string[]>> = {\n 'admin': ['hai-serv', 'hai-api-contract', 'hai-api-client', 'hai-capacitor'],\n 'website': ['hai-serv', 'hai-api-contract', 'hai-api-client', 'hai-capacitor'],\n 'h5': ['hai-serv', 'hai-api-contract', 'hai-api-client', 'hai-capacitor'],\n 'api': ['hai-ui', 'hai-kit', 'hai-capacitor'],\n 'mobile-app': ['hai-core', 'hai-kit', 'hai-serv', 'hai-api-contract'],\n 'fullstack': ['hai-kit'],\n}\n\nconst WORKFLOW_SKILLS = [\n 'hai-build',\n 'hai-app-create',\n 'hai-app-review',\n 'hai-app-tests',\n]\n\nconst PACKAGE_SKILL_MAP: Record<string, string> = {\n '@h-ai/api-contract': 'hai-api-contract',\n '@h-ai/api-client': 'hai-api-client',\n '@h-ai/core': 'hai-core',\n '@h-ai/serv': 'hai-serv',\n '@h-ai/kit': 'hai-kit',\n '@h-ai/ui': 'hai-ui',\n '@h-ai/reldb': 'hai-reldb',\n '@h-ai/cache': 'hai-cache',\n '@h-ai/iam': 'hai-iam',\n '@h-ai/storage': 'hai-storage',\n '@h-ai/ai': 'hai-ai',\n '@h-ai/crypto': 'hai-crypto',\n '@h-ai/payment': 'hai-payment',\n '@h-ai/vecdb': 'hai-vecdb',\n '@h-ai/datapipe': 'hai-datapipe',\n '@h-ai/reach': 'hai-reach',\n '@h-ai/scheduler': 'hai-scheduler',\n '@h-ai/audit': 'hai-audit',\n '@h-ai/deploy': 'hai-deploy',\n '@h-ai/capacitor': 'hai-capacitor',\n}\n\nconst SKILL_TARGET_DIRS = ['.agents/skills'] as const\n\nconst BRIDGE_FILES = [\n {\n source: 'copilot-instructions.md',\n destination: '.github/copilot-instructions.md',\n },\n {\n source: 'CLAUDE.md',\n destination: 'CLAUDE.md',\n },\n {\n source: 'AGENTS.md',\n destination: 'AGENTS.md',\n },\n {\n source: 'opencode.json',\n destination: 'opencode.json',\n },\n] as const\n\nconst BRIDGE_PROFILE_REGEX = /^[a-z0-9-]+$/\n\nasync function listTemplateSkillNames(templatesDir: string): Promise<string[]> {\n const entries = await fse.readdir(templatesDir, { withFileTypes: true })\n const skillNames: string[] = []\n\n for (const entry of entries) {\n if (!entry.isDirectory() || !entry.name.startsWith('hai-')) {\n continue\n }\n\n const skillFilePath = path.join(templatesDir, entry.name, 'SKILL.md')\n if (await fse.pathExists(skillFilePath)) {\n skillNames.push(entry.name)\n }\n }\n\n return skillNames.sort((a, b) => a.localeCompare(b))\n}\n\nexport function resolveCompatibleSkillNames(\n skillNames: string[],\n appType?: AppType,\n): string[] {\n const excludedSkills = new Set(appType ? SKILL_EXCLUSIONS_BY_APP_TYPE[appType] ?? [] : [])\n return skillNames.filter(skillName => !excludedSkills.has(skillName))\n}\n\n/**\n * 获取 templates/skills/ 目录的绝对路径\n *\n * 兼容两种运行环境:\n * - 构建后:dist/cli-skill-templates.js → ../templates/skills\n * - 测试时:src/commands/cli-skill-templates.ts → ../../templates/skills\n */\nfunction getSkillTemplatesDir(): string {\n const currentDir = path.dirname(fileURLToPath(import.meta.url))\n const distPath = path.resolve(currentDir, '..', 'templates', 'skills')\n if (fse.pathExistsSync(distPath)) {\n return distPath\n }\n return path.resolve(currentDir, '..', '..', 'templates', 'skills')\n}\n\n/**\n * 复制单个 Skill 目录到项目\n *\n * @param templatesDir - Skill 模板根目录\n * @param skillName - Skill 目录名(如 'hai-reldb')\n * @param projectPath - 用户项目根目录\n */\nasync function copySkill(\n templatesDir: string,\n skillName: string,\n projectPath: string,\n targetDirs: readonly string[] = SKILL_TARGET_DIRS,\n overwrite = true,\n): Promise<string[]> {\n const src = path.join(templatesDir, skillName)\n\n if (!(await fse.pathExists(src))) {\n return []\n }\n\n const copiedFiles: string[] = []\n\n for (const targetDir of targetDirs) {\n const dest = path.join(projectPath, targetDir, skillName)\n const skillFilePath = path.join(dest, 'SKILL.md')\n\n if (!overwrite && await fse.pathExists(skillFilePath)) {\n continue\n }\n\n await fse.copy(src, dest, { overwrite: true })\n copiedFiles.push(`${targetDir}/${skillName}/SKILL.md`)\n }\n\n return copiedFiles\n}\n\nasync function copySkills(\n templatesDir: string,\n skillNames: string[],\n projectPath: string,\n targetDirs: readonly string[] = SKILL_TARGET_DIRS,\n overwrite = true,\n): Promise<string[]> {\n const copiedFiles: string[] = []\n\n for (const skillName of new Set(skillNames)) {\n copiedFiles.push(...await copySkill(templatesDir, skillName, projectPath, targetDirs, overwrite))\n }\n\n return copiedFiles\n}\n\n/**\n * 复制桥接文件到项目\n *\n * @param templatesDir - Skill 模板根目录\n * @param projectPath - 用户项目根目录\n */\nasync function copyBridgeFiles(\n templatesDir: string,\n projectPath: string,\n overwrite = true,\n appType?: string,\n projectName?: string,\n): Promise<string[]> {\n const copiedFiles: string[] = []\n\n for (const file of BRIDGE_FILES) {\n const src = await resolveBridgeSource(templatesDir, file.source, appType, projectName !== undefined)\n const dest = path.join(projectPath, file.destination)\n\n if (!src) {\n continue\n }\n\n if (!overwrite && await fse.pathExists(dest)) {\n continue\n }\n\n await fse.ensureDir(path.dirname(dest))\n if (src.endsWith('.hbs')) {\n const template = await fse.readFile(src, 'utf8')\n const rendered = Handlebars.compile(template, { noEscape: true })({ projectName })\n await fse.writeFile(dest, rendered, 'utf8')\n }\n else {\n await fse.copy(src, dest, { overwrite })\n }\n copiedFiles.push(file.destination)\n }\n\n return copiedFiles\n}\n\nasync function resolveBridgeSource(\n templatesDir: string,\n source: string,\n appType?: string,\n allowTemplate = false,\n): Promise<string | null> {\n const profile = appType && BRIDGE_PROFILE_REGEX.test(appType) ? appType : 'generic'\n const candidates = [\n ...(allowTemplate ? [path.join(templatesDir, 'bridges', profile, `${source}.hbs`)] : []),\n path.join(templatesDir, 'bridges', profile, source),\n path.join(templatesDir, 'bridges', 'generic', source),\n path.join(templatesDir, source),\n ]\n\n for (const candidate of candidates) {\n if (await fse.pathExists(candidate)) {\n return candidate\n }\n }\n\n return null\n}\n\n/**\n * 为新项目生成完整的 Skill 文件。\n *\n * 默认复制 templates/skills 下所有 hai-* Skill,再按 appType 排除互斥项。\n *\n * @param projectPath - 用户项目根目录\n * @param _features - 预留参数;保留签名兼容 createProject 调用方\n * @param appType - 应用类型(api 类型不复制 UI Skill)\n */\nexport async function generateSkillFiles(\n projectPath: string,\n _features: string[],\n appType?: string,\n projectName?: string,\n): Promise<string[]> {\n const templatesDir = getSkillTemplatesDir()\n\n if (!(await fse.pathExists(templatesDir))) {\n return []\n }\n\n const copiedFiles: string[] = []\n\n const templateSkillNames = await listTemplateSkillNames(templatesDir)\n const compatibleSkillNames = resolveCompatibleSkillNames(templateSkillNames, appType as AppType | undefined)\n\n copiedFiles.push(...await copySkills(templatesDir, compatibleSkillNames, projectPath))\n\n // 复制桥接文件\n copiedFiles.push(...await copyBridgeFiles(templatesDir, projectPath, true, appType, projectName))\n\n return copiedFiles\n}\n\n/**\n * 为已有项目添加单个模块的 Skill 文件\n *\n * 在 `hai add <module>` 时调用,仅复制对应模块的 Skill 文件。\n *\n * @param projectPath - 用户项目根目录\n * @param moduleId - 模块标识(如 'db'、'iam')\n * @returns 复制的文件路径,若模块无对应 Skill 则返回 null\n */\nexport async function generateModuleSkillFile(\n projectPath: string,\n moduleId: string,\n): Promise<string[] | null> {\n const skillName = MODULE_SKILL_MAP[moduleId]\n if (!skillName) {\n return null\n }\n\n const templatesDir = getSkillTemplatesDir()\n if (!(await fse.pathExists(templatesDir))) {\n return null\n }\n\n const missingTargetDirs: string[] = []\n\n for (const targetDir of SKILL_TARGET_DIRS) {\n const skillFilePath = path.join(projectPath, targetDir, skillName, 'SKILL.md')\n if (!(await fse.pathExists(skillFilePath))) {\n missingTargetDirs.push(targetDir)\n }\n }\n\n const copiedBridgeFiles = await copyBridgeFiles(templatesDir, projectPath, false)\n if (missingTargetDirs.length === 0) {\n return copiedBridgeFiles.length > 0 ? copiedBridgeFiles : null\n }\n\n const copiedSkillFiles = await copySkill(templatesDir, skillName, projectPath, missingTargetDirs)\n const copiedFiles = [...copiedBridgeFiles, ...copiedSkillFiles]\n\n if (copiedFiles.length === 0) {\n return null\n }\n\n return copiedFiles\n}\n\nexport function resolveSkillNamesForPackages(packageNames: string[]): string[] {\n const skillNames = [...WORKFLOW_SKILLS]\n\n for (const packageName of packageNames) {\n const skillName = PACKAGE_SKILL_MAP[packageName]\n if (skillName) {\n skillNames.push(skillName)\n }\n }\n\n return [...new Set(skillNames)]\n}\n\nexport async function generateProjectAiSupport(\n projectPath: string,\n skillNames: string[],\n options: {\n overwriteSkills?: boolean\n overwriteBridgeFiles?: boolean\n appType?: string\n } = {},\n): Promise<string[]> {\n const templatesDir = getSkillTemplatesDir()\n\n if (!(await fse.pathExists(templatesDir))) {\n return []\n }\n\n const {\n overwriteSkills = true,\n overwriteBridgeFiles = true,\n } = options\n\n const copiedFiles: string[] = []\n copiedFiles.push(...await copySkills(templatesDir, skillNames, projectPath, SKILL_TARGET_DIRS, overwriteSkills))\n copiedFiles.push(...await copyBridgeFiles(templatesDir, projectPath, overwriteBridgeFiles, options.appType))\n\n return copiedFiles\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export { generateModuleSkillFile, generateProjectAiSupport, generateSkillFiles, resolveCompatibleSkillNames, resolveSkillNamesForPackages } from './chunk-
|
|
2
|
+
export { generateModuleSkillFile, generateProjectAiSupport, generateSkillFiles, resolveCompatibleSkillNames, resolveSkillNamesForPackages } from './chunk-WUYLYCW2.js';
|
|
3
3
|
import './chunk-2H7UOFLK.js';
|
|
4
|
-
//# sourceMappingURL=cli-skill-templates-
|
|
5
|
-
//# sourceMappingURL=cli-skill-templates-
|
|
4
|
+
//# sourceMappingURL=cli-skill-templates-ZIWYMS4Y.js.map
|
|
5
|
+
//# sourceMappingURL=cli-skill-templates-ZIWYMS4Y.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"cli-skill-templates-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"cli-skill-templates-ZIWYMS4Y.js"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { generateConfigFile } from './chunk-CFCXOKGV.js';
|
|
3
|
-
import './chunk-
|
|
3
|
+
import './chunk-WUYLYCW2.js';
|
|
4
4
|
import './chunk-2H7UOFLK.js';
|
|
5
5
|
import process3 from 'process';
|
|
6
6
|
import { core } from '@h-ai/core';
|
|
@@ -1102,8 +1102,13 @@ PORT=3000
|
|
|
1102
1102
|
` : generateEnvExample(resolvedOptions.features, configs);
|
|
1103
1103
|
await writeFile(envExamplePath, envExample);
|
|
1104
1104
|
}
|
|
1105
|
-
const { generateSkillFiles } = await import('./cli-skill-templates-
|
|
1106
|
-
await generateSkillFiles(
|
|
1105
|
+
const { generateSkillFiles } = await import('./cli-skill-templates-ZIWYMS4Y.js');
|
|
1106
|
+
await generateSkillFiles(
|
|
1107
|
+
projectPath,
|
|
1108
|
+
resolvedOptions.features,
|
|
1109
|
+
resolvedOptions.appType,
|
|
1110
|
+
resolvedOptions.name
|
|
1111
|
+
);
|
|
1107
1112
|
const appTypeLabel = APP_TYPES[resolvedOptions.appType].name;
|
|
1108
1113
|
const readmeContent = resolvedOptions.appType === "fullstack" ? generateFullstackReadme(resolvedOptions.name, resolvedOptions.packageManager, resolvedOptions.frontends) : resolvedOptions.appType === "api" ? generateApiWorkspaceReadme(resolvedOptions.name, resolvedOptions.packageManager) : generateReadme(resolvedOptions.name, appTypeLabel, resolvedOptions.packageManager);
|
|
1109
1114
|
await writeFile(
|
|
@@ -1854,7 +1859,7 @@ async function addModule(options) {
|
|
|
1854
1859
|
core.logger.info(`\u53EF\u7528\u6A21\u5757: ${Object.keys(MODULE_MAP).join(", ")}`);
|
|
1855
1860
|
return;
|
|
1856
1861
|
}
|
|
1857
|
-
const { generateProjectAiSupport, resolveSkillNamesForPackages } = await import('./cli-skill-templates-
|
|
1862
|
+
const { generateProjectAiSupport, resolveSkillNamesForPackages } = await import('./cli-skill-templates-ZIWYMS4Y.js');
|
|
1858
1863
|
if (moduleDef.packages.every((p) => project.haiPackages.includes(p))) {
|
|
1859
1864
|
const generatedFiles2 = await generateProjectAiSupport(
|
|
1860
1865
|
cwd,
|