feat(ide): package the VS Code extension as a VSIX
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 8s
VoidBuildSystem CI / sanitizers-gcc16 (push) Failing after 6s
VoidBuildSystem CI / fuzz-clang (push) Failing after 6s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 11s
VoidBuildSystem CI / wine-windows-gcc16 (push) Failing after 48s

This commit is contained in:
faumaray committed 2026-12-05 13:39:57 +03:00
1 parent 3f5b21a570
commit f032c9f7fe
10 files changed
+269 -74

No files matched your search

+2
View File
@@ -369,6 +369,8 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B
- **Wave 137 (UDIF/DMG-Style Packaging)**: `vbs install --archive FILE --archive-format dmg` writes a UDIF container - the deterministic tar payload followed by a 512-byte `koly` trailer with CRC-32 data/master checksums, segment ID, image variant and sector count. Validated independently: Python's `zlib.crc32` matches the stored checksum and the payload is a valid tar. A mountable macOS image still needs an HFS+/APFS payload writer (macOS-only).
- **Wave 138 (Full CMake File API Reply Set)**: `vbs ide generate` now emits `cmakeFiles-v1` (configure inputs/outputs), `toolchains-v1` (C/CXX compiler identity) and `cache-v2` (build type, compilers, generator, profile) beside `codemodel-v2`, so CMake-aware IDEs (CLion, VS Code CMake Tools) get the complete reply set.
- **Wave 139 (Installable VSIX for the VS Code Plugin)**: `vbs ide plugin --editor vscode --vsix FILE` now packages the generated extension as a real `.vsix` (ZIP with `extension.vsixmanifest`, `[Content_Types].xml` and the sources under `extension/`), which `code --install-extension` accepts. The stored-ZIP writer moved from the installer into `Package::create_stored_zip` so both share it. The packaged extension's own test passes when extracted, and the C++ test parses the ZIP central directory and verifies every CRC.
## Remaining future scope
- **Superiority plan ([22-superiority-and-gaps.md](../roadmap/22-superiority-and-gaps.md), 2026-12-05)**: revised platform strategy - **macOS deferred**, **Windows via MinGW-w64 cross-compilation + Wine execution** (`dev cpp-gcc -p pkgsCross.mingwW64.stdenv.cc`, `dev cpp-gcc -p wine64`), native MSVC deferred; plus packaging parity (ZIP/DEB/RPM), IDE ecosystem, migration tooling, test-runner parity, benchmarks, CI runners, and remote execution in prioritized order.
+1
View File
@@ -139,4 +139,5 @@ Base HEAD: `fe0d1a6`
| Wave 136 (Parallel worker drain) | `--parallel N` lease/execute loops; exclusive registry leases prevent duplicates | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; E2E proves overlap and no duplicates, full CTest 8/8) | `src/Main.cpp`, `tests/RegistryTests.cpp`, docs |
| Wave 137 (UDIF/DMG-style packaging) | `--archive-format dmg`: tar payload + koly trailer with CRC-32 | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; trailer parsed and CRC matches zlib, install test passes, full CTest 8/8) | `src/Install/Installer.cpp`, `src/Main.cpp`, `tests/FullV1Tests.cpp`, docs |
| Wave 138 (Full CMake File API) | `cmakeFiles-v1`, `toolchains-v1`, `cache-v2` replies | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; IDE E2E passes, full CTest 8/8) | `src/Editor/CompDb.cpp`, `tests/FullV1Tests.cpp`, docs |
| Wave 139 (VSIX packaging) | `vbs ide plugin --vsix FILE`; shared `Package::create_stored_zip` | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Python zipfile validates the VSIX, packaged harness passes under Node, C++ test checks CRCs, full CTest 8/8) | `src/Editor/CompDb.cpp`, `src/Package/Archive.cpp`, `src/Main.cpp`, `tests/FullV1Tests.cpp`, docs |
| Future (Plan 20 Slice 3 / Tracks C, E3 editor extensions) |"}] Live `conan` CLI verification; macOS/Windows/cross-compile; binary-variant signing and key distribution; daemon-side dependency materialization and editor plugins; `Void::Net`/`Void::Sqlite` alignment | PLANNED (unimplemented) | [21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md), [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md) |
+12
View File
@@ -1813,6 +1813,18 @@ VOID_INCLUDE_DIR=/tmp/opencode/vl-pin/include dev cpp -c bash fuzz/run.sh 30
(plus per-target and per-directory files), each parsed back and asserted in
`ide_integration_compdb_build_cpp_and_editor_configs_end_to_end` (**passed**, 3.12 s).
## VSIX Packaging (GCC 16.2, pin `0002e74`)
- `vbs ide plugin --editor vscode --output DIR --vsix dist/vbs-tools.vsix` writes the extension
sources plus a ZIP containing `extension.vsixmanifest`, `[Content_Types].xml` and
`extension/{package.json,extension.js,README.md,test/extension.test.js}`.
- Python `zipfile` reads it back: 6 entries, `testzip()` reports no CRC errors, the manifest has
`Id="vbs-tools"` and `Path="extension/package.json"`, and the packaged
`node test/extension.test.js` prints `extension tests passed: 6 commands`.
- `FullV1Tests.ide_plugin_assets_export_vscode_extension` parses the central directory itself,
recomputes each entry's CRC-32 and asserts the layout (**passed**, 34 ms).
- Full CTest: **8 / 8 passed** in 305.48 s.
## Limits and Unrun Checks
1. **HTTPS git fetch**: the host shell is proxy-restricted, but the Docker container could clone `https://git.faumaray.com/Void/VoidLibrary.git`; the pinned commit `3e254055e081a104f08df68dde39711bc7813518` was fetched directly for the verification above. A separate configure against the local `/home/faumaray/Projects/Library` checkout via `VBS_VOID_SOURCE_DIR` also succeeded (development-only override, checkout unmodified).
+3
View File
@@ -125,6 +125,9 @@ struct IdePluginOptions {
std::filesystem::path vbs_executable{"vbs"};
IdeKind editor{IdeKind::VsCode};
std::filesystem::path output_dir;
// Optional VSIX package path (VS Code only): a ZIP with extension.vsixmanifest,
// [Content_Types].xml and the extension sources under extension/.
std::optional<std::filesystem::path> vsix_path;
bool force{false};
};
+6
View File
@@ -36,6 +36,12 @@ create_deterministic_tar(const std::filesystem::path &output_tar,
std::vector<ArchiveEntrySpec> entries,
std::int64_t reproducibility_epoch = 0);
// Creates a stored (uncompressed) deterministic ZIP archive, e.g. for Windows installers or
// editor-extension packages (VSIX).
[[nodiscard]] Void::Result::Result<void, Void::Result::Error>
create_stored_zip(const std::filesystem::path &output_zip,
const std::vector<ArchiveEntrySpec> &entries);
// Packages a VBS project's source tree cleanly (retaining build.cpp, optional build.profiles.cpp,
// build-support/**, and declared sources/headers while excluding .git, build/, .vbs/, secrets).
[[nodiscard]] Void::Result::Result<std::string, Void::Result::Error>
+60
View File
@@ -1,6 +1,7 @@
#include <Void/Build/BootstrapConfig.hpp>
#include <Void/Build/Editor/CompDb.hpp>
#include <Void/Build/Package/Archive.hpp>
#include <Void/Build/Platform/FileOps.hpp>
#include <Void/Build/Util/Json.hpp>
#include <Void/Build/Util/Sha256.hpp>
@@ -1451,6 +1452,65 @@ console.log('extension tests passed: ' + terminals.length + ' commands');
return std::unexpected{written.error()};
}
}
// Optional VSIX package: a ZIP that `code --install-extension` accepts.
if (options.vsix_path) {
const std::string vsix_manifest =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<PackageManifest Version=\"2.0.0\" "
"xmlns=\"http://schemas.microsoft.com/developer/vsx-schema/2011\">\n"
" <Metadata>\n"
" <Identity Language=\"en-US\" Id=\"vbs-tools\" Version=\"0.1.0\" "
"Publisher=\"void\" />\n"
" <DisplayName>VoidBuildSystem</DisplayName>\n"
" <Description xml:space=\"preserve\">Build, test, install and package with "
"VoidBuildSystem.</Description>\n"
" <Tags>vbs</Tags>\n"
" <Categories>Other</Categories>\n"
" <GalleryFlags>Public</GalleryFlags>\n"
" </Metadata>\n"
" <Installation>\n"
" <InstallationTarget Id=\"Microsoft.VisualStudio.Code\" />\n"
" </Installation>\n"
" <Dependencies />\n"
" <Assets>\n"
" <Asset Type=\"Microsoft.VisualStudio.Code.Manifest\" "
"Path=\"extension/package.json\" Addressable=\"true\" />\n"
" </Assets>\n"
"</PackageManifest>\n";
const std::string content_types =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">\n"
" <Default Extension=\".json\" ContentType=\"application/json\" />\n"
" <Default Extension=\".js\" ContentType=\"application/javascript\" />\n"
" <Default Extension=\".md\" ContentType=\"text/markdown\" />\n"
" <Default Extension=\".vsixmanifest\" ContentType=\"text/xml\" />\n"
" <Default Extension=\".xml\" ContentType=\"text/xml\" />\n"
"</Types>\n";
const auto manifest_path = output / ".vsix" / "extension.vsixmanifest";
const auto types_path = output / ".vsix" / "[Content_Types].xml";
if (auto written = Platform::atomic_write_file(manifest_path, vsix_manifest, true);
!written) {
return std::unexpected{written.error()};
}
if (auto written = Platform::atomic_write_file(types_path, content_types, true); !written) {
return std::unexpected{written.error()};
}
std::vector<Package::ArchiveEntrySpec> vsix_entries{
{"extension.vsixmanifest", manifest_path, 0644u},
{"[Content_Types].xml", types_path, 0644u}};
for (const auto &name :
{"package.json", "extension.js", "README.md", "test/extension.test.js"}) {
vsix_entries.push_back({std::string{"extension/"} + name, output / name, 0644u});
}
if (options.vsix_path->has_parent_path()) {
std::filesystem::create_directories(options.vsix_path->parent_path(), ec);
}
if (auto zipped = Package::create_stored_zip(*options.vsix_path, vsix_entries); !zipped) {
return std::unexpected{zipped.error()};
}
std::filesystem::remove_all(output / ".vsix", ec);
}
return report;
}
+2 -74
View File
@@ -95,79 +95,6 @@ std::uint32_t crc32_bytes(std::string_view data) {
return crc ^ 0xFFFFFFFFu;
}
// Stored (uncompressed) deterministic ZIP archive of the installed files.
Void::Result::Result<void, Void::Result::Error>
write_stored_zip(const std::filesystem::path &output,
const std::vector<Package::ArchiveEntrySpec> &entries) {
struct Record {
std::string name;
std::uint32_t crc{0};
std::uint32_t size{0};
std::uint32_t offset{0};
std::uint32_t mode{0644};
};
std::string local;
std::vector<Record> records;
for (const auto &entry : entries) {
auto content = Void::FileSystem::read_file(entry.source_file);
if (!content) {
return std::unexpected{content.error()};
}
const auto crc = crc32_bytes(*content);
const auto size = static_cast<std::uint32_t>(content->size());
records.push_back(
{entry.archive_path, crc, size, static_cast<std::uint32_t>(local.size()), entry.mode});
put_u32(local, 0x04034b50u);
put_u16(local, 20); // version needed
put_u16(local, 0); // flags
put_u16(local, 0); // stored
put_u16(local, 0); // time
put_u16(local, 0x21); // 1980-01-01
put_u32(local, crc);
put_u32(local, size);
put_u32(local, size);
put_u16(local, static_cast<std::uint16_t>(entry.archive_path.size()));
put_u16(local, 0); // extra
local += entry.archive_path;
local += *content;
}
std::string central;
for (const auto &record : records) {
put_u32(central, 0x02014b50u);
put_u16(central, 0x031e); // made by UNIX
put_u16(central, 20);
put_u16(central, 0);
put_u16(central, 0);
put_u16(central, 0);
put_u16(central, 0x21);
put_u32(central, record.crc);
put_u32(central, record.size);
put_u32(central, record.size);
put_u16(central, static_cast<std::uint16_t>(record.name.size()));
put_u16(central, 0); // extra
put_u16(central, 0); // comment
put_u16(central, 0); // disk
put_u16(central, 0); // internal attrs
put_u32(central, (record.mode & 0777u) << 16);
put_u32(central, record.offset);
central += record.name;
}
std::string eocd;
put_u32(eocd, 0x06054b50u);
put_u16(eocd, 0);
put_u16(eocd, 0);
put_u16(eocd, static_cast<std::uint16_t>(records.size()));
put_u16(eocd, static_cast<std::uint16_t>(records.size()));
put_u32(eocd, static_cast<std::uint32_t>(central.size()));
put_u32(eocd, static_cast<std::uint32_t>(local.size()));
put_u16(eocd, 0);
std::string zip = local + central + eocd;
return Platform::atomic_write_file(output, zip, true);
}
std::string ar_member_header(std::string_view name, std::uint64_t size) {
std::string header;
std::string padded_name{name};
@@ -1132,7 +1059,8 @@ install_project(const Graph::ProjectDescription &description, const Graph::Build
}
if (options.archive_format == "zip") {
if (auto zipped = write_stored_zip(*options.archive_path, archive_entries); !zipped) {
if (auto zipped = Package::create_stored_zip(*options.archive_path, archive_entries);
!zipped) {
return std::unexpected{zipped.error()};
}
} else if (options.archive_format == "deb") {
+10
View File
@@ -3292,6 +3292,7 @@ struct IdeCmdOptions {
std::optional<std::string> compiler_arg;
std::string editor_name{"all"};
std::optional<std::string> plugin_output_arg;
std::optional<std::string> plugin_vsix_arg;
bool force{false};
};
@@ -3320,6 +3321,13 @@ int execute_ide_command(std::string_view sub, const IdeCmdOptions &opts) {
plugin_opts.editor = ide_kind;
plugin_opts.output_dir = *opts.plugin_output_arg;
plugin_opts.force = opts.force;
if (opts.plugin_vsix_arg) {
if (ide_kind != Editor::IdeKind::VsCode) {
std::cerr << "vbs ide plugin: --vsix is only supported for vscode\n";
return 2;
}
plugin_opts.vsix_path = *opts.plugin_vsix_arg;
}
if (auto exe = Platform::current_executable_path(); exe) {
plugin_opts.vbs_executable = *exe;
}
@@ -4006,6 +4014,8 @@ int main(int argc, char **argv) {
ide_plugin_cmd
.option_default("--editor", "-e", "Editor preset (vscode)", ide_opts.editor_name, "vscode")
.option("--output", "-o", "Output directory", ide_opts.plugin_output_arg)
.option("--vsix", "", "Package the VS Code extension as a .vsix (ZIP)",
ide_opts.plugin_vsix_arg)
.flag("--force", "", "Overwrite existing plugin files", ide_opts.force);
auto &ide_gen_cmd =
ide_cmd.subcommand("generate", "Generate .clangd, .vscode/, .zed/, and .idea/ IDE configs");
+106
View File
@@ -6,6 +6,7 @@
#include <Void/System/Types.hpp>
#include <algorithm>
#include <array>
#include <format>
#include <set>
@@ -118,6 +119,111 @@ create_source_package(const std::filesystem::path &project_root,
return create_deterministic_tar(output_tar, std::move(entries), reproducibility_epoch);
}
namespace {
void zip_put_u16(std::string &out, std::uint16_t value) {
out.push_back(static_cast<char>(value & 0xFFu));
out.push_back(static_cast<char>((value >> 8) & 0xFFu));
}
void zip_put_u32(std::string &out, std::uint32_t value) {
for (int shift = 0; shift < 32; shift += 8) {
out.push_back(static_cast<char>((value >> shift) & 0xFFu));
}
}
std::uint32_t zip_crc32(std::string_view data) {
static const auto table = [] {
std::array<std::uint32_t, 256> t{};
for (std::uint32_t i = 0; i < 256; ++i) {
std::uint32_t c = i;
for (int k = 0; k < 8; ++k) {
c = (c & 1u) != 0u ? (0xEDB88320u ^ (c >> 1)) : (c >> 1);
}
t[i] = c;
}
return t;
}();
std::uint32_t crc = 0xFFFFFFFFu;
for (const char ch : data) {
crc = table[(crc ^ static_cast<std::uint8_t>(ch)) & 0xFFu] ^ (crc >> 8);
}
return crc ^ 0xFFFFFFFFu;
}
} // namespace
Void::Result::Result<void, Void::Result::Error>
create_stored_zip(const std::filesystem::path &output_zip,
const std::vector<ArchiveEntrySpec> &entries) {
struct Record {
std::string name;
std::uint32_t crc{0};
std::uint32_t size{0};
std::uint32_t offset{0};
std::uint32_t mode{0644};
};
std::string local;
std::vector<Record> records;
for (const auto &entry : entries) {
auto content = Void::FileSystem::read_file(entry.source_file);
if (!content) {
return std::unexpected{content.error()};
}
const auto crc = zip_crc32(*content);
const auto size = static_cast<std::uint32_t>(content->size());
records.push_back(
{entry.archive_path, crc, size, static_cast<std::uint32_t>(local.size()), entry.mode});
zip_put_u32(local, 0x04034b50u);
zip_put_u16(local, 20); // version needed
zip_put_u16(local, 0); // flags
zip_put_u16(local, 0); // stored
zip_put_u16(local, 0); // time
zip_put_u16(local, 0x21); // 1980-01-01
zip_put_u32(local, crc);
zip_put_u32(local, size);
zip_put_u32(local, size);
zip_put_u16(local, static_cast<std::uint16_t>(entry.archive_path.size()));
zip_put_u16(local, 0); // extra
local += entry.archive_path;
local += *content;
}
std::string central;
for (const auto &record : records) {
zip_put_u32(central, 0x02014b50u);
zip_put_u16(central, 0x031e); // made by UNIX
zip_put_u16(central, 20);
zip_put_u16(central, 0);
zip_put_u16(central, 0);
zip_put_u16(central, 0);
zip_put_u16(central, 0x21);
zip_put_u32(central, record.crc);
zip_put_u32(central, record.size);
zip_put_u32(central, record.size);
zip_put_u16(central, static_cast<std::uint16_t>(record.name.size()));
zip_put_u16(central, 0); // extra
zip_put_u16(central, 0); // comment
zip_put_u16(central, 0); // disk
zip_put_u16(central, 0); // internal attrs
zip_put_u32(central, (record.mode & 0777u) << 16);
zip_put_u32(central, record.offset);
central += record.name;
}
std::string eocd;
zip_put_u32(eocd, 0x06054b50u);
zip_put_u16(eocd, 0);
zip_put_u16(eocd, 0);
zip_put_u16(eocd, static_cast<std::uint16_t>(records.size()));
zip_put_u16(eocd, static_cast<std::uint16_t>(records.size()));
zip_put_u32(eocd, static_cast<std::uint32_t>(central.size()));
zip_put_u32(eocd, static_cast<std::uint32_t>(local.size()));
zip_put_u16(eocd, 0);
return Platform::atomic_write_file(output_zip, local + central + eocd, true);
}
Void::Result::Result<ArchiveExtractionStats, Void::Result::Error>
extract_safe_tar(const std::filesystem::path &tar_path,
const std::filesystem::path &destination_dir, const ArchiveLimits &limits) {
+67
View File
@@ -1218,6 +1218,73 @@ VOID_TEST(FullV1Tests, ide_plugin_assets_export_vscode_extension) {
Void::Testing::expect(manifest_text->find("\"test\": \"node test/extension.test.js\"") !=
std::string::npos);
// VSIX packaging: a ZIP with the VS Code extension layout and valid CRCs.
{
auto vsix_options = options;
vsix_options.output_dir = tmp / "vbs-tools-vsix";
vsix_options.vsix_path = tmp / "dist" / "vbs-tools.vsix";
auto vsix_report = Editor::generate_ide_plugin_assets(vsix_options);
Void::Testing::require(vsix_report.has_value());
auto vsix_bytes = Void::FileSystem::read_file(*vsix_options.vsix_path);
Void::Testing::require(vsix_bytes.has_value());
const std::string_view zip = *vsix_bytes;
const auto read_u16 = [&](std::size_t o) {
return static_cast<std::uint16_t>(static_cast<unsigned char>(zip[o]) |
(static_cast<unsigned char>(zip[o + 1]) << 8));
};
const auto read_u32 = [&](std::size_t o) {
std::uint32_t v = 0;
for (int i = 3; i >= 0; --i) {
v = (v << 8) | static_cast<unsigned char>(zip[o + static_cast<std::size_t>(i)]);
}
return v;
};
const auto eocd = zip.rfind(std::string_view{"PK\x05\x06", 4});
Void::Testing::require(eocd != std::string_view::npos);
const auto entry_count = read_u16(eocd + 10);
std::size_t offset = read_u32(eocd + 16);
std::vector<std::string> names;
std::size_t checked = 0;
for (std::uint16_t i = 0; i < entry_count; ++i) {
Void::Testing::require(zip.substr(offset, 4) == std::string_view{"PK\x01\x02", 4});
const auto crc_expected = read_u32(offset + 16);
const auto name_len = read_u16(offset + 28);
const auto extra_len = read_u16(offset + 30);
const auto comment_len = read_u16(offset + 32);
const auto local_offset = read_u32(offset + 42);
names.emplace_back(zip.substr(offset + 46, name_len));
// Recompute the CRC from the local entry data.
const auto local_name_len = read_u16(local_offset + 26);
const auto local_extra_len = read_u16(local_offset + 28);
const auto data_size = read_u32(local_offset + 22);
const auto data_start =
static_cast<std::size_t>(local_offset) + 30 + local_name_len + local_extra_len;
std::uint32_t crc = 0xFFFFFFFFu;
for (std::size_t b = data_start; b < data_start + data_size; ++b) {
crc ^= static_cast<unsigned char>(zip[b]);
for (int bit = 0; bit < 8; ++bit) {
crc = (crc >> 1) ^ (0xEDB88320u & (0u - (crc & 1u)));
}
}
Void::Testing::expect_eq(~crc, crc_expected);
++checked;
offset += 46 + name_len + extra_len + comment_len;
}
Void::Testing::expect_eq(checked, std::size_t{6});
const auto has_entry = [&](std::string_view name) {
return std::ranges::contains(names, name);
};
Void::Testing::expect(has_entry("extension.vsixmanifest"));
Void::Testing::expect(has_entry("[Content_Types].xml"));
Void::Testing::expect(has_entry("extension/package.json"));
Void::Testing::expect(has_entry("extension/extension.js"));
Void::Testing::expect(has_entry("extension/test/extension.test.js"));
Void::Testing::expect(zip.find("Id=\"vbs-tools\"") != std::string_view::npos);
Void::Testing::expect(zip.find("Path=\"extension/package.json\"") !=
std::string_view::npos);
Void::Testing::expect(!std::filesystem::exists(vsix_options.output_dir / ".vsix"));
}
auto zed_options = options;
zed_options.editor = Editor::IdeKind::Zed;
zed_options.output_dir = tmp / "vbs-zed";