@lamentis/naome 1.2.1 → 1.3.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 (155) hide show
  1. package/Cargo.lock +2 -2
  2. package/README.md +117 -47
  3. package/bin/naome.js +65 -12
  4. package/crates/naome-cli/Cargo.toml +1 -1
  5. package/crates/naome-cli/src/context_commands.rs +47 -0
  6. package/crates/naome-cli/src/dispatcher.rs +12 -2
  7. package/crates/naome-cli/src/main.rs +78 -29
  8. package/crates/naome-cli/src/quality_commands.rs +238 -34
  9. package/crates/naome-cli/src/quality_output.rs +34 -0
  10. package/crates/naome-cli/src/quality_reconcile_command.rs +45 -0
  11. package/crates/naome-cli/src/repository_model_commands.rs +84 -0
  12. package/crates/naome-cli/src/task_commands.rs +62 -0
  13. package/crates/naome-cli/src/workflow_commands.rs +120 -3
  14. package/crates/naome-core/Cargo.toml +1 -1
  15. package/crates/naome-core/src/context/helpers.rs +75 -0
  16. package/crates/naome-core/src/context/select.rs +134 -0
  17. package/crates/naome-core/src/context/types.rs +43 -0
  18. package/crates/naome-core/src/context.rs +6 -0
  19. package/crates/naome-core/src/decision/states.rs +1 -1
  20. package/crates/naome-core/src/decision.rs +4 -1
  21. package/crates/naome-core/src/git.rs +4 -2
  22. package/crates/naome-core/src/install_plan.rs +20 -0
  23. package/crates/naome-core/src/journal.rs +2 -7
  24. package/crates/naome-core/src/lib.rs +35 -8
  25. package/crates/naome-core/src/quality/adapter_ios.rs +131 -0
  26. package/crates/naome-core/src/quality/adapter_support.rs +67 -0
  27. package/crates/naome-core/src/quality/adapters.rs +81 -18
  28. package/crates/naome-core/src/quality/baseline.rs +8 -0
  29. package/crates/naome-core/src/quality/cache.rs +151 -0
  30. package/crates/naome-core/src/quality/checks/duplicate_blocks.rs +19 -8
  31. package/crates/naome-core/src/quality/checks/near_duplicates.rs +4 -2
  32. package/crates/naome-core/src/quality/checks.rs +7 -8
  33. package/crates/naome-core/src/quality/cleanup.rs +36 -3
  34. package/crates/naome-core/src/quality/config.rs +21 -3
  35. package/crates/naome-core/src/quality/mod.rs +189 -10
  36. package/crates/naome-core/src/quality/reconcile.rs +138 -0
  37. package/crates/naome-core/src/quality/reconcile_anchors.rs +64 -0
  38. package/crates/naome-core/src/quality/scanner/analysis/normalize.rs +78 -0
  39. package/crates/naome-core/src/quality/scanner/analysis.rs +175 -0
  40. package/crates/naome-core/src/quality/scanner/repo_paths.rs +39 -3
  41. package/crates/naome-core/src/quality/scanner.rs +235 -217
  42. package/crates/naome-core/src/quality/semantic/checks.rs +151 -0
  43. package/crates/naome-core/src/quality/semantic/extract.rs +158 -0
  44. package/crates/naome-core/src/quality/semantic/model.rs +85 -0
  45. package/crates/naome-core/src/quality/semantic/route.rs +52 -0
  46. package/crates/naome-core/src/quality/semantic.rs +68 -0
  47. package/crates/naome-core/src/quality/structure/adapter_ios.rs +149 -0
  48. package/crates/naome-core/src/quality/structure/adapters.rs +60 -42
  49. package/crates/naome-core/src/quality/structure/checks/directory.rs +13 -21
  50. package/crates/naome-core/src/quality/structure/checks.rs +1 -1
  51. package/crates/naome-core/src/quality/structure/classify/roles.rs +51 -5
  52. package/crates/naome-core/src/quality/structure/classify.rs +52 -0
  53. package/crates/naome-core/src/quality/structure/config.rs +24 -3
  54. package/crates/naome-core/src/quality/structure/mod.rs +5 -2
  55. package/crates/naome-core/src/quality/structure/model.rs +8 -1
  56. package/crates/naome-core/src/quality/types.rs +59 -2
  57. package/crates/naome-core/src/repository_model/detect.rs +188 -0
  58. package/crates/naome-core/src/repository_model/explain.rs +121 -0
  59. package/crates/naome-core/src/repository_model/path_scan.rs +67 -0
  60. package/crates/naome-core/src/repository_model/path_support.rs +59 -0
  61. package/crates/naome-core/src/repository_model/types.rs +152 -0
  62. package/crates/naome-core/src/repository_model/world.rs +48 -0
  63. package/crates/naome-core/src/repository_model/world_adapters.rs +145 -0
  64. package/crates/naome-core/src/repository_model/world_path_facts.rs +55 -0
  65. package/crates/naome-core/src/repository_model/world_paths.rs +168 -0
  66. package/crates/naome-core/src/repository_model.rs +164 -0
  67. package/crates/naome-core/src/route/builtin_checks.rs +41 -16
  68. package/crates/naome-core/src/task_ledger/import.rs +142 -0
  69. package/crates/naome-core/src/task_ledger/model.rs +13 -0
  70. package/crates/naome-core/src/task_ledger/proof_record.rs +52 -0
  71. package/crates/naome-core/src/task_ledger/read.rs +118 -0
  72. package/crates/naome-core/src/task_ledger/render.rs +55 -0
  73. package/crates/naome-core/src/task_ledger/write.rs +38 -0
  74. package/crates/naome-core/src/task_ledger.rs +48 -0
  75. package/crates/naome-core/src/task_state/api.rs +4 -2
  76. package/crates/naome-core/src/task_state/completed_refresh.rs +5 -16
  77. package/crates/naome-core/src/task_state/diff.rs +2 -2
  78. package/crates/naome-core/src/task_state/evidence.rs +8 -3
  79. package/crates/naome-core/src/task_state/mod.rs +1 -1
  80. package/crates/naome-core/src/task_state/progress.rs +13 -0
  81. package/crates/naome-core/src/task_state/proof_model.rs +8 -8
  82. package/crates/naome-core/src/task_state/repair.rs +2 -2
  83. package/crates/naome-core/src/task_state/task_diff_api.rs +9 -18
  84. package/crates/naome-core/src/task_state/types.rs +24 -0
  85. package/crates/naome-core/src/verification.rs +29 -18
  86. package/crates/naome-core/src/workflow/agent/capability.rs +194 -0
  87. package/crates/naome-core/src/workflow/agent/context_delta.rs +42 -0
  88. package/crates/naome-core/src/workflow/agent/decision.rs +32 -0
  89. package/crates/naome-core/src/workflow/agent/execution.rs +80 -0
  90. package/crates/naome-core/src/workflow/agent/proof.rs +24 -0
  91. package/crates/naome-core/src/workflow/agent/support.rs +58 -0
  92. package/crates/naome-core/src/workflow/agent/watchdog.rs +47 -0
  93. package/crates/naome-core/src/workflow/agent.rs +34 -0
  94. package/crates/naome-core/src/workflow/agent_types.rs +105 -0
  95. package/crates/naome-core/src/workflow/doctor.rs +183 -0
  96. package/crates/naome-core/src/workflow/mod.rs +13 -0
  97. package/crates/naome-core/src/workflow/mutation.rs +1 -2
  98. package/crates/naome-core/src/workflow/output.rs +8 -2
  99. package/crates/naome-core/src/workflow/phase_inference.rs +1 -1
  100. package/crates/naome-core/tests/context.rs +99 -0
  101. package/crates/naome-core/tests/harness_health.rs +4 -0
  102. package/crates/naome-core/tests/install_plan.rs +14 -0
  103. package/crates/naome-core/tests/quality.rs +190 -5
  104. package/crates/naome-core/tests/quality_performance.rs +268 -0
  105. package/crates/naome-core/tests/quality_structure_adapters.rs +39 -0
  106. package/crates/naome-core/tests/quality_structure_policy.rs +19 -0
  107. package/crates/naome-core/tests/repo_support/mod.rs +5 -1
  108. package/crates/naome-core/tests/repo_support/verification_values.rs +55 -0
  109. package/crates/naome-core/tests/repository_model.rs +281 -0
  110. package/crates/naome-core/tests/route_user_diff.rs +59 -7
  111. package/crates/naome-core/tests/semantic_legacy.rs +174 -0
  112. package/crates/naome-core/tests/task_ledger.rs +328 -0
  113. package/crates/naome-core/tests/task_state.rs +28 -0
  114. package/crates/naome-core/tests/verification.rs +29 -36
  115. package/crates/naome-core/tests/workflow_agent.rs +233 -0
  116. package/crates/naome-core/tests/workflow_agent_support/mod.rs +159 -0
  117. package/crates/naome-core/tests/workflow_doctor.rs +45 -0
  118. package/crates/naome-core/tests/workflow_policy.rs +6 -1
  119. package/installer/codex-hooks.js +121 -0
  120. package/installer/context.js +10 -0
  121. package/installer/filesystem.js +4 -0
  122. package/installer/flows.js +8 -4
  123. package/installer/git-boundary.js +1 -0
  124. package/installer/harness-files.js +6 -0
  125. package/installer/install-plan.js +4 -0
  126. package/installer/main.js +1 -1
  127. package/installer/native.js +1 -1
  128. package/native/darwin-arm64/naome +0 -0
  129. package/native/linux-x64/naome +0 -0
  130. package/package.json +1 -1
  131. package/templates/naome-root/.codex/config.toml +2 -0
  132. package/templates/naome-root/.codex/hooks.json +70 -0
  133. package/templates/naome-root/.naome/bin/check-harness-health.js +8 -6
  134. package/templates/naome-root/.naome/bin/check-task-state.js +12 -7
  135. package/templates/naome-root/.naome/bin/codex-hook-io.js +122 -0
  136. package/templates/naome-root/.naome/bin/codex-hook-policy.js +180 -0
  137. package/templates/naome-root/.naome/bin/codex-hook-runtime.js +174 -0
  138. package/templates/naome-root/.naome/bin/codex-hook.js +6 -0
  139. package/templates/naome-root/.naome/bin/naome.js +45 -7
  140. package/templates/naome-root/.naome/manifest.json +12 -6
  141. package/templates/naome-root/.naome/repository-model.json +6 -0
  142. package/templates/naome-root/.naome/repository-quality.json +3 -1
  143. package/templates/naome-root/.naome/verification.json +15 -1
  144. package/templates/naome-root/.naomeignore +1 -0
  145. package/templates/naome-root/AGENTS.md +38 -83
  146. package/templates/naome-root/docs/naome/agent-workflow.md +66 -28
  147. package/templates/naome-root/docs/naome/codex-hooks.md +82 -0
  148. package/templates/naome-root/docs/naome/context-economy.md +73 -0
  149. package/templates/naome-root/docs/naome/first-run.md +25 -14
  150. package/templates/naome-root/docs/naome/index.md +18 -10
  151. package/templates/naome-root/docs/naome/repository-model.md +92 -0
  152. package/templates/naome-root/docs/naome/repository-quality.md +104 -5
  153. package/templates/naome-root/docs/naome/repository-structure.md +10 -3
  154. package/templates/naome-root/docs/naome/task-ledger.md +71 -0
  155. package/templates/naome-root/docs/naome/testing.md +16 -3
