@lamentis/naome 1.1.2 → 1.2.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.
Files changed (125) 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.js +54 -16
  6. package/crates/naome-cli/Cargo.toml +1 -1
  7. package/crates/naome-cli/src/check_commands.rs +135 -0
  8. package/crates/naome-cli/src/cli_args.rs +5 -0
  9. package/crates/naome-cli/src/dispatcher.rs +36 -0
  10. package/crates/naome-cli/src/install_bridge.rs +83 -0
  11. package/crates/naome-cli/src/main.rs +57 -341
  12. package/crates/naome-cli/src/prompt_commands.rs +68 -0
  13. package/crates/naome-cli/src/quality_commands.rs +141 -0
  14. package/crates/naome-cli/src/simple_commands.rs +53 -0
  15. package/crates/naome-cli/src/workflow_commands.rs +153 -0
  16. package/crates/naome-core/Cargo.toml +1 -1
  17. package/crates/naome-core/src/harness_health/integrity.rs +96 -0
  18. package/crates/naome-core/src/harness_health.rs +14 -126
  19. package/crates/naome-core/src/install_plan.rs +3 -0
  20. package/crates/naome-core/src/intent/classifier.rs +171 -0
  21. package/crates/naome-core/src/intent/envelope.rs +108 -0
  22. package/crates/naome-core/src/intent/legacy.rs +138 -0
  23. package/crates/naome-core/src/intent/legacy_response.rs +76 -0
  24. package/crates/naome-core/src/intent/model.rs +71 -0
  25. package/crates/naome-core/src/intent/patterns.rs +170 -0
  26. package/crates/naome-core/src/intent/resolver.rs +162 -0
  27. package/crates/naome-core/src/intent/resolver_active.rs +17 -0
  28. package/crates/naome-core/src/intent/resolver_baseline.rs +55 -0
  29. package/crates/naome-core/src/intent/resolver_catalog.rs +167 -0
  30. package/crates/naome-core/src/intent/resolver_policy.rs +72 -0
  31. package/crates/naome-core/src/intent/resolver_shared.rs +55 -0
  32. package/crates/naome-core/src/intent/risk.rs +40 -0
  33. package/crates/naome-core/src/intent/segment.rs +170 -0
  34. package/crates/naome-core/src/intent.rs +64 -879
  35. package/crates/naome-core/src/journal.rs +9 -20
  36. package/crates/naome-core/src/lib.rs +13 -0
  37. package/crates/naome-core/src/quality/adapters.rs +178 -0
  38. package/crates/naome-core/src/quality/baseline.rs +75 -0
  39. package/crates/naome-core/src/quality/checks/duplicate_blocks.rs +175 -0
  40. package/crates/naome-core/src/quality/checks/near_duplicates.rs +130 -0
  41. package/crates/naome-core/src/quality/checks.rs +228 -0
  42. package/crates/naome-core/src/quality/cleanup.rs +72 -0
  43. package/crates/naome-core/src/quality/config.rs +109 -0
  44. package/crates/naome-core/src/quality/mod.rs +90 -0
  45. package/crates/naome-core/src/quality/scanner/repo_paths.rs +103 -0
  46. package/crates/naome-core/src/quality/scanner.rs +367 -0
  47. package/crates/naome-core/src/quality/types.rs +289 -0
  48. package/crates/naome-core/src/route.rs +62 -0
  49. package/crates/naome-core/src/task_state/admission.rs +63 -0
  50. package/crates/naome-core/src/task_state/admission_proof.rs +72 -0
  51. package/crates/naome-core/src/task_state/api.rs +130 -0
  52. package/crates/naome-core/src/task_state/commit_gate.rs +138 -0
  53. package/crates/naome-core/src/task_state/compact_proof.rs +160 -0
  54. package/crates/naome-core/src/task_state/completed_refresh.rs +89 -0
  55. package/crates/naome-core/src/task_state/completion.rs +72 -0
  56. package/crates/naome-core/src/task_state/deleted_paths.rs +47 -0
  57. package/crates/naome-core/src/task_state/diff.rs +95 -0
  58. package/crates/naome-core/src/task_state/evidence.rs +154 -0
  59. package/crates/naome-core/src/task_state/git_io.rs +86 -0
  60. package/crates/naome-core/src/task_state/git_parse.rs +86 -0
  61. package/crates/naome-core/src/task_state/git_refs.rs +37 -0
  62. package/crates/naome-core/src/task_state/human_review_state.rs +31 -0
  63. package/crates/naome-core/src/task_state/mod.rs +38 -0
  64. package/crates/naome-core/src/task_state/process_guard.rs +40 -0
  65. package/crates/naome-core/src/task_state/progress.rs +123 -0
  66. package/crates/naome-core/src/task_state/proof.rs +139 -0
  67. package/crates/naome-core/src/task_state/proof_entry.rs +66 -0
  68. package/crates/naome-core/src/task_state/proof_model.rs +70 -0
  69. package/crates/naome-core/src/task_state/proof_sources.rs +76 -0
  70. package/crates/naome-core/src/task_state/push_gate.rs +49 -0
  71. package/crates/naome-core/src/task_state/reconcile.rs +7 -0
  72. package/crates/naome-core/src/task_state/repair.rs +168 -0
  73. package/crates/naome-core/src/task_state/shape.rs +117 -0
  74. package/crates/naome-core/src/task_state/task_diff_api.rs +170 -0
  75. package/crates/naome-core/src/task_state/task_records.rs +131 -0
  76. package/crates/naome-core/src/task_state/task_references.rs +126 -0
  77. package/crates/naome-core/src/task_state/types.rs +87 -0
  78. package/crates/naome-core/src/task_state/util.rs +137 -0
  79. package/crates/naome-core/src/verification/render.rs +122 -0
  80. package/crates/naome-core/src/verification.rs +176 -58
  81. package/crates/naome-core/src/verification_contract.rs +49 -21
  82. package/crates/naome-core/src/workflow/integrity.rs +123 -0
  83. package/crates/naome-core/src/workflow/integrity_normalize.rs +7 -0
  84. package/crates/naome-core/src/workflow/integrity_support.rs +110 -0
  85. package/crates/naome-core/src/workflow/mod.rs +18 -0
  86. package/crates/naome-core/src/workflow/mutation.rs +68 -0
  87. package/crates/naome-core/src/workflow/output.rs +111 -0
  88. package/crates/naome-core/src/workflow/phase_inference.rs +73 -0
  89. package/crates/naome-core/src/workflow/phases.rs +169 -0
  90. package/crates/naome-core/src/workflow/policy.rs +156 -0
  91. package/crates/naome-core/src/workflow/processes.rs +91 -0
  92. package/crates/naome-core/src/workflow/types.rs +42 -0
  93. package/crates/naome-core/tests/harness_health.rs +3 -0
  94. package/crates/naome-core/tests/intent.rs +97 -792
  95. package/crates/naome-core/tests/intent_support/mod.rs +133 -0
  96. package/crates/naome-core/tests/intent_v2.rs +90 -0
  97. package/crates/naome-core/tests/quality.rs +425 -0
  98. package/crates/naome-core/tests/route.rs +88 -188
  99. package/crates/naome-core/tests/task_state.rs +3 -0
  100. package/crates/naome-core/tests/task_state_compact.rs +110 -0
  101. package/crates/naome-core/tests/task_state_compact_support/mod.rs +5 -0
  102. package/crates/naome-core/tests/task_state_compact_support/repo.rs +130 -0
  103. package/crates/naome-core/tests/task_state_compact_support/states.rs +151 -0
  104. package/crates/naome-core/tests/workflow_integrity.rs +85 -0
  105. package/crates/naome-core/tests/workflow_policy.rs +139 -0
  106. package/crates/naome-core/tests/workflow_support/mod.rs +194 -0
  107. package/native/darwin-arm64/naome +0 -0
  108. package/native/linux-x64/naome +0 -0
  109. package/package.json +2 -2
  110. package/templates/naome-root/.naome/bin/check-harness-health.js +66 -85
  111. package/templates/naome-root/.naome/bin/check-task-state.js +9 -10
  112. package/templates/naome-root/.naome/bin/naome.js +34 -63
  113. package/templates/naome-root/.naome/manifest.json +20 -18
  114. package/templates/naome-root/.naome/repository-quality-baseline.json +5 -0
  115. package/templates/naome-root/.naome/repository-quality.json +24 -0
  116. package/templates/naome-root/.naome/task-contract.schema.json +93 -11
  117. package/templates/naome-root/.naome/upgrade-state.json +1 -1
  118. package/templates/naome-root/.naome/verification.json +37 -0
  119. package/templates/naome-root/AGENTS.md +3 -0
  120. package/templates/naome-root/docs/naome/agent-workflow.md +25 -12
  121. package/templates/naome-root/docs/naome/execution.md +25 -21
  122. package/templates/naome-root/docs/naome/index.md +4 -3
  123. package/templates/naome-root/docs/naome/repository-quality.md +43 -0
  124. package/templates/naome-root/docs/naome/testing.md +12 -0
  125. package/crates/naome-core/src/task_state.rs +0 -2210
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "naome.task-state.v1",
3
+ "$id": "naome.task-state.v2",
4
4
  "title": "NAOME Task State",
