# Common AI Prompts/Tasks and Information

## Conventions

## Programming Practices

- Do not use default exports. We use kebab-case for module names (does not apply to component
  files).
- The `rms-site` skill is available for extra help with working on this project.
- Ternaries should be implemented with a max depth of 1. Never do nested ternaries.

### Git

Do not interact with git commands that modify things unless I explicitly tell you to, though you may
freely invoke git commands that simply show info.

After completing a feature, I will sometimes ask you to give me a commit message. You will give me
the main git commit heading, and for the commit message body, you will use list items (using the
dash character to denote list items). The whole suggested commit msg should be in one copyable text
box.

## Project Structure

The entrypoint of this project is `src/index.tsx`. A client-side tampermonkey script will connect to
this webserver (which exports its bundle to `./dist`) and call `floatingActionBar`.

## App: Beauty Products survey autofill

Answer Presets, like those included in `src/_common/util/beauty/presets`, are used to generate
answer options for survey questions and call upon utility functions located in
`src/_common/util/index.ts` and `src/_common/util/beauty/utils.ts`. They can be used in various
contexts, such as in the "Skin Care" section of a beauty survey. Each preset includes a title, a
description, the type of input (e.g., "radio"), and a list of options. The options can be generated
randomly using randomly chosen numbers from a specified range, such as indicating randomly how many
items were out of stock. Another example of a randomized preset is answering how many items had
incorrect counts (ie. questions that ask how many out of stock items with 0 items in the
store/backroom show an on-hand count that is not actually 0), though this kind of randomized preset
does have a max bound as it depends on how many items were previously reported as being out of stock
in the first place. The need for these bounds is why the utility function `setDependentAnswerPreset`
is used:

Consider the usage:

```ts

const ANSWER_FLOWS: Record<string, AnswerFlow> = {
  7: setDirectAnswerPreset(
    undefined,
    "Garnier Skin Care Category - UPON ARRIVAL, BEFORE zoning or stocking, please count how many items are out of stock in the Garnier Skin Care category",
    "text",
    (storeLabel) => GLOBAL_PRESETS[storeLabel].skincare.garnier_oos_before(),
  ),
  8: setDependentAnswerPreset(
    undefined, // arg 1
    "Garnier Skin Care: After Zoning/Stocking/Merchandising, what is the Total # of Out Of Stocks during this visit", // arg 2
    "text", // arg 3
    [7], // arg 4
    beautyUtils.getAfterOOSCount, // arg 5
  );
}
```

In the call to `setDependentAnswerPreset`, the 4th argument is an array of answer IDs that the
preset depends on, and the 5th argument is a callback function that checks what answer(s) was given
to the question with the ID of 7, such that it will do its own internal computations to return a
(typically randomnized numerical) answer that is bounded by the answer to question 7. For example,
question 7 asks how many items were out of stock when I arrived to the store, and so naturally by
the time I leave the store, I should not have seen more out of stock items than I originally saw
when I arrived, which outlines the need for the need to bound the randomization of the answer
options for question 8 based on the answer given to question 7.

The dependency array could also contain several answer IDs, where for example it could refer to
multiple questions that each ask how many items were out of stock in the store that did not reflect
an out of stock on-hand count of 0, and the callback function could take in all of those answers as
arguments and do some computations with them to return a final answer that reflects a reasonable
answer based on the answers given to all of the questions in the dependency array, for example
answering why 0 items needed a count correction could depend on the answers to several questions
that each ask the aforementioned type of question about on-hand counts.

Further clarifications on arguments to `setDependentAnswerPreset` and `setDirectAnswerPreset`:

- If an answer callback function returns null, it means the question is skipped.
- The first argument is typically left as `undefined` if there is only 1 question in the survey
  whose question text is that of argument 2. However, if there are multiple questions in the survey
  with the same question text, then the first argument can be set to a string that indicates which
  particular section of the survey the question is in (e.g. "Garnier Skin Care Category" or "Garnier
  Skin Care Category")
- The callback function for `setDependentAnswerPreset` is detached from the typical execution flow
  of a program, and acts more like a Model View Controller where the callback is called
  independently and is automatically given the answers to the questions in the dependency array as
  arguments (in the same order as the dependency array).
- The question IDs are labeled by myself and can sometimes be floats simply because i wish to
  maintain a code locality where related questions are close to each other, but this is not
  necessary for accurate code execution and is more for organizational purposes.
- If a question ID given in a dependency array does not exist in the answer flow object, then this
  can cause errors in the execution of the program.

> Note: `on-hand count` refers to the store's inventory system for how many of a particular item it
> thinks are available across the store for purchase, while `out of stock` refers to the actual
> (verified by the personnel in the store that is completing the survey) event of an item having 0
> items available in the store for purchase. So if an item is out of stock, but the on-hand count is
> not 0, then that means the system is incorrectly tracking the item, which is a common issue that
> can occur in retail stores and is important to track and understand the reasons for.

## Tasks

### Task 1: Validate presets

Read the presets and confirm that the presets are set up to result in reasonable answers, in
particular calls to `setDependentAnswerPreset` of whether the answer the callback returns is
reasonable related to the dependency answer(s) it is based on.
