Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 141 additions & 0 deletions docs/design/0007-cli-module-split/cli-module-split.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# CLI Module Split

Source backlog item: `docs/method/backlog/asap/PROCESS_cli-module-split.md`
Legend: PROCESS

## Sponsors

- Human: I can inspect the CLI and find command parsing, workspace
mutations, drift logic, and file-collection behavior in separate,
named modules instead of spelunking a 1,000-line monolith.
- Agent: I can change one CLI behavior with a narrow edit scope because
the code is split by owned behavior, not piled into a single entry
file or dissolved into vague utility soup.

## Hill

METHOD keeps the current CLI command surface and behavior, but
reorganizes the implementation so `src/cli.ts` becomes a thin entry
point and runtime-owned modules carry argument parsing/help, workspace
operations, and drift detection in separate homes while workspace-local
document scaffolding stays with the workspace module unless it becomes
independently meaningful.

## Playback Questions

### Human

- [ ] Can I open the CLI code and identify where argument parsing ends
and workspace behavior begins without reading the whole command
stack top to bottom?
- [ ] If I need to review or change only drift behavior, can I find that
logic in one small module instead of tracing through unrelated
`init`, `pull`, `close`, and `status` code?

### Agent

- [ ] Does `src/cli.ts` stay a thin entry point that wires command
parsing and execution together rather than owning most of the
runtime behavior itself?
- [ ] Are the resulting modules named by owned behavior, with stable
tests proving that the CLI still preserves its existing contract?

## Accessibility and Assistive Reading

- Linear truth / reduced-complexity posture: the module layout should be
readable in a terminal or plain editor. File names should describe the
behavior they own so a reviewer can follow the CLI flow without IDE
indexing.
- Non-visual or alternate-reading expectations: this cycle should reduce
navigation burden for screen-reader users, terminal-only operators,
and agents by shortening files and making the seams more explicit in
committed paths and test names.

## Localization and Directionality

- Locale / wording / formatting assumptions: internal symbol and module
names may remain English. No localization work is part of this cycle.
- Logical direction / layout assumptions: the split should improve code
navigation through textual structure, not left/right editor panes or
IDE-specific affordances.

## Agent Inspectability and Explainability

- What must be explicit and deterministic for agents: the module
boundaries and moved responsibilities must be committed in the repo.
A reviewer should be able to point to a concrete file for CLI entry,
arg parsing/help text, workspace operations, drift behavior, and the
workspace-local scaffolding those behaviors still depend on.
- What must be attributable, evidenced, or governed: tests must prove
the CLI contract still holds after the split. This cycle should not
hide behavioral changes inside a refactor. If outputs or command
semantics change, that change needs an explicit test and design note.

## Non-goals

- [ ] Adding new CLI commands or changing the current command surface.
- [ ] Introducing a large public library API for the internal modules.
- [ ] Converting the repo away from TypeScript or rewriting the CLI in
plain JavaScript as part of this cycle.
- [ ] Sneaking in drift-feature expansion such as near-miss hints,
witness packaging, or broader test discovery.
- [ ] Splitting the file into generic `utils` buckets that weaken
ownership instead of clarifying it.

## Decisions To Make

- Which module boundaries are real enough to earn first-class files in
this cycle.
Final direction: split by owned behavior, not by syntactic category.
The first cut should likely separate:
- `src/cli.ts` as entry point plus exported `runCli`
- `src/cli-args.ts` for parse/help behavior
- `src/workspace.ts` for workspace mutation/query behavior
- `src/drift.ts` for playback-question extraction and drift matching
- `src/fs-helpers.ts` and/or `src/text-helpers.ts` only where a helper
is genuinely shared and still semantically coherent
- Whether `Workspace` should remain the primary runtime object.
Current bias: yes. Keep a real runtime-backed workspace type, but make
it smaller by moving drift-only logic out of the class first.
Workspace-local document scaffolding and markdown traversal may remain
in `src/workspace.ts` during this cycle if they stay internal to
workspace behavior.
- How far to take the split in one cycle.
Current bias: enough to remove the monolith risk now, not a full
architectural rewrite.

