@lamentis/naome 1.1.2 → 1.2.1

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.
Files changed (204) hide show
  1. package/Cargo.lock +2 -2
  2. package/Cargo.toml +1 -1
  3. package/LICENSE +180 -21
  4. package/README.md +49 -6
  5. package/bin/naome-node.js +2 -1579
  6. package/bin/naome.js +68 -16
  7. package/crates/naome-cli/Cargo.toml +1 -1
  8. package/crates/naome-cli/src/check_commands.rs +135 -0
  9. package/crates/naome-cli/src/cli_args.rs +5 -0
  10. package/crates/naome-cli/src/dispatcher.rs +37 -0
  11. package/crates/naome-cli/src/install_bridge.rs +83 -0
  12. package/crates/naome-cli/src/main.rs +60 -341
  13. package/crates/naome-cli/src/prompt_commands.rs +68 -0
  14. package/crates/naome-cli/src/quality_commands.rs +229 -0
  15. package/crates/naome-cli/src/simple_commands.rs +53 -0
  16. package/crates/naome-cli/src/workflow_commands.rs +153 -0
  17. package/crates/naome-core/Cargo.toml +1 -1
  18. package/crates/naome-core/src/decision/checks.rs +64 -0
  19. package/crates/naome-core/src/decision/idle.rs +67 -0
  20. package/crates/naome-core/src/decision/json.rs +36 -0
  21. package/crates/naome-core/src/decision/states.rs +165 -0
  22. package/crates/naome-core/src/decision.rs +131 -353
  23. package/crates/naome-core/src/harness_health/integrity.rs +96 -0
  24. package/crates/naome-core/src/harness_health.rs +14 -126
  25. package/crates/naome-core/src/install_plan.rs +5 -0
  26. package/crates/naome-core/src/intent/classifier.rs +171 -0
  27. package/crates/naome-core/src/intent/envelope.rs +108 -0
  28. package/crates/naome-core/src/intent/legacy.rs +138 -0
  29. package/crates/naome-core/src/intent/legacy_response.rs +76 -0
  30. package/crates/naome-core/src/intent/model.rs +71 -0
  31. package/crates/naome-core/src/intent/patterns.rs +170 -0
  32. package/crates/naome-core/src/intent/resolver.rs +162 -0
  33. package/crates/naome-core/src/intent/resolver_active.rs +17 -0
  34. package/crates/naome-core/src/intent/resolver_baseline.rs +55 -0
  35. package/crates/naome-core/src/intent/resolver_catalog.rs +167 -0
  36. package/crates/naome-core/src/intent/resolver_policy.rs +72 -0
  37. package/crates/naome-core/src/intent/resolver_shared.rs +55 -0
  38. package/crates/naome-core/src/intent/risk.rs +40 -0
  39. package/crates/naome-core/src/intent/segment.rs +170 -0
  40. package/crates/naome-core/src/intent.rs +64 -879
  41. package/crates/naome-core/src/journal.rs +9 -20
  42. package/crates/naome-core/src/lib.rs +15 -0
  43. package/crates/naome-core/src/paths.rs +3 -1
  44. package/crates/naome-core/src/quality/adapter_support.rs +89 -0
  45. package/crates/naome-core/src/quality/adapters.rs +131 -0
  46. package/crates/naome-core/src/quality/baseline.rs +75 -0
  47. package/crates/naome-core/src/quality/checks/duplicate_blocks.rs +175 -0
  48. package/crates/naome-core/src/quality/checks/near_duplicates.rs +130 -0
  49. package/crates/naome-core/src/quality/checks.rs +228 -0
  50. package/crates/naome-core/src/quality/cleanup.rs +84 -0
  51. package/crates/naome-core/src/quality/config.rs +102 -0
  52. package/crates/naome-core/src/quality/config_support.rs +24 -0
  53. package/crates/naome-core/src/quality/mod.rs +108 -0
  54. package/crates/naome-core/src/quality/scanner/repo_paths.rs +103 -0
  55. package/crates/naome-core/src/quality/scanner.rs +379 -0
  56. package/crates/naome-core/src/quality/structure/adapters.rs +84 -0
  57. package/crates/naome-core/src/quality/structure/checks/basic.rs +153 -0
  58. package/crates/naome-core/src/quality/structure/checks/directory.rs +144 -0
  59. package/crates/naome-core/src/quality/structure/checks/pairing.rs +63 -0
  60. package/crates/naome-core/src/quality/structure/checks.rs +124 -0
  61. package/crates/naome-core/src/quality/structure/classify/roles.rs +188 -0
  62. package/crates/naome-core/src/quality/structure/classify.rs +94 -0
  63. package/crates/naome-core/src/quality/structure/config.rs +89 -0
  64. package/crates/naome-core/src/quality/structure/defaults.rs +107 -0
  65. package/crates/naome-core/src/quality/structure/mod.rs +77 -0
  66. package/crates/naome-core/src/quality/structure/model.rs +124 -0
  67. package/crates/naome-core/src/quality/types.rs +292 -0
  68. package/crates/naome-core/src/route/builtin_checks.rs +155 -0
  69. package/crates/naome-core/src/route/builtin_context.rs +73 -0
  70. package/crates/naome-core/src/route/builtin_integrity.rs +49 -0
  71. package/crates/naome-core/src/route/builtin_require.rs +40 -0
  72. package/crates/naome-core/src/route/context.rs +180 -0
  73. package/crates/naome-core/src/route/execution.rs +96 -0
  74. package/crates/naome-core/src/route/execution_baselines.rs +146 -0
  75. package/crates/naome-core/src/route/execution_support.rs +57 -0
  76. package/crates/naome-core/src/route/execution_tasks.rs +71 -0
  77. package/crates/naome-core/src/route/git_ops.rs +72 -0
  78. package/crates/naome-core/src/route/quality_gate.rs +73 -0
  79. package/crates/naome-core/src/route/quality_gate_config.rs +126 -0
  80. package/crates/naome-core/src/route/quality_gate_snapshot.rs +69 -0
  81. package/crates/naome-core/src/route/worktree.rs +75 -0
  82. package/crates/naome-core/src/route/worktree_files.rs +32 -0
  83. package/crates/naome-core/src/route/worktree_plan.rs +131 -0
  84. package/crates/naome-core/src/route.rs +44 -1155
  85. package/crates/naome-core/src/task_state/admission.rs +63 -0
  86. package/crates/naome-core/src/task_state/admission_proof.rs +72 -0
  87. package/crates/naome-core/src/task_state/api.rs +130 -0
  88. package/crates/naome-core/src/task_state/commit_gate.rs +138 -0
  89. package/crates/naome-core/src/task_state/compact_proof.rs +160 -0
  90. package/crates/naome-core/src/task_state/completed_refresh.rs +89 -0
  91. package/crates/naome-core/src/task_state/completion.rs +72 -0
  92. package/crates/naome-core/src/task_state/deleted_paths.rs +47 -0
  93. package/crates/naome-core/src/task_state/diff.rs +95 -0
  94. package/crates/naome-core/src/task_state/evidence.rs +154 -0
  95. package/crates/naome-core/src/task_state/git_io.rs +86 -0
  96. package/crates/naome-core/src/task_state/git_parse.rs +86 -0
  97. package/crates/naome-core/src/task_state/git_refs.rs +37 -0
  98. package/crates/naome-core/src/task_state/human_review_state.rs +31 -0
  99. package/crates/naome-core/src/task_state/mod.rs +38 -0
  100. package/crates/naome-core/src/task_state/process_guard.rs +40 -0
  101. package/crates/naome-core/src/task_state/progress.rs +123 -0
  102. package/crates/naome-core/src/task_state/proof.rs +139 -0
  103. package/crates/naome-core/src/task_state/proof_entry.rs +66 -0
  104. package/crates/naome-core/src/task_state/proof_model.rs +70 -0
  105. package/crates/naome-core/src/task_state/proof_sources.rs +76 -0
  106. package/crates/naome-core/src/task_state/push_gate.rs +49 -0
  107. package/crates/naome-core/src/task_state/reconcile.rs +7 -0
  108. package/crates/naome-core/src/task_state/repair.rs +168 -0
  109. package/crates/naome-core/src/task_state/shape.rs +117 -0
  110. package/crates/naome-core/src/task_state/task_diff_api.rs +170 -0
  111. package/crates/naome-core/src/task_state/task_records.rs +131 -0
  112. package/crates/naome-core/src/task_state/task_references.rs +126 -0
  113. package/crates/naome-core/src/task_state/types.rs +87 -0
  114. package/crates/naome-core/src/task_state/util.rs +137 -0
  115. package/crates/naome-core/src/verification/render.rs +122 -0
  116. package/crates/naome-core/src/verification.rs +177 -58
  117. package/crates/naome-core/src/verification_contract.rs +49 -21
  118. package/crates/naome-core/src/workflow/integrity.rs +123 -0
  119. package/crates/naome-core/src/workflow/integrity_normalize.rs +7 -0
  120. package/crates/naome-core/src/workflow/integrity_support.rs +110 -0
  121. package/crates/naome-core/src/workflow/mod.rs +18 -0
  122. package/crates/naome-core/src/workflow/mutation.rs +68 -0
  123. package/crates/naome-core/src/workflow/output.rs +111 -0
  124. package/crates/naome-core/src/workflow/phase_inference.rs +73 -0
  125. package/crates/naome-core/src/workflow/phases.rs +169 -0
  126. package/crates/naome-core/src/workflow/policy.rs +156 -0
  127. package/crates/naome-core/src/workflow/processes.rs +91 -0
  128. package/crates/naome-core/src/workflow/types.rs +42 -0
  129. package/crates/naome-core/tests/decision.rs +24 -118
  130. package/crates/naome-core/tests/harness_health.rs +5 -0
  131. package/crates/naome-core/tests/intent.rs +97 -792
  132. package/crates/naome-core/tests/intent_support/mod.rs +133 -0
  133. package/crates/naome-core/tests/intent_v2.rs +90 -0
  134. package/crates/naome-core/tests/quality.rs +319 -0
  135. package/crates/naome-core/tests/quality_structure.rs +116 -0
  136. package/crates/naome-core/tests/quality_structure_adapters.rs +98 -0
  137. package/crates/naome-core/tests/quality_structure_policy.rs +125 -0
  138. package/crates/naome-core/tests/quality_structure_support/mod.rs +249 -0
  139. package/crates/naome-core/tests/repo_support/mod.rs +16 -0
  140. package/crates/naome-core/tests/repo_support/repo.rs +113 -0
  141. package/crates/naome-core/tests/repo_support/repo_factories.rs +99 -0
  142. package/crates/naome-core/tests/repo_support/repo_helpers.rs +123 -0
  143. package/crates/naome-core/tests/repo_support/routes.rs +81 -0
  144. package/crates/naome-core/tests/repo_support/verification.rs +168 -0
  145. package/crates/naome-core/tests/repo_support/verification_values.rs +135 -0
  146. package/crates/naome-core/tests/route.rs +1 -1476
  147. package/crates/naome-core/tests/route_baseline.rs +86 -0
  148. package/crates/naome-core/tests/route_completion.rs +141 -0
  149. package/crates/naome-core/tests/route_harness_refresh.rs +135 -0
  150. package/crates/naome-core/tests/route_user_diff.rs +198 -0
  151. package/crates/naome-core/tests/route_worktree.rs +54 -0
  152. package/crates/naome-core/tests/task_state.rs +60 -429
  153. package/crates/naome-core/tests/task_state_compact.rs +110 -0
  154. package/crates/naome-core/tests/task_state_compact_support/mod.rs +5 -0
  155. package/crates/naome-core/tests/task_state_compact_support/repo.rs +130 -0
  156. package/crates/naome-core/tests/task_state_compact_support/states.rs +151 -0
  157. package/crates/naome-core/tests/task_state_support/mod.rs +163 -0
  158. package/crates/naome-core/tests/task_state_support/states.rs +84 -0
  159. package/crates/naome-core/tests/verification.rs +4 -45
  160. package/crates/naome-core/tests/verification_contract.rs +22 -78
  161. package/crates/naome-core/tests/workflow_integrity.rs +85 -0
  162. package/crates/naome-core/tests/workflow_policy.rs +139 -0
  163. package/crates/naome-core/tests/workflow_support/mod.rs +194 -0
  164. package/installer/agents.js +90 -0
  165. package/installer/context.js +67 -0
  166. package/installer/filesystem.js +166 -0
  167. package/installer/flows.js +84 -0
  168. package/installer/git-boundary.js +170 -0
  169. package/installer/git-hook-content.js +36 -0
  170. package/installer/git-hooks.js +134 -0
  171. package/installer/git-local.js +2 -0
  172. package/installer/git-shared.js +35 -0
  173. package/installer/harness-file-ops.js +140 -0
  174. package/installer/harness-files.js +56 -0
  175. package/installer/harness-verification.js +123 -0
  176. package/installer/install-plan.js +66 -0
  177. package/installer/main.js +25 -0
  178. package/installer/manifest-state.js +167 -0
  179. package/installer/native-build.js +24 -0
  180. package/installer/native-format.js +6 -0
  181. package/installer/native.js +162 -0
  182. package/installer/output.js +131 -0
  183. package/installer/version.js +32 -0
  184. package/native/darwin-arm64/naome +0 -0
  185. package/native/linux-x64/naome +0 -0
  186. package/package.json +3 -2
  187. package/templates/naome-root/.naome/bin/check-harness-health.js +66 -85
  188. package/templates/naome-root/.naome/bin/check-task-state.js +9 -10
  189. package/templates/naome-root/.naome/bin/naome.js +51 -76
  190. package/templates/naome-root/.naome/manifest.json +22 -18
  191. package/templates/naome-root/.naome/repository-quality-baseline.json +5 -0
  192. package/templates/naome-root/.naome/repository-quality.json +24 -0
  193. package/templates/naome-root/.naome/repository-structure.json +90 -0
  194. package/templates/naome-root/.naome/task-contract.schema.json +93 -11
  195. package/templates/naome-root/.naome/upgrade-state.json +1 -1
  196. package/templates/naome-root/.naome/verification.json +38 -0
  197. package/templates/naome-root/AGENTS.md +3 -0
  198. package/templates/naome-root/docs/naome/agent-workflow.md +25 -12
  199. package/templates/naome-root/docs/naome/execution.md +25 -21
  200. package/templates/naome-root/docs/naome/index.md +5 -3
  201. package/templates/naome-root/docs/naome/repository-quality.md +46 -0
  202. package/templates/naome-root/docs/naome/repository-structure.md +51 -0
  203. package/templates/naome-root/docs/naome/testing.md +13 -0
  204. package/crates/naome-core/src/task_state.rs +0 -2210
