axstack 0.72.0 → 0.73.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axstack",
3
- "version": "0.72.0",
3
+ "version": "0.73.0",
4
4
  "description": "Axstack installer and setup CLI: installs owned chat skills and role data, configures supported harness settings, and checks T3 Code capabilities.",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -3,6 +3,19 @@ export function gitArgv(...args) {
3
3
  return ['git', '--no-optional-locks', '-c', 'core.hooksPath=/dev/null', '-c', 'core.fsmonitor=false', ...args];
4
4
  }
5
5
 
6
+ const hookReads = {
7
+ root: ['rev-parse', '--show-toplevel'],
8
+ config: ['config', '--null', '--get', 'core.hooksPath'],
9
+ hooks: ['rev-parse', '--git-path', 'hooks'],
10
+ };
11
+
12
+ /** @param {keyof typeof hookReads} read */
13
+ export function gitHookReadArgv(repo, read) {
14
+ if (!Object.hasOwn(hookReads, read)) throw Error(`Unsupported Git hook lookup: ${read}`);
15
+ // These commands execute no hooks and must see the effective hooks configuration.
16
+ return ['git', '--no-optional-locks', '-c', 'core.fsmonitor=false', '-C', repo, ...hookReads[read]];
17
+ }
18
+
6
19
  // Scrubs inherited GIT_* only; trusted cwd + --no-env-file block peer .env
7
20
  // (including non-Git controls such as XDG_CONFIG_HOME or LD_PRELOAD).
