@neurcode-ai/cli 0.20.2 → 0.20.3

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 (44) hide show
  1. package/dist/commands/brain.d.ts.map +1 -1
  2. package/dist/commands/brain.js +11 -2
  3. package/dist/commands/brain.js.map +1 -1
  4. package/dist/commands/run.d.ts.map +1 -1
  5. package/dist/commands/run.js +1 -1
  6. package/dist/commands/run.js.map +1 -1
  7. package/dist/commands/session-hook.d.ts +1 -0
  8. package/dist/commands/session-hook.d.ts.map +1 -1
  9. package/dist/commands/session-hook.js +41 -2
  10. package/dist/commands/session-hook.js.map +1 -1
  11. package/dist/commands/verify.d.ts.map +1 -1
  12. package/dist/commands/verify.js +106 -83
  13. package/dist/commands/verify.js.map +1 -1
  14. package/dist/runtime-build.json +4 -4
  15. package/dist/utils/admission-artifact.d.ts.map +1 -1
  16. package/dist/utils/admission-artifact.js +10 -0
  17. package/dist/utils/admission-artifact.js.map +1 -1
  18. package/dist/utils/agent-session-launcher.d.ts +12 -0
  19. package/dist/utils/agent-session-launcher.d.ts.map +1 -1
  20. package/dist/utils/agent-session-launcher.js +74 -22
  21. package/dist/utils/agent-session-launcher.js.map +1 -1
  22. package/dist/utils/atomic-runtime-bootstrap.d.ts +24 -0
  23. package/dist/utils/atomic-runtime-bootstrap.d.ts.map +1 -0
  24. package/dist/utils/atomic-runtime-bootstrap.js +115 -0
  25. package/dist/utils/atomic-runtime-bootstrap.js.map +1 -0
  26. package/dist/utils/brain-lifecycle.d.ts.map +1 -1
  27. package/dist/utils/brain-lifecycle.js +14 -3
  28. package/dist/utils/brain-lifecycle.js.map +1 -1
  29. package/dist/utils/gitignore.d.ts +12 -3
  30. package/dist/utils/gitignore.d.ts.map +1 -1
  31. package/dist/utils/gitignore.js +59 -22
  32. package/dist/utils/gitignore.js.map +1 -1
  33. package/dist/utils/replay-runtime.d.ts.map +1 -1
  34. package/dist/utils/replay-runtime.js +0 -1
  35. package/dist/utils/replay-runtime.js.map +1 -1
  36. package/dist/utils/repo-brain-impact.d.ts +10 -0
  37. package/dist/utils/repo-brain-impact.d.ts.map +1 -1
  38. package/dist/utils/repo-brain-impact.js +44 -0
  39. package/dist/utils/repo-brain-impact.js.map +1 -1
  40. package/dist/utils/repo-intelligence-v2.d.ts.map +1 -1
  41. package/dist/utils/repo-intelligence-v2.js +5 -0
  42. package/dist/utils/repo-intelligence-v2.js.map +1 -1
  43. package/package.json +11 -10
  44. package/LICENSE +0 -201
@@ -1047,6 +1047,9 @@ async function executePolicyOnlyMode(options, diffFiles, ignoreFilter, projectRo
1047
1047
  console.log(chalk.cyan('🛡️ General Governance mode (policy only, no plan linked)\n'));
1048
1048
  }
1049
1049
  const diffFilesForPolicy = diffFiles.filter((f) => !ignoreFilter(f.path));
1050
+ const governanceArtifactOnlyDiff = diffFilesForPolicy.length > 0
1051
+ && diffFilesForPolicy.every((file) => (file.path.startsWith('neurcode.')
1052
+ || file.path.startsWith('.neurcode/')));
1050
1053
  const expectedPolicyOnlyFiles = diffFilesForPolicy.map((file) => file.path);
1051
1054
  const signedLogsRequired = isSignedAiLogsRequired(orgGovernanceSettings);
