@spences10/pi-tool-guidance 0.0.0-stage → 0.1.1

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 Scott Spence
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,137 @@
1
- # Temporary Holding Version
1
+ # @spences10/pi-tool-guidance
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
+ <!-- package-readme:header:start -->
4
+
5
+ [![built with Vite+](https://img.shields.io/badge/built%20with-Vite+-646CFF?logo=vite&logoColor=white)](https://viteplus.dev)
6
+ [![tested with Vitest](https://img.shields.io/badge/tested%20with-Vitest-6E9F18?logo=vitest&logoColor=white)](https://vitest.dev)
7
+ [![npm version](https://img.shields.io/npm/v/@spences10/pi-tool-guidance?color=CB3837&logo=npm&logoColor=white)](https://www.npmjs.com/package/@spences10/pi-tool-guidance)
8
+ [![license](https://img.shields.io/npm/l/@spences10/pi-tool-guidance)](https://www.npmjs.com/package/@spences10/pi-tool-guidance)
9
+
10
+ ![my-pi package preview](https://raw.githubusercontent.com/spences10/my-pi/main/assets/pi-package-preview.png)
11
+
12
+ <!-- package-readme:header:end -->
13
+
14
+ ## Tool workflow guidance
15
+
16
+ Distributes native Pi skills and concise system-prompt reminders for
17
+ nopeek, Omnisearch, SQLite, and language-aware validation. It does not
18
+ depend on the maintainer's local files.
19
+
20
+ ## What ships
21
+
22
+ - `my-pi-nopeek`: one-shot credential loading, explicit key
23
+ allowlists, separate-shell limitations, and output disclosure
24
+ precautions.
25
+ - `my-pi-omnisearch`: tool discovery, source extraction, and verified
26
+ research.
27
+ - `my-pi-sqlite`: schema inspection, bounded queries, backups,
28
+ transactions, and respecting database safety gates.
29
+
30
+ Pi advertises these native skills and loads their full contents on
31
+ demand. Invoke `/skill:my-pi-nopeek`, `/skill:my-pi-omnisearch`, or
32
+ `/skill:my-pi-sqlite` to request one explicitly.
33
+
34
+ Essential reminders are contributed through a named structured prompt
35
+ section. Secret guidance is active with shell access; MCP guidance is
36
+ conditional on reachable tools or Pi's configured indirect-server
37
+ listing. Both codemode and tool-search exposure work without requiring
38
+ direct tool declarations.
39
+
40
+ ## Language-aware validation
41
+
42
+ When editing and shell tools are reachable, the prompt reminds the
43
+ agent to use the project's configured linter, type checker, Svelte
44
+ tooling, and tests for code correctness. Coding-preference regexes
45
+ remain workflow/text policies; Svelte guardrails block `$effect` by
46
+ default, with explicit user-controlled exceptions. No parser,
47
+ classifier gate, new validation tool, or automatic command execution
48
+ is added.
49
+
50
+ Use native Codemode to coordinate existing tools:
51
+
52
+ 1. Read project instructions and package scripts to select the
53
+ affected checks; do not assume every project uses the same
54
+ commands.
55
+ 2. Apply edits through `tools.edit()` / `tools.write()` and await them
56
+ before checking. Native nested calls retain the same guardrail
57
+ hooks as direct calls; do not scan the outer JavaScript as source
58
+ code.
59
+ 3. Run independent checks together only when they do not share mutable
60
+ outputs. Keep dependent edits, builds, and checks sequential.
61
+ 4. Inspect exit codes and tool errors, then summarize diagnostics. Do
62
+ not infer success from a fulfilled promise: `bash` resolves even
63
+ when its command exits nonzero.
64
+ 5. Correct the findings and rerun affected checks before reporting
65
+ completion. Code validation runs after the edit; it is not an
66
+ atomic pre-write security boundary.
67
+
68
+ For example, after choosing this repository's `check` script:
69
+
70
+ ```js
71
+ const result = await tools.bash({
72
+ command: 'pnpm run check',
73
+ timeout: 120,
74
+ });
75
+ text({
76
+ exit_code: result.exit_code,
77
+ truncated: result.truncated,
78
+ output: result.output.slice(-12000),
79
+ full_output_path: result.full_output_path,
80
+ });
81
+ if (result.exit_code !== 0) throw new Error('Project checks failed');
82
+ ```
83
+
84
+ Inspect omitted output before diagnosing a failure. For multiple
85
+ independent tool calls, `Promise.allSettled()` preserves successful
86
+ results when another call rejects; inspect each result as well as each
87
+ command's exit code. Codemode is orchestration, not a syntax checker
88
+ or a way around guardrails. No classifier or paid model call is
89
+ needed.
90
+
91
+ ## User configuration remains yours
92
+
93
+ The package does not install the nopeek CLI, start MCP servers, set
94
+ provider credentials, or modify `SYSTEM.md`, `APPEND_SYSTEM.md`, or
95
+ `mcp.json`. Configure the required tools through Pi's normal
96
+ mechanisms. Native prompt files coexist with the package's section;
97
+ disabling this extension removes its bundled resources on reload in
98
+ my-pi.
99
+
100
+ Instructions are guidance, not a security boundary. Child processes
101
+ can still print secrets; redaction and database permission enforcement
102
+ remain separate. Third-party extensions that force a complete prompt
103
+ can hide later structured sections; prefer Pi's structured prompt API.
104
+
105
+ Bundled into my-pi as `tool-guidance`. Use
106
+ `/extensions disable tool-guidance` to remove its reminders and
107
+ bundled skills on reload. The package manifest exposes the same skills
108
+ in standalone Pi.
109
+
110
+ ## Install
111
+
112
+ <!-- package-readme:install:start -->
113
+
114
+ ```bash
115
+ pi install npm:@spences10/pi-tool-guidance
116
+ ```
117
+
118
+ <!-- package-readme:install:end -->
119
+
120
+ ## Development
121
+
122
+ <!-- package-readme:development:start commands="check,test,build" -->
123
+
124
+ Package scripts build transitive workspace dependencies first, then
125
+ run local tools through Vite+ with `vp exec`.
126
+
127
+ ```bash
128
+ pnpm --filter @spences10/pi-tool-guidance run check
129
+ pnpm --filter @spences10/pi-tool-guidance run test
130
+ pnpm --filter @spences10/pi-tool-guidance run build
131
+ ```
132
+
133
+ <!-- package-readme:development:end -->
134
+
135
+ ## License
136
+
137
+ MIT
@@ -0,0 +1,5 @@
1
+ import type { BuildSystemPromptOptions, ExtensionAPI } from '@earendil-works/pi-coding-agent';
2
+ type Tool = Pick<ReturnType<ExtensionAPI['getAllTools']>[number], 'name' | 'exposure' | 'namespace'>;
3
+ export declare function tool_guidance(options: BuildSystemPromptOptions, tools: readonly Tool[]): string;
4
+ export default function tool_guidance_extension(pi: ExtensionAPI): void;
5
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,56 @@
1
+ const NOPEEK_GUIDANCE = `## Secret-safe commands
2
+ Never read secret files or print credential values into model context. Read the bundled my-pi-nopeek skill before credential-dependent commands. Use one-shot nopeek run with only the required keys; separate Pi shells do not share loaded environment changes. Child-process output can still leak secrets; redaction is best-effort, not a guarantee.`;
3
+ const OMNISEARCH_GUIDANCE = `## Web research
4
+ For research and current external facts, prefer the configured Omnisearch MCP server. Read the bundled my-pi-omnisearch skill. Discover its actual tools with tool search or codemode, and read source content before presenting claims; snippets alone are not verification.`;
5
+ const SQLITE_GUIDANCE = `## SQLite databases
6
+ Prefer the configured SQLite MCP tools over ad-hoc shell SQL. Read the bundled my-pi-sqlite skill; inspect schema before querying, keep result limits small, and prefer a backup plus an explicit transaction before authorized writes. Do not bypass safety gates to make destructive operations easier.`;
7
+ const VALIDATION_GUIDANCE = `## Language-aware validation
8
+ Use the project's configured linter, type checker, Svelte tooling, and tests for naming and language correctness. Regex guardrails enforce workflow or explicit local policy, not syntax. After edits, run the affected checks. When codemode is available, use it to coordinate independent checks and summarize diagnostics; inspect command exit codes and tool errors before reporting success. Keep edits dependent on earlier results sequential.`;
9
+ export function tool_guidance(options, tools) {
10
+ const selected = options.selectedTools ?? [
11
+ 'read',
12
+ 'bash',
13
+ 'edit',
14
+ 'write',
15
+ ];
16
+ const indirect = selected.includes('codemode') || selected.includes('tool_search');
17
+ const reachable = tools.filter((tool) => tool.exposure !== 'hidden' &&
18
+ (selected.includes(tool.name) ||
19
+ (indirect &&
20
+ ['codemode', 'deferred'].includes(tool.exposure))));
21
+ const names = reachable
22
+ .flatMap((tool) => [
23
+ tool.name,
24
+ tool.namespace?.name ?? '',
25
+ ...(tool.namespace?.aliases ?? []),
26
+ ])
27
+ .join('\n');
28
+ // Pi lists configured indirect servers before their background connections complete.
29
+ const servers = indirect
30
+ ? (options.sections?.mcp_servers ?? '')
31
+ : '';
32
+ const available = `${names}\n${servers}`.toLowerCase();
33
+ const shell = selected.some((name) => ['bash', 'powershell'].includes(name)) ||
34
+ reachable.some((tool) => ['bash', 'powershell'].includes(tool.name));
35
+ const editing = selected.some((name) => ['edit', 'write'].includes(name)) ||
36
+ reachable.some((tool) => ['edit', 'write'].includes(tool.name));
37
+ return [
38
+ shell ? NOPEEK_GUIDANCE : '',
39
+ shell && editing ? VALIDATION_GUIDANCE : '',
40
+ available.includes('omnisearch') ? OMNISEARCH_GUIDANCE : '',
41
+ available.includes('sqlite') ? SQLITE_GUIDANCE : '',
42
+ ]
43
+ .filter(Boolean)
44
+ .join('\n\n');
45
+ }
46
+ export default function tool_guidance_extension(pi) {
47
+ pi.on('before_agent_start', (event) => {
48
+ const guidance = tool_guidance(event.systemPromptOptions, pi.getAllTools());
49
+ if (guidance)
50
+ event.systemPromptOptions.sections.my_pi_tool_guidance =
51
+ guidance;
52
+ else
53
+ delete event.systemPromptOptions.sections.my_pi_tool_guidance;
54
+ });
55
+ }
56
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceR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E,CAChB,CAAC;QACF,IAAI,QAAQ;YACX,KAAK,CAAC,mBAAmB,CAAC,QAAQ,CAAC,mBAAmB;gBACrD,QAAQ,CAAC;;YAEV,OAAO,KAAK,CAAC,mBAAmB,CAAC,QAAQ,CAAC,mBAAmB,CAAC;IAChE,CAAC,CAAC,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,65 @@
1
1
  {
2
2
  "name": "@spences10/pi-tool-guidance",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "description": "Packaged nopeek, Omnisearch and SQLite workflow guidance for Pi",
5
+ "keywords": [
6
+ "pi",
7
+ "pi-package"
8
+ ],
9
+ "homepage": "https://github.com/spences10/my-pi/tree/main/packages/pi-tool-guidance#readme",
10
+ "license": "MIT",
11
+ "author": "Scott Spence <me@scottspence.com>",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/spences10/my-pi.git",
15
+ "directory": "packages/pi-tool-guidance"
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "README.md",
20
+ "skills"
21
+ ],
22
+ "type": "module",
23
+ "main": "./dist/index.js",
24
+ "types": "./dist/index.d.ts",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "default": "./dist/index.js"
29
+ }
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "devDependencies": {
35
+ "@earendil-works/pi-coding-agent": "1.4.0",
36
+ "@types/node": "^26.0.0",
37
+ "typescript": "^7.0.0",
38
+ "vite-plus": "1.4.0"
39
+ },
40
+ "peerDependencies": {
41
+ "@earendil-works/pi-coding-agent": ">=1.4.0"
42
+ },
43
+ "engines": {
44
+ "node": ">=24.15.0"
45
+ },
46
+ "pi": {
47
+ "extensions": [
48
+ "./dist/index.js"
49
+ ],
50
+ "image": "https://raw.githubusercontent.com/spences10/my-pi/main/assets/pi-package-preview.png",
51
+ "skills": [
52
+ "./skills"
53
+ ]
54
+ },
55
+ "scripts": {
56
+ "build": "pnpm --filter \"$npm_package_name^...\" run build:self && pnpm run build:self",
57
+ "build:self": "vp exec tsc -p tsconfig.build.json",
58
+ "check": "pnpm --filter \"$npm_package_name^...\" run build:self && pnpm run check:self",
59
+ "check:self": "vp exec tsc --noEmit -p tsconfig.json",
60
+ "test": "pnpm --filter \"$npm_package_name^...\" run build:self && pnpm run test:self",
61
+ "test:self": "vp test run",
62
+ "coverage:self": "vp test run --coverage",
63
+ "coverage": "pnpm --filter \"$npm_package_name^...\" run build:self && pnpm run coverage:self"
64
+ }
6
65
  }
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: my-pi-nopeek
3
+ # prettier-ignore
4
+ description: Use when loading .env credentials, running authenticated commands, or keeping secret values out of Pi context.
5
+ compatibility: Requires Pi with shell access and the nopeek CLI.
6
+ ---
7
+
8
+ # Credential-dependent commands
9
+
10
+ Use the nopeek CLI to reduce accidental disclosure. This skill does
11
+ not install hooks, load credentials automatically, or guarantee safe
12
+ output.
13
+
14
+ 1. Inspect key names with `pnpx nopeek list` or `pnpx nopeek status`;
15
+ never read secret files into model context.
16
+ 2. In pnpm projects use `pnpx nopeek`; otherwise use `npx nopeek`.
17
+ 3. Prefer one-shot execution with an explicit key allowlist:
18
+
19
+ ```bash
20
+ pnpx nopeek run .env --only DATABASE_URL -- sh -c 'psql "$DATABASE_URL" -c "select 1"'
21
+ ```
22
+
23
+ 4. Keep variable expansion inside the child shell. Do not print keys,
24
+ run `env`/`printenv`, enable tracing, or place secret values in
25
+ arguments.
26
+ 5. Review what the child command prints: nopeek cannot prevent
27
+ arbitrary applications from leaking credentials through stdout or
28
+ stderr.
29
+ 6. Use `nopeek load` only with confirmed persistent harness injection,
30
+ or when loading and execution happen in the same trusted shell. A
31
+ source-file result does not persist into another Pi tool call.
32
+ 7. Use `pnpx nopeek audit` for exposure and gitignore checks.
33
+
34
+ Pi's redaction extension is a separate best-effort safety net, not a
35
+ security boundary. If secret output is unavoidable, stop and agree on
36
+ a safer workflow rather than exposing it.
37
+
38
+ The CLI must be available through the user's package runner or
39
+ installed locally. Do not change their credential storage or
40
+ configuration implicitly. See
41
+ [nopeek's threat model](https://github.com/spences10/nopeek#threat-model-and-non-goals).
@@ -0,0 +1,34 @@
1
+ ---
2
+ name: my-pi-omnisearch
3
+ # prettier-ignore
4
+ description: Use when researching current facts, verifying documentation, or finding sources with a configured Omnisearch MCP server.
5
+ compatibility: Requires Pi with a configured Omnisearch MCP server.
6
+ ---
7
+
8
+ # Verified web research
9
+
10
+ This skill supplies guidance, not an MCP server or provider
11
+ credentials. Use the user's configured integration; do not install or
12
+ configure one without authorization.
13
+
14
+ 1. Discover the actual namespace and tool names. In codemode use
15
+ `searchTools("web search")`, `describeNamespace(namespace)`, and
16
+ `describeTool(name)`; use tool search when that is the available
17
+ route. Never assume hyphenated server names are valid JavaScript
18
+ identifiers.
19
+ 2. Use `web_search` for discovery. Choose providers deliberately:
20
+ Tavily for factual/cited searches, Brave or Kagi for operators, and
21
+ Exa for semantic discovery, when those providers are available.
22
+ 3. Use `web_extract` to read actual source content before making
23
+ claims. Search snippets alone are not verified evidence.
24
+ 4. Use `ai_search` when a synthesis with sources helps; verify
25
+ important claims against those sources.
26
+ 5. Prefer official documentation, repositories, release notes, and
27
+ source. State source conflicts, uncertainty, and partial tool
28
+ failures.
29
+ 6. In codemode inspect MCP `isError` results, not just promise
30
+ resolution.
31
+
32
+ If the server is unavailable, say so and use an available research
33
+ tool without claiming Omnisearch verified the result. Never invent
34
+ sources.
@@ -0,0 +1,35 @@
1
+ ---
2
+ name: my-pi-sqlite
3
+ # prettier-ignore
4
+ description: Use when inspecting, querying, or modifying SQLite databases through a configured SQLite MCP server.
5
+ compatibility: Requires Pi with a configured SQLite MCP server.
6
+ ---
7
+
8
+ # SQLite workflow
9
+
10
+ This skill does not install an MCP server, open databases
11
+ automatically, or authorize writes. Keep the user's server
12
+ configuration and permissions.
13
+
14
+ 1. Discover actual tool names with codemode `searchTools("SQLite")`,
15
+ `describeNamespace(namespace)`, and `describeTool(name)`, or tool
16
+ search.
17
+ 2. Use `open_database` for existing files. Use `create_database` only
18
+ when creating a database is explicitly intended.
19
+ 3. Inspect with `database_info`, `list_tables`, `describe_table`, or
20
+ `export_schema` before constructing queries.
21
+ 4. Use `execute_read_query` for SELECT, PRAGMA, and EXPLAIN. Keep
22
+ limits small, avoid selecting credential columns, and bound
23
+ model-visible output.
24
+ 5. Before authorized writes or schema changes, prefer
25
+ `backup_database` and an explicit transaction. Use
26
+ `execute_write_query` or `execute_schema_query` only when the
27
+ intent and affected data are clear.
28
+ 6. Commit only on success; roll back failed transactions. Close
29
+ databases with `close_database` when finished.
30
+ 7. In codemode inspect MCP `isError` results before continuing.
31
+
32
+ Prefer MCP over raw sqlite3 or one-off Python SQL scripts. Use a shell
33
+ fallback only when MCP is unavailable or the user explicitly requests
34
+ it, and retain the same backup, transaction, and approval precautions.
35
+ Never bypass MCP safety gates merely to make destructive SQL easier.