8
21
  export function gitEnv(env = process.env) {
@@ -0,0 +1,108 @@
1
+ import { accessSync, constants, lstatSync, readFileSync, readlinkSync, statSync } from 'node:fs';
2
+ import { gitEnv, gitHookReadArgv } from './git-argv.js';
3
+
4
+ const help = `Usage: bun hooks-check.js --repo <checkout>
5
+ --repo <checkout> Required Git checkout to inspect.
6
+ --help Show this help.
7
+ Read-only. Reads Git config and file metadata. Executes and installs no hooks.
8
+ Exit: 0 pass or n/a, 2 hold (fail or unknown), 1 usage, input or Git repository error.`;
9
+
10
+ const paths = ['hooks-dir', 'pre-commit'];
11
+ const git = (repo, read) => Bun.spawnSync(gitHookReadArgv(repo, read), { env: gitEnv() });
12
+ const output = (result) => result.stdout.toString().replace(/\n$/, '');
13
+ const gitError = (result) => result.stderr.toString().trim() || `Git exited ${result.exitCode}`;
14
+
15
+ function optional(read) {
16
+ try {
17
+ return read();
18
+ } catch (error) {
19
+ if (error.code !== 'ENOENT' && error.code !== 'ENOTDIR') throw error;
20
+ }
21
+ }
22
+
23
+ function declarations(repo) {
24
+ const present = (...files) => files.find((file) => optional(() => lstatSync(`${repo}/${file}`)));
25
+ const manifest = optional(() => readFileSync(`${repo}/package.json`, 'utf8'));
26
+ const pkg = manifest === undefined ? {} : JSON.parse(manifest);
27
+ const tools = [];
28
+ const husky = present('.husky/pre-commit')
29
+ || (Object.hasOwn(pkg?.husky?.hooks ?? {}, 'pre-commit') && 'package.json');
30
+ const lefthook = present('lefthook.yml', 'lefthook.yaml', '.lefthook.yml', '.lefthook.yaml');
31
+ const preCommit = present('.pre-commit-config.yaml', '.pre-commit-config.yml');
32
+ if (husky) tools.push({ tool: 'husky', source: husky });
33
+ if (lefthook) tools.push({ tool: 'lefthook', source: lefthook });
34
+ if (preCommit) tools.push({ tool: 'pre-commit', source: preCommit });
35
+ return tools;
36
+ }
37
+
38
+ /** @param {'pass'|'fail'|'unknown'|'n/a'} status */
39
+ const term = (id, status, evidence) => ({ id, status, evidence });
40
+
41
+ function inspectPath(id, path, extraEvidence = {}) {
42
+ const evidence = { path, ...extraEvidence };
43
+ let target;
44
+ try {
45
+ if (id === 'hooks-dir') {
46
+ return term(id, statSync(path).isDirectory() ? 'pass' : 'fail', evidence);
47
+ }
48
+ if (lstatSync(path).isSymbolicLink()) target = readlinkSync(path);
49
+ if (!statSync(path).isFile()) return term(id, 'fail', { ...evidence, target });
50
+ accessSync(path, constants.X_OK);
51
+ return term(id, 'pass', evidence);
52
+ } catch (error) {
53
+ const expected = ['ENOENT', 'ENOTDIR', 'ELOOP'].includes(error.code)
54
+ || (id === 'pre-commit' && error.syscall === 'access' && error.code === 'EACCES');
55
+ return term(id, expected ? 'fail' : 'unknown', { ...evidence, target, error: error.message });
56
+ }
57
+ }
58
+
59
+ function inspect(repo) {
60
+ let declared;
61
+ try {
62
+ const tools = declarations(repo);
63
+ declared = term('declared', tools.length ? 'pass' : 'n/a', { tools });
64
+ } catch (error) {
65
+ declared = term('declared', 'unknown', { error: error.message });
66
+ }
67
+ const config = git(repo, 'config');
68
+ const coreHooksPath = config.exitCode === 0 ? config.stdout.toString().slice(0, -1) : null;
69
+ const unknown = (error) => [declared, ...paths.map((id) => term(id, 'unknown', { coreHooksPath, error }))];
70
+ const unset = config.exitCode === 1 && config.stderr.length === 0;
71
+ if (config.exitCode !== 0 && !unset) return unknown(gitError(config));
72
+ if (coreHooksPath === '') return unknown('core.hooksPath is empty');
73
+ if (unset && declared.status !== 'pass') {
74
+ return [declared, ...paths.map((id) => term(id, 'n/a', { coreHooksPath, declared: declared.status }))];
75
+ }
76
+ const resolved = git(repo, 'hooks');
77
+ if (resolved.exitCode !== 0) return unknown(gitError(resolved));
78
+ // Keep relative components intact so file lookup follows the same path as Git.
79
+ const gitPath = output(resolved);
80
+ const path = gitPath.startsWith('/') ? gitPath : `${repo}/${gitPath}`;
81
+ return [declared, inspectPath('hooks-dir', path, { coreHooksPath }), inspectPath('pre-commit', `${path}/pre-commit`)];
82
+ }
83
+
84
+ const report = (repo, terms) => console.log(JSON.stringify({ inputs: { repo }, terms }));
85
+
86
+ /** @param {string[]} args */
87
+ function main(args) {
88
+ const [flag, checkout, ...extra] = args;
89
+ if (flag === '--help' && checkout === undefined) {
90
+ console.log(help);
91
+ return 0;
92
+ }
93
+ try {
94
+ if (flag !== '--repo' || !checkout || extra.length) throw Error(help);
95
+ const root = git(checkout, 'root');
96
+ if (root.exitCode !== 0) throw Error(gitError(root));
97
+ const repo = output(root);
98
+ const terms = inspect(repo);
99
+ report(repo, terms);
100
+ return terms.some(({ status }) => status === 'fail' || status === 'unknown') ? 2 : 0;
101
+ } catch (error) {
102
+ console.error(error.message);
103
+ report(checkout ?? null, ['declared', ...paths].map((id) => term(id, 'unknown', { error: error.message })));
104
+ return 1;
105
+ }
106
+ }
107
+
108
+ process.exitCode = main(process.argv.slice(2));
@@ -281,6 +281,17 @@ Resolve measurement errors before committing; keep repository-owned checks enfor
281
281
  Preserve the check's exclusions, but never hide authored files behind generated banners or ignore globs.
282
282
  Record the staged-file size check result in the implementation receipt.
283
283
 
284
+ Before each commit, the author runs [hooks-check](../axstack/scripts/hooks-check.js)
285
+ from a trusted cwd with `bun --no-env-file <resolved-helper> --repo <target-repository>`.
286
+ On any nonzero hooks-check exit, hold the commit and return `AXSTACK-QUESTION`
287
+ with the hooks-check JSON.
288
+ Authors never install hooks or write shared Git metadata.
289
+ The driver applies the repository's documented hook setup and resumes the author.
290
+ After resuming, the author reruns hooks-check and commits only on exit 0.
291
+ Record the hooks-check result in the implementation receipt.
292
+ Never use `--no-verify` or `-n` on commits.
293
+ Never override `core.hooksPath` for a commit.
294
+
284
295
  ## 5. Verify and return the candidate
285
296
 
286
297
  Run the acceptance checks and affected integration boundaries following
@@ -322,7 +333,7 @@ Scope: <approved spec + capability | small-change intent | maintenance snapshot>
322
333
  Delivery map: <record pointer; outcomes/accepted scope drivers; current milestone evidence; held launches>
323
334
  Shape: <total> lines vs base <sha>; bulk: <buckets>; theme: <one line>
324
335
  TDD: <normal red/green | structure-preserving old-green/same-check-new-green evidence | F-repair base-green/removal-inversion-red/rewording-green evidence>
325
- Token limit: <staged-file size check command + observed advisories/errors before each commit>
336
+ Token limit: <staged-file size check command + advisories/errors and hooks-check result before each commit>
326
337
  Simplification: <applied | not-applicable> — evidence: <diff locations and checks>; retained complexity: <necessary complexity and why>
327
338
  Acceptance: <check-run receipt paths + identities mapped to criteria>
328
339
  Dependencies: <parent revisions or none>