From 2bad714b14dc588b6f9d97679a4f2fd464a40bad Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 29 Oct 2025 08:53:02 +0100 Subject: [PATCH 01/11] refactor: pull diagnostics --- crates/pgls_cli/src/commands/dblint.rs | 26 +++++++++- crates/pgls_lsp/src/server.rs | 2 +- crates/pgls_lsp/src/session.rs | 18 +++---- .../src/features/diagnostics.rs | 13 +++-- crates/pgls_workspace/src/workspace.rs | 29 +++++++---- crates/pgls_workspace/src/workspace/client.rs | 11 ++++- crates/pgls_workspace/src/workspace/server.rs | 20 ++++---- .../src/workspace/server.tests.rs | 41 ++++++++-------- crates/pgls_workspace/src/workspace_types.rs | 2 +- .../backend-jsonrpc/src/workspace.ts | 48 +++++++++++++++---- .../backend-jsonrpc/src/workspace.ts | 11 ++--- xtask/codegen/src/generate_bindings.rs | 14 +++++- 12 files changed, 158 insertions(+), 77 deletions(-) diff --git a/crates/pgls_cli/src/commands/dblint.rs b/crates/pgls_cli/src/commands/dblint.rs index fa88023ed..592d26a25 100644 --- a/crates/pgls_cli/src/commands/dblint.rs +++ b/crates/pgls_cli/src/commands/dblint.rs @@ -1,7 +1,11 @@ +use std::time::Instant; + use crate::cli_options::CliOptions; use crate::reporter::Report; use crate::{CliDiagnostic, CliSession, VcsIntegration}; use pgls_configuration::PartialConfiguration; +use pgls_diagnostics::Error; +use pgls_workspace::features::diagnostics::{PullDatabaseDiagnosticsParams, PullDiagnosticsResult}; pub fn dblint( mut session: CliSession, @@ -10,9 +14,27 @@ pub fn dblint( ) -> Result<(), CliDiagnostic> { let configuration = session.prepare_with_config(cli_options, cli_configuration)?; session.setup_workspace(configuration, VcsIntegration::Disabled)?; + let workspace = session.workspace(); + + let max_diagnostics = if cli_options.reporter.is_default() { + cli_options.max_diagnostics.into() + } else { + u32::MAX + }; + + let start = Instant::now(); + + let PullDiagnosticsResult { + diagnostics, + skipped_diagnostics, + } = workspace.pull_db_diagnostics(PullDatabaseDiagnosticsParams { max_diagnostics })?; - // TODO: Implement actual dblint logic here - let report = Report::new(vec![], std::time::Duration::new(0, 0), 0, None); + let report = Report::new( + diagnostics.into_iter().map(Error::from).collect(), + start.elapsed(), + skipped_diagnostics, + None, + ); session.report("dblint", cli_options, &report) } diff --git a/crates/pgls_lsp/src/server.rs b/crates/pgls_lsp/src/server.rs index 18f38f007..be1f4493e 100644 --- a/crates/pgls_lsp/src/server.rs +++ b/crates/pgls_lsp/src/server.rs @@ -457,7 +457,7 @@ impl ServerFactory { workspace_method!(builder, open_file); workspace_method!(builder, change_file); workspace_method!(builder, close_file); - workspace_method!(builder, pull_diagnostics); + workspace_method!(builder, pull_file_diagnostics); workspace_method!(builder, get_completions); workspace_method!(builder, register_project_folder); workspace_method!(builder, unregister_project_folder); diff --git a/crates/pgls_lsp/src/session.rs b/crates/pgls_lsp/src/session.rs index 9a983446b..6c46324bf 100644 --- a/crates/pgls_lsp/src/session.rs +++ b/crates/pgls_lsp/src/session.rs @@ -270,15 +270,15 @@ impl Session { let categories = RuleCategoriesBuilder::default().all(); let diagnostics: Vec = { - let result = - self.workspace - .pull_diagnostics(features::diagnostics::PullDiagnosticsParams { - path: pgls_path.clone(), - max_diagnostics: u64::MAX, - categories: categories.build(), - only: Vec::new(), - skip: Vec::new(), - })?; + let result = self.workspace.pull_file_diagnostics( + features::diagnostics::PullFileDiagnosticsParams { + path: pgls_path.clone(), + max_diagnostics: u32::MAX, + categories: categories.build(), + only: Vec::new(), + skip: Vec::new(), + }, + )?; result .diagnostics diff --git a/crates/pgls_workspace/src/features/diagnostics.rs b/crates/pgls_workspace/src/features/diagnostics.rs index 1684cd3a1..b5fd533d9 100644 --- a/crates/pgls_workspace/src/features/diagnostics.rs +++ b/crates/pgls_workspace/src/features/diagnostics.rs @@ -4,10 +4,10 @@ use pgls_fs::PgTPath; #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] -pub struct PullDiagnosticsParams { +pub struct PullFileDiagnosticsParams { pub path: PgTPath, pub categories: RuleCategories, - pub max_diagnostics: u64, + pub max_diagnostics: u32, pub only: Vec, pub skip: Vec, } @@ -16,6 +16,11 @@ pub struct PullDiagnosticsParams { #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] pub struct PullDiagnosticsResult { pub diagnostics: Vec, - pub errors: usize, - pub skipped_diagnostics: u64, + pub skipped_diagnostics: u32, +} + +#[derive(Debug, serde::Serialize, serde::Deserialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +pub struct PullDatabaseDiagnosticsParams { + pub max_diagnostics: u32, } diff --git a/crates/pgls_workspace/src/workspace.rs b/crates/pgls_workspace/src/workspace.rs index b7c45408a..7b2a67499 100644 --- a/crates/pgls_workspace/src/workspace.rs +++ b/crates/pgls_workspace/src/workspace.rs @@ -16,7 +16,9 @@ use crate::{ CodeActionsParams, CodeActionsResult, ExecuteStatementParams, ExecuteStatementResult, }, completions::{CompletionsResult, GetCompletionsParams}, - diagnostics::{PullDiagnosticsParams, PullDiagnosticsResult}, + diagnostics::{ + PullDatabaseDiagnosticsParams, PullDiagnosticsResult, PullFileDiagnosticsParams, + }, on_hover::{OnHoverParams, OnHoverResult}, }, }; @@ -98,9 +100,15 @@ pub struct UnregisterProjectFolderParams { pub trait Workspace: Send + Sync + RefUnwindSafe { /// Retrieves the list of diagnostics associated to a file - fn pull_diagnostics( + fn pull_file_diagnostics( &self, - params: PullDiagnosticsParams, + params: PullFileDiagnosticsParams, + ) -> Result; + + /// Retrieves the list of diagnostics associated to a database schema + fn pull_db_diagnostics( + &self, + params: PullDatabaseDiagnosticsParams, ) -> Result; /// Retrieves a list of available code_actions for a file/cursor_position @@ -214,13 +222,14 @@ impl<'app, W: Workspace + ?Sized> FileGuard<'app, W> { only: Vec, skip: Vec, ) -> Result { - self.workspace.pull_diagnostics(PullDiagnosticsParams { - path: self.path.clone(), - categories, - max_diagnostics: max_diagnostics.into(), - only, - skip, - }) + self.workspace + .pull_file_diagnostics(PullFileDiagnosticsParams { + path: self.path.clone(), + categories, + max_diagnostics: max_diagnostics.into(), + only, + skip, + }) } } diff --git a/crates/pgls_workspace/src/workspace/client.rs b/crates/pgls_workspace/src/workspace/client.rs index 70f7c20a3..4dd331c00 100644 --- a/crates/pgls_workspace/src/workspace/client.rs +++ b/crates/pgls_workspace/src/workspace/client.rs @@ -148,13 +148,20 @@ where self.request("pgt/get_file_content", params) } - fn pull_diagnostics( + fn pull_file_diagnostics( &self, - params: crate::features::diagnostics::PullDiagnosticsParams, + params: crate::features::diagnostics::PullFileDiagnosticsParams, ) -> Result { self.request("pgt/pull_diagnostics", params) } + fn pull_db_diagnostics( + &self, + params: crate::features::diagnostics::PullDatabaseDiagnosticsParams, + ) -> Result { + self.request("pgt/pull_db_diagnostics", params) + } + fn get_completions( &self, params: super::GetCompletionsParams, diff --git a/crates/pgls_workspace/src/workspace/server.rs b/crates/pgls_workspace/src/workspace/server.rs index eedbaed6d..ff023ec5b 100644 --- a/crates/pgls_workspace/src/workspace/server.rs +++ b/crates/pgls_workspace/src/workspace/server.rs @@ -36,7 +36,7 @@ use crate::{ CommandActionCategory, ExecuteStatementParams, ExecuteStatementResult, }, completions::{CompletionsResult, GetCompletionsParams, get_statement_for_completions}, - diagnostics::{PullDiagnosticsParams, PullDiagnosticsResult}, + diagnostics::{PullDiagnosticsResult, PullFileDiagnosticsParams}, on_hover::{OnHoverParams, OnHoverResult}, }, settings::{WorkspaceSettings, WorkspaceSettingsHandle, WorkspaceSettingsHandleMut}, @@ -425,9 +425,9 @@ impl Workspace for WorkspaceServer { } #[ignored_path(path=¶ms.path)] - fn pull_diagnostics( + fn pull_file_diagnostics( &self, - params: PullDiagnosticsParams, + params: PullFileDiagnosticsParams, ) -> Result { let settings = self.workspaces(); @@ -438,7 +438,6 @@ impl Workspace for WorkspaceServer { // we might want to return an error here in the future return Ok(PullDiagnosticsResult { diagnostics: Vec::new(), - errors: 0, skipped_diagnostics: 0, }); } @@ -670,19 +669,20 @@ impl Workspace for WorkspaceServer { diagnostics.retain(|d| !suppressions.is_suppressed(d)); diagnostics.extend(suppression_errors.into_iter().map(SDiagnostic::new)); - let errors = diagnostics - .iter() - .filter(|d| d.severity() == Severity::Error || d.severity() == Severity::Fatal) - .count(); - info!("Pulled {:?} diagnostic(s)", diagnostics.len()); Ok(PullDiagnosticsResult { diagnostics, - errors, skipped_diagnostics: 0, }) } + fn pull_db_diagnostics( + &self, + _params: crate::features::diagnostics::PullDatabaseDiagnosticsParams, + ) -> Result { + Ok(PullDiagnosticsResult::default()) + } + #[ignored_path(path=¶ms.path)] #[tracing::instrument(level = "debug", skip_all, fields( path = params.path.as_os_str().to_str(), diff --git a/crates/pgls_workspace/src/workspace/server.tests.rs b/crates/pgls_workspace/src/workspace/server.tests.rs index c5e2397d1..2cb786380 100644 --- a/crates/pgls_workspace/src/workspace/server.tests.rs +++ b/crates/pgls_workspace/src/workspace/server.tests.rs @@ -83,7 +83,7 @@ async fn test_diagnostics(test_db: PgPool) { .expect("Unable to open test file"); let diagnostics = workspace - .pull_diagnostics(crate::workspace::PullDiagnosticsParams { + .pull_file_diagnostics(crate::workspace::PullFileDiagnosticsParams { path: path.clone(), categories: RuleCategories::all(), max_diagnostics: 100, @@ -141,7 +141,7 @@ async fn test_syntax_error(test_db: PgPool) { .expect("Unable to open test file"); let diagnostics = workspace - .pull_diagnostics(crate::workspace::PullDiagnosticsParams { + .pull_file_diagnostics(crate::workspace::PullFileDiagnosticsParams { path: path.clone(), categories: RuleCategories::all(), max_diagnostics: 100, @@ -181,13 +181,14 @@ async fn correctly_ignores_files() { seect 1; "#; - let diagnostics_result = workspace.pull_diagnostics(crate::workspace::PullDiagnosticsParams { - path: path.clone(), - categories: RuleCategories::all(), - max_diagnostics: 100, - only: vec![], - skip: vec![], - }); + let diagnostics_result = + workspace.pull_file_diagnostics(crate::workspace::PullFileDiagnosticsParams { + path: path.clone(), + categories: RuleCategories::all(), + max_diagnostics: 100, + only: vec![], + skip: vec![], + }); assert!( diagnostics_result.is_ok_and(|res| res.diagnostics.is_empty() @@ -257,7 +258,7 @@ async fn test_dedupe_diagnostics(test_db: PgPool) { .expect("Unable to open test file"); let diagnostics = workspace - .pull_diagnostics(crate::workspace::PullDiagnosticsParams { + .pull_file_diagnostics(crate::workspace::PullFileDiagnosticsParams { path: path.clone(), categories: RuleCategories::all(), max_diagnostics: 100, @@ -322,7 +323,7 @@ async fn test_plpgsql_assign_composite_types(test_db: PgPool) { .expect("Unable to open test file"); let diagnostics = workspace - .pull_diagnostics(crate::workspace::PullDiagnosticsParams { + .pull_file_diagnostics(crate::workspace::PullFileDiagnosticsParams { path: path.clone(), categories: RuleCategories::all(), max_diagnostics: 100, @@ -376,7 +377,7 @@ async fn test_positional_params(test_db: PgPool) { .expect("Unable to open test file"); let diagnostics = workspace - .pull_diagnostics(crate::workspace::PullDiagnosticsParams { + .pull_file_diagnostics(crate::workspace::PullFileDiagnosticsParams { path: path.clone(), categories: RuleCategories::all(), max_diagnostics: 100, @@ -437,7 +438,7 @@ async fn test_disable_plpgsql_check(test_db: PgPool) { .expect("Unable to open test file"); let diagnostics = workspace - .pull_diagnostics(crate::workspace::PullDiagnosticsParams { + .pull_file_diagnostics(crate::workspace::PullFileDiagnosticsParams { path: path.clone(), categories: RuleCategories::all(), max_diagnostics: 100, @@ -469,7 +470,7 @@ async fn test_disable_plpgsql_check(test_db: PgPool) { }); let diagnostics = workspace - .pull_diagnostics(crate::workspace::PullDiagnosticsParams { + .pull_file_diagnostics(crate::workspace::PullFileDiagnosticsParams { path: path.clone(), categories: RuleCategories::all(), max_diagnostics: 100, @@ -529,7 +530,7 @@ async fn test_disable_typecheck(test_db: PgPool) { .expect("Unable to open test file"); let diagnostics = workspace - .pull_diagnostics(crate::workspace::PullDiagnosticsParams { + .pull_file_diagnostics(crate::workspace::PullFileDiagnosticsParams { path: path.clone(), categories: RuleCategories::all(), max_diagnostics: 100, @@ -562,7 +563,7 @@ async fn test_disable_typecheck(test_db: PgPool) { }); let diagnostics = workspace - .pull_diagnostics(crate::workspace::PullDiagnosticsParams { + .pull_file_diagnostics(crate::workspace::PullFileDiagnosticsParams { path: path.clone(), categories: RuleCategories::all(), max_diagnostics: 100, @@ -609,7 +610,7 @@ FOR NO KEY UPDATE; .expect("Unable to open test file"); let diagnostics = workspace - .pull_diagnostics(crate::workspace::PullDiagnosticsParams { + .pull_file_diagnostics(crate::workspace::PullFileDiagnosticsParams { path: path.clone(), categories: RuleCategories::all(), max_diagnostics: 100, @@ -670,7 +671,7 @@ async fn test_cstyle_comments(test_db: PgPool) { .expect("Unable to open test file"); let diagnostics = workspace - .pull_diagnostics(crate::workspace::PullDiagnosticsParams { + .pull_file_diagnostics(crate::workspace::PullFileDiagnosticsParams { path: path.clone(), categories: RuleCategories::all(), max_diagnostics: 100, @@ -730,7 +731,7 @@ async fn test_search_path_configuration(test_db: PgPool) { .expect("Unable to open test file"); let diagnostics_glob = workspace - .pull_diagnostics(crate::workspace::PullDiagnosticsParams { + .pull_file_diagnostics(crate::workspace::PullFileDiagnosticsParams { path: path_glob.clone(), categories: RuleCategories::all(), max_diagnostics: 100, @@ -776,7 +777,7 @@ async fn test_search_path_configuration(test_db: PgPool) { .expect("Unable to open test file"); let diagnostics_glob = workspace - .pull_diagnostics(crate::workspace::PullDiagnosticsParams { + .pull_file_diagnostics(crate::workspace::PullFileDiagnosticsParams { path: path_glob.clone(), categories: RuleCategories::all(), max_diagnostics: 100, diff --git a/crates/pgls_workspace/src/workspace_types.rs b/crates/pgls_workspace/src/workspace_types.rs index b902fad66..896109821 100644 --- a/crates/pgls_workspace/src/workspace_types.rs +++ b/crates/pgls_workspace/src/workspace_types.rs @@ -462,7 +462,7 @@ pub fn methods() -> [WorkspaceMethod; 9] { workspace_method!(is_path_ignored), workspace_method!(register_project_folder), workspace_method!(get_file_content), - workspace_method!(pull_diagnostics), + workspace_method!(pull_file_diagnostics), workspace_method!(get_completions), workspace_method!(update_settings), workspace_method!(open_file), diff --git a/packages/@postgres-language-server/backend-jsonrpc/src/workspace.ts b/packages/@postgres-language-server/backend-jsonrpc/src/workspace.ts index 24ea5d503..ad05d0c33 100644 --- a/packages/@postgres-language-server/backend-jsonrpc/src/workspace.ts +++ b/packages/@postgres-language-server/backend-jsonrpc/src/workspace.ts @@ -1,7 +1,7 @@ // Generated file, do not edit by hand, see `xtask/codegen` import type { Transport } from "./transport"; export interface IsPathIgnoredParams { - pgt_path: PgTPath; + pgls_path: PgTPath; } export interface PgTPath { /** @@ -27,7 +27,7 @@ export type ProjectKey = string; export interface GetFileContentParams { path: PgTPath; } -export interface PullDiagnosticsParams { +export interface PullFileDiagnosticsParams { categories: RuleCategories; max_diagnostics: number; only: RuleCode[]; @@ -39,7 +39,6 @@ export type RuleCode = string; export type RuleCategory = "Lint" | "Action" | "Transformation"; export interface PullDiagnosticsResult { diagnostics: Diagnostic[]; - errors: number; skipped_diagnostics: number; } /** @@ -63,6 +62,7 @@ export interface Advices { advices: Advice[]; } export type Category = + | "lint/safety/addSerialColumn" | "lint/safety/addingFieldWithDefault" | "lint/safety/addingForeignKeyConstraint" | "lint/safety/addingNotNullField" @@ -77,7 +77,10 @@ export type Category = | "lint/safety/banTruncateCascade" | "lint/safety/changingColumnType" | "lint/safety/constraintMissingNotValid" + | "lint/safety/creatingEnum" | "lint/safety/disallowUniqueConstraint" + | "lint/safety/lockTimeoutWarning" + | "lint/safety/multipleAlterTable" | "lint/safety/preferBigInt" | "lint/safety/preferBigintOverInt" | "lint/safety/preferBigintOverSmallint" @@ -90,6 +93,7 @@ export type Category = | "lint/safety/renamingTable" | "lint/safety/requireConcurrentIndexCreation" | "lint/safety/requireConcurrentIndexDeletion" + | "lint/safety/runningStatementWhileHoldingAccessExclusive" | "lint/safety/transactionNesting" | "stdin" | "check" @@ -122,7 +126,7 @@ export type DiagnosticTags = DiagnosticTag[]; /** * Serializable representation of a [Diagnostic](super::Diagnostic) advice -See the [Visitor] trait for additional documentation on all the supported advice types. +See the [Visitor] trait for additional documentation on all the supported advice types. */ export type Advice = | { log: [LogCategory, MarkupBuf] } @@ -227,7 +231,7 @@ export interface CompletionItem { /** * The text that the editor should fill in. If `None`, the `label` should be used. Tables, for example, might have different completion_texts: -label: "users", description: "Schema: auth", completion_text: "auth.users". +label: "users", description: "Schema: auth", completion_text: "auth.users". */ export interface CompletionText { is_snippet: boolean; @@ -300,6 +304,10 @@ export interface PartialDatabaseConfiguration { * The connection timeout in seconds. */ connTimeoutSecs?: number; + /** + * A connection string that encodes the full connection setup. When provided, it takes precedence over the individual fields. + */ + connectionString?: string; /** * The name of the database. */ @@ -411,7 +419,7 @@ export interface PartialVcsConfiguration { /** * The folder where we should check for VCS files. By default, we will use the same folder where `postgres-language-server.jsonc` was found. -If we can't find the configuration, it will attempt to use the current working directory. If no current working directory can't be found, we won't use the VCS integration, and a diagnostic will be emitted +If we can't find the configuration, it will attempt to use the current working directory. If no current working directory can't be found, we won't use the VCS integration, and a diagnostic will be emitted */ root?: string; /** @@ -435,6 +443,10 @@ export type VcsClientKind = "git"; * A list of rules that belong to this group */ export interface Safety { + /** + * Adding a column with a SERIAL type or GENERATED ALWAYS AS ... STORED causes a full table rewrite. + */ + addSerialColumn?: RuleConfiguration_for_Null; /** * Adding a column with a DEFAULT value may lead to a table rewrite while holding an ACCESS EXCLUSIVE lock. */ @@ -495,10 +507,22 @@ export interface Safety { * Adding constraints without NOT VALID blocks all reads and writes. */ constraintMissingNotValid?: RuleConfiguration_for_Null; + /** + * Creating enum types is not recommended for new applications. + */ + creatingEnum?: RuleConfiguration_for_Null; /** * Disallow adding a UNIQUE constraint without using an existing index. */ disallowUniqueConstraint?: RuleConfiguration_for_Null; + /** + * Taking a dangerous lock without setting a lock timeout can cause indefinite blocking. + */ + lockTimeoutWarning?: RuleConfiguration_for_Null; + /** + * Multiple ALTER TABLE statements on the same table should be combined into a single statement. + */ + multipleAlterTable?: RuleConfiguration_for_Null; /** * Prefer BIGINT over smaller integer types. */ @@ -551,6 +575,10 @@ export interface Safety { * Dropping indexes non-concurrently can lock the table for reads. */ requireConcurrentIndexDeletion?: RuleConfiguration_for_Null; + /** + * Running additional statements while holding an ACCESS EXCLUSIVE lock blocks all table access. + */ + runningStatementWhileHoldingAccessExclusive?: RuleConfiguration_for_Null; /** * Detects problematic transaction nesting that could lead to unexpected behavior. */ @@ -590,8 +618,8 @@ export interface Workspace { params: RegisterProjectFolderParams, ): Promise; getFileContent(params: GetFileContentParams): Promise; - pullDiagnostics( - params: PullDiagnosticsParams, + pullFileDiagnostics( + params: PullFileDiagnosticsParams, ): Promise; getCompletions(params: GetCompletionsParams): Promise; updateSettings(params: UpdateSettingsParams): Promise; @@ -611,8 +639,8 @@ export function createWorkspace(transport: Transport): Workspace { getFileContent(params) { return transport.request("pgt/get_file_content", params); }, - pullDiagnostics(params) { - return transport.request("pgt/pull_diagnostics", params); + pullFileDiagnostics(params) { + return transport.request("pgt/pull_file_diagnostics", params); }, getCompletions(params) { return transport.request("pgt/get_completions", params); diff --git a/packages/@postgrestools/backend-jsonrpc/src/workspace.ts b/packages/@postgrestools/backend-jsonrpc/src/workspace.ts index 6e1498c2a..ad05d0c33 100644 --- a/packages/@postgrestools/backend-jsonrpc/src/workspace.ts +++ b/packages/@postgrestools/backend-jsonrpc/src/workspace.ts @@ -27,7 +27,7 @@ export type ProjectKey = string; export interface GetFileContentParams { path: PgTPath; } -export interface PullDiagnosticsParams { +export interface PullFileDiagnosticsParams { categories: RuleCategories; max_diagnostics: number; only: RuleCode[]; @@ -39,7 +39,6 @@ export type RuleCode = string; export type RuleCategory = "Lint" | "Action" | "Transformation"; export interface PullDiagnosticsResult { diagnostics: Diagnostic[]; - errors: number; skipped_diagnostics: number; } /** @@ -619,8 +618,8 @@ export interface Workspace { params: RegisterProjectFolderParams, ): Promise; getFileContent(params: GetFileContentParams): Promise; - pullDiagnostics( - params: PullDiagnosticsParams, + pullFileDiagnostics( + params: PullFileDiagnosticsParams, ): Promise; getCompletions(params: GetCompletionsParams): Promise; updateSettings(params: UpdateSettingsParams): Promise; @@ -640,8 +639,8 @@ export function createWorkspace(transport: Transport): Workspace { getFileContent(params) { return transport.request("pgt/get_file_content", params); }, - pullDiagnostics(params) { - return transport.request("pgt/pull_diagnostics", params); + pullFileDiagnostics(params) { + return transport.request("pgt/pull_file_diagnostics", params); }, getCompletions(params) { return transport.request("pgt/get_completions", params); diff --git a/xtask/codegen/src/generate_bindings.rs b/xtask/codegen/src/generate_bindings.rs index 5a569a5f8..9b6cf6773 100644 --- a/xtask/codegen/src/generate_bindings.rs +++ b/xtask/codegen/src/generate_bindings.rs @@ -14,8 +14,18 @@ use pgls_workspace::workspace_types::{generate_type, methods, ModuleQueue}; use xtask::{project_root, Mode, Result}; pub fn generate_bindings(mode: Mode) -> Result<()> { - let bindings_path = + let postgrestools_path = project_root().join("packages/@postgrestools/backend-jsonrpc/src/workspace.ts"); + let postgres_language_server_path = + project_root().join("packages/@postgres-language-server/backend-jsonrpc/src/workspace.ts"); + + generate_bindings_for_path(&postgrestools_path, &mode)?; + generate_bindings_for_path(&postgres_language_server_path, &mode)?; + + Ok(()) +} + +fn generate_bindings_for_path(bindings_path: &std::path::Path, mode: &Mode) -> Result<()> { let methods = methods(); let mut declarations = Vec::new(); @@ -429,7 +439,7 @@ pub fn generate_bindings(mode: Mode) -> Result<()> { let printed = formatted.print().unwrap(); let code = printed.into_code(); - update(&bindings_path, &code, &mode)?; + update(bindings_path, &code, mode)?; Ok(()) } From 5fd59d0ef296a136d77dee051497000020c87ef9 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 29 Oct 2025 08:58:07 +0100 Subject: [PATCH 02/11] fix: ci --- .github/workflows/pull_request.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index c39fc03d7..e7186525c 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -212,16 +212,27 @@ jobs: uses: oven-sh/setup-bun@v2 - name: Install JS dependencies run: bun install - - name: Build backend-jsonrpc + + - name: Build backend-jsonrpc (deprecated) working-directory: packages/@postgrestools/backend-jsonrpc run: bun run build - - name: Run backend-jsonrpc test + - name: Run backend-jsonrpc test (deprecated) working-directory: packages/@postgrestools/backend-jsonrpc run: bun run test - - name: Run cli test + - name: Run cli test (deprecated) working-directory: packages/@postgrestools/postgrestools run: bun run test + - name: Build backend-jsonrpc + working-directory: packages/@postgres-language-server/backend-jsonrpc + run: bun run build + - name: Run backend-jsonrpc test + working-directory: packages/@postgres-language-server/backend-jsonrpc + run: bun run test + - name: Run cli test + working-directory: packages/@postgres-language-server/cli + run: bun run test + codegen: name: Check Codegen runs-on: ubuntu-22.04 @@ -258,6 +269,8 @@ jobs: run: cargo run -p xtask_codegen -- analyser - name: Run the configuration codegen run: cargo run -p xtask_codegen -- configuration + - name: Run the bindings codegen + run: cargo run -p xtask_codegen -- bindings - name: Run the docs codegen run: cargo run -p docs_codegen - name: Check for git diff -- run "just ready" if you see an error From e8e28d99f1a09b884de82e4786cae8680ea2a456 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 29 Oct 2025 09:08:46 +0100 Subject: [PATCH 03/11] progress --- crates/pgls_cli/src/service/mod.rs | 2 +- crates/pgls_lsp/src/server.rs | 6 ++-- crates/pgls_lsp/tests/server.rs | 6 ++-- crates/pgls_workspace/src/workspace/client.rs | 30 +++++++++---------- .../backend-jsonrpc/src/workspace.ts | 18 +++++------ .../backend-jsonrpc/src/workspace.ts | 18 +++++------ xtask/codegen/src/generate_bindings.rs | 2 +- 7 files changed, 41 insertions(+), 41 deletions(-) diff --git a/crates/pgls_cli/src/service/mod.rs b/crates/pgls_cli/src/service/mod.rs index 75b636ee3..c676f9d3e 100644 --- a/crates/pgls_cli/src/service/mod.rs +++ b/crates/pgls_cli/src/service/mod.rs @@ -189,7 +189,7 @@ impl WorkspaceTransport for SocketTransport { self.pending_requests.insert(request.id, send); - let is_shutdown = request.method == "pgt/shutdown"; + let is_shutdown = request.method == "pgls/shutdown"; let request = JsonRpcRequest { jsonrpc: Cow::Borrowed("2.0"), diff --git a/crates/pgls_lsp/src/server.rs b/crates/pgls_lsp/src/server.rs index be1f4493e..aa89f6dd3 100644 --- a/crates/pgls_lsp/src/server.rs +++ b/crates/pgls_lsp/src/server.rs @@ -334,9 +334,9 @@ type Sessions = Arc>>; macro_rules! workspace_method { ( $builder:ident, $method:ident ) => { $builder = $builder.custom_method( - concat!("pgt/", stringify!($method)), + concat!("pgls/", stringify!($method)), |server: &LSPServer, params| { - let span = tracing::trace_span!(concat!("pgt/", stringify!($method)), params = ?params).or_current(); + let span = tracing::trace_span!(concat!("pgls/", stringify!($method)), params = ?params).or_current(); tracing::info!("Received request: {}", stringify!($method)); let workspace = server.session.workspace.clone(); @@ -445,7 +445,7 @@ impl ServerFactory { }); // "shutdown" is not part of the Workspace API - builder = builder.custom_method("pgt/shutdown", |server: &LSPServer, (): ()| { + builder = builder.custom_method("pgls/shutdown", |server: &LSPServer, (): ()| { info!("Sending shutdown signal"); server.session.broadcast_shutdown(); ready(Ok(Some(()))) diff --git a/crates/pgls_lsp/tests/server.rs b/crates/pgls_lsp/tests/server.rs index 41c6665f9..11b34023c 100644 --- a/crates/pgls_lsp/tests/server.rs +++ b/crates/pgls_lsp/tests/server.rs @@ -323,11 +323,11 @@ impl Server { .await } - /// Basic implementation of the `pgt/shutdown` request for tests + /// Basic implementation of the `pgls/shutdown` request for tests async fn pgls_shutdown(&mut self) -> Result<()> { - self.request::<_, ()>("pgt/shutdown", "_pgls_shutdown", ()) + self.request::<_, ()>("pgls/shutdown", "_pgls_shutdown", ()) .await? - .context("pgt/shutdown returned None")?; + .context("pgls/shutdown returned None")?; Ok(()) } } diff --git a/crates/pgls_workspace/src/workspace/client.rs b/crates/pgls_workspace/src/workspace/client.rs index 4dd331c00..827a01567 100644 --- a/crates/pgls_workspace/src/workspace/client.rs +++ b/crates/pgls_workspace/src/workspace/client.rs @@ -84,7 +84,7 @@ where } pub fn shutdown(self) -> Result<(), WorkspaceError> { - self.request("pgt/shutdown", ()) + self.request("pgls/shutdown", ()) } } @@ -96,48 +96,48 @@ where &self, params: crate::features::code_actions::CodeActionsParams, ) -> Result { - self.request("pgt/code_actions", params) + self.request("pgls/code_actions", params) } fn execute_statement( &self, params: crate::features::code_actions::ExecuteStatementParams, ) -> Result { - self.request("pgt/execute_statement", params) + self.request("pgls/execute_statement", params) } fn register_project_folder( &self, params: RegisterProjectFolderParams, ) -> Result { - self.request("pgt/register_project_folder", params) + self.request("pgls/register_project_folder", params) } fn unregister_project_folder( &self, params: UnregisterProjectFolderParams, ) -> Result<(), WorkspaceError> { - self.request("pgt/unregister_project_folder", params) + self.request("pgls/unregister_project_folder", params) } fn open_file(&self, params: OpenFileParams) -> Result<(), WorkspaceError> { - self.request("pgt/open_file", params) + self.request("pgls/open_file", params) } fn close_file(&self, params: CloseFileParams) -> Result<(), WorkspaceError> { - self.request("pgt/close_file", params) + self.request("pgls/close_file", params) } fn change_file(&self, params: super::ChangeFileParams) -> Result<(), WorkspaceError> { - self.request("pgt/change_file", params) + self.request("pgls/change_file", params) } fn update_settings(&self, params: super::UpdateSettingsParams) -> Result<(), WorkspaceError> { - self.request("pgt/update_settings", params) + self.request("pgls/update_settings", params) } fn is_path_ignored(&self, params: IsPathIgnoredParams) -> Result { - self.request("pgt/is_path_ignored", params) + self.request("pgls/is_path_ignored", params) } fn server_info(&self) -> Option<&ServerInfo> { @@ -145,34 +145,34 @@ where } fn get_file_content(&self, params: GetFileContentParams) -> Result { - self.request("pgt/get_file_content", params) + self.request("pgls/get_file_content", params) } fn pull_file_diagnostics( &self, params: crate::features::diagnostics::PullFileDiagnosticsParams, ) -> Result { - self.request("pgt/pull_diagnostics", params) + self.request("pgls/pull_diagnostics", params) } fn pull_db_diagnostics( &self, params: crate::features::diagnostics::PullDatabaseDiagnosticsParams, ) -> Result { - self.request("pgt/pull_db_diagnostics", params) + self.request("pgls/pull_db_diagnostics", params) } fn get_completions( &self, params: super::GetCompletionsParams, ) -> Result { - self.request("pgt/get_completions", params) + self.request("pgls/get_completions", params) } fn on_hover( &self, params: crate::features::on_hover::OnHoverParams, ) -> Result { - self.request("pgt/on_hover", params) + self.request("pgls/on_hover", params) } } diff --git a/packages/@postgres-language-server/backend-jsonrpc/src/workspace.ts b/packages/@postgres-language-server/backend-jsonrpc/src/workspace.ts index ced5de471..701554f89 100644 --- a/packages/@postgres-language-server/backend-jsonrpc/src/workspace.ts +++ b/packages/@postgres-language-server/backend-jsonrpc/src/workspace.ts @@ -631,31 +631,31 @@ export interface Workspace { export function createWorkspace(transport: Transport): Workspace { return { isPathIgnored(params) { - return transport.request("pgt/is_path_ignored", params); + return transport.request("pgls/is_path_ignored", params); }, registerProjectFolder(params) { - return transport.request("pgt/register_project_folder", params); + return transport.request("pgls/register_project_folder", params); }, getFileContent(params) { - return transport.request("pgt/get_file_content", params); + return transport.request("pgls/get_file_content", params); }, pullFileDiagnostics(params) { - return transport.request("pgt/pull_file_diagnostics", params); + return transport.request("pgls/pull_file_diagnostics", params); }, getCompletions(params) { - return transport.request("pgt/get_completions", params); + return transport.request("pgls/get_completions", params); }, updateSettings(params) { - return transport.request("pgt/update_settings", params); + return transport.request("pgls/update_settings", params); }, openFile(params) { - return transport.request("pgt/open_file", params); + return transport.request("pgls/open_file", params); }, changeFile(params) { - return transport.request("pgt/change_file", params); + return transport.request("pgls/change_file", params); }, closeFile(params) { - return transport.request("pgt/close_file", params); + return transport.request("pgls/close_file", params); }, destroy() { transport.destroy(); diff --git a/packages/@postgrestools/backend-jsonrpc/src/workspace.ts b/packages/@postgrestools/backend-jsonrpc/src/workspace.ts index ced5de471..701554f89 100644 --- a/packages/@postgrestools/backend-jsonrpc/src/workspace.ts +++ b/packages/@postgrestools/backend-jsonrpc/src/workspace.ts @@ -631,31 +631,31 @@ export interface Workspace { export function createWorkspace(transport: Transport): Workspace { return { isPathIgnored(params) { - return transport.request("pgt/is_path_ignored", params); + return transport.request("pgls/is_path_ignored", params); }, registerProjectFolder(params) { - return transport.request("pgt/register_project_folder", params); + return transport.request("pgls/register_project_folder", params); }, getFileContent(params) { - return transport.request("pgt/get_file_content", params); + return transport.request("pgls/get_file_content", params); }, pullFileDiagnostics(params) { - return transport.request("pgt/pull_file_diagnostics", params); + return transport.request("pgls/pull_file_diagnostics", params); }, getCompletions(params) { - return transport.request("pgt/get_completions", params); + return transport.request("pgls/get_completions", params); }, updateSettings(params) { - return transport.request("pgt/update_settings", params); + return transport.request("pgls/update_settings", params); }, openFile(params) { - return transport.request("pgt/open_file", params); + return transport.request("pgls/open_file", params); }, changeFile(params) { - return transport.request("pgt/change_file", params); + return transport.request("pgls/change_file", params); }, closeFile(params) { - return transport.request("pgt/close_file", params); + return transport.request("pgls/close_file", params); }, destroy() { transport.destroy(); diff --git a/xtask/codegen/src/generate_bindings.rs b/xtask/codegen/src/generate_bindings.rs index 4b7bb489d..bfd9e526c 100644 --- a/xtask/codegen/src/generate_bindings.rs +++ b/xtask/codegen/src/generate_bindings.rs @@ -128,7 +128,7 @@ pub fn generate_bindings(mode: Mode) -> Result<()> { [ AnyJsCallArgument::AnyJsExpression( AnyJsExpression::AnyJsLiteralExpression( - AnyJsLiteralExpression::JsStringLiteralExpression(make::js_string_literal_expression(make::js_string_literal(&format!("pgt/{}", method.name)))), + AnyJsLiteralExpression::JsStringLiteralExpression(make::js_string_literal_expression(make::js_string_literal(&format!("pgls/{}", method.name)))), ), ), AnyJsCallArgument::AnyJsExpression( From 7f68456a322f444134f9d0b2d0fc998310ba3452 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 29 Oct 2025 09:43:19 +0100 Subject: [PATCH 04/11] progress --- crates/pgls_workspace/src/workspace/server.tests.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/pgls_workspace/src/workspace/server.tests.rs b/crates/pgls_workspace/src/workspace/server.tests.rs index 6307c1643..29ffb3fd5 100644 --- a/crates/pgls_workspace/src/workspace/server.tests.rs +++ b/crates/pgls_workspace/src/workspace/server.tests.rs @@ -191,9 +191,8 @@ async fn correctly_ignores_files() { }); assert!( - diagnostics_result.is_ok_and(|res| res.diagnostics.is_empty() - && res.errors == 0 - && res.skipped_diagnostics == 0) + diagnostics_result + .is_ok_and(|res| res.diagnostics.is_empty() && res.skipped_diagnostics == 0) ); let close_file_result = From 5cbea63296d27a3f702dcced226279f02ce3f4ba Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 29 Oct 2025 09:50:22 +0100 Subject: [PATCH 05/11] progress --- .../@postgrestools/backend-jsonrpc/tests/workspace.test.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@postgrestools/backend-jsonrpc/tests/workspace.test.mjs b/packages/@postgrestools/backend-jsonrpc/tests/workspace.test.mjs index c35904c41..cf0f13ae6 100644 --- a/packages/@postgrestools/backend-jsonrpc/tests/workspace.test.mjs +++ b/packages/@postgrestools/backend-jsonrpc/tests/workspace.test.mjs @@ -27,7 +27,7 @@ describe("Workspace API", () => { version: 0, }); - const { diagnostics } = await workspace.pullDiagnostics({ + const { diagnostics } = await workspace.pullFileDiagnostics({ only: [], skip: [], max_diagnostics: 100, From b7cc02ebc840e765a40e2901b748e8f140888742 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 29 Oct 2025 10:05:48 +0100 Subject: [PATCH 06/11] progress --- crates/pgls_cli/src/execute/process_file/check.rs | 2 +- crates/pgls_workspace/src/workspace.rs | 2 +- .../backend-jsonrpc/tests/workspace.test.mjs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/pgls_cli/src/execute/process_file/check.rs b/crates/pgls_cli/src/execute/process_file/check.rs index de7d67c71..cb53bc99f 100644 --- a/crates/pgls_cli/src/execute/process_file/check.rs +++ b/crates/pgls_cli/src/execute/process_file/check.rs @@ -54,7 +54,7 @@ pub(crate) fn check_with_guard<'ctx>( .into_iter() .map(Error::from) .collect(), - skipped_diagnostics: pull_diagnostics_result.skipped_diagnostics as u32, + skipped_diagnostics: pull_diagnostics_result.skipped_diagnostics, }); } diff --git a/crates/pgls_workspace/src/workspace.rs b/crates/pgls_workspace/src/workspace.rs index 4bb8d3f3c..feb8e450c 100644 --- a/crates/pgls_workspace/src/workspace.rs +++ b/crates/pgls_workspace/src/workspace.rs @@ -226,7 +226,7 @@ impl<'app, W: Workspace + ?Sized> FileGuard<'app, W> { .pull_file_diagnostics(PullFileDiagnosticsParams { path: self.path.clone(), categories, - max_diagnostics: max_diagnostics.into(), + max_diagnostics, only, skip, }) diff --git a/packages/@postgres-language-server/backend-jsonrpc/tests/workspace.test.mjs b/packages/@postgres-language-server/backend-jsonrpc/tests/workspace.test.mjs index 6f586d8d9..3c32d574c 100644 --- a/packages/@postgres-language-server/backend-jsonrpc/tests/workspace.test.mjs +++ b/packages/@postgres-language-server/backend-jsonrpc/tests/workspace.test.mjs @@ -27,7 +27,7 @@ describe("Workspace API", () => { version: 0, }); - const { diagnostics } = await workspace.pullDiagnostics({ + const { diagnostics } = await workspace.pullFileDiagnostics({ only: [], skip: [], max_diagnostics: 100, From 5d98f502ecf01d5f09623d29c7793183f71d5c5d Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 29 Oct 2025 12:13:52 +0100 Subject: [PATCH 07/11] progress --- packages/@postgres-language-server/cli/test/bin.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/@postgres-language-server/cli/test/bin.test.js b/packages/@postgres-language-server/cli/test/bin.test.js index 921869e53..df89bb6a0 100644 --- a/packages/@postgres-language-server/cli/test/bin.test.js +++ b/packages/@postgres-language-server/cli/test/bin.test.js @@ -57,6 +57,7 @@ describe("postgres-language-server bin", () => { }); }); + console.log(result); expect(result.code).not.toBe(0); }); }); From 2b2312f2288f483a6142fdfd73d961655dd95e07 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 29 Oct 2025 13:23:30 +0100 Subject: [PATCH 08/11] progress --- package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index bf9303007..c7e97e76d 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,9 @@ }, "workspaces": [ "packages/@postgrestools/postgrestools", - "packages/@postgrestools/backend-jsonrpc" + "packages/@postgrestools/backend-jsonrpc", + "packages/@postgres-language-server/cli", + "packages/@postgres-language-server/backend-jsonrpc" ], "keywords": [], "author": "Supabase Community", From ee16f6c179956687539508c80a706c688d79b950 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 29 Oct 2025 16:09:35 +0100 Subject: [PATCH 09/11] progress --- bun.lock | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/bun.lock b/bun.lock index a3435297b..718b63324 100644 --- a/bun.lock +++ b/bun.lock @@ -11,6 +11,32 @@ "typescript": "^5", }, }, + "packages/@postgres-language-server/backend-jsonrpc": { + "name": "@postgres-language-server/backend-jsonrpc", + "optionalDependencies": { + "@postgres-language-server/cli-darwin-arm64": "", + "@postgres-language-server/cli-darwin-x64": "", + "@postgres-language-server/cli-linux-arm64": "", + "@postgres-language-server/cli-linux-x64": "", + "@postgres-language-server/cli-win32-arm64": "", + "@postgres-language-server/cli-win32-x64": "", + }, + }, + "packages/@postgres-language-server/cli": { + "name": "@postgres-language-server/cli", + "bin": { + "postgres-language-server": "bin/postgres-language-server", + }, + "optionalDependencies": { + "@postgres-language-server/cli-aarch64-apple-darwin": "", + "@postgres-language-server/cli-aarch64-linux-gnu": "", + "@postgres-language-server/cli-aarch64-windows-msvc": "", + "@postgres-language-server/cli-x86_64-apple-darwin": "", + "@postgres-language-server/cli-x86_64-linux-gnu": "", + "@postgres-language-server/cli-x86_64-linux-musl": "", + "@postgres-language-server/cli-x86_64-windows-msvc": "", + }, + }, "packages/@postgrestools/backend-jsonrpc": { "name": "@postgrestools/backend-jsonrpc", "optionalDependencies": { @@ -57,6 +83,24 @@ "@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@1.9.4", "", { "os": "win32", "cpu": "x64" }, "sha512-8Y5wMhVIPaWe6jw2H+KlEm4wP/f7EW3810ZLmDlrEEy5KvBsb9ECEfu/kMWD484ijfQ8+nIi0giMgu9g1UAuuA=="], + "@postgres-language-server/backend-jsonrpc": ["@postgres-language-server/backend-jsonrpc@workspace:packages/@postgres-language-server/backend-jsonrpc"], + + "@postgres-language-server/cli": ["@postgres-language-server/cli@workspace:packages/@postgres-language-server/cli"], + + "@postgres-language-server/cli-aarch64-apple-darwin": ["@postgres-language-server/cli-aarch64-apple-darwin@0.17.1", "", { "os": "darwin", "cpu": "arm64" }, "sha512-0Umsb4yuHyI8D9oZkkpa6H4aZXMAAMLa7qbOrHRP9IMML4mKp5B9wkCiyvgd1ZKRP82UQBZnVjh53AGXky4Jdw=="], + + "@postgres-language-server/cli-aarch64-linux-gnu": ["@postgres-language-server/cli-aarch64-linux-gnu@0.17.1", "", { "os": "linux", "cpu": "arm64" }, "sha512-ye8IQLNLyJK4hR5tx8rKh1tEO1Sb+Dw574cbBG++K46LTZAdRq5/IQrNkIfDzFdgU+HMK3QYfm54cgudYeVVlQ=="], + + "@postgres-language-server/cli-aarch64-windows-msvc": ["@postgres-language-server/cli-aarch64-windows-msvc@0.17.1", "", { "os": "win32", "cpu": "arm64" }, "sha512-FkOjgvN7+vq0RvwVD/effFjKgH1mrAVMnV+3eO9bdZ6jCXpPesGOyCvyhf59IzoqmvIMyEeKJzjOUcXxWPmdZg=="], + + "@postgres-language-server/cli-x86_64-apple-darwin": ["@postgres-language-server/cli-x86_64-apple-darwin@0.17.1", "", { "os": "darwin", "cpu": "x64" }, "sha512-B79kZ9tz8fvGihv4W/cyCFzw5Wz95HlqF1hnNTBocJtf8Nvo9h6RDWoUEYliBjRp37gcdV945ZjV2RHHxdKMTw=="], + + "@postgres-language-server/cli-x86_64-linux-gnu": ["@postgres-language-server/cli-x86_64-linux-gnu@0.17.1", "", { "os": "linux", "cpu": "x64" }, "sha512-lh5Lg/Cc18+232NRd1OZqdpJzuJMW6lrwkC6RKYiiTzxUfRq7uRV8qI0NNnp5cyKiyDO90cpQQ8fjepTaMzh9A=="], + + "@postgres-language-server/cli-x86_64-linux-musl": ["@postgres-language-server/cli-x86_64-linux-musl@0.17.1", "", { "os": "linux", "cpu": "x64" }, "sha512-YH5Znq0urRUxtdsbyDu6Dcg5x9qhgDqTl7gCVY/LmVrPnHfP2I6gU/TJT21B5sDTSadjwZ73AbXimLmlwG6HPA=="], + + "@postgres-language-server/cli-x86_64-windows-msvc": ["@postgres-language-server/cli-x86_64-windows-msvc@0.17.1", "", { "os": "win32", "cpu": "x64" }, "sha512-o2uIx0Vi3iEBFKKnz024JicgovJZWpM9G4WbQxf3r9IQlZPWvDXknlX7rNPQDnQTFRIUg8bpjZpjEvDFHMmuGg=="], + "@postgrestools/backend-jsonrpc": ["@postgrestools/backend-jsonrpc@workspace:packages/@postgrestools/backend-jsonrpc"], "@postgrestools/cli-aarch64-apple-darwin": ["@postgrestools/cli-aarch64-apple-darwin@0.13.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-LqgpsiupuNR1m8rSqcMdwep1UsSG5z7RZ9MYHODBB0+AsN/e1YzcyutqGeKs+AfDBdKdv7QmSbpf7KruBYL+tg=="], From 323915d06f56a4b723046c3b120aef6d0a200a14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Steinr=C3=B6tter?= Date: Sat, 1 Nov 2025 16:47:17 +0100 Subject: [PATCH 10/11] Update bin.test.js Co-authored-by: Julian Domke <68325451+juleswritescode@users.noreply.github.com> --- packages/@postgres-language-server/cli/test/bin.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/@postgres-language-server/cli/test/bin.test.js b/packages/@postgres-language-server/cli/test/bin.test.js index df89bb6a0..921869e53 100644 --- a/packages/@postgres-language-server/cli/test/bin.test.js +++ b/packages/@postgres-language-server/cli/test/bin.test.js @@ -57,7 +57,6 @@ describe("postgres-language-server bin", () => { }); }); - console.log(result); expect(result.code).not.toBe(0); }); }); From f6ade61f1b7c10edfc80190b4fd8524478b749b2 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Sat, 1 Nov 2025 17:38:47 +0100 Subject: [PATCH 11/11] progress --- crates/pgls_analyse/src/categories.rs | 24 +++++++++---------- crates/pgls_cli/src/cli_options.rs | 1 + crates/pgls_cli/src/commands/daemon.rs | 20 ++++++++-------- crates/pgls_cli/src/commands/mod.rs | 8 +++---- crates/pgls_cli/src/execute/walk.rs | 4 ++-- crates/pgls_cli/src/logging.rs | 6 ++--- crates/pgls_cli/src/service/unix.rs | 4 ++-- crates/pgls_cli/src/service/windows.rs | 4 ++-- crates/pgls_fs/src/dir.rs | 8 +++---- crates/pgls_lsp/tests/server.rs | 2 +- crates/pgls_workspace/src/workspace/client.rs | 2 +- docs/guides/ide_setup.md | 10 ++++---- justfile | 6 ++--- 13 files changed, 50 insertions(+), 49 deletions(-) diff --git a/crates/pgls_analyse/src/categories.rs b/crates/pgls_analyse/src/categories.rs index 1b4ae7209..10cca0915 100644 --- a/crates/pgls_analyse/src/categories.rs +++ b/crates/pgls_analyse/src/categories.rs @@ -91,34 +91,34 @@ impl ActionCategory { match self { ActionCategory::QuickFix(tag) => { if tag.is_empty() { - Cow::Borrowed("quickfix.pgt") + Cow::Borrowed("quickfix.pgls") } else { - Cow::Owned(format!("quickfix.pgt.{tag}")) + Cow::Owned(format!("quickfix.pgls.{tag}")) } } - ActionCategory::Refactor(RefactorKind::None) => Cow::Borrowed("refactor.pgt"), + ActionCategory::Refactor(RefactorKind::None) => Cow::Borrowed("refactor.pgls"), ActionCategory::Refactor(RefactorKind::Extract) => { - Cow::Borrowed("refactor.extract.pgt") + Cow::Borrowed("refactor.extract.pgls") } - ActionCategory::Refactor(RefactorKind::Inline) => Cow::Borrowed("refactor.inline.pgt"), + ActionCategory::Refactor(RefactorKind::Inline) => Cow::Borrowed("refactor.inline.pgls"), ActionCategory::Refactor(RefactorKind::Rewrite) => { - Cow::Borrowed("refactor.rewrite.pgt") + Cow::Borrowed("refactor.rewrite.pgls") } ActionCategory::Refactor(RefactorKind::Other(tag)) => { - Cow::Owned(format!("refactor.{tag}.pgt")) + Cow::Owned(format!("refactor.{tag}.pgls")) } - ActionCategory::Source(SourceActionKind::None) => Cow::Borrowed("source.pgt"), - ActionCategory::Source(SourceActionKind::FixAll) => Cow::Borrowed("source.fixAll.pgt"), + ActionCategory::Source(SourceActionKind::None) => Cow::Borrowed("source.pgls"), + ActionCategory::Source(SourceActionKind::FixAll) => Cow::Borrowed("source.fixAll.pgls"), ActionCategory::Source(SourceActionKind::OrganizeImports) => { - Cow::Borrowed("source.organizeImports.pgt") + Cow::Borrowed("source.organizeImports.pgls") } ActionCategory::Source(SourceActionKind::Other(tag)) => { - Cow::Owned(format!("source.{tag}.pgt")) + Cow::Owned(format!("source.{tag}.pgls")) } - ActionCategory::Other(tag) => Cow::Owned(format!("{tag}.pgt")), + ActionCategory::Other(tag) => Cow::Owned(format!("{tag}.pgls")), } } } diff --git a/crates/pgls_cli/src/cli_options.rs b/crates/pgls_cli/src/cli_options.rs index d2bcca14f..e1c7d4009 100644 --- a/crates/pgls_cli/src/cli_options.rs +++ b/crates/pgls_cli/src/cli_options.rs @@ -58,6 +58,7 @@ pub struct CliOptions { #[bpaf( env("PGT_LOG_LEVEL"), + env("PGLS_LOG_LEVEL"), long("log-level"), argument("none|debug|info|warn|error"), fallback(LoggingLevel::default()), diff --git a/crates/pgls_cli/src/commands/daemon.rs b/crates/pgls_cli/src/commands/daemon.rs index 5016a4489..36dafc61b 100644 --- a/crates/pgls_cli/src/commands/daemon.rs +++ b/crates/pgls_cli/src/commands/daemon.rs @@ -181,7 +181,7 @@ async fn start_lsp_proxy( /// The events received by the subscriber are filtered at the `info` level, /// then printed using the [HierarchicalLayer] layer, and the resulting text /// is written to log files rotated on a hourly basis (in -/// `pgt-logs/server.log.yyyy-MM-dd-HH` files inside the system temporary +/// `pgls-logs/server.log.yyyy-MM-dd-HH` files inside the system temporary /// directory) fn setup_tracing_subscriber( log_path: Option, @@ -189,7 +189,7 @@ fn setup_tracing_subscriber( log_level: Option, log_kind: Option, ) { - let pgls_log_path = log_path.unwrap_or(pgls_fs::ensure_cache_dir().join("pgt-logs")); + let pgls_log_path = log_path.unwrap_or(pgls_fs::ensure_cache_dir().join("pgls-logs")); let appender_builder = tracing_appender::rolling::RollingFileAppender::builder(); @@ -200,7 +200,7 @@ fn setup_tracing_subscriber( .build(pgls_log_path) .expect("Failed to start the logger for the daemon."); - let filter = PgtLoggingFilter::from(log_level); + let filter = PgLSLoggingFilter::from(log_level); let log_kind = log_kind.unwrap_or("hierarchical".into()); @@ -241,16 +241,16 @@ pub fn default_pgls_log_path() -> PathBuf { .or_else(|| env.pgls_log_path.value()) { Some(directory) => PathBuf::from(directory), - None => pgls_fs::ensure_cache_dir().join("pgt-logs"), + None => pgls_fs::ensure_cache_dir().join("pgls-logs"), } } /// Tracing Filter with two rules: -/// For all crates starting with pgt*, use `PGT_LOG_LEVEL` or CLI option or "info" as default +/// For all crates starting with pgls*, use `PGLS_LOG_LEVEL` or CLI option or "info" as default /// For all other crates, use "info" -struct PgtLoggingFilter(LevelFilter); +struct PgLSLoggingFilter(LevelFilter); -impl From> for PgtLoggingFilter { +impl From> for PgLSLoggingFilter { fn from(value: Option) -> Self { Self( value @@ -269,9 +269,9 @@ impl From> for PgtLoggingFilter { } } -impl PgtLoggingFilter { +impl PgLSLoggingFilter { fn is_enabled(&self, meta: &Metadata<'_>) -> bool { - let filter = if meta.target().starts_with("pgt") { + let filter = if meta.target().starts_with("pgls") { self.0 } else { LevelFilter::INFO @@ -281,7 +281,7 @@ impl PgtLoggingFilter { } } -impl Filter for PgtLoggingFilter { +impl Filter for PgLSLoggingFilter { fn enabled(&self, meta: &Metadata<'_>, _cx: &Context<'_, S>) -> bool { self.is_enabled(meta) } diff --git a/crates/pgls_cli/src/commands/mod.rs b/crates/pgls_cli/src/commands/mod.rs index 63f9ded37..3dac093e5 100644 --- a/crates/pgls_cli/src/commands/mod.rs +++ b/crates/pgls_cli/src/commands/mod.rs @@ -93,7 +93,7 @@ pub enum PgLSCommand { long("log-path"), argument("PATH"), hide_usage, - fallback(pgls_fs::ensure_cache_dir().join("pgt-logs")), + fallback(pgls_fs::ensure_cache_dir().join("pgls-logs")), )] log_path: PathBuf, /// Allows to set a custom file path to the configuration file, @@ -136,7 +136,7 @@ pub enum PgLSCommand { long("log-path"), argument("PATH"), hide_usage, - fallback(pgls_fs::ensure_cache_dir().join("pgt-logs")), + fallback(pgls_fs::ensure_cache_dir().join("pgls-logs")), )] log_path: PathBuf, /// Allows to set a custom file path to the configuration file, @@ -178,11 +178,11 @@ pub enum PgLSCommand { long("log-path"), argument("PATH"), hide_usage, - fallback(pgls_fs::ensure_cache_dir().join("pgt-logs")), + fallback(pgls_fs::ensure_cache_dir().join("pgls-logs")), )] log_path: PathBuf, - /// Allows to change the log level. Default is debug. This will only affect "pgt*" crates. All others are logged with info level. + /// Allows to change the log level. Default is debug. This will only affect "pgls*" crates. All others are logged with info level. #[bpaf( env("PGT_LOG_LEVEL"), env("PGLS_LOG_LEVEL"), diff --git a/crates/pgls_cli/src/execute/walk.rs b/crates/pgls_cli/src/execute/walk.rs index c562b5283..342794b3c 100644 --- a/crates/pgls_cli/src/execute/walk.rs +++ b/crates/pgls_cli/src/execute/walk.rs @@ -59,7 +59,7 @@ pub(crate) fn traverse( let (duration, evaluated_paths, diagnostics) = thread::scope(|s| { let handler = thread::Builder::new() - .name(String::from("pgt::console")) + .name(String::from("pgls::console")) .spawn_scoped(s, || printer.run(receiver, recv_files)) .expect("failed to spawn console thread"); @@ -121,7 +121,7 @@ fn init_thread_pool() { static INIT_ONCE: Once = Once::new(); INIT_ONCE.call_once(|| { rayon::ThreadPoolBuilder::new() - .thread_name(|index| format!("pgt::worker_{index}")) + .thread_name(|index| format!("pgls::worker_{index}")) .build_global() .expect("failed to initialize the global thread pool"); }); diff --git a/crates/pgls_cli/src/logging.rs b/crates/pgls_cli/src/logging.rs index 359119270..166a54934 100644 --- a/crates/pgls_cli/src/logging.rs +++ b/crates/pgls_cli/src/logging.rs @@ -92,12 +92,12 @@ impl Display for LoggingLevel { /// Tracing filter enabling: /// - All spans and events at level info or higher -/// - All spans and events at level debug in crates whose name starts with `pgt` +/// - All spans and events at level debug in crates whose name starts with `pgls` struct LoggingFilter { level: LoggingLevel, } -/// Tracing filter used for spans emitted by `pgt*` crates +/// Tracing filter used for spans emitted by `pgls*` crates const SELF_FILTER: LevelFilter = if cfg!(debug_assertions) { LevelFilter::TRACE } else { @@ -106,7 +106,7 @@ const SELF_FILTER: LevelFilter = if cfg!(debug_assertions) { impl LoggingFilter { fn is_enabled(&self, meta: &Metadata<'_>) -> bool { - let filter = if meta.target().starts_with("pgt") { + let filter = if meta.target().starts_with("pgls") { if let Some(level) = self.level.to_filter_level() { level } else { diff --git a/crates/pgls_cli/src/service/unix.rs b/crates/pgls_cli/src/service/unix.rs index c9f6b0bc7..aaee27ec1 100644 --- a/crates/pgls_cli/src/service/unix.rs +++ b/crates/pgls_cli/src/service/unix.rs @@ -21,7 +21,7 @@ use tracing::{Instrument, debug, info}; /// Returns the filesystem path of the global socket used to communicate with /// the server daemon fn get_socket_name() -> PathBuf { - pgls_fs::ensure_cache_dir().join(format!("pgt-socket-{}", pgls_configuration::VERSION)) + pgls_fs::ensure_cache_dir().join(format!("pgls-socket-{}", pgls_configuration::VERSION)) } #[allow(dead_code)] @@ -32,7 +32,7 @@ pub(crate) fn enumerate_pipes() -> io::Result> { let file_name = entry.file_name()?; let file_name = file_name.to_str()?; - let version = file_name.strip_prefix("pgt-socket")?; + let version = file_name.strip_prefix("pgls-socket")?; if version.is_empty() { Some(String::new()) } else { diff --git a/crates/pgls_cli/src/service/windows.rs b/crates/pgls_cli/src/service/windows.rs index f93eee9d1..5463f83cd 100644 --- a/crates/pgls_cli/src/service/windows.rs +++ b/crates/pgls_cli/src/service/windows.rs @@ -24,7 +24,7 @@ use tracing::Instrument; /// Returns the name of the global named pipe used to communicate with the /// server daemon fn get_pipe_name() -> String { - format!(r"\\.\pipe\pgt-service-{}", pgls_configuration::VERSION) + format!(r"\\.\pipe\pgls-service-{}", pgls_configuration::VERSION) } #[allow(dead_code)] @@ -35,7 +35,7 @@ pub(crate) fn enumerate_pipes() -> io::Result> { let file_name = entry.file_name()?; let file_name = file_name.to_str()?; - let version = file_name.strip_prefix("pgt-service")?; + let version = file_name.strip_prefix("pgls-service")?; if version.is_empty() { Some(String::new()) } else { diff --git a/crates/pgls_fs/src/dir.rs b/crates/pgls_fs/src/dir.rs index 6ba559e4b..e41dad4d7 100644 --- a/crates/pgls_fs/src/dir.rs +++ b/crates/pgls_fs/src/dir.rs @@ -3,10 +3,10 @@ use std::{env, fs, path::PathBuf}; use tracing::warn; pub fn ensure_cache_dir() -> PathBuf { - if let Some(proj_dirs) = ProjectDirs::from("dev", "supabase-community", "pgt") { - // Linux: /home/alice/.cache/pgt - // Win: C:\Users\Alice\AppData\Local\supabase-community\pgt\cache - // Mac: /Users/Alice/Library/Caches/dev.supabase-community.pgt + if let Some(proj_dirs) = ProjectDirs::from("dev", "supabase-community", "pgls") { + // Linux: /home/alice/.cache/pgls + // Win: C:\Users\Alice\AppData\Local\supabase-community\pgls\cache + // Mac: /Users/Alice/Library/Caches/dev.supabase-community.pgls let cache_dir = proj_dirs.cache_dir().to_path_buf(); if let Err(err) = fs::create_dir_all(&cache_dir) { let temp_dir = env::temp_dir(); diff --git a/crates/pgls_lsp/tests/server.rs b/crates/pgls_lsp/tests/server.rs index e88d00a3f..36748d214 100644 --- a/crates/pgls_lsp/tests/server.rs +++ b/crates/pgls_lsp/tests/server.rs @@ -1063,7 +1063,7 @@ async fn test_invalidate_schema_cache(test_db: PgPool) -> Result<()> { // Invalidate the schema cache (all = false for current connection only) server - .request::("pgt/invalidate_schema_cache", "_invalidate_cache", false) + .request::("pgls/invalidate_schema_cache", "_invalidate_cache", false) .await?; // Get completions after invalidating cache - 'name' should NOW be present diff --git a/crates/pgls_workspace/src/workspace/client.rs b/crates/pgls_workspace/src/workspace/client.rs index c00158a24..11b4846cb 100644 --- a/crates/pgls_workspace/src/workspace/client.rs +++ b/crates/pgls_workspace/src/workspace/client.rs @@ -177,6 +177,6 @@ where } fn invalidate_schema_cache(&self, all: bool) -> Result<(), WorkspaceError> { - self.request("pgt/invalidate_schema_cache", all) + self.request("pgls/invalidate_schema_cache", all) } } diff --git a/docs/guides/ide_setup.md b/docs/guides/ide_setup.md index 30cd344aa..5b9382cb2 100644 --- a/docs/guides/ide_setup.md +++ b/docs/guides/ide_setup.md @@ -58,13 +58,13 @@ Operations via the daemon are significantly slower than the CLI itself, so it’ ### Daemon logs -The daemon saves logs in your file system. Logs are stored in a folder called `pgt-logs`. The path of this folder changes based on your operative system: +The daemon saves logs in your file system. Logs are stored in a folder called `pgls-logs`. The path of this folder changes based on your operative system: -- Linux: `~/.cache/pgt;` -- Windows: `C:\Users\\AppData\Local\supabase-community\pgt\cache` -- macOS: `/Users//Library/Caches/dev.supabase-community.pgt` +- Linux: `~/.cache/pgls;` +- Windows: `C:\Users\\AppData\Local\supabase-community\pgls\cache` +- macOS: `/Users//Library/Caches/dev.supabase-community.pgls` For other operative systems, you can find the folder in the system’s temporary directory. -You can change the location of the `pgt-logs` folder via the `PGT_LOG_PATH` variable. +You can change the location of the `pgls-logs` folder via the `PGLS_LOG_PATH` variable. diff --git a/justfile b/justfile index 972629079..81e9d78d1 100644 --- a/justfile +++ b/justfile @@ -149,12 +149,12 @@ quick-modify: git commit -m "progress" git push -# Make sure to set your PGT_LOG_PATH in your shell profile. -# You can use the PGT_LOG_LEVEL to set your log level. +# Make sure to set your PGLS_LOG_PATH in your shell profile. +# You can use the PGLS_LOG_LEVEL to set your log level. # We recommend to install `bunyan` (npm i -g bunyan) and pipe the output through there for color-coding: # just show-logs | bunyan show-logs: - tail -f $(ls $PGT_LOG_PATH/server.log.* | sort -t- -k2,2 -k3,3 -k4,4 | tail -n 1) + tail -f $(ls $PGLS_LOG_PATH/server.log.* | sort -t- -k2,2 -k3,3 -k4,4 | tail -n 1) # Run a claude agent with the given agentic prompt file. # Commented out by default to avoid accidental usage that may incur costs.