@nimiplatform/nimi-coding 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/CONTRIBUTING.md +3 -3
  3. package/README.md +297 -41
  4. package/README.zh-CN.md +306 -31
  5. package/bin/nimicoding.mjs +1 -1
  6. package/cli/commands/authority.mjs +804 -0
  7. package/cli/commands/clear.mjs +27 -7
  8. package/cli/commands/doctor.mjs +10 -1
  9. package/cli/commands/start.mjs +23 -27
  10. package/cli/commands/sync.mjs +21 -101
  11. package/cli/constants.mjs +7 -31
  12. package/cli/dev/check-authority-surface.mjs +182 -0
  13. package/cli/dev/check-product-conformance.mjs +889 -0
  14. package/cli/help.mjs +10 -17
  15. package/cli/index.mjs +6 -47
  16. package/cli/lib/authority/anchors.mjs +491 -0
  17. package/cli/lib/authority/audit.mjs +567 -0
  18. package/cli/lib/authority/change-candidates.mjs +807 -0
  19. package/cli/lib/authority/closed-sets.mjs +645 -0
  20. package/cli/lib/authority/compile.mjs +92 -0
  21. package/cli/lib/authority/compiled-snapshot.mjs +143 -0
  22. package/cli/lib/authority/consumers.mjs +520 -0
  23. package/cli/lib/authority/diagnostics.mjs +93 -0
  24. package/cli/lib/authority/diff.mjs +310 -0
  25. package/cli/lib/authority/discover.mjs +447 -0
  26. package/cli/lib/authority/format.mjs +169 -0
  27. package/cli/lib/authority/git-snapshot.mjs +720 -0
  28. package/cli/lib/authority/graph.mjs +351 -0
  29. package/cli/lib/authority/impact.mjs +125 -0
  30. package/cli/lib/authority/lexicon.mjs +55 -0
  31. package/cli/lib/authority/query.mjs +162 -0
  32. package/cli/lib/authority/repository-corpus.mjs +37 -0
  33. package/cli/lib/authority/repository-inventory.mjs +34 -0
  34. package/cli/lib/authority/review.mjs +212 -0
  35. package/cli/lib/authority/sarif.mjs +174 -0
  36. package/cli/lib/authority/scope-bindings.mjs +225 -0
  37. package/cli/lib/authority/source-map.mjs +105 -0
  38. package/cli/lib/authority/source-markdown.mjs +167 -0
  39. package/cli/lib/authority/source-yaml.mjs +308 -0
  40. package/cli/lib/authority/surface.mjs +97 -0
  41. package/cli/lib/authority/terms.mjs +422 -0
  42. package/cli/lib/authority/tracked-text.mjs +70 -0
  43. package/cli/lib/authority/validate.mjs +300 -0
  44. package/cli/lib/bootstrap.mjs +55 -71
  45. package/cli/lib/doctor.mjs +40 -123
  46. package/cli/lib/entrypoints.mjs +104 -105
  47. package/cli/lib/fs-helpers.mjs +139 -15
  48. package/cli/lib/internal/governance/config.mjs +0 -36
  49. package/cli/lib/shared.mjs +8 -21
  50. package/cli/lib/sync.mjs +81 -92
  51. package/cli/lib/value-helpers.mjs +0 -26
  52. package/cli/lib/yaml-helpers.mjs +1 -124
  53. package/cli/seeds/bootstrap.mjs +31 -87
  54. package/cli/seeds/seed-policy.yaml +9 -63
  55. package/contracts/authority-scope-bindings.schema.yaml +15 -0
  56. package/contracts/authority-source.schema.yaml +58 -0
  57. package/contracts/authority-verifier-bindings.schema.yaml +31 -0
  58. package/methodology/authority-authoring.yaml +127 -0
  59. package/methodology/core.yaml +34 -27
  60. package/package.json +10 -6
  61. package/spec/authority-anchors.yaml +99 -0
  62. package/spec/authority-audit.yaml +89 -0
  63. package/spec/authority-authoring.yaml +137 -0
  64. package/spec/authority-change-candidates.yaml +146 -0
  65. package/spec/authority-closed-sets.yaml +65 -0
  66. package/spec/authority-consumers.yaml +77 -0
  67. package/spec/authority-context.yaml +50 -0
  68. package/spec/authority-discovery.yaml +119 -0
  69. package/spec/authority-graph.yaml +59 -0
  70. package/spec/authority-impact.yaml +61 -0
  71. package/spec/authority-review.yaml +71 -0
  72. package/spec/authority-terms.yaml +63 -0
  73. package/spec/product-scope.yaml +37 -23
  74. package/cli/commands/blueprint-audit.mjs +0 -91
  75. package/cli/commands/classify-spec-tree.mjs +0 -5
  76. package/cli/commands/generate-spec-derived-docs.mjs +0 -151
  77. package/cli/commands/generate-spec-migration-plan.mjs +0 -30
  78. package/cli/commands/surface-validator-command.mjs +0 -49
  79. package/cli/commands/validate-domain-admission.mjs +0 -5
  80. package/cli/commands/validate-guidance-bodies.mjs +0 -5
  81. package/cli/commands/validate-placement.mjs +0 -5
  82. package/cli/commands/validate-projection-edges.mjs +0 -5
  83. package/cli/commands/validate-spec-audit.mjs +0 -27
  84. package/cli/commands/validate-spec-governance.mjs +0 -144
  85. package/cli/commands/validate-spec-tree.mjs +0 -27
  86. package/cli/commands/validate-table-family.mjs +0 -5
  87. package/cli/commands/validate-tracked-output-admission.mjs +0 -5
  88. package/cli/lib/blueprint-audit.mjs +0 -363
  89. package/cli/lib/contracts.mjs +0 -21
  90. package/cli/lib/internal/contracts-loaders.mjs +0 -47
  91. package/cli/lib/internal/contracts-parse.mjs +0 -192
  92. package/cli/lib/internal/governance/runner.mjs +0 -35
  93. package/cli/lib/internal/surface-taxonomy-validators.mjs +0 -1147
  94. package/cli/lib/internal/validators-shared.mjs +0 -12
  95. package/cli/lib/internal/validators-spec-helpers.mjs +0 -52
  96. package/cli/lib/internal/validators-spec.mjs +0 -380
  97. package/cli/lib/validators.mjs +0 -30
  98. package/config/bootstrap.yaml +0 -6
  99. package/config/spec-generation-inputs.yaml +0 -41
  100. package/contracts/domain-admission.schema.yaml +0 -56
  101. package/contracts/migration-inventory.schema.yaml +0 -15
  102. package/contracts/negative-fixtures.yaml +0 -26
  103. package/contracts/placement-contract.schema.yaml +0 -127
  104. package/contracts/projection-edge.schema.yaml +0 -46
  105. package/contracts/shared-enums.yaml +0 -63
  106. package/contracts/spec-generation-audit.schema.yaml +0 -46
  107. package/contracts/spec-generation-inputs.schema.yaml +0 -43
  108. package/contracts/spec-layout.schema.yaml +0 -32
  109. package/contracts/surface-taxonomy.schema.yaml +0 -139
  110. package/contracts/table-family.schema.yaml +0 -133
  111. package/contracts/tracked-output-admission.schema.yaml +0 -17
  112. package/methodology/four-closure-policy.yaml +0 -20
  113. package/methodology/role-separation-policy.yaml +0 -22
  114. package/methodology/spec-reconstruction.yaml +0 -69
  115. package/spec/_meta/spec-tree-model.yaml +0 -44
