arkgate 4.1.0 → 4.2.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 (63) hide show
  1. package/CHANGELOG.md +124 -2
  2. package/README.md +24 -14
  3. package/bin/ark-check-runtime.mjs +16 -5
  4. package/bin/ark-mcp-runtime.mjs +766 -64
  5. package/bin/lib/agent-gates.mjs +1 -0
  6. package/bin/lib/ark-gitignore.mjs +88 -0
  7. package/bin/lib/ci-and-commands.mjs +33 -8
  8. package/bin/lib/codex-home.mjs +90 -8
  9. package/bin/lib/design-smells.mjs +71 -9
  10. package/bin/lib/doctor-plan.mjs +47 -39
  11. package/bin/lib/effective-contract-load.mjs +73 -9
  12. package/bin/lib/enforcement-honesty.mjs +78 -22
  13. package/bin/lib/enforcement-state.mjs +1 -1
  14. package/bin/lib/gate-files.mjs +441 -9
  15. package/bin/lib/github-enforcement.mjs +168 -7
  16. package/bin/lib/hook-templates.mjs +12 -11
  17. package/bin/lib/host-support-matrix.mjs +91 -17
  18. package/bin/lib/html-report-depth.mjs +13 -2
  19. package/bin/lib/html-report-evolution.mjs +114 -0
  20. package/bin/lib/html-report.mjs +18 -97
  21. package/bin/lib/import-resolve.mjs +33 -11
  22. package/bin/lib/install-activation.mjs +87 -0
  23. package/bin/lib/install-migrate.mjs +66 -50
  24. package/bin/lib/managed-upgrade.mjs +10 -41
  25. package/bin/lib/mcp-adoption.mjs +15 -5
  26. package/bin/lib/pilot-loop.mjs +25 -8
  27. package/bin/lib/project-identity.mjs +103 -0
  28. package/bin/lib/report-snapshot-context.mjs +28 -0
  29. package/bin/lib/resident-hook.mjs +33 -9
  30. package/bin/lib/rules-inventory.mjs +100 -8
  31. package/bin/lib/skill-install.mjs +272 -22
  32. package/bin/lib/skill-write.mjs +899 -0
  33. package/bin/lib/start-preview.mjs +84 -1
  34. package/bin/lib/upgrade-command.mjs +2 -5
  35. package/bin/lib/write-path-detect.mjs +2 -2
  36. package/dist/index.cjs +13 -13
  37. package/dist/index.d.ts +194 -2
  38. package/dist/index.js +13 -13
  39. package/docs/README.md +6 -4
  40. package/docs/agent-guide.md +115 -17
  41. package/docs/ai-gates.md +133 -25
  42. package/docs/assets/ark-write-gate.svg +2 -2
  43. package/docs/develop.md +16 -6
  44. package/docs/enthusiast/how-to-agent-gates.md +6 -0
  45. package/docs/package-surface.md +16 -9
  46. package/docs/product-voice.md +22 -4
  47. package/docs/use.md +3 -1
  48. package/package.json +3 -1
  49. package/schemas/ark.project-identity.schema.json +116 -0
  50. package/server.json +2 -2
  51. package/templates/skills/ark-adopt.md +9 -0
  52. package/templates/skills/ark-architect.md +12 -2
  53. package/templates/skills/ark-autopilot.md +9 -0
  54. package/templates/skills/ark-contract.md +11 -1
  55. package/templates/skills/ark-coverage.md +9 -0
  56. package/templates/skills/ark-explain.md +13 -1
  57. package/templates/skills/ark-explore.md +9 -0
  58. package/templates/skills/ark-fix.md +10 -1
  59. package/templates/skills/ark-loop.md +11 -2
  60. package/templates/skills/ark-place.md +17 -6
  61. package/templates/skills/ark-runtime.md +8 -0
  62. package/templates/skills/ark-think.md +14 -2
  63. package/templates/skills/ark-upgrade.md +9 -0
package/dist/index.d.ts CHANGED
@@ -244,7 +244,7 @@ declare function loadArkConfigContract(input: unknown, source?: string): ArkConf
244
244
  declare function parseArkConfigJson(json: string, source?: string): ArkConfigLoadResult;
245
245
 
246
246
  /** ArkGate library version — single source of truth. */
