@lamentis/naome 1.2.0 → 1.3.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 (139) hide show
  1. package/Cargo.lock +2 -2
  2. package/README.md +108 -47
  3. package/bin/naome-node.js +2 -1579
  4. package/bin/naome.js +34 -5
  5. package/crates/naome-cli/Cargo.toml +1 -1
  6. package/crates/naome-cli/src/dispatcher.rs +7 -2
  7. package/crates/naome-cli/src/main.rs +37 -22
  8. package/crates/naome-cli/src/quality_commands.rs +317 -10
  9. package/crates/naome-cli/src/workflow_commands.rs +21 -1
  10. package/crates/naome-core/Cargo.toml +1 -1
  11. package/crates/naome-core/src/decision/checks.rs +64 -0
  12. package/crates/naome-core/src/decision/idle.rs +67 -0
  13. package/crates/naome-core/src/decision/json.rs +36 -0
  14. package/crates/naome-core/src/decision/states.rs +165 -0
  15. package/crates/naome-core/src/decision.rs +131 -353
  16. package/crates/naome-core/src/git.rs +4 -2
  17. package/crates/naome-core/src/install_plan.rs +4 -0
  18. package/crates/naome-core/src/lib.rs +12 -6
  19. package/crates/naome-core/src/paths.rs +3 -1
  20. package/crates/naome-core/src/quality/adapter_support.rs +89 -0
  21. package/crates/naome-core/src/quality/adapters.rs +20 -67
  22. package/crates/naome-core/src/quality/baseline.rs +8 -0
  23. package/crates/naome-core/src/quality/cache.rs +153 -0
  24. package/crates/naome-core/src/quality/checks/duplicate_blocks.rs +25 -11
  25. package/crates/naome-core/src/quality/checks/near_duplicates.rs +4 -2
  26. package/crates/naome-core/src/quality/checks.rs +7 -8
  27. package/crates/naome-core/src/quality/cleanup.rs +48 -3
  28. package/crates/naome-core/src/quality/config.rs +8 -15
  29. package/crates/naome-core/src/quality/config_support.rs +24 -0
  30. package/crates/naome-core/src/quality/mod.rs +72 -6
  31. package/crates/naome-core/src/quality/scanner/analysis/normalize.rs +78 -0
  32. package/crates/naome-core/src/quality/scanner/analysis.rs +160 -0
  33. package/crates/naome-core/src/quality/scanner/repo_paths.rs +39 -3
  34. package/crates/naome-core/src/quality/scanner.rs +200 -215
  35. package/crates/naome-core/src/quality/semantic/checks.rs +134 -0
  36. package/crates/naome-core/src/quality/semantic/extract.rs +158 -0
  37. package/crates/naome-core/src/quality/semantic/model.rs +85 -0
  38. package/crates/naome-core/src/quality/semantic/route.rs +52 -0
  39. package/crates/naome-core/src/quality/semantic.rs +68 -0
  40. package/crates/naome-core/src/quality/structure/adapters.rs +84 -0
  41. package/crates/naome-core/src/quality/structure/checks/basic.rs +153 -0
  42. package/crates/naome-core/src/quality/structure/checks/directory.rs +134 -0
  43. package/crates/naome-core/src/quality/structure/checks/pairing.rs +63 -0
  44. package/crates/naome-core/src/quality/structure/checks.rs +124 -0
  45. package/crates/naome-core/src/quality/structure/classify/roles.rs +188 -0
  46. package/crates/naome-core/src/quality/structure/classify.rs +146 -0
  47. package/crates/naome-core/src/quality/structure/config.rs +89 -0
  48. package/crates/naome-core/src/quality/structure/defaults.rs +107 -0
  49. package/crates/naome-core/src/quality/structure/mod.rs +77 -0
  50. package/crates/naome-core/src/quality/structure/model.rs +131 -0
  51. package/crates/naome-core/src/quality/types.rs +43 -2
  52. package/crates/naome-core/src/route/builtin_checks.rs +141 -0
  53. package/crates/naome-core/src/route/builtin_context.rs +73 -0
  54. package/crates/naome-core/src/route/builtin_integrity.rs +49 -0
  55. package/crates/naome-core/src/route/builtin_require.rs +40 -0
  56. package/crates/naome-core/src/route/context.rs +180 -0
  57. package/crates/naome-core/src/route/execution.rs +96 -0
  58. package/crates/naome-core/src/route/execution_baselines.rs +146 -0
  59. package/crates/naome-core/src/route/execution_support.rs +57 -0
  60. package/crates/naome-core/src/route/execution_tasks.rs +71 -0
  61. package/crates/naome-core/src/route/git_ops.rs +72 -0
  62. package/crates/naome-core/src/route/quality_gate.rs +73 -0
  63. package/crates/naome-core/src/route/quality_gate_config.rs +126 -0
  64. package/crates/naome-core/src/route/quality_gate_snapshot.rs +69 -0
  65. package/crates/naome-core/src/route/worktree.rs +75 -0
  66. package/crates/naome-core/src/route/worktree_files.rs +32 -0
  67. package/crates/naome-core/src/route/worktree_plan.rs +131 -0
  68. package/crates/naome-core/src/route.rs +44 -1217
  69. package/crates/naome-core/src/verification.rs +1 -0
  70. package/crates/naome-core/src/workflow/doctor.rs +144 -0
  71. package/crates/naome-core/src/workflow/mod.rs +2 -0
  72. package/crates/naome-core/src/workflow/mutation.rs +1 -2
  73. package/crates/naome-core/tests/decision.rs +24 -118
  74. package/crates/naome-core/tests/harness_health.rs +2 -0
  75. package/crates/naome-core/tests/install_plan.rs +2 -0
  76. package/crates/naome-core/tests/quality.rs +26 -123
  77. package/crates/naome-core/tests/quality_performance.rs +231 -0
  78. package/crates/naome-core/tests/quality_structure.rs +116 -0
  79. package/crates/naome-core/tests/quality_structure_adapters.rs +98 -0
  80. package/crates/naome-core/tests/quality_structure_policy.rs +144 -0
  81. package/crates/naome-core/tests/quality_structure_support/mod.rs +249 -0
  82. package/crates/naome-core/tests/repo_support/mod.rs +16 -0
  83. package/crates/naome-core/tests/repo_support/repo.rs +113 -0
  84. package/crates/naome-core/tests/repo_support/repo_factories.rs +99 -0
  85. package/crates/naome-core/tests/repo_support/repo_helpers.rs +123 -0
  86. package/crates/naome-core/tests/repo_support/routes.rs +81 -0
  87. package/crates/naome-core/tests/repo_support/verification.rs +168 -0
  88. package/crates/naome-core/tests/repo_support/verification_values.rs +135 -0
  89. package/crates/naome-core/tests/route.rs +1 -1376
  90. package/crates/naome-core/tests/route_baseline.rs +86 -0
  91. package/crates/naome-core/tests/route_completion.rs +141 -0
  92. package/crates/naome-core/tests/route_harness_refresh.rs +135 -0
  93. package/crates/naome-core/tests/route_user_diff.rs +202 -0
  94. package/crates/naome-core/tests/route_worktree.rs +54 -0
  95. package/crates/naome-core/tests/semantic_legacy.rs +140 -0
  96. package/crates/naome-core/tests/task_state.rs +60 -432
  97. package/crates/naome-core/tests/task_state_compact_support/repo.rs +1 -1
  98. package/crates/naome-core/tests/task_state_support/mod.rs +163 -0
  99. package/crates/naome-core/tests/task_state_support/states.rs +84 -0
  100. package/crates/naome-core/tests/verification.rs +4 -45
  101. package/crates/naome-core/tests/verification_contract.rs +22 -78
  102. package/crates/naome-core/tests/workflow_doctor.rs +24 -0
  103. package/crates/naome-core/tests/workflow_policy.rs +6 -1
  104. package/crates/naome-core/tests/workflow_support/mod.rs +1 -1
  105. package/installer/agents.js +90 -0
  106. package/installer/context.js +67 -0
  107. package/installer/filesystem.js +166 -0
  108. package/installer/flows.js +84 -0
  109. package/installer/git-boundary.js +171 -0
  110. package/installer/git-hook-content.js +36 -0
  111. package/installer/git-hooks.js +134 -0
  112. package/installer/git-local.js +2 -0
  113. package/installer/git-shared.js +35 -0
  114. package/installer/harness-file-ops.js +140 -0
  115. package/installer/harness-files.js +56 -0
  116. package/installer/harness-verification.js +123 -0
  117. package/installer/install-plan.js +66 -0
  118. package/installer/main.js +25 -0
  119. package/installer/manifest-state.js +167 -0
  120. package/installer/native-build.js +24 -0
  121. package/installer/native-format.js +6 -0
  122. package/installer/native.js +162 -0
  123. package/installer/output.js +131 -0
  124. package/installer/version.js +32 -0
  125. package/native/darwin-arm64/naome +0 -0
  126. package/native/linux-x64/naome +0 -0
  127. package/package.json +2 -1
  128. package/templates/naome-root/.naome/bin/check-harness-health.js +3 -3
  129. package/templates/naome-root/.naome/bin/check-task-state.js +3 -3
  130. package/templates/naome-root/.naome/bin/naome.js +32 -21
  131. package/templates/naome-root/.naome/manifest.json +5 -3
  132. package/templates/naome-root/.naome/repository-structure.json +90 -0
  133. package/templates/naome-root/.naome/verification.json +1 -0
  134. package/templates/naome-root/.naomeignore +1 -0
  135. package/templates/naome-root/docs/naome/agent-workflow.md +16 -14
  136. package/templates/naome-root/docs/naome/index.md +4 -3
  137. package/templates/naome-root/docs/naome/repository-quality.md +66 -4
  138. package/templates/naome-root/docs/naome/repository-structure.md +51 -0
  139. package/templates/naome-root/docs/naome/testing.md +2 -1
