@alexgorbatchev/pi-skill-library 0.1.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.
@@ -0,0 +1,32 @@
1
+ import type { Theme } from '@mariozechner/pi-coding-agent';
2
+ import { groupLibrarySummariesByScope } from './groupLibrarySummariesByScope.js';
3
+ import { replaceHomeDirectoryWithTilde } from './replaceHomeDirectoryWithTilde.js';
4
+ import type { ILibraryReportDetails } from './types.js';
5
+
6
+ export function renderLibraryReport(theme: Theme, details: ILibraryReportDetails): string {
7
+ const lines: string[] = [theme.fg('mdHeading', '[Skills Library]')];
8
+ if (details.librarySummaries.length === 0) {
9
+ lines.push(theme.fg('dim', ' No library skills were discovered.'));
10
+ return lines.join('\n');
11
+ }
12
+
13
+ const groupedSummaries = groupLibrarySummariesByScope(details.librarySummaries);
14
+ for (const [scope, librarySummaries] of groupedSummaries) {
15
+ lines.push(` ${theme.fg('accent', scope)}`);
16
+ for (const librarySummary of librarySummaries) {
17
+ lines.push(theme.fg('dim', ` ${replaceHomeDirectoryWithTilde(librarySummary.libraryPath)}`));
18
+ for (const skillName of librarySummary.skillNames) {
19
+ lines.push(theme.fg('dim', ` /library:${skillName}`));
20
+ }
21
+ }
22
+ }
23
+
24
+ if (details.diagnostics.length > 0) {
25
+ lines.push(` ${theme.fg('warning', 'diagnostics')}`);
26
+ for (const diagnostic of details.diagnostics) {
27
+ lines.push(theme.fg('warning', ` ${replaceHomeDirectoryWithTilde(diagnostic)}`));
28
+ }
29
+ }
30
+
31
+ return lines.join('\n');
32
+ }
@@ -0,0 +1,19 @@
1
+ import { homedir } from 'node:os';
2
+ import path from 'node:path';
3
+
4
+ export function replaceHomeDirectoryWithTilde(value: string): string {
5
+ const homeDirectoryPath = homedir();
6
+ const normalizedHomeDirectoryPath = path.normalize(homeDirectoryPath);
7
+ const normalizedValue = path.normalize(value);
8
+
9
+ if (normalizedValue === normalizedHomeDirectoryPath) {
10
+ return '~';
11
+ }
12
+
13
+ const homeDirectoryPrefix = `${normalizedHomeDirectoryPath}${path.sep}`;
14
+ if (!normalizedValue.startsWith(homeDirectoryPrefix)) {
15
+ return value;
16
+ }
17
+
18
+ return `~${path.sep}${normalizedValue.slice(homeDirectoryPrefix.length)}`;
19
+ }
package/src/types.ts ADDED
@@ -0,0 +1,25 @@
1
+ import type { Skill } from '@mariozechner/pi-coding-agent';
2
+
3
+ export interface ILibraryCommand {
4
+ skillName: string;
5
+ args: string;
6
+ }
7
+
8
+ export interface ILibrarySummary {
9
+ libraryPath: string;
10
+ scope: 'project' | 'user' | 'temporary';
11
+ skillNames: string[];
12
+ }
13
+
14
+ export interface ILibraryReportDetails {
15
+ diagnostics: string[];
16
+ librarySummaries: ILibrarySummary[];
17
+ }
18
+
19
+ export interface ILibrarySkillDiscovery {
20
+ skills: Skill[];
21
+ skillByName: Map<string, Skill>;
22
+ diagnostics: string[];
23
+ libraryPaths: string[];
24
+ librarySummaries: ILibrarySummary[];
25
+ }