## Backlog Context

`src/cli.ts` is carrying too many concerns at once: command parsing,
workspace logic, file discovery, markdown extraction, normalization,
and the drift algorithm all live together. Split the CLI into smaller
runtime-owned modules so the code shape matches the repo's own doctrine
about traceability and single responsibility.

Session context:

- The `method drift` PR shipped a useful feature, but review surfaced a
real structural problem: the CLI entry point is becoming a monolith.
- Current `src/cli.ts` is 1,056 lines and mixes:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Minor inconsistency in stated line count.

Line 119 states src/cli.ts is "1,056 lines" but the AI summary claims "962 lines." Pick one number or drop the specific count. Documentation drift is still drift.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/design/0007-cli-module-split/cli-module-split.md` at line 119, The doc
line stating "Current `src/cli.ts` is 1,056 lines" conflicts with the AI summary
claiming "962 lines"; update the statement so both places match or remove the
specific line counts entirely. Locate the text "Current `src/cli.ts` is 1,056
lines" and either replace the number with the verified line count (ensure the AI
summary line is updated too) or change both occurrences to a generic phrase like
"over ~1,000 lines" to avoid future drift.

- top-level command execution
- arg parsing and usage text
- workspace mutation/query behavior
- drift extraction and matching
- recursive file collection
- markdown parsing and text normalization helpers
- The repo's newer system-style JavaScript doctrine pushes toward
runtime-owned modules with clear responsibilities. A successful split
should make the code more honest, not just more fragmented.

What this surfaced:

- `cli.ts` should become a thin entry point that preserves the exported
CLI contract.
- `Workspace` is still probably the right runtime object, but it should
stop owning drift-only logic and helper grab-bags.
- The split should be behavior-centered. Replacing one monolith with a
handful of ambiguous helper files would be a lateral move, not an
improvement.
- Existing CLI tests give this cycle a strong safety rail: the refactor
can stay honest by preserving those contracts while tightening file
boundaries.
23 changes: 0 additions & 23 deletions docs/method/backlog/asap/PROCESS_cli-module-split.md

This file was deleted.

23 changes: 23 additions & 0 deletions docs/method/backlog/cool-ideas/SYNTH_cycle-witness-command.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Cycle Witness Command

Explore a `method witness` command that can package the rerunnable
proof for a cycle close: commands run, artifacts produced, playback
answers, and file references.

Session context:

- External repos using METHOD are starting to want a cleaner way to
package what counted as the witness for a completed cycle.
- The need is broader than any one repo's local tooling. If METHOD
thinks witness packaging is a real pattern, it belongs here instead
of being rediscovered downstream.

What this surfaced:

- A witness command could reduce ad hoc closeout work while staying
faithful to METHOD's requirement that done-claims be reproducible.
- The command should package evidence, not invent it. It would point to
rerunnable proof rather than becoming a substitute for that proof.
- This still feels like a cool idea, not core doctrine, until METHOD
has clearer boundaries around artifact history, closeout flow, and
any future API surface.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Release shaping and user migration docs

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Filename prefix misleads about document type.

The PROCESS_ prefix suggests this document defines an established process, but the content is a problem statement with open questions (lines 22-35) and no defined workflow, steps, or procedures. Either remove the PROCESS_ prefix or convert this into an actual process definition with concrete steps, ownership, and success criteria.

📝 Suggested filename correction
-# Release shaping and user migration docs
+# Release shaping and user migration docs

And rename the file from:

docs/method/backlog/inbox/PROCESS_release-shaping-and-user-migration-docs.md

to:

docs/method/backlog/inbox/IDEA_release-shaping-and-user-migration-docs.md

or

docs/method/backlog/inbox/PROPOSAL_release-shaping-and-user-migration-docs.md
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/method/backlog/inbox/PROCESS_release-shaping-and-user-migration-docs.md`
at line 1, The file named PROCESS_release-shaping-and-user-migration-docs.md is
mis-prefixed because its content is a problem statement with open questions
rather than a defined process; either rename the file to
IDEA_release-shaping-and-user-migration-docs.md or
PROPOSAL_release-shaping-and-user-migration-docs.md to reflect its current
state, or convert the document into a true process by adding concrete steps,
owners (roles or people), acceptance/success criteria, and an explicit workflow
section so the PROCESS_ prefix is justified—update headings and the document
title accordingly.


