arkgate 2.11.0 → 2.13.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 (77) hide show
  1. package/CHANGELOG.md +147 -0
  2. package/README.md +70 -41
  3. package/bin/ark-check.mjs +95 -36
  4. package/bin/ark-mcp.mjs +11 -5
  5. package/bin/ark-shared.mjs +88 -56
  6. package/bin/ark.mjs +97 -29
  7. package/bin/lib/agent-gates.mjs +79 -2093
  8. package/bin/lib/architecture-scan.mjs +8 -0
  9. package/bin/lib/ci-and-commands.mjs +392 -0
  10. package/bin/lib/codex-home.mjs +7 -0
  11. package/bin/lib/config-contract.mjs +331 -0
  12. package/bin/lib/deploy-path.mjs +205 -0
  13. package/bin/lib/doctor-plan.mjs +43 -16
  14. package/bin/lib/enforcement-profiles.mjs +97 -0
  15. package/bin/lib/gate-files.mjs +223 -0
  16. package/bin/lib/hook-templates.mjs +99 -0
  17. package/bin/lib/host-support-matrix.mjs +77 -0
  18. package/bin/lib/install-migrate.mjs +473 -0
  19. package/bin/lib/mcp-adoption.mjs +455 -0
  20. package/bin/lib/open-html.mjs +75 -0
  21. package/bin/lib/presets.mjs +6 -2
  22. package/bin/lib/safety-diagnostics.mjs +31 -11
  23. package/bin/lib/skill-install.mjs +323 -0
  24. package/bin/lib/ts-resolve.mjs +2 -1
  25. package/bin/lib/typescript-host.mjs +88 -0
  26. package/bin/lib/weakest-link.mjs +417 -0
  27. package/bin/lib/write-path-capabilities.mjs +182 -0
  28. package/bin/lib/write-path-detect.mjs +101 -0
  29. package/dist/configContract-iBLxx5Tz.d.cts +53 -0
  30. package/dist/configContract-iBLxx5Tz.d.ts +53 -0
  31. package/dist/eslint/index.cjs +375 -13
  32. package/dist/eslint/index.cjs.map +1 -1
  33. package/dist/eslint/index.d.cts +30 -20
  34. package/dist/eslint/index.d.ts +30 -20
  35. package/dist/eslint/index.js +375 -13
  36. package/dist/eslint/index.js.map +1 -1
  37. package/dist/index.cjs +723 -61
  38. package/dist/index.cjs.map +1 -1
  39. package/dist/index.d.cts +95 -5
  40. package/dist/index.d.ts +95 -5
  41. package/dist/index.js +716 -61
  42. package/dist/index.js.map +1 -1
  43. package/dist/nestjs/index.cjs +150 -42
  44. package/dist/nestjs/index.cjs.map +1 -1
  45. package/dist/nestjs/index.d.cts +2 -1
  46. package/dist/nestjs/index.d.ts +2 -1
  47. package/dist/nestjs/index.js +150 -42
  48. package/dist/nestjs/index.js.map +1 -1
  49. package/dist/runtime/index.cjs +723 -61
  50. package/dist/runtime/index.cjs.map +1 -1
  51. package/dist/runtime/index.d.cts +3 -2
  52. package/dist/runtime/index.d.ts +3 -2
  53. package/dist/runtime/index.js +716 -61
  54. package/dist/runtime/index.js.map +1 -1
  55. package/dist/{types-BZ17b9i5.d.cts → types-BxBwnBpC.d.cts} +9 -36
  56. package/dist/{types-BZ17b9i5.d.ts → types-Wcs_l1_J.d.ts} +9 -36
  57. package/docs/agent-guide.md +43 -21
  58. package/docs/ai-gates.md +53 -18
  59. package/docs/configuration.md +97 -0
  60. package/docs/enthusiast/README.md +3 -3
  61. package/docs/enthusiast/how-to-agent-gates.md +7 -3
  62. package/docs/migrate-from-ark-runtime-kernel.md +3 -0
  63. package/docs/package-surface.md +22 -10
  64. package/docs/production-hardening.md +15 -2
  65. package/docs/threat-model.md +65 -0
  66. package/docs/typescript-support.md +3 -3
  67. package/package.json +15 -2
  68. package/schemas/ark.config.schema.json +750 -0
  69. package/server.json +2 -2
  70. package/templates/hooks/pre-commit-ark +37 -0
  71. package/templates/skills/ark-autopilot.md +77 -45
  72. package/templates/skills/ark-coverage.md +2 -2
  73. package/templates/skills/ark-explain.md +2 -1
  74. package/templates/skills/ark-explore.md +135 -34
  75. package/templates/skills/ark-runtime.md +8 -5
  76. package/templates/skills/ark-upgrade.md +36 -16
  77. package/tests/fixtures/ts-consumer/ark.config.json +2 -0