@@ -11,6 +11,11 @@ Use this workflow after first-run intake is complete.
11
11
  `canCreateTask` fields instead of inventing routing or final-response text.
12
12
  If route returns a `taskRoot` different from the current directory, continue
13
13
  the task from that path and leave the original worktree untouched.
14
+ When preparing the route prompt file, prepend a fenced `naome-intent-v2`
15
+ JSON envelope that states `workflowAction`, `taskIntent`, and `risk` using
16
+ canonical NAOME schema constants such as `commit_request`,
17
+ `task_revision`, and `credential_context`. Keep the original user text below
18
+ it. Do not derive workflow actions from natural-language keywords.
14
19
  3. Use `node .naome/bin/naome.js explain --prompt-file <path> --json` only when
15
20
  debugging why a policy won.
16
21
  4. Run `node .naome/bin/naome.js status --json` when reporting state without
@@ -38,11 +43,14 @@ Use this workflow after first-run intake is complete.
38
43
  11. Restate the task in concrete terms.
39
44
  12. Read `.naomeignore`.
40
45
  13. Exclude every path matched by `.naomeignore` from context gathering.
41
- 14. Read only the `requiredContext` returned by route/status plus the smallest
46
+ 14. For broad searches, use `node .naome/bin/naome.js workflow search-profile`
47
+ or equivalent excludes for `.git`, `.naome/archive`, dependencies, build
48
+ outputs, caches, and `.naomeignore` paths.
49
+ 15. Read only the `requiredContext` returned by route/status plus the smallest
42
50
  task-relevant NAOME docs.
