os-dpt 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Paul Demick
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,125 @@
1
+ # os-dpt
2
+
3
+ A local, web-based SQL editor with a built-in chat-to-SQL agent — where the
4
+ agent's knowledge lives as **plain markdown files in your repo** that you can
5
+ read, diff, and revert.
6
+
7
+ You run it in your own working directory and use it from `localhost`. Your
8
+ queries and the agent's evolving understanding of your data are ordinary files,
9
+ version-controlled by git. Nothing about your data leaves your machine except
10
+ what you send to your LLM provider when you ask the agent a question.
11
+
12
+ ## Why
13
+
14
+ Good data agents are mostly about **context** — schema, business meaning, past
15
+ queries, and hard-won corrections. Most tools keep that context in a vendor's
16
+ database where you can't see it. os-dpt keeps every layer as a file you own:
17
+
18
+ - **Live schema** — introspected from the database on demand.
19
+ - **Curated docs** — `context/schemas.md`, `context/conventions.md`,
20
+ `context/feedback.md`: human- and agent-editable markdown, scoped per data
21
+ source.
22
+ - **Memory** — when the agent learns something durable (a clarified column, a
23
+ data-quality quirk, a correction), it writes it back to those files. Because
24
+ they're git-tracked, you see a diff for every change the agent makes to its
25
+ own understanding, and you can revert it.
26
+
27
+ The result is an agent whose "learning" is transparent and yours, not a black
28
+ box.
29
+
30
+ ## Quick start
31
+
32
+ ```bash
33
+ # In the directory you want as your workspace:
34
+ npx os-dpt
35
+ ```
36
+
37
+ This launches a local server on `127.0.0.1` and opens the editor in your
38
+ browser. On first run it creates a workspace (see below). Add a database
39
+ connection (Postgres to start), then open a worksheet or the chat panel.
40
+
41
+ You'll need an Anthropic API key for the agent — set it in **Settings → AI
42
+ providers**.
43
+
44
+ To install it globally instead:
45
+
46
+ ```bash
47
+ npm install -g os-dpt
48
+ os-dpt
49
+ ```
50
+
51
+ ### Options
52
+
53
+ ```
54
+ os-dpt [options]
55
+
56
+ --workspace <dir> Workspace directory (default: current directory)
57
+ --port <n> Preferred port (default: 3756, falls back if taken)
58
+ --no-open Don't open the browser automatically
59
+ -v, --version Print version
60
+ -h, --help Show this help
61
+ ```
62
+
63
+ ## Workspace layout
64
+
65
+ os-dpt treats your current directory as the workspace root (like `git` or
66
+ `npm`):
67
+
68
+ ```
69
+ <workspace>/
70
+ ├── .os-dpt/ # gitignored — encrypted credentials, cache, drafts
71
+ ├── worksheets/ # git-tracked .sql files, one per worksheet
72
+ ├── context/ # git-tracked agent memory (markdown), scoped per source
73
+ ├── connections.json # connection metadata (no secrets)
74
+ └── .gitignore # excludes .os-dpt/
75
+ ```
76
+
77
+ Anything sensitive lives in `.os-dpt/` and is gitignored. Anything worth
78
+ versioning — your queries and the agent's context — is plain text at the root.
79
+
80
+ If the directory isn't already a git repository, os-dpt runs `git init` so
81
+ worksheet/context history works out of the box.
82
+
83
+ ## How the agent works
84
+
85
+ A small, focused tool loop (see `server/agent/`):
86
+
87
+ - `get_schema` — introspect live tables/columns.
88
+ - `get_context` / `update_context` — read and write the markdown knowledge files.
89
+ - `run_sql` — execute SQL (read-only by default; see Security).
90
+ - `write_sql` — stage SQL into a worksheet for you to review and save.
91
+ - `render_chart` — draw a chart inline from query results.
92
+ - `ask_user_question` — pause and ask rather than guess.
93
+
94
+ ## Security
95
+
96
+ os-dpt is a **single-user, loopback-only** tool with no API authentication, and
97
+ the agent can run SQL against your database. **Connections are read-only by
98
+ default**; you opt into writes per connection. For the full trust model —
99
+ credential storage, the read-only guards, TLS behavior, and what gets sent to
100
+ your LLM provider — read [SECURITY.md](./SECURITY.md) before pointing it at
101
+ anything important.
102
+
103
+ ## Develop
104
+
105
+ Requires Node and pnpm. This is a pnpm monorepo (`client` + `server`).
106
+
107
+ ```bash
108
+ pnpm install
109
+ pnpm dev # Vite + Hono in parallel
110
+ pnpm typecheck # gate changes with this
111
+ ```
112
+
113
+ Run the app against a throwaway workspace so you never materialize personal
114
+ data in the repo:
115
+
116
+ ```bash
117
+ os-dpt --workspace ./dev-workspace
118
+ ```
119
+
120
+ See [CONTRIBUTING.md](./CONTRIBUTING.md) for design principles and how to add a
121
+ database driver.
122
+
123
+ ## License
124
+
125
+ [MIT](./LICENSE) © Paul Demick
package/bin/os-dpt.mjs ADDED
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env node
2
+ // `npx os-dpt` entrypoint. Boots the bundled server (which serves the built
3
+ // client on the same port), then opens the browser. The current working
4
+ // directory is treated as the workspace — like git/npm.
5
+
6
+ import { readFileSync } from "node:fs"
7
+ import path from "node:path"
8
+ import { fileURLToPath } from "node:url"
9
+
10
+ const here = path.dirname(fileURLToPath(import.meta.url))
11
+ const pkg = JSON.parse(readFileSync(path.join(here, "..", "package.json"), "utf8"))
12
+
13
+ const argv = process.argv.slice(2)
14
+ const has = (...flags) => flags.some((f) => argv.includes(f))
15
+
16
+ if (has("--help", "-h")) {
17
+ console.log(`os-dpt ${pkg.version} — local SQL editor with a chat-to-SQL agent
18
+
19
+ Usage:
20
+ os-dpt [options]
21
+
22
+ Options:
23
+ --workspace <dir> Workspace directory (default: current directory)
24
+ --port <n> Preferred port (default: 3756, falls back if taken)
25
+ --no-open Don't open the browser automatically
26
+ -v, --version Print version
27
+ -h, --help Show this help
28
+
29
+ The current directory becomes your workspace: worksheets/ and context/ are
30
+ git-tracked; secrets live in .os-dpt/ (gitignored).`)
31
+ process.exit(0)
32
+ }
33
+
34
+ if (has("--version", "-v")) {
35
+ console.log(pkg.version)
36
+ process.exit(0)
37
+ }
38
+
39
+ // startServer(argv) does the real arg parsing (--workspace, --no-open, --port).
40
+ // We pre-read --port here only to set process.env.PORT *before* importing the
41
+ // server bundle, since some config reads the env at module load.
42
+ const portIdx = argv.findIndex((a) => a === "--port")
43
+ if (portIdx !== -1 && argv[portIdx + 1]) {
44
+ process.env.PORT = argv[portIdx + 1]
45
+ }
46
+
47
+ const { startServer, openBrowser } = await import("../server/dist/index.mjs")
48
+
49
+ const boot = await startServer(argv)
50
+
51
+ console.log(`\n os-dpt is running`)
52
+ console.log(` ➜ ${boot.url}`)
53
+ console.log(` ➜ workspace: ${boot.workspace}`)
54
+ console.log(`\n Press Ctrl-C to stop.\n`)
55
+
56
+ if (!has("--no-open")) {
57
+ const opened = await openBrowser(boot.url)
58
+ if (!opened) console.log(` Open ${boot.url} in your browser.`)
59
+ }
60
+
61
+ const shutdown = async () => {
62
+ await boot.close()
63
+ process.exit(0)
64
+ }
65
+ process.on("SIGINT", shutdown)
66
+ process.on("SIGTERM", shutdown)
package/package.json ADDED
@@ -0,0 +1,81 @@
1
+ {
2
+ "name": "os-dpt",
3
+ "version": "0.0.1",
4
+ "description": "Local web-based SQL editor with a built-in chat-to-SQL AI agent.",
5
+ "type": "module",
6
+ "packageManager": "pnpm@10.30.3",
7
+ "license": "MIT",
8
+ "author": "Paul Demick",
9
+ "homepage": "https://github.com/pdemick/os-dpt#readme",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/pdemick/os-dpt.git"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/pdemick/os-dpt/issues"
16
+ },
17
+ "keywords": [
18
+ "sql",
19
+ "sql-editor",
20
+ "postgres",
21
+ "ai-agent",
22
+ "text-to-sql",
23
+ "chat-to-sql",
24
+ "local-first"
25
+ ],
26
+ "bin": {
27
+ "os-dpt": "bin/os-dpt.mjs"
28
+ },
29
+ "files": [
30
+ "bin/",
31
+ "server/dist/",
32
+ "LICENSE",
33
+ "README.md"
34
+ ],
35
+ "engines": {
36
+ "node": ">=20.12"
37
+ },
38
+ "scripts": {
39
+ "dev": "node ./scripts/dev.mjs",
40
+ "dev:client": "pnpm --dir client dev",
41
+ "dev:server": "pnpm --dir server dev",
42
+ "build": "pnpm run build:client && pnpm run build:server",
43
+ "build:client": "pnpm --dir client build",
44
+ "build:server": "node ./scripts/build-server.mjs",
45
+ "start": "node bin/os-dpt.mjs",
46
+ "typecheck": "pnpm -r typecheck",
47
+ "lint": "pnpm --dir client lint",
48
+ "prepublishOnly": "pnpm run build"
49
+ },
50
+ "dependencies": {
51
+ "@anthropic-ai/sdk": "^0.97.0",
52
+ "@hono/node-server": "^1.13.7",
53
+ "better-sqlite3": "^12.10.0",
54
+ "hono": "^4.12.28",
55
+ "keytar": "^7.9.0",
56
+ "pg": "^8.13.1"
57
+ },
58
+ "peerDependencies": {
59
+ "braintrust": "^3.11.0"
60
+ },
61
+ "peerDependenciesMeta": {
62
+ "braintrust": {
63
+ "optional": true
64
+ }
65
+ },
66
+ "devDependencies": {
67
+ "esbuild": "^0.25.12"
68
+ },
69
+ "pnpm": {
70
+ "overrides": {
71
+ "braintrust": "^3.20.0",
72
+ "@babel/core@<7.29.6": "^7.29.6",
73
+ "esbuild@>=0.27.3 <0.28.1": "0.28.1"
74
+ },
75
+ "onlyBuiltDependencies": [
76
+ "better-sqlite3",
77
+ "esbuild",
78
+ "keytar"
79
+ ]
80
+ }
81
+ }
@@ -0,0 +1 @@
1
+ import{r,R as x,L as d,j as f,A as p}from"./index-CdhII6ua.js";var N=({code:i,language:e,raw:a,className:u,startLine:n,lineNumbers:g,...m})=>{let{shikiTheme:l}=r.useContext(x),s=d(),[h,t]=r.useState(a);return r.useEffect(()=>{if(!s){t(a);return}let o=s.highlight({code:i,language:e,themes:l},c=>{t(c)});o&&t(o)},[i,e,l,s,a]),f.jsx(p,{className:u,language:e,lineNumbers:g,result:h,startLine:n,...m})};export{N as HighlightedCodeBlockBody};