hubskillz 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/dist/index.js +71 -28
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18911,6 +18911,7 @@ var MAX_FILES_PER_SKILL = 100;
|
|
|
18911
18911
|
var MAX_FILE_CONTENT_CHARS = 2e5;
|
|
18912
18912
|
var MAX_SKILLS_PER_REQUEST = 500;
|
|
18913
18913
|
var MAX_SNAPSHOT_CHARS = MAX_FILE_CONTENT_CHARS;
|
|
18914
|
+
var MAX_INVENTORY_CHUNK_BYTES = 15e5;
|
|
18914
18915
|
var inventoryFileSchema = external_exports.object({
|
|
18915
18916
|
path: skillFilePathSchema,
|
|
18916
18917
|
hash: external_exports.string().min(1),
|
|
@@ -18961,7 +18962,12 @@ var inventoryRequestSchema = external_exports.object({
|
|
|
18961
18962
|
files: external_exports.array(inventoryFileSchema).max(MAX_FILES_PER_SKILL),
|
|
18962
18963
|
upstream: inventoryUpstreamSchema.optional()
|
|
18963
18964
|
})
|
|
18964
|
-
).max(MAX_SKILLS_PER_REQUEST)
|
|
18965
|
+
).max(MAX_SKILLS_PER_REQUEST),
|
|
18966
|
+
/** Big surfaces travel in chunks: chunk 0 replaces, the others append. */
|
|
18967
|
+
chunk: external_exports.object({
|
|
18968
|
+
index: external_exports.number().int().min(0),
|
|
18969
|
+
total: external_exports.number().int().min(1)
|
|
18970
|
+
}).optional()
|
|
18965
18971
|
});
|
|
18966
18972
|
var inventoryItemSchema = external_exports.object({
|
|
18967
18973
|
name: external_exports.string(),
|
|
@@ -18981,7 +18987,9 @@ var inventoryResponseSchema = external_exports.object({
|
|
|
18981
18987
|
});
|
|
18982
18988
|
var approvedQuerySchema = external_exports.object({ surfaceId: external_exports.string().min(1) });
|
|
18983
18989
|
var approvedSkillSchema = external_exports.object({
|
|
18984
|
-
|
|
18990
|
+
// Kebab, not z.string(): the CLI joins this onto a path (commands/sync.ts),
|
|
18991
|
+
// so the response is validated rather than trusted.
|
|
18992
|
+
name: skillNameSchema,
|
|
18985
18993
|
versionId: external_exports.string(),
|
|
18986
18994
|
version: external_exports.number().int(),
|
|
18987
18995
|
contentHash: external_exports.string(),
|
|
@@ -19515,7 +19523,7 @@ function globalSurfaceLabel() {
|
|
|
19515
19523
|
return hostname4();
|
|
19516
19524
|
}
|
|
19517
19525
|
function projectSurfaceLabel(dir) {
|
|
19518
|
-
return `${
|
|
19526
|
+
return `${basename(resolve2(dir))} (${hostname4()})`;
|
|
19519
19527
|
}
|
|
19520
19528
|
async function exists(path) {
|
|
19521
19529
|
try {
|
|
@@ -19622,25 +19630,49 @@ async function isDir(path) {
|
|
|
19622
19630
|
function inventoryRequestOf(surface) {
|
|
19623
19631
|
return {
|
|
19624
19632
|
surface: surface.descriptor,
|
|
19625
|
-
skills: surface.skills.map(
|
|
19626
|
-
|
|
19627
|
-
|
|
19628
|
-
|
|
19629
|
-
|
|
19630
|
-
|
|
19631
|
-
|
|
19632
|
-
|
|
19633
|
-
|
|
19634
|
-
|
|
19635
|
-
|
|
19636
|
-
|
|
19637
|
-
|
|
19638
|
-
|
|
19633
|
+
skills: surface.skills.map(inventorySkillOf)
|
|
19634
|
+
};
|
|
19635
|
+
}
|
|
19636
|
+
function inventoryChunksOf(surface) {
|
|
19637
|
+
const groups = [];
|
|
19638
|
+
let group = [];
|
|
19639
|
+
let bytes = 0;
|
|
19640
|
+
for (const skill of surface.skills) {
|
|
19641
|
+
const item = inventorySkillOf(skill);
|
|
19642
|
+
const size = Buffer.byteLength(JSON.stringify(item), "utf8");
|
|
19643
|
+
if (group.length > 0 && (bytes + size > MAX_INVENTORY_CHUNK_BYTES || group.length >= MAX_SKILLS_PER_REQUEST)) {
|
|
19644
|
+
groups.push(group);
|
|
19645
|
+
group = [];
|
|
19646
|
+
bytes = 0;
|
|
19647
|
+
}
|
|
19648
|
+
group.push(item);
|
|
19649
|
+
bytes += size;
|
|
19650
|
+
}
|
|
19651
|
+
groups.push(group);
|
|
19652
|
+
if (groups.length === 1) return [inventoryRequestOf(surface)];
|
|
19653
|
+
return groups.map((skills, index) => ({
|
|
19654
|
+
surface: surface.descriptor,
|
|
19655
|
+
skills,
|
|
19656
|
+
chunk: { index, total: groups.length }
|
|
19657
|
+
}));
|
|
19658
|
+
}
|
|
19659
|
+
function inventorySkillOf(skill) {
|
|
19660
|
+
const snapshot = skill.upstream === void 0 && skill.files.reduce((sum, file2) => sum + file2.content.length, 0) <= MAX_SNAPSHOT_CHARS;
|
|
19661
|
+
const item = {
|
|
19662
|
+
name: skill.name,
|
|
19663
|
+
contentHash: skill.contentHash,
|
|
19664
|
+
files: skill.files.map((file2) => {
|
|
19665
|
+
const entry = {
|
|
19666
|
+
path: file2.path,
|
|
19667
|
+
hash: file2.hash,
|
|
19668
|
+
size: file2.size
|
|
19639
19669
|
};
|
|
19640
|
-
if (
|
|
19641
|
-
return
|
|
19670
|
+
if (snapshot) entry.content = file2.content;
|
|
19671
|
+
return entry;
|
|
19642
19672
|
})
|
|
19643
19673
|
};
|
|
19674
|
+
if (skill.upstream !== void 0) item.upstream = skill.upstream;
|
|
19675
|
+
return item;
|
|
19644
19676
|
}
|
|
19645
19677
|
|
|
19646
19678
|
// src/discover.ts
|
|
@@ -19863,13 +19895,20 @@ ${quickstart(config2)}`);
|
|
|
19863
19895
|
return Result.ok(void 0);
|
|
19864
19896
|
}
|
|
19865
19897
|
async function postInventory(session, surface) {
|
|
19866
|
-
|
|
19867
|
-
|
|
19868
|
-
|
|
19869
|
-
|
|
19870
|
-
|
|
19871
|
-
|
|
19872
|
-
|
|
19898
|
+
const chunks = inventoryChunksOf(surface);
|
|
19899
|
+
let merged;
|
|
19900
|
+
for (const body of chunks) {
|
|
19901
|
+
const posted = await apiRequest({
|
|
19902
|
+
session,
|
|
19903
|
+
method: "POST",
|
|
19904
|
+
path: "/api/cli/inventory",
|
|
19905
|
+
schema: inventoryResponseSchema,
|
|
19906
|
+
body
|
|
19907
|
+
});
|
|
19908
|
+
if (posted.isFailure) return posted;
|
|
19909
|
+
merged = merged === void 0 ? posted.value : { ...merged, items: [...merged.items, ...posted.value.items] };
|
|
19910
|
+
}
|
|
19911
|
+
return Result.ok(merged ?? { surfaceId: "", items: [] });
|
|
19873
19912
|
}
|
|
19874
19913
|
function originOf(surface, name) {
|
|
19875
19914
|
const skill = surface.skills.find((entry) => entry.name === name);
|
|
@@ -20107,6 +20146,10 @@ async function maybeAdopt(session, surface, inventory, options) {
|
|
|
20107
20146
|
`Adopt ${plural(importable.length)} found here as approved in your directory?`
|
|
20108
20147
|
);
|
|
20109
20148
|
if (!wanted) return Result.ok(inventory);
|
|
20149
|
+
process.stdout.write(
|
|
20150
|
+
dim(`adopting ${plural(importable.length)}, this can take a minute...
|
|
20151
|
+
`)
|
|
20152
|
+
);
|
|
20110
20153
|
const adopted = await apiRequest({
|
|
20111
20154
|
session,
|
|
20112
20155
|
method: "POST",
|
|
@@ -20353,7 +20396,7 @@ function flagLines(flags) {
|
|
|
20353
20396
|
}
|
|
20354
20397
|
function usage() {
|
|
20355
20398
|
const width = Math.max(...COMMANDS.map((command) => command.name.length));
|
|
20356
|
-
return `${bold("hubskillz")} ${dim(`v${"0.3.
|
|
20399
|
+
return `${bold("hubskillz")} ${dim(`v${"0.3.1"}`)} keep your agent skills in sync
|
|
20357
20400
|
|
|
20358
20401
|
${bold("Usage")}
|
|
20359
20402
|
hubskillz <command> [flags]
|
|
@@ -20432,7 +20475,7 @@ Run \`hubskillz help\` for usage.`)
|
|
|
20432
20475
|
);
|
|
20433
20476
|
}
|
|
20434
20477
|
if (values.version === true) {
|
|
20435
|
-
process.stdout.write(`${"0.3.
|
|
20478
|
+
process.stdout.write(`${"0.3.1"}
|
|
20436
20479
|
`);
|
|
20437
20480
|
return Result.ok(void 0);
|
|
20438
20481
|
}
|