+
+
+ The file is not displayed in the text editor because it is binary AppleScript. It will be decompiled when you click on "Edit File".
+
+
+
What happens when you edit:
+
+ - The file will be decompiled using
osadecompile
+ - You can edit the source code in the editor
+ - On save, the code will be compiled back to binary using
osacompile
+
+
Things to note:
+
+ - Decompiled code may differ slightly from the original source
+ - Comments and formatting might not be preserved
+ - Compilation errors will prevent saving
+
+
+
+
+
+
+
+ `;
+ }
+}
+
+/**
+ * Represents a .scpt document in the custom editor
+ */
+class ScptDocument implements vscode.CustomDocument {
+ constructor(public readonly uri: vscode.Uri) {}
+
+ dispose(): void {
+ // No resources to clean up
+ }
+}
diff --git a/src/filesystem.ts b/src/filesystem.ts
new file mode 100644
index 0000000..1949f87
--- /dev/null
+++ b/src/filesystem.ts
@@ -0,0 +1,220 @@
+import { type FSWatcher, watch as watchSync } from 'node:fs';
+import { readFile, rename, stat, unlink } from 'node:fs/promises';
+import * as vscode from 'vscode';
+import { osacompileFromSource, osadecompile } from './osa.ts';
+import { scptUriToFileUri } from './util.ts';
+
+/**
+ * Virtual FileSystemProvider for binary AppleScript (.scpt) files
+ *
+ * This provider intercepts file operations on scpt: URIs and handles
+ * decompilation on read and compilation on write, allowing users to
+ * edit binary .scpt files as text in the native VSCode editor.
+ */
+export class ScptFileSystemProvider implements vscode.FileSystemProvider {
+ private _emitter = new vscode.EventEmitter