@howaboua/pi-better-skills-tool 0.0.6 → 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 CHANGED
@@ -1,5 +1,16 @@
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
+
8
+ ## 0.0.7
9
+
10
+ - Better Skills now hides the skill catalog from Pi, Code Mode, and Notebook Mode prompts while preserving native `/skill:<name>` commands.
11
+
12
+ Remove `--no-skills` from launch wrappers or aliases. Separate catalog-clearing hooks are no longer needed.
13
+
3
14
  ## 0.0.6
4
15
 
5
16
  - Requires Pi 1.0.0 or later.
package/README.md CHANGED
@@ -8,31 +8,13 @@ Progressive skill discovery for Pi, Code Mode and Notebook Mode. The `skills` to
8
8
  pi install npm:@howaboua/pi-better-skills-tool
9
9
  ```
10
10
 
11
- Requires Pi 1.0.0 or newer. Install `@howaboua/pi-codex-conversion` 3.0.25 or newer too for Code Mode and Notebook Mode. The extension remains a normal Pi tool when Codex conversion is absent.
11
+ Requires Pi 1.0.0 or newer. Install `@howaboua/pi-codex-conversion` 3.0.43 or newer too for Code Mode and Notebook Mode. The extension remains a normal Pi tool when Codex conversion is absent.
12
12
 
13
- ## Start Pi without native skills
13
+ ## Start Pi normally
14
14
 
15
- This setup assumes agent sessions start with `--no-skills`. Pi then omits its native skill catalog from the initial prompt, while the `skills` tool owns progressive discovery. Without the flag, the extension still works but treats Pi's already-loaded catalog as authoritative.
15
+ Start Pi without `--no-skills`. Better Skills hides catalog advertising from the system prompt while preserving Pi's native `/skill:<name>` commands. The model discovers and reads the loaded catalog on demand through `skills`.
16
16
 
17
- Our wrapper adds `--no-skills` to agent sessions and passes every supplied Pi argument through unchanged. Package-management and configuration commands bypass the flag:
18
-
19
- ```zsh
20
- #!/usr/bin/env zsh
21
- set -euo pipefail
22
-
23
- real_pi="$HOME/.cache/.bun/bin/pi"
24
-
25
- case "${1-}" in
26
- install|remove|uninstall|update|list|config|auth)
27
- exec "$real_pi" "$@"
28
- ;;
29
- *)
30
- exec "$real_pi" --no-skills "$@"
31
- ;;
32
- esac
33
- ```
34
-
35
- Put the wrapper earlier on `PATH` than the real Pi executable. Change `real_pi` when Pi was installed somewhere other than Bun's global binary directory. Quoted `"$@"` preserves each argument exactly, including spaces and repeated flags.
17
+ Remove `--no-skills` from an existing wrapper or alias. An additional catalog-clearing `before_agent_start` hook is no longer needed.
36
18
 
37
19
  ## Use
38
20
 
package/index.ts CHANGED
@@ -21,7 +21,19 @@ export default async function skillsExtension(pi: ExtensionAPI): Promise<void> {
21
21
 
22
22
  let loadedSkills: readonly Skill[] = [];
23
23
  pi.on("before_agent_start", (event) => {
24
- loadedSkills = event.systemPromptOptions.skills ?? [];
24
+ const options = event.systemPromptOptions;
25
+ loadedSkills = [...options.skills];
26
+ // Native /skill: expansion uses Pi's loader, not these prompt fields.
27
+ options.skills = [];
28
+ delete options.sections["skills"];
29
+ delete options.sections["skill_catalog"];
30
+ if (options.forceSystemPrompt !== undefined) {
31
+ // Full-prompt overrides bypass sections. Preserve text outside catalog containers.
32
+ options.forceSystemPrompt = options.forceSystemPrompt.replace(
33
+ /<(skills|skill_catalog)>[\s\S]*?<\/\1>/g,
34
+ "",
35
+ );
36
+ }
25
37
  });
26
38
  const tool = createSkillsTool({ getLoadedSkills: () => loadedSkills });
27
39
  pi.registerTool(tool);
@@ -44,8 +56,7 @@ async function registerSkillsInCodeMode(
44
56
  adaptToolForCodeMode(tool, {
45
57
  kind: "freeform",
46
58
  prepareInput: prepareSkillsCodeModeInput,
47
- usage:
48
- 'await tools.skills("list") // list [category...] | read <skill> [skill-or-reference...]; join commands with ;',
59
+ usage: "await tools.skills() // discovery",
49
60
  }),
50
61
  ]);
51
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.6",
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 && bun run test",
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.43",
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.43",
53
+ "@howaboua/pi-codex-conversion": "3.0.48",
55
54
  "@biomejs/biome": "^2.5.10",
56
- "@earendil-works/pi-coding-agent": "1.0.0",
57
- "@earendil-works/pi-tui": "1.0.0",
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
- export function parseRequest(input: unknown): SkillsRequest {
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 === "list") {
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 === "list"
77
- ? ["list", ...group.categories].join(" ")
78
- : ["read", group.name, ...group.selectors].join(" "),
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 === "list"
167
- ? formatSkillList(skills, command.categories)
168
- : readSkillPackage(skills, command.name, command.selectors),
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
@@ -3,5 +3,5 @@
3
3
  "compilerOptions": {
4
4
  "lib": ["ESNext", "DOM"]
5
5
  },
6
- "include": ["index.ts", "src/**/*.ts", "tests/**/*.ts"]
6
+ "include": ["index.ts", "src/**/*.ts"]
7
7
  }