@haposoft/cafekit 0.8.12 → 0.8.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,262 @@
1
+ ---
2
+ name: hapo:docs
3
+ description: "Create, update, summarize, or reconstruct project/system documentation from source code. Use reconstruct mode for as-is documentation of existing or legacy systems with evidence and uncertainty tracking."
4
+ version: 1.0.0
5
+ argument-hint: "[init|update|summarize|reconstruct] [scope]"
6
+ ---
7
+
8
+ # Docs
9
+
10
+ Project documentation workflow for CafeKit.
11
+
12
+ `hapo:docs` covers two related but distinct jobs:
13
+
14
+ 1. **Normal project docs** — create, update, or summarize living project documentation.
15
+ 2. **As-is reconstruction** — rebuild current-state system documentation from source code, especially for existing or legacy systems with missing documents.
16
+
17
+ ## Command Forms
18
+
19
+ ```text
20
+ /hapo:docs
21
+ /hapo:docs init
22
+ /hapo:docs update
23
+ /hapo:docs summarize
24
+ /hapo:docs reconstruct <scope>
25
+ ```
26
+
27
+ ## Default Behavior
28
+
29
+ Parse the user intent before selecting a mode.
30
+
31
+ | Intent signal | Mode |
32
+ |---|---|
33
+ | Existing system, legacy system, source-to-docs, as-is, reverse documentation, or requirement reconstruction | `reconstruct` |
34
+ | Missing docs, initialize docs, bootstrap docs | `init` |
35
+ | Existing docs need refresh after code changes | `update` |
36
+ | Short overview, quick codebase summary, summarize docs | `summarize` |
37
+
38
+ When `/hapo:docs` has no clear mode:
39
+
40
+ 1. Read the docs root from `.claude/runtime.json`.
41
+ 2. If the docs root is missing, choose `init`.
42
+ 3. If the docs root exists and user did not request only a summary, choose `update`.
43
+ 4. Ask one concise clarification only when choosing between normal docs and as-is reconstruction would change the output materially.
44
+
45
+ Do not show a menu when prompt intent is already clear.
46
+
47
+ ## Output Roots
48
+
49
+ Read `.claude/runtime.json` first. Use:
50
+
51
+ ```json
52
+ {
53
+ "paths": {
54
+ "docs": "docs"
55
+ }
56
+ }
57
+ ```
58
+
59
+ Default docs root: `docs/`.
60
+
61
+ Normal docs live directly under the docs root:
62
+
63
+ ```text
64
+ docs/
65
+ ├── project-overview-pdr.md
66
+ ├── codebase-summary.md
67
+ ├── system-architecture.md
68
+ ├── code-standards.md
69
+ ├── design-guidelines.md
70
+ ├── deployment-guide.md
71
+ └── project-roadmap.md
72
+ ```
73
+
74
+ Reconstructed as-is docs live under:
75
+
76
+ ```text
77
+ docs/as-is/<scope-slug>/
78
+ ├── overview.html
79
+ ├── reconstruction.json
80
+ ├── system-overview.md
81
+ ├── requirements-as-is.md
82
+ ├── roles-and-permissions.md
83
+ ├── entities-and-statuses.md
84
+ ├── business-rules.md
85
+ ├── integrations.md
86
+ ├── architecture-c4.md
87
+ ├── constraints-risks-and-decisions.md
88
+ ├── glossary.md
89
+ ├── evidence-map.md
90
+ └── unknowns-and-assumptions.md
91
+ ```
92
+
93
+ ## Subcommands
94
+
95
+ ### `init`
96
+
97
+ Create the standard project docs set from the current source code.
98
+
99
+ Use when:
100
+ - the repository has code but no useful docs
101
+ - the user asks to create project docs
102
+ - SessionStart docs-sync reports missing documentation
103
+
104
+ Load:
105
+ - `references/standard-docs-workflow.md`
106
+ - `references/init-workflow.md`
107
+
108
+ ### `update`
109
+
110
+ Refresh existing docs after code changes.
111
+
112
+ Use when:
113
+ - docs exist and source code changed
114
+ - the user asks to update or refresh docs
115
+ - docs-sync reports stale docs
116
+
117
+ Load:
118
+ - `references/standard-docs-workflow.md`
119
+ - `references/update-workflow.md`
120
+
121
+ ### `summarize`
122
+
123
+ Create or update only `codebase-summary.md`.
124
+
125
+ Use when:
126
+ - the user asks for a quick project summary
127
+ - downstream work needs orientation but not full docs
128
+
129
+ Load:
130
+ - `references/standard-docs-workflow.md`
131
+ - `references/summarize-workflow.md`
132
+
133
+ ### `reconstruct`
134
+
135
+ Rebuild current-state, as-is system documentation from source code.
136
+
137
+ Use when the user asks for:
138
+ - legacy system documentation
139
+ - source-code-to-documentation
140
+ - current system requirements
141
+ - as-is requirements
142
+ - requirement reconstruction
143
+ - reverse documentation
144
+ - Japanese-style legacy system modernization discovery
145
+
146
+ Load:
147
+ - `references/reconstruct-workflow.md`
148
+ - `templates/reconstruction.json`
149
+ - `templates/requirements-as-is.md`
150
+ - `templates/evidence-map.md`
151
+ - `templates/unknowns-and-assumptions.md`
152
+ - `templates/reconstruct-overview.html`
153
+
154
+ ## Reconstruction Is Not Specs
155
+
156
+ `hapo:docs reconstruct` MUST NOT:
157
+
158
+ - design future behavior
159
+ - add new requirements
160
+ - create implementation tasks
161
+ - create `specs/<feature>/`
162
+ - run `/hapo:develop`
163
+ - claim full business intent from code alone
164
+
165
+ Correct handoff:
166
+
167
+ ```text
168
+ /hapo:docs reconstruct <scope>
169
+ -> human review of as-is docs
170
+ -> /hapo:specs <modernization or change request>
171
+ -> /hapo:develop <feature>
172
+ ```
173
+
174
+ ## Reconstruction Evidence Rules
175
+
176
+ Every major finding in reconstructed docs MUST be classified:
177
+
178
+ ```text
179
+ Type: Observed | Inferred | Unknown
180
+ Confidence: High | Medium | Low
181
+ Evidence: file path, symbol, route, schema, test, or config
182
+ ```
183
+
184
+ Definitions:
185
+
186
+ - `Observed`: directly visible in source code, tests, schemas, route definitions, config, or docs.
187
+ - `Inferred`: likely behavior derived from multiple signals, but not directly proven.
188
+ - `Unknown`: cannot be established from available evidence.
189
+
190
+ Do not hide uncertainty. Preserving unknowns is part of the output.
191
+
192
+ ## Scope Discipline
193
+
194
+ Start with the narrowest useful scope.
195
+
196
+ For broad inputs such as `.`, `/`, `whole repo`, or `entire system`:
197
+
198
+ 1. Run a lightweight structure scout first.
199
+ 2. Split the project into modules or bounded contexts.
200
+ 3. Ask the user to pick a module if the first pass cannot safely choose one.
201
+
202
+ Prefer:
203
+
204
+ ```text
205
+ /hapo:docs reconstruct apps/admin
206
+ /hapo:docs reconstruct modules/expense-approval
207
+ /hapo:docs reconstruct src/features/order
208
+ ```
209
+
210
+ Avoid reconstructing a large monolith in one pass unless the user explicitly accepts lower precision.
211
+
212
+ ## Agent And Tool Fit
213
+
214
+ Normal docs workflows reuse the CafeKit docs stack already shipped in the package:
215
+
216
+ - use `hapo:inspect` or targeted reads to scout source scope
217
+ - use `docs-keeper` for evidence-backed docs writing when delegation is available
218
+ - use `.claude/scripts/validate-docs.cjs <docs-root>` after create/update work
219
+ - use `.claude/scripts/validate-docs-reconstruct.cjs <docs-root>/as-is/<scope-slug>` before a reconstructed bundle is handed to human review
220
+
221
+ The upstream Research docs workflow names a `docs-manager` agent. CafeKit ships `docs-keeper` instead; keep the same scouting, size-check, and validation discipline while using the packaged agent contract.
222
+
223
+ `reconstruct` may use the same scout patterns, but it writes a scoped as-is bundle and must keep uncertainty visible.
224
+
225
+ ## Best-Practice Basis
226
+
227
+ Use these documentation principles:
228
+
229
+ - **Docs as Code**: docs live in the repo and are reviewed like code.
230
+ - **C4 Model**: use system context/container/component views when architecture is relevant.
231
+ - **arc42**: capture context, building blocks, runtime behavior, deployment, risks, and decisions when useful.
232
+ - **Diataxis**: separate explanation, reference, and how-to content instead of dumping one long file.
233
+ - **ADR discipline**: if code reveals important architectural decisions, record them as recovered decision notes, not guesses.
234
+
235
+ ## Required Final Report
236
+
237
+ For any `hapo:docs` run, report:
238
+
239
+ - files created or updated
240
+ - scope analyzed
241
+ - evidence quality
242
+ - unresolved questions
243
+ - recommended next command, if any
244
+
245
+ For `reconstruct`, the recommended next command is usually:
246
+
247
+ ```text
248
+ /hapo:specs <change request based on approved as-is docs>
249
+ ```
250
+
251
+ ## References
252
+
253
+ - `references/standard-docs-workflow.md`
254
+ - `references/init-workflow.md`
255
+ - `references/update-workflow.md`
256
+ - `references/summarize-workflow.md`
257
+ - `references/reconstruct-workflow.md`
258
+ - `templates/reconstruction.json`
259
+ - `templates/requirements-as-is.md`
260
+ - `templates/evidence-map.md`
261
+ - `templates/unknowns-and-assumptions.md`
262
+ - `templates/reconstruct-overview.html`
@@ -0,0 +1,132 @@
1
+ # Init Workflow
2
+
3
+ Use with `/hapo:docs init`.
4
+
5
+ ## Goal
6
+
7
+ Create a first evidence-backed documentation baseline for a repository that already has source code but lacks useful project docs.
8
+
9
+ The first run should make future agents faster without presenting guesses as project truth.
10
+
11
+ ## Inputs
12
+
13
+ Resolve the docs root from `.claude/runtime.json` first. Default to `docs/`.
14
+
15
+ Read or scout:
16
+
17
+ - `README.md`, `CLAUDE.md`, `AGENTS.md`, and root instructions that exist
18
+ - package/workspace manifests, lock files, build config, runtime config
19
+ - source directories that actually exist
20
+ - tests, migrations, schemas, routes, CI, deployment config
21
+ - current docs root if it exists but is incomplete
22
+
23
+ Do not hardcode `src/` when a project uses `apps/`, `packages/`, `cmd/`, `internal/`, `modules/`, or another structure.
24
+
25
+ ## Required Baseline
26
+
27
+ Create or update the useful core docs below:
28
+
29
+ | File | Purpose | Creation rule |
30
+ |---|---|---|
31
+ | `README.md` | Entry point and quick commands | Update if needed; keep concise |
32
+ | `<docs-root>/project-overview-pdr.md` | Product purpose, actors, capabilities, constraints | Core |
33
+ | `<docs-root>/codebase-summary.md` | Project structure, tech stack, major runtime paths | Core |
34
+ | `<docs-root>/code-standards.md` | Observed conventions, commands, code quality rules | Core |
35
+ | `<docs-root>/system-architecture.md` | Boundaries, components, runtime/data flow | Core |
36
+ | `<docs-root>/project-roadmap.md` | Current state, milestones, known follow-up areas | Core when evidence exists |
37
+ | `<docs-root>/deployment-guide.md` | Build/deploy/runtime config | Optional when deployment evidence exists |
38
+ | `<docs-root>/design-guidelines.md` | UI/design conventions | Optional when UI evidence exists |
39
+
40
+ Do not create a large document solely to fill the table. If a core file cannot be grounded yet, create the smallest useful shell and put unresolved questions at the end.
41
+
42
+ ## Workflow
43
+
44
+ ### Phase 0: Preflight
45
+
46
+ 1. Read repo instructions and runtime docs root.
47
+ 2. Detect whether docs already exist.
48
+ 3. If user specifically asked `init` and docs exist, preserve existing content:
49
+ - read it first
50
+ - merge or add missing baseline sections
51
+ - do not overwrite human-written docs blind
52
+ 4. Build a no-scan list for ignored, generated, vendor, cache, secret, and credential paths.
53
+
54
+ ### Phase 1: Structure Scout
55
+
56
+ Run a lightweight source scout before deep reading:
57
+
58
+ 1. List top-level directories and key manifests.
59
+ 2. Count file/LOC shape by existing source areas where practical.
60
+ 3. Identify project type:
61
+ - language/framework
62
+ - package manager/build system
63
+ - app/service boundaries
64
+ - UI/API/worker/job/deployment surfaces
65
+ 4. Split large repositories into scoped source areas.
66
+
67
+ Use `hapo:inspect` when source discovery spans multiple directories. Prefer targeted reads when the repo is small.
68
+
69
+ ### Phase 2: Evidence Scout
70
+
71
+ Collect evidence for docs authorship:
72
+
73
+ | Topic | Evidence examples |
74
+ |---|---|
75
+ | Tech stack | package manifests, `go.mod`, `pyproject.toml`, build files |
76
+ | Commands | scripts, Makefiles, CI jobs |
77
+ | Runtime entry points | app bootstrap, routes, controllers, server main files |
78
+ | Data model | schemas, migrations, models, DTOs |
79
+ | Architecture | imports between modules, service boundaries, deploy config |
80
+ | Testing | test commands, test directories, fixtures |
81
+ | UI/design | shared components, tokens, styles, screenshots when present |
82
+
83
+ Merge scout results into a concise context summary. Keep file references with each important claim.
84
+
85
+ ### Phase 3: Docs Authoring
86
+
87
+ Delegate the merged context to `docs-keeper` when available. Otherwise follow its verification discipline in the main context.
88
+
89
+ Authoring rules:
90
+
91
+ 1. Read code before documenting code.
92
+ 2. Verify referenced paths, commands, config keys, endpoints, and symbols before naming them.
93
+ 3. Record observed conventions as observed; do not turn folder guesses into standards.
94
+ 4. Use relative links among docs only after confirming targets exist.
95
+ 5. Add unresolved questions to any doc whose important claim is not yet verifiable.
96
+
97
+ ### Phase 4: Size Discipline
98
+
99
+ After generation:
100
+
101
+ 1. Check markdown LOC in the docs root.
102
+ 2. Use `docs.maxLoc` from session/runtime context when provided; default to 800 lines.
103
+ 3. If a file crosses the limit:
104
+ - split on semantic boundaries
105
+ - make an `index.md` for the topic when a document becomes a folder
106
+ - keep links from the original entry point
107
+ 4. Report any intentionally accepted oversized file.
108
+
109
+ ### Phase 5: Validation And Tracking
110
+
111
+ 1. Run `.claude/scripts/validate-docs.cjs <docs-root>` when available.
112
+ 2. Fix broken internal doc links that can be resolved from evidence.
113
+ 3. If docs-sync uses `<docs-root>/.sync_hash`, update it only after the docs reflect current source state.
114
+
115
+ ## Required Final Report
116
+
117
+ Report:
118
+
119
+ - docs root used
120
+ - source areas scouted
121
+ - files created or updated
122
+ - validation result
123
+ - evidence gaps
124
+ - unresolved questions
125
+
126
+ Recommended next command:
127
+
128
+ ```text
129
+ /hapo:docs update
130
+ ```
131
+
132
+ after meaningful source changes.