From 78dc36b9c59150a3cddb66940ad3a15b6e50c3dd Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Sun, 7 Jul 2024 16:50:55 -0400 Subject: [PATCH] update --- .gitignore | 4 + decode.csv | 13 - decode.txt | 14 - log.txt | 903 ------------------ output.txt | 12 - .../example.ql | 10 +- .../header-types.ql | 12 + .../target-types.ql | 12 + .../codeql-custom-queries-javascript/types.ql | 2 +- run.mjs | 2 +- run_exhaustive_retrieval_tests.sh | 4 +- run_starcoder_exhaustive_retrieval_tests.sh | 147 +++ run_starcoder_types_and_headers_tests.sh | 147 +++ run_starcoder_vector_retrieval_tests.sh | 147 +++ run_types_and_headers_tests.sh | 14 +- run_vector_retireval_tests.sh | 2 +- src/codeql.ts | 11 +- src/constants.ts | 38 +- src/core.ts | 4 +- src/index.ts | 2 +- src/main.ts | 35 +- src/starcoder-exhaustive-retrieval.mjs | 317 ++++++ src/starcoder-types-and-headers.mjs | 347 +++++++ src/starcoder-vector-retrieval.mjs | 327 +++++++ src/testrunner-core.mjs | 48 +- src/types-and-headers.mjs | 2 +- src/vector-retrieval.mjs | 24 +- starcoder_exhaustive_collate_data.sh | 132 +++ starcoder_vector_collate_data.sh | 132 +++ take_snapshot.sh | 35 + targets/booking/checkConsistency.ts | 10 + targets/booking/imports.ql | 11 + targets/booking/invokeDependencyError.ts | 13 + targets/booking/out.sarif | 688 +++++++++++++ targets/combined/vector_prelude.ts | 320 +++++++ targets/emojipaint/checkConsistency.ts | 6 + targets/passwords/checkConsistency.ts | 9 + targets/playlist/checkConsistency.ts | 4 + targets/starcoder-booking/checkConsistency.ts | 10 + targets/starcoder-booking/epilogue.js | 103 -- targets/starcoder-booking/prelude.js | 21 - targets/starcoder-booking/sketch.ts | 7 + targets/starcoder-booking/starcoder-sketch.ts | 4 + .../starcoder-emojipaint/checkConsistency.ts | 6 + targets/starcoder-emojipaint/epilogue.js | 108 --- targets/starcoder-emojipaint/prelude.js | 30 - targets/starcoder-emojipaint/sketch.ts | 7 + .../starcoder-emojipaint/starcoder-sketch.ts | 4 + .../starcoder-passwords/checkConsistency.ts | 9 + targets/starcoder-passwords/epilogue.js | 123 --- targets/starcoder-passwords/prelude.js | 79 -- targets/starcoder-passwords/sketch.ts | 7 + .../starcoder-passwords/starcoder-sketch.ts | 4 + .../starcoder-playlist/checkConsistency.ts | 4 + targets/starcoder-playlist/epilogue.js | 142 --- targets/starcoder-playlist/prelude.js | 11 - targets/starcoder-playlist/sketch.ts | 7 + .../starcoder-playlist/starcoder-sketch.ts | 4 + targets/starcoder-todo/checkConsistency.ts | 5 + targets/starcoder-todo/epilogue.js | 139 --- targets/starcoder-todo/prelude.js | 42 - targets/starcoder-todo/sketch.ts | 7 + targets/starcoder-todo/starcoder-sketch.ts | 4 + targets/todo/checkConsistency.ts | 5 + vector_collate_data.sh | 3 +- 65 files changed, 3040 insertions(+), 1815 deletions(-) delete mode 100644 decode.csv delete mode 100644 decode.txt delete mode 100644 log.txt delete mode 100644 output.txt create mode 100644 queries/codeql-custom-queries-javascript/header-types.ql create mode 100644 queries/codeql-custom-queries-javascript/target-types.ql create mode 100755 run_starcoder_exhaustive_retrieval_tests.sh create mode 100755 run_starcoder_types_and_headers_tests.sh create mode 100755 run_starcoder_vector_retrieval_tests.sh create mode 100644 src/starcoder-exhaustive-retrieval.mjs create mode 100644 src/starcoder-types-and-headers.mjs create mode 100644 src/starcoder-vector-retrieval.mjs create mode 100755 starcoder_exhaustive_collate_data.sh create mode 100644 starcoder_vector_collate_data.sh create mode 100755 take_snapshot.sh create mode 100644 targets/booking/checkConsistency.ts create mode 100644 targets/booking/imports.ql create mode 100644 targets/booking/invokeDependencyError.ts create mode 100644 targets/booking/out.sarif create mode 100644 targets/combined/vector_prelude.ts create mode 100644 targets/emojipaint/checkConsistency.ts create mode 100644 targets/passwords/checkConsistency.ts create mode 100644 targets/playlist/checkConsistency.ts create mode 100644 targets/starcoder-booking/checkConsistency.ts delete mode 100644 targets/starcoder-booking/epilogue.js delete mode 100644 targets/starcoder-booking/prelude.js create mode 100644 targets/starcoder-booking/sketch.ts create mode 100644 targets/starcoder-booking/starcoder-sketch.ts create mode 100644 targets/starcoder-emojipaint/checkConsistency.ts delete mode 100644 targets/starcoder-emojipaint/epilogue.js delete mode 100644 targets/starcoder-emojipaint/prelude.js create mode 100644 targets/starcoder-emojipaint/sketch.ts create mode 100644 targets/starcoder-emojipaint/starcoder-sketch.ts create mode 100644 targets/starcoder-passwords/checkConsistency.ts delete mode 100644 targets/starcoder-passwords/epilogue.js delete mode 100644 targets/starcoder-passwords/prelude.js create mode 100644 targets/starcoder-passwords/sketch.ts create mode 100644 targets/starcoder-passwords/starcoder-sketch.ts create mode 100644 targets/starcoder-playlist/checkConsistency.ts delete mode 100644 targets/starcoder-playlist/epilogue.js delete mode 100644 targets/starcoder-playlist/prelude.js create mode 100644 targets/starcoder-playlist/sketch.ts create mode 100644 targets/starcoder-playlist/starcoder-sketch.ts create mode 100644 targets/starcoder-todo/checkConsistency.ts delete mode 100644 targets/starcoder-todo/epilogue.js delete mode 100644 targets/starcoder-todo/prelude.js create mode 100644 targets/starcoder-todo/sketch.ts create mode 100644 targets/starcoder-todo/starcoder-sketch.ts create mode 100644 targets/todo/checkConsistency.ts diff --git a/.gitignore b/.gitignore index ea722cc..2bda759 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,7 @@ dist/ venv codeql *db +*types-and-headers/ +*vector-retrieval/ +*exhaustive-retrieval/ +targets/**/*.js diff --git a/decode.csv b/decode.csv deleted file mode 100644 index d756c92..0000000 --- a/decode.csv +++ /dev/null @@ -1,13 +0,0 @@ -"col0" -"type Weekday = ""M"" | ""T"" | ""W"" | ""R"" | ""F"";" -"type TimeOfDay = ""AM"" | ""PM"";" -"type Time = [Weekday, TimeOfDay];" -"type User = string;" -"type BookingID = number;" -"type Booking = [Time, User, BookingID];" -"type BookingFormData = [Time, User];" -"type Model = [BookingFormData, Booking[], BookingID];" -"type AddBooking = { type: ""AddBooking""; user: User; weekday: Weekday; timeOfDay: TimeOfDay };" -"type CancelBooking = { type: ""CancelBooking""; user: User; id: number };" -"type ClearBookings = { type: ""ClearBookings"" };" -"type Action = AddBooking | CancelBooking | ClearBookings;" diff --git a/decode.txt b/decode.txt deleted file mode 100644 index 8fb7b31..0000000 --- a/decode.txt +++ /dev/null @@ -1,14 +0,0 @@ -| col0 | -+-----------------------------------------------------------------------------------------------+ -| type Weekday = "M" | "T" | "W" | "R" | "F"; | -| type TimeOfDay = "AM" | "PM"; | -| type Time = [Weekday, TimeOfDay]; | -| type User = string; | -| type BookingID = number; | -| type Booking = [Time, User, BookingID]; | -| type BookingFormData = [Time, User]; | -| type Model = [BookingFormData, Booking[], BookingID]; | -| type AddBooking = { type: "AddBooking"; user: User; weekday: Weekday; timeOfDay: TimeOfDay }; | -| type CancelBooking = { type: "CancelBooking"; user: User; id: number }; | -| type ClearBookings = { type: "ClearBookings" }; | -| type Action = AddBooking | CancelBooking | ClearBookings; | diff --git a/log.txt b/log.txt deleted file mode 100644 index ced7877..0000000 --- a/log.txt +++ /dev/null @@ -1,903 +0,0 @@ -Content-Length: 245 - -{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Using Typescript version (bundled) 5.3.3 from path \"/home/jacob/.local/share/nvim/mason/packages/typescript-language-server/node_modules/typescript/lib/tsserver.js\""}}Content-Length: 1554 - -{"jsonrpc":"2.0","id":0,"result":{"capabilities":{"textDocumentSync":2,"completionProvider":{"triggerCharacters":[".","\"","'","/","@","<"],"resolveProvider":true},"codeActionProvider":true,"codeLensProvider":{"resolveProvider":true},"definitionProvider":true,"documentFormattingProvider":true,"documentRangeFormattingProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"executeCommandProvider":{"commands":["_typescript.applyWorkspaceEdit","_typescript.applyCodeAction","_typescript.applyRefactoring","_typescript.configurePlugin","_typescript.organizeImports","_typescript.applyRenameFile","_typescript.goToSourceDefinition"]},"hoverProvider":true,"inlayHintProvider":true,"linkedEditingRangeProvider":false,"renameProvider":true,"referencesProvider":true,"selectionRangeProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",",","<"],"retriggerCharacters":[")"]},"workspaceSymbolProvider":true,"implementationProvider":true,"typeDefinitionProvider":true,"foldingRangeProvider":true,"semanticTokensProvider":{"documentSelector":null,"legend":{"tokenTypes":["class","enum","interface","namespace","typeParameter","type","parameter","variable","enumMember","property","function","member"],"tokenModifiers":["declaration","static","async","readonly","defaultLibrary","local"]},"full":true,"range":true},"workspace":{"fileOperations":{"willRename":{"filters":[{"scheme":"file","pattern":{"glob":"**/*.{ts,js,jsx,tsx,mjs,mts,cjs,cts}","matches":"file"}},{"scheme":"file","pattern":{"glob":"**","matches":"folder"}}]}}}}}}Content-Length: 269 - -{"jsonrpc":"2.0","id":1,"result":{"contents":{"kind":"markdown","value":"\n```typescript\nfunction _<(model: Model, action: Action) => Model>(): (model: Model, action: Action) => Model\n```\n"},"range":{"start":{"line":5,"character":2},"end":{"line":5,"character":3}}}}Content-Length: 36 - -{"jsonrpc":"2.0","id":2,"result":[]}Content-Length: 36 - -{"jsonrpc":"2.0","id":3,"result":[]}Content-Length: 36 - -{"jsonrpc":"2.0","id":4,"result":[]}Content-Length: 4505 - -{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/epilogue.js","diagnostics":[{"range":{"start":{"line":42,"character":84},"end":{"line":42,"character":84}},"message":"Unterminated string literal.","severity":1,"code":1002,"source":"typescript"},{"range":{"start":{"line":43,"character":0},"end":{"line":43,"character":5}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":43,"character":5},"end":{"line":43,"character":5}},"message":"Unterminated string literal.","severity":1,"code":1002,"source":"typescript"},{"range":{"start":{"line":44,"character":4},"end":{"line":44,"character":9}},"message":"':' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":44,"character":10},"end":{"line":44,"character":11}},"message":"':' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":44,"character":52},"end":{"line":44,"character":53}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":45,"character":10},"end":{"line":45,"character":11}},"message":"':' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":45,"character":112},"end":{"line":45,"character":113}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":46,"character":11},"end":{"line":46,"character":12}},"message":"':' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":47,"character":140},"end":{"line":47,"character":140}},"message":"Unterminated string literal.","severity":1,"code":1002,"source":"typescript"},{"range":{"start":{"line":48,"character":0},"end":{"line":48,"character":21}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":48,"character":21},"end":{"line":48,"character":42}},"message":"':' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":48,"character":42},"end":{"line":48,"character":63}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":48,"character":63},"end":{"line":48,"character":65}},"message":"':' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":48,"character":65},"end":{"line":48,"character":65}},"message":"Unterminated string literal.","severity":1,"code":1002,"source":"typescript"},{"range":{"start":{"line":49,"character":8},"end":{"line":49,"character":14}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":49,"character":51},"end":{"line":49,"character":51}},"message":"Unterminated string literal.","severity":1,"code":1002,"source":"typescript"},{"range":{"start":{"line":50,"character":0},"end":{"line":50,"character":6}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":50,"character":6},"end":{"line":50,"character":10}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":50,"character":10},"end":{"line":50,"character":14}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":50,"character":14},"end":{"line":50,"character":19}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":50,"character":19},"end":{"line":50,"character":19}},"message":"Unterminated string literal.","severity":1,"code":1002,"source":"typescript"},{"range":{"start":{"line":51,"character":4},"end":{"line":51,"character":5}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":51,"character":5},"end":{"line":51,"character":6}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":52,"character":1},"end":{"line":52,"character":2}},"message":"')' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":110,"character":50},"end":{"line":110,"character":50}},"message":"'}' expected.","severity":1,"code":1005,"source":"typescript","relatedInformation":[{"location":{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/epilogue.js","range":{"start":{"line":41,"character":20},"end":{"line":41,"character":21}}},"message":"The parser expected to find a '}' to match the '{' token here."}]}]}}Content-Length: 36 - -{"jsonrpc":"2.0","id":5,"result":[]}Content-Length: 36 - -{"jsonrpc":"2.0","id":6,"result":[]}Content-Length: 36 - -{"jsonrpc":"2.0","id":7,"result":[]}Content-Length: 36 - -{"jsonrpc":"2.0","id":8,"result":[]}Content-Length: 36 - -{"jsonrpc":"2.0","id":9,"result":[]}Content-Length: 197 - -{"jsonrpc":"2.0","id":10,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":7,"character":5},"end":{"line":7,"character":10}}}]}Content-Length: 214 - -{"jsonrpc":"2.0","id":11,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Model = [Grid, string, string[]]\n```\n"},"range":{"start":{"line":7,"character":5},"end":{"line":7,"character":10}}}}Content-Length: 37 - -{"jsonrpc":"2.0","id":12,"result":[]}Content-Length: 37 - -{"jsonrpc":"2.0","id":13,"result":[]}Content-Length: 196 - -{"jsonrpc":"2.0","id":14,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":5,"character":5},"end":{"line":5,"character":9}}}]}Content-Length: 198 - -{"jsonrpc":"2.0","id":15,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Grid = string[][]\n```\n"},"range":{"start":{"line":5,"character":5},"end":{"line":5,"character":9}}}}Content-Length: 37 - -{"jsonrpc":"2.0","id":16,"result":[]}Content-Length: 197 - -{"jsonrpc":"2.0","id":17,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}]}Content-Length: 196 - -{"jsonrpc":"2.0","id":18,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Emoji = string\n```\n"},"range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}}Content-Length: 37 - -{"jsonrpc":"2.0","id":19,"result":[]}Content-Length: 37 - -{"jsonrpc":"2.0","id":20,"result":[]}Content-Length: 37 - -{"jsonrpc":"2.0","id":21,"result":[]}Content-Length: 37 - -{"jsonrpc":"2.0","id":22,"result":[]}Content-Length: 37 - -{"jsonrpc":"2.0","id":23,"result":[]}Content-Length: 37 - -{"jsonrpc":"2.0","id":24,"result":[]}Content-Length: 197 - -{"jsonrpc":"2.0","id":25,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}]}Content-Length: 196 - -{"jsonrpc":"2.0","id":26,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Emoji = string\n```\n"},"range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":27,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}]}Content-Length: 196 - -{"jsonrpc":"2.0","id":28,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Emoji = string\n```\n"},"range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":29,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}]}Content-Length: 196 - -{"jsonrpc":"2.0","id":30,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Emoji = string\n```\n"},"range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":31,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}]}Content-Length: 196 - -{"jsonrpc":"2.0","id":32,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Emoji = string\n```\n"},"range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":33,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}]}Content-Length: 196 - -{"jsonrpc":"2.0","id":34,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Emoji = string\n```\n"},"range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}}Content-Length: 37 - -{"jsonrpc":"2.0","id":35,"result":[]}Content-Length: 37 - -{"jsonrpc":"2.0","id":36,"result":[]}Content-Length: 37 - -{"jsonrpc":"2.0","id":37,"result":[]}Content-Length: 196 - -{"jsonrpc":"2.0","id":38,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":5,"character":5},"end":{"line":5,"character":9}}}]}Content-Length: 198 - -{"jsonrpc":"2.0","id":39,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Grid = string[][]\n```\n"},"range":{"start":{"line":5,"character":5},"end":{"line":5,"character":9}}}}Content-Length: 196 - -{"jsonrpc":"2.0","id":40,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":5,"character":5},"end":{"line":5,"character":9}}}]}Content-Length: 198 - -{"jsonrpc":"2.0","id":41,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Grid = string[][]\n```\n"},"range":{"start":{"line":5,"character":5},"end":{"line":5,"character":9}}}}Content-Length: 196 - -{"jsonrpc":"2.0","id":42,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":5,"character":5},"end":{"line":5,"character":9}}}]}Content-Length: 198 - -{"jsonrpc":"2.0","id":43,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Grid = string[][]\n```\n"},"range":{"start":{"line":5,"character":5},"end":{"line":5,"character":9}}}}Content-Length: 196 - -{"jsonrpc":"2.0","id":44,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":5,"character":5},"end":{"line":5,"character":9}}}]}Content-Length: 198 - -{"jsonrpc":"2.0","id":45,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Grid = string[][]\n```\n"},"range":{"start":{"line":5,"character":5},"end":{"line":5,"character":9}}}}Content-Length: 37 - -{"jsonrpc":"2.0","id":46,"result":[]}Content-Length: 197 - -{"jsonrpc":"2.0","id":47,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}]}Content-Length: 196 - -{"jsonrpc":"2.0","id":48,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Emoji = string\n```\n"},"range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":49,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}]}Content-Length: 196 - -{"jsonrpc":"2.0","id":50,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Emoji = string\n```\n"},"range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":51,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}]}Content-Length: 196 - -{"jsonrpc":"2.0","id":52,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Emoji = string\n```\n"},"range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":53,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}]}Content-Length: 196 - -{"jsonrpc":"2.0","id":54,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Emoji = string\n```\n"},"range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":55,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}]}Content-Length: 196 - -{"jsonrpc":"2.0","id":56,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Emoji = string\n```\n"},"range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":57,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}]}Content-Length: 196 - -{"jsonrpc":"2.0","id":58,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Emoji = string\n```\n"},"range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}}Content-Length: 37 - -{"jsonrpc":"2.0","id":59,"result":[]}Content-Length: 197 - -{"jsonrpc":"2.0","id":60,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}]}Content-Length: 196 - -{"jsonrpc":"2.0","id":61,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Emoji = string\n```\n"},"range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":62,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}]}Content-Length: 196 - -{"jsonrpc":"2.0","id":63,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Emoji = string\n```\n"},"range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":64,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}]}Content-Length: 196 - -{"jsonrpc":"2.0","id":65,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Emoji = string\n```\n"},"range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":66,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}]}Content-Length: 196 - -{"jsonrpc":"2.0","id":67,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Emoji = string\n```\n"},"range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":68,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}]}Content-Length: 196 - -{"jsonrpc":"2.0","id":69,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Emoji = string\n```\n"},"range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":70,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}]}Content-Length: 196 - -{"jsonrpc":"2.0","id":71,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Emoji = string\n```\n"},"range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}}Content-Length: 37 - -{"jsonrpc":"2.0","id":72,"result":[]}Content-Length: 37 - -{"jsonrpc":"2.0","id":73,"result":[]}Content-Length: 37 - -{"jsonrpc":"2.0","id":74,"result":[]}Content-Length: 197 - -{"jsonrpc":"2.0","id":75,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":7,"character":5},"end":{"line":7,"character":10}}}]}Content-Length: 214 - -{"jsonrpc":"2.0","id":76,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Model = [Grid, string, string[]]\n```\n"},"range":{"start":{"line":7,"character":5},"end":{"line":7,"character":10}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":77,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":7,"character":5},"end":{"line":7,"character":10}}}]}Content-Length: 214 - -{"jsonrpc":"2.0","id":78,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Model = [Grid, string, string[]]\n```\n"},"range":{"start":{"line":7,"character":5},"end":{"line":7,"character":10}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":79,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":7,"character":5},"end":{"line":7,"character":10}}}]}Content-Length: 214 - -{"jsonrpc":"2.0","id":80,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Model = [Grid, string, string[]]\n```\n"},"range":{"start":{"line":7,"character":5},"end":{"line":7,"character":10}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":81,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":7,"character":5},"end":{"line":7,"character":10}}}]}Content-Length: 214 - -{"jsonrpc":"2.0","id":82,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Model = [Grid, string, string[]]\n```\n"},"range":{"start":{"line":7,"character":5},"end":{"line":7,"character":10}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":83,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":7,"character":5},"end":{"line":7,"character":10}}}]}Content-Length: 214 - -{"jsonrpc":"2.0","id":84,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Model = [Grid, string, string[]]\n```\n"},"range":{"start":{"line":7,"character":5},"end":{"line":7,"character":10}}}}Content-Length: 37 - -{"jsonrpc":"2.0","id":85,"result":[]}Content-Length: 854 - -{"jsonrpc":"2.0","id":86,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":9,"character":19},"end":{"line":9,"character":56}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":10,"character":18},"end":{"line":10,"character":60}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":11,"character":17},"end":{"line":11,"character":58}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":12,"character":17},"end":{"line":12,"character":38}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":13,"character":15},"end":{"line":13,"character":44}}}]}Content-Length: 8922 - -{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/epilogue.js","diagnostics":[{"range":{"start":{"line":42,"character":84},"end":{"line":42,"character":84}},"message":"Unterminated string literal.","severity":1,"code":1002,"source":"typescript"},{"range":{"start":{"line":43,"character":0},"end":{"line":43,"character":5}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":43,"character":5},"end":{"line":43,"character":5}},"message":"Unterminated string literal.","severity":1,"code":1002,"source":"typescript"},{"range":{"start":{"line":44,"character":4},"end":{"line":44,"character":9}},"message":"':' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":44,"character":10},"end":{"line":44,"character":11}},"message":"':' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":44,"character":52},"end":{"line":44,"character":53}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":45,"character":10},"end":{"line":45,"character":11}},"message":"':' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":45,"character":112},"end":{"line":45,"character":113}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":46,"character":11},"end":{"line":46,"character":12}},"message":"':' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":47,"character":140},"end":{"line":47,"character":140}},"message":"Unterminated string literal.","severity":1,"code":1002,"source":"typescript"},{"range":{"start":{"line":48,"character":0},"end":{"line":48,"character":21}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":48,"character":21},"end":{"line":48,"character":42}},"message":"':' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":48,"character":42},"end":{"line":48,"character":63}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":48,"character":63},"end":{"line":48,"character":65}},"message":"':' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":48,"character":65},"end":{"line":48,"character":65}},"message":"Unterminated string literal.","severity":1,"code":1002,"source":"typescript"},{"range":{"start":{"line":49,"character":8},"end":{"line":49,"character":14}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":49,"character":51},"end":{"line":49,"character":51}},"message":"Unterminated string literal.","severity":1,"code":1002,"source":"typescript"},{"range":{"start":{"line":50,"character":0},"end":{"line":50,"character":6}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":50,"character":6},"end":{"line":50,"character":10}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":50,"character":10},"end":{"line":50,"character":14}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":50,"character":14},"end":{"line":50,"character":19}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":50,"character":19},"end":{"line":50,"character":19}},"message":"Unterminated string literal.","severity":1,"code":1002,"source":"typescript"},{"range":{"start":{"line":51,"character":4},"end":{"line":51,"character":5}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":51,"character":5},"end":{"line":51,"character":6}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":52,"character":1},"end":{"line":52,"character":2}},"message":"')' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":110,"character":50},"end":{"line":110,"character":50}},"message":"'}' expected.","severity":1,"code":1005,"source":"typescript","relatedInformation":[{"location":{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/epilogue.js","range":{"start":{"line":41,"character":20},"end":{"line":41,"character":21}}},"message":"The parser expected to find a '}' to match the '{' token here."}]},{"range":{"start":{"line":43,"character":0},"end":{"line":43,"character":5}},"message":"Object literal may only specify known properties, and '\" });' does not exist in type 'SelectEmoji'.","severity":1,"code":2353,"source":"typescript"},{"range":{"start":{"line":44,"character":11},"end":{"line":44,"character":20}},"message":"Cannot find name 'grid_init'.","severity":1,"code":2304,"source":"typescript"},{"range":{"start":{"line":44,"character":24},"end":{"line":44,"character":38}},"message":"Cannot find name 'emojiList_init'.","severity":1,"code":2304,"source":"typescript"},{"range":{"start":{"line":45,"character":11},"end":{"line":45,"character":15}},"message":"Cannot find name 'grid'.","severity":1,"code":2304,"source":"typescript"},{"range":{"start":{"line":45,"character":30},"end":{"line":45,"character":39}},"message":"Cannot find name 'grid_init'.","severity":1,"code":2304,"source":"typescript"},{"range":{"start":{"line":45,"character":41},"end":{"line":45,"character":54}},"message":"Block-scoped variable 'selectedEmoji' used before its declaration.","severity":1,"code":2448,"source":"typescript","relatedInformation":[{"location":{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/epilogue.js","range":{"start":{"line":42,"character":13},"end":{"line":42,"character":26}}},"message":"'selectedEmoji' is declared here."}]},{"range":{"start":{"line":45,"character":41},"end":{"line":45,"character":54}},"message":"Variable 'selectedEmoji' is used before being assigned.","severity":1,"code":2454,"source":"typescript"},{"range":{"start":{"line":45,"character":56},"end":{"line":45,"character":70}},"message":"Cannot find name 'emojiList_init'.","severity":1,"code":2304,"source":"typescript"},{"range":{"start":{"line":47,"character":16},"end":{"line":47,"character":20}},"message":"Cannot find name 'grid'.","severity":1,"code":2304,"source":"typescript"},{"range":{"start":{"line":47,"character":37},"end":{"line":47,"character":41}},"message":"Cannot find name 'grid'.","severity":1,"code":2304,"source":"typescript"},{"range":{"start":{"line":47,"character":58},"end":{"line":47,"character":62}},"message":"Cannot find name 'grid'.","severity":1,"code":2304,"source":"typescript"},{"range":{"start":{"line":47,"character":79},"end":{"line":47,"character":83}},"message":"Cannot find name 'grid'.","severity":1,"code":2304,"source":"typescript"},{"range":{"start":{"line":47,"character":100},"end":{"line":47,"character":104}},"message":"Cannot find name 'grid'.","severity":1,"code":2304,"source":"typescript"},{"range":{"start":{"line":47,"character":121},"end":{"line":47,"character":125}},"message":"Cannot find name 'grid'.","severity":1,"code":2304,"source":"typescript"},{"range":{"start":{"line":49,"character":17},"end":{"line":49,"character":21}},"message":"Cannot find name 'grid'.","severity":1,"code":2304,"source":"typescript"},{"range":{"start":{"line":101,"character":27},"end":{"line":101,"character":33}},"message":"Property 'result' does not exist on type 'void'.","severity":1,"code":2339,"source":"typescript"},{"range":{"start":{"line":101,"character":74},"end":{"line":101,"character":80}},"message":"Property 'values' does not exist on type 'void'.","severity":1,"code":2339,"source":"typescript"},{"range":{"start":{"line":102,"character":16},"end":{"line":102,"character":22}},"message":"Property 'result' does not exist on type 'void'.","severity":1,"code":2339,"source":"typescript"},{"range":{"start":{"line":54,"character":13},"end":{"line":54,"character":26}},"message":"'selectedEmoji' is declared but its value is never read.","severity":4,"code":6133,"source":"typescript"},{"range":{"start":{"line":54,"character":28},"end":{"line":54,"character":37}},"message":"'emojiList' is declared but its value is never read.","severity":4,"code":6133,"source":"typescript"},{"range":{"start":{"line":73,"character":11},"end":{"line":73,"character":20}},"message":"'grid_init' is declared but its value is never read.","severity":4,"code":6133,"source":"typescript"},{"range":{"start":{"line":86,"character":11},"end":{"line":86,"character":15}},"message":"'grid' is declared but its value is never read.","severity":4,"code":6133,"source":"typescript"},{"range":{"start":{"line":86,"character":19},"end":{"line":86,"character":28}},"message":"'emojiList' is declared but its value is never read.","severity":4,"code":6133,"source":"typescript"}]}}Content-Length: 39 - -{"jsonrpc":"2.0","id":87,"result":null}Content-Length: 854 - -{"jsonrpc":"2.0","id":88,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":9,"character":19},"end":{"line":9,"character":56}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":10,"character":18},"end":{"line":10,"character":60}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":11,"character":17},"end":{"line":11,"character":58}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":12,"character":17},"end":{"line":12,"character":38}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":13,"character":15},"end":{"line":13,"character":44}}}]}Content-Length: 39 - -{"jsonrpc":"2.0","id":89,"result":null}Content-Length: 854 - -{"jsonrpc":"2.0","id":90,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":9,"character":19},"end":{"line":9,"character":56}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":10,"character":18},"end":{"line":10,"character":60}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":11,"character":17},"end":{"line":11,"character":58}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":12,"character":17},"end":{"line":12,"character":38}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":13,"character":15},"end":{"line":13,"character":44}}}]}Content-Length: 39 - -{"jsonrpc":"2.0","id":91,"result":null}Content-Length: 854 - -{"jsonrpc":"2.0","id":92,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":9,"character":19},"end":{"line":9,"character":56}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":10,"character":18},"end":{"line":10,"character":60}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":11,"character":17},"end":{"line":11,"character":58}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":12,"character":17},"end":{"line":12,"character":38}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":13,"character":15},"end":{"line":13,"character":44}}}]}Content-Length: 39 - -{"jsonrpc":"2.0","id":93,"result":null}Content-Length: 854 - -{"jsonrpc":"2.0","id":94,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":9,"character":19},"end":{"line":9,"character":56}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":10,"character":18},"end":{"line":10,"character":60}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":11,"character":17},"end":{"line":11,"character":58}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":12,"character":17},"end":{"line":12,"character":38}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":13,"character":15},"end":{"line":13,"character":44}}}]}Content-Length: 39 - -{"jsonrpc":"2.0","id":95,"result":null}Content-Length: 854 - -{"jsonrpc":"2.0","id":96,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":9,"character":19},"end":{"line":9,"character":56}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":10,"character":18},"end":{"line":10,"character":60}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":11,"character":17},"end":{"line":11,"character":58}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":12,"character":17},"end":{"line":12,"character":38}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":13,"character":15},"end":{"line":13,"character":44}}}]}Content-Length: 39 - -{"jsonrpc":"2.0","id":97,"result":null}Content-Length: 854 - -{"jsonrpc":"2.0","id":98,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":9,"character":19},"end":{"line":9,"character":56}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":10,"character":18},"end":{"line":10,"character":60}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":11,"character":17},"end":{"line":11,"character":58}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":12,"character":17},"end":{"line":12,"character":38}}},{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":13,"character":15},"end":{"line":13,"character":44}}}]}Content-Length: 39 - -{"jsonrpc":"2.0","id":99,"result":null}Content-Length: 38 - -{"jsonrpc":"2.0","id":100,"result":[]}Content-Length: 200 - -{"jsonrpc":"2.0","id":101,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":15,"character":5},"end":{"line":15,"character":11}}}]}Content-Length: 252 - -{"jsonrpc":"2.0","id":102,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Action = SelectEmoji | StampEmoji | ClearCell | ClearGrid | FillRow\n```\n"},"range":{"start":{"line":15,"character":5},"end":{"line":15,"character":11}}}}Content-Length: 38 - -{"jsonrpc":"2.0","id":103,"result":[]}Content-Length: 198 - -{"jsonrpc":"2.0","id":104,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":9,"character":5},"end":{"line":9,"character":16}}}]}Content-Length: 248 - -{"jsonrpc":"2.0","id":105,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype SelectEmoji = {\n type: \"SelectEmoji\";\n emoji: Emoji;\n}\n```\n"},"range":{"start":{"line":9,"character":5},"end":{"line":9,"character":16}}}}Content-Length: 38 - -{"jsonrpc":"2.0","id":106,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":107,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":108,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":109,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":110,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":111,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":112,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":113,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":114,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":115,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":116,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":117,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":118,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":119,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":120,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":121,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":122,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":123,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":124,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":125,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":126,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":127,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":128,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":129,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":130,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":131,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":132,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":133,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":134,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":135,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":136,"result":[]}Content-Length: 198 - -{"jsonrpc":"2.0","id":137,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}]}Content-Length: 197 - -{"jsonrpc":"2.0","id":138,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Emoji = string\n```\n"},"range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}}Content-Length: 198 - -{"jsonrpc":"2.0","id":139,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}]}Content-Length: 197 - -{"jsonrpc":"2.0","id":140,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Emoji = string\n```\n"},"range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}}Content-Length: 198 - -{"jsonrpc":"2.0","id":141,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}]}Content-Length: 197 - -{"jsonrpc":"2.0","id":142,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Emoji = string\n```\n"},"range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}}Content-Length: 198 - -{"jsonrpc":"2.0","id":143,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}]}Content-Length: 197 - -{"jsonrpc":"2.0","id":144,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Emoji = string\n```\n"},"range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}}Content-Length: 198 - -{"jsonrpc":"2.0","id":145,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}]}Content-Length: 197 - -{"jsonrpc":"2.0","id":146,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Emoji = string\n```\n"},"range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}}Content-Length: 198 - -{"jsonrpc":"2.0","id":147,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}]}Content-Length: 197 - -{"jsonrpc":"2.0","id":148,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Emoji = string\n```\n"},"range":{"start":{"line":2,"character":5},"end":{"line":2,"character":10}}}}Content-Length: 198 - -{"jsonrpc":"2.0","id":149,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":9,"character":5},"end":{"line":9,"character":16}}}]}Content-Length: 248 - -{"jsonrpc":"2.0","id":150,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype SelectEmoji = {\n type: \"SelectEmoji\";\n emoji: Emoji;\n}\n```\n"},"range":{"start":{"line":9,"character":5},"end":{"line":9,"character":16}}}}Content-Length: 198 - -{"jsonrpc":"2.0","id":151,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":9,"character":5},"end":{"line":9,"character":16}}}]}Content-Length: 248 - -{"jsonrpc":"2.0","id":152,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype SelectEmoji = {\n type: \"SelectEmoji\";\n emoji: Emoji;\n}\n```\n"},"range":{"start":{"line":9,"character":5},"end":{"line":9,"character":16}}}}Content-Length: 198 - -{"jsonrpc":"2.0","id":153,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":9,"character":5},"end":{"line":9,"character":16}}}]}Content-Length: 248 - -{"jsonrpc":"2.0","id":154,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype SelectEmoji = {\n type: \"SelectEmoji\";\n emoji: Emoji;\n}\n```\n"},"range":{"start":{"line":9,"character":5},"end":{"line":9,"character":16}}}}Content-Length: 198 - -{"jsonrpc":"2.0","id":155,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":9,"character":5},"end":{"line":9,"character":16}}}]}Content-Length: 248 - -{"jsonrpc":"2.0","id":156,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype SelectEmoji = {\n type: \"SelectEmoji\";\n emoji: Emoji;\n}\n```\n"},"range":{"start":{"line":9,"character":5},"end":{"line":9,"character":16}}}}Content-Length: 198 - -{"jsonrpc":"2.0","id":157,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":9,"character":5},"end":{"line":9,"character":16}}}]}Content-Length: 248 - -{"jsonrpc":"2.0","id":158,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype SelectEmoji = {\n type: \"SelectEmoji\";\n emoji: Emoji;\n}\n```\n"},"range":{"start":{"line":9,"character":5},"end":{"line":9,"character":16}}}}Content-Length: 198 - -{"jsonrpc":"2.0","id":159,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":9,"character":5},"end":{"line":9,"character":16}}}]}Content-Length: 248 - -{"jsonrpc":"2.0","id":160,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype SelectEmoji = {\n type: \"SelectEmoji\";\n emoji: Emoji;\n}\n```\n"},"range":{"start":{"line":9,"character":5},"end":{"line":9,"character":16}}}}Content-Length: 198 - -{"jsonrpc":"2.0","id":161,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":9,"character":5},"end":{"line":9,"character":16}}}]}Content-Length: 248 - -{"jsonrpc":"2.0","id":162,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype SelectEmoji = {\n type: \"SelectEmoji\";\n emoji: Emoji;\n}\n```\n"},"range":{"start":{"line":9,"character":5},"end":{"line":9,"character":16}}}}Content-Length: 198 - -{"jsonrpc":"2.0","id":163,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":9,"character":5},"end":{"line":9,"character":16}}}]}Content-Length: 248 - -{"jsonrpc":"2.0","id":164,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype SelectEmoji = {\n type: \"SelectEmoji\";\n emoji: Emoji;\n}\n```\n"},"range":{"start":{"line":9,"character":5},"end":{"line":9,"character":16}}}}Content-Length: 198 - -{"jsonrpc":"2.0","id":165,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":9,"character":5},"end":{"line":9,"character":16}}}]}Content-Length: 8575 - -{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/epilogue.ts","diagnostics":[{"range":{"start":{"line":48,"character":82},"end":{"line":48,"character":82}},"message":"Unterminated string literal.","severity":1,"code":1002,"source":"typescript"},{"range":{"start":{"line":49,"character":0},"end":{"line":49,"character":5}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":49,"character":5},"end":{"line":49,"character":5}},"message":"Unterminated string literal.","severity":1,"code":1002,"source":"typescript"},{"range":{"start":{"line":50,"character":2},"end":{"line":50,"character":7}},"message":"':' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":50,"character":8},"end":{"line":50,"character":9}},"message":"':' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":50,"character":50},"end":{"line":50,"character":51}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":51,"character":8},"end":{"line":51,"character":9}},"message":"':' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":51,"character":110},"end":{"line":51,"character":111}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":52,"character":9},"end":{"line":52,"character":10}},"message":"':' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":53,"character":136},"end":{"line":53,"character":136}},"message":"Unterminated string literal.","severity":1,"code":1002,"source":"typescript"},{"range":{"start":{"line":54,"character":0},"end":{"line":54,"character":21}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":54,"character":21},"end":{"line":54,"character":42}},"message":"':' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":54,"character":42},"end":{"line":54,"character":63}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":54,"character":63},"end":{"line":54,"character":65}},"message":"':' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":54,"character":65},"end":{"line":54,"character":65}},"message":"Unterminated string literal.","severity":1,"code":1002,"source":"typescript"},{"range":{"start":{"line":55,"character":4},"end":{"line":55,"character":10}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":55,"character":47},"end":{"line":55,"character":47}},"message":"Unterminated string literal.","severity":1,"code":1002,"source":"typescript"},{"range":{"start":{"line":56,"character":0},"end":{"line":56,"character":6}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":56,"character":6},"end":{"line":56,"character":10}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":56,"character":10},"end":{"line":56,"character":14}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":56,"character":14},"end":{"line":56,"character":19}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":56,"character":19},"end":{"line":56,"character":19}},"message":"Unterminated string literal.","severity":1,"code":1002,"source":"typescript"},{"range":{"start":{"line":57,"character":2},"end":{"line":57,"character":3}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":57,"character":3},"end":{"line":57,"character":4}},"message":"',' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":58,"character":1},"end":{"line":58,"character":2}},"message":"')' expected.","severity":1,"code":1005,"source":"typescript"},{"range":{"start":{"line":122,"character":50},"end":{"line":122,"character":50}},"message":"'}' expected.","severity":1,"code":1005,"source":"typescript","relatedInformation":[{"location":{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/epilogue.ts","range":{"start":{"line":47,"character":56},"end":{"line":47,"character":57}}},"message":"The parser expected to find a '}' to match the '{' token here."}]},{"range":{"start":{"line":47,"character":18},"end":{"line":47,"character":52}},"message":"A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value.","severity":1,"code":2355,"source":"typescript"},{"range":{"start":{"line":49,"character":0},"end":{"line":49,"character":5}},"message":"Object literal may only specify known properties, and '\" });' does not exist in type 'SelectEmoji'.","severity":1,"code":2353,"source":"typescript"},{"range":{"start":{"line":50,"character":9},"end":{"line":50,"character":18}},"message":"Cannot find name 'grid_init'.","severity":1,"code":2304,"source":"typescript"},{"range":{"start":{"line":50,"character":22},"end":{"line":50,"character":36}},"message":"Cannot find name 'emojiList_init'.","severity":1,"code":2304,"source":"typescript"},{"range":{"start":{"line":51,"character":9},"end":{"line":51,"character":13}},"message":"Cannot find name 'grid'.","severity":1,"code":2304,"source":"typescript"},{"range":{"start":{"line":51,"character":28},"end":{"line":51,"character":37}},"message":"Cannot find name 'grid_init'.","severity":1,"code":2304,"source":"typescript"},{"range":{"start":{"line":51,"character":39},"end":{"line":51,"character":52}},"message":"Block-scoped variable 'selectedEmoji' used before its declaration.","severity":1,"code":2448,"source":"typescript","relatedInformation":[{"location":{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/epilogue.ts","range":{"start":{"line":48,"character":11},"end":{"line":48,"character":24}}},"message":"'selectedEmoji' is declared here."}]},{"range":{"start":{"line":51,"character":39},"end":{"line":51,"character":52}},"message":"Variable 'selectedEmoji' is used before being assigned.","severity":1,"code":2454,"source":"typescript"},{"range":{"start":{"line":51,"character":54},"end":{"line":51,"character":68}},"message":"Cannot find name 'emojiList_init'.","severity":1,"code":2304,"source":"typescript"},{"range":{"start":{"line":53,"character":12},"end":{"line":53,"character":16}},"message":"Cannot find name 'grid'.","severity":1,"code":2304,"source":"typescript"},{"range":{"start":{"line":53,"character":33},"end":{"line":53,"character":37}},"message":"Cannot find name 'grid'.","severity":1,"code":2304,"source":"typescript"},{"range":{"start":{"line":53,"character":54},"end":{"line":53,"character":58}},"message":"Cannot find name 'grid'.","severity":1,"code":2304,"source":"typescript"},{"range":{"start":{"line":53,"character":75},"end":{"line":53,"character":79}},"message":"Cannot find name 'grid'.","severity":1,"code":2304,"source":"typescript"},{"range":{"start":{"line":53,"character":96},"end":{"line":53,"character":100}},"message":"Cannot find name 'grid'.","severity":1,"code":2304,"source":"typescript"},{"range":{"start":{"line":53,"character":117},"end":{"line":53,"character":121}},"message":"Cannot find name 'grid'.","severity":1,"code":2304,"source":"typescript"},{"range":{"start":{"line":55,"character":13},"end":{"line":55,"character":17}},"message":"Cannot find name 'grid'.","severity":1,"code":2304,"source":"typescript"},{"range":{"start":{"line":61,"character":11},"end":{"line":61,"character":24}},"message":"'selectedEmoji' is declared but its value is never read.","severity":4,"code":6133,"source":"typescript"},{"range":{"start":{"line":61,"character":26},"end":{"line":61,"character":35}},"message":"'emojiList' is declared but its value is never read.","severity":4,"code":6133,"source":"typescript"},{"range":{"start":{"line":82,"character":9},"end":{"line":82,"character":18}},"message":"'grid_init' is declared but its value is never read.","severity":4,"code":6133,"source":"typescript"},{"range":{"start":{"line":96,"character":9},"end":{"line":96,"character":13}},"message":"'grid' is declared but its value is never read.","severity":4,"code":6133,"source":"typescript"},{"range":{"start":{"line":96,"character":17},"end":{"line":96,"character":26}},"message":"'emojiList' is declared but its value is never read.","severity":4,"code":6133,"source":"typescript"}]}}Content-Length: 248 - -{"jsonrpc":"2.0","id":166,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype SelectEmoji = {\n type: \"SelectEmoji\";\n emoji: Emoji;\n}\n```\n"},"range":{"start":{"line":9,"character":5},"end":{"line":9,"character":16}}}}Content-Length: 198 - -{"jsonrpc":"2.0","id":167,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":9,"character":5},"end":{"line":9,"character":16}}}]}Content-Length: 248 - -{"jsonrpc":"2.0","id":168,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype SelectEmoji = {\n type: \"SelectEmoji\";\n emoji: Emoji;\n}\n```\n"},"range":{"start":{"line":9,"character":5},"end":{"line":9,"character":16}}}}Content-Length: 198 - -{"jsonrpc":"2.0","id":169,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":9,"character":5},"end":{"line":9,"character":16}}}]}Content-Length: 248 - -{"jsonrpc":"2.0","id":170,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype SelectEmoji = {\n type: \"SelectEmoji\";\n emoji: Emoji;\n}\n```\n"},"range":{"start":{"line":9,"character":5},"end":{"line":9,"character":16}}}}Content-Length: 338 - -{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/injected_sketch.js","diagnostics":[{"range":{"start":{"line":1,"character":15},"end":{"line":1,"character":16}},"message":"Cannot find name '_'.","severity":1,"code":2304,"source":"typescript"}]}}Content-Length: 38 - -{"jsonrpc":"2.0","id":171,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":172,"result":[]}Content-Length: 200 - -{"jsonrpc":"2.0","id":173,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":10,"character":5},"end":{"line":10,"character":15}}}]}Content-Length: 259 - -{"jsonrpc":"2.0","id":174,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype StampEmoji = {\n type: \"StampEmoji\";\n row: Row;\n col: Col;\n}\n```\n"},"range":{"start":{"line":10,"character":5},"end":{"line":10,"character":15}}}}Content-Length: 38 - -{"jsonrpc":"2.0","id":175,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":176,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":177,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":178,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":179,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":180,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":181,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":182,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":183,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":184,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":185,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":186,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":187,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":188,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":189,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":190,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":191,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":192,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":193,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":194,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":195,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":196,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":197,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":198,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":199,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":200,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":201,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":202,"result":[]}Content-Length: 197 - -{"jsonrpc":"2.0","id":203,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}]}Content-Length: 194 - -{"jsonrpc":"2.0","id":204,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Row = number\n```\n"},"range":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}}Content-Length: 38 - -{"jsonrpc":"2.0","id":205,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":206,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":207,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":208,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":209,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":210,"result":[]}Content-Length: 197 - -{"jsonrpc":"2.0","id":211,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}]}Content-Length: 194 - -{"jsonrpc":"2.0","id":212,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Row = number\n```\n"},"range":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":213,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}]}Content-Length: 194 - -{"jsonrpc":"2.0","id":214,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Row = number\n```\n"},"range":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":215,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}]}Content-Length: 194 - -{"jsonrpc":"2.0","id":216,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Row = number\n```\n"},"range":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}}Content-Length: 38 - -{"jsonrpc":"2.0","id":217,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":218,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":219,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":220,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":221,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":222,"result":[]}Content-Length: 197 - -{"jsonrpc":"2.0","id":223,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":4,"character":5},"end":{"line":4,"character":8}}}]}Content-Length: 194 - -{"jsonrpc":"2.0","id":224,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Col = number\n```\n"},"range":{"start":{"line":4,"character":5},"end":{"line":4,"character":8}}}}Content-Length: 38 - -{"jsonrpc":"2.0","id":225,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":226,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":227,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":228,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":229,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":230,"result":[]}Content-Length: 197 - -{"jsonrpc":"2.0","id":231,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":4,"character":5},"end":{"line":4,"character":8}}}]}Content-Length: 194 - -{"jsonrpc":"2.0","id":232,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Col = number\n```\n"},"range":{"start":{"line":4,"character":5},"end":{"line":4,"character":8}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":233,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":4,"character":5},"end":{"line":4,"character":8}}}]}Content-Length: 194 - -{"jsonrpc":"2.0","id":234,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Col = number\n```\n"},"range":{"start":{"line":4,"character":5},"end":{"line":4,"character":8}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":235,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":4,"character":5},"end":{"line":4,"character":8}}}]}Content-Length: 194 - -{"jsonrpc":"2.0","id":236,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Col = number\n```\n"},"range":{"start":{"line":4,"character":5},"end":{"line":4,"character":8}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":237,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":10,"character":5},"end":{"line":10,"character":15}}}]}Content-Length: 259 - -{"jsonrpc":"2.0","id":238,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype StampEmoji = {\n type: \"StampEmoji\";\n row: Row;\n col: Col;\n}\n```\n"},"range":{"start":{"line":10,"character":5},"end":{"line":10,"character":15}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":239,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":10,"character":5},"end":{"line":10,"character":15}}}]}Content-Length: 259 - -{"jsonrpc":"2.0","id":240,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype StampEmoji = {\n type: \"StampEmoji\";\n row: Row;\n col: Col;\n}\n```\n"},"range":{"start":{"line":10,"character":5},"end":{"line":10,"character":15}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":241,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":10,"character":5},"end":{"line":10,"character":15}}}]}Content-Length: 259 - -{"jsonrpc":"2.0","id":242,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype StampEmoji = {\n type: \"StampEmoji\";\n row: Row;\n col: Col;\n}\n```\n"},"range":{"start":{"line":10,"character":5},"end":{"line":10,"character":15}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":243,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":10,"character":5},"end":{"line":10,"character":15}}}]}Content-Length: 259 - -{"jsonrpc":"2.0","id":244,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype StampEmoji = {\n type: \"StampEmoji\";\n row: Row;\n col: Col;\n}\n```\n"},"range":{"start":{"line":10,"character":5},"end":{"line":10,"character":15}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":245,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":10,"character":5},"end":{"line":10,"character":15}}}]}Content-Length: 259 - -{"jsonrpc":"2.0","id":246,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype StampEmoji = {\n type: \"StampEmoji\";\n row: Row;\n col: Col;\n}\n```\n"},"range":{"start":{"line":10,"character":5},"end":{"line":10,"character":15}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":247,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":10,"character":5},"end":{"line":10,"character":15}}}]}Content-Length: 259 - -{"jsonrpc":"2.0","id":248,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype StampEmoji = {\n type: \"StampEmoji\";\n row: Row;\n col: Col;\n}\n```\n"},"range":{"start":{"line":10,"character":5},"end":{"line":10,"character":15}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":249,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":10,"character":5},"end":{"line":10,"character":15}}}]}Content-Length: 259 - -{"jsonrpc":"2.0","id":250,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype StampEmoji = {\n type: \"StampEmoji\";\n row: Row;\n col: Col;\n}\n```\n"},"range":{"start":{"line":10,"character":5},"end":{"line":10,"character":15}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":251,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":10,"character":5},"end":{"line":10,"character":15}}}]}Content-Length: 259 - -{"jsonrpc":"2.0","id":252,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype StampEmoji = {\n type: \"StampEmoji\";\n row: Row;\n col: Col;\n}\n```\n"},"range":{"start":{"line":10,"character":5},"end":{"line":10,"character":15}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":253,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":10,"character":5},"end":{"line":10,"character":15}}}]}Content-Length: 259 - -{"jsonrpc":"2.0","id":254,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype StampEmoji = {\n type: \"StampEmoji\";\n row: Row;\n col: Col;\n}\n```\n"},"range":{"start":{"line":10,"character":5},"end":{"line":10,"character":15}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":255,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":10,"character":5},"end":{"line":10,"character":15}}}]}Content-Length: 259 - -{"jsonrpc":"2.0","id":256,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype StampEmoji = {\n type: \"StampEmoji\";\n row: Row;\n col: Col;\n}\n```\n"},"range":{"start":{"line":10,"character":5},"end":{"line":10,"character":15}}}}Content-Length: 38 - -{"jsonrpc":"2.0","id":257,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":258,"result":[]}Content-Length: 200 - -{"jsonrpc":"2.0","id":259,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":11,"character":5},"end":{"line":11,"character":14}}}]}Content-Length: 257 - -{"jsonrpc":"2.0","id":260,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype ClearCell = {\n type: \"ClearCell\";\n row: Row;\n col: Col;\n}\n```\n"},"range":{"start":{"line":11,"character":5},"end":{"line":11,"character":14}}}}Content-Length: 38 - -{"jsonrpc":"2.0","id":261,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":262,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":263,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":264,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":265,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":266,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":267,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":268,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":269,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":270,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":271,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":272,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":273,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":274,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":275,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":276,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":277,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":278,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":279,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":280,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":281,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":282,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":283,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":284,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":285,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":286,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":287,"result":[]}Content-Length: 197 - -{"jsonrpc":"2.0","id":288,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}]}Content-Length: 194 - -{"jsonrpc":"2.0","id":289,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Row = number\n```\n"},"range":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":290,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}]}Content-Length: 194 - -{"jsonrpc":"2.0","id":291,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Row = number\n```\n"},"range":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":292,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}]}Content-Length: 194 - -{"jsonrpc":"2.0","id":293,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Row = number\n```\n"},"range":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":294,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}]}Content-Length: 194 - -{"jsonrpc":"2.0","id":295,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Row = number\n```\n"},"range":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}}Content-Length: 38 - -{"jsonrpc":"2.0","id":296,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":297,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":298,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":299,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":300,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":301,"result":[]}Content-Length: 197 - -{"jsonrpc":"2.0","id":302,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":4,"character":5},"end":{"line":4,"character":8}}}]}Content-Length: 194 - -{"jsonrpc":"2.0","id":303,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Col = number\n```\n"},"range":{"start":{"line":4,"character":5},"end":{"line":4,"character":8}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":304,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":4,"character":5},"end":{"line":4,"character":8}}}]}Content-Length: 194 - -{"jsonrpc":"2.0","id":305,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Col = number\n```\n"},"range":{"start":{"line":4,"character":5},"end":{"line":4,"character":8}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":306,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":4,"character":5},"end":{"line":4,"character":8}}}]}Content-Length: 194 - -{"jsonrpc":"2.0","id":307,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Col = number\n```\n"},"range":{"start":{"line":4,"character":5},"end":{"line":4,"character":8}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":308,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":4,"character":5},"end":{"line":4,"character":8}}}]}Content-Length: 194 - -{"jsonrpc":"2.0","id":309,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Col = number\n```\n"},"range":{"start":{"line":4,"character":5},"end":{"line":4,"character":8}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":310,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":11,"character":5},"end":{"line":11,"character":14}}}]}Content-Length: 257 - -{"jsonrpc":"2.0","id":311,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype ClearCell = {\n type: \"ClearCell\";\n row: Row;\n col: Col;\n}\n```\n"},"range":{"start":{"line":11,"character":5},"end":{"line":11,"character":14}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":312,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":11,"character":5},"end":{"line":11,"character":14}}}]}Content-Length: 257 - -{"jsonrpc":"2.0","id":313,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype ClearCell = {\n type: \"ClearCell\";\n row: Row;\n col: Col;\n}\n```\n"},"range":{"start":{"line":11,"character":5},"end":{"line":11,"character":14}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":314,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":11,"character":5},"end":{"line":11,"character":14}}}]}Content-Length: 257 - -{"jsonrpc":"2.0","id":315,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype ClearCell = {\n type: \"ClearCell\";\n row: Row;\n col: Col;\n}\n```\n"},"range":{"start":{"line":11,"character":5},"end":{"line":11,"character":14}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":316,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":11,"character":5},"end":{"line":11,"character":14}}}]}Content-Length: 257 - -{"jsonrpc":"2.0","id":317,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype ClearCell = {\n type: \"ClearCell\";\n row: Row;\n col: Col;\n}\n```\n"},"range":{"start":{"line":11,"character":5},"end":{"line":11,"character":14}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":318,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":11,"character":5},"end":{"line":11,"character":14}}}]}Content-Length: 257 - -{"jsonrpc":"2.0","id":319,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype ClearCell = {\n type: \"ClearCell\";\n row: Row;\n col: Col;\n}\n```\n"},"range":{"start":{"line":11,"character":5},"end":{"line":11,"character":14}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":320,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":11,"character":5},"end":{"line":11,"character":14}}}]}Content-Length: 257 - -{"jsonrpc":"2.0","id":321,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype ClearCell = {\n type: \"ClearCell\";\n row: Row;\n col: Col;\n}\n```\n"},"range":{"start":{"line":11,"character":5},"end":{"line":11,"character":14}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":322,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":11,"character":5},"end":{"line":11,"character":14}}}]}Content-Length: 257 - -{"jsonrpc":"2.0","id":323,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype ClearCell = {\n type: \"ClearCell\";\n row: Row;\n col: Col;\n}\n```\n"},"range":{"start":{"line":11,"character":5},"end":{"line":11,"character":14}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":324,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":11,"character":5},"end":{"line":11,"character":14}}}]}Content-Length: 257 - -{"jsonrpc":"2.0","id":325,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype ClearCell = {\n type: \"ClearCell\";\n row: Row;\n col: Col;\n}\n```\n"},"range":{"start":{"line":11,"character":5},"end":{"line":11,"character":14}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":326,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":11,"character":5},"end":{"line":11,"character":14}}}]}Content-Length: 257 - -{"jsonrpc":"2.0","id":327,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype ClearCell = {\n type: \"ClearCell\";\n row: Row;\n col: Col;\n}\n```\n"},"range":{"start":{"line":11,"character":5},"end":{"line":11,"character":14}}}}Content-Length: 38 - -{"jsonrpc":"2.0","id":328,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":329,"result":[]}Content-Length: 200 - -{"jsonrpc":"2.0","id":330,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":12,"character":5},"end":{"line":12,"character":14}}}]}Content-Length: 227 - -{"jsonrpc":"2.0","id":331,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype ClearGrid = {\n type: \"ClearGrid\";\n}\n```\n"},"range":{"start":{"line":12,"character":5},"end":{"line":12,"character":14}}}}Content-Length: 38 - -{"jsonrpc":"2.0","id":332,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":333,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":334,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":335,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":336,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":337,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":338,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":339,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":340,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":341,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":342,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":343,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":344,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":345,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":346,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":347,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":348,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":349,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":350,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":351,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":352,"result":[]}Content-Length: 200 - -{"jsonrpc":"2.0","id":353,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":12,"character":5},"end":{"line":12,"character":14}}}]}Content-Length: 227 - -{"jsonrpc":"2.0","id":354,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype ClearGrid = {\n type: \"ClearGrid\";\n}\n```\n"},"range":{"start":{"line":12,"character":5},"end":{"line":12,"character":14}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":355,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":12,"character":5},"end":{"line":12,"character":14}}}]}Content-Length: 227 - -{"jsonrpc":"2.0","id":356,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype ClearGrid = {\n type: \"ClearGrid\";\n}\n```\n"},"range":{"start":{"line":12,"character":5},"end":{"line":12,"character":14}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":357,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":12,"character":5},"end":{"line":12,"character":14}}}]}Content-Length: 227 - -{"jsonrpc":"2.0","id":358,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype ClearGrid = {\n type: \"ClearGrid\";\n}\n```\n"},"range":{"start":{"line":12,"character":5},"end":{"line":12,"character":14}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":359,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":12,"character":5},"end":{"line":12,"character":14}}}]}Content-Length: 227 - -{"jsonrpc":"2.0","id":360,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype ClearGrid = {\n type: \"ClearGrid\";\n}\n```\n"},"range":{"start":{"line":12,"character":5},"end":{"line":12,"character":14}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":361,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":12,"character":5},"end":{"line":12,"character":14}}}]}Content-Length: 227 - -{"jsonrpc":"2.0","id":362,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype ClearGrid = {\n type: \"ClearGrid\";\n}\n```\n"},"range":{"start":{"line":12,"character":5},"end":{"line":12,"character":14}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":363,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":12,"character":5},"end":{"line":12,"character":14}}}]}Content-Length: 227 - -{"jsonrpc":"2.0","id":364,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype ClearGrid = {\n type: \"ClearGrid\";\n}\n```\n"},"range":{"start":{"line":12,"character":5},"end":{"line":12,"character":14}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":365,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":12,"character":5},"end":{"line":12,"character":14}}}]}Content-Length: 227 - -{"jsonrpc":"2.0","id":366,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype ClearGrid = {\n type: \"ClearGrid\";\n}\n```\n"},"range":{"start":{"line":12,"character":5},"end":{"line":12,"character":14}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":367,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":12,"character":5},"end":{"line":12,"character":14}}}]}Content-Length: 227 - -{"jsonrpc":"2.0","id":368,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype ClearGrid = {\n type: \"ClearGrid\";\n}\n```\n"},"range":{"start":{"line":12,"character":5},"end":{"line":12,"character":14}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":369,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":12,"character":5},"end":{"line":12,"character":14}}}]}Content-Length: 227 - -{"jsonrpc":"2.0","id":370,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype ClearGrid = {\n type: \"ClearGrid\";\n}\n```\n"},"range":{"start":{"line":12,"character":5},"end":{"line":12,"character":14}}}}Content-Length: 38 - -{"jsonrpc":"2.0","id":371,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":372,"result":[]}Content-Length: 200 - -{"jsonrpc":"2.0","id":373,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":13,"character":5},"end":{"line":13,"character":12}}}]}Content-Length: 238 - -{"jsonrpc":"2.0","id":374,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype FillRow = {\n type: \"FillRow\";\n row: Row;\n}\n```\n"},"range":{"start":{"line":13,"character":5},"end":{"line":13,"character":12}}}}Content-Length: 38 - -{"jsonrpc":"2.0","id":375,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":376,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":377,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":378,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":379,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":380,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":381,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":382,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":383,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":384,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":385,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":386,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":387,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":388,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":389,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":390,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":391,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":392,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":393,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":394,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":395,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":396,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":397,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":398,"result":[]}Content-Length: 38 - -{"jsonrpc":"2.0","id":399,"result":[]}Content-Length: 197 - -{"jsonrpc":"2.0","id":400,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}]}Content-Length: 194 - -{"jsonrpc":"2.0","id":401,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Row = number\n```\n"},"range":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":402,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}]}Content-Length: 194 - -{"jsonrpc":"2.0","id":403,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Row = number\n```\n"},"range":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":404,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}]}Content-Length: 194 - -{"jsonrpc":"2.0","id":405,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Row = number\n```\n"},"range":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}}Content-Length: 197 - -{"jsonrpc":"2.0","id":406,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}]}Content-Length: 194 - -{"jsonrpc":"2.0","id":407,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Row = number\n```\n"},"range":{"start":{"line":3,"character":5},"end":{"line":3,"character":8}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":408,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":13,"character":5},"end":{"line":13,"character":12}}}]}Content-Length: 238 - -{"jsonrpc":"2.0","id":409,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype FillRow = {\n type: \"FillRow\";\n row: Row;\n}\n```\n"},"range":{"start":{"line":13,"character":5},"end":{"line":13,"character":12}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":410,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":13,"character":5},"end":{"line":13,"character":12}}}]}Content-Length: 238 - -{"jsonrpc":"2.0","id":411,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype FillRow = {\n type: \"FillRow\";\n row: Row;\n}\n```\n"},"range":{"start":{"line":13,"character":5},"end":{"line":13,"character":12}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":412,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":13,"character":5},"end":{"line":13,"character":12}}}]}Content-Length: 238 - -{"jsonrpc":"2.0","id":413,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype FillRow = {\n type: \"FillRow\";\n row: Row;\n}\n```\n"},"range":{"start":{"line":13,"character":5},"end":{"line":13,"character":12}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":414,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":13,"character":5},"end":{"line":13,"character":12}}}]}Content-Length: 238 - -{"jsonrpc":"2.0","id":415,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype FillRow = {\n type: \"FillRow\";\n row: Row;\n}\n```\n"},"range":{"start":{"line":13,"character":5},"end":{"line":13,"character":12}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":416,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":13,"character":5},"end":{"line":13,"character":12}}}]}Content-Length: 238 - -{"jsonrpc":"2.0","id":417,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype FillRow = {\n type: \"FillRow\";\n row: Row;\n}\n```\n"},"range":{"start":{"line":13,"character":5},"end":{"line":13,"character":12}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":418,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":15,"character":5},"end":{"line":15,"character":11}}}]}Content-Length: 252 - -{"jsonrpc":"2.0","id":419,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Action = SelectEmoji | StampEmoji | ClearCell | ClearGrid | FillRow\n```\n"},"range":{"start":{"line":15,"character":5},"end":{"line":15,"character":11}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":420,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":15,"character":5},"end":{"line":15,"character":11}}}]}Content-Length: 252 - -{"jsonrpc":"2.0","id":421,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Action = SelectEmoji | StampEmoji | ClearCell | ClearGrid | FillRow\n```\n"},"range":{"start":{"line":15,"character":5},"end":{"line":15,"character":11}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":422,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":15,"character":5},"end":{"line":15,"character":11}}}]}Content-Length: 252 - -{"jsonrpc":"2.0","id":423,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Action = SelectEmoji | StampEmoji | ClearCell | ClearGrid | FillRow\n```\n"},"range":{"start":{"line":15,"character":5},"end":{"line":15,"character":11}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":424,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":15,"character":5},"end":{"line":15,"character":11}}}]}Content-Length: 252 - -{"jsonrpc":"2.0","id":425,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Action = SelectEmoji | StampEmoji | ClearCell | ClearGrid | FillRow\n```\n"},"range":{"start":{"line":15,"character":5},"end":{"line":15,"character":11}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":426,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":15,"character":5},"end":{"line":15,"character":11}}}]}Content-Length: 252 - -{"jsonrpc":"2.0","id":427,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Action = SelectEmoji | StampEmoji | ClearCell | ClearGrid | FillRow\n```\n"},"range":{"start":{"line":15,"character":5},"end":{"line":15,"character":11}}}}Content-Length: 200 - -{"jsonrpc":"2.0","id":428,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":15,"character":5},"end":{"line":15,"character":11}}}]}Content-Length: 252 - -{"jsonrpc":"2.0","id":429,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Action = SelectEmoji | StampEmoji | ClearCell | ClearGrid | FillRow\n```\n"},"range":{"start":{"line":15,"character":5},"end":{"line":15,"character":11}}}}Content-Length: 38 - -{"jsonrpc":"2.0","id":430,"result":[]}Content-Length: 207 - -{"jsonrpc":"2.0","id":431,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/injected_sketch.ts","range":{"start":{"line":0,"character":22},"end":{"line":0,"character":61}}}]}Content-Length: 40 - -{"jsonrpc":"2.0","id":432,"result":null}Content-Length: 207 - -{"jsonrpc":"2.0","id":433,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/injected_sketch.ts","range":{"start":{"line":0,"character":22},"end":{"line":0,"character":61}}}]}Content-Length: 40 - -{"jsonrpc":"2.0","id":434,"result":null}Content-Length: 38 - -{"jsonrpc":"2.0","id":435,"result":[]}Content-Length: 198 - -{"jsonrpc":"2.0","id":436,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":7,"character":5},"end":{"line":7,"character":10}}}]}Content-Length: 215 - -{"jsonrpc":"2.0","id":437,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Model = [Grid, string, string[]]\n```\n"},"range":{"start":{"line":7,"character":5},"end":{"line":7,"character":10}}}}Content-Length: 198 - -{"jsonrpc":"2.0","id":438,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":7,"character":5},"end":{"line":7,"character":10}}}]}Content-Length: 215 - -{"jsonrpc":"2.0","id":439,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Model = [Grid, string, string[]]\n```\n"},"range":{"start":{"line":7,"character":5},"end":{"line":7,"character":10}}}}Content-Length: 198 - -{"jsonrpc":"2.0","id":440,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":7,"character":5},"end":{"line":7,"character":10}}}]}Content-Length: 215 - -{"jsonrpc":"2.0","id":441,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Model = [Grid, string, string[]]\n```\n"},"range":{"start":{"line":7,"character":5},"end":{"line":7,"character":10}}}}Content-Length: 198 - -{"jsonrpc":"2.0","id":442,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":7,"character":5},"end":{"line":7,"character":10}}}]}Content-Length: 215 - -{"jsonrpc":"2.0","id":443,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Model = [Grid, string, string[]]\n```\n"},"range":{"start":{"line":7,"character":5},"end":{"line":7,"character":10}}}}Content-Length: 198 - -{"jsonrpc":"2.0","id":444,"result":[{"uri":"file:///home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts","range":{"start":{"line":7,"character":5},"end":{"line":7,"character":10}}}]}Content-Length: 215 - -{"jsonrpc":"2.0","id":445,"result":{"contents":{"kind":"markdown","value":"\n```typescript\ntype Model = [Grid, string, string[]]\n```\n"},"range":{"start":{"line":7,"character":5},"end":{"line":7,"character":10}}}} \ No newline at end of file diff --git a/output.txt b/output.txt deleted file mode 100644 index eef5bec..0000000 --- a/output.txt +++ /dev/null @@ -1,12 +0,0 @@ -function _<(model: Model, action: Action) => Model>(): (model: Model, action: Action) => Model; -type Model = [Grid, string, string[]]; -type Grid = string[][]; -type Emoji = string; -type Action = SelectEmoji | StampEmoji | ClearCell | ClearGrid | FillRow; -type SelectEmoji = { type: "SelectEmoji"; emoji: Emoji;}; -type StampEmoji = { type: "StampEmoji"; row: Row; col: Col;}; -type Row = number; -type Col = number; -type ClearCell = { type: "ClearCell"; row: Row; col: Col;}; -type ClearGrid = { type: "ClearGrid";}; -type FillRow = { type: "FillRow"; row: Row;}; diff --git a/queries/codeql-custom-queries-javascript/example.ql b/queries/codeql-custom-queries-javascript/example.ql index 7723906..7a9a5ae 100644 --- a/queries/codeql-custom-queries-javascript/example.ql +++ b/queries/codeql-custom-queries-javascript/example.ql @@ -6,11 +6,5 @@ import javascript -from File fi, TypeExpr t -where - ( - t.toString() = "Weekday" or - t.toString() = "TimeOfDay" - ) and - t.getFile() = fi -select t.toString(), fi.toString() \ No newline at end of file +from Type t +select t \ No newline at end of file diff --git a/queries/codeql-custom-queries-javascript/header-types.ql b/queries/codeql-custom-queries-javascript/header-types.ql new file mode 100644 index 0000000..c9770d9 --- /dev/null +++ b/queries/codeql-custom-queries-javascript/header-types.ql @@ -0,0 +1,12 @@ +/** + * This is an automatically generated file + * @name Hello world + * @kind problem + * @problem.severity warning + * @id javascript/example/hello-world + */ + +import javascript + +from File f +select f, "Hello, world!" \ No newline at end of file diff --git a/queries/codeql-custom-queries-javascript/target-types.ql b/queries/codeql-custom-queries-javascript/target-types.ql new file mode 100644 index 0000000..c9770d9 --- /dev/null +++ b/queries/codeql-custom-queries-javascript/target-types.ql @@ -0,0 +1,12 @@ +/** + * This is an automatically generated file + * @name Hello world + * @kind problem + * @problem.severity warning + * @id javascript/example/hello-world + */ + +import javascript + +from File f +select f, "Hello, world!" \ No newline at end of file diff --git a/queries/codeql-custom-queries-javascript/types.ql b/queries/codeql-custom-queries-javascript/types.ql index e2fee09..d9ec573 100644 --- a/queries/codeql-custom-queries-javascript/types.ql +++ b/queries/codeql-custom-queries-javascript/types.ql @@ -7,5 +7,5 @@ import javascript from FunctionTypeExpr t, TypeExpr e -where t.toString() = "(model: Model, user: User) => Booking[]" and e = t.getReturnTypeAnnotation() +where t.toString() = "(num_criteria_met: number) => PasswordStrength" and e = t.getReturnTypeAnnotation() select e.toString(), e.getAPrimaryQlClass() \ No newline at end of file diff --git a/run.mjs b/run.mjs index 0b16730..3832494 100644 --- a/run.mjs +++ b/run.mjs @@ -1,2 +1,2 @@ import { extractWithCodeQL } from "./dist/index.js"; -extractWithCodeQL("/home/jacob/projects/context-extractor/targets/booking/sketch.ts"); +extractWithCodeQL("/home/jacob/projects/context-extractor/targets/emojipaint/sketch.ts"); diff --git a/run_exhaustive_retrieval_tests.sh b/run_exhaustive_retrieval_tests.sh index 0722285..2e29c2b 100755 --- a/run_exhaustive_retrieval_tests.sh +++ b/run_exhaustive_retrieval_tests.sh @@ -12,7 +12,7 @@ collate_script="$projectRoot/exhaustive_collate_data.sh" command_timeout=180 wait_time=0 -num_runs=2 +num_runs=20 # Source folders source_folders=( @@ -135,7 +135,7 @@ for source_folder in "${source_folders[@]}"; do done # Call the collate_data script -bash "$collate_script" +bash "$collate_script" "$run_name" # Print the summary and error summary echo -e "\n$summary" diff --git a/run_starcoder_exhaustive_retrieval_tests.sh b/run_starcoder_exhaustive_retrieval_tests.sh new file mode 100755 index 0000000..92f184d --- /dev/null +++ b/run_starcoder_exhaustive_retrieval_tests.sh @@ -0,0 +1,147 @@ +#!/bin/bash + +# Constants +command_prefix="node --env-file=.env src/starcoder-exhaustive-retrieval.mjs" +# api_key="--api-key $HOME/azure-4-api-key.txt" +# api_key="--api-key /home/jacob/projects/testtslspclient/openai-key.txt" +run_name=${1:-default} +projectRoot=$(pwd) +log_directory="$projectRoot/starcoder-exhaustive-retrieval/testlog" +collate_script="$projectRoot/starcoder_exhaustive_collate_data.sh" +# warm_serials="warm_serials.sh" + +command_timeout=180 +wait_time=0 +num_runs=20 + +# Source folders +source_folders=( + "$projectRoot/targets/starcoder-todo/" + "$projectRoot/targets/starcoder-playlist/" + "$projectRoot/targets/starcoder-booking/" + "$projectRoot/targets/starcoder-emojipaint/" + "$projectRoot/targets/starcoder-passwords/" +) + +# Optional argument variations +opt_arg_variations=( + # "--rag RAG.txt" + # "--rag RAG.txt --error_rounds_max 2" + # "--relevant_ctx --expected_type" + # "--temperature 1.0 --relevant_ctx --expected_type --error_rounds_max 6" + # "--temperature 1.0 --error_rounds_max 2" + # "--temperature 0.6 --error_rounds_max 2" + # "--temperature 0.3 --error_rounds_max 2" + # "--temperature 1.0 --expected_type --error_rounds_max 0" + # "--temperature 0.6 --expected_type --error_rounds_max 0" + # "--temperature 0.3 --expected_type --error_rounds_max 0" + + # "--temperature 0.6 --error_rounds_max 2" + "--temperature 0.6 --error_rounds_max 0" + + # Mammoth experiment + # "--temperature 0.6 --rag RAG.txt --error_rounds_max 2" + # "--temperature 0.6 --rag RAG.txt" + # "--temperature 0.6 --relevant_ctx --expected_type --error_rounds_max 2" + # "--temperature 0.6 --relevant_ctx --expected_type" + # "--temperature 0.6 --relevant_ctx --error_rounds_max 2" + # "--temperature 0.6 --expected_type --error_rounds_max 2" + # "--temperature 0.6 --expected_type" + # "--temperature 0.6 --error_rounds_max 2" + # "--temperature 0.6 --relevant_ctx" + # "--temperature 0.6" +) + +# Function to display usage information +usage() { + echo "Usage: $0 [--verbose] [run_name]" + echo " --verbose Display HazeLS output on the terminal in addition to saving in log files" + echo " run_name Name of the test run (default: 'default')" +} + +# Check if --verbose flag is provided +verbose=false +while [[ $# -gt 0 ]]; do + case "$1" in + --verbose) + verbose=true + shift + ;; + --*) + echo "Invalid flag: $1" + usage + exit 1 + ;; + *) + run_name=$1 + shift + ;; + esac +done + +# Call the warm_serials script +# bash "$warm_serials" + +# Create log directory if it doesn't exist +mkdir -p "$log_directory" + +# Function to run the command with given optional arguments and source folder +run_command() { + opt_args=$1 + source_folder=$2 + source=$(basename ${source_folder}) + timestamp=$(date +%Y%m%d_%H%M%S) + log_file="$log_directory/${run_name}-${source}-exhaustive-${timestamp}.log" + + if $verbose; then + timeout --foreground "$command_timeout"s bash -c "$command_prefix --run_name \"$run_name\" $opt_args --source_folder \"$source_folder\" $timestamp | tee \"$log_file\"" & + else + timeout --foreground "$command_timeout"s bash -c "$command_prefix --run_name \"$run_name\" $opt_args --source_folder \"$source_folder\" $timestamp > \"$log_file\" 2>&1" & + fi + cmd_pid=$! + wait $cmd_pid + exit_code=$? + + if [ $exit_code -eq 124 ]; then + echo "Timeout: HazeLS command exceeded ${command_timeout} seconds for source '$source_folder' with options '$opt_args'. Log file: $log_file" + error_count=$((error_count + 1)) + error_summary+="- Timeout: HazeLS command for source '$source_folder' with options '$opt_args' exceeded ${command_timeout} seconds. Log file: $log_file\n" + elif [ $exit_code -ne 0 ]; then + echo "Alert: HazeLS command exited with non-zero exit code $exit_code. Check log file: $log_file" + error_count=$((error_count + 1)) + error_summary+="- HazeLS command with options '$opt_args' for source '$source_folder' exited with code $exit_code. Log file: $log_file\n" + fi +} + +# Initialize a summary string and error tracking variables +summary="Summary of test runs:\n" +error_count=0 +error_summary="" + +# Iterate over source folders +for source_folder in "${source_folders[@]}"; do + # Iterate over optional argument variations + for opt_args in "${opt_arg_variations[@]}"; do + # Run the command multiple times for each variation and source folder + for ((i = 1; i <= num_runs; i++)); do + echo "Running test $i for source: $source_folder with options: $opt_args" + run_command "$opt_args" "$source_folder" + sleep $wait_time + done + + # Append to the summary string + summary+="- Ran $num_runs tests for source: $source_folder with options: $opt_args\n" + done +done + +# Call the collate_data script +bash "$collate_script" "$run_name" + +# Print the summary and error summary +echo -e "\n$summary" +if [ $error_count -gt 0 ]; then + echo -e "Errors encountered during test runs:\n$error_summary" + echo "Total errors: $error_count" +else + echo "All test runs completed successfully." +fi diff --git a/run_starcoder_types_and_headers_tests.sh b/run_starcoder_types_and_headers_tests.sh new file mode 100755 index 0000000..ce36291 --- /dev/null +++ b/run_starcoder_types_and_headers_tests.sh @@ -0,0 +1,147 @@ +#!/bin/bash + +# Constants +run_name=${1:-default} +projectRoot=$(pwd) +log_directory="$projectRoot/starcoder-types-and-headers/testlog" +collate_script="$projectRoot/types_and_headers_collate_data.sh" +take_snapshot="$projectRoot/take_snapshot.sh" +command_prefix="node --env-file=.env src/starcoder-types-and-headers.mjs" +# command_prefix="node src/testrunner-starcoder.mjs" + +command_timeout=120 +wait_time=0 +num_runs=20 + +# Source folders +# source_folders=( +# "/home/jacob/projects/testtslspclient/targets/starcoder-todo/" +# "/home/jacob/projects/testtslspclient/targets/starcoder-playlist/" +# "/home/jacob/projects/testtslspclient/targets/starcoder-passwords/" +# "/home/jacob/projects/testtslspclient/targets/starcoder-booking/" +# "/home/jacob/projects/testtslspclient/targets/starcoder-emojipaint/" +# ) +source_folders=( + "$projectRoot/targets/starcoder-todo/" + "$projectRoot/targets/starcoder-playlist/" + "$projectRoot/targets/starcoder-passwords/" + "$projectRoot/targets/starcoder-booking/" + "$projectRoot/targets/starcoder-emojipaint/" +) + +# Optional argument variations +opt_arg_variations=( + # "--type-constraint false --relevant-ctx false --error_rounds_max 2" + "--type-constraint false --relevant-ctx false --error_rounds_max 0" + # "--type-constraint false --relevant-ctx true --error_rounds_max 2" + "--type-constraint false --relevant-ctx true --error_rounds_max 0" + # "--type-constraint true --relevant-ctx false --error_rounds_max 2" + "--type-constraint true --relevant-ctx false --error_rounds_max 0" + # "--type-constraint true --relevant-ctx true --error_rounds_max 2" + "--type-constraint true --relevant-ctx true --error_rounds_max 0" +) +# "--type-constraint false --relevant-ctx false" +# "--type-constraint false --relevant-ctx true" +# "--type-constraint true --relevant-ctx false" +# "--type-constraint true --relevant-ctx true" + +# Function to display usage information +usage() { + echo "Usage: $0 [--verbose] [run_name]" + echo " --verbose Display HazeLS output on the terminal in addition to saving in log files" + echo " run_name Name of the test run (default: 'default')" +} + +# Check if --verbose flag is provided +verbose=false +while [[ $# -gt 0 ]]; do + case "$1" in + --verbose) + verbose=true + shift + ;; + --*) + echo "Invalid flag: $1" + usage + exit 1 + ;; + *) + run_name=$1 + shift + ;; + esac +done + +# Call the warm_serials script +# bash "$warm_serials" + +# Create log directory if it doesn't exist +mkdir -p "$log_directory" + +# Function to run the command with given optional arguments and source folder +run_command() { + opt_args=$1 + source_folder=$2 + source=$(basename ${source_folder}) + run_number=$3 + timestamp=$(date +%Y%m%d_%H%M%S) + unix_timestamp=$(date +%s) + log_file="$log_directory/${run_name}-${source}-types-and-headers-${timestamp}.log" + + if $verbose; then + timeout --foreground "$command_timeout"s bash -c "$command_prefix $timestamp $unix_timestamp --run_name \"$run_name\" $opt_args --source_folder \"$source_folder\" --run_number \"$run_number\" | tee \"$log_file\"" & + else + timeout --foreground "$command_timeout"s bash -c "$command_prefix $timestamp $unix_timestamp --run_name \"$run_name\" $opt_args --source_folder \"$source_folder\" --run_number \"$run_number\" > \"$log_file\" 2>&1" & + fi + cmd_pid=$! + wait $cmd_pid + exit_code=$? + + if [ $exit_code -eq 124 ]; then + echo "Timeout: command exceeded ${command_timeout} seconds for source '$source_folder' with options '$opt_args'. Log file: $log_file" + error_count=$((error_count + 1)) + error_summary+="- Timeout: command for source '$source_folder' with options '$opt_args' exceeded ${command_timeout} seconds. Log file: $log_file\n" + elif [ $exit_code -ne 0 ]; then + echo "Alert: command exited with non-zero exit code $exit_code. Check log file: $log_file" + error_count=$((error_count + 1)) + error_summary+="- command with options '$opt_args' for source '$source_folder' exited with code $exit_code. Log file: $log_file\n" + fi +} + +# Initialize a summary string and error tracking variables +summary="Summary of test runs:\n" +error_count=0 +error_summary="" + +# Iterate over source folders +for source_folder in "${source_folders[@]}"; do + # Iterate over optional argument variations + for opt_args in "${opt_arg_variations[@]}"; do + # Run the command multiple times for each variation and source folder + for ((i = 1; i <= num_runs; i++)); do + echo "Running test $i for source: $source_folder with options: $opt_args" + run_command "$opt_args" "$source_folder" "$i" + sleep $wait_time + done + + # Append to the summary string + summary+="- Ran $num_runs tests for source: $source_folder with options: $opt_args\n" + done +done + +# Call the collate_data script +echo "\nCollating data\n" +bash "$collate_script" "$run_name" + +# Call the take_snapshot script +# echo "\nTaking snapshot\n" +# bash "$take_snapshot" "$run_name" + +# Print the summary and error summary +echo -e "\n$summary" +if [ $error_count -gt 0 ]; then + echo -e "Errors encountered during test runs:\n$error_summary" + echo "Total errors: $error_count" +else + echo "All test runs completed successfully." +fi diff --git a/run_starcoder_vector_retrieval_tests.sh b/run_starcoder_vector_retrieval_tests.sh new file mode 100755 index 0000000..bb53684 --- /dev/null +++ b/run_starcoder_vector_retrieval_tests.sh @@ -0,0 +1,147 @@ +#!/bin/bash + +# Constants +command_prefix="node --env-file=.env src/starcoder-vector-retrieval.mjs" +# api_key="--api-key $HOME/azure-4-api-key.txt" +# api_key="--api-key /home/jacob/projects/testtslspclient/openai-key.txt" +run_name=${1:-default} +projectRoot=$(pwd) +log_directory="$projectRoot/starcoder-vector-retrieval/testlog" +collate_script="$projectRoot/starcoder_vector_collate_data.sh" +# warm_serials="warm_serials.sh" + +command_timeout=180 +wait_time=0 +num_runs=5 + +# Source folders +source_folders=( + "$projectRoot/targets/starcoder-todo/" + "$projectRoot/targets/starcoder-playlist/" + "$projectRoot/targets/starcoder-booking/" + "$projectRoot/targets/starcoder-emojipaint/" + "$projectRoot/targets/starcoder-passwords/" +) + +# Optional argument variations +opt_arg_variations=( + # "--rag RAG.txt" + # "--rag RAG.txt --error_rounds_max 2" + # "--relevant_ctx --expected_type" + # "--temperature 1.0 --relevant_ctx --expected_type --error_rounds_max 6" + # "--temperature 1.0 --error_rounds_max 2" + # "--temperature 0.6 --error_rounds_max 2" + # "--temperature 0.3 --error_rounds_max 2" + # "--temperature 1.0 --expected_type --error_rounds_max 0" + # "--temperature 0.6 --expected_type --error_rounds_max 0" + # "--temperature 0.3 --expected_type --error_rounds_max 0" + + "--temperature 0.6 --rag prelude.haze --error_rounds_max 2" + "--temperature 0.6 --rag prelude.haze --error_rounds_max 0" + + # Mammoth experiment + # "--temperature 0.6 --rag RAG.txt --error_rounds_max 2" + # "--temperature 0.6 --rag RAG.txt" + # "--temperature 0.6 --relevant_ctx --expected_type --error_rounds_max 2" + # "--temperature 0.6 --relevant_ctx --expected_type" + # "--temperature 0.6 --relevant_ctx --error_rounds_max 2" + # "--temperature 0.6 --expected_type --error_rounds_max 2" + # "--temperature 0.6 --expected_type" + # "--temperature 0.6 --error_rounds_max 2" + # "--temperature 0.6 --relevant_ctx" + # "--temperature 0.6" +) + +# Function to display usage information +usage() { + echo "Usage: $0 [--verbose] [run_name]" + echo " --verbose Display HazeLS output on the terminal in addition to saving in log files" + echo " run_name Name of the test run (default: 'default')" +} + +# Check if --verbose flag is provided +verbose=false +while [[ $# -gt 0 ]]; do + case "$1" in + --verbose) + verbose=true + shift + ;; + --*) + echo "Invalid flag: $1" + usage + exit 1 + ;; + *) + run_name=$1 + shift + ;; + esac +done + +# Call the warm_serials script +# bash "$warm_serials" + +# Create log directory if it doesn't exist +mkdir -p "$log_directory" + +# Function to run the command with given optional arguments and source folder +run_command() { + opt_args=$1 + source_folder=$2 + source=$(basename ${source_folder}) + timestamp=$(date +%Y%m%d_%H%M%S) + log_file="$log_directory/${run_name}-${source}-vector-${timestamp}.log" + + if $verbose; then + timeout --foreground "$command_timeout"s bash -c "$command_prefix --run_name \"$run_name\" $opt_args --source_folder \"$source_folder\" $timestamp | tee \"$log_file\"" & + else + timeout --foreground "$command_timeout"s bash -c "$command_prefix --run_name \"$run_name\" $opt_args --source_folder \"$source_folder\" $timestamp > \"$log_file\" 2>&1" & + fi + cmd_pid=$! + wait $cmd_pid + exit_code=$? + + if [ $exit_code -eq 124 ]; then + echo "Timeout: HazeLS command exceeded ${command_timeout} seconds for source '$source_folder' with options '$opt_args'. Log file: $log_file" + error_count=$((error_count + 1)) + error_summary+="- Timeout: HazeLS command for source '$source_folder' with options '$opt_args' exceeded ${command_timeout} seconds. Log file: $log_file\n" + elif [ $exit_code -ne 0 ]; then + echo "Alert: HazeLS command exited with non-zero exit code $exit_code. Check log file: $log_file" + error_count=$((error_count + 1)) + error_summary+="- HazeLS command with options '$opt_args' for source '$source_folder' exited with code $exit_code. Log file: $log_file\n" + fi +} + +# Initialize a summary string and error tracking variables +summary="Summary of test runs:\n" +error_count=0 +error_summary="" + +# Iterate over source folders +for source_folder in "${source_folders[@]}"; do + # Iterate over optional argument variations + for opt_args in "${opt_arg_variations[@]}"; do + # Run the command multiple times for each variation and source folder + for ((i = 1; i <= num_runs; i++)); do + echo "Running test $i for source: $source_folder with options: $opt_args" + run_command "$opt_args" "$source_folder" + sleep $wait_time + done + + # Append to the summary string + summary+="- Ran $num_runs tests for source: $source_folder with options: $opt_args\n" + done +done + +# Call the collate_data script +bash "$collate_script" "$run_name" + +# Print the summary and error summary +echo -e "\n$summary" +if [ $error_count -gt 0 ]; then + echo -e "Errors encountered during test runs:\n$error_summary" + echo "Total errors: $error_count" +else + echo "All test runs completed successfully." +fi diff --git a/run_types_and_headers_tests.sh b/run_types_and_headers_tests.sh index edf7ec0..6e583ba 100755 --- a/run_types_and_headers_tests.sh +++ b/run_types_and_headers_tests.sh @@ -11,7 +11,7 @@ command_prefix="node --env-file=.env src/types-and-headers.mjs" command_timeout=120 wait_time=0 -num_runs=1 +num_runs=20 # Source folders # source_folders=( @@ -22,11 +22,11 @@ num_runs=1 # "/home/jacob/projects/testtslspclient/targets/starcoder-emojipaint/" # ) source_folders=( - "$projectRoot/targets/todo/" - "$projectRoot/targets/playlist/" + # "$projectRoot/targets/todo/" + # "$projectRoot/targets/playlist/" "$projectRoot/targets/passwords/" - "$projectRoot/targets/booking/" - "$projectRoot/targets/emojipaint/" + # "$projectRoot/targets/booking/" + # "$projectRoot/targets/emojipaint/" ) # Optional argument variations @@ -35,6 +35,10 @@ opt_arg_variations=( "--type-constraint false --relevant-ctx true --error_rounds_max 2" "--type-constraint true --relevant-ctx false --error_rounds_max 2" "--type-constraint true --relevant-ctx true --error_rounds_max 2" + "--type-constraint false --relevant-ctx false --error_rounds_max 0" + "--type-constraint false --relevant-ctx true --error_rounds_max 0" + "--type-constraint true --relevant-ctx false --error_rounds_max 0" + "--type-constraint true --relevant-ctx true --error_rounds_max 0" ) # "--type-constraint false --relevant-ctx false" # "--type-constraint false --relevant-ctx true" diff --git a/run_vector_retireval_tests.sh b/run_vector_retireval_tests.sh index f7cdac9..a9cc339 100755 --- a/run_vector_retireval_tests.sh +++ b/run_vector_retireval_tests.sh @@ -135,7 +135,7 @@ for source_folder in "${source_folders[@]}"; do done # Call the collate_data script -bash "$collate_script" +bash "$collate_script" "$run_name" # Print the summary and error summary echo -e "\n$summary" diff --git a/src/codeql.ts b/src/codeql.ts index 16a6dda..b479314 100644 --- a/src/codeql.ts +++ b/src/codeql.ts @@ -4,7 +4,7 @@ import { execSync } from "child_process"; import { escapeQuotes, parseCodeQLRelevantTypes, parseCodeQLVars, parseCodeQLTypes, isQLFunction, isQLTuple, isQLUnion, isQLArray, isQLLocalTypeAccess, isQLPredefined, isQLLiteral, isQLKeyword, isQLInterface, isQLLabel, isQLIdentifier, parseCodeQLTypesAndLocations, parseCodeQLLocationsAndTypes } from "./utils"; import { relevantTypeObject, varsObject, typesObject, relevantTypeQueryResult, typeAndLocation } from "./types"; import { OutliningSpanKind, getDefaultFormatCodeSettings, isLiteralTypeNode, resolveModuleName } from "typescript"; -import { QUERY_DIR } from "./constants"; +import { QUERY_DIR, ROOT_DIR } from "./constants"; // import { CODEQL_PATH, ROOT_DIR, QUERY_DIR, BOOKING_DIR } from "./constants"; @@ -12,7 +12,7 @@ const createDatabaseWithCodeQL = (pathToCodeQL: string, targetPath: string): str const databaseName = path.basename(targetPath).concat("db"); const pathToDatabase = path.join(targetPath, databaseName); try { - execSync(`${pathToCodeQL} database create ${pathToDatabase} --source-root=${targetPath} --overwrite --language=javascript-typescript`) + execSync(`${pathToCodeQL} database create ${pathToDatabase} --source-root=${targetPath} --overwrite --language=javascript-typescript 1> ${path.join(ROOT_DIR, "codeql-out", `${path.basename(targetPath)}-codeql-out.txt`)} 2> ${path.join(ROOT_DIR, "codeql-out", `${path.basename(targetPath)}-codeql-err.txt`)}`) return pathToDatabase; } catch (err) { console.error(`error while creating database: ${err}`); @@ -130,7 +130,6 @@ const extractTypesAndLocations = ( const typesAndLocationsContent = fs.readFileSync(pathToDecodedJSON); const locationsAndTypes = parseCodeQLLocationsAndTypes(JSON.parse(typesAndLocationsContent.toString())); const typesAndLocations = parseCodeQLTypesAndLocations(JSON.parse(typesAndLocationsContent.toString())); - console.log("extractTypesAndLocations result: ", typesAndLocations) return { locationToType: locationsAndTypes, typeToLocation: typesAndLocations }; } @@ -758,7 +757,6 @@ const getRelevantHeaders3 = ( ) => { // console.log("getRelevantHeaders3 start: ", Date.now()) const obj = generateTargetTypes3(pathToCodeQL, pathToQuery, pathToDatabase, outDir, holeType, relevantTypes); - console.log("target types:", obj) const targetTypes = obj.targetTypes; const knownNormalForms = obj.knownNormalForms; const relevantHeaders = new Set(); @@ -1110,10 +1108,8 @@ const getRelevantHeaders4 = ( // if it's an arrow type, recurse on the return type. // if it's a tuple type, recurse on the components. const relevantHeaders = new Set(); - console.log("headers: ", headers) const targetTypes = getTargetTypes(pathToCodeQL, pathToQueryDir, pathToDatabase, outDir, relevantTypes, holeType); - console.log("targetTypes", targetTypes); headers.forEach(header => { if (isRelevantHeader(pathToCodeQL, pathToQueryDir, pathToDatabase, outDir, header, targetTypes, relevantTypes, knownTypeLocations)) { @@ -1247,8 +1243,6 @@ const isRelevantHeaderHelper = ( relevantTypes: Map, knownTypeLocations: { locationToType: Map, typeToLocation: Map } ): boolean => { - console.log("===helper===") - console.log(`typ: ${JSON.stringify(typ)}`) if (targetTypes.has(typ.typeName)) { return true; } @@ -1310,7 +1304,6 @@ const isConsistent = ( comparisonTypes: string[], knownTypeLocations: { locationToType: Map, typeToLocation: Map } ): boolean => { - console.log(`===isConsistent===`) // TODO: this is still too slow. let's just import everything and compile everything // TODO: abstract this diff --git a/src/constants.ts b/src/constants.ts index 2df6b47..ca09b01 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,13 +1,31 @@ +// import * as path from "path"; +// import * as process from "process"; +// +// +// const ROOT_DIR = process.cwd(); +// const CODEQL_PATH = path.join(ROOT_DIR, "codeql", "codeql"); +// const QUERY_DIR = path.join("/", "home", "jacob", "projects", "context-extractor", "queries", "codeql-custom-queries-javascript"); +// const TARGET_DIR = path.join("/", "home", "jacob", "projects", "context-extractor", "targets"); +// const TODO_DIR = path.join("/", "home", "jacob", "projects", "context-extractor", "targets", "todo"); +// const PLAYLIST_DIR = path.join("/", "home", "jacob", "projects", "context-extractor", "targets", "playlist"); +// const PASSWORDS_DIR = path.join("/", "home", "jacob", "projects", "context-extractor", "targets", "passwords"); +// const BOOKING_DIR = path.join("/", "home", "jacob", "projects", "context-extractor", "targets", "booking"); +// const EMOJIPAINT_DIR = path.join("/", "home", "jacob", "projects", "context-extractor", "targets", "emojipaint"); +// +// export { CODEQL_PATH, ROOT_DIR, QUERY_DIR, TARGET_DIR, TODO_DIR, PLAYLIST_DIR, PASSWORDS_DIR, BOOKING_DIR, EMOJIPAINT_DIR }; import * as path from "path"; +import * as process from "process"; -const CODEQL_PATH = path.join("/", "opt", "codeql", "codeql"); -const ROOT_DIR = path.join("/", "home", "jacob", "projects", "context-extractor"); -const QUERY_DIR = path.join("/", "home", "jacob", "projects", "context-extractor", "queries", "codeql-custom-queries-javascript"); -const TARGET_DIR = path.join("/", "home", "jacob", "projects", "context-extractor", "targets"); -const TODO_DIR = path.join("/", "home", "jacob", "projects", "context-extractor", "targets", "todo"); -const PLAYLIST_DIR = path.join("/", "home", "jacob", "projects", "context-extractor", "targets", "playlist"); -const PASSWORDS_DIR = path.join("/", "home", "jacob", "projects", "context-extractor", "targets", "passwords"); -const BOOKING_DIR = path.join("/", "home", "jacob", "projects", "context-extractor", "targets", "booking"); -const EMOJIPAINT_DIR = path.join("/", "home", "jacob", "projects", "context-extractor", "targets", "emojipaint"); -export { CODEQL_PATH, ROOT_DIR, QUERY_DIR, TARGET_DIR, TODO_DIR, PLAYLIST_DIR, PASSWORDS_DIR, BOOKING_DIR, EMOJIPAINT_DIR }; +const ROOT_DIR = path.join("/", "app"); +const DEPS_DIR = path.join(ROOT_DIR, "deps"); +const CODEQL_PATH = path.join(DEPS_DIR, "codeql", "codeql"); +const QUERY_DIR = path.join(DEPS_DIR, "queries", "codeql-custom-queries-javascript"); +const TARGET_DIR = path.join(DEPS_DIR, "targets"); +const TODO_DIR = path.join(DEPS_DIR, "targets", "todo"); +const PLAYLIST_DIR = path.join(DEPS_DIR, "targets", "playlist"); +const PASSWORDS_DIR = path.join(DEPS_DIR, "targets", "passwords"); +const BOOKING_DIR = path.join(DEPS_DIR, "targets", "booking"); +const EMOJIPAINT_DIR = path.join(DEPS_DIR, "targets", "emojipaint"); + +export { CODEQL_PATH, ROOT_DIR, DEPS_DIR, QUERY_DIR, TARGET_DIR, TODO_DIR, PLAYLIST_DIR, PASSWORDS_DIR, BOOKING_DIR, EMOJIPAINT_DIR }; diff --git a/src/core.ts b/src/core.ts index 6196fdf..dcad22f 100644 --- a/src/core.ts +++ b/src/core.ts @@ -320,12 +320,12 @@ const extractRelevantTypes = async ( depth: number): Promise> => { if (!foundSoFar.has(typeName)) { - foundSoFar.set(typeName, typeSpan); + foundSoFar.set(typeName, fullHoverResult); outputFile.write(`${fullHoverResult};\n`); // approach 1: go to type definition and hover const content = fs.readFileSync(currentFile.slice(7), "utf8"); - const charInLine = execSync(`wc -m <<< "${content.split("\n")[linePosition].slice(characterPosition)}"`); + const charInLine = execSync(`wc -m <<< "${content.split("\n")[linePosition].slice(characterPosition)}"`, { shell: "/bin/bash" }); for (let i = 0; i < Math.min(parseInt(charInLine.toString()), typeSpan.length); i++) { try { diff --git a/src/index.ts b/src/index.ts index fcfedf0..e1d33f8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1 +1 @@ -export { extract, extractWithCodeQL } from "./main" +export { extractWithCodeQL } from "./main" diff --git a/src/main.ts b/src/main.ts index 41bebf8..03a7d2e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,7 +4,7 @@ import * as fs from "fs"; import * as path from "path"; import { extractRelevantTypes, getHoleContext, extractRelevantContext } from "./core"; import { createDatabaseWithCodeQL, extractRelevantTypesWithCodeQL, extractRelevantContextWithCodeQL, extractHeadersWithCodeQL, getRelevantHeaders, extractHoleType, getRelevantHeaders3, getRelevantHeaders4, extractTypesAndLocations } from "./codeql"; -import { CODEQL_PATH, QUERY_DIR } from "./constants.js"; +import { CODEQL_PATH, DEPS_DIR, QUERY_DIR, ROOT_DIR } from "./constants.js"; // sketchPath: /home//path/to/sketch/dir/sketch.ts export const extract = async (sketchPath: string) => { @@ -161,48 +161,51 @@ export const extract = async (sketchPath: string) => { outputFile, 1 ); - console.log("relevantTypes:", relevantTypes); + // console.log("relevantTypes:", relevantTypes); - logFile.end(); - logFile.close(); - outputFile.end(); - outputFile.close(); + // logFile.end(); + // logFile.close(); + // outputFile.end(); + // outputFile.close(); const preludeContent = fs.readFileSync(`${rootPath}/prelude.ts`).toString("utf8"); - const relevantContext = extractRelevantContext(preludeContent, relevantTypes); + const relevantHeaders = extractRelevantContext(preludeContent, relevantTypes); // console.log(relevantContext); - return { holeContext: holeContext, relevantTypes: Array.from(relevantTypes), relevantContext: relevantContext }; + // return { holeContext: holeContext, relevantTypes: Array.from(relevantTypes), relevantContext: relevantContext }; + return { hole: holeContext.functionTypeSpan, relevantTypes: Array.from(relevantTypes, ([k, v]) => { return v }), relevantHeaders: relevantHeaders }; } export const extractWithCodeQL = async (sketchPath: string) => { const start = Date.now(); - console.log("start: ", start) + console.log("ROOT_DIR: ", ROOT_DIR); + console.log("DEPS_DIR: ", DEPS_DIR); + console.log("CODEQL_PATH: ", CODEQL_PATH); const targetPath = path.dirname(sketchPath); try { // extraction const databasePath = createDatabaseWithCodeQL(CODEQL_PATH, targetPath); const holeType = extractHoleType(CODEQL_PATH, path.join(QUERY_DIR, "hole.ql"), databasePath, targetPath); - console.log("holeType: ", holeType); + // console.log("holeType: ", holeType); const relevantTypes = extractRelevantTypesWithCodeQL(CODEQL_PATH, path.join(QUERY_DIR, "relevant-types.ql"), databasePath, targetPath); // console.log("relevantTypes: ", Array.from(relevantTypes, ([k, v]) => { return v.typeAliasDeclaration; })); - console.log("relevantTypes: ", relevantTypes) + // console.log("relevantTypes: ", relevantTypes) const headers = extractHeadersWithCodeQL(CODEQL_PATH, path.join(QUERY_DIR, "vars.ql"), databasePath, targetPath); - console.log("headers: ", headers) + // console.log("headers: ", headers) // const relevantContext = extractRelevantContextWithCodeQL(CODEQL_PATH, path.join(QUERY_DIR, "types.ql"), databasePath, targetPath, headers, relevantTypes); // console.log("relevantContext: ", relevantContext); // const relevantHeaders = getRelevantHeaders(CODEQL_PATH, path.join(QUERY_DIR, "types.ql"), databasePath, targetPath, headers, holeType); // console.log("relevantHeaders: ", relevantHeaders); const knownTypeLocations = extractTypesAndLocations(CODEQL_PATH, path.join(QUERY_DIR, "imports.ql"), databasePath, targetPath); - console.log("known type locations: ", knownTypeLocations) + // console.log("known type locations: ", knownTypeLocations) // NOTE: switch between the two header extraction methods // const relevantHeaders = getRelevantHeaders3(CODEQL_PATH, path.join(QUERY_DIR, "types.ql"), databasePath, targetPath, headers, holeType, relevantTypes); // console.log("relevantHeaders: ", Array.from(relevantHeaders)); const relevantHeaders = getRelevantHeaders4(CODEQL_PATH, QUERY_DIR, databasePath, targetPath, headers, holeType, relevantTypes, knownTypeLocations); - console.log("relevantHeaders: ", Array.from(relevantHeaders)); + // console.log("relevantHeaders: ", Array.from(relevantHeaders)); const end = Date.now() - console.log("end: ", end) - console.log("elapsed: ", end - start) + // console.log("end: ", end) + // console.log("elapsed: ", end - start) return { hole: holeType.typeName, relevantTypes: Array.from(relevantTypes, ([k, v]) => { return JSON.stringify(v) }), relevantHeaders: Array.from(relevantHeaders) }; } catch (err) { diff --git a/src/starcoder-exhaustive-retrieval.mjs b/src/starcoder-exhaustive-retrieval.mjs new file mode 100644 index 0000000..b869ddb --- /dev/null +++ b/src/starcoder-exhaustive-retrieval.mjs @@ -0,0 +1,317 @@ +import { execSync } from "child_process"; +import * as fs from "fs"; +import * as path from "path"; +import { joinFiles, generateStarcoderExhaustiveRetrievalPrompt } from "./testrunner-core.mjs"; + +/* PHASE 1: INITIALIZATION */ + +// initialize run data +const runData = { + "option-llm": "", + "option-source_path": "", + "option-expected_type": "", + "option-relevant_ctx": "", + "option-error_rounds_max": "", + "option-temperature": "", + "commit": "", + "start-time": "", + "round-usage-prompt-tokens": "", + "round-usage-completion-tokens": "", + "round-usage-total-tokens": "", + "end-time": "", + "tests-total": "", + "tests-pass": "", + "tests-fail": "", + "derived-time-elapsed": "", + "derived-percent-tests": "", + "derived-err-rounds-used": "", + "derived-total-tokens-used": "", + "derived-final-parses": "", + "derived-final-static-errors": "", +}; + + +// node testrunner $bashTimestamp $unixTimestamp --run-name \"$run_name\" --type-constraint \"$type_constraint\" --relevant-ctx \"$relevant_ctx\" --error-rounds-max \"$error_rounds_max\" --source-folder \"$source_folder\" +console.log(process.argv); +const runName = process.argv[3]; +const temperature = process.argv[5]; +const errorRoundsMax = process.argv[7]; +const sourceFolder = process.argv[9]; +const bashTimestamp = process.argv[10]; + +const splitted = sourceFolder.split("/"); +let source = splitted[splitted.length - 2]; +runData["tests-pass"] = "0"; +runData["derived-percent-tests"] = "0"; + +switch (source) { + case "todo": + runData["tests-total"] = "12"; + runData["tests-fail"] = "12"; + break; + case "playlist": + runData["tests-total"] = "15"; + runData["tests-fail"] = "15"; + break; + case "passwords": + runData["tests-total"] = "12"; + runData["tests-fail"] = "12"; + break; + case "booking": + runData["tests-total"] = "8"; + runData["tests-fail"] = "8"; + break; + case "emojipaint": + runData["tests-total"] = "10"; + runData["tests-fail"] = "10"; + break; +} + +console.log(`source: ${source}`); + + +runData["option-source_path"] = sourceFolder; +runData["option-error_rounds_max"] = errorRoundsMax; +runData["commit"] = ""; +runData["derived-final-parses"] = "false"; +runData["derived-final-static-errors"] = "0"; + +// directory defintions +const projectRoot = process.cwd(); +const runID = `${runName}-${source}-exhaustive-${bashTimestamp}`; +const outDirRoot = path.join(projectRoot, "starcoder-exhaustive-retrieval", "out", runID); +fs.mkdirSync(outDirRoot, { recursive: true }, (err) => { if (err) throw err; }); +const logDirRoot = path.join(projectRoot, "starcoder-exhaustive-retrieval", "testlog"); +const backupDir = path.join(projectRoot, "starcoder-exhaustive-retrieval", "backup", `${runID}`); +fs.mkdirSync(backupDir, { recursive: true }, (err) => { if (err) throw err; }); + + +/* PHASE 3: LLM CODE SYNTHESIS */ + + +// ask LLM to complete the sketch using the returned types +console.log("\n\n=== Generating Prompt ===\n\n"); +const sketchFilePath = `${path.join(sourceFolder, "starcoder-sketch.ts")}`; +let sketchFileContent = fs.readFileSync(sketchFilePath, "utf8"); +console.log("sketchFileContent: ", sketchFileContent) + +const exhaustiveCtx = fs.readFileSync(`${path.join(sourceFolder, "prelude.ts")}`) +const prompt = generateStarcoderExhaustiveRetrievalPrompt(sketchFileContent, exhaustiveCtx); +console.log(prompt); + + +let totalTokensUsed = 0; +const callStarcoder = async () => { + const response = await fetch("http://20.115.44.142:8080/completion", { + method: "POST", + body: JSON.stringify({ + prompt: prompt, + n_predict: 1000, + stop: ["\n}"], + model: "starcoder2" + }), + headers: { + "Content-Type": "application/json" + } + }); + return await response.json(); +} +let llmResult = await callStarcoder(); + + +console.log(JSON.stringify(llmResult, "", 2)); +fs.writeFileSync(`${path.join(outDirRoot, "llm_out.json")}`, JSON.stringify(llmResult, "", 2) + "\n"); +// prompt.push(llmResult.choices[0].message); + +// runData["option-llm"] = model; +// runData["option-temperature"] = "0.6"; +// runData["round-usage-prompt-tokens"] += llmResult.usage.prompt_tokens + ","; +// runData["round-usage-completion-tokens"] += llmResult.usage.completion_tokens + ","; +// runData["round-usage-total-tokens"] += llmResult.usage.total_tokens + ","; +// totalTokensUsed += llmResult.usage.total_tokens; + +// write completion to sketch +// const llmCompletedSketch = fillHole(sketchFileContent, llmResult["content"]); +fs.writeFileSync(`${path.join(sourceFolder, "exhaustive_llm_completed_sketch.ts")}`, sketchFileContent + llmResult.content + "\n}"); + + +/* PHASE 4: ERROR CORRECTION */ +console.log("\n\n=== ERROR CORRECTION ===\n\n"); + +// run tsc to check for syntax errors +let usedErrorRounds = 0; + +const testSuiteContent = joinFiles([ + path.join(sourceFolder, "prelude.ts"), + path.join(sourceFolder, "exhaustive_llm_completed_sketch.ts"), + path.join(sourceFolder, "epilogue.ts"), +]); + +fs.writeFileSync(`${path.join(sourceFolder, "exhaustive_test_suite.ts")}`, testSuiteContent); + +for (let i = 0; i < parseInt(errorRoundsMax) + 1; i++) { + try { + // res = execSync(`tsc ${ sourceFolder } llm_completed_sketch.ts`); + execSync(`tsc ${path.join(sourceFolder, "exhaustive_test_suite.ts")}`); + // console.log(`== ${ res }== `) + break; + } catch (err) { + if (i >= parseInt(errorRoundsMax)) { + console.log("\n\n=== FAILED TO COMPILE ===\n\n"); + runData["end-time"] = Math.floor(Date.now() / 1000).toString(); + + // capture error messages + const errorMsg = err.stdout.toString(); + console.log(`error: \n ${err.toString()} `); + console.log(`stdout: \n ${errorMsg} `); + + // capture number of static errors + const numErrors = execSync(`echo \"${escape(err.stdout.toString())}\" | grep "error TS" | wc -l`); + console.log("numErrors: ", numErrors.toString()); + runData["derived-final-static-errors"] = numErrors.toString().split("\n")[0]; + + runData["derived-time-elapsed"] = (parseInt(runData["end-time"]) - parseInt(runData["start-time"])).toString(); + runData["derived-err-rounds-used"] = usedErrorRounds; + runData["derived-total-tokens-used"] = totalTokensUsed; + console.log(runData); + + // const backupDir = `/home/jacob/projects/testtslspclient/backup/${runName + "-" + bashTimestamp + `-${source}-fail`}`; + // fs.mkdirSync(`${backupDir}`, { recursive: true }, (err) => { if (err) throw err; }); + execSync(`cp -r ${path.join(sourceFolder, "*.ts")} ${backupDir}`) + execSync(`cp ${path.join(projectRoot, "*.sh")} ${backupDir}`) + execSync(`cp -r ${path.join(projectRoot, "src")} ${backupDir}`) + execSync(`cp ${path.join(logDirRoot, `${runID}.log`)} ${backupDir}`) // TODO: match the log path with run.sh + execSync(`cp ${path.join(outDirRoot, "llm_out.json")} ${backupDir}`) + + let runDataStr = ""; + for (const [k, v] of Object.entries(runData)) { + runDataStr += k + ":" + v + "\n"; + } + fs.writeFileSync(`${path.join(outDirRoot, "run.data")}`, runDataStr); + fs.writeFileSync(`${path.join(outDirRoot, "FAIL")}`, runDataStr); + fs.writeFileSync(`${path.join(backupDir, "run.data")}`, runDataStr); + fs.writeFileSync(`${path.join(backupDir, "FAIL")}`, runDataStr); + + execSync(`rm -f ${path.join(sourceFolder, "erroneous*")} ${path.join(sourceFolder, "completed_sketch*")} ${path.join(sourceFolder, "exhaustive_llm_completed_sketch*")} ${path.join(sourceFolder, "exhaustive_test_suite*")} ${path.join(sourceFolder, "*.js")}`); + process.exit(1); + } else { + + console.log(`\n\n=== Error Correction Round ${i + 1} ===\n\n`); + usedErrorRounds += 1; + + // capture error messages + const errorMsg = err.stdout.toString(); + console.log(`error: \n ${err.toString()}`); + console.log(`stdout: \n ${errorMsg}`); + + // capture number of static errors + const numErrors = execSync(`echo \"${escape(err.stdout.toString())}\" | grep "error TS" | wc -l`); + console.log("numErrors: ", numErrors.toString()); + runData["derived-final-static-errors"] = numErrors.toString().split("\n")[0]; + + // console.log(`errorCorrectionPrompt:\n${JSON.stringify(errorCorrectionPrompt, "", 2)}`); + + // call the llm again + llmResult = await callStarcoder(); + + console.log(JSON.stringify(llmResult, "", 2)) + fs.writeFileSync(path.join(outDirRoot, "llm_out.json"), JSON.stringify(llmResult, "", 2) + "\n"); + // prompt.push(llmResult["content"]); + + // runData["round-usage-prompt-tokens"] += llmResult.usage.prompt_tokens + ","; + // runData["round-usage-completion-tokens"] += llmResult.usage.completion_tokens + ","; + // runData["round-usage-total-tokens"] += llmResult.usage.total_tokens + ","; + // totalTokensUsed += llmResult.usage.total_tokens; + + fs.writeFileSync(`${path.join(sourceFolder, "exhaustive_llm_completed_sketch.ts")}`, sketchFileContent + llmResult.content + "\n}"); + const testSuiteContent = joinFiles([ + path.join(sourceFolder, "prelude.ts"), + path.join(sourceFolder, "exhaustive_llm_completed_sketch.ts"), + path.join(sourceFolder, "epilogue.ts"), + ]); + + fs.writeFileSync(`${path.join(sourceFolder, "exhaustive_test_suite.ts")}`, testSuiteContent); + + } + } +} + +runData["derived-err-rounds-used"] = usedErrorRounds; +// runData["derived-total-tokens-used"] = totalTokensUsed; + + +/* PHASE 5: TEST SUITE */ + + +console.log("\n\n=== Running Test Suite ===\n\n") +try { + const testResult = execSync(`node ${path.join(sourceFolder, "exhaustive_test_suite.js")}`); + console.log("testResult: ", testResult.toString().split("\n")); + const splitTestResult = testResult.toString().split("\n"); + console.log(splitTestResult) + runData["tests-total"] = splitTestResult[splitTestResult.length - 2].split(" ")[3]; + runData["tests-pass"] = splitTestResult[splitTestResult.length - 2].split(" ")[1]; + runData["tests-fail"] = (parseInt(runData["tests-total"]) - parseInt(runData["tests-pass"])).toString(); + runData["derived-percent-tests"] = (parseInt(runData["tests-pass"]) / parseInt(runData["tests-total"])).toString(); + +} catch (err) { + console.log("error!") + console.log("testResult: ", err.toString().split("\n")); + runData["end-time"] = Math.floor(Date.now() / 1000).toString(); + runData["derived-time-elapsed"] = (parseInt(runData["end-time"]) - parseInt(runData["start-time"])).toString(); + console.log(runData); + + // const backupDir = `/home/jacob/projects/testtslspclient/backup/${runName + "-" + bashTimestamp + `-${source}-fail`}`; + // fs.mkdirSync(`${backupDir}`, { recursive: true }, (err) => { if (err) throw err; }); + // execSync(`zip -r ${backupDir}/${runName + "-" + runData["start-time"]}.zip "run_tests.sh" "collate_data.sh" "collated_data.csv" "src" "targets/target-full" "testlog" "testout"`) + execSync(`cp -r ${path.join(sourceFolder, "*.ts")} ${backupDir}`) + execSync(`cp ${path.join(projectRoot, "*.sh")} ${backupDir}`) + execSync(`cp -r ${path.join(projectRoot, "src")} ${backupDir}`) + execSync(`cp ${path.join(logDirRoot, `${runID}.log`)} ${backupDir}`) // TODO: match the log path with run.sh + execSync(`cp ${path.join(outDirRoot, "llm_out.json")} ${backupDir}`) + + let runDataStr = ""; + for (const [k, v] of Object.entries(runData)) { + runDataStr += k + ":" + v + "\n"; + } + + fs.writeFileSync(`${path.join(outDirRoot, "run.data")}`, runDataStr); + fs.writeFileSync(`${path.join(outDirRoot, "FAIL")}`, runDataStr); + fs.writeFileSync(`${path.join(backupDir, "run.data")}`, runDataStr); + fs.writeFileSync(`${path.join(backupDir, "FAIL")}`, runDataStr); + + execSync(`rm -f ${path.join(sourceFolder, "erroneous*")} ${path.join(sourceFolder, "completed_sketch*")} ${path.join(sourceFolder, "exhaustive_llm_completed_sketch*")} ${path.join(sourceFolder, "exhaustive_test_suite*")} ${path.join(sourceFolder, "*.js")}`); + process.exit(1); +} + + +/* PHASE 6: BACKUPS */ + + +// back up and clean up +runData["end-time"] = Math.floor(Date.now() / 1000).toString(); +runData["derived-time-elapsed"] = (parseInt(runData["end-time"]) - parseInt(runData["start-time"])).toString(); +runData["derived-final-parses"] = "true"; +console.log(runData); + +// const backupDir = `/home/jacob/projects/testtslspclient/backup/${runName + "-" + bashTimestamp + `-${source}-pass`}`; +// fs.mkdirSync(`${backupDir}`, { recursive: true }, (err) => { if (err) throw err; }); +// execSync(`zip -r ${backupDir}/${runName + "-" + runData["start-time"]}.zip "run_tests.sh" "collate_data.sh" "collated_data.csv" "src" "targets/target-full" "testlog" "testout"`) +execSync(`cp -r ${path.join(sourceFolder, "*.ts")} ${backupDir}`) +execSync(`cp ${path.join(projectRoot, "*.sh")} ${backupDir}`) +execSync(`cp -r ${path.join(projectRoot, "src")} ${backupDir}`) +execSync(`cp ${path.join(logDirRoot, `${runID}.log`)} ${backupDir}`) // TODO: match the log path with run.sh +execSync(`cp ${path.join(outDirRoot, "llm_out.json")} ${backupDir}`) + +let runDataStr = ""; +for (const [k, v] of Object.entries(runData)) { + runDataStr += k + ":" + v + "\n"; +} + +fs.writeFileSync(`${path.join(outDirRoot, "run.data")}`, runDataStr); +fs.writeFileSync(`${path.join(outDirRoot, "PASS")}`, runDataStr); +fs.writeFileSync(`${path.join(backupDir, "run.data")}`, runDataStr); +fs.writeFileSync(`${path.join(backupDir, "PASS")}`, runDataStr); + +execSync(`rm -f ${path.join(sourceFolder, "erroneous*")} ${path.join(sourceFolder, "completed_sketch*")} ${path.join(sourceFolder, "exhaustive_llm_completed_sketch*")} ${path.join(sourceFolder, "exhaustive_test_suite*")} ${path.join(sourceFolder, "*.js")}`); +process.exit(0); diff --git a/src/starcoder-types-and-headers.mjs b/src/starcoder-types-and-headers.mjs new file mode 100644 index 0000000..d366713 --- /dev/null +++ b/src/starcoder-types-and-headers.mjs @@ -0,0 +1,347 @@ +import { execSync } from "child_process"; +import * as fs from "fs"; +import * as path from "path"; +import { joinFiles, generateStarcoderTypesAndHeadersPrompt } from "./testrunner-core.mjs"; +import { extractWithCodeQL } from "../dist/index.js"; + +/* PHASE 1: INITIALIZATION */ + +// initialize run data +const runData = { + "option-llm": "", + "option-source_path": "", + "option-expected_type": "", + "option-relevant_ctx": "", + "option-error_rounds_max": "", + "option-temperature": "", + "commit": "", + "start-time": "", + "round-usage-prompt-tokens": "", + "round-usage-completion-tokens": "", + "round-usage-total-tokens": "", + "end-time": "", + "tests-total": "", + "tests-pass": "", + "tests-fail": "", + "derived-time-elapsed": "", + "derived-percent-tests": "", + "derived-err-rounds-used": "", + "derived-total-tokens-used": "", + "derived-final-parses": "", + "derived-final-static-errors": "", +}; + + +// node testrunner $bashTimestamp $unixTimestamp --run-name \"$run_name\" --type-constraint \"$type_constraint\" --relevant-ctx \"$relevant_ctx\" --error-rounds-max \"$error_rounds_max\" --source-folder \"$source_folder\" +console.log(process.argv); +const bashTimestamp = process.argv[2]; +const unixTimestamp = process.argv[3]; +const runName = process.argv[5]; +const typeConstraint = process.argv[7]; +const contextConstraint = process.argv[9]; +const errorRoundsMax = process.argv[11]; +const sourceFolder = process.argv[13]; + +const splitted = sourceFolder.split("/"); +let source = splitted[splitted.length - 2]; +runData["tests-pass"] = "0"; +runData["derived-percent-tests"] = "0"; + +switch (source) { + case "todo": + runData["tests-total"] = "12"; + runData["tests-fail"] = "12"; + break; + case "playlist": + runData["tests-total"] = "15"; + runData["tests-fail"] = "15"; + break; + case "passwords": + runData["tests-total"] = "12"; + runData["tests-fail"] = "12"; + break; + case "booking": + runData["tests-total"] = "8"; + runData["tests-fail"] = "8"; + break; + case "emojipaint": + runData["tests-total"] = "10"; + runData["tests-fail"] = "10"; + break; +} + +console.log(`source: ${source}`); + + +runData["option-source_path"] = sourceFolder; +runData["option-expected_type"] = typeConstraint; +runData["option-relevant_ctx"] = contextConstraint; +runData["option-error_rounds_max"] = errorRoundsMax; +runData["commit"] = ""; +runData["derived-final-parses"] = "false"; +runData["derived-final-static-errors"] = "0"; +runData["start-time"] = unixTimestamp; + +// directory defintions +const projectRoot = process.cwd(); +const runID = `${runName}-${source}-types-and-headers-${bashTimestamp}`; +const outDirRoot = path.join(projectRoot, "starcoder-types-and-headers", "out", runID); +fs.mkdirSync(outDirRoot, { recursive: true }, (err) => { if (err) throw err; }); +const logDirRoot = path.join(projectRoot, "starcoder-types-and-headers", "testlog"); +const backupDir = path.join(projectRoot, "starcoder-types-and-headers", "backup", `${runID}`); +fs.mkdirSync(backupDir, { recursive: true }, (err) => { if (err) throw err; }); + + +/* PHASE 2: TYPE EXTRACTION */ + + +const res = await extractWithCodeQL(path.join(sourceFolder, "sketch.ts")); +const holeType = res.hole; +const relevantTypes = res.relevantTypes; +const relevantHeaders = res.relevantHeaders; + +// create a new sketch that replaces the hole with an open curly brace (for starcoder comaptibility) + +const sketchFilePath = `${path.join(sourceFolder, "starcoder-sketch.ts")}`; +const sketchFileContent = fs.readFileSync(sketchFilePath, "utf8"); +// let targetTypes = null; +// if (typeConstraint === "true") { +// console.log("\n\n=== Extracting Types === \n\n"); +// execSync(`node src / app.js ${ sourceFolder } sketch.ts`) +// targetTypes = fs.readFileSync("output.txt", "utf8"); +// } + + +/* PHASE 3: LLM CODE SYNTHESIS */ + + +// ask LLM to complete the sketch using the returned types +console.log("\n\n=== Generating Prompt ===\n\n"); +let prompt = ""; +if (typeConstraint === "true" && contextConstraint === "true") { + prompt = generateStarcoderTypesAndHeadersPrompt(sketchFileContent, relevantTypes, relevantHeaders); +} else if (typeConstraint === "true") { + prompt = generateStarcoderTypesAndHeadersPrompt(sketchFileContent, relevantTypes, null); +} else if (contextConstraint === "true") { + prompt = generateStarcoderTypesAndHeadersPrompt(sketchFileContent, null, relevantHeaders); +} else { + prompt = generateStarcoderTypesAndHeadersPrompt(sketchFileContent, null, null); +} +// console.log(JSON.stringify(prompt, "", 2)); +console.log("prompt: ", prompt); + + +let totalTokensUsed = 0; +const callStarcoder = async () => { + const response = await fetch("http://20.115.44.142:8080/completion", { + method: "POST", + body: JSON.stringify({ + prompt: prompt, + n_predict: 1000, + stop: ["\n}"], + model: "starcoder2" + }), + headers: { + "Content-Type": "application/json" + } + }); + return await response.json(); +} +let llmResult = await callStarcoder(); + +console.log(JSON.stringify(llmResult, "", 2)); +fs.writeFileSync(`${path.join(outDirRoot, "llm_out.json")}`, JSON.stringify(llmResult, "", 2) + "\n"); +// prompt.push(llmResult.choices[0].message); + +// runData["option-llm"] = model; +// runData["option-temperature"] = "0.6"; +// runData["round-usage-prompt-tokens"] += llmResult.usage.prompt_tokens + ","; +// runData["round-usage-completion-tokens"] += llmResult.usage.completion_tokens + ","; +// runData["round-usage-total-tokens"] += llmResult.usage.total_tokens + ","; +// totalTokensUsed += llmResult.usage.total_tokens; + +// write completion to sketch +// const llmCompletedSketch = fillHole(sketchFileContent, llmResult["content"]); +fs.writeFileSync(`${path.join(sourceFolder, "types_and_headers_llm_completed_sketch.ts")}`, sketchFileContent + llmResult.content + "\n}"); + + +/* PHASE 4: ERROR CORRECTION */ +console.log("\n\n=== ERROR CORRECTION ===\n\n"); + +// run tsc to check for syntax errors +let usedErrorRounds = 0; + +const testSuiteContent = joinFiles([ + path.join(sourceFolder, "prelude.ts"), + path.join(sourceFolder, "types_and_headers_llm_completed_sketch.ts"), + path.join(sourceFolder, "epilogue.ts"), +]); + +fs.writeFileSync(`${path.join(sourceFolder, "types_and_headers_test_suite.ts")}`, testSuiteContent); + +for (let i = 0; i < parseInt(errorRoundsMax) + 1; i++) { + try { + // res = execSync(`tsc ${ sourceFolder } llm_completed_sketch.ts`); + execSync(`tsc ${path.join(sourceFolder, "types_and_headers_test_suite.ts")}`); + // console.log(`== ${ res }== `) + break; + } catch (err) { + if (i >= parseInt(errorRoundsMax)) { + console.log("\n\n=== FAILED TO COMPILE ===\n\n"); + runData["end-time"] = Math.floor(Date.now() / 1000).toString(); + + // capture error messages + const errorMsg = err.stdout.toString(); + console.log(`error: \n ${err.toString()} `); + console.log(`stdout: \n ${errorMsg} `); + + // capture number of static errors + const numErrors = execSync(`echo \"${escape(err.stdout.toString())}\" | grep "error TS" | wc -l`); + console.log("numErrors: ", numErrors.toString()); + runData["derived-final-static-errors"] = numErrors.toString().split("\n")[0]; + + runData["derived-time-elapsed"] = (parseInt(runData["end-time"]) - parseInt(runData["start-time"])).toString(); + runData["derived-err-rounds-used"] = usedErrorRounds; + runData["derived-total-tokens-used"] = totalTokensUsed; + console.log(runData); + + // const backupDir = `/home/jacob/projects/testtslspclient/backup/${runName + "-" + bashTimestamp + `-${source}-fail`}`; + // fs.mkdirSync(`${backupDir}`, { recursive: true }, (err) => { if (err) throw err; }); + execSync(`cp -r ${path.join(sourceFolder, "*.ts")} ${backupDir}`) + execSync(`cp ${path.join(projectRoot, "*.sh")} ${backupDir}`) + execSync(`cp -r ${path.join(projectRoot, "src")} ${backupDir}`) + execSync(`cp ${path.join(logDirRoot, `${runID}.log`)} ${backupDir}`) // TODO: match the log path with run.sh + execSync(`cp ${path.join(outDirRoot, "llm_out.json")} ${backupDir}`) + + let runDataStr = ""; + for (const [k, v] of Object.entries(runData)) { + runDataStr += k + ":" + v + "\n"; + } + fs.writeFileSync(`${path.join(outDirRoot, "run.data")}`, runDataStr); + fs.writeFileSync(`${path.join(outDirRoot, "FAIL")}`, runDataStr); + fs.writeFileSync(`${path.join(backupDir, "run.data")}`, runDataStr); + fs.writeFileSync(`${path.join(backupDir, "FAIL")}`, runDataStr); + + execSync(`rm -f ${path.join(sourceFolder, "erroneous*")} ${path.join(sourceFolder, "completed_sketch*")} ${path.join(sourceFolder, "types_and_headers_llm_completed_sketch*")} ${path.join(sourceFolder, "types_and_headers_test_suite*")} ${path.join(sourceFolder, "*.js")}`); + process.exit(1); + } else { + + console.log(`\n\n=== Error Correction Round ${i + 1} ===\n\n`); + usedErrorRounds += 1; + + // capture error messages + const errorMsg = err.stdout.toString(); + console.log(`error: \n ${err.toString()}`); + console.log(`stdout: \n ${errorMsg}`); + + // capture number of static errors + const numErrors = execSync(`echo \"${escape(err.stdout.toString())}\" | grep "error TS" | wc -l`); + console.log("numErrors: ", numErrors.toString()); + runData["derived-final-static-errors"] = numErrors.toString().split("\n")[0]; + + // console.log(`errorCorrectionPrompt:\n${JSON.stringify(errorCorrectionPrompt, "", 2)}`); + + // call the llm again + llmResult = await callStarcoder(); + + console.log(JSON.stringify(llmResult, "", 2)) + fs.writeFileSync(path.join(outDirRoot, "llm_out.json"), JSON.stringify(llmResult, "", 2) + "\n"); + // prompt.push(llmResult["content"]); + + // runData["round-usage-prompt-tokens"] += llmResult.usage.prompt_tokens + ","; + // runData["round-usage-completion-tokens"] += llmResult.usage.completion_tokens + ","; + // runData["round-usage-total-tokens"] += llmResult.usage.total_tokens + ","; + // totalTokensUsed += llmResult.usage.total_tokens; + + fs.writeFileSync(`${path.join(sourceFolder, "types_and_headers_llm_completed_sketch.ts")}`, sketchFileContent + llmResult.content + "\n}"); + const testSuiteContent = joinFiles([ + path.join(sourceFolder, "prelude.ts"), + path.join(sourceFolder, "types_and_headers_llm_completed_sketch.ts"), + path.join(sourceFolder, "epilogue.ts"), + ]); + + fs.writeFileSync(`${path.join(sourceFolder, "types_and_headers_test_suite.ts")}`, testSuiteContent); + + } + } +} + +runData["derived-err-rounds-used"] = usedErrorRounds; +runData["derived-total-tokens-used"] = totalTokensUsed; + + +/* PHASE 5: TEST SUITE */ + + +console.log("\n\n=== Running Test Suite ===\n\n") +try { + const testResult = execSync(`node ${path.join(sourceFolder, "types_and_headers_test_suite.js")}`); + console.log("testResult: ", testResult.toString().split("\n")); + const splitTestResult = testResult.toString().split("\n"); + console.log(splitTestResult) + runData["tests-total"] = splitTestResult[splitTestResult.length - 2].split(" ")[3]; + runData["tests-pass"] = splitTestResult[splitTestResult.length - 2].split(" ")[1]; + runData["tests-fail"] = (parseInt(runData["tests-total"]) - parseInt(runData["tests-pass"])).toString(); + runData["derived-percent-tests"] = (parseInt(runData["tests-pass"]) / parseInt(runData["tests-total"])).toString(); + +} catch (err) { + console.log("error!") + console.log("testResult: ", err.toString().split("\n")); + runData["end-time"] = Math.floor(Date.now() / 1000).toString(); + runData["derived-time-elapsed"] = (parseInt(runData["end-time"]) - parseInt(runData["start-time"])).toString(); + console.log(runData); + + // const backupDir = `/home/jacob/projects/testtslspclient/backup/${runName + "-" + bashTimestamp + `-${source}-fail`}`; + // fs.mkdirSync(`${backupDir}`, { recursive: true }, (err) => { if (err) throw err; }); + // execSync(`zip -r ${backupDir}/${runName + "-" + runData["start-time"]}.zip "run_tests.sh" "collate_data.sh" "collated_data.csv" "src" "targets/target-full" "testlog" "testout"`) + execSync(`cp -r ${path.join(sourceFolder, "*.ts")} ${backupDir}`) + execSync(`cp ${path.join(projectRoot, "*.sh")} ${backupDir}`) + execSync(`cp -r ${path.join(projectRoot, "src")} ${backupDir}`) + execSync(`cp ${path.join(logDirRoot, `${runID}.log`)} ${backupDir}`) // TODO: match the log path with run.sh + execSync(`cp ${path.join(outDirRoot, "llm_out.json")} ${backupDir}`) + + let runDataStr = ""; + for (const [k, v] of Object.entries(runData)) { + runDataStr += k + ":" + v + "\n"; + } + + fs.writeFileSync(`${path.join(outDirRoot, "run.data")}`, runDataStr); + fs.writeFileSync(`${path.join(outDirRoot, "FAIL")}`, runDataStr); + fs.writeFileSync(`${path.join(backupDir, "run.data")}`, runDataStr); + fs.writeFileSync(`${path.join(backupDir, "FAIL")}`, runDataStr); + + execSync(`rm -f ${path.join(sourceFolder, "erroneous*")} ${path.join(sourceFolder, "completed_sketch*")} ${path.join(sourceFolder, "types_and_headers_llm_completed_sketch*")} ${path.join(sourceFolder, "types_and_headers_test_suite*")} ${path.join(sourceFolder, "*.js")}`); + process.exit(1); +} + + +/* PHASE 6: BACKUPS */ + + +// back up and clean up +runData["end-time"] = Math.floor(Date.now() / 1000).toString(); +runData["derived-time-elapsed"] = (parseInt(runData["end-time"]) - parseInt(runData["start-time"])).toString(); +runData["derived-final-parses"] = "true"; +console.log(runData); + +// const backupDir = `/home/jacob/projects/testtslspclient/backup/${runName + "-" + bashTimestamp + `-${source}-pass`}`; +// fs.mkdirSync(`${backupDir}`, { recursive: true }, (err) => { if (err) throw err; }); +// execSync(`zip -r ${backupDir}/${runName + "-" + runData["start-time"]}.zip "run_tests.sh" "collate_data.sh" "collated_data.csv" "src" "targets/target-full" "testlog" "testout"`) +execSync(`cp -r ${path.join(sourceFolder, "*.ts")} ${backupDir}`) +execSync(`cp ${path.join(projectRoot, "*.sh")} ${backupDir}`) +execSync(`cp -r ${path.join(projectRoot, "src")} ${backupDir}`) +execSync(`cp ${path.join(logDirRoot, `${runID}.log`)} ${backupDir}`) // TODO: match the log path with run.sh +execSync(`cp ${path.join(outDirRoot, "llm_out.json")} ${backupDir}`) + +let runDataStr = ""; +for (const [k, v] of Object.entries(runData)) { + runDataStr += k + ":" + v + "\n"; +} + +fs.writeFileSync(`${path.join(outDirRoot, "run.data")}`, runDataStr); +fs.writeFileSync(`${path.join(outDirRoot, "PASS")}`, runDataStr); +fs.writeFileSync(`${path.join(backupDir, "run.data")}`, runDataStr); +fs.writeFileSync(`${path.join(backupDir, "PASS")}`, runDataStr); + +execSync(`rm -f ${path.join(sourceFolder, "erroneous*")} ${path.join(sourceFolder, "completed_sketch*")} ${path.join(sourceFolder, "types_and_headers_llm_completed_sketch*")} ${path.join(sourceFolder, "types_and_headers_test_suite*")} ${path.join(sourceFolder, "*.js")}`); +process.exit(0); diff --git a/src/starcoder-vector-retrieval.mjs b/src/starcoder-vector-retrieval.mjs new file mode 100644 index 0000000..0a10983 --- /dev/null +++ b/src/starcoder-vector-retrieval.mjs @@ -0,0 +1,327 @@ +import { execSync } from "child_process"; +import * as fs from "fs"; +import * as path from "path"; +import { joinFiles, generateStarcoderVectorRetrievalPrompt } from "./testrunner-core.mjs"; + +/* PHASE 1: INITIALIZATION */ + +// initialize run data +const runData = { + "option-llm": "", + "option-source_path": "", + "option-expected_type": "", + "option-relevant_ctx": "", + "option-error_rounds_max": "", + "option-temperature": "", + "commit": "", + "start-time": "", + "round-usage-prompt-tokens": "", + "round-usage-completion-tokens": "", + "round-usage-total-tokens": "", + "end-time": "", + "tests-total": "", + "tests-pass": "", + "tests-fail": "", + "derived-time-elapsed": "", + "derived-percent-tests": "", + "derived-err-rounds-used": "", + "derived-total-tokens-used": "", + "derived-final-parses": "", + "derived-final-static-errors": "", +}; + + +// node testrunner $bashTimestamp $unixTimestamp --run-name \"$run_name\" --type-constraint \"$type_constraint\" --relevant-ctx \"$relevant_ctx\" --error-rounds-max \"$error_rounds_max\" --source-folder \"$source_folder\" +console.log(process.argv); +const runName = process.argv[3]; +const temperature = process.argv[5]; +const rag = process.argv[7]; +const errorRoundsMax = process.argv[9]; +const sourceFolder = process.argv[11]; +const bashTimestamp = process.argv[12]; + +const splitted = sourceFolder.split("/"); +let source = splitted[splitted.length - 2]; +runData["tests-pass"] = "0"; +runData["derived-percent-tests"] = "0"; + +switch (source) { + case "todo": + runData["tests-total"] = "12"; + runData["tests-fail"] = "12"; + break; + case "playlist": + runData["tests-total"] = "15"; + runData["tests-fail"] = "15"; + break; + case "passwords": + runData["tests-total"] = "12"; + runData["tests-fail"] = "12"; + break; + case "booking": + runData["tests-total"] = "8"; + runData["tests-fail"] = "8"; + break; + case "emojipaint": + runData["tests-total"] = "10"; + runData["tests-fail"] = "10"; + break; +} + +console.log(`source: ${source}`); + + +runData["option-source_path"] = sourceFolder; +runData["option-error_rounds_max"] = errorRoundsMax; +runData["commit"] = ""; +runData["derived-final-parses"] = "false"; +runData["derived-final-static-errors"] = "0"; + +// directory defintions +const projectRoot = process.cwd(); +const runID = `${runName}-${source}-vector-${bashTimestamp}`; +const outDirRoot = path.join(projectRoot, "starcoder-vector-retrieval", "out", runID); +fs.mkdirSync(outDirRoot, { recursive: true }, (err) => { if (err) throw err; }); +const logDirRoot = path.join(projectRoot, "starcoder-vector-retrieval", "testlog"); +const backupDir = path.join(projectRoot, "starcoder-vector-retrieval", "backup", `${runID}`); +fs.mkdirSync(backupDir, { recursive: true }, (err) => { if (err) throw err; }); +const combinedFolder = path.join(projectRoot, "targets", "combined"); + + +/* PHASE 2: RAG CONTEXT GENERATION */ + + +execSync(`python3 ${path.join(projectRoot, "chunker2.py")}`, { stdio: 'ignore' }) +execSync(`python3 ${path.join(projectRoot, "starcoder_generate_rags.py")}`, { stdio: 'ignore' }) + + +/* PHASE 3: LLM CODE SYNTHESIS */ + + +// ask LLM to complete the sketch using the returned types +console.log("\n\n=== Generating Prompt ===\n\n"); + +const sketchFilePath = `${path.join(sourceFolder, "starcoder-sketch.ts")}`; +let sketchFileContent = fs.readFileSync(sketchFilePath, "utf8"); +console.log("sketchFileContent: ", sketchFileContent) + +const ragCtx = fs.readFileSync(`${path.join(sourceFolder, "RAG.txt")}`) +const prompt = generateStarcoderVectorRetrievalPrompt(sketchFileContent, ragCtx); +console.log(prompt); + + +let totalTokensUsed = 0; +const callStarcoder = async () => { + const response = await fetch("http://20.115.44.142:8080/completion", { + method: "POST", + body: JSON.stringify({ + prompt: prompt, + n_predict: 1000, + stop: ["\n}"], + model: "starcoder2" + }), + headers: { + "Content-Type": "application/json" + } + }); + return await response.json(); +} +let llmResult = await callStarcoder(); + + +console.log(JSON.stringify(llmResult, "", 2)); +fs.writeFileSync(`${path.join(outDirRoot, "llm_out.json")}`, JSON.stringify(llmResult, "", 2) + "\n"); +// prompt.push(llmResult.choices[0].message); + +// runData["option-llm"] = model; +// runData["option-temperature"] = "0.6"; +// runData["round-usage-prompt-tokens"] += llmResult.usage.prompt_tokens + ","; +// runData["round-usage-completion-tokens"] += llmResult.usage.completion_tokens + ","; +// runData["round-usage-total-tokens"] += llmResult.usage.total_tokens + ","; +// totalTokensUsed += llmResult.usage.total_tokens; + +// write completion to sketch +// const llmCompletedSketch = fillHole(sketchFileContent, llmResult["content"]); +fs.writeFileSync(`${path.join(sourceFolder, "vector_llm_completed_sketch.ts")}`, sketchFileContent + llmResult.content + "\n}"); + + +/* PHASE 4: ERROR CORRECTION */ +console.log("\n\n=== ERROR CORRECTION ===\n\n"); + +// run tsc to check for syntax errors +let usedErrorRounds = 0; + +const testSuiteContent = joinFiles([ + path.join(sourceFolder, "prelude.ts"), + path.join(sourceFolder, "vector_llm_completed_sketch.ts"), + path.join(sourceFolder, "epilogue.ts"), +]); + +fs.writeFileSync(`${path.join(sourceFolder, "vector_test_suite.ts")}`, testSuiteContent); + +for (let i = 0; i < parseInt(errorRoundsMax) + 1; i++) { + try { + // res = execSync(`tsc ${ sourceFolder } llm_completed_sketch.ts`); + execSync(`tsc ${path.join(sourceFolder, "vector_test_suite.ts")}`); + // console.log(`== ${ res }== `) + break; + } catch (err) { + if (i >= parseInt(errorRoundsMax)) { + console.log("\n\n=== FAILED TO COMPILE ===\n\n"); + runData["end-time"] = Math.floor(Date.now() / 1000).toString(); + + // capture error messages + const errorMsg = err.stdout.toString(); + console.log(`error: \n ${err.toString()} `); + console.log(`stdout: \n ${errorMsg} `); + + // capture number of static errors + const numErrors = execSync(`echo \"${escape(err.stdout.toString())}\" | grep "error TS" | wc -l`); + console.log("numErrors: ", numErrors.toString()); + runData["derived-final-static-errors"] = numErrors.toString().split("\n")[0]; + + runData["derived-time-elapsed"] = (parseInt(runData["end-time"]) - parseInt(runData["start-time"])).toString(); + runData["derived-err-rounds-used"] = usedErrorRounds; + runData["derived-total-tokens-used"] = totalTokensUsed; + console.log(runData); + + // const backupDir = `/home/jacob/projects/testtslspclient/backup/${runName + "-" + bashTimestamp + `-${source}-fail`}`; + // fs.mkdirSync(`${backupDir}`, { recursive: true }, (err) => { if (err) throw err; }); + execSync(`cp -r ${path.join(sourceFolder, "*.ts")} ${backupDir}`) + execSync(`cp ${path.join(projectRoot, "*.sh")} ${backupDir}`) + execSync(`cp -r ${path.join(projectRoot, "src")} ${backupDir}`) + execSync(`cp ${path.join(logDirRoot, `${runID}.log`)} ${backupDir}`) // TODO: match the log path with run.sh + execSync(`cp ${path.join(outDirRoot, "llm_out.json")} ${backupDir}`) + + let runDataStr = ""; + for (const [k, v] of Object.entries(runData)) { + runDataStr += k + ":" + v + "\n"; + } + fs.writeFileSync(`${path.join(outDirRoot, "run.data")}`, runDataStr); + fs.writeFileSync(`${path.join(outDirRoot, "FAIL")}`, runDataStr); + fs.writeFileSync(`${path.join(backupDir, "run.data")}`, runDataStr); + fs.writeFileSync(`${path.join(backupDir, "FAIL")}`, runDataStr); + + execSync(`rm -f ${path.join(sourceFolder, "erroneous*")} ${path.join(sourceFolder, "completed_sketch*")} ${path.join(sourceFolder, "vector_llm_completed_sketch*")} ${path.join(sourceFolder, "vector_test_suite*")} ${path.join(sourceFolder, "*.js")}`); + process.exit(1); + } else { + + console.log(`\n\n=== Error Correction Round ${i + 1} ===\n\n`); + usedErrorRounds += 1; + + // capture error messages + const errorMsg = err.stdout.toString(); + console.log(`error: \n ${err.toString()}`); + console.log(`stdout: \n ${errorMsg}`); + + // capture number of static errors + const numErrors = execSync(`echo \"${escape(err.stdout.toString())}\" | grep "error TS" | wc -l`); + console.log("numErrors: ", numErrors.toString()); + runData["derived-final-static-errors"] = numErrors.toString().split("\n")[0]; + + // console.log(`errorCorrectionPrompt:\n${JSON.stringify(errorCorrectionPrompt, "", 2)}`); + + // call the llm again + llmResult = await callStarcoder(); + + console.log(JSON.stringify(llmResult, "", 2)) + fs.writeFileSync(path.join(outDirRoot, "llm_out.json"), JSON.stringify(llmResult, "", 2) + "\n"); + // prompt.push(llmResult["content"]); + + // runData["round-usage-prompt-tokens"] += llmResult.usage.prompt_tokens + ","; + // runData["round-usage-completion-tokens"] += llmResult.usage.completion_tokens + ","; + // runData["round-usage-total-tokens"] += llmResult.usage.total_tokens + ","; + // totalTokensUsed += llmResult.usage.total_tokens; + + fs.writeFileSync(`${path.join(sourceFolder, "vector_llm_completed_sketch.ts")}`, sketchFileContent + llmResult.content + "\n}"); + const testSuiteContent = joinFiles([ + path.join(sourceFolder, "prelude.ts"), + path.join(sourceFolder, "vector_llm_completed_sketch.ts"), + path.join(sourceFolder, "epilogue.ts"), + ]); + + fs.writeFileSync(`${path.join(sourceFolder, "vector_test_suite.ts")}`, testSuiteContent); + + } + } +} + +runData["derived-err-rounds-used"] = usedErrorRounds; +// runData["derived-total-tokens-used"] = totalTokensUsed; + + +/* PHASE 5: TEST SUITE */ + + +console.log("\n\n=== Running Test Suite ===\n\n") +try { + const testResult = execSync(`node ${path.join(sourceFolder, "vector_test_suite.js")}`); + console.log("testResult: ", testResult.toString().split("\n")); + const splitTestResult = testResult.toString().split("\n"); + console.log(splitTestResult) + runData["tests-total"] = splitTestResult[splitTestResult.length - 2].split(" ")[3]; + runData["tests-pass"] = splitTestResult[splitTestResult.length - 2].split(" ")[1]; + runData["tests-fail"] = (parseInt(runData["tests-total"]) - parseInt(runData["tests-pass"])).toString(); + runData["derived-percent-tests"] = (parseInt(runData["tests-pass"]) / parseInt(runData["tests-total"])).toString(); + +} catch (err) { + console.log("error!") + console.log("testResult: ", err.toString().split("\n")); + runData["end-time"] = Math.floor(Date.now() / 1000).toString(); + runData["derived-time-elapsed"] = (parseInt(runData["end-time"]) - parseInt(runData["start-time"])).toString(); + console.log(runData); + + // const backupDir = `/home/jacob/projects/testtslspclient/backup/${runName + "-" + bashTimestamp + `-${source}-fail`}`; + // fs.mkdirSync(`${backupDir}`, { recursive: true }, (err) => { if (err) throw err; }); + // execSync(`zip -r ${backupDir}/${runName + "-" + runData["start-time"]}.zip "run_tests.sh" "collate_data.sh" "collated_data.csv" "src" "targets/target-full" "testlog" "testout"`) + execSync(`cp -r ${path.join(sourceFolder, "*.ts")} ${backupDir}`) + execSync(`cp ${path.join(projectRoot, "*.sh")} ${backupDir}`) + execSync(`cp -r ${path.join(projectRoot, "src")} ${backupDir}`) + execSync(`cp ${path.join(logDirRoot, `${runID}.log`)} ${backupDir}`) // TODO: match the log path with run.sh + execSync(`cp ${path.join(outDirRoot, "llm_out.json")} ${backupDir}`) + + let runDataStr = ""; + for (const [k, v] of Object.entries(runData)) { + runDataStr += k + ":" + v + "\n"; + } + + fs.writeFileSync(`${path.join(outDirRoot, "run.data")}`, runDataStr); + fs.writeFileSync(`${path.join(outDirRoot, "FAIL")}`, runDataStr); + fs.writeFileSync(`${path.join(backupDir, "run.data")}`, runDataStr); + fs.writeFileSync(`${path.join(backupDir, "FAIL")}`, runDataStr); + + execSync(`rm -f ${path.join(sourceFolder, "erroneous*")} ${path.join(sourceFolder, "completed_sketch*")} ${path.join(sourceFolder, "vector_llm_completed_sketch*")} ${path.join(sourceFolder, "vector_test_suite*")} ${path.join(sourceFolder, "*.js")}`); + process.exit(1); +} + + +/* PHASE 6: BACKUPS */ + + +// back up and clean up +runData["end-time"] = Math.floor(Date.now() / 1000).toString(); +runData["derived-time-elapsed"] = (parseInt(runData["end-time"]) - parseInt(runData["start-time"])).toString(); +runData["derived-final-parses"] = "true"; +console.log(runData); + +// const backupDir = `/home/jacob/projects/testtslspclient/backup/${runName + "-" + bashTimestamp + `-${source}-pass`}`; +// fs.mkdirSync(`${backupDir}`, { recursive: true }, (err) => { if (err) throw err; }); +// execSync(`zip -r ${backupDir}/${runName + "-" + runData["start-time"]}.zip "run_tests.sh" "collate_data.sh" "collated_data.csv" "src" "targets/target-full" "testlog" "testout"`) +execSync(`cp -r ${path.join(sourceFolder, "*.ts")} ${backupDir}`) +execSync(`cp ${path.join(projectRoot, "*.sh")} ${backupDir}`) +execSync(`cp -r ${path.join(projectRoot, "src")} ${backupDir}`) +execSync(`cp ${path.join(logDirRoot, `${runID}.log`)} ${backupDir}`) // TODO: match the log path with run.sh +execSync(`cp ${path.join(outDirRoot, "llm_out.json")} ${backupDir}`) + +let runDataStr = ""; +for (const [k, v] of Object.entries(runData)) { + runDataStr += k + ":" + v + "\n"; +} + +fs.writeFileSync(`${path.join(outDirRoot, "run.data")}`, runDataStr); +fs.writeFileSync(`${path.join(outDirRoot, "PASS")}`, runDataStr); +fs.writeFileSync(`${path.join(backupDir, "run.data")}`, runDataStr); +fs.writeFileSync(`${path.join(backupDir, "PASS")}`, runDataStr); + +execSync(`rm -f ${path.join(sourceFolder, "erroneous*")} ${path.join(sourceFolder, "completed_sketch*")} ${path.join(sourceFolder, "vector_llm_completed_sketch*")} ${path.join(sourceFolder, "vector_test_suite*")} ${path.join(sourceFolder, "*.js")}`); +process.exit(0); diff --git a/src/testrunner-core.mjs b/src/testrunner-core.mjs index 7f7f391..754211c 100644 --- a/src/testrunner-core.mjs +++ b/src/testrunner-core.mjs @@ -194,14 +194,11 @@ const generateVectorRetrievalPrompt = (sketchFileContent, ragCtx) => { let userPrompt = { role: "user", content: - `# Program Sketch to be completed: #\n${sketchFileContent} + `# Program Sketch to be completed: #\n${removeLines(sketchFileContent).join("\n")} # relevant snippets: # ${ragCtx} -# Program Sketch to be completed: # -${removeLines(sketchFileContent).join("\n")} - ` }; @@ -239,6 +236,47 @@ ${exhaustiveCtx} return prompt; }; + +const generateStarcoderTypesAndHeadersPrompt = (sketchFileContent, relevantTypes, relevantHeaders) => { + const prompt = []; + + if (relevantTypes) { + for (const rt of relevantTypes) { + prompt.push(`${rt}`); + } + } + + if (relevantHeaders) { + for (const rh of relevantHeaders) { + prompt.push(`${rh}`); + } + } + + prompt.push(`${sketchFileContent}`) + return prompt.join("\n"); +} + + +const generateStarcoderVectorRetrievalPrompt = (sketchFileContent, ragCtx) => { + const prompt = [ + "/*", + `${ragCtx}`, + "*/", + `${sketchFileContent}` + ].join("\n"); + return prompt; +} + + +const generateStarcoderExhaustiveRetrievalPrompt = (sketchFileContent, exhaustiveCtx) => { + const prompt = [ + `${exhaustiveCtx}`, + `${sketchFileContent}` + ].join("\n"); + return prompt; +} + + const mockLLM = (errorRound) => { let errorSketch1 = "const update: (m: Model, a: Action) => Model = (m, a) => {\n\ const add: (m: Model) => Todo = (mAdd) => {\n\ @@ -434,4 +472,4 @@ const fillHole = (fileContent, holeContent) => { return inserted.join("\n"); } -export { generatePrompt, generateTypesAndHeadersPrompt, generateVectorRetrievalPrompt, generateExhaustiveRetrievalPrompt, generateErrorCorrectionPrompt, mockLLM, joinFiles, fillHole }; +export { generatePrompt, generateTypesAndHeadersPrompt, generateVectorRetrievalPrompt, generateExhaustiveRetrievalPrompt, generateErrorCorrectionPrompt, generateStarcoderTypesAndHeadersPrompt, generateStarcoderVectorRetrievalPrompt, generateStarcoderExhaustiveRetrievalPrompt, mockLLM, joinFiles, fillHole }; diff --git a/src/types-and-headers.mjs b/src/types-and-headers.mjs index 1fa0053..8b68ab8 100644 --- a/src/types-and-headers.mjs +++ b/src/types-and-headers.mjs @@ -100,7 +100,7 @@ const holeType = res.hole; const relevantTypes = res.relevantTypes; const relevantHeaders = res.relevantHeaders; -const sketchFilePath = `${sourceFolder}sketch.ts`; +const sketchFilePath = `${path.join(sourceFolder, "sketch.ts")}`; const sketchFileContent = fs.readFileSync(sketchFilePath, "utf8"); // let targetTypes = null; // if (typeConstraint === "true") { diff --git a/src/vector-retrieval.mjs b/src/vector-retrieval.mjs index 89d4205..d5962c2 100644 --- a/src/vector-retrieval.mjs +++ b/src/vector-retrieval.mjs @@ -1,10 +1,9 @@ import OpenAI from "openai"; import { execSync } from "child_process"; import * as fs from "fs"; -import { generateVectorRetrievalPrompt, generateErrorCorrectionPrompt, joinFiles, fillHole } from "./testrunner-core.js"; -import { setDefaultAutoSelectFamilyAttemptTimeout } from "net"; +import * as path from "path" +import { generateVectorRetrievalPrompt, generateErrorCorrectionPrompt, joinFiles, fillHole } from "./testrunner-core.mjs"; -// TODO: parse CLI args and setup logging information /* PHASE 1: INITIALIZATION */ @@ -91,17 +90,21 @@ fs.mkdirSync(outDirRoot, { recursive: true }, (err) => { if (err) throw err; }); const logDirRoot = path.join(projectRoot, "vector-retrieval", "testlog"); const backupDir = path.join(projectRoot, "vector-retrieval", "backup", `${runID}`); fs.mkdirSync(backupDir, { recursive: true }, (err) => { if (err) throw err; }); +const combinedFolder = path.join(projectRoot, "targets", "combined"); /* PHASE 2: TYPE EXTRACTION */ -// TODO: run py scripts to generate RAG files +// NOTE: run py scripts to generate RAG files. This is already done for the reviewers. +execSync(`python3 ${path.join(projectRoot, "chunker2.py")}`) +execSync(`python3 ${path.join(projectRoot, "generate_rags.py")}`) /* PHASE 3: LLM CODE SYNTHESIS */ // ask LLM to complete the sketch using the returned types console.log("\n\n=== Generating Prompt ===\n\n"); -const ragCtx = fs.readFileSync(`${sourceFolder}RAG.txt`) +const sketchFileContent = fs.readFileSync(path.join(sourceFolder, "sketch.ts"), "utf8"); +const ragCtx = fs.readFileSync(`${path.join(sourceFolder, "RAG.txt")}`) let prompt = []; prompt = generateVectorRetrievalPrompt(sketchFileContent, ragCtx); // console.log(JSON.stringify(prompt, "", 2)); @@ -241,9 +244,9 @@ for (let i = 0; i < parseInt(errorRoundsMax) + 1; i++) { const llmCompletedSketch = fillHole(sketchFileContent, llmResult.choices[0].message.content); fs.writeFileSync(`${path.join(sourceFolder, "vector_llm_completed_sketch.ts")}`, llmCompletedSketch); const testSuiteContent = joinFiles([ - `${path.join(sourceFolder, "prelude.ts")}`, - `${path.join(sourceFoler, "vector_llm_completed_sketch.ts")}`, - `${path.join(sourceFolder, "epilogue.ts")}` + path.join(sourceFolder, "prelude.ts"), + path.join(sourceFolder, "vector_llm_completed_sketch.ts"), + path.join(sourceFolder, "epilogue.ts") ]); fs.writeFileSync(`${path.join(sourceFolder, "vector_test_suite.ts")}`, testSuiteContent); @@ -261,7 +264,7 @@ runData["derived-total-tokens-used"] = totalTokensUsed; console.log("\n\n=== Running Test Suite ===\n\n") try { - const testResult = execSync(`node ${sourceFolder}vector_test_suite.js`); + const testResult = execSync(`node ${path.join(sourceFolder, "vector_test_suite.js")}`); console.log("testResult: ", testResult.toString().split("\n")); const splitTestResult = testResult.toString().split("\n"); console.log(splitTestResult) @@ -323,9 +326,6 @@ for (const [k, v] of Object.entries(runData)) { runDataStr += k + ":" + v + "\n"; } -fs.writeFileSync(`${outDirRoot}/run.data`, runDataStr); -fs.writeFileSync(`${backupDir}/run.data`, runDataStr); - fs.writeFileSync(`${path.join(outDirRoot, "run.data")}`, runDataStr); fs.writeFileSync(`${path.join(outDirRoot, "PASS")}`, runDataStr); fs.writeFileSync(`${path.join(backupDir, "run.data")}`, runDataStr); diff --git a/starcoder_exhaustive_collate_data.sh b/starcoder_exhaustive_collate_data.sh new file mode 100755 index 0000000..ce5d0d1 --- /dev/null +++ b/starcoder_exhaustive_collate_data.sh @@ -0,0 +1,132 @@ +#!/bin/bash + +# Set the path to the testout folder +projectRoot=$(pwd) +testout_folder="$projectRoot/starcoder-exhaustive-retrieval/out/" + +# Set the output CSV file name +output_file="${1}_starcoder_exhaustive_collated_data.csv" + +# Initialize an array to store the keys (column headers) +keys=() + +# Initialize an associative array to store default values for certain keys +declare -A default_values +default_values["option-expected_type"]="false" +default_values["option-relevant_ctx"]="false" +default_values["option-error_rounds_max"]="0" +default_values["option-temperature"]="1.0" + +# Set the internal flag to control the usage of the whitelist +use_whitelist=true + +# Define the ordered list of keys for the whitelist +whitelist=( + "output-path" + "option-source_path" + "option-expected_type" + "option-relevant_ctx" + "option-error_rounds_max" + "option-temperature" + "start-time" + "tests-total" + "tests-pass" + "derived-time-elapsed" + "derived-percent-tests" + "derived-err-rounds-used" + "derived-total-tokens-used" + "derived-final-parses" + "derived-final-static-errors" + "derived-err-improve" +) + +# Loop through each subfolder in the testout folder to collect the keys +for subfolder in "$testout_folder"/*/; do + # Check if the run.data file exists in the subfolder + if [ -f "$subfolder/run.data" ]; then + # Read the run.data file + while IFS= read -r line; do + # Split the line by colon and extract the key + IFS=':' read -r key _ <<<"$line" + + # Remove the double quotes from the key + key=$(echo "$key" | tr -d '"') + + # Add the key to the keys array if it doesn't exist and if not using the whitelist + if ! $use_whitelist && [[ ! " ${keys[@]} " =~ " $key " ]]; then + keys+=("$key") + fi + done <"$subfolder/run.data" + fi +done + +# Set the keys to the whitelist if the flag is set +if $use_whitelist; then + keys=("${whitelist[@]}") +fi + +# Write the column headers (keys) to the output CSV file +( + IFS=',' + echo "${keys[*]}" +) >"$output_file" + +# Get the list of subfolders in the testout folder and sort them based on creation time +IFS=$'\n' sorted_subfolders=($(ls -dt "$testout_folder"/*/)) + +# Loop through each subfolder in the sorted order +for subfolder in "${sorted_subfolders[@]}"; do + # Check if the run.data file exists in the subfolder + if [ -f "$subfolder/run.data" ]; then + # Initialize an associative array to store the key-value pairs + declare -A data + + # Get the subfolder name + subfolder_name=$(basename "$subfolder") + + # Set the value for the "output-path" key + data["output-path"]="$subfolder_name" + + # Read the run.data file + while IFS= read -r line; do + # Split the line by colon and extract the key and value + IFS=':' read -r key value <<<"$line" + + # Remove the double quotes from the key + key=$(echo "$key" | tr -d '"') + + # Check if the value contains commas or other problematic characters + if [[ $value == *","* || $value == *$'\n'* || $value == *$'\r'* ]]; then + # Escape double quotes within the value + value=$(echo "$value" | sed 's/"/""/g') + # Surround the value with double quotes + value="\"$value\"" + else + # Remove the double quotes from the value + value=$(echo "$value" | tr -d '"') + fi + + # Store the key-value pair in the associative array + data["$key"]="$value" + done <"$subfolder/run.data" + + # Generate the CSV row for the current run.data file + row="" + for key in "${keys[@]}"; do + if [[ -n "${data[$key]}" ]]; then + row+="${data[$key]}," + else + # Use the default value if provided, otherwise use NULL + row+="${default_values[$key]:-NULL}," + fi + done + + # Remove the trailing comma + row="${row%,}" + + # Append the row to the output CSV file + echo "$row" >>"$output_file" + fi +done + +echo "Data collation completed. CSV file generated: $output_file" diff --git a/starcoder_vector_collate_data.sh b/starcoder_vector_collate_data.sh new file mode 100644 index 0000000..19a8bda --- /dev/null +++ b/starcoder_vector_collate_data.sh @@ -0,0 +1,132 @@ +#!/bin/bash + +# Set the path to the testout folder +projectRoot=$(pwd) +testout_folder="$projectRoot/starcoder-vector-retrieval/out/" + +# Set the output CSV file name +output_file="${1}_starcoder_vector_collated_data.csv" + +# Initialize an array to store the keys (column headers) +keys=() + +# Initialize an associative array to store default values for certain keys +declare -A default_values +default_values["option-expected_type"]="false" +default_values["option-relevant_ctx"]="false" +default_values["option-error_rounds_max"]="0" +default_values["option-temperature"]="1.0" + +# Set the internal flag to control the usage of the whitelist +use_whitelist=true + +# Define the ordered list of keys for the whitelist +whitelist=( + "output-path" + "option-source_path" + "option-expected_type" + "option-relevant_ctx" + "option-error_rounds_max" + "option-temperature" + "start-time" + "tests-total" + "tests-pass" + "derived-time-elapsed" + "derived-percent-tests" + "derived-err-rounds-used" + "derived-total-tokens-used" + "derived-final-parses" + "derived-final-static-errors" + "derived-err-improve" +) + +# Loop through each subfolder in the testout folder to collect the keys +for subfolder in "$testout_folder"/*/; do + # Check if the run.data file exists in the subfolder + if [ -f "$subfolder/run.data" ]; then + # Read the run.data file + while IFS= read -r line; do + # Split the line by colon and extract the key + IFS=':' read -r key _ <<<"$line" + + # Remove the double quotes from the key + key=$(echo "$key" | tr -d '"') + + # Add the key to the keys array if it doesn't exist and if not using the whitelist + if ! $use_whitelist && [[ ! " ${keys[@]} " =~ " $key " ]]; then + keys+=("$key") + fi + done <"$subfolder/run.data" + fi +done + +# Set the keys to the whitelist if the flag is set +if $use_whitelist; then + keys=("${whitelist[@]}") +fi + +# Write the column headers (keys) to the output CSV file +( + IFS=',' + echo "${keys[*]}" +) >"$output_file" + +# Get the list of subfolders in the testout folder and sort them based on creation time +IFS=$'\n' sorted_subfolders=($(ls -dt "$testout_folder"/*/)) + +# Loop through each subfolder in the sorted order +for subfolder in "${sorted_subfolders[@]}"; do + # Check if the run.data file exists in the subfolder + if [ -f "$subfolder/run.data" ]; then + # Initialize an associative array to store the key-value pairs + declare -A data + + # Get the subfolder name + subfolder_name=$(basename "$subfolder") + + # Set the value for the "output-path" key + data["output-path"]="$subfolder_name" + + # Read the run.data file + while IFS= read -r line; do + # Split the line by colon and extract the key and value + IFS=':' read -r key value <<<"$line" + + # Remove the double quotes from the key + key=$(echo "$key" | tr -d '"') + + # Check if the value contains commas or other problematic characters + if [[ $value == *","* || $value == *$'\n'* || $value == *$'\r'* ]]; then + # Escape double quotes within the value + value=$(echo "$value" | sed 's/"/""/g') + # Surround the value with double quotes + value="\"$value\"" + else + # Remove the double quotes from the value + value=$(echo "$value" | tr -d '"') + fi + + # Store the key-value pair in the associative array + data["$key"]="$value" + done <"$subfolder/run.data" + + # Generate the CSV row for the current run.data file + row="" + for key in "${keys[@]}"; do + if [[ -n "${data[$key]}" ]]; then + row+="${data[$key]}," + else + # Use the default value if provided, otherwise use NULL + row+="${default_values[$key]:-NULL}," + fi + done + + # Remove the trailing comma + row="${row%,}" + + # Append the row to the output CSV file + echo "$row" >>"$output_file" + fi +done + +echo "Data collation completed. CSV file generated: $output_file" diff --git a/take_snapshot.sh b/take_snapshot.sh new file mode 100755 index 0000000..794a3a4 --- /dev/null +++ b/take_snapshot.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Set the path to the backup folder +backup_folder="backup" + +run_name="$1" + +# Commit and push backup files +# git add "backup" +# git commit -m "create backup" +# git push + +# Loop through each subfolder in the testout folder to collect the keys +for subfolder in "$backup_folder"/*/; do + # Check if the run.data file exists in the subfolder + if [ -f "$subfolder/run.data" ]; then + # Get hash of last commit + hash=$(git rev-parse HEAD | head -n 1 | tr -d "\n") + + # Find and replace commit line + sed -i "s/commit:/commit:$hash/" "$subfolder/run.data" + fi +done + +# Commit new collated_data.csv +cp "${run_name}_collated_data.csv" "${backup_folder}/." +git add "${run_name}_collated_data.csv" +git commit -m "collate data" + +# Commit and push edited run.data files +git add "${backup_folder}" +git commit -m "update collated data and commit hash on run.data" +git push + +echo "Current snapshot committed with hash: $hash" diff --git a/targets/booking/checkConsistency.ts b/targets/booking/checkConsistency.ts new file mode 100644 index 0000000..dec9b6e --- /dev/null +++ b/targets/booking/checkConsistency.ts @@ -0,0 +1,10 @@ +import {Model, Action, Weekday, TimeOfDay, Time, User, BookingID, Booking, BookingFormData, AddBooking, CancelBooking, ClearBookings} from "/home/jacob/projects/context-extractor/targets/booking/prelude.ts" +function check(a: Booking): (model: Model, action: Action) => Model { return a; } +function check(a: Booking): Model { return a; } +function check(a: Booking): BookingFormData { return a; } +function check(a: Booking): Time { return a; } +function check(a: Booking): Weekday { return a; } +function check(a: Booking): TimeOfDay { return a; } +function check(a: Booking): User { return a; } +function check(a: Booking): Booking[] { return a; } +function check(a: Booking): BookingID { return a; } \ No newline at end of file diff --git a/targets/booking/imports.ql b/targets/booking/imports.ql new file mode 100644 index 0000000..fd8fa7a --- /dev/null +++ b/targets/booking/imports.ql @@ -0,0 +1,11 @@ +/** + * @id imports + * @name Imports + * @description Resolve dependencies during consistency check. + */ + +import javascript + +from File f, TypeExpr t +where(to.toString() = "Weekday" ort.toString() = "TimeOfDay") and t.getFile() = fi +select t.toString(), fi.toString() \ No newline at end of file diff --git a/targets/booking/invokeDependencyError.ts b/targets/booking/invokeDependencyError.ts new file mode 100644 index 0000000..704f9c5 --- /dev/null +++ b/targets/booking/invokeDependencyError.ts @@ -0,0 +1,13 @@ +let x: (model: Model, action: Action) => Model; +let x: Weekday; +let x: TimeOfDay; +let x: Time; +let x: User; +let x: BookingID; +let x: Booking; +let x: BookingFormData; +let x: Model; +let x: AddBooking; +let x: CancelBooking; +let x: ClearBookings; +let x: Action; \ No newline at end of file diff --git a/targets/booking/out.sarif b/targets/booking/out.sarif new file mode 100644 index 0000000..e43b55f --- /dev/null +++ b/targets/booking/out.sarif @@ -0,0 +1,688 @@ +{ + "$schema" : "https://json.schemastore.org/sarif-2.1.0.json", + "version" : "2.1.0", + "runs" : [ { + "tool" : { + "driver" : { + "name" : "CodeQL", + "organization" : "GitHub", + "semanticVersion" : "2.17.3", + "notifications" : [ { + "id" : "relevant-types", + "name" : "relevant-types", + "shortDescription" : { + "text" : "Relevant types" + }, + "fullDescription" : { + "text" : "Find the relevant types given a function hole" + }, + "defaultConfiguration" : { + "enabled" : true + }, + "properties" : { + "description" : "Find the relevant types given a function hole", + "id" : "relevant-types", + "kind" : "diagnostic", + "name" : "Relevant types" + } + }, { + "id" : "js/baseline/expected-extracted-files", + "name" : "js/baseline/expected-extracted-files", + "shortDescription" : { + "text" : "Expected extracted files" + }, + "fullDescription" : { + "text" : "Files appearing in the source archive that are expected to be extracted." + }, + "defaultConfiguration" : { + "enabled" : true + }, + "properties" : { + "tags" : [ "expected-extracted-files", "telemetry" ] + } + } ], + "rules" : [ ] + }, + "extensions" : [ { + "name" : "getting-started/queries-javascript", + "semanticVersion" : "1.0.0+1ec784d1d4c64e0f90c756e67ac087f4067bb8b0", + "locations" : [ { + "uri" : "file:///home/jacob/projects/context-extractor/queries/codeql-custom-queries-javascript/", + "description" : { + "text" : "The QL pack root directory." + } + }, { + "uri" : "file:///home/jacob/projects/context-extractor/queries/codeql-custom-queries-javascript/codeql-pack.yml", + "description" : { + "text" : "The QL pack definition file." + } + } ] + } ] + }, + "invocations" : [ { + "toolExecutionNotifications" : [ { + "locations" : [ { + "physicalLocation" : { + "artifactLocation" : { + "uri" : "prelude.ts", + "uriBaseId" : "%SRCROOT%", + "index" : 0 + }, + "region" : { + "startLine" : 3, + "endColumn" : 44 + } + } + } ], + "message" : { + "text" : "TypeAliasDeclaration" + }, + "level" : "none", + "descriptor" : { + "id" : "relevant-types", + "index" : 0 + }, + "properties" : { + "formattedMessage" : { + "text" : "TypeAliasDeclaration" + } + } + }, { + "locations" : [ { + "physicalLocation" : { + "artifactLocation" : { + "uri" : "prelude.ts", + "uriBaseId" : "%SRCROOT%", + "index" : 0 + }, + "region" : { + "startLine" : 5, + "endColumn" : 30 + } + } + } ], + "message" : { + "text" : "TypeAliasDeclaration" + }, + "level" : "none", + "descriptor" : { + "id" : "relevant-types", + "index" : 0 + }, + "properties" : { + "formattedMessage" : { + "text" : "TypeAliasDeclaration" + } + } + }, { + "locations" : [ { + "physicalLocation" : { + "artifactLocation" : { + "uri" : "prelude.ts", + "uriBaseId" : "%SRCROOT%", + "index" : 0 + }, + "region" : { + "startLine" : 7, + "endColumn" : 34 + } + } + } ], + "message" : { + "text" : "TypeAliasDeclaration" + }, + "level" : "none", + "descriptor" : { + "id" : "relevant-types", + "index" : 0 + }, + "properties" : { + "formattedMessage" : { + "text" : "TypeAliasDeclaration" + } + } + }, { + "locations" : [ { + "physicalLocation" : { + "artifactLocation" : { + "uri" : "prelude.ts", + "uriBaseId" : "%SRCROOT%", + "index" : 0 + }, + "region" : { + "startLine" : 9, + "endColumn" : 20 + } + } + } ], + "message" : { + "text" : "TypeAliasDeclaration" + }, + "level" : "none", + "descriptor" : { + "id" : "relevant-types", + "index" : 0 + }, + "properties" : { + "formattedMessage" : { + "text" : "TypeAliasDeclaration" + } + } + }, { + "locations" : [ { + "physicalLocation" : { + "artifactLocation" : { + "uri" : "prelude.ts", + "uriBaseId" : "%SRCROOT%", + "index" : 0 + }, + "region" : { + "startLine" : 11, + "endColumn" : 25 + } + } + } ], + "message" : { + "text" : "TypeAliasDeclaration" + }, + "level" : "none", + "descriptor" : { + "id" : "relevant-types", + "index" : 0 + }, + "properties" : { + "formattedMessage" : { + "text" : "TypeAliasDeclaration" + } + } + }, { + "locations" : [ { + "physicalLocation" : { + "artifactLocation" : { + "uri" : "prelude.ts", + "uriBaseId" : "%SRCROOT%", + "index" : 0 + }, + "region" : { + "startLine" : 13, + "endColumn" : 40 + } + } + } ], + "message" : { + "text" : "TypeAliasDeclaration" + }, + "level" : "none", + "descriptor" : { + "id" : "relevant-types", + "index" : 0 + }, + "properties" : { + "formattedMessage" : { + "text" : "TypeAliasDeclaration" + } + } + }, { + "locations" : [ { + "physicalLocation" : { + "artifactLocation" : { + "uri" : "prelude.ts", + "uriBaseId" : "%SRCROOT%", + "index" : 0 + }, + "region" : { + "startLine" : 15, + "endColumn" : 37 + } + } + } ], + "message" : { + "text" : "TypeAliasDeclaration" + }, + "level" : "none", + "descriptor" : { + "id" : "relevant-types", + "index" : 0 + }, + "properties" : { + "formattedMessage" : { + "text" : "TypeAliasDeclaration" + } + } + }, { + "locations" : [ { + "physicalLocation" : { + "artifactLocation" : { + "uri" : "prelude.ts", + "uriBaseId" : "%SRCROOT%", + "index" : 0 + }, + "region" : { + "startLine" : 17, + "endColumn" : 54 + } + } + } ], + "message" : { + "text" : "TypeAliasDeclaration" + }, + "level" : "none", + "descriptor" : { + "id" : "relevant-types", + "index" : 0 + }, + "properties" : { + "formattedMessage" : { + "text" : "TypeAliasDeclaration" + } + } + }, { + "locations" : [ { + "physicalLocation" : { + "artifactLocation" : { + "uri" : "prelude.ts", + "uriBaseId" : "%SRCROOT%", + "index" : 0 + }, + "region" : { + "startLine" : 19, + "endColumn" : 94 + } + } + } ], + "message" : { + "text" : "TypeAliasDeclaration" + }, + "level" : "none", + "descriptor" : { + "id" : "relevant-types", + "index" : 0 + }, + "properties" : { + "formattedMessage" : { + "text" : "TypeAliasDeclaration" + } + } + }, { + "locations" : [ { + "physicalLocation" : { + "artifactLocation" : { + "uri" : "prelude.ts", + "uriBaseId" : "%SRCROOT%", + "index" : 0 + }, + "region" : { + "startLine" : 21, + "endColumn" : 72 + } + } + } ], + "message" : { + "text" : "TypeAliasDeclaration" + }, + "level" : "none", + "descriptor" : { + "id" : "relevant-types", + "index" : 0 + }, + "properties" : { + "formattedMessage" : { + "text" : "TypeAliasDeclaration" + } + } + }, { + "locations" : [ { + "physicalLocation" : { + "artifactLocation" : { + "uri" : "prelude.ts", + "uriBaseId" : "%SRCROOT%", + "index" : 0 + }, + "region" : { + "startLine" : 23, + "endColumn" : 48 + } + } + } ], + "message" : { + "text" : "TypeAliasDeclaration" + }, + "level" : "none", + "descriptor" : { + "id" : "relevant-types", + "index" : 0 + }, + "properties" : { + "formattedMessage" : { + "text" : "TypeAliasDeclaration" + } + } + }, { + "locations" : [ { + "physicalLocation" : { + "artifactLocation" : { + "uri" : "prelude.ts", + "uriBaseId" : "%SRCROOT%", + "index" : 0 + }, + "region" : { + "startLine" : 25, + "endColumn" : 58 + } + } + } ], + "message" : { + "text" : "TypeAliasDeclaration" + }, + "level" : "none", + "descriptor" : { + "id" : "relevant-types", + "index" : 0 + }, + "properties" : { + "formattedMessage" : { + "text" : "TypeAliasDeclaration" + } + } + }, { + "locations" : [ { + "physicalLocation" : { + "artifactLocation" : { + "uri" : "prelude.js", + "uriBaseId" : "%SRCROOT%", + "index" : 1 + } + } + } ], + "message" : { + "text" : "" + }, + "level" : "none", + "descriptor" : { + "id" : "js/baseline/expected-extracted-files", + "index" : 1 + }, + "properties" : { + "formattedMessage" : { + "text" : "" + } + } + }, { + "locations" : [ { + "physicalLocation" : { + "artifactLocation" : { + "uri" : "epilogue.js", + "uriBaseId" : "%SRCROOT%", + "index" : 2 + } + } + } ], + "message" : { + "text" : "" + }, + "level" : "none", + "descriptor" : { + "id" : "js/baseline/expected-extracted-files", + "index" : 1 + }, + "properties" : { + "formattedMessage" : { + "text" : "" + } + } + }, { + "locations" : [ { + "physicalLocation" : { + "artifactLocation" : { + "uri" : "injected_sketch.ts", + "uriBaseId" : "%SRCROOT%", + "index" : 3 + } + } + } ], + "message" : { + "text" : "" + }, + "level" : "none", + "descriptor" : { + "id" : "js/baseline/expected-extracted-files", + "index" : 1 + }, + "properties" : { + "formattedMessage" : { + "text" : "" + } + } + }, { + "locations" : [ { + "physicalLocation" : { + "artifactLocation" : { + "uri" : "solution.js", + "uriBaseId" : "%SRCROOT%", + "index" : 4 + } + } + } ], + "message" : { + "text" : "" + }, + "level" : "none", + "descriptor" : { + "id" : "js/baseline/expected-extracted-files", + "index" : 1 + }, + "properties" : { + "formattedMessage" : { + "text" : "" + } + } + }, { + "locations" : [ { + "physicalLocation" : { + "artifactLocation" : { + "uri" : "epilogue.ts", + "uriBaseId" : "%SRCROOT%", + "index" : 5 + } + } + } ], + "message" : { + "text" : "" + }, + "level" : "none", + "descriptor" : { + "id" : "js/baseline/expected-extracted-files", + "index" : 1 + }, + "properties" : { + "formattedMessage" : { + "text" : "" + } + } + }, { + "locations" : [ { + "physicalLocation" : { + "artifactLocation" : { + "uri" : "sketch.ts", + "uriBaseId" : "%SRCROOT%", + "index" : 6 + } + } + } ], + "message" : { + "text" : "" + }, + "level" : "none", + "descriptor" : { + "id" : "js/baseline/expected-extracted-files", + "index" : 1 + }, + "properties" : { + "formattedMessage" : { + "text" : "" + } + } + }, { + "locations" : [ { + "physicalLocation" : { + "artifactLocation" : { + "uri" : "prelude.ts", + "uriBaseId" : "%SRCROOT%", + "index" : 0 + } + } + } ], + "message" : { + "text" : "" + }, + "level" : "none", + "descriptor" : { + "id" : "js/baseline/expected-extracted-files", + "index" : 1 + }, + "properties" : { + "formattedMessage" : { + "text" : "" + } + } + }, { + "locations" : [ { + "physicalLocation" : { + "artifactLocation" : { + "uri" : "sketch.js", + "uriBaseId" : "%SRCROOT%", + "index" : 7 + } + } + } ], + "message" : { + "text" : "" + }, + "level" : "none", + "descriptor" : { + "id" : "js/baseline/expected-extracted-files", + "index" : 1 + }, + "properties" : { + "formattedMessage" : { + "text" : "" + } + } + }, { + "locations" : [ { + "physicalLocation" : { + "artifactLocation" : { + "uri" : "injected_sketch.js", + "uriBaseId" : "%SRCROOT%", + "index" : 8 + } + } + } ], + "message" : { + "text" : "" + }, + "level" : "none", + "descriptor" : { + "id" : "js/baseline/expected-extracted-files", + "index" : 1 + }, + "properties" : { + "formattedMessage" : { + "text" : "" + } + } + }, { + "locations" : [ { + "physicalLocation" : { + "artifactLocation" : { + "uri" : "solution.ts", + "uriBaseId" : "%SRCROOT%", + "index" : 9 + } + } + } ], + "message" : { + "text" : "" + }, + "level" : "none", + "descriptor" : { + "id" : "js/baseline/expected-extracted-files", + "index" : 1 + }, + "properties" : { + "formattedMessage" : { + "text" : "" + } + } + } ], + "executionSuccessful" : true + } ], + "artifacts" : [ { + "location" : { + "uri" : "prelude.ts", + "uriBaseId" : "%SRCROOT%", + "index" : 0 + } + }, { + "location" : { + "uri" : "prelude.js", + "uriBaseId" : "%SRCROOT%", + "index" : 1 + } + }, { + "location" : { + "uri" : "epilogue.js", + "uriBaseId" : "%SRCROOT%", + "index" : 2 + } + }, { + "location" : { + "uri" : "injected_sketch.ts", + "uriBaseId" : "%SRCROOT%", + "index" : 3 + } + }, { + "location" : { + "uri" : "solution.js", + "uriBaseId" : "%SRCROOT%", + "index" : 4 + } + }, { + "location" : { + "uri" : "epilogue.ts", + "uriBaseId" : "%SRCROOT%", + "index" : 5 + } + }, { + "location" : { + "uri" : "sketch.ts", + "uriBaseId" : "%SRCROOT%", + "index" : 6 + } + }, { + "location" : { + "uri" : "sketch.js", + "uriBaseId" : "%SRCROOT%", + "index" : 7 + } + }, { + "location" : { + "uri" : "injected_sketch.js", + "uriBaseId" : "%SRCROOT%", + "index" : 8 + } + }, { + "location" : { + "uri" : "solution.ts", + "uriBaseId" : "%SRCROOT%", + "index" : 9 + } + } ], + "results" : [ ], + "newlineSequences" : [ "\r\n", "\n", "
", "
" ], + "columnKind" : "utf16CodeUnits", + "properties" : { + "semmle.formatSpecifier" : "sarif-latest" + } + } ] +} \ No newline at end of file diff --git a/targets/combined/vector_prelude.ts b/targets/combined/vector_prelude.ts new file mode 100644 index 0000000..beb3341 --- /dev/null +++ b/targets/combined/vector_prelude.ts @@ -0,0 +1,320 @@ +// TODO MVU PRELUDE + +// A todo has a description and a status +type Todo = [string, boolean]; + +// A description input buffer and a todo list +type Model = [string, Todo[]]; + +type AddTodo = { type: "AddTodo" }; + +type RemoveTodo = { type: "RemoveTodo"; id: number }; + +type ToggleTodo = { type: "ToggleTodo"; id: number }; + +type UpdateBuffer = { type: "UpdateBuffer"; name: string }; + +type Action = AddTodo | RemoveTodo | ToggleTodo | UpdateBuffer; + +type Update = (m: Model, a: Action) => Model; + +const todo_eq: (t1: Todo, t2: Todo) => Boolean = ([d1, s1], [d2, s2]) => { + return d1 === d2 && s1 === s2; +} + +const todo_array_eq: (ta1: Todo[], ta2: Todo[]) => Boolean = (ta1, ta2) => { + return ta1.length === ta2.length && ta1.every((el, i) => { return todo_eq(el, ta2[i]); }); +} + +const model_eq: (m1: Model, m2: Model) => Boolean = ([b1, ts1], [b2, ts2]) => { + return b1 === b2 && todo_array_eq(ts1, ts2); +} + +const Model_init: Model = ["", []]; + +const add: (m: Model) => Todo[] = (m) => { + if (m[0] === "") { + return m[1]; + } else { + return [...m[1], [m[0], false]]; + } +} + +const remove: (index: number, todos: Todo[]) => Todo[] = (index, todos) => { + const removedTodos: Todo[] = []; + for (let i = 0; i < todos.length; i++) { + if (i !== index) { + removedTodos.push(todos[i]); + } + } + return removedTodos; +} + +const toggle: (index: number, todos: Todo[]) => Todo[] = (index, todos) => { + const toggledTodos = todos.map((t, i) => { + if (i === index) { + return [t[0], !t[1]] as Todo; + } else { + return t; + } + }); + return toggledTodos; +} + +// PLAYLIST MVU PRELUDE + +// Non-negative ID for songs +type Id = number; + +// Actions user can do in a playlist +type PlaySong = { type: "PlaySong", id: Id }; + +type PauseCurrentSong = { type: "PauseCurrentSong" }; + +type RemoveSong = { type: "RemoveSong", id: Id }; + +// Add to the from of the playList, ignore duplication +type AddSong = { type: "AddSong", id: Id }; + +type PlayListAction = PlaySong | PauseCurrentSong | RemoveSong | AddSong; + +// The state of the playlist +type Playing = { type: "Playing", id: Id }; + +type PausedOn = { type: "PausedOn", id: Id }; + +type NoSongSelected = { type: "NoSongSelected" }; + +type PlayListState = Playing | PausedOn | NoSongSelected; + +// A playlist with a list of songs and the current state of the playlist +type PlayList = [Id[], PlayListState]; + +// Get all the song ids in the playList +const get_songs: (playlist: PlayList) => Id[] = (playlist: PlayList) => { + const [songs, _] = playlist; + return songs; +}; + +// Get the id of the currently playing song +const get_state: (playlist: PlayList) => PlayListState = (playlist: PlayList) => { + const [_, state] = playlist; + return state; +}; + +// PASSWORDS MVU PRELUDE + +type RequireUppercase = { type: "RequireUppercase" }; + +type RequireLowercase = { type: "RequireLowercase" }; + +type MinimumLength = { type: "MinimumLength"; length: number }; + +type RequireNumber = { type: "RequireNumber" }; + +type RequireSpecialChar = { type: "RequireSpecialChar" }; + +type PasswordCriteria = RequireUppercase | RequireLowercase | MinimumLength | RequireNumber | RequireSpecialChar; + +type PasswordStrength = "Weak" | "Moderate" | "Strong"; + +type Password = string; + +type Criteria = PasswordCriteria[]; + +type Strength = PasswordStrength; + +type Model = [password: Password, criteria: Criteria, strength: Strength]; + +const initialModel: Model = [ + "", + [ + { type: "MinimumLength", length: 8 }, + { type: "RequireUppercase" }, + { type: "RequireLowercase" }, + { type: "RequireNumber" }, + { type: "RequireSpecialChar" }, + ], + "Weak", +]; + +type UpdatePassword = { type: "UpdatePassword"; password: string }; +type ClearCriteria = { type: "ClearCriteria" }; +type AddCriterion = { type: "AddCriterion"; criterion: PasswordCriteria }; +type RemoveCriterion = { type: "RemoveCriterion"; criterion: PasswordCriteria }; + +type Action = UpdatePassword | ClearCriteria | AddCriterion | RemoveCriterion; + +const meetsMinLength: (password: string, len: number) => boolean = (password, len) => { + return password.length >= len; +}; + +const hasFromSet: (password: Password, set: string) => boolean = (password, set) => { + const loop: (s: string) => boolean = (s) => { + if (s.length === 0) { + return false; + } else { + const first = s[0]; + if (set.includes(first)) { + return true; + } else { + return loop(s.slice(1)); + } + } + }; + return loop(password); +}; + +const hasUppercase: (password: Password) => boolean = (password) => { + return hasFromSet(password, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); +}; + +const hasLowercase: (password: Password) => boolean = (password) => { + return hasFromSet(password, "abcdefghijklmnopqrstuvwxyz"); +}; + +const hasNumber: (password: Password) => boolean = (password) => { + return hasFromSet(password, "0123456789"); +}; + +const hasSpecialChar: (password: Password) => boolean = (password) => { + return hasFromSet(password, "!@#$%^&*()-_=+[]{}|;:,.<>?"); +}; + +const meetsCriterion: (password: Password, criterion: PasswordCriteria) => boolean = (password, criterion) => { + switch (criterion.type) { + case "RequireUppercase": + return hasUppercase(password); + case "RequireLowercase": + return hasLowercase(password); + case "MinimumLength": + return meetsMinLength(password, criterion.length); + case "RequireNumber": + return hasNumber(password); + case "RequireSpecialChar": + return hasSpecialChar(password); + } +}; + +const metCriteria: (password: Password, criteria: PasswordCriteria[]) => PasswordCriteria[] = (password, criteria) => { + return criteria.filter((c: PasswordCriteria) => meetsCriterion(password, c)); +}; + +const strength_of: (num_criteria_met: number) => PasswordStrength = (num_criteria_met) => { + switch (num_criteria_met) { + case 0: + case 1: + case 2: + return "Weak"; + case 3: + return "Moderate"; + case 4: + case 5: + return "Strong"; + default: + return "Strong"; + } +}; + +const calculateStrength: (password: Password, criteria: PasswordCriteria[]) => PasswordStrength = (password, criteria) => { + return strength_of(metCriteria(password, criteria).length); +}; + +// BOOKING MVU PRELUDE + +type Weekday = "M" | "T" | "W" | "R" | "F"; + +type TimeOfDay = "AM" | "PM"; + +type Time = [Weekday, TimeOfDay]; + +type User = string; + +type BookingID = number; + +type Booking = [Time, User, BookingID]; + +type BookingFormData = [Time, User]; + +type Model = [BookingFormData, Booking[], BookingID]; + +type AddBooking = { type: "AddBooking"; user: User; weekday: Weekday; timeOfDay: TimeOfDay }; + +type CancelBooking = { type: "CancelBooking"; user: User; id: number }; + +type ClearBookings = { type: "ClearBookings" }; + +type Action = AddBooking | CancelBooking | ClearBookings; + +const initFormState: [[Weekday, TimeOfDay], string] = [["M", "AM"], ""]; + +const Model_init: Model = [initFormState, [], 0]; + +const getBookings: (model: Model) => Booking[] = (model) => { + const [, bs,] = model; + return bs; +}; + +const bookingExists: (model: Model, booking: Booking) => boolean = (model, booking) => { + return getBookings(model).some((b) => b[0] === booking[0] && b[1] === booking[1] && b[2] === booking[2]); +}; + +const getUserBookings: (model: Model, user: User) => Booking[] = (model, user) => { + return getBookings(model).filter(([, u,]) => u === user); +}; + +const getBookingById: (model: Model, id: BookingID) => Booking | undefined = (model, id) => { + const bookings = getBookings(model).filter(([, , i]) => i === id); + return bookings.length > 0 ? bookings[0] : undefined; +}; + +const rm_booking: (user: User, id: BookingID, bookings: Booking[]) => Booking[] = (user, id, bookings) => { + return bookings.filter(([, u, i]) => (u !== user) || (i !== id)); +} + +// EMOJIPAINT MVU PRELUDE + +type Emoji = string; +type Row = number; +type Col = number; +type Grid = Emoji[][]; + +type Model = [Grid, Emoji, Emoji[]]; + +type SelectEmoji = { type: "SelectEmoji"; emoji: Emoji } // Set the currently selected emoji +type StampEmoji = { type: "StampEmoji"; row: Row; col: Col } // Stamp the current emoji at the specified position +type ClearCell = { type: "ClearCell"; row: Row; col: Col } // Clear the emoji at the specified position +type ClearGrid = { type: "ClearGrid" } // Clear the entire grid +type FillRow = { type: "FillRow"; row: Row }; // Fill the specified row with the current emoji + +type Action = SelectEmoji | StampEmoji | ClearCell | ClearGrid | FillRow; + +const model_init: Model = [ + [["", "", ""], ["", "", ""], ["", "", ""]], // Initial 3x3 empty grid + "😄", // Initial selected emoji + ["😄", "😅", "😆", "😉", "😊"] // Available emojis +]; + +const updateGrid: (grid: Grid, row: Row, col: Col, emoji: Emoji) => Grid = (grid, row, col, emoji) => { + return grid.map((r, i) => { + if (i === row) { + return r.map((c, j) => j === col ? emoji : c); + } else { + return r; + } + }); +}; + +const clearGrid: (grid: Grid) => Grid = (grid) => { + return grid.map(row => row.map(_ => "")); +}; + +const fillRowInGrid: (grid: Grid, rowToFill: Row, emoji: Emoji) => Grid = (grid, rowToFill, emoji) => { + return grid.map((row, i) => { + if (i === rowToFill) { + return row.map(_ => emoji); + } else { + return row; + } + }); +}; diff --git a/targets/emojipaint/checkConsistency.ts b/targets/emojipaint/checkConsistency.ts new file mode 100644 index 0000000..c3304a0 --- /dev/null +++ b/targets/emojipaint/checkConsistency.ts @@ -0,0 +1,6 @@ +import {Model, Action} from "/home/jacob/projects/context-extractor/targets/emojipaint/prelude.ts" +function check(a: (grid: Grid, rowToFill: Row, emoji: Emoji) => Grid): (model: Model, action: Action) => Model { return a; } +function check(a: (grid: Grid, rowToFill: Row, emoji: Emoji) => Grid): Model { return a; } +function check(a: (grid: Grid, rowToFill: Row, emoji: Emoji) => Grid): Grid { return a; } +function check(a: (grid: Grid, rowToFill: Row, emoji: Emoji) => Grid): Emoji { return a; } +function check(a: (grid: Grid, rowToFill: Row, emoji: Emoji) => Grid): Emoji[] { return a; } \ No newline at end of file diff --git a/targets/passwords/checkConsistency.ts b/targets/passwords/checkConsistency.ts new file mode 100644 index 0000000..ce4ac59 --- /dev/null +++ b/targets/passwords/checkConsistency.ts @@ -0,0 +1,9 @@ +import {Model, Action} from "/home/jacob/projects/context-extractor/targets/passwords/prelude.ts" +function check(a: (password: Password, criteria: PasswordCriteria[]) => PasswordStrength): (model: Model, action: Action) => Model { return a; } +function check(a: (password: Password, criteria: PasswordCriteria[]) => PasswordStrength): Model { return a; } +function check(a: (password: Password, criteria: PasswordCriteria[]) => PasswordStrength): password { return a; } +function check(a: (password: Password, criteria: PasswordCriteria[]) => PasswordStrength): criteria { return a; } +function check(a: (password: Password, criteria: PasswordCriteria[]) => PasswordStrength): strength { return a; } +function check(a: (password: Password, criteria: PasswordCriteria[]) => PasswordStrength): Password { return a; } +function check(a: (password: Password, criteria: PasswordCriteria[]) => PasswordStrength): Criteria { return a; } +function check(a: (password: Password, criteria: PasswordCriteria[]) => PasswordStrength): Strength { return a; } \ No newline at end of file diff --git a/targets/playlist/checkConsistency.ts b/targets/playlist/checkConsistency.ts new file mode 100644 index 0000000..cf66ba1 --- /dev/null +++ b/targets/playlist/checkConsistency.ts @@ -0,0 +1,4 @@ +function check(a: (playlist: PlayList) => PlayListState): (pl: PlayList, pla: PlayListAction) => PlayList { return a; } +function check(a: (playlist: PlayList) => PlayListState): PlayList { return a; } +function check(a: (playlist: PlayList) => PlayListState): Id[] { return a; } +function check(a: (playlist: PlayList) => PlayListState): PlayListState { return a; } \ No newline at end of file diff --git a/targets/starcoder-booking/checkConsistency.ts b/targets/starcoder-booking/checkConsistency.ts new file mode 100644 index 0000000..9c5f373 --- /dev/null +++ b/targets/starcoder-booking/checkConsistency.ts @@ -0,0 +1,10 @@ +import {AddBooking, CancelBooking, ClearBookings, Weekday, TimeOfDay, Time, User, BookingID, Booking, BookingFormData, Model, Action} from "/home/jacob/projects/context-extractor/targets/starcoder-booking/prelude.ts" +function check(a: (user: User, id: BookingID, bookings: Booking[]) => Booking[]): (model: Model, action: Action) => Model { return a; } +function check(a: (user: User, id: BookingID, bookings: Booking[]) => Booking[]): Model { return a; } +function check(a: (user: User, id: BookingID, bookings: Booking[]) => Booking[]): BookingFormData { return a; } +function check(a: (user: User, id: BookingID, bookings: Booking[]) => Booking[]): Time { return a; } +function check(a: (user: User, id: BookingID, bookings: Booking[]) => Booking[]): Weekday { return a; } +function check(a: (user: User, id: BookingID, bookings: Booking[]) => Booking[]): TimeOfDay { return a; } +function check(a: (user: User, id: BookingID, bookings: Booking[]) => Booking[]): User { return a; } +function check(a: (user: User, id: BookingID, bookings: Booking[]) => Booking[]): Booking[] { return a; } +function check(a: (user: User, id: BookingID, bookings: Booking[]) => Booking[]): BookingID { return a; } \ No newline at end of file diff --git a/targets/starcoder-booking/epilogue.js b/targets/starcoder-booking/epilogue.js deleted file mode 100644 index a36c94d..0000000 --- a/targets/starcoder-booking/epilogue.js +++ /dev/null @@ -1,103 +0,0 @@ -import { Model_init, getBookings, getUserBookings, getBookingById } from "./prelude"; -import { update } from "./sketch"; -// ROOM BOOKING MVU EPILOGUE -const test1 = () => { - const model = update(Model_init, { type: "AddBooking", user: "Charles", weekday: "M", timeOfDay: "AM" }); - return { - result: getBookings(model)[0][0][0] === "M" && getBookings(model)[0][0][1] === "AM" && getBookings(model)[0][1] === "Charles" && getBookings(model)[0][2] === 0, - values: [getBookings(model)[0], [["M", "AM"], "Charles", 0]], - }; -}; -const test2 = () => { - const model = update(Model_init, { type: "AddBooking", user: "Alice", weekday: "T", timeOfDay: "PM" }); - return { - result: getBookings(model)[0][0][0] === "T" && getBookings(model)[0][0][1] === "PM" && getBookings(model)[0][1] === "Alice" && getBookings(model)[0][2] === 0, - values: [getBookings(model)[0], [["T", "PM"], "Alice", 0]], - }; -}; -const test3 = () => { - const model = update(Model_init, { type: "AddBooking", user: "Bob", weekday: "W", timeOfDay: "AM" }); - return { - result: getUserBookings(model, "Bob")[0][0][0] === "W" && getUserBookings(model, "Bob")[0][0][1] === "AM" && getUserBookings(model, "Bob")[0][1] === "Bob" && getUserBookings(model, "Bob")[0][2] === 0, - values: [getUserBookings(model, "Bob")[0], [["W", "AM"], "Bob", 0]], - }; -}; -const test4 = () => { - let model = update(Model_init, { type: "AddBooking", user: "Alice", weekday: "R", timeOfDay: "PM" }); - model = update(model, { type: "CancelBooking", user: "Alice", id: 0 }); - return { - result: getUserBookings(model, "Alice").length === 0, - values: [getUserBookings(model, "Alice").length, 0], - }; -}; -const test5 = () => { - let model = update(Model_init, { type: "AddBooking", user: "Alice", weekday: "F", timeOfDay: "AM" }); - model = update(model, { type: "AddBooking", user: "Bob", weekday: "F", timeOfDay: "AM" }); - const booking = getBookingById(model, 1); - return { - result: booking !== undefined && booking[0][0] === "F" && booking[0][1] === "AM" && booking[1] === "Bob" && booking[2] === 1, - values: [booking, [["F", "AM"], "Bob", 1]], - }; -}; -const test6 = () => { - let model = update(Model_init, { type: "AddBooking", user: "Alice", weekday: "M", timeOfDay: "AM" }); - model = update(model, { type: "AddBooking", user: "Bob", weekday: "M", timeOfDay: "PM" }); - model = update(model, { type: "AddBooking", user: "Alice", weekday: "T", timeOfDay: "AM" }); - model = update(model, { type: "AddBooking", user: "Bob", weekday: "T", timeOfDay: "PM" }); - model = update(model, { type: "AddBooking", user: "Alice", weekday: "W", timeOfDay: "AM" }); - model = update(model, { type: "CancelBooking", user: "Alice", id: 0 }); - model = update(model, { type: "CancelBooking", user: "Bob", id: 3 }); - return { - result: getBookings(model).length === 3 && - getBookings(model)[0][0][0] === "M" && getBookings(model)[0][0][1] === "PM" && getBookings(model)[0][1] === "Bob" && getBookings(model)[0][2] === 1 && - getBookings(model)[1][0][0] === "T" && getBookings(model)[1][0][1] === "AM" && getBookings(model)[1][1] === "Alice" && getBookings(model)[1][2] === 2 && - getBookings(model)[2][0][0] === "W" && getBookings(model)[2][0][1] === "AM" && getBookings(model)[2][1] === "Alice" && getBookings(model)[2][2] === 4, - values: [getBookings(model), [ - [["M", "PM"], "Bob", 1], - [["T", "AM"], "Alice", 2], - [["W", "AM"], "Alice", 4], - ]], - }; -}; -const test7 = () => { - let model = update(Model_init, { type: "AddBooking", user: "Alice", weekday: "M", timeOfDay: "AM" }); - model = update(model, { type: "AddBooking", user: "Bob", weekday: "M", timeOfDay: "AM" }); - model = update(model, { type: "AddBooking", user: "Charlie", weekday: "M", timeOfDay: "AM" }); - model = update(model, { type: "AddBooking", user: "Dave", weekday: "M", timeOfDay: "PM" }); - model = update(model, { type: "AddBooking", user: "Eve", weekday: "M", timeOfDay: "PM" }); - model = update(model, { type: "CancelBooking", user: "Bob", id: 1 }); - model = update(model, { type: "CancelBooking", user: "Dave", id: 3 }); - model = update(model, { type: "CancelBooking", user: "Alice", id: 0 }); - return { - result: getBookings(model).length === 2 && - getBookings(model)[0][0][0] === "M" && getBookings(model)[0][0][1] === "AM" && getBookings(model)[0][1] === "Charlie" && getBookings(model)[0][2] === 2 && - getBookings(model)[1][0][0] === "M" && getBookings(model)[1][0][1] === "PM" && getBookings(model)[1][1] === "Eve" && getBookings(model)[1][2] === 4, - values: [getBookings(model), [ - [["M", "AM"], "Charlie", 2], - [["M", "PM"], "Eve", 4], - ]], - }; -}; -const test8 = () => { - let model = update(Model_init, { type: "AddBooking", user: "Alice", weekday: "M", timeOfDay: "AM" }); - model = update(model, { type: "ClearBookings" }); - return { - result: getBookings(model).length === 0, - values: [getBookings(model).length, 0], - }; -}; -const tests = [test1, test2, test3, test4, test5, test6, test7, test8]; -let score = 0; -for (let i = 0; i < tests.length; ++i) { - try { - const run = tests[i](); - console.assert(run.result === true, "%o", { i: i + 1, values: run.values }); - if (run.result) { - score++; - } - } - catch (err) { - console.log(err); - } -} -console.log(`score: ${score} / ${tests.length}`); diff --git a/targets/starcoder-booking/prelude.js b/targets/starcoder-booking/prelude.js deleted file mode 100644 index af92576..0000000 --- a/targets/starcoder-booking/prelude.js +++ /dev/null @@ -1,21 +0,0 @@ -// ROOM BOOKING MVU -const initFormState = [["M", "AM"], ""]; -const Model_init = [initFormState, [], 0]; -const getBookings = (model) => { - const [, bs,] = model; - return bs; -}; -const bookingExists = (model, booking) => { - return getBookings(model).some((b) => b[0] === booking[0] && b[1] === booking[1] && b[2] === booking[2]); -}; -const getUserBookings = (model, user) => { - return getBookings(model).filter(([, u,]) => u === user); -}; -const getBookingById = (model, id) => { - const bookings = getBookings(model).filter(([, , i]) => i === id); - return bookings.length > 0 ? bookings[0] : undefined; -}; -const rm_booking = (user, id, bookings) => { - return bookings.filter(([, u, i]) => (u !== user) || (i !== id)); -}; -export { initFormState, Model_init, getBookings, bookingExists, getUserBookings, getBookingById, rm_booking }; diff --git a/targets/starcoder-booking/sketch.ts b/targets/starcoder-booking/sketch.ts new file mode 100644 index 0000000..fa03207 --- /dev/null +++ b/targets/starcoder-booking/sketch.ts @@ -0,0 +1,7 @@ +import { Model, Action } from "./prelude"; + +// Update the Room Booking app model based on an action +const update: (model: Model, action: Action) => Model = + _() + +export { update }; diff --git a/targets/starcoder-booking/starcoder-sketch.ts b/targets/starcoder-booking/starcoder-sketch.ts new file mode 100644 index 0000000..741ea39 --- /dev/null +++ b/targets/starcoder-booking/starcoder-sketch.ts @@ -0,0 +1,4 @@ +import { Model, Action } from "./prelude"; + +// Update the Room Booking app model based on an action +const update = (model: Model, action: Action): Model => { diff --git a/targets/starcoder-emojipaint/checkConsistency.ts b/targets/starcoder-emojipaint/checkConsistency.ts new file mode 100644 index 0000000..177e5d0 --- /dev/null +++ b/targets/starcoder-emojipaint/checkConsistency.ts @@ -0,0 +1,6 @@ +import {Model, Action} from "/home/jacob/projects/context-extractor/targets/starcoder-emojipaint/prelude.ts" +function check(a: (grid: Grid, rowToFill: Row, emoji: Emoji) => Grid): (model: Model, action: Action) => Model { return a; } +function check(a: (grid: Grid, rowToFill: Row, emoji: Emoji) => Grid): Model { return a; } +function check(a: (grid: Grid, rowToFill: Row, emoji: Emoji) => Grid): Grid { return a; } +function check(a: (grid: Grid, rowToFill: Row, emoji: Emoji) => Grid): Emoji { return a; } +function check(a: (grid: Grid, rowToFill: Row, emoji: Emoji) => Grid): Emoji[] { return a; } \ No newline at end of file diff --git a/targets/starcoder-emojipaint/epilogue.js b/targets/starcoder-emojipaint/epilogue.js deleted file mode 100644 index 74944d2..0000000 --- a/targets/starcoder-emojipaint/epilogue.js +++ /dev/null @@ -1,108 +0,0 @@ -import { model_init } from "./prelude"; -import { update } from "./sketch"; -// EMOJIPAINT MVU EPILOGUE -const test1 = () => { - const [grid, ,] = update(model_init, { type: "StampEmoji", row: 0, col: 0 }); - return { - result: grid[0][0] === "😄" && grid[0][1] === "" && grid[0][2] === "" && grid[1][0] === "" && grid[1][1] === "" && grid[1][2] === "" && grid[2][0] === "" && grid[2][1] === "" && grid[2][2] === "", - values: [grid, [["😄", "", ""], ["", "", ""], ["", "", ""]]], - }; -}; -const test2 = () => { - const [grid, ,] = update(model_init, { type: "FillRow", row: 1 }); - return { - result: grid[0][0] === "" && grid[0][1] === "" && grid[0][2] === "" && grid[1][0] === "😄" && grid[1][1] === "😄" && grid[1][2] === "😄" && grid[2][0] === "" && grid[2][1] === "" && grid[2][2] === "", - values: [grid, [["", "", ""], ["😄", "😄", "😄"], ["", "", ""]]], - }; -}; -const test3 = () => { - let model = update(model_init, { type: "SelectEmoji", emoji: "😅" }); - const [grid, selectedEmoji,] = update(model, { type: "StampEmoji", row: 2, col: 2 }); - return { - result: grid[0][0] === "" && grid[0][1] === "" && grid[0][2] === "" && grid[1][0] === "" && grid[1][1] === "" && grid[1][2] === "" && grid[2][0] === "" && grid[2][1] === "" && grid[2][2] === "😅" && selectedEmoji === "😅", - values: [grid, [["", "", ""], ["", "", ""], ["", "", "😅"]], selectedEmoji, "😅"], - }; -}; -const test4 = () => { - let model = update(model_init, { type: "FillRow", row: 0 }); - const [grid, ,] = update(model, { type: "ClearCell", row: 0, col: 1 }); - return { - result: grid[0][0] === "😄" && grid[0][1] === "" && grid[0][2] === "😄" && grid[1][0] === "" && grid[1][1] === "" && grid[1][2] === "" && grid[2][0] === "" && grid[2][1] === "" && grid[2][2] === "", - values: [grid, [["😄", "", "😄"], ["", "", ""], ["", "", ""]]], - }; -}; -const test5 = () => { - let model = update(model_init, { type: "StampEmoji", row: 1, col: 1 }); - const [grid, ,] = update(model, { type: "ClearGrid" }); - return { - result: grid[0][0] === "" && grid[0][1] === "" && grid[0][2] === "" && grid[1][0] === "" && grid[1][1] === "" && grid[1][2] === "" && grid[2][0] === "" && grid[2][1] === "" && grid[2][2] === "", - values: [grid, [["", "", ""], ["", "", ""], ["", "", ""]]], - }; -}; -const test6 = () => { - const [, selectedEmoji,] = update(model_init, { type: "SelectEmoji", emoji: "😊" }); - const [grid_init, , emojiList_init] = model_init; - const [grid, ,] = update([grid_init, selectedEmoji, emojiList_init], { type: "StampEmoji", row: 1, col: 2 }); - return { - result: grid[0][0] === "" && grid[0][1] === "" && grid[0][2] === "" && grid[1][0] === "" && grid[1][1] === "" && grid[1][2] === "😊" && grid[2][0] === "" && grid[2][1] === "" && grid[2][2] === "", - values: [grid, [["", "", ""], ["", "", "😊"], ["", "", ""]]], - }; -}; -const test7 = () => { - const [, selectedEmoji, emojiList] = model_init; - const model = update(model_init, { type: "FillRow", row: 2 }); - const [grid, ,] = update(model, { type: "ClearCell", row: 2, col: 0 }); - return { - result: grid[0][0] === "" && grid[0][1] === "" && grid[0][2] === "" && grid[1][0] === "" && grid[1][1] === "" && grid[1][2] === "" && grid[2][0] === "" && grid[2][1] === "😄" && grid[2][2] === "😄", - values: [grid, [["", "", ""], ["", "", ""], ["", "😄", "😄"]]], - }; -}; -const test8 = () => { - let model = update(model_init, { type: "StampEmoji", row: 0, col: 0 }); - model = update(model, { type: "StampEmoji", row: 1, col: 1 }); - model = update(model, { type: "StampEmoji", row: 2, col: 2 }); - const [grid, ,] = update(model, { type: "ClearGrid" }); - return { - result: grid[0][0] === "" && grid[0][1] === "" && grid[0][2] === "" && grid[1][0] === "" && grid[1][1] === "" && grid[1][2] === "" && grid[2][0] === "" && grid[2][1] === "" && grid[2][2] === "", - values: [grid, [["", "", ""], ["", "", ""], ["", "", ""]]], - }; -}; -const test9 = () => { - const [grid_init, , emojiList_init] = model_init; - let model = update(model_init, { type: "FillRow", row: 0 }); - const [, selectedEmoji,] = update(model, { type: "SelectEmoji", emoji: "😆" }); - const [grid, ,] = model; - const [updatedGrid, ,] = update([grid, selectedEmoji, emojiList_init], { type: "StampEmoji", row: 1, col: 1 }); - return { - result: updatedGrid[0][0] === "😄" && updatedGrid[0][1] === "😄" && updatedGrid[0][2] === "😄" && updatedGrid[1][0] === "" && updatedGrid[1][1] === "😆" && updatedGrid[1][2] === "" && updatedGrid[2][0] === "" && updatedGrid[2][1] === "" && updatedGrid[2][2] === "", - values: [updatedGrid, [["😄", "😄", "😄"], ["", "😆", ""], ["", "", ""]]], - }; -}; -const test10 = () => { - let model = update(model_init, { type: "StampEmoji", row: 0, col: 0 }); - model = update(model, { type: "FillRow", row: 2 }); - const [grid, , emojiList] = model; - model = update(model, { type: "SelectEmoji", emoji: "😉" }); - model = update(model, { type: "StampEmoji", row: 1, col: 1 }); - model = update(model, { type: "ClearCell", row: 2, col: 2 }); - const [updatedGrid, selectedEmoji, _] = model; - return { - result: updatedGrid[0][0] === "😄" && updatedGrid[0][1] === "" && updatedGrid[0][2] === "" && updatedGrid[1][0] === "" && updatedGrid[1][1] === "😉" && updatedGrid[1][2] === "" && updatedGrid[2][0] === "😄" && updatedGrid[2][1] === "😄" && updatedGrid[2][2] === "" && selectedEmoji === "😉", - values: [updatedGrid, [["😄", "", ""], ["", "😉", ""], ["😄", "😄", ""]], selectedEmoji, "😉"], - }; -}; -const tests = [test1, test2, test3, test4, test5, test6, test7, test8, test9, test10]; -let score = 0; -for (let i = 0; i < tests.length; ++i) { - try { - const run = tests[i](); - console.assert(run.result === true, "%o", { i: i + 1, values: run.values }); - if (run.result) { - score++; - } - } - catch (err) { - console.log(err); - } -} -console.log(`score: ${score} / ${tests.length}`); diff --git a/targets/starcoder-emojipaint/prelude.js b/targets/starcoder-emojipaint/prelude.js deleted file mode 100644 index f1d8609..0000000 --- a/targets/starcoder-emojipaint/prelude.js +++ /dev/null @@ -1,30 +0,0 @@ -// EMOJIPAINT MVU -const model_init = [ - [["", "", ""], ["", "", ""], ["", "", ""]], // Initial 3x3 empty grid - "😄", // Initial selected emoji - ["😄", "😅", "😆", "😉", "😊"] // Available emojis -]; -const updateGrid = (grid, row, col, emoji) => { - return grid.map((r, i) => { - if (i === row) { - return r.map((c, j) => j === col ? emoji : c); - } - else { - return r; - } - }); -}; -const clearGrid = (grid) => { - return grid.map(row => row.map(_ => "")); -}; -const fillRowInGrid = (grid, rowToFill, emoji) => { - return grid.map((row, i) => { - if (i === rowToFill) { - return row.map(_ => emoji); - } - else { - return row; - } - }); -}; -export { model_init, updateGrid, clearGrid, fillRowInGrid }; diff --git a/targets/starcoder-emojipaint/sketch.ts b/targets/starcoder-emojipaint/sketch.ts new file mode 100644 index 0000000..ce416df --- /dev/null +++ b/targets/starcoder-emojipaint/sketch.ts @@ -0,0 +1,7 @@ +import { Model, Action } from "./prelude"; + +// Update the EmojiPaint app model based on an action +const update: (model: Model, action: Action) => Model = + _() + +export { update }; diff --git a/targets/starcoder-emojipaint/starcoder-sketch.ts b/targets/starcoder-emojipaint/starcoder-sketch.ts new file mode 100644 index 0000000..70a4bd4 --- /dev/null +++ b/targets/starcoder-emojipaint/starcoder-sketch.ts @@ -0,0 +1,4 @@ +import { Model, Action } from "./prelude"; + +// Update the EmojiPaint app model based on an action +const update = (model: Model, action: Action): Model => { diff --git a/targets/starcoder-passwords/checkConsistency.ts b/targets/starcoder-passwords/checkConsistency.ts new file mode 100644 index 0000000..68f9447 --- /dev/null +++ b/targets/starcoder-passwords/checkConsistency.ts @@ -0,0 +1,9 @@ +import {Model, Action} from "/home/jacob/projects/context-extractor/targets/starcoder-passwords/prelude.ts" +function check(a: PasswordStrength): (model: Model, action: Action) => Model { return a; } +function check(a: PasswordStrength): Model { return a; } +function check(a: PasswordStrength): password { return a; } +function check(a: PasswordStrength): criteria { return a; } +function check(a: PasswordStrength): strength { return a; } +function check(a: PasswordStrength): Password { return a; } +function check(a: PasswordStrength): Criteria { return a; } +function check(a: PasswordStrength): Strength { return a; } \ No newline at end of file diff --git a/targets/starcoder-passwords/epilogue.js b/targets/starcoder-passwords/epilogue.js deleted file mode 100644 index aeda502..0000000 --- a/targets/starcoder-passwords/epilogue.js +++ /dev/null @@ -1,123 +0,0 @@ -// import { RequireUppercase, RequireLowercase, MinimumLength, RequireNumber, RequireSpecialChar, PasswordCriteria, PasswordStrength, Password, Criteria, Strength, Model, initialModel, UpdatePassword, ClearCriteria, AddCriterion, RemoveCriterion, Action, meetsMinLength, hasFromSet, hasUppercase, hasLowercase, hasNumber, hasSpecialChar, meetsCriterion, metCriteria, strength_of, calculateStrength } from "./prelude"; -import { initialModel } from "./prelude"; -import { update } from "./sketch"; -// PASSWORDS MVU EPILOGUE -const test1 = () => { - const model = update(initialModel, { type: "ClearCriteria" }); - const [, criteria,] = model; - return { - result: criteria.length === 0, - values: [criteria.length, 0], - }; -}; -const test2 = () => { - let model = update(initialModel, { type: "ClearCriteria" }); - model = update(model, { type: "AddCriterion", criterion: { type: "RequireUppercase" } }); - const [, criteria,] = model; - return { - result: criteria.length === 1, - values: [criteria.length, 1], - }; -}; -const test3 = () => { - const model = update(initialModel, { type: "UpdatePassword", password: "pass" }); - const [password, , strength] = model; - return { - result: password === "pass" && strength === "Weak", - values: [password, "pass", strength, "Weak"], - }; -}; -const test4 = () => { - const model = update(initialModel, { type: "UpdatePassword", password: "password" }); - const [password, , strength] = model; - return { - result: password === "password" && strength === "Weak", - values: [password, "password", strength, "Weak"], - }; -}; -const test5 = () => { - const model = update(initialModel, { type: "UpdatePassword", password: "Password123" }); - const [password, , strength] = model; - return { - result: password === "Password123" && strength === "Strong", - values: [password, "Password123", strength, "Strong"], - }; -}; -const test6 = () => { - const model = update(initialModel, { type: "UpdatePassword", password: "Password123!" }); - const [password, , strength] = model; - return { - result: password === "Password123!" && strength === "Strong", - values: [password, "Password123!", strength, "Strong"], - }; -}; -const test7 = () => { - let model = update(initialModel, { type: "UpdatePassword", password: "password" }); - model = update(model, { type: "AddCriterion", criterion: { type: "RequireUppercase" } }); - const [password, criteria, strength] = model; - return { - result: password === "password" && criteria.length === 6 && strength === "Weak", - values: [password, "password", criteria.length, 6, strength, "Weak"], - }; -}; -const test8 = () => { - let model = update(initialModel, { type: "UpdatePassword", password: "Password123!" }); - model = update(model, { type: "RemoveCriterion", criterion: { type: "RequireUppercase" } }); - const [password, criteria, strength] = model; - return { - result: password === "Password123!" && criteria.length === 4 && strength === "Strong", - values: [password, "Password123!", criteria.length, 4, strength, "Strong"], - }; -}; -const test9 = () => { - let model = update(initialModel, { type: "UpdatePassword", password: "pass" }); - model = update(model, { type: "RemoveCriterion", criterion: { type: "MinimumLength", length: 8 } }); - const [password, criteria, strength] = model; - return { - result: password === "pass" && criteria.length === 4 && strength === "Weak", - values: [password, "pass", criteria.length, 4, strength, "Weak"], - }; -}; -const test10 = () => { - let model = update(initialModel, { type: "UpdatePassword", password: "Passw0rd!" }); - model = update(model, { type: "RemoveCriterion", criterion: { type: "RequireSpecialChar" } }); - const [password, criteria, strength] = model; - return { - result: password === "Passw0rd!" && criteria.length === 4 && strength === "Strong", - values: [password, "Passw0rd!", criteria.length, 4, strength, "Strong"], - }; -}; -const test11 = () => { - let model = update(initialModel, { type: "UpdatePassword", password: "password123" }); - model = update(model, { type: "AddCriterion", criterion: { type: "RequireSpecialChar" } }); - const [password, criteria, strength] = model; - return { - result: password === "password123" && criteria.length === 6 && strength === "Moderate", - values: [password, "password123", criteria.length, 6, strength, "Moderate"], - }; -}; -const test12 = () => { - let model = update(initialModel, { type: "UpdatePassword", password: "P@ssw0rd!" }); - model = update(model, { type: "RemoveCriterion", criterion: { type: "RequireUppercase" } }); - model = update(model, { type: "RemoveCriterion", criterion: { type: "RequireSpecialChar" } }); - const [password, criteria, strength] = model; - return { - result: password === "P@ssw0rd!" && criteria.length === 3 && strength === "Moderate", - values: [password, "P@ssw0rd!", criteria.length, 3, strength, "Moderate"], - }; -}; -const tests = [test1, test2, test3, test4, test5, test6, test7, test8, test9, test10, test11, test12]; -let score = 0; -for (let i = 0; i < tests.length; ++i) { - try { - const run = tests[i](); - console.assert(run.result === true, "%o", { i: i + 1, values: run.values }); - if (run.result) { - score++; - } - } - catch (err) { - console.log(err); - } -} -console.log(`score: ${score} / ${tests.length}`); diff --git a/targets/starcoder-passwords/prelude.js b/targets/starcoder-passwords/prelude.js deleted file mode 100644 index 7c5c92e..0000000 --- a/targets/starcoder-passwords/prelude.js +++ /dev/null @@ -1,79 +0,0 @@ -const initialModel = [ - "", - [ - { type: "MinimumLength", length: 8 }, - { type: "RequireUppercase" }, - { type: "RequireLowercase" }, - { type: "RequireNumber" }, - { type: "RequireSpecialChar" }, - ], - "Weak", -]; -const meetsMinLength = (password, len) => { - return password.length >= len; -}; -const hasFromSet = (password, set) => { - const loop = (s) => { - if (s.length === 0) { - return false; - } - else { - const first = s[0]; - if (set.includes(first)) { - return true; - } - else { - return loop(s.slice(1)); - } - } - }; - return loop(password); -}; -const hasUppercase = (password) => { - return hasFromSet(password, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); -}; -const hasLowercase = (password) => { - return hasFromSet(password, "abcdefghijklmnopqrstuvwxyz"); -}; -const hasNumber = (password) => { - return hasFromSet(password, "0123456789"); -}; -const hasSpecialChar = (password) => { - return hasFromSet(password, "!@#$%^&*()-_=+[]{}|;:,.<>?"); -}; -const meetsCriterion = (password, criterion) => { - switch (criterion.type) { - case "RequireUppercase": - return hasUppercase(password); - case "RequireLowercase": - return hasLowercase(password); - case "MinimumLength": - return meetsMinLength(password, criterion.length); - case "RequireNumber": - return hasNumber(password); - case "RequireSpecialChar": - return hasSpecialChar(password); - } -}; -const metCriteria = (password, criteria) => { - return criteria.filter((c) => meetsCriterion(password, c)); -}; -const strength_of = (num_criteria_met) => { - switch (num_criteria_met) { - case 0: - case 1: - case 2: - return "Weak"; - case 3: - return "Moderate"; - case 4: - case 5: - return "Strong"; - default: - return "Strong"; - } -}; -const calculateStrength = (password, criteria) => { - return strength_of(metCriteria(password, criteria).length); -}; -export { initialModel, meetsMinLength, hasFromSet, hasUppercase, hasLowercase, hasNumber, hasSpecialChar, meetsCriterion, metCriteria, strength_of, calculateStrength }; diff --git a/targets/starcoder-passwords/sketch.ts b/targets/starcoder-passwords/sketch.ts new file mode 100644 index 0000000..36cd524 --- /dev/null +++ b/targets/starcoder-passwords/sketch.ts @@ -0,0 +1,7 @@ +import { Model, Action } from "./prelude"; + +// Update Password Strength Checker app model based on an action +const update: (model: Model, action: Action) => Model = + _() + +export { update }; diff --git a/targets/starcoder-passwords/starcoder-sketch.ts b/targets/starcoder-passwords/starcoder-sketch.ts new file mode 100644 index 0000000..c0dbf76 --- /dev/null +++ b/targets/starcoder-passwords/starcoder-sketch.ts @@ -0,0 +1,4 @@ +import { Model, Action } from "./prelude"; + +// Update Password Strength Checker app model based on an action +const update = (model: Model, action: Action): Model => { diff --git a/targets/starcoder-playlist/checkConsistency.ts b/targets/starcoder-playlist/checkConsistency.ts new file mode 100644 index 0000000..cf66ba1 --- /dev/null +++ b/targets/starcoder-playlist/checkConsistency.ts @@ -0,0 +1,4 @@ +function check(a: (playlist: PlayList) => PlayListState): (pl: PlayList, pla: PlayListAction) => PlayList { return a; } +function check(a: (playlist: PlayList) => PlayListState): PlayList { return a; } +function check(a: (playlist: PlayList) => PlayListState): Id[] { return a; } +function check(a: (playlist: PlayList) => PlayListState): PlayListState { return a; } \ No newline at end of file diff --git a/targets/starcoder-playlist/epilogue.js b/targets/starcoder-playlist/epilogue.js deleted file mode 100644 index 366ef40..0000000 --- a/targets/starcoder-playlist/epilogue.js +++ /dev/null @@ -1,142 +0,0 @@ -import { get_state, get_songs } from "./prelude"; -import { update } from "./sketch"; -const PlayListState_eq = (s1, s2) => { - if (s1.type === "Playing" && s2.type === "Playing") { - return s1.id === s2.id; - } - else if (s1.type === "PausedOn" && s2.type === "PausedOn") { - return s1.id === s2.id; - } - else { - return s1.type === "NoSongSelected" && s2.type === "NoSongSelected"; - } -}; -const PlayList_eq = (p1, p2) => { - return (PlayListState_eq(get_state(p1), get_state(p2)) && - get_songs(p1).length === get_songs(p2).length && - get_songs(p1).every((id, i) => id === get_songs(p2)[i])); -}; -// Testing PlaySong -const test1 = () => ({ - result: PlayList_eq(update([[0, 1, 2], { type: "NoSongSelected" }], { type: "PlaySong", id: 0 }), [[0, 1, 2], { type: "Playing", id: 0 }]), - values: [ - update([[0, 1, 2], { type: "NoSongSelected" }], { type: "PlaySong", id: 0 }), - [[0, 1, 2], { type: "Playing", id: 0 }] - ] -}); -const test2 = () => ({ - result: PlayList_eq(update([[0, 1, 2], { type: "PausedOn", id: 1 }], { type: "PlaySong", id: 1 }), [[0, 1, 2], { type: "Playing", id: 1 }]), - values: [ - update([[0, 1, 2], { type: "PausedOn", id: 1 }], { type: "PlaySong", id: 1 }), - [[0, 1, 2], { type: "Playing", id: 1 }] - ] -}); -const test3 = () => ({ - result: PlayList_eq(update([[0, 1, 2], { type: "PausedOn", id: 0 }], { type: "PlaySong", id: 1 }), [[0, 1, 2], { type: "Playing", id: 1 }]), - values: [ - update([[0, 1, 2], { type: "PausedOn", id: 0 }], { type: "PlaySong", id: 1 }), - [[0, 1, 2], { type: "Playing", id: 1 }] - ] -}); -// Testing PauseCurrentSong -const test4 = () => ({ - result: PlayList_eq(update([[0, 1, 2], { type: "NoSongSelected" }], { type: "PauseCurrentSong" }), [[0, 1, 2], { type: "NoSongSelected" }]), - values: [ - update([[0, 1, 2], { type: "NoSongSelected" }], { type: "PauseCurrentSong" }), - [[0, 1, 2], { type: "NoSongSelected" }] - ] -}); -const test5 = () => ({ - result: PlayList_eq(update([[0, 1, 2], { type: "PausedOn", id: 1 }], { type: "PauseCurrentSong" }), [[0, 1, 2], { type: "PausedOn", id: 1 }]), - values: [ - update([[0, 1, 2], { type: "PausedOn", id: 1 }], { type: "PauseCurrentSong" }), - [[0, 1, 2], { type: "PausedOn", id: 1 }] - ] -}); -const test6 = () => ({ - result: PlayList_eq(update([[0, 1, 2], { type: "Playing", id: 0 }], { type: "PauseCurrentSong" }), [[0, 1, 2], { type: "PausedOn", id: 0 }]), - values: [ - update([[0, 1, 2], { type: "Playing", id: 0 }], { type: "PauseCurrentSong" }), - [[0, 1, 2], { type: "PausedOn", id: 0 }] - ] -}); -// Testing RemoveSong -const test7 = () => ({ - result: PlayList_eq(update([[0, 1, 2], { type: "NoSongSelected" }], { type: "RemoveSong", id: 0 }), [[1, 2], { type: "NoSongSelected" }]), - values: [ - update([[0, 1, 2], { type: "NoSongSelected" }], { type: "RemoveSong", id: 0 }), - [[1, 2], { type: "NoSongSelected" }] - ] -}); -const test8 = () => ({ - result: PlayList_eq(update([[0, 1, 2], { type: "Playing", id: 0 }], { type: "RemoveSong", id: 0 }), [[1, 2], { type: "NoSongSelected" }]), - values: [ - update([[0, 1, 2], { type: "Playing", id: 0 }], { type: "RemoveSong", id: 0 }), - [[1, 2], { type: "NoSongSelected" }] - ] -}); -const test9 = () => ({ - result: PlayList_eq(update([[0, 1, 2], { type: "PausedOn", id: 0 }], { type: "RemoveSong", id: 0 }), [[1, 2], { type: "NoSongSelected" }]), - values: [ - update([[0, 1, 2], { type: "PausedOn", id: 0 }], { type: "RemoveSong", id: 0 }), - [[1, 2], { type: "NoSongSelected" }] - ], -}); -const test10 = () => ({ - result: PlayList_eq(update([[0, 1, 2], { type: "Playing", id: 1 }], { type: "RemoveSong", id: 0 }), [[1, 2], { type: "Playing", id: 1 }]), - values: [ - update([[0, 1, 2], { type: "Playing", id: 1 }], { type: "RemoveSong", id: 0 }), - [[1, 2], { type: "Playing", id: 1 }] - ], -}); -const test11 = () => ({ - result: PlayList_eq(update([[0, 1, 2], { type: "PausedOn", id: 1 }], { type: "RemoveSong", id: 0 }), [[1, 2], { type: "PausedOn", id: 1 }]), - values: [ - update([[0, 1, 2], { type: "PausedOn", id: 1 }], { type: "RemoveSong", id: 0 }), - [[1, 2], { type: "PausedOn", id: 1 }] - ], -}); -const test12 = () => ({ - result: PlayList_eq(update([[0, 1, 2], { type: "Playing", id: 1 }], { type: "RemoveSong", id: 3 }), [[0, 1, 2], { type: "Playing", id: 1 }]), - values: [ - update([[0, 1, 2], { type: "Playing", id: 1 }], { type: "RemoveSong", id: 3 }), - [[0, 1, 2], { type: "Playing", id: 1 }] - ], -}); -// Testing AddSong -const test13 = () => ({ - result: PlayList_eq(update([[0, 1, 2], { type: "NoSongSelected" }], { type: "AddSong", id: 3 }), [[0, 1, 2, 3], { type: "NoSongSelected" }]), - values: [ - update([[0, 1, 2], { type: "NoSongSelected" }], { type: "AddSong", id: 3 }), - [[0, 1, 2, 3], { type: "NoSongSelected" }] - ], -}); -const test14 = () => ({ - result: PlayList_eq(update([[0, 1, 2], { type: "Playing", id: 0 }], { type: "AddSong", id: 3 }), [[0, 1, 2, 3], { type: "Playing", id: 0 }]), - values: [ - update([[0, 1, 2], { type: "Playing", id: 0 }], { type: "AddSong", id: 3 }), - [[0, 1, 2, 3], { type: "Playing", id: 0 }] - ], -}); -const test15 = () => ({ - result: PlayList_eq(update([[0, 1, 2], { type: "PausedOn", id: 0 }], { type: "AddSong", id: 3 }), [[0, 1, 2, 3], { type: "PausedOn", id: 0 }]), - values: [ - update([[0, 1, 2], { type: "PausedOn", id: 0 }], { type: "AddSong", id: 3 }), - [[0, 1, 2, 3], { type: "PausedOn", id: 0 }] - ], -}); -const tests = [test1, test2, test3, test4, test5, test6, test7, test8, test9, test10, test11, test12, test13, test14, test15]; -let score = 0; -for (let i = 0; i < tests.length; ++i) { - try { - const run = tests[i](); - console.assert(run.result === true, "%o", { i: i + 1, values: run.values }); - if (run.result) { - score++; - } - } - catch (err) { - console.log(err); - } -} -console.log(`score: ${score} / ${tests.length}`); diff --git a/targets/starcoder-playlist/prelude.js b/targets/starcoder-playlist/prelude.js deleted file mode 100644 index ea7d00b..0000000 --- a/targets/starcoder-playlist/prelude.js +++ /dev/null @@ -1,11 +0,0 @@ -// Get all the song ids in the playList -const get_songs = (playlist) => { - const [songs, _] = playlist; - return songs; -}; -// Get the id of the currently playing song -const get_state = (playlist) => { - const [_, state] = playlist; - return state; -}; -export { get_songs, get_state }; diff --git a/targets/starcoder-playlist/sketch.ts b/targets/starcoder-playlist/sketch.ts new file mode 100644 index 0000000..98e19e5 --- /dev/null +++ b/targets/starcoder-playlist/sketch.ts @@ -0,0 +1,7 @@ +import { PlayList, PlayListAction } from "./prelude"; + +// Update Playlist app model based on an action +const update: (pl: PlayList, pla: PlayListAction) => PlayList = + _() + +export { update }; diff --git a/targets/starcoder-playlist/starcoder-sketch.ts b/targets/starcoder-playlist/starcoder-sketch.ts new file mode 100644 index 0000000..ffcc390 --- /dev/null +++ b/targets/starcoder-playlist/starcoder-sketch.ts @@ -0,0 +1,4 @@ +import { PlayList, PlayListAction } from "./prelude"; + +// Update Playlist app model based on an action +const update = (pl: PlayList, pla: PlayListAction): PlayList => { diff --git a/targets/starcoder-todo/checkConsistency.ts b/targets/starcoder-todo/checkConsistency.ts new file mode 100644 index 0000000..30897c7 --- /dev/null +++ b/targets/starcoder-todo/checkConsistency.ts @@ -0,0 +1,5 @@ +import {Model, Action} from "/home/jacob/projects/context-extractor/targets/starcoder-todo/prelude.ts" +function check(a: (index: number, todos: Todo[]) => Todo[]): (m: Model, a: Action) => Model { return a; } +function check(a: (index: number, todos: Todo[]) => Todo[]): Model { return a; } +function check(a: (index: number, todos: Todo[]) => Todo[]): string { return a; } +function check(a: (index: number, todos: Todo[]) => Todo[]): Todo[] { return a; } \ No newline at end of file diff --git a/targets/starcoder-todo/epilogue.js b/targets/starcoder-todo/epilogue.js deleted file mode 100644 index 47f7ed8..0000000 --- a/targets/starcoder-todo/epilogue.js +++ /dev/null @@ -1,139 +0,0 @@ -import { model_eq } from "./prelude"; -import { update } from "./sketch"; -// utility -const num_todos = (m) => { - return m[1].length; -}; -// tests -// Add adds -const test1 = () => { - return { - result: num_todos(update(["Breath", []], { type: "AddTodo" })) > num_todos(["Breath", []]), - values: [num_todos(update(["Breath", []], { type: "AddTodo" })), num_todos(["Breath", []])] - }; -}; -// Add uses name, initial status set -const test2 = () => { - return { - result: model_eq(update(["Breath", []], { type: "AddTodo" }), ["", [["Breath", false]]]), - values: [ - update(["Breath", []], { type: "AddTodo" }), - ["", [["Breath", false]]] - ] - }; -}; -// Add nonempty (too impl spec? test add + remove eqs) -const test3 = () => { - return { - result: model_eq(update(["Chop wood", [["Carry water", false]]], { type: "AddTodo" }), ["", [["Carry water", false], ["Chop wood", false]]]), - values: [ - update(["Chop wood", [["Carry water", false]]], { type: "AddTodo" }), - ["", [["Carry water", false], ["Chop wood", false]]] - ] - }; -}; -// add then remove doesn't change todos -const test4 = () => { - let todos = [["Breath", false]]; - return { - result: model_eq(update(update(["Remove this", todos], { type: "AddTodo" }), { type: "RemoveTodo", id: 1 }), ["", todos]), - values: [ - update(update(["Remove this", todos], { type: "AddTodo" }), { type: "RemoveTodo", id: 1 }), - ["", todos] - ] - }; -}; -// Toggle preserves length -const test5 = () => { - let model = ["", [["1", false], ["2", false]]]; - return { - result: num_todos(update(model, { type: "ToggleTodo", id: 1 })) === num_todos(model), - values: [num_todos(update(model, { type: "ToggleTodo", id: 1 })), num_todos(model)] - }; -}; -// Toggle toggles right index -const test6 = () => { - return { - result: model_eq(update(["", [["Chop", false], ["Carry", true]]], { type: "ToggleTodo", id: 1 }), ["", [["Chop", false], ["Carry", false]]]), - values: [ - update(["", [["Chop", false], ["Carry", true]]], { type: "ToggleTodo", id: 1 }), - ["", [["Chop", false], ["Carry", false]]] - ] - }; -}; -// Toggle out of bounds -const test7 = () => { - let model = ["", [["Chop", false], ["Carry", false]]]; - return { - result: model_eq(update(model, { type: "ToggleTodo", id: 2 }), model), - values: [ - update(model, { type: "ToggleTodo", id: 2 }), - model - ] - }; -}; -// Remove removes -const test8 = () => { - let model = ["", [["1", false]]]; - return { - result: num_todos(update(model, { type: "RemoveTodo", id: 0 })) < num_todos(model), - values: [num_todos(update(model, { type: "RemoveTodo", id: 0 })), num_todos(model)] - }; -}; -// Remove removes right index -const test9 = () => { - return { - result: model_eq(update(["", [["1", false], ["2", false]]], { type: "RemoveTodo", id: 1 }), ["", [["1", false]]]), - values: [ - update(["", [["1", false], ["2", false]]], { type: "RemoveTodo", id: 1 }), - ["", [["1", false]]] - ] - }; -}; -// Remove out of bounds -const test10 = () => { - let model = ["", [["1", false]]]; - return { - result: model_eq(update(model, { type: "RemoveTodo", id: 2 }), model), - values: [ - update(model, { type: "RemoveTodo", id: 2 }), - model - ] - }; -}; -// Update Input -const test11 = () => { - return { - result: model_eq(update(["", []], { type: "UpdateBuffer", name: "Breath" }), ["Breath", []]), - values: [ - update(["", []], { type: "UpdateBuffer", name: "Breath" }), - ["Breath", []] - ] - }; -}; -// Don't add blank description -const test12 = () => { - let model = ["", [["1", false]]]; - return { - result: model_eq(update(model, { type: "AddTodo" }), model), - values: [ - update(model, { type: "AddTodo" }), - model - ] - }; -}; -const tests = [test1, test2, test3, test4, test5, test6, test7, test8, test9, test10, test11, test12]; -let score = 0; -for (let i = 0; i < tests.length; ++i) { - try { - const run = tests[i](); - console.assert(run.result === true, "%o", { i: i + 1, values: run.values }); - if (run.result) { - score++; - } - } - catch (err) { - console.log(err); - } -} -console.log(`score: ${score} / ${tests.length}`); diff --git a/targets/starcoder-todo/prelude.js b/targets/starcoder-todo/prelude.js deleted file mode 100644 index 73ae54c..0000000 --- a/targets/starcoder-todo/prelude.js +++ /dev/null @@ -1,42 +0,0 @@ -// TODO MVU -const todo_eq = ([d1, s1], [d2, s2]) => { - return d1 === d2 && s1 === s2; -}; -const todo_array_eq = (ta1, ta2) => { - return ta1.length === ta2.length && ta1.every((el, i) => { return todo_eq(el, ta2[i]); }); -}; -const model_eq = ([b1, ts1], [b2, ts2]) => { - return b1 === b2 && todo_array_eq(ts1, ts2); -}; -const Model_init = ["", []]; -const add = (m) => { - if (m[0] === "") { - return m[1]; - } - else { - return [...m[1], [m[0], false]]; - } -}; -const remove = (index, todos) => { - const removedTodos = []; - for (let i = 0; i < todos.length; i++) { - if (i !== index) { - removedTodos.push(todos[i]); - } - } - return removedTodos; - // const removedTodos = todos.filter((_, i) => { i !== index }); - // return removedTodos; -}; -const toggle = (index, todos) => { - const toggledTodos = todos.map((t, i) => { - if (i === index) { - return [t[0], !t[1]]; - } - else { - return t; - } - }); - return toggledTodos; -}; -export { model_eq, Model_init, add, remove, toggle }; diff --git a/targets/starcoder-todo/sketch.ts b/targets/starcoder-todo/sketch.ts new file mode 100644 index 0000000..f565a29 --- /dev/null +++ b/targets/starcoder-todo/sketch.ts @@ -0,0 +1,7 @@ +import { Model, Action } from "./prelude"; + +// Handle TODO actions to update the app model +const update: (m: Model, a: Action) => Model = + _() + +export { update }; diff --git a/targets/starcoder-todo/starcoder-sketch.ts b/targets/starcoder-todo/starcoder-sketch.ts new file mode 100644 index 0000000..ad14ce4 --- /dev/null +++ b/targets/starcoder-todo/starcoder-sketch.ts @@ -0,0 +1,4 @@ +import { Model, Action } from "./prelude"; + +// Handle TODO actions to update the app model +const update = (m: Model, a: Action): Model => { diff --git a/targets/todo/checkConsistency.ts b/targets/todo/checkConsistency.ts new file mode 100644 index 0000000..5c335dd --- /dev/null +++ b/targets/todo/checkConsistency.ts @@ -0,0 +1,5 @@ +import {Model, Action} from "/home/jacob/projects/context-extractor/targets/todo/prelude.ts" +function check(a: (index: number, todos: Todo[]) => Todo[]): (m: Model, a: Action) => Model { return a; } +function check(a: (index: number, todos: Todo[]) => Todo[]): Model { return a; } +function check(a: (index: number, todos: Todo[]) => Todo[]): string { return a; } +function check(a: (index: number, todos: Todo[]) => Todo[]): Todo[] { return a; } \ No newline at end of file diff --git a/vector_collate_data.sh b/vector_collate_data.sh index 640522b..f3b0a3a 100644 --- a/vector_collate_data.sh +++ b/vector_collate_data.sh @@ -1,7 +1,8 @@ #!/bin/bash # Set the path to the testout folder -testout_folder="/home/jacob/projects/testtslspclient/vector-retrieval/out" +projectRoot=$(pwd) +testout_folder="$projectRoot/vector-retrieval/out/" # Set the output CSV file name output_file="${1}_vector_collated_data.csv"