@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.
- package/Cargo.lock +2 -2
- package/README.md +117 -47
- package/bin/naome.js +65 -12
- package/crates/naome-cli/Cargo.toml +1 -1
- package/crates/naome-cli/src/context_commands.rs +47 -0
- package/crates/naome-cli/src/dispatcher.rs +12 -2
- package/crates/naome-cli/src/main.rs +78 -29
- package/crates/naome-cli/src/quality_commands.rs +238 -34
- package/crates/naome-cli/src/quality_output.rs +34 -0
- package/crates/naome-cli/src/quality_reconcile_command.rs +45 -0
- package/crates/naome-cli/src/repository_model_commands.rs +84 -0
- package/crates/naome-cli/src/task_commands.rs +62 -0
- package/crates/naome-cli/src/workflow_commands.rs +120 -3
- package/crates/naome-core/Cargo.toml +1 -1
- package/crates/naome-core/src/context/helpers.rs +75 -0
- package/crates/naome-core/src/context/select.rs +134 -0
- package/crates/naome-core/src/context/types.rs +43 -0
- package/crates/naome-core/src/context.rs +6 -0
- package/crates/naome-core/src/decision/states.rs +1 -1
- package/crates/naome-core/src/decision.rs +4 -1
- package/crates/naome-core/src/git.rs +4 -2
- package/crates/naome-core/src/install_plan.rs +20 -0
- package/crates/naome-core/src/journal.rs +2 -7
- package/crates/naome-core/src/lib.rs +35 -8
- package/crates/naome-core/src/quality/adapter_ios.rs +131 -0
- package/crates/naome-core/src/quality/adapter_support.rs +67 -0
- package/crates/naome-core/src/quality/adapters.rs +81 -18
- package/crates/naome-core/src/quality/baseline.rs +8 -0
- package/crates/naome-core/src/quality/cache.rs +151 -0
- package/crates/naome-core/src/quality/checks/duplicate_blocks.rs +19 -8
- package/crates/naome-core/src/quality/checks/near_duplicates.rs +4 -2
- package/crates/naome-core/src/quality/checks.rs +7 -8
- package/crates/naome-core/src/quality/cleanup.rs +36 -3
- package/crates/naome-core/src/quality/config.rs +21 -3
- package/crates/naome-core/src/quality/mod.rs +189 -10
- package/crates/naome-core/src/quality/reconcile.rs +138 -0
- package/crates/naome-core/src/quality/reconcile_anchors.rs +64 -0
- package/crates/naome-core/src/quality/scanner/analysis/normalize.rs +78 -0
- package/crates/naome-core/src/quality/scanner/analysis.rs +175 -0
- package/crates/naome-core/src/quality/scanner/repo_paths.rs +39 -3
- package/crates/naome-core/src/quality/scanner.rs +235 -217
- package/crates/naome-core/src/quality/semantic/checks.rs +151 -0
- package/crates/naome-core/src/quality/semantic/extract.rs +158 -0
- package/crates/naome-core/src/quality/semantic/model.rs +85 -0
- package/crates/naome-core/src/quality/semantic/route.rs +52 -0
- package/crates/naome-core/src/quality/semantic.rs +68 -0
- package/crates/naome-core/src/quality/structure/adapter_ios.rs +149 -0
- package/crates/naome-core/src/quality/structure/adapters.rs +60 -42
- package/crates/naome-core/src/quality/structure/checks/directory.rs +13 -21
- package/crates/naome-core/src/quality/structure/checks.rs +1 -1
- package/crates/naome-core/src/quality/structure/classify/roles.rs +51 -5
- package/crates/naome-core/src/quality/structure/classify.rs +52 -0
- package/crates/naome-core/src/quality/structure/config.rs +24 -3
- package/crates/naome-core/src/quality/structure/mod.rs +5 -2
- package/crates/naome-core/src/quality/structure/model.rs +8 -1
- package/crates/naome-core/src/quality/types.rs +59 -2
- package/crates/naome-core/src/repository_model/detect.rs +188 -0
- package/crates/naome-core/src/repository_model/explain.rs +121 -0
- package/crates/naome-core/src/repository_model/path_scan.rs +67 -0
- package/crates/naome-core/src/repository_model/path_support.rs +59 -0
- package/crates/naome-core/src/repository_model/types.rs +152 -0
- package/crates/naome-core/src/repository_model/world.rs +48 -0
- package/crates/naome-core/src/repository_model/world_adapters.rs +145 -0
- package/crates/naome-core/src/repository_model/world_path_facts.rs +55 -0
- package/crates/naome-core/src/repository_model/world_paths.rs +168 -0
- package/crates/naome-core/src/repository_model.rs +164 -0
- package/crates/naome-core/src/route/builtin_checks.rs +41 -16
- package/crates/naome-core/src/task_ledger/import.rs +142 -0
- package/crates/naome-core/src/task_ledger/model.rs +13 -0
- package/crates/naome-core/src/task_ledger/proof_record.rs +52 -0
- package/crates/naome-core/src/task_ledger/read.rs +118 -0
- package/crates/naome-core/src/task_ledger/render.rs +55 -0
- package/crates/naome-core/src/task_ledger/write.rs +38 -0
- package/crates/naome-core/src/task_ledger.rs +48 -0
- package/crates/naome-core/src/task_state/api.rs +4 -2
- package/crates/naome-core/src/task_state/completed_refresh.rs +5 -16
- package/crates/naome-core/src/task_state/diff.rs +2 -2
- package/crates/naome-core/src/task_state/evidence.rs +8 -3
- package/crates/naome-core/src/task_state/mod.rs +1 -1
- package/crates/naome-core/src/task_state/progress.rs +13 -0
- package/crates/naome-core/src/task_state/proof_model.rs +8 -8
- package/crates/naome-core/src/task_state/repair.rs +2 -2
- package/crates/naome-core/src/task_state/task_diff_api.rs +9 -18
- package/crates/naome-core/src/task_state/types.rs +24 -0
- package/crates/naome-core/src/verification.rs +29 -18
- package/crates/naome-core/src/workflow/agent/capability.rs +194 -0
- package/crates/naome-core/src/workflow/agent/context_delta.rs +42 -0
- package/crates/naome-core/src/workflow/agent/decision.rs +32 -0
- package/crates/naome-core/src/workflow/agent/execution.rs +80 -0
- package/crates/naome-core/src/workflow/agent/proof.rs +24 -0
- package/crates/naome-core/src/workflow/agent/support.rs +58 -0
- package/crates/naome-core/src/workflow/agent/watchdog.rs +47 -0
- package/crates/naome-core/src/workflow/agent.rs +34 -0
- package/crates/naome-core/src/workflow/agent_types.rs +105 -0
- package/crates/naome-core/src/workflow/doctor.rs +183 -0
- package/crates/naome-core/src/workflow/mod.rs +13 -0
- package/crates/naome-core/src/workflow/mutation.rs +1 -2
- package/crates/naome-core/src/workflow/output.rs +8 -2
- package/crates/naome-core/src/workflow/phase_inference.rs +1 -1
- package/crates/naome-core/tests/context.rs +99 -0
- package/crates/naome-core/tests/harness_health.rs +4 -0
- package/crates/naome-core/tests/install_plan.rs +14 -0
- package/crates/naome-core/tests/quality.rs +190 -5
- package/crates/naome-core/tests/quality_performance.rs +268 -0
- package/crates/naome-core/tests/quality_structure_adapters.rs +39 -0
- package/crates/naome-core/tests/quality_structure_policy.rs +19 -0
- package/crates/naome-core/tests/repo_support/mod.rs +5 -1
- package/crates/naome-core/tests/repo_support/verification_values.rs +55 -0
- package/crates/naome-core/tests/repository_model.rs +281 -0
- package/crates/naome-core/tests/route_user_diff.rs +59 -7
- package/crates/naome-core/tests/semantic_legacy.rs +174 -0
- package/crates/naome-core/tests/task_ledger.rs +328 -0
- package/crates/naome-core/tests/task_state.rs +28 -0
- package/crates/naome-core/tests/verification.rs +29 -36
- package/crates/naome-core/tests/workflow_agent.rs +233 -0
- package/crates/naome-core/tests/workflow_agent_support/mod.rs +159 -0
- package/crates/naome-core/tests/workflow_doctor.rs +45 -0
- package/crates/naome-core/tests/workflow_policy.rs +6 -1
- package/installer/codex-hooks.js +121 -0
- package/installer/context.js +10 -0
- package/installer/filesystem.js +4 -0
- package/installer/flows.js +8 -4
- package/installer/git-boundary.js +1 -0
- package/installer/harness-files.js +6 -0
- package/installer/install-plan.js +4 -0
- package/installer/main.js +1 -1
- package/installer/native.js +1 -1
- package/native/darwin-arm64/naome +0 -0
- package/native/linux-x64/naome +0 -0
- package/package.json +1 -1
- package/templates/naome-root/.codex/config.toml +2 -0
- package/templates/naome-root/.codex/hooks.json +70 -0
- package/templates/naome-root/.naome/bin/check-harness-health.js +8 -6
- package/templates/naome-root/.naome/bin/check-task-state.js +12 -7
- package/templates/naome-root/.naome/bin/codex-hook-io.js +122 -0
- package/templates/naome-root/.naome/bin/codex-hook-policy.js +180 -0
- package/templates/naome-root/.naome/bin/codex-hook-runtime.js +174 -0
- package/templates/naome-root/.naome/bin/codex-hook.js +6 -0
- package/templates/naome-root/.naome/bin/naome.js +45 -7
- package/templates/naome-root/.naome/manifest.json +12 -6
- package/templates/naome-root/.naome/repository-model.json +6 -0
- package/templates/naome-root/.naome/repository-quality.json +3 -1
- package/templates/naome-root/.naome/verification.json +15 -1
- package/templates/naome-root/.naomeignore +1 -0
- package/templates/naome-root/AGENTS.md +38 -83
- package/templates/naome-root/docs/naome/agent-workflow.md +66 -28
- package/templates/naome-root/docs/naome/codex-hooks.md +82 -0
- package/templates/naome-root/docs/naome/context-economy.md +73 -0
- package/templates/naome-root/docs/naome/first-run.md +25 -14
- package/templates/naome-root/docs/naome/index.md +18 -10
- package/templates/naome-root/docs/naome/repository-model.md +92 -0
- package/templates/naome-root/docs/naome/repository-quality.md +104 -5
- package/templates/naome-root/docs/naome/repository-structure.md +10 -3
- package/templates/naome-root/docs/naome/task-ledger.md +71 -0
- 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.
|
|
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.
|
|
87
|
+
version = "1.3.1"
|
|
88
88
|
dependencies = [
|
|
89
89
|
"serde",
|
|
90
90
|
"serde_json",
|
package/README.md
CHANGED
|
@@ -1,70 +1,140 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
NAOME
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
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
|
-
|
|
22
|
+
Install the CLI, then sync NAOME into a repository:
|
|
36
23
|
|
|
37
|
-
```
|
|
24
|
+
```shell
|
|
25
|
+
npm install -g @lamentis/naome
|
|
26
|
+
cd /path/to/repo
|
|
38
27
|
naome sync
|
|
39
28
|
```
|
|
40
29
|
|
|
41
|
-
|
|
42
|
-
sync the harness files:
|
|
30
|
+
For an initialized repository, start with:
|
|
43
31
|
|
|
44
|
-
```
|
|
45
|
-
naome
|
|
46
|
-
naome
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
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
|
-
|
|
66
|
+
## CLI Reference
|
|
56
67
|
|
|
57
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
|
285
|
-
|
|
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
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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, "
|
|
328
|
-
join(packageRoot, "
|
|
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) {
|
|
@@ -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::{
|
|
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::
|
|
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
|
|
32
|
-
naome quality
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
|