@pellux/goodvibes-sdk 0.24.0 → 0.25.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.
Files changed (198) hide show
  1. package/dist/_internal/platform/agents/orchestrator.d.ts +2 -0
  2. package/dist/_internal/platform/agents/orchestrator.d.ts.map +1 -1
  3. package/dist/_internal/platform/agents/orchestrator.js +38 -0
  4. package/dist/_internal/platform/automation/delivery-manager.d.ts +5 -0
  5. package/dist/_internal/platform/automation/delivery-manager.d.ts.map +1 -1
  6. package/dist/_internal/platform/automation/delivery-manager.js +14 -1
  7. package/dist/_internal/platform/automation/manager-runtime.d.ts +5 -0
  8. package/dist/_internal/platform/automation/manager-runtime.d.ts.map +1 -1
  9. package/dist/_internal/platform/automation/manager-runtime.js +32 -0
  10. package/dist/_internal/platform/channels/plugin-registry.d.ts +6 -0
  11. package/dist/_internal/platform/channels/plugin-registry.d.ts.map +1 -1
  12. package/dist/_internal/platform/channels/plugin-registry.js +17 -4
  13. package/dist/_internal/platform/channels/route-manager.d.ts +7 -0
  14. package/dist/_internal/platform/channels/route-manager.d.ts.map +1 -1
  15. package/dist/_internal/platform/channels/route-manager.js +41 -3
  16. package/dist/_internal/platform/channels/surface-registry.d.ts +3 -1
  17. package/dist/_internal/platform/channels/surface-registry.d.ts.map +1 -1
  18. package/dist/_internal/platform/channels/surface-registry.js +16 -17
  19. package/dist/_internal/platform/config/schema-types.d.ts +1 -1
  20. package/dist/_internal/platform/config/schema-types.d.ts.map +1 -1
  21. package/dist/_internal/platform/control-plane/gateway.d.ts +5 -0
  22. package/dist/_internal/platform/control-plane/gateway.d.ts.map +1 -1
  23. package/dist/_internal/platform/control-plane/gateway.js +69 -4
  24. package/dist/_internal/platform/daemon/facade-composition.d.ts.map +1 -1
  25. package/dist/_internal/platform/daemon/facade-composition.js +2 -0
  26. package/dist/_internal/platform/daemon/facade.d.ts.map +1 -1
  27. package/dist/_internal/platform/daemon/facade.js +3 -1
  28. package/dist/_internal/platform/daemon/service-manager.d.ts +5 -0
  29. package/dist/_internal/platform/daemon/service-manager.d.ts.map +1 -1
  30. package/dist/_internal/platform/daemon/service-manager.js +29 -0
  31. package/dist/_internal/platform/integrations/delivery.d.ts +5 -1
  32. package/dist/_internal/platform/integrations/delivery.d.ts.map +1 -1
  33. package/dist/_internal/platform/integrations/delivery.js +8 -1
  34. package/dist/_internal/platform/integrations/notifier.d.ts +5 -1
  35. package/dist/_internal/platform/integrations/notifier.d.ts.map +1 -1
  36. package/dist/_internal/platform/integrations/notifier.js +6 -3
  37. package/dist/_internal/platform/intelligence/lsp/service.d.ts.map +1 -1
  38. package/dist/_internal/platform/intelligence/lsp/service.js +18 -9
  39. package/dist/_internal/platform/permissions/manager.d.ts +3 -1
  40. package/dist/_internal/platform/permissions/manager.d.ts.map +1 -1
  41. package/dist/_internal/platform/permissions/manager.js +9 -5
  42. package/dist/_internal/platform/providers/anthropic-vertex.d.ts.map +1 -1
  43. package/dist/_internal/platform/providers/anthropic-vertex.js +135 -2
  44. package/dist/_internal/platform/runtime/emitters/routes.d.ts +5 -0
  45. package/dist/_internal/platform/runtime/emitters/routes.d.ts.map +1 -1
  46. package/dist/_internal/platform/runtime/emitters/routes.js +3 -0
  47. package/dist/_internal/platform/runtime/events/contracts/automation-route.d.ts +1 -0
  48. package/dist/_internal/platform/runtime/events/contracts/automation-route.d.ts.map +1 -1
  49. package/dist/_internal/platform/runtime/events/contracts/automation-route.js +7 -0
  50. package/dist/_internal/platform/runtime/events/contracts.d.ts +1 -1
  51. package/dist/_internal/platform/runtime/events/contracts.d.ts.map +1 -1
  52. package/dist/_internal/platform/runtime/events/contracts.js +3 -2
  53. package/dist/_internal/platform/runtime/events/routes.d.ts +5 -0
  54. package/dist/_internal/platform/runtime/events/routes.d.ts.map +1 -1
  55. package/dist/_internal/platform/runtime/feature-flags/flags.d.ts.map +1 -1
  56. package/dist/_internal/platform/runtime/feature-flags/flags.js +17 -21
  57. package/dist/_internal/platform/runtime/feature-flags/gates.d.ts +7 -0
  58. package/dist/_internal/platform/runtime/feature-flags/gates.d.ts.map +1 -0
  59. package/dist/_internal/platform/runtime/feature-flags/gates.js +38 -0
  60. package/dist/_internal/platform/runtime/feature-flags/index.d.ts +2 -0
  61. package/dist/_internal/platform/runtime/feature-flags/index.d.ts.map +1 -1
  62. package/dist/_internal/platform/runtime/feature-flags/index.js +1 -0
  63. package/dist/_internal/platform/runtime/mcp/index.d.ts +2 -1
  64. package/dist/_internal/platform/runtime/mcp/index.d.ts.map +1 -1
  65. package/dist/_internal/platform/runtime/mcp/index.js +4 -1
  66. package/dist/_internal/platform/runtime/permissions/index.d.ts +20 -1
  67. package/dist/_internal/platform/runtime/permissions/index.d.ts.map +1 -1
  68. package/dist/_internal/platform/runtime/permissions/index.js +27 -1
  69. package/dist/_internal/platform/runtime/permissions/policy-loader.d.ts +6 -0
  70. package/dist/_internal/platform/runtime/permissions/policy-loader.d.ts.map +1 -1
  71. package/dist/_internal/platform/runtime/permissions/policy-loader.js +7 -2
  72. package/dist/_internal/platform/runtime/plugins/index.d.ts +2 -1
  73. package/dist/_internal/platform/runtime/plugins/index.d.ts.map +1 -1
  74. package/dist/_internal/platform/runtime/plugins/index.js +4 -1
  75. package/dist/_internal/platform/runtime/services.d.ts +1 -0
  76. package/dist/_internal/platform/runtime/services.d.ts.map +1 -1
  77. package/dist/_internal/platform/runtime/services.js +21 -5
  78. package/dist/_internal/platform/runtime/shell-command-ops.d.ts +2 -0
  79. package/dist/_internal/platform/runtime/shell-command-ops.d.ts.map +1 -1
  80. package/dist/_internal/platform/runtime/shell-command-ops.js +4 -1
  81. package/dist/_internal/platform/runtime/tasks/index.d.ts +2 -1
  82. package/dist/_internal/platform/runtime/tasks/index.d.ts.map +1 -1
  83. package/dist/_internal/platform/runtime/tasks/index.js +2 -2
  84. package/dist/_internal/platform/runtime/tasks/manager.d.ts +5 -1
  85. package/dist/_internal/platform/runtime/tasks/manager.d.ts.map +1 -1
  86. package/dist/_internal/platform/runtime/tasks/manager.js +30 -1
  87. package/dist/_internal/platform/runtime/telemetry/index.d.ts +9 -3
  88. package/dist/_internal/platform/runtime/telemetry/index.d.ts.map +1 -1
  89. package/dist/_internal/platform/runtime/telemetry/index.js +7 -4
  90. package/dist/_internal/platform/runtime/tools/index.d.ts.map +1 -1
  91. package/dist/_internal/platform/runtime/tools/index.js +4 -1
  92. package/dist/_internal/platform/runtime/tools/types.d.ts +6 -0
  93. package/dist/_internal/platform/runtime/tools/types.d.ts.map +1 -1
  94. package/dist/_internal/platform/security/token-audit.d.ts +7 -0
  95. package/dist/_internal/platform/security/token-audit.d.ts.map +1 -1
  96. package/dist/_internal/platform/security/token-audit.js +6 -2
  97. package/dist/_internal/platform/state/mode-manager.d.ts +7 -0
  98. package/dist/_internal/platform/state/mode-manager.d.ts.map +1 -1
  99. package/dist/_internal/platform/state/mode-manager.js +25 -0
  100. package/dist/_internal/platform/tools/index.d.ts +4 -0
  101. package/dist/_internal/platform/tools/index.d.ts.map +1 -1
  102. package/dist/_internal/platform/tools/index.js +37 -23
  103. package/dist/_internal/platform/tools/shared/overflow.d.ts +3 -0
  104. package/dist/_internal/platform/tools/shared/overflow.d.ts.map +1 -1
  105. package/dist/_internal/platform/tools/shared/overflow.js +6 -2
  106. package/dist/_internal/platform/version.js +1 -1
  107. package/dist/_internal/platform/watchers/registry.d.ts +6 -0
  108. package/dist/_internal/platform/watchers/registry.d.ts.map +1 -1
  109. package/dist/_internal/platform/watchers/registry.js +35 -0
  110. package/package.json +9 -8
  111. package/vendor/bash-language-server/CHANGELOG.md +453 -0
  112. package/vendor/bash-language-server/GOODVIBES_PATCH.md +22 -0
  113. package/vendor/bash-language-server/README.md +230 -0
  114. package/vendor/bash-language-server/out/analyser.d.ts +187 -0
  115. package/vendor/bash-language-server/out/analyser.js +782 -0
  116. package/vendor/bash-language-server/out/analyser.js.map +1 -0
  117. package/vendor/bash-language-server/out/builtins.d.ts +2 -0
  118. package/vendor/bash-language-server/out/builtins.js +71 -0
  119. package/vendor/bash-language-server/out/builtins.js.map +1 -0
  120. package/vendor/bash-language-server/out/cli.d.ts +3 -0
  121. package/vendor/bash-language-server/out/cli.js +74 -0
  122. package/vendor/bash-language-server/out/cli.js.map +1 -0
  123. package/vendor/bash-language-server/out/config.d.ts +88 -0
  124. package/vendor/bash-language-server/out/config.js +96 -0
  125. package/vendor/bash-language-server/out/config.js.map +1 -0
  126. package/vendor/bash-language-server/out/executables.d.ts +19 -0
  127. package/vendor/bash-language-server/out/executables.js +86 -0
  128. package/vendor/bash-language-server/out/executables.js.map +1 -0
  129. package/vendor/bash-language-server/out/parser.d.ts +2 -0
  130. package/vendor/bash-language-server/out/parser.js +36 -0
  131. package/vendor/bash-language-server/out/parser.js.map +1 -0
  132. package/vendor/bash-language-server/out/reserved-words.d.ts +2 -0
  133. package/vendor/bash-language-server/out/reserved-words.js +33 -0
  134. package/vendor/bash-language-server/out/reserved-words.js.map +1 -0
  135. package/vendor/bash-language-server/out/server.d.ts +56 -0
  136. package/vendor/bash-language-server/out/server.js +756 -0
  137. package/vendor/bash-language-server/out/server.js.map +1 -0
  138. package/vendor/bash-language-server/out/shellcheck/config.d.ts +5 -0
  139. package/vendor/bash-language-server/out/shellcheck/config.js +17 -0
  140. package/vendor/bash-language-server/out/shellcheck/config.js.map +1 -0
  141. package/vendor/bash-language-server/out/shellcheck/directive.d.ts +18 -0
  142. package/vendor/bash-language-server/out/shellcheck/directive.js +62 -0
  143. package/vendor/bash-language-server/out/shellcheck/directive.js.map +1 -0
  144. package/vendor/bash-language-server/out/shellcheck/index.d.ts +22 -0
  145. package/vendor/bash-language-server/out/shellcheck/index.js +229 -0
  146. package/vendor/bash-language-server/out/shellcheck/index.js.map +1 -0
  147. package/vendor/bash-language-server/out/shellcheck/types.d.ts +175 -0
  148. package/vendor/bash-language-server/out/shellcheck/types.js +35 -0
  149. package/vendor/bash-language-server/out/shellcheck/types.js.map +1 -0
  150. package/vendor/bash-language-server/out/shfmt/index.d.ts +18 -0
  151. package/vendor/bash-language-server/out/shfmt/index.js +151 -0
  152. package/vendor/bash-language-server/out/shfmt/index.js.map +1 -0
  153. package/vendor/bash-language-server/out/snippets.d.ts +2 -0
  154. package/vendor/bash-language-server/out/snippets.js +671 -0
  155. package/vendor/bash-language-server/out/snippets.js.map +1 -0
  156. package/vendor/bash-language-server/out/types.d.ts +13 -0
  157. package/vendor/bash-language-server/out/types.js +12 -0
  158. package/vendor/bash-language-server/out/types.js.map +1 -0
  159. package/vendor/bash-language-server/out/util/array.d.ts +14 -0
  160. package/vendor/bash-language-server/out/util/array.js +36 -0
  161. package/vendor/bash-language-server/out/util/array.js.map +1 -0
  162. package/vendor/bash-language-server/out/util/async.d.ts +13 -0
  163. package/vendor/bash-language-server/out/util/async.js +24 -0
  164. package/vendor/bash-language-server/out/util/async.js.map +1 -0
  165. package/vendor/bash-language-server/out/util/declarations.d.ts +88 -0
  166. package/vendor/bash-language-server/out/util/declarations.js +295 -0
  167. package/vendor/bash-language-server/out/util/declarations.js.map +1 -0
  168. package/vendor/bash-language-server/out/util/discriminate.d.ts +1 -0
  169. package/vendor/bash-language-server/out/util/discriminate.js +7 -0
  170. package/vendor/bash-language-server/out/util/discriminate.js.map +1 -0
  171. package/vendor/bash-language-server/out/util/fs.d.ts +6 -0
  172. package/vendor/bash-language-server/out/util/fs.js +73 -0
  173. package/vendor/bash-language-server/out/util/fs.js.map +1 -0
  174. package/vendor/bash-language-server/out/util/logger.d.ts +35 -0
  175. package/vendor/bash-language-server/out/util/logger.js +105 -0
  176. package/vendor/bash-language-server/out/util/logger.js.map +1 -0
  177. package/vendor/bash-language-server/out/util/lsp.d.ts +5 -0
  178. package/vendor/bash-language-server/out/util/lsp.js +13 -0
  179. package/vendor/bash-language-server/out/util/lsp.js.map +1 -0
  180. package/vendor/bash-language-server/out/util/platform.d.ts +1 -0
  181. package/vendor/bash-language-server/out/util/platform.js +7 -0
  182. package/vendor/bash-language-server/out/util/platform.js.map +1 -0
  183. package/vendor/bash-language-server/out/util/sh.d.ts +16 -0
  184. package/vendor/bash-language-server/out/util/sh.js +132 -0
  185. package/vendor/bash-language-server/out/util/sh.js.map +1 -0
  186. package/vendor/bash-language-server/out/util/shebang.d.ts +10 -0
  187. package/vendor/bash-language-server/out/util/shebang.js +53 -0
  188. package/vendor/bash-language-server/out/util/shebang.js.map +1 -0
  189. package/vendor/bash-language-server/out/util/sourcing.d.ts +15 -0
  190. package/vendor/bash-language-server/out/util/sourcing.js +182 -0
  191. package/vendor/bash-language-server/out/util/sourcing.js.map +1 -0
  192. package/vendor/bash-language-server/out/util/tree-sitter.d.ts +22 -0
  193. package/vendor/bash-language-server/out/util/tree-sitter.js +110 -0
  194. package/vendor/bash-language-server/out/util/tree-sitter.js.map +1 -0
  195. package/vendor/bash-language-server/package.json +52 -0
  196. package/vendor/bash-language-server/parser.info +2 -0
  197. package/vendor/bash-language-server/tree-sitter-bash.wasm +0 -0
  198. package/scripts/postinstall-patch-minimatch.mjs +0 -285
