@juanibiapina/pi-gob 0.4.1 → 0.5.0
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/segment.d.ts.map +1 -1
- package/dist/segment.js +6 -3
- package/dist/segment.js.map +1 -1
- package/package.json +2 -3
package/dist/segment.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segment.d.ts","sourceRoot":"","sources":["../src/segment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"segment.d.ts","sourceRoot":"","sources":["../src/segment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAS9C,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACd;AA0BD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,WAAW,CAyBjE"}
|
package/dist/segment.js
CHANGED
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
* all with history: "⚙ npm run dev ████░░░░ 57% · make build ████████ 100%"
|
|
13
13
|
*/
|
|
14
14
|
const BAR_WIDTH = 8;
|
|
15
|
+
/** Display label for a job: description if set, otherwise the raw command. */
|
|
16
|
+
function jobLabel(job) {
|
|
17
|
+
return job.description || job.command.join(" ");
|
|
18
|
+
}
|
|
15
19
|
/**
|
|
16
20
|
* Compute progress percentage for a running job with known average duration.
|
|
17
21
|
* Returns undefined if no historical data. Clamps to 0–100.
|
|
@@ -45,8 +49,7 @@ export function formatJobSegment(jobs) {
|
|
|
45
49
|
for (const job of jobs) {
|
|
46
50
|
const pct = jobProgress(job);
|
|
47
51
|
if (pct !== undefined) {
|
|
48
|
-
|
|
49
|
-
withBar.push(`${cmd} ${renderBar(pct)}`);
|
|
52
|
+
withBar.push(`${jobLabel(job)} ${renderBar(pct)}`);
|
|
50
53
|
}
|
|
51
54
|
else {
|
|
52
55
|
withoutBar.push(job);
|
|
@@ -54,7 +57,7 @@ export function formatJobSegment(jobs) {
|
|
|
54
57
|
}
|
|
55
58
|
const parts = [...withBar];
|
|
56
59
|
if (withoutBar.length === 1) {
|
|
57
|
-
parts.push(withoutBar[0]
|
|
60
|
+
parts.push(jobLabel(withoutBar[0]));
|
|
58
61
|
}
|
|
59
62
|
else if (withoutBar.length > 1) {
|
|
60
63
|
parts.push(`${withoutBar.length} jobs`);
|
package/dist/segment.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segment.js","sourceRoot":"","sources":["../src/segment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,MAAM,SAAS,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"segment.js","sourceRoot":"","sources":["../src/segment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB,8EAA8E;AAC9E,SAAS,QAAQ,CAAC,GAAgB;IACjC,OAAO,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACjD,CAAC;AAQD;;;GAGG;AACH,SAAS,WAAW,CAAC,GAAgB;IACpC,IAAI,GAAG,CAAC,eAAe,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU;QAAE,OAAO,SAAS,CAAC;IAElE,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC;IACjD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;IACrC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAA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AM,KAAK,CAAC,EAAE,CAAC;QAC7B,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC;SAAM,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC/D,CAAC","sourcesContent":["/**\n * Powerbar segment formatting for gob running jobs.\n *\n * Each job with historical run data renders its own progress bar.\n * Jobs without progress data are grouped: 1 shows its command, N shows \"N jobs\".\n * Parts are joined with \" · \".\n *\n * Examples:\n * 1 job, no history: \"⚙ npm run dev\"\n * 1 job, with history: \"⚙ npm run dev ████░░░░ 57%\"\n * mixed: \"⚙ npm run dev ████░░░░ 57% · 2 jobs\"\n * all with history: \"⚙ npm run dev ████░░░░ 57% · make build ████████ 100%\"\n */\n\nimport type { JobResponse } from \"./types.js\";\n\nconst BAR_WIDTH = 8;\n\n/** Display label for a job: description if set, otherwise the raw command. */\nfunction jobLabel(job: JobResponse): string {\n\treturn job.description || job.command.join(\" \");\n}\n\nexport interface SegmentData {\n\ttext: string;\n\ticon: string;\n\tcolor: string;\n}\n\n/**\n * Compute progress percentage for a running job with known average duration.\n * Returns undefined if no historical data. Clamps to 0–100.\n */\nfunction jobProgress(job: JobResponse): number | undefined {\n\tif (job.avg_duration_ms <= 0 || !job.started_at) return undefined;\n\n\tconst start = new Date(job.started_at).getTime();\n\tconst elapsedMs = Date.now() - start;\n\tconst pct = Math.round((elapsedMs / job.avg_duration_ms) * 100);\n\n\treturn Math.max(0, Math.min(100, pct));\n}\n\n/**\n * Render a progress bar using block characters.\n * \"████░░░░ 57%\" or \"████████ 100%\"\n */\nfunction renderBar(pct: number): string {\n\tconst filled = Math.round((pct / 100) * BAR_WIDTH);\n\tconst empty = BAR_WIDTH - filled;\n\treturn `${\"█\".repeat(filled)}${\"░\".repeat(empty)} ${pct}%`;\n}\n\n/**\n * Format running jobs into a powerbar segment payload.\n */\nexport function formatJobSegment(jobs: JobResponse[]): SegmentData {\n\tif (jobs.length === 0) {\n\t\treturn { text: \"\", icon: \"⚙\", color: \"muted\" };\n\t}\n\n\tconst withBar: string[] = [];\n\tconst withoutBar: JobResponse[] = [];\n\tfor (const job of jobs) {\n\t\tconst pct = jobProgress(job);\n\t\tif (pct !== undefined) {\n\t\t\twithBar.push(`${jobLabel(job)} ${renderBar(pct)}`);\n\t\t} else {\n\t\t\twithoutBar.push(job);\n\t\t}\n\t}\n\n\tconst parts: string[] = [...withBar];\n\n\tif (withoutBar.length === 1) {\n\t\tparts.push(jobLabel(withoutBar[0]));\n\t} else if (withoutBar.length > 1) {\n\t\tparts.push(`${withoutBar.length} jobs`);\n\t}\n\n\treturn { text: parts.join(\" · \"), icon: \"⚙\", color: \"muted\" };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juanibiapina/pi-gob",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Pi extension for managing gob background jobs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -37,14 +37,13 @@
|
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=20.0.0"
|
|
39
39
|
},
|
|
40
|
-
"dependencies": {},
|
|
41
40
|
"peerDependencies": {
|
|
42
41
|
"@mariozechner/pi-coding-agent": "*",
|
|
43
42
|
"@mariozechner/pi-tui": "*"
|
|
44
43
|
},
|
|
45
44
|
"devDependencies": {
|
|
46
45
|
"@biomejs/biome": "2.3.5",
|
|
47
|
-
"@mariozechner/pi-coding-agent": "^0.
|
|
46
|
+
"@mariozechner/pi-coding-agent": "^0.62.0",
|
|
48
47
|
"@types/node": "^22.10.5",
|
|
49
48
|
"typescript": "^5.9.2"
|
|
50
49
|
}
|