@spences10/pi-sqlite-tools 0.0.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/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # @spences10/pi-sqlite-tools
2
+
3
+ ## 0.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 3ef8d39: Add Omnisearch and SQLite prompt shims; refine destructive
8
+ confirmation for session-created files.
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 ADDED
@@ -0,0 +1,83 @@
1
+ # @spences10/pi-sqlite-tools
2
+
3
+ Pi extension that reminds the model to prefer `mcp-sqlite-tools` for
4
+ SQLite database work instead of raw `sqlite3` shell commands.
5
+
6
+ This package does **not** start the MCP server and does **not**
7
+ duplicate its tools. `mcp-sqlite-tools` remains the source of truth;
8
+ this extension only injects workflow guidance when SQLite MCP tools
9
+ are available.
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ pi install npm:@spences10/pi-sqlite-tools
15
+ ```
16
+
17
+ Local development from this monorepo:
18
+
19
+ ```bash
20
+ pnpm --filter @spences10/pi-sqlite-tools run build
21
+ pi install ./packages/pi-sqlite-tools
22
+ # or for one run only
23
+ pi -e ./packages/pi-sqlite-tools
24
+ ```
25
+
26
+ ## What it does
27
+
28
+ The extension injects a system reminder telling the model to use
29
+ `mcp-sqlite-tools` when working with SQLite files such as:
30
+
31
+ - `.db`
32
+ - `.sqlite`
33
+ - `.sqlite3`
34
+
35
+ It encourages the safer MCP workflow:
36
+
37
+ - open databases with `open_database`
38
+ - inspect structure with `database_info`, `list_tables`,
39
+ `describe_table`, and `export_schema`
40
+ - run reads with `execute_read_query`
41
+ - back up and use transactions before writes or schema changes
42
+ - close databases when finished
43
+
44
+ It adds no slash commands and no custom tools.
45
+
46
+ ## Example MCP config
47
+
48
+ `mcp-sqlite-tools` must be configured separately, for example in
49
+ `~/.pi/agent/mcp.json`:
50
+
51
+ ```json
52
+ {
53
+ "mcpServers": {
54
+ "mcp-sqlite-tools": {
55
+ "command": "npx",
56
+ "args": ["-y", "mcp-sqlite-tools"]
57
+ }
58
+ }
59
+ }
60
+ ```
61
+
62
+ ## Using from a custom harness
63
+
64
+ ```ts
65
+ import sqliteTools from '@spences10/pi-sqlite-tools';
66
+
67
+ // pass `sqliteTools` as an ExtensionFactory to your Pi runtime
68
+ ```
69
+
70
+ `my-pi` imports this package directly and enables it as the built-in
71
+ SQLite tools reminder.
72
+
73
+ ## Development
74
+
75
+ ```bash
76
+ pnpm --filter @spences10/pi-sqlite-tools run check
77
+ pnpm --filter @spences10/pi-sqlite-tools run test
78
+ pnpm --filter @spences10/pi-sqlite-tools run build
79
+ ```
80
+
81
+ ## License
82
+
83
+ MIT
@@ -0,0 +1,3 @@
1
+ import type { BeforeAgentStartEvent, ExtensionAPI } from '@mariozechner/pi-coding-agent';
2
+ export declare function should_inject_sqlite_tools_prompt(event: Pick<BeforeAgentStartEvent, 'systemPromptOptions'>): boolean;
3
+ export default function sqlite_tools(pi: ExtensionAPI): Promise<void>;
package/dist/index.js ADDED
@@ -0,0 +1,64 @@
1
+ const MCP_SQLITE_TOOL_PREFIX = 'mcp__mcp-sqlite-tools__';
2
+ const MCP_SQLITE_TOOL_SUFFIXES = new Set([
3
+ 'open_database',
4
+ 'create_database',
5
+ 'close_database',
6
+ 'list_databases',
7
+ 'database_info',
8
+ 'list_tables',
9
+ 'describe_table',
10
+ 'create_table',
11
+ 'drop_table',
12
+ 'backup_database',
13
+ 'vacuum_database',
14
+ 'execute_read_query',
15
+ 'execute_write_query',
16
+ 'execute_schema_query',
17
+ 'bulk_insert',
18
+ 'begin_transaction',
19
+ 'commit_transaction',
20
+ 'rollback_transaction',
21
+ 'export_schema',
22
+ 'import_schema',
23
+ ]);
24
+ function is_mcp_sqlite_tool(tool_name) {
25
+ if (tool_name.startsWith(MCP_SQLITE_TOOL_PREFIX))
26
+ return true;
27
+ const [, server_name, tool] = tool_name.split('__');
28
+ if (!server_name?.includes('sqlite') || !tool)
29
+ return false;
30
+ return MCP_SQLITE_TOOL_SUFFIXES.has(tool);
31
+ }
32
+ export function should_inject_sqlite_tools_prompt(event) {
33
+ const selected_tools = event.systemPromptOptions?.selectedTools;
34
+ return !selected_tools || selected_tools.some(is_mcp_sqlite_tool);
35
+ }
36
+ export default async function sqlite_tools(pi) {
37
+ pi.on('before_agent_start', async (event) => {
38
+ if (!should_inject_sqlite_tools_prompt(event))
39
+ return {};
40
+ return {
41
+ systemPrompt: event.systemPrompt +
42
+ `
43
+
44
+ ## SQLite database access via mcp-sqlite-tools
45
+
46
+ You have access to \`mcp-sqlite-tools\`, a gated MCP server for SQLite database work. Prefer it over raw \`sqlite3\`, Python SQLite scripts, or ad-hoc SQL through \`bash\` when inspecting or modifying SQLite files.
47
+
48
+ Use it when:
49
+ - The user asks to inspect, query, analyze, or modify \`.db\`, \`.sqlite\`, or \`.sqlite3\` files
50
+ - You need schema, tables, row counts, PRAGMAs, telemetry, analytics, or session data stored in SQLite
51
+ - You are tempted to run \`sqlite3 ...\` or write a one-off script solely to execute SQL
52
+
53
+ Preferred workflow:
54
+ - Open existing databases with \`mcp__mcp-sqlite-tools__open_database\`; use \`create_database\` only when explicitly creating a new database
55
+ - Discover structure with \`database_info\`, \`list_tables\`, \`describe_table\`, and \`export_schema\` before writing queries
56
+ - Use \`execute_read_query\` for \`SELECT\`, \`PRAGMA\`, and \`EXPLAIN\`; keep result limits small unless the user asks otherwise
57
+ - Before writes or schema changes, prefer \`backup_database\` and explicit transactions; use \`execute_write_query\` or \`execute_schema_query\` only when the intent is clear
58
+ - Close databases with \`close_database\` when finished
59
+
60
+ Use raw \`sqlite3\` or shell scripts only when MCP tools are unavailable or the user explicitly asks to bypass the MCP workflow. Do not bypass the MCP safety gates just to make destructive SQL easier.`,
61
+ };
62
+ });
63
+ }
64
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,MAAM,sBAAsB,GAAG,yBAAyB,CAAC;AAEzD,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAC;IACxC,eAAe;IACf,iBAAiB;IACjB,gBAAgB;IAChB,gBAAgB;IAChB,eAAe;IACf,aAAa;IACb,gBAAgB;IAChB,cAAc;IACd,YAAY;IACZ,iBAAiB;IACjB,iBAAiB;IACjB,oBAAoB;IACpB,qBAAqB;IACrB,sBAAsB;IACtB,aAAa;IACb,mBAAmB;IACnB,oBAAoB;IACpB,sBAAsB;IACtB,eAAe;IACf,eAAe;CACf,CAAC,CAAC;AAEH,SAAS,kBAAkB,CAAC,SAAiB;IAC5C,IAAI,SAAS,CAAC,UAAU,CAAC,sBAAsB,CAAC;QAAE,OAAO,IAAI,CAAC;IAE9D,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACpD,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IAC5D,OAAO,wBAAwB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,iCAAiC,CAChD,KAAyD;IAEzD,MAAM,cAAc,GAAG,KAAK,CAAC,mBAAmB,EAAE,aAAa,CAAC;IAChE,OAAO,CAAC,cAAc,IAAI,cAAc,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,YAAY,CAAC,EAAgB;IAC1D,EAAE,CAAC,EAAE,CACJ,oBAAoB,EACpB,KAAK,EAAE,KAA4B,EAAE,EAAE;QACtC,IAAI,CAAC,iCAAiC,CAAC,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QACzD,OAAO;YACN,YAAY,EACX,KAAK,CAAC,YAAY;gBAClB;;;;;;;;;;;;;;;;;;yMAkBoM;SACrM,CAAC;IACH,CAAC,CACD,CAAC;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@spences10/pi-sqlite-tools",
3
+ "version": "0.0.1",
4
+ "description": "Pi extension that reminds the model to prefer mcp-sqlite-tools for SQLite database work",
5
+ "keywords": [
6
+ "database",
7
+ "mcp",
8
+ "pi",
9
+ "pi-package",
10
+ "sqlite"
11
+ ],
12
+ "license": "MIT",
13
+ "author": "Scott Spence <me@scottspence.com>",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/spences10/my-pi.git",
17
+ "directory": "packages/pi-sqlite-tools"
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "README.md",
22
+ "CHANGELOG.md"
23
+ ],
24
+ "type": "module",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "default": "./dist/index.js"
29
+ }
30
+ },
31
+ "dependencies": {
32
+ "@mariozechner/pi-coding-agent": "^0.70.2"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "^25.6.0",
36
+ "typescript": "^6.0.0",
37
+ "vitest": "^4.1.5"
38
+ },
39
+ "engines": {
40
+ "node": ">=22.0.0"
41
+ },
42
+ "pi": {
43
+ "extensions": [
44
+ "./dist/index.js"
45
+ ]
46
+ },
47
+ "scripts": {
48
+ "build": "tsc -p tsconfig.build.json",
49
+ "check": "tsc --noEmit -p tsconfig.json",
50
+ "test": "vitest run"
51
+ }
52
+ }