@ngockhoale/ukit 3.4.74 → 3.4.76

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 (30) hide show
  1. package/CHANGELOG.md +110 -95
  2. package/manifests/platform.full.yaml +15 -0
  3. package/package.json +14 -4
  4. package/src/cli/commands/markerStore.js +15 -0
  5. package/src/cli/index.js +7 -0
  6. package/src/core/markerStoreMigration.js +122 -0
  7. package/template_project/.claude/hooks/completion-gate.sh +10 -1
  8. package/template_project/.claude/hooks/handoff-resume.sh +9 -0
  9. package/template_project/.claude/hooks/owner-stop-gate.mjs +41 -0
  10. package/template_project/.claude/hooks/skill-router.sh +262 -28
  11. package/template_project/.claude/settings.json +11 -1
  12. package/template_project/.claude/ukit/index/publication-intent.mjs +144 -18
  13. package/template_project/.claude/ukit/index/route-task.mjs +91 -9
  14. package/template_project/.claude/ukit/runtime/cron-operation-adapter.mjs +11 -4
  15. package/template_project/.claude/ukit/runtime/execution-ledger.mjs +369 -29
  16. package/template_project/.claude/ukit/runtime/operation-evidence.mjs +9 -0
  17. package/template_project/.claude/ukit/runtime/resumable-run.mjs +33 -11
  18. package/template_project/.claude/ukit/runtime/stop-coordinator.mjs +161 -32
  19. package/template_project/.omp/hooks/pre/ukit-bridge.js +552 -4
  20. package/scripts/bug/triage.mjs +0 -76
  21. package/scripts/dev/worktree-preflight.mjs +0 -166
  22. package/scripts/docs/render-instructions.mjs +0 -66
  23. package/scripts/index/build-index.mjs +0 -102
  24. package/scripts/index/query-index.mjs +0 -128
  25. package/scripts/index/refresh-index.mjs +0 -195
  26. package/scripts/install/sync-installed-mirror.mjs +0 -263
  27. package/scripts/measure-decision-gateway.mjs +0 -306
  28. package/scripts/probe/codex-capability-probe.mjs +0 -169
  29. package/scripts/skill/audit-skill.mjs +0 -68
  30. package/scripts/test/run-handoff-isolated.mjs +0 -178