43
- 15. Inspect the existing code or docs before proposing changes.
44
- 16. Read `testing.md` and `.naome/verification.json`.
45
- 17. Identify the required proof before claiming success.
51
+ 16. Inspect the existing code or docs before proposing changes.
52
+ 17. Read `testing.md` and `.naome/verification.json`.
53
+ 18. Identify the required proof before claiming success.
46
54
 
47
55
  ## Instruction Boundaries
48
56
 
@@ -66,25 +74,30 @@ Use this workflow after first-run intake is complete.
66
74
  - Update NAOME docs only when the change reveals durable project knowledge.
67
75
  - Use `node .naome/bin/check-task-state.js --progress` for in-flight task
68
76
  validation. Use the normal task-state check only after setting `complete`.
77
+ Scope changes outside `allowedPaths` require human review before continuing.
69
78
 
70
79
  ## Before Completion
71
80
 
72
81
  1. Identify changed files.
73
82
  2. Match them against `.naome/verification.json`.
74
83
  3. Run the required checks when available.
75
- 4. Record proof in `.naome/task-state.json`, including every changed in-scope
76
- path reported by git in proof evidence.
84
+ 4. Record proof in `.naome/task-state.json`, using compact `proofPathSets` and
85
+ `proofBatches` when several checks share the same evidence or timestamp.
86
+ Include every changed in-scope path reported by git in expanded proof
87
+ evidence.
77
88
  5. Do not list `.naome/task-state.json` as task scope or proof evidence.