@@ -1671,6 +1671,138 @@ function createIntentRegistry() {
1671
1671
  return new IntentRegistry();
1672
1672
  }
1673
1673
 
1674
+ // src/domain/configContract.ts
1675
+ var ARK_CONFIG_SCHEMA_VERSION = "1.0";
1676
+ var ARK_CONFIG_SCHEMA_URL = "https://unpkg.com/arkgate@2/schemas/ark.config.schema.json";
1677
+ var DEFAULT_LAYER_NAMES = [
1678
+ "DomainModel",
1679
+ "ApplicationOrchestration",
1680
+ "PersistenceAdapters",
1681
+ "IntegrationAdapters",
1682
+ "WorkflowSagaEngine",
1683
+ "BackgroundJobsScheduling",
1684
+ "PresentationAdapters",
1685
+ "ReportingReadModels",
1686
+ "ExtensibilityMetadata",
1687
+ "SecurityAuditObservability",
1688
+ "Kernel"
1689
+ ];
1690
+ var DEFAULT_ALLOWED_FLOWS = /* @__PURE__ */ new Set([
1691
+ "PresentationAdapters->ApplicationOrchestration",
1692
+ "ApplicationOrchestration->DomainModel",
1693
+ "WorkflowSagaEngine->ApplicationOrchestration",
1694
+ "WorkflowSagaEngine->DomainModel",
1695
+ "BackgroundJobsScheduling->ApplicationOrchestration"
1696
+ ]);
1697
+ function createDefaultRules() {
1698
+ const rules = [];
1699
+ for (const from of DEFAULT_LAYER_NAMES) {
1700
+ for (const to of DEFAULT_LAYER_NAMES) {
1701
+ if (from === to || DEFAULT_ALLOWED_FLOWS.has(`${from}->${to}`)) continue;
1702
+ rules.push({ from, to, allowed: false });
1703
+ }
1704
+ }
1705
+ return rules;
1706
+ }
1707
+ var DEFAULT_ARK_CONFIG_RULES = createDefaultRules();
1708
+ var stringArraySchema = {
1709
+ type: "array",
1710
+ items: { type: "string", minLength: 1 },
1711
+ uniqueItems: true
1712
+ };
1713
+ var ARK_CONFIG_SCHEMA = {
1714
+ $schema: "https://json-schema.org/draft/2020-12/schema",
1715
+ $id: ARK_CONFIG_SCHEMA_URL,
1716
+ title: "ArkGate architecture contract",
1717
+ description: "Versioned contract consumed identically by ArkGate CLI, MCP, and ESLint surfaces.",
1718
+ type: "object",
1719
+ additionalProperties: false,
1720
+ required: ["$schema", "schemaVersion", "include", "layers", "rules"],
1721
+ properties: {
1722
+ $schema: {
1723
+ type: "string",
1724
+ minLength: 1,
1725
+ default: ARK_CONFIG_SCHEMA_URL,
1726
+ description: "Editor-facing URL or local path for this JSON Schema."
1727
+ },
1728
+ schemaVersion: {
1729
+ type: "string",
1730
+ const: ARK_CONFIG_SCHEMA_VERSION,
1731
+ default: ARK_CONFIG_SCHEMA_VERSION
1732
+ },
1733
+ name: { type: "string", minLength: 1 },
1734
+ include: { ...stringArraySchema, minItems: 1, default: ["src"] },
1735
+ exclude: { ...stringArraySchema, default: [] },
1736
+ excludeGenerated: { type: "boolean", default: true },
1737
+ frameworkOverlay: { type: "string", minLength: 1 },
1738
+ layers: {
1739
+ type: "array",
1740
+ default: [],
1741
+ items: { $ref: "#/$defs/layer" }
1742
+ },
1743
+ rules: {
1744
+ type: "array",
1745
+ default: DEFAULT_ARK_CONFIG_RULES,
1746
+ items: { $ref: "#/$defs/rule" }
1747
+ },
1748
+ cyclePolicy: {
1749
+ type: "string",
1750
+ enum: ["strict", "soft", "framework-soft", "off"],
1751
+ default: "strict"
1752
+ },
1753
+ dynamicImportAllowlist: { ...stringArraySchema, default: [] },
1754
+ safety: {
1755
+ $ref: "#/$defs/safety",
1756
+ default: {
1757
+ maxTsSuppressions: 0,
1758
+ maxAnyCasts: 0,
1759
+ allowInMemory: false,
1760
+ allowDisabledPeerIsolation: false
1761
+ }
1762
+ }
1763
+ },
1764
+ $defs: {
1765
+ layer: {
1766
+ type: "object",
1767
+ additionalProperties: false,
1768
+ required: ["name", "patterns"],
1769
+ properties: {
1770
+ name: { type: "string", minLength: 1 },
1771
+ patterns: { ...stringArraySchema, minItems: 1 },
1772
+ exclude: stringArraySchema,
1773
+ intentPrefixes: stringArraySchema,
1774
+ description: { type: "string", minLength: 1 },
1775
+ forbiddenGlobals: stringArraySchema,
1776
+ mayImportInfrastructure: { type: "boolean" },
1777
+ optional: { type: "boolean" }
1778
+ }
1779
+ },
1780
+ rule: {
1781
+ type: "object",
1782
+ additionalProperties: false,
1783
+ required: ["from", "to", "allowed"],
1784
+ properties: {
1785
+ from: { type: "string", minLength: 1 },
1786
+ to: { type: "string", minLength: 1 },
1787
+ allowed: { type: "boolean" },
1788
+ message: { type: "string", minLength: 1 },
1789
+ peerIsolation: { type: "boolean" },
1790
+ sliceFolders: { ...stringArraySchema, minItems: 1 }
1791
+ }
1792
+ },
1793
+ safety: {
1794
+ type: "object",
1795
+ additionalProperties: false,
1796
+ properties: {
1797
+ maxTsSuppressions: { type: "integer", minimum: 0, default: 0 },
1798
+ maxAnyCasts: { type: "integer", minimum: 0, default: 0 },
1799
+ allowInMemory: { type: "boolean", default: false },
1800
+ allowDisabledPeerIsolation: { type: "boolean", default: false }
1801
+ }
1802
+ }
1803
+ }
1804
+ };
1805
+
1674
1806
  // src/kernel/layers/ArchitectureProfile.ts
