From f101a5025ec6f7d8f6dc29bd3f05f75240b1e476 Mon Sep 17 00:00:00 2001 From: Devin Date: Fri, 17 Apr 2026 05:08:13 +0800 Subject: [PATCH] fix(map-codebase): pass current date to mapper agents to fix wrong Analysis Date (#2298) The `cmdInitMapCodebase` / `initMapCodebase` init handlers did not include `date` or `timestamp` fields in their JSON output, unlike `init quick` and `init todo` which both provide them. Because the mapper agents had no reliable date source, they were forced to guess the date from model training data, producing incorrect Analysis Date values (e.g. 2025-07-15 instead of the actual date) in all seven `.planning/codebase/*.md` documents. Changes: - Add `date` and `timestamp` to `cmdInitMapCodebase` (init.cjs) and `initMapCodebase` (init.ts) - Pass `{date}` into each mapper agent prompt via the workflow - Update agent definition to use the prompt-provided date instead of guessing - Cover sequential_mapping fallback path as well --- agents/gsd-codebase-mapper.md | 2 +- get-shit-done/bin/lib/init.cjs | 5 +++++ get-shit-done/workflows/map-codebase.md | 16 +++++++++++++++- sdk/src/query/init.ts | 3 +++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/agents/gsd-codebase-mapper.md b/agents/gsd-codebase-mapper.md index 51cf7cff8..b7022495e 100644 --- a/agents/gsd-codebase-mapper.md +++ b/agents/gsd-codebase-mapper.md @@ -160,7 +160,7 @@ Write document(s) to `.planning/codebase/` using the templates below. **Document naming:** UPPERCASE.md (e.g., STACK.md, ARCHITECTURE.md) **Template filling:** -1. Replace `[YYYY-MM-DD]` with current date +1. Replace `[YYYY-MM-DD]` with the date provided in your prompt (the `Today's date:` line). NEVER guess or infer the date — always use the exact date from the prompt. 2. Replace `[Placeholder text]` with findings from exploration 3. If something is not found, use "Not detected" or "Not applicable" 4. Always include file paths with backticks diff --git a/get-shit-done/bin/lib/init.cjs b/get-shit-done/bin/lib/init.cjs index 04766e671..843b62800 100644 --- a/get-shit-done/bin/lib/init.cjs +++ b/get-shit-done/bin/lib/init.cjs @@ -879,6 +879,7 @@ function cmdInitMilestoneOp(cwd, raw) { function cmdInitMapCodebase(cwd, raw) { const config = loadConfig(cwd); + const now = new Date(); // Check for existing codebase maps const codebaseDir = path.join(planningRoot(cwd), 'codebase'); @@ -897,6 +898,10 @@ function cmdInitMapCodebase(cwd, raw) { parallelization: config.parallelization, subagent_timeout: config.subagent_timeout, + // Timestamps + date: now.toISOString().split('T')[0], + timestamp: now.toISOString(), + // Paths codebase_dir: '.planning/codebase', diff --git a/get-shit-done/workflows/map-codebase.md b/get-shit-done/workflows/map-codebase.md index 29c4a03a8..1d4b28170 100644 --- a/get-shit-done/workflows/map-codebase.md +++ b/get-shit-done/workflows/map-codebase.md @@ -36,7 +36,7 @@ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi AGENT_SKILLS_MAPPER=$(gsd-sdk query agent-skills gsd-codebase-mapper 2>/dev/null) ``` -Extract from init JSON: `mapper_model`, `commit_docs`, `codebase_dir`, `existing_maps`, `has_maps`, `codebase_dir_exists`, `subagent_timeout`. +Extract from init JSON: `mapper_model`, `commit_docs`, `codebase_dir`, `existing_maps`, `has_maps`, `codebase_dir_exists`, `subagent_timeout`, `date`. @@ -114,6 +114,7 @@ Task( run_in_background=true, description="Map codebase tech stack", prompt="Focus: tech +Today's date: {date} Analyze this codebase for technology stack and external integrations. @@ -121,6 +122,8 @@ Write these documents to .planning/codebase/: - STACK.md - Languages, runtime, frameworks, dependencies, configuration - INTEGRATIONS.md - External APIs, databases, auth providers, webhooks +IMPORTANT: Use {date} for all [YYYY-MM-DD] date placeholders in documents. + Explore thoroughly. Write documents directly using templates. Return confirmation only. ${AGENT_SKILLS_MAPPER}" ) @@ -135,6 +138,7 @@ Task( run_in_background=true, description="Map codebase architecture", prompt="Focus: arch +Today's date: {date} Analyze this codebase architecture and directory structure. @@ -142,6 +146,8 @@ Write these documents to .planning/codebase/: - ARCHITECTURE.md - Pattern, layers, data flow, abstractions, entry points - STRUCTURE.md - Directory layout, key locations, naming conventions +IMPORTANT: Use {date} for all [YYYY-MM-DD] date placeholders in documents. + Explore thoroughly. Write documents directly using templates. Return confirmation only. ${AGENT_SKILLS_MAPPER}" ) @@ -156,6 +162,7 @@ Task( run_in_background=true, description="Map codebase conventions", prompt="Focus: quality +Today's date: {date} Analyze this codebase for coding conventions and testing patterns. @@ -163,6 +170,8 @@ Write these documents to .planning/codebase/: - CONVENTIONS.md - Code style, naming, patterns, error handling - TESTING.md - Framework, structure, mocking, coverage +IMPORTANT: Use {date} for all [YYYY-MM-DD] date placeholders in documents. + Explore thoroughly. Write documents directly using templates. Return confirmation only. ${AGENT_SKILLS_MAPPER}" ) @@ -177,12 +186,15 @@ Task( run_in_background=true, description="Map codebase concerns", prompt="Focus: concerns +Today's date: {date} Analyze this codebase for technical debt, known issues, and areas of concern. Write this document to .planning/codebase/: - CONCERNS.md - Tech debt, bugs, security, performance, fragile areas +IMPORTANT: Use {date} for all [YYYY-MM-DD] date placeholders in documents. + Explore thoroughly. Write document directly using template. Return confirmation only. ${AGENT_SKILLS_MAPPER}" ) @@ -232,6 +244,8 @@ When the `Task` tool is unavailable, perform codebase mapping sequentially in th **IMPORTANT:** Do NOT use `browser_subagent`, `Explore`, or any browser-based tool. Use only file system tools (Read, Bash, Write, Grep, Glob, list_dir, view_file, grep_search, or equivalent tools available in your runtime). +**IMPORTANT:** Use `{date}` from init context for all `[YYYY-MM-DD]` date placeholders in documents. NEVER guess the date. + Perform all 4 mapping passes sequentially: **Pass 1: Tech Focus** diff --git a/sdk/src/query/init.ts b/sdk/src/query/init.ts index aac46c033..3533c3ecc 100644 --- a/sdk/src/query/init.ts +++ b/sdk/src/query/init.ts @@ -747,6 +747,7 @@ export const initMilestoneOp: QueryHandler = async (_args, projectDir) => { */ export const initMapCodebase: QueryHandler = async (_args, projectDir) => { const config = await loadConfig(projectDir); + const now = new Date(); const codebaseDir = join(projectDir, '.planning', 'codebase'); let existingMaps: string[] = []; try { @@ -761,6 +762,8 @@ export const initMapCodebase: QueryHandler = async (_args, projectDir) => { search_gitignored: config.search_gitignored, parallelization: config.parallelization, subagent_timeout: (config as Record).subagent_timeout ?? undefined, + date: now.toISOString().split('T')[0], + timestamp: now.toISOString(), codebase_dir: '.planning/codebase', existing_maps: existingMaps, has_maps: existingMaps.length > 0,