@moneko/core 4.11.4-beta.2 → 4.11.5-beta.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.
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env bash
2
+ set -u
3
+
4
+ if [ ! -t 0 ]; then
5
+ hook_input=$(cat)
6
+ if printf '%s' "$hook_input" | grep -Eq '"stop_hook_active"[[:space:]]*:[[:space:]]*true'; then
7
+ exit 0
8
+ fi
9
+ fi
10
+
11
+ repo_root=$(git rev-parse --show-toplevel 2>/dev/null) || {
12
+ printf 'AI ESLint hook: unable to locate the Git repository root.\n' >&2
13
+ exit 2
14
+ }
15
+
16
+ cd "$repo_root" || exit 2
17
+
18
+ if ! command -v npx >/dev/null 2>&1; then
19
+ printf 'AI ESLint hook: npx is unavailable; install no dependency automatically and fix the environment before continuing.\n' >&2
20
+ exit 2
21
+ fi
22
+
23
+ tmp_dir=$(mktemp -d "${TMPDIR:-/tmp}/ai-eslint-fix.XXXXXX") || exit 2
24
+ trap 'rm -rf "$tmp_dir"' EXIT
25
+
26
+ had_errors=0
27
+
28
+ while IFS= read -r -d '' record; do
29
+ xy=${record:0:2}
30
+ path=${record:3}
31
+
32
+ case "$xy" in
33
+ *R*|*C*)
34
+ # Rename/copy records contain a second NUL-delimited path. Always consume it.
35
+ IFS= read -r -d '' ignored_path || true
36
+ ;;
37
+ esac
38
+
39
+ case "$xy" in
40
+ \?\?) should_lint=1 ;;
41
+ *)
42
+ case "$xy" in
43
+ *A*|*M*) should_lint=1 ;;
44
+ *) should_lint=0 ;;
45
+ esac
46
+ ;;
47
+ esac
48
+
49
+ [ "$should_lint" -eq 1 ] || continue
50
+ [ -e "$path" ] || [ -L "$path" ] || continue
51
+
52
+ output_file="$tmp_dir/output-${RANDOM}-${RANDOM}"
53
+ if ! npx mo eslint "$path" --fix >"$output_file" 2>&1; then
54
+ had_errors=1
55
+ fi
56
+ if [ -s "$output_file" ]; then
57
+ cat "$output_file" >&2
58
+ fi
59
+ done < <(git status --porcelain=v1 -z --untracked-files=all)
60
+
61
+ if [ "$had_errors" -ne 0 ]; then
62
+ printf '\nAI ESLint hook: 请 Agent 继续修复剩余 ESLint 问题。\n' >&2
63
+ exit 2
64
+ fi
65
+
66
+ exit 0
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env bash
2
+ set -u
3
+
4
+ if [ ! -t 0 ]; then
5
+ hook_input=$(cat)
6
+ if printf '%s' "$hook_input" | grep -Eq '"stop_hook_active"[[:space:]]*:[[:space:]]*true'; then
7
+ exit 0
8
+ fi
9
+ fi
10
+
11
+ repo_root=$(git rev-parse --show-toplevel 2>/dev/null) || {
12
+ printf 'AI Stylelint hook: unable to locate the Git repository root.\n' >&2
13
+ exit 2
14
+ }
15
+
16
+ cd "$repo_root" || exit 2
17
+
18
+ if ! command -v npx >/dev/null 2>&1; then
19
+ printf 'AI Stylelint hook: npx is unavailable; install no dependency automatically and fix the environment before continuing.\n' >&2
20
+ exit 2
21
+ fi
22
+
23
+ if ! npx mo stylelint src; then
24
+ printf '\nAI Stylelint hook: 请 Agent 继续修复剩余 Stylelint 问题。\n' >&2
25
+ exit 2
26
+ fi
27
+
28
+ exit 0
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,11 @@
1
+ import{existsSync as o,mkdirSync as e,readFileSync as s,writeFileSync as t}from"node:fs";import{dirname as m,resolve as r}from"node:path";import{paths as h}from"./paths.mjs";let n=h.programPath,i='bash "$(git rev-parse --show-toplevel)/node_modules/@moneko/core/hooks/eslint-fix.sh"',p='bash "$(git rev-parse --show-toplevel)/node_modules/@moneko/core/hooks/stylelint-fix.sh"',l=r(n,".codex/config.toml"),a=o(l)?s(l,"utf8"):"[features]\nhooks = true\n";for(let o of(a.includes("[[hooks.Stop]]")||(a=`${a.trimEnd()}
2
+
3
+ [[hooks.Stop]]
4
+ matcher = ".*"
5
+ `),[i,p])){let e=JSON.stringify(o);a.includes(`command = ${e}`)||(a=`${a.trimEnd()}
6
+
7
+ [[hooks.Stop.hooks]]
8
+ type = "command"
9
+ command = ${e}
10
+ `)}e(m(l),{recursive:!0}),t(l,a);let d=r(n,".claude/settings.json"),c=o(d)?JSON.parse(s(d,"utf8")):{};c.hooks??={},c.hooks.Stop??=[];let f=c.hooks.Stop.find(o=>o?.matcher===".*");for(let o of(f||(f={matcher:".*",hooks:[]},c.hooks.Stop.push(f)),f.hooks??=[],[i,p]))f.hooks.some(e=>e?.type==="command"&&e.command===o)||f.hooks.push({type:"command",command:o});e(m(d),{recursive:!0}),t(d,`${JSON.stringify(c,null,2)}
11
+ `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "4.11.4-beta.2",
3
+ "version": "4.11.5-beta.1",
4
4
  "description": "@moneko/core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",
@@ -165,6 +165,7 @@
165
165
  },
166
166
  "files": [
167
167
  "lib",
168
- "typings"
168
+ "typings",
169
+ "hooks"
169
170
  ]
170
171
  }
@@ -1,2 +0,0 @@
1
- declare function setup(): void;
2
- export default setup;
package/lib/bin/setup.mjs DELETED
@@ -1 +0,0 @@
1
- import m from"../commom/check-npm.mjs";import{corepack as o}from"../commom/corepack.mjs";import{CONFIG as c}from"../config.mjs";export default function(){o(c.corepack),m()};