@@ -7,15 +7,26 @@ NAOME keeps legacy debt visible without blocking unrelated feature work.
7
7
  - `naome quality check --changed` blocks only on files changed in the current
8
8
  diff. If a legacy file is touched, that file must satisfy the configured
9
9
  quality rules before commit.
10
- - `naome quality report` scans the repository and reports debt without failing
11
- normal feature work.
10
+ - `naome quality report` scans the repository with normal budgets and reports
11
+ debt without failing feature work. Full repository duplicate,
12
+ near-duplicate, and semantic grouping checks are deep-only.
13
+ - `naome quality report --deep` runs the intentionally expensive full
14
+ repository checks.
12
15
  - `naome cleanup plan` groups report findings into deterministic cleanup tasks.
13
16
  - `naome cleanup route --path <path>` returns agent instructions for one file.
17
+ Structure findings include rule-specific guidance such as moving misplaced
18
+ tests, pairing source with nearby tests, splitting dumping-ground folders, or
19
+ resolving case collisions.
14
20
 
15
21
  ## Configuration
16
22
 
17
23
  Repository-specific rules live in `.naome/repository-quality.json`.
18
24
 
25
+ `quality init` writes only policy files and an empty baseline placeholder. It
26
+ does not deep-scan the repository. To record existing debt intentionally, run
27
+ `quality init --baseline`; use `quality init --deep-baseline` only when broad
28
+ duplicate and semantic grouping checks are expected.
29
+
19
30
  `quality init` selects deterministic built-in adapters from repository files.
