UNPKG

@swoft/gtd-domain

Version:

Getting Things Done (GTD) productivity system - consolidated domain implementation

901 lines (897 loc) 27.1 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/integration/contracts/index.ts var contracts_exports = {}; __export(contracts_exports, { GTDNavigationHintsBuilder: () => GTDNavigationHintsBuilder, GTD_DOMAIN_SEMANTICS: () => GTD_DOMAIN_SEMANTICS, GTD_ENTITY_RELATIONSHIPS: () => GTD_ENTITY_RELATIONSHIPS, GTD_PUBLISHED_LANGUAGE_VERSION: () => GTD_PUBLISHED_LANGUAGE_VERSION, GTD_WORKFLOWS: () => GTD_WORKFLOWS, InboxCaptureRequestSchema: () => InboxCaptureRequestSchema, InboxCaptureResultSchema: () => InboxCaptureResultSchema, InboxItemSummarySchema: () => InboxItemSummarySchema, InboxQueryCriteriaSchema: () => InboxQueryCriteriaSchema, createGTDNavigationBuilder: () => createGTDNavigationBuilder, createGTDSemanticHints: () => createGTDSemanticHints, gtdDomainApi: () => gtdDomainApi }); module.exports = __toCommonJS(contracts_exports); // src/integration/contracts/zodios-api.ts var import_core = require("@zodios/core"); var import_zod = require("zod"); var InboxCaptureRequestSchema = import_zod.z.object({ content: import_zod.z.string().describe("The content/description of the item to capture"), capturedBy: import_zod.z.string().describe("Who is capturing this item"), priority: import_zod.z.enum([ "low", "medium", "high", "urgent" ]).optional().describe("Optional priority level"), tags: import_zod.z.array(import_zod.z.string()).optional().describe("Optional tags for categorization"), source: import_zod.z.string().optional().describe("Source of the capture (for tracking)"), context: import_zod.z.object({ location: import_zod.z.string().optional(), project: import_zod.z.string().optional(), reference: import_zod.z.string().optional() }).optional().describe("Optional context information") }); var InboxItemSummarySchema = import_zod.z.object({ id: import_zod.z.string().describe("Unique identifier for the inbox item"), content: import_zod.z.string().describe("The original content/description of the item"), text: import_zod.z.string().describe("Backward compatibility field - same as content"), title: import_zod.z.string().describe("User-friendly title extracted from content"), status: import_zod.z.enum([ "unprocessed", "processed" ]).describe("Current processing status"), capturedAt: import_zod.z.string().describe("When the item was captured (ISO date)"), createdAt: import_zod.z.date().describe("Backward compatibility field - same as capturedAt"), capturedBy: import_zod.z.string().describe("Who captured this item (person ID)"), capturedByPerson: import_zod.z.object({ id: import_zod.z.string(), displayName: import_zod.z.string(), roleType: import_zod.z.enum([ "Human", "AiAgent" ]) }).nullable().describe("Enriched person information"), priority: import_zod.z.enum([ "low", "medium", "high", "urgent" ]).optional().describe("Priority level if assigned"), clarification: import_zod.z.string().optional().describe("Clarification text if item has been clarified"), description: import_zod.z.string().optional().describe("Backward compatibility field - same as clarification"), isActionable: import_zod.z.boolean().optional().describe("Whether the item has been determined to be actionable"), tags: import_zod.z.array(import_zod.z.string()).optional().describe("Tags associated with the item") }); var InboxCaptureResultSchema = import_zod.z.object({ success: import_zod.z.boolean().describe("Whether the capture was successful"), itemId: import_zod.z.string().describe("The ID of the created inbox item"), capturedAt: import_zod.z.string().describe("When the item was captured"), message: import_zod.z.string().describe("Human-readable message"), error: import_zod.z.string().optional().describe("Error details if capture failed") }); var InboxQueryCriteriaSchema = import_zod.z.object({ status: import_zod.z.enum([ "inbox", "clarified", "processed" ]).optional(), priority: import_zod.z.enum([ "low", "medium", "high", "urgent" ]).optional(), capturedBy: import_zod.z.string().optional(), tags: import_zod.z.array(import_zod.z.string()).optional(), limit: import_zod.z.number().optional(), offset: import_zod.z.number().optional() }); var gtdDomainApi = (0, import_core.makeApi)([ { method: "post", path: "/api/gtd/inbox", alias: "captureInboxItem", description: "Capture a new item into GTD inbox", parameters: [ { name: "body", type: "Body", schema: InboxCaptureRequestSchema } ], response: InboxCaptureResultSchema }, { method: "get", path: "/api/gtd/inbox", alias: "getInboxItems", description: "Get inbox items with optional filtering", parameters: [ { name: "query", type: "Query", schema: InboxQueryCriteriaSchema } ], response: import_zod.z.object({ items: import_zod.z.array(InboxItemSummarySchema), total: import_zod.z.number(), hasMore: import_zod.z.boolean() }) }, { method: "get", path: "/api/gtd/inbox/:id", alias: "getInboxItem", description: "Get a specific inbox item by ID", parameters: [ { name: "id", type: "Path", schema: import_zod.z.string() } ], response: InboxItemSummarySchema }, { method: "put", path: "/api/gtd/inbox/:id/clarify", alias: "clarifyInboxItem", description: "Clarify an inbox item (step 2 of GTD)", parameters: [ { name: "id", type: "Path", schema: import_zod.z.string() }, { name: "body", type: "Body", schema: import_zod.z.object({ isActionable: import_zod.z.boolean(), outcome: import_zod.z.string().optional(), nextAction: import_zod.z.string().optional(), context: import_zod.z.string().optional(), project: import_zod.z.string().optional(), clarifiedBy: import_zod.z.string() }) } ], response: InboxItemSummarySchema }, { method: "get", path: "/api/gtd/next-actions", alias: "getNextActions", description: "Get next actions organized by context", parameters: [ { name: "query", type: "Query", schema: import_zod.z.object({ context: import_zod.z.string().optional(), priority: import_zod.z.enum([ "low", "medium", "high", "urgent" ]).optional(), limit: import_zod.z.number().optional() }) } ], response: import_zod.z.object({ actions: import_zod.z.array(import_zod.z.object({ id: import_zod.z.string(), content: import_zod.z.string(), context: import_zod.z.string(), priority: import_zod.z.enum([ "low", "medium", "high", "urgent" ]), project: import_zod.z.string().optional(), dueDate: import_zod.z.string().optional() })), byContext: import_zod.z.record(import_zod.z.string(), import_zod.z.array(import_zod.z.any())) }) }, { method: "get", path: "/api/gtd/weekly-review", alias: "getWeeklyReview", description: "Get data for GTD weekly review", response: import_zod.z.object({ inbox: import_zod.z.array(InboxItemSummarySchema), overdueTasks: import_zod.z.array(import_zod.z.any()), waitingForTasks: import_zod.z.array(import_zod.z.any()), somedayTasks: import_zod.z.array(import_zod.z.any()), completedThisWeek: import_zod.z.array(import_zod.z.any()), stats: import_zod.z.object({ tasksCompleted: import_zod.z.number(), tasksCreated: import_zod.z.number(), averageCompletionTime: import_zod.z.number(), productivityScore: import_zod.z.number() }) }) } ]); // src/navigation/GTDSemanticNavigation.ts var import_navigation_utils = require("@swoft/navigation-utils"); var GTD_ENTITY_RELATIONSHIPS = [ // Project → Next Actions relationship { sourceEntityType: "project", targetEntityType: "next_action", relationshipType: "contains", description: "Projects contain one or more next actions to move toward completion", cardinality: "one-to-many", availableActions: [ { action: "view_next_actions", toolName: "gtd_actions_by_project", relevanceContext: "When viewing a project and need to see actionable next steps" }, { action: "create_next_action", toolName: "gtd_action_create", relevanceContext: "When a project needs additional next actions to move forward" }, { action: "review_project_progress", toolName: "gtd_project_review", relevanceContext: "During weekly review or when checking project momentum" } ] }, // Next Action → Context relationship { sourceEntityType: "next_action", targetEntityType: "context", relationshipType: "belongs_to", description: "Next actions are organized by the context where they can be completed", cardinality: "many-to-one", availableActions: [ { action: "view_context_actions", toolName: "gtd_actions_by_context", relevanceContext: "When in a specific context and ready to take action" }, { action: "change_context", toolName: "gtd_action_update", relevanceContext: "When circumstances change where an action can be completed" } ] }, // Inbox Item → Project/Action relationship { sourceEntityType: "inbox_item", targetEntityType: "project", relationshipType: "triggers", description: "Inbox items can trigger the creation of new projects during clarification", availableActions: [ { action: "convert_to_project", toolName: "gtd_project_create", relevanceContext: "When an inbox item requires multiple actions to complete" }, { action: "extract_next_action", toolName: "gtd_action_create", relevanceContext: "When an inbox item can be completed with a single action" }, { action: "defer_processing", toolName: "gtd_inbox_defer", relevanceContext: "When an inbox item needs more information before processing" } ] }, // Reference → Action/Project relationship { sourceEntityType: "reference", targetEntityType: "next_action", relationshipType: "enables", description: "Reference materials enable the completion of actions and projects", cardinality: "many-to-many", availableActions: [ { action: "attach_reference", toolName: "gtd_reference_attach", relevanceContext: "When an action needs supporting documentation" }, { action: "create_reference", toolName: "gtd_reference_create", relevanceContext: "When processing reveals need for reference material" } ] }, // Waiting For → Person relationship (cross-domain) { sourceEntityType: "waiting_for", targetEntityType: "person", relationshipType: "depends_on", description: "Waiting For items depend on specific people for completion", availableActions: [ { action: "find_responsible_person", toolName: "party_list_persons", relevanceContext: "When tracking who is responsible for a waiting item" }, { action: "follow_up_reminder", toolName: "gtd_waiting_follow_up", relevanceContext: "When a waiting item needs follow-up action" } ] } ]; var GTD_WORKFLOWS = [ // Core GTD Processing Workflow { workflowId: "gtd_capture_clarify_organize", name: "GTD Capture \u2192 Clarify \u2192 Organize Workflow", steps: [ { stepId: "capture", description: "Capture everything that crosses your mind into a trusted system", tools: [ "gtd_inbox_capture", "gtd_mind_sweep" ], completionCriteria: [ "All open loops captured", "Mind feels clear" ], nextSteps: [ "clarify" ] }, { stepId: "clarify", description: "Process inbox items: What is it? Is it actionable?", tools: [ "gtd_inbox_clarify", "gtd_process_inbox" ], completionCriteria: [ "Item nature understood", "Actionability determined" ], nextSteps: [ "organize_actionable", "organize_non_actionable" ] }, { stepId: "organize_actionable", description: "Organize actionable items into appropriate lists", tools: [ "gtd_project_create", "gtd_action_create", "gtd_calendar_add" ], completionCriteria: [ "Item in appropriate action list", "Context assigned" ], nextSteps: [ "reflect" ] }, { stepId: "organize_non_actionable", description: "File non-actionable items appropriately", tools: [ "gtd_reference_create", "gtd_someday_add", "gtd_trash" ], completionCriteria: [ "Item properly filed", "Reference accessible" ], nextSteps: [ "reflect" ] }, { stepId: "reflect", description: "Review system regularly to maintain trust and currency", tools: [ "gtd_weekly_review", "gtd_daily_review" ], completionCriteria: [ "System up to date", "Priorities clear" ], nextSteps: [ "engage" ] }, { stepId: "engage", description: "Choose actions confidently based on context, time, and energy", tools: [ "gtd_actions_by_context", "gtd_next_action_choose" ], completionCriteria: [ "Action completed", "Progress made" ], nextSteps: [ "capture" ] // Continuous cycle } ], triggers: [ { trigger: "new_inbox_item", context: { source: "any", urgency: "any" } }, { trigger: "mind_sweep_session", context: { scheduled: true, type: "weekly_review" } }, { trigger: "overwhelm_feeling", context: { stress_level: "high", clarity: "low" } } ], outcomes: [ "Clear mind with trusted system", "All commitments captured and organized", "Confident action choices", "Reduced stress and increased productivity" ] }, // Weekly Review Workflow { workflowId: "gtd_weekly_review", name: "GTD Weekly Review Process", steps: [ { stepId: "collect", description: "Gather loose papers, materials, and digital items", tools: [ "gtd_mind_sweep", "gtd_inbox_capture" ], completionCriteria: [ "All loose items captured", "Physical inbox empty" ], nextSteps: [ "process" ] }, { stepId: "process", description: "Process all captured items to zero", tools: [ "gtd_process_inbox", "gtd_inbox_clarify" ], completionCriteria: [ "Inbox at zero", "All items processed" ], nextSteps: [ "review" ] }, { stepId: "review", description: "Review action lists, calendar, and waiting fors", tools: [ "gtd_actions_review", "gtd_calendar_review", "gtd_waiting_review" ], completionCriteria: [ "Lists current", "Waiting items followed up" ], nextSteps: [ "update" ] }, { stepId: "update", description: "Update project lists and someday/maybe items", tools: [ "gtd_project_list", "gtd_someday_review" ], completionCriteria: [ "Projects current", "Someday items evaluated" ], nextSteps: [ "plan" ] }, { stepId: "plan", description: "Review bigger picture goals and plan next week", tools: [ "gtd_natural_planning", "gtd_goal_review" ], completionCriteria: [ "Week planned", "Priorities set" ], nextSteps: [ "engage" ] } ], triggers: [ { trigger: "weekly_scheduled_time", context: { day: "friday", time: "afternoon" } }, { trigger: "system_feels_out_of_control", context: { stress_level: "high", system_trust: "low" } } ], outcomes: [ "System completely current and trustworthy", "Clear priorities for upcoming week", "Reduced mental overhead", "Increased confidence in commitments" ] }, // Natural Planning Workflow { workflowId: "gtd_natural_planning", name: "GTD Natural Planning Model", steps: [ { stepId: "purpose", description: "Define why you are doing this project", tools: [ "gtd_natural_planning" ], completionCriteria: [ "Purpose clearly articulated", "Motivation understood" ], nextSteps: [ "vision" ] }, { stepId: "vision", description: "Envision successful outcome - what does done look like?", tools: [ "gtd_natural_planning" ], completionCriteria: [ "Success criteria defined", "Vision compelling" ], nextSteps: [ "brainstorm" ] }, { stepId: "brainstorm", description: "Generate ideas without judgment or organization", tools: [ "gtd_natural_planning", "gtd_mind_sweep" ], completionCriteria: [ "All ideas captured", "Creative thinking exhausted" ], nextSteps: [ "organize" ] }, { stepId: "organize", description: "Structure ideas into logical sequence and priorities", tools: [ "gtd_project_create", "gtd_action_create" ], completionCriteria: [ "Project structure clear", "Next actions defined" ], nextSteps: [ "next_actions" ] }, { stepId: "next_actions", description: "Identify immediate next physical actions", tools: [ "gtd_action_create", "gtd_actions_by_context" ], completionCriteria: [ "Next actions specific", "Actions assigned contexts" ], nextSteps: [ "engage" ] } ], triggers: [ { trigger: "new_project_identified", context: { complexity: "medium_to_high", clarity: "low" } }, { trigger: "project_stuck", context: { progress: "stalled", next_action: "unclear" } } ], outcomes: [ "Clear project definition and scope", "Compelling vision of success", "Logical action sequence", "Immediate next steps identified" ] } ]; var GTDNavigationHintsBuilder = class extends import_navigation_utils.BaseNavigationHintsBuilder { static { __name(this, "GTDNavigationHintsBuilder"); } getDefaultContext() { return { domain: "gtd", operation_type: "productivity", user_journey: "gtd_workflow", workflow_state: "ready_for_action" }; } getDefaultMetadata() { return { generated_by: "gtd-semantic-navigation", version: "1.0.0", domain_methodology: "david_allen_gtd", semantic_model: "gtd_ubiquitous_language" }; } /** * Add GTD-specific workflow navigation */ addGTDWorkflowHints(currentStep, workflowId = "gtd_capture_clarify_organize") { const workflow = GTD_WORKFLOWS.find((w) => w.workflowId === workflowId); if (!workflow) return this; const currentStepDef = workflow.steps.find((s) => s.stepId === currentStep); if (!currentStepDef) return this; currentStepDef.tools.forEach((tool) => { this.addRelatedTool({ tool_name: tool, description: `${tool} - ${currentStepDef.description}`, relevance_score: 0.9, usage_context: `Current step: ${currentStep}` }); }); if (currentStepDef.nextSteps) { currentStepDef.nextSteps.forEach((nextStepId) => { const nextStep = workflow.steps.find((s) => s.stepId === nextStepId); if (nextStep) { this.addNextStep(`${nextStep.stepId}: ${nextStep.description}`); } }); } return this; } /** * Add context-aware action suggestions */ addContextualActionHints(context, energyLevel = "medium") { this.addRelatedTool({ tool_name: "gtd_actions_by_context", description: `View actions available in ${context} context`, relevance_score: 0.95, usage_context: `Current context: ${context}, Energy: ${energyLevel}` }); if (energyLevel === "low") { this.addNextStep("Consider low-energy tasks like organizing or reviewing"); this.addRelatedTool({ tool_name: "gtd_reference_review", description: "Review reference materials (low energy activity)", relevance_score: 0.8, usage_context: "Low energy level" }); } else if (energyLevel === "high") { this.addNextStep("Tackle challenging projects or creative work"); this.addRelatedTool({ tool_name: "gtd_project_advance", description: "Advance high-priority projects (high energy activity)", relevance_score: 0.9, usage_context: "High energy level" }); } return this; } /** * Add cross-domain handoffs for GTD workflow */ addGTDCrossDomainHandoffs(entityType, entityId) { switch (entityType) { case "waiting_for": this.addPersonAssignmentHandoff("responsible person for waiting item", "mcp__gtd-mcp__"); break; case "project": this.addContextHandoff("technical_implementation", { mcp: "mcp__devops-mcp__", tool: "health_check", suggested_action: "Check if this project relates to system health", scenario: "Project may have technical dependencies", pre_populated: { context: `gtd_project_${entityId}` }, workflow_context: { operation_type: "planning", severity: "medium", domain_context: { source_mcp: "mcp__gtd-mcp__", integration_type: "project_technical_assessment" } } }); break; case "next_action": this.addPersonAssignmentHandoff("action assignee", "mcp__gtd-mcp__"); break; } return this; } }; var GTD_DOMAIN_SEMANTICS = { domainId: "gtd", mcpServerId: "mcp__gtd-mcp__", entityRelationships: GTD_ENTITY_RELATIONSHIPS, workflows: GTD_WORKFLOWS, customSemantics: [ { patternId: "gtd_processing_state_transition", description: "Semantic navigation based on GTD processing states", applicableContext: { processing_state: [ "captured", "clarified", "organized", "reviewed" ] }, navigationHints: { next_steps: [ "Follow GTD processing workflow", "Consider current processing state", "Choose appropriate next action" ], context: { domain: "gtd", operation_type: "processing", user_journey: "gtd_state_transition" } } }, { patternId: "gtd_context_energy_matching", description: "Match actions to current context and energy level", applicableContext: { context_type: "any", energy_level: [ "high", "medium", "low" ], time_available: "any" }, navigationHints: { next_steps: [ "Filter actions by current context", "Consider available energy level", "Choose actions matching time available" ], context: { domain: "gtd", operation_type: "action_selection", user_journey: "context_energy_optimization" } } } ], confidence: 0.95, lastUpdated: (/* @__PURE__ */ new Date()).toISOString() }; function createGTDNavigationBuilder() { return new GTDNavigationHintsBuilder(); } __name(createGTDNavigationBuilder, "createGTDNavigationBuilder"); function createGTDSemanticHints(context) { const builder = createGTDNavigationBuilder(); if (context.workflowStep) { builder.addGTDWorkflowHints(context.workflowStep, context.workflowId); } if (context.currentContext) { builder.addContextualActionHints(context.currentContext, context.energyLevel); } if (context.entityType && context.entityId) { builder.addGTDCrossDomainHandoffs(context.entityType, context.entityId); } return builder.build(); } __name(createGTDSemanticHints, "createGTDSemanticHints"); // src/integration/contracts/index.ts var GTD_PUBLISHED_LANGUAGE_VERSION = "2.1.0"; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { GTDNavigationHintsBuilder, GTD_DOMAIN_SEMANTICS, GTD_ENTITY_RELATIONSHIPS, GTD_PUBLISHED_LANGUAGE_VERSION, GTD_WORKFLOWS, InboxCaptureRequestSchema, InboxCaptureResultSchema, InboxItemSummarySchema, InboxQueryCriteriaSchema, createGTDNavigationBuilder, createGTDSemanticHints, gtdDomainApi }); //# sourceMappingURL=index.js.map