@carllee1983/dbcli 0.3.1-beta → 0.3.2-beta

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 (2) hide show
  1. package/dist/cli.mjs +227 -25
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -42758,7 +42758,7 @@ var {
42758
42758
  // package.json
42759
42759
  var package_default = {
42760
42760
  name: "@carllee1983/dbcli",
42761
- version: "0.3.1-beta",
42761
+ version: "0.3.2-beta",
42762
42762
  description: "Database CLI for AI agents",
42763
42763
  type: "module",
42764
42764
  publishConfig: {
@@ -42812,8 +42812,231 @@ var package_default = {
42812
42812
  vitest: "^1.2.0"
42813
42813
  }
42814
42814
  };
42815
+ // resources/lang/en/messages.json
42816
+ var messages_default = {
42817
+ init: {
42818
+ description: "Initialize dbcli configuration with .env parsing and interactive prompts",
42819
+ welcome: "Welcome to dbcli",
42820
+ select_system: "Select database system:",
42821
+ prompt_host: "Database host: ",
42822
+ prompt_port: "Database port: ",
42823
+ prompt_user: "Database user: ",
42824
+ prompt_password: "Database password: ",
42825
+ prompt_name: "Database name: ",
42826
+ prompt_permission: "Permission level (query-only, read-write, admin): ",
42827
+ env_parse_note: "Note: Unable to parse .env configuration, using interactive prompts",
42828
+ connection_testing: "Testing database connection...",
42829
+ connection_success: "\u2713 Database connection successful",
42830
+ connection_failed: "\u2717 Database connection failed",
42831
+ config_saved: "Configuration saved to .dbcli",
42832
+ config_exists_overwrite: "Configuration file .dbcli already exists. Overwrite? (y/n): ",
42833
+ cancelled: "Cancelled. Configuration not changed."
42834
+ },
42835
+ schema: {
42836
+ description: "Retrieve table structure or list all tables",
42837
+ fetching: "Fetching schema...",
42838
+ success: "Schema updated",
42839
+ not_found: "Table not found in database",
42840
+ refresh_prompt: "Schema has changes. Apply? (y/n): ",
42841
+ columns_header: "Columns",
42842
+ scanning_database: "\uD83D\uDD0D Scanning database schema...",
42843
+ tables_found: "\uD83D\uDCCD Found {count} table(s). Fetching schema details...",
42844
+ processing_tables: " Processed {processed}/{total} table(s)",
42845
+ schema_exists_warning: "\u26A0\uFE0F Database schema already exists in .dbcli",
42846
+ use_force_to_override: " Use --force to override without confirmation"
42847
+ },
42848
+ list: {
42849
+ description: "List all tables in the database",
42850
+ no_tables: "No tables found in database"
42851
+ },
42852
+ query: {
42853
+ description: "Execute SQL query",
42854
+ executing: "Executing query...",
42855
+ no_results: "No results returned",
42856
+ result_count: "Results: {count} row(s)"
42857
+ },
42858
+ errors: {
42859
+ message: "Error: {message}",
42860
+ invalid_config: "Invalid configuration: {field}",
42861
+ connection_failed: "Failed to connect to database: {message}",
42862
+ permission_denied: "Permission denied (required: {required})",
42863
+ table_not_found: "Table not found: {table}",
42864
+ unsupported_lang: "Language '{lang}' not supported, using English",
42865
+ invalid_json: "Invalid JSON: {message}",
42866
+ table_blacklisted: "Error: Table '{table}' is blacklisted for {operation} operations",
42867
+ table_already_blacklisted: "Error: Table '{table}' is already blacklisted",
42868
+ table_not_in_blacklist: "Error: Table '{table}' is not in the blacklist",
42869
+ column_already_blacklisted: "Error: Column '{table}.{column}' is already blacklisted",
42870
+ column_not_in_blacklist: "Error: Column '{table}.{column}' is not in the blacklist",
42871
+ invalid_table_name: "Error: Invalid table name: {table}",
42872
+ invalid_column_format: "Error: Invalid column format. Use 'table.column'"
42873
+ },
42874
+ success: {
42875
+ inserted: "Successfully inserted {count} row(s)",
42876
+ updated: "Successfully updated {count} row(s)",
42877
+ deleted: "Successfully deleted {count} row(s)",
42878
+ no_changes: "No changes to apply"
42879
+ },
42880
+ insert: {
42881
+ description: "Insert data into a table",
42882
+ prompt_data: "Enter JSON data to insert: ",
42883
+ confirm: "Insert {count} row(s) into {table}? (y/n): "
42884
+ },
42885
+ update: {
42886
+ description: "Update data in a table",
42887
+ prompt_where: "Enter WHERE clause (e.g., id=1): ",
42888
+ prompt_set: 'Enter JSON updates (e.g., {"status": "active"}): ',
42889
+ confirm: "Update rows in {table}? (y/n): "
42890
+ },
42891
+ delete: {
42892
+ description: "Delete data from a table",
42893
+ prompt_where: "Enter WHERE clause (e.g., id=1): ",
42894
+ confirm: "Delete rows from {table}? (y/n): ",
42895
+ admin_only: "Delete command requires admin permission"
42896
+ },
42897
+ export: {
42898
+ description: "Export query results",
42899
+ formats: "Supported formats: json, csv",
42900
+ exported: "Exported {count} rows to {file}"
42901
+ },
42902
+ skill: {
42903
+ description: "Generate AI skill documentation",
42904
+ installed: "Skill installed to {path}"
42905
+ },
42906
+ blacklist: {
42907
+ description: "Manage sensitive data blacklist to prevent AI access",
42908
+ list_title: "Current Blacklist Configuration",
42909
+ tables_label: "Blacklisted tables",
42910
+ columns_label: "Blacklisted columns",
42911
+ none: "No tables or columns are currently blacklisted",
42912
+ table_added: "\u2713 Table '{table}' added to blacklist",
42913
+ table_removed: "\u2713 Table '{table}' removed from blacklist",
42914
+ column_added: "\u2713 Column '{table}.{column}' added to blacklist",
42915
+ column_removed: "\u2713 Column '{table}.{column}' removed from blacklist"
42916
+ },
42917
+ security: {
42918
+ columns_omitted: "Security: {count} column(s) were omitted based on your blacklist"
42919
+ },
42920
+ warnings: {
42921
+ blacklist_override_used: "Warning: Blacklist override enabled (DBCLI_OVERRIDE_BLACKLIST=true). Executing {operation} on blacklisted table '{table}'"
42922
+ }
42923
+ };
42924
+ // resources/lang/zh-TW/messages.json
42925
+ var messages_default2 = {
42926
+ init: {
42927
+ description: "\u521D\u59CB\u5316 dbcli \u914D\u7F6E\uFF0C\u89E3\u6790 .env \u4E26\u9032\u884C\u4E92\u52D5\u5F0F\u63D0\u793A",
42928
+ welcome: "\u6B61\u8FCE\u4F7F\u7528 dbcli",
42929
+ select_system: "\u9078\u64C7\u8CC7\u6599\u5EAB\u7CFB\u7D71\uFF1A",
42930
+ prompt_host: "\u8CC7\u6599\u5EAB\u4E3B\u6A5F\uFF1A",
42931
+ prompt_port: "\u8CC7\u6599\u5EAB\u57E0\u865F\uFF1A",
42932
+ prompt_user: "\u8CC7\u6599\u5EAB\u4F7F\u7528\u8005\uFF1A",
42933
+ prompt_password: "\u8CC7\u6599\u5EAB\u5BC6\u78BC\uFF1A",
42934
+ prompt_name: "\u8CC7\u6599\u5EAB\u540D\u7A31\uFF1A",
42935
+ prompt_permission: "\u6B0A\u9650\u7B49\u7D1A\uFF08query-only, read-write, admin\uFF09\uFF1A",
42936
+ env_parse_note: "\u63D0\u793A\uFF1A\u7121\u6CD5\u89E3\u6790 .env \u914D\u7F6E\uFF0C\u4F7F\u7528\u4E92\u52D5\u5F0F\u63D0\u793A",
42937
+ connection_testing: "\u6B63\u5728\u6E2C\u8A66\u8CC7\u6599\u5EAB\u9023\u63A5...",
42938
+ connection_success: "\u2713 \u8CC7\u6599\u5EAB\u9023\u63A5\u6210\u529F",
42939
+ connection_failed: "\u2717 \u8CC7\u6599\u5EAB\u9023\u63A5\u5931\u6557",
42940
+ config_saved: "\u914D\u7F6E\u5DF2\u4FDD\u5B58\u81F3 .dbcli",
42941
+ config_exists_overwrite: "\u914D\u7F6E\u6A94\u6848 .dbcli \u5DF2\u5B58\u5728\u3002\u662F\u5426\u8986\u84CB\uFF1F (y/n)\uFF1A",
42942
+ cancelled: "\u5DF2\u53D6\u6D88\u3002\u914D\u7F6E\u672A\u66F4\u6539\u3002"
42943
+ },
42944
+ schema: {
42945
+ description: "\u6AA2\u7D22\u8868\u683C\u7D50\u69CB\u6216\u5217\u51FA\u6240\u6709\u8868\u683C",
42946
+ fetching: "\u6B63\u5728\u6293\u53D6\u6A21\u5F0F...",
42947
+ success: "\u6A21\u5F0F\u5DF2\u66F4\u65B0",
42948
+ not_found: "\u8CC7\u6599\u5EAB\u4E2D\u627E\u4E0D\u5230\u8868\u683C",
42949
+ refresh_prompt: "\u6A21\u5F0F\u6709\u8B8A\u66F4\u3002\u662F\u5426\u5957\u7528\uFF1F (y/n)\uFF1A",
42950
+ columns_header: "\u6B04\u4F4D",
42951
+ scanning_database: "\uD83D\uDD0D \u6B63\u5728\u6383\u63CF\u8CC7\u6599\u5EAB\u67B6\u69CB...",
42952
+ tables_found: "\uD83D\uDCCD \u627E\u5230 {count} \u500B\u8868\u683C\u3002\u6B63\u5728\u7372\u53D6\u67B6\u69CB\u8A73\u60C5...",
42953
+ processing_tables: " \u8655\u7406\u4E86 {processed}/{total} \u500B\u8868\u683C",
42954
+ schema_exists_warning: "\u26A0\uFE0F \u8CC7\u6599\u5EAB\u67B6\u69CB\u5DF2\u5B58\u5728\u65BC .dbcli",
42955
+ use_force_to_override: " \u4F7F\u7528 --force \u9032\u884C\u8986\u84CB\u800C\u7121\u9700\u78BA\u8A8D"
42956
+ },
42957
+ list: {
42958
+ description: "\u5217\u51FA\u8CC7\u6599\u5EAB\u4E2D\u7684\u6240\u6709\u8868\u683C",
42959
+ no_tables: "\u8CC7\u6599\u5EAB\u4E2D\u672A\u627E\u5230\u8868\u683C"
42960
+ },
42961
+ query: {
42962
+ description: "\u57F7\u884C SQL \u67E5\u8A62",
42963
+ executing: "\u6B63\u5728\u57F7\u884C\u67E5\u8A62...",
42964
+ no_results: "\u672A\u8FD4\u56DE\u4EFB\u4F55\u7D50\u679C",
42965
+ result_count: "\u7D50\u679C\uFF1A{count} \u5217"
42966
+ },
42967
+ errors: {
42968
+ message: "\u932F\u8AA4\uFF1A{message}",
42969
+ invalid_config: "\u914D\u7F6E\u7121\u6548\uFF1A{field}",
42970
+ connection_failed: "\u7121\u6CD5\u9023\u63A5\u5230\u8CC7\u6599\u5EAB\uFF1A{message}",
42971
+ permission_denied: "\u6B0A\u9650\u88AB\u62D2\uFF08\u9700\u8981\uFF1A{required}\uFF09",
42972
+ table_not_found: "\u627E\u4E0D\u5230\u8868\u683C\uFF1A{table}",
42973
+ unsupported_lang: "\u4E0D\u652F\u63F4\u7684\u8A9E\u8A00 '{lang}'\uFF0C\u4F7F\u7528\u82F1\u6587",
42974
+ invalid_json: "\u7121\u6548\u7684 JSON\uFF1A{message}",
42975
+ table_blacklisted: "\u932F\u8AA4: \u8868\u683C '{table}' \u7684 {operation} \u64CD\u4F5C\u5DF2\u88AB\u9ED1\u540D\u55AE",
42976
+ table_already_blacklisted: "\u932F\u8AA4: \u8868\u683C '{table}' \u5DF2\u5728\u9ED1\u540D\u55AE\u4E2D",
42977
+ table_not_in_blacklist: "\u932F\u8AA4: \u8868\u683C '{table}' \u4E0D\u5728\u9ED1\u540D\u55AE\u4E2D",
42978
+ column_already_blacklisted: "\u932F\u8AA4: \u6B04\u4F4D '{table}.{column}' \u5DF2\u5728\u9ED1\u540D\u55AE\u4E2D",
42979
+ column_not_in_blacklist: "\u932F\u8AA4: \u6B04\u4F4D '{table}.{column}' \u4E0D\u5728\u9ED1\u540D\u55AE\u4E2D",
42980
+ invalid_table_name: "\u932F\u8AA4: \u7121\u6548\u7684\u8868\u683C\u540D\u7A31: {table}",
42981
+ invalid_column_format: "\u932F\u8AA4: \u7121\u6548\u7684\u6B04\u4F4D\u683C\u5F0F\u3002\u4F7F\u7528 'table.column'"
42982
+ },
42983
+ success: {
42984
+ inserted: "\u6210\u529F\u63D2\u5165 {count} \u5217",
42985
+ updated: "\u6210\u529F\u66F4\u65B0 {count} \u5217",
42986
+ deleted: "\u6210\u529F\u522A\u9664 {count} \u5217",
42987
+ no_changes: "\u6C92\u6709\u8B8A\u66F4\u8981\u5957\u7528"
42988
+ },
42989
+ insert: {
42990
+ description: "\u63D2\u5165\u8CC7\u6599\u5230\u8868\u683C",
42991
+ prompt_data: "\u8F38\u5165\u8981\u63D2\u5165\u7684 JSON \u8CC7\u6599\uFF1A",
42992
+ confirm: "\u5C07 {count} \u5217\u63D2\u5165\u5230 {table}\uFF1F (y/n)\uFF1A"
42993
+ },
42994
+ update: {
42995
+ description: "\u66F4\u65B0\u8868\u683C\u4E2D\u7684\u8CC7\u6599",
42996
+ prompt_where: "\u8F38\u5165 WHERE \u5B50\u53E5 (\u4F8B\u5982\uFF1Aid=1)\uFF1A",
42997
+ prompt_set: '\u8F38\u5165 JSON \u66F4\u65B0 (\u4F8B\u5982\uFF1A{"status": "active"})\uFF1A',
42998
+ confirm: "\u66F4\u65B0 {table} \u4E2D\u7684\u5217\uFF1F (y/n)\uFF1A"
42999
+ },
43000
+ delete: {
43001
+ description: "\u522A\u9664\u8868\u683C\u4E2D\u7684\u8CC7\u6599",
43002
+ prompt_where: "\u8F38\u5165 WHERE \u5B50\u53E5 (\u4F8B\u5982\uFF1Aid=1)\uFF1A",
43003
+ confirm: "\u522A\u9664 {table} \u4E2D\u7684\u5217\uFF1F (y/n)\uFF1A",
43004
+ admin_only: "\u522A\u9664\u547D\u4EE4\u9700\u8981\u7BA1\u7406\u54E1\u6B0A\u9650"
43005
+ },
43006
+ export: {
43007
+ description: "\u532F\u51FA\u67E5\u8A62\u7D50\u679C",
43008
+ formats: "\u652F\u63F4\u7684\u683C\u5F0F\uFF1Ajson\u3001csv",
43009
+ exported: "\u5DF2\u5C07 {count} \u5217\u532F\u51FA\u81F3 {file}"
43010
+ },
43011
+ skill: {
43012
+ description: "\u751F\u6210 AI \u6280\u80FD\u6587\u6A94",
43013
+ installed: "\u6280\u80FD\u5DF2\u5B89\u88DD\u81F3 {path}"
43014
+ },
43015
+ blacklist: {
43016
+ description: "\u7BA1\u7406\u654F\u611F\u8CC7\u6599\u9ED1\u540D\u55AE\u4EE5\u9632\u6B62 AI \u5B58\u53D6",
43017
+ list_title: "\u76EE\u524D\u9ED1\u540D\u55AE\u914D\u7F6E",
43018
+ tables_label: "\u5DF2\u9ED1\u540D\u55AE\u7684\u8868\u683C",
43019
+ columns_label: "\u5DF2\u9ED1\u540D\u55AE\u7684\u6B04\u4F4D",
43020
+ none: "\u76EE\u524D\u6C92\u6709\u9ED1\u540D\u55AE\u8868\u683C\u6216\u6B04\u4F4D",
43021
+ table_added: "\u2713 \u8868\u683C '{table}' \u5DF2\u65B0\u589E\u81F3\u9ED1\u540D\u55AE",
43022
+ table_removed: "\u2713 \u8868\u683C '{table}' \u5DF2\u5F9E\u9ED1\u540D\u55AE\u79FB\u9664",
43023
+ column_added: "\u2713 \u6B04\u4F4D '{table}.{column}' \u5DF2\u65B0\u589E\u81F3\u9ED1\u540D\u55AE",
43024
+ column_removed: "\u2713 \u6B04\u4F4D '{table}.{column}' \u5DF2\u5F9E\u9ED1\u540D\u55AE\u79FB\u9664"
43025
+ },
43026
+ security: {
43027
+ columns_omitted: "\u5B89\u5168: {count} \u500B\u6B04\u4F4D\u6839\u64DA\u4F60\u7684\u9ED1\u540D\u55AE\u5DF2\u88AB\u96B1\u85CF"
43028
+ },
43029
+ warnings: {
43030
+ blacklist_override_used: "\u8B66\u544A: \u5DF2\u555F\u7528\u9ED1\u540D\u55AE\u8986\u84CB (DBCLI_OVERRIDE_BLACKLIST=true)\u3002\u57F7\u884C {operation} \u5728\u5DF2\u9ED1\u540D\u55AE\u7684\u8868\u683C '{table}' \u4E0A"
43031
+ }
43032
+ };
42815
43033
 
42816
43034
  // src/i18n/message-loader.ts
43035
+ var BUNDLED_MESSAGES = {
43036
+ en: messages_default,
43037
+ "zh-TW": messages_default2
43038
+ };
43039
+
42817
43040
  class MessageLoader {
42818
43041
  static instance = null;
42819
43042
  messages = {};
@@ -42830,31 +43053,10 @@ class MessageLoader {
42830
43053
  return MessageLoader.instance;
42831
43054
  }
42832
43055
  loadMessages() {
42833
- try {
42834
- if (this.currentLang !== "en") {
42835
- this.messages = this.loadLanguageFile(this.currentLang);
42836
- }
42837
- this.fallbackMessages = this.loadLanguageFile("en");
42838
- } catch (error) {
42839
- console.error("Failed to load messages:", error);
42840
- throw new Error("Failed to initialize message loader");
42841
- }
42842
- }
42843
- loadLanguageFile(lang) {
42844
- try {
42845
- const dir = import.meta.dir;
42846
- const filePath = `${dir}/../../resources/lang/${lang}/messages.json`;
42847
- const messages = __require(filePath);
42848
- if (!messages || typeof messages !== "object") {
42849
- throw new Error(`Language file contains invalid data: ${lang}`);
42850
- }
42851
- return messages;
42852
- } catch (error) {
42853
- if (error instanceof Error) {
42854
- throw new Error(`Language file error (${lang}): ${error.message}`);
42855
- }
42856
- throw error;
43056
+ if (this.currentLang !== "en") {
43057
+ this.messages = BUNDLED_MESSAGES[this.currentLang] || {};
42857
43058
  }
43059
+ this.fallbackMessages = BUNDLED_MESSAGES["en"] || {};
42858
43060
  }
42859
43061
  t(key) {
42860
43062
  const parts = key.split(".");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carllee1983/dbcli",
3
- "version": "0.3.1-beta",
3
+ "version": "0.3.2-beta",
4
4
  "description": "Database CLI for AI agents",
5
5
  "type": "module",
6
6
  "publishConfig": {