20
31
  Adapters are plug-and-play profiles such as `rust` or
21
32
  `javascript-typescript`. They add stack-specific ignored/generated paths and
@@ -26,6 +37,20 @@ Local `pathRules` are project overrides, not product defaults. They may document
26
37
  repo-specific debt or special file roles, but loosening a rule to pass a feature
27
38
  diff requires human review.
28
39
 
40
+ The scanner has three modes:
41
+
42
+ - `ChangedFast`: changed files are read fully; unchanged files may contribute
43
+ cached facts for duplicate comparison.
44
+ - `Report`: repository-wide, budgeted debt visibility. If budgets are hit, JSON
45
+ sets `summary.truncated` and includes stable `reasonCodes`.
46
+ - `DeepReport`: explicit expensive scan for full duplicate, near-duplicate, and
47
+ semantic grouping work.
48
+
49
+ Per-file analysis facts are cached under `.naome/cache/quality/`. Cache entries
50
+ are local-only, keyed by NAOME version, config hash, adapter version, path, and
51
+ content hash. Cache corruption or misses cause a rescan, not a gate failure.
52
+ Use `quality cache status --json` and `quality cache clear` for maintenance.
53
+
29
54
  The default scanner is language-agnostic and uses text plus symbol heuristics:
30
55
  file length, diff growth, function or component length, top-level symbol count,