@@ -0,0 +1,61 @@
1
+ version: 2
2
+ spec:
3
+ id: nimicoding.authority-impact.v2
4
+ owner: nimi-coding
5
+ status: active
6
+ product_claim: compare_admitted_compiler_outputs_and_report_declared_relation_impact_and_host_owned_follow_up_targets_without_accepting_completion_state
7
+ commands:
8
+ diff: nimicoding authority diff <before-path> <after-path> --max-bytes <positive-integer> [--json]
9
+ impact: nimicoding authority impact <before-path> <after-path> --max-bytes <positive-integer> [--json]
10
+ diff:
11
+ source: two_independently_admitted_compiler_outputs
12
+ format: nimicoding.authority-diff/v1
13
+ top_level_fields: [format, changes, summary]
14
+ summary_fields: [units, changes]
15
+ record:
16
+ required_fields: [unitId, operation, pointer, before, after]
17
+ optional_fields: [beforeSource, afterSource]
18
+ operation_enum:
19
+ unit_added: complete_after_unit
20
+ modified: scalar_field_before_and_after
21
+ added: scope_value_or_relation_added
22
+ removed: scope_value_or_relation_removed
23
+ source_record_fields: [file, range, sourcePointer]
24
+ unit_removed_operation: forbidden
25
+ physical_unit_deletion: AUTH_DIFF_TRANSITION_INVALID
26
+ retirement: active_unit_is_replaced_by_a_valid_same_ID_same_kind_removed_tombstone
27
+ pure_profile_format_file_rename_unit_order_or_container_regroup_change: empty
28
+ ordering: [unit_ID, JSON_pointer, operation, values]
29
+ traceability: changed_values_reference_before_and_or_after_SourceMap
30
+ byte_budget:
31
+ measure: UTF-8_bytes_of_compact_JSON.stringify_diff
32
+ overflow: AUTH_DIFF_BUDGET_with_null_diff_and_partial_false
33
+ impact:
34
+ format: nimicoding.authority-impact/v2
35
+ top_level_fields: [format, analysisStatus, changedUnits, impactedUnits, obligations]
36
+ analysisStatus: completed
37
+ impacted_unit_fields: [id, kind]
38
+ obligation_fields: [ruleId, type, target]
39
+ roots: normative_governance_definition_rule_graph_changes; non_normative_metadata_diff_is_reported_but_creates_no_impact_root
40
+ direction: reverse_declared_relations_from_changed_units_to_dependents
41
+ relation_categories: [applies_to, supersedes]
42
+ unrelated_units: excluded
43
+ active_rule_obligations:
44
+ consumer: union_of_before_and_after_declared_scope
45
+ test: one_host_follow_up_target_per_impacted_active_rule
46
+ completion_or_disposition_input: forbidden
47
+ byte_budget:
48
+ measure: UTF-8_bytes_of_compact_JSON.stringify_object_containing_diff_and_impact
49
+ overflow: AUTH_IMPACT_BUDGET_with_null_diff_null_impact_and_partial_false
50
+ fail_closed:
51
+ invalid_before_or_after_authority: compiler_diagnostics
52
+ identity_reuse_kind_change_or_physical_deletion: AUTH_DIFF_TRANSITION_INVALID_or_compiler_identity_diagnostics
53
+ dangling_relation_or_illegal_lifecycle: compiler_diagnostics
54
+ missing_or_invalid_max_bytes: CLI_usage_failure
55
+ boundaries:
56
+ writes_authority: false
57
+ durable_artifacts: none
58
+ git_interpretation: none
59
+ host_obligation_state_receipt_test_execution_or_completion: not_accepted_or_owned
60
+ natural_language_contradiction_detection: not_claimed
61
+ implementation_consumer_test_sync_proof: not_admitted
@@ -0,0 +1,71 @@
1
+ version: 2
2
+ spec:
3
+ id: nimicoding.authority-review.v2
4
+ owner: nimi-coding
5
+ status: active
6
+ product_claim: one_explicit_Git_base_commit_and_one_stable_current_worktree_produce_exact_read_only_authority_analysis_with_narrow_component_statuses
7
+ command: nimicoding authority review <repository-path> --base <git-ref> --bindings <file> --max-units <positive-safe-integer> --max-edges <positive-safe-integer> --max-bytes <positive-safe-integer> [--json]
8
+ capture:
9
+ repository: exact_non_bare_Git_worktree_root
10
+ base_ref:
11
+ resolution: once_at_capture_start_to_immutable_full_commit_OID
12
+ later_use: full_OID_only
13
+ option_injection: refused
14
+ base_authority:
15
+ source: Git_object_database
16
+ root: .nimi/spec_tree_required
17
+ admitted_entry_types: [tree, regular_blob_100644_or_100755]
18
+ worktree_authority:
19
+ source: complete_live_filesystem_inventory_under_.nimi/spec
20
+ includes: [tracked_unchanged, tracked_modification, tracked_deletion, untracked_or_ignored_file, unsupported_regular_file]
21
+ refused: [missing_root, symlink, non_regular_entry, invalid_UTF-8_path, path_escape]
22
+ race: any_path_type_byte_or_stability_metadata_change_refuses_the_whole_capture
23
+ materialization:
24
+ location: independent_0700_temporary_directory
25
+ cleanup: required_after_success_or_failure
26
+ Git_mutation: forbidden
27
+ snapshot_identity:
28
+ format: sha256_colon_lowercase_hex
29
+ domain: nimicoding.authority-snapshot-content/v1
30
+ inputs: sorted_repository_relative_regular_file_paths_entry_type_exact_byte_length_and_bytes
31
+ oracles:
32
+ admission_and_counts: exactly_one_compileAuthorityPath_call_per_materialized_side
33
+ immutable_read_model: createCompiledAuthoritySnapshot_with_by_ID_owner_scope_container_and_incoming_outgoing_indexes
34
+ semantic_delta: diffAuthoritySnapshots_on_the_two_admitted_read_models
35
+ declared_impact: impactAuthorityDiff_on_the_single_computed_semantic_diff
36
+ configured_audit: auditAuthoritySnapshot_on_the_admitted_worktree_read_model_only
37
+ component_recompile_or_persistent_cache: forbidden
38
+ product:
39
+ format: nimicoding.authority-review/v2
40
+ top_level_fields: [format, operationStatus, analysisComplete, partial, businessSemanticStatus, implementationConformanceStatus, snapshots, components, diff, impact, audit, budgets]
41
+ operationStatus: completed
42
+ analysisComplete: snapshot_capture_corpus_admission_diff_impact_and_configured_audit_all_finished
43
+ partial: false
44
+ businessSemanticStatus: not_evaluated
45
+ implementationConformanceStatus: not_evaluated
46
+ components:
47
+ snapshotCapture: {fields: [status], status: captured}
48
+ corpusAdmission: {fields: [status], status: admitted}
49
+ semanticDiff: {fields: [status], status: computed}
50
+ declaredImpact: {fields: [status], status: computed}
51
+ configuredAudit: {fields: [status, blockingStatus], status: evaluated, blockingStatus: [clear, blocked]}
52
+ no_generic_policy_pass_or_conformance_status: true
53
+ budgets:
54
+ required: [maxUnits, maxEdges, maxBytes]
55
+ values: positive_safe_integers
56
+ component_bytes: same_explicit_maxBytes_passed_to_diff_impact_and_audit
57
+ review_bytes: UTF-8_bytes_of_compact_JSON.stringify_complete_review
58
+ overflow: AUTH_REVIEW_BUDGET_or_existing_component_budget_with_review_null_and_partial_false
59
+ outcomes:
60
+ completed_clear: review_present_analysisComplete_true_configured_audit_clear_exit_0
61
+ completed_blocked: review_present_analysisComplete_true_configured_audit_blocked_exit_1
62
+ refused: invalid_Git_corpus_binding_capture_transition_or_budget_returns_review_null_partial_false_exit_1
63
+ usage_error: missing_repeated_or_invalid_CLI_argument_exit_2_without_review_product
64
+ failed: uncaught_IO_resource_or_internal_failure_exit_2_without_review_product
65
+ boundaries:
66
+ writes_authority_or_project_files: false
67
+ durable_cache_database_history_receipt_or_external_result: none
68
+ impact_disposition_or_host_completion_state: not_accepted
69
+ arbitrary_shell_plugin_test_model_embedding_or_semantic_search_execution: forbidden
70
+ business_semantic_and_implementation_conformance: explicitly_not_evaluated
71
+ public_AuthorityIR_or_SourceMap_export: none
@@ -0,0 +1,63 @@
1
+ version: 1
2
+ spec:
3
+ id: nimicoding.authority-terms.v1
4
+ owner: nimi-coding
5
+ status: active
6
+ product_claim: bounded_static_index_of_the_identifiers_the_active_authority_corpus_uses_and_optionally_where_one_exact_identifier_appears_in_tracked_text
7
+ command: nimicoding authority terms <repository-path> --spec <corpus-path> [--term <t>] [--code] --max-units <positive-safe-integer> --max-terms <positive-safe-integer> --max-bytes <positive-safe-integer> [--json]
8
+ surface:
9
+ report_format: nimicoding.authority-terms/v1
10
+ corpus_root: repository_authority_corpus_only
11
+ boolean_flags: [json, code]
12
+ value_flags: [spec, term]
13
+ integer_flags: [max-units, max-terms, max-bytes]
14
+ repeatable_flags: []
15
+ findings_change_exit_code: false
16
+ inputs:
17
+ repository:
18
+ shape: exact_non_symlink_Git_worktree_root
19
+ tracked_files: one_complete_git_ls_files_cached_NUL_inventory
20
+ writes_or_execution: forbidden
21
+ corpus:
22
+ root: exact_repository_relative_.nimi/spec_resolved_realpath
23
+ units: active_only
24
+ fields: [title, meaning, statement, condition, failure]
25
+ term:
26
+ required_for_code: true
27
+ admission: must_be_one_exact_term_the_closed_lexical_grammar_admits
28
+ lexical_grammar:
29
+ classes: [snake_case, camelCase, UPPER_SNAKE, ALL_CAPS, PascalCase, dotted]
30
+ all_caps_shape: '[A-Z]{2,}'
31
+ all_caps_semantics: lexical_shape_only_without_acronym_or_product_identity_inference
32
+ acronym_leading_pascal_shape: '[A-Z]{2,}[a-z][a-z0-9]*([A-Z][a-z0-9]*)*'
33
+ ordinary_title_words: excluded_unless_they_match_the_existing_multi_segment_PascalCase_shape
34
+ boundaries: ASCII_identifier_boundaries_required
35
+ excluded: terms_inside_longer_path_like_tokens_containing_a_slash
36
+ dotted_exclusion: final_segments_that_are_known_code_extensions
37
+ code_inventory:
38
+ shape: tracked_text_inventory_v1
39
+ selection: by_decoded_content_never_by_an_extension_allowlist
40
+ rationale: a_fixed_extension_list_silently_dropped_whole_languages_while_the_report_claimed_complete
41
+ binary_detection: NUL_byte_or_undecodable_UTF_8_prefix_probe
42
+ probe_decoder: one_fresh_decoder_per_file_so_a_straddling_character_cannot_reject_the_next_file
43
+ exclusions:
44
+ every_excluded_file_reported: true
45
+ reasons: [authority-corpus, binary-content, not-utf8]
46
+ silent_exclusion: forbidden
47
+ accounting: tracked_files_equals_scanned_files_plus_excluded_files
48
+ budgets:
49
+ max_units: complete_active_unit_set_must_fit
50
+ max_terms: complete_distinct_term_set_must_fit
51
+ max_bytes: inputBytes_complete_decoded_authority_and_optional_code_input_must_fit
52
+ exceeded: refuse_with_one_diagnostic_and_no_partial_index_or_cross_reference
53
+ result:
54
+ trackedPathSetDigest: sha256_hex_of_nimicoding.repository-inventory/v1_canonical_tracked_path_set_preimage
55
+ complete: true_only_when_every_admitted_input_was_read_and_classified
56
+ byte_counts:
57
+ scannedBytes: selected_normative_authority_fields_plus_optional_decoded_code_inputs
58
+ inputBytes: complete_decoded_authority_corpus_plus_optional_decoded_code_inputs
59
+ partial: never
60
+ modes: [index, detail]
61
+ detail_fields: [term, classes, unitCount, units, code, codeReferences, codeInventory]
62
+ findings_change_exit_code: false
63
+ determinism: identical_inputs_produce_byte_identical_output
@@ -1,27 +1,41 @@
1
- version: 3
1
+ version: 9
2
2
  product:
3
3
  package_name: "@nimiplatform/nimi-coding"
4
- mission: methodology_spec_construction_and_deterministic_validation
4
+ mission: canonical_authority_methodology_formatter_compiler_primitives_and_deterministic_gates
5
5
  owned_surfaces:
6
- - bootstrap_and_sync_of_managed_.nimi_projections
7
- - methodology_principles
8
- - spec_surface_taxonomy_and_placement_contracts
9
- - spec_construction_inputs_and_generation_audit_contracts
10
- - deterministic_spec_governance_and_ai_governance_checks
6
+ - compact_authority_authoring_methodology
7
+ - exact_authority_guide_projection_and_managed_instruction_blocks
8
+ - canonical_authority_format_and_complete_root_check
9
+ - private_compile_bounded_filtered_lexical_discovery_with_field_snippets_optional_direct_authored_relation_preview_exact_query_and_declared_outgoing_context
10
+ - immutable_per_invocation_compiler_snapshots_with_transient_exact_indexes_and_change_derived_candidate_recall
11
+ - semantic_diff_and_declared_review_impact
12
+ - bounded_direct_references_exact_relation_paths_and_local_subgraphs
13
+ - project_bound_deterministic_graph_and_exact_lexical_authority_audit_and_SARIF_projection
14
+ - git_aware_exact_read_only_authority_change_review
15
+ - optional_L3_repository_governance_not_authority_admission
16
+ canonical_boundary:
17
+ host_product_authority: .nimi/spec/**/*.authority.{yaml,md}
18
+ sole_conformance_gate: nimicoding_authority_check_complete_.nimi/spec
19
+ historical_format_inference: forbidden
20
+ product_semantic_generation: forbidden
21
+ surface_separation:
22
+ public: [documented_CLI, package_documentation]
23
+ canonical_project_owned: .nimi/spec/**/*.authority.{yaml,md}
24
+ projected_AI_visible_package_owned: [.nimi/methodology/authority-authoring.yaml, AGENTS.md#managed-block, CLAUDE.md#managed-block]
25
+ local_non_authority: .nimi/local/**
26
+ package_internal: [authority_grammar_contracts, AuthorityIR, SourceMap, compiler_implementation]
11
27
  out_of_scope:
12
- - planning_or_task_lifecycle
13
- - agent_or_provider_orchestration
14
- - implementation_execution
15
- - review_approval_or_completion_state
16
- - host_prompt_or_context_management
17
- - scheduling_notifications_and_automation
18
- integration_contract:
19
- host_owns_execution: true
20
- nimi_coding_may_emit_non_mutating_analysis: true
21
- nimi_coding_may_validate_declared_artifacts: true
22
- nimi_coding_must_not_create_host_execution_state: true
23
- canonical_roots:
24
- package_authority: package://@nimiplatform/nimi-coding
25
- host_product_authority: .nimi/spec
26
- managed_projection_roots: [.nimi/config, .nimi/contracts, .nimi/methodology]
27
- local_non_authority_root: .nimi/local
28
+ - reconstruction_taxonomy_tables_guidance_registries_and_generation_audits
29
+ - profile_specific_authority_validation
30
+ - planning_task_lifecycle_delegation_execution_review_or_approval
31
+ - host_workflow_command_aggregation
32
+ - external_probe_result_attestation_test_execution_or_proof_packet_aggregation
33
+ - sqlite_cache_incremental_embedding_semantic_search_visualization_AI_execution_or_Atlas
34
+ claims:
35
+ discovery: bounded_deterministic_exact_filtered_lexical_candidates_with_SourceMapped_field_snippets_and_optional_M1_direct_authored_relation_preview_not_semantic_search_selection_context_or_absence_proof
36
+ change_candidates: complete_union_of_caller_requested_exact_channels_with_raw_fields_modality_and_reasons_not_semantic_relevance_conflict_retirement_absence_or_conformance
37
+ context: complete_declared_outgoing_interpretation_closure_not_complete_task_context
38
+ impact: declared_relation_impact_and_host_follow_up_targets_not_workflow_state_sync_or_completion_proof
39
+ graph: complete_bounded_explicit_relation_navigation_not_semantic_inference_or_raw_IR
40
+ audit: configured_graph_and_exact_case_sensitive_lexical_results_not_prose_predicate_inference_semantic_synonym_or_plugin_execution
41
+ review: immutable_base_OID_and_stable_worktree_exact_snapshots_composed_through_existing_compiler_diff_impact_and_current_audit_oracles_with_business_and_implementation_status_not_evaluated
@@ -1,91 +0,0 @@
1
- import {
2
- buildBlueprintAuditPayload,
3
- formatBlueprintAuditPayload,
4
- writeBlueprintAuditArtifact,
5
- } from "../lib/shared.mjs";
6
- import { localize } from "../lib/ui.mjs";
7
-
8
- function parseBlueprintAuditOptions(args) {
9
- const options = {
10
- json: false,
11
- writeLocal: false,
12
- blueprintRoot: null,
13
- canonicalRoot: null,
14
- };
15
-
16
- for (let index = 0; index < args.length; index += 1) {
17
- const arg = args[index];
18
-
19
- if (arg === "--json") {
20
- options.json = true;
21
- continue;
22
- }
23
-
24
- if (arg === "--write-local") {
25
- options.writeLocal = true;
26
- continue;
27
- }
28
-
29
- if (arg === "--blueprint-root" || arg === "--canonical-root") {
30
- const next = args[index + 1];
31
- if (!next || next.startsWith("--")) {
32
- return {
33
- ok: false,
34
- error: `${localize(
35
- `nimicoding blueprint-audit refused: ${arg} requires a value.`,
36
- `nimicoding blueprint-audit 已拒绝:${arg} 需要一个值。`,
37
- )}\n`,
38
- };
39
- }
40
-
41
- if (arg === "--blueprint-root") {
42
- options.blueprintRoot = next;
43
- } else {
44
- options.canonicalRoot = next;
45
- }
46
- index += 1;
47
- continue;
48
- }
49
-
50
- return {
51
- ok: false,
52
- error: `${localize(
53
- `nimicoding blueprint-audit refused: unknown option ${arg}.`,
54
- `nimicoding blueprint-audit 已拒绝:未知选项 ${arg}。`,
55
- )}\n`,
56
- };
57
- }
58
-
59
- return {
60
- ok: true,
61
- options,
62
- };
63
- }
64
-
65
- export async function runBlueprintAudit(args) {
66
- const parsed = parseBlueprintAuditOptions(args);
67
- if (!parsed.ok) {
68
- process.stderr.write(parsed.error);
69
- return 2;
70
- }
71
-
72
- const payload = await buildBlueprintAuditPayload(process.cwd(), parsed.options);
73
- if (payload.inputError) {
74
- process.stderr.write(payload.error);
75
- return payload.exitCode;
76
- }
77
-
78
- if (parsed.options.writeLocal) {
79
- await writeBlueprintAuditArtifact(process.cwd(), payload);
80
- }
81
-
82
- if (parsed.options.json) {
83
- process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
84
- } else {
85
- process.stdout.write(formatBlueprintAuditPayload(payload));
86
- }
87
-
88
- return payload.exitCode;
89
- }
90
-
91
- export { parseBlueprintAuditOptions };
@@ -1,5 +0,0 @@
1
- import { runSurfaceValidatorCommand } from "./surface-validator-command.mjs";
2
-
3
- export function runClassifySpecTree(args) {
4
- return runSurfaceValidatorCommand(args, "classify-spec-tree");
5
- }
@@ -1,151 +0,0 @@
1
- import { readFile } from "node:fs/promises";
2
- import path from "node:path";
3
- import { fileURLToPath } from "node:url";
4
-
5
- import { localize } from "../lib/ui.mjs";
6
- import { loadGovernanceConfig, requireProfile } from "../lib/internal/governance/config.mjs";
7
- import { runCommand } from "../lib/internal/governance/runner.mjs";
8
- import { parseSpecGenerationInputsConfig } from "../lib/internal/contracts-parse.mjs";
9
-
10
- const PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
11
-
12
- function parseOptions(args) {
13
- const options = {
14
- profile: null,
15
- scope: "all",
16
- check: false,
17
- };
18
-
19
- for (let index = 0; index < args.length; index += 1) {
20
- const arg = args[index];
21
-
22
- if (arg === "--profile") {
23
- const value = args[index + 1];
24
- if (!value || value.startsWith("--")) {
25
- return { ok: false, error: "nimicoding generate-spec-derived-docs refused: --profile requires a value.\n" };
26
- }
27
- options.profile = value;
28
- index += 1;
29
- continue;
30
- }
31
-
32
- if (arg === "--scope") {
33
- const value = args[index + 1];
34
- if (!value || value.startsWith("--")) {
35
- return { ok: false, error: "nimicoding generate-spec-derived-docs refused: --scope requires a value.\n" };
36
- }
37
- options.scope = value;
38
- index += 1;
39
- continue;
40
- }
41
-
42
- if (arg === "--check") {
43
- options.check = true;
44
- continue;
45
- }
46
-
47
- return {
48
- ok: false,
49
- error: `nimicoding generate-spec-derived-docs refused: unknown option ${arg}.\n`,
50
- };
51
- }
52
-
53
- return { ok: true, options };
54
- }
55
-
56
- function resolveScopes(scope, governanceConfig) {
57
- const configuredScopes = Object.keys(governanceConfig.specGovernance.generateCommands || {});
58
- if (scope === "all") {
59
- return {
60
- ok: true,
61
- scopes: configuredScopes,
62
- error: null,
63
- };
64
- }
65
- if (!configuredScopes.includes(scope)) {
66
- return {
67
- ok: false,
68
- scopes: [],
69
- error: `nimicoding generate-spec-derived-docs refused: unsupported --scope value ${scope}.\n`,
70
- };
71
- }
72
- return {
73
- ok: true,
74
- scopes: [scope],
75
- error: null,
76
- };
77
- }
78
-
79
- export async function runGenerateSpecDerivedDocs(args) {
80
- const parsed = parseOptions(args);
81
- if (!parsed.ok) {
82
- process.stderr.write(localize(parsed.error, parsed.error));
83
- return 2;
84
- }
85
-
86
- const governance = await loadGovernanceConfig(process.cwd());
87
- if (!governance.ok) {
88
- process.stderr.write(localize(
89
- `nimicoding generate-spec-derived-docs refused: ${governance.reason} at ${governance.path}.\n`,
90
- `nimicoding generate-spec-derived-docs 已拒绝:${governance.path} 的治理配置不可用。\n`,
91
- ));
92
- return 2;
93
- }
94
-
95
- const profileCheck = requireProfile(governance.config, parsed.options.profile);
96
- if (!profileCheck.ok) {
97
- process.stderr.write(localize(
98
- `nimicoding generate-spec-derived-docs refused: ${profileCheck.error}.\n`,
99
- `nimicoding generate-spec-derived-docs 已拒绝:${profileCheck.error}。\n`,
100
- ));
101
- return 2;
102
- }
103
-
104
- const scopeResolution = resolveScopes(parsed.options.scope, governance.config);
105
- if (!scopeResolution.ok) {
106
- process.stderr.write(localize(scopeResolution.error, scopeResolution.error));
107
- return 2;
108
- }
109
-
110
- const packageInputsText = await readFile(
111
- path.join(PACKAGE_ROOT, "config", "spec-generation-inputs.yaml"),
112
- "utf8",
113
- );
114
- const packageInputs = parseSpecGenerationInputsConfig(packageInputsText);
115
- if (!packageInputs.ok || !packageInputs.generationOrder.includes("validate_placement")) {
116
- process.stderr.write(localize(
117
- "nimicoding generate-spec-derived-docs refused: package spec generation inputs must be class-filtered and include placement validation.\n",
118
- "nimicoding generate-spec-derived-docs 已拒绝:package spec generation inputs 必须按 surface class 过滤并包含 placement validation。\n",
119
- ));
120
- return 2;
121
- }
122
-
123
- let failed = false;
124
- for (const scope of scopeResolution.scopes) {
125
- const commands = governance.config.specGovernance.generateCommands[scope] || [];
126
- if (commands.length === 0) {
127
- process.stderr.write(localize(
128
- `nimicoding generate-spec-derived-docs refused: scope ${scope} is not configured in .nimi/config/governance.yaml.\n`,
129
- `nimicoding generate-spec-derived-docs 已拒绝:.nimi/config/governance.yaml 未配置 ${scope}。\n`,
130
- ));
131
- return 2;
132
- }
133
-
134
- for (const command of commands) {
135
- const commandToRun = parsed.options.check ? `${command} --check` : command;
136
- const result = runCommand(commandToRun, { cwd: process.cwd() });
137
- if (result.stdout) process.stdout.write(result.stdout);
138
- if (result.stderr) process.stderr.write(result.stderr);
139
- if (!result.ok) {
140
- failed = true;
141
- break;
142
- }
143
- }
144
-
145
- if (failed) {
146
- break;
147
- }
148
- }
149
-
150
- return failed ? 1 : 0;
151
- }
@@ -1,30 +0,0 @@
1
- import {
2
- generateSpecMigrationPlan,
3
- parseSurfaceValidatorOptions,
4
- writeMigrationPlanIfRequested,
5
- } from "../lib/internal/surface-taxonomy-validators.mjs";
6
- import { localize } from "../lib/ui.mjs";
7
-
8
- export async function runGenerateSpecMigrationPlan(args) {
9
- const parsed = parseSurfaceValidatorOptions(args);
10
- if (!parsed.ok) {
11
- process.stderr.write(localize(
12
- `nimicoding generate-spec-migration-plan refused: ${parsed.error}\n`,
13
- `nimicoding generate-spec-migration-plan 已拒绝:${parsed.error}\n`,
14
- ));
15
- return 2;
16
- }
17
-
18
- try {
19
- const report = await generateSpecMigrationPlan(process.cwd(), parsed.options);
20
- await writeMigrationPlanIfRequested(report, parsed.options.emit, process.cwd());
21
- process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
22
- return report.ok ? 0 : 1;
23
- } catch (error) {
24
- process.stderr.write(localize(
25
- `nimicoding generate-spec-migration-plan refused: ${error.message}\n`,
26
- `nimicoding generate-spec-migration-plan 已拒绝:${error.message}\n`,
27
- ));
28
- return 2;
29
- }
30
- }
@@ -1,49 +0,0 @@
1
- import {
2
- classifySpecSurface,
3
- parseSurfaceValidatorOptions,
4
- validateDomainAdmission,
5
- validateGuidanceBodies,
6
- validatePlacement,
7
- validateProjectionEdges,
8
- validateTableFamily,
9
- validateTrackedOutputAdmission,
10
- writeInventoryIfRequested,
11
- } from "../lib/internal/surface-taxonomy-validators.mjs";
12
- import { localize } from "../lib/ui.mjs";
13
-
14
- const VALIDATORS = {
15
- "classify-spec-tree": classifySpecSurface,
16
- "validate-placement": validatePlacement,
17
- "validate-table-family": validateTableFamily,
18
- "validate-projection-edges": validateProjectionEdges,
19
- "validate-guidance-bodies": validateGuidanceBodies,
20
- "validate-domain-admission": validateDomainAdmission,
21
- "validate-tracked-output-admission": validateTrackedOutputAdmission,
22
- };
23
-
24
- export async function runSurfaceValidatorCommand(args, validatorName) {
25
- const parsed = parseSurfaceValidatorOptions(args);
26
- if (!parsed.ok) {
27
- process.stderr.write(localize(
28
- `nimicoding ${validatorName} refused: ${parsed.error}\n`,
29
- `nimicoding ${validatorName} 已拒绝:${parsed.error}\n`,
30
- ));
31
- return 2;
32
- }
33
-
34
- const validator = VALIDATORS[validatorName];
35
- if (!validator) {
36
- process.stderr.write(localize(
37
- `nimicoding ${validatorName} refused: unknown surface validator.\n`,
38
- `nimicoding ${validatorName} 已拒绝:未知 surface validator。\n`,
39
- ));
40
- return 2;
41
- }
42
-
43
- const report = await validator(process.cwd(), parsed.options);
44
- if (validatorName === "classify-spec-tree") {
45
- await writeInventoryIfRequested(report, parsed.options.emit, process.cwd());
46
- }
47
- process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
48
- return report.ok ? 0 : 1;
49
- }
@@ -1,5 +0,0 @@
1
- import { runSurfaceValidatorCommand } from "./surface-validator-command.mjs";
2
-
3
- export function runValidateDomainAdmission(args) {
4
- return runSurfaceValidatorCommand(args, "validate-domain-admission");
5
- }
@@ -1,5 +0,0 @@
1
- import { runSurfaceValidatorCommand } from "./surface-validator-command.mjs";
2
-
3
- export function runValidateGuidanceBodies(args) {
4
- return runSurfaceValidatorCommand(args, "validate-guidance-bodies");
5
- }
@@ -1,5 +0,0 @@
1
- import { runSurfaceValidatorCommand } from "./surface-validator-command.mjs";
2
-
3
- export function runValidatePlacement(args) {
4
- return runSurfaceValidatorCommand(args, "validate-placement");
5
- }
@@ -1,5 +0,0 @@
1
- import { runSurfaceValidatorCommand } from "./surface-validator-command.mjs";
2
-
3
- export function runValidateProjectionEdges(args) {
4
- return runSurfaceValidatorCommand(args, "validate-projection-edges");
5
- }
@@ -1,27 +0,0 @@
1
- import path from "node:path";
2
-
3
- import { validateSpecAudit, buildValidatorCliReport } from "../lib/validators.mjs";
4
- import { localize } from "../lib/ui.mjs";
5
-
6
- export async function runValidateSpecAudit(args) {
7
- const normalized = args[0] === "--" ? args.slice(1) : args;
8
- let targetPath = ".nimi/local/state/spec-generation/spec-generation-audit.yaml";
9
-
10
- if (normalized.length > 1) {
11
- process.stderr.write(localize(
12
- "nimicoding validate-spec-audit refused: expected zero or one path argument.\n",
13
- "nimicoding validate-spec-audit 已拒绝:期望零个或一个路径参数。\n",
14
- ));
15
- return 2;
16
- }
17
-
18
- if (normalized.length === 1) {
19
- targetPath = normalized[0];
20
- }
21
-
22
- const absolutePath = path.resolve(process.cwd(), targetPath);
23
- const report = await validateSpecAudit(absolutePath, { projectRoot: process.cwd() });
24
- const cliReport = buildValidatorCliReport("validate-spec-audit", absolutePath, report);
25
- process.stdout.write(`${JSON.stringify(cliReport, null, 2)}\n`);
26
- return report.ok ? 0 : 1;
27
- }