Skip to content

Commit 4ffe13b

Browse files
committed
Atom++: M0–M2 + agent guide for Claude Code
1 parent d97044d commit 4ffe13b

8 files changed

Lines changed: 419 additions & 19 deletions

File tree

‎CLAUDE.md‎

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Atom++ — Agent Guide (CLAUDE.md)
2+
3+
Atom++ is an **AI-native, hackable, Notepad++-powered code editor for macOS**, built as a
4+
**fork of Code-OSS** (the MIT core behind VS Code). Goal: the user's "last editor" — Atom feel,
5+
Notepad++ power-editing, native Claude AI, all MIT/license-clean.
6+
7+
Read `PLAN.md` for the vision/roadmap and `docs/CORE-PATCHES.md` for every change made inside
8+
the upstream source.
9+
10+
## ⚠️ The most important rule: what's tracked vs generated
11+
12+
`vscode/` is a **gitignored, disposable clone** of Code-OSS produced by `scripts/bootstrap.sh`.
13+
**Never edit anything in `vscode/` directly — it gets overwritten.** Everything that is *ours*
14+
lives in the tracked repo and is re-applied onto a clean clone:
15+
16+
| Ours (edit here, tracked) | Gets installed into (generated) | By |
17+
| --- | --- | --- |
18+
| `extensions/atom-npp-pack/`, `extensions/atom-ai/` | `vscode/extensions/*` | `apply-branding.mjs` (copy) |
19+
| `branding/product.overlay.json`, `branding/icons/` | `vscode/product.json`, `vscode/resources/...` | `apply-branding.mjs` (merge/copy) |
20+
| `patches/atom-core.patch` | edits to `vscode/src/**`, `vscode/build/**` | `bootstrap.sh` (`git apply`) |
21+
22+
So: **edit extensions in `extensions/…`, not `vscode/extensions/…`.** After editing, run
23+
`./scripts/run-dev.sh` (it syncs canonical → checkout first) to test.
24+
25+
A full rebuild from nothing = `bootstrap.sh` → `build-macos.sh`. Nothing is lost if `vscode/` is deleted.
26+
27+
## Repo layout
28+
29+
```
30+
PLAN.md vision + phased roadmap (M0/M1/M2…)
31+
CLAUDE.md this file
32+
docs/CORE-PATCHES.md log of every edit inside vscode/ (tagged // [Atom++])
33+
docs/M0-RUNBOOK.md, EXIT-TEST.md, M1-SPEC.md
34+
branding/product.overlay.json Atom++ identity + Open VSX gallery (deep-merged onto product.json)
35+
branding/icons/ app icon source PNG, generated .icns, 1024 png
36+
extensions/atom-npp-pack/ Notepad++ power-editing pack (plain JS, no build step)
37+
extensions/atom-ai/ native Claude AI (chat, providers, edit-with-diff, LM provider)
38+
patches/atom-core.patch our core source edits, applied on bootstrap
39+
scripts/ bootstrap.sh, apply-branding.mjs, run-dev.sh, build-macos.sh, make-icon.sh
40+
vscode/ GITIGNORED upstream Code-OSS checkout (generated)
41+
```
42+
43+
## Build / run
44+
45+
```bash
46+
./scripts/bootstrap.sh # fresh: clone Code-OSS @ pinned tag, brand, install extensions, apply patches, npm ci
47+
./scripts/run-dev.sh # dev: sync + compile + launch (Copilot disabled). Fast iteration.
48+
./scripts/build-macos.sh # package Atom++.app (arch-aware). Output: VSCode-darwin-<arch>/Atom++.app
49+
./scripts/make-icon.sh # regenerate .icns from branding/icons/atom-plus-plus-source.png (sips+iconutil)
50+
```
51+
52+
## Toolchain (hard requirements — these bit us)
53+
54+
- **Node = `vscode/.nvmrc` (currently 24.15.0)**. Older majors fail to compile native modules.
55+
- **Python ≥ 3.8** for node-gyp (its bundled gyp uses `:=`; 3.7 crashes).
56+
- **Native arm64 everything.** If you run under Rosetta (x64 Node on an arm64 Mac), esbuild/tsgo
57+
crash mid-build ("wrong platform" / "tsgo exited with code unknown"). Fix: native arm64 terminal +
58+
arm64 Node, then `rm -rf vscode/node_modules && npm ci`. `bootstrap.sh`/`build-macos.sh` now hard-fail on mismatch.
59+
60+
## Core patches (things changed inside vscode/)
61+
62+
Tracked in `patches/atom-core.patch`, tagged with `// [Atom++]`. Find them all:
63+
`grep -rn "\[Atom++\]" vscode/src vscode/build`. Re-create the patch after editing core:
64+
`git -C vscode diff -- <files> > patches/atom-core.patch`. Current patches:
65+
66+
1. `src/vs/workbench/contrib/files/browser/files.contribution.ts` — `files.hotExit` default → `onExitAndWindowClose` (Sublime-style persistence; application-scoped so can't be set by an extension).
67+
2. `build/lib/extensions.ts` (`packageCopilotExtensionStream`) — returns empty: do NOT bundle the proprietary GitHub Copilot Chat extension (not MIT).
68+
3. `build/lib/copilot.ts` (`prepareBuiltInCopilotRipgrepShim`) — skip instead of throw when Copilot absent.
69+
70+
## Copilot is removed everywhere (keep it that way)
71+
72+
- Not bundled in the packaged app (patches #2/#3).
73+
- Disabled in dev: `run-dev.sh` launches with `--disable-extension GitHub.copilot-chat`.
74+
- **DON'T null `product.defaultChatAgent`** — the onboarding code does `assertDefined(product.defaultChatAgent)`
75+
and the workbench crashes at startup if it's missing. Leave it a valid object; we just don't show/use it.
76+
77+
## Settings shipped as defaults (via extension `configurationDefaults` or core patch)
78+
79+
- `files.hotExit = onExitAndWindowClose` (core patch — application-scoped).
80+
- `workbench.editorLargeFileConfirmation = 2048`, `chat.commandCenter.enabled = false`, `chat.disableAIFeatures = true` (atom-npp-pack).
81+
- Extensions can only override **machine-overridable / window / resource / language-overridable** scoped settings — NOT application/machine. (That's why hotExit needed a core patch.)
82+
83+
## Feature status
84+
85+
**M1 — Notepad++ pack (`extensions/atom-npp-pack/`, all done, plain JS):**
86+
macros (`Cmd+Shift+R`/`Cmd+Alt+P`), Duplicate file (`Cmd+D` / Explorer menu), Sublime hot-exit,
87+
line operations (sort/dedup/case/…), column incrementing numbers, encoding/EOL status-bar toggle,
88+
big-file mode badge. Files: extension.js + fileOps/lineOps/columnOps/encodingEol/bigFile.js.
89+
90+
**M2 — native AI (`extensions/atom-ai/`, working):**
91+
- `providers.js` — streaming Anthropic Messages API + Ollama `/api/chat` (direct, BYO key, no backend).
92+
- `extension.js` — webview chat panel: streaming, model picker (Claude Opus 4.8 / Sonnet 4.6 / Haiku 4.5 + Ollama),
93+
`Add selection` context, and **auto-includes the whole open file** as context (chip in input; `atompp.ai.includeActiveFile`).
94+
Key stored in SecretStorage (`atompp.ai.anthropicKey`).
95+
- `lmProvider.js` — registers Claude as a native `LanguageModelChatProvider` (vendor `atompp`). Stable API.
96+
- `aiEdit.js` — **edit-with-diff**: select code → `Cmd+Alt+E` → instruction → side-by-side diff → ✓ Keep / ✗ Discard
97+
buttons on the diff toolbar (gated on `atompp.ai.diffActive`).
98+
- `inlineReview.js` — **dead code** (an inline per-hunk Keep/Undo attempt that was reverted; nothing imports it).
99+
100+
## Deferred / known limits (don't waste time re-hitting these)
101+
102+
- **Copilot-grade inline edit review** (floating Keep/Undo button widget + red removed-line phantom rows) is
103+
**core `chatEditing` UI only** — unreachable from an extension (no overlay widgets, no view-zones). Doing it
104+
"right" means driving VS Code's native chat-editing: register a chat participant + a complete
105+
`IDefaultChatAgent` in product.json + patch out Copilot's sign-in/entitlement gating in `chatSetup*`. Big,
106+
multi-session core effort. We use the diff-tab review instead.
107+
- Not yet built: inline tab-completion, codebase-wide (multi-file) chat context, Notepad++ keymap preset.
108+
109+
## Conventions
110+
111+
- Extensions are plain JS, no build step (so they ship via `fromLocalNormal`/vsce with no compile). Keep it that way.
112+
- `// @ts-check` + JSDoc at top of JS files.
113+
- Test JS logic with `node --check` and small unit snippets before wiring into the editor.
114+
- After any change, `./scripts/run-dev.sh` to verify; package with `./scripts/build-macos.sh`.
115+
- Commit `extensions/`, `patches/`, `branding/`, `scripts/`, `docs/`, `PLAN.md`, `CLAUDE.md`. Never commit `vscode/`.

‎extensions/atom-ai/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ Native, Claude-first AI for Atom++. The chat lives in its own activity-bar panel
2020
**Settings:** `atompp.ai.provider`, `atompp.ai.claude.model`, `atompp.ai.claude.maxTokens`,
2121
`atompp.ai.ollama.url`, `atompp.ai.ollama.model`.
2222

23-
**Edit with diff:** select code → `⌥⌘E` (or right-click → *AI: Edit Selection…*) → describe the change. The model rewrites it, you review a side-by-side diff, and click **Apply** or **Discard**. Your file isn't changed until you Apply.
23+
**Edit with inline review:** select code → `⌥⌘E` (or right-click → *AI: Edit Selection…*) → describe the change. The model rewrites it and the result appears **inline in the editor** with changed lines highlighted green and a CodeLens above each change offering **✓ Keep / ✗ Undo** (plus **Keep All / Undo All** at the top). Keep accepts a change; Undo restores the original for that hunk. Nothing is final until you Keep.
2424

2525
Coming next in M2: inline tab-completion, and codebase-wide context.

‎extensions/atom-ai/aiEdit.js‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*---------------------------------------------------------------------------------------------
2-
* Atom++ — AI (M2, feature: edit with diff)
2+
* Atom++ — AI (M2: edit selection → reviewable diff)
33
*
44
* Select code → describe a change → the model rewrites it → review a side-by-side diff →
5-
* Apply or Discard using the buttons on the diff editor's toolbar. The proposed text is
6-
* served through a virtual document so the diff shows syntax-highlighted before/after
7-
* without touching your file until you click Apply.
5+
* ✓ Keep / ✗ Discard from the diff editor's toolbar. The proposed text is served through a
6+
* virtual document so the diff is syntax-highlighted before/after, and your file isn't
7+
* changed until you Keep.
88
*--------------------------------------------------------------------------------------------*/
99
// @ts-check
1010
'use strict';
@@ -97,6 +97,14 @@ async function discardEdit() {
9797
vscode.window.setStatusBarMessage('Atom++ AI: edit discarded', 1500);
9898
}
9999

100+
/** Whole-line range covering the selection. */
101+
function fullLineRange(editor) {
102+
const sel = editor.selection;
103+
let endLine = sel.end.line;
104+
if (sel.end.character === 0 && endLine > sel.start.line) { endLine -= 1; }
105+
return new vscode.Range(sel.start.line, 0, endLine, editor.document.lineAt(endLine).text.length);
106+
}
107+
100108
/** @param {{aiConfig:()=>any, getClaudeKey:()=>Promise<string|undefined>, streamClaude:Function, streamOllama:Function}} deps */
101109
async function editSelection(deps) {
102110
const ed = vscode.window.activeTextEditor;
@@ -113,7 +121,7 @@ async function editSelection(deps) {
113121
if (!instruction) { return; }
114122

115123
const doc = ed.document;
116-
const range = new vscode.Range(ed.selection.start, ed.selection.end);
124+
const range = fullLineRange(ed);
117125
const original = doc.getText(range);
118126
const lang = doc.languageId || '';
119127
const userMsg = `Instruction: ${instruction}\n\nCode (${lang}):\n${original}`;
@@ -160,7 +168,7 @@ async function editSelection(deps) {
160168
pending.set(propUri.toString(), { docUri: doc.uri, range, newText: proposed, origUri });
161169

162170
await vscode.commands.executeCommand('vscode.diff', origUri, propUri,
163-
'Atom++ AI: proposed edit — use ✓ Apply / ✗ Discard above', { preview: true });
171+
'Atom++ AI: proposed edit — use ✓ Keep / ✗ Discard above', { preview: true });
164172
updateDiffContext();
165173
}
166174

@@ -173,12 +181,9 @@ function registerAiEdit(context, deps) {
173181
vscode.commands.registerCommand('atompp.ai.discardEdit', discardEdit),
174182
vscode.window.tabGroups.onDidChangeTabGroups(updateDiffContext),
175183
vscode.window.tabGroups.onDidChangeTabs((e) => {
176-
// If the user closes our diff tab without choosing, clean up.
177184
for (const tab of e.closed) {
178185
const input = /** @type {any} */ (tab.input);
179-
if (input && input.modified && input.modified.scheme === SCHEME) {
180-
cleanup(input.modified);
181-
}
186+
if (input && input.modified && input.modified.scheme === SCHEME) { cleanup(input.modified); }
182187
}
183188
updateDiffContext();
184189
})

‎extensions/atom-ai/extension.js‎

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,39 @@ function newChat() {
8181
post({ type: 'reset' });
8282
}
8383

84+
/** The currently open file as a context block (capped), or null. */
85+
function activeFileBlock() {
86+
const ed = vscode.window.activeTextEditor;
87+
if (!ed || ed.document.uri.scheme !== 'file') { return null; }
88+
if (!aiConfig().get('includeActiveFile', true)) { return null; }
89+
const name = path.basename(ed.document.uri.fsPath);
90+
const lang = ed.document.languageId || '';
91+
let body = ed.document.getText();
92+
const MAX = 120 * 1024;
93+
if (body.length > MAX) { body = body.slice(0, MAX) + '\n…(file truncated for context)…'; }
94+
return 'Currently open file `' + name + '` (full contents):\n```' + lang + '\n' + body + '\n```';
95+
}
96+
97+
/** Tell the webview which file is open, to show as a context chip. */
98+
function postActiveFile() {
99+
const ed = vscode.window.activeTextEditor;
100+
if (!ed || ed.document.uri.scheme !== 'file' || !aiConfig().get('includeActiveFile', true)) {
101+
post({ type: 'activeFile', label: null });
102+
return;
103+
}
104+
post({ type: 'activeFile', label: path.basename(ed.document.uri.fsPath) + ' · ' + ed.document.lineCount + ' lines' });
105+
}
106+
84107
async function handleSend(text) {
85108
if (!text || !text.trim()) { return; }
86109
const cfg = aiConfig();
87110
const provider = cfg.get('provider', 'claude');
88111

89-
const userContent = pendingContext ? (pendingContext + '\n\n' + text) : text;
112+
const blocks = [];
113+
const fileBlock = activeFileBlock();
114+
if (fileBlock) { blocks.push(fileBlock); }
115+
if (pendingContext) { blocks.push(pendingContext); }
116+
const userContent = blocks.length ? (blocks.join('\n\n') + '\n\n' + text) : text;
90117
conversation.push({ role: 'user', content: userContent });
91118
post({ type: 'userMessage', text });
92119
pendingContext = null;
@@ -186,7 +213,7 @@ class ChatViewProvider {
186213
view.webview.html = getHtml();
187214
view.webview.onDidReceiveMessage(async (msg) => {
188215
switch (msg.type) {
189-
case 'ready': sendConfigToWebview(); break;
216+
case 'ready': sendConfigToWebview(); postActiveFile(); break;
190217
case 'send': await handleSend(msg.text); break;
191218
case 'stop': if (abort) { abort.abort(); } break;
192219
case 'addSelection': addSelection(); break;
@@ -215,6 +242,7 @@ function activate(context) {
215242
vscode.window.registerWebviewViewProvider('atomAi.chat', new ChatViewProvider(), {
216243
webviewOptions: { retainContextWhenHidden: true }
217244
}),
245+
vscode.window.onDidChangeActiveTextEditor(() => postActiveFile()),
218246
vscode.commands.registerCommand('atompp.ai.focus', () => vscode.commands.executeCommand('atomAi.chat.focus')),
219247
vscode.commands.registerCommand('atompp.ai.newChat', newChat),
220248
vscode.commands.registerCommand('atompp.ai.pickModel', pickModel),

0 commit comments

Comments
 (0)