Skip to content

Commit d97044d

Browse files
committed
Moved everything into atom-plus-plus/extensions and update scripts
1 parent c57b1b7 commit d97044d

28 files changed

Lines changed: 2107 additions & 5 deletions

‎branding/icons/README.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(place atom-plus-plus-source.png here; make-icon.sh generates atom-plus-plus.icns)
734 KB
Loading
522 KB
Loading

‎branding/icons/atom-plus-plus.icns‎

1.37 MB
Binary file not shown.

‎branding/icons/preview-on-gray.png‎

71.2 KB
Loading

‎docs/CORE-PATCHES.md‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Atom++ — Core Patches Log
2+
3+
Changes we make **inside** the Code-OSS source (`vscode/`) rather than in our bundled
4+
extension. Keep this list short and every patch tagged with a searchable `[Atom++]`
5+
comment in the code, so a rebase onto a newer Code-OSS tag is easy to re-apply/verify.
6+
7+
## How our code survives (reproducibility)
8+
9+
`vscode/` is **gitignored** — it's a disposable clone produced by `bootstrap.sh`. Everything
10+
that is *ours* lives in the tracked repo and is re-installed onto a clean clone:
11+
12+
- **Branding** → `branding/product.overlay.json` (+ `branding/icons/`), applied by `apply-branding.mjs`.
13+
- **Extensions** → `extensions/atom-npp-pack/`, `extensions/atom-ai/` are the **canonical source**;
14+
`apply-branding.mjs` copies them into `vscode/extensions/`. Edit them *here*, not in `vscode/`.
15+
- **Core source edits** → captured as `patches/atom-core.patch`; `bootstrap.sh` applies it
16+
(`git apply --3way`) onto the fresh checkout.
17+
18+
So a full rebuild from nothing is: `bootstrap.sh` (clone + brand + extensions + patches) → `build-macos.sh`.
19+
20+
To re-create the core patch after changing core files in `vscode/`:
21+
22+
```bash
23+
git -C vscode diff -- \
24+
src/vs/workbench/contrib/files/browser/files.contribution.ts \
25+
build/lib/extensions.ts build/lib/copilot.ts > patches/atom-core.patch
26+
```
27+
28+
To find every core touch in the checkout:
29+
30+
```bash
31+
grep -rn "\[Atom++\]" vscode/src vscode/build
32+
```
33+
34+
## Patches
35+
36+
| # | File | Change | Why |
37+
| --- | --- | --- | --- |
38+
| 1 | `src/vs/workbench/contrib/files/browser/files.contribution.ts` | `files.hotExit` default → `onExitAndWindowClose` (was `onExit`) | Sublime-style persistence by default. `files.hotExit` is application-scoped, which extensions are forbidden from overriding (only machine-overridable/window/resource/language-overridable defaults may be set by extensions), so this must be a core default. |
39+
| 2 | `build/lib/extensions.ts` (`packageCopilotExtensionStream`) | Return an empty stream — don't bundle the GitHub Copilot Chat extension. | Copilot Chat is **proprietary, not MIT**; redistributing it in a non-Microsoft product isn't permitted, and its from-source packaging is fragile (missing `shims.txt`/prebuilts broke the build). Atom++'s own AI layer (M2) replaces it. |
40+
| 3 | `build/lib/copilot.ts` (`prepareBuiltInCopilotRipgrepShim`) | Skip (return) instead of throwing when the Copilot SDK dir is absent. | Pairs with patch #2: with Copilot not bundled, the ripgrep-shim packaging step must no-op rather than fail. |
41+
42+
> Dev mode (`run-dev.sh`) still loads `extensions/copilot` from source; patches #2/#3 only affect the **packaged** app. We can disable it in dev too later if desired.
43+
44+
## Rebase procedure
45+
46+
After re-running `bootstrap.sh` on a newer tag, run `grep -rn "\[Atom++\]" vscode/src`
47+
to confirm each patch above still applies (line may move; the change is a one-liner).
48+
If upstream restructured the file, re-apply the equivalent change and update this table.

