Skip to content

T-MBOK-lib-util-modules

Status: closed/done · Impact: medium · Complexity: large

Five scaffolders mint their own todayUtc(), three carry a private SLUG_RE, six sites re-implement frontmatter regexes, and _schema_patterns.ts is a 225-line library misfiled beside entry scripts. Single-home the entity-agnostic helpers under lib/util so every port task imports instead of copying.

LocationRole today
plugin/scripts/_schema_patterns.tsschema-pattern loader library misfiled in the scripts dir (3 importers + tests)
plugin/scripts/new_task.ts#todayUtcone of ×5 private date stampers across scaffolders
plugin/lib/util/yaml.tsthe only util module; no parse export — callers import npm yaml directly
plugin/scripts/worktree_scope_guard.ts#isLinkedWorktreeworktree helper duplicated against count_inflight’s listWorktreeBasenames
plugin/cli/backlog_cli/create.tsinline gh pr helpers

lib/util/{date, slug, wikilinks, frontmatter, paths, git, gh, schema_patterns}.ts exist with tests; every duplication site imports the util; _schema_patterns.ts moves out of scripts/ via git mv; util/yaml.ts gains a parse export and the inline import { parse } from "yaml" sites migrate to it.

  1. git mv plugin/scripts/_schema_patterns.ts plugin/lib/util/schema_patterns.ts; fix importers. Own commit.
  2. Add date/slug/wikilinks/frontmatter/paths, consolidating each duplication cluster; rewrite call sites. One commit per module.
  3. Extract git/gh helpers from worktree_scope_guard, count_inflight_tasks, backlog_cli, lease_cli.
  4. Add the parse export to util/yaml.ts; migrate direct npm-yaml importers.
  5. bunx tsc --noEmit + bun test after each step.
LocationKindChange
plugin/scripts/_schema_patterns.tsdeletegit mv to lib/util/schema_patterns.ts
plugin/lib/util/modifyseven new modules + tests land here
plugin/lib/util/yaml.tsmodifyadd parse export
plugin/scripts/*.tsmodifyimport utils instead of private copies
plugin/cli/backlog_cli/create.tsmodifygh helpers → util/gh
plugin/skills/standard-new/new_standard.tsmodify_schema_patterns import path
  • AC-1: grep -rn "function todayUtc\|SLUG_RE\s*=" plugin/ shows exactly one definition of each, under lib/util/ (or lib/model/identifier.ts for slug).
  • AC-2: plugin/scripts/_schema_patterns.ts is gone; git log --follow plugin/lib/util/schema_patterns.ts shows pre-move history.
  • AC-3: no file under plugin/ outside lib/util/yaml.ts imports the npm yaml package directly.
  • AC-4: full bun test + bunx tsc --noEmit green.
  • Behavior changes to any consumer — this is import-path consolidation.
  • sdlc.yaml config loading (T-KO35-config-sdlc-yaml).
  • The prs_field split (T-JJZ3-lib-root-tidy merges its generic half into util/frontmatter.ts).
  • none hard. Land before the port tasks so they import final util paths.
  • docs/plans/op-substrate-full-sweep.md §1e drive-out map; D-0007 §Migration step 2 (promote the obvious infra).

← Back to Tasks