78
- 6. Set task state to `complete`.
79
- 7. Run `node .naome/bin/check-task-state.js`.
80
- 8. If the task-state check prints a next-task admission notice, do not repeat
89
+ 6. Stop tracked long-running processes or mark them explicitly allowed in
90
+ `.naome/processes.json`.
91
+ 7. Set task state to `complete`.
92
+ 8. Run `node .naome/bin/check-task-state.js`.
93
+ 9. If the task-state check prints a next-task admission notice, do not repeat
81
94
  internal baseline options in the final response. Use the machine-generated
82
95
  `userMessage` from route/status and mention `humanOptions` only when that
83
96
  array is non-empty.
84
- 9. If no rule matches or the task check fails, report the gap and ask for human
97
+ 10. If no rule matches or the task check fails, report the gap and ask for human
85
98
  review before claiming completion.
86
- 10. Report changed files, exact commands, results, and remaining risk.
87
- 11. Only ask the user for options when intent blocks, the user explicitly asks
99
+ 11. Report changed files, exact commands, results, and remaining risk.
100
+ 12. Only ask the user for options when intent blocks, the user explicitly asks
88
101
  to review/revise/cancel, or automatic baselining fails.
89
102
 
90
103
  ## Commit And Push
@@ -13,10 +13,9 @@ You may start new feature work only when harness health and admission both pass.
13
13
  If health fails, ask the user to choose `repair_harness`,
