@bendyline/gilde 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/authoring/chat-models/gemma4-12b-q4.json +7 -3
- package/authoring/chat-models/muse-glimmer-30b-q4.json +29 -3
- package/authoring/chat-models/nemotron3.5-bolt-e4b-q4.json +29 -3
- package/authoring/chat-models/qwen3.8-27b-q2.json +21 -5
- package/authoring/chat-models/qwen3.8-27b-q3.json +21 -5
- package/authoring/chat-models/qwen3.8-27b-q4.json +21 -5
- package/authoring/chat-models/qwen3.8-27b-q6.json +26 -6
- package/authoring/chat-models/qwen3.8-27b-q8.json +27 -6
- package/authoring/chat-models/qwen3.8-flash-next-q2.json +27 -7
- package/authoring/page-demo-bootstrap.js +96 -23
- package/data/chat-models/ge/gemma4-12b-q4/manifest.json +46 -3
- package/data/chat-models/ge/gemma4-12b-q4/versions/1.2.1/manifest.json +141 -0
- package/data/chat-models/ge/gemma4-e4b-q4/manifest.json +5 -0
- package/data/chat-models/index.json +1 -1
- package/data/chat-models/mu/muse-glimmer-30b-q4/manifest.json +25 -2
- package/data/chat-models/mu/muse-glimmer-30b-q4/versions/1.0.3/manifest.json +31 -0
- package/data/chat-models/ne/nemotron3.5-bolt-e4b-q4/manifest.json +21 -4
- package/data/chat-models/ne/nemotron3.5-bolt-e4b-q4/versions/1.0.2/manifest.json +26 -0
- package/data/chat-models/or/ornith1.5-9b-q4/manifest.json +5 -0
- package/data/chat-models/or/ornith1.5-9b-q8/manifest.json +5 -0
- package/data/chat-models/qw/qwen3.5-9b-q4/manifest.json +5 -0
- package/data/chat-models/qw/qwen3.8-27b-q2/manifest.json +20 -3
- package/data/chat-models/qw/qwen3.8-27b-q2/versions/1.0.1/manifest.json +31 -0
- package/data/chat-models/qw/qwen3.8-27b-q3/manifest.json +23 -6
- package/data/chat-models/qw/qwen3.8-27b-q3/versions/1.0.2/manifest.json +31 -0
- package/data/chat-models/qw/qwen3.8-27b-q4/manifest.json +25 -3
- package/data/chat-models/qw/qwen3.8-27b-q4/versions/1.0.6/manifest.json +128 -0
- package/data/chat-models/qw/qwen3.8-27b-q6/manifest.json +25 -9
- package/data/chat-models/qw/qwen3.8-27b-q6/versions/1.0.4/manifest.json +138 -0
- package/data/chat-models/qw/qwen3.8-27b-q8/manifest.json +20 -3
- package/data/chat-models/qw/qwen3.8-27b-q8/versions/1.0.3/manifest.json +148 -0
- package/data/chat-models/qw/qwen3.8-flash-next-q2/manifest.json +27 -7
- package/data/chat-models/qw/qwen3.8-flash-next-q2/versions/1.0.3/manifest.json +47 -0
- package/data/chat-models/qw/qwen3.8-flash-next-q2/versions/1.0.4/manifest.json +47 -0
- package/data/chat-models/raw-index.json +1 -1
- package/data/craftbook-templates/al/alert-rules/versions/1.0.6/craftbook.json +383 -0
- package/data/craftbook-templates/al/alert-rules/versions/1.0.6/test.json +145 -0
- package/data/craftbook-templates/index.json +1 -1
- package/data/craftbook-templates/raw-index.json +1 -1
- package/data/craftbook-templates/re/refactor-module/versions/2.0.8/craftbook.json +754 -0
- package/data/craftbook-templates/re/refactor-module/versions/2.0.8/test.json +241 -0
- package/data/project-types/bo/books-and-close/versions/1.1.0/about.md +16 -0
- package/data/project-types/bo/books-and-close/versions/1.1.0/close.json +8 -0
- package/data/project-types/bo/books-and-close/versions/1.1.0/ledger.json +5 -0
- package/data/project-types/bo/books-and-close/versions/1.1.0/manifest.json +496 -0
- package/data/project-types/bo/books-and-close/versions/1.1.0/mission.md +5 -0
- package/data/project-types/bo/books-and-close/versions/1.1.0/pages/books/application.js +417 -0
- package/data/project-types/bo/books-and-close/versions/1.1.0/pages/books/demo-chat.js +515 -0
- package/data/project-types/bo/books-and-close/versions/1.1.0/pages/books/index.html +880 -0
- package/data/project-types/ca/campaign-room/versions/1.1.0/about.md +13 -0
- package/data/project-types/ca/campaign-room/versions/1.1.0/assets.json +11 -0
- package/data/project-types/ca/campaign-room/versions/1.1.0/campaign.json +13 -0
- package/data/project-types/ca/campaign-room/versions/1.1.0/manifest.json +610 -0
- package/data/project-types/ca/campaign-room/versions/1.1.0/mission.md +6 -0
- package/data/project-types/ca/campaign-room/versions/1.1.0/pages/campaign/application.js +439 -0
- package/data/project-types/ca/campaign-room/versions/1.1.0/pages/campaign/demo-chat.js +290 -0
- package/data/project-types/ca/campaign-room/versions/1.1.0/pages/campaign/index.html +624 -0
- package/data/project-types/ca/campaign-room/versions/1.1.0/results.json +4 -0
- package/data/project-types/ca/caregiving-binder/versions/1.2.0/about.md +7 -0
- package/data/project-types/ca/caregiving-binder/versions/1.2.0/care.json +4 -0
- package/data/project-types/ca/caregiving-binder/versions/1.2.0/manifest.json +232 -0
- package/data/project-types/ca/caregiving-binder/versions/1.2.0/meds.json +8 -0
- package/data/project-types/ca/caregiving-binder/versions/1.2.0/mission.md +7 -0
- package/data/project-types/ca/caregiving-binder/versions/1.2.0/pages/dashboard/application.js +186 -0
- package/data/project-types/ca/caregiving-binder/versions/1.2.0/pages/dashboard/demo-chat.js +224 -0
- package/data/project-types/ca/caregiving-binder/versions/1.2.0/pages/dashboard/index.html +365 -0
- package/data/project-types/ca/cash-flow-planner/versions/1.1.0/about.md +15 -0
- package/data/project-types/ca/cash-flow-planner/versions/1.1.0/cashflow.json +11 -0
- package/data/project-types/ca/cash-flow-planner/versions/1.1.0/manifest.json +443 -0
- package/data/project-types/ca/cash-flow-planner/versions/1.1.0/mission.md +6 -0
- package/data/project-types/ca/cash-flow-planner/versions/1.1.0/pages/forecast/application.js +441 -0
- package/data/project-types/ca/cash-flow-planner/versions/1.1.0/pages/forecast/demo-chat.js +517 -0
- package/data/project-types/ca/cash-flow-planner/versions/1.1.0/pages/forecast/index.html +848 -0
- package/data/project-types/cl/client-delivery/versions/1.1.0/about.md +13 -0
- package/data/project-types/cl/client-delivery/versions/1.1.0/manifest.json +376 -0
- package/data/project-types/cl/client-delivery/versions/1.1.0/milestones.json +10 -0
- package/data/project-types/cl/client-delivery/versions/1.1.0/mission.md +5 -0
- package/data/project-types/cl/client-delivery/versions/1.1.0/pages/delivery/application.js +272 -0
- package/data/project-types/cl/client-delivery/versions/1.1.0/pages/delivery/demo-chat.js +185 -0
- package/data/project-types/cl/client-delivery/versions/1.1.0/pages/delivery/index.html +593 -0
- package/data/project-types/cl/client-delivery/versions/1.1.0/projects.json +10 -0
- package/data/project-types/co/compliance-register/versions/1.1.0/about.md +12 -0
- package/data/project-types/co/compliance-register/versions/1.1.0/evidence.json +4 -0
- package/data/project-types/co/compliance-register/versions/1.1.0/manifest.json +361 -0
- package/data/project-types/co/compliance-register/versions/1.1.0/mission.md +5 -0
- package/data/project-types/co/compliance-register/versions/1.1.0/obligations.json +9 -0
- package/data/project-types/co/compliance-register/versions/1.1.0/pages/register/application.js +292 -0
- package/data/project-types/co/compliance-register/versions/1.1.0/pages/register/demo-chat.js +156 -0
- package/data/project-types/co/compliance-register/versions/1.1.0/pages/register/index.html +406 -0
- package/data/project-types/co/content-studio/versions/1.1.0/about.md +12 -0
- package/data/project-types/co/content-studio/versions/1.1.0/calendar.json +10 -0
- package/data/project-types/co/content-studio/versions/1.1.0/manifest.json +541 -0
- package/data/project-types/co/content-studio/versions/1.1.0/mission.md +6 -0
- package/data/project-types/co/content-studio/versions/1.1.0/pages/studio/application.js +413 -0
- package/data/project-types/co/content-studio/versions/1.1.0/pages/studio/demo-chat.js +247 -0
- package/data/project-types/co/content-studio/versions/1.1.0/pages/studio/index.html +486 -0
- package/data/project-types/co/content-studio/versions/1.1.0/pieces.json +12 -0
- package/data/project-types/cu/customer-voice/versions/1.1.0/about.md +15 -0
- package/data/project-types/cu/customer-voice/versions/1.1.0/actions.json +9 -0
- package/data/project-types/cu/customer-voice/versions/1.1.0/feedback.json +4 -0
- package/data/project-types/cu/customer-voice/versions/1.1.0/manifest.json +512 -0
- package/data/project-types/cu/customer-voice/versions/1.1.0/mission.md +6 -0
- package/data/project-types/cu/customer-voice/versions/1.1.0/pages/voice/application.js +303 -0
- package/data/project-types/cu/customer-voice/versions/1.1.0/pages/voice/demo-chat.js +276 -0
- package/data/project-types/cu/customer-voice/versions/1.1.0/pages/voice/index.html +832 -0
- package/data/project-types/cu/customer-voice/versions/1.1.0/themes.json +8 -0
- package/data/project-types/da/data-analysis/versions/1.1.0/about.md +20 -0
- package/data/project-types/da/data-analysis/versions/1.1.0/manifest.json +70 -0
- package/data/project-types/da/data-analysis/versions/1.1.0/mission.md +4 -0
- package/data/project-types/da/data-analysis/versions/1.1.0/pages/analytics.js +63 -0
- package/data/project-types/da/data-analysis/versions/1.1.0/pages/application.js +118 -0
- package/data/project-types/da/data-analysis/versions/1.1.0/pages/dashboard.css +94 -0
- package/data/project-types/da/data-analysis/versions/1.1.0/pages/dashboard.js +177 -0
- package/data/project-types/da/data-analysis/versions/1.1.0/pages/datasets.js +44 -0
- package/data/project-types/da/data-analysis/versions/1.1.0/pages/demo-chat.js +181 -0
- package/data/project-types/da/data-analysis/versions/1.1.0/pages/demo.js +27 -0
- package/data/project-types/da/data-analysis/versions/1.1.0/pages/index.html +142 -0
- package/data/project-types/da/data-analysis/versions/1.1.0/pages/insights.js +136 -0
- package/data/project-types/de/design-scheme/versions/1.1.0/about.md +6 -0
- package/data/project-types/de/design-scheme/versions/1.1.0/manifest.json +95 -0
- package/data/project-types/de/design-scheme/versions/1.1.0/mission.md +3 -0
- package/data/project-types/de/design-scheme/versions/1.1.0/pages/gallery/application.js +124 -0
- package/data/project-types/de/design-scheme/versions/1.1.0/pages/gallery/demo-chat.js +236 -0
- package/data/project-types/de/design-scheme/versions/1.1.0/pages/gallery/index.html +238 -0
- package/data/project-types/de/design-scheme/versions/1.1.0/schemes/index.json +9 -0
- package/data/project-types/de/design-scheme/versions/1.1.0/schemes/warm-dusk.json +4 -0
- package/data/project-types/ev/event-desk/versions/1.1.0/about.md +14 -0
- package/data/project-types/ev/event-desk/versions/1.1.0/budget.json +5 -0
- package/data/project-types/ev/event-desk/versions/1.1.0/event.json +12 -0
- package/data/project-types/ev/event-desk/versions/1.1.0/guests.json +9 -0
- package/data/project-types/ev/event-desk/versions/1.1.0/manifest.json +785 -0
- package/data/project-types/ev/event-desk/versions/1.1.0/mission.md +7 -0
- package/data/project-types/ev/event-desk/versions/1.1.0/pages/desk/application.js +1114 -0
- package/data/project-types/ev/event-desk/versions/1.1.0/pages/desk/demo-chat.js +229 -0
- package/data/project-types/ev/event-desk/versions/1.1.0/pages/desk/index.html +864 -0
- package/data/project-types/ev/event-desk/versions/1.1.0/vendors.json +10 -0
- package/data/project-types/ev/event-desk/versions/1.1.0/venues.json +11 -0
- package/data/project-types/ev/event-planner/versions/1.1.0/about.md +7 -0
- package/data/project-types/ev/event-planner/versions/1.1.0/budget.json +5 -0
- package/data/project-types/ev/event-planner/versions/1.1.0/guests.json +10 -0
- package/data/project-types/ev/event-planner/versions/1.1.0/manifest.json +260 -0
- package/data/project-types/ev/event-planner/versions/1.1.0/mission.md +6 -0
- package/data/project-types/ev/event-planner/versions/1.1.0/pages/dashboard/application.js +234 -0
- package/data/project-types/ev/event-planner/versions/1.1.0/pages/dashboard/demo-chat.js +231 -0
- package/data/project-types/ev/event-planner/versions/1.1.0/pages/dashboard/index.html +322 -0
- package/data/project-types/fi/fitness-coach/versions/1.2.0/about.md +8 -0
- package/data/project-types/fi/fitness-coach/versions/1.2.0/craftbooks/training-recap.json +34 -0
- package/data/project-types/fi/fitness-coach/versions/1.2.0/manifest.json +249 -0
- package/data/project-types/fi/fitness-coach/versions/1.2.0/mission.md +7 -0
- package/data/project-types/fi/fitness-coach/versions/1.2.0/pages/dashboard/application.js +148 -0
- package/data/project-types/fi/fitness-coach/versions/1.2.0/pages/dashboard/demo-chat.js +253 -0
- package/data/project-types/fi/fitness-coach/versions/1.2.0/pages/dashboard/index.html +419 -0
- package/data/project-types/fi/fitness-coach/versions/1.2.0/training.json +6 -0
- package/data/project-types/fl/flashcards/versions/1.3.0/about.md +8 -0
- package/data/project-types/fl/flashcards/versions/1.3.0/deck.json +7 -0
- package/data/project-types/fl/flashcards/versions/1.3.0/manifest.json +243 -0
- package/data/project-types/fl/flashcards/versions/1.3.0/mission.md +6 -0
- package/data/project-types/fl/flashcards/versions/1.3.0/pages/review/application.js +147 -0
- package/data/project-types/fl/flashcards/versions/1.3.0/pages/review/demo-chat.js +331 -0
- package/data/project-types/fl/flashcards/versions/1.3.0/pages/review/index.html +635 -0
- package/data/project-types/fr/freelance-office/versions/1.1.0/about.md +6 -0
- package/data/project-types/fr/freelance-office/versions/1.1.0/invoices.json +9 -0
- package/data/project-types/fr/freelance-office/versions/1.1.0/manifest.json +215 -0
- package/data/project-types/fr/freelance-office/versions/1.1.0/mission.md +6 -0
- package/data/project-types/fr/freelance-office/versions/1.1.0/pages/dashboard/application.js +194 -0
- package/data/project-types/fr/freelance-office/versions/1.1.0/pages/dashboard/demo-chat.js +244 -0
- package/data/project-types/fr/freelance-office/versions/1.1.0/pages/dashboard/index.html +275 -0
- package/data/project-types/fu/fundraiser-hq/versions/1.1.0/about.md +7 -0
- package/data/project-types/fu/fundraiser-hq/versions/1.1.0/donations.json +7 -0
- package/data/project-types/fu/fundraiser-hq/versions/1.1.0/manifest.json +175 -0
- package/data/project-types/fu/fundraiser-hq/versions/1.1.0/mission.md +6 -0
- package/data/project-types/fu/fundraiser-hq/versions/1.1.0/pages/dashboard/application.js +158 -0
- package/data/project-types/fu/fundraiser-hq/versions/1.1.0/pages/dashboard/demo-chat.js +171 -0
- package/data/project-types/fu/fundraiser-hq/versions/1.1.0/pages/dashboard/index.html +247 -0
- package/data/project-types/gr/grants-and-proposals/versions/1.1.0/about.md +14 -0
- package/data/project-types/gr/grants-and-proposals/versions/1.1.0/manifest.json +549 -0
- package/data/project-types/gr/grants-and-proposals/versions/1.1.0/mission.md +6 -0
- package/data/project-types/gr/grants-and-proposals/versions/1.1.0/opportunities.json +12 -0
- package/data/project-types/gr/grants-and-proposals/versions/1.1.0/pages/grants/application.js +370 -0
- package/data/project-types/gr/grants-and-proposals/versions/1.1.0/pages/grants/demo-chat.js +197 -0
- package/data/project-types/gr/grants-and-proposals/versions/1.1.0/pages/grants/index.html +501 -0
- package/data/project-types/gr/grants-and-proposals/versions/1.1.0/requirements.json +8 -0
- package/data/project-types/hi/hiring-desk/versions/1.1.0/about.md +20 -0
- package/data/project-types/hi/hiring-desk/versions/1.1.0/candidates.json +12 -0
- package/data/project-types/hi/hiring-desk/versions/1.1.0/feedback.json +4 -0
- package/data/project-types/hi/hiring-desk/versions/1.1.0/manifest.json +428 -0
- package/data/project-types/hi/hiring-desk/versions/1.1.0/mission.md +5 -0
- package/data/project-types/hi/hiring-desk/versions/1.1.0/pages/desk/application.js +345 -0
- package/data/project-types/hi/hiring-desk/versions/1.1.0/pages/desk/demo-chat.js +231 -0
- package/data/project-types/hi/hiring-desk/versions/1.1.0/pages/desk/index.html +523 -0
- package/data/project-types/hi/hiring-desk/versions/1.1.0/roles.json +10 -0
- package/data/project-types/ho/household-budget/versions/1.1.0/about.md +6 -0
- package/data/project-types/ho/household-budget/versions/1.1.0/ledger.json +5 -0
- package/data/project-types/ho/household-budget/versions/1.1.0/manifest.json +191 -0
- package/data/project-types/ho/household-budget/versions/1.1.0/mission.md +5 -0
- package/data/project-types/ho/household-budget/versions/1.1.0/pages/dashboard/application.js +176 -0
- package/data/project-types/ho/household-budget/versions/1.1.0/pages/dashboard/demo-chat.js +207 -0
- package/data/project-types/ho/household-budget/versions/1.1.0/pages/dashboard/index.html +291 -0
- package/data/project-types/ho/household-manual/versions/1.1.0/about.md +7 -0
- package/data/project-types/ho/household-manual/versions/1.1.0/manifest.json +236 -0
- package/data/project-types/ho/household-manual/versions/1.1.0/mission.md +8 -0
- package/data/project-types/ho/household-manual/versions/1.1.0/pages/dashboard/application.js +196 -0
- package/data/project-types/ho/household-manual/versions/1.1.0/pages/dashboard/demo-chat.js +178 -0
- package/data/project-types/ho/household-manual/versions/1.1.0/pages/dashboard/index.html +327 -0
- package/data/project-types/ho/household-manual/versions/1.1.0/systems.json +8 -0
- package/data/project-types/im/image-feed/versions/1.1.0/about.md +21 -0
- package/data/project-types/im/image-feed/versions/1.1.0/manifest.json +330 -0
- package/data/project-types/im/image-feed/versions/1.1.0/mission.md +10 -0
- package/data/project-types/im/image-feed/versions/1.1.0/pages/gallery/application.js +111 -0
- package/data/project-types/im/image-feed/versions/1.1.0/pages/gallery/demo-chat.js +269 -0
- package/data/project-types/im/image-feed/versions/1.1.0/pages/gallery/index.html +899 -0
- package/data/project-types/im/image-feed/versions/1.1.0/posts/index.json +4 -0
- package/data/project-types/im/image-feed/versions/1.1.0/style-guide.md +24 -0
- package/data/project-types/in/inventory-reorder/versions/1.1.0/about.md +12 -0
- package/data/project-types/in/inventory-reorder/versions/1.1.0/items.json +9 -0
- package/data/project-types/in/inventory-reorder/versions/1.1.0/manifest.json +381 -0
- package/data/project-types/in/inventory-reorder/versions/1.1.0/mission.md +6 -0
- package/data/project-types/in/inventory-reorder/versions/1.1.0/orders.json +10 -0
- package/data/project-types/in/inventory-reorder/versions/1.1.0/pages/stock/application.js +320 -0
- package/data/project-types/in/inventory-reorder/versions/1.1.0/pages/stock/demo-chat.js +200 -0
- package/data/project-types/in/inventory-reorder/versions/1.1.0/pages/stock/index.html +398 -0
- package/data/project-types/in/inventory-reorder/versions/1.1.0/pages/stock/rules.js +665 -0
- package/data/project-types/index.json +1 -1
- package/data/project-types/jo/job-hunt/versions/1.1.0/about.md +10 -0
- package/data/project-types/jo/job-hunt/versions/1.1.0/activity.json +4 -0
- package/data/project-types/jo/job-hunt/versions/1.1.0/manifest.json +296 -0
- package/data/project-types/jo/job-hunt/versions/1.1.0/mission.md +9 -0
- package/data/project-types/jo/job-hunt/versions/1.1.0/pages/dashboard/application.js +240 -0
- package/data/project-types/jo/job-hunt/versions/1.1.0/pages/dashboard/demo-chat.js +176 -0
- package/data/project-types/jo/job-hunt/versions/1.1.0/pages/dashboard/index.html +424 -0
- package/data/project-types/jo/job-hunt/versions/1.1.0/pipeline.json +6 -0
- package/data/project-types/la/language-trainer/versions/1.2.0/about.md +8 -0
- package/data/project-types/la/language-trainer/versions/1.2.0/manifest.json +245 -0
- package/data/project-types/la/language-trainer/versions/1.2.0/mission.md +4 -0
- package/data/project-types/la/language-trainer/versions/1.2.0/pages/dashboard/application.js +118 -0
- package/data/project-types/la/language-trainer/versions/1.2.0/pages/dashboard/demo-chat.js +439 -0
- package/data/project-types/la/language-trainer/versions/1.2.0/pages/dashboard/index.html +503 -0
- package/data/project-types/la/language-trainer/versions/1.2.0/progress.json +10 -0
- package/data/project-types/la/language-trainer/versions/1.2.0/reviews.json +3 -0
- package/data/project-types/la/language-trainer/versions/1.2.0/scenarios.json +84 -0
- package/data/project-types/li/life-binder/versions/1.1.0/about.md +7 -0
- package/data/project-types/li/life-binder/versions/1.1.0/documents.json +145 -0
- package/data/project-types/li/life-binder/versions/1.1.0/manifest.json +206 -0
- package/data/project-types/li/life-binder/versions/1.1.0/mission.md +6 -0
- package/data/project-types/li/life-binder/versions/1.1.0/pages/dashboard/application.js +172 -0
- package/data/project-types/li/life-binder/versions/1.1.0/pages/dashboard/demo-chat.js +184 -0
- package/data/project-types/li/life-binder/versions/1.1.0/pages/dashboard/index.html +287 -0
- package/data/project-types/me/meal-planner/versions/1.1.0/about.md +10 -0
- package/data/project-types/me/meal-planner/versions/1.1.0/manifest.json +245 -0
- package/data/project-types/me/meal-planner/versions/1.1.0/menu.json +5 -0
- package/data/project-types/me/meal-planner/versions/1.1.0/mission.md +5 -0
- package/data/project-types/me/meal-planner/versions/1.1.0/pages/dashboard/application.js +243 -0
- package/data/project-types/me/meal-planner/versions/1.1.0/pages/dashboard/demo-chat.js +139 -0
- package/data/project-types/me/meal-planner/versions/1.1.0/pages/dashboard/index.html +253 -0
- package/data/project-types/me/meal-planner/versions/1.1.0/pantry.json +9 -0
- package/data/project-types/ne/new-hire-onboarding/versions/1.1.0/about.md +14 -0
- package/data/project-types/ne/new-hire-onboarding/versions/1.1.0/hires.json +8 -0
- package/data/project-types/ne/new-hire-onboarding/versions/1.1.0/manifest.json +325 -0
- package/data/project-types/ne/new-hire-onboarding/versions/1.1.0/mission.md +5 -0
- package/data/project-types/ne/new-hire-onboarding/versions/1.1.0/pages/plans/application.js +248 -0
- package/data/project-types/ne/new-hire-onboarding/versions/1.1.0/pages/plans/demo-chat.js +188 -0
- package/data/project-types/ne/new-hire-onboarding/versions/1.1.0/pages/plans/index.html +439 -0
- package/data/project-types/ne/new-hire-onboarding/versions/1.1.0/tasks.json +8 -0
- package/data/project-types/no/novel-writing-room/versions/1.1.0/about.md +7 -0
- package/data/project-types/no/novel-writing-room/versions/1.1.0/chapters.json +10 -0
- package/data/project-types/no/novel-writing-room/versions/1.1.0/manifest.json +233 -0
- package/data/project-types/no/novel-writing-room/versions/1.1.0/mission.md +7 -0
- package/data/project-types/no/novel-writing-room/versions/1.1.0/pages/dashboard/application.js +225 -0
- package/data/project-types/no/novel-writing-room/versions/1.1.0/pages/dashboard/demo-chat.js +283 -0
- package/data/project-types/no/novel-writing-room/versions/1.1.0/pages/dashboard/index.html +342 -0
- package/data/project-types/no/novel-writing-room/versions/1.1.0/sessions.json +6 -0
- package/data/project-types/qu/quotes-and-bids/versions/1.0.0/manifest.json +1 -1
- package/data/project-types/qu/quotes-and-bids/versions/1.0.0/pages/quotes/index.html +1 -1
- package/data/project-types/qu/quotes-and-bids/versions/1.1.0/about.md +15 -0
- package/data/project-types/qu/quotes-and-bids/versions/1.1.0/manifest.json +614 -0
- package/data/project-types/qu/quotes-and-bids/versions/1.1.0/mission.md +3 -0
- package/data/project-types/qu/quotes-and-bids/versions/1.1.0/pages/quotes/application.js +386 -0
- package/data/project-types/qu/quotes-and-bids/versions/1.1.0/pages/quotes/demo-chat.js +263 -0
- package/data/project-types/qu/quotes-and-bids/versions/1.1.0/pages/quotes/index.html +941 -0
- package/data/project-types/qu/quotes-and-bids/versions/1.1.0/quotes.json +10 -0
- package/data/project-types/qu/quotes-and-bids/versions/1.1.0/rates.json +8 -0
- package/data/project-types/raw-index.json +1 -1
- package/data/project-types/sa/sales-pipeline/versions/1.1.0/about.md +10 -0
- package/data/project-types/sa/sales-pipeline/versions/1.1.0/activity.json +4 -0
- package/data/project-types/sa/sales-pipeline/versions/1.1.0/deals.json +12 -0
- package/data/project-types/sa/sales-pipeline/versions/1.1.0/manifest.json +450 -0
- package/data/project-types/sa/sales-pipeline/versions/1.1.0/mission.md +3 -0
- package/data/project-types/sa/sales-pipeline/versions/1.1.0/pages/pipeline/application.js +270 -0
- package/data/project-types/sa/sales-pipeline/versions/1.1.0/pages/pipeline/demo-chat.js +219 -0
- package/data/project-types/sa/sales-pipeline/versions/1.1.0/pages/pipeline/index.html +710 -0
- package/data/project-types/sh/shift-roster/versions/1.1.0/about.md +13 -0
- package/data/project-types/sh/shift-roster/versions/1.1.0/availability.json +8 -0
- package/data/project-types/sh/shift-roster/versions/1.1.0/manifest.json +544 -0
- package/data/project-types/sh/shift-roster/versions/1.1.0/mission.md +5 -0
- package/data/project-types/sh/shift-roster/versions/1.1.0/pages/roster/application.js +418 -0
- package/data/project-types/sh/shift-roster/versions/1.1.0/pages/roster/demo-chat.js +218 -0
- package/data/project-types/sh/shift-roster/versions/1.1.0/pages/roster/index.html +466 -0
- package/data/project-types/sh/shift-roster/versions/1.1.0/pages/roster/rules.js +878 -0
- package/data/project-types/sh/shift-roster/versions/1.1.0/rules.json +4 -0
- package/data/project-types/sh/shift-roster/versions/1.1.0/shifts.json +8 -0
- package/data/project-types/sh/shift-roster/versions/1.1.0/staff.json +8 -0
- package/data/project-types/so/social-feed/versions/1.1.0/about.md +19 -0
- package/data/project-types/so/social-feed/versions/1.1.0/manifest.json +348 -0
- package/data/project-types/so/social-feed/versions/1.1.0/mission.md +10 -0
- package/data/project-types/so/social-feed/versions/1.1.0/pages/dashboard/application.js +119 -0
- package/data/project-types/so/social-feed/versions/1.1.0/pages/dashboard/demo-chat.js +321 -0
- package/data/project-types/so/social-feed/versions/1.1.0/pages/dashboard/index.html +837 -0
- package/data/project-types/so/social-feed/versions/1.1.0/posts/index.json +4 -0
- package/data/project-types/so/social-feed/versions/1.1.0/voice-guide.md +22 -0
- package/data/project-types/so/sop-library/versions/1.1.0/about.md +15 -0
- package/data/project-types/so/sop-library/versions/1.1.0/manifest.json +347 -0
- package/data/project-types/so/sop-library/versions/1.1.0/mission.md +4 -0
- package/data/project-types/so/sop-library/versions/1.1.0/pages/library/application.js +235 -0
- package/data/project-types/so/sop-library/versions/1.1.0/pages/library/demo-chat.js +184 -0
- package/data/project-types/so/sop-library/versions/1.1.0/pages/library/index.html +529 -0
- package/data/project-types/so/sop-library/versions/1.1.0/sops/index.json +10 -0
- package/data/project-types/su/support-desk/versions/1.1.0/about.md +15 -0
- package/data/project-types/su/support-desk/versions/1.1.0/manifest.json +395 -0
- package/data/project-types/su/support-desk/versions/1.1.0/mission.md +5 -0
- package/data/project-types/su/support-desk/versions/1.1.0/pages/desk/application.js +274 -0
- package/data/project-types/su/support-desk/versions/1.1.0/pages/desk/demo-chat.js +206 -0
- package/data/project-types/su/support-desk/versions/1.1.0/pages/desk/index.html +588 -0
- package/data/project-types/su/support-desk/versions/1.1.0/tickets.json +10 -0
- package/data/project-types/te/team-goals/versions/1.1.0/about.md +12 -0
- package/data/project-types/te/team-goals/versions/1.1.0/actions.json +8 -0
- package/data/project-types/te/team-goals/versions/1.1.0/checkins.json +4 -0
- package/data/project-types/te/team-goals/versions/1.1.0/goals.json +9 -0
- package/data/project-types/te/team-goals/versions/1.1.0/keyresults.json +8 -0
- package/data/project-types/te/team-goals/versions/1.1.0/manifest.json +528 -0
- package/data/project-types/te/team-goals/versions/1.1.0/mission.md +5 -0
- package/data/project-types/te/team-goals/versions/1.1.0/pages/goals/application.js +347 -0
- package/data/project-types/te/team-goals/versions/1.1.0/pages/goals/demo-chat.js +206 -0
- package/data/project-types/te/team-goals/versions/1.1.0/pages/goals/index.html +547 -0
- package/data/project-types/tr/training-tracker/versions/1.1.0/about.md +15 -0
- package/data/project-types/tr/training-tracker/versions/1.1.0/completions.json +4 -0
- package/data/project-types/tr/training-tracker/versions/1.1.0/courses.json +8 -0
- package/data/project-types/tr/training-tracker/versions/1.1.0/manifest.json +428 -0
- package/data/project-types/tr/training-tracker/versions/1.1.0/mission.md +5 -0
- package/data/project-types/tr/training-tracker/versions/1.1.0/pages/tracker/application.js +299 -0
- package/data/project-types/tr/training-tracker/versions/1.1.0/pages/tracker/demo-chat.js +225 -0
- package/data/project-types/tr/training-tracker/versions/1.1.0/pages/tracker/index.html +555 -0
- package/data/project-types/tr/training-tracker/versions/1.1.0/people.json +8 -0
- package/data/project-types/tr/training-tracker/versions/1.1.0/quizzes.json +8 -0
- package/data/project-types/tr/trip-planner/versions/1.1.0/about.md +7 -0
- package/data/project-types/tr/trip-planner/versions/1.1.0/journal.json +4 -0
- package/data/project-types/tr/trip-planner/versions/1.1.0/manifest.json +296 -0
- package/data/project-types/tr/trip-planner/versions/1.1.0/mission.md +4 -0
- package/data/project-types/tr/trip-planner/versions/1.1.0/packing.json +8 -0
- package/data/project-types/tr/trip-planner/versions/1.1.0/pages/dashboard/application.js +176 -0
- package/data/project-types/tr/trip-planner/versions/1.1.0/pages/dashboard/demo-chat.js +264 -0
- package/data/project-types/tr/trip-planner/versions/1.1.0/pages/dashboard/index.html +373 -0
- package/data/project-types/tr/trip-planner/versions/1.1.0/trip.json +8 -0
- package/data/project-types/ve/vendor-contracts/versions/1.1.0/about.md +15 -0
- package/data/project-types/ve/vendor-contracts/versions/1.1.0/contracts.json +10 -0
- package/data/project-types/ve/vendor-contracts/versions/1.1.0/manifest.json +545 -0
- package/data/project-types/ve/vendor-contracts/versions/1.1.0/mission.md +5 -0
- package/data/project-types/ve/vendor-contracts/versions/1.1.0/pages/desk/application.js +323 -0
- package/data/project-types/ve/vendor-contracts/versions/1.1.0/pages/desk/demo-chat.js +236 -0
- package/data/project-types/ve/vendor-contracts/versions/1.1.0/pages/desk/index.html +540 -0
- package/data/project-types/ve/vendor-contracts/versions/1.1.0/vendors.json +8 -0
- package/package.json +1 -1
- package/schemas/chat-model-identity.schema.json +215 -0
- package/schemas/chat-model-version.schema.json +85 -0
- package/schemas/craftbook-doc.schema.json +15 -0
- package/schemas/craftbook-template-version.schema.json +12 -0
- package/schemas/craftbook-test.schema.json +12 -0
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
// The standalone demo's sample conversation. In Gezel, the bookkeeper's
|
|
2
|
+
// replies come from the model the person chooses; here they are scripted, and
|
|
3
|
+
// every change goes through the same tools the crew calls.
|
|
4
|
+
window.demoChat = (function () {
|
|
5
|
+
'use strict';
|
|
6
|
+
// ── cashflow-rules-start ──
|
|
7
|
+
// Pure derivations shared by the script, the page and the sample conversation:
|
|
8
|
+
// integer-cent money, repeat dates, and the 13-week forecast with its tightest
|
|
9
|
+
// week, for the plan and for each what-if. Kept self-contained between these
|
|
10
|
+
// sentinels so unit tests execute the shipped bytes.
|
|
11
|
+
var DAY_MS = 86400000;
|
|
12
|
+
var WEEKS = 13;
|
|
13
|
+
var RECURS = ['none', 'weekly', 'biweekly', 'monthly', 'quarterly'];
|
|
14
|
+
var RECURS_TEXT = { none: 'once', weekly: 'every week', biweekly: 'every two weeks', monthly: 'every month', quarterly: 'every quarter' };
|
|
15
|
+
var SHORT_MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
16
|
+
|
|
17
|
+
function pad(n) {
|
|
18
|
+
return n < 10 ? '0' + n : String(n);
|
|
19
|
+
}
|
|
20
|
+
function localDay(ms) {
|
|
21
|
+
var d = new Date(ms);
|
|
22
|
+
return d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate());
|
|
23
|
+
}
|
|
24
|
+
function normalizeDate(text) {
|
|
25
|
+
var raw = String(text || '').trim();
|
|
26
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(raw)) return raw;
|
|
27
|
+
var parsed = Date.parse(raw);
|
|
28
|
+
return isFinite(parsed) ? localDay(parsed) : null;
|
|
29
|
+
}
|
|
30
|
+
// Local noon, so adding days never trips over a daylight-saving change.
|
|
31
|
+
function dayMs(day) {
|
|
32
|
+
return Date.parse(String(day).slice(0, 10) + 'T12:00:00');
|
|
33
|
+
}
|
|
34
|
+
function addDays(day, n) {
|
|
35
|
+
var d = new Date(dayMs(day));
|
|
36
|
+
d.setDate(d.getDate() + n);
|
|
37
|
+
return localDay(d.getTime());
|
|
38
|
+
}
|
|
39
|
+
// The same day of the month `months` later; the 31st lands on a shorter month's last day.
|
|
40
|
+
function addMonths(day, months, dom) {
|
|
41
|
+
var d = new Date(dayMs(day));
|
|
42
|
+
var date = dom || d.getDate();
|
|
43
|
+
d.setDate(1);
|
|
44
|
+
d.setMonth(d.getMonth() + months);
|
|
45
|
+
d.setDate(Math.min(date, new Date(d.getFullYear(), d.getMonth() + 1, 0).getDate()));
|
|
46
|
+
return localDay(d.getTime());
|
|
47
|
+
}
|
|
48
|
+
// The k-th date of a series counted from its anchor, so a monthly 31st never drifts.
|
|
49
|
+
function occurrence(anchor, recurs, k, dom) {
|
|
50
|
+
if (recurs === 'weekly') return addDays(anchor, 7 * k);
|
|
51
|
+
if (recurs === 'biweekly') return addDays(anchor, 14 * k);
|
|
52
|
+
if (recurs === 'monthly') return addMonths(anchor, k, dom);
|
|
53
|
+
if (recurs === 'quarterly') return addMonths(anchor, 3 * k, dom);
|
|
54
|
+
return k === 0 ? anchor : null;
|
|
55
|
+
}
|
|
56
|
+
function daysBetween(from, to) {
|
|
57
|
+
return Math.round((dayMs(to) - dayMs(from)) / DAY_MS);
|
|
58
|
+
}
|
|
59
|
+
function mondayOf(day) {
|
|
60
|
+
return addDays(day, -((new Date(dayMs(day)).getDay() + 6) % 7));
|
|
61
|
+
}
|
|
62
|
+
function weekLabel(day) {
|
|
63
|
+
return SHORT_MONTHS[Number(day.slice(5, 7)) - 1] + ' ' + Number(day.slice(8, 10));
|
|
64
|
+
}
|
|
65
|
+
// Integer cents from 9600, '9,600.00' or '-1240', with no float arithmetic.
|
|
66
|
+
function parseCents(value) {
|
|
67
|
+
var text = typeof value === 'number' ? (isFinite(value) ? String(value) : '') : String(value == null ? '' : value);
|
|
68
|
+
var m = /^(-?)(\d+)(?:\.(\d*))?$/.exec(text.replace(/[$,\s]/g, ''));
|
|
69
|
+
if (!m) return null;
|
|
70
|
+
var frac = (m[3] || '') + '000';
|
|
71
|
+
var cents = Number(m[2]) * 100 + Number(frac.slice(0, 2)) + (Number(frac.charAt(2)) >= 5 ? 1 : 0);
|
|
72
|
+
return m[1] ? -cents : cents;
|
|
73
|
+
}
|
|
74
|
+
function toCents(value) {
|
|
75
|
+
var cents = parseCents(value);
|
|
76
|
+
return cents !== null && cents > 0 ? cents : null;
|
|
77
|
+
}
|
|
78
|
+
function money(cents) {
|
|
79
|
+
var abs = Math.abs(Math.round(cents));
|
|
80
|
+
var whole = String(Math.floor(abs / 100)).replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
81
|
+
return (cents < 0 ? '-' : '') + whole + '.' + pad(abs % 100);
|
|
82
|
+
}
|
|
83
|
+
function normalizeRecurs(text) {
|
|
84
|
+
var raw = String(text || '').trim().toLowerCase();
|
|
85
|
+
if (RECURS.indexOf(raw) >= 0) return raw;
|
|
86
|
+
if (/two weeks|fortnight|bi-?weekly/.test(raw)) return 'biweekly';
|
|
87
|
+
if (/week/.test(raw)) return 'weekly';
|
|
88
|
+
if (/quarter/.test(raw)) return 'quarterly';
|
|
89
|
+
if (/month/.test(raw)) return 'monthly';
|
|
90
|
+
if (/once|one-?off|single/.test(raw)) return 'none';
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
function scenarioNames(records) {
|
|
94
|
+
var names = [];
|
|
95
|
+
records.forEach(function (r) {
|
|
96
|
+
var s = r.status === 'whatif' && r.fields && r.fields.scenario;
|
|
97
|
+
if (s && names.indexOf(s) < 0) names.push(s);
|
|
98
|
+
});
|
|
99
|
+
return names;
|
|
100
|
+
}
|
|
101
|
+
// The plan's expected items, or the plan with one what-if's changes applied.
|
|
102
|
+
function planItems(records, scenario) {
|
|
103
|
+
var changes = records.filter(function (r) {
|
|
104
|
+
return scenario && r.status === 'whatif' && r.fields.scenario === scenario && r.fields.change !== 'add';
|
|
105
|
+
});
|
|
106
|
+
return records
|
|
107
|
+
.filter(function (r) {
|
|
108
|
+
return r.status === 'expected' || (scenario && r.status === 'whatif' && r.fields.scenario === scenario && r.fields.change === 'add');
|
|
109
|
+
})
|
|
110
|
+
.map(function (r) {
|
|
111
|
+
var shift = 0;
|
|
112
|
+
var dropped = false;
|
|
113
|
+
changes.forEach(function (c) {
|
|
114
|
+
if (c.fields.itemId !== r.id) return;
|
|
115
|
+
if (c.fields.change === 'drop') dropped = true;
|
|
116
|
+
if (c.fields.change === 'delay') shift += Math.round(Number(c.fields.weeks) || 0);
|
|
117
|
+
});
|
|
118
|
+
var f = r.fields;
|
|
119
|
+
return dropped
|
|
120
|
+
? null
|
|
121
|
+
: { id: r.id, name: f.name, direction: f.direction, amountCents: f.amountCents, date: f.date, recurs: f.recurs || 'none', until: f.until || '', dom: f.dom, shiftDays: 7 * shift, whatIf: r.status === 'whatif' };
|
|
122
|
+
})
|
|
123
|
+
.filter(Boolean);
|
|
124
|
+
}
|
|
125
|
+
// Thirteen weeks from this Monday. A repeat dated before the balance is already in it; a one-off
|
|
126
|
+
// that never came stays expected and is counted (and flagged late) in the first week.
|
|
127
|
+
function forecast(file, scenario, nowMs) {
|
|
128
|
+
var today = localDay(nowMs);
|
|
129
|
+
var balance = file && file.balance && typeof file.balance.amountCents === 'number' ? file.balance : null;
|
|
130
|
+
var asOf = balance && balance.asOf ? balance.asOf : today;
|
|
131
|
+
var start = mondayOf(today);
|
|
132
|
+
var end = addDays(start, 7 * WEEKS - 1);
|
|
133
|
+
var from = asOf < start ? asOf : start;
|
|
134
|
+
var weeks = [];
|
|
135
|
+
for (var w = 0; w < WEEKS; w++) weeks.push({ start: addDays(start, 7 * w), inCents: 0, outCents: 0, items: [] });
|
|
136
|
+
var late = [];
|
|
137
|
+
planItems((file && file.records) || [], scenario).forEach(function (item) {
|
|
138
|
+
if (!item.date || !(item.amountCents > 0)) return;
|
|
139
|
+
var k = 0;
|
|
140
|
+
if (item.recurs !== 'none') {
|
|
141
|
+
var gap = daysBetween(item.date, from) - item.shiftDays;
|
|
142
|
+
var period = { weekly: 7, biweekly: 14, monthly: 31, quarterly: 92 }[item.recurs] || 7;
|
|
143
|
+
if (gap > 0) k = Math.max(0, Math.floor(gap / period) - 1);
|
|
144
|
+
}
|
|
145
|
+
for (var guard = 0; guard < 600; guard++, k++) {
|
|
146
|
+
var raw = occurrence(item.date, item.recurs, k, item.dom);
|
|
147
|
+
if (!raw || (item.until && raw > item.until)) break;
|
|
148
|
+
var day = item.shiftDays ? addDays(raw, item.shiftDays) : raw;
|
|
149
|
+
if (day > end) break;
|
|
150
|
+
if (item.recurs !== 'none' && day < asOf) continue;
|
|
151
|
+
var isLate = item.recurs === 'none' && day < today;
|
|
152
|
+
var hit = { id: item.id, name: item.name, direction: item.direction, amountCents: item.amountCents, day: day, late: isLate, whatIf: item.whatIf };
|
|
153
|
+
var week = weeks[day < start ? 0 : Math.floor(daysBetween(start, day) / 7)];
|
|
154
|
+
if (item.direction === 'in') week.inCents += item.amountCents;
|
|
155
|
+
else week.outCents += item.amountCents;
|
|
156
|
+
week.items.push(hit);
|
|
157
|
+
if (isLate) late.push(hit);
|
|
158
|
+
if (item.recurs === 'none') break;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
var running = balance ? balance.amountCents : 0;
|
|
162
|
+
var totalIn = 0;
|
|
163
|
+
var totalOut = 0;
|
|
164
|
+
weeks.forEach(function (wk) {
|
|
165
|
+
wk.openCents = running;
|
|
166
|
+
running += wk.inCents - wk.outCents;
|
|
167
|
+
wk.closeCents = running;
|
|
168
|
+
totalIn += wk.inCents;
|
|
169
|
+
totalOut += wk.outCents;
|
|
170
|
+
});
|
|
171
|
+
var cushion = file && typeof file.cushionCents === 'number' ? file.cushionCents : 0;
|
|
172
|
+
var lowest = weeks[0];
|
|
173
|
+
weeks.forEach(function (wk) {
|
|
174
|
+
if (wk.closeCents < lowest.closeCents) lowest = wk;
|
|
175
|
+
});
|
|
176
|
+
return {
|
|
177
|
+
today: today, start: start, asOf: asOf, hasBalance: !!balance, balanceCents: balance ? balance.amountCents : 0,
|
|
178
|
+
cushionCents: cushion, weeks: weeks, lowest: lowest, late: late, inCents: totalIn, outCents: totalOut, endCents: running,
|
|
179
|
+
firstLow: weeks.filter(function (wk) { return wk.closeCents < cushion; })[0] || null,
|
|
180
|
+
firstNegative: weeks.filter(function (wk) { return wk.closeCents < 0; })[0] || null,
|
|
181
|
+
belowCushion: weeks.filter(function (wk) { return wk.closeCents < cushion; }).length,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function biggest(week) {
|
|
185
|
+
return week.items
|
|
186
|
+
.filter(function (i) { return i.direction === 'out'; })
|
|
187
|
+
.sort(function (a, b) { return b.amountCents - a.amountCents; })
|
|
188
|
+
.slice(0, 3)
|
|
189
|
+
.map(function (i) { return i.name + ' ' + money(i.amountCents); })
|
|
190
|
+
.reduce(function (text, part, i, all) { return text + (i === 0 ? '' : i === all.length - 1 ? ' and ' : '; ') + part; }, '');
|
|
191
|
+
}
|
|
192
|
+
// The answer to "when does cash get tight?": the warning week first, with what goes out in it.
|
|
193
|
+
function tightLine(f) {
|
|
194
|
+
var low = f.lowest;
|
|
195
|
+
var warn = f.firstNegative || f.firstLow;
|
|
196
|
+
var week = function (w) { return 'the week of ' + weekLabel(w.start) + ' (' + w.start + ')'; };
|
|
197
|
+
var going = function (w) { var out = biggest(w); return out ? ', when ' + out + ' go out' : ''; };
|
|
198
|
+
if (!warn) {
|
|
199
|
+
return 'Cash stays above the ' + money(f.cushionCents) + ' cushion for all ' + WEEKS + ' weeks; the tightest is ' + week(low) + ', ending at ' + money(low.closeCents) + going(low) + '.';
|
|
200
|
+
}
|
|
201
|
+
return (
|
|
202
|
+
(f.firstNegative ? 'Cash runs out in ' : 'Cash first drops below the ' + money(f.cushionCents) + ' cushion in ') + week(warn) +
|
|
203
|
+
', ending at ' + money(warn.closeCents) + going(warn) + '. ' +
|
|
204
|
+
(low === warn ? 'That is the tightest week.' : 'The tightest is ' + week(low) + ', ending at ' + money(low.closeCents) + '.')
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
function compareLine(name, plan, alt) {
|
|
208
|
+
var low = alt.lowest;
|
|
209
|
+
return (
|
|
210
|
+
name + ': tightest week ' + weekLabel(low.start) + ' at ' + money(low.closeCents) +
|
|
211
|
+
' (plan: ' + weekLabel(plan.lowest.start) + ' at ' + money(plan.lowest.closeCents) + ')' +
|
|
212
|
+
(alt.firstNegative
|
|
213
|
+
? '; runs out in the week of ' + weekLabel(alt.firstNegative.start)
|
|
214
|
+
: alt.firstLow
|
|
215
|
+
? '; below the cushion from the week of ' + weekLabel(alt.firstLow.start)
|
|
216
|
+
: '; never below the cushion') +
|
|
217
|
+
'; ends the 13 weeks at ' + money(alt.endCents) + ' (plan ' + money(plan.endCents) + ')'
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
function itemLine(r, records) {
|
|
221
|
+
var f = r.fields || {};
|
|
222
|
+
if (f.change === 'delay' || f.change === 'drop') {
|
|
223
|
+
var target = records.filter(function (x) { return x.id === f.itemId; })[0];
|
|
224
|
+
var what = target ? target.fields.name + ' (' + target.id + ')' : f.itemId;
|
|
225
|
+
return r.id + ' [what-if ' + f.scenario + '] ' + (f.change === 'drop' ? 'drop ' + what : 'delay ' + what + ' by ' + f.weeks + (Number(f.weeks) === 1 ? ' week' : ' weeks'));
|
|
226
|
+
}
|
|
227
|
+
return (
|
|
228
|
+
r.id + (r.status === 'whatif' ? ' [what-if ' + f.scenario + '] add ' : ' ') + f.name + ': ' + (f.direction === 'in' ? 'in ' : 'out ') +
|
|
229
|
+
money(f.amountCents || 0) + ' ' + (f.recurs && f.recurs !== 'none' ? RECURS_TEXT[f.recurs] + ' from ' + f.date + (f.until ? ' until ' + f.until : '') : 'on ' + f.date) +
|
|
230
|
+
(r.status === 'done' ? ' (done)' : '')
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
function cashPicture(file, nowMs, scenario) {
|
|
234
|
+
var records = (file && file.records) || [];
|
|
235
|
+
var plan = forecast(file, null, nowMs);
|
|
236
|
+
var view = scenario ? forecast(file, scenario, nowMs) : plan;
|
|
237
|
+
var planned = records.filter(function (r) { return r.status === 'expected'; }).length;
|
|
238
|
+
if (!plan.hasBalance && !planned) {
|
|
239
|
+
return { plan: plan, view: view, summary: 'The plan is empty: no bank balance and no expected income or bills yet. Ask for today’s bank balance, the regular bills (payroll, rent, suppliers) and the invoices still to be paid.' };
|
|
240
|
+
}
|
|
241
|
+
var parts = [(scenario ? 'With the what-if ' + scenario + ': ' : '') + tightLine(view)];
|
|
242
|
+
parts.push(
|
|
243
|
+
plan.hasBalance
|
|
244
|
+
? 'Cash in the bank: ' + money(plan.balanceCents) + ' as of ' + plan.asOf + ' (cushion ' + money(plan.cushionCents) + ').' +
|
|
245
|
+
(daysBetween(plan.asOf, plan.today) > 7 ? ' That balance is ' + daysBetween(plan.asOf, plan.today) + ' days old; a fresh one sharpens the forecast.' : '')
|
|
246
|
+
: 'No bank balance yet, so the forecast starts from zero. Ask for today’s balance.',
|
|
247
|
+
);
|
|
248
|
+
if (view.late.length) {
|
|
249
|
+
parts.push('Late, counted in this week until it arrives or is moved: ' + view.late.map(function (i) { return i.name + ' (' + i.id + ', ' + (i.direction === 'in' ? 'in ' : 'out ') + money(i.amountCents) + ', expected ' + i.day + ')'; }).join('; ') + '.');
|
|
250
|
+
}
|
|
251
|
+
parts.push(
|
|
252
|
+
'Week by week, ending balance: ' +
|
|
253
|
+
view.weeks.map(function (wk) { return weekLabel(wk.start) + ' ' + money(wk.closeCents) + ' (in ' + money(wk.inCents) + ', out ' + money(wk.outCents) + ')'; }).join(' | ') + '.',
|
|
254
|
+
);
|
|
255
|
+
parts.push('Over 13 weeks: in ' + money(view.inCents) + ', out ' + money(view.outCents) + ', ending at ' + money(view.endCents) + '.');
|
|
256
|
+
var names = scenarioNames(records);
|
|
257
|
+
if (names.length) {
|
|
258
|
+
parts.push('What-ifs: ' + names.map(function (n) { return compareLine(n, plan, forecast(file, n, nowMs)); }).join(' | ') + '.');
|
|
259
|
+
}
|
|
260
|
+
return { plan: plan, view: view, summary: parts.join(' ') };
|
|
261
|
+
}
|
|
262
|
+
// ── cashflow-rules-end ──
|
|
263
|
+
// Brightline Electric's sample cash plan, dated from today so the demo never goes stale.
|
|
264
|
+
function demoPlan(nowMs) {
|
|
265
|
+
var today = localDay(nowMs);
|
|
266
|
+
var at = function (n) { return addDays(today, n); };
|
|
267
|
+
var nextFirst = addMonths(today.slice(0, 8) + '01', 1);
|
|
268
|
+
var rows = [
|
|
269
|
+
['Payroll', 'out', 585000, at(4), 'biweekly'],
|
|
270
|
+
['Cascade Electric Supply account', 'out', 320000, at(12), 'monthly'],
|
|
271
|
+
['Shop rent', 'out', 160000, nextFirst, 'monthly'],
|
|
272
|
+
['Van loan', 'out', 68400, at(19), 'monthly'],
|
|
273
|
+
['Ridgeway Insurance', 'out', 123600, at(40), 'quarterly'],
|
|
274
|
+
['Estimated tax payment', 'out', 450000, at(58), 'none'],
|
|
275
|
+
['Delgado Trenching', 'out', 190000, at(26), 'none'],
|
|
276
|
+
['Alder Street remodel, final invoice', 'in', 960000, at(-6), 'none'],
|
|
277
|
+
['Service calls (weekly average)', 'in', 140000, at(5), 'weekly'],
|
|
278
|
+
['Kim residence panel upgrade', 'in', 325000, at(9), 'none'],
|
|
279
|
+
['Ridgeview Apartments service contract', 'in', 240000, at(15), 'monthly'],
|
|
280
|
+
['Hollis Bakery lighting retrofit', 'in', 720000, at(33), 'none'],
|
|
281
|
+
['Juniper Press warehouse lighting', 'in', 1240000, at(47), 'none'],
|
|
282
|
+
['Fernwood Studio office rewire', 'in', 580000, at(68), 'none'],
|
|
283
|
+
];
|
|
284
|
+
var stamp = new Date(nowMs).toISOString();
|
|
285
|
+
var records = rows.map(function (r, i) {
|
|
286
|
+
return {
|
|
287
|
+
id: 'cf-' + (i + 1), status: 'expected', createdAt: stamp, updatedAt: stamp, history: [],
|
|
288
|
+
fields: { name: r[0], direction: r[1], amountCents: r[2], date: r[3], recurs: r[4], dom: Number(r[3].slice(8, 10)) },
|
|
289
|
+
};
|
|
290
|
+
});
|
|
291
|
+
records.push({
|
|
292
|
+
id: 'cf-15', status: 'whatif', createdAt: stamp, updatedAt: stamp, history: [],
|
|
293
|
+
fields: { scenario: 'Lose the Ridgeview contract', change: 'drop', itemId: 'cf-11' },
|
|
294
|
+
});
|
|
295
|
+
return {
|
|
296
|
+
version: 1,
|
|
297
|
+
stages: ['expected', 'whatif', 'done', 'removed'],
|
|
298
|
+
currency: 'USD',
|
|
299
|
+
balance: { amountCents: 984000, asOf: today },
|
|
300
|
+
cushionCents: 1200000,
|
|
301
|
+
records: records,
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
var MONTH_WORDS = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'];
|
|
305
|
+
var NUMBER_WORDS = { a: 1, an: 1, one: 1, two: 2, three: 3, four: 4, five: 5, six: 6, eight: 8 };
|
|
306
|
+
|
|
307
|
+
function cash(cents) { return (cents < 0 ? '-$' : '$') + money(Math.abs(cents)).replace(/\.00$/, ''); }
|
|
308
|
+
function state(ctx) {
|
|
309
|
+
return ctx.read('cashflow.json').then(function (file) {
|
|
310
|
+
file = file || { records: [] };
|
|
311
|
+
return { file: file, records: file.records || [], plan: forecast(file, null, Date.now()) };
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
function warnText(f) {
|
|
315
|
+
var w = f.firstNegative || f.firstLow;
|
|
316
|
+
if (!w) return 'cash stays above the ' + cash(f.cushionCents) + ' cushion for all 13 weeks (tightest: the week of ' + weekLabel(f.lowest.start) + ', at ' + cash(f.lowest.closeCents) + ')';
|
|
317
|
+
return (f.firstNegative ? 'cash runs out in the week of ' : 'cash first dips below the ' + cash(f.cushionCents) + ' cushion in the week of ') + weekLabel(w.start) + ', ending at ' + cash(w.closeCents);
|
|
318
|
+
}
|
|
319
|
+
function outsOf(week) {
|
|
320
|
+
return week.items.filter(function (i) { return i.direction === 'out'; }).sort(function (a, b) { return b.amountCents - a.amountCents; }).slice(0, 3).map(function (i) { return i.name + ' (' + cash(i.amountCents) + ')'; });
|
|
321
|
+
}
|
|
322
|
+
function joinWords(parts) { return parts.length < 2 ? parts.join('') : parts.slice(0, -1).join(', ') + ' and ' + parts[parts.length - 1]; }
|
|
323
|
+
function cap(text) { return text.charAt(0).toUpperCase() + text.slice(1); }
|
|
324
|
+
function amountIn(text) {
|
|
325
|
+
var m = text.match(/\$\s?([\d,]+(?:\.\d{1,2})?)\s*(k)?/i) || text.match(/\b([\d,]{3,}(?:\.\d{1,2})?)\b/);
|
|
326
|
+
if (!m) return null;
|
|
327
|
+
var cents = toCents(m[1]);
|
|
328
|
+
return cents && m[2] ? cents * 1000 : cents;
|
|
329
|
+
}
|
|
330
|
+
function weeksIn(text) {
|
|
331
|
+
var lower = text.toLowerCase();
|
|
332
|
+
var m = lower.match(/\b(\d+|a|an|one|two|three|four|five|six|eight)\s+(week|month)s?\b/);
|
|
333
|
+
if (!m) return /\blate\b/.test(lower) ? 4 : null;
|
|
334
|
+
var n = Number(m[1]) || NUMBER_WORDS[m[1]] || 1;
|
|
335
|
+
return m[2] === 'month' ? n * 4 : n;
|
|
336
|
+
}
|
|
337
|
+
// The expected item the person means: the one whose name shares the most words with what they wrote.
|
|
338
|
+
function findItem(records, text) {
|
|
339
|
+
var words = (text.toLowerCase().match(/[a-z]{3,}/g) || []).filter(function (w) {
|
|
340
|
+
return ['the', 'and', 'our', 'for', 'was', 'has', 'got', 'are', 'all', 'came', 'what', 'paid', 'pays', 'late', 'month', 'week', 'weeks', 'today', 'invoice', 'with', 'from', 'lose', 'lost'].indexOf(w) < 0;
|
|
341
|
+
});
|
|
342
|
+
var best = null, score = 0;
|
|
343
|
+
records.forEach(function (r) {
|
|
344
|
+
if (r.status !== 'expected') return;
|
|
345
|
+
var name = String(r.fields.name).toLowerCase();
|
|
346
|
+
var hits = words.filter(function (w) { return name.indexOf(w) >= 0; }).length;
|
|
347
|
+
if (hits > score) { best = r; score = hits; }
|
|
348
|
+
});
|
|
349
|
+
return best;
|
|
350
|
+
}
|
|
351
|
+
function nextDayOfMonth(day) {
|
|
352
|
+
var today = localDay(Date.now()), candidate = today.slice(0, 8) + (day < 10 ? '0' + day : String(day));
|
|
353
|
+
return candidate > today ? candidate : addMonths(candidate, 1, day);
|
|
354
|
+
}
|
|
355
|
+
function compare(name, plan, alt) {
|
|
356
|
+
var w = alt.firstNegative || alt.firstLow, pw = plan.firstNegative || plan.firstLow;
|
|
357
|
+
return '- Tightest week: ' + weekLabel(alt.lowest.start) + ' at ' + cash(alt.lowest.closeCents) + ' (the plan: ' + weekLabel(plan.lowest.start) + ' at ' + cash(plan.lowest.closeCents) + ')\n' +
|
|
358
|
+
'- ' + (alt.firstNegative ? '**Runs out in the week of ' + weekLabel(w.start) + '**' : w ? 'Below the cushion from the week of ' + weekLabel(w.start) : 'Never below the cushion') +
|
|
359
|
+
(pw ? ' (the plan: ' + weekLabel(pw.start) + ')' : ' (the plan never dips)') + '\n' +
|
|
360
|
+
'- After 13 weeks: ' + cash(alt.endCents) + ' (the plan: ' + cash(plan.endCents) + ')';
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function tight(ctx) {
|
|
364
|
+
return ctx.invoke('cash_forecast', {}, '13 weeks ahead').then(function () { return state(ctx); }).then(function (s) {
|
|
365
|
+
var f = s.plan, w = f.firstNegative || f.firstLow;
|
|
366
|
+
var late = f.late.map(function (i) { return i.name + ' (' + cash(i.amountCents) + ', due ' + weekLabel(i.day) + ')'; });
|
|
367
|
+
if (!f.hasBalance) return 'I need today’s bank balance first. Tell me what is in the account and I’ll run the 13 weeks.';
|
|
368
|
+
var head = w
|
|
369
|
+
? cap(warnText(f)) + ', when ' + joinWords(outsOf(w)) + ' go out in the same week.'
|
|
370
|
+
: cap(warnText(f)) + '.';
|
|
371
|
+
var low = w && w !== f.lowest ? ' The tightest point is the week of ' + weekLabel(f.lowest.start) + ', at ' + cash(f.lowest.closeCents) + '.' : '';
|
|
372
|
+
return head + low + '\n\n' +
|
|
373
|
+
(late.length ? 'That already counts ' + joinWords(late) + ' as arriving this week. If it slips, every week after it is lower by the same amount, so it is the one to chase.' : 'Nothing expected is late.') +
|
|
374
|
+
'\n\nCash in the bank today: ' + cash(f.balanceCents) + '.';
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function settle(ctx, text) {
|
|
379
|
+
return state(ctx).then(function (s) {
|
|
380
|
+
var rec = findItem(s.records, text);
|
|
381
|
+
if (!rec) return 'Which one came in? Name it, like “Alder Street paid the $9,600 today”.';
|
|
382
|
+
var cents = amountIn(text);
|
|
383
|
+
var input = { item: rec.id };
|
|
384
|
+
if (cents && cents !== rec.fields.amountCents) input.amount = cents / 100;
|
|
385
|
+
var before = s.plan;
|
|
386
|
+
return ctx.invoke('settle_cash_item', input, rec.fields.name).then(function () { return state(ctx); }).then(function (after) {
|
|
387
|
+
var moved = (after.plan.firstLow || {}).start !== (before.firstLow || {}).start || after.plan.lowest.closeCents !== before.lowest.closeCents;
|
|
388
|
+
var thisWeek = before.weeks[0].items.some(function (i) { return i.id === rec.id; });
|
|
389
|
+
return 'Recorded: **' + rec.fields.name + '** ' + (rec.fields.direction === 'in' ? 'came in' : 'was paid') + ', ' + cash(input.amount ? cents : rec.fields.amountCents) + '. Cash in the bank is now ' + cash(after.plan.balanceCents) + '.\n\n' +
|
|
390
|
+
(moved
|
|
391
|
+
? 'The forecast moved: ' + warnText(after.plan) + '.'
|
|
392
|
+
: thisWeek
|
|
393
|
+
? 'The forecast holds steady, because I was already counting it this week; now it is money in the bank rather than a promise. Still, ' + warnText(after.plan) + '.'
|
|
394
|
+
: 'It was expected on ' + weekLabel(rec.fields.date) + ', so only the weeks before then change. Still, ' + warnText(after.plan) + '.');
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
function whatIf(ctx, text) {
|
|
400
|
+
var lower = text.toLowerCase();
|
|
401
|
+
return state(ctx).then(function (s) {
|
|
402
|
+
var amount = amountIn(text), item = findItem(s.records, text), input;
|
|
403
|
+
if (/\b(hire|hiring|add|buy|lease|new)\b/.test(lower) && amount) {
|
|
404
|
+
var who = (lower.match(/\b(?:hire|hiring)\s+(?:an?\s+)?([a-z]+)/) || [])[1];
|
|
405
|
+
var payroll = s.records.filter(function (r) { return r.status === 'expected' && /payroll/i.test(r.fields.name); })[0];
|
|
406
|
+
var start = payroll ? payroll.fields.date : localDay(Date.now() + 7 * 86400000);
|
|
407
|
+
var three = lower.match(/\bin (\w+) weeks?\b/);
|
|
408
|
+
if (three) start = addDays(localDay(Date.now()), 7 * (Number(three[1]) || NUMBER_WORDS[three[1]] || 1));
|
|
409
|
+
var recurs = normalizeRecurs(lower) || (who ? 'biweekly' : 'none');
|
|
410
|
+
var name = who ? cap(who) + ' wages' : 'New cost';
|
|
411
|
+
input = { scenario: who ? 'Hire ' + (/^[aeiou]/.test(who) ? 'an ' : 'a ') + who : 'New cost', change: 'add', name: name, direction: 'out', amount: amount / 100, date: start, recurs: recurs };
|
|
412
|
+
} else if (item && /\b(lose|lost|drop|cancel|cancels|cancelled|without)\b/.test(lower)) {
|
|
413
|
+
input = { scenario: 'Lose ' + item.fields.name.split(/[,(]/)[0].trim(), change: 'drop', item: item.id };
|
|
414
|
+
} else if (item) {
|
|
415
|
+
var weeks = weeksIn(text) || 4;
|
|
416
|
+
input = { scenario: item.fields.name.split(/[ ,]/)[0] + ' ' + item.fields.name.split(/[ ,]/)[1] + ' pays ' + (weeks % 4 === 0 ? (weeks === 4 ? 'a month' : weeks / 4 + ' months') : weeks + ' weeks') + ' late', change: 'delay', item: item.id, weeks: weeks };
|
|
417
|
+
} else {
|
|
418
|
+
return 'What should I try? For example “what if Hollis Bakery pays a month late?” or “what if we hire an apprentice at $1,900 every two weeks?”.';
|
|
419
|
+
}
|
|
420
|
+
// A what-if that already makes this change keeps its name, so the board never shows the same scenario twice.
|
|
421
|
+
if (input.item) {
|
|
422
|
+
var same = s.records.filter(function (r) { return r.status === 'whatif' && r.fields.itemId === input.item && r.fields.change === input.change; })[0];
|
|
423
|
+
if (same) input.scenario = same.fields.scenario;
|
|
424
|
+
}
|
|
425
|
+
return ctx.invoke('what_if', input, 'What if: ' + input.scenario).then(function () { return state(ctx); }).then(function (after) {
|
|
426
|
+
var names = scenarioNames(after.records), scenario = names.filter(function (n) { return n.toLowerCase() === input.scenario.toLowerCase(); })[0] || input.scenario;
|
|
427
|
+
var alt = forecast(after.file, scenario, Date.now());
|
|
428
|
+
return 'I tried **' + scenario + '** as a what-if; the plan itself is unchanged.\n' + compare(scenario, after.plan, alt) + '\n\n' +
|
|
429
|
+
(alt.firstNegative ? 'That runs the account dry, so it would need a plan first: chase an invoice, move a bill, or start later.' : (alt.firstLow || {}).start && (!(after.plan.firstLow) || alt.firstLow.start < after.plan.firstLow.start) ? 'It brings the warning week forward, so I’d keep an eye on it.' : 'The plan absorbs it.') +
|
|
430
|
+
' It sits beside the plan under What-ifs; tell me to clear it whenever you like.';
|
|
431
|
+
});
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
function add(ctx, text) {
|
|
436
|
+
var lower = text.toLowerCase();
|
|
437
|
+
var cents = amountIn(text);
|
|
438
|
+
var nameMatch = text.match(/\badd (?:the |a |an |our )?(.+?)(?:,|\s+\$|\s+at\b|\s+for\b|$)/i);
|
|
439
|
+
if (!cents || !nameMatch) return Promise.resolve('Tell me what it is, how much and when, like “add the new van insurance, $310 a month from the 15th”.');
|
|
440
|
+
var name = cap(nameMatch[1].replace(/^new\s+/i, '').trim());
|
|
441
|
+
var dayMatch = lower.match(/\b(?:the\s+)?(\d{1,2})(?:st|nd|rd|th)\b/);
|
|
442
|
+
var monthMatch = lower.match(new RegExp('\\b(' + MONTH_WORDS.join('|') + ')\\s+(\\d{1,2})'));
|
|
443
|
+
var date = monthMatch ? localDay(Date.parse(new Date().getFullYear() + '-' + String(MONTH_WORDS.indexOf(monthMatch[1]) + 1).padStart(2, '0') + '-' + String(monthMatch[2]).padStart(2, '0') + 'T12:00:00')) : dayMatch ? nextDayOfMonth(Number(dayMatch[1])) : localDay(Date.now() + 7 * 86400000);
|
|
444
|
+
var recurs = /\ba month|monthly|every month\b/.test(lower) ? 'monthly' : normalizeRecurs(lower) || 'none';
|
|
445
|
+
var direction = /\b(invoice|income|payment from|pays us|deposit|retainer)\b/.test(lower) ? 'in' : 'out';
|
|
446
|
+
return state(ctx).then(function (s) {
|
|
447
|
+
var before = s.plan;
|
|
448
|
+
return ctx.invoke('add_cash_item', { name: name, direction: direction, amount: cents / 100, date: date, recurs: recurs }, name + ', ' + cash(cents)).then(function () { return state(ctx); }).then(function (after) {
|
|
449
|
+
var bw = before.firstNegative || before.firstLow, aw = after.plan.firstNegative || after.plan.firstLow;
|
|
450
|
+
return 'Added **' + name + '**: ' + (direction === 'in' ? 'in ' : 'out ') + cash(cents) + ' ' + (recurs === 'none' ? 'on ' : RECURS_TEXT[recurs] + ' from ') + weekLabel(date) + '.\n\n' +
|
|
451
|
+
(aw && (!bw || aw.start !== bw.start) ? 'That moves the warning week: ' + warnText(after.plan) + '.' : 'The warning week stays where it was: ' + warnText(after.plan) + '. Over 13 weeks the plan now ends at ' + cash(after.plan.endCents) + '.');
|
|
452
|
+
});
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
function setBalance(ctx, text) {
|
|
457
|
+
var cents = amountIn(text);
|
|
458
|
+
if (!cents) return Promise.resolve('How much is in the bank? A number like “$14,200” is enough.');
|
|
459
|
+
return ctx.invoke('set_balance', { amount: cents / 100 }, 'Balance ' + cash(cents)).then(function () { return state(ctx); }).then(function (s) {
|
|
460
|
+
return 'Saved: ' + cash(cents) + ' in the bank as of today. With that, ' + warnText(s.plan) + '.';
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
function clearWhatIf(ctx, text) {
|
|
465
|
+
return state(ctx).then(function (s) {
|
|
466
|
+
var names = scenarioNames(s.records);
|
|
467
|
+
var lower = text.toLowerCase();
|
|
468
|
+
var name = names.filter(function (n) { return n.toLowerCase().split(/\s+/).some(function (w) { return w.length > 3 && lower.indexOf(w) >= 0; }); })[0] || names[names.length - 1];
|
|
469
|
+
if (!name) return 'There are no what-ifs to clear.';
|
|
470
|
+
return ctx.invoke('what_if', { scenario: name, change: 'clear' }, 'Clear ' + name).then(function () { return 'Cleared the what-if **' + name + '**. The plan never changed.'; });
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
var start = forecast(demoPlan(Date.now()), null, Date.now());
|
|
475
|
+
var firstWarn = start.firstNegative || start.firstLow;
|
|
476
|
+
return {
|
|
477
|
+
name: 'Gijs',
|
|
478
|
+
role: 'Bookkeeper',
|
|
479
|
+
greeting: 'Hello, I’m Gijs. I keep Brightline Electric’s cash plan. ' + (firstWarn ? 'Cash first dips below the ' + cash(start.cushionCents) + ' cushion in the week of ' + weekLabel(firstWarn.start) : 'Cash holds above the cushion for 13 weeks') + ', and the Alder Street invoice is six days late.',
|
|
480
|
+
suggestions: [
|
|
481
|
+
'When does cash get tight?',
|
|
482
|
+
'Alder Street paid the $9,600 today',
|
|
483
|
+
'What if Hollis Bakery pays a month late?',
|
|
484
|
+
'What if we hire an apprentice at $1,900 every two weeks?',
|
|
485
|
+
'Add the new van insurance, $310 a month from the 15th',
|
|
486
|
+
],
|
|
487
|
+
respond: function (text, ctx) {
|
|
488
|
+
var lower = text.toLowerCase();
|
|
489
|
+
if (/\b(clear|forget|drop|remove)\b.*\bwhat-?if\b/.test(lower)) return clearWhatIf(ctx, text);
|
|
490
|
+
if (/\bwhat if\b|\bwhat happens if\b|\bsuppose\b/.test(lower)) return whatIf(ctx, text);
|
|
491
|
+
if (/\b(balance|in the bank|bank has|we have)\b/.test(lower) && /\d/.test(text)) return setBalance(ctx, text);
|
|
492
|
+
if (/^\s*add\b|\bnew (bill|invoice|cost)\b/.test(lower)) return add(ctx, text);
|
|
493
|
+
if (/\b(paid|came in|received|cleared|got the)\b/.test(lower)) return settle(ctx, text);
|
|
494
|
+
if (/\b(tight|low|short|forecast|runway|cash|when|weeks)\b/.test(lower)) return tight(ctx);
|
|
495
|
+
return null;
|
|
496
|
+
},
|
|
497
|
+
reactions: {
|
|
498
|
+
page_set_balance: function (input, output, ctx) {
|
|
499
|
+
return state(ctx).then(function (s) { return 'Saved ' + cash(toCents(input.amount) || 0) + ' as the bank balance. ' + cap(warnText(s.plan)) + '.'; });
|
|
500
|
+
},
|
|
501
|
+
page_add_cash_item: function (input, output, ctx) {
|
|
502
|
+
return state(ctx).then(function (s) { return 'Added ' + input.name + ' to the plan. ' + cap(warnText(s.plan)) + '.'; });
|
|
503
|
+
},
|
|
504
|
+
page_settle_cash_item: function (input, output, ctx) {
|
|
505
|
+
return state(ctx).then(function (s) { return 'Marked it done. Cash in the bank: ' + cash(s.plan.balanceCents) + '. ' + cap(warnText(s.plan)) + '.'; });
|
|
506
|
+
},
|
|
507
|
+
page_what_if: function (input, output, ctx) {
|
|
508
|
+
return state(ctx).then(function (s) {
|
|
509
|
+
var name = scenarioNames(s.records).filter(function (n) { return n.toLowerCase() === String(input.scenario || '').trim().toLowerCase(); })[0];
|
|
510
|
+
if (!name) return 'Tried it. The plan itself is unchanged.';
|
|
511
|
+
var alt = forecast(s.file, name, Date.now());
|
|
512
|
+
return 'With “' + name + '”, ' + warnText(alt) + '. The plan itself is unchanged.';
|
|
513
|
+
});
|
|
514
|
+
},
|
|
515
|
+
},
|
|
516
|
+
};
|
|
517
|
+
})();
|