@ngockhoale/ukit 2.4.1 → 2.4.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 (56) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/manifests/platform.full.yaml +19 -111
  3. package/package.json +2 -1
  4. package/scripts/index/refresh-index.mjs +48 -18
  5. package/src/cli/commands/doctor.js +59 -2
  6. package/src/core/compact/threshold.js +36 -6
  7. package/src/core/gatewayProbe.js +143 -15
  8. package/src/core/gatewayResilienceEnv.js +136 -7
  9. package/src/diagnostics/classifyHang.js +246 -0
  10. package/src/index/buildIndex.js +1096 -75
  11. package/templates/.claude/hooks/auto-allow-bash.sh +99 -87
  12. package/templates/.claude/hooks/auto-prune-bash.sh +4 -0
  13. package/templates/.claude/hooks/block-dangerous.sh +46 -1
  14. package/templates/.claude/hooks/completion-gate.sh +65 -7
  15. package/templates/.claude/hooks/compress-output.sh +49 -2
  16. package/templates/.claude/hooks/context-hardcap-gate.sh +52 -4
  17. package/templates/.claude/hooks/context-window-guard.sh +204 -71
  18. package/templates/.claude/hooks/handoff-model-guard.sh +50 -3
  19. package/templates/.claude/hooks/handoff-resume.sh +47 -3
  20. package/templates/.claude/hooks/post-edit-verify.sh +45 -2
  21. package/templates/.claude/hooks/pre-edit-backup.sh +45 -2
  22. package/templates/.claude/hooks/protect-files.sh +46 -1
  23. package/templates/.claude/hooks/record-execution.sh +46 -2
  24. package/templates/.claude/hooks/reinject-context.sh +1 -1
  25. package/templates/.claude/hooks/reset-compact-pressure.sh +4 -0
  26. package/templates/.claude/hooks/sensitive-data-guard.sh +101 -18
  27. package/templates/.claude/hooks/skill-router.sh +59 -5
  28. package/templates/.claude/hooks/stale-spec-guard.sh +47 -2
  29. package/templates/.claude/hooks/task-watchdog.sh +129 -126
  30. package/templates/.claude/hooks/verification-guard.sh +136 -106
  31. package/templates/.claude/hooks/vision-router.sh +138 -18
  32. package/templates/.claude/settings.json +0 -5
  33. package/templates/.claude/ukit/index/lib/index-core.mjs +1027 -68
  34. package/templates/.claude/ukit/index/post-edit-verify.mjs +8 -0
  35. package/templates/.claude/ukit/index/pre-edit-backup.mjs +8 -0
  36. package/templates/.claude/ukit/index/refresh-index.mjs +48 -18
  37. package/templates/.claude/ukit/index/route-task.mjs +610 -4
  38. package/templates/.claude/ukit/index/stale-spec-check.mjs +8 -0
  39. package/templates/.claude/ukit/runtime/async-lock.mjs +340 -0
  40. package/templates/.claude/ukit/runtime/compact-threshold.mjs +73 -24
  41. package/templates/.claude/ukit/runtime/context-capacity.mjs +144 -0
  42. package/templates/.claude/ukit/runtime/execution-ledger.mjs +672 -170
  43. package/templates/.claude/ukit/runtime/hook-chain-budget.mjs +92 -0
  44. package/templates/.claude/ukit/runtime/hook-chain-runner.mjs +84 -29
  45. package/templates/.claude/ukit/runtime/hook-input.mjs +120 -0
  46. package/templates/.claude/ukit/runtime/hook-input.sh +140 -0
  47. package/templates/.claude/ukit/runtime/hook-payload-store.mjs +160 -0
  48. package/templates/.claude/ukit/runtime/hook-process.mjs +250 -0
  49. package/templates/.claude/ukit/runtime/hook-telemetry.mjs +255 -0
  50. package/templates/.claude/ukit/runtime/hook-telemetry.sh +60 -0
  51. package/templates/.claude/ukit/runtime/output-compression.mjs +8 -0
  52. package/templates/.claude/ukit/runtime/reinject-context.mjs +8 -0
  53. package/templates/.claude/ukit/runtime/stop-coordinator.mjs +509 -0
  54. package/templates/.claude/ukit/runtime/task-watchdog.mjs +180 -6
  55. package/templates/.claude/ukit/runtime/transcript-tail.mjs +107 -0
  56. package/templates/.omp/hooks/pre/ukit-bridge.js +171 -57
