@sabaiway/agent-workflow-kit 14.31.0 → 14.33.0

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.
@@ -2,6 +2,7 @@ import { join, resolve } from 'node:path';
2
2
  import { dirCovers } from './declared-paths.mjs';
3
3
  import { claudeDirOf, quoteArg, skillTargets } from './jev-facts.mjs';
4
4
  import { targetsFor } from './jev-connect.mjs';
5
+ import { BUNDLED_SCRIPT_NAMES, INSTALLER_REL, SCRIPTS_REL } from './git-hooks.mjs';
5
6
 
6
7
  export const LANE_CHAT = 'chat';
7
8
  export const LANE_HARNESS = 'harness';
@@ -27,8 +28,8 @@ export const VARIANT_LANES = Object.freeze({
27
28
  'source-size.id-squatter': LANE_CHAT,
28
29
  'gate-hook': LANE_HARNESS,
29
30
  'gate-hook.marker-stale': LANE_HARNESS,
30
- 'commit-guard': LANE_USER,
31
- enforcement: LANE_USER,
31
+ 'commit-guard': LANE_HARNESS,
32
+ enforcement: LANE_HARNESS,
32
33
  'read-lane': LANE_CHAT,
33
34
  'read-lane.stale': LANE_HARNESS,
34
35
  'read-lane.missing': LANE_HARNESS,
@@ -41,7 +42,8 @@ export const VARIANT_LANES = Object.freeze({
41
42
  'adr-store-migration': LANE_CHAT,
42
43
  'sandbox-masks': LANE_CHAT,
43
44
  'sandbox-masks.unfenced-mount': LANE_CHAT,
44
- 'worktrees-dir': LANE_CHAT,
45
+ 'worktrees-dir': LANE_HARNESS,
46
+ 'worktrees-dir.home': LANE_USER,
45
47
  'spec-adoption': LANE_CHAT,
46
48
  'profile-gap': LANE_CHAT,
47
49
  'jev-connect': LANE_USER,
@@ -79,6 +81,7 @@ export const isProtectedPath = (abs, { root, home, hooksDir }) => {
79
81
  };
80
82
 
81
83
  const SETTINGS_WRITES = [SETTINGS_PATH];
84
+ const LOCAL_SETTINGS_WRITES = [join('.claude', 'settings.local.json')];
82
85
  const HOOK_WRITES = [join('.claude', 'hooks', 'agent-workflow-gates.mjs'), ...SETTINGS_WRITES];
83
86
  const STOP_HOOK_WRITES = [join('.claude', 'hooks', 'state-block-guard.mjs'), ...SETTINGS_WRITES];
84
87
  const MCP_WRITES = ['.mcp.json', ...SETTINGS_WRITES];
@@ -97,16 +100,22 @@ const getStartupPaths = ({ env, home, platform }) => targetsFor({
97
100
  platform,
98
101
  }).filter(({ path }) => path !== null).map(({ path }) => path);
99
102
 
103
+ const preCommitOf = (facts) => join(facts.hooksDir ?? join(facts.root, '.git', 'hooks'), 'pre-commit');
104
+ const getEnforcementPaths = (facts) => [...BUNDLED_SCRIPT_NAMES.map((name) => join(facts.root, SCRIPTS_REL, name)), preCommitOf(facts)];
105
+ const getGuardPaths = (facts) => [preCommitOf(facts), join(facts.root, INSTALLER_REL)];
106
+
100
107
  const formatCommand = (argv) => argv.map(quoteArg).join(' ');
101
108
  const TERMINAL_STEP = 'run in a terminal of your own: ';
102
109
 
103
- const createForm = (file, preview, apply, writes, envDependent = false, userStep = null) => Object.freeze({
110
+ // rejudged: the written value derives from state init's record does not watch, so init re-runs its check before the apply.
111
+ const createForm = (file, preview, apply, writes, envDependent = false, userStep = null, rejudged = false) => Object.freeze({
104
112
  file,
105
113
  preview,
106
114
  apply,
107
115
  writes,
108
116
  envDependent,
109
117
  userStep,
118
+ rejudged,
110
119
  });
111
120
 
112
121
  const CORE_FORM = createForm('velocity-profile.mjs', ['--cwd', '<root>'], ['--apply', '--cwd', '<root>'], SETTINGS_WRITES);
@@ -148,8 +157,15 @@ const FORMS = Object.freeze({
148
157
  userStep: (facts) => 'your own step — the doctor has no install it can run for you here (the reason is this item\'s text) — '
149
158
  + `${TERMINAL_STEP}cd ${quoteArg(facts.root)} && ${formatCommand(['node', join(facts.toolsDir, 'autonomy-doctor.mjs')])}`,
150
159
  }),
151
- 'commit-guard': null,
152
- enforcement: null,
160
+ enforcement: createForm('git-hooks.mjs',
161
+ ['--enforcement', '--cwd', '<root>'], ['--apply', '--enforcement', '--cwd', '<root>'], getEnforcementPaths),
162
+ 'commit-guard': createForm('git-hooks.mjs',
163
+ ['--commit-guard', '--cwd', '<root>'], ['--apply', '--commit-guard', '--cwd', '<root>'], getGuardPaths),
164
+ 'worktrees-dir': createForm('velocity-profile.mjs',
165
+ ['--worktrees', '--cwd', '<root>'], ['--apply', '--worktrees', '--cwd', '<root>'], LOCAL_SETTINGS_WRITES, false, null, true),
166
+ 'worktrees-dir.home': Object.freeze({
167
+ userStep: () => 'your own step — point docs/ai/worktrees.json parentDir at a dedicated directory, then run /agent-workflow-kit recommendations',
168
+ }),
153
169
  });
154
170
 
155
171
  const resolveArgument = (arg, facts) => {
@@ -183,6 +199,11 @@ export const isEnvDependent = (variant) => {
183
199
  return FORMS[variant]?.envDependent === true;
184
200
  };
185
201
 
202
+ export const isRejudged = (variant) => {
203
+ laneOf(variant);
204
+ return FORMS[variant]?.rejudged === true;
205
+ };
206
+
186
207
  export const applySlot = (variant, facts) => {
187
208
  const lane = laneOf(variant);
188
209
  const form = FORMS[variant];