kenaz 0.3.2 → 0.3.5

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 (71) hide show
  1. package/core/.claude/commands/Ansuz.md +36 -35
  2. package/core/.claude/hooks/__tests__/task-2395-project-registration.test.js +84 -0
  3. package/core/.claude/hooks/_ansuz-conversation.js +1 -0
  4. package/core/.claude/hooks/_ansuz-conversation.test.js +6 -0
  5. package/core/.claude/hooks/_run-user-prompt.js +0 -4
  6. package/core/.claude/hooks/_run-user-prompt.test.js +2 -3
  7. package/core/.claude/hooks/handoff-staleness.js +2 -2
  8. package/core/.claude/hooks/turn-context.js +50 -2
  9. package/core/.claude/settings.json +0 -37
  10. package/core/.collaboration/core/task-api.js +4 -12
  11. package/core/.formation/README.md +21 -146
  12. package/core/.formation/bifrost/codex-doctor.js +37 -2
  13. package/core/.formation/bifrost/codex-doctor.test.js +18 -0
  14. package/core/.formation/bifrost/launch.js +1 -1
  15. package/core/.formation/bifrost/openai/codex-hook-shim.js +6 -0
  16. package/core/.formation/bifrost/openai/codex-hook-shim.test.js +11 -1
  17. package/core/.formation/bifrost/setup-codex.js +3 -0
  18. package/core/.formation/spec/task_operations.parity.test.js +0 -1
  19. package/core/.formation/tools/dashboard-models-chain.test.js +0 -6
  20. package/core/.formation/tools/dispatch-detail/cross-project-worktree.md +1 -9
  21. package/core/.formation/tools/dispatch-detail/worktree-subagent-mode.md +2 -2
  22. package/core/.formation/tools/dispatch.js +28 -549
  23. package/core/.formation/tools/mcp-allowlist.test.js +0 -1
  24. package/core/.formation/tools/post-complete/task2345.test.js +0 -5
  25. package/core/.formation/tools/pre-dispatch-snapshot.test.js +0 -100
  26. package/core/.formation/tools/prompt.js +66 -1607
  27. package/core/.formation/tools/prompt.test.js +43 -582
  28. package/core/.kenaz/claude-hooks-manifest.json +16 -16
  29. package/core/.specialist/Ansuz/RULES.md +6 -10
  30. package/core/.specialist/tools/__tests__/freya-cli-contract.test.js +0 -1
  31. package/core/.specialist/tools/__tests__/task-2218-boot-session-id.test.js +17 -1
  32. package/core/.specialist/tools/__tests__/task-2222-session-identity-interleave.test.js +17 -1
  33. package/core/.specialist/tools/__tests__/task-2254-handoff-archive-contract.test.js +6 -5
  34. package/core/.specialist/tools/ansuz-boot-fast.js +44 -100
  35. package/core/.specialist/tools/ansuz-boot-fast.test.js +45 -1
  36. package/core/KENAZ_CORE_VERSION +1 -1
  37. package/core/dev/plans/ANSUZ_SLIM_PLAN.md +68 -0
  38. package/core/plugins/kenaz/commands/Amelia.md +1 -1
  39. package/core/plugins/kenaz/commands/Ansuz.md +36 -35
  40. package/core/plugins/kenaz/hooks/hooks.json +1 -5
  41. package/core/plugins/kenaz/hooks/kenaz-hook.js +0 -4
  42. package/core/plugins/kenaz/scripts/kenaz-mode.js +11 -1
  43. package/core/plugins/kenaz/scripts/kenaz.test.js +1 -1
  44. package/core/plugins/kenaz/scripts/sync.js +6 -2
  45. package/core/plugins/kenaz/scripts/ygg.js +13 -1
  46. package/core/plugins/kenaz/skills/product_manager/SKILL.md +12 -12
  47. package/lib/cli.js +47 -6
  48. package/lib/cli.test.js +24 -0
  49. package/lib/dashboard.js +10 -0
  50. package/package.json +11 -7
  51. package/vendor/install-kenaz-cli.js +18 -7
  52. package/core/.formation/tools/broadcast.js +0 -103
  53. package/core/.formation/tools/dispatch-dryrun.test.js +0 -54
  54. package/core/.formation/tools/dispatch-notifier.js +0 -84
  55. package/core/.formation/tools/formations.js +0 -1203
  56. package/core/.formation/tools/headless-branch-recovery.test.js +0 -64
  57. package/core/.formation/tools/headless-dryrun.test.js +0 -79
  58. package/core/.formation/tools/headless-v2.js +0 -659
  59. package/core/.formation/tools/headless.js +0 -1071
  60. package/core/.formation/tools/legacy-scheduler.js +0 -1994
  61. package/core/.formation/tools/logger.js +0 -273
  62. package/core/.formation/tools/memory-loader.js +0 -422
  63. package/core/.formation/tools/process-state.js +0 -33
  64. package/core/.formation/tools/remote-conflict.js +0 -98
  65. package/core/.formation/tools/runner.js +0 -1332
  66. package/core/.formation/tools/task-utils.js +0 -344
  67. package/core/.formation/tools/task2028-headless-worktree.test.js +0 -112
  68. package/core/.formation/tools/tests/headless-mcp-args-plumbing.test.js +0 -123
  69. package/core/.formation/tools/worktree-leak.test.js +0 -162
  70. package/core/.specialist/tools/__tests__/task-1863-boot-lease-reuse.test.js +0 -99
  71. package/core/.specialist/tools/__tests__/task-1977-banner-cap.test.js +0 -129