14
14
  `review_harness_diff`, or `cancel_repair_baseline`.
15
15
 
16
- Harness health is a deterministic lifecycle gate, not an agent judgment call.
17
- When machine-owned harness files are unhealthy, normal task admission,
18
- progress, completion, commit, and push gates are blocked. Only status, health,
19
- review, and repair-baseline flows may continue until health is restored.
16
+ Harness health is deterministic: unhealthy machine-owned files block normal
17
+ admission, progress, completion, commit, and push. Only status, health, review,
18
+ and repair-baseline flows may continue until health is restored.
20
19
 
21
20
  Also read `.naome/upgrade-state.json`. If upgrade status is
22
21
  `needs_agent_upgrade`, do not start feature work. Finish `upgrade.md` first.
@@ -100,7 +99,7 @@ When starting work, update `.naome/task-state.json`:
100
99
  - set `allowedPaths` to the narrowest expected path list
101
100
  - set `declaredChangeTypes` from `.naome/verification.json`
102
101
  - set `requiredCheckIds` from the matching change types
103
- - set `proofResults` to an empty array
102
+ - set `proofResults` to an empty array while work is in progress
104
103
  - set `humanReview.required` when matching rules require review
105
104
 
106
105
  Use exact changed paths, not guessed shortcuts. If the user asks for `README.md`