package/Cargo.lock CHANGED
@@ -76,7 +76,7 @@ checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
76
76
 
77
77
  [[package]]
78
78
  name = "naome-cli"
79
- version = "1.2.1"
79
+ version = "1.3.1"
80
80
  dependencies = [
81
81
  "naome-core",
82
82
  "serde_json",
@@ -84,7 +84,7 @@ dependencies = [
84
84
 
85
85
  [[package]]
86
86
  name = "naome-core"
87
- version = "1.2.1"
87
+ version = "1.3.1"
88
88
  dependencies = [
89
89
  "serde",
90
90
  "serde_json",
package/README.md CHANGED
@@ -1,70 +1,140 @@
1
- # NAOME
2
-
3
- [![npm version](https://img.shields.io/npm/v/@lamentis/naome.svg)](https://www.npmjs.com/package/@lamentis/naome)
4
- [![license: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-green.svg)](LICENSE)
5
-
6
- NAOME is a deterministic repository harness for AI coding agents. It teaches an
7
- agent how to enter a repository, routes ambiguous user requests through explicit
8
- policy, gates work by task scope, and requires proof before completed changes
9
- are baselined.
10
-
11
- ## What NAOME Provides
12
-
13
- - Repository intake with `.naomeignore`, workflow docs, and health checks.
14
- - Task admission and progress gates that prevent unowned diffs and scope drift.
15
- - Rust-backed `status`, `next`, `route`, `commit`, quality, and workflow
16
- commands.
17
- - Intent routing that separates repository state from structured task intent.
18
- - Repository-quality checks for changed files, with old debt visible through
19
- cleanup flows instead of blocking every legacy codebase.
20
- - Verification phases for health, quality, focused tests, broad tests, package
21
- gates, and final diff checks.
22
- - Compact task proof data so repeated evidence and shared check metadata do not
23
- bloat `.naome/task-state.json`.
24
- - Local Git hooks and commit gates that keep manual commits aligned with the
25
- same harness policy.
26
-
27
- ## Install
28
-
29
- ```sh
1
+ <p align="center">
2
+ <a href="https://www.npmjs.com/package/@lamentis/naome"><img src="https://img.shields.io/npm/v/@lamentis/naome.svg" alt="npm version"></a>
3
+ <a href="../../LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-green.svg" alt="Apache-2.0 license"></a>
4
+ </p>
5
+
6
+ <h1 align="center">NAOME</h1>
7
+
8
+ <p align="center">
9
+ A deterministic repository harness for AI coding agents.
10
+ </p>
11
+
12
+ ```shell
30
13
  npm install -g @lamentis/naome
31
14
  ```
32
15
 
33
- ## Set Up A Repository
16
+ NAOME gives coding agents a repository-local operating protocol: what to read,
17
+ what to ignore, how to admit a task, which files are in scope, which checks are
18
+ required, and when work is safe to commit.
19
+
20
+ ## Quickstart
34
21
 
35
- From the repository root:
22
+ Install the CLI, then sync NAOME into a repository:
36
23
 
37
- ```sh
24
+ ```shell
25
+ npm install -g @lamentis/naome
26
+ cd /path/to/repo
38
27
  naome sync
39
28
  ```
40
29
 
41
- If the CLI reports that an update is available, refresh the global CLI and then
42
- sync the harness files:
30
+ For an initialized repository, start with:
43
31
 
44
- ```sh
45
- naome update
46
- naome sync
32
+ ```shell
33
+ naome status
34
+ naome next
35
+ naome doctor
36
+ ```
37
+
38
+ For agent-driven work, route the user's request through the harness:
39
+
40
+ ```shell
41
+ naome route --prompt-file /path/to/prompt.txt --execute --json
47
42
  ```
48
43
 
49
- Fresh repositories print a first-run prompt for your coding agent. Existing
50
- initialized repositories keep normal sync output compact and do not reprint the
51
- first-run protocol unless setup is still incomplete.
44
+ ## Why NAOME?
45
+
46
+ - Keeps agents inside explicit task scope.
47
+ - Blocks unowned diffs before new work starts.
48
+ - Separates current task work from repository cleanup debt.
49
+ - Runs changed-code quality gates without forcing legacy repositories to be
50
+ perfect on day one.
51
+ - Records verification proof before a task can be treated as complete.
52
+ - Keeps sync fast by making baseline and deep quality scans explicit.
53
+ - Can install optional Codex hooks for earlier agent feedback without making
54
+ hooks a human workflow requirement.
55
+
56
+ ## Safety Model
57
+
58
+ NAOME is repository-local. The files under `.naome/`, `.naomeignore`, and
59
+ `docs/naome/` define the local harness contract for a repository.
52
60
 
53
- ## Daily Workflow
61
+ The harness enforces read boundaries, task admission, scope drift checks,
62
+ repository-quality policy, verification phases, and commit gates. Existing debt
63
+ is reportable through cleanup flows, while changed files are held to the active
64
+ policy.
54
65
 
55
- Use NAOME commands from the target repository:
66
+ ## CLI Reference
56
67
 
57
- ```sh
68
+ Common commands:
69
+
70
+ ```shell
71
+ naome sync
72
+ naome update
58
73
  naome status
59
74
  naome next
75
+ naome doctor
60
76
  naome route --prompt-file /path/to/prompt.txt --execute --json
77
+ naome quality init
78
+ naome quality init --baseline
79
+ naome quality report
80
+ naome quality report --deep
81
+ naome quality check --changed
82
+ naome semantic check --changed
83
+ naome task render-state --write --json
61
84
  naome commit -m "type(scope): summary"
62
85
  ```
63
86
 
64
- Agents should read the NAOME docs named by `status` or `route`, run harness
65
- health before feature work, keep changes inside the active task scope, and
66
- record verification proof before marking work complete.
87
+ `naome sync` installs or repairs the local harness files. It does not run a
88
+ hidden full-repository quality scan. It also migrates any active legacy
89
+ task-state into the task ledger automatically. If quality policy is newly
90
+ seeded, run `naome quality init --baseline` deliberately; use `--deep` or
91
+ `--deep-baseline` only when you want expensive repository-wide checks.
92
+
93
+ ## Repository Docs
94
+
95
+ After sync, NAOME writes the agent-facing workflow into `docs/naome/`:
96
+
97
+ - `docs/naome/index.md` is the entry point.
98
+ - `docs/naome/agent-workflow.md` explains the active task workflow.
99
+ - `docs/naome/testing.md` maps change types to required checks.
100
+ - `docs/naome/repository-quality.md` explains quality, structure, and cleanup
101
+ policy.
102
+ - `docs/naome/codex-hooks.md` explains the optional Codex hook acceleration
103
+ layer.
104
+
105
+ Agents should follow the repository's NAOME docs instead of guessing workflow
106
+ rules from generic project files.
107
+
108
+ ## Configuration
109
+
110
+ The main local policy files are:
111
+
112
+ - `.naomeignore` for read boundaries.
113
+ - `.naome/verification.json` for check phases and proof requirements.
114
+ - `.naome/repository-quality.json` for file, symbol, duplicate, and semantic
115
+ quality policy.
116
+ - `.naome/repository-structure.json` for path role, module, and directory
117
+ structure policy.
118
+ - `.naome/task-state.json` for active task state and proof.
119
+ - `.codex/hooks.json` only when optional Codex hooks were explicitly enabled.
120
+
121
+ Product defaults stay generic. Repository-specific policy belongs in the local
122
+ `.naome/` config files.
123
+
124
+ ## Development
125
+
126
+ Useful checks for this repository:
127
+
128
+ ```shell
129
+ npm run build:rust
130
+ npm run test:decision-engine
131
+ npm run test:naome-installer
132
+ npm run pack:dry-run
133
+ node .naome/bin/naome.js quality check --changed --json
134
+ node .naome/bin/naome.js semantic check --changed --json
135
+ git diff --check
136
+ ```
67
137
 
68
138
  ## License
69
139
 
70
- NAOME is licensed under the [Apache License 2.0](LICENSE).
140
+ NAOME is licensed under the [Apache License 2.0](../../LICENSE).
package/bin/naome.js CHANGED
@@ -12,7 +12,7 @@ const packageVersion = packageMetadata.version;
12
12
  const nativeBinaryName = process.platform === "win32" ? "naome.exe" : "naome";
13
13
  const args = process.argv.slice(2);
14
14
  const [command] = args;
15
- const helpCommands = "status [--json]|next [--json]|intent --prompt-file <path> [--json]|intent --prompt <text> [--json]|route --prompt-file <path> [--execute] [--json]|route --prompt <text> [--execute] [--json]|explain --prompt-file <path> [--json]|explain --prompt <text> [--json]|install|sync [--check-update]|update [--json] [--execute]|quality init [--json]|quality check --changed [--json]|quality report [--json]|structure report [--json]|structure explain --path <path> [--json]|cleanup plan [--json]|cleanup route --path <path> [--json]|refresh-integrity [--json]|workflow search-profile|check-search|phases|processes|mutations [--json]|commit -m \"type(scope): message\"".split("|");
15
+ const helpCommands = "status [--json]|next [--json]|intent --prompt-file <path> [--json]|intent --prompt <text> [--json]|route --prompt-file <path> [--execute] [--json]|route --prompt <text> [--execute] [--json]|explain --prompt-file <path> [--json]|explain --prompt <text> [--json]|context select --changed [--json]|context select --prompt-file <path> [--json]|context select --prompt <text> [--json]|doctor [--json]|install|sync [--check-update]|update [--json] [--execute]|task render-state [--write] [--json]|task migrate-ledger [--write] [--json]|quality init [--baseline|--deep-baseline] [--json]|quality reconcile [--write] [--json]|quality check --changed [--include-scanned-paths] [--json]|quality check --path <path> [--path <path>...] [--include-scanned-paths] [--json]|quality report [--deep] [--include-scanned-paths] [--json]|quality cache status [--json]|quality cache clear|semantic report [--deep] [--json]|semantic check --changed [--json]|semantic check --path <path> [--path <path>...] [--json]|semantic route --finding <id> [--json]|semantic loop [--json]|repo model [--write] [--json]|repo check [--json]|repo explain --path <path> [--json]|structure report [--json]|structure explain --path <path> [--json]|cleanup plan [--json]|cleanup route --path <path> [--json]|refresh-integrity [--json]|workflow agent-plan|context-delta|proof-plan|capabilities|edit-watchdog|decision-gate|digest [--json]|workflow search-profile|check-search|phases|processes|mutations [--json]|commit -m \"type(scope): message\"".split("|");
16
16
 
17
17
  if (isHelpRequest(args)) {
18
18
  printHelp();
@@ -31,6 +31,7 @@ if (command === "install" || command === "sync") {
31
31
  const qualityConfigExisted = existsSync(repositoryQualityConfigPath(process.cwd()));
32
32
  const result = runNativePackageCommand(args.filter((arg) => arg !== "--check-update"));
33
33
  if (result.status === 0) {
34
+ ensureTaskLedgerMigrated(result.nativeBinary);
34
35
  ensureRepositoryQualityInitialized(result.nativeBinary, qualityConfigExisted);
35
36
  }
36
37
  process.exit(result.status === null ? 1 : result.status);
@@ -281,8 +282,54 @@ function ensureRepositoryQualityInitialized(nativeBinary, qualityConfigExisted)
281
282
  }
282
283
  }
283
284
 
284
- const result = spawnSync(nativeBinary, ["quality", "init", "--json"], {
285
- cwd: root,
285
+ const output = runNativeJsonCommand(
286
+ nativeBinary,
287
+ ["quality", "init", "--json"],
288
+ "repository quality initialization failed"
289
+ );
290
+ if (output) {
291
+ try {
292
+ const init = JSON.parse(output);
293
+ if (init.configWritten || init.structureConfigWritten) {
294
+ console.log("repository quality policy initialized");
295
+ }
296
+ if (init.baselinePending) {
297
+ console.log("baseline pending: run naome quality init --baseline");
298
+ }
299
+ } catch (_error) {
300
+ console.log(output);
301
+ }
302
+ }
303
+ }
304
+
305
+ function ensureTaskLedgerMigrated(nativeBinary) {
306
+ const root = process.cwd();
307
+ if (!existsSync(join(root, ".naome"))) {
308
+ return;
309
+ }
310
+
311
+ const output = runNativeJsonCommand(
312
+ nativeBinary,
313
+ ["task", "migrate-ledger", "--write", "--json"],
314
+ "task ledger migration failed"
315
+ );
316
+ if (!output) {
317
+ return;
318
+ }
319
+
320
+ try {
321
+ const migration = JSON.parse(output);
322
+ if (migration.updated && migration.migration?.source === "task-state") {
323
+ console.log("task ledger migrated from task-state");
324
+ }
325
+ } catch (_error) {
326
+ console.log(output);
327
+ }
328
+ }
329
+
330
+ function runNativeJsonCommand(nativeBinary, commandArgs, failureLabel) {
331
+ const result = spawnSync(nativeBinary, commandArgs, {
332
+ cwd: process.cwd(),
286
333
  encoding: "utf8",
287
334
  env: {
288
335
  ...process.env,
@@ -291,15 +338,21 @@ function ensureRepositoryQualityInitialized(nativeBinary, qualityConfigExisted)
291
338
  });
292
339
 
293
340
  if (result.status !== 0) {
294
- console.error("NAOME: repository quality initialization failed.");
295
- if (result.stdout.trim()) {
296
- console.error(result.stdout.trim());
297
- }
298
- if (result.stderr.trim()) {
299
- console.error(result.stderr.trim());
341
+ exitNativeJsonFailure(failureLabel, result);
342
+ }
343
+
344
+ return result.stdout.trim();
345
+ }
346
+
347
+ function exitNativeJsonFailure(label, result) {
348
+ console.error(`NAOME: ${label}.`);
349
+ for (const stream of [result.stdout, result.stderr]) {
350
+ const text = stream.trim();
351
+ if (text) {
352
+ console.error(text);
300
353
  }
301
- process.exit(result.status === null ? 1 : result.status);
302
354
  }
355
+ process.exit(result.status === null ? 1 : result.status);
303
356
  }
304
357
 
305
358
  function repositoryQualityConfigPath(root) {
@@ -324,8 +377,8 @@ function repositoryQualitySupportFilesExist(root) {
324
377
  function resolveNativePackageBinary() {
325
378
  const candidates = [
326
379
  process.env.NAOME_NATIVE_BIN && resolve(process.cwd(), process.env.NAOME_NATIVE_BIN),
327
- join(packageRoot, "native", `${process.platform}-${process.arch}`, nativeBinaryName),
328
- join(packageRoot, "target", "release", nativeBinaryName)
380
+ join(packageRoot, "target", "release", nativeBinaryName),
381
+ join(packageRoot, "native", `${process.platform}-${process.arch}`, nativeBinaryName)
329
382
  ].filter(Boolean);
330
383
 
331
384
  for (const candidate of candidates) {
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "naome-cli"
3
- version = "1.2.1"
3
+ version = "1.3.1"
4
4
  edition.workspace = true
5
5
  license.workspace = true
6
6
  repository.workspace = true
@@ -0,0 +1,47 @@
1
+ use std::fs;
2
+ use std::path::Path;
3
+
4
+ use naome_core::{select_context_for_changed_paths, select_context_for_prompt};
5
+
6
+ use crate::cli_args::option_value;
7
+
8
+ pub fn run_context_command(root: &Path, args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
9
+ let Some(subcommand) = args.get(1).map(String::as_str) else {
10
+ return Err("naome context requires select.".into());
11
+ };
12
+ match subcommand {
13
+ "select" => run_context_select(root, args)?,
14
+ _ => return Err(format!("unknown naome context command: {subcommand}").into()),
15
+ }
16
+ Ok(())
17
+ }
18
+
19
+ fn run_context_select(root: &Path, args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
20
+ let selection = if args.iter().any(|arg| arg == "--changed") {
21
+ select_context_for_changed_paths(root)?
22
+ } else if let Some(prompt) = option_value(args, "--prompt") {
23
+ select_context_for_prompt(root, prompt)?
24
+ } else if let Some(prompt_file) = option_value(args, "--prompt-file") {
25
+ select_context_for_prompt(root, fs::read_to_string(prompt_file)?)?
26
+ } else {
27
+ return Err(
28
+ "naome context select requires --changed, --prompt <text>, or --prompt-file <path>."
29
+ .into(),
30
+ );
31
+ };
32
+
33
+ if args.iter().any(|arg| arg == "--json") {
34
+ println!("{}", serde_json::to_string_pretty(&selection)?);
35
+ } else {
36
+ println!(
37
+ "NAOME context capsule: {} ({} file(s), ~{} token(s))",
38
+ selection.capsule.id,
39
+ selection.budget_ledger.selected_files,
40
+ selection.budget_ledger.estimated_tokens
41
+ );
42
+ for item in &selection.required_context {
43
+ println!("- {}", item.path);
44
+ }
45
+ }
46
+ Ok(())
47
+ }
@@ -1,13 +1,18 @@
1
1
  use std::path::Path;
2
2
 
3
3
  use crate::check_commands::{run_harness_health, run_task_state, run_verification_contract};
4
+ use crate::context_commands::run_context_command;
4
5
  use crate::install_bridge::run_install_bridge;
5
6
  use crate::prompt_commands::{run_explain, run_intent, run_route};
6
- use crate::quality_commands::{run_cleanup_command, run_quality_command, run_structure_command};
7
+ use crate::quality_commands::{
8
+ run_cleanup_command, run_quality_command, run_semantic_command, run_structure_command,
9
+ };
10
+ use crate::repository_model_commands::run_repo_command;
7
11
  use crate::simple_commands::{
8
12
  print_install_plan, run_commit_paths, run_journal_task, seed_verification,
9
13
  };
10
- use crate::workflow_commands::{run_refresh_integrity, run_workflow_command};
14
+ use crate::task_commands::run_task_command;
15
+ use crate::workflow_commands::{run_doctor, run_refresh_integrity, run_workflow_command};
11
16
 
12
17
  pub fn dispatch_command(
13
18
  root: &Path,
@@ -18,8 +23,13 @@ pub fn dispatch_command(
18
23
  "install" | "sync" => run_install_bridge(command, args)?,
19
24
  "install-plan" => print_install_plan(args)?,
20
25
  "seed-verification" => seed_verification(root)?,
26
+ "task" => run_task_command(root, args)?,
21
27
  "refresh-integrity" => run_refresh_integrity(root, args)?,
28
+ "context" => run_context_command(root, args)?,
29
+ "doctor" => run_doctor(root, args)?,
22
30
  "quality" => run_quality_command(root, args)?,
31
+ "semantic" => run_semantic_command(root, args)?,
32
+ "repo" => run_repo_command(root, args)?,
23
33
  "structure" => run_structure_command(root, args)?,
24
34
  "cleanup" => run_cleanup_command(root, args)?,
25
35
  "workflow" => run_workflow_command(root, args)?,
@@ -1,10 +1,15 @@
1
1
  mod check_commands;
2
2
  mod cli_args;
3
+ mod context_commands;
3
4
  mod dispatcher;
4
5
  mod install_bridge;
5
6
  mod prompt_commands;
6
7
  mod quality_commands;
8
+ mod quality_output;
9
+ mod quality_reconcile_command;
10
+ mod repository_model_commands;
7
11
  mod simple_commands;
12
+ mod task_commands;
8
13
  mod workflow_commands;
9
14
 
10
15
  use std::path::{Path, PathBuf};
@@ -22,19 +27,44 @@ const HELP: &str = r#"Usage:
22
27
  naome route --prompt <text> [--execute] [--json]
23
28
  naome explain --prompt-file <path> [--json]
24
29
  naome explain --prompt <text> [--json]
30
+ naome context select --changed [--json]
31
+ naome context select --prompt-file <path> [--json]
32
+ naome context select --prompt <text> [--json]
33
+ naome doctor [--json]
25
34
  naome install [--package-root <path>] [--installer-js <path>]
26
35
  naome sync [--package-root <path>] [--installer-js <path>]
27
36
  naome install-plan [--harness-version <version>]
28
37
  naome seed-verification
38
+ naome task render-state [--write] [--json]
39
+ naome task migrate-ledger [--write] [--json]
29
40
  naome refresh-integrity [--root <path>] [--json]
30
- naome quality init [--json]
31
- naome quality check --changed [--json]
32
- naome quality report [--json]
41
+ naome quality init [--baseline|--deep-baseline] [--json]
42
+ naome quality reconcile [--write] [--json]
43
+ naome quality check --changed [--include-scanned-paths] [--json]
44
+ naome quality check --path <path> [--path <path>...] [--include-scanned-paths] [--json]
45
+ naome quality report [--deep] [--include-scanned-paths] [--json]
46
+ naome quality cache status [--json]
47
+ naome quality cache clear
48
+ naome semantic report [--deep] [--json]
49
+ naome semantic check --changed [--json]
50
+ naome semantic check --path <path> [--path <path>...] [--json]
51
+ naome semantic route --finding <id> [--json]
52
+ naome semantic loop [--json]
53
+ naome repo model [--write] [--json]
54
+ naome repo check [--json]
55
+ naome repo explain --path <path> [--json]
33
56
  naome structure report [--json]
34
57
  naome structure explain --path <path> [--json]
35
58
  naome cleanup plan [--json]
36
59
  naome cleanup route --path <path> [--json]
37
60
  naome workflow search-profile [--json]
61
+ naome workflow agent-plan [--json]
62
+ naome workflow context-delta [--read-path <path>...] [--json]
63
+ naome workflow proof-plan [--json]
64
+ naome workflow capabilities [--json]
65
+ naome workflow edit-watchdog --path <path> [--path <path>...] [--json]
66
+ naome workflow decision-gate [--json]
67
+ naome workflow digest --command <cmd> --exit-code <code> [--output <text>|--output-file <path>] [--json]
38
68
  naome workflow check-search --command <cmd> [--json]
39
69
  naome workflow phases [--json]
40
70
  naome workflow processes [--json]
@@ -43,6 +73,33 @@ const HELP: &str = r#"Usage:
43
73
  naome check-task-state [--root <path>] [--admission|--progress|--commit-gate|--push-gate] [--allow-missing-archive]
44
74
  naome validate-verification [--root <path>]"#;
45
75
 
76
+ const PUBLIC_COMMANDS: &[&str] = &[
77
+ "status",
78
+ "next",
79
+ "intent",
80
+ "route",
81
+ "explain",
82
+ "doctor",
83
+ "journal-task",
84
+ "commit-paths",
85
+ "seed-verification",
86
+ "task",
87
+ "refresh-integrity",
88
+ "context",
89
+ "workflow",
90
+ "quality",
91
+ "semantic",
92
+ "repo",
93
+ "structure",
94
+ "cleanup",
95
+ "install-plan",
96
+ "install",
97
+ "sync",
98
+ "check-harness-health",
99
+ "check-task-state",
100
+ "validate-verification",
101
+ ];
102
+
46
103
  fn main() {
47
104
  if let Err(error) = run() {
48
105
  eprintln!("NAOME: {error}");
@@ -62,26 +119,7 @@ fn run() -> Result<(), Box<dyn std::error::Error>> {
62
119
  return Ok(());
63
120
  }
64
121
 
65
- if command != "status"
66
- && command != "next"
67
- && command != "intent"
68
- && command != "route"
69
- && command != "explain"
70
- && command != "journal-task"
71
- && command != "commit-paths"
72
- && command != "seed-verification"
73
- && command != "refresh-integrity"
74
- && command != "workflow"
75
- && command != "quality"
76
- && command != "structure"
77
- && command != "cleanup"
78
- && command != "install-plan"
79
- && command != "install"
80
- && command != "sync"
81
- && command != "check-harness-health"
82
- && command != "check-task-state"
83
- && command != "validate-verification"
84
- {
122
+ if !PUBLIC_COMMANDS.contains(&command) {
85
123
  print_help();
86
124
  return Err(format!("unknown command: {command}").into());
87
125
  }
@@ -128,7 +166,13 @@ fn is_help_request(args: &[String]) -> bool {
128
166
  }
129
167
 
130
168
  fn find_harness_root(start: &Path) -> Option<PathBuf> {
131
- find_root_with_marker(start, &[".naome", "task-state.json"])
169
+ find_root_with_any_marker(
170
+ start,
171
+ &[
172
+ &[".naome", "task-state.json"],
173
+ &[".naome", "tasks", "active.json"],
174
+ ],
175
+ )
132
176
  }
133
177
 
134
178
  fn find_manifest_root(start: &Path) -> Option<PathBuf> {
@@ -136,13 +180,18 @@ fn find_manifest_root(start: &Path) -> Option<PathBuf> {
136
180
  }
137
181
 
138
182
  fn find_root_with_marker(start: &Path, marker: &[&str]) -> Option<PathBuf> {
183
+ find_root_with_any_marker(start, &[marker])
184
+ }
185
+
186
+ fn find_root_with_any_marker(start: &Path, markers: &[&[&str]]) -> Option<PathBuf> {
139
187
  let mut current = start.to_path_buf();
140
188
  loop {
141
- if marker
142
- .iter()
143
- .fold(current.clone(), |path, part| path.join(part))
144
- .is_file()
145
- {
189
+ if markers.iter().any(|marker| {
190
+ marker
191
+ .iter()
192
+ .fold(current.clone(), |path, part| path.join(part))
193
+ .is_file()
194
+ }) {
146
195
  return Some(current);
147
196
  }
148
197