@@ -4,6 +4,14 @@ import { fileURLToPath } from 'node:url';
4
4
  import { analyzeTextBuffer, analyzeTextFile, publicTextProfile } from '../runtime/text-profile.mjs';
5
5
  import { classifySafePatchRisk, isSafePatchAdvisoryOnly, parseJsonInput, pathExists, readRuntimeSafePatchConfig, resolveProjectFile } from '../runtime/safe-patch-core.mjs';
6
6
 
7
+ // Hook-context self-deadline (2.4.1 orphan-leak class): the post-edit-verify hook passes
8
+ // UKIT_HOOK_DEADLINE_MS so a wedged read can never orphan this process past the hook
9
+ // budget. Non-hook usage never sets it and is never self-killed.
10
+ const HOOK_DEADLINE_MS = Number.parseInt(process.env.UKIT_HOOK_DEADLINE_MS || '', 10);
11
+ if (Number.isFinite(HOOK_DEADLINE_MS) && HOOK_DEADLINE_MS > 0) {
12
+ setTimeout(() => process.exit(0), HOOK_DEADLINE_MS).unref();
13
+ }
14
+
7
15
  async function readStdin() {
8
16
  return await new Promise((resolve) => {
9
17
  let raw = '';
@@ -4,6 +4,14 @@ import { analyzeTextFile, publicTextProfile } from '../runtime/text-profile.mjs'
4
4
  import { classifySafePatchRisk, parseJsonInput, pathExists, readRuntimeSafePatchConfig, resolveProjectFile } from '../runtime/safe-patch-core.mjs';
5
5
  import { fileURLToPath } from 'node:url';
6
6
 
7
+ // Hook-context self-deadline (2.4.1 orphan-leak class): the pre-edit-backup hook passes
8
+ // UKIT_HOOK_DEADLINE_MS so a wedged read can never orphan this process past the hook
9
+ // budget. Non-hook usage never sets it and is never self-killed.
10
+ const HOOK_DEADLINE_MS = Number.parseInt(process.env.UKIT_HOOK_DEADLINE_MS || '', 10);
11
+ if (Number.isFinite(HOOK_DEADLINE_MS) && HOOK_DEADLINE_MS > 0) {
12
+ setTimeout(() => process.exit(0), HOOK_DEADLINE_MS).unref();
13
+ }
14
+
7
15
  async function readStdin() {
8
16
  return await new Promise((resolve) => {
9
17
  let raw = '';
@@ -2,7 +2,7 @@
2
2
  import path from 'node:path';
3
3
  import {
4
4
  buildCodeIndex,
5
- isIndexStale,
5
+ inspectIndexStaleness,
6
6
  DEFAULT_INDEX_CACHE_MAX_AGE_MS,
7
7
  getIndexArtifactGeneratedAt,
8
8
  } from './lib/index-core.mjs';
@@ -14,34 +14,64 @@ const changedFiles = changedArg ? changedArg.split(',').map((x) => x.trim()).fil
14
14
  const force = args.includes('--force');
15
15
 
16
16
  const lastRefreshMs = await getIndexArtifactGeneratedAt({ rootDir });
17
- const stale = force
18
- ? true
19
- : await isIndexStale({ rootDir, maxAgeMs: DEFAULT_INDEX_CACHE_MAX_AGE_MS, generatedAtMs: lastRefreshMs });
20
17
 
21
- if (!stale) {
22
- console.log('[ukit:index:refresh] skipped (cache fresh)');
23
- if (lastRefreshMs !== null) {
24
- console.log(`lastRefresh: ${new Date(lastRefreshMs).toISOString()}`);
25
- }
26
- if (changedFiles.length > 0) {
27
- console.log(`changed-files-hint: ${changedFiles.join(', ')}`);
28
- }
29
- console.log(`root: ${rootDir}`);
30
- } else {
31
- const summary = await buildCodeIndex({ rootDir });
18
+ if (changedFiles.length > 0 && !force) {
19
+ // Hints carry the change set, so no staleness enumeration is needed:
20
+ // buildCodeIndex merges the hinted paths into the existing artifacts and
21
+ // falls back to the bounded full discovery path on its own when the hints
22
+ // are unsafe or the previous artifacts cannot be merged (TASK-023).
23
+ const summary = await buildCodeIndex({ rootDir, changedFiles });
32
24
 
33
25
  console.log('[ukit:index:refresh] completed');
26
+ console.log(`mode: ${summary.mode}`);
34
27
  if (lastRefreshMs !== null) {
35
28
  console.log(`lastRefreshBefore: ${new Date(lastRefreshMs).toISOString()}`);
36
29
  }
37
- if (changedFiles.length > 0) {
38
- console.log(`changed-files-hint: ${changedFiles.join(', ')}`);
39
- }
30
+ console.log(`changed-files-hint: ${changedFiles.join(', ')}`);
40
31
  console.log(`root: ${rootDir}`);
41
32
  console.log(`files: ${summary.fileCount}`);
42
33
  console.log(`parsed: ${summary.parsedCodeFileCount}`);
43
34
  console.log(`reused: ${summary.reusedCodeFileCount}`);
35
+ if (summary.removedFiles.length > 0) {
36
+ console.log(`removed: ${summary.removedFiles.length}`);
37
+ }
44
38
  console.log(`indexDir: ${summary.indexDir}`);
39
+ } else {
40
+ const staleness = force
41
+ ? null
42
+ : await inspectIndexStaleness({ rootDir, maxAgeMs: DEFAULT_INDEX_CACHE_MAX_AGE_MS, generatedAtMs: lastRefreshMs });
43
+ const stale = force || staleness.stale;
44
+
45
+ if (!stale) {
46
+ console.log('[ukit:index:refresh] skipped (cache fresh)');
47
+ if (lastRefreshMs !== null) {
48
+ console.log(`lastRefresh: ${new Date(lastRefreshMs).toISOString()}`);
49
+ }
50
+ if (changedFiles.length > 0) {
51
+ console.log(`changed-files-hint: ${changedFiles.join(', ')}`);
52
+ }
53
+ console.log(`root: ${rootDir}`);
54
+ } else {
55
+ // Reuse the staleness check's discovery snapshot: one enumeration per refresh.
56
+ const summary = await buildCodeIndex({
57
+ rootDir,
58
+ discoverySnapshot: staleness ? staleness.snapshot : null,
59
+ });
60
+
61
+ console.log('[ukit:index:refresh] completed');
62
+ console.log(`mode: ${summary.mode}`);
63
+ if (lastRefreshMs !== null) {
64
+ console.log(`lastRefreshBefore: ${new Date(lastRefreshMs).toISOString()}`);
65
+ }
66
+ if (changedFiles.length > 0) {
67
+ console.log(`changed-files-hint: ${changedFiles.join(', ')}`);
68
+ }
69
+ console.log(`root: ${rootDir}`);
70
+ console.log(`files: ${summary.fileCount}`);
71
+ console.log(`parsed: ${summary.parsedCodeFileCount}`);
72
+ console.log(`reused: ${summary.reusedCodeFileCount}`);
73
+ console.log(`indexDir: ${summary.indexDir}`);
74
+ }
45
75
  }
46
76
 
47
77
  function getRootDir(argv) {