@@ -1,33 +0,0 @@
1
- 'use strict';
2
- /**
3
- * Process State
4
- *
5
- * Shared mutable state for child process and worktree lifecycle tracking.
6
- * Extracted from headless.js.
7
- *
8
- * Exports: _activeChildren (Set), _activeWorktrees (Map), trackChild (function)
9
- *
10
- * NOTE: These are module-level singletons. All code that imports this module
11
- * shares the same Set/Map instances — this is intentional. The process.on('exit')
12
- * handler in headless.js reads these same references to clean up orphans.
13
- */
14
-
15
- // Global child process tracking — kill orphans on parent exit
16
- const _activeChildren = new Set();
17
-
18
- // Global worktree registry: worktreePath → projectRoot
19
- // Populated by launchSquad, cleaned by mergeWorktreeAndCleanup or the process exit handler.
20
- const _activeWorktrees = new Map();
21
-
22
- function trackChild(child) {
23
- _activeChildren.add(child);
24
- const remove = () => _activeChildren.delete(child);
25
- child.on('close', remove);
26
- child.on('formation:done', remove);
27
- }
28
-
29
- module.exports = {
30
- _activeChildren,
31
- _activeWorktrees,
32
- trackChild,
33
- };
@@ -1,98 +0,0 @@
1
- /**
2
- * remote-conflict.js
3
- * 跨機器 scope_paths 衝突檢查。
4
- *
5
- * 用記憶體快取(10s TTL),每輪排程前 refreshCache() 一次,
6
- * 然後逐任務呼叫 hasRemoteConflict() / hasRemoteFileConflict()。
7
- *
8
- * Yggdrasil Layer 2: Pre-dispatch Conflict Check
9
- */
10
-
11
- const { getRemoteActiveTasks, getOnlineNodes } = require('./task-sync');
12
-
13
- let _cachedRemoteTasks = null;
14
- let _cachedOnlineNodes = null;
15
- let _cacheTime = 0;
16
- const CACHE_TTL_MS = 10_000; // 10 seconds
17
-
18
- /**
19
- * 刷新遠端狀態快取(async)。
20
- * 每輪排程前呼叫一次,不是每個任務都查。
21
- */
22
- async function refreshCache(projectPath) {
23
- try {
24
- const [tasks, nodes] = await Promise.all([
25
- getRemoteActiveTasks(projectPath),
26
- getOnlineNodes(projectPath),
27
- ]);
28
- _cachedRemoteTasks = tasks;
29
- _cachedOnlineNodes = nodes;
30
- _cacheTime = Date.now();
31
- } catch {
32
- // 失敗保留舊快取
33
- }
34
- }
35
-
36
- /**
37
- * 檢查候選任務的 scope_paths 是否與遠端節點的 active 任務重疊。
38
- * @param {string[]} scopePaths - 候選任務的 scope_paths
39
- * @returns {{ conflict: boolean, conflictNode?: string, conflictTask?: string }}
40
- */
41
- function hasRemoteConflict(scopePaths) {
42
- if (!scopePaths || scopePaths.length === 0) return { conflict: false };
43
- if (!_cachedRemoteTasks || _cachedRemoteTasks.length === 0) return { conflict: false };
44
-
45
- for (const remote of _cachedRemoteTasks) {
46
- const remotePaths = remote.scope_paths || [];
47
- for (const rp of remotePaths) {
48
- for (const sp of scopePaths) {
49
- if (sp.startsWith(rp) || rp.startsWith(sp)) {
50
- return {
51
- conflict: true,
52
- conflictNode: remote.claimed_by,
53
- conflictTask: remote.task_id,
54
- };
55
- }
56
- }
57
- }
58
- }
59
-
60
- return { conflict: false };
61
- }
62
-
63
- /**
64
- * 檢查候選任務的 scope_paths 是否與遠端節點正在修改的檔案重疊。
65
- * 捕捉即時檔案層級的衝突(包括未透過 kenaz_tasks 登記的工作)。
66
- * @param {string[]} scopePaths
67
- * @returns {{ conflict: boolean, conflictNode?: string, conflictFile?: string }}
68
- */
69
- function hasRemoteFileConflict(scopePaths) {
70
- if (!scopePaths || scopePaths.length === 0) return { conflict: false };
71
- if (!_cachedOnlineNodes || _cachedOnlineNodes.length === 0) return { conflict: false };
72
-
73
- for (const node of _cachedOnlineNodes) {
74
- const touchingFiles = node.touching_files || [];
75
- for (const file of touchingFiles) {
76
- for (const sp of scopePaths) {
77
- if (file.startsWith(sp) || sp.startsWith(file)) {
78
- return {
79
- conflict: true,
80
- conflictNode: node.node_name,
81
- conflictFile: file,
82
- };
83
- }
84
- }
85
- }
86
- }
87
-
88
- return { conflict: false };
89
- }
90
-
91
- /**
92
- * 快取是否過期(或為空)。
93
- */
94
- function isCacheStale() {
95
- return !_cachedRemoteTasks || (Date.now() - _cacheTime > CACHE_TTL_MS);
96
- }
97
-
98
- module.exports = { refreshCache, hasRemoteConflict, hasRemoteFileConflict, isCacheStale };