Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

rm: macros prompts (#305)

teo6f177a665537
diff --git a/js/app/bun.lock b/js/app/bun.lock
index 80d93237b7..28c9d7c03c 100644
--- a/js/app/bun.lock
+++ b/js/app/bun.lock
@@ -1,5 +1,6 @@
{
"lockfileVersion": 1,
+ "configVersion": 0,
"workspaces": {
"": {
"name": "@coparse/monorepo",
@@ -323,9 +324,6 @@
"solid-js": "^1.9.7",
},
},
- "packages/macros-prompts": {
- "name": "macros-prompts",
- },
"packages/notifications": {
"name": "notifications",
"dependencies": {
@@ -2717,8 +2715,6 @@
"macro-entity": ["macro-entity@workspace:packages/macro-entity"],
- "macros-prompts": ["macros-prompts@workspace:packages/macros-prompts"],
-
"magic-string": ["[email protected]", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.0" } }, "sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA=="],
"make-dir": ["[email protected]", "", { "dependencies": { "semver": "^6.0.0" } }, "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw=="],
diff --git a/js/app/packages/macros-prompts/.gitignore b/js/app/packages/macros-prompts/.gitignore
deleted file mode 100644
index 9b1ee42e84..0000000000
--- a/js/app/packages/macros-prompts/.gitignore
+++ /dev/null
@@ -1,175 +0,0 @@
-# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
-
-# Logs
-
-logs
-_.log
-npm-debug.log_
-yarn-debug.log*
-yarn-error.log*
-lerna-debug.log*
-.pnpm-debug.log*
-
-# Caches
-
-.cache
-
-# Diagnostic reports (https://nodejs.org/api/report.html)
-
-report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
-
-# Runtime data
-
-pids
-_.pid
-_.seed
-*.pid.lock
-
-# Directory for instrumented libs generated by jscoverage/JSCover
-
-lib-cov
-
-# Coverage directory used by tools like istanbul
-
-coverage
-*.lcov
-
-# nyc test coverage
-
-.nyc_output
-
-# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
-
-.grunt
-
-# Bower dependency directory (https://bower.io/)
-
-bower_components
-
-# node-waf configuration
-
-.lock-wscript
-
-# Compiled binary addons (https://nodejs.org/api/addons.html)
-
-build/Release
-
-# Dependency directories
-
-node_modules/
-jspm_packages/
-
-# Snowpack dependency directory (https://snowpack.dev/)
-
-web_modules/
-
-# TypeScript cache
-
-*.tsbuildinfo
-
-# Optional npm cache directory
-
-.npm
-
-# Optional eslint cache
-
-.eslintcache
-
-# Optional stylelint cache
-
-.stylelintcache
-
-# Microbundle cache
-
-.rpt2_cache/
-.rts2_cache_cjs/
-.rts2_cache_es/
-.rts2_cache_umd/
-
-# Optional REPL history
-
-.node_repl_history
-
-# Output of 'npm pack'
-
-*.tgz
-
-# Yarn Integrity file
-
-.yarn-integrity
-
-# dotenv environment variable files
-
-.env
-.env.development.local
-.env.test.local
-.env.production.local
-.env.local
-
-# parcel-bundler cache (https://parceljs.org/)
-
-.parcel-cache
-
-# Next.js build output
-
-.next
-out
-
-# Nuxt.js build / generate output
-
-.nuxt
-dist
-
-# Gatsby files
-
-# Comment in the public line in if your project uses Gatsby and not Next.js
-
-# https://nextjs.org/blog/next-9-1#public-directory-support
-
-# public
-
-# vuepress build output
-
-.vuepress/dist
-
-# vuepress v2.x temp and cache directory
-
-.temp
-
-# Docusaurus cache and generated files
-
-.docusaurus
-
-# Serverless directories
-
-.serverless/
-
-# FuseBox cache
-
-.fusebox/
-
-# DynamoDB Local files
-
-.dynamodb/
-
-# TernJS port file
-
-.tern-port
-
-# Stores VSCode versions used for testing VSCode extensions
-
-.vscode-test
-
-# yarn v2
-
-.yarn/cache
-.yarn/unplugged
-.yarn/build-state.yml
-.yarn/install-state.gz
-.pnp.*
-
-# IntelliJ based IDEs
-.idea
-
-# Finder (MacOS) folder config
-.DS_Store
diff --git a/js/app/packages/macros-prompts/AddMacroModal.tsx b/js/app/packages/macros-prompts/AddMacroModal.tsx
deleted file mode 100644
index ca2ef032fc..0000000000
--- a/js/app/packages/macros-prompts/AddMacroModal.tsx
+++ /dev/null
@@ -1,278 +0,0 @@
-import { useHasPaidAccess } from '@core/auth';
-import { IconSelectorMenu } from '@core/component/IconSelectorMenu';
-import {
- FilteredTailwindColors,
- TailwindColorPicker,
-} from '@core/component/TailwindColorPicker';
-import { TextButton } from '@core/component/TextButton';
-import { PaywallKey, usePaywallState } from '@core/constant/PaywallState';
-import AcornIcon from '@phosphor-icons/core/regular/acorn.svg?component-solid';
-import Circle from '@phosphor-icons/core/regular/circle.svg?component-solid';
-import TrashIcon from '@phosphor-icons/core/regular/trash.svg?component-solid';
-import {
- type Accessor,
- createEffect,
- createSignal,
- onCleanup,
- onMount,
- Show,
-} from 'solid-js';
-import { createStore } from 'solid-js/store';
-import { Dynamic, Portal } from 'solid-js/web';
-// @ts-ignore
-import colors from 'tailwindcss/colors';
-import {
- createNewAndUpdateMacros,
- deleteMacro,
- editExistingMacro,
- type MacroPrompt,
- macroModalState,
- macroSignal,
- setInputToMacroPrompt,
- setMacroModalState,
-} from './macros';
-
-const MAX_TITLE_LENGTH = 50;
-
-interface AddMacroModalProps {
- inputRef: Accessor<HTMLDivElement | null | undefined>;
-}
-
-export function AddMacroModal(props: AddMacroModalProps) {
- const setSelectedMacro = macroSignal.set;
- const { showPaywall } = usePaywallState();
- const hasPaidAccess = useHasPaidAccess();
- const handleOutsideClick = (e: MouseEvent) => {
- if (e.target === e.currentTarget) {
- setErrors({});
- setMacroModalState(null);
- }
- };
- const handleKey = (e: KeyboardEvent) => {
- if (!macroModalState()) {
- return;
- }
- if (e.key === 'Escape') {
- setMacroModalState(null);
- }
- };
-
- onMount(() => {
- document.addEventListener('keydown', handleKey);
- });
-
- onCleanup(() => {
- document.removeEventListener('keydown', handleKey);
- });
- const [createdMacroStore, setCreatedMacroStore] = createStore<MacroPrompt>({
- id: '',
- title: '',
- prompt: '',
- icon: AcornIcon,
- color: FilteredTailwindColors.blue,
- });
-
- const [showIconMenu, setShowIconMenu] = createSignal(false);
- const [showColorPicker, setShowColorPicker] = createSignal(false);
-
- const [errors, setErrors] = createSignal<{ title?: string; prompt?: string }>(
- {}
- );
-
- createEffect(() => {
- const mode = macroModalState();
- if (mode?.type === 'edit' && mode.macro) {
- setCreatedMacroStore(mode.macro);
- } else {
- setCreatedMacroStore({
- title: '',
- prompt: '',
- icon: AcornIcon,
- color: FilteredTailwindColors.blue,
- });
- }
- });
-
- async function handleSaveMacro() {
- const inputRef_ = props.inputRef() ?? null;
-
- const newErrors: { title?: string; prompt?: string } = {};
-
- if (!createdMacroStore.title.trim()) {
- newErrors.title = 'Title is required';
- }
- if (!createdMacroStore.prompt.trim()) {
- newErrors.prompt = 'Prompt is required';
- }
-
- setErrors(newErrors);
-
- if (Object.keys(newErrors).length === 0) {
- if (!hasPaidAccess()) {
- showPaywall(PaywallKey.SAVED_PROMPT);
- return;
- }
-
- const newMacro: MacroPrompt = { ...createdMacroStore };
-
- const mode = macroModalState();
- if (mode?.type === 'edit') {
- // TODO- error handling?
- await editExistingMacro(newMacro);
- } else {
- // TODO- error handling?
- await createNewAndUpdateMacros(newMacro);
- }
- setSelectedMacro(newMacro);
- setInputToMacroPrompt(inputRef_, newMacro);
- setMacroModalState(null);
- }
- }
-
- async function handleDeleteMacro() {
- // TODO- error handling?
- if (!createdMacroStore.id) {
- console.error('No macro id to delete');
- return;
- }
- await deleteMacro(createdMacroStore.id);
- setMacroModalState(null);
- setSelectedMacro(null);
- }
-
- return (
- <Portal>
- <Show when={macroModalState()!}>
- <div
- class="fixed inset-0 flex items-center justify-center shadow-3xl z-modal"
- onClick={handleOutsideClick}
- >
- <div class="bg-dialog p-6 rounded-lg shadow-lg w-2/5">
- <div class="flex flex-col gap-4">
- <div class="flex flex-col gap-1">
- <label for="macro-title" class="text-sm font-medium pb-1">
- Title
- </label>
- <input
- type="text"
- id="macro-title"
- class="border border-edge rounded-md p-2 bg-input"
- placeholder="Poetry Generator, LPA Extractor, or something..."
- value={createdMacroStore.title}
- maxLength={MAX_TITLE_LENGTH}
- onInput={(e) => {
- setCreatedMacroStore(
- 'title',
- e.currentTarget.value.slice(0, MAX_TITLE_LENGTH)
- );
- setErrors((prev) => ({ ...prev, title: undefined }));
- }}
- />
- <Show when={errors().title}>
- <span class="text-failure text-sm">{errors().title}</span>
- </Show>
- </div>
- <div class="flex gap-4">
- <div class="relative">
- <TextButton
- theme="base"
- icon={() => (
- <Dynamic
- class="w-4 h-4"
- component={createdMacroStore.icon}
- style={{ color: colors[createdMacroStore.color][500] }}
- />
- )}
- text="Icon"
- onClick={() => setShowIconMenu(!showIconMenu())}
- />
- <Show when={showIconMenu()}>
- <div class="absolute top-full left-0 z-action-menu">
- <IconSelectorMenu
- show={showIconMenu}
- setShow={setShowIconMenu}
- onIconSelect={(icon) => setCreatedMacroStore({ icon })}
- color={createdMacroStore.color}
- text={createdMacroStore.title}
- />
- </div>
- </Show>
- </div>
- <div class="relative">
- <TextButton
- theme="base"
- icon={() => (
- <Circle
- class="w-4 h-4"
- style={{ color: colors[createdMacroStore.color][500] }}
- />
- )}
- text="Color"
- onClick={() => setShowColorPicker(!showColorPicker())}
- />
- <Show when={showColorPicker()}>
- <div class="absolute top-full left-0">
- <TailwindColorPicker
- onColorSelect={(color) => {
- setCreatedMacroStore('color', color);
- }}
- show={showColorPicker}
- setShow={setShowColorPicker}
- />
- </div>
- </Show>
- </div>
- </div>
- <div class="flex flex-col gap-1">
- <label for="macro-prompt" class="text-sm font-medium pb-1">
- Prompt
- </label>
- <textarea
- id="macro-prompt"
- class="border border-edge rounded-md p-2 h-24 bg-input"
- placeholder="Tell the AI what to do. Be very descriptive, like you would to a new junior colleague who is just learning how to do their job!"
- value={createdMacroStore.prompt}
- onInput={(e) => {
- setCreatedMacroStore('prompt', e.currentTarget.value);
- setErrors((prev) => ({ ...prev, prompt: undefined }));
- }}
- />
- <Show when={errors().prompt}>
- <span class="text-failure text-sm">{errors().prompt}</span>
- </Show>
- </div>
- <div class="flex justify-between mt-2">
- <div>
- <Show when={macroModalState()?.type === 'edit'}>
- <TextButton
- theme="red"
- icon={TrashIcon}
- text="Delete"
- onClick={handleDeleteMacro}
- />
- </Show>
- </div>
- <div class="flex gap-2">
- <TextButton
- theme="clear"
- text="Cancel"
- onClick={() => setMacroModalState(null)}
- />
- <TextButton
- theme="accent"
- text={
- macroModalState()?.type === 'edit'
- ? 'Save Changes'
- : 'Save Prompt'
- }
- onClick={handleSaveMacro}
- />
- </div>
- </div>
- </div>
- </div>
- </div>
- </Show>
- </Portal>
- );
-}
diff --git a/js/app/packages/macros-prompts/MacroButton.tsx b/js/app/packages/macros-prompts/MacroButton.tsx
deleted file mode 100644
index 33c47ed6b0..0000000000
--- a/js/app/packages/macros-prompts/MacroButton.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import { TextButton } from '@core/component/TextButton';
-import type { FilteredTailwindColors } from 'core/component/TailwindColorPicker';
-import { Dynamic } from 'solid-js/web';
-import colors from 'tailwindcss/colors';
-import type { MacroPrompt } from './macros';
-
-export function MacroButton(props: {
- macro: MacroPrompt & { color: FilteredTailwindColors };
- clickHandler: () => void;
-}) {
- return (
- <TextButton
- theme="clear"
- text={props.macro.title}
- icon={() => (
- <Dynamic
- component={props.macro.icon}
- style={{ color: colors[props.macro.color][500] }}
- />
- )}
- onClick={props.clickHandler}
- />
- );
-}
diff --git a/js/app/packages/macros-prompts/MacrosSelectorButton.tsx b/js/app/packages/macros-prompts/MacrosSelectorButton.tsx
deleted file mode 100644
index 51648399bc..0000000000
--- a/js/app/packages/macros-prompts/MacrosSelectorButton.tsx
+++ /dev/null
@@ -1,198 +0,0 @@
-import { IconButton } from '@core/component/IconButton';
-import { MENU_ITEM_HEIGHT } from '@core/component/Menu';
-import { OldMenu, OldMenuItem } from '@core/component/OldMenu';
-import LightningIcon from '@phosphor-icons/core/regular/lightning.svg?component-solid';
-import SearchIcon from '@phosphor-icons/core/regular/magnifying-glass.svg?component-solid';
-import PencilIcon from '@phosphor-icons/core/regular/pencil.svg?component-solid';
-import PlusIcon from '@phosphor-icons/core/regular/plus.svg?component-solid';
-import {
- type Accessor,
- createMemo,
- createSignal,
- For,
- onCleanup,
- onMount,
- Show,
-} from 'solid-js';
-import colors from 'tailwindcss/colors';
-import {
- ENABLE_EDIT_MACROS,
- ENABLE_SEARCH_MACROS,
- type MacroPrompt,
- macroSignal,
- macros,
- setInputToMacroPrompt,
- setMacroModalState,
-} from './macros';
-
-interface MacrosMenuProps {
- onMacroSelected: (macro: MacroPrompt) => void;
- macros: MacroPrompt[];
- setShow: (show: boolean) => void;
-}
-
-/*
- * This is such a non-standard menu that instead of bringing it up to our new menu best practices, I just threw in the old menu components.
- * TODO: Redesign this menu to use best practices.
- */
-export function MacrosMenu(props: MacrosMenuProps) {
- let menuRef: HTMLDivElement | undefined;
- const [searchQuery, setSearchQuery] = createSignal('');
-
- function handleOutsideClick(event: MouseEvent) {
- if (menuRef && !menuRef.contains(event.target as Node)) {
- props.setShow(false);
- }
- }
-
- // TODO- use: directive
- onMount(() => {
- document.addEventListener('mousedown', handleOutsideClick);
- onCleanup(() => {
- document.removeEventListener('mousedown', handleOutsideClick);
- });
- });
-
- const filteredMacros = createMemo(() => {
- const query = searchQuery().toLowerCase();
- return props.macros.filter((macro) =>
- macro.title.toLowerCase().includes(query)
- );
- });
-
- const menuVerticalStartPosition = createMemo(() => {
- const startOffset = 16;
- const addPromptHeight = MENU_ITEM_HEIGHT;
- const searchBoxHeight = 40; // Height of search input + padding
- const macrosListHeight = Math.min(
- 200,
- filteredMacros().length * MENU_ITEM_HEIGHT
- );
- const dividerPadding = filteredMacros().length > 0 ? 9 : 0;
-
- return (
- startOffset +
- addPromptHeight +
- searchBoxHeight +
- macrosListHeight +
- dividerPadding
- );
- });
-
- return (
- <div
- ref={menuRef}
- class="absolute bg-menu flex flex-col rounded-md left-0 z-selector-menu"
- style={{ top: `-${menuVerticalStartPosition()}px` }}
- >
- <OldMenu width="lg">
- <OldMenuItem
- text="Add Prompt"
- icon={PlusIcon}
- onClick={() => {
- setMacroModalState({ type: 'create' });
- props.setShow(false);
- }}
- spacerBottom={filteredMacros().length > 0}
- />
-
- <div class="flex w-full p-1">
- <input
- type="text"
- placeholder="Search prompts..."
- value={searchQuery()}
- onInput={(e) => setSearchQuery(e.currentTarget.value)}
- class="w-full px-2 py-1 text-sm rounded bg-input ring-1 ring-edge"
- />
- </div>
-
- <div class="max-h-[200px] overflow-y-auto w-full">
- <For each={filteredMacros()}>
- {(macro) => (
- <OldMenuItem
- text={macro.title}
- icon={() => (
- <macro.icon style={{ color: colors[macro.color][500] }} />
- )}
- onClick={() => props.onMacroSelected(macro)}
- secondaryActionHandler={
- ENABLE_EDIT_MACROS
- ? (e) => {
- e.stopPropagation();
- setMacroModalState({ type: 'edit', macro });
- props.setShow(false);
- }
- : undefined
- }
- secondaryIcon={ENABLE_EDIT_MACROS ? PencilIcon : undefined}
- />
- )}
- </For>
- </div>
-
- {ENABLE_SEARCH_MACROS && (
- <OldMenuItem
- text="Search Macros"
- icon={SearchIcon}
- onClick={() => {}}
- />
- )}
- </OldMenu>
- </div>
- );
-}
-
-interface MacrosSelectorButtonProps {
- inputRef: Accessor<HTMLDivElement | null>;
-}
-
-export function MacrosSelectorButton(props: MacrosSelectorButtonProps) {
- const [showMacrosSelector, setShowMacrosSelector] = createSignal(false);
- const setSelectedMacro = macroSignal.set;
- const selectedMacro = macroSignal.get;
-
- const toggleShowMacrosSelector = () => {
- if (showMacrosSelector()) {
- setShowMacrosSelector(false);
- return;
- }
- setShowMacrosSelector(true);
- };
-
- function handleMacroSelection(macro: MacroPrompt) {
- const inputRef_ = props.inputRef();
- setSelectedMacro(macro);
- setShowMacrosSelector(false);
- setInputToMacroPrompt(inputRef_, macro);
- }
-
- const buttonIcon = createMemo(() => {
- const macro = selectedMacro();
- if (macro) {
- // Return a component that wraps the icon with styling
- return (props: any) => (
- <macro.icon {...props} style={{ color: colors[macro.color][500] }} />
- );
- }
- return LightningIcon;
- });
-
- // TODO- use solid portal for the menu
- // TODO- https://www.solidjs.com/tutorial/bindings_directives for click outside
- return (
- <div>
- <Show when={showMacrosSelector() && macros()}>
- <MacrosMenu
- onMacroSelected={handleMacroSelection}
- macros={macros()}
- setShow={setShowMacrosSelector}
- />
- </Show>
- <IconButton
- theme="clear"
- icon={buttonIcon()}
- onClick={toggleShowMacrosSelector}
- />
- </div>
- );
-}
diff --git a/js/app/packages/macros-prompts/MacrosSuggestionList.tsx b/js/app/packages/macros-prompts/MacrosSuggestionList.tsx
deleted file mode 100644
index dce42efd8b..0000000000
--- a/js/app/packages/macros-prompts/MacrosSuggestionList.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-import { TextButton } from '@core/component/TextButton';
-import PlusCircleIcon from '@phosphor-icons/core/regular/plus-circle.svg?component-solid';
-import { type Accessor, For } from 'solid-js';
-import colors from 'tailwindcss/colors';
-import {
- type MacroPrompt,
- macros,
- setInputToMacroPrompt,
- // setSelectedMacro,
-} from './macros';
-
-export function MacrosSuggestionList(props: {
- inputRef: Accessor<HTMLDivElement | null>;
-}) {
- function handleMacroSelection(macro: MacroPrompt) {
- const inputRef_ = props.inputRef();
-
- // setSelectedMacro(macro);
- setInputToMacroPrompt(inputRef_, macro);
- }
-
- return (
- <div class="relative flex flex-row gap-2 pt-4">
- <For each={macros()}>
- {(macro) => (
- <TextButton
- theme="clear"
- text={macro.title}
- icon={() => (
- <macro.icon style={{ color: colors[macro.color][500] }} />
- )}
- onClick={() => handleMacroSelection(macro)}
- />
- )}
- </For>
- <TextButton
- theme="clear"
- text="New Macro"
- icon={() => <PlusCircleIcon />}
- />
- </div>
- );
-}
diff --git a/js/app/packages/macros-prompts/README.md b/js/app/packages/macros-prompts/README.md
deleted file mode 100644
index 1d5d4fb461..0000000000
--- a/js/app/packages/macros-prompts/README.md
+++ /dev/null
@@ -1,15 +0,0 @@
-# macros-prompts
-
-To install dependencies:
-
-```bash
-bun install
-```
-
-To run:
-
-```bash
-bun run index.ts
-```
-
-This project was created using `bun init` in bun v1.1.24. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
diff --git a/js/app/packages/macros-prompts/macros.ts b/js/app/packages/macros-prompts/macros.ts
deleted file mode 100644
index 46d807309d..0000000000
--- a/js/app/packages/macros-prompts/macros.ts
+++ /dev/null
@@ -1,190 +0,0 @@
-import { createBlockSignal } from '@core/block';
-import { iconMap } from '@core/component/IconSelectorMenu';
-import { isErr } from '@core/util/maybeResult';
-import ArrowsClockwiseIcon from '@phosphor-icons/core/regular/arrows-clockwise.svg?component-solid';
-import FunnelXIcon from '@phosphor-icons/core/regular/funnel-x.svg?component-solid';
-import LightningIcon from '@phosphor-icons/core/regular/lightning.svg?component-solid';
-import MagnifyingGlassIcon from '@phosphor-icons/core/regular/magnifying-glass.svg?component-solid';
-import { cognitionApiServiceClient } from '@service-cognition/client';
-import type { FilteredTailwindColors } from 'core/component/TailwindColorPicker';
-import {
- type Component,
- type ComponentProps,
- createResource,
- createSignal,
-} from 'solid-js';
-
-export type MacroPrompt = {
- id: string;
- title: string;
- prompt: string;
- icon: Component<ComponentProps<'svg'>>;
- color: FilteredTailwindColors;
- requiredDocs?: number;
- // TODO-M-185
- // dssFileIds: string[]
-};
-
-export const ENABLE_MACROS_IN_CHAT = true;
-export const ENABLE_SEARCH_MACROS = false;
-export const ENABLE_EDIT_MACROS = true;
-
-// TODO- remove hardcoded in M-187
-export const PRELOADED_MACROS: MacroPrompt[] = [
- {
- id: '1',
- title: 'Compare Summarizer',
- icon: ArrowsClockwiseIcon,
- color: 'green',
- prompt: `Operate as a compare tool that can meticulously identify the differences between two documents.
-Compare the two documents attached and summarize the key points in a table.
-Then, extract all specific differences/changes and list in numbered format.`,
- },
- {
- id: '2',
- title: 'Redline Change Summary',
- icon: FunnelXIcon,
- color: 'red',
- prompt: `I want you to act as a legal Compare Change summary AI. I am going to give you a document and your task is to summarize all the changes in the agreement as a table. Do not include the name of the document in your reply.
-
-Here are the columns to use in your table:
-
-1. Section (clause or term). If the clause is not named and just numbered in the document, choose either to use the name of the enclosing clause or to make a name based on the clause e.g. if the clause is not labeled termination but has to do with termination, label it "Termination (11.1)".
-2. The change, verbatim. Use [[insertion]] to represent insertions (blue) and ~~deletion~~ to represent deleted text (red).
-3. Short summary of the change;
-4. Commercial or legal.
-5. The author of the change (author name field).
-
-It is very important that you DO NOT MISS ANY REDLINES i.e. include redlines in the document. Make sure to present your table IN ORDER from first page to last.`,
- },
- {
- id: '3',
- title: 'Plan out my day',
- icon: LightningIcon,
- color: 'purple',
- prompt: `Please act as my personal assistant. I need you to plan out my day and structure my tasks.
-If I add any documents to the chat, please incorporate them into my daily agenda.
-
-Otherwise, the following represent things I need to get done today:
-
-[INSERT LIST OF TASKS HERE]`,
- },
- {
- id: '4',
- title: 'Find Info from a Document',
- icon: MagnifyingGlassIcon,
- color: 'orange',
- prompt: `Operate as a search tool that can meticulously pull out information from a document.
-Search the attached document for the following information:
-
-`,
- },
-];
-
-// TODO- not adding to the list right away
-// TODO- not keeping the preloaded macros
-
-function getIconComponent(icon: string): Component<ComponentProps<'svg'>> {
- const component = iconMap[icon];
- if (!component) {
- console.warn(`Icon ${icon} not found, falling back to ArrowsClockwiseIcon`);
- return ArrowsClockwiseIcon;
- }
- return component;
-}
-
-export async function createMacro(macro: MacroPrompt) {
- // Find the icon name by comparing the component with the values in iconMap
- const iconName =
- Object.entries(iconMap).find(
- ([, component]) => component === macro.icon
- )?.[0] ?? 'ArrowsClockwiseIcon';
-
- const macroDbObject = {
- ...macro,
- icon: iconName,
- };
-
- const result = await cognitionApiServiceClient.createMacro(macroDbObject);
- if (isErr(result)) return false;
- return true;
-}
-
-export async function createNewAndUpdateMacros(newMacro: MacroPrompt) {
- const success = await createMacro(newMacro);
- if (success) {
- mutate((current) => [...(current ?? []), newMacro]);
- await refetch(); // TODO- is this needed?
- }
- return success;
-}
-
-function createMacroPromptFromDbObject(dbMacro: any): MacroPrompt {
- return {
- ...dbMacro,
- icon: getIconComponent(dbMacro.icon),
- };
-}
-
-async function getMacros(): Promise<MacroPrompt[]> {
- const result = await cognitionApiServiceClient.getMacros();
- if (isErr(result)) return [];
- const [, data] = result;
- // Map server response to MacroPrompt type
- // TODO- this is annoying but works, the openapi.json is wrong
- // @ts-ignore
- return data.map(createMacroPromptFromDbObject);
-}
-
-export async function editExistingMacro(macro: MacroPrompt) {
- // TODO- wait for backend to support this
- // @ts-ignore
- const _result = await cognitionApiServiceClient.updateMacro({
- macro_prompt_id: macro.id,
- ...macro,
- });
- mutate((current) => current?.map((m) => (m.id === macro.id ? macro : m)));
- return true;
-}
-
-export async function deleteMacro(id: string) {
- // TODO- wait for backend to support this
- // @ts-ignore
- const _result = await cognitionApiServiceClient.deleteMacro({
- macro_prompt_id: id,
- });
- mutate((current) => current?.filter((m) => m.id !== id));
- return true;
-}
-
-export const [macros, { mutate, refetch }] = createResource(getMacros, {
- initialValue: PRELOADED_MACROS,
-});
-
-type ModalMode = {
- type: 'create' | 'edit';
- macro?: MacroPrompt;
-};
-
-export const [macroModalState, setMacroModalState] =
- createSignal<ModalMode | null>(null);
-export const macroSignal = createBlockSignal<MacroPrompt | null>(null);
-
-export function setInputToMacroPrompt(
- inputRef: HTMLDivElement | null,
- macro: MacroPrompt | null
-) {
- if (!inputRef) return;
- if (!macro) {
- inputRef.innerText = '';
- }
- if (inputRef && macro) {
- inputRef.innerText = macro.prompt;
- }
- inputRef.dispatchEvent(new Event('input', { bubbles: true }));
-
- // TODO- set files to be MacroPromptFiles
- // TODO- M-191
- // one more param where the arg is a function to call that takes a DSS file and does something (e.g. set the chat)
- // Copy teo's @ reference in chat
-}
diff --git a/js/app/packages/macros-prompts/package.json b/js/app/packages/macros-prompts/package.json
deleted file mode 100644
index 18dbca9ff9..0000000000
--- a/js/app/packages/macros-prompts/package.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "name": "macros-prompts"
-}
diff --git a/js/app/packages/macros-prompts/tsconfig.json b/js/app/packages/macros-prompts/tsconfig.json
deleted file mode 100644
index 3a9c6c75eb..0000000000
--- a/js/app/packages/macros-prompts/tsconfig.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "extends": "../../tsconfig.json",
- "compilerOptions": {
- "jsx": "preserve",
- "jsxImportSource": "solid-js",
- "verbatimModuleSyntax": true,
- "declaration": true,
- "composite": true
- }
-}
diff --git a/js/app/tsconfig.json b/js/app/tsconfig.json
index 628267170c..1ce4cb277f 100644
--- a/js/app/tsconfig.json
+++ b/js/app/tsconfig.json
@@ -154,9 +154,6 @@
"@macro-icons/*": [
"./packages/macro-icons/*"
],
- "@macros-prompts/*": [
- "./packages/macros-prompts/*"
- ],
"@observability": [
"./packages/observability/src/"
],