nomoreide 0.1.47 → 0.1.48

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 (42) hide show
  1. package/dist/core/config-store.d.ts +2 -0
  2. package/dist/core/config-store.js +12 -0
  3. package/dist/core/config-store.js.map +1 -1
  4. package/dist/core/db/driver.d.ts +59 -1
  5. package/dist/core/db/driver.js +60 -0
  6. package/dist/core/db/driver.js.map +1 -1
  7. package/dist/core/db/mysql-driver.d.ts +11 -5
  8. package/dist/core/db/mysql-driver.js +60 -4
  9. package/dist/core/db/mysql-driver.js.map +1 -1
  10. package/dist/core/db/postgres-driver.d.ts +12 -5
  11. package/dist/core/db/postgres-driver.js +55 -6
  12. package/dist/core/db/postgres-driver.js.map +1 -1
  13. package/dist/core/db/sqlite-driver.d.ts +8 -3
  14. package/dist/core/db/sqlite-driver.js +64 -3
  15. package/dist/core/db/sqlite-driver.js.map +1 -1
  16. package/dist/core/db-peek.d.ts +7 -1
  17. package/dist/core/db-peek.js +8 -0
  18. package/dist/core/db-peek.js.map +1 -1
  19. package/dist/core/db-write.d.ts +34 -0
  20. package/dist/core/db-write.js +72 -0
  21. package/dist/core/db-write.js.map +1 -0
  22. package/dist/core/types.d.ts +5 -0
  23. package/dist/core/workflows.d.ts +76 -6
  24. package/dist/core/workflows.js +18 -2
  25. package/dist/core/workflows.js.map +1 -1
  26. package/dist/mcp/tools/database.d.ts +4 -3
  27. package/dist/mcp/tools/database.js +67 -2
  28. package/dist/mcp/tools/database.js.map +1 -1
  29. package/dist/mcp/tools/index.d.ts +1 -1
  30. package/dist/web/client/assets/{code-editor-DOyUkvuQ.js → code-editor-DH7Sl3iw.js} +1 -1
  31. package/dist/web/client/assets/index-DWPlVWVN.js +211 -0
  32. package/dist/web/client/assets/index-vGzOmeUL.css +1 -0
  33. package/dist/web/client/index.html +2 -2
  34. package/dist/web/routes/context.d.ts +2 -0
  35. package/dist/web/routes/context.js.map +1 -1
  36. package/dist/web/routes/database-routes.js +57 -2
  37. package/dist/web/routes/database-routes.js.map +1 -1
  38. package/dist/web/server.js +3 -0
  39. package/dist/web/server.js.map +1 -1
  40. package/package.json +1 -1
  41. package/dist/web/client/assets/index-BpLowAcO.js +0 -204
  42. package/dist/web/client/assets/index-Df0RBiTt.css +0 -1
@@ -1,9 +1,37 @@
1
1
  import { z } from "zod";
2
+ import { isReadStatement } from "../../core/db/driver.js";
2
3
  import { stringify } from "./context.js";
4
+ /**
5
+ * Returned to the agent when a write hits the read-only query path. This is the
6
+ * contextual teach for the dock's write-staging convention — it costs nothing
7
+ * until the agent actually tries to change data, and tells it to reply with a
8
+ * `sql-write` block instead of executing or narrating console steps. The dock
9
+ * parses that block into an "Open in SQL console" button (see the web client's
10
+ * `chat/message-options.tsx`); the write still goes through the human-only
11
+ * console with its unlock + affected-rows preview.
12
+ */
13
+ function writeStagingGuidance(connection) {
14
+ return [
15
+ "This connection is read-only, so that statement was NOT executed.",
16
+ "Don't run it here, and don't tell the user to open the console and type it",
17
+ "themselves. Instead reply with the exact statement in a fenced block tagged",
18
+ "`sql-write` followed by the connection name:",
19
+ "",
20
+ "```sql-write " + connection,
21
+ "UPDATE … SET … WHERE …;",
22
+ "```",
23
+ "",
24
+ "NoMoreIDE turns that into an \"Open in SQL console\" button that stages the",
25
+ "statement in the human-only write console, where the user unlocks writes and",
26
+ "reviews an affected-rows preview before committing. Emit exactly one",
27
+ "statement, and always scope UPDATE/DELETE with a WHERE clause.",
28
+ ].join("\n");
29
+ }
3
30
  export const DATABASE_TOOL_NAMES = [
4
31
  "nomoreide_list_databases",
5
32
  "nomoreide_db_tables",
6
33
  "nomoreide_db_sample",
34
+ "nomoreide_db_query",
7
35
  ];
