@hcmai/cli 0.3.0 → 0.3.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 +1 -1
- package/dist/index.js +26 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ Source and release automation are maintained in
|
|
|
28
28
|
|
|
29
29
|
## WorkBuddy delivery projects
|
|
30
30
|
|
|
31
|
-
`@hcmai/cli@0.3.
|
|
31
|
+
`@hcmai/cli@0.3.1` can synchronize a Chiron Skill and its dependency/file closure
|
|
32
32
|
into a WorkBuddy project while generating a stable project-local launcher:
|
|
33
33
|
|
|
34
34
|
```bash
|
package/dist/index.js
CHANGED
|
@@ -4235,7 +4235,7 @@ import {
|
|
|
4235
4235
|
resolveChironBase,
|
|
4236
4236
|
assertSafeSkillId as assertSafeSkillId2,
|
|
4237
4237
|
assertSafeReferencePath,
|
|
4238
|
-
normalizeReferences,
|
|
4238
|
+
normalizeReferences as normalizeReferences2,
|
|
4239
4239
|
parseSkillRequirements,
|
|
4240
4240
|
parseSkillFrontmatter,
|
|
4241
4241
|
resolveSkillInstallOrder as resolveSkillInstallOrder2,
|
|
@@ -4261,9 +4261,10 @@ import {
|
|
|
4261
4261
|
CliErrorCode as CliErrorCode13,
|
|
4262
4262
|
assertSafeSkillFilePath,
|
|
4263
4263
|
assertSafeSkillId,
|
|
4264
|
+
normalizeReferences,
|
|
4264
4265
|
resolveSkillInstallOrder
|
|
4265
4266
|
} from "@hcmai/sdk";
|
|
4266
|
-
async function prepareSkillDocuments(catalog, requestedSkill, fetchMarkdown, fetchFile) {
|
|
4267
|
+
async function prepareSkillDocuments(catalog, requestedSkill, fetchMarkdown, fetchFile, fetchReference) {
|
|
4267
4268
|
const order = resolveSkillInstallOrder(catalog, requestedSkill);
|
|
4268
4269
|
for (const skill of order) {
|
|
4269
4270
|
if (skill.actionSurface !== "cli") {
|
|
@@ -4276,13 +4277,32 @@ async function prepareSkillDocuments(catalog, requestedSkill, fetchMarkdown, fet
|
|
|
4276
4277
|
if (skill.files === void 0) {
|
|
4277
4278
|
const markdown2 = await fetchMarkdown(skill.id);
|
|
4278
4279
|
const content = Buffer.from(markdown2, "utf8");
|
|
4280
|
+
const references = normalizeReferences(skill.references, skill.id);
|
|
4281
|
+
if (references.length > 0 && !fetchReference) {
|
|
4282
|
+
throw invalid(`\u6280\u80FD ${skill.id} \u58F0\u660E\u4E86 references\uFF0C\u4F46\u8C03\u7528\u65B9\u6CA1\u6709\u53C2\u8003\u6587\u4EF6\u4E0B\u8F7D\u80FD\u529B`);
|
|
4283
|
+
}
|
|
4284
|
+
const referenceFiles = await Promise.all(
|
|
4285
|
+
references.map(async (relativePath) => {
|
|
4286
|
+
const targetPath = `references/${relativePath}`;
|
|
4287
|
+
assertSafeSkillFilePath(targetPath);
|
|
4288
|
+
const fetched = await fetchReference(skill.id, relativePath);
|
|
4289
|
+
const referenceContent = Buffer.isBuffer(fetched) ? Buffer.from(fetched) : Buffer.from(fetched, "utf8");
|
|
4290
|
+
return {
|
|
4291
|
+
path: targetPath,
|
|
4292
|
+
content: referenceContent,
|
|
4293
|
+
bytes: referenceContent.length,
|
|
4294
|
+
sha256: sha256(referenceContent)
|
|
4295
|
+
};
|
|
4296
|
+
})
|
|
4297
|
+
);
|
|
4279
4298
|
files = [
|
|
4280
4299
|
{
|
|
4281
4300
|
path: "SKILL.md",
|
|
4282
4301
|
content,
|
|
4283
4302
|
bytes: content.length,
|
|
4284
4303
|
sha256: sha256(content)
|
|
4285
|
-
}
|
|
4304
|
+
},
|
|
4305
|
+
...referenceFiles
|
|
4286
4306
|
];
|
|
4287
4307
|
} else {
|
|
4288
4308
|
if (!Array.isArray(skill.files) || skill.files.length === 0) {
|
|
@@ -5307,7 +5327,8 @@ async function skillsSyncCommand(id, args) {
|
|
|
5307
5327
|
catalog,
|
|
5308
5328
|
id,
|
|
5309
5329
|
async (skillId) => fetchSkillMarkdown(http, skillId, base),
|
|
5310
|
-
async (skillId, relativePath) => fetchSkillFile(http, skillId, relativePath, base)
|
|
5330
|
+
async (skillId, relativePath) => fetchSkillFile(http, skillId, relativePath, base),
|
|
5331
|
+
async (skillId, relativePath) => fetchSkillReference(http, skillId, relativePath, base)
|
|
5311
5332
|
);
|
|
5312
5333
|
const result2 = await syncWorkBuddyProject({
|
|
5313
5334
|
project,
|
|
@@ -5460,7 +5481,7 @@ async function listLocalSkillIds(root) {
|
|
|
5460
5481
|
return ids.sort();
|
|
5461
5482
|
}
|
|
5462
5483
|
async function fetchSkillDocument(http, skill, endpoint, base) {
|
|
5463
|
-
const relatives =
|
|
5484
|
+
const relatives = normalizeReferences2(skill.references, skill.id);
|
|
5464
5485
|
const references = await Promise.all(relatives.map(async (relative2) => ({
|
|
5465
5486
|
path: relative2,
|
|
5466
5487
|
content: await fetchSkillReference(http, skill.id, relative2, base)
|