Skip to content

Commit 7587b9f

Browse files
feat(vscode): AffineScript port of extension (TS→AS campaign step 1 / #240) (#19)
Adds editors/vscode/src/extension.affine — AffineScript port of extension.ts, parallel artifact alongside the TS source. Step 1 of the estate-wide TS→AffineScript migration umbrella (hyperpolymath/standards#239); seed-port issue #240. Build pipeline integration (compile extension.affine → out/extension.cjs, swap package.json `main`, drop tsconfig/typescript devDeps) lands in a follow-up PR. extension.ts remains live until that swap. Binding coverage confirmed at this session: Vscode.affine (55 fns) + VscodeLanguageClient.affine cover all surface the TS used (getConfiguration, workspaceConfigGetString, newLanguageClient, languageClientStart). Pattern mirrors affinescript dogfood at affinescript/editors/vscode/src/extension.affine. Behavioural notes documented inline: - unused `path` import omitted - process.env preserved by Node child_process default behaviour (host shim handles it) - synchronize.fileEvents collapsed in newLanguageClient ABI - top-level held-client pattern replaced by activate-only start (process-exit closes the server pipe) Pre-PR ownership gate: owner=hyperpolymath, isFork=false, parent=null (verified inline).
1 parent ba74057 commit 7587b9f

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// SPDX-License-Identifier: MPL-2.0
2+
// Copyright (c) 2026 Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
3+
//
4+
// Phronesis VS Code extension — AffineScript port of editors/vscode/src/extension.ts.
5+
//
6+
// Step 1 of the estate-wide TypeScript → AffineScript migration campaign
7+
// (hyperpolymath/standards#239 umbrella, #240 seed-port issue).
8+
//
9+
// Build pipeline integration follows the affinescript dogfood pattern at
10+
// `affinescript/editors/vscode/src/extension.affine`:
11+
//
12+
// affinescript compile editors/vscode/src/extension.affine \
13+
// -o editors/vscode/out/extension.cjs
14+
//
15+
// `package.json` `main` will be updated to `./out/extension.cjs` in the
16+
// follow-up build-chain integration PR. extension.ts remains in place
17+
// alongside this file until that PR lands; the live extension still
18+
// loads `out/extension.js` from the TS build path.
19+
//
20+
// Behavioural notes vs the TS original:
21+
// - `path` import was unused in TS; omitted.
22+
// - `serverOptions.options.env: process.env` is the Node child_process
23+
// default behaviour, so the AffineScript binding (which doesn't take
24+
// env) preserves it implicitly.
25+
// - `synchronize.fileEvents: createFileSystemWatcher('**/.phr')` —
26+
// collapsed in `VscodeLanguageClient::newLanguageClient`; the host
27+
// shim derives the synchronize record from primitives.
28+
// - The TS port held the client in a top-level `let client`; the
29+
// AffineScript port follows the dogfood (process-exit closes the
30+
// server pipe; the held-client pattern adds nothing).
31+
32+
use Vscode::{ getConfiguration, workspaceConfigGetString, consoleLog };
33+
use VscodeLanguageClient::{ newLanguageClient, languageClientStart };
34+
35+
fn start_lsp() -> Int {
36+
let cfg = getConfiguration("phronesis");
37+
let server_path = workspaceConfigGetString(cfg, "serverPath", "phronesis");
38+
let client = newLanguageClient(
39+
"phronesis", // id (host shim derives documentSelector.language)
40+
"Phronesis Language Server",
41+
server_path,
42+
"lsp", // single arg (newline-separated list)
43+
0 // 0 = stdio transport
44+
);
45+
let _ = languageClientStart(client);
46+
return 0;
47+
}
48+
49+
pub fn activate(ctx: ExtensionContext) -> Int {
50+
let _ = consoleLog("Phronesis extension activated");
51+
let _ = start_lsp();
52+
return 0;
53+
}
54+
55+
pub fn deactivate() -> Int {
56+
return 0;
57+
}

0 commit comments

Comments
 (0)