@crafter/skillkit 0.1.2 → 0.1.3
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/package.json +1 -1
- package/src/bin.ts +1 -1
- package/src/commands/health.ts +20 -22
package/package.json
CHANGED
package/src/bin.ts
CHANGED
package/src/commands/health.ts
CHANGED
|
@@ -5,7 +5,6 @@ import { getTopSkills } from "../db/queries";
|
|
|
5
5
|
import { getDb } from "../db/schema";
|
|
6
6
|
import { scanInstalledSkills } from "../scanner/skills";
|
|
7
7
|
import { bold, dim, green, red, yellow } from "../tui/colors";
|
|
8
|
-
import { healthGauge } from "../tui/health";
|
|
9
8
|
|
|
10
9
|
const METADATA_BUDGET = 16000;
|
|
11
10
|
const BODY_LINE_LIMIT = 500;
|
|
@@ -31,7 +30,7 @@ function parseFrontmatter(content: string): {
|
|
|
31
30
|
if (!match)
|
|
32
31
|
return { name: "", description: "", bodyLines: content.split("\n").length };
|
|
33
32
|
|
|
34
|
-
const yaml = match[1];
|
|
33
|
+
const yaml = match[1] ?? "";
|
|
35
34
|
const body = content.slice(match[0].length);
|
|
36
35
|
const bodyLines = body.trim() ? body.trim().split("\n").length : 0;
|
|
37
36
|
|
|
@@ -39,10 +38,11 @@ function parseFrontmatter(content: string): {
|
|
|
39
38
|
let description = "";
|
|
40
39
|
|
|
41
40
|
const nameMatch = yaml.match(/^name:\s*(.+)$/m);
|
|
42
|
-
if (nameMatch) name = nameMatch[1].trim().replace(/^["']|["']$/g, "");
|
|
41
|
+
if (nameMatch?.[1]) name = nameMatch[1].trim().replace(/^["']|["']$/g, "");
|
|
43
42
|
|
|
44
43
|
const descMatch = yaml.match(/^description:\s*(.+)$/m);
|
|
45
|
-
if (descMatch
|
|
44
|
+
if (descMatch?.[1])
|
|
45
|
+
description = descMatch[1].trim().replace(/^["']|["']$/g, "");
|
|
46
46
|
|
|
47
47
|
return { name, description, bodyLines };
|
|
48
48
|
}
|
|
@@ -138,28 +138,26 @@ export async function runHealth(): Promise<void> {
|
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
console.log();
|
|
141
|
-
const gaugeStr = healthGauge(100 - metadataPct);
|
|
142
141
|
const metaKb = (totalMetadataChars / 1000).toFixed(1);
|
|
143
142
|
const budgetKb = (METADATA_BUDGET / 1000).toFixed(1);
|
|
144
143
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
)
|
|
159
|
-
|
|
160
|
-
console.log(` ${gaugeStr}`);
|
|
144
|
+
const filled = Math.round(Math.min(metadataPct, 100) / 10);
|
|
145
|
+
const empty = 10 - filled;
|
|
146
|
+
const barFill = "█".repeat(filled);
|
|
147
|
+
const barEmpty = "░".repeat(empty);
|
|
148
|
+
const colorBar =
|
|
149
|
+
metadataPct >= 90
|
|
150
|
+
? red(barFill)
|
|
151
|
+
: metadataPct >= 70
|
|
152
|
+
? yellow(barFill)
|
|
153
|
+
: green(barFill);
|
|
154
|
+
const bar = `[${colorBar}${dim(barEmpty)}]`;
|
|
155
|
+
|
|
156
|
+
console.log(
|
|
157
|
+
` ${bar} ${bold(`${metadataPct}%`)} metadata budget ${dim(`(${metaKb}K / ${budgetKb}K)`)}`,
|
|
158
|
+
);
|
|
161
159
|
console.log(
|
|
162
|
-
` ${dim(
|
|
160
|
+
` ${dim("name + description of each skill, loaded at startup")}`,
|
|
163
161
|
);
|
|
164
162
|
|
|
165
163
|
const bodyKb = (totalBodyChars / 1000).toFixed(1);
|