1 line
15 KiB
JSON
1 line
15 KiB
JSON
{"createdAt":"2024-10-15T10:13:36.913Z","updatedAt":"2024-10-15T10:15:19.565Z","id":"6FWl2946ojNZkURf","name":"DevAiOps","active":false,"nodes":[{"parameters":{"command":"rm -rf /tmp/repo"},"id":"e2e6fe07-03bf-44cd-b62d-0040e7a3be02","name":"Execute Command","type":"n8n-nodes-base.executeCommand","typeVersion":1,"position":[620,380],"notesInFlow":true,"notes":"Suppression /tmp/repo "},{"parameters":{"operation":"clone","repositoryPath":"/tmp/repo","sourceRepository":"={{$node[\"Webhook\"].json[\"body\"][\"repository\"][\"git_ssh_url\"]}}"},"id":"69e8d041-211b-447e-af1d-df5bed3bf3c3","name":"Git","type":"n8n-nodes-base.git","typeVersion":1,"position":[800,380],"alwaysOutputData":true,"notesInFlow":true,"onError":"continueRegularOutput","notes":"Clonage repo dans /tmp/repo"},{"parameters":{"command":"ls /tmp/repo"},"id":"861721c3-d374-41e8-b7c4-2c798a091adc","name":"Execute Command1","type":"n8n-nodes-base.executeCommand","typeVersion":1,"position":[1680,220],"alwaysOutputData":true,"notesInFlow":true,"notes":"Lister fichiers Git"},{"parameters":{"options":{"reset":false}},"id":"d46059fc-c202-41f4-80ff-634bb1883bb2","name":"Loop Over Items","type":"n8n-nodes-base.splitInBatches","typeVersion":3,"position":[260,640],"notesInFlow":true,"notes":"Traite fichier par fichier"},{"parameters":{"fileSelector":"=/tmp/repo/{{$json[\"fileName\"]}}","options":{}},"id":"9ed67374-8de4-4ab2-ad11-657e3be1e675","name":"Read/Write Files from Disk","type":"n8n-nodes-base.readWriteFile","typeVersion":1,"position":[440,720],"notesInFlow":true,"notes":"Lit le fichier"},{"parameters":{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict"},"conditions":[{"id":"1b92e512-49fc-47c9-a93e-b80bc1d48f3b","leftValue":"={{ $items(\"Set2\")[0].json.filtre }}","rightValue":"=.{{ $json[\"fileExtension\"] }}|","operator":{"type":"string","operation":"contains"}}],"combinator":"and"},"options":{}},"id":"c7e1d2bb-6c35-465d-8473-a6f198e372af","name":"If","type":"n8n-nodes-base.if","typeVersion":2,"position":[620,720],"notesInFlow":true,"notes":"Extension à traiter ?"},{"parameters":{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict"},"conditions":[{"id":"e182d1f3-0b86-4a38-951e-4eac8bfd025c","leftValue":"={{$node[\"Webhook\"].json[\"body\"][\"commits\"][0][\"message\"]}}","rightValue":"@inspectALL","operator":{"type":"string","operation":"contains"}}],"combinator":"and"},"options":{}},"id":"54181c05-b4d7-4290-8cf9-4fa8f6da2134","name":"If1","type":"n8n-nodes-base.if","typeVersion":2,"position":[1500,380],"notesInFlow":true,"notes":"commit msg =~ @inspectALL"},{"parameters":{"command":"=cd /tmp/repo && git diff-tree --no-commit-id --name-only {{$node[\"Webhook\"].json[\"body\"][\"commits\"][0][\"id\"] }} -r"},"id":"c200a9d3-89ec-414b-adeb-c9d4c00ee18a","name":"Execute Command2","type":"n8n-nodes-base.executeCommand","typeVersion":1,"position":[1680,380],"alwaysOutputData":true,"notesInFlow":true,"notes":"Lister fichiers Git modifiés"},{"parameters":{"jsCode":"const previousResults = $items(\"Set\")[0].json.concatenatedResults;\n\nconst updatedResults = previousResults + \"<h2>\" + $items(\"Code1\")[0].json.filename + \"</h2>\";\n\nreturn [\n {\n json: {\n concatenatedResults: updatedResults\n }\n }\n];"},"id":"4c4ee434-abda-49ab-b9f8-0dbf2bc0834f","name":"Code2","type":"n8n-nodes-base.code","typeVersion":2,"position":[1840,720],"notesInFlow":true,"notes":"Concatène résultat Variable"},{"parameters":{"assignments":{"assignments":[{"id":"085cb216-3d10-4001-b426-671666827470","name":"consigne","value":"={{ $json[\"consigne\"] }}","type":"string"},{"id":"ce95566b-edbd-4da2-8325-f3426dce8dd8","name":"filtre","value":"={{ $json[\"filtre\"] }}","type":"string"}]},"options":{}},"id":"14a6ea1c-bd45-41f3-9f8a-5bf778719302","name":"Set2","type":"n8n-nodes-base.set","typeVersion":3.3,"position":[1320,380],"notesInFlow":true,"notes":"Consigne à \"\""},{"parameters":{"fileSelector":"/tmp/repo/.iacicd","options":{"dataPropertyName":"consigne"}},"id":"8f0ce1a9-d8b1-4e44-b105-4cd658d3b1f7","name":"Read/Write Files from Disk1","type":"n8n-nodes-base.readWriteFile","typeVersion":1,"position":[980,380],"notesInFlow":true,"alwaysOutputData":true,"onError":"continueRegularOutput","notes":"Lit le fichier ~/.iacicd"},{"parameters":{"jsCode":"const fileList = $json[\"stdout\"].split('\\n').filter(file => file !== '');\nreturn fileList.map(file => ({ json: { fileName: file } }));"},"id":"20929698-b323-44ad-abb0-90c478c6708d","name":"Code","type":"n8n-nodes-base.code","typeVersion":2,"position":[1840,380],"notesInFlow":true,"notes":"Conversion liste fichier JSON"},{"parameters":{"jsCode":"let binaryDataBufferItem = await this.helpers.getBinaryDataBuffer(0, 'data');\nvar data = binaryDataBufferItem.toString('utf8')\n\nreturn {\"data\": data, \"filename\" : $json[\"fileName\"] };"},"id":"67ca957b-22d8-4141-b71d-2ec36157c0a7","name":"Code1","type":"n8n-nodes-base.code","typeVersion":2,"position":[800,720],"notesInFlow":true,"notes":"Transforme en JSON"},{"parameters":{"jsCode":"let binaryDataBufferItem;\nlet data;\nlet consigne;\nlet filtre;\n\ntry {\n binaryDataBufferItem = await this.helpers.getBinaryDataBuffer(0, 'consigne');\n data = binaryDataBufferItem.toString('utf8');\n\n // Parse the YAML content manually (simple implementation)\n const lines = data.split('\\n');\n const parsedContent = {};\n\n lines.forEach(line => {\n const [key, value] = line.split(':').map(item => item.trim());\n if (key && value !== undefined) {\n parsedContent[key] = value;\n }\n });\n\n // Extract the parameters \"consigne\" and \"filtre\"\n consigne = parsedContent.consigne;\n filtre = parsedContent.filtre;\n\n return {\n json: {\n consigne: consigne,\n filtre: filtre,\n }\n };\n} catch (error) {\n return {\n json: {\n consigne: \"Analyze the following program file writed in C language. Make a summary with severals sections for 'Objectif du code', 'Sécurite du code', 'Optimisation du code' and 'Erreurs dans le code'. Max 250 words in French for each section given before. Format the resulting document in HTML format and begin with the h3 for the sections. Use table and rich HTML content if needed to ensure best document quality. No return to line but br tag or table\",\n filtre: \".c|.h|\" // or a default value for filtre if needed\n }\n };\n}"},"id":"82bee687-21e7-425c-b432-435edb8b31e8","name":"Code3","type":"n8n-nodes-base.code","typeVersion":2,"position":[1140,380],"notesInFlow":true,"notes":"Consigne vers JSON ou défaut"},{"parameters":{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict","version":1},"conditions":[{"id":"6233a192-63ca-4478-b89e-21c580889d91","leftValue":"={{$json[\"concatenatedResults\"]}}","rightValue":"","operator":{"type":"string","operation":"empty","singleValue":true}}],"combinator":"and"},"options":{}},"id":"643ce0cf-5b5c-46b8-8a5a-67328ae81c71","name":"If2","type":"n8n-nodes-base.if","typeVersion":2,"position":[2160,720],"notesInFlow":true,"notes":"Initialisation variable ok?"},{"parameters":{"assignments":{"assignments":[{"id":"7b1033bd-f129-479d-952e-9971cf9bc59b","name":"concatenatedResults","value":"={{$json[\"concatenatedResults\"]}}","type":"string"}]},"options":{}},"id":"ef93423c-eaf4-42b1-bab4-51ff02624fdc","name":"Set","type":"n8n-nodes-base.set","typeVersion":3.3,"position":[2000,720],"notesInFlow":true,"notes":"Mise à jour Variable"},{"parameters":{"keep":"lastItems"},"id":"512d0fb4-91fa-4bbe-bec0-67c84949448a","name":"Limit","type":"n8n-nodes-base.limit","typeVersion":1,"position":[440,560],"notesInFlow":true,"notes":"Continuation du flow unique"},{"parameters":{"jsCode":" return {\n json: {\n concatenatedResults: \"\"\n }\n };"},"id":"a6e56e4e-fa2a-4dbf-be5a-83f35d1bf614","name":"Code4","type":"n8n-nodes-base.code","typeVersion":2,"position":[2000,380],"notesInFlow":true,"notes":"Entête courriel"},{"parameters":{"operation":"write","fileName":"=/tmp/repo/{{ $items(\"Code1\")[0].json.filename }}.corrected","options":{"append":false}},"id":"a7c969bf-7c74-40f7-9349-b225c3f3a2e5","name":"Read/Write Files from Disk2","type":"n8n-nodes-base.readWriteFile","typeVersion":1,"position":[1680,720]},{"parameters":{"operation":"add","repositoryPath":"/tmp/repo","pathsToAdd":"*"},"id":"e9c5d913-3ff7-434b-ab9d-987da410c354","name":"Git2","type":"n8n-nodes-base.git","typeVersion":1,"position":[800,560]},{"parameters":{"operation":"addConfig","repositoryPath":"/tmp/repo","key":"user.email","value":"horde.nicolas@imsa.msa.fr","options":{}},"id":"77405665-8d79-4968-a87b-e90152e3d65e","name":"Git7","type":"n8n-nodes-base.git","typeVersion":1,"position":[980,560]},{"parameters":{"operation":"commit","repositoryPath":"/tmp/repo","message":"=IA-CORRECTED: {{ $('DateTime').item.json.currentDate }}","options":{}},"id":"e095a27c-ac61-45fd-a2dc-3170df4a37d1","name":"Git3","type":"n8n-nodes-base.git","typeVersion":1,"position":[1140,560]},{"parameters":{"operation":"push","repositoryPath":"/tmp/repo","options":{}},"id":"9f8a2a26-f86a-4544-b262-a3f3a9e518e6","name":"Git5","type":"n8n-nodes-base.git","typeVersion":1,"position":[1320,560]},{"parameters":{"fromEmail":"nico@ia86.cc","toEmail":"nicolas@palon.fr","subject":"=[N8N-SAVE]: {{ $json.date }} - {{ $('Git1').item.json.files.length }} modifs","html":"={{ $('ListFiles').item.json.stdout }}<br>\nHash: {{ $json.hash }}","options":{"replyTo":"noreply@n8n.ia86.cc"}},"id":"343d8388-4bec-4373-8b92-be80c0c354f1","name":"Send Email","type":"n8n-nodes-base.emailSend","typeVersion":2.1,"position":[2000,560],"notesInFlow":true,"credentials":{"smtp":{"id":"d4ZAN48vF9GTpVON","name":"SMTP account"}},"notes":"Envoi courriel"},{"parameters":{"keep":"lastItems"},"id":"d0aad0d9-b51e-4859-8e0f-ca7b95e7aa0e","name":"Limit1","type":"n8n-nodes-base.limit","typeVersion":1,"position":[1840,560],"notesInFlow":true,"notes":"Garde dernier"},{"parameters":{"sortFieldsUi":{"sortField":[{"fieldName":"date","order":"descending"}]},"options":{}},"id":"5dbca0ad-a3e7-4b0f-8e34-3f94f0c570e2","name":"Sort","type":"n8n-nodes-base.sort","typeVersion":1,"position":[1680,560],"notesInFlow":true,"notes":"Tri des commits"},{"parameters":{"repositoryPath":"/tmp/repo","options":{}},"id":"d0e30411-7561-48c6-bcd2-675b686a3060","name":"Git6","type":"n8n-nodes-base.git","typeVersion":1,"position":[1500,560]},{"parameters":{"options":{}},"id":"b2acba65-ba7c-4d90-bf14-5095cd676446","name":"DateTime","type":"n8n-nodes-base.dateTime","typeVersion":2,"position":[620,560],"notesInFlow":true,"notes":"Récup date"},{"parameters":{"jsCode":"let output = $json[\"text\"].replace(/\\\\n/g, '\\n'); // Remplacer les \\n par de vrais retours à la ligne\nitems[0].binary = {\n data: {\n data: Buffer.from(output, 'utf-8').toString('base64')\n }\n};\nreturn items;"},"id":"01f1554e-d884-4973-8c85-cc54ccc3f106","name":"Code5","type":"n8n-nodes-base.code","typeVersion":2,"position":[1500,720],"notesInFlow":true,"notes":"Reformatage"},{"parameters":{"errorMessage":"Already corrected code"},"id":"db8e22e0-df31-4809-92fc-4c2601d89dd7","name":"Stop and Error","type":"n8n-nodes-base.stopAndError","typeVersion":1,"position":[620,220],"notesInFlow":true,"notes":"Si déjà corrige IA"},{"parameters":{"httpMethod":"POST","path":"2bcc82c8-c2f0-4bf1-8f85-2584becc5142","options":{}},"id":"ee6aedf4-e8d6-40f4-a47d-1e15f3ba1a67","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":1.1,"position":[280,380],"webhookId":"2bcc82c8-c2f0-4bf1-8f85-2584becc5142","notesInFlow":true,"notes":"Webhook Git sur commit "},{"parameters":{"options":{},"requestOptions":{}},"id":"ac2a1b9d-3b2f-4476-b954-71ded667cb8c","name":"Groq Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatGroq","typeVersion":1,"position":[1000,940],"credentials":{"groqApi":{"id":"u4SobGEjjuXQixeQ","name":"Groq account"}}},{"parameters":{"promptType":"define","text":"={{ $items(\"Set2\")[0].json.consigne }}\nThe informations to treat begins after the ::: chars\nName of the file to inspect: {{ $json[\"filename\"] }} \n:::{{ $json[\"data\"] }}"},"id":"bd1717ea-6853-43df-92ea-fcc5b0a9d01a","name":"Basic LLM Chain","type":"@n8n/n8n-nodes-langchain.chainLlm","typeVersion":1.4,"position":[980,720],"notesInFlow":true,"notes":"Traitement par IA Groq"},{"parameters":{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict"},"conditions":[{"id":"8425d1c6-76e4-46f3-8e4b-8656b2176dfa","leftValue":"{{ $json[\\\"body\\\"][\\\"commits\\\"][0][\\\"message\\\"] }}","rightValue":"IA-CORRECTED","operator":{"type":"string","operation":"contains"}}],"combinator":"and"},"options":{}},"id":"d75f0748-eff2-465d-b37f-829f3e3e1387","name":"If3","type":"n8n-nodes-base.if","typeVersion":2,"position":[440,380],"notesInFlow":true,"notes":"Test de non réentrance"}],"connections":{"Execute Command":{"main":[[{"node":"Git","type":"main","index":0}]]},"Git":{"main":[[{"node":"Read/Write Files from Disk1","type":"main","index":0}]]},"Execute Command1":{"main":[[{"node":"Code","type":"main","index":0}]]},"Loop Over Items":{"main":[[{"node":"Limit","type":"main","index":0}],[{"node":"Read/Write Files from Disk","type":"main","index":0}]]},"Read/Write Files from Disk":{"main":[[{"node":"If","type":"main","index":0}]]},"If":{"main":[[{"node":"Code1","type":"main","index":0}],[{"node":"Loop Over Items","type":"main","index":0}]]},"If1":{"main":[[{"node":"Execute Command1","type":"main","index":0}],[{"node":"Execute Command2","type":"main","index":0}]]},"Execute Command2":{"main":[[{"node":"Code","type":"main","index":0}]]},"Code2":{"main":[[{"node":"Set","type":"main","index":0}]]},"Set2":{"main":[[{"node":"If1","type":"main","index":0}]]},"Read/Write Files from Disk1":{"main":[[{"node":"Code3","type":"main","index":0}]]},"Code1":{"main":[[{"node":"Basic LLM Chain","type":"main","index":0}]]},"Code3":{"main":[[{"node":"Set2","type":"main","index":0}]]},"If2":{"main":[[],[{"node":"Loop Over Items","type":"main","index":0}]]},"Set":{"main":[[{"node":"If2","type":"main","index":0}]]},"Code":{"main":[[{"node":"Loop Over Items","type":"main","index":0},{"node":"Code4","type":"main","index":0}]]},"Limit":{"main":[[{"node":"DateTime","type":"main","index":0}]]},"Code4":{"main":[[{"node":"Set","type":"main","index":0}]]},"Git2":{"main":[[{"node":"Git7","type":"main","index":0}]]},"Git7":{"main":[[{"node":"Git3","type":"main","index":0}]]},"Git3":{"main":[[{"node":"Git5","type":"main","index":0}]]},"Git5":{"main":[[{"node":"Git6","type":"main","index":0}]]},"Git6":{"main":[[{"node":"Sort","type":"main","index":0}]]},"Sort":{"main":[[{"node":"Limit1","type":"main","index":0}]]},"Limit1":{"main":[[{"node":"Send Email","type":"main","index":0}]]},"DateTime":{"main":[[{"node":"Git2","type":"main","index":0}]]},"Read/Write Files from Disk2":{"main":[[{"node":"Code2","type":"main","index":0}]]},"Code5":{"main":[[{"node":"Read/Write Files from Disk2","type":"main","index":0}]]},"Webhook":{"main":[[{"node":"If3","type":"main","index":0}]]},"Groq Chat Model":{"ai_languageModel":[[{"node":"Basic LLM Chain","type":"ai_languageModel","index":0}]]},"Basic LLM Chain":{"main":[[{"node":"Code5","type":"main","index":0}]]},"If3":{"main":[[{"node":"Stop and Error","type":"main","index":0}],[{"node":"Execute Command","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":{"templateCredsSetupCompleted":true},"pinData":{},"versionId":"fa2af375-3413-42c9-b7f2-c09bfb1942aa","triggerCount":0,"tags":[]} |