@@ -118,8 +117,10 @@ While a task is `planning`, `implementing`, `revising`, or `verifying`, use
118
117
  `node .naome/bin/check-task-state.js --progress`.
119
118
 
120
119
  This validates the active task shape, admission record, check IDs, existing
121
- proof entries, and current diff scope without requiring completion proof. Use
122
- the normal task-state check only when moving the task to `complete`.
120
+ proof entries, and current diff scope without requiring completion proof. Both
121
+ legacy `proofResults` and compact `proofBatches` are expanded into the same
122
+ internal proof model before validation. Use the normal task-state check only
123
+ when moving the task to `complete`.
123
124
 
124
125
  ## Human Review
125
126
 
@@ -141,7 +142,8 @@ fix the task state before asking the human to choose an option.
141
142
 
142
143
  Before claiming completion:
143
144
 
144
- 1. Record every required proof in `activeTask.proofResults`.
145
+ 1. Record every required proof in `proofResults`, or compact `proofPathSets`
146
+ plus `proofBatches` for repeated evidence.
145
147
  2. Ensure proof evidence includes every changed in-scope path.
146
148
  3. Ensure `.naome/task-state.json` is not listed in `allowedPaths` or evidence.
147
149
  4. Set `status` to `complete`.
@@ -151,6 +153,11 @@ Before claiming completion:
151
153
 
152
154
  Completion is valid only when the task-state check passes.
153
155
 
156
+ Compact proof batches are lossless: `proofPathSets` names shared evidence,
157
+ `proofBatches[].checkedAt` shares a timestamp, and omitted proof-level
158
+ `command`/`cwd` must exactly match `.naome/verification.json`; record deviations
159
+ explicitly on the proof or batch.
160
+
154
161
  Do not reset `.naome/task-state.json` to idle just to hide the completed task.
155
162
  The completed task state is part of the task baseline and should be committed
156
163
  with the task diff. The next admitted task may overwrite it after the working
@@ -162,10 +169,9 @@ that historical task diff after the working tree is clean, so completed task
162
169
  state can stay committed without requiring the deleted file to exist.
163
170
 
164
171
  If the check passes but prints a next-task admission notice, keep the final
165
- handoff short: say the task is complete and verified, and use NAOME route/status
166
- `userMessage` for the next step. Do not list internal baseline options unless
167
- route returns non-empty `humanOptions`, automatic baselining fails, or the user
168
- explicitly asks to review, revise, cancel, or commit manually.
172
+ handoff short and use NAOME route/status `userMessage` for the next step. List
173
+ internal baseline options only when route returns `humanOptions`, automatic
174
+ baselining fails, or the user asks to review, revise, cancel, or commit manually.
169
175
 
170
176
  ## Git Reconciliation
171
177
 
@@ -181,16 +187,14 @@ commits or pushes outside NAOME, do not assume the harness is broken:
181
187
  The installed git hooks run commit and push gates, but hooks are guardrails, not
182
188
  the source of truth. Checks must still recover from manual Git operations.