5
5
  "type": "object",
6
6
  "additionalProperties": false,
7
7
  "required": ["schema", "version", "status", "activeTask", "blocker", "updatedAt"],
8
8
  "properties": {
9
- "schema": { "const": "naome.task-state.v1" },
10
- "version": { "const": 1 },
9
+ "schema": { "enum": ["naome.task-state.v1", "naome.task-state.v2"] },
10
+ "version": { "enum": [1, 2] },
11
11
  "status": {
12
12
  "enum": ["idle", "planning", "implementing", "revising", "verifying", "needs_human_review", "blocked", "complete"]
13
13
  },
@@ -30,11 +30,29 @@
30
30
  ]
31
31
  }
32
32
  },
33
+ "oneOf": [
34
+ {
35
+ "properties": {
36
+ "schema": { "const": "naome.task-state.v1" },
37
+ "version": { "const": 1 }
38
+ }
39
+ },
40
+ {
41
+ "properties": {
42
+ "schema": { "const": "naome.task-state.v2" },
43
+ "version": { "const": 2 }
44
+ }
45
+ }
46
+ ],
33
47
  "$defs": {
34
48
  "activeTask": {
35
49
  "type": "object",
36
50
  "additionalProperties": false,
37
- "required": ["id", "request", "userPrompt", "admission", "allowedPaths", "declaredChangeTypes", "requiredCheckIds", "proofResults", "humanReview"],
51
+ "required": ["id", "request", "userPrompt", "admission", "allowedPaths", "declaredChangeTypes", "requiredCheckIds", "humanReview"],
52
+ "anyOf": [
53
+ { "required": ["proofResults"] },
54
+ { "required": ["proofBatches"] }
55
+ ],
38
56
  "properties": {
39
57
  "id": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]*$" },
40
58
  "request": { "type": "string", "minLength": 1 },
@@ -58,6 +76,14 @@
58
76
  "type": "array",
59
77
  "items": { "$ref": "#/$defs/proofResult" }
60
78
  },
79
+ "proofPathSets": {
80
+ "type": "object",
81
+ "additionalProperties": { "$ref": "#/$defs/evidenceArray" }
82
+ },
83
+ "proofBatches": {
84
+ "type": "array",
85
+ "items": { "$ref": "#/$defs/proofBatch" }
86
+ },
61
87
  "revisions": {
62
88
  "type": "array",
63
89
  "items": { "$ref": "#/$defs/revision" }
@@ -109,17 +135,73 @@
109
135
  "cwd": { "type": "string", "minLength": 1 },
110
136
  "exitCode": { "type": "integer" },
111
137
  "checkedAt": { "type": "string", "format": "date-time" },
112
- "evidence": {
138
+ "evidence": { "$ref": "#/$defs/evidenceArray" },
139
+ "outputSummary": { "$ref": "#/$defs/outputSummary" }
140
+ }
141
+ },
142
+ "proofBatch": {
143
+ "type": "object",
144
+ "additionalProperties": false,
145
+ "required": ["checkedAt", "proofs"],
146
+ "properties": {
147
+ "checkedAt": { "type": "string", "format": "date-time" },
148
+ "command": { "type": "string", "minLength": 1 },
149
+ "cwd": { "type": "string", "minLength": 1 },
150
+ "evidencePathSet": { "type": "string", "minLength": 1 },
151
+ "proofs": {
152
+ "type": "array",
153
+ "items": { "$ref": "#/$defs/compactProofResult" }
154
+ }
155
+ }
156
+ },
157
+ "compactProofResult": {
158
+ "type": "object",
159
+ "additionalProperties": false,
160
+ "required": ["checkId", "exitCode"],
161
+ "properties": {
162
+ "checkId": { "type": "string", "minLength": 1 },
163
+ "command": { "type": "string", "minLength": 1 },
164
+ "cwd": { "type": "string", "minLength": 1 },
165
+ "exitCode": { "type": "integer" },
166
+ "checkedAt": { "type": "string", "format": "date-time" },
167
+ "evidence": { "$ref": "#/$defs/evidenceArray" },
168
+ "evidencePathSet": { "type": "string", "minLength": 1 },
169
+ "outputSummary": { "$ref": "#/$defs/outputSummary" }
170
+ }
171
+ },
172
+ "outputSummary": {
173
+ "type": "object",
174
+ "additionalProperties": false,
175
+ "required": ["command", "cwd", "exitCode", "truncated", "relevantLines", "affectedPaths"],
176
+ "properties": {
177
+ "command": { "type": "string", "minLength": 1 },
178
+ "cwd": { "type": "string", "minLength": 1 },
179
+ "exitCode": { "type": "integer" },
180
+ "truncated": { "type": "boolean" },
181
+ "omittedLineCount": { "type": "integer", "minimum": 0 },
182
+ "relevantLines": {
113
183
  "type": "array",
114
- "items": {
115
- "anyOf": [
116
- { "type": "string", "minLength": 1 },
117
- { "$ref": "#/$defs/evidenceEntry" }
118
- ]
119
- }
184
+ "items": { "type": "string" }
185
+ },
186
+ "affectedPaths": {
187
+ "type": "array",
188
+ "items": { "type": "string", "minLength": 1 }
189
+ },
190
+ "artifacts": {
191
+ "type": "array",
192
+ "items": { "type": "string", "minLength": 1 }
120
193
  }
121
194
  }
122
195
  },
196
+ "evidenceArray": {
197
+ "type": "array",
198
+ "items": {
199
+ "anyOf": [
200
+ { "type": "string", "minLength": 1 },
201
+ { "$ref": "#/$defs/evidenceEntry" }
202
+ ]
203
+ }
204
+ },
123
205
  "evidenceEntry": {
124
206
  "type": "object",
125
207
  "additionalProperties": false,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "status": "complete",
3
3
  "fromVersion": null,
4
- "toVersion": "1.1.1",
4
+ "toVersion": "1.2.0",
5
5
  "pending": [],
6
6
  "completed": []
7
7
  }
@@ -38,6 +38,43 @@
38
38
  ".naome/task-contract.schema.json"
39
39
  ],
