nubos-pilot 0.3.0 → 0.4.0

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,132 @@
1
+ ---
2
+ command: np:update-docs
3
+ description: Incremental codebase-doc refresh — diffs current source against .hashes.json, refreshes only affected module docs, and updates the manifest.
4
+ ---
5
+
6
+ # np:update-docs
7
+
8
+ Run after any code change to keep `.nubos-pilot/codebase/` in sync with the
9
+ source. Detects added / changed / removed files, maps them to affected
10
+ modules, dispatches the documenter agent per stale module, and writes back
11
+ updated docs + manifest.
12
+
13
+ Dev-agents must invoke this after writing/editing source. `np:execute-*`
14
+ workflows call it automatically. Humans can call it manually.
15
+
16
+ ## Philosophy
17
+
18
+ <philosophy>
19
+ Docs that lag the code are worse than no docs — agents act on stale facts.
20
+ `np:update-docs` is the backpressure that keeps the shared memory fresh.
21
+ It is cheap when little has changed (diff is empty → no-op) and incremental
22
+ when much has changed (only stale modules re-documented).
23
+
24
+ Runtime-agnostic: the subcommand returns stale-module facts + new module
25
+ stubs; the host dispatches the documenter agent on each; the workflow
26
+ calls `--apply-prose` per module.
27
+ </philosophy>
28
+
29
+ ## Scope Guardrail
30
+
31
+ <scope_guardrail>
32
+ This workflow ONLY writes inside `.nubos-pilot/codebase/`. It NEVER:
33
+
34
+ - rewrites source code
35
+ - renames or removes doc files for modules that still exist
36
+ - regenerates prose for modules that did not change
37
+ </scope_guardrail>
38
+
39
+ ## Downstream Awareness
40
+
41
+ <downstream_awareness>
42
+ - Called from every `np:execute-*` workflow's post-step.
43
+ - Reads `.doc-index.json` to map touched paths → stale docs.
44
+ - Writes `.hashes.json` on completion so the next run has a fresh baseline.
45
+
46
+ If `.doc-index.json` is missing, fall back to a full rescan via
47
+ `np:scan-codebase` instead of guessing.
48
+ </downstream_awareness>
49
+
50
+ ## Single-Call Init
51
+
52
+ ```bash
53
+ PLAN=$(node np-tools.cjs update-docs)
54
+ if [[ "$PLAN" == @file:* ]]; then PLAN=$(cat "${PLAN#@file:}"); fi
55
+ ```
56
+
57
+ Parse: `mode`, `diff_summary` (added/removed/changed/unchanged counts),
58
+ `stale_modules[]`, `added_modules[]`, `removed_modules[]`.
59
+
60
+ If all counts are zero, print "No doc updates needed." and exit.
61
+
62
+ ## Process
63
+
64
+ ### Step 1: Report diff to the user
65
+
66
+ ```
67
+ Diff vs last manifest:
68
+ - Added files: <n>
69
+ - Changed files: <n>
70
+ - Removed files: <n>
71
+
72
+ Stale modules: <n> — prose will be refreshed
73
+ Added modules: <n> — stubs written; prose pending
74
+ Removed modules: <n> — marked for user review
75
+ ```
76
+
77
+ For non-zero stale/added, ask: "Refresh prose now? (yes / no / pick)".
78
+ If "no", exit with stubs-only state — user can run the workflow later.
79
+
80
+ ### Step 2: Dispatch documenter per stale + added module
81
+
82
+ For each module in `stale_modules ++ added_modules`:
83
+
84
+ ```bash
85
+ # Build prompt from facts, dispatch agent, capture JSON to $PROSE_FILE
86
+ node np-tools.cjs update-docs --apply-prose \
87
+ --module "$MODULE_ID" \
88
+ --prose-file "$PROSE_FILE"
89
+ ```
90
+
91
+ ### Step 3: Handle removed modules
92
+
93
+ For `removed_modules`, prompt the user:
94
+
95
+ ```
96
+ Module <id> has no source files anymore. Delete its doc?
97
+ (delete / archive to modules/_archived/ / keep)
98
+ ```
99
+
100
+ Default: archive. The workflow MUST NOT silently delete docs.
101
+
102
+ ### Step 4: Verify manifest is fresh
103
+
104
+ ```bash
105
+ stat -f "%m" .nubos-pilot/codebase/.hashes.json
106
+ ```
107
+
108
+ The `generated_at` in the JSON should be within the last few seconds.
109
+
110
+ ## Output
111
+
112
+ ```
113
+ np:update-docs complete.
114
+
115
+ Diff: +<added> ~<changed> -<removed>
116
+ Refreshed: <n> modules
117
+ Added: <n> modules
118
+ Archived: <n> modules
119
+
120
+ Manifest: .nubos-pilot/codebase/.hashes.json
121
+ ```
122
+
123
+ ## Errors
124
+
125
+ | Code | Trigger | User action |
126
+ |------|---------|-------------|
127
+ | `update-docs-not-initialized` | `.nubos-pilot/` missing | Run `np:new-project` |
128
+ | `update-docs-missing-module` | `--apply-prose` without `--module` | Supply flag |
129
+ | `update-docs-missing-prose` | `--apply-prose` without `--prose-file` | Supply flag |
130
+ | `update-docs-module-not-found` | id does not exist in current scan | Rescan |
131
+ | `update-docs-prose-unreadable` | prose JSON unreadable or invalid | Fix JSON; re-dispatch agent |
132
+ | `manifest-schema-mismatch` | old `.hashes.json` from prior schema | Delete manifest; run `np:scan-codebase` |