#1589·dirsearch

Implement template system steps 1-3

Author: maurosoriaCreated Aug 14, 2026Updated Aug 14, 2026

Scope: implement only steps 1, 2, and 3 of the template-system roadmap.

1. Expose templates through the CLI

  • Add --wordlist-templates for selecting bundled template sources.
  • Add repeatable --template-var KEY=VALUE overrides.
  • Add --template-strict to reject unresolved or invalid placeholders.
  • Add --template-report FILE for a machine-readable expansion report.
  • Preserve existing -w and --wordlist-categories behavior.
  • Document the flags and add CLI/config parsing tests.

2. Compile a deterministic template plan

  • Add dependency-light TemplatePlan, TemplateContext, and TemplateSource data classes.
  • Add compile_template_plan(...) as the validation and planning entry point.
  • Validate placeholders, variables, and referenced categories before the scan starts.
  • Freeze dynamic values such as dates once per plan.
  • Estimate expansion cardinality and enforce a configurable budget.
  • Make deduplication, ordering, and shard assignment deterministic.
  • Preserve source and variable provenance and expose stable to_dict() output for Python and JSON consumers.
  • Test strict mode, invalid inputs, budgets, determinism, and serialization.

3. Select templates from preflight evidence

  • Add a pure TechnologyMatcher that converts fingerprint/preflight evidence into explicit technology matches.
  • Add a pure TemplateSelector that maps matches to template sources.
  • Support --wordlist-templates auto while exposing selected sources.
  • Keep selection evidence-based and inspectable; avoid opaque numeric scoring.
  • Define a deterministic fallback for missing or ambiguous evidence.
  • Include selected templates and supporting evidence in the template report.
  • Test known technologies, mixed evidence, ambiguous evidence, and the fallback path.

Completion criteria

  • Identical inputs produce identical plans and candidate ordering.
  • Python API and CLI expose equivalent structured planning output.
  • Template planning/report failures do not corrupt scan state.
  • Existing wordlist workflows keep passing their regression tests.