@imdeadpool/guardex 7.0.43 → 7.1.1

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 (68) hide show
  1. package/README.md +35 -0
  2. package/package.json +4 -1
  3. package/scripts/prepublish-bump-version.js +191 -0
  4. package/skills/gx-act/SKILL.md +82 -0
  5. package/src/agents/activity.js +279 -0
  6. package/src/agents/inspect.js +17 -4
  7. package/src/agents/launch.js +10 -1
  8. package/src/agents/status.js +9 -6
  9. package/src/budget/index.js +2 -1
  10. package/src/cli/args.js +118 -5
  11. package/src/cli/commands/agents.js +381 -0
  12. package/src/cli/commands/bootstrap.js +92 -0
  13. package/src/cli/commands/branch.js +127 -0
  14. package/src/cli/commands/claude.js +674 -0
  15. package/src/cli/commands/doctor.js +268 -0
  16. package/src/cli/commands/finish.js +26 -0
  17. package/src/cli/commands/mcp.js +122 -0
  18. package/src/cli/commands/misc.js +304 -0
  19. package/src/cli/commands/pr.js +439 -0
  20. package/src/cli/commands/prompt.js +92 -0
  21. package/src/cli/commands/release.js +305 -0
  22. package/src/cli/commands/report.js +244 -0
  23. package/src/cli/commands/review.js +32 -0
  24. package/src/cli/commands/setup.js +242 -0
  25. package/src/cli/commands/status.js +338 -0
  26. package/src/cli/commands/watch.js +234 -0
  27. package/src/cli/main.js +68 -3726
  28. package/src/cli/shared/repo-env.js +161 -0
  29. package/src/cli/shared/sandbox.js +417 -0
  30. package/src/cli/shared/scaffolding.js +535 -0
  31. package/src/cli/shared/toolchain-shims.js +420 -0
  32. package/src/context.js +229 -11
  33. package/src/core/runtime.js +6 -1
  34. package/src/doctor/index.js +42 -13
  35. package/src/finish/index.js +147 -5
  36. package/src/finish/preflight.js +177 -0
  37. package/src/finish/review-gate.js +182 -0
  38. package/src/git/index.js +446 -4
  39. package/src/hooks/index.js +0 -64
  40. package/src/mcp/collect.js +394 -0
  41. package/src/mcp/server.js +163 -0
  42. package/src/output/index.js +67 -1
  43. package/src/pr-review.js +23 -0
  44. package/src/pr.js +381 -0
  45. package/src/sandbox/index.js +13 -2
  46. package/src/scaffold/agent-worktree-prep.js +220 -0
  47. package/src/scaffold/index.js +108 -10
  48. package/src/scaffold/provision-config.js +314 -0
  49. package/src/speckit/index.js +226 -0
  50. package/src/terminal/index.js +1 -76
  51. package/src/terminal/kitty.js +20 -0
  52. package/src/terminal/tmux.js +9 -1
  53. package/src/toolchain/index.js +20 -0
  54. package/templates/AGENTS.monorepo-apps.md +26 -0
  55. package/templates/AGENTS.multiagent-safety.md +68 -344
  56. package/templates/AGENTS.multiagent-safety.min.md +11 -0
  57. package/templates/codex/skills/gx-act/SKILL.md +82 -0
  58. package/templates/githooks/pre-commit +22 -19
  59. package/templates/scripts/agent-branch-finish.sh +17 -33
  60. package/templates/scripts/agent-branch-merge.sh +4 -1
  61. package/templates/scripts/agent-branch-start.sh +115 -6
  62. package/templates/scripts/agent-file-locks.py +245 -50
  63. package/templates/scripts/agent-preflight.sh +31 -5
  64. package/templates/scripts/agent-worktree-prune.sh +1 -1
  65. package/templates/scripts/codex-agent.sh +0 -91
  66. package/src/agents/detect.js +0 -160
  67. package/src/cockpit/keybindings.js +0 -224
  68. package/src/cockpit/layout.js +0 -224
@@ -324,7 +324,6 @@ if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
324
324
  exit 1
325
325
  fi
326
326
  repo_root="$(git rev-parse --show-toplevel)"
327
- active_session_state_script="${repo_root}/scripts/agent-session-state.js"
328
327
 
329
328
  guardex_env_helper="${repo_root}/scripts/guardex-env.sh"
330
329
  if [[ -f "$guardex_env_helper" ]]; then
@@ -638,78 +637,6 @@ has_origin_remote() {
638
637
  git -C "$repo_root" remote get-url origin >/dev/null 2>&1
639
638
  }
640
639
 
641
- run_active_session_state() {
642
- local action="$1"
643
- shift
644
-
645
- if [[ ! -f "$active_session_state_script" ]]; then
646
- return 0
647
- fi
648
- if ! command -v "$NODE_BIN" >/dev/null 2>&1; then
649
- return 0
650
- fi
651
-
652
- "$NODE_BIN" "$active_session_state_script" "$action" "$@" >/dev/null 2>&1 || true
653
- }
654
-
655
- record_active_session_state() {
656
- local wt="$1"
657
- local branch="$2"
658
-
659
- run_active_session_state \
660
- start \
661
- --repo "$repo_root" \
662
- --branch "$branch" \
663
- --task "$TASK_NAME" \
664
- --agent "$AGENT_NAME" \
665
- --worktree "$wt" \
666
- --pid "$$" \
667
- --cli "$CODEX_BIN" \
668
- --task-mode "$TASK_MODE" \
669
- --openspec-tier "$OPENSPEC_TIER" \
670
- --routing-reason "$TASK_ROUTING_REASON"
671
- }
672
-
673
- clear_active_session_state() {
674
- local branch="$1"
675
- run_active_session_state stop --repo "$repo_root" --branch "$branch"
676
- }
677
-
678
- heartbeat_active_session_state() {
679
- local branch="$1"
680
- run_active_session_state heartbeat --repo "$repo_root" --branch "$branch" --state working
681
- }
682
-
683
- normalize_heartbeat_interval_seconds() {
684
- local raw="${GUARDEX_ACTIVE_SESSION_HEARTBEAT_INTERVAL_SECONDS:-15}"
685
- if [[ "$raw" =~ ^[0-9]+$ ]] && [[ "$raw" -ge 1 ]]; then
686
- printf '%s' "$raw"
687
- return 0
688
- fi
689
- printf '15'
690
- }
691
-
692
- start_active_session_heartbeat() {
693
- local branch="$1"
694
- local interval
695
- interval="$(normalize_heartbeat_interval_seconds)"
696
- (
697
- while true; do
698
- sleep "$interval" || break
699
- heartbeat_active_session_state "$branch"
700
- done
701
- ) &
702
- active_session_heartbeat_pid="$!"
703
- }
704
-
705
- stop_active_session_heartbeat() {
706
- if [[ -n "${active_session_heartbeat_pid:-}" ]]; then
707
- kill "$active_session_heartbeat_pid" >/dev/null 2>&1 || true
708
- wait "$active_session_heartbeat_pid" >/dev/null 2>&1 || true
709
- active_session_heartbeat_pid=""
710
- fi
711
- }
712
-
713
640
  origin_remote_supports_pr_finish() {
714
641
  local origin_url
715
642
  origin_url="$(git -C "$repo_root" remote get-url origin 2>/dev/null || true)"
@@ -1103,22 +1030,6 @@ fi
1103
1030
 
1104
1031
  echo "[codex-agent] Task routing: $(describe_task_routing) (${TASK_ROUTING_REASON})"
1105
1032
 
1106
- active_session_recorded=0
1107
- active_session_heartbeat_pid=""
1108
- cleanup_active_session_state_on_exit() {
1109
- set +e
1110
- if [[ "${active_session_recorded:-0}" -eq 1 && -n "${worktree_branch:-}" && "${worktree_branch:-}" != "HEAD" ]]; then
1111
- stop_active_session_heartbeat
1112
- clear_active_session_state "$worktree_branch"
1113
- active_session_recorded=0
1114
- fi
1115
- }
1116
-
1117
- record_active_session_state "$worktree_path" "$worktree_branch"
1118
- active_session_recorded=1
1119
- start_active_session_heartbeat "$worktree_branch"
1120
- trap cleanup_active_session_state_on_exit EXIT INT TERM
1121
-
1122
1033
  echo "[codex-agent] Launching ${CODEX_BIN} in sandbox: $worktree_path"
1123
1034
  cd "$worktree_path"
1124
1035
  set +e
@@ -1131,8 +1042,6 @@ codex_exit="$?"
1131
1042
  set -e
1132
1043
 
1133
1044
  cd "$repo_root"
1134
- cleanup_active_session_state_on_exit
1135
- trap - EXIT INT TERM
1136
1045
  final_exit="$codex_exit"
1137
1046
  auto_finish_completed=0
1138
1047
 
@@ -1,160 +0,0 @@
1
- const registry = require('./registry');
2
- const { run } = require('../core/runtime');
3
-
4
- function registryEntries() {
5
- if (typeof registry.getAgentDefinitions === 'function') {
6
- const definitions = registry.getAgentDefinitions();
7
- if (Array.isArray(definitions)) {
8
- return definitions;
9
- }
10
- }
11
-
12
- if (Array.isArray(registry.AGENT_IDS) && typeof registry.getAgentDefinition === 'function') {
13
- return registry.AGENT_IDS
14
- .map((agentId) => registry.getAgentDefinition(agentId))
15
- .filter((entry) => entry && typeof entry === 'object');
16
- }
17
-
18
- const source =
19
- registry.agents ||
20
- registry.AGENTS ||
21
- registry.registry ||
22
- registry.entries ||
23
- registry.default ||
24
- registry;
25
-
26
- if (Array.isArray(source)) {
27
- return source;
28
- }
29
-
30
- if (source && typeof source === 'object') {
31
- return Object.entries(source)
32
- .filter(([, entry]) => entry && typeof entry === 'object')
33
- .map(([id, entry]) => ({ id, ...entry }));
34
- }
35
-
36
- return [];
37
- }
38
-
39
- function findAgent(agentId) {
40
- if (typeof registry.getAgentDefinition === 'function') {
41
- const entry = registry.getAgentDefinition(agentId);
42
- if (entry) return entry;
43
- }
44
-
45
- if (typeof registry.resolveAgent === 'function') {
46
- try {
47
- const entry = registry.resolveAgent(agentId);
48
- if (entry) return entry;
49
- } catch (_error) {
50
- return null;
51
- }
52
- }
53
-
54
- if (typeof registry.getAgent === 'function') {
55
- const entry = registry.getAgent(agentId);
56
- if (entry) return entry;
57
- }
58
-
59
- return registryEntries().find((entry) => entry.id === agentId);
60
- }
61
-
62
- function registryAgentIds() {
63
- if (Array.isArray(registry.AGENT_IDS)) {
64
- return [...registry.AGENT_IDS];
65
- }
66
-
67
- if (typeof registry.getAgentDefinitions === 'function') {
68
- const definitions = registry.getAgentDefinitions();
69
- if (Array.isArray(definitions)) {
70
- return definitions.map((entry) => entry && entry.id).filter(Boolean);
71
- }
72
- }
73
-
74
- return registryEntries().map((entry) => entry.id).filter(Boolean);
75
- }
76
-
77
- function normalizeDetectCommand(detectCommand) {
78
- if (Array.isArray(detectCommand)) {
79
- const [cmd, ...args] = detectCommand;
80
- return { cmd, args, command: detectCommand.join(' ') };
81
- }
82
-
83
- if (typeof detectCommand === 'string') {
84
- const [cmd, ...args] = detectCommand.trim().split(/\s+/).filter(Boolean);
85
- return { cmd, args, command: detectCommand.trim() };
86
- }
87
-
88
- if (detectCommand && typeof detectCommand === 'object') {
89
- const cmd = detectCommand.cmd || detectCommand.command || detectCommand.bin;
90
- const args = Array.isArray(detectCommand.args) ? detectCommand.args : [];
91
- return {
92
- cmd,
93
- args,
94
- command: [cmd, ...args].filter(Boolean).join(' '),
95
- };
96
- }
97
-
98
- return { cmd: null, args: [], command: null };
99
- }
100
-
101
- function resultError(result) {
102
- if (result.error) {
103
- return result.error.message || String(result.error);
104
- }
105
-
106
- const output = `${result.stderr || ''}${result.stdout || ''}`.trim();
107
- if (output) return output;
108
-
109
- if (typeof result.status === 'number') {
110
- return `detect command exited with status ${result.status}`;
111
- }
112
-
113
- return 'detect command failed';
114
- }
115
-
116
- function detectionResult(entry, available, command, error = null) {
117
- return {
118
- id: entry.id,
119
- label: entry.label || entry.id,
120
- available,
121
- command,
122
- error,
123
- };
124
- }
125
-
126
- function detectAgent(agentId) {
127
- const entry = findAgent(agentId);
128
- if (!entry) {
129
- const known = registryAgentIds();
130
- const suffix = known.length > 0 ? ` (known agents: ${known.join(', ')})` : '';
131
- return detectionResult({ id: agentId, label: agentId }, false, null, `unknown agent: ${agentId}${suffix}`);
132
- }
133
-
134
- const { cmd, args, command } = normalizeDetectCommand(entry.detectCommand);
135
- if (!cmd) {
136
- return detectionResult(entry, false, command, 'missing detectCommand');
137
- }
138
-
139
- const result = run(cmd, args, { stdio: 'pipe' });
140
- if (!result.error && result.status === 0) {
141
- return detectionResult(entry, true, command, null);
142
- }
143
-
144
- return detectionResult(entry, false, command, resultError(result));
145
- }
146
-
147
- function detectAgents(agentIds) {
148
- const ids = Array.isArray(agentIds) ? agentIds : registryAgentIds();
149
- return ids.map((agentId) => detectAgent(agentId));
150
- }
151
-
152
- function detectAvailableAgents() {
153
- return detectAgents().filter((agent) => agent.available);
154
- }
155
-
156
- module.exports = {
157
- detectAgent,
158
- detectAgents,
159
- detectAvailableAgents,
160
- };
@@ -1,224 +0,0 @@
1
- 'use strict';
2
-
3
- const { PANE_MENU_ACTION_IDS } = require('./pane-menu');
4
-
5
- const DEFAULT_ACTION_ROWS = Object.freeze(['new-agent', 'terminal', 'settings', 'shortcuts']);
6
- const VALID_MODES = new Set(['main', 'menu', 'settings', 'shortcuts', 'new-agent', 'terminal', 'prompt']);
7
-
8
- function action(type, payload = {}) {
9
- return { type, payload };
10
- }
11
-
12
- const NAVIGATION_BINDINGS = {
13
- j: action('next'),
14
- down: action('next'),
15
- k: action('previous'),
16
- up: action('previous'),
17
- enter: action('view-selected'),
18
- };
19
-
20
- const MAIN_BINDINGS = {
21
- n: action('new-agent'),
22
- t: action('terminal'),
23
- m: action('menu'),
24
- 'alt-shift-m': action('menu'),
25
- s: action('settings'),
26
- '?': action('shortcuts'),
27
- x: action(PANE_MENU_ACTION_IDS.CLOSE),
28
- b: action(PANE_MENU_ACTION_IDS.CREATE_CHILD_WORKTREE),
29
- f: action(PANE_MENU_ACTION_IDS.BROWSE_FILES),
30
- h: action(PANE_MENU_ACTION_IDS.HIDE_PANE),
31
- P: action(PANE_MENU_ACTION_IDS.PROJECT_FOCUS),
32
- a: action(PANE_MENU_ACTION_IDS.ADD_AGENT),
33
- A: action(PANE_MENU_ACTION_IDS.ADD_TERMINAL),
34
- r: action(PANE_MENU_ACTION_IDS.REOPEN_CLOSED_WORKTREE),
35
- D: action('doctor'),
36
- d: action('diff'),
37
- l: action('locks'),
38
- y: action('sync'),
39
- F: action('finish'),
40
- c: action('cleanup-sessions'),
41
- q: action('quit'),
42
- ...NAVIGATION_BINDINGS,
43
- };
44
-
45
- const BASE_BINDINGS = {
46
- main: MAIN_BINDINGS,
47
- menu: {
48
- ...NAVIGATION_BINDINGS,
49
- esc: action('close-menu'),
50
- q: action('quit'),
51
- },
52
- settings: {
53
- ...NAVIGATION_BINDINGS,
54
- esc: action('close-settings'),
55
- q: action('quit'),
56
- },
57
- shortcuts: {
58
- esc: action('close-popup'),
59
- q: action('quit'),
60
- },
61
- 'new-agent': {
62
- enter: action('agent:start'),
63
- esc: action('close-popup'),
64
- q: action('quit'),
65
- },
66
- terminal: {
67
- enter: action('terminal:open'),
68
- esc: action('close-popup'),
69
- q: action('quit'),
70
- },
71
- prompt: {},
72
- };
73
-
74
- function cloneAction(binding) {
75
- return action(binding.type, { ...binding.payload });
76
- }
77
-
78
- function cloneBindings(bindings) {
79
- return Object.fromEntries(
80
- Object.entries(bindings).map(([mode, modeBindings]) => [
81
- mode,
82
- Object.fromEntries(
83
- Object.entries(modeBindings).map(([key, binding]) => [key, cloneAction(binding)]),
84
- ),
85
- ]),
86
- );
87
- }
88
-
89
- function defaultKeybindings() {
90
- return cloneBindings(BASE_BINDINGS);
91
- }
92
-
93
- function normalizeMode(context = {}) {
94
- return VALID_MODES.has(context.mode) ? context.mode : 'main';
95
- }
96
-
97
- function normalizeKey(key) {
98
- if (key && typeof key === 'object') {
99
- if ((key.meta || key.alt) && key.shift && String(key.name || key.key || '').toLowerCase() === 'm') {
100
- return 'alt-shift-m';
101
- }
102
- return normalizeKey(key.name || key.sequence || key.key || '');
103
- }
104
- if (key === '\r' || key === '\n') return 'enter';
105
- if (key === '\x1bM' || key === '\x1bm') return 'alt-shift-m';
106
- if (key === '\x1b') return 'esc';
107
- if (typeof key !== 'string') return '';
108
-
109
- const normalized = key.trim();
110
- if (normalized === '\x1bM' || normalized === '\x1bm') return 'alt-shift-m';
111
- if (/^alt(?:\+|-)?shift(?:\+|-)?m$/i.test(normalized)) return 'alt-shift-m';
112
- if (normalized.length === 1) return normalized;
113
-
114
- const namedKey = normalized.toLowerCase();
115
- if (namedKey === 'arrowdown') return 'down';
116
- if (namedKey === 'arrowup') return 'up';
117
- if (namedKey === 'return') return 'enter';
118
- if (namedKey === 'escape') return 'esc';
119
- return namedKey;
120
- }
121
-
122
- function resolveKeyAction(key, context = {}) {
123
- const mode = normalizeMode(context);
124
- const normalizedKey = normalizeKey(key);
125
- const keybindings = context.keybindings || BASE_BINDINGS;
126
- const binding = keybindings[mode] && keybindings[mode][normalizedKey];
127
-
128
- if (!binding) {
129
- return action('noop', { key: normalizedKey, mode });
130
- }
131
-
132
- return action(binding.type, {
133
- ...binding.payload,
134
- key: normalizedKey,
135
- mode,
136
- });
137
- }
138
-
139
- function number(value, fallback) {
140
- const parsed = Number(value);
141
- return Number.isFinite(parsed) ? parsed : fallback;
142
- }
143
-
144
- function wrapIndex(index, length) {
145
- if (length <= 0) return 0;
146
- const next = Number.isInteger(index) ? index : 0;
147
- return ((next % length) + length) % length;
148
- }
149
-
150
- function actionRows(state = {}) {
151
- if (!Array.isArray(state.actionRows) || state.actionRows.length === 0) {
152
- return [...DEFAULT_ACTION_ROWS];
153
- }
154
- return state.actionRows.map((row) => String(row || '').trim()).filter(Boolean);
155
- }
156
-
157
- function moveSelection(state = {}, direction) {
158
- const sessions = Array.isArray(state.sessions) ? state.sessions : [];
159
- if (sessions.length > 0) {
160
- return {
161
- ...state,
162
- selectedScope: 'lane',
163
- selectedIndex: wrapIndex(number(state.selectedIndex, 0) + direction, sessions.length),
164
- selectedSessionId: '',
165
- };
166
- }
167
-
168
- const rows = actionRows(state);
169
- return {
170
- ...state,
171
- actionRows: rows,
172
- selectedScope: 'action',
173
- selectedIndex: 0,
174
- actionIndex: wrapIndex(number(state.actionIndex, 0) + direction, rows.length),
175
- selectedSessionId: '',
176
- };
177
- }
178
-
179
- function closeMode(state = {}) {
180
- return {
181
- ...state,
182
- mode: 'main',
183
- lastIntent: null,
184
- };
185
- }
186
-
187
- function applyCockpitKey(state = {}, key) {
188
- const current = {
189
- ...state,
190
- mode: normalizeMode(state),
191
- };
192
- const resolved = resolveKeyAction(key, current);
193
-
194
- switch (resolved.type) {
195
- case 'next':
196
- return moveSelection(current, 1);
197
- case 'previous':
198
- return moveSelection(current, -1);
199
- case 'new-agent':
200
- return { ...current, mode: 'new-agent', lastIntent: null };
201
- case 'terminal':
202
- return { ...current, mode: 'terminal', lastIntent: null };
203
- case 'shortcuts':
204
- return { ...current, mode: 'shortcuts', lastIntent: null };
205
- case 'settings':
206
- return { ...current, mode: 'settings', lastIntent: null };
207
- case 'menu':
208
- return { ...current, mode: 'menu', lastIntent: null };
209
- case 'close-menu':
210
- case 'close-settings':
211
- case 'close-popup':
212
- return closeMode(current);
213
- case 'quit':
214
- return { ...current, shouldExit: true };
215
- default:
216
- return current;
217
- }
218
- }
219
-
220
- module.exports = {
221
- applyCockpitKey,
222
- defaultKeybindings,
223
- resolveKeyAction,
224
- };