+
{#each platforms as platform}
{/each}
@@ -75,16 +83,20 @@
-
p.id === selectedPlatform).icon}
- alt={selectedPlatform}
- class="w-5 h-5"
- />
+ {#if selectedPlatform === 'github'}
+
+ {:else}
+
p.id === selectedPlatform).icon}
+ alt={selectedPlatform}
+ class="w-5 h-5"
+ />
+ {/if}
From c4b97fdd9d233d5cb16bc363d2a9db69339275fc Mon Sep 17 00:00:00 2001
From: Samyak Jain <56000318+samyakkkk@users.noreply.github.com>
Date: Tue, 13 Aug 2024 23:18:17 +0530
Subject: [PATCH 4/7] (feat): add clear placeholders
---
web/src/lib/components/CreateAgentDialog.svelte | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/web/src/lib/components/CreateAgentDialog.svelte b/web/src/lib/components/CreateAgentDialog.svelte
index 86fb31e..cb3f4b5 100644
--- a/web/src/lib/components/CreateAgentDialog.svelte
+++ b/web/src/lib/components/CreateAgentDialog.svelte
@@ -14,12 +14,12 @@
let selectedPlatform: string = "github";
const platforms = [
- { id: 'github', icon: CarbonGithub, label: 'GitHub'},
- { id: 'npm', icon: 'npm.png', label: 'NPM' },
- { id: 'pypi', icon: 'python.png', label: 'PyPI' },
- { id: 'pub', icon: 'icons8-dart-96.png', label: 'Pub' },
- { id: 'go', icon: 'go.png', label: 'Go' }
+ { id: 'github', icon: CarbonGithub, label: 'GitHub', placeholder: 'https://github.com/user/repo' },
+ { id: 'npm', icon: 'npm.png', label: 'NPM', placeholder: 'https://www.npmjs.com/package/name' },
+ { id: 'pypi', icon: 'python.png', label: 'PyPI', placeholder: 'https://pypi.org/project/name' },
+ { id: 'pub', icon: 'icons8-dart-96.png', label: 'Pub', placeholder: 'https://pub.dev/packages/name' },
];
+
const validateURL = (url: string): boolean => {
const patterns = {
github: /^(https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/?)$/,
@@ -96,7 +96,7 @@
p.id === selectedPlatform).placeholder}
class="w-full pl-10 pr-3 py-2 bg-gray-800 border border-gray-700 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 text-gray-100 placeholder-gray-500"
/>
From 2bab7c688dc45907130bc616b8c8c3397b7cc374 Mon Sep 17 00:00:00 2001
From: Samyak Jain <56000318+samyakkkk@users.noreply.github.com>
Date: Thu, 15 Aug 2024 12:18:01 +0530
Subject: [PATCH 5/7] (feat): create with package manager logic working
---
web/.vscode/launch.json | 19 +++++++++
web/package.json | 1 +
.../lib/components/CreateAgentDialog.svelte | 39 ++++++++++++++-----
web/src/lib/components/SettingsAgent.svelte | 2 +-
.../components/chat/ChatIntroduction.svelte | 2 +-
web/src/lib/components/chat/ChatWindow.svelte | 2 +-
web/src/lib/utils/validateURL.ts | 0
web/src/routes/+page.svelte | 2 +-
web/src/routes/agent/+page.svelte | 35 ++++++++++++++---
web/src/routes/agent/[id]/+page.svelte | 2 +-
10 files changed, 85 insertions(+), 19 deletions(-)
create mode 100644 web/.vscode/launch.json
create mode 100644 web/src/lib/utils/validateURL.ts
diff --git a/web/.vscode/launch.json b/web/.vscode/launch.json
new file mode 100644
index 0000000..fbd4428
--- /dev/null
+++ b/web/.vscode/launch.json
@@ -0,0 +1,19 @@
+{
+ // Use IntelliSense to learn about possible attributes.
+ // Hover to view descriptions of existing attributes.
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+ "version": "0.2.0",
+ "configurations": [{
+ "type": "chrome",
+ "request": "launch",
+ "name": "Launch Chrome against localhost",
+ "url": "http://localhost:5173",
+ "webRoot": "${workspaceFolder}/src",
+ "breakOnLoad": true,
+ "sourceMaps": true,
+ "sourceMapPathOverrides": {
+ "webpack:///src/*": "${webRoot}/*"
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/web/package.json b/web/package.json
index 817e30c..6629b2b 100644
--- a/web/package.json
+++ b/web/package.json
@@ -37,6 +37,7 @@
"@lottiefiles/svelte-lottie-player": "^0.3.1",
"@microsoft/applicationinsights-web": "^3.3.1",
"@tailwindcss/typography": "^0.5.13",
+ "cheerio": "^1.0.0",
"dotenv": "^16.4.5",
"highlight.js": "^11.10.0",
"isomorphic-dompurify": "^2.14.0",
diff --git a/web/src/lib/components/CreateAgentDialog.svelte b/web/src/lib/components/CreateAgentDialog.svelte
index cb3f4b5..98a771e 100644
--- a/web/src/lib/components/CreateAgentDialog.svelte
+++ b/web/src/lib/components/CreateAgentDialog.svelte
@@ -20,24 +20,44 @@
{ id: 'pub', icon: 'icons8-dart-96.png', label: 'Pub', placeholder: 'https://pub.dev/packages/name' },
];
- const validateURL = (url: string): boolean => {
+ const validateURL = (url: string): { isValid: boolean, packageName: string } => {
+ // validate against these
+ // https://pub.dev/packages/webview_flutter
+ // https://pub.dev/packages/webview_flutter/install
+ // requests for:
+ // https://pypi.org/project/requests/
+ // https://pypi.org/project/requests/#history
+ // mock for:
+ // https://www.npmjs.com/package/mock
+ // https://www.npmjs.com/package/mock?activeTab=dependencies
+ // @octokit/graphql for:
+ // https://www.npmjs.com/package/@octokit/graphql
const patterns = {
github: /^(https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/?)$/,
- npm: /^(https:\/\/www\.npmjs\.com\/package\/[A-Za-z0-9_.-]+\/?)$/,
- pypi: /^(https:\/\/pypi\.org\/project\/[A-Za-z0-9_.-]+\/?)$/,
- pub: /^(https:\/\/pub\.dev\/packages\/[A-Za-z0-9_.-]+\/?)$/,
- go: /^(https:\/\/pkg\.go\.dev\/[A-Za-z0-9_.-\/]+\/?)$/
+ npm: /^(https:\/\/www\.npmjs\.com\/package\/(@?[A-Za-z0-9_.-]+\/?[A-Za-z0-9_.-]+))\/?.*$/,
+ pypi: /^(https:\/\/pypi\.org\/project\/([A-Za-z0-9_.-]+))\/?.*$/,
+ pub: /^(https:\/\/pub\.dev\/packages\/([A-Za-z0-9_.-]+))\/?.*$/,
};
- return patterns[selectedPlatform].test(url);
+
+ const match = url.match(patterns[selectedPlatform]);
+ if (match) {
+ return { isValid: true, packageName: match[2] };
+ } else {
+ return { isValid: false, packageName: "" };
+ }
};
const onCreateAgent = () => {
- if (validateURL(value)) {
+ value = value.trim()
+ const { isValid, packageName } = validateURL(value);
+ if (isValid) {
appInsights.trackEvent({
name: "CreateAgentSubmitted",
properties: { platform: selectedPlatform, url: value },
});
- goto(`${base}/agent?platform=${selectedPlatform}&url=${value}`);
+ const queryParam = selectedPlatform === 'github' ? value : packageName;
+ console.log(queryParam)
+ goto(`${base}/agent?${selectedPlatform}=${queryParam}`);
} else {
toastStore.set({
message: `Please enter a valid ${selectedPlatform} URL`,
@@ -74,7 +94,7 @@
{:else}
{/if}
-
+
@@ -93,6 +113,7 @@
/>
{/if}