METHOD needs a clearer way to shape releases, not just cycles. Alongside
`CHANGELOG.md`, the repo should have a structured, user-facing release
surface that explains what is new in a release, why it matters, and how
to migrate from previous versions when migration is required.
Comment on lines +3 to +6

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Vague problem statement lacks evidence and specificity.

The assertion that METHOD "needs a clearer way to shape releases" (line 3) provides no:

  • Evidence of current deficiency
  • Concrete examples of user pain
  • Baseline comparison (what exists now vs. what's needed)
  • Success criteria for "clearer" or "structured"

Add at least one concrete example of a release that failed to communicate effectively, or cite specific user feedback demonstrating the gap. Define measurable success criteria for what "structured" and "user-facing" actually mean in this context.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/method/backlog/inbox/PROCESS_release-shaping-and-user-migration-docs.md`
around lines 3 - 6, The problem statement in the release-shaping doc is too
vague; update the paragraph that claims "METHOD needs a clearer way to shape
releases" (and the surrounding section referencing CHANGELOG.md and the proposed
"release surface") to include one concrete historical example or user quote
showing a release that failed to communicate (e.g., a specific release/version
and the missing migration notes), plus a short baseline of current practice
(what CHANGELOG.md contains today) and 2–3 measurable success criteria for
"structured" and "user-facing" (for example: presence of migration steps per
breaking change, one-page user-facing summary, and <N>% reduction in
migration-related support tickets). Ensure these additions are placed near the
existing METHOD/CHANGELOG.md/release-surface text so reviewers can see the
evidence and criteria inline.


Session context:

- The current release doctrine is intentionally light: `release.md`
says releases happen when externally meaningful behavior changes and
points at `CHANGELOG.md` plus `README.md`.
- That is enough for honesty, but it is not enough for user-facing
release communication. Changelogs are ledger-like. Users often need a
more guided document: what changed, what to look at first, what might
break, and what to do next.
- The gap is especially visible for infrastructure repositories where a
release may change doctrine, CLI behavior, file layout, or expected
workflow. A terse changelog entry is not always the right surface for
helping a user adopt that release.
Comment on lines +10 to +20

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Uncited claims undermine credibility.

Multiple assertions lack supporting evidence:

  • Line 10-12: "current release doctrine is intentionally light" and "says releases happen when..." — cite specific line numbers from release.md or quote the relevant passage.
  • Line 14: "Changelogs are ledger-like" — this is an opinion presented as fact. Define "ledger-like" or remove the subjective characterization.
  • Line 14-16: "Users often need a more guided document" — cite user research, support tickets, or specific feedback that demonstrates this need rather than assuming it.
  • Line 17-18: "The gap is especially visible for infrastructure repositories" — provide at least one concrete example from this or another infrastructure repo showing the gap.
🔍 Suggested improvement with citations
-- The current release doctrine is intentionally light: `release.md`
-  says releases happen when externally meaningful behavior changes and
-  points at `CHANGELOG.md` plus `README.md`.
+- The current release doctrine is intentionally light. Per `release.md` 
+  (lines X-Y): "[exact quote]" — releases happen when externally 
+  meaningful behavior changes, with `CHANGELOG.md` and `README.md` as 
+  primary communication surfaces.
-- That is enough for honesty, but it is not enough for user-facing
-  release communication. Changelogs are ledger-like. Users often need a
-  more guided document: what changed, what to look at first, what might
-  break, and what to do next.
+- That is enough for honesty, but feedback from [cite source or issue] 
+  indicates users need more guidance: what changed, what to prioritize, 
+  what might break, and migration steps.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/method/backlog/inbox/PROCESS_release-shaping-and-user-migration-docs.md`
around lines 10 - 20, Revise the paragraphs in
PROCESS_release-shaping-and-user-migration-docs.md to replace uncited assertions
with evidence: quote or cite the exact lines from release.md that state the
release doctrine (referencing the phrase "releases happen when externally
meaningful behavior changes" or the exact passage), remove or rephrase
subjective language like "Changelogs are ledger-like" (define it if kept), and
add at least one concrete data point or example (e.g., a user research finding,
support ticket excerpt, or a repo-specific example) that demonstrates users
needing a more guided release document—also provide a concrete example showing
the gap for infrastructure repos (a specific repo/PR or changelog entry) so the
claim is supported.


Questions this should answer:

- What makes a release “shaped” rather than just tagged and logged?
- What artifact should accompany a real release besides
`CHANGELOG.md`?
- Should METHOD define a user-facing release note format such as:
summary, what changed, why it matters, breaking changes,
migration/upgrade steps, and links to deeper docs?
- When should a release include explicit migration guidance versus “no
migration required”?
- Where should these artifacts live: `docs/releases/`, a generated
release page, versioned markdown files, or something else?
- How should release shaping relate to cycle closeout and post-merge
ship sync?
Comment on lines +22 to +35

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Unanswered questions without prioritization or ownership.

The seven questions (lines 24-35) lack:

  • Priority: Which questions must be answered first? Which are blockers vs. nice-to-have?
  • Hypotheses: For a backlog document proposing work, include at least a working hypothesis or proposed answer for the core questions.
  • Ownership: Who should answer these questions? When?
  • Scope: Is answering all seven questions in scope for one cycle, or should they be decomposed?

Either prioritize and propose answers to the top 2-3 questions, or explicitly state this document is a scratchpad for future scoping work.

♻️ Proposed structure with prioritization
 Questions this should answer:
 
+**Critical (must answer to proceed):**
+
 - What makes a release "shaped" rather than just tagged and logged?
-- What artifact should accompany a real release besides
-  `CHANGELOG.md`?
 - Should METHOD define a user-facing release note format such as:
   summary, what changed, why it matters, breaking changes,
   migration/upgrade steps, and links to deeper docs?
+
+**Important (affects implementation):**
+
+- What artifact should accompany a real release besides
+  `CHANGELOG.md`?
 - When should a release include explicit migration guidance versus "no
   migration required"?
+
+**Nice-to-have (can defer):**
+
 - Where should these artifacts live: `docs/releases/`, a generated
   release page, versioned markdown files, or something else?
 - How should release shaping relate to cycle closeout and post-merge
   ship sync?
+
+**Proposed answers (working hypotheses):**
+
+- [Add at least one hypothesis here for the critical questions]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Questions this should answer:
- What makes a release “shaped” rather than just tagged and logged?
- What artifact should accompany a real release besides
`CHANGELOG.md`?
- Should METHOD define a user-facing release note format such as:
summary, what changed, why it matters, breaking changes,
migration/upgrade steps, and links to deeper docs?
- When should a release include explicit migration guidance versus “no
migration required”?
- Where should these artifacts live: `docs/releases/`, a generated
release page, versioned markdown files, or something else?
- How should release shaping relate to cycle closeout and post-merge
ship sync?
Questions this should answer:
**Critical (must answer to proceed):**
- What makes a release "shaped" rather than just tagged and logged?
- Should METHOD define a user-facing release note format such as:
summary, what changed, why it matters, breaking changes,
migration/upgrade steps, and links to deeper docs?
**Important (affects implementation):**
- What artifact should accompany a real release besides
`CHANGELOG.md`?
- When should a release include explicit migration guidance versus "no
migration required"?
**Nice-to-have (can defer):**
- Where should these artifacts live: `docs/releases/`, a generated
release page, versioned markdown files, or something else?
- How should release shaping relate to cycle closeout and post-merge
ship sync?
**Proposed answers (working hypotheses):**
- [Add at least one hypothesis here for the critical questions]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/method/backlog/inbox/PROCESS_release-shaping-and-user-migration-docs.md`
around lines 22 - 35, The "Questions this should answer" section lists seven
open bullets but lacks priority, hypotheses, ownership, and scope; update that
section by adding a prioritized subset (mark top 2-3 questions as blockers),
provide a short proposed hypothesis/answer for each prioritized question, assign
clear owners and target dates (e.g., Owner: `@team-member`, Due: YYYY-MM-DD), and
add a scope statement indicating whether the remaining questions are in-scope
for the current cycle or deferred (or mark the doc explicitly as a scratchpad).
Ensure edits are made in the same "Questions this should answer" block so
reviewers can see priority, hypotheses, ownership, and scope together.


What this surfaced:

- METHOD currently knows how to close cycles honestly, but not yet how
to present releases coherently to users.
- `CHANGELOG.md` is necessary, but not always sufficient as the primary
user-facing release document.
- A structured release note / migration surface could become part of the
release method without turning every cycle into release theater.
Comment on lines +1 to +44

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Missing critical backlog metadata and context.

This backlog document lacks essential information for prioritization and execution:

Missing metadata:

  • Owner/assignee (who should drive this?)
  • Priority level (P0/P1/P2 or similar)
  • Estimated scope/complexity (half-cycle? full cycle? multi-cycle?)
  • Target timeline or cycle (should this be addressed before next release?)
  • Dependencies (does this block or depend on other work?)

Missing content:

  • Zero concrete examples: Not a single reference to a specific release, user complaint, or infrastructure repo where the problem manifested
  • No success criteria: How will you know when release shaping is "good enough"?
  • No related work: Are other projects solving this? Is there prior art to reference?

Add a metadata header block and at least two concrete examples of the problem this addresses.

📋 Proposed metadata header
 # Release shaping and user migration docs
 
+**Status:** Backlog inbox  
+**Owner:** [TBD or propose]  
+**Priority:** [P1/P2/P3]  
+**Estimated scope:** [0.5 cycle / 1 cycle / 2+ cycles]  
+**Target cycle:** [TBD or propose]  
+**Dependencies:** None known  
+**Related work:** [Links to similar efforts, if any]
+
 METHOD needs a clearer way to shape releases, not just cycles. Alongside

And add a concrete examples section:

 to migrate from previous versions when migration is required.
 
+## Examples of the problem
+
+1. **[Specific release or repo]:** [Describe what went wrong, user 
+   confusion, or missing guidance]
+2. **[Another example]:** [Additional evidence]
+
 Session context:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/method/backlog/inbox/PROCESS_release-shaping-and-user-migration-docs.md`
around lines 1 - 44, The backlog doc "Release shaping and user migration docs"
is missing required metadata and concrete examples; add a metadata header at the
top including Owner (assignee), Priority (P0/P1/P2), Estimated scope
(half/full/multi-cycle), Target timeline/cycle, Dependencies, and Success
criteria, and then add a "Concrete examples" section with at least two specific
cases (repo name, release version or date, brief symptom and user impact)
showing where lack of release shaping caused problems; ensure the file sections
like the header block and the new "Concrete examples" and "Success criteria" are
clearly labeled so reviewers can find them easily.

Comment on lines +37 to +44

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Observations lack precision and actionable conclusions.

  • Line 39: "METHOD currently knows how to close cycles honestly" — METHOD is a framework/process, not a sentient entity. Rewrite to state what the current process does or doesn't include.
  • Line 41-42: "CHANGELOG.md is necessary, but not always sufficient" — provide at least one concrete example where CHANGELOG.md fell short for users.
  • Line 44: "release theater" — this is subjective and undefined. What specific behaviors constitute "release theater"? Either define the term or remove the value judgment.

Most critically: this section identifies gaps but provides no actionable next steps. Add a "Proposed next steps" or "Recommended action" section that states who should do what by when.

♻️ Proposed rewrite with precision and next steps
 What this surfaced:
 
-- METHOD currently knows how to close cycles honestly, but not yet how
-  to present releases coherently to users.
+- The current cycle closeout process captures work completed and 
+  artifacts produced, but does not synthesize those into user-facing 
+  release communication.
-- `CHANGELOG.md` is necessary, but not always sufficient as the primary
-  user-facing release document.
+- `CHANGELOG.md` is necessary for tracking changes, but [cite specific 
+  release or user feedback] showed users needed additional guidance on 
+  migration steps and breaking changes.
-- A structured release note / migration surface could become part of the
-  release method without turning every cycle into release theater.
+- A structured release note format (summary, migration steps, breaking 
+  changes) could improve release communication while maintaining the 
+  lightweight release doctrine.
+
+**Proposed next steps:**
+
+1. [Owner TBD] Draft a release note template with required and optional 
+   sections (target: [date/cycle])
+2. [Owner TBD] Pilot the template on the next infrastructure release
+3. [Owner TBD] Gather user feedback and iterate
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
What this surfaced:
- METHOD currently knows how to close cycles honestly, but not yet how
to present releases coherently to users.
- `CHANGELOG.md` is necessary, but not always sufficient as the primary
user-facing release document.
- A structured release note / migration surface could become part of the
release method without turning every cycle into release theater.
What this surfaced:
- The current cycle closeout process captures work completed and
artifacts produced, but does not synthesize those into user-facing
release communication.
- `CHANGELOG.md` is necessary for tracking changes, but [cite specific
release or user feedback] showed users needed additional guidance on
migration steps and breaking changes.
- A structured release note format (summary, migration steps, breaking
changes) could improve release communication while maintaining the
lightweight release doctrine.
**Proposed next steps:**
1. [Owner TBD] Draft a release note template with required and optional
sections (target: [date/cycle])
2. [Owner TBD] Pilot the template on the next infrastructure release
3. [Owner TBD] Gather user feedback and iterate
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/method/backlog/inbox/PROCESS_release-shaping-and-user-migration-docs.md`
around lines 37 - 44, Rewrite the paragraph to remove anthropomorphism of
"METHOD" by describing the process capabilities (e.g., "The METHOD release
process closes cycles but does not produce user-facing release summaries"),
replace the vague "CHANGELOG.md is necessary..." line with a concrete example
where CHANGELOG.md failed (e.g., missed breaking API contract or migration steps
for DB schema changes), either define "release theater" with specific behaviors
or remove the phrase, and add a short "Proposed next steps" section that assigns
owners and deadlines (e.g., product writes user-facing release template;
engineering produces migration notes for breaking changes) so the text becomes
precise and actionable referencing the terms "METHOD", "CHANGELOG.md", and
"release theater".

51 changes: 51 additions & 0 deletions docs/method/retro/0007-cli-module-split/cli-module-split.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# CLI Module Split Retro

Design: `docs/design/0007-cli-module-split/cli-module-split.md`
Outcome: hill-met
Drift check: yes

## Summary

This cycle split the CLI monolith into behavior-owned modules without
changing the command surface. `src/cli.ts` is now a thin 97-line entry
point that wires command execution together, while `src/cli-args.ts`,
`src/workspace.ts`, `src/drift.ts`, and `src/errors.ts` carry the
owned runtime behavior. This first cut moved argument parsing and
drift-specific behavior into dedicated modules while leaving
workspace-local document scaffolding inside `src/workspace.ts`. The
existing CLI contract stayed intact:
`npm test`, `npm run build`, and `npm run method -- status` all still
pass after the split.

## Playback Witness

- [Witness Index](./witness/README.md)
- [Playback Witness](./witness/playback.md)
- [Verification Witness](./witness/verification.md)

## Drift

- None recorded.

## New Debt

- None recorded.

## Cool Ideas

- None recorded.

## Backlog Maintenance

- [x] Inbox processed during cycle closeout
- [x] Priorities reviewed
- [x] Dead work buried or merged
- Moved `PROCESS_retro-conversational-closeout` from `inbox/` to
`cool-ideas/`.
- Left `SYNTH_generated-signpost-provenance` as the sole `asap/` item.
- Left `PROCESS_git-branch-workflow-policy`,
`PROCESS_library-api-surface`, and
`PROCESS_system-style-javascript-adoption` in `up-next/` for later
cycle planning.
- Branch tip now also carries the later backlog capture
`PROCESS_release-shaping-and-user-migration-docs` in `inbox/`.
24 changes: 24 additions & 0 deletions docs/method/retro/0007-cli-module-split/witness/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Witness Index

This cycle claims a structural refactor, not a new feature. The proof
rests on committed module boundaries plus rerunnable commands that show
the CLI contract still behaves the same after the split.

## Artifacts

- [playback.md](./playback.md)
Human and agent playback answers for the CLI-module-split cycle.
- [verification.md](./verification.md)
Reproducible commands showing the new `src/` layout, the thinner
entry point, and the unchanged build/test/status truth surfaces.

## Review Notes

- The done-claim is carried by committed source files and rerunnable
commands, not by review prose.
- This witness proves the split happened and that the current CLI
contract still holds. It does not claim a new public API or new CLI
behavior.
- The refactor stays aligned with the repo's system-style JavaScript
direction by keeping a real `Workspace` runtime object instead of
flattening everything into utility functions.
64 changes: 64 additions & 0 deletions docs/method/retro/0007-cli-module-split/witness/playback.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Playback Witness

Date: 2026-04-03

This was a structural refactor cycle. The deliverable is a thinner CLI
entry point and clearer behavior-owned modules, with the existing
command surface preserved.

## Human Playback

### Can I open the CLI code and identify where argument parsing ends and workspace behavior begins without reading the whole command stack top to bottom?

Yes.

The boundaries are now visible from committed file names and grep-able
exports:

- `src/cli.ts` wires execution together
- `src/cli-args.ts` owns parse/help behavior
- `src/workspace.ts` owns workspace mutations and status rendering
- `src/drift.ts` owns playback-question extraction and matching

The human no longer has to scan a 1,000-line single file to answer
basic ownership questions.

### If I need to review or change only drift behavior, can I find that logic in one small module instead of tracing through unrelated `init`, `pull`, `close`, and `status` code?

Yes.

`src/drift.ts` now holds the drift-specific behavior directly, and
`Workspace.detectDrift()` delegates to it. The refactor did not hide
drift behind generic helpers or mixed command code.

## Agent Playback

### Does `src/cli.ts` stay a thin entry point that wires command parsing and execution together rather than owning most of the runtime behavior itself?

Yes.

`src/cli.ts` is now 97 lines and contains:

- the exported `runCli`
- the exported `main`
- the entry-point bootstrap

It no longer defines `Workspace`, drift extraction, or generic file
collection behavior.

### Are the resulting modules named by owned behavior, with stable tests proving that the CLI still preserves its existing contract?

Yes.

The module names describe owned behavior directly, and the existing CLI
tests still pass after the split. Two added structural tests also prove
that:

- the behavior-owned files exist
- `src/cli.ts` no longer contains the old monolith seams

## Outcome

The hill is met. The CLI is structurally clearer, the entry point is
thin again, and the command behavior stayed stable under rerunnable
test/build/status verification.
Loading
Loading