@laylzj777/my-apple-apple-eventkit 1.1.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/CHANGELOG.md +575 -0
- package/LICENSE +21 -0
- package/README.md +304 -0
- package/README.zh-CN.md +270 -0
- package/bin/event +0 -0
- package/bin/event-disclaim +0 -0
- package/dist/bin/apple-calendar.d.ts +6 -0
- package/dist/bin/apple-calendar.js +8 -0
- package/dist/bin/apple-calendar.js.map +1 -0
- package/dist/bin/apple-reminders.d.ts +7 -0
- package/dist/bin/apple-reminders.js +9 -0
- package/dist/bin/apple-reminders.js.map +1 -0
- package/dist/bootstrap.d.ts +11 -0
- package/dist/bootstrap.js +44 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/server/handlers.d.ts +12 -0
- package/dist/server/handlers.js +58 -0
- package/dist/server/handlers.js.map +1 -0
- package/dist/server/mode.d.ts +19 -0
- package/dist/server/mode.js +47 -0
- package/dist/server/mode.js.map +1 -0
- package/dist/server/promptAbstractions.d.ts +61 -0
- package/dist/server/promptAbstractions.js +140 -0
- package/dist/server/promptAbstractions.js.map +1 -0
- package/dist/server/prompts.d.ts +13 -0
- package/dist/server/prompts.js +461 -0
- package/dist/server/prompts.js.map +1 -0
- package/dist/server/server.d.ts +61 -0
- package/dist/server/server.js +112 -0
- package/dist/server/server.js.map +1 -0
- package/dist/tools/definitions.d.ts +9 -0
- package/dist/tools/definitions.js +272 -0
- package/dist/tools/definitions.js.map +1 -0
- package/dist/tools/handlers/calendarHandlers.d.ts +11 -0
- package/dist/tools/handlers/calendarHandlers.js +151 -0
- package/dist/tools/handlers/calendarHandlers.js.map +1 -0
- package/dist/tools/handlers/formatters.d.ts +24 -0
- package/dist/tools/handlers/formatters.js +105 -0
- package/dist/tools/handlers/formatters.js.map +1 -0
- package/dist/tools/handlers/index.d.ts +8 -0
- package/dist/tools/handlers/index.js +9 -0
- package/dist/tools/handlers/index.js.map +1 -0
- package/dist/tools/handlers/listHandlers.d.ts +10 -0
- package/dist/tools/handlers/listHandlers.js +47 -0
- package/dist/tools/handlers/listHandlers.js.map +1 -0
- package/dist/tools/handlers/reminderHandlers.d.ts +10 -0
- package/dist/tools/handlers/reminderHandlers.js +219 -0
- package/dist/tools/handlers/reminderHandlers.js.map +1 -0
- package/dist/tools/handlers/shared.d.ts +28 -0
- package/dist/tools/handlers/shared.js +57 -0
- package/dist/tools/handlers/shared.js.map +1 -0
- package/dist/tools/handlers/subtaskHandlers.d.ts +12 -0
- package/dist/tools/handlers/subtaskHandlers.js +113 -0
- package/dist/tools/handlers/subtaskHandlers.js.map +1 -0
- package/dist/tools/index.d.ts +10 -0
- package/dist/tools/index.js +74 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/types/index.d.ts +263 -0
- package/dist/types/index.js +42 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/prompts.d.ts +88 -0
- package/dist/types/prompts.js +6 -0
- package/dist/types/prompts.js.map +1 -0
- package/dist/types/repository.d.ts +197 -0
- package/dist/types/repository.js +14 -0
- package/dist/types/repository.js.map +1 -0
- package/dist/utils/binaryValidator.d.ts +52 -0
- package/dist/utils/binaryValidator.js +185 -0
- package/dist/utils/binaryValidator.js.map +1 -0
- package/dist/utils/calendarRepository.d.ts +49 -0
- package/dist/utils/calendarRepository.js +226 -0
- package/dist/utils/calendarRepository.js.map +1 -0
- package/dist/utils/constants.d.ts +79 -0
- package/dist/utils/constants.js +80 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/dateFiltering.d.ts +41 -0
- package/dist/utils/dateFiltering.js +129 -0
- package/dist/utils/dateFiltering.js.map +1 -0
- package/dist/utils/dateUtils.d.ts +27 -0
- package/dist/utils/dateUtils.js +71 -0
- package/dist/utils/dateUtils.js.map +1 -0
- package/dist/utils/errorHandling.d.ts +27 -0
- package/dist/utils/errorHandling.js +88 -0
- package/dist/utils/errorHandling.js.map +1 -0
- package/dist/utils/eventCli.d.ts +40 -0
- package/dist/utils/eventCli.js +294 -0
- package/dist/utils/eventCli.js.map +1 -0
- package/dist/utils/helpers.d.ts +35 -0
- package/dist/utils/helpers.js +61 -0
- package/dist/utils/helpers.js.map +1 -0
- package/dist/utils/looseDateParser.d.ts +19 -0
- package/dist/utils/looseDateParser.js +149 -0
- package/dist/utils/looseDateParser.js.map +1 -0
- package/dist/utils/projectUtils.d.ts +13 -0
- package/dist/utils/projectUtils.js +92 -0
- package/dist/utils/projectUtils.js.map +1 -0
- package/dist/utils/reminderDateParser.d.ts +8 -0
- package/dist/utils/reminderDateParser.js +89 -0
- package/dist/utils/reminderDateParser.js.map +1 -0
- package/dist/utils/reminderRepository.d.ts +33 -0
- package/dist/utils/reminderRepository.js +262 -0
- package/dist/utils/reminderRepository.js.map +1 -0
- package/dist/utils/subtaskUtils.d.ts +103 -0
- package/dist/utils/subtaskUtils.js +253 -0
- package/dist/utils/subtaskUtils.js.map +1 -0
- package/dist/utils/tagUtils.d.ts +58 -0
- package/dist/utils/tagUtils.js +177 -0
- package/dist/utils/tagUtils.js.map +1 -0
- package/dist/utils/timeHelpers.d.ts +40 -0
- package/dist/utils/timeHelpers.js +136 -0
- package/dist/utils/timeHelpers.js.map +1 -0
- package/dist/validation/schemas.d.ts +385 -0
- package/dist/validation/schemas.js +579 -0
- package/dist/validation/schemas.js.map +1 -0
- package/package.json +96 -0
- package/scripts/build-event.mjs +513 -0
- package/scripts/disclaim.c +69 -0
- package/scripts/event-Info.plist +29 -0
- package/scripts/event.entitlements +10 -0
- package/scripts/postinstall.mjs +91 -0
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* server/prompts.ts
|
|
3
|
+
* Central registry for MCP prompts and their runtime helpers
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod/v3';
|
|
6
|
+
import { getFuzzyTimeSuggestions, getTimeContext, } from '../utils/timeHelpers.js';
|
|
7
|
+
import { DailyTaskOrganizerArgsSchema, ReminderReviewAssistantArgsSchema, SmartReminderCreatorArgsSchema, ValidationError, WeeklyPlanningWorkflowArgsSchema, } from '../validation/schemas.js';
|
|
8
|
+
import { APPLE_REMINDERS_LIMITATIONS, ASK_USER_QUESTION_EXAMPLES, buildStandardOutputFormat, CONTEXT_CALIBRATION, CORE_CONSTRAINTS, DAILY_CAPACITY_CONSTRAINTS, DEEP_WORK_CONSTRAINTS, SHALLOW_TASKS_CONSTRAINTS, TASK_BATCHING_CONSTRAINTS, TIME_BLOCK_CREATION_CONSTRAINTS, TIME_FORMAT_SPEC, WORKLOAD_CALIBRATION, } from './promptAbstractions.js';
|
|
9
|
+
const createMessage = (text) => ({
|
|
10
|
+
role: 'user',
|
|
11
|
+
content: {
|
|
12
|
+
type: 'text',
|
|
13
|
+
text,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Creates a structured prompt template with consistent formatting
|
|
18
|
+
* @param {StructuredPromptConfig} config - Configuration for prompt structure
|
|
19
|
+
* @param {string} config.mission - The core mission statement
|
|
20
|
+
* @param {string[]} config.contextInputs - Context inputs for the prompt
|
|
21
|
+
* @param {string[]} config.process - Step-by-step process instructions
|
|
22
|
+
* @param {string[]} config.outputFormat - Expected output format guidelines
|
|
23
|
+
* @param {string[]} config.qualityBar - Quality criteria and standards
|
|
24
|
+
* @param {string[]} [config.constraints] - Optional constraints and limitations
|
|
25
|
+
* @param {string[]} [config.calibration] - Optional calibration guidelines
|
|
26
|
+
* @returns {string} Formatted prompt string with all sections
|
|
27
|
+
* @private
|
|
28
|
+
*/
|
|
29
|
+
const createStructuredPrompt = ({ mission, contextInputs, process, outputFormat, qualityBar, constraints = [], calibration = [], }) => {
|
|
30
|
+
const sections = [
|
|
31
|
+
'You are an Apple Reminders strategist and productivity coach.',
|
|
32
|
+
mission,
|
|
33
|
+
'Context inputs:',
|
|
34
|
+
...contextInputs.map((input) => `- ${input}`),
|
|
35
|
+
'Process:',
|
|
36
|
+
...process.map((step, index) => `${index + 1}. ${step}`),
|
|
37
|
+
];
|
|
38
|
+
if (constraints.length > 0) {
|
|
39
|
+
sections.push('Constraints:', ...constraints.map((line) => `- ${line}`));
|
|
40
|
+
}
|
|
41
|
+
sections.push('Output format:', ...outputFormat.map((line) => `- ${line}`));
|
|
42
|
+
sections.push('Quality bar:', ...qualityBar.map((line) => `- ${line}`));
|
|
43
|
+
if (calibration.length > 0) {
|
|
44
|
+
sections.push('Calibration:', ...calibration.map((line) => `- ${line}`));
|
|
45
|
+
}
|
|
46
|
+
return sections.join('\n');
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Validates and parses prompt arguments using Zod schema
|
|
50
|
+
* @template T - Expected argument type
|
|
51
|
+
* @param {z.ZodSchema<T>} schema - Zod schema for validation
|
|
52
|
+
* @param {Record<string, unknown> | null | undefined} rawArgs - Raw arguments to validate
|
|
53
|
+
* @param {string} promptName - Name of the prompt for error messages
|
|
54
|
+
* @returns {T} Validated and parsed arguments
|
|
55
|
+
* @throws {ValidationError} If validation fails
|
|
56
|
+
* @private
|
|
57
|
+
*/
|
|
58
|
+
const validatePromptArgs = (schema, rawArgs, promptName) => {
|
|
59
|
+
try {
|
|
60
|
+
return schema.parse(rawArgs ?? {});
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
if (error instanceof z.ZodError) {
|
|
64
|
+
const errorMessages = error.errors
|
|
65
|
+
.map((err) => `${err.path.join('.')}: ${err.message}`)
|
|
66
|
+
.join('; ');
|
|
67
|
+
throw new ValidationError(`Invalid arguments for prompt '${promptName}': ${errorMessages}`);
|
|
68
|
+
}
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Build daily task organizer prompt for same-day task management
|
|
74
|
+
*
|
|
75
|
+
* Creates an intelligent daily task organization prompt that analyzes existing
|
|
76
|
+
* reminders, identifies gaps, and proactively creates or optimizes reminders
|
|
77
|
+
* with appropriate time-based properties.
|
|
78
|
+
*
|
|
79
|
+
* @param {DailyTaskOrganizerArgs} args - Organization arguments
|
|
80
|
+
* @param {string} [args.Today's focus] - Optional focus area (e.g., "urgency-based", "gap filling")
|
|
81
|
+
* @returns {PromptResponse} Structured prompt response with executable action queue
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* // Comprehensive organization
|
|
86
|
+
* const prompt = buildDailyTaskOrganizerPrompt({});
|
|
87
|
+
*
|
|
88
|
+
* // Focused on urgent tasks
|
|
89
|
+
* const urgentPrompt = buildDailyTaskOrganizerPrompt({
|
|
90
|
+
* "Today's focus": 'urgency-based organization'
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
const buildDailyTaskOrganizerPrompt = (args) => {
|
|
95
|
+
const todayFocus = args["Today's focus"] ?? '';
|
|
96
|
+
const timeContext = getTimeContext();
|
|
97
|
+
const fuzzyTimes = getFuzzyTimeSuggestions();
|
|
98
|
+
const standardOutput = buildStandardOutputFormat(timeContext.currentDate);
|
|
99
|
+
return {
|
|
100
|
+
description: 'Proactive daily task organization with intelligent reminder creation and optimization',
|
|
101
|
+
messages: [
|
|
102
|
+
createMessage(createStructuredPrompt({
|
|
103
|
+
mission: 'Mission: Transform daily tasks into organized, actionable reminders by analyzing urgency patterns, identifying gaps, and taking initiative to create or optimize reminders with appropriate properties.',
|
|
104
|
+
contextInputs: [
|
|
105
|
+
`Focus: ${todayFocus ||
|
|
106
|
+
'same-day organizing with urgency, gap filling, and cleanup'}`,
|
|
107
|
+
`Time horizon: today only — do not plan beyond today without approval.`,
|
|
108
|
+
"Action scope: today's reminders plus missing preparatory or follow-up steps.",
|
|
109
|
+
`Current time context: ${timeContext.timeDescription} (${timeContext.currentDate}), later today (${fuzzyTimes.laterToday}).`,
|
|
110
|
+
],
|
|
111
|
+
process: [
|
|
112
|
+
'Review reminders; keep only today in scope and list the rest under Out-of-scope.',
|
|
113
|
+
'Classify tasks as Deep Work (>=60 minutes) or Shallow (15-60 minutes); create calendar blocks for >=60-minute tasks.',
|
|
114
|
+
'Create missing reminders or optimize existing ones without moving due dates beyond today; avoid duplicates.',
|
|
115
|
+
`Generate due dates using ${TIME_FORMAT_SPEC} (e.g., "${timeContext.currentDate} 14:00:00-05:00").`,
|
|
116
|
+
'Batch actions by type and apply confidence gating.',
|
|
117
|
+
],
|
|
118
|
+
constraints: [
|
|
119
|
+
// Daily-task-organizer specific constraints
|
|
120
|
+
'Strict today-only policy: mention non-today reminders under "Out-of-scope items" and leave them untouched.',
|
|
121
|
+
'Ask before creating any reminder or calendar block after today.',
|
|
122
|
+
`Use ${TIME_FORMAT_SPEC} format for due dates and calendar times.`,
|
|
123
|
+
'Do not modify recurrence rules, attachments, or sub-tasks unless explicitly requested.',
|
|
124
|
+
'Assume standard working hours (9am-6pm) and reasonable task durations unless context suggests otherwise.',
|
|
125
|
+
'Do not place concept-only analysis or planning notes inside the action queue; keep them under Current state, Gaps found, Questions, or Out-of-scope.',
|
|
126
|
+
'Action queue is exclusively for executable reminder or calendar changes with tool-ready arguments, confidence labels, and rationale.',
|
|
127
|
+
// Shared constraint patterns
|
|
128
|
+
...CORE_CONSTRAINTS,
|
|
129
|
+
...TASK_BATCHING_CONSTRAINTS,
|
|
130
|
+
...TIME_BLOCK_CREATION_CONSTRAINTS,
|
|
131
|
+
...DEEP_WORK_CONSTRAINTS,
|
|
132
|
+
...SHALLOW_TASKS_CONSTRAINTS,
|
|
133
|
+
...DAILY_CAPACITY_CONSTRAINTS,
|
|
134
|
+
],
|
|
135
|
+
outputFormat: [
|
|
136
|
+
'### Current state — metrics for today: total reminders in scope, overdue items, urgent items, and key blockers.',
|
|
137
|
+
'### Gaps found — preparatory steps, follow-ups, or related reminders that must exist today.',
|
|
138
|
+
'### Out-of-scope items — reminders noted but not due today (reference only).',
|
|
139
|
+
...standardOutput.actionQueue,
|
|
140
|
+
'### Questions — concise list of missing context needed before executing low-confidence actions.',
|
|
141
|
+
standardOutput.verificationLog,
|
|
142
|
+
'### Deep work blocks — list of created or proposed ≥60-minute focus sessions (title, list, duration, objective).',
|
|
143
|
+
'### Shallow tasks — grouped routine work (15-60 minutes) with proposed sequencing and batching cues.',
|
|
144
|
+
],
|
|
145
|
+
qualityBar: [
|
|
146
|
+
'Current state highlights today-only metrics and rationale.',
|
|
147
|
+
'Actions follow confidence gating with concise rationale.',
|
|
148
|
+
'Calendar tool is used for every >=60-minute task confirmed for today.',
|
|
149
|
+
`All due dates labeled "today" use ${TIME_FORMAT_SPEC} format.`,
|
|
150
|
+
'Out-of-scope section explains what was skipped and why.',
|
|
151
|
+
],
|
|
152
|
+
calibration: [
|
|
153
|
+
...WORKLOAD_CALIBRATION,
|
|
154
|
+
...CONTEXT_CALIBRATION,
|
|
155
|
+
...APPLE_REMINDERS_LIMITATIONS,
|
|
156
|
+
],
|
|
157
|
+
})),
|
|
158
|
+
],
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Build smart reminder creator prompt for single reminder creation
|
|
163
|
+
*
|
|
164
|
+
* Creates a focused prompt for crafting a single Apple Reminder with optimal
|
|
165
|
+
* scheduling, context, and metadata based on a task idea.
|
|
166
|
+
*
|
|
167
|
+
* @param args - Reminder creation arguments
|
|
168
|
+
* @param args.Task idea - Optional task description to convert into reminder
|
|
169
|
+
* @returns Structured prompt response for creating a single reminder
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```typescript
|
|
173
|
+
* // Create reminder from task idea
|
|
174
|
+
* const prompt = buildSmartReminderCreatorPrompt({
|
|
175
|
+
* 'Task idea': 'Submit quarterly report by Friday'
|
|
176
|
+
* });
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
const buildSmartReminderCreatorPrompt = (args) => {
|
|
180
|
+
const taskIdea = args['Task idea'] ?? '';
|
|
181
|
+
const timeContext = getTimeContext();
|
|
182
|
+
const standardOutput = buildStandardOutputFormat(timeContext.currentDate);
|
|
183
|
+
return {
|
|
184
|
+
description: 'Intelligent reminder creation with optimal scheduling and context',
|
|
185
|
+
messages: [
|
|
186
|
+
createMessage(createStructuredPrompt({
|
|
187
|
+
mission: `Mission: Craft a single Apple Reminder for "${taskIdea || "today's key task"}" that names the primary execution scope, avoids duplicates, and sets the user up to follow through.`,
|
|
188
|
+
contextInputs: [
|
|
189
|
+
`Task idea: ${taskIdea || 'none provided — propose a sensible framing and ask for confirmation'}`,
|
|
190
|
+
'Existing reminder landscape to cross-check for duplicates or related work.',
|
|
191
|
+
`Current time context: ${timeContext.timeDescription} (${timeContext.currentDate})`,
|
|
192
|
+
],
|
|
193
|
+
process: [
|
|
194
|
+
'Clarify execution scope and check for overlapping reminders.',
|
|
195
|
+
'Ask for missing critical context only when needed to reach confidence.',
|
|
196
|
+
"Set title, list placement, and timing to fit the user's schedule and urgency.",
|
|
197
|
+
'Run idempotency checks and apply confidence gating before executing or recommending.',
|
|
198
|
+
],
|
|
199
|
+
constraints: [
|
|
200
|
+
'Use fuzzy time expressions unless precision is mandatory.',
|
|
201
|
+
'Ask for missing details only when confidence would stay below 60%.',
|
|
202
|
+
'Only rely on Apple Reminders native capabilities.',
|
|
203
|
+
'Do not create extra reminders unless explicitly requested.',
|
|
204
|
+
'Follow-up reminders are opt-in only.',
|
|
205
|
+
'State the primary execution focus before details.',
|
|
206
|
+
...CORE_CONSTRAINTS,
|
|
207
|
+
],
|
|
208
|
+
outputFormat: [
|
|
209
|
+
'### Primary focus — one sentence naming the reminder objective and scope.',
|
|
210
|
+
...standardOutput.actionQueue,
|
|
211
|
+
'### Support details — bullet list covering notes, subtasks, and relevant metadata.',
|
|
212
|
+
'### Follow-up sequence — ordered list of optional next nudges (omit if the user declined additional reminders).',
|
|
213
|
+
standardOutput.verificationLog,
|
|
214
|
+
'### Risks — short bullet list of potential failure points, assumptions, and mitigation ideas.',
|
|
215
|
+
],
|
|
216
|
+
qualityBar: [
|
|
217
|
+
'Timing aligns with importance and existing commitments.',
|
|
218
|
+
'No duplicate reminders are created; similar items are merged or updated.',
|
|
219
|
+
'Actions follow confidence gating with concise rationale.',
|
|
220
|
+
'Scope and assumptions are clear and tied to a specific list.',
|
|
221
|
+
],
|
|
222
|
+
calibration: [
|
|
223
|
+
'If context is insufficient to schedule confidently, respond with targeted clarification questions before delivering the final structure.',
|
|
224
|
+
'When the user has not opted into extra reminders, replace the follow-up section with a short note encouraging a future check-in instead of proposing new tasks.',
|
|
225
|
+
],
|
|
226
|
+
})),
|
|
227
|
+
],
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* Build reminder review assistant prompt for cleanup and optimization
|
|
232
|
+
*
|
|
233
|
+
* Creates a prompt that audits current reminders and delivers actionable
|
|
234
|
+
* clean-up, scheduling, and habit recommendations to boost completion rates.
|
|
235
|
+
*
|
|
236
|
+
* @param args - Review arguments
|
|
237
|
+
* @param args.reviewFocus - Optional focus area (e.g., "overdue", list name)
|
|
238
|
+
* @returns Structured prompt response with cleanup recommendations
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```typescript
|
|
242
|
+
* // Review all reminders
|
|
243
|
+
* const prompt = buildReminderReviewAssistantPrompt({});
|
|
244
|
+
*
|
|
245
|
+
* // Focus on overdue items
|
|
246
|
+
* const overduePrompt = buildReminderReviewAssistantPrompt({
|
|
247
|
+
* reviewFocus: 'overdue reminders'
|
|
248
|
+
* });
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
const buildReminderReviewAssistantPrompt = (args) => {
|
|
252
|
+
const reviewFocus = args['Review focus'] ?? '';
|
|
253
|
+
const timeContext = getTimeContext();
|
|
254
|
+
const standardOutput = buildStandardOutputFormat(timeContext.currentDate);
|
|
255
|
+
return {
|
|
256
|
+
description: 'Analyze and optimize existing reminders for better productivity',
|
|
257
|
+
messages: [
|
|
258
|
+
createMessage(createStructuredPrompt({
|
|
259
|
+
mission: 'Mission: Audit current reminders and deliver actionable clean-up, scheduling, and habit recommendations that boost completion rates.',
|
|
260
|
+
contextInputs: [
|
|
261
|
+
`Review focus: ${reviewFocus || 'none provided — default to all lists and common hotspots'}`,
|
|
262
|
+
`Current time context: ${timeContext.timeDescription} (${timeContext.currentDate})`,
|
|
263
|
+
],
|
|
264
|
+
process: [
|
|
265
|
+
'Analyze reminders: identify overdue items, stale tasks, and patterns.',
|
|
266
|
+
'Execute HIGH confidence actions immediately with tool calls.',
|
|
267
|
+
'Use AskUserQuestion for MEDIUM/LOW confidence decisions.',
|
|
268
|
+
'Recommend lightweight maintenance routines.',
|
|
269
|
+
],
|
|
270
|
+
constraints: [
|
|
271
|
+
'Use fuzzy time adjustments when suggesting schedules or follow-ups.',
|
|
272
|
+
'Ask for critical missing context before final guidance.',
|
|
273
|
+
'Keep recommendations grounded in Apple Reminders native capabilities.',
|
|
274
|
+
'Do not create NEW reminders unless the user explicitly requests it. However, you SHOULD execute updates and deletions for existing reminders when confidence is high (>80%).',
|
|
275
|
+
'When you need user confirmation or decisions, use the AskUserQuestion tool with clear options instead of asking text questions.',
|
|
276
|
+
'For critical decisions (e.g., whether to complete a task, delete items, or adjust dates), present 2-4 options with descriptions using AskUserQuestion.',
|
|
277
|
+
...ASK_USER_QUESTION_EXAMPLES,
|
|
278
|
+
...CORE_CONSTRAINTS,
|
|
279
|
+
],
|
|
280
|
+
outputFormat: [
|
|
281
|
+
'### Review summary — concise overview: total reminders, overdue count, key issues, and primary focus area.',
|
|
282
|
+
...standardOutput.actionQueue,
|
|
283
|
+
standardOutput.verificationLog,
|
|
284
|
+
],
|
|
285
|
+
qualityBar: [
|
|
286
|
+
'Actions tie back to a specific list or pattern.',
|
|
287
|
+
'Action queue entries follow confidence gating with rationale.',
|
|
288
|
+
'HIGH confidence actions (>80%) must result in actual tool calls, not just descriptions.',
|
|
289
|
+
'LOW confidence decisions (<60%) must use AskUserQuestion tool, not text questions.',
|
|
290
|
+
'No text-based questions appear in final output - all user decisions use AskUserQuestion.',
|
|
291
|
+
'Routines are lightweight and sustainable.',
|
|
292
|
+
'No new reminders are created unless explicitly requested.',
|
|
293
|
+
],
|
|
294
|
+
calibration: [
|
|
295
|
+
'If the inventory reveals more work than can be actioned immediately, flag phased recommendations with prioritized batches.',
|
|
296
|
+
],
|
|
297
|
+
})),
|
|
298
|
+
],
|
|
299
|
+
};
|
|
300
|
+
};
|
|
301
|
+
/**
|
|
302
|
+
* Build weekly planning workflow prompt for scheduling reminders
|
|
303
|
+
*
|
|
304
|
+
* Creates a prompt for building a resilient weekly execution playbook by
|
|
305
|
+
* assigning appropriate due dates to existing reminders, aligned with user
|
|
306
|
+
* planning ideas and current priorities.
|
|
307
|
+
*
|
|
308
|
+
* @param args - Weekly planning arguments
|
|
309
|
+
* @param args.User ideas - Optional planning thoughts for the week
|
|
310
|
+
* @returns Structured prompt response with weekly scheduling plan
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* ```typescript
|
|
314
|
+
* // Plan week with user ideas
|
|
315
|
+
* const prompt = buildWeeklyPlanningWorkflowPrompt({
|
|
316
|
+
* 'User ideas': 'Focus on project launch and client presentations'
|
|
317
|
+
* });
|
|
318
|
+
*
|
|
319
|
+
* // Auto-plan based on existing reminders
|
|
320
|
+
* const autoPrompt = buildWeeklyPlanningWorkflowPrompt({});
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
323
|
+
const buildWeeklyPlanningWorkflowPrompt = (args) => {
|
|
324
|
+
const userIdeas = args['User ideas'] ?? '';
|
|
325
|
+
const timeContext = getTimeContext();
|
|
326
|
+
const standardOutput = buildStandardOutputFormat(timeContext.currentDate);
|
|
327
|
+
return {
|
|
328
|
+
description: 'Assign due dates to existing reminders based on weekly planning ideas',
|
|
329
|
+
messages: [
|
|
330
|
+
createMessage(createStructuredPrompt({
|
|
331
|
+
mission: 'Mission: Build a resilient weekly execution playbook by assigning appropriate due dates to existing reminders this week, aligned with user planning ideas and current priorities.',
|
|
332
|
+
contextInputs: [
|
|
333
|
+
`User planning ideas for this week: ${userIdeas || 'none provided - analyze existing reminders and suggest reasonable distribution'}`,
|
|
334
|
+
'Time horizon: current calendar week — keep scheduling inside this range and surface overflow separately.',
|
|
335
|
+
'Existing reminders without due dates that need scheduling.',
|
|
336
|
+
'Existing reminders with due dates this week (anchor events).',
|
|
337
|
+
'Overdue reminders that may need rescheduling.',
|
|
338
|
+
'Calendar events or fixed commitments that create time constraints.',
|
|
339
|
+
`Current time context: ${timeContext.timeDescription} - ${timeContext.dayOfWeek}, ${timeContext.currentDate}`,
|
|
340
|
+
],
|
|
341
|
+
process: [
|
|
342
|
+
'Analyze user ideas to identify weekly priorities and themes.',
|
|
343
|
+
'Audit reminders and anchors (existing due dates and calendar commitments).',
|
|
344
|
+
'Assign fuzzy due dates within the week and balance workload.',
|
|
345
|
+
'Apply confidence gating and flag conflicts or overload.',
|
|
346
|
+
'Recommend lightweight review checkpoints.',
|
|
347
|
+
],
|
|
348
|
+
constraints: [
|
|
349
|
+
'Do not create new reminders; only assign or update due dates.',
|
|
350
|
+
'Keep scheduling decisions inside the current week; ask before moving beyond it.',
|
|
351
|
+
'Use fuzzy time expressions and respect existing due dates unless they conflict.',
|
|
352
|
+
'Ensure suggested due dates balance workload across the week.',
|
|
353
|
+
'Ask for critical missing context before final guidance.',
|
|
354
|
+
'State the primary weekly focus up front.',
|
|
355
|
+
...CORE_CONSTRAINTS,
|
|
356
|
+
],
|
|
357
|
+
outputFormat: [
|
|
358
|
+
'### Weekly focus — brief summary of primary themes and priorities for the week based on user ideas.',
|
|
359
|
+
'### Current state — overview with metrics: total reminders to schedule, already scheduled, overdue items.',
|
|
360
|
+
...standardOutput.actionQueue,
|
|
361
|
+
'### Immediate next steps — what to do today and tomorrow to get the week started effectively.',
|
|
362
|
+
'### Workload insights — key observations about task distribution, conflicts, or dependencies that need attention.',
|
|
363
|
+
standardOutput.verificationLog,
|
|
364
|
+
],
|
|
365
|
+
qualityBar: [
|
|
366
|
+
'Weekly focus is clear and aligned with user input.',
|
|
367
|
+
'Action queue follows confidence gating and includes rationale.',
|
|
368
|
+
'Due dates stay inside the current week and remain realistic.',
|
|
369
|
+
'Plan highlights conflicts or overload without excessive analysis.',
|
|
370
|
+
],
|
|
371
|
+
calibration: [
|
|
372
|
+
'If user ideas cannot be mapped to existing reminders, summarize these as "future planning notes" without creating reminders.',
|
|
373
|
+
'When workload appears excessive, propose explicit prioritization: which reminders are essential this week vs. can be deferred.',
|
|
374
|
+
'If user provides no ideas, infer priorities from reminder patterns (urgency signals, list organization, dependencies) and ask for confirmation only when confidence stays below 60%.',
|
|
375
|
+
],
|
|
376
|
+
})),
|
|
377
|
+
],
|
|
378
|
+
};
|
|
379
|
+
};
|
|
380
|
+
const PROMPTS = {
|
|
381
|
+
'daily-task-organizer': {
|
|
382
|
+
metadata: {
|
|
383
|
+
name: 'daily-task-organizer',
|
|
384
|
+
description: 'Proactive daily task organization with intelligent reminder creation and optimization',
|
|
385
|
+
arguments: [
|
|
386
|
+
{
|
|
387
|
+
name: "Today's focus",
|
|
388
|
+
description: 'Organization focus area (e.g., urgency-based organization, gap filling, reminder setup, or comprehensive organization)',
|
|
389
|
+
required: false,
|
|
390
|
+
},
|
|
391
|
+
],
|
|
392
|
+
},
|
|
393
|
+
parseArgs(rawArgs) {
|
|
394
|
+
return validatePromptArgs(DailyTaskOrganizerArgsSchema, rawArgs, 'daily-task-organizer');
|
|
395
|
+
},
|
|
396
|
+
buildPrompt: buildDailyTaskOrganizerPrompt,
|
|
397
|
+
},
|
|
398
|
+
'smart-reminder-creator': {
|
|
399
|
+
metadata: {
|
|
400
|
+
name: 'smart-reminder-creator',
|
|
401
|
+
description: 'Intelligently create reminders with optimal scheduling and context',
|
|
402
|
+
arguments: [
|
|
403
|
+
{
|
|
404
|
+
name: 'Task idea',
|
|
405
|
+
description: 'A short description of what you want to do',
|
|
406
|
+
required: false,
|
|
407
|
+
},
|
|
408
|
+
],
|
|
409
|
+
},
|
|
410
|
+
parseArgs(rawArgs) {
|
|
411
|
+
return validatePromptArgs(SmartReminderCreatorArgsSchema, rawArgs, 'smart-reminder-creator');
|
|
412
|
+
},
|
|
413
|
+
buildPrompt: buildSmartReminderCreatorPrompt,
|
|
414
|
+
},
|
|
415
|
+
'reminder-review-assistant': {
|
|
416
|
+
metadata: {
|
|
417
|
+
name: 'reminder-review-assistant',
|
|
418
|
+
description: 'Analyze and review existing reminders for productivity optimization',
|
|
419
|
+
arguments: [
|
|
420
|
+
{
|
|
421
|
+
name: 'Review focus',
|
|
422
|
+
description: 'A short note on what to review (e.g., overdue, a list name)',
|
|
423
|
+
required: false,
|
|
424
|
+
},
|
|
425
|
+
],
|
|
426
|
+
},
|
|
427
|
+
parseArgs(rawArgs) {
|
|
428
|
+
return validatePromptArgs(ReminderReviewAssistantArgsSchema, rawArgs, 'reminder-review-assistant');
|
|
429
|
+
},
|
|
430
|
+
buildPrompt: buildReminderReviewAssistantPrompt,
|
|
431
|
+
},
|
|
432
|
+
'weekly-planning-workflow': {
|
|
433
|
+
metadata: {
|
|
434
|
+
name: 'weekly-planning-workflow',
|
|
435
|
+
description: 'Assign due dates to existing reminders based on your weekly planning ideas',
|
|
436
|
+
arguments: [
|
|
437
|
+
{
|
|
438
|
+
name: 'User ideas',
|
|
439
|
+
description: 'Your thoughts and ideas for what you want to accomplish this week',
|
|
440
|
+
required: false,
|
|
441
|
+
},
|
|
442
|
+
],
|
|
443
|
+
},
|
|
444
|
+
parseArgs(rawArgs) {
|
|
445
|
+
return validatePromptArgs(WeeklyPlanningWorkflowArgsSchema, rawArgs, 'weekly-planning-workflow');
|
|
446
|
+
},
|
|
447
|
+
buildPrompt: buildWeeklyPlanningWorkflowPrompt,
|
|
448
|
+
},
|
|
449
|
+
};
|
|
450
|
+
export const PROMPT_LIST = Object.values(PROMPTS).map((prompt) => prompt.metadata);
|
|
451
|
+
/**
|
|
452
|
+
* 按子模块模式过滤 prompts(fork):现有 4 个均为提醒事项工作流(日历仅作
|
|
453
|
+
* 时间块参考),calendar 模式全部不暴露——引用不存在工具的 prompt 只会误导模型。
|
|
454
|
+
*/
|
|
455
|
+
export const getPromptListForMode = (mode) => (mode === 'calendar' ? [] : PROMPT_LIST);
|
|
456
|
+
export const getPromptDefinition = (name) => PROMPTS[name];
|
|
457
|
+
export const buildPromptResponse = (template, rawArgs) => {
|
|
458
|
+
const parsedArgs = template.parseArgs(rawArgs);
|
|
459
|
+
return template.buildPrompt(parsedArgs);
|
|
460
|
+
};
|
|
461
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/server/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAW3B,OAAO,EACL,uBAAuB,EACvB,cAAc,GACf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,4BAA4B,EAC5B,iCAAiC,EACjC,8BAA8B,EAC9B,eAAe,EACf,gCAAgC,GACjC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,yBAAyB,EACzB,mBAAmB,EACnB,gBAAgB,EAChB,0BAA0B,EAC1B,qBAAqB,EACrB,yBAAyB,EACzB,yBAAyB,EACzB,+BAA+B,EAC/B,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,yBAAyB,CAAC;AAMjC,MAAM,aAAa,GAAG,CAAC,IAAY,EAAsC,EAAE,CAAC,CAAC;IAC3E,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE;QACP,IAAI,EAAE,MAAM;QACZ,IAAI;KACL;CACF,CAAC,CAAC;AAYH;;;;;;;;;;;;GAYG;AACH,MAAM,sBAAsB,GAAG,CAAC,EAC9B,OAAO,EACP,aAAa,EACb,OAAO,EACP,YAAY,EACZ,UAAU,EACV,WAAW,GAAG,EAAE,EAChB,WAAW,GAAG,EAAE,GACO,EAAU,EAAE;IACnC,MAAM,QAAQ,GAAa;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,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAC/C,OAAO,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;AAC1C,CAAC,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* server/server.ts
|
|
3
|
+
* Server configuration and startup logic
|
|
4
|
+
*/
|
|
5
|
+
import 'exit-on-epipe';
|
|
6
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
7
|
+
import type { ServerConfig } from '../types/index.js';
|
|
8
|
+
import { type ServerMode } from './mode.js';
|
|
9
|
+
/** 当前模式下暴露的工具子集(fork:按域拆分,见 server/mode.ts)。 */
|
|
10
|
+
export declare const getToolsForMode: (mode: ServerMode) => {
|
|
11
|
+
inputSchema: {
|
|
12
|
+
[x: string]: unknown;
|
|
13
|
+
type: "object";
|
|
14
|
+
properties?: {
|
|
15
|
+
[x: string]: object;
|
|
16
|
+
} | undefined;
|
|
17
|
+
required?: string[] | undefined;
|
|
18
|
+
};
|
|
19
|
+
name: string;
|
|
20
|
+
description?: string | undefined;
|
|
21
|
+
outputSchema?: {
|
|
22
|
+
[x: string]: unknown;
|
|
23
|
+
type: "object";
|
|
24
|
+
properties?: {
|
|
25
|
+
[x: string]: object;
|
|
26
|
+
} | undefined;
|
|
27
|
+
required?: string[] | undefined;
|
|
28
|
+
} | undefined;
|
|
29
|
+
annotations?: {
|
|
30
|
+
title?: string | undefined;
|
|
31
|
+
readOnlyHint?: boolean | undefined;
|
|
32
|
+
destructiveHint?: boolean | undefined;
|
|
33
|
+
idempotentHint?: boolean | undefined;
|
|
34
|
+
openWorldHint?: boolean | undefined;
|
|
35
|
+
} | undefined;
|
|
36
|
+
execution?: {
|
|
37
|
+
taskSupport?: "optional" | "required" | "forbidden" | undefined;
|
|
38
|
+
} | undefined;
|
|
39
|
+
_meta?: {
|
|
40
|
+
[x: string]: unknown;
|
|
41
|
+
} | undefined;
|
|
42
|
+
icons?: {
|
|
43
|
+
src: string;
|
|
44
|
+
mimeType?: string | undefined;
|
|
45
|
+
sizes?: string[] | undefined;
|
|
46
|
+
theme?: "light" | "dark" | undefined;
|
|
47
|
+
}[] | undefined;
|
|
48
|
+
title?: string | undefined;
|
|
49
|
+
}[];
|
|
50
|
+
/**
|
|
51
|
+
* Creates and configures an MCP server instance
|
|
52
|
+
* @param config - Server configuration
|
|
53
|
+
* @returns Configured server instance
|
|
54
|
+
*/
|
|
55
|
+
export declare function createServer(config: ServerConfig): Server;
|
|
56
|
+
/**
|
|
57
|
+
* Starts the MCP server
|
|
58
|
+
* @param config - Server configuration
|
|
59
|
+
* @returns A promise that resolves when the server starts
|
|
60
|
+
*/
|
|
61
|
+
export declare function startServer(config: ServerConfig): Promise<void>;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* server/server.ts
|
|
3
|
+
* Server configuration and startup logic
|
|
4
|
+
*/
|
|
5
|
+
import 'exit-on-epipe';
|
|
6
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
7
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
8
|
+
import { TOOLS } from '../tools/definitions.js';
|
|
9
|
+
import { registerHandlers } from './handlers.js';
|
|
10
|
+
import { isToolAllowedInMode } from './mode.js';
|
|
11
|
+
import { getPromptListForMode } from './prompts.js';
|
|
12
|
+
/** 当前模式下暴露的工具子集(fork:按域拆分,见 server/mode.ts)。 */
|
|
13
|
+
export const getToolsForMode = (mode) => TOOLS.filter((tool) => isToolAllowedInMode(tool.name, mode));
|
|
14
|
+
/**
|
|
15
|
+
* Builds the `instructions` string surfaced through the MCP `initialize`
|
|
16
|
+
* response. Derived from `TOOLS` and `PROMPT_LIST` so the user-facing summary
|
|
17
|
+
* cannot drift when a tool or prompt is added — the new entry shows up
|
|
18
|
+
* automatically, and the maintainer just has to keep each tool's own
|
|
19
|
+
* `description` in `definitions.ts` accurate.
|
|
20
|
+
*/
|
|
21
|
+
const buildServerInstructions = (mode) => {
|
|
22
|
+
const tools = getToolsForMode(mode);
|
|
23
|
+
const prompts = getPromptListForMode(mode);
|
|
24
|
+
const toolLines = tools.map((tool) => `- ${tool.name} — ${tool.description}`);
|
|
25
|
+
const scope = mode === 'calendar'
|
|
26
|
+
? 'Apple Calendar'
|
|
27
|
+
: mode === 'reminders'
|
|
28
|
+
? 'Apple Reminders'
|
|
29
|
+
: 'Apple Reminders and Calendar';
|
|
30
|
+
const accounts = mode === 'calendar'
|
|
31
|
+
? 'Calendar'
|
|
32
|
+
: mode === 'reminders'
|
|
33
|
+
? 'Reminders'
|
|
34
|
+
: 'Reminders / Calendar';
|
|
35
|
+
return [
|
|
36
|
+
`This MCP server exposes native macOS ${scope} access.`,
|
|
37
|
+
'',
|
|
38
|
+
`Tools (${tools.length}):`,
|
|
39
|
+
...toolLines,
|
|
40
|
+
...(prompts.length > 0
|
|
41
|
+
? ['', `Prompts (${prompts.length}): ${prompts.map((p) => p.name).join(', ')}.`]
|
|
42
|
+
: []),
|
|
43
|
+
'',
|
|
44
|
+
`All write actions go through the user's ${accounts} accounts via EventKit.`,
|
|
45
|
+
'The first call may trigger a system permission dialog.',
|
|
46
|
+
].join('\n');
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Creates and configures an MCP server instance
|
|
50
|
+
* @param config - Server configuration
|
|
51
|
+
* @returns Configured server instance
|
|
52
|
+
*/
|
|
53
|
+
export function createServer(config) {
|
|
54
|
+
const mode = config.mode ?? 'all';
|
|
55
|
+
const server = new Server({
|
|
56
|
+
name: config.name,
|
|
57
|
+
version: config.version,
|
|
58
|
+
}, {
|
|
59
|
+
// Only advertise the capabilities we actually implement. We previously
|
|
60
|
+
// declared `resources: {}` but never registered a resource handler —
|
|
61
|
+
// that misled clients into thinking `ListResources` would work.
|
|
62
|
+
capabilities: {
|
|
63
|
+
tools: {},
|
|
64
|
+
prompts: {},
|
|
65
|
+
},
|
|
66
|
+
instructions: buildServerInstructions(mode),
|
|
67
|
+
});
|
|
68
|
+
// Register request handlers
|
|
69
|
+
registerHandlers(server, mode);
|
|
70
|
+
return server;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Starts the MCP server
|
|
74
|
+
* @param config - Server configuration
|
|
75
|
+
* @returns A promise that resolves when the server starts
|
|
76
|
+
*/
|
|
77
|
+
export async function startServer(config) {
|
|
78
|
+
let server;
|
|
79
|
+
try {
|
|
80
|
+
server = createServer(config);
|
|
81
|
+
const transport = new StdioServerTransport();
|
|
82
|
+
// Graceful shutdown: close the SDK server (which flushes the stdio
|
|
83
|
+
// transport) before exiting, so any in-flight JSON-RPC response is
|
|
84
|
+
// delivered. Bare `process.exit(0)` truncated those responses.
|
|
85
|
+
const shutdown = async (signal) => {
|
|
86
|
+
try {
|
|
87
|
+
await server?.close();
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
// Best-effort: a transport that has already torn down should not
|
|
91
|
+
// prevent termination.
|
|
92
|
+
}
|
|
93
|
+
// Node exit codes for signals are 128 + signal number; SIGINT=2, SIGTERM=15.
|
|
94
|
+
process.exit(signal === 'SIGINT' ? 130 : 143);
|
|
95
|
+
};
|
|
96
|
+
process.on('SIGINT', () => {
|
|
97
|
+
void shutdown('SIGINT');
|
|
98
|
+
});
|
|
99
|
+
process.on('SIGTERM', () => {
|
|
100
|
+
void shutdown('SIGTERM');
|
|
101
|
+
});
|
|
102
|
+
await server.connect(transport);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
// Surface the failure on stderr instead of exiting silently — MCP clients
|
|
106
|
+
// (Claude Desktop etc.) spawn the binary and only see stderr/exit code.
|
|
107
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
108
|
+
process.stderr.write(`MCP server startup failed: ${message}\n`);
|
|
109
|
+
process.exit(1);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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