1052
1055
  const activeEngineeringContext = (0, active_engineering_context_1.loadActiveEngineeringContext)(projectRoot);
@@ -1484,7 +1487,14 @@ async function executePolicyOnlyMode(options, diffFiles, ignoreFilter, projectRo
1484
1487
  // a policy rule, but it cannot turn an unevaluated file into verified evidence.
1485
1488
  policyViolations.push(...coverageViolations);
1486
1489
  policyDecision = (0, policy_decision_1.resolvePolicyDecisionFromViolations)(policyViolations);
1487
- const effectiveVerdict = policyDecision === 'block' || structuralBlockingCount > 0 || coverageIncomplete || coverageNotEvaluated
1490
+ const hasExplicitDiffContext = options.head === true || Boolean(options.base) || options.staged === true;
1491
+ const unevaluatedOnly = hasExplicitDiffContext
1492
+ && coverageNotEvaluated
1493
+ && policyOnlyStructural.filesRequested > 0
1494
+ && policyOnlyStructural.filesAnalyzed === 0
1495
+ && suppressedViolations.length === 0
1496
+ && !governanceArtifactOnlyDiff;
1497
+ const effectiveVerdict = policyDecision === 'block' || structuralBlockingCount > 0 || coverageIncomplete || unevaluatedOnly
1488
1498
  ? 'FAIL'
1489
1499
  : policyDecision === 'warn' || structuralAdvisoryCount > 0
1490
1500
  ? 'WARN'
@@ -1706,8 +1716,9 @@ async function executePolicyOnlyMode(options, diffFiles, ignoreFilter, projectRo
1706
1716
  jsonMode: Boolean(options.json),
1707
1717
  governance: governancePayload,
1708
1718
  });
1709
- if (coverageNotEvaluated && policyDecision !== 'block' && structuralBlockingCount === 0)
1719
+ if (unevaluatedOnly) {
1710
1720
  return 3;
1721
+ }
1711
1722
  return effectiveVerdict === 'FAIL' ? 2 : effectiveVerdict === 'WARN' ? 1 : 0;
1712
1723
  }