183
189
 
184
- Completed task history is also written to the local-only
185
- `.naome/task-journal.jsonl` when NAOME commit/route baselines a task or when
186
- route reconciles a clean externally committed completed task. The journal is
187
- machine-owned working memory and should stay out of project commits.
190
+ Completed task history is also written to local-only `.naome/task-journal.jsonl`
191
+ when NAOME commit/route baselines a task or reconciles a clean externally
192
+ committed completed task. Keep the journal out of project commits.
188
193
 
189
194
  ## Prompt Records
190
195
 
191
- `request` is a compact working summary. `userPrompt.text` is the exact user
192
- input that started the task or revision, so task intent survives context
193
- compaction and agent handoff. Store only user-provided task input. Do not store
194
- system prompts, developer prompts, outer-agent instructions, or unrelated chat
195
- history. If the user prompt contains secrets, pause for human review before
196
+ `request` is a compact working summary. `userPrompt.text` is the exact task or
197
+ revision prompt, so intent survives context compaction and handoff. Store only
198
+ user-provided task input, not system/developer prompts, outer-agent instructions,
199
+ or unrelated chat history. If it contains secrets, pause for human review before
196
200
  committing task state.
@@ -17,9 +17,11 @@ for the current step.
17
17
  10. `architecture.md`
18
18
  11. `testing.md`
19
19
  12. `.naome/verification.json`
20
- 13. `security.md`
21
- 14. `agent-workflow.md`
22
- 15. `decisions.md`, when changing durable project policy
20
+ 13. `repository-quality.md`, when repository-quality checks or cleanup are relevant
21
+ 14. `repository-structure.md`, when path roles or structure cleanup are relevant
22
+ 15. `security.md`
23
+ 16. `agent-workflow.md`
24
+ 17. `decisions.md`, when changing durable project policy
23
25
 
24
26
  ## Source Types
25
27
 
