Skip to content

feat(cli): devmap_analyze, opt-in auto-refresh, transitive impact, prompts (Phase 2) - #132

Merged
itsflaid merged 2 commits into
mainfrom
feat/mcp-freshness
Oct 29, 2026
Merged

itsflaid merged 2 commits into
mainfrom
feat/mcp-freshness

Conversation

@itsflaid

Copy link
Copy Markdown
Owner

Ringkasan

Fase 2: server MCP bisa me-refresh peta proyeknya sendiri, dengan AI mati secara default, dan devmap_impact jadi jauh lebih berguna sebelum mengedit file.

Yang baru

  • devmap_analyze — analisis ulang dan refresh .devmap/snapshot.json (hanya menulis di dalam .devmap/).
    • unchanged tanpa menganalisis ulang bila tidak ada file berubah; fresh: true memaksa rebuild.
    • Menunggu maksimal timeoutSeconds (default 120). Lewat itu hasilnya running dan analisis lanjut di background; panggilan berikutnya bergabung ke analisis yang sama.
    • Panggilan paralel berbagi satu analisis. Heartbeat notifications/progress supaya client tidak timeout.
  • AI mati by default. AI hanya dipakai bila server dijalankan dengan --allow-ai. Bila rebuild statis menghilangkan data turunan AI (domain/arsitektur) dari snapshot lama, hasil melaporkan aiDataDropped: true + petunjuk memulihkannya.
  • --auto-refresh (default off) — snapshot stale/hilang dibangun ulang sebelum menjawab. Bila gagal: kembali ke snapshot lama dengan snapshot.refreshError, dan tidak mencoba lagi selama 30 detik.
  • Lock lintas proses .devmap/analyze.lock — lock dari proses yang sudah mati atau lebih dari 15 menit diambil alih.
  • devmap_impact — parameter depth (1–5) mengikuti import secara transitif (aman dari siklus), plus dependentCount, affectedFeatures, isCritical, criticalDependents.
  • devmap_map/devmap_flow memakai snapshot yang sudah di-cache provider (tidak lagi baca ulang + scan stale tiap panggilan).
  • Prompts: devmap_onboard, devmap_plan_change.
  • Command: devmap mcp [--root <path>] [--auto-refresh] [--allow-ai].

Catatan keamanan/perilaku

  • Query tetap tidak pernah menulis ke disk kecuali --auto-refresh aktif atau agent memanggil devmap_analyze.
  • Mode offline terbukti tidak menyentuh provider AI: tes memasang client AI palsu yang akan gagal bila dipanggil, dengan API key dikonfigurasi (config bahkan tidak dibaca).
  • devmap_analyze ditandai readOnlyHint: false, destructiveHint: false, idempotentHint: true; openWorldHint true hanya dengan --allow-ai.
  • Lock hanya melindungi analisis dari MCP; devmap analyze di terminal belum memakainya (kemungkinan tabrakan sangat kecil, bisa ditambahkan nanti).

Perubahan di luar src/mcp

  • commands/analyze.ts: runAnalyze di-export, opsi offline. Perilaku CLI tidak berubah.
  • commands/map.ts, commands/flow.ts: opsi loaded (snapshot yang sudah dimuat).

Verifikasi

  • pnpm test (typecheck + unit): 474/474 (22 tes baru)
  • pnpm run build ✅
  • pnpm run test:package-e2e ✅ (smoke test paket kini juga memanggil devmap_analyze dari tarball)
  • Tes stdio dengan proses sungguhan menjalankan analisis nyata di dalam server dan memastikan stdout tetap bersih.

Berikutnya: Fase 3 (devmap_explain BYOK, smoke test CI, rilis 0.9.0), lalu Fase 4 (docs + landing page).


Generated by Claude Code

…ase 2 groundwork)

- export runAnalyze; AnalyzeOptions.offline skips domain inference, snapshot
  enrichment and architecture interpretation (static analysis only)
- MapOptions/FlowOptions.loaded lets long-lived callers pass an already loaded
  snapshot so it is not re-read and staleness is not re-scanned per call

No behavior change for the CLI; nothing uses these options yet.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AgTNRXcqugxRyJfMKL4AJ2
… prompts (Phase 2)

- devmap_analyze tool: re-analyze and refresh .devmap/snapshot.json.
  Returns "unchanged" without analyzing when no file changed (fresh:true forces
  a rebuild); waits up to timeoutSeconds then returns status "running" while the
  analysis continues in the background; concurrent calls share one analysis;
  sends progress notifications so clients do not time out.
- Static analysis by default: no AI is used unless the server is started with
  --allow-ai. aiDataDropped is reported when a static rebuild loses AI-derived
  data (domain/architecture) from the previous snapshot.
- --auto-refresh (off by default): a stale or missing snapshot is rebuilt before
  answering; a failing refresh falls back to the stale snapshot with
  snapshot.refreshError and backs off for 30s.
- cross-process lock (.devmap/analyze.lock): dead-pid and >15min locks are
  taken over.
- devmap_impact: `depth` (1-5) follows imports transitively, cycle-safe, and
  reports dependentCount, affectedFeatures, isCritical and criticalDependents.
- devmap_map/devmap_flow reuse the provider's cached snapshot instead of
  re-reading and re-scanning on every call.
- prompts: devmap_onboard, devmap_plan_change.
- tests: mcp-freshness.test.ts (21), offline-analyze test proving no AI access
  even with an API key configured, analyze check in the packed-package e2e.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AgTNRXcqugxRyJfMKL4AJ2
@vercel

vercel Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
devmap-web Skipped Skipped Oct 29, 2026 9:30pm UTC

@github-actions

Copy link
Copy Markdown

✅ Welcome ke DevMap!

Terima kasih sudah buat PR. Pastikan checklist ini terpenuhi sebelum review:

  • devmap doctor lolos (tanpa error)
  • Test pnpm test:cli lolos (semua pass)
  • New commands diupdate di docs/commands.md
  • Tidak ada console.log di command files
  • Registry terms sesuai standar (baca docs/guide/05-signal-registry.md)
  • Code style match dengan CONTRIBUTING.md

CI akan jalan otomatis pada setiap update. Kalau gagal, akan muncul link run di komentar ini.

Kalau DevMap membantu, tolong star ya: https://github.com/itsflaid/devmap

Terima kasih kontribusinya! 🙏

@itsflaid itsflaid left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good boy

@itsflaid
itsflaid merged commit d6d7a85 into main Oct 29, 2026
3 checks passed
@itsflaid
itsflaid deleted the feat/mcp-freshness branch October 29, 2026 21:36

This branch was previously deployed

1 inactive deployment
Preview — 81a2a6d4 Deployed Oct 29, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants