@opencorelabs/lucidity 0.3.0 → 0.6.0
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/README.md +9 -2
- package/dist/assets/speech/licenses/FluidAudio/LICENSE +201 -0
- package/dist/assets/speech/licenses/FluidAudio/ThirdPartyLicenses/fastcluster-LICENSE.md +11 -0
- package/dist/assets/speech/licenses/FluidAudio/ThirdPartyLicenses/vbx-LICENSE.md +201 -0
- package/dist/assets/speech/lucidity-speech +0 -0
- package/dist/automations/agent.d.ts +16 -0
- package/dist/automations/agent.d.ts.map +1 -0
- package/dist/automations/agent.js +196 -0
- package/dist/automations/cli.d.ts +4 -0
- package/dist/automations/cli.d.ts.map +1 -0
- package/dist/automations/cli.js +44 -0
- package/dist/automations/connections.d.ts +11 -0
- package/dist/automations/connections.d.ts.map +1 -0
- package/dist/automations/connections.js +74 -0
- package/dist/automations/designer.d.ts +39 -0
- package/dist/automations/designer.d.ts.map +1 -0
- package/dist/automations/designer.js +450 -0
- package/dist/automations/history.d.ts +4 -0
- package/dist/automations/history.d.ts.map +1 -0
- package/dist/automations/history.js +57 -0
- package/dist/automations/learning.d.ts +19 -0
- package/dist/automations/learning.d.ts.map +1 -0
- package/dist/automations/learning.js +121 -0
- package/dist/automations/pinterest.d.ts +21 -0
- package/dist/automations/pinterest.d.ts.map +1 -0
- package/dist/automations/pinterest.js +113 -0
- package/dist/automations/service.d.ts +42 -0
- package/dist/automations/service.d.ts.map +1 -0
- package/dist/automations/service.js +406 -0
- package/dist/automations/setup.d.ts +3 -0
- package/dist/automations/setup.d.ts.map +1 -0
- package/dist/automations/setup.js +48 -0
- package/dist/automations/skill.d.ts +3 -0
- package/dist/automations/skill.d.ts.map +1 -0
- package/dist/automations/skill.js +29 -0
- package/dist/automations/store.d.ts +13 -0
- package/dist/automations/store.d.ts.map +1 -0
- package/dist/automations/store.js +46 -0
- package/dist/chat/server.d.ts +2 -0
- package/dist/chat/server.d.ts.map +1 -1
- package/dist/chat/server.js +46 -2
- package/dist/coding/commandContext.d.ts +6 -0
- package/dist/coding/commandContext.d.ts.map +1 -0
- package/dist/coding/commandContext.js +20 -0
- package/dist/coding/runCodeTurn.d.ts +12 -2
- package/dist/coding/runCodeTurn.d.ts.map +1 -1
- package/dist/coding/runCodeTurn.js +49 -19
- package/dist/coding/worktree.d.ts +3 -4
- package/dist/coding/worktree.d.ts.map +1 -1
- package/dist/coding/worktree.js +3 -4
- package/dist/config.d.ts +4 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +20 -3
- package/dist/decisions/cli.d.ts +2 -0
- package/dist/decisions/cli.d.ts.map +1 -0
- package/dist/decisions/cli.js +106 -0
- package/dist/decisions/client.d.ts +20 -0
- package/dist/decisions/client.d.ts.map +1 -0
- package/dist/decisions/client.js +41 -0
- package/dist/handoff.d.ts +11 -0
- package/dist/handoff.d.ts.map +1 -0
- package/dist/handoff.js +21 -0
- package/dist/index.js +179 -40
- package/dist/jobs/briefing.js +1 -1
- package/dist/jobs/extraction.d.ts.map +1 -1
- package/dist/jobs/extraction.js +112 -22
- package/dist/jobs/fastModeReview.d.ts +39 -0
- package/dist/jobs/fastModeReview.d.ts.map +1 -0
- package/dist/jobs/fastModeReview.js +192 -0
- package/dist/jobs/voiceReview.d.ts +24 -0
- package/dist/jobs/voiceReview.d.ts.map +1 -0
- package/dist/jobs/voiceReview.js +128 -0
- package/dist/mcp/clients.d.ts +5 -0
- package/dist/mcp/clients.d.ts.map +1 -1
- package/dist/mcp/clients.js +1 -1
- package/dist/mcp/config.d.ts +3 -1
- package/dist/mcp/config.d.ts.map +1 -1
- package/dist/mcp/config.js +48 -6
- package/dist/mcp/paired.js +1 -0
- package/dist/notesContext.d.ts.map +1 -1
- package/dist/notesContext.js +3 -2
- package/dist/room/client.d.ts +20 -7
- package/dist/room/client.d.ts.map +1 -1
- package/dist/room/client.js +262 -45
- package/dist/room/computer.d.ts.map +1 -1
- package/dist/room/computer.js +8 -0
- package/dist/room/context.d.ts +3 -2
- package/dist/room/context.d.ts.map +1 -1
- package/dist/room/context.js +10 -3
- package/dist/room/turnQueue.d.ts +40 -0
- package/dist/room/turnQueue.d.ts.map +1 -0
- package/dist/room/turnQueue.js +301 -0
- package/dist/skills/lucidity-automations/SKILL.md +54 -0
- package/dist/speech/captures.d.ts +30 -0
- package/dist/speech/captures.d.ts.map +1 -0
- package/dist/speech/captures.js +209 -0
- package/dist/speech/fluidAudio.d.ts +28 -0
- package/dist/speech/fluidAudio.d.ts.map +1 -0
- package/dist/speech/fluidAudio.js +182 -0
- package/dist/speech/service.d.ts +14 -0
- package/dist/speech/service.d.ts.map +1 -0
- package/dist/speech/service.js +88 -0
- package/dist/speech/types.d.ts +19 -0
- package/dist/speech/types.d.ts.map +1 -0
- package/dist/speech/types.js +1 -0
- package/dist/turnLog.d.ts +1 -0
- package/dist/turnLog.d.ts.map +1 -1
- package/dist/turnLog.js +3 -0
- package/native/speech/Package.resolved +15 -0
- package/native/speech/Package.swift +16 -0
- package/native/speech/Sources/lucidity-speech/Speech.swift +81 -0
- package/package.json +6 -2
- package/src/automations/agent.ts +239 -0
- package/src/automations/cli.ts +52 -0
- package/src/automations/connections.ts +83 -0
- package/src/automations/designer.ts +594 -0
- package/src/automations/history.ts +59 -0
- package/src/automations/learning.ts +180 -0
- package/src/automations/pinterest.ts +146 -0
- package/src/automations/service.ts +505 -0
- package/src/automations/setup.ts +71 -0
- package/src/automations/skill.ts +40 -0
- package/src/automations/store.ts +63 -0
- package/src/chat/server.ts +62 -3
- package/src/coding/commandContext.ts +29 -0
- package/src/coding/runCodeTurn.ts +65 -21
- package/src/coding/worktree.ts +3 -4
- package/src/config.ts +29 -2
- package/src/decisions/cli.ts +136 -0
- package/src/decisions/client.ts +62 -0
- package/src/handoff.ts +28 -0
- package/src/index.ts +196 -67
- package/src/jobs/briefing.ts +1 -1
- package/src/jobs/extraction.ts +157 -32
- package/src/jobs/fastModeReview.ts +221 -0
- package/src/jobs/voiceReview.ts +156 -0
- package/src/mcp/clients.ts +1 -1
- package/src/mcp/config.ts +56 -6
- package/src/mcp/paired.ts +1 -0
- package/src/notesContext.ts +3 -2
- package/src/room/client.ts +316 -52
- package/src/room/computer.ts +8 -0
- package/src/room/context.ts +12 -3
- package/src/room/turnQueue.ts +358 -0
- package/src/speech/captures.ts +265 -0
- package/src/speech/fluidAudio.ts +242 -0
- package/src/speech/service.ts +108 -0
- package/src/speech/types.ts +13 -0
- package/src/turnLog.ts +4 -0
- package/vendor/decisions/LICENSE +662 -0
- package/vendor/decisions/dist/capture.d.ts +79 -0
- package/vendor/decisions/dist/capture.js +183 -0
- package/vendor/decisions/dist/command.d.ts +202 -0
- package/vendor/decisions/dist/command.js +750 -0
- package/vendor/decisions/dist/gate.d.ts +12 -0
- package/vendor/decisions/dist/gate.js +18 -0
- package/vendor/decisions/dist/index.d.ts +5 -0
- package/vendor/decisions/dist/index.js +5 -0
- package/vendor/decisions/dist/jev.d.ts +15 -0
- package/vendor/decisions/dist/jev.js +242 -0
- package/vendor/decisions/dist/types.d.ts +67 -0
- package/vendor/decisions/dist/types.js +1 -0
- package/vendor/decisions/package.json +22 -0
- package/vendor/decisions/src/capture.ts +199 -0
- package/vendor/decisions/src/command.ts +836 -0
- package/vendor/decisions/src/gate.ts +32 -0
- package/vendor/decisions/src/index.ts +5 -0
- package/vendor/decisions/src/jev.ts +293 -0
- package/vendor/decisions/src/types.ts +79 -0
- package/vendor/mcp-server/README.md +6 -1
- package/vendor/mcp-server/dist/client.d.ts +1 -0
- package/vendor/mcp-server/dist/client.d.ts.map +1 -1
- package/vendor/mcp-server/dist/client.js +8 -0
- package/vendor/mcp-server/dist/commentProvider.d.ts +3 -0
- package/vendor/mcp-server/dist/commentProvider.d.ts.map +1 -0
- package/vendor/mcp-server/dist/commentProvider.js +10 -0
- package/vendor/mcp-server/dist/index.js +21 -6
- package/vendor/mcp-server/dist/tools/automations.d.ts +6 -0
- package/vendor/mcp-server/dist/tools/automations.d.ts.map +1 -0
- package/vendor/mcp-server/dist/tools/automations.js +163 -0
- package/vendor/mcp-server/dist/tools/commandEventFormat.d.ts +52 -0
- package/vendor/mcp-server/dist/tools/commandEventFormat.d.ts.map +1 -0
- package/vendor/mcp-server/dist/tools/commandEventFormat.js +83 -0
- package/vendor/mcp-server/dist/tools/commandEvents.d.ts +3 -0
- package/vendor/mcp-server/dist/tools/commandEvents.d.ts.map +1 -0
- package/vendor/mcp-server/dist/tools/commandEvents.js +21 -0
- package/vendor/mcp-server/dist/tools/comments.d.ts.map +1 -1
- package/vendor/mcp-server/dist/tools/comments.js +25 -4
- package/vendor/mcp-server/dist/tools/index.d.ts +2 -0
- package/vendor/mcp-server/dist/tools/index.d.ts.map +1 -1
- package/vendor/mcp-server/dist/tools/index.js +2 -0
- package/vendor/mcp-server/dist/tools/journal.d.ts +3 -0
- package/vendor/mcp-server/dist/tools/journal.d.ts.map +1 -0
- package/vendor/mcp-server/dist/tools/journal.js +131 -0
- package/vendor/mcp-server/dist/tools/taskActivity.d.ts +3 -0
- package/vendor/mcp-server/dist/tools/taskActivity.d.ts.map +1 -0
- package/vendor/mcp-server/dist/tools/taskActivity.js +32 -0
- package/vendor/mcp-server/dist/tools/taskOccurrences.d.ts +3 -0
- package/vendor/mcp-server/dist/tools/taskOccurrences.d.ts.map +1 -0
- package/vendor/mcp-server/dist/tools/taskOccurrences.js +12 -0
- package/vendor/mcp-server/dist/tools/taskTrash.d.ts +3 -0
- package/vendor/mcp-server/dist/tools/taskTrash.d.ts.map +1 -0
- package/vendor/mcp-server/dist/tools/taskTrash.js +21 -0
- package/vendor/mcp-server/dist/tools/tasks.d.ts.map +1 -1
- package/vendor/mcp-server/dist/tools/tasks.js +67 -27
- package/vendor/mcp-server/package.json +5 -1
- package/vendor/mcp-server/src/client.ts +10 -0
- package/vendor/mcp-server/src/commentProvider.ts +9 -0
- package/vendor/mcp-server/src/index.ts +20 -6
- package/vendor/mcp-server/src/tools/automations.ts +199 -0
- package/vendor/mcp-server/src/tools/commandEventFormat.ts +108 -0
- package/vendor/mcp-server/src/tools/commandEvents.ts +27 -0
- package/vendor/mcp-server/src/tools/comments.ts +24 -3
- package/vendor/mcp-server/src/tools/index.ts +2 -0
- package/vendor/mcp-server/src/tools/journal.ts +168 -0
- package/vendor/mcp-server/src/tools/taskActivity.ts +55 -0
- package/vendor/mcp-server/src/tools/taskOccurrences.ts +26 -0
- package/vendor/mcp-server/src/tools/taskTrash.ts +23 -0
- package/vendor/mcp-server/src/tools/tasks.ts +66 -30
- package/vendor/notes/dist/index.d.ts +2 -0
- package/vendor/notes/dist/index.d.ts.map +1 -1
- package/vendor/notes/dist/index.js +2 -0
- package/vendor/notes/dist/journal-backend.d.ts +4 -0
- package/vendor/notes/dist/journal-backend.d.ts.map +1 -0
- package/vendor/notes/dist/journal-backend.js +33 -0
- package/vendor/notes/dist/journal.d.ts +7 -0
- package/vendor/notes/dist/journal.d.ts.map +1 -0
- package/vendor/notes/dist/journal.js +173 -0
- package/vendor/notes/dist/vault.d.ts.map +1 -1
- package/vendor/notes/dist/vault.js +6 -1
- package/vendor/notes/src/index.ts +2 -0
- package/vendor/notes/src/journal-backend.ts +53 -0
- package/vendor/notes/src/journal.ts +194 -0
- package/vendor/notes/src/vault.ts +9 -1
- package/vendor/runtime/README.md +4 -0
- package/vendor/runtime/dist/executor/claudeAgent.d.ts +2 -0
- package/vendor/runtime/dist/executor/claudeAgent.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/claudeAgent.js +113 -8
- package/vendor/runtime/dist/executor/claudeCode.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/claudeCode.js +8 -4
- package/vendor/runtime/dist/executor/codex.d.ts +2 -0
- package/vendor/runtime/dist/executor/codex.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codex.js +213 -11
- package/vendor/runtime/dist/executor/codexProtocol/PlanType.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/PlanType.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/PlanType.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CreditsSnapshot.d.ts +6 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CreditsSnapshot.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CreditsSnapshot.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/GetAccountRateLimitsResponse.d.ts +26 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/GetAccountRateLimitsResponse.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/GetAccountRateLimitsResponse.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitReachedType.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitReachedType.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitReachedType.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCredit.d.ts +27 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCredit.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCredit.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCreditStatus.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCreditStatus.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCreditStatus.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCreditsSummary.d.ts +13 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCreditsSummary.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCreditsSummary.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetType.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetType.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetType.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitSnapshot.d.ts +20 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitSnapshot.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitSnapshot.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitWindow.d.ts +6 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitWindow.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitWindow.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewDelivery.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewDelivery.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewDelivery.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewStartParams.d.ts +12 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewStartParams.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewStartParams.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewTarget.d.ts +17 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewTarget.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewTarget.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillDependencies.d.ts +5 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillDependencies.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillDependencies.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillErrorInfo.d.ts +5 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillErrorInfo.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillErrorInfo.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillInterface.d.ts +18 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillInterface.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillInterface.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillMetadata.d.ts +22 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillMetadata.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillMetadata.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillScope.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillScope.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillScope.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillToolDependency.d.ts +9 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillToolDependency.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillToolDependency.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillsListEntry.d.ts +8 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillsListEntry.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillsListEntry.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillsListResponse.d.ts +5 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillsListResponse.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillsListResponse.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SpendControlLimitSnapshot.d.ts +7 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SpendControlLimitSnapshot.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SpendControlLimitSnapshot.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSetNameParams.d.ts +5 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSetNameParams.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSetNameParams.js +2 -0
- package/vendor/runtime/dist/executor/health.d.ts +1 -0
- package/vendor/runtime/dist/executor/health.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/health.js +3 -0
- package/vendor/runtime/dist/executor/liveTurns.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/liveTurns.js +3 -0
- package/vendor/runtime/dist/executor/providerRouter.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/providerRouter.js +2 -1
- package/vendor/runtime/dist/executor/types.d.ts +8 -0
- package/vendor/runtime/dist/executor/types.d.ts.map +1 -1
- package/vendor/runtime/dist/harness/index.d.ts +1 -0
- package/vendor/runtime/dist/harness/index.d.ts.map +1 -1
- package/vendor/runtime/dist/harness/index.js +35 -1
- package/vendor/runtime/dist/harness/types.d.ts +4 -1
- package/vendor/runtime/dist/harness/types.d.ts.map +1 -1
- package/vendor/runtime/dist/index.d.ts +2 -1
- package/vendor/runtime/dist/index.d.ts.map +1 -1
- package/vendor/runtime/dist/index.js +2 -0
- package/vendor/runtime/dist/journal/context.d.ts +18 -0
- package/vendor/runtime/dist/journal/context.d.ts.map +1 -1
- package/vendor/runtime/dist/journal/context.js +19 -5
- package/vendor/runtime/dist/prompts/briefing.d.ts +4 -7
- package/vendor/runtime/dist/prompts/briefing.d.ts.map +1 -1
- package/vendor/runtime/dist/prompts/briefing.js +61 -12
- package/vendor/runtime/dist/prompts/cardStatement.d.ts +7 -0
- package/vendor/runtime/dist/prompts/cardStatement.d.ts.map +1 -0
- package/vendor/runtime/dist/prompts/cardStatement.js +52 -0
- package/vendor/runtime/dist/prompts/chat.d.ts +1 -0
- package/vendor/runtime/dist/prompts/chat.d.ts.map +1 -1
- package/vendor/runtime/dist/prompts/chat.js +15 -1
- package/vendor/runtime/dist/prompts/projectCapture.d.ts +7 -0
- package/vendor/runtime/dist/prompts/projectCapture.d.ts.map +1 -0
- package/vendor/runtime/dist/prompts/projectCapture.js +31 -0
- package/vendor/runtime/src/executor/claudeAgent.ts +133 -7
- package/vendor/runtime/src/executor/claudeCode.ts +6 -4
- package/vendor/runtime/src/executor/codex.ts +280 -20
- package/vendor/runtime/src/executor/codexProtocol/PlanType.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/CreditsSnapshot.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/GetAccountRateLimitsResponse.ts +25 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitReachedType.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitResetCredit.ts +27 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitResetCreditStatus.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitResetCreditsSummary.ts +14 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitResetType.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitSnapshot.ts +14 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitWindow.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/ReviewDelivery.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/ReviewStartParams.ts +12 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/ReviewTarget.ts +9 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/SkillDependencies.ts +6 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/SkillErrorInfo.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/SkillInterface.ts +14 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/SkillMetadata.ts +17 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/SkillScope.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/SkillToolDependency.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/SkillsListEntry.ts +7 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/SkillsListResponse.ts +6 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/SpendControlLimitSnapshot.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/ThreadSetNameParams.ts +5 -0
- package/vendor/runtime/src/executor/health.ts +3 -0
- package/vendor/runtime/src/executor/liveTurns.ts +3 -0
- package/vendor/runtime/src/executor/providerRouter.ts +2 -1
- package/vendor/runtime/src/executor/types.ts +8 -0
- package/vendor/runtime/src/harness/index.ts +40 -6
- package/vendor/runtime/src/harness/types.ts +4 -1
- package/vendor/runtime/src/index.ts +4 -1
- package/vendor/runtime/src/journal/context.ts +40 -7
- package/vendor/runtime/src/prompts/briefing.ts +62 -17
- package/vendor/runtime/src/prompts/cardStatement.ts +64 -0
- package/vendor/runtime/src/prompts/chat.ts +25 -3
- package/vendor/runtime/src/prompts/projectCapture.ts +51 -0
- package/vendor/shared/dist/agentCommands.d.ts +22 -0
- package/vendor/shared/dist/agentCommands.d.ts.map +1 -0
- package/vendor/shared/dist/agentCommands.js +11 -0
- package/vendor/shared/dist/automationTemplates.d.ts +37 -0
- package/vendor/shared/dist/automationTemplates.d.ts.map +1 -0
- package/vendor/shared/dist/automationTemplates.js +48 -0
- package/vendor/shared/dist/automations.d.ts +1052 -0
- package/vendor/shared/dist/automations.d.ts.map +1 -0
- package/vendor/shared/dist/automations.js +300 -0
- package/vendor/shared/dist/cardStatement.d.ts +28 -0
- package/vendor/shared/dist/cardStatement.d.ts.map +1 -0
- package/vendor/shared/dist/cardStatement.js +37 -0
- package/vendor/shared/dist/cardStudio.d.ts +756 -0
- package/vendor/shared/dist/cardStudio.d.ts.map +1 -0
- package/vendor/shared/dist/cardStudio.js +297 -0
- package/vendor/shared/dist/commandLocal.d.ts +218 -0
- package/vendor/shared/dist/commandLocal.d.ts.map +1 -0
- package/vendor/shared/dist/commandLocal.js +662 -0
- package/vendor/shared/dist/commandText.d.ts +12 -0
- package/vendor/shared/dist/commandText.d.ts.map +1 -0
- package/vendor/shared/dist/commandText.js +21 -0
- package/vendor/shared/dist/commands.d.ts +1516 -0
- package/vendor/shared/dist/commands.d.ts.map +1 -0
- package/vendor/shared/dist/commands.js +231 -0
- package/vendor/shared/dist/computer.d.ts +9 -9
- package/vendor/shared/dist/computer.d.ts.map +1 -1
- package/vendor/shared/dist/computer.js +11 -2
- package/vendor/shared/dist/constants.d.ts +3 -3
- package/vendor/shared/dist/constants.d.ts.map +1 -1
- package/vendor/shared/dist/constants.js +9 -2
- package/vendor/shared/dist/githubContributions.d.ts +93 -0
- package/vendor/shared/dist/githubContributions.d.ts.map +1 -0
- package/vendor/shared/dist/githubContributions.js +54 -0
- package/vendor/shared/dist/habitContributions.d.ts +26 -0
- package/vendor/shared/dist/habitContributions.d.ts.map +1 -0
- package/vendor/shared/dist/habitContributions.js +119 -0
- package/vendor/shared/dist/index.d.ts +26 -2
- package/vendor/shared/dist/index.d.ts.map +1 -1
- package/vendor/shared/dist/index.js +23 -2
- package/vendor/shared/dist/journal-migration.d.ts +29 -0
- package/vendor/shared/dist/journal-migration.d.ts.map +1 -0
- package/vendor/shared/dist/journal-migration.js +73 -0
- package/vendor/shared/dist/journal-vault.d.ts +414 -0
- package/vendor/shared/dist/journal-vault.d.ts.map +1 -0
- package/vendor/shared/dist/journal-vault.js +972 -0
- package/vendor/shared/dist/projectCapture.d.ts +73 -0
- package/vendor/shared/dist/projectCapture.d.ts.map +1 -0
- package/vendor/shared/dist/projectCapture.js +66 -0
- package/vendor/shared/dist/quickAdd.d.ts +90 -0
- package/vendor/shared/dist/quickAdd.d.ts.map +1 -0
- package/vendor/shared/dist/quickAdd.js +260 -0
- package/vendor/shared/dist/recurrence.d.ts +44 -0
- package/vendor/shared/dist/recurrence.d.ts.map +1 -0
- package/vendor/shared/dist/recurrence.js +37 -0
- package/vendor/shared/dist/reminderWords.d.ts +11 -0
- package/vendor/shared/dist/reminderWords.d.ts.map +1 -0
- package/vendor/shared/dist/reminderWords.js +63 -0
- package/vendor/shared/dist/schemas/comment.d.ts +13 -1
- package/vendor/shared/dist/schemas/comment.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/comment.js +5 -0
- package/vendor/shared/dist/schemas/conversation.d.ts +3 -3
- package/vendor/shared/dist/schemas/harness.d.ts +922 -59
- package/vendor/shared/dist/schemas/harness.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/harness.js +122 -3
- package/vendor/shared/dist/schemas/journal.d.ts +10 -0
- package/vendor/shared/dist/schemas/journal.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/journal.js +10 -2
- package/vendor/shared/dist/schemas/notification.d.ts +1 -1
- package/vendor/shared/dist/schemas/organization.d.ts +3 -2
- package/vendor/shared/dist/schemas/organization.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/organization.js +3 -2
- package/vendor/shared/dist/schemas/proposal.d.ts +7 -3
- package/vendor/shared/dist/schemas/proposal.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/proposal.js +2 -1
- package/vendor/shared/dist/schemas/request.d.ts +44 -4
- package/vendor/shared/dist/schemas/request.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/task.d.ts +83 -8
- package/vendor/shared/dist/schemas/task.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/task.js +20 -2
- package/vendor/shared/dist/schemas/timeSession.d.ts +2 -2
- package/vendor/shared/dist/smartCapture.d.ts +60 -0
- package/vendor/shared/dist/smartCapture.d.ts.map +1 -0
- package/vendor/shared/dist/smartCapture.js +56 -0
- package/vendor/shared/dist/speech.d.ts +39 -0
- package/vendor/shared/dist/speech.d.ts.map +1 -0
- package/vendor/shared/dist/speech.js +36 -0
- package/vendor/shared/dist/spokenNames.d.ts +25 -0
- package/vendor/shared/dist/spokenNames.d.ts.map +1 -0
- package/vendor/shared/dist/spokenNames.js +120 -0
- package/vendor/shared/dist/taskActivity.d.ts +76 -0
- package/vendor/shared/dist/taskActivity.d.ts.map +1 -0
- package/vendor/shared/dist/taskActivity.js +27 -0
- package/vendor/shared/dist/vault-search.d.ts +50 -0
- package/vendor/shared/dist/vault-search.d.ts.map +1 -0
- package/vendor/shared/dist/vault-search.js +177 -0
- package/vendor/shared/dist/voiceCapture.d.ts +32 -0
- package/vendor/shared/dist/voiceCapture.d.ts.map +1 -0
- package/vendor/shared/dist/voiceCapture.js +29 -0
- package/vendor/shared/package.json +4 -0
- package/vendor/shared/src/agentCommands.ts +35 -0
- package/vendor/shared/src/automationTemplates.ts +54 -0
- package/vendor/shared/src/automations.ts +329 -0
- package/vendor/shared/src/cardStatement.ts +49 -0
- package/vendor/shared/src/cardStudio.ts +340 -0
- package/vendor/shared/src/commandLocal.ts +738 -0
- package/vendor/shared/src/commandText.ts +25 -0
- package/vendor/shared/src/commands.ts +253 -0
- package/vendor/shared/src/computer.ts +23 -6
- package/vendor/shared/src/constants.ts +9 -2
- package/vendor/shared/src/githubContributions.ts +70 -0
- package/vendor/shared/src/habitContributions.ts +144 -0
- package/vendor/shared/src/index.ts +42 -1
- package/vendor/shared/src/journal-migration.ts +130 -0
- package/vendor/shared/src/journal-vault.ts +1240 -0
- package/vendor/shared/src/projectCapture.ts +86 -0
- package/vendor/shared/src/quickAdd.ts +310 -0
- package/vendor/shared/src/recurrence.ts +37 -0
- package/vendor/shared/src/reminderWords.ts +54 -0
- package/vendor/shared/src/schemas/comment.ts +5 -0
- package/vendor/shared/src/schemas/harness.ts +144 -7
- package/vendor/shared/src/schemas/journal.ts +15 -6
- package/vendor/shared/src/schemas/organization.ts +3 -2
- package/vendor/shared/src/schemas/proposal.ts +6 -1
- package/vendor/shared/src/schemas/task.ts +20 -2
- package/vendor/shared/src/smartCapture.ts +67 -0
- package/vendor/shared/src/speech.ts +44 -0
- package/vendor/shared/src/spokenNames.ts +128 -0
- package/vendor/shared/src/taskActivity.ts +34 -0
- package/vendor/shared/src/vault-search.ts +243 -0
- package/vendor/shared/src/voiceCapture.ts +34 -0
|
@@ -0,0 +1,738 @@
|
|
|
1
|
+
import { COMMAND_DESTINATIONS, DESTINATION_PARENTS, ORGANIZATION_DESTINATIONS, type CommandDestination, type CommandExecutableStep } from './commands.js';
|
|
2
|
+
import { normalizeInstruction, proposeClauses } from './commandText.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Act instructions the phone carries out by itself, with no network: going to a screen, or opening
|
|
6
|
+
* a project or milestone by its name. Sending "open projects" to the API and Jev took three and a
|
|
7
|
+
* half seconds to do what a tap does at once.
|
|
8
|
+
*
|
|
9
|
+
* Deliberately narrow. The whole instruction has to be a known place or exactly one name the phone
|
|
10
|
+
* already has, after the usual "take me to my ... please". Anything else, and anything that could
|
|
11
|
+
* mean two things (a project called "Notes"), returns null and goes to Jev as before.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** A project or milestone the phone already has loaded. */
|
|
15
|
+
export interface LocalCommandTarget {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
}
|
|
19
|
+
export interface LocalCommandContext {
|
|
20
|
+
projects: readonly LocalCommandTarget[];
|
|
21
|
+
milestones: readonly LocalCommandTarget[];
|
|
22
|
+
/** For "Neucleosoft procurement": places each organization has its own of. */
|
|
23
|
+
organizations?: readonly LocalCommandTarget[];
|
|
24
|
+
/** What the screen shows, top to bottom: what "the first task" means. */
|
|
25
|
+
onScreen?: readonly OnScreenItem[];
|
|
26
|
+
}
|
|
27
|
+
export interface OnScreenItem {
|
|
28
|
+
kind: 'task' | 'project' | 'milestone';
|
|
29
|
+
id: string;
|
|
30
|
+
title: string;
|
|
31
|
+
}
|
|
32
|
+
export type LocalCommandStep = Extract<CommandExecutableStep, { kind: 'navigate' | 'open' | 'back' }>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* What people call each screen besides its label. Matched after `key()`, so no "my", "the" or
|
|
36
|
+
* "screen", and in either number (see `otherNumber`), so "chat" also covers "chats".
|
|
37
|
+
*/
|
|
38
|
+
const ALIASES: Record<CommandDestination, readonly string[]> = {
|
|
39
|
+
dash: ['home', 'go home', 'main'],
|
|
40
|
+
search: ['task list', 'search'],
|
|
41
|
+
today: ['todays tasks', 'tasks for today', 'whats due today'],
|
|
42
|
+
inbox: [],
|
|
43
|
+
projects: ['project list', 'list of projects'],
|
|
44
|
+
milestones: ['milestone list', 'list of milestones'],
|
|
45
|
+
notes: [],
|
|
46
|
+
journal: ['voice journal'],
|
|
47
|
+
habits: [],
|
|
48
|
+
chat: ['chat', 'chats', 'direct messages', 'dms'],
|
|
49
|
+
code: ['coding'],
|
|
50
|
+
team: ['organizations', 'orgs'],
|
|
51
|
+
standups: ['stand up', 'daily standup', 'daily stand up', 'scrum'],
|
|
52
|
+
procurement: ['purchase requests', 'purchase orders', 'purchases', 'procurement requests'],
|
|
53
|
+
notifications: ['alerts'],
|
|
54
|
+
settings: ['preferences'],
|
|
55
|
+
voice: ['voice and speech', 'speech'],
|
|
56
|
+
computer: ['my computer', 'my mac'],
|
|
57
|
+
computer_settings: ['mac settings', 'lucid settings'],
|
|
58
|
+
automations: ['schedules', 'scheduled jobs'],
|
|
59
|
+
trash: ['deleted tasks', 'bin'],
|
|
60
|
+
apple_watch: ['watch'],
|
|
61
|
+
tab_bar: ['tab bar settings', 'bottom bar'],
|
|
62
|
+
organizations: ['manage organizations'],
|
|
63
|
+
api_key: ['api keys'],
|
|
64
|
+
profile: ['my profile'],
|
|
65
|
+
edit_profile: ['profile settings'],
|
|
66
|
+
connections: ['people', 'contacts'],
|
|
67
|
+
review: ['review queue', 'proposals', 'suggestions'],
|
|
68
|
+
weekly_review: ['weekly review', 'week review', 'my week'],
|
|
69
|
+
focus: ['focus mode', 'focus timer'],
|
|
70
|
+
card_studio: ['cards', 'add cards', 'dashboard cards'],
|
|
71
|
+
ask_lucid: ['ask lucid', 'lucid chat'],
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/** Lowercase, accents and emoji gone, punctuation as spaces: "Finance 💵" is "finance". */
|
|
75
|
+
function fold(s: string): string {
|
|
76
|
+
return s
|
|
77
|
+
.normalize('NFKD')
|
|
78
|
+
.replace(/[̀-ͯ]/g, '')
|
|
79
|
+
.toLowerCase()
|
|
80
|
+
.replace(/&/g, ' and ')
|
|
81
|
+
.replace(/['’]/g, '')
|
|
82
|
+
.replace(/[^\p{L}\p{N}]+/gu, ' ')
|
|
83
|
+
.trim();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const DETERMINERS = /^(?:(?:all|of|my|the|our|your) )+/;
|
|
87
|
+
const SCREEN_WORDS = / (?:page|screen|tab|view|section)$/;
|
|
88
|
+
/** Applied to what was said and to every name alike, so "The Plan" still matches "open the plan". */
|
|
89
|
+
const key = (folded: string) => folded.replace(DETERMINERS, '').replace(SCREEN_WORDS, '').trim();
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The same words with the last one in the other number: "milestone" and "milestones", "category"
|
|
93
|
+
* and "categories", "launch" and "launches". People say either, and speech recognition drops a plural "s" often enough
|
|
94
|
+
* that "open tasks" reached the phone as "open task".
|
|
95
|
+
*/
|
|
96
|
+
function otherNumber(words: string): string {
|
|
97
|
+
const i = words.lastIndexOf(' ') + 1;
|
|
98
|
+
const head = words.slice(0, i);
|
|
99
|
+
const last = words.slice(i);
|
|
100
|
+
if (/[^aeiou]ies$/.test(last)) return head + last.slice(0, -3) + 'y';
|
|
101
|
+
if (/(?:ch|sh|x|z|ss)es$/.test(last)) return head + last.slice(0, -2);
|
|
102
|
+
if (/[^s]s$/.test(last)) return head + last.slice(0, -1);
|
|
103
|
+
if (/[^aeiou]y$/.test(last)) return head + last.slice(0, -1) + 'ies';
|
|
104
|
+
if (/(?:ch|sh|x|z|s)$/.test(last)) return head + last + 'es';
|
|
105
|
+
return head + last + 's';
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const LEAD = new RegExp(
|
|
109
|
+
'^(?:(?:i (?:want|wanna|need|would like|d like) to |lets |let me )?' +
|
|
110
|
+
'(?:(?:go|take me|bring me|get me|navigate|jump|switch|head|move)(?: back)?(?: over)? (?:to|into)|back to|' +
|
|
111
|
+
'open(?: up)?|show(?: me)?|bring up|pull up|view|display|see))(?: |$)'
|
|
112
|
+
);
|
|
113
|
+
const TRAILING = /(?: (?:please|now|right now|for me|thanks|thank you))+$/;
|
|
114
|
+
const KIND_HINT = /^(?:(project|milestone) (.+)|(.+) (project|milestone))$/;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Every way of naming a place. The first place to claim a phrase keeps it, most specific first: a
|
|
118
|
+
* top-level place's own words, then a nested place's own words, then the pairs a nested place makes
|
|
119
|
+
* with its parent's words ("voice settings", "settings voice"). So "organizations" stays the Teams
|
|
120
|
+
* tab while "organization settings" is the Settings screen, and a new nested place is reachable by
|
|
121
|
+
* those pairs without writing any of them.
|
|
122
|
+
*/
|
|
123
|
+
const DESTINATIONS = new Map<string, CommandDestination>();
|
|
124
|
+
{
|
|
125
|
+
const words = (d: (typeof COMMAND_DESTINATIONS)[number]) => [d.label, ...ALIASES[d.key]];
|
|
126
|
+
const claim = (phrase: string, place: CommandDestination) => {
|
|
127
|
+
const k = key(fold(phrase));
|
|
128
|
+
if (!DESTINATIONS.has(k)) DESTINATIONS.set(k, place);
|
|
129
|
+
};
|
|
130
|
+
const nested = COMMAND_DESTINATIONS.filter((d) => DESTINATION_PARENTS[d.key]);
|
|
131
|
+
for (const d of COMMAND_DESTINATIONS) if (!DESTINATION_PARENTS[d.key]) for (const w of words(d)) claim(w, d.key);
|
|
132
|
+
for (const d of nested) for (const w of words(d)) claim(w, d.key);
|
|
133
|
+
for (const d of nested) {
|
|
134
|
+
const parent = COMMAND_DESTINATIONS.find((p) => p.key === DESTINATION_PARENTS[d.key])!;
|
|
135
|
+
// The other number too, as the first word of a pair: "organization settings".
|
|
136
|
+
for (const w of words(d).flatMap((w) => [w, otherNumber(key(fold(w)))])) {
|
|
137
|
+
for (const under of words(parent)) {
|
|
138
|
+
claim(`${w} ${under}`, d.key);
|
|
139
|
+
claim(`${under} ${w}`, d.key);
|
|
140
|
+
claim(`${w} in ${under}`, d.key);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function named(context: LocalCommandContext, name: string, only?: 'project' | 'milestone'): LocalCommandStep[] {
|
|
147
|
+
const pick = (list: readonly LocalCommandTarget[], kind: 'project' | 'milestone') =>
|
|
148
|
+
only && only !== kind ? [] : list
|
|
149
|
+
.filter((t) => key(fold(t.name)) === name)
|
|
150
|
+
.map((t): LocalCommandStep => ({ kind: 'open', item: { kind, id: t.id, title: t.name } }));
|
|
151
|
+
return [...pick(context.projects, 'project'), ...pick(context.milestones, 'milestone')];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const BACK = /^(?:(?:please )?(?:go|take me|bring me|get me|navigate|head) )?back(?: (?:to )?(?:the )?(?:previous|last) (?:screen|page|one))?$|^(?:go |take me )?(?:to )?(?:the )?previous (?:screen|page)$/;
|
|
155
|
+
|
|
156
|
+
const ORDINAL_WORDS: Record<string, number> = {
|
|
157
|
+
first: 1, second: 2, third: 3, fourth: 4, fifth: 5, sixth: 6, seventh: 7, eighth: 8, ninth: 9, tenth: 10,
|
|
158
|
+
one: 1, two: 2, three: 3, four: 4, five: 5, six: 6, seven: 7, eight: 8, nine: 9, ten: 10,
|
|
159
|
+
};
|
|
160
|
+
// "mile" is "milestone" with its end dropped by speech recognition: "Open second Mile" went to Jev
|
|
161
|
+
// and took 4.1 s on 2026-09-26, the slowest turn of that window.
|
|
162
|
+
const ORDINAL = /^(?:the )?(first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|last|\d{1,2}(?:st|nd|rd|th))(?: (task|project|milestone|mile|one|item|result)s?)?$/;
|
|
163
|
+
const NUMBERED = /^(task|project|milestone|mile|item|result|number)(?: number)? (\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten)$/;
|
|
164
|
+
/** "in it", "here", "on the screen": where the list is, which is the screen either way. */
|
|
165
|
+
const ON_SCREEN = / (?:in it|on it|here|in here|on (?:the|this|my) (?:screen|page|list)|in (?:the|this) (?:list|project|milestone))$/;
|
|
166
|
+
|
|
167
|
+
export interface OrdinalReference {
|
|
168
|
+
/** 1-based, or the last one. */
|
|
169
|
+
position: number | 'last';
|
|
170
|
+
kind?: OnScreenItem['kind'];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* "the first task", "the second one", "task number 3", "the last project": a position in a list,
|
|
175
|
+
* with or without a verb in front. Null when the words are anything more than that.
|
|
176
|
+
*/
|
|
177
|
+
export function ordinalReference(text: string): OrdinalReference | null {
|
|
178
|
+
let said = fold(normalizeInstruction(text));
|
|
179
|
+
const lead = LEAD.exec(said);
|
|
180
|
+
if (lead) said = said.slice(lead[0].length);
|
|
181
|
+
said = said.replace(TRAILING, '').replace(ON_SCREEN, '').trim();
|
|
182
|
+
const kindOf = (word?: string) =>
|
|
183
|
+
word === 'mile' ? 'milestone' : word === 'task' || word === 'project' || word === 'milestone' ? word : undefined;
|
|
184
|
+
const ordinal = ORDINAL.exec(said);
|
|
185
|
+
if (ordinal) {
|
|
186
|
+
const [, which, kind] = ordinal;
|
|
187
|
+
const position = which === 'last' ? 'last' : (ORDINAL_WORDS[which!] ?? parseInt(which!, 10));
|
|
188
|
+
return { position, ...(kindOf(kind) ? { kind: kindOf(kind) } : {}) };
|
|
189
|
+
}
|
|
190
|
+
const numbered = NUMBERED.exec(said);
|
|
191
|
+
if (numbered) {
|
|
192
|
+
const [, kind, n] = numbered;
|
|
193
|
+
return { position: ORDINAL_WORDS[n!] ?? parseInt(n!, 10), ...(kindOf(kind) ? { kind: kindOf(kind) } : {}) };
|
|
194
|
+
}
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** The item a reference points at among `items`, counting only the kind it names. */
|
|
199
|
+
export function pickByOrdinal<T>(items: readonly T[], ref: OrdinalReference): T | null {
|
|
200
|
+
const pool = ref.kind ? items.filter((item) => (item as { kind?: unknown }).kind === ref.kind) : items;
|
|
201
|
+
const index = ref.position === 'last' ? pool.length - 1 : ref.position - 1;
|
|
202
|
+
return index >= 0 && index < pool.length ? pool[index]! : null;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** One clause, carried out on the phone if it is certainly a place or a name. Null means ask Jev. */
|
|
206
|
+
export function resolveLocalCommand(text: string, context: LocalCommandContext): LocalCommandStep | null {
|
|
207
|
+
let said = fold(normalizeInstruction(text));
|
|
208
|
+
if (BACK.test(said.replace(TRAILING, '').trim())) return { kind: 'back' };
|
|
209
|
+
const lead = LEAD.exec(said);
|
|
210
|
+
if (lead) said = said.slice(lead[0].length);
|
|
211
|
+
said = said.replace(TRAILING, '').trim();
|
|
212
|
+
const target = key(said);
|
|
213
|
+
if (!target) return null;
|
|
214
|
+
|
|
215
|
+
// "the Lucidity project": look among projects only, then fall back to the words as a whole name
|
|
216
|
+
// for a project that is actually called "Side Project".
|
|
217
|
+
const hint = KIND_HINT.exec(said);
|
|
218
|
+
if (hint) {
|
|
219
|
+
const kind = (hint[1] ?? hint[4]) as 'project' | 'milestone';
|
|
220
|
+
const name = key(hint[2] ?? hint[3]!);
|
|
221
|
+
for (const form of [name, otherNumber(name)]) {
|
|
222
|
+
const found = named(context, form, kind);
|
|
223
|
+
if (found.length === 1) return found[0]!;
|
|
224
|
+
if (found.length > 1) return null;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// "Neucleosoft procurement", "standups for Neucleosoft": a place of one named organization.
|
|
229
|
+
const inOrganization = organizationPlace(target, context.organizations ?? []);
|
|
230
|
+
if (inOrganization) return inOrganization;
|
|
231
|
+
|
|
232
|
+
// Exactly what was said first, then the other number, so a project called "Notes" is still
|
|
233
|
+
// told apart from the Notes screen before "note" is ever read as either.
|
|
234
|
+
for (const form of [target, otherNumber(target)]) {
|
|
235
|
+
const items = named(context, form);
|
|
236
|
+
const destination = DESTINATIONS.get(form);
|
|
237
|
+
if (destination) return items.length ? null : { kind: 'navigate', destination };
|
|
238
|
+
// A bare name could be the start of anything ("Lucidity" as a task title); it needs "open".
|
|
239
|
+
if (items.length) return (lead || hint) && items.length === 1 ? items[0]! : null;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// "open the first task in it": the screen's own list. Needs the verb, like a bare name does.
|
|
243
|
+
const ref = lead ? ordinalReference(text) : null;
|
|
244
|
+
const item = ref && context.onScreen ? pickByOrdinal(context.onScreen, ref) : null;
|
|
245
|
+
if (item) return { kind: 'open', item: { kind: item.kind, id: item.id, title: item.title } };
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* The first step of an instruction when the phone can carry it out itself, and the clauses left
|
|
251
|
+
* after it, which each get the same chance in turn. `single` is a clause already split off.
|
|
252
|
+
*/
|
|
253
|
+
export function planLocally(
|
|
254
|
+
text: string,
|
|
255
|
+
context: LocalCommandContext,
|
|
256
|
+
single = false,
|
|
257
|
+
): { step: LocalCommandStep; rest: string[] } | null {
|
|
258
|
+
const clauses = single ? [] : proposeClauses(text);
|
|
259
|
+
const step = resolveLocalCommand(clauses[0] ?? text, context);
|
|
260
|
+
return step ? { step, rest: clauses.slice(1) } : null;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const placeOf = (words: string) => {
|
|
264
|
+
const place = DESTINATIONS.get(words) ?? DESTINATIONS.get(otherNumber(words));
|
|
265
|
+
return place && ORGANIZATION_DESTINATIONS.includes(place) ? place : undefined;
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
function organizationPlace(target: string, organizations: readonly LocalCommandTarget[]): LocalCommandStep | null {
|
|
269
|
+
for (const org of organizations) {
|
|
270
|
+
const name = key(fold(org.name));
|
|
271
|
+
if (!name) continue;
|
|
272
|
+
for (const prefix of [`${name} `, `${name}s `]) {
|
|
273
|
+
const place = target.startsWith(prefix) ? placeOf(target.slice(prefix.length)) : undefined;
|
|
274
|
+
if (place) return { kind: 'navigate', destination: place, organizationId: org.id };
|
|
275
|
+
}
|
|
276
|
+
const at = new RegExp(` (?:for|in|of|at|from) ${name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}$`).exec(target);
|
|
277
|
+
const place = at ? placeOf(target.slice(0, at.index)) : undefined;
|
|
278
|
+
if (place) return { kind: 'navigate', destination: place, organizationId: org.id };
|
|
279
|
+
}
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Which organization "open procurement" means: the one named, else the one on screen (a Team page,
|
|
285
|
+
* an organization's profile), else the one selected on the Team tab, else the only one there is.
|
|
286
|
+
* With several and nothing to go on, the caller asks.
|
|
287
|
+
*/
|
|
288
|
+
export function organizationFor(
|
|
289
|
+
step: LocalCommandStep | CommandExecutableStep,
|
|
290
|
+
where: { onScreen: string | null; selected: string | null; organizations: readonly LocalCommandTarget[] },
|
|
291
|
+
): { step: CommandExecutableStep; organization: LocalCommandTarget } | { choose: LocalCommandTarget[] } | null {
|
|
292
|
+
if (step.kind !== 'navigate' || !ORGANIZATION_DESTINATIONS.includes(step.destination)) return null;
|
|
293
|
+
const known = (id: string | null | undefined) => (id ? where.organizations.find((o) => o.id === id) : undefined);
|
|
294
|
+
const organization = known(step.organizationId) ?? known(where.onScreen) ?? known(where.selected)
|
|
295
|
+
?? (where.organizations.length === 1 ? where.organizations[0] : undefined);
|
|
296
|
+
if (organization) return { step: { ...step, organizationId: organization.id }, organization };
|
|
297
|
+
return { choose: [...where.organizations] };
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/** The reply for a step done on the phone, worded as the API words it. */
|
|
301
|
+
export function describeLocalStep(step: LocalCommandStep): string {
|
|
302
|
+
if (step.kind === 'back') return 'Going back.';
|
|
303
|
+
if (step.kind === 'open') return `Opening “${step.item.title}”.`;
|
|
304
|
+
return `Opening ${COMMAND_DESTINATIONS.find((d) => d.key === step.destination)?.label ?? step.destination}.`;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Instructions that are certainly a new task: "add", "create", "capture", "remind me to", "new
|
|
309
|
+
* task". Stricter than the words Jev is offered, since here nothing checks the guess: a bare
|
|
310
|
+
* "new" would turn "new york trip" into "york trip".
|
|
311
|
+
*/
|
|
312
|
+
/** How a task is named once it is announced: "called X", "and call it X", ", name it X". */
|
|
313
|
+
const NAMING = "(?:,? (?:and )?(?:call it|calling it|called|name it|named|title it|titled|saying|that says|say|to))?";
|
|
314
|
+
/** "here", "in this project": the place on screen, which is where the task goes anyway. */
|
|
315
|
+
const HERE = "(?:here|in here|over here|(?:to|in|into|on|under|for) (?:this|the current) (?:project|list|page|screen|milestone))";
|
|
316
|
+
const ADD_LEAD = new RegExp(
|
|
317
|
+
'^(?:(?:add|create|capture|jot down|note down)(?: (?:a|an))?(?: new)?(?: (?:task|to-?do|item|reminder))?' + `(?: ${HERE})?` + NAMING +
|
|
318
|
+
'|new (?:task|to-?do|reminder)' + NAMING +
|
|
319
|
+
'|(?:make|set) (?:a|an) (?:task|to-?do|reminder)' + NAMING +
|
|
320
|
+
'|remind me to|remember to)(?=\\s|$)\\s*[:,\\-–]?\\s*',
|
|
321
|
+
'i',
|
|
322
|
+
);
|
|
323
|
+
/**
|
|
324
|
+
* What people say before "add" or "create" without changing what they ask: "let's create a new
|
|
325
|
+
* task", "I want you to add ...". Only stripped in front of an add, so "I need to call mom" is
|
|
326
|
+
* still left to Jev.
|
|
327
|
+
*/
|
|
328
|
+
const ADD_OPENER = /^(?:(?:so|ok|okay|alright|right)\s+)?(?:let'?s|let us|go ahead and|i(?:'d| would)? like(?: you)? to|i want(?: you)? to|i need you to|i wanna|please)\s+/i;
|
|
329
|
+
const NOT_A_TASK = /^(?:add|create|make|new|set up)\s+(?:(?:a|an)\s+)?(?:new\s+)?(?:project|milestone|note|habit|journal|comment|sub[\s-]?tasks?|description|details)\b/i;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* The words of a new task when the instruction is certainly one ("add buy milk tomorrow" gives
|
|
333
|
+
* "buy milk tomorrow"), an empty string when it names no task at all ("add a new task"), and null
|
|
334
|
+
* when it isn't an add.
|
|
335
|
+
*/
|
|
336
|
+
export function addedTaskWords(text: string): string | null {
|
|
337
|
+
const said = normalizeInstruction(text).replace(/\s+/g, ' ').replace(ADD_OPENER, '');
|
|
338
|
+
if (NOT_A_TASK.test(said)) return null;
|
|
339
|
+
const lead = ADD_LEAD.exec(said);
|
|
340
|
+
if (!lead) return null;
|
|
341
|
+
const words = said.slice(lead[0].length).replace(new RegExp(`[\\s,]*\\b${HERE}$`, 'i'), '').trim();
|
|
342
|
+
// "add a few tasks to this project" asks for several, not one called "Few tasks to ...".
|
|
343
|
+
return SEVERAL.test(words) ? null : words;
|
|
344
|
+
}
|
|
345
|
+
const SEVERAL = /^(?:a\s+)?(?:few|some|several|multiple|couple(?:\s+of)?|more|other|\d+|two|three|four|five|ten)\s+(?:new\s+|more\s+)?(?:tasks|items|to-?dos|things|reminders)\b|^(?:tasks|items|to-?dos)\b/i;
|
|
346
|
+
|
|
347
|
+
const PLACE_WORDS = new Set(['to', 'in', 'into', 'on', 'under', 'for']);
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* A project named at the end of a new task, the way it is said rather than typed: "buy milk to the
|
|
351
|
+
* shopping list", "fix login in Lucidity", "call the bank for the finance project". Returns the
|
|
352
|
+
* words without it. Null when no project matches, or when two do.
|
|
353
|
+
*/
|
|
354
|
+
export function spokenProject(
|
|
355
|
+
words: string,
|
|
356
|
+
projects: readonly LocalCommandTarget[],
|
|
357
|
+
): { projectId: string; projectName: string; words: string } | null {
|
|
358
|
+
const parts = words.trim().split(/\s+/);
|
|
359
|
+
const names = projects.map((p) => ({ p, name: key(fold(p.name)) }));
|
|
360
|
+
// Longest first, so "to the shopping list" wins over "list".
|
|
361
|
+
for (let i = 1; i < parts.length - 1; i++) {
|
|
362
|
+
if (!PLACE_WORDS.has(fold(parts[i]!))) continue;
|
|
363
|
+
const said = key(fold(parts.slice(i + 1).join(' ')));
|
|
364
|
+
const forms = new Set([said, otherNumber(said)]);
|
|
365
|
+
const bare = said.replace(/ (?:project|list)$/, '');
|
|
366
|
+
if (bare !== said) [bare, otherNumber(bare)].forEach((f) => forms.add(f));
|
|
367
|
+
const found = [...new Map(names.filter((n) => forms.has(n.name)).map((n) => [n.p.id, n.p])).values()];
|
|
368
|
+
if (found.length > 1) return null;
|
|
369
|
+
if (found.length === 1) return { projectId: found[0]!.id, projectName: found[0]!.name, words: parts.slice(0, i).join(' ') };
|
|
370
|
+
}
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/** Said on its own, these close Act. Anything longer ("stop the timer task") is an instruction. */
|
|
375
|
+
const DISMISSALS = new Set([
|
|
376
|
+
'done', 'im done', 'i am done', 'all done', 'thats all', 'thats it', 'thats everything',
|
|
377
|
+
'stop', 'stop listening', 'close', 'close it', 'cancel', 'never mind', 'nevermind', 'forget it',
|
|
378
|
+
'bye', 'bye bye', 'goodbye', 'good bye', 'see you', 'thanks', 'thank you', 'no thanks',
|
|
379
|
+
'no thank you', 'nothing', 'nothing else', 'exit', 'dismiss', 'go away', 'quit',
|
|
380
|
+
]);
|
|
381
|
+
const DISMISSAL_OPENER = /^(?:ok|okay|alright|all right|great|cool|perfect|fine|no|nope)\s+/;
|
|
382
|
+
const DISMISSAL_CLOSER = /\s+(?:thanks|thank you|bye|for now|jev|lucid)$/;
|
|
383
|
+
|
|
384
|
+
/** Whether what was said means "I'm finished with Act" rather than an instruction. */
|
|
385
|
+
export function isDismissal(text: string): boolean {
|
|
386
|
+
const said = fold(text);
|
|
387
|
+
if (DISMISSALS.has(said)) return true;
|
|
388
|
+
const core = said.replace(DISMISSAL_OPENER, '').replace(DISMISSAL_CLOSER, '').replace(DISMISSAL_CLOSER, '').trim();
|
|
389
|
+
return DISMISSALS.has(core);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/** A change to the task that's open, said without naming it: "make it due Friday", "mark it done". */
|
|
393
|
+
export type TaskEdit =
|
|
394
|
+
| { kind: 'due'; words: string }
|
|
395
|
+
| { kind: 'clearDue' }
|
|
396
|
+
| { kind: 'move'; projectId: string | null; projectName: string | null }
|
|
397
|
+
| { kind: 'status'; status: 'complete' | 'reopen' | 'start' | 'blocked' | 'deferred' | 'pending' }
|
|
398
|
+
| { kind: 'priority'; priority: number }
|
|
399
|
+
| { kind: 'delete' }
|
|
400
|
+
/** Out of the task sheet. */
|
|
401
|
+
| { kind: 'close' }
|
|
402
|
+
/** Empty text: nothing was said after "add a comment", so ask what it should say. */
|
|
403
|
+
| { kind: 'comment'; text: string }
|
|
404
|
+
/** No titles: ask for one. */
|
|
405
|
+
| { kind: 'subtasks'; titles: string[] }
|
|
406
|
+
/** Empty title: ask for one. */
|
|
407
|
+
| { kind: 'rename'; title: string }
|
|
408
|
+
/**
|
|
409
|
+
* `add` appends to a description that exists and writes one that doesn't; `set` replaces it;
|
|
410
|
+
* `append` always adds to the end. Empty text: ask for it.
|
|
411
|
+
*/
|
|
412
|
+
| { kind: 'describe'; text: string; mode: 'add' | 'set' | 'append' }
|
|
413
|
+
| { kind: 'clearDescription' }
|
|
414
|
+
/** Null stops it repeating. */
|
|
415
|
+
| { kind: 'repeat'; frequency: 'daily' | 'weekly' | 'monthly' | 'yearly' | null }
|
|
416
|
+
/** When, as words for the caller to read; empty asks. */
|
|
417
|
+
| { kind: 'remind'; words: string }
|
|
418
|
+
| { kind: 'clearReminder' }
|
|
419
|
+
/** A milestone by the words it was called, looked up in the task's own project. Null takes it out of one. */
|
|
420
|
+
| { kind: 'milestone'; name: string | null }
|
|
421
|
+
/**
|
|
422
|
+
* Read out the description, the comments, or the task itself. `position` is a task counted on
|
|
423
|
+
* the screen ("the description of the first task"), for when none is open.
|
|
424
|
+
*/
|
|
425
|
+
| { kind: 'read'; what: 'description' | 'comments' | 'all'; position?: number | 'last' };
|
|
426
|
+
|
|
427
|
+
const THIS = '(?:this task|this one|the task|it|this|that)';
|
|
428
|
+
const CLEAR_DUE = new RegExp(`^(?:remove|clear|delete|drop|take off|get rid of)(?: ${THIS}s?)? (?:the |its )?(?:due date|deadline|date)$`);
|
|
429
|
+
const DELETE_THIS = new RegExp(`^(?:delete|remove|trash|bin|get rid of) ${THIS}$`);
|
|
430
|
+
// "Close the task" said over an open sheet means the sheet: it completed a task on 2026-09-26.
|
|
431
|
+
const CLOSE_THIS = new RegExp(`^(?:close|dismiss|hide|shut) (?:${THIS}|the sheet|this sheet|the details)$`);
|
|
432
|
+
const COMPLETE_THIS = new RegExp(`^(?:(?:complete|finish|tick off) ${THIS}|tick ${THIS} off|(?:mark|set) ${THIS} (?:as )?(?:done|complete|completed|finished)|(?:its|this is|thats) done)$`);
|
|
433
|
+
const REOPEN_THIS = new RegExp(`^(?:reopen(?: ${THIS})?|(?:mark|set) ${THIS} (?:as )?(?:not done|incomplete|open|undone))$`);
|
|
434
|
+
const START_THIS = new RegExp(`^(?:(?:start|begin)(?: working on)? ${THIS}|(?:mark|set) ${THIS} (?:as )?(?:in progress|started))$`);
|
|
435
|
+
const BLOCKED_THIS = new RegExp(`^(?:(?:mark|set|flag) ${THIS} (?:as )?blocked|block ${THIS}|(?:${THIS} is|its) blocked)$`);
|
|
436
|
+
const DEFERRED_THIS = new RegExp(`^(?:defer ${THIS}|(?:mark|set) ${THIS} (?:as )?deferred|put ${THIS} on hold|(?:${THIS} is|its) (?:deferred|on hold))$`);
|
|
437
|
+
const PENDING_THIS = new RegExp(`^(?:unblock ${THIS}|(?:mark|set) ${THIS} (?:as )?(?:pending|not started|to do|todo)|(?:stop working on|pause) ${THIS}|take ${THIS} off hold)$`);
|
|
438
|
+
|
|
439
|
+
const FREQUENCY = '(daily|weekly|monthly|yearly|annually|(?:every|each) (?:day|week|month|year))';
|
|
440
|
+
const REPEAT_THIS = [
|
|
441
|
+
new RegExp(`^(?:(?:make|set|have) ${THIS} (?:to )?|${THIS} )?(?:repeat|recur|repeats|recurs|repeating|recurring)(?: ${THIS})? ${FREQUENCY}$`),
|
|
442
|
+
new RegExp(`^(?:make|set) ${THIS} (?:to )?(?:a )?(?:recurring |repeating )?${FREQUENCY}(?: task| thing)?$`),
|
|
443
|
+
new RegExp(`^set (?:the )?(?:repeat|recurrence) to ${FREQUENCY}$`),
|
|
444
|
+
];
|
|
445
|
+
const STOP_REPEAT = new RegExp(`^(?:(?:stop|dont|do not) (?:make ${THIS} )?(?:repeat|recur)(?:ing)?(?: ${THIS})?|(?:remove|clear|turn off|cancel) (?:the )?(?:repeat|recurrence|recurring)|(?:make|set) ${THIS} (?:not repeat|non recurring|a one off(?: task)?|one off)|no repeat|set (?:the )?repeat to never)$`);
|
|
446
|
+
function frequencyOf(words: string): 'daily' | 'weekly' | 'monthly' | 'yearly' {
|
|
447
|
+
if (/day|daily/.test(words)) return 'daily';
|
|
448
|
+
if (/week/.test(words)) return 'weekly';
|
|
449
|
+
if (/month/.test(words)) return 'monthly';
|
|
450
|
+
return 'yearly';
|
|
451
|
+
}
|
|
452
|
+
/** "remind me to ..." is a new task, so a reminder needs anything but "to" after it. */
|
|
453
|
+
const REMIND_THIS = new RegExp(`^(?:remind me(?: about ${THIS})?|(?:set|add|put|create)(?: a| an)? reminder(?: (?:on|for) ${THIS})?|(?:change|move|update|set) (?:the |my )?reminder(?: (?:on|for) ${THIS})?(?: to)?)(?: (?!to )(.+))?$`);
|
|
454
|
+
const CLEAR_REMINDER = new RegExp(`^(?:(?:remove|clear|delete|cancel|turn off) (?:the |my |its )?reminder(?: (?:on|for|from) ${THIS})?|(?:dont|do not) remind me(?: about ${THIS})?|no reminder)$`);
|
|
455
|
+
const MILESTONE_THIS = [
|
|
456
|
+
new RegExp(`^(?:move|add|put|file|assign|attach)(?: ${THIS})? (?:to|into|in|under|on) (?:the |my )?(?:milestone (.+)|(.+) milestone)$`),
|
|
457
|
+
new RegExp(`^(?:set|change) (?:the |its )?milestone(?: of ${THIS})? to (?:the )?(.+?)(?: milestone)?$`),
|
|
458
|
+
];
|
|
459
|
+
const CLEAR_MILESTONE = new RegExp(`^(?:(?:remove|take) ${THIS} (?:out of|from|off) (?:the |its )?milestone|(?:remove|clear) (?:the |its )?milestone|no milestone)$`);
|
|
460
|
+
|
|
461
|
+
const ON_SCREEN_TASK = '(?:the |this )?(first|second|third|fourth|fifth|last) (?:task|one)';
|
|
462
|
+
const READ_FIELD = new RegExp(`^(?:read|tell me|what is|whats|what are|show me|say)(?: out)?(?: me)?(?: the| its)? (description|details|comments?)(?: (?:of|on|for|in) (?:${THIS}|${ON_SCREEN_TASK}))?(?: out)?$`);
|
|
463
|
+
const READ_TASK = new RegExp(`^(?:read(?: out)?(?: me)? (?:${THIS}|${ON_SCREEN_TASK})(?: out| to me)?|what does ${THIS} say|whats (?:in |on )?${THIS})$`);
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* The one item in `list` called `words` as people say names: without "the" or emoji, in either
|
|
467
|
+
* number. Null when none is, or when two are.
|
|
468
|
+
*/
|
|
469
|
+
export function namedTarget<T extends LocalCommandTarget>(list: readonly T[], words: string): T | null {
|
|
470
|
+
const said = key(fold(words));
|
|
471
|
+
const forms = new Set([said, otherNumber(said)]);
|
|
472
|
+
const found = list.filter((t) => forms.has(key(fold(t.name))));
|
|
473
|
+
return found.length === 1 ? found[0]! : null;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Priority by name, on the task sheet's slider: 100 to 1000 in steps of 100, lower first. Nothing
|
|
478
|
+
* else in the app names these levels; the numbers are where each word lands on that slider.
|
|
479
|
+
*/
|
|
480
|
+
const PRIORITY_LEVELS: Record<string, number> = {
|
|
481
|
+
urgent: 100, critical: 100, highest: 100, top: 100, 'very high': 100,
|
|
482
|
+
high: 200, important: 200,
|
|
483
|
+
medium: 500, normal: 500, default: 500, average: 500,
|
|
484
|
+
low: 800,
|
|
485
|
+
lowest: 1000, 'very low': 1000,
|
|
486
|
+
};
|
|
487
|
+
const LEVEL_WORDS = Object.keys(PRIORITY_LEVELS).sort((a, b) => b.length - a.length).join('|');
|
|
488
|
+
const LEVEL_NUMBER = '\\d{1,4}|one|two|three|four|five|six|seven|eight|nine|ten';
|
|
489
|
+
const PRIORITY_THIS = [
|
|
490
|
+
// A number needs the word "priority" next to it: "make it 5" could be a time.
|
|
491
|
+
new RegExp(`^(?:set|change|make|update|put|give ${THIS})(?: the| its| a)? priority(?: of ${THIS})?(?: to| at| as| of)? (${LEVEL_WORDS}|${LEVEL_NUMBER})$`),
|
|
492
|
+
new RegExp(`^(?:make|mark|set|flag|put|give) ${THIS} (?:to |as |at )?(?:a |an )?(?:(${LEVEL_WORDS})(?: priority)?|(${LEVEL_NUMBER}) priority|priority (${LEVEL_WORDS}|${LEVEL_NUMBER}))$`),
|
|
493
|
+
new RegExp(`^(?:${THIS} is|its) (?:a |an )?(?:(${LEVEL_WORDS})(?: priority)?|(${LEVEL_NUMBER}) priority)$`),
|
|
494
|
+
new RegExp(`^(?:a |an )?(?:(${LEVEL_WORDS}|${LEVEL_NUMBER}) priority|priority (${LEVEL_WORDS}|${LEVEL_NUMBER}))$`),
|
|
495
|
+
];
|
|
496
|
+
/** 1 to 10 are steps of the slider ("priority 3" is 300); larger numbers are the value itself. */
|
|
497
|
+
function priorityOf(said: string): number | null {
|
|
498
|
+
const level = PRIORITY_LEVELS[said];
|
|
499
|
+
if (level) return level;
|
|
500
|
+
const n = ORDINAL_WORDS[said] ?? parseInt(said, 10);
|
|
501
|
+
if (!Number.isFinite(n) || n < 1) return null;
|
|
502
|
+
const value = n <= 10 ? n * 100 : n;
|
|
503
|
+
return value <= 1000 ? value : null;
|
|
504
|
+
}
|
|
505
|
+
const MOVE_THIS = new RegExp(`^(?:move|add|put|file|send|shift)(?: ${THIS})? (?:to|into|in|under) (?:the |my )?(?:projects? )?(.+)$`);
|
|
506
|
+
const DUE_THIS = new RegExp(
|
|
507
|
+
`^(?:(?:add|set|put|give ${THIS}|change|update|make)(?: a| the| its)? (?:due date|deadline|due|date)|(?:make|set) ${THIS} due|(?:its|this is|make it|it is) due|due|reschedule(?: ${THIS})?|postpone(?: ${THIS})?|(?:move|push|shift) ${THIS}(?: back)?)(?: (?:to|for|as|on|by|till|until|at))?(?: (.+))?$`,
|
|
508
|
+
);
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Where the words of a comment or subtask begin, read from what was said rather than folded, so
|
|
512
|
+
* they keep their capitals and punctuation: "saying", "that", a colon, or nothing at all.
|
|
513
|
+
*/
|
|
514
|
+
const ON_THIS = String.raw`(?:\s+(?:on|to|for|under|in)\s+${THIS})?`;
|
|
515
|
+
// A bare space before the words, unless what follows names another task ("add a comment to car
|
|
516
|
+
// wash saying ..."): that one is Jev's to find, not the open task's.
|
|
517
|
+
const SAYING = String.raw`(?:\s*[:,\-–]\s*|\s+(?:saying|that says|which says|says|reading|that reads|that)\b[\s:,]*|\s+(?!(?:to|on|for|in|under|about|of)\s)|$)`;
|
|
518
|
+
const COMMENT = new RegExp(String.raw`^(?:(?:add|leave|post|write|put|make|drop)\s+(?:a\s+|an\s+)?(?:new\s+|quick\s+)?comment|comment)${ON_THIS}${SAYING}(.*)$`, 'i');
|
|
519
|
+
const DESCRIPTION = String.raw`(?:the\s+|its\s+)?(?:description|details)`;
|
|
520
|
+
const DESCRIBE_APPEND = new RegExp(String.raw`^(?:add|append|put|write)\s+(?:this\s+)?(?:to|onto|in|into)\s+${DESCRIPTION}${ON_THIS}${SAYING}(.*)$`, 'i');
|
|
521
|
+
const DESCRIBE_APPEND_AFTER = new RegExp(String.raw`^(?:add|append)\s+(.+?)\s+to\s+${DESCRIPTION}$`, 'i');
|
|
522
|
+
const DESCRIBE_ADD = new RegExp(String.raw`^(?:(?:add|write|put|give\s+it)\s+(?:a\s+|an\s+|the\s+|some\s+)?(?:new\s+)?(?:description|details)|description)${ON_THIS}${SAYING}(.*)$`, 'i');
|
|
523
|
+
const DESCRIBE_SET = new RegExp(String.raw`^(?:set|change|update|replace|edit|rewrite)\s+${DESCRIPTION}(?:\s+(?:of|on|for)\s+${THIS})?(?:\s+(?:to|as|with))?${SAYING}(.*)$`, 'i');
|
|
524
|
+
const CLEAR_DESCRIPTION = new RegExp(String.raw`^(?:remove|clear|delete|erase|wipe)\s+${DESCRIPTION}(?:\s+(?:of|on|from)\s+${THIS})?$`, 'i');
|
|
525
|
+
const RENAME = new RegExp(String.raw`^(?:rename(?:\s+${THIS})?(?:\s+(?:to|as))?|(?:change|update|set|edit|fix)\s+(?:the\s+|its\s+)?(?:title|name)(?:\s+(?:of\s+)?${THIS})?(?:\s+(?:to|as))?|(?:call|retitle|title)\s+(?:this\s+task|this|it)(?:\s+(?:to|as))?)${SAYING}(.*)$`, 'i');
|
|
526
|
+
const RENAME_OWN = new RegExp(String.raw`^rename\s+(?:${THIS}\b|to\b|as\b)`, 'i');
|
|
527
|
+
const SUBTASK = new RegExp(String.raw`^(?:(?:add|create|make|new|put)\s+)?(?:a\s+|an\s+|some\s+)?(?:new\s+)?sub[\s-]?task(s)?${ON_THIS}(?:\s*[:,\-–]\s*|\s+(?:called|named|saying|titled|to)\b[\s:,]*|\s+|$)(.*)$`, 'i');
|
|
528
|
+
|
|
529
|
+
/** Said words as a title or a comment: trimmed, with a capital first letter. */
|
|
530
|
+
function spoken(words: string): string {
|
|
531
|
+
const t = words.replace(/^[\s,;:\-–]+|[\s,;:\-–]+$/g, '');
|
|
532
|
+
return t ? t[0]!.toUpperCase() + t.slice(1) : '';
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* What an instruction changes about the task that's open, when it doesn't name another one. Null
|
|
537
|
+
* when it isn't one of these, or names a project that doesn't exist; that goes to Jev as before.
|
|
538
|
+
* Dates come back as words for the caller to read (`due` with empty words: "add a due date").
|
|
539
|
+
*/
|
|
540
|
+
export function taskEdit(
|
|
541
|
+
text: string,
|
|
542
|
+
projects: readonly LocalCommandTarget[],
|
|
543
|
+
milestones: readonly LocalCommandTarget[] = [],
|
|
544
|
+
): TaskEdit | null {
|
|
545
|
+
const raw = normalizeInstruction(text);
|
|
546
|
+
const comment = COMMENT.exec(raw);
|
|
547
|
+
if (comment) return { kind: 'comment', text: spoken(comment[1] ?? '') };
|
|
548
|
+
const subtask = SUBTASK.exec(raw);
|
|
549
|
+
if (subtask) {
|
|
550
|
+
// "add subtasks pack, book flights and call the hotel" is three; a single subtask keeps its "and".
|
|
551
|
+
const words = subtask[2] ?? '';
|
|
552
|
+
// "add a subtask to car wash: buy soap" names the parent; "to call the bank" is the subtask.
|
|
553
|
+
if (/sub[\s-]?tasks?\s+to\s/i.test(raw) && /:|\bsaying\b/i.test(words)) return null;
|
|
554
|
+
const titles = (subtask[1] ? words.split(/\s*,\s*(?:and\s+)?|\s+and\s+/i) : [words]).map(spoken).filter(Boolean);
|
|
555
|
+
return { kind: 'subtasks', titles: titles.slice(0, 10) };
|
|
556
|
+
}
|
|
557
|
+
if (CLEAR_DESCRIPTION.test(raw)) return { kind: 'clearDescription' };
|
|
558
|
+
const append = DESCRIBE_APPEND.exec(raw) ?? DESCRIBE_APPEND_AFTER.exec(raw);
|
|
559
|
+
if (append) return { kind: 'describe', text: spoken(append[1] ?? ''), mode: 'append' };
|
|
560
|
+
const set = DESCRIBE_SET.exec(raw);
|
|
561
|
+
if (set) return { kind: 'describe', text: spoken(set[1] ?? ''), mode: 'set' };
|
|
562
|
+
const add = DESCRIBE_ADD.exec(raw);
|
|
563
|
+
if (add) return { kind: 'describe', text: spoken(add[1] ?? ''), mode: 'add' };
|
|
564
|
+
const rename = RENAME.exec(raw);
|
|
565
|
+
if (rename) {
|
|
566
|
+
// "rename car wash to wash the car" names the task being renamed: Jev's to find.
|
|
567
|
+
const another = /^rename\s/i.test(raw) && !RENAME_OWN.test(raw) && /\s(?:to|as)\s/i.test(rename[1] ?? '');
|
|
568
|
+
return another ? null : { kind: 'rename', title: spoken(rename[1] ?? '') };
|
|
569
|
+
}
|
|
570
|
+
const said = fold(raw).replace(TRAILING, '').trim();
|
|
571
|
+
if (CLEAR_DUE.test(said)) return { kind: 'clearDue' };
|
|
572
|
+
if (DELETE_THIS.test(said)) return { kind: 'delete' };
|
|
573
|
+
if (CLOSE_THIS.test(said)) return { kind: 'close' };
|
|
574
|
+
if (COMPLETE_THIS.test(said)) return { kind: 'status', status: 'complete' };
|
|
575
|
+
if (REOPEN_THIS.test(said)) return { kind: 'status', status: 'reopen' };
|
|
576
|
+
if (START_THIS.test(said)) return { kind: 'status', status: 'start' };
|
|
577
|
+
if (BLOCKED_THIS.test(said)) return { kind: 'status', status: 'blocked' };
|
|
578
|
+
if (DEFERRED_THIS.test(said)) return { kind: 'status', status: 'deferred' };
|
|
579
|
+
if (PENDING_THIS.test(said)) return { kind: 'status', status: 'pending' };
|
|
580
|
+
for (const form of PRIORITY_THIS) {
|
|
581
|
+
const m = form.exec(said);
|
|
582
|
+
const words = m?.slice(1).find(Boolean);
|
|
583
|
+
const priority = words ? priorityOf(words) : null;
|
|
584
|
+
if (priority) return { kind: 'priority', priority };
|
|
585
|
+
}
|
|
586
|
+
if (STOP_REPEAT.test(said)) return { kind: 'repeat', frequency: null };
|
|
587
|
+
for (const form of REPEAT_THIS) {
|
|
588
|
+
const m = form.exec(said);
|
|
589
|
+
if (m) return { kind: 'repeat', frequency: frequencyOf(m[1]!) };
|
|
590
|
+
}
|
|
591
|
+
if (CLEAR_REMINDER.test(said)) return { kind: 'clearReminder' };
|
|
592
|
+
const remind = REMIND_THIS.exec(said);
|
|
593
|
+
if (remind) return { kind: 'remind', words: (remind[1] ?? '').trim() };
|
|
594
|
+
const readField = READ_FIELD.exec(said);
|
|
595
|
+
const readTask = readField ? null : READ_TASK.exec(said);
|
|
596
|
+
if (readField || readTask) {
|
|
597
|
+
const what = readField ? (readField[1]!.startsWith('comment') ? 'comments' : 'description') : 'all';
|
|
598
|
+
const which = readField ? readField[2] : readTask![1];
|
|
599
|
+
const position = which === 'last' ? 'last' : which ? ORDINAL_WORDS[which] : undefined;
|
|
600
|
+
return { kind: 'read', what, ...(position ? { position } : {}) };
|
|
601
|
+
}
|
|
602
|
+
if (CLEAR_MILESTONE.test(said)) return { kind: 'milestone', name: null };
|
|
603
|
+
for (const form of MILESTONE_THIS) {
|
|
604
|
+
const m = form.exec(said);
|
|
605
|
+
const name = m?.slice(1).find(Boolean);
|
|
606
|
+
if (name) return { kind: 'milestone', name };
|
|
607
|
+
}
|
|
608
|
+
// "move it to Lucidity" is a project, "move it to tomorrow" a date: a project name decides.
|
|
609
|
+
const move = MOVE_THIS.exec(said);
|
|
610
|
+
if (move) {
|
|
611
|
+
// The whole name first ("Shopping List"), then without a trailing "project" or "list".
|
|
612
|
+
const whole = key(move[1]!);
|
|
613
|
+
const bare = whole.replace(/ (?:project|list)$/, '');
|
|
614
|
+
if (bare === 'inbox') return { kind: 'move', projectId: null, projectName: null };
|
|
615
|
+
const forms = [whole, otherNumber(whole), bare, otherNumber(bare)];
|
|
616
|
+
const found = forms.flatMap((form) => projects.filter((p) => key(fold(p.name)) === form));
|
|
617
|
+
const unique = [...new Map(found.map((p) => [p.id, p])).values()];
|
|
618
|
+
if (unique.length === 1) return { kind: 'move', projectId: unique[0]!.id, projectName: unique[0]!.name };
|
|
619
|
+
// Not a project, but a milestone: "move it to Q3 launch".
|
|
620
|
+
if (!unique.length && namedTarget(milestones, move[1]!)) return { kind: 'milestone', name: move[1]! };
|
|
621
|
+
// "the moon project" is a project that doesn't exist, not a date.
|
|
622
|
+
if (unique.length > 1 || bare !== whole) return null;
|
|
623
|
+
}
|
|
624
|
+
const due = DUE_THIS.exec(said);
|
|
625
|
+
if (due) return { kind: 'due', words: (due[1] ?? '').trim() };
|
|
626
|
+
return null;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* A change to a whole project: by name, or "this project" on the project's own screen. `project`
|
|
631
|
+
* is null when none is called that (with `name` as said), or when no name was given (empty `name`).
|
|
632
|
+
*/
|
|
633
|
+
export type ProjectEdit =
|
|
634
|
+
| { kind: 'deleteProject' | 'archiveProject'; project: LocalCommandTarget | null; name: string }
|
|
635
|
+
| { kind: 'renameProject'; project: LocalCommandTarget | null; name: string; to: string };
|
|
636
|
+
|
|
637
|
+
// Groups: 1 "this"/"a" before "project", 2 a name after it, 3 a name before it.
|
|
638
|
+
const PROJECT_REF = String.raw`(?:(?:the|my)\s+)?(?:(this|that|a|the|my)\s+project|project\s+(.+?)|(.+?)\s+project)`;
|
|
639
|
+
const DELETE_PROJECT = new RegExp(String.raw`^(?:delete|remove|trash|get rid of)\s+${PROJECT_REF}$`, 'i');
|
|
640
|
+
const ARCHIVE_PROJECT = new RegExp(String.raw`^archive\s+(?:${PROJECT_REF}|(?:(?:the|my)\s+)?(.+))$`, 'i');
|
|
641
|
+
const RENAME_PROJECT = new RegExp(String.raw`^rename\s+${PROJECT_REF}\s+(?:to|as)\s+(.+)$`, 'i');
|
|
642
|
+
|
|
643
|
+
export function projectEdit(
|
|
644
|
+
text: string,
|
|
645
|
+
projects: readonly LocalCommandTarget[],
|
|
646
|
+
here: LocalCommandTarget | null = null,
|
|
647
|
+
): ProjectEdit | null {
|
|
648
|
+
const raw = normalizeInstruction(text);
|
|
649
|
+
const which = (named: string | undefined, pronoun: string | undefined): { project: LocalCommandTarget | null; name: string } => {
|
|
650
|
+
// "archive it" on a project's screen: the same as "this project".
|
|
651
|
+
if (named && /^(?:it|this|that)$/i.test(named.trim())) return which(undefined, 'this');
|
|
652
|
+
if (named) return { project: namedTarget(projects, named), name: named.trim() };
|
|
653
|
+
// "this project" is the one on screen; "a project" names none.
|
|
654
|
+
if (pronoun && /^(?:this|that)$/i.test(pronoun) && here) return { project: here, name: here.name };
|
|
655
|
+
return { project: null, name: '' };
|
|
656
|
+
};
|
|
657
|
+
const rename = RENAME_PROJECT.exec(raw);
|
|
658
|
+
if (rename) return { kind: 'renameProject', ...which(rename[2] ?? rename[3], rename[1]), to: spoken(rename[4]!) };
|
|
659
|
+
const del = DELETE_PROJECT.exec(raw);
|
|
660
|
+
if (del) return { kind: 'deleteProject', ...which(del[2] ?? del[3], del[1]) };
|
|
661
|
+
const archive = ARCHIVE_PROJECT.exec(raw);
|
|
662
|
+
if (archive) return { kind: 'archiveProject', ...which(archive[2] ?? archive[3] ?? archive[4], archive[1]) };
|
|
663
|
+
return null;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
const YES = new Set(['yes', 'yeah', 'yep', 'yup', 'sure', 'ok', 'okay', 'confirm', 'do it', 'go ahead', 'yes please', 'please do']);
|
|
667
|
+
/**
|
|
668
|
+
* Which offered choice a spoken answer picks, besides by position: "yes" takes the first, and a
|
|
669
|
+
* word that starts exactly one choice's label ("archive", "delete it") takes that one.
|
|
670
|
+
*/
|
|
671
|
+
export function choiceBySaying(labels: readonly string[], text: string): number | null {
|
|
672
|
+
const said = fold(normalizeInstruction(text)).replace(TRAILING, '').trim();
|
|
673
|
+
if (YES.has(said)) return labels.length ? 0 : null;
|
|
674
|
+
const verb = said.split(' ')[0];
|
|
675
|
+
if (!verb || said.split(' ').length > 3) return null;
|
|
676
|
+
const hits = labels.map((l, i) => (fold(l).split(' ')[0] === verb ? i : -1)).filter((i) => i >= 0);
|
|
677
|
+
return hits.length === 1 ? hits[0]! : null;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/** A question Fast mode asked about a task ("What should the comment say?"), answered next. */
|
|
681
|
+
export type TaskEditQuestion = 'due' | 'comment' | 'subtask' | 'title' | 'description' | 'newDescription' | 'reminder';
|
|
682
|
+
|
|
683
|
+
/** The next words, read as the answer to `question` rather than as an instruction. */
|
|
684
|
+
export function answerTo(question: TaskEditQuestion, text: string): TaskEdit {
|
|
685
|
+
const words = normalizeInstruction(text);
|
|
686
|
+
switch (question) {
|
|
687
|
+
case 'due': return { kind: 'due', words };
|
|
688
|
+
case 'comment': return { kind: 'comment', text: spoken(words) };
|
|
689
|
+
case 'subtask': return { kind: 'subtasks', titles: [spoken(words)] };
|
|
690
|
+
case 'title': return { kind: 'rename', title: spoken(words) };
|
|
691
|
+
case 'description': return { kind: 'describe', text: spoken(words), mode: 'add' };
|
|
692
|
+
case 'newDescription': return { kind: 'describe', text: spoken(words), mode: 'set' };
|
|
693
|
+
case 'reminder': return { kind: 'remind', words };
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Edits Jev can't carry out, so only the phone can, and only to a task it knows. With no task
|
|
699
|
+
* open they must not go to Jev, which reads "add a comment ..." as a new task called "Comment ...".
|
|
700
|
+
*/
|
|
701
|
+
export function phoneOnlyEdit(edit: TaskEdit): boolean {
|
|
702
|
+
if (edit.kind === 'status') return ['blocked', 'deferred', 'pending'].includes(edit.status);
|
|
703
|
+
return !['due', 'clearDue', 'move', 'delete'].includes(edit.kind);
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
/** A priority named anywhere in an instruction ("mark car wash as high priority"), for Jev's steps. */
|
|
707
|
+
export function priorityIn(text: string): number | null {
|
|
708
|
+
const said = fold(normalizeInstruction(text));
|
|
709
|
+
const m = new RegExp(`(?:^| )(?:priority (?:of |to |at |as )?(${LEVEL_WORDS}|${LEVEL_NUMBER})|(${LEVEL_WORDS}|${LEVEL_NUMBER}) priority|(urgent|critical|important))(?: |$)`).exec(said);
|
|
710
|
+
const words = m?.slice(1).find(Boolean);
|
|
711
|
+
return words ? priorityOf(words) : null;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* How often an instruction says a task repeats, from anywhere in it: null when it says to stop,
|
|
716
|
+
* undefined when it says neither.
|
|
717
|
+
*/
|
|
718
|
+
export function frequencyIn(text: string): 'daily' | 'weekly' | 'monthly' | 'yearly' | null | undefined {
|
|
719
|
+
const said = fold(normalizeInstruction(text));
|
|
720
|
+
if (/\b(?:stop|dont|do not|no longer|never|not)\b.*\b(?:repeat|recur)|\b(?:remove|clear|cancel|turn off)\b.*\b(?:repeat|recurrence)/.test(said)) return null;
|
|
721
|
+
const m = new RegExp(`(?:^| )${FREQUENCY}(?: |$)`).exec(said);
|
|
722
|
+
return m ? frequencyOf(m[1]!) : undefined;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* Words that start an edit of an existing task ("add a comment ...", "add subtasks ..."), which
|
|
727
|
+
* must never become a new task whoever read them.
|
|
728
|
+
*/
|
|
729
|
+
export function isTaskEditPhrase(text: string): boolean {
|
|
730
|
+
const said = normalizeInstruction(text).replace(ADD_OPENER, '');
|
|
731
|
+
return /^(?:(?:add|leave|post|write|put|create|make|new)\s+(?:a\s+|an\s+|some\s+)?(?:new\s+)?(?:comment|sub[\s-]?tasks?|description|details)|comment)\b/i.test(said);
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/** How a priority reads in a reply: "high priority", or "priority 300" between the named levels. */
|
|
735
|
+
export function priorityLabel(priority: number): string {
|
|
736
|
+
const names: Record<number, string> = { 100: 'top priority', 200: 'high priority', 500: 'normal priority', 800: 'low priority', 1000: 'lowest priority' };
|
|
737
|
+
return names[priority] ?? `priority ${priority}`;
|
|
738
|
+
}
|