40
40
  "lastVerified": null
41
+ },
42
+ {
43
+ "id": "repository-quality-check",
44
+ "command": "node .naome/bin/naome.js quality check --changed",
45
+ "cwd": ".",
46
+ "purpose": "Validate changed files against deterministic NAOME repository quality rules.",
47
+ "cost": "fast",
48
+ "source": "NAOME built-in",
49
+ "evidence": [
50
+ ".naome/repository-quality.json",
51
+ ".naome/repository-quality-baseline.json"
52
+ ],
53
+ "lastVerified": null
54
+ }
55
+ ],
56
+ "phases": [
57
+ {
58
+ "id": "shape-health",
59
+ "order": 10,
60
+ "checkIds": [
61
+ "naome-harness-health",
62
+ "naome-task-state"
63
+ ]
64
+ },
65
+ {
66
+ "id": "quality",
67
+ "order": 20,
68
+ "checkIds": [
69
+ "repository-quality-check"
70
+ ]
71
+ },
72
+ {
73
+ "id": "diff-check",
74
+ "order": 60,
75
+ "checkIds": [
76
+ "diff-check"
77
+ ]
41
78
  }
42
79
  ],
43
80
  "changeTypes": [],
@@ -69,6 +69,9 @@ This repository uses NAOME as its coding-agent harness.
69
69
  previous-task, or other unowned changes.