@@ -0,0 +1,35 @@
1
+ import * as LSP from 'vscode-languageserver';
2
+ export declare const LOG_LEVEL_ENV_VAR = "BASH_IDE_LOG_LEVEL";
3
+ export declare const LOG_LEVELS: readonly ["debug", "info", "warning", "error"];
4
+ export declare const DEFAULT_LOG_LEVEL: LogLevel;
5
+ type LogLevel = (typeof LOG_LEVELS)[number];
6
+ /**
7
+ * Set the log connection. Should be done at startup.
8
+ */
9
+ export declare function setLogConnection(connection: LSP.Connection): void;
10
+ /**
11
+ * Set the minimum log level.
12
+ */
13
+ export declare function setLogLevel(logLevel: LogLevel): void;
14
+ export declare class Logger {
15
+ private prefix;
16
+ constructor({ prefix }?: {
17
+ prefix?: string;
18
+ });
19
+ static MESSAGE_TYPE_TO_LOG_LEVEL_MSG: Record<LSP.MessageType, string>;
20
+ log(severity: LSP.MessageType, messageObjects: any[]): void;
21
+ debug(message: string, ...additionalArgs: any[]): void;
22
+ info(message: string, ...additionalArgs: any[]): void;
23
+ warn(message: string, ...additionalArgs: any[]): void;
24
+ error(message: string, ...additionalArgs: any[]): void;
25
+ }
26
+ /**
27
+ * Default logger.
28
+ */
29
+ export declare const logger: Logger;
30
+ /**
31
+ * Get the log level from the environment, before the server initializes.
32
+ * Should only be used internally.
33
+ */
34
+ export declare function getLogLevelFromEnvironment(): LSP.MessageType;
35
+ export {};
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logger = exports.Logger = exports.DEFAULT_LOG_LEVEL = exports.LOG_LEVELS = exports.LOG_LEVEL_ENV_VAR = void 0;
4
+ exports.setLogConnection = setLogConnection;
5
+ exports.setLogLevel = setLogLevel;
6
+ exports.getLogLevelFromEnvironment = getLogLevelFromEnvironment;
7
+ const LSP = require("vscode-languageserver");
8
+ exports.LOG_LEVEL_ENV_VAR = 'BASH_IDE_LOG_LEVEL';
9
+ exports.LOG_LEVELS = ['debug', 'info', 'warning', 'error'];
10
+ exports.DEFAULT_LOG_LEVEL = 'info';
11
+ const LOG_LEVELS_TO_MESSAGE_TYPES = {
12
+ debug: LSP.MessageType.Log,
13
+ info: LSP.MessageType.Info,
14
+ warning: LSP.MessageType.Warning,
15
+ error: LSP.MessageType.Error,
16
+ };
17
+ // Singleton madness to allow for logging from anywhere in the codebase
18
+ let _connection = null;
19
+ let _logLevel = getLogLevelFromEnvironment();
20
+ /**
21
+ * Set the log connection. Should be done at startup.
22
+ */
23
+ function setLogConnection(connection) {
24
+ _connection = connection;
25
+ }
26
+ /**
27
+ * Set the minimum log level.
28
+ */
29
+ function setLogLevel(logLevel) {
30
+ _logLevel = LOG_LEVELS_TO_MESSAGE_TYPES[logLevel];
31
+ }
32
+ class Logger {
33
+ constructor({ prefix = '' } = {}) {
34
+ this.prefix = prefix;
35
+ }
36
+ log(severity, messageObjects) {
37
+ if (_logLevel < severity) {
38
+ return;
39
+ }
40
+ if (!_connection) {
41
+ // eslint-disable-next-line no-console
42
+ console.warn(`The logger's LSP Connection is not set. Dropping messages`);
43
+ return;
44
+ }
45
+ const formattedMessage = messageObjects
46
+ .map((p) => {
47
+ if (p instanceof Error) {
48
+ return p.stack || p.message;
49
+ }
50
+ if (typeof p === 'object') {
51
+ return JSON.stringify(p, null, 2);
52
+ }
53
+ return p;
54
+ })
55
+ .join(' ');
56
+ const level = Logger.MESSAGE_TYPE_TO_LOG_LEVEL_MSG[severity];
57
+ const prefix = this.prefix ? `${this.prefix} - ` : '';
58
+ const time = new Date().toISOString().substring(11, 23);
59
+ const message = `${time} ${level} ${prefix}${formattedMessage}`;
60
+ _connection.sendNotification(LSP.LogMessageNotification.type, {
61
+ type: severity,
62
+ message,
63
+ });
64
+ }
65
+ debug(message, ...additionalArgs) {
66
+ this.log(LSP.MessageType.Log, [message, ...additionalArgs]);
67
+ }
68
+ info(message, ...additionalArgs) {
69
+ this.log(LSP.MessageType.Info, [message, ...additionalArgs]);
70
+ }
71
+ warn(message, ...additionalArgs) {
72
+ this.log(LSP.MessageType.Warning, [message, ...additionalArgs]);
73
+ }
74
+ error(message, ...additionalArgs) {
75
+ this.log(LSP.MessageType.Error, [message, ...additionalArgs]);
76
+ }
77
+ }
78
+ exports.Logger = Logger;
79
+ Logger.MESSAGE_TYPE_TO_LOG_LEVEL_MSG = {
80
+ [LSP.MessageType.Error]: 'ERROR ⛔️',
81
+ [LSP.MessageType.Warning]: 'WARNING ⛔️',
82
+ [LSP.MessageType.Info]: 'INFO',
83
+ [LSP.MessageType.Log]: 'DEBUG',
84
+ };
85
+ /**
86
+ * Default logger.
87
+ */
88
+ exports.logger = new Logger();
89
+ /**
90
+ * Get the log level from the environment, before the server initializes.
91
+ * Should only be used internally.
92
+ */
93
+ function getLogLevelFromEnvironment() {
94
+ const logLevelFromEnvironment = process.env[exports.LOG_LEVEL_ENV_VAR];
95
+ if (logLevelFromEnvironment) {
96
+ const logLevel = LOG_LEVELS_TO_MESSAGE_TYPES[logLevelFromEnvironment];
97
+ if (logLevel) {
98
+ return logLevel;
99
+ }
100
+ // eslint-disable-next-line no-console
101
+ console.warn(`Invalid ${exports.LOG_LEVEL_ENV_VAR} "${logLevelFromEnvironment}", expected one of: ${Object.keys(LOG_LEVELS_TO_MESSAGE_TYPES).join(', ')}`);
102
+ }
103
+ return LOG_LEVELS_TO_MESSAGE_TYPES[exports.DEFAULT_LOG_LEVEL];
104
+ }
105
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/util/logger.ts"],"names":[],"mappings":";;;AAwBA,4CAEC;AAKD,kCAEC;AA2ED,gEAgBC;AA5HD,6CAA4C;AAE/B,QAAA,iBAAiB,GAAG,oBAAoB,CAAA;AACxC,QAAA,UAAU,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAU,CAAA;AAC3D,QAAA,iBAAiB,GAAa,MAAM,CAAA;AAIjD,MAAM,2BAA2B,GAE7B;IACF,KAAK,EAAE,GAAG,CAAC,WAAW,CAAC,GAAG;IAC1B,IAAI,EAAE,GAAG,CAAC,WAAW,CAAC,IAAI;IAC1B,OAAO,EAAE,GAAG,CAAC,WAAW,CAAC,OAAO;IAChC,KAAK,EAAE,GAAG,CAAC,WAAW,CAAC,KAAK;CACpB,CAAA;AAEV,uEAAuE;AACvE,IAAI,WAAW,GAA0B,IAAI,CAAA;AAC7C,IAAI,SAAS,GAAoB,0BAA0B,EAAE,CAAA;AAE7D;;GAEG;AACH,SAAgB,gBAAgB,CAAC,UAA0B;IACzD,WAAW,GAAG,UAAU,CAAA;AAC1B,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,QAAkB;IAC5C,SAAS,GAAG,2BAA2B,CAAC,QAAQ,CAAC,CAAA;AACnD,CAAC;AAED,MAAa,MAAM;IAGjB,YAAY,EAAE,MAAM,GAAG,EAAE,KAA0B,EAAE;QACnD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IASM,GAAG,CAAC,QAAyB,EAAE,cA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,CACV,WAAW,yBAAiB,KAAK,uBAAuB,uBAAuB,MAAM,CAAC,IAAI,CACxF,2BAA2B,CAC5B,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACf,CAAA;IACH,CAAC;IAED,OAAO,2BAA2B,CAAC,yBAAiB,CAAC,CAAA;AACvD,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as LSP from 'vscode-languageserver/node';
2
+ /**
3
+ * Determine if a position is included in a range.
4
+ */
5
+ export declare function isPositionIncludedInRange(position: LSP.Position, range: LSP.Range): boolean;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPositionIncludedInRange = isPositionIncludedInRange;
4
+ /**
5
+ * Determine if a position is included in a range.
6
+ */
7
+ function isPositionIncludedInRange(position, range) {
8
+ return (range.start.line <= position.line &&
9
+ range.end.line >= position.line &&
10
+ range.start.character <= position.character &&
11
+ range.end.character >= position.character);
12
+ }
13
+ //# sourceMappingURL=lsp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lsp.js","sourceRoot":"","sources":["../../src/util/lsp.ts"],"names":[],"mappings":";;AAKA,8DAOC;AAVD;;GAEG;AACH,SAAgB,yBAAyB,CAAC,QAAsB,EAAE,KAAgB;IAChF,OAAO,CACL,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI;QACjC,KAAK,CAAC,GAAG,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI;QAC/B,KAAK,CAAC,KAAK,CAAC,SAAS,IAAI,QAAQ,CAAC,SAAS;QAC3C,KAAK,CAAC,GAAG,CAAC,SAAS,IAAI,QAAQ,CAAC,SAAS,CAC1C,CAAA;AACH,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function isWindows(): boolean;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isWindows = isWindows;
4
+ function isWindows() {
5
+ return process.platform === 'win32';
6
+ }
7
+ //# sourceMappingURL=platform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.js","sourceRoot":"","sources":["../../src/util/platform.ts"],"names":[],"mappings":";;AAAA,8BAEC;AAFD,SAAgB,SAAS;IACvB,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAA;AACrC,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Execute the following sh program.
3
+ */
4
+ export declare function execShellScript(body: string, cmd?: string): Promise<string>;
5
+ /**
6
+ * Get documentation for the given word by using help and man.
7
+ */
8
+ export declare function getShellDocumentationWithoutCache({ word, }: {
9
+ word: string;
10
+ }): Promise<string | null>;
11
+ export declare function formatManOutput(manOutput: string): string;
12
+ /**
13
+ * Only works for one-parameter (serializable) functions.
14
+ */
15
+ export declare function memorize<T extends Function>(func: T): T;
16
+ export declare const getShellDocumentation: typeof getShellDocumentationWithoutCache;
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getShellDocumentation = void 0;
13
+ exports.execShellScript = execShellScript;
14
+ exports.getShellDocumentationWithoutCache = getShellDocumentationWithoutCache;
15
+ exports.formatManOutput = formatManOutput;
16
+ exports.memorize = memorize;
17
+ const ChildProcess = require("child_process");
18
+ const logger_1 = require("./logger");
19
+ const platform_1 = require("./platform");
20
+ /**
21
+ * Execute the following sh program.
22
+ */
23
+ function execShellScript(body, cmd = (0, platform_1.isWindows)() ? 'cmd.exe' : 'bash') {
24
+ const args = [];
25
+ if (cmd === 'cmd.exe') {
26
+ args.push('/c', body);
27
+ }
28
+ else {
29
+ args.push('--noprofile', '--norc', '-c', body);
30
+ }
31
+ const process = ChildProcess.spawn(cmd, args);
32
+ return new Promise((resolve, reject) => {
33
+ let output = '';
34
+ const handleClose = (returnCode) => {
35
+ if (returnCode === 0) {
36
+ resolve(output);
37
+ }
38
+ else {
39
+ reject(`Failed to execute ${body}`);
40
+ }
41
+ };
42
+ process.stdout.on('data', (buffer) => {
43
+ output += buffer;
44
+ });
45
+ process.on('close', handleClose);
46
+ process.on('error', handleClose);
47
+ });
48
+ }
49
+ // Currently only reserved words where documentation doesn't make sense.
50
+ // At least on OS X these just return the builtin man. On ubuntu there
51
+ // are no documentation for them.
52
+ const WORDS_WITHOUT_DOCUMENTATION = new Set([
53
+ 'else',
54
+ 'fi',
55
+ 'then',
56
+ 'esac',
57
+ 'elif',
58
+ 'done',
59
+ ]);
60
+ /**
61
+ * Get documentation for the given word by using help and man.
62
+ */
63
+ function getShellDocumentationWithoutCache(_a) {
64
+ return __awaiter(this, arguments, void 0, function* ({ word, }) {
65
+ if (word.split(' ').length > 1) {
66
+ throw new Error(`lookupDocumentation should be given a word, received "${word}"`);
67
+ }
68
+ if (WORDS_WITHOUT_DOCUMENTATION.has(word)) {
69
+ return null;
70
+ }
71
+ const DOCUMENTATION_COMMANDS = [
72
+ { type: 'help', command: `help ${word} | col -bx` },
73
+ // We have experimented with setting MANWIDTH to different values for reformatting.
74
+ // The default line width of the terminal works fine for hover, but could be better
75
+ // for completions.
76
+ { type: 'man', command: `man -P cat ${word} | col -bx` },
77
+ ];
78
+ for (const { type, command } of DOCUMENTATION_COMMANDS) {
79
+ try {
80
+ const documentation = yield execShellScript(command);
81
+ if (documentation) {
82
+ let formattedDocumentation = documentation.trim();
83
+ if (type === 'man') {
84
+ formattedDocumentation = formatManOutput(formattedDocumentation);
85
+ }
86
+ if (formattedDocumentation) {
87
+ return formattedDocumentation;
88
+ }
89
+ }
90
+ }
91
+ catch (error) {
92
+ // Ignoring if command fails and store failure in cache
93
+ logger_1.logger.error(`getShellDocumentation failed for "${word}"`, error);
94
+ }
95
+ }
96
+ return null;
97
+ });
98
+ }
99
+ function formatManOutput(manOutput) {
100
+ const indexNameBlock = manOutput.indexOf('NAME');
101
+ const indexBeforeFooter = manOutput.lastIndexOf('\n');
102
+ if (indexNameBlock < 0 || indexBeforeFooter < 0) {
103
+ return manOutput;
104
+ }
105
+ const formattedManOutput = manOutput.slice(indexNameBlock, indexBeforeFooter);
106
+ if (!formattedManOutput) {
107
+ logger_1.logger.error(`formatManOutput failed`, { manOutput });
108
+ return manOutput;
109
+ }
110
+ return formattedManOutput;
111
+ }
112
+ /**
113
+ * Only works for one-parameter (serializable) functions.
114
+ */
115
+ /* eslint-disable @typescript-eslint/ban-types */
116
+ function memorize(func) {
117
+ const cache = new Map();
118
+ const returnFunc = function (arg) {
119
+ return __awaiter(this, void 0, void 0, function* () {
120
+ const cacheKey = JSON.stringify(arg);
121
+ if (cache.has(cacheKey)) {
122
+ return cache.get(cacheKey);
123
+ }
124
+ const result = yield func(arg);
125
+ cache.set(cacheKey, result);
126
+ return result;
127
+ });
128
+ };
129
+ return returnFunc;
130
+ }
131
+ exports.getShellDocumentation = memorize(getShellDocumentationWithoutCache);
132
+ //# sourceMappingURL=sh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sh.js","sourceRoot":"","sources":["../../src/util/sh.ts"],"names":[],"mappings":";;;;;;;;;;;;AAQA,0CAgCC;AAiBD,8EA0CC;AAED,0CAgBC;AAMD,4BAiBC;AA5ID,8CAA6C;AAE7C,qCAAiC;AACjC,yCAAsC;AAEtC;;GAEG;AACH,SAAgB,eAAe,CAC7B,IAAY,EACZ,GAAG,GAAG,IAAA,oBAAS,GAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM;IAEtC,MAAM,IAAI,GAAG,EA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Ac,GAAG,CAAC,IAAI,iBAAiB,GAAG,CAAC,EAAE,CAAC;QAChD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,MAAM,kBAAkB,GAAG,SAAS,CAAC,KAAK,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAA;IAE7E,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,eAAM,CAAC,KAAK,CAAC,wBAAwB,EAAE,EAAE,SAAS,EAAE,CAAC,CAAA;QACrD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,OAAO,kBAAkB,CAAA;AAC3B,CAAC;AAED;;GAEG;AACH,iDAAiD;AACjD,SAAgB,QAAQ,CAAqB,IAAO;IAClD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAE,CAAA;IAEvB,MAAM,UAAU,GAAG,UAAgB,GAAQ;;YACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;YAEpC,IAAI,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACxB,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YAC5B,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,CAAA;YAE9B,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;YAC3B,OAAO,MAAM,CAAA;QACf,CAAC;KAAA,CAAA;IAED,OAAO,UAAiB,CAAA;AAC1B,CAAC;AAEY,QAAA,qBAAqB,GAAG,QAAQ,CAAC,iCAAiC,CAAC,CAAA"}
@@ -0,0 +1,10 @@
1
+ declare const BASH_DIALECTS: readonly ["sh", "bash", "dash", "ksh", "zsh", "csh", "ash"];
2
+ type BashDialect = (typeof BASH_DIALECTS)[number];
3
+ export declare function getShebang(fileContent: string): string | null;
4
+ export declare function getShellDialect(shebang: string): BashDialect | null;
5
+ export declare function getShellDialectFromShellDirective(fileContent: string): BashDialect | null;
6
+ export declare function analyzeShebang(fileContent: string): {
7
+ shellDialect: BashDialect | null;
8
+ shebang: string | null;
9
+ };
10
+ export {};
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getShebang = getShebang;
4
+ exports.getShellDialect = getShellDialect;
5
+ exports.getShellDialectFromShellDirective = getShellDialectFromShellDirective;
6
+ exports.analyzeShebang = analyzeShebang;
7
+ const SHEBANG_REGEXP = /^#!(.*)/;
8
+ const SHELL_REGEXP = /bin[/](?:env )?(\w+)/;
9
+ // Non exhaustive list of bash dialects that we potentially could support and try to analyze.
10
+ const BASH_DIALECTS = ['sh', 'bash', 'dash', 'ksh', 'zsh', 'csh', 'ash'];
11
+ const SHELL_DIRECTIVE_REGEXP = new RegExp(`^\\s*#\\s*shellcheck.*shell=(${BASH_DIALECTS.join('|')}).*$|^\\s*#.*$|^\\s*$`);
12
+ function getShebang(fileContent) {
13
+ const match = SHEBANG_REGEXP.exec(fileContent);
14
+ if (!match || !match[1]) {
15
+ return null;
16
+ }
17
+ return match[1].trim();
18
+ }
19
+ function getShellDialect(shebang) {
20
+ const match = SHELL_REGEXP.exec(shebang);
21
+ if (match && match[1]) {
22
+ const bashDialect = match[1].trim();
23
+ if (BASH_DIALECTS.includes(bashDialect)) {
24
+ return bashDialect;
25
+ }
26
+ }
27
+ return null;
28
+ }
29
+ function getShellDialectFromShellDirective(fileContent) {
30
+ const contentLines = fileContent.split('\n');
31
+ for (const line of contentLines) {
32
+ const match = SHELL_DIRECTIVE_REGEXP.exec(line);
33
+ if (match === null) {
34
+ break;
35
+ }
36
+ if (match[1]) {
37
+ const bashDialect = match[1].trim();
38
+ if (BASH_DIALECTS.includes(bashDialect)) {
39
+ return bashDialect;
40
+ }
41
+ }
42
+ }
43
+ return null;
44
+ }
45
+ function analyzeShebang(fileContent) {
46
+ var _a;
47
+ const shebang = getShebang(fileContent);
48
+ return {
49
+ shebang,
50
+ shellDialect: (_a = getShellDialectFromShellDirective(fileContent)) !== null && _a !== void 0 ? _a : (shebang ? getShellDialect(shebang) : null),
51
+ };
52
+ }
53
+ //# sourceMappingURL=shebang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shebang.js","sourceRoot":"","sources":["../../src/util/shebang.ts"],"names":[],"mappings":";;AAWA,gCAOC;AAED,0CAUC;AAED,8EAiBC;AAED,wCAWC;AA9DD,MAAM,cAAc,GAAG,SAAS,CAAA;AAChC,MAAM,YAAY,GAAG,sBAAsB,CAAA;AAE3C,6FAA6F;AAC7F,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAU,CAAA;AAGjF,MAAM,sBAAsB,GAAG,IAAI,MAAM,CACvC,gCAAgC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,uBAAuB,CAC/E,CAAA;AAED,SAAgB,UAAU,CAAC,WAAmB;IAC5C,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAC9C,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QACxB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;AACxB,CAAC;AAED,SAAgB,eAAe,CAAC,OAAe;IAC7C,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACxC,IAAI,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QACtB,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAS,CAAA;QAC1C,IAAI,aAAa,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YACxC,OAAO,WAAW,CAAA;QACpB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAgB,iCAAiC,CAC/C,WAAmB;IAEnB,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC5C,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;QAChC,MAAM,KAAK,GAAG,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC/C,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,MAAK;QACP,CAAC;QACD,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YACb,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAS,CAAA;YAC1C,IAAI,aAAa,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;gBACxC,OAAO,WAAW,CAAA;YACpB,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAgB,cAAc,CAAC,WAAmB;;IAIhD,MAAM,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC,CAAA;IACvC,OAAO;QACL,OAAO;QACP,YAAY,EACV,MAAA,iCAAiC,CAAC,WAAW,CAAC,mCAC9C,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;KAC9C,CAAA;AACH,CAAC"}
@@ -0,0 +1,15 @@
1
+ import * as LSP from 'vscode-languageserver';
2
+ import * as Parser from 'web-tree-sitter';
3
+ export type SourceCommand = {
4
+ range: LSP.Range;
5
+ uri: string | null;
6
+ error: string | null;
7
+ };
8
+ /**
9
+ * Analysis the given tree for source commands.
10
+ */
11
+ export declare function getSourceCommands({ fileUri, rootPath, tree, }: {
12
+ fileUri: string;
13
+ rootPath: string | null;
14
+ tree: Parser.Tree;
15
+ }): SourceCommand[];
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSourceCommands = getSourceCommands;
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const directive_1 = require("../shellcheck/directive");
7
+ const discriminate_1 = require("./discriminate");
8
+ const fs_1 = require("./fs");
9
+ const TreeSitterUtil = require("./tree-sitter");
10
+ const SOURCING_COMMANDS = ['source', '.'];
11
+ /**
12
+ * Analysis the given tree for source commands.
13
+ */
14
+ function getSourceCommands({ fileUri, rootPath, tree, }) {
15
+ const sourceCommands = [];
16
+ const rootPaths = [path.dirname(fileUri), rootPath].filter(Boolean);
17
+ TreeSitterUtil.forEach(tree.rootNode, (node) => {
18
+ const sourcedPathInfo = getSourcedPathInfoFromNode({ node });
19
+ if (sourcedPathInfo) {
20
+ const { sourcedPath, parseError } = sourcedPathInfo;
21
+ const uri = sourcedPath ? resolveSourcedUri({ rootPaths, sourcedPath }) : null;
22
+ sourceCommands.push({
23
+ range: TreeSitterUtil.range(node),
24
+ uri,
25
+ error: uri ? null : parseError || 'failed to resolve path',
26
+ });
27
+ }
28
+ return true;
29
+ });
30
+ return sourceCommands;
31
+ }
32
+ function getSourcedPathInfoFromNode({ node, }) {
33
+ var _a, _b, _c;
34
+ if (node.type === 'command') {
35
+ const [commandNameNode, argumentNode] = node.namedChildren;
36
+ if (!commandNameNode || !argumentNode) {
37
+ return null;
38
+ }
39
+ if (commandNameNode.type === 'command_name' &&
40
+ SOURCING_COMMANDS.includes(commandNameNode.text)) {
41
+ const previousCommentNode = ((_a = node.previousSibling) === null || _a === void 0 ? void 0 : _a.type) === 'comment' ? node.previousSibling : null;
42
+ if (previousCommentNode === null || previousCommentNode === void 0 ? void 0 : previousCommentNode.text.includes('shellcheck')) {
43
+ const directives = (0, directive_1.parseShellCheckDirective)(previousCommentNode.text);
44
+ const sourcedPath = (_b = directives.find((0, discriminate_1.discriminate)('type', 'source'))) === null || _b === void 0 ? void 0 : _b.path;
45
+ if (sourcedPath === '/dev/null') {
46
+ return null;
47
+ }
48
+ if (sourcedPath) {
49
+ return {
50
+ sourcedPath,
51
+ };
52
+ }
53
+ const isNotFollowErrorDisabled = !!directives
54
+ .filter((0, discriminate_1.discriminate)('type', 'disable'))
55
+ .flatMap(({ rules }) => rules)
56
+ .find((rule) => rule === 'SC1091');
57
+ if (isNotFollowErrorDisabled) {
58
+ return null;
59
+ }
60
+ const rootFolder = (_c = directives.find((0, discriminate_1.discriminate)('type', 'source-path'))) === null || _c === void 0 ? void 0 : _c.path;
61
+ if (rootFolder && rootFolder !== 'SCRIPTDIR' && argumentNode.type === 'word') {
62
+ return {
63
+ sourcedPath: path.join(rootFolder, argumentNode.text),
64
+ };
65
+ }
66
+ }
67
+ const strValue = TreeSitterUtil.resolveStaticString(argumentNode);
68
+ if (strValue !== null) {
69
+ return {
70
+ sourcedPath: strValue,
71
+ };
72
+ }
73
+ // Strip one leading dynamic section.
74
+ if (argumentNode.type === 'string' && argumentNode.namedChildren.length === 1) {
75
+ const [variableNode] = argumentNode.namedChildren;
76
+ if (TreeSitterUtil.isExpansion(variableNode)) {
77
+ const stringContents = argumentNode.text.slice(1, -1);
78
+ if (stringContents.startsWith(`${variableNode.text}/`)) {
79
+ return {
80
+ sourcedPath: `.${stringContents.slice(variableNode.text.length)}`,
81
+ };
82
+ }
83
+ }
84
+ }
85
+ if (argumentNode.type === 'concatenation') {
86
+ // Strip one leading dynamic section from a concatenation node.
87
+ const sourcedPath = resolveSourceFromConcatenation(argumentNode);
88
+ if (sourcedPath) {
89
+ return {
90
+ sourcedPath,
91
+ };
92
+ }
93
+ }
94
+ // TODO: we could try to parse any ShellCheck "source "directive
95
+ // # shellcheck source=src/examples/config.sh
96
+ return {
97
+ parseError: `non-constant source not supported`,
98
+ };
99
+ }
100
+ }
101
+ return null;
102
+ }
103
+ /**
104
+ * Tries to resolve the given sourced path and returns a URI if possible.
105
+ * - Converts a relative paths to absolute paths
106
+ * - Converts a tilde path to an absolute path
107
+ * - Resolves the path
108
+ *
109
+ * NOTE: for future improvements:
110
+ * "If filename does not contain a slash, file names in PATH are used to find
111
+ * the directory containing filename." (see https://ss64.com/osx/source.html)
112
+ */
113
+ function resolveSourcedUri({ rootPaths, sourcedPath, }) {
114
+ if (sourcedPath.startsWith('~')) {
115
+ sourcedPath = (0, fs_1.untildify)(sourcedPath);
116
+ }
117
+ if (sourcedPath.startsWith('/')) {
118
+ if (fs.existsSync(sourcedPath)) {
119
+ return `file://${sourcedPath}`;
120
+ }
121
+ return null;
122
+ }
123
+ // resolve relative path
124
+ for (const rootPath of rootPaths) {
125
+ const potentialPath = path.join(rootPath.replace('file://', ''), sourcedPath);
126
+ // check if path is a file
127
+ if (fs.existsSync(potentialPath)) {
128
+ return `file://${potentialPath}`;
129
+ }
130
+ }
131
+ return null;
132
+ }
133
+ /*
134
+ * Resolves the source path from a concatenation node, stripping a leading dynamic directory segment.
135
+ * Returns null if the source path can't be statically determined after stripping a segment.
136
+ * Note: If a non-concatenation node is passed, null will be returned. This is likely a programmer error.
137
+ */
138
+ function resolveSourceFromConcatenation(node) {
139
+ if (node.type !== 'concatenation')
140
+ return null;
141
+ const stringValue = TreeSitterUtil.resolveStaticString(node);
142
+ if (stringValue !== null)
143
+ return stringValue; // This string is fully static.
144
+ const values = [];
145
+ // Since the string must begin with the variable, the variable must be in the first child.
146
+ const [firstNode, ...rest] = node.namedChildren;
147
+ // The first child is static, this means one of the other children is not!
148
+ if (TreeSitterUtil.resolveStaticString(firstNode) !== null)
149
+ return null;
150
+ // if the string is unquoted, the first child is the variable, so there's no more text in it.
151
+ if (!TreeSitterUtil.isExpansion(firstNode)) {
152
+ if (firstNode.namedChildCount > 1)
153
+ return null; // Only one variable is allowed.
154
+ // Since the string must begin with the variable, the variable must be first child.
155
+ const variableNode = firstNode.namedChildren[0]; // Get the variable (quoted case)
156
+ // This is command substitution!
157
+ if (!TreeSitterUtil.isExpansion(variableNode))
158
+ return null;
159
+ const stringContents = firstNode.text.slice(1, -1);
160
+ // The string doesn't start with the variable!
161
+ if (!stringContents.startsWith(variableNode.text))
162
+ return null;
163
+ // Get the remaining static portion the string
164
+ values.push(stringContents.slice(variableNode.text.length));
165
+ }
166
+ for (const child of rest) {
167
+ const value = TreeSitterUtil.resolveStaticString(child);
168
+ // The other values weren't statically determinable!
169
+ if (value === null)
170
+ return null;
171
+ values.push(value);
172
+ }
173
+ // Join all our found static values together.
174
+ const staticResult = values.join('');
175
+ // The path starts with slash, so trim the leading variable and replace with a dot
176
+ if (staticResult.startsWith('/'))
177
+ return `.${staticResult}`;
178
+ // The path doesn't start with a slash, so it's invalid
179
+ // PERF: can we fail earlier than this?
180
+ return null;
181
+ }
182
+ //# sourceMappingURL=sourcing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sourcing.js","sourceRoot":"","sources":["../../src/util/sourcing.ts"],"names":[],"mappings":";;AAqBA,8CA+BC;AApDD,yBAAwB;AACxB,6BAA4B;AAI5B,uDAAkE;AAClE,iDAA6C;AAC7C,6BAAgC;AAChC,gDAA+C;AAE/C,MAAM,iBAAiB,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;AAQzC;;GAEG;AACH,SAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,QAAQ,EACR,IAAI,GAKL;IACC,MAAM,cAAc,GAAoB,EAAE,CAAA;IAE1C,MAAM,SAAS,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAa,CAAA;IAE/E,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE;QAC7C,MAAM,eAAe,GAAG,0BAA0B,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;QAE5D,IAAI,eAAe,EAAE,CAAC;YACpB,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,eAAe,CAAA;YACnD,MAAM,GAAG,GAAG,WAAW,CAAC,CAAC,CAAC,iBAAiB,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;YAE9E,cAAc,CAAC,IAAI,CAAC;gBAClB,KAAK,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AI,CAAC,MAAM,CAAC,CAAC,CAAA;IAC7D,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,cAAc,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAA;QACvD,oDAAoD;QACpD,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,IAAI,CAAA;QAC/B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACpB,CAAC;IAED,6CAA6C;IAC7C,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACpC,kFAAkF;IAClF,IAAI,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,YAAY,EAAE,CAAA;IAC3D,uDAAuD;IACvD,uCAAuC;IACvC,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -0,0 +1,22 @@
1
+ import * as LSP from 'vscode-languageserver/node';
2
+ import { SyntaxNode } from 'web-tree-sitter';
3
+ /**
4
+ * Recursively iterate over all nodes in a tree.
5
+ *
6
+ * @param node The node to start iterating from
7
+ * @param callback The callback to call for each node. Return false to stop following children.
8
+ */
9
+ export declare function forEach(node: SyntaxNode, callback: (n: SyntaxNode) => void | boolean): void;
10
+ export declare function range(n: SyntaxNode): LSP.Range;
11
+ export declare function isDefinition(n: SyntaxNode): boolean;
12
+ export declare function isReference(n: SyntaxNode): boolean;
13
+ export declare function isVariableInReadCommand(n: SyntaxNode): boolean;
14
+ export declare function isExpansion(n: SyntaxNode): boolean;
15
+ export declare function findParent(start: SyntaxNode, predicate: (n: SyntaxNode) => boolean): SyntaxNode | null;
16
+ export declare function findParentOfType(start: SyntaxNode, type: string | string[]): SyntaxNode | null;
17
+ /**
18
+ * Resolves the full string value of a node
19
+ * Returns null if the value can't be statically determined (ie, it contains a variable or command substition).
20
+ * Supports: word, string, raw_string, and concatenation
21
+ */
22
+ export declare function resolveStaticString(node: SyntaxNode): string | null;