@qodalis/cli-files 2.0.0-beta.1 → 2.0.0-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/public-api.mjs CHANGED
@@ -4,7 +4,7 @@ import { ICliCompletionProvider_TOKEN, ICliFileTransferService_TOKEN, BrowserFil
4
4
  var IFileSystemService_TOKEN = "cli-file-system-service";
5
5
 
6
6
  // src/lib/version.ts
7
- var LIBRARY_VERSION = "2.0.0-beta.1";
7
+ var LIBRARY_VERSION = "2.0.0-beta.11";
8
8
  var API_VERSION = 2;
9
9
 
10
10
  // src/lib/processors/cli-ls-command-processor.ts
@@ -3837,7 +3837,7 @@ var STORE_NAME = "filesystem";
3837
3837
  var ROOT_KEY = "root";
3838
3838
  var CWD_KEY = "cwd";
3839
3839
  var HOME_KEY = "home";
3840
- var DEFAULT_HOME = "/home/user";
3840
+ var DEFAULT_HOME = "/";
3841
3841
  function createSeedFileSystem() {
3842
3842
  const now = Date.now();
3843
3843
  return {
@@ -4787,7 +4787,7 @@ var ServerFileSystemService = class {
4787
4787
  }
4788
4788
  // --- Private: server communication ---
4789
4789
  async serverFetch(endpoint, options) {
4790
- const url = `${this.baseUrl}/api/cli/fs${endpoint}`;
4790
+ const url = `${this.baseUrl}/api/qcli/fs${endpoint}`;
4791
4791
  const response = await fetch(url, options);
4792
4792
  if (!response.ok) {
4793
4793
  const body = await response.text();
@@ -5039,6 +5039,73 @@ var FilePathCompletionProvider = class {
5039
5039
  return results.sort();
5040
5040
  }
5041
5041
  };
5042
+ var CliUploadCommandProcessor = class {
5043
+ constructor() {
5044
+ this.command = "upload";
5045
+ this.description = "Upload a file from your local machine into the virtual filesystem";
5046
+ this.author = DefaultLibraryAuthor;
5047
+ this.version = LIBRARY_VERSION;
5048
+ this.acceptsRawInput = true;
5049
+ this.metadata = { icon: "\u{1F4E4}", module: "file management" };
5050
+ this.parameters = [
5051
+ {
5052
+ name: "accept",
5053
+ description: 'File type filter (e.g. ".json,.txt" or "image/*")',
5054
+ required: false,
5055
+ type: "string"
5056
+ }
5057
+ ];
5058
+ }
5059
+ async processCommand(command, context) {
5060
+ const fs = context.services.get(
5061
+ IFileSystemService_TOKEN
5062
+ );
5063
+ const fileService = context.services.get(
5064
+ ICliFileTransferService_TOKEN
5065
+ );
5066
+ if (!fileService) {
5067
+ context.writer.writeError("File transfer service not available.");
5068
+ return;
5069
+ }
5070
+ const accept = command.args?.["accept"];
5071
+ const destPath = command.value?.trim() || void 0;
5072
+ context.spinner?.show("Waiting for file selection...");
5073
+ const picked = await fileService.uploadFromBrowser(accept);
5074
+ if (!picked) {
5075
+ context.spinner?.hide();
5076
+ context.writer.writeln("Upload cancelled.");
5077
+ return;
5078
+ }
5079
+ const cwd = fs.getCurrentDirectory();
5080
+ const filename = destPath || picked.name;
5081
+ const resolved = fs.resolvePath(
5082
+ filename.startsWith("/") ? filename : cwd + "/" + filename
5083
+ );
5084
+ context.spinner?.show(`Saving "${picked.name}" (${picked.content.length} bytes)...`);
5085
+ try {
5086
+ fs.writeFile(resolved, picked.content);
5087
+ await fs.persist();
5088
+ context.spinner?.hide();
5089
+ context.writer.writeSuccess(
5090
+ `Uploaded ${context.writer.wrapInColor(picked.name, CliForegroundColor.Cyan)} (${picked.content.length} bytes) \u2192 ${resolved}`
5091
+ );
5092
+ } catch (e) {
5093
+ context.spinner?.hide();
5094
+ context.writer.writeError(e.message || "Failed to write file");
5095
+ }
5096
+ }
5097
+ writeDescription(context) {
5098
+ context.writer.writeln(this.description);
5099
+ context.writer.writeln("");
5100
+ context.writer.writeln("Usage:");
5101
+ context.writer.writeln(" upload Open file picker, save to current directory");
5102
+ context.writer.writeln(" upload myfile.txt Open file picker, save as myfile.txt");
5103
+ context.writer.writeln(" upload /home/user/data Open file picker, save to absolute path");
5104
+ context.writer.writeln(' upload --accept=".json" Filter file picker to .json files');
5105
+ }
5106
+ };
5107
+
5108
+ // src/public-api.ts
5042
5109
  var fsService = new IndexedDbFileSystemService();
5043
5110
  var filesModule = {
5044
5111
  apiVersion: API_VERSION,
@@ -5079,7 +5146,8 @@ var filesModule = {
5079
5146
  new CliDiffCommandProcessor(),
5080
5147
  new CliTeeCommandProcessor(),
5081
5148
  new CliXargsCommandProcessor(),
5082
- new CliShCommandProcessor()
5149
+ new CliShCommandProcessor(),
5150
+ new CliUploadCommandProcessor()
5083
5151
  ],
5084
5152
  services: [
5085
5153
  {