@mrclrchtr/supi-skills 4.7.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.
Files changed (38) hide show
  1. package/README.md +46 -0
  2. package/node_modules/@mrclrchtr/supi-core/README.md +112 -0
  3. package/node_modules/@mrclrchtr/supi-core/package.json +76 -0
  4. package/node_modules/@mrclrchtr/supi-core/src/api.ts +40 -0
  5. package/node_modules/@mrclrchtr/supi-core/src/config/config.ts +201 -0
  6. package/node_modules/@mrclrchtr/supi-core/src/config/prompt-surface.ts +363 -0
  7. package/node_modules/@mrclrchtr/supi-core/src/config.ts +10 -0
  8. package/node_modules/@mrclrchtr/supi-core/src/context/context-provider-registry.ts +36 -0
  9. package/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +31 -0
  10. package/node_modules/@mrclrchtr/supi-core/src/context.ts +8 -0
  11. package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +287 -0
  12. package/node_modules/@mrclrchtr/supi-core/src/evidence-badge.ts +41 -0
  13. package/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +57 -0
  14. package/node_modules/@mrclrchtr/supi-core/src/index.ts +34 -0
  15. package/node_modules/@mrclrchtr/supi-core/src/llm.ts +201 -0
  16. package/node_modules/@mrclrchtr/supi-core/src/model-selection.ts +134 -0
  17. package/node_modules/@mrclrchtr/supi-core/src/path-utils.ts +44 -0
  18. package/node_modules/@mrclrchtr/supi-core/src/path.ts +2 -0
  19. package/node_modules/@mrclrchtr/supi-core/src/project-roots.ts +170 -0
  20. package/node_modules/@mrclrchtr/supi-core/src/project.ts +15 -0
  21. package/node_modules/@mrclrchtr/supi-core/src/prompt-surface.ts +4 -0
  22. package/node_modules/@mrclrchtr/supi-core/src/registry-utils.ts +93 -0
  23. package/node_modules/@mrclrchtr/supi-core/src/report.ts +121 -0
  24. package/node_modules/@mrclrchtr/supi-core/src/session-utils.ts +71 -0
  25. package/node_modules/@mrclrchtr/supi-core/src/session.ts +8 -0
  26. package/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +102 -0
  27. package/node_modules/@mrclrchtr/supi-core/src/settings/settings-schema.ts +453 -0
  28. package/node_modules/@mrclrchtr/supi-core/src/settings.ts +36 -0
  29. package/node_modules/@mrclrchtr/supi-core/src/spinner-frames.ts +11 -0
  30. package/node_modules/@mrclrchtr/supi-core/src/status-spinner.ts +68 -0
  31. package/node_modules/@mrclrchtr/supi-core/src/terminal.ts +60 -0
  32. package/package.json +64 -0
  33. package/src/extension.ts +9 -0
  34. package/src/skill-catalog.ts +153 -0
  35. package/src/skill-load-settings.ts +305 -0
  36. package/src/skill-model-invocation.ts +134 -0
  37. package/src/skill-settings.ts +400 -0
  38. package/src/skill-shortcut.ts +123 -0
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ <div align="center">
2
+ <a href="https://github.com/mrclrchtr/supi/tree/main/packages/supi-skills">
3
+ <img src="https://raw.githubusercontent.com/mrclrchtr/supi/main/packages/supi-skills/assets/social-preview.png" alt="SuPi Skills" width="100%">
4
+ </a>
5
+ </div>
6
+
7
+ # @mrclrchtr/supi-skills
8
+
9
+ Adds scoped skill controls and `$skill-name` input shortcuts to the [PI coding agent](https://github.com/earendil-works/pi).
10
+
11
+ ## Install
12
+
13
+ Install the shared settings UI and this package:
14
+
15
+ ```bash
16
+ pi install npm:@mrclrchtr/supi-settings
17
+ pi install npm:@mrclrchtr/supi-skills
18
+ ```
19
+
20
+ For local development:
21
+
22
+ ```bash
23
+ pi install ./packages/supi-skills
24
+ ```
25
+
26
+ ## Skill controls
27
+
28
+ `/supi-settings` includes a searchable **Skills** section. Each skill has one of these effective states:
29
+
30
+ - **Enabled** — PI loads the skill, and the model can invoke it.
31
+ - **Model invocation disabled** — PI loads the skill for explicit user commands but omits it from the model's skill catalog.
32
+ - **Disabled** — PI does not load the skill or its command.
33
+
34
+ Use `Tab` to switch between project and global scope. Project settings inherit global settings, and trusted project overrides take precedence. SuPi stores model-invocation preferences without changing `SKILL.md`; full load changes use PI resource settings and require `/reload`.
35
+
36
+ Skills that an extension adds only at runtime support Enabled and Model invocation disabled. PI does not provide a persistent load setting for these resources. PI exposes only the active source after a name collision, so disabling a static winner can reveal a runtime source after reload. The refreshed row then shows the runtime limitation.
37
+
38
+ ## Input shortcut
39
+
40
+ `$skill-name` expands to `/skill:skill-name`. Skill-only autocomplete is active while the cursor is in a `$...` token.
41
+
42
+ Installed skill names are captured at `session_start`. Use `/reload` after you add or remove skills.
43
+
44
+ ## Credit
45
+
46
+ The skill controls are inspired by [Whamp/pi-skill-toggle](https://github.com/Whamp/pi-skill-toggle). SuPi uses PI's resource interfaces and shared settings UI instead of the upstream custom overlay and theme configuration.
@@ -0,0 +1,112 @@
1
+ <div align="center">
2
+ <a href="https://github.com/mrclrchtr/supi/tree/main/packages/supi-core">
3
+ <img src="https://raw.githubusercontent.com/mrclrchtr/supi/main/packages/supi-core/assets/social-preview.png" alt="SuPi Core" width="100%">
4
+ </a>
5
+ </div>
6
+
7
+ # @mrclrchtr/supi-core
8
+
9
+ Shared infrastructure for SuPi extensions.
10
+
11
+ This is a **pure library** — it does not register any pi commands or tools. The `/supi-settings` command is now available through `@mrclrchtr/supi-settings`.
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ pnpm add @mrclrchtr/supi-core
17
+ ```
18
+
19
+ ## Package surfaces
20
+
21
+ - `@mrclrchtr/supi-core/api` — reusable helpers for other packages and extensions
22
+ - `@mrclrchtr/supi-core/report` — shared text/report rendering helpers for TUI and plain-text summaries
23
+
24
+ ## What you get from the API
25
+
26
+ ### Config helpers
27
+
28
+ - `loadSupiConfig()` — merged config with resolution order `defaults <- global <- project`
29
+ - `loadSupiConfigForScope()` — load one scope at a time for settings UIs
30
+ - `writeSupiConfig()` — persist values
31
+ - `removeSupiConfigKey()` — remove a key or override
32
+
33
+ Config file locations:
34
+
35
+ - global: `~/.pi/agent/supi/config.json`
36
+ - project: `.pi/supi/config.json`
37
+
38
+ ### Settings helpers
39
+
40
+ - `registerSettings(pi, module)` — register one canonical asynchronous settings module
41
+ - `defineConfigSettings(options)` — adapt a fixed SuPi config section to that module interface
42
+ - settings registry helpers and types for the `@mrclrchtr/supi-settings` configuration surface
43
+
44
+ ### Context helpers
45
+
46
+ - `wrapExtensionContext()` — wrap injected text in SuPi's `<extension-context>` tag
47
+
48
+ ### Shared registries
49
+
50
+ - context-provider registry for `/supi-context`
51
+ - debug-event registry for producers that want shared debug capture
52
+ - settings registry used by `/supi-settings`
53
+
54
+ ### Project and session helpers
55
+
56
+ - project-root detection and directory walking helpers such as `findProjectRoot()` and `walkProject()`
57
+ - active-branch session helper: `getActiveBranchEntries()`
58
+ - terminal helpers such as `formatTitle()`, `signalWaiting()`, and `signalDone()`
59
+
60
+ ### Report helpers
61
+
62
+ - `clampReportWidth()` — enforce a minimum readable report width
63
+ - `formatReportTitle()` / `formatSectionHeader()` — shared themed headers
64
+ - `formatDimLine()` / `formatKeyValueLine()` — common summary rows
65
+ - `formatOverflowHint()` — consistent preview-overflow hints
66
+ - `wrapReportText()` — ANSI-aware wrapped report blocks with optional indentation
67
+
68
+ ## Example
69
+
70
+ ```ts
71
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
72
+ import {
73
+ defineConfigSettings,
74
+ loadSupiConfig,
75
+ registerSettings,
76
+ wrapExtensionContext,
77
+ } from "@mrclrchtr/supi-core/api";
78
+
79
+ export default function myExtension(pi: ExtensionAPI) {
80
+ const defaults = { enabled: true };
81
+ const config = loadSupiConfig("my-extension", process.cwd(), defaults);
82
+
83
+ registerSettings(
84
+ pi,
85
+ defineConfigSettings({
86
+ id: "my-extension",
87
+ label: "My Extension",
88
+ section: "my-extension",
89
+ defaults,
90
+ fields: [
91
+ {
92
+ kind: "boolean" as const,
93
+ key: "enabled",
94
+ label: "Enabled",
95
+ },
96
+ ],
97
+ }),
98
+ );
99
+
100
+ const message = wrapExtensionContext("my-extension", "hello", {
101
+ enabled: config.enabled,
102
+ });
103
+ void message;
104
+ }
105
+ ```
106
+
107
+ ## Source
108
+
109
+ - `src/api.ts` — exported library surface
110
+ - `src/config.ts` — shared config loading and writing
111
+ - `src/settings/` — settings registry, schema, scope resolution, and persistence
112
+ - `src/report.ts` — shared text/report rendering helpers
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "@mrclrchtr/supi-core",
3
+ "version": "4.7.0",
4
+ "description": "Shared settings, configuration, reporting, and session infrastructure",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/mrclrchtr/supi.git",
9
+ "directory": "packages/supi-core"
10
+ },
11
+ "homepage": "https://github.com/mrclrchtr/supi/tree/main/packages/supi-core#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/mrclrchtr/supi/issues"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "keywords": [
19
+ "pi",
20
+ "pi-coding-agent",
21
+ "supi",
22
+ "extension-utils",
23
+ "settings",
24
+ "configuration"
25
+ ],
26
+ "type": "module",
27
+ "files": [
28
+ "src/**/*.ts",
29
+ "!__tests__"
30
+ ],
31
+ "peerDependencies": {
32
+ "@earendil-works/pi-ai": "*",
33
+ "@earendil-works/pi-coding-agent": "*",
34
+ "@earendil-works/pi-tui": "*",
35
+ "typebox": "*"
36
+ },
37
+ "peerDependenciesMeta": {
38
+ "@earendil-works/pi-ai": {
39
+ "optional": true
40
+ },
41
+ "@earendil-works/pi-coding-agent": {
42
+ "optional": true
43
+ },
44
+ "@earendil-works/pi-tui": {
45
+ "optional": true
46
+ },
47
+ "typebox": {
48
+ "optional": true
49
+ }
50
+ },
51
+ "devDependencies": {
52
+ "@types/node": "25.9.5",
53
+ "vitest": "4.1.10"
54
+ },
55
+ "main": "src/api.ts",
56
+ "exports": {
57
+ "./api": "./src/api.ts",
58
+ "./config": "./src/config.ts",
59
+ "./context": "./src/context.ts",
60
+ "./debug": "./src/debug-registry.ts",
61
+ "./evidence-badge": "./src/evidence-badge.ts",
62
+ "./footer-registry": "./src/footer-registry.ts",
63
+ "./llm": "./src/llm.ts",
64
+ "./model-selection": "./src/model-selection.ts",
65
+ "./package.json": "./package.json",
66
+ "./path": "./src/path.ts",
67
+ "./project": "./src/project.ts",
68
+ "./prompt-surface": "./src/prompt-surface.ts",
69
+ "./report": "./src/report.ts",
70
+ "./session": "./src/session.ts",
71
+ "./settings": "./src/settings.ts",
72
+ "./spinner-frames": "./src/spinner-frames.ts",
73
+ "./status-spinner": "./src/status-spinner.ts",
74
+ "./terminal": "./src/terminal.ts"
75
+ }
76
+ }
@@ -0,0 +1,40 @@
1
+ // supi-core — shared infrastructure for SuPi extensions.
2
+ // Provides XML context tag wrapping, unified config, prompt-surface resolution,
3
+ // and shared settings, reporting, and session utilities.
4
+ //
5
+ // Convenience barrel — re-exports all domain entry points.
6
+ // For lighter imports, use one of the domain subpaths directly
7
+ // (e.g. @mrclrchtr/supi-core/config, @mrclrchtr/supi-core/context).
8
+
9
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
10
+ export * from "./config.ts";
11
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
12
+ export * from "./context.ts";
13
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
14
+ export * from "./debug-registry.ts";
15
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
16
+ export * from "./evidence-badge.ts";
17
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
18
+ export * from "./footer-registry.ts";
19
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
20
+ export * from "./llm.ts";
21
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
22
+ export * from "./model-selection.ts";
23
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
24
+ export * from "./path.ts";
25
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
26
+ export * from "./project.ts";
27
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
28
+ export * from "./prompt-surface.ts";
29
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
30
+ export * from "./report.ts";
31
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
32
+ export * from "./session.ts";
33
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
34
+ export * from "./settings.ts";
35
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
36
+ export * from "./spinner-frames.ts";
37
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
38
+ export * from "./status-spinner.ts";
39
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
40
+ export * from "./terminal.ts";
@@ -0,0 +1,201 @@
1
+ // Shared config system for SuPi extensions.
2
+ //
3
+ // Global config: ~/.pi/agent/supi/config.json
4
+ // Project config: .pi/supi/config.json (relative to cwd)
5
+ // Resolution: hardcoded defaults ← global ← project
6
+
7
+ import * as fs from "node:fs";
8
+ import * as os from "node:os";
9
+ import * as path from "node:path";
10
+ import { CONFIG_DIR_NAME } from "@earendil-works/pi-coding-agent";
11
+
12
+ const GLOBAL_CONFIG_DIR = `${CONFIG_DIR_NAME}/agent/supi`;
13
+ const PROJECT_CONFIG_DIR = `${CONFIG_DIR_NAME}/supi`;
14
+ const CONFIG_FILE = "config.json";
15
+
16
+ function getGlobalConfigPath(homeDir?: string): string {
17
+ return path.join(homeDir ?? os.homedir(), GLOBAL_CONFIG_DIR, CONFIG_FILE);
18
+ }
19
+
20
+ function getProjectConfigPath(cwd: string): string {
21
+ return path.join(cwd, PROJECT_CONFIG_DIR, CONFIG_FILE);
22
+ }
23
+
24
+ /** Return the SuPi config file path for one scope. */
25
+ export function getSupiConfigPath(
26
+ scope: "global" | "project",
27
+ cwd: string,
28
+ options?: SupiConfigOptions,
29
+ ): string {
30
+ return scope === "global" ? getGlobalConfigPath(options?.homeDir) : getProjectConfigPath(cwd);
31
+ }
32
+
33
+ export function readJsonFile(filePath: string): Record<string, unknown> | null {
34
+ let content: string;
35
+ try {
36
+ content = fs.readFileSync(filePath, "utf-8");
37
+ } catch {
38
+ // ENOENT or permission error — silent, file may not exist
39
+ return null;
40
+ }
41
+
42
+ let parsed: unknown;
43
+ try {
44
+ parsed = JSON.parse(content);
45
+ } catch {
46
+ // biome-ignore lint/suspicious/noConsole: deliberate config parse warning
47
+ console.warn(`[supi-core] Failed to parse config file, ignoring: ${filePath}`);
48
+ return null;
49
+ }
50
+
51
+ if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
52
+ return parsed as Record<string, unknown>;
53
+ }
54
+
55
+ // biome-ignore lint/suspicious/noConsole: deliberate config parse warning
56
+ console.warn(`[supi-core] Config file root is not an object, ignoring: ${filePath}`);
57
+ return null;
58
+ }
59
+
60
+ function shallowMerge<T>(base: T, ...overrides: Array<Record<string, unknown> | null>): T {
61
+ let result = { ...base };
62
+ for (const override of overrides) {
63
+ if (!override) continue;
64
+ result = { ...result, ...override };
65
+ }
66
+ return result;
67
+ }
68
+
69
+ export interface SupiConfigOptions {
70
+ homeDir?: string;
71
+ }
72
+
73
+ /**
74
+ * Load and merge config for a given extension section.
75
+ *
76
+ * Resolution order: defaults ← global ← project
77
+ */
78
+ export function loadSupiConfig<T>(
79
+ section: string,
80
+ cwd: string,
81
+ defaults: T,
82
+ options?: SupiConfigOptions,
83
+ ): T {
84
+ const globalConfig = readJsonFile(getGlobalConfigPath(options?.homeDir));
85
+ const projectConfig = readJsonFile(getProjectConfigPath(cwd));
86
+
87
+ const globalSection = extractSection(globalConfig, section);
88
+ const projectSection = extractSection(projectConfig, section);
89
+
90
+ return shallowMerge(defaults, globalSection, projectSection);
91
+ }
92
+
93
+ /**
94
+ * Load config for a single scope only.
95
+ *
96
+ * Resolution order: defaults ← selected scope
97
+ *
98
+ * This is useful for settings UIs that need to show the raw values stored in
99
+ * one scope, rather than the effective merged config.
100
+ */
101
+ export function loadSupiConfigForScope<T>(
102
+ section: string,
103
+ cwd: string,
104
+ defaults: T,
105
+ options: { scope: "global" | "project" } & SupiConfigOptions,
106
+ ): T {
107
+ const config = readJsonFile(getSupiConfigPath(options.scope, cwd, { homeDir: options.homeDir }));
108
+
109
+ const scopedSection = extractSection(config, section);
110
+ return shallowMerge(defaults, scopedSection);
111
+ }
112
+
113
+ /** Load the raw object for one config section and one scope. */
114
+ export function loadSupiConfigSectionForScope(
115
+ section: string,
116
+ cwd: string,
117
+ options: { scope: "global" | "project" } & SupiConfigOptions,
118
+ ): Record<string, unknown> | null {
119
+ const config = readJsonFile(getSupiConfigPath(options.scope, cwd, { homeDir: options.homeDir }));
120
+ return extractSection(config, section);
121
+ }
122
+
123
+ export interface SupiConfigLocation {
124
+ section: string;
125
+ scope: "global" | "project";
126
+ cwd: string;
127
+ }
128
+
129
+ /**
130
+ * Write config values for a given extension section.
131
+ */
132
+ export function writeSupiConfig(
133
+ loc: SupiConfigLocation,
134
+ value: Record<string, unknown>,
135
+ options?: SupiConfigOptions,
136
+ ): void {
137
+ const configPath = getSupiConfigPath(loc.scope, loc.cwd, options);
138
+
139
+ const dir = path.dirname(configPath);
140
+ fs.mkdirSync(dir, { recursive: true });
141
+
142
+ const existing = readJsonFile(configPath) ?? {};
143
+ existing[loc.section] = {
144
+ ...((existing[loc.section] as Record<string, unknown>) ?? {}),
145
+ ...value,
146
+ };
147
+
148
+ fs.writeFileSync(configPath, `${JSON.stringify(existing, null, 2)}\n`, "utf-8");
149
+ }
150
+
151
+ /**
152
+ * Remove a key from a config section.
153
+ * Used by `interval default` to remove the project override.
154
+ */
155
+ export function removeSupiConfigKey(
156
+ loc: SupiConfigLocation,
157
+ key: string,
158
+ options?: SupiConfigOptions,
159
+ ): void {
160
+ const configPath = getSupiConfigPath(loc.scope, loc.cwd, options);
161
+
162
+ const existing = readJsonFile(configPath);
163
+ if (!existing) return;
164
+
165
+ const sectionData = existing[loc.section] as Record<string, unknown> | undefined;
166
+ if (!sectionData) return;
167
+
168
+ delete sectionData[key];
169
+
170
+ if (Object.keys(sectionData).length === 0) {
171
+ delete existing[loc.section];
172
+ }
173
+
174
+ const dir = path.dirname(configPath);
175
+ fs.mkdirSync(dir, { recursive: true });
176
+
177
+ const content = Object.keys(existing).length > 0 ? `${JSON.stringify(existing, null, 2)}\n` : "";
178
+
179
+ if (content) {
180
+ // Directory guaranteed to exist since we just read from it
181
+ fs.writeFileSync(configPath, content, "utf-8");
182
+ } else {
183
+ try {
184
+ fs.unlinkSync(configPath);
185
+ } catch {
186
+ // File may not exist
187
+ }
188
+ }
189
+ }
190
+
191
+ function extractSection(
192
+ config: Record<string, unknown> | null,
193
+ section: string,
194
+ ): Record<string, unknown> | null {
195
+ if (!config) return null;
196
+ const data = config[section];
197
+ if (typeof data === "object" && data !== null && !Array.isArray(data)) {
198
+ return data as Record<string, unknown>;
199
+ }
200
+ return null;
201
+ }