@dylanhalstead/pi-inline-skills 0.0.0-stage → 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dylan Halstead
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,34 @@
1
- # Temporary Holding Version
1
+ # Inline skills
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Autocomplete `$skill-name` mentions and turn them into file references to skills
4
+ Pi has already discovered.
5
+
6
+ I kept typing stuff like "use the engineering-standard skill" when I wanted to point
7
+ Pi at a specific skill. This adds Codex-style `$skill-name` completion with fuzzy
8
+ search, so I don't have to remember the file's path.
9
+
10
+ ## Install
11
+
12
+ ```sh
13
+ pi install npm:@dylanhalstead/pi-inline-skills
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ```text
19
+ use the $engineering-standard skill"
20
+ ```
21
+
22
+ Type `$` in the TUI editor to search discovered skills. On submission, `$name`
23
+ becomes a file reference such as `@/absolute/path/to/skill/SKILL.md`. Unknown
24
+ names stay unchanged. No configuration is needed.
25
+
26
+ The extension does not load skill instructions. The model decides whether to
27
+ read the referenced file (which it will almost always read).
28
+
29
+ ## Important limitations
30
+
31
+ - Mentions inside code fences are also replaced. Use `\$name` to keep a mention
32
+ literal; the backslash stays in the prompt.
33
+ - Absolute skill paths become part of the prompt and session transcript and are
34
+ sent to the selected model provider.
package/package.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "@dylanhalstead/pi-inline-skills",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Autocomplete inline $skill-name mentions as file references in Pi.",
5
+ "keywords": [
6
+ "pi-extension",
7
+ "pi-package"
8
+ ],
9
+ "homepage": "https://github.com/DylanHalstead/pi-extensions/tree/main/extensions/inline-skills#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/DylanHalstead/pi-extensions/issues"
12
+ },
13
+ "license": "MIT",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/DylanHalstead/pi-extensions.git",
17
+ "directory": "extensions/inline-skills"
18
+ },
19
+ "files": [
20
+ "src/index.ts",
21
+ "README.md",
22
+ "LICENSE"
23
+ ],
24
+ "type": "module",
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "peerDependencies": {
29
+ "@earendil-works/pi-coding-agent": "*",
30
+ "@earendil-works/pi-tui": "*"
31
+ },
32
+ "pi": {
33
+ "extensions": [
34
+ "./src/index.ts"
35
+ ]
36
+ },
37
+ "scripts": {
38
+ "check": "vp -C ../.. check extensions/inline-skills",
39
+ "typecheck": "vp check --no-fmt --no-lint .",
40
+ "test": "vp -C ../.. test extensions/inline-skills/src"
41
+ }
6
42
  }
package/src/index.ts ADDED
@@ -0,0 +1,92 @@
1
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+ import { type AutocompleteProvider, fuzzyFilter } from "@earendil-works/pi-tui";
3
+
4
+ // A word-like suffix must not turn a malformed reference into a shorter valid one.
5
+ const INLINE_SKILL = /(^|\s)\$([a-z0-9]+(?:[a-z0-9-]*[a-z0-9])?)(?=$|[^\p{L}\p{N}_-])/gu;
6
+ const INLINE_SKILL_PREFIX = /(?:^|\s)(\$[^\s$]*)$/;
7
+ // Match Pi file completion; its separator regex and formatter are not public exports.
8
+ const FILE_REFERENCE_SEPARATOR =
9
+ /(?:\s|(?=\p{Punctuation})[\p{Script_Extensions=Han}\p{Script_Extensions=Hiragana}\p{Script_Extensions=Katakana}\p{Script_Extensions=Hangul}\p{Script_Extensions=Bopomofo}]|[,.:;!?()[]{}“”‘’…—])/u;
10
+
11
+ function getSkills(pi: ExtensionAPI) {
12
+ return pi
13
+ .getCommands()
14
+ .filter((command) => command.source === "skill")
15
+ .map((command) => ({
16
+ name: command.name.slice("skill:".length),
17
+ path: command.sourceInfo.path,
18
+ description: command.description,
19
+ }));
20
+ }
21
+
22
+ function createAutocompleteProvider(
23
+ pi: ExtensionAPI,
24
+ current: AutocompleteProvider,
25
+ ): AutocompleteProvider {
26
+ return {
27
+ triggerCharacters: [...new Set([...(current.triggerCharacters ?? []), "$"])],
28
+ async getSuggestions(lines, cursorLine, cursorCol, options) {
29
+ const textBeforeCursor = (lines[cursorLine] ?? "").slice(0, cursorCol);
30
+ const prefix = textBeforeCursor.match(INLINE_SKILL_PREFIX)?.[1];
31
+ if (prefix === undefined) {
32
+ return current.getSuggestions(lines, cursorLine, cursorCol, options);
33
+ }
34
+
35
+ const items = fuzzyFilter(getSkills(pi), prefix.slice(1), (skill) => skill.name).map(
36
+ ({ name, description }) => ({
37
+ value: `$${name}`,
38
+ label: name,
39
+ ...(description === undefined ? {} : { description }),
40
+ }),
41
+ );
42
+ return items.length > 0 ? { items, prefix } : null;
43
+ },
44
+ applyCompletion(lines, cursorLine, cursorCol, item, prefix) {
45
+ if (!prefix.startsWith("$")) {
46
+ return current.applyCompletion(lines, cursorLine, cursorCol, item, prefix);
47
+ }
48
+ const currentLine = lines[cursorLine] ?? "";
49
+ const completedLines = [...lines];
50
+ completedLines[cursorLine] =
51
+ currentLine.slice(0, cursorCol - prefix.length) + item.value + currentLine.slice(cursorCol);
52
+ return {
53
+ lines: completedLines,
54
+ cursorLine,
55
+ cursorCol: cursorCol - prefix.length + item.value.length,
56
+ };
57
+ },
58
+ shouldTriggerFileCompletion(lines, cursorLine, cursorCol) {
59
+ return current.shouldTriggerFileCompletion?.(lines, cursorLine, cursorCol) ?? true;
60
+ },
61
+ };
62
+ }
63
+
64
+ export default function inlineSkills(pi: ExtensionAPI): void {
65
+ pi.on("session_start", (_event, ctx) => {
66
+ if (ctx.mode === "tui") {
67
+ ctx.ui.addAutocompleteProvider((current) => createAutocompleteProvider(pi, current));
68
+ }
69
+ });
70
+
71
+ pi.on("input", (event) => {
72
+ const skills = new Map(getSkills(pi).map((skill) => [skill.name, skill]));
73
+ const text = event.text.replace(
74
+ INLINE_SKILL,
75
+ (reference: string, whitespace: string, name: string) => {
76
+ const skill = skills.get(name);
77
+ if (!skill) return reference;
78
+ const path = skill.path;
79
+ const fileReference = FILE_REFERENCE_SEPARATOR.test(path) ? `@"${path}"` : `@${path}`;
80
+ return `${whitespace}${fileReference}`;
81
+ },
82
+ );
83
+
84
+ return text === event.text
85
+ ? { action: "continue" }
86
+ : {
87
+ action: "transform",
88
+ text,
89
+ ...(event.images === undefined ? {} : { images: event.images }),
90
+ };
91
+ });
92
+ }