70
70
  - Treat `.naomeignore` as a hard read boundary. Do not inspect ignored paths
71
71
  unless the user first removes the path from `.naomeignore`.
72
+ - Use `naome workflow search-profile` or equivalent excludes for broad searches;
73
+ hidden searches must exclude `.git`, `.naome/archive`, dependencies, build
74
+ outputs, caches, and `.naomeignore` paths.
72
75
  - Use `docs/naome/testing.md` and `.naome/verification.json` before claiming
73
76
  completion.
74
77
  - Before claiming completion, run the narrowest meaningful verification that can
@@ -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,10 @@ 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. `security.md`
22
+ 15. `agent-workflow.md`
23
+ 16. `decisions.md`, when changing durable project policy
23
24
 
24
25
  ## Source Types
25
26
 
@@ -0,0 +1,43 @@
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
+ Agents may propose stricter repo-specific rules after inspecting the language
37
+ and stack.
38
+
39
+ ## Baseline
40
+
41
+ Existing debt is recorded in `.naome/repository-quality-baseline.json` by
42
+ `naome quality init`. Baseline debt remains visible in reports, but only changed
43
+ files are blocking during feature work.
@@ -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,9 @@ 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, documentation, harness, template, and CI changes.
50
62
  - Before completion, select proof from the Verification Map when possible.
51
63
  - Report exact commands and results. Do not claim proof that did not run.