1675
1807
  function normalizePrefix(prefix) {
1676
1808
  return prefix.endsWith(".") ? prefix : `${prefix}.`;
@@ -1680,21 +1812,6 @@ function byLongestPrefix(a, b) {
1680
1812
  const maxB = b.prefixes.length ? Math.max(...b.prefixes.map((p) => p.length)) : 0;
1681
1813
  return maxB - maxA;
1682
1814
  }
1683
- function flowKey(from, to) {
1684
- return `${from}->${to}`;
1685
- }
1686
- function createStrictDenyRules(layers, allowedFlows) {
1687
- const allowed = new Set(allowedFlows.map((flow) => flowKey(flow.from, flow.to)));
1688
- const rules = [];
1689
- for (const from of layers) {
1690
- for (const to of layers) {
1691
- if (from.name === to.name) continue;
1692
- if (allowed.has(flowKey(from.name, to.name))) continue;
1693
- rules.push({ from: from.name, to: to.name, allowed: false });
1694
- }
1695
- }
1696
- return rules;
1697
- }
1698
1815
  function createArchitectureProfile(options) {
1699
1816
  const layers = options.layers.map((layer) => ({
1700
1817
  ...layer,
@@ -1781,27 +1898,17 @@ var elevenLayerProfileLayers = [
1781
1898
  order: 11
1782
1899
  }
1783
1900
  ];
1784
- var elevenLayerAllowedFlows = [
1785
- { from: "PresentationAdapters", to: "ApplicationOrchestration" },
1786
- { from: "ApplicationOrchestration", to: "DomainModel" },
1787
- { from: "WorkflowSagaEngine", to: "ApplicationOrchestration" },
1788
- { from: "WorkflowSagaEngine", to: "DomainModel" },
1789
- { from: "BackgroundJobsScheduling", to: "ApplicationOrchestration" }
1790
- ];
1791
1901
  var elevenLayerProfile = createArchitectureProfile({
1792
1902
  name: "Ark 11-layer Hexagonal Event-Driven Profile",
1793
1903
  layers: elevenLayerProfileLayers,
1794
- rules: createStrictDenyRules(
1795
- elevenLayerProfileLayers,
1796
- elevenLayerAllowedFlows
1797
- )
1904
+ rules: DEFAULT_ARK_CONFIG_RULES.map((rule) => ({ ...rule }))
1798
1905
  });
1799
1906
 
1800
1907
  // src/kernel/manifest/constants.ts
1801
1908
  var MANIFEST_SCHEMA_VERSION = "1.0";
1802
1909
 
1803
1910
  // src/version.ts
1804
- var version = "2.11.0";
1911
+ var version = "2.13.0";
1805
1912
 
1806
1913
  // src/kernel/manifest/createArkManifest.ts
1807
1914
  function policyId(name) {
@@ -1937,14 +2044,14 @@ function createMetadataRegistry() {
1937
2044
  }
1938
2045
 
1939
2046
  // src/kernel/observability/ObservabilityReporter.ts
1940
- function flowKey2(flow) {
2047
+ function flowKey(flow) {
1941
2048
  return `${flow.from}->${flow.to}`;
1942
2049
  }
1943
2050
  function uniqueFlows(flows) {
1944
2051
  const seen = /* @__PURE__ */ new Set();
1945
2052
  const result = [];
1946
2053
  for (const flow of flows) {
1947
- const key = flowKey2(flow);
2054
+ const key = flowKey(flow);
1948
2055
  if (seen.has(key)) continue;
1949
2056
  seen.add(key);
1950
2057
  result.push(flow);
@@ -1952,8 +2059,8 @@ function uniqueFlows(flows) {
1952
2059
  return result;
1953
2060
  }
1954
2061
  function difference(left, right) {
1955
- const rightKeys = new Set(right.map(flowKey2));
1956
- return left.filter((flow) => !rightKeys.has(flowKey2(flow)));
2062
+ const rightKeys = new Set(right.map(flowKey));
2063
+ return left.filter((flow) => !rightKeys.has(flowKey(flow)));
1957
2064
  }
1958
2065
  function createObservabilityReporter(options) {
1959
2066
  const registry = options.registry;
@@ -2298,22 +2405,13 @@ var WorkflowEngineImpl = class {
2298
2405
  for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
2299
2406
  snapshot.attempts[step.name] = attempt;
2300
2407
  await this.store.save(snapshot);
2408
+ let result;
2301
2409
  try {
2302
- const result = await withTimeout(
2410
+ result = await withTimeout(
2303
2411
  (signal) => Promise.resolve(step.execute(snapshot.context, this.bus, signal)),
2304
2412
  step.timeoutMs,
2305
2413
  step.name
2306
2414
  );
2307
- if (result) Object.assign(snapshot.context, result);
2308
- snapshot.completedSteps.push(step.name);
2309
- snapshot.currentStep = void 0;
2310
- snapshot.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
2311
- await this.store.save(snapshot);
2312
- await this.audit("workflow.step.completed", snapshot, {
2313
- step: step.name,
2314
- attempt
2315
- });
2316
- return;
2317
2415
  } catch (err) {
2318
2416
  if (attempt < maxAttempts) {
2319
2417
  if (retry.delayMs) await sleep(retry.delayMs);
@@ -2329,6 +2427,16 @@ var WorkflowEngineImpl = class {
2329
2427
  });
2330
2428
  throw err;
2331
2429
  }
2430
+ if (result) Object.assign(snapshot.context, result);
2431
+ snapshot.completedSteps.push(step.name);
2432
+ snapshot.currentStep = void 0;
2433
+ snapshot.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
2434
+ await this.store.save(snapshot);
2435
+ await this.audit("workflow.step.completed", snapshot, {
2436
+ step: step.name,
2437
+ attempt
2438
+ });
2439
+ return;
2332
2440
  }
2333
2441
  throw new Error(`Workflow step "${step.name}" did not complete.`);
2334
2442
  }