31
56
  duplicate regions, and near-duplicate functions. Duplicate regions are grouped
@@ -33,11 +58,48 @@ to avoid overlapping window spam and include repeated regions inside the same
33
58
  file. Near-duplicate function checks compare functions/components, not
34
59
  container symbols against their own children.
35
60
 
61
+ Structure checks run through the same gate. See `repository-structure.md` for
62
+ path roles, module/layer policy, adapters, and cleanup routing.
63
+
36
64
  Agents may propose stricter repo-specific rules after inspecting the language
37
65
  and stack.
38
66
 
67
+ ## Planned Semantic Cleanup
68
+
69
+ Some maintainability debt is semantic rather than purely syntactic. Examples
70
+ include inline legacy compatibility fixtures, copied config objects, stale test
71
+ builders, hand-written schema snapshots, and helper data that should move into a
72
+ shared factory after enough call sites accumulate.
73
+
74
+ NAOME should detect these with a generic semantic-cleanup layer instead of
75
+ hard-coding product paths or deleting compatibility fixtures opportunistically.
76
+ The planned model is:
77
+
78
+ - detect repeated object shapes, schema literals, fixture builders, and config
79
+ snapshots across changed and report-mode files;
80
+ - classify each finding as `legacy fixture`, `duplicated fixture`,
81
+ `schema snapshot`, `generated metadata`, or `inline builder`;
82
+ - keep existing report-mode debt visible without blocking unrelated work;
83
+ - block only changed/new semantic debt unless local policy marks it report-only;
84
+ - route cleanup to extract a shared fixture, builder, schema writer, or generated
85
+ metadata refresh command;
86
+ - preserve behavior by requiring tests before removing or consolidating legacy
87
+ compatibility fixtures.
88
+
89
+ The first implementation exposes this as a scout, not an auto-fixer:
90
+
91
+ - `naome semantic report --json` runs a budgeted semantic report.
92
+ - `naome semantic report --deep --json` runs repo-wide semantic grouping.
93
+ - `naome semantic check --changed --json` checks only changed semantic debt for
94
+ gate use.
95
+ - `naome semantic route --finding <id> --json` gives an agent the complete
96
+ affected path list, cleanup intent, and required checks for one finding group.
97
+ - `naome semantic loop --json` selects the next deterministic cleanup action:
98
+ changed-code findings first, then report-only legacy debt.
99
+
39
100
  ## Baseline
40
101
 
41
102
  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.
103
+ `naome quality init --baseline` or `naome quality init --deep-baseline`.
104
+ Baseline debt remains visible in reports, but only changed files are blocking
105
+ 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.
@@ -58,6 +58,7 @@ phase is failing or missing.
58
58
  - Store long command output as a compact summary that preserves command, cwd,
59
59
  exit code, relevant lines, affected paths, and artifacts.
60
60
  - When intake defines change types, include `repository-quality-check` as a
61
- required check for source, documentation, harness, template, and CI changes.
61
+ required check for source, structure, documentation, harness, template, and
62
+ CI changes.
62
63
  - Before completion, select proof from the Verification Map when possible.
63
64
  - Report exact commands and results. Do not claim proof that did not run.