onto-mcp 0.3.2 → 0.4.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.
- package/.onto/processes/reconstruct/actionable-ontology-seed-recomposition-design.md +447 -0
- package/.onto/processes/reconstruct/foundry-style-ontology-seed-contract.md +934 -0
- package/.onto/processes/reconstruct/reconstruct-boundary-contract.md +303 -725
- package/.onto/processes/reconstruct/reconstruct-contract-registry.yaml +1645 -0
- package/.onto/processes/reconstruct/reconstruct-execution-ux-contract.md +26 -22
- package/.onto/processes/reconstruct/source-profile-contract.md +49 -23
- package/.onto/processes/reconstruct/source-profiles/code.md +6 -3
- package/.onto/processes/reconstruct/source-profiles/database.md +5 -2
- package/.onto/processes/reconstruct/source-profiles/document.md +5 -2
- package/.onto/processes/reconstruct/source-profiles/spreadsheet.md +5 -4
- package/.onto/processes/review/review-execution-ux-contract.md +40 -0
- package/.onto/processes/shared/pipeline-execution-ledger-contract.md +26 -10
- package/.onto/processes/shared/target-material-kind-contract.md +29 -16
- package/AGENTS.md +6 -4
- package/README.md +135 -76
- package/dist/cli.js +8 -8
- package/dist/core-api/reconstruct-api.js +117 -31
- package/dist/core-api/review-api.js +47 -0
- package/dist/core-runtime/cli/codex-review-unit-executor.js +39 -2
- package/dist/core-runtime/cli/complete-review-session.js +2 -2
- package/dist/core-runtime/cli/mock-review-unit-executor.js +1 -1
- package/dist/core-runtime/cli/review-invoke.js +9 -9
- package/dist/core-runtime/cli/run-review-prompt-execution.js +39 -5
- package/dist/core-runtime/cli/spawn-watcher.js +266 -47
- package/dist/core-runtime/cli/start-review-session.js +3 -3
- package/dist/core-runtime/llm/llm-caller.js +11 -0
- package/dist/core-runtime/llm/llm-tool-loop.js +2 -0
- package/dist/core-runtime/observability/runtime-stream-observation.js +118 -0
- package/dist/core-runtime/onboard/cli-host.js +149 -0
- package/dist/core-runtime/onboard/host-target.js +22 -0
- package/dist/core-runtime/onboard/json-config-host.js +122 -0
- package/dist/core-runtime/onboard/path-scan.js +26 -0
- package/dist/core-runtime/onboard/prompt.js +51 -0
- package/dist/core-runtime/onboard/register.js +207 -0
- package/dist/core-runtime/onboard/types.js +27 -0
- package/dist/core-runtime/reconstruct/actionable-seed-validation.js +1777 -0
- package/dist/core-runtime/reconstruct/artifact-types.js +10 -4
- package/dist/core-runtime/reconstruct/contract-registry.js +623 -0
- package/dist/core-runtime/reconstruct/domain-id.js +10 -0
- package/dist/core-runtime/reconstruct/governing-snapshot.js +716 -0
- package/dist/core-runtime/reconstruct/material-profile-validation.js +191 -0
- package/dist/core-runtime/reconstruct/materialize-preparation.js +49 -11
- package/dist/core-runtime/reconstruct/pipeline-execution-ledger.js +269 -79
- package/dist/core-runtime/reconstruct/post-seed-validation.js +1194 -51
- package/dist/core-runtime/reconstruct/record.js +104 -20
- package/dist/core-runtime/reconstruct/run.js +2107 -413
- package/dist/core-runtime/reconstruct/seed-claim-projections.js +268 -0
- package/dist/core-runtime/reconstruct/source-profiles.js +93 -4
- package/dist/core-runtime/reconstruct/terminal-validation.js +807 -0
- package/dist/core-runtime/review/review-invocation-runner.js +4 -4
- package/dist/mcp/server.js +110 -38
- package/dist/mcp/tool-schemas.js +20 -6
- package/package.json +8 -17
- package/scripts/onto-review-watch.sh +486 -0
- package/scripts/onto-runtime-watch.sh +122 -0
- package/scripts/postinstall-hint.js +22 -0
- package/.onto/processes/reconstruct/top-level-concept-discovery-contract.md +0 -387
- package/dist/core-runtime/cli/bootstrap-review-binding.js +0 -186
- package/dist/core-runtime/cli/codex-nested-dispatch.test.js +0 -390
- package/dist/core-runtime/cli/codex-nested-teamlead-executor.test.js +0 -335
- package/dist/core-runtime/cli/coordinator-helpers.js +0 -583
- package/dist/core-runtime/cli/coordinator-state-machine-deliberation.test.js +0 -167
- package/dist/core-runtime/cli/coordinator-state-machine.js +0 -794
- package/dist/core-runtime/cli/e2e-codex-multi-agent-fixes.test.js +0 -615
- package/dist/core-runtime/cli/e2e-start-review-session.test.js +0 -312
- package/dist/core-runtime/cli/health.js +0 -44
- package/dist/core-runtime/cli/inline-http-review-unit-executor.test.js +0 -567
- package/dist/core-runtime/cli/materialize-review-execution-preparation.js +0 -104
- package/dist/core-runtime/cli/migrate-session-roots.js +0 -118
- package/dist/core-runtime/cli/repo-layout-migration-replace.smoke.test.js +0 -106
- package/dist/core-runtime/cli/review-invoke-auto-resolution.test.js +0 -268
- package/dist/core-runtime/cli/review-invoke-coordinator-topology.test.js +0 -136
- package/dist/core-runtime/cli/review-invoke-resolver-caching.test.js +0 -201
- package/dist/core-runtime/cli/review-invoke-topology-dispatch.test.js +0 -192
- package/dist/core-runtime/cli/session-root-guard.js +0 -168
- package/dist/core-runtime/cli/spawn-watcher.test.js +0 -457
- package/dist/core-runtime/cli/strip-wrapping-code-fence.test.js +0 -79
- package/dist/core-runtime/cli/teamcreate-lens-deliberation-executor.js +0 -412
- package/dist/core-runtime/cli/teamcreate-lens-deliberation-executor.test.js +0 -351
- package/dist/core-runtime/cli/topology-executor-mapping.js +0 -139
- package/dist/core-runtime/cli/topology-executor-mapping.test.js +0 -173
- package/dist/core-runtime/cli/write-review-interpretation.js +0 -81
- package/dist/core-runtime/config/onto-config-cli.js +0 -278
- package/dist/core-runtime/config/onto-config-key-path.js +0 -288
- package/dist/core-runtime/config/onto-config-key-path.test.js +0 -195
- package/dist/core-runtime/config/onto-config-preview.js +0 -108
- package/dist/core-runtime/config/onto-config-preview.test.js +0 -132
- package/dist/core-runtime/discovery/config-chain.js +0 -118
- package/dist/core-runtime/discovery/config-chain.test.js +0 -103
- package/dist/core-runtime/discovery/config-profile.js +0 -199
- package/dist/core-runtime/discovery/config-profile.test.js +0 -233
- package/dist/core-runtime/discovery/host-detection.test.js +0 -186
- package/dist/core-runtime/discovery/installation-paths.test.js +0 -65
- package/dist/core-runtime/discovery/lens-registry.test.js +0 -81
- package/dist/core-runtime/discovery/path-normalization.test.js +0 -22
- package/dist/core-runtime/discovery/plugin-path.js +0 -72
- package/dist/core-runtime/discovery/plugin-path.test.js +0 -95
- package/dist/core-runtime/evolve/adapters/code-product/compile/compile-defense.js +0 -344
- package/dist/core-runtime/evolve/adapters/code-product/compile/compile-defense.test.js +0 -915
- package/dist/core-runtime/evolve/adapters/code-product/compile/compile.js +0 -564
- package/dist/core-runtime/evolve/adapters/code-product/compile/compile.test.js +0 -708
- package/dist/core-runtime/evolve/adapters/code-product/parsers/brief-parser.js +0 -165
- package/dist/core-runtime/evolve/adapters/code-product/parsers/brief-parser.test.js +0 -227
- package/dist/core-runtime/evolve/adapters/code-product/validators/validate.js +0 -59
- package/dist/core-runtime/evolve/adapters/code-product/validators/validate.test.js +0 -205
- package/dist/core-runtime/evolve/adapters/methodology/adapter.js +0 -16
- package/dist/core-runtime/evolve/adapters/methodology/adapter.test.js +0 -9
- package/dist/core-runtime/evolve/adapters/methodology/perspectives/authority-consistency.js +0 -298
- package/dist/core-runtime/evolve/adapters/methodology/perspectives/authority-consistency.test.js +0 -70
- package/dist/core-runtime/evolve/adapters/methodology/scope-types/process.js +0 -46
- package/dist/core-runtime/evolve/adapters/methodology/scope-types/process.test.js +0 -73
- package/dist/core-runtime/evolve/adapters/registry.js +0 -47
- package/dist/core-runtime/evolve/adapters/registry.test.js +0 -67
- package/dist/core-runtime/evolve/cli.js +0 -256
- package/dist/core-runtime/evolve/commands/align.js +0 -194
- package/dist/core-runtime/evolve/commands/align.test.js +0 -82
- package/dist/core-runtime/evolve/commands/apply.js +0 -161
- package/dist/core-runtime/evolve/commands/apply.test.js +0 -138
- package/dist/core-runtime/evolve/commands/close.js +0 -39
- package/dist/core-runtime/evolve/commands/close.test.js +0 -99
- package/dist/core-runtime/evolve/commands/defer.js +0 -40
- package/dist/core-runtime/evolve/commands/defer.test.js +0 -134
- package/dist/core-runtime/evolve/commands/draft.js +0 -323
- package/dist/core-runtime/evolve/commands/draft.test.js +0 -178
- package/dist/core-runtime/evolve/commands/e2e-evolve-full-cycle.test.js +0 -208
- package/dist/core-runtime/evolve/commands/error-messages.js +0 -125
- package/dist/core-runtime/evolve/commands/error-messages.test.js +0 -167
- package/dist/core-runtime/evolve/commands/propose-align.js +0 -222
- package/dist/core-runtime/evolve/commands/propose-align.test.js +0 -136
- package/dist/core-runtime/evolve/commands/reconstruct.js +0 -330
- package/dist/core-runtime/evolve/commands/reconstruct.test.js +0 -278
- package/dist/core-runtime/evolve/commands/shared.js +0 -22
- package/dist/core-runtime/evolve/commands/stale-check.js +0 -103
- package/dist/core-runtime/evolve/commands/stale-check.test.js +0 -84
- package/dist/core-runtime/evolve/commands/start.js +0 -887
- package/dist/core-runtime/evolve/commands/start.test.js +0 -396
- package/dist/core-runtime/evolve/config/project-config.js +0 -99
- package/dist/core-runtime/evolve/config/project-config.test.js +0 -170
- package/dist/core-runtime/evolve/renderers/align-packet.js +0 -280
- package/dist/core-runtime/evolve/renderers/align-packet.test.js +0 -332
- package/dist/core-runtime/evolve/renderers/draft-packet.js +0 -303
- package/dist/core-runtime/evolve/renderers/draft-packet.test.js +0 -377
- package/dist/core-runtime/evolve/renderers/format.js +0 -5
- package/dist/core-runtime/evolve/renderers/scope-md.js +0 -237
- package/dist/core-runtime/evolve/renderers/scope-md.test.js +0 -306
- package/dist/core-runtime/govern/cli.js +0 -369
- package/dist/core-runtime/govern/cli.test.js +0 -314
- package/dist/core-runtime/govern/drift-engine.js +0 -103
- package/dist/core-runtime/govern/drift-engine.test.js +0 -319
- package/dist/core-runtime/govern/promote-principle.js +0 -206
- package/dist/core-runtime/govern/promote-principle.test.js +0 -368
- package/dist/core-runtime/govern/queue.js +0 -81
- package/dist/core-runtime/govern/types.js +0 -16
- package/dist/core-runtime/install/cli.js +0 -530
- package/dist/core-runtime/install/detect.js +0 -128
- package/dist/core-runtime/install/detect.test.js +0 -155
- package/dist/core-runtime/install/gitignore-update.js +0 -74
- package/dist/core-runtime/install/gitignore-update.test.js +0 -64
- package/dist/core-runtime/install/install-integration.test.js +0 -373
- package/dist/core-runtime/install/prompts.js +0 -389
- package/dist/core-runtime/install/prompts.test.js +0 -293
- package/dist/core-runtime/install/types.js +0 -26
- package/dist/core-runtime/install/validation.js +0 -295
- package/dist/core-runtime/install/validation.test.js +0 -313
- package/dist/core-runtime/install/writer.js +0 -254
- package/dist/core-runtime/install/writer.test.js +0 -218
- package/dist/core-runtime/learning/extractor.js +0 -461
- package/dist/core-runtime/learning/feedback.js +0 -179
- package/dist/core-runtime/learning/health-report.js +0 -165
- package/dist/core-runtime/learning/health-report.test.js +0 -169
- package/dist/core-runtime/learning/loader.js +0 -388
- package/dist/core-runtime/learning/loader.test.js +0 -102
- package/dist/core-runtime/learning/promote/apply-state.js +0 -240
- package/dist/core-runtime/learning/promote/audit-obligation.js +0 -195
- package/dist/core-runtime/learning/promote/collector.js +0 -432
- package/dist/core-runtime/learning/promote/degraded-state.js +0 -125
- package/dist/core-runtime/learning/promote/domain-doc-proposer.js +0 -166
- package/dist/core-runtime/learning/promote/e2e-promote.test.js +0 -6385
- package/dist/core-runtime/learning/promote/health-snapshot.js +0 -150
- package/dist/core-runtime/learning/promote/insight-reclassifier.js +0 -544
- package/dist/core-runtime/learning/promote/judgment-auditor.js +0 -517
- package/dist/core-runtime/learning/promote/panel-reviewer.js +0 -1158
- package/dist/core-runtime/learning/promote/promote-executor.js +0 -1675
- package/dist/core-runtime/learning/promote/promoter.js +0 -307
- package/dist/core-runtime/learning/promote/retirement.js +0 -122
- package/dist/core-runtime/learning/promote/types.js +0 -23
- package/dist/core-runtime/learning/prompt-sections.js +0 -51
- package/dist/core-runtime/learning/shared/artifact-registry-init.js +0 -45
- package/dist/core-runtime/learning/shared/artifact-registry.js +0 -254
- package/dist/core-runtime/learning/shared/audit-obligation-kernel.js +0 -73
- package/dist/core-runtime/learning/shared/audit-state.js +0 -99
- package/dist/core-runtime/learning/shared/duplicate-check.js +0 -28
- package/dist/core-runtime/learning/shared/llm-caller.js +0 -831
- package/dist/core-runtime/learning/shared/llm-caller.test.js +0 -601
- package/dist/core-runtime/learning/shared/llm-tool-loop.js +0 -393
- package/dist/core-runtime/learning/shared/mode.js +0 -25
- package/dist/core-runtime/learning/shared/paths.js +0 -84
- package/dist/core-runtime/learning/shared/paths.test.js +0 -79
- package/dist/core-runtime/learning/shared/patterns.js +0 -37
- package/dist/core-runtime/learning/shared/recoverability.js +0 -355
- package/dist/core-runtime/learning/shared/recovery-context.js +0 -374
- package/dist/core-runtime/learning/shared/scope.js +0 -1
- package/dist/core-runtime/learning/shared/semantic-classifier.js +0 -94
- package/dist/core-runtime/learning/shared/specs/apply-execution-state-spec.js +0 -42
- package/dist/core-runtime/learning/shared/specs/audit-state-spec.js +0 -37
- package/dist/core-runtime/learning/shared/specs/backup-metadata-spec.js +0 -39
- package/dist/core-runtime/learning/shared/specs/emergency-log-spec.js +0 -41
- package/dist/core-runtime/learning/shared/specs/layout-version-spec.js +0 -38
- package/dist/core-runtime/learning/shared/specs/promote-decisions-spec.js +0 -43
- package/dist/core-runtime/learning/shared/specs/promote-report-spec.js +0 -113
- package/dist/core-runtime/learning/shared/specs/prune-log-spec.js +0 -36
- package/dist/core-runtime/learning/shared/specs/recovery-resolution-spec.js +0 -48
- package/dist/core-runtime/learning/shared/specs/restore-manifest-spec.js +0 -43
- package/dist/core-runtime/learning/shared/specs/spec-helpers.js +0 -64
- package/dist/core-runtime/learning/usage-tracker.js +0 -190
- package/dist/core-runtime/learning/usage-tracker.test.js +0 -176
- package/dist/core-runtime/onboard/detect-review-axes.js +0 -122
- package/dist/core-runtime/onboard/detect-review-axes.test.js +0 -127
- package/dist/core-runtime/onboard/write-review-block.js +0 -188
- package/dist/core-runtime/onboard/write-review-block.test.js +0 -240
- package/dist/core-runtime/readers/brownfield-builder.js +0 -150
- package/dist/core-runtime/readers/brownfield-builder.test.js +0 -136
- package/dist/core-runtime/readers/code-chunk-collector.js +0 -53
- package/dist/core-runtime/readers/code-chunk-collector.test.js +0 -136
- package/dist/core-runtime/readers/file-utils.js +0 -240
- package/dist/core-runtime/readers/file-utils.test.js +0 -146
- package/dist/core-runtime/readers/lexicon-citation-check.js +0 -93
- package/dist/core-runtime/readers/lexicon-citation-check.test.js +0 -77
- package/dist/core-runtime/readers/mcp-figma.js +0 -30
- package/dist/core-runtime/readers/mcp-figma.test.js +0 -82
- package/dist/core-runtime/readers/mcp-generic.js +0 -31
- package/dist/core-runtime/readers/mcp-generic.test.js +0 -76
- package/dist/core-runtime/readers/ontology-index.js +0 -148
- package/dist/core-runtime/readers/ontology-index.test.js +0 -245
- package/dist/core-runtime/readers/ontology-query.js +0 -168
- package/dist/core-runtime/readers/ontology-query.test.js +0 -311
- package/dist/core-runtime/readers/ontology-resolve.js +0 -48
- package/dist/core-runtime/readers/ontology-resolve.test.js +0 -48
- package/dist/core-runtime/readers/patterns/index.js +0 -7
- package/dist/core-runtime/readers/review-log.js +0 -213
- package/dist/core-runtime/readers/review-log.test.js +0 -313
- package/dist/core-runtime/readers/scan-local.js +0 -102
- package/dist/core-runtime/readers/scan-local.test.js +0 -102
- package/dist/core-runtime/readers/scan-tarball.js +0 -121
- package/dist/core-runtime/readers/scan-tarball.test.js +0 -283
- package/dist/core-runtime/readers/scan-vault.js +0 -34
- package/dist/core-runtime/readers/scan-vault.test.js +0 -81
- package/dist/core-runtime/readers/types.js +0 -42
- package/dist/core-runtime/readers/types.test.js +0 -94
- package/dist/core-runtime/readers/viewpoint-collectors.js +0 -229
- package/dist/core-runtime/reconstruct/seed-candidate-validation.js +0 -385
- package/dist/core-runtime/review/citation-audit.test.js +0 -165
- package/dist/core-runtime/review/execution-plan-resolver.js +0 -247
- package/dist/core-runtime/review/execution-plan-resolver.test.js +0 -243
- package/dist/core-runtime/review/execution-topology-resolver-axis-first.test.js +0 -246
- package/dist/core-runtime/review/execution-topology-resolver.js +0 -401
- package/dist/core-runtime/review/execution-topology-resolver.test.js +0 -315
- package/dist/core-runtime/review/inline-context-embedder.test.js +0 -154
- package/dist/core-runtime/review/legacy-mode-policy.js +0 -88
- package/dist/core-runtime/review/materializers-effort-persist.test.js +0 -79
- package/dist/core-runtime/review/ontology-path-classifier.js +0 -179
- package/dist/core-runtime/review/ontology-path-classifier.test.js +0 -216
- package/dist/core-runtime/review/packet-boundary-policy.test.js +0 -107
- package/dist/core-runtime/review/participating-lens-paths.test.js +0 -73
- package/dist/core-runtime/review/review-config-legacy-translate.js +0 -244
- package/dist/core-runtime/review/review-config-legacy-translate.test.js +0 -161
- package/dist/core-runtime/review/review-config-validator.js +0 -289
- package/dist/core-runtime/review/review-config-validator.test.js +0 -236
- package/dist/core-runtime/review/shape-pipeline-audit.test.js +0 -311
- package/dist/core-runtime/review/shape-to-topology-id.js +0 -117
- package/dist/core-runtime/review/shape-to-topology-id.test.js +0 -132
- package/dist/core-runtime/review/topology-shape-derivation.js +0 -155
- package/dist/core-runtime/review/topology-shape-derivation.test.js +0 -195
- package/dist/core-runtime/scope-runtime/constants.js +0 -12
- package/dist/core-runtime/scope-runtime/constraint-pool.js +0 -166
- package/dist/core-runtime/scope-runtime/constraint-pool.test.js +0 -674
- package/dist/core-runtime/scope-runtime/domain-validation-log.js +0 -135
- package/dist/core-runtime/scope-runtime/domain-validation-log.test.js +0 -156
- package/dist/core-runtime/scope-runtime/eval-persistence.js +0 -65
- package/dist/core-runtime/scope-runtime/eval-persistence.test.js +0 -84
- package/dist/core-runtime/scope-runtime/event-pipeline.js +0 -64
- package/dist/core-runtime/scope-runtime/event-pipeline.test.js +0 -450
- package/dist/core-runtime/scope-runtime/event-store.js +0 -39
- package/dist/core-runtime/scope-runtime/event-store.test.js +0 -95
- package/dist/core-runtime/scope-runtime/gate-guard.js +0 -348
- package/dist/core-runtime/scope-runtime/gate-guard.test.js +0 -1047
- package/dist/core-runtime/scope-runtime/hash.js +0 -4
- package/dist/core-runtime/scope-runtime/hash.test.js +0 -33
- package/dist/core-runtime/scope-runtime/id.js +0 -4
- package/dist/core-runtime/scope-runtime/id.test.js +0 -17
- package/dist/core-runtime/scope-runtime/reducer.js +0 -297
- package/dist/core-runtime/scope-runtime/reducer.test.js +0 -759
- package/dist/core-runtime/scope-runtime/scope-manager.js +0 -161
- package/dist/core-runtime/scope-runtime/state-machine.js +0 -309
- package/dist/core-runtime/scope-runtime/state-machine.test.js +0 -704
- package/dist/core-runtime/scope-runtime/types.js +0 -116
- package/dist/core-runtime/scope-runtime/types.test.js +0 -69
- package/dist/core-runtime/translate/render-for-user.js +0 -169
- package/dist/core-runtime/translate/render-for-user.test.js +0 -122
- package/dist/providers/capability-contract.js +0 -1
|
@@ -1,530 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `onto install` orchestrator — ties together pre-flight detection,
|
|
3
|
-
* either interactive or flag-driven decision resolution, the file
|
|
4
|
-
* writer, and the live validator.
|
|
5
|
-
*
|
|
6
|
-
* # Two execution modes
|
|
7
|
-
*
|
|
8
|
-
* **Interactive** (default): opens a readline-backed PromptIO and
|
|
9
|
-
* walks the user through the 6-step flow, capturing decisions + any
|
|
10
|
-
* secrets typed at the keyboard.
|
|
11
|
-
*
|
|
12
|
-
* **Non-interactive** (`--non-interactive` or
|
|
13
|
-
* `ONTO_INSTALL_NON_INTERACTIVE=1`): resolves every decision from
|
|
14
|
-
* flags/env directly. Missing required flags or credentials fail
|
|
15
|
-
* fast with an explicit error — never prompt. Meant for CI, Docker
|
|
16
|
-
* images, and provisioning scripts.
|
|
17
|
-
*
|
|
18
|
-
* # Shared pipeline
|
|
19
|
-
*
|
|
20
|
-
* Once both modes produce `{ decisions, secrets }`, they converge on
|
|
21
|
-
* the same write → gitignore → validate → completion sequence in
|
|
22
|
-
* `runInstallAfterDecisions`.
|
|
23
|
-
*
|
|
24
|
-
* # Testability
|
|
25
|
-
*
|
|
26
|
-
* `handleInstallCliWithOverrides()` accepts optional overrides for
|
|
27
|
-
* `homeDir`, `projectRoot`, `fetch`, `io`, and `silent`. Integration
|
|
28
|
-
* tests use these to run install against tmpdirs, stub the network,
|
|
29
|
-
* and capture output. Production dispatch calls the thin
|
|
30
|
-
* `handleInstallCli()` wrapper which supplies no overrides.
|
|
31
|
-
*/
|
|
32
|
-
import fs from "node:fs";
|
|
33
|
-
import os from "node:os";
|
|
34
|
-
import { resolveProjectRoot } from "../discovery/project-root.js";
|
|
35
|
-
import { formatPreflightSummary, runPreflight, } from "./detect.js";
|
|
36
|
-
import { ensureGitignoreEntry } from "./gitignore-update.js";
|
|
37
|
-
import { createReadlineIo, runInteractivePrompts, } from "./prompts.js";
|
|
38
|
-
import { formatValidationResult, validateInstall, } from "./validation.js";
|
|
39
|
-
import { parseEnv, resolveInstallPaths, writeInstallFiles, } from "./writer.js";
|
|
40
|
-
// ---------------------------------------------------------------------------
|
|
41
|
-
// Constants
|
|
42
|
-
// ---------------------------------------------------------------------------
|
|
43
|
-
const REVIEW_PROVIDER_VALUES = [
|
|
44
|
-
"main-native",
|
|
45
|
-
"codex",
|
|
46
|
-
"anthropic",
|
|
47
|
-
"openai",
|
|
48
|
-
"litellm",
|
|
49
|
-
];
|
|
50
|
-
const LEARN_PROVIDER_VALUES = [
|
|
51
|
-
"same",
|
|
52
|
-
"codex",
|
|
53
|
-
"anthropic",
|
|
54
|
-
"openai",
|
|
55
|
-
"litellm",
|
|
56
|
-
];
|
|
57
|
-
const TRUTHY_ENV_VALUES = new Set([
|
|
58
|
-
"1",
|
|
59
|
-
"true",
|
|
60
|
-
"TRUE",
|
|
61
|
-
"yes",
|
|
62
|
-
"YES",
|
|
63
|
-
]);
|
|
64
|
-
function envTruthy(value) {
|
|
65
|
-
return typeof value === "string" && TRUTHY_ENV_VALUES.has(value);
|
|
66
|
-
}
|
|
67
|
-
// ---------------------------------------------------------------------------
|
|
68
|
-
// Flag parsing (argv + env)
|
|
69
|
-
// ---------------------------------------------------------------------------
|
|
70
|
-
function readFlagValue(argv, name) {
|
|
71
|
-
const idx = argv.indexOf(`--${name}`);
|
|
72
|
-
if (idx < 0 || idx + 1 >= argv.length)
|
|
73
|
-
return undefined;
|
|
74
|
-
const value = argv[idx + 1];
|
|
75
|
-
if (typeof value !== "string" || value.startsWith("--"))
|
|
76
|
-
return undefined;
|
|
77
|
-
return value;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Parse install flags from argv only. Retained as the simpler form
|
|
81
|
-
* for tests and to keep the argv-reading surface in one place.
|
|
82
|
-
*/
|
|
83
|
-
export function parseInstallFlags(argv) {
|
|
84
|
-
const flags = {
|
|
85
|
-
nonInteractive: argv.includes("--non-interactive"),
|
|
86
|
-
reconfigure: argv.includes("--reconfigure") || argv.includes("--force"),
|
|
87
|
-
skipValidation: argv.includes("--skip-validation"),
|
|
88
|
-
dryRun: argv.includes("--dry-run"),
|
|
89
|
-
};
|
|
90
|
-
const profileScope = readFlagValue(argv, "profile-scope");
|
|
91
|
-
if (profileScope === "global" || profileScope === "project") {
|
|
92
|
-
flags.profileScope = profileScope;
|
|
93
|
-
}
|
|
94
|
-
const reviewProvider = readFlagValue(argv, "review-provider");
|
|
95
|
-
if (reviewProvider &&
|
|
96
|
-
REVIEW_PROVIDER_VALUES.includes(reviewProvider)) {
|
|
97
|
-
flags.reviewProvider = reviewProvider;
|
|
98
|
-
}
|
|
99
|
-
const learnProvider = readFlagValue(argv, "learn-provider");
|
|
100
|
-
if (learnProvider &&
|
|
101
|
-
LEARN_PROVIDER_VALUES.includes(learnProvider)) {
|
|
102
|
-
flags.learnProvider = learnProvider;
|
|
103
|
-
}
|
|
104
|
-
const outputLanguage = readFlagValue(argv, "output-language");
|
|
105
|
-
if (outputLanguage === "ko" || outputLanguage === "en") {
|
|
106
|
-
flags.outputLanguage = outputLanguage;
|
|
107
|
-
}
|
|
108
|
-
const litellmBaseUrl = readFlagValue(argv, "litellm-base-url");
|
|
109
|
-
if (litellmBaseUrl)
|
|
110
|
-
flags.litellmBaseUrl = litellmBaseUrl;
|
|
111
|
-
const envFile = readFlagValue(argv, "env-file");
|
|
112
|
-
if (envFile)
|
|
113
|
-
flags.envFile = envFile;
|
|
114
|
-
return flags;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Merge environment-variable defaults into a flag set. argv always
|
|
118
|
-
* wins — env only fills values that argv left unset.
|
|
119
|
-
*
|
|
120
|
-
* Env naming: `ONTO_INSTALL_<UPPERCASE_WITH_UNDERSCORES>`. Booleans
|
|
121
|
-
* accept `1 | true | TRUE | yes | YES`.
|
|
122
|
-
*/
|
|
123
|
-
export function parseInstallFlagsWithEnv(argv, env) {
|
|
124
|
-
const flags = parseInstallFlags(argv);
|
|
125
|
-
if (!flags.nonInteractive && envTruthy(env.ONTO_INSTALL_NON_INTERACTIVE)) {
|
|
126
|
-
flags.nonInteractive = true;
|
|
127
|
-
}
|
|
128
|
-
if (!flags.reconfigure && envTruthy(env.ONTO_INSTALL_RECONFIGURE)) {
|
|
129
|
-
flags.reconfigure = true;
|
|
130
|
-
}
|
|
131
|
-
if (!flags.skipValidation && envTruthy(env.ONTO_INSTALL_SKIP_VALIDATION)) {
|
|
132
|
-
flags.skipValidation = true;
|
|
133
|
-
}
|
|
134
|
-
if (!flags.dryRun && envTruthy(env.ONTO_INSTALL_DRY_RUN)) {
|
|
135
|
-
flags.dryRun = true;
|
|
136
|
-
}
|
|
137
|
-
if (!flags.profileScope) {
|
|
138
|
-
const v = env.ONTO_INSTALL_PROFILE_SCOPE;
|
|
139
|
-
if (v === "global" || v === "project")
|
|
140
|
-
flags.profileScope = v;
|
|
141
|
-
}
|
|
142
|
-
if (!flags.reviewProvider) {
|
|
143
|
-
const v = env.ONTO_INSTALL_REVIEW_PROVIDER;
|
|
144
|
-
if (v && REVIEW_PROVIDER_VALUES.includes(v)) {
|
|
145
|
-
flags.reviewProvider = v;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
if (!flags.learnProvider) {
|
|
149
|
-
const v = env.ONTO_INSTALL_LEARN_PROVIDER;
|
|
150
|
-
if (v && LEARN_PROVIDER_VALUES.includes(v)) {
|
|
151
|
-
flags.learnProvider = v;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
if (!flags.outputLanguage) {
|
|
155
|
-
const v = env.ONTO_INSTALL_OUTPUT_LANGUAGE;
|
|
156
|
-
if (v === "ko" || v === "en")
|
|
157
|
-
flags.outputLanguage = v;
|
|
158
|
-
}
|
|
159
|
-
if (!flags.litellmBaseUrl && env.ONTO_INSTALL_LITELLM_BASE_URL) {
|
|
160
|
-
flags.litellmBaseUrl = env.ONTO_INSTALL_LITELLM_BASE_URL;
|
|
161
|
-
}
|
|
162
|
-
if (!flags.envFile && env.ONTO_INSTALL_ENV_FILE) {
|
|
163
|
-
flags.envFile = env.ONTO_INSTALL_ENV_FILE;
|
|
164
|
-
}
|
|
165
|
-
return flags;
|
|
166
|
-
}
|
|
167
|
-
// ---------------------------------------------------------------------------
|
|
168
|
-
// Env-file loader
|
|
169
|
-
// ---------------------------------------------------------------------------
|
|
170
|
-
/**
|
|
171
|
-
* Load KEY=VALUE pairs from an explicit `.env` file into a target env
|
|
172
|
-
* map. Missing keys in the target are set; already-present keys are
|
|
173
|
-
* left untouched (shell env wins over a provided file, matching
|
|
174
|
-
* src/cli.ts auto-load semantics).
|
|
175
|
-
*
|
|
176
|
-
* Returns the count of keys actually inserted so the orchestrator can
|
|
177
|
-
* log how much came from the file.
|
|
178
|
-
*/
|
|
179
|
-
export function loadEnvFileInto(filePath, target) {
|
|
180
|
-
if (!fs.existsSync(filePath)) {
|
|
181
|
-
return { loaded: 0, missingFile: true };
|
|
182
|
-
}
|
|
183
|
-
const content = fs.readFileSync(filePath, "utf8");
|
|
184
|
-
let loaded = 0;
|
|
185
|
-
for (const [k, v] of parseEnv(content)) {
|
|
186
|
-
if (target[k] === undefined) {
|
|
187
|
-
target[k] = v;
|
|
188
|
-
loaded += 1;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return { loaded, missingFile: false };
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Turn a flag set + env snapshot into a complete InstallDecisions +
|
|
195
|
-
* EnvSecrets pair, failing loudly when anything required is missing.
|
|
196
|
-
*
|
|
197
|
-
* Used by the non-interactive path. Interactive path bypasses this
|
|
198
|
-
* and uses `runInteractivePrompts` instead — prompts fill missing
|
|
199
|
-
* values rather than erroring.
|
|
200
|
-
*/
|
|
201
|
-
export function resolveDecisionsFromFlags(args) {
|
|
202
|
-
const { flags, detection, env } = args;
|
|
203
|
-
const errors = [];
|
|
204
|
-
if (!flags.profileScope) {
|
|
205
|
-
errors.push("--profile-scope <global|project>");
|
|
206
|
-
}
|
|
207
|
-
if (!flags.reviewProvider) {
|
|
208
|
-
errors.push("--review-provider <provider>");
|
|
209
|
-
}
|
|
210
|
-
if (errors.length > 0) {
|
|
211
|
-
return {
|
|
212
|
-
ok: false,
|
|
213
|
-
errors: [`필수 플래그 누락: ${errors.join(", ")}`],
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
// Resolve learn provider. `same` or missing means "use review
|
|
217
|
-
// provider" — unless review is main-native, in which case learn
|
|
218
|
-
// must be explicit (main-native isn't in the background ladder).
|
|
219
|
-
let learnProvider;
|
|
220
|
-
if (!flags.learnProvider || flags.learnProvider === "same") {
|
|
221
|
-
if (flags.reviewProvider === "main-native") {
|
|
222
|
-
return {
|
|
223
|
-
ok: false,
|
|
224
|
-
errors: [
|
|
225
|
-
"--review-provider=main-native 선택 시 --learn-provider 를 명시해야 합니다.",
|
|
226
|
-
" (background ladder가 main-native를 지원하지 않습니다.)",
|
|
227
|
-
],
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
learnProvider = flags.reviewProvider;
|
|
231
|
-
}
|
|
232
|
-
else {
|
|
233
|
-
learnProvider = flags.learnProvider;
|
|
234
|
-
}
|
|
235
|
-
// Collect credentials from env (+ litellm base URL from flag).
|
|
236
|
-
const providers = new Set();
|
|
237
|
-
providers.add(flags.reviewProvider);
|
|
238
|
-
providers.add(learnProvider);
|
|
239
|
-
const credErrors = [];
|
|
240
|
-
const secrets = {};
|
|
241
|
-
for (const p of providers) {
|
|
242
|
-
switch (p) {
|
|
243
|
-
case "main-native":
|
|
244
|
-
if (!detection.hostIsClaudeCode) {
|
|
245
|
-
// Allowed but warned about — not a hard error. The caller's
|
|
246
|
-
// stderr write surfaces the warning; here we just note it.
|
|
247
|
-
}
|
|
248
|
-
break;
|
|
249
|
-
case "anthropic":
|
|
250
|
-
if (env.ANTHROPIC_API_KEY) {
|
|
251
|
-
secrets.anthropicApiKey = env.ANTHROPIC_API_KEY;
|
|
252
|
-
}
|
|
253
|
-
else {
|
|
254
|
-
credErrors.push("ANTHROPIC_API_KEY");
|
|
255
|
-
}
|
|
256
|
-
break;
|
|
257
|
-
case "openai":
|
|
258
|
-
if (env.OPENAI_API_KEY) {
|
|
259
|
-
secrets.openaiApiKey = env.OPENAI_API_KEY;
|
|
260
|
-
}
|
|
261
|
-
else {
|
|
262
|
-
credErrors.push("OPENAI_API_KEY");
|
|
263
|
-
}
|
|
264
|
-
break;
|
|
265
|
-
case "litellm": {
|
|
266
|
-
const baseUrl = flags.litellmBaseUrl ?? env.LITELLM_BASE_URL;
|
|
267
|
-
if (baseUrl) {
|
|
268
|
-
secrets.litellmBaseUrl = baseUrl;
|
|
269
|
-
}
|
|
270
|
-
else {
|
|
271
|
-
credErrors.push("LITELLM_BASE_URL (--litellm-base-url or env)");
|
|
272
|
-
}
|
|
273
|
-
if (env.LITELLM_API_KEY)
|
|
274
|
-
secrets.litellmApiKey = env.LITELLM_API_KEY;
|
|
275
|
-
break;
|
|
276
|
-
}
|
|
277
|
-
case "codex":
|
|
278
|
-
if (!detection.hasCodexBinary) {
|
|
279
|
-
credErrors.push("codex binary (install codex CLI)");
|
|
280
|
-
}
|
|
281
|
-
else if (!detection.hasCodexAuth) {
|
|
282
|
-
credErrors.push("~/.codex/auth.json (run `codex login`)");
|
|
283
|
-
}
|
|
284
|
-
break;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
if (credErrors.length > 0) {
|
|
288
|
-
return {
|
|
289
|
-
ok: false,
|
|
290
|
-
errors: [
|
|
291
|
-
`자격 증명 누락: ${credErrors.join(", ")}`,
|
|
292
|
-
" env 변수로 설정하거나 --env-file <path> 로 지정하세요.",
|
|
293
|
-
],
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
const decisions = {
|
|
297
|
-
profileScope: flags.profileScope,
|
|
298
|
-
reviewProvider: flags.reviewProvider,
|
|
299
|
-
learnProvider,
|
|
300
|
-
outputLanguage: flags.outputLanguage ?? "ko",
|
|
301
|
-
};
|
|
302
|
-
if (secrets.litellmBaseUrl) {
|
|
303
|
-
decisions.litellmBaseUrl = secrets.litellmBaseUrl;
|
|
304
|
-
}
|
|
305
|
-
return { ok: true, decisions, secrets };
|
|
306
|
-
}
|
|
307
|
-
async function runInstallAfterDecisions(args) {
|
|
308
|
-
const { decisions, secrets, detection, flags, projectRoot, homeDir, pingDeps, write, writeErr, } = args;
|
|
309
|
-
const paths = resolveInstallPaths(decisions.profileScope, projectRoot, homeDir);
|
|
310
|
-
const result = writeInstallFiles({
|
|
311
|
-
paths,
|
|
312
|
-
decisions,
|
|
313
|
-
secrets,
|
|
314
|
-
dryRun: flags.dryRun,
|
|
315
|
-
});
|
|
316
|
-
let gitignoreResult;
|
|
317
|
-
if (paths.gitignorePath) {
|
|
318
|
-
gitignoreResult = ensureGitignoreEntry(paths.gitignorePath, {
|
|
319
|
-
dryRun: flags.dryRun,
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
if (!flags.dryRun && !flags.skipValidation) {
|
|
323
|
-
write("\nProvider 검증 중...\n");
|
|
324
|
-
const validation = await validateInstall({
|
|
325
|
-
decisions,
|
|
326
|
-
secrets,
|
|
327
|
-
detection,
|
|
328
|
-
...(pingDeps ? { deps: pingDeps } : {}),
|
|
329
|
-
});
|
|
330
|
-
write(`${formatValidationResult(validation)}\n`);
|
|
331
|
-
if (!validation.ok) {
|
|
332
|
-
writeErr([
|
|
333
|
-
"",
|
|
334
|
-
"[onto] 일부 provider 검증 실패.",
|
|
335
|
-
" - 자격 증명을 수정한 뒤 `onto install --reconfigure` 로 재실행하거나",
|
|
336
|
-
" - 네트워크 제약 환경이면 `--skip-validation` 을 추가해 검증을 건너뛰세요.",
|
|
337
|
-
"",
|
|
338
|
-
].join("\n"));
|
|
339
|
-
return 1;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
printCompletion(result, gitignoreResult, flags.dryRun, write);
|
|
343
|
-
return 0;
|
|
344
|
-
}
|
|
345
|
-
// ---------------------------------------------------------------------------
|
|
346
|
-
// Help + completion printers
|
|
347
|
-
// ---------------------------------------------------------------------------
|
|
348
|
-
function printHelp(write) {
|
|
349
|
-
write([
|
|
350
|
-
"Usage: onto install [options]",
|
|
351
|
-
"",
|
|
352
|
-
"First-run setup wizard for onto. Writes config.yml + .env +",
|
|
353
|
-
".env.example to ~/.onto/ (global) or <repo>/.onto/ (project).",
|
|
354
|
-
"",
|
|
355
|
-
"Options:",
|
|
356
|
-
" --profile-scope <global|project> Where to write config.",
|
|
357
|
-
" --review-provider <provider> main-native | codex | anthropic | openai | litellm",
|
|
358
|
-
" --learn-provider <provider> same | codex | anthropic | openai | litellm",
|
|
359
|
-
" --output-language <ko|en> Principal-facing render language.",
|
|
360
|
-
" --litellm-base-url <url> LiteLLM endpoint (for litellm provider).",
|
|
361
|
-
" --env-file <path> Load a .env file before install runs.",
|
|
362
|
-
" --reconfigure, --force Allow overwriting existing config.",
|
|
363
|
-
" --skip-validation Skip the live provider ping.",
|
|
364
|
-
" --dry-run Compute changes without writing.",
|
|
365
|
-
" --non-interactive Resolve decisions from flags + env only.",
|
|
366
|
-
" --help, -h Show this help.",
|
|
367
|
-
"",
|
|
368
|
-
"Environment variables (argv overrides env):",
|
|
369
|
-
" ONTO_INSTALL_PROFILE_SCOPE, ONTO_INSTALL_REVIEW_PROVIDER,",
|
|
370
|
-
" ONTO_INSTALL_LEARN_PROVIDER, ONTO_INSTALL_OUTPUT_LANGUAGE,",
|
|
371
|
-
" ONTO_INSTALL_LITELLM_BASE_URL, ONTO_INSTALL_ENV_FILE,",
|
|
372
|
-
" ONTO_INSTALL_NON_INTERACTIVE, ONTO_INSTALL_RECONFIGURE,",
|
|
373
|
-
" ONTO_INSTALL_SKIP_VALIDATION, ONTO_INSTALL_DRY_RUN.",
|
|
374
|
-
"",
|
|
375
|
-
"Credentials (read from env; not accepted via flag):",
|
|
376
|
-
" ANTHROPIC_API_KEY, OPENAI_API_KEY,",
|
|
377
|
-
" LITELLM_BASE_URL, LITELLM_API_KEY.",
|
|
378
|
-
"",
|
|
379
|
-
"Next steps after install:",
|
|
380
|
-
" onto onboard Initialize project-specific domains and review axes.",
|
|
381
|
-
" onto help List all commands.",
|
|
382
|
-
" onto config edit Adjust models and advanced fields.",
|
|
383
|
-
"",
|
|
384
|
-
].join("\n"));
|
|
385
|
-
}
|
|
386
|
-
function printCompletion(result, gitignoreResult, dryRun, write) {
|
|
387
|
-
const header = dryRun ? "설치 미리보기 완료 (--dry-run)" : "설치 완료";
|
|
388
|
-
write(`\n${header}\n\n`);
|
|
389
|
-
write(` config.yml → ${result.writtenTo.configYml}\n`);
|
|
390
|
-
write(` .env → ${result.writtenTo.env}\n`);
|
|
391
|
-
write(` .env.example → ${result.writtenTo.envExample}\n`);
|
|
392
|
-
if (gitignoreResult) {
|
|
393
|
-
if (gitignoreResult.created) {
|
|
394
|
-
write(" .gitignore → (생성) .onto/.env 추가됨\n");
|
|
395
|
-
}
|
|
396
|
-
else if (!gitignoreResult.alreadyPresent) {
|
|
397
|
-
write(" .gitignore → .onto/.env 추가됨\n");
|
|
398
|
-
}
|
|
399
|
-
else {
|
|
400
|
-
write(" .gitignore → .onto/.env 이미 등록됨\n");
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
write("\n다음 단계:\n");
|
|
404
|
-
write(" onto onboard # 프로젝트 도메인/축 초기화\n");
|
|
405
|
-
write(" onto help # 전체 명령 확인\n");
|
|
406
|
-
write(" onto config edit # 모델 등 세부 조정\n\n");
|
|
407
|
-
}
|
|
408
|
-
export async function handleInstallCli(ontoHome, argv) {
|
|
409
|
-
return handleInstallCliWithOverrides(ontoHome, argv);
|
|
410
|
-
}
|
|
411
|
-
export async function handleInstallCliWithOverrides(_ontoHome, argv, overrides = {}) {
|
|
412
|
-
const write = overrides.write ?? ((text) => process.stdout.write(text));
|
|
413
|
-
const writeErr = overrides.writeErr ?? ((text) => process.stderr.write(text));
|
|
414
|
-
if (argv.includes("--help") || argv.includes("-h")) {
|
|
415
|
-
printHelp(write);
|
|
416
|
-
return 0;
|
|
417
|
-
}
|
|
418
|
-
const flags = parseInstallFlagsWithEnv(argv, process.env);
|
|
419
|
-
// --env-file (if provided) is loaded BEFORE detection/validation
|
|
420
|
-
// so subsequent reads see the injected keys.
|
|
421
|
-
if (flags.envFile) {
|
|
422
|
-
const { missingFile } = loadEnvFileInto(flags.envFile, process.env);
|
|
423
|
-
if (missingFile) {
|
|
424
|
-
writeErr(`[onto] --env-file 경로를 찾을 수 없습니다: ${flags.envFile}\n`);
|
|
425
|
-
return 1;
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
const homeDir = overrides.homeDir ?? os.homedir();
|
|
429
|
-
const projectRoot = overrides.projectRoot ?? resolveProjectRoot();
|
|
430
|
-
const detection = runPreflight(projectRoot);
|
|
431
|
-
if ((detection.existingGlobalConfig || detection.existingProjectConfig) &&
|
|
432
|
-
!flags.reconfigure) {
|
|
433
|
-
writeErr([
|
|
434
|
-
"[onto] 기존 config가 감지되어 install을 중단합니다.",
|
|
435
|
-
"",
|
|
436
|
-
formatPreflightSummary(detection),
|
|
437
|
-
"",
|
|
438
|
-
" 덮어쓰려면 `--reconfigure` 를 추가해 다시 실행하세요.",
|
|
439
|
-
" 일부 필드만 편집하려면 `onto config edit` 을 사용하세요.",
|
|
440
|
-
"",
|
|
441
|
-
].join("\n"));
|
|
442
|
-
return 1;
|
|
443
|
-
}
|
|
444
|
-
const pingDeps = {};
|
|
445
|
-
if (overrides.fetch)
|
|
446
|
-
pingDeps.fetch = overrides.fetch;
|
|
447
|
-
if (flags.nonInteractive) {
|
|
448
|
-
return runNonInteractive({
|
|
449
|
-
flags,
|
|
450
|
-
detection,
|
|
451
|
-
projectRoot,
|
|
452
|
-
homeDir,
|
|
453
|
-
pingDeps,
|
|
454
|
-
write,
|
|
455
|
-
writeErr,
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
return runInteractive({
|
|
459
|
-
flags,
|
|
460
|
-
detection,
|
|
461
|
-
projectRoot,
|
|
462
|
-
homeDir,
|
|
463
|
-
pingDeps,
|
|
464
|
-
...(overrides.io ? { io: overrides.io } : {}),
|
|
465
|
-
write,
|
|
466
|
-
writeErr,
|
|
467
|
-
});
|
|
468
|
-
}
|
|
469
|
-
// ---------------------------------------------------------------------------
|
|
470
|
-
// Mode branches
|
|
471
|
-
// ---------------------------------------------------------------------------
|
|
472
|
-
async function runNonInteractive(args) {
|
|
473
|
-
const { flags, detection, projectRoot, homeDir, pingDeps, write, writeErr, } = args;
|
|
474
|
-
const resolved = resolveDecisionsFromFlags({
|
|
475
|
-
flags,
|
|
476
|
-
detection,
|
|
477
|
-
env: process.env,
|
|
478
|
-
});
|
|
479
|
-
if (!resolved.ok) {
|
|
480
|
-
writeErr(`[onto] install: ${resolved.errors.join("\n")}\n`);
|
|
481
|
-
return 1;
|
|
482
|
-
}
|
|
483
|
-
if (resolved.decisions.reviewProvider === "main-native" &&
|
|
484
|
-
!detection.hostIsClaudeCode) {
|
|
485
|
-
writeErr("[onto] [warning] review-provider=main-native 선택됨 — Claude Code 세션 외부에서는 review가 실패합니다.\n");
|
|
486
|
-
}
|
|
487
|
-
return runInstallAfterDecisions({
|
|
488
|
-
decisions: resolved.decisions,
|
|
489
|
-
secrets: resolved.secrets,
|
|
490
|
-
detection,
|
|
491
|
-
flags,
|
|
492
|
-
projectRoot,
|
|
493
|
-
homeDir,
|
|
494
|
-
pingDeps,
|
|
495
|
-
write,
|
|
496
|
-
writeErr,
|
|
497
|
-
});
|
|
498
|
-
}
|
|
499
|
-
async function runInteractive(args) {
|
|
500
|
-
const { flags, detection, projectRoot, homeDir, pingDeps, io: providedIo, write, writeErr, } = args;
|
|
501
|
-
const io = providedIo ?? createReadlineIo();
|
|
502
|
-
try {
|
|
503
|
-
write("\nonto install — 첫 실행 설정 마법사\n\n");
|
|
504
|
-
write(formatPreflightSummary(detection));
|
|
505
|
-
write("\n\n");
|
|
506
|
-
const { decisions, secrets } = await runInteractivePrompts({
|
|
507
|
-
io,
|
|
508
|
-
flags,
|
|
509
|
-
detection,
|
|
510
|
-
});
|
|
511
|
-
return runInstallAfterDecisions({
|
|
512
|
-
decisions,
|
|
513
|
-
secrets,
|
|
514
|
-
detection,
|
|
515
|
-
flags,
|
|
516
|
-
projectRoot,
|
|
517
|
-
homeDir,
|
|
518
|
-
pingDeps,
|
|
519
|
-
write,
|
|
520
|
-
writeErr,
|
|
521
|
-
});
|
|
522
|
-
}
|
|
523
|
-
catch (error) {
|
|
524
|
-
writeErr(`[onto] install failed: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
525
|
-
return 1;
|
|
526
|
-
}
|
|
527
|
-
finally {
|
|
528
|
-
io.close();
|
|
529
|
-
}
|
|
530
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pre-flight environment detection for `onto install`.
|
|
3
|
-
*
|
|
4
|
-
* Scans the environment ONCE at the start of the install flow and
|
|
5
|
-
* produces a `PreflightDetection` snapshot. The interactive prompts
|
|
6
|
-
* module and the non-interactive orchestration both read from this
|
|
7
|
-
* snapshot rather than re-scanning at each step.
|
|
8
|
-
*
|
|
9
|
-
* # Why a single snapshot
|
|
10
|
-
*
|
|
11
|
-
* Two reasons:
|
|
12
|
-
*
|
|
13
|
-
* 1. Consistency — if the user runs `codex login` mid-install, the
|
|
14
|
-
* snapshot should remain stable so defaults don't shift under
|
|
15
|
-
* the user's feet. Re-scanning is an explicit action (e.g. the
|
|
16
|
-
* codex auth prompt retry path).
|
|
17
|
-
*
|
|
18
|
-
* 2. Testability — detect.test.ts can construct a synthetic
|
|
19
|
-
* snapshot without needing to stub filesystem / env var calls
|
|
20
|
-
* on every consumer.
|
|
21
|
-
*
|
|
22
|
-
* # Reuse of host-detection.ts
|
|
23
|
-
*
|
|
24
|
-
* The signal-level predicates (API keys, codex binary, Claude Code
|
|
25
|
-
* env) live in `src/core-runtime/discovery/host-detection.ts` and are
|
|
26
|
-
* shared across host resolution, topology detection, and now install.
|
|
27
|
-
* We call them directly rather than duplicating logic.
|
|
28
|
-
*/
|
|
29
|
-
import fsSync from "node:fs";
|
|
30
|
-
import os from "node:os";
|
|
31
|
-
import path from "node:path";
|
|
32
|
-
import { detectAnthropicApiKey, detectClaudeCodeEnvSignal, detectOpenAiApiKey, } from "../discovery/host-detection.js";
|
|
33
|
-
const ENV_LITELLM_BASE_URL = "LITELLM_BASE_URL";
|
|
34
|
-
function detectLiteLlmEndpointForInstall() {
|
|
35
|
-
return Boolean(process.env[ENV_LITELLM_BASE_URL]);
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* True when the `codex` binary is reachable on PATH.
|
|
39
|
-
*
|
|
40
|
-
* Separate from auth detection because the install UX distinguishes:
|
|
41
|
-
*
|
|
42
|
-
* - no binary → "install codex CLI first"
|
|
43
|
-
* - binary + no auth.json → "run `codex login` to continue"
|
|
44
|
-
* - binary + auth.json → ready to use
|
|
45
|
-
*
|
|
46
|
-
* `host-detection.ts#detectCodexBinaryAvailable` combines both checks
|
|
47
|
-
* for topology decisions; install needs the finer split.
|
|
48
|
-
*/
|
|
49
|
-
function detectCodexBinary() {
|
|
50
|
-
const pathEnv = process.env.PATH ?? "";
|
|
51
|
-
for (const dir of pathEnv.split(path.delimiter)) {
|
|
52
|
-
if (!dir)
|
|
53
|
-
continue;
|
|
54
|
-
if (fsSync.existsSync(path.join(dir, "codex"))) {
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
/** True when `~/.codex/auth.json` exists (any content). */
|
|
61
|
-
function detectCodexAuthFile() {
|
|
62
|
-
const authPath = path.join(os.homedir(), ".codex", "auth.json");
|
|
63
|
-
return fsSync.existsSync(authPath);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Path to the global onto config file candidate (`~/.onto/config.yml`).
|
|
67
|
-
*
|
|
68
|
-
* Exported so the writer and tests can reference the same path string
|
|
69
|
-
* without hardcoding it in multiple places.
|
|
70
|
-
*/
|
|
71
|
-
export function globalConfigPath() {
|
|
72
|
-
return path.join(os.homedir(), ".onto", "config.yml");
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Path to the project-scope onto config file candidate relative to a
|
|
76
|
-
* given project root.
|
|
77
|
-
*/
|
|
78
|
-
export function projectConfigPath(projectRoot) {
|
|
79
|
-
return path.join(projectRoot, ".onto", "config.yml");
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Run pre-flight detection against the current process.
|
|
83
|
-
*
|
|
84
|
-
* `projectRoot` is the resolved target directory — typically
|
|
85
|
-
* `resolveProjectRoot()` from the discovery layer. Caller is expected
|
|
86
|
-
* to pass an absolute path; install does not try to re-resolve here
|
|
87
|
-
* because the scope selection (global vs project) is downstream and
|
|
88
|
-
* may override which config path matters.
|
|
89
|
-
*/
|
|
90
|
-
export function runPreflight(projectRoot) {
|
|
91
|
-
const litellmBaseUrlValue = process.env[ENV_LITELLM_BASE_URL];
|
|
92
|
-
const result = {
|
|
93
|
-
existingGlobalConfig: fsSync.existsSync(globalConfigPath()),
|
|
94
|
-
existingProjectConfig: fsSync.existsSync(projectConfigPath(projectRoot)),
|
|
95
|
-
hasAnthropicKey: detectAnthropicApiKey(),
|
|
96
|
-
hasOpenAiKey: detectOpenAiApiKey(),
|
|
97
|
-
hasLitellmBaseUrl: detectLiteLlmEndpointForInstall(),
|
|
98
|
-
hasCodexBinary: detectCodexBinary(),
|
|
99
|
-
hasCodexAuth: detectCodexAuthFile(),
|
|
100
|
-
hostIsClaudeCode: detectClaudeCodeEnvSignal(),
|
|
101
|
-
};
|
|
102
|
-
if (result.hasLitellmBaseUrl && typeof litellmBaseUrlValue === "string") {
|
|
103
|
-
result.litellmBaseUrlValue = litellmBaseUrlValue;
|
|
104
|
-
}
|
|
105
|
-
return result;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Human-readable summary of a preflight snapshot, suitable for the
|
|
109
|
-
* install command's Step 0 (pre-flight) display.
|
|
110
|
-
*
|
|
111
|
-
* Lines are indented 2 spaces and prefixed with `✓` / `·` to signal
|
|
112
|
-
* presence vs absence. Pure render — no I/O.
|
|
113
|
-
*/
|
|
114
|
-
export function formatPreflightSummary(detection) {
|
|
115
|
-
const mark = (present) => (present ? "✓" : "·");
|
|
116
|
-
const lines = [
|
|
117
|
-
"감지된 환경:",
|
|
118
|
-
` ${mark(detection.existingGlobalConfig)} global config (~/.onto/config.yml)`,
|
|
119
|
-
` ${mark(detection.existingProjectConfig)} project config (<cwd>/.onto/config.yml)`,
|
|
120
|
-
` ${mark(detection.hasAnthropicKey)} ANTHROPIC_API_KEY`,
|
|
121
|
-
` ${mark(detection.hasOpenAiKey)} OPENAI_API_KEY`,
|
|
122
|
-
` ${mark(detection.hasLitellmBaseUrl)} LITELLM_BASE_URL${detection.litellmBaseUrlValue ? ` = ${detection.litellmBaseUrlValue}` : ""}`,
|
|
123
|
-
` ${mark(detection.hasCodexBinary)} codex binary on PATH`,
|
|
124
|
-
` ${mark(detection.hasCodexAuth)} ~/.codex/auth.json`,
|
|
125
|
-
` ${mark(detection.hostIsClaudeCode)} running inside Claude Code session`,
|
|
126
|
-
];
|
|
127
|
-
return lines.join("\n");
|
|
128
|
-
}
|