Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
- Fix blast-radius hop counting, webview message validation, evidence refresh/state, SCM path isolation, oversized-blame handling, and export/editor regressions from review intents 1–14.
- Remove inherited Git editor integration; Atomic remains the SCM provider.
- Route Atomic push, pull, insert-view, and remote registration through nodeatomic and the in-process native service; remove the CLI subprocess bridge. Share Rust authentication with the CLI, surface structured failure reports, and protect unsaved current-view buffers.
- Resolve filesystem aliases in unsaved-document guards so tickets opened through symlinked repository paths cannot bypass record, view-switch, pull, or insertion safety checks.
- Keep inactive-view insertion results separate from unrelated current-working-copy conflict paths; retain genuine target conflict failures.
- Refresh the native descriptor fingerprint after integrating Atomic dev's vault-evidence replay contract, retaining strict runtime compatibility checks.
- Regenerate the vendored nodeatomic codecs, declarations, and descriptor fingerprint from published Atomic v0.22.0; document the exact compatible runtime and retain strict rejection of mismatched contracts.
- Upgrade vulnerable production dependencies (markdown-it, mermaid, sanitize-html, katex, Puppeteer, cspell, highlight.js, Shiki) and remove unused gRPC packages; `npm audit --omit=dev` is clean.
- Load Puppeteer 25 as an ESM runtime and make webview/graph build steps cross-platform.
- Add CI for typecheck, tests, build, universal VSIX packaging, and production audit; set the public `atomicdotdev` publisher metadata and 1.0.0 version.
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This is an **extension**, not a Markdown Preview plugin. It edits existing inten

Local packages are written to `releases/`. Use the version confirmed by the build and verification output; a source version bump alone does not update the installed extension.

