@howaboua/pi-better-skills-tool 0.0.7 → 0.0.8
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/CHANGELOG.md +5 -0
- package/index.ts +1 -2
- package/package.json +6 -8
- package/src/catalog.ts +17 -13
- package/src/discovery.ts +0 -4
- package/src/tool.ts +3 -5
- package/tsconfig.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# @howaboua/pi-better-skills-tool
|
|
2
2
|
|
|
3
|
+
## 0.0.8
|
|
4
|
+
|
|
5
|
+
- ### Improvements
|
|
6
|
+
- Skills returns its catalog with command guidance when called without arguments. Explicit help remains supported.
|
|
7
|
+
|
|
3
8
|
## 0.0.7
|
|
4
9
|
|
|
5
10
|
- Better Skills now hides the skill catalog from Pi, Code Mode, and Notebook Mode prompts while preserving native `/skill:<name>` commands.
|
package/index.ts
CHANGED
|
@@ -56,8 +56,7 @@ async function registerSkillsInCodeMode(
|
|
|
56
56
|
adaptToolForCodeMode(tool, {
|
|
57
57
|
kind: "freeform",
|
|
58
58
|
prepareInput: prepareSkillsCodeModeInput,
|
|
59
|
-
usage:
|
|
60
|
-
'await tools.skills("list") // list [category...] | read <skill> [skill-or-reference...]; join commands with ;',
|
|
59
|
+
usage: "await tools.skills() // discovery",
|
|
61
60
|
}),
|
|
62
61
|
]);
|
|
63
62
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@howaboua/pi-better-skills-tool",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Progressive skill discovery for Pi, Code Mode and Notebook Mode.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,15 +32,14 @@
|
|
|
32
32
|
"biome.json"
|
|
33
33
|
],
|
|
34
34
|
"scripts": {
|
|
35
|
-
"check": "bun run lint && bun run typecheck
|
|
35
|
+
"check": "bun run lint && bun run typecheck",
|
|
36
36
|
"prepack": "bun run check",
|
|
37
37
|
"typecheck": "tsgo --noEmit",
|
|
38
38
|
"lint": "biome check .",
|
|
39
|
-
"test": "tsx --test tests/**/*.test.ts",
|
|
40
39
|
"pack:dry": "npm pack --dry-run"
|
|
41
40
|
},
|
|
42
41
|
"peerDependencies": {
|
|
43
|
-
"@howaboua/pi-codex-conversion": ">=3.0.
|
|
42
|
+
"@howaboua/pi-codex-conversion": ">=3.0.48",
|
|
44
43
|
"@earendil-works/pi-coding-agent": ">=1.0.0",
|
|
45
44
|
"@earendil-works/pi-tui": ">=1.0.0",
|
|
46
45
|
"typebox": "*"
|
|
@@ -51,12 +50,11 @@
|
|
|
51
50
|
}
|
|
52
51
|
},
|
|
53
52
|
"devDependencies": {
|
|
54
|
-
"@howaboua/pi-codex-conversion": "3.0.
|
|
53
|
+
"@howaboua/pi-codex-conversion": "3.0.48",
|
|
55
54
|
"@biomejs/biome": "^2.5.10",
|
|
56
|
-
"@earendil-works/pi-coding-agent": "1.
|
|
57
|
-
"@earendil-works/pi-tui": "1.
|
|
55
|
+
"@earendil-works/pi-coding-agent": "1.1.0",
|
|
56
|
+
"@earendil-works/pi-tui": "1.1.0",
|
|
58
57
|
"@types/node": "^26.2.0",
|
|
59
|
-
"tsx": "^4.23.12",
|
|
60
58
|
"typebox": "1.3.18",
|
|
61
59
|
"typescript": "^7.0.2"
|
|
62
60
|
},
|
package/src/catalog.ts
CHANGED
|
@@ -9,17 +9,14 @@ import {
|
|
|
9
9
|
import { readSkillPackage } from "./skill-package.js";
|
|
10
10
|
|
|
11
11
|
export type { LoadedSkill } from "./discovery.js";
|
|
12
|
-
export {
|
|
13
|
-
defaultSessionSkillsDir,
|
|
14
|
-
defaultSkillsDir,
|
|
15
|
-
discoverSkills,
|
|
16
|
-
} from "./discovery.js";
|
|
12
|
+
export { defaultSessionSkillsDir, defaultSkillsDir } from "./discovery.js";
|
|
17
13
|
|
|
18
14
|
const MAX_OUTPUT_BYTES = 48 * 1024;
|
|
19
15
|
// Leave room for an exact continuation command inside the output budget.
|
|
20
16
|
const MAX_COMMAND_BYTES = 4 * 1024;
|
|
21
17
|
|
|
22
18
|
type SkillRequest =
|
|
19
|
+
| { action: "help" }
|
|
23
20
|
| { action: "list"; categories: string[] }
|
|
24
21
|
| { action: "read"; name: string; selectors: string[] };
|
|
25
22
|
|
|
@@ -28,7 +25,7 @@ interface SkillsRequest {
|
|
|
28
25
|
offset: number;
|
|
29
26
|
}
|
|
30
27
|
|
|
31
|
-
|
|
28
|
+
function parseRequest(input: unknown): SkillsRequest {
|
|
32
29
|
if (typeof input !== "string")
|
|
33
30
|
throw new Error("skills expects a string command");
|
|
34
31
|
const offsetMatch = input.match(/\s+--offset\s+(\d+)\s*$/);
|
|
@@ -50,7 +47,10 @@ export function parseRequest(input: unknown): SkillsRequest {
|
|
|
50
47
|
function parseCommand(input: string): SkillRequest {
|
|
51
48
|
const parts = input.trim().split(/\s+/).filter(Boolean);
|
|
52
49
|
const [action, ...arguments_] = parts;
|
|
53
|
-
if (!action || action === "
|
|
50
|
+
if (!action || (action === "help" && arguments_.length === 0)) {
|
|
51
|
+
return { action: "help" };
|
|
52
|
+
}
|
|
53
|
+
if (action === "list") {
|
|
54
54
|
return { action: "list", categories: [...new Set(arguments_)] };
|
|
55
55
|
}
|
|
56
56
|
if (action === "read" && arguments_.length >= 1) {
|
|
@@ -73,9 +73,11 @@ function parseCommand(input: string): SkillRequest {
|
|
|
73
73
|
function formatCommand(commands: SkillRequest[]): string {
|
|
74
74
|
return commands
|
|
75
75
|
.map((group) =>
|
|
76
|
-
group.action === "
|
|
77
|
-
?
|
|
78
|
-
:
|
|
76
|
+
group.action === "help"
|
|
77
|
+
? "help"
|
|
78
|
+
: group.action === "list"
|
|
79
|
+
? ["list", ...group.categories].join(" ")
|
|
80
|
+
: ["read", group.name, ...group.selectors].join(" "),
|
|
79
81
|
)
|
|
80
82
|
.join("; ");
|
|
81
83
|
}
|
|
@@ -163,9 +165,11 @@ export function runSkills(
|
|
|
163
165
|
return boundedOutput(
|
|
164
166
|
request.commands
|
|
165
167
|
.map((command) =>
|
|
166
|
-
command.action === "
|
|
167
|
-
? formatSkillList(skills
|
|
168
|
-
:
|
|
168
|
+
command.action === "help"
|
|
169
|
+
? `Commands: list [category...] | read <skill> [skill-or-reference...] | help. Join commands with ;\n\n${formatSkillList(skills)}`
|
|
170
|
+
: command.action === "list"
|
|
171
|
+
? formatSkillList(skills, command.categories)
|
|
172
|
+
: readSkillPackage(skills, command.name, command.selectors),
|
|
169
173
|
)
|
|
170
174
|
.join("\n\n"),
|
|
171
175
|
request,
|
package/src/discovery.ts
CHANGED
|
@@ -173,10 +173,6 @@ function discoverDirectoryCatalog(root: string): DirectoryCatalog {
|
|
|
173
173
|
return { skills: sortSkills(skills), hiddenNames };
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
export function discoverSkills(root = defaultSkillsDir()): CatalogSkill[] {
|
|
177
|
-
return discoverDirectoryCatalog(root).skills;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
176
|
function loadedSkillCategory(
|
|
181
177
|
skill: LoadedSkill,
|
|
182
178
|
globalRoot: string,
|
package/src/tool.ts
CHANGED
|
@@ -10,10 +10,7 @@ import {
|
|
|
10
10
|
|
|
11
11
|
const SkillsParameters = Type.Object(
|
|
12
12
|
{
|
|
13
|
-
command: Type.String({
|
|
14
|
-
description:
|
|
15
|
-
"list [category...] | read <skill> [skill-or-reference...]; separate commands with ;",
|
|
16
|
-
}),
|
|
13
|
+
command: Type.Optional(Type.String({ description: "Omit for discovery" })),
|
|
17
14
|
},
|
|
18
15
|
{ additionalProperties: false },
|
|
19
16
|
);
|
|
@@ -26,6 +23,7 @@ export interface SkillsToolOptions {
|
|
|
26
23
|
}
|
|
27
24
|
|
|
28
25
|
export function prepareSkillsCodeModeInput(input: unknown): SkillsParameters {
|
|
26
|
+
if (input === undefined) return {};
|
|
29
27
|
if (typeof input !== "string")
|
|
30
28
|
throw new Error("skills expects a string command");
|
|
31
29
|
return { command: input };
|
|
@@ -42,7 +40,7 @@ export function createSkillsTool(options: SkillsToolOptions = {}) {
|
|
|
42
40
|
parameters: SkillsParameters,
|
|
43
41
|
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
44
42
|
const output = runSkills(
|
|
45
|
-
params.command,
|
|
43
|
+
params.command ?? "",
|
|
46
44
|
options.globalRoot ?? defaultSkillsDir(),
|
|
47
45
|
defaultSessionSkillsDir(ctx.cwd),
|
|
48
46
|
options.getLoadedSkills?.() ?? [],
|
package/tsconfig.json
CHANGED