1713
1724
  async function verifyCommand(options) {
@@ -2430,59 +2441,65 @@ async function verifyCommand(options) {
2430
2441
  }
2431
2442
  const untrackedDiffFiles = includeUntracked ? getUntrackedDiffFiles(projectRoot) : [];
2432
2443
  if (!diffText.trim() && untrackedDiffFiles.length === 0) {
2433
- if (!options.json) {
2434
- console.log(chalk.yellow('⚠️ Verification not evaluated: no files in the selected diff context.'));
2435
- console.log(chalk.dim(` Selected context: ${diffContextLabel || 'unresolved'}. No PASS was produced.`));
2436
- }
2437
- else {
2438
- // Surface runtime capabilities even on the empty-diff path so
2439
- // CI gates that assert `runtimeCapabilities.intentRuntime` etc.
2440
- // never receive a payload that omits the envelope. The intent
2441
- // runtime is reported as `inactive` here regardless of whether
2442
- // an intent-pack exists — there are no findings to govern.
2443
- emitVerifyJson({
2444
- grade: 'F',
2445
- score: 0,
2446
- verdict: 'FAIL',
2447
- violations: [],
2448
- adherenceScore: 0,
2449
- bloatCount: 0,
2450
- bloatFiles: [],
2451
- plannedFilesModified: 0,
2452
- totalPlannedFiles: 0,
2453
- message: 'Verification not evaluated: no files in the selected diff context.',
2454
- evaluationStatus: 'not_evaluated',
2455
- verificationCoverage: {
2456
- posture: 'not_evaluated',
2457
- context: diffContextLabel,
2458
- filesRequested: 0,
2459
- filesAnalyzed: 0,
2460
- filesSkipped: 0,
2461
- filesUnsupported: 0,
2462
- },
2463
- scopeGuardPassed: false,
2464
- runtimeCapabilities: {
2465
- schemaVersion: 'neurcode.runtime-capabilities.v1',
2466
- executionPath: localOnlyMode ? 'local-only' : 'unresolved',
2467
- intentRuntime: 'inactive',
2468
- intentContractSource: 'none',
2469
- intentRuntimeRequired: options.requireIntentRuntime === true || isEnabledFlag(process.env.NEURCODE_REQUIRE_INTENT_RUNTIME),
2470
- intentRuntimeRequirementSatisfied: true,
2471
- driftIntelligence: 'inactive',
2472
- scopeGuard: 'unenforced',
2473
- forbiddenBoundaryEnforcement: 'unenforced',
2474
- generatedCodeGovernance: 'pattern-deterministic',
2475
- structuralRules: 'inactive',
2476
- replayDeterminism: 'enforced',
2477
- apiContractStatus: localOnlyMode ? 'offline' : 'unresolved',
2478
- observedScopeCategories: [],
2479
- observedBoundaryTypes: [],
2480
- noChangesDetected: true,
2481
- },
2482
- });
2444
+ const allowPolicyOnlyWithoutDiff = options.policyOnly === true
2445
+ && options.head !== true
2446
+ && !options.base
2447
+ && options.staged !== true;
2448
+ if (!allowPolicyOnlyWithoutDiff) {
2449
+ if (!options.json) {
2450
+ console.log(chalk.yellow('⚠️ Verification not evaluated: no files in the selected diff context.'));
2451
+ console.log(chalk.dim(` Selected context: ${diffContextLabel || 'unresolved'}. No PASS was produced.`));
2452
+ }
2453
+ else {
2454
+ // Surface runtime capabilities even on the empty-diff path so
2455
+ // CI gates that assert `runtimeCapabilities.intentRuntime` etc.
2456
+ // never receive a payload that omits the envelope. The intent
2457
+ // runtime is reported as `inactive` here regardless of whether
2458
+ // an intent-pack exists — there are no findings to govern.
2459
+ emitVerifyJson({
2460
+ grade: 'F',
2461
+ score: 0,
2462
+ verdict: 'FAIL',
2463
+ violations: [],
2464
+ adherenceScore: 0,
2465
+ bloatCount: 0,
2466
+ bloatFiles: [],
2467
+ plannedFilesModified: 0,
2468
+ totalPlannedFiles: 0,
2469
+ message: 'Verification not evaluated: no files in the selected diff context.',
2470
+ evaluationStatus: 'not_evaluated',
2471
+ verificationCoverage: {
2472
+ posture: 'not_evaluated',
2473
+ context: diffContextLabel,
2474
+ filesRequested: 0,
2475
+ filesAnalyzed: 0,
2476
+ filesSkipped: 0,
2477
+ filesUnsupported: 0,
2478
+ },
2479
+ scopeGuardPassed: false,
2480
+ runtimeCapabilities: {
2481
+ schemaVersion: 'neurcode.runtime-capabilities.v1',
2482
+ executionPath: localOnlyMode ? 'local-only' : 'unresolved',
2483
+ intentRuntime: 'inactive',
2484
+ intentContractSource: 'none',
2485
+ intentRuntimeRequired: options.requireIntentRuntime === true || isEnabledFlag(process.env.NEURCODE_REQUIRE_INTENT_RUNTIME),
2486
+ intentRuntimeRequirementSatisfied: true,
2487
+ driftIntelligence: 'inactive',
2488
+ scopeGuard: 'unenforced',
2489
+ forbiddenBoundaryEnforcement: 'unenforced',
2490
+ generatedCodeGovernance: 'pattern-deterministic',
2491
+ structuralRules: 'inactive',
2492
+ replayDeterminism: 'enforced',
2493
+ apiContractStatus: localOnlyMode ? 'offline' : 'unresolved',
2494
+ observedScopeCategories: [],
2495
+ observedBoundaryTypes: [],
2496
+ noChangesDetected: true,
2497
+ },
2498
+ });
2499
+ }
2500
+ recordVerifyEvent('NO_CHANGES', 'diff=empty');
2501
+ exitWithEvidence(3);
2483
2502
  }
2484
- recordVerifyEvent('NO_CHANGES', 'diff=empty');
2485
- exitWithEvidence(3);
2486
2503
  }
2487
2504
  // Parse tracked/staged diff and merge untracked files so plan adherence
2488
2505
  // correctly counts newly created files before they are git-added.
@@ -2965,36 +2982,42 @@ async function verifyCommand(options) {
2965
2982
  }
2966
2983
  const summary = (0, diff_parser_1.getDiffSummary)(diffFiles);
2967
2984
  if (diffFiles.length === 0) {
2968
- if (!options.json) {
2969
- console.log(chalk.yellow('⚠️ Verification not evaluated: all files in the selected diff context were excluded.'));
2970
- console.log(chalk.dim(' No PASS was produced. Review ignore rules or select a different diff context.'));
2971
- }
2972
- else {
2973
- emitVerifyJson({
2974
- grade: 'F',
2975
- score: 0,
2976
- verdict: 'FAIL',
2977
- violations: [],
2978
- adherenceScore: 0,
2979
- bloatCount: 0,
2980
- bloatFiles: [],
2981
- plannedFilesModified: 0,
2982
- totalPlannedFiles: 0,
2983
- message: 'Verification not evaluated: all files in the selected diff context were excluded.',
2984
- evaluationStatus: 'not_evaluated',
2985
- verificationCoverage: {
2986
- posture: 'not_evaluated',
2987
- context: diffContextLabel,
2988
- filesRequested: allDiffFiles.length,
2989
- filesAnalyzed: 0,
2990
- filesSkipped: allDiffFiles.length,
2991
- filesUnsupported: 0,
2992
- },
2993
- scopeGuardPassed: false,
2994
- });
2985
+ const allowPolicyOnlyWithoutDiff = options.policyOnly === true
2986
+ && options.head !== true
2987
+ && !options.base
2988
+ && options.staged !== true;
2989
+ if (!allowPolicyOnlyWithoutDiff) {
2990
+ if (!options.json) {
2991
+ console.log(chalk.yellow('⚠️ Verification not evaluated: all files in the selected diff context were excluded.'));
2992
+ console.log(chalk.dim(' No PASS was produced. Review ignore rules or select a different diff context.'));
2993
+ }
2994
+ else {
2995
+ emitVerifyJson({
2996
+ grade: 'F',
2997
+ score: 0,
2998
+ verdict: 'FAIL',
2999
+ violations: [],
3000
+ adherenceScore: 0,
3001
+ bloatCount: 0,
3002
+ bloatFiles: [],
3003
+ plannedFilesModified: 0,
3004
+ totalPlannedFiles: 0,
3005
+ message: 'Verification not evaluated: all files in the selected diff context were excluded.',
3006
+ evaluationStatus: 'not_evaluated',
3007
+ verificationCoverage: {
3008
+ posture: 'not_evaluated',
3009
+ context: diffContextLabel,
3010
+ filesRequested: allDiffFiles.length,
3011
+ filesAnalyzed: 0,
3012
+ filesSkipped: allDiffFiles.length,
3013
+ filesUnsupported: 0,
3014
+ },
3015
+ scopeGuardPassed: false,
3016
+ });
3017
+ }
3018
+ recordVerifyEvent('NO_CHANGES', 'diff_files=0;status=not_evaluated');
3019
+ exitWithEvidence(3);
2995
3020
  }
2996
- recordVerifyEvent('NO_CHANGES', 'diff_files=0;status=not_evaluated');
2997
- exitWithEvidence(3);
2998
3021
  }
2999
3022
  const ignoreFilter = (0, ignore_1.loadIgnore)(projectRoot);
3000
3023
  const runtimeIgnoreSet = getRuntimeIgnoreSetFromEnv();