**Atomic prerequisite:** Atomic features require a compatible complete Atomic installation on the **extension host**, including its CLI, platform library, and `libatomic-runtime.json`. This is a universal JavaScript-only VSIX, not a bundled native runtime. Install the complete release archive into a versioned directory and put it on PATH, or set an absolute `ATOMIC_RUNTIME_DIR` before launching the editor. Older CLI-only installations are insufficient. For Remote SSH/WSL/containers, install Atomic remotely. Fully restart the editor after environment/runtime changes. Intent/Markdown editing does not require loading the native runtime.
**Atomic prerequisite:** This build targets the published **Atomic v0.22.0** runtime. Atomic features require its complete installation on the **extension host**, including the CLI, platform library, and `libatomic-runtime.json`. Install it with the [official installer](https://atomic.storage/install.sh), which registers the complete runtime for discovery without PATH setup, or extract the complete [v0.22.0 release archive](https://github.com/atomicdotdev/atomic/releases/tag/v0.22.0) into a versioned directory and put it on PATH or set an absolute `ATOMIC_RUNTIME_DIR` before launching the editor. This is a universal JavaScript-only VSIX, not a bundled native runtime. Older CLI-only installations and runtimes with a different protobuf descriptor are rejected. For Remote SSH/WSL/containers, install Atomic remotely. Fully restart the editor after runtime changes. Intent/Markdown editing does not require loading the native runtime.

1. In VS Code, VSCodium, or another compatible editor, open the Command Palette.
2. Run **Extensions: Install from VSIX…** and select that file.
Expand Down Expand Up @@ -43,11 +43,11 @@ Open a **trusted, local filesystem** workspace in an Atomic repository, then ope
- **Atomic: <repository>** shows tracked changes and untracked files separately, alongside other SCM providers. Workspace folders inside a repository are supported; multiple repositories get separate providers.
- Click a **Tracked Changes** file to open VS Code's native diff editor: the recorded view baseline on the left and the live working file (including its editor buffer) on the right. Adds use an empty recorded side; deletions use an empty working side. Untracked files still open normally. Opening a diff never restores or writes files.
- Use **+ / Atomic: Add File** on an untracked file to track it. This is not a staging layer; there is no invented index.
- Enter a message and choose **✓ / Atomic: Record Tracked Changes** (or accept the input box). This records the displayed tracked paths, not untracked files, using the displayed status's concurrency fence. Save or close unsaved repository documents first. Backend fence failures are surfaced, not retried automatically.
- Enter a message and choose **✓ / Atomic: Record Tracked Changes** (or accept the input box). This records the displayed tracked paths, not untracked files, using the displayed status's concurrency fence. Save or close unsaved repository documents first, including documents opened through symlinked repository paths. Backend fence failures are surfaced, not retried automatically.
- **Atomic History & Views** lists typed **Draft / Shared** views. Expand a view to see its change hashes, then click a hash to inspect the change without switching the working copy. **Load more changes…** pages through that view's history.
- Right-click a repository in that panel for **Create View**, **Switch View**, or **Delete View**. New views derive from the displayed current view. Deletion requires confirmation and excludes the current view. Switching never bypasses Atomic's dirty-working-copy check and also refuses unsaved editor documents.
- **Atomic: Push View** and **Atomic: Pull View** choose a remote and view names. Enter a configured remote name or an `https://atomic.storage/...` project URL; the native Atomic service resolves identity authentication and project binding. **Atomic: Add Remote** records a remote through the same native service.
- **Atomic: Insert View Into View** inserts all changes from one view into another with Atomic's dependency closure and conflict rules. It asks for confirmation and uses the native insertion API; it does not promote Draft/Shared scope. Pull and insertion may refresh the working copy when targeting the current view, so save or close unsaved repository documents first. Inactive targets do not update host files.
- **Atomic: Insert View Into View** inserts all changes from one view into another with Atomic's dependency closure and conflict rules. It asks for confirmation and uses the native insertion API; it does not promote Draft/Shared scope. Pull and insertion may refresh the working copy when targeting the current view, so save or close unsaved repository documents first. Inactive targets do not update host files, and unrelated current-working-copy conflict paths are not treated as inactive-target insertion failures.
- Filesystem events trigger debounced refreshes; **Atomic: Refresh Version Control** retries discovery and reloads state. Errors are available in the **Atomic Version Control** output channel.

### Change detail
Expand Down Expand Up @@ -90,6 +90,8 @@ There is no CLI subprocess, daemon startup, socket, direct database access, or w

Build requirements: Node.js 22+/npm (for VSCE 4), Bun, and a VS Code-compatible editor. The universal nodeatomic JavaScript consumer and its generated codecs are vendored at `vendor/nodeatomic`; its NOTICE records the source revision. A clean checkout builds without a sibling repository. Refresh that directory from the nodeatomic producer when its descriptor, API, or runtime loader changes. Its compiled codecs/fingerprint are bundled, so the resulting VSIX does not need the vendor directory. Atomic Sherpa never builds Rust or searches for Atomic producer sources. Building/packaging does not require a native library unless an explicit runtime override requests the native smoke.

The vendored codecs and compatibility fingerprint are generated from the published Atomic v0.22.0 library, not from a development checkout. To adopt another runtime contract, regenerate the upstream nodeatomic package against that complete release, then refresh its built package and provenance notice here. Never change only the expected fingerprint or weaken the loader's contract checks.

```sh
npm ci
npm test
Expand Down
15 changes: 14 additions & 1 deletion scripts/atomicOperationResults.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,22 @@ test('a successful inactive-view pull distinguishes membership from working-copy
test('insertion exposes both new and pre-existing conflicts', () => {
for (const response of [
{ hasConflicts: true, conflicts: [] },
{ hasConflicts: false, conflicts: [{ path: 'conflicted.txt' }] }
{ hasConflicts: false, filesUpdated: '1', conflicts: [{ path: 'conflicted.txt' }] }
]) {
const result = insertResult({ inserted: [], resolvedTargetView: 'target', skippedCount: 0, ...response });
expect(result.error).toContain('Insertion reported conflicts');
}
});

test('an inactive insertion does not fail because the current working copy has conflicts', () => {
const result = insertResult({ inserted: [], resolvedTargetView: 'inactive', skippedCount: 0,
hasConflicts: false, conflicts: [{ path: 'current-view-conflict.txt' }] });
expect(result.error).toBeUndefined();
});

test('inactive target conflicts never borrow paths from the current working copy', () => {
const result = insertResult({ inserted: [], resolvedTargetView: 'inactive', skippedCount: 0,
hasConflicts: true, conflicts: [{ path: 'current-view-conflict.txt' }] });
expect(result.error).toBeDefined();
expect(result.error).not.toContain('current-view-conflict.txt');
});
36 changes: 35 additions & 1 deletion scripts/atomicSourceControl.test.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { describe, expect, test } from 'bun:test';
import path from 'node:path';
import { RepositorySession, resolveRepositoryPath, statusLabels } from '../src/atomic/model.ts';
import { mkdir, mkdtemp, realpath, rm, symlink, writeFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { RepositorySession, resolveRepositoryPath, isRepositoryFilePath, statusLabels } from '../src/atomic/model.ts';

function fixture() {
const calls = [];
Expand All @@ -24,6 +26,38 @@ describe('Atomic version control model', () => {
}
});

test('matches unsaved files opened through a repository alias, including missing parent directories', async () => {
const directory = await mkdtemp(path.join(tmpdir(), 'atomic-editor-alias-'));
try {
const root = path.join(await realpath(directory), 'repository');
const alias = path.join(directory, 'alias');
await mkdir(root);
await writeFile(path.join(root, 'intent.md'), '# Intent\n');
await symlink(root, alias, 'junction');
expect(await isRepositoryFilePath(root, path.join(alias, 'intent.md'))).toBe(true);
expect(await isRepositoryFilePath(root, path.join(alias, 'new', 'nested', 'intent.md'))).toBe(true);
} finally {
await rm(directory, { recursive: true, force: true });
}
});

test('does not treat a dirty file in an aliased sibling repository as owned', async () => {
const directory = await mkdtemp(path.join(tmpdir(), 'atomic-editor-boundary-'));
try {
const canonical = await realpath(directory);
const root = path.join(canonical, 'repository');
const sibling = path.join(canonical, 'repository-other');
const alias = path.join(directory, 'alias');
await mkdir(root);
await mkdir(sibling);
await writeFile(path.join(sibling, 'intent.md'), '# Unrelated intent\n');
await symlink(sibling, alias, 'junction');
expect(await isRepositoryFilePath(root, path.join(alias, 'intent.md'))).toBe(false);
} finally {
await rm(directory, { recursive: true, force: true });
}
});

test('uses the displayed view for bounded history reads', async () => {
const { session, calls, status } = fixture();
await session.run(() => session.refresh());
Expand Down
27 changes: 27 additions & 0 deletions src/atomic/model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as path from 'node:path';
import { realpath } from 'node:fs/promises';
import type { AtomicRepository } from 'nodeatomic' with { 'resolution-mode': 'import' };
import type { ViewSummary } from '../shared/atomicEvidence';

Expand Down Expand Up @@ -38,6 +39,32 @@ export function resolveRepositoryPath(root: string, file: string): string {
return resolved;
}

/** Match editor paths to a canonical repository root, including aliases and missing files. */
export async function isRepositoryFilePath(root: string, file: string): Promise<boolean> {
const contains = (candidate: string): boolean => {
try {
resolveRepositoryPath(root, path.relative(root, candidate));
return true;
} catch { return false; }
};
if (contains(file)) return true;
let candidate = file;
let parent = path.dirname(candidate);
let suffix = '';
while (candidate !== parent) {
try {
return contains(path.join(await realpath(candidate), suffix));
} catch (error) {
const code = (error as NodeJS.ErrnoException).code;
if (code !== 'ENOENT' && code !== 'ENOTDIR') throw error;
suffix = path.join(path.basename(candidate), suffix);
candidate = parent;
parent = path.dirname(candidate);
}
}
return false;
}

function identityPart(value: unknown): string {
if (value instanceof Uint8Array) return Buffer.from(value).toString('hex');
if (value && typeof value === 'object' && 'value' in value) {
Expand Down
7 changes: 4 additions & 3 deletions src/atomic/operationResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export function pullResult(response: PullResponse): OperationResult {
export function insertResult(response: InsertViewResponse): OperationResult {
const lines = [`Inserted ${response.inserted.length} changes into “${response.resolvedTargetView}”; ${response.skippedCount} already present.`];
if (response.filesUpdated != null) lines.push(`${response.filesUpdated} working-copy files updated.`);
const conflicts = response.conflicts.map((conflict) => conflict.path).filter(Boolean);
return { lines, ...(response.hasConflicts || conflicts.length
? { error: `Insertion reported conflicts${conflicts.length ? `: ${conflicts.join(', ')}` : '.'}` } : {}) };
// Native conflict paths describe the working copy, not an inactive target.
const conflicts = response.filesUpdated == null ? '' : response.conflicts.map((conflict) => conflict.path).filter(Boolean).join(', ');
return { lines, ...(response.hasConflicts || conflicts
? { error: `Insertion reported conflicts${conflicts ? `: ${conflicts}` : '.'}` } : {}) };
}
40 changes: 23 additions & 17 deletions src/atomic/sourceControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as path from 'node:path';
import { stat, lstat, realpath } from 'node:fs/promises';
import { pathToFileURL } from 'node:url';
import * as vscode from 'vscode';
import { RepositorySession, resolveRepositoryPath, statusIdentity, statusLabels, summarizeView, viewTreeDescription, partitionRepositoryFiles, type History } from './model';
import { RepositorySession, resolveRepositoryPath, isRepositoryFilePath, statusIdentity, statusLabels, summarizeView, viewTreeDescription, partitionRepositoryFiles, type History } from './model';
import { describeAtomicError, type AtomicIssue } from './errors';
import { AtomicGraphPanel } from './graphPanel';
import { displayChangeHash } from '../shared/atomicHash';
Expand Down Expand Up @@ -65,7 +65,8 @@ class AtomicSourceControl implements vscode.TreeDataProvider<Node>, vscode.Dispo
if (!displayedStatus) throw new Error('Refresh Atomic status before recording.');
await owner.session.run(async () => {
this.requireTrusted();
if (this.hasDirtyDocuments(owner)) throw new Error('Save or close unsaved files in this repository before recording.');
if (await this.hasDirtyDocuments(owner)) throw new Error('Save or close unsaved files in this repository before recording.');
this.requireTrusted();
await owner.session.record(message, displayedStatus);
if (owner.scm.inputBox.value === message) owner.scm.inputBox.value = '';
await this.update(owner);
Expand Down Expand Up @@ -103,7 +104,8 @@ class AtomicSourceControl implements vscode.TreeDataProvider<Node>, vscode.Dispo
if (!name) return;
await owner.session.run(async () => {
this.requireTrusted();
if (this.hasDirtyDocuments(owner)) throw new Error('Save or close unsaved files before switching views.');
if (await this.hasDirtyDocuments(owner)) throw new Error('Save or close unsaved files before switching views.');
this.requireTrusted();
// Never bypass Atomic's dirty-working-copy check.
await owner.session.client.views.switch(name);
await this.update(owner);
Expand Down Expand Up @@ -386,20 +388,23 @@ class AtomicSourceControl implements vscode.TreeDataProvider<Node>, vscode.Dispo
this.changed.fire(undefined);
}

private hasDirtyDocuments(owner: RepositoryUI): boolean {
const inRepository = (uri: vscode.Uri): boolean => {
if (uri.scheme !== 'file') return false;
try {
resolveRepositoryPath(owner.session.root, path.relative(owner.session.root, uri.fsPath));
return true;
} catch { return false; }
};
if (vscode.workspace.textDocuments.some((doc) => doc.isDirty && inRepository(doc.uri))) return true;
private async hasDirtyDocuments(owner: RepositoryUI): Promise<boolean> {
const paths = new Set<string>();
for (const doc of vscode.workspace.textDocuments) {
if (doc.isDirty && doc.uri.scheme === 'file') paths.add(doc.uri.fsPath);
}
// File-backed custom documents can remain dirty after VS Code closes their backing TextDocument.
return vscode.window.tabGroups.all.some((group) => group.tabs.some((tab) => {
const input = tab.input;
return tab.isDirty && (input instanceof vscode.TabInputCustom || input instanceof vscode.TabInputText) && inRepository(input.uri);
}));
for (const group of vscode.window.tabGroups.all) {
for (const tab of group.tabs) {
const input = tab.input;
if (tab.isDirty && (input instanceof vscode.TabInputCustom || input instanceof vscode.TabInputText)
&& input.uri.scheme === 'file') paths.add(input.uri.fsPath);
}
}
for (const file of paths) {
if (await isRepositoryFilePath(owner.session.root, file)) return true;
}
return false;
}

private async promptRemote(): Promise<string | undefined> {
Expand Down Expand Up @@ -428,12 +433,13 @@ class AtomicSourceControl implements vscode.TreeDataProvider<Node>, vscode.Dispo
() => owner.session.run(async () => {
this.requireTrusted();
if (!this.isOwner(owner)) return;
if (workingCopyView !== undefined && this.hasDirtyDocuments(owner)) {
if (workingCopyView !== undefined && await this.hasDirtyDocuments(owner)) {
const currentView = (await owner.session.client.status()).view;
if (!workingCopyView.trim() || workingCopyView.trim() === currentView) {
throw new Error('Save or close unsaved files before updating the working-copy view.');
}
}
this.requireTrusted();
this.output.appendLine(`${label}: ${owner.session.root}`);
const result = await operation();
result.lines.forEach((line) => this.output.appendLine(line));
Expand Down
6 changes: 3 additions & 3 deletions vendor/nodeatomic/NOTICE
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Vendored nodeatomic JavaScript consumer and generated protobuf codecs.

Source: https://github.com/atomicdotdev/nodeatomic
Source revision: ac76e68d3d7facd8aefe26ef04baf3350509b115
Generated codecs/fingerprint use the matching libatomic descriptor.
Native producer revision: cbca73955d3a5a9cac217dc80b4e3b449b8cca8e
Source revision: fd91a76bcbef416b8114ab9885d462c5a2783dff
Generated codecs/fingerprint use the published Atomic v0.22.0 descriptor.
Native producer revision: 61d8040ed25508ca00b778ae01d7c32499f1cab3
License: MIT OR Apache-2.0

The vendored files are distributed under the MIT license in the repository
Expand Down
Loading
Loading