Skip to content

Commit ce5cc2a

Browse files
committed
2 parents f290509 + f8bb00c commit ce5cc2a

File tree

35 files changed

+145
-158
lines changed

35 files changed

+145
-158
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ Stackwise introduces a straightforward command structure, where you specify a 'b
1616

1717
```typescript
1818
stack("brief describing a specific action", {
19-
input: /* single input or object {} with multiple inputs */,
20-
outExample: // same as above, but output
19+
in: /* single input or object {} with multiple inputs */,
20+
out: // same as above, but output
2121
})
2222
```
2323

@@ -73,7 +73,7 @@ const prompt = "What's the capital of the United States ?"
7373
result = await stack(
7474
"Ask a question to GPT-4",
7575
{
76-
input: prompt
76+
in: prompt
7777
output: "Washington D.C"
7878
}
7979
)

src/convertTypescriptToJson/index.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import convertTypescriptToJson from '.';
22

33
test('flattenInputJson correctly', () => {
4-
const jsonInput = `(property) input: {
4+
const jsonInput = `(property) in: {
55
test: {
66
example: boolean;
77
};
@@ -19,13 +19,13 @@ test('flattenInputJson correctly', () => {
1919
test('flattenInputJson correctly', () => {
2020
const jsonInput = `
2121
\`\`\`typescript
22-
(property) 'input': string[]
22+
(property) 'in': string[]
2323
\`\`\`
2424
2525
2626
`;
2727
const expectedOutput = {
28-
input: 'string[]'
28+
in: 'string[]'
2929
};
3030

3131
const result = convertTypescriptToJson(jsonInput);
@@ -34,12 +34,12 @@ test('flattenInputJson correctly', () => {
3434

3535
test('flattenInputJson correctly', () => {
3636
const jsonInput = `
37-
\`\`\`(property) input: string
37+
\`\`\`(property) in: string
3838
\`\`\`
3939
4040
`;
4141
const expectedOutput = {
42-
input: 'string'
42+
in: 'string'
4343
};
4444

4545
const result = convertTypescriptToJson(jsonInput);

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function activate(context: vscode.ExtensionContext) {
4242
console.log(inputJSON);
4343

4444
const outputInfo = await getHoverInformation(
45-
stackPosition.outExamplePosition
45+
stackPosition.outPosition
4646
);
4747

4848
console.log(`inputInfo`);

src/findStackPositions/index.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import * as vscode from "vscode";
2-
import PositionObject from "../positionObject";
3-
import getHoverInformation from "../hover";
1+
import * as vscode from 'vscode';
2+
import PositionObject from '../positionObject';
3+
import getHoverInformation from '../hover';
44

55
export default async function findStackPositions(
66
document
77
): Promise<PositionObject[]> {
88
const documentContent = document.getText();
9-
const lines = documentContent.split("\n");
9+
const lines = documentContent.split('\n');
1010

1111
let positions = []; // Array to store positions
1212

1313
for (let i = 0; i < lines.length; i++) {
14-
let stackIndex = lines[i].indexOf("stack(");
14+
let stackIndex = lines[i].indexOf('stack(');
1515
while (stackIndex >= 0) {
1616
const position = new vscode.Position(i, stackIndex);
1717
const typeInfo = await getHoverInformation(position);
@@ -20,7 +20,7 @@ export default async function findStackPositions(
2020
stackPosition: position,
2121
};
2222

23-
console.log("stackPosition added:", positionObject.stackPosition);
23+
console.log('stackPosition added:', positionObject.stackPosition);
2424

2525
// Function to find the next occurrence of a keyword after a given index
2626
function findNextKeyword(keyword, startIndex, currentLine) {
@@ -34,36 +34,36 @@ export default async function findStackPositions(
3434
return null;
3535
}
3636

37-
// Find the position of 'input:'
38-
let inputPosition = findNextKeyword("input", i, stackIndex);
37+
// Find the position of 'in:'
38+
let inputPosition = findNextKeyword('in', i, stackIndex);
3939
if (inputPosition) {
40-
positionObject["inputPosition"] = inputPosition;
41-
console.log("inputPosition added:", positionObject.inputPosition);
40+
positionObject['inputPosition'] = inputPosition;
41+
console.log('inputPosition added:', positionObject.inputPosition);
4242
}
4343

44-
// Find the position of 'outExample:'
45-
let outExamplePosition = findNextKeyword(
46-
"outExample:",
44+
// Find the position of 'out:'
45+
let outPosition = findNextKeyword(
46+
'out:',
4747
i,
4848
stackIndex
4949
);
50-
if (outExamplePosition) {
51-
positionObject["outExamplePosition"] = outExamplePosition;
50+
if (outPosition) {
51+
positionObject['outPosition'] = outPosition;
5252
console.log(
53-
"outExamplePosition added:",
54-
positionObject.outExamplePosition
53+
'outPosition added:',
54+
positionObject.outPosition
5555
);
5656
}
5757

5858
positions.push(positionObject);
59-
console.log("Position object added:", positionObject);
59+
console.log('Position object added:', positionObject);
6060
}
6161

6262
// Find next occurrence of 'stack(' in the same line
63-
stackIndex = lines[i].indexOf("stack(", stackIndex + 1);
63+
stackIndex = lines[i].indexOf('stack(', stackIndex + 1);
6464
}
6565
}
6666

67-
console.log("Final positions array:", positions);
67+
console.log('Final positions array:', positions);
6868
return positions; // Return array of positions
6969
}

src/positionObject/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ import * as vscode from 'vscode';
33
export default interface PositionObject {
44
stackPosition: vscode.Position;
55
inputPosition?: vscode.Position;
6-
outExamplePosition?: vscode.Position;
6+
outPosition?: vscode.Position;
77
}

src/stack/buildStack/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ export default async function buildStack({
3737
console.log('brief after extraction');
3838
console.log(brief);
3939

40-
const { input: inputString, inputValues} = jsonify(stackSnippet);
40+
const { in: inputString, inputValues} = jsonify(stackSnippet);
4141
console.log('input after JSONIFY');
4242
console.log(inputString);
4343
// console.log('output after JSONIFY');
44-
// console.log(outExample);
44+
// console.log(out);
4545
// Create a signature from the extracted parameters
4646
const signature = generateSignature(
4747
brief,

src/stack/createSkeleton/createSkeleton.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ export default async function placeholderStackwiseFunction(prompt: string): Prom
215215
const params = { prompt: 'Describe the colors in the image.' };
216216

217217
// Modified output object to have two keys
218-
const output = { outExample: 0 };
218+
const output = { out: 0 };
219219

220220
const signature = 'placeholderStackwiseFunction';
221221
const flatInput = 'prompt: string';

src/stack/createSkeleton/index2.ts

Whitespace-only changes.

src/stack/extractBrief/extractBrief.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ describe('extractParameters', () => {
55
const input = `stack(
66
"Create a method that takes a dictionary and some textCode in. It returns a methodName. The methodName should be picked based on the first key in the value that is present in the textCode. If that's the case, the value should be returned",
77
{
8-
input: {
8+
in: {
99
"dictionary": {
1010
"Use the chatCompletion endpoint from openai to return a response": "callOpenAI",
1111
"Find a good name for this method.": "pickMethodName",
1212
},
1313
textCode: isolatedFunction
1414
},
15-
outExample:{
15+
out:{
1616
"methodName": "callOpenAI"
1717
}
1818
},
@@ -26,8 +26,8 @@ describe('extractParameters', () => {
2626
});
2727
test('extracts parameters correctly from single quotes', () => {
2828
const input = `stack('test that\'s right', {
29-
input: { test: 'ok' },
30-
outExample: { test: 'ok' }
29+
in: { test: 'ok' },
30+
out: { test: 'ok' }
3131
})`;
3232
// Update the expected output to be an array of an array
3333
const expectedOutput = "test that's right";
@@ -36,7 +36,7 @@ describe('extractParameters', () => {
3636
});
3737
test('extracts parameters correctly from backticks', () => {
3838
const input =
39-
"stack(`checking here's backticks`, {\n input: { test: 'ok' },\n outExample: { test: 'ok' }\n })";
39+
"stack(`checking here's backticks`, {\n in: { test: 'ok' },\n out: { test: 'ok' }\n })";
4040
// Update the expected output to be an array of an array
4141
const expectedOutput = `checking here's backticks`;
4242
const result = extractBrief(input);

src/stack/flattenInputJson/flattenInputJson.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import flattenInputJson from '.';
22

33
test('flattenInputJson correctly', () => {
4-
const jsonInput = { prompt: 'string', test: 'string' };
4+
const jsonInput = {in:{ prompt: 'string', test: 'string' }};
55
const expectedOutput = `prompt: string, test: string`;
66

77
const result = flattenInputJson(jsonInput);
88
expect(result).toEqual(expectedOutput);
99
});
1010

1111
test('putting any when necessary', () => {
12-
const jsonInput = { prompt: { test: 'boolean', ok: 'boolean'}};
12+
const jsonInput = {in:{ prompt: { test: 'boolean', ok: 'boolean'}}};
1313
const expectedOutput = `prompt: any`;
1414

1515
const result = flattenInputJson(jsonInput);
1616
expect(result).toEqual(expectedOutput);
1717
});
1818

1919
test('putting any when necessary', () => {
20-
const jsonInput = { prompt: { test: 'boolean'}};
20+
const jsonInput = {in:{ prompt: { test: 'boolean'}}};
2121
const expectedOutput = `prompt: boolean`;
2222

2323
const result = flattenInputJson(jsonInput);

0 commit comments

Comments
 (0)