8
36
  const connectionSchema = z.object({
9
37
  connection: z
@@ -24,9 +52,23 @@ const sampleSchema = connectionSchema.extend({
24
52
  .optional()
25
53
  .describe("Max rows to sample (default 100)."),
26
54
  });
55
+ const querySchema = connectionSchema.extend({
56
+ sql: z
57
+ .string()
58
+ .min(1)
59
+ .describe("A read-only SELECT-style statement. Writes are rejected server-side."),
60
+ limit: z
61
+ .number()
62
+ .int()
63
+ .positive()
64
+ .max(1000)
65
+ .optional()
66
+ .describe("Max rows to return (default 100)."),
67
+ });
27
68
  /**
28
- * DB Peek tools: read-only browsing of the user's registered database
29
- * connections. Scoped to connections in ConfigStore no arbitrary SQL.
69
+ * DB Peek tools: read-only access to the user's registered database
70
+ * connections. Scoped to connections in ConfigStore; `nomoreide_db_query` runs
71
+ * SQL inside a read-only transaction, so writes are rejected by the server.
30
72
  */
31
73
  export function registerDatabaseTools(server, ctx) {
32
74
  const { dbPeek } = ctx;
@@ -48,5 +90,28 @@ export function registerDatabaseTools(server, ctx) {
48
90
  parameters: sampleSchema,
49
91
  execute: async ({ connection, table, limit }) => stringify(await dbPeek.sampleRows(connection, table, limit ?? 100)),
50
92
  });
93
+ server.addTool({
94
+ name: "nomoreide_db_query",
95
+ description: "Run a read-only SQL query against a registered connection and return the rows. " +
96
+ "Read-only at the transaction level — INSERT/UPDATE/DELETE/DDL are rejected. To " +
97
+ "make a change, don't run it here and don't tell the user to open the console " +
98
+ "by hand: reply with the statement in a ```sql-write <connection>``` fenced " +
99
+ "block, which the dock renders as an 'Open in SQL console' button to review and run.",
100
+ parameters: querySchema,
101
+ execute: async ({ connection, sql, limit }) => {
102
+ try {
103
+ return stringify(await dbPeek.runQuery(connection, sql, limit ?? 100));
104
+ }
105
+ catch (caught) {
106
+ const message = caught instanceof Error ? caught.message : String(caught);
107
+ // A write rejected by the read-only transaction (every engine phrases it
108
+ // with "read only/readonly") becomes a teach, not a bare error.
109
+ if (/read[\s-]?only/i.test(message) || !isReadStatement(sql)) {
110
+ return writeStagingGuidance(connection);
111
+ }
112
+ throw caught;
113
+ }
114
+ },
115
+ });
51
116
  }
52
117
  //# sourceMappingURL=database.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"database.js","sourceRoot":"","sources":["../../../src/mcp/tools/database.ts"],"names":[],"mappings":"A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KACjD,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC;QACb,IAAI,EAAE,qBAAqB;QAC3B,WAAW,EACT,6GAA6G;QAC/G,UAAU,EAAE,YAAY;QACxB,OAAO,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAC9C,SAAS,CAAC,MAAM,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC;KACtE,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC;QACb,IAAI,EAAE,oBAAoB;QAC1B,WAAW,EACT,iFAAiF;YACjF,iFAAiF;YACjF,+EAA+E;YAC/E,6EAA6E;YAC7E,qFAAqF;QACvF,UAAU,EAAE,WAAW;QACvB,OAAO,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE;YAC5C,IAAI,CAAC;gBACH,OAAO,SAAS,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC;YACzE,CAAC;YAAC,OAAO,MAAM,EAAE,CAAC;gBAChB,MAAM,OAAO,GAAG,MAAM,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBAC1E,yEAAyE;gBACzE,gEAAgE;gBAChE,IAAI,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC;oBAC7D,OAAO,oBAAoB,CAAC,UAAU,CAAC,CAAC;gBAC1C,CAAC;gBACD,MAAM,MAAM,CAAC;YACf,CAAC;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -9,7 +9,7 @@ import { type ToolContext } from "./context.js";
9
9
  * a new domain module and register it below. This aggregator never grows a
10
10
  * per-tool branch.
11
11
  */
12
- export declare const NOMOREIDE_TOOL_NAMES: readonly ["nomoreide_list_services", "nomoreide_register_service", "nomoreide_start_service", "nomoreide_stop_service", "nomoreide_restart_service", "nomoreide_read_logs", "nomoreide_register_bundle", "nomoreide_start_bundle", "nomoreide_stop_bundle", "nomoreide_status", "nomoreide_service_context", "nomoreide_service_health", "nomoreide_timeline", "nomoreide_onboard_repo", "nomoreide_git_status", "nomoreide_git_branches", "nomoreide_git_switch_branch", "nomoreide_git_create_branch", "nomoreide_git_fetch", "nomoreide_git_diff", "nomoreide_git_staged_diff", "nomoreide_git_log", "nomoreide_git_stage", "nomoreide_git_unstage", "nomoreide_git_commit", "nomoreide_git_push", "nomoreide_git_register_repository", "nomoreide_git_select_repository", "nomoreide_github_set_token", "nomoreide_github_list_prs", "nomoreide_github_get_pr", "nomoreide_github_get_pr_diff", "nomoreide_github_create_pr", "nomoreide_github_merge_pr", "nomoreide_github_list_issues", "nomoreide_github_get_issue", "nomoreide_github_list_issue_comments", "nomoreide_github_add_issue_comment", "nomoreide_github_create_issue", "nomoreide_github_get_commit_ci", "nomoreide_github_list_workflow_runs", "nomoreide_list_errors", "nomoreide_error_prompt", "nomoreide_list_databases", "nomoreide_db_tables", "nomoreide_db_sample", "nomoreide_docs", "nomoreide_open_ui", "nomoreide_close_ui"];
12
+ export declare const NOMOREIDE_TOOL_NAMES: readonly ["nomoreide_list_services", "nomoreide_register_service", "nomoreide_start_service", "nomoreide_stop_service", "nomoreide_restart_service", "nomoreide_read_logs", "nomoreide_register_bundle", "nomoreide_start_bundle", "nomoreide_stop_bundle", "nomoreide_status", "nomoreide_service_context", "nomoreide_service_health", "nomoreide_timeline", "nomoreide_onboard_repo", "nomoreide_git_status", "nomoreide_git_branches", "nomoreide_git_switch_branch", "nomoreide_git_create_branch", "nomoreide_git_fetch", "nomoreide_git_diff", "nomoreide_git_staged_diff", "nomoreide_git_log", "nomoreide_git_stage", "nomoreide_git_unstage", "nomoreide_git_commit", "nomoreide_git_push", "nomoreide_git_register_repository", "nomoreide_git_select_repository", "nomoreide_github_set_token", "nomoreide_github_list_prs", "nomoreide_github_get_pr", "nomoreide_github_get_pr_diff", "nomoreide_github_create_pr", "nomoreide_github_merge_pr", "nomoreide_github_list_issues", "nomoreide_github_get_issue", "nomoreide_github_list_issue_comments", "nomoreide_github_add_issue_comment", "nomoreide_github_create_issue", "nomoreide_github_get_commit_ci", "nomoreide_github_list_workflow_runs", "nomoreide_list_errors", "nomoreide_error_prompt", "nomoreide_list_databases", "nomoreide_db_tables", "nomoreide_db_sample", "nomoreide_db_query", "nomoreide_docs", "nomoreide_open_ui", "nomoreide_close_ui"];
13
13
  interface RegisterNoMoreIdeToolsOptions extends ToolContext {
14
14
  server: FastMCP;
15
15
  toolCallStore?: ToolCallStore;