@@ -1,178 +0,0 @@
1
- #!/usr/bin/env node
2
- // Runs the handoff test lane in a disposable copy of the project so `ukit install`
3
- // (which writes .claude/, .ukit/, .cache/) can never overwrite the source checkout.
4
- // The child's native exit code is propagated; the copy is removed in every case.
5
- import { spawnSync } from 'node:child_process';
6
- import { constants, cpSync, existsSync, lstatSync, mkdtempSync, readdirSync, readlinkSync, realpathSync, rmSync } from 'node:fs';
7
- import { buildIsolatedEnv } from '../../tests/helpers/testHomeIsolation.mjs';
8
- import os from 'node:os';
9
- import path from 'node:path';
10
-
11
- // Project root is the directory the runner was invoked from (package.json scripts run at the root).
12
- const sourceRoot = path.resolve(process.cwd());
13
- const SKIP_TOP_LEVEL = new Set(['.git', 'node_modules']);
14
- // Live handoff run/backlog state and runtime caches must never leak into the fixture: a copied
15
- // RUN.md or queue makes the handoff gates act on the real project's pending work.
16
- const LIVE_STATE_PREFIXES = [
17
- 'docs/AI_HANDOFF/RUN.md',
18
- 'docs/AI_HANDOFF/INDEX.md',
19
- 'docs/AI_HANDOFF/ACTIVE.md',
20
- 'docs/AI_HANDOFF/HISTORY.md',
21
- 'docs/AI_HANDOFF/tasks',
22
- 'docs/AI_HANDOFF/queued',
23
- 'docs/AI_HANDOFF/archive',
24
- 'docs/AI_HANDOFF/ARCHIVE',
25
- 'docs/AI_HANDOFF/blocked-tests',
26
- 'docs/AI_HANDOFF/benchmark',
27
- '.ukit/storage/cache',
28
- '.ukit/storage/security',
29
- '.ukit/storage/runs',
30
- ];
31
- const unsafeSymlinks = [];
32
-
33
- function shouldCopy(src) {
34
- const rel = path.relative(sourceRoot, src);
35
- if (rel === '') return true;
36
- const top = rel.split(path.sep)[0];
37
- if (SKIP_TOP_LEVEL.has(top)) return false;
38
- // Nested worktrees would recursively copy the whole repo again.
39
- if (rel.split(path.sep).slice(0, 2).join('/') === '.claude/worktrees') return false;
40
- const posixRel = rel.split(path.sep).join('/');
41
- // Case-insensitive: ARCHIVE/archive are the same directory on macOS/Windows.
42
- const lower = posixRel.toLowerCase();
43
- if (LIVE_STATE_PREFIXES.some((p) => lower === p.toLowerCase() || lower.startsWith(`${p.toLowerCase()}/`))) return false;
44
- // A symlink must stay inside the tree; otherwise the copy would write through to the owner.
45
- if (lstatSync(src).isSymbolicLink()) {
46
- const target = readlinkSync(src);
47
- const resolved = path.resolve(path.dirname(src), target);
48
- const inside = path.relative(sourceRoot, resolved);
49
- if (path.isAbsolute(target) || inside.startsWith('..') || path.isAbsolute(inside)) {
50
- unsafeSymlinks.push(posixRel);
51
- return false;
52
- }
53
- }
54
- if (LIVE_STATE_PREFIXES.some((p) => posixRel === p || posixRel.startsWith(`${p}/`))) return false;
55
- return true;
56
- }
57
-
58
- let childEnv = process.env;
59
- // Hard bound for every child (git, install, the node:test run) so a hung test cannot stall a release.
60
- const CHILD_TIMEOUT_MS = 20 * 60 * 1000;
61
-
62
- function run(cwd, command, args) {
63
- const result = spawnSync(command, args, { cwd, stdio: 'inherit', env: childEnv, timeout: CHILD_TIMEOUT_MS });
64
- if (result.error) {
65
- console.error(`[handoff-isolated] failed to start ${command}: ${result.error.message}`);
66
- return 1;
67
- }
68
- if (result.signal) {
69
- console.error(`[handoff-isolated] ${command} killed by signal ${result.signal}`);
70
- return 1;
71
- }
72
- return result.status ?? 1;
73
- }
74
-
75
- function main() {
76
- const copyRoot = mkdtempSync(path.join(os.tmpdir(), 'ukit-handoff-isolated-'));
77
- console.log(`[handoff-isolated] copy=${copyRoot}`);
78
- // Throwaway HOME so install/tests never touch the caller's real user layer.
79
- const homeRoot = mkdtempSync(path.join(os.tmpdir(), 'ukit-handoff-home-'));
80
- childEnv = { ...process.env, ...buildIsolatedEnv(homeRoot) };
81
- let exitCode = 1;
82
- try {
83
- cpSync(sourceRoot, copyRoot, { recursive: true, filter: shouldCopy, verbatimSymlinks: true });
84
- if (unsafeSymlinks.length > 0) {
85
- console.error(`[handoff-isolated] unsafe source symlink (resolves outside the project): ${unsafeSymlinks.join(', ')}`);
86
- return;
87
- }
88
-
89
- // Several handoff tests call git (worktree add, ls-files, check-ignore). The copy has no
90
- // .git, so give it an isolated throwaway repo with the copied tree committed.
91
- for (const gitArgs of [
92
- ['init', '-q'],
93
- ['add', '-A'],
94
- ['-c', 'user.email=isolated@ukit.test', '-c', 'user.name=isolated', 'commit', '-q', '-m', 'isolated snapshot'],
95
- ]) {
96
- const code = run(copyRoot, 'git', gitArgs);
97
- if (code !== 0) {
98
- console.error(`[handoff-isolated] git snapshot setup failed (git ${gitArgs.find((a) => !a.startsWith('-') && !a.includes('=')) ?? gitArgs[0]} exit ${code})`);
99
- exitCode = code;
100
- return;
101
- }
102
- }
103
-
104
- // Dependencies are cloned (copy-on-write where supported) AFTER the snapshot commit so tool
105
- // caches written under node_modules can never write through to the source checkout.
106
- // UKIT_HANDOFF_DEPS_ROOT lets a worktree without node_modules borrow an installed checkout's.
107
- const depsRoot = path.resolve(process.env.UKIT_HANDOFF_DEPS_ROOT || sourceRoot);
108
- const sourceModules = path.join(depsRoot, 'node_modules');
109
- const copyModules = path.join(copyRoot, 'node_modules');
110
- if (existsSync(sourceModules) && !existsSync(copyModules)) {
111
- // Vet dependency symlinks too: one that resolves outside node_modules (for example a link
112
- // back to the source checkout) would let the copy write through to the owner's tree.
113
- const realModules = realpathSync(sourceModules);
114
- cpSync(sourceModules, copyModules, {
115
- recursive: true,
116
- verbatimSymlinks: true,
117
- mode: constants.COPYFILE_FICLONE,
118
- filter: (src) => {
119
- if (!lstatSync(src).isSymbolicLink()) return true;
120
- const resolved = path.resolve(path.dirname(src), readlinkSync(src));
121
- const rel = path.relative(realModules, resolved);
122
- return !path.isAbsolute(readlinkSync(src)) && !rel.startsWith('..') && !path.isAbsolute(rel);
123
- },
124
- });
125
- }
126
-
127
- const installCode = run(copyRoot, process.execPath, [path.join(copyRoot, 'bin', 'ukit'), 'install']);
128
- if (installCode !== 0) {
129
- console.error(`[handoff-isolated] install failed with exit ${installCode}`);
130
- exitCode = installCode;
131
- } else {
132
- // Optional targeted mode: positional args are handoff test files relative to the project root.
133
- const handoffRoot = path.join(copyRoot, 'tests', 'handoff');
134
- const targeted = [];
135
- for (const rel of process.argv.slice(2)) {
136
- const full = path.resolve(copyRoot, rel);
137
- const within = path.relative(handoffRoot, full);
138
- if (within === '' || within.startsWith('..') || path.isAbsolute(within) || path.isAbsolute(rel)) {
139
- console.error(`[handoff-isolated] invalid handoff test path: ${rel}`);
140
- exitCode = 2;
141
- return;
142
- }
143
- targeted.push(full);
144
- }
145
- const testFiles = [];
146
- const testDir = path.join(copyRoot, 'tests', 'handoff');
147
- if (targeted.length > 0) testFiles.push(...targeted);
148
- else if (existsSync(testDir)) collectTests(testDir, testFiles);
149
- if (testFiles.length === 0) {
150
- console.error('[handoff-isolated] no handoff test files found');
151
- exitCode = 1;
152
- } else {
153
- exitCode = run(copyRoot, process.execPath, ['--test', '--test-concurrency=1', ...testFiles]);
154
- }
155
- }
156
- } finally {
157
- // Diagnostic escape hatch: keep the copy for inspection when explicitly requested.
158
- if (process.env.UKIT_HANDOFF_KEEP_COPY === '1') {
159
- console.log(`[handoff-isolated] keeping copy for inspection: ${copyRoot}`);
160
- } else try {
161
- rmSync(copyRoot, { recursive: true, force: true });
162
- } catch (error) {
163
- console.error(`[handoff-isolated] cleanup failed for ${copyRoot}: ${error.message}`);
164
- }
165
- try { rmSync(homeRoot, { recursive: true, force: true }); } catch {}
166
- process.exitCode = exitCode;
167
- }
168
- }
169
-
170
- function collectTests(dir, out) {
171
- for (const entry of readdirSync(dir, { withFileTypes: true })) {
172
- const full = path.join(dir, entry.name);
173
- if (entry.isDirectory()) collectTests(full, out);
174
- else if (/\.test\.(mjs|js)$/.test(entry.name)) out.push(full);
175
- }
176
- }
177
-
178
- main();