@@ -0,0 +1,46 @@
1
+ # Repository Quality
2
+
3
+ NAOME keeps legacy debt visible without blocking unrelated feature work.
4
+
5
+ ## Gates
6
+
7
+ - `naome quality check --changed` blocks only on files changed in the current
8
+ diff. If a legacy file is touched, that file must satisfy the configured
9
+ quality rules before commit.
10
+ - `naome quality report` scans the repository and reports debt without failing
11
+ normal feature work.
12
+ - `naome cleanup plan` groups report findings into deterministic cleanup tasks.
13
+ - `naome cleanup route --path <path>` returns agent instructions for one file.
14
+
15
+ ## Configuration
16
+
17
+ Repository-specific rules live in `.naome/repository-quality.json`.
18
+
19
+ `quality init` selects deterministic built-in adapters from repository files.
20
+ Adapters are plug-and-play profiles such as `rust` or
21
+ `javascript-typescript`. They add stack-specific ignored/generated paths and
22
+ path rules at runtime without hard-coding a specific product repository into
23
+ the generic template.
24
+
25
+ Local `pathRules` are project overrides, not product defaults. They may document
26
+ repo-specific debt or special file roles, but loosening a rule to pass a feature
27
+ diff requires human review.
28
+
29
+ The default scanner is language-agnostic and uses text plus symbol heuristics:
30
+ file length, diff growth, function or component length, top-level symbol count,
31
+ duplicate regions, and near-duplicate functions. Duplicate regions are grouped
32
+ to avoid overlapping window spam and include repeated regions inside the same
33
+ file. Near-duplicate function checks compare functions/components, not
34
+ container symbols against their own children.
35
+
36
+ Structure checks run through the same gate. See `repository-structure.md` for
37
+ path roles, module/layer policy, adapters, and cleanup routing.
38
+
39
+ Agents may propose stricter repo-specific rules after inspecting the language
40
+ and stack.
41
+
42
+ ## Baseline
43
+
44
+ Existing debt is recorded in `.naome/repository-quality-baseline.json` by
45
+ `naome quality init`. Baseline debt remains visible in reports, but only changed
46
+ files are blocking during feature work.
@@ -0,0 +1,51 @@
1
+ # Repository Structure
2
+
3
+ NAOME checks whether new and changed files land in a maintainable directory
4
+ structure. Existing structure debt stays visible in reports and cleanup routes,
5
+ but normal feature work is blocked only by relevant changed paths.
6
+
7
+ ## Model
8
+
9
+ The structure model classifies each path as:
10
+
11
+ `path -> role -> module -> layer -> language -> generated/debt/changed`
12
+
13
+ Generic roles are `source`, `test`, `docs`, `config`, `script`, `generated`,
14
+ `artifact`, `dependency/vendor`, and `unknown`.
15
+
16
+ ## Gates
17
+
18
+ - `naome quality check --changed` includes structure checks.
19
+ - `naome quality report` shows structure debt with other quality findings.
20
+ - `naome structure report --json` returns only structure findings.
21
+ - `naome structure explain --path <path> --json` explains one path's role,
22
+ module, layer, language, generated flag, debt flag, and changed flag.
23
+ - `naome cleanup plan` and `naome cleanup route --path <path>` include
24
+ structure findings when a cleanup task should move or split files.
25
+
26
+ ## Checks
27
+
28
+ Structure checks include directory role mixing, misplaced file roles,
29
+ root-level file sprawl, dumping-ground directories, directory size, path depth,
30
+ case-insensitive path collisions, and source/test pairing hints.
31
+
32
+ Dumping-ground names such as `utils`, `helpers`, `common`, `shared`, `misc`,
33
+ and `lib` are not banned. New feature logic there is reported when a named
34
+ module location is more appropriate.
35
+
36
+ ## Adapters
37
+
38
+ The core is language-independent. Adapters add deterministic signals for stack
39
+ conventions. Built-in adapters currently include `rust` and
40
+ `javascript-typescript`; future adapters can add source roots, test roots,
41
+ module roots, and allowed root files without changing gate behavior.
42
+
43
+ ## Local Policy
44
+
45
+ Rules live in `.naome/repository-structure.json`. Product defaults contain no
46
+ repository-specific paths. Local policy may add source roots, test roots,
47
+ generated roots, allowed root files, directory role rules, and layer rules.
48
+
49
+ Use local policy to document real repository conventions, not to grant special
50
+ rights to one product or hide cleanup work. Loosening a structure rule to pass a
51
+ feature diff requires human review.
@@ -16,6 +16,14 @@ Status: Uninitialized
16
16
  | diff-check | `git diff --check` | `.` | fast | null |
17
17
  | naome-harness-health | `node .naome/bin/check-harness-health.js` | `.` | fast | null |
18
18
  | naome-task-state | `node .naome/bin/check-task-state.js` | `.` | fast | null |
19
+ | repository-quality-check | `node .naome/bin/naome.js quality check --changed` | `.` | fast | null |
20
+
21
+ ## Verification Phases
22
+
23
+ Run checks in `.naome/verification.json` phase order:
24
+ `shape-health`, `quality`, `focused-tests`, `broad-tests`, `package-release`,
25
+ then `diff-check`. Do not recommend later expensive phases while an earlier
26
+ phase is failing or missing.
19
27
 
20
28
  ## Change Type Rules
21
29
 
@@ -47,5 +55,10 @@ Status: Uninitialized
47
55
  - Keep instruction files under 200 lines. `.naome/verification.json` is machine
48
56
  state instead; keep it schema-valid and bounded to 20 checks, 12 change types,
49
57
  and 10 release gates.
58
+ - Store long command output as a compact summary that preserves command, cwd,
59
+ exit code, relevant lines, affected paths, and artifacts.
60
+ - When intake defines change types, include `repository-quality-check` as a
61
+ required check for source, structure, documentation, harness, template, and
62
+ CI changes.
50
63
  - Before completion, select proof from the Verification Map when possible.
51
64
  - Report exact commands and results. Do not claim proof that did not run.