Mari's guided journal software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

117 lines
5.7 KiB

import {Separator} from "../prompts/Inquire.js";
import {inquire} from "../prompts/Inquire.js";
import {summaryPrompt} from "../prompts/implementations/SummaryPrompt.js";
import {journalEntryPrompt} from "../prompts/implementations/JournalEntryPrompt.js";
import {guidedEmpathyListPrompt} from "../prompts/implementations/GuidedEmpathyListPrompt.js";
import {entryMainMenuPrompt} from "../prompts/implementations/EntryMainMenuPrompt.js";
import {CommandModule} from "yargs";
import { registerPrompts } from "../prompts/types/index.js";
import {LocalRepository} from "../repository/LocalRepository.js";
import {conditionPrompt} from "../prompts/implementations/ConditionPrompt.js";
import {entryPrompt} from "../prompts/implementations/EntryPrompt.js";
import {guidedEmpathyPrompt} from "../prompts/implementations/GuidedEmpathyPrompt.js";
import {suicidalityPrompt} from "../prompts/implementations/SuicidalityPrompt.js";
import {yamlPrompt} from "../schemata/YAMLPrompt.js";
import {sleepRecordPrompt} from "../prompts/implementations/SleepRecordPrompt.js";
export function addEntryCommand(): CommandModule {
return {
command: ["add-entry", "*"],
describe: "Adds a new entry to the journal.",
handler: async () => {
registerPrompts()
const storage = new LocalRepository()
const empathyGuide = await storage.loadEmpathyGuide()
const condition = conditionPrompt({inquire})
const summary = summaryPrompt({inquire})
const journal = journalEntryPrompt({inquire})
const suicidality = suicidalityPrompt({inquire})
const sleep = sleepRecordPrompt({inquire})
const empathy = guidedEmpathyPrompt({
inquire,
guideFactory: () => empathyGuide,
show: async (value) => console.log(value),
})
const empathyList = guidedEmpathyListPrompt({inquire, promptForEmpathy: empathy})
const mainMenuItems = [
// TODO: add ability to amend previous entry
// TODO: add To-Do list items, which can be in four states (Pending, Done, Suspended, Canceled)
// A list item with the same ID as a previous one overrides it, allowing items to be edited or
// marked as done - the current state of the list is written to a separate part of the journal
// file (or a separate file) on save, so that we can easily edit it on future visits, but the
// entry also contains a changelog of entries added, changed, and removed
condition.mainMenu,
summary.mainMenu,
new Separator(),
journal.mainMenu,
empathyList.mainMenu,
sleep.mainMenu,
// TODO: Modified HierarchicalCheckboxInput to allow for putting more things in the main menu than
// there are letters
// TODO: gratitude journaling
// TODO: thinking about the future - where do you want to be in x years type thing
// TODO: breathing regulation exercises
// TODO: Goals for the day and checking in on how yesterday's goals went
/*
{
name: typeof entry.needs === "object" ? "Check back in on needs" : "Check in on needs",
// TODO: physical needs: food, water, exercise tracking, possibly with autocompletes for each saved in a file like the empathy guide
value: NEEDS,
key: "n"
},
{
name: typeof entry.personas === "object" ? "Check back in on personas" : "Check in on personas",
// TODO: Personas' individual journal entries
value: PERSONA,
key: "p"
},
{name: typeof entry.rpg === "object" ? "Change RPG stats" : "Add RPG stats", value: RPG, key: "r"},
{
name: typeof entry.activities === "object" ? "Change record of recent activities" : "Add record of recent activities",
// TODO: Add general activity set with historical activities saved in a file like the empathy guide
value: ACTIVITIES,
key: "a"
},
{
name: typeof entry.music === "object" ? "Change record of recently played music" : "Add record of recently played music",
// TODO: Add music
value: MUSIC,
key: "m"
},
*/
suicidality.mainMenu,
/*
{
name: typeof entry.recoveries === "object" ? "Try more recovery methods" : "Try some recovery methods",
// TODO: Add list of recovery methods
value: RECOVERIES,
key: "y"
},
*/
]
const promptYaml = yamlPrompt({
inquire,
showError: async (text: string) => console.log(text)
})
const mainMenu = entryMainMenuPrompt({
inquire,
choices: mainMenuItems,
promptYaml
})
const entry = entryPrompt({
promptForCondition: condition,
promptForSummary: summary,
promptForEntryMainMenu: mainMenu,
})
const writtenEntry = await entry({})
await storage.saveEntry(writtenEntry)
console.log("Entry saved! Good work!")
}
}
}