‎extensions/atom-ai/README.md‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Atom++ — AI
2+
3+
Native, Claude-first AI for Atom++. The chat lives in its own activity-bar panel and talks
4+
**directly** to the provider — there is no Atom++ server in between.
5+
6+
**Providers**
7+
8+
- **Claude** (Anthropic) — bring your own API key (`console.anthropic.com`). The key is stored in
9+
VS Code SecretStorage (your OS keychain), never written to settings.
10+
- **Ollama** — local models, no key. Point `atompp.ai.ollama.url` at your server and set
11+
`atompp.ai.ollama.model` to a model you've pulled.
12+
13+
**Use**
14+
15+
1. Click the **Atom++ AI** icon in the activity bar.
16+
2. First send prompts for your Anthropic key (or use the 🔑 button / `Atom++: AI: Set Anthropic API Key`).
17+
3. Type and press Enter. Responses stream in; **Stop** cancels.
18+
4. Select code in the editor → **Add selection** (or `⌥⌘A`) to send it as context.
19+
20+
**Settings:** `atompp.ai.provider`, `atompp.ai.claude.model`, `atompp.ai.claude.maxTokens`,
21+
`atompp.ai.ollama.url`, `atompp.ai.ollama.model`.
22+
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.
24+
25+
Coming next in M2: inline tab-completion, and codebase-wide context.

‎extensions/atom-ai/aiEdit.js‎

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Atom++ — AI (M2, feature: edit with diff)
3+
*
4+
* 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.
8+
*--------------------------------------------------------------------------------------------*/
9+
// @ts-check
10+
'use strict';
11+
12+
const vscode = require('vscode');
13+
const path = require('path');
14+
15+
const SCHEME = 'atompp-ai';
16+
const CTX_DIFF_ACTIVE = 'atompp.ai.diffActive';
17+
18+
/** @type {Map<string,string>} virtual-doc uri -> content */
19+
const contents = new Map();
20+
/** @type {Map<string,{docUri:vscode.Uri, range:vscode.Range, newText:string, origUri:vscode.Uri}>} keyed by proposed uri */
21+
const pending = new Map();
22+
let counter = 0;
23+
let providerRegistered = false;
24+
25+
const EDIT_SYSTEM =
26+
'You are a precise code editor. Rewrite the user\'s code so it satisfies their instruction. ' +
27+
'Output ONLY the rewritten code — no explanations, no commentary, and no Markdown code fences.';
28+
29+
function stripFences(text) {
30+
let s = text.trim();
31+
s = s.replace(/^```[a-zA-Z0-9_+\-.]*\n?/, '');
32+
s = s.replace(/\n?```$/, '');
33+
return s;
34+
}
35+
36+
function registerProvider(context) {
37+
if (providerRegistered) { return; }
38+
providerRegistered = true;
39+
context.subscriptions.push(vscode.workspace.registerTextDocumentContentProvider(SCHEME, {
40+
provideTextDocumentContent(uri) { return contents.get(uri.toString()) || ''; }
41+
}));
42+
}
43+
44+
/** The proposed-uri of the diff in the currently active tab, if it's one of ours. */
45+
function activeProposedUri() {
46+
const group = vscode.window.tabGroups.activeTabGroup;
47+
const input = /** @type {any} */ (group && group.activeTab && group.activeTab.input);
48+
if (input && input.modified && input.modified.scheme === SCHEME && pending.has(input.modified.toString())) {
49+
return input.modified;
50+
}
51+
return undefined;
52+
}
53+
54+
function updateDiffContext() {
55+
vscode.commands.executeCommand('setContext', CTX_DIFF_ACTIVE, !!activeProposedUri());
56+
}
57+
58+
function cleanup(propUri) {
59+
const key = propUri.toString();
60+
const p = pending.get(key);
61+
if (p) { contents.delete(p.origUri.toString()); }
62+
contents.delete(key);
63+
pending.delete(key);
64+
}
65+
66+
async function closeDiffTab(propUri) {
67+
for (const group of vscode.window.tabGroups.all) {
68+
for (const tab of group.tabs) {
69+
const input = /** @type {any} */ (tab.input);
70+
if (input && input.modified && input.modified.toString() === propUri.toString()) {
71+
await vscode.window.tabGroups.close(tab);
72+
}
73+
}
74+
}
75+
}
76+
77+
async function applyEdit() {
78+
const propUri = activeProposedUri();
79+
if (!propUri) { return; }
80+
const p = pending.get(propUri.toString());
81+
if (!p) { return; }
82+
const we = new vscode.WorkspaceEdit();
83+
we.replace(p.docUri, p.range, p.newText);
84+
await vscode.workspace.applyEdit(we);
85+
cleanup(propUri);
86+
await closeDiffTab(propUri);
87+
updateDiffContext();
88+
vscode.window.setStatusBarMessage('$(check) Atom++ AI: edit applied', 2000);
89+
}
90+
91+
async function discardEdit() {
92+
const propUri = activeProposedUri();
93+
if (!propUri) { return; }
94+
cleanup(propUri);
95+
await closeDiffTab(propUri);
96+
updateDiffContext();
97+
vscode.window.setStatusBarMessage('Atom++ AI: edit discarded', 1500);
98+
}
99+
100+
/** @param {{aiConfig:()=>any, getClaudeKey:()=>Promise<string|undefined>, streamClaude:Function, streamOllama:Function}} deps */
101+
async function editSelection(deps) {
102+
const ed = vscode.window.activeTextEditor;
103+
if (!ed || ed.selection.isEmpty) {
104+
vscode.window.showInformationMessage('Atom++ AI: select the code you want to edit first.');
105+
return;
106+
}
107+
const instruction = await vscode.window.showInputBox({
108+
title: 'Atom++ AI — Edit selection',
109+
prompt: 'Describe the change',
110+
placeHolder: 'e.g. add error handling and a JSDoc comment',
111+
ignoreFocusOut: true
112+
});
113+
if (!instruction) { return; }
114+
115+
const doc = ed.document;
116+
const range = new vscode.Range(ed.selection.start, ed.selection.end);
117+
const original = doc.getText(range);
118+
const lang = doc.languageId || '';
119+
const userMsg = `Instruction: ${instruction}\n\nCode (${lang}):\n${original}`;
120+
121+
let result = '';
122+
try {
123+
await vscode.window.withProgress(
124+
{ location: vscode.ProgressLocation.Notification, title: 'Atom++ AI is editing…', cancellable: true },
125+
async (_progress, token) => {
126+
const ac = new AbortController();
127+
token.onCancellationRequested(() => ac.abort());
128+
const onDelta = (d) => { result += d; };
129+
const cfg = deps.aiConfig();
130+
if (cfg.get('provider', 'claude') === 'claude') {
131+
const key = await deps.getClaudeKey();
132+
if (!key) { throw new Error('No Anthropic API key set.'); }
133+
await deps.streamClaude({
134+
apiKey: key, model: cfg.get('claude.model', 'claude-sonnet-4-6'),
135+
maxTokens: cfg.get('claude.maxTokens', 4096), system: EDIT_SYSTEM,
136+
messages: [{ role: 'user', content: userMsg }], signal: ac.signal, onDelta
137+
});
138+
} else {
139+
await deps.streamOllama({
140+
url: cfg.get('ollama.url', 'http://localhost:11434'), model: cfg.get('ollama.model', 'llama3.1'),
141+
system: EDIT_SYSTEM, messages: [{ role: 'user', content: userMsg }], signal: ac.signal, onDelta
142+
});
143+
}
144+
}
145+
);
146+
} catch (e) {
147+
vscode.window.showErrorMessage('Atom++ AI edit failed: ' + String((e && e.message) || e));
148+
return;
149+
}
150+
151+
const proposed = stripFences(result);
152+
if (!proposed.trim()) { vscode.window.showWarningMessage('Atom++ AI: no edit was produced.'); return; }
153+
154+
const ext = path.extname(doc.uri.fsPath) || '.txt';
155+
const n = ++counter;
156+
const origUri = vscode.Uri.parse(`${SCHEME}:/${n}/current${ext}`);
157+
const propUri = vscode.Uri.parse(`${SCHEME}:/${n}/proposed${ext}`);
158+
contents.set(origUri.toString(), original);
159+
contents.set(propUri.toString(), proposed);
160+
pending.set(propUri.toString(), { docUri: doc.uri, range, newText: proposed, origUri });
161+
162+
await vscode.commands.executeCommand('vscode.diff', origUri, propUri,
163+
'Atom++ AI: proposed edit — use ✓ Apply / ✗ Discard above', { preview: true });
164+
updateDiffContext();
165+
}
166+
167+
/** @param {vscode.ExtensionContext} context @param {object} deps */
168+
function registerAiEdit(context, deps) {
169+
registerProvider(context);
170+
context.subscriptions.push(
171+
vscode.commands.registerCommand('atompp.ai.editSelection', () => editSelection(deps)),
172+
vscode.commands.registerCommand('atompp.ai.applyEdit', applyEdit),
173+
vscode.commands.registerCommand('atompp.ai.discardEdit', discardEdit),
174+
vscode.window.tabGroups.onDidChangeTabGroups(updateDiffContext),
175+
vscode.window.tabGroups.onDidChangeTabs((e) => {
176+
// If the user closes our diff tab without choosing, clean up.
177+
for (const tab of e.closed) {
178+
const input = /** @type {any} */ (tab.input);
179+
if (input && input.modified && input.modified.scheme === SCHEME) {
180+
cleanup(input.modified);
181+
}
182+
}
183+
updateDiffContext();
184+
})
185+
);
186+
}
187+
188+
module.exports = { registerAiEdit };

0 commit comments

Comments
 (0)