Skip to content

Commit 3f349f2

Browse files
authored
Merge pull request #58 from amol-anand/inject-datetime
feat: add user's timezone to the agent context
2 parents 60fb312 + 1ce2764 commit 3f349f2

4 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/prompt-builder.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,13 @@ The user is currently working on the following document in DA (Document Authorin
257257
- site (repo): ${pageContext.site}
258258
- path: ${ensureHtmlExtension(pageContext.path)}
259259
- view: ${pageContext.view}
260+
- user's local time zone: ${pageContext.timeZone ?? 'unknown'}
260261
- Live Preview URL: https://main--${pageContext.site}--${pageContext.org}.${environment === 'production' || !environment ? 'preview.da.live' : 'stage-preview.da.live'}${pathForUrl}
261262
- Previewed URL: https://main--${pageContext.site}--${pageContext.org}.aem.page${pathForUrl}
262263
- Published URL: https://main--${pageContext.site}--${pageContext.org}.aem.live${pathForUrl}
263264
265+
Use the user's local time zone above when interpreting relative dates/times (e.g. "today", "next Monday") or converting timestamps for display — including when calling any date/time tool — unless the user specifies otherwise.
266+
264267
**URL freshness rules:**
265268
- The **Live Preview URL** always reflects the current state of the document as it appears right now in DA — no operation needed.
266269
- The **Previewed URL** only reflects the latest content after a **preview** operation has been performed; otherwise it is outdated.

src/request-schemas.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const PageContextSchema = z.object({
55
site: z.string(),
66
path: z.string().optional().default(''),
77
view: z.string().optional(),
8+
timeZone: z.string().optional(),
89
});
910

1011
export type PageContext = z.infer<typeof PageContextSchema>;

test/prompt-builder.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ describe('buildSystemPrompt with pageContext', () => {
5353
expect(prompt).toContain('/index.html');
5454
});
5555

56+
it('includes user time zone when present', () => {
57+
const prompt = buildSystemPrompt({ ...pageContext, timeZone: 'America/New_York' });
58+
expect(prompt).toContain('America/New_York');
59+
});
60+
61+
it('shows unknown time zone when absent', () => {
62+
const prompt = buildSystemPrompt(pageContext);
63+
expect(prompt).toContain("user's local time zone: unknown");
64+
});
65+
5666
it('includes live preview URL', () => {
5767
const prompt = buildSystemPrompt(
5868
pageContext,

test/request-schemas.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ describe('PageContextSchema', () => {
2323
expect(result.data?.view).toBe('edit');
2424
});
2525

26+
it('accepts optional timeZone field', () => {
27+
const result = PageContextSchema.safeParse({
28+
org: 'adobe',
29+
site: 'docs',
30+
path: '/index.html',
31+
timeZone: 'America/New_York',
32+
});
33+
expect(result.success).toBe(true);
34+
expect(result.data?.timeZone).toBe('America/New_York');
35+
});
36+
2637
it('rejects missing org', () => {
2738
const result = PageContextSchema.safeParse({ site: 'docs', path: '/index.html' });
2839
expect(result.success).toBe(false);

0 commit comments

Comments
 (0)