247
- declare const version = "4.1.0";
247
+ declare const version = "4.2.0";
248
248
 
249
249
  /** Versioned public result contract shared by every ArkGate enforcement adapter. */
250
250
  /** 1.4 adds optional evidence.arkruleId + evidence.arkruleSource (ADR 0012 / AR03). */
@@ -588,6 +588,180 @@ declare const ARK_ANALYSIS_RESULT_SCHEMA: {
588
588
  };
589
589
  };
590
590
 
591
+ /**
592
+ * Canonical, pure contract for ArkGate MCP project identity.
593
+ *
594
+ * Filesystem canonicalization, hashing, clocks, and runtime ids belong to the
595
+ * Tooling adapter. This module owns the stable payload and published schemas so
596
+ * every MCP surface speaks the same identity/binding language.
597
+ */
598
+ declare const ARK_PROJECT_IDENTITY_SCHEMA_VERSION: "1.0";
599
+ declare const ARK_PROJECT_IDENTITY_SCHEMA_URL = "https://unpkg.com/arkgate@4/schemas/ark.project-identity.schema.json";
600
+ type ProjectIdentity = {
601
+ schemaVersion: typeof ARK_PROJECT_IDENTITY_SCHEMA_VERSION;
602
+ projectId: string;
603
+ resolvedRoot: string;
604
+ resolvedConfigPath: string;
605
+ arkgateVersion: string;
606
+ contractHash: string;
607
+ contractSource: 'project' | 'default-profile' | 'manifest';
608
+ runtimeId: string;
609
+ processStartedAt: string;
610
+ };
611
+ type ProjectExpectation = {
612
+ expectedRoot?: string;
613
+ expectedProjectId?: string;
614
+ };
615
+ type ProjectBinding = {
616
+ status: 'matched' | 'unverified' | 'mismatch';
617
+ authoritative: boolean;
618
+ expectedRoot?: string;
619
+ expectedProjectId?: string;
620
+ code?: 'PROJECT_ROOT_MISMATCH' | 'PROJECT_ID_MISMATCH' | 'INVALID_PROJECT_EXPECTATION';
621
+ message?: string;
622
+ };
623
+ declare const PROJECT_EXPECTATION_SCHEMA: {
624
+ readonly type: "object";
625
+ readonly additionalProperties: false;
626
+ readonly properties: {
627
+ readonly expectedRoot: {
628
+ readonly type: "string";
629
+ readonly minLength: 1;
630
+ readonly description: string;
631
+ };
632
+ readonly expectedProjectId: {
633
+ readonly type: "string";
634
+ readonly pattern: "^sha256:[a-f0-9]{64}$";
635
+ readonly description: "Project id previously returned by ark_identity or ark_manifest.";
636
+ };
637
+ };
638
+ };
639
+ declare const PROJECT_BINDING_SCHEMA: {
640
+ readonly type: "object";
641
+ readonly additionalProperties: false;
642
+ readonly required: readonly ["status", "authoritative"];
643
+ readonly properties: {
644
+ readonly status: {
645
+ readonly enum: readonly ["matched", "unverified", "mismatch"];
646
+ };
647
+ readonly authoritative: {
648
+ readonly type: "boolean";
649
+ };
650
+ readonly expectedRoot: {
651
+ readonly type: "string";
652
+ readonly minLength: 1;
653
+ };
654
+ readonly expectedProjectId: {
655
+ readonly type: "string";
656
+ readonly pattern: "^sha256:[a-f0-9]{64}$";
657
+ };
658
+ readonly code: {
659
+ readonly enum: readonly ["PROJECT_ROOT_MISMATCH", "PROJECT_ID_MISMATCH", "INVALID_PROJECT_EXPECTATION"];
660
+ };
661
+ readonly message: {
662
+ readonly type: "string";
663
+ readonly minLength: 1;
664
+ };
665
+ };
666
+ };
667
+ declare const ARK_PROJECT_IDENTITY_SCHEMA: {
668
+ readonly $schema: "https://json-schema.org/draft/2020-12/schema";
669
+ readonly $id: "https://unpkg.com/arkgate@4/schemas/ark.project-identity.schema.json";
670
+ readonly title: "ArkGate MCP project identity";
671
+ readonly description: "Stable project binding plus separate runtime and architecture-contract evidence.";
672
+ readonly type: "object";
673
+ readonly additionalProperties: false;
674
+ readonly required: readonly ["schemaVersion", "projectId", "resolvedRoot", "resolvedConfigPath", "arkgateVersion", "contractHash", "contractSource", "runtimeId", "processStartedAt"];
675
+ readonly properties: {
676
+ readonly schemaVersion: {
677
+ readonly const: "1.0";
678
+ };
679
+ readonly projectId: {
680
+ readonly type: "string";
681
+ readonly pattern: "^sha256:[a-f0-9]{64}$";
682
+ };
683
+ readonly resolvedRoot: {
684
+ readonly type: "string";
685
+ readonly minLength: 1;
686
+ };
687
+ readonly resolvedConfigPath: {
688
+ readonly type: "string";
689
+ readonly minLength: 1;
690
+ };
691
+ readonly arkgateVersion: {
692
+ readonly type: "string";
693
+ readonly minLength: 1;
694
+ };
695
+ readonly contractHash: {
696
+ readonly type: "string";
697
+ readonly pattern: "^sha256:[a-f0-9]{64}$";
698
+ };
699
+ readonly contractSource: {
700
+ readonly enum: readonly ["project", "default-profile", "manifest"];
701
+ };
702
+ readonly runtimeId: {
703
+ readonly type: "string";
704
+ readonly minLength: 1;
705
+ };
706
+ readonly processStartedAt: {
707
+ readonly type: "string";
708
+ readonly format: "date-time";
709
+ };
710
+ };
711
+ readonly $defs: {
712
+ readonly expectation: {
713
+ readonly type: "object";
714
+ readonly additionalProperties: false;
715
+ readonly properties: {
716
+ readonly expectedRoot: {
717
+ readonly type: "string";
718
+ readonly minLength: 1;
719
+ readonly description: string;
720
+ };
721
+ readonly expectedProjectId: {
722
+ readonly type: "string";
723
+ readonly pattern: "^sha256:[a-f0-9]{64}$";
724
+ readonly description: "Project id previously returned by ark_identity or ark_manifest.";
725
+ };
726
+ };
727
+ };
728
+ readonly binding: {
729
+ readonly type: "object";
730
+ readonly additionalProperties: false;
731
+ readonly required: readonly ["status", "authoritative"];
732
+ readonly properties: {
733
+ readonly status: {
734
+ readonly enum: readonly ["matched", "unverified", "mismatch"];
735
+ };
736
+ readonly authoritative: {
737
+ readonly type: "boolean";
738
+ };
739
+ readonly expectedRoot: {
740
+ readonly type: "string";
741
+ readonly minLength: 1;
742
+ };
743
+ readonly expectedProjectId: {
744
+ readonly type: "string";
745
+ readonly pattern: "^sha256:[a-f0-9]{64}$";
746
+ };
747
+ readonly code: {
748
+ readonly enum: readonly ["PROJECT_ROOT_MISMATCH", "PROJECT_ID_MISMATCH", "INVALID_PROJECT_EXPECTATION"];
749
+ };
750
+ readonly message: {
751
+ readonly type: "string";
752
+ readonly minLength: 1;
753
+ };
754
+ };
755
+ };
756
+ };
757
+ };
758
+ /**
759
+ * Stable identity: contract edits and MCP restarts must not change which project
760
+ * this is. Callers must pass canonical real paths and a SHA-256 hex function.
761
+ */
762
+ declare function createProjectId(resolvedRoot: string, resolvedConfigPath: string, sha256Hex: (value: string) => string): string;
763
+ declare function createProjectIdentity(input: Omit<ProjectIdentity, 'schemaVersion'>): ProjectIdentity;
764
+
591
765
  /**
592
766
  * AI Code Gate (basic).
593
767
  *
@@ -2416,6 +2590,8 @@ type RulesInventoryCandidate = {
2416
2590
  line: number;
2417
2591
  message: string;
2418
2592
  confidence: RulesInventoryConfidence;
2593
+ /** Governed layer supplied by the caller, when available. */
2594
+ governedLayer?: string;
2419
2595
  suggestedArkRule?: {
2420
2596
  layer: string;
2421
2597
  structureId?: string;
@@ -2431,8 +2607,24 @@ type RulesInventoryResult = {
2431
2607
  frozen: number;
2432
2608
  notAScore: true;
2433
2609
  };
2610
+ type RulesInventoryLayerContext = {
2611
+ name: string;
2612
+ intentPrefixes?: readonly string[];
2613
+ };
2434
2614
  type BuildRulesInventoryInput = {
2435
2615
  fileContents: Readonly<Record<string, string>>;
2616
+ /**
2617
+ * Actual governed layer by repository-relative file path.
2618
+ *
2619
+ * When a file has layer evidence, it replaces filename heuristics for deciding
2620
+ * whether the file is a Domain module or a controller-like boundary.
2621
+ */
2622
+ fileLayers?: Readonly<Record<string, string>>;
2623
+ /**
2624
+ * Configured layer intent ownership. This keeps custom names such as `core`
2625
+ * semantically Domain when they own `Domain.` without changing fileLayers.
2626
+ */
2627
+ layerContexts?: readonly RulesInventoryLayerContext[];
2436
2628
  /** Invariant / structure ids already under contract (to compute underContract count). */
2437
2629
  contractedRuleIds?: readonly string[];
2438
2630
  /** Baseline keys currently frozen for arkrule residual. */
@@ -2540,4 +2732,4 @@ type ArkDesignDeltaResult = {
2540
2732
  error?: string;
2541
2733
  };
2542
2734
 
2543
- export { type AICodeGate, type AICodeGateContext, type AICodeGateOptions, type AICodeGateResult, type AICodeGateViolation, type AIGateExtension, ANALYSIS_IR_SCHEMA_VERSION, ARK_ANALYSIS_RESULT_SCHEMA, ARK_ANALYSIS_RESULT_SCHEMA_VERSION, ARK_CONFIG_SCHEMA, ARK_CONFIG_SCHEMA_VERSION, ARK_DESIGN_DELTA_SCHEMA_VERSION, ARK_ENFORCEMENT_STATE_SCHEMA_VERSION, ARK_RULES_SCHEMA, ARK_RULES_SCHEMA_VERSION, ARK_RULE_SENSORS, type AdapterCompletenessReason, type AdapterDiagnostic, type AdapterResult, type AdapterSeverity, type AdapterViolationInput, type AnalysisCapabilityUse, type AnalysisCompilerOptions, type AnalysisCompleteness, type AnalysisContract, type AnalysisEvidence, type AnalysisFile, type AnalysisFileChange, type AnalysisFileInput, type AnalysisImportEdge, type AnalysisIr, type AnalysisMode, type AnalysisResult, type AnalysisViolation, type AnalyzeArchitectureConvergenceInput, type AnalyzeChangeInput, type AnalyzePolicyDeltaInput, type AnalyzeProjectInput, type AnalyzeResolvedProjectInput, type ArchitectureActualChange, type ArchitectureChangeMap, type ArchitectureChangeMapContract, type ArchitectureChangeMapDependency, type ArchitectureChangeMapFile, type ArchitectureChangeOperation, type ArchitectureConvergenceClassification, type ArchitectureConvergenceFinding, type ArchitectureConvergenceResult, type ArchitectureDependency, type ArchitectureEngineEdge, type ArchitectureEngineResult, type ArchitectureEngineViolation, type ArchitectureLayer, type ArchitectureLayerConfig, type ArchitectureProfile, type ArchitectureRule, type ArkCheckConfig, ArkConfig, ArkConfigLoadResult, type ArkDesignDeltaResult, type ArkEnforcementHost, type ArkEnforcementState, type ArkRuleSensorViolation, type ArkRulesFile, type ChangePreflightResult, type ClassShapeFact, type CollectAnalysisConfigWarningsInput, type CreateArchitectureProfileFromArkConfigOptions, type CreateArchitectureProfileOptions, type CreateElevenLayerArkConfigOptions, type DesignDeltaChange, type DesignDeltaIdentity, type DesignSmellEvidence, type DesignSmellFinding, type DesignSmellId, type EffectiveArkRules, type EffectiveContract, EffectiveContractError, type EffectiveContractWarning, type EnforcementBoundaryState, type EnforcementEvidence, type EnforcementEvidenceField, type EnforcementVerification, type EvaluateArchitectureGraphInput, type ForbiddenCapabilityUse, type InvariantCoverageEvidence, POLICY_DELTA_SCHEMA_VERSION, type PolicyDelta, type PolicyDeltaAcknowledgement, type PolicyDeltaAnalysis, type PolicyDeltaClassification, type PolicyDeltaFinding, type PreflightResolvedChangeInput, type PreparedChangeFile, RESOLVED_CANDIDATE_FACTS_SCHEMA, RESOLVED_CANDIDATE_FACTS_SCHEMA_VERSION, type ResolvedAmbientFact, type ResolvedAnalysisFile, type ResolvedAnalysisIr, type ResolvedAnalysisResult, type ResolvedCandidateFacts, type ResolvedCandidateFactsInput, type ResolvedCapability, type ResolvedCapabilityFact, type ResolvedChangePreflightResult, type ResolvedDependencyFact, type ResolvedDependencyKind, type ResolvedDependencyState, type ResolvedFactsCompleteness, type ResolvedFactsReason, type ResolvedFileFact, type ResolvedIntentReferenceFact, type ResolvedPublishFact, type ResolvedSafetyFact, type ResolvedSafetyKind, type ResolvedSafetyReport, type RulesInventoryCandidate, type RulesInventoryResult, type SemanticDependency, type SemanticDependencyKind, analyzeArchitectureConvergence, analyzeChange, analyzePolicyDelta, analyzeProject, analyzeResolvedProject, buildArkRuleFileHints, buildEffectiveArkRules, buildRulesInventory, canPromoteInvariant, classifyArkPolicyDelta, collectAnalysisConfigWarnings, collectEmptyAppliesToFindings, collectForbiddenCapabilityUses, createAICodeGate, createAdapterResult, createArchitectureProfile, createArchitectureProfileFromArkConfig, createElevenLayerArkConfig, createResolvedCandidateFacts, deriveArkRuleFileHints, detectArchitectureCycles, deterministicHash, effectiveContractPolicyPayload, elevenLayerProfile, emptyEffectiveArkRules, evaluateArchitectureGraph, evaluateArkRuleSensors, evaluateInvariantCoverage, explainViolation, extractClassShapesFromSource, extractSemanticDependencies, inventoryToExtractionCard, loadArkConfigContract, loadArkRulesContract, loadContract, loadResolvedCandidateFacts, parseArkConfigJson, parseArkRulesJson, policyDeltaAcknowledgementMatches, preflightChange, preflightResolvedChange, resolveEffectiveContract, resolvedFactsEvidenceRequirementsHash, stableSerialize, toAdapterDiagnostic, version };
2735
+ export { type AICodeGate, type AICodeGateContext, type AICodeGateOptions, type AICodeGateResult, type AICodeGateViolation, type AIGateExtension, ANALYSIS_IR_SCHEMA_VERSION, ARK_ANALYSIS_RESULT_SCHEMA, ARK_ANALYSIS_RESULT_SCHEMA_VERSION, ARK_CONFIG_SCHEMA, ARK_CONFIG_SCHEMA_VERSION, ARK_DESIGN_DELTA_SCHEMA_VERSION, ARK_ENFORCEMENT_STATE_SCHEMA_VERSION, ARK_PROJECT_IDENTITY_SCHEMA, ARK_PROJECT_IDENTITY_SCHEMA_URL, ARK_PROJECT_IDENTITY_SCHEMA_VERSION, ARK_RULES_SCHEMA, ARK_RULES_SCHEMA_VERSION, ARK_RULE_SENSORS, type AdapterCompletenessReason, type AdapterDiagnostic, type AdapterResult, type AdapterSeverity, type AdapterViolationInput, type AnalysisCapabilityUse, type AnalysisCompilerOptions, type AnalysisCompleteness, type AnalysisContract, type AnalysisEvidence, type AnalysisFile, type AnalysisFileChange, type AnalysisFileInput, type AnalysisImportEdge, type AnalysisIr, type AnalysisMode, type AnalysisResult, type AnalysisViolation, type AnalyzeArchitectureConvergenceInput, type AnalyzeChangeInput, type AnalyzePolicyDeltaInput, type AnalyzeProjectInput, type AnalyzeResolvedProjectInput, type ArchitectureActualChange, type ArchitectureChangeMap, type ArchitectureChangeMapContract, type ArchitectureChangeMapDependency, type ArchitectureChangeMapFile, type ArchitectureChangeOperation, type ArchitectureConvergenceClassification, type ArchitectureConvergenceFinding, type ArchitectureConvergenceResult, type ArchitectureDependency, type ArchitectureEngineEdge, type ArchitectureEngineResult, type ArchitectureEngineViolation, type ArchitectureLayer, type ArchitectureLayerConfig, type ArchitectureProfile, type ArchitectureRule, type ArkCheckConfig, ArkConfig, ArkConfigLoadResult, type ArkDesignDeltaResult, type ArkEnforcementHost, type ArkEnforcementState, type ArkRuleSensorViolation, type ArkRulesFile, type ChangePreflightResult, type ClassShapeFact, type CollectAnalysisConfigWarningsInput, type CreateArchitectureProfileFromArkConfigOptions, type CreateArchitectureProfileOptions, type CreateElevenLayerArkConfigOptions, type DesignDeltaChange, type DesignDeltaIdentity, type DesignSmellEvidence, type DesignSmellFinding, type DesignSmellId, type EffectiveArkRules, type EffectiveContract, EffectiveContractError, type EffectiveContractWarning, type EnforcementBoundaryState, type EnforcementEvidence, type EnforcementEvidenceField, type EnforcementVerification, type EvaluateArchitectureGraphInput, type ForbiddenCapabilityUse, type InvariantCoverageEvidence, POLICY_DELTA_SCHEMA_VERSION, PROJECT_BINDING_SCHEMA, PROJECT_EXPECTATION_SCHEMA, type PolicyDelta, type PolicyDeltaAcknowledgement, type PolicyDeltaAnalysis, type PolicyDeltaClassification, type PolicyDeltaFinding, type PreflightResolvedChangeInput, type PreparedChangeFile, type ProjectBinding, type ProjectExpectation, type ProjectIdentity, RESOLVED_CANDIDATE_FACTS_SCHEMA, RESOLVED_CANDIDATE_FACTS_SCHEMA_VERSION, type ResolvedAmbientFact, type ResolvedAnalysisFile, type ResolvedAnalysisIr, type ResolvedAnalysisResult, type ResolvedCandidateFacts, type ResolvedCandidateFactsInput, type ResolvedCapability, type ResolvedCapabilityFact, type ResolvedChangePreflightResult, type ResolvedDependencyFact, type ResolvedDependencyKind, type ResolvedDependencyState, type ResolvedFactsCompleteness, type ResolvedFactsReason, type ResolvedFileFact, type ResolvedIntentReferenceFact, type ResolvedPublishFact, type ResolvedSafetyFact, type ResolvedSafetyKind, type ResolvedSafetyReport, type RulesInventoryCandidate, type RulesInventoryResult, type SemanticDependency, type SemanticDependencyKind, analyzeArchitectureConvergence, analyzeChange, analyzePolicyDelta, analyzeProject, analyzeResolvedProject, buildArkRuleFileHints, buildEffectiveArkRules, buildRulesInventory, canPromoteInvariant, classifyArkPolicyDelta, collectAnalysisConfigWarnings, collectEmptyAppliesToFindings, collectForbiddenCapabilityUses, createAICodeGate, createAdapterResult, createArchitectureProfile, createArchitectureProfileFromArkConfig, createElevenLayerArkConfig, createProjectId, createProjectIdentity, createResolvedCandidateFacts, deriveArkRuleFileHints, detectArchitectureCycles, deterministicHash, effectiveContractPolicyPayload, elevenLayerProfile, emptyEffectiveArkRules, evaluateArchitectureGraph, evaluateArkRuleSensors, evaluateInvariantCoverage, explainViolation, extractClassShapesFromSource, extractSemanticDependencies, inventoryToExtractionCard, loadArkConfigContract, loadArkRulesContract, loadContract, loadResolvedCandidateFacts, parseArkConfigJson, parseArkRulesJson, policyDeltaAcknowledgementMatches, preflightChange, preflightResolvedChange, resolveEffectiveContract, resolvedFactsEvidenceRequirementsHash, stableSerialize, toAdapterDiagnostic, version };