Skip to content

feat: /oracle — Product Conscience with AST-powered codebase scanner#671

Open
rafiulnakib wants to merge 13 commits intogarrytan:mainfrom
rafiulnakib:main
Open

feat: /oracle — Product Conscience with AST-powered codebase scanner#671
rafiulnakib wants to merge 13 commits intogarrytan:mainfrom
rafiulnakib:main

Conversation

@rafiulnakib
Copy link
Copy Markdown

Summary

  • /oracle skill — Product memory and intelligence layer. Bootstraps a product map from any codebase, tracks features across sessions, surfaces connections during planning, and warns about anti-patterns.
  • AST-powered scanner (oracle/bin/scan-imports.ts) — Builds import graphs using the TypeScript compiler API. Discovers routes across 10 frameworks (Next.js App/Pages, React Router, SvelteKit, Nuxt, Remix, TanStack Router, Vue Router, Wouter, Astro, Supabase Edge Functions). Classifies route complexity (EASY/MEDIUM/HARD/MEGA), detects circular dependencies via Tarjan's SCC, finds dead code via reachability analysis.
  • Product Conscience resolver{{PRODUCT_CONSCIENCE_READ}} and {{PRODUCT_CONSCIENCE_WRITE}} blocks injected into 19+ skill templates. Every skill silently reads the product map for context and updates it after work completes.
  • 6 modes: bootstrap (first run), inventory (deep page-by-page scan with budgeted sessions), refresh (full re-analysis), update (lightweight git sync), stats (product health dashboard), query (answer questions with product context)
  • Two-tier documentation: Tier 1 = PRODUCT_MAP.md (~12 lines/feature), Tier 2 = per-feature detailed docs at docs/oracle/inventory/

What it does for the user

Run /oracle once on any project. The product conscience activates and silently runs through every gstack skill from that point on — warning about anti-patterns, tracking feature lifecycle, and surfacing connections between features during planning and review.

Key files

Area Files Lines
Scanner oracle/bin/scan-imports.ts, oracle/bin/scanner/*.ts ~5,300
Skill template oracle/SKILL.md.tmpl ~800
Resolver scripts/resolvers/oracle.ts 63
Resolver registry scripts/resolvers/index.ts +2 lines
Build integration package.json +1 build step
E2E test test/skill-e2e-oracle.test.ts 146
Scanner tests oracle/bin/scan-imports.test.ts, oracle/bin/scanner/*.test.ts ~600
Touchfiles test/helpers/touchfiles.ts +10
19 skill templates */SKILL.md.tmpl +2 lines each

Test plan

  • Scanner unit tests: framework detection, route discovery, import graph, circular deps, dead code (Wouter, React Router, Next.js, SvelteKit, Remix, TanStack, Vue, Astro)
  • Resolver tests: READ/WRITE output validation, host-agnostic paths, lean output
  • E2E test: skill-e2e-oracle.test.ts — end-to-end oracle bootstrap via claude -p
  • bun test passes (free tests, <2s)
  • bun run test:evals — E2E eval suite

🤖 Generated with Claude Code

Rafiul Nakib and others added 13 commits March 28, 2026 23:38
Import graph construction via TypeScript compiler API, git co-change
classification (EASY/MEDIUM/HARD/MEGA), Tarjan's SCC for circular deps,
dead code detection, and route discovery for React Router, Next.js,
SvelteKit, Nuxt, Remix, Astro, TanStack Router, Vue Router, and Wouter.
Includes --diff, --dry-run, --git-frequency, --visualize flags and
head_sha staleness detection. 14 fixture directories.
Self-contained HTML import graph at /tmp/oracle-scan-{slug}.html with
color-coded nodes, collapsible subtrees, circular dep highlighting.
ANSI terminal ASCII tree with --max-depth, --no-color, --compact flags.
Plus utils.test.ts for shared scanner utilities.
PRODUCT_CONSCIENCE_READ and PRODUCT_CONSCIENCE_WRITE resolvers inject
~10 lines each into 19 skill templates. Planning skills read the product
map for context. Post-work skills silently update it. oracle/SKILL.md.tmpl
compiles through gen-skill-docs like every other skill.
…lding

Adds typescript to dependencies (gstack's own, not user's project).
Wires oracle scanner into build script. Adds oracle/bin/dist/ to .gitignore.
E2E test scaffolding with touchfile declarations. Documentation updates
across README, CLAUDE.md, ARCHITECTURE.md, docs/skills.md, TODOS.md.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Merges 9 upstream commits including:
- /design-html skill (v0.14.0.0)
- Composable skills + INVOKE_SKILL resolver (v0.13.7.0)
- GStack Learns infrastructure (v0.13.4.0)
- Factory Droid compatibility (v0.13.5.0)
- Security audit round 2 (v0.13.4.0)
- Sidebar prompt injection defense
- Community wave fixes
- Rotating founder resources in /office-hours
- .factory gitignore

Oracle scanner build step preserved in package.json.
Oracle resolvers (PRODUCT_CONSCIENCE_READ/WRITE) merged alongside
new upstream resolvers (LEARNINGS, CONFIDENCE, INVOKE_SKILL, CHANGELOG_WORKFLOW).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
PRODUCT_CONSCIENCE_READ now auto-bootstraps a minimal product map when:
- No docs/oracle/PRODUCT_MAP.md exists
- No prior auto-bootstrap breadcrumb
- Repo has >=20 commits

The bootstrap is silent (no user prompt), lightweight (git log only,
under 60 seconds), and produces compressed one-liner feature entries.

PRODUCT_CONSCIENCE_WRITE now progressively enriches compressed entries
into full entries as skills run, plus a one-time /oracle inventory nudge.

Split "found" path handles both full and compressed entry formats.
35 tests (was 21), all passing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Mechanical regeneration via bun run gen:skill-docs.
All 20 skills with PRODUCT_CONSCIENCE_READ/WRITE blocks updated.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant