Skip to content

Commit 552c157

Browse files
committed
Merge branch 'dev' into nate/apple-developer-finally
2 parents 4cf31b8 + 1f2a58e commit 552c157

File tree

95 files changed

+2320
-1129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+2320
-1129
lines changed

.github/workflows/dev_pr.yaml

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Dev PR checks
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- dev
7+
8+
jobs:
9+
tsc-check:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
# 1. Check-out repository
14+
- name: Check-out repository
15+
uses: actions/checkout@v4
16+
17+
# 2. Install npm dependencies
18+
- name: Use Node.js from .nvmrc
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version-file: ".nvmrc"
22+
23+
- name: Cache extension node_modules
24+
uses: actions/cache@v3
25+
with:
26+
path: extensions/vscode/node_modules
27+
key: ${{ runner.os }}-node-${{ hashFiles('extensions/vscode/package-lock.json') }}
28+
29+
- name: Cache core node_modules
30+
uses: actions/cache@v3
31+
with:
32+
path: core/node_modules
33+
key: ${{ runner.os }}-node-${{ hashFiles('core/package-lock.json') }}
34+
35+
- name: Cache gui node_modules
36+
uses: actions/cache@v3
37+
with:
38+
path: gui/node_modules
39+
key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }}
40+
41+
- name: Cache binary node_modules
42+
uses: actions/cache@v3
43+
with:
44+
path: binary/node_modules
45+
key: ${{ runner.os }}-node-${{ hashFiles('binary/package-lock.json') }}
46+
47+
- name: extensions/vscode install
48+
run: |
49+
cd extensions/vscode
50+
npm ci
51+
env:
52+
# https://github.com/microsoft/vscode-ripgrep/issues/9#issuecomment-643965333
53+
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
54+
55+
- name: core install
56+
run: |
57+
cd core
58+
npm ci
59+
60+
- name: gui install
61+
run: |
62+
cd gui
63+
npm ci
64+
65+
- name: binary install
66+
run: |
67+
cd binary
68+
npm ci
69+
70+
- name: extensions/vscode checks
71+
run: |
72+
cd extensions/vscode
73+
npx tsc --noEmit
74+
75+
- name: core checks
76+
run: |
77+
cd core
78+
npm ci
79+
npx tsc --noEmit
80+
npm run lint
81+
env:
82+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
83+
84+
- name: gui checks
85+
run: |
86+
cd gui
87+
npx tsc --noEmit
88+
89+
- name: binary checks
90+
run: |
91+
cd binary
92+
npx tsc --noEmit

.github/workflows/ts-check.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ on:
55
branches:
66
- main
77
- preview
8-
- dev
98

109
jobs:
1110
tsc-check:

core/.eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"plugins": ["@typescript-eslint", "import"],
99
"rules": {
1010
"quotes": ["warn", "double", {}],
11-
"@typescript-eslint/naming-convention": "warn",
11+
"@typescript-eslint/naming-convention": "off",
1212
"@typescript-eslint/semi": "warn",
1313
"curly": "warn",
1414
"eqeqeq": "warn",

core/.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ target
44
npm-debug.log*
55
.env
66
.continue-test
7-
testDir
7+
testDir
8+
coverage

core/autocomplete/brackets.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ export class BracketMatchingService {
8484
// Add corresponding open brackets from suffix to stack
8585
// because we overwrite them and the diff is displayed, and this allows something to be edited after that
8686
for (let i = 0; i < suffix.length; i++) {
87-
if (suffix[i] === " ") continue;
87+
if (suffix[i] === " ") {continue;}
8888
const openBracket = BracketMatchingService.BRACKETS_REVERSE[suffix[i]];
89-
if (!openBracket) break;
89+
if (!openBracket) {break;}
9090
stack.unshift(openBracket);
9191
}
9292

core/test/streamTransforms/stopAtStopTokens.test.ts renamed to core/autocomplete/charStream.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { stopAtStopTokens } from "../../autocomplete/charStream.js";
1+
import { stopAtStopTokens } from "./charStream";
22

33
describe("stopAtStopTokens", () => {
44
async function* createMockStream(chunks: string[]): AsyncGenerator<string> {

core/autocomplete/charStream.ts

+32
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1+
/**
2+
* Asynchronous generator that yields characters from the input stream until it encounters
3+
* an end-of-line character followed by a non-whitespace character.
4+
*
5+
* @param {AsyncGenerator<string>} stream - The input stream of characters.
6+
* @param {string[]} endOfLine - An array of characters considered as end-of-line markers.
7+
* @param {() => void} fullStop - A function to be called when the generator stops.
8+
* @yields {string} Characters from the input stream.
9+
* @returns {AsyncGenerator<string>} An async generator that yields characters.
10+
*/
111
export async function* onlyWhitespaceAfterEndOfLine(
212
stream: AsyncGenerator<string>,
313
endOfLine: string[],
414
fullStop: () => void,
515
): AsyncGenerator<string> {
616
let pending = "";
17+
718
for await (let chunk of stream) {
819
chunk = pending + chunk;
920
pending = "";
21+
1022
for (let i = 0; i < chunk.length - 1; i++) {
1123
if (
1224
endOfLine.includes(chunk[i]) &&
@@ -17,6 +29,7 @@ export async function* onlyWhitespaceAfterEndOfLine(
1729
return;
1830
}
1931
}
32+
2033
if (endOfLine.includes(chunk[chunk.length - 1])) {
2134
pending = chunk[chunk.length - 1];
2235
yield chunk.slice(0, chunk.length - 1);
@@ -27,6 +40,11 @@ export async function* onlyWhitespaceAfterEndOfLine(
2740
yield pending;
2841
}
2942

43+
/**
44+
* Yields characters from the stream, stopping if the first character is a newline.
45+
* @param {AsyncGenerator<string>} stream - The input character stream.
46+
* @yields {string} Characters from the stream.
47+
*/
3048
export async function* noFirstCharNewline(stream: AsyncGenerator<string>) {
3149
let first = true;
3250
for await (const char of stream) {
@@ -40,6 +58,20 @@ export async function* noFirstCharNewline(stream: AsyncGenerator<string>) {
4058
}
4159
}
4260

61+
/**
62+
* Asynchronously yields characters from the input stream, stopping if a stop token is encountered.
63+
*
64+
* @param {AsyncGenerator<string>} stream - The input stream of characters.
65+
* @param {string[]} stopTokens - Array of tokens that signal when to stop yielding.
66+
* @yields {string} Characters from the input stream.
67+
* @returns {AsyncGenerator<string>} An async generator that yields characters until a stop condition is met.
68+
* @description
69+
* 1. If no stop tokens are provided, yields all characters from the stream.
70+
* 2. Otherwise, buffers incoming chunks and checks for stop tokens.
71+
* 3. Yields characters one by one if no stop token is found at the start of the buffer.
72+
* 4. Stops yielding and returns if a stop token is encountered.
73+
* 5. After the stream ends, yields any remaining buffered characters.
74+
*/
4375
export async function* stopAtStopTokens(
4476
stream: AsyncGenerator<string>,
4577
stopTokens: string[],

core/autocomplete/completionProvider.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {
3737
import { isOnlyPunctuationAndWhitespace } from "./filter.js";
3838
import { AutocompleteLanguageInfo } from "./languages.js";
3939
import {
40-
avoidPathLine,
40+
avoidPathLineAndEmptyComments,
4141
noTopLevelKeywordsMidline,
4242
skipPrefixes,
4343
stopAtLines,
@@ -478,9 +478,9 @@ export class CompletionProvider {
478478
const lines = fullPrefix.split("\n");
479479
fullPrefix = `${lines.slice(0, -1).join("\n")}\n${
480480
lang.singleLineComment
481-
} ${input.injectDetails.split("\n").join(`\n${lang.singleLineComment} `)}\n${
482-
lines[lines.length - 1]
483-
}`;
481+
} ${input.injectDetails
482+
.split("\n")
483+
.join(`\n${lang.singleLineComment} `)}\n${lines[lines.length - 1]}`;
484484
}
485485

486486
const fullSuffix = getRangeInString(fileContents, {
@@ -581,7 +581,10 @@ export class CompletionProvider {
581581
prefix = `${formattedSnippets}\n\n${prefix}`;
582582
} else if (prefix.trim().length === 0 && suffix.trim().length === 0) {
583583
// If it's an empty file, include the file name as a comment
584-
prefix = `${lang.singleLineComment} ${getLastNPathParts(filepath, 2)}\n${prefix}`;
584+
prefix = `${lang.singleLineComment} ${getLastNPathParts(
585+
filepath,
586+
2,
587+
)}\n${prefix}`;
585588
}
586589

587590
prompt = compiledTemplate({
@@ -689,7 +692,10 @@ export class CompletionProvider {
689692
let lineGenerator = streamLines(charGenerator);
690693
lineGenerator = stopAtLines(lineGenerator, fullStop);
691694
lineGenerator = stopAtRepeatingLines(lineGenerator, fullStop);
692-
lineGenerator = avoidPathLine(lineGenerator, lang.singleLineComment);
695+
lineGenerator = avoidPathLineAndEmptyComments(
696+
lineGenerator,
697+
lang.singleLineComment,
698+
);
693699
lineGenerator = skipPrefixes(lineGenerator);
694700
lineGenerator = noTopLevelKeywordsMidline(
695701
lineGenerator,

core/autocomplete/languages.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const Python = {
2626
name: "Python",
2727
// """"#" is for .ipynb files, where we add '"""' surrounding markdown blocks.
2828
// This stops the model from trying to complete the start of a new markdown block
29-
topLevelKeywords: ["def", "class", '"""#'],
29+
topLevelKeywords: ["def", "class", "\"\"\"#"],
3030
singleLineComment: "#",
3131
endOfLine: [],
3232
};

0 commit comments

Comments
 (0)